agent-afk 5.291.0 → 5.291.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/providers/openai-compatible/loop.d.ts +4 -1
- package/dist/agent/providers/openai-compatible/responses-translate.d.ts +2 -0
- package/dist/cli.mjs +316 -316
- package/dist/improve/schemas.d.ts +2 -2
- package/dist/index.mjs +132 -132
- package/dist/telegram.mjs +154 -154
- package/dist/web-ui-assets/assets/{ada-bCR0ucgS.js → ada-BIOnG6TC.js} +1 -1
- package/dist/web-ui-assets/assets/{ahk-CsyLZFj1.js → ahk-BrbAagtO.js} +1 -1
- package/dist/web-ui-assets/assets/{angular-html-DA-rfuFy.js → angular-html-D_SYSyRt.js} +1 -1
- package/dist/web-ui-assets/assets/{angular-ts-BrjP3tb8.js → angular-ts-DGq0tZX5.js} +1 -1
- package/dist/web-ui-assets/assets/{apl-CORt7UWP.js → apl-ChzvTHjC.js} +1 -1
- package/dist/web-ui-assets/assets/{astro-HNnZUWAn.js → astro-DTjqU0_L.js} +1 -1
- package/dist/web-ui-assets/assets/beancount-BgSHGh8x.js +1 -0
- package/dist/web-ui-assets/assets/{blade-2xfisSek.js → blade-k33SngOZ.js} +1 -1
- package/dist/web-ui-assets/assets/{cobol-nBiQ_Alo.js → cobol-BBKr1ja6.js} +1 -1
- package/dist/web-ui-assets/assets/coq-BqXF5kFF.js +1 -0
- package/dist/web-ui-assets/assets/{crystal-DGywbUpC.js → crystal-LUwhHfY5.js} +1 -1
- package/dist/web-ui-assets/assets/csharp-B_TYUkTI.js +1 -0
- package/dist/web-ui-assets/assets/css-Z72CF80r.js +1 -0
- package/dist/web-ui-assets/assets/dart-CtKP3W-j.js +1 -0
- package/dist/web-ui-assets/assets/dotenv-De0Btta0.js +1 -0
- package/dist/web-ui-assets/assets/{edge-FbVlp4U3.js → edge-CJaD-t2L.js} +1 -1
- package/dist/web-ui-assets/assets/{elixir-CkH2-t6x.js → elixir-DkJLSxtU.js} +1 -1
- package/dist/web-ui-assets/assets/emacs-lisp-DaIrSCgJ.js +1 -0
- package/dist/web-ui-assets/assets/{erb-DXfck5VN.js → erb-CSMaCouu.js} +1 -1
- package/dist/web-ui-assets/assets/{glimmer-js-ByusRIyA.js → glimmer-js-Drrc9bTt.js} +1 -1
- package/dist/web-ui-assets/assets/{glimmer-ts-BfAWNZQY.js → glimmer-ts-zeybXsvi.js} +1 -1
- package/dist/web-ui-assets/assets/gn-8iBmfbXw.js +1 -0
- package/dist/web-ui-assets/assets/{hack-BWmVpMyf.js → hack-Ck6-gGSS.js} +1 -1
- package/dist/web-ui-assets/assets/{haml-D5jkg6IW.js → haml-GN_XdMnF.js} +1 -1
- package/dist/web-ui-assets/assets/handlebars-DPT5vKgj.js +1 -0
- package/dist/web-ui-assets/assets/{html-pp8916En.js → html-BlS82ilI.js} +1 -1
- package/dist/web-ui-assets/assets/{html-derivative-DlHx6ybY.js → html-derivative-DZhk3IEZ.js} +1 -1
- package/dist/web-ui-assets/assets/{index-gg5vv6YH.js → index-CcN04Dl-.js} +1 -1
- package/dist/web-ui-assets/assets/{index-BtgJsRFJ.js → index-HrybHVLc.js} +16 -16
- package/dist/web-ui-assets/assets/{jinja-f2NsQr07.js → jinja-DFQZVq3b.js} +1 -1
- package/dist/web-ui-assets/assets/{julia-5Bft2YPA.js → julia-Cu79e8SL.js} +1 -1
- package/dist/web-ui-assets/assets/{just-Cwhn7H3k.js → just-CMxyWJJc.js} +1 -1
- package/dist/web-ui-assets/assets/latex-DJVikpzR.js +1 -0
- package/dist/web-ui-assets/assets/{liquid-C0sCDyMI.js → liquid-B-duXHXw.js} +1 -1
- package/dist/web-ui-assets/assets/luau-nOZpfvQi.js +1 -0
- package/dist/web-ui-assets/assets/marko-BYgDmDgU.js +1 -0
- package/dist/web-ui-assets/assets/{mdc-D1_yUvq7.js → mdc-DF4WjDMn.js} +1 -1
- package/dist/web-ui-assets/assets/monokai-CR4piiQ-.js +1 -0
- package/dist/web-ui-assets/assets/moonbit-Bag4Rp_g.js +1 -0
- package/dist/web-ui-assets/assets/nextflow-BCxp2Aob.js +1 -0
- package/dist/web-ui-assets/assets/{nextflow-groovy-vE_lwT2v.js → nextflow-groovy-CedDknKX.js} +1 -1
- package/dist/web-ui-assets/assets/{nim-BIad80T-.js → nim-nV83PyhX.js} +1 -1
- package/dist/web-ui-assets/assets/nushell-BXD5iret.js +1 -0
- package/dist/web-ui-assets/assets/one-dark-pro-CxGP3dtY.js +1 -0
- package/dist/web-ui-assets/assets/{org-DM6o9KBp.js → org-6a7ccXN_.js} +1 -1
- package/dist/web-ui-assets/assets/{perl-B9cMNwum.js → perl-5klg-GXX.js} +1 -1
- package/dist/web-ui-assets/assets/php-DoruYMF0.js +1 -0
- package/dist/web-ui-assets/assets/{powershell-BmBUJMz7.js → powershell-Dd0kTxKP.js} +1 -1
- package/dist/web-ui-assets/assets/{pug-DKIMFp6K.js → pug-BtYPkAgq.js} +1 -1
- package/dist/web-ui-assets/assets/{razor-BjBPvh-w.js → razor-CyjPwjZj.js} +1 -1
- package/dist/web-ui-assets/assets/red-DMbB5_pp.js +1 -0
- package/dist/web-ui-assets/assets/{rst-bs7f0vWN.js → rst-CVOjT0e7.js} +1 -1
- package/dist/web-ui-assets/assets/{ruby-C0TQ7zu5.js → ruby-C8rp0wew.js} +1 -1
- package/dist/web-ui-assets/assets/rust-DPvrY3IQ.js +1 -0
- package/dist/web-ui-assets/assets/{sas-DEy46yEz.js → sas-BGn39htG.js} +1 -1
- package/dist/web-ui-assets/assets/{scss-D5BDwBP9.js → scss-Cw6XMfVs.js} +1 -1
- package/dist/web-ui-assets/assets/solarized-dark-UcubFVte.js +1 -0
- package/dist/web-ui-assets/assets/solarized-light-DCG28T6R.js +1 -0
- package/dist/web-ui-assets/assets/{soy-8wufbnw4.js → soy-zscZBeg6.js} +1 -1
- package/dist/web-ui-assets/assets/sql-DkvoVjww.js +1 -0
- package/dist/web-ui-assets/assets/{stata-DI20mbqo.js → stata-DACIj5bg.js} +1 -1
- package/dist/web-ui-assets/assets/{svelte-Cy7k_4gC.js → svelte-D84K1R2Q.js} +1 -1
- package/dist/web-ui-assets/assets/{templ-DhtptRzy.js → templ-Vpw5XpSW.js} +1 -1
- package/dist/web-ui-assets/assets/{ts-tags-D351s5mN.js → ts-tags-Ls60c9xG.js} +1 -1
- package/dist/web-ui-assets/assets/twig-D9-LOF2p.js +1 -0
- package/dist/web-ui-assets/assets/typespec-ClX509-Q.js +1 -0
- package/dist/web-ui-assets/assets/{typst-BUadGCkm.js → typst-DamkJZ1Q.js} +1 -1
- package/dist/web-ui-assets/assets/{vue-BqiEGhQt.js → vue-DSqPwMUe.js} +1 -1
- package/dist/web-ui-assets/assets/{vue-vine-BoDAl6tE.js → vue-vine-C0RcJ6UU.js} +1 -1
- package/dist/web-ui-assets/index.html +1 -1
- package/package.json +5 -5
- package/dist/web-ui-assets/assets/beancount-k_qm7-4y.js +0 -1
- package/dist/web-ui-assets/assets/coq-C7JzOVbR.js +0 -1
- package/dist/web-ui-assets/assets/csharp-DSvCPggb.js +0 -1
- package/dist/web-ui-assets/assets/css-CLj8gQPS.js +0 -1
- package/dist/web-ui-assets/assets/dart-bE4Kk8sk.js +0 -1
- package/dist/web-ui-assets/assets/dotenv-Da5cRb03.js +0 -1
- package/dist/web-ui-assets/assets/emacs-lisp-C_m_b--Z.js +0 -1
- package/dist/web-ui-assets/assets/gn-n2N0HUVH.js +0 -1
- package/dist/web-ui-assets/assets/handlebars-BpdQsYii.js +0 -1
- package/dist/web-ui-assets/assets/latex-D5pSuvFb.js +0 -1
- package/dist/web-ui-assets/assets/luau-BnpPk5vE.js +0 -1
- package/dist/web-ui-assets/assets/marko-DjSrsDqO.js +0 -1
- package/dist/web-ui-assets/assets/monokai-BRVnQi9A.js +0 -1
- package/dist/web-ui-assets/assets/moonbit-CHtswR0a.js +0 -1
- package/dist/web-ui-assets/assets/nextflow-C-mBbutL.js +0 -1
- package/dist/web-ui-assets/assets/nushell-D3jzshHO.js +0 -1
- package/dist/web-ui-assets/assets/one-dark-pro-DVMEJ2y_.js +0 -1
- package/dist/web-ui-assets/assets/php-Csjmro_R.js +0 -1
- package/dist/web-ui-assets/assets/red-hvxz__6c.js +0 -1
- package/dist/web-ui-assets/assets/rust-B1yitclQ.js +0 -1
- package/dist/web-ui-assets/assets/solarized-dark-CpvCGNkr.js +0 -1
- package/dist/web-ui-assets/assets/solarized-light-Dlz6yCKv.js +0 -1
- package/dist/web-ui-assets/assets/sql-CRqJ_cUM.js +0 -1
- package/dist/web-ui-assets/assets/twig-27uCiNez.js +0 -1
- package/dist/web-ui-assets/assets/typespec-CAFt9gP4.js +0 -1
|
@@ -371,7 +371,7 @@ Error generating stack: `+i.message+`
|
|
|
371
371
|
`))+1))}const c="#".repeat(o),m=a.enter("headingAtx"),h=a.enter("phrasing");f.move(c+" ");let g=a.containerPhrasing(t,{before:"# ",after:`
|
|
372
372
|
`,...f.current()});return/^[\t ]/.test(g)&&(g=su(g.charCodeAt(0))+g.slice(1)),g=g?c+" "+g:c,a.options.closeAtx&&(g+=" "+c),h(),m(),g}f1.peek=V5;function f1(t){return t.value||""}function V5(){return"<"}d1.peek=Y5;function d1(t,r,a,u){const o=Xm(a),f=o==='"'?"Quote":"Apostrophe",c=a.enter("image");let m=a.enter("label");const h=a.createTracker(u);let g=h.move("![");return g+=h.move(a.safe(t.alt,{before:g,after:"]",...h.current()})),g+=h.move("]("),m(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(m=a.enter("destinationLiteral"),g+=h.move("<"),g+=h.move(a.safe(t.url,{before:g,after:">",...h.current()})),g+=h.move(">")):(m=a.enter("destinationRaw"),g+=h.move(a.safe(t.url,{before:g,after:t.title?" ":")",...h.current()}))),m(),t.title&&(m=a.enter(`title${f}`),g+=h.move(" "+o),g+=h.move(a.safe(t.title,{before:g,after:o,...h.current()})),g+=h.move(o),m()),g+=h.move(")"),c(),g}function Y5(){return"!"}m1.peek=G5;function m1(t,r,a,u){const o=t.referenceType,f=a.enter("imageReference");let c=a.enter("label");const m=a.createTracker(u);let h=m.move("![");const g=a.safe(t.alt,{before:h,after:"]",...m.current()});h+=m.move(g+"]["),c();const y=a.stack;a.stack=[],c=a.enter("reference");const p=a.safe(a.associationId(t),{before:h,after:"]",...m.current()});return c(),a.stack=y,f(),o==="full"||!g||g!==p?h+=m.move(p+"]"):o==="shortcut"?h=h.slice(0,-1):h+=m.move("]"),h}function G5(){return"!"}h1.peek=F5;function h1(t,r,a){let u=t.value||"",o="`",f=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(u);)o+="`";for(/[^ \r\n]/.test(u)&&(/^[ \r\n]/.test(u)&&/[ \r\n]$/.test(u)||/^`|`$/.test(u))&&(u=" "+u+" ");++f<a.unsafe.length;){const c=a.unsafe[f],m=a.compilePattern(c);let h;if(c.atBreak)for(;h=m.exec(u);){let g=h.index;u.charCodeAt(g)===10&&u.charCodeAt(g-1)===13&&g--,u=u.slice(0,g)+" "+u.slice(h.index+1)}}return o+u+o}function F5(){return"`"}function p1(t,r){const a=Um(t);return!!(!r.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(a===t.url||"mailto:"+a===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}g1.peek=X5;function g1(t,r,a,u){const o=Xm(a),f=o==='"'?"Quote":"Apostrophe",c=a.createTracker(u);let m,h;if(p1(t,a)){const y=a.stack;a.stack=[],m=a.enter("autolink");let p=c.move("<");return p+=c.move(a.containerPhrasing(t,{before:p,after:">",...c.current()})),p+=c.move(">"),m(),a.stack=y,p}m=a.enter("link"),h=a.enter("label");let g=c.move("[");return g+=c.move(a.containerPhrasing(t,{before:g,after:"](",...c.current()})),g+=c.move("]("),h(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(h=a.enter("destinationLiteral"),g+=c.move("<"),g+=c.move(a.safe(t.url,{before:g,after:">",...c.current()})),g+=c.move(">")):(h=a.enter("destinationRaw"),g+=c.move(a.safe(t.url,{before:g,after:t.title?" ":")",...c.current()}))),h(),t.title&&(h=a.enter(`title${f}`),g+=c.move(" "+o),g+=c.move(a.safe(t.title,{before:g,after:o,...c.current()})),g+=c.move(o),h()),g+=c.move(")"),m(),g}function X5(t,r,a){return p1(t,a)?"<":"["}y1.peek=Q5;function y1(t,r,a,u){const o=t.referenceType,f=a.enter("linkReference");let c=a.enter("label");const m=a.createTracker(u);let h=m.move("[");const g=a.containerPhrasing(t,{before:h,after:"]",...m.current()});h+=m.move(g+"]["),c();const y=a.stack;a.stack=[],c=a.enter("reference");const p=a.safe(a.associationId(t),{before:h,after:"]",...m.current()});return c(),a.stack=y,f(),o==="full"||!g||g!==p?h+=m.move(p+"]"):o==="shortcut"?h=h.slice(0,-1):h+=m.move("]"),h}function Q5(){return"["}function Qm(t){const r=t.options.bullet||"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bullet`, expected `*`, `+`, or `-`");return r}function Z5(t){const r=Qm(t),a=t.options.bulletOther;if(!a)return r==="*"?"-":"*";if(a!=="*"&&a!=="+"&&a!=="-")throw new Error("Cannot serialize items with `"+a+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(a===r)throw new Error("Expected `bullet` (`"+r+"`) and `bulletOther` (`"+a+"`) to be different");return a}function K5(t){const r=t.options.bulletOrdered||".";if(r!=="."&&r!==")")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOrdered`, expected `.` or `)`");return r}function b1(t){const r=t.options.rule||"*";if(r!=="*"&&r!=="-"&&r!=="_")throw new Error("Cannot serialize rules with `"+r+"` for `options.rule`, expected `*`, `-`, or `_`");return r}function P5(t,r,a,u){const o=a.enter("list"),f=a.bulletCurrent;let c=t.ordered?K5(a):Qm(a);const m=t.ordered?c==="."?")":".":Z5(a);let h=r&&a.bulletLastUsed?c===a.bulletLastUsed:!1;if(!t.ordered){const y=t.children?t.children[0]:void 0;if((c==="*"||c==="-")&&y&&(!y.children||!y.children[0])&&a.stack[a.stack.length-1]==="list"&&a.stack[a.stack.length-2]==="listItem"&&a.stack[a.stack.length-3]==="list"&&a.stack[a.stack.length-4]==="listItem"&&a.indexStack[a.indexStack.length-1]===0&&a.indexStack[a.indexStack.length-2]===0&&a.indexStack[a.indexStack.length-3]===0&&(h=!0),b1(a)===c&&y){let p=-1;for(;++p<t.children.length;){const v=t.children[p];if(v&&v.type==="listItem"&&v.children&&v.children[0]&&v.children[0].type==="thematicBreak"){h=!0;break}}}}h&&(c=m),a.bulletCurrent=c;const g=a.containerFlow(t,u);return a.bulletLastUsed=c,a.bulletCurrent=f,o(),g}function J5(t){const r=t.options.listItemIndent||"one";if(r!=="tab"&&r!=="one"&&r!=="mixed")throw new Error("Cannot serialize items with `"+r+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return r}function $5(t,r,a,u){const o=J5(a);let f=a.bulletCurrent||Qm(a);r&&r.type==="list"&&r.ordered&&(f=(typeof r.start=="number"&&r.start>-1?r.start:1)+(a.options.incrementListMarker===!1?0:r.children.indexOf(t))+f);let c=f.length+1;(o==="tab"||o==="mixed"&&(r&&r.type==="list"&&r.spread||t.spread))&&(c=Math.ceil(c/4)*4);const m=a.createTracker(u);m.move(f+" ".repeat(c-f.length)),m.shift(c);const h=a.enter("listItem"),g=a.indentLines(a.containerFlow(t,m.current()),y);return h(),g;function y(p,v,S){return v?(S?"":" ".repeat(c))+p:(S?f:f+" ".repeat(c-f.length))+p}}function W5(t,r,a,u){const o=a.enter("paragraph"),f=a.enter("phrasing"),c=a.containerPhrasing(t,u);return f(),o(),c}const e_=ws(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function t_(t,r,a,u){return(t.children.some(function(c){return e_(c)})?a.containerPhrasing:a.containerFlow).call(a,t,u)}function n_(t){const r=t.options.strong||"*";if(r!=="*"&&r!=="_")throw new Error("Cannot serialize strong with `"+r+"` for `options.strong`, expected `*`, or `_`");return r}x1.peek=l_;function x1(t,r,a,u){const o=n_(a),f=a.enter("strong"),c=a.createTracker(u),m=c.move(o+o);let h=c.move(a.containerPhrasing(t,{after:o,before:m,...c.current()}));const g=h.charCodeAt(0),y=ps(u.before.charCodeAt(u.before.length-1),g,o);y.inside&&(h=su(g)+h.slice(1));const p=h.charCodeAt(h.length-1),v=ps(u.after.charCodeAt(0),p,o);v.inside&&(h=h.slice(0,-1)+su(p));const S=c.move(o+o);return f(),a.attentionEncodeSurroundingInfo={after:v.outside,before:y.outside},m+h+S}function l_(t,r,a){return a.options.strong||"*"}function r_(t,r,a,u){return a.safe(t.value,u)}function a_(t){const r=t.options.ruleRepetition||3;if(r<3)throw new Error("Cannot serialize rules with repetition `"+r+"` for `options.ruleRepetition`, expected `3` or more");return r}function i_(t,r,a){const u=(b1(a)+(a.options.ruleSpaces?" ":"")).repeat(a_(a));return a.options.ruleSpaces?u.slice(0,-1):u}const v1={blockquote:j5,break:Rb,code:R5,definition:U5,emphasis:c1,hardBreak:Rb,heading:I5,html:f1,image:d1,imageReference:m1,inlineCode:h1,link:g1,linkReference:y1,list:P5,listItem:$5,paragraph:W5,root:t_,strong:x1,text:r_,thematicBreak:i_};function u_(){return{enter:{table:o_,tableData:Lb,tableHeader:Lb,tableRow:c_},exit:{codeText:f_,table:s_,tableData:Md,tableHeader:Md,tableRow:Md}}}function o_(t){const r=t._align;this.enter({type:"table",align:r.map(function(a){return a==="none"?null:a}),children:[]},t),this.data.inTable=!0}function s_(t){this.exit(t),this.data.inTable=void 0}function c_(t){this.enter({type:"tableRow",children:[]},t)}function Md(t){this.exit(t)}function Lb(t){this.enter({type:"tableCell",children:[]},t)}function f_(t){let r=this.resume();this.data.inTable&&(r=r.replace(/\\([\\|])/g,d_));const a=this.stack[this.stack.length-1];a.type,a.value=r,this.exit(t)}function d_(t,r){return r==="|"?r:t}function m_(t){const r=t||{},a=r.tableCellPadding,u=r.tablePipeAlign,o=r.stringLength,f=a?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
373
373
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:v,table:c,tableCell:h,tableRow:m}};function c(S,E,T,j){return g(y(S,T,j),S.align)}function m(S,E,T,j){const A=p(S,T,j),D=g([A]);return D.slice(0,D.indexOf(`
|
|
374
|
-
`))}function h(S,E,T,j){const A=T.enter("tableCell"),D=T.enter("phrasing"),L=T.containerPhrasing(S,{...j,before:f,after:f});return D(),A(),L}function g(S,E){return N5(S,{align:E,alignDelimiters:u,padding:a,stringLength:o})}function y(S,E,T){const j=S.children;let A=-1;const D=[],L=E.enter("table");for(;++A<j.length;)D[A]=p(j[A],E,T);return L(),D}function p(S,E,T){const j=S.children;let A=-1;const D=[],L=E.enter("tableRow");for(;++A<j.length;)D[A]=h(j[A],S,E,T);return L(),D}function v(S,E,T){let j=v1.inlineCode(S,E,T);return T.stack.includes("tableCell")&&(j=j.replace(/\|/g,"\\$&")),j}}function h_(){return{exit:{taskListCheckValueChecked:Ub,taskListCheckValueUnchecked:Ub,paragraph:g_}}}function p_(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:y_}}}function Ub(t){const r=this.stack[this.stack.length-2];r.type,r.checked=t.type==="taskListCheckValueChecked"}function g_(t){const r=this.stack[this.stack.length-2];if(r&&r.type==="listItem"&&typeof r.checked=="boolean"){const a=this.stack[this.stack.length-1];a.type;const u=a.children[0];if(u&&u.type==="text"){const o=r.children;let f=-1,c;for(;++f<o.length;){const m=o[f];if(m.type==="paragraph"){c=m;break}}c===a&&(u.value=u.value.slice(1),u.value.length===0?a.children.shift():a.position&&u.position&&typeof u.position.start.offset=="number"&&(u.position.start.column++,u.position.start.offset++,a.position.start=Object.assign({},u.position.start)))}}this.exit(t)}function y_(t,r,a,u){const o=t.children[0],f=typeof t.checked=="boolean"&&o&&o.type==="paragraph",c="["+(t.checked?"x":" ")+"] ",m=a.createTracker(u);f&&m.move(c);let h=v1.listItem(t,r,a,{...u,...m.current()});return f&&(h=h.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,g)),h;function g(y){return y+c}}function b_(){return[Pj(),y5(),S5(),u_(),h_()]}function x_(t){return{extensions:[Jj(),b5(t),w5(),m_(t),p_()]}}const v_={tokenize:T_,partial:!0},S1={tokenize:N_,partial:!0},w1={tokenize:A_,partial:!0},k1={tokenize:j_,partial:!0},S_={tokenize:__,partial:!0},E1={name:"wwwAutolink",tokenize:E_,previous:T1},C1={name:"protocolAutolink",tokenize:C_,previous:N1},Tl={name:"emailAutolink",tokenize:k_,previous:A1},nl={};function w_(){return{text:nl}}let Or=48;for(;Or<123;)nl[Or]=Tl,Or++,Or===58?Or=65:Or===91&&(Or=97);nl[43]=Tl;nl[45]=Tl;nl[46]=Tl;nl[95]=Tl;nl[72]=[Tl,C1];nl[104]=[Tl,C1];nl[87]=[Tl,E1];nl[119]=[Tl,E1];function k_(t,r,a){const u=this;let o,f;return c;function c(p){return!fm(p)||!A1.call(u,u.previous)||Zm(u.events)?a(p):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),m(p))}function m(p){return fm(p)?(t.consume(p),m):p===64?(t.consume(p),h):a(p)}function h(p){return p===46?t.check(S_,y,g)(p):p===45||p===95||Mt(p)?(f=!0,t.consume(p),h):y(p)}function g(p){return t.consume(p),o=!0,h}function y(p){return f&&o&&It(u.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),r(p)):a(p)}}function E_(t,r,a){const u=this;return o;function o(c){return c!==87&&c!==119||!T1.call(u,u.previous)||Zm(u.events)?a(c):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(v_,t.attempt(S1,t.attempt(w1,f),a),a)(c))}function f(c){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),r(c)}}function C_(t,r,a){const u=this;let o="",f=!1;return c;function c(p){return(p===72||p===104)&&N1.call(u,u.previous)&&!Zm(u.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),o+=String.fromCodePoint(p),t.consume(p),m):a(p)}function m(p){if(It(p)&&o.length<5)return o+=String.fromCodePoint(p),t.consume(p),m;if(p===58){const v=o.toLowerCase();if(v==="http"||v==="https")return t.consume(p),h}return a(p)}function h(p){return p===47?(t.consume(p),f?g:(f=!0,h)):a(p)}function g(p){return p===null||ds(p)||tt(p)||Br(p)||xs(p)?a(p):t.attempt(S1,t.attempt(w1,y),a)(p)}function y(p){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),r(p)}}function T_(t,r,a){let u=0;return o;function o(c){return(c===87||c===119)&&u<3?(u++,t.consume(c),o):c===46&&u===3?(t.consume(c),f):a(c)}function f(c){return c===null?a(c):r(c)}}function N_(t,r,a){let u,o,f;return c;function c(g){return g===46||g===95?t.check(k1,h,m)(g):g===null||tt(g)||Br(g)||g!==45&&xs(g)?h(g):(f=!0,t.consume(g),c)}function m(g){return g===95?u=!0:(o=u,u=void 0),t.consume(g),c}function h(g){return o||u||!f?a(g):r(g)}}function A_(t,r){let a=0,u=0;return o;function o(c){return c===40?(a++,t.consume(c),o):c===41&&u<a?f(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?t.check(k1,r,f)(c):c===null||tt(c)||Br(c)?r(c):(t.consume(c),o)}function f(c){return c===41&&u++,t.consume(c),o}}function j_(t,r,a){return u;function u(m){return m===33||m===34||m===39||m===41||m===42||m===44||m===46||m===58||m===59||m===63||m===95||m===126?(t.consume(m),u):m===38?(t.consume(m),f):m===93?(t.consume(m),o):m===60||m===null||tt(m)||Br(m)?r(m):a(m)}function o(m){return m===null||m===40||m===91||tt(m)||Br(m)?r(m):u(m)}function f(m){return It(m)?c(m):a(m)}function c(m){return m===59?(t.consume(m),u):It(m)?(t.consume(m),c):a(m)}}function __(t,r,a){return u;function u(f){return t.consume(f),o}function o(f){return Mt(f)?a(f):r(f)}}function T1(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||tt(t)}function N1(t){return!It(t)}function A1(t){return!(t===47||fm(t))}function fm(t){return t===43||t===45||t===46||t===95||Mt(t)}function Zm(t){let r=t.length,a=!1;for(;r--;){const u=t[r][1];if((u.type==="labelLink"||u.type==="labelImage")&&!u._balanced){a=!0;break}if(u._gfmAutolinkLiteralWalkedInto){a=!1;break}}return t.length>0&&!a&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),a}const z_={tokenize:H_,partial:!0};function O_(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:L_,continuation:{tokenize:U_},exit:B_}},text:{91:{name:"gfmFootnoteCall",tokenize:R_},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:M_,resolveTo:D_}}}}function M_(t,r,a){const u=this;let o=u.events.length;const f=u.parser.gfmFootnotes||(u.parser.gfmFootnotes=[]);let c;for(;o--;){const h=u.events[o][1];if(h.type==="labelImage"){c=h;break}if(h.type==="gfmFootnoteCall"||h.type==="labelLink"||h.type==="label"||h.type==="image"||h.type==="link")break}return m;function m(h){if(!c||!c._balanced)return a(h);const g=Ln(u.sliceSerialize({start:c.end,end:u.now()}));return g.codePointAt(0)!==94||!f.includes(g.slice(1))?a(h):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),r(h))}}function D_(t,r){let a=t.length;for(;a--;)if(t[a][1].type==="labelImage"&&t[a][0]==="enter"){t[a][1];break}t[a+1][1].type="data",t[a+3][1].type="gfmFootnoteCallLabelMarker";const u={type:"gfmFootnoteCall",start:Object.assign({},t[a+3][1].start),end:Object.assign({},t[t.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},t[a+3][1].end),end:Object.assign({},t[a+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const f={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},t[t.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},f.start),end:Object.assign({},f.end)},m=[t[a+1],t[a+2],["enter",u,r],t[a+3],t[a+4],["enter",o,r],["exit",o,r],["enter",f,r],["enter",c,r],["exit",c,r],["exit",f,r],t[t.length-2],t[t.length-1],["exit",u,r]];return t.splice(a,t.length-a+1,...m),t}function R_(t,r,a){const u=this,o=u.parser.gfmFootnotes||(u.parser.gfmFootnotes=[]);let f=0,c;return m;function m(p){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(p),t.exit("gfmFootnoteCallLabelMarker"),h}function h(p){return p!==94?a(p):(t.enter("gfmFootnoteCallMarker"),t.consume(p),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",g)}function g(p){if(f>999||p===93&&!c||p===null||p===91||tt(p))return a(p);if(p===93){t.exit("chunkString");const v=t.exit("gfmFootnoteCallString");return o.includes(Ln(u.sliceSerialize(v)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(p),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),r):a(p)}return tt(p)||(c=!0),f++,t.consume(p),p===92?y:g}function y(p){return p===91||p===92||p===93?(t.consume(p),f++,g):g(p)}}function L_(t,r,a){const u=this,o=u.parser.gfmFootnotes||(u.parser.gfmFootnotes=[]);let f,c=0,m;return h;function h(E){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(E),t.exit("gfmFootnoteDefinitionLabelMarker"),g}function g(E){return E===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(E),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",y):a(E)}function y(E){if(c>999||E===93&&!m||E===null||E===91||tt(E))return a(E);if(E===93){t.exit("chunkString");const T=t.exit("gfmFootnoteDefinitionLabelString");return f=Ln(u.sliceSerialize(T)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(E),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),v}return tt(E)||(m=!0),c++,t.consume(E),E===92?p:y}function p(E){return E===91||E===92||E===93?(t.consume(E),c++,y):y(E)}function v(E){return E===58?(t.enter("definitionMarker"),t.consume(E),t.exit("definitionMarker"),o.includes(f)||o.push(f),Ie(t,S,"gfmFootnoteDefinitionWhitespace")):a(E)}function S(E){return r(E)}}function U_(t,r,a){return t.check(hu,r,t.attempt(z_,r,a))}function B_(t){t.exit("gfmFootnoteDefinition")}function H_(t,r,a){const u=this;return Ie(t,o,"gfmFootnoteDefinitionIndent",5);function o(f){const c=u.events[u.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?r(f):a(f)}}function q_(t){let a=(t||{}).singleTilde;const u={name:"strikethrough",tokenize:f,resolveAll:o};return a==null&&(a=!0),{text:{126:u},insideSpan:{null:[u]},attentionMarkers:{null:[126]}};function o(c,m){let h=-1;for(;++h<c.length;)if(c[h][0]==="enter"&&c[h][1].type==="strikethroughSequenceTemporary"&&c[h][1]._close){let g=h;for(;g--;)if(c[g][0]==="exit"&&c[g][1].type==="strikethroughSequenceTemporary"&&c[g][1]._open&&c[h][1].end.offset-c[h][1].start.offset===c[g][1].end.offset-c[g][1].start.offset){c[h][1].type="strikethroughSequence",c[g][1].type="strikethroughSequence";const y={type:"strikethrough",start:Object.assign({},c[g][1].start),end:Object.assign({},c[h][1].end)},p={type:"strikethroughText",start:Object.assign({},c[g][1].end),end:Object.assign({},c[h][1].start)},v=[["enter",y,m],["enter",c[g][1],m],["exit",c[g][1],m],["enter",p,m]],S=m.parser.constructs.insideSpan.null;S&&mn(v,v.length,0,vs(S,c.slice(g+1,h),m)),mn(v,v.length,0,[["exit",p,m],["enter",c[h][1],m],["exit",c[h][1],m],["exit",y,m]]),mn(c,g-1,h-g+3,v),h=g+v.length-2;break}}for(h=-1;++h<c.length;)c[h][1].type==="strikethroughSequenceTemporary"&&(c[h][1].type="data");return c}function f(c,m,h){const g=this.previous,y=this.events;let p=0;return v;function v(E){return g===126&&y[y.length-1][1].type!=="characterEscape"?h(E):(c.enter("strikethroughSequenceTemporary"),S(E))}function S(E){const T=Qa(g);if(E===126)return p>1?h(E):(c.consume(E),p++,S);if(p<2&&!a)return h(E);const j=c.exit("strikethroughSequenceTemporary"),A=Qa(E);return j._open=!A||A===2&&!!T,j._close=!T||T===2&&!!A,m(E)}}}class I_{constructor(){this.map=[]}add(r,a,u){V_(this,r,a,u)}consume(r){if(this.map.sort(function(f,c){return f[0]-c[0]}),this.map.length===0)return;let a=this.map.length;const u=[];for(;a>0;)a-=1,u.push(r.slice(this.map[a][0]+this.map[a][1]),this.map[a][2]),r.length=this.map[a][0];u.push(r.slice()),r.length=0;let o=u.pop();for(;o;){for(const f of o)r.push(f);o=u.pop()}this.map.length=0}}function V_(t,r,a,u){let o=0;if(!(a===0&&u.length===0)){for(;o<t.map.length;){if(t.map[o][0]===r){t.map[o][1]+=a,t.map[o][2].push(...u);return}o+=1}t.map.push([r,a,u])}}function Y_(t,r){let a=!1;const u=[];for(;r<t.length;){const o=t[r];if(a){if(o[0]==="enter")o[1].type==="tableContent"&&u.push(t[r+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(t[r-1][1].type==="tableDelimiterMarker"){const f=u.length-1;u[f]=u[f]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(a=!0);r+=1}return u}function G_(){return{flow:{null:{name:"table",tokenize:F_,resolveAll:X_}}}}function F_(t,r,a){const u=this;let o=0,f=0,c;return m;function m(H){let ne=u.events.length-1;for(;ne>-1;){const se=u.events[ne][1].type;if(se==="lineEnding"||se==="linePrefix")ne--;else break}const J=ne>-1?u.events[ne][1].type:null,ve=J==="tableHead"||J==="tableRow"?M:h;return ve===M&&u.parser.lazy[u.now().line]?a(H):ve(H)}function h(H){return t.enter("tableHead"),t.enter("tableRow"),g(H)}function g(H){return H===124||(c=!0,f+=1),y(H)}function y(H){return H===null?a(H):we(H)?f>1?(f=0,u.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(H),t.exit("lineEnding"),S):a(H):Ue(H)?Ie(t,y,"whitespace")(H):(f+=1,c&&(c=!1,o+=1),H===124?(t.enter("tableCellDivider"),t.consume(H),t.exit("tableCellDivider"),c=!0,y):(t.enter("data"),p(H)))}function p(H){return H===null||H===124||tt(H)?(t.exit("data"),y(H)):(t.consume(H),H===92?v:p)}function v(H){return H===92||H===124?(t.consume(H),p):p(H)}function S(H){return u.interrupt=!1,u.parser.lazy[u.now().line]?a(H):(t.enter("tableDelimiterRow"),c=!1,Ue(H)?Ie(t,E,"linePrefix",u.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(H):E(H))}function E(H){return H===45||H===58?j(H):H===124?(c=!0,t.enter("tableCellDivider"),t.consume(H),t.exit("tableCellDivider"),T):W(H)}function T(H){return Ue(H)?Ie(t,j,"whitespace")(H):j(H)}function j(H){return H===58?(f+=1,c=!0,t.enter("tableDelimiterMarker"),t.consume(H),t.exit("tableDelimiterMarker"),A):H===45?(f+=1,A(H)):H===null||we(H)?P(H):W(H)}function A(H){return H===45?(t.enter("tableDelimiterFiller"),D(H)):W(H)}function D(H){return H===45?(t.consume(H),D):H===58?(c=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(H),t.exit("tableDelimiterMarker"),L):(t.exit("tableDelimiterFiller"),L(H))}function L(H){return Ue(H)?Ie(t,P,"whitespace")(H):P(H)}function P(H){return H===124?E(H):H===null||we(H)?!c||o!==f?W(H):(t.exit("tableDelimiterRow"),t.exit("tableHead"),r(H)):W(H)}function W(H){return a(H)}function M(H){return t.enter("tableRow"),F(H)}function F(H){return H===124?(t.enter("tableCellDivider"),t.consume(H),t.exit("tableCellDivider"),F):H===null||we(H)?(t.exit("tableRow"),r(H)):Ue(H)?Ie(t,F,"whitespace")(H):(t.enter("data"),q(H))}function q(H){return H===null||H===124||tt(H)?(t.exit("data"),F(H)):(t.consume(H),H===92?ie:q)}function ie(H){return H===92||H===124?(t.consume(H),q):q(H)}}function X_(t,r){let a=-1,u=!0,o=0,f=[0,0,0,0],c=[0,0,0,0],m=!1,h=0,g,y,p;const v=new I_;for(;++a<t.length;){const S=t[a],E=S[1];S[0]==="enter"?E.type==="tableHead"?(m=!1,h!==0&&(Bb(v,r,h,g,y),y=void 0,h=0),g={type:"table",start:Object.assign({},E.start),end:Object.assign({},E.end)},v.add(a,0,[["enter",g,r]])):E.type==="tableRow"||E.type==="tableDelimiterRow"?(u=!0,p=void 0,f=[0,0,0,0],c=[0,a+1,0,0],m&&(m=!1,y={type:"tableBody",start:Object.assign({},E.start),end:Object.assign({},E.end)},v.add(a,0,[["enter",y,r]])),o=E.type==="tableDelimiterRow"?2:y?3:1):o&&(E.type==="data"||E.type==="tableDelimiterMarker"||E.type==="tableDelimiterFiller")?(u=!1,c[2]===0&&(f[1]!==0&&(c[0]=c[1],p=ls(v,r,f,o,void 0,p),f=[0,0,0,0]),c[2]=a)):E.type==="tableCellDivider"&&(u?u=!1:(f[1]!==0&&(c[0]=c[1],p=ls(v,r,f,o,void 0,p)),f=c,c=[f[1],a,0,0])):E.type==="tableHead"?(m=!0,h=a):E.type==="tableRow"||E.type==="tableDelimiterRow"?(h=a,f[1]!==0?(c[0]=c[1],p=ls(v,r,f,o,a,p)):c[1]!==0&&(p=ls(v,r,c,o,a,p)),o=0):o&&(E.type==="data"||E.type==="tableDelimiterMarker"||E.type==="tableDelimiterFiller")&&(c[3]=a)}for(h!==0&&Bb(v,r,h,g,y),v.consume(r.events),a=-1;++a<r.events.length;){const S=r.events[a];S[0]==="enter"&&S[1].type==="table"&&(S[1]._align=Y_(r.events,a))}return t}function ls(t,r,a,u,o,f){const c=u===1?"tableHeader":u===2?"tableDelimiter":"tableData",m="tableContent";a[0]!==0&&(f.end=Object.assign({},Va(r.events,a[0])),t.add(a[0],0,[["exit",f,r]]));const h=Va(r.events,a[1]);if(f={type:c,start:Object.assign({},h),end:Object.assign({},h)},t.add(a[1],0,[["enter",f,r]]),a[2]!==0){const g=Va(r.events,a[2]),y=Va(r.events,a[3]),p={type:m,start:Object.assign({},g),end:Object.assign({},y)};if(t.add(a[2],0,[["enter",p,r]]),u!==2){const v=r.events[a[2]],S=r.events[a[3]];if(v[1].end=Object.assign({},S[1].end),v[1].type="chunkText",v[1].contentType="text",a[3]>a[2]+1){const E=a[2]+1,T=a[3]-a[2]-1;t.add(E,T,[])}}t.add(a[3]+1,0,[["exit",p,r]])}return o!==void 0&&(f.end=Object.assign({},Va(r.events,o)),t.add(o,0,[["exit",f,r]]),f=void 0),f}function Bb(t,r,a,u,o){const f=[],c=Va(r.events,a);o&&(o.end=Object.assign({},c),f.push(["exit",o,r])),u.end=Object.assign({},c),f.push(["exit",u,r]),t.add(a+1,0,f)}function Va(t,r){const a=t[r],u=a[0]==="enter"?"start":"end";return a[1][u]}const Q_={name:"tasklistCheck",tokenize:K_};function Z_(){return{text:{91:Q_}}}function K_(t,r,a){const u=this;return o;function o(h){return u.previous!==null||!u._gfmTasklistFirstContentOfListItem?a(h):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(h),t.exit("taskListCheckMarker"),f)}function f(h){return tt(h)?(t.enter("taskListCheckValueUnchecked"),t.consume(h),t.exit("taskListCheckValueUnchecked"),c):h===88||h===120?(t.enter("taskListCheckValueChecked"),t.consume(h),t.exit("taskListCheckValueChecked"),c):a(h)}function c(h){return h===93?(t.enter("taskListCheckMarker"),t.consume(h),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),m):a(h)}function m(h){return we(h)?r(h):Ue(h)?t.check({tokenize:P_},r,a)(h):a(h)}}function P_(t,r,a){return Ie(t,u,"whitespace");function u(o){return o===null?a(o):r(o)}}function J_(t){return Bv([w_(),O_(),q_(t),G_(),Z_()])}const $_={};function W_(t){const r=this,a=t||$_,u=r.data(),o=u.micromarkExtensions||(u.micromarkExtensions=[]),f=u.fromMarkdownExtensions||(u.fromMarkdownExtensions=[]),c=u.toMarkdownExtensions||(u.toMarkdownExtensions=[]);o.push(J_(a)),f.push(b_()),c.push(x_(a))}const ez="modulepreload",tz=function(t){return"/"+t},Hb={},Km=function(r,a,u){let o=Promise.resolve();if(a&&a.length>0){let c=function(g){return Promise.all(g.map(y=>Promise.resolve(y).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const m=document.querySelector("meta[property=csp-nonce]"),h=(m==null?void 0:m.nonce)||(m==null?void 0:m.getAttribute("nonce"));o=c(a.map(g=>{if(g=tz(g),g in Hb)return;Hb[g]=!0;const y=g.endsWith(".css"),p=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${g}"]${p}`))return;const v=document.createElement("link");if(v.rel=y?"stylesheet":ez,y||(v.as="script"),v.crossOrigin="",v.href=g,h&&v.setAttribute("nonce",h),document.head.appendChild(v),y)return new Promise((S,E)=>{v.addEventListener("load",S),v.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${g}`)))})}))}function f(c){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=c,window.dispatchEvent(m),!m.defaultPrevented)throw c}return o.then(c=>{for(const m of c||[])m.status==="rejected"&&f(m.reason);return r().catch(f)})};let Dd=null;const Rd=new Map;function j1(){return Dd||(Dd=Km(async()=>{const{createHighlighter:t}=await import("./index-BtgJsRFJ.js");return{createHighlighter:t}},[]).then(({createHighlighter:t})=>t({themes:["github-dark"],langs:["plaintext"]}))),Dd}function nz(t){const r=Rd.get(t);if(r)return r;const a=Km(()=>import("./index-BtgJsRFJ.js"),[]).then(async({bundledLanguages:u,isSpecialLang:o})=>{if(o(t))return;const f=u[t];if(!f)throw new Error(`unknown lang: ${t}`);const c=await j1();c.getLoadedLanguages().includes(t)||await c.loadLanguage(f)}).catch(u=>{throw Rd.delete(t),u});return Rd.set(t,a),a}function lz({code:t,language:r}){const[a,u]=w.useState(null),[o,f]=w.useState(0),[c,m]=w.useState(!1),h=w.useRef(null);w.useEffect(()=>{let y=!1;async function p(){const v=await j1();if(y)return;let S="plaintext";if(r){const{isSpecialLang:E}=await Km(async()=>{const{isSpecialLang:j}=await import("./index-BtgJsRFJ.js");return{isSpecialLang:j}},[]),T=v.getLoadedLanguages();E(r)||T.includes(r)?S=r:(nz(r).then(()=>{y||f(j=>j+1)}).catch(()=>{}),S="plaintext")}try{const E=v.codeToHtml(t,{lang:S,theme:"github-dark"});y||u(E)}catch{}}return u(null),p().catch(()=>{}),()=>{y=!0}},[t,r,o]),w.useEffect(()=>()=>{h.current!==null&&clearTimeout(h.current)},[]);const g=w.useCallback(()=>{navigator.clipboard.writeText(t).then(()=>{m(!0),h.current!==null&&clearTimeout(h.current),h.current=setTimeout(()=>m(!1),2e3)}).catch(()=>{})},[t]);return b.jsxs("div",{className:"relative group rounded-md bg-secondary overflow-hidden mb-2",children:[r&&b.jsx("div",{className:"text-[10px] text-muted-foreground px-3 pt-1.5 select-none",children:r}),b.jsx("button",{onClick:g,"aria-label":"Copy code",className:"absolute top-1.5 right-2 z-10 opacity-0 group-hover:opacity-100 transition-opacity rounded p-1 text-muted-foreground hover:text-foreground hover:bg-white/10",children:c?b.jsx(gm,{size:13,strokeWidth:2.5}):b.jsx(Kb,{size:13,strokeWidth:2})}),a!==null?b.jsx("div",{className:"overflow-x-auto text-xs leading-5 [&>pre]:p-3 [&>pre]:m-0 [&>pre]:bg-transparent! [&>pre]:font-mono",dangerouslySetInnerHTML:{__html:a}}):b.jsx("pre",{className:"overflow-x-auto p-3 font-mono text-xs leading-5 text-foreground",children:b.jsx("code",{children:t})})]})}const rz={h1:({children:t})=>b.jsx("h1",{className:"mb-3 text-xl font-bold",children:t}),h2:({children:t})=>b.jsx("h2",{className:"mb-2 text-lg font-semibold",children:t}),h3:({children:t})=>b.jsx("h3",{className:"mb-1.5 text-base font-semibold",children:t}),p:({children:t})=>b.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed",children:t}),ul:({children:t})=>b.jsx("ul",{className:"mb-2 ml-4 list-disc space-y-0.5",children:t}),ol:({children:t})=>b.jsx("ol",{className:"mb-2 ml-4 list-decimal space-y-0.5",children:t}),li:({children:t})=>b.jsx("li",{className:"text-sm",children:t}),blockquote:({children:t})=>b.jsx("blockquote",{className:"mb-2 border-l-2 border-brand/50 pl-3 italic text-muted-foreground",children:t}),a:({href:t,children:r})=>t&&/^(https?:\/\/|\/(?!\/)|#)/i.test(t)?b.jsx("a",{href:t,className:"text-brand underline underline-offset-2 hover:text-brand/80",target:"_blank",rel:"noopener noreferrer",children:r}):b.jsx("span",{className:"text-muted-foreground",children:r}),strong:({children:t})=>b.jsx("strong",{className:"font-semibold text-foreground",children:t}),em:({children:t})=>b.jsx("em",{className:"italic text-muted-foreground",children:t}),hr:()=>b.jsx("hr",{className:"my-3 border-border"}),table:({children:t})=>b.jsx("div",{className:"mb-2 overflow-x-auto rounded border border-border",children:b.jsx("table",{className:"w-full text-sm",children:t})}),thead:({children:t})=>b.jsx("thead",{className:"bg-secondary text-secondary-foreground",children:t}),th:({children:t})=>b.jsx("th",{className:"px-3 py-1.5 text-left font-medium",children:t}),td:({children:t})=>b.jsx("td",{className:"border-t border-border px-3 py-1.5",children:t}),code:({children:t,className:r})=>{var u;return((u=/language-(\w+)/.exec(r??""))==null?void 0:u[1])?b.jsx("code",{className:oe("text-xs",r),children:t}):b.jsx("code",{className:"rounded bg-secondary px-1 py-0.5 font-mono text-[11px] text-foreground",children:t})},pre:({children:t})=>{var o,f,c;const r=t,a=(f=/language-(\w+)/.exec(((o=r==null?void 0:r.props)==null?void 0:o.className)??""))==null?void 0:f[1],u=String(((c=r==null?void 0:r.props)==null?void 0:c.children)??"").replace(/\n$/,"");return b.jsx(lz,{code:u,language:a})}};function _1({text:t,className:r}){return b.jsx("div",{className:oe("text-sm text-foreground",r),children:b.jsx(qj,{remarkPlugins:[W_],components:rz,children:t})})}function az(){return b.jsx("span",{className:"streaming-cursor","aria-hidden":"true"})}const iz=/^[ \t]*(`{3,}|~{4,})/;function uz(t,r){if(r>=t.length)return r;const a=t.lastIndexOf(`
|
|
374
|
+
`))}function h(S,E,T,j){const A=T.enter("tableCell"),D=T.enter("phrasing"),L=T.containerPhrasing(S,{...j,before:f,after:f});return D(),A(),L}function g(S,E){return N5(S,{align:E,alignDelimiters:u,padding:a,stringLength:o})}function y(S,E,T){const j=S.children;let A=-1;const D=[],L=E.enter("table");for(;++A<j.length;)D[A]=p(j[A],E,T);return L(),D}function p(S,E,T){const j=S.children;let A=-1;const D=[],L=E.enter("tableRow");for(;++A<j.length;)D[A]=h(j[A],S,E,T);return L(),D}function v(S,E,T){let j=v1.inlineCode(S,E,T);return T.stack.includes("tableCell")&&(j=j.replace(/\|/g,"\\$&")),j}}function h_(){return{exit:{taskListCheckValueChecked:Ub,taskListCheckValueUnchecked:Ub,paragraph:g_}}}function p_(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:y_}}}function Ub(t){const r=this.stack[this.stack.length-2];r.type,r.checked=t.type==="taskListCheckValueChecked"}function g_(t){const r=this.stack[this.stack.length-2];if(r&&r.type==="listItem"&&typeof r.checked=="boolean"){const a=this.stack[this.stack.length-1];a.type;const u=a.children[0];if(u&&u.type==="text"){const o=r.children;let f=-1,c;for(;++f<o.length;){const m=o[f];if(m.type==="paragraph"){c=m;break}}c===a&&(u.value=u.value.slice(1),u.value.length===0?a.children.shift():a.position&&u.position&&typeof u.position.start.offset=="number"&&(u.position.start.column++,u.position.start.offset++,a.position.start=Object.assign({},u.position.start)))}}this.exit(t)}function y_(t,r,a,u){const o=t.children[0],f=typeof t.checked=="boolean"&&o&&o.type==="paragraph",c="["+(t.checked?"x":" ")+"] ",m=a.createTracker(u);f&&m.move(c);let h=v1.listItem(t,r,a,{...u,...m.current()});return f&&(h=h.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,g)),h;function g(y){return y+c}}function b_(){return[Pj(),y5(),S5(),u_(),h_()]}function x_(t){return{extensions:[Jj(),b5(t),w5(),m_(t),p_()]}}const v_={tokenize:T_,partial:!0},S1={tokenize:N_,partial:!0},w1={tokenize:A_,partial:!0},k1={tokenize:j_,partial:!0},S_={tokenize:__,partial:!0},E1={name:"wwwAutolink",tokenize:E_,previous:T1},C1={name:"protocolAutolink",tokenize:C_,previous:N1},Tl={name:"emailAutolink",tokenize:k_,previous:A1},nl={};function w_(){return{text:nl}}let Or=48;for(;Or<123;)nl[Or]=Tl,Or++,Or===58?Or=65:Or===91&&(Or=97);nl[43]=Tl;nl[45]=Tl;nl[46]=Tl;nl[95]=Tl;nl[72]=[Tl,C1];nl[104]=[Tl,C1];nl[87]=[Tl,E1];nl[119]=[Tl,E1];function k_(t,r,a){const u=this;let o,f;return c;function c(p){return!fm(p)||!A1.call(u,u.previous)||Zm(u.events)?a(p):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),m(p))}function m(p){return fm(p)?(t.consume(p),m):p===64?(t.consume(p),h):a(p)}function h(p){return p===46?t.check(S_,y,g)(p):p===45||p===95||Mt(p)?(f=!0,t.consume(p),h):y(p)}function g(p){return t.consume(p),o=!0,h}function y(p){return f&&o&&It(u.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),r(p)):a(p)}}function E_(t,r,a){const u=this;return o;function o(c){return c!==87&&c!==119||!T1.call(u,u.previous)||Zm(u.events)?a(c):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(v_,t.attempt(S1,t.attempt(w1,f),a),a)(c))}function f(c){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),r(c)}}function C_(t,r,a){const u=this;let o="",f=!1;return c;function c(p){return(p===72||p===104)&&N1.call(u,u.previous)&&!Zm(u.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),o+=String.fromCodePoint(p),t.consume(p),m):a(p)}function m(p){if(It(p)&&o.length<5)return o+=String.fromCodePoint(p),t.consume(p),m;if(p===58){const v=o.toLowerCase();if(v==="http"||v==="https")return t.consume(p),h}return a(p)}function h(p){return p===47?(t.consume(p),f?g:(f=!0,h)):a(p)}function g(p){return p===null||ds(p)||tt(p)||Br(p)||xs(p)?a(p):t.attempt(S1,t.attempt(w1,y),a)(p)}function y(p){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),r(p)}}function T_(t,r,a){let u=0;return o;function o(c){return(c===87||c===119)&&u<3?(u++,t.consume(c),o):c===46&&u===3?(t.consume(c),f):a(c)}function f(c){return c===null?a(c):r(c)}}function N_(t,r,a){let u,o,f;return c;function c(g){return g===46||g===95?t.check(k1,h,m)(g):g===null||tt(g)||Br(g)||g!==45&&xs(g)?h(g):(f=!0,t.consume(g),c)}function m(g){return g===95?u=!0:(o=u,u=void 0),t.consume(g),c}function h(g){return o||u||!f?a(g):r(g)}}function A_(t,r){let a=0,u=0;return o;function o(c){return c===40?(a++,t.consume(c),o):c===41&&u<a?f(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?t.check(k1,r,f)(c):c===null||tt(c)||Br(c)?r(c):(t.consume(c),o)}function f(c){return c===41&&u++,t.consume(c),o}}function j_(t,r,a){return u;function u(m){return m===33||m===34||m===39||m===41||m===42||m===44||m===46||m===58||m===59||m===63||m===95||m===126?(t.consume(m),u):m===38?(t.consume(m),f):m===93?(t.consume(m),o):m===60||m===null||tt(m)||Br(m)?r(m):a(m)}function o(m){return m===null||m===40||m===91||tt(m)||Br(m)?r(m):u(m)}function f(m){return It(m)?c(m):a(m)}function c(m){return m===59?(t.consume(m),u):It(m)?(t.consume(m),c):a(m)}}function __(t,r,a){return u;function u(f){return t.consume(f),o}function o(f){return Mt(f)?a(f):r(f)}}function T1(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||tt(t)}function N1(t){return!It(t)}function A1(t){return!(t===47||fm(t))}function fm(t){return t===43||t===45||t===46||t===95||Mt(t)}function Zm(t){let r=t.length,a=!1;for(;r--;){const u=t[r][1];if((u.type==="labelLink"||u.type==="labelImage")&&!u._balanced){a=!0;break}if(u._gfmAutolinkLiteralWalkedInto){a=!1;break}}return t.length>0&&!a&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),a}const z_={tokenize:H_,partial:!0};function O_(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:L_,continuation:{tokenize:U_},exit:B_}},text:{91:{name:"gfmFootnoteCall",tokenize:R_},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:M_,resolveTo:D_}}}}function M_(t,r,a){const u=this;let o=u.events.length;const f=u.parser.gfmFootnotes||(u.parser.gfmFootnotes=[]);let c;for(;o--;){const h=u.events[o][1];if(h.type==="labelImage"){c=h;break}if(h.type==="gfmFootnoteCall"||h.type==="labelLink"||h.type==="label"||h.type==="image"||h.type==="link")break}return m;function m(h){if(!c||!c._balanced)return a(h);const g=Ln(u.sliceSerialize({start:c.end,end:u.now()}));return g.codePointAt(0)!==94||!f.includes(g.slice(1))?a(h):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),r(h))}}function D_(t,r){let a=t.length;for(;a--;)if(t[a][1].type==="labelImage"&&t[a][0]==="enter"){t[a][1];break}t[a+1][1].type="data",t[a+3][1].type="gfmFootnoteCallLabelMarker";const u={type:"gfmFootnoteCall",start:Object.assign({},t[a+3][1].start),end:Object.assign({},t[t.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},t[a+3][1].end),end:Object.assign({},t[a+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const f={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},t[t.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},f.start),end:Object.assign({},f.end)},m=[t[a+1],t[a+2],["enter",u,r],t[a+3],t[a+4],["enter",o,r],["exit",o,r],["enter",f,r],["enter",c,r],["exit",c,r],["exit",f,r],t[t.length-2],t[t.length-1],["exit",u,r]];return t.splice(a,t.length-a+1,...m),t}function R_(t,r,a){const u=this,o=u.parser.gfmFootnotes||(u.parser.gfmFootnotes=[]);let f=0,c;return m;function m(p){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(p),t.exit("gfmFootnoteCallLabelMarker"),h}function h(p){return p!==94?a(p):(t.enter("gfmFootnoteCallMarker"),t.consume(p),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",g)}function g(p){if(f>999||p===93&&!c||p===null||p===91||tt(p))return a(p);if(p===93){t.exit("chunkString");const v=t.exit("gfmFootnoteCallString");return o.includes(Ln(u.sliceSerialize(v)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(p),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),r):a(p)}return tt(p)||(c=!0),f++,t.consume(p),p===92?y:g}function y(p){return p===91||p===92||p===93?(t.consume(p),f++,g):g(p)}}function L_(t,r,a){const u=this,o=u.parser.gfmFootnotes||(u.parser.gfmFootnotes=[]);let f,c=0,m;return h;function h(E){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(E),t.exit("gfmFootnoteDefinitionLabelMarker"),g}function g(E){return E===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(E),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",y):a(E)}function y(E){if(c>999||E===93&&!m||E===null||E===91||tt(E))return a(E);if(E===93){t.exit("chunkString");const T=t.exit("gfmFootnoteDefinitionLabelString");return f=Ln(u.sliceSerialize(T)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(E),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),v}return tt(E)||(m=!0),c++,t.consume(E),E===92?p:y}function p(E){return E===91||E===92||E===93?(t.consume(E),c++,y):y(E)}function v(E){return E===58?(t.enter("definitionMarker"),t.consume(E),t.exit("definitionMarker"),o.includes(f)||o.push(f),Ie(t,S,"gfmFootnoteDefinitionWhitespace")):a(E)}function S(E){return r(E)}}function U_(t,r,a){return t.check(hu,r,t.attempt(z_,r,a))}function B_(t){t.exit("gfmFootnoteDefinition")}function H_(t,r,a){const u=this;return Ie(t,o,"gfmFootnoteDefinitionIndent",5);function o(f){const c=u.events[u.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?r(f):a(f)}}function q_(t){let a=(t||{}).singleTilde;const u={name:"strikethrough",tokenize:f,resolveAll:o};return a==null&&(a=!0),{text:{126:u},insideSpan:{null:[u]},attentionMarkers:{null:[126]}};function o(c,m){let h=-1;for(;++h<c.length;)if(c[h][0]==="enter"&&c[h][1].type==="strikethroughSequenceTemporary"&&c[h][1]._close){let g=h;for(;g--;)if(c[g][0]==="exit"&&c[g][1].type==="strikethroughSequenceTemporary"&&c[g][1]._open&&c[h][1].end.offset-c[h][1].start.offset===c[g][1].end.offset-c[g][1].start.offset){c[h][1].type="strikethroughSequence",c[g][1].type="strikethroughSequence";const y={type:"strikethrough",start:Object.assign({},c[g][1].start),end:Object.assign({},c[h][1].end)},p={type:"strikethroughText",start:Object.assign({},c[g][1].end),end:Object.assign({},c[h][1].start)},v=[["enter",y,m],["enter",c[g][1],m],["exit",c[g][1],m],["enter",p,m]],S=m.parser.constructs.insideSpan.null;S&&mn(v,v.length,0,vs(S,c.slice(g+1,h),m)),mn(v,v.length,0,[["exit",p,m],["enter",c[h][1],m],["exit",c[h][1],m],["exit",y,m]]),mn(c,g-1,h-g+3,v),h=g+v.length-2;break}}for(h=-1;++h<c.length;)c[h][1].type==="strikethroughSequenceTemporary"&&(c[h][1].type="data");return c}function f(c,m,h){const g=this.previous,y=this.events;let p=0;return v;function v(E){return g===126&&y[y.length-1][1].type!=="characterEscape"?h(E):(c.enter("strikethroughSequenceTemporary"),S(E))}function S(E){const T=Qa(g);if(E===126)return p>1?h(E):(c.consume(E),p++,S);if(p<2&&!a)return h(E);const j=c.exit("strikethroughSequenceTemporary"),A=Qa(E);return j._open=!A||A===2&&!!T,j._close=!T||T===2&&!!A,m(E)}}}class I_{constructor(){this.map=[]}add(r,a,u){V_(this,r,a,u)}consume(r){if(this.map.sort(function(f,c){return f[0]-c[0]}),this.map.length===0)return;let a=this.map.length;const u=[];for(;a>0;)a-=1,u.push(r.slice(this.map[a][0]+this.map[a][1]),this.map[a][2]),r.length=this.map[a][0];u.push(r.slice()),r.length=0;let o=u.pop();for(;o;){for(const f of o)r.push(f);o=u.pop()}this.map.length=0}}function V_(t,r,a,u){let o=0;if(!(a===0&&u.length===0)){for(;o<t.map.length;){if(t.map[o][0]===r){t.map[o][1]+=a,t.map[o][2].push(...u);return}o+=1}t.map.push([r,a,u])}}function Y_(t,r){let a=!1;const u=[];for(;r<t.length;){const o=t[r];if(a){if(o[0]==="enter")o[1].type==="tableContent"&&u.push(t[r+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(t[r-1][1].type==="tableDelimiterMarker"){const f=u.length-1;u[f]=u[f]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(a=!0);r+=1}return u}function G_(){return{flow:{null:{name:"table",tokenize:F_,resolveAll:X_}}}}function F_(t,r,a){const u=this;let o=0,f=0,c;return m;function m(H){let ne=u.events.length-1;for(;ne>-1;){const se=u.events[ne][1].type;if(se==="lineEnding"||se==="linePrefix")ne--;else break}const J=ne>-1?u.events[ne][1].type:null,ve=J==="tableHead"||J==="tableRow"?M:h;return ve===M&&u.parser.lazy[u.now().line]?a(H):ve(H)}function h(H){return t.enter("tableHead"),t.enter("tableRow"),g(H)}function g(H){return H===124||(c=!0,f+=1),y(H)}function y(H){return H===null?a(H):we(H)?f>1?(f=0,u.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(H),t.exit("lineEnding"),S):a(H):Ue(H)?Ie(t,y,"whitespace")(H):(f+=1,c&&(c=!1,o+=1),H===124?(t.enter("tableCellDivider"),t.consume(H),t.exit("tableCellDivider"),c=!0,y):(t.enter("data"),p(H)))}function p(H){return H===null||H===124||tt(H)?(t.exit("data"),y(H)):(t.consume(H),H===92?v:p)}function v(H){return H===92||H===124?(t.consume(H),p):p(H)}function S(H){return u.interrupt=!1,u.parser.lazy[u.now().line]?a(H):(t.enter("tableDelimiterRow"),c=!1,Ue(H)?Ie(t,E,"linePrefix",u.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(H):E(H))}function E(H){return H===45||H===58?j(H):H===124?(c=!0,t.enter("tableCellDivider"),t.consume(H),t.exit("tableCellDivider"),T):W(H)}function T(H){return Ue(H)?Ie(t,j,"whitespace")(H):j(H)}function j(H){return H===58?(f+=1,c=!0,t.enter("tableDelimiterMarker"),t.consume(H),t.exit("tableDelimiterMarker"),A):H===45?(f+=1,A(H)):H===null||we(H)?P(H):W(H)}function A(H){return H===45?(t.enter("tableDelimiterFiller"),D(H)):W(H)}function D(H){return H===45?(t.consume(H),D):H===58?(c=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(H),t.exit("tableDelimiterMarker"),L):(t.exit("tableDelimiterFiller"),L(H))}function L(H){return Ue(H)?Ie(t,P,"whitespace")(H):P(H)}function P(H){return H===124?E(H):H===null||we(H)?!c||o!==f?W(H):(t.exit("tableDelimiterRow"),t.exit("tableHead"),r(H)):W(H)}function W(H){return a(H)}function M(H){return t.enter("tableRow"),F(H)}function F(H){return H===124?(t.enter("tableCellDivider"),t.consume(H),t.exit("tableCellDivider"),F):H===null||we(H)?(t.exit("tableRow"),r(H)):Ue(H)?Ie(t,F,"whitespace")(H):(t.enter("data"),q(H))}function q(H){return H===null||H===124||tt(H)?(t.exit("data"),F(H)):(t.consume(H),H===92?ie:q)}function ie(H){return H===92||H===124?(t.consume(H),q):q(H)}}function X_(t,r){let a=-1,u=!0,o=0,f=[0,0,0,0],c=[0,0,0,0],m=!1,h=0,g,y,p;const v=new I_;for(;++a<t.length;){const S=t[a],E=S[1];S[0]==="enter"?E.type==="tableHead"?(m=!1,h!==0&&(Bb(v,r,h,g,y),y=void 0,h=0),g={type:"table",start:Object.assign({},E.start),end:Object.assign({},E.end)},v.add(a,0,[["enter",g,r]])):E.type==="tableRow"||E.type==="tableDelimiterRow"?(u=!0,p=void 0,f=[0,0,0,0],c=[0,a+1,0,0],m&&(m=!1,y={type:"tableBody",start:Object.assign({},E.start),end:Object.assign({},E.end)},v.add(a,0,[["enter",y,r]])),o=E.type==="tableDelimiterRow"?2:y?3:1):o&&(E.type==="data"||E.type==="tableDelimiterMarker"||E.type==="tableDelimiterFiller")?(u=!1,c[2]===0&&(f[1]!==0&&(c[0]=c[1],p=ls(v,r,f,o,void 0,p),f=[0,0,0,0]),c[2]=a)):E.type==="tableCellDivider"&&(u?u=!1:(f[1]!==0&&(c[0]=c[1],p=ls(v,r,f,o,void 0,p)),f=c,c=[f[1],a,0,0])):E.type==="tableHead"?(m=!0,h=a):E.type==="tableRow"||E.type==="tableDelimiterRow"?(h=a,f[1]!==0?(c[0]=c[1],p=ls(v,r,f,o,a,p)):c[1]!==0&&(p=ls(v,r,c,o,a,p)),o=0):o&&(E.type==="data"||E.type==="tableDelimiterMarker"||E.type==="tableDelimiterFiller")&&(c[3]=a)}for(h!==0&&Bb(v,r,h,g,y),v.consume(r.events),a=-1;++a<r.events.length;){const S=r.events[a];S[0]==="enter"&&S[1].type==="table"&&(S[1]._align=Y_(r.events,a))}return t}function ls(t,r,a,u,o,f){const c=u===1?"tableHeader":u===2?"tableDelimiter":"tableData",m="tableContent";a[0]!==0&&(f.end=Object.assign({},Va(r.events,a[0])),t.add(a[0],0,[["exit",f,r]]));const h=Va(r.events,a[1]);if(f={type:c,start:Object.assign({},h),end:Object.assign({},h)},t.add(a[1],0,[["enter",f,r]]),a[2]!==0){const g=Va(r.events,a[2]),y=Va(r.events,a[3]),p={type:m,start:Object.assign({},g),end:Object.assign({},y)};if(t.add(a[2],0,[["enter",p,r]]),u!==2){const v=r.events[a[2]],S=r.events[a[3]];if(v[1].end=Object.assign({},S[1].end),v[1].type="chunkText",v[1].contentType="text",a[3]>a[2]+1){const E=a[2]+1,T=a[3]-a[2]-1;t.add(E,T,[])}}t.add(a[3]+1,0,[["exit",p,r]])}return o!==void 0&&(f.end=Object.assign({},Va(r.events,o)),t.add(o,0,[["exit",f,r]]),f=void 0),f}function Bb(t,r,a,u,o){const f=[],c=Va(r.events,a);o&&(o.end=Object.assign({},c),f.push(["exit",o,r])),u.end=Object.assign({},c),f.push(["exit",u,r]),t.add(a+1,0,f)}function Va(t,r){const a=t[r],u=a[0]==="enter"?"start":"end";return a[1][u]}const Q_={name:"tasklistCheck",tokenize:K_};function Z_(){return{text:{91:Q_}}}function K_(t,r,a){const u=this;return o;function o(h){return u.previous!==null||!u._gfmTasklistFirstContentOfListItem?a(h):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(h),t.exit("taskListCheckMarker"),f)}function f(h){return tt(h)?(t.enter("taskListCheckValueUnchecked"),t.consume(h),t.exit("taskListCheckValueUnchecked"),c):h===88||h===120?(t.enter("taskListCheckValueChecked"),t.consume(h),t.exit("taskListCheckValueChecked"),c):a(h)}function c(h){return h===93?(t.enter("taskListCheckMarker"),t.consume(h),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),m):a(h)}function m(h){return we(h)?r(h):Ue(h)?t.check({tokenize:P_},r,a)(h):a(h)}}function P_(t,r,a){return Ie(t,u,"whitespace");function u(o){return o===null?a(o):r(o)}}function J_(t){return Bv([w_(),O_(),q_(t),G_(),Z_()])}const $_={};function W_(t){const r=this,a=t||$_,u=r.data(),o=u.micromarkExtensions||(u.micromarkExtensions=[]),f=u.fromMarkdownExtensions||(u.fromMarkdownExtensions=[]),c=u.toMarkdownExtensions||(u.toMarkdownExtensions=[]);o.push(J_(a)),f.push(b_()),c.push(x_(a))}const ez="modulepreload",tz=function(t){return"/"+t},Hb={},Km=function(r,a,u){let o=Promise.resolve();if(a&&a.length>0){let c=function(g){return Promise.all(g.map(y=>Promise.resolve(y).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const m=document.querySelector("meta[property=csp-nonce]"),h=(m==null?void 0:m.nonce)||(m==null?void 0:m.getAttribute("nonce"));o=c(a.map(g=>{if(g=tz(g),g in Hb)return;Hb[g]=!0;const y=g.endsWith(".css"),p=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${g}"]${p}`))return;const v=document.createElement("link");if(v.rel=y?"stylesheet":ez,y||(v.as="script"),v.crossOrigin="",v.href=g,h&&v.setAttribute("nonce",h),document.head.appendChild(v),y)return new Promise((S,E)=>{v.addEventListener("load",S),v.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${g}`)))})}))}function f(c){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=c,window.dispatchEvent(m),!m.defaultPrevented)throw c}return o.then(c=>{for(const m of c||[])m.status==="rejected"&&f(m.reason);return r().catch(f)})};let Dd=null;const Rd=new Map;function j1(){return Dd||(Dd=Km(async()=>{const{createHighlighter:t}=await import("./index-HrybHVLc.js");return{createHighlighter:t}},[]).then(({createHighlighter:t})=>t({themes:["github-dark"],langs:["plaintext"]}))),Dd}function nz(t){const r=Rd.get(t);if(r)return r;const a=Km(()=>import("./index-HrybHVLc.js"),[]).then(async({bundledLanguages:u,isSpecialLang:o})=>{if(o(t))return;const f=u[t];if(!f)throw new Error(`unknown lang: ${t}`);const c=await j1();c.getLoadedLanguages().includes(t)||await c.loadLanguage(f)}).catch(u=>{throw Rd.delete(t),u});return Rd.set(t,a),a}function lz({code:t,language:r}){const[a,u]=w.useState(null),[o,f]=w.useState(0),[c,m]=w.useState(!1),h=w.useRef(null);w.useEffect(()=>{let y=!1;async function p(){const v=await j1();if(y)return;let S="plaintext";if(r){const{isSpecialLang:E}=await Km(async()=>{const{isSpecialLang:j}=await import("./index-HrybHVLc.js");return{isSpecialLang:j}},[]),T=v.getLoadedLanguages();E(r)||T.includes(r)?S=r:(nz(r).then(()=>{y||f(j=>j+1)}).catch(()=>{}),S="plaintext")}try{const E=v.codeToHtml(t,{lang:S,theme:"github-dark"});y||u(E)}catch{}}return u(null),p().catch(()=>{}),()=>{y=!0}},[t,r,o]),w.useEffect(()=>()=>{h.current!==null&&clearTimeout(h.current)},[]);const g=w.useCallback(()=>{navigator.clipboard.writeText(t).then(()=>{m(!0),h.current!==null&&clearTimeout(h.current),h.current=setTimeout(()=>m(!1),2e3)}).catch(()=>{})},[t]);return b.jsxs("div",{className:"relative group rounded-md bg-secondary overflow-hidden mb-2",children:[r&&b.jsx("div",{className:"text-[10px] text-muted-foreground px-3 pt-1.5 select-none",children:r}),b.jsx("button",{onClick:g,"aria-label":"Copy code",className:"absolute top-1.5 right-2 z-10 opacity-0 group-hover:opacity-100 transition-opacity rounded p-1 text-muted-foreground hover:text-foreground hover:bg-white/10",children:c?b.jsx(gm,{size:13,strokeWidth:2.5}):b.jsx(Kb,{size:13,strokeWidth:2})}),a!==null?b.jsx("div",{className:"overflow-x-auto text-xs leading-5 [&>pre]:p-3 [&>pre]:m-0 [&>pre]:bg-transparent! [&>pre]:font-mono",dangerouslySetInnerHTML:{__html:a}}):b.jsx("pre",{className:"overflow-x-auto p-3 font-mono text-xs leading-5 text-foreground",children:b.jsx("code",{children:t})})]})}const rz={h1:({children:t})=>b.jsx("h1",{className:"mb-3 text-xl font-bold",children:t}),h2:({children:t})=>b.jsx("h2",{className:"mb-2 text-lg font-semibold",children:t}),h3:({children:t})=>b.jsx("h3",{className:"mb-1.5 text-base font-semibold",children:t}),p:({children:t})=>b.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed",children:t}),ul:({children:t})=>b.jsx("ul",{className:"mb-2 ml-4 list-disc space-y-0.5",children:t}),ol:({children:t})=>b.jsx("ol",{className:"mb-2 ml-4 list-decimal space-y-0.5",children:t}),li:({children:t})=>b.jsx("li",{className:"text-sm",children:t}),blockquote:({children:t})=>b.jsx("blockquote",{className:"mb-2 border-l-2 border-brand/50 pl-3 italic text-muted-foreground",children:t}),a:({href:t,children:r})=>t&&/^(https?:\/\/|\/(?!\/)|#)/i.test(t)?b.jsx("a",{href:t,className:"text-brand underline underline-offset-2 hover:text-brand/80",target:"_blank",rel:"noopener noreferrer",children:r}):b.jsx("span",{className:"text-muted-foreground",children:r}),strong:({children:t})=>b.jsx("strong",{className:"font-semibold text-foreground",children:t}),em:({children:t})=>b.jsx("em",{className:"italic text-muted-foreground",children:t}),hr:()=>b.jsx("hr",{className:"my-3 border-border"}),table:({children:t})=>b.jsx("div",{className:"mb-2 overflow-x-auto rounded border border-border",children:b.jsx("table",{className:"w-full text-sm",children:t})}),thead:({children:t})=>b.jsx("thead",{className:"bg-secondary text-secondary-foreground",children:t}),th:({children:t})=>b.jsx("th",{className:"px-3 py-1.5 text-left font-medium",children:t}),td:({children:t})=>b.jsx("td",{className:"border-t border-border px-3 py-1.5",children:t}),code:({children:t,className:r})=>{var u;return((u=/language-(\w+)/.exec(r??""))==null?void 0:u[1])?b.jsx("code",{className:oe("text-xs",r),children:t}):b.jsx("code",{className:"rounded bg-secondary px-1 py-0.5 font-mono text-[11px] text-foreground",children:t})},pre:({children:t})=>{var o,f,c;const r=t,a=(f=/language-(\w+)/.exec(((o=r==null?void 0:r.props)==null?void 0:o.className)??""))==null?void 0:f[1],u=String(((c=r==null?void 0:r.props)==null?void 0:c.children)??"").replace(/\n$/,"");return b.jsx(lz,{code:u,language:a})}};function _1({text:t,className:r}){return b.jsx("div",{className:oe("text-sm text-foreground",r),children:b.jsx(qj,{remarkPlugins:[W_],components:rz,children:t})})}function az(){return b.jsx("span",{className:"streaming-cursor","aria-hidden":"true"})}const iz=/^[ \t]*(`{3,}|~{4,})/;function uz(t,r){if(r>=t.length)return r;const a=t.lastIndexOf(`
|
|
375
375
|
`,r-1)+1,u=t.slice(a,r);if(iz.test(u)){const o=t.indexOf(`
|
|
376
376
|
`,r);return o===-1?t.length:o+1}return r}function oz({text:t,isStreaming:r,speed:a=80,onComplete:u}){const o=w.useRef(0),[f,c]=w.useState(0),m=w.useRef(null),h=w.useRef(null),g=w.useRef(!1),y=w.useRef(u);w.useEffect(()=>{y.current=u},[u]);const p=w.useRef(a);w.useEffect(()=>{p.current=a});const v=!r&&o.current===0&&t.length>0,S=w.useCallback(()=>{if(m.current!==null)return;function A(D){var H;const L=h.current??D,P=D-L;h.current=D;const W=p.current/1e3,M=Math.max(1,Math.floor(W*P)),F=o.current,q=t.length;if(F<q){const ne=Math.min(F+M,q),J=uz(t,ne);o.current=J,c(J)}if(o.current>=t.length&&!r){m.current=null,h.current=null,g.current||(g.current=!0,(H=y.current)==null||H.call(y));return}m.current=requestAnimationFrame(A)}m.current=requestAnimationFrame(A)},[t,r]);w.useEffect(()=>{var A;if(v){o.current=t.length,c(t.length),g.current||(g.current=!0,(A=y.current)==null||A.call(y));return}return(o.current<t.length||r)&&S(),()=>{m.current!==null&&(cancelAnimationFrame(m.current),m.current=null)}},[t,r,v]);const E=v?t.length:f,T=t.slice(0,E),j=E<t.length||r;return b.jsxs("span",{className:"streaming-text-root",children:[b.jsx(_1,{text:T}),j&&b.jsx(az,{})]})}function z1({kind:t,text:r,className:a}){const[u,o]=w.useState(!1),f=w.useRef(null);w.useEffect(()=>()=>{f.current!==null&&clearTimeout(f.current)},[]);function c(){navigator.clipboard.writeText(r).then(()=>{o(!0),f.current!==null&&clearTimeout(f.current),f.current=setTimeout(()=>o(!1),2e3)}).catch(()=>{})}return b.jsx("div",{className:oe("absolute top-1 right-1","opacity-0 group-hover:opacity-100 transition-opacity duration-150",a),children:b.jsx("div",{className:"flex items-center gap-0.5 rounded-md border border-border bg-card px-1 py-0.5 shadow-sm",children:t==="assistant"&&b.jsx(sz,{onClick:c,title:u?"Copied!":"Copy",children:u?b.jsx(gm,{className:"h-3.5 w-3.5 text-status-running"}):b.jsx(Kb,{className:"h-3.5 w-3.5"})})})})}function sz({onClick:t,title:r,children:a}){return b.jsx("button",{type:"button",onClick:t,title:r,className:"h-6 w-6 rounded flex items-center justify-center hover:bg-secondary text-muted-foreground hover:text-foreground transition-colors",children:a})}function O1({text:t}){return b.jsxs("div",{className:"group relative flex flex-col items-end gap-1",children:[b.jsx("span",{className:"text-[11px] font-medium uppercase tracking-widest text-muted-foreground/50",children:"You"}),b.jsx("p",{className:"max-w-2xl text-sm leading-relaxed text-foreground whitespace-pre-wrap text-right",children:t}),b.jsx(z1,{kind:"user",text:t})]})}function M1({text:t,isStreaming:r=!1}){return b.jsxs("div",{className:"group relative flex flex-col gap-1",children:[b.jsx("span",{className:"text-[11px] font-medium uppercase tracking-widest text-brand/60",children:"Agent"}),b.jsx("div",{className:"max-w-3xl",children:r?b.jsx(oz,{text:t,isStreaming:!0}):b.jsx(_1,{text:t})}),b.jsx(z1,{kind:"assistant",text:t})]})}function D1({message:t}){return b.jsxs("div",{className:"flex items-start gap-2.5 rounded-xl border border-destructive/20 bg-destructive/5 px-4 py-3",children:[b.jsx(Zb,{className:"mt-0.5 h-4 w-4 shrink-0 text-status-failed"}),b.jsx("p",{className:"text-sm leading-relaxed text-status-failed",children:t})]})}function R1({text:t}){return b.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-border bg-muted/30 px-3 py-2",children:[b.jsx(Pb,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),b.jsx("p",{className:"text-xs text-muted-foreground",children:t})]})}function L1({item:t}){return b.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/30 px-3 py-1.5",children:[b.jsx("span",{className:"text-[10px] text-muted-foreground",children:"BG"}),b.jsx("span",{className:"text-xs text-foreground",children:t.label}),b.jsx("span",{className:oe("ml-auto font-mono text-[10px] capitalize",t.status==="completed"?"text-status-running":"",t.status==="failed"?"text-status-failed":"",t.status==="running"?"text-status-blocked":""),children:t.status})]})}function cz(t){const r=[];let a=0;for(;a<t.length;){const u=t[a];if(u===void 0){a++;continue}if(u.kind!=="subagent"){r.push({kind:"item",item:u}),a++;continue}const o=[];for(;a<t.length;){const f=t[a];if(f===void 0||f.kind!=="subagent")break;o.push(f),a++}r.push({kind:"subagent-group",items:o,id:o[0].id})}return r}function fz(t,r=!1){switch(t.kind){case"user":return b.jsx(O1,{text:t.text});case"assistant":return b.jsx(M1,{text:t.text,isStreaming:r});case"thinking":return b.jsx(dv,{text:t.text});case"tool":return b.jsx(ZT,{...t});case"error":return b.jsx(D1,{message:t.message});case"notice":return b.jsx(R1,{text:t.text});case"bg_job":return b.jsx(L1,{item:t});case"subagent":return null}}function dz(t,r=!1){switch(t.kind){case"user":return b.jsx(O1,{text:t.text});case"assistant":return b.jsx(M1,{text:t.text,isStreaming:r});case"thinking":return b.jsx(dv,{text:t.text});case"error":return b.jsx(D1,{message:t.message});case"notice":return b.jsx(R1,{text:t.text});case"bg_job":return b.jsx(L1,{item:t});default:return null}}function mz({sessionId:t,...r}){return b.jsx(pv.Provider,{value:t??null,children:b.jsx(hz,{...r})})}function hz({items:t,totals:r,spineMode:a=!0,turnActive:u=!1}){const o=w.useMemo(()=>cz(t),[t]),f=NN(t),c=w.useMemo(()=>{var h;for(let g=t.length-1;g>=0;g--)if(((h=t[g])==null?void 0:h.kind)==="assistant")return t[g].id;return null},[t]),m=w.useCallback((h,g)=>{const y=h.kind==="user"&&g>0,p=u&&h.id===c;return b.jsxs("div",{children:[y&&b.jsx("div",{className:"my-6 border-t border-border/40","aria-hidden":"true"}),b.jsx("div",{className:"py-2 px-1",children:dz(h,p)})]},h.id)},[u,c]);return b.jsxs("div",{className:"flex flex-col gap-0 max-w-4xl mx-auto w-full",children:[r&&b.jsx(bv,{totals:r,className:"sticky top-0 z-10 mb-4 rounded-md border border-border bg-card px-3 py-1.5"}),t.length===0?b.jsx("p",{className:"py-12 text-center text-sm text-muted-foreground",children:"No transcript items yet."}):a?b.jsx(TN,{slots:f,renderTextItem:m}):o.map((h,g)=>{if(h.kind==="item"){const{item:p}=h,v=p.kind==="user"&&g>0,S=u&&p.id===c;return b.jsxs("div",{children:[v&&b.jsx("div",{className:"my-6 border-t border-border/40","aria-hidden":"true"}),b.jsx("div",{className:"py-2 px-1",children:fz(p,S)})]},p.id)}const y=lN(h.items);return b.jsx("div",{className:"py-2 px-1",children:b.jsx(eN,{roots:y})},h.id)})]})}const pz={preference:"Preference",convention:"Convention",decision:"Decision",learning:"Learning"};function gz({type:t}){return b.jsx("span",{className:oe("inline-flex items-center rounded px-1.5 py-0.5 text-xs font-medium",t==="fact"?"bg-blue-500/15 text-blue-400":"bg-violet-500/15 text-violet-400"),children:t})}function yz({category:t}){return t?b.jsx("span",{className:"inline-flex items-center rounded px-1.5 py-0.5 text-xs font-medium bg-zinc-700 text-zinc-300",children:pz[t]??t}):null}function bz({result:t}){const r=t.content.length>200?t.content.slice(0,200)+"…":t.content,a=t.created_at?new Date(t.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):null;return b.jsxs("div",{className:"rounded-lg border border-zinc-800 bg-zinc-900 p-3 space-y-2",children:[b.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[b.jsx(gz,{type:t.type}),b.jsx(yz,{category:t.category}),a&&b.jsx("span",{className:"text-xs text-zinc-500 ml-auto",children:a})]}),b.jsx("p",{className:"text-sm text-zinc-300 leading-relaxed whitespace-pre-wrap break-words",children:r})]})}function xz({pct:t,truncated:r}){const a=Math.min(t,100),u=t>=100?"bg-red-500":t>=80?"bg-amber-400":"bg-accent";return b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx("div",{className:"flex-1 h-2 rounded-full bg-zinc-800 overflow-hidden",children:b.jsx("div",{className:oe("h-full rounded-full transition-all",u),style:{width:`${a}%`}})}),r&&b.jsx("span",{className:"inline-flex items-center rounded px-1.5 py-0.5 text-xs font-medium bg-amber-400/15 text-amber-400",children:"Truncated"})]})}function vz({hot:t}){if(!t)return null;const{content:r,usage:a}=t;return b.jsxs("section",{className:"space-y-2",children:[b.jsxs("div",{className:"flex items-center justify-between",children:[b.jsx("h3",{className:"text-sm font-semibold text-zinc-200",children:"HOT Memory"}),b.jsxs("span",{className:"text-xs text-zinc-500",children:[a.tokens.toLocaleString()," / ",a.maxTokens.toLocaleString()," tokens"]})]}),b.jsx(xz,{pct:a.pct,truncated:a.truncated}),r?b.jsx("pre",{className:"rounded-md border border-zinc-800 bg-zinc-950 p-3 text-xs text-zinc-300 font-mono overflow-x-auto whitespace-pre-wrap max-h-48",children:r}):b.jsx("p",{className:"text-xs text-zinc-500 italic",children:"No hot memory loaded."})]})}const Sz=[{value:"",label:"All Categories"},{value:"preference",label:"Preference"},{value:"convention",label:"Convention"},{value:"decision",label:"Decision"},{value:"learning",label:"Learning"}];function wz(){const[t,r]=w.useState(null),[a,u]=w.useState(""),[o,f]=w.useState(""),[c,m]=w.useState(null),[h,g]=w.useState(!1),[y,p]=w.useState(null);w.useEffect(()=>{it("/api/memory/hot").then(r).catch(()=>{})},[]);const v=w.useCallback(async S=>{S.preventDefault(),g(!0),p(null);try{const E=new URLSearchParams({q:a,limit:"20"});o&&E.set("category",o);const T=await it(`/api/memory/search?${E.toString()}`);m(T.results)}catch(E){p(E instanceof Error?E.message:"Search failed")}finally{g(!1)}},[a,o]);return b.jsxs("div",{className:"flex flex-col gap-6 p-4",children:[b.jsx(vz,{hot:t}),b.jsxs("section",{className:"space-y-3",children:[b.jsx("h3",{className:"text-sm font-semibold text-zinc-200",children:"Search Memory"}),b.jsxs("form",{onSubmit:v,className:"flex gap-2 flex-wrap",children:[b.jsx("input",{type:"text",value:a,onChange:S=>u(S.target.value),placeholder:"FTS5 query…",className:"flex-1 min-w-0 rounded-md border border-zinc-700 bg-zinc-900 px-3 py-1.5 text-sm text-zinc-100 placeholder-zinc-500 focus:outline-none focus:ring-1 focus:ring-accent"}),b.jsx("select",{value:o,onChange:S=>f(S.target.value),className:"rounded-md border border-zinc-700 bg-zinc-900 px-2 py-1.5 text-sm text-zinc-100 focus:outline-none focus:ring-1 focus:ring-accent",children:Sz.map(S=>b.jsx("option",{value:S.value,children:S.label},S.value))}),b.jsx("button",{type:"submit",disabled:h,className:"rounded-md bg-accent px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50 hover:opacity-90 transition-opacity",children:h?"Searching…":"Search"})]}),y&&b.jsx("p",{className:"text-xs text-red-400",children:y}),c!==null&&b.jsx("div",{className:"space-y-2",children:c.length===0?b.jsx("p",{className:"text-sm text-zinc-500 italic text-center py-6",children:"No results found."}):c.map(S=>b.jsx(bz,{result:S},`${S.type}-${S.created_at}-${S.content.slice(0,32)}`))})]})]})}const kz={success:{label:"Success",className:"bg-status-done/20 text-status-done border-status-done/30"},error:{label:"Error",className:"bg-status-failed/20 text-status-failed border-status-failed/30"},skipped:{label:"Skipped",className:"bg-muted text-muted-foreground border-border"}};function Ez(t){if(t<1e3)return`${t}ms`;const r=Math.floor(t/1e3);return r<60?`${r}s`:`${Math.floor(r/60)}m ${r%60}s`}function Cz(t){return new Date(t).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Tz({schedule:t,onClose:r}){const[a,u]=w.useState([]),[o,f]=w.useState(!0),[c,m]=w.useState(null);return w.useEffect(()=>{let h=!1;return f(!0),m(null),it(`/api/schedules/${t.id}/history`).then(g=>{h||u(g.history)}).catch(g=>{h||m(g instanceof Error?g.message:"Failed to load history")}).finally(()=>{h||f(!1)}),()=>{h=!0}},[t.id]),w.useEffect(()=>{const h=g=>{g.key==="Escape"&&r()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[r]),b.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",onClick:h=>{h.target===h.currentTarget&&r()},children:b.jsxs("div",{className:"flex max-h-[80vh] w-full max-w-lg flex-col rounded-xl border border-border bg-card shadow-xl",children:[b.jsxs("div",{className:"flex items-center justify-between border-b border-border px-5 py-4",children:[b.jsxs("div",{children:[b.jsx("h2",{className:"text-sm font-semibold",children:t.name}),b.jsx("p",{className:"mt-0.5 font-mono text-xs text-muted-foreground",children:t.cron})]}),b.jsx("button",{onClick:r,className:"flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground","aria-label":"Close",children:"✕"})]}),b.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-3",children:[o&&b.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"Loading history…"}),c&&b.jsx("p",{className:"py-8 text-center text-sm text-status-failed",children:c}),!o&&!c&&a.length===0&&b.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"No runs recorded yet."}),!o&&!c&&a.length>0&&b.jsx("ul",{className:"space-y-2",children:a.map((h,g)=>{const y=kz[h.status];return b.jsxs("li",{className:"flex items-start gap-3 rounded-lg border border-border bg-background/50 px-4 py-3",children:[b.jsx("span",{className:oe("mt-0.5 shrink-0 rounded-full border px-2 py-0.5 text-xs font-medium",y.className),children:y.label}),b.jsxs("div",{className:"min-w-0 flex-1",children:[b.jsxs("div",{className:"flex items-center justify-between gap-2",children:[b.jsx("span",{className:"text-xs text-muted-foreground",children:Cz(h.triggeredAt)}),b.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:Ez(h.durationMs)})]}),h.errorMessage&&b.jsx("p",{className:"mt-1 truncate font-mono text-xs text-status-failed",children:h.errorMessage})]})]},`${h.taskId}-${h.triggeredAt}-${g}`)})})]})]})})}function Nz({status:t}){return t?b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx("span",{className:oe("size-2 rounded-full",t.running?"animate-pulse bg-status-done":"bg-status-failed")}),b.jsx("span",{className:"text-sm text-muted-foreground",children:t.running?`Running${t.tasks!=null?` (${t.tasks} task${t.tasks!==1?"s":""})`:""}`:"Stopped"})]}):null}function U1({checked:t,onChange:r,disabled:a}){return b.jsx("button",{role:"switch","aria-checked":t,onClick:u=>{u.stopPropagation(),r()},disabled:a,className:oe("relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent","transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:cursor-not-allowed disabled:opacity-50",t?"bg-brand":"bg-muted"),children:b.jsx("span",{className:oe("block size-4 rounded-full bg-white shadow transition-transform",t?"translate-x-4":"translate-x-0")})})}function Az({schedule:t,onToggle:r,onDelete:a,onShowHistory:u}){const[o,f]=w.useState(!1),[c,m]=w.useState(!1),h=async()=>{f(!0),await r(t.id).finally(()=>f(!1))},g=async p=>{p.stopPropagation(),window.confirm(`Delete schedule "${t.name}"? This cannot be undone.`)&&(m(!0),await a(t.id).finally(()=>m(!1)))},y=t.trigger==="both"?"cron + session start":t.trigger??"cron";return b.jsxs("div",{className:oe("group flex cursor-pointer flex-col gap-3 rounded-xl border border-border bg-card p-4","transition-colors hover:border-brand/40 hover:bg-accent/30",!t.enabled&&"opacity-60"),onClick:()=>u(t),children:[b.jsxs("div",{className:"flex items-start justify-between gap-3",children:[b.jsxs("div",{className:"min-w-0 flex-1",children:[b.jsx("p",{className:"truncate text-sm font-semibold",children:t.name}),b.jsx("p",{className:"mt-0.5 font-mono text-xs text-muted-foreground",children:t.cron})]}),b.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[b.jsx(U1,{checked:t.enabled,onChange:()=>{h()},disabled:o}),b.jsx("button",{onClick:g,disabled:c,"aria-label":`Delete schedule ${t.name}`,className:oe("flex size-7 items-center justify-center rounded-md text-muted-foreground","opacity-0 transition-opacity group-hover:opacity-100","hover:bg-destructive/20 hover:text-status-failed","disabled:cursor-not-allowed disabled:opacity-40"),children:"🗑"})]})]}),b.jsx("code",{className:"block truncate rounded-md bg-secondary px-3 py-2 font-mono text-xs text-secondary-foreground",children:t.command}),b.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[b.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 capitalize",children:y}),t.notifyOn&&t.notifyOn!=="never"&&b.jsxs("span",{className:"rounded bg-muted px-1.5 py-0.5",children:["notify: ",t.notifyOn]}),b.jsx("span",{className:"ml-auto",children:"Click for history"})]})]})}const jz={name:"",command:"",cron:"",trigger:"cron",notifyOn:"failure",enabled:!0};function _z({onCreated:t,onCancel:r}){const[a,u]=w.useState(jz),[o,f]=w.useState(!1),[c,m]=w.useState(null),h=async p=>{if(p.preventDefault(),m(null),!a.name.trim()){m("Name is required.");return}if(!a.command.trim()){m("Command is required.");return}if(!a.cron.trim()){m("Cron expression is required.");return}f(!0);try{const v=await it("/api/schedules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});t(v.schedule,v.syncNote)}catch(v){m(v instanceof Error?v.message:"Failed to create schedule.")}finally{f(!1)}},g=(p,v)=>b.jsxs("div",{className:"flex flex-col gap-1",children:[b.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:p}),v]}),y=oe("h-8 rounded-md border border-border bg-card px-3 text-sm","placeholder:text-muted-foreground/50","focus:outline-none focus:ring-2 focus:ring-ring","disabled:cursor-not-allowed disabled:opacity-50");return b.jsxs("form",{onSubmit:p=>{h(p)},className:"flex flex-col gap-4 rounded-xl border border-brand/40 bg-card p-4",children:[b.jsx("p",{className:"text-sm font-semibold",children:"New Schedule"}),b.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[g("Name *",b.jsx("input",{type:"text",className:y,placeholder:"e.g. Nightly cleanup",value:a.name,onChange:p=>u(v=>({...v,name:p.target.value})),required:!0,disabled:o})),g("Cron expression *",b.jsx("input",{type:"text",className:oe(y,"font-mono"),placeholder:"0 2 * * *",value:a.cron,onChange:p=>u(v=>({...v,cron:p.target.value})),required:!0,disabled:o}))]}),g("Command *",b.jsx("input",{type:"text",className:oe(y,"font-mono"),placeholder:"/my-skill --auto",value:a.command,onChange:p=>u(v=>({...v,command:p.target.value})),required:!0,disabled:o})),b.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[g("Trigger",b.jsxs("select",{className:y,value:a.trigger,onChange:p=>u(v=>({...v,trigger:p.target.value})),disabled:o,children:[b.jsx("option",{value:"cron",children:"cron"}),b.jsx("option",{value:"sessionstart",children:"session start"}),b.jsx("option",{value:"both",children:"both"})]})),g("Notify on",b.jsxs("select",{className:y,value:a.notifyOn,onChange:p=>u(v=>({...v,notifyOn:p.target.value})),disabled:o,children:[b.jsx("option",{value:"failure",children:"failure"}),b.jsx("option",{value:"always",children:"always"}),b.jsx("option",{value:"never",children:"never"})]})),b.jsxs("div",{className:"flex flex-col gap-1",children:[b.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Enabled"}),b.jsx("div",{className:"flex h-8 items-center",children:b.jsx(U1,{checked:a.enabled,onChange:()=>u(p=>({...p,enabled:!p.enabled})),disabled:o})})]})]}),c&&b.jsx("p",{className:"rounded-md border border-status-failed/30 bg-status-failed/10 px-3 py-2 text-xs text-status-failed",children:c}),b.jsxs("div",{className:"flex items-center justify-end gap-2",children:[b.jsx("button",{type:"button",onClick:r,disabled:o,className:oe("h-8 rounded-md px-3 text-sm text-muted-foreground","hover:bg-accent hover:text-foreground","disabled:cursor-not-allowed disabled:opacity-50"),children:"Cancel"}),b.jsx("button",{type:"submit",disabled:o,className:oe("h-8 rounded-md bg-brand px-4 text-sm font-medium text-white","hover:bg-brand/90","disabled:cursor-not-allowed disabled:opacity-50"),children:o?"Creating…":"Create"})]})]})}function zz(){const[t,r]=w.useState([]),[a,u]=w.useState(null),[o,f]=w.useState(!0),[c,m]=w.useState(null),[h,g]=w.useState(null),[y,p]=w.useState(!1),[v,S]=w.useState(null);w.useEffect(()=>{let A=!1;return f(!0),m(null),Promise.all([it("/api/schedules"),it("/api/daemon/status")]).then(([D,L])=>{A||(r(D.schedules),u(L))}).catch(D=>{A||m(D instanceof Error?D.message:"Failed to load schedules")}).finally(()=>{A||f(!1)}),()=>{A=!0}},[]);const E=w.useCallback(async A=>{const D=await it(`/api/schedules/${A}/toggle`,{method:"POST"});r(L=>L.map(P=>P.id===A?{...P,enabled:D.enabled}:P)),D.syncNote&&(S(D.syncNote),setTimeout(()=>S(null),8e3))},[]),T=w.useCallback(async A=>{await it(`/api/schedules/${A}`,{method:"DELETE"}),r(D=>D.filter(L=>L.id!==A))},[]),j=w.useCallback((A,D)=>{r(L=>[...L,A]),p(!1),D&&(S(D),setTimeout(()=>S(null),8e3))},[]);return o?b.jsx("div",{className:"flex flex-1 items-center justify-center",children:b.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading schedules…"})}):b.jsxs("div",{className:"flex flex-1 flex-col gap-4 overflow-y-auto p-4",children:[b.jsxs("div",{className:"flex items-center justify-between",children:[b.jsx("h1",{className:"text-base font-semibold",children:"Schedules"}),b.jsxs("div",{className:"flex items-center gap-3",children:[b.jsx(Nz,{status:a}),b.jsx("button",{onClick:()=>p(A=>!A),className:oe("h-7 rounded-md px-3 text-xs font-medium",y?"bg-muted text-muted-foreground hover:bg-muted/80":"bg-brand text-white hover:bg-brand/90"),children:y?"Cancel":"+ New Schedule"})]})]}),y&&b.jsx(_z,{onCreated:j,onCancel:()=>p(!1)}),v&&b.jsx("p",{className:"rounded-lg border border-yellow-500/30 bg-yellow-500/10 px-4 py-3 text-sm text-yellow-700 dark:text-yellow-400",children:v}),c&&b.jsx("p",{className:"rounded-lg border border-status-failed/30 bg-status-failed/10 px-4 py-3 text-sm text-status-failed",children:c}),!c&&t.length===0&&!y&&b.jsx("p",{className:"mt-8 text-center text-sm text-muted-foreground",children:"No schedules configured."}),b.jsx("div",{className:"grid gap-3",children:t.map(A=>b.jsx(Az,{schedule:A,onToggle:E,onDelete:T,onShowHistory:g},A.id))}),h&&b.jsx(Tz,{schedule:h,onClose:()=>g(null)})]})}function Oz(t,r){const a=(r??Date.now())-t;if(a<1e3)return`${a}ms`;const u=Math.floor(a/1e3);if(u<60)return`${u}s`;const o=Math.floor(u/60);return o<60?`${o}m ${u%60}s`:`${Math.floor(o/60)}h ${o%60}m`}function Mz(t){const r=Math.floor((Date.now()-t)/1e3);if(r<60)return`${r}s ago`;const a=Math.floor(r/60);if(a<60)return`${a}m ago`;const u=Math.floor(a/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}function Dz(t){const r=t.lastIndexOf("/");return r!==-1?t.slice(r+1):t}const Rz={running:"bg-green-500/20 text-green-400 border border-green-500/30",completed:"bg-blue-500/20 text-blue-400 border border-blue-500/30",failed:"bg-red-500/20 text-red-400 border border-red-500/30",cancelled:"bg-neutral-500/20 text-neutral-400 border border-neutral-500/30"};function rs(t){return t.status!=="running"}function Lz({status:t}){return b.jsxs("span",{className:oe("inline-flex items-center gap-1.5 rounded px-1.5 py-0.5 text-xs font-medium",Rz[t]),children:[t==="running"&&b.jsx("span",{className:"size-1.5 rounded-full bg-green-400 animate-pulse"}),t]})}function qb({job:t,now:r,onCancel:a}){const[u,o]=w.useState(!1),[f,c]=w.useState(!1),[m,h]=w.useState(null),g=Oz(t.startedAt,t.status==="running"?r:t.endedAt),y=Mz(t.startedAt),p=u?ym:gs,v=async S=>{S.stopPropagation(),h(null),c(!0);try{await a(t.jobId)}catch(E){h(E instanceof Error?E.message:String(E))}finally{c(!1)}};return b.jsxs("div",{className:"rounded-lg border border-neutral-800 bg-neutral-900 overflow-hidden",children:[b.jsxs("div",{role:"button",tabIndex:0,onClick:()=>o(S=>!S),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),o(E=>!E))},className:"w-full text-left px-4 py-3 flex flex-col gap-2 hover:bg-neutral-800/50 transition-colors cursor-pointer",children:[b.jsxs("div",{className:"flex items-start justify-between gap-2",children:[b.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[b.jsx(p,{className:"size-3.5 shrink-0 text-neutral-500"}),b.jsx("span",{className:"text-sm font-medium text-neutral-100 truncate",children:t.label||t.jobId})]}),b.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[b.jsx(Lz,{status:t.status}),t.status==="running"&&b.jsxs("button",{type:"button",onClick:v,disabled:f,"aria-label":`Cancel job ${t.jobId}`,className:oe("flex items-center gap-1 rounded px-1.5 py-0.5 text-xs","text-neutral-500 hover:text-red-400 hover:bg-red-500/10","disabled:opacity-40 transition-colors"),children:[b.jsx(bm,{className:"size-3"}),f?"Cancelling…":"Cancel"]})]})]}),b.jsxs("div",{className:"flex items-center gap-3 text-xs text-neutral-500 pl-5",children:[b.jsx("span",{className:"font-mono bg-neutral-800 rounded px-1.5 py-0.5 text-neutral-300",children:Dz(t.model)}),b.jsx("span",{children:g}),b.jsx("span",{children:y})]}),(t.status==="failed"||t.status==="cancelled")&&t.stopReason&&b.jsxs("div",{className:"pl-5 text-xs text-neutral-500",children:[b.jsx("span",{className:"text-neutral-600",children:"reason:"})," ",b.jsx("span",{className:"font-mono text-neutral-400 line-clamp-2",title:t.stopReason,children:t.stopReason})]}),m&&b.jsx("p",{className:"pl-5 text-xs text-red-400",title:m,children:m.length>200?m.slice(0,200)+"…":m})]}),u&&b.jsxs("div",{className:"border-t border-neutral-800 px-4 py-3 bg-neutral-950 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 text-xs",children:[b.jsx(Rn,{label:"Job ID",value:t.jobId,mono:!0}),b.jsx(Rn,{label:"Subagent ID",value:t.subagentId,mono:!0}),b.jsx(Rn,{label:"Model",value:t.model,mono:!0}),b.jsx(Rn,{label:"Status",value:t.status}),b.jsx(Rn,{label:"Started",value:new Date(t.startedAt).toLocaleString()}),t.endedAt!==void 0&&b.jsx(Rn,{label:"Ended",value:new Date(t.endedAt).toLocaleString()}),b.jsx(Rn,{label:"Duration",value:g}),t.parentSessionId&&b.jsx(Rn,{label:"Parent session",value:t.parentSessionId,mono:!0}),t.stopReason&&b.jsx(Rn,{label:"Stop reason",value:t.stopReason.length>200?t.stopReason.slice(0,200)+"…":t.stopReason,mono:!0}),b.jsx(Rn,{label:"Prompt hash",value:t.promptHash,mono:!0}),b.jsx(Rn,{label:"Schema version",value:String(t.schemaVersion)})]})]})}function Rn({label:t,value:r,mono:a=!1}){return b.jsxs(b.Fragment,{children:[b.jsx("span",{className:"text-neutral-600 whitespace-nowrap",children:t}),b.jsx("span",{className:oe("text-neutral-300 break-all",a&&"font-mono"),children:r})]})}function Ib({label:t,count:r}){return b.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-neutral-500 uppercase tracking-wider",children:[b.jsx("span",{children:t}),b.jsx("span",{className:"rounded-full bg-neutral-800 px-1.5 py-0.5 text-neutral-400 normal-case",children:r})]})}function Uz(){const[t,r]=w.useState([]),[a,u]=w.useState(!0),[o,f]=w.useState(null),[c,m]=w.useState(()=>Date.now()),h=w.useRef(null),g=w.useCallback((E=!1)=>{E||u(!0),f(null),it("/api/bg-jobs").then(({jobs:T})=>r([...T].sort((j,A)=>A.startedAt-j.startedAt))).catch(T=>f(T instanceof Error?T.message:String(T))).finally(()=>{E||u(!1)})},[]);w.useEffect(()=>{g()},[g]),w.useEffect(()=>{const E=t.some(T=>!rs(T));return E&&!h.current&&(h.current=setInterval(()=>g(!0),5e3)),!E&&h.current&&(clearInterval(h.current),h.current=null),()=>{h.current&&(clearInterval(h.current),h.current=null)}},[t,g]),w.useEffect(()=>{if(!t.some(j=>!rs(j)))return;const T=setInterval(()=>m(Date.now()),1e3);return()=>clearInterval(T)},[t]);const y=w.useCallback(async E=>{await it(`/api/bg-jobs/${encodeURIComponent(E)}/cancel`,{method:"POST"}),r(T=>T.map(j=>j.jobId===E?{...j,status:"cancelled"}:j))},[]),p=t.filter(E=>E.status==="running"),v=t.filter(E=>rs(E)),S=t.some(E=>!rs(E));return b.jsxs("div",{className:"flex flex-col gap-4",children:[b.jsxs("div",{className:"flex items-center justify-between",children:[b.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-200",children:[b.jsx(Qb,{className:"size-4 text-neutral-400"}),"Background Jobs",S&&b.jsx("span",{className:"text-xs font-normal text-neutral-500",children:"(auto-refreshing)"})]}),b.jsxs("button",{onClick:()=>g(),disabled:a,className:"flex items-center gap-1.5 rounded px-2 py-1 text-xs text-neutral-400 hover:text-neutral-200 hover:bg-neutral-800 disabled:opacity-50 transition-colors",children:[b.jsx(yk,{className:oe("size-3",a&&"animate-spin")}),"Refresh"]})]}),o&&b.jsx("p",{className:"rounded border border-red-900/40 bg-red-950/30 px-3 py-2 text-xs text-red-400",children:o}),!a&&t.length===0&&!o&&b.jsx("p",{className:"text-sm text-neutral-500 text-center py-8",children:"No background jobs"}),p.length>0&&b.jsxs("div",{className:"flex flex-col gap-2",children:[b.jsx(Ib,{label:"Running",count:p.length}),p.map(E=>b.jsx(qb,{job:E,now:c,onCancel:y},E.jobId))]}),v.length>0&&b.jsxs("div",{className:"flex flex-col gap-2",children:[b.jsx(Ib,{label:"Settled",count:v.length}),v.map(E=>b.jsx(qb,{job:E,now:c,onCancel:y},E.jobId))]})]})}function eu({icon:t,title:r,children:a}){return b.jsxs("section",{className:"space-y-3",children:[b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx(t,{className:"size-4 text-muted-foreground"}),b.jsx("h2",{className:"text-sm font-semibold",children:r})]}),b.jsx("div",{className:"rounded-xl border border-border bg-card",children:a})]})}function Kt({label:t,value:r,mono:a=!1,last:u=!1}){return b.jsxs("div",{className:oe("flex items-center justify-between gap-4 px-4 py-2.5",!u&&"border-b border-border"),children:[b.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:t}),b.jsx("span",{className:oe("min-w-0 truncate text-right text-xs",a?"font-mono text-zinc-300":"text-zinc-200"),children:r})]})}function Bz({model:t,last:r}){return b.jsxs("div",{className:oe("flex items-center justify-between gap-4 px-4 py-2.5",!r&&"border-b border-border"),children:[b.jsx("span",{className:"text-xs text-zinc-200",children:t.label}),b.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:t.id})]})}const Vb=[{keys:"⌘K",description:"Open command palette"},{keys:"⌘1",description:"Go to Sessions"},{keys:"⌘2",description:"Go to Memory"},{keys:"⌘3",description:"Go to Schedules"},{keys:"⌘4",description:"Go to Background Jobs"}];function Hz({keys:t,description:r,last:a}){return b.jsxs("div",{className:oe("flex items-center justify-between gap-4 px-4 py-2.5",!a&&"border-b border-border"),children:[b.jsx("span",{className:"text-xs text-zinc-200",children:r}),b.jsx("kbd",{className:"rounded border border-border bg-secondary px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",children:t})]})}function qz({status:t}){return t?b.jsxs("span",{className:"flex items-center gap-1.5",children:[b.jsx("span",{className:oe("size-1.5 rounded-full",t.running?"animate-pulse bg-status-done":"bg-status-failed")}),b.jsx("span",{className:oe("text-xs",t.running?"text-zinc-200":"text-muted-foreground"),children:t.running?`Running${t.tasks!=null?` · ${t.tasks} task${t.tasks!==1?"s":""}`:""}`:"Stopped"})]}):b.jsx("span",{className:"text-xs text-muted-foreground",children:"–"})}function Iz(){var o;const[t,r]=w.useState({config:null,models:null,daemon:null,configError:null,modelsError:null,daemonError:null});w.useEffect(()=>{let f=!1;const c=m=>m instanceof Error?m.message:"Failed to load";return Promise.all([it("/api/config").then(m=>({ok:!0,config:m}),m=>({ok:!1,error:c(m)})),it("/api/models").then(m=>({ok:!0,models:m.models}),m=>({ok:!1,error:c(m)})),it("/api/daemon/status").then(m=>({ok:!0,daemon:m}),m=>({ok:!1,error:c(m)}))]).then(([m,h,g])=>{f||r({config:m.ok?m.config:null,configError:m.ok?null:m.error,models:h.ok?h.models:null,modelsError:h.ok?null:h.error,daemon:g.ok?g.daemon:null,daemonError:g.ok?null:g.error})}).catch(()=>{}),()=>{f=!0}},[]);const a=t.config,u=b.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading…"});return b.jsxs("div",{className:"flex flex-1 flex-col gap-6 overflow-y-auto p-4",children:[b.jsxs(eu,{icon:Pb,title:"About",children:[b.jsx(Kt,{label:"AFK version",value:a?a.version:u,mono:!0}),b.jsx(Kt,{label:"Node.js",value:a?a.nodeVersion:u,mono:!0}),b.jsx(Kt,{label:"App",value:"AFK Dashboard",last:!0})]}),b.jsxs(eu,{icon:nk,title:"Model",children:[b.jsx(Kt,{label:"Default model",value:a?a.model:u,mono:!0}),t.modelsError?b.jsx("div",{className:"px-4 py-3 text-xs text-status-failed",children:t.modelsError}):t.models===null?b.jsx(Kt,{label:"Available tiers",value:u,last:!0}):t.models.length===0?b.jsx(Kt,{label:"Available tiers",value:"None listed",last:!0}):t.models.map((f,c)=>{var m;return b.jsx(Bz,{model:f,last:c===(((m=t.models)==null?void 0:m.length)??0)-1},f.id)})]}),b.jsxs(eu,{icon:rk,title:"Paths",children:[b.jsx(Kt,{label:"AFK home",value:a?a.afkHome:u,mono:!0}),b.jsx(Kt,{label:"State dir",value:a?a.stateDir:u,mono:!0}),b.jsx(Kt,{label:"Config dir",value:a?a.configDir:u,mono:!0,last:!0})]}),b.jsxs(eu,{icon:Ya,title:"Web Server",children:[b.jsx(Kt,{label:"Host",value:a?a.webHost:u,mono:!0}),b.jsx(Kt,{label:"Port",value:a?String(a.webPort):u,mono:!0}),b.jsx(Kt,{label:"Daemon",value:b.jsx(qz,{status:t.daemon})}),!t.daemonError&&b.jsx(Kt,{label:"Tasks scheduled",value:((o=t.daemon)==null?void 0:o.tasks)!=null?String(t.daemon.tasks):"–",last:!0}),t.daemonError&&b.jsx(Kt,{label:"Daemon error",value:t.daemonError,last:!0})]}),b.jsx(eu,{icon:ak,title:"Keyboard Shortcuts",children:Vb.map((f,c)=>b.jsx(Hz,{keys:f.keys,description:f.description,last:c===Vb.length-1},f.keys))})]})}function dm(t){return t.startsWith("/")?t.slice(1):t}function B1(t){return`/${dm(t)}`}function H1(t,r){return dm(t).startsWith(dm(r))}function Vz({query:t,commands:r,onSelect:a,visible:u}){const[o,f]=w.useState(0),c=w.useRef(null),m=r.filter(h=>H1(h.name,t)).slice(0,8);return w.useEffect(()=>{f(0)},[t]),w.useEffect(()=>{var g;const h=(g=c.current)==null?void 0:g.children[o];h==null||h.scrollIntoView({block:"nearest"})},[o]),!u||m.length===0?null:b.jsx("ul",{ref:c,role:"listbox","aria-label":"Slash commands",className:oe("absolute bottom-full left-0 mb-1 w-full max-h-56 overflow-y-auto","rounded-lg border border-border bg-popover shadow-lg z-50","text-sm"),children:m.map((h,g)=>b.jsxs("li",{role:"option","aria-selected":g===o,className:oe("flex items-baseline gap-2 px-3 py-2 cursor-pointer select-none",g===o?"bg-accent text-accent-foreground":"hover:bg-accent/50"),onMouseEnter:()=>f(g),onMouseDown:y=>{y.preventDefault(),a(h.name)},children:[b.jsx("span",{className:"font-mono font-semibold shrink-0",children:B1(h.name)}),b.jsx("span",{className:"text-muted-foreground truncate",children:h.summary})]},h.name))})}function Yz(t,r,a,u,o,f,c){return!r||a===0?!1:t.key==="ArrowDown"?(o((u+1)%a),!0):t.key==="ArrowUp"?(o((u-1+a)%a),!0):t.key==="Enter"?(f(u),!0):t.key==="Escape"?(c(),!0):!1}function Gz(t){const r=t.trim();return r?r.startsWith("/")||r.startsWith("./")||r.startsWith("~/")||/^[\w.]/.test(r):!1}function Fz({onInsert:t}){const[r,a]=w.useState(!1),[u,o]=w.useState(""),[f,c]=w.useState(!1),m=w.useRef(null),h=w.useRef(null),g=w.useRef(null),y=w.useCallback(()=>{a(!1),c(!1),o("")},[]),p=w.useCallback(()=>{var S;const v=u.trim();if(!Gz(v)){c(!0),(S=m.current)==null||S.focus();return}t(`@${v}`),y()},[u,t,y]);return w.useEffect(()=>{r&&requestAnimationFrame(()=>{var v;return(v=m.current)==null?void 0:v.focus()})},[r]),w.useEffect(()=>{if(!r)return;function v(S){const E=S.target;h.current&&!h.current.contains(E)&&g.current&&!g.current.contains(E)&&y()}return document.addEventListener("click",v,{capture:!0}),()=>document.removeEventListener("click",v,{capture:!0})},[r,y]),b.jsxs("div",{className:"relative",children:[b.jsx("button",{ref:g,type:"button",onClick:()=>r?y():a(!0),"aria-label":"Insert file reference","aria-expanded":r,className:oe("flex h-8 w-8 items-center justify-center rounded-md text-sm","transition-colors hover:bg-accent hover:text-accent-foreground",r&&"bg-accent text-accent-foreground"),title:"Insert @file reference",children:b.jsx(lk,{className:"h-4 w-4"})}),r&&b.jsxs("div",{ref:h,role:"dialog","aria-label":"Insert file path",className:oe("absolute bottom-full left-0 mb-2 w-72 rounded-lg border","bg-popover p-3 shadow-lg animate-fade-in"),children:[b.jsxs("p",{className:"mb-2 text-xs text-muted-foreground",children:["Type a file path. ",b.jsx("code",{className:"text-[10px]",children:"@~/file.ts"})," or"," ",b.jsx("code",{className:"text-[10px]",children:"@src/file.ts"})]}),b.jsxs("div",{className:"flex gap-2",children:[b.jsx("input",{ref:m,type:"text",value:u,onChange:v=>{o(v.target.value),c(!1)},onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),p()),v.key==="Escape"&&y()},placeholder:"src/foo.ts or ~/file.ts",autoComplete:"off",spellCheck:!1,className:oe("flex-1 rounded-md border bg-secondary px-2 py-1 text-sm","placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring",f&&"border-destructive")}),b.jsx("button",{type:"button",onClick:p,className:oe("rounded-md bg-primary px-3 py-1 text-sm font-medium","text-primary-foreground hover:bg-primary/90"),children:"Add"})]}),f&&b.jsx("p",{className:"mt-1 text-xs text-destructive",children:"Enter a valid file path."})]})]})}const Xz=[{id:"sonnet",label:"Sonnet"},{id:"haiku",label:"Haiku"},{id:"opus",label:"Opus"}],Qz="sonnet";function Zz({onSelect:t,current:r,className:a}){const[u,o]=w.useState(Xz),f=w.useRef(!1);w.useEffect(()=>{let h=!1;return it("/api/models").then(g=>{!h&&g.models.length>0&&o(g.models)}).catch(()=>{}),()=>{h=!0}},[]);const c=r??Qz;w.useEffect(()=>{f.current||(f.current=!0,t(c))},[t,c]);const m=w.useCallback(h=>{t(h.target.value)},[t]);return b.jsxs("div",{className:oe("relative inline-flex items-center",a),children:[b.jsx("select",{value:c,onChange:m,"aria-label":"Model",className:oe("appearance-none rounded-md border bg-secondary pl-2 pr-7 py-1","text-xs font-medium text-secondary-foreground","cursor-pointer focus:outline-none focus:ring-1 focus:ring-ring"),children:u.map(h=>b.jsx("option",{value:h.id,children:h.label},h.id))}),b.jsx(ym,{className:"pointer-events-none absolute right-1.5 h-3 w-3 text-muted-foreground"})]})}function Kz({queue:t}){const{entries:r,moveItemUp:a,moveItemDown:u,removeItem:o,editItem:f}=t;return r.length===0?null:b.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/50 px-3 py-2",children:[b.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:["Queued (",r.length,")"]}),r.map((c,m)=>b.jsx(Pz,{text:c.text,isFirst:m===0,isLast:m===r.length-1,onMoveUp:()=>a(m),onMoveDown:()=>u(m),onRemove:()=>o(m),onEdit:h=>f(m,h)},c.id))]})}function Pz({text:t,isFirst:r,isLast:a,onMoveUp:u,onMoveDown:o,onRemove:f,onEdit:c}){const[m,h]=w.useState(!1),[g,y]=w.useState(t),p=w.useRef(null);w.useEffect(()=>{var T;m&&((T=p.current)==null||T.focus())},[m]);const v=w.useCallback(()=>{y(t),h(!0)},[t]),S=w.useCallback(()=>{const T=g.trim();T&&T!==t&&c(T),h(!1)},[g,t,c]),E=w.useCallback(()=>{h(!1),y(t)},[t]);return b.jsxs("div",{className:oe("group flex items-center gap-1.5 rounded-md border border-border/50","bg-secondary/50 px-2 py-1 text-sm animate-fade-in"),children:[m?b.jsx("input",{ref:p,type:"text",value:g,onChange:T=>y(T.target.value),onKeyDown:T=>{T.key==="Enter"&&S(),T.key==="Escape"&&E()},onBlur:S,className:oe("min-w-0 flex-1 bg-transparent text-sm","focus:outline-none")}):b.jsx("span",{className:"min-w-0 flex-1 truncate text-foreground/80",children:t}),b.jsxs("div",{className:"flex shrink-0 items-center gap-0.5 opacity-60 group-hover:opacity-100",children:[m?b.jsx(tu,{label:"Confirm edit",onClick:S,children:b.jsx(gm,{className:"h-3 w-3"})}):b.jsx(tu,{label:"Edit",onClick:v,children:b.jsx(mk,{className:"h-3 w-3"})}),b.jsx(tu,{label:"Move up",onClick:u,disabled:r,children:b.jsx(Zw,{className:"h-3 w-3"})}),b.jsx(tu,{label:"Move down",onClick:o,disabled:a,children:b.jsx(Xb,{className:"h-3 w-3"})}),b.jsx(tu,{label:"Remove",onClick:f,destructive:!0,children:b.jsx(bm,{className:"h-3 w-3"})})]})]})}function tu({label:t,onClick:r,disabled:a,destructive:u,children:o}){return b.jsx("button",{type:"button",onClick:r,disabled:a,"aria-label":t,title:t,className:oe("flex h-5 w-5 items-center justify-center rounded","transition-colors",a?"cursor-not-allowed opacity-30":u?"hover:bg-destructive/20 hover:text-destructive":"hover:bg-accent hover:text-accent-foreground"),children:o})}let lu=null;function Jz(){lu=null}async function $z(){return lu||(lu=(await it("/api/commands")).commands,lu)}function Wz(t){return t.startsWith("/")&&t.indexOf(" ")===-1?t.slice(1):null}function eO({sessionId:t,sessionMode:r,isBusy:a,queue:u,onModelSelect:o,currentModel:f}){const[c,m]=w.useState(""),[h,g]=w.useState(!1),[y,p]=w.useState([]),[v,S]=w.useState(0),E=w.useRef(null),T=r==="readonly",j=Wz(c),A=j!==null&&y.length>0,D=A?y.filter(q=>H1(q.name,j)).slice(0,8):[];w.useEffect(()=>{const q=()=>{document.visibilityState==="visible"&&Jz()};return document.addEventListener("visibilitychange",q),()=>document.removeEventListener("visibilitychange",q)},[]),w.useEffect(()=>{const q=E.current;if(!q)return;q.style.height="auto";const H=(parseInt(getComputedStyle(q).lineHeight)||20)*5;q.style.height=`${Math.min(q.scrollHeight,H)}px`},[c]),w.useEffect(()=>{j!==null&&$z().then(p).catch(()=>{})},[j]);const L=w.useCallback(async()=>{const q=c.trim();if(!(!q||h||T)){g(!0);try{await it(`/api/sessions/${t}/prompt`,{method:"POST",body:JSON.stringify({text:q})}),m("")}catch{}finally{g(!1)}}},[c,h,T,t]),P=w.useCallback(async()=>{try{await it(`/api/sessions/${t}/interrupt`,{method:"POST"})}catch{}},[t]),W=w.useCallback(q=>{var ie;m(`${B1(q)} `),S(0),(ie=E.current)==null||ie.focus()},[]),M=w.useCallback(q=>{if(Yz(q,A,D.length,v,S,H=>{const ne=D[H];ne&&W(ne.name)},()=>m(H=>H))){q.preventDefault();return}if(q.key==="Enter"&&!q.shiftKey)if(q.preventDefault(),a&&u){const H=c.trim();H&&(u.enqueue(H),m(""))}else L()},[A,D,v,W,L,a,c,u]),F=w.useCallback(q=>{const ie=E.current;if(!ie){m(X=>X+" "+q+" ");return}const H=ie.selectionStart??ie.value.length,ne=ie.selectionEnd??H,J=ie.value.slice(0,H),ve=ie.value.slice(ne),se=J.length>0&&!/\s$/.test(J)?" ":"",te=J+se+q+" "+ve;m(te),requestAnimationFrame(()=>{const X=H+se.length+q.length+1;ie.setSelectionRange(X,X),ie.focus()})},[]);return b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"pointer-events-none h-8 bg-gradient-to-t from-background/80 to-transparent"}),b.jsxs("div",{className:oe("relative flex flex-col gap-2","border-t border-border/50 px-4 py-3","backdrop-blur-xl bg-background/80","shadow-[0_-4px_16px_-4px_rgba(0,0,0,0.1)]",T&&"opacity-50"),children:[u&&b.jsx(Kz,{queue:u}),b.jsx(Vz,{query:j??"",commands:y,onSelect:W,visible:A}),b.jsxs("div",{className:"flex items-end gap-2",children:[b.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[b.jsx(Fz,{onInsert:F}),o&&b.jsx(Zz,{onSelect:o,current:f})]}),b.jsx("textarea",{ref:E,rows:1,value:c,disabled:T||h,onChange:q=>m(q.target.value),onKeyDown:M,placeholder:T?"Read-only session":"Send a message… (/ for commands)",className:oe("flex-1 resize-none rounded-xl border border-input bg-background","px-3 py-2 text-sm leading-5 shadow-sm","placeholder:text-muted-foreground","focus:outline-none focus:ring-2 focus:ring-ring","disabled:cursor-not-allowed")}),a?b.jsx("button",{onClick:()=>void P(),title:"Stop",className:"shrink-0 flex items-center justify-center h-9 w-9 rounded-lg bg-destructive text-destructive-foreground hover:bg-destructive/90 transition-colors",children:b.jsx($b,{className:"h-4 w-4 fill-current"})}):b.jsx("button",{onClick:()=>void L(),disabled:!c.trim()||h||T,title:"Send",className:oe("shrink-0 flex items-center justify-center h-9 w-9 rounded-lg","bg-primary text-primary-foreground hover:bg-primary/90 transition-colors","disabled:opacity-40 disabled:cursor-not-allowed"),children:b.jsx(bk,{className:"h-4 w-4"})})]})]})]})}async function tO(t){await it("/api/approve",{method:"POST",body:JSON.stringify(t)})}function nO({approval:t,onAnswered:r}){const{id:a,request:u}=t,[o,f]=w.useState(typeof u.questionDefault=="string"?u.questionDefault:""),[c,m]=w.useState(!1),[h,g]=w.useState(null),y=async(v,S)=>{m(!0),g(null);try{await tO({requestId:a,response:{action:v,content:S}}),r()}catch{g("Failed to submit — try again")}finally{m(!1)}},p=u.type??"confirm";return b.jsxs("div",{className:oe("rounded-lg border-2 border-yellow-500/60 bg-yellow-500/5 p-3 text-sm","flex flex-col gap-2"),children:[b.jsxs("div",{className:"flex items-start gap-2",children:[b.jsx(vk,{className:"h-4 w-4 text-yellow-500 mt-0.5 shrink-0"}),b.jsxs("div",{className:"flex-1 min-w-0",children:[u.title&&b.jsx("p",{className:"font-semibold text-foreground",children:u.title}),u.message&&b.jsx("p",{className:"text-muted-foreground",children:u.message}),u.description&&b.jsx("p",{className:"text-muted-foreground/80 text-xs mt-0.5",children:u.description})]}),b.jsx("button",{onClick:()=>void y("decline"),disabled:c,className:"shrink-0 text-muted-foreground hover:text-foreground",title:"Dismiss",children:b.jsx(bm,{className:"h-4 w-4"})})]}),p==="text"&&b.jsxs("div",{className:"flex gap-2",children:[b.jsx("input",{type:"text",value:o,onChange:v=>f(v.target.value),disabled:c,className:oe("flex-1 rounded border border-input bg-background px-2 py-1 text-sm","focus:outline-none focus:ring-1 focus:ring-ring")}),b.jsx(as,{onClick:()=>void y("accept",{text:o}),disabled:c,label:"Submit",variant:"primary"})]}),p==="confirm"&&b.jsxs("div",{className:"flex gap-2 justify-end",children:[b.jsx(as,{onClick:()=>void y("decline"),disabled:c,label:"No",variant:"ghost"}),b.jsx(as,{onClick:()=>void y("accept"),disabled:c,label:"Yes",variant:"primary"})]}),(p==="choice"||p==="multi_choice")&&b.jsx("div",{className:"flex flex-wrap gap-1.5",children:(u.choices??[]).map(v=>b.jsx(as,{onClick:()=>void y("accept",{choice:v}),disabled:c,label:v,variant:"outline"},v))}),h&&b.jsx("p",{className:"text-xs text-red-400",children:h})]})}function as({onClick:t,disabled:r,label:a,variant:u}){return b.jsx("button",{onClick:t,disabled:r,className:oe("rounded px-3 py-1 text-xs font-medium transition-colors disabled:opacity-50",u==="primary"&&"bg-primary text-primary-foreground hover:bg-primary/90",u==="ghost"&&"text-muted-foreground hover:text-foreground hover:bg-accent",u==="outline"&&"border border-border hover:bg-accent"),children:a})}function lO({approvals:t,onDismiss:r}){const[a,u]=w.useState(new Set),o=t.filter(c=>!a.has(c.id));if(o.length===0)return null;const f=c=>{u(m=>new Set([...m,c])),r==null||r()};return b.jsx("div",{className:"flex flex-col gap-2",children:o.map(c=>b.jsx(nO,{approval:c,onAnswered:()=>f(c.id)},c.id))})}function rO({open:t,onClose:r,children:a}){return b.jsxs(b.Fragment,{children:[b.jsx("div",{className:oe("fixed inset-0 z-40 bg-black/50 transition-opacity duration-200 md:hidden",t?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"),onClick:r,"aria-hidden":"true"}),b.jsx("div",{className:oe("fixed inset-y-0 left-0 z-50 w-64 bg-sidebar transition-transform duration-200 ease-in-out md:hidden",t?"translate-x-0":"-translate-x-full"),role:"dialog","aria-modal":"true",children:a})]})}function aO({onClick:t,className:r}){return b.jsx("button",{onClick:t,className:oe("inline-flex items-center justify-center rounded-md p-2 text-muted-foreground hover:bg-muted hover:text-foreground md:hidden",r),"aria-label":"Open sidebar",children:b.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:b.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h16"})})})}const iO=w.createContext(null),uO={success:"bg-green-600 text-white",error:"bg-red-600 text-white",info:"bg-muted text-muted-foreground border border-border"};function oO({children:t}){const[r,a]=w.useState([]),u=w.useRef(0),o=w.useCallback((f,c="info")=>{const m=++u.current;a(h=>[...h.slice(-2),{id:m,message:f,type:c}]),setTimeout(()=>{a(h=>h.filter(g=>g.id!==m))},3e3)},[]);return b.jsxs(iO.Provider,{value:{toast:o},children:[t,b.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2 pointer-events-none","aria-live":"polite","aria-label":"Notifications",children:r.map(f=>b.jsx("div",{className:oe("pointer-events-auto max-w-sm rounded-lg px-4 py-3 text-sm shadow-lg animate-slide-in-right",uO[f.type]),children:f.message},f.id))})]})}const sO=1e4;function cO(){const[t,r]=w.useState([]),[a,u]=w.useState(!0),[o,f]=w.useState(null),c=w.useRef(void 0),m=w.useCallback(async()=>{try{const h=await it("/api/sessions");r(fO(h.sessions)),f(null)}catch(h){f(h instanceof Error?h.message:"Failed to fetch sessions")}finally{u(!1)}},[]);return w.useEffect(()=>(m(),c.current=setInterval(()=>void m(),sO),()=>clearInterval(c.current)),[m]),{sessions:t,loading:a,error:o,refresh:m}}function fO(t){return[...t].sort((r,a)=>{const u=Yb(r)?1:0,o=Yb(a)?1:0;if(u!==o)return o-u;const f=r.updatedAt?new Date(r.updatedAt).getTime():0;return(a.updatedAt?new Date(a.updatedAt).getTime():0)-f})}function Yb(t){return t.mode==="live"||t.alive===!0}const dO=1e3;function mO(){const[t,r]=w.useState([]),a=w.useRef(void 0),u=w.useCallback(async()=>{try{const f=await it("/api/pending");r(f.pending)}catch{}},[]);w.useEffect(()=>(u(),a.current=setInterval(()=>void u(),dO),()=>clearInterval(a.current)),[u]);const o=new Set(t.map(f=>f.sessionId).filter(f=>!!f));return{approvals:t,pendingSessionIds:o}}const hO=15e3,pO=500;function gO(t){const a=t.replace(/\r\n/g,`
|
|
377
377
|
`).split(`
|