@pi-outpost/embed 0.28.1 → 0.29.0

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.
@@ -35574,7 +35574,7 @@ function Xg(e, t) {
35574
35574
  }
35575
35575
  //#endregion
35576
35576
  //#region ../ui/src/export/xmlText.ts
35577
- var Zg = "�", Qg = /[- -￾￿]/g, $g = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
35577
+ var Zg = "�", Qg = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]/g, $g = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
35578
35578
  function e_(e) {
35579
35579
  return e.replace(Qg, Zg).replace($g, Zg);
35580
35580
  }
@@ -277,7 +277,7 @@ l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
277
277
  |[ \r ]+
278
278
  ?)[ \r ]*`,tg=`[̀-ͯ]`,ng=RegExp(tg+`+$`),rg=`(`+Xh+`+)|`+(eg+`|`)+`([!-\\[\\]-‧‪-퟿豈-￿]`+(tg+`*`)+`|[\ud800-\udbff][\udc00-\udfff]`+(tg+`*`)+`|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5`+(`|`+$h)+(`|`+Qh+`)`),ig=class{constructor(e,t){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=t,this.tokenRegex=new RegExp(rg,`g`),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){var e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new ah(`EOF`,new ih(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new B(`Unexpected character: '`+e[t]+`'`,new ah(e[t],new ih(this,t,t+1)));var r=n[6]||n[3]||(n[2]?`\\ `:` `);if(this.catcodes[r]===14){var i=e.indexOf(`
279
279
  `,this.tokenRegex.lastIndex);return i===-1?(this.tokenRegex.lastIndex=e.length,this.settings.reportNonstrict(`commentAtEnd`,`% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)`)):this.tokenRegex.lastIndex=i+1,this.lex()}return new ah(r,new ih(this,t,this.tokenRegex.lastIndex))}},ag=class{constructor(e,t){e===void 0&&(e={}),t===void 0&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new B(`Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug`);var e=this.undefStack.pop();for(var t of Object.keys(e))e[t]===void 0?delete this.current[t]:this.current[t]=e[t]}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return Object.prototype.hasOwnProperty.call(this.current,e)||Object.prototype.hasOwnProperty.call(this.builtins,e)}get(e){if(Object.prototype.hasOwnProperty.call(this.current,e))return this.current[e];if(Object.prototype.hasOwnProperty.call(this.builtins,e))return this.builtins[e]}set(e,t,n){if(n===void 0&&(n=!1),n){for(var r=0;r<this.undefStack.length;r++)delete this.undefStack[r][e];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{var i=this.undefStack[this.undefStack.length-1];i&&!Object.prototype.hasOwnProperty.call(i,e)&&(i[e]=Object.prototype.hasOwnProperty.call(this.current,e)?this.current[e]:void 0)}t==null?delete this.current[e]:this.current[e]=t}},og=rh;$(`\\noexpand`,function(e){var t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),$(`\\expandafter`,function(e){var t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}}),$(`\\@firstoftwo`,function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),$(`\\@secondoftwo`,function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),$(`\\@ifnextchar`,function(e){var t=e.consumeArgs(3);e.consumeSpaces();var n=e.future();return t[0].length===1&&t[0][0].text===n.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}}),$(`\\@ifstar`,`\\@ifnextchar *{\\@firstoftwo{#1}}`),$(`\\TextOrMath`,function(e){var t=e.consumeArgs(2);return e.mode===`text`?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});var sg={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};$(`\\char`,function(e){var t=e.popToken(),n,r=0;if(t.text===`'`)n=8,t=e.popToken();else if(t.text===`"`)n=16,t=e.popToken();else if(t.text==="`"){if(t=e.popToken(),t.text[0]===`\\`)r=t.text.charCodeAt(1);else if(t.text===`EOF`)throw new B("\\char` missing argument");else r=t.text.charCodeAt(0)}else n=10;if(n){if(r=sg[t.text],r==null||r>=n)throw new B(`Invalid base-`+n+` digit `+t.text);for(var i;(i=sg[e.future().text])!=null&&i<n;)r*=n,r+=i,e.popToken()}return`\\@char{`+r+`}`});var cg=(e,t,n,r)=>{var i=e.consumeArg().tokens;if(i.length!==1)throw new B(`\\newcommand's first argument must be a macro name`);var a=i[0].text,o=e.isDefined(a);if(o&&!t)throw new B(`\\newcommand{`+a+`} attempting to redefine `+(a+`; use \\renewcommand`));if(!o&&!n)throw new B(`\\renewcommand{`+a+`} when command `+a+` does not yet exist; use \\newcommand`);var s=0;if(i=e.consumeArg().tokens,i.length===1&&i[0].text===`[`){for(var c=``,l=e.expandNextToken();l.text!==`]`&&l.text!==`EOF`;)c+=l.text,l=e.expandNextToken();if(!c.match(/^\s*[0-9]+\s*$/))throw new B(`Invalid number of arguments: `+c);s=parseInt(c),i=e.consumeArg().tokens}return o&&r||e.macros.set(a,{tokens:i,numArgs:s}),``};$(`\\newcommand`,e=>cg(e,!1,!0,!1)),$(`\\renewcommand`,e=>cg(e,!0,!1,!1)),$(`\\providecommand`,e=>cg(e,!0,!0,!0)),$(`\\message`,e=>{var t=e.consumeArgs(1)[0];return console.log(t.reverse().map(e=>e.text).join(``)),``}),$(`\\errmessage`,e=>{var t=e.consumeArgs(1)[0];return console.error(t.reverse().map(e=>e.text).join(``)),``}),$(`\\show`,e=>{var t=e.popToken(),n=t.text;return console.log(t,e.macros.get(n),Yh[n],Vd.math[n],Vd.text[n]),``}),$(`\\bgroup`,`{`),$(`\\egroup`,`}`),$(`~`,`\\nobreakspace`),$(`\\lq`,"`"),$(`\\rq`,`'`),$(`\\aa`,`\\r a`),$(`\\AA`,`\\r A`),$(`\\textcopyright`,"\\html@mathml{\\textcircled{c}}{\\char`©}"),$(`\\copyright`,`\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}`),$(`\\textregistered`,"\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"),$(`ℬ`,`\\mathscr{B}`),$(`ℰ`,`\\mathscr{E}`),$(`ℱ`,`\\mathscr{F}`),$(`ℋ`,`\\mathscr{H}`),$(`ℐ`,`\\mathscr{I}`),$(`ℒ`,`\\mathscr{L}`),$(`ℳ`,`\\mathscr{M}`),$(`ℛ`,`\\mathscr{R}`),$(`ℭ`,`\\mathfrak{C}`),$(`ℌ`,`\\mathfrak{H}`),$(`ℨ`,`\\mathfrak{Z}`),$(`\\Bbbk`,`\\Bbb{k}`),$(`\\llap`,`\\mathllap{\\textrm{#1}}`),$(`\\rlap`,`\\mathrlap{\\textrm{#1}}`),$(`\\clap`,`\\mathclap{\\textrm{#1}}`),$(`\\mathstrut`,`\\vphantom{(}`),$(`\\underbar`,`\\underline{\\text{#1}}`),$(`\\not`,`\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}{\\char"338}`),$(`\\neq`,"\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"),$(`\\ne`,`\\neq`),$(`≠`,`\\neq`),$(`\\notin`,"\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`∉}}"),$(`∉`,`\\notin`),$(`≘`,"\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`≘}}"),$(`≙`,"\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`≘}}"),$(`≚`,"\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`≚}}"),$(`≛`,"\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`≛}}"),$(`≝`,"\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`≝}}"),$(`≞`,"\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`≞}}"),$(`≟`,"\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`≟}}"),$(`⟂`,`\\perp`),$(`‼`,`\\mathclose{!\\mkern-0.8mu!}`),$(`∌`,`\\notni`),$(`⌜`,`\\ulcorner`),$(`⌝`,`\\urcorner`),$(`⌞`,`\\llcorner`),$(`⌟`,`\\lrcorner`),$(`©`,`\\copyright`),$(`®`,`\\textregistered`),$(`\\ulcorner`,`\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}`),$(`\\urcorner`,`\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}`),$(`\\llcorner`,`\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}`),$(`\\lrcorner`,`\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}`),$(`\\vdots`,`{\\varvdots\\rule{0pt}{15pt}}`),$(`⋮`,`\\vdots`),$(`\\varGamma`,`\\mathit{\\Gamma}`),$(`\\varDelta`,`\\mathit{\\Delta}`),$(`\\varTheta`,`\\mathit{\\Theta}`),$(`\\varLambda`,`\\mathit{\\Lambda}`),$(`\\varXi`,`\\mathit{\\Xi}`),$(`\\varPi`,`\\mathit{\\Pi}`),$(`\\varSigma`,`\\mathit{\\Sigma}`),$(`\\varUpsilon`,`\\mathit{\\Upsilon}`),$(`\\varPhi`,`\\mathit{\\Phi}`),$(`\\varPsi`,`\\mathit{\\Psi}`),$(`\\varOmega`,`\\mathit{\\Omega}`),$(`\\substack`,`\\begin{subarray}{c}#1\\end{subarray}`),$(`\\colon`,`\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax`),$(`\\boxed`,`\\fbox{$\\displaystyle{#1}$}`),$(`\\iff`,`\\DOTSB\\;\\Longleftrightarrow\\;`),$(`\\implies`,`\\DOTSB\\;\\Longrightarrow\\;`),$(`\\impliedby`,`\\DOTSB\\;\\Longleftarrow\\;`),$(`\\dddot`,`{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}`),$(`\\ddddot`,`{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}`);var lg={",":`\\dotsc`,"\\not":`\\dotsb`,"+":`\\dotsb`,"=":`\\dotsb`,"<":`\\dotsb`,">":`\\dotsb`,"-":`\\dotsb`,"*":`\\dotsb`,":":`\\dotsb`,"\\DOTSB":`\\dotsb`,"\\coprod":`\\dotsb`,"\\bigvee":`\\dotsb`,"\\bigwedge":`\\dotsb`,"\\biguplus":`\\dotsb`,"\\bigcap":`\\dotsb`,"\\bigcup":`\\dotsb`,"\\prod":`\\dotsb`,"\\sum":`\\dotsb`,"\\bigotimes":`\\dotsb`,"\\bigoplus":`\\dotsb`,"\\bigodot":`\\dotsb`,"\\bigsqcup":`\\dotsb`,"\\And":`\\dotsb`,"\\longrightarrow":`\\dotsb`,"\\Longrightarrow":`\\dotsb`,"\\longleftarrow":`\\dotsb`,"\\Longleftarrow":`\\dotsb`,"\\longleftrightarrow":`\\dotsb`,"\\Longleftrightarrow":`\\dotsb`,"\\mapsto":`\\dotsb`,"\\longmapsto":`\\dotsb`,"\\hookrightarrow":`\\dotsb`,"\\doteq":`\\dotsb`,"\\mathbin":`\\dotsb`,"\\mathrel":`\\dotsb`,"\\relbar":`\\dotsb`,"\\Relbar":`\\dotsb`,"\\xrightarrow":`\\dotsb`,"\\xleftarrow":`\\dotsb`,"\\DOTSI":`\\dotsi`,"\\int":`\\dotsi`,"\\oint":`\\dotsi`,"\\iint":`\\dotsi`,"\\iiint":`\\dotsi`,"\\iiiint":`\\dotsi`,"\\idotsint":`\\dotsi`,"\\DOTSX":`\\dotsx`},ug=new Set([`bin`,`rel`]);$(`\\dots`,function(e){var t=`\\dotso`,n=e.expandAfterFuture().text;return n in lg?t=lg[n]:(n.slice(0,4)===`\\not`||n in Vd.math&&ug.has(Vd.math[n].group))&&(t=`\\dotsb`),t});var dg={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};$(`\\dotso`,function(e){return e.future().text in dg?`\\ldots\\,`:`\\ldots`}),$(`\\dotsc`,function(e){var t=e.future().text;return t in dg&&t!==`,`?`\\ldots\\,`:`\\ldots`}),$(`\\cdots`,function(e){return e.future().text in dg?`\\@cdots\\,`:`\\@cdots`}),$(`\\dotsb`,`\\cdots`),$(`\\dotsm`,`\\cdots`),$(`\\dotsi`,`\\!\\cdots`),$(`\\dotsx`,`\\ldots\\,`),$(`\\DOTSI`,`\\relax`),$(`\\DOTSB`,`\\relax`),$(`\\DOTSX`,`\\relax`),$(`\\tmspace`,`\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax`),$(`\\,`,`\\tmspace+{3mu}{.1667em}`),$(`\\thinspace`,`\\,`),$(`\\>`,`\\mskip{4mu}`),$(`\\:`,`\\tmspace+{4mu}{.2222em}`),$(`\\medspace`,`\\:`),$(`\\;`,`\\tmspace+{5mu}{.2777em}`),$(`\\thickspace`,`\\;`),$(`\\!`,`\\tmspace-{3mu}{.1667em}`),$(`\\negthinspace`,`\\!`),$(`\\negmedspace`,`\\tmspace-{4mu}{.2222em}`),$(`\\negthickspace`,`\\tmspace-{5mu}{.277em}`),$(`\\enspace`,`\\kern.5em `),$(`\\enskip`,`\\hskip.5em\\relax`),$(`\\quad`,`\\hskip1em\\relax`),$(`\\qquad`,`\\hskip2em\\relax`),$(`\\tag`,`\\@ifstar\\tag@literal\\tag@paren`),$(`\\tag@paren`,`\\tag@literal{({#1})}`),$(`\\tag@literal`,e=>{if(e.macros.get(`\\df@tag`))throw new B(`Multiple \\tag`);return`\\gdef\\df@tag{\\text{#1}}`}),$(`\\bmod`,`\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}`),$(`\\pod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)`),$(`\\pmod`,`\\pod{{\\rm mod}\\mkern6mu#1}`),$(`\\mod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1`),$(`\\newline`,`\\\\\\relax`),$(`\\TeX`,`\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}`);var fg=V(Pd[`Main-Regular`][84][1]-.7*Pd[`Main-Regular`][65][1]);$(`\\LaTeX`,`\\textrm{\\html@mathml{`+(`L\\kern-.36em\\raisebox{`+fg+`}{\\scriptstyle A}`)+`\\kern-.15em\\TeX}{LaTeX}}`),$(`\\KaTeX`,`\\textrm{\\html@mathml{`+(`K\\kern-.17em\\raisebox{`+fg+`}{\\scriptstyle A}`)+`\\kern-.15em\\TeX}{KaTeX}}`),$(`\\hspace`,`\\@ifstar\\@hspacer\\@hspace`),$(`\\@hspace`,`\\hskip #1\\relax`),$(`\\@hspacer`,`\\rule{0pt}{0pt}\\hskip #1\\relax`),$(`\\ordinarycolon`,`:`),$(`\\vcentcolon`,`\\mathrel{\\mathop\\ordinarycolon}`),$(`\\dblcolon`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}`),$(`\\coloneqq`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}`),$(`\\Coloneqq`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}`),$(`\\coloneq`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}`),$(`\\Coloneq`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}`),$(`\\eqqcolon`,`\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}`),$(`\\Eqqcolon`,`\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}`),$(`\\eqcolon`,`\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}`),$(`\\Eqcolon`,`\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}`),$(`\\colonapprox`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}`),$(`\\Colonapprox`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}`),$(`\\colonsim`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}`),$(`\\Colonsim`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}`),$(`∷`,`\\dblcolon`),$(`∹`,`\\eqcolon`),$(`≔`,`\\coloneqq`),$(`≕`,`\\eqqcolon`),$(`⩴`,`\\Coloneqq`),$(`\\ratio`,`\\vcentcolon`),$(`\\coloncolon`,`\\dblcolon`),$(`\\colonequals`,`\\coloneqq`),$(`\\coloncolonequals`,`\\Coloneqq`),$(`\\equalscolon`,`\\eqqcolon`),$(`\\equalscoloncolon`,`\\Eqqcolon`),$(`\\colonminus`,`\\coloneq`),$(`\\coloncolonminus`,`\\Coloneq`),$(`\\minuscolon`,`\\eqcolon`),$(`\\minuscoloncolon`,`\\Eqcolon`),$(`\\coloncolonapprox`,`\\Colonapprox`),$(`\\coloncolonsim`,`\\Colonsim`),$(`\\simcolon`,`\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}`),$(`\\simcoloncolon`,`\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}`),$(`\\approxcolon`,`\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}`),$(`\\approxcoloncolon`,`\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}`),$(`\\notni`,"\\html@mathml{\\not\\ni}{\\mathrel{\\char`∌}}"),$(`\\limsup`,`\\DOTSB\\operatorname*{lim\\,sup}`),$(`\\liminf`,`\\DOTSB\\operatorname*{lim\\,inf}`),$(`\\injlim`,`\\DOTSB\\operatorname*{inj\\,lim}`),$(`\\projlim`,`\\DOTSB\\operatorname*{proj\\,lim}`),$(`\\varlimsup`,`\\DOTSB\\operatorname*{\\overline{lim}}`),$(`\\varliminf`,`\\DOTSB\\operatorname*{\\underline{lim}}`),$(`\\varinjlim`,`\\DOTSB\\operatorname*{\\underrightarrow{lim}}`),$(`\\varprojlim`,`\\DOTSB\\operatorname*{\\underleftarrow{lim}}`),$(`\\gvertneqq`,`\\html@mathml{\\@gvertneqq}{≩}`),$(`\\lvertneqq`,`\\html@mathml{\\@lvertneqq}{≨}`),$(`\\ngeqq`,`\\html@mathml{\\@ngeqq}{≱}`),$(`\\ngeqslant`,`\\html@mathml{\\@ngeqslant}{≱}`),$(`\\nleqq`,`\\html@mathml{\\@nleqq}{≰}`),$(`\\nleqslant`,`\\html@mathml{\\@nleqslant}{≰}`),$(`\\nshortmid`,`\\html@mathml{\\@nshortmid}{∤}`),$(`\\nshortparallel`,`\\html@mathml{\\@nshortparallel}{∦}`),$(`\\nsubseteqq`,`\\html@mathml{\\@nsubseteqq}{⊈}`),$(`\\nsupseteqq`,`\\html@mathml{\\@nsupseteqq}{⊉}`),$(`\\varsubsetneq`,`\\html@mathml{\\@varsubsetneq}{⊊}`),$(`\\varsubsetneqq`,`\\html@mathml{\\@varsubsetneqq}{⫋}`),$(`\\varsupsetneq`,`\\html@mathml{\\@varsupsetneq}{⊋}`),$(`\\varsupsetneqq`,`\\html@mathml{\\@varsupsetneqq}{⫌}`),$(`\\imath`,`\\html@mathml{\\@imath}{ı}`),$(`\\jmath`,`\\html@mathml{\\@jmath}{ȷ}`),$(`\\llbracket`,"\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`⟦}}"),$(`\\rrbracket`,"\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`⟧}}"),$(`⟦`,`\\llbracket`),$(`⟧`,`\\rrbracket`),$(`\\lBrace`,"\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`⦃}}"),$(`\\rBrace`,"\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`⦄}}"),$(`⦃`,`\\lBrace`),$(`⦄`,`\\rBrace`),$(`\\minuso`,"\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`⦵}}"),$(`⦵`,`\\minuso`),$(`\\darr`,`\\downarrow`),$(`\\dArr`,`\\Downarrow`),$(`\\Darr`,`\\Downarrow`),$(`\\lang`,`\\langle`),$(`\\rang`,`\\rangle`),$(`\\uarr`,`\\uparrow`),$(`\\uArr`,`\\Uparrow`),$(`\\Uarr`,`\\Uparrow`),$(`\\N`,`\\mathbb{N}`),$(`\\R`,`\\mathbb{R}`),$(`\\Z`,`\\mathbb{Z}`),$(`\\alef`,`\\aleph`),$(`\\alefsym`,`\\aleph`),$(`\\Alpha`,`\\mathrm{A}`),$(`\\Beta`,`\\mathrm{B}`),$(`\\bull`,`\\bullet`),$(`\\Chi`,`\\mathrm{X}`),$(`\\clubs`,`\\clubsuit`),$(`\\cnums`,`\\mathbb{C}`),$(`\\Complex`,`\\mathbb{C}`),$(`\\Dagger`,`\\ddagger`),$(`\\diamonds`,`\\diamondsuit`),$(`\\empty`,`\\emptyset`),$(`\\Epsilon`,`\\mathrm{E}`),$(`\\Eta`,`\\mathrm{H}`),$(`\\exist`,`\\exists`),$(`\\harr`,`\\leftrightarrow`),$(`\\hArr`,`\\Leftrightarrow`),$(`\\Harr`,`\\Leftrightarrow`),$(`\\hearts`,`\\heartsuit`),$(`\\image`,`\\Im`),$(`\\infin`,`\\infty`),$(`\\Iota`,`\\mathrm{I}`),$(`\\isin`,`\\in`),$(`\\Kappa`,`\\mathrm{K}`),$(`\\larr`,`\\leftarrow`),$(`\\lArr`,`\\Leftarrow`),$(`\\Larr`,`\\Leftarrow`),$(`\\lrarr`,`\\leftrightarrow`),$(`\\lrArr`,`\\Leftrightarrow`),$(`\\Lrarr`,`\\Leftrightarrow`),$(`\\Mu`,`\\mathrm{M}`),$(`\\natnums`,`\\mathbb{N}`),$(`\\Nu`,`\\mathrm{N}`),$(`\\Omicron`,`\\mathrm{O}`),$(`\\plusmn`,`\\pm`),$(`\\rarr`,`\\rightarrow`),$(`\\rArr`,`\\Rightarrow`),$(`\\Rarr`,`\\Rightarrow`),$(`\\real`,`\\Re`),$(`\\reals`,`\\mathbb{R}`),$(`\\Reals`,`\\mathbb{R}`),$(`\\Rho`,`\\mathrm{P}`),$(`\\sdot`,`\\cdot`),$(`\\sect`,`\\S`),$(`\\spades`,`\\spadesuit`),$(`\\sub`,`\\subset`),$(`\\sube`,`\\subseteq`),$(`\\supe`,`\\supseteq`),$(`\\Tau`,`\\mathrm{T}`),$(`\\thetasym`,`\\vartheta`),$(`\\weierp`,`\\wp`),$(`\\Zeta`,`\\mathrm{Z}`),$(`\\argmin`,`\\DOTSB\\operatorname*{arg\\,min}`),$(`\\argmax`,`\\DOTSB\\operatorname*{arg\\,max}`),$(`\\plim`,`\\DOTSB\\mathop{\\operatorname{plim}}\\limits`),$(`\\bra`,`\\mathinner{\\langle{#1}|}`),$(`\\ket`,`\\mathinner{|{#1}\\rangle}`),$(`\\braket`,`\\mathinner{\\langle{#1}\\rangle}`),$(`\\Bra`,`\\left\\langle#1\\right|`),$(`\\Ket`,`\\left|#1\\right\\rangle`);var pg=e=>t=>{var n=t.consumeArg().tokens,r=t.consumeArg().tokens,i=t.consumeArg().tokens,a=t.consumeArg().tokens,o=t.macros.get(`|`),s=t.macros.get(`\\|`);t.macros.beginGroup();var c=t=>n=>{e&&(n.macros.set(`|`,o),i.length&&n.macros.set(`\\|`,s));var a=t;return!t&&i.length&&n.future().text===`|`&&(n.popToken(),a=!0),{tokens:a?i:r,numArgs:0}};t.macros.set(`|`,c(!1)),i.length&&t.macros.set(`\\|`,c(!0));var l=t.consumeArg().tokens,u=t.expandTokens([...a,...l,...n]);return t.macros.endGroup(),{tokens:u.reverse(),numArgs:0}};$(`\\bra@ket`,pg(!1)),$(`\\bra@set`,pg(!0)),$(`\\Braket`,`\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}`),$(`\\Set`,`\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}`),$(`\\set`,`\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}`),$(`\\angln`,`{\\angl n}`),$(`\\blue`,`\\textcolor{##6495ed}{#1}`),$(`\\orange`,`\\textcolor{##ffa500}{#1}`),$(`\\pink`,`\\textcolor{##ff00af}{#1}`),$(`\\red`,`\\textcolor{##df0030}{#1}`),$(`\\green`,`\\textcolor{##28ae7b}{#1}`),$(`\\gray`,`\\textcolor{gray}{#1}`),$(`\\purple`,`\\textcolor{##9d38bd}{#1}`),$(`\\blueA`,`\\textcolor{##ccfaff}{#1}`),$(`\\blueB`,`\\textcolor{##80f6ff}{#1}`),$(`\\blueC`,`\\textcolor{##63d9ea}{#1}`),$(`\\blueD`,`\\textcolor{##11accd}{#1}`),$(`\\blueE`,`\\textcolor{##0c7f99}{#1}`),$(`\\tealA`,`\\textcolor{##94fff5}{#1}`),$(`\\tealB`,`\\textcolor{##26edd5}{#1}`),$(`\\tealC`,`\\textcolor{##01d1c1}{#1}`),$(`\\tealD`,`\\textcolor{##01a995}{#1}`),$(`\\tealE`,`\\textcolor{##208170}{#1}`),$(`\\greenA`,`\\textcolor{##b6ffb0}{#1}`),$(`\\greenB`,`\\textcolor{##8af281}{#1}`),$(`\\greenC`,`\\textcolor{##74cf70}{#1}`),$(`\\greenD`,`\\textcolor{##1fab54}{#1}`),$(`\\greenE`,`\\textcolor{##0d923f}{#1}`),$(`\\goldA`,`\\textcolor{##ffd0a9}{#1}`),$(`\\goldB`,`\\textcolor{##ffbb71}{#1}`),$(`\\goldC`,`\\textcolor{##ff9c39}{#1}`),$(`\\goldD`,`\\textcolor{##e07d10}{#1}`),$(`\\goldE`,`\\textcolor{##a75a05}{#1}`),$(`\\redA`,`\\textcolor{##fca9a9}{#1}`),$(`\\redB`,`\\textcolor{##ff8482}{#1}`),$(`\\redC`,`\\textcolor{##f9685d}{#1}`),$(`\\redD`,`\\textcolor{##e84d39}{#1}`),$(`\\redE`,`\\textcolor{##bc2612}{#1}`),$(`\\maroonA`,`\\textcolor{##ffbde0}{#1}`),$(`\\maroonB`,`\\textcolor{##ff92c6}{#1}`),$(`\\maroonC`,`\\textcolor{##ed5fa6}{#1}`),$(`\\maroonD`,`\\textcolor{##ca337c}{#1}`),$(`\\maroonE`,`\\textcolor{##9e034e}{#1}`),$(`\\purpleA`,`\\textcolor{##ddd7ff}{#1}`),$(`\\purpleB`,`\\textcolor{##c6b9fc}{#1}`),$(`\\purpleC`,`\\textcolor{##aa87ff}{#1}`),$(`\\purpleD`,`\\textcolor{##7854ab}{#1}`),$(`\\purpleE`,`\\textcolor{##543b78}{#1}`),$(`\\mintA`,`\\textcolor{##f5f9e8}{#1}`),$(`\\mintB`,`\\textcolor{##edf2df}{#1}`),$(`\\mintC`,`\\textcolor{##e0e5cc}{#1}`),$(`\\grayA`,`\\textcolor{##f6f7f7}{#1}`),$(`\\grayB`,`\\textcolor{##f0f1f2}{#1}`),$(`\\grayC`,`\\textcolor{##e3e5e6}{#1}`),$(`\\grayD`,`\\textcolor{##d6d8da}{#1}`),$(`\\grayE`,`\\textcolor{##babec2}{#1}`),$(`\\grayF`,`\\textcolor{##888d93}{#1}`),$(`\\grayG`,`\\textcolor{##626569}{#1}`),$(`\\grayH`,`\\textcolor{##3b3e40}{#1}`),$(`\\grayI`,`\\textcolor{##21242c}{#1}`),$(`\\kaBlue`,`\\textcolor{##314453}{#1}`),$(`\\kaGreen`,`\\textcolor{##71B307}{#1}`);var mg={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0},hg=class{constructor(e,t,n){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new ag(og,t.macros),this.mode=n,this.stack=[]}feed(e){this.lexer=new ig(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){var t,n,r;if(e){if(this.consumeSpaces(),this.future().text!==`[`)return null;t=this.popToken();var i=this.consumeArg([`]`]);r=i.tokens,n=i.end}else{var a=this.consumeArg();r=a.tokens,t=a.start,n=a.end}return this.pushToken(new ah(`EOF`,n.loc)),this.pushTokens(r),new ah(``,ih.range(t,n))}consumeSpaces(){for(;this.future().text===` `;)this.stack.pop()}consumeArg(e){var t=[],n=e&&e.length>0;n||this.consumeSpaces();var r=this.future(),i,a=0,o=0;do{if(i=this.popToken(),t.push(i),i.text===`{`)++a;else if(i.text===`}`){if(--a,a===-1)throw new B(`Extra }`,i)}else if(i.text===`EOF`)throw new B(`Unexpected end of input in a macro argument, expected '`+(e&&n?e[o]:`}`)+`'`,i);if(e&&n){if((a===0||a===1&&e[o]===`{`)&&i.text===e[o]){if(++o,o===e.length){t.splice(-o,o);break}}else o=0}}while(a!==0||n);return r.text===`{`&&t[t.length-1].text===`}`&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:r,end:i}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new B(`The length of delimiters doesn't match the number of args!`);for(var n=t[0],r=0;r<n.length;r++){var i=this.popToken();if(n[r]!==i.text)throw new B(`Use of the macro doesn't match its definition`,i)}}for(var a=[],o=0;o<e;o++)a.push(this.consumeArg(t&&t[o+1]).tokens);return a}countExpansion(e){if(this.expansionCount+=e,this.expansionCount>this.settings.maxExpand)throw new B(`Too many expansions: infinite loop or need to increase maxExpand setting`)}expandOnce(e){var t=this.popToken(),n=t.text,r=t.noexpand?null:this._getExpansion(n);if(r==null||e&&r.unexpandable){if(e&&r==null&&n[0]===`\\`&&!this.isDefined(n))throw new B(`Undefined control sequence: `+n);return this.pushToken(t),!1}this.countExpansion(1);var i=r.tokens,a=this.consumeArgs(r.numArgs,r.delimiters);if(r.numArgs){i=i.slice();for(var o=i.length-1;o>=0;--o){var s=i[o];if(s.text===`#`){if(o===0)throw new B(`Incomplete placeholder at end of macro body`,s);if(s=i[--o],s.text===`#`)i.splice(o+1,1);else if(/^[1-9]$/.test(s.text))i.splice(o,2,...a[s.text-1]);else throw new B(`Not a valid argument number`,s)}}}return this.pushTokens(i),i.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){var e=this.stack.pop();return e.treatAsRelax&&(e.text=`\\relax`),e}}expandMacro(e){return this.macros.has(e)?this.expandTokens([new ah(e)]):void 0}expandTokens(e){var t=[],n=this.stack.length;for(this.pushTokens(e);this.stack.length>n;)if(this.expandOnce(!0)===!1){var r=this.stack.pop();r.treatAsRelax&&=(r.noexpand=!1,!1),t.push(r)}return this.countExpansion(t.length),t}expandMacroAsText(e){var t=this.expandMacro(e);return t&&t.map(e=>e.text).join(``)}_getExpansion(e){var t=this.macros.get(e);if(t==null)return t;if(e.length===1){var n=this.lexer.catcodes[e];if(n!=null&&n!==13)return}var r=typeof t==`function`?t(this):t;if(typeof r==`string`){var i=0;if(r.includes(`#`))for(var a=r.replace(/##/g,``);a.includes(`#`+(i+1));)++i;for(var o=new ig(r,this.settings),s=[],c=o.lex();c.text!==`EOF`;)s.push(c),c=o.lex();return s.reverse(),{tokens:s,numArgs:i}}return r}isDefined(e){return this.macros.has(e)||Object.prototype.hasOwnProperty.call(Yh,e)||Object.prototype.hasOwnProperty.call(Vd.math,e)||Object.prototype.hasOwnProperty.call(Vd.text,e)||Object.prototype.hasOwnProperty.call(mg,e)}isExpandable(e){var t=this.macros.get(e);return t==null?Object.prototype.hasOwnProperty.call(Yh,e)&&!Yh[e].primitive:typeof t==`string`||typeof t==`function`||!t.unexpandable}},gg=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,_g=Object.freeze({"₊":`+`,"₋":`-`,"₌":`=`,"₍":`(`,"₎":`)`,"₀":`0`,"₁":`1`,"₂":`2`,"₃":`3`,"₄":`4`,"₅":`5`,"₆":`6`,"₇":`7`,"₈":`8`,"₉":`9`,ₐ:`a`,ₑ:`e`,ₕ:`h`,ᵢ:`i`,ⱼ:`j`,ₖ:`k`,ₗ:`l`,ₘ:`m`,ₙ:`n`,ₒ:`o`,ₚ:`p`,ᵣ:`r`,ₛ:`s`,ₜ:`t`,ᵤ:`u`,ᵥ:`v`,ₓ:`x`,ᵦ:`β`,ᵧ:`γ`,ᵨ:`ρ`,ᵩ:`ϕ`,ᵪ:`χ`,"⁺":`+`,"⁻":`-`,"⁼":`=`,"⁽":`(`,"⁾":`)`,"⁰":`0`,"¹":`1`,"²":`2`,"³":`3`,"⁴":`4`,"⁵":`5`,"⁶":`6`,"⁷":`7`,"⁸":`8`,"⁹":`9`,ᴬ:`A`,ᴮ:`B`,ᴰ:`D`,ᴱ:`E`,ᴳ:`G`,ᴴ:`H`,ᴵ:`I`,ᴶ:`J`,ᴷ:`K`,ᴸ:`L`,ᴹ:`M`,ᴺ:`N`,ᴼ:`O`,ᴾ:`P`,ᴿ:`R`,ᵀ:`T`,ᵁ:`U`,ⱽ:`V`,ᵂ:`W`,ᵃ:`a`,ᵇ:`b`,ᶜ:`c`,ᵈ:`d`,ᵉ:`e`,ᶠ:`f`,ᵍ:`g`,ʰ:`h`,ⁱ:`i`,ʲ:`j`,ᵏ:`k`,ˡ:`l`,ᵐ:`m`,ⁿ:`n`,ᵒ:`o`,ᵖ:`p`,ʳ:`r`,ˢ:`s`,ᵗ:`t`,ᵘ:`u`,ᵛ:`v`,ʷ:`w`,ˣ:`x`,ʸ:`y`,ᶻ:`z`,ᵝ:`β`,ᵞ:`γ`,ᵟ:`δ`,ᵠ:`ϕ`,ᵡ:`χ`,ᶿ:`θ`}),vg={"́":{text:`\\'`,math:`\\acute`},"̀":{text:"\\`",math:`\\grave`},"̈":{text:`\\"`,math:`\\ddot`},"̃":{text:`\\~`,math:`\\tilde`},"̄":{text:`\\=`,math:`\\bar`},"̆":{text:`\\u`,math:`\\breve`},"̌":{text:`\\v`,math:`\\check`},"̂":{text:`\\^`,math:`\\hat`},"̇":{text:`\\.`,math:`\\dot`},"̊":{text:`\\r`,math:`\\mathring`},"̋":{text:`\\H`},"̧":{text:`\\c`}},yg={á:`á`,à:`à`,ä:`ä`,ǟ:`ǟ`,ã:`ã`,ā:`ā`,ă:`ă`,ắ:`ắ`,ằ:`ằ`,ẵ:`ẵ`,ǎ:`ǎ`,â:`â`,ấ:`ấ`,ầ:`ầ`,ẫ:`ẫ`,ȧ:`ȧ`,ǡ:`ǡ`,å:`å`,ǻ:`ǻ`,ḃ:`ḃ`,ć:`ć`,ḉ:`ḉ`,č:`č`,ĉ:`ĉ`,ċ:`ċ`,ç:`ç`,ď:`ď`,ḋ:`ḋ`,ḑ:`ḑ`,é:`é`,è:`è`,ë:`ë`,ẽ:`ẽ`,ē:`ē`,ḗ:`ḗ`,ḕ:`ḕ`,ĕ:`ĕ`,ḝ:`ḝ`,ě:`ě`,ê:`ê`,ế:`ế`,ề:`ề`,ễ:`ễ`,ė:`ė`,ȩ:`ȩ`,ḟ:`ḟ`,ǵ:`ǵ`,ḡ:`ḡ`,ğ:`ğ`,ǧ:`ǧ`,ĝ:`ĝ`,ġ:`ġ`,ģ:`ģ`,ḧ:`ḧ`,ȟ:`ȟ`,ĥ:`ĥ`,ḣ:`ḣ`,ḩ:`ḩ`,í:`í`,ì:`ì`,ï:`ï`,ḯ:`ḯ`,ĩ:`ĩ`,ī:`ī`,ĭ:`ĭ`,ǐ:`ǐ`,î:`î`,ǰ:`ǰ`,ĵ:`ĵ`,ḱ:`ḱ`,ǩ:`ǩ`,ķ:`ķ`,ĺ:`ĺ`,ľ:`ľ`,ļ:`ļ`,ḿ:`ḿ`,ṁ:`ṁ`,ń:`ń`,ǹ:`ǹ`,ñ:`ñ`,ň:`ň`,ṅ:`ṅ`,ņ:`ņ`,ó:`ó`,ò:`ò`,ö:`ö`,ȫ:`ȫ`,õ:`õ`,ṍ:`ṍ`,ṏ:`ṏ`,ȭ:`ȭ`,ō:`ō`,ṓ:`ṓ`,ṑ:`ṑ`,ŏ:`ŏ`,ǒ:`ǒ`,ô:`ô`,ố:`ố`,ồ:`ồ`,ỗ:`ỗ`,ȯ:`ȯ`,ȱ:`ȱ`,ő:`ő`,ṕ:`ṕ`,ṗ:`ṗ`,ŕ:`ŕ`,ř:`ř`,ṙ:`ṙ`,ŗ:`ŗ`,ś:`ś`,ṥ:`ṥ`,š:`š`,ṧ:`ṧ`,ŝ:`ŝ`,ṡ:`ṡ`,ş:`ş`,ẗ:`ẗ`,ť:`ť`,ṫ:`ṫ`,ţ:`ţ`,ú:`ú`,ù:`ù`,ü:`ü`,ǘ:`ǘ`,ǜ:`ǜ`,ǖ:`ǖ`,ǚ:`ǚ`,ũ:`ũ`,ṹ:`ṹ`,ū:`ū`,ṻ:`ṻ`,ŭ:`ŭ`,ǔ:`ǔ`,û:`û`,ů:`ů`,ű:`ű`,ṽ:`ṽ`,ẃ:`ẃ`,ẁ:`ẁ`,ẅ:`ẅ`,ŵ:`ŵ`,ẇ:`ẇ`,ẘ:`ẘ`,ẍ:`ẍ`,ẋ:`ẋ`,ý:`ý`,ỳ:`ỳ`,ÿ:`ÿ`,ỹ:`ỹ`,ȳ:`ȳ`,ŷ:`ŷ`,ẏ:`ẏ`,ẙ:`ẙ`,ź:`ź`,ž:`ž`,ẑ:`ẑ`,ż:`ż`,Á:`Á`,À:`À`,Ä:`Ä`,Ǟ:`Ǟ`,Ã:`Ã`,Ā:`Ā`,Ă:`Ă`,Ắ:`Ắ`,Ằ:`Ằ`,Ẵ:`Ẵ`,Ǎ:`Ǎ`,Â:`Â`,Ấ:`Ấ`,Ầ:`Ầ`,Ẫ:`Ẫ`,Ȧ:`Ȧ`,Ǡ:`Ǡ`,Å:`Å`,Ǻ:`Ǻ`,Ḃ:`Ḃ`,Ć:`Ć`,Ḉ:`Ḉ`,Č:`Č`,Ĉ:`Ĉ`,Ċ:`Ċ`,Ç:`Ç`,Ď:`Ď`,Ḋ:`Ḋ`,Ḑ:`Ḑ`,É:`É`,È:`È`,Ë:`Ë`,Ẽ:`Ẽ`,Ē:`Ē`,Ḗ:`Ḗ`,Ḕ:`Ḕ`,Ĕ:`Ĕ`,Ḝ:`Ḝ`,Ě:`Ě`,Ê:`Ê`,Ế:`Ế`,Ề:`Ề`,Ễ:`Ễ`,Ė:`Ė`,Ȩ:`Ȩ`,Ḟ:`Ḟ`,Ǵ:`Ǵ`,Ḡ:`Ḡ`,Ğ:`Ğ`,Ǧ:`Ǧ`,Ĝ:`Ĝ`,Ġ:`Ġ`,Ģ:`Ģ`,Ḧ:`Ḧ`,Ȟ:`Ȟ`,Ĥ:`Ĥ`,Ḣ:`Ḣ`,Ḩ:`Ḩ`,Í:`Í`,Ì:`Ì`,Ï:`Ï`,Ḯ:`Ḯ`,Ĩ:`Ĩ`,Ī:`Ī`,Ĭ:`Ĭ`,Ǐ:`Ǐ`,Î:`Î`,İ:`İ`,Ĵ:`Ĵ`,Ḱ:`Ḱ`,Ǩ:`Ǩ`,Ķ:`Ķ`,Ĺ:`Ĺ`,Ľ:`Ľ`,Ļ:`Ļ`,Ḿ:`Ḿ`,Ṁ:`Ṁ`,Ń:`Ń`,Ǹ:`Ǹ`,Ñ:`Ñ`,Ň:`Ň`,Ṅ:`Ṅ`,Ņ:`Ņ`,Ó:`Ó`,Ò:`Ò`,Ö:`Ö`,Ȫ:`Ȫ`,Õ:`Õ`,Ṍ:`Ṍ`,Ṏ:`Ṏ`,Ȭ:`Ȭ`,Ō:`Ō`,Ṓ:`Ṓ`,Ṑ:`Ṑ`,Ŏ:`Ŏ`,Ǒ:`Ǒ`,Ô:`Ô`,Ố:`Ố`,Ồ:`Ồ`,Ỗ:`Ỗ`,Ȯ:`Ȯ`,Ȱ:`Ȱ`,Ő:`Ő`,Ṕ:`Ṕ`,Ṗ:`Ṗ`,Ŕ:`Ŕ`,Ř:`Ř`,Ṙ:`Ṙ`,Ŗ:`Ŗ`,Ś:`Ś`,Ṥ:`Ṥ`,Š:`Š`,Ṧ:`Ṧ`,Ŝ:`Ŝ`,Ṡ:`Ṡ`,Ş:`Ş`,Ť:`Ť`,Ṫ:`Ṫ`,Ţ:`Ţ`,Ú:`Ú`,Ù:`Ù`,Ü:`Ü`,Ǘ:`Ǘ`,Ǜ:`Ǜ`,Ǖ:`Ǖ`,Ǚ:`Ǚ`,Ũ:`Ũ`,Ṹ:`Ṹ`,Ū:`Ū`,Ṻ:`Ṻ`,Ŭ:`Ŭ`,Ǔ:`Ǔ`,Û:`Û`,Ů:`Ů`,Ű:`Ű`,Ṽ:`Ṽ`,Ẃ:`Ẃ`,Ẁ:`Ẁ`,Ẅ:`Ẅ`,Ŵ:`Ŵ`,Ẇ:`Ẇ`,Ẍ:`Ẍ`,Ẋ:`Ẋ`,Ý:`Ý`,Ỳ:`Ỳ`,Ÿ:`Ÿ`,Ỹ:`Ỹ`,Ȳ:`Ȳ`,Ŷ:`Ŷ`,Ẏ:`Ẏ`,Ź:`Ź`,Ž:`Ž`,Ẑ:`Ẑ`,Ż:`Ż`,ά:`ά`,ὰ:`ὰ`,ᾱ:`ᾱ`,ᾰ:`ᾰ`,έ:`έ`,ὲ:`ὲ`,ή:`ή`,ὴ:`ὴ`,ί:`ί`,ὶ:`ὶ`,ϊ:`ϊ`,ΐ:`ΐ`,ῒ:`ῒ`,ῑ:`ῑ`,ῐ:`ῐ`,ό:`ό`,ὸ:`ὸ`,ύ:`ύ`,ὺ:`ὺ`,ϋ:`ϋ`,ΰ:`ΰ`,ῢ:`ῢ`,ῡ:`ῡ`,ῠ:`ῠ`,ώ:`ώ`,ὼ:`ὼ`,Ύ:`Ύ`,Ὺ:`Ὺ`,Ϋ:`Ϋ`,Ῡ:`Ῡ`,Ῠ:`Ῠ`,Ώ:`Ώ`,Ὼ:`Ὼ`},bg=class e{constructor(e,t){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode=`math`,this.gullet=new hg(e,t,this.mode),this.settings=t,this.leftrightDepth=0,this.nextToken=null}expect(e,t){if(t===void 0&&(t=!0),this.fetch().text!==e)throw new B(`Expected '`+e+`', got '`+this.fetch().text+`'`,this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken??=this.gullet.expandNextToken(),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set(`\\color`,`\\textcolor`);try{var e=this.parseExpression(!1);return this.expect(`EOF`),this.settings.globalGroup||this.gullet.endGroup(),e}finally{this.gullet.endGroups()}}subparse(e){var t=this.nextToken;this.consume(),this.gullet.pushToken(new ah(`}`)),this.gullet.pushTokens(e);var n=this.parseExpression(!1);return this.expect(`}`),this.nextToken=t,n}parseExpression(t,n){for(var r=[];;){this.mode===`math`&&this.consumeSpaces();var i=this.fetch();if(e.endOfExpression.has(i.text)||n&&i.text===n||t&&Yh[i.text]&&Yh[i.text].infix)break;var a=this.parseAtom(n);if(!a)break;a.type!==`internal`&&r.push(a)}return this.mode===`text`&&this.formLigatures(r),this.handleInfixNodes(r)}handleInfixNodes(e){for(var t=-1,n,r=0;r<e.length;r++){var i=e[r];if(i.type===`infix`){if(t!==-1)throw new B(`only one infix operator per group`,i.token);t=r,n=i.replaceWith}}if(t!==-1&&n){var a,o,s=e.slice(0,t),c=e.slice(t+1);return a=s.length===1&&s[0].type===`ordgroup`?s[0]:{type:`ordgroup`,mode:this.mode,body:s},o=c.length===1&&c[0].type===`ordgroup`?c[0]:{type:`ordgroup`,mode:this.mode,body:c},[n===`\\\\abovefrac`?this.callFunction(n,[a,e[t],o],[]):this.callFunction(n,[a,o],[])]}return e}handleSupSubscript(e){var t=this.fetch(),n=t.text;this.consume(),this.consumeSpaces();var r;do r=this.parseGroup(e);while(r?.type===`internal`);if(!r)throw new B(`Expected group after '`+n+`'`,t);return r}formatUnsupportedCmd(e){for(var t=[],n=0;n<e.length;n++)t.push({type:`textord`,mode:`text`,text:e[n]});var r={type:`text`,mode:this.mode,body:t};return{type:`color`,mode:this.mode,color:this.settings.errorColor,body:[r]}}parseAtom(e){var t=this.parseGroup(`atom`,e);if(t?.type===`internal`||this.mode===`text`)return t;for(var n,r;;){this.consumeSpaces();var i=this.fetch();if(i.text===`\\limits`||i.text===`\\nolimits`){if(t&&t.type===`op`)t.limits=i.text===`\\limits`,t.alwaysHandleSupSub=!0;else if(t&&t.type===`operatorname`)t.alwaysHandleSupSub&&(t.limits=i.text===`\\limits`);else throw new B(`Limit controls must follow a math operator`,i);this.consume()}else if(i.text===`^`){if(n)throw new B(`Double superscript`,i);n=this.handleSupSubscript(`superscript`)}else if(i.text===`_`){if(r)throw new B(`Double subscript`,i);r=this.handleSupSubscript(`subscript`)}else if(i.text===`'`){if(n)throw new B(`Double superscript`,i);var a={type:`textord`,mode:this.mode,text:`\\prime`},o=[a];for(this.consume();this.fetch().text===`'`;)o.push(a),this.consume();this.fetch().text===`^`&&o.push(this.handleSupSubscript(`superscript`)),n={type:`ordgroup`,mode:this.mode,body:o}}else if(_g[i.text]){var s=gg.test(i.text),c=[];for(c.push(new ah(_g[i.text])),this.consume();;){var l=this.fetch().text;if(!_g[l]||gg.test(l)!==s)break;c.unshift(new ah(_g[l])),this.consume()}var u=this.subparse(c);s?r={type:`ordgroup`,mode:`math`,body:u}:n={type:`ordgroup`,mode:`math`,body:u}}else break}return n&&r?{type:`supsub`,mode:this.mode,base:t,sup:n,sub:r}:n?{type:`supsub`,mode:this.mode,base:t,sup:n}:r?{type:`supsub`,mode:this.mode,base:t,sub:r}:t}parseFunction(e,t){var n=this.fetch(),r=n.text,i=Yh[r];if(!i)return null;if(this.consume(),t&&t!==`atom`&&!i.allowedInArgument)throw new B(`Got function '`+r+`' with no arguments`+(t?` as `+t:``),n);if(this.mode===`text`&&!i.allowedInText)throw new B(`Can't use function '`+r+`' in text mode`,n);if(this.mode===`math`&&i.allowedInMath===!1)throw new B(`Can't use function '`+r+`' in math mode`,n);var a=this.parseArguments(r,i),o=a.args,s=a.optArgs;return this.callFunction(r,o,s,n,e)}callFunction(e,t,n,r,i){var a={funcName:e,parser:this,token:r,breakOnTokenText:i},o=Yh[e];if(o&&o.handler)return o.handler(a,t,n);throw new B(`No function handler for `+e)}parseArguments(e,t){var n=t.numOptionalArgs??0,r=t.numArgs+n;if(r===0)return{args:[],optArgs:[]};for(var i=[],a=[],o=0;o<r;o++){var s=t.argTypes?.[o],c=o<n;(`primitive`in t&&t.primitive&&s==null||t.type===`sqrt`&&o===1&&a[0]==null)&&(s=`primitive`);var l=this.parseGroupOfType(`argument to '`+e+`'`,s,c);if(c)a.push(l);else if(l!=null)i.push(l);else throw new B(`Null argument, please report this as a bug`)}return{args:i,optArgs:a}}parseGroupOfType(e,t,n){switch(t){case`color`:return this.parseColorGroup(n);case`size`:return this.parseSizeGroup(n);case`url`:return this.parseUrlGroup(n);case`math`:case`text`:return this.parseArgumentGroup(n,t);case`hbox`:var r=this.parseArgumentGroup(n,`text`);return r==null?null:{type:`styling`,mode:r.mode,body:[r],style:`text`,resetFont:!0};case`raw`:var i=this.parseStringGroup(n);return i==null?null:{type:`raw`,mode:`text`,string:i.text};case`primitive`:if(n)throw new B(`A primitive argument cannot be optional`);var a=this.parseGroup(e);if(a==null)throw new B(`Expected group as `+e,this.fetch());return a;case`original`:case void 0:return this.parseArgumentGroup(n);default:throw new B(`Unknown group type as `+e,this.fetch())}}consumeSpaces(){for(;this.fetch().text===` `;)this.consume()}parseStringGroup(e){var t=this.gullet.scanArgument(e);if(t==null)return null;for(var n=``,r;(r=this.fetch()).text!==`EOF`;)n+=r.text,this.consume();return this.consume(),t.text=n,t}parseRegexGroup(e,t){for(var n=this.fetch(),r=n,i=``,a;(a=this.fetch()).text!==`EOF`&&e.test(i+a.text);)r=a,i+=r.text,this.consume();if(i===``)throw new B(`Invalid `+t+`: '`+n.text+`'`,n);return n.range(r,i)}parseColorGroup(e){var t=this.parseStringGroup(e);if(t==null)return null;var n=/^(#[a-f0-9]{3,4}|#[a-f0-9]{6}|#[a-f0-9]{8}|[a-f0-9]{6}|[a-z]+)$/i.exec(t.text);if(!n)throw new B(`Invalid color: '`+t.text+`'`,t);var r=n[0];return/^[0-9a-f]{6}$/i.test(r)&&(r=`#`+r),{type:`color-token`,mode:this.mode,color:r}}parseSizeGroup(e){var t,n=!1;if(this.gullet.consumeSpaces(),t=!e&&this.gullet.future().text!==`{`?this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/,`size`):this.parseStringGroup(e),!t)return null;!e&&t.text.length===0&&(t.text=`0pt`,n=!0);var r=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(t.text);if(!r)throw new B(`Invalid size: '`+t.text+`'`,t);var i={number:+(r[1]+r[2]),unit:r[3]};if(!hd(i))throw new B(`Invalid unit: '`+i.unit+`'`,t);return{type:`size`,mode:this.mode,value:i,isBlank:n}}parseUrlGroup(e){this.gullet.lexer.setCatcode(`%`,13),this.gullet.lexer.setCatcode(`~`,12);var t=this.parseStringGroup(e);if(this.gullet.lexer.setCatcode(`%`,14),this.gullet.lexer.setCatcode(`~`,13),t==null)return null;var n=t.text.replace(/\\([#$%&~_^{}])/g,`$1`);return{type:`url`,mode:this.mode,url:n}}parseArgumentGroup(e,t){var n=this.gullet.scanArgument(e);if(n==null)return null;var r=this.mode;t&&this.switchMode(t),this.gullet.beginGroup();var i=this.parseExpression(!1,`EOF`);this.expect(`EOF`),this.gullet.endGroup();var a={type:`ordgroup`,mode:this.mode,loc:n.loc,body:i};return t&&this.switchMode(r),a}parseGroup(e,t){var n=this.fetch(),r=n.text,i;if(r===`{`||r===`\\begingroup`){this.consume();var a=r===`{`?`}`:`\\endgroup`;this.gullet.beginGroup();var o=this.parseExpression(!1,a),s=this.fetch();this.expect(a),this.gullet.endGroup(),i={type:`ordgroup`,mode:this.mode,loc:ih.range(n,s),body:o,semisimple:r===`\\begingroup`||void 0}}else if(i=this.parseFunction(t,e)||this.parseSymbol(),i==null&&r[0]===`\\`&&!Object.prototype.hasOwnProperty.call(mg,r)){if(this.settings.throwOnError)throw new B(`Undefined control sequence: `+r,n);i=this.formatUnsupportedCmd(r),this.consume()}return i}formLigatures(e){for(var t=e.length-1,n=0;n<t;++n){var r=e[n];if(r.type===`textord`){var i=r.text,a=e[n+1];if(!(!a||a.type!==`textord`)){if(i===`-`&&a.text===`-`){var o=e[n+2];n+1<t&&o&&o.type===`textord`&&o.text===`-`?(e.splice(n,3,{type:`textord`,mode:`text`,loc:ih.range(r,o),text:`---`}),t-=2):(e.splice(n,2,{type:`textord`,mode:`text`,loc:ih.range(r,a),text:`--`}),--t)}(i===`'`||i==="`")&&a.text===i&&(e.splice(n,2,{type:`textord`,mode:`text`,loc:ih.range(r,a),text:i+i}),--t)}}}}parseSymbol(){var e=this.fetch(),t=e.text;if(/^\\verb[^a-zA-Z]/.test(t)){this.consume();var n=t.slice(5),r=n.charAt(0)===`*`;if(r&&(n=n.slice(1)),n.length<2||n.charAt(0)!==n.slice(-1))throw new B(`\\verb assertion failed --
280
- please report what input caused this bug`);return n=n.slice(1,-1),{type:`verb`,mode:`text`,body:n,star:r}}Object.prototype.hasOwnProperty.call(yg,t[0])&&!Vd[this.mode][t[0]]&&(this.settings.strict&&this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Accented Unicode text character "`+t[0]+`" used in math mode`,e),t=yg[t[0]]+t.slice(1));var i=ng.exec(t);i&&(t=t.substring(0,i.index),t===`i`?t=`ı`:t===`j`&&(t=`ȷ`));var a;if(Vd[this.mode][t]){this.settings.strict&&this.mode===`math`&&ff.includes(t)&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Latin-1/Unicode text character "`+t[0]+`" used in math mode`,e);var o=Vd[this.mode][t].group,s=ih.range(e);a=Qp(o)?{type:`atom`,mode:this.mode,family:o,loc:s,text:t}:{type:o,mode:this.mode,loc:s,text:t}}else if(t.charCodeAt(0)>=128)this.settings.strict&&(Zu(t.charCodeAt(0))?this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Unicode text character "`+t[0]+`" used in math mode`,e):this.settings.reportNonstrict(`unknownSymbol`,`Unrecognized Unicode character "`+t[0]+`"`+(` (`+t.charCodeAt(0)+`)`),e)),a={type:`textord`,mode:`text`,loc:ih.range(e),text:t};else return null;if(this.consume(),i)for(var c=0;c<i[0].length;c++){var l=i[0][c];if(!vg[l])throw new B(`Unknown accent ' `+l+`'`,e);var u=vg[l][this.mode]||vg[l].text;if(!u)throw new B(`Accent `+l+` unsupported in `+this.mode+` mode`,e);a={type:`accent`,mode:this.mode,loc:ih.range(e),label:u,isStretchy:!1,isShifty:!0,base:a}}return a}};bg.endOfExpression=new Set([`}`,`\\endgroup`,`\\end`,`\\right`,`&`]);var xg=function(e,t){if(!(typeof e==`string`||e instanceof String))throw TypeError(`KaTeX can only parse string typed expression`);var n=new bg(e,t);delete n.gullet.macros.current[`\\df@tag`];var r=n.parse();if(delete n.gullet.macros.current[`\\current@color`],delete n.gullet.macros.current[`\\color`],n.gullet.macros.get(`\\df@tag`)){if(!t.displayMode)throw new B(`\\tag works only in display equations`);r=[{type:`tag`,mode:`text`,body:r,tag:n.subparse([new ah(`\\df@tag`)])}]}return r},Sg=function(e,t,n){t.textContent=``;var r=Eg(e,n).toNode();t.appendChild(r)};typeof document<`u`&&document.compatMode!==`CSS1Compat`&&(typeof console<`u`&&console.warn(`Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype.`),Sg=function(){throw new B(`KaTeX doesn't work in quirks mode.`)});var Cg=function(e,t){return Eg(e,t).toMarkup()},wg=function(e,t){return xg(e,new Au(t))},Tg=function(e,t,n){if(n.throwOnError||!(e instanceof B))throw e;var r=X([`katex-error`],[new Dd(t)]);return r.setAttribute(`title`,e.toString()),r.setAttribute(`style`,`color:`+n.errorColor),r},Eg=function(e,t){var n=new Au(t);try{return Bp(xg(e,n),e,n)}catch(t){return Tg(t,e,n)}},Dg={version:`0.18.6`,render:Sg,renderToString:Cg,ParseError:B,SETTINGS_SCHEMA:Eu,__parse:wg,__renderToDomTree:Eg,__renderToHTMLTree:function(e,t){var n=new Au(t);try{return Vp(xg(e,n),e,n)}catch(t){return Tg(t,e,n)}},__setFontMetrics:Ld,__defineSymbol:H,__defineFunction:Z,__defineMacro:$,__domTree:{Span:Cd,Anchor:wd,SymbolNode:Dd,SvgNode:Od,PathNode:kd,LineNode:Ad}},Og=class extends Error{element;constructor(e){super(`no OMML mapping for MathML element <${e}>`),this.name=`UnsupportedMathError`,this.element=e}},kg=new Set([`∑`]),Ag=new Set([`∫`,`∬`,`∭`,`∮`]),jg=new Set([`(`,`(`]),Mg=new Set([`)`,`)`]);function Ng(e,t){let n=Dg.renderToString(e,{output:`mathml`,displayMode:t,throwOnError:!1}),r=new DOMParser().parseFromString(n,`text/html`).querySelector(`math`);if(r===null)throw new Og(`math`);return r}function Pg(e){return[...e.children]}function Fg(e){return(e.textContent??``).replace(/[\u2061-\u2064]/g,``).trim()}function Ig(e){return e.flatMap(Lg)}function Lg(e){let t=e.tagName.toLowerCase().replace(/^m:/,``);switch(t){case`math`:case`semantics`:case`mrow`:case`mstyle`:case`mpadded`:return Vg(Pg(e));case`annotation`:case`annotation-xml`:case`mphantom`:return[];case`mspace`:return[new za(` `)];case`mi`:case`mn`:case`mo`:case`mtext`:{let t=Fg(e);return t===``?[]:[new za(t)]}case`mfrac`:{let[t,n]=Pg(e);if(t===void 0||n===void 0)throw new Og(`mfrac`);return[new Ha({numerator:Lg(t),denominator:Lg(n)})]}case`msqrt`:return[new lo({children:Ig(Pg(e))})];case`mroot`:{let[t,n]=Pg(e);if(t===void 0||n===void 0)throw new Og(`mroot`);return[new lo({children:Lg(t),degree:Lg(n)})]}case`msub`:case`munder`:{let[n,r]=Pg(e);if(n===void 0||r===void 0)throw new Og(t);return[new no({children:Lg(n),subScript:Lg(r)})]}case`msup`:case`mover`:{let[n,r]=Pg(e);if(n===void 0||r===void 0)throw new Og(t);return[new eo({children:Lg(n),superScript:Lg(r)})]}case`msubsup`:case`munderover`:{let[n,r,i]=Pg(e);if(n===void 0||r===void 0||i===void 0)throw new Og(t);return[new io({children:Lg(n),subScript:Lg(r),superScript:Lg(i)})]}default:throw new Og(t)}}var Rg=new Set([`msub`,`msup`,`msubsup`,`munder`,`mover`,`munderover`]);function zg(e,t){if(!Rg.has(e.tagName.toLowerCase()))return;let[n,r,i]=Pg(e);if(n===void 0)return;let a=Fg(n),o=kg.has(a),s=Ag.has(a);if(!o&&!s)return;let c=e.tagName.toLowerCase(),l=c===`msub`||c===`munder`||c===`msubsup`||c===`munderover`?r:void 0,u=c===`msup`||c===`mover`?r:c===`msubsup`||c===`munderover`?i:void 0,d={children:Ig(t),...l===void 0?{}:{subScript:Lg(l)},...u===void 0?{}:{superScript:Lg(u)}};return[o?new Za(d):new Qa(d)]}function Bg(e){let t=e[0],n=e[e.length-1];return e.length>=2&&t!==void 0&&n!==void 0&&t.tagName.toLowerCase()===`mo`&&n.tagName.toLowerCase()===`mo`&&jg.has(Fg(t))&&Mg.has(Fg(n))?[new mo({children:Vg(e.slice(1,-1))})]:Vg(e)}function Vg(e){let t=[];for(let n=0;n<e.length;n++){let r=zg(e[n],e.slice(n+1));if(r!==void 0)return t.push(...r),t;t.push(...Lg(e[n]))}return t}function Hg(e,t){let n=Ng(e,t);if(n.querySelector(`.katex-error`)!==null)throw new Og(`katex-error`);let r=n.querySelector(`semantics`),i=Pg(r===null?n:r),a=Bg((i.length===1&&i[0].tagName.toLowerCase()===`mrow`?Pg(i[0]):i).filter(e=>e.tagName.toLowerCase()!==`annotation`));if(a.length===0)throw new Og(`empty`);return a}var Ug=`�`,Wg=/[- -￾￿]/g,Gg=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;function Kg(e){return e.replace(Wg,Ug).replace(Gg,Ug)}var qg=class extends Error{constructor(e){super(e),this.name=`DiagramError`}};function Jg(e){let t=/viewBox="\s*[\d.-]+[\s,]+[\d.-]+[\s,]+([\d.]+)[\s,]+([\d.]+)/.exec(e),n=t?Number(t[1]):NaN,r=t?Number(t[2]):NaN;if(!Number.isFinite(n)||!Number.isFinite(r)||n<=0||r<=0)throw new qg(`diagram has no usable viewBox`);return{width:n,height:r}}function Yg(e,t,n){let r=/^[\s\S]*?<svg\b[^>]*>/.exec(e);return r===null?e:r[0].replace(/\swidth="[^"]*"/,``).replace(/\sheight="[^"]*"/,``).replace(/\sstyle="[^"]*"/,e=>{let t=e.replace(/max-width:[^;"]*;?/,``);return/style="\s*"/.test(t)?``:t}).replace(/>$/,` width="${t}" height="${n}">`)+e.slice(r[0].length)}var Xg=[`fill`,`fill-opacity`,`stroke`,`stroke-width`,`stroke-opacity`,`stroke-dasharray`,`stroke-linecap`,`stroke-linejoin`,`opacity`,`font-family`,`font-size`,`font-weight`,`font-style`,`text-anchor`,`dominant-baseline`];function Zg(e){let t=document.createElement(`div`);t.setAttribute(`style`,`position:absolute;left:-10000px;top:0;width:0;height:0;overflow:hidden`),t.innerHTML=e;let n=t.querySelector(`svg`);if(n===null)return e;document.body.append(t);try{let e=[n,...n.querySelectorAll(`*`)].filter(e=>e.tagName.toLowerCase()!==`style`).map(e=>{let t=window.getComputedStyle(e),n=[];for(let e of Xg){let r=t.getPropertyValue(e);r!==``&&n.push([e,r])}return{element:e,painted:n}});for(let{element:t,painted:n}of e){for(let[e,r]of n)t.setAttribute(e,r);t.removeAttribute(`style`),t.removeAttribute(`class`)}for(let e of[...n.querySelectorAll(`style`)])e.remove();return n.outerHTML}finally{t.remove()}}var Qg=Promise.resolve();async function $g(e){let t=Qg.then(e,e);return Qg=t.then(()=>void 0,()=>void 0),t}async function e_(e,t){return $g(async()=>{let n=(await Promise.resolve().then(()=>require("./mermaid.core-B3QcBB1O.cjs")).then(e=>e.t)).default,r;try{n.initialize({startOnLoad:!1,theme:`default`,securityLevel:`strict`,suppressErrorRendering:!0,flowchart:{htmlLabels:!1},htmlLabels:!1}),{svg:r}=await n.render(t,e)}catch(e){throw new qg(`mermaid could not render the diagram: ${String(e)}`)}finally{n.initialize({startOnLoad:!1,securityLevel:`strict`,suppressErrorRendering:!0})}let{width:i,height:a}=Jg(r),o=Yg(r,i,a),s=await n_(o,i,a);return{svg:Zg(o),png:s,width:i,height:a}})}var t_=2;async function n_(e,t,n){let r=document.createElement(`canvas`);r.width=Math.max(1,Math.round(t*t_)),r.height=Math.max(1,Math.round(n*t_));let i=r.getContext(`2d`);if(i===null)throw new qg(`no 2d canvas context for the fallback image`);let a=URL.createObjectURL(new Blob([e],{type:`image/svg+xml;charset=utf-8`}));try{let e=await r_(a);return i.fillStyle=`#ffffff`,i.fillRect(0,0,r.width,r.height),i.drawImage(e,0,0,r.width,r.height),await i_(r)}finally{URL.revokeObjectURL(a)}}function r_(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=()=>n(new qg(`the browser would not draw the diagram`)),r.src=e})}async function i_(e){let t=await new Promise(t=>e.toBlob(t,`image/png`));if(t===null)throw new qg(`the canvas produced no image`);return new Uint8Array(await t.arrayBuffer())}function a_(e){return e!==``&&!t.n(e)}function o_(e,n,r,i){if(a_(n))return t.a(r,t.o(e,n),i)}async function s_(e,t,n,r){let i=o_(e,t,n,r);if(i!==void 0)try{let e=await fetch(i);return e.ok?await c_(new Uint8Array(await e.arrayBuffer())):void 0}catch{return}}async function c_(e){if(l_(e))return u_(new TextDecoder().decode(e));let t=p_(e);return t===void 0?void 0:{kind:`raster`,...t,bytes:e}}function l_(e){return new TextDecoder().decode(e.subarray(0,512)).toLowerCase().includes(`<svg`)}async function u_(e){try{let{width:t,height:n}=d_(e),r=Yg(e,t,n),i=await n_(r,t,n);return{kind:`vector`,image:{svg:Zg(r),png:i,width:t,height:n}}}catch{return}}function d_(e){try{return Jg(e)}catch{let t=/<svg\b[^>]*>/.exec(e),n=f_(t?.[0]??``,`width`),r=f_(t?.[0]??``,`height`);if(n===void 0||r===void 0)throw new qg(`the referenced svg states no size`);return{width:n,height:r}}}function f_(e,t){let n=RegExp(`\\s${t}="([^"]*)"`).exec(e)?.[1];if(n===void 0)return;let r=Number.parseFloat(n.replace(/px$/i,``));return Number.isFinite(r)&&r>0&&!n.includes(`%`)?r:void 0}function p_(e){return v_(e)??y_(e)??b_(e)??S_(e)}function m_(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function h_(e,t){return e[t]|e[t+1]<<8}function g_(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24|0}var __=[137,80,78,71,13,10,26,10];function v_(e){if(!(e.length<24)&&__.every((t,n)=>e[n]===t))return C_(`png`,m_(e,16),m_(e,20))}function y_(e){if(e.length<10)return;let t=String.fromCharCode(...e.subarray(0,6));if(t===`GIF87a`||t===`GIF89a`)return C_(`gif`,h_(e,6),h_(e,8))}function b_(e){if(!(e.length<26||e[0]!==66||e[1]!==77))return C_(`bmp`,Math.abs(g_(e,18)),Math.abs(g_(e,22)))}var x_=new Set([192,193,194,195,197,198,199,201,202,203,205,206,207]);function S_(e){if(e.length<4||e[0]!==255||e[1]!==216)return;let t=2;for(;t+9<e.length;){if(e[t]!==255){t+=1;continue}let n=e[t+1];if(n===255){t+=1;continue}if(n===216||n===1||n>=208&&n<=215){t+=2;continue}if(x_.has(n))return C_(`jpg`,e[t+7]<<8|e[t+8],e[t+5]<<8|e[t+6]);let r=e[t+2]<<8|e[t+3];if(r<2)return;t+=2+r}}function C_(e,t,n){return t>0&&n>0?{type:e,width:t,height:n}:void 0}var w_=`Consolas, Courier New, monospace`,T_=360,E_=`md-ordered`;function D_(t){return e.r().use(e.l).use(e.n).use(e.t).parse(e.h(t))}function O_(e,t){return new er({text:Kg(e),bold:t.bold,italics:t.italics,strike:t.strike,...t.code===!0?{font:w_}:{}})}function k_(e,t,n={}){let r=[];for(let i of e)switch(i.type){case`text`:r.push(O_(i.value,n));break;case`strong`:r.push(...k_(i.children,t,{...n,bold:!0}));break;case`emphasis`:r.push(...k_(i.children,t,{...n,italics:!0}));break;case`delete`:r.push(...k_(i.children,t,{...n,strike:!0}));break;case`inlineCode`:r.push(O_(i.value,{...n,code:!0}));break;case`link`:r.push(new ba({children:k_(i.children,t,n),link:i.url}));break;case`break`:r.push(new er({text:``,break:1}));break;case`image`:{let e=t.get(i);e===void 0?r.push(O_(i.alt??i.url,n)):r.push(H_(e));break}case`inlineMath`:r.push(...A_(i.value,!1,n));break;default:r.push(...k_(j_(i),t,n))}return r}function A_(e,t,n){try{return[new La({children:Hg(e,t)})]}catch{return[O_(e,{...n,code:!0})]}}function j_(e){let t=e.children;return Array.isArray(t)?t:[]}var M_=[la.HEADING_1,la.HEADING_2,la.HEADING_3,la.HEADING_4,la.HEADING_5,la.HEADING_6];function N_(e,t){return new Ia({heading:M_[Math.min(e.depth,6)-1],children:k_(e.children,t)})}function P_(e){return e.value.split(`
280
+ please report what input caused this bug`);return n=n.slice(1,-1),{type:`verb`,mode:`text`,body:n,star:r}}Object.prototype.hasOwnProperty.call(yg,t[0])&&!Vd[this.mode][t[0]]&&(this.settings.strict&&this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Accented Unicode text character "`+t[0]+`" used in math mode`,e),t=yg[t[0]]+t.slice(1));var i=ng.exec(t);i&&(t=t.substring(0,i.index),t===`i`?t=`ı`:t===`j`&&(t=`ȷ`));var a;if(Vd[this.mode][t]){this.settings.strict&&this.mode===`math`&&ff.includes(t)&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Latin-1/Unicode text character "`+t[0]+`" used in math mode`,e);var o=Vd[this.mode][t].group,s=ih.range(e);a=Qp(o)?{type:`atom`,mode:this.mode,family:o,loc:s,text:t}:{type:o,mode:this.mode,loc:s,text:t}}else if(t.charCodeAt(0)>=128)this.settings.strict&&(Zu(t.charCodeAt(0))?this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Unicode text character "`+t[0]+`" used in math mode`,e):this.settings.reportNonstrict(`unknownSymbol`,`Unrecognized Unicode character "`+t[0]+`"`+(` (`+t.charCodeAt(0)+`)`),e)),a={type:`textord`,mode:`text`,loc:ih.range(e),text:t};else return null;if(this.consume(),i)for(var c=0;c<i[0].length;c++){var l=i[0][c];if(!vg[l])throw new B(`Unknown accent ' `+l+`'`,e);var u=vg[l][this.mode]||vg[l].text;if(!u)throw new B(`Accent `+l+` unsupported in `+this.mode+` mode`,e);a={type:`accent`,mode:this.mode,loc:ih.range(e),label:u,isStretchy:!1,isShifty:!0,base:a}}return a}};bg.endOfExpression=new Set([`}`,`\\endgroup`,`\\end`,`\\right`,`&`]);var xg=function(e,t){if(!(typeof e==`string`||e instanceof String))throw TypeError(`KaTeX can only parse string typed expression`);var n=new bg(e,t);delete n.gullet.macros.current[`\\df@tag`];var r=n.parse();if(delete n.gullet.macros.current[`\\current@color`],delete n.gullet.macros.current[`\\color`],n.gullet.macros.get(`\\df@tag`)){if(!t.displayMode)throw new B(`\\tag works only in display equations`);r=[{type:`tag`,mode:`text`,body:r,tag:n.subparse([new ah(`\\df@tag`)])}]}return r},Sg=function(e,t,n){t.textContent=``;var r=Eg(e,n).toNode();t.appendChild(r)};typeof document<`u`&&document.compatMode!==`CSS1Compat`&&(typeof console<`u`&&console.warn(`Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype.`),Sg=function(){throw new B(`KaTeX doesn't work in quirks mode.`)});var Cg=function(e,t){return Eg(e,t).toMarkup()},wg=function(e,t){return xg(e,new Au(t))},Tg=function(e,t,n){if(n.throwOnError||!(e instanceof B))throw e;var r=X([`katex-error`],[new Dd(t)]);return r.setAttribute(`title`,e.toString()),r.setAttribute(`style`,`color:`+n.errorColor),r},Eg=function(e,t){var n=new Au(t);try{return Bp(xg(e,n),e,n)}catch(t){return Tg(t,e,n)}},Dg={version:`0.18.6`,render:Sg,renderToString:Cg,ParseError:B,SETTINGS_SCHEMA:Eu,__parse:wg,__renderToDomTree:Eg,__renderToHTMLTree:function(e,t){var n=new Au(t);try{return Vp(xg(e,n),e,n)}catch(t){return Tg(t,e,n)}},__setFontMetrics:Ld,__defineSymbol:H,__defineFunction:Z,__defineMacro:$,__domTree:{Span:Cd,Anchor:wd,SymbolNode:Dd,SvgNode:Od,PathNode:kd,LineNode:Ad}},Og=class extends Error{element;constructor(e){super(`no OMML mapping for MathML element <${e}>`),this.name=`UnsupportedMathError`,this.element=e}},kg=new Set([`∑`]),Ag=new Set([`∫`,`∬`,`∭`,`∮`]),jg=new Set([`(`,`(`]),Mg=new Set([`)`,`)`]);function Ng(e,t){let n=Dg.renderToString(e,{output:`mathml`,displayMode:t,throwOnError:!1}),r=new DOMParser().parseFromString(n,`text/html`).querySelector(`math`);if(r===null)throw new Og(`math`);return r}function Pg(e){return[...e.children]}function Fg(e){return(e.textContent??``).replace(/[\u2061-\u2064]/g,``).trim()}function Ig(e){return e.flatMap(Lg)}function Lg(e){let t=e.tagName.toLowerCase().replace(/^m:/,``);switch(t){case`math`:case`semantics`:case`mrow`:case`mstyle`:case`mpadded`:return Vg(Pg(e));case`annotation`:case`annotation-xml`:case`mphantom`:return[];case`mspace`:return[new za(` `)];case`mi`:case`mn`:case`mo`:case`mtext`:{let t=Fg(e);return t===``?[]:[new za(t)]}case`mfrac`:{let[t,n]=Pg(e);if(t===void 0||n===void 0)throw new Og(`mfrac`);return[new Ha({numerator:Lg(t),denominator:Lg(n)})]}case`msqrt`:return[new lo({children:Ig(Pg(e))})];case`mroot`:{let[t,n]=Pg(e);if(t===void 0||n===void 0)throw new Og(`mroot`);return[new lo({children:Lg(t),degree:Lg(n)})]}case`msub`:case`munder`:{let[n,r]=Pg(e);if(n===void 0||r===void 0)throw new Og(t);return[new no({children:Lg(n),subScript:Lg(r)})]}case`msup`:case`mover`:{let[n,r]=Pg(e);if(n===void 0||r===void 0)throw new Og(t);return[new eo({children:Lg(n),superScript:Lg(r)})]}case`msubsup`:case`munderover`:{let[n,r,i]=Pg(e);if(n===void 0||r===void 0||i===void 0)throw new Og(t);return[new io({children:Lg(n),subScript:Lg(r),superScript:Lg(i)})]}default:throw new Og(t)}}var Rg=new Set([`msub`,`msup`,`msubsup`,`munder`,`mover`,`munderover`]);function zg(e,t){if(!Rg.has(e.tagName.toLowerCase()))return;let[n,r,i]=Pg(e);if(n===void 0)return;let a=Fg(n),o=kg.has(a),s=Ag.has(a);if(!o&&!s)return;let c=e.tagName.toLowerCase(),l=c===`msub`||c===`munder`||c===`msubsup`||c===`munderover`?r:void 0,u=c===`msup`||c===`mover`?r:c===`msubsup`||c===`munderover`?i:void 0,d={children:Ig(t),...l===void 0?{}:{subScript:Lg(l)},...u===void 0?{}:{superScript:Lg(u)}};return[o?new Za(d):new Qa(d)]}function Bg(e){let t=e[0],n=e[e.length-1];return e.length>=2&&t!==void 0&&n!==void 0&&t.tagName.toLowerCase()===`mo`&&n.tagName.toLowerCase()===`mo`&&jg.has(Fg(t))&&Mg.has(Fg(n))?[new mo({children:Vg(e.slice(1,-1))})]:Vg(e)}function Vg(e){let t=[];for(let n=0;n<e.length;n++){let r=zg(e[n],e.slice(n+1));if(r!==void 0)return t.push(...r),t;t.push(...Lg(e[n]))}return t}function Hg(e,t){let n=Ng(e,t);if(n.querySelector(`.katex-error`)!==null)throw new Og(`katex-error`);let r=n.querySelector(`semantics`),i=Pg(r===null?n:r),a=Bg((i.length===1&&i[0].tagName.toLowerCase()===`mrow`?Pg(i[0]):i).filter(e=>e.tagName.toLowerCase()!==`annotation`));if(a.length===0)throw new Og(`empty`);return a}var Ug=`�`,Wg=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]/g,Gg=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;function Kg(e){return e.replace(Wg,Ug).replace(Gg,Ug)}var qg=class extends Error{constructor(e){super(e),this.name=`DiagramError`}};function Jg(e){let t=/viewBox="\s*[\d.-]+[\s,]+[\d.-]+[\s,]+([\d.]+)[\s,]+([\d.]+)/.exec(e),n=t?Number(t[1]):NaN,r=t?Number(t[2]):NaN;if(!Number.isFinite(n)||!Number.isFinite(r)||n<=0||r<=0)throw new qg(`diagram has no usable viewBox`);return{width:n,height:r}}function Yg(e,t,n){let r=/^[\s\S]*?<svg\b[^>]*>/.exec(e);return r===null?e:r[0].replace(/\swidth="[^"]*"/,``).replace(/\sheight="[^"]*"/,``).replace(/\sstyle="[^"]*"/,e=>{let t=e.replace(/max-width:[^;"]*;?/,``);return/style="\s*"/.test(t)?``:t}).replace(/>$/,` width="${t}" height="${n}">`)+e.slice(r[0].length)}var Xg=[`fill`,`fill-opacity`,`stroke`,`stroke-width`,`stroke-opacity`,`stroke-dasharray`,`stroke-linecap`,`stroke-linejoin`,`opacity`,`font-family`,`font-size`,`font-weight`,`font-style`,`text-anchor`,`dominant-baseline`];function Zg(e){let t=document.createElement(`div`);t.setAttribute(`style`,`position:absolute;left:-10000px;top:0;width:0;height:0;overflow:hidden`),t.innerHTML=e;let n=t.querySelector(`svg`);if(n===null)return e;document.body.append(t);try{let e=[n,...n.querySelectorAll(`*`)].filter(e=>e.tagName.toLowerCase()!==`style`).map(e=>{let t=window.getComputedStyle(e),n=[];for(let e of Xg){let r=t.getPropertyValue(e);r!==``&&n.push([e,r])}return{element:e,painted:n}});for(let{element:t,painted:n}of e){for(let[e,r]of n)t.setAttribute(e,r);t.removeAttribute(`style`),t.removeAttribute(`class`)}for(let e of[...n.querySelectorAll(`style`)])e.remove();return n.outerHTML}finally{t.remove()}}var Qg=Promise.resolve();async function $g(e){let t=Qg.then(e,e);return Qg=t.then(()=>void 0,()=>void 0),t}async function e_(e,t){return $g(async()=>{let n=(await Promise.resolve().then(()=>require("./mermaid.core-B3QcBB1O.cjs")).then(e=>e.t)).default,r;try{n.initialize({startOnLoad:!1,theme:`default`,securityLevel:`strict`,suppressErrorRendering:!0,flowchart:{htmlLabels:!1},htmlLabels:!1}),{svg:r}=await n.render(t,e)}catch(e){throw new qg(`mermaid could not render the diagram: ${String(e)}`)}finally{n.initialize({startOnLoad:!1,securityLevel:`strict`,suppressErrorRendering:!0})}let{width:i,height:a}=Jg(r),o=Yg(r,i,a),s=await n_(o,i,a);return{svg:Zg(o),png:s,width:i,height:a}})}var t_=2;async function n_(e,t,n){let r=document.createElement(`canvas`);r.width=Math.max(1,Math.round(t*t_)),r.height=Math.max(1,Math.round(n*t_));let i=r.getContext(`2d`);if(i===null)throw new qg(`no 2d canvas context for the fallback image`);let a=URL.createObjectURL(new Blob([e],{type:`image/svg+xml;charset=utf-8`}));try{let e=await r_(a);return i.fillStyle=`#ffffff`,i.fillRect(0,0,r.width,r.height),i.drawImage(e,0,0,r.width,r.height),await i_(r)}finally{URL.revokeObjectURL(a)}}function r_(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=()=>n(new qg(`the browser would not draw the diagram`)),r.src=e})}async function i_(e){let t=await new Promise(t=>e.toBlob(t,`image/png`));if(t===null)throw new qg(`the canvas produced no image`);return new Uint8Array(await t.arrayBuffer())}function a_(e){return e!==``&&!t.n(e)}function o_(e,n,r,i){if(a_(n))return t.a(r,t.o(e,n),i)}async function s_(e,t,n,r){let i=o_(e,t,n,r);if(i!==void 0)try{let e=await fetch(i);return e.ok?await c_(new Uint8Array(await e.arrayBuffer())):void 0}catch{return}}async function c_(e){if(l_(e))return u_(new TextDecoder().decode(e));let t=p_(e);return t===void 0?void 0:{kind:`raster`,...t,bytes:e}}function l_(e){return new TextDecoder().decode(e.subarray(0,512)).toLowerCase().includes(`<svg`)}async function u_(e){try{let{width:t,height:n}=d_(e),r=Yg(e,t,n),i=await n_(r,t,n);return{kind:`vector`,image:{svg:Zg(r),png:i,width:t,height:n}}}catch{return}}function d_(e){try{return Jg(e)}catch{let t=/<svg\b[^>]*>/.exec(e),n=f_(t?.[0]??``,`width`),r=f_(t?.[0]??``,`height`);if(n===void 0||r===void 0)throw new qg(`the referenced svg states no size`);return{width:n,height:r}}}function f_(e,t){let n=RegExp(`\\s${t}="([^"]*)"`).exec(e)?.[1];if(n===void 0)return;let r=Number.parseFloat(n.replace(/px$/i,``));return Number.isFinite(r)&&r>0&&!n.includes(`%`)?r:void 0}function p_(e){return v_(e)??y_(e)??b_(e)??S_(e)}function m_(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function h_(e,t){return e[t]|e[t+1]<<8}function g_(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24|0}var __=[137,80,78,71,13,10,26,10];function v_(e){if(!(e.length<24)&&__.every((t,n)=>e[n]===t))return C_(`png`,m_(e,16),m_(e,20))}function y_(e){if(e.length<10)return;let t=String.fromCharCode(...e.subarray(0,6));if(t===`GIF87a`||t===`GIF89a`)return C_(`gif`,h_(e,6),h_(e,8))}function b_(e){if(!(e.length<26||e[0]!==66||e[1]!==77))return C_(`bmp`,Math.abs(g_(e,18)),Math.abs(g_(e,22)))}var x_=new Set([192,193,194,195,197,198,199,201,202,203,205,206,207]);function S_(e){if(e.length<4||e[0]!==255||e[1]!==216)return;let t=2;for(;t+9<e.length;){if(e[t]!==255){t+=1;continue}let n=e[t+1];if(n===255){t+=1;continue}if(n===216||n===1||n>=208&&n<=215){t+=2;continue}if(x_.has(n))return C_(`jpg`,e[t+7]<<8|e[t+8],e[t+5]<<8|e[t+6]);let r=e[t+2]<<8|e[t+3];if(r<2)return;t+=2+r}}function C_(e,t,n){return t>0&&n>0?{type:e,width:t,height:n}:void 0}var w_=`Consolas, Courier New, monospace`,T_=360,E_=`md-ordered`;function D_(t){return e.r().use(e.l).use(e.n).use(e.t).parse(e.h(t))}function O_(e,t){return new er({text:Kg(e),bold:t.bold,italics:t.italics,strike:t.strike,...t.code===!0?{font:w_}:{}})}function k_(e,t,n={}){let r=[];for(let i of e)switch(i.type){case`text`:r.push(O_(i.value,n));break;case`strong`:r.push(...k_(i.children,t,{...n,bold:!0}));break;case`emphasis`:r.push(...k_(i.children,t,{...n,italics:!0}));break;case`delete`:r.push(...k_(i.children,t,{...n,strike:!0}));break;case`inlineCode`:r.push(O_(i.value,{...n,code:!0}));break;case`link`:r.push(new ba({children:k_(i.children,t,n),link:i.url}));break;case`break`:r.push(new er({text:``,break:1}));break;case`image`:{let e=t.get(i);e===void 0?r.push(O_(i.alt??i.url,n)):r.push(H_(e));break}case`inlineMath`:r.push(...A_(i.value,!1,n));break;default:r.push(...k_(j_(i),t,n))}return r}function A_(e,t,n){try{return[new La({children:Hg(e,t)})]}catch{return[O_(e,{...n,code:!0})]}}function j_(e){let t=e.children;return Array.isArray(t)?t:[]}var M_=[la.HEADING_1,la.HEADING_2,la.HEADING_3,la.HEADING_4,la.HEADING_5,la.HEADING_6];function N_(e,t){return new Ia({heading:M_[Math.min(e.depth,6)-1],children:k_(e.children,t)})}function P_(e){return e.value.split(`
281
281
  `).map(e=>new Ia({children:[new er({text:Kg(e===``?` `:e),font:w_})],spacing:{before:0,after:0}}))}var F_=624;function I_(e,t){return e<=F_?{width:Math.round(e),height:Math.round(t)}:{width:F_,height:Math.round(t*F_/e)}}function L_(e){return(e.lang??``).toLowerCase()===`mermaid`}async function R_(e){let t=[],n=e=>{e.type===`code`&&L_(e)&&t.push(e);for(let t of e.children??[])n(t)};n(e);let r=new Map;for(let[e,n]of t.entries())try{r.set(n,await e_(n.value,`docx-export-${e}`))}catch{}return r}async function z_(e,t,n,r){let i=[],a=e=>{e.type===`image`&&i.push(e);for(let t of e.children??[])a(t)};a(e);let o=new Map,s=new Map;for(let e of i){let i=o_(t,e.url,n,r);if(i===void 0)continue;s.has(i)||s.set(i,await s_(t,e.url,n,r));let a=s.get(i);a!==void 0&&o.set(e,a)}return o}function B_(e){return new Gi({type:`svg`,data:new TextEncoder().encode(e.svg),fallback:{type:`png`,data:e.png},transformation:I_(e.width,e.height)})}function V_(e){return new Ia({alignment:fn.CENTER,children:[B_(e)]})}function H_(e){return e.kind===`vector`?B_(e.image):new Gi({type:e.type,data:e.bytes,transformation:I_(e.width,e.height)})}function U_(e){return e===0?{}:{indent:{left:T_*e},border:{left:{style:hn.SINGLE,size:12,color:`CCCCCC`,space:12}}}}function W_(e,t,n=0){let r=e.ordered===!0,i=r?t.instance++:0,a=[];for(let o of e.children){let e=!0;for(let s of o.children){if(s.type===`list`){a.push(...W_(s,t,n+1));continue}if(s.type===`paragraph`){a.push(new Ia({children:k_(s.children,t.images),...e?r?{numbering:{reference:E_,level:n,instance:i}}:{bullet:{level:n}}:{indent:{left:T_*(n+1)}}})),e=!1;continue}a.push(...q_([s],t))}}return a}function G_(e,t){return new $o({rows:e.children.map((e,n)=>new rs({tableHeader:n===0,children:e.children.map(e=>new Vo({children:[new Ia({children:k_(e.children,t)})]}))})),width:{size:100,type:ko.PERCENTAGE}})}function K_(){return new Ia({children:[],border:{bottom:{style:hn.SINGLE,size:6,color:`999999`,space:1}}})}function q_(e,t){let n=[];for(let r of e)switch(r.type){case`heading`:n.push(N_(r,t.images));break;case`paragraph`:n.push(new Ia({children:k_(r.children,t.images),...U_(t.quoteDepth)}));break;case`list`:n.push(...W_(r,t));break;case`table`:n.push(G_(r,t.images));break;case`code`:{let e=t.diagrams.get(r);e===void 0?n.push(...P_(r)):n.push(V_(e));break}case`blockquote`:n.push(...q_(r.children,{...t,quoteDepth:t.quoteDepth+1}));break;case`thematicBreak`:n.push(K_());break;case`math`:n.push(new Ia({children:A_(r.value,!0,{}),alignment:fn.CENTER}));break;default:{let e=k_(j_(r),t.images);e.length>0&&n.push(new Ia({children:e}));break}}return n}async function J_(e,t){let n=D_(e),r=await R_(n),i=await z_(n,t?.path??``,t?.serverUrl??``,t?.token??null);return q_(n.children,{instance:0,quoteDepth:0,diagrams:r,images:i})}var Y_=`Consolas, Courier New, monospace`;function X_(e){return e.replace(/\r\n/g,`
282
282
  `).replace(/\n$/,``).split(`
283
283
  `).map(e=>new Ia({children:[new er({text:Kg(e===``?` `:e),font:Y_})],spacing:{before:0,after:0}}))}function Z_(e){let t=e.split(/[/\\]/).pop()??`document`,n=t.lastIndexOf(`.`);return`${n>0?t.slice(0,n):t}.docx`}function Q_(e){return/\.(md|markdown)$/i.test(e)}async function $_(e,t,n){let r=new gl({numbering:{config:[ev()]},sections:[{children:await tv(e,t,n)}]});return Fl.toBlob(r)}function ev(){return{reference:E_,levels:[gc.DECIMAL,gc.LOWER_LETTER,gc.LOWER_ROMAN,gc.DECIMAL,gc.LOWER_LETTER].map((e,t)=>({level:t,format:e,text:`%${t+1}.`,alignment:fn.START,style:{paragraph:{indent:{left:720*(t+1),hanging:360}}}}))}}async function tv(e,t,n){return Q_(t)?J_(e,{...n,path:t}):X_(e)}async function nv(t,n,r){e.m(await $_(t,n,r),Z_(n))}exports.downloadDocx=nv;
@@ -294,10 +294,10 @@ l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
294
294
  `)){let e=Jk.exec(r);if(e===null)continue;let[,i,a,o]=e;if(i===``)continue;let s=n.get(i);s===void 0&&(s={path:i,hits:[]},n.set(i,s),t.push(s)),s.hits.push({line:Number(a),text:o})}return t}function Xk(e){return e.reduce((e,t)=>e+t.hits.length,0)}var Zk=8,Qk=5;function $k({item:e,dispatch:t}){let n=Yk(e.output??``),[r,a]=(0,i.useState)(!1);if(n.length===0)return(0,o.jsx)(jk,{item:e});let s=r?n:n.slice(0,Zk);return(0,o.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,o.jsxs)(`div`,{className:`text-xs text-zinc-500`,children:[Xk(n),` match`,Xk(n)===1?``:`es`,` in `,n.length,` file`,n.length===1?``:`s`]}),s.map(e=>(0,o.jsxs)(`div`,{className:`flex flex-col`,children:[(0,o.jsxs)(`button`,{type:`button`,onClick:()=>t({kind:`openFile`,path:e.path}),className:`flex items-center gap-2 truncate text-left font-mono text-xs text-zinc-600 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-zinc-100`,children:[(0,o.jsx)(`span`,{className:`truncate`,children:e.path}),(0,o.jsx)(`span`,{className:`shrink-0 text-zinc-400 dark:text-zinc-600`,children:e.hits.length})]}),(0,o.jsxs)(`div`,{className:`overflow-x-auto rounded border border-zinc-200 font-mono text-xs dark:border-zinc-800`,children:[e.hits.slice(0,Qk).map((e,t)=>(0,o.jsxs)(`div`,{className:`flex gap-2 px-2`,children:[(0,o.jsx)(`span`,{className:`shrink-0 select-none text-zinc-400 dark:text-zinc-600`,children:e.line}),(0,o.jsx)(`span`,{className:`whitespace-pre text-zinc-700 dark:text-zinc-300`,children:e.text})]},t)),e.hits.length>Qk&&(0,o.jsxs)(`div`,{className:`px-2 text-zinc-400 dark:text-zinc-600`,children:[`+`,e.hits.length-Qk,` more in this file`]})]})]},e.path)),!r&&n.length>Zk&&(0,o.jsxs)(`button`,{type:`button`,onClick:()=>a(!0),className:`self-start text-xs text-zinc-500 hover:text-zinc-700 dark:hover:text-zinc-300`,children:[`show `,n.length-Zk,` more file`,n.length-Zk===1?``:`s`]})]})}var eA=[Nk,Fl,Fk,Lk,qk,{id:`code-search`,match:e=>e.toolName===`grep`,stable:!0,showsRawReveal:!0,Expanded:$k},Rk,zk,Mk];function tA(e){for(let t of eA){let n=!1;try{n=t.match(e)}catch{n=!1}if(n)return t}return Mk}function nA(e,t){let n=tA(e);if(t===void 0||t===n.id)return n;let r=eA.find(e=>e.id===t);if(r===void 0||r.id===Mk.id||n.extensionOwned===!0)return n;let i=!1;try{i=r.match(e)}catch{i=!1}return i?r:n}function rA(e){if(typeof e!=`object`||!e)return``;let t=e,n=[`command`,`path`,`file_path`,`pattern`,`query`].find(e=>typeof t[e]==`string`);if(n)return t[n];let r=JSON.stringify(t);return r===`{}`?``:r}function iA({item:e,dispatch:t=Tk}){let n=(0,i.useRef)(void 0),r=nA(e,n.current);n.current=r.id;let a=r.startsExpanded===!0,[s,c]=(0,i.useState)(a);(0,i.useEffect)(()=>{c(a)},[a]);let[l,u]=(0,i.useState)(!1),d=rA(e.args),f=r.Collapsed,p=!s&&f!==void 0&&(r.hasCollapsed?.(e)??!0);return(0,o.jsxs)(`div`,{className:`rounded-lg border text-sm ${e.isError?`border-red-300 bg-red-50 dark:border-red-900/60 dark:bg-red-950/20`:`border-zinc-200 bg-zinc-50 dark:border-zinc-800 dark:bg-zinc-900/60`}`,children:[(0,o.jsxs)(`button`,{type:`button`,onClick:()=>c(!s),className:`flex w-full items-center gap-2 px-3 py-2 text-left`,children:[(0,o.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.running?`animate-pulse motion-reduce:animate-none bg-amber-400`:e.isError?`bg-red-500`:`bg-emerald-500`}`}),e.callHtml?(0,o.jsx)(De,{as:`span`,html:e.callHtml,className:`min-w-0 flex-1 text-zinc-700 dark:text-zinc-300`}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{className:`font-mono font-medium text-zinc-700 dark:text-zinc-300`,children:e.toolName}),d&&(0,o.jsx)(`span`,{className:`truncate font-mono text-xs text-zinc-500`,children:d})]}),(0,o.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-600`,children:s?`▾`:`▸`})]}),e.running&&e.progress!=null&&(0,o.jsx)(`div`,{className:`border-t border-zinc-200 px-3 py-1.5 dark:border-zinc-800`,children:(0,o.jsx)(`progress`,{value:e.progress,max:1,"aria-label":`${e.toolName} progress`,className:`h-1.5 w-full appearance-none overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-800 [&::-moz-progress-bar]:bg-emerald-500 [&::-webkit-progress-bar]:bg-transparent [&::-webkit-progress-value]:rounded-full [&::-webkit-progress-value]:bg-emerald-500`})}),p&&f!==void 0&&(0,o.jsx)(`div`,{className:`border-t border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:(0,o.jsx)(f,{item:e,dispatch:t})}),s&&(0,o.jsxs)(`div`,{className:`border-t border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,o.jsx)(r.Expanded,{item:e,dispatch:t}),r.showsRawReveal===!0&&(0,o.jsxs)(`div`,{className:`mt-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>u(!l),className:`text-xs text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-400`,children:l?`hide raw output`:`raw output`}),l&&(0,o.jsx)(`div`,{className:`mt-1`,children:(0,o.jsx)(jk,{item:e})})]})]})]})}function aA({item:e}){let[n,r]=(0,i.useState)(!1),a=e.details!==void 0,s=!!e.contentHtml,c=e.contentHtmlCollapsed??e.contentHtml,l=a||s&&!!e.contentHtmlCollapsed;return(0,o.jsxs)(`div`,{className:`rounded-lg border border-violet-200 bg-violet-50 px-3 py-2 text-sm dark:border-violet-900/60 dark:bg-violet-950/30`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsxs)(`span`,{className:`font-mono text-xs font-bold text-violet-700 dark:text-violet-300`,children:[`[`,e.customType,`]`]}),l&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>r(!n),title:`Show details`,className:`ml-auto text-xs text-violet-500 hover:text-violet-700 dark:text-violet-500 dark:hover:text-violet-300`,children:n?`▾`:`▸`})]}),s&&c?(0,o.jsx)(De,{html:n||!e.contentHtmlCollapsed?e.contentHtml??c:c,className:`mt-1 text-violet-950 dark:text-violet-100`}):(0,o.jsx)(`div`,{className:`prose-chat mt-1 text-violet-950 dark:text-violet-100`,children:(0,o.jsx)(Tf,{remarkPlugins:[t.n,t.t],rehypePlugins:[cw],children:t.h(e.text)})}),n&&a&&(0,o.jsx)(`pre`,{className:`mt-2 max-h-96 overflow-auto border-t border-violet-200 pt-2 font-mono text-xs text-violet-600 dark:border-violet-900/60 dark:text-violet-400`,children:JSON.stringify(e.details,null,2)})]})}var oA=`pi-outpost:update-notice-dismissed`;function sA(){try{return window.localStorage.getItem(oA)}catch{return null}}function cA({notice:e}){let[t,n]=(0,i.useState)(()=>sA());return t===e.latest?null:(0,o.jsxs)(`div`,{role:`status`,"data-testid":`update-notice`,className:`flex items-center gap-2 border-b border-sky-200 bg-sky-50 px-4 py-1.5 text-xs text-sky-900 dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200`,children:[(0,o.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`pi-outpost `,e.latest,` is available (you have `,e.running,`). `,e.instruction]}),(0,o.jsx)(`code`,{className:`shrink-0 rounded bg-white/70 px-1.5 py-0.5 font-mono dark:bg-sky-900/40`,children:e.copy}),(0,o.jsx)(te,{text:e.copy}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Dismiss the update notice`,onClick:()=>{try{window.localStorage.setItem(oA,e.latest)}catch{}n(e.latest)},className:`shrink-0 rounded px-1.5 text-sky-700 hover:bg-sky-100 dark:text-sky-300 dark:hover:bg-sky-900/50`,children:`×`})]})}function lA(e){return e.id??e.root}var uA={cost:0,unpriced:0,turns:0,input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0};function dA(e){let t={...uA};for(let n of e){if(n.kind!==`assistant`||!n.usage)continue;let e=n.usage;t.turns+=1,t.input+=e.input,t.output+=e.output,t.cacheRead+=e.cacheRead,t.cacheWrite+=e.cacheWrite,t.totalTokens+=e.totalTokens,e.cost===void 0?t.unpriced+=1:t.cost+=e.cost}return t}function fA(e){let t=e>0&&e<.01?4:2;return`$${e.toFixed(t)}`}function pA(e){return e<1e3?String(e):e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1)}M`}var mA=80,hA=new WeakMap;function gA(e){let t=typeof e==`object`&&!!e;if(t){let t=hA.get(e);if(t!==void 0)return t}let n=0;try{n=JSON.stringify(e)?.length??0}catch{n=0}return t&&hA.set(e,n),n}function _A(e){let t=e.replace(/\s+/g,` `).trim();return t.length>mA?`${t.slice(0,79)}…`:t}function vA(e,t){return{index:e,title:t,turns:0,toolCalls:0,failedToolCalls:0,input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,unpriced:0}}function yA(e,t){e.turns+=1,e.input+=t.input,e.output+=t.output,e.cacheRead+=t.cacheRead,e.cacheWrite+=t.cacheWrite,e.totalTokens+=t.totalTokens,t.cost===void 0?e.unpriced+=1:e.cost=(e.cost??0)+t.cost}function bA(e){if(e.length===0)return 0;let t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2==1?t[n]:(t[n-1]+t[n])/2}function xA(e){let t=[],n=[],r=[],i=new Map,a=vA(-1,``),o=a;e.forEach((e,a)=>{if(e.kind===`user`){o=vA(a,_A(e.text)),r.push(o);return}if(e.kind===`assistant`){if(!e.usage)return;t.push({index:a,number:t.length+1,requestIndex:o.index,usage:e.usage}),yA(o,e.usage);return}if(e.kind!==`tool`)return;let s={index:a,toolCallId:e.toolCallId,name:e.toolName,inputSize:gA(e.args),outputSize:e.output.length,isError:e.isError===!0,running:e.running===!0,requestIndex:o.index};n.push(s),o.toolCalls+=1,s.isError&&(o.failedToolCalls+=1);let c=i.get(s.name)??{name:s.name,calls:0,failures:0,inputSize:0,outputSize:0};c.calls+=1,s.isError&&(c.failures+=1),c.inputSize+=s.inputSize,c.outputSize+=s.outputSize,i.set(s.name,c)}),(a.turns>0||a.toolCalls>0)&&r.unshift(a);let s=dA(e),c=t.map(e=>e.usage.cost).filter(e=>e!==void 0),l=n.filter(e=>e.isError).length;return{turns:t,requests:r,toolCalls:n,tools:[...i.values()],totals:s,pricedTurns:c.length,averageTurnCost:c.length===0?0:s.cost/c.length,medianTurnCost:bA(c),totalToolCalls:n.length,failedToolCalls:l,toolCallsPerTurn:t.length===0?0:n.length/t.length}}function SA(e,t){let n=[...e];return t===`input`?n.sort((e,t)=>t.inputSize-e.inputSize):t===`failure`?n.sort((e,t)=>Number(t.isError)-Number(e.isError)||t.outputSize-e.outputSize):n.sort((e,t)=>t.outputSize-e.outputSize)}function CA(e){return e.filter(e=>e.index>=0).sort((e,t)=>t.totalTokens-e.totalTokens||(t.cost??0)-(e.cost??0))}function wA(e){return e<1e3?`${e} B`:e<1e6?`${Math.round(e/1e3)} kB`:`${(e/1e6).toFixed(1)} MB`}var TA=768,EA=26,DA=132,OA=12,kA=96,AA=124,jA=[{key:`input`,label:`input`,className:`text-emerald-500`,value:e=>e.usage.input},{key:`output`,label:`output`,className:`text-blue-500`,value:e=>e.usage.output},{key:`cacheRead`,label:`cache read`,className:`text-violet-500`,value:e=>e.usage.cacheRead},{key:`cacheWrite`,label:`cache write`,className:`text-amber-500`,value:e=>e.usage.cacheWrite}],MA=[{key:`cost`,label:`cost`,className:`text-rose-500`,value:e=>e.usage.cost??0}];function NA({title:e,children:t}){return(0,o.jsxs)(`section`,{className:`border-t border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:[(0,o.jsx)(`h3`,{className:`mb-2 font-mono text-[11px] uppercase tracking-wide text-zinc-400 dark:text-zinc-500`,children:e}),t]})}function PA({children:e}){return(0,o.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:e})}function FA({label:e,value:t,hint:n}){return(0,o.jsxs)(`div`,{className:`rounded-md border border-zinc-200 px-2 py-1.5 dark:border-zinc-800`,children:[(0,o.jsx)(`div`,{"aria-label":`${e}: ${t}`,className:`font-mono text-sm text-zinc-700 dark:text-zinc-200`,children:t}),(0,o.jsx)(`div`,{className:`text-[11px] text-zinc-500 dark:text-zinc-400`,children:e}),n&&(0,o.jsx)(`div`,{className:`text-[10px] text-zinc-400 dark:text-zinc-500`,children:n})]})}function IA({turns:e,series:t,format:n,onJump:r,describe:i}){let a=Math.max(1,...e.flatMap(e=>t.map(t=>t.value(e)))),s=Math.max(e.length*EA,EA),c=e=>EA/2+e*EA,l=e=>OA+kA*(1-e/a);return(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`div`,{className:`mb-1 flex flex-wrap gap-x-3 gap-y-1`,children:t.map(e=>(0,o.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-zinc-500 dark:text-zinc-400`,children:[(0,o.jsx)(`span`,{className:`inline-block h-0.5 w-3 bg-current ${e.className}`}),e.label]},e.key))}),(0,o.jsxs)(`div`,{className:`flex`,children:[(0,o.jsxs)(`div`,{"aria-hidden":!0,className:`flex w-12 shrink-0 flex-col justify-between py-2 pr-1 text-right font-mono text-[9px] text-zinc-400 dark:text-zinc-600`,style:{height:DA},children:[(0,o.jsx)(`span`,{children:n(a)}),(0,o.jsx)(`span`,{children:`0`})]}),(0,o.jsx)(`div`,{className:`min-w-0 flex-1 overflow-x-auto`,children:(0,o.jsxs)(`svg`,{width:s,height:DA,role:`group`,"aria-label":`Per-turn chart`,children:[(0,o.jsx)(`line`,{x1:0,x2:s,y1:108,y2:108,stroke:`currentColor`,className:`text-zinc-200 dark:text-zinc-800`}),t.map(t=>(0,o.jsx)(`polyline`,{fill:`none`,stroke:`currentColor`,strokeWidth:1.5,className:t.className,points:e.map((e,n)=>`${c(n)},${l(t.value(e))}`).join(` `)},t.key)),e.map((n,a)=>(0,o.jsxs)(`g`,{children:[t.map(e=>(0,o.jsx)(`circle`,{cx:c(a),cy:l(e.value(n)),r:2,fill:`currentColor`,className:e.className},e.key)),(0,o.jsx)(`rect`,{x:c(a)-EA/2,y:0,width:EA,height:DA,fill:`transparent`,role:`button`,tabIndex:0,"aria-label":`Turn ${n.number}: ${i(n)} — jump to it`,className:`cursor-pointer outline-none focus-visible:fill-zinc-500/10`,onClick:()=>r(n.index),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r(n.index))},children:(0,o.jsx)(`title`,{children:`turn ${n.number} · ${i(n)}`})}),(e.length<=12||n.number%5==0)&&(0,o.jsx)(`text`,{x:c(a),y:AA,textAnchor:`middle`,className:`fill-zinc-400 text-[9px] dark:fill-zinc-600`,children:n.number})]},n.index))]})})]})]})}function LA({onJump:e,label:t,children:n}){return(0,o.jsx)(`button`,{type:`button`,onClick:e,"aria-label":t,className:`flex w-full items-baseline gap-2 rounded-md px-2 py-1 text-left text-xs hover:bg-zinc-100 dark:hover:bg-zinc-900`,children:n})}function RA({analysis:e,onJump:t,onClose:n}){let[r,a]=(0,i.useState)(`output`),{totals:s}=e;function c(e){t(e),window.innerWidth<TA&&n()}let l=e.turns.length===0&&e.toolCalls.length===0,u=SA(e.toolCalls,r),d=CA(e.requests);return(0,o.jsxs)(`aside`,{"aria-label":`Session analysis`,className:`absolute inset-y-0 right-0 z-10 w-full overflow-y-auto border-l border-zinc-200 bg-white shadow-xl md:w-[26rem] dark:border-zinc-800 dark:bg-zinc-950`,children:[(0,o.jsxs)(`header`,{className:`sticky top-0 flex items-center gap-2 border-b border-zinc-200 bg-white px-4 py-2 dark:border-zinc-800 dark:bg-zinc-950`,children:[(0,o.jsx)(`h2`,{className:`font-mono text-xs text-zinc-600 dark:text-zinc-300`,children:`session analysis`}),(0,o.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close session analysis`,className:`ml-auto rounded-md px-2 py-1 text-sm text-zinc-500 hover:bg-zinc-100 dark:text-zinc-400 dark:hover:bg-zinc-900`,children:`×`})]}),l?(0,o.jsx)(`div`,{className:`px-4 py-6`,children:(0,o.jsx)(PA,{children:`Nothing to analyse yet — no turn has reported figures and no tool has been called.`})}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(NA,{title:`tokens`,children:(0,o.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,o.jsx)(FA,{label:`total`,value:pA(s.totalTokens)}),(0,o.jsx)(FA,{label:`fresh input`,value:pA(s.input)}),(0,o.jsx)(FA,{label:`output`,value:pA(s.output)}),(0,o.jsx)(FA,{label:`cache read`,value:pA(s.cacheRead)}),(0,o.jsx)(FA,{label:`cache write`,value:pA(s.cacheWrite)}),(0,o.jsx)(FA,{label:`turns`,value:String(e.turns.length)})]})}),(0,o.jsx)(NA,{title:`cost`,children:e.pricedTurns===0?(0,o.jsx)(PA,{children:`No turn was priced — this provider reports tokens only.`}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,o.jsx)(FA,{label:`total`,value:fA(s.cost)}),(0,o.jsx)(FA,{label:`average turn`,value:fA(e.averageTurnCost)}),(0,o.jsx)(FA,{label:`median turn`,value:fA(e.medianTurnCost)})]}),(0,o.jsxs)(`p`,{className:`mt-1 text-[11px] text-zinc-400 dark:text-zinc-500`,children:[`over `,e.pricedTurns,` priced turn`,e.pricedTurns===1?``:`s`,s.unpriced>0&&`, ${s.unpriced} unpriced`]})]})}),(0,o.jsx)(NA,{title:`tool calls`,children:e.totalToolCalls===0?(0,o.jsx)(PA,{children:`No tool call recorded in this session.`}):(0,o.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,o.jsx)(FA,{label:`calls`,value:String(e.totalToolCalls)}),(0,o.jsx)(FA,{label:`per turn`,value:e.toolCallsPerTurn.toFixed(1)}),(0,o.jsx)(FA,{label:`failed`,value:String(e.failedToolCalls)})]})}),(0,o.jsx)(NA,{title:`tokens per turn`,children:e.turns.length===0?(0,o.jsx)(PA,{children:`No turn has reported figures yet.`}):(0,o.jsx)(IA,{turns:e.turns,series:jA,format:pA,onJump:c,describe:e=>`${pA(e.usage.totalTokens)} tokens (input ${e.usage.input}, output ${e.usage.output}, cache read ${e.usage.cacheRead}, cache write ${e.usage.cacheWrite})`})}),(0,o.jsx)(NA,{title:`cost per turn`,children:e.pricedTurns===0?(0,o.jsx)(PA,{children:`No turn was priced, so there is no cost to plot.`}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(IA,{turns:e.turns.filter(e=>e.usage.cost!==void 0),series:MA,format:fA,onJump:c,describe:e=>fA(e.usage.cost??0)}),s.unpriced>0&&(0,o.jsxs)(`p`,{className:`mt-1 text-[10px] text-zinc-400 dark:text-zinc-500`,children:[s.unpriced,` unpriced turn`,s.unpriced===1?``:`s`,` left out — they carry no price to plot`]})]})}),(0,o.jsx)(NA,{title:`costliest tool calls`,children:u.length===0?(0,o.jsx)(PA,{children:`No tool call recorded in this session.`}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`mb-1 flex items-center gap-2`,children:[(0,o.jsx)(`label`,{htmlFor:`tool-ranking`,className:`text-[11px] text-zinc-500 dark:text-zinc-400`,children:`rank by`}),(0,o.jsxs)(`select`,{id:`tool-ranking`,value:r,onChange:e=>a(e.target.value),className:`rounded-md border border-zinc-300 bg-white px-1.5 py-0.5 font-mono text-[11px] text-zinc-600 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-300`,children:[(0,o.jsx)(`option`,{value:`output`,children:`output size`}),(0,o.jsx)(`option`,{value:`input`,children:`input size`}),(0,o.jsx)(`option`,{value:`failure`,children:`failure`})]})]}),(0,o.jsx)(`p`,{className:`mb-1 text-[10px] text-zinc-400 dark:text-zinc-500`,children:`measured content size, not tokens — a tool call carries no price`}),u.slice(0,10).map(e=>(0,o.jsxs)(LA,{onJump:()=>c(e.index),label:`Jump to the ${e.name} call, output ${wA(e.outputSize)}`,children:[(0,o.jsx)(`span`,{className:`font-mono text-zinc-600 dark:text-zinc-300`,children:e.name}),e.isError&&(0,o.jsx)(`span`,{className:`text-red-500`,children:`failed`}),e.running&&(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`running`}),(0,o.jsxs)(`span`,{className:`ml-auto font-mono text-zinc-500 dark:text-zinc-400`,children:[`in `,wA(e.inputSize),` · out `,wA(e.outputSize)]})]},e.toolCallId||`${e.index}`))]})}),(0,o.jsx)(NA,{title:`tools`,children:e.tools.length===0?(0,o.jsx)(PA,{children:`No tool has been called yet.`}):(0,o.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,o.jsx)(`thead`,{children:(0,o.jsxs)(`tr`,{className:`text-left text-[10px] uppercase text-zinc-400 dark:text-zinc-500`,children:[(0,o.jsx)(`th`,{className:`font-normal`,children:`tool`}),(0,o.jsx)(`th`,{className:`font-normal`,children:`calls`}),(0,o.jsx)(`th`,{className:`font-normal`,children:`failed`}),(0,o.jsx)(`th`,{className:`text-right font-normal`,children:`in / out`})]})}),(0,o.jsx)(`tbody`,{className:`font-mono text-zinc-600 dark:text-zinc-300`,children:[...e.tools].sort((e,t)=>t.outputSize-e.outputSize).map(e=>(0,o.jsxs)(`tr`,{children:[(0,o.jsx)(`td`,{children:e.name}),(0,o.jsx)(`td`,{children:e.calls}),(0,o.jsx)(`td`,{className:e.failures>0?`text-red-500`:``,children:e.failures}),(0,o.jsxs)(`td`,{className:`text-right`,children:[wA(e.inputSize),` / `,wA(e.outputSize)]})]},e.name))})]})}),(0,o.jsx)(NA,{title:`costliest requests`,children:d.length===0?(0,o.jsx)(PA,{children:`No request has consumed anything yet.`}):d.slice(0,10).map(e=>(0,o.jsxs)(LA,{onJump:()=>c(e.index),label:`Jump to the request "${e.title}"`,children:[(0,o.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-zinc-600 dark:text-zinc-300`,children:e.title}),(0,o.jsxs)(`span`,{className:`shrink-0 font-mono text-zinc-500 dark:text-zinc-400`,children:[pA(e.totalTokens),` tok`,e.cost!==void 0&&` · ${fA(e.cost)}`]}),(0,o.jsxs)(`span`,{className:`shrink-0 text-[10px] text-zinc-400 dark:text-zinc-500`,children:[e.turns,`t / `,e.toolCalls,`c`,e.failedToolCalls>0&&` · ${e.failedToolCalls}✗`]})]},e.index))})]})]})}var zA=2e3;function BA({items:e,scrollerRef:t,hideTools:n,onShowTools:r,onJump:a}){let[o,s]=(0,i.useState)(null),c=(0,i.useRef)(null),[l,u]=(0,i.useState)(0),d=(0,i.useRef)(null);(0,i.useEffect)(()=>()=>{d.current&&clearTimeout(d.current)},[]);let f=(0,i.useCallback)(t=>{let i=e[t];i&&(i.kind===`tool`&&n&&r(),c.current=t,u(e=>e+1))},[e,n,r]);return(0,i.useEffect)(()=>{let e=c.current;if(e===null)return;c.current=null;let n=t.current?.querySelector(`[data-item-index="${e}"]`);n&&(a(n),n.scrollIntoView?.({behavior:`smooth`,block:`center`}),s(e),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>s(null),zA))},[l,n,t,a]),{jumpToItem:f,highlightIndex:o}}var VA={tools:`pi-outpost:hide-tools`,reasoning:`pi-outpost:hide-reasoning`},HA=[`tools`,`reasoning`],UA={tools:`Tool calls`,reasoning:`Reasoning`};function WA(e){try{return localStorage.getItem(VA[e])===`1`}catch{return!1}}function GA(){return{tools:!WA(`tools`),reasoning:!WA(`reasoning`)}}function KA(e,t){try{localStorage.setItem(VA[e],t?`0`:`1`)}catch{}}function qA(e){return HA.filter(t=>!e[t]).length}function JA(e,t){let n=null;for(let r of e)(r.repo===``||t===r.repo||t.startsWith(`${r.repo}/`))&&(n===null||r.repo.length>n.repo.length)&&(n=r);return n}var YA=/(?:^|\s)@([^\s@]+)/g,XA=new Set([`,`,`.`,`;`,`:`,`!`,`?`,`)`,`]`]);function ZA(e){let t=e.length;for(;t>0&&XA.has(e[t-1]);)t--;return e.slice(0,t)}function QA(e){return[...e.matchAll(YA)].map(([,e])=>ZA(e??``)).filter(e=>e.length>0)}var $A=`uploads`,ej=class extends Error{reason;constructor(e,t){super(e),this.name=`UploadError`,this.reason=t}};function tj(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result.split(`,`,2)[1]??``),r.onerror=()=>n(r.error),r.readAsDataURL(e)})}function nj(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function rj(e){return e.type.startsWith(`image/`)?`image`:e.type===`application/pdf`||n.i(e.name)||n.t(e.name)?`extraction-tool`:e.size<=524288?`inline-text`:oj(e)&&e.size<=26214400?`extraction-tool`:`unsupported`}function ij(e){let t=rj(e);return t===`extraction-tool`||t===`image`&&e.size>7340032}var aj=new Set([`application/json`,`application/xml`,`application/javascript`,`application/x-yaml`,`application/yaml`,`application/sql`]);function oj(e){return e.type.startsWith(`text/`)||aj.has(e.type)}function sj(e){return oj(e)?`${e.name}: file too large to upload (max 25 MB)`:`${e.name}: unsupported file type${e.type?` (${e.type})`:``}`}function cj(e,t){return t instanceof ej?t.reason===`denied`?`${e.name}: cannot upload — the workspace is read-only`:t.reason===`too-large`?`${e.name}: file too large to upload (max 25 MB)`:t.reason===`invalid`?`${e.name}: ${t.message}`:`${e.name}: upload failed — ${t.message}`:`${e.name}: upload failed`}async function lj(e){let t;try{t=await e.text()}catch{return{attachments:[],errors:[`${e.name}: could not be read`]}}return t.includes(`\0`)?{attachments:[],errors:[`${e.name}: unsupported binary file`]}:{attachments:[{name:e.name,kind:`text`,data:t,mimeType:e.type||`text/plain`,source:`manual`}],errors:[]}}async function uj(e){try{let t=await tj(e);return{attachments:[{name:e.name,kind:`image`,data:t,mimeType:e.type,source:`manual`}],errors:[]}}catch{return{attachments:[],errors:[`${e.name}: could not be read`]}}}async function dj(e,t){if(e.size>26214400)return{attachments:[],errors:[`${e.name}: file too large to upload (max 25 MB)`]};let n;try{n=await tj(e)}catch{return{attachments:[],errors:[`${e.name}: could not be read`]}}try{return{attachments:[yj(await t(e.name,n))],errors:[]}}catch(t){return{attachments:[],errors:[cj(e,t)]}}}async function fj(e,t){let n=await Promise.all([...e].map(e=>{let n=rj(e);return n===`unsupported`?Promise.resolve({attachments:[],errors:[sj(e)]}):n===`inline-text`?lj(e):n===`image`&&e.size<=7340032?uj(e):dj(e,t)}));return{attachments:n.flatMap(e=>e.attachments),errors:n.flatMap(e=>e.errors)}}function pj(e){return{...yj(e),source:`preview`,previewPath:e}}function mj(e){return pj(e)}function hj(e,t){let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`(^|\\s)@${n}[,.;:!?)\\]]*(\\s|$)`).test(e)}var gj=QA;function _j(e,t){let n=e.trim(),r=e=>{n+=`${n?`
295
295
 
296
296
  `:``}${e}`};for(let e of t)e.kind===`path`?hj(n,e.data)||r(`@${e.data}`):e.kind===`text`&&r(`\`\`\`${e.name}\n${e.data}\n\`\`\``);return n}async function vj(e,t){try{let n=await fetch(t);if(!n.ok)return`${e}: unable to read preview image for attachment`;let r=n.headers.get(`Content-Type`)?.split(`;`,1)[0]??``;if(!r.startsWith(`image/`))return`${e}: preview is not a supported image attachment`;let i=new Uint8Array(await n.arrayBuffer());return i.byteLength>7340032?`${e}: image too large (max 7 MB)`:{name:e,kind:`image`,data:nj(i),mimeType:r,source:`preview`,previewPath:e}}catch{return`${e}: unable to read preview image for attachment`}}function yj(e){return{name:e,kind:`path`,data:e,mimeType:`text/plain`,source:`manual`}}function bj(e,t){return e.some(e=>e.kind===`path`&&e.data===t)?e:[...e,yj(t)]}function xj(e,t){return[...e.filter(e=>e.source!==`preview`),t]}function Sj(e,t){return e.filter((e,n)=>n!==t)}function Cj(e,t){if(!t)return!1;let n=e.composedPath();if(n.length>0)return n.includes(t);let r=e.target;return r!==null&&t.contains(r)}function wj(e){let t=(0,i.useRef)(null);return(0,i.useEffect)(()=>{function n(n){t.current&&!Cj(n,t.current)&&e()}return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),t}var Tj=100,Ej=new Intl.Collator(void 0,{sensitivity:`base`,numeric:!0}),Dj={extension:`ext`,prompt:`prompt`,skill:`skill`};function Oj(e){return e===`directory`||e===`symlink-directory`}function kj(e,t){let n=e.slice(0,t),r=/(?:^|\s)@([^\s@]*)$/.exec(n);return r?{start:t-r[1].length-1,query:r[1]}:null}function Aj({isStreaming:e,connected:t,commands:n,fileSearch:r,prefill:a,attachments:s,pendingUploads:c=[],onAttach:l,onMentionPaths:u,onRemoveAttachment:d,onSend:f,onAbort:p,onSearchFiles:m,onClearFileSearch:h,initialDraft:g,onDraftChange:_}){let[v,y]=(0,i.useState)(g??``);(0,i.useEffect)(()=>{_?.(v)},[v,_]);let[b,x]=(0,i.useState)(0),[ee,te]=(0,i.useState)(0),[ne,re]=(0,i.useState)(!1),ie=(0,i.useRef)(null),ae=(0,i.useRef)(null),oe=(0,i.useRef)(null),se=(0,i.useRef)(null),ce=(0,i.useRef)(null);(0,i.useEffect)(()=>{a&&y(a.text)},[a?.nonce]),(0,i.useEffect)(()=>{ce.current!==null&&(oe.current?.focus(),oe.current?.setSelectionRange(ce.current,ce.current),ce.current=null)},[v]);let le=(0,i.useMemo)(()=>gj(v),[v]);(0,i.useEffect)(()=>{u(le)},[le.join(`
297
- `)]);let ue=(0,i.useMemo)(()=>{let e=/^\/(\S*)$/.exec(v);return e?e[1].toLowerCase():null},[v]),de=(0,i.useMemo)(()=>ue===null?[]:n.filter(e=>e.name.toLowerCase().startsWith(ue)).sort((e,t)=>Ej.compare(e.name,t.name)).slice(0,Tj),[ue,n]),fe=ue===null?kj(v,b):null;(0,i.useEffect)(()=>{if(!fe||fe.query.length===0){h();return}let e=window.setTimeout(()=>m(fe.query),150);return()=>clearTimeout(e)},[fe?.query]);let pe=(0,i.useMemo)(()=>{if(de.length>0)return{kind:`command`,items:de};let e=fe&&r?.query===fe.query?r.results:[];return e.length>0?{kind:`file`,items:e}:null},[de,fe,r]),me=pe!==null&&!ne,S=ue===null?fe?`file:${fe.query}`:null:`cmd:${ue}`;(0,i.useEffect)(()=>{te(0)},[S]),(0,i.useEffect)(()=>{re(!1)},[ue===null?fe?`file`:null:`command`]),(0,i.useEffect)(()=>{if(!me)return;let e=e=>{Cj(e,ie.current)||re(!0)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)}},[me]),(0,i.useEffect)(()=>{ae.current?.querySelector(`[data-selected="true"]`)?.scrollIntoView({block:`nearest`})},[ee]);let he=c.length>0,[ge,_e]=(0,i.useState)(!1);(0,i.useEffect)(()=>{he||_e(!1)},[he]);function ve(){if(he){_e(!0);return}let e=_j(v,s),t=s.filter(e=>e.kind===`image`).map(e=>({data:e.data,mimeType:e.mimeType})),n=s.every(e=>e.kind===`path`);!v.trim()&&(n||!e)&&t.length===0||(f(e,t.length>0?t:void 0),y(``),h())}function ye(e){let t=`/${e.name} `;y(t),ce.current=t.length,x(t.length)}function be(e){if(!fe)return;let t=v.slice(0,fe.start),n=v.slice(b),r=`@${e.path}${Oj(e.type)?`/`:` `}`,i=`${t}${r}${n}`;y(i),h();let a=t.length+r.length;ce.current=a,x(a)}function xe(){if(pe){if(pe.kind===`command`){let e=pe.items[ee];e&&ye(e)}else{let e=pe.items[ee];e&&be(e)}}}function Se(e){if(me&&pe){if(e.key===`ArrowDown`){e.preventDefault(),te(e=>(e+1)%pe.items.length);return}if(e.key===`ArrowUp`){e.preventDefault(),te(e=>(e-1+pe.items.length)%pe.items.length);return}if(e.key===`Tab`||e.key===`Enter`){e.preventDefault(),xe();return}if(e.key===`Escape`){e.preventDefault(),re(!0);return}}e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),ve())}function Ce(e){x(e.currentTarget.selectionStart??0)}function we(e){let t=Array.from(e.clipboardData.files);t.length>0&&(e.preventDefault(),l(t))}return(0,o.jsxs)(`div`,{ref:ie,className:`relative`,children:[(s.length>0||he)&&(0,o.jsxs)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:[c.map(e=>(0,o.jsxs)(`span`,{"data-pending-upload":e.name,title:`${e.name} — copying into the workspace`,className:`flex items-center gap-1.5 rounded-md border border-dashed border-zinc-300 bg-zinc-50 py-1 pl-1.5 pr-2 text-xs text-zinc-500 dark:border-zinc-600 dark:bg-zinc-800/40 dark:text-zinc-400`,children:[(0,o.jsx)(`span`,{"aria-hidden":!0,className:`animate-pulse`,children:`⏳`}),(0,o.jsx)(`span`,{className:`max-w-40 truncate`,children:e.name}),(0,o.jsx)(`span`,{className:`sr-only`,children:`uploading`})]},e.id)),ge&&(0,o.jsx)(`span`,{role:`status`,className:`flex items-center py-1 text-xs text-amber-600 dark:text-amber-400`,children:`waiting for the attachment to finish uploading…`}),s.map((e,t)=>(0,o.jsxs)(`span`,{title:e.kind===`path`?`${e.name} — sent as a reference; the agent reads the file itself`:e.name,className:`flex items-center gap-1.5 rounded-md border border-zinc-200 bg-zinc-50 py-1 pl-1.5 pr-1 text-xs text-zinc-600 dark:border-zinc-700 dark:bg-zinc-800/60 dark:text-zinc-300`,children:[e.kind===`image`?(0,o.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:e.name,className:`h-8 w-8 rounded object-cover`}):(0,o.jsx)(`span`,{"aria-hidden":!0,className:e.kind===`path`?`font-mono font-bold text-blue-600 dark:text-blue-400`:``,children:e.kind===`path`?`@`:`📄`}),(0,o.jsx)(`span`,{className:`max-w-40 truncate`,children:e.name}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>d(t),title:`remove attachment`,className:`rounded px-1 text-zinc-400 hover:bg-zinc-200 hover:text-zinc-700 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`,children:`✕`})]},`${e.name}:${t}`))]}),me&&pe&&(0,o.jsx)(`div`,{ref:ae,className:`absolute bottom-full left-0 z-20 mb-2 max-h-72 w-full max-w-xl overflow-y-auto rounded-lg border border-zinc-200 bg-white py-1 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:pe.kind===`command`?pe.items.map((e,t)=>(0,o.jsxs)(`button`,{type:`button`,"data-selected":t===ee,onMouseEnter:()=>te(t),onClick:()=>ye(e),className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm ${t===ee?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:[(0,o.jsxs)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:[`/`,e.name]}),e.argumentHint&&(0,o.jsx)(`span`,{className:`font-mono text-xs text-zinc-500`,children:e.argumentHint}),e.description&&(0,o.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-zinc-500`,children:e.description}),(0,o.jsx)(`span`,{className:`ml-auto shrink-0 rounded bg-zinc-200 px-1 text-[10px] uppercase text-zinc-500 dark:bg-zinc-800`,children:Dj[e.source]})]},e.name)):pe.items.map((e,t)=>(0,o.jsx)(`button`,{type:`button`,"data-selected":t===ee,onMouseEnter:()=>te(t),onClick:()=>be(e),className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm ${t===ee?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:(0,o.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-zinc-800 dark:text-zinc-200`,children:[e.path,Oj(e.type)?`/`:``]})},e.path))}),(0,o.jsxs)(`div`,{className:`flex items-end gap-2 rounded-xl border border-zinc-200 bg-zinc-50 p-2 focus-within:border-zinc-400 dark:border-zinc-800 dark:bg-zinc-900 dark:focus-within:border-zinc-600`,children:[(0,o.jsx)(`textarea`,{ref:oe,value:v,onChange:e=>{y(e.target.value),x(e.target.selectionStart??e.target.value.length)},onKeyDown:Se,onClick:Ce,onKeyUp:Ce,onPaste:we,placeholder:t?e?`steer the agent… (Enter to send)`:`message pi… (/ for commands, @ for files, Enter to send, Shift+Enter for newline)`:`connecting…`,disabled:!t,rows:Math.min(6,Math.max(1,v.split(`
297
+ `)]);let ue=(0,i.useMemo)(()=>{let e=/^\/(\S*)$/.exec(v);return e?e[1].toLowerCase():null},[v]),de=(0,i.useMemo)(()=>ue===null?[]:n.filter(e=>e.name.toLowerCase().includes(ue)).sort((e,t)=>{let n=e.name.toLowerCase().startsWith(ue);return n===t.name.toLowerCase().startsWith(ue)?Ej.compare(e.name,t.name):n?-1:1}).slice(0,Tj),[ue,n]),fe=ue===null?kj(v,b):null;(0,i.useEffect)(()=>{if(!fe||fe.query.length===0){h();return}let e=window.setTimeout(()=>m(fe.query),150);return()=>clearTimeout(e)},[fe?.query]);let pe=(0,i.useMemo)(()=>{if(de.length>0)return{kind:`command`,items:de};let e=fe&&r?.query===fe.query?r.results:[];return e.length>0?{kind:`file`,items:e}:null},[de,fe,r]),me=pe!==null&&!ne,S=ue===null?fe?`file:${fe.query}`:null:`cmd:${ue}`;(0,i.useEffect)(()=>{te(0)},[S]),(0,i.useEffect)(()=>{re(!1)},[ue===null?fe?`file`:null:`command`]),(0,i.useEffect)(()=>{if(!me)return;let e=e=>{Cj(e,ie.current)||re(!0)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)}},[me]),(0,i.useEffect)(()=>{ae.current?.querySelector(`[data-selected="true"]`)?.scrollIntoView({block:`nearest`})},[ee]);let he=c.length>0,[ge,_e]=(0,i.useState)(!1);(0,i.useEffect)(()=>{he||_e(!1)},[he]);function ve(){if(he){_e(!0);return}let e=_j(v,s),t=s.filter(e=>e.kind===`image`).map(e=>({data:e.data,mimeType:e.mimeType})),n=s.every(e=>e.kind===`path`);!v.trim()&&(n||!e)&&t.length===0||(f(e,t.length>0?t:void 0),y(``),h())}function ye(e){let t=`/${e.name} `;y(t),ce.current=t.length,x(t.length)}function be(e){if(!fe)return;let t=v.slice(0,fe.start),n=v.slice(b),r=`@${e.path}${Oj(e.type)?`/`:` `}`,i=`${t}${r}${n}`;y(i),h();let a=t.length+r.length;ce.current=a,x(a)}function xe(){if(pe){if(pe.kind===`command`){let e=pe.items[ee];e&&ye(e)}else{let e=pe.items[ee];e&&be(e)}}}function Se(e){if(me&&pe){if(e.key===`ArrowDown`){e.preventDefault(),te(e=>(e+1)%pe.items.length);return}if(e.key===`ArrowUp`){e.preventDefault(),te(e=>(e-1+pe.items.length)%pe.items.length);return}if(e.key===`Tab`||e.key===`Enter`){e.preventDefault(),xe();return}if(e.key===`Escape`){e.preventDefault(),re(!0);return}}e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),ve())}function Ce(e){x(e.currentTarget.selectionStart??0)}function we(e){let t=Array.from(e.clipboardData.files);t.length>0&&(e.preventDefault(),l(t))}return(0,o.jsxs)(`div`,{ref:ie,className:`relative`,children:[(s.length>0||he)&&(0,o.jsxs)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:[c.map(e=>(0,o.jsxs)(`span`,{"data-pending-upload":e.name,title:`${e.name} — copying into the workspace`,className:`flex items-center gap-1.5 rounded-md border border-dashed border-zinc-300 bg-zinc-50 py-1 pl-1.5 pr-2 text-xs text-zinc-500 dark:border-zinc-600 dark:bg-zinc-800/40 dark:text-zinc-400`,children:[(0,o.jsx)(`span`,{"aria-hidden":!0,className:`animate-pulse`,children:`⏳`}),(0,o.jsx)(`span`,{className:`max-w-40 truncate`,children:e.name}),(0,o.jsx)(`span`,{className:`sr-only`,children:`uploading`})]},e.id)),ge&&(0,o.jsx)(`span`,{role:`status`,className:`flex items-center py-1 text-xs text-amber-600 dark:text-amber-400`,children:`waiting for the attachment to finish uploading…`}),s.map((e,t)=>(0,o.jsxs)(`span`,{title:e.kind===`path`?`${e.name} — sent as a reference; the agent reads the file itself`:e.name,className:`flex items-center gap-1.5 rounded-md border border-zinc-200 bg-zinc-50 py-1 pl-1.5 pr-1 text-xs text-zinc-600 dark:border-zinc-700 dark:bg-zinc-800/60 dark:text-zinc-300`,children:[e.kind===`image`?(0,o.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:e.name,className:`h-8 w-8 rounded object-cover`}):(0,o.jsx)(`span`,{"aria-hidden":!0,className:e.kind===`path`?`font-mono font-bold text-blue-600 dark:text-blue-400`:``,children:e.kind===`path`?`@`:`📄`}),(0,o.jsx)(`span`,{className:`max-w-40 truncate`,children:e.name}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>d(t),title:`remove attachment`,className:`rounded px-1 text-zinc-400 hover:bg-zinc-200 hover:text-zinc-700 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`,children:`✕`})]},`${e.name}:${t}`))]}),me&&pe&&(0,o.jsx)(`div`,{ref:ae,className:`absolute bottom-full left-0 z-20 mb-2 max-h-72 w-full max-w-xl overflow-y-auto rounded-lg border border-zinc-200 bg-white py-1 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:pe.kind===`command`?pe.items.map((e,t)=>(0,o.jsxs)(`button`,{type:`button`,"data-selected":t===ee,onMouseEnter:()=>te(t),onClick:()=>ye(e),className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm ${t===ee?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:[(0,o.jsxs)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:[`/`,e.name]}),e.argumentHint&&(0,o.jsx)(`span`,{className:`font-mono text-xs text-zinc-500`,children:e.argumentHint}),e.description&&(0,o.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-zinc-500`,children:e.description}),(0,o.jsx)(`span`,{className:`ml-auto shrink-0 rounded bg-zinc-200 px-1 text-[10px] uppercase text-zinc-500 dark:bg-zinc-800`,children:Dj[e.source]})]},e.name)):pe.items.map((e,t)=>(0,o.jsx)(`button`,{type:`button`,"data-selected":t===ee,onMouseEnter:()=>te(t),onClick:()=>be(e),className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm ${t===ee?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:(0,o.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-zinc-800 dark:text-zinc-200`,children:[e.path,Oj(e.type)?`/`:``]})},e.path))}),(0,o.jsxs)(`div`,{className:`flex items-end gap-2 rounded-xl border border-zinc-200 bg-zinc-50 p-2 focus-within:border-zinc-400 dark:border-zinc-800 dark:bg-zinc-900 dark:focus-within:border-zinc-600`,children:[(0,o.jsx)(`textarea`,{ref:oe,value:v,onChange:e=>{y(e.target.value),x(e.target.selectionStart??e.target.value.length)},onKeyDown:Se,onClick:Ce,onKeyUp:Ce,onPaste:we,placeholder:t?e?`steer the agent… (Enter to send)`:`message pi… (/ for commands, @ for files, Enter to send, Shift+Enter for newline)`:`connecting…`,disabled:!t,rows:Math.min(6,Math.max(1,v.split(`
298
298
  `).length)),className:`flex-1 resize-none bg-transparent px-2 py-1.5 text-[15px] outline-none placeholder:text-zinc-400 disabled:opacity-50 dark:placeholder:text-zinc-600`}),e&&(0,o.jsx)(`button`,{type:`button`,onClick:p,title:`stop`,"aria-label":`Stop the agent`,className:`rounded-lg bg-red-100 p-2 text-red-700 hover:bg-red-200 dark:bg-red-900/60 dark:text-red-200 dark:hover:bg-red-900`,children:(0,o.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,className:`h-4 w-4`,children:(0,o.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>se.current?.click(),disabled:!t,title:`attach files`,"aria-label":`Attach files`,className:`rounded-lg p-2 text-zinc-500 hover:bg-zinc-200 hover:text-zinc-700 disabled:opacity-30 dark:text-zinc-400 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:(0,o.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,o.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`})})}),(0,o.jsx)(`input`,{ref:se,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files?.length&&l(Array.from(e.target.files)),e.target.value=``}}),(0,o.jsx)(`button`,{type:`button`,onClick:ve,disabled:!t||he||!v.trim()&&s.length===0,title:he?`waiting for an attachment to finish uploading`:e?`steer`:`send`,"aria-label":e?`Steer the agent`:`Send message`,className:`rounded-lg bg-zinc-900 p-2 text-zinc-100 hover:bg-zinc-800 disabled:opacity-30 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white`,children:e?(0,o.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:[(0,o.jsx)(`circle`,{cx:`6`,cy:`19`,r:`3`}),(0,o.jsx)(`path`,{strokeLinecap:`round`,d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`}),(0,o.jsx)(`circle`,{cx:`18`,cy:`5`,r:`3`})]}):(0,o.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,o.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M6 12 3.27 3.13c6.6 1.9 12.83 4.9 18.43 8.87-5.6 3.97-11.83 6.97-18.43 8.87L6 12Zm0 0h7.5`})})})]})]})}var jj=`rounded-md border px-3 py-1.5 text-sm border-zinc-200 hover:bg-zinc-100 dark:border-zinc-800 dark:hover:bg-zinc-800`,Mj=`rounded-md bg-zinc-900 px-3 py-1.5 text-sm text-zinc-100 hover:bg-zinc-800 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white`,Nj=`w-full rounded-md border border-zinc-300 bg-white px-2 py-1.5 text-sm outline-none focus:border-zinc-500 dark:border-zinc-700 dark:bg-zinc-950 dark:focus:border-zinc-500`,Pj=`mb-4 ${Nj}`,Fj=`1,3`,Ij=` — `;function Lj(e){let t=e.indexOf(`
299
299
  `);return t===-1?{heading:e,body:``}:{heading:e.slice(0,t),body:e.slice(t+1).trim()}}function Rj(e){let t=/^(\d+)\.\s+(\S[\s\S]*)$/.exec(e.trim());if(!t)return null;let n=t[2],r=n.indexOf(Ij);return{index:Number(t[1]),label:r===-1?n:n.slice(0,r),description:r===-1?``:n.slice(r+3)}}function zj(e){if(e.method!==`input`||e.placeholder!==Fj)return null;let{heading:t,body:n}=Lj(e.title),r=[];for(let e of n.split(`
300
- `)){let t=Rj(e);t&&r.push(t)}return r.length<2||r.some((e,t)=>e.index!==t+1)?null:{heading:t,options:r}}function Bj({request:e,onRespond:t}){let[n,r]=(0,i.useState)(e.method===`editor`?e.prefill??``:``),[a,s]=(0,i.useState)([]),[c,l]=(0,i.useState)(!1),u=(e.method===`select`||e.method===`confirm`||e.method===`input`)&&e.timeout,[d,f]=(0,i.useState)(u?Math.ceil(u/1e3):null),p=zj(e),{heading:m,body:h}=Lj(e.title);function g(){t({id:e.id,cancelled:!0})}function _(e){s(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e].sort((e,t)=>e-t))}function v(){let r=n.trim();t({id:e.id,value:r.length>0?r:a.join(`,`)})}return(0,i.useEffect)(()=>{if(!c)return;let e=setTimeout(()=>l(!1),400);return()=>clearTimeout(e)},[c]),(0,i.useEffect)(()=>{if(d===null)return;if(d<=0){t({id:e.id,cancelled:!0});return}let n=setTimeout(()=>f(e=>e===null?null:e-1),1e3);return()=>clearTimeout(n)},[d,e.id,t]),(0,o.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:()=>l(!0),children:(0,o.jsxs)(`div`,{className:`w-full ${h?`max-w-2xl`:`max-w-md`} rounded-xl border bg-white p-4 shadow-2xl transition-shadow dark:bg-zinc-900 ${c?`border-zinc-400 ring-2 ring-zinc-400/60 dark:border-zinc-500 dark:ring-zinc-500/60`:`border-zinc-200 dark:border-zinc-700`}`,onClick:e=>e.stopPropagation(),children:[(0,o.jsxs)(`div`,{className:`mb-3 flex items-start gap-3`,children:[(0,o.jsx)(`h2`,{className:`flex-1 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:m}),(0,o.jsx)(`button`,{type:`button`,onClick:g,"aria-label":`Refuse to answer`,title:`Refuse to answer`,className:`-mr-1 -mt-1 rounded-md px-1.5 py-0.5 text-sm leading-none text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:`✕`})]}),h&&!p&&(0,o.jsx)(`pre`,{className:`mb-3 max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md bg-zinc-50 p-2 font-mono text-xs text-zinc-600 dark:bg-zinc-950 dark:text-zinc-400`,children:h}),e.method===`select`&&(0,o.jsx)(`div`,{className:`mb-1 flex flex-col gap-1`,children:e.options.map(n=>{let r=Rj(n);return(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:`text-left ${jj}`,children:r?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:r.label}),r.description&&(0,o.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:r.description})]}):n},n)})}),e.method===`confirm`&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`p`,{className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:e.message}),(0,o.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!1}),className:jj,children:`No`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!0}),className:Mj,children:`Yes`})]})]}),p&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`div`,{className:`mb-3 flex flex-col gap-1`,children:p.options.map(e=>(0,o.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:a.includes(e.index),onChange:()=>_(e.index),className:`mt-0.5`}),(0,o.jsxs)(`span`,{children:[(0,o.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:e.label}),e.description&&(0,o.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:e.description})]})]},e.index))}),(0,o.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`…or type your own answer`,onKeyDown:e=>{e.key===`Enter`&&v(),e.key===`Escape`&&g()},className:`mb-1 ${Nj}`}),(0,o.jsx)(`p`,{className:`mb-4 text-xs text-zinc-400 dark:text-zinc-600`,children:`A typed answer replaces the selection above.`}),(0,o.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:g,className:jj,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:v,className:Mj,children:`OK`})]})]}),e.method===`input`&&!p&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`input`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),placeholder:e.placeholder,onKeyDown:r=>{r.key===`Enter`&&t({id:e.id,value:n}),r.key===`Escape`&&g()},className:Pj}),(0,o.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:g,className:jj,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:Mj,children:`OK`})]})]}),e.method===`editor`&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`textarea`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),rows:8,onKeyDown:e=>{e.key===`Escape`&&g()},className:`resize-none font-mono ${Pj}`}),(0,o.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:g,className:jj,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:Mj,children:`OK`})]})]}),d!==null&&(0,o.jsxs)(`p`,{className:`mt-3 text-right text-xs text-zinc-400 dark:text-zinc-600`,children:[`auto-dismiss in `,d,`s`]})]})})}var Vj={info:`border-blue-300 bg-blue-50 text-blue-800 dark:border-blue-900 dark:bg-blue-950/60 dark:text-blue-200`,warning:`border-amber-300 bg-amber-50 text-amber-800 dark:border-amber-900 dark:bg-amber-950/60 dark:text-amber-200`,error:`border-red-300 bg-red-50 text-red-800 dark:border-red-900 dark:bg-red-950/60 dark:text-red-200`},Hj=6e3;function Uj({notification:e,onDismiss:t}){let n=(0,i.useRef)(t);return(0,i.useEffect)(()=>{n.current=t}),(0,i.useEffect)(()=>{let e=setTimeout(()=>n.current(),Hj);return()=>clearTimeout(e)},[e.id]),(0,o.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-lg border px-3 py-2 text-sm shadow-lg ${Vj[e.notifyType??`info`]}`,children:[(0,o.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:e.message}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Dismiss notification`,onClick:()=>n.current(),className:`-mr-1 shrink-0 rounded px-1 leading-5 opacity-60 transition-opacity hover:opacity-100 focus-visible:opacity-100`,children:`×`})]})}function Wj({notifications:e,onDismiss:t}){return e.length===0?null:(0,o.jsx)(`div`,{className:`fixed right-4 top-16 z-40 flex w-80 flex-col gap-2`,children:e.map(e=>(0,o.jsx)(Uj,{notification:e,onDismiss:()=>t(e.id)},e.id))})}var Gj={30:`#3f3f46`,31:`#dc2626`,32:`#16a34a`,33:`#ca8a04`,34:`#2563eb`,35:`#9333ea`,36:`#0891b2`,37:`#71717a`,90:`#a1a1aa`,91:`#ef4444`,92:`#22c55e`,93:`#eab308`,94:`#3b82f6`,95:`#a855f7`,96:`#06b6d4`,97:`#d4d4d8`},Kj=/\u001B\[[0-9;:]*[A-Za-z]|\u001B[()][A-Za-z0-9]|\u001B[A-Za-z]/g;function qj(e,t){let n={...e};for(let e=0;e<t.length;e++){let r=t[e];if(r===0)for(let e of Object.keys(n))delete n[e];else if(r===1)n.bold=!0;else if(r===2)n.dim=!0;else if(r===3)n.italic=!0;else if(r===4)n.underline=!0;else if(r===22)delete n.bold,delete n.dim;else if(r===23)delete n.italic;else if(r===24)delete n.underline;else if(r===39)delete n.color;else if(Gj[r]!==void 0)n.color=Gj[r];else if(r===38){if(t[e+1]===2){let[r,i,a]=[t[e+2],t[e+3],t[e+4]];[r,i,a].every(e=>Number.isFinite(e))&&(n.color=`rgb(${r} ${i} ${a})`),e+=4}else t[e+1]===5&&(e+=2)}}return n}function Jj(e){let t=[],n={},r=0;Kj.lastIndex=0;for(let i=Kj.exec(e);i!==null;i=Kj.exec(e)){i.index>r&&t.push({text:e.slice(r,i.index),...n}),r=i.index+i[0].length;let a=i[0];if(a.endsWith(`m`)){let e=a.slice(2,-1),t=e===``?[0]:e.split(/[;:]/).map(e=>e===``?0:Number(e));n=qj(n,t)}}return r<e.length&&t.push({text:e.slice(r),...n}),t}function Yj(e){return e.replace(Kj,``)}function Xj({line:e}){let t=Jj(e);return(0,o.jsx)(o.Fragment,{children:t.map((e,t)=>(0,o.jsx)(`span`,{style:{...e.color?{color:e.color}:{},...e.bold?{fontWeight:600}:{},...e.dim?{opacity:.7}:{},...e.italic?{fontStyle:`italic`}:{},...e.underline?{textDecoration:`underline`}:{}},children:e.text},t))})}function Zj({widgets:e,placement:t}){let n=Object.entries(e).filter(([,e])=>e.placement===t);return n.length===0?null:(0,o.jsx)(`div`,{className:`mb-2 flex flex-col gap-1`,children:n.map(([e,t])=>(0,o.jsx)(`div`,{className:`whitespace-pre-wrap rounded-md border border-zinc-200 bg-zinc-50 px-3 py-1.5 font-mono text-xs text-zinc-600 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-400`,children:t.lines.map((e,t)=>(0,o.jsx)(`div`,{children:(0,o.jsx)(Xj,{line:e})},t))},e))})}function Qj({text:e,path:t,serverUrl:n,token:r}){let[a,s]=(0,i.useState)(`idle`),[c,l]=(0,i.useState)(null),u=(0,i.useRef)(!1),d=(0,i.useRef)(0);async function f(){if(!(u.current||Date.now()-d.current<750)){u.current=!0,d.current=Date.now(),s(`working`),l(null);try{let{downloadDocx:i}=await Promise.resolve().then(()=>require("./docxExport-DKx7m8Wz.cjs"));await i(e,t,{serverUrl:n,token:r}),s(`idle`)}catch(e){s(`failed`),l(e instanceof Error?e.message:String(e))}finally{u.current=!1}}}return(0,o.jsx)(`button`,{type:`button`,onClick:()=>void f(),disabled:a===`working`,title:a===`failed`?`Could not export: ${c??`unknown reason`}`:`Download as a Word document`,"aria-label":`Download as a Word document`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 disabled:opacity-50 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,children:a===`working`?`… exporting`:a===`failed`?`⚠ export failed`:`⤓ word`})}function $j({query:e,onQueryChange:t,matchCount:n,truncated:r=!1,currentIndex:a,searching:s=!1,onNext:c,onPrev:l,onClose:u,inputRef:d}){let f=(0,i.useRef)(null),p=d??f;(0,i.useEffect)(()=>{p.current?.focus(),p.current?.select()},[]);let m=n===0?s?`searching…`:`0/0`:`${a+1}/${n}${r?`+`:``}`;return(0,o.jsxs)(`div`,{role:`search`,"aria-label":`Find in file`,className:`flex items-center gap-2 border-b border-zinc-200 bg-zinc-50 px-3 py-1.5 text-xs dark:border-zinc-800 dark:bg-zinc-900`,children:[(0,o.jsx)(`input`,{ref:p,type:`text`,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.shiftKey?l():c()):e.key===`Escape`&&(e.stopPropagation(),u())},placeholder:`Find in file`,"aria-label":`Find`,className:`min-w-0 flex-1 rounded border border-zinc-300 bg-white px-2 py-1 text-xs text-zinc-700 outline-none focus-visible:ring-1 focus-visible:ring-zinc-400 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-200`}),(0,o.jsx)(`span`,{className:`shrink-0 tabular-nums text-zinc-500 dark:text-zinc-400`,children:m}),(0,o.jsx)(`button`,{type:`button`,onClick:l,disabled:n===0,"aria-label":`Previous match`,title:`Previous match (Shift+Enter)`,className:`shrink-0 rounded px-1.5 py-0.5 text-zinc-500 hover:bg-zinc-200 disabled:opacity-40 dark:text-zinc-400 dark:hover:bg-zinc-800`,children:`‹`}),(0,o.jsx)(`button`,{type:`button`,onClick:c,disabled:n===0,"aria-label":`Next match`,title:`Next match (Enter)`,className:`shrink-0 rounded px-1.5 py-0.5 text-zinc-500 hover:bg-zinc-200 disabled:opacity-40 dark:text-zinc-400 dark:hover:bg-zinc-800`,children:`›`}),(0,o.jsx)(`button`,{type:`button`,onClick:u,"aria-label":`Close find bar`,title:`Close (Esc)`,className:`shrink-0 rounded px-1.5 py-0.5 text-zinc-500 hover:bg-zinc-200 dark:text-zinc-400 dark:hover:bg-zinc-800`,children:`✕`})]})}var eM=(0,i.lazy)(()=>Promise.resolve().then(()=>require("./PdfViewer-DJJoRd17.cjs"))),tM=250,nM=`(min-width: 768px)`;function rM(){let[e,t]=(0,i.useState)(()=>window.matchMedia?.(nM).matches??!0);return(0,i.useEffect)(()=>{let e=window.matchMedia?.(nM);if(e===void 0)return;let n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function iM(e,t){let[n,r]=(0,i.useState)(e);return(0,i.useEffect)(()=>{let n=window.setTimeout(()=>r(e),t);return()=>window.clearTimeout(n)},[e,t]),n}function aM(e){let t=mc(e);return t.status===`valid`?t.envelope:void 0}function oM(e){return/\.(md|markdown)$/i.test(e)}function sM(e,t){return t===void 0?!0:t===null?!1:t===``||e===t||e.startsWith(`${t}/`)}function cM({file:e,writableRoot:a,isStreaming:s,onDirtyChange:c,gitState:l,initialShowGitDiff:u=!1,gitDiff:d,onFetchGitDiff:f,onClearGitDiff:p,inRepository:m,onOpenGitHistory:h,onClose:g,onReload:v,onSave:y,serverUrl:b=``,token:x=null,onImageLoad:ee,onPdfLoad:ne,rawRevision:re=0}){let[ie,ae]=(0,i.useState)(`rendered`),[oe,ce]=(0,i.useState)(u),[le,ue]=(0,i.useState)(e.status===`loaded`&&e.justCreated?{draft:e.content,baseContent:e.content,baseMtimeMs:e.mtimeMs}:null),[de,fe]=(0,i.useState)(`idle`),pe=(0,i.useRef)(null),me=(0,i.useRef)(null),S=e.status===`loaded`?e:null,he=S!==null&&oM(e.path),ge=n.r(e.path),_e=n.i(e.path),ve=(0,i.useMemo)(()=>S===null?void 0:mc(S.content),[S?.content]),ye=ve?.status===`valid`,be=ve?.status===`valid`||ve?.status===`invalid`,xe=be||he,Se=ie===`source`,Ce=rM(),we=sM(e.path,a)&&!_e,Ee=le!==null&&le.draft!==le.baseContent,De=S?.pendingSave!==void 0,ke=le!==null&&S!==null&&S.mtimeMs!==le.baseMtimeMs,Ae=S?.saveError?.conflict===!0||ke,je=le?.draft??S?.content??``,Me=iM(je,tM),Ne=(0,i.useMemo)(()=>S===null?void 0:mc(Me),[Me,S===null]),[Pe,Fe]=(0,i.useState)(()=>e.status===`loaded`?aM(e.content):void 0);(0,i.useEffect)(()=>{Ne?.status===`valid`&&Fe(Ne.envelope)},[Ne]);let Ie=Ne!==void 0&&Ne.status!==`valid`&&Pe!==void 0,Le=Ne?.status===`invalid`?Me===S?.content&&S.documentIssues!==void 0?S.documentIssues:Ne.issues:void 0,Re=Ne?.status===`not-a-document`?Ne.why===`unparseable`?`This is not parseable JSON yet.`:"This no longer declares a structured-exchange `schema`.":Ne?.status===`unsupported-version`?`This declares ${Ne.schema}, which this version does not render.`:void 0,ze=ie===`split`&&xe&&!oe&&S!==null&&Ce,Be=oe||ze?`none`:_e?`pdf`:le===null?S!==null&&!ge?`dom`:`none`:`edit`,[Ve,He]=(0,i.useState)(!1),[Ue,We]=(0,i.useState)(``),[Ge,Ke]=(0,i.useState)(0),qe=(0,i.useRef)(null),Je=(0,i.useRef)(null),Ye=(0,i.useRef)(null),[Xe,Ze]=(0,i.useState)({matchCount:0,currentIndex:-1,searching:!1}),[Qe,$e]=(0,i.useState)([]),[et,tt]=(0,i.useState)(!1),nt=(0,i.useRef)(null),rt=(0,i.useRef)([]),it=(0,i.useRef)(0),at=(0,i.useRef)(``);function ot(e){it.current=e;for(let[t,n]of rt.current.entries())for(let r of n.marks)r.isConnected&&r.classList.toggle(`find-match-current`,t===e);let t=rt.current[e]?.marks;t?.[0]?.isConnected&&t[0].scrollIntoView({block:`center`})}let st=Ve?Ue:``,ct=(0,i.useMemo)(()=>Be===`edit`?r.t(je,st):[],[Be,je,st]);(0,i.useEffect)(()=>{Ve&&Be===`none`&&He(!1)},[Ve,Be]);let[lt,ut]=(0,i.useState)(0),dt=(0,i.useCallback)(()=>ut(e=>e+1),[]);(0,i.useEffect)(()=>{function e(){nt.current?.clear(),nt.current=null,rt.current=[],$e([]),tt(!1)}let t=Je.current;if(Be!==`dom`||st===``||t===null){e();return}nt.current?.clear();let n=r.n(t,st);nt.current=n,rt.current=n.matches,$e(n.matches),tt(n.truncated);let i=st!==at.current;at.current=st;let a=i?0:Math.min(it.current,Math.max(n.matches.length-1,0));return Ke(a),ot(a),e},[Be,st,ie,Se,lt]);function ft(e,t){let n=e[t],r=pe.current;n!==void 0&&r!==null&&(r.focus(),r.setSelectionRange(n.start,n.end),qe.current?.focus())}(0,i.useEffect)(()=>{if(Be!==`edit`||!Ve)return;let e=r.t(je,st);Ke(0),e.length>0&&ft(e,0)},[st,Be,Ve]);function pt(){He(!0)}function mt(){He(!1)}function ht(){if(Be===`pdf`)Ye.current?.findNext();else if(Be===`edit`){if(ct.length===0)return;let e=(Ge+1)%ct.length;Ke(e),ft(ct,e)}else{let e=rt.current.length;if(e===0)return;let t=(it.current+1)%e;Ke(t),ot(t)}}function gt(){if(Be===`pdf`)Ye.current?.findPrevious();else if(Be===`edit`){if(ct.length===0)return;let e=(Ge-1+ct.length)%ct.length;Ke(e),ft(ct,e)}else{let e=rt.current.length;if(e===0)return;let t=(it.current-1+e)%e;Ke(t),ot(t)}}let _t=Be===`pdf`?{matchCount:Xe.matchCount,currentIndex:Xe.currentIndex,truncated:!1,searching:Xe.searching}:Be===`edit`?{matchCount:ct.length,currentIndex:ct.length>0?Math.min(Ge,ct.length-1):-1,truncated:!1,searching:!1}:{matchCount:Qe.length,currentIndex:Qe.length>0?Math.min(Ge,Qe.length-1):-1,truncated:et,searching:!1},vt=le===null?null:(0,o.jsx)(`textarea`,{ref:pe,value:le.draft,onChange:e=>ue({...le,draft:e.target.value}),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),Ee&&!De&&!Ae&&Ct())},spellCheck:!1,className:`h-full w-full resize-none bg-transparent p-4 font-mono text-[13px] leading-relaxed text-zinc-800 outline-none ring-inset focus-visible:ring-1 focus-visible:ring-zinc-300 dark:text-zinc-200 dark:focus-visible:ring-zinc-700`});function yt(r){return(0,o.jsx)(`div`,{className:`prose-chat mx-auto max-w-3xl p-4 text-zinc-700 dark:text-zinc-300`,children:(0,o.jsx)(Tf,{remarkPlugins:[t.n,t.t],rehypePlugins:[cw],components:{pre:Te,a:({href:t,children:r,...i})=>!t||/^[a-z][a-z0-9+.-]*:/i.test(t)?(0,o.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,...i,children:r}):t.startsWith(`#`)?(0,o.jsx)(`a`,{href:t,...i,children:r}):(0,o.jsx)(`a`,{href:t,onClick:r=>{r.preventDefault(),v(n.o(e.path,t))},...i,children:r}),img:({src:t,alt:r,...i})=>{let a=typeof t==`string`&&t!==``&&!/^[a-z][a-z0-9+.-]*:/i.test(t)&&!t.startsWith(`//`)?n.a(b,n.o(e.path,t),x):t;return(0,o.jsx)(`img`,{...i,src:a,alt:r??``,loading:`lazy`,className:`max-w-full rounded-lg`})}},children:t.h(r)})})}function bt(e){ie===`split`&&e!==`split`&&Ee&&!window.confirm(`Discard unsaved changes?`)||(ie===`split`&&e!==`split`&&ue(null),ae(e))}function xt(){Ee&&!window.confirm(`Discard unsaved changes?`)||g()}function St(){S&&ue({draft:S.content,baseContent:S.content,baseMtimeMs:S.mtimeMs})}function Ct(t=!1){!S||le===null||De||(me.current=le.draft,y(e.path,le.draft,le.baseMtimeMs,t))}function wt(){ue(null),v(e.path)}function Tt(){let t=!oe;ce(t),t?f(e.path):p()}return(0,i.useEffect)(()=>{if(le!==null&&S!==null&&me.current!==null&&S.content===me.current&&S.mtimeMs!==le.baseMtimeMs){let e=me.current;me.current=null,le.draft===e?ue(null):ue({...le,baseContent:S.content,baseMtimeMs:S.mtimeMs})}},[S?.mtimeMs]),(0,i.useEffect)(()=>{function e(e){if(e.key===`Escape`){Ve?mt():xt();return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`f`){if(Be===`none`)return;e.preventDefault(),pt()}}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,i.useEffect)(()=>{ze&&we&&le===null&&S!==null&&ue({draft:S.content,baseContent:S.content,baseMtimeMs:S.mtimeMs})},[ze,we,S?.mtimeMs]),(0,i.useEffect)(()=>{fe(s?`streaming`:e=>e===`streaming`?`done`:e)},[s]),(0,i.useEffect)(()=>(c(Ee),()=>c(!1)),[Ee]),(0,i.useEffect)(()=>(u&&f(e.path),()=>p()),[]),(0,o.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[xe&&!oe&&(0,o.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5`,role:`group`,"aria-label":`How to show this document`,children:[[`rendered`,`⚏ rendered`,`Show the rendering`],[`split`,`⇹ split`,`Edit the file beside its rendering`],[`source`,`⌗ source`,`Show the file as written`]].map(([e,t,n])=>(0,o.jsx)(`button`,{type:`button`,onClick:()=>bt(e),"aria-pressed":ie===e,title:n,className:`rounded px-1.5 py-0.5 text-xs ${ie===e?`bg-zinc-100 text-zinc-700 dark:bg-zinc-800 dark:text-zinc-200`:`text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`}`,children:t},e))}),l!==void 0&&le===null&&(0,o.jsx)(`button`,{type:`button`,onClick:Tt,"aria-pressed":oe,title:oe?`Show file content`:`Show uncommitted changes (vs HEAD)`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs ${oe?`bg-amber-100 text-amber-800 dark:bg-amber-950/60 dark:text-amber-300`:`text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`}`,children:`± diff`}),m&&le===null&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>h(e.path),title:`Show this file's history`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,children:`⎇ history`}),(0,o.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-zinc-500 dark:text-zinc-400`,title:e.path,children:[e.path,Ee&&(0,o.jsx)(`span`,{className:`ml-1 text-amber-500`,children:`●`})]}),S&&!ge&&!_e&&!oe&&(0,o.jsx)(Qj,{text:je,path:e.path,serverUrl:b,token:x}),S&&le===null&&(0,o.jsx)(te,{text:S.content}),S&&le===null&&!oe&&we&&(0,o.jsx)(`button`,{type:`button`,onClick:St,className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500 dark:hover:text-zinc-200`,children:`✎ edit`}),S&&le===null&&!we&&(0,o.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,title:`Outside the writable zone`,children:`🔒 read-only`}),le!==null&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>Ct(),disabled:!Ee||De||Ae,className:`shrink-0 rounded border border-emerald-300 px-2 py-0.5 text-xs text-emerald-700 hover:border-emerald-500 disabled:opacity-50 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600`,children:De?`saving…`:`save`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{Ee&&!window.confirm(`Discard unsaved changes?`)||ue(ze&&S!==null?{draft:S.content,baseContent:S.content,baseMtimeMs:S.mtimeMs}:null)},className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-500 hover:border-zinc-400 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500`,children:`cancel`})]}),(0,o.jsx)(`button`,{type:`button`,onClick:xt,title:`Close (Esc)`,"aria-label":`Close file viewer`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),Ve&&Be!==`none`&&(0,o.jsx)($j,{inputRef:qe,query:Ue,onQueryChange:We,matchCount:_t.matchCount,currentIndex:_t.currentIndex,truncated:_t.truncated,searching:_t.searching,onNext:ht,onPrev:gt,onClose:mt}),Ae&&le!==null&&(0,o.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:[(0,o.jsx)(`span`,{className:`min-w-0 flex-1`,children:`File changed on disk since you started editing.`}),(0,o.jsx)(`button`,{type:`button`,onClick:wt,className:`shrink-0 rounded border border-amber-400 px-2 py-0.5 text-xs hover:bg-amber-100 dark:border-amber-800 dark:hover:bg-amber-950/60`,children:`reload (discard my edits)`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>Ct(!0),disabled:De,className:`shrink-0 rounded border border-amber-400 px-2 py-0.5 text-xs hover:bg-amber-100 disabled:opacity-50 dark:border-amber-800 dark:hover:bg-amber-950/60`,children:`overwrite with my version`})]}),le!==null&&S?.saveError&&!S.saveError.conflict&&(0,o.jsx)(`div`,{className:`border-b border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:S.saveError.message}),(0,o.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[oe&&le===null&&(0,o.jsxs)(`div`,{className:`p-4`,children:[d?.path===e.path&&`error`in d&&(0,o.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:d.error}),d?.path===e.path&&`before`in d&&(0,o.jsx)(Oe,{fill:!0,lines:_(d.before,d.after)}),d?.path!==e.path&&(0,o.jsx)(`div`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`loading diff…`})]}),_e&&le===null&&!oe&&(0,o.jsx)(Il,{label:`This PDF`,children:(0,o.jsx)(i.Suspense,{fallback:(0,o.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),children:(0,o.jsx)(eM,{ref:Ye,path:e.path,serverUrl:b,token:x,revision:re,findQuery:Be===`pdf`?st:``,onFindStateChange:Ze,...ne?{onLoaded:ne}:{}})})}),ge&&le===null&&!oe&&(0,o.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,o.jsx)(`img`,{src:n.a(b,e.path,x,re),alt:e.path,onLoad:()=>ee(e.path),className:`max-h-full max-w-full rounded object-contain`})}),e.status===`loading`&&le===null&&!oe&&!ge&&!_e&&(0,o.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),e.status===`error`&&!ge&&!_e&&(0,o.jsx)(`div`,{className:`p-4 text-sm text-red-600 dark:text-red-400`,children:e.message}),le!==null&&!ze&&vt,S&&le===null&&!ze&&!oe&&he&&!Se&&(0,o.jsx)(`div`,{ref:Je,children:yt(S.content)}),ze&&(0,o.jsxs)(`div`,{className:`flex h-full min-h-0`,"data-testid":`file-split`,children:[(0,o.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto border-r border-zinc-200 dark:border-zinc-800`,children:vt??(0,o.jsx)(`div`,{className:`p-4`,children:(0,o.jsx)(se,{code:S.content,path:e.path})})}),(0,o.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto`,"data-testid":`file-split-rendering`,children:he&&!be?(0,o.jsx)(`div`,{className:`prose-chat p-4 text-zinc-700 dark:text-zinc-300`,children:yt(Me)}):(0,o.jsxs)(o.Fragment,{children:[Ie&&(0,o.jsx)(`p`,{"data-testid":`file-split-stale`,className:`flex flex-wrap items-center gap-2 border-b border-amber-300 bg-amber-50 px-3 py-1.5 text-xs text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,children:(0,o.jsxs)(`span`,{children:[`Showing the document as it last stood.`,` `,Re??`The text beside it does not satisfy the schema it declares.`]})}),Le!==void 0&&(0,o.jsxs)(`ul`,{"data-testid":`file-split-issues`,className:`space-y-0.5 border-b border-zinc-200 px-3 py-1.5 text-xs text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:[Le.slice(0,6).map((e,t)=>(0,o.jsxs)(`li`,{children:[(0,o.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),Le.length>6&&(0,o.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,Le.length-6,` more`]})]}),Pe===void 0?(0,o.jsxs)(`p`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,"data-testid":`file-split-nothing`,children:[`Nothing to draw yet. `,Re??`This document does not satisfy the schema it declares.`]}):(0,o.jsx)(Il,{label:`This diagram`,children:(0,o.jsx)(`div`,{className:`p-4`,"data-testid":`file-structured-exchange`,children:(0,o.jsx)(Nl,{envelope:Pe,source:je})})})]})})]}),S&&le===null&&!ze&&!oe&&ye&&!Se&&ve?.status===`valid`&&(0,o.jsx)(Il,{label:`This diagram`,children:(0,o.jsx)(`div`,{className:`mx-auto max-w-5xl p-4`,"data-testid":`file-structured-exchange`,children:(0,o.jsx)(Nl,{envelope:ve.envelope,source:S.content})})}),S&&le===null&&!ze&&!oe&&ve?.status===`invalid`&&(0,o.jsxs)(`div`,{"data-testid":`file-structured-exchange-invalid`,className:`mx-4 mt-4 rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-200`,children:[(0,o.jsx)(`p`,{className:`font-medium`,children:`This declares a structured-exchange document and does not satisfy the schema.`}),(0,o.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-xs`,children:[(S.documentIssues??ve.issues).slice(0,8).map((e,t)=>(0,o.jsxs)(`li`,{children:[(0,o.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),(S.documentIssues??ve.issues).length>8&&(0,o.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,(S.documentIssues??ve.issues).length-8,` more`]})]})]}),S&&le===null&&!ze&&!oe&&ve?.status===`unsupported-version`&&(0,o.jsxs)(`div`,{"data-testid":`file-structured-exchange-unsupported`,className:`mx-4 mt-4 rounded-lg border border-zinc-300 bg-zinc-50 px-3 py-2 text-sm text-zinc-600 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-400`,children:[`This document declares `,(0,o.jsx)(`span`,{className:`font-mono`,children:ve.schema}),`, which this version does not render. Shown as text.`]}),S&&le===null&&!ze&&!oe&&(!he||Se)&&(!ye||Se)&&(0,o.jsx)(`div`,{ref:Je,className:`p-4`,children:(0,o.jsx)(se,{code:S.content,path:e.path,onRendered:dt})})]}),de!==`idle`&&(0,o.jsxs)(`button`,{type:`button`,onClick:xt,"aria-live":`polite`,className:`flex items-center gap-2 border-t border-zinc-200 px-3 py-2 text-left text-sm hover:bg-zinc-50 dark:border-zinc-800 dark:hover:bg-zinc-900`,children:[de===`streaming`?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500`}),(0,o.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:`π is replying…`})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full bg-emerald-500`}),(0,o.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:`π replied`})]}),(0,o.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-500`,children:`show conversation →`})]})]})}function lM(e){return e.split(`
300
+ `)){let t=Rj(e);t&&r.push(t)}return r.length<2||r.some((e,t)=>e.index!==t+1)?null:{heading:t,options:r}}function Bj({request:e,onRespond:t}){let[n,r]=(0,i.useState)(e.method===`editor`?e.prefill??``:``),[a,s]=(0,i.useState)([]),[c,l]=(0,i.useState)(!1),u=(e.method===`select`||e.method===`confirm`||e.method===`input`)&&e.timeout,[d,f]=(0,i.useState)(u?Math.ceil(u/1e3):null),p=zj(e),{heading:m,body:h}=Lj(e.title);function g(){t({id:e.id,cancelled:!0})}function _(e){s(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e].sort((e,t)=>e-t))}function v(){let r=n.trim();t({id:e.id,value:r.length>0?r:a.join(`,`)})}return(0,i.useEffect)(()=>{if(!c)return;let e=setTimeout(()=>l(!1),400);return()=>clearTimeout(e)},[c]),(0,i.useEffect)(()=>{if(d===null)return;if(d<=0){t({id:e.id,cancelled:!0});return}let n=setTimeout(()=>f(e=>e===null?null:e-1),1e3);return()=>clearTimeout(n)},[d,e.id,t]),(0,o.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:()=>l(!0),children:(0,o.jsxs)(`div`,{className:`w-full ${h?`max-w-2xl`:`max-w-md`} rounded-xl border bg-white p-4 shadow-2xl transition-shadow dark:bg-zinc-900 ${c?`border-zinc-400 ring-2 ring-zinc-400/60 dark:border-zinc-500 dark:ring-zinc-500/60`:`border-zinc-200 dark:border-zinc-700`}`,onClick:e=>e.stopPropagation(),children:[(0,o.jsxs)(`div`,{className:`mb-3 flex items-start gap-3`,children:[(0,o.jsx)(`h2`,{className:`flex-1 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:m}),(0,o.jsx)(`button`,{type:`button`,onClick:g,"aria-label":`Refuse to answer`,title:`Refuse to answer`,className:`-mr-1 -mt-1 rounded-md px-1.5 py-0.5 text-sm leading-none text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:`✕`})]}),h&&!p&&(0,o.jsx)(`pre`,{className:`mb-3 max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md bg-zinc-50 p-2 font-mono text-xs text-zinc-600 dark:bg-zinc-950 dark:text-zinc-400`,children:h}),e.method===`select`&&(0,o.jsx)(`div`,{className:`mb-1 flex flex-col gap-1`,children:e.options.map(n=>{let r=Rj(n);return(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:`text-left ${jj}`,children:r?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:r.label}),r.description&&(0,o.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:r.description})]}):n},n)})}),e.method===`confirm`&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`p`,{className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:e.message}),(0,o.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!1}),className:jj,children:`No`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!0}),className:Mj,children:`Yes`})]})]}),p&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`div`,{className:`mb-3 flex flex-col gap-1`,children:p.options.map(e=>(0,o.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:a.includes(e.index),onChange:()=>_(e.index),className:`mt-0.5`}),(0,o.jsxs)(`span`,{children:[(0,o.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:e.label}),e.description&&(0,o.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:e.description})]})]},e.index))}),(0,o.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`…or type your own answer`,onKeyDown:e=>{e.key===`Enter`&&v(),e.key===`Escape`&&g()},className:`mb-1 ${Nj}`}),(0,o.jsx)(`p`,{className:`mb-4 text-xs text-zinc-400 dark:text-zinc-600`,children:`A typed answer replaces the selection above.`}),(0,o.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:g,className:jj,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:v,className:Mj,children:`OK`})]})]}),e.method===`input`&&!p&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`input`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),placeholder:e.placeholder,onKeyDown:r=>{r.key===`Enter`&&t({id:e.id,value:n}),r.key===`Escape`&&g()},className:Pj}),(0,o.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:g,className:jj,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:Mj,children:`OK`})]})]}),e.method===`editor`&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`textarea`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),rows:8,onKeyDown:e=>{e.key===`Escape`&&g()},className:`resize-none font-mono ${Pj}`}),(0,o.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:g,className:jj,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:Mj,children:`OK`})]})]}),d!==null&&(0,o.jsxs)(`p`,{className:`mt-3 text-right text-xs text-zinc-400 dark:text-zinc-600`,children:[`auto-dismiss in `,d,`s`]})]})})}var Vj={info:`border-blue-300 bg-blue-50 text-blue-800 dark:border-blue-900 dark:bg-blue-950/60 dark:text-blue-200`,warning:`border-amber-300 bg-amber-50 text-amber-800 dark:border-amber-900 dark:bg-amber-950/60 dark:text-amber-200`,error:`border-red-300 bg-red-50 text-red-800 dark:border-red-900 dark:bg-red-950/60 dark:text-red-200`},Hj=6e3;function Uj({notification:e,onDismiss:t}){let n=(0,i.useRef)(t);return(0,i.useEffect)(()=>{n.current=t}),(0,i.useEffect)(()=>{let e=setTimeout(()=>n.current(),Hj);return()=>clearTimeout(e)},[e.id]),(0,o.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-lg border px-3 py-2 text-sm shadow-lg ${Vj[e.notifyType??`info`]}`,children:[(0,o.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:e.message}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Dismiss notification`,onClick:()=>n.current(),className:`-mr-1 shrink-0 rounded px-1 leading-5 opacity-60 transition-opacity hover:opacity-100 focus-visible:opacity-100`,children:`×`})]})}function Wj({notifications:e,onDismiss:t}){return e.length===0?null:(0,o.jsx)(`div`,{className:`fixed right-4 top-16 z-40 flex w-80 flex-col gap-2`,children:e.map(e=>(0,o.jsx)(Uj,{notification:e,onDismiss:()=>t(e.id)},e.id))})}var Gj={30:`#3f3f46`,31:`#dc2626`,32:`#16a34a`,33:`#ca8a04`,34:`#2563eb`,35:`#9333ea`,36:`#0891b2`,37:`#71717a`,90:`#a1a1aa`,91:`#ef4444`,92:`#22c55e`,93:`#eab308`,94:`#3b82f6`,95:`#a855f7`,96:`#06b6d4`,97:`#d4d4d8`},Kj=/\u001B\[[0-9;:]*[A-Za-z]|\u001B[()][A-Za-z0-9]|\u001B[A-Za-z]/g;function qj(e,t){let n={...e};for(let e=0;e<t.length;e++){let r=t[e];if(r===0)for(let e of Object.keys(n))delete n[e];else if(r===1)n.bold=!0;else if(r===2)n.dim=!0;else if(r===3)n.italic=!0;else if(r===4)n.underline=!0;else if(r===22)delete n.bold,delete n.dim;else if(r===23)delete n.italic;else if(r===24)delete n.underline;else if(r===39)delete n.color;else if(Gj[r]!==void 0)n.color=Gj[r];else if(r===38){if(t[e+1]===2){let[r,i,a]=[t[e+2],t[e+3],t[e+4]];[r,i,a].every(e=>Number.isFinite(e))&&(n.color=`rgb(${r} ${i} ${a})`),e+=4}else t[e+1]===5&&(e+=2)}}return n}function Jj(e){let t=[],n={},r=0;Kj.lastIndex=0;for(let i=Kj.exec(e);i!==null;i=Kj.exec(e)){i.index>r&&t.push({text:e.slice(r,i.index),...n}),r=i.index+i[0].length;let a=i[0];if(a.endsWith(`m`)){let e=a.slice(2,-1),t=e===``?[0]:e.split(/[;:]/).map(e=>e===``?0:Number(e));n=qj(n,t)}}return r<e.length&&t.push({text:e.slice(r),...n}),t}function Yj(e){return e.replace(Kj,``)}function Xj({line:e}){let t=Jj(e);return(0,o.jsx)(o.Fragment,{children:t.map((e,t)=>(0,o.jsx)(`span`,{style:{...e.color?{color:e.color}:{},...e.bold?{fontWeight:600}:{},...e.dim?{opacity:.7}:{},...e.italic?{fontStyle:`italic`}:{},...e.underline?{textDecoration:`underline`}:{}},children:e.text},t))})}function Zj({widgets:e,placement:t}){let n=Object.entries(e).filter(([,e])=>e.placement===t);return n.length===0?null:(0,o.jsx)(`div`,{className:`mb-2 flex flex-col gap-1`,children:n.map(([e,t])=>(0,o.jsx)(`div`,{className:`whitespace-pre-wrap rounded-md border border-zinc-200 bg-zinc-50 px-3 py-1.5 font-mono text-xs text-zinc-600 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-400`,children:t.lines.map((e,t)=>(0,o.jsx)(`div`,{children:(0,o.jsx)(Xj,{line:e})},t))},e))})}function Qj({text:e,path:t,serverUrl:n,token:r}){let[a,s]=(0,i.useState)(`idle`),[c,l]=(0,i.useState)(null),u=(0,i.useRef)(!1),d=(0,i.useRef)(0);async function f(){if(!(u.current||Date.now()-d.current<750)){u.current=!0,d.current=Date.now(),s(`working`),l(null);try{let{downloadDocx:i}=await Promise.resolve().then(()=>require("./docxExport-CwnVYwBN.cjs"));await i(e,t,{serverUrl:n,token:r}),s(`idle`)}catch(e){s(`failed`),l(e instanceof Error?e.message:String(e))}finally{u.current=!1}}}return(0,o.jsx)(`button`,{type:`button`,onClick:()=>void f(),disabled:a===`working`,title:a===`failed`?`Could not export: ${c??`unknown reason`}`:`Download as a Word document`,"aria-label":`Download as a Word document`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 disabled:opacity-50 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,children:a===`working`?`… exporting`:a===`failed`?`⚠ export failed`:`⤓ word`})}function $j({query:e,onQueryChange:t,matchCount:n,truncated:r=!1,currentIndex:a,searching:s=!1,onNext:c,onPrev:l,onClose:u,inputRef:d}){let f=(0,i.useRef)(null),p=d??f;(0,i.useEffect)(()=>{p.current?.focus(),p.current?.select()},[]);let m=n===0?s?`searching…`:`0/0`:`${a+1}/${n}${r?`+`:``}`;return(0,o.jsxs)(`div`,{role:`search`,"aria-label":`Find in file`,className:`flex items-center gap-2 border-b border-zinc-200 bg-zinc-50 px-3 py-1.5 text-xs dark:border-zinc-800 dark:bg-zinc-900`,children:[(0,o.jsx)(`input`,{ref:p,type:`text`,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.shiftKey?l():c()):e.key===`Escape`&&(e.stopPropagation(),u())},placeholder:`Find in file`,"aria-label":`Find`,className:`min-w-0 flex-1 rounded border border-zinc-300 bg-white px-2 py-1 text-xs text-zinc-700 outline-none focus-visible:ring-1 focus-visible:ring-zinc-400 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-200`}),(0,o.jsx)(`span`,{className:`shrink-0 tabular-nums text-zinc-500 dark:text-zinc-400`,children:m}),(0,o.jsx)(`button`,{type:`button`,onClick:l,disabled:n===0,"aria-label":`Previous match`,title:`Previous match (Shift+Enter)`,className:`shrink-0 rounded px-1.5 py-0.5 text-zinc-500 hover:bg-zinc-200 disabled:opacity-40 dark:text-zinc-400 dark:hover:bg-zinc-800`,children:`‹`}),(0,o.jsx)(`button`,{type:`button`,onClick:c,disabled:n===0,"aria-label":`Next match`,title:`Next match (Enter)`,className:`shrink-0 rounded px-1.5 py-0.5 text-zinc-500 hover:bg-zinc-200 disabled:opacity-40 dark:text-zinc-400 dark:hover:bg-zinc-800`,children:`›`}),(0,o.jsx)(`button`,{type:`button`,onClick:u,"aria-label":`Close find bar`,title:`Close (Esc)`,className:`shrink-0 rounded px-1.5 py-0.5 text-zinc-500 hover:bg-zinc-200 dark:text-zinc-400 dark:hover:bg-zinc-800`,children:`✕`})]})}var eM=(0,i.lazy)(()=>Promise.resolve().then(()=>require("./PdfViewer-DJJoRd17.cjs"))),tM=250,nM=`(min-width: 768px)`;function rM(){let[e,t]=(0,i.useState)(()=>window.matchMedia?.(nM).matches??!0);return(0,i.useEffect)(()=>{let e=window.matchMedia?.(nM);if(e===void 0)return;let n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function iM(e,t){let[n,r]=(0,i.useState)(e);return(0,i.useEffect)(()=>{let n=window.setTimeout(()=>r(e),t);return()=>window.clearTimeout(n)},[e,t]),n}function aM(e){let t=mc(e);return t.status===`valid`?t.envelope:void 0}function oM(e){return/\.(md|markdown)$/i.test(e)}function sM(e,t){return t===void 0?!0:t===null?!1:t===``||e===t||e.startsWith(`${t}/`)}function cM({file:e,writableRoot:a,isStreaming:s,onDirtyChange:c,gitState:l,initialShowGitDiff:u=!1,gitDiff:d,onFetchGitDiff:f,onClearGitDiff:p,inRepository:m,onOpenGitHistory:h,onClose:g,onReload:v,onSave:y,serverUrl:b=``,token:x=null,onImageLoad:ee,onPdfLoad:ne,rawRevision:re=0}){let[ie,ae]=(0,i.useState)(`rendered`),[oe,ce]=(0,i.useState)(u),[le,ue]=(0,i.useState)(e.status===`loaded`&&e.justCreated?{draft:e.content,baseContent:e.content,baseMtimeMs:e.mtimeMs}:null),[de,fe]=(0,i.useState)(`idle`),pe=(0,i.useRef)(null),me=(0,i.useRef)(null),S=e.status===`loaded`?e:null,he=S!==null&&oM(e.path),ge=n.r(e.path),_e=n.i(e.path),ve=(0,i.useMemo)(()=>S===null?void 0:mc(S.content),[S?.content]),ye=ve?.status===`valid`,be=ve?.status===`valid`||ve?.status===`invalid`,xe=be||he,Se=ie===`source`,Ce=rM(),we=sM(e.path,a)&&!_e,Ee=le!==null&&le.draft!==le.baseContent,De=S?.pendingSave!==void 0,ke=le!==null&&S!==null&&S.mtimeMs!==le.baseMtimeMs,Ae=S?.saveError?.conflict===!0||ke,je=le?.draft??S?.content??``,Me=iM(je,tM),Ne=(0,i.useMemo)(()=>S===null?void 0:mc(Me),[Me,S===null]),[Pe,Fe]=(0,i.useState)(()=>e.status===`loaded`?aM(e.content):void 0);(0,i.useEffect)(()=>{Ne?.status===`valid`&&Fe(Ne.envelope)},[Ne]);let Ie=Ne!==void 0&&Ne.status!==`valid`&&Pe!==void 0,Le=Ne?.status===`invalid`?Me===S?.content&&S.documentIssues!==void 0?S.documentIssues:Ne.issues:void 0,Re=Ne?.status===`not-a-document`?Ne.why===`unparseable`?`This is not parseable JSON yet.`:"This no longer declares a structured-exchange `schema`.":Ne?.status===`unsupported-version`?`This declares ${Ne.schema}, which this version does not render.`:void 0,ze=ie===`split`&&xe&&!oe&&S!==null&&Ce,Be=oe||ze?`none`:_e?`pdf`:le===null?S!==null&&!ge?`dom`:`none`:`edit`,[Ve,He]=(0,i.useState)(!1),[Ue,We]=(0,i.useState)(``),[Ge,Ke]=(0,i.useState)(0),qe=(0,i.useRef)(null),Je=(0,i.useRef)(null),Ye=(0,i.useRef)(null),[Xe,Ze]=(0,i.useState)({matchCount:0,currentIndex:-1,searching:!1}),[Qe,$e]=(0,i.useState)([]),[et,tt]=(0,i.useState)(!1),nt=(0,i.useRef)(null),rt=(0,i.useRef)([]),it=(0,i.useRef)(0),at=(0,i.useRef)(``);function ot(e){it.current=e;for(let[t,n]of rt.current.entries())for(let r of n.marks)r.isConnected&&r.classList.toggle(`find-match-current`,t===e);let t=rt.current[e]?.marks;t?.[0]?.isConnected&&t[0].scrollIntoView({block:`center`})}let st=Ve?Ue:``,ct=(0,i.useMemo)(()=>Be===`edit`?r.t(je,st):[],[Be,je,st]);(0,i.useEffect)(()=>{Ve&&Be===`none`&&He(!1)},[Ve,Be]);let[lt,ut]=(0,i.useState)(0),dt=(0,i.useCallback)(()=>ut(e=>e+1),[]);(0,i.useEffect)(()=>{function e(){nt.current?.clear(),nt.current=null,rt.current=[],$e([]),tt(!1)}let t=Je.current;if(Be!==`dom`||st===``||t===null){e();return}nt.current?.clear();let n=r.n(t,st);nt.current=n,rt.current=n.matches,$e(n.matches),tt(n.truncated);let i=st!==at.current;at.current=st;let a=i?0:Math.min(it.current,Math.max(n.matches.length-1,0));return Ke(a),ot(a),e},[Be,st,ie,Se,lt]);function ft(e,t){let n=e[t],r=pe.current;n!==void 0&&r!==null&&(r.focus(),r.setSelectionRange(n.start,n.end),qe.current?.focus())}(0,i.useEffect)(()=>{if(Be!==`edit`||!Ve)return;let e=r.t(je,st);Ke(0),e.length>0&&ft(e,0)},[st,Be,Ve]);function pt(){He(!0)}function mt(){He(!1)}function ht(){if(Be===`pdf`)Ye.current?.findNext();else if(Be===`edit`){if(ct.length===0)return;let e=(Ge+1)%ct.length;Ke(e),ft(ct,e)}else{let e=rt.current.length;if(e===0)return;let t=(it.current+1)%e;Ke(t),ot(t)}}function gt(){if(Be===`pdf`)Ye.current?.findPrevious();else if(Be===`edit`){if(ct.length===0)return;let e=(Ge-1+ct.length)%ct.length;Ke(e),ft(ct,e)}else{let e=rt.current.length;if(e===0)return;let t=(it.current-1+e)%e;Ke(t),ot(t)}}let _t=Be===`pdf`?{matchCount:Xe.matchCount,currentIndex:Xe.currentIndex,truncated:!1,searching:Xe.searching}:Be===`edit`?{matchCount:ct.length,currentIndex:ct.length>0?Math.min(Ge,ct.length-1):-1,truncated:!1,searching:!1}:{matchCount:Qe.length,currentIndex:Qe.length>0?Math.min(Ge,Qe.length-1):-1,truncated:et,searching:!1},vt=le===null?null:(0,o.jsx)(`textarea`,{ref:pe,value:le.draft,onChange:e=>ue({...le,draft:e.target.value}),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),Ee&&!De&&!Ae&&Ct())},spellCheck:!1,className:`h-full w-full resize-none bg-transparent p-4 font-mono text-[13px] leading-relaxed text-zinc-800 outline-none ring-inset focus-visible:ring-1 focus-visible:ring-zinc-300 dark:text-zinc-200 dark:focus-visible:ring-zinc-700`});function yt(r){return(0,o.jsx)(`div`,{className:`prose-chat mx-auto max-w-3xl p-4 text-zinc-700 dark:text-zinc-300`,children:(0,o.jsx)(Tf,{remarkPlugins:[t.n,t.t],rehypePlugins:[cw],components:{pre:Te,a:({href:t,children:r,...i})=>!t||/^[a-z][a-z0-9+.-]*:/i.test(t)?(0,o.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,...i,children:r}):t.startsWith(`#`)?(0,o.jsx)(`a`,{href:t,...i,children:r}):(0,o.jsx)(`a`,{href:t,onClick:r=>{r.preventDefault(),v(n.o(e.path,t))},...i,children:r}),img:({src:t,alt:r,...i})=>{let a=typeof t==`string`&&t!==``&&!/^[a-z][a-z0-9+.-]*:/i.test(t)&&!t.startsWith(`//`)?n.a(b,n.o(e.path,t),x):t;return(0,o.jsx)(`img`,{...i,src:a,alt:r??``,loading:`lazy`,className:`max-w-full rounded-lg`})}},children:t.h(r)})})}function bt(e){ie===`split`&&e!==`split`&&Ee&&!window.confirm(`Discard unsaved changes?`)||(ie===`split`&&e!==`split`&&ue(null),ae(e))}function xt(){Ee&&!window.confirm(`Discard unsaved changes?`)||g()}function St(){S&&ue({draft:S.content,baseContent:S.content,baseMtimeMs:S.mtimeMs})}function Ct(t=!1){!S||le===null||De||(me.current=le.draft,y(e.path,le.draft,le.baseMtimeMs,t))}function wt(){ue(null),v(e.path)}function Tt(){let t=!oe;ce(t),t?f(e.path):p()}return(0,i.useEffect)(()=>{if(le!==null&&S!==null&&me.current!==null&&S.content===me.current&&S.mtimeMs!==le.baseMtimeMs){let e=me.current;me.current=null,le.draft===e?ue(null):ue({...le,baseContent:S.content,baseMtimeMs:S.mtimeMs})}},[S?.mtimeMs]),(0,i.useEffect)(()=>{function e(e){if(e.key===`Escape`){Ve?mt():xt();return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`f`){if(Be===`none`)return;e.preventDefault(),pt()}}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,i.useEffect)(()=>{ze&&we&&le===null&&S!==null&&ue({draft:S.content,baseContent:S.content,baseMtimeMs:S.mtimeMs})},[ze,we,S?.mtimeMs]),(0,i.useEffect)(()=>{fe(s?`streaming`:e=>e===`streaming`?`done`:e)},[s]),(0,i.useEffect)(()=>(c(Ee),()=>c(!1)),[Ee]),(0,i.useEffect)(()=>(u&&f(e.path),()=>p()),[]),(0,o.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[xe&&!oe&&(0,o.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5`,role:`group`,"aria-label":`How to show this document`,children:[[`rendered`,`⚏ rendered`,`Show the rendering`],[`split`,`⇹ split`,`Edit the file beside its rendering`],[`source`,`⌗ source`,`Show the file as written`]].map(([e,t,n])=>(0,o.jsx)(`button`,{type:`button`,onClick:()=>bt(e),"aria-pressed":ie===e,title:n,className:`rounded px-1.5 py-0.5 text-xs ${ie===e?`bg-zinc-100 text-zinc-700 dark:bg-zinc-800 dark:text-zinc-200`:`text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`}`,children:t},e))}),l!==void 0&&le===null&&(0,o.jsx)(`button`,{type:`button`,onClick:Tt,"aria-pressed":oe,title:oe?`Show file content`:`Show uncommitted changes (vs HEAD)`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs ${oe?`bg-amber-100 text-amber-800 dark:bg-amber-950/60 dark:text-amber-300`:`text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`}`,children:`± diff`}),m&&le===null&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>h(e.path),title:`Show this file's history`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,children:`⎇ history`}),(0,o.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-zinc-500 dark:text-zinc-400`,title:e.path,children:[e.path,Ee&&(0,o.jsx)(`span`,{className:`ml-1 text-amber-500`,children:`●`})]}),S&&!ge&&!_e&&!oe&&(0,o.jsx)(Qj,{text:je,path:e.path,serverUrl:b,token:x}),S&&le===null&&(0,o.jsx)(te,{text:S.content}),S&&le===null&&!oe&&we&&(0,o.jsx)(`button`,{type:`button`,onClick:St,className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500 dark:hover:text-zinc-200`,children:`✎ edit`}),S&&le===null&&!we&&(0,o.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,title:`Outside the writable zone`,children:`🔒 read-only`}),le!==null&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>Ct(),disabled:!Ee||De||Ae,className:`shrink-0 rounded border border-emerald-300 px-2 py-0.5 text-xs text-emerald-700 hover:border-emerald-500 disabled:opacity-50 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600`,children:De?`saving…`:`save`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{Ee&&!window.confirm(`Discard unsaved changes?`)||ue(ze&&S!==null?{draft:S.content,baseContent:S.content,baseMtimeMs:S.mtimeMs}:null)},className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-500 hover:border-zinc-400 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500`,children:`cancel`})]}),(0,o.jsx)(`button`,{type:`button`,onClick:xt,title:`Close (Esc)`,"aria-label":`Close file viewer`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),Ve&&Be!==`none`&&(0,o.jsx)($j,{inputRef:qe,query:Ue,onQueryChange:We,matchCount:_t.matchCount,currentIndex:_t.currentIndex,truncated:_t.truncated,searching:_t.searching,onNext:ht,onPrev:gt,onClose:mt}),Ae&&le!==null&&(0,o.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:[(0,o.jsx)(`span`,{className:`min-w-0 flex-1`,children:`File changed on disk since you started editing.`}),(0,o.jsx)(`button`,{type:`button`,onClick:wt,className:`shrink-0 rounded border border-amber-400 px-2 py-0.5 text-xs hover:bg-amber-100 dark:border-amber-800 dark:hover:bg-amber-950/60`,children:`reload (discard my edits)`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>Ct(!0),disabled:De,className:`shrink-0 rounded border border-amber-400 px-2 py-0.5 text-xs hover:bg-amber-100 disabled:opacity-50 dark:border-amber-800 dark:hover:bg-amber-950/60`,children:`overwrite with my version`})]}),le!==null&&S?.saveError&&!S.saveError.conflict&&(0,o.jsx)(`div`,{className:`border-b border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:S.saveError.message}),(0,o.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[oe&&le===null&&(0,o.jsxs)(`div`,{className:`p-4`,children:[d?.path===e.path&&`error`in d&&(0,o.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:d.error}),d?.path===e.path&&`before`in d&&(0,o.jsx)(Oe,{fill:!0,lines:_(d.before,d.after)}),d?.path!==e.path&&(0,o.jsx)(`div`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`loading diff…`})]}),_e&&le===null&&!oe&&(0,o.jsx)(Il,{label:`This PDF`,children:(0,o.jsx)(i.Suspense,{fallback:(0,o.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),children:(0,o.jsx)(eM,{ref:Ye,path:e.path,serverUrl:b,token:x,revision:re,findQuery:Be===`pdf`?st:``,onFindStateChange:Ze,...ne?{onLoaded:ne}:{}})})}),ge&&le===null&&!oe&&(0,o.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,o.jsx)(`img`,{src:n.a(b,e.path,x,re),alt:e.path,onLoad:()=>ee(e.path),className:`max-h-full max-w-full rounded object-contain`})}),e.status===`loading`&&le===null&&!oe&&!ge&&!_e&&(0,o.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),e.status===`error`&&!ge&&!_e&&(0,o.jsx)(`div`,{className:`p-4 text-sm text-red-600 dark:text-red-400`,children:e.message}),le!==null&&!ze&&vt,S&&le===null&&!ze&&!oe&&he&&!Se&&(0,o.jsx)(`div`,{ref:Je,children:yt(S.content)}),ze&&(0,o.jsxs)(`div`,{className:`flex h-full min-h-0`,"data-testid":`file-split`,children:[(0,o.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto border-r border-zinc-200 dark:border-zinc-800`,children:vt??(0,o.jsx)(`div`,{className:`p-4`,children:(0,o.jsx)(se,{code:S.content,path:e.path})})}),(0,o.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto`,"data-testid":`file-split-rendering`,children:he&&!be?(0,o.jsx)(`div`,{className:`prose-chat p-4 text-zinc-700 dark:text-zinc-300`,children:yt(Me)}):(0,o.jsxs)(o.Fragment,{children:[Ie&&(0,o.jsx)(`p`,{"data-testid":`file-split-stale`,className:`flex flex-wrap items-center gap-2 border-b border-amber-300 bg-amber-50 px-3 py-1.5 text-xs text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,children:(0,o.jsxs)(`span`,{children:[`Showing the document as it last stood.`,` `,Re??`The text beside it does not satisfy the schema it declares.`]})}),Le!==void 0&&(0,o.jsxs)(`ul`,{"data-testid":`file-split-issues`,className:`space-y-0.5 border-b border-zinc-200 px-3 py-1.5 text-xs text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:[Le.slice(0,6).map((e,t)=>(0,o.jsxs)(`li`,{children:[(0,o.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),Le.length>6&&(0,o.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,Le.length-6,` more`]})]}),Pe===void 0?(0,o.jsxs)(`p`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,"data-testid":`file-split-nothing`,children:[`Nothing to draw yet. `,Re??`This document does not satisfy the schema it declares.`]}):(0,o.jsx)(Il,{label:`This diagram`,children:(0,o.jsx)(`div`,{className:`p-4`,"data-testid":`file-structured-exchange`,children:(0,o.jsx)(Nl,{envelope:Pe,source:je})})})]})})]}),S&&le===null&&!ze&&!oe&&ye&&!Se&&ve?.status===`valid`&&(0,o.jsx)(Il,{label:`This diagram`,children:(0,o.jsx)(`div`,{className:`mx-auto max-w-5xl p-4`,"data-testid":`file-structured-exchange`,children:(0,o.jsx)(Nl,{envelope:ve.envelope,source:S.content})})}),S&&le===null&&!ze&&!oe&&ve?.status===`invalid`&&(0,o.jsxs)(`div`,{"data-testid":`file-structured-exchange-invalid`,className:`mx-4 mt-4 rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-200`,children:[(0,o.jsx)(`p`,{className:`font-medium`,children:`This declares a structured-exchange document and does not satisfy the schema.`}),(0,o.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-xs`,children:[(S.documentIssues??ve.issues).slice(0,8).map((e,t)=>(0,o.jsxs)(`li`,{children:[(0,o.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),(S.documentIssues??ve.issues).length>8&&(0,o.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,(S.documentIssues??ve.issues).length-8,` more`]})]})]}),S&&le===null&&!ze&&!oe&&ve?.status===`unsupported-version`&&(0,o.jsxs)(`div`,{"data-testid":`file-structured-exchange-unsupported`,className:`mx-4 mt-4 rounded-lg border border-zinc-300 bg-zinc-50 px-3 py-2 text-sm text-zinc-600 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-400`,children:[`This document declares `,(0,o.jsx)(`span`,{className:`font-mono`,children:ve.schema}),`, which this version does not render. Shown as text.`]}),S&&le===null&&!ze&&!oe&&(!he||Se)&&(!ye||Se)&&(0,o.jsx)(`div`,{ref:Je,className:`p-4`,children:(0,o.jsx)(se,{code:S.content,path:e.path,onRendered:dt})})]}),de!==`idle`&&(0,o.jsxs)(`button`,{type:`button`,onClick:xt,"aria-live":`polite`,className:`flex items-center gap-2 border-t border-zinc-200 px-3 py-2 text-left text-sm hover:bg-zinc-50 dark:border-zinc-800 dark:hover:bg-zinc-900`,children:[de===`streaming`?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500`}),(0,o.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:`π is replying…`})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full bg-emerald-500`}),(0,o.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:`π replied`})]}),(0,o.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-500`,children:`show conversation →`})]})]})}function lM(e){return e.split(`
301
301
  `).map(e=>e.startsWith(`diff --git `)?{kind:`file`,text:e.slice(11)}:e.startsWith(`@@`)||e.startsWith(`+++`)||e.startsWith(`---`)||e.startsWith(`index `)?{kind:`hunk`,text:e}:e.startsWith(`+`)?{kind:`add`,text:e.slice(1)}:e.startsWith(`-`)?{kind:`del`,text:e.slice(1)}:{kind:`context`,text:e.startsWith(` `)?e.slice(1):e})}function uM({show:e,onClose:t}){return(0,i.useEffect)(()=>{function e(e){e.key===`Escape`&&(e.stopImmediatePropagation(),t())}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]),(0,o.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,o.jsx)(`span`,{className:`font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,12)}),(0,o.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`commit diff`}),(0,o.jsx)(`button`,{type:`button`,onClick:t,title:`Close (Esc)`,"aria-label":`Close commit diff`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),e.truncated&&(0,o.jsx)(`div`,{className:`border-b border-amber-300 bg-amber-50 px-3 py-1.5 text-xs text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:`Patch truncated — showing the first 256 KiB.`}),(0,o.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto p-3 font-mono text-xs leading-relaxed`,children:lM(e.patch).map((e,t)=>(0,o.jsxs)(`div`,{className:e.kind===`file`?`mt-3 border-t border-zinc-200 pt-2 font-bold text-zinc-700 first:mt-0 first:border-t-0 first:pt-0 dark:border-zinc-800 dark:text-zinc-200`:e.kind===`hunk`?`text-sky-600 dark:text-sky-400`:e.kind===`add`?`bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300`:e.kind===`del`?`bg-red-50 text-red-700 dark:bg-red-950/40 dark:text-red-300`:`text-zinc-500 dark:text-zinc-500`,children:[e.kind===`add`?`+ `:e.kind===`del`?`− `:``,e.text||` `]},t))})]})}var dM=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`],fM=`worktree`,pM={defaultWidth:288,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.files-sidebar-width.v1`},mM={defaultWidth:416,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.history-list-width.v1`};function hM(e,t){return Number.isFinite(e)?Math.min(t.maxWidth,Math.max(t.minWidth,Math.round(e))):t.defaultWidth}function gM(e,t){return e===null||e.trim()===``?t.defaultWidth:hM(Number(e),t)}function _M(e,t){try{return gM((t??window.localStorage).getItem(e.storageKey),e)}catch{return e.defaultWidth}}function vM(e,t,n){try{(n??window.localStorage).setItem(t.storageKey,String(hM(e,t)))}catch{}}function yM(e){let[t,n]=(0,i.useState)(()=>_M(e)),r=(0,i.useRef)(t),a=(0,i.useRef)(null),o=(0,i.useCallback)(t=>{let i=hM(t,e);return r.current=i,n(i),i},[e]),s=(0,i.useCallback)(()=>{a.current!==null&&(a.current=null,vM(r.current,e))},[e]);return{width:t,separatorProps:{onPointerDown:e=>{e.isPrimary!==!1&&(e.button??0)===0&&(e.preventDefault(),e.currentTarget.setPointerCapture?.(e.pointerId),a.current={pointerId:e.pointerId,startX:e.clientX,startWidth:r.current})},onPointerMove:e=>{let t=a.current;t!==null&&t.pointerId===e.pointerId&&o(t.startWidth+e.clientX-t.startX)},onPointerUp:e=>{a.current?.pointerId===e.pointerId&&s()},onPointerCancel:e=>{let t=a.current;t!==null&&t.pointerId===e.pointerId&&(a.current=null,o(t.startWidth))},onLostPointerCapture:s,onKeyDown:t=>{let n=null;t.key===`ArrowLeft`?n=r.current-e.keyboardStep:t.key===`ArrowRight`?n=r.current+e.keyboardStep:t.key===`Home`&&(n=e.defaultWidth),n!==null&&(t.preventDefault(),vM(o(n),e))}}}}function bM({label:e,width:t,config:n,separatorProps:r,className:i=``}){return(0,o.jsx)(`div`,{...r,role:`separator`,"aria-label":e,"aria-orientation":`vertical`,"aria-valuemin":n.minWidth,"aria-valuemax":n.maxWidth,"aria-valuenow":t,tabIndex:0,title:e,className:`group absolute inset-y-0 -right-1 z-20 w-2 cursor-col-resize touch-none outline-none ${i}`,children:(0,o.jsx)(`span`,{className:`pointer-events-none absolute inset-y-0 left-1/2 w-px bg-transparent transition-colors group-hover:bg-blue-400 group-focus-visible:bg-blue-500 group-active:bg-blue-500 dark:group-hover:bg-blue-500`})})}var xM=`#10b981`,SM=[`#8b5cf6`,`#f59e0b`,`#0ea5e9`,`#f43f5e`,`#14b8a6`,`#d946ef`];function CM(e){return e===0?xM:SM[(e-1)%SM.length]}function wM(e){return SM[e%SM.length]}function TM(e){return e*14+7+1}function EM(e){return e*14+2}function DM({row:e,laneCount:t,colorOf:n=CM}){let r=EM(t),i=TM(e.lane),a=e.highlight?xM:n(e.lane),s=e.dashed?`3 3`:void 0;return(0,o.jsxs)(`svg`,{width:r,height:36,viewBox:`0 0 ${r} 36`,"aria-hidden":!0,className:`shrink-0`,children:[e.through.map(e=>(0,o.jsx)(`line`,{x1:TM(e),y1:0,x2:TM(e),y2:36,stroke:n(e),strokeWidth:2,opacity:.55},e)),e.lineAbove&&(0,o.jsx)(`line`,{x1:i,y1:0,x2:i,y2:18,stroke:a,strokeWidth:2,strokeDasharray:s}),e.lineBelow&&(0,o.jsx)(`line`,{x1:i,y1:18,x2:i,y2:36,stroke:a,strokeWidth:2,strokeDasharray:s}),e.forkTo.map(e=>(0,o.jsx)(`path`,{d:`M ${i} 18 C ${i} 36, ${TM(e)} 18, ${TM(e)} 36`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`fork-${e}`)),(e.mergeFrom??[]).map(e=>(0,o.jsx)(`path`,{d:`M ${i} 18 C ${i} 0, ${TM(e)} 18, ${TM(e)} 0`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`merge-${e}`)),e.emphasis===`current`?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`circle`,{cx:i,cy:18,r:6,fill:`none`,stroke:a,strokeWidth:2}),(0,o.jsx)(`circle`,{cx:i,cy:18,r:2.5,fill:a})]}):(0,o.jsx)(`circle`,{cx:i,cy:18,r:4,fill:e.emphasis===`filled`?a:`var(--tree-off, #d4d4d8)`,stroke:a,strokeWidth:e.emphasis===`filled`?0:1.5})]})}function OM(e,t={}){let n=[],r=[],i=0,a=()=>{let e=r.indexOf(null);return e===-1?(r.push(null),i=Math.max(i,r.length),r.length-1):e};for(let t of e){let e=r.reduce((e,n,r)=>n===t.sha?[...e,r]:e,[]),o=e[0]??a(),s=e.slice(1);for(let e of s)r[e]=null;i=Math.max(i,o+1);let[c,...l]=t.parents;r[o]=c??null;let u=l.map(e=>{let t=a();return r[t]=e,t});n.push({rev:t.sha,path:t.path,entry:t,lane:o,through:r.reduce((e,t,n)=>t!==null&&n!==o&&!u.includes(n)?[...e,n]:e,[]),forkTo:u,mergeFrom:s,lineAbove:!0,lineBelow:t.parents.length>0,emphasis:`filled`})}let o=n[0];return n.unshift({rev:fM,path:o?.path??``,lane:o?.lane??0,through:o?.through??[],forkTo:[],mergeFrom:[],lineAbove:!1,lineBelow:n.length>0,emphasis:`current`,dashed:!t.dirty}),n[1]&&(n[1].lineAbove=!0),{rows:n,laneCount:Math.max(i,1)}}var kM=20;function AM(e){let t=(Date.now()-new Date(e).getTime())/1e3;return t<90?`now`:t<3600?`${Math.round(t/60)}m ago`:t<86400?`${Math.round(t/3600)}h ago`:`${Math.round(t/86400)}d ago`}function jM(e){return e.rev===`worktree`?`working tree`:e.rev.slice(0,7)}function MM(e,t){return e!==null&&t!==null&&e.rev===t.rev&&e.path===t.path}function NM(e){return{rev:e.rev,path:e.path}}function PM({history:e,diff:t,dirty:n,onFetchDiff:r,onClearDiff:a,onClose:s}){let[c,l]=(0,i.useState)({base:null,target:null}),{base:u,target:d}=c,[f,p]=(0,i.useState)(0),m=(0,i.useRef)([]),h=yM(mM),{rows:g,laneCount:_}=(0,i.useMemo)(()=>OM(e.entries,{dirty:n}),[e.entries,n]),v=(0,i.useRef)({onFetchDiff:r,onClose:s});v.current={onFetchDiff:r,onClose:s},(0,i.useEffect)(()=>{function e(e){e.key===`Escape`&&(e.stopImmediatePropagation(),v.current.onClose())}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[]),(0,i.useEffect)(()=>{u===null||d===null||MM(u,d)||v.current.onFetchDiff(u,d)},[u,d]);let y=(0,i.useCallback)((e,t)=>{let n=NM(e);l(r=>{if(t===`base`)return{base:n,target:MM(n,r.target)?r.base:r.target};if(t===`target`)return{base:MM(n,r.base)?r.target:r.base,target:n};if(r.base===null&&r.target===null){let t=e.entry?.parents[0],r=t===void 0?void 0:g.find(e=>e.rev===t);return{base:r?NM(r):null,target:n}}return{base:MM(n,r.base)?r.target:r.base,target:n}})},[g]),b=(0,i.useCallback)(()=>{l({base:null,target:null}),a()},[a]),x=(0,i.useCallback)(()=>l(e=>({base:e.target,target:e.base})),[]),ee=(0,i.useCallback)(e=>{p(t=>{let n=Math.max(0,Math.min(g.length-1,t+e));return m.current[n]?.focus(),n})},[g.length]),te=e=>{let t=NM(e);return MM(t,u)?`base`:MM(t,d)?`target`:null},ne=g.findIndex(e=>MM(NM(e),u)),re=g.findIndex(e=>MM(NM(e),d)),ie=ne>=0&&re>=0?{top:Math.min(ne,re)*36+18,height:Math.abs(re-ne)*36}:null;return(0,o.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,o.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-zinc-500 dark:text-zinc-400`,title:e.path,children:e.path}),u!==null&&d!==null&&(0,o.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-zinc-500 dark:text-zinc-400`,"aria-label":`Comparing ${jM(u)} to ${jM(d)}`,children:[(0,o.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:jM(u)}),` → `,(0,o.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:jM(d)})]}),u!==null&&d!==null&&(0,o.jsx)(`button`,{type:`button`,onClick:x,title:`Compare the other way round`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:`⇄ swap`}),(u!==null||d!==null)&&(0,o.jsx)(`button`,{type:`button`,onClick:b,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:`clear`}),(0,o.jsx)(`button`,{type:`button`,onClick:s,title:`Close (Esc)`,"aria-label":`Close file history`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),(0,o.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,o.jsxs)(`div`,{role:`region`,"aria-label":`Commit history`,style:{"--history-list-width":`${h.width}px`},className:`relative flex max-h-[40%] w-full shrink-0 flex-col border-b border-zinc-200 md:max-h-none md:w-[var(--history-list-width)] md:border-b-0 md:border-r dark:border-zinc-800`,children:[(0,o.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),ee(1)):e.key===`ArrowUp`&&(e.preventDefault(),ee(-1))},children:[e.status===`loading`&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`Reading history…`}),e.status===`error`&&(0,o.jsx)(`div`,{className:`m-3 rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:e.error}),e.status===`loaded`&&e.entries.length===0&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`No commits touch this file yet.`}),e.status===`loaded`&&e.entries.length>0&&(0,o.jsxs)(`div`,{className:`relative`,role:`group`,"aria-label":`Commits`,children:[ie&&(0,o.jsx)(FM,{top:ie.top,height:ie.height,baseFirst:ne<re}),g.map((e,t)=>(0,o.jsx)(RM,{ref:e=>{m.current[t]=e},row:e,laneCount:_,role:te(e),isFocused:t===f,onSelect:t=>y(e,t),onFocus:()=>p(t)},e.rev))]})]}),(0,o.jsx)(bM,{label:`Resize History commit list`,width:h.width,config:mM,separatorProps:h.separatorProps,className:`hidden md:block`})]}),(0,o.jsx)(`div`,{role:`region`,"aria-label":`History diff`,className:`min-h-0 min-w-0 flex-1 overflow-auto p-3`,children:(0,o.jsx)(zM,{diff:t,base:u,target:d})})]})]})}function FM({top:e,height:t,baseFirst:n}){return(0,o.jsxs)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute left-0 z-10 motion-safe:transition-all motion-safe:duration-150 motion-safe:ease-out`,style:{top:e,height:t,width:kM},children:[(0,o.jsx)(`div`,{className:`absolute inset-y-0 left-2 w-px bg-zinc-400 dark:bg-zinc-500`}),(0,o.jsx)(IM,{label:n?`base`:`target`,className:`top-0`}),(0,o.jsx)(IM,{label:n?`target`:`base`,className:`bottom-0`})]})}function IM({label:e,className:t}){return(0,o.jsx)(`div`,{className:`absolute left-2 flex h-px w-2.5 items-center bg-zinc-400 dark:bg-zinc-500 ${t}`,children:(0,o.jsx)(`span`,{className:`absolute -left-1 -top-1.5 rotate-180 text-[9px] leading-none text-zinc-500 [writing-mode:vertical-rl] dark:text-zinc-400`,children:e})})}var LM=`shrink-0 rounded px-1 py-0.5 text-[10px] text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 aria-disabled:cursor-default aria-disabled:opacity-30 dark:text-zinc-500 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`;function RM({row:e,laneCount:t,role:n,isFocused:r,onSelect:i,onFocus:a,ref:s}){let c=e.entry,l=c?`${c.sha.slice(0,7)} ${c.subject}`:`Working tree`;return(0,o.jsxs)(`div`,{ref:s,role:`button`,tabIndex:r?0:-1,"aria-label":l,"aria-current":n===null?void 0:`true`,onFocus:a,onClick:()=>i(),onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `?(e.preventDefault(),i()):e.key===`b`?i(`base`):e.key===`t`&&i(`target`))},style:{height:36,paddingLeft:kM},className:`group flex cursor-pointer items-center gap-2 pr-2 focus:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800/70 ${n===null?``:`bg-zinc-100 dark:bg-zinc-800/60`}`,children:[(0,o.jsx)(DM,{row:e,laneCount:t}),c?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:c.sha.slice(0,7)}),(0,o.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-700 dark:text-zinc-300`,title:c.subject,children:c.subject}),(0,o.jsxs)(`span`,{className:`shrink-0 text-[10px] text-zinc-400 dark:text-zinc-600`,children:[c.author,` · `,AM(c.date)]}),(0,o.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums`,"aria-label":`${c.added} lines added, ${c.deleted} removed`,children:[(0,o.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-500`,children:[`+`,c.added]}),` `,(0,o.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,c.deleted]})]})]}):(0,o.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`working tree`}),(0,o.jsxs)(`span`,{className:`flex shrink-0 gap-0.5`,children:[(0,o.jsx)(`button`,{type:`button`,title:n===`target`?`Make this the base (swaps the two)`:`Compare from this version`,onClick:e=>{e.stopPropagation(),i(`base`)},className:LM,children:`base`}),(0,o.jsx)(`button`,{type:`button`,title:n===`base`?`Make this the target (swaps the two)`:`Compare to this version`,onClick:e=>{e.stopPropagation(),i(`target`)},className:LM,children:`target`})]})]})}function zM({diff:e,base:t,target:n}){return t===null&&n===null?(0,o.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Pick a commit to see what changed.`}):t===null||n===null?(0,o.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Now pick the version to compare it against.`}):e?.status===`error`?(0,o.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:e.error}):e===null?(0,o.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Loading…`}):e.status===`loaded`&&e.beforeText===e.afterText?(0,o.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`These two versions are identical.`}):e.status===`loaded`&&g(e.beforeText,e.afterText)?(0,o.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`These two versions differ only in their line endings.`}):(0,o.jsx)(`div`,{className:e.status===`loading`?`opacity-40`:void 0,children:(0,o.jsx)(Oe,{fill:!0,lines:_(e.beforeText,e.afterText)})})}function BM(e){let t=e.filter(e=>!e.sideOf).flatMap(t=>[t,...e.filter(e=>e.sideOf===t.root)]);return[...t,...e.filter(e=>!t.includes(e))]}var VM={stopped:`stopped`,starting:`starting…`,idle:`idle`,working:`working`,waiting:`waiting for you`,"ready-for-review":`ready for review`};function HM({activity:e}){switch(e){case`stopped`:return(0,o.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full border border-dashed border-zinc-400 dark:border-zinc-600`});case`starting`:return(0,o.jsx)(`svg`,{className:`h-2.5 w-2.5 shrink-0 animate-spin text-zinc-500 dark:text-zinc-400`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3.5`,strokeLinecap:`round`,children:(0,o.jsx)(`path`,{d:`M12 3a9 9 0 0 1 9 9`})});case`working`:return(0,o.jsxs)(`span`,{className:`relative flex h-2 w-2 shrink-0 items-center justify-center`,children:[(0,o.jsx)(`span`,{className:`absolute h-2 w-2 animate-ping rounded-full bg-blue-700 opacity-60 dark:bg-blue-400`}),(0,o.jsx)(`span`,{className:`relative h-2 w-2 rounded-full bg-blue-700 dark:bg-blue-400`})]});case`waiting`:return(0,o.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-amber-500`});case`ready-for-review`:return(0,o.jsx)(`span`,{className:`h-2 w-2 shrink-0 rotate-45 rounded-[1px] border-2 border-violet-600 bg-violet-100 dark:border-violet-400 dark:bg-violet-950`});default:return(0,o.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-zinc-400 dark:bg-zinc-600`})}}function UM({className:e}){return(0,o.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,o.jsx)(`path`,{d:`M12 6v7`}),(0,o.jsx)(`path`,{d:`M12 18h.01`})]})}function WM({className:e}){return(0,o.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,o.jsx)(`path`,{d:`M7 3h10v18H7z`}),(0,o.jsx)(`path`,{d:`m9.5 12 1.7 1.7 3.5-3.7`})]})}function GM(e){let{workspace:t,workspaces:n,locked:r}=e,[a,s]=(0,i.useState)(!1),c=(0,i.useRef)(null);if((0,i.useEffect)(()=>{if(!a)return;let e=e=>{Cj(e,c.current)||s(!1)},t=e=>{e.key===`Escape`&&s(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a]),r||!t)return null;let l=n.filter(e=>lA(e)!==lA(t)),u=n.filter(e=>!e.sideOf).length,d=n.filter(e=>e.needsAttention);return(0,o.jsxs)(`div`,{ref:c,className:`relative`,children:[(0,o.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),"aria-expanded":a,"aria-haspopup":`menu`,title:`Project: ${t.name} (${VM[t.activity]})`,className:`flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs ${d.length>0?`border-amber-500 bg-amber-50 text-zinc-700 dark:bg-amber-950/40 dark:text-zinc-200`:`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`}`,children:[(0,o.jsx)(HM,{activity:t.activity}),(0,o.jsx)(`span`,{className:`font-medium`,children:t.name}),d.length>0?(0,o.jsxs)(`span`,{className:`flex items-center gap-1 text-amber-600 dark:text-amber-500`,children:[(0,o.jsx)(UM,{className:`h-3 w-3`}),(0,o.jsx)(`span`,{className:`font-semibold`,children:d.length})]}):l.some(e=>e.activity===`working`)&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{className:`h-3 w-px bg-zinc-300 dark:bg-zinc-600`}),(0,o.jsx)(`span`,{className:`flex items-center gap-1`,children:l.map(e=>e.activity===`working`?(0,o.jsxs)(`span`,{className:`relative flex h-1.5 w-1.5 items-center justify-center`,children:[(0,o.jsx)(`span`,{className:`absolute h-1.5 w-1.5 animate-ping rounded-full bg-blue-700 opacity-60 dark:bg-blue-400`}),(0,o.jsx)(`span`,{className:`relative h-1.5 w-1.5 rounded-full bg-blue-700 dark:bg-blue-400`})]},lA(e)):(0,o.jsx)(`span`,{className:`h-1 w-1 rounded-full bg-zinc-300 dark:bg-zinc-600`},lA(e)))})]}),(0,o.jsx)(`svg`,{className:`h-3 w-3 text-zinc-500`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,o.jsx)(`path`,{d:`m6 9 6 6 6-6`})})]}),a&&(0,o.jsxs)(`div`,{role:`menu`,className:`absolute left-0 top-full z-40 mt-1 w-87 rounded-md border border-zinc-300 bg-white p-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:[BM(n).map(n=>{let r=lA(n),i=r===lA(t),a=n.sideOf!==void 0;return(0,o.jsxs)(`div`,{"data-testid":a?`side-session-row`:`project-row`,className:`group flex items-center gap-2.5 rounded-md py-2 pr-2.5 ${a?`pl-7`:`pl-2.5`} ${i?`bg-zinc-100 dark:bg-zinc-800`:`hover:bg-zinc-50 dark:hover:bg-zinc-800/50`}`,children:[(0,o.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{s(!1),i||(a?e.onSwitch(n.root,n.id):e.onSwitch(n.root))},className:`flex min-w-0 flex-1 items-center gap-2.5 text-left`,children:[(0,o.jsx)(HM,{activity:n.activity}),(0,o.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,o.jsx)(`span`,{className:`truncate text-[13px] ${i?`font-semibold text-zinc-900 dark:text-zinc-100`:`font-medium text-zinc-900 dark:text-zinc-100`}`,children:a?n.label??n.name:n.name}),!a&&(0,o.jsx)(`span`,{className:`truncate font-mono text-[11px] text-zinc-400 dark:text-zinc-500`,children:n.root})]})]}),(0,o.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[n.needsAttention?(0,o.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] font-medium ${n.activity===`ready-for-review`?`text-violet-700 dark:text-violet-400`:`text-amber-600 dark:text-amber-500`}`,children:[n.activity===`ready-for-review`?(0,o.jsx)(WM,{className:`h-3 w-3`}):(0,o.jsx)(UM,{className:`h-3 w-3`}),VM[n.activity]]}):(0,o.jsx)(`span`,{className:`text-[11px] ${n.activity===`working`?`text-blue-700 dark:text-blue-400`:`text-zinc-400 dark:text-zinc-500`}`,children:VM[n.activity]}),!a&&e.onOpenSide&&(0,o.jsx)(`button`,{type:`button`,title:`New side session on ${n.name}`,"aria-label":`New side session on ${n.name}`,onClick:t=>{t.stopPropagation(),s(!1),e.onOpenSide?.(n.root)},className:`flex h-5 w-5 items-center justify-center rounded border border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-800 dark:border-zinc-600 dark:text-zinc-400 dark:hover:border-zinc-500 dark:hover:text-zinc-100`,children:(0,o.jsxs)(`svg`,{className:`h-2.5 w-2.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,children:[(0,o.jsx)(`path`,{d:`M12 5v14`}),(0,o.jsx)(`path`,{d:`M5 12h14`})]})}),(a||u>1)&&(0,o.jsx)(`button`,{type:`button`,title:`Close ${a?n.label??n.name:n.name}`,"aria-label":`Close ${a?n.label??n.name:n.name}`,onClick:t=>{t.stopPropagation(),a?e.onClose(n.root,n.id):e.onClose(n.root)},className:`flex h-5 w-5 items-center justify-center rounded border border-transparent text-zinc-400 opacity-0 group-hover:border-zinc-300 group-hover:opacity-100 hover:text-zinc-700 dark:group-hover:border-zinc-600 dark:hover:text-zinc-200`,children:(0,o.jsxs)(`svg`,{className:`h-2.5 w-2.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,o.jsx)(`path`,{d:`M18 6 6 18`}),(0,o.jsx)(`path`,{d:`m6 6 12 12`})]})})]})]},r)}),(0,o.jsx)(`div`,{className:`my-1 h-px bg-zinc-200 dark:bg-zinc-700`}),(0,o.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{s(!1),e.onOpen()},className:`flex w-full items-center gap-2.5 rounded-md px-2.5 py-2 text-left text-[13px] text-zinc-700 hover:bg-zinc-50 dark:text-zinc-300 dark:hover:bg-zinc-800/50`,children:[(0,o.jsxs)(`svg`,{className:`h-3.5 w-3.5 text-zinc-500`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,o.jsx)(`path`,{d:`M12 5v14`}),(0,o.jsx)(`path`,{d:`M5 12h14`})]}),`Open a project…`]})]})]})}function KM({label:e,browse:t,onBrowse:n,onSelect:r,onCancel:a}){let s=t?.path??`/`,c=t?.entries??[],l=t?.status===`loading`,[u,d]=(0,i.useState)(s);return(0,i.useEffect)(()=>{d(s)},[s]),(0,o.jsxs)(`div`,{className:`rounded-md border border-zinc-300 p-2 dark:border-zinc-700`,"data-testid":`server-path-picker`,children:[(0,o.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold text-zinc-600 dark:text-zinc-300`,children:e}),(0,o.jsx)(`button`,{type:`button`,onClick:a,className:`text-xs text-zinc-500 hover:text-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200`,children:`Cancel`})]}),(0,o.jsxs)(`form`,{className:`mb-2 flex gap-1`,onSubmit:e=>{e.preventDefault();let t=u.trim();t&&n(t)},children:[(0,o.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),d(s))},spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-label":`Current directory`,"data-testid":`picker-path`,className:`min-w-0 flex-1 rounded border border-zinc-300 px-2 py-1 font-mono text-xs text-zinc-700 focus:border-zinc-500 focus:outline-none dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200`}),(0,o.jsx)(`button`,{type:`submit`,disabled:u.trim()===``||u===s,className:`rounded border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-40 dark:border-zinc-700 dark:text-zinc-300`,children:`Go`})]}),t?.status===`error`&&(0,o.jsx)(`p`,{role:`alert`,className:`mb-2 text-xs text-red-600 dark:text-red-400`,children:t.error}),(0,o.jsxs)(`div`,{className:`mb-2 flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,disabled:!t?.parent,onClick:()=>t?.parent&&n(t.parent),className:`rounded border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-40 dark:border-zinc-700 dark:text-zinc-300`,children:`Up`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>r(s),className:`rounded bg-zinc-800 px-2 py-1 text-xs font-medium text-white hover:bg-zinc-700 dark:bg-zinc-200 dark:text-zinc-900`,children:`Use this directory`})]}),(0,o.jsxs)(`ul`,{className:`max-h-40 overflow-y-auto`,children:[l&&c.length===0&&(0,o.jsx)(`li`,{className:`px-2 py-1 text-xs text-zinc-400`,children:`Loading…`}),!l&&c.length===0&&t?.status!==`error`&&(0,o.jsx)(`li`,{className:`px-2 py-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`No subdirectories`}),c.map(e=>(0,o.jsx)(`li`,{children:(0,o.jsxs)(`button`,{type:`button`,onClick:()=>n(e.path),className:`w-full truncate rounded px-2 py-1 text-left font-mono text-xs text-zinc-600 hover:bg-zinc-100 dark:text-zinc-300 dark:hover:bg-zinc-800`,title:e.path,children:[e.name,e.name.endsWith(`:`)?`\\`:`/`]})},e.path))]})]})}function qM(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function JM(e){let{sandbox:t,applyState:n,blocked:r=!1,onCloseBrowser:a}=e,[s,c]=(0,i.useState)(!1),l=(0,i.useRef)(!1);if((0,i.useEffect)(()=>{r&&s&&(l.current=!1,c(!1))},[r,s]),(0,i.useEffect)(()=>{if(l.current&&n?.status!==`applying`){if(n?.status===`error`){l.current=!1;return}l.current=!1,c(!1),a()}},[n,a]),!t)return(0,o.jsx)(`span`,{className:`rounded-md border border-dashed border-zinc-300 px-2 py-1 text-xs text-zinc-400 dark:border-zinc-700 dark:text-zinc-500`,title:`This server runs without a sandbox, so there is no root to move`,children:`No sandbox`});let u=t.locks?.root===!0,d=qM(t.root);return(0,o.jsxs)(`div`,{className:`relative`,children:[(0,o.jsxs)(`button`,{type:`button`,disabled:u,"aria-label":u?`Sandbox root: ${t.root} (locked)`:`Sandbox root: ${t.root}`,title:u?`${t.root} — locked by the server's configuration`:t.root,onClick:()=>{e.onOpened(),c(!0),e.onBrowse(t.root)},className:`flex max-w-[14rem] items-center gap-1.5 rounded-md border px-2 py-1 text-xs ${u?`cursor-not-allowed border-zinc-200 text-zinc-400 dark:border-zinc-800 dark:text-zinc-500`:`border-zinc-300 text-zinc-600 hover:border-zinc-400 hover:text-zinc-800 dark:border-zinc-700 dark:text-zinc-300 dark:hover:border-zinc-500 dark:hover:text-zinc-100`}`,children:[(0,o.jsx)(`span`,{className:`truncate font-mono`,children:d}),u?(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):(0,o.jsx)(`span`,{"aria-hidden":`true`,children:`▾`})]}),s&&!r&&(0,o.jsxs)(`div`,{className:`absolute left-0 top-full z-20 mt-1 w-[380px] rounded-lg border border-zinc-200 bg-white p-2 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[n?.status===`error`&&(0,o.jsx)(`p`,{role:`alert`,className:`mb-2 text-xs text-red-600 dark:text-red-400`,children:n.message}),(0,o.jsx)(KM,{label:`Choose the sandbox root`,browse:e.browse,onBrowse:e.onBrowse,onSelect:t=>{l.current=!0,e.onSelect(t)},onCancel:()=>{l.current=!1,c(!1),a()}})]})]})}function YM(e){let t=(Date.now()-new Date(e).getTime())/1e3;return t<90?`now`:t<3600?`${Math.round(t/60)}m ago`:t<86400?`${Math.round(t/3600)}h ago`:`${Math.round(t/86400)}d ago`}function XM(e){return e.slice(e.lastIndexOf(`/`)+1)}function ZM({status:e,selected:t,log:n,onFetchLog:r,onShowCommit:a}){let[s,c]=(0,i.useState)(!1),l=wj(()=>c(!1)),u=e?.repos??[],d=(t===null?null:JA(u,t))??(t===null&&u.length===1?u[0]:null),f=d&&(d.ahead>0||d.behind>0)?` ${d.ahead>0?`↑${d.ahead}`:``}${d.behind>0?`↓${d.behind}`:``}`:``,p=u.length>1&&d!==null&&d.repo!==``?`${XM(d.repo)} `:``,m=e===null?`…`:d?.branch??`—`,h=d!==null&&n?.repo===d.repo?n.entries:null;return(0,i.useEffect)(()=>{s&&d!==null&&n?.repo!==d.repo&&r(d.repo)},[s,d?.repo,r]),(0,o.jsxs)(`div`,{className:`relative`,ref:l,children:[(0,o.jsxs)(`button`,{type:`button`,disabled:d===null,onClick:()=>{d!==null&&(c(!s),s||r(d.repo))},title:d===null?`no repository selected`:`git history — ${d.repo===``?`this project`:d.repo}`,className:`rounded-md border border-zinc-300 px-2 py-1 font-mono text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 disabled:cursor-default disabled:hover:border-zinc-300 disabled:hover:text-zinc-500 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200 dark:disabled:hover:border-zinc-800 dark:disabled:hover:text-zinc-400`,children:[p,`⎇ `,m,f]}),s&&d!==null&&(0,o.jsxs)(`div`,{className:`absolute left-0 top-full z-20 mt-1 max-h-96 w-[26rem] max-w-[80vw] overflow-y-auto rounded-lg border border-zinc-200 bg-white py-1 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[h===null&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),h?.length===0&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no commits`}),h?.map(e=>(0,o.jsxs)(`button`,{type:`button`,onClick:()=>{a(d.repo,e.sha),c(!1)},className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:[(0,o.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,7)}),(0,o.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-zinc-700 dark:text-zinc-300`,title:e.subject,children:e.subject}),(0,o.jsxs)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:[e.author,` · `,YM(e.date)]})]},e.sha))]})]})}function QM(e){if(e.installed===void 0)return`not installed`;if(e.restartNeeded)return`${e.installed} installed — restart to use it`;if(e.pinned!==void 0)return`${e.installed}, pinned`;let t=e.check;if(!t)return e.installed;switch(t.state){case`checking`:return`${e.installed}, checking…`;case`newer`:return`${e.installed} — ${t.latest} available`;case`current`:return`${e.installed}, up to date`;case`failed`:return`${e.installed}, not checked: ${t.reason}`;case`off`:return`${e.installed}, not checked: ${t.reason}`}}function $M({packages:e,update:t,locked:n,onCheck:r,onUpdate:a}){let[s,c]=(0,i.useState)(null);if(e===null||e.length===0)return null;let l=t?.status===`pending`?t.source:null;return(0,o.jsxs)(`div`,{className:`mt-3`,"data-testid":`pi-packages`,children:[(0,o.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium text-zinc-600 dark:text-zinc-400`,children:`Packages`}),(0,o.jsx)(`button`,{type:`button`,onClick:r,className:`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200`,children:`check for updates`})]}),(0,o.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>{let r=e.check?.state===`newer`&&!e.restartNeeded?e.check.latest:void 0;return(0,o.jsxs)(`li`,{"data-testid":`pi-package`,className:`rounded bg-zinc-50 px-2 py-1 text-xs dark:bg-zinc-800`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,o.jsx)(`span`,{className:`min-w-0 truncate font-mono text-zinc-700 dark:text-zinc-300`,title:e.source,children:e.name}),r&&!n&&s!==e.source&&(0,o.jsx)(`button`,{type:`button`,disabled:l!==null,onClick:()=>c(e.source),className:`shrink-0 rounded border border-zinc-300 px-1.5 py-0.5 text-zinc-700 hover:bg-zinc-100 disabled:opacity-50 dark:border-zinc-600 dark:text-zinc-200 dark:hover:bg-zinc-700`,children:l===e.source?`updating…`:`Update`})]}),(0,o.jsx)(`div`,{className:`line-clamp-2 text-zinc-500 dark:text-zinc-400`,"data-testid":`pi-package-status`,title:QM(e),children:QM(e)}),r&&s===e.source&&(0,o.jsxs)(`div`,{className:`mt-1 rounded border border-amber-300 bg-amber-50 p-2 text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,"data-testid":`pi-package-confirm`,children:[(0,o.jsxs)(`p`,{children:[`This replaces code that runs with the agent's privileges: `,e.name,` `,e.installed,` → `,r,`. It takes effect when pi-outpost restarts.`]}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsxs)(`button`,{type:`button`,onClick:()=>{c(null),a(e.source)},className:`rounded bg-amber-600 px-2 py-0.5 text-white hover:bg-amber-700`,children:[`Install `,r]}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`rounded px-2 py-0.5 hover:bg-amber-100 dark:hover:bg-amber-900/40`,children:`Cancel`})]})]}),t&&t.status!==`pending`&&t.source===e.source&&(0,o.jsx)(`p`,{"data-testid":`pi-package-result`,className:`mt-1 ${t.status===`installed`?`text-emerald-700 dark:text-emerald-400`:`text-amber-700 dark:text-amber-400`}`,children:t.message})]},e.source)})})]})}function eN({reasons:e,canRestart:t,restarting:n,onRestart:r}){let[a,s]=(0,i.useState)(!1);return e.length===0?null:(0,o.jsxs)(`div`,{className:`mt-3 rounded border border-sky-200 bg-sky-50 p-2 text-xs text-sky-900 dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200`,"data-testid":`restart-needed`,children:[(0,o.jsxs)(`p`,{children:[`Installed and waiting on a restart to run: `,e.join(`, `),`.`]}),t?n?(0,o.jsx)(`p`,{className:`mt-1`,children:`Restarting pi-outpost…`}):a?(0,o.jsxs)(`div`,{className:`mt-1`,children:[(0,o.jsx)(`p`,{children:`pi-outpost stops and starts again in the same terminal. Every open window reconnects by itself, and conversations are kept.`}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{s(!1),r()},className:`rounded bg-sky-700 px-2 py-0.5 text-white hover:bg-sky-800`,children:`Restart now`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>s(!1),className:`rounded px-2 py-0.5 hover:bg-sky-100 dark:hover:bg-sky-900/50`,children:`Cancel`})]})]}):(0,o.jsx)(`button`,{type:`button`,onClick:()=>s(!0),className:`mt-1 rounded border border-sky-300 px-2 py-0.5 hover:bg-sky-100 dark:border-sky-700 dark:hover:bg-sky-900/50`,children:`Restart pi-outpost`}):null]})}var tN=30,nN={display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`,overflow:`hidden`};function rN({skills:e,groups:t,enabled:n,onChange:r,disabled:a=!1,bound:s}){let[c,l]=(0,i.useState)(()=>e.length>40?new Set(e.filter(e=>n.has(e.relativePath)).map(e=>e.group)):new Set(t.map(e=>e.path))),[u,d]=(0,i.useState)(``),[f,p]=(0,i.useState)(!1),m=u.trim().toLocaleLowerCase(),h=m!==``||f,g=e=>(!f||n.has(e.relativePath))&&(!m||`${e.name} ${e.relativePath} ${e.description??``}`.toLocaleLowerCase().includes(m)),_=new Map;for(let t of e)_.set(t.group,[..._.get(t.group)??[],t]);let v=e.filter(e=>n.has(e.relativePath)).length,y=h?e.filter(g).length:e.length,b=(e,t)=>{let i=new Set(n);for(let n of e)t?i.add(n.relativePath):i.delete(n.relativePath);r(i)},x=e=>{let t=new Set(n);t.has(e)?t.delete(e):t.add(e),r(t)},ee=e=>l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,o.jsxs)(`section`,{className:`rounded-xl border border-zinc-200 p-4 dark:border-zinc-800`,"aria-label":`Collection skills`,children:[(0,o.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,o.jsxs)(`h3`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:[`Skills `,(0,o.jsxs)(`span`,{className:`font-normal text-zinc-500`,children:[`· `,v,` of `,e.length,` on`]})]}),(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,disabled:a||v===e.length,onClick:()=>b(e,!0),className:`rounded-md border px-2.5 py-1 text-xs disabled:opacity-50`,children:`All on`}),(0,o.jsx)(`button`,{type:`button`,disabled:a||v===0,onClick:()=>b(e,!1),className:`rounded-md border px-2.5 py-1 text-xs disabled:opacity-50`,children:`All off`})]})]}),s?(0,o.jsx)(`p`,{className:`mt-2 rounded border border-amber-200 bg-amber-50 p-2 text-xs text-amber-800`,children:s.kind===`count`?`This repository holds more skills than the ${s.limit} listed here.`:`Folders deeper than ${s.limit} levels were not searched for skills.`}):null,e.length>0?(0,o.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,o.jsx)(`input`,{type:`search`,"aria-label":`Search skills`,placeholder:`Search skills by name or folder`,value:u,onChange:e=>d(e.target.value),className:`min-w-0 flex-1 rounded-md border bg-transparent px-2.5 py-1 text-xs`}),(0,o.jsxs)(`button`,{type:`button`,"aria-pressed":f,onClick:()=>p(e=>!e),className:`rounded-md px-2.5 py-1 text-xs ${f?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:[`Only on (`,v,`)`]})]}):null,!h&&v>0&&v<=tN?(0,o.jsxs)(`div`,{role:`region`,"aria-label":`Skills that are on`,className:`mt-3 rounded-lg border border-emerald-200 bg-emerald-50/60 p-2 dark:border-emerald-900 dark:bg-emerald-950/30`,children:[(0,o.jsx)(`p`,{className:`px-1 text-[11px] font-medium text-emerald-800 dark:text-emerald-300`,children:`Turned on`}),(0,o.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.filter(e=>n.has(e.relativePath)).map(e=>(0,o.jsxs)(`li`,{className:`flex items-start justify-between gap-2 px-1`,children:[(0,o.jsxs)(`span`,{className:`min-w-0 text-xs`,children:[(0,o.jsx)(`span`,{className:`font-medium text-zinc-800 dark:text-zinc-100`,children:e.name}),` `,(0,o.jsx)(`span`,{className:`font-mono text-[11px] text-zinc-500`,children:e.group||`(repository root)`}),(0,o.jsx)(iN,{skill:e,checked:!0})]}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Turn off ${e.name} (${e.relativePath})`,disabled:a,onClick:()=>x(e.relativePath),className:`shrink-0 rounded border bg-white px-2 py-0.5 text-[11px] disabled:opacity-50 dark:bg-zinc-900`,children:`Turn off`})]},e.relativePath))})]}):null,e.length===0?(0,o.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:`This repository holds no skills.`}):null,h&&y===0?(0,o.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:f&&!m?`No skill is on.`:`No skill matches.`}):null,(0,o.jsx)(`ul`,{className:`mt-3 space-y-2`,children:t.map(e=>{let t=_.get(e.path)??[],r=h?t.filter(g):t;if(h&&r.length===0)return null;let i=r.filter(e=>n.has(e.relativePath)).length,s=h||c.has(e.path);return(0,o.jsxs)(`li`,{className:`rounded-lg border border-zinc-100 dark:border-zinc-800`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,o.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:()=>ee(e.path),className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,o.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs text-zinc-400`,children:s?`▾`:`▸`}),(0,o.jsx)(`span`,{className:`truncate font-mono text-xs font-medium text-zinc-700 dark:text-zinc-200`,children:e.label}),(0,o.jsxs)(`span`,{className:`shrink-0 text-[11px] text-zinc-500`,children:[i,`/`,r.length,` on`]})]}),(0,o.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,o.jsx)(`button`,{type:`button`,"aria-label":`All on in ${e.label}`,disabled:a||i===r.length,onClick:()=>b(r,!0),className:`rounded border px-2 py-0.5 text-[11px] disabled:opacity-50`,children:`All on`}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`All off in ${e.label}`,disabled:a||i===0,onClick:()=>b(r,!1),className:`rounded border px-2 py-0.5 text-[11px] disabled:opacity-50`,children:`All off`})]})]}),s?(0,o.jsx)(`ul`,{className:`space-y-1 border-t border-zinc-100 px-3 py-2 dark:border-zinc-800`,children:r.map(e=>{let t=n.has(e.relativePath);return(0,o.jsx)(`li`,{children:(0,o.jsxs)(`label`,{className:`flex items-start gap-2 rounded px-1 py-1 ${a?`opacity-60`:`cursor-pointer hover:bg-zinc-50 dark:hover:bg-zinc-800/60`}`,children:[(0,o.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":t,"aria-label":`${e.name} (${e.relativePath})`,checked:t,disabled:a,onChange:()=>x(e.relativePath),className:`mt-0.5`}),(0,o.jsxs)(`span`,{className:`min-w-0`,children:[(0,o.jsx)(`span`,{className:`block truncate text-sm text-zinc-800 dark:text-zinc-100`,children:e.name}),e.description?(0,o.jsx)(`span`,{title:e.description,style:nN,className:`text-[11px] text-zinc-500`,children:e.description}):null,(0,o.jsx)(iN,{skill:e,checked:t})]})]})},e.relativePath)})}):null]},e.path)})})]})}function iN({skill:e,checked:t}){return t===(e.state!==`off`)?e.state===`on-loaded`?(0,o.jsx)(`span`,{className:`block text-[11px] text-emerald-700 dark:text-emerald-400`,children:`Loaded`}):e.state===`on-not-loaded`?(0,o.jsxs)(`span`,{className:`block text-[11px] text-amber-700 dark:text-amber-400`,children:[`Not loaded — `,e.reason]}):e.state===`on-missing`?(0,o.jsxs)(`span`,{className:`block text-[11px] text-rose-700 dark:text-rose-400`,children:[`Missing — `,e.reason]}):null:(0,o.jsx)(`span`,{className:`block text-[11px] font-medium text-sky-700 dark:text-sky-300`,children:t?`Pending: on`:`Pending: off`})}function aN(e,t){return[...new Set(e.map(e=>e.group))].sort().map(e=>({path:e,label:e||t}))}function oN(e){return e.skills.filter(e=>e.state!==`off`).map(e=>e.relativePath)}function sN(e,t){let n=new Set(e),r=new Set(t);return n.size===r.size&&[...n].every(e=>r.has(e))}function cN(e,t){if(t.status===`loading`)return`Removing ${e}…`;if(t.status===`error`)return t.message??`Could not remove ${e}`;let n=t.result;return n?n.status===`removed`?`Removed ${e} and deleted ${n.path}.`:n.status===`removed-files-kept`?`Removed ${e}. ${n.reason??`Its files were kept`} (${n.path}).`:`Removed ${e}, but not every file could be deleted${n.reason?` — ${n.reason}`:``}. What remains is at ${n.path}.`:`Removed ${e}.`}var lN={unchecked:`Not checked`,checking:`Checking…`,current:`Up to date`,updateable:`Update available`,dirty:`Local changes`,detached:`Detached HEAD`,ahead:`Local branch ahead`,diverged:`Histories diverged`,"no-upstream":`No upstream`,locked:`Locked`,busy:`Workspace busy`,unavailable:`Unavailable`,failed:`Check failed`};function uN(e){if(!e)return[];let t=new Map(e.resources.map(e=>[e.id,e])),n=new Set(e.repositories.flatMap(e=>e.resourceIds)),r=e.repositories.map(e=>({id:e.id,name:e.name,path:e.path,repository:e,resources:e.resourceIds.flatMap(e=>t.get(e)?[t.get(e)]:[])})),i=e.resources.filter(e=>!n.has(e.id)),a=i.filter(e=>e.unavailableReason),o=i.filter(e=>!e.unavailableReason);return o.length&&r.push({id:`local`,name:`Local and built in`,reason:`Not backed by an updateable Git repository`,resources:o}),a.length&&r.push({id:`unavailable`,name:`Provenance unavailable`,reason:`The active runtime did not report enough filesystem provenance`,resources:a}),r}function dN(e){let t=e.length;for(;t>0&&(e[t-1]===`/`||e[t-1]===`\\`);)--t;return t===e.length?e:e.slice(0,t)}function fN(e){let t=dN(e),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n<=0?`/`:t.slice(0,n)}function pN(e,t){let n=dN(t),r=Math.max(n.lastIndexOf(`/`),n.lastIndexOf(`\\`)),i=r>=0?n.slice(r+1):n;return`${dN(e)}/${i||`agent-resources`}`}function mN({kind:e,resources:t,removalLocked:n=!1,onRemove:r}){return(0,o.jsxs)(`section`,{className:`rounded-xl border border-zinc-200 p-4 dark:border-zinc-800`,children:[(0,o.jsxs)(`h3`,{className:`flex items-center justify-between text-sm font-semibold capitalize text-zinc-800 dark:text-zinc-200`,children:[(0,o.jsxs)(`span`,{children:[e,`s`]}),(0,o.jsx)(`span`,{className:`text-xs font-normal text-zinc-400`,children:t.length})]}),t.length===0?(0,o.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:`None in this group`}):(0,o.jsx)(`ul`,{className:`mt-3 space-y-2`,children:t.map(e=>(0,o.jsxs)(`li`,{className:`rounded-lg bg-zinc-50 px-3 py-2 dark:bg-zinc-800/70`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,o.jsx)(`p`,{className:`truncate text-sm font-medium text-zinc-700 dark:text-zinc-200`,children:e.name}),e.userRoot&&!n?(0,o.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.userRoot}`,onClick:()=>r(e),className:`text-xs text-zinc-500 hover:text-red-600`,children:`Remove`}):null]}),(0,o.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[11px] text-zinc-400`,title:e.path,children:e.path??e.unavailableReason??`Path unavailable`})]},e.id))})]})}function hN({preview:e,busy:t,error:n,onApply:r,onCancel:a}){let[s,c]=(0,i.useState)(()=>new Set(e.roots.filter(e=>!e.locked).map(e=>`${e.kind}:${e.path}`))),[l,u]=(0,i.useState)(!1),[d,f]=(0,i.useState)(()=>new Set),p=e.mode===`collection`,m=(0,i.useMemo)(()=>e.skills.map(e=>({...e,state:`off`})),[e.skills]),h=(0,i.useMemo)(()=>aN(e.skills,e.repositoryName),[e.skills,e.repositoryName]),g=e.roots.filter(e=>e.kind===`extension`&&s.has(`extension:${e.path}`)),_=g.length>0&&!l,v=t||!p&&s.size===0||_,y=()=>{let t=g.map(e=>e.path);p?r([],t,[...d]):r(e.roots.filter(e=>e.kind===`skill`&&s.has(`skill:${e.path}`)).map(e=>e.path),t)},b=e=>{u(!1),c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,o.jsxs)(`div`,{className:`space-y-3`,"data-testid":`resource-preview`,children:[(0,o.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,o.jsxs)(`div`,{className:`min-w-0`,children:[(0,o.jsx)(`h3`,{className:`truncate text-xl font-semibold text-zinc-900 dark:text-zinc-100`,children:e.repositoryName}),(0,o.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[11px] text-zinc-500`,title:e.repositoryPath,children:e.repositoryPath})]}),(0,o.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,disabled:v,onClick:y,className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900`,children:t?`Saving…`:`Save`})]})]}),_?(0,o.jsx)(`p`,{className:`text-xs text-amber-700`,children:`Confirm the extension warning below to save.`}):null,n?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:n}):null,p?(0,o.jsx)(rN,{skills:m,groups:h,enabled:d,onChange:f,disabled:t,...e.bound?{bound:e.bound}:{}}):null,e.roots.map(e=>{let t=`${e.kind}:${e.path}`;return(0,o.jsxs)(`label`,{className:`flex items-start gap-2 rounded border p-2 ${e.locked?`opacity-50`:`cursor-pointer`}`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:s.has(t),disabled:e.locked,onChange:()=>b(t)}),(0,o.jsxs)(`span`,{children:[(0,o.jsxs)(`span`,{className:`block text-sm`,children:[e.name,` · `,e.kind]}),(0,o.jsx)(`span`,{className:`font-mono text-[11px] text-zinc-500`,children:e.path}),e.locked?(0,o.jsx)(`span`,{className:`block text-xs text-amber-700`,children:`Extension paths are locked`}):null]})]},t)}),g.length>0?(0,o.jsxs)(`label`,{className:`flex gap-2 rounded-md border border-amber-300 bg-amber-50 p-3 text-xs text-amber-900`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked)}),(0,o.jsx)(`span`,{children:`Extensions execute code with the agent's privileges. I trust the selected extension roots in this repository.`})]}):null]})}function gN(e){let t=(0,i.useRef)(null),n=(0,i.useRef)(e.onClose),r=(0,i.useRef)(!1),[a,s]=(0,i.useState)(null),[c,l]=(0,i.useState)(``),[u,d]=(0,i.useState)(`all`),[f,p]=(0,i.useState)(!1),[m,h]=(0,i.useState)(null),[g,_]=(0,i.useState)(null),[v,y]=(0,i.useState)(`skill`),[b,x]=(0,i.useState)(``),[ee,te]=(0,i.useState)(!1),[ne,re]=(0,i.useState)(``),[ie,ae]=(0,i.useState)(``),[oe,se]=(0,i.useState)(!1),[ce,le]=(0,i.useState)(``),[ue,de]=(0,i.useState)(null),[fe,pe]=(0,i.useState)({}),[me,S]=(0,i.useState)(null),[he,ge]=(0,i.useState)(null),_e=(0,i.useMemo)(()=>uN(e.inventory),[e.inventory]),ve=(0,i.useMemo)(()=>{let e=c.trim().toLocaleLowerCase();return _e.flatMap(t=>{let n=`repository`in t?t.repository.collection:void 0,r=n?t.resources.filter(e=>e.kind!==`skill`):t.resources,i=u===`all`?r:r.filter(e=>e.kind===u),a=n&&u!==`extension`?n.skills:[],o=i.length+a.length;if(o===0&&!(n&&u===`all`)||f&&(!(`repository`in t)||![`updateable`,`dirty`,`failed`,`unavailable`,`busy`].includes(t.repository.assessment.status)))return[];let s=`${t.name} ${`path`in t?t.path??``:``} ${i.map(e=>`${e.name} ${e.path??``}`).join(` `)} ${a.map(e=>`${e.name} ${e.relativePath}`).join(` `)}`.toLocaleLowerCase(),c=n?n.skills.filter(e=>e.state!==`off`).length:void 0;return!e||s.includes(e)?[{...t,resources:i,count:o,...c===void 0?{}:{onCount:c}}]:[]})},[_e,f,u,c]),ye=ve.find(e=>e.id===a)??ve[0]??null;if((0,i.useEffect)(()=>{n.current=e.onClose},[e.onClose]),(0,i.useEffect)(()=>{pe(t=>{let n={},r=!1;for(let[i,a]of Object.entries(t)){let t=e.inventory?.repositories.find(e=>e.id===i)?.collection;!t||sN(a,oN(t))?r=!0:n[i]=a}return r?n:t})},[e.inventory]),(0,i.useEffect)(()=>{e.open&&t.current?.focus()},[e.open]),(0,i.useEffect)(()=>{if(!e.open)return;let t=e=>{e.key===`Escape`&&n.current()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e.open]),(0,i.useEffect)(()=>{let t=e.operations.clonePath;t?.status===`ready`&&t.path&&!oe&&ae(t.path)},[oe,e.operations.clonePath]),(0,i.useEffect)(()=>{e.operations.enrollment?.status===`ready`&&h(null)},[e.operations.enrollment]),(0,i.useEffect)(()=>{if(e.applyState?.status===`applying`){r.current=!0;return}r.current&&e.applyState===null&&(r.current=!1,h(null),_(null),te(!1))},[e.applyState]),!e.open)return null;let be=ye&&`repository`in ye?ye.repository:null,xe=be?e.operations.updates[be.id]:void 0,Se=be?.assessment,Ce=Se?.status===`updateable`&&Se.token&&Se.localRevision&&Se.upstreamRevision,we=()=>{let t=b.trim();t&&(v===`skill`?e.onUpdateConfig({userSkillPaths:[...new Set([...e.userSkillPaths,t])]}):e.onUpdateConfig({userExtensionPaths:[...new Set([...e.userExtensionPaths,t])]}))},Te=t=>{t.userRoot&&(t.kind===`skill`?e.onUpdateConfig({userSkillPaths:e.userSkillPaths.filter(e=>e!==t.userRoot)}):e.onUpdateConfig({userExtensionPaths:e.userExtensionPaths.filter(e=>e!==t.userRoot)}))},Ee=(t,n=!1)=>{let r=t.assessment;!r.token||!r.localRevision||!r.upstreamRevision||e.onUpdate(t.id,r.token,r.localRevision,r.upstreamRevision,n)},De=be?.collection,Oe=De?oN(De):[],ke=new Set(be&&fe[be.id]?fe[be.id]:Oe),Ae=De?[...new Set([...ke,...Oe])].filter(e=>ke.has(e)!==Oe.includes(e)).length:0,je=be?e.operations.skills?.[be.id]:void 0,Me=e=>{if(!be)return;let t=be.id;pe(n=>{let r={...n};return sN(e,Oe)?delete r[t]:r[t]=[...e],r})},Ne=()=>{if(!be)return;let e=be.id;pe(t=>{let n={...t};return delete n[e],n})},Pe=()=>{if(!be||!De)return;let t=new Set(De.skills.filter(e=>e.state!==`on-missing`).map(e=>e.relativePath));e.onSetSkills(be.id,[...ke].filter(e=>t.has(e)))},Fe=he?e.operations.removals?.[he.id]:void 0,Ie=Fe?.status===`error`||Fe?.result?.status===`removed-delete-failed`;return(0,o.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/45 p-4`,role:`presentation`,onMouseDown:t=>{t.currentTarget===t.target&&e.onClose()},children:[(0,o.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`agent-resources-title`,className:`flex h-[min(760px,92vh)] w-[min(1120px,96vw)] flex-col overflow-hidden rounded-2xl border border-zinc-200 bg-white shadow-2xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,o.jsxs)(`header`,{className:`flex items-center justify-between border-b border-zinc-200 px-5 py-4 dark:border-zinc-800`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`h2`,{id:`agent-resources-title`,className:`text-lg font-semibold text-zinc-900 dark:text-zinc-100`,children:`Agent resources`}),(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Skills and extensions, grouped by repository`})]}),(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,disabled:e.operations.refresh?.status===`loading`,onClick:()=>e.onRefresh(),className:`rounded-md border px-3 py-1.5 text-xs disabled:opacity-50`,children:`Refresh all`}),(0,o.jsx)(`button`,{ref:t,type:`button`,"aria-label":`Close agent resources`,onClick:e.onClose,className:`rounded-md border px-2 py-1 text-sm`,children:`✕`})]})]}),(0,o.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[300px_1fr]`,children:[(0,o.jsxs)(`aside`,{className:`flex min-h-0 flex-col border-r border-zinc-200 bg-zinc-50/80 p-3 dark:border-zinc-800 dark:bg-zinc-950/40`,children:[(0,o.jsx)(`input`,{"aria-label":`Search resources`,value:c,onChange:e=>l(e.target.value),placeholder:`Search repositories or resources`,className:`rounded-md border bg-white px-3 py-2 text-xs dark:bg-zinc-900`}),(0,o.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[[`all`,`skill`,`extension`].map(e=>(0,o.jsx)(`button`,{type:`button`,"aria-pressed":u===e,onClick:()=>d(e),className:`rounded px-2 py-1 text-[11px] ${u===e?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:e===`all`?`All`:`${e}s`},e)),(0,o.jsx)(`button`,{type:`button`,"aria-pressed":f,onClick:()=>p(e=>!e),className:`rounded px-2 py-1 text-[11px] ${f?`bg-amber-600 text-white`:`border`}`,children:`Needs attention`})]}),(0,o.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 space-y-1 overflow-y-auto`,children:[ve.map(e=>(0,o.jsxs)(`button`,{type:`button`,onClick:()=>s(e.id),className:`w-full rounded-lg px-3 py-2.5 text-left ${ye?.id===e.id?`bg-white shadow-sm ring-1 ring-zinc-200 dark:bg-zinc-800 dark:ring-zinc-700`:`hover:bg-white/70 dark:hover:bg-zinc-900`}`,children:[(0,o.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-sm font-medium`,children:[(0,o.jsx)(`span`,{className:`truncate`,children:e.name}),(0,o.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400`,children:e.onCount===void 0?e.count??e.resources.length:`${e.onCount} on · ${e.count}`})]}),(0,o.jsx)(`span`,{className:`mt-1 block text-xs text-zinc-500`,children:`repository`in e?lN[e.repository.assessment.status]:e.reason})]},e.id)),ve.length===0?(0,o.jsx)(`p`,{className:`px-2 py-4 text-xs text-zinc-500`,children:`No matching resources`}):null]}),(0,o.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t pt-3`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{te(!1),h(`local`),_(`local`),e.onBrowseServerPath(b||`/`)},className:`rounded-md border bg-white px-3 py-2 text-xs font-medium dark:bg-zinc-900`,children:`Add local folder…`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>h(`git`),className:`rounded-md bg-zinc-900 px-3 py-2 text-xs font-medium text-white dark:bg-zinc-100 dark:text-zinc-900`,children:`Add Git repository…`})]})]}),(0,o.jsxs)(`main`,{className:`min-w-0 overflow-y-auto p-6`,children:[he&&Fe?(0,o.jsxs)(`div`,{role:Ie?`alert`:`status`,className:`mb-4 flex items-start justify-between gap-3 rounded-lg border p-3 text-sm ${Ie?`border-rose-200 bg-rose-50 text-rose-800`:`border-zinc-200 bg-zinc-50 text-zinc-700`}`,children:[(0,o.jsx)(`p`,{className:`min-w-0 break-words`,children:cN(he.name,Fe)}),Fe.status===`loading`?null:(0,o.jsx)(`button`,{type:`button`,onClick:()=>ge(null),className:`shrink-0 text-xs underline`,children:`Dismiss`})]}):null,m===`local`?(0,o.jsxs)(`div`,{className:`max-w-xl space-y-4`,"data-testid":`add-local-folder`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Add local folder`}),(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Choose an existing folder on the server and how the agent should load it.`})]}),(0,o.jsx)(`div`,{className:`flex gap-2`,children:[`skill`,`extension`].map(t=>(0,o.jsx)(`button`,{type:`button`,"aria-pressed":v===t,disabled:t===`extension`&&e.extensionLock,onClick:()=>{y(t),te(!1)},className:`rounded-md px-3 py-1.5 text-xs ${v===t?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:t===`skill`?`Skill folder`:`Extension folder`},t))}),(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`input`,{"aria-label":`Local resource folder`,value:b,onChange:e=>{te(!1),x(e.target.value)},className:`min-w-0 flex-1 rounded-md border bg-transparent px-3 py-2 text-sm`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{_(`local`),e.onBrowseServerPath(b||`/`)},className:`rounded-md border px-3 text-xs`,children:`Browse…`})]}),g===`local`?(0,o.jsx)(KM,{label:`Choose a local resource folder`,browse:e.serverBrowse,onBrowse:e.onBrowseServerPath,onSelect:t=>{te(!1),x(t),_(null),e.onCloseServerBrowser()},onCancel:()=>{_(null),e.onCloseServerBrowser()}}):null,v===`extension`?(0,o.jsxs)(`label`,{className:`flex gap-2 rounded-md border border-amber-300 bg-amber-50 p-3 text-xs text-amber-900`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:ee,onChange:e=>te(e.target.checked)}),(0,o.jsx)(`span`,{children:`Extensions execute code with the agent's privileges. I trust every extension in this folder.`})]}):null,e.extensionLock?(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Extension paths are locked by this deployment.`}):null,e.applyState?.status===`error`?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.applyState.message}):null,(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{te(!1),h(null),_(null),e.onCloseServerBrowser()},className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,disabled:!b.trim()||e.applyState?.status===`applying`||v===`extension`&&(!ee||e.extensionLock),onClick:we,className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:e.applyState?.status===`applying`?`Applying…`:`Add folder`})]})]}):m===`git`?(0,o.jsx)(`div`,{className:`max-w-2xl space-y-4`,"data-testid":`add-git-repository`,children:e.operations.preview?.status===`ready`&&e.operations.preview.preview?(0,o.jsx)(hN,{onCancel:()=>{h(null),_(null),e.onCloseServerBrowser()},preview:e.operations.preview.preview,busy:e.operations.enrollment?.status===`loading`,error:e.operations.enrollment?.status===`error`?e.operations.enrollment.message:void 0,onApply:(t,n,r)=>r?e.onEnrollRepository(e.operations.preview.preview.token,t,n,r):e.onEnrollRepository(e.operations.preview.preview.token,t,n)}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Add Git repository`}),(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Clone it to a local folder, then choose what to turn on.`})]}),(0,o.jsxs)(`label`,{className:`block`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium`,children:`Repository address`}),(0,o.jsx)(`input`,{"aria-label":`Repository address`,value:ne,onChange:e=>re(e.target.value),onBlur:()=>{let t=ne.trim();t&&(se(!1),le(t),e.onSuggestClonePath(ne))},placeholder:`https://github.com/team/resources.git`,className:`mt-1 w-full rounded-md border bg-transparent px-3 py-2 text-sm`})]}),(0,o.jsxs)(`label`,{className:`block`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium`,children:`Local folder`}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`input`,{"aria-label":`Local clone folder`,value:ie,onChange:e=>{se(!0),ae(e.target.value)},placeholder:`/path/to/resource-repositories/team-resources-ab12cd`,className:`min-w-0 flex-1 rounded-md border bg-transparent px-3 py-2 text-sm`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{_(`clone-parent`),e.onBrowseServerPath(fN(ie))},className:`rounded-md border px-3 text-xs`,children:`Choose parent…`})]})]}),e.operations.clonePath?.status===`loading`?(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Suggesting a managed folder…`}):null,e.operations.clonePath?.status===`error`&&ne.trim()===ce?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.operations.clonePath.message}):null,g===`clone-parent`?(0,o.jsx)(KM,{label:`Choose the clone's parent folder`,browse:e.serverBrowse,onBrowse:e.onBrowseServerPath,onSelect:t=>{ae(pN(t,ie)),_(null),e.onCloseServerBrowser()},onCancel:()=>{_(null),e.onCloseServerBrowser()}}):null,e.operations.preview?.status===`error`?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.operations.preview.message}):null,(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{h(null),_(null),e.onCloseServerBrowser()},className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,disabled:!ne.trim()||!ie.trim()||e.operations.preview?.status===`loading`,onClick:()=>e.onCloneRepository(ne,ie),className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:e.operations.preview?.status===`loading`?`Cloning…`:`Clone and inspect`})]})]})}):ye?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,o.jsxs)(`div`,{className:`min-w-0`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`h3`,{className:`text-xl font-semibold`,children:ye.name}),be?(0,o.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 text-[11px]`,children:lN[be.assessment.status]}):null]}),(0,o.jsx)(`p`,{className:`mt-1 truncate font-mono text-xs text-zinc-500`,children:`repository`in ye?ye.path:ye.reason}),Se?.branch?(0,o.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-400`,children:[Se.branch,Se.upstream?` → ${Se.upstream}`:``]}):null,be?.removal&&!be.removal.allowed?(0,o.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:be.removal.reason}):null]}),be?(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[be.removal?.allowed?(0,o.jsx)(`button`,{type:`button`,disabled:e.operations.removals?.[be.id]?.status===`loading`,onClick:()=>S(be),className:`rounded-md border border-red-200 px-3 py-1.5 text-xs text-red-700 disabled:opacity-50 dark:border-red-900 dark:text-red-400`,children:`Remove repository`}):null,(0,o.jsx)(`button`,{type:`button`,disabled:e.operations.refresh?.status===`loading`,onClick:()=>e.onRefresh(be.id),className:`rounded-md border px-3 py-1.5 text-xs`,children:`Check`}),Ce||xe?.status===`loading`?(0,o.jsx)(`button`,{type:`button`,disabled:xe?.status===`loading`,onClick:()=>be.containsExtensions?de(be):Ee(be),className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:xe?.status===`loading`?`Updating…`:`Update repository`}):null]}):null]}),Se?.reason?(0,o.jsxs)(`div`,{className:`mt-5 rounded-lg border p-3 text-sm ${Se.status===`dirty`?`border-rose-200 bg-rose-50 text-rose-800`:`border-zinc-200 bg-zinc-50 text-zinc-700`}`,children:[Se.reason,Se.status===`dirty`?(0,o.jsx)(`p`,{className:`mt-1 text-xs`,children:`Review and resolve these local changes in an external terminal, then check again. This updater never commits, stashes, discards, rebases, or merges them.`}):null]}):null,Se?.hasSubmodules?(0,o.jsx)(`p`,{className:`mt-3 rounded border border-amber-200 bg-amber-50 p-2 text-xs text-amber-800`,children:`This repository declares submodules. Their working trees will not be initialized or updated.`}):null,xe?.status===`ready`?(0,o.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-zinc-600`,children:xe.result?.status===`updated`&&xe.result.reloads.some(e=>e.status===`restart-required`)?`Repository updated. Its skills are reloaded; its extension code runs after pi-outpost restarts — restart it from Settings.`:xe.result?.status===`updated`?`Repository updated and runtimes reloaded.`:xe.result?.status===`updated-reload-failed`?`Repository updated on disk, but at least one runtime failed to reload.`:xe.result?.reason}):null,xe?.status===`error`?(0,o.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-red-600`,children:xe.message}):null,De&&be&&u!==`extension`?(0,o.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[Ae>0||je?.status===`loading`?(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-sky-200 bg-sky-50 px-3 py-2 text-xs text-sky-900 dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200`,children:[(0,o.jsx)(`span`,{children:je?.status===`loading`?`Applying…`:`${Ae} pending change${Ae===1?``:`s`} — applying replaces the session`}),(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,disabled:je?.status===`loading`,onClick:Ne,className:`rounded border bg-white px-2.5 py-1 disabled:opacity-50 dark:bg-zinc-900`,children:`Discard`}),(0,o.jsx)(`button`,{type:`button`,disabled:je?.status===`loading`||Ae===0,onClick:Pe,className:`rounded bg-zinc-900 px-2.5 py-1 font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900`,children:`Apply`})]})]}):null,je?.status===`error`?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:je.message}):null,(0,o.jsx)(rN,{skills:De.skills,groups:De.groups,enabled:ke,onChange:Me,disabled:je?.status===`loading`,...De.bound?{bound:De.bound}:{}},be.id),ye.resources.some(e=>e.kind===`extension`)?(0,o.jsx)(mN,{kind:`extension`,resources:ye.resources.filter(e=>e.kind===`extension`),removalLocked:e.extensionLock,onRemove:Te}):null]}):(0,o.jsxs)(`div`,{className:`mt-6 grid grid-cols-2 gap-4`,children:[(0,o.jsx)(mN,{kind:`skill`,resources:ye.resources.filter(e=>e.kind===`skill`),onRemove:Te}),(0,o.jsx)(mN,{kind:`extension`,resources:ye.resources.filter(e=>e.kind===`extension`),removalLocked:e.extensionLock,onRemove:Te})]})]}):(0,o.jsx)(`p`,{className:`text-sm text-zinc-500`,children:`No resources are reported by this runtime.`})]})]})]}),ue?(0,o.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4`,children:(0,o.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`extension-update-title`,className:`w-full max-w-md rounded-xl bg-white p-5 shadow-2xl dark:bg-zinc-900`,children:[(0,o.jsx)(`h3`,{id:`extension-update-title`,className:`font-semibold`,children:`Update executable extensions?`}),(0,o.jsxs)(`p`,{className:`mt-2 text-sm text-zinc-600 dark:text-zinc-300`,children:[ue.name,` contains extensions that run with the agent's privileges. Confirm updating `,ue.assessment.localRevision?.slice(0,8),` to `,ue.assessment.upstreamRevision?.slice(0,8),`.`]}),(0,o.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>de(null),className:`rounded border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{Ee(ue,!0),de(null)},className:`rounded bg-amber-600 px-3 py-1.5 text-xs font-medium text-white`,children:`Confirm executable update`})]})]})}):null,me?(0,o.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4`,children:(0,o.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`remove-repository-title`,"aria-describedby":`remove-repository-detail`,className:`w-full max-w-md rounded-xl bg-white p-5 shadow-2xl dark:bg-zinc-900`,children:[(0,o.jsxs)(`h3`,{id:`remove-repository-title`,className:`font-semibold`,children:[`Remove `,me.name,`?`]}),(0,o.jsx)(`p`,{id:`remove-repository-detail`,className:`mt-2 break-words text-sm text-zinc-600 dark:text-zinc-300`,children:me.removal?.deletesFiles?(0,o.jsxs)(o.Fragment,{children:[`This stops loading everything from `,me.name,` and deletes `,(0,o.jsx)(`span`,{className:`font-mono`,children:me.removal.path}),` from disk, with any local changes in it. This cannot be undone.`]}):(0,o.jsxs)(o.Fragment,{children:[`This stops loading everything from `,me.name,`. pi-outpost does not manage `,(0,o.jsx)(`span`,{className:`font-mono`,children:me.removal?.path??me.path}),`, so its files will be kept.`]})}),(0,o.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>S(null),className:`rounded border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{e.onRemoveRepository(me.id),ge({id:me.id,name:me.name}),S(null)},className:`rounded bg-red-600 px-3 py-1.5 text-xs font-medium text-white`,children:me.removal?.deletesFiles?`Delete and remove`:`Remove repository`})]})]})}):null]})}function _N(e){return[...e].sort((e,t)=>e.localeCompare(t))}function vN({extensionPaths:e,configuredExtensionPaths:t,userExtensionPaths:n,extensionLock:r,piPackages:a=null,piPackageUpdate:s=null,canRestartServer:c=!1,serverRestarting:l=!1,onCheckPiPackages:u,onUpdatePiPackage:d,onRestartServer:f,restartNeeded:p=[],tools:m,commands:h,sandbox:g,showRoots:_=!0,gitUnavailable:v,userSkillPaths:y,serverBrowse:b,pickerBlocked:x=!1,onPickerOpened:ee,applyState:te,agentResources:ne=null,agentResourceOperations:re={clonePath:null,preview:null,enrollment:null,refresh:null,updates:{},skills:{},removals:{}},versions:ie,onBrowseServerPath:ae,onCloseServerBrowser:oe,onUpdateConfig:se,onSuggestAgentResourceClonePath:ce=()=>{},onCloneAgentResourceRepository:le=()=>{},onEnrollAgentResourceRepository:ue=()=>{},onSetAgentResourceSkills:de=()=>{},onRemoveAgentResourceRepository:fe=()=>{},onRefreshAgentResourceRepositories:pe=()=>{},onUpdateAgentResourceRepository:me=()=>{}}){let[S,he]=(0,i.useState)(!1),[ge,_e]=(0,i.useState)(!1),ve=(0,i.useRef)(null),[ye,be]=(0,i.useState)(``),[xe,Se]=(0,i.useState)(``),[Ce,we]=(0,i.useState)(!1),[Te,Ee]=(0,i.useState)(!1),[De,Oe]=(0,i.useState)(null);(0,i.useEffect)(()=>{x&&De!==null&&Oe(null)},[x,De]);let ke=wj(()=>{(S||De!==null)&&Le()}),Ae=m.filter(e=>e.active),je=m.filter(e=>!e.active),Me=h.filter(e=>e.source===`skill`),Ne=[...m].sort((e,t)=>e.name.localeCompare(t.name)||Number(t.active)-Number(e.active)),Pe=te?.status===`applying`,Fe=te?.status===`error`?te.message:null;(0,i.useEffect)(()=>{g&&(be(g.root),Se(g.writableRoot??``),we(g.allowWrite),Ee(g.allowBash))},[g]);let Ie=(0,i.useRef)(!1);(0,i.useEffect)(()=>{Ie.current&&te===null&&Le(),Ie.current=Pe},[te,Pe]);function Le(){he(!1),Oe(null),oe()}function Re(e,t){ee?.(),Oe(e),ae(t.trim()||`/`)}function ze(e){De===`root`?be(e):De===`writableRoot`&&Se(e),Oe(null),oe()}let Be=g!==null&&(ye!==g.root||(xe.trim()||void 0)!==(g.writableRoot||void 0)||Ce!==g.allowWrite||Te!==g.allowBash);function Ve(){!g||!Be||se({sandbox:{root:ye,allowWrite:Ce,allowBash:Te,writableRoot:xe.trim()||void 0}})}let He=_&&g?.rootEditable!==!1,Ue=De!==null&&!x&&(0,o.jsx)(KM,{label:De===`root`?`Choose the sandbox root`:`Choose the writable root`,browse:b,onBrowse:ae,onSelect:ze,onCancel:()=>{Oe(null),oe()}});return(0,o.jsxs)(`div`,{className:`relative`,ref:ke,children:[(0,o.jsx)(`button`,{ref:ve,type:`button`,onClick:()=>he(!S),title:`Settings`,"aria-label":`Settings`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`⚙`}),S&&(0,o.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[80vh] w-[380px] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,o.jsx)(`div`,{className:`border-b border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,o.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Settings`})}),(0,o.jsxs)(`div`,{className:`min-h-0 overflow-y-auto p-4`,children:[v&&(0,o.jsxs)(`section`,{className:`mb-4`,"data-testid":`git-unavailable`,children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Version control`}),v.reason===`no-repository`?(0,o.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:`This project is not in a git repository.`}):(0,o.jsxs)(`div`,{className:`rounded border border-amber-300 bg-amber-50 px-2 py-1.5 dark:border-amber-900 dark:bg-amber-950/40`,children:[(0,o.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-300`,children:v.reason===`no-executable`?`Git is unavailable: its executable could not be run.`:`Git is unavailable: it refused this repository.`}),(0,o.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-amber-700 dark:text-amber-400`,children:v.message}),v.reason===`no-executable`&&(0,o.jsxs)(`p`,{className:`mt-1 text-xs text-amber-700 dark:text-amber-400`,children:[`Install git, add it to PATH, or name it with `,(0,o.jsx)(`span`,{className:`font-mono`,children:`gitPath`}),` in the configuration.`]})]})]}),(0,o.jsxs)(`section`,{className:`mb-4`,children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Agent resources`}),m.length===0?(0,o.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`Tool inventory unavailable for this runtime`}):(0,o.jsxs)(`details`,{"data-testid":`tools-loaded`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[Ae.length,` tools active`,je.length?` · ${je.length} inactive`:``]}),(0,o.jsx)(`ul`,{className:`mt-2 space-y-1`,children:Ne.map(e=>(0,o.jsxs)(`li`,{className:`flex justify-between rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,children:[(0,o.jsx)(`span`,{children:e.name}),(0,o.jsx)(`span`,{children:e.active?`active`:`inactive`})]},e.name))})]}),Me.length===0?(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,children:`No skills loaded`}):(0,o.jsxs)(`details`,{className:`mt-2`,"data-testid":`skills-loaded`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[Me.length,` skills loaded`]}),(0,o.jsx)(`ul`,{className:`mt-2 space-y-1`,children:_N(Me.map(e=>e.name)).map(e=>(0,o.jsx)(`li`,{className:`rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,children:e},e))})]}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Manage agent resources`,onClick:()=>{he(!1),_e(!0)},className:`mt-3 w-full rounded-md border border-zinc-300 px-3 py-2 text-xs font-medium text-zinc-700 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-800`,children:`Manage resources…`})]}),(0,o.jsxs)(`section`,{className:`mb-4`,children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Extensions`}),e===null?(0,o.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-unknown`,children:`Not reported by this runtime`}):e.length===0?(0,o.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No extensions loaded`}):(0,o.jsxs)(`details`,{"data-testid":`extensions-loaded`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[e.length,` `,e.length===1?`extension`:`extensions`,` loaded`]}),(0,o.jsx)(`ul`,{className:`mt-2 space-y-1`,children:_N(e).map(e=>(0,o.jsx)(`li`,{className:`truncate rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},e))})]}),t.length>0&&(0,o.jsxs)(`details`,{className:`mt-2`,"data-testid":`extensions-configured`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[t.length,` configured by this deployment`]}),(0,o.jsx)(`p`,{className:`mt-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`Declared in the configuration file. They load either way, and nothing here can remove them.`}),(0,o.jsx)(`ul`,{className:`mt-1 space-y-1`,children:_N(t).map(e=>(0,o.jsx)(`li`,{className:`truncate rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},e))})]}),r?(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-locked`,children:`Extension paths and repository updates that contain extensions are locked by this deployment.`}):null,(0,o.jsx)($M,{packages:a,update:s,locked:r,onCheck:()=>u?.(),onUpdate:e=>d?.(e)}),(0,o.jsx)(eN,{reasons:p,canRestart:c,restarting:l,onRestart:()=>f?.()})]}),g&&(0,o.jsxs)(`section`,{children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:He?`Sandbox`:`Agent permissions`}),(0,o.jsxs)(`div`,{className:`space-y-3`,children:[!He&&(0,o.jsxs)(`p`,{"data-testid":`sandbox-project-root`,className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`This project is confined to its own folder,`,` `,(0,o.jsx)(`span`,{className:`break-all font-mono text-zinc-800 dark:text-zinc-200`,children:g.projectRoot??g.root}),`. Each open project is confined to its own. A change here applies to this project now, and to projects opened after.`]}),He&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`label`,{className:`block`,children:[(0,o.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Root `,g.locks?.root?(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`input`,{type:`text`,value:ye,onChange:e=>be(e.target.value),disabled:g.locks?.root,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:focus:border-zinc-500`}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Browse for sandbox root`,disabled:g.locks?.root,onClick:()=>Re(`root`,ye),className:`shrink-0 rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-300`,children:`Browse…`})]})]}),De===`root`&&Ue,(0,o.jsxs)(`label`,{className:`block`,children:[(0,o.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Writable root (optional) `,g.locks?.writableRoot?(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`input`,{type:`text`,value:xe,onChange:e=>Se(e.target.value),disabled:g.locks?.writableRoot,placeholder:`Same as root`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Browse for writable root`,disabled:g.locks?.writableRoot,onClick:()=>Re(`writableRoot`,xe||ye),className:`shrink-0 rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-300`,children:`Browse…`})]})]}),De===`writableRoot`&&Ue]}),(0,o.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:Ce,onChange:e=>we(e.target.checked),disabled:g.locks?.allowWrite,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,o.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow write `,g.locks?.allowWrite?(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,o.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:Te,onChange:e=>Ee(e.target.checked),disabled:g.locks?.allowBash,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,o.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow bash `,g.locks?.allowBash?(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]})]})]}),!g&&(0,o.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No sandbox configured`}),g&&(0,o.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[Fe&&(0,o.jsx)(`p`,{role:`alert`,className:`rounded-md border border-red-300 bg-red-50 px-2 py-1 text-xs text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:Fe}),(0,o.jsx)(`button`,{type:`button`,disabled:Pe||!Be||g!==null&&!ye.trim(),onClick:Ve,className:`w-full rounded-md bg-zinc-800 px-3 py-1.5 text-xs font-medium text-white hover:bg-zinc-700 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-zinc-200 dark:text-zinc-900 dark:hover:bg-zinc-300`,children:Pe?`Applying…`:`Apply & restart session`}),(0,o.jsx)(`p`,{className:`text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Saved to the server's configuration file, then the session is rebuilt — the change survives a restart.`})]}),ie&&(0,o.jsxs)(`section`,{className:`mt-4`,children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Versions`}),(0,o.jsxs)(`div`,{className:`space-y-1 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,o.jsxs)(`p`,{children:[`pi-outpost: `,(0,o.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:ie.piOutpost})]}),ie.piSdk&&(0,o.jsxs)(`p`,{children:[`pi SDK: `,(0,o.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:ie.piSdk})]}),ie.agent&&(0,o.jsxs)(`p`,{children:[`agent: `,(0,o.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:ie.agent})]})]})]})]})]}),(0,o.jsx)(gN,{open:ge,inventory:ne,operations:re,extensionLock:r,userSkillPaths:y,userExtensionPaths:n,serverBrowse:b,applyState:te,onClose:()=>{_e(!1),oe(),ve.current?.focus()},onBrowseServerPath:e=>{ee?.(),ae(e)},onCloseServerBrowser:oe,onUpdateConfig:se,onSuggestClonePath:ce,onCloneRepository:le,onEnrollRepository:ue,onSetSkills:de,onRemoveRepository:fe,onRefresh:pe,onUpdate:me})]})}function yN(e){let t=[],n=new Set,r=0,i=0;function a(e,o,s,c){let l=e.children,u=l.slice(1).map(e=>[e,r++]);u.length>0&&i++;let d=e.onPath&&!l.some(e=>e.onPath);if(t.push({node:e,lane:o,through:[...n].filter(e=>e!==o),forkTo:u.map(([,e])=>e),lineAbove:s,lineBelow:l.length>0,branchIndex:c,isCurrent:d,emphasis:d?`current`:e.onPath?`filled`:`hollow`,highlight:e.onPath}),l.length===0){n.delete(o);return}for(let[,e]of u)n.add(e);a(l[0],o,!0,u.length>0?1:void 0),u.forEach(([e,t],n)=>a(e,t,!0,n+2))}return e.length>1&&i++,e.forEach((t,i)=>{let o=r++;n.add(o),a(t,o,!1,e.length>1?i+1:void 0)}),{rows:t,laneCount:r,branchPoints:i}}function bN(e){return e.flatMap(e=>[e,...bN(e.children)])}function xN({children:e,tone:t}){let n={current:`border-emerald-300 bg-emerald-50 text-emerald-700 dark:border-emerald-800 dark:bg-emerald-950/50 dark:text-emerald-300`,branch:`border-zinc-300 text-zinc-500 dark:border-zinc-700 dark:text-zinc-400`,label:`border-violet-300 bg-violet-50 text-violet-700 dark:border-violet-900 dark:bg-violet-950/50 dark:text-violet-300`}[t];return(0,o.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var SN=`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-500 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`;function CN({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:i,onClose:a}){let{node:s}=e,c=s.tipId??s.entryId;return(0,o.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70 ${e.isCurrent?`bg-emerald-50/60 dark:bg-emerald-950/20`:``}`,style:{height:36},children:[(0,o.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>{r(c),a()},title:n?`unavailable while the agent is running`:s.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex h-full min-w-0 flex-1 items-center gap-2 pl-2 text-left text-sm disabled:opacity-50`,children:[(0,o.jsx)(DM,{row:e,laneCount:t,colorOf:wM}),(0,o.jsx)(`span`,{className:`min-w-0 truncate ${s.onPath?`text-zinc-800 dark:text-zinc-200`:`text-zinc-600 dark:text-zinc-400`}`,children:s.text||`(empty)`}),e.forkTo.length>0&&(0,o.jsxs)(xN,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,o.jsxs)(xN,{tone:`branch`,children:[`branch `,e.branchIndex,s.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,o.jsx)(xN,{tone:`current`,children:`current`}),s.label&&(0,o.jsx)(xN,{tone:`label`,children:s.label})]}),(0,o.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>{r(s.entryId),a()},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:SN,children:`↺ redo`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{i(s.entryId),a()},title:`fork a new session from this point`,className:SN,children:`⑂ fork`})]})}function wN({tree:e,isStreaming:t,onListTree:n,onNavigate:r,onFork:a}){let[s,c]=(0,i.useState)(!1),[l,u]=(0,i.useState)(``),d=wj(()=>c(!1));(0,i.useEffect)(()=>{s&&e===null&&n()},[s,e]);let f=(0,i.useMemo)(()=>e&&e.length>0?yN(e):null,[e]),p=(0,i.useMemo)(()=>{if(!e||!l.trim())return null;let t=l.trim().toLowerCase();return bN(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,l]);return(0,o.jsxs)(`div`,{className:`relative`,ref:d,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{c(!s),s||(u(``),n())},title:`conversation tree: go back to an earlier point or fork`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`tree`}),s&&(0,o.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[70vh] w-[32rem] max-w-[90vw] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl [--tree-off:#e4e4e7] dark:border-zinc-700 dark:bg-zinc-900 dark:[--tree-off:#3f3f46]`,children:[e===null&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&f&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,o.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,o.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,o.jsxs)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:[f.rows.length,` turn`,f.rows.length===1?``:`s`,` · `,f.branchPoints,` branch point`,f.branchPoints===1?``:`s`]})]}),(0,o.jsx)(`input`,{type:`search`,value:l,onChange:e=>u(e.target.value),placeholder:`Search tree`,"aria-label":`Search conversation tree`,className:`mt-2 w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,o.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Follow the colored lines — the current branch is highlighted. Click a turn to restore the conversation there · ↺ to send it again · ⑂ to fork a session`})]}),(0,o.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:p===null?f.rows.map(e=>(0,o.jsx)(CN,{row:e,laneCount:f.laneCount,isStreaming:t,onNavigate:r,onFork:a,onClose:()=>c(!1)},e.node.entryId)):p.length===0?(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):p.map(e=>(0,o.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,o.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>{r(e.tipId??e.entryId),c(!1)},title:e.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left text-sm disabled:opacity-50`,children:[(0,o.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,o.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,o.jsx)(xN,{tone:`current`,children:`on current branch`}),e.label&&(0,o.jsx)(xN,{tone:`label`,children:e.label})]}),(0,o.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>{r(e.entryId),c(!1)},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:SN,children:`↺ redo`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{a(e.entryId),c(!1)},title:`fork a new session from this point`,className:SN,children:`⑂ fork`})]},e.entryId))})]})]})]})}var TN=200;function EN({initial:e,onCommit:t,onCancel:n}){let[r,a]=(0,i.useState)(e);return(0,o.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>a(e.target.value),onBlur:n,onKeyDown:e=>{e.key===`Enter`?t(r):e.key===`Escape`&&n()},placeholder:`Session name (empty to clear)`,"aria-label":`Session name`,className:`w-full rounded-md border border-zinc-400 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 dark:border-zinc-600 dark:placeholder:text-zinc-600`})}function DN({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:i,onStartRename:a,onRename:s,onCancelRename:c}){return n?(0,o.jsx)(`div`,{className:`px-3 py-2`,children:(0,o.jsx)(EN,{initial:e.name??``,onCommit:s,onCancel:c})}):(0,o.jsxs)(`div`,{className:`group flex items-start gap-1 hover:bg-zinc-100 dark:hover:bg-zinc-800 ${t?`bg-zinc-100 dark:bg-zinc-800/60`:``}`,children:[(0,o.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,o.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,o.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,o.jsxs)(`div`,{className:`mt-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:[new Date(e.modified).toLocaleString(),` · `,e.messageCount,` messages`,t?` · current`:``,!t&&e.liveIn?(0,o.jsxs)(`span`,{"data-testid":`session-live-in`,children:[` · open in `,e.liveIn]}):null]})]}),(0,o.jsx)(`button`,{type:`button`,onClick:a,title:`rename session`,"aria-label":`Rename session`,className:`mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`,children:`✎`}),!t&&!e.liveIn&&(0,o.jsx)(`button`,{type:`button`,onClick:i,title:`delete session`,"aria-label":`Delete session`,className:`mr-2 mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-red-100 hover:text-red-600 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-red-950/60 dark:hover:text-red-400`,children:`✕`})]})}function ON({sessions:e,sessionSearch:t,sessionId:n,onSwitchSession:r,onDeleteSession:a,onListSessions:s,onRenameSession:c,onSearchSessions:l,onClearSessionSearch:u}){let[d,f]=(0,i.useState)(!1),[p,m]=(0,i.useState)(``),[h,g]=(0,i.useState)(null),_=wj(()=>f(!1)),v=p.trim(),y=v.length>=2;(0,i.useEffect)(()=>{if(!d)return;if(!y){u();return}let e=setTimeout(()=>l(v),TN);return()=>clearTimeout(e)},[d,v,y]);function b(){f(!1),g(null)}let x=y&&(t?.status!==`loaded`||t.query!==v),ee=y?x?null:t?.results??null:e;return(0,o.jsxs)(`div`,{className:`relative`,ref:_,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{if(d){b();return}f(!0),m(``),g(null),u(),s()},className:`rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`sessions`}),d&&(0,o.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-96 w-96 flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,o.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,o.jsx)(`input`,{type:`search`,value:p,onChange:e=>m(e.target.value),placeholder:`Search sessions`,"aria-label":`Search sessions`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,o.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Searches names and everything said in a session · ✎ to rename`})]}),(0,o.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[ee===null&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),ee?.length===0&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:y?`no matches`:`no saved sessions`}),ee?.map(e=>(0,o.jsx)(DN,{session:e,isCurrent:e.id===n,renaming:h===e.path,onSwitch:()=>{r(e.path),b()},onDelete:()=>{window.confirm(`Delete this session?`)&&a(e.path)},onStartRename:()=>g(e.path),onRename:t=>{c(e.path,t),g(null),y&&l(p.trim())},onCancelRename:()=>g(null)},e.path))]})]})]})}function kN({filters:e,onFilterChange:t}){let[n,r]=(0,i.useState)(!1),a=wj(()=>r(!1)),s=qA(e),c=s>0?`Filter · ${s} hidden`:`Filter`;return(0,o.jsxs)(`div`,{className:`relative`,ref:a,onKeyDown:e=>{e.key===`Escape`&&n&&(e.stopPropagation(),r(!1))},children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>r(!n),"aria-haspopup":`menu`,"aria-expanded":n,title:`Choose what the conversation shows`,className:`rounded-md border px-2 py-1 text-xs ${s>0?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:c}),n&&(0,o.jsx)(`div`,{role:`menu`,className:`absolute right-0 z-30 mt-1 w-48 rounded-md border border-zinc-200 bg-white py-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:HA.map(n=>(0,o.jsxs)(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":e[n],onClick:()=>t(n,!e[n]),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-zinc-600 hover:bg-zinc-100 dark:text-zinc-300 dark:hover:bg-zinc-800`,children:[(0,o.jsx)(`span`,{"aria-hidden":!0,className:`w-3`,children:e[n]?`✓`:``}),(0,o.jsx)(`span`,{children:UA[n]})]},n))})]})}function AN({theme:e,onToggle:t}){return(0,o.jsx)(`button`,{type:`button`,onClick:t,title:e===`dark`?`Switch to light theme`:`Switch to dark theme`,"aria-label":e===`dark`?`Switch to light theme`:`Switch to dark theme`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:e===`dark`?`☀`:`☾`})}function jN(e){let{isStreaming:t,connected:n}=e;return(0,o.jsxs)(`header`,{className:`relative z-30 flex items-center gap-3 border-b border-zinc-200 px-4 py-2.5 dark:border-zinc-800`,children:[e.workspaceControl===`projects`&&(0,o.jsx)(GM,{workspace:e.workspace,workspaces:e.workspaces,locked:e.workspaceLocked,onSwitch:e.onSwitchWorkspace,onOpen:e.onOpenProject,onClose:e.onCloseProject,onOpenSide:e.onOpenSideSession}),e.workspaceControl===`root`&&e.rootControl&&(0,o.jsx)(JM,{sandbox:e.rootControl.sandbox,browse:e.rootControl.browse,applyState:e.rootControl.applyState,blocked:e.rootControl.blocked,onBrowse:e.rootControl.onBrowse,onCloseBrowser:e.rootControl.onCloseBrowser,onOpened:e.rootControl.onOpened,onSelect:e.rootControl.onSelect}),(0,o.jsxs)(`button`,{type:`button`,onClick:e.onToggleSidebar,title:e.sidebarOpen?`Hide files (panel opens on the left)`:`Show files`,"aria-pressed":e.sidebarOpen,className:`rounded-md border px-2 py-1 text-xs ${e.sidebarOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:[e.sidebarOpen?`◧`:`◨`,` files`]}),(0,o.jsxs)(`button`,{type:`button`,onClick:e.onToggleOutcome,"aria-pressed":e.outcomeOpen,title:`Review structured workspace Outcome`,className:`rounded-md border px-2 py-1 text-xs ${e.outcomeOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:e.workspace?.activity===`ready-for-review`?`border-amber-400 text-amber-700 dark:text-amber-300`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 dark:border-zinc-800 dark:text-zinc-400`}`,children:[`Outcome`,e.workspace?.activity===`ready-for-review`?` •`:``]}),e.gitAvailable&&(0,o.jsx)(ZM,{status:e.gitStatus,selected:e.gitSelectedPath,log:e.gitLog,onFetchLog:e.onFetchGitLog,onShowCommit:e.onShowCommit}),(0,o.jsx)(`span`,{className:`text-lg font-semibold tracking-tight`,style:{color:`var(--accent, inherit)`},children:e.title??`π`}),Object.entries(e.statuses).map(([e,t])=>(0,o.jsx)(`span`,{className:`rounded-md border border-zinc-200 px-2 py-1 text-xs text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:Yj(t)},e)),(0,o.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,o.jsx)(kN,{filters:e.filters,onFilterChange:e.onFilterChange}),e.onToggleTerminal&&(0,o.jsx)(`button`,{type:`button`,onClick:e.onToggleTerminal,title:e.terminalOpen?"Close Terminal (Ctrl+`)":"Open Terminal (Ctrl+`)","aria-pressed":e.terminalOpen,className:`rounded-md border px-2 py-1 text-xs ${e.terminalOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:`>_ terminal`}),e.showThemeToggle&&(0,o.jsx)(AN,{theme:e.theme,onToggle:e.onToggleTheme}),(0,o.jsx)(`button`,{type:`button`,onClick:e.onNewSession,title:`new session`,className:`rounded-md border border-emerald-300 px-2 py-1 text-xs text-emerald-700 hover:border-emerald-500 hover:text-emerald-600 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600 dark:hover:text-emerald-300`,children:`+ new`}),(0,o.jsx)(wN,{tree:e.tree,isStreaming:t,onListTree:e.onListTree,onNavigate:e.onNavigateTree,onFork:e.onForkSession}),(0,o.jsx)(ON,{sessions:e.sessions,sessionSearch:e.sessionSearch,sessionId:e.sessionId,onSwitchSession:e.onSwitchSession,onDeleteSession:e.onDeleteSession,onListSessions:e.onListSessions,onRenameSession:e.onRenameSession,onSearchSessions:e.onSearchSessions,onClearSessionSearch:e.onClearSessionSearch}),(0,o.jsx)(vN,{extensionPaths:e.extensionPaths,configuredExtensionPaths:e.configuredExtensionPaths,userExtensionPaths:e.userExtensionPaths,extensionLock:e.extensionLock,piPackages:e.piPackages??null,piPackageUpdate:e.piPackageUpdate??null,canRestartServer:e.canRestartServer??!1,serverRestarting:e.serverRestarting??!1,...e.onCheckPiPackages?{onCheckPiPackages:e.onCheckPiPackages}:{},...e.onUpdatePiPackage?{onUpdatePiPackage:e.onUpdatePiPackage}:{},...e.onRestartServer?{onRestartServer:e.onRestartServer}:{},restartNeeded:e.restartNeeded??[],tools:e.tools??[],commands:e.commands??[],sandbox:e.sandbox,showRoots:!(e.workspaceControl===`projects`&&e.workspaces.filter(e=>!e.sideOf).length>1),gitUnavailable:e.gitUnavailable,userSkillPaths:e.userSkillPaths,serverBrowse:e.serverBrowse,applyState:e.settingsApply,agentResources:e.agentResources,agentResourceOperations:e.agentResourceOperations,versions:e.versions,onBrowseServerPath:e.onBrowseServerPath,onCloseServerBrowser:e.onCloseServerBrowser,pickerBlocked:e.settingsPickerBlocked,onPickerOpened:e.onSettingsPickerOpened,onUpdateConfig:e.onUpdateConfig,onSuggestAgentResourceClonePath:e.onSuggestAgentResourceClonePath,onCloneAgentResourceRepository:e.onCloneAgentResourceRepository,onEnrollAgentResourceRepository:e.onEnrollAgentResourceRepository,onSetAgentResourceSkills:e.onSetAgentResourceSkills,onRemoveAgentResourceRepository:e.onRemoveAgentResourceRepository,onRefreshAgentResourceRepositories:e.onRefreshAgentResourceRepositories,onUpdateAgentResourceRepository:e.onUpdateAgentResourceRepository}),(0,o.jsx)(`span`,{className:`h-2 w-2 rounded-full ${n?`bg-emerald-500`:`bg-red-500`}`,title:n?`connected`:`disconnected`})]})]})}function MN(e,t){let n=(0,i.useRef)(new Map);(0,i.useEffect)(()=>{if(typeof Notification>`u`)return;let r=e.filter(e=>e.needsAttention),i=r.filter(e=>lA(e)!==t);for(let e of[...n.current.keys()])r.some(t=>lA(t)===e)||n.current.delete(e);if(Notification.permission===`granted`&&!(typeof document<`u`&&document.visibilityState===`visible`)){for(let e of i)if(n.current.get(lA(e))!==e.activity){n.current.set(lA(e),e.activity);try{let t=e.activity===`ready-for-review`;new Notification(t?`${e.name} is ready for review`:`${e.name} needs you`,{body:t?`Background work is ready for review.`:`The agent needs an answer to continue.`,tag:`pi-outpost:${lA(e)}`})}catch{}}}},[e,t])}function NN(e){return!e||e.percent===null?`text-zinc-400 dark:text-zinc-600`:e.percent>=85?`text-red-500`:e.percent>=60?`text-amber-500 dark:text-amber-400`:`text-emerald-500`}function PN({usage:e,analysisOpen:t,onToggleAnalysis:n}){if(e.turns===0)return null;let r=e.turns-e.unpriced,i=[`${e.turns} turn${e.turns===1?``:`s`}`,`input ${e.input.toLocaleString()}`,`output ${e.output.toLocaleString()}`,`cache read ${e.cacheRead.toLocaleString()}`,`cache write ${e.cacheWrite.toLocaleString()}`,...e.unpriced>0&&r>0?[`${e.unpriced} unpriced`]:[]].join(` · `),a=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`span`,{children:[pA(e.totalTokens),` tok`]}),r>0&&(0,o.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:[fA(e.cost),e.unpriced>0&&`*`]})]}),s=`flex items-center gap-1.5 rounded-md border px-2 py-1 font-mono text-xs text-zinc-500 dark:text-zinc-400`;return n?(0,o.jsx)(`button`,{type:`button`,onClick:n,title:`${i} — click for the session analysis`,"aria-haspopup":`dialog`,"aria-expanded":t??!1,className:`${s} ${t?`border-zinc-400 dark:border-zinc-600`:`border-zinc-300 hover:border-zinc-400 dark:border-zinc-800 dark:hover:border-zinc-600`}`,children:a}):(0,o.jsx)(`span`,{title:i,className:`${s} border-zinc-300 dark:border-zinc-800`,children:a})}function FN({usage:e}){let t=15.9155,n=2*Math.PI*t,r=e?.percent??0,i=Math.min(100,Math.max(0,r))/100*n;return(0,o.jsxs)(`svg`,{width:18,height:18,viewBox:`0 0 36 36`,className:`-rotate-90 shrink-0`,children:[(0,o.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,className:`text-zinc-200 dark:text-zinc-800`}),e&&e.percent!==null&&(0,o.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,strokeLinecap:`round`,strokeDasharray:`${i} ${n-i}`,className:NN(e)})]})}function IN({thinkingLevel:e,thinkingLevels:t,isStreaming:n,onSetThinking:r}){let[a,s]=(0,i.useState)(!1),c=(0,i.useRef)(null),l=e!==`off`,u=t&&t.length>0?t:dM,d=u.indexOf(e),f=u.length>1;return(0,i.useEffect)(()=>{if(!a)return;function e(e){c.current&&!Cj(e,c.current)&&s(!1)}function t(e){e.key===`Escape`&&s(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a]),(0,o.jsxs)(`div`,{className:`relative`,ref:c,children:[(0,o.jsxs)(`button`,{type:`button`,onClick:()=>s(!a),disabled:n,title:`thinking level`,"aria-haspopup":`true`,"aria-expanded":a,className:`flex items-center gap-1.5 rounded-md border px-2 py-1 font-mono text-xs disabled:opacity-50 ${l?`border-amber-300 text-amber-700 hover:border-amber-400 dark:border-amber-900 dark:text-amber-400 dark:hover:border-amber-700`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600`}`,children:[(0,o.jsx)(`span`,{"aria-hidden":!0,className:`text-sm leading-none ${l?``:`opacity-40 grayscale`}`,children:`🧠`}),e]}),a&&(0,o.jsxs)(`div`,{className:`absolute bottom-full left-0 z-20 mb-1 w-48 rounded-lg border border-zinc-200 bg-white p-3 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,o.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between text-xs`,children:[(0,o.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`thinking`}),(0,o.jsx)(`span`,{className:`font-mono text-zinc-700 dark:text-zinc-200`,children:e})]}),f?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`input`,{type:`range`,min:0,max:u.length-1,step:1,value:d===-1?0:d,onChange:e=>r(u[Number(e.target.value)]),"aria-label":`Thinking level`,"aria-valuetext":e,className:`w-full accent-amber-500`}),(0,o.jsxs)(`div`,{className:`mt-0.5 flex justify-between font-mono text-[9px] text-zinc-400 dark:text-zinc-600`,children:[(0,o.jsx)(`span`,{children:u[0]}),(0,o.jsx)(`span`,{children:u[u.length-1]})]})]}):(0,o.jsxs)(`p`,{className:`text-[11px] text-zinc-500 dark:text-zinc-400`,children:[`this model accepts `,(0,o.jsx)(`span`,{className:`font-mono`,children:u[0]}),` only`]})]})]})}function LN(e){let{model:t,models:n,thinkingLevel:r,modelSupportsReasoning:i,isStreaming:a,contextUsage:s,sessionUsage:c,isCompacting:l}=e;return(0,o.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,o.jsxs)(`select`,{value:t,onChange:t=>{let r=n.find(e=>`${e.provider}/${e.id}`===t.target.value);r&&e.onSetModel(r.provider,r.id)},disabled:a,className:`max-w-64 rounded-md border border-zinc-300 bg-white px-2 py-1 font-mono text-xs text-zinc-700 outline-none hover:border-zinc-400 disabled:opacity-50 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-300 dark:hover:border-zinc-600`,children:[!n.some(e=>`${e.provider}/${e.id}`===t)&&(0,o.jsx)(`option`,{value:t,children:t}),n.map(e=>(0,o.jsxs)(`option`,{value:`${e.provider}/${e.id}`,children:[e.provider,`/`,e.id]},`${e.provider}/${e.id}`))]}),i&&(0,o.jsx)(IN,{thinkingLevel:r,thinkingLevels:e.thinkingLevels,isStreaming:a,onSetThinking:e.onSetThinking}),(0,o.jsxs)(`button`,{type:`button`,onClick:e.onCompact,disabled:a||l,title:s?.tokens==null?`Click to compact the conversation context`:`${s.tokens.toLocaleString()} / ${s.contextWindow.toLocaleString()} tokens — click to compact`,className:`ml-auto flex items-center gap-1.5 rounded-md border border-zinc-300 px-2 py-1 font-mono text-xs text-zinc-500 hover:border-zinc-400 disabled:opacity-50 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600`,children:[(0,o.jsx)(FN,{usage:s}),l?`compacting…`:s?.percent==null?`context`:`${Math.round(s.percent)}%`]}),(0,o.jsx)(PN,{usage:c,analysisOpen:e.analysisOpen,onToggleAnalysis:e.onToggleAnalysis})]})}var RN=`w-full rounded-md border border-zinc-300 bg-white px-3 py-2 text-sm text-zinc-800 placeholder:text-zinc-400 focus:border-zinc-400 focus:outline-none dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-100 dark:placeholder:text-zinc-600`,zN=`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`;function BN({title:e,credentials:t,onSetCredential:n,onDeclareProvider:r,errors:a}){let s=t.providers,[c,l]=(0,i.useState)(s.length>0?`known`:`custom`),[u,d]=(0,i.useState)(s[0]?.id??``),[f,p]=(0,i.useState)(``),[m,h]=(0,i.useState)(``),[g,_]=(0,i.useState)(``),[v,y]=(0,i.useState)(``),[b,x]=(0,i.useState)(!0),[ee,te]=(0,i.useState)(!0),ne=s.some(e=>e.configured)&&!t.usableModel;function re(e){if(e.preventDefault(),!ne){if(c===`known`){u&&f.trim()&&n(u,f.trim());return}!m.trim()||!g.trim()||!f.trim()||!v.trim()||r({provider:m.trim(),baseUrl:g.trim(),apiKey:f.trim(),models:[v.trim()],compat:{supportsDeveloperRole:b,supportsReasoningEffort:ee}})}}return(0,o.jsx)(`div`,{className:`flex h-full items-center justify-center overflow-auto p-6`,children:(0,o.jsxs)(`form`,{onSubmit:re,className:`w-full max-w-md rounded-xl border border-zinc-200 p-6 shadow-sm dark:border-zinc-800`,children:[(0,o.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),ne?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`h1`,{className:`mb-3 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model is available.`}),(0,o.jsxs)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:[`Credentials are configured, so this is not a missing key: `,(0,o.jsx)(`code`,{children:`allowedModels`}),` in your configuration leaves nothing to choose from. Widen it, or remove it, then restart.`]})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model provider is set up yet. Add one to start chatting.`}),(0,o.jsx)(`div`,{className:`mb-4 flex gap-1 rounded-lg bg-zinc-100 p-1 text-xs dark:bg-zinc-800`,children:[`known`,`custom`].map(e=>(0,o.jsx)(`button`,{type:`button`,onClick:()=>l(e),className:`flex-1 rounded-md px-2 py-1.5 ${c===e?`bg-white font-medium text-zinc-800 shadow-sm dark:bg-zinc-900 dark:text-zinc-100`:`text-zinc-500 dark:text-zinc-400`}`,children:e===`known`?`Provider API key`:`OpenAI-compatible endpoint`},e))}),c===`known`?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`label`,{htmlFor:`onboarding-provider`,className:zN,children:`Provider`}),(0,o.jsx)(`select`,{id:`onboarding-provider`,value:u,onChange:e=>d(e.target.value),className:`${RN} mb-3`,children:s.map(e=>(0,o.jsxs)(`option`,{value:e.id,children:[e.name,e.configured?` (already configured)`:``]},e.id))})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`label`,{htmlFor:`onboarding-name`,className:zN,children:`Name`}),(0,o.jsx)(`input`,{id:`onboarding-name`,value:m,onChange:e=>h(e.target.value),placeholder:`corp`,className:`${RN} mb-3`}),(0,o.jsx)(`label`,{htmlFor:`onboarding-url`,className:zN,children:`Base URL`}),(0,o.jsx)(`input`,{id:`onboarding-url`,value:g,onChange:e=>_(e.target.value),placeholder:`https://llm.corp.example/v1`,className:`${RN} mb-3`}),(0,o.jsx)(`label`,{htmlFor:`onboarding-model`,className:zN,children:`Model id`}),(0,o.jsx)(`input`,{id:`onboarding-model`,value:v,onChange:e=>y(e.target.value),placeholder:`gpt-oss-120b`,className:`${RN} mb-3`})]}),(0,o.jsx)(`label`,{htmlFor:`onboarding-key`,className:zN,children:`API key`}),(0,o.jsx)(`input`,{id:`onboarding-key`,type:`password`,autoComplete:`off`,value:f,onChange:e=>p(e.target.value),placeholder:`sk-…`,className:RN}),c===`custom`&&(0,o.jsxs)(`fieldset`,{className:`mt-4 rounded-lg border border-zinc-200 p-3 dark:border-zinc-800`,children:[(0,o.jsx)(`legend`,{className:`px-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Compatibility`}),(0,o.jsxs)(`label`,{className:`flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:b,onChange:e=>x(e.target.checked),className:`mt-0.5`}),(0,o.jsxs)(`span`,{children:[`Server understands the `,(0,o.jsx)(`code`,{children:`developer`}),` role. Uncheck for vLLM, SGLang and most corporate gateways — the system prompt is then sent as a `,(0,o.jsx)(`code`,{children:`system`}),` message.`]})]}),(0,o.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:ee,onChange:e=>te(e.target.checked),className:`mt-0.5`}),(0,o.jsxs)(`span`,{children:[`Server accepts `,(0,o.jsx)(`code`,{children:`reasoning_effort`}),`. Uncheck if it rejects unknown fields.`]})]})]}),(0,o.jsx)(`button`,{type:`submit`,className:`mt-4 w-full rounded-md bg-zinc-800 px-3 py-2 text-sm font-medium text-white hover:bg-zinc-700 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white`,children:`Save and start`})]}),a.map((e,t)=>(0,o.jsx)(`p`,{className:`mt-3 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:e},t)),(0,o.jsxs)(`p`,{className:`mt-4 text-center text-xs text-zinc-400 dark:text-zinc-600`,children:[t.agentDir?`Stored in ${t.agentDir}. `:``,`Provider environment variables work too, as does `,(0,o.jsx)(`code`,{children:`pi-outpost login`}),`.`]})]})})}var VN=`application/x-pi-outpost-file`,HN=`application/x-pi-outpost-read-only-file`,UN=`mr-1 shrink-0 rounded px-1 text-xs text-zinc-400 hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 [@media(hover:hover)]:opacity-0`,WN={modified:{label:`M`,className:`text-amber-600 dark:text-amber-400`},added:{label:`A`,className:`text-emerald-600 dark:text-emerald-400`},untracked:{label:`U`,className:`text-emerald-600 dark:text-emerald-400`},deleted:{label:`D`,className:`text-red-600 dark:text-red-400`},conflicted:{label:`C`,className:`text-purple-600 dark:text-purple-400`}};function GN(e,t){return t?Object.keys(t).filter(t=>t.startsWith(`${e}/`)).length:0}function KN(e){return e===`directory`||e===`symlink-directory`}function qN(e,t){return t===void 0?!1:t===null||t!==``&&e!==t&&!e.startsWith(`${t}/`)}function JN({dir:e,depth:t,creation:n}){let[r,a]=(0,i.useState)(``),s=(0,i.useRef)(null),c=n.localError??n.serverError;return(0,i.useEffect)(()=>{s.current?.focus()},[]),(0,o.jsxs)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5`,children:[(0,o.jsx)(`input`,{ref:s,value:r,onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),n.submit(e,r)):t.key===`Escape`&&(t.preventDefault(),n.cancel())},onBlur:()=>{c===null&&n.cancel()},placeholder:`name, or name/ for a folder`,"aria-label":`New file or folder in ${e===``?`the workspace root`:e}`,spellCheck:!1,className:`w-full rounded border border-zinc-300 bg-white px-1 py-0.5 text-xs text-zinc-800 outline-none focus:border-zinc-400 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200`}),c!==null&&(0,o.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:c})]})}function YN({path:e,name:t,depth:n,rename:r}){let[a,s]=(0,i.useState)(t),c=(0,i.useRef)(null),l=r.localError??r.serverError;return(0,i.useEffect)(()=>{c.current?.focus(),c.current?.select()},[]),(0,o.jsxs)(`div`,{style:{paddingLeft:n*12+16},className:`py-0.5`,children:[(0,o.jsx)(`input`,{ref:c,value:a,disabled:r.pending,onChange:e=>s(e.target.value),onKeyDown:t=>{t.key===`Enter`&&!r.pending?(t.preventDefault(),r.submit(e,a)):t.key===`Escape`&&(t.preventDefault(),r.cancel())},onBlur:()=>{l===null&&r.cancel()},"aria-label":`Rename ${t}`,spellCheck:!1,className:`w-full rounded border border-zinc-300 bg-white px-1 py-0.5 text-xs text-zinc-800 outline-none focus:border-zinc-400 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200`}),l!==null&&(0,o.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:l})]})}function XN({path:e,depth:t,...n}){let r=n.tree[e],i=n.creation?.openIn===e?(0,o.jsx)(JN,{dir:e,depth:t,creation:n.creation}):null;return r===void 0?i:r===`loading`?(0,o.jsxs)(o.Fragment,{children:[i,(0,o.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`loading…`})]}):`error`in r?(0,o.jsxs)(o.Fragment,{children:[i,(0,o.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-red-600 dark:text-red-400`,children:r.error})]}):r.length===0?(0,o.jsxs)(o.Fragment,{children:[i,i===null&&(0,o.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`empty`})]}):(0,o.jsxs)(o.Fragment,{children:[i,r.map(r=>(0,o.jsx)(ZN,{parentPath:e,entry:r,depth:t,...n},r.name))]})}function ZN({parentPath:e,entry:t,depth:n,...r}){let[a,s]=(0,i.useState)(!1),[c,l]=(0,i.useState)(!1),u=e?`${e}/${t.name}`:t.name,d=qN(u,r.writableRoot),f=r.fileOperation?.status===`pending`;if(KN(t.type)){let e=!d&&!f,i=e=>e.includes(HN)?r.onCopyFile===void 0?null:`copy`:r.onMoveFile===void 0?null:`move`;return(0,o.jsxs)(`div`,{children:[(0,o.jsxs)(`div`,{className:`group flex w-full items-center rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${c?`bg-blue-50 ring-1 ring-blue-400 dark:bg-blue-950/40`:``}`,onDragOver:t=>{if(!e||!Array.from(t.dataTransfer.types).includes(VN))return;let n=i(Array.from(t.dataTransfer.types));n!==null&&(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=n,l(!0))},onDragLeave:()=>l(!1),onDrop:t=>{if(!e)return;let n=t.dataTransfer.getData(VN),a=n?i(Array.from(t.dataTransfer.types)):null;a!==null&&(t.preventDefault(),t.stopPropagation(),l(!1),a===`copy`?r.onCopyFile?.(n,u):r.onMoveFile?.(n,u))},children:[(0,o.jsxs)(`button`,{type:`button`,onClick:()=>{let e=!a;s(e),e&&r.tree[u]===void 0&&r.onExpand(u),r.onSelectDirectory?.(u)},style:{paddingLeft:n*12},className:`flex min-w-0 flex-1 items-center gap-1 rounded py-0.5 text-left`,children:[(0,o.jsx)(`span`,{className:`w-3 shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:a?`▾`:`▸`}),(0,o.jsx)(`span`,{title:t.name,className:`truncate ${d?`text-zinc-400 dark:text-zinc-600`:`text-zinc-700 dark:text-zinc-300`}`,children:t.name}),!a&&GN(u,r.gitFiles)>0&&(0,o.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-amber-100 px-1 font-mono text-[10px] font-bold text-amber-700 dark:bg-amber-950/60 dark:text-amber-400`,title:`${GN(u,r.gitFiles)} changed file(s) inside`,children:GN(u,r.gitFiles)})]}),r.creation&&!d&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>{s(!0),r.tree[u]===void 0&&r.onExpand(u),r.creation?.start(u)},title:`New file or folder here`,"aria-label":`New file or folder in ${t.name}`,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs text-zinc-400 hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 [@media(hover:hover)]:opacity-0`,children:`+`})]}),a&&(0,o.jsx)(XN,{path:u,depth:n+1,...r})]})}let p=u===r.openFilePath,m=r.gitFiles?.[u],h=r.attachedPaths?.includes(u)??!1,g=t.type===`file`,_=g||t.type===`symlink-file`,v=g&&!d,y=g&&(d?r.onCopyFile!==void 0:r.onMoveFile!==void 0);return r.rename?.path===u?(0,o.jsx)(YN,{path:u,name:t.name,depth:n,rename:r.rename}):(0,o.jsxs)(`div`,{className:`group flex w-full items-center rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${p?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:[(0,o.jsx)(`button`,{type:`button`,draggable:y&&!f,onDragStart:e=>{!y||f||(e.dataTransfer.effectAllowed=d?`copy`:`move`,e.dataTransfer.setData(VN,u),d&&e.dataTransfer.setData(HN,`copy`))},onClick:()=>r.onSelectFile(u),style:{paddingLeft:n*12+16},className:`flex min-w-0 flex-1 items-center py-0.5 text-left`,children:(0,o.jsx)(`span`,{title:t.name,className:`truncate ${d?`text-zinc-400 dark:text-zinc-600`:`text-zinc-600 dark:text-zinc-400`}`,children:t.name})}),_&&r.onOpenNative&&(0,o.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>r.onOpenNative?.(u),title:`Open with the associated application`,"aria-label":`Open ${t.name} with the associated application`,className:UN,children:`↗`}),v&&r.onRenameFile&&(0,o.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>r.rename?.start(u),title:`Rename file`,"aria-label":`Rename ${t.name}`,className:UN,children:`✎`}),v&&r.onDeleteFile&&(0,o.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>{window.confirm(`Delete "${t.name}" permanently?`)&&r.onDeleteFile?.(u)},title:`Delete file`,"aria-label":`Delete ${t.name}`,className:`${UN} hover:text-red-600 dark:hover:text-red-400`,children:`×`}),r.onToggleAttachPath&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>r.onToggleAttachPath?.(u),title:h?`Remove this file from the prompt`:`Reference this file in the prompt`,"aria-label":`${h?`Remove`:`Reference`} ${t.name} in the prompt`,"aria-pressed":h,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:hover:bg-zinc-700 ${h?`font-bold text-blue-600 dark:text-blue-400`:`text-zinc-400 dark:text-zinc-600 [@media(hover:hover)]:opacity-0`}`,children:`@`}),m&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>(r.onSelectDiff??r.onSelectFile)(u),title:`Show uncommitted diff`,"aria-label":`Show diff of ${t.name}`,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs font-bold hover:bg-zinc-200 dark:hover:bg-zinc-700 ${WN[m].className}`,children:WN[m].label})]})}function QN(e){let t=e.trim();if(t===``)return{error:`A name is required`};let n=t.endsWith(`/`),r=n?t.slice(0,-1).trim():t;return r===``?{error:`A name is required`}:r.includes(`/`)||r.includes(`\\`)?{error:`That is a path, not a name`}:r===`.`||r===`..`?{error:`"${r}" is not a name`}:{kind:n?`directory`:`file`,name:r}}function $N(e){let t=QN(e);return`error`in t?t:t.kind===`directory`?{error:`That is a folder name`}:{name:t.name}}function eP(e){let[t,n]=(0,i.useState)(null),[r,a]=(0,i.useState)(null),[s,c]=(0,i.useState)(null),[l,u]=(0,i.useState)(null),[d,f]=(0,i.useState)(null),[p,m]=(0,i.useState)(null),h=e.onCreateFile!==void 0||e.onCreateDirectory!==void 0,g=e.createError&&s&&e.createError.path===tP(s.dir,s.name)?e.createError.message:null,_=e.created??null;(0,i.useEffect)(()=>{s!==null&&_!==null&&_===tP(s.dir,s.name)&&(n(null),c(null),a(null))},[s,_]);let v=e.fileOperation?.status===`error`&&e.fileOperation.operation===`rename_file`&&p===e.fileOperation.path?e.fileOperation.message:null;(0,i.useEffect)(()=>{let t=e.fileOperation;t?.status===`succeeded`&&t.operation===`rename_file`&&p===t.path&&(u(null),m(null),f(null))},[p,e.fileOperation]);let y=h?{openIn:t,localError:r,serverError:g,start:e=>{n(e),a(null),c(null)},cancel:()=>{n(null),a(null),c(null)},submit:(t,n)=>{let r=QN(n);if(`error`in r){a(r.error);return}a(null),c({dir:t,name:r.name});let i=tP(t,r.name);r.kind===`directory`?e.onCreateDirectory?.(i):e.onCreateFile?.(i)}}:void 0,b=e.onRenameFile?{path:l,pending:p!==null&&e.fileOperation?.status===`pending`&&e.fileOperation.operation===`rename_file`&&e.fileOperation.path===p,localError:d,serverError:v,start:e=>{u(e),m(null),f(null)},cancel:()=>{u(null),m(null),f(null)},submit:(t,n)=>{if(n.trim()===``){u(null),m(null),f(null);return}let r=$N(n);if(`error`in r){f(r.error);return}f(null),m(t),e.onRenameFile?.(t,r.name)}}:void 0,x=!qN(``,e.writableRoot);return(0,o.jsxs)(`div`,{className:`text-sm`,children:[e.fileOperation?.status===`error`&&e.fileOperation.operation!==`rename_file`&&(0,o.jsx)(`p`,{role:`alert`,className:`mb-1 rounded bg-red-50 px-2 py-1 text-xs text-red-700 dark:bg-red-950/40 dark:text-red-300`,children:e.fileOperation.message}),(y&&x||e.onRefresh)&&(0,o.jsxs)(`div`,{className:`mb-1 flex items-center`,children:[y&&x&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>y.start(``),"aria-label":`New file or folder in the workspace root`,className:`rounded px-1 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-600 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-400`,children:`+ new`}),e.onRefresh&&(0,o.jsx)(`button`,{type:`button`,onClick:e.onRefresh,title:`Refresh the file tree`,"aria-label":`Refresh the file tree`,className:`ml-auto rounded px-1 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-600 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-400`,children:`↻`})]}),(0,o.jsx)(XN,{path:``,depth:0,...e,...y?{creation:y}:{},...b?{rename:b}:{}})]})}function tP(e,t){return e===``?t:`${e}/${t}`}function nP({tree:e,openFile:t,writableRoot:n,gitFiles:r,attachedPaths:a,onExpand:s,onSelectDirectory:c,onRefresh:l,onSelectFile:u,onSelectDiff:d,onToggleAttachPath:f,onCreateFile:p,onCreateDirectory:m,onOpenNative:h,onRenameFile:g,onDeleteFile:_,onMoveFile:v,onCopyFile:y,fileOperation:b,createError:x,created:ee}){let te=yM(pM);return(0,i.useEffect)(()=>{e[``]===void 0&&s(``)},[]),(0,o.jsxs)(`aside`,{"aria-label":`Files`,style:{width:te.width},className:`relative flex shrink-0 flex-col border-r border-zinc-200 dark:border-zinc-800`,children:[(0,o.jsx)(`div`,{className:`border-b border-zinc-200 px-3 py-2 text-xs font-semibold uppercase text-zinc-400 dark:border-zinc-800 dark:text-zinc-600`,children:`Files`}),(0,o.jsx)(`div`,{className:`flex-1 overflow-auto p-2`,children:(0,o.jsx)(eP,{tree:e,openFilePath:t?.path,writableRoot:n,gitFiles:r,attachedPaths:a,onExpand:s,onSelectDirectory:c,onRefresh:l,onSelectFile:u,onSelectDiff:d,onToggleAttachPath:f,onCreateFile:p,onCreateDirectory:m,onOpenNative:h,onRenameFile:g,onDeleteFile:_,onMoveFile:v,onCopyFile:y,fileOperation:b,createError:x,created:ee})}),(0,o.jsx)(bM,{label:`Resize Files sidebar`,width:te.width,config:pM,separatorProps:te.separatorProps})]})}function rP({title:e,onSubmit:t}){let[n,r]=(0,i.useState)(``);return(0,o.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,o.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),n.trim()&&t(n.trim())},className:`w-full max-w-sm rounded-xl border border-zinc-200 p-6 shadow-sm dark:border-zinc-800`,children:[(0,o.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),(0,o.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`This server requires an access token.`}),(0,o.jsx)(`label`,{htmlFor:`pi-outpost-token`,className:`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`,children:`Access token`}),(0,o.jsx)(`input`,{id:`pi-outpost-token`,name:`token`,type:`password`,autoComplete:`off`,spellCheck:!1,value:n,onChange:e=>r(e.target.value),placeholder:`paste the token…`,className:`mb-3 w-full rounded-md border border-zinc-300 bg-white px-2 py-1.5 font-mono text-sm outline-none focus:border-zinc-500 dark:border-zinc-700 dark:bg-zinc-950 dark:focus:border-zinc-500`}),(0,o.jsx)(`button`,{type:`submit`,disabled:!n.trim(),className:`w-full rounded-md border border-emerald-300 px-2 py-1.5 text-sm text-emerald-700 hover:border-emerald-500 disabled:opacity-50 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600`,children:`Connect`}),(0,o.jsxs)(`p`,{className:`mt-3 text-center text-xs text-zinc-400 dark:text-zinc-600`,children:[`Ask the operator for the token, or open the link containing `,(0,o.jsx)(`code`,{children:`?token=…`})]})]})})}var iP={todo:{icon:`○`,label:`To do`,className:`text-zinc-500`},in_progress:{icon:`●`,label:`In progress`,className:`text-blue-600 dark:text-blue-400`},done:{icon:`✓`,label:`Done`,className:`text-emerald-600 dark:text-emerald-400`},blocked:{icon:`!`,label:`Blocked`,className:`text-red-600 dark:text-red-400`},needs_review:{icon:`?`,label:`Needs review`,className:`text-amber-600 dark:text-amber-400`}},aP=8;function oP(e){let t=e.uri.startsWith(`workspace:`)?e.uri.slice(10):/^[a-z][a-z0-9+.-]*:/i.test(e.uri)?null:e.uri;return t===null||t===``||/^(?:[\\/]|[a-z]:[\\/])/i.test(t)||t.replaceAll(`\\`,`/`).split(`/`).includes(`..`)?null:t}function sP({plan:e,open:t,onToggle:n,onOpenWorkspace:r,requestedTaskId:a,onTaskRequestHandled:s}){let c=(0,i.useId)(),[l,u]=(0,i.useState)(!1),[d,f]=(0,i.useState)(null),[p,m]=(0,i.useState)(null);(0,i.useEffect)(()=>{a&&(e.tasks.some(e=>e.id===a)?(f(a),m(null)):(f(null),m(a)),s?.())},[e.tasks,a,s]),(0,i.useEffect)(()=>{d!==null&&!e.tasks.some(e=>e.id===d)&&f(null)},[e,d]),(0,i.useEffect)(()=>{if(!l)return;let e=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[l]);let h=(0,i.useMemo)(()=>{let t=new Map;for(let n of e.tasks)t.set(n.parentId,[...t.get(n.parentId)??[],n]);return t},[e.tasks]),g=(0,i.useMemo)(()=>new Map(e.tasks.map(e=>[e.id,e])),[e.tasks]),_=(0,i.useMemo)(()=>{let e=[],t=(n,r)=>{for(let i of h.get(n)??[])e.push({task:i,depth:r}),t(i.id,r+1)};return t(void 0,0),e.slice(0,aP)},[h]),v=d?g.get(d):void 0,y=e.tasks.filter(e=>e.status===`done`).length,b=(e,t=0)=>(h.get(e)??[]).flatMap(e=>{let n=iP[e.status];return[(0,o.jsxs)(`button`,{type:`button`,role:`treeitem`,"aria-level":t+1,"aria-selected":d===e.id,onClick:()=>f(e.id),"aria-current":e.status===`in_progress`?`step`:void 0,className:`flex w-full items-start gap-2 rounded px-2 py-1.5 text-left text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800 ${d===e.id?`bg-zinc-100 dark:bg-zinc-800`:``}`,style:{paddingLeft:`${.5+t*.85}rem`},children:[(0,o.jsx)(`span`,{className:`mt-px w-4 shrink-0 text-center font-semibold ${n.className}`,"aria-label":n.label,children:n.icon}),(0,o.jsx)(`span`,{className:e.status===`done`?`text-zinc-500 line-through`:`text-zinc-800 dark:text-zinc-200`,children:e.title})]},e.id),...b(e.id,t+1)]});return t?(0,o.jsxs)(`aside`,{"aria-label":`Work Plan`,className:`absolute inset-y-0 right-0 z-10 flex w-full flex-col border-l border-zinc-200 bg-white/95 shadow-lg backdrop-blur md:w-[23rem] dark:border-zinc-800 dark:bg-zinc-950/95`,children:[(0,o.jsxs)(`header`,{className:`border-b border-zinc-200 px-3 py-3 dark:border-zinc-800`,children:[(0,o.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,o.jsxs)(`div`,{className:`min-w-0`,children:[(0,o.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-zinc-500`,children:`Work Plan`}),(0,o.jsx)(`h2`,{className:`truncate text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:e.title})]}),(0,o.jsx)(`button`,{type:`button`,onClick:n,className:`rounded px-2 py-1 text-xs text-zinc-500 hover:bg-zinc-100 dark:hover:bg-zinc-800`,"aria-label":`Close Work Plan`,children:`×`})]}),(0,o.jsxs)(`div`,{className:`mt-2 text-xs text-zinc-500`,children:[`Progress: `,y,` / `,e.tasks.length]}),(0,o.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-800`,"aria-hidden":!0,children:(0,o.jsx)(`div`,{className:`h-full bg-emerald-500`,style:{width:`${e.tasks.length===0?0:y/e.tasks.length*100}%`}})})]}),(0,o.jsx)(`div`,{role:`tree`,"aria-label":`Work Plan tasks`,className:`min-h-0 flex-1 overflow-y-auto p-2`,children:b(void 0)}),p&&(0,o.jsx)(`div`,{role:`status`,className:`border-t border-amber-200 bg-amber-50 p-3 text-xs text-amber-800 dark:border-amber-900 dark:bg-amber-950/30 dark:text-amber-300`,children:`That Outcome task no longer exists in the current Work Plan.`}),v&&(0,o.jsxs)(`section`,{"aria-label":`Task details`,className:`max-h-[45%] overflow-y-auto border-t border-zinc-200 p-3 text-xs dark:border-zinc-800`,children:[(0,o.jsx)(`div`,{className:`font-semibold ${iP[v.status].className}`,children:iP[v.status].label}),(0,o.jsx)(`h3`,{className:`mt-1 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:v.title}),v.description&&(0,o.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-zinc-600 dark:text-zinc-300`,children:v.description}),v.statusReason&&(0,o.jsx)(`p`,{className:`mt-2 rounded bg-zinc-100 p-2 text-zinc-700 dark:bg-zinc-900 dark:text-zinc-300`,children:v.statusReason}),v.dependsOn.length>0&&(0,o.jsxs)(`div`,{className:`mt-3`,children:[(0,o.jsx)(`span`,{className:`font-semibold`,children:`Depends on:`}),` `,v.dependsOn.map(e=>g.get(e)?.title??e).join(`, `)]}),v.resources.length>0&&(0,o.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,o.jsx)(`div`,{className:`font-semibold`,children:`Resources`}),v.resources.map(e=>{let t=oP(e),n=e.label??e.uri;return t===null?/^https?:/i.test(e.uri)?(0,o.jsx)(`a`,{href:e.uri,target:`_blank`,rel:`noreferrer`,className:`block truncate text-blue-600 hover:underline dark:text-blue-400`,children:n},e.uri):(0,o.jsx)(`span`,{className:`block truncate text-zinc-500`,title:`No navigator is available for this resource`,children:n},e.uri):(0,o.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-blue-600 hover:underline dark:text-blue-400`,onClick:()=>r(t),children:n},e.uri)})]})]})]}):(0,o.jsxs)(`div`,{className:`absolute right-3 top-3 z-20`,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),onFocusCapture:()=>u(!0),onBlurCapture:()=>u(!1),children:[(0,o.jsxs)(`button`,{type:`button`,onClick:()=>{u(!1),n()},className:`rounded-md border border-zinc-300 bg-white px-2 py-1 text-xs shadow-sm dark:border-zinc-700 dark:bg-zinc-900`,"aria-label":`Open Work Plan`,"aria-describedby":c,children:[`Plan `,y,`/`,e.tasks.length]}),(0,o.jsx)(`div`,{id:c,role:`tooltip`,className:`absolute right-0 top-full w-72 pt-2 ${l?`block`:`hidden`}`,children:(0,o.jsxs)(`div`,{className:`rounded-md border border-zinc-200 bg-white p-2 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,o.jsx)(`ul`,{className:`space-y-1`,children:_.map(({task:e,depth:t})=>(0,o.jsxs)(`li`,{className:`flex min-w-0 items-start gap-1.5 text-xs`,style:{paddingLeft:`${t*.75}rem`},children:[(0,o.jsx)(`span`,{"aria-label":iP[e.status].label,className:`shrink-0 font-semibold ${iP[e.status].className}`,children:e.status===`done`?`☑`:`☐`}),(0,o.jsx)(`span`,{className:`truncate ${e.status===`done`?`text-zinc-500 line-through`:`text-zinc-800 dark:text-zinc-200`}`,children:e.title})]},e.id))}),e.tasks.length>_.length&&(0,o.jsxs)(`div`,{className:`mt-1 text-[11px] text-zinc-500`,children:[`+`,e.tasks.length-_.length,` more`]})]})})]})}var cP=Object.defineProperty,lP=Object.getOwnPropertyDescriptor,uP=(e,t)=>{for(var n in t)cP(e,n,{get:t[n],enumerable:!0})},dP=(e,t,n,r)=>{for(var i=r>1?void 0:r?lP(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&cP(t,n,i),i},fP=(e,t)=>(n,r)=>t(n,r,e),pP=`Terminal input`,mP={get:()=>pP,set:e=>pP=e},hP=`Too much output to announce, navigate to rows manually to read`,gP={get:()=>hP,set:e=>hP=e};function _P(e){return e.replace(/\r?\n/g,`\r`)}function vP(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function yP(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function bP(e,t,n,r){e.stopPropagation(),e.clipboardData&&xP(e.clipboardData.getData(`text/plain`),t,n,r)}function xP(e,t,n,r){e=_P(e),e=vP(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function SP(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function CP(e,t,n,r,i){SP(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function wP(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function TP(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var EP=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},DP=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},OP=``,kP=` `,AP=class e{constructor(){this.fg=0,this.bg=0,this.extended=new jP}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},jP=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},MP=class e extends AP{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new jP,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?wP(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},NP=`di$target`,PP=`di$dependencies`,FP=new Map;function IP(e){return e[PP]||[]}function LP(e){if(FP.has(e))return FP.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);RP(t,e,r)};return t._id=e,FP.set(e,t),t}function RP(e,t,n){t[NP]===t?t[PP].push({id:e,index:n}):(t[PP]=[{id:e,index:n}],t[NP]=t)}var zP=LP(`BufferService`),BP=LP(`CoreMouseService`),VP=LP(`CoreService`),HP=LP(`CharsetService`),UP=LP(`InstantiationService`),WP=LP(`LogService`),GP=LP(`OptionsService`),KP=LP(`OscLinkService`),qP=LP(`UnicodeService`),JP=LP(`DecorationService`),YP=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new MP,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):XP(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};YP=dP([fP(0,zP),fP(1,GP),fP(2,KP)],YP);function XP(e,t){if(confirm(`Do you want to navigate to ${t}?
302
302
 
303
303
  WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var ZP=LP(`CharSizeService`),QP=LP(`CoreBrowserService`),$P=LP(`MouseService`),eF=LP(`RenderService`),tF=LP(`SelectionService`),nF=LP(`CharacterJoinerService`),rF=LP(`ThemeService`),iF=LP(`LinkProviderService`),aF=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?dF.isErrorNoTelemetry(e)?new dF(e.message+`
@@ -42835,7 +42835,10 @@ function hM({ isStreaming: e, connected: t, commands: n, fileSearch: r, prefill:
42835
42835
  let ue = _e(() => {
42836
42836
  let e = /^\/(\S*)$/.exec(g);
42837
42837
  return e ? e[1].toLowerCase() : null;
42838
- }, [g]), de = _e(() => ue === null ? [] : n.filter((e) => e.name.toLowerCase().startsWith(ue)).sort((e, t) => dM.compare(e.name, t.name)).slice(0, uM), [ue, n]), fe = ue === null ? mM(g, v) : null;
42838
+ }, [g]), de = _e(() => ue === null ? [] : n.filter((e) => e.name.toLowerCase().includes(ue)).sort((e, t) => {
42839
+ let n = e.name.toLowerCase().startsWith(ue);
42840
+ return n === t.name.toLowerCase().startsWith(ue) ? dM.compare(e.name, t.name) : n ? -1 : 1;
42841
+ }).slice(0, uM), [ue, n]), fe = ue === null ? mM(g, v) : null;
42839
42842
  x(() => {
42840
42843
  if (!fe || fe.query.length === 0) {
42841
42844
  p();
@@ -43554,7 +43557,7 @@ function LM({ text: e, path: t, serverUrl: n, token: r }) {
43554
43557
  if (!(c.current || Date.now() - l.current < 750)) {
43555
43558
  c.current = !0, l.current = Date.now(), a("working"), s(null);
43556
43559
  try {
43557
- let { downloadDocx: i } = await import("./docxExport-D9BU770f.js");
43560
+ let { downloadDocx: i } = await import("./docxExport-6TmQjWC6.js");
43558
43561
  await i(e, t, {
43559
43562
  serverUrl: n,
43560
43563
  token: r
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-outpost/embed",
3
- "version": "0.28.1",
3
+ "version": "0.29.0",
4
4
  "type": "module",
5
5
  "description": "Mount pi-outpost as a Shadow-DOM-isolated widget inside another web app.",
6
6
  "license": "MIT",