@cnrai/pave 0.11.81 → 0.11.82

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.
Files changed (64) hide show
  1. package/package.json +1 -1
  2. package/pave.js +2 -2
  3. package/web/assets/{abnfDiagram-VCTEODGH-BXhWpXaX.js → abnfDiagram-VCTEODGH-9I7swegc.js} +1 -1
  4. package/web/assets/{arc-BmYtSzrn.js → arc-DyVWQdpx.js} +1 -1
  5. package/web/assets/{architectureDiagram-5GKGNRK7-CHqB0B37.js → architectureDiagram-5GKGNRK7-Bu33Fevc.js} +1 -1
  6. package/web/assets/{blockDiagram-NRAW4CY4-BnJdjCct.js → blockDiagram-NRAW4CY4-BjSrG4Gi.js} +1 -1
  7. package/web/assets/{c4Diagram-UCG6FXSJ-DEmhNpiC.js → c4Diagram-UCG6FXSJ-DKW76ufa.js} +1 -1
  8. package/web/assets/channel-lYoL_8ok.js +1 -0
  9. package/web/assets/{chunk-2Q5K7J3B-DwJWuDtM.js → chunk-2Q5K7J3B-DWiA9qEw.js} +1 -1
  10. package/web/assets/{chunk-5VM5RSS4-DTP0Zeg1.js → chunk-5VM5RSS4-BxwBK-a7.js} +1 -1
  11. package/web/assets/{chunk-F27PBJKO-gLmuQFor.js → chunk-F27PBJKO-55JB7WtZ.js} +1 -1
  12. package/web/assets/{chunk-G27WJ6UU-C5uK6hq8.js → chunk-G27WJ6UU-BYcYIibk.js} +1 -1
  13. package/web/assets/{chunk-JWPE2WC7-C74l6_6g.js → chunk-JWPE2WC7-D-kqXy5w.js} +1 -1
  14. package/web/assets/{chunk-LCL6LL3I-MJsgUUXd.js → chunk-LCL6LL3I-D7ezi85E.js} +1 -1
  15. package/web/assets/{chunk-POPQ4Y6H-C7xLRLVw.js → chunk-POPQ4Y6H-B-1wHMit.js} +1 -1
  16. package/web/assets/{chunk-SVP7TREG-B0M6BeIk.js → chunk-SVP7TREG-BUGEg5xN.js} +1 -1
  17. package/web/assets/{chunk-XXDRQBXY-BJDqr-_S.js → chunk-XXDRQBXY-Cb0f4fIf.js} +1 -1
  18. package/web/assets/classDiagram-DTDB5LWJ-C5UXAo_j.js +1 -0
  19. package/web/assets/classDiagram-v2-JRS7N3AN-C5UXAo_j.js +1 -0
  20. package/web/assets/{cose-bilkent-JH36ORCC-6WJ3pd2a.js → cose-bilkent-JH36ORCC-CAWDvLIh.js} +1 -1
  21. package/web/assets/{cynefin-OW5HDTMX-CztPPRdk.js → cynefin-OW5HDTMX-Cosp1kQ3.js} +1 -1
  22. package/web/assets/{cynefinDiagram-5FMLGOSQ-BmoKZty0.js → cynefinDiagram-5FMLGOSQ-DNbene_1.js} +1 -1
  23. package/web/assets/{dagre-3AP2YEHR-du2SQF1d.js → dagre-3AP2YEHR-CP2z1R4J.js} +1 -1
  24. package/web/assets/{diagram-S7CK7UJ4-CP_ukNXy.js → diagram-S7CK7UJ4-Bq6kE3Qo.js} +1 -1
  25. package/web/assets/{diagram-UQ7AKVKN-DTpkfX16.js → diagram-UQ7AKVKN-BjhawDgz.js} +1 -1
  26. package/web/assets/{diagram-VSXAHHWV-C-liwSeC.js → diagram-VSXAHHWV-k-uyl7kx.js} +1 -1
  27. package/web/assets/{diagram-VX7I27RA-Bf6ukRSI.js → diagram-VX7I27RA-CvQYwC6D.js} +1 -1
  28. package/web/assets/{diagram-Z3DM3KII-VhngwGfd.js → diagram-Z3DM3KII-ClEsZ-KM.js} +1 -1
  29. package/web/assets/{ebnfDiagram-PWID7BFC-BJqdyBtq.js → ebnfDiagram-PWID7BFC-DM6ZbS6R.js} +1 -1
  30. package/web/assets/{erDiagram-SSCWMZ5O-CifiUovu.js → erDiagram-SSCWMZ5O-CYaU_Nw-.js} +1 -1
  31. package/web/assets/{flowDiagram-A5DVABFB-DhNq8km9.js → flowDiagram-A5DVABFB-C5Rbw9x2.js} +1 -1
  32. package/web/assets/{ganttDiagram-EL5Y4UJY-RYm4e06w.js → ganttDiagram-EL5Y4UJY-1uZXMEyg.js} +1 -1
  33. package/web/assets/{gitGraphDiagram-WWUBYQGX-CfMTElsq.js → gitGraphDiagram-WWUBYQGX-Be1ZzKab.js} +1 -1
  34. package/web/assets/{index-NYgaHwWL.js → index-CV--Typp.js} +2 -2
  35. package/web/assets/{infoDiagram-RXCK75RN-DRlRkTgf.js → infoDiagram-RXCK75RN-C910kEri.js} +1 -1
  36. package/web/assets/{ishikawaDiagram-5VMMS53U-BhpHRlkp.js → ishikawaDiagram-5VMMS53U-CqIAX_4U.js} +1 -1
  37. package/web/assets/{journeyDiagram-EYS64GPL-Bmq7RimD.js → journeyDiagram-EYS64GPL-BJH2T6Oe.js} +1 -1
  38. package/web/assets/{kanban-definition-3QL26DDD-BafmhluM.js → kanban-definition-3QL26DDD-D4MwIQqo.js} +1 -1
  39. package/web/assets/{layout-DG1Ed2Rk.js → layout-E0MZ6Vxs.js} +1 -1
  40. package/web/assets/{linear-gS7m77H-.js → linear-BUHqk8Cw.js} +1 -1
  41. package/web/assets/{mermaid.core-BWRDK01d.js → mermaid.core-AbOCDXp6.js} +5 -5
  42. package/web/assets/{mindmap-definition-FBJOCRG2-DV3aa9MA.js → mindmap-definition-FBJOCRG2-BAJfUJuW.js} +1 -1
  43. package/web/assets/{pegDiagram-XKGWAZYB-CJLtzQ32.js → pegDiagram-XKGWAZYB-5bYvRIwo.js} +1 -1
  44. package/web/assets/{pieDiagram-E7YTZNPT-BkYv4AEi.js → pieDiagram-E7YTZNPT-D2yDVdcL.js} +1 -1
  45. package/web/assets/{quadrantDiagram-AXDQQJYC-DcFzhrN9.js → quadrantDiagram-AXDQQJYC-BnD6S8YV.js} +1 -1
  46. package/web/assets/{railroadDiagram-O6MQD6OU-DtsSMaLO.js → railroadDiagram-O6MQD6OU-DQR3NMJt.js} +1 -1
  47. package/web/assets/{requirementDiagram-EFPCY7ZU-BfEu7hzS.js → requirementDiagram-EFPCY7ZU-B6ZQEd81.js} +1 -1
  48. package/web/assets/{sankeyDiagram-P5KCCOFB-C6iVHR41.js → sankeyDiagram-P5KCCOFB-gujp6WSF.js} +1 -1
  49. package/web/assets/{sequenceDiagram-WJ2MYXX4-Cc5yHmpF.js → sequenceDiagram-WJ2MYXX4-hohjJ8lb.js} +1 -1
  50. package/web/assets/{sizeCapture-X5ZJPWSS-BJcoM0R7.js → sizeCapture-X5ZJPWSS-nn3k8g1M.js} +1 -1
  51. package/web/assets/{stateDiagram-HBIQ2CUA-4nAP9F22.js → stateDiagram-HBIQ2CUA-k17nzvdJ.js} +1 -1
  52. package/web/assets/stateDiagram-v2-4QOOHH4V-D5-Y44AB.js +1 -0
  53. package/web/assets/{swimlanes-XN3QIQJK-Dwk5JGoT.js → swimlanes-XN3QIQJK-T7GDnOeh.js} +1 -1
  54. package/web/assets/swimlanesDiagram-VK2B7HYN-BmhKCblm.js +8 -0
  55. package/web/assets/{timeline-definition-24CTP7MA-CQd6-o_H.js → timeline-definition-24CTP7MA-CrjmBowP.js} +1 -1
  56. package/web/assets/{vennDiagram-4TSXK5OY-C_uCn_U9.js → vennDiagram-4TSXK5OY-t0JqhJnA.js} +1 -1
  57. package/web/assets/{wardleyDiagram-VM6X3IG4-9RdEEI_A.js → wardleyDiagram-VM6X3IG4-DKYd1Jnq.js} +1 -1
  58. package/web/assets/{xychartDiagram-S5SC5T6Z-eHrbsHp8.js → xychartDiagram-S5SC5T6Z-CH7Mipdq.js} +1 -1
  59. package/web/index.html +1 -1
  60. package/web/assets/channel-C_umbusZ.js +0 -1
  61. package/web/assets/classDiagram-DTDB5LWJ-Buz0Njj4.js +0 -1
  62. package/web/assets/classDiagram-v2-JRS7N3AN-Buz0Njj4.js +0 -1
  63. package/web/assets/stateDiagram-v2-4QOOHH4V-DsTWgQl9.js +0 -1
  64. package/web/assets/swimlanesDiagram-VK2B7HYN-D82XPNnY.js +0 -8
@@ -81,7 +81,7 @@ Error generating stack: `+i.message+`
81
81
  https://github.com/highlightjs/highlight.js/issues/2277`),R=T,Y=M),U===void 0&&(U=!0);const V={code:Y,language:R};O("before:highlight",V);const X=V.result?V.result:f(V.language,V.code,U);return X.code=V.code,O("after:highlight",X),X}function f(T,M,U,Y){const R=Object.create(null);function V(F,B){return F.keywords[B]}function X(){if(!me.keywords){Re.addText(fe);return}let F=0;me.keywordPatternRe.lastIndex=0;let B=me.keywordPatternRe.exec(fe),W="";for(;B;){W+=fe.substring(F,B.index);const re=de.case_insensitive?B[0].toLowerCase():B[0],_e=V(me,re);if(_e){const[We,Ne]=_e;if(Re.addText(W),W="",R[re]=(R[re]||0)+1,R[re]<=Sq&&(Ge+=Ne),We.startsWith("_"))W+=B[0];else{const je=de.classNameAliases[We]||We;ue(B[0],je)}}else W+=B[0];F=me.keywordPatternRe.lastIndex,B=me.keywordPatternRe.exec(fe)}W+=fe.substring(F),Re.addText(W)}function I(){if(fe==="")return;let F=null;if(typeof me.subLanguage=="string"){if(!t[me.subLanguage]){Re.addText(fe);return}F=f(me.subLanguage,fe,!0,ee[me.subLanguage]),ee[me.subLanguage]=F._top}else F=p(fe,me.subLanguage.length?me.subLanguage:null);me.relevance>0&&(Ge+=F.relevance),Re.__addSublanguage(F._emitter,F.language)}function H(){me.subLanguage!=null?I():X(),fe=""}function ue(F,B){F!==""&&(Re.startScope(B),Re.addText(F),Re.endScope())}function J(F,B){let W=1;const re=B.length-1;for(;W<=re;){if(!F._emit[W]){W++;continue}const _e=de.classNameAliases[F[W]]||F[W],We=B[W];_e?ue(We,_e):(fe=We,X(),fe=""),W++}}function ge(F,B){return F.scope&&typeof F.scope=="string"&&Re.openNode(de.classNameAliases[F.scope]||F.scope),F.beginScope&&(F.beginScope._wrap?(ue(fe,de.classNameAliases[F.beginScope._wrap]||F.beginScope._wrap),fe=""):F.beginScope._multi&&(J(F.beginScope,B),fe="")),me=Object.create(F,{parent:{value:me}}),me}function K(F,B,W){let re=UH(F.endRe,W);if(re){if(F["on:end"]){const _e=new p2(F);F["on:end"](B,_e),_e.isMatchIgnored&&(re=!1)}if(re){for(;F.endsParent&&F.parent;)F=F.parent;return F}}if(F.endsWithParent)return K(F.parent,B,W)}function he(F){return me.matcher.regexIndex===0?(fe+=F[0],1):(qe=!0,0)}function Me(F){const B=F[0],W=F.rule,re=new p2(W),_e=[W.__beforeBegin,W["on:begin"]];for(const We of _e)if(We&&(We(F,re),re.isMatchIgnored))return he(B);return W.skip?fe+=B:(W.excludeBegin&&(fe+=B),H(),!W.returnBegin&&!W.excludeBegin&&(fe=B)),ge(W,F),W.returnBegin?0:B.length}function Te(F){const B=F[0],W=M.substring(F.index),re=K(me,F,W);if(!re)return v2;const _e=me;me.endScope&&me.endScope._wrap?(H(),ue(B,me.endScope._wrap)):me.endScope&&me.endScope._multi?(H(),J(me.endScope,F)):_e.skip?fe+=B:(_e.returnEnd||_e.excludeEnd||(fe+=B),H(),_e.excludeEnd&&(fe=B));do me.scope&&Re.closeNode(),!me.skip&&!me.subLanguage&&(Ge+=me.relevance),me=me.parent;while(me!==re.parent);return re.starts&&ge(re.starts,F),_e.returnEnd?0:B.length}function Ae(){const F=[];for(let B=me;B!==de;B=B.parent)B.scope&&F.unshift(B.scope);F.forEach(B=>Re.openNode(B))}let Pe={};function be(F,B){const W=B&&B[0];if(fe+=F,W==null)return H(),0;if(Pe.type==="begin"&&B.type==="end"&&Pe.index===B.index&&W===""){if(fe+=M.slice(B.index,B.index+1),!a){const re=new Error(`0 width match regex (${T})`);throw re.languageName=T,re.badRule=Pe.rule,re}return 1}if(Pe=B,B.type==="begin")return Me(B);if(B.type==="illegal"&&!U){const re=new Error('Illegal lexeme "'+W+'" for mode "'+(me.scope||"<unnamed>")+'"');throw re.mode=me,re}else if(B.type==="end"){const re=Te(B);if(re!==v2)return re}if(B.type==="illegal"&&W==="")return B.index===M.length||(fe+=`
82
82
  `),1;if(we>1e5&&we>B.index*3)throw new Error("potential infinite loop, way more iterations than matches");return fe+=W,W.length}const de=C(T);if(!de)throw ds(i.replace("{}",T)),new Error('Unknown language: "'+T+'"');const pe=kq(de);let Oe="",me=Y||pe;const ee={},Re=new l.__emitter(l);Ae();let fe="",Ge=0,Se=0,we=0,qe=!1;try{if(de.__emitTokens)de.__emitTokens(M,Re);else{for(me.matcher.considerAll();;){we++,qe?qe=!1:me.matcher.considerAll(),me.matcher.lastIndex=Se;const F=me.matcher.exec(M);if(!F)break;const B=M.substring(Se,F.index),W=be(B,F);Se=F.index+W}be(M.substring(Se))}return Re.finalize(),Oe=Re.toHTML(),{language:T,value:Oe,relevance:Ge,illegal:!1,_emitter:Re,_top:me}}catch(F){if(F.message&&F.message.includes("Illegal"))return{language:T,value:op(M),illegal:!0,relevance:0,_illegalBy:{message:F.message,index:Se,context:M.slice(Se-100,Se+100),mode:F.mode,resultSoFar:Oe},_emitter:Re};if(a)return{language:T,value:op(M),illegal:!1,relevance:0,errorRaised:F,_emitter:Re,_top:me};throw F}}function g(T){const M={value:op(T),illegal:!1,relevance:0,_top:s,_emitter:new l.__emitter(l)};return M._emitter.addText(T),M}function p(T,M){M=M||l.languages||Object.keys(t);const U=g(T),Y=M.filter(C).filter(j).map(H=>f(H,T,!1));Y.unshift(U);const R=Y.sort((H,ue)=>{if(H.relevance!==ue.relevance)return ue.relevance-H.relevance;if(H.language&&ue.language){if(C(H.language).supersetOf===ue.language)return 1;if(C(ue.language).supersetOf===H.language)return-1}return 0}),[V,X]=R,I=V;return I.secondBest=X,I}function m(T,M,U){const Y=M&&n[M]||U;T.classList.add("hljs"),T.classList.add(`language-${Y}`)}function y(T){let M=null;const U=u(T);if(c(U))return;if(O("before:highlightElement",{el:T,language:U}),T.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",T);return}if(T.children.length>0&&(l.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(T)),l.throwUnescapedHTML))throw new Eq("One of your code blocks includes unescaped HTML.",T.innerHTML);M=T;const Y=M.textContent,R=U?d(Y,{language:U,ignoreIllegals:!0}):p(Y);T.innerHTML=R.value,T.dataset.highlighted="yes",m(T,U,R.language),T.result={language:R.language,re:R.relevance,relevance:R.relevance},R.secondBest&&(T.secondBest={language:R.secondBest.language,relevance:R.secondBest.relevance}),O("after:highlightElement",{el:T,result:R,text:Y})}function v(T){l=b2(l,T)}const x=()=>{S(),Us("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function b(){S(),Us("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let k=!1;function S(){function T(){S()}if(document.readyState==="loading"){k||window.addEventListener("DOMContentLoaded",T,!1),k=!0;return}document.querySelectorAll(l.cssSelector).forEach(y)}function E(T,M){let U=null;try{U=M(e)}catch(Y){if(ds("Language definition for '{}' could not be registered.".replace("{}",T)),a)ds(Y);else throw Y;U=s}U.name||(U.name=T),t[T]=U,U.rawDefinition=M.bind(null,e),U.aliases&&A(U.aliases,{languageName:T})}function _(T){delete t[T];for(const M of Object.keys(n))n[M]===T&&delete n[M]}function w(){return Object.keys(t)}function C(T){return T=(T||"").toLowerCase(),t[T]||t[n[T]]}function A(T,{languageName:M}){typeof T=="string"&&(T=[T]),T.forEach(U=>{n[U.toLowerCase()]=M})}function j(T){const M=C(T);return M&&!M.disableAutodetect}function D(T){T["before:highlightBlock"]&&!T["before:highlightElement"]&&(T["before:highlightElement"]=M=>{T["before:highlightBlock"](Object.assign({block:M.el},M))}),T["after:highlightBlock"]&&!T["after:highlightElement"]&&(T["after:highlightElement"]=M=>{T["after:highlightBlock"](Object.assign({block:M.el},M))})}function P(T){D(T),r.push(T)}function q(T){const M=r.indexOf(T);M!==-1&&r.splice(M,1)}function O(T,M){const U=T;r.forEach(function(Y){Y[U]&&Y[U](M)})}function L(T){return Us("10.7.0","highlightBlock will be removed entirely in v12.0"),Us("10.7.0","Please use highlightElement now."),y(T)}Object.assign(e,{highlight:d,highlightAuto:p,highlightAll:S,highlightElement:y,highlightBlock:L,configure:v,initHighlighting:x,initHighlightingOnLoad:b,registerLanguage:E,unregisterLanguage:_,listLanguages:w,getLanguage:C,registerAliases:A,autoDetection:j,inherit:b2,addPlugin:P,removePlugin:q}),e.debugMode=function(){a=!1},e.safeMode=function(){a=!0},e.versionString=wq,e.regex={concat:Ns,lookahead:JR,either:E1,optional:BH,anyNumberOfTimes:FH};for(const T in Su)typeof Su[T]=="object"&&QR(Su[T]);return Object.assign(e,Su),e},No=lI({});No.newInstance=()=>lI({});var Nq=No;No.HighlightJS=No;No.default=No;const Cq=Co(Nq),k2={},jq="hljs-";function Tq(e){const t=Cq.newInstance();return e&&i(e),{highlight:n,highlightAuto:r,listLanguages:a,register:i,registerAlias:s,registered:l};function n(c,u,d){const f=d||k2,g=typeof f.prefix=="string"?f.prefix:jq;if(!t.getLanguage(c))throw new Error("Unknown language: `"+c+"` is not registered");t.configure({__emitter:Aq,classPrefix:g});const p=t.highlight(u,{ignoreIllegals:!0,language:c});if(p.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:p.errorRaised});const m=p._emitter.root,y=m.data;return y.language=p.language,y.relevance=p.relevance,m}function r(c,u){const f=(u||k2).subset||a();let g=-1,p=0,m;for(;++g<f.length;){const y=f[g];if(!t.getLanguage(y))continue;const v=n(y,c,u);v.data&&v.data.relevance!==void 0&&v.data.relevance>p&&(p=v.data.relevance,m=v)}return m||{type:"root",children:[],data:{language:void 0,relevance:p}}}function a(){return t.listLanguages()}function i(c,u){if(typeof c=="string")t.registerLanguage(c,u);else{let d;for(d in c)Object.hasOwn(c,d)&&t.registerLanguage(d,c[d])}}function s(c,u){if(typeof c=="string")t.registerAliases(typeof u=="string"?u:[...u],{languageName:c});else{let d;for(d in c)if(Object.hasOwn(c,d)){const f=c[d];t.registerAliases(typeof f=="string"?f:[...f],{languageName:d})}}}function l(c){return!!t.getLanguage(c)}}class Aq{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const r=this.stack[this.stack.length-1],a=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:a}):r.children.push(...a)}openNode(t){const n=this,r=t.split(".").map(function(s,l){return l?s+"_".repeat(l):n.options.classPrefix+s}),a=this.stack[this.stack.length-1],i={type:"element",tagName:"span",properties:{className:r},children:[]};a.children.push(i),this.stack.push(i)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const Rq={};function _2(e){const t=e||Rq,n=t.aliases,r=t.detect||!1,a=t.languages||MH,i=t.plainText,s=t.prefix,l=t.subset;let c="hljs";const u=Tq(a);if(n&&u.registerAlias(n),s){const d=s.indexOf("-");c=d===-1?s:s.slice(0,d)}return function(d,f){hf(d,"element",function(g,p,m){if(g.tagName!=="code"||!m||m.type!=="element"||m.tagName!=="pre")return;const y=Iq(g);if(y===!1||!y&&!r||y&&i&&i.includes(y))return;Array.isArray(g.properties.className)||(g.properties.className=[]),g.properties.className.includes(c)||g.properties.className.unshift(c);const v=a$(g,{whitespace:"pre"});let x;try{x=y?u.highlight(y,v,{prefix:s}):u.highlightAuto(v,{prefix:s,subset:l})}catch(b){const k=b;if(y&&/Unknown language/.test(k.message)){f.message("Cannot highlight as `"+y+"`, it’s not registered",{ancestors:[m,g],cause:k,place:g.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw k}!y&&x.data&&x.data.language&&g.properties.className.push("language-"+x.data.language),x.children.length>0&&(g.children=x.children)})}}function Iq(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let r;for(;++n<t.length;){const a=String(t[n]);if(a==="no-highlight"||a==="nohighlight")return!1;!r&&a.slice(0,5)==="lang-"&&(r=a.slice(5)),!r&&a.slice(0,9)==="language-"&&(r=a.slice(9))}return r}function Mb(){function e(t){const n=new Set(["strong","emphasis","delete"]);function r(a){if(a.children)for(let i=0;i<a.children.length;i++){const s=a.children[i];if(n.has(s.type)){if(i>0){const u=a.children[i-1];u.type==="text"?u.value&&/[a-zA-Z0-9]$/.test(u.value)&&!u.value.endsWith(" ")&&!u.value.endsWith(`
83
83
  `)&&(u.value+=" "):(a.children.splice(i,0,{type:"text",value:" "}),i++)}const l=i+1,c=l<a.children.length?a.children[l]:null;c&&(c.type==="text"?c.value&&/^[a-zA-Z0-9]/.test(c.value)&&!c.value.startsWith(" ")&&!c.value.startsWith(`
84
- `)&&(c.value=" "+c.value):n.has(c.type)&&a.children.splice(l,0,{type:"text",value:" "}))}r(s)}}return r(t),t}return e}function ed({children:e,language:t,className:n,frameless:r,...a}){const[i,s]=h.useState(!1),l=String(e).replace(/\n$/,""),c=n||(t?"language-"+t:""),u=async()=>{try{await navigator.clipboard.writeText(l),s(!0),setTimeout(()=>s(!1),2e3)}catch{const d=document.createElement("textarea");d.value=l,document.body.appendChild(d),d.select(),document.execCommand("copy"),document.body.removeChild(d),s(!0),setTimeout(()=>s(!1),2e3)}};return r?o.jsxs("div",{className:"relative group rounded-lg overflow-hidden bg-gray-100 dark:bg-gray-800/50 my-3",children:[o.jsx("button",{onClick:u,className:"absolute top-2 right-2 z-10 p-1.5 rounded-md bg-gray-200/80 dark:bg-gray-700/80 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors backdrop-blur-sm",title:"Copy","aria-label":"Copy code",children:i?o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),o.jsx("pre",{className:"p-4 overflow-x-auto text-sm",...a,children:o.jsx("code",{className:c||void 0,children:e})})]}):o.jsxs("div",{className:"relative group rounded-lg overflow-hidden bg-gray-900 dark:bg-gray-950 my-3 px-1.5 py-0.5",children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5 bg-gray-800 dark:bg-gray-900 text-xs text-gray-400",children:[o.jsx("span",{children:t||"code"}),o.jsx("button",{onClick:u,className:"flex items-center gap-1 hover:text-gray-200 transition-colors",children:i?o.jsxs(o.Fragment,{children:[o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),"Copied"]}):o.jsxs(o.Fragment,{children:[o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})}),"Copy"]})})]}),o.jsx("pre",{className:"p-4 overflow-x-auto text-sm",...a,children:o.jsx("code",{className:c||void 0,children:e})})]})}function xf(e,t){if(!t)return"";try{const n=typeof t=="string"?JSON.parse(t):t;if(n.command)return n.command;if(n.filePath&&e==="read")return`read ${n.filePath}`;if(n.pattern&&e==="grep"){const r=n.path||n.include||".";return`grep "${n.pattern}" ${r}`}if(n.pattern&&e==="glob")return`glob "${n.pattern}"`;if(n.filePath&&e==="edit")return`edit ${n.filePath}`;if(n.filePath&&e==="write")return`write ${n.filePath}`;if(n._purpose&&e==="task")return`task "${n._purpose}"`;if(n.url&&(e==="webfetch"||e==="fetch"))return`fetch ${n.url}`;if(n.action&&e==="todo"){let r=`todo ${n.action}`;return n.text&&(r+=` "${n.text}"`),n.id&&(r+=` #${n.id}`),r}if(n.action&&e==="permission"){let r=`permission ${n.action}`;return n.type&&(r+=` ${n.type}`),n.target&&(r+=` ${n.target}`),r}{const r=[];for(const[a,i]of Object.entries(n))if(!(i==null||i===""))if(typeof i=="boolean")i&&r.push(`--${a}`);else if(Array.isArray(i)){const s=i.map(c=>String(c)).join(", "),l=s.length>60?s.slice(0,60)+"...":s;r.push(`--${a} "${l}"`)}else{const s=String(i),l=s.length>60?s.slice(0,60)+"...":s;r.push(`--${a} "${l}"`)}return r.length>0?`${e} ${r.join(" ")}`:e||""}}catch{return""}}function fs(e){return typeof e!="string"?e:e.replace(/\x1b\[[0-9;]*[@-~]|\x1b\].*?(?:\x07|\x1b\\)|\x1b[()][AB012]|\x1b[=>]/g,"")}function Mq(e){if(!e)return null;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{return null}return t&&t.canvas&&t.canvas.type&&t.canvas.source?t.canvas:null}function Lq({part:e}){const{t}=Tt(),{tool:n,state:r}=e,[a,i]=h.useState(!1);if(!r)return null;const s=r.status||"running",l=r.title||n||t("tool.tool"),c=xf(n||l,r.input),u=r.input&&r.input._purpose?r.input._purpose:null,d=s==="completed"?Mq(r.output):null,f=!u||a,g={running:"border-yellow-400 bg-yellow-50 dark:bg-yellow-900/20",completed:"border-green-400 bg-green-50 dark:bg-green-900/20",error:"border-red-400 bg-red-50 dark:bg-red-900/20",pending_confirmation:"border-blue-400 bg-blue-50 dark:bg-blue-900/20"},p={running:o.jsxs("svg",{className:"w-4 h-4 text-yellow-500 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[o.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),o.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),completed:o.jsx("svg",{className:"w-4 h-4 text-green-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),error:o.jsx("svg",{className:"w-4 h-4 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}),pending_confirmation:o.jsx("svg",{className:"w-4 h-4 text-blue-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})};return o.jsxs("div",{className:`rounded-lg border-l-4 p-2 xs:p-3 text-xs sm:text-sm ${g[s]||g.running}`,children:[o.jsxs("div",{className:`flex items-center gap-2 ${u?"cursor-pointer select-none":""}`,onClick:u?()=>i(!a):void 0,children:[p[s]||p.running,u?o.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-200 flex-1",children:u}):o.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-200",children:l}),u&&o.jsx("svg",{className:`w-4 h-4 text-gray-400 flex-shrink-0 transition-transform ${a?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),f&&c&&!d&&o.jsxs("div",{className:"mt-2 font-mono text-xs bg-gray-900 dark:bg-gray-950 text-gray-100 rounded px-2 py-1.5 overflow-x-auto",children:[o.jsx("span",{className:"text-green-400 select-none",children:"$ "}),o.jsx("span",{className:"text-gray-100",children:c})]}),d?o.jsxs("div",{className:"mt-2 text-xs text-blue-700 dark:text-blue-300 flex items-center gap-1.5",children:[o.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 5a1 1 0 011-1h14a1 1 0 011 1v14a1 1 0 01-1 1H5a1 1 0 01-1-1V5z"}),o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12l3 3 5-6"})]}),o.jsxs("span",{children:[d.type==="mermaid"?"Mermaid diagram":d.type==="svg"?"SVG illustration":"Math",d.title?o.jsxs(o.Fragment,{children:[": ",o.jsx("span",{className:"font-medium",children:d.title})]}):null," rendered → see ",o.jsx("span",{className:"font-medium",children:"canvas"})," pane"]})]}):r.output&&s==="completed"&&f&&o.jsx("pre",{className:"mt-2 text-xs text-gray-600 dark:text-gray-400 overflow-x-auto max-h-32 overflow-y-auto whitespace-pre-wrap break-all max-w-full",children:fs((typeof r.output=="string"?r.output:JSON.stringify(r.output,null,2)).slice(0,600)).slice(0,500)}),r.error&&f&&o.jsx("pre",{className:"mt-2 text-xs text-red-600 dark:text-red-400 whitespace-pre-wrap break-all overflow-x-auto max-w-full",children:fs(typeof r.error=="string"?r.error:r.error.message||"Error")})]})}function Oq({part:e}){const{tool:t,state:n}=e,[r,a]=h.useState(!1);if(!n)return null;const i=n.status||"running",s=n.title||t||"Tool",l=xf(t||s,n.input),c=n.input&&n.input._purpose?n.input._purpose:null,u=!c||r;return o.jsxs("div",{className:"py-1",children:[o.jsxs("div",{className:`flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400 ${c?"cursor-pointer select-none":""}`,onClick:c?()=>a(!r):void 0,children:[i==="running"&&o.jsxs("svg",{className:"w-3 h-3 text-gray-400 animate-spin flex-shrink-0",fill:"none",viewBox:"0 0 24 24",children:[o.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),o.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),i==="completed"&&o.jsx("svg",{className:"w-3 h-3 text-green-500 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),i==="error"&&o.jsx("svg",{className:"w-3 h-3 text-red-500 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}),i==="pending_confirmation"&&o.jsx("svg",{className:"w-3 h-3 text-blue-500 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),c?o.jsx("span",{className:"font-medium truncate flex-1",children:c}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"font-medium truncate",children:s}),l&&o.jsx("span",{className:"font-mono text-[11px] text-gray-400 dark:text-gray-500 truncate",children:l})]}),c&&o.jsx("svg",{className:`w-3 h-3 text-gray-400 flex-shrink-0 transition-transform ${r?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),u&&l&&o.jsx("div",{className:"mt-1 font-mono text-[11px] text-gray-400 dark:text-gray-500 truncate",children:l}),n.output&&i==="completed"&&u&&o.jsx("div",{className:"mt-1 font-mono text-[11px] text-gray-500 dark:text-gray-400 break-all whitespace-pre-wrap truncate",children:fs(typeof n.output=="string"?n.output:JSON.stringify(n.output,null,2)).slice(0,500)}),n.error&&u&&o.jsx("div",{className:"mt-1 text-[11px] text-red-500 dark:text-red-400 truncate",children:fs(typeof n.error=="string"?n.error:n.error.message||"Error").slice(0,120)}),n.error&&!u&&o.jsx("div",{className:"mt-1 text-[11px] text-red-500 dark:text-red-400 truncate",children:fs(typeof n.error=="string"?n.error:n.error.message||"Error").slice(0,120)})]})}function Dq({text:e,isStreaming:t}){const{t:n}=Tt(),[r,a]=h.useState(!1),i=e&&e.trim().length>0,s=t&&!r?(e||"").slice(-400).replace(/\s+/g," ").trim():"";return o.jsxs("div",{className:"py-1",children:[o.jsxs("div",{className:`flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400 ${i?"cursor-pointer select-none":""}`,onClick:i?()=>a(!r):void 0,children:[t?o.jsxs("svg",{className:"w-3 h-3 text-gray-400 dark:text-gray-500 animate-spin flex-shrink-0",fill:"none",viewBox:"0 0 24 24",children:[o.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),o.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}):o.jsx("svg",{className:"w-3 h-3 text-green-500 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),o.jsx("span",{className:`font-medium flex-shrink-0 ${s?"":"flex-1"}`,children:n("chat.thinking")}),s&&o.jsx("span",{className:"flex-1 min-w-0 font-medium italic opacity-80 whitespace-nowrap overflow-hidden text-right",style:{maskImage:"linear-gradient(to right, transparent, black 24px)",WebkitMaskImage:"linear-gradient(to right, transparent, black 24px)"},children:s}),i&&o.jsx("svg",{className:`w-3 h-3 text-gray-400 flex-shrink-0 transition-transform ${r?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),r&&i&&o.jsx("div",{className:"mt-1 prose prose-sm dark:prose-invert max-w-none break-words text-gray-600 dark:text-gray-300 italic opacity-80",children:o.jsx(lc,{remarkPlugins:[uc,Mb],children:e})})]})}function Pq(e){return!!(e.hasText||e.hasImages||e.hasTools&&e.toolsVisibleHere||e.isFrameless&&e.hasReasoning)}function Fq(e){return typeof e=="string"?e:e&&typeof e=="object"&&(e.text||e.label)||String(e)}function Bq({part:e,questionId:t}){const{t:n}=Tt(),{state:r}=e,a=r&&r.status||"running",i=r&&r.input||{},s=Array.isArray(i.questions)&&i.questions.length>0?i.questions:[{text:"(no question)",options:void 0}],l=a==="completed",c=r&&r.output||"",[u,d]=h.useState({}),[f,g]=h.useState({}),[p,m]=h.useState(null),[y,v]=h.useState(null),[x,b]=h.useState(t),k=h.useRef(!0),S=h.useRef(null);h.useEffect(()=>{t&&b(t)},[t]);const E=e.callID||e.id||null;h.useEffect(()=>{if(!r||l||x||!E)return;let q=!1;return ZD().then(O=>{if(q||!k.current)return;const L=Array.isArray(O&&O.pending)?O.pending:[];for(var T=0;T<L.length;T++){var M=L[T],U=M.tool&&M.tool.callID?M.tool.callID:null;if(U===E&&M.id){b(M.id);break}}}).catch(()=>{}),()=>{q=!0}},[r,l,x,E]),h.useEffect(()=>()=>{k.current=!1},[]),h.useEffect(()=>{!l&&S.current&&(S.current.focus(),S.current.scrollIntoView({behavior:"smooth",block:"center"}))},[l]);const _=q=>{var O,L;return(((O=u[q])==null?void 0:O.length)??0)>0||(((L=f[q])==null?void 0:L.trim().length)??0)>0},w=s.every((q,O)=>_(O)),C=(q,O,L)=>{d(T=>{const M=T[q]??[];return L?{...T,[q]:M.includes(O)?M.filter(U=>U!==O):[...M,O]}:{...T,[q]:M.includes(O)?[]:[O]}})},A=h.useCallback(async()=>{if(!w||!x)return;const q=s.map((O,L)=>{var U;const T=u[L]??[],M=(U=f[L])==null?void 0:U.trim();return M?[...T,M]:T});m("reply"),v(null);try{const O=await JD(x,q);if(!k.current)return;if(O&&O.success===!1){v(O.error||"Failed to reply"),m(null);return}}catch(O){if(!k.current)return;v(O.message||"Failed to reply"),m(null)}},[x,s,u,f,w]),j=h.useCallback(async()=>{if(x){m("reject"),v(null);try{const q=await eP(x);if(!k.current)return;if(q&&q.success===!1){v(q.error||"Failed to dismiss"),m(null);return}}catch(q){if(!k.current)return;v(q.message||"Failed to dismiss"),m(null)}}},[x]);if(!r)return null;const D=q=>{q.key==="Enter"&&!q.shiftKey&&(q.preventDefault(),A())};if(l)return o.jsxs("div",{className:"my-2 rounded-lg border-l-4 border-primary-500 bg-primary-50/50 dark:bg-primary-900/10 p-3",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.jsx("svg",{className:"w-4 h-4 text-primary-600 dark:text-primary-400 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),o.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-primary-600 dark:text-primary-400",children:n("question.title")}),o.jsx("svg",{className:"w-3.5 h-3.5 text-green-500 flex-shrink-0 ml-auto",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})]}),s.map((q,O)=>o.jsxs("div",{className:O>0?"pt-2 mt-2 border-t border-gray-200 dark:border-gray-700":"",children:[o.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 mb-1 whitespace-pre-wrap",children:q.text}),c&&o.jsx("p",{className:"text-sm font-medium text-primary-700 dark:text-primary-300",children:zq(c,O,s.length)})]},O))]});let P=!1;return o.jsxs("div",{className:"my-2 rounded-lg border-l-4 border-primary-500 bg-primary-50/30 dark:bg-primary-900/10 p-3",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[o.jsx("svg",{className:"w-4 h-4 text-primary-600 dark:text-primary-400 flex-shrink-0 animate-pulse",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),o.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-primary-600 dark:text-primary-400",children:n("question.title")})]}),s.map((q,O)=>{const L=Array.isArray(q.options)?q.options:[],T=L.length>0,M=q.multiple===!0,U=q.custom!==!1,Y=u[O]??[],R=U&&!P;return R&&(P=!0),o.jsxs("div",{className:O>0?"pt-3 mt-3 border-t border-gray-200 dark:border-gray-700":"",children:[(q.header||M)&&o.jsxs("div",{className:"flex items-center gap-2 mb-1.5 flex-wrap",children:[q.header&&o.jsx("span",{className:"text-[10px] uppercase tracking-wider font-semibold text-primary-600 dark:text-primary-400 bg-primary-100 dark:bg-primary-900/30 rounded px-1.5 py-0.5",children:q.header}),M&&o.jsx("span",{className:"text-[10px] uppercase tracking-wider font-semibold text-gray-400 dark:text-gray-500",children:n("question.select_all")})]}),o.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 mb-2 whitespace-pre-wrap",children:q.text}),T&&o.jsx("div",{className:"flex flex-col gap-1.5 mb-2",children:L.map((V,X)=>{const I=Fq(V),H=Y.includes(I);return o.jsx("button",{onClick:()=>C(O,I,M),disabled:p!==null,className:`text-left px-3 py-2 text-sm rounded-md border transition-colors ${H?"border-primary-500 bg-primary-50 dark:bg-primary-900/20 text-primary-700 dark:text-primary-300":"border-gray-200 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700"} disabled:opacity-50 disabled:cursor-not-allowed`,"aria-pressed":H,children:I},X)})}),U&&o.jsx("input",{ref:R?S:void 0,type:"text",value:f[O]??"",onChange:V=>g(X=>({...X,[O]:V.target.value})),onKeyDown:D,disabled:p!==null,placeholder:n(T?"question.custom_placeholder":"question.input_placeholder"),className:"w-full px-3 py-2 text-sm rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-400 dark:placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed"})]},O)}),y&&o.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-3 mb-2",children:y}),!x&&!l&&o.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 mt-2",children:n("question.reconnecting")||"Reconnecting…"}),o.jsxs("div",{className:"flex items-center justify-end gap-2 mt-3",children:[o.jsx("button",{onClick:j,disabled:p!==null||!x,className:"px-3 py-1.5 text-sm font-medium rounded-md border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n(p==="reject"?"question.dismissing":"question.dismiss")}),o.jsx("button",{onClick:A,disabled:p!==null||!w||!x,className:"px-3 py-1.5 text-sm font-medium rounded-md text-white bg-primary-600 hover:bg-primary-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:p==="reply"?n("question.submitting"):s.length>1?n("question.submit_n",{count:s.length}):n("question.submit")})]})]})}function zq(e,t,n){if(n===1){const i="User's answer: ";return e.startsWith(i)?e.slice(i.length):e}const r=e.split(`
84
+ `)&&(c.value=" "+c.value):n.has(c.type)&&a.children.splice(l,0,{type:"text",value:" "}))}r(s)}}return r(t),t}return e}function ed({children:e,language:t,className:n,frameless:r,...a}){const[i,s]=h.useState(!1),l=String(e).replace(/\n$/,""),c=n||(t?"language-"+t:""),u=async()=>{try{await navigator.clipboard.writeText(l),s(!0),setTimeout(()=>s(!1),2e3)}catch{const d=document.createElement("textarea");d.value=l,document.body.appendChild(d),d.select(),document.execCommand("copy"),document.body.removeChild(d),s(!0),setTimeout(()=>s(!1),2e3)}};return r?o.jsxs("div",{className:"relative group rounded-lg overflow-hidden bg-gray-100 dark:bg-gray-800/50 my-3",children:[o.jsx("button",{onClick:u,className:"absolute top-2 right-2 z-10 p-1.5 rounded-md bg-gray-200/80 dark:bg-gray-700/80 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors backdrop-blur-sm",title:"Copy","aria-label":"Copy code",children:i?o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),o.jsx("pre",{className:"p-4 overflow-x-auto text-sm",...a,children:o.jsx("code",{className:c||void 0,children:e})})]}):o.jsxs("div",{className:"relative group rounded-lg overflow-hidden bg-gray-900 dark:bg-gray-950 my-3 px-1.5 py-0.5",children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5 bg-gray-800 dark:bg-gray-900 text-xs text-gray-400",children:[o.jsx("span",{children:t||"code"}),o.jsx("button",{onClick:u,className:"flex items-center gap-1 hover:text-gray-200 transition-colors",children:i?o.jsxs(o.Fragment,{children:[o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),"Copied"]}):o.jsxs(o.Fragment,{children:[o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})}),"Copy"]})})]}),o.jsx("pre",{className:"p-4 overflow-x-auto text-sm",...a,children:o.jsx("code",{className:c||void 0,children:e})})]})}function xf(e,t){if(!t)return"";try{const n=typeof t=="string"?JSON.parse(t):t;if(n.command)return n.command;if(n.filePath&&e==="read")return`read ${n.filePath}`;if(n.pattern&&e==="grep"){const r=n.path||n.include||".";return`grep "${n.pattern}" ${r}`}if(n.pattern&&e==="glob")return`glob "${n.pattern}"`;if(n.filePath&&e==="edit")return`edit ${n.filePath}`;if(n.filePath&&e==="write")return`write ${n.filePath}`;if(n._purpose&&e==="task")return`task "${n._purpose}"`;if(n.url&&(e==="webfetch"||e==="fetch"))return`fetch ${n.url}`;if(n.action&&e==="todo"){let r=`todo ${n.action}`;return n.text&&(r+=` "${n.text}"`),n.id&&(r+=` #${n.id}`),r}if(n.action&&e==="permission"){let r=`permission ${n.action}`;return n.type&&(r+=` ${n.type}`),n.target&&(r+=` ${n.target}`),r}{const r=[];for(const[a,i]of Object.entries(n))if(!(i==null||i===""))if(typeof i=="boolean")i&&r.push(`--${a}`);else if(Array.isArray(i)){const s=i.map(c=>String(c)).join(", "),l=s.length>60?s.slice(0,60)+"...":s;r.push(`--${a} "${l}"`)}else{const s=String(i),l=s.length>60?s.slice(0,60)+"...":s;r.push(`--${a} "${l}"`)}return r.length>0?`${e} ${r.join(" ")}`:e||""}}catch{return""}}function fs(e){return typeof e!="string"?e:e.replace(/\x1b\[[0-9;]*[@-~]|\x1b\].*?(?:\x07|\x1b\\)|\x1b[()][AB012]|\x1b[=>]/g,"")}function Mq(e){if(!e)return null;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{return null}return t&&t.canvas&&t.canvas.type&&t.canvas.source?t.canvas:null}function Lq({part:e}){const{t}=Tt(),{tool:n,state:r}=e,[a,i]=h.useState(!1);if(!r)return null;const s=r.status||"running",l=r.title||n||t("tool.tool"),c=xf(n||l,r.input),u=r.input&&r.input._purpose?r.input._purpose:null,d=s==="completed"?Mq(r.output):null,f=!u||a,g={running:"border-yellow-400 bg-yellow-50 dark:bg-yellow-900/20",completed:"border-green-400 bg-green-50 dark:bg-green-900/20",error:"border-red-400 bg-red-50 dark:bg-red-900/20",pending_confirmation:"border-blue-400 bg-blue-50 dark:bg-blue-900/20"},p={running:o.jsxs("svg",{className:"w-4 h-4 text-yellow-500 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[o.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),o.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),completed:o.jsx("svg",{className:"w-4 h-4 text-green-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),error:o.jsx("svg",{className:"w-4 h-4 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}),pending_confirmation:o.jsx("svg",{className:"w-4 h-4 text-blue-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})};return o.jsxs("div",{className:`rounded-lg border-l-4 p-2 xs:p-3 text-xs sm:text-sm ${g[s]||g.running}`,children:[o.jsxs("div",{className:`flex items-center gap-2 ${u?"cursor-pointer select-none":""}`,onClick:u?()=>i(!a):void 0,children:[p[s]||p.running,u?o.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-200 flex-1",children:u}):o.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-200",children:l}),u&&o.jsx("svg",{className:`w-4 h-4 text-gray-400 flex-shrink-0 transition-transform ${a?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),f&&c&&!d&&o.jsxs("div",{className:"mt-2 font-mono text-xs bg-gray-900 dark:bg-gray-950 text-gray-100 rounded px-2 py-1.5 overflow-x-auto",children:[o.jsx("span",{className:"text-green-400 select-none",children:"$ "}),o.jsx("span",{className:"text-gray-100",children:c})]}),d?o.jsxs("div",{className:"mt-2 text-xs text-blue-700 dark:text-blue-300 flex items-center gap-1.5",children:[o.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 5a1 1 0 011-1h14a1 1 0 011 1v14a1 1 0 01-1 1H5a1 1 0 01-1-1V5z"}),o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12l3 3 5-6"})]}),o.jsxs("span",{children:[d.type==="mermaid"?"Mermaid diagram":d.type==="svg"?"SVG illustration":"Math",d.title?o.jsxs(o.Fragment,{children:[": ",o.jsx("span",{className:"font-medium",children:d.title})]}):null," rendered → see ",o.jsx("span",{className:"font-medium",children:"canvas"})," pane"]})]}):r.output&&s==="completed"&&f&&o.jsx("pre",{className:"mt-2 text-xs text-gray-600 dark:text-gray-400 overflow-x-auto max-h-32 overflow-y-auto whitespace-pre-wrap break-all max-w-full",children:fs((typeof r.output=="string"?r.output:JSON.stringify(r.output,null,2)).slice(0,600)).slice(0,500)}),r.error&&f&&o.jsx("pre",{className:"mt-2 text-xs text-red-600 dark:text-red-400 whitespace-pre-wrap break-all overflow-x-auto max-w-full",children:fs(typeof r.error=="string"?r.error:r.error.message||"Error")})]})}function Oq({part:e}){const{tool:t,state:n}=e,[r,a]=h.useState(!1);if(!n)return null;const i=n.status||"running",s=n.title||t||"Tool",l=xf(t||s,n.input),c=n.input&&n.input._purpose?n.input._purpose:null,u=!c||r;return o.jsxs("div",{className:"py-1",children:[o.jsxs("div",{className:`flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400 ${c?"cursor-pointer select-none":""}`,onClick:c?()=>a(!r):void 0,children:[i==="running"&&o.jsxs("svg",{className:"w-3 h-3 text-gray-400 animate-spin flex-shrink-0",fill:"none",viewBox:"0 0 24 24",children:[o.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),o.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),i==="completed"&&o.jsx("svg",{className:"w-3 h-3 text-green-500 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),i==="error"&&o.jsx("svg",{className:"w-3 h-3 text-red-500 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}),i==="pending_confirmation"&&o.jsx("svg",{className:"w-3 h-3 text-blue-500 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),c?o.jsx("span",{className:"font-medium truncate flex-1",children:c}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"font-medium truncate",children:s}),l&&o.jsx("span",{className:"font-mono text-[11px] text-gray-400 dark:text-gray-500 truncate",children:l})]}),c&&o.jsx("svg",{className:`w-3 h-3 text-gray-400 flex-shrink-0 transition-transform ${r?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),u&&l&&o.jsx("div",{className:"mt-1 font-mono text-[11px] text-gray-400 dark:text-gray-500 truncate",children:l}),n.output&&i==="completed"&&u&&o.jsx("div",{className:"mt-1 font-mono text-[11px] text-gray-500 dark:text-gray-400 break-all whitespace-pre-wrap truncate",children:fs(typeof n.output=="string"?n.output:JSON.stringify(n.output,null,2)).slice(0,500)}),n.error&&u&&o.jsx("div",{className:"mt-1 text-[11px] text-red-500 dark:text-red-400 truncate",children:fs(typeof n.error=="string"?n.error:n.error.message||"Error").slice(0,120)}),n.error&&!u&&o.jsx("div",{className:"mt-1 text-[11px] text-red-500 dark:text-red-400 truncate",children:fs(typeof n.error=="string"?n.error:n.error.message||"Error").slice(0,120)})]})}function Dq({text:e,isStreaming:t}){const{t:n}=Tt(),[r,a]=h.useState(!1),i=e&&e.trim().length>0,s=t&&!r?(e||"").slice(-400).replace(/\s+/g," ").trim():"";return o.jsxs("div",{className:"py-1",children:[o.jsxs("div",{className:`flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400 ${i?"cursor-pointer select-none":""}`,onClick:i?()=>a(!r):void 0,children:[t?o.jsxs("svg",{className:"w-3 h-3 text-gray-400 dark:text-gray-500 animate-spin flex-shrink-0",fill:"none",viewBox:"0 0 24 24",children:[o.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),o.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}):o.jsx("svg",{className:"w-3 h-3 text-green-500 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),o.jsx("span",{className:`font-medium flex-shrink-0 ${s?"":"flex-1"}`,children:n("chat.thinking")}),s&&o.jsx("span",{className:"flex-1 min-w-0 font-medium italic opacity-80 whitespace-nowrap overflow-hidden flex justify-end",style:{maskImage:"linear-gradient(to right, transparent, black 24px)",WebkitMaskImage:"linear-gradient(to right, transparent, black 24px)"},children:s}),i&&o.jsx("svg",{className:`w-3 h-3 text-gray-400 flex-shrink-0 transition-transform ${r?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),r&&i&&o.jsx("div",{className:"mt-1 prose prose-sm dark:prose-invert max-w-none break-words text-gray-600 dark:text-gray-300 italic opacity-80",children:o.jsx(lc,{remarkPlugins:[uc,Mb],children:e})})]})}function Pq(e){return!!(e.hasText||e.hasImages||e.hasTools&&e.toolsVisibleHere||e.isFrameless&&e.hasReasoning)}function Fq(e){return typeof e=="string"?e:e&&typeof e=="object"&&(e.text||e.label)||String(e)}function Bq({part:e,questionId:t}){const{t:n}=Tt(),{state:r}=e,a=r&&r.status||"running",i=r&&r.input||{},s=Array.isArray(i.questions)&&i.questions.length>0?i.questions:[{text:"(no question)",options:void 0}],l=a==="completed",c=r&&r.output||"",[u,d]=h.useState({}),[f,g]=h.useState({}),[p,m]=h.useState(null),[y,v]=h.useState(null),[x,b]=h.useState(t),k=h.useRef(!0),S=h.useRef(null);h.useEffect(()=>{t&&b(t)},[t]);const E=e.callID||e.id||null;h.useEffect(()=>{if(!r||l||x||!E)return;let q=!1;return ZD().then(O=>{if(q||!k.current)return;const L=Array.isArray(O&&O.pending)?O.pending:[];for(var T=0;T<L.length;T++){var M=L[T],U=M.tool&&M.tool.callID?M.tool.callID:null;if(U===E&&M.id){b(M.id);break}}}).catch(()=>{}),()=>{q=!0}},[r,l,x,E]),h.useEffect(()=>()=>{k.current=!1},[]),h.useEffect(()=>{!l&&S.current&&(S.current.focus(),S.current.scrollIntoView({behavior:"smooth",block:"center"}))},[l]);const _=q=>{var O,L;return(((O=u[q])==null?void 0:O.length)??0)>0||(((L=f[q])==null?void 0:L.trim().length)??0)>0},w=s.every((q,O)=>_(O)),C=(q,O,L)=>{d(T=>{const M=T[q]??[];return L?{...T,[q]:M.includes(O)?M.filter(U=>U!==O):[...M,O]}:{...T,[q]:M.includes(O)?[]:[O]}})},A=h.useCallback(async()=>{if(!w||!x)return;const q=s.map((O,L)=>{var U;const T=u[L]??[],M=(U=f[L])==null?void 0:U.trim();return M?[...T,M]:T});m("reply"),v(null);try{const O=await JD(x,q);if(!k.current)return;if(O&&O.success===!1){v(O.error||"Failed to reply"),m(null);return}}catch(O){if(!k.current)return;v(O.message||"Failed to reply"),m(null)}},[x,s,u,f,w]),j=h.useCallback(async()=>{if(x){m("reject"),v(null);try{const q=await eP(x);if(!k.current)return;if(q&&q.success===!1){v(q.error||"Failed to dismiss"),m(null);return}}catch(q){if(!k.current)return;v(q.message||"Failed to dismiss"),m(null)}}},[x]);if(!r)return null;const D=q=>{q.key==="Enter"&&!q.shiftKey&&(q.preventDefault(),A())};if(l)return o.jsxs("div",{className:"my-2 rounded-lg border-l-4 border-primary-500 bg-primary-50/50 dark:bg-primary-900/10 p-3",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.jsx("svg",{className:"w-4 h-4 text-primary-600 dark:text-primary-400 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),o.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-primary-600 dark:text-primary-400",children:n("question.title")}),o.jsx("svg",{className:"w-3.5 h-3.5 text-green-500 flex-shrink-0 ml-auto",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})]}),s.map((q,O)=>o.jsxs("div",{className:O>0?"pt-2 mt-2 border-t border-gray-200 dark:border-gray-700":"",children:[o.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 mb-1 whitespace-pre-wrap",children:q.text}),c&&o.jsx("p",{className:"text-sm font-medium text-primary-700 dark:text-primary-300",children:zq(c,O,s.length)})]},O))]});let P=!1;return o.jsxs("div",{className:"my-2 rounded-lg border-l-4 border-primary-500 bg-primary-50/30 dark:bg-primary-900/10 p-3",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[o.jsx("svg",{className:"w-4 h-4 text-primary-600 dark:text-primary-400 flex-shrink-0 animate-pulse",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),o.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-primary-600 dark:text-primary-400",children:n("question.title")})]}),s.map((q,O)=>{const L=Array.isArray(q.options)?q.options:[],T=L.length>0,M=q.multiple===!0,U=q.custom!==!1,Y=u[O]??[],R=U&&!P;return R&&(P=!0),o.jsxs("div",{className:O>0?"pt-3 mt-3 border-t border-gray-200 dark:border-gray-700":"",children:[(q.header||M)&&o.jsxs("div",{className:"flex items-center gap-2 mb-1.5 flex-wrap",children:[q.header&&o.jsx("span",{className:"text-[10px] uppercase tracking-wider font-semibold text-primary-600 dark:text-primary-400 bg-primary-100 dark:bg-primary-900/30 rounded px-1.5 py-0.5",children:q.header}),M&&o.jsx("span",{className:"text-[10px] uppercase tracking-wider font-semibold text-gray-400 dark:text-gray-500",children:n("question.select_all")})]}),o.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 mb-2 whitespace-pre-wrap",children:q.text}),T&&o.jsx("div",{className:"flex flex-col gap-1.5 mb-2",children:L.map((V,X)=>{const I=Fq(V),H=Y.includes(I);return o.jsx("button",{onClick:()=>C(O,I,M),disabled:p!==null,className:`text-left px-3 py-2 text-sm rounded-md border transition-colors ${H?"border-primary-500 bg-primary-50 dark:bg-primary-900/20 text-primary-700 dark:text-primary-300":"border-gray-200 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700"} disabled:opacity-50 disabled:cursor-not-allowed`,"aria-pressed":H,children:I},X)})}),U&&o.jsx("input",{ref:R?S:void 0,type:"text",value:f[O]??"",onChange:V=>g(X=>({...X,[O]:V.target.value})),onKeyDown:D,disabled:p!==null,placeholder:n(T?"question.custom_placeholder":"question.input_placeholder"),className:"w-full px-3 py-2 text-sm rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-400 dark:placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed"})]},O)}),y&&o.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-3 mb-2",children:y}),!x&&!l&&o.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 mt-2",children:n("question.reconnecting")||"Reconnecting…"}),o.jsxs("div",{className:"flex items-center justify-end gap-2 mt-3",children:[o.jsx("button",{onClick:j,disabled:p!==null||!x,className:"px-3 py-1.5 text-sm font-medium rounded-md border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n(p==="reject"?"question.dismissing":"question.dismiss")}),o.jsx("button",{onClick:A,disabled:p!==null||!w||!x,className:"px-3 py-1.5 text-sm font-medium rounded-md text-white bg-primary-600 hover:bg-primary-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:p==="reply"?n("question.submitting"):s.length>1?n("question.submit_n",{count:s.length}):n("question.submit")})]})]})}function zq(e,t,n){if(n===1){const i="User's answer: ";return e.startsWith(i)?e.slice(i.length):e}const r=e.split(`
85
85
  `),a=`[${t+1}] `;for(const i of r)if(i.startsWith(a))return i.slice(a.length);return e}function Uq({sessionId:e}){const{t}=Tt(),[n,r]=h.useState(null),[a,i]=h.useState(!1),[s,l]=h.useState(null),[c,u]=h.useState(!1),[d,f]=h.useState(null),g=h.useRef(null),p=n!==null;h.useEffect(()=>{if(!a)return;const b=k=>{k.key==="Escape"&&(k.stopPropagation(),i(!1))};return window.addEventListener("keydown",b),g.current&&g.current.focus(),()=>window.removeEventListener("keydown",b)},[a]);const m=async()=>{if(!(p||!e)){i(!0),u(!0),f(null);try{const{content:b}=await MP(e);l(typeof b=="string"?b:"")}catch(b){console.error("Failed to load PLAN.md:",b),f(t("planCard.loadError"))}finally{u(!1)}}},y=()=>{p||(r("executed"),window.dispatchEvent(new CustomEvent("pave:plan-execute")))},v=()=>{p||r("dismissed")},x="inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-xs font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed";return o.jsxs("div",{className:"mt-2 flex flex-col gap-2 rounded-xl border border-amber-300 dark:border-amber-700 bg-amber-50 dark:bg-amber-900/20 px-3 py-2.5 transition-opacity "+(p?"opacity-50":""),children:[o.jsx("div",{className:"text-xs font-medium text-amber-800 dark:text-amber-200",children:t("planCard.heading")}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("button",{type:"button",onClick:m,disabled:p||c||!e,className:x+" border-sky-300 dark:border-sky-700 text-sky-700 dark:text-sky-300 hover:bg-sky-100 dark:hover:bg-sky-900/40",children:t("planCard.showPlan")}),o.jsx("button",{type:"button",onClick:y,disabled:p,className:x+" border-emerald-300 dark:border-emerald-700 text-emerald-700 dark:text-emerald-300 hover:bg-emerald-100 dark:hover:bg-emerald-900/40",children:t("planCard.execute")}),o.jsx("button",{type:"button",onClick:v,disabled:p,className:x+" border-amber-300 dark:border-amber-700 text-amber-700 dark:text-amber-300 hover:bg-amber-100 dark:hover:bg-amber-900/40",children:t("planCard.keepPlanning")})]}),p&&o.jsx("div",{className:"text-[11px] text-gray-500 dark:text-gray-400","aria-live":"polite",children:t(n==="executed"?"planCard.executedStatus":"planCard.dismissedStatus")}),a&&o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:()=>i(!1),children:o.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":t("planCard.heading"),className:"flex max-h-[80vh] w-full max-w-2xl flex-col rounded-lg bg-white dark:bg-gray-800 shadow-xl",onClick:b=>b.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 dark:border-gray-700 px-4 py-2.5",children:[o.jsx("span",{className:"text-sm font-medium text-gray-800 dark:text-gray-100",children:"PLAN.md"}),o.jsx("button",{ref:g,type:"button",onClick:()=>i(!1),className:"rounded p-1 text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 hover:text-gray-600 dark:hover:text-gray-200","aria-label":t("planCard.close"),children:"✕"})]}),c?o.jsx("div",{className:"px-4 py-6 text-xs text-gray-500 dark:text-gray-400",children:t("planCard.loading")}):d?o.jsx("div",{className:"px-4 py-6 text-xs text-red-600 dark:text-red-400",children:d}):o.jsx("pre",{className:"overflow-auto whitespace-pre-wrap break-words px-4 py-3 text-xs text-gray-800 dark:text-gray-200",children:s})]})})]})}const $q="plan.md";function Hq(e){const t=String(e).split(/[\\/]/);return t[t.length-1]||""}function qq(e){return typeof e!="string"||!e?!1:Hq(e).toLowerCase()===$q}function Wq(e){if(!Array.isArray(e))return null;let t=null;for(const n of e){if(!n||n.type!=="tool"||n.tool!=="write"&&n.tool!=="edit")continue;const r=n.state&&n.state.input||{};qq(r.filePath)&&(t={content:typeof r.content=="string"?r.content:null})}return t}function C1(e,t,n=!1){if(t){const r=Object.values(t).filter(a=>a.type==="reasoning"&&n?!1:a.type==="text"||a.type==="reasoning").map(a=>a.text||a.delta||"").join(`
86
86
 
87
87
  `);if(r)return r}return!e||e.length===0?"":e.filter(r=>r.type==="reasoning"&&n?!1:r.type==="text"||r.type==="reasoning").map(r=>r.text||"").join(`
@@ -102,7 +102,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),R=T,Y=M),U===void 0&&(
102
102
  `)?" ":"";f(Ie+Ke+(te||""));return}f(Ie=>{const Ke=Ie&&!Ie.endsWith(" ")&&!Ie.endsWith(`
103
103
  `)?" ":"";return Ie+Ke+te})},[]),He=h.useRef(null),ct=h.useCallback(()=>{Ne.current="",setTimeout(()=>{He.current&&He.current()},50)},[]),{state:Ue,progress:Je,downloadingFile:ce,startRecording:Ve,stopRecording:it,resumeRecording:gt,cancelRecording:Bt}=vW({onTranscript:je,onError:we,onAutoSubmit:ct,model:S||void 0,language:O&&O!=="auto"?O:void 0}),Nn=h.useCallback(()=>(f(te=>(Ne.current=te||"",te)),Ve()),[Ve]);h.useEffect(()=>{try{O&&localStorage.setItem(P,O)}catch{}},[O]),h.useEffect(()=>{if(!T)return;const te=xe=>{U.current&&!U.current.contains(xe.target)&&M(!1)};return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[T]),h.useEffect(()=>{let te=!1;return fb().then(xe=>{te||(xe&&Array.isArray(xe.models)&&xe.models.length>0&&(k(xe.models),E(Ie=>Ie||xe.models[0].name)),xe&&(xe.preferredEngine==="whisper"||xe.preferredEngine==="paraformer")&&V(xe.preferredEngine))}).catch(()=>{}),()=>{te=!0}},[fb]),h.useEffect(()=>{if(!X)return;const te=xe=>{H.current&&!H.current.contains(xe.target)&&I(!1)};return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[X]);const xn=h.useCallback(te=>{I(!1),V(xe=>xe===te?xe:(NP(te).then(()=>{te==="paraformer"&&we("Paraformer selected — the streaming engine is starting (first use downloads ~1 GB).")}).catch(()=>{V(xe),we("Could not switch the speech engine — is the server reachable?")}),te))},[we]);h.useEffect(()=>{if(!_){D(-1);return}A.current.length=b.length;function te(Ie){C.current&&!C.current.contains(Ie.target)&&w(!1)}function xe(Ie){if(Ie.key==="Escape"){w(!1);return}Ie.key!=="ArrowDown"&&Ie.key!=="ArrowUp"&&Ie.key!=="Home"&&Ie.key!=="End"||(Ie.preventDefault(),D(Ke=>{const Et=A.current.length;if(!Et)return Ke;const bt=typeof Ke=="number"?Ke:-1;let Ot=bt;return Ie.key==="ArrowDown"?Ot=bt<Et-1?bt+1:0:Ie.key==="ArrowUp"?Ot=bt>0?bt-1:Et-1:Ie.key==="Home"?Ot=0:Ie.key==="End"&&(Ot=Et-1),A.current[Ot]&&A.current[Ot].focus(),Ot}))}return document.addEventListener("mousedown",te),document.addEventListener("keydown",xe),()=>{document.removeEventListener("mousedown",te),document.removeEventListener("keydown",xe)}},[_,b.length]),h.useEffect(()=>{const te=J.current;te&&(te.style.height="auto",te.style.height=Math.min(te.scrollHeight,200)+"px")},[d]),h.useEffect(()=>{ue.current=g},[g]),h.useEffect(()=>{var te;(te=J.current)==null||te.focus()},[]),h.useImperativeHandle(c,()=>({focus:()=>{var te;(te=J.current)==null||te.focus()},setText:te=>{f(typeof te=="string"?te:""),requestAnimationFrame(()=>{var xe;return(xe=J.current)==null?void 0:xe.focus()})}}),[]);const Ht=async()=>{const te=d.trim();var xe=g.filter(function(bt){return lp(bt.type)}),Ie=g.filter(function(bt){return!lp(bt.type)});const Ke=EW(te);if(Ke&&typeof l=="function"){const bt=he.current;try{await l(Ke.name,Ke.args,{imageAttachments:xe.length>0?xe:void 0,fileAttachments:Ie.length>0?Ie:void 0})}catch{return}if(f(""),Pe(!1),de(""),fe(null),ee(0),bt)try{localStorage.removeItem(Ki+bt)}catch{}g.forEach(function(Ot){Ot.preview&&URL.revokeObjectURL(Ot.preview)}),p([]),J.current&&(J.current.style.height="auto");return}if(!te&&xe.length===0&&Ie.length===0)return;const Et=he.current;try{await t(te,xe.length>0?xe:void 0,m?"plan":void 0,Ie.length>0?Ie:void 0)}catch{return}if(f(""),Pe(!1),de(""),fe(null),ee(0),Et)try{localStorage.removeItem(Ki+Et)}catch{}g.forEach(function(bt){bt.preview&&URL.revokeObjectURL(bt.preview)}),p([]),J.current&&(J.current.style.height="auto")};He.current=Ht;const mr=te=>{if(Ae){const xe=W();if(te.key==="ArrowDown"){xe>0&&(te.preventDefault(),ee(Ie=>(Ie+1)%xe));return}if(te.key==="ArrowUp"){xe>0&&(te.preventDefault(),ee(Ie=>(Ie-1+xe)%xe));return}if(te.key==="Enter"||te.key==="Tab"){if(xe>0){te.preventDefault();const Ie=B[me];Ie&&(Ie.type==="command"?_e(Ie.skill,Ie.name):Ie.type==="builtin"?_e("__builtin__",Ie.name):_e(Ie.skill,null));return}if(te.key==="Tab"){Pe(!1),de(""),fe(null),ee(0);return}}if(te.key==="Escape"){te.preventDefault(),Pe(!1),de(""),fe(null),ee(0);return}if(te.key==="Backspace"&&Re){const Ie=d.slice(1),Ke=Re+" ";if(Ie===Ke||Ie===Re){te.preventDefault(),We();return}}}te.key==="Enter"&&!te.shiftKey&&(te.preventDefault(),Ht())},pn=te=>{if(!a){var xe=te.clipboardData&&te.clipboardData.items;if(xe){for(var Ie=[],Ke=0;Ke<xe.length;Ke++){var Et=(xe[Ke].type||"").toLowerCase();if(yf.indexOf(Et)!==-1){var bt=xe[Ke].getAsFile();bt&&Ie.push(bt)}}if(Ie.length!==0){for(var Ot=!1,ve=0;ve<xe.length;ve++)if(xe[ve].type&&xe[ve].type.startsWith("text/")){Ot=!0;break}Ot||te.preventDefault();var st=Ie.map(function(St){return{id:Date.now()+"-"+Math.random().toString(36).slice(2,8),file:St,name:St.name||"pasted-image.png",size:St.size,type:St.type,preview:null}});p(function(St){var Ta=Dd-St.length;if(Ta<=0)return St;for(var ar=st.slice(0,Ta),It=0;It<ar.length;It++)ar[It].preview=URL.createObjectURL(ar[It].file);return St.concat(ar)})}}}},zt=te=>{const xe=Array.from(te.target.files||[]);if(xe.length===0)return;const Ie=xe.filter(Et=>dI.indexOf(Et.type)!==-1);if(Ie.length===0){te.target.value="";return}const Ke=Ie.map(Et=>({id:Date.now()+"-"+Math.random().toString(36).slice(2,8),file:Et,name:Et.name,size:Et.size,type:Et.type,preview:null}));p(Et=>{var bt=Dd-Et.length;if(bt<=0)return Et;for(var Ot=Ke.slice(0,bt),ve=0;ve<Ot.length;ve++)Ot[ve].preview=lp(Ot[ve].file.type)?URL.createObjectURL(Ot[ve].file):null;return[...Et,...Ot]}),te.target.value=""},Gr=te=>{p(xe=>{const Ie=xe.find(Ke=>Ke.id===te);return Ie!=null&&Ie.preview&&URL.revokeObjectURL(Ie.preview),xe.filter(Ke=>Ke.id!==te)})},se=te=>te<1024?te+" B":te<1024*1024?(te/1024).toFixed(1)+" KB":(te/(1024*1024)).toFixed(1)+" MB";return h.useEffect(()=>()=>{ue.current.forEach(te=>{te.preview&&URL.revokeObjectURL(te.preview)})},[]),o.jsx("div",{className:"border-t border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-950 px-2 sm:px-4 py-3",children:o.jsxs("div",{className:"max-w-full sm:max-w-3xl mx-auto",children:[m&&o.jsxs("div",{className:"flex items-center gap-2 mb-2 px-3 py-1.5 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg text-xs text-amber-700 dark:text-amber-300",children:[o.jsx("svg",{className:"w-3.5 h-3.5 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})}),o.jsx("span",{children:"Plan mode -- read-only. The agent will analyze and plan without making changes."})]}),g.length>0&&o.jsx("div",{className:"flex flex-wrap gap-2 mb-2 overflow-hidden",children:g.map(te=>o.jsxs("div",{className:"relative group flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm",children:[te.preview?o.jsx("img",{src:te.preview,alt:te.name,className:"w-10 h-10 rounded object-cover"}):o.jsx("svg",{className:"w-5 h-5 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"text-xs text-gray-700 dark:text-gray-300 truncate max-w-[120px]",children:te.name}),o.jsx("p",{className:"text-xs text-gray-400",children:se(te.size)})]}),o.jsx("button",{onClick:()=>Gr(te.id),"aria-label":`Remove attachment ${te.name||""}`,className:"absolute -top-1.5 -right-1.5 w-5 h-5 rounded-full bg-gray-500 hover:bg-red-500 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},te.id))}),o.jsxs("div",{className:"relative flex flex-col sm:flex-row sm:items-end gap-1 sm:gap-2 bg-gray-100 dark:bg-gray-800 rounded-2xl px-3 py-2",children:[o.jsx(kW,{skills:pe,builtins:F,filter:be,onSelect:_e,visible:Ae,selectedIndex:me,activeSkill:Re,onBack:We}),o.jsxs("div",{className:"order-2 sm:order-none flex items-center gap-1 flex-wrap sm:flex-nowrap relative",children:[o.jsx("button",{onClick:()=>{var te;return(te=ge.current)==null?void 0:te.click()},disabled:a||r,className:"flex-shrink-0 w-8 h-8 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700 disabled:opacity-40 flex items-center justify-center transition-colors text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",title:u("chat.attach_file"),"aria-label":u("chat.attach_file"),children:o.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M18.375 12.739l-7.693 7.693a4.5 4.5 0 01-6.364-6.364l10.94-10.94A3 3 0 1119.5 7.372L8.552 18.32m.009-.01l-.01.01m5.699-9.941l-7.81 7.81a1.5 1.5 0 002.112 2.13"})})}),o.jsx("input",{ref:ge,type:"file",multiple:!0,accept:iW,onChange:zt,className:"hidden"}),o.jsx("button",{onClick:Ue==="recording"?it:Ue==="paused"?gt:Ue==="loading"?Bt:Nn,disabled:Ue==="draining"||(a||r)&&Ue!=="recording"&&Ue!=="loading"&&Ue!=="paused",className:"flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center transition-colors "+(Ue==="recording"?"bg-red-500 hover:bg-red-600 text-white animate-pulse":Ue==="paused"?"bg-yellow-500 hover:bg-yellow-600 text-white":Ue==="loading"||Ue==="draining"?"bg-gray-200 dark:bg-gray-700 text-gray-400 cursor-wait":"hover:bg-gray-200 dark:hover:bg-gray-700 disabled:opacity-40 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200"),title:Ue==="recording"?u("voice.stop_recording")||"Stop recording":Ue==="paused"?u("voice.resume_recording")||"Resume recording":Ue==="loading"?u("voice.loading_model"):Ue==="draining"?u("voice.processing")||"Processing remaining audio":u("voice.start_recording"),"aria-label":Ue==="recording"?u("voice.stop_recording")||"Stop recording":Ue==="paused"?u("voice.resume_recording")||"Resume recording":Ue==="loading"?u("voice.loading_model"):Ue==="draining"?u("voice.processing")||"Processing remaining audio":u("voice.start_recording"),children:Ue==="draining"?o.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[o.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),o.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}):Ue==="loading"?o.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[o.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),o.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}):Ue==="recording"?o.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 24 24",children:o.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})}):Ue==="paused"?o.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 24 24",children:o.jsx("circle",{cx:"12",cy:"12",r:"6"})}):o.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 18.75a6 6 0 006-6v-1.5m-6 7.5a6 6 0 01-6-6v-1.5m6 7.5v3.75m-3.75 0h7.5M12 15.75a3 3 0 01-3-3V4.5a3 3 0 116 0v8.25a3 3 0 01-3 3z"})})}),Ue==="loading"&&o.jsxs("div",{className:"absolute -top-6 left-1/2 -translate-x-1/2 bg-gray-800 dark:bg-gray-700 text-white text-xs px-2 py-1 rounded shadow whitespace-nowrap flex items-center gap-2",children:[o.jsx("div",{className:"w-16 h-1.5 bg-gray-600 rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full bg-primary-400 transition-all duration-300",style:{width:`${Je}%`}})}),o.jsx("span",{children:ce?`${ce} ${Je}%`:`${Je}%`})]}),R==="whisper"&&o.jsxs("div",{className:"relative flex-shrink-0",ref:U,children:[o.jsxs("button",{onClick:()=>M(te=>!te),disabled:Ue==="recording"||Ue==="draining",className:"h-8 px-2 rounded-full flex items-center justify-center gap-1 transition-colors text-xs font-medium hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 disabled:opacity-40 disabled:cursor-not-allowed",title:"Speech recognition language","aria-label":"Select speech recognition language","aria-haspopup":"menu","aria-expanded":T,children:[o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.5 21l5.25-11.25L21 21m-9-3h7.5M3 5.621a48.474 48.474 0 016-.371m0 0c1.12 0 2.233.038 3.334.114M9 5.25V3m3.334 2.364C11.176 10.658 7.69 15.08 3 17.502m9.334-12.138c.896.061 1.785.147 2.666.257m-4.589 8.495a18.023 18.023 0 01-3.827-5.802"})}),o.jsx("span",{className:"max-w-[80px] truncate",children:(q.find(te=>te.code===O)||q[0]).label}),o.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})})]}),T&&o.jsx("div",{className:"absolute bottom-full mb-1 left-0 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 min-w-[180px] max-h-64 overflow-y-auto z-50",role:"menu","aria-label":"Speech recognition language",children:q.map(te=>o.jsx("button",{role:"menuitemradio","aria-checked":te.code===O,onClick:()=>{L(te.code),M(!1),te.code==="yue"&&we("Cantonese requires whisper-small or larger. If transcription is poor, this device may be using the tiny model (Safari, or older cached version).")},className:"w-full text-left px-3 py-1.5 text-xs transition-colors "+(te.code===O?"bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 font-medium":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"),children:te.label},te.code))})]}),o.jsxs("div",{className:"relative flex-shrink-0",ref:H,children:[o.jsxs("button",{onClick:()=>I(te=>!te),disabled:Ue==="recording"||Ue==="draining",className:"h-8 px-2 rounded-full flex items-center justify-center gap-1 transition-colors text-xs font-medium hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 disabled:opacity-40 disabled:cursor-not-allowed",title:"Speech recognition engine","aria-label":"Select speech recognition engine","aria-haspopup":"menu","aria-expanded":X,children:[o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.348 14.652a3.75 3.75 0 010-5.304m5.304 0a3.75 3.75 0 010 5.304m-7.425 2.121a6.75 6.75 0 010-9.546m9.546 0a6.75 6.75 0 010 9.546M5.106 18.894c-3.808-3.807-3.808-9.98 0-13.788m13.788 0c3.808 3.807 3.808 9.98 0 13.788M12 12h.008v.008H12V12zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z"})}),o.jsx("span",{className:"max-w-[90px] truncate",children:(Y.find(te=>te.code===R)||Y[0]).label}),o.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})})]}),X&&o.jsx("div",{className:"absolute bottom-full mb-1 left-0 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 min-w-[200px] z-50",role:"menu","aria-label":"Speech recognition engine",children:Y.map(te=>o.jsxs("button",{role:"menuitemradio","aria-checked":te.code===R,onClick:()=>xn(te.code),className:"w-full text-left px-3 py-1.5 text-xs transition-colors "+(te.code===R?"bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 font-medium":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"),children:[o.jsx("div",{children:te.label}),o.jsx("div",{className:"text-[10px] text-gray-400 dark:text-gray-500",children:te.code==="whisper"?"Batch · all languages (default)":"Live streaming · 中文/粵語/English"})]},te.code))})]}),R==="whisper"&&b.length>1&&o.jsxs("div",{className:"relative flex-shrink-0",ref:C,children:[o.jsxs("button",{onClick:()=>w(te=>!te),disabled:Ue==="recording"||Ue==="draining",className:"h-8 px-2 rounded-full flex items-center justify-center gap-1 transition-colors text-xs font-medium hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 disabled:opacity-40 disabled:cursor-not-allowed",title:u("voice.select_asr_model"),"aria-label":u("voice.select_asr_model"),"aria-haspopup":"menu","aria-expanded":_,children:[o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09z"})}),o.jsx("span",{className:"max-w-[80px] truncate",children:(b.find(te=>te.name===S)||b[0]).label}),o.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})})]}),_&&o.jsx("div",{className:"absolute bottom-full mb-1 left-0 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 min-w-[160px] z-50",role:"menu","aria-label":u("voice.select_asr_model"),children:b.map((te,xe)=>o.jsxs("button",{ref:Ie=>{A.current[xe]=Ie},role:"menuitemradio","aria-checked":te.name===S,tabIndex:j===xe?0:-1,onClick:()=>{E(te.name),w(!1)},className:"w-full text-left px-3 py-1.5 text-xs transition-colors "+(te.name===S?"bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 font-medium":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"),children:[te.label,te.type!=="openai"&&o.jsxs("span",{className:"ml-1 text-gray-400 dark:text-gray-500",children:["(",te.type,")"]})]},`${te.name}-${xe}`))})]}),o.jsxs("button",{onClick:()=>y(te=>!te),disabled:a||r,className:"flex-shrink-0 h-8 px-2 rounded-full flex items-center justify-center gap-1 transition-colors text-xs font-medium "+(m?"bg-amber-100 dark:bg-amber-900/40 text-amber-700 dark:text-amber-300 ring-1 ring-amber-300 dark:ring-amber-700":"hover:bg-gray-200 dark:hover:bg-gray-700 disabled:opacity-40 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200"),title:m?"Plan mode active (read-only) — click to switch to build":"Switch to plan mode (read-only)","aria-label":m?"Disable plan mode":"Enable plan mode","aria-pressed":m,children:[o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12h3.75M9 15h3.75M9 18h3.75m3 .75H18a2.25 2.25 0 002.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 00-1.123-.08m-5.801 0c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 00.75-.75 2.25 2.25 0 00-.1-.664m-5.8 0A2.251 2.251 0 0113.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m0 0H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V9.375c0-.621-.504-1.125-1.125-1.125H8.25zM6.75 12h.008v.008H6.75V12zm0 3h.008v.008H6.75V15zm0 3h.008v.008H6.75V18z"})}),m?"Plan":""]})]}),o.jsxs("div",{className:"order-1 sm:order-none flex items-end gap-2 flex-1 min-w-0",children:[o.jsx("textarea",{ref:J,value:d,onChange:te=>re(te.target.value),onKeyDown:mr,onPaste:pn,placeholder:u("chat.send_placeholder"),disabled:a,rows:1,role:Ae?"combobox":void 0,"aria-controls":Ae?"slash-command-listbox":void 0,"aria-activedescendant":Ae&&W()>0?"slash-item-"+me:void 0,"aria-expanded":Ae||void 0,className:"flex-1 bg-transparent resize-none outline-none text-sm py-1.5 min-h-[32px] text-gray-900 dark:text-gray-100 placeholder-gray-400 dark:placeholder-gray-500 max-h-[200px]"}),r&&o.jsx("button",{onClick:n,className:"flex-shrink-0 w-8 h-8 rounded-full bg-red-500 hover:bg-red-600 flex items-center justify-center transition-colors",title:u("chat.stop_generating"),"aria-label":u("chat.stop_generating"),children:o.jsx("svg",{className:"w-3.5 h-3.5 text-white",fill:"currentColor",viewBox:"0 0 24 24",children:o.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})})}),o.jsxs("button",{onClick:Ht,disabled:!d.trim()&&g.length===0||a,className:"relative flex-shrink-0 w-8 h-8 rounded-full bg-accent-400 hover:bg-accent-500 disabled:bg-gray-300 dark:disabled:bg-gray-600 flex items-center justify-center transition-colors",title:r?"Queue message (will send when current finishes)":u("chat.send_button"),"aria-label":r?"Queue message":u("chat.send_button"),"aria-disabled":!d.trim()&&g.length===0||a?"true":void 0,children:[o.jsx("svg",{className:"w-4 h-4 text-gray-900",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 12h14M12 5l7 7-7 7"})}),s>0&&o.jsx("span",{className:"absolute -top-1 -right-1 min-w-[16px] h-4 px-1 rounded-full bg-amber-500 text-white text-[10px] font-bold flex items-center justify-center ring-2 ring-white dark:ring-gray-800","aria-label":`${s} message${s===1?"":"s"} queued`,children:s})]})]})]}),o.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1.5 text-center",children:u("chat.send_hint")}),v&&o.jsxs("div",{role:"alert",className:"mt-2 px-3 py-2 bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300 text-sm rounded-lg flex items-center gap-2",children:[o.jsx("svg",{className:"w-4 h-4 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"})}),o.jsx("span",{children:v}),o.jsx("button",{onClick:()=>x(null),className:"ml-auto text-red-500 hover:text-red-700 dark:hover:text-red-200","aria-label":u("voice.dismiss_error"),children:o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]})})});function NW({darkMode:e,onToggleTheme:t}){const{t:n}=Tt(),r=(v,x)=>{const b=n(v);return b===v?x:b},[a,i]=h.useState(""),[s,l]=h.useState(""),[c,u]=h.useState(!1),[d,f]=h.useState(null),[g,p]=h.useState(!1);h.useEffect(()=>{fetch("/auth/membership/available").then(v=>v.json()).then(v=>p(v.available===!0)).catch(()=>{})},[]);const m=async v=>{v.preventDefault(),f(null),u(!0);try{const x=await fetch("/auth/membership/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:a,password:s})}),b=await x.json().catch(()=>({}));if(!x.ok){f(b.error||"Login failed"),u(!1);return}window.location.reload()}catch(x){f("Connection error: "+x.message),u(!1)}},y=async()=>{f(null),u(!0);try{const v=await fetch("/auth/local/login",{method:"POST",credentials:"include"}),x=await v.json().catch(()=>({}));if(!v.ok){f(x.error||"Local login failed"),u(!1);return}window.location.href="/"}catch(v){f("Connection error: "+v.message),u(!1)}};return o.jsxs("div",{className:"min-h-screen flex flex-col bg-gray-50 dark:bg-gray-950",children:[o.jsx("div",{className:"flex justify-end p-4",children:o.jsx("button",{onClick:t,className:"p-2 rounded-lg bg-gray-200 dark:bg-gray-800 text-gray-600 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-700 transition-colors",title:n(e?"theme.light":"theme.dark"),"aria-label":n(e?"theme.light":"theme.dark"),children:e?o.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})}):o.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})})})}),o.jsx("div",{className:"flex-1 flex items-center justify-center px-4",children:o.jsxs("div",{className:"w-full max-w-sm",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-primary-500 mb-4",children:o.jsx("span",{className:"text-white font-bold text-2xl",children:"P"})}),o.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:"PAVE"}),o.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:n("login.pave_subtitle")})]}),o.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-xl border border-gray-200 dark:border-gray-800 p-6 shadow-sm ring-1 ring-accent-400/20",children:[o.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 text-center mb-6",children:n("login.sign_in")}),d&&o.jsx("div",{className:"mb-4 px-3 py-2 rounded-lg bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 text-sm border border-red-200 dark:border-red-800",children:d}),g&&o.jsxs("form",{onSubmit:m,className:"space-y-3 mb-4",children:[o.jsx("input",{type:"email",placeholder:r("login.email_placeholder","Email"),value:a,onChange:v=>i(v.target.value),required:!0,className:"w-full px-3 py-2.5 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 text-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent"}),o.jsx("input",{type:"password",placeholder:r("login.password_placeholder","Password"),value:s,onChange:v=>l(v.target.value),required:!0,className:"w-full px-3 py-2.5 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 text-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent"}),o.jsx("button",{type:"submit",disabled:c,className:"w-full py-2.5 px-4 rounded-lg bg-primary-500 hover:bg-primary-600 text-white font-medium text-sm transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:c?r("login.signing_in","Signing in..."):n("login.sign_in")})]}),g&&o.jsxs("div",{className:"flex items-center gap-3 my-4",children:[o.jsx("div",{className:"flex-1 border-t border-gray-200 dark:border-gray-700"}),o.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:r("login.or","or")}),o.jsx("div",{className:"flex-1 border-t border-gray-200 dark:border-gray-700"})]}),o.jsxs("button",{type:"button",onClick:y,disabled:c,className:"flex items-center justify-center gap-3 w-full py-2.5 px-4 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200 font-medium text-sm transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[o.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),r("login.sign_in_locally","Sign in locally")]}),o.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 text-center mt-4",children:n("login.terms")})]})]})})]})}function CW({user:e,onLogout:t,onSkillManagement:n,onAgentManagement:r,onPricingSettings:a,onDlpSettings:i,onSettings:s}){const{t:l}=Tt(),[c,u]=h.useState(!1),d=h.useRef(null);if(h.useEffect(()=>{if(!c)return;function g(p){d.current&&!d.current.contains(p.target)&&u(!1)}return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[c]),!e)return null;const f=(e.name||e.email||"?").split(" ").map(g=>g[0]).join("").slice(0,2).toUpperCase();return o.jsxs("div",{className:"relative",ref:d,children:[o.jsxs("button",{onClick:()=>u(!c),className:"flex items-center gap-2 px-2 py-1 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",title:e.email,"aria-label":e.name||e.email||l("user_menu.title"),children:[e.picture?o.jsx("img",{src:e.picture,alt:"","aria-hidden":"true",className:"w-7 h-7 rounded-full",referrerPolicy:"no-referrer"}):o.jsx("div",{className:"w-7 h-7 rounded-full bg-primary-500 flex items-center justify-center",children:o.jsx("span",{className:"text-white text-xs font-semibold",children:f})}),o.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 hidden sm:inline max-w-[120px] truncate",children:e.name||e.email}),o.jsx("svg",{className:"w-3 h-3 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),c&&o.jsxs("div",{className:"absolute right-0 top-full mt-1 w-56 bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700 shadow-lg z-50 py-1",children:[o.jsxs("div",{className:"px-3 py-2 border-b border-gray-100 dark:border-gray-800",children:[o.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:e.name}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.email})]}),n&&o.jsxs("button",{type:"button",onClick:()=>{u(!1),n()},className:"w-full text-left px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors flex items-center gap-2",children:[o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11 4a2 2 0 114 0v1a1 1 0 001 1h3a1 1 0 011 1v3a1 1 0 01-1 1h-1a2 2 0 100 4h1a1 1 0 011 1v3a1 1 0 01-1 1h-3a1 1 0 01-1-1v-1a2 2 0 10-4 0v1a1 1 0 01-1 1H7a1 1 0 01-1-1v-3a1 1 0 00-1-1H4a2 2 0 110-4h1a1 1 0 001-1V7a1 1 0 011-1h3a1 1 0 001-1V4z"})}),l("user_menu.skills")]}),r&&o.jsxs("button",{onClick:()=>{u(!1),r()},className:"w-full text-left px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors flex items-center gap-2",children:[o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),l("user_menu.agents")]}),a&&o.jsxs("button",{onClick:()=>{u(!1),a()},className:"w-full text-left px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors flex items-center gap-2",children:[o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),l("user_menu.pricing")]}),i&&o.jsxs("button",{onClick:()=>{u(!1),i()},className:"w-full text-left px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors flex items-center gap-2",children:[o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})}),l("user_menu.privacy_dlp")]}),s&&o.jsxs("button",{onClick:()=>{u(!1),s()},className:"w-full text-left px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors flex items-center gap-2",children:[o.jsxs("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),l("user_menu.settings")]}),t&&o.jsx("button",{onClick:()=>{u(!1),t()},className:"w-full text-left px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",children:l("user_menu.sign_out")})]})]})}function fI({toolParts:e}){const{t}=Tt();return!e||e.length===0?o.jsxs("div",{className:"p-4",children:[o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide font-medium mb-3",children:t("task.activity")}),o.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:t("task.no_active")})]}):o.jsxs("div",{className:"p-4",children:[o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide font-medium mb-3",children:t("task.working")}),o.jsx("div",{className:"space-y-1 max-h-[calc(100vh-300px)] overflow-y-auto",children:e.map(n=>o.jsx(jW,{part:n},n.id))})]})}function jW({part:e}){var a,i;const t=((a=e.state)==null?void 0:a.status)||"running",n=((i=e.state)==null?void 0:i.input)||{},r=TW(e.tool,n);return o.jsxs("div",{className:"flex items-center gap-2 py-1",children:[o.jsxs("div",{className:"flex-shrink-0",children:[t==="running"&&o.jsx("div",{className:"w-3.5 h-3.5 rounded-full border-2 border-primary-400 border-t-transparent animate-spin"}),t==="completed"&&o.jsx("svg",{className:"w-3.5 h-3.5 text-green-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),t==="error"&&o.jsx("svg",{className:"w-3.5 h-3.5 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}),t==="pending_confirmation"&&o.jsx("svg",{className:"w-3.5 h-3.5 text-amber-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01"})})]}),o.jsx("span",{className:`text-xs truncate ${t==="running"?"text-gray-800 dark:text-gray-200":t==="error"?"text-red-500 dark:text-red-400":"text-gray-500 dark:text-gray-400"}`,children:r})]})}function TW(e,t){if(!e)return"Processing...";switch(e){case"Read":return"Reading "+Cu(t.filePath);case"Write":return"Writing "+Cu(t.filePath);case"Edit":return"Editing "+Cu(t.filePath);case"Bash":{const n=t.command||"";return R2(n)}case"Glob":return"Searching for files"+(t.pattern?": "+t.pattern:"");case"Grep":return"Searching code"+(t.pattern?' for "'+Ob(t.pattern,30)+'"':"");case"Fetch":case"WebFetch":return"Fetching web page"+(t.url?": "+Ob(t.url,40):"");case"Skill":{const n=t.name||t.skill||"";return AW(n)}case"Todo":case"TodoWrite":return"Updating plan";case"Task":return t._purpose||"Running sub-task";default:return t.filePath?"Processing "+Cu(t.filePath):t.command?R2(t.command):"Running "+e.toLowerCase()}}function Cu(e){if(!e)return"file";const t=e.split("/"),n=t[t.length-1]||"file";return t.length<=2?n:t[t.length-2]+"/"+n}function R2(e){if(!e)return"Running command";const t=e.trim();if(/^(ls|dir)\b/i.test(t))return"Listing files";if(/^(cat|less|more)\b/i.test(t))return"Reading file contents";if(/^(mkdir)\b/i.test(t))return"Creating directory";if(/^(rm|del)\b/i.test(t))return"Removing files";if(/^(cp|copy)\b/i.test(t))return"Copying files";if(/^(mv|move|rename)\b/i.test(t))return"Moving files";if(/^(git\s+status)\b/i.test(t))return"Checking git status";if(/^(git\s+log)\b/i.test(t))return"Viewing git history";if(/^(git\s+diff)\b/i.test(t))return"Comparing changes";if(/^(git\s+add)\b/i.test(t))return"Staging changes";if(/^(git\s+commit)\b/i.test(t))return"Committing changes";if(/^(git\s+push)\b/i.test(t))return"Pushing to remote";if(/^(git\s+pull)\b/i.test(t))return"Pulling from remote";if(/^(git\s+clone)\b/i.test(t))return"Cloning repository";if(/^(git\s+checkout|git\s+switch)\b/i.test(t))return"Switching branches";if(/^(git\s+branch)\b/i.test(t))return"Managing branches";if(/^git\b/i.test(t))return"Running git command";if(/^(npm\s+install|npm\s+i|yarn\s+install|yarn\s+add|pnpm\s+install)\b/i.test(t))return"Installing dependencies";if(/^(npm\s+run\s+build|yarn\s+build|pnpm\s+build)\b/i.test(t))return"Building project";if(/^(npm\s+run\s+test|npm\s+test|yarn\s+test|jest|pytest|mocha)\b/i.test(t))return"Running tests";if(/^(npm\s+run\s+dev|npm\s+start|yarn\s+dev|yarn\s+start)\b/i.test(t))return"Starting dev server";if(/^(npm|yarn|pnpm)\b/i.test(t))return"Running package manager";if(/^(node|python|ruby|php|java)\b/i.test(t))return"Running script";if(/^(docker)\b/i.test(t))return"Running Docker command";if(/^(curl|wget)\b/i.test(t))return"Fetching URL";if(/^(chmod|chown)\b/i.test(t))return"Changing permissions";if(/^(find|locate)\b/i.test(t))return"Finding files";if(/^(grep|rg|ag)\b/i.test(t))return"Searching file contents";if(/^(sed|awk)\b/i.test(t))return"Processing text";if(/^(echo|printf)\b/i.test(t))return"Running command";if(/^(ssh|scp)\b/i.test(t))return"Connecting remotely";if(/^(ping|traceroute|nslookup|dig)\b/i.test(t))return"Checking network";if(/^(tar|zip|unzip|gzip)\b/i.test(t))return"Compressing/extracting files";const n=t.split(/\s+/)[0];return"Running "+Ob(n,20)}function AW(e,t){const n=(e||"").toLowerCase();return n.includes("gmail")||n.includes("email")?"Checking email":n.includes("gdrive")||n.includes("drive")?"Accessing Google Drive":n.includes("gcal")||n.includes("calendar")?"Checking calendar":n.includes("gtasks")||n.includes("tasks")?"Managing tasks":n.includes("discord")?"Using Discord":n.includes("whatsapp")?"Using WhatsApp":n.includes("wrike")?"Checking Wrike":n.includes("dropbox")?"Accessing Dropbox":n.includes("pandadoc")?"Working with PandaDoc":n.includes("freshbooks")?"Checking FreshBooks":n.includes("mailchimp")?"Using Mailchimp":n.includes("bamboohr")?"Checking BambooHR":e?"Using "+e:"Running skill"}function Ob(e,t){return e?e.length<=t?e:e.slice(0,t)+"...":""}const Db=10,Pb=24,I2=2,RW=14,gI="pave-terminal-font-size";function IW(){try{const e=localStorage.getItem(gI);if(e!==null){const t=parseInt(e,10);if(!Number.isNaN(t)&&t>=Db&&t<=Pb)return t}}catch{}return RW}function pI({toolParts:e,matrixMode:t,onToggleMatrix:n,darkMode:r=!0}){var{t:a}=Tt();const i=h.useRef(null),s=h.useRef(null),l=h.useRef(null),[c,u]=h.useState(IW),d=h.useCallback(()=>{u(y=>Math.max(Db,y-I2))},[]),f=h.useCallback(()=>{u(y=>Math.min(Pb,y+I2))},[]);h.useEffect(()=>{try{localStorage.setItem(gI,String(c))}catch{}},[c]);const g=r?{bg:"bg-gray-950",headerBg:"bg-gray-900",headerBorder:"border-gray-800",titleText:"text-gray-400",promptColor:"text-green-400",commandColor:"text-gray-200",outputColor:"text-green-300/70",waitingText:"text-gray-500",runningColor:"text-yellow-400",doneColor:"text-green-500",errorColor:"text-red-400",pendingColor:"text-blue-400"}:{bg:"bg-gray-100",headerBg:"bg-gray-200",headerBorder:"border-gray-300",titleText:"text-gray-600",promptColor:"text-green-600",commandColor:"text-gray-800",outputColor:"text-green-700/80",waitingText:"text-gray-500",runningColor:"text-yellow-600",doneColor:"text-green-600",errorColor:"text-red-600",pendingColor:"text-blue-600"},p=`px-1.5 py-0.5 text-xs font-mono rounded ${r?"bg-gray-600 text-gray-300 hover:bg-gray-500":"bg-gray-300 text-gray-700 hover:bg-gray-200"} disabled:opacity-40 disabled:cursor-default`;h.useEffect(()=>{i.current&&!t&&(i.current.scrollTop=i.current.scrollHeight)},[e,t]);const m=h.useCallback(()=>{const y=s.current;if(!y)return;const v=y.getContext("2d");if(!v)return;const x=()=>{const C=y.parentElement;if(C&&C.clientWidth>0&&C.clientHeight>0){y.width=C.clientWidth,y.height=C.clientHeight;return}const A=y.getBoundingClientRect();if(A.width>0&&A.height>0){y.width=A.width,y.height=A.height;return}y.width=0,y.height=0};x();const b=c;let k=Math.floor(y.width/b),S=new Array(k).fill(1);const E="アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",_=()=>{v.fillStyle="rgba(0, 0, 0, 0.05)",v.fillRect(0,0,y.width,y.height),v.fillStyle="#0F0",v.font=b+"px monospace";for(let C=0;C<S.length;C++){const A=E.charAt(Math.floor(Math.random()*E.length));v.fillText(A,C*b,S[C]*b),S[C]*b>y.height&&Math.random()>.975&&(S[C]=0),S[C]++}l.current=requestAnimationFrame(_)},w=()=>{x(),k=Math.floor(y.width/b);const C=new Array(k).fill(0);for(let A=0;A<Math.min(S.length,C.length);A++)C[A]=S[A];S=C};return window.addEventListener("resize",w),l.current=requestAnimationFrame(_),()=>{window.removeEventListener("resize",w),l.current&&cancelAnimationFrame(l.current)}},[c]);return h.useEffect(()=>{let y;return t?y=m():l.current&&(cancelAnimationFrame(l.current),l.current=null),()=>{y&&y(),l.current&&(cancelAnimationFrame(l.current),l.current=null)}},[t,m]),e&&e.some(y=>{var v;return(((v=y.state)==null?void 0:v.status)||"running")==="running"}),o.jsxs("div",{className:`flex flex-col h-full ${g.bg} font-mono`,style:{fontSize:c+"px"},children:[o.jsxs("div",{className:`flex items-center justify-between px-3 py-2 ${g.headerBg} border-b ${g.headerBorder} flex-shrink-0`,children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex gap-1.5",children:[o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-500 cursor-pointer",onDoubleClick:n,title:""}),o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-yellow-500"}),o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-green-500"})]}),o.jsx("span",{className:`${g.titleText} text-xs ml-2`,children:"PAVE Terminal"})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{type:"button",onClick:d,disabled:c<=Db,className:p,"aria-label":a("terminal.decrease_font"),title:a("terminal.decrease_font"),children:"A-"}),o.jsx("button",{type:"button",onClick:f,disabled:c>=Pb,className:p,"aria-label":a("terminal.increase_font"),title:a("terminal.increase_font"),children:"A+"})]})]}),o.jsx("div",{className:"flex-1 relative overflow-hidden",children:t?o.jsxs(o.Fragment,{children:[o.jsx("canvas",{ref:s,className:"absolute inset-0 w-full h-full"}),e&&e.length>0&&o.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/60 px-3 py-2 max-h-32 overflow-y-auto",children:e.slice(-3).map(y=>o.jsx(LW,{part:y},y.id))})]}):o.jsx("div",{ref:i,className:"h-full overflow-y-auto px-3 py-2 space-y-1",children:!e||e.length===0?o.jsxs("div",{children:[o.jsxs("div",{className:g.promptColor,children:["$ ",o.jsx("span",{className:"terminal-cursor",children:"█"})]}),o.jsx("p",{className:`${g.waitingText} mt-2`,children:"Awaiting commands..."})]}):o.jsxs(o.Fragment,{children:[e.map(y=>o.jsx(MW,{part:y,theme:g},y.id)),o.jsxs("div",{className:g.promptColor,children:["$ ",o.jsx("span",{className:"terminal-cursor",children:"█"})]})]})})})]})}function MW({part:e,theme:t}){var{t:n}=Tt();const{tool:r,state:a}=e;if(!a)return null;const i=a.status||"running",l=xf(r||a.title,a.input)||r||a.title||"unknown",c=a.output?fs(typeof a.output=="string"?a.output:JSON.stringify(a.output,null,2)):null;return o.jsxs("div",{className:"mb-2",children:[o.jsxs("div",{className:`${t.commandColor} break-all`,children:[o.jsx("span",{className:`${t.promptColor} select-none`,children:"$ "}),l]}),i==="running"&&o.jsx("div",{className:`${t.runningColor} mt-0.5`,children:"[running...]"}),i==="completed"&&c&&o.jsx("pre",{className:`${t.outputColor} mt-0.5 whitespace-pre-wrap break-all`,children:c}),i==="completed"&&!c&&o.jsx("div",{className:`${t.doneColor} mt-0.5`,children:"[done]"}),i==="error"&&o.jsxs("pre",{className:`${t.errorColor} mt-0.5 whitespace-pre-wrap break-all`,children:["[error] ",a.error?fs(typeof a.error=="string"?a.error:a.error.message||n("common.error")):n("common.unknown_error")]}),i==="pending_confirmation"&&o.jsx("div",{className:`${t.pendingColor} mt-0.5`,children:"[awaiting confirmation...]"})]})}function LW({part:e}){const{tool:t,state:n}=e;if(!n)return null;const r=n.status||"running",i=xf(t||n.title,n.input)||t||n.title||"unknown",s={running:"text-yellow-400",completed:"text-green-400",error:"text-red-400",pending_confirmation:"text-blue-400"},l={running:"RUN",completed:"OK",error:"ERR",pending_confirmation:"WAIT"};return o.jsxs("div",{className:"text-xs font-mono truncate",children:[o.jsxs("span",{className:s[r]||"text-gray-400",children:["[",l[r]||r,"]"]}),o.jsxs("span",{className:"text-green-300 ml-1",children:["$ ",i]})]})}function j1(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var up,M2;function OW(){if(M2)return up;M2=1;function e(){this.__data__=[],this.size=0}return up=e,up}var dp,L2;function Oo(){if(L2)return dp;L2=1;function e(t,n){return t===n||t!==t&&n!==n}return dp=e,dp}var fp,O2;function bf(){if(O2)return fp;O2=1;var e=Oo();function t(n,r){for(var a=n.length;a--;)if(e(n[a][0],r))return a;return-1}return fp=t,fp}var gp,D2;function DW(){if(D2)return gp;D2=1;var e=bf(),t=Array.prototype,n=t.splice;function r(a){var i=this.__data__,s=e(i,a);if(s<0)return!1;var l=i.length-1;return s==l?i.pop():n.call(i,s,1),--this.size,!0}return gp=r,gp}var pp,P2;function PW(){if(P2)return pp;P2=1;var e=bf();function t(n){var r=this.__data__,a=e(r,n);return a<0?void 0:r[a][1]}return pp=t,pp}var hp,F2;function FW(){if(F2)return hp;F2=1;var e=bf();function t(n){return e(this.__data__,n)>-1}return hp=t,hp}var mp,B2;function BW(){if(B2)return mp;B2=1;var e=bf();function t(n,r){var a=this.__data__,i=e(a,n);return i<0?(++this.size,a.push([n,r])):a[i][1]=r,this}return mp=t,mp}var xp,z2;function vf(){if(z2)return xp;z2=1;var e=OW(),t=DW(),n=PW(),r=FW(),a=BW();function i(s){var l=-1,c=s==null?0:s.length;for(this.clear();++l<c;){var u=s[l];this.set(u[0],u[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=n,i.prototype.has=r,i.prototype.set=a,xp=i,xp}var yp,U2;function zW(){if(U2)return yp;U2=1;var e=vf();function t(){this.__data__=new e,this.size=0}return yp=t,yp}var bp,$2;function UW(){if($2)return bp;$2=1;function e(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r}return bp=e,bp}var vp,H2;function $W(){if(H2)return vp;H2=1;function e(t){return this.__data__.get(t)}return vp=e,vp}var kp,q2;function HW(){if(q2)return kp;q2=1;function e(t){return this.__data__.has(t)}return kp=e,kp}var _p,W2;function hI(){if(W2)return _p;W2=1;var e=typeof pi=="object"&&pi&&pi.Object===Object&&pi;return _p=e,_p}var wp,V2;function da(){if(V2)return wp;V2=1;var e=hI(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return wp=n,wp}var Ep,G2;function Do(){if(G2)return Ep;G2=1;var e=da(),t=e.Symbol;return Ep=t,Ep}var Sp,K2;function qW(){if(K2)return Sp;K2=1;var e=Do(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,a=e?e.toStringTag:void 0;function i(s){var l=n.call(s,a),c=s[a];try{s[a]=void 0;var u=!0}catch{}var d=r.call(s);return u&&(l?s[a]=c:delete s[a]),d}return Sp=i,Sp}var Np,Y2;function WW(){if(Y2)return Np;Y2=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return Np=n,Np}var Cp,X2;function Cs(){if(X2)return Cp;X2=1;var e=Do(),t=qW(),n=WW(),r="[object Null]",a="[object Undefined]",i=e?e.toStringTag:void 0;function s(l){return l==null?l===void 0?a:r:i&&i in Object(l)?t(l):n(l)}return Cp=s,Cp}var jp,Q2;function Wr(){if(Q2)return jp;Q2=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return jp=e,jp}var Tp,Z2;function Cc(){if(Z2)return Tp;Z2=1;var e=Cs(),t=Wr(),n="[object AsyncFunction]",r="[object Function]",a="[object GeneratorFunction]",i="[object Proxy]";function s(l){if(!t(l))return!1;var c=e(l);return c==r||c==a||c==n||c==i}return Tp=s,Tp}var Ap,J2;function VW(){if(J2)return Ap;J2=1;var e=da(),t=e["__core-js_shared__"];return Ap=t,Ap}var Rp,eE;function GW(){if(eE)return Rp;eE=1;var e=VW(),t=function(){var r=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function n(r){return!!t&&t in r}return Rp=n,Rp}var Ip,tE;function mI(){if(tE)return Ip;tE=1;var e=Function.prototype,t=e.toString;function n(r){if(r!=null){try{return t.call(r)}catch{}try{return r+""}catch{}}return""}return Ip=n,Ip}var Mp,nE;function KW(){if(nE)return Mp;nE=1;var e=Cc(),t=GW(),n=Wr(),r=mI(),a=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,s=Function.prototype,l=Object.prototype,c=s.toString,u=l.hasOwnProperty,d=RegExp("^"+c.call(u).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function f(g){if(!n(g)||t(g))return!1;var p=e(g)?d:i;return p.test(r(g))}return Mp=f,Mp}var Lp,rE;function YW(){if(rE)return Lp;rE=1;function e(t,n){return t==null?void 0:t[n]}return Lp=e,Lp}var Op,aE;function js(){if(aE)return Op;aE=1;var e=KW(),t=YW();function n(r,a){var i=t(r,a);return e(i)?i:void 0}return Op=n,Op}var Dp,iE;function T1(){if(iE)return Dp;iE=1;var e=js(),t=da(),n=e(t,"Map");return Dp=n,Dp}var Pp,sE;function kf(){if(sE)return Pp;sE=1;var e=js(),t=e(Object,"create");return Pp=t,Pp}var Fp,oE;function XW(){if(oE)return Fp;oE=1;var e=kf();function t(){this.__data__=e?e(null):{},this.size=0}return Fp=t,Fp}var Bp,lE;function QW(){if(lE)return Bp;lE=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return Bp=e,Bp}var zp,cE;function ZW(){if(cE)return zp;cE=1;var e=kf(),t="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function a(i){var s=this.__data__;if(e){var l=s[i];return l===t?void 0:l}return r.call(s,i)?s[i]:void 0}return zp=a,zp}var Up,uE;function JW(){if(uE)return Up;uE=1;var e=kf(),t=Object.prototype,n=t.hasOwnProperty;function r(a){var i=this.__data__;return e?i[a]!==void 0:n.call(i,a)}return Up=r,Up}var $p,dE;function eV(){if(dE)return $p;dE=1;var e=kf(),t="__lodash_hash_undefined__";function n(r,a){var i=this.__data__;return this.size+=this.has(r)?0:1,i[r]=e&&a===void 0?t:a,this}return $p=n,$p}var Hp,fE;function tV(){if(fE)return Hp;fE=1;var e=XW(),t=QW(),n=ZW(),r=JW(),a=eV();function i(s){var l=-1,c=s==null?0:s.length;for(this.clear();++l<c;){var u=s[l];this.set(u[0],u[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=n,i.prototype.has=r,i.prototype.set=a,Hp=i,Hp}var qp,gE;function nV(){if(gE)return qp;gE=1;var e=tV(),t=vf(),n=T1();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return qp=r,qp}var Wp,pE;function rV(){if(pE)return Wp;pE=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return Wp=e,Wp}var Vp,hE;function _f(){if(hE)return Vp;hE=1;var e=rV();function t(n,r){var a=n.__data__;return e(r)?a[typeof r=="string"?"string":"hash"]:a.map}return Vp=t,Vp}var Gp,mE;function aV(){if(mE)return Gp;mE=1;var e=_f();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return Gp=t,Gp}var Kp,xE;function iV(){if(xE)return Kp;xE=1;var e=_f();function t(n){return e(this,n).get(n)}return Kp=t,Kp}var Yp,yE;function sV(){if(yE)return Yp;yE=1;var e=_f();function t(n){return e(this,n).has(n)}return Yp=t,Yp}var Xp,bE;function oV(){if(bE)return Xp;bE=1;var e=_f();function t(n,r){var a=e(this,n),i=a.size;return a.set(n,r),this.size+=a.size==i?0:1,this}return Xp=t,Xp}var Qp,vE;function A1(){if(vE)return Qp;vE=1;var e=nV(),t=aV(),n=iV(),r=sV(),a=oV();function i(s){var l=-1,c=s==null?0:s.length;for(this.clear();++l<c;){var u=s[l];this.set(u[0],u[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=n,i.prototype.has=r,i.prototype.set=a,Qp=i,Qp}var Zp,kE;function lV(){if(kE)return Zp;kE=1;var e=vf(),t=T1(),n=A1(),r=200;function a(i,s){var l=this.__data__;if(l instanceof e){var c=l.__data__;if(!t||c.length<r-1)return c.push([i,s]),this.size=++l.size,this;l=this.__data__=new n(c)}return l.set(i,s),this.size=l.size,this}return Zp=a,Zp}var Jp,_E;function wf(){if(_E)return Jp;_E=1;var e=vf(),t=zW(),n=UW(),r=$W(),a=HW(),i=lV();function s(l){var c=this.__data__=new e(l);this.size=c.size}return s.prototype.clear=t,s.prototype.delete=n,s.prototype.get=r,s.prototype.has=a,s.prototype.set=i,Jp=s,Jp}var eh,wE;function R1(){if(wE)return eh;wE=1;function e(t,n){for(var r=-1,a=t==null?0:t.length;++r<a&&n(t[r],r,t)!==!1;);return t}return eh=e,eh}var th,EE;function xI(){if(EE)return th;EE=1;var e=js(),t=function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}}();return th=t,th}var nh,SE;function Ef(){if(SE)return nh;SE=1;var e=xI();function t(n,r,a){r=="__proto__"&&e?e(n,r,{configurable:!0,enumerable:!0,value:a,writable:!0}):n[r]=a}return nh=t,nh}var rh,NE;function Sf(){if(NE)return rh;NE=1;var e=Ef(),t=Oo(),n=Object.prototype,r=n.hasOwnProperty;function a(i,s,l){var c=i[s];(!(r.call(i,s)&&t(c,l))||l===void 0&&!(s in i))&&e(i,s,l)}return rh=a,rh}var ah,CE;function jc(){if(CE)return ah;CE=1;var e=Sf(),t=Ef();function n(r,a,i,s){var l=!i;i||(i={});for(var c=-1,u=a.length;++c<u;){var d=a[c],f=s?s(i[d],r[d],d,i,r):void 0;f===void 0&&(f=r[d]),l?t(i,d,f):e(i,d,f)}return i}return ah=n,ah}var ih,jE;function cV(){if(jE)return ih;jE=1;function e(t,n){for(var r=-1,a=Array(t);++r<t;)a[r]=n(r);return a}return ih=e,ih}var sh,TE;function ja(){if(TE)return sh;TE=1;function e(t){return t!=null&&typeof t=="object"}return sh=e,sh}var oh,AE;function uV(){if(AE)return oh;AE=1;var e=Cs(),t=ja(),n="[object Arguments]";function r(a){return t(a)&&e(a)==n}return oh=r,oh}var lh,RE;function Tc(){if(RE)return lh;RE=1;var e=uV(),t=ja(),n=Object.prototype,r=n.hasOwnProperty,a=n.propertyIsEnumerable,i=e(function(){return arguments}())?e:function(s){return t(s)&&r.call(s,"callee")&&!a.call(s,"callee")};return lh=i,lh}var ch,IE;function Sn(){if(IE)return ch;IE=1;var e=Array.isArray;return ch=e,ch}var pl={exports:{}},uh,ME;function dV(){if(ME)return uh;ME=1;function e(){return!1}return uh=e,uh}pl.exports;var LE;function Po(){return LE||(LE=1,function(e,t){var n=da(),r=dV(),a=t&&!t.nodeType&&t,i=a&&!0&&e&&!e.nodeType&&e,s=i&&i.exports===a,l=s?n.Buffer:void 0,c=l?l.isBuffer:void 0,u=c||r;e.exports=u}(pl,pl.exports)),pl.exports}var dh,OE;function Nf(){if(OE)return dh;OE=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(r,a){var i=typeof r;return a=a??e,!!a&&(i=="number"||i!="symbol"&&t.test(r))&&r>-1&&r%1==0&&r<a}return dh=n,dh}var fh,DE;function I1(){if(DE)return fh;DE=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return fh=t,fh}var gh,PE;function fV(){if(PE)return gh;PE=1;var e=Cs(),t=I1(),n=ja(),r="[object Arguments]",a="[object Array]",i="[object Boolean]",s="[object Date]",l="[object Error]",c="[object Function]",u="[object Map]",d="[object Number]",f="[object Object]",g="[object RegExp]",p="[object Set]",m="[object String]",y="[object WeakMap]",v="[object ArrayBuffer]",x="[object DataView]",b="[object Float32Array]",k="[object Float64Array]",S="[object Int8Array]",E="[object Int16Array]",_="[object Int32Array]",w="[object Uint8Array]",C="[object Uint8ClampedArray]",A="[object Uint16Array]",j="[object Uint32Array]",D={};D[b]=D[k]=D[S]=D[E]=D[_]=D[w]=D[C]=D[A]=D[j]=!0,D[r]=D[a]=D[v]=D[i]=D[x]=D[s]=D[l]=D[c]=D[u]=D[d]=D[f]=D[g]=D[p]=D[m]=D[y]=!1;function P(q){return n(q)&&t(q.length)&&!!D[e(q)]}return gh=P,gh}var ph,FE;function Cf(){if(FE)return ph;FE=1;function e(t){return function(n){return t(n)}}return ph=e,ph}var hl={exports:{}};hl.exports;var BE;function M1(){return BE||(BE=1,function(e,t){var n=hI(),r=t&&!t.nodeType&&t,a=r&&!0&&e&&!e.nodeType&&e,i=a&&a.exports===r,s=i&&n.process,l=function(){try{var c=a&&a.require&&a.require("util").types;return c||s&&s.binding&&s.binding("util")}catch{}}();e.exports=l}(hl,hl.exports)),hl.exports}var hh,zE;function Ac(){if(zE)return hh;zE=1;var e=fV(),t=Cf(),n=M1(),r=n&&n.isTypedArray,a=r?t(r):e;return hh=a,hh}var mh,UE;function yI(){if(UE)return mh;UE=1;var e=cV(),t=Tc(),n=Sn(),r=Po(),a=Nf(),i=Ac(),s=Object.prototype,l=s.hasOwnProperty;function c(u,d){var f=n(u),g=!f&&t(u),p=!f&&!g&&r(u),m=!f&&!g&&!p&&i(u),y=f||g||p||m,v=y?e(u.length,String):[],x=v.length;for(var b in u)(d||l.call(u,b))&&!(y&&(b=="length"||p&&(b=="offset"||b=="parent")||m&&(b=="buffer"||b=="byteLength"||b=="byteOffset")||a(b,x)))&&v.push(b);return v}return mh=c,mh}var xh,$E;function jf(){if($E)return xh;$E=1;var e=Object.prototype;function t(n){var r=n&&n.constructor,a=typeof r=="function"&&r.prototype||e;return n===a}return xh=t,xh}var yh,HE;function bI(){if(HE)return yh;HE=1;function e(t,n){return function(r){return t(n(r))}}return yh=e,yh}var bh,qE;function gV(){if(qE)return bh;qE=1;var e=bI(),t=e(Object.keys,Object);return bh=t,bh}var vh,WE;function L1(){if(WE)return vh;WE=1;var e=jf(),t=gV(),n=Object.prototype,r=n.hasOwnProperty;function a(i){if(!e(i))return t(i);var s=[];for(var l in Object(i))r.call(i,l)&&l!="constructor"&&s.push(l);return s}return vh=a,vh}var kh,VE;function Ja(){if(VE)return kh;VE=1;var e=Cc(),t=I1();function n(r){return r!=null&&t(r.length)&&!e(r)}return kh=n,kh}var _h,GE;function Bi(){if(GE)return _h;GE=1;var e=yI(),t=L1(),n=Ja();function r(a){return n(a)?e(a):t(a)}return _h=r,_h}var wh,KE;function pV(){if(KE)return wh;KE=1;var e=jc(),t=Bi();function n(r,a){return r&&e(a,t(a),r)}return wh=n,wh}var Eh,YE;function hV(){if(YE)return Eh;YE=1;function e(t){var n=[];if(t!=null)for(var r in Object(t))n.push(r);return n}return Eh=e,Eh}var Sh,XE;function mV(){if(XE)return Sh;XE=1;var e=Wr(),t=jf(),n=hV(),r=Object.prototype,a=r.hasOwnProperty;function i(s){if(!e(s))return n(s);var l=t(s),c=[];for(var u in s)u=="constructor"&&(l||!a.call(s,u))||c.push(u);return c}return Sh=i,Sh}var Nh,QE;function Ts(){if(QE)return Nh;QE=1;var e=yI(),t=mV(),n=Ja();function r(a){return n(a)?e(a,!0):t(a)}return Nh=r,Nh}var Ch,ZE;function xV(){if(ZE)return Ch;ZE=1;var e=jc(),t=Ts();function n(r,a){return r&&e(a,t(a),r)}return Ch=n,Ch}var ml={exports:{}};ml.exports;var JE;function vI(){return JE||(JE=1,function(e,t){var n=da(),r=t&&!t.nodeType&&t,a=r&&!0&&e&&!e.nodeType&&e,i=a&&a.exports===r,s=i?n.Buffer:void 0,l=s?s.allocUnsafe:void 0;function c(u,d){if(d)return u.slice();var f=u.length,g=l?l(f):new u.constructor(f);return u.copy(g),g}e.exports=c}(ml,ml.exports)),ml.exports}var jh,eS;function kI(){if(eS)return jh;eS=1;function e(t,n){var r=-1,a=t.length;for(n||(n=Array(a));++r<a;)n[r]=t[r];return n}return jh=e,jh}var Th,tS;function _I(){if(tS)return Th;tS=1;function e(t,n){for(var r=-1,a=t==null?0:t.length,i=0,s=[];++r<a;){var l=t[r];n(l,r,t)&&(s[i++]=l)}return s}return Th=e,Th}var Ah,nS;function wI(){if(nS)return Ah;nS=1;function e(){return[]}return Ah=e,Ah}var Rh,rS;function O1(){if(rS)return Rh;rS=1;var e=_I(),t=wI(),n=Object.prototype,r=n.propertyIsEnumerable,a=Object.getOwnPropertySymbols,i=a?function(s){return s==null?[]:(s=Object(s),e(a(s),function(l){return r.call(s,l)}))}:t;return Rh=i,Rh}var Ih,aS;function yV(){if(aS)return Ih;aS=1;var e=jc(),t=O1();function n(r,a){return e(r,t(r),a)}return Ih=n,Ih}var Mh,iS;function D1(){if(iS)return Mh;iS=1;function e(t,n){for(var r=-1,a=n.length,i=t.length;++r<a;)t[i+r]=n[r];return t}return Mh=e,Mh}var Lh,sS;function Tf(){if(sS)return Lh;sS=1;var e=bI(),t=e(Object.getPrototypeOf,Object);return Lh=t,Lh}var Oh,oS;function EI(){if(oS)return Oh;oS=1;var e=D1(),t=Tf(),n=O1(),r=wI(),a=Object.getOwnPropertySymbols,i=a?function(s){for(var l=[];s;)e(l,n(s)),s=t(s);return l}:r;return Oh=i,Oh}var Dh,lS;function bV(){if(lS)return Dh;lS=1;var e=jc(),t=EI();function n(r,a){return e(r,t(r),a)}return Dh=n,Dh}var Ph,cS;function SI(){if(cS)return Ph;cS=1;var e=D1(),t=Sn();function n(r,a,i){var s=a(r);return t(r)?s:e(s,i(r))}return Ph=n,Ph}var Fh,uS;function NI(){if(uS)return Fh;uS=1;var e=SI(),t=O1(),n=Bi();function r(a){return e(a,n,t)}return Fh=r,Fh}var Bh,dS;function vV(){if(dS)return Bh;dS=1;var e=SI(),t=EI(),n=Ts();function r(a){return e(a,n,t)}return Bh=r,Bh}var zh,fS;function kV(){if(fS)return zh;fS=1;var e=js(),t=da(),n=e(t,"DataView");return zh=n,zh}var Uh,gS;function _V(){if(gS)return Uh;gS=1;var e=js(),t=da(),n=e(t,"Promise");return Uh=n,Uh}var $h,pS;function CI(){if(pS)return $h;pS=1;var e=js(),t=da(),n=e(t,"Set");return $h=n,$h}var Hh,hS;function wV(){if(hS)return Hh;hS=1;var e=js(),t=da(),n=e(t,"WeakMap");return Hh=n,Hh}var qh,mS;function Fo(){if(mS)return qh;mS=1;var e=kV(),t=T1(),n=_V(),r=CI(),a=wV(),i=Cs(),s=mI(),l="[object Map]",c="[object Object]",u="[object Promise]",d="[object Set]",f="[object WeakMap]",g="[object DataView]",p=s(e),m=s(t),y=s(n),v=s(r),x=s(a),b=i;return(e&&b(new e(new ArrayBuffer(1)))!=g||t&&b(new t)!=l||n&&b(n.resolve())!=u||r&&b(new r)!=d||a&&b(new a)!=f)&&(b=function(k){var S=i(k),E=S==c?k.constructor:void 0,_=E?s(E):"";if(_)switch(_){case p:return g;case m:return l;case y:return u;case v:return d;case x:return f}return S}),qh=b,qh}var Wh,xS;function EV(){if(xS)return Wh;xS=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r){var a=r.length,i=new r.constructor(a);return a&&typeof r[0]=="string"&&t.call(r,"index")&&(i.index=r.index,i.input=r.input),i}return Wh=n,Wh}var Vh,yS;function jI(){if(yS)return Vh;yS=1;var e=da(),t=e.Uint8Array;return Vh=t,Vh}var Gh,bS;function P1(){if(bS)return Gh;bS=1;var e=jI();function t(n){var r=new n.constructor(n.byteLength);return new e(r).set(new e(n)),r}return Gh=t,Gh}var Kh,vS;function SV(){if(vS)return Kh;vS=1;var e=P1();function t(n,r){var a=r?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.byteLength)}return Kh=t,Kh}var Yh,kS;function NV(){if(kS)return Yh;kS=1;var e=/\w*$/;function t(n){var r=new n.constructor(n.source,e.exec(n));return r.lastIndex=n.lastIndex,r}return Yh=t,Yh}var Xh,_S;function CV(){if(_S)return Xh;_S=1;var e=Do(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function r(a){return n?Object(n.call(a)):{}}return Xh=r,Xh}var Qh,wS;function TI(){if(wS)return Qh;wS=1;var e=P1();function t(n,r){var a=r?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.length)}return Qh=t,Qh}var Zh,ES;function jV(){if(ES)return Zh;ES=1;var e=P1(),t=SV(),n=NV(),r=CV(),a=TI(),i="[object Boolean]",s="[object Date]",l="[object Map]",c="[object Number]",u="[object RegExp]",d="[object Set]",f="[object String]",g="[object Symbol]",p="[object ArrayBuffer]",m="[object DataView]",y="[object Float32Array]",v="[object Float64Array]",x="[object Int8Array]",b="[object Int16Array]",k="[object Int32Array]",S="[object Uint8Array]",E="[object Uint8ClampedArray]",_="[object Uint16Array]",w="[object Uint32Array]";function C(A,j,D){var P=A.constructor;switch(j){case p:return e(A);case i:case s:return new P(+A);case m:return t(A,D);case y:case v:case x:case b:case k:case S:case E:case _:case w:return a(A,D);case l:return new P;case c:case f:return new P(A);case u:return n(A);case d:return new P;case g:return r(A)}}return Zh=C,Zh}var Jh,SS;function AI(){if(SS)return Jh;SS=1;var e=Wr(),t=Object.create,n=function(){function r(){}return function(a){if(!e(a))return{};if(t)return t(a);r.prototype=a;var i=new r;return r.prototype=void 0,i}}();return Jh=n,Jh}var em,NS;function RI(){if(NS)return em;NS=1;var e=AI(),t=Tf(),n=jf();function r(a){return typeof a.constructor=="function"&&!n(a)?e(t(a)):{}}return em=r,em}var tm,CS;function TV(){if(CS)return tm;CS=1;var e=Fo(),t=ja(),n="[object Map]";function r(a){return t(a)&&e(a)==n}return tm=r,tm}var nm,jS;function AV(){if(jS)return nm;jS=1;var e=TV(),t=Cf(),n=M1(),r=n&&n.isMap,a=r?t(r):e;return nm=a,nm}var rm,TS;function RV(){if(TS)return rm;TS=1;var e=Fo(),t=ja(),n="[object Set]";function r(a){return t(a)&&e(a)==n}return rm=r,rm}var am,AS;function IV(){if(AS)return am;AS=1;var e=RV(),t=Cf(),n=M1(),r=n&&n.isSet,a=r?t(r):e;return am=a,am}var im,RS;function II(){if(RS)return im;RS=1;var e=wf(),t=R1(),n=Sf(),r=pV(),a=xV(),i=vI(),s=kI(),l=yV(),c=bV(),u=NI(),d=vV(),f=Fo(),g=EV(),p=jV(),m=RI(),y=Sn(),v=Po(),x=AV(),b=Wr(),k=IV(),S=Bi(),E=Ts(),_=1,w=2,C=4,A="[object Arguments]",j="[object Array]",D="[object Boolean]",P="[object Date]",q="[object Error]",O="[object Function]",L="[object GeneratorFunction]",T="[object Map]",M="[object Number]",U="[object Object]",Y="[object RegExp]",R="[object Set]",V="[object String]",X="[object Symbol]",I="[object WeakMap]",H="[object ArrayBuffer]",ue="[object DataView]",J="[object Float32Array]",ge="[object Float64Array]",K="[object Int8Array]",he="[object Int16Array]",Me="[object Int32Array]",Te="[object Uint8Array]",Ae="[object Uint8ClampedArray]",Pe="[object Uint16Array]",be="[object Uint32Array]",de={};de[A]=de[j]=de[H]=de[ue]=de[D]=de[P]=de[J]=de[ge]=de[K]=de[he]=de[Me]=de[T]=de[M]=de[U]=de[Y]=de[R]=de[V]=de[X]=de[Te]=de[Ae]=de[Pe]=de[be]=!0,de[q]=de[O]=de[I]=!1;function pe(Oe,me,ee,Re,fe,Ge){var Se,we=me&_,qe=me&w,F=me&C;if(ee&&(Se=fe?ee(Oe,Re,fe,Ge):ee(Oe)),Se!==void 0)return Se;if(!b(Oe))return Oe;var B=y(Oe);if(B){if(Se=g(Oe),!we)return s(Oe,Se)}else{var W=f(Oe),re=W==O||W==L;if(v(Oe))return i(Oe,we);if(W==U||W==A||re&&!fe){if(Se=qe||re?{}:m(Oe),!we)return qe?c(Oe,a(Se,Oe)):l(Oe,r(Se,Oe))}else{if(!de[W])return fe?Oe:{};Se=p(Oe,W,we)}}Ge||(Ge=new e);var _e=Ge.get(Oe);if(_e)return _e;Ge.set(Oe,Se),k(Oe)?Oe.forEach(function(je){Se.add(pe(je,me,ee,je,Oe,Ge))}):x(Oe)&&Oe.forEach(function(je,He){Se.set(He,pe(je,me,ee,He,Oe,Ge))});var We=F?qe?d:u:qe?E:S,Ne=B?void 0:We(Oe);return t(Ne||Oe,function(je,He){Ne&&(He=je,je=Oe[He]),n(Se,He,pe(je,me,ee,He,Oe,Ge))}),Se}return im=pe,im}var sm,IS;function MV(){if(IS)return sm;IS=1;var e=II(),t=4;function n(r){return e(r,t)}return sm=n,sm}var om,MS;function F1(){if(MS)return om;MS=1;function e(t){return function(){return t}}return om=e,om}var lm,LS;function LV(){if(LS)return lm;LS=1;function e(t){return function(n,r,a){for(var i=-1,s=Object(n),l=a(n),c=l.length;c--;){var u=l[t?c:++i];if(r(s[u],u,s)===!1)break}return n}}return lm=e,lm}var cm,OS;function B1(){if(OS)return cm;OS=1;var e=LV(),t=e();return cm=t,cm}var um,DS;function z1(){if(DS)return um;DS=1;var e=B1(),t=Bi();function n(r,a){return r&&e(r,a,t)}return um=n,um}var dm,PS;function OV(){if(PS)return dm;PS=1;var e=Ja();function t(n,r){return function(a,i){if(a==null)return a;if(!e(a))return n(a,i);for(var s=a.length,l=r?s:-1,c=Object(a);(r?l--:++l<s)&&i(c[l],l,c)!==!1;);return a}}return dm=t,dm}var fm,FS;function Af(){if(FS)return fm;FS=1;var e=z1(),t=OV(),n=t(e);return fm=n,fm}var gm,BS;function As(){if(BS)return gm;BS=1;function e(t){return t}return gm=e,gm}var pm,zS;function MI(){if(zS)return pm;zS=1;var e=As();function t(n){return typeof n=="function"?n:e}return pm=t,pm}var hm,US;function LI(){if(US)return hm;US=1;var e=R1(),t=Af(),n=MI(),r=Sn();function a(i,s){var l=r(i)?e:t;return l(i,n(s))}return hm=a,hm}var mm,$S;function OI(){return $S||($S=1,mm=LI()),mm}var xm,HS;function DV(){if(HS)return xm;HS=1;var e=Af();function t(n,r){var a=[];return e(n,function(i,s,l){r(i,s,l)&&a.push(i)}),a}return xm=t,xm}var ym,qS;function PV(){if(qS)return ym;qS=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return ym=t,ym}var bm,WS;function FV(){if(WS)return bm;WS=1;function e(t){return this.__data__.has(t)}return bm=e,bm}var vm,VS;function DI(){if(VS)return vm;VS=1;var e=A1(),t=PV(),n=FV();function r(a){var i=-1,s=a==null?0:a.length;for(this.__data__=new e;++i<s;)this.add(a[i])}return r.prototype.add=r.prototype.push=t,r.prototype.has=n,vm=r,vm}var km,GS;function BV(){if(GS)return km;GS=1;function e(t,n){for(var r=-1,a=t==null?0:t.length;++r<a;)if(n(t[r],r,t))return!0;return!1}return km=e,km}var _m,KS;function PI(){if(KS)return _m;KS=1;function e(t,n){return t.has(n)}return _m=e,_m}var wm,YS;function FI(){if(YS)return wm;YS=1;var e=DI(),t=BV(),n=PI(),r=1,a=2;function i(s,l,c,u,d,f){var g=c&r,p=s.length,m=l.length;if(p!=m&&!(g&&m>p))return!1;var y=f.get(s),v=f.get(l);if(y&&v)return y==l&&v==s;var x=-1,b=!0,k=c&a?new e:void 0;for(f.set(s,l),f.set(l,s);++x<p;){var S=s[x],E=l[x];if(u)var _=g?u(E,S,x,l,s,f):u(S,E,x,s,l,f);if(_!==void 0){if(_)continue;b=!1;break}if(k){if(!t(l,function(w,C){if(!n(k,C)&&(S===w||d(S,w,c,u,f)))return k.push(C)})){b=!1;break}}else if(!(S===E||d(S,E,c,u,f))){b=!1;break}}return f.delete(s),f.delete(l),b}return wm=i,wm}var Em,XS;function zV(){if(XS)return Em;XS=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(a,i){r[++n]=[i,a]}),r}return Em=e,Em}var Sm,QS;function U1(){if(QS)return Sm;QS=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(a){r[++n]=a}),r}return Sm=e,Sm}var Nm,ZS;function UV(){if(ZS)return Nm;ZS=1;var e=Do(),t=jI(),n=Oo(),r=FI(),a=zV(),i=U1(),s=1,l=2,c="[object Boolean]",u="[object Date]",d="[object Error]",f="[object Map]",g="[object Number]",p="[object RegExp]",m="[object Set]",y="[object String]",v="[object Symbol]",x="[object ArrayBuffer]",b="[object DataView]",k=e?e.prototype:void 0,S=k?k.valueOf:void 0;function E(_,w,C,A,j,D,P){switch(C){case b:if(_.byteLength!=w.byteLength||_.byteOffset!=w.byteOffset)return!1;_=_.buffer,w=w.buffer;case x:return!(_.byteLength!=w.byteLength||!D(new t(_),new t(w)));case c:case u:case g:return n(+_,+w);case d:return _.name==w.name&&_.message==w.message;case p:case y:return _==w+"";case f:var q=a;case m:var O=A&s;if(q||(q=i),_.size!=w.size&&!O)return!1;var L=P.get(_);if(L)return L==w;A|=l,P.set(_,w);var T=r(q(_),q(w),A,j,D,P);return P.delete(_),T;case v:if(S)return S.call(_)==S.call(w)}return!1}return Nm=E,Nm}var Cm,JS;function $V(){if(JS)return Cm;JS=1;var e=NI(),t=1,n=Object.prototype,r=n.hasOwnProperty;function a(i,s,l,c,u,d){var f=l&t,g=e(i),p=g.length,m=e(s),y=m.length;if(p!=y&&!f)return!1;for(var v=p;v--;){var x=g[v];if(!(f?x in s:r.call(s,x)))return!1}var b=d.get(i),k=d.get(s);if(b&&k)return b==s&&k==i;var S=!0;d.set(i,s),d.set(s,i);for(var E=f;++v<p;){x=g[v];var _=i[x],w=s[x];if(c)var C=f?c(w,_,x,s,i,d):c(_,w,x,i,s,d);if(!(C===void 0?_===w||u(_,w,l,c,d):C)){S=!1;break}E||(E=x=="constructor")}if(S&&!E){var A=i.constructor,j=s.constructor;A!=j&&"constructor"in i&&"constructor"in s&&!(typeof A=="function"&&A instanceof A&&typeof j=="function"&&j instanceof j)&&(S=!1)}return d.delete(i),d.delete(s),S}return Cm=a,Cm}var jm,eN;function HV(){if(eN)return jm;eN=1;var e=wf(),t=FI(),n=UV(),r=$V(),a=Fo(),i=Sn(),s=Po(),l=Ac(),c=1,u="[object Arguments]",d="[object Array]",f="[object Object]",g=Object.prototype,p=g.hasOwnProperty;function m(y,v,x,b,k,S){var E=i(y),_=i(v),w=E?d:a(y),C=_?d:a(v);w=w==u?f:w,C=C==u?f:C;var A=w==f,j=C==f,D=w==C;if(D&&s(y)){if(!s(v))return!1;E=!0,A=!1}if(D&&!A)return S||(S=new e),E||l(y)?t(y,v,x,b,k,S):n(y,v,w,x,b,k,S);if(!(x&c)){var P=A&&p.call(y,"__wrapped__"),q=j&&p.call(v,"__wrapped__");if(P||q){var O=P?y.value():y,L=q?v.value():v;return S||(S=new e),k(O,L,x,b,S)}}return D?(S||(S=new e),r(y,v,x,b,k,S)):!1}return jm=m,jm}var Tm,tN;function BI(){if(tN)return Tm;tN=1;var e=HV(),t=ja();function n(r,a,i,s,l){return r===a?!0:r==null||a==null||!t(r)&&!t(a)?r!==r&&a!==a:e(r,a,i,s,n,l)}return Tm=n,Tm}var Am,nN;function qV(){if(nN)return Am;nN=1;var e=wf(),t=BI(),n=1,r=2;function a(i,s,l,c){var u=l.length,d=u,f=!c;if(i==null)return!d;for(i=Object(i);u--;){var g=l[u];if(f&&g[2]?g[1]!==i[g[0]]:!(g[0]in i))return!1}for(;++u<d;){g=l[u];var p=g[0],m=i[p],y=g[1];if(f&&g[2]){if(m===void 0&&!(p in i))return!1}else{var v=new e;if(c)var x=c(m,y,p,i,s,v);if(!(x===void 0?t(y,m,n|r,c,v):x))return!1}}return!0}return Am=a,Am}var Rm,rN;function zI(){if(rN)return Rm;rN=1;var e=Wr();function t(n){return n===n&&!e(n)}return Rm=t,Rm}var Im,aN;function WV(){if(aN)return Im;aN=1;var e=zI(),t=Bi();function n(r){for(var a=t(r),i=a.length;i--;){var s=a[i],l=r[s];a[i]=[s,l,e(l)]}return a}return Im=n,Im}var Mm,iN;function UI(){if(iN)return Mm;iN=1;function e(t,n){return function(r){return r==null?!1:r[t]===n&&(n!==void 0||t in Object(r))}}return Mm=e,Mm}var Lm,sN;function VV(){if(sN)return Lm;sN=1;var e=qV(),t=WV(),n=UI();function r(a){var i=t(a);return i.length==1&&i[0][2]?n(i[0][0],i[0][1]):function(s){return s===a||e(s,a,i)}}return Lm=r,Lm}var Om,oN;function Bo(){if(oN)return Om;oN=1;var e=Cs(),t=ja(),n="[object Symbol]";function r(a){return typeof a=="symbol"||t(a)&&e(a)==n}return Om=r,Om}var Dm,lN;function $1(){if(lN)return Dm;lN=1;var e=Sn(),t=Bo(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function a(i,s){if(e(i))return!1;var l=typeof i;return l=="number"||l=="symbol"||l=="boolean"||i==null||t(i)?!0:r.test(i)||!n.test(i)||s!=null&&i in Object(s)}return Dm=a,Dm}var Pm,cN;function GV(){if(cN)return Pm;cN=1;var e=A1(),t="Expected a function";function n(r,a){if(typeof r!="function"||a!=null&&typeof a!="function")throw new TypeError(t);var i=function(){var s=arguments,l=a?a.apply(this,s):s[0],c=i.cache;if(c.has(l))return c.get(l);var u=r.apply(this,s);return i.cache=c.set(l,u)||c,u};return i.cache=new(n.Cache||e),i}return n.Cache=e,Pm=n,Pm}var Fm,uN;function KV(){if(uN)return Fm;uN=1;var e=GV(),t=500;function n(r){var a=e(r,function(s){return i.size===t&&i.clear(),s}),i=a.cache;return a}return Fm=n,Fm}var Bm,dN;function YV(){if(dN)return Bm;dN=1;var e=KV(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=e(function(a){var i=[];return a.charCodeAt(0)===46&&i.push(""),a.replace(t,function(s,l,c,u){i.push(c?u.replace(n,"$1"):l||s)}),i});return Bm=r,Bm}var zm,fN;function Rf(){if(fN)return zm;fN=1;function e(t,n){for(var r=-1,a=t==null?0:t.length,i=Array(a);++r<a;)i[r]=n(t[r],r,t);return i}return zm=e,zm}var Um,gN;function XV(){if(gN)return Um;gN=1;var e=Do(),t=Rf(),n=Sn(),r=Bo(),a=e?e.prototype:void 0,i=a?a.toString:void 0;function s(l){if(typeof l=="string")return l;if(n(l))return t(l,s)+"";if(r(l))return i?i.call(l):"";var c=l+"";return c=="0"&&1/l==-1/0?"-0":c}return Um=s,Um}var $m,pN;function $I(){if(pN)return $m;pN=1;var e=XV();function t(n){return n==null?"":e(n)}return $m=t,$m}var Hm,hN;function If(){if(hN)return Hm;hN=1;var e=Sn(),t=$1(),n=YV(),r=$I();function a(i,s){return e(i)?i:t(i,s)?[i]:n(r(i))}return Hm=a,Hm}var qm,mN;function Rc(){if(mN)return qm;mN=1;var e=Bo();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return qm=t,qm}var Wm,xN;function Mf(){if(xN)return Wm;xN=1;var e=If(),t=Rc();function n(r,a){a=e(a,r);for(var i=0,s=a.length;r!=null&&i<s;)r=r[t(a[i++])];return i&&i==s?r:void 0}return Wm=n,Wm}var Vm,yN;function QV(){if(yN)return Vm;yN=1;var e=Mf();function t(n,r,a){var i=n==null?void 0:e(n,r);return i===void 0?a:i}return Vm=t,Vm}var Gm,bN;function ZV(){if(bN)return Gm;bN=1;function e(t,n){return t!=null&&n in Object(t)}return Gm=e,Gm}var Km,vN;function HI(){if(vN)return Km;vN=1;var e=If(),t=Tc(),n=Sn(),r=Nf(),a=I1(),i=Rc();function s(l,c,u){c=e(c,l);for(var d=-1,f=c.length,g=!1;++d<f;){var p=i(c[d]);if(!(g=l!=null&&u(l,p)))break;l=l[p]}return g||++d!=f?g:(f=l==null?0:l.length,!!f&&a(f)&&r(p,f)&&(n(l)||t(l)))}return Km=s,Km}var Ym,kN;function qI(){if(kN)return Ym;kN=1;var e=ZV(),t=HI();function n(r,a){return r!=null&&t(r,a,e)}return Ym=n,Ym}var Xm,_N;function JV(){if(_N)return Xm;_N=1;var e=BI(),t=QV(),n=qI(),r=$1(),a=zI(),i=UI(),s=Rc(),l=1,c=2;function u(d,f){return r(d)&&a(f)?i(s(d),f):function(g){var p=t(g,d);return p===void 0&&p===f?n(g,d):e(f,p,l|c)}}return Xm=u,Xm}var Qm,wN;function WI(){if(wN)return Qm;wN=1;function e(t){return function(n){return n==null?void 0:n[t]}}return Qm=e,Qm}var Zm,EN;function eG(){if(EN)return Zm;EN=1;var e=Mf();function t(n){return function(r){return e(r,n)}}return Zm=t,Zm}var Jm,SN;function tG(){if(SN)return Jm;SN=1;var e=WI(),t=eG(),n=$1(),r=Rc();function a(i){return n(i)?e(r(i)):t(i)}return Jm=a,Jm}var e0,NN;function ei(){if(NN)return e0;NN=1;var e=VV(),t=JV(),n=As(),r=Sn(),a=tG();function i(s){return typeof s=="function"?s:s==null?n:typeof s=="object"?r(s)?t(s[0],s[1]):e(s):a(s)}return e0=i,e0}var t0,CN;function VI(){if(CN)return t0;CN=1;var e=_I(),t=DV(),n=ei(),r=Sn();function a(i,s){var l=r(i)?e:t;return l(i,n(s,3))}return t0=a,t0}var n0,jN;function nG(){if(jN)return n0;jN=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r,a){return r!=null&&t.call(r,a)}return n0=n,n0}var r0,TN;function GI(){if(TN)return r0;TN=1;var e=nG(),t=HI();function n(r,a){return r!=null&&t(r,a,e)}return r0=n,r0}var a0,AN;function rG(){if(AN)return a0;AN=1;var e=L1(),t=Fo(),n=Tc(),r=Sn(),a=Ja(),i=Po(),s=jf(),l=Ac(),c="[object Map]",u="[object Set]",d=Object.prototype,f=d.hasOwnProperty;function g(p){if(p==null)return!0;if(a(p)&&(r(p)||typeof p=="string"||typeof p.splice=="function"||i(p)||l(p)||n(p)))return!p.length;var m=t(p);if(m==c||m==u)return!p.size;if(s(p))return!e(p).length;for(var y in p)if(f.call(p,y))return!1;return!0}return a0=g,a0}var i0,RN;function KI(){if(RN)return i0;RN=1;function e(t){return t===void 0}return i0=e,i0}var s0,IN;function YI(){if(IN)return s0;IN=1;var e=Af(),t=Ja();function n(r,a){var i=-1,s=t(r)?Array(r.length):[];return e(r,function(l,c,u){s[++i]=a(l,c,u)}),s}return s0=n,s0}var o0,MN;function XI(){if(MN)return o0;MN=1;var e=Rf(),t=ei(),n=YI(),r=Sn();function a(i,s){var l=r(i)?e:n;return l(i,t(s,3))}return o0=a,o0}var l0,LN;function aG(){if(LN)return l0;LN=1;function e(t,n,r,a){var i=-1,s=t==null?0:t.length;for(a&&s&&(r=t[++i]);++i<s;)r=n(r,t[i],i,t);return r}return l0=e,l0}var c0,ON;function iG(){if(ON)return c0;ON=1;function e(t,n,r,a,i){return i(t,function(s,l,c){r=a?(a=!1,s):n(r,s,l,c)}),r}return c0=e,c0}var u0,DN;function QI(){if(DN)return u0;DN=1;var e=aG(),t=Af(),n=ei(),r=iG(),a=Sn();function i(s,l,c){var u=a(s)?e:r,d=arguments.length<3;return u(s,n(l,4),c,d,t)}return u0=i,u0}var d0,PN;function sG(){if(PN)return d0;PN=1;var e=Cs(),t=Sn(),n=ja(),r="[object String]";function a(i){return typeof i=="string"||!t(i)&&n(i)&&e(i)==r}return d0=a,d0}var f0,FN;function oG(){if(FN)return f0;FN=1;var e=WI(),t=e("length");return f0=t,f0}var g0,BN;function lG(){if(BN)return g0;BN=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",a=t+n+r,i="\\ufe0e\\ufe0f",s="\\u200d",l=RegExp("["+s+e+a+i+"]");function c(u){return l.test(u)}return g0=c,g0}var p0,zN;function cG(){if(zN)return p0;zN=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",a=t+n+r,i="\\ufe0e\\ufe0f",s="["+e+"]",l="["+a+"]",c="\\ud83c[\\udffb-\\udfff]",u="(?:"+l+"|"+c+")",d="[^"+e+"]",f="(?:\\ud83c[\\udde6-\\uddff]){2}",g="[\\ud800-\\udbff][\\udc00-\\udfff]",p="\\u200d",m=u+"?",y="["+i+"]?",v="(?:"+p+"(?:"+[d,f,g].join("|")+")"+y+m+")*",x=y+m+v,b="(?:"+[d+l+"?",l,f,g,s].join("|")+")",k=RegExp(c+"(?="+c+")|"+b+x,"g");function S(E){for(var _=k.lastIndex=0;k.test(E);)++_;return _}return p0=S,p0}var h0,UN;function uG(){if(UN)return h0;UN=1;var e=oG(),t=lG(),n=cG();function r(a){return t(a)?n(a):e(a)}return h0=r,h0}var m0,$N;function dG(){if($N)return m0;$N=1;var e=L1(),t=Fo(),n=Ja(),r=sG(),a=uG(),i="[object Map]",s="[object Set]";function l(c){if(c==null)return 0;if(n(c))return r(c)?a(c):c.length;var u=t(c);return u==i||u==s?c.size:e(c).length}return m0=l,m0}var x0,HN;function fG(){if(HN)return x0;HN=1;var e=R1(),t=AI(),n=z1(),r=ei(),a=Tf(),i=Sn(),s=Po(),l=Cc(),c=Wr(),u=Ac();function d(f,g,p){var m=i(f),y=m||s(f)||u(f);if(g=r(g,4),p==null){var v=f&&f.constructor;y?p=m?new v:[]:c(f)?p=l(v)?t(a(f)):{}:p={}}return(y?e:n)(f,function(x,b,k){return g(p,x,b,k)}),p}return x0=d,x0}var y0,qN;function gG(){if(qN)return y0;qN=1;var e=Do(),t=Tc(),n=Sn(),r=e?e.isConcatSpreadable:void 0;function a(i){return n(i)||t(i)||!!(r&&i&&i[r])}return y0=a,y0}var b0,WN;function H1(){if(WN)return b0;WN=1;var e=D1(),t=gG();function n(r,a,i,s,l){var c=-1,u=r.length;for(i||(i=t),l||(l=[]);++c<u;){var d=r[c];a>0&&i(d)?a>1?n(d,a-1,i,s,l):e(l,d):s||(l[l.length]=d)}return l}return b0=n,b0}var v0,VN;function pG(){if(VN)return v0;VN=1;function e(t,n,r){switch(r.length){case 0:return t.call(n);case 1:return t.call(n,r[0]);case 2:return t.call(n,r[0],r[1]);case 3:return t.call(n,r[0],r[1],r[2])}return t.apply(n,r)}return v0=e,v0}var k0,GN;function ZI(){if(GN)return k0;GN=1;var e=pG(),t=Math.max;function n(r,a,i){return a=t(a===void 0?r.length-1:a,0),function(){for(var s=arguments,l=-1,c=t(s.length-a,0),u=Array(c);++l<c;)u[l]=s[a+l];l=-1;for(var d=Array(a+1);++l<a;)d[l]=s[l];return d[a]=i(u),e(r,this,d)}}return k0=n,k0}var _0,KN;function hG(){if(KN)return _0;KN=1;var e=F1(),t=xI(),n=As(),r=t?function(a,i){return t(a,"toString",{configurable:!0,enumerable:!1,value:e(i),writable:!0})}:n;return _0=r,_0}var w0,YN;function mG(){if(YN)return w0;YN=1;var e=800,t=16,n=Date.now;function r(a){var i=0,s=0;return function(){var l=n(),c=t-(l-s);if(s=l,c>0){if(++i>=e)return arguments[0]}else i=0;return a.apply(void 0,arguments)}}return w0=r,w0}var E0,XN;function JI(){if(XN)return E0;XN=1;var e=hG(),t=mG(),n=t(e);return E0=n,E0}var S0,QN;function Lf(){if(QN)return S0;QN=1;var e=As(),t=ZI(),n=JI();function r(a,i){return n(t(a,i,e),a+"")}return S0=r,S0}var N0,ZN;function e3(){if(ZN)return N0;ZN=1;function e(t,n,r,a){for(var i=t.length,s=r+(a?1:-1);a?s--:++s<i;)if(n(t[s],s,t))return s;return-1}return N0=e,N0}var C0,JN;function xG(){if(JN)return C0;JN=1;function e(t){return t!==t}return C0=e,C0}var j0,eC;function yG(){if(eC)return j0;eC=1;function e(t,n,r){for(var a=r-1,i=t.length;++a<i;)if(t[a]===n)return a;return-1}return j0=e,j0}var T0,tC;function bG(){if(tC)return T0;tC=1;var e=e3(),t=xG(),n=yG();function r(a,i,s){return i===i?n(a,i,s):e(a,t,s)}return T0=r,T0}var A0,nC;function vG(){if(nC)return A0;nC=1;var e=bG();function t(n,r){var a=n==null?0:n.length;return!!a&&e(n,r,0)>-1}return A0=t,A0}var R0,rC;function kG(){if(rC)return R0;rC=1;function e(t,n,r){for(var a=-1,i=t==null?0:t.length;++a<i;)if(r(n,t[a]))return!0;return!1}return R0=e,R0}var I0,aC;function _G(){if(aC)return I0;aC=1;function e(){}return I0=e,I0}var M0,iC;function wG(){if(iC)return M0;iC=1;var e=CI(),t=_G(),n=U1(),r=1/0,a=e&&1/n(new e([,-0]))[1]==r?function(i){return new e(i)}:t;return M0=a,M0}var L0,sC;function EG(){if(sC)return L0;sC=1;var e=DI(),t=vG(),n=kG(),r=PI(),a=wG(),i=U1(),s=200;function l(c,u,d){var f=-1,g=t,p=c.length,m=!0,y=[],v=y;if(d)m=!1,g=n;else if(p>=s){var x=u?null:a(c);if(x)return i(x);m=!1,g=r,v=new e}else v=u?[]:y;e:for(;++f<p;){var b=c[f],k=u?u(b):b;if(b=d||b!==0?b:0,m&&k===k){for(var S=v.length;S--;)if(v[S]===k)continue e;u&&v.push(k),y.push(b)}else g(v,k,d)||(v!==y&&v.push(k),y.push(b))}return y}return L0=l,L0}var O0,oC;function t3(){if(oC)return O0;oC=1;var e=Ja(),t=ja();function n(r){return t(r)&&e(r)}return O0=n,O0}var D0,lC;function SG(){if(lC)return D0;lC=1;var e=H1(),t=Lf(),n=EG(),r=t3(),a=t(function(i){return n(e(i,1,r,!0))});return D0=a,D0}var P0,cC;function NG(){if(cC)return P0;cC=1;var e=Rf();function t(n,r){return e(r,function(a){return n[a]})}return P0=t,P0}var F0,uC;function n3(){if(uC)return F0;uC=1;var e=NG(),t=Bi();function n(r){return r==null?[]:e(r,t(r))}return F0=n,F0}var B0,dC;function Vr(){if(dC)return B0;dC=1;var e;if(typeof j1=="function")try{e={clone:MV(),constant:F1(),each:OI(),filter:VI(),has:GI(),isArray:Sn(),isEmpty:rG(),isFunction:Cc(),isUndefined:KI(),keys:Bi(),map:XI(),reduce:QI(),size:dG(),transform:fG(),union:SG(),values:n3()}}catch{}return e||(e=window._),B0=e,B0}var z0,fC;function q1(){if(fC)return z0;fC=1;var e=Vr();z0=a;var t="\0",n="\0",r="";function a(d){this._isDirected=e.has(d,"directed")?d.directed:!0,this._isMultigraph=e.has(d,"multigraph")?d.multigraph:!1,this._isCompound=e.has(d,"compound")?d.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[n]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}a.prototype._nodeCount=0,a.prototype._edgeCount=0,a.prototype.isDirected=function(){return this._isDirected},a.prototype.isMultigraph=function(){return this._isMultigraph},a.prototype.isCompound=function(){return this._isCompound},a.prototype.setGraph=function(d){return this._label=d,this},a.prototype.graph=function(){return this._label},a.prototype.setDefaultNodeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultNodeLabelFn=d,this},a.prototype.nodeCount=function(){return this._nodeCount},a.prototype.nodes=function(){return e.keys(this._nodes)},a.prototype.sources=function(){var d=this;return e.filter(this.nodes(),function(f){return e.isEmpty(d._in[f])})},a.prototype.sinks=function(){var d=this;return e.filter(this.nodes(),function(f){return e.isEmpty(d._out[f])})},a.prototype.setNodes=function(d,f){var g=arguments,p=this;return e.each(d,function(m){g.length>1?p.setNode(m,f):p.setNode(m)}),this},a.prototype.setNode=function(d,f){return e.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=f),this):(this._nodes[d]=arguments.length>1?f:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=n,this._children[d]={},this._children[n][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)},a.prototype.node=function(d){return this._nodes[d]},a.prototype.hasNode=function(d){return e.has(this._nodes,d)},a.prototype.removeNode=function(d){var f=this;if(e.has(this._nodes,d)){var g=function(p){f.removeEdge(f._edgeObjs[p])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],e.each(this.children(d),function(p){f.setParent(p)}),delete this._children[d]),e.each(e.keys(this._in[d]),g),delete this._in[d],delete this._preds[d],e.each(e.keys(this._out[d]),g),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},a.prototype.setParent=function(d,f){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(f))f=n;else{f+="";for(var g=f;!e.isUndefined(g);g=this.parent(g))if(g===d)throw new Error("Setting "+f+" as parent of "+d+" would create a cycle");this.setNode(f)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=f,this._children[f][d]=!0,this},a.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},a.prototype.parent=function(d){if(this._isCompound){var f=this._parent[d];if(f!==n)return f}},a.prototype.children=function(d){if(e.isUndefined(d)&&(d=n),this._isCompound){var f=this._children[d];if(f)return e.keys(f)}else{if(d===n)return this.nodes();if(this.hasNode(d))return[]}},a.prototype.predecessors=function(d){var f=this._preds[d];if(f)return e.keys(f)},a.prototype.successors=function(d){var f=this._sucs[d];if(f)return e.keys(f)},a.prototype.neighbors=function(d){var f=this.predecessors(d);if(f)return e.union(f,this.successors(d))},a.prototype.isLeaf=function(d){var f;return this.isDirected()?f=this.successors(d):f=this.neighbors(d),f.length===0},a.prototype.filterNodes=function(d){var f=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});f.setGraph(this.graph());var g=this;e.each(this._nodes,function(y,v){d(v)&&f.setNode(v,y)}),e.each(this._edgeObjs,function(y){f.hasNode(y.v)&&f.hasNode(y.w)&&f.setEdge(y,g.edge(y))});var p={};function m(y){var v=g.parent(y);return v===void 0||f.hasNode(v)?(p[y]=v,v):v in p?p[v]:m(v)}return this._isCompound&&e.each(f.nodes(),function(y){f.setParent(y,m(y))}),f},a.prototype.setDefaultEdgeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultEdgeLabelFn=d,this},a.prototype.edgeCount=function(){return this._edgeCount},a.prototype.edges=function(){return e.values(this._edgeObjs)},a.prototype.setPath=function(d,f){var g=this,p=arguments;return e.reduce(d,function(m,y){return p.length>1?g.setEdge(m,y,f):g.setEdge(m,y),y}),this},a.prototype.setEdge=function(){var d,f,g,p,m=!1,y=arguments[0];typeof y=="object"&&y!==null&&"v"in y?(d=y.v,f=y.w,g=y.name,arguments.length===2&&(p=arguments[1],m=!0)):(d=y,f=arguments[1],g=arguments[3],arguments.length>2&&(p=arguments[2],m=!0)),d=""+d,f=""+f,e.isUndefined(g)||(g=""+g);var v=l(this._isDirected,d,f,g);if(e.has(this._edgeLabels,v))return m&&(this._edgeLabels[v]=p),this;if(!e.isUndefined(g)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(f),this._edgeLabels[v]=m?p:this._defaultEdgeLabelFn(d,f,g);var x=c(this._isDirected,d,f,g);return d=x.v,f=x.w,Object.freeze(x),this._edgeObjs[v]=x,i(this._preds[f],d),i(this._sucs[d],f),this._in[f][v]=x,this._out[d][v]=x,this._edgeCount++,this},a.prototype.edge=function(d,f,g){var p=arguments.length===1?u(this._isDirected,arguments[0]):l(this._isDirected,d,f,g);return this._edgeLabels[p]},a.prototype.hasEdge=function(d,f,g){var p=arguments.length===1?u(this._isDirected,arguments[0]):l(this._isDirected,d,f,g);return e.has(this._edgeLabels,p)},a.prototype.removeEdge=function(d,f,g){var p=arguments.length===1?u(this._isDirected,arguments[0]):l(this._isDirected,d,f,g),m=this._edgeObjs[p];return m&&(d=m.v,f=m.w,delete this._edgeLabels[p],delete this._edgeObjs[p],s(this._preds[f],d),s(this._sucs[d],f),delete this._in[f][p],delete this._out[d][p],this._edgeCount--),this},a.prototype.inEdges=function(d,f){var g=this._in[d];if(g){var p=e.values(g);return f?e.filter(p,function(m){return m.v===f}):p}},a.prototype.outEdges=function(d,f){var g=this._out[d];if(g){var p=e.values(g);return f?e.filter(p,function(m){return m.w===f}):p}},a.prototype.nodeEdges=function(d,f){var g=this.inEdges(d,f);if(g)return g.concat(this.outEdges(d,f))};function i(d,f){d[f]?d[f]++:d[f]=1}function s(d,f){--d[f]||delete d[f]}function l(d,f,g,p){var m=""+f,y=""+g;if(!d&&m>y){var v=m;m=y,y=v}return m+r+y+r+(e.isUndefined(p)?t:p)}function c(d,f,g,p){var m=""+f,y=""+g;if(!d&&m>y){var v=m;m=y,y=v}var x={v:m,w:y};return p&&(x.name=p),x}function u(d,f){return l(d,f.v,f.w,f.name)}return z0}var U0,gC;function CG(){return gC||(gC=1,U0="2.1.8"),U0}var $0,pC;function jG(){return pC||(pC=1,$0={Graph:q1(),version:CG()}),$0}var H0,hC;function TG(){if(hC)return H0;hC=1;var e=Vr(),t=q1();H0={write:n,read:i};function n(s){var l={options:{directed:s.isDirected(),multigraph:s.isMultigraph(),compound:s.isCompound()},nodes:r(s),edges:a(s)};return e.isUndefined(s.graph())||(l.value=e.clone(s.graph())),l}function r(s){return e.map(s.nodes(),function(l){var c=s.node(l),u=s.parent(l),d={v:l};return e.isUndefined(c)||(d.value=c),e.isUndefined(u)||(d.parent=u),d})}function a(s){return e.map(s.edges(),function(l){var c=s.edge(l),u={v:l.v,w:l.w};return e.isUndefined(l.name)||(u.name=l.name),e.isUndefined(c)||(u.value=c),u})}function i(s){var l=new t(s.options).setGraph(s.value);return e.each(s.nodes,function(c){l.setNode(c.v,c.value),c.parent&&l.setParent(c.v,c.parent)}),e.each(s.edges,function(c){l.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),l}return H0}var q0,mC;function AG(){if(mC)return q0;mC=1;var e=Vr();q0=t;function t(n){var r={},a=[],i;function s(l){e.has(r,l)||(r[l]=!0,i.push(l),e.each(n.successors(l),s),e.each(n.predecessors(l),s))}return e.each(n.nodes(),function(l){i=[],s(l),i.length&&a.push(i)}),a}return q0}var W0,xC;function r3(){if(xC)return W0;xC=1;var e=Vr();W0=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(n){return n.key})},t.prototype.has=function(n){return e.has(this._keyIndices,n)},t.prototype.priority=function(n){var r=this._keyIndices[n];if(r!==void 0)return this._arr[r].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(n,r){var a=this._keyIndices;if(n=String(n),!e.has(a,n)){var i=this._arr,s=i.length;return a[n]=s,i.push({key:n,priority:r}),this._decrease(s),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key},t.prototype.decrease=function(n,r){var a=this._keyIndices[n];if(r>this._arr[a].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[a].priority+" New: "+r);this._arr[a].priority=r,this._decrease(a)},t.prototype._heapify=function(n){var r=this._arr,a=2*n,i=a+1,s=n;a<r.length&&(s=r[a].priority<r[s].priority?a:s,i<r.length&&(s=r[i].priority<r[s].priority?i:s),s!==n&&(this._swap(n,s),this._heapify(s)))},t.prototype._decrease=function(n){for(var r=this._arr,a=r[n].priority,i;n!==0&&(i=n>>1,!(r[i].priority<a));)this._swap(n,i),n=i},t.prototype._swap=function(n,r){var a=this._arr,i=this._keyIndices,s=a[n],l=a[r];a[n]=l,a[r]=s,i[l.key]=n,i[s.key]=r},W0}var V0,yC;function a3(){if(yC)return V0;yC=1;var e=Vr(),t=r3();V0=r;var n=e.constant(1);function r(i,s,l,c){return a(i,String(s),l||n,c||function(u){return i.outEdges(u)})}function a(i,s,l,c){var u={},d=new t,f,g,p=function(m){var y=m.v!==f?m.v:m.w,v=u[y],x=l(m),b=g.distance+x;if(x<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+m+" Weight: "+x);b<v.distance&&(v.distance=b,v.predecessor=f,d.decrease(y,b))};for(i.nodes().forEach(function(m){var y=m===s?0:Number.POSITIVE_INFINITY;u[m]={distance:y},d.add(m,y)});d.size()>0&&(f=d.removeMin(),g=u[f],g.distance!==Number.POSITIVE_INFINITY);)c(f).forEach(p);return u}return V0}var G0,bC;function RG(){if(bC)return G0;bC=1;var e=a3(),t=Vr();G0=n;function n(r,a,i){return t.transform(r.nodes(),function(s,l){s[l]=e(r,l,a,i)},{})}return G0}var K0,vC;function i3(){if(vC)return K0;vC=1;var e=Vr();K0=t;function t(n){var r=0,a=[],i={},s=[];function l(c){var u=i[c]={onStack:!0,lowlink:r,index:r++};if(a.push(c),n.successors(c).forEach(function(g){e.has(i,g)?i[g].onStack&&(u.lowlink=Math.min(u.lowlink,i[g].index)):(l(g),u.lowlink=Math.min(u.lowlink,i[g].lowlink))}),u.lowlink===u.index){var d=[],f;do f=a.pop(),i[f].onStack=!1,d.push(f);while(c!==f);s.push(d)}}return n.nodes().forEach(function(c){e.has(i,c)||l(c)}),s}return K0}var Y0,kC;function IG(){if(kC)return Y0;kC=1;var e=Vr(),t=i3();Y0=n;function n(r){return e.filter(t(r),function(a){return a.length>1||a.length===1&&r.hasEdge(a[0],a[0])})}return Y0}var X0,_C;function MG(){if(_C)return X0;_C=1;var e=Vr();X0=n;var t=e.constant(1);function n(a,i,s){return r(a,i||t,s||function(l){return a.outEdges(l)})}function r(a,i,s){var l={},c=a.nodes();return c.forEach(function(u){l[u]={},l[u][u]={distance:0},c.forEach(function(d){u!==d&&(l[u][d]={distance:Number.POSITIVE_INFINITY})}),s(u).forEach(function(d){var f=d.v===u?d.w:d.v,g=i(d);l[u][f]={distance:g,predecessor:u}})}),c.forEach(function(u){var d=l[u];c.forEach(function(f){var g=l[f];c.forEach(function(p){var m=g[u],y=d[p],v=g[p],x=m.distance+y.distance;x<v.distance&&(v.distance=x,v.predecessor=y.predecessor)})})}),l}return X0}var Q0,wC;function s3(){if(wC)return Q0;wC=1;var e=Vr();Q0=t,t.CycleException=n;function t(r){var a={},i={},s=[];function l(c){if(e.has(i,c))throw new n;e.has(a,c)||(i[c]=!0,a[c]=!0,e.each(r.predecessors(c),l),delete i[c],s.push(c))}if(e.each(r.sinks(),l),e.size(a)!==r.nodeCount())throw new n;return s}function n(){}return n.prototype=new Error,Q0}var Z0,EC;function LG(){if(EC)return Z0;EC=1;var e=s3();Z0=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return Z0}var J0,SC;function o3(){if(SC)return J0;SC=1;var e=Vr();J0=t;function t(r,a,i){e.isArray(a)||(a=[a]);var s=(r.isDirected()?r.successors:r.neighbors).bind(r),l=[],c={};return e.each(a,function(u){if(!r.hasNode(u))throw new Error("Graph does not have node: "+u);n(r,u,i==="post",c,s,l)}),l}function n(r,a,i,s,l,c){e.has(s,a)||(s[a]=!0,i||c.push(a),e.each(l(a),function(u){n(r,u,i,s,l,c)}),i&&c.push(a))}return J0}var ex,NC;function OG(){if(NC)return ex;NC=1;var e=o3();ex=t;function t(n,r){return e(n,r,"post")}return ex}var tx,CC;function DG(){if(CC)return tx;CC=1;var e=o3();tx=t;function t(n,r){return e(n,r,"pre")}return tx}var nx,jC;function PG(){if(jC)return nx;jC=1;var e=Vr(),t=q1(),n=r3();nx=r;function r(a,i){var s=new t,l={},c=new n,u;function d(g){var p=g.v===u?g.w:g.v,m=c.priority(p);if(m!==void 0){var y=i(g);y<m&&(l[p]=u,c.decrease(p,y))}}if(a.nodeCount()===0)return s;e.each(a.nodes(),function(g){c.add(g,Number.POSITIVE_INFINITY),s.setNode(g)}),c.decrease(a.nodes()[0],0);for(var f=!1;c.size()>0;){if(u=c.removeMin(),e.has(l,u))s.setEdge(u,l[u]);else{if(f)throw new Error("Input graph is not connected: "+a);f=!0}a.nodeEdges(u).forEach(d)}return s}return nx}var rx,TC;function FG(){return TC||(TC=1,rx={components:AG(),dijkstra:a3(),dijkstraAll:RG(),findCycles:IG(),floydWarshall:MG(),isAcyclic:LG(),postorder:OG(),preorder:DG(),prim:PG(),tarjan:i3(),topsort:s3()}),rx}var ax,AC;function BG(){if(AC)return ax;AC=1;var e=jG();return ax={Graph:e.Graph,json:TG(),alg:FG(),version:e.version},ax}var Pd;if(typeof j1=="function")try{Pd=BG()}catch{}Pd||(Pd=window.graphlib);var fa=Pd,ix,RC;function zG(){if(RC)return ix;RC=1;var e=II(),t=1,n=4;function r(a){return e(a,t|n)}return ix=r,ix}var sx,IC;function Of(){if(IC)return sx;IC=1;var e=Oo(),t=Ja(),n=Nf(),r=Wr();function a(i,s,l){if(!r(l))return!1;var c=typeof s;return(c=="number"?t(l)&&n(s,l.length):c=="string"&&s in l)?e(l[s],i):!1}return sx=a,sx}var ox,MC;function UG(){if(MC)return ox;MC=1;var e=Lf(),t=Oo(),n=Of(),r=Ts(),a=Object.prototype,i=a.hasOwnProperty,s=e(function(l,c){l=Object(l);var u=-1,d=c.length,f=d>2?c[2]:void 0;for(f&&n(c[0],c[1],f)&&(d=1);++u<d;)for(var g=c[u],p=r(g),m=-1,y=p.length;++m<y;){var v=p[m],x=l[v];(x===void 0||t(x,a[v])&&!i.call(l,v))&&(l[v]=g[v])}return l});return ox=s,ox}var lx,LC;function $G(){if(LC)return lx;LC=1;var e=ei(),t=Ja(),n=Bi();function r(a){return function(i,s,l){var c=Object(i);if(!t(i)){var u=e(s,3);i=n(i),s=function(f){return u(c[f],f,c)}}var d=a(i,s,l);return d>-1?c[u?i[d]:d]:void 0}}return lx=r,lx}var cx,OC;function HG(){if(OC)return cx;OC=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return cx=t,cx}var ux,DC;function qG(){if(DC)return ux;DC=1;var e=HG(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return ux=n,ux}var dx,PC;function WG(){if(PC)return dx;PC=1;var e=qG(),t=Wr(),n=Bo(),r=NaN,a=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,s=/^0o[0-7]+$/i,l=parseInt;function c(u){if(typeof u=="number")return u;if(n(u))return r;if(t(u)){var d=typeof u.valueOf=="function"?u.valueOf():u;u=t(d)?d+"":d}if(typeof u!="string")return u===0?u:+u;u=e(u);var f=i.test(u);return f||s.test(u)?l(u.slice(2),f?2:8):a.test(u)?r:+u}return dx=c,dx}var fx,FC;function l3(){if(FC)return fx;FC=1;var e=WG(),t=1/0,n=17976931348623157e292;function r(a){if(!a)return a===0?a:0;if(a=e(a),a===t||a===-t){var i=a<0?-1:1;return i*n}return a===a?a:0}return fx=r,fx}var gx,BC;function VG(){if(BC)return gx;BC=1;var e=l3();function t(n){var r=e(n),a=r%1;return r===r?a?r-a:r:0}return gx=t,gx}var px,zC;function GG(){if(zC)return px;zC=1;var e=e3(),t=ei(),n=VG(),r=Math.max;function a(i,s,l){var c=i==null?0:i.length;if(!c)return-1;var u=l==null?0:n(l);return u<0&&(u=r(c+u,0)),e(i,t(s,3),u)}return px=a,px}var hx,UC;function KG(){if(UC)return hx;UC=1;var e=$G(),t=GG(),n=e(t);return hx=n,hx}var mx,$C;function c3(){if($C)return mx;$C=1;var e=H1();function t(n){var r=n==null?0:n.length;return r?e(n,1):[]}return mx=t,mx}var xx,HC;function YG(){if(HC)return xx;HC=1;var e=B1(),t=MI(),n=Ts();function r(a,i){return a==null?a:e(a,t(i),n)}return xx=r,xx}var yx,qC;function XG(){if(qC)return yx;qC=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return yx=e,yx}var bx,WC;function QG(){if(WC)return bx;WC=1;var e=Ef(),t=z1(),n=ei();function r(a,i){var s={};return i=n(i,3),t(a,function(l,c,u){e(s,c,i(l,c,u))}),s}return bx=r,bx}var vx,VC;function W1(){if(VC)return vx;VC=1;var e=Bo();function t(n,r,a){for(var i=-1,s=n.length;++i<s;){var l=n[i],c=r(l);if(c!=null&&(u===void 0?c===c&&!e(c):a(c,u)))var u=c,d=l}return d}return vx=t,vx}var kx,GC;function ZG(){if(GC)return kx;GC=1;function e(t,n){return t>n}return kx=e,kx}var _x,KC;function JG(){if(KC)return _x;KC=1;var e=W1(),t=ZG(),n=As();function r(a){return a&&a.length?e(a,n,t):void 0}return _x=r,_x}var wx,YC;function u3(){if(YC)return wx;YC=1;var e=Ef(),t=Oo();function n(r,a,i){(i!==void 0&&!t(r[a],i)||i===void 0&&!(a in r))&&e(r,a,i)}return wx=n,wx}var Ex,XC;function eK(){if(XC)return Ex;XC=1;var e=Cs(),t=Tf(),n=ja(),r="[object Object]",a=Function.prototype,i=Object.prototype,s=a.toString,l=i.hasOwnProperty,c=s.call(Object);function u(d){if(!n(d)||e(d)!=r)return!1;var f=t(d);if(f===null)return!0;var g=l.call(f,"constructor")&&f.constructor;return typeof g=="function"&&g instanceof g&&s.call(g)==c}return Ex=u,Ex}var Sx,QC;function d3(){if(QC)return Sx;QC=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return Sx=e,Sx}var Nx,ZC;function tK(){if(ZC)return Nx;ZC=1;var e=jc(),t=Ts();function n(r){return e(r,t(r))}return Nx=n,Nx}var Cx,JC;function nK(){if(JC)return Cx;JC=1;var e=u3(),t=vI(),n=TI(),r=kI(),a=RI(),i=Tc(),s=Sn(),l=t3(),c=Po(),u=Cc(),d=Wr(),f=eK(),g=Ac(),p=d3(),m=tK();function y(v,x,b,k,S,E,_){var w=p(v,b),C=p(x,b),A=_.get(C);if(A){e(v,b,A);return}var j=E?E(w,C,b+"",v,x,_):void 0,D=j===void 0;if(D){var P=s(C),q=!P&&c(C),O=!P&&!q&&g(C);j=C,P||q||O?s(w)?j=w:l(w)?j=r(w):q?(D=!1,j=t(C,!0)):O?(D=!1,j=n(C,!0)):j=[]:f(C)||i(C)?(j=w,i(w)?j=m(w):(!d(w)||u(w))&&(j=a(C))):D=!1}D&&(_.set(C,j),S(j,C,k,E,_),_.delete(C)),e(v,b,j)}return Cx=y,Cx}var jx,e4;function rK(){if(e4)return jx;e4=1;var e=wf(),t=u3(),n=B1(),r=nK(),a=Wr(),i=Ts(),s=d3();function l(c,u,d,f,g){c!==u&&n(u,function(p,m){if(g||(g=new e),a(p))r(c,u,m,d,l,f,g);else{var y=f?f(s(c,m),p,m+"",c,u,g):void 0;y===void 0&&(y=p),t(c,m,y)}},i)}return jx=l,jx}var Tx,t4;function aK(){if(t4)return Tx;t4=1;var e=Lf(),t=Of();function n(r){return e(function(a,i){var s=-1,l=i.length,c=l>1?i[l-1]:void 0,u=l>2?i[2]:void 0;for(c=r.length>3&&typeof c=="function"?(l--,c):void 0,u&&t(i[0],i[1],u)&&(c=l<3?void 0:c,l=1),a=Object(a);++s<l;){var d=i[s];d&&r(a,d,s,c)}return a})}return Tx=n,Tx}var Ax,n4;function iK(){if(n4)return Ax;n4=1;var e=rK(),t=aK(),n=t(function(r,a,i){e(r,a,i)});return Ax=n,Ax}var Rx,r4;function f3(){if(r4)return Rx;r4=1;function e(t,n){return t<n}return Rx=e,Rx}var Ix,a4;function sK(){if(a4)return Ix;a4=1;var e=W1(),t=f3(),n=As();function r(a){return a&&a.length?e(a,n,t):void 0}return Ix=r,Ix}var Mx,i4;function oK(){if(i4)return Mx;i4=1;var e=W1(),t=ei(),n=f3();function r(a,i){return a&&a.length?e(a,t(i,2),n):void 0}return Mx=r,Mx}var Lx,s4;function lK(){if(s4)return Lx;s4=1;var e=da(),t=function(){return e.Date.now()};return Lx=t,Lx}var Ox,o4;function cK(){if(o4)return Ox;o4=1;var e=Sf(),t=If(),n=Nf(),r=Wr(),a=Rc();function i(s,l,c,u){if(!r(s))return s;l=t(l,s);for(var d=-1,f=l.length,g=f-1,p=s;p!=null&&++d<f;){var m=a(l[d]),y=c;if(m==="__proto__"||m==="constructor"||m==="prototype")return s;if(d!=g){var v=p[m];y=u?u(v,m,p):void 0,y===void 0&&(y=r(v)?v:n(l[d+1])?[]:{})}e(p,m,y),p=p[m]}return s}return Ox=i,Ox}var Dx,l4;function uK(){if(l4)return Dx;l4=1;var e=Mf(),t=cK(),n=If();function r(a,i,s){for(var l=-1,c=i.length,u={};++l<c;){var d=i[l],f=e(a,d);s(f,d)&&t(u,n(d,a),f)}return u}return Dx=r,Dx}var Px,c4;function dK(){if(c4)return Px;c4=1;var e=uK(),t=qI();function n(r,a){return e(r,a,function(i,s){return t(r,s)})}return Px=n,Px}var Fx,u4;function fK(){if(u4)return Fx;u4=1;var e=c3(),t=ZI(),n=JI();function r(a){return n(t(a,void 0,e),a+"")}return Fx=r,Fx}var Bx,d4;function gK(){if(d4)return Bx;d4=1;var e=dK(),t=fK(),n=t(function(r,a){return r==null?{}:e(r,a)});return Bx=n,Bx}var zx,f4;function pK(){if(f4)return zx;f4=1;var e=Math.ceil,t=Math.max;function n(r,a,i,s){for(var l=-1,c=t(e((a-r)/(i||1)),0),u=Array(c);c--;)u[s?c:++l]=r,r+=i;return u}return zx=n,zx}var Ux,g4;function hK(){if(g4)return Ux;g4=1;var e=pK(),t=Of(),n=l3();function r(a){return function(i,s,l){return l&&typeof l!="number"&&t(i,s,l)&&(s=l=void 0),i=n(i),s===void 0?(s=i,i=0):s=n(s),l=l===void 0?i<s?1:-1:n(l),e(i,s,l,a)}}return Ux=r,Ux}var $x,p4;function mK(){if(p4)return $x;p4=1;var e=hK(),t=e();return $x=t,$x}var Hx,h4;function xK(){if(h4)return Hx;h4=1;function e(t,n){var r=t.length;for(t.sort(n);r--;)t[r]=t[r].value;return t}return Hx=e,Hx}var qx,m4;function yK(){if(m4)return qx;m4=1;var e=Bo();function t(n,r){if(n!==r){var a=n!==void 0,i=n===null,s=n===n,l=e(n),c=r!==void 0,u=r===null,d=r===r,f=e(r);if(!u&&!f&&!l&&n>r||l&&c&&d&&!u&&!f||i&&c&&d||!a&&d||!s)return 1;if(!i&&!l&&!f&&n<r||f&&a&&s&&!i&&!l||u&&a&&s||!c&&s||!d)return-1}return 0}return qx=t,qx}var Wx,x4;function bK(){if(x4)return Wx;x4=1;var e=yK();function t(n,r,a){for(var i=-1,s=n.criteria,l=r.criteria,c=s.length,u=a.length;++i<c;){var d=e(s[i],l[i]);if(d){if(i>=u)return d;var f=a[i];return d*(f=="desc"?-1:1)}}return n.index-r.index}return Wx=t,Wx}var Vx,y4;function vK(){if(y4)return Vx;y4=1;var e=Rf(),t=Mf(),n=ei(),r=YI(),a=xK(),i=Cf(),s=bK(),l=As(),c=Sn();function u(d,f,g){f.length?f=e(f,function(y){return c(y)?function(v){return t(v,y.length===1?y[0]:y)}:y}):f=[l];var p=-1;f=e(f,i(n));var m=r(d,function(y,v,x){var b=e(f,function(k){return k(y)});return{criteria:b,index:++p,value:y}});return a(m,function(y,v){return s(y,v,g)})}return Vx=u,Vx}var Gx,b4;function kK(){if(b4)return Gx;b4=1;var e=H1(),t=vK(),n=Lf(),r=Of(),a=n(function(i,s){if(i==null)return[];var l=s.length;return l>1&&r(i,s[0],s[1])?s=[]:l>2&&r(s[0],s[1],s[2])&&(s=[s[0]]),t(i,e(s,1),[])});return Gx=a,Gx}var Kx,v4;function _K(){if(v4)return Kx;v4=1;var e=$I(),t=0;function n(r){var a=++t;return e(r)+a}return Kx=n,Kx}var Yx,k4;function wK(){if(k4)return Yx;k4=1;function e(t,n,r){for(var a=-1,i=t.length,s=n.length,l={};++a<i;){var c=a<s?n[a]:void 0;r(l,t[a],c)}return l}return Yx=e,Yx}var Xx,_4;function EK(){if(_4)return Xx;_4=1;var e=Sf(),t=wK();function n(r,a){return t(r||[],a||[],e)}return Xx=n,Xx}var Fd;if(typeof j1=="function")try{Fd={cloneDeep:zG(),constant:F1(),defaults:UG(),each:OI(),filter:VI(),find:KG(),flatten:c3(),forEach:LI(),forIn:YG(),has:GI(),isUndefined:KI(),last:XG(),map:XI(),mapValues:QG(),max:JG(),merge:iK(),min:sK(),minBy:oK(),now:lK(),pick:gK(),range:mK(),reduce:QI(),sortBy:kK(),uniqueId:_K(),values:n3(),zipObject:EK()}}catch{}Fd||(Fd=window._);var cn=Fd,SK=Df;function Df(){var e={};e._next=e._prev=e,this._sentinel=e}Df.prototype.dequeue=function(){var e=this._sentinel,t=e._prev;if(t!==e)return g3(t),t};Df.prototype.enqueue=function(e){var t=this._sentinel;e._prev&&e._next&&g3(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t};Df.prototype.toString=function(){for(var e=[],t=this._sentinel,n=t._prev;n!==t;)e.push(JSON.stringify(n,NK)),n=n._prev;return"["+e.join(", ")+"]"};function g3(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function NK(e,t){if(e!=="_next"&&e!=="_prev")return t}var $a=cn,CK=fa.Graph,jK=SK,TK=RK,AK=$a.constant(1);function RK(e,t){if(e.nodeCount()<=1)return[];var n=MK(e,t||AK),r=IK(n.graph,n.buckets,n.zeroIdx);return $a.flatten($a.map(r,function(a){return e.outEdges(a.v,a.w)}),!0)}function IK(e,t,n){for(var r=[],a=t[t.length-1],i=t[0],s;e.nodeCount();){for(;s=i.dequeue();)Qx(e,t,n,s);for(;s=a.dequeue();)Qx(e,t,n,s);if(e.nodeCount()){for(var l=t.length-2;l>0;--l)if(s=t[l].dequeue(),s){r=r.concat(Qx(e,t,n,s,!0));break}}}return r}function Qx(e,t,n,r,a){var i=a?[]:void 0;return $a.forEach(e.inEdges(r.v),function(s){var l=e.edge(s),c=e.node(s.v);a&&i.push({v:s.v,w:s.w}),c.out-=l,Fb(t,n,c)}),$a.forEach(e.outEdges(r.v),function(s){var l=e.edge(s),c=s.w,u=e.node(c);u.in-=l,Fb(t,n,u)}),e.removeNode(r.v),i}function MK(e,t){var n=new CK,r=0,a=0;$a.forEach(e.nodes(),function(l){n.setNode(l,{v:l,in:0,out:0})}),$a.forEach(e.edges(),function(l){var c=n.edge(l.v,l.w)||0,u=t(l),d=c+u;n.setEdge(l.v,l.w,d),a=Math.max(a,n.node(l.v).out+=u),r=Math.max(r,n.node(l.w).in+=u)});var i=$a.range(a+r+3).map(function(){return new jK}),s=r+1;return $a.forEach(n.nodes(),function(l){Fb(i,s,n.node(l))}),{graph:n,buckets:i,zeroIdx:s}}function Fb(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}var os=cn,LK=TK,OK={run:DK,undo:FK};function DK(e){var t=e.graph().acyclicer==="greedy"?LK(e,n(e)):PK(e);os.forEach(t,function(r){var a=e.edge(r);e.removeEdge(r),a.forwardName=r.name,a.reversed=!0,e.setEdge(r.w,r.v,a,os.uniqueId("rev"))});function n(r){return function(a){return r.edge(a).weight}}}function PK(e){var t=[],n={},r={};function a(i){os.has(r,i)||(r[i]=!0,n[i]=!0,os.forEach(e.outEdges(i),function(s){os.has(n,s.w)?t.push(s):a(s.w)}),delete n[i])}return os.forEach(e.nodes(),a),t}function FK(e){os.forEach(e.edges(),function(t){var n=e.edge(t);if(n.reversed){e.removeEdge(t);var r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}var Ut=cn,p3=fa.Graph,pr={addDummyNode:h3,simplify:BK,asNonCompoundGraph:zK,successorWeights:UK,predecessorWeights:$K,intersectRect:HK,buildLayerMatrix:qK,normalizeRanks:WK,removeEmptyRanks:VK,addBorderNode:GK,maxRank:m3,partition:KK,time:YK,notime:XK};function h3(e,t,n,r){var a;do a=Ut.uniqueId(r);while(e.hasNode(a));return n.dummy=t,e.setNode(a,n),a}function BK(e){var t=new p3().setGraph(e.graph());return Ut.forEach(e.nodes(),function(n){t.setNode(n,e.node(n))}),Ut.forEach(e.edges(),function(n){var r=t.edge(n.v,n.w)||{weight:0,minlen:1},a=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+a.weight,minlen:Math.max(r.minlen,a.minlen)})}),t}function zK(e){var t=new p3({multigraph:e.isMultigraph()}).setGraph(e.graph());return Ut.forEach(e.nodes(),function(n){e.children(n).length||t.setNode(n,e.node(n))}),Ut.forEach(e.edges(),function(n){t.setEdge(n,e.edge(n))}),t}function UK(e){var t=Ut.map(e.nodes(),function(n){var r={};return Ut.forEach(e.outEdges(n),function(a){r[a.w]=(r[a.w]||0)+e.edge(a).weight}),r});return Ut.zipObject(e.nodes(),t)}function $K(e){var t=Ut.map(e.nodes(),function(n){var r={};return Ut.forEach(e.inEdges(n),function(a){r[a.v]=(r[a.v]||0)+e.edge(a).weight}),r});return Ut.zipObject(e.nodes(),t)}function HK(e,t){var n=e.x,r=e.y,a=t.x-n,i=t.y-r,s=e.width/2,l=e.height/2;if(!a&&!i)throw new Error("Not possible to find intersection inside of the rectangle");var c,u;return Math.abs(i)*s>Math.abs(a)*l?(i<0&&(l=-l),c=l*a/i,u=l):(a<0&&(s=-s),c=s,u=s*i/a),{x:n+c,y:r+u}}function qK(e){var t=Ut.map(Ut.range(m3(e)+1),function(){return[]});return Ut.forEach(e.nodes(),function(n){var r=e.node(n),a=r.rank;Ut.isUndefined(a)||(t[a][r.order]=n)}),t}function WK(e){var t=Ut.min(Ut.map(e.nodes(),function(n){return e.node(n).rank}));Ut.forEach(e.nodes(),function(n){var r=e.node(n);Ut.has(r,"rank")&&(r.rank-=t)})}function VK(e){var t=Ut.min(Ut.map(e.nodes(),function(i){return e.node(i).rank})),n=[];Ut.forEach(e.nodes(),function(i){var s=e.node(i).rank-t;n[s]||(n[s]=[]),n[s].push(i)});var r=0,a=e.graph().nodeRankFactor;Ut.forEach(n,function(i,s){Ut.isUndefined(i)&&s%a!==0?--r:r&&Ut.forEach(i,function(l){e.node(l).rank+=r})})}function GK(e,t,n,r){var a={width:0,height:0};return arguments.length>=4&&(a.rank=n,a.order=r),h3(e,"border",a,t)}function m3(e){return Ut.max(Ut.map(e.nodes(),function(t){var n=e.node(t).rank;if(!Ut.isUndefined(n))return n}))}function KK(e,t){var n={lhs:[],rhs:[]};return Ut.forEach(e,function(r){t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function YK(e,t){var n=Ut.now();try{return t()}finally{console.log(e+" time: "+(Ut.now()-n)+"ms")}}function XK(e,t){return t()}var x3=cn,QK=pr,ZK={run:JK,undo:tY};function JK(e){e.graph().dummyChains=[],x3.forEach(e.edges(),function(t){eY(e,t)})}function eY(e,t){var n=t.v,r=e.node(n).rank,a=t.w,i=e.node(a).rank,s=t.name,l=e.edge(t),c=l.labelRank;if(i!==r+1){e.removeEdge(t);var u,d,f;for(f=0,++r;r<i;++f,++r)l.points=[],d={width:0,height:0,edgeLabel:l,edgeObj:t,rank:r},u=QK.addDummyNode(e,"edge",d,"_d"),r===c&&(d.width=l.width,d.height=l.height,d.dummy="edge-label",d.labelpos=l.labelpos),e.setEdge(n,u,{weight:l.weight},s),f===0&&e.graph().dummyChains.push(u),n=u;e.setEdge(n,a,{weight:l.weight},s)}}function tY(e){x3.forEach(e.graph().dummyChains,function(t){var n=e.node(t),r=n.edgeLabel,a;for(e.setEdge(n.edgeObj,r);n.dummy;)a=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=a,n=e.node(t)})}var ju=cn,Pf={longestPath:nY,slack:rY};function nY(e){var t={};function n(r){var a=e.node(r);if(ju.has(t,r))return a.rank;t[r]=!0;var i=ju.min(ju.map(e.outEdges(r),function(s){return n(s.w)-e.edge(s).minlen}));return(i===Number.POSITIVE_INFINITY||i===void 0||i===null)&&(i=0),a.rank=i}ju.forEach(e.sources(),n)}function rY(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Bd=cn,aY=fa.Graph,zd=Pf.slack,y3=iY;function iY(e){var t=new aY({directed:!1}),n=e.nodes()[0],r=e.nodeCount();t.setNode(n,{});for(var a,i;sY(t,e)<r;)a=oY(t,e),i=t.hasNode(a.v)?zd(e,a):-zd(e,a),lY(t,e,i);return t}function sY(e,t){function n(r){Bd.forEach(t.nodeEdges(r),function(a){var i=a.v,s=r===i?a.w:i;!e.hasNode(s)&&!zd(t,a)&&(e.setNode(s,{}),e.setEdge(r,s,{}),n(s))})}return Bd.forEach(e.nodes(),n),e.nodeCount()}function oY(e,t){return Bd.minBy(t.edges(),function(n){if(e.hasNode(n.v)!==e.hasNode(n.w))return zd(t,n)})}function lY(e,t,n){Bd.forEach(e.nodes(),function(r){t.node(r).rank+=n})}var Xa=cn,cY=y3,uY=Pf.slack,dY=Pf.longestPath,fY=fa.alg.preorder,gY=fa.alg.postorder,pY=pr.simplify,hY=Rs;Rs.initLowLimValues=G1;Rs.initCutValues=V1;Rs.calcCutValue=b3;Rs.leaveEdge=k3;Rs.enterEdge=_3;Rs.exchangeEdges=w3;function Rs(e){e=pY(e),dY(e);var t=cY(e);G1(t),V1(t,e);for(var n,r;n=k3(t);)r=_3(t,e,n),w3(t,e,n,r)}function V1(e,t){var n=gY(e,e.nodes());n=n.slice(0,n.length-1),Xa.forEach(n,function(r){mY(e,t,r)})}function mY(e,t,n){var r=e.node(n),a=r.parent;e.edge(n,a).cutvalue=b3(e,t,n)}function b3(e,t,n){var r=e.node(n),a=r.parent,i=!0,s=t.edge(n,a),l=0;return s||(i=!1,s=t.edge(a,n)),l=s.weight,Xa.forEach(t.nodeEdges(n),function(c){var u=c.v===n,d=u?c.w:c.v;if(d!==a){var f=u===i,g=t.edge(c).weight;if(l+=f?g:-g,yY(e,n,d)){var p=e.edge(n,d).cutvalue;l+=f?-p:p}}}),l}function G1(e,t){arguments.length<2&&(t=e.nodes()[0]),v3(e,{},1,t)}function v3(e,t,n,r,a){var i=n,s=e.node(r);return t[r]=!0,Xa.forEach(e.neighbors(r),function(l){Xa.has(t,l)||(n=v3(e,t,n,l,r))}),s.low=i,s.lim=n++,a?s.parent=a:delete s.parent,n}function k3(e){return Xa.find(e.edges(),function(t){return e.edge(t).cutvalue<0})}function _3(e,t,n){var r=n.v,a=n.w;t.hasEdge(r,a)||(r=n.w,a=n.v);var i=e.node(r),s=e.node(a),l=i,c=!1;i.lim>s.lim&&(l=s,c=!0);var u=Xa.filter(t.edges(),function(d){return c===w4(e,e.node(d.v),l)&&c!==w4(e,e.node(d.w),l)});return Xa.minBy(u,function(d){return uY(t,d)})}function w3(e,t,n,r){var a=n.v,i=n.w;e.removeEdge(a,i),e.setEdge(r.v,r.w,{}),G1(e),V1(e,t),xY(e,t)}function xY(e,t){var n=Xa.find(e.nodes(),function(a){return!t.node(a).parent}),r=fY(e,n);r=r.slice(1),Xa.forEach(r,function(a){var i=e.node(a).parent,s=t.edge(a,i),l=!1;s||(s=t.edge(i,a),l=!0),t.node(a).rank=t.node(i).rank+(l?s.minlen:-s.minlen)})}function yY(e,t,n){return e.hasEdge(t,n)}function w4(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var bY=Pf,E3=bY.longestPath,vY=y3,kY=hY,_Y=wY;function wY(e){switch(e.graph().ranker){case"network-simplex":E4(e);break;case"tight-tree":SY(e);break;case"longest-path":EY(e);break;default:E4(e)}}var EY=E3;function SY(e){E3(e),vY(e)}function E4(e){kY(e)}var Bb=cn,NY=CY;function CY(e){var t=TY(e);Bb.forEach(e.graph().dummyChains,function(n){for(var r=e.node(n),a=r.edgeObj,i=jY(e,t,a.v,a.w),s=i.path,l=i.lca,c=0,u=s[c],d=!0;n!==a.w;){if(r=e.node(n),d){for(;(u=s[c])!==l&&e.node(u).maxRank<r.rank;)c++;u===l&&(d=!1)}if(!d){for(;c<s.length-1&&e.node(u=s[c+1]).minRank<=r.rank;)c++;u=s[c]}e.setParent(n,u),n=e.successors(n)[0]}})}function jY(e,t,n,r){var a=[],i=[],s=Math.min(t[n].low,t[r].low),l=Math.max(t[n].lim,t[r].lim),c,u;c=n;do c=e.parent(c),a.push(c);while(c&&(t[c].low>s||l>t[c].lim));for(u=c,c=r;(c=e.parent(c))!==u;)i.push(c);return{path:a.concat(i.reverse()),lca:u}}function TY(e){var t={},n=0;function r(a){var i=n;Bb.forEach(e.children(a),r),t[a]={low:i,lim:n++}}return Bb.forEach(e.children(),r),t}var Ha=cn,zb=pr,AY={run:RY,cleanup:LY};function RY(e){var t=zb.addDummyNode(e,"root",{},"_root"),n=IY(e),r=Ha.max(Ha.values(n))-1,a=2*r+1;e.graph().nestingRoot=t,Ha.forEach(e.edges(),function(s){e.edge(s).minlen*=a});var i=MY(e)+1;Ha.forEach(e.children(),function(s){S3(e,t,a,i,r,n,s)}),e.graph().nodeRankFactor=a}function S3(e,t,n,r,a,i,s){var l=e.children(s);if(!l.length){s!==t&&e.setEdge(t,s,{weight:0,minlen:n});return}var c=zb.addBorderNode(e,"_bt"),u=zb.addBorderNode(e,"_bb"),d=e.node(s);e.setParent(c,s),d.borderTop=c,e.setParent(u,s),d.borderBottom=u,Ha.forEach(l,function(f){S3(e,t,n,r,a,i,f);var g=e.node(f),p=g.borderTop?g.borderTop:f,m=g.borderBottom?g.borderBottom:f,y=g.borderTop?r:2*r,v=p!==m?1:a-i[s]+1;e.setEdge(c,p,{weight:y,minlen:v,nestingEdge:!0}),e.setEdge(m,u,{weight:y,minlen:v,nestingEdge:!0})}),e.parent(s)||e.setEdge(t,c,{weight:0,minlen:a+i[s]})}function IY(e){var t={};function n(r,a){var i=e.children(r);i&&i.length&&Ha.forEach(i,function(s){n(s,a+1)}),t[r]=a}return Ha.forEach(e.children(),function(r){n(r,1)}),t}function MY(e){return Ha.reduce(e.edges(),function(t,n){return t+e.edge(n).weight},0)}function LY(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,Ha.forEach(e.edges(),function(n){var r=e.edge(n);r.nestingEdge&&e.removeEdge(n)})}var Zx=cn,OY=pr,DY=PY;function PY(e){function t(n){var r=e.children(n),a=e.node(n);if(r.length&&Zx.forEach(r,t),Zx.has(a,"minRank")){a.borderLeft=[],a.borderRight=[];for(var i=a.minRank,s=a.maxRank+1;i<s;++i)S4(e,"borderLeft","_bl",n,a,i),S4(e,"borderRight","_br",n,a,i)}}Zx.forEach(e.children(),t)}function S4(e,t,n,r,a,i){var s={width:0,height:0,rank:i,borderType:t},l=a[t][i-1],c=OY.addDummyNode(e,"border",s,n);a[t][i]=c,e.setParent(c,r),l&&e.setEdge(l,c,{weight:1})}var _a=cn,FY={adjust:BY,undo:zY};function BY(e){var t=e.graph().rankdir.toLowerCase();(t==="lr"||t==="rl")&&N3(e)}function zY(e){var t=e.graph().rankdir.toLowerCase();(t==="bt"||t==="rl")&&UY(e),(t==="lr"||t==="rl")&&($Y(e),N3(e))}function N3(e){_a.forEach(e.nodes(),function(t){N4(e.node(t))}),_a.forEach(e.edges(),function(t){N4(e.edge(t))})}function N4(e){var t=e.width;e.width=e.height,e.height=t}function UY(e){_a.forEach(e.nodes(),function(t){Jx(e.node(t))}),_a.forEach(e.edges(),function(t){var n=e.edge(t);_a.forEach(n.points,Jx),_a.has(n,"y")&&Jx(n)})}function Jx(e){e.y=-e.y}function $Y(e){_a.forEach(e.nodes(),function(t){ey(e.node(t))}),_a.forEach(e.edges(),function(t){var n=e.edge(t);_a.forEach(n.points,ey),_a.has(n,"x")&&ey(n)})}function ey(e){var t=e.x;e.x=e.y,e.y=t}var Da=cn,HY=qY;function qY(e){var t={},n=Da.filter(e.nodes(),function(l){return!e.children(l).length}),r=Da.max(Da.map(n,function(l){return e.node(l).rank})),a=Da.map(Da.range(r+1),function(){return[]});function i(l){if(!Da.has(t,l)){t[l]=!0;var c=e.node(l);a[c.rank].push(l),Da.forEach(e.successors(l),i)}}var s=Da.sortBy(n,function(l){return e.node(l).rank});return Da.forEach(s,i),a}var si=cn,WY=VY;function VY(e,t){for(var n=0,r=1;r<t.length;++r)n+=GY(e,t[r-1],t[r]);return n}function GY(e,t,n){for(var r=si.zipObject(n,si.map(n,function(u,d){return d})),a=si.flatten(si.map(t,function(u){return si.sortBy(si.map(e.outEdges(u),function(d){return{pos:r[d.w],weight:e.edge(d).weight}}),"pos")}),!0),i=1;i<n.length;)i<<=1;var s=2*i-1;i-=1;var l=si.map(new Array(s),function(){return 0}),c=0;return si.forEach(a.forEach(function(u){var d=u.pos+i;l[d]+=u.weight;for(var f=0;d>0;)d%2&&(f+=l[d+1]),d=d-1>>1,l[d]+=u.weight;c+=u.weight*f})),c}var C4=cn,KY=YY;function YY(e,t){return C4.map(t,function(n){var r=e.inEdges(n);if(r.length){var a=C4.reduce(r,function(i,s){var l=e.edge(s),c=e.node(s.v);return{sum:i.sum+l.weight*c.order,weight:i.weight+l.weight}},{sum:0,weight:0});return{v:n,barycenter:a.sum/a.weight,weight:a.weight}}else return{v:n}})}var _r=cn,XY=QY;function QY(e,t){var n={};_r.forEach(e,function(a,i){var s=n[a.v]={indegree:0,in:[],out:[],vs:[a.v],i};_r.isUndefined(a.barycenter)||(s.barycenter=a.barycenter,s.weight=a.weight)}),_r.forEach(t.edges(),function(a){var i=n[a.v],s=n[a.w];!_r.isUndefined(i)&&!_r.isUndefined(s)&&(s.indegree++,i.out.push(n[a.w]))});var r=_r.filter(n,function(a){return!a.indegree});return ZY(r)}function ZY(e){var t=[];function n(i){return function(s){s.merged||(_r.isUndefined(s.barycenter)||_r.isUndefined(i.barycenter)||s.barycenter>=i.barycenter)&&JY(i,s)}}function r(i){return function(s){s.in.push(i),--s.indegree===0&&e.push(s)}}for(;e.length;){var a=e.pop();t.push(a),_r.forEach(a.in.reverse(),n(a)),_r.forEach(a.out,r(a))}return _r.map(_r.filter(t,function(i){return!i.merged}),function(i){return _r.pick(i,["vs","i","barycenter","weight"])})}function JY(e,t){var n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}var xl=cn,eX=pr,tX=nX;function nX(e,t){var n=eX.partition(e,function(d){return xl.has(d,"barycenter")}),r=n.lhs,a=xl.sortBy(n.rhs,function(d){return-d.i}),i=[],s=0,l=0,c=0;r.sort(rX(!!t)),c=j4(i,a,c),xl.forEach(r,function(d){c+=d.vs.length,i.push(d.vs),s+=d.barycenter*d.weight,l+=d.weight,c=j4(i,a,c)});var u={vs:xl.flatten(i,!0)};return l&&(u.barycenter=s/l,u.weight=l),u}function j4(e,t,n){for(var r;t.length&&(r=xl.last(t)).i<=n;)t.pop(),e.push(r.vs),n++;return n}function rX(e){return function(t,n){return t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}}var gi=cn,aX=KY,iX=XY,sX=tX,oX=C3;function C3(e,t,n,r){var a=e.children(t),i=e.node(t),s=i?i.borderLeft:void 0,l=i?i.borderRight:void 0,c={};s&&(a=gi.filter(a,function(m){return m!==s&&m!==l}));var u=aX(e,a);gi.forEach(u,function(m){if(e.children(m.v).length){var y=C3(e,m.v,n,r);c[m.v]=y,gi.has(y,"barycenter")&&cX(m,y)}});var d=iX(u,n);lX(d,c);var f=sX(d,r);if(s&&(f.vs=gi.flatten([s,f.vs,l],!0),e.predecessors(s).length)){var g=e.node(e.predecessors(s)[0]),p=e.node(e.predecessors(l)[0]);gi.has(f,"barycenter")||(f.barycenter=0,f.weight=0),f.barycenter=(f.barycenter*f.weight+g.order+p.order)/(f.weight+2),f.weight+=2}return f}function lX(e,t){gi.forEach(e,function(n){n.vs=gi.flatten(n.vs.map(function(r){return t[r]?t[r].vs:r}),!0)})}function cX(e,t){gi.isUndefined(e.barycenter)?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}var yl=cn,uX=fa.Graph,dX=fX;function fX(e,t,n){var r=gX(e),a=new uX({compound:!0}).setGraph({root:r}).setDefaultNodeLabel(function(i){return e.node(i)});return yl.forEach(e.nodes(),function(i){var s=e.node(i),l=e.parent(i);(s.rank===t||s.minRank<=t&&t<=s.maxRank)&&(a.setNode(i),a.setParent(i,l||r),yl.forEach(e[n](i),function(c){var u=c.v===i?c.w:c.v,d=a.edge(u,i),f=yl.isUndefined(d)?0:d.weight;a.setEdge(u,i,{weight:e.edge(c).weight+f})}),yl.has(s,"minRank")&&a.setNode(i,{borderLeft:s.borderLeft[t],borderRight:s.borderRight[t]}))}),a}function gX(e){for(var t;e.hasNode(t=yl.uniqueId("_root")););return t}var pX=cn,hX=mX;function mX(e,t,n){var r={},a;pX.forEach(n,function(i){for(var s=e.parent(i),l,c;s;){if(l=e.parent(s),l?(c=r[l],r[l]=s):(c=a,a=s),c&&c!==s){t.setEdge(c,s);return}s=l}})}var Ci=cn,xX=HY,yX=WY,bX=oX,vX=dX,kX=hX,_X=fa.Graph,T4=pr,wX=EX;function EX(e){var t=T4.maxRank(e),n=A4(e,Ci.range(1,t+1),"inEdges"),r=A4(e,Ci.range(t-1,-1,-1),"outEdges"),a=xX(e);R4(e,a);for(var i=Number.POSITIVE_INFINITY,s,l=0,c=0;c<4;++l,++c){SX(l%2?n:r,l%4>=2),a=T4.buildLayerMatrix(e);var u=yX(e,a);u<i&&(c=0,s=Ci.cloneDeep(a),i=u)}R4(e,s)}function A4(e,t,n){return Ci.map(t,function(r){return vX(e,r,n)})}function SX(e,t){var n=new _X;Ci.forEach(e,function(r){var a=r.graph().root,i=bX(r,a,n,t);Ci.forEach(i.vs,function(s,l){r.node(s).order=l}),kX(r,n,i.vs)})}function R4(e,t){Ci.forEach(t,function(n){Ci.forEach(n,function(r,a){e.node(r).order=a})})}var kt=cn,NX=fa.Graph,CX=pr,jX={positionX:BX};function TX(e,t){var n={};function r(a,i){var s=0,l=0,c=a.length,u=kt.last(i);return kt.forEach(i,function(d,f){var g=RX(e,d),p=g?e.node(g).order:c;(g||d===u)&&(kt.forEach(i.slice(l,f+1),function(m){kt.forEach(e.predecessors(m),function(y){var v=e.node(y),x=v.order;(x<s||p<x)&&!(v.dummy&&e.node(m).dummy)&&j3(n,y,m)})}),l=f+1,s=p)}),i}return kt.reduce(t,r),n}function AX(e,t){var n={};function r(i,s,l,c,u){var d;kt.forEach(kt.range(s,l),function(f){d=i[f],e.node(d).dummy&&kt.forEach(e.predecessors(d),function(g){var p=e.node(g);p.dummy&&(p.order<c||p.order>u)&&j3(n,g,d)})})}function a(i,s){var l=-1,c,u=0;return kt.forEach(s,function(d,f){if(e.node(d).dummy==="border"){var g=e.predecessors(d);g.length&&(c=e.node(g[0]).order,r(s,u,f,l,c),u=f,l=c)}r(s,u,s.length,c,i.length)}),s}return kt.reduce(t,a),n}function RX(e,t){if(e.node(t).dummy)return kt.find(e.predecessors(t),function(n){return e.node(n).dummy})}function j3(e,t,n){if(t>n){var r=t;t=n,n=r}var a=e[t];a||(e[t]=a={}),a[n]=!0}function IX(e,t,n){if(t>n){var r=t;t=n,n=r}return kt.has(e[t],n)}function MX(e,t,n,r){var a={},i={},s={};return kt.forEach(t,function(l){kt.forEach(l,function(c,u){a[c]=c,i[c]=c,s[c]=u})}),kt.forEach(t,function(l){var c=-1;kt.forEach(l,function(u){var d=r(u);if(d.length){d=kt.sortBy(d,function(y){return s[y]});for(var f=(d.length-1)/2,g=Math.floor(f),p=Math.ceil(f);g<=p;++g){var m=d[g];i[u]===u&&c<s[m]&&!IX(n,u,m)&&(i[m]=u,i[u]=a[u]=a[m],c=s[m])}}})}),{root:a,align:i}}function LX(e,t,n,r,a){var i={},s=OX(e,t,n,a),l=a?"borderLeft":"borderRight";function c(f,g){for(var p=s.nodes(),m=p.pop(),y={};m;)y[m]?f(m):(y[m]=!0,p.push(m),p=p.concat(g(m))),m=p.pop()}function u(f){i[f]=s.inEdges(f).reduce(function(g,p){return Math.max(g,i[p.v]+s.edge(p))},0)}function d(f){var g=s.outEdges(f).reduce(function(m,y){return Math.min(m,i[y.w]-s.edge(y))},Number.POSITIVE_INFINITY),p=e.node(f);g!==Number.POSITIVE_INFINITY&&p.borderType!==l&&(i[f]=Math.max(i[f],g))}return c(u,s.predecessors.bind(s)),c(d,s.successors.bind(s)),kt.forEach(r,function(f){i[f]=i[n[f]]}),i}function OX(e,t,n,r){var a=new NX,i=e.graph(),s=zX(i.nodesep,i.edgesep,r);return kt.forEach(t,function(l){var c;kt.forEach(l,function(u){var d=n[u];if(a.setNode(d),c){var f=n[c],g=a.edge(f,d);a.setEdge(f,d,Math.max(s(e,u,c),g||0))}c=u})}),a}function DX(e,t){return kt.minBy(kt.values(t),function(n){var r=Number.NEGATIVE_INFINITY,a=Number.POSITIVE_INFINITY;return kt.forIn(n,function(i,s){var l=UX(e,s)/2;r=Math.max(i+l,r),a=Math.min(i-l,a)}),r-a})}function PX(e,t){var n=kt.values(t),r=kt.min(n),a=kt.max(n);kt.forEach(["u","d"],function(i){kt.forEach(["l","r"],function(s){var l=i+s,c=e[l],u;if(c!==t){var d=kt.values(c);u=s==="l"?r-kt.min(d):a-kt.max(d),u&&(e[l]=kt.mapValues(c,function(f){return f+u}))}})})}function FX(e,t){return kt.mapValues(e.ul,function(n,r){if(t)return e[t.toLowerCase()][r];var a=kt.sortBy(kt.map(e,r));return(a[1]+a[2])/2})}function BX(e){var t=CX.buildLayerMatrix(e),n=kt.merge(TX(e,t),AX(e,t)),r={},a;kt.forEach(["u","d"],function(s){a=s==="u"?t:kt.values(t).reverse(),kt.forEach(["l","r"],function(l){l==="r"&&(a=kt.map(a,function(f){return kt.values(f).reverse()}));var c=(s==="u"?e.predecessors:e.successors).bind(e),u=MX(e,a,n,c),d=LX(e,a,u.root,u.align,l==="r");l==="r"&&(d=kt.mapValues(d,function(f){return-f})),r[s+l]=d})});var i=DX(e,r);return PX(r,i),FX(r,e.graph().align)}function zX(e,t,n){return function(r,a,i){var s=r.node(a),l=r.node(i),c=0,u;if(c+=s.width/2,kt.has(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":u=-s.width/2;break;case"r":u=s.width/2;break}if(u&&(c+=n?u:-u),u=0,c+=(s.dummy?t:e)/2,c+=(l.dummy?t:e)/2,c+=l.width/2,kt.has(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":u=l.width/2;break;case"r":u=-l.width/2;break}return u&&(c+=n?u:-u),u=0,c}}function UX(e,t){return e.node(t).width}var bl=cn,T3=pr,$X=jX.positionX,HX=qX;function qX(e){e=T3.asNonCompoundGraph(e),WX(e),bl.forEach($X(e),function(t,n){e.node(n).x=t})}function WX(e){var t=T3.buildLayerMatrix(e),n=e.graph().ranksep,r=0;bl.forEach(t,function(a){var i=bl.max(bl.map(a,function(s){return e.node(s).height}));bl.forEach(a,function(s){e.node(s).y=r+i/2}),r+=i+n})}var Ct=cn,I4=OK,M4=ZK,VX=_Y,GX=pr.normalizeRanks,KX=NY,YX=pr.removeEmptyRanks,L4=AY,XX=DY,O4=FY,QX=wX,ZX=HX,Ri=pr,JX=fa.Graph,eQ=tQ;function tQ(e,t){var n=t&&t.debugTiming?Ri.time:Ri.notime;n("layout",function(){var r=n(" buildLayoutGraph",function(){return fQ(e)});n(" runLayout",function(){nQ(r,n)}),n(" updateInputGraph",function(){rQ(e,r)})})}function nQ(e,t){t(" makeSpaceForEdgeLabels",function(){gQ(e)}),t(" removeSelfEdges",function(){_Q(e)}),t(" acyclic",function(){I4.run(e)}),t(" nestingGraph.run",function(){L4.run(e)}),t(" rank",function(){VX(Ri.asNonCompoundGraph(e))}),t(" injectEdgeLabelProxies",function(){pQ(e)}),t(" removeEmptyRanks",function(){YX(e)}),t(" nestingGraph.cleanup",function(){L4.cleanup(e)}),t(" normalizeRanks",function(){GX(e)}),t(" assignRankMinMax",function(){hQ(e)}),t(" removeEdgeLabelProxies",function(){mQ(e)}),t(" normalize.run",function(){M4.run(e)}),t(" parentDummyChains",function(){KX(e)}),t(" addBorderSegments",function(){XX(e)}),t(" order",function(){QX(e)}),t(" insertSelfEdges",function(){wQ(e)}),t(" adjustCoordinateSystem",function(){O4.adjust(e)}),t(" position",function(){ZX(e)}),t(" positionSelfEdges",function(){EQ(e)}),t(" removeBorderNodes",function(){kQ(e)}),t(" normalize.undo",function(){M4.undo(e)}),t(" fixupEdgeLabelCoords",function(){bQ(e)}),t(" undoCoordinateSystem",function(){O4.undo(e)}),t(" translateGraph",function(){xQ(e)}),t(" assignNodeIntersects",function(){yQ(e)}),t(" reversePoints",function(){vQ(e)}),t(" acyclic.undo",function(){I4.undo(e)})}function rQ(e,t){Ct.forEach(e.nodes(),function(n){var r=e.node(n),a=t.node(n);r&&(r.x=a.x,r.y=a.y,t.children(n).length&&(r.width=a.width,r.height=a.height))}),Ct.forEach(e.edges(),function(n){var r=e.edge(n),a=t.edge(n);r.points=a.points,Ct.has(a,"x")&&(r.x=a.x,r.y=a.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var aQ=["nodesep","edgesep","ranksep","marginx","marginy"],iQ={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},sQ=["acyclicer","ranker","rankdir","align"],oQ=["width","height"],lQ={width:0,height:0},cQ=["minlen","weight","width","height","labeloffset"],uQ={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},dQ=["labelpos"];function fQ(e){var t=new JX({multigraph:!0,compound:!0}),n=ny(e.graph());return t.setGraph(Ct.merge({},iQ,ty(n,aQ),Ct.pick(n,sQ))),Ct.forEach(e.nodes(),function(r){var a=ny(e.node(r));t.setNode(r,Ct.defaults(ty(a,oQ),lQ)),t.setParent(r,e.parent(r))}),Ct.forEach(e.edges(),function(r){var a=ny(e.edge(r));t.setEdge(r,Ct.merge({},uQ,ty(a,cQ),Ct.pick(a,dQ)))}),t}function gQ(e){var t=e.graph();t.ranksep/=2,Ct.forEach(e.edges(),function(n){var r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function pQ(e){Ct.forEach(e.edges(),function(t){var n=e.edge(t);if(n.width&&n.height){var r=e.node(t.v),a=e.node(t.w),i={rank:(a.rank-r.rank)/2+r.rank,e:t};Ri.addDummyNode(e,"edge-proxy",i,"_ep")}})}function hQ(e){var t=0;Ct.forEach(e.nodes(),function(n){var r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Ct.max(t,r.maxRank))}),e.graph().maxRank=t}function mQ(e){Ct.forEach(e.nodes(),function(t){var n=e.node(t);n.dummy==="edge-proxy"&&(e.edge(n.e).labelRank=n.rank,e.removeNode(t))})}function xQ(e){var t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,a=0,i=e.graph(),s=i.marginx||0,l=i.marginy||0;function c(u){var d=u.x,f=u.y,g=u.width,p=u.height;t=Math.min(t,d-g/2),n=Math.max(n,d+g/2),r=Math.min(r,f-p/2),a=Math.max(a,f+p/2)}Ct.forEach(e.nodes(),function(u){c(e.node(u))}),Ct.forEach(e.edges(),function(u){var d=e.edge(u);Ct.has(d,"x")&&c(d)}),t-=s,r-=l,Ct.forEach(e.nodes(),function(u){var d=e.node(u);d.x-=t,d.y-=r}),Ct.forEach(e.edges(),function(u){var d=e.edge(u);Ct.forEach(d.points,function(f){f.x-=t,f.y-=r}),Ct.has(d,"x")&&(d.x-=t),Ct.has(d,"y")&&(d.y-=r)}),i.width=n-t+s,i.height=a-r+l}function yQ(e){Ct.forEach(e.edges(),function(t){var n=e.edge(t),r=e.node(t.v),a=e.node(t.w),i,s;n.points?(i=n.points[0],s=n.points[n.points.length-1]):(n.points=[],i=a,s=r),n.points.unshift(Ri.intersectRect(r,i)),n.points.push(Ri.intersectRect(a,s))})}function bQ(e){Ct.forEach(e.edges(),function(t){var n=e.edge(t);if(Ct.has(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function vQ(e){Ct.forEach(e.edges(),function(t){var n=e.edge(t);n.reversed&&n.points.reverse()})}function kQ(e){Ct.forEach(e.nodes(),function(t){if(e.children(t).length){var n=e.node(t),r=e.node(n.borderTop),a=e.node(n.borderBottom),i=e.node(Ct.last(n.borderLeft)),s=e.node(Ct.last(n.borderRight));n.width=Math.abs(s.x-i.x),n.height=Math.abs(a.y-r.y),n.x=i.x+n.width/2,n.y=r.y+n.height/2}}),Ct.forEach(e.nodes(),function(t){e.node(t).dummy==="border"&&e.removeNode(t)})}function _Q(e){Ct.forEach(e.edges(),function(t){if(t.v===t.w){var n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function wQ(e){var t=Ri.buildLayerMatrix(e);Ct.forEach(t,function(n){var r=0;Ct.forEach(n,function(a,i){var s=e.node(a);s.order=i+r,Ct.forEach(s.selfEdges,function(l){Ri.addDummyNode(e,"selfedge",{width:l.label.width,height:l.label.height,rank:s.rank,order:i+ ++r,e:l.e,label:l.label},"_se")}),delete s.selfEdges})})}function EQ(e){Ct.forEach(e.nodes(),function(t){var n=e.node(t);if(n.dummy==="selfedge"){var r=e.node(n.e.v),a=r.x+r.width/2,i=r.y,s=n.x-a,l=r.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:a+2*s/3,y:i-l},{x:a+5*s/6,y:i-l},{x:a+s,y:i},{x:a+5*s/6,y:i+l},{x:a+2*s/3,y:i+l}],n.label.x=n.x,n.label.y=n.y}})}function ty(e,t){return Ct.mapValues(Ct.pick(e,t),Number)}function ny(e){var t={};return Ct.forEach(e,function(n,r){t[r.toLowerCase()]=n}),t}var Tu=cn,SQ=pr,NQ=fa.Graph,CQ={debugOrdering:jQ};function jQ(e){var t=SQ.buildLayerMatrix(e),n=new NQ({compound:!0,multigraph:!0}).setGraph({});return Tu.forEach(e.nodes(),function(r){n.setNode(r,{label:r}),n.setParent(r,"layer"+e.node(r).rank)}),Tu.forEach(e.edges(),function(r){n.setEdge(r.v,r.w,{},r.name)}),Tu.forEach(t,function(r,a){var i="layer"+a;n.setNode(i,{rank:"same"}),Tu.reduce(r,function(s,l){return n.setEdge(s,l,{style:"invis"}),l})}),n}var TQ="0.8.5",AQ={graphlib:fa,layout:eQ,debug:CQ,util:{time:pr.time,notime:pr.notime},version:TQ};const Ud=Co(AQ),RQ={completed:{fill:"#dcfce7",stroke:"#16a34a",label:"#15803d"},in_progress:{fill:"#dbeafe",stroke:"#3b82f6",label:"#1d4ed8"},blocked:{fill:"#fef3c7",stroke:"#f59e0b",label:"#b45309"},open:{fill:"#f1f5f9",stroke:"#94a3b8",label:"#475569"}},IQ={completed:{fill:"#14532d",stroke:"#22c55e",label:"#86efac"},in_progress:{fill:"#1e3a8a",stroke:"#60a5fa",label:"#bfdbfe"},blocked:{fill:"#78350f",stroke:"#fbbf24",label:"#fde68a"},open:{fill:"#1e293b",stroke:"#64748b",label:"#cbd5e1"}};function MQ(e,t){return e?e.length<=t?e:e.slice(0,t-1)+"…":""}function D4(e){return e.status==="completed"?"completed":e.status==="in_progress"?"in_progress":e.blockedBy&&e.blockedBy.length>0&&e.isBlocked?"blocked":"open"}function LQ({todos:e,darkMode:t}){const n=Array.isArray(e)?e:[],[r,a]=h.useState(null),i=h.useRef(null),s=h.useRef(null),[l,c]=h.useState(400),[u,d]=h.useState(function(){if(typeof window<"u"){const P=parseFloat(localStorage.getItem("pave-map-zoom")||"");if(Number.isFinite(P)&&P>.1)return P}return 1});h.useEffect(function(){typeof window<"u"&&localStorage.setItem("pave-map-zoom",String(u))},[u]);const[f,g]=h.useState(function(){return typeof window<"u"?localStorage.getItem("pave-map-show-completed")!=="false":!0});h.useEffect(function(){typeof window<"u"&&localStorage.setItem("pave-map-show-completed",f?"true":"false")},[f]);const[p,m]=h.useState(function(){if(typeof window<"u"){const P=localStorage.getItem("pave-map-rankdir");if(P==="LR"||P==="TB")return P}return"TB"});h.useEffect(function(){typeof window<"u"&&localStorage.setItem("pave-map-rankdir",p)},[p]);const y=h.useMemo(function(){if(f)return n;const P=n.filter(function(O){return O.status!=="completed"}),q={};return P.forEach(function(O){q[O.id]=!0}),P.map(function(O){if(!O.blockedBy||!O.blockedBy.length)return O;const L=O.blockedBy.filter(function(T){return q[T]});return L.length===O.blockedBy.length?O:Object.assign({},O,{blockedBy:L})})},[n,f]);h.useEffect(function(){if(!i.current)return;function P(){i.current&&c(i.current.clientWidth||400)}P();const q=new ResizeObserver(P);return q.observe(i.current),function(){q.disconnect()}},[]);const v=h.useMemo(function(){if(!y.length)return{nodes:[],edges:[],width:0,height:0};const P=new Ud.graphlib.Graph;P.setGraph({rankdir:p,nodesep:24,ranksep:36,marginx:16,marginy:16}),P.setDefaultEdgeLabel(function(){return{}});const q=180,O=56;y.forEach(function(M){P.setNode(String(M.id),{width:q,height:O,todo:M})}),y.forEach(function(M){(M.blockedBy||[]).forEach(function(Y){P.hasNode(String(Y))&&P.setEdge(String(Y),String(M.id))})}),Ud.layout(P);const L=P.nodes().map(function(M){const U=P.node(M);return{id:M,x:U.x-q/2,y:U.y-O/2,w:q,h:O,todo:U.todo}}),T=P.edges().map(function(M){const U=P.edge(M);return{from:M.v,to:M.w,points:U.points}});return{nodes:L,edges:T,width:P.graph().width||q+32,height:P.graph().height||O+32}},[y,p]),x=t?IQ:RQ;if(!y.length){const P=n.length-y.length;return o.jsxs("div",{ref:i,className:"flex flex-col items-center justify-center h-full text-center px-6",children:[o.jsx("div",{className:"text-gray-400 dark:text-gray-500 mb-2",children:o.jsx("svg",{className:"w-12 h-12 mx-auto opacity-50",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})})}),P>0?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"text-sm font-medium text-gray-600 dark:text-gray-300",children:"All work complete"}),o.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1 max-w-xs",children:[P," completed ",P===1?"todo is":"todos are"," hidden."]}),o.jsx("button",{type:"button",onClick:function(){g(!0)},className:"mt-3 text-xs px-3 py-1 rounded border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800",children:"Show completed"})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"text-sm font-medium text-gray-600 dark:text-gray-300",children:"Strategy map is empty"}),o.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1 max-w-xs",children:["Ask the agent to plan the work — todos created with the ",o.jsx("code",{className:"px-1 bg-gray-200 dark:bg-gray-700 rounded",children:"todo"})," tool will appear here as a live DAG."]})]})]})}function b(P){if(!P||P.length<2)return"";let q="M "+P[0].x+" "+P[0].y;for(let O=1;O<P.length;O++)q+=" L "+P[O].x+" "+P[O].y;return q}const k=n.reduce(function(P,q){const O=D4(q);return P[O]=(P[O]||0)+1,P},{}),S=k.completed||0,E=Math.max(v.width,100),_=Math.max(v.height,100),C=(E>l-24?1:(l-24)/E)*u,A=E*C,j=_*C;function D(P){(P.ctrlKey||P.metaKey)&&(P.preventDefault(),d(function(q){const O=P.deltaY<0?q*1.1:q/1.1;return Math.max(.25,Math.min(4,O))}))}return o.jsxs("div",{ref:i,className:"h-full flex flex-col bg-white dark:bg-gray-900",children:[o.jsxs("div",{className:"flex items-center justify-between px-3 pt-3 pb-2 text-xs flex-shrink-0",children:[o.jsx("div",{className:"font-semibold text-gray-700 dark:text-gray-200",children:"Strategy Map"}),o.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[o.jsxs("span",{children:[n.length," total"]}),k.in_progress?o.jsxs("span",{className:"text-blue-600 dark:text-blue-400",children:[k.in_progress," active"]}):null,S?o.jsxs("span",{className:"text-green-600 dark:text-green-400",children:[S," done"]}):null,k.blocked?o.jsxs("span",{className:"text-amber-600 dark:text-amber-400",children:[k.blocked," blocked"]}):null,o.jsxs("div",{className:"flex items-center gap-0.5 ml-1 border-l border-gray-200 dark:border-gray-700 pl-2",children:[o.jsx("button",{type:"button",onClick:function(){m(function(P){return P==="TB"?"LR":"TB"})},className:"px-1.5 py-0.5 rounded text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 text-[10px]",title:p==="TB"?"Switch to horizontal layout":"Switch to vertical layout","aria-label":"Toggle layout direction",children:p==="TB"?"↓":"→"}),o.jsx("button",{type:"button",onClick:function(){d(function(P){return Math.max(.25,P/1.25)})},className:"px-1.5 py-0.5 rounded text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800",title:"Zoom out","aria-label":"Zoom out",children:"−"}),o.jsxs("button",{type:"button",onClick:function(){d(1)},className:"px-1.5 py-0.5 rounded text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 text-[10px] tabular-nums min-w-[3em]",title:"Reset zoom","aria-label":"Reset zoom",children:[Math.round(u*100),"%"]}),o.jsx("button",{type:"button",onClick:function(){d(function(P){return Math.min(4,P*1.25)})},className:"px-1.5 py-0.5 rounded text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800",title:"Zoom in","aria-label":"Zoom in",children:"+"})]}),S>0?o.jsx("button",{type:"button",onClick:function(){g(function(P){return!P})},className:"ml-1 px-2 py-0.5 rounded border text-[10px] "+(f?"border-blue-400 text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800"),title:f?"Hide completed todos":"Show completed todos",children:f?"hide done":"show done"}):null]})]}),o.jsx("div",{ref:s,className:"flex-1 min-h-0 overflow-auto px-3 pb-3",onWheel:D,children:o.jsxs("svg",{viewBox:"0 0 "+E+" "+_,width:A,height:j,style:{display:"block"},children:[o.jsx("defs",{children:o.jsx("marker",{id:"sm-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto",children:o.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:t?"#64748b":"#94a3b8"})})}),v.edges.map(function(P,q){return o.jsx("path",{d:b(P.points),fill:"none",stroke:t?"#475569":"#cbd5e1",strokeWidth:1.5,markerEnd:"url(#sm-arrow)"},"e"+q)}),v.nodes.map(function(P){const q=D4(P.todo),O=x[q],L=q==="in_progress",T=r===P.id;return o.jsxs("g",{transform:"translate("+P.x+","+P.y+")",onMouseEnter:function(){a(P.id)},onMouseLeave:function(){a(null)},style:{cursor:"pointer"},children:[o.jsx("rect",{width:P.w,height:P.h,rx:6,ry:6,fill:O.fill,stroke:O.stroke,strokeWidth:L||T?2:1.25,children:L?o.jsx("animate",{attributeName:"stroke-width",values:"1.5;2.5;1.5",dur:"1.6s",repeatCount:"indefinite"}):null}),L?o.jsx("circle",{cx:10,cy:10,r:3.5,fill:O.stroke,children:o.jsx("animate",{attributeName:"r",values:"3;5;3",dur:"1.4s",repeatCount:"indefinite"})}):null,o.jsx("text",{x:P.w/2,y:P.h/2-6,textAnchor:"middle",fontSize:11,fontWeight:600,fill:O.label,children:"#"+P.todo.id}),o.jsx("text",{x:P.w/2,y:P.h/2+12,textAnchor:"middle",fontSize:11,fill:t?"#e2e8f0":"#0f172a",children:MQ(P.todo.text,26)}),T&&P.todo.text&&P.todo.text.length>26?o.jsx("title",{children:P.todo.text}):null]},P.id)})]})})]})}const OQ={bash:{fill:"#f1f5f9",stroke:"#64748b",label:"#334155"},read:{fill:"#dbeafe",stroke:"#3b82f6",label:"#1d4ed8"},Read:{fill:"#dbeafe",stroke:"#3b82f6",label:"#1d4ed8"},edit:{fill:"#dcfce7",stroke:"#16a34a",label:"#15803d"},Edit:{fill:"#dcfce7",stroke:"#16a34a",label:"#15803d"},write:{fill:"#dcfce7",stroke:"#15803d",label:"#14532d"},Write:{fill:"#dcfce7",stroke:"#15803d",label:"#14532d"},glob:{fill:"#ede9fe",stroke:"#8b5cf6",label:"#6d28d9"},grep:{fill:"#ede9fe",stroke:"#8b5cf6",label:"#6d28d9"},fetch:{fill:"#fce7f3",stroke:"#db2777",label:"#9d174d"},canvas:{fill:"#fef3c7",stroke:"#f59e0b",label:"#b45309"},todo:{fill:"#e0f2fe",stroke:"#0ea5e9",label:"#0369a1"}},DQ={fill:"#f1f5f9",stroke:"#94a3b8",label:"#475569"},PQ={fill:"#fee2e2",stroke:"#dc2626",label:"#991b1b"},FQ={bash:{fill:"#1e293b",stroke:"#94a3b8",label:"#e2e8f0"},read:{fill:"#1e3a8a",stroke:"#60a5fa",label:"#bfdbfe"},Read:{fill:"#1e3a8a",stroke:"#60a5fa",label:"#bfdbfe"},edit:{fill:"#14532d",stroke:"#22c55e",label:"#86efac"},Edit:{fill:"#14532d",stroke:"#22c55e",label:"#86efac"},write:{fill:"#14532d",stroke:"#16a34a",label:"#bbf7d0"},Write:{fill:"#14532d",stroke:"#16a34a",label:"#bbf7d0"},glob:{fill:"#4c1d95",stroke:"#a78bfa",label:"#ddd6fe"},grep:{fill:"#4c1d95",stroke:"#a78bfa",label:"#ddd6fe"},fetch:{fill:"#831843",stroke:"#f472b6",label:"#fbcfe8"},canvas:{fill:"#78350f",stroke:"#fbbf24",label:"#fde68a"},todo:{fill:"#0c4a6e",stroke:"#38bdf8",label:"#bae6fd"}},BQ={fill:"#1e293b",stroke:"#64748b",label:"#cbd5e1"},zQ={fill:"#7f1d1d",stroke:"#f87171",label:"#fecaca"},UQ={fill:"#fef9c3",stroke:"#ca8a04",label:"#713f12"},$Q={fill:"#3f2d0a",stroke:"#facc15",label:"#fde68a"},oi={data:{light:"#0ea5e9",dark:"#38bdf8"},file:{light:"#94a3b8",dark:"#64748b"},seq:{light:"#cbd5e1",dark:"#475569"}};function HQ(e,t){return e?e.length<=t?e:e.slice(0,t-1)+"…":""}function qQ(e,t){return e.kind==="thought"?t?$Q:UQ:e.status==="error"?t?zQ:PQ:(t?FQ:OQ)[e.tool]||(t?BQ:DQ)}function WQ({graph:e,darkMode:t,onNodeClick:n}){const r=e&&Array.isArray(e.nodes)?e.nodes:[],a=e&&Array.isArray(e.edges)?e.edges:[],i=h.useRef(null),s=h.useRef(null),[l,c]=h.useState(null),[u,d]=h.useState(400),[f,g]=h.useState(function(){if(typeof window<"u"){const L=parseFloat(localStorage.getItem("pave-toolmap-zoom")||"");if(Number.isFinite(L)&&L>.1)return L}return 1});h.useEffect(function(){typeof window<"u"&&localStorage.setItem("pave-toolmap-zoom",String(f))},[f]);const[p,m]=h.useState(function(){if(typeof window<"u"){const L=localStorage.getItem("pave-toolmap-rankdir");if(L==="LR"||L==="TB")return L}return"TB"});h.useEffect(function(){typeof window<"u"&&localStorage.setItem("pave-toolmap-rankdir",p)},[p]);const[y,v]=h.useState(function(){return typeof window<"u"?localStorage.getItem("pave-toolmap-show-hidden")==="true":!1});h.useEffect(function(){typeof window<"u"&&localStorage.setItem("pave-toolmap-show-hidden",y?"true":"false")},[y]);const[x,b]=h.useState(function(){return!(typeof window<"u"&&localStorage.getItem("pave-toolmap-show-thoughts")==="false")});h.useEffect(function(){typeof window<"u"&&localStorage.setItem("pave-toolmap-show-thoughts",x?"true":"false")},[x]);const k=h.useMemo(function(){let L=r;return y||(L=L.filter(function(T){return!T.hidden})),x||(L=L.filter(function(T){return T.kind!=="thought"})),L},[r,y,x]),S=h.useMemo(function(){const L={};return k.forEach(function(T){L[T.id]=!0}),a.filter(function(T){return L[T.from]&&L[T.to]})},[a,k]),E=h.useMemo(function(){if(!k.length)return{nodes:[],edges:[],width:0,height:0};const L=new Ud.graphlib.Graph;L.setGraph({rankdir:p,nodesep:18,ranksep:32,marginx:14,marginy:14}),L.setDefaultEdgeLabel(function(){return{}});const T=168,M=44,U=240,Y=60;k.forEach(function(X){X.kind==="thought"?L.setNode(X.id,{width:U,height:Y,node:X}):L.setNode(X.id,{width:T,height:M,node:X})}),S.forEach(function(X){L.hasNode(X.from)&&L.hasNode(X.to)&&L.setEdge(X.from,X.to,{kind:X.kind})}),Ud.layout(L);const R=L.nodes().map(function(X){const I=L.node(X);return{id:X,x:I.x-I.width/2,y:I.y-I.height/2,w:I.width,h:I.height,node:I.node}}),V=L.edges().map(function(X){const I=L.edge(X);return{from:X.v,to:X.w,points:I.points||[],kind:I.kind||"seq"}});return{nodes:R,edges:V,width:L.graph().width||T+28,height:L.graph().height||M+28}},[k,S,p]);h.useEffect(function(){if(!i.current)return;function L(){i.current&&d(i.current.clientWidth||400)}L();const T=new ResizeObserver(L);return T.observe(i.current),function(){T.disconnect()}},[]);const _=h.useMemo(function(){const L={total:0,ok:0,error:0,running:0,hidden:0,thoughts:0};return r.forEach(function(T){if(T.kind==="thought"){L.thoughts++;return}L.total++,T.hidden&&L.hidden++,T.status==="error"?L.error++:T.status==="running"?L.running++:L.ok++}),L},[r]);if(!k.length)return o.jsxs("div",{ref:i,className:"flex flex-col items-center justify-center h-full text-center px-6",children:[o.jsx("div",{className:"text-gray-400 dark:text-gray-500 mb-2",children:o.jsx("svg",{className:"w-12 h-12 mx-auto opacity-50",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})}),o.jsx("div",{className:"text-sm font-medium text-gray-600 dark:text-gray-300",children:"No tool calls yet"}),o.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1 max-w-xs",children:"Tool invocations will appear here as a DAG showing data flow and file dependencies."}),_.hidden>0&&!y?o.jsxs("button",{type:"button",onClick:function(){v(!0)},className:"mt-3 text-xs px-3 py-1 rounded border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800",children:["Show ",_.hidden," hidden"]}):null]});function w(L){if(!L||L.length<2)return"";let T="M "+L[0].x+" "+L[0].y;for(let M=1;M<L.length;M++)T+=" L "+L[M].x+" "+L[M].y;return T}const C=Math.max(E.width,100),A=Math.max(E.height,100),D=(C>u-24?1:(u-24)/C)*f,P=C*D,q=A*D;function O(L){(L.ctrlKey||L.metaKey)&&(L.preventDefault(),g(function(T){const M=L.deltaY<0?T*1.1:T/1.1;return Math.max(.25,Math.min(4,M))}))}return o.jsxs("div",{ref:i,className:"h-full flex flex-col bg-white dark:bg-gray-900",children:[o.jsxs("div",{className:"flex items-center justify-between px-3 pt-3 pb-2 text-xs flex-shrink-0",children:[o.jsx("div",{className:"font-semibold text-gray-700 dark:text-gray-200",children:"Tool Calls"}),o.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[o.jsxs("span",{children:[_.total," tools"]}),_.running?o.jsxs("span",{className:"text-blue-600 dark:text-blue-400",children:[_.running," live"]}):null,_.error?o.jsxs("span",{className:"text-red-600 dark:text-red-400",children:[_.error," err"]}):null,o.jsxs("div",{className:"flex items-center gap-0.5 ml-1 border-l border-gray-200 dark:border-gray-700 pl-2",children:[o.jsx("button",{type:"button",onClick:function(){m(function(L){return L==="TB"?"LR":"TB"})},className:"px-1.5 py-0.5 rounded text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 text-[10px]",title:p==="TB"?"Switch to horizontal layout":"Switch to vertical layout","aria-label":"Toggle layout direction",children:p==="TB"?"↓":"→"}),o.jsx("button",{type:"button",onClick:function(){g(function(L){return Math.max(.25,L/1.25)})},className:"px-1.5 py-0.5 rounded text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800",title:"Zoom out","aria-label":"Zoom out",children:"−"}),o.jsxs("button",{type:"button",onClick:function(){g(1)},className:"px-1.5 py-0.5 rounded text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 text-[10px] tabular-nums min-w-[3em]",title:"Reset zoom","aria-label":"Reset zoom",children:[Math.round(f*100),"%"]}),o.jsx("button",{type:"button",onClick:function(){g(function(L){return Math.min(4,L*1.25)})},className:"px-1.5 py-0.5 rounded text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800",title:"Zoom in","aria-label":"Zoom in",children:"+"})]}),_.hidden>0?o.jsx("button",{type:"button",onClick:function(){v(function(L){return!L})},className:"ml-1 px-2 py-0.5 rounded border text-[10px] "+(y?"border-blue-400 text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800"),title:y?"Hide bookkeeping tools":"Show bookkeeping tools (todo, permission, etc.)",children:y?"hide bk":"show bk"}):null,_.thoughts>0?o.jsx("button",{type:"button",onClick:function(){b(function(L){return!L})},className:"ml-1 px-2 py-0.5 rounded border text-[10px] "+(x?"border-yellow-500 text-yellow-700 dark:text-yellow-300 bg-yellow-50 dark:bg-yellow-900/30":"border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800"),title:x?"Hide reasoning bubbles":"Show reasoning bubbles ("+_.thoughts+" thoughts)",children:x?"💭 "+_.thoughts:"💭 off"}):null]})]}),o.jsx("div",{ref:s,className:"flex-1 min-h-0 overflow-auto px-3 pb-3",onWheel:O,children:o.jsxs("svg",{viewBox:"0 0 "+C+" "+A,width:P,height:q,style:{display:"block"},children:[o.jsxs("defs",{children:[o.jsx("marker",{id:"tcm-arrow-data",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto",children:o.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:t?oi.data.dark:oi.data.light})}),o.jsx("marker",{id:"tcm-arrow-file",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto",children:o.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:t?oi.file.dark:oi.file.light})}),o.jsx("marker",{id:"tcm-arrow-seq",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto",children:o.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:t?oi.seq.dark:oi.seq.light})})]}),E.edges.map(function(L,T){const M=t?oi[L.kind].dark:oi[L.kind].light;return o.jsx("path",{d:w(L.points),fill:"none",stroke:M,strokeWidth:L.kind==="data"?1.75:L.kind==="file"?1.25:1,strokeDasharray:L.kind==="seq"?"3,3":void 0,markerEnd:"url(#tcm-arrow-"+L.kind+")"},"e"+T)}),E.nodes.map(function(L){const T=L.node,M=qQ(T,t),U=T.status==="running",Y=l===L.id;if(T.kind==="thought"){const V=T.label||"",X=32,I=3,H=V.split(/\s+/),ue=[];let J="";for(const ge of H){if(ue.length===I-1&&(J+" "+ge).length>X){ue.push(J);const K=H.slice(H.indexOf(ge)).join(" ");ue.push(K.length>X?K.slice(0,X-1)+"…":K),J="";break}if(!J){J=ge;continue}if((J+" "+ge).length<=X?J=J+" "+ge:(ue.push(J),J=ge),ue.length>=I)break}return J&&ue.length<I&&ue.push(J),o.jsxs("g",{transform:"translate("+L.x+","+L.y+")",onMouseEnter:function(){c(L.id)},onMouseLeave:function(){c(null)},onClick:function(){n&&n(T)},style:{cursor:n?"pointer":"default"},children:[o.jsx("rect",{width:L.w,height:L.h,rx:L.h/2,ry:L.h/2,fill:M.fill,stroke:M.stroke,strokeWidth:Y?1.75:1,strokeDasharray:T.source==="reasoning"?void 0:"4,2"}),o.jsx("text",{x:14,y:2,fontSize:9,fontStyle:"italic",fill:M.label,children:ue.map(function(ge,K){return o.jsx("tspan",{x:14,dy:K===0?14:11,children:(K===0?"💭 ":"")+ge},"ln"+K)})}),o.jsx("title",{children:(T.source==="reasoning"?"[reasoning] ":"[thought] ")+(T.fullText||T.label)})]},L.id)}return o.jsxs("g",{transform:"translate("+L.x+","+L.y+")",onMouseEnter:function(){c(L.id)},onMouseLeave:function(){c(null)},onClick:function(){n&&n(T)},style:{cursor:n?"pointer":"default"},children:[o.jsx("rect",{width:L.w,height:L.h,rx:5,ry:5,fill:M.fill,stroke:M.stroke,strokeWidth:U||Y?2:1.25,opacity:T.hidden?.55:1,children:U?o.jsx("animate",{attributeName:"stroke-width",values:"1.5;2.5;1.5",dur:"1.6s",repeatCount:"indefinite"}):null}),o.jsx("text",{x:8,y:16,fontSize:10,fontWeight:600,fill:M.label,children:T.tool}),o.jsx("text",{x:8,y:32,fontSize:10,fill:t?"#cbd5e1":"#475569",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",children:HQ(T.label,22)}),o.jsx("title",{children:T.tool+" · "+T.label+(T.status==="error"?" · ERROR":T.status==="running"?" · RUNNING":"")}),U?o.jsxs("g",{transform:"translate("+(L.w-9)+",9)",children:[o.jsx("circle",{r:4.5,fill:t?"#1e293b":"#ffffff",stroke:M.stroke,strokeWidth:.75}),o.jsxs("circle",{r:3,fill:t?"#38bdf8":"#0ea5e9",children:[o.jsx("animate",{attributeName:"opacity",values:"1;0.25;1",dur:"1.1s",repeatCount:"indefinite"}),o.jsx("animate",{attributeName:"r",values:"2.4;3.4;2.4",dur:"1.1s",repeatCount:"indefinite"})]})]}):null]},L.id)})]})})]})}/*! @license DOMPurify 3.4.14 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.14/LICENSE */function P4(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function VQ(e){if(Array.isArray(e))return e}function GQ(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,a,i,s,l=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(c=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);c=!0);}catch(d){u=!0,a=d}finally{try{if(!c&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw a}}return l}}function KQ(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
104
104
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function YQ(e,t){return VQ(e)||GQ(e,t)||XQ(e,t)||KQ()}function XQ(e,t){if(e){if(typeof e=="string")return P4(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?P4(e,t):void 0}}const A3=Object.entries,F4=Object.setPrototypeOf,QQ=Object.isFrozen,ZQ=Object.getPrototypeOf,JQ=Object.getOwnPropertyDescriptor;let Rn=Object.freeze,Ln=Object.seal,Ks=Object.create,R3=typeof Reflect<"u"&&Reflect,Ub=R3.apply,$b=R3.construct;Rn||(Rn=function(t){return t});Ln||(Ln=function(t){return t});Ub||(Ub=function(t,n){for(var r=arguments.length,a=new Array(r>2?r-2:0),i=2;i<r;i++)a[i-2]=arguments[i];return t.apply(n,a)});$b||($b=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return new t(...r)});const es=En(Array.prototype.forEach),eZ=En(Array.prototype.lastIndexOf),B4=En(Array.prototype.pop),sl=En(Array.prototype.push),tZ=En(Array.prototype.splice),xo=Array.isArray,vl=En(String.prototype.toLowerCase),ry=En(String.prototype.toString),z4=En(String.prototype.match),ol=En(String.prototype.replace),U4=En(String.prototype.indexOf),nZ=En(String.prototype.trim),rZ=En(Number.prototype.toString),aZ=En(Boolean.prototype.toString),$4=typeof BigInt>"u"?null:En(BigInt.prototype.toString),H4=typeof Symbol>"u"?null:En(Symbol.prototype.toString),lr=En(Object.prototype.hasOwnProperty),ll=En(Object.prototype.toString),$n=En(RegExp.prototype.test),Yi=iZ(TypeError);function En(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return Ub(e,t,r)}}function iZ(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return $b(e,n)}}function Dt(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:vl;if(F4&&F4(e,null),!xo(t))return e;let r=t.length;for(;r--;){let a=t[r];if(typeof a=="string"){const i=n(a);i!==a&&(QQ(t)||(t[r]=i),a=i)}e[a]=!0}return e}function sZ(e){for(let t=0;t<e.length;t++)lr(e,t)||(e[t]=null);return e}function vr(e){const t=Ks(null);for(const r of A3(e)){var n=YQ(r,2);const a=n[0],i=n[1];lr(e,a)&&(xo(i)?t[a]=sZ(i):i&&typeof i=="object"&&i.constructor===Object?t[a]=vr(i):t[a]=i)}return t}function oZ(e){switch(typeof e){case"string":return e;case"number":return rZ(e);case"boolean":return aZ(e);case"bigint":return $4?$4(e):"0";case"symbol":return H4?H4(e):"Symbol()";case"undefined":return ll(e);case"function":case"object":{if(e===null)return ll(e);const t=e,n=ea(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:ll(r)}return ll(e)}default:return ll(e)}}function ea(e,t){for(;e!==null;){const r=JQ(e,t);if(r){if(r.get)return En(r.get);if(typeof r.value=="function")return En(r.value)}e=ZQ(e)}function n(){return null}return n}function lZ(e){try{return $n(e,""),!0}catch{return!1}}const q4=Rn(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ay=Rn(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),iy=Rn(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),cZ=Rn(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),sy=Rn(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),uZ=Rn(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),W4=Rn(["#text"]),V4=Rn(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),oy=Rn(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),G4=Rn(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Au=Rn(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),dZ=Ln(/{{[\w\W]*|^[\w\W]*}}/g),fZ=Ln(/<%[\w\W]*|^[\w\W]*%>/g),gZ=Ln(/\${[\w\W]*/g),pZ=Ln(/^data-[\-\w.\u00B7-\uFFFF]+$/),hZ=Ln(/^aria-[\-\w]+$/),K4=Ln(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),mZ=Ln(/^(?:\w+script|data):/i),xZ=Ln(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),yZ=Ln(/^html$/i),bZ=Ln(/^[a-z][.\w]*(-[.\w]+)+$/i),Y4=Ln(/<[/\w!]/g),X4=Ln(/<[/\w]/g),vZ=Ln(/<\/no(script|embed|frames)/i),kZ=Ln(/\/>/i),yr={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},I3=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],_Z=Rn(Dt({},I3)),wZ=function(){const e={};return es(I3,t=>{e[t]=Ln(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),Rn(e)}(),EZ=function(){return typeof window>"u"?null:window},SZ=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const a="data-tt-policy-suffix";n&&n.hasAttribute(a)&&(r=n.getAttribute(a));const i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Q4=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},li=function(t,n,r,a){return lr(t,n)&&xo(t[n])?Dt(a.base?vr(a.base):{},t[n],a.transform):r},ly=function(t,n,r){const a=lr(t,n)?t[n]:void 0;return a&&typeof a=="object"?vr(a):r()};function M3(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:EZ();const t=De=>M3(De);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==yr.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,a=r.currentScript;e.DocumentFragment;const i=e.HTMLTemplateElement,s=e.Node,l=e.Element,c=e.NodeFilter,u=e.NamedNodeMap;u===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const d=e.DOMParser,f=e.trustedTypes,g=l.prototype,p=ea(g,"cloneNode"),m=ea(g,"remove"),y=ea(g,"nextSibling"),v=ea(g,"childNodes"),x=ea(g,"parentNode"),b=ea(g,"shadowRoot"),k=ea(g,"attributes"),S=s&&s.prototype?ea(s.prototype,"nodeType"):null,E=s&&s.prototype?ea(s.prototype,"nodeName"):null,_=s&&s.prototype?ea(s.prototype,"ownerDocument"):null,w=function($){return S?S($):$.nodeType},C=function($){return E?E($):$.nodeName};if(typeof i=="function"){const De=n.createElement("template");De.content&&De.content.ownerDocument&&(n=De.content.ownerDocument)}let A,j="",D,P=!1,q=0;const O=function(){if(q>0)throw Yi('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},L=function($){O(),q++;try{return A.createHTML($)}finally{q--}},T=function($){O(),q++;try{return A.createScriptURL($)}finally{q--}},M=function(){return P||(D=SZ(f,a),P=!0),D},U=n,Y=U.implementation,R=U.createNodeIterator,V=U.createDocumentFragment,X=U.getElementsByTagName,I=r.importNode;let H=Q4();t.isSupported=typeof A3=="function"&&typeof x=="function"&&Y&&Y.createHTMLDocument!==void 0;const ue=dZ,J=fZ,ge=gZ,K=pZ,he=hZ,Me=mZ,Te=xZ,Ae=bZ;let Pe=K4,be=null;const de=Dt({},[...q4,...ay,...iy,...sy,...W4]);let pe=null;const Oe=Dt({},[...V4,...oy,...G4,...Au]);let me=Object.seal(Ks(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ee=null,Re=null;const fe=Object.seal(Ks(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ge=!0,Se=!0,we=!1,qe=!0,F=!1,B=!0,W=!1,re=!1,_e=null,We=null,Ne=!1,je=!1,He=!1,ct=!1,Ue=!0,Je=!1;const ce="user-content-";let Ve=!0,it=!1,gt={},Bt=null;const Nn=Dt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let xn=null;const Ht=Dt({},["audio","video","img","source","image","track"]);let mr=null;const pn=Dt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),zt="http://www.w3.org/1998/Math/MathML",Gr="http://www.w3.org/2000/svg",se="http://www.w3.org/1999/xhtml";let te=se,xe=!1,Ie=null;const Ke=Dt({},[zt,Gr,se],ry),Et=Rn(["mi","mo","mn","ms","mtext"]);let bt=Dt({},Et);const Ot=Rn(["annotation-xml"]);let ve=Dt({},Ot);const st=Dt({},["title","style","font","a","script"]);let St=null;const Ta=["application/xhtml+xml","text/html"],ar="text/html";let It=null,Kr=null;const Bf=n.createElement("form"),ga=function($){return $ instanceof RegExp||$ instanceof Function},Rr=function(){let $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Kr&&Kr===$)return;(!$||typeof $!="object")&&($={}),$=vr($),St=Ta.indexOf($.PARSER_MEDIA_TYPE)===-1?ar:$.PARSER_MEDIA_TYPE,It=St==="application/xhtml+xml"?ry:vl,be=li($,"ALLOWED_TAGS",de,{transform:It}),pe=li($,"ALLOWED_ATTR",Oe,{transform:It}),Ie=li($,"ALLOWED_NAMESPACES",Ke,{transform:ry}),mr=li($,"ADD_URI_SAFE_ATTR",pn,{transform:It,base:pn}),xn=li($,"ADD_DATA_URI_TAGS",Ht,{transform:It,base:Ht}),Bt=li($,"FORBID_CONTENTS",Nn,{transform:It}),ee=li($,"FORBID_TAGS",vr({}),{transform:It}),Re=li($,"FORBID_ATTR",vr({}),{transform:It}),gt=lr($,"USE_PROFILES")?$.USE_PROFILES&&typeof $.USE_PROFILES=="object"?vr($.USE_PROFILES):$.USE_PROFILES:!1,Ge=$.ALLOW_ARIA_ATTR!==!1,Se=$.ALLOW_DATA_ATTR!==!1,we=$.ALLOW_UNKNOWN_PROTOCOLS||!1,qe=$.ALLOW_SELF_CLOSE_IN_ATTR!==!1,F=$.SAFE_FOR_TEMPLATES||!1,B=$.SAFE_FOR_XML!==!1,W=$.WHOLE_DOCUMENT||!1,je=$.RETURN_DOM||!1,He=$.RETURN_DOM_FRAGMENT||!1,ct=$.RETURN_TRUSTED_TYPE||!1,Ne=$.FORCE_BODY||!1,Ue=$.SANITIZE_DOM!==!1,Je=$.SANITIZE_NAMED_PROPS||!1,Ve=$.KEEP_CONTENT!==!1,it=$.IN_PLACE||!1,Pe=lZ($.ALLOWED_URI_REGEXP)?$.ALLOWED_URI_REGEXP:K4,te=typeof $.NAMESPACE=="string"?$.NAMESPACE:se,bt=ly($,"MATHML_TEXT_INTEGRATION_POINTS",()=>Dt({},Et)),ve=ly($,"HTML_INTEGRATION_POINTS",()=>Dt({},Ot));const ie=ly($,"CUSTOM_ELEMENT_HANDLING",()=>Ks(null));if(me=Ks(null),lr(ie,"tagNameCheck")&&ga(ie.tagNameCheck)&&(me.tagNameCheck=ie.tagNameCheck),lr(ie,"attributeNameCheck")&&ga(ie.attributeNameCheck)&&(me.attributeNameCheck=ie.attributeNameCheck),lr(ie,"allowCustomizedBuiltInElements")&&typeof ie.allowCustomizedBuiltInElements=="boolean"&&(me.allowCustomizedBuiltInElements=ie.allowCustomizedBuiltInElements),Ln(me),F&&(Se=!1),He&&(je=!0),gt&&(be=Dt({},W4),pe=Ks(null),gt.html===!0&&(Dt(be,q4),Dt(pe,V4)),gt.svg===!0&&(Dt(be,ay),Dt(pe,oy),Dt(pe,Au)),gt.svgFilters===!0&&(Dt(be,iy),Dt(pe,oy),Dt(pe,Au)),gt.mathMl===!0&&(Dt(be,sy),Dt(pe,G4),Dt(pe,Au))),fe.tagCheck=null,fe.attributeCheck=null,lr($,"ADD_TAGS")&&(typeof $.ADD_TAGS=="function"?fe.tagCheck=$.ADD_TAGS:xo($.ADD_TAGS)&&(be===de&&(be=vr(be)),Dt(be,$.ADD_TAGS,It))),lr($,"ADD_ATTR")&&(typeof $.ADD_ATTR=="function"?fe.attributeCheck=$.ADD_ATTR:xo($.ADD_ATTR)&&(pe===Oe&&(pe=vr(pe)),Dt(pe,$.ADD_ATTR,It))),lr($,"ADD_FORBID_CONTENTS")&&xo($.ADD_FORBID_CONTENTS)&&(Bt===Nn&&(Bt=vr(Bt)),Dt(Bt,$.ADD_FORBID_CONTENTS,It)),Ve&&(be["#text"]=!0),W&&Dt(be,["html","head","body"]),be.table&&(Dt(be,["tbody"]),delete ee.tbody),$.TRUSTED_TYPES_POLICY){if(typeof $.TRUSTED_TYPES_POLICY.createHTML!="function")throw Yi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof $.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Yi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const Ce=A;A=$.TRUSTED_TYPES_POLICY;try{j=L("")}catch(Ye){throw A=Ce,Ye}}else $.TRUSTED_TYPES_POLICY===null?(A=void 0,j=""):(A===void 0&&(A=M()),A&&typeof j=="string"&&(j=L("")));Rn&&Rn($),Kr=$},zi=Dt({},[...ay,...iy,...cZ]),ir=Dt({},[...sy,...uZ]),zf=function($,ie,Ce){return ie.namespaceURI===se?$==="svg":ie.namespaceURI===zt?$==="svg"&&(Ce==="annotation-xml"||bt[Ce]):!!zi[$]},ti=function($,ie,Ce){return ie.namespaceURI===se?$==="math":ie.namespaceURI===Gr?$==="math"&&ve[Ce]:!!ir[$]},Is=function($,ie,Ce){return ie.namespaceURI===Gr&&!ve[Ce]||ie.namespaceURI===zt&&!bt[Ce]?!1:!ir[$]&&(st[$]||!zi[$])},Mc=function($){let ie=x($);(!ie||!ie.tagName)&&(ie={namespaceURI:te,tagName:"template"});const Ce=vl($.tagName),Ye=vl(ie.tagName);return Ie[$.namespaceURI]?$.namespaceURI===Gr?zf(Ce,ie,Ye):$.namespaceURI===zt?ti(Ce,ie,Ye):$.namespaceURI===se?Is(Ce,ie,Ye):!!(St==="application/xhtml+xml"&&Ie[$.namespaceURI]):!1},Yr=function($){sl(t.removed,{element:$});try{x($).removeChild($)}catch{if(m($),!x($))throw Yi("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ui=function($,ie,Ce){try{$.removeAttributeNode(ie)}catch{try{$.removeAttribute(Ce)}catch{}}},On=function($){Ms($);const ie=v($);if(ie){const Ye=[];es(ie,nt=>{sl(Ye,nt)}),es(Ye,nt=>{try{m(nt)}catch{}})}const Ce=k($);if(Ce)for(let Ye=Ce.length-1;Ye>=0;--Ye){const nt=Ce[Ye],lt=nt&&nt.name;typeof lt=="string"&&Ui($,nt,lt)}},hn=function($,ie,Ce){if(!Ce)try{Ce=ie.getAttributeNode($)}catch{Ce=null}sl(t.removed,{attribute:Ce||null,from:ie});try{Ce?ie.removeAttributeNode(Ce):ie.removeAttribute($)}catch{try{ie.removeAttribute($)}catch{}}if($==="is")if(je||He)try{Yr(ie)}catch{}else try{ie.setAttribute($,"")}catch{}},Lc=function($){const ie=k($);if(ie)for(let Ce=ie.length-1;Ce>=0;--Ce){const Ye=ie[Ce],nt=Ye&&Ye.name;typeof nt!="string"||pe[It(nt)]||Ui($,Ye,nt)}},Ms=function($){const ie=[$];for(;ie.length>0;){const Ce=ie.pop();w(Ce)===yr.element&&Lc(Ce);const nt=v(Ce);if(nt)for(let lt=nt.length-1;lt>=0;--lt)ie.push(nt[lt])}},Xr=function($,ie){return B?$==="patchsrc"?!0:$==="for"&&ie!=="label"&&ie!=="output":!1},Uf=function($){if(!B)return;const ie=[$];for(;ie.length>0;){const Ce=ie.pop(),Ye=w(Ce);if(Ye===yr.processingInstruction||Ye===yr.comment&&$n(X4,Ce.data)){try{m(Ce)}catch{}continue}if(Ye===yr.element){const lt=Ce,jt=It(C(Ce));try{lt.hasAttribute&&lt.hasAttribute("patchsrc")&&lt.removeAttribute("patchsrc"),lt.hasAttribute&&lt.hasAttribute("for")&&Xr("for",jt)&&lt.removeAttribute("for")}catch{}}const nt=v(Ce);if(nt)for(let lt=nt.length-1;lt>=0;--lt)ie.push(nt[lt])}},Ls=function($){let ie=null,Ce=null;if(Ne)$="<remove></remove>"+$;else{const lt=z4($,/^[\r\n\t ]+/);Ce=lt&&lt[0]}St==="application/xhtml+xml"&&te===se&&($='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+$+"</body></html>");const Ye=A?L($):$;if(te===se)try{ie=new d().parseFromString(Ye,St)}catch{}if(!ie||!ie.documentElement){ie=Y.createDocument(te,"template",null);try{ie.documentElement.innerHTML=xe?j:Ye}catch{}}const nt=ie.body||ie.documentElement;return $&&Ce&&nt.insertBefore(n.createTextNode(Ce),nt.childNodes[0]||null),te===se?X.call(ie,W?"html":"body")[0]:W?ie.documentElement:nt},Oc=function($){const ie=_?_($):$.ownerDocument;return R.call(ie||$,$,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Aa=function($){return $=ol($,ue," "),$=ol($,J," "),$=ol($,ge," "),$},zo=function($){var ie;$.normalize();const Ce=_?_($):$.ownerDocument,Ye=R.call(Ce||$,$,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let nt=Ye.nextNode();for(;nt;)nt.data=Aa(nt.data),nt=Ye.nextNode();const lt=(ie=$.querySelectorAll)===null||ie===void 0?void 0:ie.call($,"template");lt&&es(lt,jt=>{Ir(jt.content)&&zo(jt.content)})},$i=function($){const ie=E?E($):null;return typeof ie!="string"||It(ie)!=="form"?!1:typeof $.nodeName!="string"||typeof $.textContent!="string"||typeof $.removeChild!="function"||$.attributes!==k($)||typeof $.removeAttribute!="function"||typeof $.setAttribute!="function"||typeof $.namespaceURI!="string"||typeof $.insertBefore!="function"||typeof $.hasChildNodes!="function"||$.nodeType!==S($)||$.childNodes!==v($)},Ir=function($){if(!S||typeof $!="object"||$===null)return!1;try{return S($)===yr.documentFragment}catch{return!1}},Ra=function($){if(!S||typeof $!="object"||$===null)return!1;try{return typeof S($)=="number"}catch{return!1}};function Mr(De,$,ie){De.length!==0&&es(De,Ce=>{Ce.call(t,$,ie,Kr)})}const Hi=function($,ie){return!!(B&&$.hasChildNodes()&&!Ra($.firstElementChild)&&$n(Y4,$.textContent)&&$n(Y4,$.innerHTML)||B&&$.namespaceURI===se&&_Z[ie]&&(Ra($.firstElementChild)||typeof $.textContent=="string"&&$n(wZ[ie],$.textContent))||$.nodeType===yr.processingInstruction||B&&$.nodeType===yr.comment&&$n(X4,$.data))},qi=function($,ie){if($ instanceof RegExp)return $n($,ie);if($ instanceof Function){for(var Ce=arguments.length,Ye=new Array(Ce>2?Ce-2:0),nt=2;nt<Ce;nt++)Ye[nt-2]=arguments[nt];return!!$(ie,...Ye)}return!1},rt=function($,ie,Ce){if(!ee[ie]&&zc(ie)&&qi(me.tagNameCheck,ie))return!1;if(Ve&&!Bt[ie]){const Ye=x($),nt=v($);if(nt&&Ye){const lt=nt.length;for(let jt=lt-1;jt>=0;--jt){const Wt=$===Ce?p(nt[jt],!0):nt[jt];Ye.insertBefore(Wt,y($))}}}return Yr($),!0},Dc=function($,ie,Ce,Ye){return $.length===0?ie:ie===Ce||ie===Ye?vr(ie):ie},Uo=function($,ie){return $===ie||x($)!==null?!1:(it&&Ms($),!0)},Pc=function($,ie){if(Mr(H.beforeSanitizeElements,$,null),Uo($,ie))return!0;if($i($))return Yr($),!0;const Ce=It(C($));if(be=Dc(H.uponSanitizeElement,be,de,_e),Mr(H.uponSanitizeElement,$,{tagName:Ce,allowedTags:be}),Uo($,ie))return!0;if(Hi($,Ce))return Yr($),!0;if(ee[Ce]||!(fe.tagCheck instanceof Function&&fe.tagCheck(Ce))&&!be[Ce]){const nt=rt($,Ce,ie);return nt===!1&&Mr(H.afterSanitizeElements,$,null),nt}if(w($)===yr.element&&!Mc($)||(Ce==="noscript"||Ce==="noembed"||Ce==="noframes")&&$n(vZ,$.innerHTML))return Yr($),!0;if(F&&$.nodeType===yr.text){const nt=Aa($.textContent);$.textContent!==nt&&(sl(t.removed,{element:$.cloneNode()}),$.textContent=nt)}return Mr(H.afterSanitizeElements,$,null),!1},Fc=function($,ie,Ce){if(Re[ie]||Xr(ie,$)||Ue&&(ie==="id"||ie==="name")&&(Ce in n||Ce in Bf))return!1;const Ye=pe[ie]||fe.attributeCheck instanceof Function&&fe.attributeCheck(ie,$);return Se&&$n(K,ie)||Ge&&$n(he,ie)?!0:Ye?mr[ie]||$n(Pe,ol(Ce,Te,""))||(ie==="src"||ie==="xlink:href"||ie==="href")&&$!=="script"&&U4(Ce,"data:")===0&&xn[$]||we&&!$n(Me,ol(Ce,Te,""))?!0:!Ce:zc($)&&qi(me.tagNameCheck,$)&&qi(me.attributeNameCheck,ie,$)||ie==="is"&&me.allowCustomizedBuiltInElements&&qi(me.tagNameCheck,Ce)},Bc=Dt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),zc=function($){return!Bc[vl($)]&&$n(Ae,$)},$o=function($,ie,Ce,Ye){if(A&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!Ce)switch(f.getAttributeType($,ie)){case"TrustedHTML":return L(Ye);case"TrustedScriptURL":return T(Ye)}return Ye},$f=function($,ie,Ce,Ye){try{Ce?$.setAttributeNS(Ce,ie,Ye):$.setAttribute(ie,Ye),$i($)?Yr($):B4(t.removed)}catch{hn(ie,$)}},Os=function($){Mr(H.beforeSanitizeAttributes,$,null);const ie=$.attributes;if(!ie||$i($))return;pe=Dc(H.uponSanitizeAttribute,pe,Oe,We);const Ce={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:pe,forceKeepAttr:void 0};let Ye=ie.length;const nt=It($.nodeName);for(;Ye--;){const lt=ie[Ye],jt=lt.name,Wt=lt.namespaceURI,yn=lt.value,bn=It(jt),Wi=yn;let Jt=jt==="value"?Wi:nZ(Wi);if(Ce.attrName=bn,Ce.attrValue=Jt,Ce.keepAttr=!0,Ce.forceKeepAttr=void 0,Mr(H.uponSanitizeAttribute,$,Ce),Jt=Ce.attrValue,Je&&(bn==="id"||bn==="name")&&U4(Jt,ce)!==0&&(hn(jt,$,lt),Jt=ce+Jt),B&&$n(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Jt)){hn(jt,$,lt);continue}if(bn==="attributename"&&z4(Jt,"href")){hn(jt,$,lt);continue}if(!Ce.forceKeepAttr){if(!Ce.keepAttr){hn(jt,$,lt);continue}if(!qe&&$n(kZ,Jt)){hn(jt,$,lt);continue}if(F&&(Jt=Aa(Jt)),!Fc(nt,bn,Jt)){hn(jt,$,lt);continue}Jt=$o(nt,bn,Wt,Jt),Jt!==Wi&&$f($,jt,Wt,Jt)}}Mr(H.afterSanitizeAttributes,$,null)},Ia=function($){let ie=null;const Ce=Oc($);for(Mr(H.beforeSanitizeShadowDOM,$,null);ie=Ce.nextNode();)if(Mr(H.uponSanitizeShadowNode,ie,null),Pc(ie,$),Os(ie),Ir(ie.content)&&Ia(ie.content),w(ie)===yr.element){const Ye=b(ie);Ir(Ye)&&(Ho(Ye),Ia(Ye))}Mr(H.afterSanitizeShadowDOM,$,null)},Ho=function($){const ie=[{node:$,shadow:null}];for(;ie.length>0;){const Ce=ie.pop();if(Ce.shadow){Ia(Ce.shadow);continue}const Ye=Ce.node,lt=w(Ye)===yr.element,jt=v(Ye);if(jt)for(let Wt=jt.length-1;Wt>=0;--Wt)ie.push({node:jt[Wt],shadow:null});if(lt){const Wt=E?E(Ye):null;if(typeof Wt=="string"&&It(Wt)==="template"){const yn=Ye.content;Ir(yn)&&ie.push({node:yn,shadow:null})}}if(lt){const Wt=b(Ye);Ir(Wt)&&ie.push({node:null,shadow:Wt},{node:Wt,shadow:null})}}};return t.sanitize=function(De){let $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ie=null,Ce=null,Ye=null,nt=null;if(xe=!De,xe&&(De="<!-->"),typeof De!="string"&&!Ra(De)&&(De=oZ(De),typeof De!="string"))throw Yi("dirty is not a string, aborting");if(!t.isSupported)return De;re?(be=_e,pe=We):Rr($),(H.uponSanitizeElement.length>0||H.uponSanitizeAttribute.length>0)&&(be=vr(be)),H.uponSanitizeAttribute.length>0&&(pe=vr(pe)),t.removed=[];const lt=it&&typeof De!="string"&&Ra(De);if(lt){Uf(De);const yn=C(De);if(typeof yn=="string"){const bn=It(yn);if(!be[bn]||ee[bn])throw On(De),Yi("root node is forbidden and cannot be sanitized in-place")}if($i(De))throw On(De),Yi("root node is clobbered and cannot be sanitized in-place");try{Ho(De)}catch(bn){throw On(De),bn}}else if(Ra(De))ie=Ls("<!---->"),Ce=ie.ownerDocument.importNode(De,!0),Ce.nodeType===yr.element&&Ce.nodeName==="BODY"||Ce.nodeName==="HTML"?ie=Ce:ie.appendChild(Ce),Ho(Ce);else{if(!je&&!F&&!W&&De.indexOf("<")===-1)return A&&ct?L(De):De;if(ie=Ls(De),!ie)return je?null:ct?j:""}ie&&Ne&&Yr(ie.firstChild);const jt=lt?De:ie;try{const yn=Oc(jt);for(;Ye=yn.nextNode();)Pc(Ye,jt),Os(Ye),Ir(Ye.content)&&Ia(Ye.content)}catch(yn){throw lt&&(On(De),es(t.removed,bn=>{bn.element&&Ms(bn.element)})),yn}if(lt)return es(t.removed,yn=>{yn.element&&Ms(yn.element)}),F&&zo(De),De;if(je){if(F&&zo(ie),He)for(nt=V.call(ie.ownerDocument);ie.firstChild;)nt.appendChild(ie.firstChild);else nt=ie;return(pe.shadowroot||pe.shadowrootmode)&&(nt=I.call(r,nt,!0)),nt}let Wt=W?ie.outerHTML:ie.innerHTML;return W&&be["!doctype"]&&ie.ownerDocument&&ie.ownerDocument.doctype&&ie.ownerDocument.doctype.name&&$n(yZ,ie.ownerDocument.doctype.name)&&(Wt="<!DOCTYPE "+ie.ownerDocument.doctype.name+`>
105
- `+Wt),F&&(Wt=Aa(Wt)),A&&ct?L(Wt):Wt},t.setConfig=function(){let De=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Rr(De),re=!0,_e=be,We=pe},t.clearConfig=function(){Kr=null,re=!1,_e=null,We=null,A=D,j=""},t.isValidAttribute=function(De,$,ie){Kr||Rr({});const Ce=It(De),Ye=It($);return Fc(Ce,Ye,ie)},t.addHook=function(De,$){typeof $=="function"&&lr(H,De)&&sl(H[De],$)},t.removeHook=function(De,$){if(lr(H,De)){if($!==void 0){const ie=eZ(H[De],$);return ie===-1?void 0:tZ(H[De],ie,1)[0]}return B4(H[De])}},t.removeHooks=function(De){lr(H,De)&&(H[De]=[])},t.removeAllHooks=function(){H=Q4()},t}var NZ=M3();let cy=null;function CZ(){return cy||(cy=O5(()=>import("./mermaid.core-BWRDK01d.js").then(e=>e.ca),[]).then(function(e){const t=e.default||e;return t.initialize({startOnLoad:!1,securityLevel:"strict",theme:"default",flowchart:{curve:"basis"},suppressErrorRendering:!0}),t})),cy}function Z4(){return typeof document>"u"?!1:document.documentElement.classList.contains("dark")}let J4=0;function jZ(){return J4+=1,"pave-canvas-"+J4}function TZ({source:e}){const t=h.useRef(null),n=h.useRef(jZ()),[r,a]=h.useState(null),[i,s]=h.useState(Z4());return h.useEffect(function(){if(typeof window>"u")return;const l=new MutationObserver(function(){const c=Z4();s(function(u){return u!==c?c:u})});return l.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),function(){l.disconnect()}},[]),h.useEffect(function(){let l=!1;return a(null),CZ().then(function(c){l||(c.initialize({startOnLoad:!1,securityLevel:"strict",theme:i?"dark":"default",flowchart:{curve:"basis"},suppressErrorRendering:!0}),c.render(n.current,e).then(function(u){if(!l&&t.current){let d=u.svg;d=d.replace(/<svg([^>]*)\sstyle="[^"]*max-width:[^";]*;?[^"]*"/i,"<svg$1"),d=d.replace(/(<svg[^>]*)\swidth="[^"]*"/i,"$1"),d=d.replace(/(<svg[^>]*)\sheight="[^"]*"/i,"$1"),d=d.replace(/<svg\b/i,'<svg width="100%" height="100%" preserveAspectRatio="xMidYMid meet"'),t.current.innerHTML=d}}).catch(function(u){l||a(u&&u.message||String(u))}))}).catch(function(c){l||a("Failed to load mermaid: "+(c&&c.message||String(c)))}),function(){l=!0}},[e,i]),r?o.jsxs("div",{className:"text-xs text-red-600 dark:text-red-400 p-2",children:[o.jsx("div",{className:"font-semibold mb-1",children:"Mermaid render error:"}),o.jsx("pre",{className:"whitespace-pre-wrap",children:r}),o.jsxs("details",{className:"mt-2",children:[o.jsx("summary",{className:"cursor-pointer text-gray-600 dark:text-gray-400",children:"Source"}),o.jsx("pre",{className:"mt-1 p-2 bg-gray-100 dark:bg-gray-800 rounded overflow-x-auto",children:e})]})]}):o.jsx("div",{ref:t,className:"mermaid-canvas w-full h-full flex items-center justify-center [&>svg]:max-w-full [&>svg]:max-h-full [&>svg]:w-full [&>svg]:h-auto"})}function AZ({source:e}){const t=h.useMemo(function(){return NZ.sanitize(e,{USE_PROFILES:{svg:!0,svgFilters:!0}})},[e]);return o.jsx("div",{className:"svg-canvas overflow-x-auto",dangerouslySetInnerHTML:{__html:t}})}function RZ({source:e}){return o.jsx("pre",{className:"text-sm p-2 bg-gray-100 dark:bg-gray-800 rounded overflow-x-auto",children:e})}function IZ({canvas:e}){if(!e||!e.type||!e.source)return null;let t=null;return e.type==="mermaid"?t=o.jsx(TZ,{source:e.source}):e.type==="svg"?t=o.jsx(AZ,{source:e.source}):e.type==="katex"?t=o.jsx(RZ,{source:e.source}):t=o.jsxs("pre",{className:"text-xs text-red-600 dark:text-red-400",children:["Unknown canvas type: ",e.type]}),o.jsx("div",{className:"w-full h-full flex items-center justify-center",children:t})}function ej({canvases:e,onClear:t}){const n=Array.isArray(e)?e:[],[r,a]=h.useState(Math.max(0,n.length-1)),[i,s]=h.useState(1),[l,c]=h.useState(!1);h.useEffect(function(){a(function(v){return v>=n.length-2?Math.max(0,n.length-1):Math.min(v,Math.max(0,n.length-1))})},[n.length]),h.useEffect(function(){s(1)},[r]),h.useEffect(function(){if(!l)return;const v=x=>{x.key==="Escape"&&c(!1)};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[l]);const u=h.useCallback(()=>s(v=>Math.min(4,+(v+.25).toFixed(2))),[]),d=h.useCallback(()=>s(v=>Math.max(.5,+(v-.25).toFixed(2))),[]),f=h.useCallback(()=>s(1),[]);if(n.length===0)return o.jsxs("div",{className:"h-full flex flex-col items-center justify-center p-6 text-center",children:[o.jsx("svg",{className:"w-12 h-12 text-gray-300 dark:text-gray-600 mb-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 17V7m0 10a2 2 0 01-2 2H5a2 2 0 01-2-2V7a2 2 0 012-2h2a2 2 0 012 2m0 10a2 2 0 002 2h2a2 2 0 002-2M9 7a2 2 0 012-2h2a2 2 0 012 2m0 10V7m0 10a2 2 0 002 2h2a2 2 0 002-2V7a2 2 0 00-2-2h-2a2 2 0 00-2 2"})}),o.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400 max-w-xs",children:["Ask the agent to draw something here. It can use the ",o.jsx("code",{className:"px-1 bg-gray-200 dark:bg-gray-700 rounded",children:"canvas"})," tool to render Mermaid diagrams, SVG illustrations, or math."]})]});const g=Math.min(Math.max(0,r),n.length-1),p=n[g],m=o.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-1.5 border-b border-gray-200 dark:border-gray-700 text-xs",children:[n.length>1?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{type:"button",onClick:()=>a(Math.max(0,g-1)),disabled:g===0,className:"px-2 py-0.5 rounded text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-40 disabled:cursor-not-allowed",title:"Previous canvas",children:"←"}),o.jsxs("span",{className:"text-gray-500 dark:text-gray-400 tabular-nums",children:[g+1,"/",n.length]}),o.jsx("button",{type:"button",onClick:()=>a(Math.min(n.length-1,g+1)),disabled:g===n.length-1,className:"px-2 py-0.5 rounded text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-40 disabled:cursor-not-allowed",title:"Next canvas",children:"→"})]}):o.jsx("div",{}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{type:"button",onClick:d,disabled:i<=.5,className:"px-1.5 py-0.5 rounded text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-40",title:"Zoom out",children:"−"}),o.jsxs("button",{type:"button",onClick:f,className:"px-1.5 py-0.5 rounded text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 tabular-nums min-w-[3rem]",title:"Reset zoom",children:[Math.round(i*100),"%"]}),o.jsx("button",{type:"button",onClick:u,disabled:i>=4,className:"px-1.5 py-0.5 rounded text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-40",title:"Zoom in",children:"+"}),o.jsx("button",{type:"button",onClick:()=>c(v=>!v),className:"ml-1 px-1.5 py-0.5 rounded text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800",title:l?"Exit fullscreen (Esc)":"Fullscreen",children:l?"⤢":"⛶"}),t?o.jsx("button",{type:"button",onClick:t,className:"ml-1 px-1.5 py-0.5 rounded text-gray-600 dark:text-gray-300 hover:bg-red-50 dark:hover:bg-red-900/30 hover:text-red-600 dark:hover:text-red-400",title:"Clear all canvases (hides them; messages preserved)",children:"✕"}):null]})]}),y=o.jsxs("div",{className:"flex-1 overflow-auto p-3",children:[p.title?o.jsx("div",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200 mb-2",children:p.title}):null,o.jsx("div",{style:{transform:`scale(${i})`,transformOrigin:"top left",width:i===1?"100%":`${100/i}%`},children:o.jsx(IZ,{canvas:p})}),p.caption?o.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400 italic",children:p.caption}):null]});return l?o.jsxs("div",{className:"fixed inset-0 z-50 bg-white dark:bg-gray-900 flex flex-col",children:[m,y]}):o.jsxs("div",{className:"h-full flex flex-col",children:[m,y]})}function MZ(e){return e?e.includes("/")?e.split("/").slice(1).join("/")||null:e:null}function LZ(e,t){const n=MZ(e);return{modelID:n||t||null,activeModelID:n,conversationModelID:t}}const K1={"github-copilot":"GitHub Copilot",anthropic:"Anthropic",openai:"OpenAI",google:"Google",other:"Other"};function Y1(e){return e==="recommended"?" — Recommended":e==="fast"?" — Fast":e==="premium"?" — Premium":""}function X1(e){const t={};return e.forEach(n=>{const r=n.provider||"other";t[r]||(t[r]=[]),t[r].push(n)}),t}const tj={"claude-opus-4.5":2e5,"claude-opus-4.6":2e5,"claude-sonnet-4":2e5,"claude-sonnet-4.5":2e5,"claude-sonnet-4.6":2e5,"gpt-4o":128e3,"gpt-4.1":1047576,"gpt-4-turbo":128e3,"gpt-4":8192,o1:2e5,"o1-mini":128e3,o3:2e5,"o3-mini":2e5},OZ=128e3;function uy(e){const[t,n]=h.useState(e),r=h.useRef(e),a=h.useRef(0),i=h.useRef(0);return h.useEffect(()=>{if(e===r.current)return;a.current=0,r.current=t;const s=400,l=t,c=e,u=d=>{a.current||(a.current=d);const f=d-a.current,g=Math.min(f/s,1),p=1-Math.pow(1-g,3);n(Math.round(l+(c-l)*p)),g<1?i.current=requestAnimationFrame(u):n(c)};return i.current=requestAnimationFrame(u),()=>cancelAnimationFrame(i.current)},[e]),t}function DZ({messages:e,isBusy:t,activeModel:n,sessionModel:r,isPrivateMode:a,registryEntries:i}){var V,X;var{t:s}=Tt();const l=e.filter(I=>{var H;return((H=I.info)==null?void 0:H.role)==="user"}).length,c=e.filter(I=>{var H;return((H=I.info)==null?void 0:H.role)==="assistant"}).length;let u=0,d=0,f=0,g=null,p=null;for(let I=e.length-1;I>=0;I--){const H=e[I];if(((V=H.info)==null?void 0:V.role)==="assistant"&&((X=H.info)==null?void 0:X.mode)!=="compaction"){const ue=H.info.tokens;if(ue&&(ue.input||ue.output)){!g&&H.info.modelID&&(g=H.info.modelID),u=ue.lastInput??ue.input??0,d=ue.lastOutput??ue.output??0,f=ue.lastReasoning??ue.reasoning??0,H.info.contextLimit&&(p=H.info.contextLimit);break}}}const m=uy(u),y=uy(d),v=uy(f),x=m+y+v,b=u+d+f>0;let k=n;typeof r=="string"&&r?k=r:r&&r.providerID&&r.modelID&&(k=r.providerID+"/"+r.modelID);let{modelID:S,activeModelID:E}=LZ(k,g),_=null;if(a){S="privacy",E="privacy";let I=null;typeof r=="string"&&r?I=r.includes("/")?r.split("/").pop():r:r&&r.modelID&&(I=r.modelID),_=I||(n?String(n).split("/").pop():null)}else g&&E&&g!==E&&(_=g);const w=h.useMemo(()=>{const I={};if(i&&i.length>0){for(const H of i)if(H.limit&&typeof H.limit.context=="number"&&H.limit.context>0){I[H.key]=H.limit.context;const ue=H.key.includes("/")?H.key.split("/").pop():H.key;ue&&(I[ue]=H.limit.context)}}return I},[i]),C=g||S,j=!!(g&&E&&g!==E)&&(w[k]||w[S]||tj[S])||p||w[C]||w[k]||tj[C]||OZ,D=Math.min(100,Math.round(m/j*100));let P="bg-green-500";D>=90?P="bg-red-500":D>=75?P="bg-orange-500":D>=50&&(P="bg-yellow-500");const q="border-gray-200 dark:border-gray-800",O="text-gray-500 dark:text-gray-400",L="text-gray-500 dark:text-gray-400",T="text-gray-700 dark:text-gray-300",M="border-gray-100 dark:border-gray-800";return o.jsxs("div",{className:`p-4 border-t ${q}`,children:[o.jsx("p",{className:`text-xs ${O} uppercase tracking-wide font-medium mb-3`,children:s("token_usage.session_info")}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:`text-xs ${L}`,children:s("token_usage.messages")}),o.jsx("span",{className:`text-xs font-medium ${T}`,children:l+c})]}),S&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:`text-xs ${L}`,children:s("token_usage.model")}),o.jsx("span",{className:`text-xs font-medium ${T} truncate ml-2 max-w-[140px]`,children:nj(S)})]}),_&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:`text-xs ${L}`,children:s("token_usage.originally")}),o.jsx("span",{className:`text-xs ${L} truncate ml-2 max-w-[140px]`,children:nj(_)})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:`text-xs ${L}`,children:s("token_usage.status")}),o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${t?"bg-accent-400 animate-pulse":"bg-green-500"}`}),o.jsx("span",{className:`text-xs font-medium ${T}`,children:s(t?"token_usage.generating":"token_usage.idle")})]})]}),b?o.jsx(o.Fragment,{children:o.jsxs("div",{className:`border-t ${M} pt-2 mt-2`,children:[o.jsxs("div",{className:"mb-2",children:[o.jsxs("div",{className:"flex items-center justify-between mb-1",children:[o.jsx("span",{className:`text-xs ${L}`,children:"Context"}),o.jsxs("span",{className:`text-xs ${L}`,children:[D,"% of ",(j/1e3).toFixed(0),"k"]})]}),o.jsx("div",{className:"h-1.5 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden",children:o.jsx("div",{className:`h-full ${P} transition-all duration-300`,style:{width:`${D}%`}})})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:`text-xs ${L}`,children:"Input"}),o.jsx("span",{className:`text-xs font-medium ${T} tabular-nums`,children:m.toLocaleString()})]}),o.jsxs("div",{className:"flex items-center justify-between mt-1",children:[o.jsx("span",{className:`text-xs ${L}`,children:"Output"}),o.jsx("span",{className:`text-xs font-medium ${T} tabular-nums`,children:y.toLocaleString()})]}),f>0&&o.jsxs("div",{className:"flex items-center justify-between mt-1",children:[o.jsx("span",{className:`text-xs ${L}`,children:"Reasoning"}),o.jsx("span",{className:`text-xs font-medium ${T} tabular-nums`,children:v.toLocaleString()})]}),o.jsxs("div",{className:`flex items-center justify-between mt-1 pt-1 border-t ${M}`,children:[o.jsx("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Total"}),o.jsx("span",{className:"text-xs font-semibold text-gray-900 dark:text-gray-100 tabular-nums",children:x.toLocaleString()})]})]})}):o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:`text-xs ${L}`,children:"Tokens"}),o.jsx("span",{className:`text-xs ${L}`,children:"--"})]})]})]})}function nj(e){return e?{"claude-opus-4.5":"Claude Opus 4.5","claude-opus-4.6":"Claude Opus 4.6","claude-sonnet-4":"Claude Sonnet 4","claude-sonnet-4.5":"Claude Sonnet 4.5","claude-sonnet-4.6":"Claude Sonnet 4.6","gpt-4o":"GPT-4o","gpt-4.1":"GPT-4.1","gpt-4-turbo":"GPT-4 Turbo","gpt-4":"GPT-4"}[e]||e:""}function PZ({sessionModel:e,activeModel:t,registryEntries:n,onModelChange:r,disabled:a,lockedReason:i}){const{t:s}=Tt(),[l,c]=h.useState(!1),u=h.useRef(null),[d,f]=h.useState(-1),g=h.useRef([]);h.useEffect(()=>{if(!l)return;function b(k){u.current&&!u.current.contains(k.target)&&c(!1)}return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[l]),h.useEffect(()=>{if(!l)return;function b(k){if(k.key==="Escape"){c(!1);return}k.key!=="ArrowDown"&&k.key!=="ArrowUp"&&k.key!=="Home"&&k.key!=="End"||(k.preventDefault(),f(S=>{const E=g.current.length;if(!E)return S;const _=typeof S=="number"?S:-1;let w=_;return k.key==="ArrowDown"?w=_<E-1?_+1:0:k.key==="ArrowUp"?w=_>0?_-1:E-1:k.key==="Home"?w=0:k.key==="End"&&(w=E-1),g.current[w]&&g.current[w].focus(),w}))}return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[l]);const p=typeof e=="string"&&e.trim()?e.trim():null,m=p!=null,y=Array.isArray(n)?n:[],v=FZ(p,t,y,s),x=h.useCallback(b=>{r(b===t||p&&p===b?null:b),c(!1)},[p,t,r]);return g.current.length=y.length,o.jsxs("div",{className:"relative",ref:u,children:[o.jsxs("button",{type:"button",onClick:()=>c(b=>!b),disabled:a,className:"flex items-center gap-1.5 px-2 py-1 text-xs font-medium rounded-md transition-colors "+(m||v?"bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400 hover:bg-primary-200 dark:hover:bg-primary-900/50":"text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800")+(a?" opacity-50 cursor-not-allowed":" cursor-pointer"),title:i||s("model_selector.title"),"aria-label":i||s("model_selector.title"),"aria-haspopup":"menu","aria-expanded":l,children:[i?o.jsxs("svg",{className:"w-3.5 h-3.5 flex-shrink-0 text-emerald-600 dark:text-emerald-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 11c.667 0 2 .4 2 2v3a2 2 0 11-4 0v-3c0-1.6 1.333-2 2-2zM6 11V8a6 6 0 1112 0v3"}),o.jsx("rect",{x:"5",y:"11",width:"14",height:"10",rx:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):o.jsx("svg",{className:"w-3.5 h-3.5 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),o.jsx("span",{className:"max-w-[120px] truncate",children:v}),o.jsx("svg",{className:`w-3 h-3 transition-transform ${l?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),l&&o.jsxs("div",{className:"absolute left-0 sm:left-auto sm:right-0 top-full mt-1 w-64 max-w-[calc(100vw-1.5rem)] max-h-72 overflow-y-auto bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-50",role:"menu","aria-label":s("model_selector.list_label"),children:[y.length===0&&o.jsx("div",{className:"px-3 py-2 text-xs text-gray-400 dark:text-gray-500",children:s("model_selector.no_models")}),y.map((b,k)=>{const S=p===b.key,E=!!t&&(b.key===t||b.target===t||b.url===t),_=b.builtin?b.key:b.displayName||b.key;return o.jsxs("button",{type:"button",ref:w=>{g.current[k]=w},tabIndex:d===k?0:-1,role:"menuitemradio","aria-checked":S||!m&&E,onClick:()=>x(b.key),className:"w-full text-left px-3 py-2 text-xs transition-colors "+(S||!m&&E?"bg-primary-50 dark:bg-primary-900/20 text-primary-700 dark:text-primary-400":"text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800"),children:[o.jsx("span",{className:"font-medium",children:_}),E&&o.jsxs("span",{className:"ml-1 text-gray-400 dark:text-gray-500",children:["(",s("model_selector.default_label"),")"]})]},b.key)})]})]})}function FZ(e,t,n,r){return e?rj(e,n):t?rj(t,n):r("model_selector.default_label")}function BZ(e,t){if(!e||!Array.isArray(t))return null;for(let n=0;n<t.length;n++){const r=t[n];if(r&&(r.key===e||r.target===e||r.url===e))return r}return null}function rj(e,t){if(!e)return"";const n=BZ(e,t);return n?n.builtin?n.key:n.displayName||n.key:typeof e=="string"&&e.includes("/")?e.split("/").slice(1).join("/"):e}function zZ(e){e.sessionId;var t=e.disabledSkills,n=e.onToggle,r=e.onResetToDefaults,a=e.t,i=e.disabled,s=h.useState(!1),l=s[0],c=s[1],u=h.useState([]),d=u[0],f=u[1],g=h.useState(!1),p=g[0],m=g[1],y=h.useRef(null),v=t instanceof Array?new Set(t):new Set,x=h.useCallback(async function(){m(!0);try{var _=await Hv();f(_||[])}catch{}finally{m(!1)}},[]);h.useEffect(function(){x()},[x]),h.useEffect(function(){if(!l)return;function _(w){y.current&&!y.current.contains(w.target)&&c(!1)}return document.addEventListener("mousedown",_),function(){document.removeEventListener("mousedown",_)}},[l]);var b=v.size,k=v.has("agent"),S=k?b-1:b,E=Math.max(0,d.length-S+(k?0:1));return o.jsxs("div",{className:"relative",ref:y,children:[o.jsxs("button",{onClick:function(){c(!l)},disabled:i,className:"p-1.5 rounded-lg transition-colors "+(b>0?"bg-amber-500/10 text-amber-600 dark:text-amber-400":"text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800")+(i?" opacity-50 cursor-not-allowed":""),title:a("skills.toggle_title"),"aria-label":a("skills.toggle_title"),children:[o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11 4a2 2 0 114 0v1a1 1 0 001 1h3a1 1 0 011 1v3a1 1 0 01-1 1h-1a2 2 0 100 4h1a1 1 0 011 1v3a1 1 0 01-1 1h-3a1 1 0 01-1-1v-1a2 2 0 10-4 0v1a1 1 0 01-1 1H7a1 1 0 01-1-1v-3a1 1 0 00-1-1H4a2 2 0 110-4h1a1 1 0 001-1V7a1 1 0 011-1h3a1 1 0 001-1V4z"})}),E>0&&o.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 text-[9px] font-bold flex items-center justify-center bg-primary-500 text-white rounded-full",children:E})]}),l&&o.jsxs("div",{className:"absolute left-0 sm:left-auto sm:right-0 top-full mt-1 w-64 max-w-[calc(100vw-1.5rem)] bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-50 max-h-80 overflow-y-auto",children:[o.jsxs("div",{className:"px-3 py-2 border-b border-gray-100 dark:border-gray-800",children:[o.jsx("p",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300",children:a("skills.toggle_header")}),o.jsx("p",{className:"text-[10px] text-gray-400 dark:text-gray-500 mt-0.5",children:a("skills.toggle_hint")})]}),p?o.jsx("div",{className:"flex items-center justify-center py-4",children:o.jsx("div",{className:"w-5 h-5 border-2 border-primary-500 border-t-transparent rounded-full animate-spin"})}):d.length===0?o.jsx("div",{className:"px-3 py-4 text-center",children:o.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:a("skills.no_skills")})}):o.jsx("div",{className:"py-1",children:d.map(function(_){var w=v.has(_.name);return o.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[o.jsx("span",{className:"text-xs text-gray-700 dark:text-gray-300 truncate flex-1 mr-2",children:_.name}),o.jsx("button",{onClick:function(){n(_.name,w)},className:"relative inline-flex h-5 w-9 items-center rounded-full transition-colors flex-shrink-0 "+(w?"bg-gray-300 dark:bg-gray-600":"bg-primary-500"),role:"switch","aria-checked":!w,children:o.jsx("span",{className:"inline-block h-3.5 w-3.5 transform rounded-full bg-white transition-transform "+(w?"translate-x-1":"translate-x-5")})})]},_.name)})}),o.jsx("div",{className:"px-3 py-1.5 border-t border-gray-100 dark:border-gray-800",children:o.jsx("p",{className:"text-[10px] font-semibold text-gray-400 dark:text-gray-500 uppercase tracking-wide",children:a("skills.builtin_tools")})}),o.jsx("div",{className:"py-1",children:o.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[o.jsx("span",{className:"text-xs text-gray-700 dark:text-gray-300 truncate flex-1 mr-2",children:a("skills.agent_comm")}),o.jsx("button",{onClick:function(){n("agent",k)},className:"relative inline-flex h-5 w-9 items-center rounded-full transition-colors flex-shrink-0 "+(k?"bg-gray-300 dark:bg-gray-600":"bg-primary-500"),role:"switch","aria-checked":!k,children:o.jsx("span",{className:"inline-block h-3.5 w-3.5 transform rounded-full bg-white transition-transform "+(k?"translate-x-1":"translate-x-5")})})]})}),r&&o.jsx("div",{className:"px-3 py-1.5 border-t border-gray-100 dark:border-gray-800",children:o.jsx("button",{onClick:r,className:"w-full text-xs font-medium text-gray-500 dark:text-gray-400 hover:text-primary-600 dark:hover:text-primary-400 hover:underline transition-colors text-center",children:a("skills.reset_to_defaults")})})]})]})}function UZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.25 6.087c0-.355.186-.676.401-.959.221-.29.349-.634.349-1.003 0-1.036-1.007-1.875-2.25-1.875S10.5 3.089 10.5 4.125c0 .369.128.713.349 1.003.215.283.401.604.401.959V6a.75.75 0 01-.75.75H7.5a.75.75 0 00-.75.75v2.25c0 .414-.336.75-.75.75S5.25 10.164 5.25 9.75V9A2.25 2.25 0 003 11.25v.75a.75.75 0 00.75.75h2.25c.414 0 .75.336.75.75s-.336.75-.75.75H3.75a.75.75 0 00-.75.75v.75A2.25 2.25 0 005.25 18h1.5a.75.75 0 01.75.75v.75c0 .414.336.75.75.75h6a.75.75 0 00.75-.75v-.75a.75.75 0 01.75-.75h1.5A2.25 2.25 0 0019.5 15.75v-.75a.75.75 0 00-.75-.75h-2.25a.75.75 0 01-.75-.75c0-.414.336-.75.75-.75h2.25a.75.75 0 00.75-.75v-.75A2.25 2.25 0 0017.25 9h-3a.75.75 0 01-.75-.75V6.087z"})})}function $Z({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M20 18h-2V9.25L12 13 6 9.25V18H4V6h1.2l6.8 4.25L18.8 6H20m0-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2z"})})}function HZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M7.71 3.5l-5.71 9.94 3.48 6.06h5.44L4.07 8.56 7.71 3.5zm1.42 0L15.84 15h-6.71L2.42 3.5h6.71zm.71 12h11.46l-3.48 6.06H6.36l3.48-6.06zm.71-1L16.84 3.5l5.71 9.94-3.48.06H10.55z"})})}function qZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M20.317 4.37a19.791 19.791 0 00-4.885-1.515.074.074 0 00-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 00-5.487 0 12.64 12.64 0 00-.617-1.25.077.077 0 00-.079-.037A19.736 19.736 0 003.677 4.37a.07.07 0 00-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 00.031.057 19.9 19.9 0 005.993 3.03.078.078 0 00.084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 00-.041-.106 13.107 13.107 0 01-1.872-.892.077.077 0 01-.008-.128 10.2 10.2 0 00.372-.292.074.074 0 01.077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 01.078.01c.12.098.246.198.373.292a.077.077 0 01-.006.127 12.299 12.299 0 01-1.873.892.077.077 0 00-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 00.084.028 19.839 19.839 0 006.002-3.03.077.077 0 00.032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 00-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"})})}function WZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"})})}function VZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M3 6l3.5 12h2l2.5-8 2.5 8h2L19 6h-2.5l-2.25 8L12 6h-2l-2.25 8L5.5 6H3z"})})}function GZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M5 3a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2V5a2 2 0 00-2-2H5zm11.293 6.707l-5.5 5.5a1 1 0 01-1.414 0l-2.5-2.5a1 1 0 111.414-1.414L10.086 13.1l4.793-4.793a1 1 0 111.414 1.4z"})})}function KZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M4 18V6h3.2l2.8 7 2.8-7H16v12h-2.4V9.6L10.6 18H9.4L6.4 9.6V18H4z"})})}function YZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 15.5v-5l-3 3v-4l3-3v-3l4 4-4 4v4z"})})}function XZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}function QZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"})})}function ZZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M6 2l6 3.75L6 9.5.002 5.75 6 2zm12 0l6 3.75-6 3.75-5.998-3.75L18 2zM.002 13.25L6 9.5l6 3.75L6 17 .002 13.25zm17.998-3.75l6 3.75L18 17l-5.998-3.75L18 9.5zM6 18.25l6-3.75 6 3.75-6 3.75-6-3.75z"})})}function JZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v12m-3-2.818l.879.659c1.171.879 3.07.879 4.242 0 1.172-.879 1.172-2.303 0-3.182C13.536 12.219 12.768 12 12 12c-.725 0-1.45-.22-2.003-.659-1.106-.879-1.106-2.303 0-3.182s2.9-.879 4.006 0l.415.33M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}function eJ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 7.5v11.25m-18 0A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75m-18 0v-7.5A2.25 2.25 0 015.25 9h13.5A2.25 2.25 0 0121 11.25v7.5"})})}function tJ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}const aj={gmail:$Z,gdrive:HZ,discord:qZ,whatsapp:WZ,wrike:VZ,gtasks:GZ,mailchimp:KZ,bamboohr:YZ,pandadoc:XZ,exa:QZ,dropbox:ZZ,freshbooks:JZ,gcal:eJ,docx2md:tJ};function nJ(e){return Object.prototype.hasOwnProperty.call(aj,e)?aj[e]:UZ}const ij={gmail:"#EA4335",gdrive:"#4285F4",discord:"#5865F2",whatsapp:"#25D366",wrike:"#08CF65",gtasks:"#4285F4",mailchimp:"#FFE01B",bamboohr:"#73C41D",pandadoc:"#4ABB5A",exa:"#6366F1",dropbox:"#0061FF",freshbooks:"#00B7E3",gcal:"#4285F4",docx2md:"#6B7280"};function rJ({installed:e,configured:t,t:n}){return e?t?o.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400",children:[o.jsx("svg",{className:"w-3 h-3 mr-1",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),n("skills.configured")]}):o.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400",children:[o.jsx("svg",{className:"w-3 h-3 mr-1",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),n("skills.needs_setup")]}):o.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400",children:n("skills.not_installed")})}function aJ({skill:e,onClose:t,onSaved:n}){var{t:r}=Tt(),a=bc(),[i,s]=h.useState({}),[l,c]=h.useState(!0),[u,d]=h.useState(!1),[f,g]=h.useState(null),[p,m]=h.useState(!1),[y,v]=h.useState(null);h.useEffect(function(){var A=!1;async function j(){try{var D=await rP(e.name);if(A)return;v(D);for(var P=Object.create(null),q=Object.keys(D.tokens||{}),O=0;O<q.length;O++){var L=q[O],T=D.tokens[L]||{},M=T.env||L;P[M]=""}s(P),c(!1)}catch(U){A||(g(U.message),c(!1))}}return j(),function(){A=!0}},[e.name]);var x=h.useMemo(function(){if(!y||!y.tokens)return null;if(y.oauth&&y.oauth.broker){var A=!!y.oauth.connected,j=y.oauth.provider||"";return{provider:j?j.charAt(0).toUpperCase()+j.slice(1):"OAuth",brokered:!0,canConnect:!A,refreshConfigured:A,clientIdConfigured:!0,clientSecretConfigured:!0}}for(var D=Object.keys(y.tokens),P=0;P<D.length;P++){var q=y.tokens[D[P]]||{};if(q.description&&q.description.includes("OAuth")){for(var O=null,L=null,T=null,M=Object.entries(y.tokens),U=0;U<M.length;U++){var Y=M[U][0];Y.includes("REFRESH_TOKEN")&&(O=Y),(Y.includes("CLIENT_ID")||Y.includes("APP_KEY"))&&(L=Y),(Y.includes("CLIENT_SECRET")||Y.includes("APP_SECRET"))&&(T=Y)}if(O&&L){var R=y.tokens[O]&&y.tokens[O].configured,V=y.tokens[L]&&y.tokens[L].configured,X=T&&y.tokens[T]&&y.tokens[T].configured,I="OAuth";return e.name==="gmail"||e.name==="gdrive"||e.name==="gcal"||e.name==="gtasks"?I="Google":e.name==="dropbox"?I="Dropbox":e.name==="freshbooks"&&(I="FreshBooks"),{provider:I,canConnect:V&&X&&!R,refreshConfigured:R,clientIdConfigured:V,clientSecretConfigured:X}}}}return null},[y,e.name]),b=h.useCallback(async function(){g(null),m(!0);try{if(x&&x.brokered){let ue=function(){C.current&&(clearInterval(C.current),C.current=null)};var A=await fP(e.name),j=600,D=700,P=(window.screen.width-j)/2,q=(window.screen.height-D)/2,O=window.open(A.authorizeUrl,"oauth_popup","width="+j+",height="+D+",left="+P+",top="+q+",scrollbars=yes");if(!O){g("Popup blocked. Please allow popups or visit: "+A.authorizeUrl),m(!1);return}var L=A.flowId,T=0,M=0;C.current=setInterval(async function(){T+=1500;try{var J=await gP(e.name,L);if(J&&J.connected){ue();try{O.close()}catch{}m(!1),n();return}}catch(ge){ue(),g(ge.message),m(!1);return}if(O.closed&&(M||(M=T),T-M>9e3)){ue(),m(!1),n();return}T>3e5&&(ue(),m(!1),g("Connection timed out. Please try again."))},1500);return}var U=await dP(e.name),Y=600,R=700,V=(window.screen.width-Y)/2,X=(window.screen.height-R)/2,I=window.open(U.authorizeUrl,"oauth_popup","width="+Y+",height="+R+",left="+V+",top="+X+",scrollbars=yes");if(I)var H=setInterval(function(){I.closed&&(clearInterval(H),m(!1),n())},500);else g("Popup blocked. Please allow popups or visit: "+U.authorizeUrl),m(!1)}catch(ue){g(ue.message),m(!1)}},[e.name,n,x]),k=h.useCallback(async function(){g(null),d(!0);try{for(var A=Object.create(null),j=Object.keys(i),D=0;D<j.length;D++){var P=j[D];i[P]&&i[P].trim()&&(A[P]=i[P].trim())}if(Object.keys(A).length===0){g(r("skills.enter_token")),d(!1);return}await oP(e.name,A),n()}catch(q){g(q.message)}finally{d(!1)}},[i,e.name,n,r]),S=h.useCallback(async function(){if(await a({title:r("skills.clear_title"),message:r("skills.clear_confirm",{skill:e.name}),destructive:!0})){g(null),d(!0);try{await lP(e.name),n()}catch(A){g(A.message)}finally{d(!1)}}},[e.name,n,a,r]),E=h.useCallback(function(A,j){s(function(D){var P=Object.assign(Object.create(null),D);return P[A]=j,P})},[]),_=y&&!(y.oauth&&y.oauth.broker)?Object.entries(y.tokens||{}).map(function(A){var j=A[0],D=A[1],P=D&&D.env||j;return{name:j,env:P,description:D.description,configured:D.configured,maskedValue:D.maskedValue}}):[],w=h.useRef(null);h.useEffect(function(){function A(j){j.key==="Escape"&&t()}return document.addEventListener("keydown",A),w.current&&w.current.focus(),function(){document.removeEventListener("keydown",A)}},[t]);var C=h.useRef(null);return h.useEffect(function(){return function(){C.current&&(clearInterval(C.current),C.current=null)}},[]),o.jsx("div",{ref:w,tabIndex:-1,className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:t,role:"dialog","aria-modal":"true","aria-label":r("skills.configure_skill",{skill:e.name}),children:o.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-xl shadow-2xl w-full max-w-lg mx-4 p-6",onClick:function(A){A.stopPropagation()},children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:r("skills.configure_skill",{skill:e.name})}),o.jsx("button",{onClick:t,className:"p-1 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-400","aria-label":r("skills.close_credential_editor"),children:o.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),l&&o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx("div",{className:"w-6 h-6 border-2 border-primary-500 border-t-transparent rounded-full animate-spin"})}),!l&&_.length>0&&o.jsx("div",{className:"space-y-3 mb-4",children:_.map(function(A){return o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[A.env,A.configured&&o.jsxs("span",{className:"ml-2 text-xs text-green-600 dark:text-green-400",children:["(",r("skills.current_value",{value:A.maskedValue}),")"]})]}),A.description&&o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:A.description}),o.jsx("input",{type:"password",placeholder:A.configured?r("skills.leave_blank"):r("skills.enter_value"),value:i[A.env]||"",onChange:function(j){E(A.env,j.target.value)},className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 placeholder-gray-400"})]},A.env)})}),!l&&x&&o.jsx("div",{className:"mb-4 p-4 bg-gray-50 dark:bg-gray-800/50 rounded-lg border border-gray-200 dark:border-gray-700",children:x.canConnect?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:r("skills.oauth_connect_hint",{provider:x.provider})}),o.jsx("button",{onClick:b,disabled:p||u,className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 bg-primary-500 hover:bg-primary-600 text-white font-medium rounded-lg disabled:opacity-50 transition-colors",children:p?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),r("skills.oauth_connecting")]}):o.jsxs(o.Fragment,{children:[o.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),r("skills.oauth_connect",{provider:x.provider})]})})]}):x.refreshConfigured?o.jsxs("div",{className:"space-y-3",children:[o.jsxs("p",{className:"text-sm text-green-600 dark:text-green-400 flex items-center gap-2",children:[o.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),r("skills.oauth_connected",{provider:x.provider})]}),o.jsx("button",{onClick:S,disabled:u,className:"text-sm text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 disabled:opacity-50",children:r("skills.oauth_disconnect",{provider:x.provider})})]}):o.jsx("p",{className:"text-sm text-amber-600 dark:text-amber-400",children:r("skills.oauth_needs_credentials",{provider:x.provider})})}),!l&&!f&&_.length===0&&!x&&o.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 py-4",children:r("skills.no_credentials_needed")}),f&&o.jsx("p",{className:"text-sm text-red-600 dark:text-red-400 mb-3",children:f}),!l&&_.length>0&&o.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-gray-200 dark:border-gray-700",children:[o.jsx("button",{onClick:S,disabled:u,className:"text-sm text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 disabled:opacity-50",children:r("skills.clear_all")}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("button",{onClick:t,className:"px-3 py-1.5 text-sm text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg",children:r("skills.cancel")}),o.jsx("button",{onClick:k,disabled:u,className:"px-4 py-1.5 text-sm font-medium bg-primary-500 hover:bg-primary-600 text-white rounded-lg disabled:opacity-50 transition-colors",children:r(u?"skills.saving":"skills.save")})]})]})]})})}function iJ({skill:e,installed:t,updateInfo:n,updatingSkill:r,onConfigure:a,onInstall:i,onUpdate:s,onUninstall:l,skillDefaultEnabled:c,onToggleDefault:u,t:d}){var f=nJ(e.name),g=Object.prototype.hasOwnProperty.call(ij,e.name)?ij[e.name]:"#6B7280",[p,m]=h.useState(!1),y=r===e.name,v=n&&n.hasUpdate,x=h.useCallback(async function(){m(!0);try{await i(e)}finally{m(!1)}},[e,i]),b=h.useCallback(function(){s&&s(e.name)},[e.name,s]);return o.jsxs("div",{className:"group relative bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-xl p-4 hover:shadow-md dark:hover:shadow-gray-800/50 transition-all flex flex-col",children:[o.jsx("div",{className:"absolute top-0 left-4 right-4 h-0.5 rounded-full",style:{backgroundColor:g}}),o.jsxs("div",{className:"flex items-start gap-3 mt-1 flex-1",children:[o.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center flex-shrink-0",style:{backgroundColor:g+"15"},children:o.jsx(f,{className:"w-5 h-5",style:{color:g}})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[o.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 truncate",children:e.name}),o.jsx(rJ,{installed:t,configured:t&&e.allTokensConfigured,t:d}),t&&v&&o.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400",children:[o.jsx("svg",{className:"w-3 h-3 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"v",n.latestVersion]}),t&&n&&!v&&o.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400",children:d("skills.up_to_date")})]}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 line-clamp-2",children:e.description||d("skills.no_description")}),e.version&&o.jsxs("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:["v",e.version]})]})]}),o.jsx("div",{className:"mt-auto pt-3 flex items-center gap-2",children:t?o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:function(){a(e)},className:"flex-1 px-3 py-1.5 text-xs font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-lg transition-colors",children:d("skills.configure")}),u&&o.jsxs("button",{onClick:function(){u(e.name,!c)},title:d("skills.default_for_new_sessions"),className:"px-2 py-1.5 text-xs font-medium rounded-lg transition-colors flex items-center gap-1 "+(c?"text-primary-600 dark:text-primary-400 bg-primary-50 dark:bg-primary-900/20 hover:bg-primary-100 dark:hover:bg-primary-900/40":"text-gray-400 dark:text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-800"),children:[o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:c?o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"}):o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),d("skills.default")]}),v&&o.jsx("button",{onClick:b,disabled:y,className:"px-3 py-1.5 text-xs font-medium text-white bg-primary-500 hover:bg-primary-600 rounded-lg transition-colors disabled:opacity-50",children:y?o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx("svg",{className:"w-3 h-3 animate-spin",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),d("skills.updating")]}):d("skills.update")}),l&&o.jsx("button",{onClick:function(){l(e)},title:d("skills.uninstall"),className:"px-2 py-1.5 text-xs font-medium text-gray-400 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors","aria-label":d("skills.uninstall"),children:o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]}):o.jsx("button",{onClick:x,disabled:p,className:"flex-1 px-3 py-1.5 text-xs font-medium text-white bg-primary-500 hover:bg-primary-600 rounded-lg transition-colors disabled:opacity-50",children:p?o.jsxs("span",{className:"flex items-center justify-center gap-1",children:[o.jsx("svg",{className:"w-3 h-3 animate-spin",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),d("skills.installing")]}):d("skills.install")})})]})}function sJ({onBack:e}){var{t}=Tt(),[n,r]=h.useState([]),[a,i]=h.useState([]),[s,l]=h.useState(!0),[c,u]=h.useState(null),[d,f]=h.useState(null),[g,p]=h.useState("all"),[m,y]=h.useState(""),[v,x]=h.useState(!1),[b,k]=h.useState(Object.create(null)),[S,E]=h.useState(null),[_,w]=h.useState(!1),[C,A]=h.useState(Object.create(null)),j=bc(),D=h.useCallback(async function(){l(!0),u(null),w(!1);try{var H=await Promise.allSettled([Hv(),nP(),U5()]),ue=H[0].status==="fulfilled"?H[0].value:[],J=H[1].status==="fulfilled"?H[1].value:[],ge=H[2].status==="fulfilled"?H[2].value.skillDefaults||{}:{};r(ue),i(J),A(ge);var K=[];H[0].status==="rejected"&&K.push(t("skills.load_installed_failed",{error:H[0].reason.message})),H[1].status==="rejected"&&K.push(t("skills.load_marketplace_failed",{error:H[1].reason.message})),K.length>0&&u(K.join("; "))}catch(he){u(he.message)}finally{l(!1)}},[t]);h.useEffect(function(){D()},[D]);var P=[],q=new Set(n.map(function(H){return H.name}));n.forEach(function(H){P.push(Object.assign({},H,{_installed:!0}))}),a.forEach(function(H){q.has(H.name)||P.push(Object.assign({},H,{_installed:!1,allTokensConfigured:!1}))});var O=P;if(g==="installed"?O=P.filter(function(H){return H._installed}):g==="available"&&(O=P.filter(function(H){return!H._installed})),m){var L=m.toLowerCase();O=O.filter(function(H){return H.name&&H.name.toLowerCase().indexOf(L)!==-1||H.description&&H.description.toLowerCase().indexOf(L)!==-1||H.category&&H.category.toLowerCase().indexOf(L)!==-1})}var T=h.useCallback(async function(H){try{await aP(H.name),D()}catch(ue){u(t("skills.install_failed",{error:ue.message}))}},[D,t]),M=h.useCallback(function(H){f(H)},[]),U=h.useCallback(async function(H){if(await j({title:t("skills.uninstall_title"),message:t("skills.uninstall_confirm",{skill:H.name}),destructive:!0,confirmLabel:t("skills.uninstall")}))try{await cP(H.name),D()}catch(ue){u(t("skills.uninstall_failed",{error:ue.message}))}},[D,j,t]),Y=h.useCallback(function(){f(null),D()},[D]),R=h.useCallback(async function(H,ue){A(function(ge){var K=Object.assign({},ge);return ue?K[H]=!0:delete K[H],K});try{var J={};J[H]=ue,await uP(J)}catch(ge){A(function(K){var he=Object.assign({},K);return ue?delete he[H]:he[H]=!0,he}),u(ge.message)}},[]),V=h.useCallback(async function(){x(!0),u(null);try{var H=await sP(),ue=Object.create(null);(H.skills||[]).forEach(function(J){ue[J.name]={hasUpdate:J.hasUpdate,latestVersion:J.latestVersion,currentVersion:J.currentVersion}}),k(ue),w(!0)}catch(J){u(J.message)}finally{x(!1)}},[]),X=h.useCallback(async function(H){E(H),u(null);try{var ue=await iP(H);ue.updated&&(k(function(J){var ge=Object.assign(Object.create(null),J);return ge[H]={hasUpdate:!1,latestVersion:J[H]?J[H].latestVersion:null,currentVersion:J[H]?J[H].currentVersion:null},ge}),D())}catch(J){u(t("skills.update_failed")+": "+J.message)}finally{E(null)}},[D,t]),I=Object.values(b).filter(function(H){return H&&H.hasUpdate}).length;return o.jsxs("div",{className:"h-full flex flex-col bg-white dark:bg-gray-950 min-h-0",children:[o.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-800",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("button",{onClick:e,className:"p-1.5 rounded-lg text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors","aria-label":t("skills.back_to_chat"),children:o.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.5 19.5L3 12m0 0l7.5-7.5M3 12h18"})})}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:t("skills.skill_management")}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:t("skills.installed_count",{installed:n.length,available:a.filter(function(H){return!q.has(H.name)}).length})})]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("button",{onClick:V,disabled:v||s,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-gray-600 dark:text-gray-300 bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-lg transition-colors disabled:opacity-50",children:v?o.jsxs(o.Fragment,{children:[o.jsx("svg",{className:"w-3.5 h-3.5 animate-spin",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),t("skills.checking_updates")]}):o.jsxs(o.Fragment,{children:[o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),t("skills.check_updates")]})}),I>0&&o.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400 rounded-full",children:t("skills.updates_available",{count:I})}),_&&I===0&&!v&&o.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 rounded-full",children:t("skills.no_updates")}),o.jsx("div",{className:"flex items-center gap-1 bg-gray-100 dark:bg-gray-800 rounded-lg p-0.5",children:["all","installed","available"].map(function(H){return o.jsx("button",{onClick:function(){p(H)},className:"px-3 py-1 text-xs font-medium rounded-md transition-colors "+(g===H?"bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 shadow-sm":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),children:t("skills.tab_"+H)},H)})})]})]}),o.jsx("div",{className:"flex-shrink-0 px-6 py-3 border-b border-gray-100 dark:border-gray-800/50",children:o.jsxs("div",{className:"relative",children:[o.jsx("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),o.jsx("input",{type:"text",placeholder:t("skills.search_placeholder"),value:m,onChange:function(H){y(H.target.value)},className:"w-full pl-10 pr-4 py-2 text-sm bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg text-gray-900 dark:text-gray-100 placeholder-gray-400 outline-none focus:ring-2 focus:ring-primary-500/30 focus:border-primary-500"})]})}),o.jsxs("div",{className:"flex-1 overflow-y-auto overflow-x-hidden p-6 min-h-0",children:[s&&o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx("div",{className:"w-8 h-8 border-2 border-primary-500 border-t-transparent rounded-full animate-spin"})}),c&&o.jsx("div",{className:"mb-4 p-3 bg-red-50 dark:bg-red-900/20 rounded-lg border border-red-200 dark:border-red-800",children:o.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:c})}),!s&&O.length===0&&o.jsx("div",{className:"text-center py-12",children:o.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:t(m?"skills.no_match":"skills.no_skills")})}),!s&&O.length>0&&o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:O.map(function(H){return o.jsx(iJ,{skill:H,installed:H._installed,updateInfo:b[H.name],updatingSkill:S,onConfigure:M,onInstall:T,onUpdate:X,onUninstall:H._installed?U:null,skillDefaultEnabled:!!C[H.name],onToggleDefault:H._installed?R:null,t},H.name)})})]}),d&&o.jsx(aJ,{skill:d,onClose:function(){f(null)},onSaved:Y})]})}const Xt="";function Qt(e,t={}){return fetch(e,{credentials:"include",...t})}async function oJ(){const e=await Qt(Xt+"/api/agents");if(!e.ok)throw new Error("Failed to fetch agents: "+e.statusText);return e.json()}async function lJ(e){const t=await Qt(Xt+"/api/agents/"+encodeURIComponent(e));if(!t.ok)throw new Error("Failed to fetch agent: "+t.statusText);return t.json()}async function Hb(e){const t=await Qt(Xt+"/api/agents/"+encodeURIComponent(e)+"/start",{method:"POST"});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||"Failed to start agent")}return t.json()}async function qb(e){const t=await Qt(Xt+"/api/agents/"+encodeURIComponent(e)+"/stop",{method:"POST"});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||"Failed to stop agent")}return t.json()}async function $d(e,t){const n={};t&&t.clean&&(n.clean=!0);const r=await Qt(Xt+"/api/agents/"+encodeURIComponent(e)+"/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok){const a=await r.json().catch(()=>({}));throw new Error(a.error||"Failed to restart agent")}return r.json()}async function Wb(e,t){const n={};t&&t.level&&(n.level=t.level),t&&t.span&&(n.span=t.span);const r=await Qt(Xt+"/api/agents/"+encodeURIComponent(e)+"/pause",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok){const a=await r.json().catch(()=>({}));throw new Error(a.error||"Failed to pause agent")}return r.json()}async function Vb(e){const t=await Qt(Xt+"/api/agents/"+encodeURIComponent(e)+"/unpause",{method:"POST"});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||"Failed to unpause agent")}return t.json()}async function cJ(e,t,n,r){const a={message:t,priority:n};r!=null&&(a.replyToInbox=r);const i=await Qt(Xt+"/api/agents/"+encodeURIComponent(e)+"/inbox",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.error||"Failed to send message to agent")}return i.json()}async function uJ(e,t,n){const r={message:t};n!=null&&(r.replyToInbox=n);const a=await Qt(Xt+"/api/agents/"+encodeURIComponent(e)+"/interrupt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({}));throw new Error(i.error||"Failed to send urgent interrupt to agent")}return a.json()}async function dJ(e,t){let n=Xt+"/api/agents/"+encodeURIComponent(e)+"/messages";t&&t.refresh&&(n+="?refresh=true");const r=await Qt(n);if(!r.ok)throw new Error("Failed to fetch agent messages: "+r.statusText);return r.json()}async function fJ(){const e=await Qt(Xt+"/api/pricing");if(!e.ok)throw new Error("Failed to fetch pricing: "+e.statusText);return e.json()}async function gJ(e){const t=await Qt(Xt+"/api/pricing",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||"Failed to update pricing")}return t.json()}async function pJ(){const e=await Qt(Xt+"/api/pricing/reset",{method:"POST"});if(!e.ok){const t=await e.json().catch(()=>({}));throw new Error(t.error||"Failed to reset pricing")}return e.json()}async function hJ(e,t=!1){const n=Xt+"/api/agents/"+encodeURIComponent(e)+(t?"?force=true":""),r=await Qt(n,{method:"DELETE"});if(!r.ok){const a=await r.json().catch(()=>({}));throw new Error(a.error||"Failed to delete agent")}return r.json()}async function mJ(e){const t=await Qt(Xt+"/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||"Failed to create agent")}return t.json()}async function L3(){const e=await Qt(Xt+"/api/skills");if(!e.ok)throw new Error("Failed to fetch skills: "+e.statusText);return e.json()}async function Q1(){const e=await Qt(Xt+"/api/models");if(!e.ok)throw new Error("Failed to fetch models: "+e.statusText);return e.json()}async function xJ(e,t){const n=await Qt(Xt+"/api/agents/"+encodeURIComponent(e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||"Failed to update agent")}return n.json()}async function yJ(e){const t=await Qt(Xt+"/api/agents/"+encodeURIComponent(e)+"/agents-md");if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||"Failed to fetch AGENTS.md")}return t.json()}async function bJ(e,t){const n=await Qt(Xt+"/api/agents/"+encodeURIComponent(e)+"/agents-md",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||"Failed to update AGENTS.md")}return n.json()}async function O3(e){const t=await Qt(Xt+"/api/agents/"+encodeURIComponent(e)+"/export");if(!t.ok){const l=await t.json().catch(()=>({}));throw new Error(l.error||"Failed to export agent")}const n=await t.text(),r=new Blob([n],{type:"text/yaml"}),a=URL.createObjectURL(r),i=t.headers.get("X-Filename")||e+".agent.yaml",s=document.createElement("a");s.href=a,s.download=i,document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>URL.revokeObjectURL(a),5e3)}async function vJ(e,t){const n=new URLSearchParams,r=n.toString()?"?"+n.toString():"",a=await Qt(Xt+"/api/agents/import"+r,{method:"POST",headers:{"Content-Type":"text/yaml"},body:e});if(!a.ok){const i=await a.json().catch(()=>({}));throw new Error(i.error||"Failed to import agent")}return a.json()}async function dy(){const e=await Qt(Xt+"/api/system/updates");if(!e.ok){const t="Failed to check for updates",n=await e.json().catch(()=>({})),r=n.error||n.message||n.output||e.statusText;throw r?r.indexOf(t)===0||r===t?new Error(r):new Error(t+": "+r):new Error(t)}return e.json()}async function kJ(){const e=await Qt(Xt+"/api/system/update",{method:"POST"});if(!e.ok){const n="Failed to perform update",r=await e.json().catch(()=>({})),a=r.error||r.message||r.output||e.statusText;throw a?a.indexOf(n)===0||a===n?new Error(a):new Error(n+": "+a):new Error(n)}const t=await e.json();if(t.status!=="success"){let n=t.error||t.message||"";throw t.output&&!t.error&&!t.message?n="Update returned status: "+(t.status||"failed")+(t.output?": "+t.output:""):t.output&&(n+=t.output?" ("+t.output+")":""),n||(n="Update returned unexpected status: "+(t.status||"unknown")),new Error(n)}return t}async function sj(){const e=await Qt(Xt+"/api/models/registry");if(!e.ok)throw new Error("Failed to fetch model registry: "+e.statusText);return e.json()}async function oj(e,t){const n=await Qt(Xt+"/api/models/registry",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||"Failed to save model: "+n.statusText)}return n.json()}async function lj(e){const t=await Qt(Xt+"/api/models/registry/"+encodeURIComponent(e),{method:"DELETE"});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||"Failed to delete model: "+t.statusText)}return t.json()}function D3(e){const t=typeof e=="string"?e.split("-"):null;if(t&&t.length===3){const n=Number(t[0]),r=Number(t[1]),a=Number(t[2]);if(!Number.isNaN(n)&&!Number.isNaN(r)&&!Number.isNaN(a))return new Date(n,r-1,a)}return new Date(e)}function _J(e){const t=D3(e),n=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return n[t.getDay()]+", "+r[t.getMonth()]+" "+t.getDate()}function Ru(e){return e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(1)+"K":e.toString()}function wJ({data:e}){if(!e||e.length===0)return o.jsx("div",{className:"h-32 flex items-center justify-center text-sm text-gray-400 dark:text-gray-500",children:"No usage data available"});const t=280,n=120,r={top:10,right:10,bottom:25,left:40},a=t-r.left-r.right,i=n-r.top-r.bottom,s=Math.max(...e.map(g=>(g.input||0)+(g.output||0)+(g.cached||0)),1),l=a/e.length,c=Math.max(8,l*.6),u=(l-c)/2,d=g=>i-g/s*i,f=[0,.25,.5,.75,1].map(g=>Math.round(s*g));return o.jsxs("div",{className:"relative",children:[o.jsxs("svg",{width:"100%",height:n,viewBox:`0 0 ${t} ${n}`,className:"overflow-visible",children:[f.map((g,p)=>{const m=r.top+d(g);return o.jsxs("g",{children:[o.jsx("line",{x1:r.left,y1:m,x2:t-r.right,y2:m,stroke:"currentColor",strokeOpacity:.1,className:"text-gray-400 dark:text-gray-600"}),o.jsx("text",{x:r.left-5,y:m,textAnchor:"end",dominantBaseline:"middle",className:"text-[9px] fill-gray-400 dark:fill-gray-500",children:Ru(g)})]},p)}),e.map((g,p)=>{const m=r.left+p*l+u,y=g.input||0,v=g.output||0,x=g.cached||0,b=y/s*i,k=v/s*i,S=x/s*i,E=r.top+i-b,_=E-k,w=_-S,C=D3(g.date),A=["S","M","T","W","T","F","S"][C.getDay()];return o.jsxs("g",{className:"group",children:[o.jsx("rect",{x:m-u,y:r.top,width:l,height:i,fill:"transparent",className:"cursor-pointer"}),y>0&&o.jsx("rect",{x:m,y:E,width:c,height:b,rx:2,className:"fill-blue-500 dark:fill-blue-400 transition-opacity group-hover:opacity-80"}),v>0&&o.jsx("rect",{x:m,y:_,width:c,height:k,rx:2,className:"fill-green-500 dark:fill-green-400 transition-opacity group-hover:opacity-80"}),x>0&&o.jsx("rect",{x:m,y:w,width:c,height:S,rx:2,className:"fill-purple-500 dark:fill-purple-400 transition-opacity group-hover:opacity-80"}),o.jsx("text",{x:m+c/2,y:n-5,textAnchor:"middle",className:"text-[9px] fill-gray-400 dark:fill-gray-500",children:A}),o.jsxs("g",{className:"opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none",children:[o.jsx("rect",{x:m+c/2-45,y:Math.min(w,_,E)-50,width:90,height:45,rx:4,className:"fill-gray-900 dark:fill-gray-100"}),o.jsx("text",{x:m+c/2,y:Math.min(w,_,E)-38,textAnchor:"middle",className:"text-[9px] fill-white dark:fill-gray-900 font-medium",children:_J(g.date)}),o.jsxs("text",{x:m+c/2,y:Math.min(w,_,E)-26,textAnchor:"middle",className:"text-[8px] fill-blue-300 dark:fill-blue-600",children:["In: ",Ru(y)]}),o.jsxs("text",{x:m+c/2,y:Math.min(w,_,E)-16,textAnchor:"middle",className:"text-[8px] fill-green-300 dark:fill-green-600",children:["Out: ",Ru(v)]}),o.jsxs("text",{x:m+c/2,y:Math.min(w,_,E)-6,textAnchor:"middle",className:"text-[8px] fill-purple-300 dark:fill-purple-600",children:["Cache: ",Ru(x)]})]})]},p)})]}),o.jsxs("div",{className:"flex items-center justify-center gap-4 mt-2 text-xs",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("div",{className:"w-2 h-2 rounded-sm bg-blue-500 dark:bg-blue-400"}),o.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Input"})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("div",{className:"w-2 h-2 rounded-sm bg-green-500 dark:bg-green-400"}),o.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Output"})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("div",{className:"w-2 h-2 rounded-sm bg-purple-500 dark:bg-purple-400"}),o.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Cached"})]})]})]})}function EJ({agentName:e,onClose:t,onToolPartsChange:n,hackerMode:r}){var{t:a}=Tt(),[i,s]=h.useState([]),[l,c]=h.useState(!0),[u,d]=h.useState(null),[f,g]=h.useState(!1),[p,m]=h.useState(""),[y,v]=h.useState(!0),[x,b]=h.useState(!1),[k,S]=h.useState(!1),[E,_]=h.useState(!1),[w,C]=h.useState(!1),A=h.useRef(null),j=h.useRef(null),D=h.useRef(!0),P=h.useRef([]),q=h.useRef(null),O=h.useRef(null),L=h.useRef(null),T=h.useRef(null);h.useEffect(function(){P.current=i},[i]);var M=h.useCallback(async function(J,ge){if(e){ge!==!1&&c(!0);try{var K=await dJ(e,{refresh:!!J}),he=K.messages||[],Me=P.current,Te=he.length!==Me.length;if(!Te&&he.length>0&&Me.length>0){var Ae=he[he.length-1],Pe=Me[Me.length-1];if(Ae.info.id!==Pe.info.id&&(Te=!0),!Te){var be=Ae.parts||[],de=Pe.parts||[];if(be.length!==de.length)Te=!0;else for(var pe=0;pe<be.length&&!Te;pe++){var Oe=be[pe]||{},me=de[pe]||{},ee=Oe.state?Oe.state.status:Oe.status,Re=me.state?me.state.status:me.status;(Oe.id!==me.id||ee!==Re)&&(Te=!0)}}}Te&&s(he.slice()),d(null)}catch(fe){console.error("Failed to load messages:",fe),d(fe.message)}finally{ge!==!1&&c(!1)}}},[e]);h.useEffect(function(){M(!0);var J=setInterval(function(){M(!0,!1)},5e3);return function(){clearInterval(J),O.current&&clearTimeout(O.current),T.current&&clearTimeout(T.current)}},[M]),h.useEffect(function(){D.current&&A.current&&A.current.scrollIntoView({behavior:"smooth"})},[i]);var U=h.useCallback(function(){var J=j.current;J&&(D.current=J.scrollHeight-J.scrollTop-J.clientHeight<50)},[]),Y=h.useMemo(function(){for(var J=null,ge=i.length-1;ge>=0;ge--)if(i[ge].info&&i[ge].info.role==="assistant"){J=i[ge];break}return J?(J.parts||[]).filter(function(K){return K.type==="tool"}):[]},[i]);h.useEffect(function(){n&&n(Y)},[Y,n]);var R=h.useCallback(async function(){if(!(!p.trim()||x)){b(!0),S(!1),_(!1),C(!1),d(null);try{await cJ(e,p.trim(),"normal",y),m(""),S(!0),O.current&&clearTimeout(O.current),O.current=setTimeout(function(){S(!1),g(!1),O.current=null},1500),T.current&&clearTimeout(T.current),T.current=setTimeout(function(){M(!0,!1),T.current=null},500)}catch(J){d(J.message)}finally{b(!1)}}},[e,p,y,x,M]),V=h.useCallback(async function(){if(!(!p.trim()||x)){if(!w){C(!0);return}b(!0),S(!1),_(!0),C(!1),d(null);try{await uJ(e,p.trim(),y),m(""),S(!0),O.current&&clearTimeout(O.current),O.current=setTimeout(function(){S(!1),g(!1),O.current=null},1500),T.current&&clearTimeout(T.current),T.current=setTimeout(function(){M(!0,!1),T.current=null},500)}catch(J){d(J.message)}finally{b(!1)}}},[e,p,x,w,y,M]),X=h.useCallback(function(){g(!1),C(!1),d(null),O.current&&(clearTimeout(O.current),O.current=null),T.current&&(clearTimeout(T.current),T.current=null),S(!1)},[]);h.useEffect(function(){if(!f)return;function J(ge){ge.key==="Escape"&&!x&&X()}return document.addEventListener("keydown",J),function(){document.removeEventListener("keydown",J)}},[f,X,x]),h.useEffect(function(){if(!(!f||!L.current)){var J=L.current;J.contains(document.activeElement)||J.focus()}},[f]);var I=h.useCallback(function(J){J.target===J.currentTarget&&!x&&X()},[X,x]),H=h.useCallback(function(J){J.key==="Enter"&&!J.shiftKey&&!w&&(J.preventDefault(),R())},[R,w]),ue=h.useCallback(function(){},[]);return o.jsxs("div",{className:"h-full flex flex-col bg-white dark:bg-gray-900 relative",children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-gray-800",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-500 dark:text-gray-400 transition-colors",title:a("agents.back"),children:o.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Conversation"}),o.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:[e," - ",i.length," messages"]})]})]}),o.jsx("button",{onClick:function(){D.current=!0,M(!0),A.current&&A.current.scrollIntoView({behavior:"smooth"})},disabled:l,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-400 transition-colors disabled:opacity-50",title:a("agents.refresh"),children:o.jsx("svg",{className:`w-4 h-4 ${l?"animate-spin":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]}),u&&o.jsxs("div",{className:"mx-4 mt-3 px-4 py-2 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 text-sm rounded-lg flex items-center justify-between",children:[o.jsx("span",{children:u}),o.jsx("button",{onClick:function(){d(null)},className:"ml-2 text-red-400 hover:text-red-600",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),k&&o.jsxs("div",{className:`mx-4 mt-3 px-4 py-2 text-sm rounded-lg flex items-center gap-2 ${E?"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400":"bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400"}`,children:[o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:E?o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13 10V3L4 14h7v7l9-11h-7z"}):o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),a(E?"agent_conversation.interrupt_sent":"agent_conversation.message_queued")]}),o.jsx("div",{ref:j,onScroll:U,className:"flex-1 overflow-y-auto px-4 py-4",children:l&&i.length===0?o.jsx("div",{className:"flex items-center justify-center h-32",children:o.jsx("div",{className:"w-6 h-6 border-2 border-primary-500 border-t-transparent rounded-full animate-spin"})}):i.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center h-32 text-center",children:[o.jsx("div",{className:"w-12 h-12 rounded-xl bg-gray-100 dark:bg-gray-800 flex items-center justify-center mb-3",children:o.jsx("svg",{className:"w-6 h-6 text-gray-400 dark:text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})}),o.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:a("agent_conversation.no_messages")}),o.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1",children:a("agent_conversation.no_messages_hint")})]}):o.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[i.map(function(J){return o.jsx(cI,{message:J.info,parts:J.parts,streamingParts:null,searchQuery:null,matchOffset:-1,matchCount:0,activeMatchIndex:-1,registerMatchRef:ue,hackerMode:r,hideThinking:!1},J.info.id)}),o.jsx("div",{ref:A})]})}),o.jsx("div",{className:"absolute bottom-6 right-6",children:o.jsxs("button",{onClick:function(){g(!0),C(!1),d(null)},className:"px-4 py-2.5 bg-primary-500 hover:bg-primary-600 text-white rounded-full shadow-lg font-medium text-sm transition-colors flex items-center gap-2","aria-label":a("agent_conversation.compose_button"),children:[o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),a("agent_conversation.compose_button")]})}),f&&o.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/40 backdrop-blur-sm",onClick:I,children:o.jsxs("div",{ref:L,tabIndex:-1,role:"dialog","aria-modal":"true","aria-labelledby":"compose-modal-title",className:"bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700 shadow-xl w-full max-w-lg mx-4 max-h-[80vh] flex flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[o.jsx("h3",{id:"compose-modal-title",className:"text-base font-semibold text-gray-900 dark:text-white",children:a("agent_conversation.modal_title",{name:e})}),o.jsx("button",{onClick:X,disabled:x,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors"+(x?" opacity-50 cursor-not-allowed":""),"aria-label":a("common.close"),children:o.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),o.jsxs("div",{className:"px-5 py-4 space-y-4 overflow-y-auto flex-1 min-h-0",children:[o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:y,onChange:function(J){v(J.target.checked)},className:"w-4 h-4 rounded border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500"}),o.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:a("agent_conversation.reply_to_inbox")})]}),o.jsx("textarea",{ref:q,value:p,onChange:function(J){m(J.target.value)},onKeyDown:H,placeholder:a("agent_conversation.send_placeholder"),className:"w-full px-4 py-3 bg-gray-50 dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 outline-none resize-none text-sm text-gray-900 dark:text-gray-100 placeholder-gray-400 dark:placeholder-gray-500 focus:ring-2 focus:ring-primary-500 dark:focus:ring-primary-400 focus:border-transparent",rows:4,disabled:x,autoFocus:!0}),k&&o.jsx("p",{className:"text-sm text-green-600 dark:text-green-400 font-medium",children:a(E?"agent_conversation.interrupt_sent":"agent_conversation.message_queued")}),u&&o.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:u})]}),o.jsx("div",{className:"px-5 py-4 border-t border-gray-200 dark:border-gray-700 flex-shrink-0",children:w?o.jsxs("div",{className:"space-y-2",children:[o.jsx("p",{className:"text-xs text-red-500 dark:text-red-400 font-medium",children:a("agent_conversation.urgent_warning")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("button",{onClick:function(){C(!1)},className:"px-3 py-1.5 text-xs text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 transition-colors",children:a("common.cancel")}),o.jsxs("button",{onClick:V,disabled:!p.trim()||x,className:"px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white rounded-lg disabled:opacity-50 disabled:cursor-not-allowed text-xs font-medium transition-colors flex items-center gap-1.5",children:[x&&E?o.jsx("div",{className:"w-3 h-3 border-2 border-white border-t-transparent rounded-full animate-spin"}):o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13 10V3L4 14h7v7l9-11h-7z"})}),a("agent_conversation.confirm_interrupt")]})]})]}):o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("button",{onClick:V,disabled:!p.trim()||x,className:"px-3 py-1.5 text-xs text-red-500 dark:text-red-400 hover:text-red-600 dark:hover:text-red-300 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center gap-1.5",children:[o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13 10V3L4 14h7v7l9-11h-7z"})}),a("agent_conversation.urgent_interrupt_button")]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("button",{onClick:X,disabled:x,className:"px-4 py-2 text-sm transition-colors"+(x?" text-gray-400 dark:text-gray-600 cursor-not-allowed":" text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200"),children:a("common.cancel")}),o.jsxs("button",{onClick:R,disabled:!p.trim()||x,className:"px-4 py-2 bg-primary-500 hover:bg-primary-600 text-white rounded-lg disabled:opacity-50 disabled:cursor-not-allowed font-medium text-sm transition-colors flex items-center gap-2",children:[x&&!E?o.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})}),a("agent_conversation.send_button")]})]})]})})]})})]})}function SJ({isOpen:e,agent:t,onClose:n,onUpdated:r,onDeleted:a}){const{t:i}=Tt(),[s,l]=h.useState(""),[c,u]=h.useState(""),[d,f]=h.useState(""),[g,p]=h.useState(""),[m,y]=h.useState(!1),[v,x]=h.useState([]),[b,k]=h.useState(!1),[S,E]=h.useState(""),[_,w]=h.useState(null),[C,A]=h.useState(!1),[j,D]=h.useState([]),[P,q]=h.useState([]),[O,L]=h.useState(!1),[T,M]=h.useState(!0),[U,Y]=h.useState(!1),[R,V]=h.useState(!1),[X,I]=h.useState(null),[H,ue]=h.useState(!1),[J,ge]=h.useState(!1),[K,he]=h.useState("general"),[Me,Te]=h.useState(!1);h.useEffect(()=>{const fe={cancelled:!1};if(e&&t&&!Me){Ae();const Ge=(typeof t.model=="string"?t.model.trim():t.model)||"github-copilot/claude-opus-4.6";Pe(fe,Ge),Te(!0)}return e||(Te(!1),y(!1),p(""),M(!0),q([])),()=>{fe.cancelled=!0}},[e,t==null?void 0:t.name]);const Ae=()=>{if(!t)return;l(t.displayName||t.name||""),u(t.cwd||"");const fe=(typeof t.model=="string"?t.model.trim():t.model)||"github-copilot/claude-opus-4.6";f(fe),y(!1),p(""),x(Array.isArray(t.skills)?t.skills:[]),k(!!t.skipInitialPrompt)},Pe=async(fe,Ge)=>{L(!0),M(!0),t!=null&&t.name&&Y(!0);const Se=[L3(),Q1()];t!=null&&t.name&&Se.push(yJ(t.name));const we=await Promise.allSettled(Se);if(fe.cancelled)return;const[qe,F,B]=we;if(qe.status==="fulfilled"?D(qe.value):(console.error("Failed to load skills:",qe.reason),D([])),L(!1),F.status==="fulfilled"){const W=F.value;q(W);const re=Ge;W.find(_e=>_e.id===re)||(y(!0),p(re),f(re))}else console.error("Failed to load models:",F.reason),q([]);if(M(!1),t!=null&&t.name&&B){if(B.status==="fulfilled"){const W=B.value;E(W.content||""),w(W.path||null),A(W.exists||!1)}else console.error("Failed to load AGENTS.md:",B.reason),E(""),w(null),A(!1);Y(!1)}},be=fe=>{x(Ge=>Ge.includes(fe)?Ge.filter(Se=>Se!==fe):[...Ge,fe])},de=()=>{v.length===j.length?x([]):x(j.map(fe=>fe.name))},pe=async fe=>{if(fe&&fe.preventDefault(),!!(t!=null&&t.name)){I(null),V(!0);try{await xJ(t.name,{displayName:s.trim()||t.name,workspace:c.trim(),model:d,skipInitialPrompt:b,skills:v}),_&&S!==null&&!Re&&await bJ(t.name,S),r&&r(t.name),n()}catch(Ge){I(Ge.message)}finally{V(!1)}}},Oe=async()=>{if(t!=null&&t.name){ge(!0),I(null);try{await hJ(t.name,!0),a&&a(t.name),n()}catch(fe){I(fe.message),ue(!1)}finally{ge(!1)}}},me=()=>{!R&&!J&&(I(null),ue(!1),he("general"),n())};if(!e||!t)return null;const ee=t.state==="working"||t.state==="idle"||t.state==="starting",Re=c.trim()!==(t.cwd||"");return o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[o.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:me}),H&&o.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4",children:[o.jsx("div",{className:"absolute inset-0 bg-black/30",onClick:()=>ue(!1)}),o.jsxs("div",{className:"relative bg-white dark:bg-gray-900 rounded-xl shadow-2xl max-w-md w-full p-6",children:[o.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-2",children:"Delete Agent?"}),o.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:["Are you sure you want to delete ",o.jsx("strong",{children:t.displayName||t.name}),"?",ee&&o.jsx("span",{className:"block mt-2 text-yellow-600 dark:text-yellow-400",children:"Warning: This agent is currently running and will be stopped."})]}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-500 mb-4",children:"This will remove the agent registration. The workspace directory will not be deleted."}),o.jsxs("div",{className:"flex justify-end gap-3",children:[o.jsx("button",{onClick:()=>ue(!1),disabled:J,className:"px-4 py-2 rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors disabled:opacity-50",children:i("common.cancel")}),o.jsx("button",{onClick:Oe,disabled:J,className:"px-4 py-2 rounded-lg bg-red-600 hover:bg-red-700 text-white font-medium transition-colors disabled:opacity-50 flex items-center gap-2",children:J?o.jsxs(o.Fragment,{children:[o.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[o.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),o.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),i("common.deleting")]}):i("common.delete")})]})]})]}),o.jsxs("div",{className:"relative bg-white dark:bg-gray-900 rounded-2xl shadow-2xl max-w-2xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-800",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:i("agent_edit.title")}),o.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[t.name,ee&&o.jsxs("span",{className:"ml-2 text-yellow-600 dark:text-yellow-400",children:["(",i("agent_edit.running_warning"),")"]})]})]}),o.jsx("button",{onClick:me,disabled:R||J,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-400 transition-colors disabled:opacity-50",children:o.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),o.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-800 px-6",children:[o.jsx("button",{onClick:()=>he("general"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${K==="general"?"border-primary-500 text-primary-600 dark:text-primary-400":"border-transparent text-gray-500 hover:text-gray-700 dark:hover:text-gray-300"}`,children:i("agent_edit.tab_general")}),o.jsx("button",{onClick:()=>he("soul"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${K==="soul"?"border-primary-500 text-primary-600 dark:text-primary-400":"border-transparent text-gray-500 hover:text-gray-700 dark:hover:text-gray-300"}`,children:i("agent_edit.tab_soul")})]}),o.jsxs("form",{onSubmit:fe=>fe.preventDefault(),className:"flex-1 overflow-y-auto p-6 space-y-6",children:[X&&o.jsxs("div",{className:"px-4 py-3 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 text-sm rounded-lg flex items-center justify-between",children:[o.jsx("span",{children:X}),o.jsx("button",{type:"button",onClick:()=>I(null),className:"ml-2 text-red-400 hover:text-red-600",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),K==="general"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[i("agent_edit.name_label"),o.jsx("span",{className:"text-gray-400 font-normal ml-1",children:i("agent_edit.cannot_change")})]}),o.jsx("input",{type:"text",value:t.name,disabled:!0,className:"w-full px-4 py-2 rounded-lg bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-500 dark:text-gray-400 cursor-not-allowed font-mono"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:i("agent_edit.display_name_label")}),o.jsx("input",{type:"text",value:s,onChange:fe=>l(fe.target.value),placeholder:i("agent_edit.display_name_placeholder"),className:"w-full px-4 py-2 rounded-lg bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-primary-500"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:i("agent_edit.working_dir_label")}),ee?o.jsx("div",{className:"px-4 py-2 rounded-lg bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-500 dark:text-gray-400 font-mono text-sm break-all",children:c||i("agent_edit.not_set")}):o.jsx("input",{type:"text",value:c,onChange:fe=>u(fe.target.value),placeholder:i("agent_edit.working_dir_placeholder"),disabled:R||J,className:"w-full px-4 py-2 rounded-lg bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-primary-500 font-mono text-sm disabled:opacity-50"}),ee?o.jsx("p",{className:"mt-1 text-xs text-gray-400",children:i("agent_edit.stop_to_change")}):c.trim()!==(t.cwd||"")?o.jsx("p",{className:"mt-1 text-xs text-amber-500 dark:text-amber-400",children:i("agent_edit.workspace_move_warning")}):o.jsx("p",{className:"mt-1 text-xs text-gray-400",children:i("agent_edit.working_dir_hint")})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:i("agent_edit.model_label")}),T?o.jsx("div",{className:"w-full px-4 py-2 rounded-lg bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-400 text-sm",children:i("agent_edit.loading_models")}):P.length===0?o.jsx("input",{type:"text",value:d,onChange:fe=>f(fe.target.value),placeholder:i("agent_edit.model_placeholder"),className:"w-full px-4 py-2 rounded-lg bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-primary-500 font-mono text-sm"}):o.jsxs(o.Fragment,{children:[o.jsxs("select",{value:m?"__custom__":d,onChange:fe=>{fe.target.value==="__custom__"?(y(!0),d&&d!=="__custom__"&&p(d)):(y(!1),f(fe.target.value))},className:"w-full px-4 py-2 rounded-lg bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-primary-500",children:[(()=>{const fe=X1(P);return Object.entries(fe).map(([Ge,Se])=>o.jsx("optgroup",{label:K1[Ge]||Ge,children:Se.map(we=>o.jsxs("option",{value:we.id,children:[we.name,Y1(we.tier)]},we.id))},Ge))})(),o.jsx("option",{value:"__custom__",children:i("agent_edit.custom_model")})]}),m&&o.jsx("input",{type:"text",value:g,onChange:fe=>{p(fe.target.value),f(fe.target.value)},placeholder:i("agent_edit.custom_model_placeholder"),className:"w-full mt-2 px-4 py-2 rounded-lg bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-primary-500 font-mono text-sm"})]}),o.jsx("p",{className:"mt-1 text-xs text-gray-400",children:i(m?"agent_edit.custom_model_hint":"agent_edit.model_hint")})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:i("agent_edit.start_mode")}),o.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:b,onChange:fe=>k(fe.target.checked),className:"mt-0.5 rounded border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500"}),o.jsxs("div",{children:[o.jsx("span",{className:"text-sm text-gray-900 dark:text-gray-100",children:i("agent_edit.dormant_mode")}),o.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:i("agent_edit.dormant_mode_desc")})]})]})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:i("agent_edit.skills_label")}),o.jsx("button",{type:"button",onClick:de,className:"text-xs text-primary-600 dark:text-primary-400 hover:underline",children:v.length===j.length?i("agent_edit.deselect_all"):i("agent_edit.select_all")})]}),o.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg p-3 max-h-48 overflow-y-auto bg-gray-50 dark:bg-gray-800",children:O?o.jsx("div",{className:"text-center py-4 text-gray-500",children:i("agent_edit.loading_skills")}):j.length===0?o.jsx("div",{className:"text-center py-4 text-gray-500",children:i("agent_edit.no_skills")}):o.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2",children:j.map(fe=>o.jsxs("label",{className:`flex items-center gap-2 px-3 py-2 rounded-lg cursor-pointer transition-colors ${v.includes(fe.name)?"bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-300":"hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:[o.jsx("input",{type:"checkbox",checked:v.includes(fe.name),onChange:()=>be(fe.name),className:"rounded border-gray-300 text-primary-600 focus:ring-primary-500"}),o.jsxs("span",{className:"text-sm truncate",title:fe.description,children:[fe.icon&&o.jsx("span",{className:"mr-1",children:fe.icon}),fe.name]})]},fe.name))})}),o.jsx("p",{className:"mt-1 text-xs text-gray-400",children:i("agent_edit.skills_selected",{count:v.length})})]})]}),K==="soul"&&o.jsxs("div",{className:"space-y-4",children:[_&&o.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono bg-gray-50 dark:bg-gray-800 rounded px-3 py-2",children:[_,!C&&o.jsx("span",{className:"ml-2 text-yellow-600 dark:text-yellow-400",children:i("agent_edit.will_be_created")})]}),!_&&!c.trim()&&o.jsx("div",{className:"px-4 py-3 bg-yellow-50 dark:bg-yellow-900/20 text-yellow-700 dark:text-yellow-400 text-sm rounded-lg",children:i("agent_edit.no_workspace_warning")}),Re&&o.jsx("div",{className:"px-4 py-3 bg-amber-50 dark:bg-amber-900/20 text-amber-700 dark:text-amber-400 text-sm rounded-lg",children:i("agent_edit.workspace_changed_warning")}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:i("agent_edit.instructions_label")}),o.jsx("textarea",{value:S,onChange:fe=>E(fe.target.value),disabled:!_||Re,rows:16,placeholder:i(U?"common.loading":"agent_edit.soul_placeholder"),className:"w-full px-4 py-3 rounded-lg bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-primary-500 font-mono text-sm resize-none disabled:cursor-not-allowed disabled:opacity-50"}),o.jsx("p",{className:"mt-1 text-xs text-gray-400",children:i("agent_edit.instructions_hint")})]})]})]}),o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900",children:[o.jsxs("button",{type:"button",onClick:()=>ue(!0),disabled:R||J,className:"px-4 py-2 rounded-lg text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors disabled:opacity-50 flex items-center gap-2",children:[o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})}),i("common.delete")]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("button",{type:"button",onClick:me,disabled:R||J,className:"px-4 py-2 rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors disabled:opacity-50",children:i("common.cancel")}),o.jsx("button",{type:"button",onClick:pe,disabled:R||J,className:"px-6 py-2 rounded-lg bg-primary-600 hover:bg-primary-700 text-white font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:R?o.jsxs(o.Fragment,{children:[o.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[o.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),o.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),i("agent_edit.saving")]}):o.jsxs(o.Fragment,{children:[o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),i("agent_edit.save")]})})]})]})]})]})}const cj={working:"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400",idle:"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400",paused:"bg-orange-100 dark:bg-orange-900/30 text-orange-700 dark:text-orange-400",stopped:"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400",crashed:"bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-400",error:"bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-400",starting:"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-400"},uj={working:o.jsx("svg",{className:"w-4 h-4 mr-1.5",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),idle:o.jsx("svg",{className:"w-4 h-4 mr-1.5",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{d:"M17.293 13.293A8 8 0 016.707 2.707a8.001 8.001 0 1010.586 10.586z"})}),paused:o.jsx("svg",{className:"w-4 h-4 mr-1.5",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zM7 8a1 1 0 012 0v4a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v4a1 1 0 102 0V8a1 1 0 00-1-1z",clipRule:"evenodd"})}),stopped:o.jsx("svg",{className:"w-4 h-4 mr-1.5",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8 7a1 1 0 00-1 1v4a1 1 0 001 1h4a1 1 0 001-1V8a1 1 0 00-1-1H8z",clipRule:"evenodd"})}),crashed:o.jsx("svg",{className:"w-4 h-4 mr-1.5",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),error:o.jsx("svg",{className:"w-4 h-4 mr-1.5",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),starting:o.jsx("svg",{className:"w-4 h-4 mr-1.5 animate-spin",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})};function NJ({state:e}){const t=cj[e]||cj.stopped,n=uj[e]||uj.stopped;return o.jsxs("span",{className:`inline-flex items-center px-3 py-1 rounded-full text-sm font-medium ${t}`,children:[n,e]})}function CJ(e){if(!e)return"-";const t=Date.now()-e,n=Math.floor(t/1e3);if(n<60)return n+"s";const r=Math.floor(n/60);if(r<60)return r+"m";const a=Math.floor(r/60),i=r%60;if(a<24)return a+"h "+i+"m";const s=Math.floor(a/24),l=a%24;return s+"d "+l+"h"}function fy({label:e,value:t,max:n,color:r}){const a=n>0?Math.min(100,Math.round(t/n*100)):0;return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between text-xs",children:[o.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:e}),o.jsx("span",{className:"text-gray-700 dark:text-gray-300 font-medium",children:t.toLocaleString()})]}),o.jsx("div",{className:"h-1.5 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden",children:o.jsx("div",{className:`h-full ${r} transition-all duration-300`,style:{width:a+"%"}})})]})}function Xi({label:e,value:t,mono:n}){return o.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-gray-100 dark:border-gray-800 last:border-0",children:[o.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:e}),o.jsx("span",{className:`text-sm text-gray-900 dark:text-gray-100 ${n?"font-mono":""}`,children:t||"-"})]})}function jJ({agent:e,onClose:t,onAction:n,onToolPartsChange:r,hackerMode:a}){const{t:i}=Tt(),[s,l]=h.useState(e),[c,u]=h.useState(null),[d,f]=h.useState(null),[g,p]=h.useState(!1),[m,y]=h.useState(!1),v=h.useCallback(async()=>{if(e!=null&&e.name)try{const C=await lJ(e.name);l(C),u(null)}catch(C){console.error("Failed to load agent:",C),u(C.message)}},[e==null?void 0:e.name]);h.useEffect(()=>{v();const C=setInterval(v,5e3);return()=>clearInterval(C)},[v]);const x=h.useCallback(async C=>{f(C),u(null);try{C==="start"?await Hb(s.name):C==="stop"?await qb(s.name):C==="restart"?await $d(s.name):C==="cleanRestart"?await $d(s.name,{clean:!0}):C==="pause"?await Wb(s.name,{level:"tools"}):C==="unpause"&&await Vb(s.name),await v(),n&&n(s.name,C)}catch(A){u(A.message)}finally{f(null)}},[s==null?void 0:s.name,v,n]),b=(s==null?void 0:s.state)==="working"||(s==null?void 0:s.state)==="idle"||(s==null?void 0:s.state)==="starting"||(s==null?void 0:s.state)==="paused",k=(s==null?void 0:s.state)==="paused"||(s==null?void 0:s.paused),S=(s==null?void 0:s.displayName)||(s==null?void 0:s.name)||"Unknown Agent",E=(s==null?void 0:s.tokens)||{input:0,output:0,cached:0,total:0},_=Math.max(E.input,E.output,E.cached,1),w=(s==null?void 0:s.cost)||{input:0,output:0,cached:0,total:0};return g?o.jsx(EJ,{agentName:s==null?void 0:s.name,onClose:()=>{p(!1),r&&r(null)},onToolPartsChange:r,hackerMode:a}):o.jsxs("div",{className:"h-full flex flex-col bg-white dark:bg-gray-900 border-l border-gray-200 dark:border-gray-800",children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-800",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-500 dark:text-gray-400 transition-colors flex-shrink-0",title:i("agent_detail.back"),"aria-label":i("agent_detail.back"),children:o.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 truncate",title:S,children:S}),(s==null?void 0:s.displayName)&&s.displayName!==s.name&&o.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 truncate",title:s.name,children:s.name})]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("button",{onClick:()=>y(!0),className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-500 dark:text-gray-400 transition-colors",title:i("agent_detail.edit_settings"),"aria-label":i("agent_detail.edit_settings"),children:o.jsxs("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}),o.jsx(NJ,{state:(s==null?void 0:s.state)||"stopped"})]})]}),o.jsx(SJ,{isOpen:m,agent:s,onClose:()=>y(!1),onUpdated:C=>{v(),n&&n(C,"updated")},onDeleted:C=>{n&&n(C,"deleted"),t()}}),c&&o.jsxs("div",{className:"mx-6 mt-4 px-4 py-2 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 text-sm rounded-lg flex items-center justify-between",children:[o.jsx("span",{children:c}),o.jsx("button",{onClick:()=>u(null),className:"ml-2 text-red-400 hover:text-red-600",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[o.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:b?o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>x("stop"),disabled:d,className:"flex-1 px-4 py-2 text-sm font-medium rounded-lg bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 disabled:opacity-50 transition-colors",children:i(d==="stop"?"agents.stopping":"agents.stop")}),k?o.jsx("button",{onClick:()=>x("unpause"),disabled:d,className:"flex-1 px-4 py-2 text-sm font-medium rounded-lg bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 hover:bg-green-200 dark:hover:bg-green-800/40 disabled:opacity-50 transition-colors",children:i(d==="unpause"?"agents.resuming":"agents.resume")}):o.jsx("button",{onClick:()=>x("pause"),disabled:d,className:"flex-1 px-4 py-2 text-sm font-medium rounded-lg bg-orange-100 dark:bg-orange-900/30 text-orange-700 dark:text-orange-400 hover:bg-orange-200 dark:hover:bg-orange-800/40 disabled:opacity-50 transition-colors",children:i(d==="pause"?"agents.pausing":"agents.pause")}),o.jsx("button",{onClick:()=>x("restart"),disabled:d,className:"flex-1 px-4 py-2 text-sm font-medium rounded-lg bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400 hover:bg-primary-200 dark:hover:bg-primary-800/40 disabled:opacity-50 transition-colors",children:i(d==="restart"?"agents.restarting":"agents.restart")}),o.jsx("button",{onClick:()=>x("cleanRestart"),disabled:d,className:"flex-1 px-4 py-2 text-sm font-medium rounded-lg bg-orange-100 dark:bg-orange-900/30 text-orange-700 dark:text-orange-400 hover:bg-orange-200 dark:hover:bg-orange-800/40 disabled:opacity-50 transition-colors",title:i("agents.clean_restart_tooltip"),children:i(d==="cleanRestart"?"agents.restarting":"agents.clean_restart")})]}):o.jsx("button",{onClick:()=>x("start"),disabled:d,className:"flex-1 px-4 py-2 text-sm font-medium rounded-lg bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 hover:bg-green-200 dark:hover:bg-green-800/40 disabled:opacity-50 transition-colors",children:i(d==="start"?"agents.starting":"agents.start")})}),o.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800/50 rounded-xl p-4",children:[o.jsx("h3",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-3",children:i("agent_detail.agent_info")}),o.jsxs("div",{className:"space-y-0",children:[o.jsx(Xi,{label:i("agent_detail.model"),value:s==null?void 0:s.model,mono:!0}),o.jsx(Xi,{label:i("agent_detail.port"),value:s==null?void 0:s.port,mono:!0}),o.jsx(Xi,{label:i("agent_detail.pid"),value:s==null?void 0:s.pid,mono:!0}),o.jsx(Xi,{label:i("agent_detail.session_id"),value:s!=null&&s.sessionId?s.sessionId.slice(0,12)+"...":null,mono:!0}),o.jsx(Xi,{label:i("agent_detail.uptime"),value:CJ(s==null?void 0:s.startedAt)}),o.jsx(Xi,{label:i("agent_detail.iteration"),value:s==null?void 0:s.iteration}),o.jsx(Xi,{label:i("agent_detail.start_mode"),value:s!=null&&s.skipInitialPrompt?i("agent_detail.start_mode_dormant"):i("agent_detail.start_mode_normal")})]})]}),o.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800/50 rounded-xl p-4",children:[o.jsx("h3",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-3",children:i("agent_detail.token_usage")}),o.jsxs("div",{className:"space-y-3",children:[o.jsx(fy,{label:i("agent_detail.token_input"),value:E.input,max:_,color:"bg-blue-500"}),o.jsx(fy,{label:i("agent_detail.token_output"),value:E.output,max:_,color:"bg-green-500"}),o.jsx(fy,{label:i("agent_detail.token_cached"),value:E.cached,max:_,color:"bg-purple-500"}),o.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-gray-200 dark:border-gray-700",children:[o.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-300",children:"Total"}),o.jsx("span",{className:"text-sm font-bold text-gray-900 dark:text-gray-100",children:E.total.toLocaleString()})]})]})]}),o.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800/50 rounded-xl p-4",children:[o.jsx("h3",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-3",children:"Estimated Cost"}),o.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-3",children:[o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Input"}),o.jsxs("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:["$",w.input.toFixed(4)]})]}),o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Output"}),o.jsxs("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:["$",w.output.toFixed(4)]})]}),o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Cached"}),o.jsxs("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:["$",w.cached.toFixed(4)]})]})]}),o.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-gray-200 dark:border-gray-700",children:[o.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-300",children:i("agent_detail.total_cost")}),o.jsxs("span",{className:"text-lg font-bold text-gray-900 dark:text-gray-100",children:["$",w.total.toFixed(4)]})]})]}),(s==null?void 0:s.dailyUsage)&&s.dailyUsage.length>0&&o.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800/50 rounded-xl p-4",children:[o.jsx("h3",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-3",children:"Daily Usage (Last 7 Days)"}),o.jsx(wJ,{data:s.dailyUsage})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("button",{className:"w-full px-4 py-2.5 text-sm font-medium rounded-lg border border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors flex items-center justify-center gap-2",onClick:()=>p(!0),children:[o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),i("agent_detail.view_conversation")]}),o.jsxs("button",{className:"w-full px-4 py-2.5 text-sm font-medium rounded-lg border border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors flex items-center justify-center gap-2",onClick:()=>y(!0),children:[o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})}),i("agent_detail.edit_settings")]}),o.jsxs("button",{className:"w-full px-4 py-2.5 text-sm font-medium rounded-lg border border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors flex items-center justify-center gap-2",onClick:async()=>{try{await O3(s.name)}catch(C){u(i("agents.export_error")+": "+C.message)}},children:[o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),i("agents.export")]})]}),(s==null?void 0:s.cwd)&&o.jsxs("div",{className:"text-xs text-gray-400 dark:text-gray-500 break-all",children:[o.jsx("span",{className:"font-medium",children:i("agent_detail.working_dir_label")}),o.jsx("br",{}),o.jsx("span",{className:"font-mono",children:s.cwd})]})]})]})}const Iu=["swift","quick","rapid","agile","nimble","clever","smart","wise","bright","keen","bold","brave","calm","steady","noble","silent","shadow","storm","iron","steel","amber","azure","cobalt","crimson","golden","cosmic","cyber","digital","quantum","prime"],Mu=["falcon","hawk","eagle","raven","phoenix","wolf","fox","hound","coyote","tiger","panther","lynx","leopard","bear","orca","shark","viper","cobra","dragon","griffin","sentinel","guardian","titan","node","nexus","core","spark","pulse"];function dj(e=[],t=100){const n=new Set(e.map(s=>s.toLowerCase()));for(let s=0;s<t;s++){const l=Iu[Math.floor(Math.random()*Iu.length)],c=Mu[Math.floor(Math.random()*Mu.length)],u=`${l}-${c}`;if(!n.has(u))return u}const r=Iu[Math.floor(Math.random()*Iu.length)],a=Mu[Math.floor(Math.random()*Mu.length)],i=Math.floor(Math.random()*1e3);return`${r}-${a}-${i}`}function fj(e,t=[]){if(!e||typeof e!="string")return{valid:!1,error:"Name is required"};const n=e.trim().toLowerCase();return n.length===0?{valid:!1,error:"Name cannot be empty"}:n.length<2?{valid:!1,error:"Name must be at least 2 characters"}:n.length>50?{valid:!1,error:"Name must be 50 characters or less"}:/^[a-z0-9_-]+$/.test(n)?new Set(t.map(a=>a.toLowerCase())).has(n)?{valid:!1,error:"An agent with this name already exists"}:{valid:!0,error:null}:{valid:!1,error:"Name can only contain lowercase letters, numbers, hyphens, and underscores"}}function TJ(e){return e?e.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9_-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,""):""}const Lu=`# AGENTS.md - AI Agent Instructions
105
+ `+Wt),F&&(Wt=Aa(Wt)),A&&ct?L(Wt):Wt},t.setConfig=function(){let De=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Rr(De),re=!0,_e=be,We=pe},t.clearConfig=function(){Kr=null,re=!1,_e=null,We=null,A=D,j=""},t.isValidAttribute=function(De,$,ie){Kr||Rr({});const Ce=It(De),Ye=It($);return Fc(Ce,Ye,ie)},t.addHook=function(De,$){typeof $=="function"&&lr(H,De)&&sl(H[De],$)},t.removeHook=function(De,$){if(lr(H,De)){if($!==void 0){const ie=eZ(H[De],$);return ie===-1?void 0:tZ(H[De],ie,1)[0]}return B4(H[De])}},t.removeHooks=function(De){lr(H,De)&&(H[De]=[])},t.removeAllHooks=function(){H=Q4()},t}var NZ=M3();let cy=null;function CZ(){return cy||(cy=O5(()=>import("./mermaid.core-AbOCDXp6.js").then(e=>e.ca),[]).then(function(e){const t=e.default||e;return t.initialize({startOnLoad:!1,securityLevel:"strict",theme:"default",flowchart:{curve:"basis"},suppressErrorRendering:!0}),t})),cy}function Z4(){return typeof document>"u"?!1:document.documentElement.classList.contains("dark")}let J4=0;function jZ(){return J4+=1,"pave-canvas-"+J4}function TZ({source:e}){const t=h.useRef(null),n=h.useRef(jZ()),[r,a]=h.useState(null),[i,s]=h.useState(Z4());return h.useEffect(function(){if(typeof window>"u")return;const l=new MutationObserver(function(){const c=Z4();s(function(u){return u!==c?c:u})});return l.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),function(){l.disconnect()}},[]),h.useEffect(function(){let l=!1;return a(null),CZ().then(function(c){l||(c.initialize({startOnLoad:!1,securityLevel:"strict",theme:i?"dark":"default",flowchart:{curve:"basis"},suppressErrorRendering:!0}),c.render(n.current,e).then(function(u){if(!l&&t.current){let d=u.svg;d=d.replace(/<svg([^>]*)\sstyle="[^"]*max-width:[^";]*;?[^"]*"/i,"<svg$1"),d=d.replace(/(<svg[^>]*)\swidth="[^"]*"/i,"$1"),d=d.replace(/(<svg[^>]*)\sheight="[^"]*"/i,"$1"),d=d.replace(/<svg\b/i,'<svg width="100%" height="100%" preserveAspectRatio="xMidYMid meet"'),t.current.innerHTML=d}}).catch(function(u){l||a(u&&u.message||String(u))}))}).catch(function(c){l||a("Failed to load mermaid: "+(c&&c.message||String(c)))}),function(){l=!0}},[e,i]),r?o.jsxs("div",{className:"text-xs text-red-600 dark:text-red-400 p-2",children:[o.jsx("div",{className:"font-semibold mb-1",children:"Mermaid render error:"}),o.jsx("pre",{className:"whitespace-pre-wrap",children:r}),o.jsxs("details",{className:"mt-2",children:[o.jsx("summary",{className:"cursor-pointer text-gray-600 dark:text-gray-400",children:"Source"}),o.jsx("pre",{className:"mt-1 p-2 bg-gray-100 dark:bg-gray-800 rounded overflow-x-auto",children:e})]})]}):o.jsx("div",{ref:t,className:"mermaid-canvas w-full h-full flex items-center justify-center [&>svg]:max-w-full [&>svg]:max-h-full [&>svg]:w-full [&>svg]:h-auto"})}function AZ({source:e}){const t=h.useMemo(function(){return NZ.sanitize(e,{USE_PROFILES:{svg:!0,svgFilters:!0}})},[e]);return o.jsx("div",{className:"svg-canvas overflow-x-auto",dangerouslySetInnerHTML:{__html:t}})}function RZ({source:e}){return o.jsx("pre",{className:"text-sm p-2 bg-gray-100 dark:bg-gray-800 rounded overflow-x-auto",children:e})}function IZ({canvas:e}){if(!e||!e.type||!e.source)return null;let t=null;return e.type==="mermaid"?t=o.jsx(TZ,{source:e.source}):e.type==="svg"?t=o.jsx(AZ,{source:e.source}):e.type==="katex"?t=o.jsx(RZ,{source:e.source}):t=o.jsxs("pre",{className:"text-xs text-red-600 dark:text-red-400",children:["Unknown canvas type: ",e.type]}),o.jsx("div",{className:"w-full h-full flex items-center justify-center",children:t})}function ej({canvases:e,onClear:t}){const n=Array.isArray(e)?e:[],[r,a]=h.useState(Math.max(0,n.length-1)),[i,s]=h.useState(1),[l,c]=h.useState(!1);h.useEffect(function(){a(function(v){return v>=n.length-2?Math.max(0,n.length-1):Math.min(v,Math.max(0,n.length-1))})},[n.length]),h.useEffect(function(){s(1)},[r]),h.useEffect(function(){if(!l)return;const v=x=>{x.key==="Escape"&&c(!1)};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[l]);const u=h.useCallback(()=>s(v=>Math.min(4,+(v+.25).toFixed(2))),[]),d=h.useCallback(()=>s(v=>Math.max(.5,+(v-.25).toFixed(2))),[]),f=h.useCallback(()=>s(1),[]);if(n.length===0)return o.jsxs("div",{className:"h-full flex flex-col items-center justify-center p-6 text-center",children:[o.jsx("svg",{className:"w-12 h-12 text-gray-300 dark:text-gray-600 mb-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 17V7m0 10a2 2 0 01-2 2H5a2 2 0 01-2-2V7a2 2 0 012-2h2a2 2 0 012 2m0 10a2 2 0 002 2h2a2 2 0 002-2M9 7a2 2 0 012-2h2a2 2 0 012 2m0 10V7m0 10a2 2 0 002 2h2a2 2 0 002-2V7a2 2 0 00-2-2h-2a2 2 0 00-2 2"})}),o.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400 max-w-xs",children:["Ask the agent to draw something here. It can use the ",o.jsx("code",{className:"px-1 bg-gray-200 dark:bg-gray-700 rounded",children:"canvas"})," tool to render Mermaid diagrams, SVG illustrations, or math."]})]});const g=Math.min(Math.max(0,r),n.length-1),p=n[g],m=o.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-1.5 border-b border-gray-200 dark:border-gray-700 text-xs",children:[n.length>1?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{type:"button",onClick:()=>a(Math.max(0,g-1)),disabled:g===0,className:"px-2 py-0.5 rounded text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-40 disabled:cursor-not-allowed",title:"Previous canvas",children:"←"}),o.jsxs("span",{className:"text-gray-500 dark:text-gray-400 tabular-nums",children:[g+1,"/",n.length]}),o.jsx("button",{type:"button",onClick:()=>a(Math.min(n.length-1,g+1)),disabled:g===n.length-1,className:"px-2 py-0.5 rounded text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-40 disabled:cursor-not-allowed",title:"Next canvas",children:"→"})]}):o.jsx("div",{}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{type:"button",onClick:d,disabled:i<=.5,className:"px-1.5 py-0.5 rounded text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-40",title:"Zoom out",children:"−"}),o.jsxs("button",{type:"button",onClick:f,className:"px-1.5 py-0.5 rounded text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 tabular-nums min-w-[3rem]",title:"Reset zoom",children:[Math.round(i*100),"%"]}),o.jsx("button",{type:"button",onClick:u,disabled:i>=4,className:"px-1.5 py-0.5 rounded text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-40",title:"Zoom in",children:"+"}),o.jsx("button",{type:"button",onClick:()=>c(v=>!v),className:"ml-1 px-1.5 py-0.5 rounded text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800",title:l?"Exit fullscreen (Esc)":"Fullscreen",children:l?"⤢":"⛶"}),t?o.jsx("button",{type:"button",onClick:t,className:"ml-1 px-1.5 py-0.5 rounded text-gray-600 dark:text-gray-300 hover:bg-red-50 dark:hover:bg-red-900/30 hover:text-red-600 dark:hover:text-red-400",title:"Clear all canvases (hides them; messages preserved)",children:"✕"}):null]})]}),y=o.jsxs("div",{className:"flex-1 overflow-auto p-3",children:[p.title?o.jsx("div",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200 mb-2",children:p.title}):null,o.jsx("div",{style:{transform:`scale(${i})`,transformOrigin:"top left",width:i===1?"100%":`${100/i}%`},children:o.jsx(IZ,{canvas:p})}),p.caption?o.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400 italic",children:p.caption}):null]});return l?o.jsxs("div",{className:"fixed inset-0 z-50 bg-white dark:bg-gray-900 flex flex-col",children:[m,y]}):o.jsxs("div",{className:"h-full flex flex-col",children:[m,y]})}function MZ(e){return e?e.includes("/")?e.split("/").slice(1).join("/")||null:e:null}function LZ(e,t){const n=MZ(e);return{modelID:n||t||null,activeModelID:n,conversationModelID:t}}const K1={"github-copilot":"GitHub Copilot",anthropic:"Anthropic",openai:"OpenAI",google:"Google",other:"Other"};function Y1(e){return e==="recommended"?" — Recommended":e==="fast"?" — Fast":e==="premium"?" — Premium":""}function X1(e){const t={};return e.forEach(n=>{const r=n.provider||"other";t[r]||(t[r]=[]),t[r].push(n)}),t}const tj={"claude-opus-4.5":2e5,"claude-opus-4.6":2e5,"claude-sonnet-4":2e5,"claude-sonnet-4.5":2e5,"claude-sonnet-4.6":2e5,"gpt-4o":128e3,"gpt-4.1":1047576,"gpt-4-turbo":128e3,"gpt-4":8192,o1:2e5,"o1-mini":128e3,o3:2e5,"o3-mini":2e5},OZ=128e3;function uy(e){const[t,n]=h.useState(e),r=h.useRef(e),a=h.useRef(0),i=h.useRef(0);return h.useEffect(()=>{if(e===r.current)return;a.current=0,r.current=t;const s=400,l=t,c=e,u=d=>{a.current||(a.current=d);const f=d-a.current,g=Math.min(f/s,1),p=1-Math.pow(1-g,3);n(Math.round(l+(c-l)*p)),g<1?i.current=requestAnimationFrame(u):n(c)};return i.current=requestAnimationFrame(u),()=>cancelAnimationFrame(i.current)},[e]),t}function DZ({messages:e,isBusy:t,activeModel:n,sessionModel:r,isPrivateMode:a,registryEntries:i}){var V,X;var{t:s}=Tt();const l=e.filter(I=>{var H;return((H=I.info)==null?void 0:H.role)==="user"}).length,c=e.filter(I=>{var H;return((H=I.info)==null?void 0:H.role)==="assistant"}).length;let u=0,d=0,f=0,g=null,p=null;for(let I=e.length-1;I>=0;I--){const H=e[I];if(((V=H.info)==null?void 0:V.role)==="assistant"&&((X=H.info)==null?void 0:X.mode)!=="compaction"){const ue=H.info.tokens;if(ue&&(ue.input||ue.output)){!g&&H.info.modelID&&(g=H.info.modelID),u=ue.lastInput??ue.input??0,d=ue.lastOutput??ue.output??0,f=ue.lastReasoning??ue.reasoning??0,H.info.contextLimit&&(p=H.info.contextLimit);break}}}const m=uy(u),y=uy(d),v=uy(f),x=m+y+v,b=u+d+f>0;let k=n;typeof r=="string"&&r?k=r:r&&r.providerID&&r.modelID&&(k=r.providerID+"/"+r.modelID);let{modelID:S,activeModelID:E}=LZ(k,g),_=null;if(a){S="privacy",E="privacy";let I=null;typeof r=="string"&&r?I=r.includes("/")?r.split("/").pop():r:r&&r.modelID&&(I=r.modelID),_=I||(n?String(n).split("/").pop():null)}else g&&E&&g!==E&&(_=g);const w=h.useMemo(()=>{const I={};if(i&&i.length>0){for(const H of i)if(H.limit&&typeof H.limit.context=="number"&&H.limit.context>0){I[H.key]=H.limit.context;const ue=H.key.includes("/")?H.key.split("/").pop():H.key;ue&&(I[ue]=H.limit.context)}}return I},[i]),C=g||S,j=!!(g&&E&&g!==E)&&(w[k]||w[S]||tj[S])||p||w[C]||w[k]||tj[C]||OZ,D=Math.min(100,Math.round(m/j*100));let P="bg-green-500";D>=90?P="bg-red-500":D>=75?P="bg-orange-500":D>=50&&(P="bg-yellow-500");const q="border-gray-200 dark:border-gray-800",O="text-gray-500 dark:text-gray-400",L="text-gray-500 dark:text-gray-400",T="text-gray-700 dark:text-gray-300",M="border-gray-100 dark:border-gray-800";return o.jsxs("div",{className:`p-4 border-t ${q}`,children:[o.jsx("p",{className:`text-xs ${O} uppercase tracking-wide font-medium mb-3`,children:s("token_usage.session_info")}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:`text-xs ${L}`,children:s("token_usage.messages")}),o.jsx("span",{className:`text-xs font-medium ${T}`,children:l+c})]}),S&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:`text-xs ${L}`,children:s("token_usage.model")}),o.jsx("span",{className:`text-xs font-medium ${T} truncate ml-2 max-w-[140px]`,children:nj(S)})]}),_&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:`text-xs ${L}`,children:s("token_usage.originally")}),o.jsx("span",{className:`text-xs ${L} truncate ml-2 max-w-[140px]`,children:nj(_)})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:`text-xs ${L}`,children:s("token_usage.status")}),o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${t?"bg-accent-400 animate-pulse":"bg-green-500"}`}),o.jsx("span",{className:`text-xs font-medium ${T}`,children:s(t?"token_usage.generating":"token_usage.idle")})]})]}),b?o.jsx(o.Fragment,{children:o.jsxs("div",{className:`border-t ${M} pt-2 mt-2`,children:[o.jsxs("div",{className:"mb-2",children:[o.jsxs("div",{className:"flex items-center justify-between mb-1",children:[o.jsx("span",{className:`text-xs ${L}`,children:"Context"}),o.jsxs("span",{className:`text-xs ${L}`,children:[D,"% of ",(j/1e3).toFixed(0),"k"]})]}),o.jsx("div",{className:"h-1.5 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden",children:o.jsx("div",{className:`h-full ${P} transition-all duration-300`,style:{width:`${D}%`}})})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:`text-xs ${L}`,children:"Input"}),o.jsx("span",{className:`text-xs font-medium ${T} tabular-nums`,children:m.toLocaleString()})]}),o.jsxs("div",{className:"flex items-center justify-between mt-1",children:[o.jsx("span",{className:`text-xs ${L}`,children:"Output"}),o.jsx("span",{className:`text-xs font-medium ${T} tabular-nums`,children:y.toLocaleString()})]}),f>0&&o.jsxs("div",{className:"flex items-center justify-between mt-1",children:[o.jsx("span",{className:`text-xs ${L}`,children:"Reasoning"}),o.jsx("span",{className:`text-xs font-medium ${T} tabular-nums`,children:v.toLocaleString()})]}),o.jsxs("div",{className:`flex items-center justify-between mt-1 pt-1 border-t ${M}`,children:[o.jsx("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Total"}),o.jsx("span",{className:"text-xs font-semibold text-gray-900 dark:text-gray-100 tabular-nums",children:x.toLocaleString()})]})]})}):o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:`text-xs ${L}`,children:"Tokens"}),o.jsx("span",{className:`text-xs ${L}`,children:"--"})]})]})]})}function nj(e){return e?{"claude-opus-4.5":"Claude Opus 4.5","claude-opus-4.6":"Claude Opus 4.6","claude-sonnet-4":"Claude Sonnet 4","claude-sonnet-4.5":"Claude Sonnet 4.5","claude-sonnet-4.6":"Claude Sonnet 4.6","gpt-4o":"GPT-4o","gpt-4.1":"GPT-4.1","gpt-4-turbo":"GPT-4 Turbo","gpt-4":"GPT-4"}[e]||e:""}function PZ({sessionModel:e,activeModel:t,registryEntries:n,onModelChange:r,disabled:a,lockedReason:i}){const{t:s}=Tt(),[l,c]=h.useState(!1),u=h.useRef(null),[d,f]=h.useState(-1),g=h.useRef([]);h.useEffect(()=>{if(!l)return;function b(k){u.current&&!u.current.contains(k.target)&&c(!1)}return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[l]),h.useEffect(()=>{if(!l)return;function b(k){if(k.key==="Escape"){c(!1);return}k.key!=="ArrowDown"&&k.key!=="ArrowUp"&&k.key!=="Home"&&k.key!=="End"||(k.preventDefault(),f(S=>{const E=g.current.length;if(!E)return S;const _=typeof S=="number"?S:-1;let w=_;return k.key==="ArrowDown"?w=_<E-1?_+1:0:k.key==="ArrowUp"?w=_>0?_-1:E-1:k.key==="Home"?w=0:k.key==="End"&&(w=E-1),g.current[w]&&g.current[w].focus(),w}))}return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[l]);const p=typeof e=="string"&&e.trim()?e.trim():null,m=p!=null,y=Array.isArray(n)?n:[],v=FZ(p,t,y,s),x=h.useCallback(b=>{r(b===t||p&&p===b?null:b),c(!1)},[p,t,r]);return g.current.length=y.length,o.jsxs("div",{className:"relative",ref:u,children:[o.jsxs("button",{type:"button",onClick:()=>c(b=>!b),disabled:a,className:"flex items-center gap-1.5 px-2 py-1 text-xs font-medium rounded-md transition-colors "+(m||v?"bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400 hover:bg-primary-200 dark:hover:bg-primary-900/50":"text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800")+(a?" opacity-50 cursor-not-allowed":" cursor-pointer"),title:i||s("model_selector.title"),"aria-label":i||s("model_selector.title"),"aria-haspopup":"menu","aria-expanded":l,children:[i?o.jsxs("svg",{className:"w-3.5 h-3.5 flex-shrink-0 text-emerald-600 dark:text-emerald-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 11c.667 0 2 .4 2 2v3a2 2 0 11-4 0v-3c0-1.6 1.333-2 2-2zM6 11V8a6 6 0 1112 0v3"}),o.jsx("rect",{x:"5",y:"11",width:"14",height:"10",rx:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):o.jsx("svg",{className:"w-3.5 h-3.5 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),o.jsx("span",{className:"max-w-[120px] truncate",children:v}),o.jsx("svg",{className:`w-3 h-3 transition-transform ${l?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),l&&o.jsxs("div",{className:"absolute left-0 sm:left-auto sm:right-0 top-full mt-1 w-64 max-w-[calc(100vw-1.5rem)] max-h-72 overflow-y-auto bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-50",role:"menu","aria-label":s("model_selector.list_label"),children:[y.length===0&&o.jsx("div",{className:"px-3 py-2 text-xs text-gray-400 dark:text-gray-500",children:s("model_selector.no_models")}),y.map((b,k)=>{const S=p===b.key,E=!!t&&(b.key===t||b.target===t||b.url===t),_=b.builtin?b.key:b.displayName||b.key;return o.jsxs("button",{type:"button",ref:w=>{g.current[k]=w},tabIndex:d===k?0:-1,role:"menuitemradio","aria-checked":S||!m&&E,onClick:()=>x(b.key),className:"w-full text-left px-3 py-2 text-xs transition-colors "+(S||!m&&E?"bg-primary-50 dark:bg-primary-900/20 text-primary-700 dark:text-primary-400":"text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800"),children:[o.jsx("span",{className:"font-medium",children:_}),E&&o.jsxs("span",{className:"ml-1 text-gray-400 dark:text-gray-500",children:["(",s("model_selector.default_label"),")"]})]},b.key)})]})]})}function FZ(e,t,n,r){return e?rj(e,n):t?rj(t,n):r("model_selector.default_label")}function BZ(e,t){if(!e||!Array.isArray(t))return null;for(let n=0;n<t.length;n++){const r=t[n];if(r&&(r.key===e||r.target===e||r.url===e))return r}return null}function rj(e,t){if(!e)return"";const n=BZ(e,t);return n?n.builtin?n.key:n.displayName||n.key:typeof e=="string"&&e.includes("/")?e.split("/").slice(1).join("/"):e}function zZ(e){e.sessionId;var t=e.disabledSkills,n=e.onToggle,r=e.onResetToDefaults,a=e.t,i=e.disabled,s=h.useState(!1),l=s[0],c=s[1],u=h.useState([]),d=u[0],f=u[1],g=h.useState(!1),p=g[0],m=g[1],y=h.useRef(null),v=t instanceof Array?new Set(t):new Set,x=h.useCallback(async function(){m(!0);try{var _=await Hv();f(_||[])}catch{}finally{m(!1)}},[]);h.useEffect(function(){x()},[x]),h.useEffect(function(){if(!l)return;function _(w){y.current&&!y.current.contains(w.target)&&c(!1)}return document.addEventListener("mousedown",_),function(){document.removeEventListener("mousedown",_)}},[l]);var b=v.size,k=v.has("agent"),S=k?b-1:b,E=Math.max(0,d.length-S+(k?0:1));return o.jsxs("div",{className:"relative",ref:y,children:[o.jsxs("button",{onClick:function(){c(!l)},disabled:i,className:"p-1.5 rounded-lg transition-colors "+(b>0?"bg-amber-500/10 text-amber-600 dark:text-amber-400":"text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800")+(i?" opacity-50 cursor-not-allowed":""),title:a("skills.toggle_title"),"aria-label":a("skills.toggle_title"),children:[o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11 4a2 2 0 114 0v1a1 1 0 001 1h3a1 1 0 011 1v3a1 1 0 01-1 1h-1a2 2 0 100 4h1a1 1 0 011 1v3a1 1 0 01-1 1h-3a1 1 0 01-1-1v-1a2 2 0 10-4 0v1a1 1 0 01-1 1H7a1 1 0 01-1-1v-3a1 1 0 00-1-1H4a2 2 0 110-4h1a1 1 0 001-1V7a1 1 0 011-1h3a1 1 0 001-1V4z"})}),E>0&&o.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 text-[9px] font-bold flex items-center justify-center bg-primary-500 text-white rounded-full",children:E})]}),l&&o.jsxs("div",{className:"absolute left-0 sm:left-auto sm:right-0 top-full mt-1 w-64 max-w-[calc(100vw-1.5rem)] bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-50 max-h-80 overflow-y-auto",children:[o.jsxs("div",{className:"px-3 py-2 border-b border-gray-100 dark:border-gray-800",children:[o.jsx("p",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300",children:a("skills.toggle_header")}),o.jsx("p",{className:"text-[10px] text-gray-400 dark:text-gray-500 mt-0.5",children:a("skills.toggle_hint")})]}),p?o.jsx("div",{className:"flex items-center justify-center py-4",children:o.jsx("div",{className:"w-5 h-5 border-2 border-primary-500 border-t-transparent rounded-full animate-spin"})}):d.length===0?o.jsx("div",{className:"px-3 py-4 text-center",children:o.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:a("skills.no_skills")})}):o.jsx("div",{className:"py-1",children:d.map(function(_){var w=v.has(_.name);return o.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[o.jsx("span",{className:"text-xs text-gray-700 dark:text-gray-300 truncate flex-1 mr-2",children:_.name}),o.jsx("button",{onClick:function(){n(_.name,w)},className:"relative inline-flex h-5 w-9 items-center rounded-full transition-colors flex-shrink-0 "+(w?"bg-gray-300 dark:bg-gray-600":"bg-primary-500"),role:"switch","aria-checked":!w,children:o.jsx("span",{className:"inline-block h-3.5 w-3.5 transform rounded-full bg-white transition-transform "+(w?"translate-x-1":"translate-x-5")})})]},_.name)})}),o.jsx("div",{className:"px-3 py-1.5 border-t border-gray-100 dark:border-gray-800",children:o.jsx("p",{className:"text-[10px] font-semibold text-gray-400 dark:text-gray-500 uppercase tracking-wide",children:a("skills.builtin_tools")})}),o.jsx("div",{className:"py-1",children:o.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[o.jsx("span",{className:"text-xs text-gray-700 dark:text-gray-300 truncate flex-1 mr-2",children:a("skills.agent_comm")}),o.jsx("button",{onClick:function(){n("agent",k)},className:"relative inline-flex h-5 w-9 items-center rounded-full transition-colors flex-shrink-0 "+(k?"bg-gray-300 dark:bg-gray-600":"bg-primary-500"),role:"switch","aria-checked":!k,children:o.jsx("span",{className:"inline-block h-3.5 w-3.5 transform rounded-full bg-white transition-transform "+(k?"translate-x-1":"translate-x-5")})})]})}),r&&o.jsx("div",{className:"px-3 py-1.5 border-t border-gray-100 dark:border-gray-800",children:o.jsx("button",{onClick:r,className:"w-full text-xs font-medium text-gray-500 dark:text-gray-400 hover:text-primary-600 dark:hover:text-primary-400 hover:underline transition-colors text-center",children:a("skills.reset_to_defaults")})})]})]})}function UZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.25 6.087c0-.355.186-.676.401-.959.221-.29.349-.634.349-1.003 0-1.036-1.007-1.875-2.25-1.875S10.5 3.089 10.5 4.125c0 .369.128.713.349 1.003.215.283.401.604.401.959V6a.75.75 0 01-.75.75H7.5a.75.75 0 00-.75.75v2.25c0 .414-.336.75-.75.75S5.25 10.164 5.25 9.75V9A2.25 2.25 0 003 11.25v.75a.75.75 0 00.75.75h2.25c.414 0 .75.336.75.75s-.336.75-.75.75H3.75a.75.75 0 00-.75.75v.75A2.25 2.25 0 005.25 18h1.5a.75.75 0 01.75.75v.75c0 .414.336.75.75.75h6a.75.75 0 00.75-.75v-.75a.75.75 0 01.75-.75h1.5A2.25 2.25 0 0019.5 15.75v-.75a.75.75 0 00-.75-.75h-2.25a.75.75 0 01-.75-.75c0-.414.336-.75.75-.75h2.25a.75.75 0 00.75-.75v-.75A2.25 2.25 0 0017.25 9h-3a.75.75 0 01-.75-.75V6.087z"})})}function $Z({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M20 18h-2V9.25L12 13 6 9.25V18H4V6h1.2l6.8 4.25L18.8 6H20m0-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2z"})})}function HZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M7.71 3.5l-5.71 9.94 3.48 6.06h5.44L4.07 8.56 7.71 3.5zm1.42 0L15.84 15h-6.71L2.42 3.5h6.71zm.71 12h11.46l-3.48 6.06H6.36l3.48-6.06zm.71-1L16.84 3.5l5.71 9.94-3.48.06H10.55z"})})}function qZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M20.317 4.37a19.791 19.791 0 00-4.885-1.515.074.074 0 00-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 00-5.487 0 12.64 12.64 0 00-.617-1.25.077.077 0 00-.079-.037A19.736 19.736 0 003.677 4.37a.07.07 0 00-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 00.031.057 19.9 19.9 0 005.993 3.03.078.078 0 00.084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 00-.041-.106 13.107 13.107 0 01-1.872-.892.077.077 0 01-.008-.128 10.2 10.2 0 00.372-.292.074.074 0 01.077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 01.078.01c.12.098.246.198.373.292a.077.077 0 01-.006.127 12.299 12.299 0 01-1.873.892.077.077 0 00-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 00.084.028 19.839 19.839 0 006.002-3.03.077.077 0 00.032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 00-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"})})}function WZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"})})}function VZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M3 6l3.5 12h2l2.5-8 2.5 8h2L19 6h-2.5l-2.25 8L12 6h-2l-2.25 8L5.5 6H3z"})})}function GZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M5 3a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2V5a2 2 0 00-2-2H5zm11.293 6.707l-5.5 5.5a1 1 0 01-1.414 0l-2.5-2.5a1 1 0 111.414-1.414L10.086 13.1l4.793-4.793a1 1 0 111.414 1.4z"})})}function KZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M4 18V6h3.2l2.8 7 2.8-7H16v12h-2.4V9.6L10.6 18H9.4L6.4 9.6V18H4z"})})}function YZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 15.5v-5l-3 3v-4l3-3v-3l4 4-4 4v4z"})})}function XZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}function QZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"})})}function ZZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M6 2l6 3.75L6 9.5.002 5.75 6 2zm12 0l6 3.75-6 3.75-5.998-3.75L18 2zM.002 13.25L6 9.5l6 3.75L6 17 .002 13.25zm17.998-3.75l6 3.75L18 17l-5.998-3.75L18 9.5zM6 18.25l6-3.75 6 3.75-6 3.75-6-3.75z"})})}function JZ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v12m-3-2.818l.879.659c1.171.879 3.07.879 4.242 0 1.172-.879 1.172-2.303 0-3.182C13.536 12.219 12.768 12 12 12c-.725 0-1.45-.22-2.003-.659-1.106-.879-1.106-2.303 0-3.182s2.9-.879 4.006 0l.415.33M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}function eJ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 7.5v11.25m-18 0A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75m-18 0v-7.5A2.25 2.25 0 015.25 9h13.5A2.25 2.25 0 0121 11.25v7.5"})})}function tJ({className:e,...t}){return o.jsx("svg",{className:e,...t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}const aj={gmail:$Z,gdrive:HZ,discord:qZ,whatsapp:WZ,wrike:VZ,gtasks:GZ,mailchimp:KZ,bamboohr:YZ,pandadoc:XZ,exa:QZ,dropbox:ZZ,freshbooks:JZ,gcal:eJ,docx2md:tJ};function nJ(e){return Object.prototype.hasOwnProperty.call(aj,e)?aj[e]:UZ}const ij={gmail:"#EA4335",gdrive:"#4285F4",discord:"#5865F2",whatsapp:"#25D366",wrike:"#08CF65",gtasks:"#4285F4",mailchimp:"#FFE01B",bamboohr:"#73C41D",pandadoc:"#4ABB5A",exa:"#6366F1",dropbox:"#0061FF",freshbooks:"#00B7E3",gcal:"#4285F4",docx2md:"#6B7280"};function rJ({installed:e,configured:t,t:n}){return e?t?o.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400",children:[o.jsx("svg",{className:"w-3 h-3 mr-1",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),n("skills.configured")]}):o.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400",children:[o.jsx("svg",{className:"w-3 h-3 mr-1",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),n("skills.needs_setup")]}):o.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400",children:n("skills.not_installed")})}function aJ({skill:e,onClose:t,onSaved:n}){var{t:r}=Tt(),a=bc(),[i,s]=h.useState({}),[l,c]=h.useState(!0),[u,d]=h.useState(!1),[f,g]=h.useState(null),[p,m]=h.useState(!1),[y,v]=h.useState(null);h.useEffect(function(){var A=!1;async function j(){try{var D=await rP(e.name);if(A)return;v(D);for(var P=Object.create(null),q=Object.keys(D.tokens||{}),O=0;O<q.length;O++){var L=q[O],T=D.tokens[L]||{},M=T.env||L;P[M]=""}s(P),c(!1)}catch(U){A||(g(U.message),c(!1))}}return j(),function(){A=!0}},[e.name]);var x=h.useMemo(function(){if(!y||!y.tokens)return null;if(y.oauth&&y.oauth.broker){var A=!!y.oauth.connected,j=y.oauth.provider||"";return{provider:j?j.charAt(0).toUpperCase()+j.slice(1):"OAuth",brokered:!0,canConnect:!A,refreshConfigured:A,clientIdConfigured:!0,clientSecretConfigured:!0}}for(var D=Object.keys(y.tokens),P=0;P<D.length;P++){var q=y.tokens[D[P]]||{};if(q.description&&q.description.includes("OAuth")){for(var O=null,L=null,T=null,M=Object.entries(y.tokens),U=0;U<M.length;U++){var Y=M[U][0];Y.includes("REFRESH_TOKEN")&&(O=Y),(Y.includes("CLIENT_ID")||Y.includes("APP_KEY"))&&(L=Y),(Y.includes("CLIENT_SECRET")||Y.includes("APP_SECRET"))&&(T=Y)}if(O&&L){var R=y.tokens[O]&&y.tokens[O].configured,V=y.tokens[L]&&y.tokens[L].configured,X=T&&y.tokens[T]&&y.tokens[T].configured,I="OAuth";return e.name==="gmail"||e.name==="gdrive"||e.name==="gcal"||e.name==="gtasks"?I="Google":e.name==="dropbox"?I="Dropbox":e.name==="freshbooks"&&(I="FreshBooks"),{provider:I,canConnect:V&&X&&!R,refreshConfigured:R,clientIdConfigured:V,clientSecretConfigured:X}}}}return null},[y,e.name]),b=h.useCallback(async function(){g(null),m(!0);try{if(x&&x.brokered){let ue=function(){C.current&&(clearInterval(C.current),C.current=null)};var A=await fP(e.name),j=600,D=700,P=(window.screen.width-j)/2,q=(window.screen.height-D)/2,O=window.open(A.authorizeUrl,"oauth_popup","width="+j+",height="+D+",left="+P+",top="+q+",scrollbars=yes");if(!O){g("Popup blocked. Please allow popups or visit: "+A.authorizeUrl),m(!1);return}var L=A.flowId,T=0,M=0;C.current=setInterval(async function(){T+=1500;try{var J=await gP(e.name,L);if(J&&J.connected){ue();try{O.close()}catch{}m(!1),n();return}}catch(ge){ue(),g(ge.message),m(!1);return}if(O.closed&&(M||(M=T),T-M>9e3)){ue(),m(!1),n();return}T>3e5&&(ue(),m(!1),g("Connection timed out. Please try again."))},1500);return}var U=await dP(e.name),Y=600,R=700,V=(window.screen.width-Y)/2,X=(window.screen.height-R)/2,I=window.open(U.authorizeUrl,"oauth_popup","width="+Y+",height="+R+",left="+V+",top="+X+",scrollbars=yes");if(I)var H=setInterval(function(){I.closed&&(clearInterval(H),m(!1),n())},500);else g("Popup blocked. Please allow popups or visit: "+U.authorizeUrl),m(!1)}catch(ue){g(ue.message),m(!1)}},[e.name,n,x]),k=h.useCallback(async function(){g(null),d(!0);try{for(var A=Object.create(null),j=Object.keys(i),D=0;D<j.length;D++){var P=j[D];i[P]&&i[P].trim()&&(A[P]=i[P].trim())}if(Object.keys(A).length===0){g(r("skills.enter_token")),d(!1);return}await oP(e.name,A),n()}catch(q){g(q.message)}finally{d(!1)}},[i,e.name,n,r]),S=h.useCallback(async function(){if(await a({title:r("skills.clear_title"),message:r("skills.clear_confirm",{skill:e.name}),destructive:!0})){g(null),d(!0);try{await lP(e.name),n()}catch(A){g(A.message)}finally{d(!1)}}},[e.name,n,a,r]),E=h.useCallback(function(A,j){s(function(D){var P=Object.assign(Object.create(null),D);return P[A]=j,P})},[]),_=y&&!(y.oauth&&y.oauth.broker)?Object.entries(y.tokens||{}).map(function(A){var j=A[0],D=A[1],P=D&&D.env||j;return{name:j,env:P,description:D.description,configured:D.configured,maskedValue:D.maskedValue}}):[],w=h.useRef(null);h.useEffect(function(){function A(j){j.key==="Escape"&&t()}return document.addEventListener("keydown",A),w.current&&w.current.focus(),function(){document.removeEventListener("keydown",A)}},[t]);var C=h.useRef(null);return h.useEffect(function(){return function(){C.current&&(clearInterval(C.current),C.current=null)}},[]),o.jsx("div",{ref:w,tabIndex:-1,className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:t,role:"dialog","aria-modal":"true","aria-label":r("skills.configure_skill",{skill:e.name}),children:o.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-xl shadow-2xl w-full max-w-lg mx-4 p-6",onClick:function(A){A.stopPropagation()},children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:r("skills.configure_skill",{skill:e.name})}),o.jsx("button",{onClick:t,className:"p-1 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-400","aria-label":r("skills.close_credential_editor"),children:o.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),l&&o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx("div",{className:"w-6 h-6 border-2 border-primary-500 border-t-transparent rounded-full animate-spin"})}),!l&&_.length>0&&o.jsx("div",{className:"space-y-3 mb-4",children:_.map(function(A){return o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[A.env,A.configured&&o.jsxs("span",{className:"ml-2 text-xs text-green-600 dark:text-green-400",children:["(",r("skills.current_value",{value:A.maskedValue}),")"]})]}),A.description&&o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:A.description}),o.jsx("input",{type:"password",placeholder:A.configured?r("skills.leave_blank"):r("skills.enter_value"),value:i[A.env]||"",onChange:function(j){E(A.env,j.target.value)},className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 placeholder-gray-400"})]},A.env)})}),!l&&x&&o.jsx("div",{className:"mb-4 p-4 bg-gray-50 dark:bg-gray-800/50 rounded-lg border border-gray-200 dark:border-gray-700",children:x.canConnect?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:r("skills.oauth_connect_hint",{provider:x.provider})}),o.jsx("button",{onClick:b,disabled:p||u,className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 bg-primary-500 hover:bg-primary-600 text-white font-medium rounded-lg disabled:opacity-50 transition-colors",children:p?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),r("skills.oauth_connecting")]}):o.jsxs(o.Fragment,{children:[o.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),r("skills.oauth_connect",{provider:x.provider})]})})]}):x.refreshConfigured?o.jsxs("div",{className:"space-y-3",children:[o.jsxs("p",{className:"text-sm text-green-600 dark:text-green-400 flex items-center gap-2",children:[o.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),r("skills.oauth_connected",{provider:x.provider})]}),o.jsx("button",{onClick:S,disabled:u,className:"text-sm text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 disabled:opacity-50",children:r("skills.oauth_disconnect",{provider:x.provider})})]}):o.jsx("p",{className:"text-sm text-amber-600 dark:text-amber-400",children:r("skills.oauth_needs_credentials",{provider:x.provider})})}),!l&&!f&&_.length===0&&!x&&o.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 py-4",children:r("skills.no_credentials_needed")}),f&&o.jsx("p",{className:"text-sm text-red-600 dark:text-red-400 mb-3",children:f}),!l&&_.length>0&&o.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-gray-200 dark:border-gray-700",children:[o.jsx("button",{onClick:S,disabled:u,className:"text-sm text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 disabled:opacity-50",children:r("skills.clear_all")}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("button",{onClick:t,className:"px-3 py-1.5 text-sm text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg",children:r("skills.cancel")}),o.jsx("button",{onClick:k,disabled:u,className:"px-4 py-1.5 text-sm font-medium bg-primary-500 hover:bg-primary-600 text-white rounded-lg disabled:opacity-50 transition-colors",children:r(u?"skills.saving":"skills.save")})]})]})]})})}function iJ({skill:e,installed:t,updateInfo:n,updatingSkill:r,onConfigure:a,onInstall:i,onUpdate:s,onUninstall:l,skillDefaultEnabled:c,onToggleDefault:u,t:d}){var f=nJ(e.name),g=Object.prototype.hasOwnProperty.call(ij,e.name)?ij[e.name]:"#6B7280",[p,m]=h.useState(!1),y=r===e.name,v=n&&n.hasUpdate,x=h.useCallback(async function(){m(!0);try{await i(e)}finally{m(!1)}},[e,i]),b=h.useCallback(function(){s&&s(e.name)},[e.name,s]);return o.jsxs("div",{className:"group relative bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-xl p-4 hover:shadow-md dark:hover:shadow-gray-800/50 transition-all flex flex-col",children:[o.jsx("div",{className:"absolute top-0 left-4 right-4 h-0.5 rounded-full",style:{backgroundColor:g}}),o.jsxs("div",{className:"flex items-start gap-3 mt-1 flex-1",children:[o.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center flex-shrink-0",style:{backgroundColor:g+"15"},children:o.jsx(f,{className:"w-5 h-5",style:{color:g}})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[o.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 truncate",children:e.name}),o.jsx(rJ,{installed:t,configured:t&&e.allTokensConfigured,t:d}),t&&v&&o.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400",children:[o.jsx("svg",{className:"w-3 h-3 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"v",n.latestVersion]}),t&&n&&!v&&o.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400",children:d("skills.up_to_date")})]}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 line-clamp-2",children:e.description||d("skills.no_description")}),e.version&&o.jsxs("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:["v",e.version]})]})]}),o.jsx("div",{className:"mt-auto pt-3 flex items-center gap-2",children:t?o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:function(){a(e)},className:"flex-1 px-3 py-1.5 text-xs font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-lg transition-colors",children:d("skills.configure")}),u&&o.jsxs("button",{onClick:function(){u(e.name,!c)},title:d("skills.default_for_new_sessions"),className:"px-2 py-1.5 text-xs font-medium rounded-lg transition-colors flex items-center gap-1 "+(c?"text-primary-600 dark:text-primary-400 bg-primary-50 dark:bg-primary-900/20 hover:bg-primary-100 dark:hover:bg-primary-900/40":"text-gray-400 dark:text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-800"),children:[o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:c?o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"}):o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),d("skills.default")]}),v&&o.jsx("button",{onClick:b,disabled:y,className:"px-3 py-1.5 text-xs font-medium text-white bg-primary-500 hover:bg-primary-600 rounded-lg transition-colors disabled:opacity-50",children:y?o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx("svg",{className:"w-3 h-3 animate-spin",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),d("skills.updating")]}):d("skills.update")}),l&&o.jsx("button",{onClick:function(){l(e)},title:d("skills.uninstall"),className:"px-2 py-1.5 text-xs font-medium text-gray-400 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors","aria-label":d("skills.uninstall"),children:o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]}):o.jsx("button",{onClick:x,disabled:p,className:"flex-1 px-3 py-1.5 text-xs font-medium text-white bg-primary-500 hover:bg-primary-600 rounded-lg transition-colors disabled:opacity-50",children:p?o.jsxs("span",{className:"flex items-center justify-center gap-1",children:[o.jsx("svg",{className:"w-3 h-3 animate-spin",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),d("skills.installing")]}):d("skills.install")})})]})}function sJ({onBack:e}){var{t}=Tt(),[n,r]=h.useState([]),[a,i]=h.useState([]),[s,l]=h.useState(!0),[c,u]=h.useState(null),[d,f]=h.useState(null),[g,p]=h.useState("all"),[m,y]=h.useState(""),[v,x]=h.useState(!1),[b,k]=h.useState(Object.create(null)),[S,E]=h.useState(null),[_,w]=h.useState(!1),[C,A]=h.useState(Object.create(null)),j=bc(),D=h.useCallback(async function(){l(!0),u(null),w(!1);try{var H=await Promise.allSettled([Hv(),nP(),U5()]),ue=H[0].status==="fulfilled"?H[0].value:[],J=H[1].status==="fulfilled"?H[1].value:[],ge=H[2].status==="fulfilled"?H[2].value.skillDefaults||{}:{};r(ue),i(J),A(ge);var K=[];H[0].status==="rejected"&&K.push(t("skills.load_installed_failed",{error:H[0].reason.message})),H[1].status==="rejected"&&K.push(t("skills.load_marketplace_failed",{error:H[1].reason.message})),K.length>0&&u(K.join("; "))}catch(he){u(he.message)}finally{l(!1)}},[t]);h.useEffect(function(){D()},[D]);var P=[],q=new Set(n.map(function(H){return H.name}));n.forEach(function(H){P.push(Object.assign({},H,{_installed:!0}))}),a.forEach(function(H){q.has(H.name)||P.push(Object.assign({},H,{_installed:!1,allTokensConfigured:!1}))});var O=P;if(g==="installed"?O=P.filter(function(H){return H._installed}):g==="available"&&(O=P.filter(function(H){return!H._installed})),m){var L=m.toLowerCase();O=O.filter(function(H){return H.name&&H.name.toLowerCase().indexOf(L)!==-1||H.description&&H.description.toLowerCase().indexOf(L)!==-1||H.category&&H.category.toLowerCase().indexOf(L)!==-1})}var T=h.useCallback(async function(H){try{await aP(H.name),D()}catch(ue){u(t("skills.install_failed",{error:ue.message}))}},[D,t]),M=h.useCallback(function(H){f(H)},[]),U=h.useCallback(async function(H){if(await j({title:t("skills.uninstall_title"),message:t("skills.uninstall_confirm",{skill:H.name}),destructive:!0,confirmLabel:t("skills.uninstall")}))try{await cP(H.name),D()}catch(ue){u(t("skills.uninstall_failed",{error:ue.message}))}},[D,j,t]),Y=h.useCallback(function(){f(null),D()},[D]),R=h.useCallback(async function(H,ue){A(function(ge){var K=Object.assign({},ge);return ue?K[H]=!0:delete K[H],K});try{var J={};J[H]=ue,await uP(J)}catch(ge){A(function(K){var he=Object.assign({},K);return ue?delete he[H]:he[H]=!0,he}),u(ge.message)}},[]),V=h.useCallback(async function(){x(!0),u(null);try{var H=await sP(),ue=Object.create(null);(H.skills||[]).forEach(function(J){ue[J.name]={hasUpdate:J.hasUpdate,latestVersion:J.latestVersion,currentVersion:J.currentVersion}}),k(ue),w(!0)}catch(J){u(J.message)}finally{x(!1)}},[]),X=h.useCallback(async function(H){E(H),u(null);try{var ue=await iP(H);ue.updated&&(k(function(J){var ge=Object.assign(Object.create(null),J);return ge[H]={hasUpdate:!1,latestVersion:J[H]?J[H].latestVersion:null,currentVersion:J[H]?J[H].currentVersion:null},ge}),D())}catch(J){u(t("skills.update_failed")+": "+J.message)}finally{E(null)}},[D,t]),I=Object.values(b).filter(function(H){return H&&H.hasUpdate}).length;return o.jsxs("div",{className:"h-full flex flex-col bg-white dark:bg-gray-950 min-h-0",children:[o.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-800",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("button",{onClick:e,className:"p-1.5 rounded-lg text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors","aria-label":t("skills.back_to_chat"),children:o.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.5 19.5L3 12m0 0l7.5-7.5M3 12h18"})})}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:t("skills.skill_management")}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:t("skills.installed_count",{installed:n.length,available:a.filter(function(H){return!q.has(H.name)}).length})})]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("button",{onClick:V,disabled:v||s,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-gray-600 dark:text-gray-300 bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-lg transition-colors disabled:opacity-50",children:v?o.jsxs(o.Fragment,{children:[o.jsx("svg",{className:"w-3.5 h-3.5 animate-spin",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),t("skills.checking_updates")]}):o.jsxs(o.Fragment,{children:[o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),t("skills.check_updates")]})}),I>0&&o.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400 rounded-full",children:t("skills.updates_available",{count:I})}),_&&I===0&&!v&&o.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 rounded-full",children:t("skills.no_updates")}),o.jsx("div",{className:"flex items-center gap-1 bg-gray-100 dark:bg-gray-800 rounded-lg p-0.5",children:["all","installed","available"].map(function(H){return o.jsx("button",{onClick:function(){p(H)},className:"px-3 py-1 text-xs font-medium rounded-md transition-colors "+(g===H?"bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 shadow-sm":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),children:t("skills.tab_"+H)},H)})})]})]}),o.jsx("div",{className:"flex-shrink-0 px-6 py-3 border-b border-gray-100 dark:border-gray-800/50",children:o.jsxs("div",{className:"relative",children:[o.jsx("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),o.jsx("input",{type:"text",placeholder:t("skills.search_placeholder"),value:m,onChange:function(H){y(H.target.value)},className:"w-full pl-10 pr-4 py-2 text-sm bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg text-gray-900 dark:text-gray-100 placeholder-gray-400 outline-none focus:ring-2 focus:ring-primary-500/30 focus:border-primary-500"})]})}),o.jsxs("div",{className:"flex-1 overflow-y-auto overflow-x-hidden p-6 min-h-0",children:[s&&o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx("div",{className:"w-8 h-8 border-2 border-primary-500 border-t-transparent rounded-full animate-spin"})}),c&&o.jsx("div",{className:"mb-4 p-3 bg-red-50 dark:bg-red-900/20 rounded-lg border border-red-200 dark:border-red-800",children:o.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:c})}),!s&&O.length===0&&o.jsx("div",{className:"text-center py-12",children:o.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:t(m?"skills.no_match":"skills.no_skills")})}),!s&&O.length>0&&o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:O.map(function(H){return o.jsx(iJ,{skill:H,installed:H._installed,updateInfo:b[H.name],updatingSkill:S,onConfigure:M,onInstall:T,onUpdate:X,onUninstall:H._installed?U:null,skillDefaultEnabled:!!C[H.name],onToggleDefault:H._installed?R:null,t},H.name)})})]}),d&&o.jsx(aJ,{skill:d,onClose:function(){f(null)},onSaved:Y})]})}const Xt="";function Qt(e,t={}){return fetch(e,{credentials:"include",...t})}async function oJ(){const e=await Qt(Xt+"/api/agents");if(!e.ok)throw new Error("Failed to fetch agents: "+e.statusText);return e.json()}async function lJ(e){const t=await Qt(Xt+"/api/agents/"+encodeURIComponent(e));if(!t.ok)throw new Error("Failed to fetch agent: "+t.statusText);return t.json()}async function Hb(e){const t=await Qt(Xt+"/api/agents/"+encodeURIComponent(e)+"/start",{method:"POST"});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||"Failed to start agent")}return t.json()}async function qb(e){const t=await Qt(Xt+"/api/agents/"+encodeURIComponent(e)+"/stop",{method:"POST"});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||"Failed to stop agent")}return t.json()}async function $d(e,t){const n={};t&&t.clean&&(n.clean=!0);const r=await Qt(Xt+"/api/agents/"+encodeURIComponent(e)+"/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok){const a=await r.json().catch(()=>({}));throw new Error(a.error||"Failed to restart agent")}return r.json()}async function Wb(e,t){const n={};t&&t.level&&(n.level=t.level),t&&t.span&&(n.span=t.span);const r=await Qt(Xt+"/api/agents/"+encodeURIComponent(e)+"/pause",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok){const a=await r.json().catch(()=>({}));throw new Error(a.error||"Failed to pause agent")}return r.json()}async function Vb(e){const t=await Qt(Xt+"/api/agents/"+encodeURIComponent(e)+"/unpause",{method:"POST"});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||"Failed to unpause agent")}return t.json()}async function cJ(e,t,n,r){const a={message:t,priority:n};r!=null&&(a.replyToInbox=r);const i=await Qt(Xt+"/api/agents/"+encodeURIComponent(e)+"/inbox",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.error||"Failed to send message to agent")}return i.json()}async function uJ(e,t,n){const r={message:t};n!=null&&(r.replyToInbox=n);const a=await Qt(Xt+"/api/agents/"+encodeURIComponent(e)+"/interrupt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({}));throw new Error(i.error||"Failed to send urgent interrupt to agent")}return a.json()}async function dJ(e,t){let n=Xt+"/api/agents/"+encodeURIComponent(e)+"/messages";t&&t.refresh&&(n+="?refresh=true");const r=await Qt(n);if(!r.ok)throw new Error("Failed to fetch agent messages: "+r.statusText);return r.json()}async function fJ(){const e=await Qt(Xt+"/api/pricing");if(!e.ok)throw new Error("Failed to fetch pricing: "+e.statusText);return e.json()}async function gJ(e){const t=await Qt(Xt+"/api/pricing",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||"Failed to update pricing")}return t.json()}async function pJ(){const e=await Qt(Xt+"/api/pricing/reset",{method:"POST"});if(!e.ok){const t=await e.json().catch(()=>({}));throw new Error(t.error||"Failed to reset pricing")}return e.json()}async function hJ(e,t=!1){const n=Xt+"/api/agents/"+encodeURIComponent(e)+(t?"?force=true":""),r=await Qt(n,{method:"DELETE"});if(!r.ok){const a=await r.json().catch(()=>({}));throw new Error(a.error||"Failed to delete agent")}return r.json()}async function mJ(e){const t=await Qt(Xt+"/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||"Failed to create agent")}return t.json()}async function L3(){const e=await Qt(Xt+"/api/skills");if(!e.ok)throw new Error("Failed to fetch skills: "+e.statusText);return e.json()}async function Q1(){const e=await Qt(Xt+"/api/models");if(!e.ok)throw new Error("Failed to fetch models: "+e.statusText);return e.json()}async function xJ(e,t){const n=await Qt(Xt+"/api/agents/"+encodeURIComponent(e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||"Failed to update agent")}return n.json()}async function yJ(e){const t=await Qt(Xt+"/api/agents/"+encodeURIComponent(e)+"/agents-md");if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||"Failed to fetch AGENTS.md")}return t.json()}async function bJ(e,t){const n=await Qt(Xt+"/api/agents/"+encodeURIComponent(e)+"/agents-md",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||"Failed to update AGENTS.md")}return n.json()}async function O3(e){const t=await Qt(Xt+"/api/agents/"+encodeURIComponent(e)+"/export");if(!t.ok){const l=await t.json().catch(()=>({}));throw new Error(l.error||"Failed to export agent")}const n=await t.text(),r=new Blob([n],{type:"text/yaml"}),a=URL.createObjectURL(r),i=t.headers.get("X-Filename")||e+".agent.yaml",s=document.createElement("a");s.href=a,s.download=i,document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>URL.revokeObjectURL(a),5e3)}async function vJ(e,t){const n=new URLSearchParams,r=n.toString()?"?"+n.toString():"",a=await Qt(Xt+"/api/agents/import"+r,{method:"POST",headers:{"Content-Type":"text/yaml"},body:e});if(!a.ok){const i=await a.json().catch(()=>({}));throw new Error(i.error||"Failed to import agent")}return a.json()}async function dy(){const e=await Qt(Xt+"/api/system/updates");if(!e.ok){const t="Failed to check for updates",n=await e.json().catch(()=>({})),r=n.error||n.message||n.output||e.statusText;throw r?r.indexOf(t)===0||r===t?new Error(r):new Error(t+": "+r):new Error(t)}return e.json()}async function kJ(){const e=await Qt(Xt+"/api/system/update",{method:"POST"});if(!e.ok){const n="Failed to perform update",r=await e.json().catch(()=>({})),a=r.error||r.message||r.output||e.statusText;throw a?a.indexOf(n)===0||a===n?new Error(a):new Error(n+": "+a):new Error(n)}const t=await e.json();if(t.status!=="success"){let n=t.error||t.message||"";throw t.output&&!t.error&&!t.message?n="Update returned status: "+(t.status||"failed")+(t.output?": "+t.output:""):t.output&&(n+=t.output?" ("+t.output+")":""),n||(n="Update returned unexpected status: "+(t.status||"unknown")),new Error(n)}return t}async function sj(){const e=await Qt(Xt+"/api/models/registry");if(!e.ok)throw new Error("Failed to fetch model registry: "+e.statusText);return e.json()}async function oj(e,t){const n=await Qt(Xt+"/api/models/registry",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||"Failed to save model: "+n.statusText)}return n.json()}async function lj(e){const t=await Qt(Xt+"/api/models/registry/"+encodeURIComponent(e),{method:"DELETE"});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||"Failed to delete model: "+t.statusText)}return t.json()}function D3(e){const t=typeof e=="string"?e.split("-"):null;if(t&&t.length===3){const n=Number(t[0]),r=Number(t[1]),a=Number(t[2]);if(!Number.isNaN(n)&&!Number.isNaN(r)&&!Number.isNaN(a))return new Date(n,r-1,a)}return new Date(e)}function _J(e){const t=D3(e),n=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return n[t.getDay()]+", "+r[t.getMonth()]+" "+t.getDate()}function Ru(e){return e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(1)+"K":e.toString()}function wJ({data:e}){if(!e||e.length===0)return o.jsx("div",{className:"h-32 flex items-center justify-center text-sm text-gray-400 dark:text-gray-500",children:"No usage data available"});const t=280,n=120,r={top:10,right:10,bottom:25,left:40},a=t-r.left-r.right,i=n-r.top-r.bottom,s=Math.max(...e.map(g=>(g.input||0)+(g.output||0)+(g.cached||0)),1),l=a/e.length,c=Math.max(8,l*.6),u=(l-c)/2,d=g=>i-g/s*i,f=[0,.25,.5,.75,1].map(g=>Math.round(s*g));return o.jsxs("div",{className:"relative",children:[o.jsxs("svg",{width:"100%",height:n,viewBox:`0 0 ${t} ${n}`,className:"overflow-visible",children:[f.map((g,p)=>{const m=r.top+d(g);return o.jsxs("g",{children:[o.jsx("line",{x1:r.left,y1:m,x2:t-r.right,y2:m,stroke:"currentColor",strokeOpacity:.1,className:"text-gray-400 dark:text-gray-600"}),o.jsx("text",{x:r.left-5,y:m,textAnchor:"end",dominantBaseline:"middle",className:"text-[9px] fill-gray-400 dark:fill-gray-500",children:Ru(g)})]},p)}),e.map((g,p)=>{const m=r.left+p*l+u,y=g.input||0,v=g.output||0,x=g.cached||0,b=y/s*i,k=v/s*i,S=x/s*i,E=r.top+i-b,_=E-k,w=_-S,C=D3(g.date),A=["S","M","T","W","T","F","S"][C.getDay()];return o.jsxs("g",{className:"group",children:[o.jsx("rect",{x:m-u,y:r.top,width:l,height:i,fill:"transparent",className:"cursor-pointer"}),y>0&&o.jsx("rect",{x:m,y:E,width:c,height:b,rx:2,className:"fill-blue-500 dark:fill-blue-400 transition-opacity group-hover:opacity-80"}),v>0&&o.jsx("rect",{x:m,y:_,width:c,height:k,rx:2,className:"fill-green-500 dark:fill-green-400 transition-opacity group-hover:opacity-80"}),x>0&&o.jsx("rect",{x:m,y:w,width:c,height:S,rx:2,className:"fill-purple-500 dark:fill-purple-400 transition-opacity group-hover:opacity-80"}),o.jsx("text",{x:m+c/2,y:n-5,textAnchor:"middle",className:"text-[9px] fill-gray-400 dark:fill-gray-500",children:A}),o.jsxs("g",{className:"opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none",children:[o.jsx("rect",{x:m+c/2-45,y:Math.min(w,_,E)-50,width:90,height:45,rx:4,className:"fill-gray-900 dark:fill-gray-100"}),o.jsx("text",{x:m+c/2,y:Math.min(w,_,E)-38,textAnchor:"middle",className:"text-[9px] fill-white dark:fill-gray-900 font-medium",children:_J(g.date)}),o.jsxs("text",{x:m+c/2,y:Math.min(w,_,E)-26,textAnchor:"middle",className:"text-[8px] fill-blue-300 dark:fill-blue-600",children:["In: ",Ru(y)]}),o.jsxs("text",{x:m+c/2,y:Math.min(w,_,E)-16,textAnchor:"middle",className:"text-[8px] fill-green-300 dark:fill-green-600",children:["Out: ",Ru(v)]}),o.jsxs("text",{x:m+c/2,y:Math.min(w,_,E)-6,textAnchor:"middle",className:"text-[8px] fill-purple-300 dark:fill-purple-600",children:["Cache: ",Ru(x)]})]})]},p)})]}),o.jsxs("div",{className:"flex items-center justify-center gap-4 mt-2 text-xs",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("div",{className:"w-2 h-2 rounded-sm bg-blue-500 dark:bg-blue-400"}),o.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Input"})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("div",{className:"w-2 h-2 rounded-sm bg-green-500 dark:bg-green-400"}),o.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Output"})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("div",{className:"w-2 h-2 rounded-sm bg-purple-500 dark:bg-purple-400"}),o.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Cached"})]})]})]})}function EJ({agentName:e,onClose:t,onToolPartsChange:n,hackerMode:r}){var{t:a}=Tt(),[i,s]=h.useState([]),[l,c]=h.useState(!0),[u,d]=h.useState(null),[f,g]=h.useState(!1),[p,m]=h.useState(""),[y,v]=h.useState(!0),[x,b]=h.useState(!1),[k,S]=h.useState(!1),[E,_]=h.useState(!1),[w,C]=h.useState(!1),A=h.useRef(null),j=h.useRef(null),D=h.useRef(!0),P=h.useRef([]),q=h.useRef(null),O=h.useRef(null),L=h.useRef(null),T=h.useRef(null);h.useEffect(function(){P.current=i},[i]);var M=h.useCallback(async function(J,ge){if(e){ge!==!1&&c(!0);try{var K=await dJ(e,{refresh:!!J}),he=K.messages||[],Me=P.current,Te=he.length!==Me.length;if(!Te&&he.length>0&&Me.length>0){var Ae=he[he.length-1],Pe=Me[Me.length-1];if(Ae.info.id!==Pe.info.id&&(Te=!0),!Te){var be=Ae.parts||[],de=Pe.parts||[];if(be.length!==de.length)Te=!0;else for(var pe=0;pe<be.length&&!Te;pe++){var Oe=be[pe]||{},me=de[pe]||{},ee=Oe.state?Oe.state.status:Oe.status,Re=me.state?me.state.status:me.status;(Oe.id!==me.id||ee!==Re)&&(Te=!0)}}}Te&&s(he.slice()),d(null)}catch(fe){console.error("Failed to load messages:",fe),d(fe.message)}finally{ge!==!1&&c(!1)}}},[e]);h.useEffect(function(){M(!0);var J=setInterval(function(){M(!0,!1)},5e3);return function(){clearInterval(J),O.current&&clearTimeout(O.current),T.current&&clearTimeout(T.current)}},[M]),h.useEffect(function(){D.current&&A.current&&A.current.scrollIntoView({behavior:"smooth"})},[i]);var U=h.useCallback(function(){var J=j.current;J&&(D.current=J.scrollHeight-J.scrollTop-J.clientHeight<50)},[]),Y=h.useMemo(function(){for(var J=null,ge=i.length-1;ge>=0;ge--)if(i[ge].info&&i[ge].info.role==="assistant"){J=i[ge];break}return J?(J.parts||[]).filter(function(K){return K.type==="tool"}):[]},[i]);h.useEffect(function(){n&&n(Y)},[Y,n]);var R=h.useCallback(async function(){if(!(!p.trim()||x)){b(!0),S(!1),_(!1),C(!1),d(null);try{await cJ(e,p.trim(),"normal",y),m(""),S(!0),O.current&&clearTimeout(O.current),O.current=setTimeout(function(){S(!1),g(!1),O.current=null},1500),T.current&&clearTimeout(T.current),T.current=setTimeout(function(){M(!0,!1),T.current=null},500)}catch(J){d(J.message)}finally{b(!1)}}},[e,p,y,x,M]),V=h.useCallback(async function(){if(!(!p.trim()||x)){if(!w){C(!0);return}b(!0),S(!1),_(!0),C(!1),d(null);try{await uJ(e,p.trim(),y),m(""),S(!0),O.current&&clearTimeout(O.current),O.current=setTimeout(function(){S(!1),g(!1),O.current=null},1500),T.current&&clearTimeout(T.current),T.current=setTimeout(function(){M(!0,!1),T.current=null},500)}catch(J){d(J.message)}finally{b(!1)}}},[e,p,x,w,y,M]),X=h.useCallback(function(){g(!1),C(!1),d(null),O.current&&(clearTimeout(O.current),O.current=null),T.current&&(clearTimeout(T.current),T.current=null),S(!1)},[]);h.useEffect(function(){if(!f)return;function J(ge){ge.key==="Escape"&&!x&&X()}return document.addEventListener("keydown",J),function(){document.removeEventListener("keydown",J)}},[f,X,x]),h.useEffect(function(){if(!(!f||!L.current)){var J=L.current;J.contains(document.activeElement)||J.focus()}},[f]);var I=h.useCallback(function(J){J.target===J.currentTarget&&!x&&X()},[X,x]),H=h.useCallback(function(J){J.key==="Enter"&&!J.shiftKey&&!w&&(J.preventDefault(),R())},[R,w]),ue=h.useCallback(function(){},[]);return o.jsxs("div",{className:"h-full flex flex-col bg-white dark:bg-gray-900 relative",children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-gray-800",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-500 dark:text-gray-400 transition-colors",title:a("agents.back"),children:o.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Conversation"}),o.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:[e," - ",i.length," messages"]})]})]}),o.jsx("button",{onClick:function(){D.current=!0,M(!0),A.current&&A.current.scrollIntoView({behavior:"smooth"})},disabled:l,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-400 transition-colors disabled:opacity-50",title:a("agents.refresh"),children:o.jsx("svg",{className:`w-4 h-4 ${l?"animate-spin":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]}),u&&o.jsxs("div",{className:"mx-4 mt-3 px-4 py-2 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 text-sm rounded-lg flex items-center justify-between",children:[o.jsx("span",{children:u}),o.jsx("button",{onClick:function(){d(null)},className:"ml-2 text-red-400 hover:text-red-600",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),k&&o.jsxs("div",{className:`mx-4 mt-3 px-4 py-2 text-sm rounded-lg flex items-center gap-2 ${E?"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400":"bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400"}`,children:[o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:E?o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13 10V3L4 14h7v7l9-11h-7z"}):o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),a(E?"agent_conversation.interrupt_sent":"agent_conversation.message_queued")]}),o.jsx("div",{ref:j,onScroll:U,className:"flex-1 overflow-y-auto px-4 py-4",children:l&&i.length===0?o.jsx("div",{className:"flex items-center justify-center h-32",children:o.jsx("div",{className:"w-6 h-6 border-2 border-primary-500 border-t-transparent rounded-full animate-spin"})}):i.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center h-32 text-center",children:[o.jsx("div",{className:"w-12 h-12 rounded-xl bg-gray-100 dark:bg-gray-800 flex items-center justify-center mb-3",children:o.jsx("svg",{className:"w-6 h-6 text-gray-400 dark:text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})}),o.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:a("agent_conversation.no_messages")}),o.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1",children:a("agent_conversation.no_messages_hint")})]}):o.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[i.map(function(J){return o.jsx(cI,{message:J.info,parts:J.parts,streamingParts:null,searchQuery:null,matchOffset:-1,matchCount:0,activeMatchIndex:-1,registerMatchRef:ue,hackerMode:r,hideThinking:!1},J.info.id)}),o.jsx("div",{ref:A})]})}),o.jsx("div",{className:"absolute bottom-6 right-6",children:o.jsxs("button",{onClick:function(){g(!0),C(!1),d(null)},className:"px-4 py-2.5 bg-primary-500 hover:bg-primary-600 text-white rounded-full shadow-lg font-medium text-sm transition-colors flex items-center gap-2","aria-label":a("agent_conversation.compose_button"),children:[o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),a("agent_conversation.compose_button")]})}),f&&o.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/40 backdrop-blur-sm",onClick:I,children:o.jsxs("div",{ref:L,tabIndex:-1,role:"dialog","aria-modal":"true","aria-labelledby":"compose-modal-title",className:"bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700 shadow-xl w-full max-w-lg mx-4 max-h-[80vh] flex flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[o.jsx("h3",{id:"compose-modal-title",className:"text-base font-semibold text-gray-900 dark:text-white",children:a("agent_conversation.modal_title",{name:e})}),o.jsx("button",{onClick:X,disabled:x,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors"+(x?" opacity-50 cursor-not-allowed":""),"aria-label":a("common.close"),children:o.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),o.jsxs("div",{className:"px-5 py-4 space-y-4 overflow-y-auto flex-1 min-h-0",children:[o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:y,onChange:function(J){v(J.target.checked)},className:"w-4 h-4 rounded border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500"}),o.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:a("agent_conversation.reply_to_inbox")})]}),o.jsx("textarea",{ref:q,value:p,onChange:function(J){m(J.target.value)},onKeyDown:H,placeholder:a("agent_conversation.send_placeholder"),className:"w-full px-4 py-3 bg-gray-50 dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 outline-none resize-none text-sm text-gray-900 dark:text-gray-100 placeholder-gray-400 dark:placeholder-gray-500 focus:ring-2 focus:ring-primary-500 dark:focus:ring-primary-400 focus:border-transparent",rows:4,disabled:x,autoFocus:!0}),k&&o.jsx("p",{className:"text-sm text-green-600 dark:text-green-400 font-medium",children:a(E?"agent_conversation.interrupt_sent":"agent_conversation.message_queued")}),u&&o.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:u})]}),o.jsx("div",{className:"px-5 py-4 border-t border-gray-200 dark:border-gray-700 flex-shrink-0",children:w?o.jsxs("div",{className:"space-y-2",children:[o.jsx("p",{className:"text-xs text-red-500 dark:text-red-400 font-medium",children:a("agent_conversation.urgent_warning")}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("button",{onClick:function(){C(!1)},className:"px-3 py-1.5 text-xs text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 transition-colors",children:a("common.cancel")}),o.jsxs("button",{onClick:V,disabled:!p.trim()||x,className:"px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white rounded-lg disabled:opacity-50 disabled:cursor-not-allowed text-xs font-medium transition-colors flex items-center gap-1.5",children:[x&&E?o.jsx("div",{className:"w-3 h-3 border-2 border-white border-t-transparent rounded-full animate-spin"}):o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13 10V3L4 14h7v7l9-11h-7z"})}),a("agent_conversation.confirm_interrupt")]})]})]}):o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("button",{onClick:V,disabled:!p.trim()||x,className:"px-3 py-1.5 text-xs text-red-500 dark:text-red-400 hover:text-red-600 dark:hover:text-red-300 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center gap-1.5",children:[o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13 10V3L4 14h7v7l9-11h-7z"})}),a("agent_conversation.urgent_interrupt_button")]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("button",{onClick:X,disabled:x,className:"px-4 py-2 text-sm transition-colors"+(x?" text-gray-400 dark:text-gray-600 cursor-not-allowed":" text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200"),children:a("common.cancel")}),o.jsxs("button",{onClick:R,disabled:!p.trim()||x,className:"px-4 py-2 bg-primary-500 hover:bg-primary-600 text-white rounded-lg disabled:opacity-50 disabled:cursor-not-allowed font-medium text-sm transition-colors flex items-center gap-2",children:[x&&!E?o.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})}),a("agent_conversation.send_button")]})]})]})})]})})]})}function SJ({isOpen:e,agent:t,onClose:n,onUpdated:r,onDeleted:a}){const{t:i}=Tt(),[s,l]=h.useState(""),[c,u]=h.useState(""),[d,f]=h.useState(""),[g,p]=h.useState(""),[m,y]=h.useState(!1),[v,x]=h.useState([]),[b,k]=h.useState(!1),[S,E]=h.useState(""),[_,w]=h.useState(null),[C,A]=h.useState(!1),[j,D]=h.useState([]),[P,q]=h.useState([]),[O,L]=h.useState(!1),[T,M]=h.useState(!0),[U,Y]=h.useState(!1),[R,V]=h.useState(!1),[X,I]=h.useState(null),[H,ue]=h.useState(!1),[J,ge]=h.useState(!1),[K,he]=h.useState("general"),[Me,Te]=h.useState(!1);h.useEffect(()=>{const fe={cancelled:!1};if(e&&t&&!Me){Ae();const Ge=(typeof t.model=="string"?t.model.trim():t.model)||"github-copilot/claude-opus-4.6";Pe(fe,Ge),Te(!0)}return e||(Te(!1),y(!1),p(""),M(!0),q([])),()=>{fe.cancelled=!0}},[e,t==null?void 0:t.name]);const Ae=()=>{if(!t)return;l(t.displayName||t.name||""),u(t.cwd||"");const fe=(typeof t.model=="string"?t.model.trim():t.model)||"github-copilot/claude-opus-4.6";f(fe),y(!1),p(""),x(Array.isArray(t.skills)?t.skills:[]),k(!!t.skipInitialPrompt)},Pe=async(fe,Ge)=>{L(!0),M(!0),t!=null&&t.name&&Y(!0);const Se=[L3(),Q1()];t!=null&&t.name&&Se.push(yJ(t.name));const we=await Promise.allSettled(Se);if(fe.cancelled)return;const[qe,F,B]=we;if(qe.status==="fulfilled"?D(qe.value):(console.error("Failed to load skills:",qe.reason),D([])),L(!1),F.status==="fulfilled"){const W=F.value;q(W);const re=Ge;W.find(_e=>_e.id===re)||(y(!0),p(re),f(re))}else console.error("Failed to load models:",F.reason),q([]);if(M(!1),t!=null&&t.name&&B){if(B.status==="fulfilled"){const W=B.value;E(W.content||""),w(W.path||null),A(W.exists||!1)}else console.error("Failed to load AGENTS.md:",B.reason),E(""),w(null),A(!1);Y(!1)}},be=fe=>{x(Ge=>Ge.includes(fe)?Ge.filter(Se=>Se!==fe):[...Ge,fe])},de=()=>{v.length===j.length?x([]):x(j.map(fe=>fe.name))},pe=async fe=>{if(fe&&fe.preventDefault(),!!(t!=null&&t.name)){I(null),V(!0);try{await xJ(t.name,{displayName:s.trim()||t.name,workspace:c.trim(),model:d,skipInitialPrompt:b,skills:v}),_&&S!==null&&!Re&&await bJ(t.name,S),r&&r(t.name),n()}catch(Ge){I(Ge.message)}finally{V(!1)}}},Oe=async()=>{if(t!=null&&t.name){ge(!0),I(null);try{await hJ(t.name,!0),a&&a(t.name),n()}catch(fe){I(fe.message),ue(!1)}finally{ge(!1)}}},me=()=>{!R&&!J&&(I(null),ue(!1),he("general"),n())};if(!e||!t)return null;const ee=t.state==="working"||t.state==="idle"||t.state==="starting",Re=c.trim()!==(t.cwd||"");return o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[o.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:me}),H&&o.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4",children:[o.jsx("div",{className:"absolute inset-0 bg-black/30",onClick:()=>ue(!1)}),o.jsxs("div",{className:"relative bg-white dark:bg-gray-900 rounded-xl shadow-2xl max-w-md w-full p-6",children:[o.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-2",children:"Delete Agent?"}),o.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:["Are you sure you want to delete ",o.jsx("strong",{children:t.displayName||t.name}),"?",ee&&o.jsx("span",{className:"block mt-2 text-yellow-600 dark:text-yellow-400",children:"Warning: This agent is currently running and will be stopped."})]}),o.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-500 mb-4",children:"This will remove the agent registration. The workspace directory will not be deleted."}),o.jsxs("div",{className:"flex justify-end gap-3",children:[o.jsx("button",{onClick:()=>ue(!1),disabled:J,className:"px-4 py-2 rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors disabled:opacity-50",children:i("common.cancel")}),o.jsx("button",{onClick:Oe,disabled:J,className:"px-4 py-2 rounded-lg bg-red-600 hover:bg-red-700 text-white font-medium transition-colors disabled:opacity-50 flex items-center gap-2",children:J?o.jsxs(o.Fragment,{children:[o.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[o.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),o.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),i("common.deleting")]}):i("common.delete")})]})]})]}),o.jsxs("div",{className:"relative bg-white dark:bg-gray-900 rounded-2xl shadow-2xl max-w-2xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-800",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:i("agent_edit.title")}),o.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[t.name,ee&&o.jsxs("span",{className:"ml-2 text-yellow-600 dark:text-yellow-400",children:["(",i("agent_edit.running_warning"),")"]})]})]}),o.jsx("button",{onClick:me,disabled:R||J,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-400 transition-colors disabled:opacity-50",children:o.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),o.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-800 px-6",children:[o.jsx("button",{onClick:()=>he("general"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${K==="general"?"border-primary-500 text-primary-600 dark:text-primary-400":"border-transparent text-gray-500 hover:text-gray-700 dark:hover:text-gray-300"}`,children:i("agent_edit.tab_general")}),o.jsx("button",{onClick:()=>he("soul"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${K==="soul"?"border-primary-500 text-primary-600 dark:text-primary-400":"border-transparent text-gray-500 hover:text-gray-700 dark:hover:text-gray-300"}`,children:i("agent_edit.tab_soul")})]}),o.jsxs("form",{onSubmit:fe=>fe.preventDefault(),className:"flex-1 overflow-y-auto p-6 space-y-6",children:[X&&o.jsxs("div",{className:"px-4 py-3 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 text-sm rounded-lg flex items-center justify-between",children:[o.jsx("span",{children:X}),o.jsx("button",{type:"button",onClick:()=>I(null),className:"ml-2 text-red-400 hover:text-red-600",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),K==="general"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[i("agent_edit.name_label"),o.jsx("span",{className:"text-gray-400 font-normal ml-1",children:i("agent_edit.cannot_change")})]}),o.jsx("input",{type:"text",value:t.name,disabled:!0,className:"w-full px-4 py-2 rounded-lg bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-500 dark:text-gray-400 cursor-not-allowed font-mono"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:i("agent_edit.display_name_label")}),o.jsx("input",{type:"text",value:s,onChange:fe=>l(fe.target.value),placeholder:i("agent_edit.display_name_placeholder"),className:"w-full px-4 py-2 rounded-lg bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-primary-500"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:i("agent_edit.working_dir_label")}),ee?o.jsx("div",{className:"px-4 py-2 rounded-lg bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-500 dark:text-gray-400 font-mono text-sm break-all",children:c||i("agent_edit.not_set")}):o.jsx("input",{type:"text",value:c,onChange:fe=>u(fe.target.value),placeholder:i("agent_edit.working_dir_placeholder"),disabled:R||J,className:"w-full px-4 py-2 rounded-lg bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-primary-500 font-mono text-sm disabled:opacity-50"}),ee?o.jsx("p",{className:"mt-1 text-xs text-gray-400",children:i("agent_edit.stop_to_change")}):c.trim()!==(t.cwd||"")?o.jsx("p",{className:"mt-1 text-xs text-amber-500 dark:text-amber-400",children:i("agent_edit.workspace_move_warning")}):o.jsx("p",{className:"mt-1 text-xs text-gray-400",children:i("agent_edit.working_dir_hint")})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:i("agent_edit.model_label")}),T?o.jsx("div",{className:"w-full px-4 py-2 rounded-lg bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-400 text-sm",children:i("agent_edit.loading_models")}):P.length===0?o.jsx("input",{type:"text",value:d,onChange:fe=>f(fe.target.value),placeholder:i("agent_edit.model_placeholder"),className:"w-full px-4 py-2 rounded-lg bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-primary-500 font-mono text-sm"}):o.jsxs(o.Fragment,{children:[o.jsxs("select",{value:m?"__custom__":d,onChange:fe=>{fe.target.value==="__custom__"?(y(!0),d&&d!=="__custom__"&&p(d)):(y(!1),f(fe.target.value))},className:"w-full px-4 py-2 rounded-lg bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-primary-500",children:[(()=>{const fe=X1(P);return Object.entries(fe).map(([Ge,Se])=>o.jsx("optgroup",{label:K1[Ge]||Ge,children:Se.map(we=>o.jsxs("option",{value:we.id,children:[we.name,Y1(we.tier)]},we.id))},Ge))})(),o.jsx("option",{value:"__custom__",children:i("agent_edit.custom_model")})]}),m&&o.jsx("input",{type:"text",value:g,onChange:fe=>{p(fe.target.value),f(fe.target.value)},placeholder:i("agent_edit.custom_model_placeholder"),className:"w-full mt-2 px-4 py-2 rounded-lg bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-primary-500 font-mono text-sm"})]}),o.jsx("p",{className:"mt-1 text-xs text-gray-400",children:i(m?"agent_edit.custom_model_hint":"agent_edit.model_hint")})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:i("agent_edit.start_mode")}),o.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:b,onChange:fe=>k(fe.target.checked),className:"mt-0.5 rounded border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500"}),o.jsxs("div",{children:[o.jsx("span",{className:"text-sm text-gray-900 dark:text-gray-100",children:i("agent_edit.dormant_mode")}),o.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:i("agent_edit.dormant_mode_desc")})]})]})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:i("agent_edit.skills_label")}),o.jsx("button",{type:"button",onClick:de,className:"text-xs text-primary-600 dark:text-primary-400 hover:underline",children:v.length===j.length?i("agent_edit.deselect_all"):i("agent_edit.select_all")})]}),o.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg p-3 max-h-48 overflow-y-auto bg-gray-50 dark:bg-gray-800",children:O?o.jsx("div",{className:"text-center py-4 text-gray-500",children:i("agent_edit.loading_skills")}):j.length===0?o.jsx("div",{className:"text-center py-4 text-gray-500",children:i("agent_edit.no_skills")}):o.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2",children:j.map(fe=>o.jsxs("label",{className:`flex items-center gap-2 px-3 py-2 rounded-lg cursor-pointer transition-colors ${v.includes(fe.name)?"bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-300":"hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:[o.jsx("input",{type:"checkbox",checked:v.includes(fe.name),onChange:()=>be(fe.name),className:"rounded border-gray-300 text-primary-600 focus:ring-primary-500"}),o.jsxs("span",{className:"text-sm truncate",title:fe.description,children:[fe.icon&&o.jsx("span",{className:"mr-1",children:fe.icon}),fe.name]})]},fe.name))})}),o.jsx("p",{className:"mt-1 text-xs text-gray-400",children:i("agent_edit.skills_selected",{count:v.length})})]})]}),K==="soul"&&o.jsxs("div",{className:"space-y-4",children:[_&&o.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono bg-gray-50 dark:bg-gray-800 rounded px-3 py-2",children:[_,!C&&o.jsx("span",{className:"ml-2 text-yellow-600 dark:text-yellow-400",children:i("agent_edit.will_be_created")})]}),!_&&!c.trim()&&o.jsx("div",{className:"px-4 py-3 bg-yellow-50 dark:bg-yellow-900/20 text-yellow-700 dark:text-yellow-400 text-sm rounded-lg",children:i("agent_edit.no_workspace_warning")}),Re&&o.jsx("div",{className:"px-4 py-3 bg-amber-50 dark:bg-amber-900/20 text-amber-700 dark:text-amber-400 text-sm rounded-lg",children:i("agent_edit.workspace_changed_warning")}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:i("agent_edit.instructions_label")}),o.jsx("textarea",{value:S,onChange:fe=>E(fe.target.value),disabled:!_||Re,rows:16,placeholder:i(U?"common.loading":"agent_edit.soul_placeholder"),className:"w-full px-4 py-3 rounded-lg bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-primary-500 font-mono text-sm resize-none disabled:cursor-not-allowed disabled:opacity-50"}),o.jsx("p",{className:"mt-1 text-xs text-gray-400",children:i("agent_edit.instructions_hint")})]})]})]}),o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900",children:[o.jsxs("button",{type:"button",onClick:()=>ue(!0),disabled:R||J,className:"px-4 py-2 rounded-lg text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors disabled:opacity-50 flex items-center gap-2",children:[o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})}),i("common.delete")]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("button",{type:"button",onClick:me,disabled:R||J,className:"px-4 py-2 rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors disabled:opacity-50",children:i("common.cancel")}),o.jsx("button",{type:"button",onClick:pe,disabled:R||J,className:"px-6 py-2 rounded-lg bg-primary-600 hover:bg-primary-700 text-white font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:R?o.jsxs(o.Fragment,{children:[o.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[o.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),o.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),i("agent_edit.saving")]}):o.jsxs(o.Fragment,{children:[o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),i("agent_edit.save")]})})]})]})]})]})}const cj={working:"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400",idle:"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400",paused:"bg-orange-100 dark:bg-orange-900/30 text-orange-700 dark:text-orange-400",stopped:"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400",crashed:"bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-400",error:"bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-400",starting:"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-400"},uj={working:o.jsx("svg",{className:"w-4 h-4 mr-1.5",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),idle:o.jsx("svg",{className:"w-4 h-4 mr-1.5",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{d:"M17.293 13.293A8 8 0 016.707 2.707a8.001 8.001 0 1010.586 10.586z"})}),paused:o.jsx("svg",{className:"w-4 h-4 mr-1.5",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zM7 8a1 1 0 012 0v4a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v4a1 1 0 102 0V8a1 1 0 00-1-1z",clipRule:"evenodd"})}),stopped:o.jsx("svg",{className:"w-4 h-4 mr-1.5",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8 7a1 1 0 00-1 1v4a1 1 0 001 1h4a1 1 0 001-1V8a1 1 0 00-1-1H8z",clipRule:"evenodd"})}),crashed:o.jsx("svg",{className:"w-4 h-4 mr-1.5",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),error:o.jsx("svg",{className:"w-4 h-4 mr-1.5",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),starting:o.jsx("svg",{className:"w-4 h-4 mr-1.5 animate-spin",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})};function NJ({state:e}){const t=cj[e]||cj.stopped,n=uj[e]||uj.stopped;return o.jsxs("span",{className:`inline-flex items-center px-3 py-1 rounded-full text-sm font-medium ${t}`,children:[n,e]})}function CJ(e){if(!e)return"-";const t=Date.now()-e,n=Math.floor(t/1e3);if(n<60)return n+"s";const r=Math.floor(n/60);if(r<60)return r+"m";const a=Math.floor(r/60),i=r%60;if(a<24)return a+"h "+i+"m";const s=Math.floor(a/24),l=a%24;return s+"d "+l+"h"}function fy({label:e,value:t,max:n,color:r}){const a=n>0?Math.min(100,Math.round(t/n*100)):0;return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between text-xs",children:[o.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:e}),o.jsx("span",{className:"text-gray-700 dark:text-gray-300 font-medium",children:t.toLocaleString()})]}),o.jsx("div",{className:"h-1.5 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden",children:o.jsx("div",{className:`h-full ${r} transition-all duration-300`,style:{width:a+"%"}})})]})}function Xi({label:e,value:t,mono:n}){return o.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-gray-100 dark:border-gray-800 last:border-0",children:[o.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:e}),o.jsx("span",{className:`text-sm text-gray-900 dark:text-gray-100 ${n?"font-mono":""}`,children:t||"-"})]})}function jJ({agent:e,onClose:t,onAction:n,onToolPartsChange:r,hackerMode:a}){const{t:i}=Tt(),[s,l]=h.useState(e),[c,u]=h.useState(null),[d,f]=h.useState(null),[g,p]=h.useState(!1),[m,y]=h.useState(!1),v=h.useCallback(async()=>{if(e!=null&&e.name)try{const C=await lJ(e.name);l(C),u(null)}catch(C){console.error("Failed to load agent:",C),u(C.message)}},[e==null?void 0:e.name]);h.useEffect(()=>{v();const C=setInterval(v,5e3);return()=>clearInterval(C)},[v]);const x=h.useCallback(async C=>{f(C),u(null);try{C==="start"?await Hb(s.name):C==="stop"?await qb(s.name):C==="restart"?await $d(s.name):C==="cleanRestart"?await $d(s.name,{clean:!0}):C==="pause"?await Wb(s.name,{level:"tools"}):C==="unpause"&&await Vb(s.name),await v(),n&&n(s.name,C)}catch(A){u(A.message)}finally{f(null)}},[s==null?void 0:s.name,v,n]),b=(s==null?void 0:s.state)==="working"||(s==null?void 0:s.state)==="idle"||(s==null?void 0:s.state)==="starting"||(s==null?void 0:s.state)==="paused",k=(s==null?void 0:s.state)==="paused"||(s==null?void 0:s.paused),S=(s==null?void 0:s.displayName)||(s==null?void 0:s.name)||"Unknown Agent",E=(s==null?void 0:s.tokens)||{input:0,output:0,cached:0,total:0},_=Math.max(E.input,E.output,E.cached,1),w=(s==null?void 0:s.cost)||{input:0,output:0,cached:0,total:0};return g?o.jsx(EJ,{agentName:s==null?void 0:s.name,onClose:()=>{p(!1),r&&r(null)},onToolPartsChange:r,hackerMode:a}):o.jsxs("div",{className:"h-full flex flex-col bg-white dark:bg-gray-900 border-l border-gray-200 dark:border-gray-800",children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-800",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-500 dark:text-gray-400 transition-colors flex-shrink-0",title:i("agent_detail.back"),"aria-label":i("agent_detail.back"),children:o.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 truncate",title:S,children:S}),(s==null?void 0:s.displayName)&&s.displayName!==s.name&&o.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 truncate",title:s.name,children:s.name})]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("button",{onClick:()=>y(!0),className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-500 dark:text-gray-400 transition-colors",title:i("agent_detail.edit_settings"),"aria-label":i("agent_detail.edit_settings"),children:o.jsxs("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}),o.jsx(NJ,{state:(s==null?void 0:s.state)||"stopped"})]})]}),o.jsx(SJ,{isOpen:m,agent:s,onClose:()=>y(!1),onUpdated:C=>{v(),n&&n(C,"updated")},onDeleted:C=>{n&&n(C,"deleted"),t()}}),c&&o.jsxs("div",{className:"mx-6 mt-4 px-4 py-2 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 text-sm rounded-lg flex items-center justify-between",children:[o.jsx("span",{children:c}),o.jsx("button",{onClick:()=>u(null),className:"ml-2 text-red-400 hover:text-red-600",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[o.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:b?o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>x("stop"),disabled:d,className:"flex-1 px-4 py-2 text-sm font-medium rounded-lg bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 disabled:opacity-50 transition-colors",children:i(d==="stop"?"agents.stopping":"agents.stop")}),k?o.jsx("button",{onClick:()=>x("unpause"),disabled:d,className:"flex-1 px-4 py-2 text-sm font-medium rounded-lg bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 hover:bg-green-200 dark:hover:bg-green-800/40 disabled:opacity-50 transition-colors",children:i(d==="unpause"?"agents.resuming":"agents.resume")}):o.jsx("button",{onClick:()=>x("pause"),disabled:d,className:"flex-1 px-4 py-2 text-sm font-medium rounded-lg bg-orange-100 dark:bg-orange-900/30 text-orange-700 dark:text-orange-400 hover:bg-orange-200 dark:hover:bg-orange-800/40 disabled:opacity-50 transition-colors",children:i(d==="pause"?"agents.pausing":"agents.pause")}),o.jsx("button",{onClick:()=>x("restart"),disabled:d,className:"flex-1 px-4 py-2 text-sm font-medium rounded-lg bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400 hover:bg-primary-200 dark:hover:bg-primary-800/40 disabled:opacity-50 transition-colors",children:i(d==="restart"?"agents.restarting":"agents.restart")}),o.jsx("button",{onClick:()=>x("cleanRestart"),disabled:d,className:"flex-1 px-4 py-2 text-sm font-medium rounded-lg bg-orange-100 dark:bg-orange-900/30 text-orange-700 dark:text-orange-400 hover:bg-orange-200 dark:hover:bg-orange-800/40 disabled:opacity-50 transition-colors",title:i("agents.clean_restart_tooltip"),children:i(d==="cleanRestart"?"agents.restarting":"agents.clean_restart")})]}):o.jsx("button",{onClick:()=>x("start"),disabled:d,className:"flex-1 px-4 py-2 text-sm font-medium rounded-lg bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 hover:bg-green-200 dark:hover:bg-green-800/40 disabled:opacity-50 transition-colors",children:i(d==="start"?"agents.starting":"agents.start")})}),o.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800/50 rounded-xl p-4",children:[o.jsx("h3",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-3",children:i("agent_detail.agent_info")}),o.jsxs("div",{className:"space-y-0",children:[o.jsx(Xi,{label:i("agent_detail.model"),value:s==null?void 0:s.model,mono:!0}),o.jsx(Xi,{label:i("agent_detail.port"),value:s==null?void 0:s.port,mono:!0}),o.jsx(Xi,{label:i("agent_detail.pid"),value:s==null?void 0:s.pid,mono:!0}),o.jsx(Xi,{label:i("agent_detail.session_id"),value:s!=null&&s.sessionId?s.sessionId.slice(0,12)+"...":null,mono:!0}),o.jsx(Xi,{label:i("agent_detail.uptime"),value:CJ(s==null?void 0:s.startedAt)}),o.jsx(Xi,{label:i("agent_detail.iteration"),value:s==null?void 0:s.iteration}),o.jsx(Xi,{label:i("agent_detail.start_mode"),value:s!=null&&s.skipInitialPrompt?i("agent_detail.start_mode_dormant"):i("agent_detail.start_mode_normal")})]})]}),o.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800/50 rounded-xl p-4",children:[o.jsx("h3",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-3",children:i("agent_detail.token_usage")}),o.jsxs("div",{className:"space-y-3",children:[o.jsx(fy,{label:i("agent_detail.token_input"),value:E.input,max:_,color:"bg-blue-500"}),o.jsx(fy,{label:i("agent_detail.token_output"),value:E.output,max:_,color:"bg-green-500"}),o.jsx(fy,{label:i("agent_detail.token_cached"),value:E.cached,max:_,color:"bg-purple-500"}),o.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-gray-200 dark:border-gray-700",children:[o.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-300",children:"Total"}),o.jsx("span",{className:"text-sm font-bold text-gray-900 dark:text-gray-100",children:E.total.toLocaleString()})]})]})]}),o.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800/50 rounded-xl p-4",children:[o.jsx("h3",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-3",children:"Estimated Cost"}),o.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-3",children:[o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Input"}),o.jsxs("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:["$",w.input.toFixed(4)]})]}),o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Output"}),o.jsxs("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:["$",w.output.toFixed(4)]})]}),o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Cached"}),o.jsxs("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:["$",w.cached.toFixed(4)]})]})]}),o.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-gray-200 dark:border-gray-700",children:[o.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-300",children:i("agent_detail.total_cost")}),o.jsxs("span",{className:"text-lg font-bold text-gray-900 dark:text-gray-100",children:["$",w.total.toFixed(4)]})]})]}),(s==null?void 0:s.dailyUsage)&&s.dailyUsage.length>0&&o.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800/50 rounded-xl p-4",children:[o.jsx("h3",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-3",children:"Daily Usage (Last 7 Days)"}),o.jsx(wJ,{data:s.dailyUsage})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("button",{className:"w-full px-4 py-2.5 text-sm font-medium rounded-lg border border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors flex items-center justify-center gap-2",onClick:()=>p(!0),children:[o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),i("agent_detail.view_conversation")]}),o.jsxs("button",{className:"w-full px-4 py-2.5 text-sm font-medium rounded-lg border border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors flex items-center justify-center gap-2",onClick:()=>y(!0),children:[o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})}),i("agent_detail.edit_settings")]}),o.jsxs("button",{className:"w-full px-4 py-2.5 text-sm font-medium rounded-lg border border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors flex items-center justify-center gap-2",onClick:async()=>{try{await O3(s.name)}catch(C){u(i("agents.export_error")+": "+C.message)}},children:[o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),i("agents.export")]})]}),(s==null?void 0:s.cwd)&&o.jsxs("div",{className:"text-xs text-gray-400 dark:text-gray-500 break-all",children:[o.jsx("span",{className:"font-medium",children:i("agent_detail.working_dir_label")}),o.jsx("br",{}),o.jsx("span",{className:"font-mono",children:s.cwd})]})]})]})}const Iu=["swift","quick","rapid","agile","nimble","clever","smart","wise","bright","keen","bold","brave","calm","steady","noble","silent","shadow","storm","iron","steel","amber","azure","cobalt","crimson","golden","cosmic","cyber","digital","quantum","prime"],Mu=["falcon","hawk","eagle","raven","phoenix","wolf","fox","hound","coyote","tiger","panther","lynx","leopard","bear","orca","shark","viper","cobra","dragon","griffin","sentinel","guardian","titan","node","nexus","core","spark","pulse"];function dj(e=[],t=100){const n=new Set(e.map(s=>s.toLowerCase()));for(let s=0;s<t;s++){const l=Iu[Math.floor(Math.random()*Iu.length)],c=Mu[Math.floor(Math.random()*Mu.length)],u=`${l}-${c}`;if(!n.has(u))return u}const r=Iu[Math.floor(Math.random()*Iu.length)],a=Mu[Math.floor(Math.random()*Mu.length)],i=Math.floor(Math.random()*1e3);return`${r}-${a}-${i}`}function fj(e,t=[]){if(!e||typeof e!="string")return{valid:!1,error:"Name is required"};const n=e.trim().toLowerCase();return n.length===0?{valid:!1,error:"Name cannot be empty"}:n.length<2?{valid:!1,error:"Name must be at least 2 characters"}:n.length>50?{valid:!1,error:"Name must be 50 characters or less"}:/^[a-z0-9_-]+$/.test(n)?new Set(t.map(a=>a.toLowerCase())).has(n)?{valid:!1,error:"An agent with this name already exists"}:{valid:!0,error:null}:{valid:!1,error:"Name can only contain lowercase letters, numbers, hyphens, and underscores"}}function TJ(e){return e?e.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9_-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,""):""}const Lu=`# AGENTS.md - AI Agent Instructions
106
106
 
107
107
  ## Overview
108
108
  You are an autonomous AI agent. Your goal is to help users accomplish tasks efficiently.