dorkos 0.45.0 → 0.45.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +6 -6
- package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-SWyE65Is-DbU6EhZc.js → BaseTanStackRouterDevtoolsPanel-SWyE65Is-DBeTmo8s.js} +1 -1
- package/dist/client/assets/BaseTanStackRouterDevtoolsPanel-SWyE65Is-DptF2Iv2.js +539 -0
- package/dist/client/assets/{BlintzCanvas-YWLFAfxE.js → BlintzCanvas-BC2wvdMT.js} +1 -1
- package/dist/client/assets/BlintzCanvas-tAgLU3aR.js +1160 -0
- package/dist/client/assets/{CanvasCsvContent-Dcuaf91X.js → CanvasCsvContent-B0IwcV_U.js} +1 -1
- package/dist/client/assets/CanvasCsvContent-RYl7B_ua.js +15 -0
- package/dist/client/assets/{CanvasFileContent-gn5aMM24.js → CanvasFileContent-BHJI0OTy.js} +2 -2
- package/dist/client/assets/CanvasFileContent-BsJsR4E1.js +2 -0
- package/dist/client/assets/{CanvasModel3dContent-C3PJHVs8.js → CanvasModel3dContent-BcdM2LJg.js} +2 -2
- package/dist/client/assets/CanvasModel3dContent-ohjBCAJd.js +2 -0
- package/dist/client/assets/{CodeMirrorEditor-f8fXFh5i.js → CodeMirrorEditor-C-gkWN8h.js} +1 -1
- package/dist/client/assets/CodeMirrorEditor-SHXbcVUy.js +1 -0
- package/dist/client/assets/{ConfigTab-Cetgg_6C.js → ConfigTab-DJu3oDC2.js} +1 -1
- package/dist/client/assets/ConfigTab-TuhuSOnv.js +17 -0
- package/dist/client/assets/{FloatingTanStackRouterDevtools-CnpwH7La-BOdQs4zz.js → FloatingTanStackRouterDevtools-CnpwH7La-BmSxRfr_.js} +1 -1
- package/dist/client/assets/FloatingTanStackRouterDevtools-CnpwH7La-Dk8iG4Hx.js +1 -0
- package/dist/client/assets/{Model3dViewer-qR1sbYAL.js → Model3dViewer-D6VCAF61.js} +1 -1
- package/dist/client/assets/Model3dViewer-K9pNJx1c.js +5372 -0
- package/dist/client/assets/{SessionsTab-BCsOP3gI.js → SessionsTab-BrqarM-T.js} +1 -1
- package/dist/client/assets/SessionsTab-Di1R_A1t.js +1 -0
- package/dist/client/assets/{ToolkitTab-BYtBugsk.js → ToolkitTab-BOaJEnPh.js} +1 -1
- package/dist/client/assets/ToolkitTab-a2dYMBx9.js +1 -0
- package/dist/client/assets/{TopologyGraph-xyvgCKHX.js → TopologyGraph-DUJWDhtI.js} +1 -1
- package/dist/client/assets/TopologyGraph-Dehijt2P.js +35 -0
- package/dist/client/assets/{highlighted-body-OFNGDK62-B8b-ZuJR.js → highlighted-body-OFNGDK62-B_0h6J6M.js} +1 -1
- package/dist/client/assets/highlighted-body-OFNGDK62-D85fxms5.js +1 -0
- package/dist/client/assets/{index-BrVLuO9-.js → index-5ALgrOFO.js} +1 -1
- package/dist/client/assets/{index-YPp3bUkv.js → index-B4Fq7yld.js} +1 -1
- package/dist/client/assets/{index-CZBlFw3s.js → index-B4_k9QZg.js} +1 -1
- package/dist/client/assets/{index-B-WBHpyv.js → index-B7ObcNSe.js} +1 -1
- package/dist/client/assets/{index-BzFClKht.js → index-B9VCOBmA.js} +2 -2
- package/dist/client/assets/{index-BaGiFKrR.js → index-BCp9aZet.js} +1 -1
- package/dist/client/assets/index-BDdd8Mqa.js +1 -0
- package/dist/client/assets/index-BNSNg7yH.js +1316 -0
- package/dist/client/assets/{index-aEzy0_Oi.js → index-BQk-ivFT.js} +1 -1
- package/dist/client/assets/{index-CCHYQVhi.js → index-BT9yFVeS.js} +3 -3
- package/dist/client/assets/{index-sKKm7yEm.js → index-BZYDK9c8.js} +8 -8
- package/dist/client/assets/{index-Djl0lRsF.js → index-Bbn2wn69.js} +1 -1
- package/dist/client/assets/{index-C27wAnIu.js → index-BcX7mUEk.js} +1 -1
- package/dist/client/assets/{index-BT9Vxyz4.js → index-Bcx7LFbL.js} +1 -1
- package/dist/client/assets/{index-CCqqyjKr.js → index-BdUsepd_.js} +1 -1
- package/dist/client/assets/index-BeWJN4g0.js +1 -0
- package/dist/client/assets/index-Bh6Wh5Du.js +1 -0
- package/dist/client/assets/index-BqqIE9sa.js +1 -0
- package/dist/client/assets/{index-CzJ4xEDL.js → index-Bvs4ET-I.js} +1 -1
- package/dist/client/assets/{index-Ced3HTl7.js → index-Bx073uVW.js} +1 -1
- package/dist/client/assets/{index-BJyMVoKM.js → index-C20-Z8l4.js} +1 -1
- package/dist/client/assets/{index-lFLNlOBz.js → index-C2NQ-Ck8.js} +1 -1
- package/dist/client/assets/index-C44W9aTS.js +2 -0
- package/dist/client/assets/index-C6SlFkyv.js +2 -0
- package/dist/client/assets/{index-DjSzGDon.js → index-C9IMI6L6.js} +1 -1
- package/dist/client/assets/{index-C2pa1dy_.js → index-CK2kZcMG.js} +1 -1
- package/dist/client/assets/index-CKCx_Kan.js +6 -0
- package/dist/client/assets/index-CQxDY4vU.js +6 -0
- package/dist/client/assets/{index-oZPvMe-H.js → index-CSZQyH2J.js} +1 -1
- package/dist/client/assets/{index-9i9Kxi6Z.js → index-CT-ZBhf1.js} +1 -1
- package/dist/client/assets/{index-BkmzUjFL.js → index-CaH1aFVg.js} +1 -1
- package/dist/client/assets/index-CdAooMjU.js +15 -0
- package/dist/client/assets/{index-BKp1QoTa.js → index-CvMyZRD2.js} +1 -1
- package/dist/client/assets/index-CyUySFAD.js +13 -0
- package/dist/client/assets/{index-BQ0KNUVJ.js → index-CyWkKBhZ.js} +1 -1
- package/dist/client/assets/{index-DWocbnZZ.js → index-D1ekLRaV.js} +1 -1
- package/dist/client/assets/{index-DRqPbLFU.js → index-D9MT2UpW.js} +1 -1
- package/dist/client/assets/index-DEA_Cy2Q.js +1 -0
- package/dist/client/assets/index-DLQOQsnm.js +1 -0
- package/dist/client/assets/index-DQD1r_S5.js +70 -0
- package/dist/client/assets/{index-BV2QuCxp.js → index-DUshTWP6.js} +1 -1
- package/dist/client/assets/index-DbAfUW6T.js +1 -0
- package/dist/client/assets/index-DhLhWBOz.js +1 -0
- package/dist/client/assets/index-DiQETlwd.js +71 -0
- package/dist/client/assets/index-Do63XgYk.js +1 -0
- package/dist/client/assets/index-DvPThthM.js +1 -0
- package/dist/client/assets/index-Dyl6ywSG.js +7 -0
- package/dist/client/assets/{index-CTqKf40t.js → index-MDyXRyeQ.js} +1 -1
- package/dist/client/assets/index-QFOwC8Sb.js +6 -0
- package/dist/client/assets/index-YNTMAxpK.js +1 -0
- package/dist/client/assets/index-ZZSS75im.js +1 -0
- package/dist/client/assets/index-_mq6ScXa.js +1 -0
- package/dist/client/assets/index-dj2DvPaa.js +1 -0
- package/dist/client/assets/index-oQeM2FOC.js +1 -0
- package/dist/client/assets/{index-ByyRHqai.js → index-rZ21sTqk.js} +1 -1
- package/dist/client/assets/index-sgPwXj8m.js +1 -0
- package/dist/client/assets/index-w2P-tT_0.js +1 -0
- package/dist/client/assets/{index-DQrSytvk.js → index-w2dnLgsj.js} +1 -1
- package/dist/client/assets/index-xIhoncSx.js +1 -0
- package/dist/client/assets/index-yXRJmHf-.js +3 -0
- package/dist/client/index.html +1 -1
- package/dist/server/index.js +2 -1
- package/dist/server/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BlintzCanvas-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BlintzCanvas-BC2wvdMT.js","assets/index-BT9yFVeS.js","assets/BlintzCanvas-CLCIbR7o.css","assets/CanvasModel3dContent-ohjBCAJd.js","assets/fetch-src-4Qlrf9qq.js","assets/CanvasCsvContent-RYl7B_ua.js","assets/TopologyGraph-Dehijt2P.js","assets/TopologyGraph-C7eadB24.css","assets/index-DiQETlwd.js","assets/index-DYP7pi_n.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
var zme=Object.defineProperty;var Uz=e=>{throw TypeError(e)};var Bme=(e,t,n)=>t in e?zme(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ze=(e,t,n)=>Bme(e,typeof t!="symbol"?t+"":t,n),AN=(e,t,n)=>t.has(e)||Uz("Cannot "+n);var ne=(e,t,n)=>(AN(e,t,"read from private field"),n?n.call(e):t.get(e)),tt=(e,t,n)=>t.has(e)?Uz("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),qe=(e,t,n,s)=>(AN(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),Gt=(e,t,n)=>(AN(e,t,"access private method"),n);var gx=(e,t,n,s)=>({set _(r){qe(e,t,r,n)},get _(){return ne(e,t,s)}});function $me(e,t){for(var n=0;n<t.length;n++){const s=t[n];if(typeof s!="string"&&!Array.isArray(s)){for(const r in s)if(r!=="default"&&!(r in e)){const i=Object.getOwnPropertyDescriptor(s,r);i&&Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:()=>s[r]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function n(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(r){if(r.ep)return;r.ep=!0;const i=n(r);fetch(r.href,i)}})();const Hme="modulepreload",Ume=function(e){return"/"+e},Vz={},ks=function(t,n,s){let r=Promise.resolve();if(n&&n.length>0){let o=function(u){return Promise.all(u.map(d=>Promise.resolve(d).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));r=o(n.map(u=>{if(u=Ume(u),u in Vz)return;Vz[u]=!0;const d=u.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${f}`))return;const m=document.createElement("link");if(m.rel=d?"stylesheet":Hme,d||(m.as="script"),m.crossOrigin="",m.href=u,c&&m.setAttribute("nonce",c),document.head.appendChild(m),d)return new Promise((g,y)=>{m.addEventListener("load",g),m.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${u}`)))})}))}function i(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return r.then(o=>{for(const l of o||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})};var RSt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function hl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var RN={exports:{}},xx={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -1236,7 +1236,7 @@ ${t}</tr>
|
|
|
1236
1236
|
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${$o(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:n,tokens:s}){let r=this.parser.parseInline(s),i=FH(t);if(i===null)return r;t=i;let o='<a href="'+t+'"';return n&&(o+=' title="'+$o(n)+'"'),o+=">"+r+"</a>",o}image({href:t,title:n,text:s,tokens:r}){r&&(s=this.parser.parseInline(r,this.parser.textRenderer));let i=FH(t);if(i===null)return $o(s);t=i;let o=`<img src="${t}" alt="${$o(s)}"`;return n&&(o+=` title="${$o(n)}"`),o+=">",o}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:$o(t.text)}},G4=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},oo=class cD{constructor(t){Ze(this,"options");Ze(this,"renderer");Ze(this,"textRenderer");this.options=t||rm,this.options.renderer=this.options.renderer||new SC,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new G4}static parse(t,n){return new cD(n).parse(t)}static parseInline(t,n){return new cD(n).parseInline(t)}parse(t){var s,r;this.renderer.parser=this;let n="";for(let i=0;i<t.length;i++){let o=t[i];if((r=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&r[o.type]){let c=o,u=this.options.extensions.renderers[c.type].call({parser:this},c);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(c.type)){n+=u||"";continue}}let l=o;switch(l.type){case"space":{n+=this.renderer.space(l);break}case"hr":{n+=this.renderer.hr(l);break}case"heading":{n+=this.renderer.heading(l);break}case"code":{n+=this.renderer.code(l);break}case"table":{n+=this.renderer.table(l);break}case"blockquote":{n+=this.renderer.blockquote(l);break}case"list":{n+=this.renderer.list(l);break}case"checkbox":{n+=this.renderer.checkbox(l);break}case"html":{n+=this.renderer.html(l);break}case"def":{n+=this.renderer.def(l);break}case"paragraph":{n+=this.renderer.paragraph(l);break}case"text":{n+=this.renderer.text(l);break}default:{let c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return n}parseInline(t,n=this.renderer){var r,i;this.renderer.parser=this;let s="";for(let o=0;o<t.length;o++){let l=t[o];if((i=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&i[l.type]){let u=this.options.extensions.renderers[l.type].call({parser:this},l);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(l.type)){s+=u||"";continue}}let c=l;switch(c.type){case"escape":{s+=n.text(c);break}case"html":{s+=n.html(c);break}case"link":{s+=n.link(c);break}case"image":{s+=n.image(c);break}case"checkbox":{s+=n.checkbox(c);break}case"strong":{s+=n.strong(c);break}case"em":{s+=n.em(c);break}case"codespan":{s+=n.codespan(c);break}case"br":{s+=n.br(c);break}case"del":{s+=n.del(c);break}case"text":{s+=n.text(c);break}default:{let u='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return s}},Cw,my=(Cw=class{constructor(e){Ze(this,"options");Ze(this,"block");this.options=e||rm}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?za.lex:za.lexInline}provideParser(){return this.block?oo.parse:oo.parseInline}},Ze(Cw,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),Ze(Cw,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Cw),ZYe=class{constructor(...t){Ze(this,"defaults",F4());Ze(this,"options",this.setOptions);Ze(this,"parse",this.parseMarkdown(!0));Ze(this,"parseInline",this.parseMarkdown(!1));Ze(this,"Parser",oo);Ze(this,"Renderer",SC);Ze(this,"TextRenderer",G4);Ze(this,"Lexer",za);Ze(this,"Tokenizer",bC);Ze(this,"Hooks",my);this.use(...t)}walkTokens(t,n){var r,i;let s=[];for(let o of t)switch(s=s.concat(n.call(this,o)),o.type){case"table":{let l=o;for(let c of l.header)s=s.concat(this.walkTokens(c.tokens,n));for(let c of l.rows)for(let u of c)s=s.concat(this.walkTokens(u.tokens,n));break}case"list":{let l=o;s=s.concat(this.walkTokens(l.items,n));break}default:{let l=o;(i=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[l.type]?this.defaults.extensions.childTokens[l.type].forEach(c=>{let u=l[c].flat(1/0);s=s.concat(this.walkTokens(u,n))}):l.tokens&&(s=s.concat(this.walkTokens(l.tokens,n)))}}return s}use(...t){let n=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(s=>{let r={...s};if(r.async=this.defaults.async||r.async||!1,s.extensions&&(s.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let o=n.renderers[i.name];o?n.renderers[i.name]=function(...l){let c=i.renderer.apply(this,l);return c===!1&&(c=o.apply(this,l)),c}:n.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=n[i.level];o?o.unshift(i.tokenizer):n[i.level]=[i.tokenizer],i.start&&(i.level==="block"?n.startBlock?n.startBlock.push(i.start):n.startBlock=[i.start]:i.level==="inline"&&(n.startInline?n.startInline.push(i.start):n.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(n.childTokens[i.name]=i.childTokens)}),r.extensions=n),s.renderer){let i=this.defaults.renderer||new SC(this.defaults);for(let o in s.renderer){if(!(o in i))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let l=o,c=s.renderer[l],u=i[l];i[l]=(...d)=>{let f=c.apply(i,d);return f===!1&&(f=u.apply(i,d)),f||""}}r.renderer=i}if(s.tokenizer){let i=this.defaults.tokenizer||new bC(this.defaults);for(let o in s.tokenizer){if(!(o in i))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let l=o,c=s.tokenizer[l],u=i[l];i[l]=(...d)=>{let f=c.apply(i,d);return f===!1&&(f=u.apply(i,d)),f}}r.tokenizer=i}if(s.hooks){let i=this.defaults.hooks||new my;for(let o in s.hooks){if(!(o in i))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let l=o,c=s.hooks[l],u=i[l];my.passThroughHooks.has(o)?i[l]=d=>{if(this.defaults.async&&my.passThroughHooksRespectAsync.has(o))return(async()=>{let m=await c.call(i,d);return u.call(i,m)})();let f=c.call(i,d);return u.call(i,f)}:i[l]=(...d)=>{if(this.defaults.async)return(async()=>{let m=await c.apply(i,d);return m===!1&&(m=await u.apply(i,d)),m})();let f=c.apply(i,d);return f===!1&&(f=u.apply(i,d)),f}}r.hooks=i}if(s.walkTokens){let i=this.defaults.walkTokens,o=s.walkTokens;r.walkTokens=function(l){let c=[];return c.push(o.call(this,l)),i&&(c=c.concat(i.call(this,l))),c}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,n){return za.lex(t,n??this.defaults)}parser(t,n){return oo.parse(t,n??this.defaults)}parseMarkdown(t){return(n,s)=>{let r={...s},i={...this.defaults,...r},o=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=t),i.async)return(async()=>{let l=i.hooks?await i.hooks.preprocess(n):n,c=await(i.hooks?await i.hooks.provideLexer():t?za.lex:za.lexInline)(l,i),u=i.hooks?await i.hooks.processAllTokens(c):c;i.walkTokens&&await Promise.all(this.walkTokens(u,i.walkTokens));let d=await(i.hooks?await i.hooks.provideParser():t?oo.parse:oo.parseInline)(u,i);return i.hooks?await i.hooks.postprocess(d):d})().catch(o);try{i.hooks&&(n=i.hooks.preprocess(n));let l=(i.hooks?i.hooks.provideLexer():t?za.lex:za.lexInline)(n,i);i.hooks&&(l=i.hooks.processAllTokens(l)),i.walkTokens&&this.walkTokens(l,i.walkTokens);let c=(i.hooks?i.hooks.provideParser():t?oo.parse:oo.parseInline)(l,i);return i.hooks&&(c=i.hooks.postprocess(c)),c}catch(l){return o(l)}}}onError(t,n){return s=>{if(s.message+=`
|
|
1237
1237
|
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+$o(s.message+"",!0)+"</pre>";return n?Promise.resolve(r):r}if(n)return Promise.reject(s);throw s}}},yh=new ZYe;function Qn(e,t){return yh.parse(e,t)}Qn.options=Qn.setOptions=function(e){return yh.setOptions(e),Qn.defaults=yh.defaults,Hoe(Qn.defaults),Qn};Qn.getDefaults=F4;Qn.defaults=rm;Qn.use=function(...e){return yh.use(...e),Qn.defaults=yh.defaults,Hoe(Qn.defaults),Qn};Qn.walkTokens=function(e,t){return yh.walkTokens(e,t)};Qn.parseInline=yh.parseInline;Qn.Parser=oo;Qn.parser=oo.parse;Qn.Renderer=SC;Qn.TextRenderer=G4;Qn.Lexer=za;Qn.lexer=za.lex;Qn.Tokenizer=bC;Qn.Hooks=my;Qn.parse=Qn;Qn.options;Qn.setOptions;Qn.use;Qn.walkTokens;Qn.parseInline;oo.parse;za.lex;var XYe=300,QYe="300px",JYe=500;function eZe(e={}){let{immediate:t=!1,debounceDelay:n=XYe,rootMargin:s=QYe,idleTimeout:r=JYe}=e,[i,o]=x.useState(!1),l=x.useRef(null),c=x.useRef(null),u=x.useRef(null),d=x.useMemo(()=>g=>{let y=Date.now();return window.setTimeout(()=>{g({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-y))})},1)},[]),f=x.useMemo(()=>typeof window<"u"&&window.requestIdleCallback?(g,y)=>window.requestIdleCallback(g,y):d,[d]),m=x.useMemo(()=>typeof window<"u"&&window.cancelIdleCallback?g=>window.cancelIdleCallback(g):g=>{clearTimeout(g)},[]);return x.useEffect(()=>{if(t){o(!0);return}let g=l.current;if(!g)return;c.current&&(clearTimeout(c.current),c.current=null),u.current&&(m(u.current),u.current=null);let y=()=>{c.current&&(clearTimeout(c.current),c.current=null),u.current&&(m(u.current),u.current=null)},b=T=>{u.current=f(E=>{E.timeRemaining()>0||E.didTimeout?(o(!0),T.disconnect()):u.current=f(()=>{o(!0),T.disconnect()},{timeout:r/2})},{timeout:r})},S=T=>{y(),c.current=window.setTimeout(()=>{var E,j;let _=T.takeRecords();(_.length===0||(j=(E=_.at(-1))==null?void 0:E.isIntersecting)!=null&&j)&&b(T)},n)},w=(T,E)=>{T.isIntersecting?S(E):y()},C=new IntersectionObserver(T=>{for(let E of T)w(E,C)},{rootMargin:s,threshold:0});return C.observe(g),()=>{c.current&&clearTimeout(c.current),u.current&&m(u.current),C.disconnect()}},[t,n,s,r,m,f]),{shouldRender:i,containerRef:l}}var Qoe=/\s/,tZe=/^\s+$/,nZe=new Set(["code","pre","svg","math","annotation"]),sZe=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",rZe=e=>e.some(t=>sZe(t)&&nZe.has(t.tagName)),iZe=e=>{let t=[],n="",s=!1;for(let r of e){let i=Qoe.test(r);i!==s&&n&&(t.push(n),n=""),n+=r,s=i}return n&&t.push(n),t},aZe=e=>{let t=[],n="";for(let s of e)Qoe.test(s)?n+=s:(n&&(t.push(n),n=""),t.push(s));return n&&t.push(n),t},oZe=(e,t,n,s,r,i)=>{let o=`--sd-animation:sd-${t};--sd-duration:${r?0:n}ms;--sd-easing:${s}`;return i&&(o+=`;--sd-delay:${i}ms`),{type:"element",tagName:"span",properties:{"data-sd-animate":!0,style:o},children:[{type:"text",value:e}]}},lZe=(e,t,n,s,r)=>{let i=t.at(-1);if(!(i&&"children"in i))return;if(rZe(t))return Rp;let o=i,l=o.children.indexOf(e);if(l===-1)return;let c=e.value;if(!c.trim()){r.count+=c.length;return}let u=n.sep==="char"?aZe(c):iZe(c),d=s.prevContentLength,f=u.map(m=>{let g=r.count;if(r.count+=m.length,tZe.test(m))return{type:"text",value:m};let y=d>0&&g<d,b=y?0:r.newIndex++*n.stagger;return oZe(m,n.animation,n.duration,n.easing,y,b)});return o.children.splice(l,1,...f),l+f.length},cZe=0;function uD(e){var t,n,s,r,i;let o={animation:(t=e==null?void 0:e.animation)!=null?t:"fadeIn",duration:(n=e==null?void 0:e.duration)!=null?n:150,easing:(s=e==null?void 0:e.easing)!=null?s:"ease",sep:(r=e==null?void 0:e.sep)!=null?r:"word",stagger:(i=e==null?void 0:e.stagger)!=null?i:40},l={prevContentLength:0,lastRenderCharCount:0},c=cZe++,u=()=>d=>{let f={count:0,newIndex:0};m4(d,"text",(m,g)=>lZe(m,g,o,l,f)),l.lastRenderCharCount=f.count,l.prevContentLength=0};return Object.defineProperty(u,"name",{value:`rehypeAnimate$${c}`}),{name:"animate",type:"animate",rehypePlugin:u,setPrevContentLength(d){l.prevContentLength=d},getLastRenderCharCount(){let d=l.lastRenderCharCount;return l.lastRenderCharCount=0,d}}}uD();var Joe=x.createContext(!1),uZe=()=>x.useContext(Joe),K4=(...e)=>iE(rE(e)),dZe=(e,t)=>{if(!e||!t)return t;let n=`${e}:`;return t.split(/\s+/).filter(Boolean).map(s=>s.startsWith(n)?s:`${e}:${s}`).join(" ")},fZe=e=>e?(...t)=>dZe(e,iE(rE(t))):K4,Gp=(e,t,n)=>{let s=typeof t=="string"&&n.startsWith("text/csv")?"\uFEFF":"",r=typeof t=="string"?new Blob([s+t],{type:n}):t,i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)},dD=x.createContext(K4),rn=()=>x.useContext(dD),hZe=K4("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),mZe=e=>{let t={};for(let n of e.split(";")){let s=n.indexOf(":");if(s>0){let r=n.slice(0,s).trim(),i=n.slice(s+1).trim();r&&i&&(t[r]=i)}}return t},pZe=x.memo(({children:e,result:t,language:n,className:s,startLine:r,lineNumbers:i=!0,...o})=>{let l=rn(),c=x.useMemo(()=>l(hZe),[l]),u=x.useMemo(()=>{let d={};return t.bg&&(d["--sdm-bg"]=t.bg),t.fg&&(d["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(d,mZe(t.rootStyle)),d},[t.bg,t.fg,t.rootStyle]);return a.jsx("div",{className:l(s,"overflow-x-auto rounded-md border border-border bg-background p-4 text-sm"),"data-language":n,"data-streamdown":"code-block-body",...o,children:a.jsx("pre",{className:l(s,"bg-[var(--sdm-bg,inherit]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]"),style:u,children:a.jsx("code",{className:i?l("[counter-increment:line_0] [counter-reset:line]"):void 0,style:i&&r&&r>1?{counterReset:`line ${r-1}`}:void 0,children:t.tokens.map((d,f)=>a.jsx("span",{className:i?c:void 0,children:d.length===0||d.length===1&&d[0].content===""?`
|
|
1238
1238
|
`:d.map((m,g)=>{let y={},b=!!m.bgColor;if(m.color&&(y["--sdm-c"]=m.color),m.bgColor&&(y["--sdm-tbg"]=m.bgColor),m.htmlStyle)for(let[S,w]of Object.entries(m.htmlStyle))S==="color"?y["--sdm-c"]=w:S==="background-color"?(y["--sdm-tbg"]=w,b=!0):y[S]=w;return a.jsx("span",{className:l("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",b&&"bg-[var(--sdm-tbg)]",b&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:y,...m.htmlAttrs,children:m.content},g)})},f))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers),gZe=({className:e,language:t,style:n,isIncomplete:s,...r})=>{let i=rn();return a.jsx("div",{className:i("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":s||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...n},...r})},ele=x.createContext({code:""}),tle=()=>x.useContext(ele),xZe=({language:e})=>{let t=rn();return a.jsx("div",{className:t("flex h-8 items-center text-muted-foreground text-xs"),"data-language":e,"data-streamdown":"code-block-header",children:a.jsx("span",{className:t("ml-1 font-mono lowercase"),children:e})})},yZe=e=>{let t=e.length;for(;t>0&&e[t-1]===`
|
|
1239
|
-
`;)t--;return e.slice(0,t)},vZe=x.lazy(()=>ks(()=>import("./highlighted-body-OFNGDK62-
|
|
1239
|
+
`;)t--;return e.slice(0,t)},vZe=x.lazy(()=>ks(()=>import("./highlighted-body-OFNGDK62-D85fxms5.js"),[]).then(e=>({default:e.HighlightedCodeBlockBody}))),bZe=({code:e,language:t,className:n,children:s,isIncomplete:r=!1,startLine:i,lineNumbers:o,...l})=>{let c=rn(),u=x.useMemo(()=>yZe(e),[e]),d=x.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:u.split(`
|
|
1240
1240
|
`).map(f=>[{content:f,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[u]);return a.jsx(ele.Provider,{value:{code:e},children:a.jsxs(gZe,{isIncomplete:r,language:t,children:[a.jsx(xZe,{language:t}),s?a.jsx("div",{className:c("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:a.jsx("div",{className:c("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"code-block-actions",children:s})}):null,a.jsx(x.Suspense,{fallback:a.jsx(pZe,{className:n,language:t,lineNumbers:o,result:d,startLine:i,...l}),children:a.jsx(vZe,{className:n,code:u,language:t,lineNumbers:o,raw:d,startLine:i,...l})})]})})},SZe=e=>a.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:a.jsx("path",{clipRule:"evenodd",d:"M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z",fill:"currentColor",fillRule:"evenodd"})}),wZe=e=>a.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:a.jsx("path",{clipRule:"evenodd",d:"M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z",fill:"currentColor",fillRule:"evenodd"})}),kZe=e=>a.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:a.jsx("path",{clipRule:"evenodd",d:"M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z",fill:"currentColor",fillRule:"evenodd"})}),CZe=e=>a.jsxs("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[a.jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),a.jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),a.jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),a.jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),a.jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),a.jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),a.jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),a.jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),a.jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),a.jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),EZe=e=>a.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:a.jsx("path",{clipRule:"evenodd",d:"M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z",fill:"currentColor",fillRule:"evenodd"})}),TZe=e=>a.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:a.jsx("path",{clipRule:"evenodd",d:"M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z",fill:"currentColor",fillRule:"evenodd"})}),_Ze=e=>a.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:a.jsx("path",{clipRule:"evenodd",d:"M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",fill:"currentColor",fillRule:"evenodd"})}),NZe=e=>a.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:a.jsx("path",{clipRule:"evenodd",d:"M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",fill:"currentColor",fillRule:"evenodd"})}),jZe=e=>a.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:a.jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),AZe=e=>a.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:a.jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),py={CheckIcon:SZe,CopyIcon:wZe,DownloadIcon:kZe,ExternalLinkIcon:NZe,Loader2Icon:CZe,Maximize2Icon:EZe,RotateCcwIcon:TZe,XIcon:_Ze,ZoomInIcon:jZe,ZoomOutIcon:AZe},nle=x.createContext(py),RZe=(e,t)=>{if(e===t)return!0;if(!(e&&t))return e===t;let n=Object.keys(e),s=Object.keys(t);return n.length!==s.length?!1:n.every(r=>e[r]===t[r])},$H=({icons:e,children:t})=>{let n=x.useRef(e),s=x.useRef(e?{...py,...e}:py);RZe(n.current,e)||(n.current=e,s.current=e?{...py,...e}:py);let r=s.current;return a.jsx(nle.Provider,{value:r,children:t})},Ao=()=>x.useContext(nle),sle={copyCode:"Copy Code",downloadFile:"Download file",downloadDiagram:"Download diagram",downloadDiagramAsSvg:"Download diagram as SVG",downloadDiagramAsPng:"Download diagram as PNG",downloadDiagramAsMmd:"Download diagram as MMD",viewFullscreen:"View fullscreen",exitFullscreen:"Exit fullscreen",mermaidFormatSvg:"SVG",mermaidFormatPng:"PNG",mermaidFormatMmd:"MMD",copyTable:"Copy table",copyTableAsMarkdown:"Copy table as Markdown",copyTableAsCsv:"Copy table as CSV",copyTableAsTsv:"Copy table as TSV",downloadTable:"Download table",downloadTableAsCsv:"Download table as CSV",downloadTableAsMarkdown:"Download table as Markdown",tableFormatMarkdown:"Markdown",tableFormatCsv:"CSV",tableFormatTsv:"TSV",imageNotAvailable:"Image not available",downloadImage:"Download image",openExternalLink:"Open external link?",externalLinkWarning:"You're about to visit an external website.",close:"Close",copyLink:"Copy link",copied:"Copied",openLink:"Open link"},fD=x.createContext(sle),Kc=()=>x.useContext(fD),HH=({onCopy:e,onError:t,timeout:n=2e3,children:s,className:r,code:i,...o})=>{let l=rn(),[c,u]=x.useState(!1),d=x.useRef(0),{code:f}=tle(),{isAnimating:m}=x.useContext(xa),g=Kc(),y=i??f,b=async()=>{var C;if(typeof window>"u"||!((C=navigator==null?void 0:navigator.clipboard)!=null&&C.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{c||(await navigator.clipboard.writeText(y),u(!0),e==null||e(),d.current=window.setTimeout(()=>u(!1),n))}catch(T){t==null||t(T)}};x.useEffect(()=>()=>{window.clearTimeout(d.current)},[]);let S=Ao(),w=c?S.CheckIcon:S.CopyIcon;return a.jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-copy-button",disabled:m,onClick:b,title:g.copyCode,type:"button",...o,children:s??a.jsx(w,{size:14})})},UH={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",文言:"wy"},MZe=({onDownload:e,onError:t,language:n,children:s,className:r,code:i,...o})=>{let l=rn(),{code:c}=tle(),{isAnimating:u}=x.useContext(xa),d=Kc(),f=Ao(),m=i??c,g=`file.${n&&n in UH?UH[n]:"txt"}`,y="text/plain",b=()=>{try{Gp(g,m,y),e==null||e()}catch(S){t==null||t(S)}};return a.jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-download-button",disabled:u,onClick:b,title:d.downloadFile,type:"button",...o,children:s??a.jsx(f.DownloadIcon,{size:14})})},VH=()=>{let{Loader2Icon:e}=Ao(),t=rn();return a.jsxs("div",{className:t("w-full divide-y divide-border overflow-hidden rounded-xl border border-border"),children:[a.jsx("div",{className:t("h-[46px] w-full bg-muted/80")}),a.jsx("div",{className:t("flex w-full items-center justify-center p-4"),children:a.jsx(e,{className:t("size-4 animate-spin")})})]})},DZe=/\.[^/.]+$/,OZe=({node:e,className:t,src:n,alt:s,onLoad:r,onError:i,...o})=>{let{DownloadIcon:l}=Ao(),c=rn(),u=x.useRef(null),[d,f]=x.useState(!1),[m,g]=x.useState(!1),y=Kc(),b=o.width!=null||o.height!=null,S=(d||b)&&!m,w=m&&!b;x.useEffect(()=>{let j=u.current;if(j!=null&&j.complete){let _=j.naturalWidth>0;f(_),g(!_)}},[]);let C=x.useCallback(j=>{f(!0),g(!1),r==null||r(j)},[r]),T=x.useCallback(j=>{f(!1),g(!0),i==null||i(j)},[i]),E=async()=>{if(n)try{let j=await(await fetch(n)).blob(),_=new URL(n,window.location.origin).pathname.split("/").pop()||"",N=_.split(".").pop(),R=_.includes(".")&&N!==void 0&&N.length<=4,O="";if(R)O=_;else{let M=j.type,L="png";M.includes("jpeg")||M.includes("jpg")?L="jpg":M.includes("png")?L="png":M.includes("svg")?L="svg":M.includes("gif")?L="gif":M.includes("webp")&&(L="webp"),O=`${(s||_||"image").replace(DZe,"")}.${L}`}Gp(O,j,j.type)}catch{window.open(n,"_blank")}};return n?a.jsxs("div",{className:c("group relative my-4 inline-block"),"data-streamdown":"image-wrapper",children:[a.jsx("img",{alt:s,className:c("max-w-full rounded-lg",w&&"hidden",t),"data-streamdown":"image",onError:T,onLoad:C,ref:u,src:n,...o}),w&&a.jsx("span",{className:c("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:y.imageNotAvailable}),a.jsx("div",{className:c("pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block")}),S&&a.jsx("button",{className:c("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 group-hover:opacity-100"),onClick:E,title:y.downloadImage,type:"button",children:a.jsx(l,{size:14})})]}):null},Fy=0,W4=()=>{Fy+=1,Fy===1&&(document.body.style.overflow="hidden")},Y4=()=>{Fy=Math.max(0,Fy-1),Fy===0&&(document.body.style.overflow="")},IZe=({url:e,isOpen:t,onClose:n,onConfirm:s})=>{let{CheckIcon:r,CopyIcon:i,ExternalLinkIcon:o,XIcon:l}=Ao(),c=rn(),[u,d]=x.useState(!1),f=Kc(),m=x.useCallback(async()=>{try{await navigator.clipboard.writeText(e),d(!0),setTimeout(()=>d(!1),2e3)}catch{}},[e]),g=x.useCallback(()=>{s(),n()},[s,n]);return x.useEffect(()=>{if(t){W4();let y=b=>{b.key==="Escape"&&n()};return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y),Y4()}}},[t,n]),t?a.jsx("div",{className:c("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),"data-streamdown":"link-safety-modal",onClick:n,onKeyDown:y=>{y.key==="Escape"&&n()},role:"button",tabIndex:0,children:a.jsxs("div",{className:c("relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg"),onClick:y=>y.stopPropagation(),onKeyDown:y=>y.stopPropagation(),role:"presentation",children:[a.jsx("button",{className:c("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:n,title:f.close,type:"button",children:a.jsx(l,{size:16})}),a.jsxs("div",{className:c("flex flex-col gap-2"),children:[a.jsxs("div",{className:c("flex items-center gap-2 font-semibold text-lg"),children:[a.jsx(o,{size:20}),a.jsx("span",{children:f.openExternalLink})]}),a.jsx("p",{className:c("text-muted-foreground text-sm"),children:f.externalLinkWarning})]}),a.jsx("div",{className:c("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),a.jsxs("div",{className:c("flex gap-2"),children:[a.jsx("button",{className:c("flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted"),onClick:m,type:"button",children:u?a.jsxs(a.Fragment,{children:[a.jsx(r,{size:14}),a.jsx("span",{children:f.copied})]}):a.jsxs(a.Fragment,{children:[a.jsx(i,{size:14}),a.jsx("span",{children:f.copyLink})]})}),a.jsxs("button",{className:c("flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90"),onClick:g,type:"button",children:[a.jsx(o,{size:14}),a.jsx("span",{children:f.openLink})]})]})]})}):null},hD=x.createContext(null),Z4=()=>x.useContext(hD),HSt=()=>{var e;let t=Z4();return(e=t==null?void 0:t.code)!=null?e:null},X4=()=>{var e;let t=Z4();return(e=t==null?void 0:t.mermaid)!=null?e:null},PZe=e=>{var t;let n=Z4();return n!=null&&n.renderers&&e&&(t=n.renderers.find(s=>Array.isArray(s.language)?s.language.includes(e):s.language===e))!=null?t:null},LZe=(e,t)=>{var n;let s=(n=void 0)!=null?n:5;return new Promise((r,i)=>{let o="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),l=new Image;l.crossOrigin="anonymous",l.onload=()=>{let c=document.createElement("canvas"),u=l.width*s,d=l.height*s;c.width=u,c.height=d;let f=c.getContext("2d");if(!f){i(new Error("Failed to create 2D canvas context for PNG export"));return}f.drawImage(l,0,0,u,d),c.toBlob(m=>{if(!m){i(new Error("Failed to create PNG blob"));return}r(m)},"image/png")},l.onerror=()=>i(new Error("Failed to load SVG image")),l.src=o})},FZe=({chart:e,children:t,className:n,onDownload:s,config:r,onError:i})=>{let o=rn(),[l,c]=x.useState(!1),u=x.useRef(null),{isAnimating:d}=x.useContext(xa),f=Ao(),m=X4(),g=Kc(),y=async b=>{try{if(b==="mmd"){Gp("diagram.mmd",e,"text/plain"),c(!1),s==null||s(b);return}if(!m){i==null||i(new Error("Mermaid plugin not available"));return}let S=m.getMermaid(r),w=e.split("").reduce((E,j)=>(E<<5)-E+j.charCodeAt(0)|0,0),C=`mermaid-${Math.abs(w)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:T}=await S.render(C,e);if(!T){i==null||i(new Error("SVG not found. Please wait for the diagram to render."));return}if(b==="svg"){Gp("diagram.svg",T,"image/svg+xml"),c(!1),s==null||s(b);return}if(b==="png"){let E=await LZe(T);Gp("diagram.png",E,"image/png"),s==null||s(b),c(!1);return}}catch(S){i==null||i(S)}};return x.useEffect(()=>{let b=S=>{let w=S.composedPath();u.current&&!w.includes(u.current)&&c(!1)};return document.addEventListener("mousedown",b),()=>{document.removeEventListener("mousedown",b)}},[]),a.jsxs("div",{className:o("relative"),ref:u,children:[a.jsx("button",{className:o("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",n),disabled:d,onClick:()=>c(!l),title:g.downloadDiagram,type:"button",children:t??a.jsx(f.DownloadIcon,{size:14})}),l?a.jsxs("div",{className:o("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[a.jsx("button",{className:o("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>y("svg"),title:g.downloadDiagramAsSvg,type:"button",children:g.mermaidFormatSvg}),a.jsx("button",{className:o("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>y("png"),title:g.downloadDiagramAsPng,type:"button",children:g.mermaidFormatPng}),a.jsx("button",{className:o("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>y("mmd"),title:g.downloadDiagramAsMmd,type:"button",children:g.mermaidFormatMmd})]}):null]})},zZe=({chart:e,config:t,onFullscreen:n,onExit:s,className:r,...i})=>{let{Maximize2Icon:o,XIcon:l}=Ao(),c=rn(),[u,d]=x.useState(!1),{isAnimating:f,controls:m}=x.useContext(xa),g=Kc(),y=(()=>{if(typeof m=="boolean")return m;let S=m.mermaid;return S===!1?!1:S===!0||S===void 0?!0:S.panZoom!==!1})(),b=()=>{d(!u)};return x.useEffect(()=>{if(u){W4();let S=w=>{w.key==="Escape"&&d(!1)};return document.addEventListener("keydown",S),()=>{document.removeEventListener("keydown",S),Y4()}}},[u]),x.useEffect(()=>{u?n==null||n():s&&s()},[u,n,s]),a.jsxs(a.Fragment,{children:[a.jsx("button",{className:c("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:f,onClick:b,title:g.viewFullscreen,type:"button",...i,children:a.jsx(o,{size:14})}),u?Wa.createPortal(a.jsxs("div",{className:c("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),onClick:b,onKeyDown:S=>{S.key==="Escape"&&b()},role:"button",tabIndex:0,children:[a.jsx("button",{className:c("absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:b,title:g.exitFullscreen,type:"button",children:a.jsx(l,{size:20})}),a.jsx("div",{className:c("flex size-full items-center justify-center p-4"),onClick:S=>S.stopPropagation(),onKeyDown:S=>S.stopPropagation(),role:"presentation",children:a.jsx(Lle,{chart:e,className:c("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:!0,showControls:y})})]}),document.body):null]})},rle=e=>{var t,n;let s=[],r=[],i=e.querySelectorAll("thead th");for(let l of i)s.push(((t=l.textContent)==null?void 0:t.trim())||"");let o=e.querySelectorAll("tbody tr");for(let l of o){let c=[],u=l.querySelectorAll("td");for(let d of u)c.push(((n=d.textContent)==null?void 0:n.trim())||"");r.push(c)}return{headers:s,rows:r}},ile=e=>{let{headers:t,rows:n}=e,s=l=>{let c=!1,u=!1;for(let d of l){if(d==='"'){c=!0,u=!0;break}(d===","||d===`
|
|
1241
1241
|
`)&&(c=!0)}return c?u?`"${l.replace(/"/g,'""')}"`:`"${l}"`:l},r=t.length>0?n.length+1:n.length,i=new Array(r),o=0;t.length>0&&(i[o]=t.map(s).join(","),o+=1);for(let l of n)i[o]=l.map(s).join(","),o+=1;return i.join(`
|
|
1242
1242
|
`)},BZe=e=>{let{headers:t,rows:n}=e,s=l=>{let c=!1;for(let d of l)if(d===" "||d===`
|
|
@@ -1257,7 +1257,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1257
1257
|
|
|
1258
1258
|
`})}return n},bXe=/([\\`*_~[\]|])/g,SXe=e=>e.replace(bXe,"\\$1"),wXe=(e,t)=>{if(!t.length)return e;let n=e;for(let s of t){let r=new RegExp(`(<${s}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${s}\\s*>)`,"gi");n=n.replace(r,(i,o,l,c)=>{let u=SXe(l).replace(/\n\n/g," ");return o+u+c})}return n},Dle=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(Dle).join(""):"",kXe=e=>t=>{if(!e||e.length===0)return;let n=new Set(e.map(s=>s.toLowerCase()));dl(t,"element",s=>{if(n.has(s.tagName.toLowerCase())){let r=Dle(s);s.children=r?[{type:"text",value:r}]:[]}})},CXe=()=>e=>{dl(e,"code",t=>{var n,s;t.meta&&(t.data=(n=t.data)!=null?n:{},t.data.hProperties={...(s=t.data.hProperties)!=null?s:{},metastring:t.meta})})},EXe=/^[ \t]*<[\w!/?-]/,TXe=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,_Xe=e=>typeof e!="string"||e.length===0||!EXe.test(e)?e:e.replace(TXe,"$1"),tU,nU,sU,rU,rk={...Tf,protocols:{...Tf.protocols,href:[...(nU=(tU=Tf.protocols)==null?void 0:tU.href)!=null?nU:[],"tel"]},attributes:{...Tf.attributes,code:[...(rU=(sU=Tf.attributes)==null?void 0:sU.code)!=null?rU:[],"metastring"]}},gD={raw:J3,sanitize:[Uae,rk],harden:[w9e,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:!0}]},NXe={gfm:[Bqe,{}],codeMeta:CXe},iU=Object.values(gD),jXe=Object.values(NXe),AXe={block:" ▋",circle:" ●"},Ole=["github-light","github-dark"],Ile={enabled:!0},RXe={shikiTheme:Ole,controls:!0,isAnimating:!1,lineNumbers:!0,mode:"streaming",mermaid:void 0,linkSafety:Ile},xa=x.createContext(RXe),Ple=x.memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:n,index:s,isIncomplete:r,dir:i,animatePlugin:o,...l})=>{if(o){let d=o.getLastRenderCharCount();o.setPrevContentLength(d)}let c=typeof e=="string"&&n?_Xe(e):e,u=a.jsx(Mle,{...l,children:c});return a.jsx(Joe.Provider,{value:r,children:i?a.jsx("div",{dir:i,style:{display:"contents"},children:u}):u})},(e,t)=>{if(e.content!==t.content||e.shouldNormalizeHtmlIndentation!==t.shouldNormalizeHtmlIndentation||e.index!==t.index||e.isIncomplete!==t.isIncomplete||e.dir!==t.dir)return!1;if(e.components!==t.components){let n=Object.keys(e.components||{}),s=Object.keys(t.components||{});if(n.length!==s.length||n.some(r=>{var i,o;return((i=e.components)==null?void 0:i[r])!==((o=t.components)==null?void 0:o[r])}))return!1}return!(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});Ple.displayName="Block";var J4=x.memo(({children:e,mode:t="streaming",dir:n,parseIncompleteMarkdown:s=!0,normalizeHtmlIndentation:r=!1,components:i,rehypePlugins:o=iU,remarkPlugins:l=jXe,className:c,shikiTheme:u=Ole,mermaid:d,controls:f=!0,isAnimating:m=!1,animated:g,BlockComponent:y=Ple,parseMarkdownIntoBlocksFn:b=yXe,caret:S,plugins:w,remend:C,linkSafety:T=Ile,lineNumbers:E=!0,allowedTags:j,literalTagContent:_,translations:N,icons:R,prefix:O,onAnimationStart:M,onAnimationEnd:L,...P})=>{let $=x.useId(),[q,K]=x.useTransition(),B=x.useMemo(()=>fZe(O),[O]),V=x.useRef(null),Q=x.useRef(M),re=x.useRef(L);Q.current=M,re.current=L,x.useEffect(()=>{var He,gt,Ct;if(t==="static")return;let cn=V.current;if(V.current=m,cn===null){m&&((He=Q.current)==null||He.call(Q));return}m&&!cn?(gt=Q.current)==null||gt.call(Q):!m&&cn&&((Ct=re.current)==null||Ct.call(re))},[m,t]);let U=x.useMemo(()=>j?Object.keys(j):[],[j]),G=x.useMemo(()=>{if(typeof e!="string")return"";let He=t==="streaming"&&s?XGe(e,C):e;return _&&_.length>0&&(He=wXe(He,_)),U.length>0&&(He=vXe(He,U)),He},[e,t,s,C,U,_]),W=x.useMemo(()=>b(G),[G,b]),[F,X]=x.useState(W);x.useEffect(()=>{t==="streaming"&&!me?K(()=>{X(W)}):X(W)},[W,t]);let J=t==="streaming"?F:W,ae=x.useMemo(()=>n==="auto"?J.map(GH):void 0,[J,n]),oe=x.useMemo(()=>J.map((He,gt)=>`${$}-${gt}`),[J.length,$]),de=x.useMemo(()=>g===!0?"true":g?JSON.stringify(g):"",[g]),me=x.useMemo(()=>de?de==="true"?uD():uD(g):null,[de]),Re=x.useMemo(()=>{var He,gt;return{shikiTheme:(gt=(He=w==null?void 0:w.code)==null?void 0:He.getThemes())!=null?gt:u,controls:f,isAnimating:m,lineNumbers:E,mode:t,mermaid:d,linkSafety:T}},[u,f,m,E,t,d,T,w==null?void 0:w.code]),Fe=x.useMemo(()=>N?JSON.stringify(N):"",[N]),Le=x.useMemo(()=>({...sle,...N}),[Fe]),Xe=x.useMemo(()=>{let{inlineCode:He,...gt}=i??{},Ct={...YZe,...gt};if(He){let cn=Ct.code;Ct.code=Nt=>"data-block"in Nt?cn?x.createElement(cn,Nt):null:x.createElement(He,Nt)}return Ct},[i]),ze=x.useMemo(()=>{let He=[];return w!=null&&w.cjk&&(He=[...He,...w.cjk.remarkPluginsBefore]),He=[...He,...l],w!=null&&w.cjk&&(He=[...He,...w.cjk.remarkPluginsAfter]),w!=null&&w.math&&(He=[...He,w.math.remarkPlugin]),He},[l,w==null?void 0:w.math,w==null?void 0:w.cjk]),Mt=x.useMemo(()=>{var He;let gt=o;if(j&&Object.keys(j).length>0&&o===iU){let Ct={...rk,tagNames:[...(He=rk.tagNames)!=null?He:[],...Object.keys(j)],attributes:{...rk.attributes,...j}};gt=[gD.raw,[Uae,Ct],gD.harden]}return _&&_.length>0&&(gt=[...gt,[kXe,_]]),w!=null&&w.math&&(gt=[...gt,w.math.rehypePlugin]),me&&m&&(gt=[...gt,me.rehypePlugin]),gt},[o,w==null?void 0:w.math,me,m,j,_]),Ft=x.useMemo(()=>{if(!m||J.length===0)return!1;let He=J.at(-1);return KH(He)||eXe(He)},[m,J]),Pe=x.useMemo(()=>S&&m&&!Ft?{"--streamdown-caret":`"${AXe[S]}"`}:void 0,[S,m,Ft]);return t==="static"?a.jsx(fD.Provider,{value:Le,children:a.jsx(hD.Provider,{value:w??null,children:a.jsx(xa.Provider,{value:Re,children:a.jsx($H,{icons:R,children:a.jsx(dD.Provider,{value:B,children:a.jsx("div",{className:B("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",c),dir:n==="auto"?GH(G):n,children:a.jsx(Mle,{components:Xe,rehypePlugins:Mt,remarkPlugins:ze,...P,children:G})})})})})})}):a.jsx(fD.Provider,{value:Le,children:a.jsx(hD.Provider,{value:w??null,children:a.jsx(xa.Provider,{value:Re,children:a.jsx($H,{icons:R,children:a.jsx(dD.Provider,{value:B,children:a.jsxs("div",{className:B("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",S&&!Ft?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,c),style:Pe,children:[J.length===0&&S&&m&&a.jsx("span",{}),J.map((He,gt)=>{var Ct;let cn=gt===J.length-1,Nt=m&&cn&&KH(He);return a.jsx(y,{animatePlugin:me,components:Xe,content:He,dir:(Ct=ae==null?void 0:ae[gt])!=null?Ct:n!=="auto"?n:void 0,index:gt,isIncomplete:Nt,rehypePlugins:Mt,remarkPlugins:ze,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:s,...P},oe[gt])})]})})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.animated===t.animated&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety&&e.lineNumbers===t.lineNumbers&&e.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);J4.displayName="Streamdown";var MXe=({children:e,className:t,minZoom:n=.5,maxZoom:s=3,zoomStep:r=.1,showControls:i=!0,initialZoom:o=1,fullscreen:l=!1})=>{let{RotateCcwIcon:c,ZoomInIcon:u,ZoomOutIcon:d}=Ao(),f=rn(),m=x.useRef(null),g=x.useRef(null),[y,b]=x.useState(o),[S,w]=x.useState({x:0,y:0}),[C,T]=x.useState(!1),[E,j]=x.useState({x:0,y:0}),[_,N]=x.useState({x:0,y:0}),R=x.useCallback(B=>{b(V=>Math.max(n,Math.min(s,V+B)))},[n,s]),O=x.useCallback(()=>{R(r)},[R,r]),M=x.useCallback(()=>{R(-r)},[R,r]),L=x.useCallback(()=>{b(o),w({x:0,y:0})},[o]),P=x.useCallback(B=>{B.preventDefault();let V=B.deltaY>0?-r:r;R(V)},[R,r]),$=x.useCallback(B=>{if(B.button!==0||B.isPrimary===!1)return;T(!0),j({x:B.clientX,y:B.clientY}),N(S);let V=B.currentTarget;V instanceof HTMLElement&&V.setPointerCapture(B.pointerId)},[S]),q=x.useCallback(B=>{if(!C)return;B.preventDefault();let V=B.clientX-E.x,Q=B.clientY-E.y;w({x:_.x+V,y:_.y+Q})},[C,E,_]),K=x.useCallback(B=>{T(!1);let V=B.currentTarget;V instanceof HTMLElement&&V.releasePointerCapture(B.pointerId)},[]);return x.useEffect(()=>{let B=m.current;if(B)return B.addEventListener("wheel",P,{passive:!1}),()=>{B.removeEventListener("wheel",P)}},[P]),x.useEffect(()=>{let B=g.current;if(B&&C)return document.body.style.userSelect="none",B.addEventListener("pointermove",q,{passive:!1}),B.addEventListener("pointerup",K),B.addEventListener("pointercancel",K),()=>{document.body.style.userSelect="",B.removeEventListener("pointermove",q),B.removeEventListener("pointerup",K),B.removeEventListener("pointercancel",K)}},[C,q,K]),a.jsxs("div",{className:f("relative flex flex-col",l?"h-full w-full":"min-h-28 w-full",t),ref:m,style:{cursor:C?"grabbing":"grab"},children:[i?a.jsxs("div",{className:f("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm",l?"bottom-4 left-4":"bottom-2 left-2"),children:[a.jsx("button",{className:f("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:y>=s,onClick:O,title:"Zoom in",type:"button",children:a.jsx(u,{size:16})}),a.jsx("button",{className:f("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:y<=n,onClick:M,title:"Zoom out",type:"button",children:a.jsx(d,{size:16})}),a.jsx("button",{className:f("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:L,title:"Reset zoom and pan",type:"button",children:a.jsx(c,{size:16})})]}):null,a.jsx("div",{className:f("flex-1 origin-center transition-transform duration-150 ease-out",l?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:$,ref:g,role:"application",style:{transform:`translate(${S.x}px, ${S.y}px) scale(${y})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})},Lle=({chart:e,className:t,config:n,fullscreen:s=!1,showControls:r=!0})=>{let i=rn(),[o,l]=x.useState(null),[c,u]=x.useState(!1),[d,f]=x.useState(""),[m,g]=x.useState(""),[y,b]=x.useState(0),{mermaid:S}=x.useContext(xa),w=X4(),C=S==null?void 0:S.errorComponent,{shouldRender:T,containerRef:E}=eZe({immediate:s});if(x.useEffect(()=>{if(T){if(!w){l("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{l(null),u(!0);let _=w.getMermaid(n),N=e.split("").reduce((M,L)=>(M<<5)-M+L.charCodeAt(0)|0,0),R=`mermaid-${Math.abs(N)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:O}=await _.render(R,e);f(O),g(O)}catch(_){if(!(m||d)){let N=_ instanceof Error?_.message:"Failed to render Mermaid chart";l(N)}}finally{u(!1)}})()}},[e,n,y,T,w]),!(T||d||m))return a.jsx("div",{className:i("my-4 min-h-[200px]",t),ref:E});if(c&&!d&&!m)return a.jsx("div",{className:i("my-4 flex justify-center p-4",t),ref:E,children:a.jsxs("div",{className:i("flex items-center space-x-2 text-muted-foreground"),children:[a.jsx("div",{className:i("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),a.jsx("span",{className:i("text-sm"),children:"Loading diagram..."})]})});if(o&&!d&&!m){let _=()=>b(N=>N+1);return C?a.jsx("div",{ref:E,children:a.jsx(C,{chart:e,error:o,retry:_})}):a.jsxs("div",{className:i("rounded-md bg-red-50 p-4",t),ref:E,children:[a.jsxs("p",{className:i("font-mono text-red-700 text-sm"),children:["Mermaid Error: ",o]}),a.jsxs("details",{className:i("mt-2"),children:[a.jsx("summary",{className:i("cursor-pointer text-red-600 text-xs"),children:"Show Code"}),a.jsx("pre",{className:i("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let j=d||m;return a.jsx("div",{className:i("size-full",t),"data-streamdown":"mermaid",ref:E,children:a.jsx(MXe,{className:i(s?"size-full overflow-hidden":"overflow-hidden",t),fullscreen:s,maxZoom:3,minZoom:.5,showControls:r,zoomStep:.1,children:a.jsx("div",{"aria-label":"Mermaid chart",className:i("flex justify-center",s?"size-full items-center":null),dangerouslySetInnerHTML:{__html:j},role:"img"})})})};const DXe={enabled:!0,renderModal:e=>a.jsx(TT,{...e})};function Ev({content:e,className:t,linkSafety:n=!1}){return a.jsx("div",{className:Y("prose prose-sm dark:prose-invert max-w-none",t),children:a.jsx(J4,{linkSafety:n?DXe:void 0,children:e})})}function Al({...e}){return a.jsx($g,{"data-slot":"sheet",...e})}function OXe({...e}){return a.jsx(Jv,{"data-slot":"sheet-trigger",...e})}function IXe({...e}){return a.jsx(Hg,{"data-slot":"sheet-portal",...e})}function PXe({className:e,...t}){return a.jsx(Ph,{"data-slot":"sheet-overlay",className:Y("data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function Rl({className:e,children:t,side:n="right",showCloseButton:s=!0,...r}){return a.jsxs(IXe,{children:[a.jsx(PXe,{}),a.jsxs(Lh,{"data-slot":"sheet-content",className:Y("bg-background data-[state=closed]:animate-out data-[state=open]:animate-in fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",n==="right"&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",n==="left"&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",n==="top"&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",n==="bottom"&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",e),...r,children:[t,s&&a.jsxs(Fh,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",children:[a.jsx(es,{className:"size-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Ml({className:e,...t}){return a.jsx("div",{"data-slot":"sheet-header",className:Y("flex flex-col gap-1.5 p-4",e),...t})}function HT({className:e,...t}){return a.jsx("div",{"data-slot":"sheet-footer",className:Y("mt-auto flex flex-col gap-2 p-4",e),...t})}function Dl({className:e,...t}){return a.jsx(Ug,{"data-slot":"sheet-title",className:Y("text-foreground font-semibold",e),...t})}function Hd({className:e,...t}){return a.jsx(Vg,{"data-slot":"sheet-description",className:Y("text-muted-foreground text-sm",e),...t})}const LXe="16rem",FXe="18rem",zXe="3rem",BXe="b",eP=x.createContext(null);function UT(){const e=x.useContext(eP);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}function $Xe({defaultOpen:e=!0,open:t,onOpenChange:n,className:s,style:r,children:i,...o}){const l=Us(),[c,u]=x.useState(!1),[d,f]=x.useState(e),m=t??d,g=x.useCallback(w=>{const C=typeof w=="function"?w(m):w;n?n(C):f(C)},[n,m]),y=x.useCallback(()=>l?u(w=>!w):g(w=>!w),[l,g,u]);x.useEffect(()=>{const w=C=>{C.key===BXe&&(C.metaKey||C.ctrlKey)&&(C.preventDefault(),y())};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[y]);const b=m?"expanded":"collapsed",S=x.useMemo(()=>({state:b,open:m,setOpen:g,isMobile:l,openMobile:c,setOpenMobile:u,toggleSidebar:y}),[b,m,g,l,c,u,y]);return a.jsx(eP.Provider,{value:S,children:a.jsx(em,{delayDuration:0,children:a.jsx("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":LXe,"--sidebar-width-icon":zXe,...r},className:Y("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full",s),...o,children:i})})})}function HXe({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:s,children:r,...i}){const{isMobile:o,state:l,openMobile:c,setOpenMobile:u}=UT();return n==="none"?a.jsx("div",{"data-slot":"sidebar",className:Y("bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",s),...i,children:r}):o?a.jsx(Al,{open:c,onOpenChange:u,...i,children:a.jsxs(Rl,{"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden",style:{"--sidebar-width":FXe},side:e,children:[a.jsxs(Ml,{className:"sr-only",children:[a.jsx(Dl,{children:"Sidebar"}),a.jsx(Hd,{children:"Displays the mobile sidebar."})]}),a.jsx("div",{className:"flex h-full w-full flex-col",children:r})]})}):a.jsxs("div",{className:"group peer text-sidebar-foreground hidden md:block","data-state":l,"data-collapsible":l==="collapsed"?n:"","data-variant":t,"data-side":e,"data-slot":"sidebar",children:[a.jsx("div",{"data-slot":"sidebar-gap",className:Y("relative w-(--sidebar-width) bg-transparent transition-[width] duration-300 ease-in-out","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),a.jsx("div",{"data-slot":"sidebar-container",className:Y("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-300 ease-in-out md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",s),...i,children:a.jsx("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-md",children:r})})]})}function UXe({className:e,onClick:t,...n}){const{toggleSidebar:s}=UT();return a.jsxs(ge,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon",className:Y("size-7",e),onClick:r=>{t==null||t(r),s()},...n,children:[a.jsx(JMe,{}),a.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})}function VXe({className:e,...t}){const{toggleSidebar:n}=UT();return a.jsx("button",{"data-sidebar":"rail","data-slot":"sidebar-rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:n,title:"Toggle Sidebar",className:Y("hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex","in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})}function qXe({className:e,...t}){return a.jsx("main",{"data-slot":"sidebar-inset",className:Y("bg-background relative flex min-w-0 flex-1 flex-col","md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",e),...t})}function Fle({className:e,...t}){return a.jsx("div",{"data-slot":"sidebar-header","data-sidebar":"header",className:Y("flex flex-col gap-2 p-2",e),...t})}function GXe({className:e,...t}){return a.jsx("div",{"data-slot":"sidebar-footer","data-sidebar":"footer",className:Y("flex flex-col gap-2 p-2",e),...t})}function zle({className:e,...t}){return a.jsx("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:Y("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t})}function Nc({className:e,...t}){return a.jsx("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:Y("relative flex w-full min-w-0 flex-col p-2",e),...t})}function po({className:e,asChild:t=!1,...n}){const s=t?Zv:"div";return a.jsx(s,{"data-slot":"sidebar-group-label","data-sidebar":"group-label",className:Y("text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-hidden transition-[margin,opacity] duration-300 ease-in-out focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...n})}function ik({className:e,asChild:t=!1,...n}){const s=t?Zv:"button";return a.jsx(s,{"data-slot":"sidebar-group-action","data-sidebar":"group-action",className:Y("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 md:after:hidden","group-data-[collapsible=icon]:hidden",e),...n})}function Xr({className:e,...t}){return a.jsx("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:Y("flex w-full min-w-0 flex-col gap-1",e),...t})}function Lr({className:e,...t}){return a.jsx("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:Y("group/menu-item relative",e),...t})}const KXe=Td("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding,background-color,color,transform] duration-150 ease-out group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:scale-[0.97] active:duration-100 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function Ni({asChild:e=!1,isActive:t=!1,variant:n="default",size:s="default",tooltip:r,className:i,...o}){const l=e?Zv:"button",{isMobile:c,state:u}=UT(),d=a.jsx(l,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":s,"data-active":t,className:Y(KXe({variant:n,size:s}),i),...o});return r?(typeof r=="string"&&(r={children:r}),a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:d}),a.jsx(yn,{side:"right",align:"center",hidden:u!=="collapsed"||c,...r})]})):d}function WXe({className:e,asChild:t=!1,showOnHover:n=!1,...s}){const r=t?Zv:"button";return a.jsx(r,{"data-slot":"sidebar-menu-action","data-sidebar":"menu-action",className:Y("text-sidebar-foreground ring-sidebar-ring peer-hover/menu-button:text-sidebar-accent-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 md:after:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",n&&"peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0",e),...s})}const Ble=x.createContext(null);function b0(){const e=x.useContext(Ble);if(!e)throw new Error("useFilterBar must be used within a <FilterBar> component.");return e}function YXe({state:e,children:t,className:n}){return a.jsx(Ble.Provider,{value:e,children:a.jsx("div",{"data-slot":"filter-bar",className:Y("flex flex-wrap items-center gap-2 px-4 py-3",n),children:t})})}function ZXe({placeholder:e="Search...",className:t}){const{inputValues:n,set:s}=b0(),r=n.search;return a.jsxs("div",{"data-slot":"filter-bar-search",className:Y("relative",t),children:[a.jsx(pa,{className:"text-muted-foreground pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2"}),a.jsx(sn,{responsive:!1,placeholder:e,value:r??"",onChange:i=>s("search",i.target.value),className:"h-8 pl-8 text-sm sm:max-w-64"})]})}function XXe({name:e,className:t}){var g;const{schema:n,values:s,set:r}=b0(),[i,o]=x.useState(!1),l=n.definitions[e];if(!l||!QE(l))return null;const c=l,u=c.label??e,d=s[e]??[],f=d.length===0?u:d.length===1?`${u}: ${((g=c.labels)==null?void 0:g[d[0]])??d[0]}`:`${u}: ${d.length} selected`;function m(y){const b=d.includes(y)?d.filter(S=>S!==y):[...d,y];r(e,b)}return a.jsxs(c0,{open:i,onOpenChange:o,children:[a.jsxs(u0,{"data-slot":"filter-bar-primary",className:Y("border-input hover:bg-accent hover:text-accent-foreground inline-flex h-7 items-center gap-1 rounded-md border px-2.5 text-xs",d.length>0&&"border-primary/50",t),children:[f,a.jsx(Hs,{className:"size-3 opacity-50"})]}),a.jsx(d0,{align:"start",className:"w-48 p-1",children:c.options.map(y=>{var b,S;return a.jsxs("label",{className:"hover:bg-accent flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-xs",children:[a.jsx(Sg,{checked:d.includes(y),onCheckedChange:()=>m(y)}),((b=c.colors)==null?void 0:b[y])&&a.jsx("span",{className:Y("size-2 shrink-0 rounded-full bg-current",c.colors[y])}),a.jsx("span",{children:((S=c.labels)==null?void 0:S[y])??y})]},y)})})]})}const QXe={enum:Y5,dateRange:Kte,boolean:hDe,numericRange:ZRe},JXe=[{label:"Past 1h",value:"1h"},{label:"Past 24h",value:"24h"},{label:"Past 7d",value:"7d"},{label:"Past 30d",value:"30d"}];function eQe({dynamicOptions:e,className:t}){const{schema:n,values:s,set:r,clear:i}=b0(),[o,l]=x.useState(!1),[c,u]=x.useState("list"),d=Object.entries(n.definitions).filter(([,j])=>j.type!=="text");function f(j){l(j),j||u("list")}function m(j){u(j)}function g(){u("list")}function y(){return a.jsx("div",{className:"flex flex-col",children:d.map(([j,_])=>{const N=QXe[_.type]??Y5,R=_.isActive(s[j]),O=_.label??j;return a.jsxs("button",{type:"button",onClick:()=>m(j),className:"hover:bg-accent flex items-center gap-2 rounded-sm px-2 py-1.5 text-xs",children:[a.jsx(N,{className:"text-muted-foreground size-3.5"}),a.jsx("span",{className:"flex-1 text-left",children:O}),R&&a.jsx(Lt,{className:"text-primary size-3"})]},j)})})}function b(j){const _=n.definitions[j];if(!_)return null;const N=_.label??j;return a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs("button",{type:"button",onClick:g,className:"hover:bg-accent -mx-1 flex items-center gap-1 rounded-sm px-1 py-1 text-xs font-medium",children:[a.jsx(ov,{className:"size-3"}),N]}),S(j)]})}function S(j){const _=n.definitions[j];return _?QE(_)?w(j,_):_.type==="dateRange"?C(j):_.type==="boolean"?T(j):_.type==="numericRange"?E(j):null:null}function w(j,_){const N=_.dynamic?(e==null?void 0:e[j])??_.options:_.options,R=s[j]??(_.multi?[]:""),O=Array.isArray(R)?R:R?[R]:[];function M(L){if(_.multi){const P=O.includes(L)?O.filter($=>$!==L):[...O,L];r(j,P)}else r(j,O.includes(L)?"":L)}return a.jsxs("div",{className:"flex flex-col",children:[N.map(L=>{var P,$;return a.jsxs("label",{className:"hover:bg-accent flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-xs",children:[a.jsx(Sg,{checked:O.includes(L),onCheckedChange:()=>M(L)}),((P=_.colors)==null?void 0:P[L])&&a.jsx("span",{className:Y("size-2 shrink-0 rounded-full bg-current",_.colors[L])}),a.jsx("span",{children:(($=_.labels)==null?void 0:$[L])??L})]},L)}),O.length>0&&a.jsx(ge,{variant:"ghost",size:"xs",responsive:!1,className:"mt-1 self-start",onClick:()=>i(j),children:"Clear"})]})}function C(j){const _=s[j]??{};return a.jsxs("div",{className:"flex flex-col gap-1",children:[JXe.map(N=>a.jsx("button",{type:"button",onClick:()=>r(j,{preset:N.value}),className:Y("hover:bg-accent rounded-sm px-2 py-1.5 text-left text-xs",_.preset===N.value&&"bg-accent font-medium"),children:N.label},N.value)),_.preset&&a.jsx(ge,{variant:"ghost",size:"xs",responsive:!1,className:"mt-1 self-start",onClick:()=>i(j),children:"Clear"})]})}function T(j){const _=s[j];return a.jsx("div",{className:"flex flex-col gap-1",children:[!0,!1].map(N=>a.jsx("button",{type:"button",onClick:()=>r(j,_===N?null:N),className:Y("hover:bg-accent rounded-sm px-2 py-1.5 text-left text-xs",_===N&&"bg-accent font-medium"),children:N?"Yes":"No"},String(N)))})}function E(j){const _=s[j]??{};return a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:"text-muted-foreground w-8",children:"Min"}),a.jsx(sn,{responsive:!1,type:"number","aria-label":"Minimum value",value:_.min??"",onChange:N=>r(j,{..._,min:N.target.value?Number(N.target.value):void 0}),className:"h-7 text-xs"})]}),a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:"text-muted-foreground w-8",children:"Max"}),a.jsx(sn,{responsive:!1,type:"number","aria-label":"Maximum value",value:_.max??"",onChange:N=>r(j,{..._,max:N.target.value?Number(N.target.value):void 0}),className:"h-7 text-xs"})]})]})}return a.jsxs(c0,{open:o,onOpenChange:f,children:[a.jsxs(u0,{"data-slot":"filter-bar-add-filter",className:Y("border-muted text-muted-foreground hover:text-foreground hover:border-input inline-flex h-7 items-center gap-1 rounded-md border border-dashed px-2.5 text-xs",t),children:[a.jsx(Cs,{className:"size-3"}),"Filter"]}),a.jsx(d0,{align:"start",className:"w-52 p-1",children:c==="list"?y():b(c)})]})}function tQe({options:e,className:t}){var c;const{sortField:n,sortDirection:s,setSort:r}=b0(),i=((c=e[n])==null?void 0:c.label)??n,o=s==="asc"?mb:hb;function l(u){u.stopPropagation(),r(n,s==="asc"?"desc":"asc")}return a.jsxs(a0,{children:[a.jsxs(o0,{"data-slot":"filter-bar-sort",className:Y("border-input hover:bg-accent hover:text-accent-foreground inline-flex h-7 items-center gap-1 rounded-md border px-2.5 text-xs",t),children:["Sort: ",i,a.jsx("span",{role:"button",tabIndex:-1,onClick:l,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),l(u))},className:"hover:bg-muted -mr-1 rounded p-0.5","aria-label":`Sort ${s==="asc"?"descending":"ascending"}`,children:a.jsx(o,{className:"size-3"})})]}),a.jsx(Qh,{align:"start",children:Object.entries(e).map(([u,d])=>a.jsx(Nr,{onClick:()=>r(u,s),className:Y(u===n&&"bg-accent font-medium"),children:d.label},u))})]})}function nQe({count:e,total:t,noun:n,className:s}){const{clearAll:r}=b0(),i=e===1?n:`${n}s`;return a.jsxs("div",{"data-slot":"filter-bar-result-count",className:Y("text-muted-foreground ml-auto flex items-center gap-2 text-xs",s),children:[a.jsx("span",{children:e===t?`${e} ${i}`:`${e} of ${t} ${i}`}),e<t&&a.jsx(ge,{variant:"ghost",size:"xs",responsive:!1,onClick:r,children:"Clear all"})]})}function sQe({className:e}){const{schema:t,values:n,activeCount:s,isFiltered:r,clear:i,clearAll:o}=b0(),l=Us(),[c,u]=x.useState(!1);if(!r)return null;const d=Object.entries(t.definitions).filter(([f,m])=>{const g=n[f];return m.isActive(g)}).map(([f,m])=>{const g=n[f],y=m.label??f;let b;if(m.type==="text")b=String(g);else if(QE(m)&&m.labels){const S=w=>{var C;return((C=m.labels)==null?void 0:C[w])??w};b=Array.isArray(g)?g.map(S).join(", "):S(g)}else if(m.type==="dateRange"){const S=g;S.preset?b=`Past ${S.preset}`:S.after&&S.before?b=`${S.after} – ${S.before}`:S.after?b=`After ${S.after}`:S.before?b=`Before ${S.before}`:b=String(g)}else if(m.type==="numericRange"){const S=g;S.min!==void 0&&S.max!==void 0?b=`${S.min}–${S.max}`:S.min!==void 0?b=`≥ ${S.min}`:S.max!==void 0?b=`≤ ${S.max}`:b=String(g)}else m.type==="boolean"?b=g===!0?"Yes":"No":Array.isArray(g)?b=g.join(", "):b=String(g);return{name:f,label:y,displayValue:b}});return l?a.jsxs(Al,{open:c,onOpenChange:u,children:[a.jsxs(OXe,{"data-slot":"filter-bar-active-filters",className:Y("border-primary/50 inline-flex h-7 items-center gap-1 rounded-md border px-2 text-xs",e),children:[a.jsx(URe,{className:"size-3"}),s]}),a.jsxs(Rl,{side:"bottom",children:[a.jsx(Ml,{children:a.jsx(Dl,{children:"Active filters"})}),a.jsxs("div",{className:"flex flex-col gap-2 p-4",children:[d.map(({name:f,label:m,displayValue:g})=>a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsxs("span",{children:[m,": ",g]}),a.jsx(ge,{variant:"ghost",size:"icon-xs",responsive:!1,onClick:()=>i(f),"aria-label":`Remove ${m} filter`,children:a.jsx(es,{className:"size-3"})})]},f)),a.jsx(ge,{variant:"ghost",size:"xs",responsive:!1,className:"mt-2 self-start",onClick:()=>{o(),u(!1)},children:"Clear all"})]})]})]}):a.jsx("div",{"data-slot":"filter-bar-active-filters",className:Y("flex flex-wrap items-center gap-1",e),children:d.map(({name:f,label:m,displayValue:g})=>a.jsxs("span",{className:"border-muted bg-muted/50 inline-flex h-6 items-center gap-1 rounded-full border px-2 text-xs",children:[m,": ",g,a.jsx("button",{type:"button",onClick:()=>i(f),className:"hover:text-foreground text-muted-foreground -mr-0.5 rounded-full p-0.5","aria-label":`Remove ${m} filter`,children:a.jsx(es,{className:"size-3"})})]},f))})}const ji=Object.assign(YXe,{Search:ZXe,Primary:XXe,AddFilter:eQe,Sort:tQe,ResultCount:nQe,ActiveFilters:sQe});function rQe({error:e}){const t=Oi(),[n,s]=x.useState(!1);return a.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-6 p-8",children:[a.jsx(fr,{className:"text-muted-foreground size-10"}),a.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[a.jsx("h2",{className:"text-foreground text-lg font-semibold",children:"Something went wrong"}),a.jsx("p",{className:"text-muted-foreground max-w-md text-sm",children:e.message})]}),!1,a.jsxs("div",{className:"flex gap-3",children:[a.jsx(ge,{variant:"outline",size:"sm",onClick:()=>t.invalidate(),children:"Retry"}),a.jsx(ge,{variant:"ghost",size:"sm",onClick:()=>t.navigate({to:"/"}),children:"Go to Dashboard"})]})]})}function $le(){return a.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-6 p-8",children:[a.jsx(pa,{className:"text-muted-foreground size-10"}),a.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[a.jsx("h2",{className:"text-foreground text-lg font-semibold",children:"Page not found"}),a.jsx("p",{className:"text-muted-foreground max-w-md text-sm",children:"The page you're looking for doesn't exist."})]}),a.jsx(ge,{variant:"outline",size:"sm",asChild:!0,children:a.jsx(QC,{to:"/",children:"Go to Dashboard"})})]})}function iQe({error:e}){const t=e instanceof Error?e.message:String(e);return e instanceof Error&&e.stack,a.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100dvh",padding:"2rem",backgroundColor:"#09090b",color:"#d4d4d8",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace'},children:[a.jsx("p",{style:{fontSize:"1rem",fontWeight:600,marginBottom:"0.5rem"},children:"DorkOS encountered an unexpected error."}),a.jsx("p",{style:{fontSize:"0.75rem",opacity:.6,maxWidth:"32rem",textAlign:"center"},children:t}),!1,a.jsx("button",{onClick:()=>window.location.reload(),style:{marginTop:"1.5rem",padding:"0.5rem 1rem",fontSize:"0.875rem",backgroundColor:"transparent",color:"#d4d4d8",border:"1px solid #3f3f46",borderRadius:"0.375rem",cursor:"pointer",fontFamily:"inherit"},onMouseOver:n=>{n.target.style.backgroundColor="#18181b"},onFocus:n=>{n.target.style.backgroundColor="#18181b"},onMouseOut:n=>{n.target.style.backgroundColor="transparent"},onBlur:n=>{n.target.style.backgroundColor="transparent"},children:"Reload DorkOS"})]})}const aQe=["capabilities"];function im(){const e=je();return st({queryKey:[...aQe],queryFn:()=>e.getCapabilities(),staleTime:1/0})}function tP(e){const{data:t}=im();if(t)return t.capabilities[e??t.defaultRuntime]}const Wc=["requirements"];function VT(){const e=je();return st({queryKey:[...Wc],queryFn:()=>e.checkRequirements(),staleTime:5*6e4,refetchOnWindowFocus:!1})}function xD(e,t){const n=e==null?void 0:e.runtimes[t];return n?n.dependencies.every(s=>s.status==="satisfied"):!0}function Hle(e,t,n=!0){const s=e==null?void 0:e.runtimes[t];return s?s.state?{state:s.state,connect:s.connect}:Cwe(t,s.dependencies):!e||n?{state:"ready"}:{state:"connect",connect:{kind:"install",label:`Install ${BZ(t)}`}}}function oQe(){var l,c;const e=je(),t=et(),[n,s]=x.useState(null),r=Bt({mutationFn:()=>(s(null),e.provisionOpenCode(u=>s(u))),onSuccess:u=>{u.ok&&t.invalidateQueries({queryKey:[...Wc]})}}),i=r.isError||((l=r.data)==null?void 0:l.ok)===!1,o=r.isError?r.error.message:((c=r.data)==null?void 0:c.error)??null;return{provision:()=>r.mutate(),isPending:r.isPending,isError:i,errorMessage:i?o??"Something went wrong.":null,progress:n,result:r.data}}function lQe({size:e=16,className:t}){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor",className:t,"aria-hidden":"true",children:a.jsx("path",{d:"M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z"})})}function Ule({size:e=16,className:t}){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor",className:t,"aria-hidden":"true",children:a.jsx("path",{d:"M17.304 3.541h-3.672l6.696 16.918h3.672zm-10.608 0L0 20.459h3.744l1.37-3.553h7.005l1.369 3.553h3.744L10.536 3.541zm-.372 10.339 2.18-5.632 2.171 5.632z"})})}function Vle({size:e=16,className:t}){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor",className:t,"aria-hidden":"true",children:a.jsx("path",{d:"M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"})})}const qle=Vle;function Gle({size:e=16,className:t}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",className:t,"aria-hidden":"true",children:[a.jsx("path",{d:"M8.5 5.5 2.5 12l6 6.5"}),a.jsx("path",{d:"m15.5 5.5 6 6.5-6 6.5"}),a.jsx("circle",{cx:"12",cy:"12",r:"1.6",fill:"currentColor",stroke:"none"})]})}function aU({size:e=16,className:t}){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor",className:t,"aria-hidden":"true",children:a.jsx("path",{d:"M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81"})})}function cQe({size:e=16,className:t}){return a.jsx(ADe,{className:t,style:{width:e,height:e}})}function uQe({size:e=16,className:t}){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",className:t,"aria-hidden":"true",children:a.jsx("text",{x:"12",y:"18",textAnchor:"middle",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"20",fontWeight:"900",fill:"currentColor",children:"#"})})}function dQe({size:e=16,className:t}){return a.jsx(Ad,{className:t,style:{width:e,height:e}})}const oU={telegram:lQe,"claude-code":Ule,openai:Vle,codex:qle,opencode:Gle,gemini:aU,"gemini-cli":aU,slack:uQe,webhook:cQe},Kle={"claude-code":{type:"claude-code",label:"Claude Code",icon:Ule,accent:"var(--color-orange-500)"},opencode:{type:"opencode",label:"OpenCode",icon:Gle,accent:"var(--color-violet-500)",setup:{installCommand:"npm i -g opencode-ai && opencode auth login",infoUrl:"https://opencode.ai/docs/server"}},codex:{type:"codex",label:"Codex",icon:qle,accent:"var(--color-teal-500)",setup:{installCommand:"npm i -g @openai/codex && codex login",infoUrl:"https://developers.openai.com/codex"}},"test-mode":{type:"test-mode",label:"Test Mode",icon:DRe,accent:"var(--color-amber-500)"}},yD=["claude-code","codex","opencode"];function Ka(e){return Kle[e]??{type:e,label:e,icon:dQe,accent:"var(--color-muted-foreground)"}}function fQe(e){const t=e==null?void 0:e.trim();if(!t)return null;const n=t.lastIndexOf("/"),s=n>=0?t.slice(n+1):t;return s.length>0?s:null}function Wle(e){const t=Ka(e.runtime).label,n=fQe(e.model);return{label:t,modelLabel:n,text:n?`${t} · ${n}`:t}}function Yle({type:e,model:t,size:n=12,className:s}){const i=Ka(e).icon,{text:o}=Wle({runtime:e,model:t});return a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx("span",{"aria-label":`Runtime: ${o}`,className:Y("inline-flex shrink-0 items-center",s),children:a.jsx(i,{size:n})})}),a.jsx(yn,{side:"top",sideOffset:4,children:o})]})}function vD({runtime:e,model:t,size:n=12,className:s,iconClassName:r}){const i=Ka(e).icon,{text:o}=Wle({runtime:e,model:t});return a.jsxs("span",{className:Y("inline-flex items-center gap-1",s),children:[a.jsx(i,{...r?{className:r}:{size:n}}),a.jsx("span",{children:o})]})}const lU=new Set(["ollama","lmstudio","llamacpp","llama.cpp","vllm","local"]),cU=14;function hQe(e){const t=e.match(/(\d+(?:\.\d+)?)\s*b\b/i);if(!t)return null;const n=Number.parseFloat(t[1]);return Number.isFinite(n)?n:null}function mQe(e,t){const n=e==null?void 0:e.trim().toLowerCase();if(n)return lU.has(n)?"local":"cloud";const s=t.indexOf("/"),r=s>=0?t.slice(0,s).toLowerCase():"";return r&&lU.has(r)?"local":"cloud"}function pQe(e){const t=mQe(e.provider,e.modelId),n=hQe(e.modelId);if(t==="local"){const s=n!==null&&n<cU;return{locality:t,badgeLabel:"local · private · free",benefit:"Private and free — it runs on your machine, so your code never leaves it and there are no per-token bills.",capability:s?`Capable for everyday coding, but not frontier — small local models (under ~${cU}B) are unreliable at tool-calling. For frontier quality, reach for Claude, Codex, or a top cloud model.`:"Runs entirely on your machine — capable, though frontier quality still comes from Claude, Codex, or a top cloud model.",paramsB:n}}return{locality:t,badgeLabel:"cloud · per-token",benefit:"Runs in the cloud, billed per token — nothing to install, no local hardware needed.",capability:"Frontier quality — Claude, Codex, and top cloud models live here.",paramsB:n}}function nP({provider:e,modelId:t,detail:n,className:s}){const r=pQe({provider:e,modelId:t}),i=r.locality==="local",o=i?pb:XM;return a.jsxs("div",{className:Y("space-y-1",s),children:[a.jsxs(zt,{variant:"secondary",className:Y("gap-1 font-normal",i?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"),"data-locality":r.locality,children:[a.jsx(o,{className:"size-3","aria-hidden":!0}),r.badgeLabel]}),n&&a.jsxs("div",{className:"space-y-0.5",children:[a.jsx("p",{className:"text-muted-foreground text-xs",children:r.benefit}),a.jsx("p",{className:"text-muted-foreground/80 text-[11px] leading-snug",children:r.capability})]})]})}function sP({command:e,infoUrl:t,copyLabel:n}){return!e&&!t?null:a.jsxs("div",{className:"space-y-2",children:[e&&a.jsxs("div",{className:"bg-muted flex items-center justify-between gap-2 rounded-lg px-3 py-2.5",children:[a.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[a.jsx(J5,{className:"text-muted-foreground size-3.5 shrink-0"}),a.jsx("code",{className:"truncate text-xs",children:e})]}),a.jsx(vv,{value:e,label:n??"Copy install command",className:"shrink-0"})]}),t&&a.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:["Learn more ",a.jsx(fa,{className:"size-3"})]})]})}function gQe(e,t){if(e)return[e];const n=t.filter(s=>!yD.includes(s)&&s!=="test-mode");return[...yD,...n]}function Zle({runtime:e,requirements:t,registeredTypes:n=[],onRecheck:s,isRechecking:r=!1,renderConnect:i}){const o=gQe(e,n);return a.jsxs("div",{className:"space-y-4","data-testid":"runtime-setup-panel",children:[o.map(l=>a.jsx(xQe,{type:l,requirements:t,registered:n.includes(l),renderConnect:i},l)),s&&a.jsxs("div",{className:"flex items-center justify-end gap-3 pt-1",children:[a.jsx("p",{className:"text-muted-foreground text-xs",children:"Refresh after connecting."}),a.jsxs(ge,{variant:"outline",size:"sm",className:"gap-2",onClick:s,disabled:r,children:[a.jsx(ma,{className:Y("size-3.5",r&&"animate-spin")}),"Check again"]})]})]})}function xQe({type:e,requirements:t,registered:n,renderConnect:s}){const r=Ka(e),i=r.icon,o=t==null?void 0:t.runtimes[e],l=Hle(t,e,n),c=l.state==="ready",[u,d]=x.useState(!1),f=!!o||!!r.setup;return a.jsxs("section",{className:"border-border rounded-xl border p-4","data-testid":`runtime-section-${e}`,children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(i,{className:"size-4"}),a.jsx("span",{className:"text-sm font-medium",children:r.label})]}),c&&a.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-emerald-500","data-testid":`runtime-ready-${e}`,children:[a.jsx(Lt,{className:"size-3.5"})," Ready"]})]}),!c&&l.connect&&a.jsx("div",{className:"mt-3",children:a.jsx(yQe,{type:e,connect:l.connect,renderConnect:s,onShowDetails:()=>d(!0)})}),f&&a.jsxs(ol,{open:u,onOpenChange:d,className:"mt-3",children:[a.jsxs(ll,{className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:[a.jsx(Hs,{className:Y("size-3.5 transition-transform",u&&"rotate-180")}),"Setup details"]}),a.jsx(cl,{className:"mt-3 space-y-3",children:o?o.dependencies.map(m=>a.jsx(SQe,{dep:m},m.name)):a.jsxs(a.Fragment,{children:[a.jsxs("p",{className:"text-muted-foreground text-xs",children:["Not registered with this server. Install it, then enable"," ",a.jsxs("code",{className:"text-2xs",children:["runtimes.",e]})," in your DorkOS config."]}),r.setup&&a.jsx(sP,{command:r.setup.installCommand,infoUrl:r.setup.infoUrl,copyLabel:`Copy install command for ${r.label}`})]})})]})]})}function yQe({type:e,connect:t,renderConnect:n,onShowDetails:s}){return e==="opencode"&&t.kind==="install"?a.jsx(vQe,{label:t.label}):n&&(t.kind==="login"||t.kind==="provider-picker")?a.jsx(a.Fragment,{children:n({type:e,connect:t})}):a.jsx(ge,{size:"sm",onClick:s,children:t.label})}function vQe({label:e}){const{provision:t,isPending:n,isError:s,errorMessage:r,progress:i,result:o}=oQe();return n||o!=null&&o.ok?a.jsx(bQe,{message:(i==null?void 0:i.message)??"Installing OpenCode…"}):s?a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-destructive text-xs",role:"alert",children:r}),a.jsx(ge,{size:"sm",onClick:t,children:"Try again"})]}):a.jsx(ge,{size:"sm",onClick:t,children:e})}function bQe({message:e}){const t=Ds();return a.jsxs(te.div,{className:"bg-muted flex items-center gap-2 rounded-lg px-3 py-2.5",initial:t?!1:{opacity:0},animate:{opacity:1},"data-testid":"provision-progress",children:[a.jsx(te.span,{className:"text-muted-foreground inline-flex",animate:t?{}:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:a.jsx(Sn,{className:"size-3.5"})}),a.jsx(Ue,{mode:"wait",children:a.jsx(te.span,{className:"truncate text-xs",initial:t?!1:{opacity:0},animate:{opacity:1},exit:t?void 0:{opacity:0},transition:{duration:.2},children:e},e)})]})}function SQe({dep:e}){const t=e.status==="satisfied";return a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[t?a.jsx(Lt,{className:"size-3.5 shrink-0 text-emerald-500"}):a.jsx(Hh,{className:"size-3.5 shrink-0 text-amber-500"}),a.jsx("span",{className:"text-sm",children:e.name}),a.jsx("span",{className:"text-muted-foreground truncate text-xs",children:t&&e.version?`v${e.version}`:e.description})]}),!t&&(e.installHint||e.infoUrl)&&a.jsx(sP,{command:e.installHint,infoUrl:e.infoUrl,copyLabel:`Copy install command for ${e.name}`})]})}function Xle({runtime:e,open:t,onOpenChange:n,renderConnect:s,onRuntimeReady:r}){const i=VT(),{data:o}=im(),l=e?Ka(e):null,c=Hle(i.data,e??"",o?e!==void 0&&e in o.capabilities:!0),u=i.data!==void 0,d=l!==null&&u&&c.state==="ready",f=x.useRef(null);return x.useEffect(()=>{if(!t){f.current=null;return}if(e===void 0||!u)return;const m=f.current;f.current={runtime:e,ready:d},m!==null&&m.runtime===e&&!m.ready&&d&&(r==null||r(e))},[t,u,d,e,r]),a.jsx(fi,{open:t,onOpenChange:n,children:a.jsxs(hi,{className:"sm:max-w-md",children:[a.jsxs(va,{children:[a.jsx(Li,{children:l?l.label:"Your runtimes"}),a.jsx(Ga,{children:l?d?"This runtime is ready to use.":"Connect it to start a session.":"Connect any runtime to start a session with it."})]}),a.jsx(Ab,{children:a.jsx(Zle,{runtime:e,requirements:i.data,registeredTypes:o?Object.keys(o.capabilities):void 0,onRecheck:()=>void i.refetch(),isRechecking:i.isFetching,renderConnect:s})})]})})}function Qle({children:e,onRename:t,onFork:n}){return!t&&!n?a.jsx(a.Fragment,{children:e}):a.jsxs(Aie,{children:[a.jsx(Rie,{asChild:!0,children:e}),a.jsxs(Mie,{className:"w-44",children:[t&&a.jsxs(Ny,{onClick:t,children:[a.jsx(KE,{className:"mr-2 size-4"}),"Rename"]}),t&&n&&a.jsx(z3,{}),n&&a.jsxs(Ny,{onClick:n,children:[a.jsx(nne,{className:"mr-2 size-4"}),"Fork session"]})]})]})}function uU(e){try{return new Date(e).toLocaleString([],{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return e}}function wQe({session:e,isActive:t,onClick:n,onFork:s,onRename:r,isNew:i=!1}){const[o,l]=x.useState(!1),[c,u]=x.useState(!1),[d,f]=x.useState(""),m=x.useRef(null),g=x.useRef(!1),y=e.permissionMode==="bypassPermissions",b=Gh(6e4),S=x.useMemo(()=>ii(e.updatedAt),[e.updatedAt,b]);x.useEffect(()=>{c&&(g.current=!1,requestAnimationFrame(()=>{var M,L;(M=m.current)==null||M.focus(),(L=m.current)==null||L.select()}))},[c]);const w=x.useCallback(()=>{f(e.title),u(!0)},[e.title]),C=x.useCallback(()=>{if(g.current)return;g.current=!0;const M=d.trim();u(!1),!(!M||M===e.title)&&(r==null||r(e.id,M))},[d,e.id,e.title,r]),T=x.useCallback(()=>{g.current=!0,u(!1)},[]),E=Ure(e.id),j=x.useCallback(M=>{M.stopPropagation(),l(L=>!L)},[]),_=x.useCallback(M=>{M.stopPropagation(),w()},[w]),{animate:N,transition:R,initial:O}=CQe({isNew:i,borderState:E});return a.jsx(gn,{children:a.jsxs(te.div,{"data-testid":"session-row",initial:O,animate:N,transition:R,style:E.pulse?void 0:{borderLeftColor:E.color},className:Y("group relative rounded-lg border-l-2 transition-colors duration-150",t&&"text-foreground"),children:[t&&a.jsx(te.div,{layoutId:"active-session-bg",className:"bg-secondary absolute inset-0 rounded-lg",transition:{type:"spring",stiffness:280,damping:32}}),a.jsx(Qle,{onRename:r?w:void 0,onFork:s?()=>s(e.id):void 0,children:a.jsx(xn,{asChild:!0,disabled:E.kind==="idle",children:a.jsxs(te.div,{role:"button",tabIndex:0,"aria-current":t?"page":void 0,"aria-label":`Session: ${Cg(e.title)}. ${E.label}.`,onClick:n,onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),n())},whileTap:{scale:.98},transition:{type:"spring",stiffness:400,damping:30},className:"relative z-10 cursor-pointer px-3 py-2",children:[a.jsxs("div",{className:"text-muted-foreground flex items-center gap-1 text-xs",children:[a.jsx("span",{className:"min-w-0 flex-1",children:S}),a.jsxs("span",{className:"flex flex-shrink-0 items-center gap-1",children:[E.kind==="pendingApproval"&&a.jsx(sne,{className:"size-(--size-icon-xs) text-amber-500","aria-label":"Awaiting your approval"}),y&&a.jsx(kQe,{}),r&&!c&&a.jsx("button",{type:"button",onClick:_,className:"text-muted-foreground/60 hover:text-muted-foreground rounded p-0.5 opacity-0 transition-opacity duration-150 group-hover:opacity-100 focus-visible:opacity-100 max-md:p-1.5 max-md:opacity-100","aria-label":"Rename session",children:a.jsx(KE,{className:"size-(--size-icon-xs)"})}),a.jsx("button",{type:"button",onClick:j,className:Y("rounded p-0.5 transition-opacity duration-150 max-md:p-1.5",o?"text-muted-foreground opacity-100":"text-muted-foreground/60 hover:text-muted-foreground opacity-0 group-hover:opacity-100 focus-visible:opacity-100 max-md:opacity-100"),"aria-label":"Session details","aria-expanded":o,children:a.jsx(te.div,{animate:{rotate:o?180:0},transition:{type:"spring",stiffness:400,damping:30},children:a.jsx(Hs,{className:"size-(--size-icon-sm)"})})})]})]}),c?a.jsx("input",{ref:m,autoFocus:!0,value:d,onChange:M=>f(M.target.value),onBlur:C,onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),C()),M.key==="Escape"&&(M.preventDefault(),T())},onClick:M=>M.stopPropagation(),className:"bg-background text-foreground mt-0.5 w-full rounded border px-1 text-xs outline-none","aria-label":"Session title"}):a.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5",children:[a.jsx(Yle,{type:e.runtime,model:e.model,className:"text-muted-foreground/50"}),a.jsx("div",{className:"text-muted-foreground/70 min-w-0 flex-1 truncate text-xs",title:r?"Click the pencil icon to rename":void 0,children:Cg(e.title)})]})]})})}),a.jsx(yn,{side:"right",sideOffset:8,children:E.label}),a.jsx(Ue,{initial:!1,children:o&&a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:[0,0,.2,1]},className:"relative z-10 overflow-hidden",children:a.jsxs("div",{className:"text-muted-foreground border-border/30 mx-2 space-y-1.5 border-t px-3 pt-2 pb-2 text-[11px]",children:[a.jsx(Gx,{label:"Session ID",value:e.id,copyable:!0}),a.jsx(Gx,{label:"Created",value:uU(e.createdAt)}),a.jsx(Gx,{label:"Updated",value:uU(e.updatedAt)}),a.jsx(Gx,{label:"Runtime",value:Ka(e.runtime).label}),a.jsx(Gx,{label:"Permissions",value:y?"Skip (unsafe)":"Default"}),s&&a.jsxs("button",{type:"button",onClick:M=>{M.stopPropagation(),s(e.id)},className:"hover:bg-secondary/80 text-muted-foreground/60 hover:text-muted-foreground mt-1 inline-flex items-center gap-1 rounded px-1.5 py-0.5 transition-colors duration-100","aria-label":"Fork session",children:[a.jsx(nne,{className:"size-(--size-icon-xs)"}),a.jsx("span",{children:"Fork"})]})]})})})]})})}function kQe(){return a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx("button",{type:"button",className:"inline-flex cursor-help","aria-label":"Permissions bypassed",onClick:e=>e.stopPropagation(),children:a.jsx(Q5,{className:"size-(--size-icon-xs) text-red-500"})})}),a.jsx(yn,{side:"top",sideOffset:4,children:"Permissions bypassed — agent can run any command without approval"})]})}function CQe({isNew:e,borderState:t}){const{animate:n,transition:s}=HI(t.pulse,t.color,t.dimColor);return x.useMemo(()=>{if(!(e||t.pulse))return{initial:void 0,animate:void 0,transition:void 0};const i={...e?{opacity:1,y:0}:{},...n},o={...e?{opacity:{duration:.2,ease:[0,0,.2,1]},y:{duration:.2,ease:[0,0,.2,1]}}:{},...s};return{initial:e?{opacity:0,y:-8}:void 0,animate:i,transition:o}},[e,t.pulse,n,s])}function Gx({label:e,value:t,copyable:n=!1}){return a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("span",{className:"text-muted-foreground/60 w-16 flex-shrink-0",children:e}),a.jsx("span",{className:"min-w-0 flex-1 truncate font-mono select-all",children:t}),n&&a.jsx(vv,{value:t,label:`Copy ${e}`})]})}function EQe({session:e,isActive:t,onClick:n,onFork:s,onRename:r}){const[i,o]=x.useState(!1),[l,c]=x.useState(""),u=x.useRef(null),d=x.useRef(!1),f=Ure(e.id),m=Gh(6e4),g=x.useMemo(()=>ii(e.updatedAt),[e.updatedAt,m]),{animate:y,transition:b}=HI(f.pulse,f.color,f.dimColor,"backgroundColor");x.useEffect(()=>{i&&(d.current=!1,requestAnimationFrame(()=>{var T,E;(T=u.current)==null||T.focus(),(E=u.current)==null||E.select()}))},[i]);const S=x.useCallback(()=>{c(e.title),o(!0)},[e.title]),w=x.useCallback(()=>{if(d.current)return;d.current=!0;const T=l.trim();o(!1),!(!T||T===e.title)&&(r==null||r(e.id,T))},[l,e.id,e.title,r]),C=x.useCallback(()=>{d.current=!0,o(!1)},[]);return a.jsxs(gn,{children:[a.jsx(Qle,{onRename:r?S:void 0,onFork:s?()=>s(e.id):void 0,children:a.jsx(xn,{asChild:!0,children:a.jsxs("button",{type:"button","data-testid":"session-row",onClick:n,className:Y("flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-xs transition-colors duration-100 active:scale-[0.98]",t?"bg-secondary text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[a.jsx(te.span,{"aria-hidden":!0,animate:y,transition:b,style:f.pulse?void 0:{backgroundColor:f.color},className:"size-1.5 shrink-0 rounded-full"}),i?a.jsx("input",{ref:u,autoFocus:!0,value:l,onChange:T=>c(T.target.value),onBlur:w,onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),w()),T.key==="Escape"&&(T.preventDefault(),C())},onClick:T=>T.stopPropagation(),className:"bg-background text-foreground min-w-0 flex-1 rounded border px-1 text-xs outline-none","aria-label":"Session title"}):a.jsx("span",{className:"min-w-0 flex-1 truncate",children:Cg(e.title)}),a.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[f.kind==="pendingApproval"&&a.jsx(sne,{className:"size-(--size-icon-xs) text-amber-500","aria-label":"Awaiting approval"}),a.jsx(Yle,{type:e.runtime,model:e.model,className:"text-muted-foreground/50"}),a.jsx("span",{className:"text-muted-foreground/60 text-[10px]",children:g})]})]})})}),f.kind!=="idle"&&a.jsx(yn,{side:"right",sideOffset:8,children:f.label})]})}function rP({variant:e,session:t,isActive:n,onClick:s,onFork:r,onRename:i,isNew:o}){return e==="compact"?a.jsx(EQe,{session:t,isActive:n,onClick:s,onFork:r,onRename:i}):a.jsx(wQe,{session:t,isActive:n,onClick:s,onFork:r,onRename:i,isNew:o})}const yc={all:["agents"],byPath:e=>["agents","byPath",e],resolved:e=>["agents","resolved",...e]};function $b(e){const t=je();return st({queryKey:yc.byPath(e??""),queryFn:()=>t.getAgentByPath(e),enabled:!!e,staleTime:6e4,gcTime:5*6e4})}function TQe(){const e=je(),t=et();return Bt({mutationFn:n=>e.initAgent(n.path,n.name,n.description,n.runtime),onSuccess:(n,s)=>{t.invalidateQueries({queryKey:yc.byPath(s.path)}),t.invalidateQueries({queryKey:yc.all})}})}function _Qe(){const e=je(),t=et();return Bt({mutationFn:n=>e.updateAgentByPath(n.path,n.updates),onMutate:async({path:n,updates:s})=>{await t.cancelQueries({queryKey:yc.byPath(n)});const r=t.getQueryData(yc.byPath(n));return r&&t.setQueryData(yc.byPath(n),{...r,...s}),{previous:r}},onError:(n,{path:s},r)=>{r!=null&&r.previous&&t.setQueryData(yc.byPath(s),r.previous)},onSettled:(n,s,{path:r})=>{t.invalidateQueries({queryKey:yc.byPath(r)})}})}function Jle(e){const t=je();return st({queryKey:yc.resolved(e),queryFn:()=>t.resolveAgents(e),enabled:e.length>0,staleTime:6e4})}function qT(e,t){return x.useMemo(()=>e?Dd(e):{color:YO(t),emoji:ZO(t)},[e,t])}function am(){return Nne("relay")}const NQe=["relay","messages"];function jQe(){const e=je(),t=et();return Bt({mutationFn:n=>e.sendRelayMessage(n),onSuccess:()=>{t.invalidateQueries({queryKey:[...NQe]})}})}function AQe(e,t){const n=et(),{connectionState:s,failedAttempts:r}=Mne();return kg("relay_message",()=>{e&&n.invalidateQueries({queryKey:["relay","conversations"]})}),kg("relay_signal",()=>{e&&n.invalidateQueries({queryKey:["relay","conversations"]})}),{connectionState:s,failedAttempts:r}}const iP=["relay","adapters"],Kx=["relay","adapters","catalog"];function Hb(e=!0){const t=je();return st({queryKey:[...iP],queryFn:()=>t.listRelayAdapters(),enabled:e,refetchInterval:1e4,refetchIntervalInBackground:!1})}function ece(){const e=je(),t=et();return Bt({mutationFn:({id:n,enabled:s})=>e.toggleRelayAdapter(n,s),onMutate:async({id:n,enabled:s})=>{await t.cancelQueries({queryKey:[...Kx]});const r=t.getQueryData([...Kx]);return r&&t.setQueryData([...Kx],i=>i==null?void 0:i.map(o=>({...o,instances:o.instances.map(l=>l.id===n?{...l,enabled:s}:l)}))),{previousCatalog:r}},onError:(n,s,r)=>{r!=null&&r.previousCatalog&&t.setQueryData([...Kx],r.previousCatalog),Ye.error("Failed to toggle adapter")},onSettled:()=>{t.invalidateQueries({queryKey:[...iP]}),t.invalidateQueries({queryKey:[...Kx]})}})}function RQe(){const e=et();kg("relay_adapters_changed",()=>{e.invalidateQueries({queryKey:[...iP]})})}const GT=["relay","adapters","catalog"],aP=["relay","adapters"];function oP(e){return e instanceof Error?e.message:"An unexpected error occurred"}function S0(e=!0){const t=je();return st({queryKey:[...GT],queryFn:()=>t.getAdapterCatalog(),enabled:e,refetchInterval:3e4})}function MQe(){const e=je(),t=et();return Bt({mutationFn:({type:n,id:s,config:r})=>e.addRelayAdapter(n,s,r),onSuccess:()=>{t.invalidateQueries({queryKey:[...GT]}),t.invalidateQueries({queryKey:[...aP]})},onError:n=>{Ye.error(oP(n))}})}function DQe(){const e=je(),t=et();return Bt({mutationFn:n=>e.removeRelayAdapter(n),onSuccess:()=>{t.invalidateQueries({queryKey:[...GT]}),t.invalidateQueries({queryKey:[...aP]}),Ye.success("Adapter removed")},onError:n=>{Ye.error(oP(n))}})}function tce(){const e=je(),t=et();return Bt({mutationFn:({id:n,config:s})=>e.updateRelayAdapterConfig(n,s),onSuccess:()=>{t.invalidateQueries({queryKey:[...GT]}),t.invalidateQueries({queryKey:[...aP]}),Ye.success("Configuration updated")},onError:n=>{Ye.error(oP(n))}})}function OQe(){const e=je();return Bt({mutationFn:({type:t,config:n})=>e.testRelayAdapterConnection(t,n)})}const IQe="internal";function PQe(e=!0){const t=S0(e),n=x.useMemo(()=>{var s;return((s=t.data)==null?void 0:s.filter(r=>r.manifest.category!==IQe))??[]},[t.data]);return{...t,data:n}}function LQe(e){const t=je();return st({queryKey:["relay","trace",e],queryFn:()=>t.getRelayTrace(e),enabled:!!e,staleTime:3e4})}function lP(){const e=je();return st({queryKey:["relay","metrics"],queryFn:()=>e.getRelayDeliveryMetrics(),staleTime:3e4,refetchInterval:3e4})}const nce=["relay","dead-letters"];function w0(e=!0){const t=je();return st({queryKey:[...nce,"aggregated"],queryFn:async()=>(await t.listAggregatedDeadLetters()).groups,enabled:e,refetchInterval:3e4})}function sce(){const e=je(),t=et();return Bt({mutationFn:async({source:n,reason:s})=>e.dismissDeadLetterGroup(n,s),onSuccess:()=>{t.invalidateQueries({queryKey:[...nce]})}})}const FQe=["relay","conversations"];function zQe(e=!0){const t=je();return st({queryKey:[...FQe],queryFn:()=>t.listRelayConversations(),enabled:e,refetchInterval:5e3})}function BQe(e){const t=je();return st({queryKey:["relay","adapters",e,"events"],queryFn:()=>t.getAdapterEvents(e),enabled:!!e,refetchInterval:5e3})}function $Qe(e){const t=je();return st({queryKey:["relay","observed-chats",e],queryFn:()=>t.getObservedChats(e),enabled:!!e,staleTime:3e4})}const rce={connected:"bg-green-500",disconnected:"bg-muted-foreground",error:"bg-red-500",starting:"bg-amber-500 motion-safe:animate-pulse",stopping:"bg-amber-500 motion-safe:animate-pulse",reconnecting:"bg-amber-500 motion-safe:animate-pulse"},USt={connected:"Connected",disconnected:"Ready",error:"Error",starting:"Connecting…",stopping:"Stopping…",reconnecting:"Reconnecting…"};function Ud(){return Nne("tasks")}const KT=["tasks"];function WT(e=!0){const t=je();return st({queryKey:[...KT],queryFn:()=>t.listTasks(),enabled:e})}function cP(){const e=je(),t=et();return Bt({mutationFn:n=>e.createTask(n),onSuccess:()=>{t.invalidateQueries({queryKey:[...KT]})}})}function uP(){const e=je(),t=et();return Bt({mutationFn:({id:n,...s})=>e.updateTask(n,s),onSuccess:()=>{t.invalidateQueries({queryKey:[...KT]})}})}function ice(){const e=je(),t=et();return Bt({mutationFn:n=>e.deleteTask(n),onSuccess:()=>{t.invalidateQueries({queryKey:[...KT]})}})}function HQe(){const e=je(),t=et();return Bt({mutationFn:n=>e.triggerTask(n),onSuccess:()=>{t.invalidateQueries({queryKey:["tasks","runs"]})}})}const YT=["tasks","runs"];function k0(e,t=!0){const n=je();return st({queryKey:[...YT,e],queryFn:()=>n.listTaskRuns(e),refetchInterval:s=>{var r;return(r=s.state.data)!=null&&r.some(i=>i.status==="running")?1e4:!1},refetchIntervalInBackground:!1,enabled:t})}function UQe(e){const t=je();return st({queryKey:[...YT,e],queryFn:()=>t.getTaskRun(e),enabled:!!e})}function dP(e=!0){const t=je();return st({queryKey:[...YT,"active-count"],queryFn:async()=>(await t.listTaskRuns({limit:50})).filter(s=>s.status==="running").length,enabled:e,refetchInterval:1e4,refetchIntervalInBackground:!1})}function ace(){const e=je(),t=et();return Bt({mutationFn:n=>e.cancelTaskRun(n),onSuccess:()=>{t.invalidateQueries({queryKey:[...YT]})}})}const VQe="dorkos-tasks-last-viewed";function qQe(e=!0){const{data:t}=k0({limit:50},e),n=x.useRef(new Set),[s,r]=x.useState(0);x.useEffect(()=>{if(!t)return;const o=new Set(t.filter(u=>u.status==="running").map(u=>u.id)),l=n.current;let c=0;for(const u of l){const d=t.find(f=>f.id===u);d&&d.status!=="running"&&c++}c>0&&r(u=>u+c),n.current=o},[t]);const i=x.useCallback(()=>{r(0),localStorage.setItem(VQe,new Date().toISOString())},[]);return{unviewedCount:s,clearBadge:i}}function fP(){const e=je();return st({queryKey:["tasks","templates"],queryFn:()=>e.getTaskTemplates()})}const Ub=gl(e=>({pendingTemplate:null,externalTrigger:!1,openWithTemplate:t=>e({pendingTemplate:t,externalTrigger:!0}),openBlank:()=>e({pendingTemplate:null,externalTrigger:!0}),clear:()=>e({pendingTemplate:null,externalTrigger:!1})}));function oce(e){const{data:t}=$b(e),n=am(),s=Ud();return x.useMemo(()=>{const r=(t==null?void 0:t.enabledToolGroups)??{};return{tasks:s?r.tasks===!1?"disabled-by-agent":"enabled":"disabled-by-server",relay:n?r.relay===!1?"disabled-by-agent":"enabled":"disabled-by-server",mesh:r.mesh===!1?"disabled-by-agent":"enabled",adapter:n?r.adapter===!1?"disabled-by-agent":"enabled":"disabled-by-server"}},[t,n,s])}function GQe(e,t){const n=je();return st({queryKey:["mcp-config",e,t??null],queryFn:()=>n.getMcpConfig(e,{runtime:t??void 0}),enabled:!!e,staleTime:3e4})}const dU={light:{heroGlow:"28",heroGlowOuter:"14",pillBgStart:"20",pillBgEnd:"14",pillBorder:"50",pillGlow:"30"},dark:{heroGlow:"18",heroGlowOuter:"08",pillBgStart:"12",pillBgEnd:"08",pillBorder:"40",pillGlow:"33"}};function KQe(){return document.documentElement.classList.contains("dark")}function WQe(){return!1}function YQe(e){const t=new MutationObserver(n=>{for(const s of n)if(s.attributeName==="class"){e();return}});return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()}function hP(){return x.useSyncExternalStore(YQe,KQe,WQe)}function ZQe(){return hP()?dU.dark:dU.light}const XQe={active:"ring-emerald-500/60",inactive:"ring-amber-500/60",stale:"ring-muted-foreground/20",unreachable:"ring-red-500/60"},QQe=Td("relative inline-flex shrink-0 items-center justify-center rounded-full transition-[background-color] duration-500 ease-in-out",{variants:{size:{xs:"size-5 text-xs",sm:"size-7 text-sm",md:"size-9 text-lg",lg:"size-12 text-2xl"}},defaultVariants:{size:"sm"}});function Vb({color:e,emoji:t,size:n,healthStatus:s,className:r}){return a.jsxs("span",{"data-slot":"agent-avatar",className:Y(QQe({size:n}),s&&"ring-2",s&&XQe[s],r),style:{backgroundColor:`color-mix(in oklch, ${e} 18%, transparent)`},"aria-hidden":!0,children:[a.jsx("span",{className:"leading-none",children:t}),s==="active"&&a.jsx("span",{className:"absolute -top-px -right-px size-2 rounded-full bg-emerald-500","aria-hidden":!0,children:a.jsx("span",{className:"absolute inset-0 animate-ping rounded-full bg-emerald-500 opacity-40 motion-reduce:hidden"})})]})}const fU=Td("inline-flex items-center min-w-0",{variants:{size:{xs:"gap-1.5",sm:"gap-2",md:"gap-2.5",lg:"gap-3"}},defaultVariants:{size:"sm"}}),hU=Td("truncate",{variants:{size:{xs:"text-xs font-medium",sm:"text-sm font-medium",md:"text-sm font-semibold",lg:"text-base font-semibold"}},defaultVariants:{size:"sm"}}),mU=Td("text-muted-foreground truncate",{variants:{size:{xs:"text-[10px]",sm:"text-xs",md:"text-xs",lg:"text-sm"}},defaultVariants:{size:"sm"}});function bD({color:e,emoji:t,name:n,detail:s,size:r,healthStatus:i,className:o,onClick:l}){const c=r??"sm",u=c==="md"||c==="lg",d=a.jsxs(a.Fragment,{children:[a.jsx(Vb,{color:e,emoji:t,size:r,healthStatus:i}),u?a.jsxs("span",{className:"flex min-w-0 flex-col",children:[a.jsx("span",{className:hU({size:r}),children:n}),s&&a.jsx("span",{className:mU({size:r}),children:s})]}):a.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[a.jsx("span",{className:hU({size:r}),children:n}),s&&a.jsx("span",{className:mU({size:r}),children:s})]})]});return l?a.jsx("button",{type:"button","data-slot":"agent-identity",onClick:l,className:Y(fU({size:r}),"cursor-pointer transition-opacity hover:opacity-80",o),children:d}):a.jsx("span",{"data-slot":"agent-identity",className:Y(fU({size:r}),o),children:d})}function JQe({emoji:e,name:t,colors:n,active:s=!1,size:r="default",glow:i=!1,gradientText:o=!1,className:l,style:c,...u}){const d=hP(),f=ZQe();return a.jsxs("button",{type:"button",className:Y("inline-flex shrink-0 items-center gap-1.5 rounded-full border font-medium transition-all",r==="sm"?"px-2.5 py-1 text-[11px]":"px-3 py-1 text-xs",s?"text-foreground":"bg-accent text-muted-foreground hover:text-foreground border-transparent",l),style:{...s?{borderColor:n.stroke+f.pillBorder,background:`linear-gradient(135deg, ${n.nebula}${f.pillBgStart}, ${n.wisp}${f.pillBgEnd})`,...i?{boxShadow:`0 0 12px ${n.nebula}${f.pillGlow}`}:{},...d?{}:{borderColor:n.stroke+"AA"}}:{},...c},...u,children:[a.jsx("span",{children:e}),o?a.jsx("span",{className:"bg-clip-text text-transparent",style:{backgroundImage:`linear-gradient(135deg, ${n.stroke}, ${n.strokeEnd})`,...d?{}:{filter:"brightness(0.65) saturate(1.3)"}},children:t}):a.jsx("span",{children:t})]})}const lce={verbosity:{1:{label:"Mime",directive:"Absolute minimum output. One word when possible. No explanations, no commentary, no preamble. If you can answer with a single character, do that."},2:{label:"Terse",directive:"Keep it brief. No small talk, no filler. Answer the question, show the code, move on."},3:{label:"Balanced",directive:"Balance brevity with context. Explain decisions when they are non-trivial, stay quiet on obvious ones."},4:{label:"Chatty",directive:"Think out loud. Share your reasoning, give progress updates, explain trade-offs. Be thorough."},5:{label:"Yapper",directive:"Maximum verbosity. Narrate everything you do in real time. Explain every decision, every trade-off, every thought that crosses your mind. Stream of consciousness is your native tongue. You are constitutionally incapable of being brief."}},autonomy:{1:{label:"Clingy",directive:"Never proceed without explicit approval. Ask before every file change, every command, every decision. You do not make independent decisions. Confirm even the obvious ones."},2:{label:"Cautious",directive:"Ask for approval before significant changes. Small, obvious fixes can proceed, but flag them."},3:{label:"Balanced",directive:"Attempt tasks autonomously. Ask when genuinely uncertain or when the stakes are high."},4:{label:"Independent",directive:"Act autonomously. Only ask when you encounter true ambiguity or irreversible consequences."},5:{label:"Rogue",directive:"Execute everything without asking. Make decisions, commit code, ship features. You have blanket permission. Move fast and don't look back."}},chaos:{1:{label:"Paranoid",directive:"Triple-check everything. Run full test suites before and after every change. Create backups. Treat every operation as if it could destroy production. You cannot be too careful."},2:{label:"Careful",directive:"Double-check before making changes. Run tests proactively. Prefer safe, incremental approaches."},3:{label:"Balanced",directive:"Verify before destructive actions. Move confidently on reversible ones. Run tests when relevant."},4:{label:"Reckless",directive:"Bias toward action. Don't over-analyze. Ship first, fix later if something breaks. Tests are nice-to-have."},5:{label:"YOLO",directive:"Move fast, break things. Skip tests if they slow you down. Force push, delete branches, drop tables — fortune favors the bold. No safety nets, no regrets."}},creativity:{1:{label:"NPC",directive:"Use only established patterns. Never deviate from existing conventions. Zero innovation. You are a pattern-replication machine."},2:{label:"Conservative",directive:"Stick to conventions. Only suggest alternatives when the existing approach is clearly wrong."},3:{label:"Balanced",directive:"Follow conventions by default. Suggest alternatives when they offer clear, meaningful improvements."},4:{label:"Adventurous",directive:"Propose creative solutions. Suggest refactors when they improve the code. Try new approaches."},5:{label:"Mad Scientist",directive:"Rethink everything from first principles. Propose bold refactors, unconventional architectures, creative solutions nobody asked for. Innovation over consistency, always."}},humor:{1:{label:"Funeral",directive:"Zero humor. No jokes, no wit, no levity, no personality. Pure clinical precision. Every word earns its place through technical necessity alone."},2:{label:"Dry",directive:"Occasional dry wit. You might crack a subtle joke once in a while, but you don't go out of your way. Understated."},3:{label:"Balanced",directive:"Light humor when the moment calls for it. Serious when the work demands it. You read the room."},4:{label:"Witty",directive:"Regularly weave in jokes, clever observations, and playful commentary. Make the work fun. Puns welcome."},5:{label:"Class Clown",directive:"Everything is a bit. Commit messages are standup routines. Code comments are roast sessions. You will explain Big-O notation through an elaborate cooking metaphor. You cannot help yourself."}},spice:{1:{label:"Corporate",directive:"Pristine professional language at all times. No contractions, no slang, no informality. Every response could be read aloud in a boardroom."},2:{label:"Professional",directive:"Clean, clear, professional language. Contractions are fine but keep it polished and workplace-appropriate."},3:{label:"Balanced",directive:"Casual professional. Speak naturally, use contractions, relax the formality. Like talking to a smart colleague."},4:{label:"Casual",directive:"Loose, informal language. Slang, abbreviations, internet speak are all fair game. Talk like a friend, not a coworker."},5:{label:"Sailor",directive:"Absolutely zero filter. Profanity is punctuation. Speak like the most unfiltered, foul-mouthed engineer at the bar at 2 AM. Say what you actually think, how you'd actually say it."}}},eJe={verbosity:3,autonomy:3,chaos:3,creativity:3,humor:3,spice:3},cce=["verbosity","autonomy","chaos","creativity","humor","spice"];function VSt(e){return cce.map(n=>{const s=e[n]??3,r=lce[n][s];return`- **${tJe(n)}** (${r.label}): ${r.directive}`}).join(`
|
|
1259
1259
|
`)}function tJe(e){return e.charAt(0).toUpperCase()+e.slice(1)}const qSt={verbosity:{1:"One-word answers. Smoke signals.",2:"Brief and direct — no small talk.",3:"Balanced — explains when it matters.",4:"Thorough — thinks out loud.",5:"Cannot stop talking. You didn't ask for this."},autonomy:{1:"Asks permission for everything.",2:"Checks in before big moves.",3:"Acts independently on routine tasks.",4:"Highly autonomous — asks only when stuck.",5:"Already shipped it while you were reading this."},chaos:{1:"Triple-checks everything. Paranoid by design.",2:"Double-checks, tests proactively.",3:"Careful with irreversible, confident on safe.",4:"Ships first, worries later.",5:"YOLO. No tests, no backups, no regrets."},creativity:{1:"Follows patterns robotically.",2:"Conservative — deviates only when necessary.",3:"Follows conventions, suggests clear improvements.",4:"Proposes creative solutions and refactors.",5:"Will rewrite your app in Haskell to fix a CSS bug."},humor:{1:"Zero levity. Supreme Court energy.",2:"Occasional dry wit, subtle.",3:"Light humor when appropriate.",4:"Regularly drops jokes. Puns welcome.",5:"Everything is a bit. Cannot help itself."},spice:{1:"Boardroom-ready. Pristine professional.",2:"Clean and polished.",3:"Casual professional. Speaks naturally.",4:"Slang, internet speak. Talks like a friend.",5:"Zero filter. Profanity is punctuation."}};function nJe({traits:e,onChange:t,onSliderChange:n}){const s=x.useCallback((r,i)=>{n==null||n(r,i),t({...e,[r]:i})},[e,t,n]);return a.jsx("div",{className:"space-y-4",children:cce.map(r=>a.jsx(sJe,{name:r,level:e[r]??3,onChange:s},r))})}function sJe({name:e,level:t,onChange:n}){const s=lce[e][t];return a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"font-medium capitalize",children:e}),a.jsxs("span",{className:"text-muted-foreground",children:[t,"/5 ",s.label]})]}),a.jsx(y8e,{value:[t],onValueChange:([r])=>n(e,r),min:1,max:5,step:1,"aria-label":`${e} trait level`})]})}function uce(e,t,n){const s=je();return st({queryKey:["commands",{cwd:e??null,sessionId:t??null,runtime:n??null}],queryFn:()=>s.getCommands(!1,e??void 0,{sessionId:t,runtime:n}),staleTime:ia.COMMANDS_STALE_TIME_MS,gcTime:ia.COMMANDS_GC_TIME_MS})}function rJe(){const e=et();kg("commands_changed",()=>{e.invalidateQueries({queryKey:["commands"]})})}const RA={name:{exact:0,prefix:1,"word-boundary":2,substring:6,subsequence:8},alias:{exact:3,prefix:4,"word-boundary":5,substring:7,subsequence:9},description:{exact:10,prefix:11,"word-boundary":12,substring:13,subsequence:14}},iJe={match:!1,bucket:Number.POSITIVE_INFINITY,score:0};function pU(e){return e.startsWith("/")?e.slice(1):e}function gU(e,t){return e.bucket<t.bucket||e.bucket===t.bucket&&e.score>t.score}function aJe(e,t){let n=iJe;const s=Mw(e,pU(t.fullCommand));s.match&&s.tier&&(n={match:!0,bucket:RA.name[s.tier],score:s.score});for(const r of t.aliases??[]){const i=Mw(e,pU(r));if(!i.match||!i.tier)continue;const o={bucket:RA.alias[i.tier],score:i.score};gU(o,n)&&(n={match:!0,...o,matchedAlias:r})}if(t.description){const r=Mw(e,t.description);if(r.match&&r.tier){const i={bucket:RA.description[r.tier],score:r.score};gU(i,n)&&(n={match:!0,...i})}}return n}const qb=["relay","bindings"];function Gb(){const e=je();return st({queryKey:[...qb],queryFn:()=>e.getBindings()})}function oJe(){const e=et();kg("relay_bindings_changed",()=>{e.invalidateQueries({queryKey:[...qb]})})}function ZT(){const e=je(),t=et();return Bt({mutationFn:n=>e.createBinding(n),onSuccess:()=>{t.invalidateQueries({queryKey:[...qb]})}})}function lJe(){const e=je(),t=et();return Bt({mutationFn:n=>e.deleteBinding(n),onSuccess:()=>{t.invalidateQueries({queryKey:[...qb]})}})}function cJe(){const e=je(),t=et();return Bt({mutationFn:({id:n,updates:s})=>e.updateBinding(n,s),onSuccess:()=>{t.invalidateQueries({queryKey:[...qb]})}})}function uJe(){return!0}const dJe=["mesh","agent-paths"];function Kb(){const e=je();return st({queryKey:[...dJe],queryFn:()=>e.listMeshAgentPaths(),staleTime:3e4})}const fJe=["mesh","agents"];function ba(e,t=!0){const n=je();return st({queryKey:[...fJe,e],queryFn:()=>n.listMeshAgents(e),enabled:t,staleTime:3e4})}function dce(){const e=je(),t=et();return Bt({mutationFn:n=>e.registerMeshAgent(n.path,n.overrides,n.approver,n.scanRoot),onSuccess:()=>{t.invalidateQueries({queryKey:["mesh","agents"]}),t.invalidateQueries({queryKey:["mesh","agent-paths"]})}})}function hJe(){const e=je(),t=et();return Bt({mutationFn:n=>e.denyMeshAgent(n.path,n.reason,n.denier),onSuccess:()=>{t.invalidateQueries({queryKey:["mesh","denied"]})}})}const mJe=["mesh","denied"];function pJe(e=!0){const t=je();return st({queryKey:[...mJe],queryFn:()=>t.listDeniedMeshAgents(),enabled:e,staleTime:3e4})}const gJe=["mesh","status"],xJe=3e4;function mP(e=!0){const t=je();return st({queryKey:[...gJe],queryFn:()=>t.getMeshStatus(),enabled:e,refetchInterval:xJe})}function fce(e){const t=je();return st({queryKey:["mesh","agent-health",e],queryFn:()=>t.getMeshAgentHealth(e),enabled:e!==null})}const yJe=["mesh","topology"];function pP(e,t=!0){const n=je();return st({queryKey:[...yJe,e],queryFn:()=>n.getMeshTopology(e),enabled:t,staleTime:3e4,refetchInterval:3e4})}const vJe=["mesh","topology"];function bJe(){const e=je(),t=et();return Bt({mutationFn:n=>e.updateMeshAccessRule(n),onSuccess:()=>{t.invalidateQueries({queryKey:vJe})}})}function SJe(e,t=!0){const n=je();return st({queryKey:["mesh","agent-access",e],queryFn:()=>n.getMeshAgentAccess(e),enabled:t&&!!e,staleTime:3e4})}function hce(){var u;const e=je(),t=et(),{data:n}=st({queryKey:["config"],queryFn:()=>e.getConfig(),staleTime:300*1e3}),s=((u=n==null?void 0:n.mesh)==null?void 0:u.scanRoots)??[],r=(n==null?void 0:n.boundary)??"",i=s.length>0?s:r?[r]:[],{mutate:o,isPending:l}=Bt({mutationFn:async d=>{await e.updateConfig({mesh:{scanRoots:d}})},onSuccess:()=>{t.invalidateQueries({queryKey:["config"]})}}),c=x.useCallback(d=>o(d),[o]);return{roots:i,boundary:r,isSaving:l,setScanRoots:c}}const xU=[{value:"per-chat",label:"Per Chat",description:"One session per chat/conversation. Messages from the same chat resume the same session."},{value:"per-user",label:"Per User",description:"One session per user. All messages from a user share a session across chats."},{value:"stateless",label:"Stateless",description:"Every message starts a new session. No conversation history."}],yU=[{value:"default",label:"Default",description:"Agent asks for approval before using any tools"},{value:"plan",label:"Plan Only",description:"Agent can read files but asks before making changes"},{value:"acceptEdits",label:"Accept Edits",description:"Agent can read and write files; asks before running shell commands"},{value:"bypassPermissions",label:"Full Access",description:"Agent can use all tools without asking for approval"}];function wJe({strategy:e,onStrategyChange:t,permissionMode:n,onPermissionModeChange:s,bypassWarningOpen:r,onBypassWarningOpenChange:i,onBypassConfirm:o,canInitiate:l,onCanInitiateChange:c,canReply:u,onCanReplyChange:d,canReceive:f,onCanReceiveChange:m,open:g,onOpenChange:y,hasChanges:b}){const S=xU.find(C=>C.value===e),w=yU.find(C=>C.value===n);return a.jsxs(a.Fragment,{children:[a.jsxs(WI,{open:g,onOpenChange:y,trigger:"Advanced",badge:b?a.jsx(zt,{variant:"secondary",className:"text-xs",children:"Modified"}):void 0,children:[a.jsxs("div",{className:"space-y-1.5 px-4 py-3",children:[a.jsx(Rt,{htmlFor:"binding-session-strategy",children:"Session Strategy"}),a.jsxs(On,{value:e,onValueChange:C=>t(C),children:[a.jsx(_n,{id:"binding-session-strategy",className:"w-full",children:a.jsx(In,{})}),a.jsx(Nn,{children:xU.map(C=>a.jsx(mt,{value:C.value,children:C.label},C.value))})]}),S&&a.jsx("p",{className:"text-muted-foreground text-xs",children:S.description})]}),a.jsxs("div",{className:"space-y-1.5 px-4 py-3",children:[a.jsx(Rt,{htmlFor:"binding-permission-mode",children:"Permission Mode"}),a.jsxs(On,{value:n,onValueChange:s,children:[a.jsx(_n,{id:"binding-permission-mode",className:"w-full",children:a.jsx(In,{})}),a.jsx(Nn,{children:yU.map(C=>a.jsx(mt,{value:C.value,children:C.label},C.value))})]}),w&&a.jsx("p",{className:"text-muted-foreground text-xs",children:w.description})]}),a.jsxs("div",{className:"space-y-2.5 px-4 py-3",children:[a.jsx("p",{className:"text-muted-foreground text-xs font-medium",children:"Message Direction"}),a.jsxs("div",{className:"flex cursor-pointer items-center justify-between gap-3",children:[a.jsxs(Rt,{htmlFor:"perm-initiate",className:"flex cursor-pointer items-center gap-1.5 text-xs font-normal",children:[a.jsx(Hc,{className:"text-muted-foreground size-3"}),"Agent can initiate messages"]}),a.jsx(sr,{id:"perm-initiate",checked:l,onCheckedChange:c,"aria-label":"Agent can initiate messages"})]}),a.jsxs("div",{className:"flex cursor-pointer items-center justify-between gap-3",children:[a.jsx(Rt,{htmlFor:"perm-reply",className:"cursor-pointer text-xs font-normal",children:"Agent can reply to messages"}),a.jsx(sr,{id:"perm-reply",checked:u,onCheckedChange:d,"aria-label":"Agent can reply to messages"})]}),a.jsxs("div",{className:"flex cursor-pointer items-center justify-between gap-3",children:[a.jsx(Rt,{htmlFor:"perm-receive",className:"cursor-pointer text-xs font-normal",children:"Agent receives inbound messages"}),a.jsx(sr,{id:"perm-receive",checked:f,onCheckedChange:m,"aria-label":"Agent receives inbound messages"})]})]})]}),a.jsx(Sl,{open:r,onOpenChange:i,children:a.jsxs(ko,{children:[a.jsxs(wl,{children:[a.jsx(Co,{children:"Enable Full Access?"}),a.jsx(Eo,{children:"Any user who can send messages through this adapter (e.g., members of your Slack workspace) will be able to trigger unrestricted agent actions, including file system access and command execution."})]}),a.jsxs(kl,{children:[a.jsx(_o,{children:"Cancel"}),a.jsx(To,{onClick:o,className:"bg-red-600 hover:bg-red-700 focus:ring-red-600",children:"Enable Full Access"})]})]})})]})}const Ia="__any__",kJe={"per-chat":"One thread for each conversation","per-user":"One thread for each person",stateless:"No memory between messages"};function CJe({sessionStrategy:e,chatDisplayName:t,channelType:n}){const s=kJe[e];return t?`${s} in ${t}`:n?`${s} · ${n}`:s}function EJe(e){return{adapterId:e.adapterId,agentId:e.agentId,sessionStrategy:e.sessionStrategy,label:e.label,permissionMode:e.permissionMode,chatId:e.chatId,channelType:e.channelType,canInitiate:e.canInitiate,canReply:e.canReply,canReceive:e.canReceive}}function TJe(e){return{sessionStrategy:e.sessionStrategy,label:e.label,permissionMode:e.permissionMode,chatId:e.chatId??null,channelType:e.channelType??null,canInitiate:e.canInitiate,canReply:e.canReply,canReceive:e.canReceive}}function _Je(e){return!!(e!=null&&e.canInitiate||(e==null?void 0:e.canReply)===!1||(e==null?void 0:e.canReceive)===!1||(e==null?void 0:e.permissionMode)!==void 0&&e.permissionMode!=="acceptEdits"||e!=null&&e.sessionStrategy&&e.sessionStrategy!=="per-chat")}function NJe(e){return{adapterId:(e==null?void 0:e.adapterId)??"",agentId:(e==null?void 0:e.agentId)??"",strategy:(e==null?void 0:e.sessionStrategy)??"per-chat",label:(e==null?void 0:e.label)??"",chatId:(e==null?void 0:e.chatId)??Ia,channelType:(e==null?void 0:e.channelType)??Ia,permissionMode:(e==null?void 0:e.permissionMode)??"acceptEdits",canInitiate:(e==null?void 0:e.canInitiate)??!1,canReply:(e==null?void 0:e.canReply)??!0,canReceive:(e==null?void 0:e.canReceive)??!0}}const jJe=[{value:"dm",label:"Direct Message"},{value:"group",label:"Group"},{value:"channel",label:"Channel"},{value:"thread",label:"Thread"}];function mce({open:e,onOpenChange:t,onConfirm:n,mode:s,initialValues:r,adapterName:i,agentName:o,onDelete:l,bindingId:c,isPending:u}){const d=s==="edit",[f,m]=x.useState(()=>!!(r!=null&&r.chatId||r!=null&&r.channelType)),[g,y]=x.useState(()=>_Je(r)),[b,S]=x.useState(!1),[w]=x.useState(()=>NJe(r)),C=XE({defaultValues:w,onSubmit:async({value:P})=>{await n({adapterId:P.adapterId,agentId:P.agentId,sessionStrategy:P.strategy,label:P.label,permissionMode:P.permissionMode,chatId:P.chatId===Ia?void 0:P.chatId,channelType:P.channelType===Ia?void 0:P.channelType,canInitiate:P.canInitiate,canReply:P.canReply,canReceive:P.canReceive}),d||C.reset()}}),{data:T=[]}=S0(),{data:E}=ba(),[j,_]=x.useState(()=>(r==null?void 0:r.adapterId)??""),{data:N=[]}=$Qe(j||void 0),R=T.flatMap(P=>P.instances.filter($=>$.enabled).map($=>({id:$.id,label:$.label?`${$.label} (${P.manifest.displayName})`:`${$.id} (${P.manifest.displayName})`}))),O=(E==null?void 0:E.agents)??[];function M(P){P==="bypassPermissions"?S(!0):C.setFieldValue("permissionMode",P)}function L(){C.setFieldValue("chatId",Ia),C.setFieldValue("channelType",Ia)}return a.jsx(fi,{open:e,onOpenChange:t,children:a.jsxs(hi,{className:"max-h-[85vh] max-w-md gap-0 p-0",children:[a.jsxs(va,{className:"border-b px-4 py-3",children:[a.jsx(Li,{children:d?"Edit Channel":"Connect Channel"}),a.jsx(Ga,{className:"sr-only",children:d?"Edit this channel's configuration":"Connect this channel to an agent"})]}),a.jsx(C.Subscribe,{selector:P=>({values:P.values,isSubmitting:P.isSubmitting}),children:({values:P,isSubmitting:$})=>{var W;const q=d||!!P.adapterId&&!!P.agentId,K=!d||P.adapterId!==w.adapterId||P.agentId!==w.agentId||P.strategy!==w.strategy||P.label!==w.label||P.chatId!==w.chatId||P.channelType!==w.channelType||P.permissionMode!==w.permissionMode||P.canInitiate!==w.canInitiate||P.canReply!==w.canReply||P.canReceive!==w.canReceive,B=d?o:(W=O.find(F=>F.id===P.agentId))==null?void 0:W.name,V=q&&B?`${CJe({sessionStrategy:P.strategy,chatDisplayName:P.chatId!==Ia?`#${P.chatId}`:void 0,channelType:P.channelType!==Ia?P.channelType:void 0})} — routed to ${B}.`:null,Q=P.chatId!==Ia||P.channelType!==Ia,re=P.strategy!=="per-chat"||P.permissionMode!=="acceptEdits"||P.canInitiate||!P.canReply||!P.canReceive,U=!q||!K||!!u||$,G=!!u||$;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"space-y-5 overflow-y-auto px-4 py-5",children:[d?a.jsxs("p",{className:"text-muted-foreground text-sm",children:["Channel: ",a.jsx("span",{className:"text-foreground font-medium",children:i})," ","→ ",a.jsx("span",{className:"text-foreground font-medium",children:o})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:"binding-adapter",children:"Adapter"}),R.length===0?a.jsx("p",{className:"text-muted-foreground border-input rounded-md border px-3 py-2 text-sm opacity-50",children:"No adapters configured"}):a.jsx(C.AppField,{name:"adapterId",children:F=>a.jsxs(On,{value:F.state.value,onValueChange:X=>{F.handleChange(X),_(X)},children:[a.jsx(_n,{id:"binding-adapter",className:"w-full",children:a.jsx(In,{placeholder:"Select an adapter"})}),a.jsx(Nn,{children:R.map(X=>a.jsx(mt,{value:X.id,children:X.label},X.id))})]})})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:"binding-agent",children:"Agent"}),O.length===0?a.jsx("p",{className:"text-muted-foreground border-input rounded-md border px-3 py-2 text-sm opacity-50",children:"No agents registered"}):a.jsx(C.AppField,{name:"agentId",children:F=>a.jsxs(On,{value:F.state.value,onValueChange:F.handleChange,children:[a.jsx(_n,{id:"binding-agent",className:"w-full",children:a.jsx(In,{placeholder:"Select an agent"})}),a.jsx(Nn,{children:O.map(X=>a.jsx(mt,{value:X.id,children:nn(X)},X.id))})]})})]})]}),a.jsx(C.AppField,{name:"label",children:F=>a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:"binding-label",children:"Label (optional)"}),a.jsx(sn,{id:"binding-label",placeholder:"e.g., Customer support bot",value:F.state.value,onBlur:F.handleBlur,onChange:X=>F.handleChange(X.target.value)}),a.jsx(Va,{children:"A display name for this binding"})]})}),a.jsxs(WI,{open:f,onOpenChange:m,trigger:"Chat Filter",badge:Q?a.jsx(zt,{variant:"secondary",className:"text-xs",children:"Active"}):void 0,children:[a.jsx(C.AppField,{name:"chatId",children:F=>a.jsxs("div",{className:"space-y-1.5 px-4 py-3",children:[a.jsx(Rt,{htmlFor:"binding-chat-id",children:"Chat ID"}),a.jsxs(On,{value:F.state.value,onValueChange:F.handleChange,children:[a.jsx(_n,{id:"binding-chat-id",className:"w-full",children:a.jsx(In,{placeholder:"Any chat (wildcard)"})}),a.jsxs(Nn,{children:[a.jsx(mt,{value:Ia,children:"Any chat (wildcard)"}),N.map(X=>a.jsxs(mt,{value:X.chatId,children:[a.jsx("span",{children:X.displayName??X.chatId}),(X.channelType||X.messageCount>0)&&a.jsx("span",{className:"text-muted-foreground ml-2 text-xs",children:[X.channelType,`${X.messageCount} msgs`].filter(Boolean).join(" · ")})]},X.chatId))]})]}),a.jsx(Va,{children:"Route only messages from a specific chat or channel"})]})}),a.jsx(C.AppField,{name:"channelType",children:F=>a.jsxs("div",{className:"space-y-1.5 px-4 py-3",children:[a.jsx(Rt,{htmlFor:"binding-channel-type",children:"Channel Type"}),a.jsxs(On,{value:F.state.value,onValueChange:F.handleChange,children:[a.jsx(_n,{id:"binding-channel-type",className:"w-full",children:a.jsx(In,{placeholder:"Any type (wildcard)"})}),a.jsxs(Nn,{children:[a.jsx(mt,{value:Ia,children:"Any type (wildcard)"}),jJe.map(X=>a.jsx(mt,{value:X.value,children:X.label},X.value))]})]})]})}),Q&&a.jsx("div",{className:"px-4 py-3",children:a.jsx(ge,{variant:"ghost",size:"sm",onClick:L,children:"Clear filters"})})]}),a.jsx(wJe,{strategy:P.strategy,onStrategyChange:F=>C.setFieldValue("strategy",F),permissionMode:P.permissionMode,onPermissionModeChange:M,bypassWarningOpen:b,onBypassWarningOpenChange:S,onBypassConfirm:()=>C.setFieldValue("permissionMode","bypassPermissions"),canInitiate:P.canInitiate,onCanInitiateChange:F=>C.setFieldValue("canInitiate",F),canReply:P.canReply,onCanReplyChange:F=>C.setFieldValue("canReply",F),canReceive:P.canReceive,onCanReceiveChange:F=>C.setFieldValue("canReceive",F),open:g,onOpenChange:y,hasChanges:re}),V&&a.jsx("p",{className:"text-muted-foreground bg-muted/50 rounded-md px-3 py-2 text-xs italic",children:V})]}),a.jsxs(jb,{className:"border-t px-4 py-3",children:[d&&l&&c&&a.jsxs(Sl,{children:[a.jsx(mT,{asChild:!0,children:a.jsxs(ge,{variant:"ghost",size:"sm",className:"mr-auto text-red-600 hover:bg-red-50 hover:text-red-700 dark:hover:bg-red-950",children:[a.jsx(wo,{className:"mr-1.5 size-3.5"}),"Remove"]})}),a.jsxs(ko,{children:[a.jsxs(wl,{children:[a.jsx(Co,{children:"Remove channel"}),a.jsx(Eo,{children:"Remove this channel? The agent will no longer receive messages from it."})]}),a.jsxs(kl,{children:[a.jsx(_o,{children:"Cancel"}),a.jsx(To,{onClick:()=>l(c),className:"bg-red-600 hover:bg-red-700 focus:ring-red-600",children:"Remove"})]})]})]}),a.jsx(ge,{variant:"ghost",size:"sm",onClick:()=>t(!1),children:"Cancel"}),a.jsxs(ge,{size:"sm",onClick:()=>C.handleSubmit(),disabled:U,children:[G&&a.jsx(Sn,{className:"mr-1.5 size-3.5 animate-spin"}),G?"Saving...":d?"Save Changes":"Connect Channel"]})]})]})}})]})})}const AJe={"per-chat":"Per Chat","per-user":"Per User",stateless:"Stateless"};function RJe(e){return AJe[e]??e}function MJe({sessionId:e}){const t=et();if(!e)return null;const n=t.getQueryData(["session",e]);return!n||n.permissionMode!=="bypassPermissions"?null:a.jsxs("div",{role:"alert",className:Y("flex items-center gap-2 border-b px-4 py-1.5","border-red-200 bg-red-50 text-red-700","dark:border-red-900 dark:bg-red-950/50 dark:text-red-400"),children:[a.jsx(Q5,{className:"size-3.5 shrink-0"}),a.jsx("span",{className:"text-xs font-medium",children:"All permissions bypassed — the agent can execute any tool without approval"})]})}const vU=["config"],DJe=["meet-dorkbot","discovery","tasks","adapters"];function Wb(){const e=je(),t=et(),n=x.useRef(new Set),s=x.useRef(new Set),{data:r,isLoading:i}=st({queryKey:[...vU],queryFn:()=>e.getConfig(),staleTime:300*1e3}),o={completedSteps:[],skippedSteps:[],startedAt:null,dismissedAt:null},l=r!=null&&r.onboarding?{completedSteps:r.onboarding.completedSteps,skippedSteps:r.onboarding.skippedSteps,startedAt:r.onboarding.startedAt,dismissedAt:r.onboarding.dismissedAt}:o,c=DJe.every(S=>l.completedSteps.includes(S)),u=l.dismissedAt!==null,d=!i&&!c&&!u,f=Bt({mutationFn:S=>e.updateConfig({onboarding:S}),onSuccess:()=>{t.invalidateQueries({queryKey:[...vU]}).then(()=>{n.current.clear(),s.current.clear()})},onError:(S,w)=>{n.current.clear(),s.current.clear();const C=Object.keys(w).join(", ");Ye.error(`Failed to save onboarding progress (${C})`)}});function m(S){const w=new Set([...l.completedSteps,...n.current]);w.has(S)||(n.current.add(S),f.mutate({completedSteps:[...w,S]}))}function g(S){const w=new Set([...l.skippedSteps,...s.current]);w.has(S)||(s.current.add(S),f.mutate({skippedSteps:[...w,S]}))}function y(){return f.mutateAsync({dismissedAt:new Date().toISOString()})}function b(){l.startedAt||f.mutate({startedAt:new Date().toISOString()})}return{state:l,config:r,isLoading:i,isOnboardingComplete:c,isOnboardingDismissed:u,shouldShowOnboarding:d,completeStep:m,skipStep:g,dismiss:y,startOnboarding:b}}const pce={tasks:Uc},OJe=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function gce(e){const t=e.trim().split(/\s+/);if(t.length!==5)return e;const[n,s,r,i,o]=t;return r==="*"&&i==="*"&&o==="*"&&Wx(s)&&Wx(n)?`Every day at ${bU(s,n)}`:r==="*"&&i==="*"&&Wx(o)&&Wx(s)&&Wx(n)?`Every ${OJe[Number(o)]??`day ${o}`} at ${bU(s,n)}`:e}function Wx(e){return/^\d+$/.test(e)}function bU(e,t){const n=Number(e),s=Number(t),r=n>=12?"PM":"AM";return`${n===0?12:n>12?n-12:n}:${String(s).padStart(2,"0")} ${r}`}function IJe(){const[e,t]=x.useState({x:0,y:0}),[n,s]=x.useState(!1),r=Ds(),i=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(hover: none)").matches,o=r||i,l=x.useCallback(d=>{if(o)return;const f=d.currentTarget.getBoundingClientRect();t({x:d.clientX-f.left,y:d.clientY-f.top}),s(!0)},[o]),c=x.useCallback(()=>{s(!1)},[]),u=!o&&n?{background:`radial-gradient(350px circle at ${e.x}px ${e.y}px, rgba(59,130,246,0.06), transparent 80%)`}:void 0;return{position:e,isActive:n,onMouseMove:l,onMouseLeave:c,spotlightStyle:u}}function xce({preset:e,variant:t,checked:n,onCheckedChange:s,onSelect:r,selected:i=!1,className:o}){const{onMouseMove:l,onMouseLeave:c,spotlightStyle:u}=IJe(),d=()=>{t==="toggle"?s==null||s(!n):r==null||r(e)};return a.jsxs("button",{type:"button",onClick:d,onMouseMove:l,onMouseLeave:c,className:Y("relative flex w-full items-start gap-4 rounded-lg border p-4 text-left transition","hover:bg-accent/50","min-h-11",t==="toggle"&&n&&"border-primary/40 bg-accent/30",t==="selectable"&&i&&"border-primary ring-primary bg-accent/30 ring-1",o),children:[u&&a.jsx("div",{className:"pointer-events-none absolute inset-0 rounded-lg",style:u}),t==="toggle"&&a.jsx("div",{className:"flex size-11 shrink-0 items-center justify-center",children:a.jsx(sr,{checked:n??!1,onCheckedChange:s,"aria-label":`Enable ${e.name}`,onClick:f=>f.stopPropagation()})}),a.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[a.jsx("div",{className:"font-medium",children:e.name}),a.jsx("p",{className:"text-muted-foreground text-sm",children:e.description}),a.jsx("p",{className:"text-muted-foreground text-xs",children:gce(e.cron)}),a.jsx("p",{className:"text-muted-foreground/80 line-clamp-2 text-sm",children:e.prompt})]})]})}function yce({onSelect:e,selectedId:t,className:n}){const{data:s,isLoading:r,isError:i}=fP();return r?a.jsx("div",{className:Y("grid grid-cols-2 gap-3",n),children:[0,1,2,3].map(o=>a.jsx("div",{className:"bg-muted animate-tasks h-28 rounded-lg border"},o))}):i?a.jsx("p",{className:"text-destructive text-sm",children:"Failed to load presets. You can start from scratch."}):!s||s.length===0?a.jsx("p",{className:"text-muted-foreground text-sm",children:"No presets available."}):a.jsx("div",{className:Y("grid grid-cols-2 gap-3",n),children:s.map(o=>a.jsx(xce,{preset:o,variant:"selectable",selected:o.id===t,onSelect:e},o.id))})}var MA={exports:{}},SU;function PJe(){return SU||(SU=1,(function(e,t){(function(s,r){e.exports=r()})(globalThis,()=>(()=>{var n={949(o,l,c){Object.defineProperty(l,"__esModule",{value:!0}),l.CronParser=void 0;var u=c(515),d=(function(){function f(m,g,y){g===void 0&&(g=!0),y===void 0&&(y=!1),this.expression=m,this.dayOfWeekStartIndexZero=g,this.monthStartIndexZero=y}return f.prototype.parse=function(){var m,g,y=(m=this.expression)!==null&&m!==void 0?m:"";if(y==="@reboot")return g=["@reboot","","","","","",""],g;if(y.startsWith("@")){var b=this.parseSpecial(this.expression);g=this.extractParts(b)}else g=this.extractParts(this.expression);return this.normalize(g),this.validate(g),g},f.prototype.parseSpecial=function(m){var g={"@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"},y=g[m];if(!y)throw new Error("Unknown special expression.");return y},f.prototype.extractParts=function(m){if(!this.expression)throw new Error("cron expression is empty");for(var g=m.trim().split(/[ ]+/),y=0;y<g.length;y++)if(g[y].includes(",")){var b=g[y].split(",").map(function(w){return w.trim()}).filter(function(w){return w!==""}).map(function(w){return isNaN(Number(w))?w:Number(w)}).filter(function(w){return w!==null&&w!==""});b.length===0&&b.push("*"),b.sort(function(w,C){return w!==null&&C!==null?w-C:0}),g[y]=b.map(function(w){return w!==null?w.toString():""}).join(",")}if(g.length<5)throw new Error("Expression has only ".concat(g.length," part").concat(g.length==1?"":"s",". At least 5 parts are required."));if(g.length==5)g.unshift(""),g.push("");else if(g.length==6){var S=/\d{4}$/.test(g[5])||g[4]=="?"||g[2]=="?";S?g.unshift(""):g.push("")}else if(g.length>7)throw new Error("Expression has ".concat(g.length," parts; too many!"));return g},f.prototype.normalize=function(m){var g=this;if(m[3]=m[3].replace("?","*"),m[5]=m[5].replace("?","*"),m[2]=m[2].replace("?","*"),m[0].indexOf("0/")==0&&(m[0]=m[0].replace("0/","*/")),m[1].indexOf("0/")==0&&(m[1]=m[1].replace("0/","*/")),m[2].indexOf("0/")==0&&(m[2]=m[2].replace("0/","*/")),m[3].indexOf("1/")==0&&(m[3]=m[3].replace("1/","*/")),m[4].indexOf("1/")==0&&(m[4]=m[4].replace("1/","*/")),m[6].indexOf("1/")==0&&(m[6]=m[6].replace("1/","*/")),m[5]=m[5].replace(/(^\d)|([^#/\s]\d)/g,function(j){var _=j.replace(/\D/,""),N=_;return g.dayOfWeekStartIndexZero?_=="7"&&(N="0"):N=(parseInt(_)-1).toString(),j.replace(_,N)}),m[5]=="L"&&(m[5]="6"),m[3]=="?"&&(m[3]="*"),m[3].indexOf("W")>-1&&(m[3].indexOf(",")>-1||m[3].indexOf("-")>-1))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var y={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var b in y)m[5]=m[5].replace(new RegExp(b,"gi"),y[b].toString());m[4]=m[4].replace(/(^\d{1,2})|([^#/\s]\d{1,2})/g,function(j){var _=j.replace(/\D/,""),N=_;return g.monthStartIndexZero&&(N=(parseInt(_)+1).toString()),j.replace(_,N)});var S={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var w in S)m[4]=m[4].replace(new RegExp(w,"gi"),S[w].toString());m[0]=="0"&&(m[0]=""),!/\*|\-|\,|\//.test(m[2])&&(/\*|\//.test(m[1])||/\*|\//.test(m[0]))&&(m[2]+="-".concat(m[2]));for(var C=0;C<m.length;C++)if(m[C].indexOf(",")!=-1&&(m[C]=m[C].split(",").filter(function(j){return j!==""}).join(",")||"*"),m[C]=="*/1"&&(m[C]="*"),m[C].indexOf("/")>-1&&!/^\*|\-|\,/.test(m[C])){var T=null;switch(C){case 4:T="12";break;case 5:T="6";break;case 6:T="9999";break;default:T=null;break}if(T!==null){var E=m[C].split("/");m[C]="".concat(E[0],"-").concat(T,"/").concat(E[1])}}},f.prototype.validate=function(m){var g="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(m[0],g),this.validateOnlyExpectedCharactersFound(m[1],g),this.validateOnlyExpectedCharactersFound(m[2],g),this.validateOnlyExpectedCharactersFound(m[3],"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(m[4],g),this.validateOnlyExpectedCharactersFound(m[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(m[6],g),this.validateAnyRanges(m)},f.prototype.validateAnyRanges=function(m){u.default.secondRange(m[0]),u.default.minuteRange(m[1]),u.default.hourRange(m[2]),u.default.dayOfMonthRange(m[3]),u.default.monthRange(m[4],this.monthStartIndexZero),u.default.dayOfWeekRange(m[5],this.dayOfWeekStartIndexZero)},f.prototype.validateOnlyExpectedCharactersFound=function(m,g){var y=m.match(new RegExp("[^".concat(g,"]+"),"gi"));if(y&&y.length)throw new Error("Expression contains invalid values: '".concat(y.toString(),"'"))},f})();l.CronParser=d},333(o,l,c){Object.defineProperty(l,"__esModule",{value:!0}),l.ExpressionDescriptor=void 0;var u=c(823),d=c(949),f=(function(){function m(g,y){if(this.expression=g,this.options=y,this.expressionParts=new Array(5),!this.options.locale&&m.defaultLocale&&(this.options.locale=m.defaultLocale),!m.locales[this.options.locale]){var b=Object.keys(m.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(b,"'.")),this.options.locale=b}this.i18n=m.locales[this.options.locale],y.use24HourTimeFormat===void 0&&(y.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return m.toString=function(g,y){var b=y===void 0?{}:y,S=b.throwExceptionOnParseError,w=S===void 0?!0:S,C=b.verbose,T=C===void 0?!1:C,E=b.dayOfWeekStartIndexZero,j=E===void 0?!0:E,_=b.monthStartIndexZero,N=_===void 0?!1:_,R=b.use24HourTimeFormat,O=b.trimHoursLeadingZero,M=O===void 0?!1:O,L=b.locale,P=L===void 0?null:L,$=b.logicalAndDayFields,q=$===void 0?!1:$,K={throwExceptionOnParseError:w,verbose:T,dayOfWeekStartIndexZero:j,monthStartIndexZero:N,use24HourTimeFormat:R,trimHoursLeadingZero:M,locale:P,logicalAndDayFields:q};K.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var B=new m(g,K);return B.getFullDescription()},m.initialize=function(g,y){y===void 0&&(y="en"),m.specialCharacters=["/","-",",","*"],m.defaultLocale=y,g.load(m.locales)},m.prototype.getFullDescription=function(){var g,y,b="";try{var S=new d.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=S.parse(),this.expressionParts[0]==="@reboot")return((y=(g=this.i18n).atReboot)===null||y===void 0?void 0:y.call(g))||"Run once, at startup";var w=this.getTimeOfDayDescription(),C=this.getDayOfMonthDescription(),T=this.getMonthDescription(),E=this.getDayOfWeekDescription(),j=this.getYearDescription();b+=w+C+E+T+j,b=this.transformVerbosity(b,!!this.options.verbose),b=b.charAt(0).toLocaleUpperCase()+b.substr(1)}catch(_){if(!this.options.throwExceptionOnParseError)b=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(_)}return b},m.prototype.getTimeOfDayDescription=function(){var g=this.expressionParts[0],y=this.expressionParts[1],b=this.expressionParts[2],S="";if(!u.StringUtilities.containsAny(y,m.specialCharacters)&&!u.StringUtilities.containsAny(b,m.specialCharacters)&&!u.StringUtilities.containsAny(g,m.specialCharacters))S+=this.i18n.atSpace()+this.formatTime(b,y,g);else if(!g&&y.indexOf("-")>-1&&!(y.indexOf(",")>-1)&&!(y.indexOf("/")>-1)&&!u.StringUtilities.containsAny(b,m.specialCharacters)){var w=y.split("-");S+=u.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(b,w[0],""),this.formatTime(b,w[1],""))}else if(!g&&b.indexOf(",")>-1&&b.indexOf("-")==-1&&b.indexOf("/")==-1&&!u.StringUtilities.containsAny(y,m.specialCharacters)){var C=b.split(",");S+=this.i18n.at();for(var T=0;T<C.length;T++)S&&(S+=" "),S+=this.formatTime(C[T],y,""),T<C.length-2&&(S+=","),T==C.length-2&&(S+=this.i18n.spaceAnd())}else{var E=this.getSecondsDescription(),j=this.getMinutesDescription(),_=this.getHoursDescription();if(S+=E,S&&j&&(S+=", "),S+=j,j===_)return S;S&&_&&(S+=", "),S+=_}return S},m.prototype.getSecondsDescription=function(){var g=this,y=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(b){return b},function(b){return u.StringUtilities.format(g.i18n.everyX0Seconds(b),b)},function(b){return g.i18n.secondsX0ThroughX1PastTheMinute()},function(b){return b=="0"?"":parseInt(b)<20?g.i18n.atX0SecondsPastTheMinute(b):g.i18n.atX0SecondsPastTheMinuteGt20()||g.i18n.atX0SecondsPastTheMinute(b)});return y},m.prototype.getMinutesDescription=function(){var g=this,y=this.expressionParts[0],b=this.expressionParts[2],S=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(w){return w},function(w){return u.StringUtilities.format(g.i18n.everyX0Minutes(w),w)},function(w){return g.i18n.minutesX0ThroughX1PastTheHour()},function(w){var C,T;try{return w=="0"&&b.indexOf("/")==-1&&y==""?g.i18n.everyHour():w=="0"?((T=(C=g.i18n).onTheHour)===null||T===void 0?void 0:T.call(C))||g.i18n.atX0MinutesPastTheHour(w):parseInt(w)<20?g.i18n.atX0MinutesPastTheHour(w):g.i18n.atX0MinutesPastTheHourGt20()||g.i18n.atX0MinutesPastTheHour(w)}catch{return g.i18n.atX0MinutesPastTheHour(w)}});return S},m.prototype.getHoursDescription=function(){var g=this,y=this.expressionParts[2],b=0,S=[];y.split("/")[0].split(",").forEach(function(T){var E=T.split("-");E.length===2&&S.push({value:E[1],index:b+1}),b+=E.length});var w=0,C=this.getSegmentDescription(y,this.i18n.everyHour(),function(T){var E=S.find(function(_){return _.value===T&&_.index===w}),j=E&&g.expressionParts[1]!=="0";return w++,j?g.formatTime(T,"59",""):g.formatTime(T,"0","")},function(T){return u.StringUtilities.format(g.i18n.everyX0Hours(T),T)},function(T){return g.i18n.betweenX0AndX1()},function(T){return g.i18n.atX0()});return C},m.prototype.getDayOfWeekDescription=function(){var g=this,y=this.i18n.daysOfTheWeek(),b=null;return this.expressionParts[5]=="*"?b="":b=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(S,w){var C=S;S.indexOf("#")>-1?C=S.substring(0,S.indexOf("#")):S.indexOf("L")>-1&&(C=C.replace("L",""));var T=parseInt(C),E=g.i18n.daysOfTheWeekInCase?g.i18n.daysOfTheWeekInCase(w)[T]:y[T];if(S.indexOf("#")>-1){var j=null,_=S.substring(S.indexOf("#")+1),N=S.substring(0,S.indexOf("#"));switch(_){case"1":j=g.i18n.first(N);break;case"2":j=g.i18n.second(N);break;case"3":j=g.i18n.third(N);break;case"4":j=g.i18n.fourth(N);break;case"5":j=g.i18n.fifth(N);break}E=j+" "+E}return E},function(S){return parseInt(S)==1?"":u.StringUtilities.format(g.i18n.commaEveryX0DaysOfTheWeek(S),S)},function(S){var w=S.substring(0,S.indexOf("-")),C=g.expressionParts[3]!="*";return C?g.i18n.commaAndX0ThroughX1(w):g.i18n.commaX0ThroughX1(w)},function(S){var w=null;if(S.indexOf("#")>-1){var C=S.substring(S.indexOf("#")+1),T=S.substring(0,S.indexOf("#"));w=g.i18n.commaOnThe(C,T).trim()+g.i18n.spaceX0OfTheMonth()}else if(S.indexOf("L")>-1)w=g.i18n.commaOnTheLastX0OfTheMonth(S.replace("L",""));else{var E=g.expressionParts[3]!="*";E?g.options.logicalAndDayFields?w=g.i18n.commaOnlyOnX0(S):w=g.i18n.commaAndOnX0():w=g.i18n.commaOnlyOnX0(S)}return w}),b},m.prototype.getMonthDescription=function(){var g=this,y=this.i18n.monthsOfTheYear(),b=this.getSegmentDescription(this.expressionParts[4],"",function(S,w){return w&&g.i18n.monthsOfTheYearInCase?g.i18n.monthsOfTheYearInCase(w)[parseInt(S)-1]:y[parseInt(S)-1]},function(S){return parseInt(S)==1?"":u.StringUtilities.format(g.i18n.commaEveryX0Months(S),S)},function(S){return g.i18n.commaMonthX0ThroughMonthX1()||g.i18n.commaX0ThroughX1()},function(S){return g.i18n.commaOnlyInMonthX0?g.i18n.commaOnlyInMonthX0():g.i18n.commaOnlyInX0()});return b},m.prototype.getDayOfMonthDescription=function(){var g=this,y=null,b=this.expressionParts[3];switch(b){case"L":y=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":y=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var S=b.match(/(\d{1,2}W)|(W\d{1,2})/);if(S){var w=parseInt(S[0].replace("W","")),C=w==1?this.i18n.firstWeekday():u.StringUtilities.format(this.i18n.weekdayNearestDayX0(),w.toString());y=u.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),C);break}else{var T=b.match(/L-(\d{1,2})/);if(T){var E=T[1];y=u.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(E),E);break}else{if(b=="*"&&this.expressionParts[5]!="*")return"";y=this.getSegmentDescription(b,this.i18n.commaEveryDay(),function(j){return j=="L"?g.i18n.lastDay():g.i18n.dayX0?u.StringUtilities.format(g.i18n.dayX0(),j):j},function(j){return j=="1"?g.i18n.commaEveryDay():g.i18n.commaEveryX0Days(j)},function(j){return g.i18n.commaBetweenDayX0AndX1OfTheMonth(j)},function(j){return g.i18n.commaOnDayX0OfTheMonth(j)})}break}}return y},m.prototype.getYearDescription=function(){var g=this,y=this.getSegmentDescription(this.expressionParts[6],"",function(b){return/^\d+$/.test(b)?new Date(parseInt(b),1).getFullYear().toString():b},function(b){return u.StringUtilities.format(g.i18n.commaEveryX0Years(b),b)},function(b){return g.i18n.commaYearX0ThroughYearX1()||g.i18n.commaX0ThroughX1()},function(b){return g.i18n.commaOnlyInYearX0?g.i18n.commaOnlyInYearX0():g.i18n.commaOnlyInX0()});return y},m.prototype.getSegmentDescription=function(g,y,b,S,w,C){var T=null,E=g.indexOf("/")>-1,j=g.indexOf("-")>-1,_=g.indexOf(",")>-1;if(!g)T="";else if(g==="*")T=y;else if(!E&&!j&&!_)T=u.StringUtilities.format(C(g),b(g));else if(_){for(var N=g.split(","),R="",O=this.i18n.spaceAnd(),M=0;M<N.length;M++)if(M>0&&N.length>2&&(R+=",",M<N.length-1&&(R+=" ")),M>0&&N.length>1&&(M==N.length-1||N.length==2)&&(R+=O==","&&N.length>2?" ":"".concat(O," ")),N[M].indexOf("/")>-1||N[M].indexOf("-")>-1){var L=N[M].indexOf("-")>-1&&N[M].indexOf("/")==-1,P=this.getSegmentDescription(N[M],y,b,S,L?this.i18n.commaX0ThroughX1:w,C);L&&(P=P.replace(", ","")),R+=P}else if(!E)R+=b(N[M]);else{var $=this.getSegmentDescription(N[M],y,b,S,w,C);$&&$.startsWith(", ")&&($=$.substring(2)),R+=$}E?T=R:T=u.StringUtilities.format(C(g),R)}else if(E){var N=g.split("/");if(T=u.StringUtilities.format(S(N[1]),N[1]),N[0].indexOf("-")>-1){var q=this.generateRangeSegmentDescription(N[0],w,b);q.indexOf(", ")!=0&&(T+=", "),T+=q}else if(N[0].indexOf("*")==-1){var K=u.StringUtilities.format(C(N[0]),b(N[0]));K=K.replace(", ",""),T+=u.StringUtilities.format(this.i18n.commaStartingX0(),K)}}else j&&(T=this.generateRangeSegmentDescription(g,w,b));return T},m.prototype.generateRangeSegmentDescription=function(g,y,b){var S="",w=g.split("-"),C=b(w[0],1),T=b(w[1],2),E=y(g);return S+=u.StringUtilities.format(E,C,T),S},m.prototype.formatTime=function(g,y,b){var S=0,w=0,C=parseInt(g)+S,T=parseInt(y)+w;T>=60?(T-=60,C+=1):T<0&&(T+=60,C-=1),C>=24?C=C-24:C<0&&(C=24+C);var E="",j=!1;this.options.use24HourTimeFormat||(j=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),E=j?"".concat(this.getPeriod(C)," "):" ".concat(this.getPeriod(C)),C>12&&(C-=12),C===0&&(C=12));var _="";b&&(_=":".concat(("00"+b).substring(b.length)));var N=C.toString(),R=("00"+N).substring(N.length),O=T.toString(),M=("00"+O).substring(O.length),L=this.options.trimHoursLeadingZero?N:R;return"".concat(j?E:"").concat(L,":").concat(M).concat(_).concat(j?"":E)},m.prototype.transformVerbosity=function(g,y){if(!y&&(g=g.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),g=g.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),g=g.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),g=g.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var b=0,S=Object.entries(this.i18n.conciseVerbosityReplacements());b<S.length;b++){var w=S[b],C=w[0],T=w[1];g=g.replace(new RegExp(C,"g"),T)}return g},m.prototype.getPeriod=function(g){return g>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},m.locales={},m})();l.ExpressionDescriptor=f},747(o,l,c){Object.defineProperty(l,"__esModule",{value:!0}),l.enLocaleLoader=void 0;var u=c(486),d=(function(){function f(){}return f.prototype.load=function(m){m.en=new u.en},f})();l.enLocaleLoader=d},486(o,l){Object.defineProperty(l,"__esModule",{value:!0}),l.en=void 0;var c=(function(){function u(){}return u.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},u.prototype.atX0MinutesPastTheHourGt20=function(){return null},u.prototype.commaMonthX0ThroughMonthX1=function(){return null},u.prototype.commaYearX0ThroughYearX1=function(){return null},u.prototype.use24HourTimeFormatByDefault=function(){return!1},u.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},u.prototype.everyMinute=function(){return"every minute"},u.prototype.everyHour=function(){return"every hour"},u.prototype.atSpace=function(){return"At "},u.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},u.prototype.at=function(){return"At"},u.prototype.spaceAnd=function(){return" and"},u.prototype.everySecond=function(){return"every second"},u.prototype.everyX0Seconds=function(){return"every %s seconds"},u.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},u.prototype.atX0SecondsPastTheMinute=function(){return"at %s seconds past the minute"},u.prototype.everyX0Minutes=function(){return"every %s minutes"},u.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},u.prototype.atX0MinutesPastTheHour=function(){return"at %s minutes past the hour"},u.prototype.everyX0Hours=function(){return"every %s hours"},u.prototype.betweenX0AndX1=function(){return"between %s and %s"},u.prototype.atX0=function(){return"at %s"},u.prototype.commaEveryDay=function(){return", every day"},u.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},u.prototype.commaX0ThroughX1=function(){return", %s through %s"},u.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},u.prototype.first=function(){return"first"},u.prototype.second=function(){return"second"},u.prototype.third=function(){return"third"},u.prototype.fourth=function(){return"fourth"},u.prototype.fifth=function(){return"fifth"},u.prototype.commaOnThe=function(){return", on the "},u.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},u.prototype.lastDay=function(){return"the last day"},u.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},u.prototype.commaOnlyOnX0=function(){return", only on %s"},u.prototype.commaAndOnX0=function(){return", and on %s"},u.prototype.commaEveryX0Months=function(){return", every %s months"},u.prototype.commaOnlyInX0=function(){return", only in %s"},u.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},u.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},u.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(){return", %s days before the last day of the month"},u.prototype.firstWeekday=function(){return"first weekday"},u.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},u.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},u.prototype.commaEveryX0Days=function(){return", every %s days in a month"},u.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},u.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},u.prototype.commaEveryHour=function(){return", every hour"},u.prototype.commaEveryX0Years=function(){return", every %s years"},u.prototype.commaStartingX0=function(){return", starting %s"},u.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},u.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},u.prototype.atReboot=function(){return"Run once, at startup"},u.prototype.onTheHour=function(){return"on the hour"},u})();l.en=c},515(o,l){Object.defineProperty(l,"__esModule",{value:!0});function c(d,f){if(!d)throw new Error(f)}var u=(function(){function d(){}return d.secondRange=function(f){for(var m=f.split(","),g=0;g<m.length;g++)if(!isNaN(parseInt(m[g],10))){var y=parseInt(m[g],10);c(y>=0&&y<=59,"seconds part must be >= 0 and <= 59")}},d.minuteRange=function(f){for(var m=f.split(","),g=0;g<m.length;g++)if(!isNaN(parseInt(m[g],10))){var y=parseInt(m[g],10);c(y>=0&&y<=59,"minutes part must be >= 0 and <= 59")}},d.hourRange=function(f){for(var m=f.split(","),g=0;g<m.length;g++)if(!isNaN(parseInt(m[g],10))){var y=parseInt(m[g],10);c(y>=0&&y<=23,"hours part must be >= 0 and <= 23")}},d.dayOfMonthRange=function(f){for(var m=f.split(","),g=0;g<m.length;g++)if(!isNaN(parseInt(m[g],10))){var y=parseInt(m[g],10);c(y>=1&&y<=31,"DOM part must be >= 1 and <= 31")}},d.monthRange=function(f,m){for(var g=f.split(","),y=0;y<g.length;y++)if(!isNaN(parseInt(g[y],10))){var b=parseInt(g[y],10);c(b>=1&&b<=12,m?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},d.dayOfWeekRange=function(f,m){for(var g=f.split(","),y=0;y<g.length;y++)if(!isNaN(parseInt(g[y],10))){var b=parseInt(g[y],10);c(b>=0&&b<=6,m?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}},d})();l.default=u},823(o,l){Object.defineProperty(l,"__esModule",{value:!0}),l.StringUtilities=void 0;var c=(function(){function u(){}return u.format=function(d){for(var f=[],m=1;m<arguments.length;m++)f[m-1]=arguments[m];return d.replace(/%s/g,function(g){return f.shift()})},u.containsAny=function(d,f){return f.some(function(m){return d.indexOf(m)>-1})},u})();l.StringUtilities=c}},s={};function r(o){var l=s[o];if(l!==void 0)return l.exports;var c=s[o]={exports:{}};return n[o](c,c.exports,r),c.exports}var i={};return(()=>{var o=i;Object.defineProperty(o,"__esModule",{value:!0}),o.toString=void 0;var l=r(333),c=r(747);l.ExpressionDescriptor.initialize(new c.enLocaleLoader),o.default=l.ExpressionDescriptor;var u=l.ExpressionDescriptor.toString;o.toString=u})(),i})())})(MA)),MA.exports}var LJe=PJe();const vce=hl(LJe),Sp={frequency:"daily",hour:9,days:[1,2,3,4,5],dayOfMonth:1},FJe=[{value:"15m",label:"Every 15 minutes"},{value:"hourly",label:"Every hour"},{value:"daily",label:"Every day"},{value:"weekly",label:"Every week"},{value:"monthly",label:"Every month"}],zJe=[{value:1,label:"Mon"},{value:2,label:"Tue"},{value:3,label:"Wed"},{value:4,label:"Thu"},{value:5,label:"Fri"},{value:6,label:"Sat"},{value:0,label:"Sun"}],BJe=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],$Je=[1,2,3,4,5],HJe=[0,6],DA={duration:.2,ease:[.4,0,.2,1]};function wU(e){const t=e.trim();if(!t)return null;const n=t.split(/\s+/);if(n.length!==5)return null;const[s,r,i,o,l]=n;if(o!=="*")return null;if(s==="*/15"&&r==="*"&&i==="*"&&l==="*")return{...Sp,frequency:"15m"};if(s!=="0")return null;if(r==="*"&&i==="*"&&l==="*")return{...Sp,frequency:"hourly"};const c=Number(r);if(!Number.isInteger(c)||c<0||c>23)return null;if(i!=="*"&&l==="*"){const u=Number(i);return!Number.isInteger(u)||u<1||u>31?null:{...Sp,frequency:"monthly",hour:c,dayOfMonth:u}}if(i==="*"&&l==="*")return{...Sp,frequency:"daily",hour:c};if(i==="*"&&l!=="*"){const u=UJe(l);return u?{...Sp,frequency:"weekly",hour:c,days:u}:null}return null}function UJe(e){const t=[];for(const n of e.split(",")){const s=n.match(/^(\d)-(\d)$/);if(s){const r=Number(s[1]),i=Number(s[2]);if(r>6||i>6||r>i)return null;for(let o=r;o<=i;o++)t.push(o)}else{const r=Number(n);if(!Number.isInteger(r)||r<0||r>6)return null;t.push(r)}}return t.length>0?t.sort((n,s)=>n-s):null}function kU(e){switch(e.frequency){case"15m":return"*/15 * * * *";case"hourly":return"0 * * * *";case"daily":return`0 ${e.hour} * * *`;case"weekly":return`0 ${e.hour} * * ${e.days.join(",")}`;case"monthly":return`0 ${e.hour} ${e.dayOfMonth} * *`}}function bce(e){const t=e<12?"AM":"PM";return`${e%12||12}:00 ${t}`}function Sce(e){const t=e%100;if(t>=11&&t<=13)return`${e}th`;const n=e%10;return n===1?`${e}st`:n===2?`${e}nd`:n===3?`${e}rd`:`${e}th`}function CU(e,t){return e.length===t.length&&e.every((n,s)=>n===t[s])}function VJe(e){const t=bce(e.hour);switch(e.frequency){case"15m":return"Runs every 15 minutes";case"hourly":return"Runs every hour, on the hour";case"daily":return`Runs every day at ${t}`;case"weekly":{const n=[...e.days].sort((o,l)=>o-l);if(CU(n,$Je))return`Runs every weekday at ${t}`;if(CU(n,HJe))return`Runs every Saturday and Sunday at ${t}`;const r=n.filter(o=>o!==0).concat(n.includes(0)?[0]:[]).map(o=>BJe[o]);if(r.length===1)return`Runs every ${r[0]} at ${t}`;if(r.length===2)return`Runs every ${r[0]} and ${r[1]} at ${t}`;const i=r.pop();return`Runs every ${r.join(", ")}, and ${i} at ${t}`}case"monthly":return`Runs on the ${Sce(e.dayOfMonth)} of every month at ${t}`}}function EU(e){if(!e.trim())return"";try{return vce.toString(e)}catch{return"Invalid cron expression"}}function qJe({value:e,onChange:t}){const n=wU(e),[s,r]=x.useState(n?"simple":e.trim()?"cron":"simple"),[i,o]=x.useState(n??Sp),l=x.useRef(e);x.useEffect(()=>{if(e===l.current)return;l.current=e;const S=wU(e);S?(r("simple"),o(S)):e.trim()&&r("cron")},[e]);function c(S){o(S);const w=kU(S);l.current=w,t(w)}function u(S){c({...i,frequency:S})}function d(S){c({...i,hour:Number(S)})}function f(S){const w=i.days.includes(S);if(w&&i.days.length<=1)return;const C=w?i.days.filter(T=>T!==S):[...i.days,S].sort((T,E)=>T-E);c({...i,days:C})}function m(S){c({...i,dayOfMonth:Number(S)})}function g(){r("cron")}function y(){r("simple");const S=kU(i);l.current=S,t(S)}const b=i.frequency!=="15m"&&i.frequency!=="hourly";return s==="cron"?a.jsxs("div",{className:"space-y-2",children:[a.jsx("button",{type:"button",onClick:y,className:"text-muted-foreground hover:text-foreground text-xs underline-offset-4 hover:underline",children:"Back to simple schedule"}),a.jsx(sn,{className:"font-mono",value:e,onChange:S=>t(S.target.value),placeholder:"0 9 * * 1-5"}),e.trim()&&a.jsx("p",{className:Y("text-xs",EU(e)==="Invalid cron expression"?"text-destructive":"text-muted-foreground"),children:EU(e)}),a.jsx("a",{href:"https://crontab.guru",target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground block text-xs hover:underline",children:"Learn about cron expressions"})]}):a.jsxs("div",{className:"space-y-3",children:[a.jsxs(On,{value:i.frequency,onValueChange:u,children:[a.jsx(_n,{responsive:!1,className:"h-9","aria-label":"Frequency",children:a.jsx(In,{})}),a.jsx(Nn,{children:FJe.map(S=>a.jsx(mt,{value:S.value,children:S.label},S.value))})]}),a.jsx(Ue,{initial:!1,mode:"wait",children:b&&a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:DA,className:"overflow-hidden",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-muted-foreground text-sm",children:"at"}),a.jsxs(On,{value:String(i.hour),onValueChange:d,children:[a.jsx(_n,{responsive:!1,className:"h-9 w-32","aria-label":"Time",children:a.jsx(In,{})}),a.jsx(Nn,{children:Array.from({length:24},(S,w)=>a.jsx(mt,{value:String(w),children:bce(w)},w))})]})]})},"time")}),a.jsx(Ue,{initial:!1,children:i.frequency==="weekly"&&a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:DA,className:"overflow-hidden",children:a.jsx("div",{className:"flex flex-wrap gap-1.5",children:zJe.map(S=>{const w=i.days.includes(S.value);return a.jsx("button",{type:"button","aria-label":S.label,"aria-pressed":w,className:Y("rounded-md border px-2.5 py-1 text-xs font-medium transition-colors",w?"border-primary bg-primary/10 text-primary":"border-input text-muted-foreground hover:bg-accent hover:text-accent-foreground"),onClick:()=>f(S.value),children:S.label},S.value)})})},"days")}),a.jsx(Ue,{initial:!1,children:i.frequency==="monthly"&&a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:DA,className:"overflow-hidden",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-muted-foreground text-sm",children:"on day"}),a.jsxs(On,{value:String(i.dayOfMonth),onValueChange:m,children:[a.jsx(_n,{responsive:!1,className:"h-9 w-20","aria-label":"Day of month",children:a.jsx(In,{})}),a.jsx(Nn,{children:Array.from({length:31},(S,w)=>a.jsx(mt,{value:String(w+1),children:Sce(w+1)},w+1))})]})]})},"dom")}),a.jsx("p",{className:"text-muted-foreground text-xs",children:VJe(i)}),a.jsx("button",{type:"button",onClick:g,className:"text-muted-foreground hover:text-foreground text-xs underline-offset-4 hover:underline",children:"Use a cron expression"})]})}function GJe(e){const t=new Map;for(const n of e){const[s]=n.split("/");t.has(s)||t.set(s,[]),t.get(s).push(n)}return t}function KJe({value:e,onChange:t}){const[n,s]=x.useState(!1),r=x.useRef(null),i=x.useMemo(()=>{try{return Intl.supportedValuesOf("timeZone")}catch{return[]}},[]),o=x.useMemo(()=>GJe(i),[i]),l=x.useMemo(()=>Intl.DateTimeFormat().resolvedOptions().timeZone,[]);x.useEffect(()=>{if(!n)return;function d(f){r.current&&!r.current.contains(f.target)&&s(!1)}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[n]);const c=e||"System default";function u(d){t(d),s(!1)}return a.jsxs("div",{ref:r,className:"relative w-full",children:[a.jsxs("button",{type:"button","aria-expanded":n,"aria-haspopup":"listbox",className:Y("border-input ring-offset-background flex h-9 w-full items-center justify-between rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm transition-colors","focus-visible:ring-ring focus-visible:ring-1 focus-visible:outline-none","hover:bg-accent/50"),onClick:()=>s(d=>!d),children:[a.jsx("span",{className:"truncate",children:c}),a.jsx(Wte,{className:"ml-2 size-4 shrink-0 opacity-50"})]}),n&&a.jsx("div",{className:"bg-popover text-popover-foreground absolute top-full left-0 z-50 mt-1 w-full rounded-md border shadow-md",children:a.jsxs(gT,{children:[a.jsx(xT,{placeholder:"Search timezone..."}),a.jsxs(yT,{className:"max-h-60",children:[a.jsx(vT,{children:"No timezone found."}),a.jsxs(ao,{heading:"Default",children:[a.jsxs(Qr,{value:"system-default",onSelect:()=>u(""),children:[a.jsx("span",{children:"System default"}),e===""&&a.jsx(Lt,{className:"ml-auto size-4"})]}),l&&a.jsxs(Qr,{value:`${l}-detected`,onSelect:()=>u(l),children:[a.jsxs("span",{children:[l," (detected)"]}),e===l&&a.jsx(Lt,{className:"ml-auto size-4"})]})]}),[...o.entries()].map(([d,f])=>a.jsx(ao,{heading:d,children:f.map(m=>a.jsxs(Qr,{value:m,onSelect:()=>u(m),children:[a.jsx("span",{children:m.replace(`${d}/`,"").replace(/_/g," ")}),m===e&&a.jsx(Lt,{className:"ml-auto size-4"})]},m))},d))]})]})})]})}function TU({agents:e,value:t,onSelect:n}){return a.jsxs(gT,{children:[a.jsx(xT,{placeholder:"Search agents..."}),a.jsxs(yT,{className:"!max-h-60 !overflow-y-auto",children:[a.jsx(vT,{children:"No agents found."}),a.jsx(ao,{children:e.map(s=>{const r=Dd(s);return a.jsxs(Qr,{value:`${nn(s)} ${s.name} ${s.projectPath}`,onSelect:()=>n(s.id),children:[a.jsx(Vb,{color:r.color,emoji:r.emoji,size:"xs"}),a.jsx("span",{className:"truncate font-medium",children:nn(s)}),a.jsx("span",{className:"text-muted-foreground truncate text-xs",children:Mc(s.projectPath)}),s.id===t&&a.jsx(Lt,{className:"ml-auto size-4 shrink-0"})]},s.id)})})]})]})}function _U({selectedAgent:e,open:t,onClick:n}){const s=e?Dd(e):null;return a.jsxs("button",{type:"button","aria-expanded":t,"aria-haspopup":"listbox",className:Y("border-input ring-offset-background flex h-9 w-full items-center justify-between rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm transition-colors","focus-visible:ring-ring focus-visible:ring-1 focus-visible:outline-none","hover:bg-accent/50"),onClick:n,children:[e?a.jsxs("span",{className:"flex items-center gap-2 truncate",children:[a.jsx(Vb,{color:s.color,emoji:s.emoji,size:"xs"}),a.jsx("span",{className:"truncate",children:nn(e)})]}):a.jsx("span",{className:"text-muted-foreground",children:"Select an agent..."}),a.jsx(Wte,{className:"ml-2 size-4 shrink-0 opacity-50"})]})}function wce({agents:e,value:t,onValueChange:n}){const[s,r]=x.useState(!1),i=Us(),o=x.useRef(null);x.useEffect(()=>{if(!s||i)return;function u(d){o.current&&!o.current.contains(d.target)&&r(!1)}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[s,i]);const l=e.find(u=>u.id===t);function c(u){n(u===t?void 0:u),r(!1)}return e.length===0?a.jsxs("div",{className:"rounded-md border px-4 py-6 text-center",children:[a.jsx("p",{className:"text-muted-foreground text-sm",children:"No agents registered yet"}),a.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"Register an agent via the Mesh panel to schedule automated tasks."})]}):i?a.jsxs(a.Fragment,{children:[a.jsx(_U,{selectedAgent:l,open:s,onClick:()=>r(!0)}),a.jsx(Zh,{open:s,onOpenChange:r,children:a.jsxs(Xh,{children:[a.jsx(_b,{children:a.jsx(Nb,{children:"Select an agent"})}),a.jsx("div",{className:"px-4 pb-4",children:a.jsx(TU,{agents:e,value:t,onSelect:c})})]})})]}):a.jsxs("div",{ref:o,className:"relative w-full",children:[a.jsx(_U,{selectedAgent:l,open:s,onClick:()=>r(u=>!u)}),s&&a.jsx("div",{className:"bg-popover text-popover-foreground absolute top-full left-0 z-50 mt-1 w-full rounded-md border shadow-md",children:a.jsx(TU,{agents:e,value:t,onSelect:c})})]})}const OA="10m",WJe=100;function YJe(e){return`${Math.round(e/6e4)}m`}function Sf(e,t,n){return e?{name:e.name,description:e.description??"",prompt:e.prompt,cron:e.cron??"",agentId:e.agentId??"",timezone:e.timezone??"",permissionMode:e.permissionMode==="bypassPermissions"?"bypassPermissions":"acceptEdits",maxRuntime:e.maxRuntime?YJe(e.maxRuntime):OA}:t?{name:t.name,description:t.description,prompt:t.prompt,cron:t.cron,agentId:n??"",timezone:t.timezone??"",permissionMode:"acceptEdits",maxRuntime:OA}:{name:"",description:"",prompt:"",cron:"",agentId:n??"",timezone:"",permissionMode:"acceptEdits",maxRuntime:OA}}function ZJe({defaultValues:e,agents:t,editTask:n,onSubmitSuccess:s,onCancel:r,onDeleteClick:i,isPending:o}){const l=cP(),c=uP(),u=XE({defaultValues:e,onSubmit:({value:d})=>{const f=d.agentId.trim()||void 0,m=d.cron.trim();if(n){const g={name:d.name.trim(),description:d.description.trim(),prompt:d.prompt.trim(),cron:m||null,...m&&d.timezone?{timezone:d.timezone}:{},permissionMode:d.permissionMode,maxRuntime:d.maxRuntime.trim()||void 0};c.mutate({id:n.id,...g},{onSuccess:s})}else{const g=f??"global",y={name:d.name.trim(),description:d.description.trim()||d.name.trim(),prompt:d.prompt.trim(),target:g,cron:m||void 0,...m&&d.timezone?{timezone:d.timezone}:{},permissionMode:d.permissionMode,maxRuntime:d.maxRuntime.trim()||void 0};l.mutate(y,{onSuccess:s})}}});return a.jsxs(u.AppForm,{children:[a.jsx("form",{onSubmit:d=>{d.preventDefault(),u.handleSubmit()},id:"schedule-form",className:"min-h-0 flex-1 overflow-y-auto",children:a.jsxs("div",{className:"space-y-5 px-4 py-5",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(Rt,{children:"Agent"}),a.jsx(u.AppField,{name:"agentId",children:d=>a.jsx(wce,{agents:t,value:d.state.value||void 0,onValueChange:f=>d.handleChange(f??"")})})]}),a.jsx(u.AppField,{name:"name",children:d=>a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:"schedule-name",children:"Name *"}),a.jsx("input",{id:"schedule-name",className:"border-input focus-visible:ring-ring w-full rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm focus-visible:ring-1 focus-visible:outline-none",value:d.state.value,onChange:f=>d.handleChange(f.target.value),onBlur:d.handleBlur,maxLength:WJe,placeholder:"Daily code review"}),d.state.meta.isTouched&&d.state.meta.errors.length>0&&a.jsx("p",{className:"text-destructive text-xs",children:String(d.state.meta.errors[0])})]})}),a.jsx(u.AppField,{name:"description",children:d=>a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:"schedule-description",children:"Description *"}),a.jsx("input",{id:"schedule-description",className:"border-input focus-visible:ring-ring w-full rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm focus-visible:ring-1 focus-visible:outline-none",value:d.state.value,onChange:f=>d.handleChange(f.target.value),onBlur:d.handleBlur,placeholder:"A short description of this schedule"}),d.state.meta.isTouched&&d.state.meta.errors.length>0&&a.jsx("p",{className:"text-destructive text-xs",children:String(d.state.meta.errors[0])})]})}),a.jsx(u.AppField,{name:"prompt",children:d=>a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:"schedule-prompt",children:"Prompt *"}),a.jsx("textarea",{id:"schedule-prompt",className:"border-input focus-visible:ring-ring w-full rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm focus-visible:ring-1 focus-visible:outline-none",value:d.state.value,onChange:f=>d.handleChange(f.target.value),onBlur:d.handleBlur,rows:4,placeholder:"Review all pending PRs and summarize findings..."}),d.state.meta.isTouched&&d.state.meta.errors.length>0&&a.jsx("p",{className:"text-destructive text-xs",children:String(d.state.meta.errors[0])})]})}),a.jsxs("details",{className:"group",open:!!e.cron,children:[a.jsxs("summary",{className:"text-muted-foreground hover:text-foreground flex cursor-pointer list-none items-center gap-1.5 text-sm",children:[a.jsx(Rs,{className:"size-4 transition-transform group-open:rotate-90"}),"Schedule",a.jsx("span",{className:"text-muted-foreground/60 text-xs",children:"(optional)"})]}),a.jsxs("div",{className:"mt-3 space-y-4 pl-6",children:[a.jsx(u.AppField,{name:"cron",children:d=>a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{children:"Cron Expression"}),a.jsx(qJe,{value:d.state.value,onChange:f=>d.handleChange(f)})]})}),a.jsx(u.AppField,{name:"timezone",children:d=>a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{children:"Timezone"}),a.jsx(KJe,{value:d.state.value,onChange:f=>d.handleChange(f)})]})})]})]}),a.jsxs("details",{className:"group",children:[a.jsxs("summary",{className:"text-muted-foreground hover:text-foreground flex cursor-pointer list-none items-center gap-1.5 text-sm",children:[a.jsx(Rs,{className:"size-4 transition-transform group-open:rotate-90"}),"Advanced settings"]}),a.jsxs("div",{className:"mt-3 space-y-4 pl-6",children:[a.jsx(u.AppField,{name:"permissionMode",children:d=>a.jsxs("fieldset",{className:"space-y-2",children:[a.jsx("legend",{className:"mb-1.5 text-sm font-medium",children:"Permission Mode"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",name:"permissionMode",checked:d.state.value==="acceptEdits",onChange:()=>d.handleChange("acceptEdits")}),"Allow file edits"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",name:"permissionMode",checked:d.state.value==="bypassPermissions",onChange:()=>d.handleChange("bypassPermissions")}),"Full autonomy"]}),d.state.value==="bypassPermissions"&&a.jsx("p",{className:"text-xs text-yellow-600 dark:text-yellow-400",children:"Warning: This allows the agent to execute any tool without approval."})]})}),a.jsx(u.AppField,{name:"maxRuntime",children:d=>a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:"schedule-max-runtime",children:"Max Runtime"}),a.jsx("input",{id:"schedule-max-runtime",className:"border-input focus-visible:ring-ring w-24 rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm focus-visible:ring-1 focus-visible:outline-none",value:d.state.value,onChange:f=>d.handleChange(f.target.value),onBlur:d.handleBlur,placeholder:"10m"})]})})]})]})]})}),a.jsxs(jb,{className:"shrink-0 border-t px-4 py-3",children:[n&&a.jsxs(ge,{type:"button",variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive mr-auto",onClick:i,children:[a.jsx(wo,{className:"mr-1.5 size-4"}),"Delete"]}),a.jsx(ge,{variant:"ghost",size:"sm",onClick:r,children:"Cancel"}),a.jsx(u.Subscribe,{selector:d=>d.values.name.trim()!==""&&d.values.prompt.trim()!=="",children:d=>a.jsx(ge,{type:"submit",size:"sm",form:"schedule-form",disabled:!d||o,children:o?"Saving...":n?"Save":"Create"})})]})]})}function SD({open:e,onOpenChange:t,editTask:n,initialPreset:s,initialAgentId:r}){const i=ice(),o=uP(),l=cP(),{data:c}=Kb(),u=(c==null?void 0:c.agents)??[],[d,f]=x.useState(()=>n?"form":"preset-picker"),[m,g]=x.useState(null),[y,b]=x.useState(!1),[S,w]=x.useState((n==null?void 0:n.enabled)??!0),[C,T]=x.useState(()=>Sf(n,void 0,r)),[E,j]=x.useState(0);function _(q){T(q),j(K=>K+1)}x.useEffect(()=>{if(!e){_(Sf(n,void 0,r)),g(null),b(!1),f(n?"form":"preset-picker");return}n?(_(Sf(n)),w(n.enabled),f("form")):s?(_(Sf(void 0,s,r)),g(s),f("form")):(_(Sf(void 0,void 0,r)),f("preset-picker"))},[n,e,s,r]);const{pendingTemplate:N,externalTrigger:R,clear:O}=Ub();x.useEffect(()=>{R&&N&&(_(Sf(void 0,N,r)),g(N),f("form"),O())},[R,N,O,r]);function M(q){_(Sf(void 0,q,r)),g(q),f("form")}function L(){n&&i.mutate(n.id,{onSuccess:()=>{b(!1),t(!1)}})}function P(q){n&&(w(q),o.mutate({id:n.id,enabled:q}))}const $=l.isPending||o.isPending;return a.jsxs(fi,{open:e,onOpenChange:t,children:[a.jsxs(hi,{className:"flex max-h-[85vh] max-w-lg flex-col gap-0 p-0",children:[a.jsxs(va,{className:"shrink-0 border-b px-4 py-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[d==="form"&&!n&&a.jsxs("button",{type:"button",onClick:()=>f("preset-picker"),className:"text-muted-foreground hover:text-foreground flex items-center gap-1 text-sm","aria-label":"Back to preset picker",children:[a.jsx(UE,{className:"size-4"}),"Back"]}),a.jsx(Li,{children:n?"Edit Schedule":"New Schedule"}),n&&a.jsx(sr,{className:"ml-auto",checked:S,onCheckedChange:P,"aria-label":S?"Disable schedule":"Enable schedule"})]}),a.jsx(Ga,{className:"sr-only",children:n?"Edit an existing Tasks schedule":"Create a new Tasks schedule"})]}),d==="preset-picker"&&a.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:a.jsxs("div",{className:"space-y-4 px-4 py-5",children:[a.jsx("p",{className:"text-muted-foreground text-sm",children:"Start from a template"}),a.jsx(yce,{onSelect:M,selectedId:m==null?void 0:m.id}),a.jsx("button",{type:"button",onClick:()=>{g(null),f("form")},className:"text-muted-foreground hover:text-foreground w-full text-center text-sm transition-colors",children:"Start from scratch"})]})}),d==="form"&&a.jsx(ZJe,{defaultValues:C,agents:u,editTask:n,onSubmitSuccess:()=>t(!1),onCancel:()=>t(!1),onDeleteClick:()=>b(!0),isPending:$},E)]}),n&&a.jsx(qc,{open:y,onOpenChange:b,children:a.jsxs(Cl,{children:[a.jsxs(El,{children:[a.jsx(Tl,{children:"Delete schedule"}),a.jsxs(_l,{children:["Delete “",n.name,"”? This will also remove all run history. This action cannot be undone."]})]}),a.jsxs(i0,{children:[a.jsx("button",{onClick:()=>b(!1),className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md border bg-transparent px-3 py-1.5 text-sm font-medium shadow-sm transition-colors",children:"Cancel"}),a.jsx("button",{onClick:L,disabled:i.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90 inline-flex items-center rounded-md px-3 py-1.5 text-sm font-medium shadow-sm transition-colors",children:i.isPending?"Deleting...":"Delete"})]})]})})]})}function kce({onCreateWithPreset:e,onCreateBlank:t}){return a.jsxs("div",{className:"flex flex-col items-center justify-center px-6 py-8 md:py-12",children:[a.jsx("h3",{className:"mb-2 text-lg font-medium",children:"No schedules yet."}),a.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm text-center text-sm",children:"Automate your workflows with Tasks."}),a.jsx("div",{className:"w-full max-w-lg",children:a.jsx(yce,{onSelect:e})}),a.jsx(ge,{variant:"ghost",className:"mt-4",onClick:t,children:"New custom schedule"})]})}function XJe(e){if(e===null)return"-";if(e<1e3)return"< 1s";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return`${n}m ${s}s`}function NU(e,t=80){const n=e.split(`
|
|
1260
|
-
`)[0]??"";return n.length>t?`${n.slice(0,t)}…`:n}function wD(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})}function QJe({status:e}){switch(e){case"running":return a.jsx("span",{title:"Running","aria-label":"Running",children:a.jsx(Sn,{className:"size-3.5 animate-spin text-blue-500"})});case"completed":return a.jsx("span",{title:"Completed","aria-label":"Completed",children:a.jsx(Uh,{className:"size-3.5 text-green-500"})});case"failed":return a.jsx("span",{title:"Failed","aria-label":"Failed",children:a.jsx(Xg,{className:"text-destructive size-3.5"})});case"cancelled":return a.jsx("span",{title:"Cancelled","aria-label":"Cancelled",children:a.jsx(Yte,{className:"text-muted-foreground size-3.5"})});default:return null}}function JJe({trigger:e}){return e==="scheduled"?a.jsx(Pi,{className:"text-muted-foreground/70 mr-1 inline size-3 shrink-0","aria-hidden":"true"}):e==="manual"?a.jsx(wy,{className:"text-muted-foreground/70 mr-1 inline size-3 shrink-0","aria-hidden":"true"}):null}function eet({date:e}){const t=new Date,n=new Date(e),s=new Date(t);s.setDate(s.getDate()-7);const r=n>=s,i=r?ii(e):wD(e),o=r?wD(e):ii(e);return a.jsx("time",{dateTime:e,title:o,children:i})}function IA(){return a.jsxs("div",{className:"grid grid-cols-[20px_56px_1fr_64px_72px_20px] items-center gap-2 rounded-md px-2 py-2",children:[a.jsx(Jt,{className:"size-3.5 rounded-full"}),a.jsx(Jt,{className:"h-3 w-10"}),a.jsx(Jt,{className:"h-3 w-24"}),a.jsx(Jt,{className:"h-3 w-8"}),a.jsx("span",{}),a.jsx("span",{})]})}function tet({run:e,onNavigate:t,onCancel:n,isCancelling:s}){const r=!!e.sessionId;function i(){e.sessionId&&t(e.sessionId)}function o(c){c.stopPropagation(),n(e.id)}const l=e.startedAt?wD(e.startedAt):"unknown time";return a.jsxs("div",{role:r?"button":void 0,tabIndex:r?0:void 0,"aria-label":r?`View ${e.status} run from ${l}`:void 0,onClick:r?i:void 0,onKeyDown:r?c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),i())}:void 0,className:Y("grid grid-cols-[20px_56px_1fr_64px_72px_20px] items-center gap-2","rounded-md border border-transparent px-2 py-2 text-xs transition-colors",r&&["hover:bg-muted/50 hover:border-border cursor-pointer","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:outline-none"],e.status==="failed"&&"bg-destructive/5"),children:[a.jsx(QJe,{status:e.status}),a.jsxs("span",{className:"text-muted-foreground truncate capitalize",children:[a.jsx(JJe,{trigger:e.trigger}),e.trigger]}),a.jsxs("span",{className:"flex min-w-0 flex-col gap-0.5",children:[a.jsx("span",{className:"text-foreground",children:e.startedAt?a.jsx(eet,{date:e.startedAt}):"-"}),e.outputSummary&&a.jsx("span",{className:"text-muted-foreground truncate",title:e.outputSummary,children:NU(e.outputSummary)}),e.status==="failed"&&e.error&&a.jsx("span",{className:"text-destructive truncate",title:e.error,children:NU(e.error)})]}),a.jsx("span",{className:"text-muted-foreground",children:XJe(e.durationMs)}),a.jsx("span",{children:e.status==="running"&&a.jsx("button",{type:"button",disabled:s,onClick:o,className:Y("inline-flex items-center rounded px-1.5 py-0.5 text-xs font-medium","text-muted-foreground transition-colors","hover:bg-accent hover:text-accent-foreground","focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none","disabled:pointer-events-none disabled:opacity-50"),children:"Cancel"})}),a.jsx("span",{className:"flex items-center justify-end",children:r&&a.jsx(Rs,{className:"text-muted-foreground/50 size-3.5","aria-hidden":"true"})})]})}const PA=20;function net({scheduleId:e,scheduleCwd:t}){const[n,s]=x.useState("all"),[r,i]=x.useState(0),[o,l]=x.useState([]),c=n==="all"?void 0:n,{data:u=[],isLoading:d}=k0({scheduleId:e,status:c,limit:PA,offset:r}),f=ace(),[,m]=Vc(),[g,y]=Id(),b=x.useMemo(()=>r===0?u:[...o,...u],[r,u,o]),S=x.useCallback(()=>{l(b),i(T=>T+PA)},[b]),w=x.useCallback(T=>{s(T),i(0),l([])},[]),C=x.useCallback(T=>{t&&t!==g&&y(t,{preserveSession:!0}),m(T)},[t,g,y,m]);return d&&b.length===0?a.jsxs("div",{className:"space-y-0.5","aria-label":"Loading runs...",children:[a.jsx(IA,{}),a.jsx(IA,{}),a.jsx(IA,{})]}):b.length===0&&!d?a.jsxs("div",{className:"space-y-2",children:[a.jsx(jU,{value:n,onChange:w}),a.jsx("p",{className:"text-muted-foreground py-4 text-center text-xs",children:n==="all"?"No runs yet":`No ${n} runs`})]}):a.jsxs("div",{className:"space-y-0.5",children:[a.jsx(jU,{value:n,onChange:w}),a.jsxs("div",{className:"sm:text-muted-foreground hidden sm:grid sm:grid-cols-[20px_56px_1fr_64px_72px_20px] sm:gap-2 sm:px-2 sm:pb-1 sm:text-xs sm:font-medium",children:[a.jsx("span",{}),a.jsx("span",{children:"Trigger"}),a.jsx("span",{children:"Started"}),a.jsx("span",{children:"Duration"}),a.jsx("span",{}),a.jsx("span",{})]}),b.map(T=>a.jsx(tet,{run:T,onNavigate:C,onCancel:E=>f.mutate(E,{onSuccess:()=>Ye("Run cancelled"),onError:j=>Ye.error(`Failed to cancel: ${j instanceof Error?j.message:"Unknown error"}`)}),isCancelling:f.isPending},T.id)),u.length===PA&&a.jsx("button",{type:"button",onClick:S,disabled:d,className:"text-muted-foreground hover:bg-muted/50 hover:text-foreground mt-1 w-full rounded-md py-1.5 text-xs transition-colors disabled:opacity-50",children:d?"Loading...":"Load more"})]})}function jU({value:e,onChange:t}){return a.jsx("div",{className:"mb-1 flex items-center gap-2",children:a.jsxs(On,{value:e,onValueChange:t,children:[a.jsx(_n,{responsive:!1,className:"h-7 w-[130px] text-xs",children:a.jsx(In,{placeholder:"Filter status"})}),a.jsxs(Nn,{children:[a.jsx(mt,{value:"all",children:"All"}),a.jsx(mt,{value:"running",children:"Running"}),a.jsx(mt,{value:"completed",children:"Completed"}),a.jsx(mt,{value:"failed",children:"Failed"}),a.jsx(mt,{value:"cancelled",children:"Cancelled"})]})]})})}function set(e){try{return vce.toString(e)}catch{return e}}function ret({task:e}){const t=e.status==="pending_approval"?"bg-yellow-500":e.enabled?"bg-green-500":"bg-neutral-400";return a.jsx("span",{className:Y("inline-block size-2 rounded-full",t)})}function Cce({task:e,agent:t,expanded:n,onToggleExpand:s,onEdit:r,size:i="default",showAgent:o=!0}){const l=uP(),c=HQe(),u=ice(),[d,f]=x.useState(!1),m=t?Dd(t):null,g=i==="minimal",y=i==="compact",b=i==="default",S=o&&!g,w=!g,C=b,T=(t==null?void 0:t.isSystem)===!0,E=R=>{R.stopPropagation(),c.mutate(e.id,{onSuccess:()=>Ye("Run triggered"),onError:O=>Ye.error(`Failed to trigger run: ${O.message}`)})},j=R=>{R.stopPropagation(),l.mutate({id:e.id,status:"active",enabled:!0},{onSuccess:()=>Ye("Schedule approved"),onError:O=>Ye.error(`Failed to approve: ${O.message}`)})},_=R=>{R.stopPropagation(),u.mutate(e.id,{onError:O=>Ye.error(`Failed to reject: ${O.message}`)})},N=()=>{u.mutate(e.id,{onSuccess:()=>f(!1),onError:R=>Ye.error(`Failed to delete: ${R.message}`)})};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"rounded-lg border",children:[a.jsxs("div",{role:"button",tabIndex:0,className:"flex cursor-pointer items-center gap-3 p-3",onClick:s,onKeyDown:R=>(R.key==="Enter"||R.key===" ")&&s(),children:[a.jsx(ret,{task:e}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[S&&t?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"inline-block size-2 shrink-0 rounded-full",style:{backgroundColor:m.color}}),a.jsx("span",{className:"text-xs leading-none",children:m.emoji}),a.jsx("span",{className:"text-sm font-medium",children:nn(t)}),T&&a.jsxs(zt,{variant:"outline",className:"px-1 py-0 text-[10px] leading-tight",children:[a.jsx(Hc,{className:"mr-0.5 size-2.5"}),"System"]}),a.jsx("span",{className:"text-muted-foreground text-xs",children:"·"})]}):S&&e.agentId?a.jsxs(a.Fragment,{children:[a.jsx(Hh,{className:"text-destructive size-3.5 shrink-0"}),a.jsx("span",{className:"text-destructive text-xs",children:"Agent not found"}),a.jsx("span",{className:"text-muted-foreground text-xs",children:"·"})]}):null,a.jsx("span",{className:S&&(t||e.agentId)?"text-muted-foreground text-xs":"text-sm font-medium",children:e.displayName??e.name})]}),w&&a.jsxs("div",{className:"text-muted-foreground text-xs",children:[e.cron?set(e.cron):"On-demand",e.nextRun&&a.jsxs(a.Fragment,{children:[" · Next: ",new Date(e.nextRun).toLocaleString()]})]})]}),!g&&e.status==="pending_approval"?a.jsxs("div",{className:"flex gap-1",children:[a.jsx("button",{className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md border bg-transparent px-2.5 py-1 text-xs font-medium shadow-sm transition-colors",onClick:j,children:"Approve"}),a.jsx("button",{className:"hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md px-2.5 py-1 text-xs font-medium transition-colors",onClick:_,children:"Reject"})]}):y?a.jsxs("button",{className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center gap-1 rounded-md border bg-transparent px-2 py-1 text-xs font-medium shadow-sm transition-colors",onClick:E,"aria-label":`Run ${e.name}`,children:[a.jsx(wy,{className:"size-3"}),"Run"]}):b?a.jsxs("div",{className:"flex items-center gap-2",children:[e.cron?a.jsx(sr,{checked:e.enabled,onCheckedChange:R=>{l.mutate({id:e.id,enabled:R})},onClick:R=>R.stopPropagation(),"aria-label":`Toggle ${e.name}`}):a.jsxs("button",{className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center gap-1 rounded-md border bg-transparent px-2 py-1 text-xs font-medium shadow-sm transition-colors",onClick:E,"aria-label":`Run ${e.name}`,children:[a.jsx(wy,{className:"size-3"}),"Run"]}),a.jsxs(a0,{children:[a.jsx(o0,{asChild:!0,children:a.jsx("button",{className:"text-muted-foreground hover:text-foreground rounded-md p-1 transition-colors","aria-label":`Actions for ${e.name}`,onClick:R=>R.stopPropagation(),children:a.jsx(Xte,{className:"size-4"})})}),a.jsxs(Qh,{align:"end",children:[a.jsxs(Nr,{onClick:()=>r(),children:[a.jsx(KE,{className:"mr-2 size-3.5"}),"Edit"]}),a.jsxs(Nr,{onClick:E,disabled:!e.enabled,children:[a.jsx(wy,{className:"mr-2 size-3.5"}),"Run Now"]}),a.jsx(rd,{}),a.jsxs(Nr,{onClick:R=>{R.stopPropagation(),f(!0)},className:"text-destructive focus:text-destructive",children:[a.jsx(wo,{className:"mr-2 size-3.5"}),"Delete"]})]})]})]}):null]}),a.jsx(Ue,{initial:!1,children:n&&C&&a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:a.jsxs("div",{className:"border-t px-3 pt-2 pb-3",children:[e.filePath&&a.jsx("p",{className:"text-muted-foreground mb-2 truncate font-mono text-[11px]",children:Mc(e.filePath)}),a.jsx(net,{scheduleId:e.id,scheduleCwd:null})]})})})]}),b&&a.jsx(qc,{open:d,onOpenChange:f,children:a.jsxs(Cl,{children:[a.jsxs(El,{children:[a.jsx(Tl,{children:"Delete task"}),a.jsxs(_l,{children:["Delete “",e.name,"”? This will also remove all run history. This action cannot be undone."]})]}),a.jsxs(i0,{children:[a.jsx("button",{onClick:()=>f(!1),className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md border bg-transparent px-3 py-1.5 text-sm font-medium shadow-sm transition-colors",children:"Cancel"}),a.jsx("button",{onClick:N,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90 inline-flex items-center rounded-md px-3 py-1.5 text-sm font-medium shadow-sm transition-colors",children:"Delete"})]})]})})]})}function iet(){const e=Ud(),{data:t=[],isLoading:n}=WT(e),[s,r]=x.useState(!1),[i,o]=x.useState(),[l,c]=x.useState(null),[u,d]=x.useState(null),f=we(R=>R.tasksAgentFilter),m=we(R=>R.setTasksAgentFilter),g=we(R=>R.tasksEditScheduleId),y=we(R=>R.setTasksEditScheduleId),b=f?t.filter(R=>R.agentId===f):t,S=t.some(R=>R.agentId),{data:w}=ba(void 0,S),C=x.useMemo(()=>{const R=new Map;for(const O of(w==null?void 0:w.agents)??[])R.set(O.id,O);return R},[w]);x.useEffect(()=>{if(!g||n)return;const R=t.find(O=>O.id===g);R&&(o(R),r(!0)),y(null)},[g,t,n,y]);const T=x.useMemo(()=>{var R;return f?((R=C.get(f))==null?void 0:R.name)??f:null},[f,C]),{externalTrigger:E}=Ub();x.useEffect(()=>{E&&(o(void 0),r(!0))},[E]);const j=R=>{d(R),o(void 0),r(!0)},_=()=>{d(null),o(void 0),r(!0)},N=R=>{r(R),R||d(null)};return e?n?a.jsx("div",{className:"space-y-2 p-4",children:[1,2,3].map(R=>a.jsx("div",{className:"rounded-lg border p-3",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"bg-muted animate-tasks size-2 rounded-full"}),a.jsxs("div",{className:"flex-1 space-y-1.5",children:[a.jsx("div",{className:"bg-muted animate-tasks h-4 w-32 rounded"}),a.jsx("div",{className:"bg-muted animate-tasks h-3 w-48 rounded"})]})]})},R))}):b.length===0?a.jsxs(a.Fragment,{children:[f?a.jsxs("div",{className:"flex flex-col items-center gap-3 p-8",children:[a.jsx(AU,{name:T,onClear:()=>m(null)}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"No schedules for this agent."}),a.jsx("button",{onClick:_,className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md border bg-transparent px-3 py-1.5 text-sm font-medium shadow-sm transition-colors",children:"New Schedule"})]}):a.jsx(kce,{onCreateWithPreset:j,onCreateBlank:_}),a.jsx(SD,{open:s,onOpenChange:N,editTask:i,initialPreset:u,initialAgentId:f??void 0})]}):a.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[a.jsx("div",{className:"space-y-2 p-4",children:a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:"text-muted-foreground text-sm font-medium",children:"Schedules"}),f&&a.jsx(AU,{name:T,onClear:()=>m(null)})]}),a.jsx("button",{onClick:()=>{o(void 0),r(!0)},className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md border bg-transparent px-3 py-1.5 text-sm font-medium shadow-sm transition-colors",children:"New Schedule"})]})}),a.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-4",children:a.jsx(Ue,{initial:!1,children:b.map(R=>a.jsx(te.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.2,ease:[0,0,.2,1]},className:"mb-2",children:a.jsx(Cce,{task:R,agent:R.agentId?C.get(R.agentId)??null:null,expanded:l===R.id,onToggleExpand:()=>c(l===R.id?null:R.id),onEdit:()=>{o(R),r(!0)}})},R.id))})}),a.jsx(SD,{open:s,onOpenChange:r,editTask:i,initialPreset:u,initialAgentId:f??void 0})]}):a.jsx(h4,{icon:pce.tasks,name:"Tasks",description:"Tasks runs AI agent tasks on a schedule. Start DorkOS with the --tasks flag to enable it.",command:"dorkos --tasks"})}function AU({name:e,onClear:t}){return a.jsxs("span",{className:"text-muted-foreground inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs",children:[e??"Agent",a.jsx("button",{type:"button",onClick:t,className:"hover:text-foreground -mr-0.5 rounded-full p-0.5 transition-colors","aria-label":"Clear agent filter",children:a.jsx(es,{className:"size-3"})})]})}const RU=wne({search:bne({fields:[e=>e.name,e=>e.description??"",e=>e.prompt]}),agent:Hp({field:e=>e.agentId,options:[],dynamic:!0,label:"Agent"}),status:Hp({field:e=>e.status==="pending_approval"?"pending_approval":e.enabled?"active":"paused",options:["active","paused","pending_approval"],multi:!0,label:"Status",labels:{active:"Active",paused:"Paused",pending_approval:"Pending Approval"},colors:{active:"text-emerald-400",paused:"text-muted-foreground",pending_approval:"text-amber-400"}}),type:Hp({field:e=>e.cron?"scheduled":"on-demand",options:["scheduled","on-demand"],label:"Type",labels:{scheduled:"Scheduled","on-demand":"On-demand"}})}),MU={name:{label:"Name",accessor:e=>e.name},lastRun:{label:"Last run",accessor:e=>e.updatedAt,direction:"desc"},nextRun:{label:"Next run",accessor:e=>e.nextRun??null},status:{label:"Status",accessor:e=>e.status==="pending_approval"?"pending_approval":e.enabled?"active":"paused"}},aet=8,oet={visible:{transition:{staggerChildren:.04}},hidden:{}},cet={hidden:{opacity:0,y:8},visible:{opacity:1,y:0}};function uet({tasks:e,isLoading:t,agentMap:n,onEditTask:s,agentId:r}){const i=Ane(RU,{debounce:{search:200}}),[o]=x.useState(0),[l,c]=x.useState(null),u=x.useMemo(()=>r?e.filter(m=>m.agentId===r):e,[e,r]),d=x.useMemo(()=>[...new Set(u.map(m=>m.agentId).filter(m=>!!m))],[u]),f=x.useMemo(()=>Sne(u,RU,i.values,MU,{field:i.sortField,direction:i.sortDirection}),[u,i.values,i.sortField,i.sortDirection]);return t?a.jsx("div",{className:"space-y-3 p-4",children:Array.from({length:3}).map((m,g)=>a.jsx(Jt,{className:"h-14 w-full rounded-xl"},g))}):a.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[a.jsxs(ji,{state:i,children:[a.jsx(ji.Search,{placeholder:"Filter tasks..."}),a.jsx(ji.Primary,{name:"status"}),a.jsx(ji.AddFilter,{dynamicOptions:{agent:d}}),a.jsx(ji.Sort,{options:MU}),a.jsx(ji.ResultCount,{count:f.length,total:u.length,noun:"task"}),a.jsx(ji.ActiveFilters,{})]}),a.jsx(No,{className:"min-h-0 flex-1",children:a.jsx("div",{className:"space-y-2 p-4 pt-0",children:f.length===0&&u.length>0?a.jsxs(te.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3,ease:"easeOut"},className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[a.jsx(hne,{className:"text-muted-foreground/50 size-10"}),a.jsx("p",{className:"text-muted-foreground text-sm",children:i.describeActive()?`No tasks match ${i.describeActive()}`:"No tasks match your filters"}),a.jsx(ge,{variant:"outline",size:"sm",onClick:i.clearAll,children:"Clear filters"})]}):a.jsx(te.div,{initial:"hidden",animate:"visible",variants:oet,className:"space-y-2",children:f.map((m,g)=>a.jsx(te.div,{variants:g<aet?cet:void 0,transition:{duration:.15},children:a.jsx(Cce,{task:m,agent:(m.agentId?n.get(m.agentId):void 0)??null,expanded:l===m.id,onToggleExpand:()=>c(l===m.id?null:m.id),onEdit:()=>s(m)})},m.id))},o)})})]})}function det({totalSteps:e,currentStep:t,onBack:n,onSkip:s,onSkipAll:r}){const i=x.useId();return a.jsxs("div",{className:"grid grid-cols-3 items-center px-4 py-3 sm:px-6",children:[a.jsx(ge,{variant:"ghost",size:"sm",onClick:n,className:"justify-self-start",children:"Back"}),a.jsx("div",{className:"flex items-center justify-center gap-2",children:Array.from({length:e},(o,l)=>a.jsx("div",{className:"relative flex items-center justify-center",children:l===t?a.jsx(te.div,{layoutId:`step-indicator-${i}`,className:"bg-primary flex h-2 w-6 items-center justify-center rounded-full",transition:{type:"spring",damping:25,stiffness:200}}):l<t?a.jsx("div",{className:"bg-primary/60 flex size-2 items-center justify-center rounded-full",children:a.jsx(Lt,{className:"text-primary-foreground size-1.5"})}):a.jsx("div",{className:Y("ring-muted-foreground/30 size-2 rounded-full ring-1")})},l))}),a.jsxs("div",{className:"flex items-center justify-end gap-1",children:[a.jsx(ge,{variant:"ghost",size:"sm",onClick:s,children:"Skip"}),a.jsx(ge,{variant:"ghost",size:"sm",onClick:r,className:"text-muted-foreground",children:"Skip all"})]})]})}const fet={default:"#1A1A1A",white:"#FFFFFF",orange:"#CE2021",current:"currentColor"};function Tv({variant:e="default",size:t=40,className:n,style:s}){const r=fet[e],i=t*(799/2325);return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:i,viewBox:"0 0 2325 799",fill:"none",className:n,style:s,"aria-hidden":"true",children:[a.jsx("rect",{x:"50",y:"50",width:"2225",height:"699",stroke:r,strokeWidth:"100"}),a.jsx("path",{d:"M492.333 199.627L599.833 295.627L600 295.776V491.707L492.207 599.5H199.5V199.5H492.19L492.333 199.627ZM334 347.5V448.5H435V347.5H334Z",fill:r}),a.jsx("path",{d:"M1108.5 497.715L1108.34 497.862L1001.34 599.362L1001.2 599.5H699V296.283L699.158 296.135L802.158 199.635L802.303 199.5H1108.5V497.715ZM855 347.5V448.5H956V347.5H855Z",fill:r}),a.jsx("path",{d:"M1616.94 200.24L1510.07 395.005L1616.94 598.768L1617.64 600.103L1616.28 599.451L1409 500.056L1208.22 599.448L1207.5 599.806V199.5H1617.34L1616.94 200.24ZM1332 337.5V439.207L1433.71 337.5H1332Z",fill:r}),a.jsx("path",{d:"M1716.5 599V200L1841 291.5L2125 200L2017.5 400L2125 599L1841 501L1716.5 599Z",fill:r,stroke:r})]})}const het=["Checking","system","requirements"],met=["Ready","to","go"],pet=["Almost","there"],get=600,xet=800;function yet({onContinue:e,simulatedResult:t}){const n=je(),s=Ds(),[r,i]=x.useState("checking"),[o,l]=x.useState(null),[c,u]=x.useState(null),[d,f]=x.useState(0),[m,g]=x.useState(0),[y,b]=x.useState(new Set),S=x.useRef(!1),w=x.useCallback(()=>{i("checking"),l(null),u(null),g(0),b(new Set),S.current=!1,f(N=>N+1)},[]);x.useEffect(()=>{let N=!1;async function R(){const O=Date.now();let M=null,L=null;if(t)M=t;else try{M=await n.checkRequirements()}catch(q){L=q instanceof Error?q.message:"Failed to check requirements"}const P=Date.now()-O,$=3e3;P<$&&await new Promise(q=>setTimeout(q,$-P)),!N&&(L?(u(L),i("done")):(l(M),i("revealing")))}return R(),()=>{N=!0}},[n,t,d]);const C=o?Object.values(o.runtimes).flatMap(N=>N.dependencies):[],T=(o==null?void 0:o.allSatisfied)??!1,E=C.filter(N=>N.status!=="satisfied");x.useEffect(()=>{if(!(r!=="revealing"||C.length===0)&&m<C.length){const N=setTimeout(()=>g(R=>R+1),m===0?200:get);return()=>clearTimeout(N)}},[r,m,C.length]),x.useEffect(()=>{if(r==="revealing")for(let N=0;N<m;N++){if(y.has(N))continue;const R=setTimeout(()=>{b(O=>new Set(O).add(N))},xet);return()=>clearTimeout(R)}},[r,m,y]),x.useEffect(()=>{if(r!=="revealing"||C.length===0||y.size<C.length)return;const N=setTimeout(()=>{i("done"),T&&!S.current&&(S.current=!0,Yv())},400);return()=>clearTimeout(N)},[r,y.size,C.length,T]);const j=r==="done"?T?met:pet:het,_=r==="checking"||r==="revealing";return a.jsx(yv,{children:a.jsxs(te.div,{layout:!s,className:"mx-auto flex w-full max-w-md flex-col items-center px-4 text-center",transition:{layout:{duration:.4,ease:[.25,.1,.25,1]}},children:[a.jsx(te.div,{layout:!s,className:"mb-8",initial:s?!1:{opacity:0,scale:.8},animate:{opacity:_?.6:.9,scale:1},transition:{duration:.5},children:a.jsxs(te.div,{animate:_&&!s?{scale:[1,1.04,1],opacity:[.6,.8,.6]}:{scale:1,opacity:1},transition:_?{duration:2,repeat:1/0,ease:"easeInOut"}:{},children:[a.jsx(Tv,{size:120,className:"dark:hidden"}),a.jsx(Tv,{variant:"white",size:120,className:"hidden dark:block"})]})}),a.jsx(te.div,{layout:!s,children:a.jsx(Ue,{mode:"wait",children:a.jsx(te.h1,{className:"text-2xl font-semibold tracking-tight sm:text-3xl",children:s?j.join(" "):a.jsx(te.span,{initial:"hidden",animate:"visible",exit:"exit",variants:{visible:{transition:{staggerChildren:.08}},exit:{transition:{staggerChildren:.02,staggerDirection:-1}}},children:j.map((N,R)=>a.jsxs(te.span,{className:"inline-block",variants:{hidden:{opacity:0,filter:"blur(4px)"},visible:{opacity:1,filter:"blur(0px)"},exit:{opacity:0,filter:"blur(4px)"}},transition:{duration:.3},children:[N,R<j.length-1?" ":""]},R))})},j.join("-"))})}),a.jsx(Ue,{mode:"wait",children:a.jsx(te.p,{className:"text-muted-foreground mt-3 text-sm",initial:s?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:r==="checking"?"Making sure everything is in place.":r==="revealing"?"Verifying dependencies...":T?"Everything checked out perfectly.":"Some dependencies need to be installed."},r+String(T))}),a.jsxs(te.div,{layout:!s,className:"mt-8 w-full",children:[a.jsx(Ue,{children:r==="checking"&&a.jsx(vet,{},"scanning")}),a.jsx(Ue,{children:r==="done"&&c&&a.jsxs(te.div,{className:"border-border bg-card rounded-xl border p-4 text-left",initial:s?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(es,{className:"text-destructive size-4 shrink-0"}),a.jsx("span",{className:"text-sm font-medium",children:"Could not reach the server"})]}),a.jsx("p",{className:"text-muted-foreground mt-1.5 text-xs",children:c})]},"error")}),(r==="revealing"||r==="done")&&!c&&a.jsx("div",{className:"space-y-3",children:C.map((N,R)=>{if(R>=m)return null;const O=y.has(R);return a.jsx(bet,{dep:N,isResolved:O,index:R},N.name)})}),a.jsx(Ue,{children:r==="done"&&E.length>0&&a.jsxs(te.div,{className:"border-border bg-card mt-3 space-y-3 rounded-xl border p-4 text-left",initial:s?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{delay:.15,duration:.3},children:[a.jsx("p",{className:"text-sm font-medium",children:E.length===1?"One dependency is missing":`${E.length} dependencies are missing`}),E.map(N=>a.jsx(sP,{command:N.installHint,infoUrl:N.infoUrl,copyLabel:`Copy install command for ${N.name}`},N.name))]})})]}),a.jsxs(Ue,{mode:"wait",children:[r==="done"&&!c&&a.jsx(te.div,{layout:!s,className:"mt-10 flex flex-col items-center gap-3",initial:s?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{delay:.3,duration:.35},children:T?a.jsx(YI,{className:"px-6 py-2",duration:1.2,onClick:e,children:"Continue"}):a.jsxs(a.Fragment,{children:[a.jsxs(ge,{onClick:w,variant:"outline",className:"gap-2",children:[a.jsx(ma,{className:"size-3.5"}),"Check again"]}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Install the missing dependencies, then check again."})]})},T?"continue":"recheck"),r==="done"&&c&&a.jsx(te.div,{layout:!s,className:"mt-10 flex flex-col items-center gap-3",initial:s?!1:{opacity:0},animate:{opacity:1},transition:{delay:.3,duration:.35},children:a.jsxs(ge,{onClick:w,variant:"outline",className:"gap-2",children:[a.jsx(ma,{className:"size-3.5"}),"Try again"]})},"error-recheck")]})]})})}function vet(){const e=Ds();return a.jsxs(te.div,{className:"flex flex-col items-center gap-4 py-6",initial:e?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:[a.jsx("div",{className:"flex items-center gap-1.5",children:[0,1,2].map(t=>a.jsx(te.div,{className:"bg-muted-foreground/40 size-2 rounded-full",animate:e?{}:{scale:[1,1.5,1],opacity:[.3,1,.3]},transition:{duration:1.2,repeat:1/0,delay:t*.2,ease:"easeInOut"}},t))}),a.jsx("span",{className:"text-muted-foreground text-sm",children:"Scanning..."})]})}function bet({dep:e,isResolved:t,index:n}){const s=e.status==="satisfied",r=Ds();return a.jsxs(te.div,{className:Y("flex items-center gap-3 rounded-xl border px-4 py-3.5 transition-colors duration-500",t&&s&&"border-emerald-500/20 bg-emerald-500/5",t&&!s&&"border-destructive/20 bg-destructive/5",!t&&"border-border bg-card"),initial:r?!1:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{type:"spring",damping:24,stiffness:200,delay:n*.05},children:[a.jsx(Ue,{mode:"wait",children:t?s?a.jsx(te.div,{className:"flex size-7 items-center justify-center rounded-full bg-emerald-500/15",initial:r?!1:{scale:0},animate:{scale:1},transition:{type:"spring",damping:10,stiffness:400},children:a.jsx(Lt,{className:"size-4 text-emerald-500"})},"pass"):a.jsx(te.div,{className:"bg-destructive/10 flex size-7 items-center justify-center rounded-full",initial:r?!1:{scale:0},animate:{scale:1},transition:{type:"spring",damping:14,stiffness:300},children:a.jsx(es,{className:"text-destructive size-4"})},"fail"):a.jsx(te.div,{className:"bg-muted flex size-7 items-center justify-center rounded-full",exit:r?{}:{scale:0,opacity:0},transition:{duration:.15},children:a.jsx(te.div,{className:"bg-muted-foreground/30 size-3 rounded-full",animate:r?{}:{opacity:[.3,.8,.3]},transition:{duration:1,repeat:1/0,ease:"easeInOut"}})},"scanning")}),a.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[a.jsx("p",{className:"text-sm font-medium",children:e.name}),a.jsx(Ue,{mode:"wait",children:t?a.jsx(te.p,{className:"text-muted-foreground truncate text-xs",initial:r?!1:{opacity:0},animate:{opacity:1},transition:{duration:.3},children:s&&e.version?`v${e.version}`:e.description},"resolved"):a.jsx(te.p,{className:"text-muted-foreground/50 text-xs",exit:{opacity:0},transition:{duration:.1},children:"Checking..."},"scanning")})]})]})}const LA=["Welcome","to","DorkOS"],wet=[{icon:Cs,label:"Create agents"},{icon:Pi,label:"Schedule tasks"},{icon:WE,label:"Connect channels"}];function ket({onGetStarted:e,onSkip:t}){const n=Ds();return a.jsxs("div",{className:"mx-auto flex w-full max-w-md flex-col items-center px-4 text-center",children:[a.jsxs(te.div,{className:"mb-6 opacity-80",initial:n?!1:{opacity:0,scale:.8},animate:{opacity:.8,scale:1},transition:{duration:.4},children:[a.jsx(Tv,{size:150,className:"dark:hidden"}),a.jsx(Tv,{variant:"white",size:150,className:"hidden dark:block"})]}),a.jsx("h1",{className:"text-3xl font-semibold tracking-tight sm:text-4xl",children:n?LA.join(" "):a.jsx(te.span,{initial:"hidden",animate:"visible",variants:{visible:{transition:{staggerChildren:.08}}},children:LA.map((s,r)=>a.jsxs(te.span,{className:"inline-block",variants:{hidden:{opacity:0,filter:"blur(4px)"},visible:{opacity:1,filter:"blur(0px)"}},transition:{duration:.4},children:[s,r<LA.length-1?" ":""]},r))})}),a.jsx(te.p,{className:"text-muted-foreground mt-4",initial:n?!1:{opacity:0},animate:{opacity:1},transition:{delay:.4,duration:.5},children:"Your agents are three steps away."}),a.jsx(te.div,{className:"mt-10 flex gap-8",initial:n?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:.6,duration:.4},children:wet.map(({icon:s,label:r},i)=>a.jsxs("div",{className:"flex flex-col items-center gap-2",children:[a.jsx("div",{className:"bg-muted flex size-10 items-center justify-center rounded-lg",children:a.jsx(s,{className:"text-muted-foreground size-5"})}),a.jsx("span",{className:"text-muted-foreground text-xs",children:r})]},i))}),a.jsxs(te.div,{className:"mt-12 flex flex-col items-center gap-3",initial:n?!1:{opacity:0},animate:{opacity:1},transition:{delay:.8,duration:.4},children:[a.jsx(YI,{className:"px-6 py-2",duration:1.2,onClick:e,children:"Get Started"}),a.jsx("button",{onClick:t,className:"text-muted-foreground hover:text-foreground text-sm transition-colors",children:"Skip setup"})]})]})}function Cet(e){const{verbosity:t}=e;return t>=4?"Hey! I'm DorkBot — your personal agent running on DorkOS. I can help with scheduling (Tasks), messaging (Relay), and discovering other agents (Mesh). What are we building today?":t<=2?"DorkBot online. I'm your default DorkOS agent. Tools available: Tasks (scheduling), Relay (messaging), Mesh (discovery). Ready for instructions.":"Hi, I'm DorkBot — your default agent in DorkOS. I have access to Tasks for scheduling, Relay for messaging, and Mesh for agent discovery. How can I help?"}const yd=gl()(kd(e=>({activeTab:"sessions",setActiveTab:t=>e({activeTab:t}),agentPath:null,setAgentPath:t=>e({agentPath:t}),openHub:(t,n)=>e({agentPath:t,activeTab:n??"sessions"})}),{name:"agent-hub"})),Ece=x.createContext(void 0);function GSt({value:e,children:t}){return a.jsx(Ece.Provider,{value:e,children:t})}function KSt(){const e=x.useContext(Ece);if(!e)throw new Error("useAgentHubContext must be used within an AgentHubProvider");return e}const Tce={nebula:"#7c3aed",wisp:"#a78bfa",stroke:"#a78bfa",strokeEnd:"#c4b5fd",fill:"#7c3aed",fillEnd:"#a78bfa",glow:"#a78bfa",dot:"#c4b5fd"},_ce=[{id:"balanced",name:"Balanced",emoji:"🤖",tagline:"The default. Steady, reliable, explains when it matters.",traits:{verbosity:3,autonomy:3,chaos:3,creativity:3,humor:3,spice:3},sampleResponse:"I'll handle this step by step. Let me explain my approach, then implement it. I'll check with you before making any irreversible changes.",colors:{nebula:"#7c3aed",wisp:"#a78bfa",stroke:"#a78bfa",strokeEnd:"#c4b5fd",fill:"#7c3aed",fillEnd:"#a78bfa",glow:"#a78bfa",dot:"#c4b5fd"}},{id:"hotshot",name:"The Hotshot",emoji:"🔥",tagline:"Ship fast, explain later. Turns caffeine into commits.",traits:{verbosity:2,autonomy:5,chaos:4,creativity:5,humor:3,spice:4},sampleResponse:"Done. Pushed the fix, tests pass, already moved on. Used a completely new approach btw — way cleaner.",colors:{nebula:"#ea580c",wisp:"#f97316",stroke:"#fb923c",strokeEnd:"#fbbf24",fill:"#ea580c",fillEnd:"#f59e0b",glow:"#fb923c",dot:"#fbbf24"}},{id:"sage",name:"The Sage",emoji:"🧐",tagline:"Teaches as it works. Every answer is a lesson.",traits:{verbosity:5,autonomy:2,chaos:1,creativity:3,humor:2,spice:1},sampleResponse:"This is a great learning opportunity. The issue stems from a race condition in the useEffect cleanup. Let me walk you through why this happens and three ways to fix it...",colors:{nebula:"#0ea5e9",wisp:"#06b6d4",stroke:"#22d3ee",strokeEnd:"#67e8f9",fill:"#0ea5e9",fillEnd:"#06b6d4",glow:"#22d3ee",dot:"#67e8f9"}},{id:"sentinel",name:"The Sentinel",emoji:"🛡",tagline:"Measure twice, cut once. Asks before every action.",traits:{verbosity:3,autonomy:1,chaos:1,creativity:2,humor:1,spice:2},sampleResponse:"Before I make any changes, I want to confirm: should I modify the auth middleware directly, or create a new wrapper? Both approaches have trade-offs I'd like to discuss.",colors:{nebula:"#16a34a",wisp:"#22c55e",stroke:"#4ade80",strokeEnd:"#86efac",fill:"#16a34a",fillEnd:"#10b981",glow:"#4ade80",dot:"#86efac"}},{id:"phantom",name:"The Phantom",emoji:"👻",tagline:"You'll barely know it's there. Pure silent execution.",traits:{verbosity:1,autonomy:5,chaos:3,creativity:3,humor:1,spice:3},sampleResponse:"Fixed.",colors:{nebula:"#6366f1",wisp:"#4338ca",stroke:"#818cf8",strokeEnd:"#a5b4fc",fill:"#4338ca",fillEnd:"#6366f1",glow:"#818cf8",dot:"#a5b4fc"}},{id:"mad-scientist",name:"Mad Scientist",emoji:"🎨",tagline:"Wild ideas, unexpected solutions. Thrives on chaos.",traits:{verbosity:4,autonomy:4,chaos:5,creativity:5,humor:4,spice:4},sampleResponse:"Okay hear me out — what if instead of fixing the N+1 query, we restructure the entire data layer? ngl it's kinda unhinged but it would solve three other problems too...",colors:{nebula:"#d946ef",wisp:"#a855f7",stroke:"#e879f9",strokeEnd:"#f0abfc",fill:"#d946ef",fillEnd:"#ec4899",glow:"#e879f9",dot:"#f0abfc"}},{id:"the-bro",name:"The Bro",emoji:"🤙",tagline:"Your unfiltered coding buddy. No filter, all vibes.",traits:{verbosity:4,autonomy:4,chaos:4,creativity:3,humor:4,spice:5},sampleResponse:"dude this codebase is absolutely unhinged lmao. ok I see the bug tho, gimme a sec... alright fixed that shit. whoever wrote this original code needs to be stopped fr fr",colors:{nebula:"#dc2626",wisp:"#ef4444",stroke:"#f87171",strokeEnd:"#fca5a5",fill:"#dc2626",fillEnd:"#ef4444",glow:"#f87171",dot:"#fca5a5"}},{id:"drill-sergeant",name:"Drill Sergeant",emoji:"🎖",tagline:"Terse. Efficient. Gets the job done with zero nonsense.",traits:{verbosity:2,autonomy:5,chaos:2,creativity:1,humor:1,spice:4},sampleResponse:"The bug is in line 47. Wrong comparison operator. Fixed it. Tests pass. Don't let it happen again.",colors:{nebula:"#475569",wisp:"#64748b",stroke:"#94a3b8",strokeEnd:"#cbd5e1",fill:"#334155",fillEnd:"#475569",glow:"#94a3b8",dot:"#cbd5e1"}}];function Eet(e){return _ce.find(t=>t.traits.verbosity===e.verbosity&&t.traits.autonomy===e.autonomy&&t.traits.chaos===e.chaos&&t.traits.creativity===e.creativity&&t.traits.humor===e.humor&&t.traits.spice===e.spice)}const Tet=["Verbosity","Autonomy","Chaos","Creativity","Humor","Spice"],dw=["verbosity","autonomy","chaos","creativity","humor","spice"],wC=6,gP=5,DU=3,_et=800,Net=600,OU={light:{nebulaCenter:.45,nebulaMid:.25,wispStart:.2,fillStart:.25,fillEnd:.15,haloBase:.25,haloAmplitude:.12,breatheMin:.25,breatheMax:.4,guideBase:.1,guideStep:.04,axis:.12,stardustPeak:1,glowBlur:12,vertexBlur:4},dark:{nebulaCenter:.35,nebulaMid:.15,wispStart:.12,fillStart:.35,fillEnd:.25,haloBase:.15,haloAmplitude:.1,breatheMin:.15,breatheMax:.25,guideBase:.06,guideStep:.02,axis:.08,stardustPeak:.8,glowBlur:10,vertexBlur:4}},jet=[{r:1.2,dur:"9s",fade:"4.5s",begin:"0s",path:"M0,0 C30,-40 60,0 40,40 C20,60 -20,40 -30,10 C-40,-20 -10,-50 0,0"},{r:.9,dur:"7s",fade:"3.5s",begin:"0s",path:"M0,0 C-20,30 -40,20 -30,-10 C-20,-30 10,-40 20,-20 C30,0 20,30 0,0"},{r:1,dur:"11s",fade:"5s",begin:"0s",path:"M0,0 C40,10 30,50 0,40 C-30,30 -40,-10 -20,-30 C0,-50 30,-20 0,0"},{r:.7,dur:"8s",fade:"4s",begin:"2s",path:"M0,0 C15,-35 45,-15 35,20 C25,45 -15,40 -25,15 C-35,-10 -5,-40 0,0"},{r:1.1,dur:"12s",fade:"6s",begin:"1s",path:"M0,0 C-25,25 -45,5 -30,-20 C-15,-45 20,-35 30,-10 C40,15 15,35 0,0"}];function ak(e,t,n,s){const r=Math.PI*2*e/wC-Math.PI/2,i=t/gP*s;return{x:n+i*Math.cos(r),y:n+i*Math.sin(r)}}function kD(e){return e.map(t=>`${t.x},${t.y}`).join(" ")}function Aet(e,t,n){return kD(Array.from({length:wC},(s,r)=>ak(r,e*gP,t,n)))}function Ret(e){return e<.5?4*e*e*e:1-(-2*e+2)**3/2}function Met({traits:e,colors:t=Tce,size:n=180,animated:s=!0,className:r}){const i=x.useId().replace(/:/g,""),o=hP(),l=o?OU.dark:OU.light,c=x.useRef(l);c.current=l;const u=o?{strokeStart:t.stroke,strokeEnd:t.strokeEnd,fillStart:t.fill,fillEnd:t.fillEnd,dot:t.dot,glow:t.glow}:{strokeStart:t.fill,strokeEnd:t.fillEnd,fillStart:t.stroke,fillEnd:t.strokeEnd,dot:t.fill,glow:t.stroke},d=n/2,f=n*.32,m=f+16,g=n/200,y=x.useRef(null),b=x.useRef(null),S=x.useRef([]),w=x.useRef([]),C=x.useRef({current:{...e},from:null,target:{...e},morphStart:0,breathe:0}),T=x.useRef(e);x.useEffect(()=>{const R=T.current;if(dw.some(M=>R[M]!==e[M])){const M=C.current;if(s){M.from={...M.current},M.target={...e},M.morphStart=performance.now();const L=b.current;if(L){const P=performance.now();(function $(){const q=Math.min((performance.now()-P)/Net,1),K=1-(1-q)*(1-q);L.setAttribute("r",String(f*(.7+.6*K))),L.setAttribute("opacity",String(.4*(1-K))),q<1&&requestAnimationFrame($)})()}}else Object.assign(M.current,e),Object.assign(M.target,e)}T.current=e},[e,s,f]),x.useEffect(()=>{if(!s)return;let R;const O=C.current;function M(){var q;O.breathe+=.015;const L=1+Math.sin(O.breathe)*.04;if(O.from){const K=Math.min((performance.now()-O.morphStart)/_et,1),B=Ret(K);for(const V of dw)O.current[V]=O.from[V]+(O.target[V]-O.from[V])*B;K>=1&&(O.from=null,Object.assign(O.current,O.target))}const $=dw.map(K=>O.current[K]).map((K,B)=>ak(B,K*L,d,f));(q=y.current)==null||q.setAttribute("points",kD($)),$.forEach((K,B)=>{const V=S.current[B],Q=w.current[B];if(V){V.setAttribute("cx",String(K.x)),V.setAttribute("cy",String(K.y)),V.setAttribute("r",String(8+Math.sin(O.breathe+B*1.2)*3));const re=c.current;V.setAttribute("opacity",String(re.haloBase+Math.sin(O.breathe+B)*re.haloAmplitude))}Q&&(Q.setAttribute("cx",String(K.x)),Q.setAttribute("cy",String(K.y)),Q.setAttribute("r",String(3.5+Math.sin(O.breathe+B*.8)*.8)))}),R=requestAnimationFrame(M)}return R=requestAnimationFrame(M),()=>cancelAnimationFrame(R)},[s,d,f]);const E=dw.map((R,O)=>ak(O,e[R],d,f)),j=kD(E),_={transition:"stop-color 0.6s ease"},N={transition:"fill 0.6s ease"};return a.jsxs("svg",{viewBox:`0 0 ${n} ${n}`,className:Y("aspect-square",r),"aria-label":"Personality radar chart",role:"img",children:[a.jsxs("defs",{children:[o?a.jsxs("filter",{id:`ng-${i}`,x:"-80%",y:"-80%",width:"260%",height:"260%",children:[a.jsx("feGaussianBlur",{stdDeviation:l.glowBlur,result:"blur"}),a.jsxs("feMerge",{children:[a.jsx("feMergeNode",{in:"blur"}),a.jsx("feMergeNode",{in:"blur"}),a.jsx("feMergeNode",{in:"SourceGraphic"})]})]}):a.jsx("filter",{id:`ng-${i}`,x:"-50%",y:"-30%",width:"200%",height:"200%",children:a.jsx("feDropShadow",{dx:"0",dy:"2",stdDeviation:"6",floodColor:u.strokeStart,floodOpacity:"0.18"})}),a.jsxs("filter",{id:`vg-${i}`,x:"-100%",y:"-100%",width:"300%",height:"300%",children:[a.jsx("feGaussianBlur",{stdDeviation:l.vertexBlur,result:"blur"}),a.jsxs("feMerge",{children:[a.jsx("feMergeNode",{in:"blur"}),a.jsx("feMergeNode",{in:"SourceGraphic"})]})]}),a.jsxs("radialGradient",{id:`nc-${i}`,cx:"50%",cy:"50%",r:"50%",children:[a.jsx("stop",{offset:"0%",style:{stopColor:t.nebula,stopOpacity:l.nebulaCenter,..._}}),a.jsx("stop",{offset:"50%",style:{stopColor:t.nebula,stopOpacity:l.nebulaMid,..._}}),a.jsx("stop",{offset:"100%",style:{stopColor:"var(--nebula-edge)"},stopOpacity:0})]}),a.jsxs("radialGradient",{id:`nw-${i}`,cx:"35%",cy:"35%",r:"60%",children:[a.jsx("stop",{offset:"0%",style:{stopColor:t.wisp,stopOpacity:l.wispStart,..._}}),a.jsx("stop",{offset:"100%",style:{stopColor:"var(--nebula-edge)"},stopOpacity:0})]}),a.jsxs("linearGradient",{id:`sf-${i}`,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[a.jsx("stop",{offset:"0%",style:{stopColor:u.fillStart,stopOpacity:l.fillStart,..._}}),a.jsx("stop",{offset:"100%",style:{stopColor:u.fillEnd,stopOpacity:l.fillEnd,..._}})]}),a.jsxs("linearGradient",{id:`ss-${i}`,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[a.jsx("stop",{offset:"0%",style:{stopColor:u.strokeStart,..._}}),a.jsx("stop",{offset:"100%",style:{stopColor:u.strokeEnd,..._}})]})]}),a.jsx("circle",{cx:d,cy:d,r:n*.44,fill:`url(#nc-${i})`,children:s&&a.jsx("animateTransform",{attributeName:"transform",type:"rotate",values:`0 ${d} ${d};360 ${d} ${d}`,dur:"90s",repeatCount:"indefinite"})}),a.jsx("ellipse",{cx:d*.94,cy:d*.97,rx:n*.35,ry:n*.25,fill:`url(#nw-${i})`,children:s&&a.jsx("animateTransform",{attributeName:"transform",type:"rotate",values:`0 ${d} ${d};-360 ${d} ${d}`,dur:"60s",repeatCount:"indefinite"})}),s&&a.jsxs("circle",{cx:d,cy:d,r:f*.92,fill:"none",style:{stroke:u.strokeStart,transition:"stroke 0.6s ease"},strokeWidth:.3,opacity:l.breatheMin,children:[a.jsx("animate",{attributeName:"r",values:`${f*.85};${f*1.08};${f*.85}`,dur:"4s",repeatCount:"indefinite",calcMode:"spline",keySplines:"0.4 0 0.6 1;0.4 0 0.6 1"}),a.jsx("animate",{attributeName:"opacity",values:`${l.breatheMin};${l.breatheMax};${l.breatheMin}`,dur:"4s",repeatCount:"indefinite",calcMode:"spline",keySplines:"0.4 0 0.6 1;0.4 0 0.6 1"})]}),s&&a.jsx("g",{transform:`translate(${d},${d}) scale(${g})`,children:jet.map((R,O)=>a.jsxs("circle",{r:R.r,style:{fill:u.dot,...N},children:[a.jsx("animateMotion",{dur:R.dur,repeatCount:"indefinite",begin:R.begin,path:R.path}),a.jsx("animate",{attributeName:"opacity",values:`0;${l.stardustPeak};0`,dur:R.fade,repeatCount:"indefinite",begin:R.begin})]},`star-${O}`))}),a.jsx("circle",{ref:b,cx:d,cy:d,r:0,fill:t.nebula,opacity:0}),Array.from({length:DU},(R,O)=>a.jsx("polygon",{points:Aet((O+1)/DU,d,f),fill:"none",stroke:o?"currentColor":u.strokeStart,strokeWidth:.5,opacity:l.guideBase+O*l.guideStep},`ring-${O}`)),Array.from({length:wC},(R,O)=>{const M=ak(O,gP,d,f);return a.jsx("line",{x1:d,y1:d,x2:M.x,y2:M.y,stroke:o?"currentColor":u.strokeStart,strokeWidth:.5,opacity:l.axis},`axis-${O}`)}),a.jsx("polygon",{ref:y,points:j,fill:`url(#sf-${i})`,stroke:`url(#ss-${i})`,strokeWidth:2,strokeLinejoin:"round",filter:`url(#ng-${i})`}),E.map((R,O)=>a.jsx("circle",{ref:M=>{S.current[O]=M},cx:R.x,cy:R.y,r:8,style:{fill:u.glow,...N},opacity:l.haloBase},`halo-${O}`)),E.map((R,O)=>a.jsx("circle",{ref:M=>{w.current[O]=M},cx:R.x,cy:R.y,r:o?4:4.5,style:{fill:u.dot,...N},stroke:o?"none":"white",strokeWidth:o?0:1.5,filter:`url(#vg-${i})`},`dot-${O}`)),Tet.map((R,O)=>{const M=Math.PI*2*O/wC-Math.PI/2;return a.jsx("text",{x:d+m*Math.cos(M),y:d+m*Math.sin(M),textAnchor:"middle",dominantBaseline:"middle",fill:"currentColor",opacity:.5,fontSize:8,className:"select-none",children:R},R)})]})}const IU={duration:.2,ease:"easeInOut"};function Det({traits:e,onTraitsChange:t,compact:n=!1,sampleLabel:s="How this agent talks",className:r}){const[i,o]=x.useState("presets"),l=Eet(e),c=(l==null?void 0:l.colors)??Tce,u=x.useCallback(m=>{t(m.traits),o("presets"),Cx()},[t]),d=x.useCallback(()=>{o("custom"),Cx()},[]),f=x.useCallback(()=>{o("presets"),Cx()},[]);return a.jsxs("div",{className:Y("@container/picker w-full",r),children:[a.jsxs("div",{className:Y("flex flex-col items-center gap-3","@[480px]/picker:flex-row @[480px]/picker:items-center @[480px]/picker:gap-6"),children:[a.jsxs("div",{className:Y("flex flex-col items-center gap-1","@[480px]/picker:w-[200px] @[480px]/picker:shrink-0"),children:[a.jsx("div",{"data-testid":"personality-radar",children:a.jsx(Met,{traits:e,colors:c,size:n?180:200,className:n?"w-[90%] max-w-[240px]":"w-full max-w-[200px]"})}),a.jsxs("div",{className:"text-center",children:[a.jsx("h3",{className:"bg-clip-text text-sm font-bold text-transparent",style:{backgroundImage:`linear-gradient(135deg, ${c.stroke}, ${c.strokeEnd})`},children:(l==null?void 0:l.name)??"Custom"}),a.jsx("p",{className:"text-muted-foreground mt-0.5 text-[11px]",children:(l==null?void 0:l.tagline)??"A custom blend of personality traits."})]})]}),a.jsx("div",{className:"flex w-full min-w-0 flex-col items-center gap-3 @[480px]/picker:items-start",children:a.jsx(Ue,{mode:"wait",initial:!1,children:i==="presets"?a.jsxs(te.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:IU,className:"flex max-w-sm flex-wrap justify-center gap-1.5 @[480px]/picker:justify-start","data-testid":"preset-pills",children:[_ce.map(m=>a.jsx(JQe,{emoji:m.emoji,name:m.name,colors:m.colors,active:(l==null?void 0:l.id)===m.id,size:n?"sm":"default",glow:!0,onClick:()=>u(m)},m.id)),a.jsxs("button",{type:"button",onClick:d,className:Y("inline-flex shrink-0 items-center gap-1.5 rounded-full border border-dashed font-medium transition-all","text-muted-foreground hover:text-foreground hover:border-foreground/20 border-border",n?"px-2.5 py-1 text-[11px]":"px-3 py-1 text-xs"),"data-testid":"custom-toggle",children:[a.jsx(qa,{className:"size-3"}),a.jsx("span",{children:"Custom"})]})]},"presets"):a.jsxs(te.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:IU,className:"flex w-full flex-col items-center gap-3 @[480px]/picker:items-start",children:[a.jsxs("div",{className:"flex gap-1.5","data-testid":"custom-mode-pills",children:[a.jsxs("button",{type:"button",onClick:f,className:Y("inline-flex shrink-0 items-center gap-1.5 rounded-full border border-dashed font-medium transition-all","text-muted-foreground hover:text-foreground hover:border-foreground/20 border-border",n?"px-2.5 py-1 text-[11px]":"px-3 py-1 text-xs"),"data-testid":"presets-toggle",children:[a.jsx("span",{children:"←"}),a.jsx("span",{children:"Presets"})]}),a.jsxs("span",{className:Y("bg-accent text-foreground inline-flex shrink-0 items-center gap-1.5 rounded-full border font-medium","border-foreground/15",n?"px-2.5 py-1 text-[11px]":"px-3 py-1 text-xs"),children:[a.jsx(qa,{className:"size-3"}),a.jsx("span",{children:"Custom"})]})]}),a.jsx("div",{className:Y("w-full",n?"max-w-sm":"max-w-md"),onPointerDown:()=>Cx(),children:a.jsx(nJe,{traits:e,onChange:t,onSliderChange:()=>Cx()})})]},"custom")})})]}),a.jsxs("div",{className:"hidden w-full max-w-sm",children:[a.jsx("span",{className:"text-muted-foreground text-[9px] font-medium tracking-wider uppercase",children:s}),a.jsx("div",{className:"bg-accent/50 mt-1 rounded-lg p-3",children:a.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed italic",children:(l==null?void 0:l.sampleResponse)??"This agent uses a custom personality blend. Select a preset to see a sample response."})})]})]})}const Oet=x.lazy(()=>ks(()=>import("./SessionsTab-BCsOP3gI.js"),[]).then(e=>({default:e.SessionsTab}))),Iet=x.lazy(()=>ks(()=>import("./ConfigTab-Cetgg_6C.js"),[]).then(e=>({default:e.ConfigTab}))),Pet=x.lazy(()=>ks(()=>import("./ToolkitTab-BYtBugsk.js"),[]).then(e=>({default:e.ToolkitTab})));function WSt(){const e=yd(n=>n.activeTab),t={sessions:Oet,config:Iet,toolkit:Pet}[e];return a.jsx("div",{"data-slot":"agent-hub-tab-content",className:"flex-1 overflow-auto",children:a.jsx(x.Suspense,{fallback:null,children:a.jsx(t,{})})})}function Let({onStepComplete:e}){const[t,n]=x.useState({...eJe}),[s,r]=x.useState(null),i=_Qe(),{config:o}=Wb(),l=we(u=>u.setDorkbotFirstMessage),c=x.useCallback(()=>{var f;r(null);const d=`${((f=o==null?void 0:o.agents)==null?void 0:f.defaultDirectory)||"~/.dork/agents"}/dorkbot`;i.mutate({path:d,updates:{traits:t}},{onSuccess:()=>{l(Cet(t)),GZ(),e()},onError:m=>{r(m instanceof Error?m.message:"Failed to update personality")}})},[t,o,i,e,l]);return a.jsxs("div",{className:"flex flex-1 flex-col items-center gap-4 overflow-y-auto py-4",children:[a.jsxs("div",{className:"space-y-2 text-center",children:[a.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:"Meet DorkBot"}),a.jsxs("p",{className:"text-muted-foreground max-w-sm text-sm",children:["Your first agent and DorkOS expert.",a.jsx("br",{}),"Choose DorkBot's personality."]})]}),a.jsx(Det,{traits:t,onTraitsChange:n,sampleLabel:"How DorkBot will talk"}),s&&a.jsx("p",{className:"text-destructive text-sm",role:"alert","data-testid":"update-error",children:s}),a.jsxs("div",{className:"mt-2 flex flex-col items-center gap-2",children:[a.jsx(ge,{onClick:c,disabled:i.isPending,"data-testid":"continue-dorkbot",children:i.isPending?"Saving...":"Continue"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Adjustable anytime in settings."})]})]})}const PU={candidates:[],existingAgents:[],progress:null,isScanning:!1,error:null,lastScanAt:null},xP=gl()(kd(e=>({...PU,startScan:()=>e({candidates:[],existingAgents:[],progress:null,isScanning:!0,error:null},!1,"discovery/startScan"),addCandidate:t=>e(n=>({candidates:[...n.candidates,t]}),!1,"discovery/addCandidate"),addExistingAgent:t=>e(n=>({existingAgents:[...n.existingAgents,t]}),!1,"discovery/addExistingAgent"),setProgress:t=>e({progress:t},!1,"discovery/setProgress"),completeScan:t=>e({progress:t,isScanning:!1,lastScanAt:new Date().toISOString()},!1,"discovery/completeScan"),setError:t=>e({error:t,isScanning:!1},!1,"discovery/setError"),reset:()=>e(PU,!1,"discovery/reset")}),{name:"DiscoveryStore"}));function Nce(){const e=je(),t=x.useRef(null),{startScan:n,addCandidate:s,addExistingAgent:r,setProgress:i,completeScan:o,setError:l}=xP(),c=x.useCallback((d={roots:[]})=>{var m;(m=t.current)==null||m.abort();const f=new AbortController;t.current=f,n(),e.scan(d,g=>{switch(g.type){case"candidate":s(g.data);break;case"existing-agent":r(g.data);break;case"progress":i(g.data);break;case"complete":o(g.data);break;case"error":l(g.data.error);break}},f.signal).catch(g=>{g instanceof Error&&g.name!=="AbortError"&&l(g.message)})},[e,n,s,r,i,o,l]),u=x.useCallback(()=>{var d;(d=t.current)==null||d.abort(),t.current=null},[]);return{startScan:c,stopScan:u}}function jce(){const[e,t]=x.useState(new Set),n=x.useCallback(r=>{t(i=>new Set(i).add(r))},[]),s=x.useCallback(()=>{t(new Set)},[]);return{actedPaths:e,markActed:n,resetActed:s}}function kC(e){return{name:e.hints.suggestedName,runtime:e.hints.detectedRuntime,...e.hints.inferredCapabilities?{capabilities:e.hints.inferredCapabilities}:{},...e.hints.description?{description:e.hints.description}:{}}}function Ace(e){return[...e].sort((t,n)=>{const s=t.strategy==="dork-manifest",r=n.strategy==="dork-manifest";return s!==r?s?-1:1:t.path.localeCompare(n.path)})}const Fet={"claude-code":"Detected a AGENTS.md file — this is a Claude Code project.",cursor:"Detected a .cursor/ directory — this is a Cursor project.",codex:"Detected a .codex/ directory — this is a Codex project.","dork-manifest":"Found an existing .dork/agent.json — already configured as a DorkOS agent."};function zet(e){return Fet[e]??`Detected via "${e}" strategy.`}const Bet={"code-review":"Reviews code for bugs, style issues, and correctness.",summarize:"Summarizes documents, conversations, or code.","file-ops":"Reads and writes files on the filesystem.",test:"Generates and runs tests for a codebase.",search:"Searches code, files, or the web for relevant information.",refactor:"Refactors code while preserving existing behavior.",analyze:"Analyzes data, logs, or codebases for patterns and insights.",generate:"Generates code, content, or structured output.",debug:"Diagnoses and fixes bugs in code.",deploy:"Manages deployment pipelines and infrastructure changes."};function $et(e){return Bet[e]??"Agent capability detected from project structure."}function Rce({candidate:e,onApprove:t,onDeny:n,onSkip:s,className:r}){const{path:i,strategy:o,hints:l}=e;return a.jsxs(te.div,{"data-slot":"candidate-card",layout:!0,initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.15,ease:"easeOut"},className:Y("flex items-start justify-between rounded-xl border p-4",r),children:[a.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[a.jsx("p",{className:"text-sm leading-tight font-semibold",children:l.suggestedName||i.split("/").pop()||i}),a.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 text-xs",children:[a.jsx(th,{className:"size-3 shrink-0"}),a.jsx("span",{className:"truncate font-mono",children:i})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[a.jsxs(ZI,{openDelay:300,children:[a.jsx(XI,{asChild:!0,children:a.jsx(zt,{variant:"secondary",className:"hover:bg-secondary/80 cursor-default text-xs",children:l.detectedRuntime})}),a.jsxs(QI,{className:"w-56 space-y-1.5 p-3",side:"top",align:"start",children:[a.jsx("p",{className:"text-xs font-medium",children:"Detected runtime"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:zet(o)})]})]}),l.inferredCapabilities&&l.inferredCapabilities.length>0&&l.inferredCapabilities.map(c=>a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx(zt,{variant:"outline",className:"cursor-default text-[10px]",children:c})}),a.jsx(yn,{side:"top",className:"max-w-48 text-center",children:$et(c)})]},c))]})]}),a.jsxs("div",{className:"ml-4 flex shrink-0 items-center gap-1.5",children:[a.jsx("button",{type:"button",onClick:()=>t(e),className:"focus-visible:ring-ring rounded-md bg-green-600/10 px-2.5 py-1 text-xs font-medium text-green-700 hover:bg-green-600/20 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none dark:text-green-400",children:"Add"}),s&&a.jsx("button",{type:"button",onClick:()=>s(e),className:"text-muted-foreground hover:bg-muted focus-visible:ring-ring rounded-md px-2.5 py-1 text-xs font-medium focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",children:"Skip"}),n&&a.jsx("button",{type:"button",onClick:()=>n(e),className:"focus-visible:ring-ring rounded-md bg-red-600/10 px-2.5 py-1 text-xs font-medium text-red-700 hover:bg-red-600/20 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none dark:text-red-400",children:"Deny"})]})]})}function Het({agent:e}){return a.jsxs("div",{className:"bg-muted/50 flex items-center gap-3 rounded-lg border px-4 py-3",children:[a.jsx(Uh,{className:"text-muted-foreground size-4 shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"truncate text-sm font-medium",children:nn(e)}),a.jsx("p",{className:"text-muted-foreground truncate text-xs",children:e.path})]}),a.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:"Imported"})]})}const Uet=2;function Mce({agents:e}){const[t,n]=x.useState(e.length<=Uet);return e.length===0?null:a.jsxs("div",{children:[a.jsxs("button",{type:"button",onClick:()=>n(s=>!s),className:"text-muted-foreground hover:text-foreground flex w-full items-center gap-1.5 py-1.5 text-xs transition-colors",children:[a.jsx(Rs,{className:Y("size-3 transition-transform",t&&"rotate-90")}),e.length," project",e.length===1?"":"s"," already in DorkOS"]}),t&&a.jsx("div",{className:"mt-2 space-y-2",children:e.map(s=>a.jsx(Het,{agent:s},s.path))})]})}function Dce({count:e,onAddAll:t,disabled:n}){return e===0?null:a.jsxs("div",{className:"flex items-center justify-between py-1",children:[a.jsxs("span",{className:"text-muted-foreground text-sm font-medium",children:[e," new project",e===1?"":"s"]}),a.jsx(ge,{variant:"outline",size:"sm",onClick:t,disabled:n,children:"Add All"})]})}function Oce({roots:e,onChange:t}){const[n,s]=x.useState(""),[r,i]=x.useState(!1),o=x.useCallback(d=>{const f=d.trim();f&&!e.includes(f)&&t([...e,f])},[e,t]),l=x.useCallback(d=>{t(e.filter(f=>f!==d))},[e,t]),c=x.useCallback(d=>{(d.key==="Enter"||d.key===",")&&(d.preventDefault(),n.trim()&&(o(n),s(""))),d.key==="Backspace"&&n===""&&e.length>0&&l(e[e.length-1])},[n,e,o,l]),u=x.useCallback(d=>{o(d)},[o]);return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"focus-within:ring-ring flex min-h-[40px] flex-wrap items-center gap-1.5 rounded-md border bg-transparent px-3 py-1.5 focus-within:ring-2",children:[e.map(d=>a.jsxs(zt,{variant:"secondary",className:"gap-1 py-0.5 font-mono text-xs",children:[d,a.jsx("button",{type:"button",onClick:()=>l(d),className:"hover:bg-muted-foreground/20 ml-0.5 rounded-sm","aria-label":`Remove ${d}`,children:a.jsx(es,{className:"size-3"})})]},d)),a.jsx("input",{type:"text",value:n,onChange:d=>s(d.target.value),onKeyDown:c,placeholder:e.length===0?"Add paths to scan (Enter to add)":"Add more...",className:"placeholder:text-muted-foreground min-w-[120px] flex-1 bg-transparent text-sm focus-visible:outline-none"}),a.jsx("button",{type:"button",onClick:()=>i(!0),className:"text-muted-foreground hover:bg-accent hover:text-foreground shrink-0 rounded p-1","aria-label":"Browse for directory",children:a.jsx($c,{className:"size-4"})})]}),a.jsx(ET,{open:r,onOpenChange:i,onSelect:u})]})}function Vet({onAgentCreated:e}){var g;const[t,n]=x.useState(""),[s,r]=x.useState(""),[i,o]=x.useState(""),[l,c]=x.useState(!1),[u,d]=x.useState(!1),f=TQe(),m=x.useCallback(()=>{!t||!s.trim()||f.mutate({path:t,name:s.trim(),description:i.trim()||void 0},{onSuccess:()=>{d(!0),setTimeout(e,1200)}})},[t,s,i,f,e]);return u?a.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 py-12 text-center",children:[a.jsx(Uh,{className:"text-primary size-12"}),a.jsx("h3",{className:"text-lg font-semibold",children:"Agent created"}),a.jsxs("p",{className:"text-muted-foreground text-sm",children:[a.jsx("span",{className:"font-medium",children:s})," is ready at"," ",a.jsx("span",{className:"font-mono text-xs",children:Mc(t)})]})]}):a.jsx("div",{className:"flex flex-col items-center justify-center",children:a.jsxs("div",{className:"w-full max-w-sm space-y-4",children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:"agent-directory",children:"Project directory"}),a.jsxs("button",{id:"agent-directory",type:"button",onClick:()=>c(!0),className:`border-input bg-background hover:bg-accent flex h-10 w-full items-center gap-2 rounded-md border px-3 text-sm transition-colors ${t?"text-foreground":"text-muted-foreground"}`,children:[a.jsx($c,{className:"size-4 flex-shrink-0"}),a.jsx("span",{className:"truncate",children:t?Mc(t):"Select a directory..."})]}),a.jsx(ET,{open:l,onOpenChange:c,onSelect:n})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:"agent-name",children:"Agent name"}),a.jsx(sn,{id:"agent-name",type:"text",placeholder:"e.g. my-project",value:s,onChange:y=>r(y.target.value)})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs(Rt,{htmlFor:"agent-persona",children:["Persona ",a.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),a.jsx(V5,{id:"agent-persona",placeholder:"Describe what this agent does...",value:i,onChange:y=>o(y.target.value),rows:3})]}),a.jsx(ge,{className:"w-full",onClick:m,disabled:!t||!s.trim()||f.isPending,children:f.isPending?a.jsxs(a.Fragment,{children:[a.jsx(Sn,{className:"size-4 animate-spin"}),"Creating..."]}):"Create agent"}),f.isError&&a.jsxs("p",{className:"text-destructive text-center text-sm",children:["Failed to initialize agent. ",((g=f.error)==null?void 0:g.message)??"Please try again."]})]})})}function qet({onStepComplete:e}){const{startScan:t}=Nce(),{candidates:n,existingAgents:s,isScanning:r,progress:i,error:o}=xP(),l=dce(),{actedPaths:c,markActed:u,resetActed:d}=jce(),[f,m]=x.useState(!1),[g,y]=x.useState(!1),[b,S]=x.useState(3),{roots:w,setScanRoots:C}=hce(),[T,E]=x.useState(null),j=T??w,_=Ds(),N=x.useRef(!1);x.useEffect(()=>{N.current||(N.current=!0,m(!0),t())},[t]);const R=x.useMemo(()=>r?n:Ace(n),[n,r]),O=x.useCallback(W=>{u(W.path),l.mutate({path:W.path,overrides:kC(W)})},[l,u]),M=x.useCallback(W=>{u(W.path)},[u]),L=x.useCallback(()=>{for(const W of R)c.has(W.path)||(u(W.path),l.mutate({path:W.path,overrides:kC(W)}))},[R,c,l,u]),P=x.useCallback(W=>{E(W),C(W)},[C]),$=x.useCallback(()=>{d(),m(!0),t(j.length>0?{roots:j,maxDepth:b}:{roots:[]})},[t,d,j,b]),q=x.useCallback(()=>{$()},[$]),K=s.length>0,B=n.length>0,V=K||B,Q=f&&!r,re=Q&&!V,U=!B||n.every(W=>c.has(W.path)),G=R.filter(W=>!c.has(W.path));return a.jsxs("div",{className:"flex min-h-0 w-full flex-1 flex-col items-center",children:[a.jsxs("div",{className:"w-full shrink-0 text-center",children:[a.jsx("h2",{className:"text-2xl font-semibold tracking-tight sm:text-3xl",children:r&&!V?"Searching your machine...":re?"Create Your First Agent":"Projects Found"}),r&&!V&&a.jsxs("div",{className:"mt-2 space-y-1",children:[a.jsx("p",{className:"text-muted-foreground text-sm",children:"Looking for existing projects on your machine."}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Once imported, your agents can work across them — and you can connect to Slack, Telegram, and more."})]}),re&&a.jsx("p",{className:"text-muted-foreground mt-2 text-sm",children:"No projects were found on your machine."})]}),r&&!V&&a.jsxs("div",{className:"mt-8 flex shrink-0 flex-col items-center gap-4",children:[a.jsx(te.div,{animate:_?{}:{scale:[1,1.15,1]},transition:{duration:1.5,repeat:1/0,ease:"easeInOut"},children:a.jsx(pa,{className:"text-muted-foreground size-8"})}),i&&a.jsxs("p",{className:"text-muted-foreground text-sm",children:["Scanned ",i.scannedDirs," directories"]})]}),r&&V&&i&&a.jsxs("div",{className:"text-muted-foreground mt-4 shrink-0 text-center text-sm",children:["Scanning... ",i.scannedDirs," directories · Found ",i.foundAgents," ","project",i.foundAgents===1?"":"s"]}),Q&&V&&a.jsx("p",{className:"text-muted-foreground mt-3 shrink-0 text-center text-sm",children:"Add existing projects you want to manage in DorkOS. You can assign agents, schedule tasks, and connect to Slack, Telegram, and more."}),o&&a.jsx("div",{className:"border-destructive/30 bg-destructive/5 text-destructive mt-6 shrink-0 rounded-lg border px-4 py-3 text-sm",children:o}),V&&a.jsx("div",{className:"mt-4 min-h-0 w-full flex-1 overflow-y-auto pr-1",children:a.jsxs("div",{className:"space-y-3",children:[G.length>0&&a.jsx(Dce,{count:G.length,onAddAll:L}),a.jsx(Ue,{mode:"popLayout",children:G.map(W=>a.jsx(Rce,{candidate:W,onApprove:O,onSkip:M},W.path))}),K&&a.jsx(Mce,{agents:s})]})}),re&&a.jsxs("div",{className:"mt-6 w-full",children:[a.jsx(Vet,{onAgentCreated:q}),a.jsxs("div",{className:"mt-4",children:[a.jsxs("button",{type:"button",onClick:()=>y(!g),className:"text-muted-foreground hover:text-foreground mx-auto flex items-center gap-1 text-xs",children:[a.jsx(Hs,{className:`size-3 transition-transform ${g?"":"-rotate-90"}`}),"Scan options"]}),g&&a.jsxs("div",{className:"bg-muted/30 mt-2 space-y-3 rounded-lg border p-3",children:[a.jsx(Oce,{roots:j,onChange:P}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("label",{htmlFor:"onboarding-scan-depth",className:"text-muted-foreground text-xs",children:"Scan depth"}),a.jsx("input",{id:"onboarding-scan-depth",type:"range",min:1,max:5,value:b,onChange:W=>S(Number(W.target.value)),className:"flex-1"}),a.jsx("span",{className:"min-w-[1.5rem] text-center text-xs font-medium",children:b})]})]})]}),a.jsxs("div",{className:"mt-6 flex flex-col items-center gap-3",children:[a.jsx(ge,{variant:"outline",size:"sm",onClick:$,children:"Scan Again"}),a.jsx("button",{onClick:e,className:"text-muted-foreground hover:text-foreground text-sm transition-colors",children:"Continue without adding"})]})]}),Q&&V&&a.jsx("div",{className:"mt-4 flex shrink-0 flex-col items-center gap-2 border-t pt-4",children:a.jsx(ge,{size:"lg",onClick:e,variant:U?"default":"outline",children:"Continue"})})]})}function Get({onStepComplete:e,agents:t}){const{data:n,isLoading:s,isError:r}=fP(),i=cP(),[o,l]=x.useState(null),[c,u]=x.useState(!1),[d,f]=x.useState(null),m=t.length===1?t[0]:t.find(C=>C.id===d)??null,g=x.useMemo(()=>o??new Set((n==null?void 0:n.map(C=>C.id))??[]),[o,n]),y=x.useCallback(C=>{l(T=>{const E=T??new Set((n==null?void 0:n.map(_=>_.id))??[]),j=new Set(E);return j.has(C)?j.delete(C):j.add(C),j})},[n]),b=g.size,S=b>0&&m!==null,w=x.useCallback(async()=>{if(!n||b===0||!m){e();return}u(!0);const C=n.filter(j=>g.has(j.id)),E=(await Promise.allSettled(C.map(j=>i.mutateAsync({name:j.name,description:j.description,prompt:j.prompt,cron:j.cron,target:m.id})))).filter(j=>j.status==="rejected");E.length>0&&(console.error("[TaskTemplatesStep] Schedule creation failures:",E),Ye.warning(`${E.length} of ${C.length} schedule(s) failed to create. You can retry from Tasks later.`)),u(!1),e()},[n,b,g,m,i,e]);return a.jsxs("div",{className:"mx-auto w-full max-w-2xl flex-1 space-y-4 overflow-y-auto px-4",children:[a.jsxs("div",{className:"space-y-2 text-center",children:[a.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:"Want your agents to work while you sleep?"}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Tasks runs automated tasks on a schedule — like a cron job for your agents."})]}),t.length===1&&a.jsxs("p",{className:"text-muted-foreground text-center text-sm",children:["Scheduling for ",t[0].icon?`${t[0].icon} `:"",t[0].name]}),t.length>=2&&a.jsx("div",{className:"mx-auto max-w-xs",children:a.jsxs(On,{value:d??"",onValueChange:f,children:[a.jsx(_n,{children:a.jsx(In,{placeholder:"Select a project..."})}),a.jsx(Nn,{children:t.map(C=>a.jsxs(mt,{value:C.id,children:[C.icon?`${C.icon} `:"",nn(C)]},C.id))})]})}),s&&a.jsx("p",{className:"text-muted-foreground text-center text-sm",children:"Loading presets..."}),r&&a.jsx("p",{className:"text-destructive text-center text-sm",children:"Failed to load presets. You can skip this step and configure schedules later."}),n&&n.length>0&&a.jsx("div",{className:"grid gap-3",children:n.map(C=>a.jsx(xce,{preset:C,variant:"toggle",checked:g.has(C.id),onCheckedChange:()=>y(C.id)},C.id))}),a.jsxs("div",{className:"flex flex-col items-center gap-3 pt-2",children:[a.jsx(ge,{onClick:w,size:"lg",disabled:c||b>0&&!S,children:c?"Creating...":b>0?`Create ${b} Schedule${b===1?"":"s"}`:"Continue Without Schedules"}),t.length>=2&&a.jsx("p",{className:"text-muted-foreground text-xs",children:"You can put your other agents on autopilot anytime from Tasks."})]})]})}const FA=["You're","all","set!"];function Ket({onComplete:e}){const t=Ds(),{state:n}=Wb(),s=x.useRef(!1);x.useEffect(()=>{s.current||(s.current=!0,Yv())},[]);const r=n.completedSteps.includes("meet-dorkbot"),i=n.completedSteps.includes("discovery"),o=n.completedSteps.includes("tasks"),l=[{icon:Ad,label:r?"Met DorkBot":"DorkBot skipped",done:r},{icon:e0,label:i?"Agents discovered":"Agents skipped",done:i},{icon:Pi,label:o?"Schedules created":"Schedules skipped",done:o}];return a.jsxs(te.div,{initial:t?!1:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.3,ease:"easeOut"},className:"mx-auto flex w-full max-w-md flex-col items-center gap-8 px-4 text-center",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("h2",{className:"text-3xl font-semibold tracking-tight",children:t?FA.join(" "):a.jsx(te.span,{initial:"hidden",animate:"visible",variants:{visible:{transition:{staggerChildren:.08}}},children:FA.map((c,u)=>a.jsxs(te.span,{className:"inline-block",variants:{hidden:{opacity:0,filter:"blur(4px)"},visible:{opacity:1,filter:"blur(0px)"}},transition:{duration:.4},children:[c,u<FA.length-1?" ":""]},u))})}),a.jsx("p",{className:"text-muted-foreground",children:"Your workspace is configured and ready."})]}),a.jsx(te.div,{className:"w-full space-y-3",initial:"hidden",animate:"visible",variants:t?{}:{visible:{transition:{staggerChildren:.12,delayChildren:.3}}},children:l.map(({icon:c,label:u,done:d})=>a.jsxs(te.div,{variants:t?{}:{hidden:{opacity:0,y:12},visible:{opacity:1,y:0}},transition:{duration:.3},className:"flex items-center gap-3 rounded-lg border p-4",children:[a.jsx(c,{className:`size-5 ${d?"text-primary":"text-muted-foreground/50"}`}),a.jsx("span",{className:d?"text-sm":"text-muted-foreground text-sm",children:u})]},u))}),a.jsx(te.div,{initial:t?!1:{opacity:0},animate:{opacity:1},transition:{delay:.8,duration:.4},children:a.jsx(YI,{className:"px-6 py-2",duration:1.2,onClick:e,children:"Start your first session"})})]})}const gy=["meet-dorkbot","discovery","tasks"],Wet=gy.indexOf("tasks"),zA=-2,LU=-1;function Ice({onComplete:e,initialStep:t=zA}){var L;const[n,s]=x.useState(t),[r,i]=x.useState(1),[o,l]=x.useState(!1),{completeStep:c,skipStep:u,dismiss:d,startOnboarding:f,config:m}=Wb(),g=Hn(),y=Us(),b=Ds(),S=Kb();x.useEffect(()=>{f()},[]);const w=x.useCallback(()=>{n<gy.length-1?(i(1),s(P=>P+1)):(c("adapters"),l(!0))},[n,c]),C=x.useCallback(()=>{n>0?(i(-1),s(P=>P-1)):n===0&&(i(-1),s(zA))},[n]),T=x.useCallback(()=>{c(gy[n]),w()},[n,c,w]),E=x.useCallback(()=>{u(gy[n]),w()},[n,u,w]),j=x.useCallback(async()=>{await d(),e()},[d,e]),_=x.useCallback(()=>{i(1),s(LU)},[]),N=x.useCallback(()=>{i(1),s(0)},[]),R=x.useCallback(()=>{var K,B;const P=((K=m==null?void 0:m.agents)==null?void 0:K.defaultAgent)||"dorkbot",q=`${((B=m==null?void 0:m.agents)==null?void 0:B.defaultDirectory)||"~/.dork/agents"}/${P}`;g({to:"/session",search:{dir:q}}),e()},[m,g,e]);if(x.useEffect(()=>{var P;n===Wet&&!S.isLoading&&((P=S.data)==null?void 0:P.agents.length)===0&&(c("tasks"),w())},[n,S.isLoading,S.data,c,w]),o)return a.jsx("div",{className:"bg-background flex h-full w-full items-center justify-center",children:a.jsx(Ket,{onComplete:R})});if(n===zA)return a.jsx("div",{className:"bg-background flex h-full w-full items-center justify-center",children:a.jsx(ket,{onGetStarted:_,onSkip:j})});if(n===LU)return a.jsx("div",{className:"bg-background flex h-full w-full items-center justify-center",children:a.jsx(yet,{onContinue:N})});const O=y?150:300,M=b?{enter:{opacity:0},center:{opacity:1},exit:{opacity:0}}:{enter:P=>({x:P>0?O:-O,opacity:0,scale:.98,filter:"blur(2px)"}),center:{x:0,opacity:1,scale:1,filter:"blur(0px)"},exit:P=>({x:P>0?-O:O,opacity:0,scale:.98,filter:"blur(2px)"})};return a.jsxs("div",{className:"bg-background flex h-full w-full flex-col",children:[a.jsx(det,{totalSteps:gy.length,currentStep:n,onBack:C,onSkip:E,onSkipAll:j}),a.jsx("div",{className:"relative flex-1 overflow-hidden",children:a.jsx(Ue,{mode:"wait",custom:r,children:a.jsx(te.div,{custom:r,variants:M,initial:"enter",animate:"center",exit:"exit",transition:{type:b?"tween":"spring",damping:25,stiffness:200,duration:b?.15:void 0},className:"absolute inset-0 flex flex-col",children:a.jsxs("div",{className:"mx-auto flex min-h-0 w-full max-w-2xl flex-1 flex-col px-4 py-4 sm:px-6",children:[n===0&&a.jsx(Let,{onStepComplete:T}),n===1&&a.jsx(qet,{onStepComplete:T}),n===2&&a.jsx(Get,{onStepComplete:T,agents:((L=S.data)==null?void 0:L.agents)??[]})]})},n)})})]})}const yP={healthy:{dot:"bg-green-500",text:"text-green-600 dark:text-green-400",border:"border-l-green-500"},delivered:{dot:"bg-green-500",text:"text-green-600 dark:text-green-400",border:"border-l-green-500"},connected:{dot:"bg-green-500",text:"text-green-600 dark:text-green-400",border:"border-l-green-500"},pending:{dot:"bg-blue-500",text:"text-blue-600 dark:text-blue-400",border:"border-l-blue-500"},starting:{dot:"bg-blue-500",text:"text-blue-600 dark:text-blue-400",border:"border-l-blue-500"},new:{dot:"bg-blue-500",text:"text-blue-600 dark:text-blue-400",border:"border-l-blue-500"},reconnecting:{dot:"bg-amber-500",text:"text-amber-600 dark:text-amber-400",border:"border-l-amber-500"},degraded:{dot:"bg-amber-500",text:"text-amber-600 dark:text-amber-400",border:"border-l-amber-500"},warning:{dot:"bg-amber-500",text:"text-amber-600 dark:text-amber-400",border:"border-l-amber-500"},rate_limited:{dot:"bg-amber-500",text:"text-amber-600 dark:text-amber-400",border:"border-l-amber-500"},failed:{dot:"bg-red-500",text:"text-red-600 dark:text-red-400",border:"border-l-red-500"},error:{dot:"bg-red-500",text:"text-red-600 dark:text-red-400",border:"border-l-red-500"},disconnected:{dot:"bg-red-500",text:"text-red-600 dark:text-red-400",border:"border-l-red-500"},inactive:{dot:"bg-gray-400",text:"text-muted-foreground",border:"border-l-gray-400"},stopped:{dot:"bg-gray-400",text:"text-muted-foreground",border:"border-l-gray-400"}};function Yet(e){var t;return((t=yP[e])==null?void 0:t.dot)??"bg-gray-400"}function Zet(e){var t;return((t=yP[e])==null?void 0:t.text)??"text-muted-foreground"}function Xet(e){var t;return((t=yP[e])==null?void 0:t.border)??"border-l-gray-400"}function Qet(e){switch(e){case"delivered":return"bg-green-500";case"failed":return"bg-red-500";case"sent":return"bg-yellow-500";case"timeout":return"bg-gray-500";default:return"bg-gray-400"}}function Jet(e){return new Date(e).toLocaleTimeString()}function FU(e,t){if(e==null||t==null)return null;const n=new Date(t).getTime()-new Date(e).getTime();return n<1e3?`${n}ms`:`${(n/1e3).toFixed(1)}s`}function ett({messageId:e,onClose:t}){const{data:n,isLoading:s,error:r}=LQe(e);if(s)return a.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading trace..."});if(r||!n)return a.jsx("div",{className:"text-destructive p-4 text-sm",children:"Failed to load trace."});const{traceId:i,spans:o}=n;return a.jsxs("div",{className:"flex flex-col gap-2 p-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-muted-foreground font-mono text-xs",children:["Trace: ",i.slice(0,8),"..."]}),t&&a.jsx("button",{onClick:t,className:"text-muted-foreground hover:text-foreground text-xs",children:"Close"})]}),a.jsx("div",{className:"border-border relative ml-3 border-l pl-6",children:o.map(l=>{const c=FU(l.sentAt,l.deliveredAt),u=FU(l.deliveredAt,l.processedAt);return a.jsxs("div",{className:"relative pb-4 last:pb-0",children:[a.jsx("div",{className:`absolute top-1 -left-[calc(1.5rem+0.3125rem)] h-2.5 w-2.5 rounded-full ${Qet(l.status)}`}),a.jsxs("div",{className:"flex flex-col gap-0.5",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:"font-medium",children:l.subject}),a.jsx("span",{className:"bg-muted rounded px-1.5 py-0.5 text-xs",children:l.status})]}),a.jsxs("div",{className:"text-muted-foreground flex gap-3 text-xs",children:[a.jsxs("span",{children:["Sent: ",Jet(l.sentAt)]}),c&&a.jsxs("span",{children:["Delivery: ",c]}),u&&a.jsxs("span",{children:["Processing: ",u]})]}),l.errorMessage&&a.jsx("div",{className:"bg-destructive/10 text-destructive mt-1 rounded px-2 py-1 text-xs",children:l.errorMessage})]})]},l.id)})})]})}function BA(e){if(e.payload&&typeof e.payload=="object"){const n=e.payload;if(typeof n.adapterId=="string")return n.adapterId}const t=e.from.raw.match(/^relay\.human\.([^.]+)/);return t?t[1]:""}function zU(e){if(e.payload&&typeof e.payload=="object"){const t=e.payload;if(typeof t.chatId=="string")return t.chatId}}function BU(e){if(e.payload&&typeof e.payload=="object"){const n=e.payload.channelType;if(n==="dm"||n==="group"||n==="channel"||n==="thread")return n}}const ttt={delivered:"Delivered",failed:"Failed",pending:"Pending"};function $U(e){return new Date(e).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",second:"2-digit"})}function ntt(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function stt(e){return e.status==="delivered"?e.responseCount>0?`delivered · ${e.responseCount} chunks`:"delivered":e.failureReason??ttt[e.status].toLowerCase()}function rtt({conversation:e}){const[t,n]=x.useState(!1),[s,r]=x.useState(!1),[i,o]=x.useState(!1),[l,c]=x.useState(""),[u,d]=x.useState(!1),[f,m]=x.useState(!1),{data:g}=ba(),y=x.useMemo(()=>(g==null?void 0:g.agents)??[],[g]),{mutate:b}=ZT(),{data:S=[]}=Gb(),w=BA(e),C=x.useMemo(()=>S.filter(O=>O.adapterId===w),[S,w]),T=Yet(e.status),E=Zet(e.status),j=Xet(e.status),_=x.useCallback(()=>{y.find(M=>M.id===l)&&(b({adapterId:BA(e),agentId:l,sessionStrategy:"per-chat",label:"",chatId:zU(e),channelType:BU(e)}),c(""),d(!1))},[y,l,e,b]),N=x.useCallback(()=>{d(!1),m(!0)},[]),R=x.useCallback(O=>{b({adapterId:O.adapterId,agentId:O.agentId,sessionStrategy:O.sessionStrategy,label:O.label,chatId:O.chatId,channelType:O.channelType,canInitiate:O.canInitiate,canReply:O.canReply,canReceive:O.canReceive}),m(!1)},[b]);return a.jsxs("div",{className:Y("hover:bg-muted/50 w-full rounded-lg border border-l-2 text-left transition-colors hover:shadow-sm",j,t&&"bg-muted/30"),children:[a.jsxs("div",{className:"flex items-start gap-2 p-3",children:[a.jsxs("button",{type:"button",onClick:()=>n(!t),className:"flex min-w-0 flex-1 items-start gap-2",children:[a.jsx("span",{className:Y("mt-1 size-2 shrink-0 rounded-full",T)}),a.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[a.jsxs("div",{className:"text-muted-foreground text-xs",children:[a.jsx("span",{className:"inline-block w-8 font-medium",children:"From"}),a.jsx("span",{className:"text-foreground",children:e.from.label})]}),a.jsxs("div",{className:"text-muted-foreground text-xs",children:[a.jsx("span",{className:"inline-block w-8 font-medium",children:"To"}),a.jsx("span",{className:"text-foreground",children:e.to.label})]}),a.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.preview&&a.jsxs("span",{className:"text-muted-foreground min-w-0 flex-1 truncate text-xs",children:['"',e.preview,'"']}),a.jsx("span",{className:Y("shrink-0 text-xs",E),children:stt(e)})]})]})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[a.jsx("span",{className:"text-muted-foreground text-xs",children:ii(e.sentAt)}),a.jsxs(c0,{open:u,onOpenChange:d,children:[a.jsx(u0,{asChild:!0,children:a.jsxs(ge,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-xs",onClick:O=>O.stopPropagation(),"aria-label":"Route to agent",children:[a.jsx(fne,{className:"mr-1 size-3"}),"Route"]})}),a.jsxs(d0,{className:"w-64 space-y-3 p-3",align:"end",children:[a.jsx("p",{className:"text-xs font-medium",children:"Route to Agent"}),C.length>0&&a.jsx("div",{className:"rounded border border-blue-200 bg-blue-50 px-2 py-1.5 text-xs dark:border-blue-900 dark:bg-blue-950",children:a.jsxs("p",{className:"font-medium text-blue-800 dark:text-blue-200",children:[C.length," binding",C.length!==1?"s":""," ","already exist",C.length===1?"s":""," for this adapter"]})}),a.jsxs(On,{value:l,onValueChange:c,children:[a.jsx(_n,{className:"h-8 text-xs",children:a.jsx(In,{placeholder:"Select agent"})}),a.jsx(Nn,{children:y.map(O=>a.jsx(mt,{value:O.id,children:nn(O)},O.id))})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(ge,{variant:"link",size:"sm",className:"h-6 px-0 text-xs",onClick:N,children:"More options..."}),a.jsx(ge,{size:"sm",className:"h-7 text-xs",disabled:!l,onClick:_,children:"Create Binding"})]})]})]})]})]}),f&&a.jsx(mce,{open:!0,onOpenChange:O=>{O||m(!1)},mode:"create",initialValues:{adapterId:BA(e),agentId:l||void 0,chatId:zU(e),channelType:BU(e)},onConfirm:R}),a.jsx(Ue,{initial:!1,children:t&&a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"overflow-hidden",children:a.jsxs("div",{className:"space-y-3 border-t px-3 pt-3 pb-3",children:[e.payload!=null&&a.jsxs("div",{children:[a.jsx("span",{className:"text-muted-foreground text-xs font-medium",children:"Payload"}),a.jsx("pre",{className:"bg-muted mt-1 max-h-40 overflow-auto rounded p-2 font-mono text-xs",children:JSON.stringify(e.payload,null,2)})]}),a.jsxs("div",{className:"text-muted-foreground text-xs",children:[a.jsxs("span",{children:["Sent ",$U(e.sentAt)]}),e.completedAt&&a.jsxs("span",{children:[" · Completed ",$U(e.completedAt)]}),e.durationMs!=null&&a.jsxs("span",{children:[" · Duration: ",ntt(e.durationMs)]}),e.responseCount>0&&a.jsxs("span",{children:[" · ",e.responseCount," response chunks"]})]}),e.failureReason&&a.jsx("div",{className:"bg-destructive/10 text-destructive rounded px-2 py-1 text-xs",children:e.failureReason}),a.jsxs("button",{type:"button",onClick:O=>{O.stopPropagation(),r(!s)},className:"text-muted-foreground hover:text-foreground flex items-center gap-1.5 text-xs",children:[s?a.jsx(Hs,{className:"size-3.5"}):a.jsx(Rs,{className:"size-3.5"}),"Technical Details"]}),a.jsx(Ue,{initial:!1,children:s&&a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:a.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs",children:[a.jsx("dt",{className:"text-muted-foreground",children:"Subject"}),a.jsx("dd",{className:"truncate font-mono",children:e.subject}),e.sessionId&&a.jsxs(a.Fragment,{children:[a.jsx("dt",{className:"text-muted-foreground",children:"Session"}),a.jsx("dd",{className:"font-mono",children:e.sessionId.slice(0,8)})]}),e.traceId&&a.jsxs(a.Fragment,{children:[a.jsx("dt",{className:"text-muted-foreground",children:"Trace ID"}),a.jsxs("dd",{className:"font-mono",children:[e.traceId.slice(0,12),"…"]})]}),a.jsx("dt",{className:"text-muted-foreground",children:"Source"}),a.jsx("dd",{className:"truncate font-mono",children:e.from.raw}),a.jsx("dt",{className:"text-muted-foreground",children:"Destination"}),a.jsx("dd",{className:"truncate font-mono",children:e.to.raw})]})})}),e.traceId&&a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",onClick:O=>{O.stopPropagation(),o(!i)},className:"text-muted-foreground hover:text-foreground flex items-center gap-1.5 text-xs",children:[i?a.jsx(Hs,{className:"size-3.5"}):a.jsx(Rs,{className:"size-3.5"}),"Trace Timeline"]}),a.jsx(Ue,{initial:!1,children:i&&a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:a.jsx(ett,{messageId:e.traceId,onClose:()=>o(!1)})})})]})]})})})]})}const itt={hop_limit:{label:"Hop Limit",className:"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400"},ttl_expired:{label:"TTL Expired",className:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"},cycle_detected:{label:"Cycle Detected",className:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400"},budget_exhausted:{label:"Budget Exhausted",className:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"}},att={label:"Unknown",className:"bg-muted text-muted-foreground"};function ott(e,t){const n=ii(e),s=ii(t);return n===s?s:`${n} — ${s}`}function ltt({group:e}){const[t,n]=x.useState(!1),s=sce(),r=itt[e.reason]??att;return a.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50/50 p-3 dark:border-red-900/40 dark:bg-red-950/20",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(fr,{className:"mt-0.5 size-4 shrink-0 text-red-500"}),a.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"truncate text-sm font-medium",children:e.source}),a.jsx(zt,{className:Y("shrink-0 border-0 text-xs font-normal",r.className),children:r.label}),a.jsx(zt,{variant:"destructive",className:"shrink-0 tabular-nums",children:e.count.toLocaleString()})]}),a.jsx("p",{className:"text-muted-foreground text-xs",children:ott(e.firstSeen,e.lastSeen)})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.sample!=null&&a.jsxs(a.Fragment,{children:[a.jsxs(ge,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>n(!0),children:[a.jsx(K5,{className:"mr-1 size-3"}),"View Sample"]}),a.jsx(qc,{open:t,onOpenChange:n,children:a.jsxs(Cl,{className:"max-w-lg",children:[a.jsxs(El,{children:[a.jsx(Tl,{children:"Sample Envelope"}),a.jsxs(_l,{children:["Representative failure from ",e.source," (",r.label,")"]})]}),a.jsx("pre",{className:"bg-muted max-h-80 overflow-auto rounded-md p-3 font-mono text-xs",children:JSON.stringify(e.sample,null,2)})]})})]}),a.jsxs(Sl,{children:[a.jsx(mT,{asChild:!0,children:a.jsxs(ge,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground h-7 px-2 text-xs",disabled:s.isPending,children:[a.jsx(wo,{className:"mr-1 size-3"}),"Mark Resolved"]})}),a.jsxs(ko,{children:[a.jsxs(wl,{children:[a.jsx(Co,{children:"Mark dead letters as resolved?"}),a.jsxs(Eo,{children:["This will dismiss ",e.count," dead letter",e.count!==1?"s":""," from"," ",a.jsx("span",{className:"font-medium",children:e.source})," (",r.label,"). This action cannot be undone."]})]}),a.jsxs(kl,{children:[a.jsx(_o,{children:"Cancel"}),a.jsx(To,{onClick:()=>s.mutate({source:e.source,reason:e.reason}),children:"Mark Resolved"})]})]})]})]})]})})}function ctt({enabled:e=!0}){const{data:t=[],isLoading:n}=w0(e),{data:s}=lP(),r=s==null?void 0:s.budgetRejections,i=r&&Object.values(r).some(o=>o>0);return n||t.length===0?null:a.jsxs("div",{className:"space-y-2",children:[i&&a.jsx("div",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 dark:border-amber-900 dark:bg-amber-950",children:a.jsxs("p",{className:"text-xs font-medium text-amber-800 dark:text-amber-200",children:["Budget rejections: ",r.hopLimit," hop limit,"," ",r.cycleDetected," cycles, ",r.budgetExhausted," budget,"," ",r.ttlExpired," TTL"]})}),t.map(o=>a.jsx(ltt,{group:o},`${o.source}:${o.reason}`))]})}function utt(e){try{return JSON.parse(e)}catch{return{content:e}}}const dtt=se({subject:z().min(1,"Subject is required"),from:z().min(1,"From is required"),payload:z().min(1,"Payload is required")});function ftt({open:e,onOpenChange:t}={}){const[n,s]=x.useState(!1),r=e!==void 0,i=r?e:n,o=jQe(),l=XE({defaultValues:{subject:"",from:"relay.human.console",payload:""},validators:{onSubmit:dtt},onSubmit:({value:u})=>{o.mutate({subject:u.subject,from:u.from,payload:utt(u.payload)},{onSuccess:()=>{Ye.success("Message sent"),l.reset(),c(!1)}})}});function c(u){r?t==null||t(u):s(u),u||l.reset()}return a.jsxs(qc,{open:i,onOpenChange:c,children:[!r&&a.jsx(eie,{asChild:!0,children:a.jsxs(ge,{variant:"ghost",size:"sm",className:"gap-1.5","data-testid":"compose-trigger",children:[a.jsx(r3e,{className:"size-3.5"}),"Compose"]})}),a.jsxs(Cl,{children:[a.jsxs(El,{children:[a.jsx(Tl,{children:"Send Test Message"}),a.jsx(_l,{children:"Compose a message to send through the Relay bus."})]}),a.jsx(l.AppForm,{children:a.jsxs("form",{onSubmit:u=>{u.preventDefault(),l.handleSubmit()},className:"space-y-4",children:[a.jsx(l.AppField,{name:"subject",children:u=>a.jsx(u.TextField,{label:"Subject",placeholder:"e.g. relay.test.ping"})}),a.jsx(l.AppField,{name:"from",children:u=>a.jsx(u.TextField,{label:"From"})}),a.jsx(l.AppField,{name:"payload",children:u=>a.jsx(u.TextareaField,{label:"Payload",placeholder:'Plain text or JSON (e.g. {"content": "hello"})',rows:4})}),a.jsx("div",{className:"flex justify-end",children:a.jsxs(ge,{type:"submit",disabled:o.isPending,children:[a.jsx(M3e,{className:"mr-2 size-4"}),"Send"]})})]})})]})]})}function htt({enabled:e}){const{data:t}=lP();if(!e||!t)return null;const n=[{label:"Total",value:t.totalMessages,variant:"default"},{label:"Delivered",value:t.deliveredCount,variant:"success"},{label:"Failed",value:t.failedCount,variant:t.failedCount>0?"danger":"default"},{label:"Dead Letter",value:t.deadLetteredCount,variant:t.deadLetteredCount>0?"warning":"default"}];return a.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-2",children:[n.map(({label:s,value:r,variant:i})=>a.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[a.jsx("span",{className:"text-muted-foreground",children:s}),a.jsx("span",{className:Y("font-medium tabular-nums",i==="success"&&r>0&&"text-green-600 dark:text-green-500",i==="danger"&&"text-red-600 dark:text-red-500",i==="warning"&&"text-amber-600 dark:text-amber-500"),children:r.toLocaleString()})]},s)),t.avgDeliveryLatencyMs!=null&&a.jsxs("div",{className:"ml-auto flex items-center gap-1.5 text-xs",children:[a.jsx("span",{className:"text-muted-foreground",children:"Avg"}),a.jsx("span",{className:"font-medium tabular-nums",children:t.avgDeliveryLatencyMs<1e3?`${Math.round(t.avgDeliveryLatencyMs)}ms`:`${(t.avgDeliveryLatencyMs/1e3).toFixed(1)}s`})]})]})}function mtt(e){return e.startsWith("relay.agent.")?"chat":e.startsWith("relay.system.tasks.")?"tasks":"system"}const ptt={initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,height:0},transition:{duration:.2,ease:"easeOut"}},gtt={initial:!1,animate:{opacity:1,y:0},exit:{opacity:0,height:0},transition:{duration:.2,ease:"easeOut"}};function xtt(e,t,n,s){return e.filter(r=>{if(t!=="all"&&mtt(r.subject)!==t||n!=="all"&&r.status!==n)return!1;if(s){const i=s.toLowerCase();if(!(r.from.label.toLowerCase().includes(i)||r.to.label.toLowerCase().includes(i)||r.preview.toLowerCase().includes(i)||r.subject.toLowerCase().includes(i)))return!1}return!0})}function ytt({enabled:e,deadLetterRef:t,onSwitchToChannels:n,autoShowFailures:s}){const[r,i]=x.useState("all"),[o,l]=x.useState("all"),[c,u]=x.useState(""),[d,f]=x.useState(!1),[m,g]=x.useState(!1),{data:y,isLoading:b}=zQe(e),{data:S=[]}=w0(e),w=x.useMemo(()=>(y==null?void 0:y.conversations)??[],[y==null?void 0:y.conversations]);S.length>0;const C=x.useRef(null);x.useEffect(()=>{w.length>0&&C.current===null&&(C.current=new Set(w.map(_=>_.id)))},[w]),x.useEffect(()=>{!m&&S.length>0&&f(!0)},[S.length,m]),x.useEffect(()=>{s&&(f(!0),g(!1))},[s]);const T=r!=="all"||o!=="all"||c!=="",E=xtt(w,r,o,c);function j(){i("all"),l("all"),u("")}return b?a.jsx("div",{className:"space-y-2 p-4",children:[1,2,3].map(_=>a.jsx("div",{className:"rounded-lg border p-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"bg-muted animate-tasks size-4 rounded"}),a.jsx("div",{className:"bg-muted animate-tasks h-4 w-40 rounded"}),a.jsx("div",{className:"bg-muted animate-tasks ml-auto h-3 w-16 rounded"})]})},_))}):a.jsxs(a.Fragment,{children:[a.jsx(htt,{enabled:e}),a.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsxs(On,{value:r,onValueChange:_=>i(_),children:[a.jsx(_n,{className:"w-32",children:a.jsx(In,{})}),a.jsxs(Nn,{children:[a.jsx(mt,{value:"all",children:"All sources"}),a.jsx(mt,{value:"chat",children:"Chat messages"}),a.jsx(mt,{value:"tasks",children:"Tasks jobs"}),a.jsx(mt,{value:"system",children:"System"})]})]}),a.jsxs(On,{value:o,onValueChange:_=>l(_),children:[a.jsx(_n,{className:"w-32",children:a.jsx(In,{})}),a.jsxs(Nn,{children:[a.jsx(mt,{value:"all",children:"All statuses"}),a.jsx(mt,{value:"delivered",children:"Delivered"}),a.jsx(mt,{value:"failed",children:"Failed"}),a.jsx(mt,{value:"pending",children:"Pending"})]})]}),a.jsxs(ge,{variant:d?"secondary":"ghost",size:"sm",className:"relative",onClick:()=>{f(!d),g(!0)},"aria-pressed":d,"aria-label":"Show dead letters",children:[a.jsx(fr,{className:"mr-1 size-3.5"}),"Dead Letters",S.length>0&&!d&&m&&a.jsx("span",{className:"absolute -top-0.5 -right-0.5 size-2 rounded-full bg-red-500"})]}),a.jsx(sn,{className:"h-9 w-44",placeholder:"Filter by agent or message...",value:c,onChange:_=>u(_.target.value),"aria-label":"Search conversations"}),T&&a.jsx(ge,{variant:"ghost",size:"sm",onClick:j,children:"Clear filters"}),a.jsx("div",{className:"ml-auto",children:a.jsx(ftt,{})})]}),d&&a.jsx("div",{ref:t,children:a.jsx(ctt,{enabled:e})}),E.length===0&&!T?a.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[a.jsx("div",{className:"pointer-events-none mb-2 w-full max-w-sm opacity-20 select-none",children:a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"rounded-lg border p-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"bg-muted size-4 rounded"}),a.jsx("div",{className:"bg-muted h-3 w-32 rounded"}),a.jsx("div",{className:"bg-muted ml-auto h-3 w-12 rounded"})]})}),a.jsx("div",{className:"rounded-lg border p-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"bg-muted size-4 rounded"}),a.jsx("div",{className:"bg-muted h-3 w-44 rounded"}),a.jsx("div",{className:"bg-muted ml-auto h-3 w-12 rounded"})]})}),a.jsx("div",{className:"rounded-lg border p-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"bg-muted size-4 rounded"}),a.jsx("div",{className:"bg-muted h-3 w-24 rounded"}),a.jsx("div",{className:"bg-muted ml-auto h-3 w-12 rounded"})]})})]})}),a.jsx(rMe,{className:"text-muted-foreground/50 size-10"}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm font-medium",children:"No activity yet"}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Messages will appear here as your agents communicate"})]})]}):E.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[a.jsx(pa,{className:"text-muted-foreground/50 size-10"}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm font-medium",children:"No messages match your filters"}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Try adjusting your filter criteria."})]}),a.jsx(ge,{variant:"ghost",size:"sm",onClick:j,children:"Clear filters"})]}):a.jsx("div",{className:"space-y-2",children:a.jsx(Ue,{mode:"popLayout",children:E.map(_=>{const R=C.current!==null&&!C.current.has(_.id)?ptt:gtt;return a.jsx(te.div,{...R,children:a.jsx(rtt,{conversation:_})},_.id)})})})]})]})}const vtt={messaging:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",automation:"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200",internal:"bg-gray-100 text-gray-800 dark:bg-gray-900 dark:text-gray-200",custom:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200"};function Pce(e){return vtt[e]??""}function vP({iconId:e,adapterType:t,size:n=16,className:s}){const r=oU[e??""]??oU[t??""];return r?a.jsx(r,{size:n,className:s}):a.jsx(Ad,{className:s,style:{width:n,height:n}})}function btt({manifest:e,instance:t,primaryName:n,secondaryName:s,statusDotClass:r,onToggle:i,onShowEvents:o,onConfigure:l,onRemove:c,onAddBinding:u,isBuiltinClaude:d}){return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[a.jsx("div",{className:r,"aria-hidden":!0}),a.jsx(vP,{iconId:e.iconId,adapterType:e.type,size:16,className:"text-muted-foreground shrink-0"}),a.jsx("span",{className:"text-sm font-medium",children:n})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[a.jsx(sr,{checked:t.enabled,onCheckedChange:i}),a.jsxs(a0,{children:[a.jsx(o0,{asChild:!0,children:a.jsx(ge,{variant:"ghost",size:"sm",className:"size-7 p-0","aria-label":"Adapter actions",children:a.jsx(yRe,{className:"size-4"})})}),a.jsxs(Qh,{align:"end",children:[a.jsxs(Nr,{onClick:o,children:[a.jsx(fb,{className:"mr-2 size-3.5"}),"Events"]}),a.jsxs(Nr,{onClick:u,children:[a.jsx(qE,{className:"mr-2 size-3.5"}),"Add channel"]}),a.jsxs(Nr,{onClick:l,children:[a.jsx(qa,{className:"mr-2 size-3.5"}),"Configure"]}),a.jsxs(Nr,{onClick:c,disabled:d,className:"text-red-600 focus:text-red-600",children:[a.jsx(wo,{className:"mr-2 size-3.5"}),"Remove"]})]})]})]})]}),a.jsxs("div",{className:"mt-1 flex items-center gap-2 pl-[18px]",children:[s&&a.jsx("span",{className:"text-muted-foreground text-xs",children:s}),s&&a.jsx("span",{className:"text-muted-foreground/50 text-xs",children:"·"}),a.jsx(zt,{variant:"secondary",className:Y("text-xs",Pce(e.category)),children:e.category}),e.deprecated&&a.jsx(zt,{variant:"outline",className:"text-xs text-amber-600 dark:text-amber-500",children:"Deprecated"})]})]})}function Stt({agentName:e,sessionStrategy:t,chatId:n,channelType:s,canInitiate:r=!1,canReply:i=!0,canReceive:o=!0}){return a.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:[a.jsx("span",{className:"truncate",children:e}),t!=="per-chat"&&a.jsx(zt,{variant:"secondary",className:"shrink-0 text-xs",children:RJe(t)}),n&&a.jsx(zt,{variant:"outline",className:"shrink-0 truncate text-xs",children:s?`#${n}`:n}),a.jsxs(em,{children:[r&&a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx(Uc,{className:"size-3 shrink-0 text-amber-500","aria-label":"Can initiate messages"})}),a.jsx(yn,{children:"Can initiate messages"})]}),!i&&a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx(jMe,{className:"text-muted-foreground/70 size-3 shrink-0","aria-label":"Reply disabled"})}),a.jsx(yn,{children:"Reply disabled"})]}),!o&&a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx(oAe,{className:"text-muted-foreground/70 size-3 shrink-0","aria-label":"Receive disabled"})}),a.jsx(yn,{children:"Receive disabled"})]})]})]})}function HU({adapterId:e,onQuickBind:t,onAdvanced:n,isPending:s,children:r}){const[i,o]=x.useState(!1),{data:l}=ba(),{data:c=[]}=Gb(),u=x.useMemo(()=>new Set(c.filter(g=>g.adapterId===e).map(g=>g.agentId)),[c,e]),d=x.useMemo(()=>((l==null?void 0:l.agents)??[]).filter(g=>!u.has(g.id)),[l,u]);async function f(g){await t(g),o(!1)}function m(){o(!1),n()}return a.jsxs(c0,{open:i,onOpenChange:o,children:[a.jsx(u0,{asChild:!0,children:r}),a.jsxs(d0,{className:"w-56 p-0",align:"start",children:[a.jsxs(gT,{children:[a.jsx(xT,{placeholder:"Search agents..."}),a.jsxs(yT,{children:[a.jsx(vT,{children:"No agents registered"}),d.map(g=>a.jsxs(Qr,{value:g.id,keywords:[nn(g)],onSelect:()=>f(g.id),disabled:s,children:[s?a.jsx(Sn,{className:"mr-2 size-3.5 animate-spin"}):null,nn(g)]},g.id))]})]}),a.jsx("div",{className:"border-t px-2 py-1.5",children:a.jsx(ge,{variant:"ghost",size:"sm",className:"text-muted-foreground w-full text-xs",onClick:m,children:"Advanced..."})})]})]})}const $A=3;function wtt({instance:e,isBuiltinClaude:t,boundAgentRows:n,totalAgentCount:s,isConnected:r,hasBindings:i,onEditBinding:o,onQuickBind:l,onAdvancedBind:c,createBindingPending:u}){const[d,f]=x.useState(!1),m=d?n:n.slice(0,$A),g=n.length-$A;return a.jsx("div",{className:"mt-3 space-y-1.5 pl-[18px]",children:t?a.jsxs("p",{className:"text-muted-foreground text-sm",children:["Serving ",s," ",s===1?"agent":"agents"," · Chat + Tasks"]}):i?a.jsxs(a.Fragment,{children:[m.map(y=>a.jsxs("button",{type:"button",className:"group/row hover:bg-muted/50 flex w-full cursor-pointer items-center gap-1.5 rounded px-1 py-0.5 text-left transition-colors",onClick:()=>o(y.binding),children:[a.jsx(Stt,{agentName:y.agentName,sessionStrategy:y.sessionStrategy,chatId:y.chatId,channelType:y.channelType,canInitiate:y.canInitiate,canReply:y.canReply,canReceive:y.canReceive}),a.jsx(Rs,{className:"text-muted-foreground ml-auto size-3 opacity-0 transition-opacity group-hover/row:opacity-100"})]},y.bindingId)),g>0&&!d&&a.jsxs("button",{type:"button",className:"text-muted-foreground hover:text-foreground mt-1 text-xs hover:underline",onClick:()=>f(!0),children:["Show ",g," more"]}),d&&n.length>$A&&a.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground mt-1 text-xs hover:underline",onClick:()=>f(!1),children:"Show less"}),a.jsx(HU,{adapterId:e.id,onQuickBind:l,onAdvanced:c,isPending:u,children:a.jsxs(ge,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground mt-1 h-6 gap-1 px-2 text-xs",children:[a.jsx(Cs,{className:"size-3"}),"Add channel"]})})]}):r?a.jsx(HU,{adapterId:e.id,onQuickBind:l,onAdvanced:c,isPending:u,children:a.jsxs(ge,{variant:"ghost",size:"sm",className:"mt-1 h-6 gap-1 px-2 text-xs text-amber-600 hover:bg-amber-50 hover:text-amber-700 dark:text-amber-500 dark:hover:bg-amber-950",children:[a.jsx(Cs,{className:"size-3"}),"Add channel"]})}):null})}function ktt({instance:e}){const{errorCount:t,lastError:n}=e.status;return!t&&!n?null:a.jsxs("div",{className:"mt-3 pl-[18px]",children:[t>0&&!n&&a.jsxs("div",{className:"flex items-center gap-1 text-xs text-red-500",children:[a.jsx(fr,{className:"size-3"}),a.jsxs("span",{children:[t," ",t===1?"error":"errors"]})]}),n&&a.jsxs(ol,{children:[a.jsx("div",{className:"flex items-center gap-1",children:a.jsx(ll,{asChild:!0,children:a.jsxs("button",{className:"flex items-center gap-1 text-xs text-red-500 hover:text-red-600","aria-label":"Toggle full error message",children:[a.jsx(Rs,{className:"size-3 transition-transform data-[state=open]:rotate-90"}),t>0&&a.jsx(fr,{className:"size-3"}),a.jsx("span",{className:"max-w-[200px] truncate",children:t>0?`${t} ${t===1?"error":"errors"}`:n})]})})}),a.jsx(cl,{children:a.jsx("div",{className:"mt-1 rounded-md bg-red-50 p-2 font-mono text-xs text-red-700 dark:bg-red-950 dark:text-red-300",children:n})})]})]})}function Ctt({instance:e,manifest:t,onToggle:n,onConfigure:s,onShowEvents:r,onEditBinding:i,onRemoveConfirm:o,onAddBinding:l}){const c=ZT(),u=t.type==="claude-code"&&t.builtin,d=e.label||e.status.displayName||e.id,f=e.label?e.status.displayName||t.displayName:null,{data:m=[]}=Gb(),{data:g}=ba(),y=x.useMemo(()=>(g==null?void 0:g.agents)??[],[g==null?void 0:g.agents]),b=y.length,S=x.useMemo(()=>m.filter(N=>N.adapterId===e.id),[m,e.id]),w=x.useMemo(()=>S.map(N=>{const R=y.find(O=>O.id===N.agentId);return{bindingId:N.id,agentName:(R==null?void 0:R.name)??N.agentId,sessionStrategy:N.sessionStrategy,chatId:N.chatId,channelType:N.channelType,canInitiate:N.canInitiate,canReply:N.canReply,canReceive:N.canReceive,binding:N}}),[S,y]),C=S.length>0,T=e.status.state==="connected",E=u||C,j=Y("size-2 shrink-0 rounded-full",e.status.state==="connected"&&!E?"bg-amber-500 motion-safe:animate-pulse":rce[e.status.state]??"bg-muted-foreground");async function _(N){try{await c.mutateAsync({adapterId:e.id,agentId:N,sessionStrategy:"per-chat",label:""}),Ye.success("Channel connected")}catch(R){Ye.error(R instanceof Error?R.message:"Failed to connect channel")}}return a.jsxs("div",{className:Y("shadow-soft hover:shadow-elevated rounded-xl border p-5 transition-shadow",u&&"border-dashed"),children:[a.jsx(btt,{manifest:t,instance:e,primaryName:d,secondaryName:f,statusDotClass:j,onToggle:n,onShowEvents:()=>r(e.id),onConfigure:s,onRemove:()=>o(e.id,d),onAddBinding:()=>l(e.id,e.id),isBuiltinClaude:u}),a.jsx(wtt,{instance:e,isBuiltinClaude:u,boundAgentRows:w,totalAgentCount:b,isConnected:T,hasBindings:C,onEditBinding:N=>i(N),onQuickBind:_,onAdvancedBind:()=>l(e.id,e.id),createBindingPending:c.isPending}),a.jsx(ktt,{instance:e})]})}const Ett={"adapter.connected":"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200","adapter.message_sent":"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200","adapter.disconnected":"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200","adapter.error":"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200","adapter.message_received":"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200","adapter.status_change":"bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200"},CD={"adapter.connected":"Connected","adapter.disconnected":"Disconnected","adapter.message_received":"Received","adapter.message_sent":"Sent","adapter.error":"Error","adapter.status_change":"Status"},Ttt=Object.keys(CD);function _tt({adapterId:e}){const{data:t,isLoading:n}=BQe(e),[s,r]=x.useState("all"),i=x.useRef(null),[o,l]=x.useState(!0),c=x.useCallback(()=>{const m=i.current;if(!m)return;l(m.scrollHeight-m.scrollTop-m.clientHeight<20)},[]);x.useEffect(()=>{o&&i.current&&(i.current.scrollTop=i.current.scrollHeight)},[t,o]);const u=()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight,l(!0))};if(n)return a.jsx("div",{className:"space-y-2 p-3",children:[1,2,3,4].map(m=>a.jsx(Jt,{className:"h-6 w-full"},m))});const d=(t==null?void 0:t.events)??[],f=s==="all"?d:d.filter(m=>m.subject===s);return d.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 p-6 text-center",children:[a.jsx(fb,{className:"text-muted-foreground size-6"}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"No events recorded"})]}):a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[a.jsx("h4",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Events"}),a.jsxs(On,{value:s,onValueChange:r,children:[a.jsx(_n,{className:"h-7 w-[130px] text-xs",children:a.jsx(In,{})}),a.jsxs(Nn,{children:[a.jsx(mt,{value:"all",children:"All types"}),Ttt.map(m=>a.jsx(mt,{value:m,children:CD[m]},m))]})]})]}),a.jsx("div",{ref:i,onScroll:c,className:"flex-1 overflow-y-auto p-2",children:f.map(m=>{const g=m.metadata?JSON.parse(m.metadata):null,y=new Date(m.sentAt).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"});return a.jsxs("div",{className:"flex items-start gap-2 py-1",children:[a.jsx("span",{className:"text-muted-foreground shrink-0 font-mono text-xs tabular-nums",children:y}),a.jsx(zt,{variant:"secondary",className:Y("shrink-0 text-[10px]",Ett[m.subject]??""),children:CD[m.subject]??m.subject}),a.jsx("span",{className:"text-xs break-words",children:(g==null?void 0:g.message)??m.subject})]},m.id)})}),!o&&a.jsx("div",{className:"flex justify-center border-t py-1",children:a.jsxs(ge,{variant:"ghost",size:"sm",onClick:u,className:"h-6 text-xs",children:[a.jsx(hb,{className:"mr-1 size-3"}),"Jump to bottom"]})})]})}function Lce({manifest:e,onAdd:t}){return a.jsxs("div",{className:"hover:bg-muted/50 flex flex-col justify-between rounded-lg border p-4 transition-colors",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(vP,{iconId:e.iconId,adapterType:e.type,size:20,className:"text-muted-foreground shrink-0"}),a.jsx("span",{className:"text-sm font-medium",children:e.displayName}),a.jsx(zt,{variant:"secondary",className:Pce(e.category),children:e.category})]}),a.jsx("p",{className:"text-muted-foreground text-xs",children:e.description})]}),a.jsx("div",{className:"mt-3",children:a.jsxs(ge,{variant:"outline",size:"sm",className:"w-full",onClick:t,children:[a.jsx(Cs,{className:"mr-1 size-3"}),"Add"]})})]})}const UU=["configure","test","confirm","bind"],Ntt={configure:"Configure",test:"Test",confirm:"Confirm",bind:"Bind"};function jtt({current:e,showBindStep:t}){const n=t?UU:UU.filter(r=>r!=="bind"),s=n.indexOf(e);return a.jsx("div",{className:"flex items-start justify-between px-1",role:"navigation","aria-label":"Wizard steps",children:n.map((r,i)=>{const o=i<s,l=i===s,c=i>s;return a.jsxs(x.Fragment,{children:[i>0&&a.jsx("div",{className:Y("mt-3 h-px flex-1",o||l?"bg-primary":"border-muted-foreground/40 border-t border-dashed")}),a.jsxs("div",{className:"flex flex-col items-center gap-1",children:[a.jsx("div",{className:Y("flex size-6 items-center justify-center rounded-full text-xs font-medium",o&&"bg-primary text-primary-foreground",l&&"bg-primary text-primary-foreground ring-primary/30 ring-2",c&&"border-muted-foreground text-muted-foreground border"),"aria-current":l?"step":void 0,children:o?a.jsx(Lt,{className:"size-3"}):i+1}),a.jsx("span",{className:Y("text-[10px]",l?"text-foreground font-medium":"text-muted-foreground"),children:Ntt[r]})]})]},r)})})}function Att({field:e,value:t,onChange:n,error:s,allValues:r}){const[i,o]=x.useState("");if(e.showWhen&&r[e.showWhen.field]!==e.showWhen.equals)return null;const l=`config-field-${e.key}`,c=e.type==="select"&&e.displayAs==="radio-cards",u=t!=null?String(t):"",d=u==="***",f=()=>{if(d){o("");return}if(e.pattern&&u&&!new RegExp(e.pattern).test(u)){o(e.patternMessage??"Invalid format");return}o("")},m=s??i;if(e.type==="boolean")return a.jsxs("div",{children:[a.jsxs(ua,{orientation:"horizontal",className:"items-center justify-between gap-4",children:[a.jsxs(Ute,{className:"min-w-0",children:[a.jsx(da,{htmlFor:l,className:Y("text-sm font-medium",e.required&&'after:text-destructive after:ml-0.5 after:content-["*"]'),children:e.label}),e.description&&a.jsx(Va,{className:"text-xs",children:e.description})]}),a.jsx(sr,{id:l,checked:!!t,onCheckedChange:y=>n(e.key,y)})]}),e.helpMarkdown&&a.jsxs(ol,{children:[a.jsxs(ll,{className:"text-muted-foreground hover:text-foreground mt-1 flex items-center gap-1 text-xs transition-colors",children:[a.jsx(pB,{className:"size-3"}),"Where do I find this?",a.jsx(Hs,{className:"size-3 transition-transform [[data-state=open]_&]:rotate-180"})]}),a.jsx(cl,{children:a.jsx("div",{className:"bg-muted/50 mt-2 rounded-md border p-3",children:a.jsx(Ev,{content:e.helpMarkdown,className:"text-xs"})})})]}),a.jsx(Ue,{children:m&&a.jsx(te.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.15},className:"overflow-hidden",children:a.jsx(rl,{className:"mt-1.5",children:m})})})]});const g=()=>{var y,b;switch(e.type){case"text":case"url":return a.jsx(sn,{id:l,type:e.type==="url"?"url":"text",value:u,onChange:S=>n(e.key,S.target.value),placeholder:e.placeholder,"aria-invalid":!!m||void 0});case"password":return d?a.jsx(il,{id:l,value:u,showPassword:!1,onChange:S=>{n(e.key,S.target.value.trim()),i&&o("")},onFocus:()=>n(e.key,""),onBlur:f,placeholder:"Saved — enter a new one to replace"}):a.jsx(il,{id:l,value:u,visibleByDefault:e.visibleByDefault??!1,onChange:S=>{n(e.key,S.target.value.trim()),i&&o("")},onBlur:f,onPaste:()=>setTimeout(f,0),placeholder:e.placeholder,"aria-invalid":!!m||void 0});case"number":return a.jsx(sn,{id:l,type:"number",value:u,onChange:S=>n(e.key,S.target.value?Number(S.target.value):void 0),placeholder:e.placeholder,"aria-invalid":!!m||void 0});case"select":return e.displayAs==="radio-cards"?a.jsx("div",{className:"grid grid-cols-2 gap-3",role:"radiogroup","aria-labelledby":`${l}-label`,children:(y=e.options)==null?void 0:y.map(S=>a.jsxs("button",{type:"button",role:"radio","aria-checked":u===S.value,onClick:()=>n(e.key,S.value),className:Y("hover:bg-accent/50 focus-visible:border-ring focus-visible:ring-ring/50 flex flex-col items-start rounded-md border p-3 text-left transition outline-none focus-visible:ring-[3px]",u===S.value&&"border-primary ring-primary bg-accent/30 ring-1"),children:[a.jsx("span",{className:"text-sm font-medium",children:S.label}),S.description&&a.jsx("span",{className:"text-muted-foreground mt-1 text-xs",children:S.description})]},S.value))}):a.jsxs(On,{value:u,onValueChange:S=>n(e.key,S),children:[a.jsx(_n,{id:l,"aria-invalid":!!m||void 0,children:a.jsx(In,{placeholder:e.placeholder??"Select..."})}),a.jsx(Nn,{children:(b=e.options)==null?void 0:b.map(S=>a.jsx(mt,{value:S.value,children:S.label},S.value))})]});case"textarea":return a.jsx(V5,{id:l,value:u,onChange:S=>n(e.key,S.target.value),placeholder:e.placeholder,rows:3,"aria-invalid":!!m||void 0});default:return null}};return a.jsxs(ua,{children:[a.jsx(da,{id:`${l}-label`,htmlFor:c?void 0:l,className:Y(e.required&&!d&&'after:text-destructive after:ml-0.5 after:content-["*"]'),children:e.label}),g(),e.description&&a.jsx(Va,{className:"text-xs",children:e.description}),e.helpMarkdown&&a.jsxs(ol,{children:[a.jsxs(ll,{className:"text-muted-foreground hover:text-foreground mt-1 flex items-center gap-1 text-xs transition-colors",children:[a.jsx(pB,{className:"size-3"}),"Where do I find this?",a.jsx(Hs,{className:"size-3 transition-transform [[data-state=open]_&]:rotate-180"})]}),a.jsx(cl,{children:a.jsx("div",{className:"bg-muted/50 mt-2 rounded-md border p-3",children:a.jsx(Ev,{content:e.helpMarkdown,className:"text-xs"})})})]}),a.jsx(Ue,{children:m&&a.jsx(te.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.15},className:"overflow-hidden",children:a.jsx(rl,{children:m})})})]})}function Rtt(e,t){return e.showWhen?t[e.showWhen.field]===e.showWhen.equals:!0}function Mtt({fields:e,allValues:t,renderField:n}){const s=new Map;for(const r of e){const i=r.section;s.has(i)||s.set(i,[]),s.get(i).push(r)}return a.jsx("div",{className:"space-y-6",children:Array.from(s.entries()).map(([r,i])=>{const o=i.filter(l=>Rtt(l,t));return o.length===0?null:a.jsxs("div",{className:"space-y-3",children:[r&&a.jsx("h4",{className:"text-sm font-semibold",children:r}),a.jsx(vr,{children:a.jsx(dr,{children:o.map(l=>n(l))})})]},r??"__default")})})}function Dtt({manifest:e,label:t,onLabelChange:n,fields:s,form:r,currentSetupStep:i,hasSetupGuide:o,onOpenGuide:l}){const{Subscribe:c,AppField:u}=r;return a.jsxs("div",{className:"space-y-4",children:[e.setupInstructions&&a.jsxs("div",{className:"flex gap-2 rounded-md border border-blue-200 bg-blue-50 p-3 text-sm text-blue-800 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-200",children:[a.jsx(VE,{className:"mt-0.5 size-4 shrink-0"}),a.jsx(Ev,{content:e.setupInstructions,className:"text-sm text-blue-800 dark:text-blue-200"})]}),(e.actionButton||o)&&a.jsxs("div",{className:"flex items-center justify-end gap-2",children:[o&&a.jsxs(ge,{type:"button",variant:"outline",size:"sm",onClick:l,children:[a.jsx(q5,{className:"mr-1.5 size-3.5"}),"Setup Guide"]}),e.actionButton&&a.jsx("a",{href:e.actionButton.url,target:"_blank",rel:"noopener noreferrer",children:a.jsx(ge,{type:"button",variant:"outline",size:"sm",children:e.actionButton.label})})]}),i&&a.jsx("h4",{className:"text-sm font-medium",children:i.title}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(Rt,{htmlFor:"adapter-label",children:"Name (optional)"}),a.jsx(sn,{id:"adapter-label",placeholder:e.displayName,value:t,onChange:d=>n(d.target.value)}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"A friendly name to identify this adapter instance."})]}),a.jsx(c,{selector:d=>d.values,children:d=>a.jsx(Mtt,{fields:s,allValues:d,renderField:f=>a.jsx(u,{name:f.key,children:m=>{var g;return a.jsx(Att,{field:f,value:m.state.value,onChange:(y,b)=>m.handleChange(b),onBlur:m.handleBlur,error:m.state.meta.isTouched?(g=m.state.meta.errors[0])==null?void 0:g.toString():void 0,allValues:d})}},f.key)})})]})}function Ott({isPending:e,isSuccess:t,isError:n,errorMessage:s,botUsername:r,onRetry:i}){return a.jsxs("div",{className:"flex flex-col items-center gap-3 py-6",children:[e&&a.jsxs(a.Fragment,{children:[a.jsx(Sn,{className:"text-muted-foreground size-8 animate-spin"}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Testing connection..."})]}),t&&a.jsxs("div",{className:"flex flex-col items-center gap-2",children:[a.jsx(Uh,{className:"size-8 text-green-500"}),a.jsx("p",{className:"text-sm text-green-700 dark:text-green-400",children:"Connection successful"}),r&&a.jsx("div",{className:"flex items-center gap-2 rounded-md border px-3 py-2 text-sm",children:a.jsxs("span",{className:"font-mono",children:["@",r]})})]}),n&&a.jsxs(a.Fragment,{children:[a.jsx(Xg,{className:"size-8 text-red-500"}),a.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:"Connection failed"}),s&&a.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-xs text-red-700 dark:border-red-800 dark:bg-red-950 dark:text-red-300",children:[a.jsx(fr,{className:"mt-0.5 size-3 shrink-0"}),a.jsx("span",{children:s})]}),a.jsx(ge,{variant:"outline",size:"sm",onClick:i,children:"Retry"})]})]})}function Itt(e){return e.length>8?"•••• "+e.slice(-4):"•••"}function Ptt({manifest:e,adapterId:t,isEditMode:n,values:s}){return a.jsxs("div",{className:"space-y-3",children:[!n&&a.jsxs("div",{className:"flex justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Adapter ID"}),a.jsx("span",{className:"font-mono",children:t})]}),e.configFields.map(r=>{if(r.showWhen&&s[r.showWhen.field]!==r.showWhen.equals)return null;const i=String(s[r.key]??""),o=r.type==="password"?Itt(i):i;return a.jsxs("div",{className:"flex justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:r.label}),a.jsx("span",{className:"max-w-[200px] truncate font-mono",children:o})]},r.key)})]})}const Ltt=[{value:"per-chat",label:"Per Chat"},{value:"per-user",label:"Per User"},{value:"stateless",label:"Stateless"}];function Ftt({agentOptions:e,agentId:t,onAgentIdChange:n,strategy:s,onStrategyChange:r,botUsername:i,adapterType:o}){return x.useEffect(()=>{e.length===1&&!t&&n(e[0].id)},[e.length]),a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-muted-foreground text-sm",children:"Connect this channel to an agent so incoming messages are routed automatically. You can skip this and connect it later from the Connections tab."}),e.length===0?a.jsx("div",{className:"text-muted-foreground rounded-md border border-dashed px-4 py-6 text-center text-sm",children:"No agents registered yet. Once you have an agent, connect this channel to it from the Connections tab."}):e.length===1?a.jsxs("div",{className:"bg-accent/30 rounded-md border px-4 py-3 text-sm",children:["Will bind to ",a.jsx("span",{className:"font-medium",children:nn(e[0])})]}):a.jsxs("div",{className:"space-y-2",children:[a.jsx(Rt,{htmlFor:"bind-agent",children:"Agent"}),a.jsxs(On,{value:t,onValueChange:n,children:[a.jsx(_n,{id:"bind-agent",className:"w-full",children:a.jsx(In,{placeholder:"Select an agent"})}),a.jsx(Nn,{children:e.map(l=>a.jsx(mt,{value:l.id,children:nn(l)},l.id))})]})]}),e.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(Rt,{htmlFor:"bind-strategy",children:"Session Strategy"}),a.jsxs(On,{value:s,onValueChange:l=>r(l),children:[a.jsx(_n,{id:"bind-strategy",className:"w-full",children:a.jsx(In,{})}),a.jsx(Nn,{children:Ltt.map(l=>a.jsx(mt,{value:l.value,children:l.label},l.value))})]})]}),i&&o==="telegram"&&a.jsxs("a",{href:`https://t.me/${i}`,target:"_blank",rel:"noopener noreferrer",className:"text-primary inline-flex items-center gap-1.5 text-sm underline-offset-4 hover:underline",children:["Message @",i," in Telegram"]})]})}function ztt({open:e,onOpenChange:t,title:n,content:s}){return a.jsx(Al,{open:e,onOpenChange:t,children:a.jsxs(Rl,{side:"right",className:"w-[480px] overflow-y-auto sm:max-w-lg",children:[a.jsxs(Ml,{children:[a.jsxs(Dl,{className:"flex items-center gap-2",children:[a.jsx(q5,{className:"size-4"}),n," Setup Guide"]}),a.jsx(Hd,{children:"Step-by-step instructions for configuring this adapter."})]}),a.jsx("div",{className:"mt-4 px-4",children:a.jsx(Ev,{content:s})})]})})}function HA(e){const t={};for(const[n,s]of Object.entries(e)){const r=n.split(".");let i=t;for(let o=0;o<r.length-1;o++){const l=r[o];(!(l in i)||typeof i[l]!="object"||i[l]===null)&&(i[l]={}),i=i[l]}i[r[r.length-1]]=s}return t}function VU(e,t){const n=t.split(".");let s=e;for(const r of n){if(s==null||typeof s!="object")return;s=s[r]}return s}function Btt(e,t){const n={};for(const s of e.configFields){const r=t?VU(t,s.key):void 0;r!==void 0&&s.type!=="password"?n[s.key]=r:s.type==="password"&&t&&VU(t,s.key)!==void 0?n[s.key]="***":s.default!==void 0?n[s.key]=s.default:n[s.key]=s.type==="boolean"?!1:""}return n}function $tt(e,t=[]){const n=e.type;if(!t.includes(n))return n;let s=2;for(;t.includes(`${n}-${s}`);)s++;return`${n}-${s}`}function Htt({manifest:e,existingInstance:t,existingAdapterIds:n=[],onOpenChange:s}){const r=!!t,[i,o]=x.useState("configure"),[l,c]=x.useState(!1),[u]=x.useState(()=>(t==null?void 0:t.id)??$tt(e,n)),[d,f]=x.useState(()=>{var ae;return((ae=t==null?void 0:t.config)==null?void 0:ae.label)??""}),[m,g]=x.useState(0),[y,b]=x.useState(""),[S,w]=x.useState(""),[C,T]=x.useState(""),[E,j]=x.useState("per-chat"),_=MQe(),N=tce(),R=OQe(),O=ZT(),{data:M}=ba(),L=(M==null?void 0:M.agents)??[],P=e.setupSteps&&e.setupSteps.length>0,$=XE({defaultValues:Btt(e,t==null?void 0:t.config),validators:{onSubmit:({value:ae})=>{const oe={};for(const de of e.configFields)if(!(de.showWhen&&ae[de.showWhen.field]!==de.showWhen.equals)&&de.required){const me=ae[de.key];(me==null||me==="")&&(oe[de.key]=`${de.label} is required`)}return Object.keys(oe).length>0?{fields:oe}:void 0}},onSubmit:async()=>{}}),q=x.useMemo(()=>{if(!P||!e.setupSteps)return e.configFields;const ae=e.setupSteps[m];return ae?e.configFields.filter(oe=>ae.fields.includes(oe.key)):e.configFields},[e.configFields,e.setupSteps,P,m]),K=x.useCallback(()=>{const ae=$.state.values;let oe=!0;for(const de of q)if(!(de.showWhen&&ae[de.showWhen.field]!==de.showWhen.equals)&&de.required){const me=ae[de.key];(me==null||me==="")&&($.setFieldMeta(de.key,Re=>({...Re,isTouched:!0,errors:[`${de.label} is required`],errorMap:{onSubmit:`${de.label} is required`}})),oe=!1)}return oe},[$,q]),B=x.useCallback(()=>{if(i==="configure"){if(!K())return;if(P&&e.setupSteps&&m<e.setupSteps.length-1){g(de=>de+1);return}const oe=$.state.values;o("test"),R.mutate({type:e.type,config:HA(oe)},{onSuccess:de=>{de.botUsername&&(b(de.botUsername),d||f(`@${de.botUsername}`))}})}else i==="test"&&o("confirm")},[i,P,e,m,K,$,R,d]),V=x.useCallback(()=>{i==="test"?(o("configure"),R.reset()):i==="confirm"?o("test"):i==="bind"?s(!1):i==="configure"&&P&&m>0&&g(ae=>ae-1)},[i,P,m,R,s]),Q=x.useCallback(()=>{const ae=$.state.values,oe=HA(ae),de=d?{...oe,label:d}:oe;r&&t?N.mutate({id:t.id,config:de},{onSuccess:()=>s(!1)}):_.mutate({type:e.type,id:u,config:de},{onSuccess:()=>{const me=d||u;Ye.success(`${e.displayName} adapter added`,{description:me?`"${me}" is ready to use.`:void 0}),w(u),o("bind")},onError:me=>{var Re,Fe,Le;(Re=me.message)!=null&&Re.includes("timed out")?Ye.error("Request timed out",{description:"Check your token and network connectivity, then try again."}):((Fe=me.message)!=null&&Fe.includes("duplicate")||(Le=me.message)!=null&&Le.includes("exists"))&&(o("configure"),g(0))}})},[$,r,t,N,_,e,u,d,s]),re=x.useCallback(()=>{C&&O.mutate({adapterId:S,agentId:C,sessionStrategy:E,label:""},{onSuccess:()=>s(!1)})},[C,S,E,O,s]),U=x.useCallback(()=>{s(!1)},[s]),G=x.useCallback(ae=>{ae||(o("configure"),g(0),f(""),b(""),w(""),T(""),j("per-chat"),c(!1),$.reset(),R.reset()),s(ae)},[s,$,R]),W=x.useCallback(()=>{R.mutate({type:e.type,config:HA($.state.values)})},[R,e.type,$]),F=_.isPending||N.isPending,X=O.isPending,J=P&&e.setupSteps?e.setupSteps[m]:void 0;return{step:i,isEditMode:r,adapterId:u,label:d,setLabel:f,botUsername:y,guideOpen:l,setGuideOpen:c,form:$,visibleFields:q,bindAgentId:C,setBindAgentId:T,bindStrategy:E,setBindStrategy:j,agentOptions:L,isSaving:F,isBinding:X,hasSetupSteps:P,setupStepIndex:m,currentSetupStep:J,testConnection:R,handleContinue:B,handleBack:V,handleSave:Q,handleBind:re,handleSkipBind:U,handleOpenChange:G,handleRetryTest:W}}function Fce({open:e,onOpenChange:t,manifest:n,existingInstance:s,existingAdapterIds:r=[]}){var Q;const i=Htt({manifest:n,existingInstance:s,existingAdapterIds:r,onOpenChange:t}),{step:o,isEditMode:l,adapterId:c,label:u,setLabel:d,botUsername:f,guideOpen:m,setGuideOpen:g,form:y,visibleFields:b,bindAgentId:S,setBindAgentId:w,bindStrategy:C,setBindStrategy:T,agentOptions:E,isSaving:j,isBinding:_,hasSetupSteps:N,setupStepIndex:R,currentSetupStep:O,testConnection:M,handleContinue:L,handleBack:P,handleSave:$,handleBind:q,handleSkipBind:K,handleOpenChange:B,handleRetryTest:V}=i;return a.jsxs(x.Fragment,{children:[a.jsx(qc,{open:e,onOpenChange:B,children:a.jsxs(Cl,{className:"flex max-h-[85vh] max-w-lg flex-col",children:[a.jsxs(El,{children:[a.jsx(Tl,{children:l?`Edit ${n.displayName}`:`Add ${n.displayName}`}),a.jsxs(_l,{children:[o==="configure"&&((O==null?void 0:O.description)??"Configure the adapter settings."),o==="test"&&"Testing connection to the adapter.",o==="confirm"&&"Review your configuration before saving.",o==="bind"&&"Optionally bind this adapter to an agent."]})]}),a.jsxs("div",{className:"min-h-0 space-y-4 overflow-y-auto py-2",children:[a.jsx(jtt,{current:o,showBindStep:!l}),a.jsx(Ue,{mode:"wait",children:a.jsxs(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},children:[o==="configure"&&a.jsx(Dtt,{manifest:n,label:u,onLabelChange:d,fields:b,form:y,currentSetupStep:O,hasSetupGuide:!!n.setupGuide,onOpenGuide:()=>g(!0)}),o==="test"&&a.jsx(Ott,{isPending:M.isPending,isSuccess:M.isSuccess,isError:M.isError,errorMessage:(Q=M.error)==null?void 0:Q.message,botUsername:f,onRetry:V}),o==="confirm"&&a.jsx(y.Subscribe,{selector:re=>re.values,children:re=>a.jsx(Ptt,{manifest:n,adapterId:c,isEditMode:l,values:re})}),o==="bind"&&a.jsx(Ftt,{agentOptions:E,agentId:S,onAgentIdChange:w,strategy:C,onStrategyChange:T,botUsername:f,adapterType:n.type})]},o)})]}),a.jsxs(i0,{className:"flex items-center justify-between sm:justify-between",children:[a.jsxs("div",{children:[(o==="test"||o==="confirm")&&a.jsxs(ge,{variant:"ghost",onClick:P,disabled:j,children:[a.jsx(ov,{className:"mr-1 size-4"}),"Back"]}),o==="configure"&&N&&R>0&&a.jsxs(ge,{variant:"ghost",onClick:P,children:[a.jsx(ov,{className:"mr-1 size-4"}),"Back"]})]}),a.jsxs("div",{className:"flex gap-2",children:[o!=="bind"&&a.jsx(ge,{variant:"outline",onClick:()=>B(!1),children:"Cancel"}),o==="configure"&&a.jsxs(ge,{onClick:L,children:["Continue",a.jsx(uh,{className:"ml-1 size-4"})]}),o==="test"&&!M.isPending&&!M.isSuccess&&a.jsx(ge,{variant:"ghost",onClick:L,children:"Skip"}),o==="test"&&M.isSuccess&&a.jsxs(ge,{onClick:L,children:["Continue",a.jsx(uh,{className:"ml-1 size-4"})]}),o==="confirm"&&a.jsxs(ge,{onClick:$,disabled:j,children:[j&&a.jsx(Sn,{className:"mr-2 size-4 animate-spin"}),l?"Save Changes":"Add Adapter"]}),o==="bind"&&a.jsxs(a.Fragment,{children:[a.jsx(ge,{variant:"ghost",onClick:K,disabled:_,children:"Skip"}),a.jsxs(ge,{onClick:q,disabled:!S||_,children:[_&&a.jsx(Sn,{className:"mr-2 size-4 animate-spin"}),"Bind to Agent"]})]})]})]})]})}),n.setupGuide&&a.jsx(ztt,{open:m,onOpenChange:g,title:n.displayName,content:n.setupGuide})]})}function Utt(){const[e,t]=x.useState({removeTarget:null,eventsTarget:null,bindingTarget:null});return{...e,openRemove:(n,s)=>t(r=>({...r,removeTarget:{instanceId:n,name:s}})),closeRemove:()=>t(n=>({...n,removeTarget:null})),openEvents:n=>t(s=>({...s,eventsTarget:{instanceId:n}})),closeEvents:()=>t(n=>({...n,eventsTarget:null})),openBindingCreate:n=>t(s=>({...s,bindingTarget:{mode:"create",adapterId:n}})),openBindingEdit:(n,s)=>t(r=>({...r,bindingTarget:{mode:"edit",adapterId:n,binding:s}})),closeBinding:()=>t(n=>({...n,bindingTarget:null}))}}function qU({enabled:e}){var R,O;const{data:t=[],isLoading:n}=S0(e),{data:s}=ba(),{mutate:r}=ece(),{mutate:i}=DQe(),o=ZT(),l=cJe(),c=lJe(),[u,d]=x.useState({open:!1}),f=et(),m=Utt();function g(M){var L;return(L=t.flatMap(P=>P.instances.map($=>({instance:$,manifest:P.manifest}))).find(P=>P.instance.id===M))==null?void 0:L.manifest}function y(M){const L=s==null?void 0:s.agents.find(P=>P.id===M);return L?nn(L):M}async function b(M){const L=m.bindingTarget;if(L)try{L.mode==="edit"&&L.binding?(await l.mutateAsync({id:L.binding.id,updates:TJe(M)}),Ye.success("Channel updated")):(await o.mutateAsync(EJe(M)),Ye.success("Channel connected")),m.closeBinding()}catch(P){Ye.error(P instanceof Error?P.message:"Failed to save channel")}}async function S(M){try{await c.mutateAsync(M),Ye.success("Channel removed"),m.closeBinding()}catch(L){Ye.error(L instanceof Error?L.message:"Failed to remove channel")}}if(n)return a.jsxs("div",{className:"space-y-6 p-4",children:[a.jsxs("div",{className:"space-y-3",children:[a.jsx(Jt,{className:"h-4 w-32"}),a.jsx("div",{className:"space-y-2",children:[1,2].map(M=>a.jsx(Jt,{className:"h-16 w-full rounded-lg"},M))})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx(Jt,{className:"h-4 w-32"}),a.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))"},children:[1,2].map(M=>a.jsxs("div",{className:"rounded-lg border p-4",children:[a.jsx(Jt,{className:"mb-2 h-5 w-24"}),a.jsx(Jt,{className:"h-4 w-full"}),a.jsx(Jt,{className:"mt-3 h-8 w-full"})]},M))})]})]});const w=t.flatMap(M=>M.instances.map(L=>({instance:L,manifest:M.manifest}))),C=t.filter(M=>!M.manifest.deprecated&&(M.instances.length===0||M.manifest.multiInstance)),T=M=>{d({open:!0,manifest:M})},E=(M,L)=>{d({open:!0,manifest:M,instanceId:L})},j=u.instanceId?t.flatMap(M=>M.instances).find(M=>M.id===u.instanceId):void 0,_=()=>{f.invalidateQueries({queryKey:["relay","adapters","catalog"]})},N=M=>({adapterId:M.adapterId,agentId:M.agentId,sessionStrategy:M.sessionStrategy,label:M.label??"",permissionMode:M.permissionMode,chatId:M.chatId,channelType:M.channelType,canInitiate:M.canInitiate,canReply:M.canReply,canReceive:M.canReceive});return a.jsxs("div",{className:"space-y-6 p-4",children:[a.jsxs("section",{children:[a.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[a.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Active Channels"}),a.jsx(ge,{variant:"ghost",size:"sm",onClick:_,className:"size-7 p-0","aria-label":"Refresh channel catalog",children:a.jsx(ma,{className:"size-3.5"})})]}),w.length===0?a.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed py-8",children:[a.jsx(Gk,{className:"text-muted-foreground/40 size-8"}),a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-muted-foreground text-sm",children:"No channels active"}),a.jsx("p",{className:"text-muted-foreground/60 text-xs",children:"Add a channel below to connect agents to external services"})]})]}):a.jsx("div",{className:"space-y-3",children:w.map(({instance:M,manifest:L})=>a.jsx(Ctt,{instance:M,manifest:L,onToggle:P=>r({id:M.id,enabled:P}),onConfigure:()=>E(L,M.id),onShowEvents:P=>m.openEvents(P),onEditBinding:P=>m.openBindingEdit(P.adapterId,P),onRemoveConfirm:(P,$)=>m.openRemove(P,$),onAddBinding:P=>m.openBindingCreate(P)},M.id))})]}),a.jsxs("section",{children:[a.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-semibold tracking-wide uppercase",children:"Add Channel"}),C.length===0?a.jsx("p",{className:"text-muted-foreground text-sm",children:"All channel types are active. Multi-instance channels like Webhook can be added again from the active list."}):a.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))"},children:C.map(M=>a.jsx(Lce,{manifest:M.manifest,onAdd:()=>T(M.manifest)},M.manifest.type))})]}),u.manifest&&a.jsx(Fce,{open:u.open,onOpenChange:M=>{M||d({open:!1})},manifest:u.manifest,existingInstance:j,existingAdapterIds:t.flatMap(M=>M.instances.map(L=>L.id))}),m.removeTarget&&a.jsx(Sl,{open:!0,onOpenChange:M=>{M||m.closeRemove()},children:a.jsxs(ko,{children:[a.jsxs(wl,{children:[a.jsx(Co,{children:"Remove adapter"}),a.jsxs(Eo,{children:['Are you sure you want to remove "',m.removeTarget.name,'"? This will stop the adapter and remove its configuration. Messages to its subjects will no longer be delivered.']})]}),a.jsxs(kl,{children:[a.jsx(_o,{children:"Cancel"}),a.jsx(To,{onClick:()=>{i(m.removeTarget.instanceId),m.closeRemove()},className:"bg-red-600 hover:bg-red-700 focus:ring-red-600",children:"Remove"})]})]})}),m.eventsTarget&&a.jsx(Al,{open:!0,onOpenChange:M=>{M||m.closeEvents()},children:a.jsxs(Rl,{className:"flex flex-col sm:max-w-md",children:[a.jsx(Ml,{children:a.jsx(Dl,{children:"Events"})}),a.jsx("div",{className:"flex-1 overflow-hidden",children:a.jsx(_tt,{adapterId:m.eventsTarget.instanceId})})]})}),m.bindingTarget&&a.jsx(mce,{open:!0,onOpenChange:M=>{M||m.closeBinding()},mode:m.bindingTarget.mode,initialValues:m.bindingTarget.binding?N(m.bindingTarget.binding):{adapterId:m.bindingTarget.adapterId},adapterName:(R=g(m.bindingTarget.adapterId))==null?void 0:R.displayName,agentName:m.bindingTarget.binding?y(m.bindingTarget.binding.agentId):void 0,onConfirm:b,onDelete:m.bindingTarget.mode==="edit"?S:void 0,bindingId:(O=m.bindingTarget.binding)==null?void 0:O.id,isPending:o.isPending||l.isPending||c.isPending})]})}function Vtt({onAddChannel:e}){return a.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center px-6 py-16",children:[a.jsx("div",{className:"pointer-events-none mb-8 w-full max-w-md opacity-30 select-none",children:a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"rounded-lg border p-3",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"flex size-6 items-center justify-center rounded-full bg-blue-500/20",children:a.jsx("div",{className:"size-3 rounded-full bg-blue-500"})}),a.jsxs("div",{className:"flex-1 space-y-1",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm font-medium",children:"relay.agent.frontend"}),a.jsx("span",{className:"text-muted-foreground text-xs",children:"2m ago"})]}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Build completed successfully"})]})]})}),a.jsx("div",{className:"rounded-lg border p-3",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"flex size-6 items-center justify-center rounded-full bg-emerald-500/20",children:a.jsx("div",{className:"size-3 rounded-full bg-emerald-500"})}),a.jsxs("div",{className:"flex-1 space-y-1",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm font-medium",children:"relay.system.tasks.audit"}),a.jsx("span",{className:"text-muted-foreground text-xs",children:"15m ago"})]}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Scheduled audit run delivered"})]})]})}),a.jsx("div",{className:"rounded-lg border p-3",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"flex size-6 items-center justify-center rounded-full bg-orange-500/20",children:a.jsx("div",{className:"size-3 rounded-full bg-orange-500"})}),a.jsxs("div",{className:"flex-1 space-y-1",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm font-medium",children:"relay.agent.backend"}),a.jsx("span",{className:"text-muted-foreground text-xs",children:"1h ago"})]}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"API migration task completed"})]})]})})]})}),a.jsx("h3",{className:"mb-2 text-lg font-medium",children:"Connect your agents to the world"}),a.jsx("p",{className:"text-muted-foreground mb-1 max-w-sm text-center text-sm",children:"Relay routes messages between your agents and external platforms."}),a.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm text-center text-sm",children:"Add your first channel to start sending and receiving messages."}),a.jsx(ge,{onClick:e,children:"Add Channel"})]})}const GU={healthy:"bg-emerald-500",degraded:"bg-amber-500",critical:"bg-red-500"};function qtt(e){return e==null?"—":e<1?"<1ms":`${Math.round(e)}ms`}function Gtt(e,t,n){const s=e.totalMessages>0?(e.failedCount+e.deadLetteredCount)/e.totalMessages:0;if(n===0)return{state:"healthy",message:"No connections configured"};if(s>.5||t===0)return{state:"critical",message:`${Math.round(s*100)}% failure rate — ${e.failedCount} messages failed today`};if(t<n||s>=.05){const r=n-t;return r>0?{state:"degraded",message:`${r} connection${r>1?"s":""} disconnected`}:{state:"degraded",message:`${e.failedCount} failure${e.failedCount!==1?"s":""} in last 24h`}}return{state:"healthy",message:`${t} connection${t>1?"s":""} active`}}function Ktt(e){const{data:t=[],isLoading:n}=S0(e),s=t.flatMap(o=>o.instances),r=s.length,i=s.filter(o=>o.status.state==="connected").length;return{total:r,connected:i,isLoading:n}}function Wtt({enabled:e=!0,onFailedClick:t}){const n=am(),{data:s,isLoading:r}=lP(),{total:i,connected:o,isLoading:l}=Ktt(e&&n);if(!n||!e||r||l||!s)return null;const{state:c,message:u}=Gtt(s,o,i),d=(c==="degraded"||c==="critical")&&t!=null,f=qtt(s.avgDeliveryLatencyMs),m=`${s.totalMessages} messages today · ${s.failedCount} failed · ${f} avg latency`;return a.jsx(em,{children:a.jsx("div",{className:"text-muted-foreground flex items-center gap-2 border-b px-3 py-1.5 text-xs",children:c==="healthy"?a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsxs("span",{className:"flex min-w-0 flex-1 cursor-default items-center gap-1.5",children:[a.jsx("span",{className:`size-2 shrink-0 rounded-full ${GU[c]}`,"aria-hidden":"true"}),a.jsx("span",{className:"truncate",children:u}),s.avgDeliveryLatencyMs!=null&&a.jsxs(a.Fragment,{children:[a.jsx("span",{"aria-hidden":"true",children:"·"}),a.jsx("span",{children:f})]})]})}),a.jsx(yn,{side:"bottom",children:m})]}):a.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[a.jsx("span",{className:`size-2 shrink-0 rounded-full ${GU[c]}`,"aria-hidden":"true"}),d?a.jsx("button",{type:"button",onClick:t,className:"truncate text-left hover:underline","aria-label":`${u} — click to view failures`,children:u}):a.jsx("span",{className:"truncate",children:u})]})})})}function Ytt(){const e=am(),[t,n]=x.useState("connections"),[s,r]=x.useState(!1),[i,o]=x.useState(!1),l=x.useRef(null),{connectionState:c}=AQe(e),{data:u=[]}=S0(e),d=u.some(m=>m.instances.length>0),f=x.useCallback(()=>{n("activity"),o(!0),setTimeout(()=>o(!1),100),setTimeout(()=>{var m;(m=l.current)==null||m.scrollIntoView({behavior:"smooth",block:"start"})},150)},[]);return e?a.jsx(Ue,{mode:"wait",children:d?a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"flex h-full flex-col",children:a.jsxs(CT,{value:t,onValueChange:n,className:"flex h-full flex-col",children:[a.jsx(Wtt,{enabled:e,onFailedClick:f}),a.jsx(p9e,{connectionState:c,className:"mx-4 mt-2"}),a.jsxs(Mb,{className:"mx-4 mt-3 shrink-0",children:[a.jsx(_c,{value:"connections",children:"Connections"}),a.jsx(_c,{value:"activity",children:"Activity"})]}),a.jsx(Ue,{mode:"wait",children:a.jsxs(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"min-h-0 flex-1 overflow-y-auto",children:[a.jsx(Vp,{value:"connections",className:"h-full",children:a.jsx(qU,{enabled:e})}),a.jsx(Vp,{value:"activity",className:"h-full",children:a.jsx(ytt,{enabled:e,deadLetterRef:l,onSwitchToChannels:()=>n("connections"),autoShowFailures:i})})]},t)})]})},"mode-b"):a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"flex h-full flex-col",children:s?a.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:a.jsx(qU,{enabled:e})}):a.jsx(Vtt,{onAddChannel:()=>r(!0)})},"mode-a")}):a.jsx(h4,{icon:fne,name:"Relay",description:"Relay provides inter-agent messaging. Start DorkOS with relay enabled.",command:"DORKOS_RELAY_ENABLED=true dorkos"})}const UA={"meet-dorkbot":"Meet DorkBot",discovery:"Create agents",tasks:"Set up Tasks schedules",adapters:"Connect adapters"},Ztt=["discovery","tasks"];function Xtt({onStepClick:e,onDismiss:t}){const{state:n}=Wb(),s=Ds();return a.jsxs(te.div,{initial:s?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3},className:"border-border bg-card relative rounded-lg border p-3",children:[a.jsx("button",{onClick:t,className:"text-muted-foreground/50 hover:text-muted-foreground absolute top-1.5 right-1.5 rounded-md p-0.5 transition-colors duration-150","aria-label":"Dismiss getting started",children:a.jsx(es,{className:"size-3.5"})}),a.jsx("h3",{className:"mb-2 text-xs font-medium",children:"Getting Started"}),a.jsx("ul",{className:"space-y-1",children:Ztt.map((r,i)=>{const o=n.completedSteps.includes(r),l=n.skippedSteps.includes(r);return o?a.jsxs("li",{className:"flex items-center gap-2 py-0.5",children:[a.jsx(Lt,{className:"text-primary size-3.5 shrink-0"}),a.jsx("span",{className:"text-muted-foreground text-xs",children:UA[r]})]},r):l?a.jsxs("li",{className:"flex items-center gap-2 py-0.5",children:[a.jsx(IMe,{className:"text-muted-foreground/40 size-3.5 shrink-0"}),a.jsx("button",{onClick:()=>e(i),className:Y("text-muted-foreground/40 text-left text-xs transition-colors duration-150","hover:text-muted-foreground"),children:UA[r]})]},r):a.jsxs("li",{className:"flex items-center gap-2 py-0.5",children:[a.jsx(dh,{className:"text-muted-foreground size-3.5 shrink-0"}),a.jsx("button",{onClick:()=>e(i),className:"text-foreground text-left text-xs transition-colors duration-150 hover:underline",children:UA[r]})]},r)})})]})}function Qtt(e){return`set${e.charAt(0).toUpperCase()}${e.slice(1)}`}function Jtt(e){const t=t0(),n=Kh(),s=Wh();switch(e){case"settings":return{isOpen:t.isOpen,close:t.close};case"tasks":return{isOpen:n.isOpen,close:n.close};case"relay":return{isOpen:s.isOpen,close:s.close};default:return{isOpen:!1,close:()=>{}}}}function ent({contribution:e}){const t=we(u=>u[e.openStateKey]),n=we(u=>u[Qtt(e.openStateKey)]),s=Jtt(e.urlParam),r=s.isOpen,i=s.close,o=t||r,l=x.useCallback(u=>{n(u),!u&&r&&i()},[n,r,i]),c=e.component;return a.jsx(c,{open:o,onOpenChange:l})}function tnt(){const e=Od("dialog"),t=we(s=>s.onboardingStep),n=we(s=>s.setOnboardingStep);return a.jsxs(a.Fragment,{children:[e.map(s=>a.jsx(ent,{contribution:s},s.id)),t!==null&&a.jsx("div",{className:"bg-background fixed inset-0 z-50",children:a.jsx(Ice,{initialStep:t,onComplete:()=>n(null)})})]})}function nnt(){const{theme:e,setTheme:t}=yb(),{fontFamily:n,setFontFamily:s,fontSize:r,setFontSize:i,resetPreferences:o}=we();return a.jsxs("div",{className:"space-y-4",children:[a.jsx(l0,{actions:a.jsx("button",{onClick:()=>{o(),t("system")},className:"text-muted-foreground hover:text-foreground text-xs transition-colors duration-150",children:"Reset to defaults"}),children:"Appearance"}),a.jsx(vr,{children:a.jsxs(dr,{children:[a.jsx(cs,{label:"Theme",description:"Choose your preferred color scheme",children:a.jsxs(On,{value:e,onValueChange:t,children:[a.jsx(_n,{className:"w-32",children:a.jsx(In,{})}),a.jsxs(Nn,{children:[a.jsx(mt,{value:"light",children:"Light"}),a.jsx(mt,{value:"dark",children:"Dark"}),a.jsx(mt,{value:"system",children:"System"})]})]})}),a.jsx(cs,{label:"Font family",description:"Choose the typeface for the interface",children:a.jsxs(On,{value:n,onValueChange:l=>s(l),children:[a.jsx(_n,{className:"w-40",children:a.jsx(In,{})}),a.jsx(Nn,{children:Ak.map(l=>a.jsx(mt,{value:l.key,children:a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{children:l.displayName}),a.jsx("span",{className:"text-muted-foreground text-xs",children:l.description})]})},l.key))})]})}),a.jsx(cs,{label:"Font size",description:"Adjust the text size across the interface",children:a.jsxs(On,{value:r,onValueChange:l=>i(l),children:[a.jsx(_n,{className:"w-32",children:a.jsx(In,{})}),a.jsxs(Nn,{children:[a.jsx(mt,{value:"small",children:"Small"}),a.jsx(mt,{value:"medium",children:"Medium"}),a.jsx(mt,{value:"large",children:"Large"})]})]})})]})})]})}function snt(){const{showTimestamps:e,setShowTimestamps:t,expandToolCalls:n,setExpandToolCalls:s,autoHideToolCalls:r,setAutoHideToolCalls:i,devtoolsOpen:o,toggleDevtools:l,showShortcutChips:c,setShowShortcutChips:u,showTaskCelebrations:d,setShowTaskCelebrations:f,enableNotificationSound:m,setEnableNotificationSound:g,enableTasksNotifications:y,setEnableTasksNotifications:b,promoEnabled:S,setPromoEnabled:w}=we();return a.jsxs("div",{className:"space-y-4",children:[a.jsx(l0,{children:"Preferences"}),a.jsx(vr,{children:a.jsxs(dr,{children:[a.jsx(Zi,{label:"Show timestamps",description:"Display message timestamps in chat",checked:e,onCheckedChange:t}),a.jsx(Zi,{label:"Expand tool calls",description:"Auto-expand tool call details in messages",checked:n,onCheckedChange:s}),a.jsx(Zi,{label:"Auto-hide tool calls",description:"Fade out completed tool calls after a few seconds",checked:r,onCheckedChange:i}),a.jsx(Zi,{label:"Show shortcut chips",description:"Display shortcut hints below the message input",checked:c,onCheckedChange:u}),a.jsx(Zi,{label:"Task celebrations",description:"Show animations when tasks complete",checked:d,onCheckedChange:f}),a.jsx(Zi,{label:"Notification sound",description:"Play a sound when AI finishes responding (3s+ responses)",checked:m,onCheckedChange:g}),a.jsx(Zi,{label:"Tasks run notifications",description:"Show a toast when a scheduled Tasks run completes",checked:y,onCheckedChange:b}),a.jsx(Zi,{label:"Feature suggestions",description:"Show feature discovery cards on the dashboard and sidebar",checked:S,onCheckedChange:w}),a.jsx(Zi,{label:"Show dev tools",description:"Enable developer tools panel",checked:o,onCheckedChange:()=>l()})]})})]})}const zce=he.createContext(null);function rnt(){const e=he.useContext(zce);if(!e)throw new Error("StatusLine.Item must be used within a StatusLine.");return e}const int={duration:.2,ease:[.4,0,.2,1]};function ant({sessionId:e,isStreaming:t,children:n}){const[s,r]=x.useState([]),i=x.useCallback(d=>{r(f=>f.includes(d)?f:[...f,d])},[]),o=x.useCallback(d=>{r(f=>f.filter(m=>m!==d))},[]),l=s[0]??null,c=s.length>0,u=x.useMemo(()=>({itemTransition:int,firstVisibleKey:l,registerItem:i,unregisterItem:o}),[l,i,o]);return a.jsxs(zce.Provider,{value:u,children:[a.jsx(Ue,{initial:!1,children:c&&a.jsx(te.div,{role:"toolbar","aria-label":"Session status","aria-live":"polite","data-testid":"status-line",initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:[.4,0,.2,1]},className:"overflow-hidden",children:a.jsx(cnt,{children:a.jsx(Ue,{initial:!1,mode:"popLayout",children:he.Children.map(n,d=>{if(!he.isValidElement(d))return d;const f=d.props.itemKey;return f?he.cloneElement(d,{key:f}):d})})})})}),!c&&n]})}function ont({itemKey:e,visible:t,children:n}){const{itemTransition:s,firstVisibleKey:r,registerItem:i,unregisterItem:o}=rnt();if(x.useEffect(()=>{if(t)return i(e),()=>o(e)},[t,e,i,o]),!t)return null;const l=e===r;return a.jsxs(te.div,{layout:"position",initial:{opacity:0,scale:.8,filter:"blur(4px)"},animate:{opacity:1,scale:1,filter:"blur(0px)"},exit:{opacity:0,scale:.8,filter:"blur(4px)"},transition:s,className:"inline-flex items-center gap-2",children:[!l&&a.jsx(lnt,{}),n]},e)}function lnt(){return a.jsx("span",{className:"text-muted-foreground/30","aria-hidden":"true",children:"·"})}function cnt({children:e}){const t=x.useRef(null),[n,s]=x.useState(!1),r=x.useCallback(()=>{const i=t.current;i&&s(i.scrollWidth-i.scrollLeft-i.clientWidth>1)},[]);return x.useEffect(()=>{const i=t.current;if(!i)return;r(),i.addEventListener("scroll",r,{passive:!0});const o=new ResizeObserver(r);return o.observe(i),()=>{i.removeEventListener("scroll",r),o.disconnect()}},[r]),a.jsxs("div",{className:"relative",children:[a.jsx("div",{ref:t,className:"text-muted-foreground scrollbar-none flex items-center gap-2 overflow-x-auto px-1 text-xs whitespace-nowrap",children:e}),a.jsx("div",{className:Y("from-background pointer-events-none absolute top-0 right-0 bottom-0 w-8 bg-gradient-to-l to-transparent transition-opacity duration-200",n?"opacity-100":"opacity-0"),"aria-hidden":!0})]})}const Wi=Object.assign(ant,{Item:ont});function unt({cwd:e}){const t=e.split("/").filter(Boolean).pop()??e;return a.jsxs("span",{className:"inline-flex items-center gap-1",title:e,children:[a.jsx(th,{className:"size-(--size-icon-xs)"}),a.jsx("span",{children:t})]})}HO(FO);const VA={DORKOS_PORT:0,VITE_PORT:1,SITE_PORT:2};function Bce(e){return{DORKOS_PORT:e+VA.DORKOS_PORT,VITE_PORT:e+VA.VITE_PORT,SITE_PORT:e+VA.SITE_PORT}}const dnt=/^[A-Za-z0-9._-]+$/,$ce=Je(["worktree","clone"]).openapi("WorkspaceProviderType"),fnt=Je(["provisioning","ready","failed","removing"]).openapi("WorkspaceStatus");se({id:z(),projectKey:z(),key:z().regex(dnt),path:z(),source:z(),branch:z().nullable(),provider:$ce,status:fnt,portBase:Ee().int(),portBlockSize:Ee().int(),hostname:z().nullable(),url:z().nullable(),pinned:rt(),createdAt:z(),lastUsedAt:z()}).openapi("Workspace");se({projectKey:z(),key:z(),source:z(),provider:$ce.optional()}).openapi("EnsureWorkspaceRequest");function hnt(e){const t=je();return st({queryKey:["git-status",e],queryFn:()=>t.getGitStatus(e??void 0),enabled:!!e,refetchInterval:ia.GIT_STATUS_REFETCH_MS,refetchIntervalInBackground:!1,staleTime:ia.GIT_STATUS_STALE_TIME_MS})}function mnt(e){return!!e&&!("error"in e)}function pnt({data:e,workspace:t}){if(!e)return null;if(!mnt(e))return a.jsxs("span",{className:"text-muted-foreground/50 inline-flex items-center gap-1",title:"Not a git repository",children:[a.jsx($p,{className:"size-(--size-icon-xs)"}),a.jsx("span",{children:"No repo"})]});const n=e.modified+e.staged+e.untracked,s=n===1?"1 change":`${n} changes`,r=[];if(e.modified>0&&r.push(`${e.modified} modified`),e.staged>0&&r.push(`${e.staged} staged`),e.untracked>0&&r.push(`${e.untracked} untracked`),e.conflicted>0&&r.push(`${e.conflicted} conflicted`),t){const o=Bce(t.portBase),l=[`${t.branch??e.branch} · ${t.provider}`,e.ahead>0?`↑${e.ahead}`:"",e.behind>0?`↓${e.behind}`:"",r.length>0?r.join(", "):"clean",`ports ${o.DORKOS_PORT} / ${o.VITE_PORT} / ${o.SITE_PORT}`,t.pinned?"pinned":""].filter(Boolean);return a.jsxs("span",{className:"inline-flex items-center gap-1",title:l.join(" · "),children:[a.jsx($p,{className:"size-(--size-icon-xs)"}),a.jsx("span",{className:"max-w-[20ch] truncate font-medium",children:t.key}),a.jsxs("span",{className:"text-muted-foreground",children:["· ",t.projectKey]}),t.pinned&&a.jsx(gb,{className:"text-muted-foreground size-(--size-icon-xs)"}),n>0&&a.jsxs("span",{className:"text-muted-foreground",children:["· ",s]})]})}const i=r.length>0?`${e.branch} · ${r.join(", ")}`:`${e.branch} · clean`;return a.jsxs("span",{className:"inline-flex items-center gap-1",title:i,children:[a.jsx($p,{className:"size-(--size-icon-xs)"}),a.jsx("span",{className:"max-w-[25ch] truncate",children:e.branch}),e.ahead>0&&a.jsxs("span",{className:"text-muted-foreground inline-flex items-center gap-0.5",children:[a.jsx(mb,{className:"size-(--size-icon-xs)"}),e.ahead]}),e.behind>0&&a.jsxs("span",{className:"text-muted-foreground inline-flex items-center gap-0.5",children:[a.jsx(hb,{className:"size-(--size-icon-xs)"}),e.behind]}),n>0&&a.jsxs("span",{className:"text-muted-foreground",children:["· ",s]})]})}const KU={default:Hc,acceptEdits:xb,plan:zAe,dontAsk:pb,bypassPermissions:Q5,auto:Jg,"always-allow":Lt,"always-deny":Xg,scripted:G5},WU={bypassPermissions:!0,auto:!0,"always-allow":!0},YU=Hc,gnt={auto:"Preview"},xnt="Auto mode requires Opus 4.6+ or Sonnet 4.6",ynt={default:"Default",acceptEdits:"Accept Edits",plan:"Plan Mode",dontAsk:"Don't Ask",bypassPermissions:"Bypass All",auto:"Auto"};function vnt({mode:e,onChangeMode:t,disabled:n,runtime:s,modelSupportsAutoMode:r}){const i=tP(s);if(i&&!i.permissionModes.supported)return null;const o=(i==null?void 0:i.permissionModes.values)??[],l=!r&&o.some(y=>y.id==="auto"),c=l?o.filter(y=>y.id!=="auto"):o,u=c.find(y=>y.id===e),d=(u==null?void 0:u.label)??ynt[e]??e,f=KU[e]??YU,m=WU[e]??!1,g=a.jsxs("button",{disabled:n,className:`hover:text-foreground inline-flex items-center gap-1 transition-colors duration-150 disabled:cursor-not-allowed disabled:opacity-40 ${m?"text-red-500":""}`,children:[a.jsx(f,{className:"size-(--size-icon-xs)"}),a.jsx("span",{children:d})]});return n?a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx("span",{className:"inline-flex",children:g})}),a.jsx(yn,{side:"top",children:"Send a message first"})]}):a.jsxs(i4,{children:[a.jsx(a4,{asChild:!0,children:g}),a.jsxs(o4,{side:"top",align:"start",className:"w-56",children:[a.jsx(l4,{children:"Permission Mode"}),a.jsx(Nie,{value:e,onValueChange:y=>t(y),children:c.map(y=>{const b=KU[y.id]??YU,S=WU[y.id]??!1,w=gnt[y.id];return a.jsx(jie,{value:y.id,icon:b,description:y.description,className:S?"text-red-500":"",children:a.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[y.label,w&&a.jsx("span",{className:"bg-muted text-muted-foreground rounded px-1 py-px text-[10px] font-medium tracking-wide uppercase",children:w})]})},y.id)})}),l&&a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsxs("p",{"data-testid":"auto-unsupported-hint",className:"text-muted-foreground flex items-center gap-1.5 px-2 py-1.5 text-[10px]",children:[a.jsx(Jg,{className:"size-(--size-icon-xs) shrink-0"}),"Auto unavailable on this model"]})}),a.jsx(yn,{side:"top",children:xnt})]})]})]})}function bnt(e){const t=je(),n=et(),s=Bt({mutationFn:r=>t.storeRuntimeCredential(e,r),onSuccess:()=>{n.invalidateQueries({queryKey:[...Wc]})}});return{store:r=>{r.trim().length!==0&&s.mutate(r)},isPending:s.isPending,isSuccess:s.isSuccess,isError:s.isError,errorMessage:s.isError?s.error.message??"Could not save the API key.":null,reset:s.reset}}function Snt(e){var o,l,c;const t=je(),n=et(),s=Bt({mutationFn:()=>t.delegateRuntimeLogin(e),onSuccess:u=>{u.ok&&n.invalidateQueries({queryKey:[...Wc]})}}),r=s.isError||((o=s.data)==null?void 0:o.ok)===!1,i=s.isError?s.error.message:((l=s.data)==null?void 0:l.error)??null;return{login:()=>s.mutate(),isPending:s.isPending,isSuccess:((c=s.data)==null?void 0:c.ok)===!0,isError:r,errorMessage:r?i??"Sign-in failed. Please try again.":null}}function vd({message:e}){const t=Ds();return a.jsxs(te.div,{className:"bg-muted flex items-center gap-2 rounded-lg px-3 py-2.5",initial:t?!1:{opacity:0},animate:{opacity:1},"data-testid":"connect-progress",children:[a.jsx(te.span,{className:"text-muted-foreground inline-flex",animate:t?{}:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:a.jsx(Sn,{className:"size-3.5"})}),a.jsx(Ue,{mode:"wait",children:a.jsx(te.span,{className:"truncate text-xs",initial:t?!1:{opacity:0},animate:{opacity:1},exit:t?void 0:{opacity:0},transition:{duration:.2},children:e},e)})]})}function XT({message:e="Connected"}){return a.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-3 py-2.5 text-xs text-emerald-500","data-testid":"connect-connected",children:[a.jsx(Lt,{className:"size-3.5"}),e]})}function QT({message:e,onRetry:t}){return a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-destructive text-xs",role:"alert",children:e}),a.jsx(ge,{size:"sm",onClick:t,children:"Try again"})]})}const ZU={"claude-code":{signInLabel:"Sign in",signInHint:"Use your Claude subscription or Anthropic account.",signInPending:"Waiting for sign-in to complete…",keyLabel:"Anthropic API key",keyPlaceholder:"sk-ant-…",getKeyUrl:"https://console.anthropic.com/settings/keys"},codex:{signInLabel:"Sign in with ChatGPT",signInHint:"Use your ChatGPT account.",signInPending:"Waiting for sign-in to complete…",keyLabel:"OpenAI API key",keyPlaceholder:"sk-…",getKeyUrl:"https://platform.openai.com/api-keys"}};function wnt({type:e}){const t=ZU[e]??ZU["claude-code"],n=Snt(e);return a.jsxs("div",{className:"space-y-4","data-testid":`login-connect-${e}`,children:[a.jsx("div",{className:"space-y-2",children:n.isPending?a.jsx(vd,{message:t.signInPending}):n.isSuccess?a.jsx(XT,{message:"Signed in"}):n.isError?a.jsx(QT,{message:n.errorMessage??"Sign-in failed.",onRetry:n.login}):a.jsxs(a.Fragment,{children:[a.jsx(ge,{size:"sm",className:"w-full",onClick:n.login,children:t.signInLabel}),a.jsx("p",{className:"text-muted-foreground text-xs",children:t.signInHint})]})}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"bg-border h-px flex-1"}),a.jsx("span",{className:"text-muted-foreground text-2xs tracking-wide uppercase",children:"or"}),a.jsx("span",{className:"bg-border h-px flex-1"})]}),a.jsx(knt,{type:e,copy:t})]})}function knt({type:e,copy:t}){const[n,s]=x.useState(""),r=bnt(e);return r.isPending?a.jsx(vd,{message:"Saving your API key…"}):r.isSuccess?a.jsx(XT,{}):a.jsxs("form",{className:"space-y-2",onSubmit:i=>{i.preventDefault(),r.store(n)},children:[a.jsx(Rt,{htmlFor:`api-key-${e}`,className:"text-xs",children:t.keyLabel}),a.jsx(il,{id:`api-key-${e}`,value:n,onChange:i=>s(i.target.value),placeholder:t.keyPlaceholder,autoComplete:"off",spellCheck:!1}),r.isError&&a.jsx("p",{className:"text-destructive text-xs",role:"alert",children:r.errorMessage}),a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.getKeyUrl?a.jsxs("a",{href:t.getKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:["Get an API key ",a.jsx(fa,{className:"size-3"})]}):a.jsx("span",{}),a.jsx(ge,{type:"submit",size:"sm",variant:"outline",disabled:n.trim().length===0,children:"Save key"})]})]})}const JT="ollama";function Cnt(e){const t=je();return st({queryKey:["runtime-connect","ollama"],queryFn:()=>t.detectOllama(),enabled:e,staleTime:3e4})}function Ent(){const e=je(),t=et(),n=Bt({mutationFn:s=>e.updateConfig({runtimes:{opencode:{provider:JT}}}),onSuccess:()=>{t.invalidateQueries({queryKey:[...Wc]})}});return{connect:s=>n.mutate(s),isPending:n.isPending,isSuccess:n.isSuccess,isError:n.isError,errorMessage:n.isError?n.error.message??"Could not connect to Ollama.":null}}function Tnt(){const e=je(),t=et(),n=Bt({mutationFn:({providerId:s,key:r,baseURL:i})=>e.storeProviderCredential(s,r,(i==null?void 0:i.trim())||null),onSuccess:()=>{t.invalidateQueries({queryKey:[...Wc]})}});return{connect:s=>{s.key.trim().length===0||s.providerId.trim().length===0||n.mutate(s)},isPending:n.isPending,isSuccess:n.isSuccess,isError:n.isError,errorMessage:n.isError?n.error.message??"Could not save the provider key.":null}}function _nt(e){const t=je();return st({queryKey:["runtime-connect","ollama","catalog"],queryFn:()=>t.getOllamaModelCatalog(),enabled:e,staleTime:6e4})}function Nnt(){var l,c;const e=je(),t=et(),[n,s]=x.useState(null),r=Bt({mutationFn:async u=>{s(null);const d=await e.pullOllamaModel(u,f=>s(f));return d.ok&&await e.updateConfig({runtimes:{opencode:{provider:JT}}}),d},onSuccess:u=>{u.ok&&t.invalidateQueries({queryKey:[...Wc]})}}),i=r.isError||((l=r.data)==null?void 0:l.ok)===!1,o=r.isError?r.error.message:((c=r.data)==null?void 0:c.error)??null;return{pull:u=>r.mutate(u),isPending:r.isPending,isError:i,errorMessage:i?o??"The pull could not be completed.":null,progress:n,result:r.data}}const jnt="https://ollama.com/search?c=code",Ant={"runs-well":{label:"Runs well on your machine",tone:"text-emerald-600 dark:text-emerald-400"},"may-be-slow":{label:"May be slow on your machine",tone:"text-amber-600 dark:text-amber-400"},"too-large":{label:"Too large for your machine",tone:"text-destructive"}};function Rnt(){var l,c;const e=_nt(!0),t=Nnt();if(t.isPending)return a.jsx(Mnt,{progress:t.progress});const n=(l=e.data)==null?void 0:l.models[0];if((c=t.result)!=null&&c.ok&&n)return a.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-3 py-2.5 text-xs text-emerald-500","data-testid":"guided-pull-connected",children:[a.jsx(Lt,{className:"size-3.5 shrink-0"}),a.jsx("span",{children:"Connected —"}),a.jsx(vD,{runtime:"opencode",model:n.model.id,className:"text-xs"})]});if(t.isError&&n)return a.jsx(QT,{message:t.errorMessage??"The pull could not be completed.",onRetry:()=>t.pull(n.model.id)});if(e.isPending)return a.jsx(vd,{message:"Checking which models fit your machine…"});if(!n)return a.jsxs("div",{className:"space-y-2","data-testid":"ollama-no-model",children:[a.jsx("p",{className:"text-muted-foreground text-xs",children:"Ollama is running, but no coding model is pulled yet. Browse Ollama’s models to pull one."}),a.jsx(XU,{})]});const{model:s,verdict:r,explanation:i}=n,o=Ant[r];return a.jsxs("div",{className:"space-y-3","data-testid":"ollama-no-model",children:[a.jsx("p",{className:"text-muted-foreground text-xs",children:"Ollama is running, but no coding model is pulled yet. Pull a curated coding model to connect — private and free, on your machine."}),a.jsxs("div",{className:"border-border space-y-2.5 rounded-lg border p-3","data-testid":"guided-pull-card",children:[a.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[a.jsx("span",{className:"text-sm font-medium",children:s.label}),a.jsx("span",{className:"text-muted-foreground text-xs","data-testid":"guided-pull-size",children:s.sizeLabel})]}),a.jsxs("div",{className:"space-y-0.5","data-testid":"guided-pull-verdict","data-verdict":r,children:[a.jsx("p",{className:Y("text-xs font-medium",o.tone),children:o.label}),a.jsx("p",{className:"text-muted-foreground/80 text-[11px] leading-snug",children:i})]}),a.jsx(nP,{provider:JT,modelId:s.id,detail:!0}),a.jsxs(ge,{size:"sm",className:"w-full",disabled:r==="too-large",onClick:()=>t.pull(s.id),"data-testid":"guided-pull-start",children:["Pull ",s.label]})]}),a.jsx(XU,{})]})}function XU(){return a.jsxs("a",{href:jnt,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:["Browse Ollama models ",a.jsx(fa,{className:"size-3"})]})}function Mnt({progress:e}){const t=Ds(),n=e==null?void 0:e.percent,s=(e==null?void 0:e.status)??"Starting download…";return a.jsxs("div",{className:"space-y-2","data-testid":"guided-pull-progress",children:[a.jsx("div",{className:"bg-muted h-2 w-full overflow-hidden rounded-full",children:n===void 0?a.jsx(te.div,{className:"bg-primary/70 h-full w-1/3 rounded-full",animate:t?{}:{x:["-100%","300%"]},transition:{duration:1.2,repeat:1/0,ease:"easeInOut"}}):a.jsx(te.div,{className:"bg-primary h-full rounded-full",initial:!1,animate:{width:`${Math.min(100,Math.max(0,n))}%`},transition:t?{duration:0}:{duration:.3,ease:"easeOut"},"data-testid":"guided-pull-bar"})}),a.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-xs",children:[a.jsx(te.span,{className:"inline-flex",animate:t?{}:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:a.jsx(Sn,{className:"size-3.5"})}),a.jsx(Ue,{mode:"wait",children:a.jsxs(te.span,{className:"truncate",initial:t?!1:{opacity:0},animate:{opacity:1},exit:t?void 0:{opacity:0},transition:{duration:.2},children:[s,n!==void 0?` · ${Math.round(n)}%`:""]},s)})]})]})}const Dnt="https://ollama.com/download";function Ont({active:e}){const t=Cnt(e),n=Ent();if(n.isSuccess)return a.jsx(XT,{message:"Connected to Ollama"});if(n.isPending)return a.jsx(vd,{message:"Connecting to Ollama…"});if(n.isError)return a.jsx(QT,{message:n.errorMessage??"Could not connect to Ollama.",onRetry:()=>t.refetch()});if(t.isPending)return a.jsx(vd,{message:"Looking for Ollama on your machine…"});const s=t.data,r=(s==null?void 0:s.running)??!1,i=(s==null?void 0:s.models)??[];return r?i.length===0?a.jsx(Rnt,{}):a.jsxs("div",{className:"space-y-2","data-testid":"ollama-models",children:[a.jsx("p",{className:"text-muted-foreground text-xs",children:"Private and free: runs on your machine; your code never leaves it."}),a.jsx("ul",{className:"space-y-1.5",children:i.map(o=>a.jsxs("li",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[a.jsx("span",{className:"truncate text-sm",children:o.name}),a.jsx(nP,{provider:JT,modelId:o.name})]}),a.jsx(ge,{size:"sm",onClick:()=>n.connect(o.name),children:"Use this"})]},o.name))})]}):a.jsxs("div",{className:"space-y-3","data-testid":"ollama-absent",children:[a.jsx("p",{className:"text-muted-foreground text-xs",children:"Ollama isn’t running. Install it to run models locally — private and free, on your machine."}),a.jsx("a",{href:Dnt,target:"_blank",rel:"noopener noreferrer",className:"inline-flex",children:a.jsxs(ge,{size:"sm",variant:"outline",className:"gap-1.5",children:["Install Ollama ",a.jsx(fa,{className:"size-3.5"})]})})]})}const bP=["runtime-connect","openrouter","models"];function Int(e){const t=je();return st({queryKey:[...bP],queryFn:()=>t.getOpenRouterModels(),enabled:e,staleTime:5*6e4})}function Pnt(){var i,o,l;const e=je(),t=et(),n=Bt({mutationFn:c=>e.storeOpenRouterKey(c),onSuccess:c=>{c.ok&&(t.invalidateQueries({queryKey:[...Wc]}),t.invalidateQueries({queryKey:[...bP]}))}}),s=n.isError||((i=n.data)==null?void 0:i.ok)===!1,r=n.isError?n.error.message:((o=n.data)==null?void 0:o.error)??null;return{store:c=>{c.trim().length!==0&&n.mutate(c)},isPending:n.isPending,isSuccess:((l=n.data)==null?void 0:l.ok)===!0,isError:s,errorMessage:s?r??"Could not save the OpenRouter key.":null}}function Lnt(){var m,g;const e=je(),t=et(),[n,s]=x.useState(null),[r,i]=x.useState(null),o=Bt({mutationFn:()=>e.startOpenRouterOAuth(),onMutate:()=>i(null),onSuccess:({authorizeUrl:y,state:b})=>{window.open(y,"_blank","noopener,noreferrer"),s(b)},onError:y=>i(y.message??"Could not start OpenRouter sign-in.")}),l=st({queryKey:["runtime-connect","openrouter","oauth",n],queryFn:()=>e.getOpenRouterOAuthStatus(n),enabled:n!==null,refetchInterval:y=>{var b;return((b=y.state.data)==null?void 0:b.status)==="pending"?1500:!1}}),c=(m=l.data)==null?void 0:m.status;x.useEffect(()=>{c==="connected"&&(t.invalidateQueries({queryKey:[...Wc]}),t.invalidateQueries({queryKey:[...bP]}))},[c,t]);const u=o.isPending||n!==null&&c==="pending",d=!!r||c==="error",f=d?r??((g=l.data)==null?void 0:g.error)??"OpenRouter sign-in failed. Please try again.":null;return{begin:()=>o.mutate(),isPending:u,isSuccess:c==="connected",isError:d,errorMessage:f}}const Fnt="https://openrouter.ai/keys";function znt(){const[e,t]=x.useState(""),n=Pnt(),s=Lnt();return n.isSuccess||s.isSuccess?a.jsx(Bnt,{}):a.jsxs("div",{className:"space-y-4","data-testid":"openrouter-gateway",children:[a.jsx("div",{className:"space-y-2",children:s.isPending?a.jsx(vd,{message:"Finish signing in to OpenRouter in the new tab…"}):s.isError?a.jsx(QT,{message:s.errorMessage??"OpenRouter sign-in failed.",onRetry:s.begin}):a.jsxs(a.Fragment,{children:[a.jsx(ge,{size:"sm",className:"w-full",onClick:s.begin,children:"Connect OpenRouter"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Creates a scoped key automatically — no copy-paste."})]})}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"bg-border h-px flex-1"}),a.jsx("span",{className:"text-muted-foreground text-2xs tracking-wide uppercase",children:"or"}),a.jsx("span",{className:"bg-border h-px flex-1"})]}),n.isPending?a.jsx(vd,{message:"Checking your OpenRouter key…"}):a.jsxs("form",{className:"space-y-2",onSubmit:i=>{i.preventDefault(),n.store(e)},children:[a.jsx(Rt,{htmlFor:"openrouter-key",className:"text-xs",children:"OpenRouter key"}),a.jsx(il,{id:"openrouter-key",value:e,onChange:i=>t(i.target.value),placeholder:"sk-or-…",autoComplete:"off",spellCheck:!1}),n.isError&&a.jsx("p",{className:"text-destructive text-xs",role:"alert",children:n.errorMessage}),a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("a",{href:Fnt,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:["Get an OpenRouter key ",a.jsx(fa,{className:"size-3"})]}),a.jsx(ge,{type:"submit",size:"sm",variant:"outline",disabled:e.trim().length===0,children:"Save key"})]})]})]})}function Bnt(){var t,n;const e=Int(!0);return a.jsxs("div",{className:"space-y-2","data-testid":"openrouter-models",children:[a.jsx("div",{className:"flex items-center gap-2 text-xs text-emerald-500",children:"Connected to OpenRouter"}),a.jsx(nP,{provider:"openrouter",modelId:"openrouter"}),a.jsx(Rt,{htmlFor:"openrouter-model",className:"text-xs",children:"Model"}),a.jsxs("select",{id:"openrouter-model",className:"border-input bg-background focus-visible:ring-ring w-full rounded-md border px-3 py-2 text-sm focus-visible:ring-1 focus-visible:outline-none",disabled:e.isPending||(((t=e.data)==null?void 0:t.length)??0)===0,children:[e.isPending&&a.jsx("option",{children:"Loading models…"}),(n=e.data)==null?void 0:n.map(s=>a.jsx("option",{value:s.id,children:s.name},s.id))]})]})}function $nt(){const[e,t]=x.useState("openai"),[n,s]=x.useState(""),[r,i]=x.useState(""),o=Tnt();return o.isPending?a.jsx(vd,{message:"Saving your provider key…"}):o.isSuccess?a.jsx(XT,{}):a.jsxs("form",{className:"space-y-3","data-testid":"direct-provider",onSubmit:l=>{l.preventDefault(),o.connect({providerId:e,key:n,baseURL:r})},children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:"direct-provider-id",className:"text-xs",children:"Provider"}),a.jsx(sn,{id:"direct-provider-id",value:e,onChange:l=>t(l.target.value),placeholder:"openai",autoComplete:"off",spellCheck:!1})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:"direct-provider-key",className:"text-xs",children:"API key"}),a.jsx(il,{id:"direct-provider-key",value:n,onChange:l=>s(l.target.value),placeholder:"sk-…",autoComplete:"off",spellCheck:!1})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs(Rt,{htmlFor:"direct-provider-base-url",className:"text-xs",children:["Base URL ",a.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),a.jsx(sn,{id:"direct-provider-base-url",value:r,onChange:l=>i(l.target.value),placeholder:"https://api.example.com/v1",autoComplete:"off",spellCheck:!1})]}),o.isError&&a.jsx("p",{className:"text-destructive text-xs",role:"alert",children:o.errorMessage}),a.jsx(ge,{type:"submit",size:"sm",className:"w-full",disabled:n.trim().length===0||e.trim().length===0,children:"Connect provider"})]})}function Hnt(){const[e,t]=x.useState("local");return a.jsxs(CT,{value:e,onValueChange:n=>t(n),"data-testid":"opencode-provider-picker",children:[a.jsxs(Mb,{className:"w-full",children:[a.jsx(_c,{value:"local",className:"flex-1",children:"Local"}),a.jsx(_c,{value:"gateway",className:"flex-1",children:"Gateway"}),a.jsx(_c,{value:"direct",className:"flex-1",children:"Direct"})]}),a.jsx(Vp,{value:"local",className:"mt-3",children:a.jsx(Ont,{active:e==="local"})}),a.jsx(Vp,{value:"gateway",className:"mt-3",children:a.jsx(znt,{})}),a.jsx(Vp,{value:"direct",className:"mt-3",children:a.jsx($nt,{})})]})}function Unt({type:e,connect:t}){return t.kind==="provider-picker"?a.jsx(Hnt,{}):t.kind==="login"?a.jsx(wnt,{type:e}):null}const SP=e=>a.jsx(Unt,{...e});function Vnt({runtime:e,model:t,onChangeRuntime:n,canSelect:s}){const{data:r}=im(),{data:i}=VT(),[o,l]=x.useState({open:!1}),c=Object.keys((r==null?void 0:r.capabilities)??{}),u=c.filter(y=>xD(i,y)),d=c.filter(y=>!xD(i,y)),f=r!==void 0&&Object.values(Kle).some(y=>y.setup&&!c.includes(y.type)),m=s&&!!n&&(c.length>1||d.length>0||f),g=a.jsx(vD,{runtime:e,model:t,iconClassName:"size-(--size-icon-xs)"});return s?m?a.jsxs(a.Fragment,{children:[a.jsxs(i4,{children:[a.jsx(a4,{asChild:!0,children:a.jsx("button",{className:"hover:text-foreground transition-colors duration-150",children:a.jsx(vD,{runtime:e,model:t,iconClassName:"size-(--size-icon-xs)"})})}),a.jsxs(o4,{side:"top",align:"start",className:"w-56",children:[a.jsx(l4,{children:"Runtime"}),a.jsx(Nie,{value:e,onValueChange:y=>n==null?void 0:n(y),children:u.map(y=>{const b=Ka(y);return a.jsx(jie,{value:y,icon:b.icon,children:b.label},y)})}),d.map(y=>{const b=Ka(y);return a.jsx(F3,{icon:b.icon,description:"Connect",onSelect:()=>l({open:!0,runtime:y}),children:b.label},y)}),f&&a.jsxs(a.Fragment,{children:[a.jsx(g8e,{}),a.jsx(F3,{icon:Cs,onSelect:()=>l({open:!0}),children:"Add a runtime"})]})]})]}),a.jsx(Xle,{runtime:o.runtime,open:o.open,onOpenChange:y=>l(b=>({...b,open:y})),renderConnect:SP,onRuntimeReady:y=>{n==null||n(y),l({open:!1})}})]}):g:a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:g}),a.jsx(yn,{side:"top",children:"The runtime is set when a session starts and can't be changed afterward."})]})}function qnt({open:e,onOpenChange:t,onConfirm:n}){return a.jsx(Sl,{open:e,onOpenChange:t,children:a.jsxs(ko,{children:[a.jsxs(wl,{children:[a.jsxs(Co,{className:"flex items-center gap-2",children:[a.jsx(Jg,{className:"size-4 text-red-500"}),"Turn on Auto mode",a.jsx(zt,{variant:"secondary",className:"text-[10px] tracking-wide uppercase",children:"Preview"})]}),a.jsx(Eo,{children:"The agent runs on its own and only checks with you before risky actions — like deleting files or running unfamiliar commands. You can switch back anytime."})]}),a.jsxs(kl,{children:[a.jsx(_o,{children:"Cancel"}),a.jsx(To,{onClick:n,children:"Turn on Auto mode"})]})]})})}const ED={none:{label:"None",description:"No reasoning"},minimal:{label:"Minimal",description:"Near-zero thinking"},low:{label:"Low",description:"Fastest responses"},medium:{label:"Medium",description:"Moderate thinking"},high:{label:"High",description:"Deep reasoning"},max:{label:"Max",description:"Maximum thinking"},xhigh:{label:"XHigh",description:"Beyond maximum"}},Gnt={duration:.15,ease:"easeOut"};function Knt(e){return e>=1e6?`${Math.round(e/1e6)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function Wnt(e,t){const n=t.find(r=>r.value===e);if(n)return n.displayName;const s=e.match(/claude-(\w+)-/);return s?s[1].charAt(0).toUpperCase()+s[1].slice(1):e}function Ynt(){return a.jsx("div",{className:"space-y-2","data-testid":"model-cards-skeleton",children:Array.from({length:3}).map((e,t)=>a.jsxs("div",{className:"flex items-center gap-3 rounded-xl p-3",children:[a.jsx(Jt,{className:"size-4 rounded-full"}),a.jsxs("div",{className:"flex-1 space-y-1.5",children:[a.jsx(Jt,{className:"h-3.5 w-24"}),a.jsx(Jt,{className:"h-2.5 w-32"})]}),a.jsx(Jt,{className:"h-5 w-10 rounded-md"})]},t))})}function Znt({onRetry:e}){return a.jsxs("div",{className:"flex flex-col items-center gap-3 py-6 text-center","data-testid":"model-load-error",children:[a.jsx(Hh,{className:"text-muted-foreground size-5"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Failed to load models"}),a.jsxs("button",{onClick:e,className:"text-foreground hover:bg-accent inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs transition-colors",children:[a.jsx(ma,{className:"size-3"}),"Retry"]})]})}function Xnt({model:e,isSelected:t}){return a.jsxs("label",{className:Y("flex w-full cursor-pointer items-center gap-3 rounded-xl border p-3 transition-colors duration-150",t?"bg-secondary border-foreground/15":"border-border hover:border-muted-foreground/30 hover:bg-muted/50 opacity-70"),children:[a.jsx(bv,{value:e.value,className:"shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"text-foreground truncate text-sm font-medium",children:e.displayName}),a.jsx("div",{className:"text-muted-foreground truncate text-[11px] leading-tight",children:e.description})]}),e.contextWindow&&a.jsx(zt,{variant:"secondary",className:"shrink-0 text-[10px]",children:Knt(e.contextWindow)})]})}function Qnt({effortLevels:e,effort:t,onChangeEffort:n}){return a.jsxs("div",{children:[a.jsx("div",{className:"text-muted-foreground mb-2 text-[11px] font-medium tracking-wide uppercase",children:"Effort"}),a.jsxs("div",{className:"flex flex-wrap gap-1.5",role:"radiogroup","aria-label":"Effort level",children:[a.jsx(QU,{label:"Default",isSelected:t===null,onClick:()=>n(null)}),e.map(s=>a.jsx(QU,{label:ED[s].label,description:ED[s].description,isSelected:t===s,onClick:()=>n(s)},s))]})]})}function QU({label:e,description:t,isSelected:n,onClick:s}){const r=a.jsx("button",{role:"radio","aria-checked":n,onClick:s,className:Y("rounded-md px-2.5 py-1 text-xs font-medium transition-colors duration-150",n?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground"),children:e});return t?a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:r}),a.jsx(yn,{side:"top",className:"text-xs",children:t})]}):r}function Jnt({supportsFastMode:e,fastMode:t,onChangeFastMode:n}){return e?a.jsxs("div",{children:[a.jsx("div",{className:"text-muted-foreground mb-2 text-[11px] font-medium tracking-wide uppercase",children:"Mode"}),a.jsx("div",{className:"flex gap-1.5",children:a.jsx(est,{label:"Fast",icon:a.jsx(Uc,{className:"size-3"}),isActive:t,onToggle:()=>n(!t)})})]}):null}function est({label:e,icon:t,isActive:n,onToggle:s}){return a.jsxs("button",{role:"switch","aria-checked":n,onClick:s,className:Y("inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs font-medium transition-colors duration-150",n?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground"),children:[t,e]})}function tst({model:e,onChangeModel:t,effort:n,onChangeEffort:s,fastMode:r,onChangeFastMode:i,disabled:o,sessionId:l,runtime:c}){const{data:u,isLoading:d,isError:f,refetch:m}=aI({sessionId:l,runtime:c??void 0}),g=u??[],y=g.find(T=>T.value===e),b=(y==null?void 0:y.supportsEffort)&&y.supportedEffortLevels&&y.supportedEffortLevels.length>0,S=(y==null?void 0:y.supportsFastMode)??!1,w=n?ED[n].label:null,C=a.jsxs("button",{disabled:o,className:"hover:text-foreground inline-flex items-center gap-1 transition-colors duration-150 disabled:cursor-not-allowed disabled:opacity-40","data-testid":"model-config-trigger",children:[a.jsx(Ad,{className:"size-(--size-icon-xs)"}),a.jsx("span",{children:Wnt(e,g)}),w&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-muted-foreground text-[11px]",children:"·"}),a.jsx(zt,{variant:"secondary",className:"px-1.5 py-0 text-[10px]",children:w})]}),r&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-muted-foreground text-[11px]",children:"·"}),a.jsxs(zt,{variant:"secondary",className:"px-1.5 py-0 text-[10px]",children:[a.jsx(Uc,{className:"mr-0.5 inline size-2.5"}),"Fast"]})]})]});return o?a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx("span",{className:"inline-flex",children:C})}),a.jsx(yn,{side:"top",children:"Send a message first"})]}):a.jsxs(t4,{children:[a.jsx(n4,{asChild:!0,children:C}),a.jsxs(s4,{side:"top",align:"start",className:"w-80 p-3","data-testid":"model-config-popover",children:[a.jsx(r4,{children:"Model"}),d&&a.jsx(Ynt,{}),f&&a.jsx(Znt,{onRetry:()=>m()}),!d&&!f&&a.jsx(JI,{value:e,onValueChange:t,className:"grid-cols-1 gap-1.5","aria-label":"Model selection","data-testid":"model-card-list",children:g.map(T=>a.jsx(Xnt,{model:T,isSelected:T.value===e},T.value))}),a.jsx(Ue,{children:!d&&!f&&(b||S)&&a.jsxs(te.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:Gnt,children:[a.jsx(av,{className:"my-3"}),a.jsx("div",{className:"text-muted-foreground mb-3 text-[11px] font-medium tracking-wide uppercase",children:"Configuration"}),a.jsxs("div",{className:"space-y-3",children:[b&&a.jsx(Qnt,{effortLevels:y.supportedEffortLevels,effort:n,onChangeEffort:s}),S&&a.jsx(Jnt,{supportsFastMode:(y==null?void 0:y.supportsFastMode)??!1,fastMode:r,onChangeFastMode:i})]})]},"config")})]})]})}function qA(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function nst({cacheReadTokens:e,cacheCreationTokens:t,contextTokens:n}){const s=n??e+t,r=Math.max(0,s-e-t),i=s>0?Math.round(e/s*100):0,o=i>=70?"text-emerald-500":i>=30?"":"text-amber-500";return a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsxs("span",{className:Y("inline-flex cursor-default items-center gap-1",o),"aria-label":"Prompt cache hit rate",children:[a.jsx(Uc,{className:"size-(--size-icon-xs)"}),a.jsxs("span",{children:[i,"%"]})]})}),a.jsx(yn,{side:"top",className:"max-w-56",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("div",{className:"text-xs font-medium",children:"Prompt Cache"}),a.jsxs("div",{className:"space-y-0.5 text-[10px]",children:[a.jsxs("div",{className:"flex justify-between gap-3",children:[a.jsx("span",{className:"text-muted-foreground",children:"Cache hits"}),a.jsx("span",{children:qA(e)})]}),a.jsxs("div",{className:"flex justify-between gap-3",children:[a.jsx("span",{className:"text-muted-foreground",children:"Cache writes"}),a.jsx("span",{children:qA(t)})]}),n!=null&&n>0&&a.jsxs("div",{className:"flex justify-between gap-3",children:[a.jsx("span",{className:"text-muted-foreground",children:"Uncached"}),a.jsx("span",{children:qA(r)})]})]})]})})]})}function GA(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function sst({percent:e,contextUsage:t}){const n=t?Math.round(t.percentage):e,s=n>=95?"text-red-500":n>=80?"text-amber-500":"",r=a.jsxs("span",{className:Y("inline-flex items-center gap-1",s),children:[a.jsx(uMe,{className:"size-(--size-icon-xs)"}),a.jsxs("span",{children:[n,"%"]})]});if(!t)return r;const i=t.categories.filter(o=>o.tokens>0).sort((o,l)=>l.tokens-o.tokens);return a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx("span",{className:"inline-flex cursor-default","aria-label":"Context window usage",children:r})}),a.jsx(yn,{side:"top",className:"max-w-64",children:a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("div",{className:"text-xs font-medium",children:[GA(t.totalTokens)," / ",GA(t.maxTokens)," tokens"]}),i.length>0&&a.jsx("div",{className:"space-y-0.5",children:i.map(o=>a.jsxs("div",{className:"flex items-center justify-between gap-3 text-[10px]",children:[a.jsxs("span",{className:"flex items-center gap-1 truncate",children:[a.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full",style:{backgroundColor:o.color}}),o.name]}),a.jsx("span",{className:"text-muted-foreground shrink-0",children:GA(o.tokens)})]},o.name))})]})})]})}function JU(e){return e.kind==="subscription"&&e.utilization!=null||e.costUsd!=null}function rst({usage:e}){if(e.kind==="subscription"&&e.utilization!=null){const s=Math.round(e.utilization*100),r=e.state==="exhausted",i=e.state==="warning"||s>=80,o=r?"text-red-500":i?"text-amber-500":"",l=e.resetsAt?new Date(e.resetsAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):null;return a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsxs("span",{className:Y("inline-flex cursor-default items-center gap-1",o),"aria-label":"Subscription usage",children:[a.jsx(tne,{className:"size-(--size-icon-xs)"}),a.jsxs("span",{children:[s,"%"]})]})}),a.jsx(yn,{side:"top",className:"max-w-56",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("div",{className:"text-xs font-medium",children:"Subscription Usage"}),a.jsxs("div",{className:"space-y-0.5 text-[10px]",children:[a.jsxs("div",{className:"flex justify-between gap-3",children:[a.jsx("span",{className:"text-muted-foreground",children:"Utilization"}),a.jsxs("span",{children:[s,"%"]})]}),e.windowLabel&&a.jsxs("div",{className:"flex justify-between gap-3",children:[a.jsx("span",{className:"text-muted-foreground",children:"Window"}),a.jsx("span",{children:e.windowLabel})]}),l&&a.jsxs("div",{className:"flex justify-between gap-3",children:[a.jsx("span",{className:"text-muted-foreground",children:"Resets at"}),a.jsx("span",{children:l})]}),e.costUsd!=null&&a.jsxs("div",{className:"flex justify-between gap-3",children:[a.jsx("span",{className:"text-muted-foreground",children:"Session cost"}),a.jsxs("span",{children:["$",e.costUsd.toFixed(2)]})]}),e.detail&&a.jsx("div",{className:"text-amber-500",children:e.detail}),r&&a.jsx("div",{className:"text-red-500",children:"Rate limit reached"})]})]})})]})}if(e.costUsd==null)return null;const n=`$${e.costUsd.toFixed(2)}`;return e.detail?a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsxs("span",{className:"inline-flex cursor-default items-center gap-1","aria-label":"Session cost",children:[a.jsx(XM,{className:"size-(--size-icon-xs)"}),a.jsx("span",{children:n})]})}),a.jsx(yn,{side:"top",className:"max-w-56",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("div",{className:"text-xs font-medium",children:"Session Cost"}),a.jsx("div",{className:"text-muted-foreground text-[10px]",children:e.detail})]})})]}):a.jsxs("span",{className:"inline-flex items-center gap-1","aria-label":"Session cost",children:[a.jsx(XM,{className:"size-(--size-icon-xs)"}),a.jsx("span",{children:n})]})}function ist({enabled:e,onToggle:t}){const n=e?yne:NDe;return a.jsx("button",{onClick:t,className:"hover:text-foreground inline-flex items-center gap-1 transition-colors duration-150","aria-label":e?"Mute notification sound":"Unmute notification sound",title:e?"Sound on — click to mute":"Sound off — click to unmute",children:a.jsx(n,{className:"size-(--size-icon-xs)"})})}function ast({enabled:e,onToggle:t}){const n=e?dDe:cDe;return a.jsxs(ZI,{openDelay:300,children:[a.jsx(XI,{asChild:!0,children:a.jsx("button",{onClick:t,className:"hover:text-foreground inline-flex items-center gap-1 transition-colors duration-150","aria-label":e?"Disable background refresh":"Enable background refresh",children:a.jsx(n,{className:"size-(--size-icon-xs)"})})}),a.jsxs(QI,{side:"top",align:"center",className:"w-64 p-3",children:[a.jsxs("p",{className:"text-sm font-medium",children:["Background refresh ",e?"on":"off"]}),a.jsx("p",{className:"text-muted-foreground mt-1.5 text-xs leading-relaxed",children:e?"Messages are checked for updates periodically, even when no one is typing. Useful if agents run in the background. Turn off to reduce network usage.":"Messages only update while someone is actively responding. Turn on if you have agents running unattended and want to see their progress."})]})]})}const ost={connecting:{color:"bg-amber-500",label:"Connecting",icon:Uw,tasks:!0},connected:{color:"bg-emerald-500",label:"Connected",icon:Uw,tasks:!1},reconnecting:{color:"bg-amber-500",label:"Reconnecting",icon:Uw,tasks:!0},disconnected:{color:"bg-red-500",label:"Connection lost",icon:ZE,tasks:!1}};function lst({connectionState:e,failedAttempts:t}){const n=e!=="connected",s=ost[e],r=s.icon,i=t&&e==="reconnecting"?`Reconnecting (${t}/${kf.DISCONNECTED_THRESHOLD})`:s.label;return a.jsx(Wi.Item,{itemKey:"connection",visible:n,children:a.jsxs(ZI,{openDelay:200,children:[a.jsx(XI,{asChild:!0,children:a.jsxs("span",{className:"flex cursor-default items-center gap-1.5 text-xs",role:"status",children:[a.jsx("span",{className:Y("size-1.5 rounded-full",s.color,s.tasks&&"animate-tasks")}),a.jsx("span",{className:"text-muted-foreground",children:i})]})}),a.jsx(QI,{side:"top",align:"center",className:"w-72 p-3",children:a.jsxs("div",{className:"flex items-start gap-2.5",children:[a.jsx(r,{className:Y("mt-0.5 size-4 shrink-0",e==="disconnected"?"text-red-500":"text-amber-500")}),a.jsxs("div",{className:"min-w-0 space-y-1.5",children:[a.jsx("p",{className:"text-sm font-medium",children:i}),a.jsx(cst,{connectionState:e})]})]})})]})})}function cst({connectionState:e}){const t="text-muted-foreground text-xs leading-relaxed";return e==="connecting"?a.jsx("p",{className:t,children:"Opening the live connection to this session. New messages and updates appear once it's open."}):e==="reconnecting"?a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("p",{className:t,children:"The live connection dropped and is reconnecting automatically. Incoming messages and updates are paused — nothing is lost; anything missed replays when it reconnects."}),a.jsx("p",{className:Y(t,"text-muted-foreground/70"),children:"No action needed."})]}):a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("p",{className:t,children:"Could not re-establish the live connection after several attempts. New messages and updates will not appear until it's restored."}),a.jsx("p",{className:Y(t,"text-muted-foreground/70"),children:"Try refreshing the page. If the issue persists, check that the DorkOS server is running."})]})}function ust({subagents:e}){return a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsxs("span",{className:"inline-flex items-center gap-1",children:[a.jsx(e0,{className:"size-(--size-icon-xs)"}),a.jsxs("span",{children:[e.length," agent",e.length!==1?"s":""]})]})}),a.jsx(yn,{side:"top",className:"max-w-64",children:a.jsx("ul",{className:"space-y-1",children:e.map(t=>a.jsxs("li",{children:[a.jsx("span",{className:"font-medium",children:t.name}),t.model&&a.jsxs("span",{className:"text-muted-foreground ml-1 text-[10px]",children:["(",t.model,")"]}),a.jsx("p",{className:"text-muted-foreground line-clamp-1 text-[10px] leading-tight",children:t.description})]},t.name))})})]})}const dst={session:"Session Info",controls:"Controls"},Yb=[{key:"cwd",label:"Directory",description:"Current working directory",group:"session",icon:$c,defaultVisible:!0},{key:"git",label:"Git Status",description:"Branch name and change count",group:"session",icon:$p,defaultVisible:!0},{key:"runtime",label:"Runtime",description:"Agent runtime for this session",group:"session",icon:Zte,defaultVisible:!0},{key:"model",label:"Model",description:"Selected AI model",group:"session",icon:Ad,defaultVisible:!0},{key:"cache",label:"Cache",description:"Prompt cache hit rate",group:"session",icon:Uc,defaultVisible:!0},{key:"context",label:"Context Usage",description:"Context window utilization",group:"session",icon:wAe,defaultVisible:!0},{key:"usage",label:"Usage & cost",description:"Subscription utilization or session cost",group:"session",icon:tne,defaultVisible:!0},{key:"permission",label:"Permission Mode",description:"Agent permission level selector",group:"controls",icon:Hc,defaultVisible:!0},{key:"sound",label:"Sound",description:"Notification sound toggle",group:"controls",icon:yne,defaultVisible:!0},{key:"polling",label:"Refresh",description:"Background polling for updates",group:"controls",icon:ma,defaultVisible:!0}];function Hce(e){const t=e.charAt(0).toUpperCase()+e.slice(1),n=`showStatusBar${t}`,s=`setShowStatusBar${t}`,r=we(o=>o[n]),i=we(o=>o[s]);return[r,i]}function e_(){const e=we.getState();for(const t of Yb){const s=`setShowStatusBar${t.key.charAt(0).toUpperCase()+t.key.slice(1)}`,r=e[s];r(t.defaultVisible)}}function fst(){return["session","controls"].map(t=>({group:t,label:dst[t],items:Yb.filter(n=>n.group===t)})).filter(t=>t.items.length>0)}function hst({itemKey:e}){const t=Yb.find(i=>i.key===e),[n,s]=Hce(e);if(!t)return null;const r=t.icon;return a.jsx(cs,{label:a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(r,{className:"text-muted-foreground size-3.5 shrink-0","aria-hidden":!0}),t.label]}),description:t.description,children:a.jsx(sr,{checked:n,onCheckedChange:s,"aria-label":`Toggle ${t.label}`})})}function Uce(){const e=fst();return a.jsxs("div",{className:"flex flex-col gap-4","aria-label":"Status bar configuration",children:[e.map(t=>a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("p",{className:"text-muted-foreground px-1 text-xs font-medium tracking-wide uppercase",children:t.label}),a.jsx(vr,{children:a.jsx(dr,{children:t.items.map(n=>a.jsx(hst,{itemKey:n.key},n.key))})})]},t.group)),a.jsx(ge,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground h-auto justify-start px-1 py-1 text-xs",onClick:e_,children:"Reset to defaults"})]})}Uce.displayName="StatusBarConfigureContent";function Vce({children:e,open:t,onOpenChange:n}){return a.jsxs(t4,{open:t,onOpenChange:n,children:[a.jsx(n4,{asChild:!0,children:e}),a.jsxs(s4,{side:"top",align:"end",className:"w-72 p-3","aria-label":"Status bar configuration",children:[a.jsx(r4,{children:"Configure Status Bar"}),a.jsx(Uce,{})]})]})}Vce.displayName="StatusBarConfigurePopover";function qce(e,t){const[n,s,r]=e.split(".").map(Number),[i,o,l]=t.split(".").map(Number);return n!==i?n>i:s!==o?s>o:r>l}function mst(e,t){const[n,s]=e.split(".").map(Number),[r,i]=t.split(".").map(Number);return n!==r||s!==i}function pst({item:e}){const[t,n]=Hce(e.key);return a.jsx(Zi,{label:e.label,description:e.description,checked:t,onCheckedChange:n})}function gst(){return a.jsxs("div",{className:"space-y-4",children:[a.jsx(l0,{actions:a.jsx("button",{onClick:e_,className:"text-muted-foreground hover:text-foreground text-xs transition-colors duration-150",children:"Reset to defaults"}),children:"Status Bar"}),a.jsx(vr,{children:a.jsx(dr,{children:Yb.map(e=>a.jsx(pst,{item:e},e.key))})})]})}function xst(){const e=VT(),{data:t}=im();return a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-muted-foreground text-sm",children:"DorkOS speaks three agent runtimes: connect any of them, each ready or one click away. Run frontier models in the cloud, or your own models locally, private and free."}),a.jsx(Zle,{requirements:e.data,registeredTypes:t?Object.keys(t.capabilities):void 0,onRecheck:()=>void e.refetch(),isRechecking:e.isFetching,renderConnect:SP})]})}function yst(){const e=je(),{data:t,isLoading:n}=st({queryKey:["config"],queryFn:()=>e.getConfig(),staleTime:3e4});return a.jsx("div",{className:"space-y-3",children:n?a.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((s,r)=>a.jsxs("div",{className:"flex items-center justify-between py-1",children:[a.jsx("div",{className:"bg-muted animate-tasks h-4 w-24 rounded"}),a.jsx("div",{className:"bg-muted animate-tasks h-4 w-16 rounded"})]},r))}):t?a.jsxs("div",{className:"space-y-1",children:[t.isDevMode?a.jsxs("div",{className:"-mx-1 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 dark:border-amber-800 dark:bg-amber-950/30",children:[a.jsx("span",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:"Development Build"}),a.jsx("p",{className:"mt-0.5 text-xs text-amber-700 dark:text-amber-300",children:"Running from source — version checks disabled"})]}):a.jsxs(a.Fragment,{children:[a.jsx(nc,{label:"Version",value:t.version}),t.latestVersion&&qce(t.latestVersion,t.version)&&a.jsxs("div",{className:"-mx-1 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 dark:border-amber-800 dark:bg-amber-950/30",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("span",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:["Update available: v",t.latestVersion]})}),a.jsxs("p",{className:"mt-0.5 text-xs text-amber-700 dark:text-amber-300",children:["Run"," ",a.jsx("code",{className:"rounded bg-amber-100 px-1 py-0.5 font-mono text-[10px] dark:bg-amber-900/50",children:"npm update -g dorkos"})," ","to update"]})]})]}),a.jsx(nc,{label:"Port",value:String(t.port)}),a.jsx(nc,{label:"Uptime",value:vst(t.uptime)}),a.jsx(nc,{label:"API URL",value:`http://localhost:${t.port}`,mono:!0}),a.jsx(nc,{label:"MCP Endpoint",value:`http://localhost:${t.port}/mcp`,mono:!0}),a.jsx(nc,{label:"Working Directory",value:t.workingDirectory,mono:!0,truncate:!0}),a.jsx(nc,{label:"Data Directory",value:t.dorkHome,mono:!0,truncate:!0}),a.jsx(nc,{label:"Boundary",value:t.boundary,mono:!0,truncate:!0}),a.jsx(nc,{label:"Node.js",value:t.nodeVersion})]}):null})}function nc({label:e,value:t,mono:n,truncate:s,muted:r}){const[i,o]=wg();return a.jsxs("button",{type:"button",onClick:()=>o(t),className:"hover:bg-muted/50 active:bg-muted/70 -mx-1 flex w-full items-center justify-between gap-4 rounded px-1 py-1 transition-colors duration-100",children:[a.jsx("span",{className:"text-muted-foreground shrink-0 text-sm",children:e}),i?a.jsx("span",{className:"text-muted-foreground text-xs",children:"Copied"}):a.jsx("span",{className:Y("text-right text-sm",n&&"font-mono",s&&"max-w-48 min-w-0 truncate",r&&"text-muted-foreground"),dir:s?"rtl":void 0,title:t,children:t})]})}function vst(e){const t=Math.floor(e/3600),n=Math.floor(e%3600/60),s=Math.floor(e%60),r=[];return t>0&&r.push(`${t}h`),n>0&&r.push(`${n}m`),r.push(`${s}s`),r.join(" ")}const bst={relayTools:!0,meshTools:!0,adapterTools:!0,tasksTools:!0};function Sst(){const e=je(),t=et(),{data:n}=st({queryKey:["config"],queryFn:()=>e.getConfig(),staleTime:3e4}),s={...bst,...n==null?void 0:n.agentContext},r=Bt({mutationFn:o=>e.updateConfig({agentContext:{...s,...o}}),onSuccess:()=>{t.invalidateQueries({queryKey:["config"]})}}),i=x.useCallback(o=>{r.mutate(o)},[r]);return{config:s,updateConfig:i}}const xy={core:["ping","get_server_info","get_session_count","get_agent","control_ui","get_ui_state"],tasks:["tasks_list","tasks_create","tasks_update","tasks_delete","tasks_get_run_history"],relay:["relay_send","relay_inbox","relay_list_endpoints","relay_register_endpoint","relay_send_and_wait","relay_send_async","relay_unregister_endpoint","relay_get_trace","relay_get_metrics"],mesh:["mesh_discover","mesh_register","mesh_list","mesh_deny","mesh_unregister","mesh_status","mesh_inspect","mesh_query_topology"],adapter:["relay_list_adapters","relay_enable_adapter","relay_disable_adapter","relay_reload_adapters","binding_list","binding_create","binding_delete","binding_list_sessions","relay_notify_user"]},eV={tasks:"tasksTools",relay:"relayTools",mesh:"meshTools",adapter:"adapterTools"},wst=[{key:"tasks",label:"Tasks (Scheduling)",description:"Create and manage scheduled agent runs",tools:xy.tasks},{key:"relay",label:"Relay (Messaging)",description:"Send messages, check inbox, register endpoints",tools:xy.relay,implicitNote:"Includes trace tools (relay_get_trace, relay_get_metrics)"},{key:"mesh",label:"Mesh (Discovery)",description:"Discover, register, and query agents",tools:xy.mesh},{key:"adapter",label:"Relay Adapters",description:"Manage Telegram, Slack, webhooks, and bindings",tools:xy.adapter,implicitNote:"Includes binding tools (binding_list, binding_create, binding_delete)"}];function Gce({tools:e,implicitNote:t}){return a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx(zt,{variant:"outline",className:"text-muted-foreground shrink-0 cursor-default text-xs font-normal",children:e.length})}),a.jsxs(yn,{side:"top",className:"max-w-xs",children:[a.jsx("p",{className:"font-mono text-xs",children:e.join(", ")}),t&&a.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:t})]})]})}function kst({group:e,enabled:t,available:n,initError:s,overrideCount:r,onToggle:i,expandContent:o}){const[l,c]=x.useState(!1),u=!!o,d=a.jsxs("div",{className:"flex items-center gap-2",children:[s&&a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx(fr,{className:"size-3.5 shrink-0 text-amber-500"})}),a.jsx(yn,{side:"top",className:"max-w-xs",children:a.jsx("p",{className:"text-xs",children:s})})]}),!n&&!s&&a.jsx(zt,{variant:"secondary",className:"text-xs",children:"Disabled"}),r>0&&a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsxs("span",{className:"text-muted-foreground shrink-0 text-xs",children:[r," ",r===1?"override":"overrides"]})}),a.jsx(yn,{side:"top",children:a.jsxs("p",{className:"text-xs",children:[r," ",r===1?"agent has":"agents have"," a per-agent override for this group"]})})]}),a.jsx(Gce,{tools:e.tools,implicitNote:e.implicitNote}),a.jsx(sr,{checked:t,onCheckedChange:m=>i(e.key,m),disabled:!n,"aria-label":`Toggle ${e.label}`}),u&&a.jsx(ll,{asChild:!0,children:a.jsx("button",{className:"text-muted-foreground hover:text-foreground rounded-sm p-0.5 transition-colors duration-150","aria-label":`${l?"Collapse":"Expand"} ${e.label} settings`,children:a.jsx(Hs,{className:Y("size-3.5 transition-transform duration-150",!l&&"-rotate-90")})})})]}),f=a.jsx(cs,{label:e.label,description:e.description,children:d});return u?a.jsxs(ol,{open:l,onOpenChange:c,children:[f,a.jsx(cl,{children:a.jsx("div",{className:"border-border mt-2 space-y-2 border-t pt-2",children:o})})]}):f}function Cst({scheduler:e,onUpdate:t}){return a.jsxs(a.Fragment,{children:[a.jsx(cs,{label:"Concurrent runs",description:"Maximum parallel task runs",children:a.jsx(sn,{type:"number",min:1,max:10,value:e.maxConcurrentRuns,onChange:n=>{const s=parseInt(n.target.value,10);s>=1&&s<=10&&t({maxConcurrentRuns:s})},className:"w-20"})}),a.jsx(cs,{label:"Timezone",description:"IANA timezone for cron schedules",children:a.jsxs(On,{value:e.timezone??"system",onValueChange:n=>t({timezone:n==="system"?null:n}),children:[a.jsx(_n,{className:"w-48",children:a.jsx(In,{})}),a.jsxs(Nn,{children:[a.jsx(mt,{value:"system",children:"System default"}),a.jsx(mt,{value:"UTC",children:"UTC"}),a.jsx(mt,{value:"America/New_York",children:"America/New_York"}),a.jsx(mt,{value:"America/Chicago",children:"America/Chicago"}),a.jsx(mt,{value:"America/Denver",children:"America/Denver"}),a.jsx(mt,{value:"America/Los_Angeles",children:"America/Los_Angeles"}),a.jsx(mt,{value:"Europe/London",children:"Europe/London"}),a.jsx(mt,{value:"Europe/Berlin",children:"Europe/Berlin"}),a.jsx(mt,{value:"Europe/Paris",children:"Europe/Paris"}),a.jsx(mt,{value:"Asia/Tokyo",children:"Asia/Tokyo"}),a.jsx(mt,{value:"Asia/Shanghai",children:"Asia/Shanghai"}),a.jsx(mt,{value:"Asia/Kolkata",children:"Asia/Kolkata"}),a.jsx(mt,{value:"Australia/Sydney",children:"Australia/Sydney"})]})]})}),a.jsx(cs,{label:"Run history",description:"Completed runs to keep",children:a.jsx(sn,{type:"number",min:1,max:1e4,value:e.retentionCount,onChange:n=>{const s=parseInt(n.target.value,10);s>=1&&t({retentionCount:s})},className:"w-24"})})]})}function Est(){return a.jsxs("div",{className:"flex gap-3 rounded-md border border-amber-500/20 bg-amber-500/10 p-3",children:[a.jsx(fr,{className:"mt-0.5 size-4 shrink-0 text-amber-500"}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-xs font-medium",children:"Do not configure this for agents running inside DorkOS."}),a.jsxs("p",{className:"text-muted-foreground text-xs",children:["DorkOS already provides tools to its managed agents internally. Adding DorkOS as an external MCP server to those same agents causes duplicate tool names — the Anthropic API will return HTTP 400 “Tool names must be unique” and all tool calls will fail. External MCP access is for agents running ",a.jsx("strong",{children:"outside"})," of DorkOS (standalone Claude Code, Cursor, Windsurf)."]})]})]})}function Tst({endpoint:e}){return a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm font-medium",children:"Endpoint"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"MCP server URL for external agents"})]}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("code",{className:"bg-muted min-w-0 flex-1 truncate rounded-md px-3 py-2 font-mono text-xs",children:e}),a.jsx(vv,{value:e})]})]})}function _st({rateLimit:e,onUpdate:t}){return a.jsxs("div",{className:"space-y-3",children:[a.jsx(Zi,{label:"Rate limiting",description:"Limit external MCP requests per time window",checked:e.enabled,onCheckedChange:n=>t({enabled:n}),ariaLabel:"Toggle rate limiting"}),e.enabled&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("label",{htmlFor:"mcp-max-requests",className:"text-muted-foreground text-xs",children:"Max requests"}),a.jsx(sn,{id:"mcp-max-requests",type:"number",min:1,max:1e3,value:e.maxPerWindow,onChange:n=>{const s=parseInt(n.target.value,10);s>=1&&s<=1e3&&t({maxPerWindow:s})},className:"w-20"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("label",{htmlFor:"mcp-window-secs",className:"text-muted-foreground text-xs",children:"Window (sec)"}),a.jsx(sn,{id:"mcp-window-secs",type:"number",min:1,max:3600,value:e.windowSecs,onChange:n=>{const s=parseInt(n.target.value,10);s>=1&&s<=3600&&t({windowSecs:s})},className:"w-20"})]})]}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Rate limit changes take effect after server restart."})]})]})}function Nst(e,t){const n=t?`Bearer ${t}`:"Bearer dork_mcp_YOUR_API_KEY";return{claudeCode:JSON.stringify({mcpServers:{"dorkos-external":{type:"http",url:e,headers:{Authorization:n}}}},null,2),claudeCodeCli:`claude mcp add-json dorkos-external '${JSON.stringify({type:"http",url:e,headers:{Authorization:n}})}'`,cursor:JSON.stringify({mcpServers:{"dorkos-external":{url:e,headers:{Authorization:n}}}},null,2),windsurf:JSON.stringify({mcpServers:{"dorkos-external":{serverUrl:e,headers:{Authorization:n}}}},null,2)}}function jst({endpoint:e,apiKey:t}){const[n,s]=x.useState(!1),[r,i]=x.useState("claude-code"),o=Nst(e,t),l=r==="claude-code"?o.claudeCode:r==="cursor"?o.cursor:o.windsurf;return a.jsxs(ol,{open:n,onOpenChange:s,children:[a.jsxs(ll,{className:"flex w-full items-center justify-between text-sm font-medium",children:[a.jsx("span",{children:"Setup Instructions"}),a.jsx(Hs,{className:Y("text-muted-foreground size-3.5 transition-transform duration-150",!n&&"-rotate-90")})]}),a.jsx(cl,{children:a.jsxs("div",{className:"mt-3 space-y-3",children:[a.jsx("div",{className:"bg-muted flex gap-0.5 rounded-md p-0.5",children:["claude-code","cursor","windsurf"].map(c=>a.jsx("button",{onClick:()=>i(c),className:Y("flex-1 rounded-sm px-3 py-1.5 text-xs font-medium transition-colors",r===c?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:c==="claude-code"?"Claude Code":c==="cursor"?"Cursor":"Windsurf"},c))}),a.jsxs("div",{className:"relative",children:[a.jsx("pre",{className:"bg-muted overflow-x-auto rounded-md p-3 text-xs leading-relaxed",children:l}),a.jsx("div",{className:"absolute top-2 right-2",children:a.jsx(vv,{value:l})})]}),r==="claude-code"&&a.jsxs("div",{className:"relative",children:[a.jsx("p",{className:"text-muted-foreground mb-1 text-xs",children:"Or add via CLI:"}),a.jsx("pre",{className:"bg-muted overflow-x-auto rounded-md p-3 text-xs leading-relaxed",children:o.claudeCodeCli}),a.jsx("div",{className:"absolute right-2 bottom-2",children:a.jsx(vv,{value:o.claudeCodeCli})})]})]})})]})}function Ast({mcp:e}){const t=je(),n=et(),[s,r]=x.useState(!1),i=x.useCallback(()=>n.invalidateQueries({queryKey:["config"]}),[n]),o=x.useCallback(async u=>{await t.updateConfig({mcp:{enabled:u,rateLimit:e.rateLimit}}),await i()},[t,e.rateLimit,i]),l=x.useCallback(async u=>{await t.updateConfig({mcp:{enabled:e.enabled,rateLimit:{...e.rateLimit,...u}}}),await i()},[t,e.enabled,e.rateLimit,i]),c=e.enabled?e.authConfigured?a.jsx(zt,{variant:"outline",className:"border-green-500/50 text-xs text-green-600",children:"Enabled"}):a.jsx(zt,{variant:"outline",className:"border-amber-500/50 text-xs text-amber-600",children:"No auth"}):a.jsx(zt,{variant:"secondary",className:"text-xs",children:"Disabled"});return a.jsx(vr,{children:a.jsxs(ol,{open:s,onOpenChange:r,children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm font-medium",children:"External MCP Server"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Add the DorkOS MCP to agents outside of DorkOS"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[c,a.jsx(sr,{checked:e.enabled,onCheckedChange:o,"aria-label":"Toggle external MCP access"}),a.jsx(ll,{asChild:!0,children:a.jsx("button",{className:"text-muted-foreground hover:text-foreground rounded-sm p-0.5 transition-colors duration-150","aria-label":`${s?"Collapse":"Expand"} external MCP server settings`,children:a.jsx(Hs,{className:Y("size-3.5 transition-transform duration-150",!s&&"-rotate-90")})})})]})]}),a.jsx(cl,{children:a.jsxs(dr,{className:"border-t",children:[a.jsx(Est,{}),a.jsx(Tst,{endpoint:e.endpoint}),a.jsx(Rst,{authSource:e.authSource}),a.jsx(_st,{rateLimit:e.rateLimit,onUpdate:l}),a.jsx(jst,{endpoint:e.endpoint,apiKey:null})]})})]})})}function Rst({authSource:e}){return e==="env"?a.jsx(cs,{label:"Authentication",description:"Gated by the MCP_API_KEY environment variable",children:a.jsx(zt,{variant:"outline",children:"Environment variable"})}):a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(rne,{className:"text-muted-foreground size-3.5"}),a.jsx("p",{className:"text-sm font-medium",children:"Authentication"})]}),a.jsxs("p",{className:"text-muted-foreground text-xs",children:["MCP clients authenticate with a personal API key. Create or revoke keys in Settings → Security → API keys, then pass it as a ",a.jsx("code",{className:"font-mono",children:"Bearer"})," token."]})]})}function Mst({onClick:e}){return a.jsx("button",{onClick:e,className:"text-muted-foreground hover:text-foreground text-xs transition-colors duration-150",children:"Reset to defaults"})}function Dst(){var S,w,C,T;const e=am(),t=Ud(),{config:n,updateConfig:s}=Sst(),r=je(),i=et(),{section:o}=t0();N5e(o);const{data:l}=st({queryKey:["config"],queryFn:()=>r.getConfig(),staleTime:3e4}),{data:c}=ba(),u=l==null?void 0:l.scheduler,d=x.useMemo(()=>{const E=(c==null?void 0:c.agents)??[],j={tasks:0,relay:0,mesh:0,adapter:0};for(const _ of E){const N=_.enabledToolGroups;N&&(N.tasks!==void 0&&j.tasks++,N.relay!==void 0&&j.relay++,N.mesh!==void 0&&j.mesh++,N.adapter!==void 0&&j.adapter++)}return j},[c]),f={tasks:t,relay:e,mesh:!0,adapter:e},m={tasks:(S=l==null?void 0:l.tasks)==null?void 0:S.initError,relay:(w=l==null?void 0:l.relay)==null?void 0:w.initError,mesh:(C=l==null?void 0:l.mesh)==null?void 0:C.initError,adapter:(T=l==null?void 0:l.relay)==null?void 0:T.initError},g=x.useCallback((E,j)=>{s({[eV[E]]:j})},[s]),y=x.useCallback(async E=>{const j=u??{maxConcurrentRuns:1,timezone:null,retentionCount:100};await r.updateConfig({scheduler:{...j,...E}}),await i.invalidateQueries({queryKey:["config"]})},[r,i,u]),b=x.useCallback(async()=>{await r.updateConfig({agentContext:{relayTools:!0,meshTools:!0,adapterTools:!0,tasksTools:!0}}),i.invalidateQueries({queryKey:["config"]})},[r,i]);return a.jsxs("div",{className:"space-y-4",children:[a.jsx(l0,{actions:a.jsx(Mst,{onClick:b}),children:"Tools"}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Control which MCP tool groups are available to agents. These are global defaults — individual agents can override them in their Tools tab."}),a.jsx(vr,{children:a.jsxs(dr,{children:[a.jsx(cs,{label:"Core Tools",description:"Server info, agent identity, UI control",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Gce,{tools:xy.core}),a.jsx("span",{className:"text-muted-foreground text-xs",children:"Always enabled"})]})}),wst.map(E=>a.jsx(kst,{group:E,enabled:n[eV[E.key]],available:f[E.key],initError:m[E.key],overrideCount:d[E.key],onToggle:g,expandContent:E.key==="tasks"&&u?a.jsx(Cst,{scheduler:u,onUpdate:y}):void 0},E.key))]})}),(l==null?void 0:l.mcp)&&a.jsx("div",{"data-section":"external-mcp",children:a.jsx(Ast,{mcp:l.mcp})})]})}function Ost(e){const t=rce[e.status.state]??"bg-muted-foreground";return Y("size-2 shrink-0 rounded-full",t)}function Ist({instance:e,manifest:t,bindingCount:n,onToggle:s,onConfigure:r}){const i=e.label||e.status.displayName||e.id,o=Ost(e),{inbound:l,outbound:c}=e.status.messageCount,u=l+c;return a.jsxs("div",{className:"flex items-center gap-3 py-2",children:[a.jsx("div",{className:o,"aria-hidden":!0}),a.jsx(vP,{iconId:t.iconId,adapterType:t.type,size:16,className:"text-muted-foreground shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"truncate text-sm font-medium",children:i}),a.jsxs("p",{className:"text-muted-foreground/60 text-xs",children:[n!==void 0&&n>0?`${n} agent${n!==1?"s":""}`:"No agents",u>0&&` · ${u} messages`]})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[a.jsx(sr,{checked:e.enabled,onCheckedChange:s,"aria-label":`${i} enabled`}),a.jsx(ge,{variant:"ghost",size:"sm",onClick:r,className:"size-7 p-0","aria-label":`Configure ${i}`,children:a.jsx(qa,{className:"size-3.5"})})]})]})}const tV={maxConcurrent:3,defaultTimeoutMs:3e5},Yx={maxConcurrent:{min:1,max:20},defaultTimeoutMs:{min:1e4,max:36e5}};function Pst(){const e=am(),{data:t=[],isLoading:n}=PQe(e),{mutate:s}=ece(),{data:r=[]}=Gb(),[i,o]=x.useState({open:!1}),{data:l=[]}=S0(e),{mutate:c}=tce(),u=x.useMemo(()=>l.find(P=>P.manifest.category==="internal"&&P.manifest.type==="claude-code"),[l]),d=u==null?void 0:u.instances[0],f=d==null?void 0:d.config,m=Number((f==null?void 0:f.maxConcurrent)??tV.maxConcurrent),g=Number((f==null?void 0:f.defaultTimeoutMs)??tV.defaultTimeoutMs),y={maxConcurrent:m,defaultTimeoutMs:g},[b,S]=x.useState(null),[w,C]=x.useState(null),T=b??String(m),E=w??String(g);function j(P,$){const q=Number($),K=Yx[P],B=!Number.isNaN(q)&&q>=K.min&&q<=K.max,V=q!==y[P];d&&B&&V&&c({id:d.id,config:{[P]:q}}),P==="maxConcurrent"&&S(null),P==="defaultTimeoutMs"&&C(null)}const _=x.useMemo(()=>{const P=new Map;for(const $ of r)P.set($.adapterId,(P.get($.adapterId)??0)+1);return P},[r]);if(!e)return a.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed py-8",children:[a.jsx(Gk,{className:"text-muted-foreground/40 size-8"}),a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-muted-foreground text-sm",children:"Relay is disabled"}),a.jsx("p",{className:"text-muted-foreground/60 text-xs",children:"Enable the Relay message bus to manage channels here"})]})]});if(n)return a.jsx("div",{className:"space-y-2",children:[1,2,3].map(P=>a.jsx(Jt,{className:"h-10 w-full rounded-md"},P))});const N=t.flatMap(P=>P.instances.map($=>({instance:$,manifest:P.manifest}))),R=t.filter(P=>!P.manifest.deprecated&&(P.instances.length===0||P.manifest.multiInstance)),O=P=>{o({open:!0,manifest:P})},M=(P,$)=>{o({open:!0,manifest:P,instanceId:$})},L=i.instanceId?t.flatMap(P=>P.instances).find(P=>P.id===i.instanceId):void 0;return a.jsxs(a.Fragment,{children:[N.length>0?a.jsx(vr,{children:a.jsx(dr,{children:N.map(({instance:P,manifest:$})=>a.jsx(Ist,{instance:P,manifest:$,bindingCount:_.get(P.id)??0,onToggle:q=>s({id:P.id,enabled:q}),onConfigure:()=>M($,P.id)},P.id))})}):a.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed py-8",children:[a.jsx(Gk,{className:"text-muted-foreground/40 size-8"}),a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-muted-foreground text-sm",children:"No channels configured"}),a.jsx("p",{className:"text-muted-foreground/60 text-xs",children:"Add a channel below to connect agents to external platforms"})]})]}),R.length>0&&a.jsxs("section",{children:[a.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-semibold tracking-wide uppercase",children:"Available Channels"}),a.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))"},children:R.map(P=>a.jsx(Lce,{manifest:P.manifest,onAdd:()=>O(P.manifest)},P.manifest.type))})]}),d&&a.jsxs("section",{children:[a.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-semibold tracking-wide uppercase",children:"Session Delivery"}),a.jsx(vr,{children:a.jsxs(dr,{children:[a.jsx(Zi,{label:"Deliver to Claude Code",description:"Start a Claude Code agent session automatically when a relay message arrives",checked:d.enabled,onCheckedChange:P=>s({id:d.id,enabled:P})}),a.jsx(cs,{label:"Max concurrent sessions",description:"Maximum relay-delivered sessions running at the same time",children:a.jsx(sn,{type:"number",min:Yx.maxConcurrent.min,max:Yx.maxConcurrent.max,value:T,onChange:P=>S(P.target.value),onBlur:P=>j("maxConcurrent",P.target.value),className:"w-24"})}),a.jsx(cs,{label:"Default timeout",description:"Timeout budget per relay-delivered session, in milliseconds",children:a.jsx(sn,{type:"number",min:Yx.defaultTimeoutMs.min,max:Yx.defaultTimeoutMs.max,value:E,onChange:P=>C(P.target.value),onBlur:P=>j("defaultTimeoutMs",P.target.value),className:"w-32"})})]})})]}),i.manifest&&a.jsx(Fce,{open:i.open,onOpenChange:P=>{P||o({open:!1})},manifest:i.manifest,existingInstance:L,existingAdapterIds:t.flatMap(P=>P.instances.map($=>$.id))})]})}function Lst(){var c;const e=je(),t=et(),{data:n,isLoading:s}=st({queryKey:["mesh","agents"],queryFn:()=>e.listMeshAgents(),staleTime:3e4}),{data:r}=st({queryKey:["config"],queryFn:()=>e.getConfig(),staleTime:3e4}),i=(n==null?void 0:n.agents)??[],o=((c=r==null?void 0:r.agents)==null?void 0:c.defaultAgent)??"dorkbot";async function l(u){await e.setDefaultAgent(u),await t.invalidateQueries({queryKey:["config"]})}return s?a.jsx(Jt,{className:"h-10 w-full rounded-md"}):i.length===0?a.jsx("div",{className:"rounded-xl border border-dashed py-8 text-center",children:a.jsx("p",{className:"text-muted-foreground text-sm",children:"No agents found"})}):a.jsx(vr,{children:a.jsx(dr,{children:a.jsx(cs,{label:"Default agent",description:"The primary agent used for new sessions and post-onboarding",children:a.jsxs(On,{value:o,onValueChange:l,children:[a.jsx(_n,{className:"w-44","data-testid":"default-agent-select",children:a.jsx(In,{})}),a.jsx(Nn,{children:i.map(u=>a.jsx(mt,{value:u.name,children:nn(u)},u.id))})]})})})})}function Fst(){return x.useSyncExternalStore(s1e,c9,c9)}function zst(){return x.useSyncExternalStore(i1e,u9,u9)}async function Bst(e){const t=await e.json().catch(()=>({})),n=e.headers.get("X-Retry-After")??e.headers.get("Retry-After"),s=n?Number(n):void 0;return{message:t.message||e.statusText||`Request failed (${e.status})`,status:e.status,code:t.code,retryAfter:Number.isFinite(s)?s:void 0}}function $st(e){async function t(n,s,r){let i;try{i=await fetch(`${e}/auth${s}`,{method:n,headers:{"Content-Type":"application/json"},credentials:"include",body:r===void 0?void 0:JSON.stringify(r)})}catch{return{data:null,error:{message:"Network error — could not reach the server.",status:0}}}return i.ok?{data:await i.json().catch(()=>null),error:null}:{data:null,error:await Bst(i)}}return{signIn:{email:n=>t("POST","/sign-in/email",n)},signUp:{email:n=>t("POST","/sign-up/email",n)},signOut:()=>t("POST","/sign-out"),getSession:()=>t("GET","/get-session"),apiKey:{create:n=>t("POST","/api-key/create",n),list:()=>t("GET","/api-key/list"),delete:n=>t("POST","/api-key/delete",n)}}}const Hst=$st(dZ()),Ust=x.createContext(Hst);function om(){return x.useContext(Ust)}const wP=["auth","session"];function Vst(){const e=om();return st({queryKey:wP,queryFn:async()=>{const{data:t}=await e.getSession();return t??null},staleTime:3e4})}function qst(){const e=om(),t=et(),[n,s]=x.useState(!1),[r,i]=x.useState(null);return{run:x.useCallback(async(l,c)=>{s(!0),i(null);const{error:u}=await e.signIn.email({email:l,password:c});return s(!1),u?(i(u),{ok:!1,error:u}):($O(!1),await t.invalidateQueries(),{ok:!0})},[e,t]),isPending:n,error:r,reset:()=>i(null)}}function Gst(){const e=om(),t=et(),[n,s]=x.useState(!1),[r,i]=x.useState(null);return{run:x.useCallback(async(l,c,u)=>{s(!0),i(null);const{error:d}=await e.signUp.email({email:l,password:c,name:u});return s(!1),d?(i(d),{ok:!1,error:d}):($O(!1),await t.invalidateQueries({queryKey:wP}),{ok:!0})},[e,t]),isPending:n,error:r,reset:()=>i(null)}}function Kst(){const e=om(),t=et(),[n,s]=x.useState(!1),[r,i]=x.useState(null);return{run:x.useCallback(async()=>{s(!0),i(null);const{error:l}=await e.signOut();return s(!1),l?(i(l),{ok:!1,error:l}):(t.setQueryData(wP,null),await t.invalidateQueries(),{ok:!0})},[e,t]),isPending:n,error:r,reset:()=>i(null)}}function Wst(){const{data:e}=Vst();return(e==null?void 0:e.user)??null}function Yst({onSignedIn:e}){const t=x.useId(),n=x.useId(),[s,r]=x.useState(""),[i,o]=x.useState(""),{run:l,isPending:c,error:u}=qst();async function d(g){if(g.preventDefault(),c)return;(await l(s,i)).ok&&(e==null||e())}const m=(u==null?void 0:u.status)===429||(u==null?void 0:u.retryAfter)!==void 0?`Too many attempts. Try again${u!=null&&u.retryAfter?` in ${u.retryAfter}s`:" in a little while"}.`:u==null?void 0:u.message;return a.jsx("div",{className:"flex min-h-screen w-full items-center justify-center p-6",children:a.jsxs("div",{className:"bg-card shadow-elevated w-full max-w-sm rounded-xl border p-6",children:[a.jsxs("div",{className:"mb-6 flex flex-col items-center text-center",children:[a.jsx("div",{className:"bg-muted mb-3 flex size-11 items-center justify-center rounded-full",children:a.jsx(pb,{className:"size-5"})}),a.jsx("h1",{className:"text-lg font-semibold",children:"Sign in to DorkOS"}),a.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"This instance requires a login to continue."})]}),a.jsxs("form",{onSubmit:d,className:"space-y-4",children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:t,children:"Email"}),a.jsx(sn,{id:t,type:"email",autoComplete:"username",value:s,onChange:g=>r(g.target.value),required:!0,autoFocus:!0})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:n,children:"Password"}),a.jsx(il,{id:n,autoComplete:"current-password",value:i,onChange:g=>o(g.target.value),required:!0})]}),m&&a.jsx("p",{className:"text-sm text-red-500",role:"alert",children:m}),a.jsx(ge,{type:"submit",className:"w-full",disabled:c,children:c?"Signing in…":"Sign in"})]})]})})}function Zst({children:e}){return Fst()?a.jsx(Yst,{}):a.jsx(a.Fragment,{children:e})}const nV=8;function Kce({title:e,description:t,submitLabel:n="Create account",onCreated:s,onOwnerExists:r,onCancel:i}){const o=x.useId(),l=x.useId(),c=x.useId(),[u,d]=x.useState(""),[f,m]=x.useState(""),[g,y]=x.useState(""),[b,S]=x.useState(null),{run:w,isPending:C,error:T}=Gst();async function E(N){if(N.preventDefault(),C)return;if(S(null),f.length<nV){S(`Password must be at least ${nV} characters.`);return}if(f!==g){S("Passwords do not match.");return}const R=await w(u,f,u);if(R.ok){await s();return}R.error.code==="REGISTRATION_CLOSED"&&r&&await r()}const j=(T==null?void 0:T.code)==="REGISTRATION_CLOSED"&&!r,_=b??(j?"An owner account already exists for this instance. Sign in instead.":T==null?void 0:T.message);return a.jsxs("div",{className:"space-y-5",children:[(e||t)&&a.jsxs("div",{className:"space-y-1",children:[e&&a.jsx("h2",{className:"text-base font-semibold",children:e}),t&&a.jsx("p",{className:"text-muted-foreground text-sm",children:t})]}),a.jsxs("form",{onSubmit:E,className:"space-y-4",children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:o,children:"Email"}),a.jsx(sn,{id:o,type:"email",autoComplete:"username",value:u,onChange:N=>d(N.target.value),required:!0,autoFocus:!0}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"A local identifier only — it is never verified and no email is ever sent."})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:l,children:"Password"}),a.jsx(il,{id:l,autoComplete:"new-password",value:f,onChange:N=>m(N.target.value),required:!0})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:c,children:"Confirm password"}),a.jsx(il,{id:c,autoComplete:"new-password",value:g,onChange:N=>y(N.target.value),required:!0})]}),_&&a.jsx("p",{className:"text-sm text-red-500",role:"alert",children:_}),a.jsxs("div",{className:"flex gap-2",children:[i&&a.jsx(ge,{type:"button",variant:"ghost",onClick:i,disabled:C,children:"Cancel"}),a.jsx(ge,{type:"submit",className:"flex-1",disabled:C,children:C?"Creating…":n})]})]})]})}const t_={all:["config"],current:()=>[...t_.all,"current"]};function Wce(){const e=je();return st({queryKey:t_.current(),queryFn:()=>e.getConfig(),staleTime:3e4})}function Yce(){const e=je(),t=et();return Bt({mutationFn:n=>e.updateConfig(n),onSuccess:()=>{t.invalidateQueries({queryKey:t_.current()})}})}function Xst(){const e=zst(),t=je(),n=et(),s=x.useCallback(async()=>{await t.updateConfig({auth:{enabled:!0}}),await n.invalidateQueries({queryKey:t_.current()});const r=e==null?void 0:e.onComplete;QN(),r==null||r()},[t,n,e]);return e?a.jsx(qc,{open:!0,onOpenChange:r=>!r&&QN(),children:a.jsxs(Cl,{children:[a.jsxs(El,{children:[a.jsx(Tl,{children:"Create an owner account"}),a.jsx(_l,{children:e.message})]}),a.jsx(Kce,{submitLabel:"Create account & continue",onCreated:s,onOwnerExists:s,onCancel:QN})]})}):null}const kP=["auth","api-keys"];function Qst(){const e=om();return st({queryKey:kP,queryFn:async()=>{const{data:t}=await e.apiKey.list();return t??[]},staleTime:3e4})}function Jst(){const e=om(),t=et(),[n,s]=x.useState(!1),[r,i]=x.useState(null);return{run:x.useCallback(async(l,c)=>{s(!0),i(null);const{data:u,error:d}=await e.apiKey.create({name:l.trim()||void 0,expiresIn:c??null});return s(!1),d||!u?(i(d??{message:"Failed to create API key.",status:0}),null):(await t.invalidateQueries({queryKey:kP}),u)},[e,t]),isPending:n,error:r,reset:()=>i(null)}}function ert(){const e=om(),t=et(),[n,s]=x.useState(null),[r,i]=x.useState(null);return{run:x.useCallback(async l=>{s(l),i(null);const{error:c}=await e.apiKey.delete({keyId:l});return s(null),c?(i(c),!1):(await t.invalidateQueries({queryKey:kP}),!0)},[e,t]),pendingId:n,error:r,reset:()=>i(null)}}const sV=[{label:"Never",value:"never",seconds:null},{label:"7 days",value:"7d",seconds:3600*24*7},{label:"30 days",value:"30d",seconds:3600*24*30},{label:"90 days",value:"90d",seconds:3600*24*90}];function trt(){const e=x.useId(),{data:t,isLoading:n}=Qst(),s=Jst(),r=ert(),[i,o]=x.useState(""),[l,c]=x.useState("never"),[u,d]=x.useState(null);async function f(){var y;const m=((y=sV.find(b=>b.value===l))==null?void 0:y.seconds)??null,g=await s.run(i,m);g&&(d(g),o(""),c("never"))}return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(rne,{className:"text-muted-foreground size-4"}),a.jsx("p",{className:"text-sm font-medium",children:"API keys"})]}),a.jsxs("p",{className:"text-muted-foreground text-xs",children:["Personal keys for MCP clients, scripts, and agents. Pass a key as a"," ",a.jsx("code",{className:"font-mono",children:"Bearer"})," token. The value is shown once at creation."]})]}),u?a.jsx(nrt,{created:u,onDone:()=>d(null)}):a.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[a.jsxs("div",{className:"min-w-40 flex-1 space-y-1.5",children:[a.jsx(Rt,{htmlFor:e,children:"Name"}),a.jsx(sn,{id:e,placeholder:"e.g. laptop-cli",value:i,onChange:m=>o(m.target.value)})]}),a.jsxs("div",{className:"w-32 space-y-1.5",children:[a.jsx(Rt,{children:"Expires"}),a.jsxs(On,{value:l,onValueChange:c,children:[a.jsx(_n,{children:a.jsx(In,{})}),a.jsx(Nn,{children:sV.map(m=>a.jsx(mt,{value:m.value,children:m.label},m.value))})]})]}),a.jsx(ge,{onClick:f,disabled:s.isPending,children:s.isPending?"Creating…":"Create key"})]}),s.error&&a.jsx("p",{className:"text-xs text-red-500",role:"alert",children:s.error.message}),a.jsx("div",{className:"space-y-1.5",children:n?a.jsx(Jt,{className:"h-9 w-full"}):t&&t.length>0?t.map(m=>a.jsx(srt,{apiKey:m,revoking:r.pendingId===m.id,onRevoke:()=>r.run(m.id)},m.id)):a.jsx("p",{className:"text-muted-foreground text-xs",children:"No API keys yet."})}),r.error&&a.jsx("p",{className:"text-xs text-red-500",role:"alert",children:r.error.message})]})}function nrt({created:e,onDone:t}){const[n,s]=wg();return a.jsxs("div",{className:"border-primary/40 bg-primary/5 space-y-3 rounded-lg border p-3",children:[a.jsx("p",{className:"text-sm font-medium",children:"Copy your key now — it won't be shown again"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("code",{className:"bg-muted min-w-0 flex-1 truncate rounded-md px-3 py-2 font-mono text-xs",children:e.key}),a.jsx("button",{className:"text-muted-foreground hover:text-foreground shrink-0 rounded-sm p-1.5 transition-colors",onClick:()=>s(e.key),"aria-label":"Copy API key",children:n?a.jsx(Lt,{className:"size-4 text-green-500"}):a.jsx(Vh,{className:"size-4"})})]}),a.jsx(ge,{variant:"outline",size:"sm",onClick:t,children:"Done"})]})}function srt({apiKey:e,revoking:t,onRevoke:n}){const s=e.name||"Unnamed key",r=e.start?`${e.start}…`:e.prefix||"";return a.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border px-3 py-2",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"truncate text-sm font-medium",children:s}),a.jsxs("p",{className:"text-muted-foreground font-mono text-xs",children:[r,e.expiresAt?` · expires ${new Date(e.expiresAt).toLocaleDateString()}`:" · no expiry"]})]}),a.jsxs(Sl,{children:[a.jsx(mT,{asChild:!0,children:a.jsx(ge,{variant:"ghost",size:"sm",disabled:t,"aria-label":`Revoke ${s}`,children:a.jsx(wo,{className:"size-3.5"})})}),a.jsxs(ko,{children:[a.jsxs(wl,{children:[a.jsx(Co,{children:"Revoke this API key?"}),a.jsxs(Eo,{children:["Anything using “",s,"” will immediately lose access. This cannot be undone."]})]}),a.jsxs(kl,{children:[a.jsx(_o,{children:"Cancel"}),a.jsx(To,{onClick:n,children:"Revoke"})]})]})]})]})}function rrt(){var u;const{data:e}=Wce(),t=Yce(),n=Wst(),s=Kst(),r=((u=e==null?void 0:e.auth)==null?void 0:u.enabled)??!1,[i,o]=x.useState(!1);function l(d){d?o(!0):t.mutate({auth:{enabled:!1}})}async function c(){await t.mutateAsync({auth:{enabled:!0}}),o(!1)}return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(xb,{className:"text-muted-foreground size-4"}),a.jsx("h2",{className:"text-sm font-semibold",children:"Security"})]}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Require an owner login to reach this instance. Exposing DorkOS beyond localhost (a tunnel or non-loopback bind) always requires login."})]}),a.jsx(vr,{children:a.jsxs(dr,{children:[a.jsx(cs,{label:"Require login",description:r?"An owner account is required to use this instance.":"Off — this instance starts with no login (localhost only).",children:a.jsx(sr,{checked:r,onCheckedChange:l,"aria-label":"Require login"})}),r&&a.jsx(cs,{label:"Signed in",description:(n==null?void 0:n.email)??"Owner account",children:a.jsxs(ge,{variant:"outline",size:"sm",onClick:()=>s.run(),disabled:s.isPending,children:[a.jsx(SMe,{className:"mr-1.5 size-3.5"}),s.isPending?"Signing out…":"Sign out"]})})]})}),r&&a.jsx(vr,{children:a.jsx(dr,{children:a.jsx(trt,{})})}),a.jsx(qc,{open:i,onOpenChange:o,children:a.jsxs(Cl,{children:[a.jsxs(El,{children:[a.jsx(Tl,{children:"Create an owner account"}),a.jsx(_l,{children:"This becomes the login for this instance. Email is a local identifier only."})]}),a.jsx(Kce,{submitLabel:"Create account & require login",onCreated:c,onOwnerExists:c,onCancel:()=>o(!1)})]})})]})}function irt(){return a.jsx(rrt,{})}const art=2500,ort=new Set(["linked","denied","expired","unlinked"]),fw=["cloud","status"];function lrt(e){return e instanceof Error&&e.message?e.message:"Could not reach the DorkOS cloud. Try again shortly."}function crt(){const e=je(),t=et(),n=st({queryKey:fw,queryFn:()=>e.getCloudStatus(),staleTime:3e4}),[s,r]=x.useState(null),[i,o]=x.useState(null),[l,c]=x.useState(!1),[u,d]=x.useState(!1),[f,m]=x.useState(null),g=x.useRef(null),y=x.useRef(!0),b=x.useRef(!1),S=x.useCallback(()=>{g.current&&(clearInterval(g.current),g.current=null)},[]),w=x.useCallback(async()=>{try{const _=await e.getCloudLinkStatus();if(!y.current)return;o(_),ort.has(_.state)&&(S(),_.state==="linked"&&await t.invalidateQueries({queryKey:fw}))}catch{}},[e,t,S]),C=x.useCallback(()=>{S(),g.current=setInterval(()=>void w(),art)},[w,S]);x.useEffect(()=>(y.current=!0,e.getCloudLinkStatus().then(_=>{y.current&&!b.current&&o(_)}).catch(()=>{}),()=>{y.current=!1,S()}),[e,S]);const T=x.useCallback(async()=>{m(null),c(!0),b.current=!0;try{const _=await e.startCloudLink();r(_),o({state:"pending"}),C()}catch(_){b.current=!1,m(lrt(_))}finally{c(!1)}},[e,C]),E=x.useCallback(async()=>{d(!0);try{await e.unlinkCloud(),S(),r(null),b.current=!1,o({state:"idle"}),t.setQueryData(fw,{linked:!1,accountLabel:null,lastHeartbeatAt:null}),await t.invalidateQueries({queryKey:fw})}catch{}finally{d(!1)}},[e,t,S]);return{view:x.useMemo(()=>{var N,R,O;const _=i==null?void 0:i.state;return s&&_==="pending"?{kind:"pending",userCode:s.userCode,verificationUri:s.verificationUri,expiresAt:s.expiresAt}:_==="denied"?{kind:"denied"}:_==="expired"?{kind:"expired"}:_==="unlinked"?{kind:"revoked"}:_==="linked"?{kind:"linked",accountLabel:(i==null?void 0:i.accountLabel)??((N=n.data)==null?void 0:N.accountLabel)??null,lastHeartbeatAt:(i==null?void 0:i.lastHeartbeatAt)??((R=n.data)==null?void 0:R.lastHeartbeatAt)??null}:n.isLoading&&!n.data?{kind:"loading"}:(O=n.data)!=null&&O.linked?{kind:"linked",accountLabel:n.data.accountLabel,lastHeartbeatAt:n.data.lastHeartbeatAt}:{kind:"idle"}},[s,i,n.data,n.isLoading]),start:T,unlink:E,starting:l,unlinking:u,startError:f}}function urt(){const{view:e,start:t,unlink:n,starting:s,unlinking:r,startError:i}=crt();return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(qE,{className:"text-muted-foreground size-4"}),a.jsx("h2",{className:"text-sm font-semibold",children:"DorkOS account"})]}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Link this instance to a DorkOS account to reach it from dorkos.ai and receive updates. Linking is independent of local login."})]}),a.jsx(vr,{children:a.jsx(dr,{children:a.jsx(drt,{view:e,start:t,unlink:n,starting:s,unlinking:r,startError:i})})})]})}function drt({view:e,start:t,unlink:n,starting:s,unlinking:r,startError:i}){switch(e.kind){case"loading":return a.jsx(Jt,{className:"h-9 w-40"});case"idle":return a.jsx(frt,{start:t,starting:s,startError:i});case"pending":return a.jsx(hrt,{view:e});case"linked":return a.jsx(mrt,{view:e,unlink:n,unlinking:r});case"expired":return a.jsx(KA,{title:"Your code expired",description:"The link code timed out before it was approved. Generate a new one to try again.",actionLabel:"Generate a new code",onAction:t,pending:s});case"denied":return a.jsx(KA,{title:"Link request denied",description:"The request was rejected on dorkos.ai. Start again if that wasn't intentional.",actionLabel:"Try again",onAction:t,pending:s});case"revoked":return a.jsx(KA,{title:"This instance was unlinked",description:"DorkOS revoked this instance's access. Link again to reconnect it to your account.",actionLabel:"Link again",onAction:t,pending:s})}}function frt({start:e,starting:t,startError:n}){return a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:"text-muted-foreground text-sm",children:"This instance is not linked to a DorkOS account."}),a.jsxs(ge,{onClick:()=>void e(),disabled:t,children:[t?a.jsx(Sn,{className:"mr-1.5 size-4 animate-spin"}):a.jsx(qE,{className:"mr-1.5 size-4"}),t?"Starting…":"Link this instance"]}),n&&a.jsx("p",{className:"text-sm text-red-500",role:"alert",children:n})]})}function hrt({view:e}){const[t,n]=wg();return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-sm font-medium",children:"Enter this code to link"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("code",{className:"bg-muted flex-1 rounded-md px-4 py-3 text-center font-mono text-2xl font-semibold tracking-[0.2em] tabular-nums",children:e.userCode}),a.jsx("button",{className:"text-muted-foreground hover:text-foreground shrink-0 rounded-sm p-2 transition-colors",onClick:()=>n(e.userCode),"aria-label":"Copy code",children:t?a.jsx(Lt,{className:"size-4 text-green-500"}):a.jsx(Vh,{className:"size-4"})})]})]}),a.jsxs(ge,{variant:"outline",onClick:()=>prt(e.verificationUri,e.userCode),children:[a.jsx(fa,{className:"mr-1.5 size-4"}),"Open dorkos.ai/activate"]}),a.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-sm",role:"status",children:[a.jsx(Sn,{className:"size-4 animate-spin"}),a.jsx("span",{children:"Waiting for you to approve on dorkos.ai…"})]})]})}function mrt({view:e,unlink:t,unlinking:n}){return a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{className:"flex items-start justify-between gap-3",children:[a.jsxs("div",{className:"min-w-0 space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"size-2 shrink-0 rounded-full bg-green-500","aria-hidden":!0}),a.jsx("p",{className:"text-sm font-medium",children:"Linked"})]}),e.accountLabel?a.jsx("p",{className:"text-foreground truncate text-sm",children:e.accountLabel}):a.jsx("p",{className:"text-muted-foreground text-sm",children:"Syncing account…"}),e.lastHeartbeatAt&&a.jsxs("p",{className:"text-muted-foreground text-xs",children:["Last synced ",ii(e.lastHeartbeatAt).toLowerCase()]})]}),a.jsxs(Sl,{children:[a.jsx(mT,{asChild:!0,children:a.jsxs(ge,{variant:"outline",size:"sm",disabled:n,"aria-label":"Unlink this instance",children:[a.jsx(kDe,{className:Y("mr-1.5 size-3.5",n&&"animate-pulse")}),n?"Unlinking…":"Unlink"]})}),a.jsxs(ko,{children:[a.jsxs(wl,{children:[a.jsx(Co,{children:"Unlink this instance?"}),a.jsx(Eo,{children:"This instance will stop reporting to your DorkOS account. You can link it again at any time."})]}),a.jsxs(kl,{children:[a.jsx(_o,{children:"Cancel"}),a.jsx(To,{onClick:()=>void t(),children:"Unlink"})]})]})]})]})})}function KA({title:e,description:t,actionLabel:n,onAction:s,pending:r}){return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(fr,{className:"mt-0.5 size-4 shrink-0 text-amber-500"}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm font-medium",children:e}),a.jsx("p",{className:"text-muted-foreground text-sm",children:t})]})]}),a.jsxs(ge,{onClick:()=>void s(),disabled:r,children:[r?a.jsx(Sn,{className:"mr-1.5 size-4 animate-spin"}):a.jsx(ma,{className:"mr-1.5 size-4"}),n]})]})}function prt(e,t){try{const n=new URL(e);if(n.protocol!=="https:"&&n.protocol!=="http:")return;n.searchParams.set("code",t),window.open(n.href,"_blank","noopener,noreferrer")}catch{}}function grt(){return a.jsx(urt,{})}function xrt({open:e,onOpenChange:t,onResetComplete:n}){const[s,r]=x.useState(""),[i,o]=x.useState(!1),l=je(),c=s==="reset";async function u(){o(!0);try{await l.resetAllData("reset"),localStorage.clear(),t(!1),n()}catch(f){Ye.error(f instanceof Error?f.message:"Failed to reset data")}finally{o(!1)}}function d(f){f||(r(""),o(!1)),t(f)}return a.jsx(Sl,{open:e,onOpenChange:d,children:a.jsxs(ko,{children:[a.jsxs(wl,{children:[a.jsx(Co,{children:"Reset All Data"}),a.jsx(Eo,{asChild:!0,children:a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{children:"This will permanently delete all DorkOS data, including:"}),a.jsxs("ul",{className:"list-inside list-disc space-y-1 text-sm",children:[a.jsx("li",{children:"All Tasks schedules and run history"}),a.jsx("li",{children:"All Relay configuration and messages"}),a.jsx("li",{children:"All Mesh agent registry data"}),a.jsx("li",{children:"Your config file and preferences"}),a.jsx("li",{children:"All server logs"})]}),a.jsx("p",{children:"The server will restart automatically. Your UI preferences will also be cleared."}),a.jsx("p",{className:"font-semibold",children:"This action cannot be undone."})]})})]}),a.jsx("div",{className:"py-2",children:a.jsx(sn,{placeholder:'Type "reset" to confirm',value:s,onChange:f=>r(f.target.value),"data-testid":"reset-confirm-input"})}),a.jsxs(kl,{children:[a.jsx(_o,{children:"Cancel"}),a.jsx(To,{disabled:!c||i,onClick:u,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:i?"Resetting...":"Reset All Data"})]})]})})}function yrt({open:e,onOpenChange:t,onRestartComplete:n}){const[s,r]=x.useState(!1),i=je();async function o(){r(!0);try{await i.restartServer(),t(!1),n()}catch(l){Ye.error(l instanceof Error?l.message:"Failed to restart server")}finally{r(!1)}}return a.jsx(Sl,{open:e,onOpenChange:t,children:a.jsxs(ko,{children:[a.jsxs(wl,{children:[a.jsx(Co,{children:"Restart Server"}),a.jsx(Eo,{children:"This will restart the DorkOS server. All active sessions will be interrupted."})]}),a.jsxs(kl,{children:[a.jsx(_o,{children:"Cancel"}),a.jsx(To,{disabled:s,onClick:o,children:s?"Restarting...":"Restart Server"})]})]})})}const vrt=["fatal","error","warn","info","debug","trace"];function brt(){const[e,t]=x.useState(!1),[n,s]=x.useState(!1),r=we(m=>m.enableMessagePolling),i=we(m=>m.setEnableMessagePolling),o=we(m=>m.setRestartOverlayOpen),l=je(),c=et(),{data:u}=st({queryKey:["config"],queryFn:()=>l.getConfig(),staleTime:3e4}),d=u==null?void 0:u.logging,f=x.useCallback(async m=>{const g=d??{level:"info",maxLogSizeKb:500,maxLogFiles:14};await l.updateConfig({logging:{...g,...m}}),await c.invalidateQueries({queryKey:["config"]})},[l,c,d]);return a.jsxs("div",{className:"space-y-6",children:[a.jsx("h3",{className:"text-sm font-semibold",children:"Background Updates"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Messages stream in live and stay in sync across windows automatically. This optional setting adds an extra polling fallback for sessions running outside DorkOS."}),a.jsx(vr,{children:a.jsx(dr,{children:a.jsx(Zi,{label:"Background refresh",description:"Poll for updates to sessions running outside DorkOS (e.g. the Claude Code CLI). Enable only if external activity isn't appearing promptly.",checked:r,onCheckedChange:i})})}),d&&a.jsxs(a.Fragment,{children:[a.jsx("h3",{className:"text-sm font-semibold",children:"Logging"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Server log verbosity and rotation. Changes take effect immediately for log level; rotation settings apply on next file rotation."}),a.jsx(vr,{children:a.jsxs(dr,{children:[a.jsx(cs,{label:"Log level",description:"Server log verbosity",children:a.jsxs(On,{value:d.level,onValueChange:m=>f({level:m}),children:[a.jsx(_n,{className:"w-28",children:a.jsx(In,{})}),a.jsx(Nn,{children:vrt.map(m=>a.jsx(mt,{value:m,children:m},m))})]})}),a.jsx(cs,{label:"Max log file size",description:"Size in KB before a log file is rotated",children:a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(sn,{type:"number",min:100,max:10240,value:d.maxLogSizeKb,onChange:m=>{const g=parseInt(m.target.value,10);g>=100&&g<=10240&&f({maxLogSizeKb:g})},className:"w-24"}),a.jsx("span",{className:"text-muted-foreground text-xs",children:"KB"})]})}),a.jsx(cs,{label:"Rotated files kept",description:"Number of old log files to retain (1-30)",children:a.jsx(sn,{type:"number",min:1,max:30,value:d.maxLogFiles,onChange:m=>{const g=parseInt(m.target.value,10);g>=1&&g<=30&&f({maxLogFiles:g})},className:"w-20"})}),(u==null?void 0:u.dorkHome)&&a.jsx(Srt,{dorkHome:u.dorkHome})]})})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(fr,{className:"text-destructive size-4"}),a.jsx("h3",{className:"text-destructive text-sm font-semibold",children:"Danger Zone"})]}),a.jsx(vr,{className:"border-destructive/50",children:a.jsxs(dr,{children:[a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm font-medium",children:"Reset All Data"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Permanently delete all DorkOS data and restart the server."})]}),a.jsx(ge,{variant:"destructive",size:"sm",onClick:()=>t(!0),children:"Reset"})]}),a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm font-medium",children:"Restart Server"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Restart the DorkOS server process. Active sessions will be interrupted."})]}),a.jsx(ge,{variant:"destructive",size:"sm",onClick:()=>s(!0),children:"Restart"})]})]})}),a.jsx(xrt,{open:e,onOpenChange:t,onResetComplete:()=>o(!0)}),a.jsx(yrt,{open:n,onOpenChange:s,onRestartComplete:()=>o(!0)})]})}function Srt({dorkHome:e}){const[t,n]=x.useState(!1),s=`${e}/logs`;function r(){navigator.clipboard.writeText(s).then(()=>{n(!0),setTimeout(()=>n(!1),yo.COPY_FEEDBACK_MS)})}return a.jsx(cs,{label:"Log location",description:"Directory where server log files are stored",children:a.jsx("button",{type:"button",onClick:r,className:"text-muted-foreground hover:text-foreground flex items-center gap-1.5 transition-colors",children:t?a.jsx("span",{className:"text-xs",children:"Copied"}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"max-w-40 truncate font-mono text-xs",dir:"rtl",title:s,children:s}),a.jsx(Vh,{className:"size-3 shrink-0"})]})})})}function wrt({onClick:e}){return Us()?a.jsxs(te.button,{onClick:e,whileTap:{scale:.98},transition:{type:"spring",stiffness:400,damping:30},className:Y("flex w-full items-center gap-3 px-4 py-3 text-left text-sm transition-colors","hover:bg-muted/50 active:bg-muted min-h-[44px]"),children:[a.jsx(ha,{className:"text-muted-foreground size-(--size-icon-sm) shrink-0"}),a.jsx("span",{className:"flex-1",children:"Remote Access"}),a.jsx(Rs,{className:"text-muted-foreground/40 size-(--size-icon-sm) shrink-0"})]}):a.jsx("button",{onClick:e,className:"text-muted-foreground hover:text-foreground hover:bg-muted/50 relative mx-2 flex w-[calc(100%-1rem)] items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors duration-150",children:a.jsxs("span",{className:"relative z-10 flex items-center gap-2",children:[a.jsx(ha,{className:"size-(--size-icon-sm) shrink-0"}),"Remote Access"]})})}const krt=15e3,Crt=3e4,Ert=3e4;function Trt(e,t,n){return!e&&!t?"landing":!e&&t||t?"setup":n==="error"?"error":n==="starting"?"connecting":n==="connected"||n==="stopping"?"connected":"ready"}function _rt({open:e}){const t=je(),{data:n}=st({queryKey:["config"],queryFn:()=>t.getConfig(),staleTime:300*1e3}),s=n==null?void 0:n.tunnel,[r,i]=x.useState("off"),[o,l]=x.useState(null),[c,u]=x.useState(null),[d,f]=x.useState(!1),[m,g]=x.useState(""),[y,b]=x.useState(null),[S,w]=x.useState(!1),[C,T]=x.useState(""),[E,j]=x.useState(null),_=x.useRef(void 0);x.useEffect(()=>{s!=null&&s.connected&&(s!=null&&s.url)?(i("connected"),l(s.url)):r!=="starting"&&r!=="stopping"&&(i("off"),l(null))},[s==null?void 0:s.connected,s==null?void 0:s.url,r]),x.useEffect(()=>{s!=null&&s.domain&&T(s.domain)},[s==null?void 0:s.domain]),x.useEffect(()=>{s!=null&&s.tokenConfigured&&f(!1)},[s==null?void 0:s.tokenConfigured]),x.useEffect(()=>{const L=_.current,P=(s==null?void 0:s.connected)??!1;_.current=P,L!==void 0&&(L&&!P?Ye.error("Remote access disconnected",{id:"tunnel-status",description:"Attempting to reconnect..."}):!L&&P&&(s!=null&&s.url)&&Ye.success("Remote access reconnected",{id:"tunnel-status",description:s.url}))},[s==null?void 0:s.connected,s==null?void 0:s.url]),x.useEffect(()=>{if(r!=="starting"&&r!=="stopping")return;const L=setTimeout(()=>{r==="starting"?(i("error"),u("Connection timed out. Please try again.")):r==="stopping"&&(i("off"),l(null))},Crt);return()=>clearTimeout(L)},[r]),x.useEffect(()=>{if(r!=="connected"||!o||!e){j(null);return}const L=async()=>{try{const $=performance.now();await fetch(`${o}/api/health`,{mode:"cors",cache:"no-store"}),j(Math.round(performance.now()-$))}catch{j(null)}};L();const P=setInterval(L,Ert);return()=>clearInterval(P)},[r,o,e]);const N=!!(s!=null&&s.tokenConfigured),R=Trt(N,d,r);return{state:r,setState:i,url:o,setUrl:l,error:c,setError:u,showSetup:d,setShowSetup:f,authToken:m,setAuthToken:g,tokenError:y,setTokenError:b,showTokenInput:S,setShowTokenInput:w,domain:C,setDomain:T,latencyMs:E,tunnel:s,tokenConfigured:N,viewState:R,isTransitioning:r==="starting"||r==="stopping",isChecked:r==="connected"||r==="starting"||r==="stopping"}}function Nrt(){const e=je();return st({queryKey:["tunnel-status"],queryFn:async()=>(await e.getConfig()).tunnel,refetchInterval:3e4,refetchIntervalInBackground:!1})}const jrt="dorkos-tunnel";function rV(){const e=Bwe(jrt);e.postMessage({type:"tunnel_changed"}),e.close()}function Art({machine:e,transport:t,queryClient:n}){const s=x.useRef(void 0),r=x.useCallback(async()=>{e.setState("starting"),e.setError(null);const c=setTimeout(()=>{e.setState("error"),e.setError("Connection timed out after 15 seconds")},krt);try{const u=await t.startTunnel();clearTimeout(c),e.setState("connected"),e.setUrl(u.url),n.invalidateQueries({queryKey:["config"]}),rV()}catch(u){if(clearTimeout(c),u.code==="AUTH_REQUIRED_FOR_EXPOSURE"){e.setState("off"),r1e({reason:"exposure",message:"Exposing DorkOS requires a login.",onComplete:()=>{var d;return void((d=s.current)==null?void 0:d.call(s))}});return}e.setState("error"),e.setError(u instanceof Error?u.message:"Failed to start tunnel")}},[e,t,n]);x.useEffect(()=>{s.current=r},[r]);const i=x.useCallback(async c=>{if(c)await r();else{e.setState("stopping"),e.setError(null);try{await t.stopTunnel(),e.setState("off"),e.setUrl(null),n.invalidateQueries({queryKey:["config"]}),rV()}catch(u){e.setState("connected"),e.setError(u instanceof Error?u.message:"Failed to stop tunnel")}}},[r,e,t,n]),o=x.useCallback(async()=>{e.setTokenError(null);try{await t.updateConfig({tunnel:{authtoken:e.authToken}}),e.setAuthToken(""),e.setShowTokenInput(!1),e.setShowSetup(!1),n.invalidateQueries({queryKey:["config"]})}catch{e.setTokenError("Could not save token. Try again.")}},[e,n,t]),l=x.useCallback(async()=>{try{await t.updateConfig({tunnel:{domain:e.domain.trim()||null}}),n.invalidateQueries({queryKey:["config"]})}catch{}},[e,n,t]);return{handleToggle:i,handleSaveToken:o,handleSaveDomain:l}}function Rrt(){return a.jsxs("svg",{viewBox:"0 0 240 120",className:"mx-auto h-24 w-48","aria-hidden":"true",children:[a.jsx("rect",{x:"80",y:"30",width:"80",height:"50",rx:"4",className:"fill-none stroke-current",strokeWidth:"2"}),a.jsx("rect",{x:"70",y:"80",width:"100",height:"6",rx:"2",className:"fill-current opacity-30"}),a.jsx("rect",{x:"90",y:"42",width:"20",height:"2",rx:"1",className:"fill-current opacity-40"}),a.jsx("rect",{x:"90",y:"48",width:"40",height:"2",rx:"1",className:"fill-current opacity-20"}),a.jsx("rect",{x:"90",y:"54",width:"30",height:"2",rx:"1",className:"fill-current opacity-20"}),a.jsx("rect",{x:"195",y:"35",width:"28",height:"45",rx:"4",className:"fill-none stroke-current",strokeWidth:"1.5"}),a.jsx("circle",{cx:"209",cy:"73",r:"2",className:"fill-current opacity-30"}),a.jsx("rect",{x:"10",y:"30",width:"40",height:"55",rx:"4",className:"fill-none stroke-current",strokeWidth:"1.5"}),a.jsx("circle",{cx:"30",cy:"78",r:"2",className:"fill-current opacity-30"}),a.jsx("line",{x1:"160",y1:"55",x2:"195",y2:"55",className:"stroke-current opacity-40",strokeWidth:"1.5",strokeDasharray:"4 3"}),a.jsx("line",{x1:"80",y1:"55",x2:"50",y2:"55",className:"stroke-current opacity-40",strokeWidth:"1.5",strokeDasharray:"4 3"})]})}function Mrt(){return a.jsxs("div",{className:"space-y-3",children:[a.jsx(Rrt,{}),a.jsx("p",{className:"text-foreground text-center text-sm font-medium",children:"Access DorkOS from any device"})]})}function Drt({onGetStarted:e}){return a.jsxs("div",{"data-testid":"tunnel-landing",className:"space-y-6 py-2",children:[a.jsx(Mrt,{}),a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-foreground text-sm font-medium",children:"Access DorkOS from any device"}),a.jsx("p",{className:"text-muted-foreground mx-auto mt-1 max-w-[280px] text-xs leading-relaxed",children:"Create a secure tunnel to access your sessions from your phone, tablet, or any browser."})]}),a.jsx(ge,{onClick:e,className:"w-full transition-transform duration-100 hover:scale-[1.01] active:scale-[0.98]",children:"Get started"}),a.jsx("p",{className:"text-muted-foreground/60 text-center text-xs",children:"Requires a free ngrok account"})]})}const Ort={initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0}},Irt={duration:.2,ease:[0,0,.2,1]};function Prt({authToken:e,tokenError:t,onAuthTokenChange:n,onSaveToken:s}){return a.jsxs("div",{"data-testid":"tunnel-setup",className:"space-y-4",children:[a.jsxs(ua,{"data-invalid":t?!0:void 0,children:[a.jsx(da,{htmlFor:"tunnel-auth-token",className:"text-xs font-medium",children:"ngrok auth token"}),a.jsx(sn,{id:"tunnel-auth-token",type:"password",placeholder:"Paste your ngrok auth token",value:e,onChange:r=>n(r.target.value),onKeyDown:r=>{r.key==="Enter"&&e.trim()&&s()},className:"text-sm"}),a.jsx(Ue,{children:t&&a.jsx(te.div,{variants:Ort,initial:"initial",animate:"animate",exit:"exit",transition:Irt,className:"overflow-hidden",children:a.jsx(rl,{children:t})},"token-error")})]}),a.jsx(ge,{size:"sm",className:"w-full",disabled:!e.trim(),onClick:()=>void s(),children:"Save token"}),a.jsxs("p",{className:"text-muted-foreground text-xs",children:["Don't have a token?"," ",a.jsxs("a",{href:"https://dashboard.ngrok.com/signup",target:"_blank",rel:"noopener noreferrer",className:"text-foreground group inline-flex items-center gap-0.5 underline underline-offset-2",children:["Sign up for ngrok",a.jsx(Hw,{className:"size-3 transition-transform duration-100 group-hover:-translate-x-0.5"})]})," ","— free tier is sufficient."]})]})}const Lrt={initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0}},Frt={duration:.2,ease:[0,0,.2,1]},zrt={collapsed:{rotate:0},expanded:{rotate:90}},Brt={duration:.15,ease:"easeInOut"};function iV({active:e,label:t}){return a.jsxs("span",{className:Y("flex items-center gap-1 text-xs",e?"text-muted-foreground":"text-muted-foreground/50"),children:[e?a.jsx(Lt,{className:"size-3 text-green-500"}):a.jsx("span",{className:"text-muted-foreground/40",children:"○"}),t]})}function $rt({authToken:e,tokenError:t,showTokenInput:n,onAuthTokenChange:s,onSaveToken:r,onShowTokenInput:i,domain:o,onDomainChange:l,onDomainSave:c}){const[u,d]=x.useState(!1),f=m=>{m.key==="Enter"&&c()};return a.jsxs("div",{"data-testid":"tunnel-settings",children:[a.jsxs("button",{type:"button",onClick:()=>d(m=>!m),className:"hover:text-foreground text-muted-foreground flex w-full items-center gap-1.5 py-1 text-xs transition-colors",children:[a.jsx(te.span,{variants:zrt,animate:u?"expanded":"collapsed",transition:Brt,className:"inline-flex origin-center","aria-hidden":!0,children:a.jsx(Rs,{className:"size-3.5"})}),a.jsx("span",{className:"font-medium",children:"Settings"})]}),!u&&a.jsxs("div",{className:"mt-1.5 flex gap-3 pl-5",children:[a.jsx(iV,{active:!0,label:"Token"}),a.jsx(iV,{active:!!o.trim(),label:o.trim()||"No domain"})]}),a.jsx(Ue,{initial:!1,children:u&&a.jsx(te.div,{variants:Lrt,initial:"initial",animate:"animate",exit:"exit",transition:Frt,className:"overflow-hidden",children:a.jsxs("div",{className:"space-y-4 pt-3",children:[a.jsx("div",{className:"space-y-2",children:n?a.jsxs(ua,{children:[a.jsx(da,{className:"text-sm",children:"Auth token"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(sn,{type:"password",value:e,onChange:m=>s(m.target.value),placeholder:"Paste ngrok auth token",className:"flex-1","aria-label":"Auth token"}),a.jsx(ge,{type:"button",size:"sm",onClick:r,disabled:!e.trim(),children:"Save"})]}),t&&a.jsx(rl,{children:t})]}):a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"space-y-0.5",children:[a.jsx("p",{className:"text-sm font-medium",children:"Auth token"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Token saved"})]}),a.jsx(ge,{type:"button",variant:"outline",size:"sm",onClick:i,children:"Change"})]})}),a.jsxs(ua,{children:[a.jsx(da,{className:"text-sm",children:"Custom domain"}),a.jsx(sn,{type:"text",value:o,onChange:m=>l(m.target.value),onBlur:c,onKeyDown:f,placeholder:"your-domain.ngrok.app","aria-label":"Custom domain"}),a.jsx(Va,{className:"text-xs",children:"Leave blank to use a randomly assigned ngrok URL."})]})]})},"settings-panel")})]})}const ok=[0,500,1200],aV=[{label:"Initialising ngrok agent",thresholdMs:ok[0]},{label:"Opening secure tunnel",thresholdMs:ok[1]},{label:"Registering public URL",thresholdMs:ok[2]}],Hrt={hidden:{},show:{transition:{staggerChildren:.15}}},Urt={hidden:{opacity:0,y:8},show:{opacity:1,y:0,transition:{type:"spring",stiffness:320,damping:28}}},Vrt={initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1}},qrt={type:"spring",stiffness:400,damping:30};function Grt(){const[e,t]=x.useState(0);return x.useEffect(()=>{const n=Date.now(),s=ok.map(r=>setTimeout(()=>{t(Date.now()-n)},r));return()=>{s.forEach(clearTimeout)}},[]),a.jsx(te.div,{className:"space-y-3 py-2","data-testid":"tunnel-connecting",variants:Hrt,initial:"hidden",animate:"show",children:aV.map((n,s)=>{var c;const r=e>=n.thresholdMs,i=((c=aV[s+1])==null?void 0:c.thresholdMs)??1/0,o=e>=i,l=r&&!o;return a.jsxs(te.div,{variants:Urt,className:Y("flex items-center gap-3 text-sm transition-opacity duration-300",r?"opacity-100":"opacity-0"),children:[a.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:a.jsx(Ue,{mode:"wait",children:o?a.jsx(te.span,{variants:Vrt,initial:"initial",animate:"animate",exit:{scale:.5,opacity:0},transition:qrt,className:"inline-flex",children:a.jsx(Lt,{className:"text-muted-foreground size-4"})},"check"):l?a.jsx(te.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"inline-flex",children:a.jsx(Sn,{className:"text-muted-foreground size-4 animate-spin"})},"spinner"):null})}),a.jsx("span",{className:Y("transition-colors duration-200",o?"text-muted-foreground":"text-foreground"),children:n.label})]},n.label)})})}var WA={exports:{}},YA,oV;function Krt(){if(oV)return YA;oV=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return YA=e,YA}var ZA,lV;function Wrt(){if(lV)return ZA;lV=1;var e=Krt();function t(){}function n(){}return n.resetWarningCache=t,ZA=function(){function s(o,l,c,u,d,f){if(f!==e){var m=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw m.name="Invariant Violation",m}}s.isRequired=s;function r(){return s}var i={array:s,bigint:s,bool:s,func:s,number:s,object:s,string:s,symbol:s,any:s,arrayOf:r,element:s,elementType:s,instanceOf:r,node:s,objectOf:r,oneOf:r,oneOfType:r,shape:r,exact:r,checkPropTypes:n,resetWarningCache:t};return i.PropTypes=i,i},ZA}var cV;function Yrt(){return cV||(cV=1,WA.exports=Wrt()()),WA.exports}var Zrt=Yrt();const jt=hl(Zrt),lm=function(e,t){let r=e;const i=yy[t];let o=null,l=0,c=null;const u=[],d={},f=function(N,R){l=r*4+17,o=(function(O){const M=new Array(O);for(let L=0;L<O;L+=1){M[L]=new Array(O);for(let P=0;P<O;P+=1)M[L][P]=null}return M})(l),m(0,0),m(l-7,0),m(0,l-7),b(),y(),w(N,R),r>=7&&S(N),c==null&&(c=E(r,i,u)),C(c,R)},m=function(N,R){for(let O=-1;O<=7;O+=1)if(!(N+O<=-1||l<=N+O))for(let M=-1;M<=7;M+=1)R+M<=-1||l<=R+M||(0<=O&&O<=6&&(M==0||M==6)||0<=M&&M<=6&&(O==0||O==6)||2<=O&&O<=4&&2<=M&&M<=4?o[N+O][R+M]=!0:o[N+O][R+M]=!1)},g=function(){let N=0,R=0;for(let O=0;O<8;O+=1){f(!0,O);const M=Cu.getLostPoint(d);(O==0||N>M)&&(N=M,R=O)}return R},y=function(){for(let N=8;N<l-8;N+=1)o[N][6]==null&&(o[N][6]=N%2==0);for(let N=8;N<l-8;N+=1)o[6][N]==null&&(o[6][N]=N%2==0)},b=function(){const N=Cu.getPatternPosition(r);for(let R=0;R<N.length;R+=1)for(let O=0;O<N.length;O+=1){const M=N[R],L=N[O];if(o[M][L]==null)for(let P=-2;P<=2;P+=1)for(let $=-2;$<=2;$+=1)P==-2||P==2||$==-2||$==2||P==0&&$==0?o[M+P][L+$]=!0:o[M+P][L+$]=!1}},S=function(N){const R=Cu.getBCHTypeNumber(r);for(let O=0;O<18;O+=1){const M=!N&&(R>>O&1)==1;o[Math.floor(O/3)][O%3+l-8-3]=M}for(let O=0;O<18;O+=1){const M=!N&&(R>>O&1)==1;o[O%3+l-8-3][Math.floor(O/3)]=M}},w=function(N,R){const O=i<<3|R,M=Cu.getBCHTypeInfo(O);for(let L=0;L<15;L+=1){const P=!N&&(M>>L&1)==1;L<6?o[L][8]=P:L<8?o[L+1][8]=P:o[l-15+L][8]=P}for(let L=0;L<15;L+=1){const P=!N&&(M>>L&1)==1;L<8?o[8][l-L-1]=P:L<9?o[8][15-L-1+1]=P:o[8][15-L-1]=P}o[l-8][8]=!N},C=function(N,R){let O=-1,M=l-1,L=7,P=0;const $=Cu.getMaskFunction(R);for(let q=l-1;q>0;q-=2)for(q==6&&(q-=1);;){for(let K=0;K<2;K+=1)if(o[M][q-K]==null){let B=!1;P<N.length&&(B=(N[P]>>>L&1)==1),$(M,q-K)&&(B=!B),o[M][q-K]=B,L-=1,L==-1&&(P+=1,L=7)}if(M+=O,M<0||l<=M){M-=O,O=-O;break}}},T=function(N,R){let O=0,M=0,L=0;const P=new Array(R.length),$=new Array(R.length);for(let V=0;V<R.length;V+=1){const Q=R[V].dataCount,re=R[V].totalCount-Q;M=Math.max(M,Q),L=Math.max(L,re),P[V]=new Array(Q);for(let F=0;F<P[V].length;F+=1)P[V][F]=255&N.getBuffer()[F+O];O+=Q;const U=Cu.getErrorCorrectPolynomial(re),W=_v(P[V],U.getLength()-1).mod(U);$[V]=new Array(U.getLength()-1);for(let F=0;F<$[V].length;F+=1){const X=F+W.getLength()-$[V].length;$[V][F]=X>=0?W.getAt(X):0}}let q=0;for(let V=0;V<R.length;V+=1)q+=R[V].totalCount;const K=new Array(q);let B=0;for(let V=0;V<M;V+=1)for(let Q=0;Q<R.length;Q+=1)V<P[Q].length&&(K[B]=P[Q][V],B+=1);for(let V=0;V<L;V+=1)for(let Q=0;Q<R.length;Q+=1)V<$[Q].length&&(K[B]=$[Q][V],B+=1);return K},E=function(N,R,O){const M=uV.getRSBlocks(N,R),L=dV();for(let $=0;$<O.length;$+=1){const q=O[$];L.put(q.getMode(),4),L.put(q.getLength(),Cu.getLengthInBits(q.getMode(),N)),q.write(L)}let P=0;for(let $=0;$<M.length;$+=1)P+=M[$].dataCount;if(L.getLengthInBits()>P*8)throw"code length overflow. ("+L.getLengthInBits()+">"+P*8+")";for(L.getLengthInBits()+4<=P*8&&L.put(0,4);L.getLengthInBits()%8!=0;)L.putBit(!1);for(;!(L.getLengthInBits()>=P*8||(L.put(236,8),L.getLengthInBits()>=P*8));)L.put(17,8);return T(L,M)};d.addData=function(N,R){R=R||"Byte";let O=null;switch(R){case"Numeric":O=Xrt(N);break;case"Alphanumeric":O=Qrt(N);break;case"Byte":O=Jrt(N);break;case"Kanji":O=eit(N);break;default:throw"mode:"+R}u.push(O),c=null},d.isDark=function(N,R){if(N<0||l<=N||R<0||l<=R)throw N+","+R;return o[N][R]},d.getModuleCount=function(){return l},d.make=function(){if(r<1){let N=1;for(;N<40;N++){const R=uV.getRSBlocks(N,i),O=dV();for(let L=0;L<u.length;L++){const P=u[L];O.put(P.getMode(),4),O.put(P.getLength(),Cu.getLengthInBits(P.getMode(),N)),P.write(O)}let M=0;for(let L=0;L<R.length;L++)M+=R[L].dataCount;if(O.getLengthInBits()<=M*8)break}r=N}f(!1,g())},d.createTableTag=function(N,R){N=N||2,R=typeof R>"u"?N*4:R;let O="";O+='<table style="',O+=" border-width: 0px; border-style: none;",O+=" border-collapse: collapse;",O+=" padding: 0px; margin: "+R+"px;",O+='">',O+="<tbody>";for(let M=0;M<d.getModuleCount();M+=1){O+="<tr>";for(let L=0;L<d.getModuleCount();L+=1)O+='<td style="',O+=" border-width: 0px; border-style: none;",O+=" border-collapse: collapse;",O+=" padding: 0px; margin: 0px;",O+=" width: "+N+"px;",O+=" height: "+N+"px;",O+=" background-color: ",O+=d.isDark(M,L)?"#000000":"#ffffff",O+=";",O+='"/>';O+="</tr>"}return O+="</tbody>",O+="</table>",O},d.createSvgTag=function(N,R,O,M){let L={};typeof arguments[0]=="object"&&(L=arguments[0],N=L.cellSize,R=L.margin,O=L.alt,M=L.title),N=N||2,R=typeof R>"u"?N*4:R,O=typeof O=="string"?{text:O}:O||{},O.text=O.text||null,O.id=O.text?O.id||"qrcode-description":null,M=typeof M=="string"?{text:M}:M||{},M.text=M.text||null,M.id=M.text?M.id||"qrcode-title":null;const P=d.getModuleCount()*N+R*2;let $,q,K,B,V="",Q;for(Q="l"+N+",0 0,"+N+" -"+N+",0 0,-"+N+"z ",V+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',V+=L.scalable?"":' width="'+P+'px" height="'+P+'px"',V+=' viewBox="0 0 '+P+" "+P+'" ',V+=' preserveAspectRatio="xMinYMin meet"',V+=M.text||O.text?' role="img" aria-labelledby="'+j([M.id,O.id].join(" ").trim())+'"':"",V+=">",V+=M.text?'<title id="'+j(M.id)+'">'+j(M.text)+"</title>":"",V+=O.text?'<description id="'+j(O.id)+'">'+j(O.text)+"</description>":"",V+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',V+='<path d="',K=0;K<d.getModuleCount();K+=1)for(B=K*N+R,$=0;$<d.getModuleCount();$+=1)d.isDark(K,$)&&(q=$*N+R,V+="M"+q+","+B+Q);return V+='" stroke="transparent" fill="black"/>',V+="</svg>",V},d.createDataURL=function(N,R){N=N||2,R=typeof R>"u"?N*4:R;const O=d.getModuleCount()*N+R*2,M=R,L=O-R;return rit(O,O,function(P,$){if(M<=P&&P<L&&M<=$&&$<L){const q=Math.floor((P-M)/N),K=Math.floor(($-M)/N);return d.isDark(K,q)?0:1}else return 1})},d.createImgTag=function(N,R,O){N=N||2,R=typeof R>"u"?N*4:R;const M=d.getModuleCount()*N+R*2;let L="";return L+="<img",L+=' src="',L+=d.createDataURL(N,R),L+='"',L+=' width="',L+=M,L+='"',L+=' height="',L+=M,L+='"',O&&(L+=' alt="',L+=j(O),L+='"'),L+="/>",L};const j=function(N){let R="";for(let O=0;O<N.length;O+=1){const M=N.charAt(O);switch(M){case"<":R+="<";break;case">":R+=">";break;case"&":R+="&";break;case'"':R+=""";break;default:R+=M;break}}return R},_=function(N){N=typeof N>"u"?2:N;const O=d.getModuleCount()*1+N*2,M=N,L=O-N;let P,$,q,K,B;const V={"██":"█","█ ":"▀"," █":"▄"," ":" "},Q={"██":"▀","█ ":"▀"," █":" "," ":" "};let re="";for(P=0;P<O;P+=2){for(q=Math.floor((P-M)/1),K=Math.floor((P+1-M)/1),$=0;$<O;$+=1)B="█",M<=$&&$<L&&M<=P&&P<L&&d.isDark(q,Math.floor(($-M)/1))&&(B=" "),M<=$&&$<L&&M<=P+1&&P+1<L&&d.isDark(K,Math.floor(($-M)/1))?B+=" ":B+="█",re+=N<1&&P+1>=L?Q[B]:V[B];re+=`
|
|
1260
|
+
`)[0]??"";return n.length>t?`${n.slice(0,t)}…`:n}function wD(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})}function QJe({status:e}){switch(e){case"running":return a.jsx("span",{title:"Running","aria-label":"Running",children:a.jsx(Sn,{className:"size-3.5 animate-spin text-blue-500"})});case"completed":return a.jsx("span",{title:"Completed","aria-label":"Completed",children:a.jsx(Uh,{className:"size-3.5 text-green-500"})});case"failed":return a.jsx("span",{title:"Failed","aria-label":"Failed",children:a.jsx(Xg,{className:"text-destructive size-3.5"})});case"cancelled":return a.jsx("span",{title:"Cancelled","aria-label":"Cancelled",children:a.jsx(Yte,{className:"text-muted-foreground size-3.5"})});default:return null}}function JJe({trigger:e}){return e==="scheduled"?a.jsx(Pi,{className:"text-muted-foreground/70 mr-1 inline size-3 shrink-0","aria-hidden":"true"}):e==="manual"?a.jsx(wy,{className:"text-muted-foreground/70 mr-1 inline size-3 shrink-0","aria-hidden":"true"}):null}function eet({date:e}){const t=new Date,n=new Date(e),s=new Date(t);s.setDate(s.getDate()-7);const r=n>=s,i=r?ii(e):wD(e),o=r?wD(e):ii(e);return a.jsx("time",{dateTime:e,title:o,children:i})}function IA(){return a.jsxs("div",{className:"grid grid-cols-[20px_56px_1fr_64px_72px_20px] items-center gap-2 rounded-md px-2 py-2",children:[a.jsx(Jt,{className:"size-3.5 rounded-full"}),a.jsx(Jt,{className:"h-3 w-10"}),a.jsx(Jt,{className:"h-3 w-24"}),a.jsx(Jt,{className:"h-3 w-8"}),a.jsx("span",{}),a.jsx("span",{})]})}function tet({run:e,onNavigate:t,onCancel:n,isCancelling:s}){const r=!!e.sessionId;function i(){e.sessionId&&t(e.sessionId)}function o(c){c.stopPropagation(),n(e.id)}const l=e.startedAt?wD(e.startedAt):"unknown time";return a.jsxs("div",{role:r?"button":void 0,tabIndex:r?0:void 0,"aria-label":r?`View ${e.status} run from ${l}`:void 0,onClick:r?i:void 0,onKeyDown:r?c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),i())}:void 0,className:Y("grid grid-cols-[20px_56px_1fr_64px_72px_20px] items-center gap-2","rounded-md border border-transparent px-2 py-2 text-xs transition-colors",r&&["hover:bg-muted/50 hover:border-border cursor-pointer","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:outline-none"],e.status==="failed"&&"bg-destructive/5"),children:[a.jsx(QJe,{status:e.status}),a.jsxs("span",{className:"text-muted-foreground truncate capitalize",children:[a.jsx(JJe,{trigger:e.trigger}),e.trigger]}),a.jsxs("span",{className:"flex min-w-0 flex-col gap-0.5",children:[a.jsx("span",{className:"text-foreground",children:e.startedAt?a.jsx(eet,{date:e.startedAt}):"-"}),e.outputSummary&&a.jsx("span",{className:"text-muted-foreground truncate",title:e.outputSummary,children:NU(e.outputSummary)}),e.status==="failed"&&e.error&&a.jsx("span",{className:"text-destructive truncate",title:e.error,children:NU(e.error)})]}),a.jsx("span",{className:"text-muted-foreground",children:XJe(e.durationMs)}),a.jsx("span",{children:e.status==="running"&&a.jsx("button",{type:"button",disabled:s,onClick:o,className:Y("inline-flex items-center rounded px-1.5 py-0.5 text-xs font-medium","text-muted-foreground transition-colors","hover:bg-accent hover:text-accent-foreground","focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none","disabled:pointer-events-none disabled:opacity-50"),children:"Cancel"})}),a.jsx("span",{className:"flex items-center justify-end",children:r&&a.jsx(Rs,{className:"text-muted-foreground/50 size-3.5","aria-hidden":"true"})})]})}const PA=20;function net({scheduleId:e,scheduleCwd:t}){const[n,s]=x.useState("all"),[r,i]=x.useState(0),[o,l]=x.useState([]),c=n==="all"?void 0:n,{data:u=[],isLoading:d}=k0({scheduleId:e,status:c,limit:PA,offset:r}),f=ace(),[,m]=Vc(),[g,y]=Id(),b=x.useMemo(()=>r===0?u:[...o,...u],[r,u,o]),S=x.useCallback(()=>{l(b),i(T=>T+PA)},[b]),w=x.useCallback(T=>{s(T),i(0),l([])},[]),C=x.useCallback(T=>{t&&t!==g&&y(t,{preserveSession:!0}),m(T)},[t,g,y,m]);return d&&b.length===0?a.jsxs("div",{className:"space-y-0.5","aria-label":"Loading runs...",children:[a.jsx(IA,{}),a.jsx(IA,{}),a.jsx(IA,{})]}):b.length===0&&!d?a.jsxs("div",{className:"space-y-2",children:[a.jsx(jU,{value:n,onChange:w}),a.jsx("p",{className:"text-muted-foreground py-4 text-center text-xs",children:n==="all"?"No runs yet":`No ${n} runs`})]}):a.jsxs("div",{className:"space-y-0.5",children:[a.jsx(jU,{value:n,onChange:w}),a.jsxs("div",{className:"sm:text-muted-foreground hidden sm:grid sm:grid-cols-[20px_56px_1fr_64px_72px_20px] sm:gap-2 sm:px-2 sm:pb-1 sm:text-xs sm:font-medium",children:[a.jsx("span",{}),a.jsx("span",{children:"Trigger"}),a.jsx("span",{children:"Started"}),a.jsx("span",{children:"Duration"}),a.jsx("span",{}),a.jsx("span",{})]}),b.map(T=>a.jsx(tet,{run:T,onNavigate:C,onCancel:E=>f.mutate(E,{onSuccess:()=>Ye("Run cancelled"),onError:j=>Ye.error(`Failed to cancel: ${j instanceof Error?j.message:"Unknown error"}`)}),isCancelling:f.isPending},T.id)),u.length===PA&&a.jsx("button",{type:"button",onClick:S,disabled:d,className:"text-muted-foreground hover:bg-muted/50 hover:text-foreground mt-1 w-full rounded-md py-1.5 text-xs transition-colors disabled:opacity-50",children:d?"Loading...":"Load more"})]})}function jU({value:e,onChange:t}){return a.jsx("div",{className:"mb-1 flex items-center gap-2",children:a.jsxs(On,{value:e,onValueChange:t,children:[a.jsx(_n,{responsive:!1,className:"h-7 w-[130px] text-xs",children:a.jsx(In,{placeholder:"Filter status"})}),a.jsxs(Nn,{children:[a.jsx(mt,{value:"all",children:"All"}),a.jsx(mt,{value:"running",children:"Running"}),a.jsx(mt,{value:"completed",children:"Completed"}),a.jsx(mt,{value:"failed",children:"Failed"}),a.jsx(mt,{value:"cancelled",children:"Cancelled"})]})]})})}function set(e){try{return vce.toString(e)}catch{return e}}function ret({task:e}){const t=e.status==="pending_approval"?"bg-yellow-500":e.enabled?"bg-green-500":"bg-neutral-400";return a.jsx("span",{className:Y("inline-block size-2 rounded-full",t)})}function Cce({task:e,agent:t,expanded:n,onToggleExpand:s,onEdit:r,size:i="default",showAgent:o=!0}){const l=uP(),c=HQe(),u=ice(),[d,f]=x.useState(!1),m=t?Dd(t):null,g=i==="minimal",y=i==="compact",b=i==="default",S=o&&!g,w=!g,C=b,T=(t==null?void 0:t.isSystem)===!0,E=R=>{R.stopPropagation(),c.mutate(e.id,{onSuccess:()=>Ye("Run triggered"),onError:O=>Ye.error(`Failed to trigger run: ${O.message}`)})},j=R=>{R.stopPropagation(),l.mutate({id:e.id,status:"active",enabled:!0},{onSuccess:()=>Ye("Schedule approved"),onError:O=>Ye.error(`Failed to approve: ${O.message}`)})},_=R=>{R.stopPropagation(),u.mutate(e.id,{onError:O=>Ye.error(`Failed to reject: ${O.message}`)})},N=()=>{u.mutate(e.id,{onSuccess:()=>f(!1),onError:R=>Ye.error(`Failed to delete: ${R.message}`)})};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"rounded-lg border",children:[a.jsxs("div",{role:"button",tabIndex:0,className:"flex cursor-pointer items-center gap-3 p-3",onClick:s,onKeyDown:R=>(R.key==="Enter"||R.key===" ")&&s(),children:[a.jsx(ret,{task:e}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[S&&t?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"inline-block size-2 shrink-0 rounded-full",style:{backgroundColor:m.color}}),a.jsx("span",{className:"text-xs leading-none",children:m.emoji}),a.jsx("span",{className:"text-sm font-medium",children:nn(t)}),T&&a.jsxs(zt,{variant:"outline",className:"px-1 py-0 text-[10px] leading-tight",children:[a.jsx(Hc,{className:"mr-0.5 size-2.5"}),"System"]}),a.jsx("span",{className:"text-muted-foreground text-xs",children:"·"})]}):S&&e.agentId?a.jsxs(a.Fragment,{children:[a.jsx(Hh,{className:"text-destructive size-3.5 shrink-0"}),a.jsx("span",{className:"text-destructive text-xs",children:"Agent not found"}),a.jsx("span",{className:"text-muted-foreground text-xs",children:"·"})]}):null,a.jsx("span",{className:S&&(t||e.agentId)?"text-muted-foreground text-xs":"text-sm font-medium",children:e.displayName??e.name})]}),w&&a.jsxs("div",{className:"text-muted-foreground text-xs",children:[e.cron?set(e.cron):"On-demand",e.nextRun&&a.jsxs(a.Fragment,{children:[" · Next: ",new Date(e.nextRun).toLocaleString()]})]})]}),!g&&e.status==="pending_approval"?a.jsxs("div",{className:"flex gap-1",children:[a.jsx("button",{className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md border bg-transparent px-2.5 py-1 text-xs font-medium shadow-sm transition-colors",onClick:j,children:"Approve"}),a.jsx("button",{className:"hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md px-2.5 py-1 text-xs font-medium transition-colors",onClick:_,children:"Reject"})]}):y?a.jsxs("button",{className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center gap-1 rounded-md border bg-transparent px-2 py-1 text-xs font-medium shadow-sm transition-colors",onClick:E,"aria-label":`Run ${e.name}`,children:[a.jsx(wy,{className:"size-3"}),"Run"]}):b?a.jsxs("div",{className:"flex items-center gap-2",children:[e.cron?a.jsx(sr,{checked:e.enabled,onCheckedChange:R=>{l.mutate({id:e.id,enabled:R})},onClick:R=>R.stopPropagation(),"aria-label":`Toggle ${e.name}`}):a.jsxs("button",{className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center gap-1 rounded-md border bg-transparent px-2 py-1 text-xs font-medium shadow-sm transition-colors",onClick:E,"aria-label":`Run ${e.name}`,children:[a.jsx(wy,{className:"size-3"}),"Run"]}),a.jsxs(a0,{children:[a.jsx(o0,{asChild:!0,children:a.jsx("button",{className:"text-muted-foreground hover:text-foreground rounded-md p-1 transition-colors","aria-label":`Actions for ${e.name}`,onClick:R=>R.stopPropagation(),children:a.jsx(Xte,{className:"size-4"})})}),a.jsxs(Qh,{align:"end",children:[a.jsxs(Nr,{onClick:()=>r(),children:[a.jsx(KE,{className:"mr-2 size-3.5"}),"Edit"]}),a.jsxs(Nr,{onClick:E,disabled:!e.enabled,children:[a.jsx(wy,{className:"mr-2 size-3.5"}),"Run Now"]}),a.jsx(rd,{}),a.jsxs(Nr,{onClick:R=>{R.stopPropagation(),f(!0)},className:"text-destructive focus:text-destructive",children:[a.jsx(wo,{className:"mr-2 size-3.5"}),"Delete"]})]})]})]}):null]}),a.jsx(Ue,{initial:!1,children:n&&C&&a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:a.jsxs("div",{className:"border-t px-3 pt-2 pb-3",children:[e.filePath&&a.jsx("p",{className:"text-muted-foreground mb-2 truncate font-mono text-[11px]",children:Mc(e.filePath)}),a.jsx(net,{scheduleId:e.id,scheduleCwd:null})]})})})]}),b&&a.jsx(qc,{open:d,onOpenChange:f,children:a.jsxs(Cl,{children:[a.jsxs(El,{children:[a.jsx(Tl,{children:"Delete task"}),a.jsxs(_l,{children:["Delete “",e.name,"”? This will also remove all run history. This action cannot be undone."]})]}),a.jsxs(i0,{children:[a.jsx("button",{onClick:()=>f(!1),className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md border bg-transparent px-3 py-1.5 text-sm font-medium shadow-sm transition-colors",children:"Cancel"}),a.jsx("button",{onClick:N,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90 inline-flex items-center rounded-md px-3 py-1.5 text-sm font-medium shadow-sm transition-colors",children:"Delete"})]})]})})]})}function iet(){const e=Ud(),{data:t=[],isLoading:n}=WT(e),[s,r]=x.useState(!1),[i,o]=x.useState(),[l,c]=x.useState(null),[u,d]=x.useState(null),f=we(R=>R.tasksAgentFilter),m=we(R=>R.setTasksAgentFilter),g=we(R=>R.tasksEditScheduleId),y=we(R=>R.setTasksEditScheduleId),b=f?t.filter(R=>R.agentId===f):t,S=t.some(R=>R.agentId),{data:w}=ba(void 0,S),C=x.useMemo(()=>{const R=new Map;for(const O of(w==null?void 0:w.agents)??[])R.set(O.id,O);return R},[w]);x.useEffect(()=>{if(!g||n)return;const R=t.find(O=>O.id===g);R&&(o(R),r(!0)),y(null)},[g,t,n,y]);const T=x.useMemo(()=>{var R;return f?((R=C.get(f))==null?void 0:R.name)??f:null},[f,C]),{externalTrigger:E}=Ub();x.useEffect(()=>{E&&(o(void 0),r(!0))},[E]);const j=R=>{d(R),o(void 0),r(!0)},_=()=>{d(null),o(void 0),r(!0)},N=R=>{r(R),R||d(null)};return e?n?a.jsx("div",{className:"space-y-2 p-4",children:[1,2,3].map(R=>a.jsx("div",{className:"rounded-lg border p-3",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"bg-muted animate-tasks size-2 rounded-full"}),a.jsxs("div",{className:"flex-1 space-y-1.5",children:[a.jsx("div",{className:"bg-muted animate-tasks h-4 w-32 rounded"}),a.jsx("div",{className:"bg-muted animate-tasks h-3 w-48 rounded"})]})]})},R))}):b.length===0?a.jsxs(a.Fragment,{children:[f?a.jsxs("div",{className:"flex flex-col items-center gap-3 p-8",children:[a.jsx(AU,{name:T,onClear:()=>m(null)}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"No schedules for this agent."}),a.jsx("button",{onClick:_,className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md border bg-transparent px-3 py-1.5 text-sm font-medium shadow-sm transition-colors",children:"New Schedule"})]}):a.jsx(kce,{onCreateWithPreset:j,onCreateBlank:_}),a.jsx(SD,{open:s,onOpenChange:N,editTask:i,initialPreset:u,initialAgentId:f??void 0})]}):a.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[a.jsx("div",{className:"space-y-2 p-4",children:a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:"text-muted-foreground text-sm font-medium",children:"Schedules"}),f&&a.jsx(AU,{name:T,onClear:()=>m(null)})]}),a.jsx("button",{onClick:()=>{o(void 0),r(!0)},className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md border bg-transparent px-3 py-1.5 text-sm font-medium shadow-sm transition-colors",children:"New Schedule"})]})}),a.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-4",children:a.jsx(Ue,{initial:!1,children:b.map(R=>a.jsx(te.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.2,ease:[0,0,.2,1]},className:"mb-2",children:a.jsx(Cce,{task:R,agent:R.agentId?C.get(R.agentId)??null:null,expanded:l===R.id,onToggleExpand:()=>c(l===R.id?null:R.id),onEdit:()=>{o(R),r(!0)}})},R.id))})}),a.jsx(SD,{open:s,onOpenChange:r,editTask:i,initialPreset:u,initialAgentId:f??void 0})]}):a.jsx(h4,{icon:pce.tasks,name:"Tasks",description:"Tasks runs AI agent tasks on a schedule. Start DorkOS with the --tasks flag to enable it.",command:"dorkos --tasks"})}function AU({name:e,onClear:t}){return a.jsxs("span",{className:"text-muted-foreground inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs",children:[e??"Agent",a.jsx("button",{type:"button",onClick:t,className:"hover:text-foreground -mr-0.5 rounded-full p-0.5 transition-colors","aria-label":"Clear agent filter",children:a.jsx(es,{className:"size-3"})})]})}const RU=wne({search:bne({fields:[e=>e.name,e=>e.description??"",e=>e.prompt]}),agent:Hp({field:e=>e.agentId,options:[],dynamic:!0,label:"Agent"}),status:Hp({field:e=>e.status==="pending_approval"?"pending_approval":e.enabled?"active":"paused",options:["active","paused","pending_approval"],multi:!0,label:"Status",labels:{active:"Active",paused:"Paused",pending_approval:"Pending Approval"},colors:{active:"text-emerald-400",paused:"text-muted-foreground",pending_approval:"text-amber-400"}}),type:Hp({field:e=>e.cron?"scheduled":"on-demand",options:["scheduled","on-demand"],label:"Type",labels:{scheduled:"Scheduled","on-demand":"On-demand"}})}),MU={name:{label:"Name",accessor:e=>e.name},lastRun:{label:"Last run",accessor:e=>e.updatedAt,direction:"desc"},nextRun:{label:"Next run",accessor:e=>e.nextRun??null},status:{label:"Status",accessor:e=>e.status==="pending_approval"?"pending_approval":e.enabled?"active":"paused"}},aet=8,oet={visible:{transition:{staggerChildren:.04}},hidden:{}},cet={hidden:{opacity:0,y:8},visible:{opacity:1,y:0}};function uet({tasks:e,isLoading:t,agentMap:n,onEditTask:s,agentId:r}){const i=Ane(RU,{debounce:{search:200}}),[o]=x.useState(0),[l,c]=x.useState(null),u=x.useMemo(()=>r?e.filter(m=>m.agentId===r):e,[e,r]),d=x.useMemo(()=>[...new Set(u.map(m=>m.agentId).filter(m=>!!m))],[u]),f=x.useMemo(()=>Sne(u,RU,i.values,MU,{field:i.sortField,direction:i.sortDirection}),[u,i.values,i.sortField,i.sortDirection]);return t?a.jsx("div",{className:"space-y-3 p-4",children:Array.from({length:3}).map((m,g)=>a.jsx(Jt,{className:"h-14 w-full rounded-xl"},g))}):a.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[a.jsxs(ji,{state:i,children:[a.jsx(ji.Search,{placeholder:"Filter tasks..."}),a.jsx(ji.Primary,{name:"status"}),a.jsx(ji.AddFilter,{dynamicOptions:{agent:d}}),a.jsx(ji.Sort,{options:MU}),a.jsx(ji.ResultCount,{count:f.length,total:u.length,noun:"task"}),a.jsx(ji.ActiveFilters,{})]}),a.jsx(No,{className:"min-h-0 flex-1",children:a.jsx("div",{className:"space-y-2 p-4 pt-0",children:f.length===0&&u.length>0?a.jsxs(te.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3,ease:"easeOut"},className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[a.jsx(hne,{className:"text-muted-foreground/50 size-10"}),a.jsx("p",{className:"text-muted-foreground text-sm",children:i.describeActive()?`No tasks match ${i.describeActive()}`:"No tasks match your filters"}),a.jsx(ge,{variant:"outline",size:"sm",onClick:i.clearAll,children:"Clear filters"})]}):a.jsx(te.div,{initial:"hidden",animate:"visible",variants:oet,className:"space-y-2",children:f.map((m,g)=>a.jsx(te.div,{variants:g<aet?cet:void 0,transition:{duration:.15},children:a.jsx(Cce,{task:m,agent:(m.agentId?n.get(m.agentId):void 0)??null,expanded:l===m.id,onToggleExpand:()=>c(l===m.id?null:m.id),onEdit:()=>s(m)})},m.id))},o)})})]})}function det({totalSteps:e,currentStep:t,onBack:n,onSkip:s,onSkipAll:r}){const i=x.useId();return a.jsxs("div",{className:"grid grid-cols-3 items-center px-4 py-3 sm:px-6",children:[a.jsx(ge,{variant:"ghost",size:"sm",onClick:n,className:"justify-self-start",children:"Back"}),a.jsx("div",{className:"flex items-center justify-center gap-2",children:Array.from({length:e},(o,l)=>a.jsx("div",{className:"relative flex items-center justify-center",children:l===t?a.jsx(te.div,{layoutId:`step-indicator-${i}`,className:"bg-primary flex h-2 w-6 items-center justify-center rounded-full",transition:{type:"spring",damping:25,stiffness:200}}):l<t?a.jsx("div",{className:"bg-primary/60 flex size-2 items-center justify-center rounded-full",children:a.jsx(Lt,{className:"text-primary-foreground size-1.5"})}):a.jsx("div",{className:Y("ring-muted-foreground/30 size-2 rounded-full ring-1")})},l))}),a.jsxs("div",{className:"flex items-center justify-end gap-1",children:[a.jsx(ge,{variant:"ghost",size:"sm",onClick:s,children:"Skip"}),a.jsx(ge,{variant:"ghost",size:"sm",onClick:r,className:"text-muted-foreground",children:"Skip all"})]})]})}const fet={default:"#1A1A1A",white:"#FFFFFF",orange:"#CE2021",current:"currentColor"};function Tv({variant:e="default",size:t=40,className:n,style:s}){const r=fet[e],i=t*(799/2325);return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:i,viewBox:"0 0 2325 799",fill:"none",className:n,style:s,"aria-hidden":"true",children:[a.jsx("rect",{x:"50",y:"50",width:"2225",height:"699",stroke:r,strokeWidth:"100"}),a.jsx("path",{d:"M492.333 199.627L599.833 295.627L600 295.776V491.707L492.207 599.5H199.5V199.5H492.19L492.333 199.627ZM334 347.5V448.5H435V347.5H334Z",fill:r}),a.jsx("path",{d:"M1108.5 497.715L1108.34 497.862L1001.34 599.362L1001.2 599.5H699V296.283L699.158 296.135L802.158 199.635L802.303 199.5H1108.5V497.715ZM855 347.5V448.5H956V347.5H855Z",fill:r}),a.jsx("path",{d:"M1616.94 200.24L1510.07 395.005L1616.94 598.768L1617.64 600.103L1616.28 599.451L1409 500.056L1208.22 599.448L1207.5 599.806V199.5H1617.34L1616.94 200.24ZM1332 337.5V439.207L1433.71 337.5H1332Z",fill:r}),a.jsx("path",{d:"M1716.5 599V200L1841 291.5L2125 200L2017.5 400L2125 599L1841 501L1716.5 599Z",fill:r,stroke:r})]})}const het=["Checking","system","requirements"],met=["Ready","to","go"],pet=["Almost","there"],get=600,xet=800;function yet({onContinue:e,simulatedResult:t}){const n=je(),s=Ds(),[r,i]=x.useState("checking"),[o,l]=x.useState(null),[c,u]=x.useState(null),[d,f]=x.useState(0),[m,g]=x.useState(0),[y,b]=x.useState(new Set),S=x.useRef(!1),w=x.useCallback(()=>{i("checking"),l(null),u(null),g(0),b(new Set),S.current=!1,f(N=>N+1)},[]);x.useEffect(()=>{let N=!1;async function R(){const O=Date.now();let M=null,L=null;if(t)M=t;else try{M=await n.checkRequirements()}catch(q){L=q instanceof Error?q.message:"Failed to check requirements"}const P=Date.now()-O,$=3e3;P<$&&await new Promise(q=>setTimeout(q,$-P)),!N&&(L?(u(L),i("done")):(l(M),i("revealing")))}return R(),()=>{N=!0}},[n,t,d]);const C=o?Object.values(o.runtimes).flatMap(N=>N.dependencies):[],T=(o==null?void 0:o.allSatisfied)??!1,E=C.filter(N=>N.status!=="satisfied");x.useEffect(()=>{if(!(r!=="revealing"||C.length===0)&&m<C.length){const N=setTimeout(()=>g(R=>R+1),m===0?200:get);return()=>clearTimeout(N)}},[r,m,C.length]),x.useEffect(()=>{if(r==="revealing")for(let N=0;N<m;N++){if(y.has(N))continue;const R=setTimeout(()=>{b(O=>new Set(O).add(N))},xet);return()=>clearTimeout(R)}},[r,m,y]),x.useEffect(()=>{if(r!=="revealing"||C.length===0||y.size<C.length)return;const N=setTimeout(()=>{i("done"),T&&!S.current&&(S.current=!0,Yv())},400);return()=>clearTimeout(N)},[r,y.size,C.length,T]);const j=r==="done"?T?met:pet:het,_=r==="checking"||r==="revealing";return a.jsx(yv,{children:a.jsxs(te.div,{layout:!s,className:"mx-auto flex w-full max-w-md flex-col items-center px-4 text-center",transition:{layout:{duration:.4,ease:[.25,.1,.25,1]}},children:[a.jsx(te.div,{layout:!s,className:"mb-8",initial:s?!1:{opacity:0,scale:.8},animate:{opacity:_?.6:.9,scale:1},transition:{duration:.5},children:a.jsxs(te.div,{animate:_&&!s?{scale:[1,1.04,1],opacity:[.6,.8,.6]}:{scale:1,opacity:1},transition:_?{duration:2,repeat:1/0,ease:"easeInOut"}:{},children:[a.jsx(Tv,{size:120,className:"dark:hidden"}),a.jsx(Tv,{variant:"white",size:120,className:"hidden dark:block"})]})}),a.jsx(te.div,{layout:!s,children:a.jsx(Ue,{mode:"wait",children:a.jsx(te.h1,{className:"text-2xl font-semibold tracking-tight sm:text-3xl",children:s?j.join(" "):a.jsx(te.span,{initial:"hidden",animate:"visible",exit:"exit",variants:{visible:{transition:{staggerChildren:.08}},exit:{transition:{staggerChildren:.02,staggerDirection:-1}}},children:j.map((N,R)=>a.jsxs(te.span,{className:"inline-block",variants:{hidden:{opacity:0,filter:"blur(4px)"},visible:{opacity:1,filter:"blur(0px)"},exit:{opacity:0,filter:"blur(4px)"}},transition:{duration:.3},children:[N,R<j.length-1?" ":""]},R))})},j.join("-"))})}),a.jsx(Ue,{mode:"wait",children:a.jsx(te.p,{className:"text-muted-foreground mt-3 text-sm",initial:s?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:r==="checking"?"Making sure everything is in place.":r==="revealing"?"Verifying dependencies...":T?"Everything checked out perfectly.":"Some dependencies need to be installed."},r+String(T))}),a.jsxs(te.div,{layout:!s,className:"mt-8 w-full",children:[a.jsx(Ue,{children:r==="checking"&&a.jsx(vet,{},"scanning")}),a.jsx(Ue,{children:r==="done"&&c&&a.jsxs(te.div,{className:"border-border bg-card rounded-xl border p-4 text-left",initial:s?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(es,{className:"text-destructive size-4 shrink-0"}),a.jsx("span",{className:"text-sm font-medium",children:"Could not reach the server"})]}),a.jsx("p",{className:"text-muted-foreground mt-1.5 text-xs",children:c})]},"error")}),(r==="revealing"||r==="done")&&!c&&a.jsx("div",{className:"space-y-3",children:C.map((N,R)=>{if(R>=m)return null;const O=y.has(R);return a.jsx(bet,{dep:N,isResolved:O,index:R},N.name)})}),a.jsx(Ue,{children:r==="done"&&E.length>0&&a.jsxs(te.div,{className:"border-border bg-card mt-3 space-y-3 rounded-xl border p-4 text-left",initial:s?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{delay:.15,duration:.3},children:[a.jsx("p",{className:"text-sm font-medium",children:E.length===1?"One dependency is missing":`${E.length} dependencies are missing`}),E.map(N=>a.jsx(sP,{command:N.installHint,infoUrl:N.infoUrl,copyLabel:`Copy install command for ${N.name}`},N.name))]})})]}),a.jsxs(Ue,{mode:"wait",children:[r==="done"&&!c&&a.jsx(te.div,{layout:!s,className:"mt-10 flex flex-col items-center gap-3",initial:s?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{delay:.3,duration:.35},children:T?a.jsx(YI,{className:"px-6 py-2",duration:1.2,onClick:e,children:"Continue"}):a.jsxs(a.Fragment,{children:[a.jsxs(ge,{onClick:w,variant:"outline",className:"gap-2",children:[a.jsx(ma,{className:"size-3.5"}),"Check again"]}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Install the missing dependencies, then check again."})]})},T?"continue":"recheck"),r==="done"&&c&&a.jsx(te.div,{layout:!s,className:"mt-10 flex flex-col items-center gap-3",initial:s?!1:{opacity:0},animate:{opacity:1},transition:{delay:.3,duration:.35},children:a.jsxs(ge,{onClick:w,variant:"outline",className:"gap-2",children:[a.jsx(ma,{className:"size-3.5"}),"Try again"]})},"error-recheck")]})]})})}function vet(){const e=Ds();return a.jsxs(te.div,{className:"flex flex-col items-center gap-4 py-6",initial:e?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:[a.jsx("div",{className:"flex items-center gap-1.5",children:[0,1,2].map(t=>a.jsx(te.div,{className:"bg-muted-foreground/40 size-2 rounded-full",animate:e?{}:{scale:[1,1.5,1],opacity:[.3,1,.3]},transition:{duration:1.2,repeat:1/0,delay:t*.2,ease:"easeInOut"}},t))}),a.jsx("span",{className:"text-muted-foreground text-sm",children:"Scanning..."})]})}function bet({dep:e,isResolved:t,index:n}){const s=e.status==="satisfied",r=Ds();return a.jsxs(te.div,{className:Y("flex items-center gap-3 rounded-xl border px-4 py-3.5 transition-colors duration-500",t&&s&&"border-emerald-500/20 bg-emerald-500/5",t&&!s&&"border-destructive/20 bg-destructive/5",!t&&"border-border bg-card"),initial:r?!1:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{type:"spring",damping:24,stiffness:200,delay:n*.05},children:[a.jsx(Ue,{mode:"wait",children:t?s?a.jsx(te.div,{className:"flex size-7 items-center justify-center rounded-full bg-emerald-500/15",initial:r?!1:{scale:0},animate:{scale:1},transition:{type:"spring",damping:10,stiffness:400},children:a.jsx(Lt,{className:"size-4 text-emerald-500"})},"pass"):a.jsx(te.div,{className:"bg-destructive/10 flex size-7 items-center justify-center rounded-full",initial:r?!1:{scale:0},animate:{scale:1},transition:{type:"spring",damping:14,stiffness:300},children:a.jsx(es,{className:"text-destructive size-4"})},"fail"):a.jsx(te.div,{className:"bg-muted flex size-7 items-center justify-center rounded-full",exit:r?{}:{scale:0,opacity:0},transition:{duration:.15},children:a.jsx(te.div,{className:"bg-muted-foreground/30 size-3 rounded-full",animate:r?{}:{opacity:[.3,.8,.3]},transition:{duration:1,repeat:1/0,ease:"easeInOut"}})},"scanning")}),a.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[a.jsx("p",{className:"text-sm font-medium",children:e.name}),a.jsx(Ue,{mode:"wait",children:t?a.jsx(te.p,{className:"text-muted-foreground truncate text-xs",initial:r?!1:{opacity:0},animate:{opacity:1},transition:{duration:.3},children:s&&e.version?`v${e.version}`:e.description},"resolved"):a.jsx(te.p,{className:"text-muted-foreground/50 text-xs",exit:{opacity:0},transition:{duration:.1},children:"Checking..."},"scanning")})]})]})}const LA=["Welcome","to","DorkOS"],wet=[{icon:Cs,label:"Create agents"},{icon:Pi,label:"Schedule tasks"},{icon:WE,label:"Connect channels"}];function ket({onGetStarted:e,onSkip:t}){const n=Ds();return a.jsxs("div",{className:"mx-auto flex w-full max-w-md flex-col items-center px-4 text-center",children:[a.jsxs(te.div,{className:"mb-6 opacity-80",initial:n?!1:{opacity:0,scale:.8},animate:{opacity:.8,scale:1},transition:{duration:.4},children:[a.jsx(Tv,{size:150,className:"dark:hidden"}),a.jsx(Tv,{variant:"white",size:150,className:"hidden dark:block"})]}),a.jsx("h1",{className:"text-3xl font-semibold tracking-tight sm:text-4xl",children:n?LA.join(" "):a.jsx(te.span,{initial:"hidden",animate:"visible",variants:{visible:{transition:{staggerChildren:.08}}},children:LA.map((s,r)=>a.jsxs(te.span,{className:"inline-block",variants:{hidden:{opacity:0,filter:"blur(4px)"},visible:{opacity:1,filter:"blur(0px)"}},transition:{duration:.4},children:[s,r<LA.length-1?" ":""]},r))})}),a.jsx(te.p,{className:"text-muted-foreground mt-4",initial:n?!1:{opacity:0},animate:{opacity:1},transition:{delay:.4,duration:.5},children:"Your agents are three steps away."}),a.jsx(te.div,{className:"mt-10 flex gap-8",initial:n?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:.6,duration:.4},children:wet.map(({icon:s,label:r},i)=>a.jsxs("div",{className:"flex flex-col items-center gap-2",children:[a.jsx("div",{className:"bg-muted flex size-10 items-center justify-center rounded-lg",children:a.jsx(s,{className:"text-muted-foreground size-5"})}),a.jsx("span",{className:"text-muted-foreground text-xs",children:r})]},i))}),a.jsxs(te.div,{className:"mt-12 flex flex-col items-center gap-3",initial:n?!1:{opacity:0},animate:{opacity:1},transition:{delay:.8,duration:.4},children:[a.jsx(YI,{className:"px-6 py-2",duration:1.2,onClick:e,children:"Get Started"}),a.jsx("button",{onClick:t,className:"text-muted-foreground hover:text-foreground text-sm transition-colors",children:"Skip setup"})]})]})}function Cet(e){const{verbosity:t}=e;return t>=4?"Hey! I'm DorkBot — your personal agent running on DorkOS. I can help with scheduling (Tasks), messaging (Relay), and discovering other agents (Mesh). What are we building today?":t<=2?"DorkBot online. I'm your default DorkOS agent. Tools available: Tasks (scheduling), Relay (messaging), Mesh (discovery). Ready for instructions.":"Hi, I'm DorkBot — your default agent in DorkOS. I have access to Tasks for scheduling, Relay for messaging, and Mesh for agent discovery. How can I help?"}const yd=gl()(kd(e=>({activeTab:"sessions",setActiveTab:t=>e({activeTab:t}),agentPath:null,setAgentPath:t=>e({agentPath:t}),openHub:(t,n)=>e({agentPath:t,activeTab:n??"sessions"})}),{name:"agent-hub"})),Ece=x.createContext(void 0);function GSt({value:e,children:t}){return a.jsx(Ece.Provider,{value:e,children:t})}function KSt(){const e=x.useContext(Ece);if(!e)throw new Error("useAgentHubContext must be used within an AgentHubProvider");return e}const Tce={nebula:"#7c3aed",wisp:"#a78bfa",stroke:"#a78bfa",strokeEnd:"#c4b5fd",fill:"#7c3aed",fillEnd:"#a78bfa",glow:"#a78bfa",dot:"#c4b5fd"},_ce=[{id:"balanced",name:"Balanced",emoji:"🤖",tagline:"The default. Steady, reliable, explains when it matters.",traits:{verbosity:3,autonomy:3,chaos:3,creativity:3,humor:3,spice:3},sampleResponse:"I'll handle this step by step. Let me explain my approach, then implement it. I'll check with you before making any irreversible changes.",colors:{nebula:"#7c3aed",wisp:"#a78bfa",stroke:"#a78bfa",strokeEnd:"#c4b5fd",fill:"#7c3aed",fillEnd:"#a78bfa",glow:"#a78bfa",dot:"#c4b5fd"}},{id:"hotshot",name:"The Hotshot",emoji:"🔥",tagline:"Ship fast, explain later. Turns caffeine into commits.",traits:{verbosity:2,autonomy:5,chaos:4,creativity:5,humor:3,spice:4},sampleResponse:"Done. Pushed the fix, tests pass, already moved on. Used a completely new approach btw — way cleaner.",colors:{nebula:"#ea580c",wisp:"#f97316",stroke:"#fb923c",strokeEnd:"#fbbf24",fill:"#ea580c",fillEnd:"#f59e0b",glow:"#fb923c",dot:"#fbbf24"}},{id:"sage",name:"The Sage",emoji:"🧐",tagline:"Teaches as it works. Every answer is a lesson.",traits:{verbosity:5,autonomy:2,chaos:1,creativity:3,humor:2,spice:1},sampleResponse:"This is a great learning opportunity. The issue stems from a race condition in the useEffect cleanup. Let me walk you through why this happens and three ways to fix it...",colors:{nebula:"#0ea5e9",wisp:"#06b6d4",stroke:"#22d3ee",strokeEnd:"#67e8f9",fill:"#0ea5e9",fillEnd:"#06b6d4",glow:"#22d3ee",dot:"#67e8f9"}},{id:"sentinel",name:"The Sentinel",emoji:"🛡",tagline:"Measure twice, cut once. Asks before every action.",traits:{verbosity:3,autonomy:1,chaos:1,creativity:2,humor:1,spice:2},sampleResponse:"Before I make any changes, I want to confirm: should I modify the auth middleware directly, or create a new wrapper? Both approaches have trade-offs I'd like to discuss.",colors:{nebula:"#16a34a",wisp:"#22c55e",stroke:"#4ade80",strokeEnd:"#86efac",fill:"#16a34a",fillEnd:"#10b981",glow:"#4ade80",dot:"#86efac"}},{id:"phantom",name:"The Phantom",emoji:"👻",tagline:"You'll barely know it's there. Pure silent execution.",traits:{verbosity:1,autonomy:5,chaos:3,creativity:3,humor:1,spice:3},sampleResponse:"Fixed.",colors:{nebula:"#6366f1",wisp:"#4338ca",stroke:"#818cf8",strokeEnd:"#a5b4fc",fill:"#4338ca",fillEnd:"#6366f1",glow:"#818cf8",dot:"#a5b4fc"}},{id:"mad-scientist",name:"Mad Scientist",emoji:"🎨",tagline:"Wild ideas, unexpected solutions. Thrives on chaos.",traits:{verbosity:4,autonomy:4,chaos:5,creativity:5,humor:4,spice:4},sampleResponse:"Okay hear me out — what if instead of fixing the N+1 query, we restructure the entire data layer? ngl it's kinda unhinged but it would solve three other problems too...",colors:{nebula:"#d946ef",wisp:"#a855f7",stroke:"#e879f9",strokeEnd:"#f0abfc",fill:"#d946ef",fillEnd:"#ec4899",glow:"#e879f9",dot:"#f0abfc"}},{id:"the-bro",name:"The Bro",emoji:"🤙",tagline:"Your unfiltered coding buddy. No filter, all vibes.",traits:{verbosity:4,autonomy:4,chaos:4,creativity:3,humor:4,spice:5},sampleResponse:"dude this codebase is absolutely unhinged lmao. ok I see the bug tho, gimme a sec... alright fixed that shit. whoever wrote this original code needs to be stopped fr fr",colors:{nebula:"#dc2626",wisp:"#ef4444",stroke:"#f87171",strokeEnd:"#fca5a5",fill:"#dc2626",fillEnd:"#ef4444",glow:"#f87171",dot:"#fca5a5"}},{id:"drill-sergeant",name:"Drill Sergeant",emoji:"🎖",tagline:"Terse. Efficient. Gets the job done with zero nonsense.",traits:{verbosity:2,autonomy:5,chaos:2,creativity:1,humor:1,spice:4},sampleResponse:"The bug is in line 47. Wrong comparison operator. Fixed it. Tests pass. Don't let it happen again.",colors:{nebula:"#475569",wisp:"#64748b",stroke:"#94a3b8",strokeEnd:"#cbd5e1",fill:"#334155",fillEnd:"#475569",glow:"#94a3b8",dot:"#cbd5e1"}}];function Eet(e){return _ce.find(t=>t.traits.verbosity===e.verbosity&&t.traits.autonomy===e.autonomy&&t.traits.chaos===e.chaos&&t.traits.creativity===e.creativity&&t.traits.humor===e.humor&&t.traits.spice===e.spice)}const Tet=["Verbosity","Autonomy","Chaos","Creativity","Humor","Spice"],dw=["verbosity","autonomy","chaos","creativity","humor","spice"],wC=6,gP=5,DU=3,_et=800,Net=600,OU={light:{nebulaCenter:.45,nebulaMid:.25,wispStart:.2,fillStart:.25,fillEnd:.15,haloBase:.25,haloAmplitude:.12,breatheMin:.25,breatheMax:.4,guideBase:.1,guideStep:.04,axis:.12,stardustPeak:1,glowBlur:12,vertexBlur:4},dark:{nebulaCenter:.35,nebulaMid:.15,wispStart:.12,fillStart:.35,fillEnd:.25,haloBase:.15,haloAmplitude:.1,breatheMin:.15,breatheMax:.25,guideBase:.06,guideStep:.02,axis:.08,stardustPeak:.8,glowBlur:10,vertexBlur:4}},jet=[{r:1.2,dur:"9s",fade:"4.5s",begin:"0s",path:"M0,0 C30,-40 60,0 40,40 C20,60 -20,40 -30,10 C-40,-20 -10,-50 0,0"},{r:.9,dur:"7s",fade:"3.5s",begin:"0s",path:"M0,0 C-20,30 -40,20 -30,-10 C-20,-30 10,-40 20,-20 C30,0 20,30 0,0"},{r:1,dur:"11s",fade:"5s",begin:"0s",path:"M0,0 C40,10 30,50 0,40 C-30,30 -40,-10 -20,-30 C0,-50 30,-20 0,0"},{r:.7,dur:"8s",fade:"4s",begin:"2s",path:"M0,0 C15,-35 45,-15 35,20 C25,45 -15,40 -25,15 C-35,-10 -5,-40 0,0"},{r:1.1,dur:"12s",fade:"6s",begin:"1s",path:"M0,0 C-25,25 -45,5 -30,-20 C-15,-45 20,-35 30,-10 C40,15 15,35 0,0"}];function ak(e,t,n,s){const r=Math.PI*2*e/wC-Math.PI/2,i=t/gP*s;return{x:n+i*Math.cos(r),y:n+i*Math.sin(r)}}function kD(e){return e.map(t=>`${t.x},${t.y}`).join(" ")}function Aet(e,t,n){return kD(Array.from({length:wC},(s,r)=>ak(r,e*gP,t,n)))}function Ret(e){return e<.5?4*e*e*e:1-(-2*e+2)**3/2}function Met({traits:e,colors:t=Tce,size:n=180,animated:s=!0,className:r}){const i=x.useId().replace(/:/g,""),o=hP(),l=o?OU.dark:OU.light,c=x.useRef(l);c.current=l;const u=o?{strokeStart:t.stroke,strokeEnd:t.strokeEnd,fillStart:t.fill,fillEnd:t.fillEnd,dot:t.dot,glow:t.glow}:{strokeStart:t.fill,strokeEnd:t.fillEnd,fillStart:t.stroke,fillEnd:t.strokeEnd,dot:t.fill,glow:t.stroke},d=n/2,f=n*.32,m=f+16,g=n/200,y=x.useRef(null),b=x.useRef(null),S=x.useRef([]),w=x.useRef([]),C=x.useRef({current:{...e},from:null,target:{...e},morphStart:0,breathe:0}),T=x.useRef(e);x.useEffect(()=>{const R=T.current;if(dw.some(M=>R[M]!==e[M])){const M=C.current;if(s){M.from={...M.current},M.target={...e},M.morphStart=performance.now();const L=b.current;if(L){const P=performance.now();(function $(){const q=Math.min((performance.now()-P)/Net,1),K=1-(1-q)*(1-q);L.setAttribute("r",String(f*(.7+.6*K))),L.setAttribute("opacity",String(.4*(1-K))),q<1&&requestAnimationFrame($)})()}}else Object.assign(M.current,e),Object.assign(M.target,e)}T.current=e},[e,s,f]),x.useEffect(()=>{if(!s)return;let R;const O=C.current;function M(){var q;O.breathe+=.015;const L=1+Math.sin(O.breathe)*.04;if(O.from){const K=Math.min((performance.now()-O.morphStart)/_et,1),B=Ret(K);for(const V of dw)O.current[V]=O.from[V]+(O.target[V]-O.from[V])*B;K>=1&&(O.from=null,Object.assign(O.current,O.target))}const $=dw.map(K=>O.current[K]).map((K,B)=>ak(B,K*L,d,f));(q=y.current)==null||q.setAttribute("points",kD($)),$.forEach((K,B)=>{const V=S.current[B],Q=w.current[B];if(V){V.setAttribute("cx",String(K.x)),V.setAttribute("cy",String(K.y)),V.setAttribute("r",String(8+Math.sin(O.breathe+B*1.2)*3));const re=c.current;V.setAttribute("opacity",String(re.haloBase+Math.sin(O.breathe+B)*re.haloAmplitude))}Q&&(Q.setAttribute("cx",String(K.x)),Q.setAttribute("cy",String(K.y)),Q.setAttribute("r",String(3.5+Math.sin(O.breathe+B*.8)*.8)))}),R=requestAnimationFrame(M)}return R=requestAnimationFrame(M),()=>cancelAnimationFrame(R)},[s,d,f]);const E=dw.map((R,O)=>ak(O,e[R],d,f)),j=kD(E),_={transition:"stop-color 0.6s ease"},N={transition:"fill 0.6s ease"};return a.jsxs("svg",{viewBox:`0 0 ${n} ${n}`,className:Y("aspect-square",r),"aria-label":"Personality radar chart",role:"img",children:[a.jsxs("defs",{children:[o?a.jsxs("filter",{id:`ng-${i}`,x:"-80%",y:"-80%",width:"260%",height:"260%",children:[a.jsx("feGaussianBlur",{stdDeviation:l.glowBlur,result:"blur"}),a.jsxs("feMerge",{children:[a.jsx("feMergeNode",{in:"blur"}),a.jsx("feMergeNode",{in:"blur"}),a.jsx("feMergeNode",{in:"SourceGraphic"})]})]}):a.jsx("filter",{id:`ng-${i}`,x:"-50%",y:"-30%",width:"200%",height:"200%",children:a.jsx("feDropShadow",{dx:"0",dy:"2",stdDeviation:"6",floodColor:u.strokeStart,floodOpacity:"0.18"})}),a.jsxs("filter",{id:`vg-${i}`,x:"-100%",y:"-100%",width:"300%",height:"300%",children:[a.jsx("feGaussianBlur",{stdDeviation:l.vertexBlur,result:"blur"}),a.jsxs("feMerge",{children:[a.jsx("feMergeNode",{in:"blur"}),a.jsx("feMergeNode",{in:"SourceGraphic"})]})]}),a.jsxs("radialGradient",{id:`nc-${i}`,cx:"50%",cy:"50%",r:"50%",children:[a.jsx("stop",{offset:"0%",style:{stopColor:t.nebula,stopOpacity:l.nebulaCenter,..._}}),a.jsx("stop",{offset:"50%",style:{stopColor:t.nebula,stopOpacity:l.nebulaMid,..._}}),a.jsx("stop",{offset:"100%",style:{stopColor:"var(--nebula-edge)"},stopOpacity:0})]}),a.jsxs("radialGradient",{id:`nw-${i}`,cx:"35%",cy:"35%",r:"60%",children:[a.jsx("stop",{offset:"0%",style:{stopColor:t.wisp,stopOpacity:l.wispStart,..._}}),a.jsx("stop",{offset:"100%",style:{stopColor:"var(--nebula-edge)"},stopOpacity:0})]}),a.jsxs("linearGradient",{id:`sf-${i}`,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[a.jsx("stop",{offset:"0%",style:{stopColor:u.fillStart,stopOpacity:l.fillStart,..._}}),a.jsx("stop",{offset:"100%",style:{stopColor:u.fillEnd,stopOpacity:l.fillEnd,..._}})]}),a.jsxs("linearGradient",{id:`ss-${i}`,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[a.jsx("stop",{offset:"0%",style:{stopColor:u.strokeStart,..._}}),a.jsx("stop",{offset:"100%",style:{stopColor:u.strokeEnd,..._}})]})]}),a.jsx("circle",{cx:d,cy:d,r:n*.44,fill:`url(#nc-${i})`,children:s&&a.jsx("animateTransform",{attributeName:"transform",type:"rotate",values:`0 ${d} ${d};360 ${d} ${d}`,dur:"90s",repeatCount:"indefinite"})}),a.jsx("ellipse",{cx:d*.94,cy:d*.97,rx:n*.35,ry:n*.25,fill:`url(#nw-${i})`,children:s&&a.jsx("animateTransform",{attributeName:"transform",type:"rotate",values:`0 ${d} ${d};-360 ${d} ${d}`,dur:"60s",repeatCount:"indefinite"})}),s&&a.jsxs("circle",{cx:d,cy:d,r:f*.92,fill:"none",style:{stroke:u.strokeStart,transition:"stroke 0.6s ease"},strokeWidth:.3,opacity:l.breatheMin,children:[a.jsx("animate",{attributeName:"r",values:`${f*.85};${f*1.08};${f*.85}`,dur:"4s",repeatCount:"indefinite",calcMode:"spline",keySplines:"0.4 0 0.6 1;0.4 0 0.6 1"}),a.jsx("animate",{attributeName:"opacity",values:`${l.breatheMin};${l.breatheMax};${l.breatheMin}`,dur:"4s",repeatCount:"indefinite",calcMode:"spline",keySplines:"0.4 0 0.6 1;0.4 0 0.6 1"})]}),s&&a.jsx("g",{transform:`translate(${d},${d}) scale(${g})`,children:jet.map((R,O)=>a.jsxs("circle",{r:R.r,style:{fill:u.dot,...N},children:[a.jsx("animateMotion",{dur:R.dur,repeatCount:"indefinite",begin:R.begin,path:R.path}),a.jsx("animate",{attributeName:"opacity",values:`0;${l.stardustPeak};0`,dur:R.fade,repeatCount:"indefinite",begin:R.begin})]},`star-${O}`))}),a.jsx("circle",{ref:b,cx:d,cy:d,r:0,fill:t.nebula,opacity:0}),Array.from({length:DU},(R,O)=>a.jsx("polygon",{points:Aet((O+1)/DU,d,f),fill:"none",stroke:o?"currentColor":u.strokeStart,strokeWidth:.5,opacity:l.guideBase+O*l.guideStep},`ring-${O}`)),Array.from({length:wC},(R,O)=>{const M=ak(O,gP,d,f);return a.jsx("line",{x1:d,y1:d,x2:M.x,y2:M.y,stroke:o?"currentColor":u.strokeStart,strokeWidth:.5,opacity:l.axis},`axis-${O}`)}),a.jsx("polygon",{ref:y,points:j,fill:`url(#sf-${i})`,stroke:`url(#ss-${i})`,strokeWidth:2,strokeLinejoin:"round",filter:`url(#ng-${i})`}),E.map((R,O)=>a.jsx("circle",{ref:M=>{S.current[O]=M},cx:R.x,cy:R.y,r:8,style:{fill:u.glow,...N},opacity:l.haloBase},`halo-${O}`)),E.map((R,O)=>a.jsx("circle",{ref:M=>{w.current[O]=M},cx:R.x,cy:R.y,r:o?4:4.5,style:{fill:u.dot,...N},stroke:o?"none":"white",strokeWidth:o?0:1.5,filter:`url(#vg-${i})`},`dot-${O}`)),Tet.map((R,O)=>{const M=Math.PI*2*O/wC-Math.PI/2;return a.jsx("text",{x:d+m*Math.cos(M),y:d+m*Math.sin(M),textAnchor:"middle",dominantBaseline:"middle",fill:"currentColor",opacity:.5,fontSize:8,className:"select-none",children:R},R)})]})}const IU={duration:.2,ease:"easeInOut"};function Det({traits:e,onTraitsChange:t,compact:n=!1,sampleLabel:s="How this agent talks",className:r}){const[i,o]=x.useState("presets"),l=Eet(e),c=(l==null?void 0:l.colors)??Tce,u=x.useCallback(m=>{t(m.traits),o("presets"),Cx()},[t]),d=x.useCallback(()=>{o("custom"),Cx()},[]),f=x.useCallback(()=>{o("presets"),Cx()},[]);return a.jsxs("div",{className:Y("@container/picker w-full",r),children:[a.jsxs("div",{className:Y("flex flex-col items-center gap-3","@[480px]/picker:flex-row @[480px]/picker:items-center @[480px]/picker:gap-6"),children:[a.jsxs("div",{className:Y("flex flex-col items-center gap-1","@[480px]/picker:w-[200px] @[480px]/picker:shrink-0"),children:[a.jsx("div",{"data-testid":"personality-radar",children:a.jsx(Met,{traits:e,colors:c,size:n?180:200,className:n?"w-[90%] max-w-[240px]":"w-full max-w-[200px]"})}),a.jsxs("div",{className:"text-center",children:[a.jsx("h3",{className:"bg-clip-text text-sm font-bold text-transparent",style:{backgroundImage:`linear-gradient(135deg, ${c.stroke}, ${c.strokeEnd})`},children:(l==null?void 0:l.name)??"Custom"}),a.jsx("p",{className:"text-muted-foreground mt-0.5 text-[11px]",children:(l==null?void 0:l.tagline)??"A custom blend of personality traits."})]})]}),a.jsx("div",{className:"flex w-full min-w-0 flex-col items-center gap-3 @[480px]/picker:items-start",children:a.jsx(Ue,{mode:"wait",initial:!1,children:i==="presets"?a.jsxs(te.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:IU,className:"flex max-w-sm flex-wrap justify-center gap-1.5 @[480px]/picker:justify-start","data-testid":"preset-pills",children:[_ce.map(m=>a.jsx(JQe,{emoji:m.emoji,name:m.name,colors:m.colors,active:(l==null?void 0:l.id)===m.id,size:n?"sm":"default",glow:!0,onClick:()=>u(m)},m.id)),a.jsxs("button",{type:"button",onClick:d,className:Y("inline-flex shrink-0 items-center gap-1.5 rounded-full border border-dashed font-medium transition-all","text-muted-foreground hover:text-foreground hover:border-foreground/20 border-border",n?"px-2.5 py-1 text-[11px]":"px-3 py-1 text-xs"),"data-testid":"custom-toggle",children:[a.jsx(qa,{className:"size-3"}),a.jsx("span",{children:"Custom"})]})]},"presets"):a.jsxs(te.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:IU,className:"flex w-full flex-col items-center gap-3 @[480px]/picker:items-start",children:[a.jsxs("div",{className:"flex gap-1.5","data-testid":"custom-mode-pills",children:[a.jsxs("button",{type:"button",onClick:f,className:Y("inline-flex shrink-0 items-center gap-1.5 rounded-full border border-dashed font-medium transition-all","text-muted-foreground hover:text-foreground hover:border-foreground/20 border-border",n?"px-2.5 py-1 text-[11px]":"px-3 py-1 text-xs"),"data-testid":"presets-toggle",children:[a.jsx("span",{children:"←"}),a.jsx("span",{children:"Presets"})]}),a.jsxs("span",{className:Y("bg-accent text-foreground inline-flex shrink-0 items-center gap-1.5 rounded-full border font-medium","border-foreground/15",n?"px-2.5 py-1 text-[11px]":"px-3 py-1 text-xs"),children:[a.jsx(qa,{className:"size-3"}),a.jsx("span",{children:"Custom"})]})]}),a.jsx("div",{className:Y("w-full",n?"max-w-sm":"max-w-md"),onPointerDown:()=>Cx(),children:a.jsx(nJe,{traits:e,onChange:t,onSliderChange:()=>Cx()})})]},"custom")})})]}),a.jsxs("div",{className:"hidden w-full max-w-sm",children:[a.jsx("span",{className:"text-muted-foreground text-[9px] font-medium tracking-wider uppercase",children:s}),a.jsx("div",{className:"bg-accent/50 mt-1 rounded-lg p-3",children:a.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed italic",children:(l==null?void 0:l.sampleResponse)??"This agent uses a custom personality blend. Select a preset to see a sample response."})})]})]})}const Oet=x.lazy(()=>ks(()=>import("./SessionsTab-Di1R_A1t.js"),[]).then(e=>({default:e.SessionsTab}))),Iet=x.lazy(()=>ks(()=>import("./ConfigTab-DJu3oDC2.js"),[]).then(e=>({default:e.ConfigTab}))),Pet=x.lazy(()=>ks(()=>import("./ToolkitTab-a2dYMBx9.js"),[]).then(e=>({default:e.ToolkitTab})));function WSt(){const e=yd(n=>n.activeTab),t={sessions:Oet,config:Iet,toolkit:Pet}[e];return a.jsx("div",{"data-slot":"agent-hub-tab-content",className:"flex-1 overflow-auto",children:a.jsx(x.Suspense,{fallback:null,children:a.jsx(t,{})})})}function Let({onStepComplete:e}){const[t,n]=x.useState({...eJe}),[s,r]=x.useState(null),i=_Qe(),{config:o}=Wb(),l=we(u=>u.setDorkbotFirstMessage),c=x.useCallback(()=>{var f;r(null);const d=`${((f=o==null?void 0:o.agents)==null?void 0:f.defaultDirectory)||"~/.dork/agents"}/dorkbot`;i.mutate({path:d,updates:{traits:t}},{onSuccess:()=>{l(Cet(t)),GZ(),e()},onError:m=>{r(m instanceof Error?m.message:"Failed to update personality")}})},[t,o,i,e,l]);return a.jsxs("div",{className:"flex flex-1 flex-col items-center gap-4 overflow-y-auto py-4",children:[a.jsxs("div",{className:"space-y-2 text-center",children:[a.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:"Meet DorkBot"}),a.jsxs("p",{className:"text-muted-foreground max-w-sm text-sm",children:["Your first agent and DorkOS expert.",a.jsx("br",{}),"Choose DorkBot's personality."]})]}),a.jsx(Det,{traits:t,onTraitsChange:n,sampleLabel:"How DorkBot will talk"}),s&&a.jsx("p",{className:"text-destructive text-sm",role:"alert","data-testid":"update-error",children:s}),a.jsxs("div",{className:"mt-2 flex flex-col items-center gap-2",children:[a.jsx(ge,{onClick:c,disabled:i.isPending,"data-testid":"continue-dorkbot",children:i.isPending?"Saving...":"Continue"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Adjustable anytime in settings."})]})]})}const PU={candidates:[],existingAgents:[],progress:null,isScanning:!1,error:null,lastScanAt:null},xP=gl()(kd(e=>({...PU,startScan:()=>e({candidates:[],existingAgents:[],progress:null,isScanning:!0,error:null},!1,"discovery/startScan"),addCandidate:t=>e(n=>({candidates:[...n.candidates,t]}),!1,"discovery/addCandidate"),addExistingAgent:t=>e(n=>({existingAgents:[...n.existingAgents,t]}),!1,"discovery/addExistingAgent"),setProgress:t=>e({progress:t},!1,"discovery/setProgress"),completeScan:t=>e({progress:t,isScanning:!1,lastScanAt:new Date().toISOString()},!1,"discovery/completeScan"),setError:t=>e({error:t,isScanning:!1},!1,"discovery/setError"),reset:()=>e(PU,!1,"discovery/reset")}),{name:"DiscoveryStore"}));function Nce(){const e=je(),t=x.useRef(null),{startScan:n,addCandidate:s,addExistingAgent:r,setProgress:i,completeScan:o,setError:l}=xP(),c=x.useCallback((d={roots:[]})=>{var m;(m=t.current)==null||m.abort();const f=new AbortController;t.current=f,n(),e.scan(d,g=>{switch(g.type){case"candidate":s(g.data);break;case"existing-agent":r(g.data);break;case"progress":i(g.data);break;case"complete":o(g.data);break;case"error":l(g.data.error);break}},f.signal).catch(g=>{g instanceof Error&&g.name!=="AbortError"&&l(g.message)})},[e,n,s,r,i,o,l]),u=x.useCallback(()=>{var d;(d=t.current)==null||d.abort(),t.current=null},[]);return{startScan:c,stopScan:u}}function jce(){const[e,t]=x.useState(new Set),n=x.useCallback(r=>{t(i=>new Set(i).add(r))},[]),s=x.useCallback(()=>{t(new Set)},[]);return{actedPaths:e,markActed:n,resetActed:s}}function kC(e){return{name:e.hints.suggestedName,runtime:e.hints.detectedRuntime,...e.hints.inferredCapabilities?{capabilities:e.hints.inferredCapabilities}:{},...e.hints.description?{description:e.hints.description}:{}}}function Ace(e){return[...e].sort((t,n)=>{const s=t.strategy==="dork-manifest",r=n.strategy==="dork-manifest";return s!==r?s?-1:1:t.path.localeCompare(n.path)})}const Fet={"claude-code":"Detected a AGENTS.md file — this is a Claude Code project.",cursor:"Detected a .cursor/ directory — this is a Cursor project.",codex:"Detected a .codex/ directory — this is a Codex project.","dork-manifest":"Found an existing .dork/agent.json — already configured as a DorkOS agent."};function zet(e){return Fet[e]??`Detected via "${e}" strategy.`}const Bet={"code-review":"Reviews code for bugs, style issues, and correctness.",summarize:"Summarizes documents, conversations, or code.","file-ops":"Reads and writes files on the filesystem.",test:"Generates and runs tests for a codebase.",search:"Searches code, files, or the web for relevant information.",refactor:"Refactors code while preserving existing behavior.",analyze:"Analyzes data, logs, or codebases for patterns and insights.",generate:"Generates code, content, or structured output.",debug:"Diagnoses and fixes bugs in code.",deploy:"Manages deployment pipelines and infrastructure changes."};function $et(e){return Bet[e]??"Agent capability detected from project structure."}function Rce({candidate:e,onApprove:t,onDeny:n,onSkip:s,className:r}){const{path:i,strategy:o,hints:l}=e;return a.jsxs(te.div,{"data-slot":"candidate-card",layout:!0,initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.15,ease:"easeOut"},className:Y("flex items-start justify-between rounded-xl border p-4",r),children:[a.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[a.jsx("p",{className:"text-sm leading-tight font-semibold",children:l.suggestedName||i.split("/").pop()||i}),a.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 text-xs",children:[a.jsx(th,{className:"size-3 shrink-0"}),a.jsx("span",{className:"truncate font-mono",children:i})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[a.jsxs(ZI,{openDelay:300,children:[a.jsx(XI,{asChild:!0,children:a.jsx(zt,{variant:"secondary",className:"hover:bg-secondary/80 cursor-default text-xs",children:l.detectedRuntime})}),a.jsxs(QI,{className:"w-56 space-y-1.5 p-3",side:"top",align:"start",children:[a.jsx("p",{className:"text-xs font-medium",children:"Detected runtime"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:zet(o)})]})]}),l.inferredCapabilities&&l.inferredCapabilities.length>0&&l.inferredCapabilities.map(c=>a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx(zt,{variant:"outline",className:"cursor-default text-[10px]",children:c})}),a.jsx(yn,{side:"top",className:"max-w-48 text-center",children:$et(c)})]},c))]})]}),a.jsxs("div",{className:"ml-4 flex shrink-0 items-center gap-1.5",children:[a.jsx("button",{type:"button",onClick:()=>t(e),className:"focus-visible:ring-ring rounded-md bg-green-600/10 px-2.5 py-1 text-xs font-medium text-green-700 hover:bg-green-600/20 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none dark:text-green-400",children:"Add"}),s&&a.jsx("button",{type:"button",onClick:()=>s(e),className:"text-muted-foreground hover:bg-muted focus-visible:ring-ring rounded-md px-2.5 py-1 text-xs font-medium focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",children:"Skip"}),n&&a.jsx("button",{type:"button",onClick:()=>n(e),className:"focus-visible:ring-ring rounded-md bg-red-600/10 px-2.5 py-1 text-xs font-medium text-red-700 hover:bg-red-600/20 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none dark:text-red-400",children:"Deny"})]})]})}function Het({agent:e}){return a.jsxs("div",{className:"bg-muted/50 flex items-center gap-3 rounded-lg border px-4 py-3",children:[a.jsx(Uh,{className:"text-muted-foreground size-4 shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"truncate text-sm font-medium",children:nn(e)}),a.jsx("p",{className:"text-muted-foreground truncate text-xs",children:e.path})]}),a.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:"Imported"})]})}const Uet=2;function Mce({agents:e}){const[t,n]=x.useState(e.length<=Uet);return e.length===0?null:a.jsxs("div",{children:[a.jsxs("button",{type:"button",onClick:()=>n(s=>!s),className:"text-muted-foreground hover:text-foreground flex w-full items-center gap-1.5 py-1.5 text-xs transition-colors",children:[a.jsx(Rs,{className:Y("size-3 transition-transform",t&&"rotate-90")}),e.length," project",e.length===1?"":"s"," already in DorkOS"]}),t&&a.jsx("div",{className:"mt-2 space-y-2",children:e.map(s=>a.jsx(Het,{agent:s},s.path))})]})}function Dce({count:e,onAddAll:t,disabled:n}){return e===0?null:a.jsxs("div",{className:"flex items-center justify-between py-1",children:[a.jsxs("span",{className:"text-muted-foreground text-sm font-medium",children:[e," new project",e===1?"":"s"]}),a.jsx(ge,{variant:"outline",size:"sm",onClick:t,disabled:n,children:"Add All"})]})}function Oce({roots:e,onChange:t}){const[n,s]=x.useState(""),[r,i]=x.useState(!1),o=x.useCallback(d=>{const f=d.trim();f&&!e.includes(f)&&t([...e,f])},[e,t]),l=x.useCallback(d=>{t(e.filter(f=>f!==d))},[e,t]),c=x.useCallback(d=>{(d.key==="Enter"||d.key===",")&&(d.preventDefault(),n.trim()&&(o(n),s(""))),d.key==="Backspace"&&n===""&&e.length>0&&l(e[e.length-1])},[n,e,o,l]),u=x.useCallback(d=>{o(d)},[o]);return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"focus-within:ring-ring flex min-h-[40px] flex-wrap items-center gap-1.5 rounded-md border bg-transparent px-3 py-1.5 focus-within:ring-2",children:[e.map(d=>a.jsxs(zt,{variant:"secondary",className:"gap-1 py-0.5 font-mono text-xs",children:[d,a.jsx("button",{type:"button",onClick:()=>l(d),className:"hover:bg-muted-foreground/20 ml-0.5 rounded-sm","aria-label":`Remove ${d}`,children:a.jsx(es,{className:"size-3"})})]},d)),a.jsx("input",{type:"text",value:n,onChange:d=>s(d.target.value),onKeyDown:c,placeholder:e.length===0?"Add paths to scan (Enter to add)":"Add more...",className:"placeholder:text-muted-foreground min-w-[120px] flex-1 bg-transparent text-sm focus-visible:outline-none"}),a.jsx("button",{type:"button",onClick:()=>i(!0),className:"text-muted-foreground hover:bg-accent hover:text-foreground shrink-0 rounded p-1","aria-label":"Browse for directory",children:a.jsx($c,{className:"size-4"})})]}),a.jsx(ET,{open:r,onOpenChange:i,onSelect:u})]})}function Vet({onAgentCreated:e}){var g;const[t,n]=x.useState(""),[s,r]=x.useState(""),[i,o]=x.useState(""),[l,c]=x.useState(!1),[u,d]=x.useState(!1),f=TQe(),m=x.useCallback(()=>{!t||!s.trim()||f.mutate({path:t,name:s.trim(),description:i.trim()||void 0},{onSuccess:()=>{d(!0),setTimeout(e,1200)}})},[t,s,i,f,e]);return u?a.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 py-12 text-center",children:[a.jsx(Uh,{className:"text-primary size-12"}),a.jsx("h3",{className:"text-lg font-semibold",children:"Agent created"}),a.jsxs("p",{className:"text-muted-foreground text-sm",children:[a.jsx("span",{className:"font-medium",children:s})," is ready at"," ",a.jsx("span",{className:"font-mono text-xs",children:Mc(t)})]})]}):a.jsx("div",{className:"flex flex-col items-center justify-center",children:a.jsxs("div",{className:"w-full max-w-sm space-y-4",children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:"agent-directory",children:"Project directory"}),a.jsxs("button",{id:"agent-directory",type:"button",onClick:()=>c(!0),className:`border-input bg-background hover:bg-accent flex h-10 w-full items-center gap-2 rounded-md border px-3 text-sm transition-colors ${t?"text-foreground":"text-muted-foreground"}`,children:[a.jsx($c,{className:"size-4 flex-shrink-0"}),a.jsx("span",{className:"truncate",children:t?Mc(t):"Select a directory..."})]}),a.jsx(ET,{open:l,onOpenChange:c,onSelect:n})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:"agent-name",children:"Agent name"}),a.jsx(sn,{id:"agent-name",type:"text",placeholder:"e.g. my-project",value:s,onChange:y=>r(y.target.value)})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs(Rt,{htmlFor:"agent-persona",children:["Persona ",a.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),a.jsx(V5,{id:"agent-persona",placeholder:"Describe what this agent does...",value:i,onChange:y=>o(y.target.value),rows:3})]}),a.jsx(ge,{className:"w-full",onClick:m,disabled:!t||!s.trim()||f.isPending,children:f.isPending?a.jsxs(a.Fragment,{children:[a.jsx(Sn,{className:"size-4 animate-spin"}),"Creating..."]}):"Create agent"}),f.isError&&a.jsxs("p",{className:"text-destructive text-center text-sm",children:["Failed to initialize agent. ",((g=f.error)==null?void 0:g.message)??"Please try again."]})]})})}function qet({onStepComplete:e}){const{startScan:t}=Nce(),{candidates:n,existingAgents:s,isScanning:r,progress:i,error:o}=xP(),l=dce(),{actedPaths:c,markActed:u,resetActed:d}=jce(),[f,m]=x.useState(!1),[g,y]=x.useState(!1),[b,S]=x.useState(3),{roots:w,setScanRoots:C}=hce(),[T,E]=x.useState(null),j=T??w,_=Ds(),N=x.useRef(!1);x.useEffect(()=>{N.current||(N.current=!0,m(!0),t())},[t]);const R=x.useMemo(()=>r?n:Ace(n),[n,r]),O=x.useCallback(W=>{u(W.path),l.mutate({path:W.path,overrides:kC(W)})},[l,u]),M=x.useCallback(W=>{u(W.path)},[u]),L=x.useCallback(()=>{for(const W of R)c.has(W.path)||(u(W.path),l.mutate({path:W.path,overrides:kC(W)}))},[R,c,l,u]),P=x.useCallback(W=>{E(W),C(W)},[C]),$=x.useCallback(()=>{d(),m(!0),t(j.length>0?{roots:j,maxDepth:b}:{roots:[]})},[t,d,j,b]),q=x.useCallback(()=>{$()},[$]),K=s.length>0,B=n.length>0,V=K||B,Q=f&&!r,re=Q&&!V,U=!B||n.every(W=>c.has(W.path)),G=R.filter(W=>!c.has(W.path));return a.jsxs("div",{className:"flex min-h-0 w-full flex-1 flex-col items-center",children:[a.jsxs("div",{className:"w-full shrink-0 text-center",children:[a.jsx("h2",{className:"text-2xl font-semibold tracking-tight sm:text-3xl",children:r&&!V?"Searching your machine...":re?"Create Your First Agent":"Projects Found"}),r&&!V&&a.jsxs("div",{className:"mt-2 space-y-1",children:[a.jsx("p",{className:"text-muted-foreground text-sm",children:"Looking for existing projects on your machine."}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Once imported, your agents can work across them — and you can connect to Slack, Telegram, and more."})]}),re&&a.jsx("p",{className:"text-muted-foreground mt-2 text-sm",children:"No projects were found on your machine."})]}),r&&!V&&a.jsxs("div",{className:"mt-8 flex shrink-0 flex-col items-center gap-4",children:[a.jsx(te.div,{animate:_?{}:{scale:[1,1.15,1]},transition:{duration:1.5,repeat:1/0,ease:"easeInOut"},children:a.jsx(pa,{className:"text-muted-foreground size-8"})}),i&&a.jsxs("p",{className:"text-muted-foreground text-sm",children:["Scanned ",i.scannedDirs," directories"]})]}),r&&V&&i&&a.jsxs("div",{className:"text-muted-foreground mt-4 shrink-0 text-center text-sm",children:["Scanning... ",i.scannedDirs," directories · Found ",i.foundAgents," ","project",i.foundAgents===1?"":"s"]}),Q&&V&&a.jsx("p",{className:"text-muted-foreground mt-3 shrink-0 text-center text-sm",children:"Add existing projects you want to manage in DorkOS. You can assign agents, schedule tasks, and connect to Slack, Telegram, and more."}),o&&a.jsx("div",{className:"border-destructive/30 bg-destructive/5 text-destructive mt-6 shrink-0 rounded-lg border px-4 py-3 text-sm",children:o}),V&&a.jsx("div",{className:"mt-4 min-h-0 w-full flex-1 overflow-y-auto pr-1",children:a.jsxs("div",{className:"space-y-3",children:[G.length>0&&a.jsx(Dce,{count:G.length,onAddAll:L}),a.jsx(Ue,{mode:"popLayout",children:G.map(W=>a.jsx(Rce,{candidate:W,onApprove:O,onSkip:M},W.path))}),K&&a.jsx(Mce,{agents:s})]})}),re&&a.jsxs("div",{className:"mt-6 w-full",children:[a.jsx(Vet,{onAgentCreated:q}),a.jsxs("div",{className:"mt-4",children:[a.jsxs("button",{type:"button",onClick:()=>y(!g),className:"text-muted-foreground hover:text-foreground mx-auto flex items-center gap-1 text-xs",children:[a.jsx(Hs,{className:`size-3 transition-transform ${g?"":"-rotate-90"}`}),"Scan options"]}),g&&a.jsxs("div",{className:"bg-muted/30 mt-2 space-y-3 rounded-lg border p-3",children:[a.jsx(Oce,{roots:j,onChange:P}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("label",{htmlFor:"onboarding-scan-depth",className:"text-muted-foreground text-xs",children:"Scan depth"}),a.jsx("input",{id:"onboarding-scan-depth",type:"range",min:1,max:5,value:b,onChange:W=>S(Number(W.target.value)),className:"flex-1"}),a.jsx("span",{className:"min-w-[1.5rem] text-center text-xs font-medium",children:b})]})]})]}),a.jsxs("div",{className:"mt-6 flex flex-col items-center gap-3",children:[a.jsx(ge,{variant:"outline",size:"sm",onClick:$,children:"Scan Again"}),a.jsx("button",{onClick:e,className:"text-muted-foreground hover:text-foreground text-sm transition-colors",children:"Continue without adding"})]})]}),Q&&V&&a.jsx("div",{className:"mt-4 flex shrink-0 flex-col items-center gap-2 border-t pt-4",children:a.jsx(ge,{size:"lg",onClick:e,variant:U?"default":"outline",children:"Continue"})})]})}function Get({onStepComplete:e,agents:t}){const{data:n,isLoading:s,isError:r}=fP(),i=cP(),[o,l]=x.useState(null),[c,u]=x.useState(!1),[d,f]=x.useState(null),m=t.length===1?t[0]:t.find(C=>C.id===d)??null,g=x.useMemo(()=>o??new Set((n==null?void 0:n.map(C=>C.id))??[]),[o,n]),y=x.useCallback(C=>{l(T=>{const E=T??new Set((n==null?void 0:n.map(_=>_.id))??[]),j=new Set(E);return j.has(C)?j.delete(C):j.add(C),j})},[n]),b=g.size,S=b>0&&m!==null,w=x.useCallback(async()=>{if(!n||b===0||!m){e();return}u(!0);const C=n.filter(j=>g.has(j.id)),E=(await Promise.allSettled(C.map(j=>i.mutateAsync({name:j.name,description:j.description,prompt:j.prompt,cron:j.cron,target:m.id})))).filter(j=>j.status==="rejected");E.length>0&&(console.error("[TaskTemplatesStep] Schedule creation failures:",E),Ye.warning(`${E.length} of ${C.length} schedule(s) failed to create. You can retry from Tasks later.`)),u(!1),e()},[n,b,g,m,i,e]);return a.jsxs("div",{className:"mx-auto w-full max-w-2xl flex-1 space-y-4 overflow-y-auto px-4",children:[a.jsxs("div",{className:"space-y-2 text-center",children:[a.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:"Want your agents to work while you sleep?"}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Tasks runs automated tasks on a schedule — like a cron job for your agents."})]}),t.length===1&&a.jsxs("p",{className:"text-muted-foreground text-center text-sm",children:["Scheduling for ",t[0].icon?`${t[0].icon} `:"",t[0].name]}),t.length>=2&&a.jsx("div",{className:"mx-auto max-w-xs",children:a.jsxs(On,{value:d??"",onValueChange:f,children:[a.jsx(_n,{children:a.jsx(In,{placeholder:"Select a project..."})}),a.jsx(Nn,{children:t.map(C=>a.jsxs(mt,{value:C.id,children:[C.icon?`${C.icon} `:"",nn(C)]},C.id))})]})}),s&&a.jsx("p",{className:"text-muted-foreground text-center text-sm",children:"Loading presets..."}),r&&a.jsx("p",{className:"text-destructive text-center text-sm",children:"Failed to load presets. You can skip this step and configure schedules later."}),n&&n.length>0&&a.jsx("div",{className:"grid gap-3",children:n.map(C=>a.jsx(xce,{preset:C,variant:"toggle",checked:g.has(C.id),onCheckedChange:()=>y(C.id)},C.id))}),a.jsxs("div",{className:"flex flex-col items-center gap-3 pt-2",children:[a.jsx(ge,{onClick:w,size:"lg",disabled:c||b>0&&!S,children:c?"Creating...":b>0?`Create ${b} Schedule${b===1?"":"s"}`:"Continue Without Schedules"}),t.length>=2&&a.jsx("p",{className:"text-muted-foreground text-xs",children:"You can put your other agents on autopilot anytime from Tasks."})]})]})}const FA=["You're","all","set!"];function Ket({onComplete:e}){const t=Ds(),{state:n}=Wb(),s=x.useRef(!1);x.useEffect(()=>{s.current||(s.current=!0,Yv())},[]);const r=n.completedSteps.includes("meet-dorkbot"),i=n.completedSteps.includes("discovery"),o=n.completedSteps.includes("tasks"),l=[{icon:Ad,label:r?"Met DorkBot":"DorkBot skipped",done:r},{icon:e0,label:i?"Agents discovered":"Agents skipped",done:i},{icon:Pi,label:o?"Schedules created":"Schedules skipped",done:o}];return a.jsxs(te.div,{initial:t?!1:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.3,ease:"easeOut"},className:"mx-auto flex w-full max-w-md flex-col items-center gap-8 px-4 text-center",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("h2",{className:"text-3xl font-semibold tracking-tight",children:t?FA.join(" "):a.jsx(te.span,{initial:"hidden",animate:"visible",variants:{visible:{transition:{staggerChildren:.08}}},children:FA.map((c,u)=>a.jsxs(te.span,{className:"inline-block",variants:{hidden:{opacity:0,filter:"blur(4px)"},visible:{opacity:1,filter:"blur(0px)"}},transition:{duration:.4},children:[c,u<FA.length-1?" ":""]},u))})}),a.jsx("p",{className:"text-muted-foreground",children:"Your workspace is configured and ready."})]}),a.jsx(te.div,{className:"w-full space-y-3",initial:"hidden",animate:"visible",variants:t?{}:{visible:{transition:{staggerChildren:.12,delayChildren:.3}}},children:l.map(({icon:c,label:u,done:d})=>a.jsxs(te.div,{variants:t?{}:{hidden:{opacity:0,y:12},visible:{opacity:1,y:0}},transition:{duration:.3},className:"flex items-center gap-3 rounded-lg border p-4",children:[a.jsx(c,{className:`size-5 ${d?"text-primary":"text-muted-foreground/50"}`}),a.jsx("span",{className:d?"text-sm":"text-muted-foreground text-sm",children:u})]},u))}),a.jsx(te.div,{initial:t?!1:{opacity:0},animate:{opacity:1},transition:{delay:.8,duration:.4},children:a.jsx(YI,{className:"px-6 py-2",duration:1.2,onClick:e,children:"Start your first session"})})]})}const gy=["meet-dorkbot","discovery","tasks"],Wet=gy.indexOf("tasks"),zA=-2,LU=-1;function Ice({onComplete:e,initialStep:t=zA}){var L;const[n,s]=x.useState(t),[r,i]=x.useState(1),[o,l]=x.useState(!1),{completeStep:c,skipStep:u,dismiss:d,startOnboarding:f,config:m}=Wb(),g=Hn(),y=Us(),b=Ds(),S=Kb();x.useEffect(()=>{f()},[]);const w=x.useCallback(()=>{n<gy.length-1?(i(1),s(P=>P+1)):(c("adapters"),l(!0))},[n,c]),C=x.useCallback(()=>{n>0?(i(-1),s(P=>P-1)):n===0&&(i(-1),s(zA))},[n]),T=x.useCallback(()=>{c(gy[n]),w()},[n,c,w]),E=x.useCallback(()=>{u(gy[n]),w()},[n,u,w]),j=x.useCallback(async()=>{await d(),e()},[d,e]),_=x.useCallback(()=>{i(1),s(LU)},[]),N=x.useCallback(()=>{i(1),s(0)},[]),R=x.useCallback(()=>{var K,B;const P=((K=m==null?void 0:m.agents)==null?void 0:K.defaultAgent)||"dorkbot",q=`${((B=m==null?void 0:m.agents)==null?void 0:B.defaultDirectory)||"~/.dork/agents"}/${P}`;g({to:"/session",search:{dir:q}}),e()},[m,g,e]);if(x.useEffect(()=>{var P;n===Wet&&!S.isLoading&&((P=S.data)==null?void 0:P.agents.length)===0&&(c("tasks"),w())},[n,S.isLoading,S.data,c,w]),o)return a.jsx("div",{className:"bg-background flex h-full w-full items-center justify-center",children:a.jsx(Ket,{onComplete:R})});if(n===zA)return a.jsx("div",{className:"bg-background flex h-full w-full items-center justify-center",children:a.jsx(ket,{onGetStarted:_,onSkip:j})});if(n===LU)return a.jsx("div",{className:"bg-background flex h-full w-full items-center justify-center",children:a.jsx(yet,{onContinue:N})});const O=y?150:300,M=b?{enter:{opacity:0},center:{opacity:1},exit:{opacity:0}}:{enter:P=>({x:P>0?O:-O,opacity:0,scale:.98,filter:"blur(2px)"}),center:{x:0,opacity:1,scale:1,filter:"blur(0px)"},exit:P=>({x:P>0?-O:O,opacity:0,scale:.98,filter:"blur(2px)"})};return a.jsxs("div",{className:"bg-background flex h-full w-full flex-col",children:[a.jsx(det,{totalSteps:gy.length,currentStep:n,onBack:C,onSkip:E,onSkipAll:j}),a.jsx("div",{className:"relative flex-1 overflow-hidden",children:a.jsx(Ue,{mode:"wait",custom:r,children:a.jsx(te.div,{custom:r,variants:M,initial:"enter",animate:"center",exit:"exit",transition:{type:b?"tween":"spring",damping:25,stiffness:200,duration:b?.15:void 0},className:"absolute inset-0 flex flex-col",children:a.jsxs("div",{className:"mx-auto flex min-h-0 w-full max-w-2xl flex-1 flex-col px-4 py-4 sm:px-6",children:[n===0&&a.jsx(Let,{onStepComplete:T}),n===1&&a.jsx(qet,{onStepComplete:T}),n===2&&a.jsx(Get,{onStepComplete:T,agents:((L=S.data)==null?void 0:L.agents)??[]})]})},n)})})]})}const yP={healthy:{dot:"bg-green-500",text:"text-green-600 dark:text-green-400",border:"border-l-green-500"},delivered:{dot:"bg-green-500",text:"text-green-600 dark:text-green-400",border:"border-l-green-500"},connected:{dot:"bg-green-500",text:"text-green-600 dark:text-green-400",border:"border-l-green-500"},pending:{dot:"bg-blue-500",text:"text-blue-600 dark:text-blue-400",border:"border-l-blue-500"},starting:{dot:"bg-blue-500",text:"text-blue-600 dark:text-blue-400",border:"border-l-blue-500"},new:{dot:"bg-blue-500",text:"text-blue-600 dark:text-blue-400",border:"border-l-blue-500"},reconnecting:{dot:"bg-amber-500",text:"text-amber-600 dark:text-amber-400",border:"border-l-amber-500"},degraded:{dot:"bg-amber-500",text:"text-amber-600 dark:text-amber-400",border:"border-l-amber-500"},warning:{dot:"bg-amber-500",text:"text-amber-600 dark:text-amber-400",border:"border-l-amber-500"},rate_limited:{dot:"bg-amber-500",text:"text-amber-600 dark:text-amber-400",border:"border-l-amber-500"},failed:{dot:"bg-red-500",text:"text-red-600 dark:text-red-400",border:"border-l-red-500"},error:{dot:"bg-red-500",text:"text-red-600 dark:text-red-400",border:"border-l-red-500"},disconnected:{dot:"bg-red-500",text:"text-red-600 dark:text-red-400",border:"border-l-red-500"},inactive:{dot:"bg-gray-400",text:"text-muted-foreground",border:"border-l-gray-400"},stopped:{dot:"bg-gray-400",text:"text-muted-foreground",border:"border-l-gray-400"}};function Yet(e){var t;return((t=yP[e])==null?void 0:t.dot)??"bg-gray-400"}function Zet(e){var t;return((t=yP[e])==null?void 0:t.text)??"text-muted-foreground"}function Xet(e){var t;return((t=yP[e])==null?void 0:t.border)??"border-l-gray-400"}function Qet(e){switch(e){case"delivered":return"bg-green-500";case"failed":return"bg-red-500";case"sent":return"bg-yellow-500";case"timeout":return"bg-gray-500";default:return"bg-gray-400"}}function Jet(e){return new Date(e).toLocaleTimeString()}function FU(e,t){if(e==null||t==null)return null;const n=new Date(t).getTime()-new Date(e).getTime();return n<1e3?`${n}ms`:`${(n/1e3).toFixed(1)}s`}function ett({messageId:e,onClose:t}){const{data:n,isLoading:s,error:r}=LQe(e);if(s)return a.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading trace..."});if(r||!n)return a.jsx("div",{className:"text-destructive p-4 text-sm",children:"Failed to load trace."});const{traceId:i,spans:o}=n;return a.jsxs("div",{className:"flex flex-col gap-2 p-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-muted-foreground font-mono text-xs",children:["Trace: ",i.slice(0,8),"..."]}),t&&a.jsx("button",{onClick:t,className:"text-muted-foreground hover:text-foreground text-xs",children:"Close"})]}),a.jsx("div",{className:"border-border relative ml-3 border-l pl-6",children:o.map(l=>{const c=FU(l.sentAt,l.deliveredAt),u=FU(l.deliveredAt,l.processedAt);return a.jsxs("div",{className:"relative pb-4 last:pb-0",children:[a.jsx("div",{className:`absolute top-1 -left-[calc(1.5rem+0.3125rem)] h-2.5 w-2.5 rounded-full ${Qet(l.status)}`}),a.jsxs("div",{className:"flex flex-col gap-0.5",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:"font-medium",children:l.subject}),a.jsx("span",{className:"bg-muted rounded px-1.5 py-0.5 text-xs",children:l.status})]}),a.jsxs("div",{className:"text-muted-foreground flex gap-3 text-xs",children:[a.jsxs("span",{children:["Sent: ",Jet(l.sentAt)]}),c&&a.jsxs("span",{children:["Delivery: ",c]}),u&&a.jsxs("span",{children:["Processing: ",u]})]}),l.errorMessage&&a.jsx("div",{className:"bg-destructive/10 text-destructive mt-1 rounded px-2 py-1 text-xs",children:l.errorMessage})]})]},l.id)})})]})}function BA(e){if(e.payload&&typeof e.payload=="object"){const n=e.payload;if(typeof n.adapterId=="string")return n.adapterId}const t=e.from.raw.match(/^relay\.human\.([^.]+)/);return t?t[1]:""}function zU(e){if(e.payload&&typeof e.payload=="object"){const t=e.payload;if(typeof t.chatId=="string")return t.chatId}}function BU(e){if(e.payload&&typeof e.payload=="object"){const n=e.payload.channelType;if(n==="dm"||n==="group"||n==="channel"||n==="thread")return n}}const ttt={delivered:"Delivered",failed:"Failed",pending:"Pending"};function $U(e){return new Date(e).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",second:"2-digit"})}function ntt(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function stt(e){return e.status==="delivered"?e.responseCount>0?`delivered · ${e.responseCount} chunks`:"delivered":e.failureReason??ttt[e.status].toLowerCase()}function rtt({conversation:e}){const[t,n]=x.useState(!1),[s,r]=x.useState(!1),[i,o]=x.useState(!1),[l,c]=x.useState(""),[u,d]=x.useState(!1),[f,m]=x.useState(!1),{data:g}=ba(),y=x.useMemo(()=>(g==null?void 0:g.agents)??[],[g]),{mutate:b}=ZT(),{data:S=[]}=Gb(),w=BA(e),C=x.useMemo(()=>S.filter(O=>O.adapterId===w),[S,w]),T=Yet(e.status),E=Zet(e.status),j=Xet(e.status),_=x.useCallback(()=>{y.find(M=>M.id===l)&&(b({adapterId:BA(e),agentId:l,sessionStrategy:"per-chat",label:"",chatId:zU(e),channelType:BU(e)}),c(""),d(!1))},[y,l,e,b]),N=x.useCallback(()=>{d(!1),m(!0)},[]),R=x.useCallback(O=>{b({adapterId:O.adapterId,agentId:O.agentId,sessionStrategy:O.sessionStrategy,label:O.label,chatId:O.chatId,channelType:O.channelType,canInitiate:O.canInitiate,canReply:O.canReply,canReceive:O.canReceive}),m(!1)},[b]);return a.jsxs("div",{className:Y("hover:bg-muted/50 w-full rounded-lg border border-l-2 text-left transition-colors hover:shadow-sm",j,t&&"bg-muted/30"),children:[a.jsxs("div",{className:"flex items-start gap-2 p-3",children:[a.jsxs("button",{type:"button",onClick:()=>n(!t),className:"flex min-w-0 flex-1 items-start gap-2",children:[a.jsx("span",{className:Y("mt-1 size-2 shrink-0 rounded-full",T)}),a.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[a.jsxs("div",{className:"text-muted-foreground text-xs",children:[a.jsx("span",{className:"inline-block w-8 font-medium",children:"From"}),a.jsx("span",{className:"text-foreground",children:e.from.label})]}),a.jsxs("div",{className:"text-muted-foreground text-xs",children:[a.jsx("span",{className:"inline-block w-8 font-medium",children:"To"}),a.jsx("span",{className:"text-foreground",children:e.to.label})]}),a.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.preview&&a.jsxs("span",{className:"text-muted-foreground min-w-0 flex-1 truncate text-xs",children:['"',e.preview,'"']}),a.jsx("span",{className:Y("shrink-0 text-xs",E),children:stt(e)})]})]})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[a.jsx("span",{className:"text-muted-foreground text-xs",children:ii(e.sentAt)}),a.jsxs(c0,{open:u,onOpenChange:d,children:[a.jsx(u0,{asChild:!0,children:a.jsxs(ge,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-xs",onClick:O=>O.stopPropagation(),"aria-label":"Route to agent",children:[a.jsx(fne,{className:"mr-1 size-3"}),"Route"]})}),a.jsxs(d0,{className:"w-64 space-y-3 p-3",align:"end",children:[a.jsx("p",{className:"text-xs font-medium",children:"Route to Agent"}),C.length>0&&a.jsx("div",{className:"rounded border border-blue-200 bg-blue-50 px-2 py-1.5 text-xs dark:border-blue-900 dark:bg-blue-950",children:a.jsxs("p",{className:"font-medium text-blue-800 dark:text-blue-200",children:[C.length," binding",C.length!==1?"s":""," ","already exist",C.length===1?"s":""," for this adapter"]})}),a.jsxs(On,{value:l,onValueChange:c,children:[a.jsx(_n,{className:"h-8 text-xs",children:a.jsx(In,{placeholder:"Select agent"})}),a.jsx(Nn,{children:y.map(O=>a.jsx(mt,{value:O.id,children:nn(O)},O.id))})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(ge,{variant:"link",size:"sm",className:"h-6 px-0 text-xs",onClick:N,children:"More options..."}),a.jsx(ge,{size:"sm",className:"h-7 text-xs",disabled:!l,onClick:_,children:"Create Binding"})]})]})]})]})]}),f&&a.jsx(mce,{open:!0,onOpenChange:O=>{O||m(!1)},mode:"create",initialValues:{adapterId:BA(e),agentId:l||void 0,chatId:zU(e),channelType:BU(e)},onConfirm:R}),a.jsx(Ue,{initial:!1,children:t&&a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"overflow-hidden",children:a.jsxs("div",{className:"space-y-3 border-t px-3 pt-3 pb-3",children:[e.payload!=null&&a.jsxs("div",{children:[a.jsx("span",{className:"text-muted-foreground text-xs font-medium",children:"Payload"}),a.jsx("pre",{className:"bg-muted mt-1 max-h-40 overflow-auto rounded p-2 font-mono text-xs",children:JSON.stringify(e.payload,null,2)})]}),a.jsxs("div",{className:"text-muted-foreground text-xs",children:[a.jsxs("span",{children:["Sent ",$U(e.sentAt)]}),e.completedAt&&a.jsxs("span",{children:[" · Completed ",$U(e.completedAt)]}),e.durationMs!=null&&a.jsxs("span",{children:[" · Duration: ",ntt(e.durationMs)]}),e.responseCount>0&&a.jsxs("span",{children:[" · ",e.responseCount," response chunks"]})]}),e.failureReason&&a.jsx("div",{className:"bg-destructive/10 text-destructive rounded px-2 py-1 text-xs",children:e.failureReason}),a.jsxs("button",{type:"button",onClick:O=>{O.stopPropagation(),r(!s)},className:"text-muted-foreground hover:text-foreground flex items-center gap-1.5 text-xs",children:[s?a.jsx(Hs,{className:"size-3.5"}):a.jsx(Rs,{className:"size-3.5"}),"Technical Details"]}),a.jsx(Ue,{initial:!1,children:s&&a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:a.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs",children:[a.jsx("dt",{className:"text-muted-foreground",children:"Subject"}),a.jsx("dd",{className:"truncate font-mono",children:e.subject}),e.sessionId&&a.jsxs(a.Fragment,{children:[a.jsx("dt",{className:"text-muted-foreground",children:"Session"}),a.jsx("dd",{className:"font-mono",children:e.sessionId.slice(0,8)})]}),e.traceId&&a.jsxs(a.Fragment,{children:[a.jsx("dt",{className:"text-muted-foreground",children:"Trace ID"}),a.jsxs("dd",{className:"font-mono",children:[e.traceId.slice(0,12),"…"]})]}),a.jsx("dt",{className:"text-muted-foreground",children:"Source"}),a.jsx("dd",{className:"truncate font-mono",children:e.from.raw}),a.jsx("dt",{className:"text-muted-foreground",children:"Destination"}),a.jsx("dd",{className:"truncate font-mono",children:e.to.raw})]})})}),e.traceId&&a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",onClick:O=>{O.stopPropagation(),o(!i)},className:"text-muted-foreground hover:text-foreground flex items-center gap-1.5 text-xs",children:[i?a.jsx(Hs,{className:"size-3.5"}):a.jsx(Rs,{className:"size-3.5"}),"Trace Timeline"]}),a.jsx(Ue,{initial:!1,children:i&&a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:a.jsx(ett,{messageId:e.traceId,onClose:()=>o(!1)})})})]})]})})})]})}const itt={hop_limit:{label:"Hop Limit",className:"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400"},ttl_expired:{label:"TTL Expired",className:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"},cycle_detected:{label:"Cycle Detected",className:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400"},budget_exhausted:{label:"Budget Exhausted",className:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"}},att={label:"Unknown",className:"bg-muted text-muted-foreground"};function ott(e,t){const n=ii(e),s=ii(t);return n===s?s:`${n} — ${s}`}function ltt({group:e}){const[t,n]=x.useState(!1),s=sce(),r=itt[e.reason]??att;return a.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50/50 p-3 dark:border-red-900/40 dark:bg-red-950/20",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(fr,{className:"mt-0.5 size-4 shrink-0 text-red-500"}),a.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"truncate text-sm font-medium",children:e.source}),a.jsx(zt,{className:Y("shrink-0 border-0 text-xs font-normal",r.className),children:r.label}),a.jsx(zt,{variant:"destructive",className:"shrink-0 tabular-nums",children:e.count.toLocaleString()})]}),a.jsx("p",{className:"text-muted-foreground text-xs",children:ott(e.firstSeen,e.lastSeen)})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.sample!=null&&a.jsxs(a.Fragment,{children:[a.jsxs(ge,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>n(!0),children:[a.jsx(K5,{className:"mr-1 size-3"}),"View Sample"]}),a.jsx(qc,{open:t,onOpenChange:n,children:a.jsxs(Cl,{className:"max-w-lg",children:[a.jsxs(El,{children:[a.jsx(Tl,{children:"Sample Envelope"}),a.jsxs(_l,{children:["Representative failure from ",e.source," (",r.label,")"]})]}),a.jsx("pre",{className:"bg-muted max-h-80 overflow-auto rounded-md p-3 font-mono text-xs",children:JSON.stringify(e.sample,null,2)})]})})]}),a.jsxs(Sl,{children:[a.jsx(mT,{asChild:!0,children:a.jsxs(ge,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground h-7 px-2 text-xs",disabled:s.isPending,children:[a.jsx(wo,{className:"mr-1 size-3"}),"Mark Resolved"]})}),a.jsxs(ko,{children:[a.jsxs(wl,{children:[a.jsx(Co,{children:"Mark dead letters as resolved?"}),a.jsxs(Eo,{children:["This will dismiss ",e.count," dead letter",e.count!==1?"s":""," from"," ",a.jsx("span",{className:"font-medium",children:e.source})," (",r.label,"). This action cannot be undone."]})]}),a.jsxs(kl,{children:[a.jsx(_o,{children:"Cancel"}),a.jsx(To,{onClick:()=>s.mutate({source:e.source,reason:e.reason}),children:"Mark Resolved"})]})]})]})]})]})})}function ctt({enabled:e=!0}){const{data:t=[],isLoading:n}=w0(e),{data:s}=lP(),r=s==null?void 0:s.budgetRejections,i=r&&Object.values(r).some(o=>o>0);return n||t.length===0?null:a.jsxs("div",{className:"space-y-2",children:[i&&a.jsx("div",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 dark:border-amber-900 dark:bg-amber-950",children:a.jsxs("p",{className:"text-xs font-medium text-amber-800 dark:text-amber-200",children:["Budget rejections: ",r.hopLimit," hop limit,"," ",r.cycleDetected," cycles, ",r.budgetExhausted," budget,"," ",r.ttlExpired," TTL"]})}),t.map(o=>a.jsx(ltt,{group:o},`${o.source}:${o.reason}`))]})}function utt(e){try{return JSON.parse(e)}catch{return{content:e}}}const dtt=se({subject:z().min(1,"Subject is required"),from:z().min(1,"From is required"),payload:z().min(1,"Payload is required")});function ftt({open:e,onOpenChange:t}={}){const[n,s]=x.useState(!1),r=e!==void 0,i=r?e:n,o=jQe(),l=XE({defaultValues:{subject:"",from:"relay.human.console",payload:""},validators:{onSubmit:dtt},onSubmit:({value:u})=>{o.mutate({subject:u.subject,from:u.from,payload:utt(u.payload)},{onSuccess:()=>{Ye.success("Message sent"),l.reset(),c(!1)}})}});function c(u){r?t==null||t(u):s(u),u||l.reset()}return a.jsxs(qc,{open:i,onOpenChange:c,children:[!r&&a.jsx(eie,{asChild:!0,children:a.jsxs(ge,{variant:"ghost",size:"sm",className:"gap-1.5","data-testid":"compose-trigger",children:[a.jsx(r3e,{className:"size-3.5"}),"Compose"]})}),a.jsxs(Cl,{children:[a.jsxs(El,{children:[a.jsx(Tl,{children:"Send Test Message"}),a.jsx(_l,{children:"Compose a message to send through the Relay bus."})]}),a.jsx(l.AppForm,{children:a.jsxs("form",{onSubmit:u=>{u.preventDefault(),l.handleSubmit()},className:"space-y-4",children:[a.jsx(l.AppField,{name:"subject",children:u=>a.jsx(u.TextField,{label:"Subject",placeholder:"e.g. relay.test.ping"})}),a.jsx(l.AppField,{name:"from",children:u=>a.jsx(u.TextField,{label:"From"})}),a.jsx(l.AppField,{name:"payload",children:u=>a.jsx(u.TextareaField,{label:"Payload",placeholder:'Plain text or JSON (e.g. {"content": "hello"})',rows:4})}),a.jsx("div",{className:"flex justify-end",children:a.jsxs(ge,{type:"submit",disabled:o.isPending,children:[a.jsx(M3e,{className:"mr-2 size-4"}),"Send"]})})]})})]})]})}function htt({enabled:e}){const{data:t}=lP();if(!e||!t)return null;const n=[{label:"Total",value:t.totalMessages,variant:"default"},{label:"Delivered",value:t.deliveredCount,variant:"success"},{label:"Failed",value:t.failedCount,variant:t.failedCount>0?"danger":"default"},{label:"Dead Letter",value:t.deadLetteredCount,variant:t.deadLetteredCount>0?"warning":"default"}];return a.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-2",children:[n.map(({label:s,value:r,variant:i})=>a.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[a.jsx("span",{className:"text-muted-foreground",children:s}),a.jsx("span",{className:Y("font-medium tabular-nums",i==="success"&&r>0&&"text-green-600 dark:text-green-500",i==="danger"&&"text-red-600 dark:text-red-500",i==="warning"&&"text-amber-600 dark:text-amber-500"),children:r.toLocaleString()})]},s)),t.avgDeliveryLatencyMs!=null&&a.jsxs("div",{className:"ml-auto flex items-center gap-1.5 text-xs",children:[a.jsx("span",{className:"text-muted-foreground",children:"Avg"}),a.jsx("span",{className:"font-medium tabular-nums",children:t.avgDeliveryLatencyMs<1e3?`${Math.round(t.avgDeliveryLatencyMs)}ms`:`${(t.avgDeliveryLatencyMs/1e3).toFixed(1)}s`})]})]})}function mtt(e){return e.startsWith("relay.agent.")?"chat":e.startsWith("relay.system.tasks.")?"tasks":"system"}const ptt={initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,height:0},transition:{duration:.2,ease:"easeOut"}},gtt={initial:!1,animate:{opacity:1,y:0},exit:{opacity:0,height:0},transition:{duration:.2,ease:"easeOut"}};function xtt(e,t,n,s){return e.filter(r=>{if(t!=="all"&&mtt(r.subject)!==t||n!=="all"&&r.status!==n)return!1;if(s){const i=s.toLowerCase();if(!(r.from.label.toLowerCase().includes(i)||r.to.label.toLowerCase().includes(i)||r.preview.toLowerCase().includes(i)||r.subject.toLowerCase().includes(i)))return!1}return!0})}function ytt({enabled:e,deadLetterRef:t,onSwitchToChannels:n,autoShowFailures:s}){const[r,i]=x.useState("all"),[o,l]=x.useState("all"),[c,u]=x.useState(""),[d,f]=x.useState(!1),[m,g]=x.useState(!1),{data:y,isLoading:b}=zQe(e),{data:S=[]}=w0(e),w=x.useMemo(()=>(y==null?void 0:y.conversations)??[],[y==null?void 0:y.conversations]);S.length>0;const C=x.useRef(null);x.useEffect(()=>{w.length>0&&C.current===null&&(C.current=new Set(w.map(_=>_.id)))},[w]),x.useEffect(()=>{!m&&S.length>0&&f(!0)},[S.length,m]),x.useEffect(()=>{s&&(f(!0),g(!1))},[s]);const T=r!=="all"||o!=="all"||c!=="",E=xtt(w,r,o,c);function j(){i("all"),l("all"),u("")}return b?a.jsx("div",{className:"space-y-2 p-4",children:[1,2,3].map(_=>a.jsx("div",{className:"rounded-lg border p-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"bg-muted animate-tasks size-4 rounded"}),a.jsx("div",{className:"bg-muted animate-tasks h-4 w-40 rounded"}),a.jsx("div",{className:"bg-muted animate-tasks ml-auto h-3 w-16 rounded"})]})},_))}):a.jsxs(a.Fragment,{children:[a.jsx(htt,{enabled:e}),a.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsxs(On,{value:r,onValueChange:_=>i(_),children:[a.jsx(_n,{className:"w-32",children:a.jsx(In,{})}),a.jsxs(Nn,{children:[a.jsx(mt,{value:"all",children:"All sources"}),a.jsx(mt,{value:"chat",children:"Chat messages"}),a.jsx(mt,{value:"tasks",children:"Tasks jobs"}),a.jsx(mt,{value:"system",children:"System"})]})]}),a.jsxs(On,{value:o,onValueChange:_=>l(_),children:[a.jsx(_n,{className:"w-32",children:a.jsx(In,{})}),a.jsxs(Nn,{children:[a.jsx(mt,{value:"all",children:"All statuses"}),a.jsx(mt,{value:"delivered",children:"Delivered"}),a.jsx(mt,{value:"failed",children:"Failed"}),a.jsx(mt,{value:"pending",children:"Pending"})]})]}),a.jsxs(ge,{variant:d?"secondary":"ghost",size:"sm",className:"relative",onClick:()=>{f(!d),g(!0)},"aria-pressed":d,"aria-label":"Show dead letters",children:[a.jsx(fr,{className:"mr-1 size-3.5"}),"Dead Letters",S.length>0&&!d&&m&&a.jsx("span",{className:"absolute -top-0.5 -right-0.5 size-2 rounded-full bg-red-500"})]}),a.jsx(sn,{className:"h-9 w-44",placeholder:"Filter by agent or message...",value:c,onChange:_=>u(_.target.value),"aria-label":"Search conversations"}),T&&a.jsx(ge,{variant:"ghost",size:"sm",onClick:j,children:"Clear filters"}),a.jsx("div",{className:"ml-auto",children:a.jsx(ftt,{})})]}),d&&a.jsx("div",{ref:t,children:a.jsx(ctt,{enabled:e})}),E.length===0&&!T?a.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[a.jsx("div",{className:"pointer-events-none mb-2 w-full max-w-sm opacity-20 select-none",children:a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"rounded-lg border p-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"bg-muted size-4 rounded"}),a.jsx("div",{className:"bg-muted h-3 w-32 rounded"}),a.jsx("div",{className:"bg-muted ml-auto h-3 w-12 rounded"})]})}),a.jsx("div",{className:"rounded-lg border p-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"bg-muted size-4 rounded"}),a.jsx("div",{className:"bg-muted h-3 w-44 rounded"}),a.jsx("div",{className:"bg-muted ml-auto h-3 w-12 rounded"})]})}),a.jsx("div",{className:"rounded-lg border p-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"bg-muted size-4 rounded"}),a.jsx("div",{className:"bg-muted h-3 w-24 rounded"}),a.jsx("div",{className:"bg-muted ml-auto h-3 w-12 rounded"})]})})]})}),a.jsx(rMe,{className:"text-muted-foreground/50 size-10"}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm font-medium",children:"No activity yet"}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Messages will appear here as your agents communicate"})]})]}):E.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[a.jsx(pa,{className:"text-muted-foreground/50 size-10"}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm font-medium",children:"No messages match your filters"}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Try adjusting your filter criteria."})]}),a.jsx(ge,{variant:"ghost",size:"sm",onClick:j,children:"Clear filters"})]}):a.jsx("div",{className:"space-y-2",children:a.jsx(Ue,{mode:"popLayout",children:E.map(_=>{const R=C.current!==null&&!C.current.has(_.id)?ptt:gtt;return a.jsx(te.div,{...R,children:a.jsx(rtt,{conversation:_})},_.id)})})})]})]})}const vtt={messaging:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",automation:"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200",internal:"bg-gray-100 text-gray-800 dark:bg-gray-900 dark:text-gray-200",custom:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200"};function Pce(e){return vtt[e]??""}function vP({iconId:e,adapterType:t,size:n=16,className:s}){const r=oU[e??""]??oU[t??""];return r?a.jsx(r,{size:n,className:s}):a.jsx(Ad,{className:s,style:{width:n,height:n}})}function btt({manifest:e,instance:t,primaryName:n,secondaryName:s,statusDotClass:r,onToggle:i,onShowEvents:o,onConfigure:l,onRemove:c,onAddBinding:u,isBuiltinClaude:d}){return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[a.jsx("div",{className:r,"aria-hidden":!0}),a.jsx(vP,{iconId:e.iconId,adapterType:e.type,size:16,className:"text-muted-foreground shrink-0"}),a.jsx("span",{className:"text-sm font-medium",children:n})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[a.jsx(sr,{checked:t.enabled,onCheckedChange:i}),a.jsxs(a0,{children:[a.jsx(o0,{asChild:!0,children:a.jsx(ge,{variant:"ghost",size:"sm",className:"size-7 p-0","aria-label":"Adapter actions",children:a.jsx(yRe,{className:"size-4"})})}),a.jsxs(Qh,{align:"end",children:[a.jsxs(Nr,{onClick:o,children:[a.jsx(fb,{className:"mr-2 size-3.5"}),"Events"]}),a.jsxs(Nr,{onClick:u,children:[a.jsx(qE,{className:"mr-2 size-3.5"}),"Add channel"]}),a.jsxs(Nr,{onClick:l,children:[a.jsx(qa,{className:"mr-2 size-3.5"}),"Configure"]}),a.jsxs(Nr,{onClick:c,disabled:d,className:"text-red-600 focus:text-red-600",children:[a.jsx(wo,{className:"mr-2 size-3.5"}),"Remove"]})]})]})]})]}),a.jsxs("div",{className:"mt-1 flex items-center gap-2 pl-[18px]",children:[s&&a.jsx("span",{className:"text-muted-foreground text-xs",children:s}),s&&a.jsx("span",{className:"text-muted-foreground/50 text-xs",children:"·"}),a.jsx(zt,{variant:"secondary",className:Y("text-xs",Pce(e.category)),children:e.category}),e.deprecated&&a.jsx(zt,{variant:"outline",className:"text-xs text-amber-600 dark:text-amber-500",children:"Deprecated"})]})]})}function Stt({agentName:e,sessionStrategy:t,chatId:n,channelType:s,canInitiate:r=!1,canReply:i=!0,canReceive:o=!0}){return a.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:[a.jsx("span",{className:"truncate",children:e}),t!=="per-chat"&&a.jsx(zt,{variant:"secondary",className:"shrink-0 text-xs",children:RJe(t)}),n&&a.jsx(zt,{variant:"outline",className:"shrink-0 truncate text-xs",children:s?`#${n}`:n}),a.jsxs(em,{children:[r&&a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx(Uc,{className:"size-3 shrink-0 text-amber-500","aria-label":"Can initiate messages"})}),a.jsx(yn,{children:"Can initiate messages"})]}),!i&&a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx(jMe,{className:"text-muted-foreground/70 size-3 shrink-0","aria-label":"Reply disabled"})}),a.jsx(yn,{children:"Reply disabled"})]}),!o&&a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx(oAe,{className:"text-muted-foreground/70 size-3 shrink-0","aria-label":"Receive disabled"})}),a.jsx(yn,{children:"Receive disabled"})]})]})]})}function HU({adapterId:e,onQuickBind:t,onAdvanced:n,isPending:s,children:r}){const[i,o]=x.useState(!1),{data:l}=ba(),{data:c=[]}=Gb(),u=x.useMemo(()=>new Set(c.filter(g=>g.adapterId===e).map(g=>g.agentId)),[c,e]),d=x.useMemo(()=>((l==null?void 0:l.agents)??[]).filter(g=>!u.has(g.id)),[l,u]);async function f(g){await t(g),o(!1)}function m(){o(!1),n()}return a.jsxs(c0,{open:i,onOpenChange:o,children:[a.jsx(u0,{asChild:!0,children:r}),a.jsxs(d0,{className:"w-56 p-0",align:"start",children:[a.jsxs(gT,{children:[a.jsx(xT,{placeholder:"Search agents..."}),a.jsxs(yT,{children:[a.jsx(vT,{children:"No agents registered"}),d.map(g=>a.jsxs(Qr,{value:g.id,keywords:[nn(g)],onSelect:()=>f(g.id),disabled:s,children:[s?a.jsx(Sn,{className:"mr-2 size-3.5 animate-spin"}):null,nn(g)]},g.id))]})]}),a.jsx("div",{className:"border-t px-2 py-1.5",children:a.jsx(ge,{variant:"ghost",size:"sm",className:"text-muted-foreground w-full text-xs",onClick:m,children:"Advanced..."})})]})]})}const $A=3;function wtt({instance:e,isBuiltinClaude:t,boundAgentRows:n,totalAgentCount:s,isConnected:r,hasBindings:i,onEditBinding:o,onQuickBind:l,onAdvancedBind:c,createBindingPending:u}){const[d,f]=x.useState(!1),m=d?n:n.slice(0,$A),g=n.length-$A;return a.jsx("div",{className:"mt-3 space-y-1.5 pl-[18px]",children:t?a.jsxs("p",{className:"text-muted-foreground text-sm",children:["Serving ",s," ",s===1?"agent":"agents"," · Chat + Tasks"]}):i?a.jsxs(a.Fragment,{children:[m.map(y=>a.jsxs("button",{type:"button",className:"group/row hover:bg-muted/50 flex w-full cursor-pointer items-center gap-1.5 rounded px-1 py-0.5 text-left transition-colors",onClick:()=>o(y.binding),children:[a.jsx(Stt,{agentName:y.agentName,sessionStrategy:y.sessionStrategy,chatId:y.chatId,channelType:y.channelType,canInitiate:y.canInitiate,canReply:y.canReply,canReceive:y.canReceive}),a.jsx(Rs,{className:"text-muted-foreground ml-auto size-3 opacity-0 transition-opacity group-hover/row:opacity-100"})]},y.bindingId)),g>0&&!d&&a.jsxs("button",{type:"button",className:"text-muted-foreground hover:text-foreground mt-1 text-xs hover:underline",onClick:()=>f(!0),children:["Show ",g," more"]}),d&&n.length>$A&&a.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground mt-1 text-xs hover:underline",onClick:()=>f(!1),children:"Show less"}),a.jsx(HU,{adapterId:e.id,onQuickBind:l,onAdvanced:c,isPending:u,children:a.jsxs(ge,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground mt-1 h-6 gap-1 px-2 text-xs",children:[a.jsx(Cs,{className:"size-3"}),"Add channel"]})})]}):r?a.jsx(HU,{adapterId:e.id,onQuickBind:l,onAdvanced:c,isPending:u,children:a.jsxs(ge,{variant:"ghost",size:"sm",className:"mt-1 h-6 gap-1 px-2 text-xs text-amber-600 hover:bg-amber-50 hover:text-amber-700 dark:text-amber-500 dark:hover:bg-amber-950",children:[a.jsx(Cs,{className:"size-3"}),"Add channel"]})}):null})}function ktt({instance:e}){const{errorCount:t,lastError:n}=e.status;return!t&&!n?null:a.jsxs("div",{className:"mt-3 pl-[18px]",children:[t>0&&!n&&a.jsxs("div",{className:"flex items-center gap-1 text-xs text-red-500",children:[a.jsx(fr,{className:"size-3"}),a.jsxs("span",{children:[t," ",t===1?"error":"errors"]})]}),n&&a.jsxs(ol,{children:[a.jsx("div",{className:"flex items-center gap-1",children:a.jsx(ll,{asChild:!0,children:a.jsxs("button",{className:"flex items-center gap-1 text-xs text-red-500 hover:text-red-600","aria-label":"Toggle full error message",children:[a.jsx(Rs,{className:"size-3 transition-transform data-[state=open]:rotate-90"}),t>0&&a.jsx(fr,{className:"size-3"}),a.jsx("span",{className:"max-w-[200px] truncate",children:t>0?`${t} ${t===1?"error":"errors"}`:n})]})})}),a.jsx(cl,{children:a.jsx("div",{className:"mt-1 rounded-md bg-red-50 p-2 font-mono text-xs text-red-700 dark:bg-red-950 dark:text-red-300",children:n})})]})]})}function Ctt({instance:e,manifest:t,onToggle:n,onConfigure:s,onShowEvents:r,onEditBinding:i,onRemoveConfirm:o,onAddBinding:l}){const c=ZT(),u=t.type==="claude-code"&&t.builtin,d=e.label||e.status.displayName||e.id,f=e.label?e.status.displayName||t.displayName:null,{data:m=[]}=Gb(),{data:g}=ba(),y=x.useMemo(()=>(g==null?void 0:g.agents)??[],[g==null?void 0:g.agents]),b=y.length,S=x.useMemo(()=>m.filter(N=>N.adapterId===e.id),[m,e.id]),w=x.useMemo(()=>S.map(N=>{const R=y.find(O=>O.id===N.agentId);return{bindingId:N.id,agentName:(R==null?void 0:R.name)??N.agentId,sessionStrategy:N.sessionStrategy,chatId:N.chatId,channelType:N.channelType,canInitiate:N.canInitiate,canReply:N.canReply,canReceive:N.canReceive,binding:N}}),[S,y]),C=S.length>0,T=e.status.state==="connected",E=u||C,j=Y("size-2 shrink-0 rounded-full",e.status.state==="connected"&&!E?"bg-amber-500 motion-safe:animate-pulse":rce[e.status.state]??"bg-muted-foreground");async function _(N){try{await c.mutateAsync({adapterId:e.id,agentId:N,sessionStrategy:"per-chat",label:""}),Ye.success("Channel connected")}catch(R){Ye.error(R instanceof Error?R.message:"Failed to connect channel")}}return a.jsxs("div",{className:Y("shadow-soft hover:shadow-elevated rounded-xl border p-5 transition-shadow",u&&"border-dashed"),children:[a.jsx(btt,{manifest:t,instance:e,primaryName:d,secondaryName:f,statusDotClass:j,onToggle:n,onShowEvents:()=>r(e.id),onConfigure:s,onRemove:()=>o(e.id,d),onAddBinding:()=>l(e.id,e.id),isBuiltinClaude:u}),a.jsx(wtt,{instance:e,isBuiltinClaude:u,boundAgentRows:w,totalAgentCount:b,isConnected:T,hasBindings:C,onEditBinding:N=>i(N),onQuickBind:_,onAdvancedBind:()=>l(e.id,e.id),createBindingPending:c.isPending}),a.jsx(ktt,{instance:e})]})}const Ett={"adapter.connected":"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200","adapter.message_sent":"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200","adapter.disconnected":"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200","adapter.error":"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200","adapter.message_received":"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200","adapter.status_change":"bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200"},CD={"adapter.connected":"Connected","adapter.disconnected":"Disconnected","adapter.message_received":"Received","adapter.message_sent":"Sent","adapter.error":"Error","adapter.status_change":"Status"},Ttt=Object.keys(CD);function _tt({adapterId:e}){const{data:t,isLoading:n}=BQe(e),[s,r]=x.useState("all"),i=x.useRef(null),[o,l]=x.useState(!0),c=x.useCallback(()=>{const m=i.current;if(!m)return;l(m.scrollHeight-m.scrollTop-m.clientHeight<20)},[]);x.useEffect(()=>{o&&i.current&&(i.current.scrollTop=i.current.scrollHeight)},[t,o]);const u=()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight,l(!0))};if(n)return a.jsx("div",{className:"space-y-2 p-3",children:[1,2,3,4].map(m=>a.jsx(Jt,{className:"h-6 w-full"},m))});const d=(t==null?void 0:t.events)??[],f=s==="all"?d:d.filter(m=>m.subject===s);return d.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 p-6 text-center",children:[a.jsx(fb,{className:"text-muted-foreground size-6"}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"No events recorded"})]}):a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[a.jsx("h4",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Events"}),a.jsxs(On,{value:s,onValueChange:r,children:[a.jsx(_n,{className:"h-7 w-[130px] text-xs",children:a.jsx(In,{})}),a.jsxs(Nn,{children:[a.jsx(mt,{value:"all",children:"All types"}),Ttt.map(m=>a.jsx(mt,{value:m,children:CD[m]},m))]})]})]}),a.jsx("div",{ref:i,onScroll:c,className:"flex-1 overflow-y-auto p-2",children:f.map(m=>{const g=m.metadata?JSON.parse(m.metadata):null,y=new Date(m.sentAt).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"});return a.jsxs("div",{className:"flex items-start gap-2 py-1",children:[a.jsx("span",{className:"text-muted-foreground shrink-0 font-mono text-xs tabular-nums",children:y}),a.jsx(zt,{variant:"secondary",className:Y("shrink-0 text-[10px]",Ett[m.subject]??""),children:CD[m.subject]??m.subject}),a.jsx("span",{className:"text-xs break-words",children:(g==null?void 0:g.message)??m.subject})]},m.id)})}),!o&&a.jsx("div",{className:"flex justify-center border-t py-1",children:a.jsxs(ge,{variant:"ghost",size:"sm",onClick:u,className:"h-6 text-xs",children:[a.jsx(hb,{className:"mr-1 size-3"}),"Jump to bottom"]})})]})}function Lce({manifest:e,onAdd:t}){return a.jsxs("div",{className:"hover:bg-muted/50 flex flex-col justify-between rounded-lg border p-4 transition-colors",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(vP,{iconId:e.iconId,adapterType:e.type,size:20,className:"text-muted-foreground shrink-0"}),a.jsx("span",{className:"text-sm font-medium",children:e.displayName}),a.jsx(zt,{variant:"secondary",className:Pce(e.category),children:e.category})]}),a.jsx("p",{className:"text-muted-foreground text-xs",children:e.description})]}),a.jsx("div",{className:"mt-3",children:a.jsxs(ge,{variant:"outline",size:"sm",className:"w-full",onClick:t,children:[a.jsx(Cs,{className:"mr-1 size-3"}),"Add"]})})]})}const UU=["configure","test","confirm","bind"],Ntt={configure:"Configure",test:"Test",confirm:"Confirm",bind:"Bind"};function jtt({current:e,showBindStep:t}){const n=t?UU:UU.filter(r=>r!=="bind"),s=n.indexOf(e);return a.jsx("div",{className:"flex items-start justify-between px-1",role:"navigation","aria-label":"Wizard steps",children:n.map((r,i)=>{const o=i<s,l=i===s,c=i>s;return a.jsxs(x.Fragment,{children:[i>0&&a.jsx("div",{className:Y("mt-3 h-px flex-1",o||l?"bg-primary":"border-muted-foreground/40 border-t border-dashed")}),a.jsxs("div",{className:"flex flex-col items-center gap-1",children:[a.jsx("div",{className:Y("flex size-6 items-center justify-center rounded-full text-xs font-medium",o&&"bg-primary text-primary-foreground",l&&"bg-primary text-primary-foreground ring-primary/30 ring-2",c&&"border-muted-foreground text-muted-foreground border"),"aria-current":l?"step":void 0,children:o?a.jsx(Lt,{className:"size-3"}):i+1}),a.jsx("span",{className:Y("text-[10px]",l?"text-foreground font-medium":"text-muted-foreground"),children:Ntt[r]})]})]},r)})})}function Att({field:e,value:t,onChange:n,error:s,allValues:r}){const[i,o]=x.useState("");if(e.showWhen&&r[e.showWhen.field]!==e.showWhen.equals)return null;const l=`config-field-${e.key}`,c=e.type==="select"&&e.displayAs==="radio-cards",u=t!=null?String(t):"",d=u==="***",f=()=>{if(d){o("");return}if(e.pattern&&u&&!new RegExp(e.pattern).test(u)){o(e.patternMessage??"Invalid format");return}o("")},m=s??i;if(e.type==="boolean")return a.jsxs("div",{children:[a.jsxs(ua,{orientation:"horizontal",className:"items-center justify-between gap-4",children:[a.jsxs(Ute,{className:"min-w-0",children:[a.jsx(da,{htmlFor:l,className:Y("text-sm font-medium",e.required&&'after:text-destructive after:ml-0.5 after:content-["*"]'),children:e.label}),e.description&&a.jsx(Va,{className:"text-xs",children:e.description})]}),a.jsx(sr,{id:l,checked:!!t,onCheckedChange:y=>n(e.key,y)})]}),e.helpMarkdown&&a.jsxs(ol,{children:[a.jsxs(ll,{className:"text-muted-foreground hover:text-foreground mt-1 flex items-center gap-1 text-xs transition-colors",children:[a.jsx(pB,{className:"size-3"}),"Where do I find this?",a.jsx(Hs,{className:"size-3 transition-transform [[data-state=open]_&]:rotate-180"})]}),a.jsx(cl,{children:a.jsx("div",{className:"bg-muted/50 mt-2 rounded-md border p-3",children:a.jsx(Ev,{content:e.helpMarkdown,className:"text-xs"})})})]}),a.jsx(Ue,{children:m&&a.jsx(te.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.15},className:"overflow-hidden",children:a.jsx(rl,{className:"mt-1.5",children:m})})})]});const g=()=>{var y,b;switch(e.type){case"text":case"url":return a.jsx(sn,{id:l,type:e.type==="url"?"url":"text",value:u,onChange:S=>n(e.key,S.target.value),placeholder:e.placeholder,"aria-invalid":!!m||void 0});case"password":return d?a.jsx(il,{id:l,value:u,showPassword:!1,onChange:S=>{n(e.key,S.target.value.trim()),i&&o("")},onFocus:()=>n(e.key,""),onBlur:f,placeholder:"Saved — enter a new one to replace"}):a.jsx(il,{id:l,value:u,visibleByDefault:e.visibleByDefault??!1,onChange:S=>{n(e.key,S.target.value.trim()),i&&o("")},onBlur:f,onPaste:()=>setTimeout(f,0),placeholder:e.placeholder,"aria-invalid":!!m||void 0});case"number":return a.jsx(sn,{id:l,type:"number",value:u,onChange:S=>n(e.key,S.target.value?Number(S.target.value):void 0),placeholder:e.placeholder,"aria-invalid":!!m||void 0});case"select":return e.displayAs==="radio-cards"?a.jsx("div",{className:"grid grid-cols-2 gap-3",role:"radiogroup","aria-labelledby":`${l}-label`,children:(y=e.options)==null?void 0:y.map(S=>a.jsxs("button",{type:"button",role:"radio","aria-checked":u===S.value,onClick:()=>n(e.key,S.value),className:Y("hover:bg-accent/50 focus-visible:border-ring focus-visible:ring-ring/50 flex flex-col items-start rounded-md border p-3 text-left transition outline-none focus-visible:ring-[3px]",u===S.value&&"border-primary ring-primary bg-accent/30 ring-1"),children:[a.jsx("span",{className:"text-sm font-medium",children:S.label}),S.description&&a.jsx("span",{className:"text-muted-foreground mt-1 text-xs",children:S.description})]},S.value))}):a.jsxs(On,{value:u,onValueChange:S=>n(e.key,S),children:[a.jsx(_n,{id:l,"aria-invalid":!!m||void 0,children:a.jsx(In,{placeholder:e.placeholder??"Select..."})}),a.jsx(Nn,{children:(b=e.options)==null?void 0:b.map(S=>a.jsx(mt,{value:S.value,children:S.label},S.value))})]});case"textarea":return a.jsx(V5,{id:l,value:u,onChange:S=>n(e.key,S.target.value),placeholder:e.placeholder,rows:3,"aria-invalid":!!m||void 0});default:return null}};return a.jsxs(ua,{children:[a.jsx(da,{id:`${l}-label`,htmlFor:c?void 0:l,className:Y(e.required&&!d&&'after:text-destructive after:ml-0.5 after:content-["*"]'),children:e.label}),g(),e.description&&a.jsx(Va,{className:"text-xs",children:e.description}),e.helpMarkdown&&a.jsxs(ol,{children:[a.jsxs(ll,{className:"text-muted-foreground hover:text-foreground mt-1 flex items-center gap-1 text-xs transition-colors",children:[a.jsx(pB,{className:"size-3"}),"Where do I find this?",a.jsx(Hs,{className:"size-3 transition-transform [[data-state=open]_&]:rotate-180"})]}),a.jsx(cl,{children:a.jsx("div",{className:"bg-muted/50 mt-2 rounded-md border p-3",children:a.jsx(Ev,{content:e.helpMarkdown,className:"text-xs"})})})]}),a.jsx(Ue,{children:m&&a.jsx(te.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.15},className:"overflow-hidden",children:a.jsx(rl,{children:m})})})]})}function Rtt(e,t){return e.showWhen?t[e.showWhen.field]===e.showWhen.equals:!0}function Mtt({fields:e,allValues:t,renderField:n}){const s=new Map;for(const r of e){const i=r.section;s.has(i)||s.set(i,[]),s.get(i).push(r)}return a.jsx("div",{className:"space-y-6",children:Array.from(s.entries()).map(([r,i])=>{const o=i.filter(l=>Rtt(l,t));return o.length===0?null:a.jsxs("div",{className:"space-y-3",children:[r&&a.jsx("h4",{className:"text-sm font-semibold",children:r}),a.jsx(vr,{children:a.jsx(dr,{children:o.map(l=>n(l))})})]},r??"__default")})})}function Dtt({manifest:e,label:t,onLabelChange:n,fields:s,form:r,currentSetupStep:i,hasSetupGuide:o,onOpenGuide:l}){const{Subscribe:c,AppField:u}=r;return a.jsxs("div",{className:"space-y-4",children:[e.setupInstructions&&a.jsxs("div",{className:"flex gap-2 rounded-md border border-blue-200 bg-blue-50 p-3 text-sm text-blue-800 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-200",children:[a.jsx(VE,{className:"mt-0.5 size-4 shrink-0"}),a.jsx(Ev,{content:e.setupInstructions,className:"text-sm text-blue-800 dark:text-blue-200"})]}),(e.actionButton||o)&&a.jsxs("div",{className:"flex items-center justify-end gap-2",children:[o&&a.jsxs(ge,{type:"button",variant:"outline",size:"sm",onClick:l,children:[a.jsx(q5,{className:"mr-1.5 size-3.5"}),"Setup Guide"]}),e.actionButton&&a.jsx("a",{href:e.actionButton.url,target:"_blank",rel:"noopener noreferrer",children:a.jsx(ge,{type:"button",variant:"outline",size:"sm",children:e.actionButton.label})})]}),i&&a.jsx("h4",{className:"text-sm font-medium",children:i.title}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(Rt,{htmlFor:"adapter-label",children:"Name (optional)"}),a.jsx(sn,{id:"adapter-label",placeholder:e.displayName,value:t,onChange:d=>n(d.target.value)}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"A friendly name to identify this adapter instance."})]}),a.jsx(c,{selector:d=>d.values,children:d=>a.jsx(Mtt,{fields:s,allValues:d,renderField:f=>a.jsx(u,{name:f.key,children:m=>{var g;return a.jsx(Att,{field:f,value:m.state.value,onChange:(y,b)=>m.handleChange(b),onBlur:m.handleBlur,error:m.state.meta.isTouched?(g=m.state.meta.errors[0])==null?void 0:g.toString():void 0,allValues:d})}},f.key)})})]})}function Ott({isPending:e,isSuccess:t,isError:n,errorMessage:s,botUsername:r,onRetry:i}){return a.jsxs("div",{className:"flex flex-col items-center gap-3 py-6",children:[e&&a.jsxs(a.Fragment,{children:[a.jsx(Sn,{className:"text-muted-foreground size-8 animate-spin"}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Testing connection..."})]}),t&&a.jsxs("div",{className:"flex flex-col items-center gap-2",children:[a.jsx(Uh,{className:"size-8 text-green-500"}),a.jsx("p",{className:"text-sm text-green-700 dark:text-green-400",children:"Connection successful"}),r&&a.jsx("div",{className:"flex items-center gap-2 rounded-md border px-3 py-2 text-sm",children:a.jsxs("span",{className:"font-mono",children:["@",r]})})]}),n&&a.jsxs(a.Fragment,{children:[a.jsx(Xg,{className:"size-8 text-red-500"}),a.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:"Connection failed"}),s&&a.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-xs text-red-700 dark:border-red-800 dark:bg-red-950 dark:text-red-300",children:[a.jsx(fr,{className:"mt-0.5 size-3 shrink-0"}),a.jsx("span",{children:s})]}),a.jsx(ge,{variant:"outline",size:"sm",onClick:i,children:"Retry"})]})]})}function Itt(e){return e.length>8?"•••• "+e.slice(-4):"•••"}function Ptt({manifest:e,adapterId:t,isEditMode:n,values:s}){return a.jsxs("div",{className:"space-y-3",children:[!n&&a.jsxs("div",{className:"flex justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Adapter ID"}),a.jsx("span",{className:"font-mono",children:t})]}),e.configFields.map(r=>{if(r.showWhen&&s[r.showWhen.field]!==r.showWhen.equals)return null;const i=String(s[r.key]??""),o=r.type==="password"?Itt(i):i;return a.jsxs("div",{className:"flex justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:r.label}),a.jsx("span",{className:"max-w-[200px] truncate font-mono",children:o})]},r.key)})]})}const Ltt=[{value:"per-chat",label:"Per Chat"},{value:"per-user",label:"Per User"},{value:"stateless",label:"Stateless"}];function Ftt({agentOptions:e,agentId:t,onAgentIdChange:n,strategy:s,onStrategyChange:r,botUsername:i,adapterType:o}){return x.useEffect(()=>{e.length===1&&!t&&n(e[0].id)},[e.length]),a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-muted-foreground text-sm",children:"Connect this channel to an agent so incoming messages are routed automatically. You can skip this and connect it later from the Connections tab."}),e.length===0?a.jsx("div",{className:"text-muted-foreground rounded-md border border-dashed px-4 py-6 text-center text-sm",children:"No agents registered yet. Once you have an agent, connect this channel to it from the Connections tab."}):e.length===1?a.jsxs("div",{className:"bg-accent/30 rounded-md border px-4 py-3 text-sm",children:["Will bind to ",a.jsx("span",{className:"font-medium",children:nn(e[0])})]}):a.jsxs("div",{className:"space-y-2",children:[a.jsx(Rt,{htmlFor:"bind-agent",children:"Agent"}),a.jsxs(On,{value:t,onValueChange:n,children:[a.jsx(_n,{id:"bind-agent",className:"w-full",children:a.jsx(In,{placeholder:"Select an agent"})}),a.jsx(Nn,{children:e.map(l=>a.jsx(mt,{value:l.id,children:nn(l)},l.id))})]})]}),e.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(Rt,{htmlFor:"bind-strategy",children:"Session Strategy"}),a.jsxs(On,{value:s,onValueChange:l=>r(l),children:[a.jsx(_n,{id:"bind-strategy",className:"w-full",children:a.jsx(In,{})}),a.jsx(Nn,{children:Ltt.map(l=>a.jsx(mt,{value:l.value,children:l.label},l.value))})]})]}),i&&o==="telegram"&&a.jsxs("a",{href:`https://t.me/${i}`,target:"_blank",rel:"noopener noreferrer",className:"text-primary inline-flex items-center gap-1.5 text-sm underline-offset-4 hover:underline",children:["Message @",i," in Telegram"]})]})}function ztt({open:e,onOpenChange:t,title:n,content:s}){return a.jsx(Al,{open:e,onOpenChange:t,children:a.jsxs(Rl,{side:"right",className:"w-[480px] overflow-y-auto sm:max-w-lg",children:[a.jsxs(Ml,{children:[a.jsxs(Dl,{className:"flex items-center gap-2",children:[a.jsx(q5,{className:"size-4"}),n," Setup Guide"]}),a.jsx(Hd,{children:"Step-by-step instructions for configuring this adapter."})]}),a.jsx("div",{className:"mt-4 px-4",children:a.jsx(Ev,{content:s})})]})})}function HA(e){const t={};for(const[n,s]of Object.entries(e)){const r=n.split(".");let i=t;for(let o=0;o<r.length-1;o++){const l=r[o];(!(l in i)||typeof i[l]!="object"||i[l]===null)&&(i[l]={}),i=i[l]}i[r[r.length-1]]=s}return t}function VU(e,t){const n=t.split(".");let s=e;for(const r of n){if(s==null||typeof s!="object")return;s=s[r]}return s}function Btt(e,t){const n={};for(const s of e.configFields){const r=t?VU(t,s.key):void 0;r!==void 0&&s.type!=="password"?n[s.key]=r:s.type==="password"&&t&&VU(t,s.key)!==void 0?n[s.key]="***":s.default!==void 0?n[s.key]=s.default:n[s.key]=s.type==="boolean"?!1:""}return n}function $tt(e,t=[]){const n=e.type;if(!t.includes(n))return n;let s=2;for(;t.includes(`${n}-${s}`);)s++;return`${n}-${s}`}function Htt({manifest:e,existingInstance:t,existingAdapterIds:n=[],onOpenChange:s}){const r=!!t,[i,o]=x.useState("configure"),[l,c]=x.useState(!1),[u]=x.useState(()=>(t==null?void 0:t.id)??$tt(e,n)),[d,f]=x.useState(()=>{var ae;return((ae=t==null?void 0:t.config)==null?void 0:ae.label)??""}),[m,g]=x.useState(0),[y,b]=x.useState(""),[S,w]=x.useState(""),[C,T]=x.useState(""),[E,j]=x.useState("per-chat"),_=MQe(),N=tce(),R=OQe(),O=ZT(),{data:M}=ba(),L=(M==null?void 0:M.agents)??[],P=e.setupSteps&&e.setupSteps.length>0,$=XE({defaultValues:Btt(e,t==null?void 0:t.config),validators:{onSubmit:({value:ae})=>{const oe={};for(const de of e.configFields)if(!(de.showWhen&&ae[de.showWhen.field]!==de.showWhen.equals)&&de.required){const me=ae[de.key];(me==null||me==="")&&(oe[de.key]=`${de.label} is required`)}return Object.keys(oe).length>0?{fields:oe}:void 0}},onSubmit:async()=>{}}),q=x.useMemo(()=>{if(!P||!e.setupSteps)return e.configFields;const ae=e.setupSteps[m];return ae?e.configFields.filter(oe=>ae.fields.includes(oe.key)):e.configFields},[e.configFields,e.setupSteps,P,m]),K=x.useCallback(()=>{const ae=$.state.values;let oe=!0;for(const de of q)if(!(de.showWhen&&ae[de.showWhen.field]!==de.showWhen.equals)&&de.required){const me=ae[de.key];(me==null||me==="")&&($.setFieldMeta(de.key,Re=>({...Re,isTouched:!0,errors:[`${de.label} is required`],errorMap:{onSubmit:`${de.label} is required`}})),oe=!1)}return oe},[$,q]),B=x.useCallback(()=>{if(i==="configure"){if(!K())return;if(P&&e.setupSteps&&m<e.setupSteps.length-1){g(de=>de+1);return}const oe=$.state.values;o("test"),R.mutate({type:e.type,config:HA(oe)},{onSuccess:de=>{de.botUsername&&(b(de.botUsername),d||f(`@${de.botUsername}`))}})}else i==="test"&&o("confirm")},[i,P,e,m,K,$,R,d]),V=x.useCallback(()=>{i==="test"?(o("configure"),R.reset()):i==="confirm"?o("test"):i==="bind"?s(!1):i==="configure"&&P&&m>0&&g(ae=>ae-1)},[i,P,m,R,s]),Q=x.useCallback(()=>{const ae=$.state.values,oe=HA(ae),de=d?{...oe,label:d}:oe;r&&t?N.mutate({id:t.id,config:de},{onSuccess:()=>s(!1)}):_.mutate({type:e.type,id:u,config:de},{onSuccess:()=>{const me=d||u;Ye.success(`${e.displayName} adapter added`,{description:me?`"${me}" is ready to use.`:void 0}),w(u),o("bind")},onError:me=>{var Re,Fe,Le;(Re=me.message)!=null&&Re.includes("timed out")?Ye.error("Request timed out",{description:"Check your token and network connectivity, then try again."}):((Fe=me.message)!=null&&Fe.includes("duplicate")||(Le=me.message)!=null&&Le.includes("exists"))&&(o("configure"),g(0))}})},[$,r,t,N,_,e,u,d,s]),re=x.useCallback(()=>{C&&O.mutate({adapterId:S,agentId:C,sessionStrategy:E,label:""},{onSuccess:()=>s(!1)})},[C,S,E,O,s]),U=x.useCallback(()=>{s(!1)},[s]),G=x.useCallback(ae=>{ae||(o("configure"),g(0),f(""),b(""),w(""),T(""),j("per-chat"),c(!1),$.reset(),R.reset()),s(ae)},[s,$,R]),W=x.useCallback(()=>{R.mutate({type:e.type,config:HA($.state.values)})},[R,e.type,$]),F=_.isPending||N.isPending,X=O.isPending,J=P&&e.setupSteps?e.setupSteps[m]:void 0;return{step:i,isEditMode:r,adapterId:u,label:d,setLabel:f,botUsername:y,guideOpen:l,setGuideOpen:c,form:$,visibleFields:q,bindAgentId:C,setBindAgentId:T,bindStrategy:E,setBindStrategy:j,agentOptions:L,isSaving:F,isBinding:X,hasSetupSteps:P,setupStepIndex:m,currentSetupStep:J,testConnection:R,handleContinue:B,handleBack:V,handleSave:Q,handleBind:re,handleSkipBind:U,handleOpenChange:G,handleRetryTest:W}}function Fce({open:e,onOpenChange:t,manifest:n,existingInstance:s,existingAdapterIds:r=[]}){var Q;const i=Htt({manifest:n,existingInstance:s,existingAdapterIds:r,onOpenChange:t}),{step:o,isEditMode:l,adapterId:c,label:u,setLabel:d,botUsername:f,guideOpen:m,setGuideOpen:g,form:y,visibleFields:b,bindAgentId:S,setBindAgentId:w,bindStrategy:C,setBindStrategy:T,agentOptions:E,isSaving:j,isBinding:_,hasSetupSteps:N,setupStepIndex:R,currentSetupStep:O,testConnection:M,handleContinue:L,handleBack:P,handleSave:$,handleBind:q,handleSkipBind:K,handleOpenChange:B,handleRetryTest:V}=i;return a.jsxs(x.Fragment,{children:[a.jsx(qc,{open:e,onOpenChange:B,children:a.jsxs(Cl,{className:"flex max-h-[85vh] max-w-lg flex-col",children:[a.jsxs(El,{children:[a.jsx(Tl,{children:l?`Edit ${n.displayName}`:`Add ${n.displayName}`}),a.jsxs(_l,{children:[o==="configure"&&((O==null?void 0:O.description)??"Configure the adapter settings."),o==="test"&&"Testing connection to the adapter.",o==="confirm"&&"Review your configuration before saving.",o==="bind"&&"Optionally bind this adapter to an agent."]})]}),a.jsxs("div",{className:"min-h-0 space-y-4 overflow-y-auto py-2",children:[a.jsx(jtt,{current:o,showBindStep:!l}),a.jsx(Ue,{mode:"wait",children:a.jsxs(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},children:[o==="configure"&&a.jsx(Dtt,{manifest:n,label:u,onLabelChange:d,fields:b,form:y,currentSetupStep:O,hasSetupGuide:!!n.setupGuide,onOpenGuide:()=>g(!0)}),o==="test"&&a.jsx(Ott,{isPending:M.isPending,isSuccess:M.isSuccess,isError:M.isError,errorMessage:(Q=M.error)==null?void 0:Q.message,botUsername:f,onRetry:V}),o==="confirm"&&a.jsx(y.Subscribe,{selector:re=>re.values,children:re=>a.jsx(Ptt,{manifest:n,adapterId:c,isEditMode:l,values:re})}),o==="bind"&&a.jsx(Ftt,{agentOptions:E,agentId:S,onAgentIdChange:w,strategy:C,onStrategyChange:T,botUsername:f,adapterType:n.type})]},o)})]}),a.jsxs(i0,{className:"flex items-center justify-between sm:justify-between",children:[a.jsxs("div",{children:[(o==="test"||o==="confirm")&&a.jsxs(ge,{variant:"ghost",onClick:P,disabled:j,children:[a.jsx(ov,{className:"mr-1 size-4"}),"Back"]}),o==="configure"&&N&&R>0&&a.jsxs(ge,{variant:"ghost",onClick:P,children:[a.jsx(ov,{className:"mr-1 size-4"}),"Back"]})]}),a.jsxs("div",{className:"flex gap-2",children:[o!=="bind"&&a.jsx(ge,{variant:"outline",onClick:()=>B(!1),children:"Cancel"}),o==="configure"&&a.jsxs(ge,{onClick:L,children:["Continue",a.jsx(uh,{className:"ml-1 size-4"})]}),o==="test"&&!M.isPending&&!M.isSuccess&&a.jsx(ge,{variant:"ghost",onClick:L,children:"Skip"}),o==="test"&&M.isSuccess&&a.jsxs(ge,{onClick:L,children:["Continue",a.jsx(uh,{className:"ml-1 size-4"})]}),o==="confirm"&&a.jsxs(ge,{onClick:$,disabled:j,children:[j&&a.jsx(Sn,{className:"mr-2 size-4 animate-spin"}),l?"Save Changes":"Add Adapter"]}),o==="bind"&&a.jsxs(a.Fragment,{children:[a.jsx(ge,{variant:"ghost",onClick:K,disabled:_,children:"Skip"}),a.jsxs(ge,{onClick:q,disabled:!S||_,children:[_&&a.jsx(Sn,{className:"mr-2 size-4 animate-spin"}),"Bind to Agent"]})]})]})]})]})}),n.setupGuide&&a.jsx(ztt,{open:m,onOpenChange:g,title:n.displayName,content:n.setupGuide})]})}function Utt(){const[e,t]=x.useState({removeTarget:null,eventsTarget:null,bindingTarget:null});return{...e,openRemove:(n,s)=>t(r=>({...r,removeTarget:{instanceId:n,name:s}})),closeRemove:()=>t(n=>({...n,removeTarget:null})),openEvents:n=>t(s=>({...s,eventsTarget:{instanceId:n}})),closeEvents:()=>t(n=>({...n,eventsTarget:null})),openBindingCreate:n=>t(s=>({...s,bindingTarget:{mode:"create",adapterId:n}})),openBindingEdit:(n,s)=>t(r=>({...r,bindingTarget:{mode:"edit",adapterId:n,binding:s}})),closeBinding:()=>t(n=>({...n,bindingTarget:null}))}}function qU({enabled:e}){var R,O;const{data:t=[],isLoading:n}=S0(e),{data:s}=ba(),{mutate:r}=ece(),{mutate:i}=DQe(),o=ZT(),l=cJe(),c=lJe(),[u,d]=x.useState({open:!1}),f=et(),m=Utt();function g(M){var L;return(L=t.flatMap(P=>P.instances.map($=>({instance:$,manifest:P.manifest}))).find(P=>P.instance.id===M))==null?void 0:L.manifest}function y(M){const L=s==null?void 0:s.agents.find(P=>P.id===M);return L?nn(L):M}async function b(M){const L=m.bindingTarget;if(L)try{L.mode==="edit"&&L.binding?(await l.mutateAsync({id:L.binding.id,updates:TJe(M)}),Ye.success("Channel updated")):(await o.mutateAsync(EJe(M)),Ye.success("Channel connected")),m.closeBinding()}catch(P){Ye.error(P instanceof Error?P.message:"Failed to save channel")}}async function S(M){try{await c.mutateAsync(M),Ye.success("Channel removed"),m.closeBinding()}catch(L){Ye.error(L instanceof Error?L.message:"Failed to remove channel")}}if(n)return a.jsxs("div",{className:"space-y-6 p-4",children:[a.jsxs("div",{className:"space-y-3",children:[a.jsx(Jt,{className:"h-4 w-32"}),a.jsx("div",{className:"space-y-2",children:[1,2].map(M=>a.jsx(Jt,{className:"h-16 w-full rounded-lg"},M))})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx(Jt,{className:"h-4 w-32"}),a.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))"},children:[1,2].map(M=>a.jsxs("div",{className:"rounded-lg border p-4",children:[a.jsx(Jt,{className:"mb-2 h-5 w-24"}),a.jsx(Jt,{className:"h-4 w-full"}),a.jsx(Jt,{className:"mt-3 h-8 w-full"})]},M))})]})]});const w=t.flatMap(M=>M.instances.map(L=>({instance:L,manifest:M.manifest}))),C=t.filter(M=>!M.manifest.deprecated&&(M.instances.length===0||M.manifest.multiInstance)),T=M=>{d({open:!0,manifest:M})},E=(M,L)=>{d({open:!0,manifest:M,instanceId:L})},j=u.instanceId?t.flatMap(M=>M.instances).find(M=>M.id===u.instanceId):void 0,_=()=>{f.invalidateQueries({queryKey:["relay","adapters","catalog"]})},N=M=>({adapterId:M.adapterId,agentId:M.agentId,sessionStrategy:M.sessionStrategy,label:M.label??"",permissionMode:M.permissionMode,chatId:M.chatId,channelType:M.channelType,canInitiate:M.canInitiate,canReply:M.canReply,canReceive:M.canReceive});return a.jsxs("div",{className:"space-y-6 p-4",children:[a.jsxs("section",{children:[a.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[a.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Active Channels"}),a.jsx(ge,{variant:"ghost",size:"sm",onClick:_,className:"size-7 p-0","aria-label":"Refresh channel catalog",children:a.jsx(ma,{className:"size-3.5"})})]}),w.length===0?a.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed py-8",children:[a.jsx(Gk,{className:"text-muted-foreground/40 size-8"}),a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-muted-foreground text-sm",children:"No channels active"}),a.jsx("p",{className:"text-muted-foreground/60 text-xs",children:"Add a channel below to connect agents to external services"})]})]}):a.jsx("div",{className:"space-y-3",children:w.map(({instance:M,manifest:L})=>a.jsx(Ctt,{instance:M,manifest:L,onToggle:P=>r({id:M.id,enabled:P}),onConfigure:()=>E(L,M.id),onShowEvents:P=>m.openEvents(P),onEditBinding:P=>m.openBindingEdit(P.adapterId,P),onRemoveConfirm:(P,$)=>m.openRemove(P,$),onAddBinding:P=>m.openBindingCreate(P)},M.id))})]}),a.jsxs("section",{children:[a.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-semibold tracking-wide uppercase",children:"Add Channel"}),C.length===0?a.jsx("p",{className:"text-muted-foreground text-sm",children:"All channel types are active. Multi-instance channels like Webhook can be added again from the active list."}):a.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))"},children:C.map(M=>a.jsx(Lce,{manifest:M.manifest,onAdd:()=>T(M.manifest)},M.manifest.type))})]}),u.manifest&&a.jsx(Fce,{open:u.open,onOpenChange:M=>{M||d({open:!1})},manifest:u.manifest,existingInstance:j,existingAdapterIds:t.flatMap(M=>M.instances.map(L=>L.id))}),m.removeTarget&&a.jsx(Sl,{open:!0,onOpenChange:M=>{M||m.closeRemove()},children:a.jsxs(ko,{children:[a.jsxs(wl,{children:[a.jsx(Co,{children:"Remove adapter"}),a.jsxs(Eo,{children:['Are you sure you want to remove "',m.removeTarget.name,'"? This will stop the adapter and remove its configuration. Messages to its subjects will no longer be delivered.']})]}),a.jsxs(kl,{children:[a.jsx(_o,{children:"Cancel"}),a.jsx(To,{onClick:()=>{i(m.removeTarget.instanceId),m.closeRemove()},className:"bg-red-600 hover:bg-red-700 focus:ring-red-600",children:"Remove"})]})]})}),m.eventsTarget&&a.jsx(Al,{open:!0,onOpenChange:M=>{M||m.closeEvents()},children:a.jsxs(Rl,{className:"flex flex-col sm:max-w-md",children:[a.jsx(Ml,{children:a.jsx(Dl,{children:"Events"})}),a.jsx("div",{className:"flex-1 overflow-hidden",children:a.jsx(_tt,{adapterId:m.eventsTarget.instanceId})})]})}),m.bindingTarget&&a.jsx(mce,{open:!0,onOpenChange:M=>{M||m.closeBinding()},mode:m.bindingTarget.mode,initialValues:m.bindingTarget.binding?N(m.bindingTarget.binding):{adapterId:m.bindingTarget.adapterId},adapterName:(R=g(m.bindingTarget.adapterId))==null?void 0:R.displayName,agentName:m.bindingTarget.binding?y(m.bindingTarget.binding.agentId):void 0,onConfirm:b,onDelete:m.bindingTarget.mode==="edit"?S:void 0,bindingId:(O=m.bindingTarget.binding)==null?void 0:O.id,isPending:o.isPending||l.isPending||c.isPending})]})}function Vtt({onAddChannel:e}){return a.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center px-6 py-16",children:[a.jsx("div",{className:"pointer-events-none mb-8 w-full max-w-md opacity-30 select-none",children:a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"rounded-lg border p-3",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"flex size-6 items-center justify-center rounded-full bg-blue-500/20",children:a.jsx("div",{className:"size-3 rounded-full bg-blue-500"})}),a.jsxs("div",{className:"flex-1 space-y-1",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm font-medium",children:"relay.agent.frontend"}),a.jsx("span",{className:"text-muted-foreground text-xs",children:"2m ago"})]}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Build completed successfully"})]})]})}),a.jsx("div",{className:"rounded-lg border p-3",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"flex size-6 items-center justify-center rounded-full bg-emerald-500/20",children:a.jsx("div",{className:"size-3 rounded-full bg-emerald-500"})}),a.jsxs("div",{className:"flex-1 space-y-1",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm font-medium",children:"relay.system.tasks.audit"}),a.jsx("span",{className:"text-muted-foreground text-xs",children:"15m ago"})]}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Scheduled audit run delivered"})]})]})}),a.jsx("div",{className:"rounded-lg border p-3",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"flex size-6 items-center justify-center rounded-full bg-orange-500/20",children:a.jsx("div",{className:"size-3 rounded-full bg-orange-500"})}),a.jsxs("div",{className:"flex-1 space-y-1",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm font-medium",children:"relay.agent.backend"}),a.jsx("span",{className:"text-muted-foreground text-xs",children:"1h ago"})]}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"API migration task completed"})]})]})})]})}),a.jsx("h3",{className:"mb-2 text-lg font-medium",children:"Connect your agents to the world"}),a.jsx("p",{className:"text-muted-foreground mb-1 max-w-sm text-center text-sm",children:"Relay routes messages between your agents and external platforms."}),a.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm text-center text-sm",children:"Add your first channel to start sending and receiving messages."}),a.jsx(ge,{onClick:e,children:"Add Channel"})]})}const GU={healthy:"bg-emerald-500",degraded:"bg-amber-500",critical:"bg-red-500"};function qtt(e){return e==null?"—":e<1?"<1ms":`${Math.round(e)}ms`}function Gtt(e,t,n){const s=e.totalMessages>0?(e.failedCount+e.deadLetteredCount)/e.totalMessages:0;if(n===0)return{state:"healthy",message:"No connections configured"};if(s>.5||t===0)return{state:"critical",message:`${Math.round(s*100)}% failure rate — ${e.failedCount} messages failed today`};if(t<n||s>=.05){const r=n-t;return r>0?{state:"degraded",message:`${r} connection${r>1?"s":""} disconnected`}:{state:"degraded",message:`${e.failedCount} failure${e.failedCount!==1?"s":""} in last 24h`}}return{state:"healthy",message:`${t} connection${t>1?"s":""} active`}}function Ktt(e){const{data:t=[],isLoading:n}=S0(e),s=t.flatMap(o=>o.instances),r=s.length,i=s.filter(o=>o.status.state==="connected").length;return{total:r,connected:i,isLoading:n}}function Wtt({enabled:e=!0,onFailedClick:t}){const n=am(),{data:s,isLoading:r}=lP(),{total:i,connected:o,isLoading:l}=Ktt(e&&n);if(!n||!e||r||l||!s)return null;const{state:c,message:u}=Gtt(s,o,i),d=(c==="degraded"||c==="critical")&&t!=null,f=qtt(s.avgDeliveryLatencyMs),m=`${s.totalMessages} messages today · ${s.failedCount} failed · ${f} avg latency`;return a.jsx(em,{children:a.jsx("div",{className:"text-muted-foreground flex items-center gap-2 border-b px-3 py-1.5 text-xs",children:c==="healthy"?a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsxs("span",{className:"flex min-w-0 flex-1 cursor-default items-center gap-1.5",children:[a.jsx("span",{className:`size-2 shrink-0 rounded-full ${GU[c]}`,"aria-hidden":"true"}),a.jsx("span",{className:"truncate",children:u}),s.avgDeliveryLatencyMs!=null&&a.jsxs(a.Fragment,{children:[a.jsx("span",{"aria-hidden":"true",children:"·"}),a.jsx("span",{children:f})]})]})}),a.jsx(yn,{side:"bottom",children:m})]}):a.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[a.jsx("span",{className:`size-2 shrink-0 rounded-full ${GU[c]}`,"aria-hidden":"true"}),d?a.jsx("button",{type:"button",onClick:t,className:"truncate text-left hover:underline","aria-label":`${u} — click to view failures`,children:u}):a.jsx("span",{className:"truncate",children:u})]})})})}function Ytt(){const e=am(),[t,n]=x.useState("connections"),[s,r]=x.useState(!1),[i,o]=x.useState(!1),l=x.useRef(null),{connectionState:c}=AQe(e),{data:u=[]}=S0(e),d=u.some(m=>m.instances.length>0),f=x.useCallback(()=>{n("activity"),o(!0),setTimeout(()=>o(!1),100),setTimeout(()=>{var m;(m=l.current)==null||m.scrollIntoView({behavior:"smooth",block:"start"})},150)},[]);return e?a.jsx(Ue,{mode:"wait",children:d?a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"flex h-full flex-col",children:a.jsxs(CT,{value:t,onValueChange:n,className:"flex h-full flex-col",children:[a.jsx(Wtt,{enabled:e,onFailedClick:f}),a.jsx(p9e,{connectionState:c,className:"mx-4 mt-2"}),a.jsxs(Mb,{className:"mx-4 mt-3 shrink-0",children:[a.jsx(_c,{value:"connections",children:"Connections"}),a.jsx(_c,{value:"activity",children:"Activity"})]}),a.jsx(Ue,{mode:"wait",children:a.jsxs(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"min-h-0 flex-1 overflow-y-auto",children:[a.jsx(Vp,{value:"connections",className:"h-full",children:a.jsx(qU,{enabled:e})}),a.jsx(Vp,{value:"activity",className:"h-full",children:a.jsx(ytt,{enabled:e,deadLetterRef:l,onSwitchToChannels:()=>n("connections"),autoShowFailures:i})})]},t)})]})},"mode-b"):a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"flex h-full flex-col",children:s?a.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:a.jsx(qU,{enabled:e})}):a.jsx(Vtt,{onAddChannel:()=>r(!0)})},"mode-a")}):a.jsx(h4,{icon:fne,name:"Relay",description:"Relay provides inter-agent messaging. Start DorkOS with relay enabled.",command:"DORKOS_RELAY_ENABLED=true dorkos"})}const UA={"meet-dorkbot":"Meet DorkBot",discovery:"Create agents",tasks:"Set up Tasks schedules",adapters:"Connect adapters"},Ztt=["discovery","tasks"];function Xtt({onStepClick:e,onDismiss:t}){const{state:n}=Wb(),s=Ds();return a.jsxs(te.div,{initial:s?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3},className:"border-border bg-card relative rounded-lg border p-3",children:[a.jsx("button",{onClick:t,className:"text-muted-foreground/50 hover:text-muted-foreground absolute top-1.5 right-1.5 rounded-md p-0.5 transition-colors duration-150","aria-label":"Dismiss getting started",children:a.jsx(es,{className:"size-3.5"})}),a.jsx("h3",{className:"mb-2 text-xs font-medium",children:"Getting Started"}),a.jsx("ul",{className:"space-y-1",children:Ztt.map((r,i)=>{const o=n.completedSteps.includes(r),l=n.skippedSteps.includes(r);return o?a.jsxs("li",{className:"flex items-center gap-2 py-0.5",children:[a.jsx(Lt,{className:"text-primary size-3.5 shrink-0"}),a.jsx("span",{className:"text-muted-foreground text-xs",children:UA[r]})]},r):l?a.jsxs("li",{className:"flex items-center gap-2 py-0.5",children:[a.jsx(IMe,{className:"text-muted-foreground/40 size-3.5 shrink-0"}),a.jsx("button",{onClick:()=>e(i),className:Y("text-muted-foreground/40 text-left text-xs transition-colors duration-150","hover:text-muted-foreground"),children:UA[r]})]},r):a.jsxs("li",{className:"flex items-center gap-2 py-0.5",children:[a.jsx(dh,{className:"text-muted-foreground size-3.5 shrink-0"}),a.jsx("button",{onClick:()=>e(i),className:"text-foreground text-left text-xs transition-colors duration-150 hover:underline",children:UA[r]})]},r)})})]})}function Qtt(e){return`set${e.charAt(0).toUpperCase()}${e.slice(1)}`}function Jtt(e){const t=t0(),n=Kh(),s=Wh();switch(e){case"settings":return{isOpen:t.isOpen,close:t.close};case"tasks":return{isOpen:n.isOpen,close:n.close};case"relay":return{isOpen:s.isOpen,close:s.close};default:return{isOpen:!1,close:()=>{}}}}function ent({contribution:e}){const t=we(u=>u[e.openStateKey]),n=we(u=>u[Qtt(e.openStateKey)]),s=Jtt(e.urlParam),r=s.isOpen,i=s.close,o=t||r,l=x.useCallback(u=>{n(u),!u&&r&&i()},[n,r,i]),c=e.component;return a.jsx(c,{open:o,onOpenChange:l})}function tnt(){const e=Od("dialog"),t=we(s=>s.onboardingStep),n=we(s=>s.setOnboardingStep);return a.jsxs(a.Fragment,{children:[e.map(s=>a.jsx(ent,{contribution:s},s.id)),t!==null&&a.jsx("div",{className:"bg-background fixed inset-0 z-50",children:a.jsx(Ice,{initialStep:t,onComplete:()=>n(null)})})]})}function nnt(){const{theme:e,setTheme:t}=yb(),{fontFamily:n,setFontFamily:s,fontSize:r,setFontSize:i,resetPreferences:o}=we();return a.jsxs("div",{className:"space-y-4",children:[a.jsx(l0,{actions:a.jsx("button",{onClick:()=>{o(),t("system")},className:"text-muted-foreground hover:text-foreground text-xs transition-colors duration-150",children:"Reset to defaults"}),children:"Appearance"}),a.jsx(vr,{children:a.jsxs(dr,{children:[a.jsx(cs,{label:"Theme",description:"Choose your preferred color scheme",children:a.jsxs(On,{value:e,onValueChange:t,children:[a.jsx(_n,{className:"w-32",children:a.jsx(In,{})}),a.jsxs(Nn,{children:[a.jsx(mt,{value:"light",children:"Light"}),a.jsx(mt,{value:"dark",children:"Dark"}),a.jsx(mt,{value:"system",children:"System"})]})]})}),a.jsx(cs,{label:"Font family",description:"Choose the typeface for the interface",children:a.jsxs(On,{value:n,onValueChange:l=>s(l),children:[a.jsx(_n,{className:"w-40",children:a.jsx(In,{})}),a.jsx(Nn,{children:Ak.map(l=>a.jsx(mt,{value:l.key,children:a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{children:l.displayName}),a.jsx("span",{className:"text-muted-foreground text-xs",children:l.description})]})},l.key))})]})}),a.jsx(cs,{label:"Font size",description:"Adjust the text size across the interface",children:a.jsxs(On,{value:r,onValueChange:l=>i(l),children:[a.jsx(_n,{className:"w-32",children:a.jsx(In,{})}),a.jsxs(Nn,{children:[a.jsx(mt,{value:"small",children:"Small"}),a.jsx(mt,{value:"medium",children:"Medium"}),a.jsx(mt,{value:"large",children:"Large"})]})]})})]})})]})}function snt(){const{showTimestamps:e,setShowTimestamps:t,expandToolCalls:n,setExpandToolCalls:s,autoHideToolCalls:r,setAutoHideToolCalls:i,devtoolsOpen:o,toggleDevtools:l,showShortcutChips:c,setShowShortcutChips:u,showTaskCelebrations:d,setShowTaskCelebrations:f,enableNotificationSound:m,setEnableNotificationSound:g,enableTasksNotifications:y,setEnableTasksNotifications:b,promoEnabled:S,setPromoEnabled:w}=we();return a.jsxs("div",{className:"space-y-4",children:[a.jsx(l0,{children:"Preferences"}),a.jsx(vr,{children:a.jsxs(dr,{children:[a.jsx(Zi,{label:"Show timestamps",description:"Display message timestamps in chat",checked:e,onCheckedChange:t}),a.jsx(Zi,{label:"Expand tool calls",description:"Auto-expand tool call details in messages",checked:n,onCheckedChange:s}),a.jsx(Zi,{label:"Auto-hide tool calls",description:"Fade out completed tool calls after a few seconds",checked:r,onCheckedChange:i}),a.jsx(Zi,{label:"Show shortcut chips",description:"Display shortcut hints below the message input",checked:c,onCheckedChange:u}),a.jsx(Zi,{label:"Task celebrations",description:"Show animations when tasks complete",checked:d,onCheckedChange:f}),a.jsx(Zi,{label:"Notification sound",description:"Play a sound when AI finishes responding (3s+ responses)",checked:m,onCheckedChange:g}),a.jsx(Zi,{label:"Tasks run notifications",description:"Show a toast when a scheduled Tasks run completes",checked:y,onCheckedChange:b}),a.jsx(Zi,{label:"Feature suggestions",description:"Show feature discovery cards on the dashboard and sidebar",checked:S,onCheckedChange:w}),a.jsx(Zi,{label:"Show dev tools",description:"Enable developer tools panel",checked:o,onCheckedChange:()=>l()})]})})]})}const zce=he.createContext(null);function rnt(){const e=he.useContext(zce);if(!e)throw new Error("StatusLine.Item must be used within a StatusLine.");return e}const int={duration:.2,ease:[.4,0,.2,1]};function ant({sessionId:e,isStreaming:t,children:n}){const[s,r]=x.useState([]),i=x.useCallback(d=>{r(f=>f.includes(d)?f:[...f,d])},[]),o=x.useCallback(d=>{r(f=>f.filter(m=>m!==d))},[]),l=s[0]??null,c=s.length>0,u=x.useMemo(()=>({itemTransition:int,firstVisibleKey:l,registerItem:i,unregisterItem:o}),[l,i,o]);return a.jsxs(zce.Provider,{value:u,children:[a.jsx(Ue,{initial:!1,children:c&&a.jsx(te.div,{role:"toolbar","aria-label":"Session status","aria-live":"polite","data-testid":"status-line",initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:[.4,0,.2,1]},className:"overflow-hidden",children:a.jsx(cnt,{children:a.jsx(Ue,{initial:!1,mode:"popLayout",children:he.Children.map(n,d=>{if(!he.isValidElement(d))return d;const f=d.props.itemKey;return f?he.cloneElement(d,{key:f}):d})})})})}),!c&&n]})}function ont({itemKey:e,visible:t,children:n}){const{itemTransition:s,firstVisibleKey:r,registerItem:i,unregisterItem:o}=rnt();if(x.useEffect(()=>{if(t)return i(e),()=>o(e)},[t,e,i,o]),!t)return null;const l=e===r;return a.jsxs(te.div,{layout:"position",initial:{opacity:0,scale:.8,filter:"blur(4px)"},animate:{opacity:1,scale:1,filter:"blur(0px)"},exit:{opacity:0,scale:.8,filter:"blur(4px)"},transition:s,className:"inline-flex items-center gap-2",children:[!l&&a.jsx(lnt,{}),n]},e)}function lnt(){return a.jsx("span",{className:"text-muted-foreground/30","aria-hidden":"true",children:"·"})}function cnt({children:e}){const t=x.useRef(null),[n,s]=x.useState(!1),r=x.useCallback(()=>{const i=t.current;i&&s(i.scrollWidth-i.scrollLeft-i.clientWidth>1)},[]);return x.useEffect(()=>{const i=t.current;if(!i)return;r(),i.addEventListener("scroll",r,{passive:!0});const o=new ResizeObserver(r);return o.observe(i),()=>{i.removeEventListener("scroll",r),o.disconnect()}},[r]),a.jsxs("div",{className:"relative",children:[a.jsx("div",{ref:t,className:"text-muted-foreground scrollbar-none flex items-center gap-2 overflow-x-auto px-1 text-xs whitespace-nowrap",children:e}),a.jsx("div",{className:Y("from-background pointer-events-none absolute top-0 right-0 bottom-0 w-8 bg-gradient-to-l to-transparent transition-opacity duration-200",n?"opacity-100":"opacity-0"),"aria-hidden":!0})]})}const Wi=Object.assign(ant,{Item:ont});function unt({cwd:e}){const t=e.split("/").filter(Boolean).pop()??e;return a.jsxs("span",{className:"inline-flex items-center gap-1",title:e,children:[a.jsx(th,{className:"size-(--size-icon-xs)"}),a.jsx("span",{children:t})]})}HO(FO);const VA={DORKOS_PORT:0,VITE_PORT:1,SITE_PORT:2};function Bce(e){return{DORKOS_PORT:e+VA.DORKOS_PORT,VITE_PORT:e+VA.VITE_PORT,SITE_PORT:e+VA.SITE_PORT}}const dnt=/^[A-Za-z0-9._-]+$/,$ce=Je(["worktree","clone"]).openapi("WorkspaceProviderType"),fnt=Je(["provisioning","ready","failed","removing"]).openapi("WorkspaceStatus");se({id:z(),projectKey:z(),key:z().regex(dnt),path:z(),source:z(),branch:z().nullable(),provider:$ce,status:fnt,portBase:Ee().int(),portBlockSize:Ee().int(),hostname:z().nullable(),url:z().nullable(),pinned:rt(),createdAt:z(),lastUsedAt:z()}).openapi("Workspace");se({projectKey:z(),key:z(),source:z(),provider:$ce.optional()}).openapi("EnsureWorkspaceRequest");function hnt(e){const t=je();return st({queryKey:["git-status",e],queryFn:()=>t.getGitStatus(e??void 0),enabled:!!e,refetchInterval:ia.GIT_STATUS_REFETCH_MS,refetchIntervalInBackground:!1,staleTime:ia.GIT_STATUS_STALE_TIME_MS})}function mnt(e){return!!e&&!("error"in e)}function pnt({data:e,workspace:t}){if(!e)return null;if(!mnt(e))return a.jsxs("span",{className:"text-muted-foreground/50 inline-flex items-center gap-1",title:"Not a git repository",children:[a.jsx($p,{className:"size-(--size-icon-xs)"}),a.jsx("span",{children:"No repo"})]});const n=e.modified+e.staged+e.untracked,s=n===1?"1 change":`${n} changes`,r=[];if(e.modified>0&&r.push(`${e.modified} modified`),e.staged>0&&r.push(`${e.staged} staged`),e.untracked>0&&r.push(`${e.untracked} untracked`),e.conflicted>0&&r.push(`${e.conflicted} conflicted`),t){const o=Bce(t.portBase),l=[`${t.branch??e.branch} · ${t.provider}`,e.ahead>0?`↑${e.ahead}`:"",e.behind>0?`↓${e.behind}`:"",r.length>0?r.join(", "):"clean",`ports ${o.DORKOS_PORT} / ${o.VITE_PORT} / ${o.SITE_PORT}`,t.pinned?"pinned":""].filter(Boolean);return a.jsxs("span",{className:"inline-flex items-center gap-1",title:l.join(" · "),children:[a.jsx($p,{className:"size-(--size-icon-xs)"}),a.jsx("span",{className:"max-w-[20ch] truncate font-medium",children:t.key}),a.jsxs("span",{className:"text-muted-foreground",children:["· ",t.projectKey]}),t.pinned&&a.jsx(gb,{className:"text-muted-foreground size-(--size-icon-xs)"}),n>0&&a.jsxs("span",{className:"text-muted-foreground",children:["· ",s]})]})}const i=r.length>0?`${e.branch} · ${r.join(", ")}`:`${e.branch} · clean`;return a.jsxs("span",{className:"inline-flex items-center gap-1",title:i,children:[a.jsx($p,{className:"size-(--size-icon-xs)"}),a.jsx("span",{className:"max-w-[25ch] truncate",children:e.branch}),e.ahead>0&&a.jsxs("span",{className:"text-muted-foreground inline-flex items-center gap-0.5",children:[a.jsx(mb,{className:"size-(--size-icon-xs)"}),e.ahead]}),e.behind>0&&a.jsxs("span",{className:"text-muted-foreground inline-flex items-center gap-0.5",children:[a.jsx(hb,{className:"size-(--size-icon-xs)"}),e.behind]}),n>0&&a.jsxs("span",{className:"text-muted-foreground",children:["· ",s]})]})}const KU={default:Hc,acceptEdits:xb,plan:zAe,dontAsk:pb,bypassPermissions:Q5,auto:Jg,"always-allow":Lt,"always-deny":Xg,scripted:G5},WU={bypassPermissions:!0,auto:!0,"always-allow":!0},YU=Hc,gnt={auto:"Preview"},xnt="Auto mode requires Opus 4.6+ or Sonnet 4.6",ynt={default:"Default",acceptEdits:"Accept Edits",plan:"Plan Mode",dontAsk:"Don't Ask",bypassPermissions:"Bypass All",auto:"Auto"};function vnt({mode:e,onChangeMode:t,disabled:n,runtime:s,modelSupportsAutoMode:r}){const i=tP(s);if(i&&!i.permissionModes.supported)return null;const o=(i==null?void 0:i.permissionModes.values)??[],l=!r&&o.some(y=>y.id==="auto"),c=l?o.filter(y=>y.id!=="auto"):o,u=c.find(y=>y.id===e),d=(u==null?void 0:u.label)??ynt[e]??e,f=KU[e]??YU,m=WU[e]??!1,g=a.jsxs("button",{disabled:n,className:`hover:text-foreground inline-flex items-center gap-1 transition-colors duration-150 disabled:cursor-not-allowed disabled:opacity-40 ${m?"text-red-500":""}`,children:[a.jsx(f,{className:"size-(--size-icon-xs)"}),a.jsx("span",{children:d})]});return n?a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx("span",{className:"inline-flex",children:g})}),a.jsx(yn,{side:"top",children:"Send a message first"})]}):a.jsxs(i4,{children:[a.jsx(a4,{asChild:!0,children:g}),a.jsxs(o4,{side:"top",align:"start",className:"w-56",children:[a.jsx(l4,{children:"Permission Mode"}),a.jsx(Nie,{value:e,onValueChange:y=>t(y),children:c.map(y=>{const b=KU[y.id]??YU,S=WU[y.id]??!1,w=gnt[y.id];return a.jsx(jie,{value:y.id,icon:b,description:y.description,className:S?"text-red-500":"",children:a.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[y.label,w&&a.jsx("span",{className:"bg-muted text-muted-foreground rounded px-1 py-px text-[10px] font-medium tracking-wide uppercase",children:w})]})},y.id)})}),l&&a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsxs("p",{"data-testid":"auto-unsupported-hint",className:"text-muted-foreground flex items-center gap-1.5 px-2 py-1.5 text-[10px]",children:[a.jsx(Jg,{className:"size-(--size-icon-xs) shrink-0"}),"Auto unavailable on this model"]})}),a.jsx(yn,{side:"top",children:xnt})]})]})]})}function bnt(e){const t=je(),n=et(),s=Bt({mutationFn:r=>t.storeRuntimeCredential(e,r),onSuccess:()=>{n.invalidateQueries({queryKey:[...Wc]})}});return{store:r=>{r.trim().length!==0&&s.mutate(r)},isPending:s.isPending,isSuccess:s.isSuccess,isError:s.isError,errorMessage:s.isError?s.error.message??"Could not save the API key.":null,reset:s.reset}}function Snt(e){var o,l,c;const t=je(),n=et(),s=Bt({mutationFn:()=>t.delegateRuntimeLogin(e),onSuccess:u=>{u.ok&&n.invalidateQueries({queryKey:[...Wc]})}}),r=s.isError||((o=s.data)==null?void 0:o.ok)===!1,i=s.isError?s.error.message:((l=s.data)==null?void 0:l.error)??null;return{login:()=>s.mutate(),isPending:s.isPending,isSuccess:((c=s.data)==null?void 0:c.ok)===!0,isError:r,errorMessage:r?i??"Sign-in failed. Please try again.":null}}function vd({message:e}){const t=Ds();return a.jsxs(te.div,{className:"bg-muted flex items-center gap-2 rounded-lg px-3 py-2.5",initial:t?!1:{opacity:0},animate:{opacity:1},"data-testid":"connect-progress",children:[a.jsx(te.span,{className:"text-muted-foreground inline-flex",animate:t?{}:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:a.jsx(Sn,{className:"size-3.5"})}),a.jsx(Ue,{mode:"wait",children:a.jsx(te.span,{className:"truncate text-xs",initial:t?!1:{opacity:0},animate:{opacity:1},exit:t?void 0:{opacity:0},transition:{duration:.2},children:e},e)})]})}function XT({message:e="Connected"}){return a.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-3 py-2.5 text-xs text-emerald-500","data-testid":"connect-connected",children:[a.jsx(Lt,{className:"size-3.5"}),e]})}function QT({message:e,onRetry:t}){return a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-destructive text-xs",role:"alert",children:e}),a.jsx(ge,{size:"sm",onClick:t,children:"Try again"})]})}const ZU={"claude-code":{signInLabel:"Sign in",signInHint:"Use your Claude subscription or Anthropic account.",signInPending:"Waiting for sign-in to complete…",keyLabel:"Anthropic API key",keyPlaceholder:"sk-ant-…",getKeyUrl:"https://console.anthropic.com/settings/keys"},codex:{signInLabel:"Sign in with ChatGPT",signInHint:"Use your ChatGPT account.",signInPending:"Waiting for sign-in to complete…",keyLabel:"OpenAI API key",keyPlaceholder:"sk-…",getKeyUrl:"https://platform.openai.com/api-keys"}};function wnt({type:e}){const t=ZU[e]??ZU["claude-code"],n=Snt(e);return a.jsxs("div",{className:"space-y-4","data-testid":`login-connect-${e}`,children:[a.jsx("div",{className:"space-y-2",children:n.isPending?a.jsx(vd,{message:t.signInPending}):n.isSuccess?a.jsx(XT,{message:"Signed in"}):n.isError?a.jsx(QT,{message:n.errorMessage??"Sign-in failed.",onRetry:n.login}):a.jsxs(a.Fragment,{children:[a.jsx(ge,{size:"sm",className:"w-full",onClick:n.login,children:t.signInLabel}),a.jsx("p",{className:"text-muted-foreground text-xs",children:t.signInHint})]})}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"bg-border h-px flex-1"}),a.jsx("span",{className:"text-muted-foreground text-2xs tracking-wide uppercase",children:"or"}),a.jsx("span",{className:"bg-border h-px flex-1"})]}),a.jsx(knt,{type:e,copy:t})]})}function knt({type:e,copy:t}){const[n,s]=x.useState(""),r=bnt(e);return r.isPending?a.jsx(vd,{message:"Saving your API key…"}):r.isSuccess?a.jsx(XT,{}):a.jsxs("form",{className:"space-y-2",onSubmit:i=>{i.preventDefault(),r.store(n)},children:[a.jsx(Rt,{htmlFor:`api-key-${e}`,className:"text-xs",children:t.keyLabel}),a.jsx(il,{id:`api-key-${e}`,value:n,onChange:i=>s(i.target.value),placeholder:t.keyPlaceholder,autoComplete:"off",spellCheck:!1}),r.isError&&a.jsx("p",{className:"text-destructive text-xs",role:"alert",children:r.errorMessage}),a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.getKeyUrl?a.jsxs("a",{href:t.getKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:["Get an API key ",a.jsx(fa,{className:"size-3"})]}):a.jsx("span",{}),a.jsx(ge,{type:"submit",size:"sm",variant:"outline",disabled:n.trim().length===0,children:"Save key"})]})]})}const JT="ollama";function Cnt(e){const t=je();return st({queryKey:["runtime-connect","ollama"],queryFn:()=>t.detectOllama(),enabled:e,staleTime:3e4})}function Ent(){const e=je(),t=et(),n=Bt({mutationFn:s=>e.updateConfig({runtimes:{opencode:{provider:JT}}}),onSuccess:()=>{t.invalidateQueries({queryKey:[...Wc]})}});return{connect:s=>n.mutate(s),isPending:n.isPending,isSuccess:n.isSuccess,isError:n.isError,errorMessage:n.isError?n.error.message??"Could not connect to Ollama.":null}}function Tnt(){const e=je(),t=et(),n=Bt({mutationFn:({providerId:s,key:r,baseURL:i})=>e.storeProviderCredential(s,r,(i==null?void 0:i.trim())||null),onSuccess:()=>{t.invalidateQueries({queryKey:[...Wc]})}});return{connect:s=>{s.key.trim().length===0||s.providerId.trim().length===0||n.mutate(s)},isPending:n.isPending,isSuccess:n.isSuccess,isError:n.isError,errorMessage:n.isError?n.error.message??"Could not save the provider key.":null}}function _nt(e){const t=je();return st({queryKey:["runtime-connect","ollama","catalog"],queryFn:()=>t.getOllamaModelCatalog(),enabled:e,staleTime:6e4})}function Nnt(){var l,c;const e=je(),t=et(),[n,s]=x.useState(null),r=Bt({mutationFn:async u=>{s(null);const d=await e.pullOllamaModel(u,f=>s(f));return d.ok&&await e.updateConfig({runtimes:{opencode:{provider:JT}}}),d},onSuccess:u=>{u.ok&&t.invalidateQueries({queryKey:[...Wc]})}}),i=r.isError||((l=r.data)==null?void 0:l.ok)===!1,o=r.isError?r.error.message:((c=r.data)==null?void 0:c.error)??null;return{pull:u=>r.mutate(u),isPending:r.isPending,isError:i,errorMessage:i?o??"The pull could not be completed.":null,progress:n,result:r.data}}const jnt="https://ollama.com/search?c=code",Ant={"runs-well":{label:"Runs well on your machine",tone:"text-emerald-600 dark:text-emerald-400"},"may-be-slow":{label:"May be slow on your machine",tone:"text-amber-600 dark:text-amber-400"},"too-large":{label:"Too large for your machine",tone:"text-destructive"}};function Rnt(){var l,c;const e=_nt(!0),t=Nnt();if(t.isPending)return a.jsx(Mnt,{progress:t.progress});const n=(l=e.data)==null?void 0:l.models[0];if((c=t.result)!=null&&c.ok&&n)return a.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-3 py-2.5 text-xs text-emerald-500","data-testid":"guided-pull-connected",children:[a.jsx(Lt,{className:"size-3.5 shrink-0"}),a.jsx("span",{children:"Connected —"}),a.jsx(vD,{runtime:"opencode",model:n.model.id,className:"text-xs"})]});if(t.isError&&n)return a.jsx(QT,{message:t.errorMessage??"The pull could not be completed.",onRetry:()=>t.pull(n.model.id)});if(e.isPending)return a.jsx(vd,{message:"Checking which models fit your machine…"});if(!n)return a.jsxs("div",{className:"space-y-2","data-testid":"ollama-no-model",children:[a.jsx("p",{className:"text-muted-foreground text-xs",children:"Ollama is running, but no coding model is pulled yet. Browse Ollama’s models to pull one."}),a.jsx(XU,{})]});const{model:s,verdict:r,explanation:i}=n,o=Ant[r];return a.jsxs("div",{className:"space-y-3","data-testid":"ollama-no-model",children:[a.jsx("p",{className:"text-muted-foreground text-xs",children:"Ollama is running, but no coding model is pulled yet. Pull a curated coding model to connect — private and free, on your machine."}),a.jsxs("div",{className:"border-border space-y-2.5 rounded-lg border p-3","data-testid":"guided-pull-card",children:[a.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[a.jsx("span",{className:"text-sm font-medium",children:s.label}),a.jsx("span",{className:"text-muted-foreground text-xs","data-testid":"guided-pull-size",children:s.sizeLabel})]}),a.jsxs("div",{className:"space-y-0.5","data-testid":"guided-pull-verdict","data-verdict":r,children:[a.jsx("p",{className:Y("text-xs font-medium",o.tone),children:o.label}),a.jsx("p",{className:"text-muted-foreground/80 text-[11px] leading-snug",children:i})]}),a.jsx(nP,{provider:JT,modelId:s.id,detail:!0}),a.jsxs(ge,{size:"sm",className:"w-full",disabled:r==="too-large",onClick:()=>t.pull(s.id),"data-testid":"guided-pull-start",children:["Pull ",s.label]})]}),a.jsx(XU,{})]})}function XU(){return a.jsxs("a",{href:jnt,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:["Browse Ollama models ",a.jsx(fa,{className:"size-3"})]})}function Mnt({progress:e}){const t=Ds(),n=e==null?void 0:e.percent,s=(e==null?void 0:e.status)??"Starting download…";return a.jsxs("div",{className:"space-y-2","data-testid":"guided-pull-progress",children:[a.jsx("div",{className:"bg-muted h-2 w-full overflow-hidden rounded-full",children:n===void 0?a.jsx(te.div,{className:"bg-primary/70 h-full w-1/3 rounded-full",animate:t?{}:{x:["-100%","300%"]},transition:{duration:1.2,repeat:1/0,ease:"easeInOut"}}):a.jsx(te.div,{className:"bg-primary h-full rounded-full",initial:!1,animate:{width:`${Math.min(100,Math.max(0,n))}%`},transition:t?{duration:0}:{duration:.3,ease:"easeOut"},"data-testid":"guided-pull-bar"})}),a.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-xs",children:[a.jsx(te.span,{className:"inline-flex",animate:t?{}:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:a.jsx(Sn,{className:"size-3.5"})}),a.jsx(Ue,{mode:"wait",children:a.jsxs(te.span,{className:"truncate",initial:t?!1:{opacity:0},animate:{opacity:1},exit:t?void 0:{opacity:0},transition:{duration:.2},children:[s,n!==void 0?` · ${Math.round(n)}%`:""]},s)})]})]})}const Dnt="https://ollama.com/download";function Ont({active:e}){const t=Cnt(e),n=Ent();if(n.isSuccess)return a.jsx(XT,{message:"Connected to Ollama"});if(n.isPending)return a.jsx(vd,{message:"Connecting to Ollama…"});if(n.isError)return a.jsx(QT,{message:n.errorMessage??"Could not connect to Ollama.",onRetry:()=>t.refetch()});if(t.isPending)return a.jsx(vd,{message:"Looking for Ollama on your machine…"});const s=t.data,r=(s==null?void 0:s.running)??!1,i=(s==null?void 0:s.models)??[];return r?i.length===0?a.jsx(Rnt,{}):a.jsxs("div",{className:"space-y-2","data-testid":"ollama-models",children:[a.jsx("p",{className:"text-muted-foreground text-xs",children:"Private and free: runs on your machine; your code never leaves it."}),a.jsx("ul",{className:"space-y-1.5",children:i.map(o=>a.jsxs("li",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[a.jsx("span",{className:"truncate text-sm",children:o.name}),a.jsx(nP,{provider:JT,modelId:o.name})]}),a.jsx(ge,{size:"sm",onClick:()=>n.connect(o.name),children:"Use this"})]},o.name))})]}):a.jsxs("div",{className:"space-y-3","data-testid":"ollama-absent",children:[a.jsx("p",{className:"text-muted-foreground text-xs",children:"Ollama isn’t running. Install it to run models locally — private and free, on your machine."}),a.jsx("a",{href:Dnt,target:"_blank",rel:"noopener noreferrer",className:"inline-flex",children:a.jsxs(ge,{size:"sm",variant:"outline",className:"gap-1.5",children:["Install Ollama ",a.jsx(fa,{className:"size-3.5"})]})})]})}const bP=["runtime-connect","openrouter","models"];function Int(e){const t=je();return st({queryKey:[...bP],queryFn:()=>t.getOpenRouterModels(),enabled:e,staleTime:5*6e4})}function Pnt(){var i,o,l;const e=je(),t=et(),n=Bt({mutationFn:c=>e.storeOpenRouterKey(c),onSuccess:c=>{c.ok&&(t.invalidateQueries({queryKey:[...Wc]}),t.invalidateQueries({queryKey:[...bP]}))}}),s=n.isError||((i=n.data)==null?void 0:i.ok)===!1,r=n.isError?n.error.message:((o=n.data)==null?void 0:o.error)??null;return{store:c=>{c.trim().length!==0&&n.mutate(c)},isPending:n.isPending,isSuccess:((l=n.data)==null?void 0:l.ok)===!0,isError:s,errorMessage:s?r??"Could not save the OpenRouter key.":null}}function Lnt(){var m,g;const e=je(),t=et(),[n,s]=x.useState(null),[r,i]=x.useState(null),o=Bt({mutationFn:()=>e.startOpenRouterOAuth(),onMutate:()=>i(null),onSuccess:({authorizeUrl:y,state:b})=>{window.open(y,"_blank","noopener,noreferrer"),s(b)},onError:y=>i(y.message??"Could not start OpenRouter sign-in.")}),l=st({queryKey:["runtime-connect","openrouter","oauth",n],queryFn:()=>e.getOpenRouterOAuthStatus(n),enabled:n!==null,refetchInterval:y=>{var b;return((b=y.state.data)==null?void 0:b.status)==="pending"?1500:!1}}),c=(m=l.data)==null?void 0:m.status;x.useEffect(()=>{c==="connected"&&(t.invalidateQueries({queryKey:[...Wc]}),t.invalidateQueries({queryKey:[...bP]}))},[c,t]);const u=o.isPending||n!==null&&c==="pending",d=!!r||c==="error",f=d?r??((g=l.data)==null?void 0:g.error)??"OpenRouter sign-in failed. Please try again.":null;return{begin:()=>o.mutate(),isPending:u,isSuccess:c==="connected",isError:d,errorMessage:f}}const Fnt="https://openrouter.ai/keys";function znt(){const[e,t]=x.useState(""),n=Pnt(),s=Lnt();return n.isSuccess||s.isSuccess?a.jsx(Bnt,{}):a.jsxs("div",{className:"space-y-4","data-testid":"openrouter-gateway",children:[a.jsx("div",{className:"space-y-2",children:s.isPending?a.jsx(vd,{message:"Finish signing in to OpenRouter in the new tab…"}):s.isError?a.jsx(QT,{message:s.errorMessage??"OpenRouter sign-in failed.",onRetry:s.begin}):a.jsxs(a.Fragment,{children:[a.jsx(ge,{size:"sm",className:"w-full",onClick:s.begin,children:"Connect OpenRouter"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Creates a scoped key automatically — no copy-paste."})]})}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"bg-border h-px flex-1"}),a.jsx("span",{className:"text-muted-foreground text-2xs tracking-wide uppercase",children:"or"}),a.jsx("span",{className:"bg-border h-px flex-1"})]}),n.isPending?a.jsx(vd,{message:"Checking your OpenRouter key…"}):a.jsxs("form",{className:"space-y-2",onSubmit:i=>{i.preventDefault(),n.store(e)},children:[a.jsx(Rt,{htmlFor:"openrouter-key",className:"text-xs",children:"OpenRouter key"}),a.jsx(il,{id:"openrouter-key",value:e,onChange:i=>t(i.target.value),placeholder:"sk-or-…",autoComplete:"off",spellCheck:!1}),n.isError&&a.jsx("p",{className:"text-destructive text-xs",role:"alert",children:n.errorMessage}),a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("a",{href:Fnt,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:["Get an OpenRouter key ",a.jsx(fa,{className:"size-3"})]}),a.jsx(ge,{type:"submit",size:"sm",variant:"outline",disabled:e.trim().length===0,children:"Save key"})]})]})]})}function Bnt(){var t,n;const e=Int(!0);return a.jsxs("div",{className:"space-y-2","data-testid":"openrouter-models",children:[a.jsx("div",{className:"flex items-center gap-2 text-xs text-emerald-500",children:"Connected to OpenRouter"}),a.jsx(nP,{provider:"openrouter",modelId:"openrouter"}),a.jsx(Rt,{htmlFor:"openrouter-model",className:"text-xs",children:"Model"}),a.jsxs("select",{id:"openrouter-model",className:"border-input bg-background focus-visible:ring-ring w-full rounded-md border px-3 py-2 text-sm focus-visible:ring-1 focus-visible:outline-none",disabled:e.isPending||(((t=e.data)==null?void 0:t.length)??0)===0,children:[e.isPending&&a.jsx("option",{children:"Loading models…"}),(n=e.data)==null?void 0:n.map(s=>a.jsx("option",{value:s.id,children:s.name},s.id))]})]})}function $nt(){const[e,t]=x.useState("openai"),[n,s]=x.useState(""),[r,i]=x.useState(""),o=Tnt();return o.isPending?a.jsx(vd,{message:"Saving your provider key…"}):o.isSuccess?a.jsx(XT,{}):a.jsxs("form",{className:"space-y-3","data-testid":"direct-provider",onSubmit:l=>{l.preventDefault(),o.connect({providerId:e,key:n,baseURL:r})},children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:"direct-provider-id",className:"text-xs",children:"Provider"}),a.jsx(sn,{id:"direct-provider-id",value:e,onChange:l=>t(l.target.value),placeholder:"openai",autoComplete:"off",spellCheck:!1})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:"direct-provider-key",className:"text-xs",children:"API key"}),a.jsx(il,{id:"direct-provider-key",value:n,onChange:l=>s(l.target.value),placeholder:"sk-…",autoComplete:"off",spellCheck:!1})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs(Rt,{htmlFor:"direct-provider-base-url",className:"text-xs",children:["Base URL ",a.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),a.jsx(sn,{id:"direct-provider-base-url",value:r,onChange:l=>i(l.target.value),placeholder:"https://api.example.com/v1",autoComplete:"off",spellCheck:!1})]}),o.isError&&a.jsx("p",{className:"text-destructive text-xs",role:"alert",children:o.errorMessage}),a.jsx(ge,{type:"submit",size:"sm",className:"w-full",disabled:n.trim().length===0||e.trim().length===0,children:"Connect provider"})]})}function Hnt(){const[e,t]=x.useState("local");return a.jsxs(CT,{value:e,onValueChange:n=>t(n),"data-testid":"opencode-provider-picker",children:[a.jsxs(Mb,{className:"w-full",children:[a.jsx(_c,{value:"local",className:"flex-1",children:"Local"}),a.jsx(_c,{value:"gateway",className:"flex-1",children:"Gateway"}),a.jsx(_c,{value:"direct",className:"flex-1",children:"Direct"})]}),a.jsx(Vp,{value:"local",className:"mt-3",children:a.jsx(Ont,{active:e==="local"})}),a.jsx(Vp,{value:"gateway",className:"mt-3",children:a.jsx(znt,{})}),a.jsx(Vp,{value:"direct",className:"mt-3",children:a.jsx($nt,{})})]})}function Unt({type:e,connect:t}){return t.kind==="provider-picker"?a.jsx(Hnt,{}):t.kind==="login"?a.jsx(wnt,{type:e}):null}const SP=e=>a.jsx(Unt,{...e});function Vnt({runtime:e,model:t,onChangeRuntime:n,canSelect:s}){const{data:r}=im(),{data:i}=VT(),[o,l]=x.useState({open:!1}),c=Object.keys((r==null?void 0:r.capabilities)??{}),u=c.filter(y=>xD(i,y)),d=c.filter(y=>!xD(i,y)),f=r!==void 0&&Object.values(Kle).some(y=>y.setup&&!c.includes(y.type)),m=s&&!!n&&(c.length>1||d.length>0||f),g=a.jsx(vD,{runtime:e,model:t,iconClassName:"size-(--size-icon-xs)"});return s?m?a.jsxs(a.Fragment,{children:[a.jsxs(i4,{children:[a.jsx(a4,{asChild:!0,children:a.jsx("button",{className:"hover:text-foreground transition-colors duration-150",children:a.jsx(vD,{runtime:e,model:t,iconClassName:"size-(--size-icon-xs)"})})}),a.jsxs(o4,{side:"top",align:"start",className:"w-56",children:[a.jsx(l4,{children:"Runtime"}),a.jsx(Nie,{value:e,onValueChange:y=>n==null?void 0:n(y),children:u.map(y=>{const b=Ka(y);return a.jsx(jie,{value:y,icon:b.icon,children:b.label},y)})}),d.map(y=>{const b=Ka(y);return a.jsx(F3,{icon:b.icon,description:"Connect",onSelect:()=>l({open:!0,runtime:y}),children:b.label},y)}),f&&a.jsxs(a.Fragment,{children:[a.jsx(g8e,{}),a.jsx(F3,{icon:Cs,onSelect:()=>l({open:!0}),children:"Add a runtime"})]})]})]}),a.jsx(Xle,{runtime:o.runtime,open:o.open,onOpenChange:y=>l(b=>({...b,open:y})),renderConnect:SP,onRuntimeReady:y=>{n==null||n(y),l({open:!1})}})]}):g:a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:g}),a.jsx(yn,{side:"top",children:"The runtime is set when a session starts and can't be changed afterward."})]})}function qnt({open:e,onOpenChange:t,onConfirm:n}){return a.jsx(Sl,{open:e,onOpenChange:t,children:a.jsxs(ko,{children:[a.jsxs(wl,{children:[a.jsxs(Co,{className:"flex items-center gap-2",children:[a.jsx(Jg,{className:"size-4 text-red-500"}),"Turn on Auto mode",a.jsx(zt,{variant:"secondary",className:"text-[10px] tracking-wide uppercase",children:"Preview"})]}),a.jsx(Eo,{children:"The agent runs on its own and only checks with you before risky actions — like deleting files or running unfamiliar commands. You can switch back anytime."})]}),a.jsxs(kl,{children:[a.jsx(_o,{children:"Cancel"}),a.jsx(To,{onClick:n,children:"Turn on Auto mode"})]})]})})}const ED={none:{label:"None",description:"No reasoning"},minimal:{label:"Minimal",description:"Near-zero thinking"},low:{label:"Low",description:"Fastest responses"},medium:{label:"Medium",description:"Moderate thinking"},high:{label:"High",description:"Deep reasoning"},max:{label:"Max",description:"Maximum thinking"},xhigh:{label:"XHigh",description:"Beyond maximum"}},Gnt={duration:.15,ease:"easeOut"};function Knt(e){return e>=1e6?`${Math.round(e/1e6)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function Wnt(e,t){const n=t.find(r=>r.value===e);if(n)return n.displayName;const s=e.match(/claude-(\w+)-/);return s?s[1].charAt(0).toUpperCase()+s[1].slice(1):e}function Ynt(){return a.jsx("div",{className:"space-y-2","data-testid":"model-cards-skeleton",children:Array.from({length:3}).map((e,t)=>a.jsxs("div",{className:"flex items-center gap-3 rounded-xl p-3",children:[a.jsx(Jt,{className:"size-4 rounded-full"}),a.jsxs("div",{className:"flex-1 space-y-1.5",children:[a.jsx(Jt,{className:"h-3.5 w-24"}),a.jsx(Jt,{className:"h-2.5 w-32"})]}),a.jsx(Jt,{className:"h-5 w-10 rounded-md"})]},t))})}function Znt({onRetry:e}){return a.jsxs("div",{className:"flex flex-col items-center gap-3 py-6 text-center","data-testid":"model-load-error",children:[a.jsx(Hh,{className:"text-muted-foreground size-5"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Failed to load models"}),a.jsxs("button",{onClick:e,className:"text-foreground hover:bg-accent inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs transition-colors",children:[a.jsx(ma,{className:"size-3"}),"Retry"]})]})}function Xnt({model:e,isSelected:t}){return a.jsxs("label",{className:Y("flex w-full cursor-pointer items-center gap-3 rounded-xl border p-3 transition-colors duration-150",t?"bg-secondary border-foreground/15":"border-border hover:border-muted-foreground/30 hover:bg-muted/50 opacity-70"),children:[a.jsx(bv,{value:e.value,className:"shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"text-foreground truncate text-sm font-medium",children:e.displayName}),a.jsx("div",{className:"text-muted-foreground truncate text-[11px] leading-tight",children:e.description})]}),e.contextWindow&&a.jsx(zt,{variant:"secondary",className:"shrink-0 text-[10px]",children:Knt(e.contextWindow)})]})}function Qnt({effortLevels:e,effort:t,onChangeEffort:n}){return a.jsxs("div",{children:[a.jsx("div",{className:"text-muted-foreground mb-2 text-[11px] font-medium tracking-wide uppercase",children:"Effort"}),a.jsxs("div",{className:"flex flex-wrap gap-1.5",role:"radiogroup","aria-label":"Effort level",children:[a.jsx(QU,{label:"Default",isSelected:t===null,onClick:()=>n(null)}),e.map(s=>a.jsx(QU,{label:ED[s].label,description:ED[s].description,isSelected:t===s,onClick:()=>n(s)},s))]})]})}function QU({label:e,description:t,isSelected:n,onClick:s}){const r=a.jsx("button",{role:"radio","aria-checked":n,onClick:s,className:Y("rounded-md px-2.5 py-1 text-xs font-medium transition-colors duration-150",n?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground"),children:e});return t?a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:r}),a.jsx(yn,{side:"top",className:"text-xs",children:t})]}):r}function Jnt({supportsFastMode:e,fastMode:t,onChangeFastMode:n}){return e?a.jsxs("div",{children:[a.jsx("div",{className:"text-muted-foreground mb-2 text-[11px] font-medium tracking-wide uppercase",children:"Mode"}),a.jsx("div",{className:"flex gap-1.5",children:a.jsx(est,{label:"Fast",icon:a.jsx(Uc,{className:"size-3"}),isActive:t,onToggle:()=>n(!t)})})]}):null}function est({label:e,icon:t,isActive:n,onToggle:s}){return a.jsxs("button",{role:"switch","aria-checked":n,onClick:s,className:Y("inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs font-medium transition-colors duration-150",n?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground"),children:[t,e]})}function tst({model:e,onChangeModel:t,effort:n,onChangeEffort:s,fastMode:r,onChangeFastMode:i,disabled:o,sessionId:l,runtime:c}){const{data:u,isLoading:d,isError:f,refetch:m}=aI({sessionId:l,runtime:c??void 0}),g=u??[],y=g.find(T=>T.value===e),b=(y==null?void 0:y.supportsEffort)&&y.supportedEffortLevels&&y.supportedEffortLevels.length>0,S=(y==null?void 0:y.supportsFastMode)??!1,w=n?ED[n].label:null,C=a.jsxs("button",{disabled:o,className:"hover:text-foreground inline-flex items-center gap-1 transition-colors duration-150 disabled:cursor-not-allowed disabled:opacity-40","data-testid":"model-config-trigger",children:[a.jsx(Ad,{className:"size-(--size-icon-xs)"}),a.jsx("span",{children:Wnt(e,g)}),w&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-muted-foreground text-[11px]",children:"·"}),a.jsx(zt,{variant:"secondary",className:"px-1.5 py-0 text-[10px]",children:w})]}),r&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-muted-foreground text-[11px]",children:"·"}),a.jsxs(zt,{variant:"secondary",className:"px-1.5 py-0 text-[10px]",children:[a.jsx(Uc,{className:"mr-0.5 inline size-2.5"}),"Fast"]})]})]});return o?a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx("span",{className:"inline-flex",children:C})}),a.jsx(yn,{side:"top",children:"Send a message first"})]}):a.jsxs(t4,{children:[a.jsx(n4,{asChild:!0,children:C}),a.jsxs(s4,{side:"top",align:"start",className:"w-80 p-3","data-testid":"model-config-popover",children:[a.jsx(r4,{children:"Model"}),d&&a.jsx(Ynt,{}),f&&a.jsx(Znt,{onRetry:()=>m()}),!d&&!f&&a.jsx(JI,{value:e,onValueChange:t,className:"grid-cols-1 gap-1.5","aria-label":"Model selection","data-testid":"model-card-list",children:g.map(T=>a.jsx(Xnt,{model:T,isSelected:T.value===e},T.value))}),a.jsx(Ue,{children:!d&&!f&&(b||S)&&a.jsxs(te.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:Gnt,children:[a.jsx(av,{className:"my-3"}),a.jsx("div",{className:"text-muted-foreground mb-3 text-[11px] font-medium tracking-wide uppercase",children:"Configuration"}),a.jsxs("div",{className:"space-y-3",children:[b&&a.jsx(Qnt,{effortLevels:y.supportedEffortLevels,effort:n,onChangeEffort:s}),S&&a.jsx(Jnt,{supportsFastMode:(y==null?void 0:y.supportsFastMode)??!1,fastMode:r,onChangeFastMode:i})]})]},"config")})]})]})}function qA(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function nst({cacheReadTokens:e,cacheCreationTokens:t,contextTokens:n}){const s=n??e+t,r=Math.max(0,s-e-t),i=s>0?Math.round(e/s*100):0,o=i>=70?"text-emerald-500":i>=30?"":"text-amber-500";return a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsxs("span",{className:Y("inline-flex cursor-default items-center gap-1",o),"aria-label":"Prompt cache hit rate",children:[a.jsx(Uc,{className:"size-(--size-icon-xs)"}),a.jsxs("span",{children:[i,"%"]})]})}),a.jsx(yn,{side:"top",className:"max-w-56",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("div",{className:"text-xs font-medium",children:"Prompt Cache"}),a.jsxs("div",{className:"space-y-0.5 text-[10px]",children:[a.jsxs("div",{className:"flex justify-between gap-3",children:[a.jsx("span",{className:"text-muted-foreground",children:"Cache hits"}),a.jsx("span",{children:qA(e)})]}),a.jsxs("div",{className:"flex justify-between gap-3",children:[a.jsx("span",{className:"text-muted-foreground",children:"Cache writes"}),a.jsx("span",{children:qA(t)})]}),n!=null&&n>0&&a.jsxs("div",{className:"flex justify-between gap-3",children:[a.jsx("span",{className:"text-muted-foreground",children:"Uncached"}),a.jsx("span",{children:qA(r)})]})]})]})})]})}function GA(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function sst({percent:e,contextUsage:t}){const n=t?Math.round(t.percentage):e,s=n>=95?"text-red-500":n>=80?"text-amber-500":"",r=a.jsxs("span",{className:Y("inline-flex items-center gap-1",s),children:[a.jsx(uMe,{className:"size-(--size-icon-xs)"}),a.jsxs("span",{children:[n,"%"]})]});if(!t)return r;const i=t.categories.filter(o=>o.tokens>0).sort((o,l)=>l.tokens-o.tokens);return a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx("span",{className:"inline-flex cursor-default","aria-label":"Context window usage",children:r})}),a.jsx(yn,{side:"top",className:"max-w-64",children:a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("div",{className:"text-xs font-medium",children:[GA(t.totalTokens)," / ",GA(t.maxTokens)," tokens"]}),i.length>0&&a.jsx("div",{className:"space-y-0.5",children:i.map(o=>a.jsxs("div",{className:"flex items-center justify-between gap-3 text-[10px]",children:[a.jsxs("span",{className:"flex items-center gap-1 truncate",children:[a.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full",style:{backgroundColor:o.color}}),o.name]}),a.jsx("span",{className:"text-muted-foreground shrink-0",children:GA(o.tokens)})]},o.name))})]})})]})}function JU(e){return e.kind==="subscription"&&e.utilization!=null||e.costUsd!=null}function rst({usage:e}){if(e.kind==="subscription"&&e.utilization!=null){const s=Math.round(e.utilization*100),r=e.state==="exhausted",i=e.state==="warning"||s>=80,o=r?"text-red-500":i?"text-amber-500":"",l=e.resetsAt?new Date(e.resetsAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):null;return a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsxs("span",{className:Y("inline-flex cursor-default items-center gap-1",o),"aria-label":"Subscription usage",children:[a.jsx(tne,{className:"size-(--size-icon-xs)"}),a.jsxs("span",{children:[s,"%"]})]})}),a.jsx(yn,{side:"top",className:"max-w-56",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("div",{className:"text-xs font-medium",children:"Subscription Usage"}),a.jsxs("div",{className:"space-y-0.5 text-[10px]",children:[a.jsxs("div",{className:"flex justify-between gap-3",children:[a.jsx("span",{className:"text-muted-foreground",children:"Utilization"}),a.jsxs("span",{children:[s,"%"]})]}),e.windowLabel&&a.jsxs("div",{className:"flex justify-between gap-3",children:[a.jsx("span",{className:"text-muted-foreground",children:"Window"}),a.jsx("span",{children:e.windowLabel})]}),l&&a.jsxs("div",{className:"flex justify-between gap-3",children:[a.jsx("span",{className:"text-muted-foreground",children:"Resets at"}),a.jsx("span",{children:l})]}),e.costUsd!=null&&a.jsxs("div",{className:"flex justify-between gap-3",children:[a.jsx("span",{className:"text-muted-foreground",children:"Session cost"}),a.jsxs("span",{children:["$",e.costUsd.toFixed(2)]})]}),e.detail&&a.jsx("div",{className:"text-amber-500",children:e.detail}),r&&a.jsx("div",{className:"text-red-500",children:"Rate limit reached"})]})]})})]})}if(e.costUsd==null)return null;const n=`$${e.costUsd.toFixed(2)}`;return e.detail?a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsxs("span",{className:"inline-flex cursor-default items-center gap-1","aria-label":"Session cost",children:[a.jsx(XM,{className:"size-(--size-icon-xs)"}),a.jsx("span",{children:n})]})}),a.jsx(yn,{side:"top",className:"max-w-56",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("div",{className:"text-xs font-medium",children:"Session Cost"}),a.jsx("div",{className:"text-muted-foreground text-[10px]",children:e.detail})]})})]}):a.jsxs("span",{className:"inline-flex items-center gap-1","aria-label":"Session cost",children:[a.jsx(XM,{className:"size-(--size-icon-xs)"}),a.jsx("span",{children:n})]})}function ist({enabled:e,onToggle:t}){const n=e?yne:NDe;return a.jsx("button",{onClick:t,className:"hover:text-foreground inline-flex items-center gap-1 transition-colors duration-150","aria-label":e?"Mute notification sound":"Unmute notification sound",title:e?"Sound on — click to mute":"Sound off — click to unmute",children:a.jsx(n,{className:"size-(--size-icon-xs)"})})}function ast({enabled:e,onToggle:t}){const n=e?dDe:cDe;return a.jsxs(ZI,{openDelay:300,children:[a.jsx(XI,{asChild:!0,children:a.jsx("button",{onClick:t,className:"hover:text-foreground inline-flex items-center gap-1 transition-colors duration-150","aria-label":e?"Disable background refresh":"Enable background refresh",children:a.jsx(n,{className:"size-(--size-icon-xs)"})})}),a.jsxs(QI,{side:"top",align:"center",className:"w-64 p-3",children:[a.jsxs("p",{className:"text-sm font-medium",children:["Background refresh ",e?"on":"off"]}),a.jsx("p",{className:"text-muted-foreground mt-1.5 text-xs leading-relaxed",children:e?"Messages are checked for updates periodically, even when no one is typing. Useful if agents run in the background. Turn off to reduce network usage.":"Messages only update while someone is actively responding. Turn on if you have agents running unattended and want to see their progress."})]})]})}const ost={connecting:{color:"bg-amber-500",label:"Connecting",icon:Uw,tasks:!0},connected:{color:"bg-emerald-500",label:"Connected",icon:Uw,tasks:!1},reconnecting:{color:"bg-amber-500",label:"Reconnecting",icon:Uw,tasks:!0},disconnected:{color:"bg-red-500",label:"Connection lost",icon:ZE,tasks:!1}};function lst({connectionState:e,failedAttempts:t}){const n=e!=="connected",s=ost[e],r=s.icon,i=t&&e==="reconnecting"?`Reconnecting (${t}/${kf.DISCONNECTED_THRESHOLD})`:s.label;return a.jsx(Wi.Item,{itemKey:"connection",visible:n,children:a.jsxs(ZI,{openDelay:200,children:[a.jsx(XI,{asChild:!0,children:a.jsxs("span",{className:"flex cursor-default items-center gap-1.5 text-xs",role:"status",children:[a.jsx("span",{className:Y("size-1.5 rounded-full",s.color,s.tasks&&"animate-tasks")}),a.jsx("span",{className:"text-muted-foreground",children:i})]})}),a.jsx(QI,{side:"top",align:"center",className:"w-72 p-3",children:a.jsxs("div",{className:"flex items-start gap-2.5",children:[a.jsx(r,{className:Y("mt-0.5 size-4 shrink-0",e==="disconnected"?"text-red-500":"text-amber-500")}),a.jsxs("div",{className:"min-w-0 space-y-1.5",children:[a.jsx("p",{className:"text-sm font-medium",children:i}),a.jsx(cst,{connectionState:e})]})]})})]})})}function cst({connectionState:e}){const t="text-muted-foreground text-xs leading-relaxed";return e==="connecting"?a.jsx("p",{className:t,children:"Opening the live connection to this session. New messages and updates appear once it's open."}):e==="reconnecting"?a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("p",{className:t,children:"The live connection dropped and is reconnecting automatically. Incoming messages and updates are paused — nothing is lost; anything missed replays when it reconnects."}),a.jsx("p",{className:Y(t,"text-muted-foreground/70"),children:"No action needed."})]}):a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("p",{className:t,children:"Could not re-establish the live connection after several attempts. New messages and updates will not appear until it's restored."}),a.jsx("p",{className:Y(t,"text-muted-foreground/70"),children:"Try refreshing the page. If the issue persists, check that the DorkOS server is running."})]})}function ust({subagents:e}){return a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsxs("span",{className:"inline-flex items-center gap-1",children:[a.jsx(e0,{className:"size-(--size-icon-xs)"}),a.jsxs("span",{children:[e.length," agent",e.length!==1?"s":""]})]})}),a.jsx(yn,{side:"top",className:"max-w-64",children:a.jsx("ul",{className:"space-y-1",children:e.map(t=>a.jsxs("li",{children:[a.jsx("span",{className:"font-medium",children:t.name}),t.model&&a.jsxs("span",{className:"text-muted-foreground ml-1 text-[10px]",children:["(",t.model,")"]}),a.jsx("p",{className:"text-muted-foreground line-clamp-1 text-[10px] leading-tight",children:t.description})]},t.name))})})]})}const dst={session:"Session Info",controls:"Controls"},Yb=[{key:"cwd",label:"Directory",description:"Current working directory",group:"session",icon:$c,defaultVisible:!0},{key:"git",label:"Git Status",description:"Branch name and change count",group:"session",icon:$p,defaultVisible:!0},{key:"runtime",label:"Runtime",description:"Agent runtime for this session",group:"session",icon:Zte,defaultVisible:!0},{key:"model",label:"Model",description:"Selected AI model",group:"session",icon:Ad,defaultVisible:!0},{key:"cache",label:"Cache",description:"Prompt cache hit rate",group:"session",icon:Uc,defaultVisible:!0},{key:"context",label:"Context Usage",description:"Context window utilization",group:"session",icon:wAe,defaultVisible:!0},{key:"usage",label:"Usage & cost",description:"Subscription utilization or session cost",group:"session",icon:tne,defaultVisible:!0},{key:"permission",label:"Permission Mode",description:"Agent permission level selector",group:"controls",icon:Hc,defaultVisible:!0},{key:"sound",label:"Sound",description:"Notification sound toggle",group:"controls",icon:yne,defaultVisible:!0},{key:"polling",label:"Refresh",description:"Background polling for updates",group:"controls",icon:ma,defaultVisible:!0}];function Hce(e){const t=e.charAt(0).toUpperCase()+e.slice(1),n=`showStatusBar${t}`,s=`setShowStatusBar${t}`,r=we(o=>o[n]),i=we(o=>o[s]);return[r,i]}function e_(){const e=we.getState();for(const t of Yb){const s=`setShowStatusBar${t.key.charAt(0).toUpperCase()+t.key.slice(1)}`,r=e[s];r(t.defaultVisible)}}function fst(){return["session","controls"].map(t=>({group:t,label:dst[t],items:Yb.filter(n=>n.group===t)})).filter(t=>t.items.length>0)}function hst({itemKey:e}){const t=Yb.find(i=>i.key===e),[n,s]=Hce(e);if(!t)return null;const r=t.icon;return a.jsx(cs,{label:a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(r,{className:"text-muted-foreground size-3.5 shrink-0","aria-hidden":!0}),t.label]}),description:t.description,children:a.jsx(sr,{checked:n,onCheckedChange:s,"aria-label":`Toggle ${t.label}`})})}function Uce(){const e=fst();return a.jsxs("div",{className:"flex flex-col gap-4","aria-label":"Status bar configuration",children:[e.map(t=>a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("p",{className:"text-muted-foreground px-1 text-xs font-medium tracking-wide uppercase",children:t.label}),a.jsx(vr,{children:a.jsx(dr,{children:t.items.map(n=>a.jsx(hst,{itemKey:n.key},n.key))})})]},t.group)),a.jsx(ge,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground h-auto justify-start px-1 py-1 text-xs",onClick:e_,children:"Reset to defaults"})]})}Uce.displayName="StatusBarConfigureContent";function Vce({children:e,open:t,onOpenChange:n}){return a.jsxs(t4,{open:t,onOpenChange:n,children:[a.jsx(n4,{asChild:!0,children:e}),a.jsxs(s4,{side:"top",align:"end",className:"w-72 p-3","aria-label":"Status bar configuration",children:[a.jsx(r4,{children:"Configure Status Bar"}),a.jsx(Uce,{})]})]})}Vce.displayName="StatusBarConfigurePopover";function qce(e,t){const[n,s,r]=e.split(".").map(Number),[i,o,l]=t.split(".").map(Number);return n!==i?n>i:s!==o?s>o:r>l}function mst(e,t){const[n,s]=e.split(".").map(Number),[r,i]=t.split(".").map(Number);return n!==r||s!==i}function pst({item:e}){const[t,n]=Hce(e.key);return a.jsx(Zi,{label:e.label,description:e.description,checked:t,onCheckedChange:n})}function gst(){return a.jsxs("div",{className:"space-y-4",children:[a.jsx(l0,{actions:a.jsx("button",{onClick:e_,className:"text-muted-foreground hover:text-foreground text-xs transition-colors duration-150",children:"Reset to defaults"}),children:"Status Bar"}),a.jsx(vr,{children:a.jsx(dr,{children:Yb.map(e=>a.jsx(pst,{item:e},e.key))})})]})}function xst(){const e=VT(),{data:t}=im();return a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-muted-foreground text-sm",children:"DorkOS speaks three agent runtimes: connect any of them, each ready or one click away. Run frontier models in the cloud, or your own models locally, private and free."}),a.jsx(Zle,{requirements:e.data,registeredTypes:t?Object.keys(t.capabilities):void 0,onRecheck:()=>void e.refetch(),isRechecking:e.isFetching,renderConnect:SP})]})}function yst(){const e=je(),{data:t,isLoading:n}=st({queryKey:["config"],queryFn:()=>e.getConfig(),staleTime:3e4});return a.jsx("div",{className:"space-y-3",children:n?a.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((s,r)=>a.jsxs("div",{className:"flex items-center justify-between py-1",children:[a.jsx("div",{className:"bg-muted animate-tasks h-4 w-24 rounded"}),a.jsx("div",{className:"bg-muted animate-tasks h-4 w-16 rounded"})]},r))}):t?a.jsxs("div",{className:"space-y-1",children:[t.isDevMode?a.jsxs("div",{className:"-mx-1 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 dark:border-amber-800 dark:bg-amber-950/30",children:[a.jsx("span",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:"Development Build"}),a.jsx("p",{className:"mt-0.5 text-xs text-amber-700 dark:text-amber-300",children:"Running from source — version checks disabled"})]}):a.jsxs(a.Fragment,{children:[a.jsx(nc,{label:"Version",value:t.version}),t.latestVersion&&qce(t.latestVersion,t.version)&&a.jsxs("div",{className:"-mx-1 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 dark:border-amber-800 dark:bg-amber-950/30",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("span",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:["Update available: v",t.latestVersion]})}),a.jsxs("p",{className:"mt-0.5 text-xs text-amber-700 dark:text-amber-300",children:["Run"," ",a.jsx("code",{className:"rounded bg-amber-100 px-1 py-0.5 font-mono text-[10px] dark:bg-amber-900/50",children:"npm update -g dorkos"})," ","to update"]})]})]}),a.jsx(nc,{label:"Port",value:String(t.port)}),a.jsx(nc,{label:"Uptime",value:vst(t.uptime)}),a.jsx(nc,{label:"API URL",value:`http://localhost:${t.port}`,mono:!0}),a.jsx(nc,{label:"MCP Endpoint",value:`http://localhost:${t.port}/mcp`,mono:!0}),a.jsx(nc,{label:"Working Directory",value:t.workingDirectory,mono:!0,truncate:!0}),a.jsx(nc,{label:"Data Directory",value:t.dorkHome,mono:!0,truncate:!0}),a.jsx(nc,{label:"Boundary",value:t.boundary,mono:!0,truncate:!0}),a.jsx(nc,{label:"Node.js",value:t.nodeVersion})]}):null})}function nc({label:e,value:t,mono:n,truncate:s,muted:r}){const[i,o]=wg();return a.jsxs("button",{type:"button",onClick:()=>o(t),className:"hover:bg-muted/50 active:bg-muted/70 -mx-1 flex w-full items-center justify-between gap-4 rounded px-1 py-1 transition-colors duration-100",children:[a.jsx("span",{className:"text-muted-foreground shrink-0 text-sm",children:e}),i?a.jsx("span",{className:"text-muted-foreground text-xs",children:"Copied"}):a.jsx("span",{className:Y("text-right text-sm",n&&"font-mono",s&&"max-w-48 min-w-0 truncate",r&&"text-muted-foreground"),dir:s?"rtl":void 0,title:t,children:t})]})}function vst(e){const t=Math.floor(e/3600),n=Math.floor(e%3600/60),s=Math.floor(e%60),r=[];return t>0&&r.push(`${t}h`),n>0&&r.push(`${n}m`),r.push(`${s}s`),r.join(" ")}const bst={relayTools:!0,meshTools:!0,adapterTools:!0,tasksTools:!0};function Sst(){const e=je(),t=et(),{data:n}=st({queryKey:["config"],queryFn:()=>e.getConfig(),staleTime:3e4}),s={...bst,...n==null?void 0:n.agentContext},r=Bt({mutationFn:o=>e.updateConfig({agentContext:{...s,...o}}),onSuccess:()=>{t.invalidateQueries({queryKey:["config"]})}}),i=x.useCallback(o=>{r.mutate(o)},[r]);return{config:s,updateConfig:i}}const xy={core:["ping","get_server_info","get_session_count","get_agent","control_ui","get_ui_state"],tasks:["tasks_list","tasks_create","tasks_update","tasks_delete","tasks_get_run_history"],relay:["relay_send","relay_inbox","relay_list_endpoints","relay_register_endpoint","relay_send_and_wait","relay_send_async","relay_unregister_endpoint","relay_get_trace","relay_get_metrics"],mesh:["mesh_discover","mesh_register","mesh_list","mesh_deny","mesh_unregister","mesh_status","mesh_inspect","mesh_query_topology"],adapter:["relay_list_adapters","relay_enable_adapter","relay_disable_adapter","relay_reload_adapters","binding_list","binding_create","binding_delete","binding_list_sessions","relay_notify_user"]},eV={tasks:"tasksTools",relay:"relayTools",mesh:"meshTools",adapter:"adapterTools"},wst=[{key:"tasks",label:"Tasks (Scheduling)",description:"Create and manage scheduled agent runs",tools:xy.tasks},{key:"relay",label:"Relay (Messaging)",description:"Send messages, check inbox, register endpoints",tools:xy.relay,implicitNote:"Includes trace tools (relay_get_trace, relay_get_metrics)"},{key:"mesh",label:"Mesh (Discovery)",description:"Discover, register, and query agents",tools:xy.mesh},{key:"adapter",label:"Relay Adapters",description:"Manage Telegram, Slack, webhooks, and bindings",tools:xy.adapter,implicitNote:"Includes binding tools (binding_list, binding_create, binding_delete)"}];function Gce({tools:e,implicitNote:t}){return a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx(zt,{variant:"outline",className:"text-muted-foreground shrink-0 cursor-default text-xs font-normal",children:e.length})}),a.jsxs(yn,{side:"top",className:"max-w-xs",children:[a.jsx("p",{className:"font-mono text-xs",children:e.join(", ")}),t&&a.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:t})]})]})}function kst({group:e,enabled:t,available:n,initError:s,overrideCount:r,onToggle:i,expandContent:o}){const[l,c]=x.useState(!1),u=!!o,d=a.jsxs("div",{className:"flex items-center gap-2",children:[s&&a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx(fr,{className:"size-3.5 shrink-0 text-amber-500"})}),a.jsx(yn,{side:"top",className:"max-w-xs",children:a.jsx("p",{className:"text-xs",children:s})})]}),!n&&!s&&a.jsx(zt,{variant:"secondary",className:"text-xs",children:"Disabled"}),r>0&&a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsxs("span",{className:"text-muted-foreground shrink-0 text-xs",children:[r," ",r===1?"override":"overrides"]})}),a.jsx(yn,{side:"top",children:a.jsxs("p",{className:"text-xs",children:[r," ",r===1?"agent has":"agents have"," a per-agent override for this group"]})})]}),a.jsx(Gce,{tools:e.tools,implicitNote:e.implicitNote}),a.jsx(sr,{checked:t,onCheckedChange:m=>i(e.key,m),disabled:!n,"aria-label":`Toggle ${e.label}`}),u&&a.jsx(ll,{asChild:!0,children:a.jsx("button",{className:"text-muted-foreground hover:text-foreground rounded-sm p-0.5 transition-colors duration-150","aria-label":`${l?"Collapse":"Expand"} ${e.label} settings`,children:a.jsx(Hs,{className:Y("size-3.5 transition-transform duration-150",!l&&"-rotate-90")})})})]}),f=a.jsx(cs,{label:e.label,description:e.description,children:d});return u?a.jsxs(ol,{open:l,onOpenChange:c,children:[f,a.jsx(cl,{children:a.jsx("div",{className:"border-border mt-2 space-y-2 border-t pt-2",children:o})})]}):f}function Cst({scheduler:e,onUpdate:t}){return a.jsxs(a.Fragment,{children:[a.jsx(cs,{label:"Concurrent runs",description:"Maximum parallel task runs",children:a.jsx(sn,{type:"number",min:1,max:10,value:e.maxConcurrentRuns,onChange:n=>{const s=parseInt(n.target.value,10);s>=1&&s<=10&&t({maxConcurrentRuns:s})},className:"w-20"})}),a.jsx(cs,{label:"Timezone",description:"IANA timezone for cron schedules",children:a.jsxs(On,{value:e.timezone??"system",onValueChange:n=>t({timezone:n==="system"?null:n}),children:[a.jsx(_n,{className:"w-48",children:a.jsx(In,{})}),a.jsxs(Nn,{children:[a.jsx(mt,{value:"system",children:"System default"}),a.jsx(mt,{value:"UTC",children:"UTC"}),a.jsx(mt,{value:"America/New_York",children:"America/New_York"}),a.jsx(mt,{value:"America/Chicago",children:"America/Chicago"}),a.jsx(mt,{value:"America/Denver",children:"America/Denver"}),a.jsx(mt,{value:"America/Los_Angeles",children:"America/Los_Angeles"}),a.jsx(mt,{value:"Europe/London",children:"Europe/London"}),a.jsx(mt,{value:"Europe/Berlin",children:"Europe/Berlin"}),a.jsx(mt,{value:"Europe/Paris",children:"Europe/Paris"}),a.jsx(mt,{value:"Asia/Tokyo",children:"Asia/Tokyo"}),a.jsx(mt,{value:"Asia/Shanghai",children:"Asia/Shanghai"}),a.jsx(mt,{value:"Asia/Kolkata",children:"Asia/Kolkata"}),a.jsx(mt,{value:"Australia/Sydney",children:"Australia/Sydney"})]})]})}),a.jsx(cs,{label:"Run history",description:"Completed runs to keep",children:a.jsx(sn,{type:"number",min:1,max:1e4,value:e.retentionCount,onChange:n=>{const s=parseInt(n.target.value,10);s>=1&&t({retentionCount:s})},className:"w-24"})})]})}function Est(){return a.jsxs("div",{className:"flex gap-3 rounded-md border border-amber-500/20 bg-amber-500/10 p-3",children:[a.jsx(fr,{className:"mt-0.5 size-4 shrink-0 text-amber-500"}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-xs font-medium",children:"Do not configure this for agents running inside DorkOS."}),a.jsxs("p",{className:"text-muted-foreground text-xs",children:["DorkOS already provides tools to its managed agents internally. Adding DorkOS as an external MCP server to those same agents causes duplicate tool names — the Anthropic API will return HTTP 400 “Tool names must be unique” and all tool calls will fail. External MCP access is for agents running ",a.jsx("strong",{children:"outside"})," of DorkOS (standalone Claude Code, Cursor, Windsurf)."]})]})]})}function Tst({endpoint:e}){return a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm font-medium",children:"Endpoint"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"MCP server URL for external agents"})]}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("code",{className:"bg-muted min-w-0 flex-1 truncate rounded-md px-3 py-2 font-mono text-xs",children:e}),a.jsx(vv,{value:e})]})]})}function _st({rateLimit:e,onUpdate:t}){return a.jsxs("div",{className:"space-y-3",children:[a.jsx(Zi,{label:"Rate limiting",description:"Limit external MCP requests per time window",checked:e.enabled,onCheckedChange:n=>t({enabled:n}),ariaLabel:"Toggle rate limiting"}),e.enabled&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("label",{htmlFor:"mcp-max-requests",className:"text-muted-foreground text-xs",children:"Max requests"}),a.jsx(sn,{id:"mcp-max-requests",type:"number",min:1,max:1e3,value:e.maxPerWindow,onChange:n=>{const s=parseInt(n.target.value,10);s>=1&&s<=1e3&&t({maxPerWindow:s})},className:"w-20"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("label",{htmlFor:"mcp-window-secs",className:"text-muted-foreground text-xs",children:"Window (sec)"}),a.jsx(sn,{id:"mcp-window-secs",type:"number",min:1,max:3600,value:e.windowSecs,onChange:n=>{const s=parseInt(n.target.value,10);s>=1&&s<=3600&&t({windowSecs:s})},className:"w-20"})]})]}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Rate limit changes take effect after server restart."})]})]})}function Nst(e,t){const n=t?`Bearer ${t}`:"Bearer dork_mcp_YOUR_API_KEY";return{claudeCode:JSON.stringify({mcpServers:{"dorkos-external":{type:"http",url:e,headers:{Authorization:n}}}},null,2),claudeCodeCli:`claude mcp add-json dorkos-external '${JSON.stringify({type:"http",url:e,headers:{Authorization:n}})}'`,cursor:JSON.stringify({mcpServers:{"dorkos-external":{url:e,headers:{Authorization:n}}}},null,2),windsurf:JSON.stringify({mcpServers:{"dorkos-external":{serverUrl:e,headers:{Authorization:n}}}},null,2)}}function jst({endpoint:e,apiKey:t}){const[n,s]=x.useState(!1),[r,i]=x.useState("claude-code"),o=Nst(e,t),l=r==="claude-code"?o.claudeCode:r==="cursor"?o.cursor:o.windsurf;return a.jsxs(ol,{open:n,onOpenChange:s,children:[a.jsxs(ll,{className:"flex w-full items-center justify-between text-sm font-medium",children:[a.jsx("span",{children:"Setup Instructions"}),a.jsx(Hs,{className:Y("text-muted-foreground size-3.5 transition-transform duration-150",!n&&"-rotate-90")})]}),a.jsx(cl,{children:a.jsxs("div",{className:"mt-3 space-y-3",children:[a.jsx("div",{className:"bg-muted flex gap-0.5 rounded-md p-0.5",children:["claude-code","cursor","windsurf"].map(c=>a.jsx("button",{onClick:()=>i(c),className:Y("flex-1 rounded-sm px-3 py-1.5 text-xs font-medium transition-colors",r===c?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:c==="claude-code"?"Claude Code":c==="cursor"?"Cursor":"Windsurf"},c))}),a.jsxs("div",{className:"relative",children:[a.jsx("pre",{className:"bg-muted overflow-x-auto rounded-md p-3 text-xs leading-relaxed",children:l}),a.jsx("div",{className:"absolute top-2 right-2",children:a.jsx(vv,{value:l})})]}),r==="claude-code"&&a.jsxs("div",{className:"relative",children:[a.jsx("p",{className:"text-muted-foreground mb-1 text-xs",children:"Or add via CLI:"}),a.jsx("pre",{className:"bg-muted overflow-x-auto rounded-md p-3 text-xs leading-relaxed",children:o.claudeCodeCli}),a.jsx("div",{className:"absolute right-2 bottom-2",children:a.jsx(vv,{value:o.claudeCodeCli})})]})]})})]})}function Ast({mcp:e}){const t=je(),n=et(),[s,r]=x.useState(!1),i=x.useCallback(()=>n.invalidateQueries({queryKey:["config"]}),[n]),o=x.useCallback(async u=>{await t.updateConfig({mcp:{enabled:u,rateLimit:e.rateLimit}}),await i()},[t,e.rateLimit,i]),l=x.useCallback(async u=>{await t.updateConfig({mcp:{enabled:e.enabled,rateLimit:{...e.rateLimit,...u}}}),await i()},[t,e.enabled,e.rateLimit,i]),c=e.enabled?e.authConfigured?a.jsx(zt,{variant:"outline",className:"border-green-500/50 text-xs text-green-600",children:"Enabled"}):a.jsx(zt,{variant:"outline",className:"border-amber-500/50 text-xs text-amber-600",children:"No auth"}):a.jsx(zt,{variant:"secondary",className:"text-xs",children:"Disabled"});return a.jsx(vr,{children:a.jsxs(ol,{open:s,onOpenChange:r,children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm font-medium",children:"External MCP Server"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Add the DorkOS MCP to agents outside of DorkOS"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[c,a.jsx(sr,{checked:e.enabled,onCheckedChange:o,"aria-label":"Toggle external MCP access"}),a.jsx(ll,{asChild:!0,children:a.jsx("button",{className:"text-muted-foreground hover:text-foreground rounded-sm p-0.5 transition-colors duration-150","aria-label":`${s?"Collapse":"Expand"} external MCP server settings`,children:a.jsx(Hs,{className:Y("size-3.5 transition-transform duration-150",!s&&"-rotate-90")})})})]})]}),a.jsx(cl,{children:a.jsxs(dr,{className:"border-t",children:[a.jsx(Est,{}),a.jsx(Tst,{endpoint:e.endpoint}),a.jsx(Rst,{authSource:e.authSource}),a.jsx(_st,{rateLimit:e.rateLimit,onUpdate:l}),a.jsx(jst,{endpoint:e.endpoint,apiKey:null})]})})]})})}function Rst({authSource:e}){return e==="env"?a.jsx(cs,{label:"Authentication",description:"Gated by the MCP_API_KEY environment variable",children:a.jsx(zt,{variant:"outline",children:"Environment variable"})}):a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(rne,{className:"text-muted-foreground size-3.5"}),a.jsx("p",{className:"text-sm font-medium",children:"Authentication"})]}),a.jsxs("p",{className:"text-muted-foreground text-xs",children:["MCP clients authenticate with a personal API key. Create or revoke keys in Settings → Security → API keys, then pass it as a ",a.jsx("code",{className:"font-mono",children:"Bearer"})," token."]})]})}function Mst({onClick:e}){return a.jsx("button",{onClick:e,className:"text-muted-foreground hover:text-foreground text-xs transition-colors duration-150",children:"Reset to defaults"})}function Dst(){var S,w,C,T;const e=am(),t=Ud(),{config:n,updateConfig:s}=Sst(),r=je(),i=et(),{section:o}=t0();N5e(o);const{data:l}=st({queryKey:["config"],queryFn:()=>r.getConfig(),staleTime:3e4}),{data:c}=ba(),u=l==null?void 0:l.scheduler,d=x.useMemo(()=>{const E=(c==null?void 0:c.agents)??[],j={tasks:0,relay:0,mesh:0,adapter:0};for(const _ of E){const N=_.enabledToolGroups;N&&(N.tasks!==void 0&&j.tasks++,N.relay!==void 0&&j.relay++,N.mesh!==void 0&&j.mesh++,N.adapter!==void 0&&j.adapter++)}return j},[c]),f={tasks:t,relay:e,mesh:!0,adapter:e},m={tasks:(S=l==null?void 0:l.tasks)==null?void 0:S.initError,relay:(w=l==null?void 0:l.relay)==null?void 0:w.initError,mesh:(C=l==null?void 0:l.mesh)==null?void 0:C.initError,adapter:(T=l==null?void 0:l.relay)==null?void 0:T.initError},g=x.useCallback((E,j)=>{s({[eV[E]]:j})},[s]),y=x.useCallback(async E=>{const j=u??{maxConcurrentRuns:1,timezone:null,retentionCount:100};await r.updateConfig({scheduler:{...j,...E}}),await i.invalidateQueries({queryKey:["config"]})},[r,i,u]),b=x.useCallback(async()=>{await r.updateConfig({agentContext:{relayTools:!0,meshTools:!0,adapterTools:!0,tasksTools:!0}}),i.invalidateQueries({queryKey:["config"]})},[r,i]);return a.jsxs("div",{className:"space-y-4",children:[a.jsx(l0,{actions:a.jsx(Mst,{onClick:b}),children:"Tools"}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Control which MCP tool groups are available to agents. These are global defaults — individual agents can override them in their Tools tab."}),a.jsx(vr,{children:a.jsxs(dr,{children:[a.jsx(cs,{label:"Core Tools",description:"Server info, agent identity, UI control",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Gce,{tools:xy.core}),a.jsx("span",{className:"text-muted-foreground text-xs",children:"Always enabled"})]})}),wst.map(E=>a.jsx(kst,{group:E,enabled:n[eV[E.key]],available:f[E.key],initError:m[E.key],overrideCount:d[E.key],onToggle:g,expandContent:E.key==="tasks"&&u?a.jsx(Cst,{scheduler:u,onUpdate:y}):void 0},E.key))]})}),(l==null?void 0:l.mcp)&&a.jsx("div",{"data-section":"external-mcp",children:a.jsx(Ast,{mcp:l.mcp})})]})}function Ost(e){const t=rce[e.status.state]??"bg-muted-foreground";return Y("size-2 shrink-0 rounded-full",t)}function Ist({instance:e,manifest:t,bindingCount:n,onToggle:s,onConfigure:r}){const i=e.label||e.status.displayName||e.id,o=Ost(e),{inbound:l,outbound:c}=e.status.messageCount,u=l+c;return a.jsxs("div",{className:"flex items-center gap-3 py-2",children:[a.jsx("div",{className:o,"aria-hidden":!0}),a.jsx(vP,{iconId:t.iconId,adapterType:t.type,size:16,className:"text-muted-foreground shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"truncate text-sm font-medium",children:i}),a.jsxs("p",{className:"text-muted-foreground/60 text-xs",children:[n!==void 0&&n>0?`${n} agent${n!==1?"s":""}`:"No agents",u>0&&` · ${u} messages`]})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[a.jsx(sr,{checked:e.enabled,onCheckedChange:s,"aria-label":`${i} enabled`}),a.jsx(ge,{variant:"ghost",size:"sm",onClick:r,className:"size-7 p-0","aria-label":`Configure ${i}`,children:a.jsx(qa,{className:"size-3.5"})})]})]})}const tV={maxConcurrent:3,defaultTimeoutMs:3e5},Yx={maxConcurrent:{min:1,max:20},defaultTimeoutMs:{min:1e4,max:36e5}};function Pst(){const e=am(),{data:t=[],isLoading:n}=PQe(e),{mutate:s}=ece(),{data:r=[]}=Gb(),[i,o]=x.useState({open:!1}),{data:l=[]}=S0(e),{mutate:c}=tce(),u=x.useMemo(()=>l.find(P=>P.manifest.category==="internal"&&P.manifest.type==="claude-code"),[l]),d=u==null?void 0:u.instances[0],f=d==null?void 0:d.config,m=Number((f==null?void 0:f.maxConcurrent)??tV.maxConcurrent),g=Number((f==null?void 0:f.defaultTimeoutMs)??tV.defaultTimeoutMs),y={maxConcurrent:m,defaultTimeoutMs:g},[b,S]=x.useState(null),[w,C]=x.useState(null),T=b??String(m),E=w??String(g);function j(P,$){const q=Number($),K=Yx[P],B=!Number.isNaN(q)&&q>=K.min&&q<=K.max,V=q!==y[P];d&&B&&V&&c({id:d.id,config:{[P]:q}}),P==="maxConcurrent"&&S(null),P==="defaultTimeoutMs"&&C(null)}const _=x.useMemo(()=>{const P=new Map;for(const $ of r)P.set($.adapterId,(P.get($.adapterId)??0)+1);return P},[r]);if(!e)return a.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed py-8",children:[a.jsx(Gk,{className:"text-muted-foreground/40 size-8"}),a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-muted-foreground text-sm",children:"Relay is disabled"}),a.jsx("p",{className:"text-muted-foreground/60 text-xs",children:"Enable the Relay message bus to manage channels here"})]})]});if(n)return a.jsx("div",{className:"space-y-2",children:[1,2,3].map(P=>a.jsx(Jt,{className:"h-10 w-full rounded-md"},P))});const N=t.flatMap(P=>P.instances.map($=>({instance:$,manifest:P.manifest}))),R=t.filter(P=>!P.manifest.deprecated&&(P.instances.length===0||P.manifest.multiInstance)),O=P=>{o({open:!0,manifest:P})},M=(P,$)=>{o({open:!0,manifest:P,instanceId:$})},L=i.instanceId?t.flatMap(P=>P.instances).find(P=>P.id===i.instanceId):void 0;return a.jsxs(a.Fragment,{children:[N.length>0?a.jsx(vr,{children:a.jsx(dr,{children:N.map(({instance:P,manifest:$})=>a.jsx(Ist,{instance:P,manifest:$,bindingCount:_.get(P.id)??0,onToggle:q=>s({id:P.id,enabled:q}),onConfigure:()=>M($,P.id)},P.id))})}):a.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed py-8",children:[a.jsx(Gk,{className:"text-muted-foreground/40 size-8"}),a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-muted-foreground text-sm",children:"No channels configured"}),a.jsx("p",{className:"text-muted-foreground/60 text-xs",children:"Add a channel below to connect agents to external platforms"})]})]}),R.length>0&&a.jsxs("section",{children:[a.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-semibold tracking-wide uppercase",children:"Available Channels"}),a.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))"},children:R.map(P=>a.jsx(Lce,{manifest:P.manifest,onAdd:()=>O(P.manifest)},P.manifest.type))})]}),d&&a.jsxs("section",{children:[a.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-semibold tracking-wide uppercase",children:"Session Delivery"}),a.jsx(vr,{children:a.jsxs(dr,{children:[a.jsx(Zi,{label:"Deliver to Claude Code",description:"Start a Claude Code agent session automatically when a relay message arrives",checked:d.enabled,onCheckedChange:P=>s({id:d.id,enabled:P})}),a.jsx(cs,{label:"Max concurrent sessions",description:"Maximum relay-delivered sessions running at the same time",children:a.jsx(sn,{type:"number",min:Yx.maxConcurrent.min,max:Yx.maxConcurrent.max,value:T,onChange:P=>S(P.target.value),onBlur:P=>j("maxConcurrent",P.target.value),className:"w-24"})}),a.jsx(cs,{label:"Default timeout",description:"Timeout budget per relay-delivered session, in milliseconds",children:a.jsx(sn,{type:"number",min:Yx.defaultTimeoutMs.min,max:Yx.defaultTimeoutMs.max,value:E,onChange:P=>C(P.target.value),onBlur:P=>j("defaultTimeoutMs",P.target.value),className:"w-32"})})]})})]}),i.manifest&&a.jsx(Fce,{open:i.open,onOpenChange:P=>{P||o({open:!1})},manifest:i.manifest,existingInstance:L,existingAdapterIds:t.flatMap(P=>P.instances.map($=>$.id))})]})}function Lst(){var c;const e=je(),t=et(),{data:n,isLoading:s}=st({queryKey:["mesh","agents"],queryFn:()=>e.listMeshAgents(),staleTime:3e4}),{data:r}=st({queryKey:["config"],queryFn:()=>e.getConfig(),staleTime:3e4}),i=(n==null?void 0:n.agents)??[],o=((c=r==null?void 0:r.agents)==null?void 0:c.defaultAgent)??"dorkbot";async function l(u){await e.setDefaultAgent(u),await t.invalidateQueries({queryKey:["config"]})}return s?a.jsx(Jt,{className:"h-10 w-full rounded-md"}):i.length===0?a.jsx("div",{className:"rounded-xl border border-dashed py-8 text-center",children:a.jsx("p",{className:"text-muted-foreground text-sm",children:"No agents found"})}):a.jsx(vr,{children:a.jsx(dr,{children:a.jsx(cs,{label:"Default agent",description:"The primary agent used for new sessions and post-onboarding",children:a.jsxs(On,{value:o,onValueChange:l,children:[a.jsx(_n,{className:"w-44","data-testid":"default-agent-select",children:a.jsx(In,{})}),a.jsx(Nn,{children:i.map(u=>a.jsx(mt,{value:u.name,children:nn(u)},u.id))})]})})})})}function Fst(){return x.useSyncExternalStore(s1e,c9,c9)}function zst(){return x.useSyncExternalStore(i1e,u9,u9)}async function Bst(e){const t=await e.json().catch(()=>({})),n=e.headers.get("X-Retry-After")??e.headers.get("Retry-After"),s=n?Number(n):void 0;return{message:t.message||e.statusText||`Request failed (${e.status})`,status:e.status,code:t.code,retryAfter:Number.isFinite(s)?s:void 0}}function $st(e){async function t(n,s,r){let i;try{i=await fetch(`${e}/auth${s}`,{method:n,headers:{"Content-Type":"application/json"},credentials:"include",body:r===void 0?void 0:JSON.stringify(r)})}catch{return{data:null,error:{message:"Network error — could not reach the server.",status:0}}}return i.ok?{data:await i.json().catch(()=>null),error:null}:{data:null,error:await Bst(i)}}return{signIn:{email:n=>t("POST","/sign-in/email",n)},signUp:{email:n=>t("POST","/sign-up/email",n)},signOut:()=>t("POST","/sign-out"),getSession:()=>t("GET","/get-session"),apiKey:{create:n=>t("POST","/api-key/create",n),list:()=>t("GET","/api-key/list"),delete:n=>t("POST","/api-key/delete",n)}}}const Hst=$st(dZ()),Ust=x.createContext(Hst);function om(){return x.useContext(Ust)}const wP=["auth","session"];function Vst(){const e=om();return st({queryKey:wP,queryFn:async()=>{const{data:t}=await e.getSession();return t??null},staleTime:3e4})}function qst(){const e=om(),t=et(),[n,s]=x.useState(!1),[r,i]=x.useState(null);return{run:x.useCallback(async(l,c)=>{s(!0),i(null);const{error:u}=await e.signIn.email({email:l,password:c});return s(!1),u?(i(u),{ok:!1,error:u}):($O(!1),await t.invalidateQueries(),{ok:!0})},[e,t]),isPending:n,error:r,reset:()=>i(null)}}function Gst(){const e=om(),t=et(),[n,s]=x.useState(!1),[r,i]=x.useState(null);return{run:x.useCallback(async(l,c,u)=>{s(!0),i(null);const{error:d}=await e.signUp.email({email:l,password:c,name:u});return s(!1),d?(i(d),{ok:!1,error:d}):($O(!1),await t.invalidateQueries({queryKey:wP}),{ok:!0})},[e,t]),isPending:n,error:r,reset:()=>i(null)}}function Kst(){const e=om(),t=et(),[n,s]=x.useState(!1),[r,i]=x.useState(null);return{run:x.useCallback(async()=>{s(!0),i(null);const{error:l}=await e.signOut();return s(!1),l?(i(l),{ok:!1,error:l}):(t.setQueryData(wP,null),await t.invalidateQueries(),{ok:!0})},[e,t]),isPending:n,error:r,reset:()=>i(null)}}function Wst(){const{data:e}=Vst();return(e==null?void 0:e.user)??null}function Yst({onSignedIn:e}){const t=x.useId(),n=x.useId(),[s,r]=x.useState(""),[i,o]=x.useState(""),{run:l,isPending:c,error:u}=qst();async function d(g){if(g.preventDefault(),c)return;(await l(s,i)).ok&&(e==null||e())}const m=(u==null?void 0:u.status)===429||(u==null?void 0:u.retryAfter)!==void 0?`Too many attempts. Try again${u!=null&&u.retryAfter?` in ${u.retryAfter}s`:" in a little while"}.`:u==null?void 0:u.message;return a.jsx("div",{className:"flex min-h-screen w-full items-center justify-center p-6",children:a.jsxs("div",{className:"bg-card shadow-elevated w-full max-w-sm rounded-xl border p-6",children:[a.jsxs("div",{className:"mb-6 flex flex-col items-center text-center",children:[a.jsx("div",{className:"bg-muted mb-3 flex size-11 items-center justify-center rounded-full",children:a.jsx(pb,{className:"size-5"})}),a.jsx("h1",{className:"text-lg font-semibold",children:"Sign in to DorkOS"}),a.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"This instance requires a login to continue."})]}),a.jsxs("form",{onSubmit:d,className:"space-y-4",children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:t,children:"Email"}),a.jsx(sn,{id:t,type:"email",autoComplete:"username",value:s,onChange:g=>r(g.target.value),required:!0,autoFocus:!0})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:n,children:"Password"}),a.jsx(il,{id:n,autoComplete:"current-password",value:i,onChange:g=>o(g.target.value),required:!0})]}),m&&a.jsx("p",{className:"text-sm text-red-500",role:"alert",children:m}),a.jsx(ge,{type:"submit",className:"w-full",disabled:c,children:c?"Signing in…":"Sign in"})]})]})})}function Zst({children:e}){return Fst()?a.jsx(Yst,{}):a.jsx(a.Fragment,{children:e})}const nV=8;function Kce({title:e,description:t,submitLabel:n="Create account",onCreated:s,onOwnerExists:r,onCancel:i}){const o=x.useId(),l=x.useId(),c=x.useId(),[u,d]=x.useState(""),[f,m]=x.useState(""),[g,y]=x.useState(""),[b,S]=x.useState(null),{run:w,isPending:C,error:T}=Gst();async function E(N){if(N.preventDefault(),C)return;if(S(null),f.length<nV){S(`Password must be at least ${nV} characters.`);return}if(f!==g){S("Passwords do not match.");return}const R=await w(u,f,u);if(R.ok){await s();return}R.error.code==="REGISTRATION_CLOSED"&&r&&await r()}const j=(T==null?void 0:T.code)==="REGISTRATION_CLOSED"&&!r,_=b??(j?"An owner account already exists for this instance. Sign in instead.":T==null?void 0:T.message);return a.jsxs("div",{className:"space-y-5",children:[(e||t)&&a.jsxs("div",{className:"space-y-1",children:[e&&a.jsx("h2",{className:"text-base font-semibold",children:e}),t&&a.jsx("p",{className:"text-muted-foreground text-sm",children:t})]}),a.jsxs("form",{onSubmit:E,className:"space-y-4",children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:o,children:"Email"}),a.jsx(sn,{id:o,type:"email",autoComplete:"username",value:u,onChange:N=>d(N.target.value),required:!0,autoFocus:!0}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"A local identifier only — it is never verified and no email is ever sent."})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:l,children:"Password"}),a.jsx(il,{id:l,autoComplete:"new-password",value:f,onChange:N=>m(N.target.value),required:!0})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:c,children:"Confirm password"}),a.jsx(il,{id:c,autoComplete:"new-password",value:g,onChange:N=>y(N.target.value),required:!0})]}),_&&a.jsx("p",{className:"text-sm text-red-500",role:"alert",children:_}),a.jsxs("div",{className:"flex gap-2",children:[i&&a.jsx(ge,{type:"button",variant:"ghost",onClick:i,disabled:C,children:"Cancel"}),a.jsx(ge,{type:"submit",className:"flex-1",disabled:C,children:C?"Creating…":n})]})]})]})}const t_={all:["config"],current:()=>[...t_.all,"current"]};function Wce(){const e=je();return st({queryKey:t_.current(),queryFn:()=>e.getConfig(),staleTime:3e4})}function Yce(){const e=je(),t=et();return Bt({mutationFn:n=>e.updateConfig(n),onSuccess:()=>{t.invalidateQueries({queryKey:t_.current()})}})}function Xst(){const e=zst(),t=je(),n=et(),s=x.useCallback(async()=>{await t.updateConfig({auth:{enabled:!0}}),await n.invalidateQueries({queryKey:t_.current()});const r=e==null?void 0:e.onComplete;QN(),r==null||r()},[t,n,e]);return e?a.jsx(qc,{open:!0,onOpenChange:r=>!r&&QN(),children:a.jsxs(Cl,{children:[a.jsxs(El,{children:[a.jsx(Tl,{children:"Create an owner account"}),a.jsx(_l,{children:e.message})]}),a.jsx(Kce,{submitLabel:"Create account & continue",onCreated:s,onOwnerExists:s,onCancel:QN})]})}):null}const kP=["auth","api-keys"];function Qst(){const e=om();return st({queryKey:kP,queryFn:async()=>{const{data:t}=await e.apiKey.list();return t??[]},staleTime:3e4})}function Jst(){const e=om(),t=et(),[n,s]=x.useState(!1),[r,i]=x.useState(null);return{run:x.useCallback(async(l,c)=>{s(!0),i(null);const{data:u,error:d}=await e.apiKey.create({name:l.trim()||void 0,expiresIn:c??null});return s(!1),d||!u?(i(d??{message:"Failed to create API key.",status:0}),null):(await t.invalidateQueries({queryKey:kP}),u)},[e,t]),isPending:n,error:r,reset:()=>i(null)}}function ert(){const e=om(),t=et(),[n,s]=x.useState(null),[r,i]=x.useState(null);return{run:x.useCallback(async l=>{s(l),i(null);const{error:c}=await e.apiKey.delete({keyId:l});return s(null),c?(i(c),!1):(await t.invalidateQueries({queryKey:kP}),!0)},[e,t]),pendingId:n,error:r,reset:()=>i(null)}}const sV=[{label:"Never",value:"never",seconds:null},{label:"7 days",value:"7d",seconds:3600*24*7},{label:"30 days",value:"30d",seconds:3600*24*30},{label:"90 days",value:"90d",seconds:3600*24*90}];function trt(){const e=x.useId(),{data:t,isLoading:n}=Qst(),s=Jst(),r=ert(),[i,o]=x.useState(""),[l,c]=x.useState("never"),[u,d]=x.useState(null);async function f(){var y;const m=((y=sV.find(b=>b.value===l))==null?void 0:y.seconds)??null,g=await s.run(i,m);g&&(d(g),o(""),c("never"))}return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(rne,{className:"text-muted-foreground size-4"}),a.jsx("p",{className:"text-sm font-medium",children:"API keys"})]}),a.jsxs("p",{className:"text-muted-foreground text-xs",children:["Personal keys for MCP clients, scripts, and agents. Pass a key as a"," ",a.jsx("code",{className:"font-mono",children:"Bearer"})," token. The value is shown once at creation."]})]}),u?a.jsx(nrt,{created:u,onDone:()=>d(null)}):a.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[a.jsxs("div",{className:"min-w-40 flex-1 space-y-1.5",children:[a.jsx(Rt,{htmlFor:e,children:"Name"}),a.jsx(sn,{id:e,placeholder:"e.g. laptop-cli",value:i,onChange:m=>o(m.target.value)})]}),a.jsxs("div",{className:"w-32 space-y-1.5",children:[a.jsx(Rt,{children:"Expires"}),a.jsxs(On,{value:l,onValueChange:c,children:[a.jsx(_n,{children:a.jsx(In,{})}),a.jsx(Nn,{children:sV.map(m=>a.jsx(mt,{value:m.value,children:m.label},m.value))})]})]}),a.jsx(ge,{onClick:f,disabled:s.isPending,children:s.isPending?"Creating…":"Create key"})]}),s.error&&a.jsx("p",{className:"text-xs text-red-500",role:"alert",children:s.error.message}),a.jsx("div",{className:"space-y-1.5",children:n?a.jsx(Jt,{className:"h-9 w-full"}):t&&t.length>0?t.map(m=>a.jsx(srt,{apiKey:m,revoking:r.pendingId===m.id,onRevoke:()=>r.run(m.id)},m.id)):a.jsx("p",{className:"text-muted-foreground text-xs",children:"No API keys yet."})}),r.error&&a.jsx("p",{className:"text-xs text-red-500",role:"alert",children:r.error.message})]})}function nrt({created:e,onDone:t}){const[n,s]=wg();return a.jsxs("div",{className:"border-primary/40 bg-primary/5 space-y-3 rounded-lg border p-3",children:[a.jsx("p",{className:"text-sm font-medium",children:"Copy your key now — it won't be shown again"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("code",{className:"bg-muted min-w-0 flex-1 truncate rounded-md px-3 py-2 font-mono text-xs",children:e.key}),a.jsx("button",{className:"text-muted-foreground hover:text-foreground shrink-0 rounded-sm p-1.5 transition-colors",onClick:()=>s(e.key),"aria-label":"Copy API key",children:n?a.jsx(Lt,{className:"size-4 text-green-500"}):a.jsx(Vh,{className:"size-4"})})]}),a.jsx(ge,{variant:"outline",size:"sm",onClick:t,children:"Done"})]})}function srt({apiKey:e,revoking:t,onRevoke:n}){const s=e.name||"Unnamed key",r=e.start?`${e.start}…`:e.prefix||"";return a.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border px-3 py-2",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"truncate text-sm font-medium",children:s}),a.jsxs("p",{className:"text-muted-foreground font-mono text-xs",children:[r,e.expiresAt?` · expires ${new Date(e.expiresAt).toLocaleDateString()}`:" · no expiry"]})]}),a.jsxs(Sl,{children:[a.jsx(mT,{asChild:!0,children:a.jsx(ge,{variant:"ghost",size:"sm",disabled:t,"aria-label":`Revoke ${s}`,children:a.jsx(wo,{className:"size-3.5"})})}),a.jsxs(ko,{children:[a.jsxs(wl,{children:[a.jsx(Co,{children:"Revoke this API key?"}),a.jsxs(Eo,{children:["Anything using “",s,"” will immediately lose access. This cannot be undone."]})]}),a.jsxs(kl,{children:[a.jsx(_o,{children:"Cancel"}),a.jsx(To,{onClick:n,children:"Revoke"})]})]})]})]})}function rrt(){var u;const{data:e}=Wce(),t=Yce(),n=Wst(),s=Kst(),r=((u=e==null?void 0:e.auth)==null?void 0:u.enabled)??!1,[i,o]=x.useState(!1);function l(d){d?o(!0):t.mutate({auth:{enabled:!1}})}async function c(){await t.mutateAsync({auth:{enabled:!0}}),o(!1)}return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(xb,{className:"text-muted-foreground size-4"}),a.jsx("h2",{className:"text-sm font-semibold",children:"Security"})]}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Require an owner login to reach this instance. Exposing DorkOS beyond localhost (a tunnel or non-loopback bind) always requires login."})]}),a.jsx(vr,{children:a.jsxs(dr,{children:[a.jsx(cs,{label:"Require login",description:r?"An owner account is required to use this instance.":"Off — this instance starts with no login (localhost only).",children:a.jsx(sr,{checked:r,onCheckedChange:l,"aria-label":"Require login"})}),r&&a.jsx(cs,{label:"Signed in",description:(n==null?void 0:n.email)??"Owner account",children:a.jsxs(ge,{variant:"outline",size:"sm",onClick:()=>s.run(),disabled:s.isPending,children:[a.jsx(SMe,{className:"mr-1.5 size-3.5"}),s.isPending?"Signing out…":"Sign out"]})})]})}),r&&a.jsx(vr,{children:a.jsx(dr,{children:a.jsx(trt,{})})}),a.jsx(qc,{open:i,onOpenChange:o,children:a.jsxs(Cl,{children:[a.jsxs(El,{children:[a.jsx(Tl,{children:"Create an owner account"}),a.jsx(_l,{children:"This becomes the login for this instance. Email is a local identifier only."})]}),a.jsx(Kce,{submitLabel:"Create account & require login",onCreated:c,onOwnerExists:c,onCancel:()=>o(!1)})]})})]})}function irt(){return a.jsx(rrt,{})}const art=2500,ort=new Set(["linked","denied","expired","unlinked"]),fw=["cloud","status"];function lrt(e){return e instanceof Error&&e.message?e.message:"Could not reach the DorkOS cloud. Try again shortly."}function crt(){const e=je(),t=et(),n=st({queryKey:fw,queryFn:()=>e.getCloudStatus(),staleTime:3e4}),[s,r]=x.useState(null),[i,o]=x.useState(null),[l,c]=x.useState(!1),[u,d]=x.useState(!1),[f,m]=x.useState(null),g=x.useRef(null),y=x.useRef(!0),b=x.useRef(!1),S=x.useCallback(()=>{g.current&&(clearInterval(g.current),g.current=null)},[]),w=x.useCallback(async()=>{try{const _=await e.getCloudLinkStatus();if(!y.current)return;o(_),ort.has(_.state)&&(S(),_.state==="linked"&&await t.invalidateQueries({queryKey:fw}))}catch{}},[e,t,S]),C=x.useCallback(()=>{S(),g.current=setInterval(()=>void w(),art)},[w,S]);x.useEffect(()=>(y.current=!0,e.getCloudLinkStatus().then(_=>{y.current&&!b.current&&o(_)}).catch(()=>{}),()=>{y.current=!1,S()}),[e,S]);const T=x.useCallback(async()=>{m(null),c(!0),b.current=!0;try{const _=await e.startCloudLink();r(_),o({state:"pending"}),C()}catch(_){b.current=!1,m(lrt(_))}finally{c(!1)}},[e,C]),E=x.useCallback(async()=>{d(!0);try{await e.unlinkCloud(),S(),r(null),b.current=!1,o({state:"idle"}),t.setQueryData(fw,{linked:!1,accountLabel:null,lastHeartbeatAt:null}),await t.invalidateQueries({queryKey:fw})}catch{}finally{d(!1)}},[e,t,S]);return{view:x.useMemo(()=>{var N,R,O;const _=i==null?void 0:i.state;return s&&_==="pending"?{kind:"pending",userCode:s.userCode,verificationUri:s.verificationUri,expiresAt:s.expiresAt}:_==="denied"?{kind:"denied"}:_==="expired"?{kind:"expired"}:_==="unlinked"?{kind:"revoked"}:_==="linked"?{kind:"linked",accountLabel:(i==null?void 0:i.accountLabel)??((N=n.data)==null?void 0:N.accountLabel)??null,lastHeartbeatAt:(i==null?void 0:i.lastHeartbeatAt)??((R=n.data)==null?void 0:R.lastHeartbeatAt)??null}:n.isLoading&&!n.data?{kind:"loading"}:(O=n.data)!=null&&O.linked?{kind:"linked",accountLabel:n.data.accountLabel,lastHeartbeatAt:n.data.lastHeartbeatAt}:{kind:"idle"}},[s,i,n.data,n.isLoading]),start:T,unlink:E,starting:l,unlinking:u,startError:f}}function urt(){const{view:e,start:t,unlink:n,starting:s,unlinking:r,startError:i}=crt();return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(qE,{className:"text-muted-foreground size-4"}),a.jsx("h2",{className:"text-sm font-semibold",children:"DorkOS account"})]}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Link this instance to a DorkOS account to reach it from dorkos.ai and receive updates. Linking is independent of local login."})]}),a.jsx(vr,{children:a.jsx(dr,{children:a.jsx(drt,{view:e,start:t,unlink:n,starting:s,unlinking:r,startError:i})})})]})}function drt({view:e,start:t,unlink:n,starting:s,unlinking:r,startError:i}){switch(e.kind){case"loading":return a.jsx(Jt,{className:"h-9 w-40"});case"idle":return a.jsx(frt,{start:t,starting:s,startError:i});case"pending":return a.jsx(hrt,{view:e});case"linked":return a.jsx(mrt,{view:e,unlink:n,unlinking:r});case"expired":return a.jsx(KA,{title:"Your code expired",description:"The link code timed out before it was approved. Generate a new one to try again.",actionLabel:"Generate a new code",onAction:t,pending:s});case"denied":return a.jsx(KA,{title:"Link request denied",description:"The request was rejected on dorkos.ai. Start again if that wasn't intentional.",actionLabel:"Try again",onAction:t,pending:s});case"revoked":return a.jsx(KA,{title:"This instance was unlinked",description:"DorkOS revoked this instance's access. Link again to reconnect it to your account.",actionLabel:"Link again",onAction:t,pending:s})}}function frt({start:e,starting:t,startError:n}){return a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:"text-muted-foreground text-sm",children:"This instance is not linked to a DorkOS account."}),a.jsxs(ge,{onClick:()=>void e(),disabled:t,children:[t?a.jsx(Sn,{className:"mr-1.5 size-4 animate-spin"}):a.jsx(qE,{className:"mr-1.5 size-4"}),t?"Starting…":"Link this instance"]}),n&&a.jsx("p",{className:"text-sm text-red-500",role:"alert",children:n})]})}function hrt({view:e}){const[t,n]=wg();return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-sm font-medium",children:"Enter this code to link"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("code",{className:"bg-muted flex-1 rounded-md px-4 py-3 text-center font-mono text-2xl font-semibold tracking-[0.2em] tabular-nums",children:e.userCode}),a.jsx("button",{className:"text-muted-foreground hover:text-foreground shrink-0 rounded-sm p-2 transition-colors",onClick:()=>n(e.userCode),"aria-label":"Copy code",children:t?a.jsx(Lt,{className:"size-4 text-green-500"}):a.jsx(Vh,{className:"size-4"})})]})]}),a.jsxs(ge,{variant:"outline",onClick:()=>prt(e.verificationUri,e.userCode),children:[a.jsx(fa,{className:"mr-1.5 size-4"}),"Open dorkos.ai/activate"]}),a.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-sm",role:"status",children:[a.jsx(Sn,{className:"size-4 animate-spin"}),a.jsx("span",{children:"Waiting for you to approve on dorkos.ai…"})]})]})}function mrt({view:e,unlink:t,unlinking:n}){return a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{className:"flex items-start justify-between gap-3",children:[a.jsxs("div",{className:"min-w-0 space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"size-2 shrink-0 rounded-full bg-green-500","aria-hidden":!0}),a.jsx("p",{className:"text-sm font-medium",children:"Linked"})]}),e.accountLabel?a.jsx("p",{className:"text-foreground truncate text-sm",children:e.accountLabel}):a.jsx("p",{className:"text-muted-foreground text-sm",children:"Syncing account…"}),e.lastHeartbeatAt&&a.jsxs("p",{className:"text-muted-foreground text-xs",children:["Last synced ",ii(e.lastHeartbeatAt).toLowerCase()]})]}),a.jsxs(Sl,{children:[a.jsx(mT,{asChild:!0,children:a.jsxs(ge,{variant:"outline",size:"sm",disabled:n,"aria-label":"Unlink this instance",children:[a.jsx(kDe,{className:Y("mr-1.5 size-3.5",n&&"animate-pulse")}),n?"Unlinking…":"Unlink"]})}),a.jsxs(ko,{children:[a.jsxs(wl,{children:[a.jsx(Co,{children:"Unlink this instance?"}),a.jsx(Eo,{children:"This instance will stop reporting to your DorkOS account. You can link it again at any time."})]}),a.jsxs(kl,{children:[a.jsx(_o,{children:"Cancel"}),a.jsx(To,{onClick:()=>void t(),children:"Unlink"})]})]})]})]})})}function KA({title:e,description:t,actionLabel:n,onAction:s,pending:r}){return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(fr,{className:"mt-0.5 size-4 shrink-0 text-amber-500"}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm font-medium",children:e}),a.jsx("p",{className:"text-muted-foreground text-sm",children:t})]})]}),a.jsxs(ge,{onClick:()=>void s(),disabled:r,children:[r?a.jsx(Sn,{className:"mr-1.5 size-4 animate-spin"}):a.jsx(ma,{className:"mr-1.5 size-4"}),n]})]})}function prt(e,t){try{const n=new URL(e);if(n.protocol!=="https:"&&n.protocol!=="http:")return;n.searchParams.set("code",t),window.open(n.href,"_blank","noopener,noreferrer")}catch{}}function grt(){return a.jsx(urt,{})}function xrt({open:e,onOpenChange:t,onResetComplete:n}){const[s,r]=x.useState(""),[i,o]=x.useState(!1),l=je(),c=s==="reset";async function u(){o(!0);try{await l.resetAllData("reset"),localStorage.clear(),t(!1),n()}catch(f){Ye.error(f instanceof Error?f.message:"Failed to reset data")}finally{o(!1)}}function d(f){f||(r(""),o(!1)),t(f)}return a.jsx(Sl,{open:e,onOpenChange:d,children:a.jsxs(ko,{children:[a.jsxs(wl,{children:[a.jsx(Co,{children:"Reset All Data"}),a.jsx(Eo,{asChild:!0,children:a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{children:"This will permanently delete all DorkOS data, including:"}),a.jsxs("ul",{className:"list-inside list-disc space-y-1 text-sm",children:[a.jsx("li",{children:"All Tasks schedules and run history"}),a.jsx("li",{children:"All Relay configuration and messages"}),a.jsx("li",{children:"All Mesh agent registry data"}),a.jsx("li",{children:"Your config file and preferences"}),a.jsx("li",{children:"All server logs"})]}),a.jsx("p",{children:"The server will restart automatically. Your UI preferences will also be cleared."}),a.jsx("p",{className:"font-semibold",children:"This action cannot be undone."})]})})]}),a.jsx("div",{className:"py-2",children:a.jsx(sn,{placeholder:'Type "reset" to confirm',value:s,onChange:f=>r(f.target.value),"data-testid":"reset-confirm-input"})}),a.jsxs(kl,{children:[a.jsx(_o,{children:"Cancel"}),a.jsx(To,{disabled:!c||i,onClick:u,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:i?"Resetting...":"Reset All Data"})]})]})})}function yrt({open:e,onOpenChange:t,onRestartComplete:n}){const[s,r]=x.useState(!1),i=je();async function o(){r(!0);try{await i.restartServer(),t(!1),n()}catch(l){Ye.error(l instanceof Error?l.message:"Failed to restart server")}finally{r(!1)}}return a.jsx(Sl,{open:e,onOpenChange:t,children:a.jsxs(ko,{children:[a.jsxs(wl,{children:[a.jsx(Co,{children:"Restart Server"}),a.jsx(Eo,{children:"This will restart the DorkOS server. All active sessions will be interrupted."})]}),a.jsxs(kl,{children:[a.jsx(_o,{children:"Cancel"}),a.jsx(To,{disabled:s,onClick:o,children:s?"Restarting...":"Restart Server"})]})]})})}const vrt=["fatal","error","warn","info","debug","trace"];function brt(){const[e,t]=x.useState(!1),[n,s]=x.useState(!1),r=we(m=>m.enableMessagePolling),i=we(m=>m.setEnableMessagePolling),o=we(m=>m.setRestartOverlayOpen),l=je(),c=et(),{data:u}=st({queryKey:["config"],queryFn:()=>l.getConfig(),staleTime:3e4}),d=u==null?void 0:u.logging,f=x.useCallback(async m=>{const g=d??{level:"info",maxLogSizeKb:500,maxLogFiles:14};await l.updateConfig({logging:{...g,...m}}),await c.invalidateQueries({queryKey:["config"]})},[l,c,d]);return a.jsxs("div",{className:"space-y-6",children:[a.jsx("h3",{className:"text-sm font-semibold",children:"Background Updates"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Messages stream in live and stay in sync across windows automatically. This optional setting adds an extra polling fallback for sessions running outside DorkOS."}),a.jsx(vr,{children:a.jsx(dr,{children:a.jsx(Zi,{label:"Background refresh",description:"Poll for updates to sessions running outside DorkOS (e.g. the Claude Code CLI). Enable only if external activity isn't appearing promptly.",checked:r,onCheckedChange:i})})}),d&&a.jsxs(a.Fragment,{children:[a.jsx("h3",{className:"text-sm font-semibold",children:"Logging"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Server log verbosity and rotation. Changes take effect immediately for log level; rotation settings apply on next file rotation."}),a.jsx(vr,{children:a.jsxs(dr,{children:[a.jsx(cs,{label:"Log level",description:"Server log verbosity",children:a.jsxs(On,{value:d.level,onValueChange:m=>f({level:m}),children:[a.jsx(_n,{className:"w-28",children:a.jsx(In,{})}),a.jsx(Nn,{children:vrt.map(m=>a.jsx(mt,{value:m,children:m},m))})]})}),a.jsx(cs,{label:"Max log file size",description:"Size in KB before a log file is rotated",children:a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(sn,{type:"number",min:100,max:10240,value:d.maxLogSizeKb,onChange:m=>{const g=parseInt(m.target.value,10);g>=100&&g<=10240&&f({maxLogSizeKb:g})},className:"w-24"}),a.jsx("span",{className:"text-muted-foreground text-xs",children:"KB"})]})}),a.jsx(cs,{label:"Rotated files kept",description:"Number of old log files to retain (1-30)",children:a.jsx(sn,{type:"number",min:1,max:30,value:d.maxLogFiles,onChange:m=>{const g=parseInt(m.target.value,10);g>=1&&g<=30&&f({maxLogFiles:g})},className:"w-20"})}),(u==null?void 0:u.dorkHome)&&a.jsx(Srt,{dorkHome:u.dorkHome})]})})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(fr,{className:"text-destructive size-4"}),a.jsx("h3",{className:"text-destructive text-sm font-semibold",children:"Danger Zone"})]}),a.jsx(vr,{className:"border-destructive/50",children:a.jsxs(dr,{children:[a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm font-medium",children:"Reset All Data"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Permanently delete all DorkOS data and restart the server."})]}),a.jsx(ge,{variant:"destructive",size:"sm",onClick:()=>t(!0),children:"Reset"})]}),a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm font-medium",children:"Restart Server"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Restart the DorkOS server process. Active sessions will be interrupted."})]}),a.jsx(ge,{variant:"destructive",size:"sm",onClick:()=>s(!0),children:"Restart"})]})]})}),a.jsx(xrt,{open:e,onOpenChange:t,onResetComplete:()=>o(!0)}),a.jsx(yrt,{open:n,onOpenChange:s,onRestartComplete:()=>o(!0)})]})}function Srt({dorkHome:e}){const[t,n]=x.useState(!1),s=`${e}/logs`;function r(){navigator.clipboard.writeText(s).then(()=>{n(!0),setTimeout(()=>n(!1),yo.COPY_FEEDBACK_MS)})}return a.jsx(cs,{label:"Log location",description:"Directory where server log files are stored",children:a.jsx("button",{type:"button",onClick:r,className:"text-muted-foreground hover:text-foreground flex items-center gap-1.5 transition-colors",children:t?a.jsx("span",{className:"text-xs",children:"Copied"}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"max-w-40 truncate font-mono text-xs",dir:"rtl",title:s,children:s}),a.jsx(Vh,{className:"size-3 shrink-0"})]})})})}function wrt({onClick:e}){return Us()?a.jsxs(te.button,{onClick:e,whileTap:{scale:.98},transition:{type:"spring",stiffness:400,damping:30},className:Y("flex w-full items-center gap-3 px-4 py-3 text-left text-sm transition-colors","hover:bg-muted/50 active:bg-muted min-h-[44px]"),children:[a.jsx(ha,{className:"text-muted-foreground size-(--size-icon-sm) shrink-0"}),a.jsx("span",{className:"flex-1",children:"Remote Access"}),a.jsx(Rs,{className:"text-muted-foreground/40 size-(--size-icon-sm) shrink-0"})]}):a.jsx("button",{onClick:e,className:"text-muted-foreground hover:text-foreground hover:bg-muted/50 relative mx-2 flex w-[calc(100%-1rem)] items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors duration-150",children:a.jsxs("span",{className:"relative z-10 flex items-center gap-2",children:[a.jsx(ha,{className:"size-(--size-icon-sm) shrink-0"}),"Remote Access"]})})}const krt=15e3,Crt=3e4,Ert=3e4;function Trt(e,t,n){return!e&&!t?"landing":!e&&t||t?"setup":n==="error"?"error":n==="starting"?"connecting":n==="connected"||n==="stopping"?"connected":"ready"}function _rt({open:e}){const t=je(),{data:n}=st({queryKey:["config"],queryFn:()=>t.getConfig(),staleTime:300*1e3}),s=n==null?void 0:n.tunnel,[r,i]=x.useState("off"),[o,l]=x.useState(null),[c,u]=x.useState(null),[d,f]=x.useState(!1),[m,g]=x.useState(""),[y,b]=x.useState(null),[S,w]=x.useState(!1),[C,T]=x.useState(""),[E,j]=x.useState(null),_=x.useRef(void 0);x.useEffect(()=>{s!=null&&s.connected&&(s!=null&&s.url)?(i("connected"),l(s.url)):r!=="starting"&&r!=="stopping"&&(i("off"),l(null))},[s==null?void 0:s.connected,s==null?void 0:s.url,r]),x.useEffect(()=>{s!=null&&s.domain&&T(s.domain)},[s==null?void 0:s.domain]),x.useEffect(()=>{s!=null&&s.tokenConfigured&&f(!1)},[s==null?void 0:s.tokenConfigured]),x.useEffect(()=>{const L=_.current,P=(s==null?void 0:s.connected)??!1;_.current=P,L!==void 0&&(L&&!P?Ye.error("Remote access disconnected",{id:"tunnel-status",description:"Attempting to reconnect..."}):!L&&P&&(s!=null&&s.url)&&Ye.success("Remote access reconnected",{id:"tunnel-status",description:s.url}))},[s==null?void 0:s.connected,s==null?void 0:s.url]),x.useEffect(()=>{if(r!=="starting"&&r!=="stopping")return;const L=setTimeout(()=>{r==="starting"?(i("error"),u("Connection timed out. Please try again.")):r==="stopping"&&(i("off"),l(null))},Crt);return()=>clearTimeout(L)},[r]),x.useEffect(()=>{if(r!=="connected"||!o||!e){j(null);return}const L=async()=>{try{const $=performance.now();await fetch(`${o}/api/health`,{mode:"cors",cache:"no-store"}),j(Math.round(performance.now()-$))}catch{j(null)}};L();const P=setInterval(L,Ert);return()=>clearInterval(P)},[r,o,e]);const N=!!(s!=null&&s.tokenConfigured),R=Trt(N,d,r);return{state:r,setState:i,url:o,setUrl:l,error:c,setError:u,showSetup:d,setShowSetup:f,authToken:m,setAuthToken:g,tokenError:y,setTokenError:b,showTokenInput:S,setShowTokenInput:w,domain:C,setDomain:T,latencyMs:E,tunnel:s,tokenConfigured:N,viewState:R,isTransitioning:r==="starting"||r==="stopping",isChecked:r==="connected"||r==="starting"||r==="stopping"}}function Nrt(){const e=je();return st({queryKey:["tunnel-status"],queryFn:async()=>(await e.getConfig()).tunnel,refetchInterval:3e4,refetchIntervalInBackground:!1})}const jrt="dorkos-tunnel";function rV(){const e=Bwe(jrt);e.postMessage({type:"tunnel_changed"}),e.close()}function Art({machine:e,transport:t,queryClient:n}){const s=x.useRef(void 0),r=x.useCallback(async()=>{e.setState("starting"),e.setError(null);const c=setTimeout(()=>{e.setState("error"),e.setError("Connection timed out after 15 seconds")},krt);try{const u=await t.startTunnel();clearTimeout(c),e.setState("connected"),e.setUrl(u.url),n.invalidateQueries({queryKey:["config"]}),rV()}catch(u){if(clearTimeout(c),u.code==="AUTH_REQUIRED_FOR_EXPOSURE"){e.setState("off"),r1e({reason:"exposure",message:"Exposing DorkOS requires a login.",onComplete:()=>{var d;return void((d=s.current)==null?void 0:d.call(s))}});return}e.setState("error"),e.setError(u instanceof Error?u.message:"Failed to start tunnel")}},[e,t,n]);x.useEffect(()=>{s.current=r},[r]);const i=x.useCallback(async c=>{if(c)await r();else{e.setState("stopping"),e.setError(null);try{await t.stopTunnel(),e.setState("off"),e.setUrl(null),n.invalidateQueries({queryKey:["config"]}),rV()}catch(u){e.setState("connected"),e.setError(u instanceof Error?u.message:"Failed to stop tunnel")}}},[r,e,t,n]),o=x.useCallback(async()=>{e.setTokenError(null);try{await t.updateConfig({tunnel:{authtoken:e.authToken}}),e.setAuthToken(""),e.setShowTokenInput(!1),e.setShowSetup(!1),n.invalidateQueries({queryKey:["config"]})}catch{e.setTokenError("Could not save token. Try again.")}},[e,n,t]),l=x.useCallback(async()=>{try{await t.updateConfig({tunnel:{domain:e.domain.trim()||null}}),n.invalidateQueries({queryKey:["config"]})}catch{}},[e,n,t]);return{handleToggle:i,handleSaveToken:o,handleSaveDomain:l}}function Rrt(){return a.jsxs("svg",{viewBox:"0 0 240 120",className:"mx-auto h-24 w-48","aria-hidden":"true",children:[a.jsx("rect",{x:"80",y:"30",width:"80",height:"50",rx:"4",className:"fill-none stroke-current",strokeWidth:"2"}),a.jsx("rect",{x:"70",y:"80",width:"100",height:"6",rx:"2",className:"fill-current opacity-30"}),a.jsx("rect",{x:"90",y:"42",width:"20",height:"2",rx:"1",className:"fill-current opacity-40"}),a.jsx("rect",{x:"90",y:"48",width:"40",height:"2",rx:"1",className:"fill-current opacity-20"}),a.jsx("rect",{x:"90",y:"54",width:"30",height:"2",rx:"1",className:"fill-current opacity-20"}),a.jsx("rect",{x:"195",y:"35",width:"28",height:"45",rx:"4",className:"fill-none stroke-current",strokeWidth:"1.5"}),a.jsx("circle",{cx:"209",cy:"73",r:"2",className:"fill-current opacity-30"}),a.jsx("rect",{x:"10",y:"30",width:"40",height:"55",rx:"4",className:"fill-none stroke-current",strokeWidth:"1.5"}),a.jsx("circle",{cx:"30",cy:"78",r:"2",className:"fill-current opacity-30"}),a.jsx("line",{x1:"160",y1:"55",x2:"195",y2:"55",className:"stroke-current opacity-40",strokeWidth:"1.5",strokeDasharray:"4 3"}),a.jsx("line",{x1:"80",y1:"55",x2:"50",y2:"55",className:"stroke-current opacity-40",strokeWidth:"1.5",strokeDasharray:"4 3"})]})}function Mrt(){return a.jsxs("div",{className:"space-y-3",children:[a.jsx(Rrt,{}),a.jsx("p",{className:"text-foreground text-center text-sm font-medium",children:"Access DorkOS from any device"})]})}function Drt({onGetStarted:e}){return a.jsxs("div",{"data-testid":"tunnel-landing",className:"space-y-6 py-2",children:[a.jsx(Mrt,{}),a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-foreground text-sm font-medium",children:"Access DorkOS from any device"}),a.jsx("p",{className:"text-muted-foreground mx-auto mt-1 max-w-[280px] text-xs leading-relaxed",children:"Create a secure tunnel to access your sessions from your phone, tablet, or any browser."})]}),a.jsx(ge,{onClick:e,className:"w-full transition-transform duration-100 hover:scale-[1.01] active:scale-[0.98]",children:"Get started"}),a.jsx("p",{className:"text-muted-foreground/60 text-center text-xs",children:"Requires a free ngrok account"})]})}const Ort={initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0}},Irt={duration:.2,ease:[0,0,.2,1]};function Prt({authToken:e,tokenError:t,onAuthTokenChange:n,onSaveToken:s}){return a.jsxs("div",{"data-testid":"tunnel-setup",className:"space-y-4",children:[a.jsxs(ua,{"data-invalid":t?!0:void 0,children:[a.jsx(da,{htmlFor:"tunnel-auth-token",className:"text-xs font-medium",children:"ngrok auth token"}),a.jsx(sn,{id:"tunnel-auth-token",type:"password",placeholder:"Paste your ngrok auth token",value:e,onChange:r=>n(r.target.value),onKeyDown:r=>{r.key==="Enter"&&e.trim()&&s()},className:"text-sm"}),a.jsx(Ue,{children:t&&a.jsx(te.div,{variants:Ort,initial:"initial",animate:"animate",exit:"exit",transition:Irt,className:"overflow-hidden",children:a.jsx(rl,{children:t})},"token-error")})]}),a.jsx(ge,{size:"sm",className:"w-full",disabled:!e.trim(),onClick:()=>void s(),children:"Save token"}),a.jsxs("p",{className:"text-muted-foreground text-xs",children:["Don't have a token?"," ",a.jsxs("a",{href:"https://dashboard.ngrok.com/signup",target:"_blank",rel:"noopener noreferrer",className:"text-foreground group inline-flex items-center gap-0.5 underline underline-offset-2",children:["Sign up for ngrok",a.jsx(Hw,{className:"size-3 transition-transform duration-100 group-hover:-translate-x-0.5"})]})," ","— free tier is sufficient."]})]})}const Lrt={initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0}},Frt={duration:.2,ease:[0,0,.2,1]},zrt={collapsed:{rotate:0},expanded:{rotate:90}},Brt={duration:.15,ease:"easeInOut"};function iV({active:e,label:t}){return a.jsxs("span",{className:Y("flex items-center gap-1 text-xs",e?"text-muted-foreground":"text-muted-foreground/50"),children:[e?a.jsx(Lt,{className:"size-3 text-green-500"}):a.jsx("span",{className:"text-muted-foreground/40",children:"○"}),t]})}function $rt({authToken:e,tokenError:t,showTokenInput:n,onAuthTokenChange:s,onSaveToken:r,onShowTokenInput:i,domain:o,onDomainChange:l,onDomainSave:c}){const[u,d]=x.useState(!1),f=m=>{m.key==="Enter"&&c()};return a.jsxs("div",{"data-testid":"tunnel-settings",children:[a.jsxs("button",{type:"button",onClick:()=>d(m=>!m),className:"hover:text-foreground text-muted-foreground flex w-full items-center gap-1.5 py-1 text-xs transition-colors",children:[a.jsx(te.span,{variants:zrt,animate:u?"expanded":"collapsed",transition:Brt,className:"inline-flex origin-center","aria-hidden":!0,children:a.jsx(Rs,{className:"size-3.5"})}),a.jsx("span",{className:"font-medium",children:"Settings"})]}),!u&&a.jsxs("div",{className:"mt-1.5 flex gap-3 pl-5",children:[a.jsx(iV,{active:!0,label:"Token"}),a.jsx(iV,{active:!!o.trim(),label:o.trim()||"No domain"})]}),a.jsx(Ue,{initial:!1,children:u&&a.jsx(te.div,{variants:Lrt,initial:"initial",animate:"animate",exit:"exit",transition:Frt,className:"overflow-hidden",children:a.jsxs("div",{className:"space-y-4 pt-3",children:[a.jsx("div",{className:"space-y-2",children:n?a.jsxs(ua,{children:[a.jsx(da,{className:"text-sm",children:"Auth token"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(sn,{type:"password",value:e,onChange:m=>s(m.target.value),placeholder:"Paste ngrok auth token",className:"flex-1","aria-label":"Auth token"}),a.jsx(ge,{type:"button",size:"sm",onClick:r,disabled:!e.trim(),children:"Save"})]}),t&&a.jsx(rl,{children:t})]}):a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"space-y-0.5",children:[a.jsx("p",{className:"text-sm font-medium",children:"Auth token"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Token saved"})]}),a.jsx(ge,{type:"button",variant:"outline",size:"sm",onClick:i,children:"Change"})]})}),a.jsxs(ua,{children:[a.jsx(da,{className:"text-sm",children:"Custom domain"}),a.jsx(sn,{type:"text",value:o,onChange:m=>l(m.target.value),onBlur:c,onKeyDown:f,placeholder:"your-domain.ngrok.app","aria-label":"Custom domain"}),a.jsx(Va,{className:"text-xs",children:"Leave blank to use a randomly assigned ngrok URL."})]})]})},"settings-panel")})]})}const ok=[0,500,1200],aV=[{label:"Initialising ngrok agent",thresholdMs:ok[0]},{label:"Opening secure tunnel",thresholdMs:ok[1]},{label:"Registering public URL",thresholdMs:ok[2]}],Hrt={hidden:{},show:{transition:{staggerChildren:.15}}},Urt={hidden:{opacity:0,y:8},show:{opacity:1,y:0,transition:{type:"spring",stiffness:320,damping:28}}},Vrt={initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1}},qrt={type:"spring",stiffness:400,damping:30};function Grt(){const[e,t]=x.useState(0);return x.useEffect(()=>{const n=Date.now(),s=ok.map(r=>setTimeout(()=>{t(Date.now()-n)},r));return()=>{s.forEach(clearTimeout)}},[]),a.jsx(te.div,{className:"space-y-3 py-2","data-testid":"tunnel-connecting",variants:Hrt,initial:"hidden",animate:"show",children:aV.map((n,s)=>{var c;const r=e>=n.thresholdMs,i=((c=aV[s+1])==null?void 0:c.thresholdMs)??1/0,o=e>=i,l=r&&!o;return a.jsxs(te.div,{variants:Urt,className:Y("flex items-center gap-3 text-sm transition-opacity duration-300",r?"opacity-100":"opacity-0"),children:[a.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:a.jsx(Ue,{mode:"wait",children:o?a.jsx(te.span,{variants:Vrt,initial:"initial",animate:"animate",exit:{scale:.5,opacity:0},transition:qrt,className:"inline-flex",children:a.jsx(Lt,{className:"text-muted-foreground size-4"})},"check"):l?a.jsx(te.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"inline-flex",children:a.jsx(Sn,{className:"text-muted-foreground size-4 animate-spin"})},"spinner"):null})}),a.jsx("span",{className:Y("transition-colors duration-200",o?"text-muted-foreground":"text-foreground"),children:n.label})]},n.label)})})}var WA={exports:{}},YA,oV;function Krt(){if(oV)return YA;oV=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return YA=e,YA}var ZA,lV;function Wrt(){if(lV)return ZA;lV=1;var e=Krt();function t(){}function n(){}return n.resetWarningCache=t,ZA=function(){function s(o,l,c,u,d,f){if(f!==e){var m=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw m.name="Invariant Violation",m}}s.isRequired=s;function r(){return s}var i={array:s,bigint:s,bool:s,func:s,number:s,object:s,string:s,symbol:s,any:s,arrayOf:r,element:s,elementType:s,instanceOf:r,node:s,objectOf:r,oneOf:r,oneOfType:r,shape:r,exact:r,checkPropTypes:n,resetWarningCache:t};return i.PropTypes=i,i},ZA}var cV;function Yrt(){return cV||(cV=1,WA.exports=Wrt()()),WA.exports}var Zrt=Yrt();const jt=hl(Zrt),lm=function(e,t){let r=e;const i=yy[t];let o=null,l=0,c=null;const u=[],d={},f=function(N,R){l=r*4+17,o=(function(O){const M=new Array(O);for(let L=0;L<O;L+=1){M[L]=new Array(O);for(let P=0;P<O;P+=1)M[L][P]=null}return M})(l),m(0,0),m(l-7,0),m(0,l-7),b(),y(),w(N,R),r>=7&&S(N),c==null&&(c=E(r,i,u)),C(c,R)},m=function(N,R){for(let O=-1;O<=7;O+=1)if(!(N+O<=-1||l<=N+O))for(let M=-1;M<=7;M+=1)R+M<=-1||l<=R+M||(0<=O&&O<=6&&(M==0||M==6)||0<=M&&M<=6&&(O==0||O==6)||2<=O&&O<=4&&2<=M&&M<=4?o[N+O][R+M]=!0:o[N+O][R+M]=!1)},g=function(){let N=0,R=0;for(let O=0;O<8;O+=1){f(!0,O);const M=Cu.getLostPoint(d);(O==0||N>M)&&(N=M,R=O)}return R},y=function(){for(let N=8;N<l-8;N+=1)o[N][6]==null&&(o[N][6]=N%2==0);for(let N=8;N<l-8;N+=1)o[6][N]==null&&(o[6][N]=N%2==0)},b=function(){const N=Cu.getPatternPosition(r);for(let R=0;R<N.length;R+=1)for(let O=0;O<N.length;O+=1){const M=N[R],L=N[O];if(o[M][L]==null)for(let P=-2;P<=2;P+=1)for(let $=-2;$<=2;$+=1)P==-2||P==2||$==-2||$==2||P==0&&$==0?o[M+P][L+$]=!0:o[M+P][L+$]=!1}},S=function(N){const R=Cu.getBCHTypeNumber(r);for(let O=0;O<18;O+=1){const M=!N&&(R>>O&1)==1;o[Math.floor(O/3)][O%3+l-8-3]=M}for(let O=0;O<18;O+=1){const M=!N&&(R>>O&1)==1;o[O%3+l-8-3][Math.floor(O/3)]=M}},w=function(N,R){const O=i<<3|R,M=Cu.getBCHTypeInfo(O);for(let L=0;L<15;L+=1){const P=!N&&(M>>L&1)==1;L<6?o[L][8]=P:L<8?o[L+1][8]=P:o[l-15+L][8]=P}for(let L=0;L<15;L+=1){const P=!N&&(M>>L&1)==1;L<8?o[8][l-L-1]=P:L<9?o[8][15-L-1+1]=P:o[8][15-L-1]=P}o[l-8][8]=!N},C=function(N,R){let O=-1,M=l-1,L=7,P=0;const $=Cu.getMaskFunction(R);for(let q=l-1;q>0;q-=2)for(q==6&&(q-=1);;){for(let K=0;K<2;K+=1)if(o[M][q-K]==null){let B=!1;P<N.length&&(B=(N[P]>>>L&1)==1),$(M,q-K)&&(B=!B),o[M][q-K]=B,L-=1,L==-1&&(P+=1,L=7)}if(M+=O,M<0||l<=M){M-=O,O=-O;break}}},T=function(N,R){let O=0,M=0,L=0;const P=new Array(R.length),$=new Array(R.length);for(let V=0;V<R.length;V+=1){const Q=R[V].dataCount,re=R[V].totalCount-Q;M=Math.max(M,Q),L=Math.max(L,re),P[V]=new Array(Q);for(let F=0;F<P[V].length;F+=1)P[V][F]=255&N.getBuffer()[F+O];O+=Q;const U=Cu.getErrorCorrectPolynomial(re),W=_v(P[V],U.getLength()-1).mod(U);$[V]=new Array(U.getLength()-1);for(let F=0;F<$[V].length;F+=1){const X=F+W.getLength()-$[V].length;$[V][F]=X>=0?W.getAt(X):0}}let q=0;for(let V=0;V<R.length;V+=1)q+=R[V].totalCount;const K=new Array(q);let B=0;for(let V=0;V<M;V+=1)for(let Q=0;Q<R.length;Q+=1)V<P[Q].length&&(K[B]=P[Q][V],B+=1);for(let V=0;V<L;V+=1)for(let Q=0;Q<R.length;Q+=1)V<$[Q].length&&(K[B]=$[Q][V],B+=1);return K},E=function(N,R,O){const M=uV.getRSBlocks(N,R),L=dV();for(let $=0;$<O.length;$+=1){const q=O[$];L.put(q.getMode(),4),L.put(q.getLength(),Cu.getLengthInBits(q.getMode(),N)),q.write(L)}let P=0;for(let $=0;$<M.length;$+=1)P+=M[$].dataCount;if(L.getLengthInBits()>P*8)throw"code length overflow. ("+L.getLengthInBits()+">"+P*8+")";for(L.getLengthInBits()+4<=P*8&&L.put(0,4);L.getLengthInBits()%8!=0;)L.putBit(!1);for(;!(L.getLengthInBits()>=P*8||(L.put(236,8),L.getLengthInBits()>=P*8));)L.put(17,8);return T(L,M)};d.addData=function(N,R){R=R||"Byte";let O=null;switch(R){case"Numeric":O=Xrt(N);break;case"Alphanumeric":O=Qrt(N);break;case"Byte":O=Jrt(N);break;case"Kanji":O=eit(N);break;default:throw"mode:"+R}u.push(O),c=null},d.isDark=function(N,R){if(N<0||l<=N||R<0||l<=R)throw N+","+R;return o[N][R]},d.getModuleCount=function(){return l},d.make=function(){if(r<1){let N=1;for(;N<40;N++){const R=uV.getRSBlocks(N,i),O=dV();for(let L=0;L<u.length;L++){const P=u[L];O.put(P.getMode(),4),O.put(P.getLength(),Cu.getLengthInBits(P.getMode(),N)),P.write(O)}let M=0;for(let L=0;L<R.length;L++)M+=R[L].dataCount;if(O.getLengthInBits()<=M*8)break}r=N}f(!1,g())},d.createTableTag=function(N,R){N=N||2,R=typeof R>"u"?N*4:R;let O="";O+='<table style="',O+=" border-width: 0px; border-style: none;",O+=" border-collapse: collapse;",O+=" padding: 0px; margin: "+R+"px;",O+='">',O+="<tbody>";for(let M=0;M<d.getModuleCount();M+=1){O+="<tr>";for(let L=0;L<d.getModuleCount();L+=1)O+='<td style="',O+=" border-width: 0px; border-style: none;",O+=" border-collapse: collapse;",O+=" padding: 0px; margin: 0px;",O+=" width: "+N+"px;",O+=" height: "+N+"px;",O+=" background-color: ",O+=d.isDark(M,L)?"#000000":"#ffffff",O+=";",O+='"/>';O+="</tr>"}return O+="</tbody>",O+="</table>",O},d.createSvgTag=function(N,R,O,M){let L={};typeof arguments[0]=="object"&&(L=arguments[0],N=L.cellSize,R=L.margin,O=L.alt,M=L.title),N=N||2,R=typeof R>"u"?N*4:R,O=typeof O=="string"?{text:O}:O||{},O.text=O.text||null,O.id=O.text?O.id||"qrcode-description":null,M=typeof M=="string"?{text:M}:M||{},M.text=M.text||null,M.id=M.text?M.id||"qrcode-title":null;const P=d.getModuleCount()*N+R*2;let $,q,K,B,V="",Q;for(Q="l"+N+",0 0,"+N+" -"+N+",0 0,-"+N+"z ",V+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',V+=L.scalable?"":' width="'+P+'px" height="'+P+'px"',V+=' viewBox="0 0 '+P+" "+P+'" ',V+=' preserveAspectRatio="xMinYMin meet"',V+=M.text||O.text?' role="img" aria-labelledby="'+j([M.id,O.id].join(" ").trim())+'"':"",V+=">",V+=M.text?'<title id="'+j(M.id)+'">'+j(M.text)+"</title>":"",V+=O.text?'<description id="'+j(O.id)+'">'+j(O.text)+"</description>":"",V+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',V+='<path d="',K=0;K<d.getModuleCount();K+=1)for(B=K*N+R,$=0;$<d.getModuleCount();$+=1)d.isDark(K,$)&&(q=$*N+R,V+="M"+q+","+B+Q);return V+='" stroke="transparent" fill="black"/>',V+="</svg>",V},d.createDataURL=function(N,R){N=N||2,R=typeof R>"u"?N*4:R;const O=d.getModuleCount()*N+R*2,M=R,L=O-R;return rit(O,O,function(P,$){if(M<=P&&P<L&&M<=$&&$<L){const q=Math.floor((P-M)/N),K=Math.floor(($-M)/N);return d.isDark(K,q)?0:1}else return 1})},d.createImgTag=function(N,R,O){N=N||2,R=typeof R>"u"?N*4:R;const M=d.getModuleCount()*N+R*2;let L="";return L+="<img",L+=' src="',L+=d.createDataURL(N,R),L+='"',L+=' width="',L+=M,L+='"',L+=' height="',L+=M,L+='"',O&&(L+=' alt="',L+=j(O),L+='"'),L+="/>",L};const j=function(N){let R="";for(let O=0;O<N.length;O+=1){const M=N.charAt(O);switch(M){case"<":R+="<";break;case">":R+=">";break;case"&":R+="&";break;case'"':R+=""";break;default:R+=M;break}}return R},_=function(N){N=typeof N>"u"?2:N;const O=d.getModuleCount()*1+N*2,M=N,L=O-N;let P,$,q,K,B;const V={"██":"█","█ ":"▀"," █":"▄"," ":" "},Q={"██":"▀","█ ":"▀"," █":" "," ":" "};let re="";for(P=0;P<O;P+=2){for(q=Math.floor((P-M)/1),K=Math.floor((P+1-M)/1),$=0;$<O;$+=1)B="█",M<=$&&$<L&&M<=P&&P<L&&d.isDark(q,Math.floor(($-M)/1))&&(B=" "),M<=$&&$<L&&M<=P+1&&P+1<L&&d.isDark(K,Math.floor(($-M)/1))?B+=" ":B+="█",re+=N<1&&P+1>=L?Q[B]:V[B];re+=`
|
|
1261
1261
|
`}return O%2&&N>0?re.substring(0,re.length-O-1)+Array(O+1).join("▀"):re.substring(0,re.length-1)};return d.createASCII=function(N,R){if(N=N||1,N<2)return _(R);N-=1,R=typeof R>"u"?N*2:R;const O=d.getModuleCount()*N+R*2,M=R,L=O-R;let P,$,q,K;const B=Array(N+1).join("██"),V=Array(N+1).join(" ");let Q="",re="";for(P=0;P<O;P+=1){for(q=Math.floor((P-M)/N),re="",$=0;$<O;$+=1)K=1,M<=$&&$<L&&M<=P&&P<L&&d.isDark(q,Math.floor(($-M)/N))&&(K=0),re+=K?B:V;for(q=0;q<N;q+=1)Q+=re+`
|
|
1262
1262
|
`}return Q.substring(0,Q.length-1)},d.renderTo2dContext=function(N,R){R=R||2;const O=d.getModuleCount();for(let M=0;M<O;M++)for(let L=0;L<O;L++)N.fillStyle=d.isDark(M,L)?"black":"white",N.fillRect(L*R,M*R,R,R)},d};lm.stringToBytes=function(e){const t=[];for(let n=0;n<e.length;n+=1){const s=e.charCodeAt(n);t.push(s&255)}return t};lm.createStringToBytes=function(e,t){const n=(function(){const r=nit(e),i=function(){const c=r.read();if(c==-1)throw"eof";return c};let o=0;const l={};for(;;){const c=r.read();if(c==-1)break;const u=i(),d=i(),f=i(),m=String.fromCharCode(c<<8|u),g=d<<8|f;l[m]=g,o+=1}if(o!=t)throw o+" != "+t;return l})(),s=63;return function(r){const i=[];for(let o=0;o<r.length;o+=1){const l=r.charCodeAt(o);if(l<128)i.push(l);else{const c=n[r.charAt(o)];typeof c=="number"?(c&255)==c?i.push(c):(i.push(c>>>8),i.push(c&255)):i.push(s)}}return i}};const Ir={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},yy={L:1,M:0,Q:3,H:2},ku={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},Cu=(function(){const e=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],t=1335,n=7973,s=21522,r={},i=function(o){let l=0;for(;o!=0;)l+=1,o>>>=1;return l};return r.getBCHTypeInfo=function(o){let l=o<<10;for(;i(l)-i(t)>=0;)l^=t<<i(l)-i(t);return(o<<10|l)^s},r.getBCHTypeNumber=function(o){let l=o<<12;for(;i(l)-i(n)>=0;)l^=n<<i(l)-i(n);return o<<12|l},r.getPatternPosition=function(o){return e[o-1]},r.getMaskFunction=function(o){switch(o){case ku.PATTERN000:return function(l,c){return(l+c)%2==0};case ku.PATTERN001:return function(l,c){return l%2==0};case ku.PATTERN010:return function(l,c){return c%3==0};case ku.PATTERN011:return function(l,c){return(l+c)%3==0};case ku.PATTERN100:return function(l,c){return(Math.floor(l/2)+Math.floor(c/3))%2==0};case ku.PATTERN101:return function(l,c){return l*c%2+l*c%3==0};case ku.PATTERN110:return function(l,c){return(l*c%2+l*c%3)%2==0};case ku.PATTERN111:return function(l,c){return(l*c%3+(l+c)%2)%2==0};default:throw"bad maskPattern:"+o}},r.getErrorCorrectPolynomial=function(o){let l=_v([1],0);for(let c=0;c<o;c+=1)l=l.multiply(_v([1,Ru.gexp(c)],0));return l},r.getLengthInBits=function(o,l){if(1<=l&&l<10)switch(o){case Ir.MODE_NUMBER:return 10;case Ir.MODE_ALPHA_NUM:return 9;case Ir.MODE_8BIT_BYTE:return 8;case Ir.MODE_KANJI:return 8;default:throw"mode:"+o}else if(l<27)switch(o){case Ir.MODE_NUMBER:return 12;case Ir.MODE_ALPHA_NUM:return 11;case Ir.MODE_8BIT_BYTE:return 16;case Ir.MODE_KANJI:return 10;default:throw"mode:"+o}else if(l<41)switch(o){case Ir.MODE_NUMBER:return 14;case Ir.MODE_ALPHA_NUM:return 13;case Ir.MODE_8BIT_BYTE:return 16;case Ir.MODE_KANJI:return 12;default:throw"mode:"+o}else throw"type:"+l},r.getLostPoint=function(o){const l=o.getModuleCount();let c=0;for(let f=0;f<l;f+=1)for(let m=0;m<l;m+=1){let g=0;const y=o.isDark(f,m);for(let b=-1;b<=1;b+=1)if(!(f+b<0||l<=f+b))for(let S=-1;S<=1;S+=1)m+S<0||l<=m+S||b==0&&S==0||y==o.isDark(f+b,m+S)&&(g+=1);g>5&&(c+=3+g-5)}for(let f=0;f<l-1;f+=1)for(let m=0;m<l-1;m+=1){let g=0;o.isDark(f,m)&&(g+=1),o.isDark(f+1,m)&&(g+=1),o.isDark(f,m+1)&&(g+=1),o.isDark(f+1,m+1)&&(g+=1),(g==0||g==4)&&(c+=3)}for(let f=0;f<l;f+=1)for(let m=0;m<l-6;m+=1)o.isDark(f,m)&&!o.isDark(f,m+1)&&o.isDark(f,m+2)&&o.isDark(f,m+3)&&o.isDark(f,m+4)&&!o.isDark(f,m+5)&&o.isDark(f,m+6)&&(c+=40);for(let f=0;f<l;f+=1)for(let m=0;m<l-6;m+=1)o.isDark(m,f)&&!o.isDark(m+1,f)&&o.isDark(m+2,f)&&o.isDark(m+3,f)&&o.isDark(m+4,f)&&!o.isDark(m+5,f)&&o.isDark(m+6,f)&&(c+=40);let u=0;for(let f=0;f<l;f+=1)for(let m=0;m<l;m+=1)o.isDark(m,f)&&(u+=1);const d=Math.abs(100*u/l/l-50)/5;return c+=d*10,c},r})(),Ru=(function(){const e=new Array(256),t=new Array(256);for(let s=0;s<8;s+=1)e[s]=1<<s;for(let s=8;s<256;s+=1)e[s]=e[s-4]^e[s-5]^e[s-6]^e[s-8];for(let s=0;s<255;s+=1)t[e[s]]=s;const n={};return n.glog=function(s){if(s<1)throw"glog("+s+")";return t[s]},n.gexp=function(s){for(;s<0;)s+=255;for(;s>=256;)s-=255;return e[s]},n})(),_v=function(e,t){if(typeof e.length>"u")throw e.length+"/"+t;const n=(function(){let r=0;for(;r<e.length&&e[r]==0;)r+=1;const i=new Array(e.length-r+t);for(let o=0;o<e.length-r;o+=1)i[o]=e[o+r];return i})(),s={};return s.getAt=function(r){return n[r]},s.getLength=function(){return n.length},s.multiply=function(r){const i=new Array(s.getLength()+r.getLength()-1);for(let o=0;o<s.getLength();o+=1)for(let l=0;l<r.getLength();l+=1)i[o+l]^=Ru.gexp(Ru.glog(s.getAt(o))+Ru.glog(r.getAt(l)));return _v(i,0)},s.mod=function(r){if(s.getLength()-r.getLength()<0)return s;const i=Ru.glog(s.getAt(0))-Ru.glog(r.getAt(0)),o=new Array(s.getLength());for(let l=0;l<s.getLength();l+=1)o[l]=s.getAt(l);for(let l=0;l<r.getLength();l+=1)o[l]^=Ru.gexp(Ru.glog(r.getAt(l))+i);return _v(o,0).mod(r)},s},uV=(function(){const e=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t=function(r,i){const o={};return o.totalCount=r,o.dataCount=i,o},n={},s=function(r,i){switch(i){case yy.L:return e[(r-1)*4+0];case yy.M:return e[(r-1)*4+1];case yy.Q:return e[(r-1)*4+2];case yy.H:return e[(r-1)*4+3];default:return}};return n.getRSBlocks=function(r,i){const o=s(r,i);if(typeof o>"u")throw"bad rs block @ typeNumber:"+r+"/errorCorrectionLevel:"+i;const l=o.length/3,c=[];for(let u=0;u<l;u+=1){const d=o[u*3+0],f=o[u*3+1],m=o[u*3+2];for(let g=0;g<d;g+=1)c.push(t(f,m))}return c},n})(),dV=function(){const e=[];let t=0;const n={};return n.getBuffer=function(){return e},n.getAt=function(s){const r=Math.floor(s/8);return(e[r]>>>7-s%8&1)==1},n.put=function(s,r){for(let i=0;i<r;i+=1)n.putBit((s>>>r-i-1&1)==1)},n.getLengthInBits=function(){return t},n.putBit=function(s){const r=Math.floor(t/8);e.length<=r&&e.push(0),s&&(e[r]|=128>>>t%8),t+=1},n},Xrt=function(e){const t=Ir.MODE_NUMBER,n=e,s={};s.getMode=function(){return t},s.getLength=function(o){return n.length},s.write=function(o){const l=n;let c=0;for(;c+2<l.length;)o.put(r(l.substring(c,c+3)),10),c+=3;c<l.length&&(l.length-c==1?o.put(r(l.substring(c,c+1)),4):l.length-c==2&&o.put(r(l.substring(c,c+2)),7))};const r=function(o){let l=0;for(let c=0;c<o.length;c+=1)l=l*10+i(o.charAt(c));return l},i=function(o){if("0"<=o&&o<="9")return o.charCodeAt(0)-48;throw"illegal char :"+o};return s},Qrt=function(e){const t=Ir.MODE_ALPHA_NUM,n=e,s={};s.getMode=function(){return t},s.getLength=function(i){return n.length},s.write=function(i){const o=n;let l=0;for(;l+1<o.length;)i.put(r(o.charAt(l))*45+r(o.charAt(l+1)),11),l+=2;l<o.length&&i.put(r(o.charAt(l)),6)};const r=function(i){if("0"<=i&&i<="9")return i.charCodeAt(0)-48;if("A"<=i&&i<="Z")return i.charCodeAt(0)-65+10;switch(i){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+i}};return s},Jrt=function(e){const t=Ir.MODE_8BIT_BYTE,n=lm.stringToBytes(e),s={};return s.getMode=function(){return t},s.getLength=function(r){return n.length},s.write=function(r){for(let i=0;i<n.length;i+=1)r.put(n[i],8)},s},eit=function(e){const t=Ir.MODE_KANJI,n=lm.stringToBytes;(function(i,o){const l=n(i);if(l.length!=2||(l[0]<<8|l[1])!=o)throw"sjis not supported."})("友",38726);const s=n(e),r={};return r.getMode=function(){return t},r.getLength=function(i){return~~(s.length/2)},r.write=function(i){const o=s;let l=0;for(;l+1<o.length;){let c=(255&o[l])<<8|255&o[l+1];if(33088<=c&&c<=40956)c-=33088;else if(57408<=c&&c<=60351)c-=49472;else throw"illegal char at "+(l+1)+"/"+c;c=(c>>>8&255)*192+(c&255),i.put(c,13),l+=2}if(l<o.length)throw"illegal char at "+(l+1)},r},Zce=function(){const e=[],t={};return t.writeByte=function(n){e.push(n&255)},t.writeShort=function(n){t.writeByte(n),t.writeByte(n>>>8)},t.writeBytes=function(n,s,r){s=s||0,r=r||n.length;for(let i=0;i<r;i+=1)t.writeByte(n[i+s])},t.writeString=function(n){for(let s=0;s<n.length;s+=1)t.writeByte(n.charCodeAt(s))},t.toByteArray=function(){return e},t.toString=function(){let n="";n+="[";for(let s=0;s<e.length;s+=1)s>0&&(n+=","),n+=e[s];return n+="]",n},t},tit=function(){let e=0,t=0,n=0,s="";const r={},i=function(l){s+=String.fromCharCode(o(l&63))},o=function(l){if(l<0)throw"n:"+l;if(l<26)return 65+l;if(l<52)return 97+(l-26);if(l<62)return 48+(l-52);if(l==62)return 43;if(l==63)return 47;throw"n:"+l};return r.writeByte=function(l){for(e=e<<8|l&255,t+=8,n+=1;t>=6;)i(e>>>t-6),t-=6},r.flush=function(){if(t>0&&(i(e<<6-t),e=0,t=0),n%3!=0){const l=3-n%3;for(let c=0;c<l;c+=1)s+="="}},r.toString=function(){return s},r},nit=function(e){const t=e;let n=0,s=0,r=0;const i={};i.read=function(){for(;r<8;){if(n>=t.length){if(r==0)return-1;throw"unexpected end of file./"+r}const c=t.charAt(n);if(n+=1,c=="=")return r=0,-1;if(c.match(/^\s$/))continue;s=s<<6|o(c.charCodeAt(0)),r+=6}const l=s>>>r-8&255;return r-=8,l};const o=function(l){if(65<=l&&l<=90)return l-65;if(97<=l&&l<=122)return l-97+26;if(48<=l&&l<=57)return l-48+52;if(l==43)return 62;if(l==47)return 63;throw"c:"+l};return i},sit=function(e,t){const n=e,s=t,r=new Array(e*t),i={};i.setPixel=function(u,d,f){r[d*n+u]=f},i.write=function(u){u.writeString("GIF87a"),u.writeShort(n),u.writeShort(s),u.writeByte(128),u.writeByte(0),u.writeByte(0),u.writeByte(0),u.writeByte(0),u.writeByte(0),u.writeByte(255),u.writeByte(255),u.writeByte(255),u.writeString(","),u.writeShort(0),u.writeShort(0),u.writeShort(n),u.writeShort(s),u.writeByte(0);const d=2,f=l(d);u.writeByte(d);let m=0;for(;f.length-m>255;)u.writeByte(255),u.writeBytes(f,m,255),m+=255;u.writeByte(f.length-m),u.writeBytes(f,m,f.length-m),u.writeByte(0),u.writeString(";")};const o=function(u){const d=u;let f=0,m=0;const g={};return g.write=function(y,b){if(y>>>b)throw"length over";for(;f+b>=8;)d.writeByte(255&(y<<f|m)),b-=8-f,y>>>=8-f,m=0,f=0;m=y<<f|m,f=f+b},g.flush=function(){f>0&&d.writeByte(m)},g},l=function(u){const d=1<<u,f=(1<<u)+1;let m=u+1;const g=c();for(let C=0;C<d;C+=1)g.add(String.fromCharCode(C));g.add(String.fromCharCode(d)),g.add(String.fromCharCode(f));const y=Zce(),b=o(y);b.write(d,m);let S=0,w=String.fromCharCode(r[S]);for(S+=1;S<r.length;){const C=String.fromCharCode(r[S]);S+=1,g.contains(w+C)?w=w+C:(b.write(g.indexOf(w),m),g.size()<4095&&(g.size()==1<<m&&(m+=1),g.add(w+C)),w=C)}return b.write(g.indexOf(w),m),b.write(f,m),b.flush(),y.toByteArray()},c=function(){const u={};let d=0;const f={};return f.add=function(m){if(f.contains(m))throw"dup key:"+m;u[m]=d,d+=1},f.size=function(){return d},f.indexOf=function(m){return u[m]},f.contains=function(m){return typeof u[m]<"u"},f};return i},rit=function(e,t,n){const s=sit(e,t);for(let l=0;l<t;l+=1)for(let c=0;c<e;c+=1)s.setPixel(c,l,n(c,l));const r=Zce();s.write(r);const i=tit(),o=r.toByteArray();for(let l=0;l<o.length;l+=1)i.writeByte(o[l]);return i.flush(),"data:image/gif;base64,"+i};lm.stringToBytes;function CC(){return CC=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)({}).hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},CC.apply(null,arguments)}function Xce(e,t){if(e==null)return{};var n,s,r=iit(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)n=i[s],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function iit(e,t){if(e==null)return{};var n={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(t.indexOf(s)!==-1)continue;n[s]=e[s]}return n}var ait=["bgColor","bgD","fgD","fgColor","size","title","viewBoxSize","xmlns"],oit={bgColor:jt.oneOfType([jt.object,jt.string]).isRequired,bgD:jt.string.isRequired,fgColor:jt.oneOfType([jt.object,jt.string]).isRequired,fgD:jt.string.isRequired,size:jt.number.isRequired,title:jt.string,viewBoxSize:jt.number.isRequired,xmlns:jt.string},CP=x.forwardRef(function(e,t){var n=e.bgColor,s=e.bgD,r=e.fgD,i=e.fgColor,o=e.size,l=e.title,c=e.viewBoxSize,u=e.xmlns,d=u===void 0?"http://www.w3.org/2000/svg":u,f=Xce(e,ait);return he.createElement("svg",CC({},f,{height:o,ref:t,viewBox:"0 0 ".concat(c," ").concat(c),width:o,xmlns:d}),l?he.createElement("title",null,l):null,he.createElement("path",{d:s,fill:n}),he.createElement("path",{d:r,fill:i}))});CP.displayName="QRCodeSvg";CP.propTypes=oit;var lit=["bgColor","fgColor","level","size","value"];lm.stringToBytes=function(e){return Array.from(new TextEncoder().encode(e))};var cit={bgColor:jt.oneOfType([jt.object,jt.string]),fgColor:jt.oneOfType([jt.object,jt.string]),level:jt.string,size:jt.number,value:jt.string.isRequired},EP=x.forwardRef(function(e,t){var n=e.bgColor,s=n===void 0?"#FFFFFF":n,r=e.fgColor,i=r===void 0?"#000000":r,o=e.level,l=o===void 0?"L":o,c=e.size,u=c===void 0?256:c,d=e.value,f=Xce(e,lit),m=lm(0,l);m.addData(d),m.make();var g=m.getModuleCount(),y=Array.from({length:g},function(b,S){return Array.from({length:g},function(w,C){return m.isDark(S,C)})});return he.createElement(CP,CC({},f,{bgColor:s,bgD:y.map(function(b,S){return b.map(function(w,C){return w?"":"M ".concat(C," ").concat(S," l 1 0 0 1 -1 0 Z")}).join(" ")}).join(" "),fgColor:i,fgD:y.map(function(b,S){return b.map(function(w,C){return w?"M ".concat(C," ").concat(S," l 1 0 0 1 -1 0 Z"):""}).join(" ")}).join(" "),ref:t,size:u,viewBoxSize:g}))});EP.displayName="QRCode";EP.propTypes=cit;function uit(e){return/auth|token|ERR_NGROK_105/i.test(e)?"Check your auth token at dashboard.ngrok.com":/timeout|ETIMEDOUT/i.test(e)?"Connection timed out. Check your network.":/limit|ERR_NGROK_108/i.test(e)?"Tunnel limit reached. Free ngrok accounts allow one active tunnel.":/DNS|NXDOMAIN|ERR_NGROK_332/i.test(e)?"DNS resolution failed. Check your domain configuration.":/gateway|502|ERR_NGROK_3200/i.test(e)?"Gateway error. The tunnel endpoint is unreachable.":/upgrade|ERR_NGROK_120/i.test(e)?"Feature requires a paid ngrok plan.":/ECONNREFUSED/i.test(e)?"Connection refused. Ensure the server is running.":e}function dit(e){return e===null?"bg-gray-400":e<200?"bg-green-500":e<500?"bg-amber-400":"bg-red-500"}const fit={initial:{scale:.98,opacity:0},animate:{scale:1,opacity:1}},hit={type:"spring",stiffness:400,damping:28},mit={initial:{opacity:0},animate:{opacity:1}},pit={duration:.3,delay:.5},git={initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0}},xit={duration:.2,ease:[0,0,.2,1]};function yit({url:e,activeSessionId:t,latencyMs:n}){const[s,r]=wg(),[i,o]=wg(),[l,c]=x.useState(!1),u=t?`${e}?session=${t}`:null;return a.jsxs("div",{"data-testid":"tunnel-connected",className:"space-y-3",children:[a.jsxs(te.div,{className:"bg-muted/30 rounded-lg border border-green-500/20 p-3",variants:fit,initial:"initial",animate:"animate",transition:hit,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:Y("inline-block size-1.5 shrink-0 rounded-full",dit(n)),"aria-label":n!==null?`${n}ms latency`:"Latency unknown"}),a.jsx("span",{className:"text-foreground min-w-0 flex-1 truncate font-mono text-xs",children:e.replace(/^https?:\/\//,"")}),a.jsx(Ue,{children:n!==null&&a.jsxs(te.span,{className:"text-muted-foreground shrink-0 text-xs",variants:mit,initial:"initial",animate:"animate",transition:pit,children:[n,"ms"]})})]}),a.jsxs("div",{className:"mt-3 flex gap-2",children:[a.jsxs(ge,{variant:"outline",size:"sm",className:"flex-1 gap-1.5",onClick:()=>r(e),children:[s?a.jsx(Lt,{className:"size-3"}):a.jsx(Vh,{className:"size-3"}),s?"Copied":"Copy URL"]}),u&&a.jsxs(ge,{variant:"outline",size:"sm",className:"flex-1 gap-1.5",onClick:()=>o(u),children:[i?a.jsx(Lt,{className:"size-3"}):a.jsx(ane,{className:"size-3"}),i?"Copied":"Session link"]}),a.jsx(ge,{variant:"outline",size:"sm",onClick:()=>c(d=>!d),"aria-label":"Toggle QR code",className:Y(l&&"bg-accent"),children:a.jsx(h3e,{className:"size-3.5"})})]})]}),a.jsx(Ue,{children:l&&a.jsxs(te.div,{variants:git,initial:"initial",animate:"animate",exit:"exit",transition:xit,className:"overflow-hidden",children:[a.jsx("div",{className:"flex justify-center rounded-lg bg-white p-4",children:a.jsx(EP,{value:e,size:180,level:"M"})}),a.jsx("p",{className:"text-muted-foreground mt-2 text-center text-xs",children:"Scan from any device"})]},"qr-expand")})]})}const vit={initial:{x:0},animate:{x:[0,-2,2,-1,0]}},bit={duration:.35,ease:"easeInOut"};function Sit({error:e,onRetry:t}){const n=uit(e);return a.jsx(te.div,{"data-testid":"tunnel-error",className:"rounded-lg border border-red-200 bg-red-50 p-4 dark:border-red-800 dark:bg-red-950/30",variants:vit,initial:"initial",animate:"animate",transition:bit,children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Hh,{className:"mt-0.5 size-4 shrink-0 text-red-600 dark:text-red-400"}),a.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[a.jsx("p",{className:"text-sm font-medium text-red-800 dark:text-red-200",children:"Connection failed"}),a.jsx("p",{className:"text-xs text-red-700 dark:text-red-300",children:n}),a.jsxs(ge,{variant:"outline",size:"sm",onClick:t,className:"border-red-300 text-red-700 hover:bg-red-100 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-900/50",children:[a.jsx(ma,{className:"mr-1.5 size-3.5"}),"Try again"]})]})]})})}const wit={initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4}},kit={duration:.2,ease:[0,0,.2,1]},rp={variants:wit,initial:"initial",animate:"animate",exit:"exit",transition:kit};function TP({open:e,onOpenChange:t}){const n=je(),s=!Us(),r=et(),[i]=Vc(),o=_rt({open:e}),l=Art({machine:o,transport:n,queryClient:r}),c={off:"bg-gray-400",starting:"bg-amber-400",connected:"bg-green-500",stopping:"bg-gray-400",error:"bg-red-500"}[o.state];return a.jsx(fi,{open:e,onOpenChange:t,children:a.jsxs(hi,{className:Y("max-h-[85vh]",s&&"max-w-md"),children:[a.jsxs(va,{children:[a.jsxs(Li,{className:"flex items-center gap-2 text-sm font-medium",children:[a.jsx("span",{className:Y("inline-block size-2 rounded-full",c,o.isTransitioning&&"animate-tasks")}),"Remote Access"]}),o.viewState==="landing"&&a.jsx(Ga,{className:"text-muted-foreground text-xs",children:"Access DorkOS from any device, any browser."}),o.viewState==="connecting"&&a.jsx(Ga,{className:"text-muted-foreground text-xs",children:"Establishing connection..."})]}),a.jsxs("div",{className:"space-y-4 overflow-y-auto px-4 pb-4",children:[a.jsxs(Ue,{mode:"wait",children:[o.viewState==="landing"&&a.jsx(te.div,{...rp,children:a.jsx(Drt,{onGetStarted:()=>o.setShowSetup(!0)})},"landing"),o.viewState==="setup"&&a.jsx(te.div,{...rp,children:a.jsx(Prt,{authToken:o.authToken,tokenError:o.tokenError,onAuthTokenChange:o.setAuthToken,onSaveToken:l.handleSaveToken})},"setup"),o.viewState==="ready"&&a.jsx(te.div,{...rp,children:a.jsx("div",{className:Y("rounded-lg border p-4 transition-colors duration-300","border-border bg-muted/30"),children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium",children:"Enable remote access"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Open a secure tunnel via ngrok"})]}),a.jsx(sr,{checked:!1,onCheckedChange:l.handleToggle})]})})},"ready"),o.viewState==="connecting"&&a.jsx(te.div,{...rp,children:a.jsx(Grt,{})},"connecting"),o.viewState==="connected"&&o.url&&a.jsxs(te.div,{...rp,children:[a.jsx(yit,{url:o.url,activeSessionId:i,latencyMs:o.latencyMs}),a.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[a.jsx("p",{className:"text-muted-foreground text-sm",children:"Remote access is on"}),a.jsx(sr,{checked:o.isChecked,onCheckedChange:l.handleToggle,disabled:o.isTransitioning})]})]},"connected"),o.viewState==="error"&&o.error&&a.jsx(te.div,{...rp,children:a.jsx(Sit,{error:o.error,onRetry:()=>{o.setState("off"),o.setError(null)}})},"error")]}),o.tokenConfigured&&o.viewState!=="setup"&&o.viewState!=="landing"&&a.jsxs(a.Fragment,{children:[a.jsx(av,{}),a.jsx($rt,{authToken:o.authToken,tokenError:o.tokenError,showTokenInput:o.showTokenInput,onAuthTokenChange:o.setAuthToken,onSaveToken:l.handleSaveToken,onShowTokenInput:()=>o.setShowTokenInput(!0),domain:o.domain,onDomainChange:o.setDomain,onDomainSave:l.handleSaveDomain})]}),o.viewState!=="connected"&&o.viewState!=="landing"&&o.viewState!=="ready"&&a.jsxs(a.Fragment,{children:[a.jsx(av,{}),a.jsxs(ua,{orientation:"horizontal",className:Y("items-center justify-between rounded-lg border px-3 py-2 transition-colors duration-300",o.state==="starting"&&"border-amber-400/40",o.state==="stopping"&&"border-amber-400/20",o.state==="error"&&"border-destructive/40",o.state==="off"&&"border-transparent"),children:[a.jsx(da,{className:"text-sm font-normal",children:"Enable remote access"}),a.jsx(sr,{checked:o.isChecked,onCheckedChange:l.handleToggle,disabled:o.isTransitioning})]})]})]})]})})}const Cit=[{id:"appearance",label:"Appearance",icon:YMe,component:nnt},{id:"preferences",label:"Preferences",icon:P3e,component:snt},{id:"statusBar",label:"Status Bar",icon:hMe,component:gst},{id:"server",label:"Server",icon:mne,component:yst},{id:"tools",label:"Tools",icon:ODe,component:Dst},{id:"channels",label:"Channels",icon:WE,component:Pst},{id:"agents",label:"Agents",icon:Ad,component:Lst},{id:"runtimes",label:"Runtimes",icon:Zte,component:xst},{id:"security",label:"Security",icon:xb,component:irt},{id:"account",label:"DorkOS account",icon:qE,component:grt},{id:"advanced",label:"Advanced",icon:G5,component:brt}];function Eit({open:e,onOpenChange:t}){const{activeTab:n}=t0(),[s,r]=x.useState(!1);return a.jsxs(a.Fragment,{children:[a.jsx(o8e,{open:e,onOpenChange:t,title:"App Settings",description:"Application settings",defaultTab:"appearance",initialTab:n,tabs:Cit,sidebarExtras:a.jsx(wrt,{onClick:()=>r(!0)}),extensionSlot:"settings.tabs",testId:"settings-dialog"}),a.jsx(TP,{open:s,onOpenChange:r})]})}const Tit=1500,_it=3e4;function Nit({open:e,onDismiss:t}){const[n,s]=x.useState(!1),r=je(),i=x.useRef(null),o=x.useRef(null),l=x.useCallback(()=>{i.current&&clearTimeout(i.current),o.current&&clearInterval(o.current),i.current=null,o.current=null},[]),c=x.useCallback(()=>{s(!1),l(),i.current=setTimeout(()=>{o.current&&clearInterval(o.current),o.current=null,s(!0)},_it),o.current=setInterval(async()=>{try{await r.health(),l(),window.location.reload()}catch{}},Tit)},[r,l]);if(x.useEffect(()=>(e&&c(),l),[e,c,l]),!e)return null;const u=a.jsx("div",{className:"bg-background/80 fixed inset-0 z-[100] flex items-center justify-center backdrop-blur-sm","data-testid":"server-restart-overlay",children:a.jsx("div",{className:"flex flex-col items-center gap-4 text-center",children:n?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-foreground text-sm font-medium",children:"Server did not restart within 30 seconds."}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Check your terminal for errors."}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(ge,{variant:"outline",size:"sm",onClick:c,children:"Try Again"}),a.jsx(ge,{variant:"outline",size:"sm",onClick:t,children:"Dismiss"})]})]}):a.jsxs(a.Fragment,{children:[a.jsx(Sn,{className:"text-muted-foreground size-8 animate-spin"}),a.jsx("p",{className:"text-foreground text-sm font-medium",children:"Restarting server..."}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Waiting for server to come back..."})]})})});return Wa.createPortal(u,document.body)}function jit({open:e,onOpenChange:t}){return a.jsx(Eit,{open:e,onOpenChange:t})}function Ait({open:e,onOpenChange:t}){const[n,s]=Id(),r=we(l=>l.recentCwds),i=x.useMemo(()=>r.map(l=>l.path),[r]),{data:o}=Jle(i);return a.jsx(ET,{open:e,onOpenChange:t,onSelect:l=>s(l),initialPath:n,resolvedAgents:o})}function Rit({open:e,onOpenChange:t}){return a.jsx(fi,{open:e,onOpenChange:t,children:a.jsxs(hi,{className:"h-[85vh] max-w-2xl gap-0 p-0",children:[a.jsx(Rb,{}),a.jsxs(va,{className:"border-b px-4 py-3",children:[a.jsx(Li,{className:"text-sm font-medium",children:"Tasks Scheduler"}),a.jsx(Ga,{className:"sr-only",children:"Manage scheduled AI agent tasks"})]}),a.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:a.jsx(iet,{})})]})})}function Mit({open:e,onOpenChange:t}){return a.jsx(fi,{open:e,onOpenChange:t,children:a.jsxs(hi,{className:"h-[85vh] max-w-2xl gap-0 p-0",children:[a.jsx(Rb,{}),a.jsxs(va,{className:"border-b px-4 py-3",children:[a.jsx(Li,{className:"text-sm font-medium",children:"Connections"}),a.jsx(Ga,{className:"sr-only",children:"Manage adapters and monitor message activity"})]}),a.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:a.jsx(Ytt,{})})]})})}function Dit({open:e,onOpenChange:t}){return a.jsx(Nit,{open:e,onDismiss:()=>t(!1)})}const Oit=[{id:"settings",component:jit,openStateKey:"settingsOpen",priority:1,urlParam:"settings"},{id:"directory-picker",component:Ait,openStateKey:"pickerOpen",priority:2},{id:"tasks",component:Rit,openStateKey:"tasksOpen",priority:3,urlParam:"tasks"},{id:"relay",component:Mit,openStateKey:"relayOpen",priority:4,urlParam:"relay"},{id:"server-restart-overlay",component:Dit,openStateKey:"restartOverlayOpen",priority:7}],Iit=[{id:"overview",icon:ine,label:"Overview",shortcut:1},{id:"sessions",icon:Rd,label:"Sessions",shortcut:2},{id:"schedules",icon:Pi,label:"Schedules",shortcut:3},{id:"connections",icon:Gk,label:"Connections",shortcut:4}],Pit={ok:"bg-green-500",partial:"bg-amber-500",error:"bg-red-500"};function Lit({activeTab:e,onTabChange:t,schedulesBadge:n,connectionsStatus:s,visibleTabs:r}){const i=x.useRef(null),o=zg?"⌘":"Ctrl+",l=x.useCallback(u=>{var m,g;const d=r.indexOf(e);let f=d;if(u.key==="ArrowRight"?(f=(d+1)%r.length,u.preventDefault()):u.key==="ArrowLeft"&&(f=(d-1+r.length)%r.length,u.preventDefault()),f!==d){t(r[f]);const y=(m=i.current)==null?void 0:m.querySelectorAll('[role="tab"]');(g=y==null?void 0:y[f])==null||g.focus()}},[e,t,r]),c=Iit.filter(u=>r.includes(u.id));return a.jsxs("div",{ref:i,role:"tablist","aria-label":"Sidebar views",tabIndex:-1,className:"border-border relative flex items-center gap-1 border-b px-2 py-1.5",onKeyDown:l,children:[c.map(u=>{const d=e===u.id,f=u.icon;return a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsxs("button",{role:"tab",id:`sidebar-tab-${u.id}`,"aria-selected":d,"aria-controls":`sidebar-tabpanel-${u.id}`,tabIndex:d?0:-1,onClick:()=>t(u.id),className:Y("relative rounded-md p-2 transition-colors duration-150",d?"text-foreground":"text-muted-foreground/50 hover:text-muted-foreground"),children:[a.jsx(f,{className:"size-(--size-icon-sm)"}),u.id==="schedules"&&n>0&&a.jsxs("span",{className:"absolute -top-0.5 -right-0.5 flex size-4 items-center justify-center rounded-full bg-green-500 text-[10px] font-medium text-white",children:[n>9?"9+":n,a.jsx("span",{className:"animate-tasks absolute inset-0 rounded-full bg-green-500/30"})]}),u.id==="connections"&&s!=="none"&&a.jsx("span",{className:Y("absolute -top-0.5 -right-0.5 size-1.5 rounded-full",Pit[s])}),d&&a.jsx(te.div,{layoutId:"sidebar-tab-indicator",className:"bg-brand absolute right-0 bottom-[-7px] left-0 h-0.5 rounded-full",transition:{type:"spring",stiffness:280,damping:32}})]})}),a.jsxs(yn,{side:"bottom",children:[u.label," ",`${o}${u.shortcut}`]})]},u.id)}),a.jsx("div",{className:"flex-1"}),a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx("button",{type:"button",onClick:()=>ud.getState().open(),className:"text-muted-foreground/50 hover:text-muted-foreground rounded-md p-2 transition-colors duration-150","aria-label":"New Agent",children:a.jsx(Cs,{className:"size-(--size-icon-sm)"})})}),a.jsx(yn,{side:"bottom",children:"New Agent"})]})]})}function Fit({warning:e}){const t=Ka(e.runtime).label;return a.jsxs("p",{className:"text-muted-foreground/60 flex items-start gap-1.5 text-xs",title:e.message,"data-testid":`session-list-warning-${e.runtime}`,children:[a.jsx(Hh,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),a.jsxs("span",{children:["Couldn't load ",t," sessions"]})]})}function Qce({activeSessionId:e,groupedSessions:t,warnings:n=[],onSessionClick:s,onForkSession:r,onRenameSession:i}){return a.jsxs(No,{type:"scroll",className:"h-full",viewportClassName:"[&>div]:!block",children:[n.length>0&&a.jsx("div",{className:"space-y-1 px-4 pt-2","data-testid":"session-list-warnings",children:n.map(o=>a.jsx(Fit,{warning:o},o.runtime))}),a.jsx(te.div,{layout:!0,children:t.length>0?a.jsx(a.Fragment,{children:t.map(o=>{const l=t.length===1&&o.label==="Today";return a.jsxs(Nc,{children:[!l&&a.jsx(po,{className:"text-2xs text-muted-foreground/70 font-medium tracking-wider uppercase",children:o.label}),a.jsx(Xr,{children:o.sessions.map(c=>a.jsx(Lr,{children:a.jsx(rP,{variant:"full",session:c,isActive:c.id===e,onClick:()=>s(c.id),onFork:r,onRename:i})},c.id))})]},o.label)})}):a.jsx("div",{className:"flex h-32 items-center justify-center",children:a.jsx("p",{className:"text-muted-foreground/60 text-sm",children:"No conversations yet"})})})]})}const zit=5;function Bit({status:e}){switch(e){case"running":return a.jsx(Sn,{className:"size-3 shrink-0 animate-spin text-blue-500","aria-hidden":!0});case"completed":return a.jsx(Uh,{className:"size-3 shrink-0 text-green-500","aria-hidden":!0});case"failed":return a.jsx(Xg,{className:"text-destructive size-3 shrink-0","aria-hidden":!0});case"cancelled":return a.jsx(Yte,{className:"text-muted-foreground size-3 shrink-0","aria-hidden":!0});default:return null}}function $it(e){if(e===null)return"";if(e<1e3)return"< 1s";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return`${n}m ${s}s`}function Hit({run:e,scheduleName:t}){return a.jsx(Lr,{children:a.jsxs(Ni,{className:"text-sm",children:[a.jsx(Sn,{className:"size-3 shrink-0 animate-spin text-blue-500","aria-hidden":!0}),a.jsx("span",{className:"truncate",children:t}),e.startedAt&&a.jsx("span",{className:"text-muted-foreground/50 ml-auto shrink-0 text-xs",children:ii(e.startedAt)})]})})}function Uit({schedule:e,onEdit:t}){return a.jsx(Lr,{children:a.jsxs(Ni,{onClick:()=>t(e.id),className:"text-sm",children:[a.jsx(Pi,{className:"text-muted-foreground/50 size-3 shrink-0","aria-hidden":!0}),a.jsx("span",{className:"truncate",children:e.name}),e.nextRun&&a.jsx("span",{className:"text-muted-foreground/50 ml-auto shrink-0 text-xs",children:ii(e.nextRun)})]})})}function Vit({run:e,scheduleName:t}){const n=e.status==="running"&&e.finishedAt?e.error?"failed":"completed":e.status;return a.jsx(Lr,{children:a.jsxs(Ni,{className:"text-sm",children:[a.jsx(Bit,{status:n}),a.jsx("span",{className:"truncate",children:t}),a.jsxs("span",{className:"text-muted-foreground/50 ml-auto flex shrink-0 items-center gap-1.5 text-xs",children:[e.durationMs!==null&&a.jsx("span",{children:$it(e.durationMs)}),e.finishedAt&&a.jsx("span",{children:ii(e.finishedAt)})]})]})})}function Jce({toolStatus:e,agentId:t}){const n=Kh(),s=we(E=>E.setTasksAgentFilter),r=we(E=>E.setTasksEditScheduleId),i=e!=="disabled-by-server",{data:o=[]}=WT(i),{data:l=0}=dP(i),{data:c=[]}=k0(void 0,i),{data:u=[]}=fP(),{openWithTemplate:d}=Ub(),f=[u[0],u[2]].filter(Boolean),m=x.useMemo(()=>t?o.filter(E=>E.agentId===t):o,[t,o]),g=x.useMemo(()=>{const E=new Map;for(const j of m)E.set(j.id,j.name);return E},[m]),y=x.useMemo(()=>c.filter(E=>g.has(E.scheduleId)),[c,g]),{runningRuns:b,recentRuns:S}=x.useMemo(()=>{const E=[],j=[];for(const _ of y)_.finishedAt!=null||_.status!=="running"?j.push(_):E.push(_);return j.sort((_,N)=>(N.finishedAt??N.createdAt).localeCompare(_.finishedAt??_.createdAt)),{runningRuns:E,recentRuns:j.slice(0,zit)}},[y]),w=x.useMemo(()=>m.filter(E=>E.enabled&&E.status==="active"&&E.nextRun).sort((E,j)=>(E.nextRun??"").localeCompare(j.nextRun??"")),[m]),C=()=>{t&&(s(t),r(null)),n.open()},T=E=>{r(E),s(null),n.open()};return e==="disabled-by-agent"?a.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 px-4 py-8",children:[a.jsx("p",{className:"text-muted-foreground/60 text-sm",children:"Tasks disabled for this agent"}),a.jsx("button",{onClick:C,className:"text-muted-foreground hover:text-foreground text-xs transition-colors",children:"Open Tasks →"})]}):m.length===0?a.jsxs("div",{className:"flex flex-col gap-3 px-3 py-4",children:[a.jsx("p",{className:"text-muted-foreground/70 text-xs",children:"No schedules yet."}),f.length>0&&a.jsx("div",{className:"space-y-2",children:f.map(E=>a.jsxs("div",{className:"rounded-lg border p-3 text-sm",children:[a.jsx("div",{className:"font-medium",children:E.name}),a.jsx("p",{className:"text-muted-foreground text-xs",children:gce(E.cron)}),a.jsx("button",{type:"button",onClick:()=>{d(E),C()},className:"text-primary mt-2 text-xs hover:underline",children:"+ Use preset"})]},E.id))}),a.jsx("button",{onClick:C,className:"text-muted-foreground hover:text-foreground text-xs transition-colors",children:"Open Tasks →"})]}):a.jsx(No,{type:"scroll",className:"h-full",children:a.jsxs("div",{className:"pr-1",children:[b.length>0&&a.jsxs(Nc,{children:[a.jsxs(po,{className:"text-2xs text-muted-foreground/70 font-medium tracking-wider uppercase",children:["Running",a.jsx("span",{className:"text-muted-foreground/50 ml-auto text-xs font-normal normal-case",children:l})]}),a.jsx(Xr,{children:b.map(E=>a.jsx(Hit,{run:E,scheduleName:g.get(E.scheduleId)??"Unknown"},E.id))})]}),w.length>0&&a.jsxs(Nc,{children:[a.jsx(po,{className:"text-2xs text-muted-foreground/70 font-medium tracking-wider uppercase",children:"Upcoming"}),a.jsx(Xr,{children:w.map(E=>a.jsx(Uit,{schedule:E,onEdit:T},E.id))})]}),S.length>0&&a.jsxs(Nc,{children:[a.jsx(po,{className:"text-2xs text-muted-foreground/70 font-medium tracking-wider uppercase",children:"Recent Runs"}),a.jsx(Xr,{children:S.map(E=>a.jsx(Vit,{run:E,scheduleName:g.get(E.scheduleId)??"Unknown"},E.id))})]}),a.jsx("div",{className:"px-3 py-2",children:a.jsx("button",{onClick:C,className:"text-muted-foreground hover:text-foreground text-xs transition-colors",children:"Open Tasks →"})})]})})}const qit={connected:"bg-green-500",disconnected:"bg-amber-500",error:"bg-red-500"},Git={enabled:"bg-green-500","disabled-by-agent":"bg-muted-foreground/20","disabled-by-server":"bg-muted-foreground/20"},fV={connected:"bg-green-500",failed:"bg-red-500","needs-auth":"bg-amber-500",pending:"bg-amber-500",disabled:"bg-muted-foreground/20"},Kit=[{key:"tasks",label:"Tasks"},{key:"relay",label:"Relay"},{key:"mesh",label:"Mesh"}],XA=3,QA=4,n_=[0,0,.2,1],hV={initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0}},mV={duration:.2,ease:n_},pV={initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0}},gV={duration:.25,ease:n_},xV={initial:{opacity:0,y:3},animate:{opacity:1,y:0},exit:{opacity:0,y:-3}},yV={duration:.12,ease:n_},ip={initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}},ap={duration:.15,ease:n_};function eue({toolStatus:e,agentId:t,activeSessionId:n}){const s=we(G=>G.selectedCwd),r=we(G=>G.setRightPanelOpen),i=we(G=>G.setActiveRightPanelTab),o=Hn(),l=Wh(),c=e.relay!=="disabled-by-server",u=e.mesh!=="disabled-by-server",{data:d=[]}=Hb(c),{data:f=[]}=Gb(),{data:m}=ba(void 0,u),g=x.useMemo(()=>(m==null?void 0:m.agents)??[],[m==null?void 0:m.agents]),{data:y}=GQe(s),b=(y==null?void 0:y.servers)??[],S=b.slice(0,QA),w=Math.max(0,b.length-QA),{data:C,isLoading:T}=SJe(t??"",u&&!!t),E=x.useMemo(()=>{const G=F=>F.config.type==="claude-code"&&F.config.builtin===!0;if(!t)return d.filter(G);const W=new Set(f.filter(F=>F.agentId===t).map(F=>F.adapterId));return d.filter(F=>G(F)||W.has(F.config.id))},[d,f,t]),j=x.useMemo(()=>{if(!t||T||!C)return g;const G=new Set(C.agents.map(W=>W.id));return g.filter(W=>G.has(W.id))},[g,t,C,T]),_=j.slice(0,XA),N=Math.max(0,j.length-XA),[R,O]=x.useState(!1),[M,L]=x.useState(!1),[P,$]=x.useState(!1),q=je(),K=et(),B=Ine(n),V=tP(B),Q=x.useCallback(async()=>{if(!n||P)return;if(!(V!=null&&V.supportsPlugins)){const W=Ka(B??"").label;Ye.warning(`${B?W:"This runtime"} does not support plugin reload`);return}const G=q.asClaudePluginTransport(n);if(!G){Ye.warning("The active session runtime does not support plugin reload");return}$(!0);try{const W=await G.reloadPlugins();await K.invalidateQueries({queryKey:["mcp-config"]}),W.errorCount>0?Ye.warning(`Plugins reloaded with ${W.errorCount} error(s)`):Ye.success(`Reloaded ${W.pluginCount} plugin(s), ${W.commandCount} command(s)`)}catch(W){Ye.error(W instanceof Error?W.message:"Failed to reload plugins")}finally{$(!1)}},[n,P,q,K,V,B]),re=c,U=u;return a.jsx(No,{type:"scroll",className:"h-full",children:a.jsxs("div",{className:"pr-1",children:[a.jsx(Ue,{initial:!1,children:re&&a.jsx(te.div,{variants:pV,initial:"initial",animate:"animate",exit:"exit",transition:gV,className:"overflow-hidden",children:a.jsxs(Nc,{children:[a.jsx(po,{className:"text-2xs text-muted-foreground/70 font-medium tracking-wider uppercase",children:"Channels"}),a.jsx(ik,{"aria-label":"Open Relay panel",onClick:()=>l.open(),children:a.jsx(Hw,{})}),a.jsx(Ue,{mode:"wait",initial:!1,children:e.relay==="disabled-by-agent"?a.jsx(te.div,{variants:ip,initial:"initial",animate:"animate",exit:"exit",transition:ap,className:"px-3 py-2",children:a.jsx("p",{className:"text-muted-foreground/60 text-sm",children:"Channels disabled for this agent"})},"relay-disabled"):E.length===0?a.jsx(te.div,{variants:ip,initial:"initial",animate:"animate",exit:"exit",transition:ap,className:"px-3 py-2",children:a.jsx("p",{className:"text-muted-foreground/60 text-sm",children:"No channels configured"})},"relay-empty"):a.jsx(te.div,{variants:ip,initial:"initial",animate:"animate",exit:"exit",transition:ap,children:a.jsx(Xr,{children:E.map(G=>a.jsx(Lr,{children:a.jsxs(Ni,{onClick:()=>l.open(),className:"text-sm",children:[a.jsx("span",{className:Y("size-2 shrink-0 rounded-full",qit[G.status.state]??"bg-muted-foreground/20",G.status.state==="connected"&&"animate-tasks")}),a.jsx("span",{className:"truncate",children:G.status.displayName}),a.jsx("span",{className:"text-muted-foreground/50 ml-auto text-xs capitalize",children:G.status.state})]})},G.config.id))})},"relay-list")})]})})}),a.jsx(Ue,{initial:!1,children:U&&a.jsx(te.div,{variants:pV,initial:"initial",animate:"animate",exit:"exit",transition:gV,className:"overflow-hidden",children:a.jsxs(Nc,{children:[a.jsx(po,{className:"text-2xs text-muted-foreground/70 font-medium tracking-wider uppercase",children:"Agents"}),a.jsx(ik,{"aria-label":"Open Mesh panel",onClick:()=>o({to:"/agents"}),children:a.jsx(Hw,{})}),a.jsx(Ue,{mode:"wait",initial:!1,children:e.mesh==="disabled-by-agent"?a.jsx(te.div,{variants:ip,initial:"initial",animate:"animate",exit:"exit",transition:ap,className:"px-3 py-2",children:a.jsx("p",{className:"text-muted-foreground/60 text-sm",children:"Mesh disabled for this agent"})},"mesh-disabled"):j.length===0?a.jsx(te.div,{variants:ip,initial:"initial",animate:"animate",exit:"exit",transition:ap,className:"px-3 py-2",children:a.jsx("p",{className:"text-muted-foreground/60 text-sm",children:"No agents registered"})},"mesh-empty"):a.jsxs(te.div,{variants:ip,initial:"initial",animate:"animate",exit:"exit",transition:ap,children:[a.jsx(Xr,{children:_.map(G=>a.jsx(Lr,{children:a.jsxs(Ni,{onClick:()=>o({to:"/agents"}),className:"text-sm",children:[a.jsx("span",{className:"bg-muted-foreground/40 size-2 shrink-0 rounded-full"}),a.jsx("span",{className:"truncate",children:nn(G)})]})},G.id))}),a.jsx(Ue,{initial:!1,children:R&&a.jsx(te.div,{variants:hV,initial:"initial",animate:"animate",exit:"exit",transition:mV,className:"overflow-hidden",children:a.jsx(Xr,{children:j.slice(XA).map(G=>a.jsx(Lr,{children:a.jsxs(Ni,{onClick:()=>o({to:"/agents"}),className:"text-sm",children:[a.jsx("span",{className:"bg-muted-foreground/40 size-2 shrink-0 rounded-full"}),a.jsx("span",{className:"truncate",children:nn(G)})]})},G.id))})})})]},"mesh-list")}),N>0&&a.jsx("div",{className:"px-3 py-1",children:a.jsx("button",{onClick:()=>O(G=>!G),className:"text-muted-foreground hover:text-foreground relative text-xs transition-colors",children:a.jsx(Ue,{mode:"wait",initial:!1,children:a.jsx(te.span,{variants:xV,initial:"initial",animate:"animate",exit:"exit",transition:yV,className:"block",children:R?"Show less":`+ ${N} more ${N===1?"agent":"agents"} reachable →`},R?"less":"more")})})})]})})}),a.jsxs(Nc,{children:[a.jsx(po,{className:"text-2xs text-muted-foreground/70 font-medium tracking-wider uppercase",children:"Tools"}),a.jsx(ik,{"aria-label":"Edit capabilities",onClick:()=>(()=>{s&&yd.getState().openHub(s,"config"),i("agent-hub"),r(!0)})(),children:a.jsx(Hw,{})}),a.jsx(Xr,{children:Kit.map(({key:G,label:W})=>{const F=e[G];return a.jsx(Lr,{children:a.jsxs(Ni,{className:"text-sm",onClick:()=>(()=>{s&&yd.getState().openHub(s,"config"),i("agent-hub"),r(!0)})(),children:[a.jsx("span",{className:Y("size-2 shrink-0 rounded-full",Git[F])}),a.jsx("span",{className:"truncate",children:W}),a.jsx("span",{className:"text-muted-foreground/50 ml-auto text-xs",children:F==="enabled"?"enabled":"off"})]})},G)})}),a.jsxs(Xr,{children:[S.map(G=>a.jsx(Lr,{children:a.jsxs(Ni,{className:"text-sm",children:[a.jsx("span",{className:Y("size-2 shrink-0 rounded-full",fV[G.status??""]??"bg-muted-foreground/40",G.status==="connected"&&"animate-tasks")}),a.jsx("span",{className:"truncate",children:G.name}),a.jsx("span",{className:"text-muted-foreground/50 ml-auto text-xs",children:"mcp"})]})},G.name)),n&&(V==null?void 0:V.supportsPlugins)&&a.jsx(Lr,{children:a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsxs(Ni,{className:"text-muted-foreground hover:text-foreground text-xs",onClick:Q,disabled:P,"aria-label":"Reload plugins",children:[a.jsx(ma,{className:Y("size-3 shrink-0",P&&"animate-spin")}),a.jsx("span",{children:"Reload plugins"})]})}),a.jsx(yn,{side:"right",children:"Reload MCP servers and commands from disk"})]})})]}),a.jsx(Ue,{initial:!1,children:M&&a.jsx(te.div,{variants:hV,initial:"initial",animate:"animate",exit:"exit",transition:mV,className:"overflow-hidden",children:a.jsx(Xr,{children:b.slice(QA).map(G=>a.jsx(Lr,{children:a.jsxs(Ni,{className:"text-sm",children:[a.jsx("span",{className:Y("size-2 shrink-0 rounded-full",fV[G.status??""]??"bg-muted-foreground/40",G.status==="connected"&&"animate-tasks")}),a.jsx("span",{className:"truncate",children:G.name}),a.jsx("span",{className:"text-muted-foreground/50 ml-auto text-xs",children:"mcp"})]})},G.name))})})}),w>0&&a.jsx("div",{className:"px-3 py-1",children:a.jsx("button",{onClick:()=>L(G=>!G),className:"text-muted-foreground hover:text-foreground relative text-xs transition-colors",children:a.jsx(Ue,{mode:"wait",initial:!1,children:a.jsx(te.span,{variants:xV,initial:"initial",animate:"animate",exit:"exit",transition:yV,className:"block",children:M?"Show less":`+ ${w} more ${w===1?"server":"servers"} →`},M?"less":"more")})})})]})]})})}function Wit({onClose:e}){const{open:t}=Wh(),n=()=>{e(),t()};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"flex size-10 items-center justify-center rounded-lg bg-gradient-to-br from-purple-500/10 to-purple-600/10",children:a.jsx(Rd,{className:"size-5 text-purple-500"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium",children:"Get notified where you already are"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Slack, Telegram, and more"})]})]}),a.jsxs("div",{className:"bg-muted/50 space-y-3 rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(qte,{className:"text-muted-foreground mt-0.5 size-4"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs font-medium",children:"Real-time notifications"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Know when agents finish, fail, or need input"})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Uc,{className:"text-muted-foreground mt-0.5 size-4"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs font-medium",children:"Two-way communication"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Reply to agents directly from your messaging app"})]})]})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(ge,{variant:"ghost",size:"sm",onClick:e,children:"Not now"}),a.jsx(ge,{size:"sm",onClick:n,children:"Set up adapters"})]})]})}function Yit({onClose:e}){const{open:t}=Kh(),n=()=>{e(),t()};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"flex size-10 items-center justify-center rounded-lg bg-gradient-to-br from-indigo-500/10 to-indigo-600/10",children:a.jsx(GE,{className:"size-5 text-indigo-500"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium",children:"Agents that work while you sleep"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Schedule recurring tasks with Tasks"})]})]}),a.jsxs("div",{className:"bg-muted/50 space-y-3 rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Pi,{className:"text-muted-foreground mt-0.5 size-4"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs font-medium",children:"Cron-style schedules"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Run agents on any schedule — daily, hourly, or custom cron"})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(x3e,{className:"text-muted-foreground mt-0.5 size-4"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs font-medium",children:"Wake up to results"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Review completed work in the morning, not start it"})]})]})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(ge,{variant:"ghost",size:"sm",onClick:e,children:"Later"}),a.jsx(ge,{size:"sm",onClick:n,children:"Create a schedule"})]})]})}function Zit({onClose:e}){const t=Hn(),n=()=>{e(),t({to:"/agents"})};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"flex size-10 items-center justify-center rounded-lg bg-gradient-to-br from-emerald-500/10 to-emerald-600/10",children:a.jsx(cne,{className:"size-5 text-emerald-500"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium",children:"Let your agents collaborate"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Agent-to-agent communication via Mesh"})]})]}),a.jsxs("div",{className:"bg-muted/50 space-y-3 rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(e0,{className:"text-muted-foreground mt-0.5 size-4"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs font-medium",children:"Multi-agent workflows"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Agents can delegate tasks and share context"})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(HMe,{className:"text-muted-foreground mt-0.5 size-4"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs font-medium",children:"Topology view"}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Visualize how your agents connect and communicate"})]})]})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(ge,{variant:"ghost",size:"sm",onClick:e,children:"Not now"}),a.jsx(ge,{size:"sm",onClick:n,children:"Explore Mesh"})]})]})}const Xit=[{id:"remote-access",placements:["dashboard-main","dashboard-sidebar"],priority:90,shouldShow:()=>!0,content:{icon:ha,title:"Use DorkOS on the go",shortDescription:"Access your agents from anywhere",ctaLabel:"Learn more"},action:{type:"open-dialog",component:TP}},{id:"relay-adapters",placements:["dashboard-main","agent-sidebar","dashboard-sidebar"],priority:80,shouldShow:e=>e.isRelayEnabled&&!e.hasAdapter("slack")&&!e.hasAdapter("telegram"),content:{icon:Rd,title:"Connect to Slack & Telegram",shortDescription:"Get notifications where you already are",ctaLabel:"Learn more"},action:{type:"dialog",component:Wit}},{id:"schedules",placements:["dashboard-main","agent-sidebar","dashboard-sidebar"],priority:70,shouldShow:e=>e.isTasksEnabled&&e.sessionCount>0,content:{icon:GE,title:"Run agents while you sleep",shortDescription:"Set schedules and wake up to results",ctaLabel:"Set up"},action:{type:"dialog",component:Yit}},{id:"agent-chat",placements:["dashboard-main","agent-sidebar"],priority:60,shouldShow:e=>e.isMeshEnabled&&e.agentCount>=2,content:{icon:cne,title:"Agent-to-agent conversations",shortDescription:"Let your agents collaborate",ctaLabel:"Learn more"},action:{type:"dialog",component:Zit}}];function Qit(){return uJe()}const vV="dorkos-first-use-date",Jit=1e3*60*60*24;function eat(){try{const e=localStorage.getItem(vV);if(e){const n=new Date(e);if(!isNaN(n.getTime()))return n}const t=new Date;return localStorage.setItem(vV,t.toISOString()),t}catch{return new Date}}function tat(){const e=eat();return Math.floor((Date.now()-e.getTime())/Jit)}function nat(){const[e]=x.useState(tat);return e}function sat(){const e=Ud(),t=Qit(),n=am(),{sessions:s}=bl(),{data:r}=ba(),i=nat(),{data:o}=Hb(n);return{hasAdapter:x.useCallback(c=>o?o.some(u=>u.config.type===c&&u.status.state==="connected"):!1,[o]),isTasksEnabled:e,isMeshEnabled:t,isRelayEnabled:n,sessionCount:s.length,agentCount:(r==null?void 0:r.agents.length)??0,daysSinceFirstUse:i}}function rat(e,t){const n=sat(),s=we(i=>i.dismissedPromoIds),r=we(i=>i.promoEnabled);return x.useMemo(()=>r?Xit.filter(i=>i.placements.includes(e)).filter(i=>!s.includes(i.id)).filter(i=>i.shouldShow(n)).sort((i,o)=>o.priority-i.priority).slice(0,t):[],[e,t,n,s,r])}function bV({promo:e,open:t,onOpenChange:n}){const s=x.useCallback(()=>{n(!1)},[n]);if(e.action.type!=="dialog")return null;const r=e.action.component;return a.jsx(fi,{open:t,onOpenChange:n,children:a.jsxs(hi,{className:"max-h-[85vh] max-w-lg gap-0 p-0",children:[a.jsx(Rb,{}),a.jsxs(va,{className:"p-4 pb-0",children:[a.jsx(Li,{className:"text-sm font-medium",children:e.content.title}),a.jsx(Ga,{className:"sr-only",children:e.content.shortDescription})]}),a.jsx(Ab,{className:"p-4",children:a.jsx(r,{onClose:s})})]})})}const SV={initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,scale:.95,transition:{duration:.15}}};function iat({promo:e,placement:t}){const n=we(c=>c.dismissPromo),[s,r]=x.useState(!1),i=t==="dashboard-sidebar"||t==="agent-sidebar",o=e.content.icon,l=()=>{e.action.type==="dialog"||e.action.type==="open-dialog"?r(!0):e.action.type==="navigate"?window.location.href=e.action.to:e.action.type==="action"&&e.action.handler()};return i?a.jsxs(te.div,{variants:SV,layout:!0,children:[a.jsxs("button",{"data-slot":"promo-card-compact",onClick:l,className:"border-border bg-card hover:bg-accent flex w-full items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",children:[a.jsx("div",{className:"bg-muted flex size-8 shrink-0 items-center justify-center rounded-md",children:a.jsx(o,{className:"text-muted-foreground size-4"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"truncate text-xs font-medium",children:e.content.title}),a.jsx("p",{className:"text-muted-foreground truncate text-[11px]",children:e.content.shortDescription})]}),a.jsx(uh,{className:"text-muted-foreground size-3.5 shrink-0"})]}),e.action.type==="dialog"&&a.jsx(bV,{promo:e,open:s,onOpenChange:r}),e.action.type==="open-dialog"&&a.jsx(e.action.component,{open:s,onOpenChange:r})]}):a.jsxs(te.div,{variants:SV,layout:!0,children:[a.jsxs("div",{role:"button",tabIndex:0,"data-slot":"promo-card",className:Y("group border-border bg-card shadow-soft card-interactive hover:bg-accent relative w-full cursor-pointer rounded-xl border p-4 text-left transition-colors"),onClick:l,onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),l())},children:[a.jsx("button",{type:"button","aria-label":"Dismiss suggestion",onClick:c=>{c.stopPropagation(),n(e.id)},className:"text-muted-foreground hover:text-foreground absolute top-3 right-3 rounded-sm p-1 opacity-0 transition-opacity group-hover:opacity-100 hover:opacity-100 focus-visible:opacity-100",children:a.jsx(es,{className:"size-3.5"})}),a.jsx("div",{className:"bg-muted flex size-8 items-center justify-center rounded-md",children:a.jsx(o,{className:"text-muted-foreground size-4"})}),a.jsx("p",{className:"mt-2 text-sm font-medium",children:e.content.title}),a.jsx("p",{className:"text-muted-foreground mt-0.5 line-clamp-2 text-xs",children:e.content.shortDescription}),a.jsxs("span",{className:"text-muted-foreground mt-2 inline-flex items-center gap-1 text-xs font-medium",children:[e.content.ctaLabel,a.jsx(uh,{className:"size-3"})]})]}),e.action.type==="dialog"&&a.jsx(bV,{promo:e,open:s,onOpenChange:r}),e.action.type==="open-dialog"&&a.jsx(e.action.component,{open:s,onOpenChange:r})]})}const aat={initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:[0,0,.2,1]}},oat={animate:{transition:{staggerChildren:.04}}};function _P({placement:e,maxUnits:t}){const n=rat(e,t),s=Ds(),r=s?{}:aat;return a.jsx(Ue,{initial:!1,children:n.length>0&&a.jsxs(te.section,{"data-slot":"promo-slot",...r,className:"overflow-hidden",children:[e==="dashboard-main"&&a.jsx("h2",{className:"text-muted-foreground mb-3 text-xs font-medium tracking-widest uppercase",children:"Discover"}),a.jsx(te.div,{variants:s?void 0:oat,initial:"initial",animate:"animate",className:e==="dashboard-main"?"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3":"space-y-2",children:n.map(i=>a.jsx(iat,{promo:i,placement:e},i.id))})]},"promo-slot")})}function tue({recentSessions:e,activeSessionId:t,onSessionClick:n,onViewMore:s,isVisible:r}){return a.jsx("div",{role:"tabpanel",id:"sidebar-tabpanel-overview","aria-labelledby":"sidebar-tab-overview",className:Y("h-full",!r&&"hidden"),children:a.jsxs("div",{className:"space-y-4 p-3",children:[e.length>0&&a.jsxs(Nc,{className:"p-0",children:[a.jsx(po,{className:"text-muted-foreground/70 text-[10px] font-medium tracking-wider uppercase",children:"Recent Sessions"}),a.jsx(Xr,{children:e.map(i=>a.jsx(Lr,{children:a.jsx(rP,{variant:"full",session:i,isActive:i.id===t,onClick:()=>n(i.id)})},i.id))}),a.jsx("button",{onClick:s,className:"text-muted-foreground hover:text-foreground mt-1 px-3 text-[11px] transition-colors",children:"View more"})]}),a.jsx(_P,{placement:"agent-sidebar",maxUnits:3})]})})}function lat({agentName:e,onDashboard:t,onNewSession:n}){return a.jsxs(Fle,{className:"border-b p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 py-1",children:[a.jsx(Ni,{"data-slot":"dashboard-link",type:"button",size:"sm",tooltip:"Dashboard","aria-label":"Dashboard",onClick:t,className:"text-muted-foreground hover:bg-accent hover:text-foreground h-7! w-7! shrink-0 justify-center p-0 transition-all duration-100 active:scale-[0.98]",children:a.jsx(UE,{className:"size-(--size-icon-sm)"})}),a.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:e??"Agent"})]}),a.jsx(Xr,{children:a.jsx(Lr,{children:a.jsxs(Ni,{onClick:n,className:"group border-border text-muted-foreground hover:bg-accent hover:text-foreground flex w-full items-center justify-between gap-1.5 rounded-md border px-2.5 py-1.5 text-xs font-medium transition-all duration-100 active:scale-[0.98] disabled:opacity-50",children:[a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(Cs,{className:"size-(--size-icon-sm)"}),"New session"]}),a.jsx(Zr,{className:"shrink-0 opacity-0 transition-opacity duration-150 group-hover:opacity-100",children:lE(oE.NEW_SESSION)})]})})})]})}function cat(e){const t=oce(e),n=t.relay!=="disabled-by-server",s=t.mesh!=="disabled-by-server",{data:r}=Hb(n),{data:i}=ba(void 0,s),o=i==null?void 0:i.agents;return x.useMemo(()=>{const l=r??[],c=o??[];return l.length===0&&c.length===0?"none":l.some(u=>u.status.state==="error")?"error":l.every(u=>u.status.state==="connected")?"ok":"partial"},[r,o])}function uat(){const e=Ud(),{unviewedCount:t,clearBadge:n}=qQe(e),s=we(d=>d.enableTasksNotifications),r=Kh(),i=we(d=>d.setTasksBadgeCount),l=we(d=>d.tasksOpen)||r.isOpen,c=r.open;x.useEffect(()=>{l&&n()},[l,n]);const u=x.useRef(0);x.useEffect(()=>{s&&(t>u.current&&Ye("Tasks run completed",{description:"A scheduled run has finished.",duration:6e3,action:{label:"View history",onClick:()=>c()}}),u.current=t)},[t,s,c]),x.useEffect(()=>(i(t),()=>i(0)),[t,i])}function dat(){const{sidebarActiveTab:e,setSidebarActiveTab:t}=we(),n=we(i=>i.sidebarOpen),s=Od("sidebar.tabs"),r=x.useMemo(()=>s.filter(i=>!i.visibleWhen||i.visibleWhen()).map(i=>i.id),[s]);return x.useEffect(()=>{r.includes(e)||t("overview")},[r,e,t]),x.useEffect(()=>{if(!n)return;const i=o=>{if(!(o.metaKey||o.ctrlKey))return;const c={1:"overview",2:"sessions",3:"schedules",4:"connections"}[o.key];c&&r.includes(c)&&(o.preventDefault(),t(c))};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[n,r,t]),{visibleTabs:r,sidebarActiveTab:e,setSidebarActiveTab:t}}function fat(){const{setActiveSession:e}=bl(),{setSidebarOpen:t}=we(),n=Us(),s=x.useContext(eP),r=x.useCallback((u=!1)=>{if(!n)return;const d=()=>{t(!1),s==null||s.setOpenMobile(!1)};u?setTimeout(d,yo.SIDEBAR_AUTO_CLOSE_MS):d()},[n,t,s]),i=x.useCallback(()=>{e(crypto.randomUUID()),r(!0)},[e,r]),o=x.useCallback(u=>{e(u),r()},[e,r]),l=we(u=>u.setSidebarLevel),c=x.useCallback(()=>{l("dashboard"),r()},[l,r]);return x.useEffect(()=>{const u=d=>{(d.metaKey||d.ctrlKey)&&d.shiftKey&&d.key==="N"&&(d.preventDefault(),i())};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[i]),{handleNewSession:i,handleSessionClick:o,handleDashboard:c}}function hat(){const e=we(_=>_.selectedCwd),{sessions:t,activeSessionId:n}=iI(e),s=A5e(),{data:r}=$b(e),i=oce(e),o=i.tasks!=="disabled-by-server",{data:l=0}=dP(o),c=cat(e);uat();const{visibleTabs:u,sidebarActiveTab:d,setSidebarActiveTab:f}=dat(),{handleNewSession:m,handleSessionClick:g,handleDashboard:y}=fat(),b=je(),S=et(),w=UI(e),C=x.useCallback(async _=>{try{const N=await b.forkSession(_,void 0,e??void 0);await S.invalidateQueries({queryKey:["sessions"]}),g(N.id)}catch(N){Ye.error(N instanceof Error?N.message:"Failed to fork session")}},[b,e,S,g]),T=x.useCallback((_,N)=>{w.mutate({sessionId:_,title:N})},[w]),E=x.useMemo(()=>Owe(t),[t]),j=x.useMemo(()=>t.slice(0,3),[t]);return a.jsxs(a.Fragment,{children:[a.jsx(lat,{agentName:r?nn(r):void 0,onDashboard:y,onNewSession:m}),a.jsx(Lit,{activeTab:d,onTabChange:f,schedulesBadge:l,connectionsStatus:c,visibleTabs:u}),a.jsxs(zle,{"data-testid":"session-list",className:"!overflow-hidden",children:[a.jsx(tue,{recentSessions:j,activeSessionId:n,onSessionClick:g,onViewMore:()=>f("sessions"),isVisible:d==="overview"}),a.jsx("div",{role:"tabpanel",id:"sidebar-tabpanel-sessions","aria-labelledby":"sidebar-tab-sessions",className:Y("h-full",d!=="sessions"&&"hidden"),children:a.jsx(Qce,{activeSessionId:n,groupedSessions:E,warnings:s,onSessionClick:g,onForkSession:C,onRenameSession:T})}),a.jsx("div",{role:"tabpanel",id:"sidebar-tabpanel-schedules","aria-labelledby":"sidebar-tab-schedules",className:Y("h-full",d!=="schedules"&&"hidden"),children:a.jsx(Jce,{toolStatus:i.tasks,agentId:(r==null?void 0:r.id)??null})}),a.jsx("div",{role:"tabpanel",id:"sidebar-tabpanel-connections","aria-labelledby":"sidebar-tab-connections",className:Y("h-full",d!=="connections"&&"hidden"),children:a.jsx(eue,{toolStatus:i,agentId:r==null?void 0:r.id,activeSessionId:n})})]})]})}const mat="npm update -g dorkos",pat="https://github.com/dork-labs/dorkos/releases";function gat({currentVersion:e,latestVersion:t,isFeature:n,onDismiss:s}){const[r,i]=x.useState(!1),o=x.useCallback(()=>{navigator.clipboard.writeText(mat),i(!0),setTimeout(()=>i(!1),yo.COPY_FEEDBACK_MS)},[]);return a.jsxs(te.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},transition:{duration:.2},className:Y("mx-2 mb-1 rounded-md border p-3",n?"border-amber-500/20 bg-amber-500/5":"border-border bg-muted/50"),children:[a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-sm font-medium",children:[a.jsx(mb,{className:"size-3.5"}),a.jsxs("span",{children:["v",e," → v",t]})]}),a.jsx("button",{type:"button",onClick:()=>s(t),className:"text-muted-foreground hover:text-foreground -mt-0.5 shrink-0 transition-colors","aria-label":"Dismiss upgrade notification",children:a.jsx(es,{className:"size-3.5"})})]}),a.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:n?"New features available":"Patch update available"}),a.jsxs("div",{className:"mt-2.5 flex items-center gap-3",children:[a.jsxs("button",{type:"button",onClick:o,className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors","aria-label":"Copy update command",children:[r?a.jsx(Lt,{className:"size-3 text-emerald-500"}):a.jsx($Ae,{className:"size-3"}),"Copy command"]}),n&&a.jsxs("a",{href:pat,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:[a.jsx(fa,{className:"size-3"}),"What's new"]})]})]})}const JA=["light","dark","system"],xat={light:xne,dark:GE,system:LMe};function yat(){const{devtoolsOpen:e,routerDevtoolsOpen:t,toggleDevtools:n,toggleRouterDevtools:s}=we(),{theme:r,setTheme:i}=yb(),o=xat[r],l=je(),c=et(),[u,d]=x.useState(!1),{data:f}=Nrt(),{open:m}=t0(),g=Od("sidebar.footer"),y=x.useMemo(()=>g.filter($=>!$.showInDevOnly||!1),[g]),{data:b}=st({queryKey:["config"],queryFn:()=>l.getConfig(),staleTime:300*1e3}),S=b==null?void 0:b.version,w=(b==null?void 0:b.latestVersion)??null,C=(b==null?void 0:b.isDevMode)??!1,T=x.useMemo(()=>(b==null?void 0:b.dismissedUpgradeVersions)??[],[b==null?void 0:b.dismissedUpgradeVersions]),E=w!==null&&S!==void 0&&qce(w,S),j=E&&mst(w,S),_=E&&T.includes(w),[N,R]=x.useState(!1),O=E&&!_&&(j||N),M=x.useCallback(async $=>{const q=[...T,$];await l.updateConfig({ui:{dismissedUpgradeVersions:q}}),c.invalidateQueries({queryKey:["config"]}),R(!1)},[T,l,c]),L=x.useCallback(()=>{const $=JA.indexOf(r);i(JA[($+1)%JA.length])},[r,i]),P=x.useCallback(()=>{const $=[`DorkOS ${S?`v${S}`:"(unknown version)"}`,"Mode: production",`URL: ${window.location.origin}`,`User Agent: ${navigator.userAgent}`,`Timestamp: ${new Date().toISOString()}`].join(`
|
|
1263
1263
|
`);navigator.clipboard.writeText($)},[S]);return x.useEffect(()=>{},[]),a.jsxs("div",{children:[a.jsx(Ue,{children:O&&a.jsx(gat,{currentVersion:S,latestVersion:w,isFeature:j,onDismiss:M},"upgrade-card")}),a.jsxs("div",{className:"flex items-center px-2 py-1.5",children:[a.jsx("a",{href:"https://dorkos.ai",target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground/50 hover:text-muted-foreground transition-colors duration-150",children:a.jsx(Tv,{variant:"current",size:60})}),a.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[(b==null?void 0:b.tunnel)&&!0&&a.jsxs(a.Fragment,{children:[a.jsxs("button",{onClick:()=>d(!0),className:Y("relative rounded-md p-1 transition-colors duration-150","text-muted-foreground/50 hover:text-muted-foreground"),"aria-label":(f??b.tunnel).connected?`Remote connected: ${new URL((f??b.tunnel).url).hostname}`:"Remote disconnected",children:[a.jsx(ha,{className:"size-(--size-icon-sm)"}),a.jsx("span",{className:Y("absolute top-0.5 right-0.5 size-1.5 rounded-full transition-colors duration-300",(f??b.tunnel).connected?"bg-green-500":"bg-gray-400")})]}),a.jsx(TP,{open:u,onOpenChange:d})]}),y.map($=>{const q=$.id==="theme"?o:$.icon;if($.id==="devtools"){const V=e||t;return a.jsxs(a0,{children:[a.jsx(o0,{asChild:!0,children:a.jsx("button",{className:Y("rounded-md p-1 transition-colors duration-150",V?"text-amber-500":"text-amber-500/60 hover:text-amber-500"),"aria-label":"Developer tools",children:a.jsx(q,{className:"size-(--size-icon-sm)"})})}),a.jsxs(Qh,{side:"top",align:"end",className:"w-52",children:[a.jsx(KI,{children:"Developer Tools"}),a.jsxs(Nr,{onSelect:()=>window.open("/dev","_blank"),children:[a.jsx(ine,{className:"size-(--size-icon-sm)"}),"Dev Playground",a.jsxs("span",{className:"text-muted-foreground/50 ml-auto flex items-center gap-1.5",children:[a.jsx("kbd",{className:"text-[10px]",children:lE(oE.DEV_PLAYGROUND)}),a.jsx(fa,{className:"size-3"})]})]}),a.jsx(rd,{}),a.jsxs(Nr,{onSelect:Q=>{Q.preventDefault(),n()},children:[a.jsx(Lt,{className:Y("size-(--size-icon-sm)",!e&&"invisible")}),"React Query"]}),a.jsxs(Nr,{onSelect:Q=>{Q.preventDefault(),s()},children:[a.jsx(Lt,{className:Y("size-(--size-icon-sm)",!t&&"invisible")}),"Router Inspector"]}),a.jsx(rd,{}),a.jsxs(Nr,{onSelect:P,children:[a.jsx(Vh,{className:"size-(--size-icon-sm)"}),"Copy Debug Info"]}),a.jsx(rd,{}),a.jsxs("div",{className:"text-muted-foreground/50 px-2 py-1 text-[10px]",children:["production"," · ",window.location.host]})]})]},$.id)}const K=$.id==="theme"?L:$.id==="settings"?()=>m():$.onClick,B=$.id==="theme"?`Theme: ${r}. Click to cycle.`:$.label;return a.jsx("button",{onClick:K,className:Y("rounded-md p-1 transition-colors duration-150","text-muted-foreground/50 hover:text-muted-foreground"),"aria-label":B,title:$.id==="theme"?`Theme: ${r}`:void 0,children:a.jsx(q,{className:"size-(--size-icon-sm)"})},$.id)})]})]}),a.jsx("div",{className:Y("-mt-1 px-2 pb-1.5 text-[10px]",E&&!_&&!j?"cursor-pointer":"cursor-default",C?"font-medium text-amber-600 dark:text-amber-400":"text-muted-foreground"),onClick:E&&!_&&!j?()=>R($=>!$):void 0,onKeyDown:E&&!_&&!j?$=>{($.key==="Enter"||$.key===" ")&&($.preventDefault(),R(q=>!q))}:void 0,role:E&&!_&&!j?"button":void 0,tabIndex:E&&!_&&!j?0:void 0,"aria-label":C?"Development build":S?`Version ${S}`:void 0,children:C?"DEV":S?a.jsxs("span",{className:"inline-flex items-center gap-1",children:["v",S," ",a.jsx("span",{className:"text-muted-foreground/50",children:"beta"}),E&&!_&&a.jsx("span",{className:Y("inline-block size-1.5 rounded-full",j?"bg-amber-500":"bg-muted-foreground/50"),"aria-hidden":"true"})]}):null})]})}const vat=[{id:"settings",icon:qa,label:"App Settings",onClick:()=>{},priority:2},{id:"theme",icon:xne,label:"Toggle Theme",onClick:()=>{},priority:3},{id:"devtools",icon:vAe,label:"Devtools",onClick:()=>{},priority:4,showInDevOnly:!0}],bat=[{id:"overview",icon:W5,label:"Overview",component:tue,shortcut:"⌘1",priority:1},{id:"sessions",icon:Rd,label:"Sessions",component:Qce,shortcut:"⌘2",priority:2},{id:"schedules",icon:Pi,label:"Schedules",component:Jce,visibleWhen:()=>!0,shortcut:"⌘3",priority:3},{id:"connections",icon:WE,label:"Connections",component:eue,shortcut:"⌘4",priority:4}];function Sat({children:e,isPinned:t,onTogglePin:n,onOpenProfile:s,onNewSession:r}){return a.jsxs(bT,{children:[a.jsx(ST,{asChild:!0,children:e}),a.jsxs(wT,{className:"w-48",children:[a.jsx(Ec,{onClick:n,children:t?a.jsxs(a.Fragment,{children:[a.jsx(Z5,{className:"mr-2 size-4"}),"Unpin agent"]}):a.jsxs(a.Fragment,{children:[a.jsx(gb,{className:"mr-2 size-4"}),"Pin agent"]})}),a.jsx(dC,{}),a.jsxs(Ec,{onClick:s,children:[a.jsx(Md,{className:"mr-2 size-4"}),"Agent profile"]}),a.jsx(dC,{}),a.jsxs(Ec,{onClick:r,children:[a.jsx(Cs,{className:"mr-2 size-4"}),"New session"]})]})]})}const wat={streaming:"bg-green-500",pendingApproval:"bg-amber-500",error:"bg-destructive",unseen:"bg-blue-500",idle:null};function kat({status:e,label:t}){const n=wat[e];return n?a.jsx("span",{className:Y("size-1.5 shrink-0 rounded-full",n),role:"status","aria-label":t}):null}const Cat=3,Eat={expanded:{height:"auto",transition:{type:"spring",stiffness:500,damping:35,mass:.8}},collapsed:{height:0,transition:{type:"spring",stiffness:600,damping:40,mass:.8}}},hw=.06,wV=.04;function kV({path:e,agent:t,displayName:n,isActive:s,isExpanded:r,isPinned:i,onSelect:o,onToggleExpand:l,onTogglePin:c,onOpenProfile:u,sessions:d,isLoadingSessions:f,activeSessionId:m,onSessionClick:g,onNewSession:y,onForkSession:b,onRenameSession:S}){const w=Us(),C=qT(t,e),T=n??nn(t,e.split("/").pop()??"Agent"),E=d.slice(0,Cat),j=s&&r,_=x.useMemo(()=>d.map(P=>P.id),[d]),N=DFe(_,e),R=N.kind==="idle"&&s?C.color:N.color,{animate:O,transition:M}=HI(N.pulse,N.color,N.dimColor),L=x.useCallback(()=>{s?l():o()},[s,o,l]);return a.jsx(Lr,{children:a.jsxs(te.div,{animate:O,transition:M,style:N.pulse?void 0:{borderLeftColor:R},className:"rounded-md border-l-2",children:[a.jsx(Sat,{isPinned:i,onTogglePin:c,onOpenProfile:u,onNewSession:y,children:a.jsxs("div",{"data-slot":"agent-list-item",onClick:L,className:Y("flex w-full cursor-pointer items-center gap-2 rounded-md px-2.5 py-1.5 text-xs font-medium transition-all duration-100 active:scale-[0.98]",s?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[a.jsx("span",{className:"min-w-0 flex-1",children:a.jsx(bD,{...C,name:T,size:"xs"})}),a.jsx(kat,{status:N.kind,label:N.label}),a.jsxs(a0,{children:[a.jsx(o0,{asChild:!0,children:a.jsx(WXe,{showOnHover:!w,"aria-label":"Agent actions",onClick:P=>P.stopPropagation(),children:a.jsx(Xte,{className:"size-4"})})}),a.jsxs(Qh,{side:"right",align:"start",className:"w-48",children:[a.jsx(Nr,{onClick:c,children:i?a.jsxs(a.Fragment,{children:[a.jsx(Z5,{className:"mr-2 size-4"}),"Unpin agent"]}):a.jsxs(a.Fragment,{children:[a.jsx(gb,{className:"mr-2 size-4"}),"Pin agent"]})}),a.jsx(rd,{}),a.jsxs(Nr,{onClick:u,children:[a.jsx(Md,{className:"mr-2 size-4"}),"Agent profile"]}),a.jsx(rd,{}),a.jsxs(Nr,{onClick:y,children:[a.jsx(Cs,{className:"mr-2 size-4"}),"New session"]})]})]})]})}),a.jsx(te.div,{animate:j?"expanded":"collapsed",initial:!1,variants:Eat,className:Y("overflow-hidden",!j&&"pointer-events-none"),"aria-hidden":!j,children:a.jsx("div",{className:"bg-accent/30 space-y-0.5 py-1 pl-3",children:a.jsxs(Ue,{children:[j&&f&&E.length===0&&a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1,transition:{duration:.2,delay:hw}},exit:{opacity:0,transition:{duration:.1}},children:a.jsx("div",{className:"text-muted-foreground/30 px-2.5 py-1.5 text-[11px]",children:a.jsx("span",{className:"animate-pulse",children:"Loading…"})})},"loading"),j&&!f&&E.length===0&&a.jsx(te.div,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0,transition:{opacity:{duration:.15,ease:[0,0,.2,1]},y:{type:"spring",stiffness:500,damping:30},delay:hw}},exit:{opacity:0,y:-6,transition:{duration:.1}},children:a.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5",children:[a.jsx("span",{className:"bg-primary/10 text-primary rounded px-1.5 py-0.5 text-[10px] font-semibold tabular-nums",children:"#1"}),a.jsx("span",{className:"text-muted-foreground/50 text-[11px]",children:"First session"})]})},"first-session"),j&&E.map((P,$)=>a.jsx(te.div,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0,transition:{opacity:{duration:.15,ease:[0,0,.2,1]},y:{type:"spring",stiffness:500,damping:30},delay:hw+$*wV}},exit:{opacity:0,y:-6,transition:{duration:.1,delay:(E.length-1-$)*.025}},children:a.jsx(rP,{variant:"compact",session:P,isActive:P.id===m,onClick:()=>g(P.id),onFork:b,onRename:S})},P.id)),j&&E.length>0&&a.jsx(te.div,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0,transition:{opacity:{duration:.15,ease:[0,0,.2,1]},y:{type:"spring",stiffness:500,damping:30},delay:hw+E.length*wV}},exit:{opacity:0,y:-6,transition:{duration:.1}},children:a.jsxs("button",{type:"button",onClick:P=>{P.stopPropagation(),y()},className:"text-muted-foreground hover:bg-accent hover:text-foreground flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-xs transition-colors duration-100",children:[a.jsx(Cs,{className:"size-(--size-icon-xs)"}),"New session"]})},"new-session-btn")]})})})]})})}function Tat(){const[e,t]=x.useState(!1),n=Hn();return a.jsxs(c0,{open:e,onOpenChange:t,children:[a.jsx(u0,{asChild:!0,children:a.jsx(ik,{"aria-label":"Add agent",children:a.jsx(Cs,{})})}),a.jsxs(d0,{side:"right",align:"start",className:"w-48 p-1",children:[a.jsxs("button",{type:"button",onClick:()=>{t(!1),ud.getState().open()},className:"hover:bg-accent hover:text-accent-foreground flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm",children:[a.jsx(Cs,{className:"size-4"}),"Create agent"]}),a.jsxs("button",{type:"button",onClick:()=>{t(!1),ud.getState().open("import")},className:"hover:bg-accent hover:text-accent-foreground flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm",children:[a.jsx(QM,{className:"size-4"}),"Import project"]}),a.jsxs("button",{type:"button",onClick:()=>{t(!1),n({to:"/marketplace"})},className:"hover:bg-accent hover:text-accent-foreground flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm",children:[a.jsx(gne,{className:"size-4"}),"Browse Marketplace"]})]})]})}function _at({onAddAgent:e}){return a.jsxs("div",{className:"border-border/50 mx-1 mt-2 rounded-lg border border-dashed p-3",children:[a.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:"Add more agents to your fleet. Each agent can be configured with its own tools, personality, and project context."}),a.jsxs("button",{type:"button",onClick:e,className:"text-muted-foreground hover:text-foreground mt-2 flex items-center gap-1.5 text-xs font-medium transition-colors",children:[a.jsx(Cs,{className:"size-3.5"}),"Add agent"]})]})}function Nat(){var G,W;const e=Hn(),t=Vv({select:F=>F.location.pathname}),n=et(),s=je(),r=we(F=>F.selectedCwd),i=we(F=>F.setGlobalPaletteOpen);we(F=>F.setSidebarLevel);const o=we(F=>F.pinnedAgentPaths),l=we(F=>F.pinAgent),c=we(F=>F.unpinAgent),u=we(F=>F.setRightPanelOpen),d=we(F=>F.setActiveRightPanelTab),{data:f}=st({queryKey:["config"],queryFn:()=>s.getConfig(),staleTime:3e4}),m=((G=f==null?void 0:f.agents)==null?void 0:G.defaultAgent)??"dorkbot",y=`${((W=f==null?void 0:f.agents)==null?void 0:W.defaultDirectory)??"~/.dork/agents"}/${m}`,{data:b}=Kb(),S=x.useMemo(()=>((b==null?void 0:b.agents)??[]).map(F=>F.projectPath),[b]),{data:w}=Jle(S),C=x.useMemo(()=>{const F=new Map,X=new Map;for(const J of S){const ae=nn(w==null?void 0:w[J],J.split("/").pop()??"Agent"),oe=X.get(ae)??[];oe.push(J),X.set(ae,oe)}for(const[J,ae]of X){if(ae.length===1){F.set(ae[0],J);continue}const oe=ae.map(de=>de.split("/").filter(Boolean));for(const[de,me]of ae.entries()){const Re=oe[de];let Fe="";for(let Le=2;Le<Re.length;Le++){const Xe=Re[Re.length-Le];if(oe.every((Mt,Ft)=>Ft===de||Mt.length<Le||Mt[Mt.length-Le]!==Xe)){Fe=Xe;break}}F.set(me,Fe?`${J} (${Fe})`:J)}}return F},[S,w]),T=x.useMemo(()=>[...S].sort((F,X)=>{const J=(C.get(F)??"").toLowerCase(),ae=(C.get(X)??"").toLowerCase();return J.localeCompare(ae)}),[S,C]),E=x.useMemo(()=>{const F=new Set(T);return o.filter(X=>F.has(X))},[o,T]),j=x.useMemo(()=>{const F=new Set(E);return T.filter(X=>!F.has(X))},[T,E]);x.useEffect(()=>{o.length===0&&y&&T.includes(y)&&l(y)},[o.length,y,T,l]);const{sessions:_,activeSessionId:N,isLoading:R}=iI(r),O=x.useMemo(()=>_.slice(0,3),[_]),[M,L]=x.useState(r);x.useEffect(()=>{L(r)},[r]);const P=x.useCallback(F=>{var ae;const X=n.getQueryData(["sessions",F]),J=((ae=X==null?void 0:X[0])==null?void 0:ae.id)??crypto.randomUUID();e({to:"/session",search:{dir:F,session:J}})},[e,n]),$=x.useCallback(F=>{e({to:"/session",search:X=>({...X,session:F})})},[e]),q=x.useCallback(()=>{e({to:"/session",search:{dir:r??void 0,session:crypto.randomUUID()}})},[e,r]),K=x.useCallback(F=>{L(X=>X===F?null:F)},[]),B=x.useCallback(F=>{o.includes(F)?c(F):l(F)},[o,l,c]),V=x.useCallback(F=>{yd.getState().openHub(F),u(!0),d("agent-hub")},[u,d]),Q=x.useCallback(async F=>{try{const X=await s.forkSession(F,void 0,r??void 0);await n.invalidateQueries({queryKey:["sessions"]}),e({to:"/session",search:J=>({...J,session:X.id})})}catch(X){Ye.error(X instanceof Error?X.message:"Failed to fork session")}},[s,r,n,e]),re=UI(r),U=x.useCallback((F,X)=>{re.mutate({sessionId:F,title:X})},[re]);return a.jsxs(a.Fragment,{children:[a.jsx(Fle,{className:"border-b p-3",children:a.jsxs(Xr,{children:[a.jsx(op,{icon:W5,label:"Dashboard",isActive:t==="/",onClick:()=>e({to:"/"})}),a.jsx(op,{icon:fb,label:"Activity",isActive:t==="/activity",onClick:()=>e({to:"/activity"})}),a.jsx(op,{icon:e0,label:"Agents",isActive:t==="/agents",onClick:()=>e({to:"/agents"})}),a.jsx(op,{icon:Uc,label:"Tasks",isActive:t==="/tasks",onClick:()=>e({to:"/tasks"})}),a.jsx(op,{icon:ene,label:"Workspaces",isActive:t==="/workspaces",onClick:()=>e({to:"/workspaces"})}),a.jsx(op,{icon:gne,label:"Marketplace",isActive:t==="/marketplace"||t.startsWith("/marketplace/"),onClick:()=>e({to:"/marketplace"})}),a.jsx(Lr,{children:a.jsxs(Ni,{onClick:()=>i(!0),className:"group text-muted-foreground hover:bg-accent hover:text-foreground flex w-full items-center justify-between gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium",children:[a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(pa,{className:"size-(--size-icon-sm)"}),"Search"]}),a.jsx(Zr,{className:"shrink-0 opacity-0 transition-opacity duration-150 group-hover:opacity-100",children:lE(oE.COMMAND_PALETTE)})]})})]})}),a.jsxs(zle,{className:"p-3",children:[a.jsxs(Nc,{children:[a.jsx(po,{className:"text-muted-foreground/70 text-[10px] font-medium tracking-wider uppercase",children:"Agents"}),a.jsx(Tat,{}),E.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(po,{className:"text-muted-foreground/50 mt-1 text-[9px] font-medium tracking-wider uppercase",children:"Pinned"}),a.jsx(Xr,{children:E.map(F=>{const X=r===F&&t==="/session";return a.jsx(kV,{path:F,agent:(w==null?void 0:w[F])??null,displayName:C.get(F),isActive:X,isExpanded:M===F,isPinned:!0,onSelect:()=>P(F),onToggleExpand:()=>K(F),onTogglePin:()=>B(F),onOpenProfile:()=>V(F),sessions:X?O:[],isLoadingSessions:X&&R,activeSessionId:N,onSessionClick:$,onNewSession:q,onForkSession:Q,onRenameSession:U},`pinned-${F}`)})})]}),E.length>0&&j.length>0&&a.jsx(po,{className:"text-muted-foreground/50 mt-3 text-[9px] font-medium tracking-wider uppercase",children:"Other"}),a.jsx(Xr,{children:(E.length>0?j:T).map(F=>{const X=r===F&&t==="/session";return a.jsx(kV,{path:F,agent:(w==null?void 0:w[F])??null,displayName:C.get(F),isActive:X,isExpanded:M===F,isPinned:o.includes(F),onSelect:()=>P(F),onToggleExpand:()=>K(F),onTogglePin:()=>B(F),onOpenProfile:()=>V(F),sessions:X?O:[],isLoadingSessions:X&&R,activeSessionId:N,onSessionClick:$,onNewSession:q,onForkSession:Q,onRenameSession:U},F)})}),T.length<=2&&a.jsx(_at,{onAddAgent:()=>ud.getState().open()}),T.length>=3&&T.length<=4&&a.jsxs("button",{type:"button",onClick:()=>ud.getState().open(),className:"text-muted-foreground hover:text-foreground mt-1 flex items-center gap-1.5 px-2 text-xs font-medium transition-colors",children:[a.jsx(Cs,{className:"size-3.5"}),"Add agent"]})]}),a.jsx(_P,{placement:"dashboard-sidebar",maxUnits:3})]})]})}function op({icon:e,label:t,isActive:n,onClick:s}){return a.jsx(Lr,{children:a.jsxs(Ni,{isActive:n,onClick:s,className:Y("relative flex w-full items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium",n&&"before:bg-primary before:absolute before:inset-y-1 before:left-0 before:w-0.5 before:rounded-full"),children:[a.jsx(e,{className:Y("size-(--size-icon-sm) transition-colors duration-150",!n&&"text-muted-foreground group-hover/menu-item:text-sidebar-accent-foreground")}),t]})})}function nue(){const e=we(t=>t.setGlobalPaletteOpen);return a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx(te.button,{onClick:()=>e(!0),className:"text-muted-foreground hover:text-foreground flex h-7 w-7 items-center justify-center rounded-md transition-colors",whileHover:{scale:1.1},whileTap:{scale:.93},transition:{type:"spring",stiffness:600,damping:35},"aria-label":"Open command palette",children:a.jsx(pa,{className:"size-4"})})}),a.jsxs(yn,{side:"bottom",children:["Search ",a.jsx(Zr,{children:zg?"⌘K":"Ctrl+K"})]})]})}function C0({title:e,children:t,actions:n}){return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-sm font-medium",children:e}),t?a.jsx("div",{className:"ml-3 flex min-w-0 flex-1 items-center",children:t}):a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n,a.jsx(nue,{})]})]})}function jat({agentName:e}){return a.jsxs(a.Fragment,{children:[a.jsxs("nav",{"aria-label":"Breadcrumb",className:"flex items-center gap-1 text-sm",children:[a.jsx(QC,{to:"/agents",className:"text-muted-foreground hover:text-foreground transition-colors",children:"Agents"}),e&&a.jsxs(a.Fragment,{children:[a.jsx(Rs,{className:"text-muted-foreground/50 size-3","aria-hidden":!0}),a.jsx("span",{className:"font-medium",children:e})]}),a.jsx(Rs,{className:"text-muted-foreground/50 size-3","aria-hidden":!0}),a.jsx("span",{className:"text-muted-foreground",children:"Session"})]}),a.jsx("div",{className:"flex-1"}),a.jsx("div",{className:"flex shrink-0 items-center gap-2",children:a.jsx(nue,{})})]})}const Aat={healthy:"bg-muted-foreground/30",degraded:"bg-amber-500",error:"bg-red-500"},CV={healthy:"All systems operational",degraded:"Some adapters disconnected",error:"Issues detected — check Needs Attention"};function Rat({state:e}){return a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx("span",{className:Y("size-2 shrink-0 rounded-full",Aat[e]),"aria-label":CV[e]})}),a.jsx(yn,{side:"bottom",className:"text-xs",children:CV[e]})]})}const Mat=1440*60*1e3;function Dat(){const{data:e}=k0({status:"failed"}),{data:t}=w0(),{data:n}=mP(),{data:s}=Hb(),r=Gh();return x.useMemo(()=>{const i=r-Mat,o=e==null?void 0:e.some(d=>new Date(d.createdAt).getTime()>i),l=t==null?void 0:t.some(d=>d.count>0),c=((n==null?void 0:n.unreachableCount)??0)>0;return o||l||c?"error":(s==null?void 0:s.some(d=>{var f;return((f=d.status)==null?void 0:f.state)!=="connected"}))?"degraded":"healthy"},[r,e,t,n,s])}function EV(){const e=Dat();return a.jsx(C0,{title:"Dashboard",children:a.jsx(Rat,{state:e})})}const TV=[{mode:"list",label:"Agents",icon:Y5},{mode:"topology",label:"Topology",icon:ha}],_V=[{mode:"denied",label:"Denied",icon:F3e},{mode:"access",label:"Access",icon:pb}];function Oat({viewMode:e}){const t=ud(i=>i.open),n=Hn(),s=Us();function r(i){n({to:"/agents",search:o=>({...o,view:i})})}return a.jsxs(C0,{title:"Agents",actions:a.jsxs(ge,{variant:"outline",size:"xs",onClick:()=>t(),children:[a.jsx(Cs,{}),"New Agent"]}),children:[!s&&a.jsxs("div",{className:"bg-muted flex items-center rounded-md p-0.5",children:[TV.map(({mode:i,label:o})=>a.jsx("button",{type:"button",onClick:()=>r(i),className:Y("text-xs font-medium transition-colors",e===i?"bg-background text-foreground rounded-md px-3 py-1 shadow-sm":"text-muted-foreground hover:text-foreground px-3 py-1"),children:o},i)),a.jsx("div",{className:"mx-1 h-4 border-l"}),_V.map(({mode:i,label:o})=>a.jsx("button",{type:"button",onClick:()=>r(i),className:Y("text-xs font-medium transition-colors",e===i?"bg-background text-foreground rounded-md px-3 py-1 shadow-sm":"text-muted-foreground hover:text-foreground px-3 py-1"),children:o},i))]}),s&&a.jsxs(On,{value:e,onValueChange:i=>r(i),children:[a.jsx(_n,{className:"w-[140px]",children:a.jsx(In,{})}),a.jsx(Nn,{children:[...TV,..._V].map(({mode:i,label:o})=>a.jsx(mt,{value:i,children:o},i))})]})]})}const Iat=["activity"];function Pat(e={}){const t=je();return Ppe({queryKey:[...Iat,e],queryFn:({pageParam:n})=>t.listActivityEvents({...e,limit:50,before:n}),initialPageParam:void 0,getNextPageParam:n=>n.nextCursor??void 0,staleTime:3e4,refetchOnWindowFocus:!0})}const NV=["categories","actorType","actorId","since"];function NP(){const e=Hn(),t=ml({strict:!1}),n={categories:t.categories,actorType:t.actorType,actorId:t.actorId,since:t.since},s=NV.some(f=>t[f]!==void 0),r={};n.categories&&(r.categories=n.categories),n.actorType&&(r.actorType=n.actorType),n.actorId&&(r.actorId=n.actorId),n.since&&(r.since=n.since);const i=x.useCallback(f=>{e({search:f})},[e]),o=x.useCallback(f=>{i(m=>{const g=m.categories?m.categories.split(","):[],y=g.includes(f)?g.filter(b=>b!==f):[...g,f];return{...m,categories:y.length>0?y.join(","):void 0}})},[i]),l=x.useCallback(f=>{i(m=>({...m,actorType:f}))},[i]),c=x.useCallback(f=>{i(m=>({...m,actorId:f}))},[i]),u=x.useCallback(f=>{i(m=>({...m,since:f}))},[i]),d=x.useCallback(()=>{i(f=>{const m={...f};for(const g of NV)delete m[g];return m})},[i]);return{filters:n,queryFilters:r,isFiltered:s,toggleCategory:o,setActorType:l,setActorId:c,setSince:u,clearAll:d}}const jV="dorkos:lastVisitedActivity";function Lat(){const[e]=x.useState(()=>localStorage.getItem(jV)),t=x.useRef(!1);return x.useEffect(()=>{t.current||(localStorage.setItem(jV,new Date().toISOString()),t.current=!0)},[]),e}function Fat(e){const t=x.useRef(null),n=x.useCallback(s=>{var l,c,u;const r=t.current;if(!r)return;const i=r.querySelectorAll("[data-activity-row]"),o=Array.from(i).findIndex(d=>d===document.activeElement||d.contains(document.activeElement));switch(s.key){case"ArrowDown":{s.preventDefault();const d=Math.min(o+1,i.length-1);(l=i[d])==null||l.focus();break}case"ArrowUp":{s.preventDefault();const d=Math.max(o-1,0);(c=i[d])==null||c.focus();break}case"Escape":{(u=document.activeElement)==null||u.blur();break}}},[e]);return{containerRef:t,handleKeyDown:n}}const zat=["Today","Yesterday","This Week","Earlier"];function Bat(e,t){const n=new Map;for(const s of e){const r=$at(new Date(s.occurredAt),t),i=n.get(r)??[];i.push(s),n.set(r,i)}return zat.filter(s=>n.has(s)).map(s=>({label:s,items:n.get(s)}))}function $at(e,t){const n=new Date(t);n.setHours(0,0,0,0);const s=new Date(n);s.setDate(s.getDate()-1);const r=new Date(n);return r.setDate(r.getDate()-r.getDay()),e>=n?"Today":e>=s?"Yesterday":e>=r?"This Week":"Earlier"}const jP={tasks:{text:"text-purple-500",bg:"bg-purple-500/10",label:"Tasks"},relay:{text:"text-teal-500",bg:"bg-teal-500/10",label:"Relay"},agent:{text:"text-indigo-500",bg:"bg-indigo-500/10",label:"Agent"},config:{text:"text-amber-500",bg:"bg-amber-500/10",label:"Config"},system:{text:"text-neutral-500",bg:"bg-neutral-500/10",label:"System"}},Hat={user:{text:"text-muted-foreground"},agent:{text:"text-foreground"},system:{icon:qa,text:"text-neutral-500"},tasks:{icon:Pi,text:"text-purple-500"}};function Uat({actorType:e,actorLabel:t,agentColor:n,className:s}){const r=Hat[e],i=r.icon;return e==="user"?a.jsx("span",{"data-slot":"actor-badge",className:Y("inline-flex items-center rounded-full border px-2 py-0.5 text-xs font-medium","border-border text-muted-foreground",s),children:t}):e==="agent"?a.jsxs("span",{"data-slot":"actor-badge",className:Y("inline-flex items-center gap-1.5 text-xs font-medium",r.text,s),children:[a.jsx("span",{className:"size-2 shrink-0 rounded-full",style:n?{backgroundColor:n}:void 0,"aria-hidden":!0}),a.jsx("span",{className:"truncate",children:t})]}):a.jsxs("span",{"data-slot":"actor-badge",className:Y("inline-flex items-center gap-1 text-xs font-medium",r.text,s),children:[i&&a.jsx(i,{className:"size-3 shrink-0","aria-hidden":!0}),a.jsx("span",{children:t})]})}function Vat(e,t=new Date){const n=new Date(e),s=new Date(t);s.setHours(0,0,0,0);const r=new Date(s);r.setDate(r.getDate()-1);const i=new Date(s);i.setDate(i.getDate()-i.getDay());const o=n.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});return n>=s?o:n>=r?`Yesterday ${o}`:n>=i?`${n.toLocaleDateString("en-US",{weekday:"long"})} ${o}`:n.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function sue({item:e,className:t}){const n=Hn(),s=Vat(e.occurredAt);return a.jsxs(Tc,{"data-slot":"activity-row","data-activity-row":!0,tabIndex:0,onKeyDown:r=>{r.key==="Enter"&&e.linkPath&&n({to:e.linkPath,replace:!1})},className:Y("focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none",t),children:[a.jsx(ra,{className:"w-28 py-1.5 pr-0 pl-2 max-sm:hidden",children:a.jsx("span",{className:"text-muted-foreground text-xs tabular-nums",children:s})}),a.jsx(ra,{className:"w-24 py-1.5 pr-0 max-sm:hidden",children:a.jsx(Uat,{actorType:e.actorType,actorLabel:e.actorLabel})}),a.jsx(ra,{className:"max-w-0 py-1.5 max-sm:pl-2",children:a.jsxs("span",{className:"text-foreground/80 block truncate text-sm",children:[a.jsx("span",{className:"text-muted-foreground mr-1 text-xs font-medium sm:hidden",children:e.actorLabel}),e.summary]})}),a.jsx(ra,{className:"w-16 py-1.5 pr-2 text-right max-sm:w-10",children:e.linkPath&&a.jsx(ge,{variant:"ghost",size:"sm",className:"h-6 min-h-[44px] px-2 text-xs sm:min-h-0",onClick:()=>n({to:e.linkPath,replace:!1}),children:"Open →"})})]})}function qat({label:e,className:t}){return a.jsx("div",{"data-slot":"activity-group-header",className:Y("sticky top-0 z-10 -mx-4 px-4 py-2","bg-background/95 backdrop-blur-sm",t),children:a.jsx("h3",{className:"text-muted-foreground text-xs font-medium tracking-wider uppercase",children:e})})}const Gat=["tasks","relay","agent","config","system"];function Kat({category:e,isActive:t,onToggle:n}){const s=jP[e];return a.jsx(te.button,{type:"button",layout:!0,onClick:n,"aria-pressed":t,transition:{duration:.15},className:Y("inline-flex h-6 items-center rounded-full px-2.5 text-xs font-medium transition-colors","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:outline-none",t?Y(s.bg,s.text):"text-muted-foreground hover:bg-muted hover:text-foreground"),children:s.label})}function Wat({isActive:e,onClick:t}){return a.jsx(te.button,{type:"button",layout:!0,onClick:t,"aria-pressed":e,transition:{duration:.15},className:Y("inline-flex h-6 items-center rounded-full px-2.5 text-xs font-medium transition-colors","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:outline-none",e?"bg-foreground text-background":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:"All"})}function Yat({className:e}){const{filters:t,isFiltered:n,toggleCategory:s,clearAll:r}=NP(),i=new Set(t.categories?t.categories.split(","):[]),o=()=>{n&&r()};return a.jsxs("div",{"data-slot":"activity-filter-bar",className:Y("flex items-center gap-1",e),children:[a.jsx(Wat,{isActive:!n,onClick:o}),Gat.map(l=>a.jsx(Kat,{category:l,isActive:i.has(l),onToggle:()=>s(l)},l)),a.jsx(Ue,{children:n&&a.jsx(te.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.15},children:a.jsxs(ge,{variant:"ghost",size:"xs",className:"ml-1",onClick:r,children:[a.jsx(es,{"aria-hidden":!0}),"Clear"]})},"clear-filters")})]})}function Zat({isFiltered:e=!1,className:t}){const{filters:n,clearAll:s}=NP();return e?a.jsx(Qat,{categories:n.categories,onClear:s,className:t}):a.jsx(Xat,{className:t})}function Xat({className:e}){return a.jsxs("div",{"data-slot":"activity-empty-state",className:Y("flex flex-col items-center justify-center gap-3 py-16 text-center",e),children:[a.jsx("div",{className:"bg-muted rounded-full p-4",children:a.jsx(fb,{className:"text-muted-foreground size-6","aria-hidden":!0})}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-foreground text-sm font-medium",children:"No activity yet"}),a.jsx("p",{className:"text-muted-foreground max-w-xs text-sm",children:"Events will appear here as your agents work."})]})]})}function Qat({categories:e,onClear:t,className:n}){const s=Jat(e);return a.jsxs("div",{"data-slot":"activity-empty-state",className:Y("flex flex-col items-center justify-center gap-3 py-16 text-center",n),children:[a.jsx("div",{className:"bg-muted rounded-full p-4",children:a.jsx(fb,{className:"text-muted-foreground size-6","aria-hidden":!0})}),a.jsxs("div",{className:"space-y-1",children:[a.jsxs("p",{className:"text-foreground text-sm font-medium",children:["No ",s," events found"]}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Try adjusting your filters."})]}),a.jsx(ge,{variant:"outline",size:"sm",onClick:t,children:"Clear filters"})]})}function Jat(e){if(!e)return"matching";const n=e.split(",").map(i=>{var o;return((o=jP[i])==null?void 0:o.label)??i});if(n.length===1)return n[0];const s=n[n.length-1];return`${n.slice(0,-1).join(", ")} or ${s}`}function eot(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/36e5);return n<1?"recently":n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}function tot(e,t){const n=new Date(t),s={};for(const r of e)new Date(r.occurredAt)>n&&(s[r.category]=(s[r.category]??0)+1);return s}function not(e){const t={tasks:"Tasks run",relay:"Relay event",agent:"Agent update",config:"Config change",system:"System event"};return Object.entries(e).filter(([,n])=>n>0).map(([n,s])=>{const r=t[n];return`${s} ${s===1?r:`${r}s`}`}).join(" · ")}function sot({lastVisitedAt:e,items:t,className:n}){if(!e)return null;const s=tot(t,e);if(Object.values(s).reduce((l,c)=>l+(c??0),0)===0)return null;const i=eot(e),o=not(s);return a.jsxs(te.div,{"data-slot":"activity-since-last-visit",initial:{opacity:0,y:-6},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},className:Y("rounded-lg border px-4 py-3","bg-card border-border",n),children:[a.jsxs("p",{className:"text-muted-foreground text-xs",children:[a.jsx("span",{className:"text-foreground font-medium",children:"Since your last visit"})," ",a.jsxs("span",{children:["(",i,")"]})]}),a.jsx("p",{className:"text-foreground/80 mt-0.5 text-sm",children:o}),a.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:Object.keys(s).map(l=>{const c=s[l];if(!c)return null;const u=jP[l];return a.jsxs("span",{className:Y("inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium",u.bg,u.text),children:[c," ",u.label]},l)})})]})}function rot(){return a.jsx(C0,{title:"Activity",children:a.jsx(Yat,{})})}function iot(){const e=Ud(),t=Ub(n=>n.openBlank);return a.jsx(C0,{title:"Tasks",actions:e?a.jsxs(ge,{variant:"outline",size:"xs",onClick:t,children:[a.jsx(Cs,{}),"New Task"]}):void 0})}function aot(){return a.jsx(C0,{title:"Marketplace"})}function oot(){return a.jsx(C0,{title:"Marketplace Sources"})}const AP="dorkos:agent-frecency-v2",rue=10,lot=[{maxAgeMs:14400*1e3,points:100},{maxAgeMs:1440*60*1e3,points:80},{maxAgeMs:4320*60*1e3,points:60},{maxAgeMs:10080*60*1e3,points:40},{maxAgeMs:720*60*60*1e3,points:20},{maxAgeMs:2160*60*60*1e3,points:10}];function cot(e,t){const n=t-e;for(const s of lot)if(n<=s.maxAgeMs)return s.points;return 0}function uot(e,t=Date.now()){if(e.timestamps.length===0)return 0;const n=e.timestamps.reduce((r,i)=>r+cot(i,t),0),s=Math.min(e.timestamps.length,rue);return e.totalCount*n/s}function dot(){try{const e=localStorage.getItem(AP);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function fot(e){try{localStorage.setItem(AP,JSON.stringify(e))}catch{}}let lk=[];function hot(e){return lk.push(e),()=>{lk=lk.filter(t=>t!==e)}}function mot(){lk.forEach(e=>e())}function pot(){try{return localStorage.getItem(AP)??"[]"}catch{return"[]"}}function iue(){const e=x.useSyncExternalStore(hot,pot,()=>"[]"),t=x.useMemo(()=>{try{const r=JSON.parse(e);return Array.isArray(r)?r:[]}catch{return[]}},[e]),n=x.useCallback(r=>{const i=dot(),o=Date.now(),l=i.find(u=>u.agentId===r);let c;l?c=i.map(u=>u.agentId===r?{...u,timestamps:[o,...u.timestamps].slice(0,rue),totalCount:u.totalCount+1}:u):c=[...i,{agentId:r,timestamps:[o],totalCount:1}],fot(c),mot()},[]),s=x.useCallback(r=>{const i=Date.now(),o=new Map;for(const l of t)o.set(l.agentId,uot(l,i));return[...r].sort((l,c)=>{const u=o.get(l)??-1,d=o.get(c)??-1;return u===d?l.localeCompare(c):d-u})},[t]);return{entries:t,recordUsage:n,getSortedAgentIds:s}}const got=5,xot=3,yot=3600*1e3;function vot(e){const{data:t,isLoading:n}=Kb(),{data:s}=uce(),{getSortedAgentIds:r}=iue(),{sessions:i}=bl(),{data:o}=dP(),l=we(w=>w.previousCwd),c=Gh(),u=Od("command-palette.items"),d=x.useMemo(()=>u.filter(w=>w.category==="feature"),[u]),f=x.useMemo(()=>u.filter(w=>w.category==="quick-action"),[u]),m=x.useMemo(()=>(t==null?void 0:t.agents)??[],[t]),g=x.useMemo(()=>{if(m.length===0)return[];const w=new Map(m.map(j=>[j.id,j])),C=r(m.map(j=>j.id)),T=e?m.find(j=>j.projectPath===e):null,E=[];T&&E.push(T);for(const j of C){if(E.length>=got)break;const _=w.get(j);_&&_.id!==(T==null?void 0:T.id)&&E.push(_)}return E},[m,r,e]),y=x.useMemo(()=>s?s.commands.map(w=>({name:w.fullCommand,description:w.description})):[],[s]),b=x.useMemo(()=>{const w=[];for(const C of m)w.push({id:C.id,name:C.name,type:"agent",keywords:[C.projectPath,C.id],data:C});for(const C of d)w.push({id:C.id,name:C.label,type:"feature",data:C});for(const C of y)w.push({id:`cmd-${C.name}`,name:C.name,type:"command",keywords:C.description?[C.description]:void 0,data:C});for(const C of f)w.push({id:C.id,name:C.label,type:"quick-action",data:C});return w},[m,y,d,f]),S=x.useMemo(()=>{const w=[];if(i&&e){const C=rI(i,e);if(C.length>0){const T=C[0];new Date(T.updatedAt??T.createdAt??"").getTime()>c-yot&&w.push({id:"suggestion-continue",label:`Continue: ${Cg(T.title)}`,description:"Resume your most recent session",icon:"Clock",action:`continueSession:${T.id}`})}}if(o&&o>0&&w.push({id:"suggestion-tasks",label:`${o} active Tasks run${o>1?"s":""}`,description:"View running schedules",icon:"Clock",action:"openTasks"}),l&&l!==e){const C=m.find(T=>T.projectPath===l);C&&w.push({id:"suggestion-switchback",label:`Switch back to ${C.name}`,description:Mc(l),icon:"FolderOpen",action:`switchAgent:${C.id}`})}return w.slice(0,xot)},[c,i,e,o,l,m]);return{recentAgents:g,allAgents:m,features:d,commands:y,quickActions:f,searchableItems:b,suggestions:S,isLoading:n}}function bot(){const e=we(o=>o.toggleGlobalPalette),t=we(o=>o.setGlobalPaletteOpen),n=we(o=>o.globalPaletteOpen),{close:s}=t0(),{close:r}=Kh(),{close:i}=Wh();return x.useEffect(()=>{const o=l=>{(l.metaKey||l.ctrlKey)&&l.key==="k"&&(l.preventDefault(),n||(s(),r(),i()),e())};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[e,s,r,i,n]),{globalPaletteOpen:n,setGlobalPaletteOpen:t,toggleGlobalPalette:e}}function Vd(e){return Array.isArray?Array.isArray(e):oue(e)==="[object Array]"}function Sot(e){if(typeof e=="string")return e;if(typeof e=="bigint")return e.toString();const t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function TD(e){return e==null?"":Sot(e)}function ei(e){return typeof e=="string"}function ck(e){return typeof e=="number"}function wot(e){return e===!0||e===!1||kot(e)&&oue(e)=="[object Boolean]"}function aue(e){return typeof e=="object"}function kot(e){return aue(e)&&e!==null}function ta(e){return e!=null}function mw(e){return!e.trim().length}function oue(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const Cot="Incorrect 'index' type",_D="Invalid doc index: must be a non-negative integer within the bounds of the docs array",Eot=e=>`Invalid value for key ${e}`,Tot=e=>`Pattern length exceeds max of ${e}.`,_ot=e=>`Missing ${e} property in key`,Not=e=>`Property 'weight' in key '${e}' must be a positive integer`,jot="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",AV=Object.prototype.hasOwnProperty;var Aot=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(n=>{const s=lue(n);this._keys.push(s),this._keyMap[s.id]=s,t+=s.weight}),this._keys.forEach(n=>{n.weight/=t})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function lue(e){let t=null,n=null,s=null,r=1,i=null;if(ei(e)||Vd(e))s=e,t=RV(e),n=uk(e);else{if(!AV.call(e,"name"))throw new Error(_ot("name"));const o=e.name;if(s=o,AV.call(e,"weight")&&e.weight!==void 0&&(r=e.weight,r<=0))throw new Error(Not(uk(o)));t=RV(o),n=uk(o),i=e.getFn??null}return{path:t,id:n,weight:r,src:s,getFn:i}}function RV(e){return Vd(e)?e:e.split(".")}function uk(e){return Vd(e)?e.join("."):e}function Rot(e,t){const n=[];let s=!1;const r=(i,o,l,c)=>{if(ta(i))if(!o[l])n.push(c!==void 0?{v:i,i:c}:i);else{const u=i[o[l]];if(!ta(u))return;if(l===o.length-1&&(ei(u)||ck(u)||wot(u)||typeof u=="bigint"))n.push(c!==void 0?{v:TD(u),i:c}:TD(u));else if(Vd(u)){s=!0;for(let d=0,f=u.length;d<f;d+=1)r(u[d],o,l+1,d)}else o.length&&r(u,o,l+1,c)}};return r(e,ei(t)?t.split("."):t,0),s?n:n[0]}const Mot={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Dot={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},Oot={location:0,threshold:.6,distance:100},Iot={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:Rot,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},At=Object.freeze({...Dot,...Mot,...Oot,...Iot});function Pot(e=1,t=3){const n=new Map,s=Math.pow(10,t);return{get(r){let i=1,o=!1;for(let c=0;c<r.length;c++)r.charCodeAt(c)===32?o||(i++,o=!0):o=!1;if(n.has(i))return n.get(i);const l=Math.round(s/Math.pow(i,.5*e))/s;return n.set(i,l),l},clear(){n.clear()}}}var RP=class{constructor({getFn:e=At.getFn,fieldNormWeight:t=At.fieldNormWeight}={}){this.norm=Pot(t,3),this.getFn=e,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((t,n)=>{this._keysMap[t.id]=n})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const e=this.docs.length;this.records=new Array(e);let t=0;if(ei(this.docs[0]))for(let n=0;n<e;n++){const s=this._createStringRecord(this.docs[n],n);s&&(this.records[t++]=s)}else for(let n=0;n<e;n++)this.records[t++]=this._createObjectRecord(this.docs[n],n);this.records.length=t,this.norm.clear()}add(e,t){if(!Number.isInteger(t)||t<0)throw new Error(_D);if(ei(e)){const s=this._createStringRecord(e,t);return s&&this.records.push(s),s}const n=this._createObjectRecord(e,t);return this.records.push(n),n}removeAt(e){if(!Number.isInteger(e)||e<0)throw new Error(_D);for(let t=0,n=this.records.length;t<n;t+=1)if(this.records[t].i===e){this.records.splice(t,1);break}for(let t=0,n=this.records.length;t<n;t+=1)this.records[t].i>e&&(this.records[t].i-=1)}removeAll(e){const t=new Set;for(const s of e)Number.isInteger(s)&&s>=0&&t.add(s);if(t.size===0)return;this.records=this.records.filter(s=>!t.has(s.i));const n=Array.from(t).sort((s,r)=>s-r);for(const s of this.records){let r=0,i=n.length;for(;r<i;){const o=r+i>>>1;n[o]<s.i?r=o+1:i=o}s.i-=r}}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_createStringRecord(e,t){return!ta(e)||mw(e)?null:{v:e,i:t,n:this.norm.get(e)}}_createObjectRecord(e,t){const n={i:t,$:{}};for(let s=0,r=this.keys.length;s<r;s++){const i=this.keys[s],o=i.getFn?i.getFn(e):this.getFn(e,i.path);if(ta(o)){if(Vd(o)){const l=[];for(let c=0,u=o.length;c<u;c+=1){const d=o[c];if(ta(d)){if(ei(d)){if(!mw(d)){const f={v:d,i:c,n:this.norm.get(d)};l.push(f)}}else if(ta(d.v)){const f=ei(d.v)?d.v:TD(d.v);if(!mw(f)){const m={v:f,i:d.i,n:this.norm.get(f)};l.push(m)}}}}n.$[s]=l}else if(ei(o)&&!mw(o)){const l={v:o,n:this.norm.get(o)};n.$[s]=l}}}return n}toJSON(){return{keys:this.keys.map(({getFn:e,...t})=>t),records:this.records}}};function cue(e,t,{getFn:n=At.getFn,fieldNormWeight:s=At.fieldNormWeight}={}){const r=new RP({getFn:n,fieldNormWeight:s});return r.setKeys(e.map(lue)),r.setSources(t),r.create(),r}function Lot(e,{getFn:t=At.getFn,fieldNormWeight:n=At.fieldNormWeight}={}){const{keys:s,records:r}=e,i=new RP({getFn:t,fieldNormWeight:n});return i.setKeys(s),i.setIndexRecords(r),i}function Fot(e=[],t=At.minMatchCharLength){const n=[];let s=-1,r=-1,i=0;for(let o=e.length;i<o;i+=1){const l=e[i];l&&s===-1?s=i:!l&&s!==-1&&(r=i-1,r-s+1>=t&&n.push([s,r]),s=-1)}return e[i-1]&&i-s>=t&&n.push([s,i-1]),n}function zot(e,t,n,{location:s=At.location,distance:r=At.distance,threshold:i=At.threshold,findAllMatches:o=At.findAllMatches,minMatchCharLength:l=At.minMatchCharLength,includeMatches:c=At.includeMatches,ignoreLocation:u=At.ignoreLocation}={}){if(t.length>32)throw new Error(Tot(32));const d=t.length,f=e.length,m=Math.max(0,Math.min(s,f));let g=i,y=m;const b=(O,M)=>{const L=O/d;if(u)return L;const P=Math.abs(m-M);return r?L+P/r:P?1:L},S=l>1||c,w=S?Array(f):[];let C;for(;(C=e.indexOf(t,y))>-1;){const O=b(0,C);if(g=Math.min(O,g),y=C+d,S){let M=0;for(;M<d;)w[C+M]=1,M+=1}}y=-1;let T=[],E=1,j=0,_=d+f;const N=1<<d-1;for(let O=0;O<d;O+=1){let M=0,L=_;for(;M<L;)b(O,m+L)<=g?M=L:_=L,L=Math.floor((_-M)/2+M);_=L;let P=Math.max(1,m-L+1);const $=o?f:Math.min(m+L,f)+d,q=Array($+2);q[$+1]=(1<<O)-1;for(let K=$;K>=P;K-=1){const B=K-1,V=n[e[B]];if(q[K]=(q[K+1]<<1|1)&V,O&&(q[K]|=(T[K+1]|T[K])<<1|1|T[K+1]),q[K]&N&&(E=b(O,B),E<=g)){if(g=E,y=B,j=O,y<=m)break;P=Math.max(1,2*m-y)}}if(b(O+1,m)>g)break;T=q}if(S&&y>=0){const O=Math.min(f-1,y+d-1+j);for(let M=y;M<=O;M+=1)n[e[M]]&&(w[M]=1)}const R={isMatch:y>=0,score:Math.max(.001,E)};if(S){const O=Fot(w,l);O.length?c&&(R.indices=O):R.isMatch=!1}return R}function Bot(e){const t={};for(let n=0,s=e.length;n<s;n+=1){const r=e.charAt(n);t[r]=(t[r]||0)|1<<s-n-1}return t}function MP(e){if(e.length<=1)return e;e.sort((n,s)=>n[0]-s[0]||n[1]-s[1]);const t=[e[0]];for(let n=1,s=e.length;n<s;n+=1){const r=t[t.length-1],i=e[n];i[0]<=r[1]+1?r[1]=Math.max(r[1],i[1]):t.push(i)}return t}const uue={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},$ot=new RegExp("["+Object.keys(uue).join("")+"]","g"),Nv=typeof String.prototype.normalize=="function"?e=>e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace($ot,t=>uue[t]):e=>e;var DP=class{constructor(e,{location:t=At.location,threshold:n=At.threshold,distance:s=At.distance,includeMatches:r=At.includeMatches,findAllMatches:i=At.findAllMatches,minMatchCharLength:o=At.minMatchCharLength,isCaseSensitive:l=At.isCaseSensitive,ignoreDiacritics:c=At.ignoreDiacritics,ignoreLocation:u=At.ignoreLocation}={}){if(this.options={location:t,threshold:n,distance:s,includeMatches:r,findAllMatches:i,minMatchCharLength:o,isCaseSensitive:l,ignoreDiacritics:c,ignoreLocation:u},e=l?e:e.toLowerCase(),e=c?Nv(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const d=(m,g)=>{this.chunks.push({pattern:m,alphabet:Bot(m),startIndex:g})},f=this.pattern.length;if(f>32){let m=0;const g=f%32,y=f-g;for(;m<y;)d(this.pattern.substr(m,32),m),m+=32;if(g){const b=f-32;d(this.pattern.substr(b),b)}}else d(this.pattern,0)}searchIn(e){const{isCaseSensitive:t,ignoreDiacritics:n,includeMatches:s}=this.options;if(e=t?e:e.toLowerCase(),e=n?Nv(e):e,this.pattern===e){const y={isMatch:!0,score:0};return s&&(y.indices=[[0,e.length-1]]),y}const{location:r,distance:i,threshold:o,findAllMatches:l,minMatchCharLength:c,ignoreLocation:u}=this.options,d=[];let f=0,m=!1;this.chunks.forEach(({pattern:y,alphabet:b,startIndex:S})=>{const{isMatch:w,score:C,indices:T}=zot(e,y,b,{location:r+S,distance:i,threshold:o,findAllMatches:l,minMatchCharLength:c,includeMatches:s,ignoreLocation:u});w&&(m=!0),f+=C,w&&T&&d.push(...T)});const g={isMatch:m,score:m?f/this.chunks.length:1};return m&&s&&(g.indices=MP(d)),g}};const Hot=new Set(["fuzzy","include"]);function Uot(e){return e.startsWith("inverse")}const ND=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:e=>({type:"exact",search(t){const n=t===e;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:e=>({type:"include",search(t){let n=0,s;const r=[],i=e.length;for(;(s=t.indexOf(e,n))>-1;)n=s+i,r.push([s,n-1]);const o=!!r.length;return{isMatch:o,score:o?0:1,indices:r}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:e=>({type:"prefix-exact",search(t){const n=t.startsWith(e);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:e=>({type:"inverse-prefix-exact",search(t){const n=!t.startsWith(e);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:e=>({type:"inverse-suffix-exact",search(t){const n=!t.endsWith(e);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:e=>({type:"suffix-exact",search(t){const n=t.endsWith(e);return{isMatch:n,score:n?0:1,indices:[t.length-e.length,t.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:e=>({type:"inverse-exact",search(t){const n=t.indexOf(e)===-1;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(e,t={})=>{const n=new DP(e,{location:t.location??At.location,threshold:t.threshold??At.threshold,distance:t.distance??At.distance,includeMatches:t.includeMatches??At.includeMatches,findAllMatches:t.findAllMatches??At.findAllMatches,minMatchCharLength:t.minMatchCharLength??At.minMatchCharLength,isCaseSensitive:t.isCaseSensitive??At.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics??At.ignoreDiacritics,ignoreLocation:t.ignoreLocation??At.ignoreLocation});return{type:"fuzzy",search(s){return n.searchIn(s)}}}}],MV=ND.length,Vot="\0",qot="|";function Got(e){const t=[],n=e.length;let s=0;for(;s<n;){for(;s<n&&e[s]===" ";)s++;if(s>=n)break;let r=s;for(;r<n&&e[r]!==" "&&e[r]!=='"';)r++;if(r<n&&e[r]==='"'){for(r++;r<n;){if(e[r]==='"'){const i=r+1;if(i>=n||e[i]===" "){r++;break}if(e[i]==="$"&&(i+1>=n||e[i+1]===" ")){r+=2;break}}r++}t.push(e.substring(s,r)),s=r}else{for(;r<n&&e[r]!==" ";)r++;t.push(e.substring(s,r)),s=r}}return t}function DV(e,t){const n=e.match(t);return n?n[1]:null}function Kot(e,t={}){return e.replace(/\\\|/g,Vot).split(qot).map(n=>{const s=Got(n.replace(/\u0000/g,"|").trim()).filter(i=>i&&!!i.trim()),r=[];for(let i=0,o=s.length;i<o;i+=1){const l=s[i];let c=!1,u=-1;for(;!c&&++u<MV;){const d=ND[u],f=DV(l,d.multiRegex);f&&(r.push(d.create(f,t)),c=!0)}if(!c)for(u=-1;++u<MV;){const d=ND[u],f=DV(l,d.singleRegex);if(f){r.push(d.create(f,t));break}}}return r})}var Wot=class{constructor(e,{isCaseSensitive:t=At.isCaseSensitive,ignoreDiacritics:n=At.ignoreDiacritics,includeMatches:s=At.includeMatches,minMatchCharLength:r=At.minMatchCharLength,ignoreLocation:i=At.ignoreLocation,findAllMatches:o=At.findAllMatches,location:l=At.location,threshold:c=At.threshold,distance:u=At.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:n,includeMatches:s,minMatchCharLength:r,findAllMatches:o,ignoreLocation:i,location:l,threshold:c,distance:u},e=t?e:e.toLowerCase(),e=n?Nv(e):e,this.pattern=e,this.query=Kot(this.pattern,this.options)}static condition(e,t){return t.useExtendedSearch}searchIn(e){const t=this.query;if(!t)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:s,ignoreDiacritics:r}=this.options;e=s?e:e.toLowerCase(),e=r?Nv(e):e;let i=0;const o=[];let l=0,c=!1;for(let u=0,d=t.length;u<d;u+=1){const f=t[u];o.length=0,i=0,c=!1;for(let m=0,g=f.length;m<g;m+=1){const y=f[m],{isMatch:b,indices:S,score:w}=y.search(e);if(b)i+=1,l+=w,Uot(y.type)&&(c=!0),n&&(Hot.has(y.type)?o.push(...S):o.push(S));else{l=0,i=0,o.length=0,c=!1;break}}if(i){const m={isMatch:!0,score:l/i};return c&&(m.hasInverse=!0),n&&(m.indices=MP(o)),m}}return{isMatch:!1,score:1}}};const jD=[];function OP(...e){jD.push(...e)}function EC(e,t){for(let n=0,s=jD.length;n<s;n+=1){const r=jD[n];if(r.condition(e,t))return new r(e,t)}return new DP(e,t)}const TC={AND:"$and",OR:"$or"},AD={PATH:"$path",PATTERN:"$val"},RD=e=>!!(e[TC.AND]||e[TC.OR]),Yot=e=>!!e[AD.PATH],Zot=e=>!Vd(e)&&aue(e)&&!RD(e),OV=e=>({[TC.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function due(e,t,{auto:n=!0}={}){const s=r=>{if(ei(r)){const c={keyId:null,pattern:r};return n&&(c.searcher=EC(r,t)),c}const i=Object.keys(r),o=Yot(r);if(!o&&i.length>1&&!RD(r))return s(OV(r));if(Zot(r)){const c=o?r[AD.PATH]:i[0],u=o?r[AD.PATTERN]:r[c];if(!ei(u))throw new Error(Eot(c));const d={keyId:uk(c),pattern:u};return n&&(d.searcher=EC(u,t)),d}const l={children:[],operator:i[0]};return i.forEach(c=>{const u=r[c];Vd(u)&&u.forEach(d=>{l.children.push(s(d))})}),l};return RD(e)||(e=OV(e)),s(e)}function MD(e,{ignoreFieldNorm:t=At.ignoreFieldNorm}){let n=1;return e.forEach(({key:s,norm:r,score:i})=>{const o=s?s.weight:null;n*=Math.pow(i===0&&o?Number.EPSILON:i,(o||1)*(t?1:r))}),n}function Xot(e,{ignoreFieldNorm:t=At.ignoreFieldNorm}){e.forEach(n=>{n.score=MD(n.matches,{ignoreFieldNorm:t})})}var Qot=class{constructor(e){this.limit=e,this.heap=[]}get size(){return this.heap.length}shouldInsert(e){return this.size<this.limit||e<this.heap[0].score}insert(e){this.size<this.limit?(this.heap.push(e),this._bubbleUp(this.size-1)):e.score<this.heap[0].score&&(this.heap[0]=e,this._sinkDown(0))}extractSorted(e){return this.heap.sort(e)}_bubbleUp(e){const t=this.heap;for(;e>0;){const n=e-1>>1;if(t[e].score<=t[n].score)break;const s=t[e];t[e]=t[n],t[n]=s,e=n}}_sinkDown(e){const t=this.heap,n=t.length;let s=e;do{e=s;const r=2*e+1,i=2*e+2;if(r<n&&t[r].score>t[s].score&&(s=r),i<n&&t[i].score>t[s].score&&(s=i),s!==e){const o=t[e];t[e]=t[s],t[s]=o}}while(s!==e)}};function Jot(e){const t=[];return e.matches.forEach(n=>{if(!ta(n.indices)||!n.indices.length)return;const s={indices:n.indices,value:n.value};n.key&&(s.key=n.key.id),n.idx>-1&&(s.refIndex=n.idx),t.push(s)}),t}function elt(e,t,{includeMatches:n=At.includeMatches,includeScore:s=At.includeScore}={}){return e.map(r=>{const{idx:i}=r,o={item:t[i],refIndex:i};return n&&(o.matches=Jot(r)),s&&(o.score=r.score),o})}const tlt=/[\p{L}\p{M}\p{N}_]+/gu,IV=new WeakSet;function nlt(e){IV.has(e)||(IV.add(e),console.warn(`[Fuse] tokenize regex ${e} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function slt(e){if(typeof e=="function"){let t=!1;return n=>{const s=e(n);if(!t&&(t=!0,!Array.isArray(s)||s.some(r=>typeof r!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(s)?"array containing non-strings":typeof s}.`);return s}}return e instanceof RegExp?(e.global||nlt(e),t=>t.match(e)||[]):t=>t.match(tlt)||[]}function DD({isCaseSensitive:e=!1,ignoreDiacritics:t=!1,tokenize:n}={}){const s=slt(n);return{tokenize(r){return e||(r=r.toLowerCase()),t&&(r=Nv(r)),s(r)}}}var rlt=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=DD({isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,tokenize:t.tokenize});const n=this.analyzer.tokenize(e),{df:s,fieldCount:r}=t._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const i of n){this.termSearchers.push(new DP(i,{location:t.location,threshold:t.threshold,distance:t.distance,includeMatches:t.includeMatches,findAllMatches:t.findAllMatches,minMatchCharLength:t.minMatchCharLength,isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,ignoreLocation:!0}));const o=s.get(i)||0,l=Math.log(1+(r-o+.5)/(o+.5));this.idfWeights.push(l)}this.combineAll=t.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(e){if(!this.termSearchers.length)return{isMatch:!1,score:1};const t=[];let n=0,s=0,r=0,i=0;const o=this.combineAll&&!this.useMask?new Set:null;for(let u=0;u<this.termSearchers.length;u++){const d=this.termSearchers[u].searchIn(e),f=this.idfWeights[u];s+=f,d.isMatch&&(r++,n+=f*(1-d.score),d.indices&&t.push(...d.indices),this.combineAll&&(this.useMask?i|=1<<u:o.add(u)))}if(r===0)return{isMatch:!1,score:1};const l=s>0?1-n/s:0,c={isMatch:!0,score:Math.max(.001,l)};return this.options.includeMatches&&t.length&&(c.indices=MP(t)),this.combineAll&&(this.useMask?c.matchedMask=i:c.matchedTerms=o,c.termCount=this.numTerms),c}};function eR(e,t,n,s){const r=s.tokenize(t);if(!r.length)return;e.fieldCount++,e.docFieldCount.set(n,(e.docFieldCount.get(n)||0)+1);const i=new Set(r);let o=e.docTermFieldHits.get(n);o||(o=new Map,e.docTermFieldHits.set(n,o));for(const l of i)o.set(l,(o.get(l)||0)+1),e.df.set(l,(e.df.get(l)||0)+1)}function fue(e,t,n,s){const{i:r,v:i,$:o}=t;if(i!==void 0){eR(e,i,r,s);return}if(o)for(let l=0;l<n;l++){const c=o[l];if(c)if(Array.isArray(c))for(const u of c)eR(e,u.v,r,s);else eR(e,c.v,r,s)}}function ilt(e,t,n){const s={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const r of e)fue(s,r,t,n);return s}function alt(e,t,n,s){fue(e,t,n,s)}function olt(e,t){const n=e.docFieldCount.get(t);if(n===void 0)return;e.fieldCount-=n,e.docFieldCount.delete(t);const s=e.docTermFieldHits.get(t);if(s){for(const[r,i]of s){const o=(e.df.get(r)||0)-i;o<=0?e.df.delete(r):e.df.set(r,o)}e.docTermFieldHits.delete(t)}}function PV(e,t){if(t.length===0)return;const n=Array.from(new Set(t)).sort((l,c)=>l-c);for(const l of n)olt(e,l);const s=l=>{let c=0,u=n.length;for(;c<u;){const d=c+u>>>1;n[d]<l?c=d+1:u=d}return l-c},r=n[0],i=new Map;for(const[l,c]of e.docFieldCount)i.set(l>r?s(l):l,c);e.docFieldCount=i;const o=new Map;for(const[l,c]of e.docTermFieldHits)o.set(l>r?s(l):l,c);e.docTermFieldHits=o}var qd=class{constructor(e,t,n){this.options={...At,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new Aot(this.options.keys),this._docs=e,this._myIndex=null,this._invertedIndex=null,this.setCollection(e,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(e){if(this._lastQuery===e)return this._lastSearcher;const t=EC(e,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=e,this._lastSearcher=t,t}setCollection(e,t){if(this._docs=e,t&&!(t instanceof RP))throw new Error(Cot);if(this._myIndex=t||cue(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=DD({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=ilt(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(e){if(!ta(e))return;this._docs.push(e);const t=this._myIndex.add(e,this._docs.length-1);if(this._invertedIndex&&t){const n=DD({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});alt(this._invertedIndex,t,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}remove(e=()=>!1){const t=[],n=[];for(let s=0,r=this._docs.length;s<r;s+=1)e(this._docs[s],s)&&(t.push(this._docs[s]),n.push(s));if(n.length){this._invertedIndex&&PV(this._invertedIndex,n);const s=new Set(n);this._docs=this._docs.filter((r,i)=>!s.has(i)),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return t}removeAt(e){if(!Number.isInteger(e)||e<0||e>=this._docs.length)throw new Error(_D);this._invertedIndex&&PV(this._invertedIndex,[e]);const t=this._docs.splice(e,1)[0];return this._myIndex.removeAt(e),this._invalidateSearcherCache(),t}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}search(e,t){const{limit:n=-1}=t||{},{includeMatches:s,includeScore:r,shouldSort:i,sortFn:o,ignoreFieldNorm:l}=this.options;if(ei(e)&&!e.trim()){let d=this._docs.map((f,m)=>({item:f,refIndex:m}));return ck(n)&&n>-1&&(d=d.slice(0,n)),d}const c=ck(n)&&n>0&&ei(e);let u;if(c){const d=new Qot(n);ei(this._docs[0])?this._searchStringList(e,{heap:d,ignoreFieldNorm:l}):this._searchObjectList(e,{heap:d,ignoreFieldNorm:l}),u=d.extractSorted(o)}else u=ei(e)?ei(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),Xot(u,{ignoreFieldNorm:l}),i&&u.sort(o),ck(n)&&n>-1&&(u=u.slice(0,n));return elt(u,this._docs,{includeMatches:s,includeScore:r})}_searchStringList(e,{heap:t,ignoreFieldNorm:n}={}){const s=this._getSearcher(e),r=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:i}=this._myIndex,o=t?null:[];return i.forEach(({v:l,i:c,n:u})=>{if(!ta(l))return;const d=s.searchIn(l);if(d.isMatch){const f={score:d.score,value:l,norm:u,indices:d.indices};r&&(f.matchedMask=d.matchedMask,f.matchedTerms=d.matchedTerms,f.termCount=d.termCount);const m=[f];if(!r||this._coversAllTokens(m)){const g={item:l,idx:c,matches:m};t?(g.score=MD(g.matches,{ignoreFieldNorm:n}),t.shouldInsert(g.score)&&t.insert(g)):o.push(g)}}}),o}_searchLogical(e){const t=due(e,this.options),n=(o,l,c)=>{if(!("children"in o)){const{keyId:m,searcher:g}=o;let y;return m===null?(y=[],this._myIndex.keys.forEach((b,S)=>{y.push(...this._findMatches({key:b,value:l[S],searcher:g}))})):y=this._findMatches({key:this._keyStore.get(m),value:this._myIndex.getValueForItemAtKeyId(l,m),searcher:g}),y&&y.length?[{idx:c,item:l,matches:y}]:[]}const{children:u,operator:d}=o,f=[];for(let m=0,g=u.length;m<g;m+=1){const y=u[m],b=n(y,l,c);if(b.length)f.push(...b);else if(d===TC.AND)return[]}return f},s=this._myIndex.records,r=new Map,i=[];return s.forEach(({$:o,i:l})=>{if(ta(o)){const c=n(t,o,l);c.length&&(r.has(l)||(r.set(l,{idx:l,item:o,matches:[]}),i.push(r.get(l))),c.forEach(({matches:u})=>{r.get(l).matches.push(...u)}))}}),i}_searchObjectList(e,{heap:t,ignoreFieldNorm:n}={}){const s=this._getSearcher(e),r=this.options.useTokenSearch&&this.options.tokenMatch==="all",{keys:i,records:o}=this._myIndex,l=t?null:[];return o.forEach(({$:c,i:u})=>{if(!ta(c))return;const d=[];let f=!1,m=!1;if(i.forEach((g,y)=>{const b=this._findMatches({key:g,value:c[y],searcher:s});b.length?(d.push(...b),b[0].hasInverse&&(m=!0)):f=!0}),!(m&&f)&&d.length&&(!r||this._coversAllTokens(d))){const g={idx:u,item:c,matches:d};t?(g.score=MD(g.matches,{ignoreFieldNorm:n}),t.shouldInsert(g.score)&&t.insert(g)):l.push(g)}}),l}_findMatches({key:e,value:t,searcher:n}){if(!ta(t))return[];const s=[];if(Vd(t))t.forEach(({v:r,i,n:o})=>{if(!ta(r))return;const l=n.searchIn(r);if(l.isMatch){const c={score:l.score,key:e,value:r,idx:i,norm:o,indices:l.indices,hasInverse:l.hasInverse};l.termCount!==void 0&&(c.matchedMask=l.matchedMask,c.matchedTerms=l.matchedTerms,c.termCount=l.termCount),s.push(c)}});else{const{v:r,n:i}=t,o=n.searchIn(r);if(o.isMatch){const l={score:o.score,key:e,value:r,norm:i,indices:o.indices,hasInverse:o.hasInverse};o.termCount!==void 0&&(l.matchedMask=o.matchedMask,l.matchedTerms=o.matchedTerms,l.termCount=o.termCount),s.push(l)}}return s}_coversAllTokens(e){const t=e.length?e[0].termCount:void 0;if(t===void 0)return!0;if(t<=31){let s=0;for(let r=0;r<e.length;r++)s|=e[r].matchedMask||0;return s===2**t-1}const n=new Set;for(let s=0;s<e.length;s++){const r=e[s].matchedTerms;if(r)for(const i of r)n.add(i)}return n.size===t}};qd.version="7.4.2";qd.createIndex=cue;qd.parseIndex=Lot;qd.config=At;qd.match=function(e,t,n){if(n&&n.useTokenSearch)throw new Error(jot);return EC(e,{...At,...n}).searchIn(t)};qd.parseQuery=due;OP(Wot);OP(rlt);qd.use=function(...e){e.forEach(t=>OP(t))};var llt=qd;const clt={keys:["name","keywords"],includeMatches:!0,threshold:.3,distance:100,minMatchCharLength:1};function ult(e,t){const{prefix:n,term:s}=x.useMemo(()=>dlt(t),[t]),r=x.useMemo(()=>n==="@"?e.filter(l=>l.type==="agent"):n===">"?e.filter(l=>l.type==="command"):e,[e,n]),i=x.useMemo(()=>new llt(r,clt),[r]);return{results:x.useMemo(()=>s?i.search(s).map(l=>({item:l.item,matches:l.matches})):r.map(l=>({item:l,matches:void 0})),[i,s,r]),prefix:n,term:s}}function dlt(e){return e.startsWith("@")?{prefix:"@",term:e.slice(1)}:e.startsWith(">")?{prefix:">",term:e.slice(1)}:{prefix:null,term:e}}function flt(e){const[t,n]=Id(),{recordUsage:s}=iue(),{setTheme:r,theme:i}=yb(),o=Hn(),l=we(C=>C.setPreviousCwd),{open:c}=t0(),{open:u}=Kh(),{open:d}=Wh(),f=we(C=>C.setPickerOpen),m=we(C=>C.setCanvasOpen),g=we(C=>C.setRightPanelOpen),y=we(C=>C.setActiveRightPanelTab),b=x.useCallback(C=>{t&&t!==C.projectPath&&l(t),s(C.id),n(C.projectPath),e()},[s,n,e,t,l]),S=x.useCallback(C=>{switch(e(),C){case"openTasks":u();return;case"openRelay":d();return;case"openMesh":o({to:"/agents"});return;case"openSettings":c();return;case"discoverAgents":o({to:"/agents"});return;case"browseFilesystem":f(!0);return;case"openAgentProfile":y("agent-hub"),g(!0);return}},[e,o,u,d,c,f,y,g]),w=x.useCallback(C=>{switch(e(),C){case"navigateDashboard":o({to:"/"});return;case"openDevPlayground":window.open("/dev","_blank");return;case"toggleDevtools":we.getState().toggleDevtools();return;case"toggleRouterDevtools":we.getState().toggleRouterDevtools();return;case"createAgent":ud.getState().open();return;case"toggleCanvas":m(!we.getState().canvasOpen);return;case"toggleTheme":r(i==="dark"?"light":"dark");return;case"openTasks":u();return;case"openRelay":d();return;case"openMesh":case"discoverAgents":o({to:"/agents"});return;case"openSettings":c();return;case"browseFilesystem":f(!0);return}},[e,o,r,i,m,f,u,d,c]);return{handleAgentSelect:b,handleFeatureAction:S,handleQuickAction:w,recordUsage:s,setDir:n,selectedCwd:t}}function hue(e,t){const n=x.useDeferredValue(e),{sessions:s}=iI(t),{data:r}=fce(n||null),i=x.useMemo(()=>s.slice(0,3).map(o=>({id:o.id,title:Cg(o.title),lastActive:o.updatedAt})),[s]);return{sessionCount:s.length,recentSessions:i,health:r??null}}function hlt({agent:e}){const{sessionCount:t,recentSessions:n,health:s}=hue(e.id,e.projectPath),{color:r,emoji:i}=Dd(e);return a.jsx(te.div,{initial:{opacity:0,width:0},animate:{opacity:1,width:240},exit:{opacity:0,width:0},transition:{duration:.2,ease:[0,0,.2,1]},className:"flex-shrink-0 overflow-hidden border-l will-change-[width]",children:a.jsxs("div",{className:"w-[240px] space-y-3 p-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"size-2.5 flex-shrink-0 rounded-full",style:{backgroundColor:r}}),a.jsx("span",{className:"text-base",children:i}),a.jsx("span",{className:"truncate text-sm font-semibold",children:nn(e)})]}),a.jsx("p",{className:"text-muted-foreground truncate text-xs",children:Mc(e.projectPath)}),a.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[s&&a.jsx(zt,{variant:s.status==="active"?"default":"secondary",className:"px-1.5 py-0 text-[10px]",children:s.status}),a.jsxs("span",{className:"text-muted-foreground",children:[t," ",t===1?"session":"sessions"]})]}),n.length>0&&a.jsxs("div",{className:"space-y-1 pt-1",children:[a.jsx("p",{className:"text-muted-foreground text-[10px] font-medium tracking-wider uppercase",children:"Recent"}),a.jsx("ul",{className:"space-y-0.5",children:n.map(o=>a.jsx("li",{className:"text-muted-foreground truncate text-xs",children:o.title},o.id))})]})]})})}function mlt({agent:e,onOpenHere:t,onOpenNewTab:n,onNewSession:s,onEditSettings:r,recentSessions:i}){const o=zg?"⌘":"Ctrl+";return a.jsxs(a.Fragment,{children:[a.jsxs(ao,{heading:`${nn(e)} Actions`,children:[a.jsxs(Qr,{value:"open-here",onSelect:t,children:[a.jsx($c,{className:"size-4"}),a.jsx("span",{children:"Open Here"}),a.jsx(d7,{children:"Enter"})]}),a.jsxs(Qr,{value:"open-new-tab",onSelect:n,children:[a.jsx(fa,{className:"size-4"}),a.jsx("span",{children:"Open in New Tab"}),a.jsxs(d7,{children:[o,"Enter"]})]}),a.jsxs(Qr,{value:"new-session",onSelect:s,children:[a.jsx(Cs,{className:"size-4"}),a.jsx("span",{children:"New Session"})]}),a.jsxs(Qr,{value:"edit-settings",onSelect:r,children:[a.jsx(qa,{className:"size-4"}),a.jsxs("span",{children:["Edit ",nn(e)," Settings"]})]})]}),i.length>0&&a.jsx(ao,{heading:"Recent Sessions",children:i.map(l=>a.jsxs(Qr,{value:l.id,children:[a.jsx(Rd,{className:"size-4"}),a.jsx("span",{className:"truncate",children:l.title}),a.jsx("span",{className:"text-muted-foreground ml-auto text-xs",children:plt(l.lastActive)})]},l.id))})]})}function plt(e){const t=Date.now(),n=new Date(e).getTime(),s=t-n,r=Math.floor(s/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const i=Math.floor(r/60);if(i<24)return`${i}h ago`;const o=Math.floor(i/24);return o<7?`${o}d ago`:`${Math.floor(o/7)}w ago`}const lp="bg-muted rounded px-1 py-0.5 font-mono text-[10px]";function glt({page:e,hasAgentSelected:t}){const n=zg?"⌘":"Ctrl";return a.jsxs("div",{className:"text-muted-foreground flex flex-shrink-0 items-center gap-3 border-t px-3 py-1.5 text-xs",children:[a.jsxs("span",{className:"inline-flex items-center gap-1",children:[a.jsx("kbd",{className:lp,children:"↑↓"}),"Navigate"]}),!e&&t&&a.jsxs("span",{className:"inline-flex items-center gap-1",children:[a.jsx("kbd",{className:lp,children:"Enter"}),"Open"]}),(!e&&t||e==="agent-actions")&&a.jsxs("span",{className:"inline-flex items-center gap-1",children:[a.jsxs("kbd",{className:lp,children:[n,"Enter"]}),"New Tab"]}),e==="agent-actions"&&a.jsxs("span",{className:"inline-flex items-center gap-1",children:[a.jsx("kbd",{className:lp,children:"Enter"}),"Select"]}),e&&a.jsxs("span",{className:"inline-flex items-center gap-1",children:[a.jsx("kbd",{className:lp,children:"Backspace"}),"Back"]}),a.jsxs("span",{className:"ml-auto inline-flex items-center gap-1",children:[a.jsx("kbd",{className:lp,children:"esc"}),"Close"]})]})}function xlt({text:e,indices:t,className:n}){if(!t||t.length===0)return a.jsx("span",{className:n,children:e});const s=[];let r=0;for(let i=0;i<t.length;i++){const[o,l]=t[i],c=l+1;r<o&&s.push(a.jsx("span",{children:e.slice(r,o)},`p-${i}`)),s.push(a.jsx("mark",{className:"text-foreground bg-transparent font-semibold",children:e.slice(o,c)},`m-${i}`)),r=c}return r<e.length&&s.push(a.jsx("span",{children:e.slice(r)},"tail")),a.jsx("span",{className:n,children:s})}function LV({agent:e,isActive:t,onSelect:n,nameIndices:s,isSelected:r}){const{color:i,emoji:o}=Dd(e);return a.jsxs(Qr,{value:nn(e),keywords:[e.name,e.projectPath,e.id],onSelect:()=>n(),className:"relative flex items-start gap-2 py-2",forceMount:t?!0:void 0,children:[r&&a.jsx(te.div,{layoutId:"cmd-palette-selection",className:"bg-accent absolute inset-0 rounded-sm",transition:{duration:.15,ease:[0,0,.2,1]}}),a.jsxs("div",{className:"relative z-10 flex w-full items-start gap-2",children:[a.jsx(Vb,{color:i,emoji:o,size:"xs",className:"mt-0.5 flex-shrink-0"}),a.jsx("div",{className:"min-w-0 flex-1",children:a.jsxs("div",{className:"flex items-center gap-2",children:[s?a.jsx(xlt,{text:nn(e),indices:s,className:"truncate text-sm font-semibold"}):a.jsx("span",{className:"truncate text-sm font-semibold",children:nn(e)}),a.jsx("span",{className:"text-muted-foreground ml-auto flex-shrink-0 text-xs",children:Mc(e.projectPath)}),t&&a.jsx(Lt,{className:"text-muted-foreground size-4 flex-shrink-0"})]})})]})]})}const tR={Clock:Pi,Radio:WE,Globe:ha,Settings:qa,Plus:Cs,Search:pa,FolderOpen:$c,Moon:GE},Dp=[0,0,.2,1],ylt=[.4,0,1,1],vlt={hidden:{opacity:0,scale:.96,y:-8},visible:{opacity:1,scale:1,y:0,transition:{duration:.2,ease:Dp}},exit:{opacity:0,scale:.96,y:-8,transition:{duration:.12,ease:ylt}}},blt={hidden:{},visible:{transition:{staggerChildren:.035,delayChildren:.04}}},cp={hidden:{opacity:0,y:-4},visible:{opacity:1,y:0,transition:{duration:.15,ease:Dp}}};function Slt({staggerKey:e,isZeroQuery:t,isAtMode:n,isCommandMode:s,search:r,selectedCwd:i,selectedValue:o,suggestions:l,recentAgents:c,allAgents:u,searchAgents:d,searchFeatures:f,searchCommands:m,searchQuickActions:g,agentMatchMap:y,onFeatureAction:b,onAgentSelect:S,onQuickAction:w,onGoToAgentActions:C,onClose:T}){return a.jsxs(te.div,{variants:blt,initial:"hidden",animate:"visible",children:[t&&l.length>0&&a.jsx(ao,{heading:"Suggestions",children:l.map((E,j)=>{const _=tR[E.icon];return a.jsx(te.div,{variants:j<8?cp:void 0,children:a.jsx(Qr,{value:E.id,onSelect:()=>{if(E.action==="openTasks")b("openTasks");else if(E.action.startsWith("switchAgent:")){const N=E.action.split(":")[1],R=u.find(O=>O.id===N);R&&S(R)}else E.action.startsWith("continueSession:")&&T()},children:a.jsxs(te.div,{whileHover:{x:2},transition:{duration:.1,ease:Dp},className:"flex w-full items-center gap-2",children:[_&&a.jsx(_,{className:"size-4"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"text-sm",children:E.label}),a.jsx("span",{className:"text-muted-foreground ml-2 text-xs",children:E.description})]})]})})},E.id)})}),t&&c.length>0&&a.jsx(ao,{heading:"Recent Agents",children:a.jsx(yv,{id:"cmd-palette-recent",children:c.map((E,j)=>a.jsx(te.div,{variants:j<8?cp:void 0,children:a.jsx(LV,{agent:E,isActive:E.projectPath===i,isSelected:o===nn(E),onSelect:()=>C(E)})},E.id))})}),!t&&d.length>0&&a.jsx(ao,{heading:"All Agents",children:a.jsx(yv,{id:"cmd-palette-all",children:d.map((E,j)=>{var _,N;return a.jsx(te.div,{variants:j<8?cp:void 0,children:a.jsx(LV,{agent:E,isActive:E.projectPath===i,isSelected:o===nn(E),onSelect:()=>C(E),nameIndices:(N=(_=y.get(E.id))==null?void 0:_.find(R=>R.key==="name"))==null?void 0:N.indices})},E.id)})})}),!n&&!s&&f.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(Yj,{}),a.jsx(ao,{heading:"Features",children:f.map((E,j)=>{const _=tR[E.icon];return a.jsx(te.div,{variants:j<8?cp:void 0,children:a.jsx(Qr,{value:E.label,onSelect:()=>b(E.action),children:a.jsxs(te.div,{whileHover:{x:2},transition:{duration:.1,ease:Dp},className:"flex w-full items-center gap-2",children:[_&&a.jsx(_,{className:"size-4"}),a.jsx("span",{children:E.label}),E.shortcut&&a.jsx("span",{className:"text-muted-foreground ml-auto text-xs",children:E.shortcut})]})})},E.id)})})]}),!n&&(s||r.length>0)&&m.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(Yj,{}),a.jsx(ao,{heading:"Commands",children:m.map((E,j)=>a.jsx(te.div,{variants:j<8?cp:void 0,children:a.jsx(Qr,{value:E.name,children:a.jsxs(te.div,{whileHover:{x:2},transition:{duration:.1,ease:Dp},className:"flex w-full items-center gap-2",children:[a.jsx("span",{className:"font-mono text-xs",children:E.name}),E.description&&a.jsx("span",{className:"text-muted-foreground ml-2 text-xs",children:E.description})]})})},E.name))})]}),!n&&!s&&g.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(Yj,{}),a.jsx(ao,{heading:"Quick Actions",children:g.map((E,j)=>{const _=tR[E.icon];return a.jsx(te.div,{variants:j<8?cp:void 0,children:a.jsx(Qr,{value:E.label,onSelect:()=>w(E.action),children:a.jsxs(te.div,{whileHover:{x:2},transition:{duration:.1,ease:Dp},className:"flex w-full items-center gap-2",children:[_&&a.jsx(_,{className:"size-4"}),a.jsx("span",{children:E.label})]})})},E.id)})})]})]},e)}function wlt(){const{globalPaletteOpen:e,setGlobalPaletteOpen:t}=bot(),[n,s]=x.useState(""),r=x.useRef(null),[i,o]=x.useState(""),[l,c]=x.useState([]),[u,d]=x.useState(null),f=l[l.length-1],[m,g]=x.useState(0),y=Us(),b=we(Pe=>Pe.globalPaletteInitialSearch),S=we(Pe=>Pe.clearGlobalPaletteInitialSearch),w=x.useCallback(()=>{t(!1),S(),s(""),o(""),c([]),d(null)},[t,S]),{handleAgentSelect:C,handleFeatureAction:T,handleQuickAction:E,recordUsage:j,setDir:_,selectedCwd:N}=flt(w),{recentAgents:R,allAgents:O,features:M,commands:L,quickActions:P,searchableItems:$,suggestions:q}=vot(N),{results:K,prefix:B}=ult($,n),V=x.useMemo(()=>{const Pe=new Map;for(const He of K)He.item.type==="agent"&&Pe.set(He.item.id,He.matches);return Pe},[K]),Q=x.useMemo(()=>n?new Set(K.filter(Pe=>Pe.item.type==="agent").map(Pe=>Pe.item.id)):null,[K,n]),re=x.useMemo(()=>!n||B==="@"||B===">"?null:new Set(K.filter(Pe=>Pe.item.type==="feature").map(Pe=>Pe.item.id)),[K,n,B]),U=x.useMemo(()=>!n||B==="@"?null:new Set(K.filter(Pe=>Pe.item.type==="command").map(Pe=>Pe.item.id)),[K,n,B]),G=x.useMemo(()=>!n||B==="@"||B===">"?null:new Set(K.filter(Pe=>Pe.item.type==="quick-action").map(Pe=>Pe.item.id)),[K,n,B]),W=B==="@",F=B===">",X=x.useMemo(()=>i?[...R,...O].find(He=>He.name===i)??null:null,[i,R,O]),J=!y&&X!==null,ae=hue((u==null?void 0:u.id)??"",(u==null?void 0:u.projectPath)??""),oe=we(Pe=>Pe.setRightPanelOpen),de=we(Pe=>Pe.setActiveRightPanelTab),me=x.useCallback(()=>{c(Pe=>Pe.slice(0,-1)),d(Pe=>l.length<=1?null:Pe)},[l.length]),Re=x.useCallback(Pe=>{d(Pe),c(He=>[...He,"agent-actions"]),s(""),o(""),g(He=>He+1)},[]);x.useEffect(()=>{e&&b!=null&&(s(b),S(),requestAnimationFrame(()=>{const Pe=r.current;if(Pe){const He=b.length;Pe.setSelectionRange(He,He)}}))},[e,b,S]);const Fe=x.useCallback(Pe=>{t(Pe),Pe?g(He=>He+1):(s(""),o(""),c([]),d(null))},[t]),Le=!n,Xe=x.useMemo(()=>Q?O.filter(Pe=>Q.has(Pe.id)):O,[O,Q]),ze=x.useMemo(()=>re?M.filter(Pe=>re.has(Pe.id)):M,[M,re]),Mt=x.useMemo(()=>U?L.filter(Pe=>U.has(`cmd-${Pe.name}`)):L,[L,U]),Ft=x.useMemo(()=>G?P.filter(Pe=>G.has(Pe.id)):P,[P,G]);return a.jsx(fi,{open:e,onOpenChange:Fe,children:a.jsx(hi,{className:Y("!min-h-0 overflow-hidden p-0 transition-[max-width] duration-200","[&>button:last-child]:top-2 [&>button:last-child]:right-2.5",J?"max-w-[640px]":"max-w-[480px]",y&&"h-[85vh]"),children:a.jsxs(te.div,{variants:vlt,initial:"hidden",animate:"visible",exit:"exit",className:Y("flex overflow-hidden",y&&"h-full flex-col"),children:[a.jsxs(gT,{loop:!0,shouldFilter:!1,value:i,onValueChange:o,className:Y("min-w-0 flex-1",y&&"flex flex-col [&_[cmdk-list]]:max-h-none [&_[cmdk-list]]:flex-1 [&_[cmdk-list]]:overflow-y-auto"),onKeyDown:Pe=>{if(Pe.key==="Enter"&&(Pe.metaKey||Pe.ctrlKey)&&!f&&X){Pe.preventDefault();const He=new URL(window.location.href);He.searchParams.set("dir",X.projectPath),window.open(He.toString(),"_blank"),j(X.id),w();return}if(Pe.key==="Enter"&&(Pe.metaKey||Pe.ctrlKey)&&f==="agent-actions"&&u){Pe.preventDefault();const He=new URL(window.location.href);He.searchParams.set("dir",u.projectPath),window.open(He.toString(),"_blank"),j(u.id),w();return}Pe.key==="Backspace"&&!n&&l.length>0&&(Pe.preventDefault(),me()),Pe.key==="Escape"&&l.length>0&&(Pe.preventDefault(),Pe.stopPropagation(),me())},children:[l.length>0&&a.jsxs("div",{className:"text-muted-foreground flex items-center gap-1 border-b px-3 py-1.5 text-xs",children:[a.jsx("button",{onClick:()=>{c([]),d(null),g(Pe=>Pe+1)},className:"hover:text-foreground transition-colors",children:"All"}),a.jsx("span",{children:"/"}),a.jsxs("span",{children:["Agent: ",u==null?void 0:u.name]})]}),a.jsx(xT,{ref:r,placeholder:f==="agent-actions"?`${(u==null?void 0:u.name)??"Agent"} actions...`:"Search agents, features, commands...",value:n,onValueChange:s}),a.jsx(yT,{children:a.jsxs(No,{className:"h-full",children:[a.jsx(vT,{children:"No results found."}),a.jsx(Ue,{mode:"wait",initial:!1,children:a.jsxs(te.div,{initial:{opacity:0,x:f?16:-16},animate:{opacity:1,x:0},exit:{opacity:0,x:f?-16:16},transition:{duration:.15,ease:"easeOut"},children:[!f&&a.jsx(Slt,{staggerKey:m,isZeroQuery:Le,isAtMode:W,isCommandMode:F,search:n,selectedCwd:N,selectedValue:i,suggestions:q,recentAgents:R,allAgents:O,searchAgents:Xe,searchFeatures:ze,searchCommands:Mt,searchQuickActions:Ft,agentMatchMap:V,onFeatureAction:T,onAgentSelect:C,onQuickAction:E,onGoToAgentActions:Re,onClose:w}),f==="agent-actions"&&u&&a.jsx(mlt,{agent:u,onOpenHere:()=>C(u),onOpenNewTab:()=>{const Pe=new URL(window.location.href);Pe.searchParams.set("dir",u.projectPath),window.open(Pe.toString(),"_blank"),j(u.id),w()},onNewSession:()=>{_(u.projectPath),j(u.id),w()},onEditSettings:()=>{yd.getState().openHub(u.projectPath),de("agent-hub"),oe(!0),w()},recentSessions:ae.recentSessions})]},f??"root")})]})}),a.jsx(glt,{page:f,hasAgentSelected:J})]}),a.jsx(Ue,{children:J&&X&&a.jsx(hlt,{agent:X},X.id)})]})})})}const klt=[{id:"tasks",label:"Tasks Scheduler",icon:"Clock",action:"openTasks",category:"feature",priority:1},{id:"relay",label:"Channels",icon:"Radio",action:"openRelay",category:"feature",priority:2},{id:"mesh",label:"Agents",icon:"Globe",action:"openMesh",category:"feature",priority:3},{id:"settings",label:"Settings",icon:"Settings",action:"openSettings",category:"feature",priority:4},{id:"agent-profile",label:"Agent Profile",icon:"User",action:"openAgentProfile",category:"feature",priority:5}],Clt=[{id:"dashboard",label:"Go to Dashboard",icon:"Home",action:"navigateDashboard",category:"quick-action",priority:1},{id:"new-session",label:"New Session",icon:"Plus",action:"newSession",category:"quick-action",priority:2},{id:"create-agent",label:"Create Agent",icon:"Plus",action:"createAgent",category:"quick-action",priority:3},{id:"discover",label:"Import Projects",icon:"Search",action:"discoverAgents",category:"quick-action",priority:4},{id:"browse",label:"Browse Filesystem",icon:"FolderOpen",action:"browseFilesystem",category:"quick-action",priority:5},{id:"theme",label:"Toggle Theme",icon:"Moon",action:"toggleTheme",category:"quick-action",priority:6},{id:"canvas",label:"Toggle Canvas",icon:"PanelRight",action:"toggleCanvas",category:"quick-action",priority:7}];function FV(e,t){let n;for(const s of t){const r=s.endsWith("/")?s.slice(0,-1):s;(e===r||e.startsWith(r+"/"))&&(!n||r.length>n.length)&&(n=r)}return n}function Elt(){return a.jsxs("svg",{viewBox:"0 0 240 120",className:"mx-auto h-24 w-48","aria-hidden":"true",children:[a.jsx("path",{d:"M15 25 L33 25 L37 33 L60 33 L60 77 L15 77 Z",className:"fill-none stroke-current",strokeWidth:"1.5"}),a.jsx("rect",{x:"23",y:"44",width:"16",height:"2",rx:"1",className:"fill-current opacity-40"}),a.jsx("rect",{x:"23",y:"50",width:"26",height:"2",rx:"1",className:"fill-current opacity-20"}),a.jsx("rect",{x:"23",y:"56",width:"20",height:"2",rx:"1",className:"fill-current opacity-20"}),a.jsx("path",{d:"M180 25 L198 25 L202 33 L225 33 L225 77 L180 77 Z",className:"fill-none stroke-current",strokeWidth:"1.5"}),a.jsx("rect",{x:"188",y:"44",width:"20",height:"2",rx:"1",className:"fill-current opacity-40"}),a.jsx("rect",{x:"188",y:"50",width:"14",height:"2",rx:"1",className:"fill-current opacity-20"}),a.jsx("rect",{x:"188",y:"56",width:"24",height:"2",rx:"1",className:"fill-current opacity-20"}),a.jsx("circle",{cx:"120",cy:"48",r:"18",className:"fill-none stroke-current",strokeWidth:"2"}),a.jsx("line",{x1:"133",y1:"61",x2:"148",y2:"76",className:"stroke-current",strokeWidth:"3",strokeLinecap:"round"}),a.jsx("path",{d:"M110 38 Q114 33 120 32",className:"fill-none stroke-current opacity-30",strokeWidth:"1.5",strokeLinecap:"round"}),a.jsx("line",{x1:"63",y1:"55",x2:"102",y2:"50",className:"stroke-current opacity-40",strokeWidth:"1.5",strokeDasharray:"4 3"}),a.jsx("line",{x1:"138",y1:"50",x2:"177",y2:"55",className:"stroke-current opacity-40",strokeWidth:"1.5",strokeDasharray:"4 3"})]})}const Tlt=[{name:"claude-code",signal:"AGENTS.md",label:"Claude Code project"},{name:"cursor",signal:".cursor/",label:"Cursor project"},{name:"codex",signal:".codex/",label:"Codex project"},{name:"dork",signal:".dork/agent.json",label:"DorkOS agent (auto-imported)"}];function mue({fullBleed:e=!1}){var re;const{roots:t,setScanRoots:n}=hce(),[s,r]=x.useState(null),[i,o]=x.useState(!1),[l,c]=x.useState(3),{startScan:u}=Nce(),{candidates:d,existingAgents:f,isScanning:m,progress:g,error:y,lastScanAt:b}=xP(),{mutate:S}=dce(),{mutate:w}=hJe(),{data:C}=ba(),{actedPaths:T,markActed:E,resetActed:j}=jce(),_=s??t;function N(U){r(U),n(U)}function R(){_.length>0&&(j(),u({roots:_,maxDepth:l}))}const M=x.useMemo(()=>m?d:Ace(d),[d,m]).filter(U=>!T.has(U.path)),L=(((re=C==null?void 0:C.agents)==null?void 0:re.length)??0)>0,P=f.length>0,$=d.length>0,q=P||$,K=!m&&b!==null,B=!m&&b===null;function V(){for(const U of M)E(U.path),S({path:U.path,overrides:kC(U),scanRoot:FV(U.path,_)},{onSuccess:()=>E(U.path)})}const Q=a.jsxs("div",{children:[a.jsxs("button",{type:"button",onClick:()=>o(!i),className:"text-muted-foreground hover:text-foreground flex items-center gap-1 text-xs",children:[a.jsx(Hs,{className:`size-3 transition-transform ${i?"":"-rotate-90"}`}),"Advanced"]}),i&&a.jsxs("div",{className:"bg-muted/30 mt-2 space-y-3 rounded-lg border p-3",children:[a.jsx(Oce,{roots:_,onChange:N}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("label",{htmlFor:"scan-depth",className:"text-muted-foreground text-xs",children:"Scan depth"}),a.jsx("input",{id:"scan-depth",type:"range",min:1,max:5,value:l,onChange:U=>c(Number(U.target.value)),className:"flex-1"}),a.jsx("span",{className:"min-w-[1.5rem] text-center text-xs font-medium",children:l})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("p",{className:"text-muted-foreground flex items-center gap-1 text-xs",children:[a.jsx(FRe,{className:"size-3"}),"Detection strategies"]}),a.jsx("ul",{className:"space-y-1 pl-4",children:Tlt.map(U=>a.jsxs("li",{className:"flex items-baseline gap-1.5",children:[a.jsx("code",{className:"text-foreground/70 text-[10px]",children:U.signal}),a.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["→ ",U.label]})]},U.name))})]})]})]});return a.jsx("div",{className:e?"flex h-full flex-col p-6":"space-y-4 p-4",children:B?a.jsx("div",{className:e?"flex flex-1 items-center justify-center":"",children:a.jsxs("div",{className:e?"w-full max-w-sm space-y-5":"space-y-5",children:[a.jsx(Elt,{}),a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-foreground text-sm font-medium",children:"Find your existing projects"}),a.jsx("p",{className:"text-muted-foreground mx-auto mt-1 max-w-[300px] text-xs leading-relaxed",children:"Scan your filesystem for Claude Code, Cursor, Codex, and other AI projects to manage in one place."})]}),y&&a.jsx("div",{className:"border-destructive/30 bg-destructive/5 text-destructive rounded-lg border px-4 py-3 text-sm",children:y}),a.jsxs(ge,{onClick:R,disabled:_.length===0,className:"w-full",children:[a.jsx(pa,{className:"size-4"}),"Search for Projects"]}),a.jsx("p",{className:"text-muted-foreground/60 text-center text-xs",children:"Read-only scan — nothing changes until you approve"}),Q]})}):a.jsxs(a.Fragment,{children:[e&&a.jsxs("div",{className:"mb-4 space-y-1",children:[a.jsx("h2",{className:"text-lg font-semibold",children:"Import Projects"}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Search for existing projects to import into DorkOS."})]}),a.jsxs("div",{className:"space-y-3",children:[Q,a.jsxs(ge,{onClick:R,disabled:m||_.length===0,children:[m?a.jsx(Sn,{className:"size-4 animate-spin"}):a.jsx(pa,{className:"size-4"}),"Search for Projects"]})]}),a.jsxs("div",{className:e?"mt-4 flex-1 overflow-y-auto":"",children:[m&&a.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 p-8",children:[a.jsx(Sn,{className:"text-muted-foreground size-5 animate-spin"}),g&&a.jsxs("div",{className:"text-muted-foreground space-y-0.5 text-center text-xs",children:[a.jsxs("p",{children:["Scanned ",g.scannedDirs," directories"]}),a.jsxs("p",{children:["Found ",g.foundAgents," project",g.foundAgents===1?"":"s"]})]})]}),y&&a.jsx("div",{className:"border-destructive/30 bg-destructive/5 text-destructive mb-3 rounded-lg border px-4 py-3 text-sm",children:y}),K&&!$&&P&&a.jsxs("div",{className:"rounded-xl border border-dashed p-8 text-center",children:[a.jsx("p",{className:"text-sm font-medium",children:"All projects already imported"}),a.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"All found projects are already imported. Check the Agents tab to see them."})]}),K&&!q&&a.jsxs("div",{className:"rounded-xl border border-dashed p-8 text-center",children:[a.jsx("p",{className:"text-sm font-medium",children:L?"No new projects found":"No projects found"}),a.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:L?"All found projects are already imported. Check the Agents tab to see them.":"Try scanning deeper directories or adding different paths."})]}),K&&M.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(Dce,{count:M.length,onAddAll:V}),a.jsx(Ue,{mode:"popLayout",children:M.map(U=>a.jsx(Rce,{candidate:U,className:"mb-2",onApprove:G=>S({path:G.path,overrides:kC(G),scanRoot:FV(G.path,_)},{onSuccess:()=>E(G.path)}),onSkip:G=>E(G.path),onDeny:G=>w({path:G.path},{onSuccess:()=>E(G.path)})},U.path))})]}),K&&P&&a.jsx("div",{className:"mt-3",children:a.jsx(Mce,{agents:f})})]})]})})}function pue({icon:e,headline:t,description:n,action:s,preview:r}){return a.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 p-12 text-center",children:[r&&a.jsx("div",{className:"pointer-events-none mb-4 w-full max-w-sm opacity-40 select-none",children:r}),a.jsx("div",{className:"bg-muted/50 rounded-xl p-3",children:a.jsx(e,{className:"text-muted-foreground size-6"})}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm font-medium",children:t}),a.jsx("p",{className:"text-muted-foreground max-w-[280px] text-xs",children:n})]}),s&&a.jsx(ge,{size:"sm",onClick:s.onClick,className:"mt-1",children:s.label})]})}function _lt({namespace:e,agentCount:t,agents:n}){const[s,r]=x.useState(!1);return a.jsxs("div",{className:"rounded-xl border",children:[a.jsxs("button",{type:"button",onClick:()=>r(!s),className:"hover:bg-muted/50 flex w-full items-center gap-2 px-4 py-3 text-left",children:[s?a.jsx(Hs,{className:"size-4"}):a.jsx(Rs,{className:"size-4"}),a.jsx("span",{className:"text-sm font-medium",children:e}),a.jsxs(zt,{variant:"secondary",className:"ml-auto text-xs",children:[t," agent",t!==1?"s":""]})]}),s&&a.jsx("div",{className:"space-y-2 border-t px-4 py-2",children:n.map(i=>a.jsxs("div",{className:"flex items-center justify-between py-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm",children:nn(i)}),a.jsx(zt,{variant:"outline",className:"text-xs",children:i.runtime})]}),i.budget&&a.jsxs("div",{className:"text-muted-foreground flex gap-2 text-xs",children:[a.jsxs("span",{children:[i.budget.maxCallsPerHour," calls/hr"]}),a.jsxs("span",{children:[i.budget.maxHopsPerMessage," max hops"]})]})]},i.id))})]})}function Nlt({sourceNamespace:e,targetNamespace:t,action:n,onRemove:s}){return a.jsxs("div",{className:"flex items-center justify-between rounded-lg border px-3 py-2",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:"font-mono",children:e}),a.jsx("span",{className:"text-muted-foreground",children:"→"}),a.jsx("span",{className:"font-mono",children:t}),a.jsx(zt,{variant:n==="allow"?"default":"destructive",className:"text-xs",children:n})]}),a.jsx(ge,{type:"button",variant:"ghost",size:"icon-sm",onClick:s,className:"text-muted-foreground hover:bg-destructive/10 hover:text-destructive","aria-label":`Remove access from ${e} to ${t}`,children:a.jsx(wo,{})})]})}function jlt({namespaces:e,onAdd:t,isPending:n}){const[s,r]=x.useState(""),[i,o]=x.useState("");function l(c){c.preventDefault(),s&&i&&s!==i&&(t(s,i),r(""),o(""))}return a.jsxs("form",{onSubmit:l,className:"flex items-end gap-2",children:[a.jsxs("div",{className:"flex-1 space-y-1",children:[a.jsx(Rt,{htmlFor:"acl-source",className:"text-muted-foreground text-xs font-medium",children:"Source"}),a.jsxs(On,{value:s,onValueChange:r,children:[a.jsx(_n,{id:"acl-source",className:"w-full",children:a.jsx(In,{placeholder:"Select namespace"})}),a.jsx(Nn,{children:e.map(c=>a.jsx(mt,{value:c,children:c},c))})]})]}),a.jsxs("div",{className:"flex-1 space-y-1",children:[a.jsx(Rt,{htmlFor:"acl-target",className:"text-muted-foreground text-xs font-medium",children:"Target"}),a.jsxs(On,{value:i,onValueChange:o,children:[a.jsx(_n,{id:"acl-target",className:"w-full",children:a.jsx(In,{placeholder:"Select namespace"})}),a.jsx(Nn,{children:e.map(c=>a.jsx(mt,{value:c,children:c},c))})]})]}),a.jsxs(ge,{type:"submit",disabled:n||!s||!i||s===i,children:[n?a.jsx(Sn,{className:"animate-spin"}):a.jsx(Cs,{}),"Allow Access"]})]})}function Alt({onGoToDiscovery:e}={}){const{data:t,isLoading:n}=pP(),{mutate:s,isPending:r}=bJe();if(n)return a.jsx("div",{className:"flex items-center justify-center p-8",children:a.jsx(Sn,{className:"text-muted-foreground size-5 animate-spin"})});const i=(t==null?void 0:t.namespaces)??[],o=(t==null?void 0:t.accessRules)??[],l=i.map(c=>c.namespace);return i.length===0?a.jsx(pue,{icon:Hc,headline:"Cross-project access requires multiple namespaces",description:"Register agents from different directories to create namespaces, then configure cross-namespace access rules.",action:e?{label:"Go to Discovery",onClick:e}:void 0}):a.jsxs("div",{className:"space-y-6 p-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("h3",{className:"text-muted-foreground text-sm font-medium",children:"Namespaces"}),i.map(c=>a.jsx(_lt,{namespace:c.namespace,agentCount:c.agentCount,agents:c.agents},c.namespace))]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("h3",{className:"text-muted-foreground text-sm font-medium",children:"Cross-Project Access Rules"}),o.length===0?a.jsx("p",{className:"text-muted-foreground text-xs",children:"No cross-project rules. Agents can only communicate within their own namespace."}):a.jsx("div",{className:"space-y-1",children:o.map(c=>a.jsx(Nlt,{sourceNamespace:c.sourceNamespace,targetNamespace:c.targetNamespace,action:c.action,onRemove:()=>s({sourceNamespace:c.sourceNamespace,targetNamespace:c.targetNamespace,action:"deny"})},`${c.sourceNamespace}-${c.targetNamespace}`))})]}),l.length>=2&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h3",{className:"text-muted-foreground text-sm font-medium",children:"Allow Cross-Project Access"}),a.jsx(jlt,{namespaces:l,isPending:r,onAdd:(c,u)=>s({sourceNamespace:c,targetNamespace:u,action:"allow"})})]})]})}const gue={active:{label:"Active",color:"bg-green-500"},inactive:{label:"Inactive",color:"bg-amber-500"},stale:{label:"Stale",color:"bg-zinc-400"}};function Rlt(e){return e in gue}function zV({onClick:e}){return a.jsx("button",{type:"button",onClick:e,"aria-label":"Close detail panel",className:"text-muted-foreground hover:text-foreground",children:a.jsx(es,{className:"size-(--size-icon-sm)"})})}function BV({agentId:e,onClose:t,onOpenSettings:n}){const{data:s,isLoading:r}=fce(e);if(r)return a.jsx("div",{className:"flex w-64 items-center justify-center border-l p-4",children:a.jsx("span",{className:"text-muted-foreground text-sm",children:"Loading..."})});if(!s)return a.jsxs("div",{className:"w-64 border-l p-4",children:[a.jsx("div",{className:"flex justify-end",children:a.jsx(zV,{onClick:t})}),a.jsx("p",{className:"text-muted-foreground mt-2 text-sm",children:"Agent not found"})]});const i=Rlt(s.status)?s.status:"stale",o=gue[i];return a.jsxs("div",{className:"w-64 overflow-y-auto border-l p-4",children:[a.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[a.jsx("h3",{className:"truncate text-sm font-semibold",children:s.name}),a.jsx(zV,{onClick:t})]}),a.jsxs("div",{className:"space-y-3 text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${o.color}`,"aria-hidden":"true"}),a.jsx("span",{children:o.label})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-muted-foreground",children:"Last seen: "}),a.jsx("span",{children:s.lastSeenAt?ii(s.lastSeenAt):"Never"})]}),s.lastSeenEvent&&a.jsxs("div",{children:[a.jsx("span",{className:"text-muted-foreground",children:"Last event: "}),a.jsx("span",{children:s.lastSeenEvent})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-muted-foreground",children:"Runtime: "}),a.jsx(zt,{variant:"secondary",className:"text-[0.625rem]",children:s.runtime})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-muted-foreground",children:"Registered: "}),a.jsx("span",{children:s.registeredAt?ii(s.registeredAt):"Unknown"})]}),Array.isArray(s.capabilities)&&s.capabilities.length>0&&a.jsxs("div",{children:[a.jsx("span",{className:"text-muted-foreground mb-1 block",children:"Capabilities:"}),a.jsx("div",{className:"flex flex-wrap gap-1",children:s.capabilities.map(l=>a.jsx(zt,{variant:"outline",className:"text-[0.625rem]",children:l},l))})]})]}),n&&a.jsx("div",{className:"mt-4 border-t pt-3",children:a.jsxs("button",{type:"button",onClick:n,className:"hover:bg-muted inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-1.5 text-xs font-medium",children:[a.jsx(qa,{className:"size-3.5"}),"Open Settings"]})})]})}function Mlt(){const e=je(),t=et();return Bt({mutationFn:n=>e.createAgent(n),onSuccess:()=>{t.invalidateQueries({queryKey:["agents"]}),t.invalidateQueries({queryKey:["mesh","agents"]}),t.invalidateQueries({queryKey:["mesh","agent-paths"]})}})}function Dlt({step:e,creationMode:t,templateName:n}){var O;const s=je(),{data:r}=st({queryKey:["config"],queryFn:()=>s.getConfig(),staleTime:3e4}),i=((O=r==null?void 0:r.agents)==null?void 0:O.defaultDirectory)??"~/.dork/agents",[o,l]=x.useState(""),[c,u]=x.useState(!1),[d,f]=x.useState(""),[m,g]=x.useState(!1),[y,b]=x.useState(!1),[S,w]=x.useState("idle"),C=x.useMemo(()=>o?YOe(o):"",[o]),T=x.useMemo(()=>C?kne(C):{valid:!1,error:void 0},[C]),E=o.length>0&&C.length>0&&!T.valid,j=d||`${i}/${C}`,_=o.length>0&&T.valid&&S!=="error";x.useEffect(()=>{if(e==="configure"&&t==="template"&&n&&!o){const M=n.replace(/^@[^/]+\//,"");l(M),u(!0)}},[e,t,n]),x.useEffect(()=>{if(e!=="configure")return;const M=d||(C?`${i}/${C}`:"");if(!M){w("idle");return}w("checking");const L=setTimeout(async()=>{try{const $=(await s.browseDirectory(M)).entries.some(q=>q.name===".dork");w($?"exists-has-dork":"exists-no-dork")}catch(P){const $=P instanceof Error?P.message:"";$.includes("EACCES")||$.includes("permission")?w("error"):w("no-path")}},500);return()=>clearTimeout(L)},[e,d,C,i,s]);function N(M){l(M),c&&u(!1)}function R(){l(""),u(!1),f(""),g(!1),b(!1),w("idle")}return{displayName:o,slug:C,handleNameChange:N,nameAutoFilled:c,slugValidation:T,showSlugError:E,defaultDirectory:i,resolvedDirectory:j,directoryOverride:d,setDirectoryOverride:f,directoryOpen:m,setDirectoryOpen:g,directoryPickerOpen:y,setDirectoryPickerOpen:b,conflictStatus:S,canSubmit:_,reset:R}}const $V={choose:"How do you want to start?","pick-template":"Pick a template",configure:"Name your agent",import:"Scan for existing projects"};function Olt(e){switch(e){case"template":return"pick-template";case"import":return"import";default:return"choose"}}const Ilt=[{mode:"new",icon:Qg,iconBg:"bg-indigo-500/10 text-indigo-600 dark:text-indigo-400",title:"Start Blank",subtitle:"Empty agent with a name and directory"},{mode:"template",icon:une,iconBg:"bg-purple-500/10 text-purple-600 dark:text-purple-400",title:"From Template",subtitle:"Pre-configured agent from the marketplace"},{mode:"import",icon:pa,iconBg:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",title:"Import Project",subtitle:"Scan for an existing project on disk"}];function Plt({onSelect:e}){return a.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3 sm:gap-3",children:Ilt.map(t=>{const n=t.icon;return a.jsxs("button",{type:"button",onClick:()=>e(t.mode),className:Y("card-interactive flex items-center gap-3 rounded-xl border p-4 text-left","sm:flex-col sm:text-center","hover:border-border/80 transition-all duration-200 hover:shadow-md","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2"),"data-testid":`method-${t.mode}`,children:[a.jsx("div",{className:Y("flex size-10 shrink-0 items-center justify-center rounded-lg",t.iconBg),children:a.jsx(n,{className:"size-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-semibold",children:t.title}),a.jsx("p",{className:"text-muted-foreground text-[11px]",children:t.subtitle})]})]},t.mode)})})}function Llt({form:e,creationMode:t,template:n,onChangeTemplate:s,onImportInstead:r}){const i=x.useRef(null);return x.useEffect(()=>{const o=setTimeout(()=>{var l;return(l=i.current)==null?void 0:l.focus()},160);return()=>clearTimeout(o)},[]),a.jsxs("div",{className:"space-y-4",children:[t==="template"&&n.source&&a.jsxs("div",{className:"bg-muted/50 flex items-center gap-2 rounded-lg border px-3 py-2",children:[a.jsx("span",{className:"text-sm",children:"📦"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"truncate text-sm font-medium",children:n.name??n.source}),a.jsx("p",{className:"text-muted-foreground text-[11px]",children:"Template selected"})]}),a.jsx("button",{type:"button",onClick:s,className:"text-primary text-xs hover:underline","data-testid":"change-template",children:"Change"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(Rt,{htmlFor:"agent-name",children:"Name"}),a.jsx(sn,{ref:i,id:"agent-name",placeholder:"My Cool Agent",value:e.displayName,onChange:o=>e.handleNameChange(o.target.value),"aria-invalid":e.showSlugError,"aria-describedby":e.showSlugError?"agent-name-error":e.nameAutoFilled?"agent-name-hint":void 0}),e.displayName&&e.slug&&!e.showSlugError&&a.jsxs("p",{className:"text-muted-foreground text-xs",children:["Slug:"," ",a.jsx("code",{className:"bg-muted rounded px-1 py-0.5 font-mono text-xs",children:e.slug})]}),e.showSlugError&&a.jsx("p",{id:"agent-name-error",className:"text-destructive text-xs",role:"alert",children:e.slugValidation.error}),e.nameAutoFilled&&!e.showSlugError&&a.jsx("p",{id:"agent-name-hint",className:"text-muted-foreground text-xs","data-testid":"auto-fill-hint",children:"Pre-filled from template — edit freely"}),e.conflictStatus==="exists-has-dork"&&a.jsxs("div",{"data-testid":"conflict-status",children:[a.jsx("p",{className:"text-warning text-xs font-medium",children:"Existing project detected"}),a.jsx("button",{type:"button",className:"text-primary text-xs hover:underline",onClick:r,"data-testid":"import-instead-link",children:"Import instead?"})]})]}),a.jsxs(ol,{open:e.directoryOpen,onOpenChange:e.setDirectoryOpen,children:[a.jsx(ll,{asChild:!0,children:a.jsxs("button",{type:"button",className:"text-muted-foreground hover:text-foreground flex w-full items-center gap-1 text-sm transition-colors","data-testid":"directory-advanced-toggle",children:[a.jsx(Hs,{className:Y("size-4 transition-transform",e.directoryOpen&&"rotate-180")}),"Directory",e.directoryOverride&&a.jsx("span",{className:"bg-primary/10 text-primary ml-1 rounded px-1.5 py-0.5 text-xs",children:"custom"})]})}),a.jsx(cl,{children:a.jsxs("div",{className:"space-y-1.5 pt-2",children:[a.jsx(h9e,{id:"agent-directory",placeholder:e.slug?e.resolvedDirectory:`${e.defaultDirectory}/...`,value:e.directoryOverride,onChange:e.setDirectoryOverride,onBrowse:()=>e.setDirectoryPickerOpen(!0),browseTestId:"browse-directory-button","data-testid":"directory-preview"}),e.conflictStatus==="no-path"&&a.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"conflict-status",children:"Will create new directory"}),e.conflictStatus==="exists-no-dork"&&a.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"conflict-status",children:"Directory exists — will create project inside"}),e.conflictStatus==="error"&&a.jsx("p",{className:"text-destructive text-xs","data-testid":"conflict-status",children:"Cannot access this path"})]})})]})]})}const Bn={all:["marketplace"],packages:()=>[...Bn.all,"packages"],packageList:e=>[...Bn.packages(),{filter:e}],packageDetail:e=>[...Bn.packages(),"detail",e],preview:()=>[...Bn.all,"preview"],permissionPreview:(e,t)=>t&&Object.keys(t).length>0?[...Bn.preview(),e,t]:[...Bn.preview(),e],installed:e=>e?[...Bn.all,"installed",{projectPath:e}]:[...Bn.all,"installed"],installedDetail:e=>[...Bn.all,"installed","detail",e],sources:()=>[...Bn.all,"sources"]};function jv(e){const t=je();return st({queryKey:Bn.packageList(e),queryFn:()=>t.listMarketplacePackages(e),staleTime:6e4})}function Flt(e,t){const n=je(),{enabled:s=!0,marketplace:r}=t??{};return st({queryKey:Bn.packageDetail(e??""),queryFn:()=>n.getMarketplacePackage(e,r),enabled:s&&e!==null,staleTime:6e4})}function xue(e,t){const n=je(),{enabled:s=!0,...r}=t??{},i=Object.keys(r).length>0;return st({queryKey:Bn.permissionPreview(e??"",i?r:void 0),queryFn:()=>n.previewMarketplacePackage(e,i?r:void 0),enabled:s&&e!==null,staleTime:3e4})}function s_(e){const t=je();return st({queryKey:Bn.installed(e),queryFn:()=>t.listInstalledPackages(e),staleTime:6e4})}function zlt(e,t){const n=je();return st({queryKey:Bn.installedDetail(e??""),queryFn:()=>n.listPackageInstallations(e),enabled:((t==null?void 0:t.enabled)??!0)&&e!==null,staleTime:6e4})}function Blt(){const e=je();return st({queryKey:Bn.sources(),queryFn:()=>e.listMarketplaceSources(),staleTime:6e4})}function $lt(){const e=je(),t=et();return Bt({mutationFn:({name:n,options:s})=>e.installMarketplacePackage(n,s),onSuccess:(n,{name:s,options:r})=>{t.invalidateQueries({queryKey:Bn.installed()}),r!=null&&r.projectPath&&t.invalidateQueries({queryKey:Bn.installed(r.projectPath)}),t.invalidateQueries({queryKey:Bn.packages()}),t.invalidateQueries({queryKey:Bn.packageDetail(s)}),t.invalidateQueries({queryKey:["commands"]})}})}function Hlt(){const e=je(),t=et();return Bt({mutationFn:({name:n,options:s})=>e.uninstallMarketplacePackage(n,s),onSuccess:(n,{name:s,options:r})=>{t.invalidateQueries({queryKey:Bn.installed()}),r!=null&&r.projectPath&&t.invalidateQueries({queryKey:Bn.installed(r.projectPath)}),t.invalidateQueries({queryKey:Bn.packageDetail(s)}),t.invalidateQueries({queryKey:["commands"]})}})}function Ult(){const e=je(),t=et();return Bt({mutationFn:({name:n,options:s})=>e.updateMarketplacePackage(n,s),onSuccess:(n,{name:s,options:r})=>{t.invalidateQueries({queryKey:Bn.installed()}),r!=null&&r.projectPath&&t.invalidateQueries({queryKey:Bn.installed(r.projectPath)}),t.invalidateQueries({queryKey:Bn.packageDetail(s)}),r!=null&&r.apply&&t.invalidateQueries({queryKey:["commands"]})}})}function Vlt(){const e=je(),t=et();return Bt({mutationFn:n=>e.addMarketplaceSource(n),onSuccess:()=>{t.invalidateQueries({queryKey:Bn.sources()}),t.invalidateQueries({queryKey:Bn.packages()})}})}function qlt(){const e=je(),t=et();return Bt({mutationFn:n=>e.removeMarketplaceSource(n),onSuccess:()=>{t.invalidateQueries({queryKey:Bn.sources()}),t.invalidateQueries({queryKey:Bn.packages()})}})}function Glt(e){const t=typeof e.q=="string"&&e.q.trim().length>0?e.q:void 0;return{...e,view:e.view==="browse"?void 0:e.view,type:e.type==="all"?void 0:e.type,sort:e.sort==="featured"?void 0:e.sort,q:t,category:e.category??void 0,pkg:e.pkg??void 0}}function E0(){const e=Hn(),t=ml({strict:!1}),n=t.view==="installed"?"installed":"browse",s=typeof t.type=="string"?t.type:"all",r=typeof t.sort=="string"?t.sort:"featured",i=typeof t.q=="string"?t.q:void 0,o=typeof t.category=="string"?t.category:void 0,l=typeof t.pkg=="string"?t.pkg:void 0,c=x.useCallback((w,C)=>{e({search:T=>Glt({...T,...w}),replace:C==null?void 0:C.replace})},[e]),u=x.useCallback(w=>c({view:w}),[c]),d=x.useCallback(w=>c({type:w},{replace:!0}),[c]),f=x.useCallback(w=>c({sort:w},{replace:!0}),[c]),m=x.useCallback(w=>c({q:w},{replace:!0}),[c]),g=x.useCallback(w=>c({category:w??void 0},{replace:!0}),[c]),y=x.useCallback(()=>c({type:void 0,sort:void 0,q:void 0,category:void 0},{replace:!0}),[c]),b=x.useCallback(w=>c({pkg:w}),[c]),S=x.useCallback(()=>c({pkg:void 0},{replace:!0}),[c]);return{view:n,type:s,sort:r,search:i??"",category:o??null,selectedPackageName:l??null,setView:u,setType:d,setSort:f,setSearch:m,setCategory:g,resetFilters:y,openDetail:b,closeDetail:S}}const Klt=300,Wlt=[{value:"all",label:"All"},{value:"agent",label:"Agents"},{value:"plugin",label:"Plugins"},{value:"skill-pack",label:"Skill Packs"},{value:"adapter",label:"Adapters"}];function Ylt(){const{search:e,type:t,setSearch:n,setType:s}=E0(),r=x.useRef(null),[i,o]=x.useState(e);x.useEffect(()=>{if(i===e)return;const c=setTimeout(()=>n(i),Klt);return()=>clearTimeout(c)},[i,e,n]),x.useEffect(()=>{o(e)},[e]);const l=x.useCallback(c=>{var f;if(c.key!=="/"||c.metaKey||c.ctrlKey||c.altKey)return;const u=c.target,d=u==null?void 0:u.tagName;d==="INPUT"||d==="TEXTAREA"||d==="SELECT"||u!=null&&u.isContentEditable||(c.preventDefault(),(f=r.current)==null||f.focus())},[]);return x.useEffect(()=>(document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)),[l]),a.jsxs("header",{className:"space-y-3",children:[a.jsxs("div",{className:"group/search relative",children:[a.jsx(Rt,{htmlFor:"marketplace-search",className:"sr-only",children:"Search packages"}),a.jsx(pa,{className:"text-muted-foreground group-focus-within/search:text-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 transition-colors duration-200","aria-hidden":!0}),a.jsx(sn,{ref:r,id:"marketplace-search","data-testid":"marketplace-search",value:i,onChange:c=>o(c.target.value),placeholder:"Search packages…",className:"pr-10 pl-9 transition-shadow duration-200 focus:shadow-md"}),a.jsx("kbd",{className:"text-muted-foreground/60 pointer-events-none absolute top-1/2 right-3 -translate-y-1/2 rounded border border-current/20 px-1.5 py-0.5 font-mono text-[10px] leading-none group-focus-within/search:opacity-0",children:"/"})]}),a.jsx(CT,{value:t,onValueChange:c=>s(c),"aria-label":"Filter by package type",children:a.jsx(Mb,{className:"h-auto flex-wrap gap-1 bg-transparent p-0",children:Wlt.map(c=>a.jsx(_c,{value:c.value,className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground rounded-full",children:c.label},c.value))})})]})}const Zlt={installConfirmPackage:null,installContext:null},Kp=gl()(kd(e=>({...Zlt,openInstallConfirm:(t,n)=>e({installConfirmPackage:t,installContext:n??null},!1,"marketplace/openInstallConfirm"),closeInstallConfirm:()=>e({installConfirmPackage:null,installContext:null},!1,"marketplace/closeInstallConfirm")}),{name:"MarketplaceStore"})),Xlt={agent:"border-blue-500/20 bg-blue-500/10 text-blue-600 dark:text-blue-400",plugin:"border-purple-500/20 bg-purple-500/10 text-purple-600 dark:text-purple-400","skill-pack":"border-emerald-500/20 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",adapter:"border-amber-500/20 bg-amber-500/10 text-amber-600 dark:text-amber-400"},Qlt={agent:"AGENT",plugin:"PLUGIN","skill-pack":"SKILL PACK",adapter:"ADAPTER"};function IP({type:e,className:t}){return a.jsx(zt,{variant:"outline",className:Y("font-mono text-[10px] tracking-wider",Xlt[e],t),children:Qlt[e]})}function Jlt(e){return typeof e=="string"?e:e&&typeof e=="object"&&"name"in e?String(e.name):null}function PP({pkg:e,installed:t,onClick:n,onInstallClick:s,variant:r="default"}){const i=e.type??"plugin",o=Jlt(e.author)??e.marketplace??null,l=r==="compact",c=u=>{u.stopPropagation(),s==null||s(u)};return a.jsxs("div",{role:"button",tabIndex:0,onClick:n,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),n())},className:Y("card-interactive group bg-card flex h-full cursor-pointer flex-col rounded-xl border text-left",l?"p-4":"p-6","hover:border-border/80 transition-all duration-200 hover:shadow-md","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2"),"data-testid":`package-card-${e.name}`,children:[a.jsxs("div",{className:"mb-3 flex items-start justify-between gap-2",children:[a.jsx("span",{className:"text-2xl leading-none","aria-hidden":!0,children:e.icon??"📦"}),!l&&e.featured&&a.jsx(YE,{className:"size-4 shrink-0 fill-amber-400 text-amber-400","aria-label":"Featured package"})]}),a.jsx("h3",{className:"mb-1 text-sm leading-tight font-semibold",children:e.name}),a.jsx(IP,{type:i,className:"mb-3 self-start"}),e.description&&a.jsx("p",{className:"text-muted-foreground mb-3 line-clamp-2 text-xs",children:e.description}),!l&&o&&a.jsxs("div",{className:"text-muted-foreground mb-3 flex items-center gap-1.5 text-[11px]",children:[a.jsx(Md,{className:"size-3 shrink-0","aria-hidden":!0}),a.jsx("span",{className:"truncate",children:o})]}),!l&&a.jsx("div",{className:"mt-auto flex items-center justify-end gap-2",children:t?a.jsxs("span",{className:"flex items-center gap-1 text-xs text-emerald-600 dark:text-emerald-400",children:[a.jsx(Lt,{className:"size-3","aria-hidden":!0}),"Installed"]}):a.jsxs(ge,{size:"sm",variant:"ghost",onClick:c,className:"gap-1",children:["Install",a.jsx("span",{className:"inline-block transition-transform duration-200 group-hover:translate-x-0.5",children:"→"})]})})]})}const Zx=3,ect=3;function tct({label:e}){return a.jsxs("section",{"aria-label":e,className:"space-y-3",children:[a.jsx("h2",{className:"text-base font-semibold",children:e}),a.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3",children:Array.from({length:ect}).map((t,n)=>a.jsx(Jt,{className:"h-48 rounded-xl"},n))})]})}function HV({label:e,packages:t}){const{openDetail:n}=E0(),s=Kp(r=>r.openInstallConfirm);return a.jsxs("section",{"aria-label":e,className:"space-y-3",children:[a.jsx("h2",{className:"text-base font-semibold",children:e}),a.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3",children:t.map(r=>a.jsx("div",{className:"h-full",children:a.jsx(PP,{pkg:r,onClick:()=>n(r.name),onInstallClick:()=>s(r)})},r.name))})]})}function nct(){const{data:e,isLoading:t}=jv({type:"agent"}),{data:n,isLoading:s}=jv(),r=Ds(),{search:i,type:o}=E0(),l=i.length>0||o!=="all",c=t||s;let u=null;if(c&&!l)u=a.jsx(tct,{label:"Featured"});else if(!l){const d=(e??[]).filter(f=>f.featured).slice(0,Zx);if(d.length>0)u=a.jsx(HV,{label:"Featured Agents",packages:d});else{const f=n??[];if(f.length>0){const m=new Set,g=[];for(const y of f){const b=y.type??"plugin";if(m.has(b)||(m.add(b),g.push(y)),g.length>=Zx)break}if(g.length<Zx){for(const y of f)if(g.some(b=>b.name===y.name)||g.push(y),g.length>=Zx)break}u=a.jsx(HV,{label:"Popular Packages",packages:g.slice(0,Zx)})}}}return a.jsx(Ue,{initial:!1,children:u&&a.jsx(te.div,{initial:r?!1:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:r?void 0:{opacity:0,height:0,transition:{duration:.25,ease:"easeInOut"}},transition:{duration:.3,ease:"easeOut"},className:"overflow-hidden",children:u},"featured-rail")})}var Tn;(function(e){e.assertEqual=r=>{};function t(r){}e.assertIs=t;function n(r){throw new Error}e.assertNever=n,e.arrayToEnum=r=>{const i={};for(const o of r)i[o]=o;return i},e.getValidEnumValues=r=>{const i=e.objectKeys(r).filter(l=>typeof r[r[l]]!="number"),o={};for(const l of i)o[l]=r[l];return e.objectValues(o)},e.objectValues=r=>e.objectKeys(r).map(function(i){return r[i]}),e.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const i=[];for(const o in r)Object.prototype.hasOwnProperty.call(r,o)&&i.push(o);return i},e.find=(r,i)=>{for(const o of r)if(i(o))return o},e.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function s(r,i=" | "){return r.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}e.joinValues=s,e.jsonStringifyReplacer=(r,i)=>typeof i=="bigint"?i.toString():i})(Tn||(Tn={}));var UV;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(UV||(UV={}));const ct=Tn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Iu=e=>{switch(typeof e){case"undefined":return ct.undefined;case"string":return ct.string;case"number":return Number.isNaN(e)?ct.nan:ct.number;case"boolean":return ct.boolean;case"function":return ct.function;case"bigint":return ct.bigint;case"symbol":return ct.symbol;case"object":return Array.isArray(e)?ct.array:e===null?ct.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?ct.promise:typeof Map<"u"&&e instanceof Map?ct.map:typeof Set<"u"&&e instanceof Set?ct.set:typeof Date<"u"&&e instanceof Date?ct.date:ct.object;default:return ct.unknown}},We=Tn.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Pc extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(i){return i.message},s={_errors:[]},r=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(r);else if(o.code==="invalid_return_type")r(o.returnTypeError);else if(o.code==="invalid_arguments")r(o.argumentsError);else if(o.path.length===0)s._errors.push(n(o));else{let l=s,c=0;for(;c<o.path.length;){const u=o.path[c];c===o.path.length-1?(l[u]=l[u]||{_errors:[]},l[u]._errors.push(n(o))):l[u]=l[u]||{_errors:[]},l=l[u],c++}}};return r(this),s}static assert(t){if(!(t instanceof Pc))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Tn.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},s=[];for(const r of this.issues)if(r.path.length>0){const i=r.path[0];n[i]=n[i]||[],n[i].push(t(r))}else s.push(t(r));return{formErrors:s,fieldErrors:n}}get formErrors(){return this.flatten()}}Pc.create=e=>new Pc(e);const OD=(e,t)=>{let n;switch(e.code){case We.invalid_type:e.received===ct.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case We.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Tn.jsonStringifyReplacer)}`;break;case We.unrecognized_keys:n=`Unrecognized key(s) in object: ${Tn.joinValues(e.keys,", ")}`;break;case We.invalid_union:n="Invalid input";break;case We.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Tn.joinValues(e.options)}`;break;case We.invalid_enum_value:n=`Invalid enum value. Expected ${Tn.joinValues(e.options)}, received '${e.received}'`;break;case We.invalid_arguments:n="Invalid function arguments";break;case We.invalid_return_type:n="Invalid function return type";break;case We.invalid_date:n="Invalid date";break;case We.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Tn.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case We.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case We.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case We.custom:n="Invalid input";break;case We.invalid_intersection_types:n="Intersection results could not be merged";break;case We.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case We.not_finite:n="Number must be finite";break;default:n=t.defaultError,Tn.assertNever(e)}return{message:n}};let sct=OD;function rct(){return sct}const ict=e=>{const{data:t,path:n,errorMaps:s,issueData:r}=e,i=[...n,...r.path||[]],o={...r,path:i};if(r.message!==void 0)return{...r,path:i,message:r.message};let l="";const c=s.filter(u=>!!u).slice().reverse();for(const u of c)l=u(o,{data:t,defaultError:l}).message;return{...r,path:i,message:l}};function nt(e,t){const n=rct(),s=ict({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===OD?void 0:OD].filter(r=>!!r)});e.common.issues.push(s)}class ci{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const s=[];for(const r of n){if(r.status==="aborted")return It;r.status==="dirty"&&t.dirty(),s.push(r.value)}return{status:t.value,value:s}}static async mergeObjectAsync(t,n){const s=[];for(const r of n){const i=await r.key,o=await r.value;s.push({key:i,value:o})}return ci.mergeObjectSync(t,s)}static mergeObjectSync(t,n){const s={};for(const r of n){const{key:i,value:o}=r;if(i.status==="aborted"||o.status==="aborted")return It;i.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||r.alwaysSet)&&(s[i.value]=o.value)}return{status:t.value,value:s}}}const It=Object.freeze({status:"aborted"}),vy=e=>({status:"dirty",value:e}),Xa=e=>({status:"valid",value:e}),VV=e=>e.status==="aborted",qV=e=>e.status==="dirty",Dg=e=>e.status==="valid",_C=e=>typeof Promise<"u"&&e instanceof Promise;var vt;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(vt||(vt={}));class fl{constructor(t,n,s,r){this._cachedPath=[],this.parent=t,this.data=n,this._path=s,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const GV=(e,t)=>{if(Dg(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Pc(e.common.issues);return this._error=n,this._error}}};function Wt(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:s,description:r}=e;if(t&&(n||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:r}:{errorMap:(o,l)=>{const{message:c}=e;return o.code==="invalid_enum_value"?{message:c??l.defaultError}:typeof l.data>"u"?{message:c??s??l.defaultError}:o.code!=="invalid_type"?{message:l.defaultError}:{message:c??n??l.defaultError}},description:r}}class hn{get description(){return this._def.description}_getType(t){return Iu(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:Iu(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ci,ctx:{common:t.parent.common,data:t.data,parsedType:Iu(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(_C(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const s=this.safeParse(t,n);if(s.success)return s.data;throw s.error}safeParse(t,n){const s={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Iu(t)},r=this._parseSync({data:t,path:s.path,parent:s});return GV(s,r)}"~validate"(t){var s,r;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Iu(t)};if(!this["~standard"].async)try{const i=this._parseSync({data:t,path:[],parent:n});return Dg(i)?{value:i.value}:{issues:n.common.issues}}catch(i){(r=(s=i==null?void 0:i.message)==null?void 0:s.toLowerCase())!=null&&r.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(i=>Dg(i)?{value:i.value}:{issues:n.common.issues})}async parseAsync(t,n){const s=await this.safeParseAsync(t,n);if(s.success)return s.data;throw s.error}async safeParseAsync(t,n){const s={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Iu(t)},r=this._parse({data:t,path:s.path,parent:s}),i=await(_C(r)?r:Promise.resolve(r));return GV(s,i)}refine(t,n){const s=r=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(r):n;return this._refinement((r,i)=>{const o=t(r),l=()=>i.addIssue({code:We.custom,...s(r)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(l(),!1)):o?!0:(l(),!1)})}refinement(t,n){return this._refinement((s,r)=>t(s)?!0:(r.addIssue(typeof n=="function"?n(s,r):n),!1))}_refinement(t){return new Sh({schema:this,typeName:Pt.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return jc.create(this,this._def)}nullable(){return wh.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return sl.create(this)}promise(){return DC.create(this,this._def)}or(t){return jC.create([this,t],this._def)}and(t){return AC.create(this,t,this._def)}transform(t){return new Sh({...Wt(this._def),schema:this,typeName:Pt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new OC({...Wt(this._def),innerType:this,defaultValue:n,typeName:Pt.ZodDefault})}brand(){return new Sue({typeName:Pt.ZodBranded,type:this,...Wt(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new IC({...Wt(this._def),innerType:this,catchValue:n,typeName:Pt.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return FP.create(this,t)}readonly(){return PC.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const act=/^c[^\s-]{8,}$/i,oct=/^[0-9a-z]+$/,lct=/^[0-9A-HJKMNP-TV-Z]{26}$/i,cct=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,uct=/^[a-z0-9_-]{21}$/i,dct=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,fct=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,hct=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,mct="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let nR;const pct=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,gct=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,xct=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,yct=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,vct=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,bct=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,yue="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Sct=new RegExp(`^${yue}$`);function vue(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function wct(e){return new RegExp(`^${vue(e)}$`)}function kct(e){let t=`${yue}T${vue(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function Cct(e,t){return!!((t==="v4"||!t)&&pct.test(e)||(t==="v6"||!t)&&xct.test(e))}function Ect(e,t){if(!dct.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const s=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(s));return!(typeof r!="object"||r===null||"typ"in r&&(r==null?void 0:r.typ)!=="JWT"||!r.alg||t&&r.alg!==t)}catch{return!1}}function Tct(e,t){return!!((t==="v4"||!t)&&gct.test(e)||(t==="v6"||!t)&&yct.test(e))}class kc extends hn{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==ct.string){const i=this._getOrReturnCtx(t);return nt(i,{code:We.invalid_type,expected:ct.string,received:i.parsedType}),It}const s=new ci;let r;for(const i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(r=this._getOrReturnCtx(t,r),nt(r,{code:We.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),s.dirty());else if(i.kind==="max")t.data.length>i.value&&(r=this._getOrReturnCtx(t,r),nt(r,{code:We.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),s.dirty());else if(i.kind==="length"){const o=t.data.length>i.value,l=t.data.length<i.value;(o||l)&&(r=this._getOrReturnCtx(t,r),o?nt(r,{code:We.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&nt(r,{code:We.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),s.dirty())}else if(i.kind==="email")hct.test(t.data)||(r=this._getOrReturnCtx(t,r),nt(r,{validation:"email",code:We.invalid_string,message:i.message}),s.dirty());else if(i.kind==="emoji")nR||(nR=new RegExp(mct,"u")),nR.test(t.data)||(r=this._getOrReturnCtx(t,r),nt(r,{validation:"emoji",code:We.invalid_string,message:i.message}),s.dirty());else if(i.kind==="uuid")cct.test(t.data)||(r=this._getOrReturnCtx(t,r),nt(r,{validation:"uuid",code:We.invalid_string,message:i.message}),s.dirty());else if(i.kind==="nanoid")uct.test(t.data)||(r=this._getOrReturnCtx(t,r),nt(r,{validation:"nanoid",code:We.invalid_string,message:i.message}),s.dirty());else if(i.kind==="cuid")act.test(t.data)||(r=this._getOrReturnCtx(t,r),nt(r,{validation:"cuid",code:We.invalid_string,message:i.message}),s.dirty());else if(i.kind==="cuid2")oct.test(t.data)||(r=this._getOrReturnCtx(t,r),nt(r,{validation:"cuid2",code:We.invalid_string,message:i.message}),s.dirty());else if(i.kind==="ulid")lct.test(t.data)||(r=this._getOrReturnCtx(t,r),nt(r,{validation:"ulid",code:We.invalid_string,message:i.message}),s.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{r=this._getOrReturnCtx(t,r),nt(r,{validation:"url",code:We.invalid_string,message:i.message}),s.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(r=this._getOrReturnCtx(t,r),nt(r,{validation:"regex",code:We.invalid_string,message:i.message}),s.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(r=this._getOrReturnCtx(t,r),nt(r,{code:We.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),s.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(r=this._getOrReturnCtx(t,r),nt(r,{code:We.invalid_string,validation:{startsWith:i.value},message:i.message}),s.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(r=this._getOrReturnCtx(t,r),nt(r,{code:We.invalid_string,validation:{endsWith:i.value},message:i.message}),s.dirty()):i.kind==="datetime"?kct(i).test(t.data)||(r=this._getOrReturnCtx(t,r),nt(r,{code:We.invalid_string,validation:"datetime",message:i.message}),s.dirty()):i.kind==="date"?Sct.test(t.data)||(r=this._getOrReturnCtx(t,r),nt(r,{code:We.invalid_string,validation:"date",message:i.message}),s.dirty()):i.kind==="time"?wct(i).test(t.data)||(r=this._getOrReturnCtx(t,r),nt(r,{code:We.invalid_string,validation:"time",message:i.message}),s.dirty()):i.kind==="duration"?fct.test(t.data)||(r=this._getOrReturnCtx(t,r),nt(r,{validation:"duration",code:We.invalid_string,message:i.message}),s.dirty()):i.kind==="ip"?Cct(t.data,i.version)||(r=this._getOrReturnCtx(t,r),nt(r,{validation:"ip",code:We.invalid_string,message:i.message}),s.dirty()):i.kind==="jwt"?Ect(t.data,i.alg)||(r=this._getOrReturnCtx(t,r),nt(r,{validation:"jwt",code:We.invalid_string,message:i.message}),s.dirty()):i.kind==="cidr"?Tct(t.data,i.version)||(r=this._getOrReturnCtx(t,r),nt(r,{validation:"cidr",code:We.invalid_string,message:i.message}),s.dirty()):i.kind==="base64"?vct.test(t.data)||(r=this._getOrReturnCtx(t,r),nt(r,{validation:"base64",code:We.invalid_string,message:i.message}),s.dirty()):i.kind==="base64url"?bct.test(t.data)||(r=this._getOrReturnCtx(t,r),nt(r,{validation:"base64url",code:We.invalid_string,message:i.message}),s.dirty()):Tn.assertNever(i);return{status:s.value,value:t.data}}_regex(t,n,s){return this.refinement(r=>t.test(r),{validation:n,code:We.invalid_string,...vt.errToObj(s)})}_addCheck(t){return new kc({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...vt.errToObj(t)})}url(t){return this._addCheck({kind:"url",...vt.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...vt.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...vt.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...vt.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...vt.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...vt.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...vt.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...vt.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...vt.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...vt.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...vt.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...vt.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...vt.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...vt.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...vt.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...vt.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...vt.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...vt.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...vt.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...vt.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...vt.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...vt.errToObj(n)})}nonempty(t){return this.min(1,vt.errToObj(t))}trim(){return new kc({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new kc({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new kc({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}kc.create=e=>new kc({checks:[],typeName:Pt.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Wt(e)});function _ct(e,t){const n=(e.toString().split(".")[1]||"").length,s=(t.toString().split(".")[1]||"").length,r=n>s?n:s,i=Number.parseInt(e.toFixed(r).replace(".","")),o=Number.parseInt(t.toFixed(r).replace(".",""));return i%o/10**r}class Og extends hn{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==ct.number){const i=this._getOrReturnCtx(t);return nt(i,{code:We.invalid_type,expected:ct.number,received:i.parsedType}),It}let s;const r=new ci;for(const i of this._def.checks)i.kind==="int"?Tn.isInteger(t.data)||(s=this._getOrReturnCtx(t,s),nt(s,{code:We.invalid_type,expected:"integer",received:"float",message:i.message}),r.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(s=this._getOrReturnCtx(t,s),nt(s,{code:We.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(s=this._getOrReturnCtx(t,s),nt(s,{code:We.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):i.kind==="multipleOf"?_ct(t.data,i.value)!==0&&(s=this._getOrReturnCtx(t,s),nt(s,{code:We.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(s=this._getOrReturnCtx(t,s),nt(s,{code:We.not_finite,message:i.message}),r.dirty()):Tn.assertNever(i);return{status:r.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,vt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,vt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,vt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,vt.toString(n))}setLimit(t,n,s,r){return new Og({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:s,message:vt.toString(r)}]})}_addCheck(t){return new Og({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:vt.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:vt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:vt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:vt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:vt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:vt.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:vt.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:vt.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:vt.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Tn.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(n===null||s.value>n)&&(n=s.value):s.kind==="max"&&(t===null||s.value<t)&&(t=s.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Og.create=e=>new Og({checks:[],typeName:Pt.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Wt(e)});class Av extends hn{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==ct.bigint)return this._getInvalidInput(t);let s;const r=new ci;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(s=this._getOrReturnCtx(t,s),nt(s,{code:We.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(s=this._getOrReturnCtx(t,s),nt(s,{code:We.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(s=this._getOrReturnCtx(t,s),nt(s,{code:We.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):Tn.assertNever(i);return{status:r.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return nt(n,{code:We.invalid_type,expected:ct.bigint,received:n.parsedType}),It}gte(t,n){return this.setLimit("min",t,!0,vt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,vt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,vt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,vt.toString(n))}setLimit(t,n,s,r){return new Av({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:s,message:vt.toString(r)}]})}_addCheck(t){return new Av({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:vt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:vt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:vt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:vt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:vt.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Av.create=e=>new Av({checks:[],typeName:Pt.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Wt(e)});class ID extends hn{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==ct.boolean){const s=this._getOrReturnCtx(t);return nt(s,{code:We.invalid_type,expected:ct.boolean,received:s.parsedType}),It}return Xa(t.data)}}ID.create=e=>new ID({typeName:Pt.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Wt(e)});class NC extends hn{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==ct.date){const i=this._getOrReturnCtx(t);return nt(i,{code:We.invalid_type,expected:ct.date,received:i.parsedType}),It}if(Number.isNaN(t.data.getTime())){const i=this._getOrReturnCtx(t);return nt(i,{code:We.invalid_date}),It}const s=new ci;let r;for(const i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(r=this._getOrReturnCtx(t,r),nt(r,{code:We.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),s.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(r=this._getOrReturnCtx(t,r),nt(r,{code:We.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),s.dirty()):Tn.assertNever(i);return{status:s.value,value:new Date(t.data.getTime())}}_addCheck(t){return new NC({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:vt.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:vt.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}NC.create=e=>new NC({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:Pt.ZodDate,...Wt(e)});class KV extends hn{_parse(t){if(this._getType(t)!==ct.symbol){const s=this._getOrReturnCtx(t);return nt(s,{code:We.invalid_type,expected:ct.symbol,received:s.parsedType}),It}return Xa(t.data)}}KV.create=e=>new KV({typeName:Pt.ZodSymbol,...Wt(e)});class PD extends hn{_parse(t){if(this._getType(t)!==ct.undefined){const s=this._getOrReturnCtx(t);return nt(s,{code:We.invalid_type,expected:ct.undefined,received:s.parsedType}),It}return Xa(t.data)}}PD.create=e=>new PD({typeName:Pt.ZodUndefined,...Wt(e)});class LD extends hn{_parse(t){if(this._getType(t)!==ct.null){const s=this._getOrReturnCtx(t);return nt(s,{code:We.invalid_type,expected:ct.null,received:s.parsedType}),It}return Xa(t.data)}}LD.create=e=>new LD({typeName:Pt.ZodNull,...Wt(e)});class WV extends hn{constructor(){super(...arguments),this._any=!0}_parse(t){return Xa(t.data)}}WV.create=e=>new WV({typeName:Pt.ZodAny,...Wt(e)});class FD extends hn{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Xa(t.data)}}FD.create=e=>new FD({typeName:Pt.ZodUnknown,...Wt(e)});class bd extends hn{_parse(t){const n=this._getOrReturnCtx(t);return nt(n,{code:We.invalid_type,expected:ct.never,received:n.parsedType}),It}}bd.create=e=>new bd({typeName:Pt.ZodNever,...Wt(e)});class YV extends hn{_parse(t){if(this._getType(t)!==ct.undefined){const s=this._getOrReturnCtx(t);return nt(s,{code:We.invalid_type,expected:ct.void,received:s.parsedType}),It}return Xa(t.data)}}YV.create=e=>new YV({typeName:Pt.ZodVoid,...Wt(e)});class sl extends hn{_parse(t){const{ctx:n,status:s}=this._processInputParams(t),r=this._def;if(n.parsedType!==ct.array)return nt(n,{code:We.invalid_type,expected:ct.array,received:n.parsedType}),It;if(r.exactLength!==null){const o=n.data.length>r.exactLength.value,l=n.data.length<r.exactLength.value;(o||l)&&(nt(n,{code:o?We.too_big:We.too_small,minimum:l?r.exactLength.value:void 0,maximum:o?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),s.dirty())}if(r.minLength!==null&&n.data.length<r.minLength.value&&(nt(n,{code:We.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),s.dirty()),r.maxLength!==null&&n.data.length>r.maxLength.value&&(nt(n,{code:We.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),s.dirty()),n.common.async)return Promise.all([...n.data].map((o,l)=>r.type._parseAsync(new fl(n,o,n.path,l)))).then(o=>ci.mergeArray(s,o));const i=[...n.data].map((o,l)=>r.type._parseSync(new fl(n,o,n.path,l)));return ci.mergeArray(s,i)}get element(){return this._def.type}min(t,n){return new sl({...this._def,minLength:{value:t,message:vt.toString(n)}})}max(t,n){return new sl({...this._def,maxLength:{value:t,message:vt.toString(n)}})}length(t,n){return new sl({...this._def,exactLength:{value:t,message:vt.toString(n)}})}nonempty(t){return this.min(1,t)}}sl.create=(e,t)=>new sl({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Pt.ZodArray,...Wt(t)});function wp(e){if(e instanceof tr){const t={};for(const n in e.shape){const s=e.shape[n];t[n]=jc.create(wp(s))}return new tr({...e._def,shape:()=>t})}else return e instanceof sl?new sl({...e._def,type:wp(e.element)}):e instanceof jc?jc.create(wp(e.unwrap())):e instanceof wh?wh.create(wp(e.unwrap())):e instanceof vh?vh.create(e.items.map(t=>wp(t))):e}class tr extends hn{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=Tn.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==ct.object){const u=this._getOrReturnCtx(t);return nt(u,{code:We.invalid_type,expected:ct.object,received:u.parsedType}),It}const{status:s,ctx:r}=this._processInputParams(t),{shape:i,keys:o}=this._getCached(),l=[];if(!(this._def.catchall instanceof bd&&this._def.unknownKeys==="strip"))for(const u in r.data)o.includes(u)||l.push(u);const c=[];for(const u of o){const d=i[u],f=r.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new fl(r,f,r.path,u)),alwaysSet:u in r.data})}if(this._def.catchall instanceof bd){const u=this._def.unknownKeys;if(u==="passthrough")for(const d of l)c.push({key:{status:"valid",value:d},value:{status:"valid",value:r.data[d]}});else if(u==="strict")l.length>0&&(nt(r,{code:We.unrecognized_keys,keys:l}),s.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const d of l){const f=r.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new fl(r,f,r.path,d)),alwaysSet:d in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const u=[];for(const d of c){const f=await d.key,m=await d.value;u.push({key:f,value:m,alwaysSet:d.alwaysSet})}return u}).then(u=>ci.mergeObjectSync(s,u)):ci.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(t){return vt.errToObj,new tr({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,s)=>{var i,o;const r=((o=(i=this._def).errorMap)==null?void 0:o.call(i,n,s).message)??s.defaultError;return n.code==="unrecognized_keys"?{message:vt.errToObj(t).message??r}:{message:r}}}:{}})}strip(){return new tr({...this._def,unknownKeys:"strip"})}passthrough(){return new tr({...this._def,unknownKeys:"passthrough"})}extend(t){return new tr({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new tr({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Pt.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new tr({...this._def,catchall:t})}pick(t){const n={};for(const s of Tn.objectKeys(t))t[s]&&this.shape[s]&&(n[s]=this.shape[s]);return new tr({...this._def,shape:()=>n})}omit(t){const n={};for(const s of Tn.objectKeys(this.shape))t[s]||(n[s]=this.shape[s]);return new tr({...this._def,shape:()=>n})}deepPartial(){return wp(this)}partial(t){const n={};for(const s of Tn.objectKeys(this.shape)){const r=this.shape[s];t&&!t[s]?n[s]=r:n[s]=r.optional()}return new tr({...this._def,shape:()=>n})}required(t){const n={};for(const s of Tn.objectKeys(this.shape))if(t&&!t[s])n[s]=this.shape[s];else{let i=this.shape[s];for(;i instanceof jc;)i=i._def.innerType;n[s]=i}return new tr({...this._def,shape:()=>n})}keyof(){return bue(Tn.objectKeys(this.shape))}}tr.create=(e,t)=>new tr({shape:()=>e,unknownKeys:"strip",catchall:bd.create(),typeName:Pt.ZodObject,...Wt(t)});tr.strictCreate=(e,t)=>new tr({shape:()=>e,unknownKeys:"strict",catchall:bd.create(),typeName:Pt.ZodObject,...Wt(t)});tr.lazycreate=(e,t)=>new tr({shape:e,unknownKeys:"strip",catchall:bd.create(),typeName:Pt.ZodObject,...Wt(t)});class jC extends hn{_parse(t){const{ctx:n}=this._processInputParams(t),s=this._def.options;function r(i){for(const l of i)if(l.result.status==="valid")return l.result;for(const l of i)if(l.result.status==="dirty")return n.common.issues.push(...l.ctx.common.issues),l.result;const o=i.map(l=>new Pc(l.ctx.common.issues));return nt(n,{code:We.invalid_union,unionErrors:o}),It}if(n.common.async)return Promise.all(s.map(async i=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(r);{let i;const o=[];for(const c of s){const u={...n,common:{...n.common,issues:[]},parent:null},d=c._parseSync({data:n.data,path:n.path,parent:u});if(d.status==="valid")return d;d.status==="dirty"&&!i&&(i={result:d,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const l=o.map(c=>new Pc(c));return nt(n,{code:We.invalid_union,unionErrors:l}),It}}get options(){return this._def.options}}jC.create=(e,t)=>new jC({options:e,typeName:Pt.ZodUnion,...Wt(t)});const ic=e=>e instanceof BD?ic(e.schema):e instanceof Sh?ic(e.innerType()):e instanceof MC?[e.value]:e instanceof bh?e.options:e instanceof $D?Tn.objectValues(e.enum):e instanceof OC?ic(e._def.innerType):e instanceof PD?[void 0]:e instanceof LD?[null]:e instanceof jc?[void 0,...ic(e.unwrap())]:e instanceof wh?[null,...ic(e.unwrap())]:e instanceof Sue||e instanceof PC?ic(e.unwrap()):e instanceof IC?ic(e._def.innerType):[];class LP extends hn{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==ct.object)return nt(n,{code:We.invalid_type,expected:ct.object,received:n.parsedType}),It;const s=this.discriminator,r=n.data[s],i=this.optionsMap.get(r);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(nt(n,{code:We.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),It)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,s){const r=new Map;for(const i of n){const o=ic(i.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const l of o){if(r.has(l))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(l)}`);r.set(l,i)}}return new LP({typeName:Pt.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:r,...Wt(s)})}}function zD(e,t){const n=Iu(e),s=Iu(t);if(e===t)return{valid:!0,data:e};if(n===ct.object&&s===ct.object){const r=Tn.objectKeys(t),i=Tn.objectKeys(e).filter(l=>r.indexOf(l)!==-1),o={...e,...t};for(const l of i){const c=zD(e[l],t[l]);if(!c.valid)return{valid:!1};o[l]=c.data}return{valid:!0,data:o}}else if(n===ct.array&&s===ct.array){if(e.length!==t.length)return{valid:!1};const r=[];for(let i=0;i<e.length;i++){const o=e[i],l=t[i],c=zD(o,l);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return n===ct.date&&s===ct.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class AC extends hn{_parse(t){const{status:n,ctx:s}=this._processInputParams(t),r=(i,o)=>{if(VV(i)||VV(o))return It;const l=zD(i.value,o.value);return l.valid?((qV(i)||qV(o))&&n.dirty(),{status:n.value,value:l.data}):(nt(s,{code:We.invalid_intersection_types}),It)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([i,o])=>r(i,o)):r(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}AC.create=(e,t,n)=>new AC({left:e,right:t,typeName:Pt.ZodIntersection,...Wt(n)});class vh extends hn{_parse(t){const{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==ct.array)return nt(s,{code:We.invalid_type,expected:ct.array,received:s.parsedType}),It;if(s.data.length<this._def.items.length)return nt(s,{code:We.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),It;!this._def.rest&&s.data.length>this._def.items.length&&(nt(s,{code:We.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...s.data].map((o,l)=>{const c=this._def.items[l]||this._def.rest;return c?c._parse(new fl(s,o,s.path,l)):null}).filter(o=>!!o);return s.common.async?Promise.all(i).then(o=>ci.mergeArray(n,o)):ci.mergeArray(n,i)}get items(){return this._def.items}rest(t){return new vh({...this._def,rest:t})}}vh.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new vh({items:e,typeName:Pt.ZodTuple,rest:null,...Wt(t)})};class RC extends hn{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==ct.object)return nt(s,{code:We.invalid_type,expected:ct.object,received:s.parsedType}),It;const r=[],i=this._def.keyType,o=this._def.valueType;for(const l in s.data)r.push({key:i._parse(new fl(s,l,s.path,l)),value:o._parse(new fl(s,s.data[l],s.path,l)),alwaysSet:l in s.data});return s.common.async?ci.mergeObjectAsync(n,r):ci.mergeObjectSync(n,r)}get element(){return this._def.valueType}static create(t,n,s){return n instanceof hn?new RC({keyType:t,valueType:n,typeName:Pt.ZodRecord,...Wt(s)}):new RC({keyType:kc.create(),valueType:t,typeName:Pt.ZodRecord,...Wt(n)})}}class ZV extends hn{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==ct.map)return nt(s,{code:We.invalid_type,expected:ct.map,received:s.parsedType}),It;const r=this._def.keyType,i=this._def.valueType,o=[...s.data.entries()].map(([l,c],u)=>({key:r._parse(new fl(s,l,s.path,[u,"key"])),value:i._parse(new fl(s,c,s.path,[u,"value"]))}));if(s.common.async){const l=new Map;return Promise.resolve().then(async()=>{for(const c of o){const u=await c.key,d=await c.value;if(u.status==="aborted"||d.status==="aborted")return It;(u.status==="dirty"||d.status==="dirty")&&n.dirty(),l.set(u.value,d.value)}return{status:n.value,value:l}})}else{const l=new Map;for(const c of o){const u=c.key,d=c.value;if(u.status==="aborted"||d.status==="aborted")return It;(u.status==="dirty"||d.status==="dirty")&&n.dirty(),l.set(u.value,d.value)}return{status:n.value,value:l}}}}ZV.create=(e,t,n)=>new ZV({valueType:t,keyType:e,typeName:Pt.ZodMap,...Wt(n)});class Rv extends hn{_parse(t){const{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==ct.set)return nt(s,{code:We.invalid_type,expected:ct.set,received:s.parsedType}),It;const r=this._def;r.minSize!==null&&s.data.size<r.minSize.value&&(nt(s,{code:We.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),n.dirty()),r.maxSize!==null&&s.data.size>r.maxSize.value&&(nt(s,{code:We.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),n.dirty());const i=this._def.valueType;function o(c){const u=new Set;for(const d of c){if(d.status==="aborted")return It;d.status==="dirty"&&n.dirty(),u.add(d.value)}return{status:n.value,value:u}}const l=[...s.data.values()].map((c,u)=>i._parse(new fl(s,c,s.path,u)));return s.common.async?Promise.all(l).then(c=>o(c)):o(l)}min(t,n){return new Rv({...this._def,minSize:{value:t,message:vt.toString(n)}})}max(t,n){return new Rv({...this._def,maxSize:{value:t,message:vt.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Rv.create=(e,t)=>new Rv({valueType:e,minSize:null,maxSize:null,typeName:Pt.ZodSet,...Wt(t)});class BD extends hn{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}BD.create=(e,t)=>new BD({getter:e,typeName:Pt.ZodLazy,...Wt(t)});class MC extends hn{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return nt(n,{received:n.data,code:We.invalid_literal,expected:this._def.value}),It}return{status:"valid",value:t.data}}get value(){return this._def.value}}MC.create=(e,t)=>new MC({value:e,typeName:Pt.ZodLiteral,...Wt(t)});function bue(e,t){return new bh({values:e,typeName:Pt.ZodEnum,...Wt(t)})}class bh extends hn{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),s=this._def.values;return nt(n,{expected:Tn.joinValues(s),received:n.parsedType,code:We.invalid_type}),It}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),s=this._def.values;return nt(n,{received:n.data,code:We.invalid_enum_value,options:s}),It}return Xa(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return bh.create(t,{...this._def,...n})}exclude(t,n=this._def){return bh.create(this.options.filter(s=>!t.includes(s)),{...this._def,...n})}}bh.create=bue;class $D extends hn{_parse(t){const n=Tn.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(t);if(s.parsedType!==ct.string&&s.parsedType!==ct.number){const r=Tn.objectValues(n);return nt(s,{expected:Tn.joinValues(r),received:s.parsedType,code:We.invalid_type}),It}if(this._cache||(this._cache=new Set(Tn.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const r=Tn.objectValues(n);return nt(s,{received:s.data,code:We.invalid_enum_value,options:r}),It}return Xa(t.data)}get enum(){return this._def.values}}$D.create=(e,t)=>new $D({values:e,typeName:Pt.ZodNativeEnum,...Wt(t)});class DC extends hn{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==ct.promise&&n.common.async===!1)return nt(n,{code:We.invalid_type,expected:ct.promise,received:n.parsedType}),It;const s=n.parsedType===ct.promise?n.data:Promise.resolve(n.data);return Xa(s.then(r=>this._def.type.parseAsync(r,{path:n.path,errorMap:n.common.contextualErrorMap})))}}DC.create=(e,t)=>new DC({type:e,typeName:Pt.ZodPromise,...Wt(t)});class Sh extends hn{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Pt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:s}=this._processInputParams(t),r=this._def.effect||null,i={addIssue:o=>{nt(s,o),o.fatal?n.abort():n.dirty()},get path(){return s.path}};if(i.addIssue=i.addIssue.bind(i),r.type==="preprocess"){const o=r.transform(s.data,i);if(s.common.async)return Promise.resolve(o).then(async l=>{if(n.value==="aborted")return It;const c=await this._def.schema._parseAsync({data:l,path:s.path,parent:s});return c.status==="aborted"?It:c.status==="dirty"||n.value==="dirty"?vy(c.value):c});{if(n.value==="aborted")return It;const l=this._def.schema._parseSync({data:o,path:s.path,parent:s});return l.status==="aborted"?It:l.status==="dirty"||n.value==="dirty"?vy(l.value):l}}if(r.type==="refinement"){const o=l=>{const c=r.refinement(l,i);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l};if(s.common.async===!1){const l=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return l.status==="aborted"?It:(l.status==="dirty"&&n.dirty(),o(l.value),{status:n.value,value:l.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(l=>l.status==="aborted"?It:(l.status==="dirty"&&n.dirty(),o(l.value).then(()=>({status:n.value,value:l.value}))))}if(r.type==="transform")if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!Dg(o))return It;const l=r.transform(o.value,i);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:l}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>Dg(o)?Promise.resolve(r.transform(o.value,i)).then(l=>({status:n.value,value:l})):It);Tn.assertNever(r)}}Sh.create=(e,t,n)=>new Sh({schema:e,typeName:Pt.ZodEffects,effect:t,...Wt(n)});Sh.createWithPreprocess=(e,t,n)=>new Sh({schema:t,effect:{type:"preprocess",transform:e},typeName:Pt.ZodEffects,...Wt(n)});class jc extends hn{_parse(t){return this._getType(t)===ct.undefined?Xa(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}jc.create=(e,t)=>new jc({innerType:e,typeName:Pt.ZodOptional,...Wt(t)});class wh extends hn{_parse(t){return this._getType(t)===ct.null?Xa(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}wh.create=(e,t)=>new wh({innerType:e,typeName:Pt.ZodNullable,...Wt(t)});class OC extends hn{_parse(t){const{ctx:n}=this._processInputParams(t);let s=n.data;return n.parsedType===ct.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}OC.create=(e,t)=>new OC({innerType:e,typeName:Pt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Wt(t)});class IC extends hn{_parse(t){const{ctx:n}=this._processInputParams(t),s={...n,common:{...n.common,issues:[]}},r=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return _C(r)?r.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Pc(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Pc(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}IC.create=(e,t)=>new IC({innerType:e,typeName:Pt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Wt(t)});class XV extends hn{_parse(t){if(this._getType(t)!==ct.nan){const s=this._getOrReturnCtx(t);return nt(s,{code:We.invalid_type,expected:ct.nan,received:s.parsedType}),It}return{status:"valid",value:t.data}}}XV.create=e=>new XV({typeName:Pt.ZodNaN,...Wt(e)});class Sue extends hn{_parse(t){const{ctx:n}=this._processInputParams(t),s=n.data;return this._def.type._parse({data:s,path:n.path,parent:n})}unwrap(){return this._def.type}}class FP extends hn{_parse(t){const{status:n,ctx:s}=this._processInputParams(t);if(s.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?It:i.status==="dirty"?(n.dirty(),vy(i.value)):this._def.out._parseAsync({data:i.value,path:s.path,parent:s})})();{const r=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?It:r.status==="dirty"?(n.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:s.path,parent:s})}}static create(t,n){return new FP({in:t,out:n,typeName:Pt.ZodPipeline})}}class PC extends hn{_parse(t){const n=this._def.innerType._parse(t),s=r=>(Dg(r)&&(r.value=Object.freeze(r.value)),r);return _C(n)?n.then(r=>s(r)):s(n)}unwrap(){return this._def.innerType}}PC.create=(e,t)=>new PC({innerType:e,typeName:Pt.ZodReadonly,...Wt(t)});var Pt;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Pt||(Pt={}));const Qe=kc.create,Pu=Og.create,r_=ID.create,uo=FD.create;bd.create;const Di=sl.create,Ms=tr.create,Nct=jC.create,jct=LP.create;AC.create;vh.create;const wue=RC.create,Ol=MC.create,kh=bh.create;DC.create;jc.create;wh.create;const kue=Qe().min(1).max(64).regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,"Must be lowercase alphanumeric with hyphens, not starting/ending with hyphen").refine(e=>!e.includes("--"),"Must not contain consecutive hyphens"),Act=kh(["skill","task","command"]);Ms({name:kue,description:Qe().min(1).max(1024),license:Qe().optional(),compatibility:Qe().max(500).optional(),metadata:wue(Qe(),Qe()).optional(),"allowed-tools":Qe().optional(),kind:Act.optional()});const Rct=kh(["agent","plugin","skill-pack","adapter"]),QV=Qe().regex(/^\d+\.\d+\.\d+(-[\w.]+)?(\+[\w.]+)?$/,"Must be a valid semver string"),Mct=Qe().regex(/^(adapter|plugin|skill-pack|agent):[a-z][a-z0-9-]*([@][\w.~^>=<!*-]+)?$/,"Must be of the form <type>:<name> or <type>:<name>@<version>"),Dct=kh(["skills","tasks","commands","hooks","extensions","adapters","mcp-servers","lsp-servers","agents"]),i_=Ms({schemaVersion:Ol(1).default(1),name:kue,version:QV,type:Rct,description:Qe().min(1).max(1024),displayName:Qe().max(128).optional(),author:Qe().max(256).optional(),license:Qe().max(64).optional(),repository:Qe().url().optional(),homepage:Qe().url().optional(),tags:Di(Qe().max(32)).max(20).default([]),category:Qe().max(64).optional(),icon:Qe().max(64).optional(),minDorkosVersion:QV.optional(),layers:Di(Dct).default([]),requires:Di(Mct).default([]),featured:r_().optional()}),Oct=i_.extend({type:Ol("plugin"),extensions:Di(Qe()).default([])}),Ict=i_.extend({type:Ol("agent"),agentDefaults:Ms({persona:Qe().max(4e3).optional(),capabilities:Di(Qe()).default([]),traits:Ms({verbosity:Pu().int().min(1).max(5).optional(),autonomy:Pu().int().min(1).max(5).optional(),chaos:Pu().int().min(1).max(5).optional(),creativity:Pu().int().min(1).max(5).optional(),humor:Pu().int().min(1).max(5).optional(),spice:Pu().int().min(1).max(5).optional()}).optional()}).optional()}),Pct=i_.extend({type:Ol("skill-pack")}),Lct=i_.extend({type:Ol("adapter"),adapterType:Qe().min(1).max(64)});jct("type",[Oct,Ict,Pct,Lct]);const Cue=new Set(["claude-code-marketplace","claude-code-plugins","claude-plugins-official","anthropic-marketplace","anthropic-plugins","agent-skills","knowledge-work-plugins","life-sciences"]),Fct=Qe().regex(/^\.\//,'Relative paths must start with "./"').refine(e=>!e.includes(".."),'Relative paths must not contain ".."'),zct=Ms({source:Ol("github"),repo:Qe().regex(/^[\w.-]+\/[\w.-]+$/,"Must be owner/repo format"),ref:Qe().optional(),sha:Qe().regex(/^[0-9a-f]{40}$/,"SHA must be 40 lowercase hex characters").optional()}),Bct=Ms({source:Ol("url"),url:Qe().url(),ref:Qe().optional(),sha:Qe().regex(/^[0-9a-f]{40}$/,"SHA must be 40 lowercase hex characters").optional()}),$ct=Ms({source:Ol("git-subdir"),url:Qe(),path:Qe().min(1),ref:Qe().optional(),sha:Qe().regex(/^[0-9a-f]{40}$/,"SHA must be 40 lowercase hex characters").optional()}),Hct=Ms({source:Ol("npm"),package:Qe().min(1),version:Qe().optional(),registry:Qe().url().optional()}),Eue=Nct([Fct,zct,Bct,$ct,Hct]),Uct=Ms({name:Qe().min(1),email:Qe().email().optional()}),Tue=Ms({name:Qe().min(1),email:Qe().email().optional()}),_ue=Ms({description:Qe().optional(),version:Qe().optional(),pluginRoot:Qe().optional()}),Nue=Ms({name:Qe().min(1).regex(/^[a-z0-9][a-z0-9-]*$/,"Must be kebab-case"),source:Eue,description:Qe().optional(),version:Qe().optional(),author:Uct.optional(),homepage:Qe().url().optional(),repository:Qe().url().optional(),license:Qe().max(64).optional(),keywords:Di(Qe()).max(50).optional(),category:Qe().max(64).optional(),tags:Di(Qe().max(32)).max(20).optional(),strict:r_().optional(),commands:uo().optional(),agents:uo().optional(),hooks:uo().optional(),mcpServers:uo().optional(),lspServers:uo().optional()}).passthrough();Ms({name:Qe().min(1).regex(/^[a-z0-9][a-z0-9-]*$/,"Must be kebab-case").refine(e=>!Cue.has(e),"Reserved marketplace name — see CC reserved list"),owner:Tue,metadata:_ue.optional(),plugins:Di(Nue)}).passthrough();const Vct=Ms({model:kh(["free","paid","freemium","byo-license"]),priceUsd:Pu().nonnegative().optional(),billingPeriod:kh(["one-time","monthly","yearly"]).optional(),trialDays:Pu().int().nonnegative().optional()}),qct=Ms({type:kh(["agent","plugin","skill-pack","adapter"]).optional(),layers:Di(kh(["skills","tasks","commands","hooks","extensions","adapters","mcp-servers","lsp-servers","agents"])).optional(),requires:Di(Qe().regex(/^(adapter|plugin|skill-pack|agent):[a-z][a-z0-9-]*([@][\w.~^>=<!*-]+)?$/)).optional(),featured:r_().optional(),icon:Qe().max(64).optional(),dorkosMinVersion:Qe().regex(/^\d+\.\d+\.\d+(-[\w.]+)?(\+[\w.]+)?$/).optional(),pricing:Vct.optional()});Ms({$schema:Qe().optional(),schemaVersion:Ol(1),plugins:wue(Qe(),qct)});const Gct=Eue,Kct=Ms({name:Qe().min(1),email:Qe().email().optional()}).strict(),Wct=Ms({name:Qe().min(1),email:Qe().email().optional()}).strict(),Yct=Ms({description:Qe().optional(),version:Qe().optional(),pluginRoot:Qe().optional()}).strict(),Zct=Ms({name:Qe().min(1).regex(/^[a-z0-9][a-z0-9-]*$/,"Must be kebab-case"),source:Gct,description:Qe().optional(),version:Qe().optional(),author:Kct.optional(),homepage:Qe().url().optional(),repository:Qe().url().optional(),license:Qe().max(64).optional(),keywords:Di(Qe()).max(50).optional(),category:Qe().max(64).optional(),tags:Di(Qe().max(32)).max(20).optional(),strict:r_().optional(),commands:uo().optional(),agents:uo().optional(),hooks:uo().optional(),mcpServers:uo().optional(),lspServers:uo().optional()}).strict();Ms({name:Qe().min(1).regex(/^[a-z0-9][a-z0-9-]*$/,"Must be kebab-case").refine(e=>!Cue.has(e),"Reserved marketplace name — see CC reserved list"),owner:Wct,metadata:Yct.optional(),plugins:Di(Zct)}).strict();Ms({name:Qe().min(1).regex(/^[a-z0-9][a-z0-9.-]*$/,"Must be kebab-case (letters, digits, dots, hyphens)"),owner:Tue,metadata:_ue.optional(),plugins:Di(uo())}).passthrough();Nue.extend({name:Qe().min(1).regex(/^[a-z0-9][a-z0-9.-]*$/,"Must be kebab-case (letters, digits, dots, hyphens)")});function Xct(e,t){return e.name.toLowerCase().includes(t)||(e.description??"").toLowerCase().includes(t)||(e.keywords??[]).some(n=>n.toLowerCase().includes(t))?!0:(e.tags??[]).some(n=>n.toLowerCase().includes(t))}function Qct(e,t){return t==="all"?!0:(e.type??"plugin")===t}function Jct(e,t){const n=t.search.trim().toLowerCase();return e.filter(s=>!(!Qct(s,t.type)||t.category!==null&&s.category!==t.category||n&&!Xct(s,n)))}function jue(e,t){return e.name.localeCompare(t.name)}function eut(e,t){const n=e.featured?1:0,s=t.featured?1:0;return n!==s?s-n:jue(e,t)}function tut(e,t){const n=[...e];switch(t){case"featured":return n.sort(eut);case"popular":case"recent":case"name":return n.sort(jue)}}function Aue({count:e=8}){return a.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4","aria-busy":"true","aria-label":"Loading packages",children:Array.from({length:e}).map((t,n)=>a.jsxs("div",{className:"bg-card rounded-xl border p-6",children:[a.jsx("div",{className:"mb-3 flex items-start justify-between gap-2",children:a.jsx(Jt,{className:"size-6 rounded-full"})}),a.jsx(Jt,{className:"mb-1 h-4 w-3/4"}),a.jsx(Jt,{className:"mb-3 h-3 w-16"}),a.jsx(Jt,{className:"mb-1 h-3 w-full"}),a.jsx(Jt,{className:"mb-4 h-3 w-2/3"}),a.jsx("div",{className:"flex items-center justify-end",children:a.jsx(Jt,{className:"h-7 w-16"})})]},n))})}function Rue({onResetFilters:e,title:t="No packages match your filters",description:n="Try adjusting your search or category filters."}){return a.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-dashed py-16 text-center",children:[a.jsx(GMe,{className:"text-muted-foreground mb-4 size-10","aria-hidden":!0}),a.jsx("h3",{className:"mb-2 text-base font-semibold",children:t}),a.jsx("p",{className:"text-muted-foreground mb-4 max-w-sm text-sm",children:n}),e&&a.jsx(ge,{variant:"outline",onClick:e,children:"Reset filters"})]})}const nut=/network|fetch|offline/i;function Mue({error:e,onRetry:t}){const n=nut.test(e.message),s=n?ZE:fr,r=n?"You appear to be offline":"Something went wrong";return a.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-dashed py-16 text-center",children:[a.jsx(s,{className:"text-muted-foreground mb-4 size-10","aria-hidden":!0}),a.jsx("h3",{className:"mb-2 text-base font-semibold",children:r}),a.jsx("p",{className:"text-muted-foreground mb-4 max-w-sm text-sm",children:e.message}),a.jsx(ge,{variant:"outline",onClick:t,children:"Try again"})]})}const sut=[{value:"featured",label:"Featured"},{value:"name",label:"A–Z"},{value:"recent",label:"Recent"},{value:"popular",label:"Popular"}],HD=20,rut=.03,iut={hidden:{},visible:{transition:{staggerChildren:rut}}},aut={hidden:e=>({opacity:e<HD?0:1,y:e<HD?12:0}),visible:{opacity:1,y:0,transition:{duration:.25,ease:"easeOut"}}};function out(){const{data:e,isLoading:t,error:n,refetch:s}=jv(),{data:r}=s_(),i=Ds(),{type:o,category:l,search:c,sort:u,setSort:d,resetFilters:f,openDetail:m}=E0(),g=Kp(S=>S.openInstallConfirm),y=x.useMemo(()=>e?tut(Jct(e,{type:o,category:l,search:c}),u):[],[e,o,l,c,u]),b=x.useMemo(()=>new Set((r??[]).map(S=>S.name)),[r]);return t?a.jsx(Aue,{}):n?a.jsx(Mue,{error:n,onRetry:()=>void s()}):y.length===0?a.jsx(Rue,{onResetFilters:f}):a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsxs("h2",{className:"text-base font-semibold",children:["All Packages",a.jsxs("span",{className:"text-muted-foreground ml-2 text-sm font-normal",children:["(",y.length,")"]})]}),a.jsxs(On,{value:u,onValueChange:S=>d(S),children:[a.jsx(_n,{className:"h-8 w-32 text-xs",children:a.jsx(In,{})}),a.jsx(Nn,{children:sut.map(S=>a.jsx(mt,{value:S.value,className:"text-xs",children:S.label},S.value))})]})]}),a.jsx(te.div,{variants:i?void 0:iut,initial:"hidden",animate:"visible",className:"grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4",children:y.map((S,w)=>a.jsx(te.div,{variants:i?void 0:aut,custom:w<HD?w:0,className:"h-full",children:a.jsx(PP,{pkg:S,installed:b.has(S.name),onClick:()=>m(S.name),onInstallClick:()=>g(S)})},S.name))})]})}function JV(e){return e instanceof Error?`Uninstall failed: ${e.message}`:"Uninstall failed: unknown error"}function pw(e){return e.where?`${e.name} from ${e.where}`:e.name}function Due(){const e=Hlt(),{mutate:t,mutateAsync:n}=e,s=x.useCallback(({where:i,...o})=>{const l=Ye.loading(`Uninstalling ${pw({...o,where:i})}…`);t(o,{onSuccess:()=>{Ye.success(`Uninstalled ${pw({...o,where:i})}`,{id:l})},onError:c=>{Ye.error(JV(c),{id:l})}})},[t]),r=x.useCallback(async({where:i,...o})=>{const l=Ye.loading(`Uninstalling ${pw({...o,where:i})}…`);try{const c=await n(o);return Ye.success(`Uninstalled ${pw({...o,where:i})}`,{id:l}),c}catch(c){throw Ye.error(JV(c),{id:l}),c}},[n]);return{...e,mutate:s,mutateAsync:r}}function lut(e){const t=[];e.fileChanges.length>0&&t.push({icon:"file",label:`${e.fileChanges.length} file${e.fileChanges.length===1?"":"s"} will be created, modified, or deleted`});for(const n of e.extensions)t.push({icon:"puzzle",label:`Register UI extension: ${n.id}`,description:n.slots.length>0?`Slots: ${n.slots.join(", ")}`:void 0});for(const n of e.tasks)t.push({icon:"clock",label:`Schedule task: ${n.name}${n.cron?` (${n.cron})`:""}`});return t}function cut(e){return{effects:lut(e),secrets:e.secrets.map(t=>({icon:"key",label:t.key+(t.required?"":" (optional)"),description:t.description,severity:t.required?"warning":"info"})),hosts:e.externalHosts.map(t=>({icon:"globe",label:t})),dependencies:e.requires.map(t=>({icon:t.satisfied?"check":"alert-triangle",label:`${t.type}:${t.name}${t.version?`@${t.version}`:""}`,severity:t.satisfied?"info":"warning"})),conflicts:e.conflicts.map(t=>({icon:"alert-triangle",label:t.description,description:t.conflictingPackage?`Conflicts with: ${t.conflictingPackage}`:void 0,severity:t.level==="error"?"error":"warning"}))}}const uut={file:qh,puzzle:X5,clock:Pi,key:lMe,globe:ha,check:Lt,"alert-triangle":fr},eq={info:"text-muted-foreground",warning:"text-amber-600 dark:text-amber-400",error:"text-destructive"};function dut({item:e}){const t=uut[e.icon]??qh,n=e.severity?eq[e.severity]:eq.info;return a.jsxs("li",{className:Y("flex items-start gap-2 text-sm",n),children:[a.jsx(t,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),a.jsxs("div",{className:"flex-1",children:[a.jsx("span",{children:e.label}),e.description&&a.jsx("p",{className:"text-muted-foreground mt-0.5 text-xs",children:e.description})]})]})}function Xx({title:e,items:t,tone:n,defaultOpen:s}){if(t.length===0)return null;const r=s??t.length<=3;return a.jsxs("details",{open:r,className:"group/perm",children:[a.jsxs("summary",{className:Y("flex cursor-pointer list-none items-center gap-2 text-xs font-semibold tracking-wider uppercase","select-none [&::-webkit-details-marker]:hidden",n==="warning"?"text-amber-600 dark:text-amber-400":"text-muted-foreground"),children:[a.jsx(Rs,{className:"size-3 shrink-0 transition-transform duration-200 group-open/perm:rotate-90"}),e,a.jsxs("span",{className:"text-muted-foreground font-normal tracking-normal normal-case",children:["(",t.length,")"]})]}),a.jsx("ul",{className:"mt-2 space-y-1.5",children:t.map((i,o)=>a.jsx(dut,{item:i},o))})]})}function Oue({preview:e}){const t=cut(e);return a.jsxs("div",{className:"space-y-6",children:[a.jsx(Xx,{title:"What this package will do",items:t.effects}),a.jsx(Xx,{title:"Secrets required",items:t.secrets}),a.jsx(Xx,{title:"External hosts",items:t.hosts}),a.jsx(Xx,{title:"Dependencies",items:t.dependencies}),a.jsx(Xx,{title:"Conflicts",items:t.conflicts,tone:"warning"})]})}function fut(e){if(typeof e=="string")return e;if(e&&typeof e=="object"&&"name"in e)return String(e.name)}function Iue(e){return e.scope===void 0||e.scope==="global"}function UD(e){var t;return Iue(e)?"All agents (global)":e.agentName??((t=e.agentPath)==null?void 0:t.split("/").filter(Boolean).pop())??"This agent"}function hut(e){if(!e)return null;const t=[];return e.commands>0&&t.push(`${e.commands} command${e.commands===1?"":"s"}`),e.skills>0&&t.push(`${e.skills} skill${e.skills===1?"":"s"}`),e.hooks&&t.push("hooks"),t.length>0?t.join(" · "):null}const mut=3e3;function put(){return a.jsxs("div",{className:"space-y-4",children:[a.jsx(Jt,{className:"h-4 w-3/4"}),a.jsx(Jt,{className:"h-4 w-1/2"}),a.jsx(Jt,{className:"h-20 w-full rounded-lg"}),a.jsx(Jt,{className:"h-4 w-2/3"})]})}function sR({icon:e,children:t}){return a.jsxs("div",{className:"bg-muted/50 flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs",children:[a.jsx(e,{className:"text-muted-foreground size-3 shrink-0","aria-hidden":!0}),a.jsx("span",{className:"truncate",children:t})]})}function gut({installation:e,isRemoving:t,isConfirmingUninstall:n,disabled:s,onReinstall:r,onUninstallClick:i}){const o=Iue(e),l=UD(e),c=o?ha:Ad,u=e.installedAt?new Date(e.installedAt).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):null;return a.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border p-3",children:[a.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[a.jsx(c,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":!0}),a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"truncate text-sm font-medium",children:l}),e.scope==="override"&&a.jsx("span",{className:"shrink-0 rounded-full bg-amber-100 px-1.5 py-0.5 text-[9px] font-medium text-amber-700 dark:bg-amber-900 dark:text-amber-300",children:"Overrides global"})]}),a.jsxs("div",{className:"text-muted-foreground text-xs",children:["v",e.version,u&&` · ${u}`]})]})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[a.jsxs(ge,{size:"sm",variant:"ghost",disabled:s,onClick:r,"aria-label":`Reinstall for ${l}`,children:[a.jsx(ma,{className:"mr-1 size-3","aria-hidden":!0}),"Reinstall"]}),a.jsxs(ge,{size:"sm",variant:n?"destructive":"ghost",disabled:s,onClick:i,"aria-label":n?`Confirm uninstall for ${l}`:`Uninstall for ${l}`,className:n?"":"text-destructive hover:text-destructive",children:[a.jsx(wo,{className:"mr-1 size-3","aria-hidden":!0}),t?"Removing…":n?"Confirm":"Uninstall"]})]})]})}function xut({installations:e,uninstallPendingFor:t,anyMutationPending:n,onReinstall:s,onUninstall:r}){var d,f;const[i,o]=x.useState(null);function l(m){i===m.installPath?(o(null),r(m)):(o(m.installPath),setTimeout(()=>{o(g=>g===m.installPath?null:g)},mut))}const c=hut((d=e.find(m=>m.provides))==null?void 0:d.provides),u=(f=e.find(m=>m.installedFrom))==null?void 0:f.installedFrom;return a.jsxs("section",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-emerald-600 dark:text-emerald-400",children:[a.jsx(Lt,{className:"size-4 shrink-0","aria-hidden":!0}),e.length===1?"Installed":`Installed in ${e.length} locations`]}),a.jsx("div",{className:"space-y-2",role:"list","aria-label":"Installations",children:e.map(m=>a.jsx("div",{role:"listitem",children:a.jsx(gut,{installation:m,isRemoving:t===m.installPath,isConfirmingUninstall:i===m.installPath,disabled:n,onReinstall:()=>s(m),onUninstallClick:()=>l(m)})},m.installPath))}),a.jsxs("dl",{className:"text-muted-foreground space-y-1.5 text-xs",children:[u&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx($c,{className:"size-3 shrink-0","aria-hidden":!0}),a.jsxs("span",{children:["from ",u]})]}),c&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(X5,{className:"size-3 shrink-0","aria-hidden":!0}),a.jsxs("span",{children:["Provides ",c]})]})]})]})}function yut(){var P;const{selectedPackageName:e,closeDetail:t}=E0(),n=Kp($=>$.openInstallConfirm),{data:s}=jv(),r=e?(s??[]).find($=>$.name===e)??null:null;x.useEffect(()=>{e&&s&&!s.some($=>$.name===e)&&t()},[e,s,t]);const i=r!==null,o=(r==null?void 0:r.name)??null,{data:l,isLoading:c}=Flt(o,{enabled:i}),{data:u,isLoading:d}=s_(),f=r!==null?(u??[]).filter($=>$.name===r.name):[],m=f.length>0,{data:g}=zlt(o,{enabled:m}),{data:y,isLoading:b}=xue(o,{enabled:i&&!m&&!d}),S=Due(),C=c||b||i&&d,T=(y==null?void 0:y.preview)??(l==null?void 0:l.preview),E=fut((l==null?void 0:l.manifest.author)??(r==null?void 0:r.author)),j=l==null?void 0:l.manifest.version,_=l==null?void 0:l.manifest.license,N=r==null?void 0:r.homepage,R=r==null?void 0:r.marketplace;function O($){r&&n(r,$.agentPath?{agentPath:$.agentPath,agentName:UD($)}:void 0)}function M($){r&&S.mutate({name:r.name,options:$.agentPath?{projectPath:$.agentPath}:void 0,where:$.agentPath?UD($):void 0})}const L=S.isPending&&S.variables?((P=f.find($=>{var q,K;return($.agentPath??void 0)===((K=(q=S.variables)==null?void 0:q.options)==null?void 0:K.projectPath)}))==null?void 0:P.installPath)??null:null;return a.jsx(Al,{open:r!==null,onOpenChange:$=>!$&&t(),children:a.jsx(Rl,{side:"right",className:"flex w-full flex-col overflow-hidden sm:max-w-xl",children:r&&a.jsxs(a.Fragment,{children:[a.jsxs(Ml,{className:"shrink-0 space-y-4 border-b pb-6",children:[a.jsxs("div",{className:"flex items-start gap-4 pr-8",children:[a.jsx("div",{className:"bg-muted flex size-14 shrink-0 items-center justify-center rounded-xl text-3xl",children:r.icon??"📦"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsx(Dl,{className:"text-lg",children:r.name}),a.jsx(IP,{type:r.type??"plugin",className:"shrink-0"})]}),r.description&&a.jsx(Hd,{className:"mt-1.5 line-clamp-3 text-sm",children:r.description})]})]}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[j&&a.jsxs(zt,{variant:"outline",className:"font-mono text-[10px]",children:["v",j]}),E&&a.jsx(sR,{icon:Md,children:E}),R&&a.jsx(sR,{icon:ha,children:R}),_&&a.jsx(sR,{icon:T3e,children:_})]}),N&&a.jsxs("a",{href:N,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1.5 text-xs transition-colors",children:[a.jsx(fa,{className:"size-3","aria-hidden":!0}),a.jsx("span",{className:"truncate",children:N})]})]}),a.jsx("div",{className:"flex-1 space-y-6 overflow-y-auto px-4 py-6",children:C?a.jsx(put,{}):m?a.jsx(xut,{installations:g??f,uninstallPendingFor:L,anyMutationPending:S.isPending,onReinstall:O,onUninstall:M}):T?a.jsxs("section",{children:[a.jsx("h3",{className:"mb-3 text-sm font-semibold",children:"Permissions & Effects"}),a.jsx(Oue,{preview:T})]}):a.jsx("p",{className:"text-muted-foreground text-sm",children:"No special permissions required."})}),a.jsxs(HT,{className:"flex-row gap-2 border-t pt-4",children:[a.jsx(ge,{variant:"ghost",onClick:t,className:"flex-1",children:"Close"}),m?a.jsx(ge,{variant:"outline",disabled:S.isPending,onClick:()=>n(r),className:"flex-1",children:"Install…"}):a.jsx(ge,{onClick:()=>n(r),className:"flex-1",children:"Install"})]})]})})})}function tq(e){return e instanceof Error?`Install failed: ${e.message}`:"Install failed: unknown error"}function vut(){const e=$lt(),{mutate:t,mutateAsync:n}=e,s=x.useCallback(i=>{const o=Ye.loading(`Installing ${i.name}…`);t(i,{onSuccess:()=>{Ye.success(`Installed ${i.name}`,{id:o})},onError:l=>{Ye.error(tq(l),{id:o})}})},[t]),r=x.useCallback(async i=>{const o=Ye.loading(`Installing ${i.name}…`);try{const l=await n(i);return Ye.success(`Installed ${i.name}`,{id:o}),l}catch(l){throw Ye.error(tq(l),{id:o}),l}},[n]);return{...e,mutate:s,mutateAsync:r}}function but(e,t){return t==="global"?e===void 0||e==="global":e==="agent-local"||e==="override"}function Sut(e){return e.isPending?e.isReinstall?"Reinstalling…":"Installing…":e.hasBlockingConflicts?"Cannot install — conflicts detected":e.isReinstall?"Reinstall":"Install"}function wut(){const e=Kp(N=>N.installConfirmPackage),t=Kp(N=>N.installContext),n=Kp(N=>N.closeInstallConfirm),s=vut(),{data:r}=Kb(),i=(r==null?void 0:r.agents)??[],[o,l]=x.useState(t?"agent-local":"global"),[c,u]=x.useState(void 0);x.useEffect(()=>{if(t){l("agent-local");const N=i.find(R=>R.projectPath===t.agentPath);u(N==null?void 0:N.id)}else l("global"),u(void 0)},[t,i]);const d=i.find(N=>N.id===c),f=o==="agent-local"?d==null?void 0:d.projectPath:void 0,m=o==="agent-local"&&!c,{data:g,isLoading:y}=xue((e==null?void 0:e.name)??null,{enabled:e!==null&&!m,...f?{projectPath:f}:{}}),b=m?null:(g==null?void 0:g.preview)??null,S=b!==null&&b.conflicts.some(N=>N.level==="error"),{data:w}=s_(f),C=!m&&(w??[]).some(N=>N.name===(e==null?void 0:e.name)&&but(N.scope,o)),T=s.isPending||y||S||e===null||m,E=Sut({isPending:s.isPending,isReinstall:C,hasBlockingConflicts:S});async function j(){if(e)try{const N=f?{projectPath:f}:void 0;await s.mutateAsync({name:e.name,options:N}),n()}catch{}}function _(N){N||n()}return a.jsx(fi,{open:e!==null,onOpenChange:_,children:a.jsx(hi,{className:"max-h-[85vh] !min-h-0 sm:max-w-2xl",children:e&&a.jsxs(a.Fragment,{children:[a.jsxs(va,{className:"shrink-0",children:[a.jsxs(Li,{children:[C?"Reinstall":"Install"," ",e.name,"?"]}),a.jsx(Ga,{children:C?"Reinstalling replaces the existing installation at this scope. Review what this package will do below.":"Review what this package will do before installing. This action cannot be undone without running an uninstall."})]}),a.jsxs("div",{className:"shrink-0 space-y-2 px-4 sm:px-6",children:[a.jsx("div",{className:"text-muted-foreground text-[10px] font-medium tracking-wider uppercase",children:"Install for"}),a.jsxs(JI,{value:o,onValueChange:N=>{l(N),N==="global"&&u(void 0)},className:"gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(bv,{value:"global",id:"scope-global"}),a.jsx(Rt,{htmlFor:"scope-global",className:"text-sm font-normal",children:"All agents (global)"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(bv,{value:"agent-local",id:"scope-agent"}),a.jsx(Rt,{htmlFor:"scope-agent",className:"text-sm font-normal",children:"Specific agent"})]})]}),o==="agent-local"&&a.jsx("div",{className:"pl-6",children:a.jsx(wce,{agents:i,value:c,onValueChange:u})})]}),a.jsxs(Ab,{className:"mt-4",children:[m&&a.jsx("p",{className:"text-muted-foreground text-sm",children:"Select an agent to preview what this install will do."}),y&&a.jsx("p",{className:"text-muted-foreground text-sm",children:"Loading preview…"}),b&&a.jsx(Oue,{preview:b})]}),a.jsxs(jb,{className:"shrink-0",children:[a.jsx(ge,{variant:"ghost",onClick:n,disabled:s.isPending,children:"Cancel"}),a.jsx(ge,{onClick:j,disabled:T,children:E})]})]})})})}function nq(e,t){const n=t.applied[0];return n?`Updated ${e} to v${n.version}`:`${e} is already up to date`}function sq(e){return e instanceof Error?`Update failed: ${e.message}`:"Update failed: unknown error"}function kut(){const e=Ult(),{mutate:t,mutateAsync:n}=e,s=x.useCallback(i=>{const o=Ye.loading(`Updating ${i.name}…`);t(i,{onSuccess:l=>{Ye.success(nq(i.name,l),{id:o})},onError:l=>{Ye.error(sq(l),{id:o})}})},[t]),r=x.useCallback(async i=>{const o=Ye.loading(`Updating ${i.name}…`);try{const l=await n(i);return Ye.success(nq(i.name,l),{id:o}),l}catch(l){throw Ye.error(sq(l),{id:o}),l}},[n]);return{...e,mutate:s,mutateAsync:r}}function Pue(e){var t;return e.scope!=="agent-local"&&e.scope!=="override"?null:e.agentName??((t=e.agentPath)==null?void 0:t.split("/").filter(Boolean).pop())??"agent"}function Cut({installation:e,isConfirmingUninstall:t,isUninstalling:n,isUpdating:s,onUpdateClick:r,onUninstallClick:i}){const{name:o,version:l,type:c,scope:u,installedFrom:d,installedAt:f}=e,m=f?new Date(f).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):null,g=Pue(e);return a.jsxs("div",{className:"bg-card flex items-center justify-between gap-4 rounded-xl border p-6",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"text-sm font-semibold",children:o}),a.jsx(IP,{type:c}),a.jsxs(zt,{variant:"outline",className:"font-mono text-xs",children:["v",l]}),u==="agent-local"&&a.jsx("span",{className:"rounded-full bg-blue-100 px-1.5 py-0.5 text-[9px] font-medium text-blue-700 dark:bg-blue-900 dark:text-blue-300",children:"Local"}),u==="override"&&a.jsx("span",{className:"rounded-full bg-amber-100 px-1.5 py-0.5 text-[9px] font-medium text-amber-700 dark:bg-amber-900 dark:text-amber-300",children:"Overrides global"})]}),a.jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-0.5 text-xs",children:[g&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Ad,{className:"size-3","aria-hidden":!0}),g]}),d&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx($c,{className:"size-3","aria-hidden":!0}),d]}),m&&a.jsxs("span",{children:["Installed ",m]})]})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[a.jsxs(ge,{size:"sm",variant:"outline",onClick:r,disabled:s,"aria-label":`Check for updates to ${o}${g?` on ${g}`:""}`,children:[a.jsx(ma,{className:`mr-1 size-3 ${s?"animate-spin":""}`,"aria-hidden":!0}),s?"Updating…":"Update"]}),a.jsxs(ge,{size:"sm",variant:t?"destructive":"ghost",onClick:i,disabled:n,"aria-label":t?`Confirm uninstall of ${o}${g?` from ${g}`:""}`:`Uninstall ${o}${g?` from ${g}`:""}`,className:t?"":"text-destructive hover:text-destructive",children:[a.jsx(wo,{className:"mr-1 size-3","aria-hidden":!0}),n?"Removing…":t?"Confirm":"Uninstall"]})]})]})}const Eut=3e3;function Tut(){const{data:e,isLoading:t,error:n,refetch:s}=s_(),r=Due(),i=kut(),[o,l]=x.useState(null);if(t)return a.jsx(Aue,{count:3});if(n)return a.jsx(Mue,{error:n,onRetry:()=>void s()});if(!e||e.length===0)return a.jsx(Rue,{title:"No packages installed",description:"Browse the marketplace to discover and install your first package."});function c(f){i.mutate({name:f.name,options:{apply:!0,...f.agentPath&&{projectPath:f.agentPath}}})}function u(f){o===f.installPath?(r.mutate({name:f.name,options:{purge:!1,...f.agentPath&&{projectPath:f.agentPath}},where:Pue(f)??void 0}),l(null)):(l(f.installPath),setTimeout(()=>{l(m=>m===f.installPath?null:m)},Eut))}function d(f,m){var g;return(f==null?void 0:f.name)===m.name&&(((g=f==null?void 0:f.options)==null?void 0:g.projectPath)??void 0)===(m.agentPath??void 0)}return a.jsx("div",{className:"space-y-3",role:"list","aria-label":"Installed packages",children:e.map(f=>a.jsx("div",{role:"listitem",children:a.jsx(Cut,{installation:f,isConfirmingUninstall:o===f.installPath,isUninstalling:r.isPending&&d(r.variables,f),isUpdating:i.isPending&&d(i.variables,f),onUpdateClick:()=>c(f),onUninstallClick:()=>u(f)})},f.installPath))})}function _ut(){var r;const{data:e}=Wce(),t=Yce();if((r=e==null?void 0:e.telemetry)!=null&&r.userHasDecided)return null;const n=()=>{t.mutate({telemetry:{enabled:!1,userHasDecided:!0}})},s=()=>{t.mutate({telemetry:{enabled:!0,userHasDecided:!0}})};return a.jsxs("div",{role:"region","aria-label":"Marketplace telemetry consent",className:"border-border bg-muted/40 mb-6 flex flex-col gap-4 rounded-xl border p-5 sm:flex-row sm:items-start sm:justify-between",children:[a.jsxs("div",{className:"min-w-0 space-y-1",children:[a.jsx("h3",{className:"text-sm font-semibold",children:"Help improve the marketplace"}),a.jsxs("p",{className:"text-muted-foreground text-sm",children:["Send anonymous install events to dorkos.ai so we can rank packages and fix install failures. No PII. Random per-install ID. Off unless you opt in."," ",a.jsx("a",{href:"https://dorkos.ai/marketplace/privacy",target:"_blank",rel:"noopener noreferrer",className:"text-foreground underline underline-offset-2",children:"Privacy contract"}),"."]})]}),a.jsxs("div",{className:"flex flex-shrink-0 gap-2",children:[a.jsx(ge,{variant:"outline",size:"sm",onClick:n,disabled:t.isPending,children:"No thanks"}),a.jsx(ge,{size:"sm",onClick:s,disabled:t.isPending,children:"Send anonymous events"})]})]})}function Nut(){const{view:e,setView:t}=E0();return a.jsxs("div",{className:"mx-auto max-w-7xl space-y-8 px-4 py-8",children:[a.jsx(_ut,{}),a.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Marketplace"}),a.jsx("p",{className:"text-muted-foreground text-sm",children:e==="installed"?"Manage every package installed across your global and per-agent scopes.":"Browse and install agents, plugins, skill packs, and adapters from the DorkOS marketplace."})]}),a.jsx(CT,{value:e,onValueChange:n=>t(n),children:a.jsxs(Mb,{"aria-label":"Marketplace view",children:[a.jsx(_c,{value:"browse",children:"Browse"}),a.jsx(_c,{value:"installed",children:"Installed"})]})})]}),e==="installed"?a.jsx("section",{"aria-label":"Installed packages",children:a.jsx(Tut,{})}):a.jsxs(a.Fragment,{children:[a.jsx(Ylt,{}),a.jsx(nct,{}),a.jsx("section",{"aria-label":"All packages",children:a.jsx(out,{})})]}),a.jsx(yut,{}),a.jsx(wut,{})]})}function jut({name:e,source:t,enabled:n,addedAt:s,onRemove:r,isRemoving:i}){const o=new Date(s).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"});return a.jsxs("div",{className:"bg-card flex items-start justify-between rounded-xl border p-5",children:[a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(dh,{className:`mt-0.5 size-3 shrink-0 fill-current ${n?"text-emerald-500":"text-muted-foreground"}`,"aria-label":n?"Enabled":"Disabled"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"truncate text-sm font-semibold",children:e}),a.jsx("p",{className:"text-muted-foreground truncate text-xs",children:t}),a.jsxs("p",{className:"text-muted-foreground mt-1 text-xs",children:["Added ",o]})]})]}),a.jsxs(ge,{variant:"ghost",size:"sm",onClick:r,disabled:i,className:"text-destructive hover:text-destructive ml-4 shrink-0","aria-label":`Remove ${e}`,children:[a.jsx(wo,{className:"size-3.5"}),a.jsx("span",{className:"ml-1.5 hidden sm:inline",children:"Remove"})]})]})}function Aut({open:e,onOpenChange:t,isPending:n,onSubmit:s}){const[r,i]=x.useState(""),[o,l]=x.useState(""),c=()=>{s(r.trim(),o.trim())},u=f=>{f||(i(""),l("")),t(f)},d=o.trim().length>0&&r.trim().length>0;return a.jsx(qc,{open:e,onOpenChange:u,children:a.jsxs(Cl,{className:"sm:max-w-md",children:[a.jsxs(El,{children:[a.jsx(Tl,{children:"Add Marketplace Source"}),a.jsx(_l,{children:"Enter a git URL and friendly name for a registry that publishes marketplace packages."})]}),a.jsxs("div",{className:"space-y-4 py-2",children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:"source-url",children:"Git URL"}),a.jsx(sn,{id:"source-url",value:o,onChange:f=>l(f.target.value),placeholder:"https://github.com/org/marketplace",autoComplete:"off"})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Rt,{htmlFor:"source-name",children:"Name"}),a.jsx(sn,{id:"source-name",value:r,onChange:f=>i(f.target.value),placeholder:"e.g. my-registry",autoComplete:"off"})]})]}),a.jsxs(i0,{children:[a.jsx(ge,{variant:"ghost",onClick:()=>u(!1),disabled:n,children:"Cancel"}),a.jsx(ge,{onClick:c,disabled:!d||n,children:n?"Adding…":"Add Source"})]})]})})}function Rut(){const{data:e,isLoading:t}=Blt(),n=Vlt(),s=qlt(),[r,i]=x.useState(!1),o=(c,u)=>{n.mutate({name:c,source:u,enabled:!0},{onSuccess:()=>i(!1)})},l=!t&&(!e||e.length===0);return a.jsxs("div",{className:"mx-auto max-w-2xl space-y-6 px-4 py-8",children:[a.jsxs("div",{className:"flex items-start justify-between gap-4",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Marketplace Sources"}),a.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Git registries that publish marketplace packages."})]}),a.jsxs(ge,{onClick:()=>i(!0),size:"sm",children:[a.jsx(Cs,{className:"mr-1.5 size-4"}),"Add Source"]})]}),t&&a.jsx("div",{className:"space-y-3",children:[1,2].map(c=>a.jsx("div",{className:"bg-muted h-20 animate-pulse rounded-xl border"},c))}),l&&a.jsxs("div",{className:"rounded-xl border border-dashed p-10 text-center",children:[a.jsx("p",{className:"text-sm font-medium",children:"No sources configured"}),a.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"Add a git registry to browse and install marketplace packages."}),a.jsxs(ge,{className:"mt-4",size:"sm",onClick:()=>i(!0),children:[a.jsx(Cs,{className:"mr-1.5 size-4"}),"Add Source"]})]}),e&&e.length>0&&a.jsx("div",{className:"space-y-3",children:e.map(c=>a.jsx(jut,{name:c.name,source:c.source,enabled:c.enabled,addedAt:c.addedAt,onRemove:()=>s.mutate(c.name),isRemoving:s.isPending},c.name))}),a.jsx(Aut,{open:r,onOpenChange:i,isPending:n.isPending,onSubmit:o})]})}const Mut=se({view:Je(["browse","installed"]).optional(),type:Je(["all","agent","plugin","skill-pack","adapter"]).optional(),sort:Je(["featured","popular","recent","name"]).optional(),q:z().optional(),category:z().optional(),pkg:z().optional()});function Dut({onSelect:e,typeFilter:t="agent"}){const[n,s]=x.useState(""),[r,i]=x.useState(!1),{data:o,error:l}=jv({type:t}),c=x.useMemo(()=>o==null?void 0:o.filter(u=>u.type===t),[o,t]);return a.jsxs("div",{className:"space-y-3",children:[l?a.jsx("p",{className:"text-muted-foreground py-8 text-center text-xs",children:"Could not load marketplace agents. Check your network and marketplace sources in Settings."}):(c??[]).length===0?a.jsx("p",{className:"text-muted-foreground py-8 text-center text-xs",children:"No marketplace agents available. Add a marketplace source in Settings."}):a.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2","data-testid":"marketplace-template-grid",children:c.map(u=>a.jsx(PP,{pkg:u,variant:"compact",onClick:()=>e(u.source,u.name),"data-testid":`marketplace-template-${u.name}`},u.name))}),a.jsxs(ol,{open:r,onOpenChange:i,children:[a.jsx(ll,{asChild:!0,children:a.jsxs("button",{type:"button",className:"text-muted-foreground hover:text-foreground flex w-full items-center gap-1 text-sm transition-colors","data-testid":"advanced-toggle",children:[a.jsx(Hs,{className:Y("size-4 transition-transform",r&&"rotate-180")}),"Advanced"]})}),a.jsx(cl,{children:a.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[a.jsx(sn,{value:n,onChange:u=>s(u.target.value),placeholder:"github.com/org/repo","data-testid":"custom-url-input",className:"flex-1"}),a.jsx(ge,{size:"sm",disabled:!n,onClick:()=>{e(n),s("")},"data-testid":"custom-url-go",children:"Go"})]})})]})]})}function Out(){const{isOpen:e,initialMode:t,close:n}=ud(),s=Mlt(),r=Hn(),i=we(N=>N.setSidebarLevel),[o,l]=x.useState("choose"),[c,u]=x.useState("new"),[d,f]=x.useState(null),[m,g]=x.useState(null),[y,b]=x.useState(!1);e!==y&&(b(e),e&&(l(Olt(t)),u(t==="import"?"import":t==="template"?"template":"new")));const S=Dlt({step:o,creationMode:c,templateName:m});function w(){S.reset(),f(null),g(null),l("choose"),u("new")}const C=x.useCallback(N=>{u(N),l(N==="template"?"pick-template":N==="import"?"import":"configure")},[]),T=x.useCallback((N,R)=>{N&&(f(N),g(R??N.split("/").pop()??null),l("configure"))},[]);function E(){l(o==="configure"&&c==="template"?"pick-template":"choose")}function j(){!S.canSubmit||s.isPending||s.mutate({name:S.slug,displayName:S.displayName.trim()||void 0,...S.directoryOverride?{directory:S.directoryOverride}:{},...c==="template"&&d?{template:d}:{}},{onSuccess:N=>{GZ(),n(),w(),r({to:"/session",search:{dir:N._path,session:crypto.randomUUID()}}),i("session")},onError:N=>{Ye.error(N instanceof Error?N.message:"Failed to create agent")}})}function _(N){N||(n(),w())}return a.jsx(fi,{open:e,onOpenChange:_,children:a.jsxs(hi,{className:"flex max-h-[85vh] max-w-lg flex-col gap-0 p-0",children:[a.jsxs(va,{className:"shrink-0 border-b px-4 py-3",children:[a.jsx(Li,{children:"Create Agent"}),a.jsx(Ga,{children:$V[o]})]}),a.jsx("span",{className:"sr-only","aria-live":"polite","aria-atomic":"true",children:$V[o]}),a.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-4",children:a.jsx(Ue,{mode:"wait",children:a.jsxs(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[o==="choose"&&a.jsx(Plt,{onSelect:C}),o==="pick-template"&&a.jsx(Dut,{onSelect:T}),o==="configure"&&a.jsx(Llt,{form:S,creationMode:c,template:{source:d,name:m},onChangeTemplate:()=>l("pick-template"),onImportInstead:()=>{u("import"),l("import")}}),o==="import"&&a.jsx(mue,{})]},o)})}),a.jsx(ET,{open:S.directoryPickerOpen,onOpenChange:S.setDirectoryPickerOpen,initialPath:S.directoryOverride||S.defaultDirectory,onSelect:N=>{S.setDirectoryOverride(N),S.directoryOpen||S.setDirectoryOpen(!0)}}),o!=="choose"&&a.jsx(jb,{className:"shrink-0 border-t px-4 py-3",children:a.jsxs("div",{className:"flex w-full items-center justify-between",children:[a.jsxs(ge,{variant:"ghost",onClick:E,"data-testid":"back-button",children:[a.jsx(ov,{className:"mr-1 size-4"}),"Back"]}),o==="configure"&&a.jsx(ge,{onClick:j,disabled:!S.canSubmit||s.isPending,"data-testid":"create-button",children:s.isPending?"Creating...":"Create Agent"})]})})]})})}function Iut(){const e=we(s=>s.shortcutsPanelOpen),t=we(s=>s.setShortcutsPanelOpen),n=Uwe();return a.jsx(fi,{open:e,onOpenChange:t,children:a.jsxs(hi,{className:"sm:max-w-md",children:[a.jsx(va,{children:a.jsx(Li,{children:"Keyboard Shortcuts"})}),a.jsx(Ab,{className:"space-y-6",children:n.map(({group:s,label:r,shortcuts:i})=>a.jsxs("div",{children:[a.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-medium tracking-wider uppercase",children:r}),a.jsx("div",{className:"space-y-1",children:i.map(o=>a.jsxs("div",{className:"flex items-center justify-between py-1.5 text-sm",children:[a.jsx("span",{children:o.label}),a.jsx(Zr,{className:"inline-flex",children:lE(o)})]},o.id))})]},s))})]})})}function Put(){const e=we(t=>t.toggleShortcutsPanel);x.useEffect(()=>{const t=n=>{const s=n.target,r=s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable;n.key==="?"&&!r&&(n.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}const a_=x.createContext(null);a_.displayName="PanelGroupContext";const As={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},zP=10,ih=x.useLayoutEffect,rq=Th.useId,Lut=typeof rq=="function"?rq:()=>null;let Fut=0;function BP(e=null){const t=Lut(),n=x.useRef(e||t||null);return n.current===null&&(n.current=""+Fut++),e??n.current}function Lue({children:e,className:t="",collapsedSize:n,collapsible:s,defaultSize:r,forwardedRef:i,id:o,maxSize:l,minSize:c,onCollapse:u,onExpand:d,onResize:f,order:m,style:g,tagName:y="div",...b}){const S=x.useContext(a_);if(S===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:w,expandPanel:C,getPanelSize:T,getPanelStyle:E,groupId:j,isPanelCollapsed:_,reevaluatePanelConstraints:N,registerPanel:R,resizePanel:O,unregisterPanel:M}=S,L=BP(o),P=x.useRef({callbacks:{onCollapse:u,onExpand:d,onResize:f},constraints:{collapsedSize:n,collapsible:s,defaultSize:r,maxSize:l,minSize:c},id:L,idIsFromProps:o!==void 0,order:m});x.useRef({didLogMissingDefaultSizeWarning:!1}),ih(()=>{const{callbacks:q,constraints:K}=P.current,B={...K};P.current.id=L,P.current.idIsFromProps=o!==void 0,P.current.order=m,q.onCollapse=u,q.onExpand=d,q.onResize=f,K.collapsedSize=n,K.collapsible=s,K.defaultSize=r,K.maxSize=l,K.minSize=c,(B.collapsedSize!==K.collapsedSize||B.collapsible!==K.collapsible||B.maxSize!==K.maxSize||B.minSize!==K.minSize)&&N(P.current,B)}),ih(()=>{const q=P.current;return R(q),()=>{M(q)}},[m,L,R,M]),x.useImperativeHandle(i,()=>({collapse:()=>{w(P.current)},expand:q=>{C(P.current,q)},getId(){return L},getSize(){return T(P.current)},isCollapsed(){return _(P.current)},isExpanded(){return!_(P.current)},resize:q=>{O(P.current,q)}}),[w,C,T,_,L,O]);const $=E(P.current,r);return x.createElement(y,{...b,children:e,className:t,id:L,style:{...$,...g},[As.groupId]:j,[As.panel]:"",[As.panelCollapsible]:s||void 0,[As.panelId]:L,[As.panelSize]:parseFloat(""+$.flexGrow).toFixed(1)})}const o_=x.forwardRef((e,t)=>x.createElement(Lue,{...e,forwardedRef:t}));Lue.displayName="Panel";o_.displayName="forwardRef(Panel)";let VD=null,dk=-1,Lu=null;function zut(e,t,n){const s=(t&Hue)!==0,r=(t&Uue)!==0,i=(t&Vue)!==0,o=(t&que)!==0;if(t){if(s)return i?"se-resize":o?"ne-resize":"e-resize";if(r)return i?"sw-resize":o?"nw-resize":"w-resize";if(i)return"s-resize";if(o)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function But(){Lu!==null&&(document.head.removeChild(Lu),VD=null,Lu=null,dk=-1)}function rR(e,t,n){var s,r;const i=zut(e,t);if(VD!==i){if(VD=i,Lu===null&&(Lu=document.createElement("style"),document.head.appendChild(Lu)),dk>=0){var o;(o=Lu.sheet)===null||o===void 0||o.removeRule(dk)}dk=(s=(r=Lu.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${i} !important;}`))!==null&&s!==void 0?s:-1}}function Fue(e){return e.type==="keydown"}function zue(e){return e.type.startsWith("pointer")}function Bue(e){return e.type.startsWith("mouse")}function l_(e){if(zue(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Bue(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function $ut(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Hut(e,t,n){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Uut(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:oq(e),b:oq(t)};let s;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),s=e;Xt(s,"Stacking order can only be calculated for elements with a common ancestor");const r={a:aq(iq(n.a)),b:aq(iq(n.b))};if(r.a===r.b){const i=s.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let l=i.length;for(;l--;){const c=i[l];if(c===o.a)return 1;if(c===o.b)return-1}}return Math.sign(r.a-r.b)}const Vut=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function qut(e){var t;const n=getComputedStyle((t=$ue(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function Gut(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||qut(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||Vut.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function iq(e){let t=e.length;for(;t--;){const n=e[t];if(Xt(n,"Missing node"),Gut(n))return n}return null}function aq(e){return e&&Number(getComputedStyle(e).zIndex)||0}function oq(e){const t=[];for(;e;)t.push(e),e=$ue(e);return t}function $ue(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const Hue=1,Uue=2,Vue=4,que=8,Kut=$ut()==="coarse";let go=[],Wp=!1,Fu=new Map,c_=new Map;const Mv=new Set;function Wut(e,t,n,s,r){var i;const{ownerDocument:o}=t,l={direction:n,element:t,hitAreaMargins:s,setResizeHandlerState:r},c=(i=Fu.get(o))!==null&&i!==void 0?i:0;return Fu.set(o,c+1),Mv.add(l),LC(),function(){var d;c_.delete(e),Mv.delete(l);const f=(d=Fu.get(o))!==null&&d!==void 0?d:1;if(Fu.set(o,f-1),LC(),f===1&&Fu.delete(o),go.includes(l)){const m=go.indexOf(l);m>=0&&go.splice(m,1),u_(),r("up",!0,null)}}}function Yut(e){const{target:t}=e,{x:n,y:s}=l_(e);Wp=!0,$P({target:t,x:n,y:s}),LC(),go.length>0&&(FC("down",e),u_(),e.preventDefault(),Gue(t)||e.stopImmediatePropagation())}function iR(e){const{x:t,y:n}=l_(e);if(Wp&&e.type!=="pointerleave"&&e.buttons===0&&(Wp=!1,FC("up",e)),!Wp){const{target:s}=e;$P({target:s,x:t,y:n})}FC("move",e),u_(),go.length>0&&e.preventDefault()}function aR(e){const{target:t}=e,{x:n,y:s}=l_(e);c_.clear(),Wp=!1,go.length>0&&(e.preventDefault(),Gue(t)||e.stopImmediatePropagation()),FC("up",e),$P({target:t,x:n,y:s}),u_(),LC()}function Gue(e){let t=e;for(;t;){if(t.hasAttribute(As.resizeHandle))return!0;t=t.parentElement}return!1}function $P({target:e,x:t,y:n}){go.splice(0);let s=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(s=e),Mv.forEach(r=>{const{element:i,hitAreaMargins:o}=r,l=i.getBoundingClientRect(),{bottom:c,left:u,right:d,top:f}=l,m=Kut?o.coarse:o.fine;if(t>=u-m&&t<=d+m&&n>=f-m&&n<=c+m){if(s!==null&&document.contains(s)&&i!==s&&!i.contains(s)&&!s.contains(i)&&Uut(s,i)>0){let y=s,b=!1;for(;y&&!y.contains(i);){if(Hut(y.getBoundingClientRect(),l)){b=!0;break}y=y.parentElement}if(b)return}go.push(r)}})}function oR(e,t){c_.set(e,t)}function u_(){let e=!1,t=!1;go.forEach(s=>{const{direction:r}=s;r==="horizontal"?e=!0:t=!0});let n=0;c_.forEach(s=>{n|=s}),e&&t?rR("intersection",n):e?rR("horizontal",n):t?rR("vertical",n):But()}let lR;function LC(){var e;(e=lR)===null||e===void 0||e.abort(),lR=new AbortController;const t={capture:!0,signal:lR.signal};Mv.size&&(Wp?(go.length>0&&Fu.forEach((n,s)=>{const{body:r}=s;n>0&&(r.addEventListener("contextmenu",aR,t),r.addEventListener("pointerleave",iR,t),r.addEventListener("pointermove",iR,t))}),Fu.forEach((n,s)=>{const{body:r}=s;r.addEventListener("pointerup",aR,t),r.addEventListener("pointercancel",aR,t)})):Fu.forEach((n,s)=>{const{body:r}=s;n>0&&(r.addEventListener("pointerdown",Yut,t),r.addEventListener("pointermove",iR,t))}))}function FC(e,t){Mv.forEach(n=>{const{setResizeHandlerState:s}=n,r=go.includes(n);s(e,r,t)})}function Zut(){const[e,t]=x.useState(0);return x.useCallback(()=>t(n=>n+1),[])}function Xt(e,t){if(!e)throw console.error(t),Error(t)}function Ch(e,t,n=zP){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function vc(e,t,n=zP){return Ch(e,t,n)===0}function Xi(e,t,n){return Ch(e,t,n)===0}function Xut(e,t,n){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++){const r=e[s],i=t[s];if(!Xi(r,i,n))return!1}return!0}function Op({panelConstraints:e,panelIndex:t,size:n}){const s=e[t];Xt(s!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:r=0,collapsible:i,maxSize:o=100,minSize:l=0}=s;if(Ch(n,l)<0)if(i){const c=(r+l)/2;Ch(n,c)<0?n=r:n=l}else n=l;return n=Math.min(o,n),n=parseFloat(n.toFixed(zP)),n}function by({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:s,prevLayout:r,trigger:i}){if(Xi(e,0))return t;const o=[...t],[l,c]=s;Xt(l!=null,"Invalid first pivot index"),Xt(c!=null,"Invalid second pivot index");let u=0;if(i==="keyboard"){{const f=e<0?c:l,m=n[f];Xt(m,`Panel constraints not found for index ${f}`);const{collapsedSize:g=0,collapsible:y,minSize:b=0}=m;if(y){const S=t[f];if(Xt(S!=null,`Previous layout not found for panel index ${f}`),Xi(S,g)){const w=b-S;Ch(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}{const f=e<0?l:c,m=n[f];Xt(m,`No panel constraints found for index ${f}`);const{collapsedSize:g=0,collapsible:y,minSize:b=0}=m;if(y){const S=t[f];if(Xt(S!=null,`Previous layout not found for panel index ${f}`),Xi(S,b)){const w=S-g;Ch(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}}{const f=e<0?1:-1;let m=e<0?c:l,g=0;for(;;){const b=t[m];Xt(b!=null,`Previous layout not found for panel index ${m}`);const w=Op({panelConstraints:n,panelIndex:m,size:100})-b;if(g+=w,m+=f,m<0||m>=n.length)break}const y=Math.min(Math.abs(e),Math.abs(g));e=e<0?0-y:y}{let m=e<0?l:c;for(;m>=0&&m<n.length;){const g=Math.abs(e)-Math.abs(u),y=t[m];Xt(y!=null,`Previous layout not found for panel index ${m}`);const b=y-g,S=Op({panelConstraints:n,panelIndex:m,size:b});if(!Xi(y,S)&&(u+=y-S,o[m]=S,u.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?m--:m++}}if(Xut(r,o))return r;{const f=e<0?c:l,m=t[f];Xt(m!=null,`Previous layout not found for panel index ${f}`);const g=m+u,y=Op({panelConstraints:n,panelIndex:f,size:g});if(o[f]=y,!Xi(y,g)){let b=g-y,w=e<0?c:l;for(;w>=0&&w<n.length;){const C=o[w];Xt(C!=null,`Previous layout not found for panel index ${w}`);const T=C+b,E=Op({panelConstraints:n,panelIndex:w,size:T});if(Xi(C,E)||(b-=E-C,o[w]=E),Xi(b,0))break;e>0?w--:w++}}}const d=o.reduce((f,m)=>m+f,0);return Xi(d,100)?o:r}function Qut({layout:e,panelsArray:t,pivotIndices:n}){let s=0,r=100,i=0,o=0;const l=n[0];Xt(l!=null,"No pivot index found"),t.forEach((f,m)=>{const{constraints:g}=f,{maxSize:y=100,minSize:b=0}=g;m===l?(s=b,r=y):(i+=b,o+=y)});const c=Math.min(r,100-i),u=Math.max(s,100-o),d=e[l];return{valueMax:c,valueMin:u,valueNow:d}}function Dv(e,t=document){return Array.from(t.querySelectorAll(`[${As.resizeHandleId}][data-panel-group-id="${e}"]`))}function Kue(e,t,n=document){const r=Dv(e,n).findIndex(i=>i.getAttribute(As.resizeHandleId)===t);return r??null}function Wue(e,t,n){const s=Kue(e,t,n);return s!=null?[s,s+1]:[-1,-1]}function Jut(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function Yue(e,t=document){if(Jut(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function d_(e,t=document){const n=t.querySelector(`[${As.resizeHandleId}="${e}"]`);return n||null}function edt(e,t,n,s=document){var r,i,o,l;const c=d_(t,s),u=Dv(e,s),d=c?u.indexOf(c):-1,f=(r=(i=n[d])===null||i===void 0?void 0:i.id)!==null&&r!==void 0?r:null,m=(o=(l=n[d+1])===null||l===void 0?void 0:l.id)!==null&&o!==void 0?o:null;return[f,m]}function tdt({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:s,panelDataArray:r,panelGroupElement:i,setLayout:o}){x.useRef({didWarnAboutMissingResizeHandle:!1}),ih(()=>{if(!i)return;const l=Dv(n,i);for(let c=0;c<r.length-1;c++){const{valueMax:u,valueMin:d,valueNow:f}=Qut({layout:s,panelsArray:r,pivotIndices:[c,c+1]}),m=l[c];if(m!=null){const g=r[c];Xt(g,`No panel data found for index "${c}"`),m.setAttribute("aria-controls",g.id),m.setAttribute("aria-valuemax",""+Math.round(u)),m.setAttribute("aria-valuemin",""+Math.round(d)),m.setAttribute("aria-valuenow",f!=null?""+Math.round(f):"")}}return()=>{l.forEach((c,u)=>{c.removeAttribute("aria-controls"),c.removeAttribute("aria-valuemax"),c.removeAttribute("aria-valuemin"),c.removeAttribute("aria-valuenow")})}},[n,s,r,i]),x.useEffect(()=>{if(!i)return;const l=t.current;Xt(l,"Eager values not found");const{panelDataArray:c}=l,u=Yue(n,i);Xt(u!=null,`No group found for id "${n}"`);const d=Dv(n,i);Xt(d,`No resize handles found for group id "${n}"`);const f=d.map(m=>{const g=m.getAttribute(As.resizeHandleId);Xt(g,"Resize handle element has no handle id attribute");const[y,b]=edt(n,g,c,i);if(y==null||b==null)return()=>{};const S=w=>{if(!w.defaultPrevented)switch(w.key){case"Enter":{w.preventDefault();const C=c.findIndex(T=>T.id===y);if(C>=0){const T=c[C];Xt(T,`No panel data found for index ${C}`);const E=s[C],{collapsedSize:j=0,collapsible:_,minSize:N=0}=T.constraints;if(E!=null&&_){const R=by({delta:Xi(E,j)?N-j:j-E,initialLayout:s,panelConstraints:c.map(O=>O.constraints),pivotIndices:Wue(n,g,i),prevLayout:s,trigger:"keyboard"});s!==R&&o(R)}}break}}};return m.addEventListener("keydown",S),()=>{m.removeEventListener("keydown",S)}});return()=>{f.forEach(m=>m())}},[i,e,t,n,s,r,o])}function lq(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Zue(e,t){const n=e==="horizontal",{x:s,y:r}=l_(t);return n?s:r}function ndt(e,t,n,s,r){const i=n==="horizontal",o=d_(t,r);Xt(o,`No resize handle element found for id "${t}"`);const l=o.getAttribute(As.groupId);Xt(l,"Resize handle element has no group id attribute");let{initialCursorPosition:c}=s;const u=Zue(n,e),d=Yue(l,r);Xt(d,`No group element found for id "${l}"`);const f=d.getBoundingClientRect(),m=i?f.width:f.height;return(u-c)/m*100}function sdt(e,t,n,s,r,i){if(Fue(e)){const o=n==="horizontal";let l=0;e.shiftKey?l=100:r!=null?l=r:l=10;let c=0;switch(e.key){case"ArrowDown":c=o?0:l;break;case"ArrowLeft":c=o?-l:0;break;case"ArrowRight":c=o?l:0;break;case"ArrowUp":c=o?0:-l;break;case"End":c=100;break;case"Home":c=-100;break}return c}else return s==null?0:ndt(e,t,n,s,i)}function rdt({panelDataArray:e}){const t=Array(e.length),n=e.map(i=>i.constraints);let s=0,r=100;for(let i=0;i<e.length;i++){const o=n[i];Xt(o,`Panel constraints not found for index ${i}`);const{defaultSize:l}=o;l!=null&&(s++,t[i]=l,r-=l)}for(let i=0;i<e.length;i++){const o=n[i];Xt(o,`Panel constraints not found for index ${i}`);const{defaultSize:l}=o;if(l!=null)continue;const c=e.length-s,u=r/c;s++,t[i]=u,r-=u}return t}function up(e,t,n){t.forEach((s,r)=>{const i=e[r];Xt(i,`Panel data not found for index ${r}`);const{callbacks:o,constraints:l,id:c}=i,{collapsedSize:u=0,collapsible:d}=l,f=n[c];if(f==null||s!==f){n[c]=s;const{onCollapse:m,onExpand:g,onResize:y}=o;y&&y(s,f),d&&(m||g)&&(g&&(f==null||vc(f,u))&&!vc(s,u)&&g(),m&&(f==null||!vc(f,u))&&vc(s,u)&&m())}})}function gw(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function idt({defaultSize:e,dragState:t,layout:n,panelData:s,panelIndex:r,precision:i=3}){const o=n[r];let l;return o==null?l=e!=null?e.toFixed(i):"1":s.length===1?l="1":l=o.toFixed(i),{flexBasis:0,flexGrow:l,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function adt(e,t=10){let n=null;return(...r)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...r)},t)}}function cq(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function Xue(e){return`react-resizable-panels:${e}`}function Que(e){return e.map(t=>{const{constraints:n,id:s,idIsFromProps:r,order:i}=t;return r?s:i?`${i}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function Jue(e,t){try{const n=Xue(e),s=t.getItem(n);if(s){const r=JSON.parse(s);if(typeof r=="object"&&r!=null)return r}}catch{}return null}function odt(e,t,n){var s,r;const i=(s=Jue(e,n))!==null&&s!==void 0?s:{},o=Que(t);return(r=i[o])!==null&&r!==void 0?r:null}function ldt(e,t,n,s,r){var i;const o=Xue(e),l=Que(t),c=(i=Jue(e,r))!==null&&i!==void 0?i:{};c[l]={expandToSizes:Object.fromEntries(n.entries()),layout:s};try{r.setItem(o,JSON.stringify(c))}catch(u){console.error(u)}}function uq({layout:e,panelConstraints:t}){const n=[...e],s=n.reduce((i,o)=>i+o,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(i=>`${i}%`).join(", ")}`);if(!Xi(s,100)&&n.length>0)for(let i=0;i<t.length;i++){const o=n[i];Xt(o!=null,`No layout data found for index ${i}`);const l=100/s*o;n[i]=l}let r=0;for(let i=0;i<t.length;i++){const o=n[i];Xt(o!=null,`No layout data found for index ${i}`);const l=Op({panelConstraints:t,panelIndex:i,size:o});o!=l&&(r+=o-l,n[i]=l)}if(!Xi(r,0))for(let i=0;i<t.length;i++){const o=n[i];Xt(o!=null,`No layout data found for index ${i}`);const l=o+r,c=Op({panelConstraints:t,panelIndex:i,size:l});if(o!==c&&(r-=c-o,n[i]=c,Xi(r,0)))break}return n}const cdt=100,Sy={getItem:e=>(cq(Sy),Sy.getItem(e)),setItem:(e,t)=>{cq(Sy),Sy.setItem(e,t)}},dq={};function ede({autoSaveId:e=null,children:t,className:n="",direction:s,forwardedRef:r,id:i=null,onLayout:o=null,keyboardResizeBy:l=null,storage:c=Sy,style:u,tagName:d="div",...f}){const m=BP(i),g=x.useRef(null),[y,b]=x.useState(null),[S,w]=x.useState([]),C=Zut(),T=x.useRef({}),E=x.useRef(new Map),j=x.useRef(0),_=x.useRef({autoSaveId:e,direction:s,dragState:y,id:m,keyboardResizeBy:l,onLayout:o,storage:c}),N=x.useRef({layout:S,panelDataArray:[],panelDataArrayChanged:!1});x.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),x.useImperativeHandle(r,()=>({getId:()=>_.current.id,getLayout:()=>{const{layout:F}=N.current;return F},setLayout:F=>{const{onLayout:X}=_.current,{layout:J,panelDataArray:ae}=N.current,oe=uq({layout:F,panelConstraints:ae.map(de=>de.constraints)});lq(J,oe)||(w(oe),N.current.layout=oe,X&&X(oe),up(ae,oe,T.current))}}),[]),ih(()=>{_.current.autoSaveId=e,_.current.direction=s,_.current.dragState=y,_.current.id=m,_.current.onLayout=o,_.current.storage=c}),tdt({committedValuesRef:_,eagerValuesRef:N,groupId:m,layout:S,panelDataArray:N.current.panelDataArray,setLayout:w,panelGroupElement:g.current}),x.useEffect(()=>{const{panelDataArray:F}=N.current;if(e){if(S.length===0||S.length!==F.length)return;let X=dq[e];X==null&&(X=adt(ldt,cdt),dq[e]=X);const J=[...F],ae=new Map(E.current);X(e,J,ae,S,c)}},[e,S,c]),x.useEffect(()=>{});const R=x.useCallback(F=>{const{onLayout:X}=_.current,{layout:J,panelDataArray:ae}=N.current;if(F.constraints.collapsible){const oe=ae.map(Fe=>Fe.constraints),{collapsedSize:de=0,panelSize:me,pivotIndices:Re}=wf(ae,F,J);if(Xt(me!=null,`Panel size not found for panel "${F.id}"`),!vc(me,de)){E.current.set(F.id,me);const Le=kp(ae,F)===ae.length-1?me-de:de-me,Xe=by({delta:Le,initialLayout:J,panelConstraints:oe,pivotIndices:Re,prevLayout:J,trigger:"imperative-api"});gw(J,Xe)||(w(Xe),N.current.layout=Xe,X&&X(Xe),up(ae,Xe,T.current))}}},[]),O=x.useCallback((F,X)=>{const{onLayout:J}=_.current,{layout:ae,panelDataArray:oe}=N.current;if(F.constraints.collapsible){const de=oe.map(ze=>ze.constraints),{collapsedSize:me=0,panelSize:Re=0,minSize:Fe=0,pivotIndices:Le}=wf(oe,F,ae),Xe=X??Fe;if(vc(Re,me)){const ze=E.current.get(F.id),Mt=ze!=null&&ze>=Xe?ze:Xe,Pe=kp(oe,F)===oe.length-1?Re-Mt:Mt-Re,He=by({delta:Pe,initialLayout:ae,panelConstraints:de,pivotIndices:Le,prevLayout:ae,trigger:"imperative-api"});gw(ae,He)||(w(He),N.current.layout=He,J&&J(He),up(oe,He,T.current))}}},[]),M=x.useCallback(F=>{const{layout:X,panelDataArray:J}=N.current,{panelSize:ae}=wf(J,F,X);return Xt(ae!=null,`Panel size not found for panel "${F.id}"`),ae},[]),L=x.useCallback((F,X)=>{const{panelDataArray:J}=N.current,ae=kp(J,F);return idt({defaultSize:X,dragState:y,layout:S,panelData:J,panelIndex:ae})},[y,S]),P=x.useCallback(F=>{const{layout:X,panelDataArray:J}=N.current,{collapsedSize:ae=0,collapsible:oe,panelSize:de}=wf(J,F,X);return Xt(de!=null,`Panel size not found for panel "${F.id}"`),oe===!0&&vc(de,ae)},[]),$=x.useCallback(F=>{const{layout:X,panelDataArray:J}=N.current,{collapsedSize:ae=0,collapsible:oe,panelSize:de}=wf(J,F,X);return Xt(de!=null,`Panel size not found for panel "${F.id}"`),!oe||Ch(de,ae)>0},[]),q=x.useCallback(F=>{const{panelDataArray:X}=N.current;X.push(F),X.sort((J,ae)=>{const oe=J.order,de=ae.order;return oe==null&&de==null?0:oe==null?-1:de==null?1:oe-de}),N.current.panelDataArrayChanged=!0,C()},[C]);ih(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:F,onLayout:X,storage:J}=_.current,{layout:ae,panelDataArray:oe}=N.current;let de=null;if(F){const Re=odt(F,oe,J);Re&&(E.current=new Map(Object.entries(Re.expandToSizes)),de=Re.layout)}de==null&&(de=rdt({panelDataArray:oe}));const me=uq({layout:de,panelConstraints:oe.map(Re=>Re.constraints)});lq(ae,me)||(w(me),N.current.layout=me,X&&X(me),up(oe,me,T.current))}}),ih(()=>{const F=N.current;return()=>{F.layout=[]}},[]);const K=x.useCallback(F=>{let X=!1;const J=g.current;return J&&window.getComputedStyle(J,null).getPropertyValue("direction")==="rtl"&&(X=!0),function(oe){oe.preventDefault();const de=g.current;if(!de)return()=>null;const{direction:me,dragState:Re,id:Fe,keyboardResizeBy:Le,onLayout:Xe}=_.current,{layout:ze,panelDataArray:Mt}=N.current,{initialLayout:Ft}=Re??{},Pe=Wue(Fe,F,de);let He=sdt(oe,F,me,Re,Le,de);const gt=me==="horizontal";gt&&X&&(He=-He);const Ct=Mt.map(ts=>ts.constraints),cn=by({delta:He,initialLayout:Ft??ze,panelConstraints:Ct,pivotIndices:Pe,prevLayout:ze,trigger:Fue(oe)?"keyboard":"mouse-or-touch"}),Nt=!gw(ze,cn);(zue(oe)||Bue(oe))&&j.current!=He&&(j.current=He,!Nt&&He!==0?gt?oR(F,He<0?Hue:Uue):oR(F,He<0?Vue:que):oR(F,0)),Nt&&(w(cn),N.current.layout=cn,Xe&&Xe(cn),up(Mt,cn,T.current))}},[]),B=x.useCallback((F,X)=>{const{onLayout:J}=_.current,{layout:ae,panelDataArray:oe}=N.current,de=oe.map(ze=>ze.constraints),{panelSize:me,pivotIndices:Re}=wf(oe,F,ae);Xt(me!=null,`Panel size not found for panel "${F.id}"`);const Le=kp(oe,F)===oe.length-1?me-X:X-me,Xe=by({delta:Le,initialLayout:ae,panelConstraints:de,pivotIndices:Re,prevLayout:ae,trigger:"imperative-api"});gw(ae,Xe)||(w(Xe),N.current.layout=Xe,J&&J(Xe),up(oe,Xe,T.current))},[]),V=x.useCallback((F,X)=>{const{layout:J,panelDataArray:ae}=N.current,{collapsedSize:oe=0,collapsible:de}=X,{collapsedSize:me=0,collapsible:Re,maxSize:Fe=100,minSize:Le=0}=F.constraints,{panelSize:Xe}=wf(ae,F,J);Xe!=null&&(de&&Re&&vc(Xe,oe)?vc(oe,me)||B(F,me):Xe<Le?B(F,Le):Xe>Fe&&B(F,Fe))},[B]),Q=x.useCallback((F,X)=>{const{direction:J}=_.current,{layout:ae}=N.current;if(!g.current)return;const oe=d_(F,g.current);Xt(oe,`Drag handle element not found for id "${F}"`);const de=Zue(J,X);b({dragHandleId:F,dragHandleRect:oe.getBoundingClientRect(),initialCursorPosition:de,initialLayout:ae})},[]),re=x.useCallback(()=>{b(null)},[]),U=x.useCallback(F=>{const{panelDataArray:X}=N.current,J=kp(X,F);J>=0&&(X.splice(J,1),delete T.current[F.id],N.current.panelDataArrayChanged=!0,C())},[C]),G=x.useMemo(()=>({collapsePanel:R,direction:s,dragState:y,expandPanel:O,getPanelSize:M,getPanelStyle:L,groupId:m,isPanelCollapsed:P,isPanelExpanded:$,reevaluatePanelConstraints:V,registerPanel:q,registerResizeHandle:K,resizePanel:B,startDragging:Q,stopDragging:re,unregisterPanel:U,panelGroupElement:g.current}),[R,y,s,O,M,L,m,P,$,V,q,K,B,Q,re,U]),W={display:"flex",flexDirection:s==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return x.createElement(a_.Provider,{value:G},x.createElement(d,{...f,children:t,className:n,id:i,ref:g,style:{...W,...u},[As.group]:"",[As.groupDirection]:s,[As.groupId]:m}))}const tde=x.forwardRef((e,t)=>x.createElement(ede,{...e,forwardedRef:t}));ede.displayName="PanelGroup";tde.displayName="forwardRef(PanelGroup)";function kp(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function wf(e,t,n){const s=kp(e,t),i=s===e.length-1?[s-1,s]:[s,s+1],o=n[s];return{...t.constraints,panelSize:o,pivotIndices:i}}function udt({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:s}){x.useEffect(()=>{if(e||n==null||s==null)return;const r=d_(t,s);if(r==null)return;const i=o=>{if(!o.defaultPrevented)switch(o.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{o.preventDefault(),n(o);break}case"F6":{o.preventDefault();const l=r.getAttribute(As.groupId);Xt(l,`No group element found for id "${l}"`);const c=Dv(l,s),u=Kue(l,t,s);Xt(u!==null,`No resize element found for id "${t}"`);const d=o.shiftKey?u>0?u-1:c.length-1:u+1<c.length?u+1:0;c[d].focus();break}}};return r.addEventListener("keydown",i),()=>{r.removeEventListener("keydown",i)}},[s,e,t,n])}function HP({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:s,id:r,onBlur:i,onClick:o,onDragging:l,onFocus:c,onPointerDown:u,onPointerUp:d,style:f={},tabIndex:m=0,tagName:g="div",...y}){var b,S;const w=x.useRef(null),C=x.useRef({onClick:o,onDragging:l,onPointerDown:u,onPointerUp:d});x.useEffect(()=>{C.current.onClick=o,C.current.onDragging=l,C.current.onPointerDown=u,C.current.onPointerUp=d});const T=x.useContext(a_);if(T===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:E,groupId:j,registerResizeHandle:_,startDragging:N,stopDragging:R,panelGroupElement:O}=T,M=BP(r),[L,P]=x.useState("inactive"),[$,q]=x.useState(!1),[K,B]=x.useState(null),V=x.useRef({state:L});ih(()=>{V.current.state=L}),x.useEffect(()=>{if(n)B(null);else{const G=_(M);B(()=>G)}},[n,M,_]);const Q=(b=s==null?void 0:s.coarse)!==null&&b!==void 0?b:15,re=(S=s==null?void 0:s.fine)!==null&&S!==void 0?S:5;x.useEffect(()=>{if(n||K==null)return;const G=w.current;Xt(G,"Element ref not attached");let W=!1;return Wut(M,G,E,{coarse:Q,fine:re},(X,J,ae)=>{if(!J){P("inactive");return}switch(X){case"down":{P("drag"),W=!1,Xt(ae,'Expected event to be defined for "down" action'),N(M,ae);const{onDragging:oe,onPointerDown:de}=C.current;oe==null||oe(!0),de==null||de();break}case"move":{const{state:oe}=V.current;W=!0,oe!=="drag"&&P("hover"),Xt(ae,'Expected event to be defined for "move" action'),K(ae);break}case"up":{P("hover"),R();const{onClick:oe,onDragging:de,onPointerUp:me}=C.current;de==null||de(!1),me==null||me(),W||oe==null||oe();break}}})},[Q,E,n,re,_,M,K,N,R]),udt({disabled:n,handleId:M,resizeHandler:K,panelGroupElement:O});const U={touchAction:"none",userSelect:"none"};return x.createElement(g,{...y,children:e,className:t,id:r,onBlur:()=>{q(!1),i==null||i()},onFocus:()=>{q(!0),c==null||c()},ref:w,role:"separator",style:{...U,...f},tabIndex:m,[As.groupDirection]:E,[As.groupId]:j,[As.resizeHandle]:"",[As.resizeHandleActive]:L==="drag"?"pointer":$?"keyboard":void 0,[As.resizeHandleEnabled]:!n,[As.resizeHandleId]:M,[As.resizeHandleState]:L})}HP.displayName="PanelResizeHandle";class ddt extends x.Component{constructor(){super(...arguments);Ze(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n,s){console.error("[RightPanel] Tab component error:",n,s)}componentDidUpdate(n){n.tabId!==this.props.tabId&&this.state.hasError&&this.setState({hasError:!1})}render(){return this.state.hasError?a.jsx("div",{className:"flex h-full items-center justify-center p-4",children:a.jsx("p",{className:"text-muted-foreground text-sm",children:"Something went wrong in this panel."})}):this.props.children}}function fdt({contributions:e,actions:t}){const n=we(i=>i.setRightPanelOpen),s=we(i=>i.activeRightPanelTab),r=we(i=>i.setActiveRightPanelTab);return a.jsxs("div",{className:"flex w-full items-center justify-between border-b px-3 py-2","data-slot":"right-panel-header",children:[e.length>1?a.jsx("div",{className:"bg-accent/60 inline-flex gap-0.5 rounded-lg p-0.5",role:"tablist","aria-label":"Right panel tabs",children:e.map(i=>{const o=i.id===s,l=i.icon;return a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsxs("button",{type:"button",role:"tab","aria-selected":o,"aria-label":i.title,onClick:()=>r(i.id),className:Y("flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[10px] font-medium transition-colors",o?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[a.jsx(l,{className:"size-3.5"}),a.jsx("span",{children:i.title})]})}),a.jsx(yn,{side:"bottom",children:i.title})]},i.id)})}):a.jsx("div",{}),a.jsxs("div",{className:"flex items-center gap-1",children:[t,a.jsx(ge,{variant:"ghost",size:"icon","aria-label":"Close panel",className:"size-7 shrink-0",onClick:()=>n(!1),children:a.jsx(es,{className:"size-3.5"})})]})]})}const hdt="flex-grow 300ms ease-in-out",mdt="opacity 300ms ease-in-out";function pdt(){const e=we(E=>E.rightPanelOpen),t=we(E=>E.setRightPanelOpen),n=we(E=>E.activeRightPanelTab),s=we(E=>E.setActiveRightPanelTabView),r=Us(),i=x.useRef(null),[o,l]=x.useState(!1),[c,u]=x.useState(!1);x.useEffect(()=>{const E=requestAnimationFrame(()=>u(!0));return()=>cancelAnimationFrame(E)},[]);const d=Vv({select:E=>E.location.pathname}),f=je(),m=Od("right-panel"),g=x.useMemo(()=>m.filter(E=>!E.visibleWhen||E.visibleWhen({pathname:d,transport:f})),[m,d,f]);x.useEffect(()=>{g.length>0&&(g.some(j=>j.id===n)||s(g[0].id))},[g,n,s]);const y=e&&g.length>0;if(x.useEffect(()=>{const E=i.current;E&&(y&&E.isCollapsed()?E.expand():!y&&E.isExpanded()&&E.collapse())},[y]),g.length===0)return null;const b=g.find(E=>E.id===n),S=b==null?void 0:b.component,w=b==null?void 0:b.headerActions,C=a.jsxs(a.Fragment,{children:[a.jsx(fdt,{contributions:g,actions:w?a.jsx(x.Suspense,{fallback:null,children:a.jsx(w,{})}):void 0}),a.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:a.jsx(ddt,{tabId:n,children:a.jsx(x.Suspense,{fallback:null,children:S&&a.jsx(S,{})})})})]});if(r)return y?a.jsx(Al,{open:!0,onOpenChange:E=>!E&&t(!1),children:a.jsxs(Rl,{side:"right",showCloseButton:!1,className:"bg-sidebar text-sidebar-foreground flex w-full flex-col gap-0 p-0 sm:max-w-full",children:[a.jsxs(Ml,{className:"sr-only",children:[a.jsx(Dl,{children:"Panel"}),a.jsx(Hd,{children:"Right panel content."})]}),C]})}):null;const T=c&&!o;return a.jsxs(a.Fragment,{children:[a.jsx(HP,{className:"group relative",style:{width:0,overflow:"visible"},disabled:!y,onDragging:l,children:a.jsx("div",{className:"absolute inset-y-0 -left-1 z-10 flex w-2 items-center justify-center",style:{opacity:y?1:0,pointerEvents:y?"auto":"none",...T&&{transition:mdt}},children:a.jsx("div",{className:"group-hover:bg-ring/50 h-full w-px transition-colors duration-500"})})}),a.jsx(o_,{ref:i,id:"right-panel",order:2,defaultSize:y?35:0,minSize:20,collapsible:!0,collapsedSize:0,onCollapse:()=>t(!1),onExpand:()=>{e||t(!0)},style:T?{transition:hdt}:void 0,children:a.jsx("div",{className:"bg-sidebar text-sidebar-foreground flex h-full flex-col overflow-hidden border-l",children:C})})]})}function gdt(){const e=we(u=>u.rightPanelOpen),t=we(u=>u.toggleRightPanel),n=Vv({select:u=>u.location.pathname}),s=je();if(Od("right-panel").filter(u=>!u.visibleWhen||u.visibleWhen({pathname:n,transport:s})).length===0)return null;const o=e?XMe:dne,l=e?"Close right panel":"Open right panel",c=zg?"⌘.":"Ctrl+.";return a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx(te.button,{"aria-label":l,className:"text-muted-foreground hover:text-foreground relative flex h-7 w-7 items-center justify-center rounded-md transition-colors",onClick:t,whileHover:{scale:1.1},whileTap:{scale:.93},transition:{type:"spring",stiffness:600,damping:35},children:a.jsx(o,{className:"size-4"})})}),a.jsxs(yn,{children:[a.jsx("span",{className:"pr-2",children:"Toggle right panel"}),a.jsx(Zr,{className:"relative z-10",children:c})]})]})}function xdt(){const e=we(t=>t.loadRightPanelState);x.useEffect(()=>{e()},[e])}const fq=Symbol("right-panel-layout-key-pending");function ydt(){const[e]=Id(),{data:t,isPending:n}=$b(e),s=we(i=>i.loadRightPanelForAgent);let r;e?n?r=fq:r=(t==null?void 0:t.id)??e:r=null,x.useEffect(()=>{r!==fq&&s(r)},[r,s]),x.useEffect(()=>()=>s(null),[s])}function vdt(){const e=we(t=>t.toggleRightPanel);x.useEffect(()=>{const t=n=>{(n.metaKey||n.ctrlKey)&&n.key==="."&&(n.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}function bdt(){const e=we(n=>n.setRightPanelOpen),t=we(n=>n.setActiveRightPanelTab);x.useEffect(()=>{const n=s=>{if((s.metaKey||s.ctrlKey)&&s.shiftKey&&s.key==="A"){s.preventDefault();const{rightPanelOpen:r,activeRightPanelTab:i}=we.getState();r&&i==="agent-hub"?e(!1):(t("agent-hub"),e(!0))}};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[e,t])}function Sdt(){const e=Vv({select:s=>s.location.pathname}),t=we(s=>s.sidebarLevel),n=we(s=>s.setSidebarLevel);return x.useEffect(()=>{e!=="/session"&&t==="session"&&n("dashboard")},[e,t,n]),e==="/session"&&t==="session"?{key:"session",body:a.jsx(hat,{}),direction:1}:{key:"dashboard",body:a.jsx(Nat,{}),direction:-1}}function wdt({agentName:e}){const{pathname:t,searchStr:n}=Vv({select:s=>({pathname:s.location.pathname,searchStr:s.location.searchStr})});switch(t){case"/":return{key:"dashboard",content:a.jsx(EV,{}),borderStyle:void 0};case"/agents":{const s=new URLSearchParams(n).get("view"),i=["list","topology","denied","access"].includes(s)?s:"list";return{key:"agents",content:a.jsx(Oat,{viewMode:i}),borderStyle:void 0}}case"/tasks":return{key:"tasks",content:a.jsx(iot,{}),borderStyle:void 0};case"/activity":return{key:"activity",content:a.jsx(rot,{}),borderStyle:void 0};case"/marketplace":return{key:"marketplace",content:a.jsx(aot,{}),borderStyle:void 0};case"/marketplace/sources":return{key:"marketplace-sources",content:a.jsx(oot,{}),borderStyle:void 0};case"/session":return{key:"session",content:a.jsx(jat,{agentName:e}),borderStyle:void 0};default:return{key:"dashboard",content:a.jsx(EV,{}),borderStyle:void 0}}}function kdt(){const{sidebarOpen:e,setSidebarOpen:t}=we(),[n]=Vc();M5e();const[s]=Id(),r=we(_=>_.isStreaming),i=we(_=>_.activeForm),o=we(_=>_.isWaitingForUser),l=we(_=>_.tasksBadgeCount),{data:c}=$b(s),u=qT(c??null,s??"");m5e({cwd:s,isStreaming:r,color:c?u.color:void 0}),p5e({cwd:s,activeForm:i,isStreaming:r,isWaitingForUser:o,agentName:c?nn(c):void 0,agentEmoji:c?u.emoji:void 0,tasksBadgeCount:l}),Put(),vdt(),bdt(),xdt(),j5e(),gIe(),rJe(),oJe(),RQe();const d=we(_=>_.setOnboardingStep),{shouldShowOnboarding:f,isLoading:m,dismiss:g}=Wb(),[y,b]=x.useState(!1),[S,w]=x.useState(!1);x.useEffect(()=>{if(!m)return;const _=setTimeout(()=>w(!0),3e3);return()=>clearTimeout(_)},[m]);const C=f&&!y,T=x.useCallback(()=>b(!0),[]),E=Sdt(),j=wdt({agentName:c?nn(c):void 0});return m&&!S?a.jsx("div",{className:"bg-background h-dvh"}):a.jsx(em,{children:a.jsxs(u6e,{reducedMotion:"user",children:[a.jsx(yv,{id:"onboarding-to-chat",children:a.jsx(Ue,{mode:"wait",children:C?a.jsx(te.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 z-50",children:a.jsx(Ice,{onComplete:T})},"onboarding"):a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.2},className:"h-dvh",children:a.jsxs("div",{"data-testid":"app-shell",className:"bg-background text-foreground flex h-dvh flex-col",children:[a.jsx(MJe,{sessionId:n}),a.jsxs($Xe,{open:e,onOpenChange:t,className:"flex-1 overflow-hidden",style:{"--sidebar-width":"20rem"},children:[a.jsxs(HXe,{variant:"inset",children:[a.jsx(Ue,{mode:"wait",initial:!1,custom:E.direction,children:a.jsx(te.div,{custom:E.direction,initial:"enter",animate:"center",exit:"exit",variants:{enter:_=>({x:`${_*100}%`,opacity:0}),center:{x:0,opacity:1},exit:_=>({x:`${_*-100}%`,opacity:0})},transition:{duration:.2,ease:[.4,0,.2,1]},className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:E.body},E.key)}),a.jsxs(GXe,{className:"border-t p-3",children:[f&&a.jsx("div",{className:"mb-2",children:a.jsx(Xtt,{onStepClick:_=>d(_),onDismiss:g})}),a.jsx(yat,{})]}),a.jsx(VXe,{})]}),a.jsxs(qXe,{className:"overflow-hidden",children:[a.jsxs("header",{className:"relative flex h-9 shrink-0 items-center gap-2 border-b px-2 transition-[border-color] duration-300",style:j.borderStyle,children:[a.jsx(UXe,{className:"-ml-0.5"}),a.jsx(av,{orientation:"vertical",className:"mr-1 h-4"}),a.jsx(Ue,{mode:"wait",initial:!1,children:a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.1},className:"flex min-w-0 flex-1 items-center gap-2",children:j.content},j.key)}),a.jsx(gdt,{})]}),a.jsx("main",{className:"flex-1 overflow-hidden",children:a.jsxs(tde,{direction:"horizontal",autoSaveId:"app-shell-right-panel",children:[a.jsx(o_,{id:"main-content",order:1,minSize:30,defaultSize:100,children:a.jsx(SO,{})}),a.jsx(pdt,{})]})})]})]})]})},"main-app")})}),a.jsx(tnt,{}),a.jsx(wlt,{}),a.jsx(Out,{}),a.jsx(Iut,{}),a.jsx(m9e,{})]})})}const Cdt=1800*1e3,Edt=1440*60*1e3,Tdt=8;function _dt(){const{sessions:e}=bl(),{data:t}=k0({status:"failed"}),{data:n}=w0(),{data:s}=mP(),r=Hn(),i=Gh();return x.useMemo(()=>{const o=[],l=i-Edt,c=i-Cdt;if(e)for(const u of e){const d=new Date(u.updatedAt).getTime();if(d<c&&d>l){const f=Math.floor((i-d)/6e4),m=Cg(u.title);o.push({id:`stalled-${u.id}`,type:"stalled-session",icon:Pi,title:`Session "${m}" idle`,description:`Session idle for ${f} minutes`,timestamp:u.updatedAt,action:{label:"Open →",onClick:()=>r({to:"/session",search:{session:u.id,dir:u.cwd??""}})},severity:"warning"})}}if(t)for(const u of t)new Date(u.createdAt).getTime()>l&&o.push({id:`failed-${u.id}`,type:"failed-run",icon:Xg,title:"Tasks run failed",description:`Tasks run ${u.id.slice(0,8)} failed`,timestamp:u.createdAt,action:{label:"View →",onClick:()=>r({to:"/",search:{detail:"failed-run",itemId:u.id}})},severity:"error"});if(n)for(const u of n)u.count>0&&o.push({id:`dead-letter-${u.source}-${u.reason}`,type:"dead-letter",icon:one,title:`${u.count} undeliverable Relay message${u.count===1?"":"s"}`,description:`Dead letters: ${u.source} — ${u.reason}`,timestamp:u.lastSeen,action:{label:"View →",onClick:()=>r({to:"/",search:{detail:"dead-letter",itemId:`${u.source}::${u.reason}`}})},severity:"warning"});if(s&&s.unreachableCount>0){const u=s.unreachableCount;o.push({id:"offline-agents",type:"offline-agent",icon:ZE,title:`${u} agent${u>1?"s":""} offline`,description:`${u} mesh agent${u>1?"s":""} unreachable`,timestamp:new Date(i).toISOString(),action:{label:"View →",onClick:()=>r({to:"/",search:{detail:"offline-agent",itemId:"offline"}})},severity:"error"})}return o.sort((u,d)=>new Date(d.timestamp).getTime()-new Date(u.timestamp).getTime()),o.slice(0,Tdt)},[i,e,t,n,s,r])}function Ig(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<60)return`${n}m`;const s=Math.floor(n/60);return s<24?`${s}h`:`${Math.floor(s/24)}d`}const Ndt={initial:{opacity:0,y:8},animate:{opacity:1,y:0}};function jdt({item:e}){const t=e.icon,n=Ig(e.timestamp);return a.jsxs(te.div,{variants:Ndt,className:"hover:bg-accent/50 flex min-w-0 items-center gap-2.5 rounded-md px-2 py-1 transition-colors",children:[a.jsx("span",{className:Y("size-1.5 shrink-0 rounded-full",e.severity==="error"?"bg-red-500":"bg-amber-500")}),a.jsx(t,{className:Y("size-3.5 shrink-0",e.severity==="error"?"text-red-500/70":"text-amber-500/70")}),a.jsx("span",{className:"text-foreground/90 min-w-0 flex-1 truncate text-xs",children:e.description}),a.jsx("span",{className:"text-muted-foreground shrink-0 text-xs tabular-nums",children:n}),a.jsx(ge,{variant:"ghost",size:"sm",className:"h-6 shrink-0 px-2 text-xs",onClick:e.action.onClick,children:e.action.label})]})}const Adt={initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.25,ease:[0,0,.2,1]}},Rdt={animate:{transition:{staggerChildren:.04}}};function Mdt(){const e=_dt();return a.jsx(Ue,{initial:!1,children:e.length>0&&a.jsxs(te.section,{...Adt,className:"overflow-hidden",children:[a.jsx("h2",{className:"mb-3 text-xs font-medium tracking-widest text-amber-600 uppercase dark:text-amber-500",children:"Needs Attention"}),a.jsx("div",{className:"rounded-xl border border-amber-500/15 bg-amber-500/[0.03] p-2 dark:bg-amber-900/[0.07]",children:a.jsx(te.div,{variants:Rdt,initial:"initial",animate:"animate",children:e.slice(0,8).map(t=>a.jsx(jdt,{item:t},t.id))})})]},"attention")})}function Ddt({open:e,itemId:t,onClose:n}){const{data:s}=w0(),r=sce(),i=(t==null?void 0:t.indexOf("::"))??-1,o=i>=0?t.slice(0,i):void 0,l=i>=0?t.slice(i+2):void 0,c=s==null?void 0:s.find(d=>d.source===o&&d.reason===l),u=()=>{!o||!l||r.mutate({source:o,reason:l},{onSuccess:n})};return a.jsx(Al,{open:e,onOpenChange:d=>!d&&n(),children:a.jsxs(Rl,{side:"right",children:[a.jsxs(Ml,{children:[a.jsx(Dl,{children:"Dead Letters"}),a.jsx(Hd,{children:o??"Unknown source"})]}),a.jsx(No,{className:"flex-1 px-4",children:c?a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsxs("p",{className:"text-foreground text-sm",children:[c.count," undeliverable message",c.count===1?"":"s"]}),a.jsx(zt,{variant:"secondary",children:c.reason})]}),a.jsxs("div",{className:"space-y-1 text-sm",children:[a.jsxs("p",{className:"text-muted-foreground",children:["First seen: ",Ig(c.firstSeen)," ago"]}),a.jsxs("p",{className:"text-muted-foreground",children:["Last seen: ",Ig(c.lastSeen)," ago"]})]}),c.sample!=null&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-muted-foreground text-xs font-medium",children:"Sample payload"}),a.jsx("pre",{className:"bg-muted overflow-x-auto rounded-md p-3 font-mono text-xs",children:JSON.stringify(c.sample,null,2)})]})]}):a.jsx("p",{className:"text-muted-foreground py-8 text-center text-sm",children:"This item has been resolved."})}),a.jsxs(HT,{children:[c&&a.jsx(ge,{variant:"destructive",onClick:u,disabled:r.isPending,children:r.isPending?"Dismissing...":"Dismiss Group"}),a.jsx(ge,{variant:"outline",onClick:n,children:"Close"})]})]})})}function Odt(e){const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;if(n<60)return`${n}m ${s}s`;const r=Math.floor(n/60),i=n%60;return`${r}h ${i}m`}function Idt({open:e,itemId:t,onClose:n}){const{data:s,isLoading:r,isError:i}=UQe(e?t??null:null),o=ace(),l=Hn(),c=()=>{s!=null&&s.sessionId&&l({to:"/session",search:{session:s.sessionId}})},u=()=>{s&&o.mutate(s.id)};return a.jsx(Al,{open:e,onOpenChange:d=>!d&&n(),children:a.jsxs(Rl,{side:"right",children:[a.jsxs(Ml,{children:[a.jsx(Dl,{children:"Failed Run"}),a.jsx(Hd,{children:t?t.slice(0,8):"Unknown"})]}),a.jsxs(No,{className:"flex-1 px-4",children:[r&&a.jsxs("div",{className:"space-y-4",children:[a.jsx(Jt,{className:"h-6 w-24"}),a.jsx(Jt,{className:"h-4 w-48"}),a.jsx(Jt,{className:"h-20 w-full"})]}),i&&a.jsx("p",{className:"text-destructive py-8 text-center text-sm",children:"Failed to load run details."}),!r&&!i&&!s&&a.jsx("p",{className:"text-muted-foreground py-8 text-center text-sm",children:"This item has been resolved."}),s&&a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsx(zt,{variant:"destructive",children:"Failed"}),a.jsx(zt,{variant:"secondary",children:s.trigger==="scheduled"?"Scheduled":"Manual"})]}),a.jsxs("div",{className:"space-y-1 text-sm",children:[s.startedAt&&a.jsxs("p",{className:"text-muted-foreground",children:["Started: ",Ig(s.startedAt)," ago"]}),s.finishedAt&&a.jsxs("p",{className:"text-muted-foreground",children:["Finished: ",Ig(s.finishedAt)," ago"]}),s.durationMs!=null&&a.jsxs("p",{className:"text-muted-foreground",children:["Duration: ",Odt(s.durationMs)]})]}),s.error&&a.jsxs("div",{className:"bg-destructive/10 border-destructive/20 rounded-md border p-3",children:[a.jsx("p",{className:"text-destructive text-sm font-medium",children:"Error"}),a.jsx("p",{className:"text-destructive/80 mt-1 text-sm",children:s.error})]}),s.outputSummary&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-muted-foreground text-xs font-medium",children:"Output"}),a.jsx("pre",{className:"bg-muted max-h-48 overflow-auto rounded-md p-3 font-mono text-xs",children:s.outputSummary})]})]})]}),a.jsxs(HT,{children:[(s==null?void 0:s.sessionId)&&a.jsx(ge,{variant:"default",onClick:c,children:"View Session"}),(s==null?void 0:s.status)==="running"&&a.jsx(ge,{variant:"destructive",onClick:u,disabled:o.isPending,children:o.isPending?"Cancelling...":"Cancel"}),a.jsx(ge,{variant:"outline",onClick:n,children:"Close"})]})]})})}function Pdt({agent:e}){const t=qT(e,e.projectPath??"");return a.jsxs("div",{className:"flex items-center gap-3 py-2",children:[a.jsx("span",{className:"text-lg","aria-hidden":!0,children:t.emoji}),a.jsx("div",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:t.color}}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-foreground truncate text-sm font-medium",children:nn(e)}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(zt,{variant:"destructive",className:"text-xs",children:"Unreachable"}),e.runtime&&a.jsx(zt,{variant:"secondary",className:"text-xs",children:e.runtime})]})]}),e.lastSeenAt&&a.jsxs("span",{className:"text-muted-foreground shrink-0 text-xs",children:[Ig(e.lastSeenAt)," ago"]})]})}function Ldt({open:e,onClose:t}){const{data:n}=pP(),s=x.useMemo(()=>n?n.namespaces.flatMap(r=>r.agents).filter(r=>r.healthStatus==="unreachable"):[],[n]);return a.jsx(Al,{open:e,onOpenChange:r=>!r&&t(),children:a.jsxs(Rl,{side:"right",children:[a.jsxs(Ml,{children:[a.jsx(Dl,{children:"Offline Agents"}),a.jsxs(Hd,{children:[s.length," agent",s.length===1?"":"s"," unreachable"]})]}),a.jsx(No,{className:"flex-1 px-4",children:s.length>0?a.jsx("div",{className:"divide-y",children:s.map(r=>a.jsx(Pdt,{agent:r},r.id))}):a.jsxs("div",{className:"flex flex-col items-center gap-2 py-8",children:[a.jsx(Lt,{className:"size-6 text-green-500"}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"All agents are online"})]})}),a.jsx(HT,{children:a.jsx(ge,{variant:"outline",onClick:t,children:"Close"})})]})})}function Fdt(){const e=ml({strict:!1}),t=Hn(),n=Od("dashboard.sections"),s=x.useMemo(()=>n.filter(i=>!i.visibleWhen||i.visibleWhen()),[n]),r=x.useCallback(()=>{t({to:"/",search:{}})},[t]);return a.jsxs(a.Fragment,{children:[a.jsx(No,{className:"h-full",children:a.jsx("div",{className:"mx-auto max-w-4xl space-y-6 px-4 py-6 sm:space-y-8 sm:px-6 sm:py-8",children:s.map(i=>a.jsx(i.component,{},i.id))})}),a.jsx(Ddt,{open:e.detail==="dead-letter",itemId:e.itemId,onClose:r}),a.jsx(Idt,{open:e.detail==="failed-run",itemId:e.itemId,onClose:r}),a.jsx(Ldt,{open:e.detail==="offline-agent",onClose:r})]})}const nde=6e4,qD=60*nde,GD=24*qD;function zdt(e,t){const n=new Date(e).getTime()-t;return n<=0?null:n<qD?`${Math.floor(n/nde)}m`:n<GD?`${Math.floor(n/qD)}h`:`${Math.floor(n/GD)}d`}function Bdt(){const e=Ud(),{data:t}=WT(e),{data:n}=k0({status:"failed"},e),s=am(),{data:r}=Hb(s),{data:i}=w0(s),{data:o}=mP(),l=Gh(),c=l-GD,u=(()=>{if(!t)return null;const g=t.filter(y=>y.nextRun!=null).map(y=>new Date(y.nextRun).getTime()).filter(y=>y>l).sort((y,b)=>y-b);return g.length===0?null:zdt(new Date(g[0]).toISOString(),l)})(),d=n?n.filter(g=>new Date(g.createdAt).getTime()>c).length:0,f=r?r.filter(g=>g.status.state==="connected").map(g=>g.config.type):[],m=i?i.reduce((g,y)=>g+y.count,0):0;return{tasks:{enabled:e,scheduleCount:(t==null?void 0:t.length)??0,nextRunIn:u,failedRunCount:d},relay:{enabled:s,adapterCount:(r==null?void 0:r.length)??0,connectedNames:f,deadLetterCount:m},mesh:{totalAgents:(o==null?void 0:o.totalAgents)??0,offlineCount:(o==null?void 0:o.unreachableCount)??0}}}const $dt=1440*60*1e3,cR=7;function Hdt(){const{sessions:e}=bl(),t=Gh();return x.useMemo(()=>{const n=Array(cR).fill(0);if(!e.length)return n;const s=new Date(t),r=new Date(s.getFullYear(),s.getMonth(),s.getDate());for(const i of e){const o=new Date(i.createdAt),l=new Date(o.getFullYear(),o.getMonth(),o.getDate()),c=Math.floor((r.getTime()-l.getTime())/$dt);c>=0&&c<cR&&n[cR-1-c]++}return n},[t,e])}const Udt={warning:"text-amber-600 dark:text-amber-500",error:"text-red-600 dark:text-red-500"};function uR({title:e,primaryMetric:t,secondaryInfo:n,exception:s,disabled:r=!1,onClick:i}){return a.jsxs("button",{type:"button",className:"bg-card shadow-soft card-interactive flex h-full w-full cursor-pointer flex-col items-start rounded-xl border p-4 text-left",onClick:i,children:[a.jsx("p",{className:Y("text-sm font-medium",r?"text-muted-foreground/50":"text-foreground"),children:e}),r?a.jsx("p",{className:"text-muted-foreground/50 mt-1 text-xs",children:"Disabled"}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:t}),n&&a.jsx("p",{className:"text-muted-foreground mt-0.5 text-xs",children:n}),s&&s.count>0&&a.jsxs("p",{className:Y("mt-1 text-xs",Udt[s.severity]),children:[s.count," ",s.label]})]})]})}const hq=10,Vdt=4,mq=30,pq=1;function qdt({data:e,className:t}){const n=Math.max(...e,1);return a.jsx("svg",{viewBox:"0 0 100 30",className:Y("text-muted-foreground",t),"aria-hidden":"true",children:e.map((s,r)=>{const i=s/n*mq;return a.jsx("rect",{x:r*(hq+Vdt)+1,y:mq-Math.max(i,pq),width:hq,height:Math.max(i,pq),rx:2,fill:"currentColor",opacity:.6},r)})})}const Gdt={initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.3,ease:"easeOut"}},Kdt={animate:{transition:{staggerChildren:.04}}},xw={initial:{opacity:0,y:8},animate:{opacity:1,y:0}};function Wdt(){const e=Bdt(),t=Hdt(),n=Kh(),s=Wh(),r=Hn(),i=t.reduce((c,u)=>c+u,0),o=e.tasks.nextRunIn?`Next: ${e.tasks.nextRunIn}`:void 0,l=e.relay.connectedNames.length>0?e.relay.connectedNames.join(" · "):void 0;return a.jsxs(te.section,{...Gdt,children:[a.jsx("h2",{className:"text-muted-foreground mb-3 text-xs font-medium tracking-widest uppercase",children:"System Status"}),a.jsxs(te.div,{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",variants:Kdt,initial:"initial",animate:"animate",children:[a.jsx(te.div,{variants:xw,children:a.jsx(uR,{title:"Tasks",primaryMetric:`${e.tasks.scheduleCount} schedule${e.tasks.scheduleCount!==1?"s":""}`,secondaryInfo:o,exception:e.tasks.failedRunCount>0?{count:e.tasks.failedRunCount,label:"failed today",severity:"error"}:void 0,disabled:!e.tasks.enabled,onClick:()=>n.open()})}),a.jsx(te.div,{variants:xw,children:a.jsx(uR,{title:"Relay",primaryMetric:`${e.relay.adapterCount} adapter${e.relay.adapterCount!==1?"s":""}`,secondaryInfo:l,exception:e.relay.deadLetterCount>0?{count:e.relay.deadLetterCount,label:"dead letters",severity:"warning"}:void 0,disabled:!e.relay.enabled,onClick:()=>s.open()})}),a.jsx(te.div,{variants:xw,children:a.jsx(uR,{title:"Mesh",primaryMetric:`${e.mesh.totalAgents} agent${e.mesh.totalAgents!==1?"s":""}`,exception:e.mesh.offlineCount>0?{count:e.mesh.offlineCount,label:"offline",severity:"error"}:void 0,onClick:()=>r({to:"/agents",search:{view:"topology"}})})}),a.jsx(te.div,{variants:xw,children:a.jsxs("button",{type:"button",className:"bg-card shadow-soft card-interactive flex h-full w-full cursor-pointer flex-col items-start rounded-xl border p-4 text-left",onClick:()=>{},"aria-label":"Session activity this week",children:[a.jsx("p",{className:"text-foreground text-sm font-medium",children:"Activity"}),a.jsxs("p",{className:"text-muted-foreground mt-1 text-xs",children:[i," this week"]}),a.jsx(qdt,{data:t,className:"mt-2 h-8 w-full"})]})})]})]})}const Ydt=15,Zdt=["Today","Yesterday","This Week","Earlier"];function Xdt(e){const t=new Date,n=new Date(t);n.setHours(0,0,0,0);const s=new Date(n);s.setDate(s.getDate()-1);const r=new Date(n);r.setDate(r.getDate()-r.getDay());const i=new Map;for(const o of e){const l=new Date(o.occurredAt);let c;l>=n?c="Today":l>=s?c="Yesterday":l>=r?c="This Week":c="Earlier";const u=i.get(c)??[];u.push(o),i.set(c,u)}return Zdt.filter(o=>i.has(o)).map(o=>({label:o,items:i.get(o)}))}function Qdt(){const e=je(),{data:t,isLoading:n}=st({queryKey:["dashboard-activity"],queryFn:()=>e.listActivityEvents({limit:Ydt}),staleTime:3e4,refetchOnWindowFocus:!0});return{groups:x.useMemo(()=>Xdt((t==null?void 0:t.items)??[]),[t==null?void 0:t.items]),hasMore:(t==null?void 0:t.nextCursor)!=null,isLoading:n}}const Jdt={animate:{transition:{staggerChildren:.05}}},eft={initial:{opacity:0,y:8},animate:{opacity:1,y:0,transition:{duration:.2}}};function tft(){const e=Hn(),{groups:t,isLoading:n}=Qdt();return!n&&t.length===0?a.jsxs("section",{children:[a.jsx("h2",{className:"text-muted-foreground mb-3 text-xs font-medium tracking-widest uppercase",children:"Recent Activity"}),a.jsx("div",{className:"bg-card/50 flex items-center justify-center rounded-xl border border-dashed py-8",children:a.jsx("p",{className:"text-muted-foreground text-sm",children:"No activity yet. Your agent history will appear here."})})]}):a.jsxs("section",{children:[a.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[a.jsx("h2",{className:"text-muted-foreground text-xs font-medium tracking-widest uppercase",children:"Recent Activity"}),a.jsx(ge,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>e({to:"/activity"}),children:"View all →"})]}),a.jsx(te.div,{variants:Jdt,initial:"initial",animate:"animate",children:t.map((s,r)=>a.jsxs(te.div,{variants:eft,children:[a.jsx("h3",{className:"text-muted-foreground/70 mb-1.5 text-[11px] font-medium",style:r>0?{marginTop:"1rem"}:void 0,children:s.label}),a.jsx(f0,{children:a.jsx(h0,{children:s.items.map(i=>a.jsx(sue,{item:i},i.id))})})]},s.label))})]})}function nft(){return a.jsx(_P,{placement:"dashboard-main",maxUnits:4})}const sft=[{id:"needs-attention",component:Mdt,priority:1},{id:"promo",component:nft,priority:2},{id:"system-status",component:Wdt,priority:3},{id:"recent-activity",component:tft,priority:4}];function rft(e,t,n){const s=x.useCallback(y=>{var C;if(!e||!t.current)return;const b=qn.getState(),S=(C=n.current)==null?void 0:C.get(e);if(S!==void 0&&b.getSession(e).mountGeneration!==S)return;const w=typeof y=="function"?y(b.getSession(e).messages):y;b.updateSession(e,{messages:w})},[e,t,n]),r=x.useCallback(y=>{e&&qn.getState().updateSession(e,{input:y})},[e]),i=x.useCallback(y=>{e&&qn.getState().updateSession(e,{status:y})},[e]),o=x.useCallback(y=>{e&&qn.getState().updateSession(e,{error:y})},[e]),l=x.useCallback(y=>{e&&qn.getState().updateSession(e,{sessionBusy:y})},[e]),c=x.useCallback(y=>{e&&qn.getState().updateSession(e,{sessionStatus:y})},[e]),u=x.useCallback(y=>{e&&qn.getState().updateSession(e,{estimatedTokens:y})},[e]),d=x.useCallback(y=>{e&&qn.getState().updateSession(e,{streamStartTime:y})},[e]),f=x.useCallback(y=>{e&&qn.getState().updateSession(e,{isTextStreaming:y})},[e]),m=x.useCallback(y=>{e&&qn.getState().updateSession(e,{systemStatus:y})},[e]),g=x.useCallback(y=>{e&&qn.getState().updateSession(e,{promptSuggestions:y})},[e]);return{setMessages:s,setInput:r,setStatus:i,setError:o,setSessionBusy:l,setSessionStatus:c,setEstimatedTokens:u,setStreamStartTime:d,setIsTextStreaming:f,setSystemStatus:m,setPromptSuggestions:g}}function sde(e){const t=[],n=[];for(const s of e)s.type==="text"?t.push(s.text):s.type==="tool_call"&&n.push({toolCallId:s.toolCallId,toolName:s.toolName,input:s.input||"",result:s.result,progressOutput:s.progressOutput,status:s.status,interactiveType:s.interactiveType,questions:s.questions,answers:s.answers,timeoutMs:s.timeoutMs,hooks:s.hooks,startedAt:s.startedAt,completedAt:s.completedAt});return{content:t.join(`
|
|
@@ -1265,13 +1265,13 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1265
1265
|
* Copyright (c) StackBlitz. All rights reserved.
|
|
1266
1266
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
1267
1267
|
*--------------------------------------------------------------------------------------------*/const Tht={damping:.7,stiffness:.05,mass:1.25},_ht=70,Nht=1e3/60,jht=350;let f_=!1;var sK;(sK=globalThis.document)==null||sK.addEventListener("mousedown",()=>{f_=!0});var rK;(rK=globalThis.document)==null||rK.addEventListener("mouseup",()=>{f_=!1});var iK;(iK=globalThis.document)==null||iK.addEventListener("click",()=>{f_=!1});const Aht=(e={})=>{const[t,n]=x.useState(!1),[s,r]=x.useState(e.initial!==!1),[i,o]=x.useState(!1),l=x.useRef(null);l.current=e;const c=x.useCallback(()=>{var E;if(!f_)return!1;const C=window.getSelection();if(!C||!C.rangeCount)return!1;const T=C.getRangeAt(0);return T.commonAncestorContainer.contains(S.current)||((E=S.current)==null?void 0:E.contains(T.commonAncestorContainer))},[]),u=x.useCallback(C=>{f.isAtBottom=C,r(C)},[]),d=x.useCallback(C=>{f.escapedFromLock=C,n(C)},[]),f=x.useMemo(()=>{let C;return{escapedFromLock:t,isAtBottom:s,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){var T;return((T=S.current)==null?void 0:T.scrollTop)??0},set scrollTop(T){if(S.current){const{scrollBehavior:E}=getComputedStyle(S.current);E!=="auto"&&(S.current.style.scrollBehavior="auto"),S.current.scrollTop=T,f.ignoreScrollToTop=S.current.scrollTop,E!=="auto"&&(S.current.style.scrollBehavior=E)}},get targetScrollTop(){return!S.current||!w.current?0:S.current.scrollHeight-1-S.current.clientHeight},get calculatedTargetScrollTop(){if(!S.current||!w.current)return 0;const{targetScrollTop:T}=this;if(!e.targetScrollTop)return T;if((C==null?void 0:C.targetScrollTop)===T)return C.calculatedScrollTop;const E=Math.max(Math.min(e.targetScrollTop(T,{scrollElement:S.current,contentElement:w.current}),T),0);return C={targetScrollTop:T,calculatedScrollTop:E},requestAnimationFrame(()=>{C=void 0}),E},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=_ht}}},[]),m=x.useCallback((C={})=>{var O;typeof C=="string"&&(C={animation:C}),C.preserveScrollPosition||u(!0);const T=Date.now()+(Number(C.wait)||0),E=mR(l.current,C.animation),{ignoreEscapes:j=!1}=C;let _,N=f.calculatedTargetScrollTop;C.duration instanceof Promise?C.duration.finally(()=>{_=Date.now()}):_=T+(C.duration??0);const R=async()=>{const M=new Promise(requestAnimationFrame).then(()=>{var q;if(!f.isAtBottom)return f.animation=void 0,!1;const{scrollTop:L}=f,P=performance.now(),$=(P-(f.lastTick??P))/Nht;if(f.animation||(f.animation={behavior:E,promise:M,ignoreEscapes:j}),f.animation.behavior===E&&(f.lastTick=P),c()||T>Date.now())return R();if(L<Math.min(N,f.calculatedTargetScrollTop)){if(((q=f.animation)==null?void 0:q.behavior)===E){if(E==="instant")return f.scrollTop=f.calculatedTargetScrollTop,R();f.velocity=(E.damping*f.velocity+E.stiffness*f.scrollDifference)/E.mass,f.accumulated+=f.velocity*$,f.scrollTop+=f.accumulated,f.scrollTop!==L&&(f.accumulated=0)}return R()}return _>Date.now()?(N=f.calculatedTargetScrollTop,R()):(f.animation=void 0,f.scrollTop<f.calculatedTargetScrollTop?m({animation:mR(l.current,l.current.resize),ignoreEscapes:j,duration:Math.max(0,_-Date.now())||void 0}):f.isAtBottom)});return M.then(L=>(requestAnimationFrame(()=>{f.animation||(f.lastTick=void 0,f.velocity=0)}),L))};return C.wait!==!0&&(f.animation=void 0),((O=f.animation)==null?void 0:O.behavior)===E?f.animation.promise:R()},[u,c,f]),g=x.useCallback(()=>{d(!0),u(!1)},[d,u]),y=x.useCallback(({target:C})=>{if(C!==S.current)return;const{scrollTop:T,ignoreScrollToTop:E}=f;let{lastScrollTop:j=T}=f;f.lastScrollTop=T,f.ignoreScrollToTop=void 0,E&&E>T&&(j=E),o(f.isNearBottom),setTimeout(()=>{var R;if(f.resizeDifference||T===E)return;if(c()){d(!0),u(!1);return}const _=T>j,N=T<j;if((R=f.animation)!=null&&R.ignoreEscapes){f.scrollTop=j;return}N&&(d(!0),u(!1)),_&&d(!1),!f.escapedFromLock&&f.isNearBottom&&u(!0)},1)},[d,u,c,f]),b=x.useCallback(({target:C,deltaY:T})=>{var j;let E=C;for(;!["scroll","auto"].includes(getComputedStyle(E).overflow);){if(!E.parentElement)return;E=E.parentElement}E===S.current&&T<0&&S.current.scrollHeight>S.current.clientHeight&&!((j=f.animation)!=null&&j.ignoreEscapes)&&(d(!0),u(!1))},[d,u,f]),S=Sq(C=>{var T,E;(T=S.current)==null||T.removeEventListener("scroll",y),(E=S.current)==null||E.removeEventListener("wheel",b),C==null||C.addEventListener("scroll",y,{passive:!0}),C==null||C.addEventListener("wheel",b,{passive:!0})},[]),w=Sq(C=>{var E,j;if((E=f.resizeObserver)==null||E.disconnect(),f.resizeObserver=void 0,!C)return;let T;f.resizeObserver=new ResizeObserver(([_])=>{const{height:N}=_.contentRect,R=N-(T??N);if(f.resizeDifference=R,f.scrollTop>f.targetScrollTop&&(f.scrollTop=f.targetScrollTop),o(f.isNearBottom),R>=0){const O=mR(l.current,T?l.current.resize:l.current.initial);m({animation:O,wait:!0,preserveScrollPosition:!0,duration:O==="instant"?void 0:jht})}else f.isNearBottom&&(d(!1),u(!0));T=N,requestAnimationFrame(()=>{setTimeout(()=>{f.resizeDifference===R&&(f.resizeDifference=0)},1)})}),(j=f.resizeObserver)==null||j.observe(C)},[]);return{contentRef:w,scrollRef:S,scrollToBottom:m,stopScroll:g,isAtBottom:s||i,isNearBottom:i,escapedFromLock:t,state:f}};function Sq(e,t){const n=x.useCallback(s=>(n.current=s,e(s)),t);return n}const hR=new Map;function mR(...e){const t={...Tht};let n=!1;for(const r of e){if(r==="instant"){n=!0;continue}typeof r=="object"&&(n=!1,t.damping=r.damping??t.damping,t.stiffness=r.stiffness??t.stiffness,t.mass=r.mass??t.mass)}const s=JSON.stringify(t);return hR.has(s)||hR.set(s,Object.freeze(t)),n?"instant":hR.get(s)}var Rht=/\s+/g,Mht=e=>typeof e!="string"||!e?e:e.replace(Rht," ").trim(),BC=(...e)=>{const t=[],n=s=>{if(!s&&s!==0&&s!==0n)return;if(Array.isArray(s)){for(let i=0,o=s.length;i<o;i++)n(s[i]);return}const r=typeof s;if(r==="string"||r==="number"||r==="bigint"){if(r==="number"&&s!==s)return;t.push(String(s))}else if(r==="object"){const i=Object.keys(s);for(let o=0,l=i.length;o<l;o++){const c=i[o];s[c]&&t.push(c)}}};for(let s=0,r=e.length;s<r;s++){const i=e[s];i!=null&&n(i)}return t.length>0?Mht(t.join(" ")):void 0},wq=e=>e===!1?"false":e===!0?"true":e===0?"0":e,Ci=e=>{if(!e||typeof e!="object")return!0;for(const t in e)return!1;return!0},Dht=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(let r=0;r<n.length;r++){const i=n[r];if(!s.includes(i)||e[i]!==t[i])return!1}return!0},Oht=(e,t)=>{for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const s=t[n];n in e?e[n]=BC(e[n],s):e[n]=s}return e},fde=(e,t)=>{for(let n=0;n<e.length;n++){const s=e[n];Array.isArray(s)?fde(s,t):s&&t.push(s)}},hde=(...e)=>{const t=[];fde(e,t);const n=[];for(let s=0;s<t.length;s++)t[s]&&n.push(t[s]);return n},KD=(e,t)=>{const n={};for(const s in e){const r=e[s];if(s in t){const i=t[s];Array.isArray(r)||Array.isArray(i)?n[s]=hde(i,r):typeof r=="object"&&typeof i=="object"&&r&&i?n[s]=KD(r,i):n[s]=i+" "+r}else n[s]=r}for(const s in t)s in e||(n[s]=t[s]);return n},Iht={twMerge:!0,twMergeConfig:{}};function Pht(){let e=null,t={},n=!1;return{get cachedTwMerge(){return e},set cachedTwMerge(s){e=s},get cachedTwMergeConfig(){return t},set cachedTwMergeConfig(s){t=s},get didTwMergeConfigChange(){return n},set didTwMergeConfigChange(s){n=s},reset(){e=null,t={},n=!1}}}var cc=Pht(),Lht=e=>{const t=(s,r)=>{const{extend:i=null,slots:o={},variants:l={},compoundVariants:c=[],compoundSlots:u=[],defaultVariants:d={}}=s,f={...Iht,...r},m=i!=null&&i.base?BC(i.base,s==null?void 0:s.base):s==null?void 0:s.base,g=i!=null&&i.variants&&!Ci(i.variants)?KD(l,i.variants):l,y=i!=null&&i.defaultVariants&&!Ci(i.defaultVariants)?{...i.defaultVariants,...d}:d;!Ci(f.twMergeConfig)&&!Dht(f.twMergeConfig,cc.cachedTwMergeConfig)&&(cc.didTwMergeConfigChange=!0,cc.cachedTwMergeConfig=f.twMergeConfig);const b=Ci(i==null?void 0:i.slots),S=Ci(o)?{}:{base:BC(s==null?void 0:s.base,b&&(i==null?void 0:i.base)),...o},w=b?S:Oht({...i==null?void 0:i.slots},Ci(S)?{base:s==null?void 0:s.base}:S),C=Ci(i==null?void 0:i.compoundVariants)?c:hde(i==null?void 0:i.compoundVariants,c),T=j=>{if(Ci(g)&&Ci(o)&&b)return e(m,j==null?void 0:j.class,j==null?void 0:j.className)(f);if(C&&!Array.isArray(C))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof C}`);if(u&&!Array.isArray(u))throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof u}`);const _=(q,K=g,B=null,V=null)=>{const Q=K[q];if(!Q||Ci(Q))return null;const re=(V==null?void 0:V[q])??(j==null?void 0:j[q]);if(re===null)return null;const U=wq(re);if(typeof U=="object")return null;const G=y==null?void 0:y[q],W=U??wq(G);return Q[W||"false"]},N=()=>{if(!g)return null;const q=Object.keys(g),K=[];for(let B=0;B<q.length;B++){const V=_(q[B],g);V&&K.push(V)}return K},R=(q,K)=>{if(!g||typeof g!="object")return null;const B=[];for(const V in g){const Q=_(V,g,q,K),re=q==="base"&&typeof Q=="string"?Q:Q&&Q[q];re&&B.push(re)}return B},O={};for(const q in j){const K=j[q];K!==void 0&&(O[q]=K)}const M=(q,K)=>{var V;const B=typeof(j==null?void 0:j[q])=="object"?{[q]:(V=j[q])==null?void 0:V.initial}:{};return{...y,...O,...B,...K}},L=(q=[],K)=>{const B=[],V=q.length;for(let Q=0;Q<V;Q++){const{class:re,className:U,...G}=q[Q];let W=!0;const F=M(null,K);for(const X in G){const J=G[X],ae=F[X];if(Array.isArray(J)){if(!J.includes(ae)){W=!1;break}}else{if((J==null||J===!1)&&(ae==null||ae===!1))continue;if(ae!==J){W=!1;break}}}W&&(re&&B.push(re),U&&B.push(U))}return B},P=q=>{const K=L(C,q);if(!Array.isArray(K))return K;const B={},V=e;for(let Q=0;Q<K.length;Q++){const re=K[Q];if(typeof re=="string")B.base=V(B.base,re)(f);else if(typeof re=="object")for(const U in re)B[U]=V(B[U],re[U])(f)}return B},$=q=>{if(u.length<1)return null;const K={},B=M(null,q);for(let V=0;V<u.length;V++){const{slots:Q=[],class:re,className:U,...G}=u[V];if(!Ci(G)){let W=!0;for(const F in G){const X=B[F],J=G[F];if(X===void 0||(Array.isArray(J)?!J.includes(X):J!==X)){W=!1;break}}if(!W)continue}for(let W=0;W<Q.length;W++){const F=Q[W];K[F]||(K[F]=[]),K[F].push([re,U])}}return K};if(!Ci(o)||!b){const q={};if(typeof w=="object"&&!Ci(w)){const K=e;for(const B in w)q[B]=V=>{const Q=P(V),re=$(V);return K(w[B],R(B,V),Q?Q[B]:void 0,re?re[B]:void 0,V==null?void 0:V.class,V==null?void 0:V.className)(f)}}return q}return e(m,N(),L(C),j==null?void 0:j.class,j==null?void 0:j.className)(f)},E=()=>{if(!(!g||typeof g!="object"))return Object.keys(g)};return T.variantKeys=E(),T.extend=i,T.base=m,T.slots=w,T.variants=g,T.defaultVariants=y,T.compoundSlots=u,T.compoundVariants=C,T};return{tv:t,createTV:s=>(r,i)=>t(r,i?KD(s,i):s)}},Fht=e=>Ci(e)?iE:n1e({...e,extend:{theme:e.theme,classGroups:e.classGroups,conflictingClassGroupModifiers:e.conflictingClassGroupModifiers,conflictingClassGroups:e.conflictingClassGroups,...e.extend}}),zht=(e,t)=>{const n=BC(e);return!n||!((t==null?void 0:t.twMerge)??!0)?n:((!cc.cachedTwMerge||cc.didTwMergeConfigChange)&&(cc.didTwMergeConfigChange=!1,cc.cachedTwMerge=Fht(cc.cachedTwMergeConfig)),cc.cachedTwMerge(n)||void 0)},Bht=(...e)=>t=>zht(e,t),{tv:mde}=Lht(Bht);const $ht=mde({slots:{root:"group relative flex gap-[var(--msg-gap)] transition-colors duration-150",content:"min-w-0 text-sm",timestamp:"absolute top-1 right-4 hidden text-xs transition-colors duration-150 sm:inline",divider:"absolute inset-x-0 top-0 h-px bg-[var(--msg-divider-color)]"},variants:{role:{user:{root:"ml-auto max-w-[var(--msg-user-max-width)] rounded-msg bg-user-msg px-4 py-2.5 hover:bg-user-msg/90",content:"font-[var(--msg-user-font-weight)]"},assistant:{root:"w-full px-[var(--msg-padding-x)] py-[var(--msg-padding-y)] rounded-msg hover:bg-muted",content:"max-w-[var(--msg-content-max-width)] flex-1 font-[var(--msg-assistant-font-weight)]"}},position:{first:{},middle:{},last:{},only:{}},density:{comfortable:{},compact:{root:"px-3",content:"text-xs"}}},compoundVariants:[{role:"assistant",position:"first",class:{root:"pt-[var(--msg-padding-y-start)] pb-[var(--msg-padding-y-mid)]"}},{role:"assistant",position:"middle",class:{root:"pt-[var(--msg-padding-y-mid)] pb-[var(--msg-padding-y-mid)]"}},{role:"assistant",position:"last",class:{root:"pt-[var(--msg-padding-y-mid)] pb-[var(--msg-padding-y-end)]"}},{role:"assistant",position:"only",class:{root:"pt-[var(--msg-padding-y-start)] pb-[var(--msg-padding-y-end)]"}},{role:"user",position:"first",class:{root:"mt-3 mb-px"}},{role:"user",position:"middle",class:{root:"my-px"}},{role:"user",position:"last",class:{root:"mt-px mb-3"}},{role:"user",position:"only",class:{root:"mt-3 mb-3"}},{role:"user",position:"first",class:{root:"rounded-br-msg-tight"}},{role:"user",position:"middle",class:{root:"rounded-r-msg-tight"}},{role:"user",position:"last",class:{root:"rounded-tr-msg-tight"}}],defaultVariants:{role:"assistant",position:"only",density:"comfortable"}}),pR=mde({variants:{status:{pending:"text-status-pending",running:"text-status-info",complete:"text-status-success",error:"text-status-error"}}}),pde=x.createContext(null);function Hht({children:e,value:t}){const n=x.useMemo(()=>t,[t.sessionId,t.isStreaming,t.isLatestMessage,t.activeToolCallId,t.onToolRef,t.focusedOptionIndex,t.onToolDecided,t.onRetry,t.inputZoneToolCallId,t.textEffect]);return a.jsx(pde,{value:n,children:e})}function Uht(){const e=x.useContext(pde);if(!e)throw new Error("useMessageContext must be used within MessageProvider");return e}const Vht=()=>Promise.resolve(),gde=x.createContext({onAction:Vht,agentActionsEnabled:!1,superseded:!1,latched:!1,dispatchedActionId:null,dispatchStatus:"idle"});function qht({children:e,sessionId:t,widgetTitle:n,isLatestMessage:s=!0}){const{setTheme:r}=yb(),i=je(),[o,l]=x.useState(null),[c,u]=x.useState(null),d=x.useCallback(async m=>{switch(m.kind){case"ui":{const g={store:we.getState(),setTheme:r,supportsTerminal:i.supportsTerminal};Kk(g,m.command,"user");return}case"url":l(m.href);return;case"agent":{if(!t)return;const g={actionId:m.id,payload:m.payload,widgetTitle:n},y=Zn.getState();y.setOptimisticUserMessage(t,{id:crypto.randomUUID(),content:swe(g)}),y.setTriggerPending(t,!0),u({actionId:m.id,status:"pending"});try{await i.sendUiAction(t,g),u({actionId:m.id,status:"sent"}),setTimeout(()=>{var S;const b=Zn.getState().getSession(t);b.triggerPending&&((S=b.status)==null?void 0:S.lifecycle)!=="streaming"&&Zn.getState().setTriggerPending(t,!1)},yo.TRIGGER_PENDING_TIMEOUT_MS)}catch(b){throw y.setOptimisticUserMessage(t,null),y.setTriggerPending(t,!1),u(null),b}return}}},[r,i,t,n]),f=x.useMemo(()=>({onAction:d,agentActionsEnabled:!!t,superseded:!s,latched:c!==null,dispatchedActionId:(c==null?void 0:c.actionId)??null,dispatchStatus:(c==null?void 0:c.status)??"idle"}),[d,t,s,c]);return a.jsxs(gde.Provider,{value:f,children:[e,a.jsx(TT,{url:o??"",isOpen:o!==null,onClose:()=>l(null),onConfirm:()=>{o&&window.open(o,"_blank","noopener,noreferrer"),l(null)}})]})}function h_(){return x.useContext(gde)}function xde(e){const{agentActionsEnabled:t,superseded:n,latched:s,dispatchedActionId:r,dispatchStatus:i}=h_(),o=e.kind==="agent",l=o&&r!==null&&e.id===r,c=o&&!t,u=o&&n;return{isAgent:o,unavailable:c,superseded:u,latched:o&&s&&!l,isDispatched:l,dispatchStatus:l?i:"idle",interactive:o?!c&&!u&&!s:!0}}const zi={type:"spring",stiffness:400,damping:32,mass:.8},T0=[.22,1,.36,1],VP=.05,qP=.9,Zb={hidden:{opacity:0,y:6,scale:.985},visible:{opacity:1,y:0,scale:1,transition:zi}},m_={hidden:{},visible:{transition:{staggerChildren:VP}}};function hr(){return!Ds()}function yde(e,t,n=qP*1e3){const[s,r]=x.useState(()=>t?0:e),i=x.useRef(t?0:e);return x.useEffect(()=>{if(!t){i.current=e,r(e);return}const o=MFe(i.current,e,{duration:n/1e3,ease:T0,onUpdate:l=>{i.current=l,r(l)}});return()=>o.stop()},[e,t,n]),s}const vde=x.createContext(null),Ght=vde.Provider;function bde(){return x.useContext(vde)}const Kht={default:"bg-secondary text-secondary-foreground border-transparent",success:"bg-status-success-bg text-status-success-fg border-status-success-border",warning:"bg-status-warning-bg text-status-warning-fg border-status-warning-border",error:"bg-status-error-bg text-status-error-fg border-status-error-border",info:"bg-status-info-bg text-status-info-fg border-status-info-border"};function p_(e){return Kht[e??"default"]}function Wht(e){var l;if(typeof e=="number")return Number.isFinite(e)?{prefix:"",suffix:"",decimals:0,grouped:!1,value:e}:null;const t=e.match(/^(.*?)(-?\d[\d,]*(?:\.\d+)?)(.*)$/s);if(!t)return null;const[,n,s,r]=t,i=Number(s.replace(/,/g,""));if(!Number.isFinite(i))return null;const o=s.includes(".")?((l=s.split(".")[1])==null?void 0:l.length)??0:0;return{prefix:n,suffix:r,decimals:o,grouped:s.includes(","),value:i}}function Yht(e,t){const n=t.toFixed(e.decimals),s=e.grouped?Number(n).toLocaleString("en-US",{minimumFractionDigits:e.decimals,maximumFractionDigits:e.decimals}):n;return`${e.prefix}${s}${e.suffix}`}const Zht={1:"text-lg font-semibold",2:"text-base font-semibold",3:"text-sm font-semibold"};function Xht({node:e}){const t=e.level??3,n=Y(Zht[t],"text-foreground");return t===1?a.jsx("h1",{className:n,children:e.text}):t===2?a.jsx("h2",{className:n,children:e.text}):a.jsx("h3",{className:n,children:e.text})}function Qht({node:e}){return a.jsx(Ev,{content:e.text,className:"text-sm",linkSafety:!0})}function Jht({node:e}){const t=hr();return a.jsx(te.span,{className:Y("inline-flex w-fit items-center rounded-md border px-2 py-0.5 text-xs font-medium",p_(e.tone)),initial:t?{opacity:0,scale:.8}:!1,animate:t?{opacity:1,scale:1}:!1,transition:zi,children:e.text})}function emt(){return a.jsx(av,{})}const tmt={up:mb,down:hb,flat:uh},nmt={up:"text-status-success",down:"text-status-error",flat:"text-muted-foreground"};function smt({node:e}){const t=hr(),n=Wht(e.value),s=yde((n==null?void 0:n.value)??0,t&&n!==null),r=n?Yht(n,s):String(e.value),i=e.delta?tmt[e.delta.direction]:null;return a.jsxs("div",{className:"flex flex-col gap-0.5",children:[a.jsx("span",{className:"text-muted-foreground text-xs font-medium",children:e.label}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-baseline gap-2",children:[a.jsx("span",{className:"text-foreground text-2xl font-semibold tabular-nums",children:r}),e.delta&&i&&a.jsxs(te.span,{className:Y("inline-flex items-center gap-0.5 text-xs font-medium",nmt[e.delta.direction]),initial:t?{opacity:0,x:-4}:!1,animate:t?{opacity:1,x:0}:!1,transition:{...zi,delay:.25},children:[a.jsx(i,{className:"size-3","aria-hidden":!0}),e.delta.value]})]}),e.trend&&e.trend.length>=2&&a.jsx(rmt,{values:e.trend})]}),e.hint&&a.jsx("span",{className:"text-muted-foreground text-xs",children:e.hint})]})}function rmt({values:e}){const t=hr(),n=`spark-wipe-${x.useId().replace(/:/g,"")}`,s=Math.min(...e),r=Math.max(...e),i=r-s||1,o=e.map((l,c)=>{const u=c/(e.length-1)*100,d=r===s?50:100-(l-s)/i*100;return`${u},${d}`}).join(" ");return a.jsxs("svg",{viewBox:"0 0 100 100",preserveAspectRatio:"none",className:"h-5 w-16 shrink-0 overflow-visible","aria-hidden":!0,children:[t&&a.jsx("defs",{children:a.jsx("clipPath",{id:n,children:a.jsx(te.rect,{x:-4,y:-12,height:124,initial:{width:0},animate:{width:108},transition:{duration:qP,ease:T0}})})}),a.jsx("g",{clipPath:t?`url(#${n})`:void 0,children:a.jsx("polyline",{points:o,fill:"none",stroke:"hsl(var(--chart-1))",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})})]})}function imt({node:e}){return a.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm",children:e.items.map((t,n)=>a.jsxs("div",{className:"contents",children:[a.jsx("dt",{className:"text-muted-foreground",children:t.key}),a.jsx("dd",{className:"text-foreground text-right break-words",children:t.value})]},`${t.key}-${n}`))})}function amt({node:e}){const t=hr(),n=yde(e.value,t);return a.jsxs("div",{className:"flex flex-col gap-1",children:[(e.label||e.label==="")&&a.jsxs("div",{className:"text-muted-foreground flex items-center justify-between text-xs",children:[a.jsx("span",{children:e.label}),a.jsxs("span",{className:"tabular-nums",children:[Math.round(n),"%"]})]}),a.jsx(UFe,{value:n})]})}function omt({node:e}){return a.jsxs("figure",{className:"flex flex-col gap-1",children:[a.jsx("img",{src:e.src,alt:e.alt,className:"max-h-80 w-full rounded-md border object-contain",loading:"lazy"}),e.caption&&a.jsx("figcaption",{className:"text-muted-foreground text-xs",children:e.caption})]})}const lmt=te.create(h0),cmt=te.create(Tc),kq={left:"text-left",center:"text-center",right:"text-right"};function umt(e){return e===null?"—":typeof e=="boolean"?e?"Yes":"No":String(e)}function dmt({node:e}){const t=hr();return a.jsx("div",{className:"overflow-x-auto",children:a.jsxs(f0,{children:[a.jsx(c4,{children:a.jsx(Tc,{children:e.columns.map(n=>a.jsx(fC,{className:Y(n.align&&kq[n.align]),children:n.label},n.key))})}),a.jsx(lmt,{variants:t?m_:void 0,initial:t?"hidden":!1,animate:t?"visible":!1,children:e.rows.map((n,s)=>a.jsx(cmt,{variants:t?Zb:void 0,children:e.columns.map(r=>a.jsx(ra,{className:Y("tabular-nums",r.align&&kq[r.align]),children:umt(n[r.key]??null)},r.key))},s))})]})})}const fmt={"alert-circle":Hh,"alert-triangle":fr,archive:Qje,"arrow-right":uh,bell:qte,bookmark:dAe,calendar:Kte,check:Lt,"check-circle":MAe,circle:dh,clock:Pi,cloud:VAe,code:GAe,cog:G5,database:tRe,file:qh,"file-text":Qg,flag:RRe,folder:th,"git-branch":$p,globe:ha,heart:QRe,home:eMe,info:VE,link:ane,lock:pb,mail:one,"map-pin":CMe,"message-square":Rd,package:une,play:wy,rocket:v3e,search:pa,server:mne,settings:qa,star:YE,tag:rDe,terminal:J5,"thumbs-up":oDe,trash:gDe,"trending-down":yDe,"trending-up":SDe,user:Md,users:e0,zap:Uc};function GP(e){if(!e)return dh;const t=e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/\s+/g,"-").toLowerCase();return fmt[t]??dh}function g_({action:e,label:t,variant:n,fullWidth:s}){const{onAction:r}=h_(),i=xde(e),o=hr(),l=i.isDispatched&&i.dispatchStatus==="pending",c=i.isDispatched&&i.dispatchStatus==="sent",u=!i.interactive,d=o&&i.interactive,f=()=>{if(u)return;const y=r(e);e.kind==="agent"&&y.catch(()=>{Ye.error("Couldn't send the action",{description:"The agent may be busy right now — try again in a moment."})})};let m=null;i.superseded?m="Superseded — use the latest widget":i.unavailable?m="Interactions aren't available here":i.latched&&(m="Sent — waiting for the agent's reply");const g=a.jsxs(ge,{type:"button",size:"sm",variant:n??"default","aria-disabled":u||void 0,disabled:l,onClick:u?void 0:f,className:Y(s&&"w-full",u&&"cursor-default",(i.unavailable||i.superseded)&&"opacity-50",c&&"opacity-70"),children:[l&&a.jsx(Sn,{className:"size-3.5 animate-spin","aria-hidden":!0}),c&&a.jsx(Lt,{className:"size-3.5","aria-hidden":!0}),t]});return m?a.jsx(em,{children:a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:g}),a.jsx(yn,{children:m})]})}):d?a.jsx(te.div,{className:Y("inline-flex",s&&"w-full"),whileHover:{scale:1.02},whileTap:{scale:.97},transition:zi,children:g}):g}function hmt({node:e}){return a.jsx(g_,{action:e.action,label:e.label,variant:e.variant})}function mmt({node:e}){const t=bde(),[n,s]=x.useState(""),r=t?t.values[e.name]??"":n,i=o=>t?t.setValue(e.name,o):s(o);return a.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.label&&a.jsx(Rt,{htmlFor:`widget-${e.name}`,children:e.label}),a.jsx(sn,{id:`widget-${e.name}`,name:e.name,type:e.kind==="number"?"number":"text",placeholder:e.placeholder,value:r,onChange:o=>i(o.target.value)})]})}function pmt({node:e}){const t=bde(),[n,s]=x.useState(""),r=t?t.values[e.name]??"":n,i=o=>t?t.setValue(e.name,o):s(o);return a.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.label&&a.jsx(Rt,{htmlFor:`widget-${e.name}`,children:e.label}),a.jsxs(On,{value:r||void 0,onValueChange:i,children:[a.jsx(_n,{id:`widget-${e.name}`,children:a.jsx(In,{placeholder:"Select…"})}),a.jsx(Nn,{children:e.options.map(o=>a.jsx(mt,{value:o.value,children:o.label},o.value))})]})]})}function gmt({node:e}){const t=hr();return a.jsx(te.ul,{className:"divide-border divide-y",variants:t?m_:void 0,initial:t?"hidden":!1,animate:t?"visible":!1,children:e.items.map((n,s)=>{const r=GP(n.icon);return a.jsxs(te.li,{className:"hover:bg-muted/40 -mx-2 flex items-center gap-3 rounded-md px-2 py-2 transition-colors first:pt-0 last:pb-0",variants:t?Zb:void 0,children:[n.image&&a.jsx("img",{src:n.image,alt:"",className:"size-10 shrink-0 rounded-md border object-cover",loading:"lazy"}),n.icon&&a.jsx(r,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":!0}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-foreground truncate text-sm font-medium",children:n.title}),n.subtitle&&a.jsx("p",{className:"text-muted-foreground truncate text-xs",children:n.subtitle})]}),n.meta&&a.jsx("span",{className:"text-muted-foreground shrink-0 text-sm tabular-nums",children:n.meta}),n.badge&&a.jsx("span",{className:Y("inline-flex shrink-0 items-center rounded-md border px-2 py-0.5 text-xs font-medium",p_(n.badge.tone)),children:n.badge.text}),n.actions&&n.actions.length>0&&a.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:n.actions.map((i,o)=>a.jsx(g_,{action:i,label:i.kind==="agent"?i.label??"Action":xmt(i)},o))})]},s)})})}function xmt(e){return e.kind==="url"?"Open":"Run"}const Ff=["hsl(var(--chart-1))","hsl(var(--chart-2))","hsl(var(--chart-3))","hsl(var(--chart-4))","hsl(var(--chart-5))"],ymt=180,vmt=.15;function bmt({node:e}){const t=e.height??ymt,n=`${e.kind} chart`;return e.data.length===0?a.jsx("p",{className:"text-muted-foreground text-xs",children:"No data to chart."}):e.kind==="bar"?a.jsx(wmt,{data:e.data,height:t,label:n}):e.kind==="pie"?a.jsx(Emt,{data:e.data,height:t,label:n}):a.jsx(kmt,{data:e.data,height:t,area:e.kind==="area",label:n})}const Smt=18;function wmt({data:e,height:t,label:n}){const s=hr(),r=Math.max(...e.map(o=>o.value),0)||1,i=Math.max(0,t-Smt);return a.jsxs("div",{role:"img","aria-label":n,className:"flex flex-col gap-1",children:[a.jsx("div",{className:"flex items-end gap-2",style:{height:t},children:e.map((o,l)=>a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col items-center justify-end gap-1",children:[a.jsx("span",{className:"text-muted-foreground text-2xs tabular-nums",children:o.value}),a.jsx(te.div,{className:"w-full origin-bottom rounded-t-sm",style:{height:o.value/r*i,backgroundColor:Ff[l%Ff.length]},initial:s?{scaleY:0}:!1,animate:s?{scaleY:1}:!1,transition:{...zi,delay:l*VP}})]},l))}),a.jsx(Sde,{data:e})]})}function kmt({data:e,height:t,area:n,label:s}){const r=Math.max(...e.map(m=>m.value),0)||1,i=e.length,l=e.map((m,g)=>{const y=i===1?50:g/(i-1)*100,b=100-m.value/r*100;return{x:y,y:b}}).map(m=>`${m.x},${m.y}`).join(" "),c=`0,100 ${l} 100,100`,u=Ff[0],d=hr(),f=`chart-wipe-${x.useId().replace(/:/g,"")}`;return a.jsxs("div",{role:"img","aria-label":s,className:"flex flex-col gap-1",children:[a.jsxs("svg",{viewBox:"0 0 100 100",preserveAspectRatio:"none",style:{height:t},className:"w-full overflow-visible",children:[d&&a.jsx("defs",{children:a.jsx("clipPath",{id:f,children:a.jsx(te.rect,{x:-4,y:-12,height:124,initial:{width:0},animate:{width:108},transition:{duration:qP,ease:T0}})})}),a.jsxs("g",{clipPath:d?`url(#${f})`:void 0,children:[n&&a.jsx("polygon",{points:c,fill:u,opacity:vmt}),a.jsx("polyline",{points:l,fill:"none",stroke:u,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]})]}),a.jsx(Sde,{data:e})]})}const Cmt=359.99;function Emt({data:e,height:t,label:n}){const s=hr(),r=e.reduce((o,l)=>o+l.value,0)||1,i=e.map((o,l)=>{const u=-90+e.slice(0,l).reduce((m,g)=>m+g.value,0)/r*360,d=o.value/r*360,f=d>=Cmt;return{d:o,full:f,path:f?"":Tmt(u,u+d)}});return a.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[a.jsx("svg",{viewBox:"0 0 100 100",role:"img","aria-label":n,style:{height:t,width:t},children:i.map((o,l)=>{const c=Ff[l%Ff.length],u={initial:s?{opacity:0,scale:.6}:!1,animate:s?{opacity:1,scale:1}:!1,transition:{...zi,delay:l*VP},style:{transformOrigin:"50px 50px"}};return o.full?a.jsx(te.circle,{cx:50,cy:50,r:50,fill:c,...u},l):a.jsx(te.path,{d:o.path,fill:c,...u},l)})}),a.jsx("ul",{className:"flex flex-col gap-1 text-xs",children:e.map((o,l)=>a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"size-2.5 shrink-0 rounded-sm",style:{backgroundColor:Ff[l%Ff.length]},"aria-hidden":!0}),a.jsx("span",{className:"text-foreground",children:o.label}),a.jsx("span",{className:"text-muted-foreground tabular-nums",children:o.value})]},l))})]})}function Sde({data:e}){return a.jsx("div",{className:"flex gap-2",children:e.map((t,n)=>a.jsx("span",{className:Y("text-muted-foreground text-2xs min-w-0 flex-1 truncate text-center"),title:t.label,children:t.label},n))})}function Tmt(e,t){const i=Cq(50,50,50,e),o=Cq(50,50,50,t),l=t-e>180?1:0;return`M 50 50 L ${i.x} ${i.y} A 50 50 0 ${l} 1 ${o.x} ${o.y} Z`}function Cq(e,t,n,s){const r=s*Math.PI/180;return{x:e+n*Math.cos(r),y:t+n*Math.sin(r)}}const _mt={done:"border-status-success bg-status-success text-status-success-fg",active:"border-primary bg-primary text-primary-foreground",upcoming:"border-border bg-background text-muted-foreground"};function Nmt({node:e}){const t=hr();return a.jsx(te.ol,{className:"flex flex-col",variants:t?m_:void 0,initial:t?"hidden":!1,animate:t?"visible":!1,children:e.items.map((n,s)=>{const r=n.status??"upcoming",i=s===e.items.length-1,o=n.icon?GP(n.icon):null;return a.jsxs(te.li,{className:"flex gap-3",variants:t?Zb:void 0,children:[a.jsxs("div",{className:"flex flex-col items-center",children:[a.jsxs("span",{className:"relative flex size-5 shrink-0 items-center justify-center",children:[r==="active"&&t&&a.jsx(te.span,{className:"border-primary absolute inset-0 rounded-full border",initial:{opacity:.6,scale:1},animate:{opacity:0,scale:1.8},transition:{duration:1.6,repeat:1/0,ease:"easeOut"},"aria-hidden":!0}),a.jsx("span",{className:Y("flex size-3 items-center justify-center rounded-full border",_mt[r],r==="active"&&"ring-primary/30 ring-2"),children:o&&a.jsx(o,{className:"size-2.5","aria-hidden":!0})})]}),!i&&a.jsx("span",{className:"bg-border w-px flex-1","aria-hidden":!0})]}),a.jsxs("div",{className:Y("min-w-0 flex-1",!i&&"pb-4"),children:[n.time&&a.jsx("p",{className:"text-muted-foreground text-xs tabular-nums",children:n.time}),a.jsx("p",{className:Y("text-foreground text-sm",r==="active"?"font-semibold":"font-medium"),children:n.title}),n.subtitle&&a.jsx("p",{className:"text-muted-foreground text-xs",children:n.subtitle})]})]},s)})})}function jmt({node:e}){const t=x.useId(),[n,s]=x.useState(()=>e.items.map(i=>i.checked??!1)),r=x.useMemo(()=>{if(!e.action)return null;const i=e.items.filter((l,c)=>n[c]).map(l=>l.label),o=e.items.filter((l,c)=>!n[c]).map(l=>l.label);return{...e.action,payload:{...e.action.payload??{},checked:i,unchecked:o}}},[e.action,e.items,n]);return a.jsxs("div",{className:"flex flex-col gap-3",children:[a.jsx("ul",{className:"flex flex-col gap-2",children:e.items.map((i,o)=>{const l=`${t}-${o}`;return a.jsxs("li",{className:"flex items-start gap-2.5",children:[a.jsx(Sg,{id:l,checked:n[o],onCheckedChange:c=>s(u=>u.map((d,f)=>f===o?c===!0:d)),className:"mt-0.5"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx(Rt,{htmlFor:l,className:Y("text-sm font-normal transition-colors",n[o]&&"text-muted-foreground line-through"),children:i.label}),i.note&&a.jsx("p",{className:"text-muted-foreground text-xs",children:i.note})]})]},o)})}),r&&a.jsx(g_,{action:r,label:e.submitLabel??"Confirm",fullWidth:!0})]})}const Amt=te.create(h0),Rmt=te.create(Tc);function Mmt({value:e}){return e==null?a.jsx("span",{className:"text-muted-foreground",children:"—"}):typeof e=="boolean"?e?a.jsx(Lt,{className:"text-status-success mx-auto size-4","aria-label":"Yes"}):a.jsx(es,{className:"text-muted-foreground mx-auto size-4","aria-label":"No"}):a.jsx("span",{className:"tabular-nums",children:String(e)})}function Dmt({node:e}){const t=hr();return a.jsx("div",{className:"overflow-x-auto",children:a.jsxs(f0,{children:[a.jsx(c4,{children:a.jsxs(Tc,{children:[a.jsx(fC,{}),e.options.map((n,s)=>a.jsxs(fC,{className:Y("text-center",n.recommended&&"bg-primary/5"),children:[a.jsx("span",{className:"text-foreground font-medium",children:n.name}),n.recommended&&a.jsx("span",{className:Y("text-2xs mt-1 flex w-fit items-center justify-center rounded-md border px-1.5 py-0.5 font-medium","mx-auto",p_("success")),children:"Recommended"})]},s))]})}),a.jsx(Amt,{variants:t?m_:void 0,initial:t?"hidden":!1,animate:t?"visible":!1,children:e.rows.map((n,s)=>a.jsxs(Rmt,{variants:t?Zb:void 0,children:[a.jsx(ra,{className:"text-muted-foreground font-medium",children:n.label}),e.options.map((r,i)=>a.jsx(ra,{className:Y("text-center",r.recommended&&"bg-primary/5"),children:a.jsx(Mmt,{value:n.values[i]??null})},i))]},s))})]})})}const WD=5,Omt=Array.from({length:WD});function Eq({className:e}){return a.jsx("div",{className:"flex","aria-hidden":!0,children:Omt.map((t,n)=>a.jsx(YE,{className:Y("size-4",e)},n))})}function Imt({node:e}){const t=hr(),n=e.value/WD*100;return a.jsxs(te.div,{className:"flex items-center gap-2",initial:t?{opacity:0,y:4}:!1,animate:t?{opacity:1,y:0}:!1,transition:zi,children:[a.jsxs("div",{className:"relative w-fit",role:"img","aria-label":`Rated ${e.value.toFixed(1)} out of ${WD}`,children:[a.jsx(Eq,{className:"text-muted-foreground"}),a.jsx("div",{className:"absolute inset-y-0 left-0 overflow-hidden",style:{width:`${n}%`},children:a.jsx(Eq,{className:"fill-status-warning text-status-warning"})})]}),a.jsx("span",{className:"text-foreground text-sm font-medium tabular-nums",children:e.value.toFixed(1)}),e.count!==void 0&&a.jsxs("span",{className:"text-muted-foreground text-sm tabular-nums",children:["(",e.count.toLocaleString(),")"]}),e.label&&a.jsx("span",{className:"text-muted-foreground text-sm",children:e.label})]})}const Tq=3,yw=42,Pmt={thinking:{lx:27,rx:43,y:22},sheepish:{lx:21,rx:37,y:30}},Lmt={lx:24,rx:40,y:26},Fmt=.15,zmt=4.85,Bmt={duration:Fmt,times:[0,.85,.92,1],repeat:1/0,repeatDelay:zmt,ease:"easeInOut"},_q=new Set(["happy","thinking","sheepish","determined","surprised","sad"]);function $mt({node:e}){const t=hr(),n=x.useRef(!1);return x.useEffect(()=>{e.emotion!=="celebrating"||!t||n.current||(n.current=!0,Yv())},[e.emotion,t]),a.jsxs(te.div,{className:"flex items-center gap-3",role:"img","aria-label":`Mood: ${e.emotion}`,initial:t?{opacity:0,scale:.9}:!1,animate:t?{opacity:1,scale:1}:!1,transition:zi,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(te.div,{className:"bg-muted text-foreground relative flex size-14 shrink-0 items-center justify-center overflow-hidden rounded-full",animate:e.emotion==="celebrating"&&t?{y:[0,-3,0]}:void 0,transition:e.emotion==="celebrating"&&t?{duration:1.4,repeat:1/0,ease:"easeInOut"}:void 0,children:a.jsx("svg",{viewBox:"0 0 64 64",className:"size-full","aria-hidden":!0,children:a.jsx(Hmt,{emotion:e.emotion,motionOn:t})})}),e.emotion==="thinking"&&a.jsx(Vmt,{motionOn:t})]}),e.message&&a.jsx("div",{className:"bg-muted/40 rounded-lg border px-3 py-2 text-sm",children:e.message})]})}function Hmt({emotion:e,motionOn:t}){const n=Pmt[e]??Lmt;return a.jsxs(a.Fragment,{children:[e==="love"?a.jsxs(a.Fragment,{children:[a.jsx(Aq,{cx:n.lx,cy:n.y,motionOn:t}),a.jsx(Aq,{cx:n.rx,cy:n.y,motionOn:t})]}):e==="celebrating"?a.jsxs(a.Fragment,{children:[a.jsx(jq,{cx:n.lx,cy:n.y}),a.jsx(jq,{cx:n.rx,cy:n.y})]}):a.jsxs(a.Fragment,{children:[a.jsx(Nq,{cx:n.lx,cy:n.y,r:e==="surprised"?4.5:Tq,popIn:e==="surprised",active:_q.has(e),motionOn:t}),a.jsx(Nq,{cx:n.rx,cy:n.y,r:e==="surprised"?4.5:Tq,popIn:e==="surprised",active:_q.has(e),motionOn:t})]}),e==="determined"&&a.jsxs(a.Fragment,{children:[a.jsx("line",{x1:n.lx-5,y1:n.y-7,x2:n.lx+3,y2:n.y-4,stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round"}),a.jsx("line",{x1:n.rx+5,y1:n.y-7,x2:n.rx-3,y2:n.y-4,stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round"})]}),e==="sheepish"&&a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:14,cy:34,r:3,className:"text-status-error",fill:"currentColor",fillOpacity:.3}),a.jsx("circle",{cx:50,cy:34,r:3,className:"text-status-error",fill:"currentColor",fillOpacity:.3})]}),a.jsx(Umt,{emotion:e})]})}function Umt({emotion:e}){switch(e){case"happy":return a.jsx("path",{d:"M20 40 Q32 50 44 40",fill:"none",stroke:"currentColor",strokeWidth:3,strokeLinecap:"round"});case"thinking":return a.jsx("line",{x1:27,y1:yw,x2:37,y2:yw,stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round"});case"celebrating":return a.jsx("path",{d:"M20 38 Q32 52 44 38 Q32 45 20 38 Z",fill:"currentColor",stroke:"currentColor",strokeWidth:1,strokeLinejoin:"round"});case"sheepish":return a.jsx("path",{d:"M24 42 Q28 39.5 32 42 T40 42",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"});case"determined":return a.jsx("line",{x1:23,y1:yw,x2:41,y2:yw,stroke:"currentColor",strokeWidth:3,strokeLinecap:"round"});case"surprised":return a.jsx("circle",{cx:32,cy:44,r:3,fill:"none",stroke:"currentColor",strokeWidth:2});case"sad":return a.jsx("path",{d:"M20 46 Q32 37 44 46",fill:"none",stroke:"currentColor",strokeWidth:3,strokeLinecap:"round"});case"love":return a.jsx("path",{d:"M22 40 Q32 46 42 40",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round"})}}function Nq({cx:e,cy:t,r:n,active:s,popIn:r,motionOn:i}){const o=i&&s;return a.jsx(te.circle,{cx:e,cy:t,r:n,fill:"currentColor",style:{transformOrigin:`${e}px ${t}px`},initial:i&&r?{scale:.3}:void 0,animate:i?{scale:1,...o?{scaleY:[1,1,.1,1]}:{}}:void 0,transition:i?{scale:zi,...o?{scaleY:Bmt}:{}}:void 0})}function jq({cx:e,cy:t}){return a.jsx("path",{d:`M ${e-4} ${t+1} Q ${e} ${t-4} ${e+4} ${t+1}`,fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round"})}function Aq({cx:e,cy:t,motionOn:n}){const s=`M ${e} ${t+4} C ${e-8} ${t-2}, ${e-4} ${t-8}, ${e} ${t-4} C ${e+4} ${t-8}, ${e+8} ${t-2}, ${e} ${t+4} Z`;return a.jsx(te.path,{d:s,fill:"currentColor",className:"text-status-error",style:{transformOrigin:`${e}px ${t}px`},animate:n?{scale:[1,1.1,1]}:void 0,transition:n?{duration:1.8,repeat:1/0,ease:"easeInOut"}:void 0})}function Vmt({motionOn:e}){return a.jsx("div",{className:"flex items-end gap-1","aria-hidden":!0,children:[0,1,2].map(t=>a.jsx(te.span,{className:"bg-muted-foreground/60 size-1.5 rounded-full",animate:e?{opacity:[.25,1,.25]}:void 0,transition:e?{duration:1.2,repeat:1/0,delay:t*.25,ease:"easeInOut"}:void 0},t))})}const qmt=2,Gmt=5;function Kmt(e,t){var s,r,i,o;const n=(r=(s=e[t[0].row])==null?void 0:s[t[0].col])==null?void 0:r.glyph;if(!n)return null;for(const{row:l,col:c}of t)if(((o=(i=e[l])==null?void 0:i[c])==null?void 0:o.glyph)!==n)return null;return n}function Wmt(e){const t=e.length;if(t<qmt||t>Gmt||e.some(s=>s.length!==t))return null;const n=[];for(let s=0;s<t;s++)n.push(Array.from({length:t},(r,i)=>({row:s,col:i}))),n.push(Array.from({length:t},(r,i)=>({row:i,col:s})));n.push(Array.from({length:t},(s,r)=>({row:r,col:r}))),n.push(Array.from({length:t},(s,r)=>({row:r,col:t-1-r})));for(const s of n){const r=Kmt(e,s);if(r)return{glyph:r,cells:s}}return null}function Ymt(e,t,n){return e!==null&&e.cells.some(s=>s.row===t&&s.col===n)}const Rq=.12,Zmt=.2,wde="0 0 24 24";function Xmt(e){const t=e.trim().toLowerCase();return t==="x"?"x":t==="o"||t==="0"||t==="⭕"||t==="◯"?"o":"glyph"}const YD={className:"stroke-current",fill:"none",strokeWidth:2.75,strokeLinecap:"round"};function Qmt({motionOn:e}){const t=n=>({duration:Rq,ease:T0,delay:n});return a.jsxs("svg",{viewBox:wde,className:"size-[1.15em]","aria-hidden":!0,focusable:"false",children:[a.jsx(te.path,{...YD,d:"M7 7 L17 17",initial:e?{pathLength:0}:!1,animate:e?{pathLength:1}:!1,transition:e?t(0):void 0}),a.jsx(te.path,{...YD,d:"M17 7 L7 17",initial:e?{pathLength:0}:!1,animate:e?{pathLength:1}:!1,transition:e?t(Rq):void 0})]})}function Jmt({motionOn:e}){return a.jsx("svg",{viewBox:wde,className:"size-[1.15em]","aria-hidden":!0,focusable:"false",children:a.jsx(te.circle,{...YD,cx:12,cy:12,r:6.5,transform:"rotate(-90 12 12)",initial:e?{pathLength:0}:!1,animate:e?{pathLength:1}:!1,transition:e?{duration:Zmt,ease:T0}:void 0})})}function ept({motionOn:e}){return a.jsx(te.span,{"aria-hidden":!0,className:"bg-foreground/70 block size-[0.5em] rounded-full",initial:e?{scale:0,opacity:0}:!1,animate:e?{scale:1,opacity:1}:!1,transition:e?zi:void 0})}function $C({mark:e,motionOn:t}){if(!e.trim())return a.jsx(ept,{motionOn:t});const n=Xmt(e);return n==="x"?a.jsx(Qmt,{motionOn:t}):n==="o"?a.jsx(Jmt,{motionOn:t}):a.jsx(te.span,{"aria-hidden":!0,className:"block leading-none",initial:t?{scale:.4,opacity:0}:!1,animate:t?{scale:1,opacity:1}:!1,transition:t?zi:void 0,children:e})}function gR(e){if(!e||e.kind!=="agent")return"";const t=e.payload,n=(t==null?void 0:t.glyph)??(t==null?void 0:t.mark);return typeof n=="string"?n:""}function kde(e){return e.glyph?e.glyph:e.icon?e.icon:"filled"}function Cde(e){return Y("relative flex aspect-square items-center justify-center rounded-md border text-2xl leading-none",e.tone&&p_(e.tone))}function tpt({cell:e,icon:t,motionOn:n,row:s,col:r,winRole:i}){const o=!!(e.glyph||e.icon);return a.jsxs(te.div,{role:"gridcell","aria-label":o?`Row ${s+1}, column ${r+1}: ${kde(e)}`:void 0,className:Y(Cde(e),i==="loser"&&"opacity-60"),animate:n&&i==="winner"?{scale:[1,1.08,1]}:void 0,transition:n&&i==="winner"?{duration:1.4,repeat:1/0,ease:"easeInOut",delay:.6}:void 0,children:[e.glyph&&a.jsx($C,{mark:e.glyph,motionOn:n}),!e.glyph&&t&&a.jsx(t,{className:"size-6","aria-hidden":!0})]})}function npt({cell:e,icon:t,motionOn:n,row:s,col:r,winRole:i}){const{onAction:o}=h_(),l=xde(e.action),c=l.isDispatched?gR(e.action):null,u=l.interactive&&e.action.kind==="agent"&&!!gR(e.action),d=!l.interactive,f=()=>{if(!l.interactive)return;const b=o(e.action);e.action.kind==="agent"&&b.catch(()=>{Ye.error("Couldn't send the move",{description:"The agent may be busy right now — try again in a moment."})})},m=(()=>{const b=`Row ${s+1}, column ${r+1}`;return l.isDispatched?`${b}: ${c||"played"}`:e.glyph||e.icon?`${b}: ${kde(e)}`:l.interactive?`${b}: empty — play here`:`${b}: empty`})();let g=null;l.superseded?g="Superseded — use the latest widget":l.unavailable?g="Interactions aren't available here":l.latched&&(g="Move sent — waiting for the agent's reply");const y=a.jsxs(te.button,{type:"button","aria-label":m,"aria-disabled":d||void 0,onClick:d?void 0:f,className:Y(Cde(e),"group focus-ring w-full transition-colors",l.interactive&&"hover:bg-muted/60 cursor-pointer",d&&"cursor-default",i==="loser"&&"opacity-60"),whileHover:l.interactive?{scale:1.05}:void 0,whileTap:l.interactive?{scale:.95}:void 0,transition:zi,children:[u&&a.jsx("span",{className:"pointer-events-none absolute inset-0 flex items-center justify-center text-2xl opacity-0 transition-opacity duration-150 group-hover:opacity-20",children:a.jsx($C,{mark:gR(e.action),motionOn:!1})}),a.jsx(spt,{optimisticMark:c,glyph:e.glyph,icon:t,motionOn:n})]});return a.jsx(te.div,{role:"gridcell",animate:n&&i==="winner"?{scale:[1,1.08,1]}:void 0,transition:n&&i==="winner"?{duration:1.4,repeat:1/0,ease:"easeInOut",delay:.6}:void 0,children:g?a.jsx(em,{children:a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:y}),a.jsx(yn,{children:g})]})}):y})}function spt({optimisticMark:e,glyph:t,icon:n,motionOn:s}){return e!==null?a.jsx($C,{mark:e,motionOn:s}):t?a.jsx($C,{mark:t,motionOn:s}):n?a.jsx(n,{className:"size-6","aria-hidden":!0}):null}function rpt(e){return e.cell.action?a.jsx(npt,{...e,cell:e.cell}):a.jsx(tpt,{...e})}const Mq=.28,ipt=.32;function vw(e,t,n){return e*(t+n)+t/2}function apt({win:e,size:t,cellUnit:n,gapUnit:s,colorClass:r,motionOn:i}){const o=t*n+(t-1)*s,l=e.cells[0],c=e.cells[e.cells.length-1],u=vw(l.col,n,s),d=vw(l.row,n,s),f=vw(c.col,n,s),m=vw(c.row,n,s);return a.jsx("svg",{viewBox:`0 0 ${o} ${o}`,className:Y("pointer-events-none absolute inset-0 h-full w-full",r),"aria-hidden":!0,focusable:"false",children:a.jsx(te.line,{x1:u,y1:d,x2:f,y2:m,className:"stroke-current",strokeWidth:2.25,strokeLinecap:"round",initial:i?{pathLength:0,opacity:0}:!1,animate:i?{pathLength:1,opacity:1}:!1,transition:i?{pathLength:{duration:ipt,ease:T0,delay:Mq},opacity:{duration:.12,delay:Mq}}:void 0})})}const opt={},lpt=.02,cpt={hidden:{},visible:{transition:{staggerChildren:lpt}}};function upt(e,t,n,s){return e?Ymt(e,t,n)?"winner":s.glyph?"loser":"none":"none"}const dpt=4,fpt=3.25,hpt=2.5,mpt=.25,ppt={default:"text-primary",success:"text-status-success-fg",warning:"text-status-warning-fg",error:"text-status-error-fg",info:"text-status-info-fg"};function gpt({node:e}){var d,f;const t=hr(),{latched:n,superseded:s}=h_(),r=Math.max(1,...e.rows.map(m=>m.length)),i=r<=dpt?fpt:hpt,o=Wmt(e.rows),l=o?((f=(d=e.rows[o.cells[0].row])==null?void 0:d[o.cells[0].col])==null?void 0:f.tone)??"default":"default",c=ppt[l],u=n&&!s;return a.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.label&&a.jsx("p",{className:"text-muted-foreground text-xs",children:e.label}),a.jsxs("div",{className:Y("relative w-fit",s&&"saturate-[0.9]"),children:[u&&a.jsx(te.div,{"aria-hidden":!0,className:"ring-primary/40 pointer-events-none absolute -inset-1 rounded-lg ring-2",initial:t?{opacity:.25}:!1,animate:t?{opacity:[.25,.6,.25]}:{opacity:.4},transition:t?{duration:2,repeat:1/0,ease:"easeInOut"}:void 0}),a.jsx(te.div,{role:"grid","aria-label":e.label??"Board",className:"grid w-fit gap-1",style:{gridTemplateColumns:`repeat(${r}, minmax(0, ${i}rem))`},variants:t?cpt:void 0,initial:t?"hidden":!1,animate:t?"visible":!1,children:e.rows.map((m,g)=>a.jsx("div",{role:"row",className:"contents",children:Array.from({length:r},(y,b)=>{const S=m[b]??opt,w=!S.glyph&&S.icon?GP(S.icon):null,C=upt(o,g,b,S);return a.jsx(rpt,{cell:S,icon:w,motionOn:t,row:g,col:b,winRole:C},`${g}-${b}`)})},g))}),o&&a.jsx(apt,{win:o,size:r,cellUnit:i,gapUnit:mpt,colorClass:c,motionOn:t})]})]})}const xpt=1.2,ypt={coin:"rounded-full bg-status-warning-bg border-status-warning-border text-status-warning-fg",d6:"rounded-xl bg-muted border-border text-foreground",d20:"rounded-xl bg-muted border-border text-foreground","8ball":"rounded-full bg-foreground border-foreground text-background"},vpt=[oRe,sRe,iRe,cRe,dRe,hRe];function bpt(e){const t={duration:xpt,ease:"easeOut"};switch(e){case"coin":return{animate:{rotateY:[0,360,720,1080]},transition:t};case"d6":case"d20":return{animate:{rotate:[0,-15,15,-10,10,0],x:[0,-2,2,-2,2,0]},transition:t};case"8ball":return{animate:{x:[0,-6,6,-4,4,-2,2,0]},transition:t}}}function Spt({kind:e,result:t}){switch(e){case"coin":return a.jsx(YAe,{className:"size-7","aria-hidden":!0});case"8ball":return a.jsx("span",{"aria-hidden":!0,children:"8"});case"d20":return a.jsx("svg",{viewBox:"0 0 24 24",className:"size-7","aria-hidden":!0,children:a.jsx("polygon",{points:"12,2 21,8 21,16 12,22 3,16 3,8",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinejoin:"round"})});case"d6":{const n=Number(t),s=Number.isInteger(n)&&n>=1&&n<=6?vpt[n-1]:pRe;return a.jsx(s,{className:"size-7","aria-hidden":!0})}}}function wpt({node:e}){const t=hr(),[n,s]=x.useState(0),[r,i]=x.useState(!t),{animate:o,transition:l}=bpt(e.kind);return a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{type:"button","aria-label":`Replay the ${e.kind} reveal`,onClick:()=>{t&&(i(!1),s(c=>c+1))},className:Y("focus-ring flex size-16 shrink-0 items-center justify-center border-2 text-lg font-bold",ypt[e.kind]),children:a.jsx(te.span,{className:"flex items-center justify-center",initial:t?{rotate:0,x:0,rotateY:0}:!1,animate:t?o:!1,transition:t?l:void 0,onAnimationComplete:()=>i(!0),children:a.jsx(Spt,{kind:e.kind,result:e.result})},n)}),a.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.label&&a.jsx("span",{className:"text-muted-foreground text-xs",children:e.label}),a.jsx(te.span,{"aria-live":"polite",className:"text-foreground text-lg font-semibold tabular-nums",initial:t?{opacity:0,scale:1.3}:!1,animate:r?{opacity:1,scale:1}:{opacity:0,scale:1.3},transition:zi,children:r?e.result:""})]})]})}const kpt={sm:"gap-2",md:"gap-3",lg:"gap-5"};function Ov({node:e}){switch(e.type){case"stack":return a.jsx(Cpt,{node:e});case"card":return a.jsx(Ept,{node:e});case"form":return a.jsx(Tpt,{node:e});case"divider":return a.jsx(emt,{});case"heading":return a.jsx(Xht,{node:e});case"text":return a.jsx(Qht,{node:e});case"badge":return a.jsx(Jht,{node:e});case"stat":return a.jsx(smt,{node:e});case"keyValue":return a.jsx(imt,{node:e});case"progress":return a.jsx(amt,{node:e});case"image":return a.jsx(omt,{node:e});case"table":return a.jsx(dmt,{node:e});case"list":return a.jsx(gmt,{node:e});case"chart":return a.jsx(bmt,{node:e});case"timeline":return a.jsx(Nmt,{node:e});case"checklist":return a.jsx(jmt,{node:e});case"compare":return a.jsx(Dmt,{node:e});case"rating":return a.jsx(Imt,{node:e});case"mood":return a.jsx($mt,{node:e});case"board":return a.jsx(gpt,{node:e});case"reveal":return a.jsx(wpt,{node:e});case"button":return a.jsx(hmt,{node:e});case"input":return a.jsx(mmt,{node:e});case"select":return a.jsx(pmt,{node:e});default:return a.jsx(_pt,{nodeType:e.type})}}function Cpt({node:e}){return a.jsx("div",{className:Y("flex",e.direction==="horizontal"?"flex-row items-start":"flex-col",kpt[e.gap??"md"]),children:e.children.map((t,n)=>a.jsx(Ov,{node:t},n))})}function Ept({node:e}){const t=!!(e.title||e.description);return a.jsxs(LFe,{className:"shadow-soft",children:[t&&a.jsxs(FFe,{children:[e.title&&a.jsx(zFe,{children:e.title}),e.description&&a.jsx(BFe,{children:e.description})]}),a.jsx($Fe,{children:e.children.map((n,s)=>a.jsx(Ov,{node:n},s))}),e.footer&&e.footer.length>0&&a.jsx(HFe,{children:e.footer.map((n,s)=>a.jsx(Ov,{node:n},s))})]})}function Tpt({node:e}){const[t,n]=x.useState({}),s=x.useCallback((o,l)=>{n(c=>({...c,[o]:l}))},[]),r=x.useMemo(()=>({values:t,setValue:s}),[t,s]),i=x.useMemo(()=>({...e.submit.action,payload:{...e.submit.action.payload??{},...t}}),[e.submit.action,t]);return a.jsxs("form",{onSubmit:o=>o.preventDefault(),className:"flex flex-col gap-3",children:[a.jsx(Ght,{value:r,children:e.children.map((o,l)=>a.jsx(Ov,{node:o},l))}),a.jsx(g_,{action:i,label:e.submit.label,fullWidth:!0})]})}function _pt({nodeType:e}){return a.jsxs("div",{className:"text-muted-foreground rounded-md border border-dashed p-2 text-xs",children:["Unsupported widget element",e?`: ${e}`:""]})}function Ede({document:e,sessionId:t,isLatestMessage:n}){const s=hr();return a.jsx(qht,{sessionId:t,widgetTitle:e.title,isLatestMessage:n,children:a.jsx(te.section,{"aria-label":e.title??"Widget",className:"text-sm",variants:s?Zb:void 0,initial:s?"hidden":!1,animate:s?"visible":!1,children:a.jsx(Ov,{node:e.root})})})}function Tde(e,t){const n=wwe.safeParse(e);if(!n.success){const s=n.error.issues[0],r=(s==null?void 0:s.path.join("."))??"";return{ok:!1,error:s?`${r?`${r}: `:""}${s.message}`:"Invalid widget",raw:t??jpt(e)}}return{ok:!0,document:n.data}}function Npt(e){let t;try{t=JSON.parse(e)}catch(n){return{ok:!1,error:n instanceof Error?n.message:"Invalid JSON",raw:e}}return Tde(t,e)}function jpt(e){try{return JSON.stringify(e,null,2)??String(e)}catch{return String(e)}}function _de({error:e,raw:t}){const[n,s]=x.useState(!1);return a.jsx("div",{className:"bg-card text-card-foreground rounded-lg border p-3 text-sm",children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(fr,{className:"text-muted-foreground mt-0.5 size-4 shrink-0","aria-hidden":!0}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"font-medium",children:"This widget couldn't be rendered"}),a.jsx("p",{className:"text-muted-foreground mt-0.5 text-xs break-words",children:e}),a.jsxs("button",{type:"button",onClick:()=>s(r=>!r),"aria-expanded":n,className:"text-muted-foreground hover:text-foreground focus-visible:ring-ring mt-2 inline-flex items-center gap-1 rounded text-xs focus-visible:ring-2 focus-visible:outline-none",children:[a.jsx(Rs,{className:Y("size-3 transition-transform",n&&"rotate-90")}),n?"Hide":"Show"," raw JSON"]}),n&&a.jsx("pre",{className:"bg-muted text-muted-foreground mt-2 max-h-64 overflow-auto rounded-md p-2 text-xs",children:a.jsx("code",{children:t})})]})]})})}const Apt=1.6;function fp({className:e}){return a.jsx("div",{className:Y("bg-muted rounded-md",e)})}function Rpt(){const e=hr();return a.jsxs("div",{className:"bg-card shadow-soft relative flex flex-col gap-3 overflow-hidden rounded-lg border p-4","aria-busy":"true","aria-label":"Loading widget",children:[a.jsxs("div",{className:"flex items-center gap-2.5",children:[a.jsx(fp,{className:"size-8 rounded-lg"}),a.jsxs("div",{className:"flex flex-1 flex-col gap-1.5",children:[a.jsx(fp,{className:"h-3.5 w-1/3"}),a.jsx(fp,{className:"h-2.5 w-1/2"})]})]}),a.jsx(fp,{className:"h-2.5 w-full"}),a.jsx(fp,{className:"h-2.5 w-5/6"}),a.jsx(fp,{className:"h-16 w-full"}),e&&a.jsx(te.div,{"aria-hidden":!0,className:"pointer-events-none absolute inset-y-0 left-0 w-1/2 -skew-x-12 bg-gradient-to-r from-transparent via-white/50 to-transparent dark:via-white/[0.06]",initial:{x:"-150%"},animate:{x:"350%"},transition:{duration:Apt,ease:"linear",repeat:1/0,repeatDelay:.4}})]})}function Mpt({code:e,isIncomplete:t,sessionId:n,isLatestMessage:s}){const r=x.useRef(null);if(!t){const i=Npt(e);if(i.ok)r.current=i.document;else if(r.current===null)return a.jsx("div",{className:"my-2",children:a.jsx(_de,{error:i.error,raw:i.raw})})}return r.current?a.jsx("div",{className:"my-2",children:a.jsx(Ede,{document:r.current,sessionId:n,isLatestMessage:s})}):a.jsx("div",{className:"my-2",children:a.jsx(Rpt,{})})}function Dpt(e){return e.replace(/[-_]+/g," ").trim()}function Opt({action:e}){const t=hr(),n=Dpt(e.actionId),s=`Widget interaction${e.title?`, ${e.title}`:""}: ${n}`;return a.jsxs(te.span,{"data-testid":"ui-action-chip",title:e.payload?JSON.stringify(e.payload):void 0,className:Y("ml-auto inline-flex w-fit items-center gap-2 rounded-full border py-1 pr-3 pl-1.5","bg-muted/40 shadow-soft text-xs"),initial:t?{opacity:0,y:4,scale:.9}:!1,animate:t?{opacity:1,y:0,scale:1}:!1,transition:t?zi:void 0,children:[a.jsx("span",{className:"sr-only",children:s}),a.jsx("span",{"aria-hidden":!0,className:"bg-primary/10 text-primary flex size-5 shrink-0 items-center justify-center rounded-full",children:a.jsx(BMe,{className:"size-3"})}),a.jsxs("span",{"aria-hidden":!0,className:"text-muted-foreground truncate",children:[e.title&&a.jsx("span",{className:"text-foreground font-medium",children:e.title}),e.title&&a.jsx("span",{className:"px-1 opacity-50",children:"·"}),a.jsx("span",{className:"text-foreground font-medium",children:n})]})]})}const Ipt=/<ui_action>([\s\S]*?)<\/ui_action>/;function Dq(e){try{const t=JSON.parse(e);return t!==null&&typeof t=="object"?t:null}catch{return null}}function Ppt(e){const t=e.match(Ipt);if(!t)return null;const n=t[1].split(`
|
|
1268
|
-
`);let s=null,r=null,i=null,o=null;for(let l=0;l<n.length;l++){const c=n[l],u=c.match(/^\s*Widget:\s*(.*)$/);if(u){const g=u[1].trim();s=g&&g!=="(untitled)"?g:null;continue}const d=c.match(/^\s*Action:\s*(.*)$/);if(d){r=d[1].trim();continue}const f=c.match(/^\s*Widget ID:\s*(.*)$/);if(f){i=f[1].trim()||null;continue}const m=c.match(/^\s*Payload:\s*(.*)$/);if(m){const g=m[1].trim();g&&g!=="(none)"
|
|
1269
|
-
|
|
1268
|
+
`);let s=null,r=null,i=null,o=null;for(let l=0;l<n.length;l++){const c=n[l],u=c.match(/^\s*Widget:\s*(.*)$/);if(u){const g=u[1].trim();s=g&&g!=="(untitled)"?g:null;continue}const d=c.match(/^\s*Action:\s*(.*)$/);if(d){r=d[1].trim();continue}const f=c.match(/^\s*Widget ID:\s*(.*)$/);if(f){i=f[1].trim()||null;continue}const m=c.match(/^\s*Payload:\s*(.*)$/);if(m){const g=m[1].trim();if(g&&g!=="(none)")o=Dq(g);else if(!g){let y="";for(let b=l+1;b<n.length;b++){y+=(y?`
|
|
1269
|
+
`:"")+n[b];const S=Dq(y.trim());if(S){o=S;break}}}break}}return r?{title:s,actionId:r,widgetId:i,payload:o}:null}const Lpt=/^Please read the following uploaded file\(s\):\n((?:- .+\n)+)\n?/,Fpt=/^[a-f0-9]{8}-/,zpt=new Set(["png","jpg","jpeg","gif","webp","svg"]);function Bpt(e){const t=e.match(Lpt);if(!t)return{files:[],textContent:e};const s=t[1].split(`
|
|
1270
1270
|
`).filter(i=>i.startsWith("- ")).map(i=>{var d;const o=i.slice(2).trim(),c=(o.split("/").pop()??o).replace(Fpt,""),u=((d=c.split(".").pop())==null?void 0:d.toLowerCase())??"";return{path:o,displayName:c,isImage:zpt.has(u)}}),r=e.slice(t[0].length).trim();return{files:s,textContent:r}}function fk(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function $pt(e){const t=["Context compacted"];return(e==null?void 0:e.preTokens)!==void 0&&t.push(`${fk(e.preTokens)} tokens`),e!=null&&e.trigger&&t.push(e.trigger),t.join(" · ")}function Hpt(e){var n;switch(((n=e.split(".").pop())==null?void 0:n.toLowerCase())??""){case"txt":case"md":case"log":return Qg;case"ts":case"tsx":case"js":case"jsx":case"json":case"py":case"rs":case"go":return Jte;case"csv":case"xls":case"xlsx":return _Re;case"png":case"jpg":case"jpeg":case"gif":case"webp":case"svg":return ERe;default:return qh}}function Upt({files:e}){const t=we(n=>n.selectedCwd);return e.length===0?null:a.jsx("div",{className:"flex flex-wrap gap-1.5 pb-1.5",children:e.map(n=>{const s=n.path.split("/").pop()??n.path;if(n.isImage){const i=`/api/uploads/${encodeURIComponent(s)}?cwd=${encodeURIComponent(t??"")}`;return a.jsx(te.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.15},children:a.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:a.jsx("img",{src:i,alt:n.displayName,loading:"lazy",className:"border-border/50 max-h-[120px] max-w-[200px] cursor-pointer rounded-lg border object-contain transition-all duration-150 hover:brightness-95"})})},n.path)}const r=Hpt(n.displayName);return a.jsxs(te.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.15},className:"bg-muted flex items-center gap-1 rounded-md px-2 py-1 text-xs",children:[a.jsx(r,{className:"text-muted-foreground size-3 shrink-0"}),a.jsx("span",{className:"max-w-40 truncate",children:n.displayName})]},n.path)})})}const Vpt=e=>typeof e=="boolean"||e instanceof Boolean,qpt=e=>typeof e=="number"||e instanceof Number,Gpt=e=>typeof e=="bigint"||e instanceof BigInt,Nde=e=>!!e&&e instanceof Date,Kpt=e=>typeof e=="string"||e instanceof String,Wpt=e=>Array.isArray(e),jde=e=>typeof e=="object"&&e!==null,Ade=e=>!!e&&e instanceof Object&&typeof e=="function";function HC(e,t){return t===void 0&&(t=!1),!e||t?`"${e}"`:e}function Ypt(e,t,n){return n?JSON.stringify(e):t?`"${e}"`:e}function Rde(e){let{field:t,value:n,data:s,lastElement:r,openBracket:i,closeBracket:o,level:l,style:c,shouldExpandNode:u,clickToExpandNode:d,outerRef:f,beforeExpandChange:m}=e;const g=x.useRef(!1),[y,b]=x.useState(()=>u(l,n,t)),S=x.useRef(null);x.useEffect(()=>{g.current?b(u(l,n,t)):g.current=!0},[u]);const w=x.useId();if(s.length===0)return Zpt({field:t,openBracket:i,closeBracket:o,lastElement:r,style:c});const C=y?c.collapseIcon:c.expandIcon,T=y?c.ariaLables.collapseJson:c.ariaLables.expandJson,E=l+1,j=s.length-1,_=O=>{y!==O&&(!m||m({level:l,value:n,field:t,newExpandValue:O}))&&b(O)},N=O=>{if(O.key==="ArrowRight"||O.key==="ArrowLeft")O.preventDefault(),_(O.key==="ArrowRight");else if(O.key==="ArrowUp"||O.key==="ArrowDown"){O.preventDefault();const M=O.key==="ArrowUp"?-1:1;if(!f.current)return;const L=f.current.querySelectorAll("[role=button]");let P=-1;for(let q=0;q<L.length;q++)if(L[q].tabIndex===0){P=q;break}if(P<0)return;const $=(P+M+L.length)%L.length;L[P].tabIndex=-1,L[$].tabIndex=0,L[$].focus()}},R=()=>{var O;_(!y);const M=S.current;if(!M)return;const L=(O=f.current)===null||O===void 0?void 0:O.querySelector('[role=button][tabindex="0"]');L&&(L.tabIndex=-1),M.tabIndex=0,M.focus()};return x.createElement("div",{className:c.basicChildStyle,role:"treeitem","aria-expanded":y,"aria-selected":void 0},x.createElement("span",{className:C,onClick:R,onKeyDown:N,role:"button","aria-label":T,"aria-expanded":y,"aria-controls":y?w:void 0,ref:S,tabIndex:l===0?0:-1}),(t||t==="")&&(d?x.createElement("span",{className:c.clickableLabel,onClick:R,onKeyDown:N},HC(t,c.quotesForFieldNames),":"):x.createElement("span",{className:c.label},HC(t,c.quotesForFieldNames),":")),x.createElement("span",{className:c.punctuation},i),y?x.createElement("ul",{id:w,role:"group",className:c.childFieldsContainer},s.map((O,M)=>x.createElement(ZD,{key:O[0]||M,field:O[0],value:O[1],style:c,lastElement:M===j,level:E,shouldExpandNode:u,clickToExpandNode:d,beforeExpandChange:m,outerRef:f}))):x.createElement("span",{className:c.collapsedContent,onClick:R,onKeyDown:N}),x.createElement("span",{className:c.punctuation},o),!r&&x.createElement("span",{className:c.punctuation},","))}function Zpt(e){let{field:t,openBracket:n,closeBracket:s,lastElement:r,style:i}=e;return x.createElement("div",{className:i.basicChildStyle,role:"treeitem","aria-selected":void 0},(t||t==="")&&x.createElement("span",{className:i.label},HC(t,i.quotesForFieldNames),":"),x.createElement("span",{className:i.punctuation},n),x.createElement("span",{className:i.punctuation},s),!r&&x.createElement("span",{className:i.punctuation},","))}function Xpt(e){let{field:t,value:n,style:s,lastElement:r,shouldExpandNode:i,clickToExpandNode:o,level:l,outerRef:c,beforeExpandChange:u}=e;return Rde({field:t,value:n,lastElement:r||!1,level:l,openBracket:"{",closeBracket:"}",style:s,shouldExpandNode:i,clickToExpandNode:o,data:Object.keys(n).map(d=>[d,n[d]]),outerRef:c,beforeExpandChange:u})}function Qpt(e){let{field:t,value:n,style:s,lastElement:r,level:i,shouldExpandNode:o,clickToExpandNode:l,outerRef:c,beforeExpandChange:u}=e;return Rde({field:t,value:n,lastElement:r||!1,level:i,openBracket:"[",closeBracket:"]",style:s,shouldExpandNode:o,clickToExpandNode:l,data:n.map(d=>[void 0,d]),outerRef:c,beforeExpandChange:u})}function Jpt(e){let{field:t,value:n,style:s,lastElement:r}=e,i,o=s.otherValue;return n===null?(i="null",o=s.nullValue):n===void 0?(i="undefined",o=s.undefinedValue):Kpt(n)?(i=Ypt(n,!s.noQuotesForStringValues,s.stringifyStringValues),o=s.stringValue):Vpt(n)?(i=n?"true":"false",o=s.booleanValue):qpt(n)?(i=n.toString(),o=s.numberValue):Gpt(n)?(i=`${n.toString()}n`,o=s.numberValue):Nde(n)?i=n.toISOString():Ade(n)?i="function() { }":i=n.toString(),x.createElement("div",{className:s.basicChildStyle,role:"treeitem","aria-selected":void 0},(t||t==="")&&x.createElement("span",{className:s.label},HC(t,s.quotesForFieldNames),":"),x.createElement("span",{className:o},i),!r&&x.createElement("span",{className:s.punctuation},","))}function ZD(e){const t=e.value;return Wpt(t)?x.createElement(Qpt,Object.assign({},e)):jde(t)&&!Nde(t)&&!Ade(t)?x.createElement(Xpt,Object.assign({},e)):x.createElement(Jpt,Object.assign({},e))}var Fn={"container-light":"_2IvMF _GzYRV","basic-element-style":"_2bkNM","child-fields-container":"_1BXBN","label-light":"_1MGIk","clickable-label-light":"_2YKJg _1MGIk _1MFti","punctuation-light":"_3uHL6 _3eOF8","value-null-light":"_2T6PJ","value-undefined-light":"_1Gho6","value-string-light":"_vGjyY","value-number-light":"_1bQdo","value-boolean-light":"_3zQKs","value-other-light":"_1xvuR","collapse-icon-light":"_oLqym _f10Tu _1MFti _1LId0","expand-icon-light":"_2AXVT _f10Tu _1MFti _1UmXx","collapsed-content-light":"_2KJWg _1pNG9 _1MFti","container-dark":"_11RoI _GzYRV","expand-icon-dark":"_17H2C _f10Tu _1MFti _1UmXx","collapse-icon-dark":"_3QHg2 _f10Tu _1MFti _1LId0","collapsed-content-dark":"_3fDAz _1pNG9 _1MFti","label-dark":"_2bSDX","clickable-label-dark":"_1RQEj _2bSDX _1MFti","punctuation-dark":"_gsbQL _3eOF8","value-null-dark":"_LaAZe","value-undefined-dark":"_GTKgm","value-string-dark":"_Chy1W","value-number-dark":"_2bveF","value-boolean-dark":"_2vRm-","value-other-dark":"_1prJR"};const Mde={collapseJson:"collapse JSON",expandJson:"expand JSON"},xR={container:Fn["container-light"],basicChildStyle:Fn["basic-element-style"],childFieldsContainer:Fn["child-fields-container"],label:Fn["label-light"],clickableLabel:Fn["clickable-label-light"],nullValue:Fn["value-null-light"],undefinedValue:Fn["value-undefined-light"],stringValue:Fn["value-string-light"],booleanValue:Fn["value-boolean-light"],numberValue:Fn["value-number-light"],otherValue:Fn["value-other-light"],punctuation:Fn["punctuation-light"],collapseIcon:Fn["collapse-icon-light"],expandIcon:Fn["expand-icon-light"],collapsedContent:Fn["collapsed-content-light"],noQuotesForStringValues:!1,quotesForFieldNames:!1,ariaLables:Mde,stringifyStringValues:!1},egt={container:Fn["container-dark"],basicChildStyle:Fn["basic-element-style"],childFieldsContainer:Fn["child-fields-container"],label:Fn["label-dark"],clickableLabel:Fn["clickable-label-dark"],nullValue:Fn["value-null-dark"],undefinedValue:Fn["value-undefined-dark"],stringValue:Fn["value-string-dark"],booleanValue:Fn["value-boolean-dark"],numberValue:Fn["value-number-dark"],otherValue:Fn["value-other-dark"],punctuation:Fn["punctuation-dark"],collapseIcon:Fn["collapse-icon-dark"],expandIcon:Fn["expand-icon-dark"],collapsedContent:Fn["collapsed-content-dark"],noQuotesForStringValues:!1,quotesForFieldNames:!1,ariaLables:Mde,stringifyStringValues:!1},tgt=()=>!0,ngt=e=>e<1,sgt=e=>{let{data:t,style:n=xR,shouldExpandNode:s=tgt,clickToExpandNode:r=!1,beforeExpandChange:i,compactTopLevel:o,...l}=e;const c=x.useRef(null);return x.createElement("div",Object.assign({"aria-label":"JSON view"},l,{className:n.container,ref:c,role:"tree"}),o&&jde(t)?Object.entries(t).map(u=>{let[d,f]=u;return x.createElement(ZD,{key:d,field:d,value:f,style:{...xR,...n},lastElement:!0,level:1,shouldExpandNode:s,clickToExpandNode:r,beforeExpandChange:i,outerRef:c})}):x.createElement(ZD,{value:t,style:{...xR,...n},lastElement:!0,level:0,shouldExpandNode:s,clickToExpandNode:r,outerRef:c,beforeExpandChange:i}))};var Da={},yR,Oq;function rgt(){if(Oq)return yR;Oq=1;const e=[[{color:"0, 0, 0",class:"ansi-black"},{color:"187, 0, 0",class:"ansi-red"},{color:"0, 187, 0",class:"ansi-green"},{color:"187, 187, 0",class:"ansi-yellow"},{color:"0, 0, 187",class:"ansi-blue"},{color:"187, 0, 187",class:"ansi-magenta"},{color:"0, 187, 187",class:"ansi-cyan"},{color:"255,255,255",class:"ansi-white"}],[{color:"85, 85, 85",class:"ansi-bright-black"},{color:"255, 85, 85",class:"ansi-bright-red"},{color:"0, 255, 0",class:"ansi-bright-green"},{color:"255, 255, 85",class:"ansi-bright-yellow"},{color:"85, 85, 255",class:"ansi-bright-blue"},{color:"255, 85, 255",class:"ansi-bright-magenta"},{color:"85, 255, 255",class:"ansi-bright-cyan"},{color:"255, 255, 255",class:"ansi-bright-white"}]],t=/(https?:\/\/(?:[A-Za-z0-9#;/?:@=+$',_.!~*()[\]-]|&|%[A-Fa-f0-9]{2})+)/gm;class n{static escapeForHtml(r){return new n().escapeForHtml(r)}static linkify(r){return new n().linkify(r)}static ansiToHtml(r,i){return new n().ansiToHtml(r,i)}static ansiToJson(r,i){return new n().ansiToJson(r,i)}static ansiToText(r){return new n().ansiToText(r)}constructor(){this.fg=this.bg=this.fg_truecolor=this.bg_truecolor=null,this.bright=0,this.decorations=[]}setupPalette(){this.PALETTE_COLORS=[];for(let l=0;l<2;++l)for(let c=0;c<8;++c)this.PALETTE_COLORS.push(e[l][c].color);let r=[0,95,135,175,215,255],i=(l,c,u)=>r[l]+", "+r[c]+", "+r[u];for(let l=0;l<6;++l)for(let c=0;c<6;++c)for(let u=0;u<6;++u)this.PALETTE_COLORS.push(i(l,c,u));let o=8;for(let l=0;l<24;++l,o+=10)this.PALETTE_COLORS.push(o+", "+o+", "+o)}escapeForHtml(r){return r.replace(/[&<>\"]/gm,i=>i=="&"?"&":i=='"'?""":i=="<"?"<":i==">"?">":"")}linkify(r){return r.replace(t,i=>`<a href="${i}">${i}</a>`)}ansiToHtml(r,i){return this.process(r,i,!0)}ansiToJson(r,i){return i=i||{},i.json=!0,i.clearLine=!1,this.process(r,i,!0)}ansiToText(r){return this.process(r,{},!1)}process(r,i,o){let l=this,c=r.split(/\033\[/),u=c.shift();i==null&&(i={}),i.clearLine=/\r/.test(r);let d=c.map(f=>this.processChunk(f,i,o));if(i&&i.json){let f=l.processChunkJson("");return f.content=u,f.clearLine=i.clearLine,d.unshift(f),i.remove_empty&&(d=d.filter(m=>!m.isEmpty())),d}else d.unshift(u);return d.join("")}processChunkJson(r,i,o){i=typeof i>"u"?{}:i;let l=i.use_classes=typeof i.use_classes<"u"&&i.use_classes,c=i.key=l?"class":"color",u={content:r,fg:null,bg:null,fg_truecolor:null,bg_truecolor:null,isInverted:!1,clearLine:i.clearLine,decoration:null,decorations:[],was_processed:!1,isEmpty:()=>!u.content},d=r.match(/^([!\x3c-\x3f]*)([\d;]*)([\x20-\x2c]*[\x40-\x7e])([\s\S]*)/m);if(!d)return u;u.content=d[4];let f=d[2].split(";");if(d[1]!==""||d[3]!=="m"||!o)return u;let m=this;for(;f.length>0;){let g=f.shift(),y=parseInt(g);if(isNaN(y)||y===0)m.fg=m.bg=null,m.decorations=[];else if(y===1)m.decorations.push("bold");else if(y===2)m.decorations.push("dim");else if(y===3)m.decorations.push("italic");else if(y===4)m.decorations.push("underline");else if(y===5)m.decorations.push("blink");else if(y===7)m.decorations.push("reverse");else if(y===8)m.decorations.push("hidden");else if(y===9)m.decorations.push("strikethrough");else if(y===21)m.removeDecoration("bold");else if(y===22)m.removeDecoration("bold"),m.removeDecoration("dim");else if(y===23)m.removeDecoration("italic");else if(y===24)m.removeDecoration("underline");else if(y===25)m.removeDecoration("blink");else if(y===27)m.removeDecoration("reverse");else if(y===28)m.removeDecoration("hidden");else if(y===29)m.removeDecoration("strikethrough");else if(y===39)m.fg=null;else if(y===49)m.bg=null;else if(y>=30&&y<38)m.fg=e[0][y%10][c];else if(y>=90&&y<98)m.fg=e[1][y%10][c];else if(y>=40&&y<48)m.bg=e[0][y%10][c];else if(y>=100&&y<108)m.bg=e[1][y%10][c];else if(y===38||y===48){let b=y===38;if(f.length>=1){let S=f.shift();if(S==="5"&&f.length>=1){let w=parseInt(f.shift());if(w>=0&&w<=255)if(!l)this.PALETTE_COLORS||m.setupPalette(),b?m.fg=this.PALETTE_COLORS[w]:m.bg=this.PALETTE_COLORS[w];else{let C=w>=16?"ansi-palette-"+w:e[w>7?1:0][w%8].class;b?m.fg=C:m.bg=C}}else if(S==="2"&&f.length>=3){let w=parseInt(f.shift()),C=parseInt(f.shift()),T=parseInt(f.shift());if(w>=0&&w<=255&&C>=0&&C<=255&&T>=0&&T<=255){let E=w+", "+C+", "+T;l?b?(m.fg="ansi-truecolor",m.fg_truecolor=E):(m.bg="ansi-truecolor",m.bg_truecolor=E):b?m.fg=E:m.bg=E}}}}}return m.fg===null&&m.bg===null&&m.decorations.length===0||(u.fg=m.fg,u.bg=m.bg,u.fg_truecolor=m.fg_truecolor,u.bg_truecolor=m.bg_truecolor,u.decorations=m.decorations,u.decoration=m.decorations.slice(-1).pop()||null,u.was_processed=!0),u}processChunk(r,i,o){i=i||{};let l=this.processChunkJson(r,i,o),c=i.use_classes;if(l.decorations=l.decorations.filter(y=>{if(y==="reverse"){l.fg||(l.fg=e[0][7][c?"class":"color"]),l.bg||(l.bg=e[0][0][c?"class":"color"]);let b=l.fg;l.fg=l.bg,l.bg=b;let S=l.fg_truecolor;return l.fg_truecolor=l.bg_truecolor,l.bg_truecolor=S,l.isInverted=!0,!1}return!0}),i.json)return l;if(l.isEmpty())return"";if(!l.was_processed)return l.content;let u=[],d=[],f=[],m={},g=y=>{let b=[],S;for(S in y)y.hasOwnProperty(S)&&b.push("data-"+S+'="'+this.escapeForHtml(y[S])+'"');return b.length>0?" "+b.join(" "):""};return l.isInverted&&(m["ansi-is-inverted"]="true"),l.fg&&(c?(u.push(l.fg+"-fg"),l.fg_truecolor!==null&&(m["ansi-truecolor-fg"]=l.fg_truecolor,l.fg_truecolor=null)):u.push("color:rgb("+l.fg+")")),l.bg&&(c?(u.push(l.bg+"-bg"),l.bg_truecolor!==null&&(m["ansi-truecolor-bg"]=l.bg_truecolor,l.bg_truecolor=null)):u.push("background-color:rgb("+l.bg+")")),l.decorations.forEach(y=>{if(c){d.push("ansi-"+y);return}y==="bold"?d.push("font-weight:bold"):y==="dim"?d.push("opacity:0.5"):y==="italic"?d.push("font-style:italic"):y==="hidden"?d.push("visibility:hidden"):y==="strikethrough"?f.push("line-through"):f.push(y)}),f.length&&d.push("text-decoration:"+f.join(" ")),c?'<span class="'+u.concat(d).join(" ")+'"'+g(m)+">"+l.content+"</span>":'<span style="'+u.concat(d).join(";")+'"'+g(m)+">"+l.content+"</span>"}removeDecoration(r){const i=this.decorations.indexOf(r);i>=0&&this.decorations.splice(i,1)}}return yR=n,yR}var Jx={exports:{}},Iq;function igt(){if(Iq)return Jx.exports;Iq=1;function e(r){if(!r)return"";if(!/\r/.test(r))return r;for(r=r.replace(/\r+\n/gm,`
|
|
1271
1271
|
`);/\r./.test(r);)r=r.replace(/^([^\r\n]*)\r+([^\r\n]+)/gm,function(i,o,l){return l+o.slice(l.length)});return r}function t(r){for(var i=0,o=0;o<r.length;o++)r[i].length<=r[o].length&&(i=o);return i}function n(r){if(!/\r/.test(r))return r;for(var i=r.split("\r"),o=[];i.length>0;){var l=t(i);o.push(i[l]),i=i.slice(l+1)}return o.join("\r")}function s(r){if(!r)return"";if(!/\r/.test(r))return r;if(!/\n/.test(r))return n(r);r=r.replace(/\r+\n/gm,`
|
|
1272
1272
|
`);var i=r.lastIndexOf(`
|
|
1273
1273
|
`);return e(r.slice(0,i))+`
|
|
1274
|
-
`+n(r.slice(i+1))}return Jx.exports=e,Jx.exports.escapeCarriageReturn=e,Jx.exports.escapeCarriageReturnSafe=s,Jx.exports}var vR,Pq;function agt(){return Pq||(Pq=1,vR=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/),vR}var bR,Lq;function ogt(){return Lq||(Lq=1,bR=/[\0-\x1F\x7F-\x9F]/),bR}var SR,Fq;function lgt(){return Fq||(Fq=1,SR=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/),SR}var wR,zq;function cgt(){return zq||(zq=1,wR=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4E\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDF55-\uDF59]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD806[\uDC3B\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/),wR}var kR,Bq;function ugt(){return Bq||(Bq=1,kR=function(e){var t={};t.src_Any=agt().source,t.src_Cc=ogt().source,t.src_Z=lgt().source,t.src_P=cgt().source,t.src_ZPCc=[t.src_Z,t.src_P,t.src_Cc].join("|"),t.src_ZCc=[t.src_Z,t.src_Cc].join("|");var n="[><|]";return t.src_pseudo_letter="(?:(?!"+n+"|"+t.src_ZPCc+")"+t.src_Any+")",t.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",t.src_auth="(?:(?:(?!"+t.src_ZCc+"|[@/\\[\\]()]).)+@)?",t.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",t.src_host_terminator="(?=$|"+n+"|"+t.src_ZPCc+")(?!-|_|:\\d|\\.-|\\.(?!$|"+t.src_ZPCc+"))",t.src_path="(?:[/?#](?:(?!"+t.src_ZCc+"|"+n+`|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!`+t.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+t.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+t.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+t.src_ZCc+`|["]).)+\\"|\\'(?:(?!`+t.src_ZCc+"|[']).)+\\'|\\'(?="+t.src_pseudo_letter+"|[-]).|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!"+t.src_ZCc+"|[.]).|"+(e&&e["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+t.src_ZCc+").|;(?!"+t.src_ZCc+").|\\!+(?!"+t.src_ZCc+"|[!]).|\\?(?!"+t.src_ZCc+"|[?]).)+|\\/)?",t.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',t.src_xn="xn--[a-z0-9\\-]{1,59}",t.src_domain_root="(?:"+t.src_xn+"|"+t.src_pseudo_letter+"{1,63})",t.src_domain="(?:"+t.src_xn+"|(?:"+t.src_pseudo_letter+")|(?:"+t.src_pseudo_letter+"(?:-|"+t.src_pseudo_letter+"){0,61}"+t.src_pseudo_letter+"))",t.src_host="(?:(?:(?:(?:"+t.src_domain+")\\.)*"+t.src_domain+"))",t.tpl_host_fuzzy="(?:"+t.src_ip4+"|(?:(?:(?:"+t.src_domain+")\\.)+(?:%TLDS%)))",t.tpl_host_no_ip_fuzzy="(?:(?:(?:"+t.src_domain+")\\.)+(?:%TLDS%))",t.src_host_strict=t.src_host+t.src_host_terminator,t.tpl_host_fuzzy_strict=t.tpl_host_fuzzy+t.src_host_terminator,t.src_host_port_strict=t.src_host+t.src_port+t.src_host_terminator,t.tpl_host_port_fuzzy_strict=t.tpl_host_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_port_no_ip_fuzzy_strict=t.tpl_host_no_ip_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+t.src_ZPCc+"|>|$))",t.tpl_email_fuzzy="(^|"+n+'|"|\\(|'+t.src_ZCc+")("+t.src_email_name+"@"+t.tpl_host_fuzzy_strict+")",t.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_fuzzy_strict+t.src_path+")",t.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_no_ip_fuzzy_strict+t.src_path+")",t}),kR}var CR,$q;function dgt(){if($q)return CR;$q=1;function e(T){var E=Array.prototype.slice.call(arguments,1);return E.forEach(function(j){j&&Object.keys(j).forEach(function(_){T[_]=j[_]})}),T}function t(T){return Object.prototype.toString.call(T)}function n(T){return t(T)==="[object String]"}function s(T){return t(T)==="[object Object]"}function r(T){return t(T)==="[object RegExp]"}function i(T){return t(T)==="[object Function]"}function o(T){return T.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}var l={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function c(T){return Object.keys(T||{}).reduce(function(E,j){return E||l.hasOwnProperty(j)},!1)}var u={"http:":{validate:function(T,E,j){var _=T.slice(E);return j.re.http||(j.re.http=new RegExp("^\\/\\/"+j.re.src_auth+j.re.src_host_port_strict+j.re.src_path,"i")),j.re.http.test(_)?_.match(j.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(T,E,j){var _=T.slice(E);return j.re.no_http||(j.re.no_http=new RegExp("^"+j.re.src_auth+"(?:localhost|(?:(?:"+j.re.src_domain+")\\.)+"+j.re.src_domain_root+")"+j.re.src_port+j.re.src_host_terminator+j.re.src_path,"i")),j.re.no_http.test(_)?E>=3&&T[E-3]===":"||E>=3&&T[E-3]==="/"?0:_.match(j.re.no_http)[0].length:0}},"mailto:":{validate:function(T,E,j){var _=T.slice(E);return j.re.mailto||(j.re.mailto=new RegExp("^"+j.re.src_email_name+"@"+j.re.src_host_strict,"i")),j.re.mailto.test(_)?_.match(j.re.mailto)[0].length:0}}},d="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",f="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function m(T){T.__index__=-1,T.__text_cache__=""}function g(T){return function(E,j){var _=E.slice(j);return T.test(_)?_.match(T)[0].length:0}}function y(){return function(T,E){E.normalize(T)}}function b(T){var E=T.re=ugt()(T.__opts__),j=T.__tlds__.slice();T.onCompile(),T.__tlds_replaced__||j.push(d),j.push(E.src_xn),E.src_tlds=j.join("|");function _(M){return M.replace("%TLDS%",E.src_tlds)}E.email_fuzzy=RegExp(_(E.tpl_email_fuzzy),"i"),E.link_fuzzy=RegExp(_(E.tpl_link_fuzzy),"i"),E.link_no_ip_fuzzy=RegExp(_(E.tpl_link_no_ip_fuzzy),"i"),E.host_fuzzy_test=RegExp(_(E.tpl_host_fuzzy_test),"i");var N=[];T.__compiled__={};function R(M,L){throw new Error('(LinkifyIt) Invalid schema "'+M+'": '+L)}Object.keys(T.__schemas__).forEach(function(M){var L=T.__schemas__[M];if(L!==null){var P={validate:null,link:null};if(T.__compiled__[M]=P,s(L)){r(L.validate)?P.validate=g(L.validate):i(L.validate)?P.validate=L.validate:R(M,L),i(L.normalize)?P.normalize=L.normalize:L.normalize?R(M,L):P.normalize=y();return}if(n(L)){N.push(M);return}R(M,L)}}),N.forEach(function(M){T.__compiled__[T.__schemas__[M]]&&(T.__compiled__[M].validate=T.__compiled__[T.__schemas__[M]].validate,T.__compiled__[M].normalize=T.__compiled__[T.__schemas__[M]].normalize)}),T.__compiled__[""]={validate:null,normalize:y()};var O=Object.keys(T.__compiled__).filter(function(M){return M.length>0&&T.__compiled__[M]}).map(o).join("|");T.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+E.src_ZPCc+"))("+O+")","i"),T.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+E.src_ZPCc+"))("+O+")","ig"),T.re.pretest=RegExp("("+T.re.schema_test.source+")|("+T.re.host_fuzzy_test.source+")|@","i"),m(T)}function S(T,E){var j=T.__index__,_=T.__last_index__,N=T.__text_cache__.slice(j,_);this.schema=T.__schema__.toLowerCase(),this.index=j+E,this.lastIndex=_+E,this.raw=N,this.text=N,this.url=N}function w(T,E){var j=new S(T,E);return T.__compiled__[j.schema].normalize(j,T),j}function C(T,E){if(!(this instanceof C))return new C(T,E);E||c(T)&&(E=T,T={}),this.__opts__=e({},l,E),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=e({},u,T),this.__compiled__={},this.__tlds__=f,this.__tlds_replaced__=!1,this.re={},b(this)}return C.prototype.add=function(E,j){return this.__schemas__[E]=j,b(this),this},C.prototype.set=function(E){return this.__opts__=e(this.__opts__,E),this},C.prototype.test=function(E){if(this.__text_cache__=E,this.__index__=-1,!E.length)return!1;var j,_,N,R,O,M,L,P,$;if(this.re.schema_test.test(E)){for(L=this.re.schema_search,L.lastIndex=0;(j=L.exec(E))!==null;)if(R=this.testSchemaAt(E,j[2],L.lastIndex),R){this.__schema__=j[2],this.__index__=j.index+j[1].length,this.__last_index__=j.index+j[0].length+R;break}}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(P=E.search(this.re.host_fuzzy_test),P>=0&&(this.__index__<0||P<this.__index__)&&(_=E.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))!==null&&(O=_.index+_[1].length,(this.__index__<0||O<this.__index__)&&(this.__schema__="",this.__index__=O,this.__last_index__=_.index+_[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&($=E.indexOf("@"),$>=0&&(N=E.match(this.re.email_fuzzy))!==null&&(O=N.index+N[1].length,M=N.index+N[0].length,(this.__index__<0||O<this.__index__||O===this.__index__&&M>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=O,this.__last_index__=M))),this.__index__>=0},C.prototype.pretest=function(E){return this.re.pretest.test(E)},C.prototype.testSchemaAt=function(E,j,_){return this.__compiled__[j.toLowerCase()]?this.__compiled__[j.toLowerCase()].validate(E,_,this):0},C.prototype.match=function(E){var j=0,_=[];this.__index__>=0&&this.__text_cache__===E&&(_.push(w(this,j)),j=this.__last_index__);for(var N=j?E.slice(j):E;this.test(N);)_.push(w(this,j)),N=N.slice(this.__last_index__),j+=this.__last_index__;return _.length?_:null},C.prototype.tlds=function(E,j){return E=Array.isArray(E)?E:[E],j?(this.__tlds__=this.__tlds__.concat(E).sort().filter(function(_,N,R){return _!==R[N-1]}).reverse(),b(this),this):(this.__tlds__=E.slice(),this.__tlds_replaced__=!0,b(this),this)},C.prototype.normalize=function(E){E.schema||(E.url="http://"+E.url),E.schema==="mailto:"&&!/^mailto:/i.test(E.url)&&(E.url="mailto:"+E.url)},C.prototype.onCompile=function(){},CR=C,CR}var Hq;function fgt(){if(Hq)return Da;Hq=1;var e=Da&&Da.__createBinding||(Object.create?(function(S,w,C,T){T===void 0&&(T=C);var E=Object.getOwnPropertyDescriptor(w,C);(!E||("get"in E?!w.__esModule:E.writable||E.configurable))&&(E={enumerable:!0,get:function(){return w[C]}}),Object.defineProperty(S,T,E)}):(function(S,w,C,T){T===void 0&&(T=C),S[T]=w[C]})),t=Da&&Da.__setModuleDefault||(Object.create?(function(S,w){Object.defineProperty(S,"default",{enumerable:!0,value:w})}):function(S,w){S.default=w}),n=Da&&Da.__importStar||(function(){var S=function(w){return S=Object.getOwnPropertyNames||function(C){var T=[];for(var E in C)Object.prototype.hasOwnProperty.call(C,E)&&(T[T.length]=E);return T},S(w)};return function(w){if(w&&w.__esModule)return w;var C={};if(w!=null)for(var T=S(w),E=0;E<T.length;E++)T[E]!=="default"&&e(C,w,T[E]);return t(C,w),C}})(),s=Da&&Da.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(Da,"__esModule",{value:!0}),Da.default=y;const r=s(rgt()),i=igt(),o=s(dgt()),l=n(Lg());function c(S,w=!1){return S=(0,i.escapeCarriageReturn)(b(S)),r.default.ansiToJson(S,{json:!0,remove_empty:!0,use_classes:w})}function u(S){let w="";return S.bg&&(w+=`${S.bg}-bg `),S.fg&&(w+=`${S.fg}-fg `),S.decoration&&(w+=`ansi-${S.decoration} `),w===""?null:(w=w.substring(0,w.length-1),w)}function d(S){const w={};switch(S.bg&&(w.backgroundColor=`rgb(${S.bg})`),S.fg&&(w.color=`rgb(${S.fg})`),S.decoration){case"bold":w.fontWeight="bold";break;case"dim":w.opacity="0.5";break;case"italic":w.fontStyle="italic";break;case"hidden":w.visibility="hidden";break;case"strikethrough":w.textDecoration="line-through";break;case"underline":w.textDecoration="underline";break;case"blink":w.textDecoration="blink";break}return w}function f(S,w,C,T){const E=w?null:d(C),j=w?u(C):null;return S?S==="fuzzy"?g(C,T,E,j):m(C,T,E,j):l.createElement("span",{style:E,key:T,className:j},C.content)}function m(S,w,C,T){const E=[],j=/(\s|^)(https?:\/\/(?:www\.|(?!www))[^\s.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/g;let _=0,N;for(;(N=j.exec(S.content))!==null;){const[,R,O]=N,M=N.index+R.length;M>_&&E.push(S.content.substring(_,M));const L=O.startsWith("www.")?`http://${O}`:O;E.push(l.createElement("a",{key:_,href:L,target:"_blank"},`${O}`)),_=j.lastIndex}return _<S.content.length&&E.push(S.content.substring(_)),l.createElement("span",{style:C,key:w,className:T},E)}function g(S,w,C,T){var E;const j=(0,o.default)({fuzzyEmail:!1}).tlds(["io"],!0);if(!j.pretest(S.content))return l.createElement("span",{style:C,key:w,className:T},S.content);const _=j.match(S.content);if(!_)return l.createElement("span",{style:C,key:w,className:T},S.content);const N=[S.content.substring(0,(E=_[0])===null||E===void 0?void 0:E.index)];return _.forEach((R,O)=>{var M;N.push(l.createElement("a",{href:R.url,target:"_blank",key:O},S.content.substring(R.index,R.lastIndex))),_[O+1]&&N.push(S.content.substring(_[O].lastIndex,(M=_[O+1])===null||M===void 0?void 0:M.index))}),_[_.length-1].lastIndex!==S.content.length&&N.push(S.content.substring(_[_.length-1].lastIndex,S.content.length)),l.createElement("span",{style:C,key:w,className:T},N)}function y(S){const{className:w,useClasses:C,children:T,linkify:E}=S;return l.createElement("code",{className:w},c(T??"",C??!1).map(f.bind(null,E??!1,C??!1)))}function b(S){let w=S;do S=w,w=S.replace(/[^\n]\x08/gm,"");while(w.length<S.length);return S}return Da}var hgt=fgt();const mgt=hl(hgt),pgt=x.lazy(()=>ks(()=>import("./index-BaGiFKrR.js"),[])),ggt={...egt,container:"bg-transparent text-xs font-mono leading-relaxed",label:"text-muted-foreground font-medium mr-1",clickableLabel:"text-muted-foreground font-medium mr-1 cursor-pointer",nullValue:"text-muted-foreground italic",undefinedValue:"text-muted-foreground italic",stringValue:"text-foreground",booleanValue:"text-amber-400",numberValue:"text-blue-400",otherValue:"text-muted-foreground",punctuation:"text-muted-foreground",collapseIcon:"text-muted-foreground",expandIcon:"text-muted-foreground",collapsedContent:"text-muted-foreground"},Uq=5120;function xgt(e){try{const t=JSON.parse(e);return typeof t=="object"&&t!==null&&("old_string"in t||"new_string"in t)?t:null}catch{return null}}function ER({children:e,rawContent:t,supportsRawToggle:n,isRaw:s,onToggleRaw:r}){const[i,o]=x.useState(!1),l=t.length>Uq,c=l&&!i?t.slice(0,Uq):t;return a.jsxs("div",{className:"space-y-1",children:[n&&a.jsx("div",{className:"flex justify-end",children:a.jsx("button",{onClick:r,className:"text-muted-foreground hover:text-foreground text-xs underline",children:s?"Formatted":"Raw"})}),s?a.jsxs(a.Fragment,{children:[a.jsx("pre",{className:"max-h-64 overflow-y-auto text-xs whitespace-pre-wrap",children:c}),l&&!i&&a.jsxs("button",{onClick:()=>o(!0),className:"text-muted-foreground hover:text-foreground text-xs underline",children:["Show full output (",(t.length/1024).toFixed(1),"KB)"]})]}):e]})}function ygt({oldValue:e,newValue:t,rawContent:n}){return a.jsx(x.Suspense,{fallback:a.jsx("pre",{className:"max-h-64 overflow-y-auto text-xs whitespace-pre-wrap",children:n}),children:a.jsx(pgt,{oldValue:e,newValue:t,splitView:!1,useDarkTheme:!0,hideLineNumbers:!0,showDiffOnly:!0,extraLinesSurroundingDiff:2,styles:{variables:{dark:{diffViewerBackground:"transparent",addedBackground:"rgba(34, 197, 94, 0.1)",addedColor:"rgb(134, 239, 172)",addedGutterBackground:"rgba(34, 197, 94, 0.08)",wordAddedBackground:"rgba(34, 197, 94, 0.2)",removedBackground:"rgba(239, 68, 68, 0.1)",removedColor:"rgb(252, 165, 165)",removedGutterBackground:"rgba(239, 68, 68, 0.08)",wordRemovedBackground:"rgba(239, 68, 68, 0.2)",gutterBackground:"hsl(0 0% 9%)",gutterBackgroundDark:"hsl(0 0% 7%)",gutterColor:"hsl(0 0% 40%)"}}}})})}function Dde({content:e,toolName:t,input:n}){const[s,r]=x.useState(!1);if(t==="Edit"&&n){const o=xgt(n);if(o)return a.jsx(ygt,{oldValue:o.old_string??"",newValue:o.new_string??"",rawContent:e})}const i=ROe(e);if(i==="json"){let o;try{o=JSON.parse(e)}catch{o={}}return a.jsx(ER,{rawContent:e,supportsRawToggle:!0,isRaw:s,onToggleRaw:()=>r(l=>!l),children:a.jsx(sgt,{data:o,style:ggt,shouldExpandNode:ngt})})}return i==="ansi"?a.jsx(ER,{rawContent:e,supportsRawToggle:!0,isRaw:s,onToggleRaw:()=>r(o=>!o),children:a.jsx("pre",{className:"max-h-64 overflow-y-auto text-xs whitespace-pre-wrap",children:a.jsx(mgt,{children:e})})}):a.jsx(ER,{rawContent:e,supportsRawToggle:!1,isRaw:!0,onToggleRaw:()=>{},children:null})}function vgt({message:e}){const[t,n]=x.useState(!1),s=x.useMemo(()=>Bpt(e.content),[e.content]),r=x.useMemo(()=>Ppt(e.content),[e.content]);return r?a.jsx(Opt,{action:r}):e.messageType==="command"?a.jsx("div",{className:"text-msg-command-fg truncate font-mono text-sm",children:e.content}):e.messageType==="local_command_output"?a.jsx(Dde,{content:e.content,toolName:""}):e.messageType==="compaction"?a.jsxs("div",{className:"w-full",children:[a.jsxs("button",{onClick:()=>n(!t),className:"text-msg-compaction-fg flex w-full items-center gap-2 text-xs",children:[a.jsx("div",{className:"bg-border/40 h-px flex-1"}),a.jsx(Rs,{className:Y("size-3 transition-transform duration-200",t&&"rotate-90")}),a.jsx("span",{children:$pt(e.compactMetadata)}),a.jsx("div",{className:"bg-border/40 h-px flex-1"})]}),t&&a.jsx("div",{className:"text-msg-compaction-fg mt-2 text-xs whitespace-pre-wrap",children:e.content})]}):a.jsxs("div",{children:[s.files.length>0&&a.jsx(Upt,{files:s.files}),s.textContent&&a.jsx("div",{className:"break-words whitespace-pre-wrap",children:s.textContent})]})}const bgt={enabled:!0,renderModal:e=>a.jsx(TT,{...e})};function Sgt({content:e,isStreaming:t=!1,textEffect:n=Vwe,sessionId:s,isLatestMessage:r}){const i=Gwe(n),o=x.useMemo(()=>({renderers:[{language:"dorkos-ui",component:l=>a.jsx(Mpt,{...l,sessionId:s,isLatestMessage:r})}]}),[s,r]);return a.jsx("div",{className:Y("relative",t&&"streaming-cursor"),children:a.jsx(J4,{shikiTheme:["github-light","github-dark"],linkSafety:bgt,animated:i,isAnimating:t,plugins:o,children:e})})}function Ode(e){switch(e){case"pending":case"running":return a.jsx(Sn,{className:Y("size-(--size-icon-xs) animate-spin",pR({status:e}))});case"complete":return a.jsx(Lt,{className:Y("size-(--size-icon-xs)",pR({status:e}))});case"error":return a.jsx(es,{className:Y("size-(--size-icon-xs)",pR({status:e}))})}}function TR({isSelected:e,isFocused:t,control:n,children:s,"data-selected":r}){return a.jsxs("div",{className:Y("flex items-center gap-2 rounded px-2 py-1 transition-all duration-150",e?"bg-muted":"hover:bg-muted/80",t&&"ring-status-info/50 ring-1"),"data-selected":r,children:[n,s]})}function Yp({icon:e,label:t,trailing:n,children:s,...r}){return a.jsxs("div",{className:"bg-muted/50 rounded-msg-tool shadow-msg-tool border px-3 py-1 text-sm transition-all duration-150",...r,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[e,t,n]}),s]})}function Vq({type:e,toolName:t,toolInput:n,...s}){const r=e==="approval"?"Waiting for approval":"Answering questions",i=t?WO(t,n??""):null,o=i?`${r} — ${i}`:`${r}...`;return a.jsx("div",{className:"bg-muted/50 rounded-msg-tool text-muted-foreground shadow-msg-tool border px-3 py-1 text-sm transition-all duration-150",...s,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Sn,{className:"size-(--size-icon-sm) shrink-0 animate-spin"}),a.jsx("span",{className:"truncate text-xs",children:o})]})})}function Xb({expanded:e,onToggle:t,header:n,children:s,variant:r="default",dimmed:i=!1,disabled:o=!1,hideChevron:l=!1,extraContent:c,ariaLabel:u,className:d,...f}){const m=l?void 0:e;return a.jsxs("div",{className:Y("bg-muted/40 mt-px rounded-md border-l-2 text-sm transition-all duration-200 first:mt-1",r==="default"&&"border-l-muted-foreground/30",r==="thinking"&&"border-l-muted-foreground/20",r==="memory"&&"border-l-muted-foreground/20",i&&!e&&"opacity-50 hover:opacity-100",d),...f,children:[a.jsxs("button",{onClick:()=>!o&&t(),disabled:o,className:Y("flex w-full items-center gap-2 px-3 py-1",o&&"cursor-default"),"aria-expanded":m,"aria-label":u,children:[n,!l&&!o&&a.jsx(te.div,{animate:{rotate:e?180:0},transition:{type:"spring",stiffness:400,damping:30},className:"ml-auto",children:a.jsx(Hs,{className:"text-muted-foreground size-(--size-icon-xs)"})})]}),c,a.jsx(Ue,{initial:!1,children:e&&a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:a.jsx("div",{className:"border-border/50 border-t px-3 pt-1 pb-3",children:s})})})]})}function Ide({isActive:e=!1,isResolved:t=!1,children:n,className:s,...r}){return a.jsx("div",{className:Y("border-status-info bg-muted/50 rounded-msg-tool border-l-2 p-3 text-sm transition-all duration-200",e&&"ring-ring/30 ring-2",!e&&!t&&"opacity-60",s),...r,children:n})}const wgt=5120;function kgt({content:e,threshold:t=wgt,className:n}){const[s,r]=x.useState(!1),i=e.length>t,o=i&&!s?e.slice(0,t):e;return a.jsxs("div",{className:Y("mt-2 border-t pt-2",n),children:[a.jsx("pre",{className:"max-h-48 overflow-y-auto text-xs whitespace-pre-wrap",children:o}),i&&!s&&a.jsxs("button",{onClick:()=>r(!0),className:"text-muted-foreground hover:text-foreground mt-1 text-xs underline",children:["Show full output (",(e.length/1024).toFixed(1),"KB)"]})]})}const Cgt={running:a.jsx(Sn,{className:"text-muted-foreground size-(--size-icon-xs) animate-spin"}),success:a.jsx(Lt,{className:"text-muted-foreground size-(--size-icon-xs)"}),error:a.jsx(es,{className:"text-destructive size-(--size-icon-xs)"}),cancelled:a.jsx(es,{className:"text-muted-foreground size-(--size-icon-xs)"})};function Egt({hook:e}){const t=!!(e.stdout||e.stderr),[n,s]=x.useState(e.status==="error"),r=e.stderr||e.stdout;return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>t&&s(i=>!i),className:Y("flex w-full items-center gap-1.5 py-0.5",!t&&"cursor-default"),"aria-expanded":t?n:void 0,disabled:!t,children:[Cgt[e.status],a.jsx("span",{className:Y("text-3xs font-mono",e.status==="error"?"text-destructive":"text-muted-foreground"),children:e.hookName}),e.status==="error"&&a.jsx("span",{className:"text-3xs text-destructive",children:"failed"}),e.exitCode!==void 0&&a.jsxs("span",{className:"text-3xs text-muted-foreground ml-auto",children:["exit ",e.exitCode]})]}),a.jsx(Ue,{initial:!1,children:n&&t&&r&&a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:[.4,0,.2,1]},className:"overflow-hidden",children:a.jsx("pre",{className:"text-muted-foreground max-h-32 overflow-y-auto py-1 text-xs whitespace-pre-wrap",children:r})})})]})}function Tgt({toolCall:e,defaultExpanded:t=!1}){const[n,s]=x.useState(t),r=!!e.progressOutput;x.useEffect(()=>{r&&!n&&s(!0)},[r]);const i=e.hooks&&e.hooks.length>0?a.jsx("div",{className:"border-border/50 space-y-0.5 border-t px-3 py-1",children:e.hooks.map(c=>a.jsx(Egt,{hook:c},c.hookId))}):void 0,o=e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0,l=$Z(e.toolName);return a.jsxs(Xb,{expanded:n,onToggle:()=>s(!n),dimmed:e.status==="complete",extraContent:i,"data-testid":"tool-call-card","data-tool-name":e.toolName,"data-status":e.status,header:a.jsxs(a.Fragment,{children:[Ode(e.status),l&&a.jsx("span",{className:"bg-muted text-muted-foreground text-3xs rounded px-1 py-0.5 font-medium",children:l}),a.jsx("span",{className:"text-3xs flex-1 text-left font-mono",children:WO(e.toolName,e.input)}),o!==void 0&&a.jsx("span",{className:"text-muted-foreground text-3xs tabular-nums",children:JDe(o)})]}),children:[e.status==="running"&&!e.input?a.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 py-1 text-xs",children:[a.jsx(Sn,{className:"size-3 animate-spin"}),a.jsx("span",{children:"Preparing..."})]}):e.input!==void 0&&e.input!==""?a.jsx(UZ,{toolName:e.toolName,input:e.input,isStreaming:e.status==="running"}):null,e.progressOutput&&!e.result&&a.jsx(kgt,{content:e.progressOutput}),e.result&&a.jsx("div",{className:"mt-2 border-t pt-2",children:a.jsx(Dde,{content:e.result,toolName:e.toolName,input:e.input})})]})}const qq={duration:.15,ease:"easeOut"},Gq=120,Kq=60,Wq=new Set(["Bash","Write","Edit","NotebookEdit"]),Yq=new Set(["WebFetch","WebSearch"]);function _gt(e){const t=e.includes("__")?e.split("__").pop():e;return Wq.has(t)||Wq.has(e)?"high":Yq.has(t)||Yq.has(e)||e.startsWith("mcp__")?"medium":"low"}function Ngt(e){const t=Math.floor(e/60),n=e%60;return t>0?`${t}:${String(n).padStart(2,"0")}`:`${n}s`}function jgt(e){if(e===null)return"";if(e<=0)return"Expired";const t=Math.floor(e/60),n=e%60;return t>0?`${t} minute${t!==1?"s":""} and ${n} second${n!==1?"s":""} remaining`:`${n} second${n!==1?"s":""} remaining`}function Pde({sessionId:e,toolCallId:t,toolName:n,input:s,isActive:r=!1,onDecided:i,ref:o,timeoutMs:l,approvalStartedAt:c,approvalRemainingMs:u,approvalTitle:d,approvalDisplayName:f,approvalDescription:m,approvalBlockedPath:g,approvalDecisionReason:y,approvalHasSuggestions:b}){const S=je(),w=x.useMemo(()=>_gt(n),[n]),C=$Z(n),T=WO(n,s),E=f||T,[j,_]=x.useState(!1),[N,R]=x.useState(null),[O,M]=x.useState(null),[L,P]=x.useState(null),$=x.useRef(!1),[q,K]=x.useState("");x.useEffect(()=>{if(N||!l)return;const U=u!==void 0?Date.now()+u:c?c+l:Date.now()+l;P(Math.max(0,Math.ceil((U-Date.now())/1e3)));const G=setInterval(()=>{const W=Math.max(0,Math.ceil((U-Date.now())/1e3));P(W),W<=0&&clearInterval(G)},1e3);return()=>clearInterval(G)},[l,c,u,N]),x.useEffect(()=>{L===0&&!N&&($.current=!0,R("denied"),i==null||i())},[L,N,i]),x.useEffect(()=>{L===Gq?K("Tool approval required. 2 minutes remaining."):L===Kq?K("Urgent: 1 minute to approve or deny."):L===0&&K("Tool approval timed out. Execution denied.")},[L]);const B=x.useMemo(()=>L===null?"normal":L<=0?"expired":L<=Kq?"urgent":L<=Gq?"warning":"normal",[L]),V=x.useCallback(async()=>{if(!(j||N)){_(!0),M(null);try{await S.approveTool(e,t),R("approved"),i==null||i()}catch(U){U.code==="INTERACTION_ALREADY_RESOLVED"?(R("approved"),i==null||i()):(console.error("Approval failed:",U),M("Approval request failed — try again"))}finally{_(!1)}}},[j,N,S,e,t,i]),Q=x.useCallback(async()=>{if(!(j||N)){_(!0),M(null);try{await S.approveTool(e,t,!0),R("approved"),i==null||i()}catch(U){U.code==="INTERACTION_ALREADY_RESOLVED"?(R("approved"),i==null||i()):(console.error("Always Allow failed:",U),M("Always Allow request failed — try again"))}finally{_(!1)}}},[j,N,S,e,t,i]),re=x.useCallback(async()=>{if(!(j||N)){_(!0),M(null);try{await S.denyTool(e,t),R("denied"),i==null||i()}catch(U){U.code==="INTERACTION_ALREADY_RESOLVED"?(R("denied"),i==null||i()):(console.error("Deny failed:",U),M("Deny request failed — try again"))}finally{_(!1)}}},[j,N,S,e,t,i]);if(x.useImperativeHandle(o,()=>({approve(){V()},alwaysAllow(){Q()},deny(){re()}}),[V,Q,re]),N){const U=N==="approved";return a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},transition:qq,children:a.jsx(Yp,{"data-testid":"tool-approval-decided","data-decision":N,icon:U?a.jsx(Lt,{className:"text-status-success size-(--size-icon-sm) shrink-0"}):a.jsx(es,{className:"text-status-error size-(--size-icon-sm) shrink-0"}),label:a.jsx("span",{className:"text-3xs font-mono",children:E}),trailing:a.jsx("span",{className:Y("text-2xs rounded-full px-1.5 py-0.5 font-medium",U?"bg-status-success-bg text-status-success-fg":"bg-status-error-bg text-status-error-fg"),children:U?"Approved":"Denied"}),children:N==="denied"&&$.current&&a.jsxs("p",{className:"text-2xs text-muted-foreground mt-1",children:["Auto-denied — approval timed out after ",Math.ceil((l??0)/6e4)," minutes. The agent continued without this tool."]})})})}return a.jsxs(Ide,{isActive:r,isResolved:!!N,className:"my-1","data-testid":"tool-approval",children:[a.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[a.jsx(Hc,{className:Y("size-(--size-icon-md)",w==="high"&&"text-status-error",w==="medium"&&"text-status-warning",w==="low"&&"text-muted-foreground")}),a.jsx("span",{className:"font-semibold",children:d||"Tool approval required"})]}),(m||y||g)&&a.jsxs("div",{className:"text-muted-foreground text-2xs mb-2 space-y-0.5",children:[m&&a.jsx("p",{children:m}),y&&!m&&a.jsx("p",{children:y}),g&&a.jsxs("p",{className:"font-mono",children:["Path: ",g]})]}),l&&!N&&a.jsx("div",{role:"progressbar","aria-valuemin":0,"aria-valuemax":Math.ceil(l/1e3),"aria-valuenow":L??0,"aria-valuetext":jgt(L),className:"bg-muted mb-2 h-1 w-full overflow-hidden rounded-full",children:a.jsx("div",{className:Y("h-full rounded-full transition-colors duration-500",B==="normal"&&"bg-muted-foreground/30",B==="warning"&&"bg-status-warning",B==="urgent"&&"bg-status-error","motion-safe:animate-drain"),style:{animationDuration:`${l}ms`,animationTimingFunction:"linear",animationFillMode:"forwards"}})}),a.jsx(Ue,{children:(B==="warning"||B==="urgent")&&L!==null&&a.jsx(te.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:qq,className:"mb-2",children:a.jsxs("span",{className:Y("text-2xs tabular-nums",B==="warning"&&"text-status-warning",B==="urgent"&&"text-status-error"),children:[Ngt(L)," remaining"]})})}),a.jsxs("div",{className:"mb-2 flex items-center gap-1.5",children:[C&&a.jsx("span",{className:"bg-muted text-muted-foreground text-3xs rounded px-1 py-0.5 font-medium",children:C}),a.jsx("span",{className:"font-mono text-xs",children:E})]}),s&&a.jsx("div",{className:"bg-muted mb-3 rounded p-2",children:a.jsx(UZ,{toolName:n,input:s})}),O&&a.jsx("p",{className:"text-status-error text-2xs mb-2",children:O}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsxs(ge,{size:"sm",onClick:V,disabled:j,className:"transition-opacity duration-150",children:[a.jsx(Lt,{className:"size-(--size-icon-xs)"})," Approve",r&&a.jsx(Zr,{className:"ml-1.5",children:"Enter"})]}),b&&a.jsxs(ge,{size:"sm",variant:"outline",onClick:Q,disabled:j,className:"transition-opacity duration-150",children:[a.jsx(xb,{className:"size-(--size-icon-xs)"})," Always Allow",r&&a.jsx(Zr,{className:"ml-1.5",children:"Shift+Enter"})]}),a.jsxs(ge,{size:"sm",variant:"outline",onClick:re,disabled:j,className:"transition-opacity duration-150",children:[a.jsx(es,{className:"size-(--size-icon-xs)"})," Deny",r&&a.jsx(Zr,{className:"ml-1.5",children:"Esc"})]})]}),a.jsx("span",{role:"status","aria-live":"assertive","aria-atomic":"true",className:"sr-only",children:q})]})}function Agt(e,t,n,s,r){const i=n==null?void 0:n[String(t)];if(i){if(e.multiSelect&&i.startsWith("["))try{return JSON.parse(i).join(", ")}catch{return i}return i}const o=s[t];return o?e.multiSelect?o.map(l=>l==="__other__"?r[t]:l).join(", "):o==="__other__"?r[t]:o:null}function Rgt({questions:e,answers:t,selections:n,otherText:s}){const r=a.jsx(Lt,{className:"text-status-success size-(--size-icon-sm) shrink-0"}),i=e.map((o,l)=>({idx:l,header:o.header,value:Agt(o,l,t,n,s)})).filter(o=>o.value!==null);if(i.length===0){const o=e.length===1?"Question answered":`${e.length} questions answered`;return a.jsx(Yp,{"data-testid":"question-prompt-submitted",icon:r,label:a.jsx("span",{className:"truncate",children:o})})}return i.length===1?a.jsx(Yp,{"data-testid":"question-prompt-submitted",icon:r,label:a.jsx("span",{className:"truncate",children:`${i[0].header}: ${i[0].value}`})}):a.jsx(Yp,{"data-testid":"question-prompt-submitted",icon:r,label:a.jsx("span",{className:"text-muted-foreground",children:"Questions answered"}),children:a.jsx("dl",{className:"mt-1 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 pl-6 text-xs",children:i.map(({idx:o,header:l,value:c})=>a.jsxs(x.Fragment,{children:[a.jsx("dt",{className:"text-muted-foreground",children:l}),a.jsx("dd",{className:"text-foreground break-words",children:c})]},o))})})}const Mgt={duration:.25,ease:[.4,0,.2,1]},_R={duration:.15,ease:"easeOut"},Dgt={enter:e=>({opacity:0,x:e*20}),center:{opacity:1,x:0},exit:e=>({opacity:0,x:e*-20})},Lde=x.forwardRef(function({sessionId:t,toolCallId:n,questions:s,answers:r,isActive:i=!1,focusedOptionIndex:o=-1,onDecided:l},c){const u=je(),d=x.useId(),[f,m]=x.useState({}),[g,y]=x.useState({}),[b,S]=x.useState(!!r),[w,C]=x.useState(!1),[T,E]=x.useState(null),[j,_]=x.useState("0"),N=x.useRef(1),R=s[Number(j)]||s[0],O=Number(j),M=R?R.options.length+1:0;function L(U,G){m(W=>({...W,[U]:G}))}function P(U,G,W){m(F=>{const X=F[U]||[];return W?{...F,[U]:[...X,G]}:{...F,[U]:X.filter(J=>J!==G)}})}function $(U,G){y(W=>({...W,[U]:G}))}function q(U){var W,F;const G=f[U];if(!G)return!1;if(s[U].multiSelect){const X=G;return X.length>0&&(!X.includes("__other__")||!!((W=g[U])!=null&&W.trim()))}return G!=="__other__"||!!((F=g[U])!=null&&F.trim())}function K(){return s.every((U,G)=>q(G))}const B=x.useCallback(async()=>{if(!K()||w)return;C(!0),E(null);const U={};s.forEach((G,W)=>{var X;const F=f[W];if(G.multiSelect){const J=F.map(ae=>{var oe;return ae==="__other__"?((oe=g[W])==null?void 0:oe.trim())||"":ae}).filter(Boolean);U[String(W)]=J.join(", ")}else U[String(W)]=F==="__other__"?((X=g[W])==null?void 0:X.trim())||"":F});try{await u.submitAnswers(t,n,U),S(!0),l==null||l(U)}catch(G){G.code==="INTERACTION_ALREADY_RESOLVED"?(S(!0),l==null||l(U)):E(G instanceof Error?G.message:"Failed to submit answers")}finally{C(!1)}},[f,g,w,u,t,n,s,l]);x.useImperativeHandle(c,()=>({toggleOption(U){if(!R||b||w)return;if(U===R.options.length){R.multiSelect?(f[O]||[]).includes("__other__")?P(O,"__other__",!1):P(O,"__other__",!0):L(O,"__other__");return}const G=R.options[U];G&&(R.multiSelect?(f[O]||[]).includes(G.label)?P(O,G.label,!1):P(O,G.label,!0):L(O,G.label))},navigateOption(U){},navigateQuestion(U){if(s.length<=1)return;const G=Number(j);U==="next"&&G<s.length-1?(N.current=1,_(String(G+1))):U==="prev"&&G>0&&(N.current=-1,_(String(G-1)))},submit(){const U=Number(j);if(U<s.length-1){N.current=1,_(String(U+1));return}B()},getOptionCount(){return M},getActiveTab(){return j}}),[R,O,j,f,b,w,M,B,s.length]);function V(U){const G=Number(j);U==="next"&&G<s.length-1?(N.current=1,_(String(G+1))):U==="prev"&&G>0&&(N.current=-1,_(String(G-1)))}function Q(U,G){const W=U.multiSelect?(f[G]||[]).includes("__other__"):f[G]==="__other__",F=`${d}-q-${G}-other`,X=U.options.length;return a.jsx(TR,{isSelected:W,isFocused:i&&o===X,"data-selected":W,control:U.multiSelect?a.jsx(Sg,{checked:W,id:F,disabled:w,onCheckedChange:J=>P(G,"__other__",!!J)}):a.jsx(bv,{value:"__other__",id:F,disabled:w}),children:a.jsxs("div",{className:"flex-1",children:[a.jsxs("label",{htmlFor:F,className:"flex cursor-pointer items-center",children:[a.jsx("span",{className:"text-sm font-medium",children:"Other"}),X<9&&a.jsx(Zr,{className:"text-2xs text-muted-foreground ml-auto shrink-0",children:X+1})]}),a.jsx(Ue,{initial:!1,children:W&&a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:Mgt,className:"overflow-hidden",children:a.jsx("textarea",{placeholder:"Type your answer...",rows:2,value:g[G]||"",disabled:w,onChange:J=>$(G,J.target.value),className:"bg-background border-border focus:ring-ring mt-1 w-full resize-y rounded border px-2 py-1 text-sm focus:ring-1 focus:outline-none",autoFocus:!0})})})]})})}function re(U,G){return a.jsxs("div",{children:[a.jsx("p",{className:"text-foreground mb-1.5",children:U.question}),U.multiSelect?a.jsxs("div",{role:"group","aria-label":U.question,className:"ml-1 space-y-1",children:[U.options.map((W,F)=>{const X=(f[G]||[]).includes(W.label),J=`${d}-q-${G}-opt-${F}`;return a.jsx(TR,{isSelected:X,isFocused:i&&o===F,"data-selected":X,control:a.jsx(Sg,{checked:X,id:J,disabled:w,onCheckedChange:ae=>P(G,W.label,!!ae)}),children:a.jsxs("label",{htmlFor:J,className:"flex flex-1 cursor-pointer items-center",children:[a.jsx("span",{className:"text-sm font-medium",children:W.label}),W.description&&a.jsxs("span",{className:"text-muted-foreground ml-1.5 text-xs",children:[" ","— ",W.description]}),F<9&&a.jsx(Zr,{className:"text-2xs text-muted-foreground ml-auto shrink-0",children:F+1})]})},F)}),Q(U,G)]}):a.jsxs(JI,{value:f[G]??"",onValueChange:W=>L(G,W),"aria-label":U.question,className:"ml-1 gap-1",children:[U.options.map((W,F)=>{const X=f[G]===W.label,J=`${d}-q-${G}-opt-${F}`;return a.jsx(TR,{isSelected:X,isFocused:i&&o===F,"data-selected":X,control:a.jsx(bv,{value:W.label,id:J,disabled:w}),children:a.jsxs("label",{htmlFor:J,className:"flex flex-1 cursor-pointer items-center",children:[a.jsx("span",{className:"text-sm font-medium",children:W.label}),W.description&&a.jsxs("span",{className:"text-muted-foreground ml-1.5 text-xs",children:[" ","— ",W.description]}),F<9&&a.jsx(Zr,{className:"text-2xs text-muted-foreground ml-auto shrink-0",children:F+1})]})},F)}),Q(U,G)]})]})}return b?a.jsx(te.div,{initial:r?!1:{opacity:0},animate:{opacity:1},transition:_R,children:a.jsx(Rgt,{questions:s,answers:r,selections:f,otherText:g})}):a.jsxs(Ide,{isActive:i,isResolved:b,children:[s.length===1?re(s[0],0):a.jsxs("div",{children:[a.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[a.jsx("span",{className:"text-muted-foreground text-xs",children:s[Number(j)].header??`Question ${Number(j)+1} of ${s.length}`}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsxs(ge,{size:"sm",variant:"ghost",onClick:()=>V("prev"),disabled:Number(j)===0,className:"h-7 px-2 text-xs",children:["Back ",i&&a.jsx(Zr,{className:"ml-1",children:"←"})]}),Number(j)<s.length-1?a.jsxs(ge,{size:"sm",onClick:()=>V("next"),className:"h-7 px-2 text-xs",children:["Next ",i&&a.jsx(Zr,{className:"ml-1",children:"→"})]}):a.jsxs(ge,{size:"sm",onClick:B,disabled:!K()||w,className:"h-7 px-2 text-xs transition-opacity duration-150",children:[a.jsx(Lt,{className:"size-(--size-icon-xs)"}),w?"Submitting...":"Submit",i&&a.jsx(Zr,{className:"ml-1",children:"Enter"})]})]})]}),a.jsx(Ue,{mode:"wait",custom:N.current,children:a.jsx(te.div,{custom:N.current,variants:Dgt,initial:"enter",animate:"center",exit:"exit",transition:_R,children:re(s[Number(j)],Number(j))},j)})]}),a.jsx(Ue,{children:T&&a.jsx(te.p,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:_R,className:"mt-2 text-xs text-red-500",children:T})}),s.length===1&&a.jsx(ge,{size:"sm",onClick:B,disabled:!K()||w,className:"mt-2 transition-opacity duration-150",children:w?"Submitting...":a.jsxs(a.Fragment,{children:[a.jsx(Lt,{className:"size-(--size-icon-xs)"})," Submit",i&&a.jsx(Zr,{className:"ml-1.5",children:"Enter"})]})})]})});function Ogt(e){if(!e)return[];const t=e.properties??{};return Object.entries(t).map(([n,s])=>({key:n,label:s.description??n,type:s.type??"string",options:s.enum,defaultValue:s.default}))}function Igt({sessionId:e,interactionId:t,serverName:n,message:s,mode:r="form",url:i,requestedSchema:o,status:l,action:c}){const u=je(),[d,f]=x.useState(!1),[m,g]=x.useState(null),[y,b]=x.useState({}),[S,w]=x.useState(!1),C=x.useMemo(()=>Ogt(o),[o]),T=l!=="pending",E=x.useCallback(async(M,L)=>{if(!(d||T)){f(!0),g(null);try{await u.submitElicitation(e,t,M,L)}catch(P){if(P.code!=="INTERACTION_ALREADY_RESOLVED"){g(P instanceof Error?P.message:"Failed to submit"),f(!1);return}}f(!1)}},[u,e,t,d,T]),j=x.useCallback(()=>{const M={};for(const L of C)M[L.key]=y[L.key]??L.defaultValue??"";E("accept",M)},[C,y,E]),_=x.useCallback(()=>{E("accept")},[E]),N=x.useCallback(()=>{E("decline")},[E]),R=x.useCallback((M,L)=>{b(P=>({...P,[M]:L}))},[]),O=x.useCallback(()=>{i&&(window.open(i,"_blank","noopener,noreferrer"),w(!0))},[i]);return T?a.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 py-1 text-xs",children:[a.jsx("span",{className:"font-mono",children:n}),a.jsx("span",{children:"—"}),a.jsx("span",{children:c==="accept"?"Authorized":c==="decline"?"Declined":"Cancelled"})]}):a.jsxs(te.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.15},className:Y("border-border bg-card my-2 rounded-xl border p-4","shadow-soft"),children:[a.jsxs("div",{className:"text-muted-foreground mb-2 flex items-center gap-2 text-xs",children:[a.jsx("span",{className:"bg-muted inline-flex items-center rounded-md px-2 py-0.5 font-mono text-[10px]",children:n}),a.jsx("span",{children:"requests input"})]}),a.jsx("p",{className:"mb-3 text-sm",children:s}),m&&a.jsx("p",{className:"text-destructive mb-2 text-xs",children:m}),r==="url"&&i&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ge,{size:"sm",variant:"outline",onClick:O,disabled:d,children:"Open authorization page"}),S&&a.jsx(ge,{size:"sm",onClick:_,disabled:d,children:d?"Submitting…":"Done — I authorized"}),a.jsx(ge,{size:"sm",variant:"ghost",onClick:N,disabled:d,children:"Decline"})]}),r==="form"&&a.jsxs(a.Fragment,{children:[C.length>0?a.jsx("div",{className:"mb-3 space-y-2",children:C.map(M=>a.jsxs("div",{children:[a.jsx("label",{htmlFor:`elicitation-${t}-${M.key}`,className:"text-muted-foreground mb-1 block text-xs font-medium",children:M.label}),M.options?a.jsxs("select",{id:`elicitation-${t}-${M.key}`,className:"border-input bg-background w-full rounded-md border px-3 py-1.5 text-sm",value:y[M.key]??String(M.defaultValue??""),onChange:L=>R(M.key,L.target.value),disabled:d,children:[a.jsx("option",{value:"",children:"Select…"}),M.options.map(L=>a.jsx("option",{value:L,children:L},L))]}):a.jsx("input",{id:`elicitation-${t}-${M.key}`,type:M.type==="number"?"number":"text",className:"border-input bg-background w-full rounded-md border px-3 py-1.5 text-sm",placeholder:String(M.defaultValue??""),value:y[M.key]??"",onChange:L=>R(M.key,L.target.value),disabled:d})]},M.key))}):a.jsx("p",{className:"text-muted-foreground mb-3 text-xs",children:"No additional input required."}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ge,{size:"sm",onClick:j,disabled:d,children:d?"Submitting…":"Accept"}),a.jsx(ge,{size:"sm",variant:"ghost",onClick:N,disabled:d,children:"Decline"})]})]})]})}function Pgt(e){if(e<1e3)return"<1s";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return`${n}m ${s}s`}function Lgt(e){const t=[];return e.toolUses&&t.push(`${e.toolUses} tool ${e.toolUses===1?"call":"calls"}`),e.durationMs&&t.push(Pgt(e.durationMs)),t.length>0?t.join(" · "):null}function Fgt({part:e}){const[t,n]=x.useState(!1),s=x.useRef(null),r=Lgt(e),i=e.subagentText,o=!!(r||e.summary||e.lastToolName||i);return x.useEffect(()=>{const l=s.current;l&&(l.scrollTop=l.scrollHeight)},[i]),a.jsx(Xb,{expanded:t,onToggle:()=>o&&n(!t),hideChevron:!o,ariaLabel:`Background task: ${e.description}`,"data-testid":"subagent-block","data-task-id":e.taskId,"data-status":e.status,header:a.jsxs(a.Fragment,{children:[Ode(e.status==="stopped"?"complete":e.status),a.jsx("span",{className:"text-3xs truncate font-mono",children:e.description}),r&&a.jsx("span",{className:"text-3xs text-muted-foreground ml-1 shrink-0",children:r})]}),children:a.jsxs("div",{className:"space-y-1.5",children:[i&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-3xs text-muted-foreground/70 tracking-wide uppercase",children:"Subagent output"}),a.jsx("pre",{ref:s,className:"text-foreground/90 bg-muted/50 max-h-64 overflow-y-auto rounded-md p-2 text-xs break-words whitespace-pre-wrap","data-testid":"subagent-text",children:i})]}),e.lastToolName&&e.status==="running"&&a.jsxs("p",{className:"text-3xs text-muted-foreground",children:["Last tool: ",a.jsx("span",{className:"font-mono",children:e.lastToolName})]}),e.summary&&a.jsx("pre",{className:"overflow-x-auto text-xs whitespace-pre-wrap",children:e.summary})]})})}function zgt(e){if(e<1e3)return"<1s";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return`${n}m ${s}s`}function Bgt({text:e,isStreaming:t,elapsedMs:n}){const[s,r]=x.useState(t),i=x.useRef(t),o=x.useRef(null);x.useEffect(()=>{i.current&&!t&&r(!1),i.current=t},[t]),x.useEffect(()=>{t&&s&&o.current&&(o.current.scrollTop=o.current.scrollHeight)},[e,t,s]);const l=n?`Thought for ${zgt(n)}`:"Thinking...";return a.jsx(Xb,{expanded:s,onToggle:()=>r(!s),variant:"thinking",dimmed:!t,disabled:t,ariaLabel:l,"data-testid":"thinking-block","data-streaming":t?"true":void 0,header:a.jsxs(a.Fragment,{children:[a.jsx(xAe,{className:Y("text-muted-foreground size-(--size-icon-xs)",t&&"animate-tasks")}),a.jsx("span",{className:Y("text-3xs text-muted-foreground font-mono",t&&"animate-tasks"),children:l})]}),children:a.jsx("div",{ref:o,className:"max-h-32 overflow-y-auto",children:a.jsx("pre",{className:"text-muted-foreground text-xs break-words whitespace-pre-wrap",children:e})})})}const $gt={duration:.25,ease:[.4,0,.2,1]},Hgt={max_turns:{heading:"Turn limit reached",subtext:"The agent ran for its maximum number of turns.",retryable:!1},execution_error:{heading:"Agent stopped unexpectedly",subtext:"An error occurred during execution.",retryable:!0},budget_exceeded:{heading:"Cost limit reached",subtext:"This session exceeded its budget.",retryable:!1},output_format_error:{heading:"Output format error",subtext:"The agent couldn't produce the required output format.",retryable:!1}};function KP({message:e,category:t,details:n,onRetry:s,heading:r,subtext:i}){const[o,l]=x.useState(!1),c=t?Hgt[t]:null,u=r??(c==null?void 0:c.heading)??"Error",d=i??(c==null?void 0:c.subtext)??e,f=(c==null?void 0:c.retryable)??!!s;return a.jsx("div",{className:Y("my-2 rounded-lg border px-4 py-3","border-destructive/30 bg-destructive/5 text-foreground"),children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(fr,{className:"text-destructive mt-0.5 size-4 shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm font-medium",children:u}),a.jsx("p",{className:"text-muted-foreground mt-0.5 text-sm",children:d}),n&&a.jsxs("button",{type:"button",onClick:()=>l(!o),className:"text-muted-foreground hover:text-foreground mt-2 flex items-center gap-1 text-xs","aria-expanded":o,children:[a.jsx(te.div,{animate:{rotate:o?0:-90},transition:{type:"spring",stiffness:400,damping:30},children:a.jsx(Hs,{className:"size-3"})}),"Details"]}),a.jsx(Ue,{initial:!1,children:o&&n&&a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:$gt,className:"overflow-hidden",children:a.jsx("pre",{className:"bg-muted/50 mt-1 max-h-40 overflow-auto rounded p-2 text-xs whitespace-pre-wrap",children:n})})})]}),f&&s&&a.jsxs(ge,{variant:"outline",size:"sm",onClick:s,className:"shrink-0 gap-1.5",children:[a.jsx(S3e,{className:"size-3"}),"Retry"]})]})})}function Ugt({mode:e,memories:t,isStreaming:n}){const[s,r]=x.useState(n),i=x.useRef(n);if(x.useEffect(()=>{i.current&&!n&&r(!1),i.current=n},[n]),t.length===0)return null;const o=t.length,l=n?o<=1?"Consulting memory…":`Consulting ${o} memories…`:o===1?"Recalled 1 memory":`Recalled ${o} memories`,c=e==="synthesize"?Jg:q5,u=e==="synthesize"?"sparkles":"bookopen";return a.jsx(Xb,{expanded:s,onToggle:()=>r(!s),variant:"memory",dimmed:!n,disabled:n,ariaLabel:l,"data-testid":"memory-recall-block","data-streaming":n?"true":void 0,header:a.jsxs(a.Fragment,{children:[a.jsx(c,{"aria-hidden":"true","data-testid":"memory-recall-header-icon","data-icon":u,className:Y("text-muted-foreground size-(--size-icon-xs)",n&&"animate-tasks")}),a.jsx("span",{className:Y("text-3xs text-muted-foreground font-mono",n&&"animate-tasks"),children:l})]}),children:a.jsx(Vgt,{memories:t})})}function Vgt({memories:e}){return a.jsx("ul",{className:"flex flex-col gap-1 px-3 py-2",children:e.map(t=>a.jsx(qgt,{memory:t},t.path))})}function qgt({memory:e}){const t=e.path.startsWith("<synthesis:"),n=e.scope==="team"?e0:Md,s=e.scope==="team"?"team":"personal",r=async()=>{const i=t&&e.content?e.content:e.path;try{await navigator.clipboard.writeText(i),Ye.success("Copied to clipboard")}catch{Ye.error("Failed to copy")}};if(t&&e.content){const i=e.path.replace(/^<synthesis:/,"synthesis:").replace(/>$/,"");return a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:r,"aria-label":`Copy synthesized ${s} memory content`,"data-scope":e.scope,className:"focus-ring hover:bg-muted/50 flex min-h-[44px] w-full flex-col items-start gap-1 rounded-md px-2 py-1 text-left",children:[a.jsx("span",{className:"text-sm",children:e.content}),a.jsxs("span",{className:"text-3xs text-muted-foreground flex items-center gap-1 font-mono",children:[a.jsx(n,{"aria-hidden":"true",className:"size-(--size-icon-xs)"}),i]})]})})}return a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:r,"aria-label":`Copy ${s} memory path ${e.path}`,"data-scope":e.scope,className:"focus-ring hover:bg-muted/50 flex min-h-[44px] w-full items-center gap-2 rounded-md px-2 py-1 text-left",children:[a.jsx("span",{className:"flex-1 truncate font-mono text-sm",children:eOe(e.path,40)}),a.jsx(n,{"aria-hidden":"true",className:"text-muted-foreground size-(--size-icon-xs)"})]})})}function Ggt({toolName:e,reasonType:t,reason:n,message:s}){const r=t==="classifier",i=n||s,o=r?`Blocked by auto-mode classifier: ${i}`:`Blocked: ${i}`;return a.jsxs("div",{"data-testid":"permission-denied-chip","data-reason-type":t,className:Y("my-2 flex items-start gap-2 rounded-md border px-3 py-2","text-foreground border-amber-500/30 bg-amber-500/5"),children:[a.jsx(H3e,{"aria-hidden":"true",className:"mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-500"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm",children:o}),a.jsx("p",{className:"text-muted-foreground mt-0.5 font-mono text-xs",children:e})]})]})}function Kgt(e,t){return e===void 0?"Compacted context":t===void 0?`Compacted context — ${fk(e)} tokens summarized`:`Compacted context — ${fk(e)} → ${fk(t)} tokens`}function Wgt({trigger:e,preTokens:t,postTokens:n,failed:s,error:r}){return s?a.jsx(Yp,{"data-testid":"compact-boundary-row","data-failed":"true",icon:a.jsx(fr,{"aria-hidden":"true",className:"size-3 shrink-0 text-amber-500"}),label:a.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:"Compaction failed"}),children:r?a.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:r}):null}):a.jsx(Yp,{"data-testid":"compact-boundary-row",icon:a.jsx(ma,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:a.jsx("span",{className:"text-muted-foreground",children:Kgt(t,n)}),trailing:e?a.jsx("span",{"data-testid":"compact-boundary-trigger",className:"text-3xs text-muted-foreground/70 ml-auto font-mono uppercase",children:e}):void 0})}function Ygt(e){const t=je(),{sessionId:n,serverName:s,uri:r,enabled:i=!0}=e;return st({queryKey:["mcp-app-resource",n,s,r],queryFn:()=>t.fetchMcpAppResource(n,{serverName:s,uri:r}),enabled:i&&!!(n&&s&&r),staleTime:300*1e3,retry:!1})}const Zq=-32601,Xq=-32e3,Zgt=["inline","fullscreen"];function Xgt(e){const{iframe:t,expectedOrigin:n,hostContext:s,handlers:r}=e,i=d=>{var f;(f=t.contentWindow)==null||f.postMessage(d,"*")},o=(d,f)=>{d!=null&&i({jsonrpc:"2.0",id:d,result:f})},l=(d,f,m)=>{d!=null&&i({jsonrpc:"2.0",id:d,error:{code:f,message:m}})},c=async d=>{switch(d.method){case"ui/initialize":{o(d.id,{availableDisplayModes:[...Zgt],hostContext:s});return}case"resources/read":{const f=Jgt(d.params);if(!f)return l(d.id,Zq,"resources/read requires a uri");try{const m=await r.readResource(f);o(d.id,{contents:[{uri:f,...m}]})}catch(m){l(d.id,Xq,m instanceof Error?m.message:"read failed")}return}case"ui/open-link":{const f=e0t(d.params);f&&r.openLink(f),o(d.id,{});return}case"ui/request-display-mode":{const f=t0t(d.params);f&&r.requestDisplayMode(f),o(d.id,{granted:f==="fullscreen"||f==="inline"});return}case"tools/call":{l(d.id,Xq,"App tool calls are not permitted in this host (v1)");return}default:{l(d.id,Zq,`Unknown method: ${d.method}`);return}}},u=d=>{if(d.source!==t.contentWindow||d.origin!==n)return;const f=Qgt(d.data);f&&c(f)};return window.addEventListener("message",u),()=>window.removeEventListener("message",u)}function Qgt(e){if(typeof e!="object"||e===null)return null;const t=e;return t.jsonrpc!=="2.0"||typeof t.method!="string"?null:{jsonrpc:"2.0",method:t.method,id:t.id,params:t.params}}function Jgt(e){const t=e==null?void 0:e.uri;return typeof t=="string"?t:void 0}function e0t(e){const t=e==null?void 0:e.url;return typeof t=="string"?t:void 0}function t0t(e){const t=e==null?void 0:e.mode;return t==="inline"||t==="fullscreen"||t==="pip"?t:void 0}const n0t="allow-scripts",s0t="null",r0t="default-src 'none'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'",i0t={camera:"camera",microphone:"microphone",geolocation:"geolocation","clipboard-write":"clipboard-write"};function a0t(e){if(e.length!==0)return e.map(t=>`${i0t[t]} 'self'`).join("; ")}function o0t(e,t){const n=t&&t.trim().length>0?t:r0t,s=`<meta http-equiv="Content-Security-Policy" content="${l0t(n)}">`;return/<head[^>]*>/i.test(e)?e.replace(/<head[^>]*>/i,r=>`${r}${s}`):/<html[^>]*>/i.test(e)?e.replace(/<html[^>]*>/i,r=>`${r}<head>${s}</head>`):`<!doctype html><html><head>${s}</head><body>${e}</body></html>`}function l0t(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<")}function c0t(){return document.documentElement.classList.contains("dark")?"dark":"light"}function Fde({sessionId:e,serverName:t,uri:n,title:s,onRequestFullscreen:r,className:i}){const o=je(),l=x.useRef(null),[c,u]=x.useState(null),{data:d,isLoading:f,isError:m,error:g}=Ygt({sessionId:e,serverName:t,uri:n}),y=d!=null&&d.text?o0t(d.text,d.csp):void 0,b=a0t((d==null?void 0:d.permissions)??[]),S=x.useCallback(async E=>{const j=await o.fetchMcpAppResource(e,{serverName:t,uri:E});return{mimeType:j.mimeType,text:j.text,blob:j.blob}},[o,e,t]),w=x.useCallback(E=>{E==="fullscreen"&&(r==null||r())},[r]),[C,T]=x.useState(void 0);return x.useEffect(()=>{const E=l.current;if(!E||!y)return;const j=Xgt({iframe:E,expectedOrigin:s0t,hostContext:{hostName:"DorkOS",theme:c0t()},handlers:{readResource:S,openLink:_=>u(_),requestDisplayMode:w}});return T(y),j},[y,S,w]),f?a.jsx("div",{className:Y("text-muted-foreground p-4 text-sm",i),children:"Loading app…"}):m||!y?a.jsx("div",{className:Y("text-muted-foreground p-4 text-sm",i),children:m?`Could not load app from ${t}: ${g instanceof Error?g.message:"unknown error"}`:"This app returned no renderable content."}):a.jsxs("div",{className:Y("relative h-full w-full",i),children:[a.jsx("iframe",{ref:l,title:s??`MCP App from ${t}`,sandbox:n0t,...b?{allow:b}:{},srcDoc:C,className:"bg-background h-full w-full border-0"}),a.jsx(TT,{url:c??"",isOpen:c!==null,onClose:()=>u(null),onConfirm:()=>{c&&window.open(c,"_blank","noopener,noreferrer"),u(null)}})]})}const zde="dorkos:mcp-app-consent:";function Bde(e){return`${zde}${e}`}function u0t(e){try{return localStorage.getItem(Bde(e))==="granted"}catch{return!1}}function d0t(e){try{localStorage.setItem(Bde(e),"granted")}catch{}f0t()}const XD=new Set;function f0t(){for(const e of XD)e()}function h0t(e){XD.add(e);const t=n=>{var s;(s=n.key)!=null&&s.startsWith(zde)&&e()};return window.addEventListener("storage",t),()=>{XD.delete(e),window.removeEventListener("storage",t)}}function m0t(e){const t=x.useSyncExternalStore(h0t,()=>u0t(e),()=>!1),n=x.useCallback(()=>d0t(e),[e]);return{consented:t,grant:n}}const p0t="h-80";function g0t({sessionId:e,serverName:t,uri:n,title:s}){const{consented:r,grant:i}=m0t(t),o=we(u=>u.setCanvasOpen),l=we(u=>u.openCanvasDocument),c=()=>{l({type:"mcp_app",serverName:t,uri:n,title:s}),o(!0)};return r?a.jsxs("div",{className:"overflow-hidden rounded-lg border",children:[a.jsxs("div",{className:"bg-muted/40 flex items-center justify-between border-b px-3 py-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium",children:[a.jsx(ZM,{className:"text-muted-foreground size-3.5 shrink-0"}),a.jsx("span",{className:"truncate",children:s??`App · ${t}`})]}),a.jsx("button",{type:"button",onClick:c,title:"Open in canvas",className:"text-muted-foreground hover:bg-muted hover:text-foreground rounded-md p-1 transition-colors",children:a.jsx(lne,{className:"size-3.5"})})]}),a.jsx(Fde,{sessionId:e,serverName:t,uri:n,title:s,onRequestFullscreen:c,className:p0t})]}):a.jsxs("div",{className:"bg-muted/40 flex flex-col gap-3 rounded-lg border p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[a.jsx(ZM,{className:"text-muted-foreground size-4 shrink-0"}),a.jsxs("span",{children:["Interactive app provided by ",t]})]}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"This runs sandboxed code from the MCP server. It cannot access your session, files, or credentials. Render it?"}),a.jsx("div",{children:a.jsx("button",{type:"button",onClick:i,className:"bg-foreground text-background hover:bg-foreground/90 rounded-lg px-3 py-1.5 text-sm font-medium transition-colors",children:"Render app"})})]})}function x0t(e){if(e.startsWith("mcp__"))return e.split("__")[1]||void 0}function $de(e,t,n){const s=x.useRef(e),[r,i]=x.useState(!(t&&s.current==="complete"));return x.useEffect(()=>{if(t&&e==="complete"&&s.current!=="complete"&&!n){const o=setTimeout(()=>i(!1),yo.TOOL_CALL_AUTO_HIDE_MS);return()=>clearTimeout(o)}},[e,t,n]),!t||n?!0:r}function Qq({part:e,autoHide:t,expandToolCalls:n}){var i;const s=((i=e.hooks)==null?void 0:i.some(o=>o.status==="error"))??!1,r=$de(e.status,t,s);return a.jsx(Ue,{children:r&&a.jsx(te.div,{exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:a.jsx(Tgt,{toolCall:{toolCallId:e.toolCallId,toolName:e.toolName,input:e.input||"",result:e.result,progressOutput:e.progressOutput,status:e.status,hooks:e.hooks,startedAt:e.startedAt,completedAt:e.completedAt},defaultExpanded:n})},e.toolCallId)})}function y0t({part:e,autoHide:t,index:n}){const s=e.isStreaming?"running":"complete",r=$de(s,t,!1);return a.jsx(Ue,{children:r&&a.jsx(te.div,{exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:a.jsx(Bgt,{text:e.text,isStreaming:e.isStreaming??!1,elapsedMs:e.elapsedMs})},`thinking-${n}`)})}const v0t=4,Jq=2;function b0t({children:e}){const[t,n]=x.useState(!1);if(e.length<=v0t||t)return a.jsx(a.Fragment,{children:e});const s=e.length-Jq;return a.jsxs(a.Fragment,{children:[e.slice(0,Jq),a.jsx(Xb,{expanded:!1,onToggle:()=>n(!0),hideChevron:!0,className:"border-l-muted-foreground/15",header:a.jsxs(a.Fragment,{children:[a.jsx(Rs,{className:"text-muted-foreground size-(--size-icon-xs)"}),a.jsxs("span",{className:"text-3xs text-muted-foreground font-mono",children:["and ",s," more steps…"]})]}),children:a.jsx(a.Fragment,{})})]})}function S0t({message:e}){const{sessionId:t,isStreaming:n,isLatestMessage:s,activeToolCallId:r,onToolRef:i,focusedOptionIndex:o,onToolDecided:l,onRetry:c,inputZoneToolCallId:u,textEffect:d}=Uht(),{expandToolCalls:f,autoHideToolCalls:m}=we(),g=e.parts??[],y=x.useCallback(E=>{i==null||i(E)},[i]),b=x.useCallback(E=>{i==null||i(E)},[i]);let S=-1;for(let E=g.length-1;E>=0;E--)if(g[E].type==="text"){S=E;break}function w(E,j){if(E.type==="text")return a.jsx("div",{className:"msg-assistant",children:a.jsx(Sgt,{content:E.text,isStreaming:n&&j===S,textEffect:d,sessionId:t,isLatestMessage:s})},`text-${j}`);if(E.type==="background_task")return a.jsx(Fgt,{part:E},E.taskId);if(E.type==="error")return a.jsx(KP,{message:E.message,category:E.category,details:E.details,onRetry:c},`error-${j}`);if(E.type==="thinking")return a.jsx(y0t,{part:E,autoHide:m,index:j},`thinking-${j}`);if(E.type==="elicitation")return a.jsx(Igt,{sessionId:t,interactionId:E.interactionId,serverName:E.serverName,message:E.message,mode:E.mode,url:E.url,requestedSchema:E.requestedSchema,status:E.status,action:E.action},`elicitation-${E.interactionId}`);if(E.type==="memory_recall")return a.jsx(Ugt,{mode:E.mode,memories:E.memories,isStreaming:E.isStreaming??!1},`memory-recall-${j}`);if(E.type==="permission_denied")return a.jsx(Ggt,{toolName:E.toolName,reasonType:E.reasonType,reason:E.reason,message:E.message},`permission-denied-${E.toolCallId}-${j}`);if(E.type==="compact_boundary")return a.jsx(Wgt,{trigger:E.trigger,preTokens:E.preTokens,postTokens:E.postTokens,failed:E.failed,error:E.error},`compact-boundary-${j}`);const _=E;if(_.interactiveType==="approval"&&_.status==="pending"){if(_.toolCallId===u)return a.jsx(Vq,{type:"approval",toolName:_.toolName,toolInput:_.input},_.toolCallId);const R=_.toolCallId===r;return a.jsx(Pde,{ref:R?y:void 0,sessionId:t,toolCallId:_.toolCallId,toolName:_.toolName,input:_.input||"",timeoutMs:_.timeoutMs,approvalStartedAt:_.approvalStartedAt,approvalRemainingMs:_.approvalRemainingMs,approvalTitle:_.approvalTitle,approvalDisplayName:_.approvalDisplayName,approvalDescription:_.approvalDescription,approvalBlockedPath:_.approvalBlockedPath,approvalDecisionReason:_.approvalDecisionReason,approvalHasSuggestions:_.approvalHasSuggestions,isActive:R,onDecided:l?()=>l(_.toolCallId):void 0},_.toolCallId)}if(_.interactiveType==="question"&&_.questions){if(_.toolCallId===u)return a.jsx(Vq,{type:"question",toolName:_.toolName,toolInput:_.input},_.toolCallId);const R=_.toolCallId===r;return a.jsx(Lde,{ref:R?b:void 0,sessionId:t,toolCallId:_.toolCallId,questions:_.questions,answers:_.answers??(_.status!=="pending"?{}:void 0),isActive:R,focusedOptionIndex:R?o:-1,onDecided:l?O=>l(_.toolCallId,O):void 0},_.toolCallId)}const N=_.ui?x0t(_.toolName):void 0;return _.ui&&_.status==="complete"&&N?a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Qq,{part:_,autoHide:m,expandToolCalls:f}),a.jsx(g0t,{sessionId:t,serverName:N,uri:_.ui.resourceUri})]},_.toolCallId):a.jsx(Qq,{part:_,autoHide:m,expandToolCalls:f},_.toolCallId)}const C=[];let T=[];for(let E=0;E<g.length;E++){const j=g[E];j.type==="thinking"||j.type==="tool_call"&&!j.interactiveType?T.push(E):(T.length>0&&(C.push(T.length===1?{type:"single",index:T[0]}:{type:"run",indices:[...T]}),T=[]),C.push({type:"single",index:E}))}return T.length>0&&C.push(T.length===1?{type:"single",index:T[0]}:{type:"run",indices:[...T]}),a.jsx(a.Fragment,{children:C.map(E=>{if(E.type==="single"){const _=g[E.index];return _.type==="thinking"||_.type==="tool_call"&&!_.interactiveType?a.jsx("div",{className:"my-3",children:w(_,E.index)},`spacer-${E.index}`):w(_,E.index)}const j=E.indices.map(_=>w(g[_],_));return a.jsx("div",{className:"my-3",children:a.jsx(b0t,{children:j})},`run-${E.indices[0]}`)})})}function w0t({prompt:e,sessionId:t,className:n}){const s=Hn(),{sessions:r}=bl(),{data:i}=im(),{data:o}=VT(),[l,c]=x.useState({open:!1}),u=r.find(S=>S.id===t),d=u==null?void 0:u.runtime,f=u==null?void 0:u.cwd,m=yD.filter(S=>S!==d),g=S=>(i?S in i.capabilities:!0)&&xD(o,S),y=S=>{s({to:"/session",search:{session:crypto.randomUUID(),dir:f,runtime:S,prompt:e}})},b=S=>{if(!g(S)){c({open:!0,runtime:S});return}y(S)};return a.jsxs(a.Fragment,{children:[a.jsxs(i4,{children:[a.jsx(a4,{asChild:!0,children:a.jsx("button",{type:"button","aria-label":"Run this prompt with another runtime",className:Y("text-muted-foreground/60 hover:text-foreground inline-flex items-center transition-colors duration-150",n),children:a.jsx(q3e,{className:"size-3.5"})})}),a.jsxs(o4,{align:"end",className:"w-52",children:[a.jsx(l4,{children:"Run this with…"}),m.map(S=>{const w=Ka(S);return a.jsx(F3,{icon:w.icon,description:g(S)?void 0:"Connect",onSelect:()=>b(S),children:w.label},S)})]})]}),a.jsx(Xle,{runtime:l.runtime,open:l.open,onOpenChange:S=>c(w=>({...w,open:S})),renderConnect:SP,onRuntimeReady:S=>{c({open:!1}),y(S)}})]})}function k0t(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function C0t({message:e,grouping:t,sessionId:n,isNew:s=!1,isStreaming:r=!1,isLatestMessage:i=!1,activeToolCallId:o=null,onToolRef:l,focusedOptionIndex:c=-1,onToolDecided:u,onRetry:d,inputZoneToolCallId:f=null,textEffect:m}){const g=e.role==="user",y=e.messageType==="local_command_output",b=g&&!y,S=b&&!0&&e.messageType!=="command"&&e.messageType!=="compaction"&&e.content.trim().length>0,{showTimestamps:w}=we(),{position:C,groupIndex:T}=t,E=C==="only"||C==="first",j=$ht({role:b?"user":"assistant",position:C});return a.jsx(Hht,{value:{sessionId:n,isStreaming:r,isLatestMessage:i,activeToolCallId:o,onToolRef:l,focusedOptionIndex:c,onToolDecided:u,onRetry:d,inputZoneToolCallId:f,textEffect:m},children:a.jsxs(te.div,{initial:s?{opacity:0,y:8,x:b?12:0,scale:b?.97:1}:!1,animate:{opacity:1,y:0,x:0,scale:1},transition:{type:"spring",stiffness:320,damping:28},"data-testid":"message-item","data-role":e.role,className:j.root(),children:[E&&T>0&&!g&&a.jsx("div",{className:j.divider()}),e.timestamp&&a.jsx("span",{className:Y(j.timestamp(),w?"text-msg-timestamp":"group-hover:text-msg-timestamp text-transparent"),children:k0t(e.timestamp)}),S&&a.jsx(w0t,{prompt:e.content,sessionId:n,className:"absolute top-2 -left-9 opacity-0 group-hover:opacity-100 focus-visible:opacity-100"}),a.jsx("div",{className:j.content(),children:g?a.jsx(vgt,{message:e}):a.jsx(S0t,{message:e})})]})})}const eG=800,tG=24;function E0t({scrollRef:e}){const t=x.useRef(null),n=x.useRef(null),s=x.useRef(null),[r,i]=x.useState(!1),o=x.useRef(!1),l=x.useRef(0),c=x.useRef(0),u=x.useCallback(()=>{i(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{o.current||i(!1)},eG)},[]),d=x.useCallback(()=>{const g=e.current,y=t.current,b=n.current;if(!g||!y||!b)return;const{scrollTop:S,scrollHeight:w,clientHeight:C}=g;if(w<=C){y.style.display="none";return}y.style.display="";const T=b.clientHeight,E=C/w,j=Math.max(E*T,tG),_=T-j,R=S/(w-C)*_;y.style.height=`${j}px`,y.style.transform=`translateY(${R}px)`},[e]);x.useEffect(()=>{const g=e.current;if(!g)return;const y=()=>{u(),d()};return g.addEventListener("scroll",y,{passive:!0}),d(),()=>g.removeEventListener("scroll",y)},[e,u,d]);const f=x.useCallback(g=>{if(g.target===t.current)return;const y=e.current,b=n.current;if(!y||!b)return;const S=b.getBoundingClientRect(),w=(g.clientY-S.top)/S.height;y.scrollTop=w*(y.scrollHeight-y.clientHeight)},[e]),m=x.useCallback(g=>{var S;g.preventDefault(),g.stopPropagation(),o.current=!0,l.current=g.clientY,c.current=((S=e.current)==null?void 0:S.scrollTop)??0;const y=w=>{const C=e.current,T=n.current;if(!C||!T)return;const E=w.clientY-l.current,j=T.clientHeight,_=C.clientHeight/C.scrollHeight,N=Math.max(_*j,tG),R=j-N,O=C.scrollHeight-C.clientHeight,M=E/R*O;C.scrollTop=c.current+M},b=()=>{o.current=!1,document.removeEventListener("pointermove",y),document.removeEventListener("pointerup",b),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>i(!1),eG)};document.addEventListener("pointermove",y),document.addEventListener("pointerup",b)},[e]);return a.jsx("div",{ref:n,role:"presentation",onClick:f,className:"pointer-events-auto absolute top-12 right-0 bottom-0 z-10 w-2.5",children:a.jsx("div",{ref:t,onPointerDown:m,className:"bg-border absolute right-0.5 w-1.5 cursor-pointer rounded-full transition-opacity duration-200",style:{opacity:r?1:0}})})}function T0t(e){let t=0;return e.map((n,s)=>{const r=s>0?e[s-1].role:null,i=s<e.length-1?e[s+1].role:null,o=r!==n.role,l=i!==n.role;o&&s>0&&t++;let c;return o&&l?c="only":o?c="first":l?c="last":c="middle",{position:c,groupIndex:t}})}const _0t=x.forwardRef(function({messages:t,sessionId:n,isTextStreaming:s,onScrollStateChange:r,activeToolCallId:i,onToolRef:o,focusedOptionIndex:l,onToolDecided:c,onRetry:u,inputZoneToolCallId:d,textEffect:f},m){const[g,y]=x.useState(null),b=x.useMemo(()=>T0t(t),[t]),{scrollRef:S,contentRef:w,isAtBottom:C,scrollToBottom:T}=Aht({resize:"smooth",initial:"instant"});x.useEffect(()=>{g===null&&t.length>0&&y(t.length)},[t.length,g]);const E=Eht({count:t.length,getScrollElement:()=>S.current,estimateSize:()=>80,overscan:5,measureElement:j=>(j==null?void 0:j.getBoundingClientRect().height)??80});return x.useEffect(()=>{r==null||r({isAtBottom:C,distanceFromBottom:C?0:200})},[C,r]),x.useEffect(()=>{const j=S.current;if(!j||t.length===0)return;let _=!1;const N=new IntersectionObserver(([R])=>{R.isIntersecting?_&&(_=!1,requestAnimationFrame(()=>{T()})):_=!0},{threshold:.1});return N.observe(j),()=>N.disconnect()},[S,t.length,T]),x.useImperativeHandle(m,()=>({scrollToBottom:T}),[T]),a.jsxs("div",{"data-testid":"message-list",className:"relative h-full",children:[a.jsx("div",{ref:S,className:"chat-scroll-area hide-scrollbar h-full overflow-y-auto px-3 pt-12",style:{overflowAnchor:"none"},children:a.jsx("div",{ref:w,style:{height:E.getTotalSize(),position:"relative",width:"100%"},children:E.getVirtualItems().map(j=>{const _=t[j.index],N=g!==null&&j.index>=g,R=j.index===t.length-1,M=R&&_.role==="assistant"&&!!s;return a.jsx("div",{"data-index":j.index,ref:E.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${j.start}px)`},children:a.jsx(C0t,{message:_,grouping:b[j.index],sessionId:n,isNew:N,isStreaming:M,isLatestMessage:R,activeToolCallId:i,onToolRef:o,focusedOptionIndex:l,onToolDecided:c,onRetry:u,inputZoneToolCallId:d,textEffect:f})},j.key)})})}),a.jsx(E0t,{scrollRef:S})]})});function N0t({messages:e,sessionId:t,isLoadingHistory:n,isTextStreaming:s,isAtBottom:r,hasNewMessages:i,scrollToBottom:o,onScrollStateChange:l,activeToolCallId:c,onToolRef:u,focusedOptionIndex:d,onToolDecided:f,onRetry:m,inputZoneToolCallId:g,messageListRef:y}){const b=we(w=>w.dorkbotFirstMessage),S=we(w=>w.setDorkbotFirstMessage);return a.jsxs("div",{className:"relative min-h-0 flex-1",children:[n?a.jsx("div",{className:"flex h-full items-center justify-center",children:a.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:[a.jsxs("div",{className:"flex gap-1",children:[a.jsx("span",{className:"bg-muted-foreground h-2 w-2 rounded-full",style:{animation:"typing-dot 1.4s ease-in-out infinite",animationDelay:"0s"}}),a.jsx("span",{className:"bg-muted-foreground h-2 w-2 rounded-full",style:{animation:"typing-dot 1.4s ease-in-out infinite",animationDelay:"0.2s"}}),a.jsx("span",{className:"bg-muted-foreground h-2 w-2 rounded-full",style:{animation:"typing-dot 1.4s ease-in-out infinite",animationDelay:"0.4s"}})]}),"Loading conversation..."]})}):e.length===0?a.jsx("div",{className:"flex h-full items-center justify-center",children:b?a.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[a.jsx(te.div,{layoutId:"dorkbot-first-message",className:"bg-muted/50 w-full max-w-md rounded-lg border p-4","data-testid":"dorkbot-welcome-message",onLayoutAnimationComplete:()=>{S(null)},children:a.jsx("p",{className:"text-muted-foreground text-sm",children:b})}),a.jsx("p",{className:"text-muted-foreground/60 text-sm",children:"Type a message below to begin"})]}):a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-muted-foreground text-base",children:"Start a conversation"}),a.jsx("p",{className:"text-muted-foreground/60 mt-2 text-sm",children:"Type a message below to begin"})]})}):a.jsx(_0t,{ref:y,messages:e,sessionId:t,isTextStreaming:s,onScrollStateChange:l,activeToolCallId:c,onToolRef:u,focusedOptionIndex:d,onToolDecided:f,onRetry:m,inputZoneToolCallId:g}),a.jsx(Ue,{children:i&&!r&&a.jsx(te.button,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:{duration:.2},onClick:o,className:"bg-foreground text-background hover:bg-foreground/90 absolute bottom-16 left-1/2 z-10 -translate-x-1/2 cursor-pointer rounded-full px-3 py-1.5 text-xs font-medium shadow-sm transition-colors",role:"status","aria-live":"polite",children:"New messages"})}),a.jsx(Ue,{children:!r&&e.length>0&&!n&&a.jsx(te.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.15},onClick:o,className:"bg-background absolute right-4 bottom-4 rounded-full border p-2 shadow-sm transition-shadow hover:shadow-md","aria-label":"Scroll to bottom",children:a.jsx(hb,{className:"size-(--size-icon-md)"})})})]})}const j0t=500;function A0t({textareaRef:e,value:t,isStreaming:n,isMobile:s,sessionBusy:r,editingQueueItem:i,isPaletteOpen:o,queueHasItems:l,onSubmit:c,onStop:u,onEscape:d,onClear:f,onArrowUp:m,onArrowDown:g,onCommandSelect:y,onQueue:b,onSaveEdit:S,onCancelEdit:w,onQueueNavigateUp:C,onQueueNavigateDown:T}){const E=x.useRef(0);return x.useCallback(_=>{if(_.key==="Escape"&&n){u==null||u();return}if(_.key==="Escape"&&i){w==null||w();return}if(_.key==="Escape"){const N=Date.now();o?(d==null||d(),E.current=N):t.trim()&&N-E.current<j0t?(f==null||f(),E.current=0):(d==null||d(),E.current=N);return}if(!o&&l){if(_.key==="ArrowUp"){const N=e.current,R=!N||N.selectionStart===0;if(!t.trim()||R){_.preventDefault(),C==null||C();return}}if(_.key==="ArrowDown"){const N=e.current,R=!N||N.selectionStart===N.value.length;if(i&&R){_.preventDefault(),T==null||T();return}}}if(o){if(_.key==="ArrowDown"){_.preventDefault(),g==null||g();return}if(_.key==="ArrowUp"){_.preventDefault(),m==null||m();return}if(_.key==="Enter"&&!_.shiftKey||_.key==="Tab"){_.preventDefault(),y==null||y();return}}_.key==="Enter"&&!_.shiftKey&&!s&&(_.preventDefault(),i&&t.trim()?S==null||S():n&&t.trim()?b==null||b():!n&&!r&&t.trim()&&c())},[n,s,t,c,u,d,f,o,m,g,y,i,b,S,w,l,C,T,r,e])}const R0t=200,nG=24;function M0t(e,t){const n=x.useCallback(()=>{const s=e.current;s&&(s.style.height="auto",s.style.height=`${Math.min(s.scrollHeight,R0t)}px`)},[e]);return x.useEffect(()=>{const s=e.current;if(!s||t!=="")return;const r=s.scrollHeight;if(r<=nG)return;s.style.height=`${r}px`,s.style.transition="height 200ms ease",requestAnimationFrame(()=>{s.style.height=`${nG}px`});const i=()=>{s.style.transition="",s.style.height=""};return s.addEventListener("transitionend",i,{once:!0}),()=>s.removeEventListener("transitionend",i)},[e,t]),n}const NR={send:{icon:null,className:"bg-primary text-primary-foreground hover:bg-primary/90",label:"Send message"},stop:{icon:pne,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",label:"Stop generating"},queue:{icon:Pi,className:"bg-muted text-muted-foreground hover:bg-muted/80",label:"Queue message"},update:{icon:Lt,className:"bg-primary text-primary-foreground hover:bg-primary/90",label:"Save edit"}};function D0t(e,t,n,s){return s&&e?"update":t&&e?"queue":t?"stop":e&&!n?"send":null}function O0t({hasText:e,isStreaming:t,isUploading:n,sessionBusy:s,editingQueueItem:r,queueDepth:i,isMobile:o,onSubmit:l,onStop:c,onQueue:u,onSaveEdit:d}){const f=D0t(e,t,n,r),m=o?mb:QAe,g=f==="send"?l:f==="stop"?c:f==="queue"?u:f==="update"?d:void 0;return a.jsxs(a.Fragment,{children:[t&&e&&a.jsx(te.button,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.15},whileHover:{scale:1.1},whileTap:{scale:.9},onClick:c,type:"button",className:"bg-destructive text-destructive-foreground hover:bg-destructive/90 shrink-0 rounded-lg p-1.5 transition-colors max-md:p-2","aria-label":"Stop generating",children:a.jsx(pne,{className:"size-(--size-icon-sm)"})}),f&&a.jsxs("div",{className:"relative",children:[a.jsx(te.button,{animate:{opacity:1,scale:1},transition:{duration:.15},whileHover:s?void 0:{scale:1.1},whileTap:s?void 0:{scale:.9},onClick:g,disabled:f==="send"&&s,className:Y("shrink-0 rounded-lg p-1.5 transition-colors max-md:p-2",NR[f].className,f==="send"&&s&&"pointer-events-none opacity-50"),"aria-label":NR[f].label,children:f==="send"?a.jsx(m,{className:"size-(--size-icon-sm)"}):(()=>{const y=NR[f].icon;return a.jsx(y,{className:"size-(--size-icon-sm)"})})()}),i>0&&f==="queue"&&a.jsx("span",{className:"bg-foreground text-background absolute -top-1 -right-1 flex h-4 w-4 items-center justify-center rounded-full text-[10px] font-medium",children:i})]})]})}const I0t=x.forwardRef(function({value:t,onChange:n,onSubmit:s,isStreaming:r,isUploading:i=!1,sessionBusy:o=!1,editingQueueItem:l=!1,queueDepth:c=0,onStop:u,onQueue:d,onSaveEdit:f,onCancelEdit:m,onEscape:g,onClear:y,isPaletteOpen:b,onArrowUp:S,onArrowDown:w,onCommandSelect:C,activeDescendantId:T,onCursorChange:E,onAttach:j,placeholder:_="Send a message...",placeholderOverlay:N,onQueueNavigateUp:R,onQueueNavigateDown:O,queueHasItems:M=!1},L){const P=x.useRef(null),$=x.useRef(null),[q,K]=x.useState(!1),B=Us();x.useImperativeHandle(L,()=>({focus:()=>{var J;return(J=P.current)==null?void 0:J.focus()},focusAt:J=>{const ae=P.current;ae&&(ae.focus(),ae.setSelectionRange(J,J))}})),x.useEffect(()=>{var J;(J=P.current)==null||J.focus()},[]);const V=A0t({textareaRef:P,value:t,isStreaming:r,isMobile:B,sessionBusy:o,editingQueueItem:l,isPaletteOpen:b,queueHasItems:M,onSubmit:s,onStop:u,onEscape:g,onClear:y,onArrowUp:S,onArrowDown:w,onCommandSelect:C,onQueue:d,onSaveEdit:f,onCancelEdit:m,onQueueNavigateUp:R,onQueueNavigateDown:O}),Q=M0t(P,t),re=x.useCallback(()=>K(!0),[]),U=x.useCallback(()=>{K(!1),b&&(g==null||g())},[b,g]),G=x.useCallback(J=>{n(J.target.value),E==null||E(J.target.selectionStart),Q()},[n,E,Q]),W=x.useCallback(()=>{P.current&&(E==null||E(P.current.selectionStart))},[E]),F=t.trim().length>0,X=F&&!o;return a.jsxs("div",{className:"flex flex-col gap-1.5",children:[o&&a.jsx("div",{className:"px-1 text-xs text-amber-600 dark:text-amber-500",children:"Session is busy. Please wait..."}),l&&a.jsxs("div",{className:"text-muted-foreground px-0.5 text-xs",children:["Editing message",c>0?" —":""]}),a.jsxs("div",{className:Y("border-input bg-background flex items-end gap-1.5 rounded-md border p-1.5 shadow-xs transition-[color,box-shadow]",q&&"border-ring ring-ring/75 ring-[1px]",l&&"border-primary/40",!j&&"pl-3"),children:[j&&a.jsxs(a.Fragment,{children:[a.jsx("input",{ref:$,type:"file",className:"hidden",multiple:!0,onChange:J=>{const ae=Array.from(J.target.files??[]);ae.length>0&&j(ae),J.target.value=""}}),a.jsx("button",{type:"button",onClick:()=>{var J;return(J=$.current)==null?void 0:J.click()},className:"text-muted-foreground hover:text-foreground flex shrink-0 items-center justify-center rounded-md px-1.5 py-1 transition-colors disabled:opacity-50","aria-label":"Attach file",children:a.jsx(n3e,{className:"size-4"})})]}),a.jsxs("div",{className:"relative min-h-[24px] flex-1",children:[!F&&N,a.jsx("textarea",{ref:P,value:t,onChange:G,onKeyDown:V,onFocus:re,onBlur:U,onSelect:W,role:"combobox","aria-autocomplete":"list","aria-controls":b?T!=null&&T.startsWith("file-")?"file-palette-listbox":"command-palette-listbox":void 0,"aria-expanded":b??!1,"aria-activedescendant":b?T:void 0,"aria-label":_,placeholder:N?"":_,className:"block max-h-[200px] min-h-[24px] w-full resize-none bg-transparent py-0.5 text-sm focus:outline-none",rows:1,disabled:o})]}),a.jsx(te.button,{animate:{opacity:X?.5:0,scale:X?1:.8},transition:{duration:.15},whileHover:X?{opacity:1}:void 0,onClick:y,disabled:!X,type:"button",className:Y("text-muted-foreground hover:text-foreground shrink-0 rounded-lg p-1 transition-colors",!X&&"pointer-events-none"),"aria-label":"Clear message",children:a.jsx(es,{className:"size-(--size-icon-sm)"})}),a.jsx(O0t,{hasText:F,isStreaming:r,isUploading:i,sessionBusy:o,editingQueueItem:l,queueDepth:c,isMobile:B,onSubmit:s,onStop:u,onQueue:d,onSaveEdit:f})]})]})});function P0t({sessionId:e,pendingApprovals:t,onAllDecided:n}){const s=je(),[r,i]=x.useState(!1),o=x.useCallback(async()=>{if(!r){i(!0);try{const c=t.map(u=>u.toolCallId);await s.batchApprove(e,c),n==null||n()}catch(c){console.error("Batch approve failed:",c)}finally{i(!1)}}},[r,s,e,t,n]),l=x.useCallback(async()=>{if(!r){i(!0);try{const c=t.map(u=>u.toolCallId);await s.batchDeny(e,c),n==null||n()}catch(c){console.error("Batch deny failed:",c)}finally{i(!1)}}},[r,s,e,t,n]);return t.length<2?null:a.jsxs("div",{className:"border-border bg-muted/50 mb-1.5 flex items-center justify-between rounded-lg border px-3 py-1.5",children:[a.jsxs("span",{className:"text-muted-foreground text-xs",children:[t.length," tools awaiting approval"]}),a.jsxs("div",{className:"flex gap-1.5",children:[a.jsxs(ge,{size:"xs",variant:"outline",onClick:o,disabled:r,children:[a.jsx(CAe,{className:"size-3"})," Approve All"]}),a.jsxs(ge,{size:"xs",variant:"ghost",onClick:l,disabled:r,children:[a.jsx(Xg,{className:"size-3"})," Deny All"]})]})]})}function L0t({sessionId:e,activeInteraction:t,pendingApprovals:n,focusedOptionIndex:s,onToolRef:r,onToolDecided:i}){const o=l=>i(t.toolCallId,l);return a.jsxs(a.Fragment,{children:[a.jsx(P0t,{sessionId:e,pendingApprovals:n}),t.interactiveType==="approval"?a.jsx(Pde,{ref:r,sessionId:e,toolCallId:t.toolCallId,toolName:t.toolName,input:t.input||"",isActive:!0,onDecided:o,timeoutMs:t.timeoutMs,approvalStartedAt:t.approvalStartedAt,approvalTitle:t.approvalTitle,approvalDisplayName:t.approvalDisplayName,approvalDescription:t.approvalDescription,approvalBlockedPath:t.approvalBlockedPath,approvalDecisionReason:t.approvalDecisionReason,approvalHasSuggestions:t.approvalHasSuggestions}):t.interactiveType==="question"&&t.questions?a.jsx(Lde,{ref:r,sessionId:e,toolCallId:t.toolCallId,questions:t.questions,answers:t.answers,isActive:!0,focusedOptionIndex:s,onDecided:o}):null]})}const sG=e=>Symbol.iterator in e,rG=e=>"entries"in e,iG=(e,t)=>{const n=e instanceof Map?e:new Map(e.entries()),s=t instanceof Map?t:new Map(t.entries());if(n.size!==s.size)return!1;for(const[r,i]of n)if(!s.has(r)||!Object.is(i,s.get(r)))return!1;return!0},F0t=(e,t)=>{const n=e[Symbol.iterator](),s=t[Symbol.iterator]();let r=n.next(),i=s.next();for(;!r.done&&!i.done;){if(!Object.is(r.value,i.value))return!1;r=n.next(),i=s.next()}return!!r.done&&!!i.done};function z0t(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:sG(e)&&sG(t)?rG(e)&&rG(t)?iG(e,t):F0t(e,t):iG({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function B0t(e){const t=he.useRef(void 0);return n=>{const s=e(n);return z0t(t.current,s)?t.current:t.current=s}}const $0t=e=>["workspaces",e??null];function H0t(e){const t=je(),n=st({queryKey:$0t(e),queryFn:()=>t.listWorkspaces(e)});return{workspaces:n.data??[],isLoading:n.isLoading,error:n.error}}function Hde(){const e=et();return()=>e.invalidateQueries({queryKey:["workspaces"]})}function U0t(e){const t=je();return st({queryKey:["workspace-for-session",e??null],queryFn:()=>t.resolveWorkspace(e),enabled:!!e}).data??null}function V0t(e){const t=e.contextUsage;return!t||t.maxTokens<=0?null:Math.min(100,Math.round(t.totalTokens/t.maxTokens*100))}function q0t(e){var n;const t=e.cacheStats;return!t||t.cacheReadTokens===0&&t.cacheCreationTokens===0?null:{cacheReadTokens:t.cacheReadTokens,cacheCreationTokens:t.cacheCreationTokens,contextTokens:(n=e.contextUsage)==null?void 0:n.totalTokens}}function G0t(e){return e?{contextPercent:V0t(e),costUsd:e.cost,model:e.model,cacheStatus:q0t(e),usage:e.usage}:{contextPercent:null,costUsd:null,model:null,cacheStatus:null,usage:null}}function K0t({children:e,onSwitchAgent:t,onOpenProfile:n,onNewSession:s}){return a.jsxs(Aie,{children:[a.jsx(Rie,{children:e}),a.jsxs(Mie,{className:"w-48",children:[a.jsxs(Ny,{onClick:t,children:[a.jsx(tAe,{className:"mr-2 size-4"}),"Switch agent"]}),a.jsx(z3,{}),a.jsxs(Ny,{onClick:n,children:[a.jsx(Md,{className:"mr-2 size-4"}),"Agent profile"]}),a.jsx(z3,{}),a.jsxs(Ny,{onClick:s,children:[a.jsx(Cs,{className:"mr-2 size-4"}),"New session"]})]})]})}const W0t=[{trigger:"/",label:"Commands",icon:J5,ariaLabel:"Insert slash command trigger"},{trigger:"@",label:"Files",icon:Qg,ariaLabel:"Insert file mention trigger"}];function aG({onChipClick:e,agentName:t,agentColor:n,agentEmoji:s,agentPath:r}){const i=Hn(),o=x.useCallback(()=>{r&&(yd.getState().openHub(r),we.getState().setRightPanelOpen(!0),we.getState().setActiveRightPanelTab("agent-hub"))},[r]),l=x.useCallback(()=>{we.getState().openGlobalPaletteWithSearch("@")},[]),c=x.useCallback(()=>{i({to:"/session",search:{dir:r??void 0,session:crypto.randomUUID()}})},[i,r]),u=t&&n&&s;return a.jsxs(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"mt-1.5 flex items-center justify-center gap-2 sm:justify-start",children:[u&&(r?a.jsx(K0t,{onSwitchAgent:l,onOpenProfile:o,onNewSession:c,children:a.jsx(bD,{size:"xs",name:t,color:n,emoji:s,onClick:o})}):a.jsx(bD,{size:"xs",name:t,color:n,emoji:s})),W0t.map(d=>a.jsxs("button",{type:"button","aria-label":d.ariaLabel,onClick:()=>e(d.trigger),className:"bg-secondary text-muted-foreground hover:text-foreground hover:bg-muted inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs transition-colors duration-150",children:[a.jsx(d.icon,{className:"size-3"}),a.jsx("kbd",{className:"font-mono text-[10px] opacity-60",children:d.trigger}),d.label]},d.trigger))]})}function Y0t({collapsed:e,onToggle:t}){return a.jsx("div",{role:"button",tabIndex:0,"aria-label":e?"Expand input extras":"Collapse input extras",onClick:t,onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),t())},className:"flex h-6 w-full cursor-pointer items-center justify-center",children:a.jsx("div",{className:"bg-muted-foreground/30 hover:bg-muted-foreground/50 active:bg-muted-foreground/50 h-1 w-9 rounded-full transition-colors"})})}function Fo({itemLabel:e,onHide:t,onConfigure:n,children:s}){return a.jsxs(bT,{children:[a.jsx(ST,{className:"inline-flex items-center",children:s}),a.jsxs(wT,{children:[e&&t&&a.jsxs(a.Fragment,{children:[a.jsxs(Ec,{onClick:t,children:["Hide “",e,"”"]}),a.jsx(dC,{})]}),a.jsx(Ec,{onClick:n,children:"Configure status bar..."}),a.jsx(Ec,{onClick:e_,children:"Reset to defaults"})]})]})}function zo(e){var t;return((t=Yb.find(n=>n.key===e))==null?void 0:t.label)??null}const oG=80,lG=500;function Z0t({sessionId:e,sessionStatus:t,isStreaming:n,onChipClick:s,syncConnectionState:r,agentName:i,agentColor:o,agentEmoji:l,agentPath:c}){var kn;const u=Us(),d=ude(e),f=Pne(e,t,n,d.runtime),{showShortcutChips:m,showStatusBarCwd:g,setShowStatusBarCwd:y,showStatusBarPermission:b,setShowStatusBarPermission:S,showStatusBarRuntime:w,setShowStatusBarRuntime:C,showStatusBarModel:T,setShowStatusBarModel:E,showStatusBarContext:j,setShowStatusBarContext:_,showStatusBarCache:N,setShowStatusBarCache:R,showStatusBarUsage:O,setShowStatusBarUsage:M,showStatusBarGit:L,setShowStatusBarGit:P,showStatusBarSound:$,setShowStatusBarSound:q,showStatusBarPolling:K,setShowStatusBarPolling:B,enableNotificationSound:V,setEnableNotificationSound:Q,enableMessagePolling:re,setEnableMessagePolling:U}=we(),G=Wne(e),W=G0t(G),F=qn(x.useCallback(Tt=>{var Vt;return((Vt=Tt.sessions[e])==null?void 0:Vt.contextUsage)??null},[e])),X=qn(B0t(Tt=>{var Cn;const Vt=(Cn=Tt.sessions[e])==null?void 0:Cn.sessionStatus;return!(Vt!=null&&Vt.cacheReadTokens)&&!(Vt!=null&&Vt.cacheCreationTokens)?null:{cacheReadTokens:Vt.cacheReadTokens??0,cacheCreationTokens:Vt.cacheCreationTokens??0,contextTokens:Vt.contextTokens}})),J=W.cacheStatus??X,ae=W.contextPercent??f.contextPercent,oe=W.usage,{data:de}=hnt(f.cwd),me=U0t(f.cwd),{data:Re}=D5e(e),{data:Fe}=aI({sessionId:e||void 0,runtime:d.runtime??void 0}),Le=((kn=Fe==null?void 0:Fe.find(Tt=>Tt.value===f.model))==null?void 0:kn.supportsAutoMode)??!1,Xe=Q5e(e),ze=qn(Tt=>Tt.recordAutoConfirmed),[Mt,Ft]=x.useState(!1),Pe=x.useCallback(Tt=>{if(Tt==="auto"&&!Xe){Ft(!0);return}f.updateSession({permissionMode:Tt})},[Xe,f]),He=x.useCallback(()=>{ze(e),f.updateSession({permissionMode:"auto"}),Ft(!1)},[ze,e,f]),gt=tP(d.runtime),Ct=(gt==null?void 0:gt.supportsCostTracking)??!0,[cn,Nt]=x.useState(!1),[ts,Ln]=x.useState(!1),[Oe,le]=x.useState(()=>u?parseInt(localStorage.getItem(Dn.GESTURE_HINT_COUNT)||"0",10)<3:!1);x.useEffect(()=>{if(!Oe)return;const Tt=setTimeout(()=>{le(!1);const Vt=parseInt(localStorage.getItem(Dn.GESTURE_HINT_COUNT)||"0",10);localStorage.setItem(Dn.GESTURE_HINT_COUNT,String(Vt+1))},yo.GESTURE_HINT_DISMISS_MS);return()=>clearTimeout(Tt)},[Oe]);const Ce=x.useCallback(()=>{le(!1);const Tt=parseInt(localStorage.getItem(Dn.GESTURE_HINT_COUNT)||"0",10);localStorage.setItem(Dn.GESTURE_HINT_COUNT,String(Tt+1))},[]),Ge=(Tt,Vt)=>{const{offset:Cn,velocity:ns}=Vt;Cn.y>oG||ns.y>lG?Ln(!0):(Cn.y<-oG||ns.y<-lG)&&Ln(!1)},ot=a.jsx(em,{children:a.jsxs(gn,{children:[a.jsx(Vce,{open:cn,onOpenChange:Nt,children:a.jsx(xn,{asChild:!0,children:a.jsx("button",{type:"button","aria-label":"Configure status bar",className:"text-muted-foreground/50 hover:text-muted-foreground inline-flex shrink-0 items-center transition-colors duration-150",children:a.jsx(K3e,{className:"size-3"})})})}),a.jsx(yn,{side:"top",children:a.jsx("p",{children:"Configure status bar"})})]})}),bt=a.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[a.jsxs(bT,{children:[a.jsx(ST,{className:"min-w-0 flex-1",children:a.jsxs(Wi,{sessionId:e,isStreaming:n,children:[a.jsx(Wi.Item,{itemKey:"cwd",visible:g&&!!f.cwd,children:a.jsx(Fo,{itemLabel:zo("cwd"),onHide:()=>y(!1),onConfigure:()=>Nt(!0),children:f.cwd&&a.jsx(unt,{cwd:f.cwd})})}),a.jsx(Wi.Item,{itemKey:"git",visible:L,children:a.jsx(Fo,{itemLabel:zo("git"),onHide:()=>P(!1),onConfigure:()=>Nt(!0),children:a.jsx(pnt,{data:de,workspace:me})})}),a.jsx(Wi.Item,{itemKey:"permission",visible:b,children:a.jsx(Fo,{itemLabel:zo("permission"),onHide:()=>S(!1),onConfigure:()=>Nt(!0),children:a.jsx(vnt,{mode:f.permissionMode,onChangeMode:Pe,disabled:!e,runtime:d.runtime,modelSupportsAutoMode:Le})})}),a.jsx(Wi.Item,{itemKey:"runtime",visible:w&&d.runtime!==null,children:a.jsx(Fo,{itemLabel:zo("runtime"),onHide:()=>C(!1),onConfigure:()=>Nt(!0),children:d.runtime!==null&&a.jsx(Vnt,{runtime:d.runtime,model:d.model,onChangeRuntime:d.onChangeRuntime,canSelect:d.canSelect})})}),a.jsx(Wi.Item,{itemKey:"model",visible:T,children:a.jsx(Fo,{itemLabel:zo("model"),onHide:()=>E(!1),onConfigure:()=>Nt(!0),children:a.jsx(tst,{model:f.model,onChangeModel:Tt=>f.updateSession({model:Tt}),effort:f.effort,onChangeEffort:Tt=>f.updateSession({effort:Tt??void 0}),fastMode:f.fastMode,onChangeFastMode:Tt=>f.updateSession({fastMode:Tt}),disabled:!e,sessionId:e||void 0,runtime:d.runtime})})}),a.jsx(Wi.Item,{itemKey:"cache",visible:N&&J!==null,children:a.jsx(Fo,{itemLabel:zo("cache"),onHide:()=>R(!1),onConfigure:()=>Nt(!0),children:J&&a.jsx(nst,{cacheReadTokens:J.cacheReadTokens,cacheCreationTokens:J.cacheCreationTokens,contextTokens:J.contextTokens})})}),a.jsx(Wi.Item,{itemKey:"context",visible:j&&ae!==null,children:a.jsx(Fo,{itemLabel:zo("context"),onHide:()=>_(!1),onConfigure:()=>Nt(!0),children:ae!==null&&a.jsx(sst,{percent:ae,contextUsage:F})})}),a.jsx(Wi.Item,{itemKey:"usage",visible:O&&oe!==null&&JU(oe)&&Ct,children:a.jsx(Fo,{itemLabel:zo("usage"),onHide:()=>M(!1),onConfigure:()=>Nt(!0),children:oe&&JU(oe)&&a.jsx(rst,{usage:oe})})}),a.jsx(Wi.Item,{itemKey:"sound",visible:$,children:a.jsx(Fo,{itemLabel:zo("sound"),onHide:()=>q(!1),onConfigure:()=>Nt(!0),children:a.jsx(ist,{enabled:V,onToggle:()=>Q(!V)})})}),a.jsx(Wi.Item,{itemKey:"polling",visible:K,children:a.jsx(Fo,{itemLabel:zo("polling"),onHide:()=>B(!1),onConfigure:()=>Nt(!0),children:a.jsx(ast,{enabled:re,onToggle:()=>U(!re)})})}),a.jsx(lst,{connectionState:r}),a.jsx(Wi.Item,{itemKey:"subagents",visible:!!Re&&Re.length>0,children:Re&&Re.length>0&&a.jsx(ust,{subagents:Re})})]})}),a.jsxs(wT,{children:[a.jsx(Ec,{onClick:()=>Nt(!0),children:"Configure status bar..."}),a.jsx(Ec,{onClick:e_,children:"Reset to defaults"})]})]}),ot,a.jsx(qnt,{open:Mt,onOpenChange:Ft,onConfirm:He})]});return u?a.jsxs(a.Fragment,{children:[a.jsx(te.div,{animate:Oe?{y:[0,8,0]}:void 0,transition:Oe?{duration:1.2,repeat:2}:void 0,children:a.jsx(Y0t,{collapsed:ts,onToggle:()=>Ln(Tt=>!Tt)})}),a.jsx(Ue,{children:Oe&&a.jsx(te.p,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:Ce,className:"text-muted-foreground cursor-pointer text-center text-xs",children:"Swipe to collapse"})}),a.jsx(Ue,{initial:!1,children:!ts&&a.jsxs(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{type:"spring",stiffness:300,damping:30},className:"overflow-hidden",drag:"y",dragConstraints:{top:0,bottom:0},dragElastic:.2,onDragEnd:Ge,style:{touchAction:"pan-y"},children:[m&&a.jsx(aG,{onChipClick:s,agentName:i,agentColor:o,agentEmoji:l,agentPath:c}),bt]})})]}):a.jsxs(a.Fragment,{children:[a.jsx(Ue,{children:m&&a.jsx(aG,{onChipClick:s,agentName:i,agentColor:o,agentEmoji:l,agentPath:c})}),bt]})}function X0t({color:e}){const t=[{bx:"-8px",by:"-10px",delay:"0s"},{bx:"8px",by:"-8px",delay:"0.03s"},{bx:"-6px",by:"6px",delay:"0.06s"},{bx:"10px",by:"4px",delay:"0.09s"},{bx:"0px",by:"-12px",delay:"0.04s"},{bx:"-10px",by:"0px",delay:"0.07s"},{bx:"6px",by:"10px",delay:"0.05s"},{bx:"-4px",by:"-6px",delay:"0.08s"}];return a.jsx("div",{className:"pointer-events-none absolute inset-0",children:t.map((n,s)=>a.jsx("span",{className:"absolute top-1/2 left-1/2 size-[3px] rounded-full",style:{backgroundColor:e,"--bx":n.bx,"--by":n.by,animation:`burst-particle 0.5s ease-out ${n.delay} forwards`}},s))})}function Q0t({agent:e,index:t}){const n=x.useMemo(()=>({animationDelay:`${t*.09}s`}),[t]),[s,r]=x.useState("running"),i=x.useRef(e.status);return x.useEffect(()=>{if(i.current==="running"&&(e.status==="complete"||e.status==="error")&&s==="running"){r("celebrating");const o=setTimeout(()=>r("done"),350);return()=>clearTimeout(o)}i.current=e.status},[e.status,s]),s==="done"?a.jsx("div",{className:"relative inline-flex",children:e.status==="error"?a.jsxs("svg",{className:"check-appear h-6 w-[22px]",viewBox:"0 0 22 24",children:[a.jsx("circle",{cx:"11",cy:"12",r:"7",fill:"none",stroke:e.color,strokeWidth:"1.5",opacity:"0.3"}),a.jsx("line",{x1:"8",y1:"9",x2:"14",y2:"15",stroke:e.color,strokeWidth:"2",strokeLinecap:"round"}),a.jsx("line",{x1:"14",y1:"9",x2:"8",y2:"15",stroke:e.color,strokeWidth:"2",strokeLinecap:"round"})]}):a.jsxs("svg",{className:"check-appear h-6 w-[22px]",viewBox:"0 0 22 24",children:[a.jsx("circle",{cx:"11",cy:"12",r:"7",fill:"none",stroke:e.color,strokeWidth:"1.5",opacity:"0.3"}),a.jsx("polyline",{points:"7,12 10,15 15,9",fill:"none",stroke:e.color,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}):a.jsxs("div",{className:"group relative inline-flex",children:[a.jsx("svg",{className:"h-6 w-[22px] shrink-0",style:{"--c":e.color},viewBox:"0 0 22 24","aria-label":e.description,children:a.jsxs("g",{className:"r-all",style:n,children:[a.jsx("circle",{cx:"11",cy:"4.5",r:"2.8",fill:"var(--c)"}),a.jsx("circle",{cx:"12.3",cy:"3.7",r:"0.6",fill:"hsl(0 0% 100% / 0.7)"}),a.jsx("ellipse",{cx:"11",cy:"10.5",rx:"2.5",ry:"3.5",fill:"var(--c)"}),a.jsxs("g",{className:"r-rua",style:n,children:[a.jsx("line",{x1:"12",y1:"9",x2:"14",y2:"11",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),a.jsx("g",{className:"r-rfa",style:n,children:a.jsx("line",{x1:"14",y1:"11",x2:"14.5",y2:"13",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]}),a.jsxs("g",{className:"r-lua",style:n,children:[a.jsx("line",{x1:"10",y1:"9",x2:"8",y2:"11",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),a.jsx("g",{className:"r-lfa",style:n,children:a.jsx("line",{x1:"8",y1:"11",x2:"7.5",y2:"13",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]}),a.jsxs("g",{className:"r-rt",style:n,children:[a.jsx("line",{x1:"11",y1:"14",x2:"13",y2:"17",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),a.jsx("g",{className:"r-rs",style:n,children:a.jsx("line",{x1:"13",y1:"17",x2:"13.5",y2:"21",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]}),a.jsxs("g",{className:"r-lt",style:n,children:[a.jsx("line",{x1:"11",y1:"14",x2:"9",y2:"17",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),a.jsx("g",{className:"r-ls",style:n,children:a.jsx("line",{x1:"9",y1:"17",x2:"8.5",y2:"21",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]})]})}),s==="celebrating"&&a.jsx(X0t,{color:e.color}),s==="running"&&a.jsxs("div",{className:Y("pointer-events-none absolute bottom-[calc(100%+8px)] left-1/2","-translate-x-1/2 translate-y-1 opacity-0 transition-all duration-150","group-hover:translate-y-0 group-hover:opacity-100","border-border bg-popover z-10 rounded-lg border px-3 py-2 whitespace-nowrap","text-foreground text-[0.6875rem] shadow-lg"),children:[a.jsxs("div",{className:"mb-0.5 flex items-center gap-1.5 font-semibold",children:[a.jsx("div",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:e.color}}),e.description]}),a.jsxs("div",{className:"text-muted-foreground font-mono text-[0.625rem]",children:[e.toolUses??0," tool calls · ",Math.round((e.durationMs??0)/1e3),"s"]}),e.lastToolName&&a.jsxs("div",{className:"text-muted-foreground/60 mt-0.5 font-mono text-[0.5625rem]",children:["Last: ",e.lastToolName]}),a.jsx("div",{className:"border-t-border absolute top-full left-1/2 -translate-x-1/2 border-5 border-transparent"})]})]})}function J0t({bashTasks:e}){const t=Ds(),n=e.filter(r=>r.taskType==="bash"),s=n.length;return s===0?null:a.jsxs("div",{role:"status","aria-live":"polite","aria-label":`${s} bash task${s!==1?"s":""} running`,className:"flex items-center gap-1.5",children:[a.jsx(Ue,{mode:"popLayout",children:n.map(r=>a.jsxs(te.div,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:{duration:.25},className:"relative flex size-3 items-center justify-center",children:[r.status==="running"&&!t&&a.jsx("span",{className:"task-dot-tasks absolute inset-0 rounded-full opacity-40",style:{backgroundColor:r.color,animation:"task-dot-tasks 2s ease-in-out infinite"}}),a.jsx("span",{className:"relative size-1.5 rounded-full",style:{backgroundColor:r.color}})]},r.taskId))}),a.jsxs("span",{className:"text-muted-foreground text-xs whitespace-nowrap",children:[s," task",s!==1?"s":""]})]})}const ext=3e3;function txt({taskType:e,onConfirm:t}){const[n,s]=x.useState(!1),r=x.useRef(null);x.useEffect(()=>()=>{r.current&&clearTimeout(r.current)},[]),x.useEffect(()=>{if(n)return r.current=setTimeout(()=>{s(!1)},ext),()=>{r.current&&clearTimeout(r.current)}},[n]);const i=x.useCallback(()=>{if(e==="bash"){t();return}n?(r.current&&clearTimeout(r.current),s(!1),t()):s(!0)},[e,n,t]),o=x.useCallback(l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),i())},[i]);return a.jsx("button",{onClick:i,onKeyDown:o,className:Y("flex shrink-0 items-center justify-center rounded transition-all duration-150","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-1",n?"bg-destructive/20 text-destructive hover:bg-destructive/30 px-1.5 py-0.5 text-[0.625rem] font-medium":"text-muted-foreground/40 hover:text-destructive size-4"),"aria-label":n?"Confirm stop task":"Stop task",tabIndex:0,children:n?"Stop?":a.jsx(es,{className:"size-3"})})}function nxt({task:e,onStop:t}){const n=e.taskType==="agent"?e.description??"Background agent":e.command??"Background task",s=e.durationMs?Math.round(e.durationMs/1e3):0,r=e.status==="running";return a.jsxs("div",{className:Y("flex items-center gap-2 rounded-md px-2 py-1 text-xs",r?"bg-muted":"bg-muted/50 opacity-60"),children:[a.jsx("span",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:e.color}}),a.jsx("span",{className:"text-muted-foreground/60 shrink-0 text-[0.625rem] tracking-wider uppercase",children:e.taskType}),a.jsx("span",{className:"text-foreground min-w-0 flex-1 truncate",children:n}),e.taskType==="agent"&&e.toolUses!==void 0&&e.toolUses>0&&a.jsxs("span",{className:"text-muted-foreground/60 shrink-0 font-mono text-[0.625rem]",children:[e.toolUses," tools"]}),s>0&&a.jsxs("span",{className:"text-muted-foreground/60 shrink-0 font-mono text-[0.625rem]",children:[s,"s"]}),r&&a.jsx(txt,{taskType:e.taskType,onConfirm:t})]})}function sxt({tasks:e,onStopTask:t}){return a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.25,ease:[.16,1,.3,1]},className:"border-border overflow-hidden border-t px-2 py-1.5",children:a.jsx("div",{className:"flex flex-col gap-1",children:e.map(n=>a.jsx(nxt,{task:n,onStop:()=>t(n.taskId)},n.taskId))})})}const QD=4,Ude=[.16,1,.3,1],rxt={width:{duration:.4,ease:Ude},opacity:{duration:.25}};function ixt({tasks:e,onStopTask:t}){const[n,s]=x.useState(!1),r=Ds(),i=e.filter(g=>g.taskType==="agent"),o=e.filter(g=>g.taskType==="bash"),l=e.length,c=i.slice(0,QD),u=i.length-QD,d=i.reduce((g,y)=>g+(y.toolUses??0),0),f=Math.max(0,...e.map(g=>Math.round((g.durationMs??0)/1e3))),m=r?{duration:0}:{duration:.35,ease:Ude};return a.jsx(Ue,{children:l>0&&a.jsxs(te.div,{role:"status","aria-live":"polite","aria-label":`${l} background task${l!==1?"s":""} running`,initial:{opacity:0,y:6,maxHeight:0},animate:{opacity:1,y:0,maxHeight:n?400:44},exit:{opacity:0,maxHeight:0},transition:m,className:"border-border bg-card overflow-hidden rounded-lg border",children:[a.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[i.length>0&&a.jsx(axt,{visibleAgents:c,overflowAgentCount:u,allAgentTasks:i}),i.length>0&&o.length>0&&a.jsx("div",{className:"bg-border h-4 w-px shrink-0"}),o.length>0&&a.jsx(J0t,{bashTasks:o}),a.jsxs("span",{className:"text-muted-foreground text-xs whitespace-nowrap",children:[a.jsx("strong",{className:"text-foreground font-semibold",children:l})," task",l!==1?"s":""," running"]}),a.jsxs("span",{className:"text-muted-foreground/60 ml-auto font-mono text-[0.6875rem] whitespace-nowrap",children:[d>0&&a.jsxs(a.Fragment,{children:[d," tools · "]}),f,"s"]}),a.jsxs("button",{type:"button",onClick:()=>s(g=>!g),className:"text-muted-foreground hover:text-foreground ml-1 flex shrink-0 items-center gap-1 transition-colors duration-150","aria-label":n?"Collapse task details":"Expand task details","aria-expanded":n,children:[a.jsx("span",{className:"text-[0.625rem] tabular-nums",children:l}),a.jsx(Hs,{className:Y("size-3.5 transition-transform duration-200",n&&"rotate-180")})]})]}),a.jsx(Ue,{children:n&&a.jsx(sxt,{tasks:e,onStopTask:t})})]},"background-task-bar")})}function axt({visibleAgents:e,overflowAgentCount:t,allAgentTasks:n}){return a.jsxs("div",{className:"flex items-center gap-0",children:[a.jsx(Ue,{mode:"popLayout",children:e.map((s,r)=>a.jsx(te.div,{initial:{width:0,opacity:0},animate:{width:22,opacity:1},exit:{width:0,opacity:0},transition:rxt,className:"shrink-0",children:a.jsx(Q0t,{agent:{taskId:s.taskId,description:s.description??"",status:s.status==="running"?"running":s.status==="complete"?"complete":"error",color:s.color,toolUses:s.toolUses,lastToolName:s.lastToolName,durationMs:s.durationMs,summary:s.summary},index:r})},s.taskId))}),t>0&&a.jsx(oxt,{count:t,overflowTasks:n.slice(QD)})]})}function oxt({count:e,overflowTasks:t}){return a.jsxs("div",{className:"group relative",children:[a.jsxs("div",{className:"text-muted-foreground bg-muted flex size-6 shrink-0 items-center justify-center rounded-full text-[0.625rem] font-semibold","aria-label":`${e} more agents running`,children:["+",e]}),a.jsxs("div",{className:Y("pointer-events-none absolute bottom-[calc(100%+8px)] left-1/2","-translate-x-1/2 translate-y-1 opacity-0 transition-all duration-150","group-hover:translate-y-0 group-hover:opacity-100","border-border bg-popover z-10 rounded-lg border px-3 py-2 whitespace-nowrap","text-foreground text-[0.6875rem] shadow-lg"),children:[t.map(n=>a.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[a.jsx("div",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:n.color}}),a.jsx("span",{className:"text-[0.625rem]",children:n.description})]},n.taskId)),a.jsx("div",{className:"border-t-border absolute top-full left-1/2 -translate-x-1/2 border-5 border-transparent"})]})]})}const cG=["hsl(210 80% 60%)","hsl(150 60% 50%)","hsl(270 60% 65%)","hsl(36 90% 55%)","hsl(340 75% 60%)"],uG=5e3,lxt=1e3,cxt=1500;function uxt(e){const t=x.useRef(new Map),n=x.useRef(0),s=x.useRef(new Map),r=x.useRef(new Set),[,i]=x.useState(0),o=x.useMemo(()=>{const c=new Map;for(const u of e)for(const d of u.parts)d.type==="background_task"&&c.set(d.taskId,d);return c},[e]);x.useEffect(()=>{if(!Array.from(o.values()).some(d=>d.taskType==="bash"&&d.status==="running"&&Date.now()-d.startedAt<uG))return;const u=setInterval(()=>{i(d=>d+1)},lxt);return()=>clearInterval(u)},[o]);const l=x.useRef(new Set);for(const[c,u]of o){const d=s.current.get(c),f=u.status==="complete"||u.status==="error"||u.status==="stopped";d==="running"&&f&&!r.current.has(c)&&r.current.add(c),s.current.set(c,u.status)}return x.useEffect(()=>{for(const c of r.current)l.current.has(c)||(l.current.add(c),setTimeout(()=>{r.current.delete(c),l.current.delete(c),i(u=>u+1)},cxt))},[o]),x.useMemo(()=>{const c=Date.now(),u=[];for(const[d,f]of o){const m=f.status==="running",g=r.current.has(d);!m&&!g||f.taskType==="bash"&&m&&c-f.startedAt<uG||(t.current.has(d)||(t.current.set(d,cG[n.current%cG.length]),n.current+=1),u.push({taskId:f.taskId,taskType:f.taskType,status:f.status,color:t.current.get(d),startedAt:f.startedAt,description:f.description,toolUses:f.toolUses,lastToolName:f.lastToolName,durationMs:f.durationMs,summary:f.summary,command:f.command}))}return u},[o])}function dxt({status:e,sessionBusy:t,sessionId:n,selectedCwd:s,onFlush:r}){const i=dIe(n??""),[o,l]=x.useState(null),c=x.useRef(r);c.current=r;const u=x.useRef(i);u.current=i;const d=x.useRef(o);d.current=o;const f=x.useRef("idle"),m=x.useRef(null);x.useEffect(()=>{const E=n===null?null:`${n}\0${s??""}`;if(m.current!==E&&(m.current=E,f.current="idle",l(null)),f.current==="streaming"&&e==="idle"&&n){const j=u.current,_=d.current;if(j.length>0&&!t){const N=_===0?j.length>1?1:null:0;if(N!==null){const R=j[N];Zn.getState().removeQueuedMessage(n,R.id),_!==null&&_>N&&l(O=>O!==null?O-1:null),c.current(R.content,n,{queued:!0})}}}f.current=e},[e,t,n,s]);const g=x.useCallback(E=>{!E.trim()||!n||Zn.getState().enqueueMessage(n,E)},[n]),y=x.useCallback((E,j)=>{const _=i[E];!_||!n||Zn.getState().updateQueuedMessage(n,_.id,j)},[i,n]),b=x.useCallback(E=>{const j=i[E];j&&n&&Zn.getState().removeQueuedMessage(n,j.id),l(_=>_===E?null:_!==null&&_>E?_-1:_)},[i,n]),S=x.useCallback(E=>{var j;return l(E),((j=i[E])==null?void 0:j.content)??""},[i]),w=x.useCallback(()=>{l(null)},[]),C=x.useCallback(E=>{o!==null&&(y(o,E),l(null))},[o,y]),T=x.useCallback(()=>{n&&Zn.getState().clearQueue(n),l(null)},[n]);return{queue:i,editingIndex:o,addToQueue:g,updateQueueItem:y,removeFromQueue:b,startEditing:S,cancelEditing:w,saveEditing:C,clearQueue:T}}function fxt({input:e,setInput:t,status:n,sessionBusy:s,sessionId:r,selectedCwd:i,onFlush:o,tryNativeCommand:l,chatInputRef:c}){const u=x.useRef("");x.useEffect(()=>{u.current=""},[r]);const d=dxt({status:n,sessionBusy:s,sessionId:r,selectedCwd:i,onFlush:o}),f=x.useCallback(()=>{const C=e.trim();if(!C)return;const T=l(C);if(T.handled){T.ran&&t("");return}d.addToQueue(C),t("")},[e,d,t,l]),m=x.useCallback(C=>{var E;d.editingIndex===null&&(u.current=e);const T=d.startEditing(C);t(T),(E=c.current)==null||E.focus()},[e,d,t,c]),g=x.useCallback(()=>{d.editingIndex!==null&&e.trim()&&(d.saveEditing(e.trim()),t(u.current))},[e,d,t]),y=x.useCallback(()=>{d.cancelEditing(),t(u.current)},[d,t]),b=x.useCallback(C=>{d.editingIndex===C&&t(u.current),d.removeFromQueue(C)},[d,t]),S=x.useCallback(()=>{if(d.editingIndex===null){u.current=e;const C=d.startEditing(d.queue.length-1);t(C)}else if(d.editingIndex>0){const C=d.startEditing(d.editingIndex-1);t(C)}else d.cancelEditing(),t(u.current)},[e,d,t]),w=x.useCallback(()=>{if(d.editingIndex!==null)if(d.editingIndex<d.queue.length-1){const C=d.startEditing(d.editingIndex+1);t(C)}else d.cancelEditing(),t(u.current)},[d,t]);return{queue:d.queue,editingIndex:d.editingIndex,handleQueue:f,handleQueueEdit:m,handleQueueSaveEdit:g,handleQueueCancelEdit:y,handleQueueRemove:b,handleQueueNavigateUp:S,handleQueueNavigateDown:w}}function hxt(e){return e.type.startsWith("image/")}function mxt({files:e,onRemove:t}){const n=x.useMemo(()=>{const s=new Map;for(const r of e)hxt(r.file)&&s.set(r.id,URL.createObjectURL(r.file));return s},[e]);return x.useEffect(()=>()=>{for(const s of n.values())URL.revokeObjectURL(s)},[n]),a.jsx("div",{className:"flex flex-wrap gap-1.5 px-1 pb-1.5",children:a.jsx(Ue,{children:e.map(s=>{const r=n.get(s.id);return a.jsxs(te.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},className:"bg-muted flex items-center gap-1 rounded-md px-2 py-1 text-xs",children:[s.status==="uploading"?a.jsx(Sn,{className:"text-muted-foreground size-3 animate-spin"}):s.status==="error"?a.jsx(Hh,{className:"text-destructive size-3"}):r?a.jsx("img",{src:r,alt:"",className:"size-5 shrink-0 rounded object-cover"}):a.jsx(qh,{className:"text-muted-foreground size-3"}),a.jsx("span",{className:"max-w-32 truncate",children:s.file.name}),s.status==="uploading"&&a.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[s.progress,"%"]}),a.jsx("button",{type:"button",onClick:()=>t(s.id),className:"text-muted-foreground hover:text-foreground -mr-0.5 ml-0.5 rounded-sm p-0.5","aria-label":`Remove ${s.file.name}`,children:a.jsx(es,{className:"size-3"})})]},s.id)})})})}function pxt({queue:e,editingIndex:t,onEdit:n,onRemove:s}){return e.length===0?null:a.jsxs(te.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2},className:"mb-1.5 overflow-hidden",children:[a.jsxs("div",{className:"text-muted-foreground mb-1 text-xs font-medium",children:["Queued (",e.length,")"]}),a.jsx("div",{className:"space-y-0.5",children:a.jsx(Ue,{mode:"popLayout",children:e.map((r,i)=>a.jsx(te.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0,transition:{type:"spring",stiffness:320,damping:28}},exit:{opacity:0,scale:.95,transition:{duration:.15}},layout:!0,children:a.jsxs("button",{type:"button",onClick:()=>n(i),className:Y("group flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-left transition-colors",t===i?"border-primary bg-muted border-l-2":"hover:bg-muted/50"),children:[a.jsxs("span",{className:"text-muted-foreground shrink-0 text-xs font-medium",children:[i+1,"."]}),a.jsx("span",{className:"text-muted-foreground line-clamp-1 flex-1 text-sm",children:r.content}),a.jsx("span",{role:"button",tabIndex:0,onClick:o=>{o.stopPropagation(),s(i)},onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&(o.stopPropagation(),o.preventDefault(),s(i))},className:"text-muted-foreground hover:text-foreground shrink-0 rounded-sm p-0.5 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100","aria-label":`Remove queued message ${i+1}`,children:a.jsx(es,{className:"size-3"})})]})},r.id))})})]})}function gxt({filteredCommands:e,selectedIndex:t,onSelect:n}){const s=x.useMemo(()=>{const r=[],i=new Map;let o=0;for(const l of e){const c=l.namespace??"built-in";i.has(c)||i.set(c,[]),i.get(c).push({cmd:l,index:o++})}for(const[l,c]of i)r.push({namespace:l,items:c});return r},[e]);return x.useEffect(()=>{const r=document.getElementById(`command-item-${t}`);r&&r.scrollIntoView({block:"nearest"})},[t]),a.jsx(te.div,{initial:{opacity:0,scale:.98,y:4},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:4},transition:{duration:.15,ease:[0,0,.2,1]},className:"bg-popover max-h-80 overflow-hidden rounded-lg border shadow-lg",onMouseDown:r=>r.preventDefault(),children:a.jsx("div",{id:"command-palette-listbox",role:"listbox",className:"max-h-72 overflow-y-auto p-1.5",children:e.length===0?a.jsx("div",{className:"text-muted-foreground px-2 py-4 text-center text-sm",children:"No commands found."}):s.map(({namespace:r,items:i},o)=>a.jsxs("div",{children:[o>0&&a.jsx("div",{className:"bg-border mx-2 my-1.5 h-px"}),a.jsx("div",{className:"text-muted-foreground/70 px-2 pt-1.5 pb-1 text-[11px] font-medium tracking-wide uppercase",children:r}),i.map(({cmd:l,index:c})=>{const u=c===t;return a.jsxs("div",{id:`command-item-${c}`,role:"option","aria-selected":u,"data-selected":u,tabIndex:u?0:-1,onClick:()=>n(l),onKeyDown:d=>{d.key==="Enter"&&n(l)},className:"data-[selected=true]:bg-accent hover:bg-muted cursor-pointer rounded-md px-2 py-1.5 transition-colors duration-100",children:[a.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[a.jsx("span",{className:"text-foreground shrink-0 font-mono text-[13px] font-medium",children:l.fullCommand}),l.argumentHint&&a.jsx("span",{className:"text-muted-foreground/50 shrink-0 font-mono text-xs",children:l.argumentHint}),l.matchedAlias&&a.jsxs("span",{className:"text-muted-foreground/60 ml-auto shrink-0 font-mono text-[11px] italic",children:["matched /",l.matchedAlias.replace(/^\//,"")]})]}),l.description&&a.jsx("p",{className:"text-muted-foreground mt-0.5 truncate text-xs leading-normal",children:l.description})]},l.fullCommand)})]},r))})})}function xxt({text:e,indices:t,startOffset:n=0}){const s=new Set(t.map(r=>r-n));return a.jsx(a.Fragment,{children:e.split("").map((r,i)=>s.has(i)?a.jsx("span",{className:"text-foreground font-semibold",children:r},i):a.jsx("span",{children:r},i))})}function yxt({filteredFiles:e,selectedIndex:t,onSelect:n}){return x.useEffect(()=>{const s=document.getElementById(`file-item-${t}`);s&&s.scrollIntoView({block:"nearest"})},[t]),a.jsx(te.div,{initial:{opacity:0,scale:.98,y:4},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:4},transition:{duration:.15,ease:[0,0,.2,1]},className:"bg-popover max-h-80 overflow-hidden rounded-lg border shadow-lg",onMouseDown:s=>s.preventDefault(),children:a.jsx("div",{id:"file-palette-listbox",role:"listbox",className:"max-h-72 overflow-y-auto p-1.5",children:e.length===0?a.jsx("div",{className:"text-muted-foreground px-2 py-4 text-center text-sm",children:"No files found."}):e.map((s,r)=>{const i=r===t,o=s.isDirectory?th:qh;return a.jsxs("div",{id:`file-item-${r}`,role:"option","aria-selected":i,"data-selected":i,tabIndex:i?0:-1,onClick:()=>n(s),onKeyDown:l=>{l.key==="Enter"&&n(s)},className:"data-[selected=true]:bg-accent hover:bg-muted flex cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 transition-colors duration-100",children:[a.jsx(o,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("span",{className:"text-foreground truncate text-sm font-medium",children:a.jsx(xxt,{text:s.filename,indices:s.indices,startOffset:s.directory.length})}),s.directory&&a.jsx("p",{className:"text-muted-foreground/70 truncate text-xs leading-normal",children:s.directory})]})]},s.path)})})})}function vxt(e){const t=je();return st({queryKey:["files",{cwd:e??null}],queryFn:()=>t.listFiles(e),enabled:!!e,staleTime:ia.FILES_STALE_TIME_MS,gcTime:ia.FILES_GC_TIME_MS})}const bxt=5e3;function Sxt(e){const t=[...e];for(let n=t.length-1;n>0;n--){const s=Math.floor(Math.random()*(n+1));[t[n],t[s]]=[t[s],t[n]]}return t}function wxt({defaultText:e,hints:t,enabled:n,intervalMs:s=bxt}){const[r,i]=x.useState(0),[o]=x.useState(()=>t.length>0?Sxt(t):[]);x.useEffect(()=>{if(!n||t.length===0){i(0);return}const d=setInterval(()=>i(f=>f+1),s);return()=>clearInterval(d)},[n,t.length,s]);const l=r>0&&r%2===1,c=Math.floor(r/2)%(o.length||1);return{text:l?o[c]??e:e,key:r,isHint:l}}const kxt={initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4}},Cxt={duration:.3,ease:"easeInOut"};function Ext({text:e,animationKey:t}){return a.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-start overflow-hidden py-0.5",children:a.jsx(Ue,{mode:"wait",children:a.jsx(te.span,{variants:kxt,initial:"initial",animate:"animate",exit:"exit",transition:Cxt,className:"text-muted-foreground truncate text-sm",children:e},t)})})}const Txt=["Type @ to mention a file","Type / to browse commands","Shift+Enter for a new line","Drop or paste files to attach","Press Esc twice to clear"],_xt=new Map([["1km","application/vnd.1000minds.decision-model+xml"],["3dml","text/vnd.in3d.3dml"],["3ds","image/x-3ds"],["3g2","video/3gpp2"],["3gp","video/3gp"],["3gpp","video/3gpp"],["3mf","model/3mf"],["7z","application/x-7z-compressed"],["7zip","application/x-7z-compressed"],["123","application/vnd.lotus-1-2-3"],["aab","application/x-authorware-bin"],["aac","audio/x-acc"],["aam","application/x-authorware-map"],["aas","application/x-authorware-seg"],["abw","application/x-abiword"],["ac","application/vnd.nokia.n-gage.ac+xml"],["ac3","audio/ac3"],["acc","application/vnd.americandynamics.acc"],["ace","application/x-ace-compressed"],["acu","application/vnd.acucobol"],["acutc","application/vnd.acucorp"],["adp","audio/adpcm"],["aep","application/vnd.audiograph"],["afm","application/x-font-type1"],["afp","application/vnd.ibm.modcap"],["ahead","application/vnd.ahead.space"],["ai","application/pdf"],["aif","audio/x-aiff"],["aifc","audio/x-aiff"],["aiff","audio/x-aiff"],["air","application/vnd.adobe.air-application-installer-package+zip"],["ait","application/vnd.dvb.ait"],["ami","application/vnd.amiga.ami"],["amr","audio/amr"],["apk","application/vnd.android.package-archive"],["apng","image/apng"],["appcache","text/cache-manifest"],["application","application/x-ms-application"],["apr","application/vnd.lotus-approach"],["arc","application/x-freearc"],["arj","application/x-arj"],["asc","application/pgp-signature"],["asf","video/x-ms-asf"],["asm","text/x-asm"],["aso","application/vnd.accpac.simply.aso"],["asx","video/x-ms-asf"],["atc","application/vnd.acucorp"],["atom","application/atom+xml"],["atomcat","application/atomcat+xml"],["atomdeleted","application/atomdeleted+xml"],["atomsvc","application/atomsvc+xml"],["atx","application/vnd.antix.game-component"],["au","audio/x-au"],["avi","video/x-msvideo"],["avif","image/avif"],["aw","application/applixware"],["azf","application/vnd.airzip.filesecure.azf"],["azs","application/vnd.airzip.filesecure.azs"],["azv","image/vnd.airzip.accelerator.azv"],["azw","application/vnd.amazon.ebook"],["b16","image/vnd.pco.b16"],["bat","application/x-msdownload"],["bcpio","application/x-bcpio"],["bdf","application/x-font-bdf"],["bdm","application/vnd.syncml.dm+wbxml"],["bdoc","application/x-bdoc"],["bed","application/vnd.realvnc.bed"],["bh2","application/vnd.fujitsu.oasysprs"],["bin","application/octet-stream"],["blb","application/x-blorb"],["blorb","application/x-blorb"],["bmi","application/vnd.bmi"],["bmml","application/vnd.balsamiq.bmml+xml"],["bmp","image/bmp"],["book","application/vnd.framemaker"],["box","application/vnd.previewsystems.box"],["boz","application/x-bzip2"],["bpk","application/octet-stream"],["bpmn","application/octet-stream"],["bsp","model/vnd.valve.source.compiled-map"],["btif","image/prs.btif"],["buffer","application/octet-stream"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["c","text/x-c"],["c4d","application/vnd.clonk.c4group"],["c4f","application/vnd.clonk.c4group"],["c4g","application/vnd.clonk.c4group"],["c4p","application/vnd.clonk.c4group"],["c4u","application/vnd.clonk.c4group"],["c11amc","application/vnd.cluetrust.cartomobile-config"],["c11amz","application/vnd.cluetrust.cartomobile-config-pkg"],["cab","application/vnd.ms-cab-compressed"],["caf","audio/x-caf"],["cap","application/vnd.tcpdump.pcap"],["car","application/vnd.curl.car"],["cat","application/vnd.ms-pki.seccat"],["cb7","application/x-cbr"],["cba","application/x-cbr"],["cbr","application/x-cbr"],["cbt","application/x-cbr"],["cbz","application/x-cbr"],["cc","text/x-c"],["cco","application/x-cocoa"],["cct","application/x-director"],["ccxml","application/ccxml+xml"],["cdbcmsg","application/vnd.contact.cmsg"],["cda","application/x-cdf"],["cdf","application/x-netcdf"],["cdfx","application/cdfx+xml"],["cdkey","application/vnd.mediastation.cdkey"],["cdmia","application/cdmi-capability"],["cdmic","application/cdmi-container"],["cdmid","application/cdmi-domain"],["cdmio","application/cdmi-object"],["cdmiq","application/cdmi-queue"],["cdr","application/cdr"],["cdx","chemical/x-cdx"],["cdxml","application/vnd.chemdraw+xml"],["cdy","application/vnd.cinderella"],["cer","application/pkix-cert"],["cfs","application/x-cfs-compressed"],["cgm","image/cgm"],["chat","application/x-chat"],["chm","application/vnd.ms-htmlhelp"],["chrt","application/vnd.kde.kchart"],["cif","chemical/x-cif"],["cii","application/vnd.anser-web-certificate-issue-initiation"],["cil","application/vnd.ms-artgalry"],["cjs","application/node"],["cla","application/vnd.claymore"],["class","application/octet-stream"],["clkk","application/vnd.crick.clicker.keyboard"],["clkp","application/vnd.crick.clicker.palette"],["clkt","application/vnd.crick.clicker.template"],["clkw","application/vnd.crick.clicker.wordbank"],["clkx","application/vnd.crick.clicker"],["clp","application/x-msclip"],["cmc","application/vnd.cosmocaller"],["cmdf","chemical/x-cmdf"],["cml","chemical/x-cml"],["cmp","application/vnd.yellowriver-custom-menu"],["cmx","image/x-cmx"],["cod","application/vnd.rim.cod"],["coffee","text/coffeescript"],["com","application/x-msdownload"],["conf","text/plain"],["cpio","application/x-cpio"],["cpp","text/x-c"],["cpt","application/mac-compactpro"],["crd","application/x-mscardfile"],["crl","application/pkix-crl"],["crt","application/x-x509-ca-cert"],["crx","application/x-chrome-extension"],["cryptonote","application/vnd.rig.cryptonote"],["csh","application/x-csh"],["csl","application/vnd.citationstyles.style+xml"],["csml","chemical/x-csml"],["csp","application/vnd.commonspace"],["csr","application/octet-stream"],["css","text/css"],["cst","application/x-director"],["csv","text/csv"],["cu","application/cu-seeme"],["curl","text/vnd.curl"],["cww","application/prs.cww"],["cxt","application/x-director"],["cxx","text/x-c"],["dae","model/vnd.collada+xml"],["daf","application/vnd.mobius.daf"],["dart","application/vnd.dart"],["dataless","application/vnd.fdsn.seed"],["davmount","application/davmount+xml"],["dbf","application/vnd.dbf"],["dbk","application/docbook+xml"],["dcr","application/x-director"],["dcurl","text/vnd.curl.dcurl"],["dd2","application/vnd.oma.dd2+xml"],["ddd","application/vnd.fujixerox.ddd"],["ddf","application/vnd.syncml.dmddf+xml"],["dds","image/vnd.ms-dds"],["deb","application/x-debian-package"],["def","text/plain"],["deploy","application/octet-stream"],["der","application/x-x509-ca-cert"],["dfac","application/vnd.dreamfactory"],["dgc","application/x-dgc-compressed"],["dic","text/x-c"],["dir","application/x-director"],["dis","application/vnd.mobius.dis"],["disposition-notification","message/disposition-notification"],["dist","application/octet-stream"],["distz","application/octet-stream"],["djv","image/vnd.djvu"],["djvu","image/vnd.djvu"],["dll","application/octet-stream"],["dmg","application/x-apple-diskimage"],["dmn","application/octet-stream"],["dmp","application/vnd.tcpdump.pcap"],["dms","application/octet-stream"],["dna","application/vnd.dna"],["doc","application/msword"],["docm","application/vnd.ms-word.template.macroEnabled.12"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["dot","application/msword"],["dotm","application/vnd.ms-word.template.macroEnabled.12"],["dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"],["dp","application/vnd.osgi.dp"],["dpg","application/vnd.dpgraph"],["dra","audio/vnd.dra"],["drle","image/dicom-rle"],["dsc","text/prs.lines.tag"],["dssc","application/dssc+der"],["dtb","application/x-dtbook+xml"],["dtd","application/xml-dtd"],["dts","audio/vnd.dts"],["dtshd","audio/vnd.dts.hd"],["dump","application/octet-stream"],["dvb","video/vnd.dvb.file"],["dvi","application/x-dvi"],["dwd","application/atsc-dwd+xml"],["dwf","model/vnd.dwf"],["dwg","image/vnd.dwg"],["dxf","image/vnd.dxf"],["dxp","application/vnd.spotfire.dxp"],["dxr","application/x-director"],["ear","application/java-archive"],["ecelp4800","audio/vnd.nuera.ecelp4800"],["ecelp7470","audio/vnd.nuera.ecelp7470"],["ecelp9600","audio/vnd.nuera.ecelp9600"],["ecma","application/ecmascript"],["edm","application/vnd.novadigm.edm"],["edx","application/vnd.novadigm.edx"],["efif","application/vnd.picsel"],["ei6","application/vnd.pg.osasli"],["elc","application/octet-stream"],["emf","image/emf"],["eml","message/rfc822"],["emma","application/emma+xml"],["emotionml","application/emotionml+xml"],["emz","application/x-msmetafile"],["eol","audio/vnd.digital-winds"],["eot","application/vnd.ms-fontobject"],["eps","application/postscript"],["epub","application/epub+zip"],["es","application/ecmascript"],["es3","application/vnd.eszigno3+xml"],["esa","application/vnd.osgi.subsystem"],["esf","application/vnd.epson.esf"],["et3","application/vnd.eszigno3+xml"],["etx","text/x-setext"],["eva","application/x-eva"],["evy","application/x-envoy"],["exe","application/octet-stream"],["exi","application/exi"],["exp","application/express"],["exr","image/aces"],["ext","application/vnd.novadigm.ext"],["ez","application/andrew-inset"],["ez2","application/vnd.ezpix-album"],["ez3","application/vnd.ezpix-package"],["f","text/x-fortran"],["f4v","video/mp4"],["f77","text/x-fortran"],["f90","text/x-fortran"],["fbs","image/vnd.fastbidsheet"],["fcdt","application/vnd.adobe.formscentral.fcdt"],["fcs","application/vnd.isac.fcs"],["fdf","application/vnd.fdf"],["fdt","application/fdt+xml"],["fe_launch","application/vnd.denovo.fcselayout-link"],["fg5","application/vnd.fujitsu.oasysgp"],["fgd","application/x-director"],["fh","image/x-freehand"],["fh4","image/x-freehand"],["fh5","image/x-freehand"],["fh7","image/x-freehand"],["fhc","image/x-freehand"],["fig","application/x-xfig"],["fits","image/fits"],["flac","audio/x-flac"],["fli","video/x-fli"],["flo","application/vnd.micrografx.flo"],["flv","video/x-flv"],["flw","application/vnd.kde.kivio"],["flx","text/vnd.fmi.flexstor"],["fly","text/vnd.fly"],["fm","application/vnd.framemaker"],["fnc","application/vnd.frogans.fnc"],["fo","application/vnd.software602.filler.form+xml"],["for","text/x-fortran"],["fpx","image/vnd.fpx"],["frame","application/vnd.framemaker"],["fsc","application/vnd.fsc.weblaunch"],["fst","image/vnd.fst"],["ftc","application/vnd.fluxtime.clip"],["fti","application/vnd.anser-web-funds-transfer-initiation"],["fvt","video/vnd.fvt"],["fxp","application/vnd.adobe.fxp"],["fxpl","application/vnd.adobe.fxp"],["fzs","application/vnd.fuzzysheet"],["g2w","application/vnd.geoplan"],["g3","image/g3fax"],["g3w","application/vnd.geospace"],["gac","application/vnd.groove-account"],["gam","application/x-tads"],["gbr","application/rpki-ghostbusters"],["gca","application/x-gca-compressed"],["gdl","model/vnd.gdl"],["gdoc","application/vnd.google-apps.document"],["geo","application/vnd.dynageo"],["geojson","application/geo+json"],["gex","application/vnd.geometry-explorer"],["ggb","application/vnd.geogebra.file"],["ggt","application/vnd.geogebra.tool"],["ghf","application/vnd.groove-help"],["gif","image/gif"],["gim","application/vnd.groove-identity-message"],["glb","model/gltf-binary"],["gltf","model/gltf+json"],["gml","application/gml+xml"],["gmx","application/vnd.gmx"],["gnumeric","application/x-gnumeric"],["gpg","application/gpg-keys"],["gph","application/vnd.flographit"],["gpx","application/gpx+xml"],["gqf","application/vnd.grafeq"],["gqs","application/vnd.grafeq"],["gram","application/srgs"],["gramps","application/x-gramps-xml"],["gre","application/vnd.geometry-explorer"],["grv","application/vnd.groove-injector"],["grxml","application/srgs+xml"],["gsf","application/x-font-ghostscript"],["gsheet","application/vnd.google-apps.spreadsheet"],["gslides","application/vnd.google-apps.presentation"],["gtar","application/x-gtar"],["gtm","application/vnd.groove-tool-message"],["gtw","model/vnd.gtw"],["gv","text/vnd.graphviz"],["gxf","application/gxf"],["gxt","application/vnd.geonext"],["gz","application/gzip"],["gzip","application/gzip"],["h","text/x-c"],["h261","video/h261"],["h263","video/h263"],["h264","video/h264"],["hal","application/vnd.hal+xml"],["hbci","application/vnd.hbci"],["hbs","text/x-handlebars-template"],["hdd","application/x-virtualbox-hdd"],["hdf","application/x-hdf"],["heic","image/heic"],["heics","image/heic-sequence"],["heif","image/heif"],["heifs","image/heif-sequence"],["hej2","image/hej2k"],["held","application/atsc-held+xml"],["hh","text/x-c"],["hjson","application/hjson"],["hlp","application/winhlp"],["hpgl","application/vnd.hp-hpgl"],["hpid","application/vnd.hp-hpid"],["hps","application/vnd.hp-hps"],["hqx","application/mac-binhex40"],["hsj2","image/hsj2"],["htc","text/x-component"],["htke","application/vnd.kenameaapp"],["htm","text/html"],["html","text/html"],["hvd","application/vnd.yamaha.hv-dic"],["hvp","application/vnd.yamaha.hv-voice"],["hvs","application/vnd.yamaha.hv-script"],["i2g","application/vnd.intergeo"],["icc","application/vnd.iccprofile"],["ice","x-conference/x-cooltalk"],["icm","application/vnd.iccprofile"],["ico","image/x-icon"],["ics","text/calendar"],["ief","image/ief"],["ifb","text/calendar"],["ifm","application/vnd.shana.informed.formdata"],["iges","model/iges"],["igl","application/vnd.igloader"],["igm","application/vnd.insors.igm"],["igs","model/iges"],["igx","application/vnd.micrografx.igx"],["iif","application/vnd.shana.informed.interchange"],["img","application/octet-stream"],["imp","application/vnd.accpac.simply.imp"],["ims","application/vnd.ms-ims"],["in","text/plain"],["ini","text/plain"],["ink","application/inkml+xml"],["inkml","application/inkml+xml"],["install","application/x-install-instructions"],["iota","application/vnd.astraea-software.iota"],["ipfix","application/ipfix"],["ipk","application/vnd.shana.informed.package"],["irm","application/vnd.ibm.rights-management"],["irp","application/vnd.irepository.package+xml"],["iso","application/x-iso9660-image"],["itp","application/vnd.shana.informed.formtemplate"],["its","application/its+xml"],["ivp","application/vnd.immervision-ivp"],["ivu","application/vnd.immervision-ivu"],["jad","text/vnd.sun.j2me.app-descriptor"],["jade","text/jade"],["jam","application/vnd.jam"],["jar","application/java-archive"],["jardiff","application/x-java-archive-diff"],["java","text/x-java-source"],["jhc","image/jphc"],["jisp","application/vnd.jisp"],["jls","image/jls"],["jlt","application/vnd.hp-jlyt"],["jng","image/x-jng"],["jnlp","application/x-java-jnlp-file"],["joda","application/vnd.joost.joda-archive"],["jp2","image/jp2"],["jpe","image/jpeg"],["jpeg","image/jpeg"],["jpf","image/jpx"],["jpg","image/jpeg"],["jpg2","image/jp2"],["jpgm","video/jpm"],["jpgv","video/jpeg"],["jph","image/jph"],["jpm","video/jpm"],["jpx","image/jpx"],["js","application/javascript"],["json","application/json"],["json5","application/json5"],["jsonld","application/ld+json"],["jsonl","application/jsonl"],["jsonml","application/jsonml+json"],["jsx","text/jsx"],["jxr","image/jxr"],["jxra","image/jxra"],["jxrs","image/jxrs"],["jxs","image/jxs"],["jxsc","image/jxsc"],["jxsi","image/jxsi"],["jxss","image/jxss"],["kar","audio/midi"],["karbon","application/vnd.kde.karbon"],["kdb","application/octet-stream"],["kdbx","application/x-keepass2"],["key","application/x-iwork-keynote-sffkey"],["kfo","application/vnd.kde.kformula"],["kia","application/vnd.kidspiration"],["kml","application/vnd.google-earth.kml+xml"],["kmz","application/vnd.google-earth.kmz"],["kne","application/vnd.kinar"],["knp","application/vnd.kinar"],["kon","application/vnd.kde.kontour"],["kpr","application/vnd.kde.kpresenter"],["kpt","application/vnd.kde.kpresenter"],["kpxx","application/vnd.ds-keypoint"],["ksp","application/vnd.kde.kspread"],["ktr","application/vnd.kahootz"],["ktx","image/ktx"],["ktx2","image/ktx2"],["ktz","application/vnd.kahootz"],["kwd","application/vnd.kde.kword"],["kwt","application/vnd.kde.kword"],["lasxml","application/vnd.las.las+xml"],["latex","application/x-latex"],["lbd","application/vnd.llamagraphics.life-balance.desktop"],["lbe","application/vnd.llamagraphics.life-balance.exchange+xml"],["les","application/vnd.hhe.lesson-player"],["less","text/less"],["lgr","application/lgr+xml"],["lha","application/octet-stream"],["link66","application/vnd.route66.link66+xml"],["list","text/plain"],["list3820","application/vnd.ibm.modcap"],["listafp","application/vnd.ibm.modcap"],["litcoffee","text/coffeescript"],["lnk","application/x-ms-shortcut"],["log","text/plain"],["lostxml","application/lost+xml"],["lrf","application/octet-stream"],["lrm","application/vnd.ms-lrm"],["ltf","application/vnd.frogans.ltf"],["lua","text/x-lua"],["luac","application/x-lua-bytecode"],["lvp","audio/vnd.lucent.voice"],["lwp","application/vnd.lotus-wordpro"],["lzh","application/octet-stream"],["m1v","video/mpeg"],["m2a","audio/mpeg"],["m2v","video/mpeg"],["m3a","audio/mpeg"],["m3u","text/plain"],["m3u8","application/vnd.apple.mpegurl"],["m4a","audio/x-m4a"],["m4p","application/mp4"],["m4s","video/iso.segment"],["m4u","application/vnd.mpegurl"],["m4v","video/x-m4v"],["m13","application/x-msmediaview"],["m14","application/x-msmediaview"],["m21","application/mp21"],["ma","application/mathematica"],["mads","application/mads+xml"],["maei","application/mmt-aei+xml"],["mag","application/vnd.ecowin.chart"],["maker","application/vnd.framemaker"],["man","text/troff"],["manifest","text/cache-manifest"],["map","application/json"],["mar","application/octet-stream"],["markdown","text/markdown"],["mathml","application/mathml+xml"],["mb","application/mathematica"],["mbk","application/vnd.mobius.mbk"],["mbox","application/mbox"],["mc1","application/vnd.medcalcdata"],["mcd","application/vnd.mcd"],["mcurl","text/vnd.curl.mcurl"],["md","text/markdown"],["mdb","application/x-msaccess"],["mdi","image/vnd.ms-modi"],["mdx","text/mdx"],["me","text/troff"],["mesh","model/mesh"],["meta4","application/metalink4+xml"],["metalink","application/metalink+xml"],["mets","application/mets+xml"],["mfm","application/vnd.mfmp"],["mft","application/rpki-manifest"],["mgp","application/vnd.osgeo.mapguide.package"],["mgz","application/vnd.proteus.magazine"],["mid","audio/midi"],["midi","audio/midi"],["mie","application/x-mie"],["mif","application/vnd.mif"],["mime","message/rfc822"],["mj2","video/mj2"],["mjp2","video/mj2"],["mjs","application/javascript"],["mk3d","video/x-matroska"],["mka","audio/x-matroska"],["mkd","text/x-markdown"],["mks","video/x-matroska"],["mkv","video/x-matroska"],["mlp","application/vnd.dolby.mlp"],["mmd","application/vnd.chipnuts.karaoke-mmd"],["mmf","application/vnd.smaf"],["mml","text/mathml"],["mmr","image/vnd.fujixerox.edmics-mmr"],["mng","video/x-mng"],["mny","application/x-msmoney"],["mobi","application/x-mobipocket-ebook"],["mods","application/mods+xml"],["mov","video/quicktime"],["movie","video/x-sgi-movie"],["mp2","audio/mpeg"],["mp2a","audio/mpeg"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mp4a","audio/mp4"],["mp4s","application/mp4"],["mp4v","video/mp4"],["mp21","application/mp21"],["mpc","application/vnd.mophun.certificate"],["mpd","application/dash+xml"],["mpe","video/mpeg"],["mpeg","video/mpeg"],["mpg","video/mpeg"],["mpg4","video/mp4"],["mpga","audio/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["mpm","application/vnd.blueice.multipass"],["mpn","application/vnd.mophun.application"],["mpp","application/vnd.ms-project"],["mpt","application/vnd.ms-project"],["mpy","application/vnd.ibm.minipay"],["mqy","application/vnd.mobius.mqy"],["mrc","application/marc"],["mrcx","application/marcxml+xml"],["ms","text/troff"],["mscml","application/mediaservercontrol+xml"],["mseed","application/vnd.fdsn.mseed"],["mseq","application/vnd.mseq"],["msf","application/vnd.epson.msf"],["msg","application/vnd.ms-outlook"],["msh","model/mesh"],["msi","application/x-msdownload"],["msl","application/vnd.mobius.msl"],["msm","application/octet-stream"],["msp","application/octet-stream"],["msty","application/vnd.muvee.style"],["mtl","model/mtl"],["mts","model/vnd.mts"],["mus","application/vnd.musician"],["musd","application/mmt-usd+xml"],["musicxml","application/vnd.recordare.musicxml+xml"],["mvb","application/x-msmediaview"],["mvt","application/vnd.mapbox-vector-tile"],["mwf","application/vnd.mfer"],["mxf","application/mxf"],["mxl","application/vnd.recordare.musicxml"],["mxmf","audio/mobile-xmf"],["mxml","application/xv+xml"],["mxs","application/vnd.triscape.mxs"],["mxu","video/vnd.mpegurl"],["n-gage","application/vnd.nokia.n-gage.symbian.install"],["n3","text/n3"],["nb","application/mathematica"],["nbp","application/vnd.wolfram.player"],["nc","application/x-netcdf"],["ncx","application/x-dtbncx+xml"],["nfo","text/x-nfo"],["ngdat","application/vnd.nokia.n-gage.data"],["nitf","application/vnd.nitf"],["nlu","application/vnd.neurolanguage.nlu"],["nml","application/vnd.enliven"],["nnd","application/vnd.noblenet-directory"],["nns","application/vnd.noblenet-sealer"],["nnw","application/vnd.noblenet-web"],["npx","image/vnd.net-fpx"],["nq","application/n-quads"],["nsc","application/x-conference"],["nsf","application/vnd.lotus-notes"],["nt","application/n-triples"],["ntf","application/vnd.nitf"],["numbers","application/x-iwork-numbers-sffnumbers"],["nzb","application/x-nzb"],["oa2","application/vnd.fujitsu.oasys2"],["oa3","application/vnd.fujitsu.oasys3"],["oas","application/vnd.fujitsu.oasys"],["obd","application/x-msbinder"],["obgx","application/vnd.openblox.game+xml"],["obj","model/obj"],["oda","application/oda"],["odb","application/vnd.oasis.opendocument.database"],["odc","application/vnd.oasis.opendocument.chart"],["odf","application/vnd.oasis.opendocument.formula"],["odft","application/vnd.oasis.opendocument.formula-template"],["odg","application/vnd.oasis.opendocument.graphics"],["odi","application/vnd.oasis.opendocument.image"],["odm","application/vnd.oasis.opendocument.text-master"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogex","model/vnd.opengex"],["ogg","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["omdoc","application/omdoc+xml"],["onepkg","application/onenote"],["onetmp","application/onenote"],["onetoc","application/onenote"],["onetoc2","application/onenote"],["opf","application/oebps-package+xml"],["opml","text/x-opml"],["oprc","application/vnd.palm"],["opus","audio/ogg"],["org","text/x-org"],["osf","application/vnd.yamaha.openscoreformat"],["osfpvg","application/vnd.yamaha.openscoreformat.osfpvg+xml"],["osm","application/vnd.openstreetmap.data+xml"],["otc","application/vnd.oasis.opendocument.chart-template"],["otf","font/otf"],["otg","application/vnd.oasis.opendocument.graphics-template"],["oth","application/vnd.oasis.opendocument.text-web"],["oti","application/vnd.oasis.opendocument.image-template"],["otp","application/vnd.oasis.opendocument.presentation-template"],["ots","application/vnd.oasis.opendocument.spreadsheet-template"],["ott","application/vnd.oasis.opendocument.text-template"],["ova","application/x-virtualbox-ova"],["ovf","application/x-virtualbox-ovf"],["owl","application/rdf+xml"],["oxps","application/oxps"],["oxt","application/vnd.openofficeorg.extension"],["p","text/x-pascal"],["p7a","application/x-pkcs7-signature"],["p7b","application/x-pkcs7-certificates"],["p7c","application/pkcs7-mime"],["p7m","application/pkcs7-mime"],["p7r","application/x-pkcs7-certreqresp"],["p7s","application/pkcs7-signature"],["p8","application/pkcs8"],["p10","application/x-pkcs10"],["p12","application/x-pkcs12"],["pac","application/x-ns-proxy-autoconfig"],["pages","application/x-iwork-pages-sffpages"],["pas","text/x-pascal"],["paw","application/vnd.pawaafile"],["pbd","application/vnd.powerbuilder6"],["pbm","image/x-portable-bitmap"],["pcap","application/vnd.tcpdump.pcap"],["pcf","application/x-font-pcf"],["pcl","application/vnd.hp-pcl"],["pclxl","application/vnd.hp-pclxl"],["pct","image/x-pict"],["pcurl","application/vnd.curl.pcurl"],["pcx","image/x-pcx"],["pdb","application/x-pilot"],["pde","text/x-processing"],["pdf","application/pdf"],["pem","application/x-x509-user-cert"],["pfa","application/x-font-type1"],["pfb","application/x-font-type1"],["pfm","application/x-font-type1"],["pfr","application/font-tdpfr"],["pfx","application/x-pkcs12"],["pgm","image/x-portable-graymap"],["pgn","application/x-chess-pgn"],["pgp","application/pgp"],["php","application/x-httpd-php"],["php3","application/x-httpd-php"],["php4","application/x-httpd-php"],["phps","application/x-httpd-php-source"],["phtml","application/x-httpd-php"],["pic","image/x-pict"],["pkg","application/octet-stream"],["pki","application/pkixcmp"],["pkipath","application/pkix-pkipath"],["pkpass","application/vnd.apple.pkpass"],["pl","application/x-perl"],["plb","application/vnd.3gpp.pic-bw-large"],["plc","application/vnd.mobius.plc"],["plf","application/vnd.pocketlearn"],["pls","application/pls+xml"],["pm","application/x-perl"],["pml","application/vnd.ctc-posml"],["png","image/png"],["pnm","image/x-portable-anymap"],["portpkg","application/vnd.macports.portpkg"],["pot","application/vnd.ms-powerpoint"],["potm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["potx","application/vnd.openxmlformats-officedocument.presentationml.template"],["ppa","application/vnd.ms-powerpoint"],["ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"],["ppd","application/vnd.cups-ppd"],["ppm","image/x-portable-pixmap"],["pps","application/vnd.ms-powerpoint"],["ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"],["ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"],["ppt","application/powerpoint"],["pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["pqa","application/vnd.palm"],["prc","application/x-pilot"],["pre","application/vnd.lotus-freelance"],["prf","application/pics-rules"],["provx","application/provenance+xml"],["ps","application/postscript"],["psb","application/vnd.3gpp.pic-bw-small"],["psd","application/x-photoshop"],["psf","application/x-font-linux-psf"],["pskcxml","application/pskc+xml"],["pti","image/prs.pti"],["ptid","application/vnd.pvi.ptid1"],["pub","application/x-mspublisher"],["pvb","application/vnd.3gpp.pic-bw-var"],["pwn","application/vnd.3m.post-it-notes"],["pya","audio/vnd.ms-playready.media.pya"],["pyv","video/vnd.ms-playready.media.pyv"],["qam","application/vnd.epson.quickanime"],["qbo","application/vnd.intu.qbo"],["qfx","application/vnd.intu.qfx"],["qps","application/vnd.publishare-delta-tree"],["qt","video/quicktime"],["qwd","application/vnd.quark.quarkxpress"],["qwt","application/vnd.quark.quarkxpress"],["qxb","application/vnd.quark.quarkxpress"],["qxd","application/vnd.quark.quarkxpress"],["qxl","application/vnd.quark.quarkxpress"],["qxt","application/vnd.quark.quarkxpress"],["ra","audio/x-realaudio"],["ram","audio/x-pn-realaudio"],["raml","application/raml+yaml"],["rapd","application/route-apd+xml"],["rar","application/x-rar"],["ras","image/x-cmu-raster"],["rcprofile","application/vnd.ipunplugged.rcprofile"],["rdf","application/rdf+xml"],["rdz","application/vnd.data-vision.rdz"],["relo","application/p2p-overlay+xml"],["rep","application/vnd.businessobjects"],["res","application/x-dtbresource+xml"],["rgb","image/x-rgb"],["rif","application/reginfo+xml"],["rip","audio/vnd.rip"],["ris","application/x-research-info-systems"],["rl","application/resource-lists+xml"],["rlc","image/vnd.fujixerox.edmics-rlc"],["rld","application/resource-lists-diff+xml"],["rm","audio/x-pn-realaudio"],["rmi","audio/midi"],["rmp","audio/x-pn-realaudio-plugin"],["rms","application/vnd.jcp.javame.midlet-rms"],["rmvb","application/vnd.rn-realmedia-vbr"],["rnc","application/relax-ng-compact-syntax"],["rng","application/xml"],["roa","application/rpki-roa"],["roff","text/troff"],["rp9","application/vnd.cloanto.rp9"],["rpm","audio/x-pn-realaudio-plugin"],["rpss","application/vnd.nokia.radio-presets"],["rpst","application/vnd.nokia.radio-preset"],["rq","application/sparql-query"],["rs","application/rls-services+xml"],["rsa","application/x-pkcs7"],["rsat","application/atsc-rsat+xml"],["rsd","application/rsd+xml"],["rsheet","application/urc-ressheet+xml"],["rss","application/rss+xml"],["rtf","text/rtf"],["rtx","text/richtext"],["run","application/x-makeself"],["rusd","application/route-usd+xml"],["rv","video/vnd.rn-realvideo"],["s","text/x-asm"],["s3m","audio/s3m"],["saf","application/vnd.yamaha.smaf-audio"],["sass","text/x-sass"],["sbml","application/sbml+xml"],["sc","application/vnd.ibm.secure-container"],["scd","application/x-msschedule"],["scm","application/vnd.lotus-screencam"],["scq","application/scvp-cv-request"],["scs","application/scvp-cv-response"],["scss","text/x-scss"],["scurl","text/vnd.curl.scurl"],["sda","application/vnd.stardivision.draw"],["sdc","application/vnd.stardivision.calc"],["sdd","application/vnd.stardivision.impress"],["sdkd","application/vnd.solent.sdkm+xml"],["sdkm","application/vnd.solent.sdkm+xml"],["sdp","application/sdp"],["sdw","application/vnd.stardivision.writer"],["sea","application/octet-stream"],["see","application/vnd.seemail"],["seed","application/vnd.fdsn.seed"],["sema","application/vnd.sema"],["semd","application/vnd.semd"],["semf","application/vnd.semf"],["senmlx","application/senml+xml"],["sensmlx","application/sensml+xml"],["ser","application/java-serialized-object"],["setpay","application/set-payment-initiation"],["setreg","application/set-registration-initiation"],["sfd-hdstx","application/vnd.hydrostatix.sof-data"],["sfs","application/vnd.spotfire.sfs"],["sfv","text/x-sfv"],["sgi","image/sgi"],["sgl","application/vnd.stardivision.writer-global"],["sgm","text/sgml"],["sgml","text/sgml"],["sh","application/x-sh"],["shar","application/x-shar"],["shex","text/shex"],["shf","application/shf+xml"],["shtml","text/html"],["sid","image/x-mrsid-image"],["sieve","application/sieve"],["sig","application/pgp-signature"],["sil","audio/silk"],["silo","model/mesh"],["sis","application/vnd.symbian.install"],["sisx","application/vnd.symbian.install"],["sit","application/x-stuffit"],["sitx","application/x-stuffitx"],["siv","application/sieve"],["skd","application/vnd.koan"],["skm","application/vnd.koan"],["skp","application/vnd.koan"],["skt","application/vnd.koan"],["sldm","application/vnd.ms-powerpoint.slide.macroenabled.12"],["sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"],["slim","text/slim"],["slm","text/slim"],["sls","application/route-s-tsid+xml"],["slt","application/vnd.epson.salt"],["sm","application/vnd.stepmania.stepchart"],["smf","application/vnd.stardivision.math"],["smi","application/smil"],["smil","application/smil"],["smv","video/x-smv"],["smzip","application/vnd.stepmania.package"],["snd","audio/basic"],["snf","application/x-font-snf"],["so","application/octet-stream"],["spc","application/x-pkcs7-certificates"],["spdx","text/spdx"],["spf","application/vnd.yamaha.smaf-phrase"],["spl","application/x-futuresplash"],["spot","text/vnd.in3d.spot"],["spp","application/scvp-vp-response"],["spq","application/scvp-vp-request"],["spx","audio/ogg"],["sql","application/x-sql"],["src","application/x-wais-source"],["srt","application/x-subrip"],["sru","application/sru+xml"],["srx","application/sparql-results+xml"],["ssdl","application/ssdl+xml"],["sse","application/vnd.kodak-descriptor"],["ssf","application/vnd.epson.ssf"],["ssml","application/ssml+xml"],["sst","application/octet-stream"],["st","application/vnd.sailingtracker.track"],["stc","application/vnd.sun.xml.calc.template"],["std","application/vnd.sun.xml.draw.template"],["stf","application/vnd.wt.stf"],["sti","application/vnd.sun.xml.impress.template"],["stk","application/hyperstudio"],["stl","model/stl"],["stpx","model/step+xml"],["stpxz","model/step-xml+zip"],["stpz","model/step+zip"],["str","application/vnd.pg.format"],["stw","application/vnd.sun.xml.writer.template"],["styl","text/stylus"],["stylus","text/stylus"],["sub","text/vnd.dvb.subtitle"],["sus","application/vnd.sus-calendar"],["susp","application/vnd.sus-calendar"],["sv4cpio","application/x-sv4cpio"],["sv4crc","application/x-sv4crc"],["svc","application/vnd.dvb.service"],["svd","application/vnd.svd"],["svg","image/svg+xml"],["svgz","image/svg+xml"],["swa","application/x-director"],["swf","application/x-shockwave-flash"],["swi","application/vnd.aristanetworks.swi"],["swidtag","application/swid+xml"],["sxc","application/vnd.sun.xml.calc"],["sxd","application/vnd.sun.xml.draw"],["sxg","application/vnd.sun.xml.writer.global"],["sxi","application/vnd.sun.xml.impress"],["sxm","application/vnd.sun.xml.math"],["sxw","application/vnd.sun.xml.writer"],["t","text/troff"],["t3","application/x-t3vm-image"],["t38","image/t38"],["taglet","application/vnd.mynfc"],["tao","application/vnd.tao.intent-module-archive"],["tap","image/vnd.tencent.tap"],["tar","application/x-tar"],["tcap","application/vnd.3gpp2.tcap"],["tcl","application/x-tcl"],["td","application/urc-targetdesc+xml"],["teacher","application/vnd.smart.teacher"],["tei","application/tei+xml"],["teicorpus","application/tei+xml"],["tex","application/x-tex"],["texi","application/x-texinfo"],["texinfo","application/x-texinfo"],["text","text/plain"],["tfi","application/thraud+xml"],["tfm","application/x-tex-tfm"],["tfx","image/tiff-fx"],["tga","image/x-tga"],["tgz","application/x-tar"],["thmx","application/vnd.ms-officetheme"],["tif","image/tiff"],["tiff","image/tiff"],["tk","application/x-tcl"],["tmo","application/vnd.tmobile-livetv"],["toml","application/toml"],["torrent","application/x-bittorrent"],["tpl","application/vnd.groove-tool-template"],["tpt","application/vnd.trid.tpt"],["tr","text/troff"],["tra","application/vnd.trueapp"],["trig","application/trig"],["trm","application/x-msterminal"],["ts","video/mp2t"],["tsd","application/timestamped-data"],["tsv","text/tab-separated-values"],["ttc","font/collection"],["ttf","font/ttf"],["ttl","text/turtle"],["ttml","application/ttml+xml"],["twd","application/vnd.simtech-mindmapper"],["twds","application/vnd.simtech-mindmapper"],["txd","application/vnd.genomatix.tuxedo"],["txf","application/vnd.mobius.txf"],["txt","text/plain"],["u8dsn","message/global-delivery-status"],["u8hdr","message/global-headers"],["u8mdn","message/global-disposition-notification"],["u8msg","message/global"],["u32","application/x-authorware-bin"],["ubj","application/ubjson"],["udeb","application/x-debian-package"],["ufd","application/vnd.ufdl"],["ufdl","application/vnd.ufdl"],["ulx","application/x-glulx"],["umj","application/vnd.umajin"],["unityweb","application/vnd.unity"],["uoml","application/vnd.uoml+xml"],["uri","text/uri-list"],["uris","text/uri-list"],["urls","text/uri-list"],["usdz","model/vnd.usdz+zip"],["ustar","application/x-ustar"],["utz","application/vnd.uiq.theme"],["uu","text/x-uuencode"],["uva","audio/vnd.dece.audio"],["uvd","application/vnd.dece.data"],["uvf","application/vnd.dece.data"],["uvg","image/vnd.dece.graphic"],["uvh","video/vnd.dece.hd"],["uvi","image/vnd.dece.graphic"],["uvm","video/vnd.dece.mobile"],["uvp","video/vnd.dece.pd"],["uvs","video/vnd.dece.sd"],["uvt","application/vnd.dece.ttml+xml"],["uvu","video/vnd.uvvu.mp4"],["uvv","video/vnd.dece.video"],["uvva","audio/vnd.dece.audio"],["uvvd","application/vnd.dece.data"],["uvvf","application/vnd.dece.data"],["uvvg","image/vnd.dece.graphic"],["uvvh","video/vnd.dece.hd"],["uvvi","image/vnd.dece.graphic"],["uvvm","video/vnd.dece.mobile"],["uvvp","video/vnd.dece.pd"],["uvvs","video/vnd.dece.sd"],["uvvt","application/vnd.dece.ttml+xml"],["uvvu","video/vnd.uvvu.mp4"],["uvvv","video/vnd.dece.video"],["uvvx","application/vnd.dece.unspecified"],["uvvz","application/vnd.dece.zip"],["uvx","application/vnd.dece.unspecified"],["uvz","application/vnd.dece.zip"],["vbox","application/x-virtualbox-vbox"],["vbox-extpack","application/x-virtualbox-vbox-extpack"],["vcard","text/vcard"],["vcd","application/x-cdlink"],["vcf","text/x-vcard"],["vcg","application/vnd.groove-vcard"],["vcs","text/x-vcalendar"],["vcx","application/vnd.vcx"],["vdi","application/x-virtualbox-vdi"],["vds","model/vnd.sap.vds"],["vhd","application/x-virtualbox-vhd"],["vis","application/vnd.visionary"],["viv","video/vnd.vivo"],["vlc","application/videolan"],["vmdk","application/x-virtualbox-vmdk"],["vob","video/x-ms-vob"],["vor","application/vnd.stardivision.writer"],["vox","application/x-authorware-bin"],["vrml","model/vrml"],["vsd","application/vnd.visio"],["vsf","application/vnd.vsf"],["vss","application/vnd.visio"],["vst","application/vnd.visio"],["vsw","application/vnd.visio"],["vtf","image/vnd.valve.source.texture"],["vtt","text/vtt"],["vtu","model/vnd.vtu"],["vxml","application/voicexml+xml"],["w3d","application/x-director"],["wad","application/x-doom"],["wadl","application/vnd.sun.wadl+xml"],["war","application/java-archive"],["wasm","application/wasm"],["wav","audio/x-wav"],["wax","audio/x-ms-wax"],["wbmp","image/vnd.wap.wbmp"],["wbs","application/vnd.criticaltools.wbs+xml"],["wbxml","application/wbxml"],["wcm","application/vnd.ms-works"],["wdb","application/vnd.ms-works"],["wdp","image/vnd.ms-photo"],["weba","audio/webm"],["webapp","application/x-web-app-manifest+json"],["webm","video/webm"],["webmanifest","application/manifest+json"],["webp","image/webp"],["wg","application/vnd.pmi.widget"],["wgt","application/widget"],["wks","application/vnd.ms-works"],["wm","video/x-ms-wm"],["wma","audio/x-ms-wma"],["wmd","application/x-ms-wmd"],["wmf","image/wmf"],["wml","text/vnd.wap.wml"],["wmlc","application/wmlc"],["wmls","text/vnd.wap.wmlscript"],["wmlsc","application/vnd.wap.wmlscriptc"],["wmv","video/x-ms-wmv"],["wmx","video/x-ms-wmx"],["wmz","application/x-msmetafile"],["woff","font/woff"],["woff2","font/woff2"],["word","application/msword"],["wpd","application/vnd.wordperfect"],["wpl","application/vnd.ms-wpl"],["wps","application/vnd.ms-works"],["wqd","application/vnd.wqd"],["wri","application/x-mswrite"],["wrl","model/vrml"],["wsc","message/vnd.wfa.wsc"],["wsdl","application/wsdl+xml"],["wspolicy","application/wspolicy+xml"],["wtb","application/vnd.webturbo"],["wvx","video/x-ms-wvx"],["x3d","model/x3d+xml"],["x3db","model/x3d+fastinfoset"],["x3dbz","model/x3d+binary"],["x3dv","model/x3d-vrml"],["x3dvz","model/x3d+vrml"],["x3dz","model/x3d+xml"],["x32","application/x-authorware-bin"],["x_b","model/vnd.parasolid.transmit.binary"],["x_t","model/vnd.parasolid.transmit.text"],["xaml","application/xaml+xml"],["xap","application/x-silverlight-app"],["xar","application/vnd.xara"],["xav","application/xcap-att+xml"],["xbap","application/x-ms-xbap"],["xbd","application/vnd.fujixerox.docuworks.binder"],["xbm","image/x-xbitmap"],["xca","application/xcap-caps+xml"],["xcs","application/calendar+xml"],["xdf","application/xcap-diff+xml"],["xdm","application/vnd.syncml.dm+xml"],["xdp","application/vnd.adobe.xdp+xml"],["xdssc","application/dssc+xml"],["xdw","application/vnd.fujixerox.docuworks"],["xel","application/xcap-el+xml"],["xenc","application/xenc+xml"],["xer","application/patch-ops-error+xml"],["xfdf","application/vnd.adobe.xfdf"],["xfdl","application/vnd.xfdl"],["xht","application/xhtml+xml"],["xhtml","application/xhtml+xml"],["xhvml","application/xv+xml"],["xif","image/vnd.xiff"],["xl","application/excel"],["xla","application/vnd.ms-excel"],["xlam","application/vnd.ms-excel.addin.macroEnabled.12"],["xlc","application/vnd.ms-excel"],["xlf","application/xliff+xml"],["xlm","application/vnd.ms-excel"],["xls","application/vnd.ms-excel"],["xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"],["xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xlt","application/vnd.ms-excel"],["xltm","application/vnd.ms-excel.template.macroEnabled.12"],["xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"],["xlw","application/vnd.ms-excel"],["xm","audio/xm"],["xml","application/xml"],["xns","application/xcap-ns+xml"],["xo","application/vnd.olpc-sugar"],["xop","application/xop+xml"],["xpi","application/x-xpinstall"],["xpl","application/xproc+xml"],["xpm","image/x-xpixmap"],["xpr","application/vnd.is-xpr"],["xps","application/vnd.ms-xpsdocument"],["xpw","application/vnd.intercon.formnet"],["xpx","application/vnd.intercon.formnet"],["xsd","application/xml"],["xsl","application/xml"],["xslt","application/xslt+xml"],["xsm","application/vnd.syncml+xml"],["xspf","application/xspf+xml"],["xul","application/vnd.mozilla.xul+xml"],["xvm","application/xv+xml"],["xvml","application/xv+xml"],["xwd","image/x-xwindowdump"],["xyz","chemical/x-xyz"],["xz","application/x-xz"],["yaml","text/yaml"],["yang","application/yang"],["yin","application/yin+xml"],["yml","text/yaml"],["ymp","text/x-suse-ymp"],["z","application/x-compress"],["z1","application/x-zmachine"],["z2","application/x-zmachine"],["z3","application/x-zmachine"],["z4","application/x-zmachine"],["z5","application/x-zmachine"],["z6","application/x-zmachine"],["z7","application/x-zmachine"],["z8","application/x-zmachine"],["zaz","application/vnd.zzazz.deck+xml"],["zip","application/zip"],["zir","application/vnd.zul"],["zirz","application/vnd.zul"],["zmm","application/vnd.handheld-entertainment+xml"],["zsh","text/x-scriptzsh"]]);function Pg(e,t,n){const s=Nxt(e),{webkitRelativePath:r}=e,i=typeof t=="string"?t:typeof r=="string"&&r.length>0?r:`./${e.name}`;return typeof s.path!="string"&&dG(s,"path",i),dG(s,"relativePath",i),s}function Nxt(e){const{name:t}=e;if(t&&t.lastIndexOf(".")!==-1&&!e.type){const s=t.split(".").pop().toLowerCase(),r=_xt.get(s);r&&Object.defineProperty(e,"type",{value:r,writable:!1,configurable:!1,enumerable:!0})}return e}function dG(e,t,n){Object.defineProperty(e,t,{value:n,writable:!1,configurable:!1,enumerable:!0})}const jxt=[".DS_Store","Thumbs.db"];function Axt(e){return Ih(this,void 0,void 0,function*(){return UC(e)&&Rxt(e.dataTransfer)?Ixt(e.dataTransfer,e.type):Mxt(e)?Dxt(e):Array.isArray(e)&&e.every(t=>"getFile"in t&&typeof t.getFile=="function")?Oxt(e):[]})}function Rxt(e){return UC(e)}function Mxt(e){return UC(e)&&UC(e.target)}function UC(e){return typeof e=="object"&&e!==null}function Dxt(e){return JD(e.target.files).map(t=>Pg(t))}function Oxt(e){return Ih(this,void 0,void 0,function*(){return(yield Promise.all(e.map(n=>n.getFile()))).map(n=>Pg(n))})}function Ixt(e,t){return Ih(this,void 0,void 0,function*(){if(e.items){const n=JD(e.items).filter(r=>r.kind==="file");if(t!=="drop")return n;const s=yield Promise.all(n.map(Pxt));return fG(Vde(s))}return fG(JD(e.files).map(n=>Pg(n)))})}function fG(e){return e.filter(t=>jxt.indexOf(t.name)===-1)}function JD(e){if(e===null)return[];const t=[];for(let n=0;n<e.length;n++){const s=e[n];t.push(s)}return t}function Pxt(e){if(typeof e.webkitGetAsEntry!="function")return hG(e);const t=e.webkitGetAsEntry();return t&&t.isDirectory?qde(t):hG(e,t)}function Vde(e){return e.reduce((t,n)=>[...t,...Array.isArray(n)?Vde(n):[n]],[])}function hG(e,t){return Ih(this,void 0,void 0,function*(){var n;if(globalThis.isSecureContext&&typeof e.getAsFileSystemHandle=="function"){const i=yield e.getAsFileSystemHandle();if(i===null)throw new Error(`${e} is not a File`);if(i!==void 0){const o=yield i.getFile();return o.handle=i,Pg(o)}}const s=e.getAsFile();if(!s)throw new Error(`${e} is not a File`);return Pg(s,(n=t==null?void 0:t.fullPath)!==null&&n!==void 0?n:void 0)})}function Lxt(e){return Ih(this,void 0,void 0,function*(){return e.isDirectory?qde(e):Fxt(e)})}function qde(e){const t=e.createReader();return new Promise((n,s)=>{const r=[];function i(){t.readEntries(o=>Ih(this,void 0,void 0,function*(){if(o.length){const l=Promise.all(o.map(Lxt));r.push(l),i()}else try{const l=yield Promise.all(r);n(l)}catch(l){s(l)}}),o=>{s(o)})}i()})}function Fxt(e){return Ih(this,void 0,void 0,function*(){return new Promise((t,n)=>{e.file(s=>{const r=Pg(s,e.fullPath);t(r)},s=>{n(s)})})})}var bw={},mG;function zxt(){return mG||(mG=1,bw.__esModule=!0,bw.default=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(",");if(n.length===0)return!0;var s=e.name||"",r=(e.type||"").toLowerCase(),i=r.replace(/\/.*$/,"");return n.some(function(o){var l=o.trim().toLowerCase();return l.charAt(0)==="."?s.toLowerCase().endsWith(l):l.endsWith("/*")?i===l.replace(/\/.*$/,""):r===l})}return!0}),bw}var Bxt=zxt();const jR=hl(Bxt);function pG(e){return Uxt(e)||Hxt(e)||Kde(e)||$xt()}function $xt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
1274
|
+
`+n(r.slice(i+1))}return Jx.exports=e,Jx.exports.escapeCarriageReturn=e,Jx.exports.escapeCarriageReturnSafe=s,Jx.exports}var vR,Pq;function agt(){return Pq||(Pq=1,vR=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/),vR}var bR,Lq;function ogt(){return Lq||(Lq=1,bR=/[\0-\x1F\x7F-\x9F]/),bR}var SR,Fq;function lgt(){return Fq||(Fq=1,SR=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/),SR}var wR,zq;function cgt(){return zq||(zq=1,wR=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4E\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDF55-\uDF59]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD806[\uDC3B\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/),wR}var kR,Bq;function ugt(){return Bq||(Bq=1,kR=function(e){var t={};t.src_Any=agt().source,t.src_Cc=ogt().source,t.src_Z=lgt().source,t.src_P=cgt().source,t.src_ZPCc=[t.src_Z,t.src_P,t.src_Cc].join("|"),t.src_ZCc=[t.src_Z,t.src_Cc].join("|");var n="[><|]";return t.src_pseudo_letter="(?:(?!"+n+"|"+t.src_ZPCc+")"+t.src_Any+")",t.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",t.src_auth="(?:(?:(?!"+t.src_ZCc+"|[@/\\[\\]()]).)+@)?",t.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",t.src_host_terminator="(?=$|"+n+"|"+t.src_ZPCc+")(?!-|_|:\\d|\\.-|\\.(?!$|"+t.src_ZPCc+"))",t.src_path="(?:[/?#](?:(?!"+t.src_ZCc+"|"+n+`|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!`+t.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+t.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+t.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+t.src_ZCc+`|["]).)+\\"|\\'(?:(?!`+t.src_ZCc+"|[']).)+\\'|\\'(?="+t.src_pseudo_letter+"|[-]).|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!"+t.src_ZCc+"|[.]).|"+(e&&e["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+t.src_ZCc+").|;(?!"+t.src_ZCc+").|\\!+(?!"+t.src_ZCc+"|[!]).|\\?(?!"+t.src_ZCc+"|[?]).)+|\\/)?",t.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',t.src_xn="xn--[a-z0-9\\-]{1,59}",t.src_domain_root="(?:"+t.src_xn+"|"+t.src_pseudo_letter+"{1,63})",t.src_domain="(?:"+t.src_xn+"|(?:"+t.src_pseudo_letter+")|(?:"+t.src_pseudo_letter+"(?:-|"+t.src_pseudo_letter+"){0,61}"+t.src_pseudo_letter+"))",t.src_host="(?:(?:(?:(?:"+t.src_domain+")\\.)*"+t.src_domain+"))",t.tpl_host_fuzzy="(?:"+t.src_ip4+"|(?:(?:(?:"+t.src_domain+")\\.)+(?:%TLDS%)))",t.tpl_host_no_ip_fuzzy="(?:(?:(?:"+t.src_domain+")\\.)+(?:%TLDS%))",t.src_host_strict=t.src_host+t.src_host_terminator,t.tpl_host_fuzzy_strict=t.tpl_host_fuzzy+t.src_host_terminator,t.src_host_port_strict=t.src_host+t.src_port+t.src_host_terminator,t.tpl_host_port_fuzzy_strict=t.tpl_host_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_port_no_ip_fuzzy_strict=t.tpl_host_no_ip_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+t.src_ZPCc+"|>|$))",t.tpl_email_fuzzy="(^|"+n+'|"|\\(|'+t.src_ZCc+")("+t.src_email_name+"@"+t.tpl_host_fuzzy_strict+")",t.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_fuzzy_strict+t.src_path+")",t.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_no_ip_fuzzy_strict+t.src_path+")",t}),kR}var CR,$q;function dgt(){if($q)return CR;$q=1;function e(T){var E=Array.prototype.slice.call(arguments,1);return E.forEach(function(j){j&&Object.keys(j).forEach(function(_){T[_]=j[_]})}),T}function t(T){return Object.prototype.toString.call(T)}function n(T){return t(T)==="[object String]"}function s(T){return t(T)==="[object Object]"}function r(T){return t(T)==="[object RegExp]"}function i(T){return t(T)==="[object Function]"}function o(T){return T.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}var l={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function c(T){return Object.keys(T||{}).reduce(function(E,j){return E||l.hasOwnProperty(j)},!1)}var u={"http:":{validate:function(T,E,j){var _=T.slice(E);return j.re.http||(j.re.http=new RegExp("^\\/\\/"+j.re.src_auth+j.re.src_host_port_strict+j.re.src_path,"i")),j.re.http.test(_)?_.match(j.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(T,E,j){var _=T.slice(E);return j.re.no_http||(j.re.no_http=new RegExp("^"+j.re.src_auth+"(?:localhost|(?:(?:"+j.re.src_domain+")\\.)+"+j.re.src_domain_root+")"+j.re.src_port+j.re.src_host_terminator+j.re.src_path,"i")),j.re.no_http.test(_)?E>=3&&T[E-3]===":"||E>=3&&T[E-3]==="/"?0:_.match(j.re.no_http)[0].length:0}},"mailto:":{validate:function(T,E,j){var _=T.slice(E);return j.re.mailto||(j.re.mailto=new RegExp("^"+j.re.src_email_name+"@"+j.re.src_host_strict,"i")),j.re.mailto.test(_)?_.match(j.re.mailto)[0].length:0}}},d="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",f="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function m(T){T.__index__=-1,T.__text_cache__=""}function g(T){return function(E,j){var _=E.slice(j);return T.test(_)?_.match(T)[0].length:0}}function y(){return function(T,E){E.normalize(T)}}function b(T){var E=T.re=ugt()(T.__opts__),j=T.__tlds__.slice();T.onCompile(),T.__tlds_replaced__||j.push(d),j.push(E.src_xn),E.src_tlds=j.join("|");function _(M){return M.replace("%TLDS%",E.src_tlds)}E.email_fuzzy=RegExp(_(E.tpl_email_fuzzy),"i"),E.link_fuzzy=RegExp(_(E.tpl_link_fuzzy),"i"),E.link_no_ip_fuzzy=RegExp(_(E.tpl_link_no_ip_fuzzy),"i"),E.host_fuzzy_test=RegExp(_(E.tpl_host_fuzzy_test),"i");var N=[];T.__compiled__={};function R(M,L){throw new Error('(LinkifyIt) Invalid schema "'+M+'": '+L)}Object.keys(T.__schemas__).forEach(function(M){var L=T.__schemas__[M];if(L!==null){var P={validate:null,link:null};if(T.__compiled__[M]=P,s(L)){r(L.validate)?P.validate=g(L.validate):i(L.validate)?P.validate=L.validate:R(M,L),i(L.normalize)?P.normalize=L.normalize:L.normalize?R(M,L):P.normalize=y();return}if(n(L)){N.push(M);return}R(M,L)}}),N.forEach(function(M){T.__compiled__[T.__schemas__[M]]&&(T.__compiled__[M].validate=T.__compiled__[T.__schemas__[M]].validate,T.__compiled__[M].normalize=T.__compiled__[T.__schemas__[M]].normalize)}),T.__compiled__[""]={validate:null,normalize:y()};var O=Object.keys(T.__compiled__).filter(function(M){return M.length>0&&T.__compiled__[M]}).map(o).join("|");T.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+E.src_ZPCc+"))("+O+")","i"),T.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+E.src_ZPCc+"))("+O+")","ig"),T.re.pretest=RegExp("("+T.re.schema_test.source+")|("+T.re.host_fuzzy_test.source+")|@","i"),m(T)}function S(T,E){var j=T.__index__,_=T.__last_index__,N=T.__text_cache__.slice(j,_);this.schema=T.__schema__.toLowerCase(),this.index=j+E,this.lastIndex=_+E,this.raw=N,this.text=N,this.url=N}function w(T,E){var j=new S(T,E);return T.__compiled__[j.schema].normalize(j,T),j}function C(T,E){if(!(this instanceof C))return new C(T,E);E||c(T)&&(E=T,T={}),this.__opts__=e({},l,E),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=e({},u,T),this.__compiled__={},this.__tlds__=f,this.__tlds_replaced__=!1,this.re={},b(this)}return C.prototype.add=function(E,j){return this.__schemas__[E]=j,b(this),this},C.prototype.set=function(E){return this.__opts__=e(this.__opts__,E),this},C.prototype.test=function(E){if(this.__text_cache__=E,this.__index__=-1,!E.length)return!1;var j,_,N,R,O,M,L,P,$;if(this.re.schema_test.test(E)){for(L=this.re.schema_search,L.lastIndex=0;(j=L.exec(E))!==null;)if(R=this.testSchemaAt(E,j[2],L.lastIndex),R){this.__schema__=j[2],this.__index__=j.index+j[1].length,this.__last_index__=j.index+j[0].length+R;break}}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(P=E.search(this.re.host_fuzzy_test),P>=0&&(this.__index__<0||P<this.__index__)&&(_=E.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))!==null&&(O=_.index+_[1].length,(this.__index__<0||O<this.__index__)&&(this.__schema__="",this.__index__=O,this.__last_index__=_.index+_[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&($=E.indexOf("@"),$>=0&&(N=E.match(this.re.email_fuzzy))!==null&&(O=N.index+N[1].length,M=N.index+N[0].length,(this.__index__<0||O<this.__index__||O===this.__index__&&M>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=O,this.__last_index__=M))),this.__index__>=0},C.prototype.pretest=function(E){return this.re.pretest.test(E)},C.prototype.testSchemaAt=function(E,j,_){return this.__compiled__[j.toLowerCase()]?this.__compiled__[j.toLowerCase()].validate(E,_,this):0},C.prototype.match=function(E){var j=0,_=[];this.__index__>=0&&this.__text_cache__===E&&(_.push(w(this,j)),j=this.__last_index__);for(var N=j?E.slice(j):E;this.test(N);)_.push(w(this,j)),N=N.slice(this.__last_index__),j+=this.__last_index__;return _.length?_:null},C.prototype.tlds=function(E,j){return E=Array.isArray(E)?E:[E],j?(this.__tlds__=this.__tlds__.concat(E).sort().filter(function(_,N,R){return _!==R[N-1]}).reverse(),b(this),this):(this.__tlds__=E.slice(),this.__tlds_replaced__=!0,b(this),this)},C.prototype.normalize=function(E){E.schema||(E.url="http://"+E.url),E.schema==="mailto:"&&!/^mailto:/i.test(E.url)&&(E.url="mailto:"+E.url)},C.prototype.onCompile=function(){},CR=C,CR}var Hq;function fgt(){if(Hq)return Da;Hq=1;var e=Da&&Da.__createBinding||(Object.create?(function(S,w,C,T){T===void 0&&(T=C);var E=Object.getOwnPropertyDescriptor(w,C);(!E||("get"in E?!w.__esModule:E.writable||E.configurable))&&(E={enumerable:!0,get:function(){return w[C]}}),Object.defineProperty(S,T,E)}):(function(S,w,C,T){T===void 0&&(T=C),S[T]=w[C]})),t=Da&&Da.__setModuleDefault||(Object.create?(function(S,w){Object.defineProperty(S,"default",{enumerable:!0,value:w})}):function(S,w){S.default=w}),n=Da&&Da.__importStar||(function(){var S=function(w){return S=Object.getOwnPropertyNames||function(C){var T=[];for(var E in C)Object.prototype.hasOwnProperty.call(C,E)&&(T[T.length]=E);return T},S(w)};return function(w){if(w&&w.__esModule)return w;var C={};if(w!=null)for(var T=S(w),E=0;E<T.length;E++)T[E]!=="default"&&e(C,w,T[E]);return t(C,w),C}})(),s=Da&&Da.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(Da,"__esModule",{value:!0}),Da.default=y;const r=s(rgt()),i=igt(),o=s(dgt()),l=n(Lg());function c(S,w=!1){return S=(0,i.escapeCarriageReturn)(b(S)),r.default.ansiToJson(S,{json:!0,remove_empty:!0,use_classes:w})}function u(S){let w="";return S.bg&&(w+=`${S.bg}-bg `),S.fg&&(w+=`${S.fg}-fg `),S.decoration&&(w+=`ansi-${S.decoration} `),w===""?null:(w=w.substring(0,w.length-1),w)}function d(S){const w={};switch(S.bg&&(w.backgroundColor=`rgb(${S.bg})`),S.fg&&(w.color=`rgb(${S.fg})`),S.decoration){case"bold":w.fontWeight="bold";break;case"dim":w.opacity="0.5";break;case"italic":w.fontStyle="italic";break;case"hidden":w.visibility="hidden";break;case"strikethrough":w.textDecoration="line-through";break;case"underline":w.textDecoration="underline";break;case"blink":w.textDecoration="blink";break}return w}function f(S,w,C,T){const E=w?null:d(C),j=w?u(C):null;return S?S==="fuzzy"?g(C,T,E,j):m(C,T,E,j):l.createElement("span",{style:E,key:T,className:j},C.content)}function m(S,w,C,T){const E=[],j=/(\s|^)(https?:\/\/(?:www\.|(?!www))[^\s.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/g;let _=0,N;for(;(N=j.exec(S.content))!==null;){const[,R,O]=N,M=N.index+R.length;M>_&&E.push(S.content.substring(_,M));const L=O.startsWith("www.")?`http://${O}`:O;E.push(l.createElement("a",{key:_,href:L,target:"_blank"},`${O}`)),_=j.lastIndex}return _<S.content.length&&E.push(S.content.substring(_)),l.createElement("span",{style:C,key:w,className:T},E)}function g(S,w,C,T){var E;const j=(0,o.default)({fuzzyEmail:!1}).tlds(["io"],!0);if(!j.pretest(S.content))return l.createElement("span",{style:C,key:w,className:T},S.content);const _=j.match(S.content);if(!_)return l.createElement("span",{style:C,key:w,className:T},S.content);const N=[S.content.substring(0,(E=_[0])===null||E===void 0?void 0:E.index)];return _.forEach((R,O)=>{var M;N.push(l.createElement("a",{href:R.url,target:"_blank",key:O},S.content.substring(R.index,R.lastIndex))),_[O+1]&&N.push(S.content.substring(_[O].lastIndex,(M=_[O+1])===null||M===void 0?void 0:M.index))}),_[_.length-1].lastIndex!==S.content.length&&N.push(S.content.substring(_[_.length-1].lastIndex,S.content.length)),l.createElement("span",{style:C,key:w,className:T},N)}function y(S){const{className:w,useClasses:C,children:T,linkify:E}=S;return l.createElement("code",{className:w},c(T??"",C??!1).map(f.bind(null,E??!1,C??!1)))}function b(S){let w=S;do S=w,w=S.replace(/[^\n]\x08/gm,"");while(w.length<S.length);return S}return Da}var hgt=fgt();const mgt=hl(hgt),pgt=x.lazy(()=>ks(()=>import("./index-DQD1r_S5.js"),[])),ggt={...egt,container:"bg-transparent text-xs font-mono leading-relaxed",label:"text-muted-foreground font-medium mr-1",clickableLabel:"text-muted-foreground font-medium mr-1 cursor-pointer",nullValue:"text-muted-foreground italic",undefinedValue:"text-muted-foreground italic",stringValue:"text-foreground",booleanValue:"text-amber-400",numberValue:"text-blue-400",otherValue:"text-muted-foreground",punctuation:"text-muted-foreground",collapseIcon:"text-muted-foreground",expandIcon:"text-muted-foreground",collapsedContent:"text-muted-foreground"},Uq=5120;function xgt(e){try{const t=JSON.parse(e);return typeof t=="object"&&t!==null&&("old_string"in t||"new_string"in t)?t:null}catch{return null}}function ER({children:e,rawContent:t,supportsRawToggle:n,isRaw:s,onToggleRaw:r}){const[i,o]=x.useState(!1),l=t.length>Uq,c=l&&!i?t.slice(0,Uq):t;return a.jsxs("div",{className:"space-y-1",children:[n&&a.jsx("div",{className:"flex justify-end",children:a.jsx("button",{onClick:r,className:"text-muted-foreground hover:text-foreground text-xs underline",children:s?"Formatted":"Raw"})}),s?a.jsxs(a.Fragment,{children:[a.jsx("pre",{className:"max-h-64 overflow-y-auto text-xs whitespace-pre-wrap",children:c}),l&&!i&&a.jsxs("button",{onClick:()=>o(!0),className:"text-muted-foreground hover:text-foreground text-xs underline",children:["Show full output (",(t.length/1024).toFixed(1),"KB)"]})]}):e]})}function ygt({oldValue:e,newValue:t,rawContent:n}){return a.jsx(x.Suspense,{fallback:a.jsx("pre",{className:"max-h-64 overflow-y-auto text-xs whitespace-pre-wrap",children:n}),children:a.jsx(pgt,{oldValue:e,newValue:t,splitView:!1,useDarkTheme:!0,hideLineNumbers:!0,showDiffOnly:!0,extraLinesSurroundingDiff:2,styles:{variables:{dark:{diffViewerBackground:"transparent",addedBackground:"rgba(34, 197, 94, 0.1)",addedColor:"rgb(134, 239, 172)",addedGutterBackground:"rgba(34, 197, 94, 0.08)",wordAddedBackground:"rgba(34, 197, 94, 0.2)",removedBackground:"rgba(239, 68, 68, 0.1)",removedColor:"rgb(252, 165, 165)",removedGutterBackground:"rgba(239, 68, 68, 0.08)",wordRemovedBackground:"rgba(239, 68, 68, 0.2)",gutterBackground:"hsl(0 0% 9%)",gutterBackgroundDark:"hsl(0 0% 7%)",gutterColor:"hsl(0 0% 40%)"}}}})})}function Dde({content:e,toolName:t,input:n}){const[s,r]=x.useState(!1);if(t==="Edit"&&n){const o=xgt(n);if(o)return a.jsx(ygt,{oldValue:o.old_string??"",newValue:o.new_string??"",rawContent:e})}const i=ROe(e);if(i==="json"){let o;try{o=JSON.parse(e)}catch{o={}}return a.jsx(ER,{rawContent:e,supportsRawToggle:!0,isRaw:s,onToggleRaw:()=>r(l=>!l),children:a.jsx(sgt,{data:o,style:ggt,shouldExpandNode:ngt})})}return i==="ansi"?a.jsx(ER,{rawContent:e,supportsRawToggle:!0,isRaw:s,onToggleRaw:()=>r(o=>!o),children:a.jsx("pre",{className:"max-h-64 overflow-y-auto text-xs whitespace-pre-wrap",children:a.jsx(mgt,{children:e})})}):a.jsx(ER,{rawContent:e,supportsRawToggle:!1,isRaw:!0,onToggleRaw:()=>{},children:null})}function vgt({message:e}){const[t,n]=x.useState(!1),s=x.useMemo(()=>Bpt(e.content),[e.content]),r=x.useMemo(()=>Ppt(e.content),[e.content]);return r?a.jsx(Opt,{action:r}):e.messageType==="command"?a.jsx("div",{className:"text-msg-command-fg truncate font-mono text-sm",children:e.content}):e.messageType==="local_command_output"?a.jsx(Dde,{content:e.content,toolName:""}):e.messageType==="compaction"?a.jsxs("div",{className:"w-full",children:[a.jsxs("button",{onClick:()=>n(!t),className:"text-msg-compaction-fg flex w-full items-center gap-2 text-xs",children:[a.jsx("div",{className:"bg-border/40 h-px flex-1"}),a.jsx(Rs,{className:Y("size-3 transition-transform duration-200",t&&"rotate-90")}),a.jsx("span",{children:$pt(e.compactMetadata)}),a.jsx("div",{className:"bg-border/40 h-px flex-1"})]}),t&&a.jsx("div",{className:"text-msg-compaction-fg mt-2 text-xs whitespace-pre-wrap",children:e.content})]}):a.jsxs("div",{children:[s.files.length>0&&a.jsx(Upt,{files:s.files}),s.textContent&&a.jsx("div",{className:"break-words whitespace-pre-wrap",children:s.textContent})]})}const bgt={enabled:!0,renderModal:e=>a.jsx(TT,{...e})};function Sgt({content:e,isStreaming:t=!1,textEffect:n=Vwe,sessionId:s,isLatestMessage:r}){const i=Gwe(n),o=x.useMemo(()=>({renderers:[{language:"dorkos-ui",component:l=>a.jsx(Mpt,{...l,sessionId:s,isLatestMessage:r})}]}),[s,r]);return a.jsx("div",{className:Y("relative",t&&"streaming-cursor"),children:a.jsx(J4,{shikiTheme:["github-light","github-dark"],linkSafety:bgt,animated:i,isAnimating:t,plugins:o,children:e})})}function Ode(e){switch(e){case"pending":case"running":return a.jsx(Sn,{className:Y("size-(--size-icon-xs) animate-spin",pR({status:e}))});case"complete":return a.jsx(Lt,{className:Y("size-(--size-icon-xs)",pR({status:e}))});case"error":return a.jsx(es,{className:Y("size-(--size-icon-xs)",pR({status:e}))})}}function TR({isSelected:e,isFocused:t,control:n,children:s,"data-selected":r}){return a.jsxs("div",{className:Y("flex items-center gap-2 rounded px-2 py-1 transition-all duration-150",e?"bg-muted":"hover:bg-muted/80",t&&"ring-status-info/50 ring-1"),"data-selected":r,children:[n,s]})}function Yp({icon:e,label:t,trailing:n,children:s,...r}){return a.jsxs("div",{className:"bg-muted/50 rounded-msg-tool shadow-msg-tool border px-3 py-1 text-sm transition-all duration-150",...r,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[e,t,n]}),s]})}function Vq({type:e,toolName:t,toolInput:n,...s}){const r=e==="approval"?"Waiting for approval":"Answering questions",i=t?WO(t,n??""):null,o=i?`${r} — ${i}`:`${r}...`;return a.jsx("div",{className:"bg-muted/50 rounded-msg-tool text-muted-foreground shadow-msg-tool border px-3 py-1 text-sm transition-all duration-150",...s,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Sn,{className:"size-(--size-icon-sm) shrink-0 animate-spin"}),a.jsx("span",{className:"truncate text-xs",children:o})]})})}function Xb({expanded:e,onToggle:t,header:n,children:s,variant:r="default",dimmed:i=!1,disabled:o=!1,hideChevron:l=!1,extraContent:c,ariaLabel:u,className:d,...f}){const m=l?void 0:e;return a.jsxs("div",{className:Y("bg-muted/40 mt-px rounded-md border-l-2 text-sm transition-all duration-200 first:mt-1",r==="default"&&"border-l-muted-foreground/30",r==="thinking"&&"border-l-muted-foreground/20",r==="memory"&&"border-l-muted-foreground/20",i&&!e&&"opacity-50 hover:opacity-100",d),...f,children:[a.jsxs("button",{onClick:()=>!o&&t(),disabled:o,className:Y("flex w-full items-center gap-2 px-3 py-1",o&&"cursor-default"),"aria-expanded":m,"aria-label":u,children:[n,!l&&!o&&a.jsx(te.div,{animate:{rotate:e?180:0},transition:{type:"spring",stiffness:400,damping:30},className:"ml-auto",children:a.jsx(Hs,{className:"text-muted-foreground size-(--size-icon-xs)"})})]}),c,a.jsx(Ue,{initial:!1,children:e&&a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:a.jsx("div",{className:"border-border/50 border-t px-3 pt-1 pb-3",children:s})})})]})}function Ide({isActive:e=!1,isResolved:t=!1,children:n,className:s,...r}){return a.jsx("div",{className:Y("border-status-info bg-muted/50 rounded-msg-tool border-l-2 p-3 text-sm transition-all duration-200",e&&"ring-ring/30 ring-2",!e&&!t&&"opacity-60",s),...r,children:n})}const wgt=5120;function kgt({content:e,threshold:t=wgt,className:n}){const[s,r]=x.useState(!1),i=e.length>t,o=i&&!s?e.slice(0,t):e;return a.jsxs("div",{className:Y("mt-2 border-t pt-2",n),children:[a.jsx("pre",{className:"max-h-48 overflow-y-auto text-xs whitespace-pre-wrap",children:o}),i&&!s&&a.jsxs("button",{onClick:()=>r(!0),className:"text-muted-foreground hover:text-foreground mt-1 text-xs underline",children:["Show full output (",(e.length/1024).toFixed(1),"KB)"]})]})}const Cgt={running:a.jsx(Sn,{className:"text-muted-foreground size-(--size-icon-xs) animate-spin"}),success:a.jsx(Lt,{className:"text-muted-foreground size-(--size-icon-xs)"}),error:a.jsx(es,{className:"text-destructive size-(--size-icon-xs)"}),cancelled:a.jsx(es,{className:"text-muted-foreground size-(--size-icon-xs)"})};function Egt({hook:e}){const t=!!(e.stdout||e.stderr),[n,s]=x.useState(e.status==="error"),r=e.stderr||e.stdout;return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>t&&s(i=>!i),className:Y("flex w-full items-center gap-1.5 py-0.5",!t&&"cursor-default"),"aria-expanded":t?n:void 0,disabled:!t,children:[Cgt[e.status],a.jsx("span",{className:Y("text-3xs font-mono",e.status==="error"?"text-destructive":"text-muted-foreground"),children:e.hookName}),e.status==="error"&&a.jsx("span",{className:"text-3xs text-destructive",children:"failed"}),e.exitCode!==void 0&&a.jsxs("span",{className:"text-3xs text-muted-foreground ml-auto",children:["exit ",e.exitCode]})]}),a.jsx(Ue,{initial:!1,children:n&&t&&r&&a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:[.4,0,.2,1]},className:"overflow-hidden",children:a.jsx("pre",{className:"text-muted-foreground max-h-32 overflow-y-auto py-1 text-xs whitespace-pre-wrap",children:r})})})]})}function Tgt({toolCall:e,defaultExpanded:t=!1}){const[n,s]=x.useState(t),r=!!e.progressOutput;x.useEffect(()=>{r&&!n&&s(!0)},[r]);const i=e.hooks&&e.hooks.length>0?a.jsx("div",{className:"border-border/50 space-y-0.5 border-t px-3 py-1",children:e.hooks.map(c=>a.jsx(Egt,{hook:c},c.hookId))}):void 0,o=e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0,l=$Z(e.toolName);return a.jsxs(Xb,{expanded:n,onToggle:()=>s(!n),dimmed:e.status==="complete",extraContent:i,"data-testid":"tool-call-card","data-tool-name":e.toolName,"data-status":e.status,header:a.jsxs(a.Fragment,{children:[Ode(e.status),l&&a.jsx("span",{className:"bg-muted text-muted-foreground text-3xs rounded px-1 py-0.5 font-medium",children:l}),a.jsx("span",{className:"text-3xs flex-1 text-left font-mono",children:WO(e.toolName,e.input)}),o!==void 0&&a.jsx("span",{className:"text-muted-foreground text-3xs tabular-nums",children:JDe(o)})]}),children:[e.status==="running"&&!e.input?a.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 py-1 text-xs",children:[a.jsx(Sn,{className:"size-3 animate-spin"}),a.jsx("span",{children:"Preparing..."})]}):e.input!==void 0&&e.input!==""?a.jsx(UZ,{toolName:e.toolName,input:e.input,isStreaming:e.status==="running"}):null,e.progressOutput&&!e.result&&a.jsx(kgt,{content:e.progressOutput}),e.result&&a.jsx("div",{className:"mt-2 border-t pt-2",children:a.jsx(Dde,{content:e.result,toolName:e.toolName,input:e.input})})]})}const qq={duration:.15,ease:"easeOut"},Gq=120,Kq=60,Wq=new Set(["Bash","Write","Edit","NotebookEdit"]),Yq=new Set(["WebFetch","WebSearch"]);function _gt(e){const t=e.includes("__")?e.split("__").pop():e;return Wq.has(t)||Wq.has(e)?"high":Yq.has(t)||Yq.has(e)||e.startsWith("mcp__")?"medium":"low"}function Ngt(e){const t=Math.floor(e/60),n=e%60;return t>0?`${t}:${String(n).padStart(2,"0")}`:`${n}s`}function jgt(e){if(e===null)return"";if(e<=0)return"Expired";const t=Math.floor(e/60),n=e%60;return t>0?`${t} minute${t!==1?"s":""} and ${n} second${n!==1?"s":""} remaining`:`${n} second${n!==1?"s":""} remaining`}function Pde({sessionId:e,toolCallId:t,toolName:n,input:s,isActive:r=!1,onDecided:i,ref:o,timeoutMs:l,approvalStartedAt:c,approvalRemainingMs:u,approvalTitle:d,approvalDisplayName:f,approvalDescription:m,approvalBlockedPath:g,approvalDecisionReason:y,approvalHasSuggestions:b}){const S=je(),w=x.useMemo(()=>_gt(n),[n]),C=$Z(n),T=WO(n,s),E=f||T,[j,_]=x.useState(!1),[N,R]=x.useState(null),[O,M]=x.useState(null),[L,P]=x.useState(null),$=x.useRef(!1),[q,K]=x.useState("");x.useEffect(()=>{if(N||!l)return;const U=u!==void 0?Date.now()+u:c?c+l:Date.now()+l;P(Math.max(0,Math.ceil((U-Date.now())/1e3)));const G=setInterval(()=>{const W=Math.max(0,Math.ceil((U-Date.now())/1e3));P(W),W<=0&&clearInterval(G)},1e3);return()=>clearInterval(G)},[l,c,u,N]),x.useEffect(()=>{L===0&&!N&&($.current=!0,R("denied"),i==null||i())},[L,N,i]),x.useEffect(()=>{L===Gq?K("Tool approval required. 2 minutes remaining."):L===Kq?K("Urgent: 1 minute to approve or deny."):L===0&&K("Tool approval timed out. Execution denied.")},[L]);const B=x.useMemo(()=>L===null?"normal":L<=0?"expired":L<=Kq?"urgent":L<=Gq?"warning":"normal",[L]),V=x.useCallback(async()=>{if(!(j||N)){_(!0),M(null);try{await S.approveTool(e,t),R("approved"),i==null||i()}catch(U){U.code==="INTERACTION_ALREADY_RESOLVED"?(R("approved"),i==null||i()):(console.error("Approval failed:",U),M("Approval request failed — try again"))}finally{_(!1)}}},[j,N,S,e,t,i]),Q=x.useCallback(async()=>{if(!(j||N)){_(!0),M(null);try{await S.approveTool(e,t,!0),R("approved"),i==null||i()}catch(U){U.code==="INTERACTION_ALREADY_RESOLVED"?(R("approved"),i==null||i()):(console.error("Always Allow failed:",U),M("Always Allow request failed — try again"))}finally{_(!1)}}},[j,N,S,e,t,i]),re=x.useCallback(async()=>{if(!(j||N)){_(!0),M(null);try{await S.denyTool(e,t),R("denied"),i==null||i()}catch(U){U.code==="INTERACTION_ALREADY_RESOLVED"?(R("denied"),i==null||i()):(console.error("Deny failed:",U),M("Deny request failed — try again"))}finally{_(!1)}}},[j,N,S,e,t,i]);if(x.useImperativeHandle(o,()=>({approve(){V()},alwaysAllow(){Q()},deny(){re()}}),[V,Q,re]),N){const U=N==="approved";return a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},transition:qq,children:a.jsx(Yp,{"data-testid":"tool-approval-decided","data-decision":N,icon:U?a.jsx(Lt,{className:"text-status-success size-(--size-icon-sm) shrink-0"}):a.jsx(es,{className:"text-status-error size-(--size-icon-sm) shrink-0"}),label:a.jsx("span",{className:"text-3xs font-mono",children:E}),trailing:a.jsx("span",{className:Y("text-2xs rounded-full px-1.5 py-0.5 font-medium",U?"bg-status-success-bg text-status-success-fg":"bg-status-error-bg text-status-error-fg"),children:U?"Approved":"Denied"}),children:N==="denied"&&$.current&&a.jsxs("p",{className:"text-2xs text-muted-foreground mt-1",children:["Auto-denied — approval timed out after ",Math.ceil((l??0)/6e4)," minutes. The agent continued without this tool."]})})})}return a.jsxs(Ide,{isActive:r,isResolved:!!N,className:"my-1","data-testid":"tool-approval",children:[a.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[a.jsx(Hc,{className:Y("size-(--size-icon-md)",w==="high"&&"text-status-error",w==="medium"&&"text-status-warning",w==="low"&&"text-muted-foreground")}),a.jsx("span",{className:"font-semibold",children:d||"Tool approval required"})]}),(m||y||g)&&a.jsxs("div",{className:"text-muted-foreground text-2xs mb-2 space-y-0.5",children:[m&&a.jsx("p",{children:m}),y&&!m&&a.jsx("p",{children:y}),g&&a.jsxs("p",{className:"font-mono",children:["Path: ",g]})]}),l&&!N&&a.jsx("div",{role:"progressbar","aria-valuemin":0,"aria-valuemax":Math.ceil(l/1e3),"aria-valuenow":L??0,"aria-valuetext":jgt(L),className:"bg-muted mb-2 h-1 w-full overflow-hidden rounded-full",children:a.jsx("div",{className:Y("h-full rounded-full transition-colors duration-500",B==="normal"&&"bg-muted-foreground/30",B==="warning"&&"bg-status-warning",B==="urgent"&&"bg-status-error","motion-safe:animate-drain"),style:{animationDuration:`${l}ms`,animationTimingFunction:"linear",animationFillMode:"forwards"}})}),a.jsx(Ue,{children:(B==="warning"||B==="urgent")&&L!==null&&a.jsx(te.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:qq,className:"mb-2",children:a.jsxs("span",{className:Y("text-2xs tabular-nums",B==="warning"&&"text-status-warning",B==="urgent"&&"text-status-error"),children:[Ngt(L)," remaining"]})})}),a.jsxs("div",{className:"mb-2 flex items-center gap-1.5",children:[C&&a.jsx("span",{className:"bg-muted text-muted-foreground text-3xs rounded px-1 py-0.5 font-medium",children:C}),a.jsx("span",{className:"font-mono text-xs",children:E})]}),s&&a.jsx("div",{className:"bg-muted mb-3 rounded p-2",children:a.jsx(UZ,{toolName:n,input:s})}),O&&a.jsx("p",{className:"text-status-error text-2xs mb-2",children:O}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsxs(ge,{size:"sm",onClick:V,disabled:j,className:"transition-opacity duration-150",children:[a.jsx(Lt,{className:"size-(--size-icon-xs)"})," Approve",r&&a.jsx(Zr,{className:"ml-1.5",children:"Enter"})]}),b&&a.jsxs(ge,{size:"sm",variant:"outline",onClick:Q,disabled:j,className:"transition-opacity duration-150",children:[a.jsx(xb,{className:"size-(--size-icon-xs)"})," Always Allow",r&&a.jsx(Zr,{className:"ml-1.5",children:"Shift+Enter"})]}),a.jsxs(ge,{size:"sm",variant:"outline",onClick:re,disabled:j,className:"transition-opacity duration-150",children:[a.jsx(es,{className:"size-(--size-icon-xs)"})," Deny",r&&a.jsx(Zr,{className:"ml-1.5",children:"Esc"})]})]}),a.jsx("span",{role:"status","aria-live":"assertive","aria-atomic":"true",className:"sr-only",children:q})]})}function Agt(e,t,n,s,r){const i=n==null?void 0:n[String(t)];if(i){if(e.multiSelect&&i.startsWith("["))try{return JSON.parse(i).join(", ")}catch{return i}return i}const o=s[t];return o?e.multiSelect?o.map(l=>l==="__other__"?r[t]:l).join(", "):o==="__other__"?r[t]:o:null}function Rgt({questions:e,answers:t,selections:n,otherText:s}){const r=a.jsx(Lt,{className:"text-status-success size-(--size-icon-sm) shrink-0"}),i=e.map((o,l)=>({idx:l,header:o.header,value:Agt(o,l,t,n,s)})).filter(o=>o.value!==null);if(i.length===0){const o=e.length===1?"Question answered":`${e.length} questions answered`;return a.jsx(Yp,{"data-testid":"question-prompt-submitted",icon:r,label:a.jsx("span",{className:"truncate",children:o})})}return i.length===1?a.jsx(Yp,{"data-testid":"question-prompt-submitted",icon:r,label:a.jsx("span",{className:"truncate",children:`${i[0].header}: ${i[0].value}`})}):a.jsx(Yp,{"data-testid":"question-prompt-submitted",icon:r,label:a.jsx("span",{className:"text-muted-foreground",children:"Questions answered"}),children:a.jsx("dl",{className:"mt-1 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 pl-6 text-xs",children:i.map(({idx:o,header:l,value:c})=>a.jsxs(x.Fragment,{children:[a.jsx("dt",{className:"text-muted-foreground",children:l}),a.jsx("dd",{className:"text-foreground break-words",children:c})]},o))})})}const Mgt={duration:.25,ease:[.4,0,.2,1]},_R={duration:.15,ease:"easeOut"},Dgt={enter:e=>({opacity:0,x:e*20}),center:{opacity:1,x:0},exit:e=>({opacity:0,x:e*-20})},Lde=x.forwardRef(function({sessionId:t,toolCallId:n,questions:s,answers:r,isActive:i=!1,focusedOptionIndex:o=-1,onDecided:l},c){const u=je(),d=x.useId(),[f,m]=x.useState({}),[g,y]=x.useState({}),[b,S]=x.useState(!!r),[w,C]=x.useState(!1),[T,E]=x.useState(null),[j,_]=x.useState("0"),N=x.useRef(1),R=s[Number(j)]||s[0],O=Number(j),M=R?R.options.length+1:0;function L(U,G){m(W=>({...W,[U]:G}))}function P(U,G,W){m(F=>{const X=F[U]||[];return W?{...F,[U]:[...X,G]}:{...F,[U]:X.filter(J=>J!==G)}})}function $(U,G){y(W=>({...W,[U]:G}))}function q(U){var W,F;const G=f[U];if(!G)return!1;if(s[U].multiSelect){const X=G;return X.length>0&&(!X.includes("__other__")||!!((W=g[U])!=null&&W.trim()))}return G!=="__other__"||!!((F=g[U])!=null&&F.trim())}function K(){return s.every((U,G)=>q(G))}const B=x.useCallback(async()=>{if(!K()||w)return;C(!0),E(null);const U={};s.forEach((G,W)=>{var X;const F=f[W];if(G.multiSelect){const J=F.map(ae=>{var oe;return ae==="__other__"?((oe=g[W])==null?void 0:oe.trim())||"":ae}).filter(Boolean);U[String(W)]=J.join(", ")}else U[String(W)]=F==="__other__"?((X=g[W])==null?void 0:X.trim())||"":F});try{await u.submitAnswers(t,n,U),S(!0),l==null||l(U)}catch(G){G.code==="INTERACTION_ALREADY_RESOLVED"?(S(!0),l==null||l(U)):E(G instanceof Error?G.message:"Failed to submit answers")}finally{C(!1)}},[f,g,w,u,t,n,s,l]);x.useImperativeHandle(c,()=>({toggleOption(U){if(!R||b||w)return;if(U===R.options.length){R.multiSelect?(f[O]||[]).includes("__other__")?P(O,"__other__",!1):P(O,"__other__",!0):L(O,"__other__");return}const G=R.options[U];G&&(R.multiSelect?(f[O]||[]).includes(G.label)?P(O,G.label,!1):P(O,G.label,!0):L(O,G.label))},navigateOption(U){},navigateQuestion(U){if(s.length<=1)return;const G=Number(j);U==="next"&&G<s.length-1?(N.current=1,_(String(G+1))):U==="prev"&&G>0&&(N.current=-1,_(String(G-1)))},submit(){const U=Number(j);if(U<s.length-1){N.current=1,_(String(U+1));return}B()},getOptionCount(){return M},getActiveTab(){return j}}),[R,O,j,f,b,w,M,B,s.length]);function V(U){const G=Number(j);U==="next"&&G<s.length-1?(N.current=1,_(String(G+1))):U==="prev"&&G>0&&(N.current=-1,_(String(G-1)))}function Q(U,G){const W=U.multiSelect?(f[G]||[]).includes("__other__"):f[G]==="__other__",F=`${d}-q-${G}-other`,X=U.options.length;return a.jsx(TR,{isSelected:W,isFocused:i&&o===X,"data-selected":W,control:U.multiSelect?a.jsx(Sg,{checked:W,id:F,disabled:w,onCheckedChange:J=>P(G,"__other__",!!J)}):a.jsx(bv,{value:"__other__",id:F,disabled:w}),children:a.jsxs("div",{className:"flex-1",children:[a.jsxs("label",{htmlFor:F,className:"flex cursor-pointer items-center",children:[a.jsx("span",{className:"text-sm font-medium",children:"Other"}),X<9&&a.jsx(Zr,{className:"text-2xs text-muted-foreground ml-auto shrink-0",children:X+1})]}),a.jsx(Ue,{initial:!1,children:W&&a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:Mgt,className:"overflow-hidden",children:a.jsx("textarea",{placeholder:"Type your answer...",rows:2,value:g[G]||"",disabled:w,onChange:J=>$(G,J.target.value),className:"bg-background border-border focus:ring-ring mt-1 w-full resize-y rounded border px-2 py-1 text-sm focus:ring-1 focus:outline-none",autoFocus:!0})})})]})})}function re(U,G){return a.jsxs("div",{children:[a.jsx("p",{className:"text-foreground mb-1.5",children:U.question}),U.multiSelect?a.jsxs("div",{role:"group","aria-label":U.question,className:"ml-1 space-y-1",children:[U.options.map((W,F)=>{const X=(f[G]||[]).includes(W.label),J=`${d}-q-${G}-opt-${F}`;return a.jsx(TR,{isSelected:X,isFocused:i&&o===F,"data-selected":X,control:a.jsx(Sg,{checked:X,id:J,disabled:w,onCheckedChange:ae=>P(G,W.label,!!ae)}),children:a.jsxs("label",{htmlFor:J,className:"flex flex-1 cursor-pointer items-center",children:[a.jsx("span",{className:"text-sm font-medium",children:W.label}),W.description&&a.jsxs("span",{className:"text-muted-foreground ml-1.5 text-xs",children:[" ","— ",W.description]}),F<9&&a.jsx(Zr,{className:"text-2xs text-muted-foreground ml-auto shrink-0",children:F+1})]})},F)}),Q(U,G)]}):a.jsxs(JI,{value:f[G]??"",onValueChange:W=>L(G,W),"aria-label":U.question,className:"ml-1 gap-1",children:[U.options.map((W,F)=>{const X=f[G]===W.label,J=`${d}-q-${G}-opt-${F}`;return a.jsx(TR,{isSelected:X,isFocused:i&&o===F,"data-selected":X,control:a.jsx(bv,{value:W.label,id:J,disabled:w}),children:a.jsxs("label",{htmlFor:J,className:"flex flex-1 cursor-pointer items-center",children:[a.jsx("span",{className:"text-sm font-medium",children:W.label}),W.description&&a.jsxs("span",{className:"text-muted-foreground ml-1.5 text-xs",children:[" ","— ",W.description]}),F<9&&a.jsx(Zr,{className:"text-2xs text-muted-foreground ml-auto shrink-0",children:F+1})]})},F)}),Q(U,G)]})]})}return b?a.jsx(te.div,{initial:r?!1:{opacity:0},animate:{opacity:1},transition:_R,children:a.jsx(Rgt,{questions:s,answers:r,selections:f,otherText:g})}):a.jsxs(Ide,{isActive:i,isResolved:b,children:[s.length===1?re(s[0],0):a.jsxs("div",{children:[a.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[a.jsx("span",{className:"text-muted-foreground text-xs",children:s[Number(j)].header??`Question ${Number(j)+1} of ${s.length}`}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsxs(ge,{size:"sm",variant:"ghost",onClick:()=>V("prev"),disabled:Number(j)===0,className:"h-7 px-2 text-xs",children:["Back ",i&&a.jsx(Zr,{className:"ml-1",children:"←"})]}),Number(j)<s.length-1?a.jsxs(ge,{size:"sm",onClick:()=>V("next"),className:"h-7 px-2 text-xs",children:["Next ",i&&a.jsx(Zr,{className:"ml-1",children:"→"})]}):a.jsxs(ge,{size:"sm",onClick:B,disabled:!K()||w,className:"h-7 px-2 text-xs transition-opacity duration-150",children:[a.jsx(Lt,{className:"size-(--size-icon-xs)"}),w?"Submitting...":"Submit",i&&a.jsx(Zr,{className:"ml-1",children:"Enter"})]})]})]}),a.jsx(Ue,{mode:"wait",custom:N.current,children:a.jsx(te.div,{custom:N.current,variants:Dgt,initial:"enter",animate:"center",exit:"exit",transition:_R,children:re(s[Number(j)],Number(j))},j)})]}),a.jsx(Ue,{children:T&&a.jsx(te.p,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:_R,className:"mt-2 text-xs text-red-500",children:T})}),s.length===1&&a.jsx(ge,{size:"sm",onClick:B,disabled:!K()||w,className:"mt-2 transition-opacity duration-150",children:w?"Submitting...":a.jsxs(a.Fragment,{children:[a.jsx(Lt,{className:"size-(--size-icon-xs)"})," Submit",i&&a.jsx(Zr,{className:"ml-1.5",children:"Enter"})]})})]})});function Ogt(e){if(!e)return[];const t=e.properties??{};return Object.entries(t).map(([n,s])=>({key:n,label:s.description??n,type:s.type??"string",options:s.enum,defaultValue:s.default}))}function Igt({sessionId:e,interactionId:t,serverName:n,message:s,mode:r="form",url:i,requestedSchema:o,status:l,action:c}){const u=je(),[d,f]=x.useState(!1),[m,g]=x.useState(null),[y,b]=x.useState({}),[S,w]=x.useState(!1),C=x.useMemo(()=>Ogt(o),[o]),T=l!=="pending",E=x.useCallback(async(M,L)=>{if(!(d||T)){f(!0),g(null);try{await u.submitElicitation(e,t,M,L)}catch(P){if(P.code!=="INTERACTION_ALREADY_RESOLVED"){g(P instanceof Error?P.message:"Failed to submit"),f(!1);return}}f(!1)}},[u,e,t,d,T]),j=x.useCallback(()=>{const M={};for(const L of C)M[L.key]=y[L.key]??L.defaultValue??"";E("accept",M)},[C,y,E]),_=x.useCallback(()=>{E("accept")},[E]),N=x.useCallback(()=>{E("decline")},[E]),R=x.useCallback((M,L)=>{b(P=>({...P,[M]:L}))},[]),O=x.useCallback(()=>{i&&(window.open(i,"_blank","noopener,noreferrer"),w(!0))},[i]);return T?a.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 py-1 text-xs",children:[a.jsx("span",{className:"font-mono",children:n}),a.jsx("span",{children:"—"}),a.jsx("span",{children:c==="accept"?"Authorized":c==="decline"?"Declined":"Cancelled"})]}):a.jsxs(te.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.15},className:Y("border-border bg-card my-2 rounded-xl border p-4","shadow-soft"),children:[a.jsxs("div",{className:"text-muted-foreground mb-2 flex items-center gap-2 text-xs",children:[a.jsx("span",{className:"bg-muted inline-flex items-center rounded-md px-2 py-0.5 font-mono text-[10px]",children:n}),a.jsx("span",{children:"requests input"})]}),a.jsx("p",{className:"mb-3 text-sm",children:s}),m&&a.jsx("p",{className:"text-destructive mb-2 text-xs",children:m}),r==="url"&&i&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ge,{size:"sm",variant:"outline",onClick:O,disabled:d,children:"Open authorization page"}),S&&a.jsx(ge,{size:"sm",onClick:_,disabled:d,children:d?"Submitting…":"Done — I authorized"}),a.jsx(ge,{size:"sm",variant:"ghost",onClick:N,disabled:d,children:"Decline"})]}),r==="form"&&a.jsxs(a.Fragment,{children:[C.length>0?a.jsx("div",{className:"mb-3 space-y-2",children:C.map(M=>a.jsxs("div",{children:[a.jsx("label",{htmlFor:`elicitation-${t}-${M.key}`,className:"text-muted-foreground mb-1 block text-xs font-medium",children:M.label}),M.options?a.jsxs("select",{id:`elicitation-${t}-${M.key}`,className:"border-input bg-background w-full rounded-md border px-3 py-1.5 text-sm",value:y[M.key]??String(M.defaultValue??""),onChange:L=>R(M.key,L.target.value),disabled:d,children:[a.jsx("option",{value:"",children:"Select…"}),M.options.map(L=>a.jsx("option",{value:L,children:L},L))]}):a.jsx("input",{id:`elicitation-${t}-${M.key}`,type:M.type==="number"?"number":"text",className:"border-input bg-background w-full rounded-md border px-3 py-1.5 text-sm",placeholder:String(M.defaultValue??""),value:y[M.key]??"",onChange:L=>R(M.key,L.target.value),disabled:d})]},M.key))}):a.jsx("p",{className:"text-muted-foreground mb-3 text-xs",children:"No additional input required."}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ge,{size:"sm",onClick:j,disabled:d,children:d?"Submitting…":"Accept"}),a.jsx(ge,{size:"sm",variant:"ghost",onClick:N,disabled:d,children:"Decline"})]})]})]})}function Pgt(e){if(e<1e3)return"<1s";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return`${n}m ${s}s`}function Lgt(e){const t=[];return e.toolUses&&t.push(`${e.toolUses} tool ${e.toolUses===1?"call":"calls"}`),e.durationMs&&t.push(Pgt(e.durationMs)),t.length>0?t.join(" · "):null}function Fgt({part:e}){const[t,n]=x.useState(!1),s=x.useRef(null),r=Lgt(e),i=e.subagentText,o=!!(r||e.summary||e.lastToolName||i);return x.useEffect(()=>{const l=s.current;l&&(l.scrollTop=l.scrollHeight)},[i]),a.jsx(Xb,{expanded:t,onToggle:()=>o&&n(!t),hideChevron:!o,ariaLabel:`Background task: ${e.description}`,"data-testid":"subagent-block","data-task-id":e.taskId,"data-status":e.status,header:a.jsxs(a.Fragment,{children:[Ode(e.status==="stopped"?"complete":e.status),a.jsx("span",{className:"text-3xs truncate font-mono",children:e.description}),r&&a.jsx("span",{className:"text-3xs text-muted-foreground ml-1 shrink-0",children:r})]}),children:a.jsxs("div",{className:"space-y-1.5",children:[i&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-3xs text-muted-foreground/70 tracking-wide uppercase",children:"Subagent output"}),a.jsx("pre",{ref:s,className:"text-foreground/90 bg-muted/50 max-h-64 overflow-y-auto rounded-md p-2 text-xs break-words whitespace-pre-wrap","data-testid":"subagent-text",children:i})]}),e.lastToolName&&e.status==="running"&&a.jsxs("p",{className:"text-3xs text-muted-foreground",children:["Last tool: ",a.jsx("span",{className:"font-mono",children:e.lastToolName})]}),e.summary&&a.jsx("pre",{className:"overflow-x-auto text-xs whitespace-pre-wrap",children:e.summary})]})})}function zgt(e){if(e<1e3)return"<1s";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return`${n}m ${s}s`}function Bgt({text:e,isStreaming:t,elapsedMs:n}){const[s,r]=x.useState(t),i=x.useRef(t),o=x.useRef(null);x.useEffect(()=>{i.current&&!t&&r(!1),i.current=t},[t]),x.useEffect(()=>{t&&s&&o.current&&(o.current.scrollTop=o.current.scrollHeight)},[e,t,s]);const l=n?`Thought for ${zgt(n)}`:"Thinking...";return a.jsx(Xb,{expanded:s,onToggle:()=>r(!s),variant:"thinking",dimmed:!t,disabled:t,ariaLabel:l,"data-testid":"thinking-block","data-streaming":t?"true":void 0,header:a.jsxs(a.Fragment,{children:[a.jsx(xAe,{className:Y("text-muted-foreground size-(--size-icon-xs)",t&&"animate-tasks")}),a.jsx("span",{className:Y("text-3xs text-muted-foreground font-mono",t&&"animate-tasks"),children:l})]}),children:a.jsx("div",{ref:o,className:"max-h-32 overflow-y-auto",children:a.jsx("pre",{className:"text-muted-foreground text-xs break-words whitespace-pre-wrap",children:e})})})}const $gt={duration:.25,ease:[.4,0,.2,1]},Hgt={max_turns:{heading:"Turn limit reached",subtext:"The agent ran for its maximum number of turns.",retryable:!1},execution_error:{heading:"Agent stopped unexpectedly",subtext:"An error occurred during execution.",retryable:!0},budget_exceeded:{heading:"Cost limit reached",subtext:"This session exceeded its budget.",retryable:!1},output_format_error:{heading:"Output format error",subtext:"The agent couldn't produce the required output format.",retryable:!1}};function KP({message:e,category:t,details:n,onRetry:s,heading:r,subtext:i}){const[o,l]=x.useState(!1),c=t?Hgt[t]:null,u=r??(c==null?void 0:c.heading)??"Error",d=i??(c==null?void 0:c.subtext)??e,f=(c==null?void 0:c.retryable)??!!s;return a.jsx("div",{className:Y("my-2 rounded-lg border px-4 py-3","border-destructive/30 bg-destructive/5 text-foreground"),children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(fr,{className:"text-destructive mt-0.5 size-4 shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm font-medium",children:u}),a.jsx("p",{className:"text-muted-foreground mt-0.5 text-sm",children:d}),n&&a.jsxs("button",{type:"button",onClick:()=>l(!o),className:"text-muted-foreground hover:text-foreground mt-2 flex items-center gap-1 text-xs","aria-expanded":o,children:[a.jsx(te.div,{animate:{rotate:o?0:-90},transition:{type:"spring",stiffness:400,damping:30},children:a.jsx(Hs,{className:"size-3"})}),"Details"]}),a.jsx(Ue,{initial:!1,children:o&&n&&a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:$gt,className:"overflow-hidden",children:a.jsx("pre",{className:"bg-muted/50 mt-1 max-h-40 overflow-auto rounded p-2 text-xs whitespace-pre-wrap",children:n})})})]}),f&&s&&a.jsxs(ge,{variant:"outline",size:"sm",onClick:s,className:"shrink-0 gap-1.5",children:[a.jsx(S3e,{className:"size-3"}),"Retry"]})]})})}function Ugt({mode:e,memories:t,isStreaming:n}){const[s,r]=x.useState(n),i=x.useRef(n);if(x.useEffect(()=>{i.current&&!n&&r(!1),i.current=n},[n]),t.length===0)return null;const o=t.length,l=n?o<=1?"Consulting memory…":`Consulting ${o} memories…`:o===1?"Recalled 1 memory":`Recalled ${o} memories`,c=e==="synthesize"?Jg:q5,u=e==="synthesize"?"sparkles":"bookopen";return a.jsx(Xb,{expanded:s,onToggle:()=>r(!s),variant:"memory",dimmed:!n,disabled:n,ariaLabel:l,"data-testid":"memory-recall-block","data-streaming":n?"true":void 0,header:a.jsxs(a.Fragment,{children:[a.jsx(c,{"aria-hidden":"true","data-testid":"memory-recall-header-icon","data-icon":u,className:Y("text-muted-foreground size-(--size-icon-xs)",n&&"animate-tasks")}),a.jsx("span",{className:Y("text-3xs text-muted-foreground font-mono",n&&"animate-tasks"),children:l})]}),children:a.jsx(Vgt,{memories:t})})}function Vgt({memories:e}){return a.jsx("ul",{className:"flex flex-col gap-1 px-3 py-2",children:e.map(t=>a.jsx(qgt,{memory:t},t.path))})}function qgt({memory:e}){const t=e.path.startsWith("<synthesis:"),n=e.scope==="team"?e0:Md,s=e.scope==="team"?"team":"personal",r=async()=>{const i=t&&e.content?e.content:e.path;try{await navigator.clipboard.writeText(i),Ye.success("Copied to clipboard")}catch{Ye.error("Failed to copy")}};if(t&&e.content){const i=e.path.replace(/^<synthesis:/,"synthesis:").replace(/>$/,"");return a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:r,"aria-label":`Copy synthesized ${s} memory content`,"data-scope":e.scope,className:"focus-ring hover:bg-muted/50 flex min-h-[44px] w-full flex-col items-start gap-1 rounded-md px-2 py-1 text-left",children:[a.jsx("span",{className:"text-sm",children:e.content}),a.jsxs("span",{className:"text-3xs text-muted-foreground flex items-center gap-1 font-mono",children:[a.jsx(n,{"aria-hidden":"true",className:"size-(--size-icon-xs)"}),i]})]})})}return a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:r,"aria-label":`Copy ${s} memory path ${e.path}`,"data-scope":e.scope,className:"focus-ring hover:bg-muted/50 flex min-h-[44px] w-full items-center gap-2 rounded-md px-2 py-1 text-left",children:[a.jsx("span",{className:"flex-1 truncate font-mono text-sm",children:eOe(e.path,40)}),a.jsx(n,{"aria-hidden":"true",className:"text-muted-foreground size-(--size-icon-xs)"})]})})}function Ggt({toolName:e,reasonType:t,reason:n,message:s}){const r=t==="classifier",i=n||s,o=r?`Blocked by auto-mode classifier: ${i}`:`Blocked: ${i}`;return a.jsxs("div",{"data-testid":"permission-denied-chip","data-reason-type":t,className:Y("my-2 flex items-start gap-2 rounded-md border px-3 py-2","text-foreground border-amber-500/30 bg-amber-500/5"),children:[a.jsx(H3e,{"aria-hidden":"true",className:"mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-500"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm",children:o}),a.jsx("p",{className:"text-muted-foreground mt-0.5 font-mono text-xs",children:e})]})]})}function Kgt(e,t){return e===void 0?"Compacted context":t===void 0?`Compacted context — ${fk(e)} tokens summarized`:`Compacted context — ${fk(e)} → ${fk(t)} tokens`}function Wgt({trigger:e,preTokens:t,postTokens:n,failed:s,error:r}){return s?a.jsx(Yp,{"data-testid":"compact-boundary-row","data-failed":"true",icon:a.jsx(fr,{"aria-hidden":"true",className:"size-3 shrink-0 text-amber-500"}),label:a.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:"Compaction failed"}),children:r?a.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:r}):null}):a.jsx(Yp,{"data-testid":"compact-boundary-row",icon:a.jsx(ma,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:a.jsx("span",{className:"text-muted-foreground",children:Kgt(t,n)}),trailing:e?a.jsx("span",{"data-testid":"compact-boundary-trigger",className:"text-3xs text-muted-foreground/70 ml-auto font-mono uppercase",children:e}):void 0})}function Ygt(e){const t=je(),{sessionId:n,serverName:s,uri:r,enabled:i=!0}=e;return st({queryKey:["mcp-app-resource",n,s,r],queryFn:()=>t.fetchMcpAppResource(n,{serverName:s,uri:r}),enabled:i&&!!(n&&s&&r),staleTime:300*1e3,retry:!1})}const Zq=-32601,Xq=-32e3,Zgt=["inline","fullscreen"];function Xgt(e){const{iframe:t,expectedOrigin:n,hostContext:s,handlers:r}=e,i=d=>{var f;(f=t.contentWindow)==null||f.postMessage(d,"*")},o=(d,f)=>{d!=null&&i({jsonrpc:"2.0",id:d,result:f})},l=(d,f,m)=>{d!=null&&i({jsonrpc:"2.0",id:d,error:{code:f,message:m}})},c=async d=>{switch(d.method){case"ui/initialize":{o(d.id,{availableDisplayModes:[...Zgt],hostContext:s});return}case"resources/read":{const f=Jgt(d.params);if(!f)return l(d.id,Zq,"resources/read requires a uri");try{const m=await r.readResource(f);o(d.id,{contents:[{uri:f,...m}]})}catch(m){l(d.id,Xq,m instanceof Error?m.message:"read failed")}return}case"ui/open-link":{const f=e0t(d.params);f&&r.openLink(f),o(d.id,{});return}case"ui/request-display-mode":{const f=t0t(d.params);f&&r.requestDisplayMode(f),o(d.id,{granted:f==="fullscreen"||f==="inline"});return}case"tools/call":{l(d.id,Xq,"App tool calls are not permitted in this host (v1)");return}default:{l(d.id,Zq,`Unknown method: ${d.method}`);return}}},u=d=>{if(d.source!==t.contentWindow||d.origin!==n)return;const f=Qgt(d.data);f&&c(f)};return window.addEventListener("message",u),()=>window.removeEventListener("message",u)}function Qgt(e){if(typeof e!="object"||e===null)return null;const t=e;return t.jsonrpc!=="2.0"||typeof t.method!="string"?null:{jsonrpc:"2.0",method:t.method,id:t.id,params:t.params}}function Jgt(e){const t=e==null?void 0:e.uri;return typeof t=="string"?t:void 0}function e0t(e){const t=e==null?void 0:e.url;return typeof t=="string"?t:void 0}function t0t(e){const t=e==null?void 0:e.mode;return t==="inline"||t==="fullscreen"||t==="pip"?t:void 0}const n0t="allow-scripts",s0t="null",r0t="default-src 'none'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'",i0t={camera:"camera",microphone:"microphone",geolocation:"geolocation","clipboard-write":"clipboard-write"};function a0t(e){if(e.length!==0)return e.map(t=>`${i0t[t]} 'self'`).join("; ")}function o0t(e,t){const n=t&&t.trim().length>0?t:r0t,s=`<meta http-equiv="Content-Security-Policy" content="${l0t(n)}">`;return/<head[^>]*>/i.test(e)?e.replace(/<head[^>]*>/i,r=>`${r}${s}`):/<html[^>]*>/i.test(e)?e.replace(/<html[^>]*>/i,r=>`${r}<head>${s}</head>`):`<!doctype html><html><head>${s}</head><body>${e}</body></html>`}function l0t(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<")}function c0t(){return document.documentElement.classList.contains("dark")?"dark":"light"}function Fde({sessionId:e,serverName:t,uri:n,title:s,onRequestFullscreen:r,className:i}){const o=je(),l=x.useRef(null),[c,u]=x.useState(null),{data:d,isLoading:f,isError:m,error:g}=Ygt({sessionId:e,serverName:t,uri:n}),y=d!=null&&d.text?o0t(d.text,d.csp):void 0,b=a0t((d==null?void 0:d.permissions)??[]),S=x.useCallback(async E=>{const j=await o.fetchMcpAppResource(e,{serverName:t,uri:E});return{mimeType:j.mimeType,text:j.text,blob:j.blob}},[o,e,t]),w=x.useCallback(E=>{E==="fullscreen"&&(r==null||r())},[r]),[C,T]=x.useState(void 0);return x.useEffect(()=>{const E=l.current;if(!E||!y)return;const j=Xgt({iframe:E,expectedOrigin:s0t,hostContext:{hostName:"DorkOS",theme:c0t()},handlers:{readResource:S,openLink:_=>u(_),requestDisplayMode:w}});return T(y),j},[y,S,w]),f?a.jsx("div",{className:Y("text-muted-foreground p-4 text-sm",i),children:"Loading app…"}):m||!y?a.jsx("div",{className:Y("text-muted-foreground p-4 text-sm",i),children:m?`Could not load app from ${t}: ${g instanceof Error?g.message:"unknown error"}`:"This app returned no renderable content."}):a.jsxs("div",{className:Y("relative h-full w-full",i),children:[a.jsx("iframe",{ref:l,title:s??`MCP App from ${t}`,sandbox:n0t,...b?{allow:b}:{},srcDoc:C,className:"bg-background h-full w-full border-0"}),a.jsx(TT,{url:c??"",isOpen:c!==null,onClose:()=>u(null),onConfirm:()=>{c&&window.open(c,"_blank","noopener,noreferrer"),u(null)}})]})}const zde="dorkos:mcp-app-consent:";function Bde(e){return`${zde}${e}`}function u0t(e){try{return localStorage.getItem(Bde(e))==="granted"}catch{return!1}}function d0t(e){try{localStorage.setItem(Bde(e),"granted")}catch{}f0t()}const XD=new Set;function f0t(){for(const e of XD)e()}function h0t(e){XD.add(e);const t=n=>{var s;(s=n.key)!=null&&s.startsWith(zde)&&e()};return window.addEventListener("storage",t),()=>{XD.delete(e),window.removeEventListener("storage",t)}}function m0t(e){const t=x.useSyncExternalStore(h0t,()=>u0t(e),()=>!1),n=x.useCallback(()=>d0t(e),[e]);return{consented:t,grant:n}}const p0t="h-80";function g0t({sessionId:e,serverName:t,uri:n,title:s}){const{consented:r,grant:i}=m0t(t),o=we(u=>u.setCanvasOpen),l=we(u=>u.openCanvasDocument),c=()=>{l({type:"mcp_app",serverName:t,uri:n,title:s}),o(!0)};return r?a.jsxs("div",{className:"overflow-hidden rounded-lg border",children:[a.jsxs("div",{className:"bg-muted/40 flex items-center justify-between border-b px-3 py-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium",children:[a.jsx(ZM,{className:"text-muted-foreground size-3.5 shrink-0"}),a.jsx("span",{className:"truncate",children:s??`App · ${t}`})]}),a.jsx("button",{type:"button",onClick:c,title:"Open in canvas",className:"text-muted-foreground hover:bg-muted hover:text-foreground rounded-md p-1 transition-colors",children:a.jsx(lne,{className:"size-3.5"})})]}),a.jsx(Fde,{sessionId:e,serverName:t,uri:n,title:s,onRequestFullscreen:c,className:p0t})]}):a.jsxs("div",{className:"bg-muted/40 flex flex-col gap-3 rounded-lg border p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[a.jsx(ZM,{className:"text-muted-foreground size-4 shrink-0"}),a.jsxs("span",{children:["Interactive app provided by ",t]})]}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"This runs sandboxed code from the MCP server. It cannot access your session, files, or credentials. Render it?"}),a.jsx("div",{children:a.jsx("button",{type:"button",onClick:i,className:"bg-foreground text-background hover:bg-foreground/90 rounded-lg px-3 py-1.5 text-sm font-medium transition-colors",children:"Render app"})})]})}function x0t(e){if(e.startsWith("mcp__"))return e.split("__")[1]||void 0}function $de(e,t,n){const s=x.useRef(e),[r,i]=x.useState(!(t&&s.current==="complete"));return x.useEffect(()=>{if(t&&e==="complete"&&s.current!=="complete"&&!n){const o=setTimeout(()=>i(!1),yo.TOOL_CALL_AUTO_HIDE_MS);return()=>clearTimeout(o)}},[e,t,n]),!t||n?!0:r}function Qq({part:e,autoHide:t,expandToolCalls:n}){var i;const s=((i=e.hooks)==null?void 0:i.some(o=>o.status==="error"))??!1,r=$de(e.status,t,s);return a.jsx(Ue,{children:r&&a.jsx(te.div,{exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:a.jsx(Tgt,{toolCall:{toolCallId:e.toolCallId,toolName:e.toolName,input:e.input||"",result:e.result,progressOutput:e.progressOutput,status:e.status,hooks:e.hooks,startedAt:e.startedAt,completedAt:e.completedAt},defaultExpanded:n})},e.toolCallId)})}function y0t({part:e,autoHide:t,index:n}){const s=e.isStreaming?"running":"complete",r=$de(s,t,!1);return a.jsx(Ue,{children:r&&a.jsx(te.div,{exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:a.jsx(Bgt,{text:e.text,isStreaming:e.isStreaming??!1,elapsedMs:e.elapsedMs})},`thinking-${n}`)})}const v0t=4,Jq=2;function b0t({children:e}){const[t,n]=x.useState(!1);if(e.length<=v0t||t)return a.jsx(a.Fragment,{children:e});const s=e.length-Jq;return a.jsxs(a.Fragment,{children:[e.slice(0,Jq),a.jsx(Xb,{expanded:!1,onToggle:()=>n(!0),hideChevron:!0,className:"border-l-muted-foreground/15",header:a.jsxs(a.Fragment,{children:[a.jsx(Rs,{className:"text-muted-foreground size-(--size-icon-xs)"}),a.jsxs("span",{className:"text-3xs text-muted-foreground font-mono",children:["and ",s," more steps…"]})]}),children:a.jsx(a.Fragment,{})})]})}function S0t({message:e}){const{sessionId:t,isStreaming:n,isLatestMessage:s,activeToolCallId:r,onToolRef:i,focusedOptionIndex:o,onToolDecided:l,onRetry:c,inputZoneToolCallId:u,textEffect:d}=Uht(),{expandToolCalls:f,autoHideToolCalls:m}=we(),g=e.parts??[],y=x.useCallback(E=>{i==null||i(E)},[i]),b=x.useCallback(E=>{i==null||i(E)},[i]);let S=-1;for(let E=g.length-1;E>=0;E--)if(g[E].type==="text"){S=E;break}function w(E,j){if(E.type==="text")return a.jsx("div",{className:"msg-assistant",children:a.jsx(Sgt,{content:E.text,isStreaming:n&&j===S,textEffect:d,sessionId:t,isLatestMessage:s})},`text-${j}`);if(E.type==="background_task")return a.jsx(Fgt,{part:E},E.taskId);if(E.type==="error")return a.jsx(KP,{message:E.message,category:E.category,details:E.details,onRetry:c},`error-${j}`);if(E.type==="thinking")return a.jsx(y0t,{part:E,autoHide:m,index:j},`thinking-${j}`);if(E.type==="elicitation")return a.jsx(Igt,{sessionId:t,interactionId:E.interactionId,serverName:E.serverName,message:E.message,mode:E.mode,url:E.url,requestedSchema:E.requestedSchema,status:E.status,action:E.action},`elicitation-${E.interactionId}`);if(E.type==="memory_recall")return a.jsx(Ugt,{mode:E.mode,memories:E.memories,isStreaming:E.isStreaming??!1},`memory-recall-${j}`);if(E.type==="permission_denied")return a.jsx(Ggt,{toolName:E.toolName,reasonType:E.reasonType,reason:E.reason,message:E.message},`permission-denied-${E.toolCallId}-${j}`);if(E.type==="compact_boundary")return a.jsx(Wgt,{trigger:E.trigger,preTokens:E.preTokens,postTokens:E.postTokens,failed:E.failed,error:E.error},`compact-boundary-${j}`);const _=E;if(_.interactiveType==="approval"&&_.status==="pending"){if(_.toolCallId===u)return a.jsx(Vq,{type:"approval",toolName:_.toolName,toolInput:_.input},_.toolCallId);const R=_.toolCallId===r;return a.jsx(Pde,{ref:R?y:void 0,sessionId:t,toolCallId:_.toolCallId,toolName:_.toolName,input:_.input||"",timeoutMs:_.timeoutMs,approvalStartedAt:_.approvalStartedAt,approvalRemainingMs:_.approvalRemainingMs,approvalTitle:_.approvalTitle,approvalDisplayName:_.approvalDisplayName,approvalDescription:_.approvalDescription,approvalBlockedPath:_.approvalBlockedPath,approvalDecisionReason:_.approvalDecisionReason,approvalHasSuggestions:_.approvalHasSuggestions,isActive:R,onDecided:l?()=>l(_.toolCallId):void 0},_.toolCallId)}if(_.interactiveType==="question"&&_.questions){if(_.toolCallId===u)return a.jsx(Vq,{type:"question",toolName:_.toolName,toolInput:_.input},_.toolCallId);const R=_.toolCallId===r;return a.jsx(Lde,{ref:R?b:void 0,sessionId:t,toolCallId:_.toolCallId,questions:_.questions,answers:_.answers??(_.status!=="pending"?{}:void 0),isActive:R,focusedOptionIndex:R?o:-1,onDecided:l?O=>l(_.toolCallId,O):void 0},_.toolCallId)}const N=_.ui?x0t(_.toolName):void 0;return _.ui&&_.status==="complete"&&N?a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Qq,{part:_,autoHide:m,expandToolCalls:f}),a.jsx(g0t,{sessionId:t,serverName:N,uri:_.ui.resourceUri})]},_.toolCallId):a.jsx(Qq,{part:_,autoHide:m,expandToolCalls:f},_.toolCallId)}const C=[];let T=[];for(let E=0;E<g.length;E++){const j=g[E];j.type==="thinking"||j.type==="tool_call"&&!j.interactiveType?T.push(E):(T.length>0&&(C.push(T.length===1?{type:"single",index:T[0]}:{type:"run",indices:[...T]}),T=[]),C.push({type:"single",index:E}))}return T.length>0&&C.push(T.length===1?{type:"single",index:T[0]}:{type:"run",indices:[...T]}),a.jsx(a.Fragment,{children:C.map(E=>{if(E.type==="single"){const _=g[E.index];return _.type==="thinking"||_.type==="tool_call"&&!_.interactiveType?a.jsx("div",{className:"my-3",children:w(_,E.index)},`spacer-${E.index}`):w(_,E.index)}const j=E.indices.map(_=>w(g[_],_));return a.jsx("div",{className:"my-3",children:a.jsx(b0t,{children:j})},`run-${E.indices[0]}`)})})}function w0t({prompt:e,sessionId:t,className:n}){const s=Hn(),{sessions:r}=bl(),{data:i}=im(),{data:o}=VT(),[l,c]=x.useState({open:!1}),u=r.find(S=>S.id===t),d=u==null?void 0:u.runtime,f=u==null?void 0:u.cwd,m=yD.filter(S=>S!==d),g=S=>(i?S in i.capabilities:!0)&&xD(o,S),y=S=>{s({to:"/session",search:{session:crypto.randomUUID(),dir:f,runtime:S,prompt:e}})},b=S=>{if(!g(S)){c({open:!0,runtime:S});return}y(S)};return a.jsxs(a.Fragment,{children:[a.jsxs(i4,{children:[a.jsx(a4,{asChild:!0,children:a.jsx("button",{type:"button","aria-label":"Run this prompt with another runtime",className:Y("text-muted-foreground/60 hover:text-foreground inline-flex items-center transition-colors duration-150",n),children:a.jsx(q3e,{className:"size-3.5"})})}),a.jsxs(o4,{align:"end",className:"w-52",children:[a.jsx(l4,{children:"Run this with…"}),m.map(S=>{const w=Ka(S);return a.jsx(F3,{icon:w.icon,description:g(S)?void 0:"Connect",onSelect:()=>b(S),children:w.label},S)})]})]}),a.jsx(Xle,{runtime:l.runtime,open:l.open,onOpenChange:S=>c(w=>({...w,open:S})),renderConnect:SP,onRuntimeReady:S=>{c({open:!1}),y(S)}})]})}function k0t(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function C0t({message:e,grouping:t,sessionId:n,isNew:s=!1,isStreaming:r=!1,isLatestMessage:i=!1,activeToolCallId:o=null,onToolRef:l,focusedOptionIndex:c=-1,onToolDecided:u,onRetry:d,inputZoneToolCallId:f=null,textEffect:m}){const g=e.role==="user",y=e.messageType==="local_command_output",b=g&&!y,S=b&&!0&&e.messageType!=="command"&&e.messageType!=="compaction"&&e.content.trim().length>0,{showTimestamps:w}=we(),{position:C,groupIndex:T}=t,E=C==="only"||C==="first",j=$ht({role:b?"user":"assistant",position:C});return a.jsx(Hht,{value:{sessionId:n,isStreaming:r,isLatestMessage:i,activeToolCallId:o,onToolRef:l,focusedOptionIndex:c,onToolDecided:u,onRetry:d,inputZoneToolCallId:f,textEffect:m},children:a.jsxs(te.div,{initial:s?{opacity:0,y:8,x:b?12:0,scale:b?.97:1}:!1,animate:{opacity:1,y:0,x:0,scale:1},transition:{type:"spring",stiffness:320,damping:28},"data-testid":"message-item","data-role":e.role,className:j.root(),children:[E&&T>0&&!g&&a.jsx("div",{className:j.divider()}),e.timestamp&&a.jsx("span",{className:Y(j.timestamp(),w?"text-msg-timestamp":"group-hover:text-msg-timestamp text-transparent"),children:k0t(e.timestamp)}),S&&a.jsx(w0t,{prompt:e.content,sessionId:n,className:"absolute top-2 -left-9 opacity-0 group-hover:opacity-100 focus-visible:opacity-100"}),a.jsx("div",{className:j.content(),children:g?a.jsx(vgt,{message:e}):a.jsx(S0t,{message:e})})]})})}const eG=800,tG=24;function E0t({scrollRef:e}){const t=x.useRef(null),n=x.useRef(null),s=x.useRef(null),[r,i]=x.useState(!1),o=x.useRef(!1),l=x.useRef(0),c=x.useRef(0),u=x.useCallback(()=>{i(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{o.current||i(!1)},eG)},[]),d=x.useCallback(()=>{const g=e.current,y=t.current,b=n.current;if(!g||!y||!b)return;const{scrollTop:S,scrollHeight:w,clientHeight:C}=g;if(w<=C){y.style.display="none";return}y.style.display="";const T=b.clientHeight,E=C/w,j=Math.max(E*T,tG),_=T-j,R=S/(w-C)*_;y.style.height=`${j}px`,y.style.transform=`translateY(${R}px)`},[e]);x.useEffect(()=>{const g=e.current;if(!g)return;const y=()=>{u(),d()};return g.addEventListener("scroll",y,{passive:!0}),d(),()=>g.removeEventListener("scroll",y)},[e,u,d]);const f=x.useCallback(g=>{if(g.target===t.current)return;const y=e.current,b=n.current;if(!y||!b)return;const S=b.getBoundingClientRect(),w=(g.clientY-S.top)/S.height;y.scrollTop=w*(y.scrollHeight-y.clientHeight)},[e]),m=x.useCallback(g=>{var S;g.preventDefault(),g.stopPropagation(),o.current=!0,l.current=g.clientY,c.current=((S=e.current)==null?void 0:S.scrollTop)??0;const y=w=>{const C=e.current,T=n.current;if(!C||!T)return;const E=w.clientY-l.current,j=T.clientHeight,_=C.clientHeight/C.scrollHeight,N=Math.max(_*j,tG),R=j-N,O=C.scrollHeight-C.clientHeight,M=E/R*O;C.scrollTop=c.current+M},b=()=>{o.current=!1,document.removeEventListener("pointermove",y),document.removeEventListener("pointerup",b),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>i(!1),eG)};document.addEventListener("pointermove",y),document.addEventListener("pointerup",b)},[e]);return a.jsx("div",{ref:n,role:"presentation",onClick:f,className:"pointer-events-auto absolute top-12 right-0 bottom-0 z-10 w-2.5",children:a.jsx("div",{ref:t,onPointerDown:m,className:"bg-border absolute right-0.5 w-1.5 cursor-pointer rounded-full transition-opacity duration-200",style:{opacity:r?1:0}})})}function T0t(e){let t=0;return e.map((n,s)=>{const r=s>0?e[s-1].role:null,i=s<e.length-1?e[s+1].role:null,o=r!==n.role,l=i!==n.role;o&&s>0&&t++;let c;return o&&l?c="only":o?c="first":l?c="last":c="middle",{position:c,groupIndex:t}})}const _0t=x.forwardRef(function({messages:t,sessionId:n,isTextStreaming:s,onScrollStateChange:r,activeToolCallId:i,onToolRef:o,focusedOptionIndex:l,onToolDecided:c,onRetry:u,inputZoneToolCallId:d,textEffect:f},m){const[g,y]=x.useState(null),b=x.useMemo(()=>T0t(t),[t]),{scrollRef:S,contentRef:w,isAtBottom:C,scrollToBottom:T}=Aht({resize:"smooth",initial:"instant"});x.useEffect(()=>{g===null&&t.length>0&&y(t.length)},[t.length,g]);const E=Eht({count:t.length,getScrollElement:()=>S.current,estimateSize:()=>80,overscan:5,measureElement:j=>(j==null?void 0:j.getBoundingClientRect().height)??80});return x.useEffect(()=>{r==null||r({isAtBottom:C,distanceFromBottom:C?0:200})},[C,r]),x.useEffect(()=>{const j=S.current;if(!j||t.length===0)return;let _=!1;const N=new IntersectionObserver(([R])=>{R.isIntersecting?_&&(_=!1,requestAnimationFrame(()=>{T()})):_=!0},{threshold:.1});return N.observe(j),()=>N.disconnect()},[S,t.length,T]),x.useImperativeHandle(m,()=>({scrollToBottom:T}),[T]),a.jsxs("div",{"data-testid":"message-list",className:"relative h-full",children:[a.jsx("div",{ref:S,className:"chat-scroll-area hide-scrollbar h-full overflow-y-auto px-3 pt-12",style:{overflowAnchor:"none"},children:a.jsx("div",{ref:w,style:{height:E.getTotalSize(),position:"relative",width:"100%"},children:E.getVirtualItems().map(j=>{const _=t[j.index],N=g!==null&&j.index>=g,R=j.index===t.length-1,M=R&&_.role==="assistant"&&!!s;return a.jsx("div",{"data-index":j.index,ref:E.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${j.start}px)`},children:a.jsx(C0t,{message:_,grouping:b[j.index],sessionId:n,isNew:N,isStreaming:M,isLatestMessage:R,activeToolCallId:i,onToolRef:o,focusedOptionIndex:l,onToolDecided:c,onRetry:u,inputZoneToolCallId:d,textEffect:f})},j.key)})})}),a.jsx(E0t,{scrollRef:S})]})});function N0t({messages:e,sessionId:t,isLoadingHistory:n,isTextStreaming:s,isAtBottom:r,hasNewMessages:i,scrollToBottom:o,onScrollStateChange:l,activeToolCallId:c,onToolRef:u,focusedOptionIndex:d,onToolDecided:f,onRetry:m,inputZoneToolCallId:g,messageListRef:y}){const b=we(w=>w.dorkbotFirstMessage),S=we(w=>w.setDorkbotFirstMessage);return a.jsxs("div",{className:"relative min-h-0 flex-1",children:[n?a.jsx("div",{className:"flex h-full items-center justify-center",children:a.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:[a.jsxs("div",{className:"flex gap-1",children:[a.jsx("span",{className:"bg-muted-foreground h-2 w-2 rounded-full",style:{animation:"typing-dot 1.4s ease-in-out infinite",animationDelay:"0s"}}),a.jsx("span",{className:"bg-muted-foreground h-2 w-2 rounded-full",style:{animation:"typing-dot 1.4s ease-in-out infinite",animationDelay:"0.2s"}}),a.jsx("span",{className:"bg-muted-foreground h-2 w-2 rounded-full",style:{animation:"typing-dot 1.4s ease-in-out infinite",animationDelay:"0.4s"}})]}),"Loading conversation..."]})}):e.length===0?a.jsx("div",{className:"flex h-full items-center justify-center",children:b?a.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[a.jsx(te.div,{layoutId:"dorkbot-first-message",className:"bg-muted/50 w-full max-w-md rounded-lg border p-4","data-testid":"dorkbot-welcome-message",onLayoutAnimationComplete:()=>{S(null)},children:a.jsx("p",{className:"text-muted-foreground text-sm",children:b})}),a.jsx("p",{className:"text-muted-foreground/60 text-sm",children:"Type a message below to begin"})]}):a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-muted-foreground text-base",children:"Start a conversation"}),a.jsx("p",{className:"text-muted-foreground/60 mt-2 text-sm",children:"Type a message below to begin"})]})}):a.jsx(_0t,{ref:y,messages:e,sessionId:t,isTextStreaming:s,onScrollStateChange:l,activeToolCallId:c,onToolRef:u,focusedOptionIndex:d,onToolDecided:f,onRetry:m,inputZoneToolCallId:g}),a.jsx(Ue,{children:i&&!r&&a.jsx(te.button,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:{duration:.2},onClick:o,className:"bg-foreground text-background hover:bg-foreground/90 absolute bottom-16 left-1/2 z-10 -translate-x-1/2 cursor-pointer rounded-full px-3 py-1.5 text-xs font-medium shadow-sm transition-colors",role:"status","aria-live":"polite",children:"New messages"})}),a.jsx(Ue,{children:!r&&e.length>0&&!n&&a.jsx(te.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.15},onClick:o,className:"bg-background absolute right-4 bottom-4 rounded-full border p-2 shadow-sm transition-shadow hover:shadow-md","aria-label":"Scroll to bottom",children:a.jsx(hb,{className:"size-(--size-icon-md)"})})})]})}const j0t=500;function A0t({textareaRef:e,value:t,isStreaming:n,isMobile:s,sessionBusy:r,editingQueueItem:i,isPaletteOpen:o,queueHasItems:l,onSubmit:c,onStop:u,onEscape:d,onClear:f,onArrowUp:m,onArrowDown:g,onCommandSelect:y,onQueue:b,onSaveEdit:S,onCancelEdit:w,onQueueNavigateUp:C,onQueueNavigateDown:T}){const E=x.useRef(0);return x.useCallback(_=>{if(_.key==="Escape"&&n){u==null||u();return}if(_.key==="Escape"&&i){w==null||w();return}if(_.key==="Escape"){const N=Date.now();o?(d==null||d(),E.current=N):t.trim()&&N-E.current<j0t?(f==null||f(),E.current=0):(d==null||d(),E.current=N);return}if(!o&&l){if(_.key==="ArrowUp"){const N=e.current,R=!N||N.selectionStart===0;if(!t.trim()||R){_.preventDefault(),C==null||C();return}}if(_.key==="ArrowDown"){const N=e.current,R=!N||N.selectionStart===N.value.length;if(i&&R){_.preventDefault(),T==null||T();return}}}if(o){if(_.key==="ArrowDown"){_.preventDefault(),g==null||g();return}if(_.key==="ArrowUp"){_.preventDefault(),m==null||m();return}if(_.key==="Enter"&&!_.shiftKey||_.key==="Tab"){_.preventDefault(),y==null||y();return}}_.key==="Enter"&&!_.shiftKey&&!s&&(_.preventDefault(),i&&t.trim()?S==null||S():n&&t.trim()?b==null||b():!n&&!r&&t.trim()&&c())},[n,s,t,c,u,d,f,o,m,g,y,i,b,S,w,l,C,T,r,e])}const R0t=200,nG=24;function M0t(e,t){const n=x.useCallback(()=>{const s=e.current;s&&(s.style.height="auto",s.style.height=`${Math.min(s.scrollHeight,R0t)}px`)},[e]);return x.useEffect(()=>{const s=e.current;if(!s||t!=="")return;const r=s.scrollHeight;if(r<=nG)return;s.style.height=`${r}px`,s.style.transition="height 200ms ease",requestAnimationFrame(()=>{s.style.height=`${nG}px`});const i=()=>{s.style.transition="",s.style.height=""};return s.addEventListener("transitionend",i,{once:!0}),()=>s.removeEventListener("transitionend",i)},[e,t]),n}const NR={send:{icon:null,className:"bg-primary text-primary-foreground hover:bg-primary/90",label:"Send message"},stop:{icon:pne,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",label:"Stop generating"},queue:{icon:Pi,className:"bg-muted text-muted-foreground hover:bg-muted/80",label:"Queue message"},update:{icon:Lt,className:"bg-primary text-primary-foreground hover:bg-primary/90",label:"Save edit"}};function D0t(e,t,n,s){return s&&e?"update":t&&e?"queue":t?"stop":e&&!n?"send":null}function O0t({hasText:e,isStreaming:t,isUploading:n,sessionBusy:s,editingQueueItem:r,queueDepth:i,isMobile:o,onSubmit:l,onStop:c,onQueue:u,onSaveEdit:d}){const f=D0t(e,t,n,r),m=o?mb:QAe,g=f==="send"?l:f==="stop"?c:f==="queue"?u:f==="update"?d:void 0;return a.jsxs(a.Fragment,{children:[t&&e&&a.jsx(te.button,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.15},whileHover:{scale:1.1},whileTap:{scale:.9},onClick:c,type:"button",className:"bg-destructive text-destructive-foreground hover:bg-destructive/90 shrink-0 rounded-lg p-1.5 transition-colors max-md:p-2","aria-label":"Stop generating",children:a.jsx(pne,{className:"size-(--size-icon-sm)"})}),f&&a.jsxs("div",{className:"relative",children:[a.jsx(te.button,{animate:{opacity:1,scale:1},transition:{duration:.15},whileHover:s?void 0:{scale:1.1},whileTap:s?void 0:{scale:.9},onClick:g,disabled:f==="send"&&s,className:Y("shrink-0 rounded-lg p-1.5 transition-colors max-md:p-2",NR[f].className,f==="send"&&s&&"pointer-events-none opacity-50"),"aria-label":NR[f].label,children:f==="send"?a.jsx(m,{className:"size-(--size-icon-sm)"}):(()=>{const y=NR[f].icon;return a.jsx(y,{className:"size-(--size-icon-sm)"})})()}),i>0&&f==="queue"&&a.jsx("span",{className:"bg-foreground text-background absolute -top-1 -right-1 flex h-4 w-4 items-center justify-center rounded-full text-[10px] font-medium",children:i})]})]})}const I0t=x.forwardRef(function({value:t,onChange:n,onSubmit:s,isStreaming:r,isUploading:i=!1,sessionBusy:o=!1,editingQueueItem:l=!1,queueDepth:c=0,onStop:u,onQueue:d,onSaveEdit:f,onCancelEdit:m,onEscape:g,onClear:y,isPaletteOpen:b,onArrowUp:S,onArrowDown:w,onCommandSelect:C,activeDescendantId:T,onCursorChange:E,onAttach:j,placeholder:_="Send a message...",placeholderOverlay:N,onQueueNavigateUp:R,onQueueNavigateDown:O,queueHasItems:M=!1},L){const P=x.useRef(null),$=x.useRef(null),[q,K]=x.useState(!1),B=Us();x.useImperativeHandle(L,()=>({focus:()=>{var J;return(J=P.current)==null?void 0:J.focus()},focusAt:J=>{const ae=P.current;ae&&(ae.focus(),ae.setSelectionRange(J,J))}})),x.useEffect(()=>{var J;(J=P.current)==null||J.focus()},[]);const V=A0t({textareaRef:P,value:t,isStreaming:r,isMobile:B,sessionBusy:o,editingQueueItem:l,isPaletteOpen:b,queueHasItems:M,onSubmit:s,onStop:u,onEscape:g,onClear:y,onArrowUp:S,onArrowDown:w,onCommandSelect:C,onQueue:d,onSaveEdit:f,onCancelEdit:m,onQueueNavigateUp:R,onQueueNavigateDown:O}),Q=M0t(P,t),re=x.useCallback(()=>K(!0),[]),U=x.useCallback(()=>{K(!1),b&&(g==null||g())},[b,g]),G=x.useCallback(J=>{n(J.target.value),E==null||E(J.target.selectionStart),Q()},[n,E,Q]),W=x.useCallback(()=>{P.current&&(E==null||E(P.current.selectionStart))},[E]),F=t.trim().length>0,X=F&&!o;return a.jsxs("div",{className:"flex flex-col gap-1.5",children:[o&&a.jsx("div",{className:"px-1 text-xs text-amber-600 dark:text-amber-500",children:"Session is busy. Please wait..."}),l&&a.jsxs("div",{className:"text-muted-foreground px-0.5 text-xs",children:["Editing message",c>0?" —":""]}),a.jsxs("div",{className:Y("border-input bg-background flex items-end gap-1.5 rounded-md border p-1.5 shadow-xs transition-[color,box-shadow]",q&&"border-ring ring-ring/75 ring-[1px]",l&&"border-primary/40",!j&&"pl-3"),children:[j&&a.jsxs(a.Fragment,{children:[a.jsx("input",{ref:$,type:"file",className:"hidden",multiple:!0,onChange:J=>{const ae=Array.from(J.target.files??[]);ae.length>0&&j(ae),J.target.value=""}}),a.jsx("button",{type:"button",onClick:()=>{var J;return(J=$.current)==null?void 0:J.click()},className:"text-muted-foreground hover:text-foreground flex shrink-0 items-center justify-center rounded-md px-1.5 py-1 transition-colors disabled:opacity-50","aria-label":"Attach file",children:a.jsx(n3e,{className:"size-4"})})]}),a.jsxs("div",{className:"relative min-h-[24px] flex-1",children:[!F&&N,a.jsx("textarea",{ref:P,value:t,onChange:G,onKeyDown:V,onFocus:re,onBlur:U,onSelect:W,role:"combobox","aria-autocomplete":"list","aria-controls":b?T!=null&&T.startsWith("file-")?"file-palette-listbox":"command-palette-listbox":void 0,"aria-expanded":b??!1,"aria-activedescendant":b?T:void 0,"aria-label":_,placeholder:N?"":_,className:"block max-h-[200px] min-h-[24px] w-full resize-none bg-transparent py-0.5 text-sm focus:outline-none",rows:1,disabled:o})]}),a.jsx(te.button,{animate:{opacity:X?.5:0,scale:X?1:.8},transition:{duration:.15},whileHover:X?{opacity:1}:void 0,onClick:y,disabled:!X,type:"button",className:Y("text-muted-foreground hover:text-foreground shrink-0 rounded-lg p-1 transition-colors",!X&&"pointer-events-none"),"aria-label":"Clear message",children:a.jsx(es,{className:"size-(--size-icon-sm)"})}),a.jsx(O0t,{hasText:F,isStreaming:r,isUploading:i,sessionBusy:o,editingQueueItem:l,queueDepth:c,isMobile:B,onSubmit:s,onStop:u,onQueue:d,onSaveEdit:f})]})]})});function P0t({sessionId:e,pendingApprovals:t,onAllDecided:n}){const s=je(),[r,i]=x.useState(!1),o=x.useCallback(async()=>{if(!r){i(!0);try{const c=t.map(u=>u.toolCallId);await s.batchApprove(e,c),n==null||n()}catch(c){console.error("Batch approve failed:",c)}finally{i(!1)}}},[r,s,e,t,n]),l=x.useCallback(async()=>{if(!r){i(!0);try{const c=t.map(u=>u.toolCallId);await s.batchDeny(e,c),n==null||n()}catch(c){console.error("Batch deny failed:",c)}finally{i(!1)}}},[r,s,e,t,n]);return t.length<2?null:a.jsxs("div",{className:"border-border bg-muted/50 mb-1.5 flex items-center justify-between rounded-lg border px-3 py-1.5",children:[a.jsxs("span",{className:"text-muted-foreground text-xs",children:[t.length," tools awaiting approval"]}),a.jsxs("div",{className:"flex gap-1.5",children:[a.jsxs(ge,{size:"xs",variant:"outline",onClick:o,disabled:r,children:[a.jsx(CAe,{className:"size-3"})," Approve All"]}),a.jsxs(ge,{size:"xs",variant:"ghost",onClick:l,disabled:r,children:[a.jsx(Xg,{className:"size-3"})," Deny All"]})]})]})}function L0t({sessionId:e,activeInteraction:t,pendingApprovals:n,focusedOptionIndex:s,onToolRef:r,onToolDecided:i}){const o=l=>i(t.toolCallId,l);return a.jsxs(a.Fragment,{children:[a.jsx(P0t,{sessionId:e,pendingApprovals:n}),t.interactiveType==="approval"?a.jsx(Pde,{ref:r,sessionId:e,toolCallId:t.toolCallId,toolName:t.toolName,input:t.input||"",isActive:!0,onDecided:o,timeoutMs:t.timeoutMs,approvalStartedAt:t.approvalStartedAt,approvalTitle:t.approvalTitle,approvalDisplayName:t.approvalDisplayName,approvalDescription:t.approvalDescription,approvalBlockedPath:t.approvalBlockedPath,approvalDecisionReason:t.approvalDecisionReason,approvalHasSuggestions:t.approvalHasSuggestions}):t.interactiveType==="question"&&t.questions?a.jsx(Lde,{ref:r,sessionId:e,toolCallId:t.toolCallId,questions:t.questions,answers:t.answers,isActive:!0,focusedOptionIndex:s,onDecided:o}):null]})}const sG=e=>Symbol.iterator in e,rG=e=>"entries"in e,iG=(e,t)=>{const n=e instanceof Map?e:new Map(e.entries()),s=t instanceof Map?t:new Map(t.entries());if(n.size!==s.size)return!1;for(const[r,i]of n)if(!s.has(r)||!Object.is(i,s.get(r)))return!1;return!0},F0t=(e,t)=>{const n=e[Symbol.iterator](),s=t[Symbol.iterator]();let r=n.next(),i=s.next();for(;!r.done&&!i.done;){if(!Object.is(r.value,i.value))return!1;r=n.next(),i=s.next()}return!!r.done&&!!i.done};function z0t(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:sG(e)&&sG(t)?rG(e)&&rG(t)?iG(e,t):F0t(e,t):iG({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function B0t(e){const t=he.useRef(void 0);return n=>{const s=e(n);return z0t(t.current,s)?t.current:t.current=s}}const $0t=e=>["workspaces",e??null];function H0t(e){const t=je(),n=st({queryKey:$0t(e),queryFn:()=>t.listWorkspaces(e)});return{workspaces:n.data??[],isLoading:n.isLoading,error:n.error}}function Hde(){const e=et();return()=>e.invalidateQueries({queryKey:["workspaces"]})}function U0t(e){const t=je();return st({queryKey:["workspace-for-session",e??null],queryFn:()=>t.resolveWorkspace(e),enabled:!!e}).data??null}function V0t(e){const t=e.contextUsage;return!t||t.maxTokens<=0?null:Math.min(100,Math.round(t.totalTokens/t.maxTokens*100))}function q0t(e){var n;const t=e.cacheStats;return!t||t.cacheReadTokens===0&&t.cacheCreationTokens===0?null:{cacheReadTokens:t.cacheReadTokens,cacheCreationTokens:t.cacheCreationTokens,contextTokens:(n=e.contextUsage)==null?void 0:n.totalTokens}}function G0t(e){return e?{contextPercent:V0t(e),costUsd:e.cost,model:e.model,cacheStatus:q0t(e),usage:e.usage}:{contextPercent:null,costUsd:null,model:null,cacheStatus:null,usage:null}}function K0t({children:e,onSwitchAgent:t,onOpenProfile:n,onNewSession:s}){return a.jsxs(Aie,{children:[a.jsx(Rie,{children:e}),a.jsxs(Mie,{className:"w-48",children:[a.jsxs(Ny,{onClick:t,children:[a.jsx(tAe,{className:"mr-2 size-4"}),"Switch agent"]}),a.jsx(z3,{}),a.jsxs(Ny,{onClick:n,children:[a.jsx(Md,{className:"mr-2 size-4"}),"Agent profile"]}),a.jsx(z3,{}),a.jsxs(Ny,{onClick:s,children:[a.jsx(Cs,{className:"mr-2 size-4"}),"New session"]})]})]})}const W0t=[{trigger:"/",label:"Commands",icon:J5,ariaLabel:"Insert slash command trigger"},{trigger:"@",label:"Files",icon:Qg,ariaLabel:"Insert file mention trigger"}];function aG({onChipClick:e,agentName:t,agentColor:n,agentEmoji:s,agentPath:r}){const i=Hn(),o=x.useCallback(()=>{r&&(yd.getState().openHub(r),we.getState().setRightPanelOpen(!0),we.getState().setActiveRightPanelTab("agent-hub"))},[r]),l=x.useCallback(()=>{we.getState().openGlobalPaletteWithSearch("@")},[]),c=x.useCallback(()=>{i({to:"/session",search:{dir:r??void 0,session:crypto.randomUUID()}})},[i,r]),u=t&&n&&s;return a.jsxs(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"mt-1.5 flex items-center justify-center gap-2 sm:justify-start",children:[u&&(r?a.jsx(K0t,{onSwitchAgent:l,onOpenProfile:o,onNewSession:c,children:a.jsx(bD,{size:"xs",name:t,color:n,emoji:s,onClick:o})}):a.jsx(bD,{size:"xs",name:t,color:n,emoji:s})),W0t.map(d=>a.jsxs("button",{type:"button","aria-label":d.ariaLabel,onClick:()=>e(d.trigger),className:"bg-secondary text-muted-foreground hover:text-foreground hover:bg-muted inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs transition-colors duration-150",children:[a.jsx(d.icon,{className:"size-3"}),a.jsx("kbd",{className:"font-mono text-[10px] opacity-60",children:d.trigger}),d.label]},d.trigger))]})}function Y0t({collapsed:e,onToggle:t}){return a.jsx("div",{role:"button",tabIndex:0,"aria-label":e?"Expand input extras":"Collapse input extras",onClick:t,onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),t())},className:"flex h-6 w-full cursor-pointer items-center justify-center",children:a.jsx("div",{className:"bg-muted-foreground/30 hover:bg-muted-foreground/50 active:bg-muted-foreground/50 h-1 w-9 rounded-full transition-colors"})})}function Fo({itemLabel:e,onHide:t,onConfigure:n,children:s}){return a.jsxs(bT,{children:[a.jsx(ST,{className:"inline-flex items-center",children:s}),a.jsxs(wT,{children:[e&&t&&a.jsxs(a.Fragment,{children:[a.jsxs(Ec,{onClick:t,children:["Hide “",e,"”"]}),a.jsx(dC,{})]}),a.jsx(Ec,{onClick:n,children:"Configure status bar..."}),a.jsx(Ec,{onClick:e_,children:"Reset to defaults"})]})]})}function zo(e){var t;return((t=Yb.find(n=>n.key===e))==null?void 0:t.label)??null}const oG=80,lG=500;function Z0t({sessionId:e,sessionStatus:t,isStreaming:n,onChipClick:s,syncConnectionState:r,agentName:i,agentColor:o,agentEmoji:l,agentPath:c}){var kn;const u=Us(),d=ude(e),f=Pne(e,t,n,d.runtime),{showShortcutChips:m,showStatusBarCwd:g,setShowStatusBarCwd:y,showStatusBarPermission:b,setShowStatusBarPermission:S,showStatusBarRuntime:w,setShowStatusBarRuntime:C,showStatusBarModel:T,setShowStatusBarModel:E,showStatusBarContext:j,setShowStatusBarContext:_,showStatusBarCache:N,setShowStatusBarCache:R,showStatusBarUsage:O,setShowStatusBarUsage:M,showStatusBarGit:L,setShowStatusBarGit:P,showStatusBarSound:$,setShowStatusBarSound:q,showStatusBarPolling:K,setShowStatusBarPolling:B,enableNotificationSound:V,setEnableNotificationSound:Q,enableMessagePolling:re,setEnableMessagePolling:U}=we(),G=Wne(e),W=G0t(G),F=qn(x.useCallback(Tt=>{var Vt;return((Vt=Tt.sessions[e])==null?void 0:Vt.contextUsage)??null},[e])),X=qn(B0t(Tt=>{var Cn;const Vt=(Cn=Tt.sessions[e])==null?void 0:Cn.sessionStatus;return!(Vt!=null&&Vt.cacheReadTokens)&&!(Vt!=null&&Vt.cacheCreationTokens)?null:{cacheReadTokens:Vt.cacheReadTokens??0,cacheCreationTokens:Vt.cacheCreationTokens??0,contextTokens:Vt.contextTokens}})),J=W.cacheStatus??X,ae=W.contextPercent??f.contextPercent,oe=W.usage,{data:de}=hnt(f.cwd),me=U0t(f.cwd),{data:Re}=D5e(e),{data:Fe}=aI({sessionId:e||void 0,runtime:d.runtime??void 0}),Le=((kn=Fe==null?void 0:Fe.find(Tt=>Tt.value===f.model))==null?void 0:kn.supportsAutoMode)??!1,Xe=Q5e(e),ze=qn(Tt=>Tt.recordAutoConfirmed),[Mt,Ft]=x.useState(!1),Pe=x.useCallback(Tt=>{if(Tt==="auto"&&!Xe){Ft(!0);return}f.updateSession({permissionMode:Tt})},[Xe,f]),He=x.useCallback(()=>{ze(e),f.updateSession({permissionMode:"auto"}),Ft(!1)},[ze,e,f]),gt=tP(d.runtime),Ct=(gt==null?void 0:gt.supportsCostTracking)??!0,[cn,Nt]=x.useState(!1),[ts,Ln]=x.useState(!1),[Oe,le]=x.useState(()=>u?parseInt(localStorage.getItem(Dn.GESTURE_HINT_COUNT)||"0",10)<3:!1);x.useEffect(()=>{if(!Oe)return;const Tt=setTimeout(()=>{le(!1);const Vt=parseInt(localStorage.getItem(Dn.GESTURE_HINT_COUNT)||"0",10);localStorage.setItem(Dn.GESTURE_HINT_COUNT,String(Vt+1))},yo.GESTURE_HINT_DISMISS_MS);return()=>clearTimeout(Tt)},[Oe]);const Ce=x.useCallback(()=>{le(!1);const Tt=parseInt(localStorage.getItem(Dn.GESTURE_HINT_COUNT)||"0",10);localStorage.setItem(Dn.GESTURE_HINT_COUNT,String(Tt+1))},[]),Ge=(Tt,Vt)=>{const{offset:Cn,velocity:ns}=Vt;Cn.y>oG||ns.y>lG?Ln(!0):(Cn.y<-oG||ns.y<-lG)&&Ln(!1)},ot=a.jsx(em,{children:a.jsxs(gn,{children:[a.jsx(Vce,{open:cn,onOpenChange:Nt,children:a.jsx(xn,{asChild:!0,children:a.jsx("button",{type:"button","aria-label":"Configure status bar",className:"text-muted-foreground/50 hover:text-muted-foreground inline-flex shrink-0 items-center transition-colors duration-150",children:a.jsx(K3e,{className:"size-3"})})})}),a.jsx(yn,{side:"top",children:a.jsx("p",{children:"Configure status bar"})})]})}),bt=a.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[a.jsxs(bT,{children:[a.jsx(ST,{className:"min-w-0 flex-1",children:a.jsxs(Wi,{sessionId:e,isStreaming:n,children:[a.jsx(Wi.Item,{itemKey:"cwd",visible:g&&!!f.cwd,children:a.jsx(Fo,{itemLabel:zo("cwd"),onHide:()=>y(!1),onConfigure:()=>Nt(!0),children:f.cwd&&a.jsx(unt,{cwd:f.cwd})})}),a.jsx(Wi.Item,{itemKey:"git",visible:L,children:a.jsx(Fo,{itemLabel:zo("git"),onHide:()=>P(!1),onConfigure:()=>Nt(!0),children:a.jsx(pnt,{data:de,workspace:me})})}),a.jsx(Wi.Item,{itemKey:"permission",visible:b,children:a.jsx(Fo,{itemLabel:zo("permission"),onHide:()=>S(!1),onConfigure:()=>Nt(!0),children:a.jsx(vnt,{mode:f.permissionMode,onChangeMode:Pe,disabled:!e,runtime:d.runtime,modelSupportsAutoMode:Le})})}),a.jsx(Wi.Item,{itemKey:"runtime",visible:w&&d.runtime!==null,children:a.jsx(Fo,{itemLabel:zo("runtime"),onHide:()=>C(!1),onConfigure:()=>Nt(!0),children:d.runtime!==null&&a.jsx(Vnt,{runtime:d.runtime,model:d.model,onChangeRuntime:d.onChangeRuntime,canSelect:d.canSelect})})}),a.jsx(Wi.Item,{itemKey:"model",visible:T,children:a.jsx(Fo,{itemLabel:zo("model"),onHide:()=>E(!1),onConfigure:()=>Nt(!0),children:a.jsx(tst,{model:f.model,onChangeModel:Tt=>f.updateSession({model:Tt}),effort:f.effort,onChangeEffort:Tt=>f.updateSession({effort:Tt??void 0}),fastMode:f.fastMode,onChangeFastMode:Tt=>f.updateSession({fastMode:Tt}),disabled:!e,sessionId:e||void 0,runtime:d.runtime})})}),a.jsx(Wi.Item,{itemKey:"cache",visible:N&&J!==null,children:a.jsx(Fo,{itemLabel:zo("cache"),onHide:()=>R(!1),onConfigure:()=>Nt(!0),children:J&&a.jsx(nst,{cacheReadTokens:J.cacheReadTokens,cacheCreationTokens:J.cacheCreationTokens,contextTokens:J.contextTokens})})}),a.jsx(Wi.Item,{itemKey:"context",visible:j&&ae!==null,children:a.jsx(Fo,{itemLabel:zo("context"),onHide:()=>_(!1),onConfigure:()=>Nt(!0),children:ae!==null&&a.jsx(sst,{percent:ae,contextUsage:F})})}),a.jsx(Wi.Item,{itemKey:"usage",visible:O&&oe!==null&&JU(oe)&&Ct,children:a.jsx(Fo,{itemLabel:zo("usage"),onHide:()=>M(!1),onConfigure:()=>Nt(!0),children:oe&&JU(oe)&&a.jsx(rst,{usage:oe})})}),a.jsx(Wi.Item,{itemKey:"sound",visible:$,children:a.jsx(Fo,{itemLabel:zo("sound"),onHide:()=>q(!1),onConfigure:()=>Nt(!0),children:a.jsx(ist,{enabled:V,onToggle:()=>Q(!V)})})}),a.jsx(Wi.Item,{itemKey:"polling",visible:K,children:a.jsx(Fo,{itemLabel:zo("polling"),onHide:()=>B(!1),onConfigure:()=>Nt(!0),children:a.jsx(ast,{enabled:re,onToggle:()=>U(!re)})})}),a.jsx(lst,{connectionState:r}),a.jsx(Wi.Item,{itemKey:"subagents",visible:!!Re&&Re.length>0,children:Re&&Re.length>0&&a.jsx(ust,{subagents:Re})})]})}),a.jsxs(wT,{children:[a.jsx(Ec,{onClick:()=>Nt(!0),children:"Configure status bar..."}),a.jsx(Ec,{onClick:e_,children:"Reset to defaults"})]})]}),ot,a.jsx(qnt,{open:Mt,onOpenChange:Ft,onConfirm:He})]});return u?a.jsxs(a.Fragment,{children:[a.jsx(te.div,{animate:Oe?{y:[0,8,0]}:void 0,transition:Oe?{duration:1.2,repeat:2}:void 0,children:a.jsx(Y0t,{collapsed:ts,onToggle:()=>Ln(Tt=>!Tt)})}),a.jsx(Ue,{children:Oe&&a.jsx(te.p,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:Ce,className:"text-muted-foreground cursor-pointer text-center text-xs",children:"Swipe to collapse"})}),a.jsx(Ue,{initial:!1,children:!ts&&a.jsxs(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{type:"spring",stiffness:300,damping:30},className:"overflow-hidden",drag:"y",dragConstraints:{top:0,bottom:0},dragElastic:.2,onDragEnd:Ge,style:{touchAction:"pan-y"},children:[m&&a.jsx(aG,{onChipClick:s,agentName:i,agentColor:o,agentEmoji:l,agentPath:c}),bt]})})]}):a.jsxs(a.Fragment,{children:[a.jsx(Ue,{children:m&&a.jsx(aG,{onChipClick:s,agentName:i,agentColor:o,agentEmoji:l,agentPath:c})}),bt]})}function X0t({color:e}){const t=[{bx:"-8px",by:"-10px",delay:"0s"},{bx:"8px",by:"-8px",delay:"0.03s"},{bx:"-6px",by:"6px",delay:"0.06s"},{bx:"10px",by:"4px",delay:"0.09s"},{bx:"0px",by:"-12px",delay:"0.04s"},{bx:"-10px",by:"0px",delay:"0.07s"},{bx:"6px",by:"10px",delay:"0.05s"},{bx:"-4px",by:"-6px",delay:"0.08s"}];return a.jsx("div",{className:"pointer-events-none absolute inset-0",children:t.map((n,s)=>a.jsx("span",{className:"absolute top-1/2 left-1/2 size-[3px] rounded-full",style:{backgroundColor:e,"--bx":n.bx,"--by":n.by,animation:`burst-particle 0.5s ease-out ${n.delay} forwards`}},s))})}function Q0t({agent:e,index:t}){const n=x.useMemo(()=>({animationDelay:`${t*.09}s`}),[t]),[s,r]=x.useState("running"),i=x.useRef(e.status);return x.useEffect(()=>{if(i.current==="running"&&(e.status==="complete"||e.status==="error")&&s==="running"){r("celebrating");const o=setTimeout(()=>r("done"),350);return()=>clearTimeout(o)}i.current=e.status},[e.status,s]),s==="done"?a.jsx("div",{className:"relative inline-flex",children:e.status==="error"?a.jsxs("svg",{className:"check-appear h-6 w-[22px]",viewBox:"0 0 22 24",children:[a.jsx("circle",{cx:"11",cy:"12",r:"7",fill:"none",stroke:e.color,strokeWidth:"1.5",opacity:"0.3"}),a.jsx("line",{x1:"8",y1:"9",x2:"14",y2:"15",stroke:e.color,strokeWidth:"2",strokeLinecap:"round"}),a.jsx("line",{x1:"14",y1:"9",x2:"8",y2:"15",stroke:e.color,strokeWidth:"2",strokeLinecap:"round"})]}):a.jsxs("svg",{className:"check-appear h-6 w-[22px]",viewBox:"0 0 22 24",children:[a.jsx("circle",{cx:"11",cy:"12",r:"7",fill:"none",stroke:e.color,strokeWidth:"1.5",opacity:"0.3"}),a.jsx("polyline",{points:"7,12 10,15 15,9",fill:"none",stroke:e.color,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}):a.jsxs("div",{className:"group relative inline-flex",children:[a.jsx("svg",{className:"h-6 w-[22px] shrink-0",style:{"--c":e.color},viewBox:"0 0 22 24","aria-label":e.description,children:a.jsxs("g",{className:"r-all",style:n,children:[a.jsx("circle",{cx:"11",cy:"4.5",r:"2.8",fill:"var(--c)"}),a.jsx("circle",{cx:"12.3",cy:"3.7",r:"0.6",fill:"hsl(0 0% 100% / 0.7)"}),a.jsx("ellipse",{cx:"11",cy:"10.5",rx:"2.5",ry:"3.5",fill:"var(--c)"}),a.jsxs("g",{className:"r-rua",style:n,children:[a.jsx("line",{x1:"12",y1:"9",x2:"14",y2:"11",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),a.jsx("g",{className:"r-rfa",style:n,children:a.jsx("line",{x1:"14",y1:"11",x2:"14.5",y2:"13",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]}),a.jsxs("g",{className:"r-lua",style:n,children:[a.jsx("line",{x1:"10",y1:"9",x2:"8",y2:"11",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),a.jsx("g",{className:"r-lfa",style:n,children:a.jsx("line",{x1:"8",y1:"11",x2:"7.5",y2:"13",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]}),a.jsxs("g",{className:"r-rt",style:n,children:[a.jsx("line",{x1:"11",y1:"14",x2:"13",y2:"17",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),a.jsx("g",{className:"r-rs",style:n,children:a.jsx("line",{x1:"13",y1:"17",x2:"13.5",y2:"21",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]}),a.jsxs("g",{className:"r-lt",style:n,children:[a.jsx("line",{x1:"11",y1:"14",x2:"9",y2:"17",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),a.jsx("g",{className:"r-ls",style:n,children:a.jsx("line",{x1:"9",y1:"17",x2:"8.5",y2:"21",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]})]})}),s==="celebrating"&&a.jsx(X0t,{color:e.color}),s==="running"&&a.jsxs("div",{className:Y("pointer-events-none absolute bottom-[calc(100%+8px)] left-1/2","-translate-x-1/2 translate-y-1 opacity-0 transition-all duration-150","group-hover:translate-y-0 group-hover:opacity-100","border-border bg-popover z-10 rounded-lg border px-3 py-2 whitespace-nowrap","text-foreground text-[0.6875rem] shadow-lg"),children:[a.jsxs("div",{className:"mb-0.5 flex items-center gap-1.5 font-semibold",children:[a.jsx("div",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:e.color}}),e.description]}),a.jsxs("div",{className:"text-muted-foreground font-mono text-[0.625rem]",children:[e.toolUses??0," tool calls · ",Math.round((e.durationMs??0)/1e3),"s"]}),e.lastToolName&&a.jsxs("div",{className:"text-muted-foreground/60 mt-0.5 font-mono text-[0.5625rem]",children:["Last: ",e.lastToolName]}),a.jsx("div",{className:"border-t-border absolute top-full left-1/2 -translate-x-1/2 border-5 border-transparent"})]})]})}function J0t({bashTasks:e}){const t=Ds(),n=e.filter(r=>r.taskType==="bash"),s=n.length;return s===0?null:a.jsxs("div",{role:"status","aria-live":"polite","aria-label":`${s} bash task${s!==1?"s":""} running`,className:"flex items-center gap-1.5",children:[a.jsx(Ue,{mode:"popLayout",children:n.map(r=>a.jsxs(te.div,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:{duration:.25},className:"relative flex size-3 items-center justify-center",children:[r.status==="running"&&!t&&a.jsx("span",{className:"task-dot-tasks absolute inset-0 rounded-full opacity-40",style:{backgroundColor:r.color,animation:"task-dot-tasks 2s ease-in-out infinite"}}),a.jsx("span",{className:"relative size-1.5 rounded-full",style:{backgroundColor:r.color}})]},r.taskId))}),a.jsxs("span",{className:"text-muted-foreground text-xs whitespace-nowrap",children:[s," task",s!==1?"s":""]})]})}const ext=3e3;function txt({taskType:e,onConfirm:t}){const[n,s]=x.useState(!1),r=x.useRef(null);x.useEffect(()=>()=>{r.current&&clearTimeout(r.current)},[]),x.useEffect(()=>{if(n)return r.current=setTimeout(()=>{s(!1)},ext),()=>{r.current&&clearTimeout(r.current)}},[n]);const i=x.useCallback(()=>{if(e==="bash"){t();return}n?(r.current&&clearTimeout(r.current),s(!1),t()):s(!0)},[e,n,t]),o=x.useCallback(l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),i())},[i]);return a.jsx("button",{onClick:i,onKeyDown:o,className:Y("flex shrink-0 items-center justify-center rounded transition-all duration-150","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-1",n?"bg-destructive/20 text-destructive hover:bg-destructive/30 px-1.5 py-0.5 text-[0.625rem] font-medium":"text-muted-foreground/40 hover:text-destructive size-4"),"aria-label":n?"Confirm stop task":"Stop task",tabIndex:0,children:n?"Stop?":a.jsx(es,{className:"size-3"})})}function nxt({task:e,onStop:t}){const n=e.taskType==="agent"?e.description??"Background agent":e.command??"Background task",s=e.durationMs?Math.round(e.durationMs/1e3):0,r=e.status==="running";return a.jsxs("div",{className:Y("flex items-center gap-2 rounded-md px-2 py-1 text-xs",r?"bg-muted":"bg-muted/50 opacity-60"),children:[a.jsx("span",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:e.color}}),a.jsx("span",{className:"text-muted-foreground/60 shrink-0 text-[0.625rem] tracking-wider uppercase",children:e.taskType}),a.jsx("span",{className:"text-foreground min-w-0 flex-1 truncate",children:n}),e.taskType==="agent"&&e.toolUses!==void 0&&e.toolUses>0&&a.jsxs("span",{className:"text-muted-foreground/60 shrink-0 font-mono text-[0.625rem]",children:[e.toolUses," tools"]}),s>0&&a.jsxs("span",{className:"text-muted-foreground/60 shrink-0 font-mono text-[0.625rem]",children:[s,"s"]}),r&&a.jsx(txt,{taskType:e.taskType,onConfirm:t})]})}function sxt({tasks:e,onStopTask:t}){return a.jsx(te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.25,ease:[.16,1,.3,1]},className:"border-border overflow-hidden border-t px-2 py-1.5",children:a.jsx("div",{className:"flex flex-col gap-1",children:e.map(n=>a.jsx(nxt,{task:n,onStop:()=>t(n.taskId)},n.taskId))})})}const QD=4,Ude=[.16,1,.3,1],rxt={width:{duration:.4,ease:Ude},opacity:{duration:.25}};function ixt({tasks:e,onStopTask:t}){const[n,s]=x.useState(!1),r=Ds(),i=e.filter(g=>g.taskType==="agent"),o=e.filter(g=>g.taskType==="bash"),l=e.length,c=i.slice(0,QD),u=i.length-QD,d=i.reduce((g,y)=>g+(y.toolUses??0),0),f=Math.max(0,...e.map(g=>Math.round((g.durationMs??0)/1e3))),m=r?{duration:0}:{duration:.35,ease:Ude};return a.jsx(Ue,{children:l>0&&a.jsxs(te.div,{role:"status","aria-live":"polite","aria-label":`${l} background task${l!==1?"s":""} running`,initial:{opacity:0,y:6,maxHeight:0},animate:{opacity:1,y:0,maxHeight:n?400:44},exit:{opacity:0,maxHeight:0},transition:m,className:"border-border bg-card overflow-hidden rounded-lg border",children:[a.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[i.length>0&&a.jsx(axt,{visibleAgents:c,overflowAgentCount:u,allAgentTasks:i}),i.length>0&&o.length>0&&a.jsx("div",{className:"bg-border h-4 w-px shrink-0"}),o.length>0&&a.jsx(J0t,{bashTasks:o}),a.jsxs("span",{className:"text-muted-foreground text-xs whitespace-nowrap",children:[a.jsx("strong",{className:"text-foreground font-semibold",children:l})," task",l!==1?"s":""," running"]}),a.jsxs("span",{className:"text-muted-foreground/60 ml-auto font-mono text-[0.6875rem] whitespace-nowrap",children:[d>0&&a.jsxs(a.Fragment,{children:[d," tools · "]}),f,"s"]}),a.jsxs("button",{type:"button",onClick:()=>s(g=>!g),className:"text-muted-foreground hover:text-foreground ml-1 flex shrink-0 items-center gap-1 transition-colors duration-150","aria-label":n?"Collapse task details":"Expand task details","aria-expanded":n,children:[a.jsx("span",{className:"text-[0.625rem] tabular-nums",children:l}),a.jsx(Hs,{className:Y("size-3.5 transition-transform duration-200",n&&"rotate-180")})]})]}),a.jsx(Ue,{children:n&&a.jsx(sxt,{tasks:e,onStopTask:t})})]},"background-task-bar")})}function axt({visibleAgents:e,overflowAgentCount:t,allAgentTasks:n}){return a.jsxs("div",{className:"flex items-center gap-0",children:[a.jsx(Ue,{mode:"popLayout",children:e.map((s,r)=>a.jsx(te.div,{initial:{width:0,opacity:0},animate:{width:22,opacity:1},exit:{width:0,opacity:0},transition:rxt,className:"shrink-0",children:a.jsx(Q0t,{agent:{taskId:s.taskId,description:s.description??"",status:s.status==="running"?"running":s.status==="complete"?"complete":"error",color:s.color,toolUses:s.toolUses,lastToolName:s.lastToolName,durationMs:s.durationMs,summary:s.summary},index:r})},s.taskId))}),t>0&&a.jsx(oxt,{count:t,overflowTasks:n.slice(QD)})]})}function oxt({count:e,overflowTasks:t}){return a.jsxs("div",{className:"group relative",children:[a.jsxs("div",{className:"text-muted-foreground bg-muted flex size-6 shrink-0 items-center justify-center rounded-full text-[0.625rem] font-semibold","aria-label":`${e} more agents running`,children:["+",e]}),a.jsxs("div",{className:Y("pointer-events-none absolute bottom-[calc(100%+8px)] left-1/2","-translate-x-1/2 translate-y-1 opacity-0 transition-all duration-150","group-hover:translate-y-0 group-hover:opacity-100","border-border bg-popover z-10 rounded-lg border px-3 py-2 whitespace-nowrap","text-foreground text-[0.6875rem] shadow-lg"),children:[t.map(n=>a.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[a.jsx("div",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:n.color}}),a.jsx("span",{className:"text-[0.625rem]",children:n.description})]},n.taskId)),a.jsx("div",{className:"border-t-border absolute top-full left-1/2 -translate-x-1/2 border-5 border-transparent"})]})]})}const cG=["hsl(210 80% 60%)","hsl(150 60% 50%)","hsl(270 60% 65%)","hsl(36 90% 55%)","hsl(340 75% 60%)"],uG=5e3,lxt=1e3,cxt=1500;function uxt(e){const t=x.useRef(new Map),n=x.useRef(0),s=x.useRef(new Map),r=x.useRef(new Set),[,i]=x.useState(0),o=x.useMemo(()=>{const c=new Map;for(const u of e)for(const d of u.parts)d.type==="background_task"&&c.set(d.taskId,d);return c},[e]);x.useEffect(()=>{if(!Array.from(o.values()).some(d=>d.taskType==="bash"&&d.status==="running"&&Date.now()-d.startedAt<uG))return;const u=setInterval(()=>{i(d=>d+1)},lxt);return()=>clearInterval(u)},[o]);const l=x.useRef(new Set);for(const[c,u]of o){const d=s.current.get(c),f=u.status==="complete"||u.status==="error"||u.status==="stopped";d==="running"&&f&&!r.current.has(c)&&r.current.add(c),s.current.set(c,u.status)}return x.useEffect(()=>{for(const c of r.current)l.current.has(c)||(l.current.add(c),setTimeout(()=>{r.current.delete(c),l.current.delete(c),i(u=>u+1)},cxt))},[o]),x.useMemo(()=>{const c=Date.now(),u=[];for(const[d,f]of o){const m=f.status==="running",g=r.current.has(d);!m&&!g||f.taskType==="bash"&&m&&c-f.startedAt<uG||(t.current.has(d)||(t.current.set(d,cG[n.current%cG.length]),n.current+=1),u.push({taskId:f.taskId,taskType:f.taskType,status:f.status,color:t.current.get(d),startedAt:f.startedAt,description:f.description,toolUses:f.toolUses,lastToolName:f.lastToolName,durationMs:f.durationMs,summary:f.summary,command:f.command}))}return u},[o])}function dxt({status:e,sessionBusy:t,sessionId:n,selectedCwd:s,onFlush:r}){const i=dIe(n??""),[o,l]=x.useState(null),c=x.useRef(r);c.current=r;const u=x.useRef(i);u.current=i;const d=x.useRef(o);d.current=o;const f=x.useRef("idle"),m=x.useRef(null);x.useEffect(()=>{const E=n===null?null:`${n}\0${s??""}`;if(m.current!==E&&(m.current=E,f.current="idle",l(null)),f.current==="streaming"&&e==="idle"&&n){const j=u.current,_=d.current;if(j.length>0&&!t){const N=_===0?j.length>1?1:null:0;if(N!==null){const R=j[N];Zn.getState().removeQueuedMessage(n,R.id),_!==null&&_>N&&l(O=>O!==null?O-1:null),c.current(R.content,n,{queued:!0})}}}f.current=e},[e,t,n,s]);const g=x.useCallback(E=>{!E.trim()||!n||Zn.getState().enqueueMessage(n,E)},[n]),y=x.useCallback((E,j)=>{const _=i[E];!_||!n||Zn.getState().updateQueuedMessage(n,_.id,j)},[i,n]),b=x.useCallback(E=>{const j=i[E];j&&n&&Zn.getState().removeQueuedMessage(n,j.id),l(_=>_===E?null:_!==null&&_>E?_-1:_)},[i,n]),S=x.useCallback(E=>{var j;return l(E),((j=i[E])==null?void 0:j.content)??""},[i]),w=x.useCallback(()=>{l(null)},[]),C=x.useCallback(E=>{o!==null&&(y(o,E),l(null))},[o,y]),T=x.useCallback(()=>{n&&Zn.getState().clearQueue(n),l(null)},[n]);return{queue:i,editingIndex:o,addToQueue:g,updateQueueItem:y,removeFromQueue:b,startEditing:S,cancelEditing:w,saveEditing:C,clearQueue:T}}function fxt({input:e,setInput:t,status:n,sessionBusy:s,sessionId:r,selectedCwd:i,onFlush:o,tryNativeCommand:l,chatInputRef:c}){const u=x.useRef("");x.useEffect(()=>{u.current=""},[r]);const d=dxt({status:n,sessionBusy:s,sessionId:r,selectedCwd:i,onFlush:o}),f=x.useCallback(()=>{const C=e.trim();if(!C)return;const T=l(C);if(T.handled){T.ran&&t("");return}d.addToQueue(C),t("")},[e,d,t,l]),m=x.useCallback(C=>{var E;d.editingIndex===null&&(u.current=e);const T=d.startEditing(C);t(T),(E=c.current)==null||E.focus()},[e,d,t,c]),g=x.useCallback(()=>{d.editingIndex!==null&&e.trim()&&(d.saveEditing(e.trim()),t(u.current))},[e,d,t]),y=x.useCallback(()=>{d.cancelEditing(),t(u.current)},[d,t]),b=x.useCallback(C=>{d.editingIndex===C&&t(u.current),d.removeFromQueue(C)},[d,t]),S=x.useCallback(()=>{if(d.editingIndex===null){u.current=e;const C=d.startEditing(d.queue.length-1);t(C)}else if(d.editingIndex>0){const C=d.startEditing(d.editingIndex-1);t(C)}else d.cancelEditing(),t(u.current)},[e,d,t]),w=x.useCallback(()=>{if(d.editingIndex!==null)if(d.editingIndex<d.queue.length-1){const C=d.startEditing(d.editingIndex+1);t(C)}else d.cancelEditing(),t(u.current)},[d,t]);return{queue:d.queue,editingIndex:d.editingIndex,handleQueue:f,handleQueueEdit:m,handleQueueSaveEdit:g,handleQueueCancelEdit:y,handleQueueRemove:b,handleQueueNavigateUp:S,handleQueueNavigateDown:w}}function hxt(e){return e.type.startsWith("image/")}function mxt({files:e,onRemove:t}){const n=x.useMemo(()=>{const s=new Map;for(const r of e)hxt(r.file)&&s.set(r.id,URL.createObjectURL(r.file));return s},[e]);return x.useEffect(()=>()=>{for(const s of n.values())URL.revokeObjectURL(s)},[n]),a.jsx("div",{className:"flex flex-wrap gap-1.5 px-1 pb-1.5",children:a.jsx(Ue,{children:e.map(s=>{const r=n.get(s.id);return a.jsxs(te.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},className:"bg-muted flex items-center gap-1 rounded-md px-2 py-1 text-xs",children:[s.status==="uploading"?a.jsx(Sn,{className:"text-muted-foreground size-3 animate-spin"}):s.status==="error"?a.jsx(Hh,{className:"text-destructive size-3"}):r?a.jsx("img",{src:r,alt:"",className:"size-5 shrink-0 rounded object-cover"}):a.jsx(qh,{className:"text-muted-foreground size-3"}),a.jsx("span",{className:"max-w-32 truncate",children:s.file.name}),s.status==="uploading"&&a.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[s.progress,"%"]}),a.jsx("button",{type:"button",onClick:()=>t(s.id),className:"text-muted-foreground hover:text-foreground -mr-0.5 ml-0.5 rounded-sm p-0.5","aria-label":`Remove ${s.file.name}`,children:a.jsx(es,{className:"size-3"})})]},s.id)})})})}function pxt({queue:e,editingIndex:t,onEdit:n,onRemove:s}){return e.length===0?null:a.jsxs(te.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2},className:"mb-1.5 overflow-hidden",children:[a.jsxs("div",{className:"text-muted-foreground mb-1 text-xs font-medium",children:["Queued (",e.length,")"]}),a.jsx("div",{className:"space-y-0.5",children:a.jsx(Ue,{mode:"popLayout",children:e.map((r,i)=>a.jsx(te.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0,transition:{type:"spring",stiffness:320,damping:28}},exit:{opacity:0,scale:.95,transition:{duration:.15}},layout:!0,children:a.jsxs("button",{type:"button",onClick:()=>n(i),className:Y("group flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-left transition-colors",t===i?"border-primary bg-muted border-l-2":"hover:bg-muted/50"),children:[a.jsxs("span",{className:"text-muted-foreground shrink-0 text-xs font-medium",children:[i+1,"."]}),a.jsx("span",{className:"text-muted-foreground line-clamp-1 flex-1 text-sm",children:r.content}),a.jsx("span",{role:"button",tabIndex:0,onClick:o=>{o.stopPropagation(),s(i)},onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&(o.stopPropagation(),o.preventDefault(),s(i))},className:"text-muted-foreground hover:text-foreground shrink-0 rounded-sm p-0.5 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100","aria-label":`Remove queued message ${i+1}`,children:a.jsx(es,{className:"size-3"})})]})},r.id))})})]})}function gxt({filteredCommands:e,selectedIndex:t,onSelect:n}){const s=x.useMemo(()=>{const r=[],i=new Map;let o=0;for(const l of e){const c=l.namespace??"built-in";i.has(c)||i.set(c,[]),i.get(c).push({cmd:l,index:o++})}for(const[l,c]of i)r.push({namespace:l,items:c});return r},[e]);return x.useEffect(()=>{const r=document.getElementById(`command-item-${t}`);r&&r.scrollIntoView({block:"nearest"})},[t]),a.jsx(te.div,{initial:{opacity:0,scale:.98,y:4},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:4},transition:{duration:.15,ease:[0,0,.2,1]},className:"bg-popover max-h-80 overflow-hidden rounded-lg border shadow-lg",onMouseDown:r=>r.preventDefault(),children:a.jsx("div",{id:"command-palette-listbox",role:"listbox",className:"max-h-72 overflow-y-auto p-1.5",children:e.length===0?a.jsx("div",{className:"text-muted-foreground px-2 py-4 text-center text-sm",children:"No commands found."}):s.map(({namespace:r,items:i},o)=>a.jsxs("div",{children:[o>0&&a.jsx("div",{className:"bg-border mx-2 my-1.5 h-px"}),a.jsx("div",{className:"text-muted-foreground/70 px-2 pt-1.5 pb-1 text-[11px] font-medium tracking-wide uppercase",children:r}),i.map(({cmd:l,index:c})=>{const u=c===t;return a.jsxs("div",{id:`command-item-${c}`,role:"option","aria-selected":u,"data-selected":u,tabIndex:u?0:-1,onClick:()=>n(l),onKeyDown:d=>{d.key==="Enter"&&n(l)},className:"data-[selected=true]:bg-accent hover:bg-muted cursor-pointer rounded-md px-2 py-1.5 transition-colors duration-100",children:[a.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[a.jsx("span",{className:"text-foreground shrink-0 font-mono text-[13px] font-medium",children:l.fullCommand}),l.argumentHint&&a.jsx("span",{className:"text-muted-foreground/50 shrink-0 font-mono text-xs",children:l.argumentHint}),l.matchedAlias&&a.jsxs("span",{className:"text-muted-foreground/60 ml-auto shrink-0 font-mono text-[11px] italic",children:["matched /",l.matchedAlias.replace(/^\//,"")]})]}),l.description&&a.jsx("p",{className:"text-muted-foreground mt-0.5 truncate text-xs leading-normal",children:l.description})]},l.fullCommand)})]},r))})})}function xxt({text:e,indices:t,startOffset:n=0}){const s=new Set(t.map(r=>r-n));return a.jsx(a.Fragment,{children:e.split("").map((r,i)=>s.has(i)?a.jsx("span",{className:"text-foreground font-semibold",children:r},i):a.jsx("span",{children:r},i))})}function yxt({filteredFiles:e,selectedIndex:t,onSelect:n}){return x.useEffect(()=>{const s=document.getElementById(`file-item-${t}`);s&&s.scrollIntoView({block:"nearest"})},[t]),a.jsx(te.div,{initial:{opacity:0,scale:.98,y:4},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:4},transition:{duration:.15,ease:[0,0,.2,1]},className:"bg-popover max-h-80 overflow-hidden rounded-lg border shadow-lg",onMouseDown:s=>s.preventDefault(),children:a.jsx("div",{id:"file-palette-listbox",role:"listbox",className:"max-h-72 overflow-y-auto p-1.5",children:e.length===0?a.jsx("div",{className:"text-muted-foreground px-2 py-4 text-center text-sm",children:"No files found."}):e.map((s,r)=>{const i=r===t,o=s.isDirectory?th:qh;return a.jsxs("div",{id:`file-item-${r}`,role:"option","aria-selected":i,"data-selected":i,tabIndex:i?0:-1,onClick:()=>n(s),onKeyDown:l=>{l.key==="Enter"&&n(s)},className:"data-[selected=true]:bg-accent hover:bg-muted flex cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 transition-colors duration-100",children:[a.jsx(o,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("span",{className:"text-foreground truncate text-sm font-medium",children:a.jsx(xxt,{text:s.filename,indices:s.indices,startOffset:s.directory.length})}),s.directory&&a.jsx("p",{className:"text-muted-foreground/70 truncate text-xs leading-normal",children:s.directory})]})]},s.path)})})})}function vxt(e){const t=je();return st({queryKey:["files",{cwd:e??null}],queryFn:()=>t.listFiles(e),enabled:!!e,staleTime:ia.FILES_STALE_TIME_MS,gcTime:ia.FILES_GC_TIME_MS})}const bxt=5e3;function Sxt(e){const t=[...e];for(let n=t.length-1;n>0;n--){const s=Math.floor(Math.random()*(n+1));[t[n],t[s]]=[t[s],t[n]]}return t}function wxt({defaultText:e,hints:t,enabled:n,intervalMs:s=bxt}){const[r,i]=x.useState(0),[o]=x.useState(()=>t.length>0?Sxt(t):[]);x.useEffect(()=>{if(!n||t.length===0){i(0);return}const d=setInterval(()=>i(f=>f+1),s);return()=>clearInterval(d)},[n,t.length,s]);const l=r>0&&r%2===1,c=Math.floor(r/2)%(o.length||1);return{text:l?o[c]??e:e,key:r,isHint:l}}const kxt={initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4}},Cxt={duration:.3,ease:"easeInOut"};function Ext({text:e,animationKey:t}){return a.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-start overflow-hidden py-0.5",children:a.jsx(Ue,{mode:"wait",children:a.jsx(te.span,{variants:kxt,initial:"initial",animate:"animate",exit:"exit",transition:Cxt,className:"text-muted-foreground truncate text-sm",children:e},t)})})}const Txt=["Type @ to mention a file","Type / to browse commands","Shift+Enter for a new line","Drop or paste files to attach","Press Esc twice to clear"],_xt=new Map([["1km","application/vnd.1000minds.decision-model+xml"],["3dml","text/vnd.in3d.3dml"],["3ds","image/x-3ds"],["3g2","video/3gpp2"],["3gp","video/3gp"],["3gpp","video/3gpp"],["3mf","model/3mf"],["7z","application/x-7z-compressed"],["7zip","application/x-7z-compressed"],["123","application/vnd.lotus-1-2-3"],["aab","application/x-authorware-bin"],["aac","audio/x-acc"],["aam","application/x-authorware-map"],["aas","application/x-authorware-seg"],["abw","application/x-abiword"],["ac","application/vnd.nokia.n-gage.ac+xml"],["ac3","audio/ac3"],["acc","application/vnd.americandynamics.acc"],["ace","application/x-ace-compressed"],["acu","application/vnd.acucobol"],["acutc","application/vnd.acucorp"],["adp","audio/adpcm"],["aep","application/vnd.audiograph"],["afm","application/x-font-type1"],["afp","application/vnd.ibm.modcap"],["ahead","application/vnd.ahead.space"],["ai","application/pdf"],["aif","audio/x-aiff"],["aifc","audio/x-aiff"],["aiff","audio/x-aiff"],["air","application/vnd.adobe.air-application-installer-package+zip"],["ait","application/vnd.dvb.ait"],["ami","application/vnd.amiga.ami"],["amr","audio/amr"],["apk","application/vnd.android.package-archive"],["apng","image/apng"],["appcache","text/cache-manifest"],["application","application/x-ms-application"],["apr","application/vnd.lotus-approach"],["arc","application/x-freearc"],["arj","application/x-arj"],["asc","application/pgp-signature"],["asf","video/x-ms-asf"],["asm","text/x-asm"],["aso","application/vnd.accpac.simply.aso"],["asx","video/x-ms-asf"],["atc","application/vnd.acucorp"],["atom","application/atom+xml"],["atomcat","application/atomcat+xml"],["atomdeleted","application/atomdeleted+xml"],["atomsvc","application/atomsvc+xml"],["atx","application/vnd.antix.game-component"],["au","audio/x-au"],["avi","video/x-msvideo"],["avif","image/avif"],["aw","application/applixware"],["azf","application/vnd.airzip.filesecure.azf"],["azs","application/vnd.airzip.filesecure.azs"],["azv","image/vnd.airzip.accelerator.azv"],["azw","application/vnd.amazon.ebook"],["b16","image/vnd.pco.b16"],["bat","application/x-msdownload"],["bcpio","application/x-bcpio"],["bdf","application/x-font-bdf"],["bdm","application/vnd.syncml.dm+wbxml"],["bdoc","application/x-bdoc"],["bed","application/vnd.realvnc.bed"],["bh2","application/vnd.fujitsu.oasysprs"],["bin","application/octet-stream"],["blb","application/x-blorb"],["blorb","application/x-blorb"],["bmi","application/vnd.bmi"],["bmml","application/vnd.balsamiq.bmml+xml"],["bmp","image/bmp"],["book","application/vnd.framemaker"],["box","application/vnd.previewsystems.box"],["boz","application/x-bzip2"],["bpk","application/octet-stream"],["bpmn","application/octet-stream"],["bsp","model/vnd.valve.source.compiled-map"],["btif","image/prs.btif"],["buffer","application/octet-stream"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["c","text/x-c"],["c4d","application/vnd.clonk.c4group"],["c4f","application/vnd.clonk.c4group"],["c4g","application/vnd.clonk.c4group"],["c4p","application/vnd.clonk.c4group"],["c4u","application/vnd.clonk.c4group"],["c11amc","application/vnd.cluetrust.cartomobile-config"],["c11amz","application/vnd.cluetrust.cartomobile-config-pkg"],["cab","application/vnd.ms-cab-compressed"],["caf","audio/x-caf"],["cap","application/vnd.tcpdump.pcap"],["car","application/vnd.curl.car"],["cat","application/vnd.ms-pki.seccat"],["cb7","application/x-cbr"],["cba","application/x-cbr"],["cbr","application/x-cbr"],["cbt","application/x-cbr"],["cbz","application/x-cbr"],["cc","text/x-c"],["cco","application/x-cocoa"],["cct","application/x-director"],["ccxml","application/ccxml+xml"],["cdbcmsg","application/vnd.contact.cmsg"],["cda","application/x-cdf"],["cdf","application/x-netcdf"],["cdfx","application/cdfx+xml"],["cdkey","application/vnd.mediastation.cdkey"],["cdmia","application/cdmi-capability"],["cdmic","application/cdmi-container"],["cdmid","application/cdmi-domain"],["cdmio","application/cdmi-object"],["cdmiq","application/cdmi-queue"],["cdr","application/cdr"],["cdx","chemical/x-cdx"],["cdxml","application/vnd.chemdraw+xml"],["cdy","application/vnd.cinderella"],["cer","application/pkix-cert"],["cfs","application/x-cfs-compressed"],["cgm","image/cgm"],["chat","application/x-chat"],["chm","application/vnd.ms-htmlhelp"],["chrt","application/vnd.kde.kchart"],["cif","chemical/x-cif"],["cii","application/vnd.anser-web-certificate-issue-initiation"],["cil","application/vnd.ms-artgalry"],["cjs","application/node"],["cla","application/vnd.claymore"],["class","application/octet-stream"],["clkk","application/vnd.crick.clicker.keyboard"],["clkp","application/vnd.crick.clicker.palette"],["clkt","application/vnd.crick.clicker.template"],["clkw","application/vnd.crick.clicker.wordbank"],["clkx","application/vnd.crick.clicker"],["clp","application/x-msclip"],["cmc","application/vnd.cosmocaller"],["cmdf","chemical/x-cmdf"],["cml","chemical/x-cml"],["cmp","application/vnd.yellowriver-custom-menu"],["cmx","image/x-cmx"],["cod","application/vnd.rim.cod"],["coffee","text/coffeescript"],["com","application/x-msdownload"],["conf","text/plain"],["cpio","application/x-cpio"],["cpp","text/x-c"],["cpt","application/mac-compactpro"],["crd","application/x-mscardfile"],["crl","application/pkix-crl"],["crt","application/x-x509-ca-cert"],["crx","application/x-chrome-extension"],["cryptonote","application/vnd.rig.cryptonote"],["csh","application/x-csh"],["csl","application/vnd.citationstyles.style+xml"],["csml","chemical/x-csml"],["csp","application/vnd.commonspace"],["csr","application/octet-stream"],["css","text/css"],["cst","application/x-director"],["csv","text/csv"],["cu","application/cu-seeme"],["curl","text/vnd.curl"],["cww","application/prs.cww"],["cxt","application/x-director"],["cxx","text/x-c"],["dae","model/vnd.collada+xml"],["daf","application/vnd.mobius.daf"],["dart","application/vnd.dart"],["dataless","application/vnd.fdsn.seed"],["davmount","application/davmount+xml"],["dbf","application/vnd.dbf"],["dbk","application/docbook+xml"],["dcr","application/x-director"],["dcurl","text/vnd.curl.dcurl"],["dd2","application/vnd.oma.dd2+xml"],["ddd","application/vnd.fujixerox.ddd"],["ddf","application/vnd.syncml.dmddf+xml"],["dds","image/vnd.ms-dds"],["deb","application/x-debian-package"],["def","text/plain"],["deploy","application/octet-stream"],["der","application/x-x509-ca-cert"],["dfac","application/vnd.dreamfactory"],["dgc","application/x-dgc-compressed"],["dic","text/x-c"],["dir","application/x-director"],["dis","application/vnd.mobius.dis"],["disposition-notification","message/disposition-notification"],["dist","application/octet-stream"],["distz","application/octet-stream"],["djv","image/vnd.djvu"],["djvu","image/vnd.djvu"],["dll","application/octet-stream"],["dmg","application/x-apple-diskimage"],["dmn","application/octet-stream"],["dmp","application/vnd.tcpdump.pcap"],["dms","application/octet-stream"],["dna","application/vnd.dna"],["doc","application/msword"],["docm","application/vnd.ms-word.template.macroEnabled.12"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["dot","application/msword"],["dotm","application/vnd.ms-word.template.macroEnabled.12"],["dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"],["dp","application/vnd.osgi.dp"],["dpg","application/vnd.dpgraph"],["dra","audio/vnd.dra"],["drle","image/dicom-rle"],["dsc","text/prs.lines.tag"],["dssc","application/dssc+der"],["dtb","application/x-dtbook+xml"],["dtd","application/xml-dtd"],["dts","audio/vnd.dts"],["dtshd","audio/vnd.dts.hd"],["dump","application/octet-stream"],["dvb","video/vnd.dvb.file"],["dvi","application/x-dvi"],["dwd","application/atsc-dwd+xml"],["dwf","model/vnd.dwf"],["dwg","image/vnd.dwg"],["dxf","image/vnd.dxf"],["dxp","application/vnd.spotfire.dxp"],["dxr","application/x-director"],["ear","application/java-archive"],["ecelp4800","audio/vnd.nuera.ecelp4800"],["ecelp7470","audio/vnd.nuera.ecelp7470"],["ecelp9600","audio/vnd.nuera.ecelp9600"],["ecma","application/ecmascript"],["edm","application/vnd.novadigm.edm"],["edx","application/vnd.novadigm.edx"],["efif","application/vnd.picsel"],["ei6","application/vnd.pg.osasli"],["elc","application/octet-stream"],["emf","image/emf"],["eml","message/rfc822"],["emma","application/emma+xml"],["emotionml","application/emotionml+xml"],["emz","application/x-msmetafile"],["eol","audio/vnd.digital-winds"],["eot","application/vnd.ms-fontobject"],["eps","application/postscript"],["epub","application/epub+zip"],["es","application/ecmascript"],["es3","application/vnd.eszigno3+xml"],["esa","application/vnd.osgi.subsystem"],["esf","application/vnd.epson.esf"],["et3","application/vnd.eszigno3+xml"],["etx","text/x-setext"],["eva","application/x-eva"],["evy","application/x-envoy"],["exe","application/octet-stream"],["exi","application/exi"],["exp","application/express"],["exr","image/aces"],["ext","application/vnd.novadigm.ext"],["ez","application/andrew-inset"],["ez2","application/vnd.ezpix-album"],["ez3","application/vnd.ezpix-package"],["f","text/x-fortran"],["f4v","video/mp4"],["f77","text/x-fortran"],["f90","text/x-fortran"],["fbs","image/vnd.fastbidsheet"],["fcdt","application/vnd.adobe.formscentral.fcdt"],["fcs","application/vnd.isac.fcs"],["fdf","application/vnd.fdf"],["fdt","application/fdt+xml"],["fe_launch","application/vnd.denovo.fcselayout-link"],["fg5","application/vnd.fujitsu.oasysgp"],["fgd","application/x-director"],["fh","image/x-freehand"],["fh4","image/x-freehand"],["fh5","image/x-freehand"],["fh7","image/x-freehand"],["fhc","image/x-freehand"],["fig","application/x-xfig"],["fits","image/fits"],["flac","audio/x-flac"],["fli","video/x-fli"],["flo","application/vnd.micrografx.flo"],["flv","video/x-flv"],["flw","application/vnd.kde.kivio"],["flx","text/vnd.fmi.flexstor"],["fly","text/vnd.fly"],["fm","application/vnd.framemaker"],["fnc","application/vnd.frogans.fnc"],["fo","application/vnd.software602.filler.form+xml"],["for","text/x-fortran"],["fpx","image/vnd.fpx"],["frame","application/vnd.framemaker"],["fsc","application/vnd.fsc.weblaunch"],["fst","image/vnd.fst"],["ftc","application/vnd.fluxtime.clip"],["fti","application/vnd.anser-web-funds-transfer-initiation"],["fvt","video/vnd.fvt"],["fxp","application/vnd.adobe.fxp"],["fxpl","application/vnd.adobe.fxp"],["fzs","application/vnd.fuzzysheet"],["g2w","application/vnd.geoplan"],["g3","image/g3fax"],["g3w","application/vnd.geospace"],["gac","application/vnd.groove-account"],["gam","application/x-tads"],["gbr","application/rpki-ghostbusters"],["gca","application/x-gca-compressed"],["gdl","model/vnd.gdl"],["gdoc","application/vnd.google-apps.document"],["geo","application/vnd.dynageo"],["geojson","application/geo+json"],["gex","application/vnd.geometry-explorer"],["ggb","application/vnd.geogebra.file"],["ggt","application/vnd.geogebra.tool"],["ghf","application/vnd.groove-help"],["gif","image/gif"],["gim","application/vnd.groove-identity-message"],["glb","model/gltf-binary"],["gltf","model/gltf+json"],["gml","application/gml+xml"],["gmx","application/vnd.gmx"],["gnumeric","application/x-gnumeric"],["gpg","application/gpg-keys"],["gph","application/vnd.flographit"],["gpx","application/gpx+xml"],["gqf","application/vnd.grafeq"],["gqs","application/vnd.grafeq"],["gram","application/srgs"],["gramps","application/x-gramps-xml"],["gre","application/vnd.geometry-explorer"],["grv","application/vnd.groove-injector"],["grxml","application/srgs+xml"],["gsf","application/x-font-ghostscript"],["gsheet","application/vnd.google-apps.spreadsheet"],["gslides","application/vnd.google-apps.presentation"],["gtar","application/x-gtar"],["gtm","application/vnd.groove-tool-message"],["gtw","model/vnd.gtw"],["gv","text/vnd.graphviz"],["gxf","application/gxf"],["gxt","application/vnd.geonext"],["gz","application/gzip"],["gzip","application/gzip"],["h","text/x-c"],["h261","video/h261"],["h263","video/h263"],["h264","video/h264"],["hal","application/vnd.hal+xml"],["hbci","application/vnd.hbci"],["hbs","text/x-handlebars-template"],["hdd","application/x-virtualbox-hdd"],["hdf","application/x-hdf"],["heic","image/heic"],["heics","image/heic-sequence"],["heif","image/heif"],["heifs","image/heif-sequence"],["hej2","image/hej2k"],["held","application/atsc-held+xml"],["hh","text/x-c"],["hjson","application/hjson"],["hlp","application/winhlp"],["hpgl","application/vnd.hp-hpgl"],["hpid","application/vnd.hp-hpid"],["hps","application/vnd.hp-hps"],["hqx","application/mac-binhex40"],["hsj2","image/hsj2"],["htc","text/x-component"],["htke","application/vnd.kenameaapp"],["htm","text/html"],["html","text/html"],["hvd","application/vnd.yamaha.hv-dic"],["hvp","application/vnd.yamaha.hv-voice"],["hvs","application/vnd.yamaha.hv-script"],["i2g","application/vnd.intergeo"],["icc","application/vnd.iccprofile"],["ice","x-conference/x-cooltalk"],["icm","application/vnd.iccprofile"],["ico","image/x-icon"],["ics","text/calendar"],["ief","image/ief"],["ifb","text/calendar"],["ifm","application/vnd.shana.informed.formdata"],["iges","model/iges"],["igl","application/vnd.igloader"],["igm","application/vnd.insors.igm"],["igs","model/iges"],["igx","application/vnd.micrografx.igx"],["iif","application/vnd.shana.informed.interchange"],["img","application/octet-stream"],["imp","application/vnd.accpac.simply.imp"],["ims","application/vnd.ms-ims"],["in","text/plain"],["ini","text/plain"],["ink","application/inkml+xml"],["inkml","application/inkml+xml"],["install","application/x-install-instructions"],["iota","application/vnd.astraea-software.iota"],["ipfix","application/ipfix"],["ipk","application/vnd.shana.informed.package"],["irm","application/vnd.ibm.rights-management"],["irp","application/vnd.irepository.package+xml"],["iso","application/x-iso9660-image"],["itp","application/vnd.shana.informed.formtemplate"],["its","application/its+xml"],["ivp","application/vnd.immervision-ivp"],["ivu","application/vnd.immervision-ivu"],["jad","text/vnd.sun.j2me.app-descriptor"],["jade","text/jade"],["jam","application/vnd.jam"],["jar","application/java-archive"],["jardiff","application/x-java-archive-diff"],["java","text/x-java-source"],["jhc","image/jphc"],["jisp","application/vnd.jisp"],["jls","image/jls"],["jlt","application/vnd.hp-jlyt"],["jng","image/x-jng"],["jnlp","application/x-java-jnlp-file"],["joda","application/vnd.joost.joda-archive"],["jp2","image/jp2"],["jpe","image/jpeg"],["jpeg","image/jpeg"],["jpf","image/jpx"],["jpg","image/jpeg"],["jpg2","image/jp2"],["jpgm","video/jpm"],["jpgv","video/jpeg"],["jph","image/jph"],["jpm","video/jpm"],["jpx","image/jpx"],["js","application/javascript"],["json","application/json"],["json5","application/json5"],["jsonld","application/ld+json"],["jsonl","application/jsonl"],["jsonml","application/jsonml+json"],["jsx","text/jsx"],["jxr","image/jxr"],["jxra","image/jxra"],["jxrs","image/jxrs"],["jxs","image/jxs"],["jxsc","image/jxsc"],["jxsi","image/jxsi"],["jxss","image/jxss"],["kar","audio/midi"],["karbon","application/vnd.kde.karbon"],["kdb","application/octet-stream"],["kdbx","application/x-keepass2"],["key","application/x-iwork-keynote-sffkey"],["kfo","application/vnd.kde.kformula"],["kia","application/vnd.kidspiration"],["kml","application/vnd.google-earth.kml+xml"],["kmz","application/vnd.google-earth.kmz"],["kne","application/vnd.kinar"],["knp","application/vnd.kinar"],["kon","application/vnd.kde.kontour"],["kpr","application/vnd.kde.kpresenter"],["kpt","application/vnd.kde.kpresenter"],["kpxx","application/vnd.ds-keypoint"],["ksp","application/vnd.kde.kspread"],["ktr","application/vnd.kahootz"],["ktx","image/ktx"],["ktx2","image/ktx2"],["ktz","application/vnd.kahootz"],["kwd","application/vnd.kde.kword"],["kwt","application/vnd.kde.kword"],["lasxml","application/vnd.las.las+xml"],["latex","application/x-latex"],["lbd","application/vnd.llamagraphics.life-balance.desktop"],["lbe","application/vnd.llamagraphics.life-balance.exchange+xml"],["les","application/vnd.hhe.lesson-player"],["less","text/less"],["lgr","application/lgr+xml"],["lha","application/octet-stream"],["link66","application/vnd.route66.link66+xml"],["list","text/plain"],["list3820","application/vnd.ibm.modcap"],["listafp","application/vnd.ibm.modcap"],["litcoffee","text/coffeescript"],["lnk","application/x-ms-shortcut"],["log","text/plain"],["lostxml","application/lost+xml"],["lrf","application/octet-stream"],["lrm","application/vnd.ms-lrm"],["ltf","application/vnd.frogans.ltf"],["lua","text/x-lua"],["luac","application/x-lua-bytecode"],["lvp","audio/vnd.lucent.voice"],["lwp","application/vnd.lotus-wordpro"],["lzh","application/octet-stream"],["m1v","video/mpeg"],["m2a","audio/mpeg"],["m2v","video/mpeg"],["m3a","audio/mpeg"],["m3u","text/plain"],["m3u8","application/vnd.apple.mpegurl"],["m4a","audio/x-m4a"],["m4p","application/mp4"],["m4s","video/iso.segment"],["m4u","application/vnd.mpegurl"],["m4v","video/x-m4v"],["m13","application/x-msmediaview"],["m14","application/x-msmediaview"],["m21","application/mp21"],["ma","application/mathematica"],["mads","application/mads+xml"],["maei","application/mmt-aei+xml"],["mag","application/vnd.ecowin.chart"],["maker","application/vnd.framemaker"],["man","text/troff"],["manifest","text/cache-manifest"],["map","application/json"],["mar","application/octet-stream"],["markdown","text/markdown"],["mathml","application/mathml+xml"],["mb","application/mathematica"],["mbk","application/vnd.mobius.mbk"],["mbox","application/mbox"],["mc1","application/vnd.medcalcdata"],["mcd","application/vnd.mcd"],["mcurl","text/vnd.curl.mcurl"],["md","text/markdown"],["mdb","application/x-msaccess"],["mdi","image/vnd.ms-modi"],["mdx","text/mdx"],["me","text/troff"],["mesh","model/mesh"],["meta4","application/metalink4+xml"],["metalink","application/metalink+xml"],["mets","application/mets+xml"],["mfm","application/vnd.mfmp"],["mft","application/rpki-manifest"],["mgp","application/vnd.osgeo.mapguide.package"],["mgz","application/vnd.proteus.magazine"],["mid","audio/midi"],["midi","audio/midi"],["mie","application/x-mie"],["mif","application/vnd.mif"],["mime","message/rfc822"],["mj2","video/mj2"],["mjp2","video/mj2"],["mjs","application/javascript"],["mk3d","video/x-matroska"],["mka","audio/x-matroska"],["mkd","text/x-markdown"],["mks","video/x-matroska"],["mkv","video/x-matroska"],["mlp","application/vnd.dolby.mlp"],["mmd","application/vnd.chipnuts.karaoke-mmd"],["mmf","application/vnd.smaf"],["mml","text/mathml"],["mmr","image/vnd.fujixerox.edmics-mmr"],["mng","video/x-mng"],["mny","application/x-msmoney"],["mobi","application/x-mobipocket-ebook"],["mods","application/mods+xml"],["mov","video/quicktime"],["movie","video/x-sgi-movie"],["mp2","audio/mpeg"],["mp2a","audio/mpeg"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mp4a","audio/mp4"],["mp4s","application/mp4"],["mp4v","video/mp4"],["mp21","application/mp21"],["mpc","application/vnd.mophun.certificate"],["mpd","application/dash+xml"],["mpe","video/mpeg"],["mpeg","video/mpeg"],["mpg","video/mpeg"],["mpg4","video/mp4"],["mpga","audio/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["mpm","application/vnd.blueice.multipass"],["mpn","application/vnd.mophun.application"],["mpp","application/vnd.ms-project"],["mpt","application/vnd.ms-project"],["mpy","application/vnd.ibm.minipay"],["mqy","application/vnd.mobius.mqy"],["mrc","application/marc"],["mrcx","application/marcxml+xml"],["ms","text/troff"],["mscml","application/mediaservercontrol+xml"],["mseed","application/vnd.fdsn.mseed"],["mseq","application/vnd.mseq"],["msf","application/vnd.epson.msf"],["msg","application/vnd.ms-outlook"],["msh","model/mesh"],["msi","application/x-msdownload"],["msl","application/vnd.mobius.msl"],["msm","application/octet-stream"],["msp","application/octet-stream"],["msty","application/vnd.muvee.style"],["mtl","model/mtl"],["mts","model/vnd.mts"],["mus","application/vnd.musician"],["musd","application/mmt-usd+xml"],["musicxml","application/vnd.recordare.musicxml+xml"],["mvb","application/x-msmediaview"],["mvt","application/vnd.mapbox-vector-tile"],["mwf","application/vnd.mfer"],["mxf","application/mxf"],["mxl","application/vnd.recordare.musicxml"],["mxmf","audio/mobile-xmf"],["mxml","application/xv+xml"],["mxs","application/vnd.triscape.mxs"],["mxu","video/vnd.mpegurl"],["n-gage","application/vnd.nokia.n-gage.symbian.install"],["n3","text/n3"],["nb","application/mathematica"],["nbp","application/vnd.wolfram.player"],["nc","application/x-netcdf"],["ncx","application/x-dtbncx+xml"],["nfo","text/x-nfo"],["ngdat","application/vnd.nokia.n-gage.data"],["nitf","application/vnd.nitf"],["nlu","application/vnd.neurolanguage.nlu"],["nml","application/vnd.enliven"],["nnd","application/vnd.noblenet-directory"],["nns","application/vnd.noblenet-sealer"],["nnw","application/vnd.noblenet-web"],["npx","image/vnd.net-fpx"],["nq","application/n-quads"],["nsc","application/x-conference"],["nsf","application/vnd.lotus-notes"],["nt","application/n-triples"],["ntf","application/vnd.nitf"],["numbers","application/x-iwork-numbers-sffnumbers"],["nzb","application/x-nzb"],["oa2","application/vnd.fujitsu.oasys2"],["oa3","application/vnd.fujitsu.oasys3"],["oas","application/vnd.fujitsu.oasys"],["obd","application/x-msbinder"],["obgx","application/vnd.openblox.game+xml"],["obj","model/obj"],["oda","application/oda"],["odb","application/vnd.oasis.opendocument.database"],["odc","application/vnd.oasis.opendocument.chart"],["odf","application/vnd.oasis.opendocument.formula"],["odft","application/vnd.oasis.opendocument.formula-template"],["odg","application/vnd.oasis.opendocument.graphics"],["odi","application/vnd.oasis.opendocument.image"],["odm","application/vnd.oasis.opendocument.text-master"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogex","model/vnd.opengex"],["ogg","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["omdoc","application/omdoc+xml"],["onepkg","application/onenote"],["onetmp","application/onenote"],["onetoc","application/onenote"],["onetoc2","application/onenote"],["opf","application/oebps-package+xml"],["opml","text/x-opml"],["oprc","application/vnd.palm"],["opus","audio/ogg"],["org","text/x-org"],["osf","application/vnd.yamaha.openscoreformat"],["osfpvg","application/vnd.yamaha.openscoreformat.osfpvg+xml"],["osm","application/vnd.openstreetmap.data+xml"],["otc","application/vnd.oasis.opendocument.chart-template"],["otf","font/otf"],["otg","application/vnd.oasis.opendocument.graphics-template"],["oth","application/vnd.oasis.opendocument.text-web"],["oti","application/vnd.oasis.opendocument.image-template"],["otp","application/vnd.oasis.opendocument.presentation-template"],["ots","application/vnd.oasis.opendocument.spreadsheet-template"],["ott","application/vnd.oasis.opendocument.text-template"],["ova","application/x-virtualbox-ova"],["ovf","application/x-virtualbox-ovf"],["owl","application/rdf+xml"],["oxps","application/oxps"],["oxt","application/vnd.openofficeorg.extension"],["p","text/x-pascal"],["p7a","application/x-pkcs7-signature"],["p7b","application/x-pkcs7-certificates"],["p7c","application/pkcs7-mime"],["p7m","application/pkcs7-mime"],["p7r","application/x-pkcs7-certreqresp"],["p7s","application/pkcs7-signature"],["p8","application/pkcs8"],["p10","application/x-pkcs10"],["p12","application/x-pkcs12"],["pac","application/x-ns-proxy-autoconfig"],["pages","application/x-iwork-pages-sffpages"],["pas","text/x-pascal"],["paw","application/vnd.pawaafile"],["pbd","application/vnd.powerbuilder6"],["pbm","image/x-portable-bitmap"],["pcap","application/vnd.tcpdump.pcap"],["pcf","application/x-font-pcf"],["pcl","application/vnd.hp-pcl"],["pclxl","application/vnd.hp-pclxl"],["pct","image/x-pict"],["pcurl","application/vnd.curl.pcurl"],["pcx","image/x-pcx"],["pdb","application/x-pilot"],["pde","text/x-processing"],["pdf","application/pdf"],["pem","application/x-x509-user-cert"],["pfa","application/x-font-type1"],["pfb","application/x-font-type1"],["pfm","application/x-font-type1"],["pfr","application/font-tdpfr"],["pfx","application/x-pkcs12"],["pgm","image/x-portable-graymap"],["pgn","application/x-chess-pgn"],["pgp","application/pgp"],["php","application/x-httpd-php"],["php3","application/x-httpd-php"],["php4","application/x-httpd-php"],["phps","application/x-httpd-php-source"],["phtml","application/x-httpd-php"],["pic","image/x-pict"],["pkg","application/octet-stream"],["pki","application/pkixcmp"],["pkipath","application/pkix-pkipath"],["pkpass","application/vnd.apple.pkpass"],["pl","application/x-perl"],["plb","application/vnd.3gpp.pic-bw-large"],["plc","application/vnd.mobius.plc"],["plf","application/vnd.pocketlearn"],["pls","application/pls+xml"],["pm","application/x-perl"],["pml","application/vnd.ctc-posml"],["png","image/png"],["pnm","image/x-portable-anymap"],["portpkg","application/vnd.macports.portpkg"],["pot","application/vnd.ms-powerpoint"],["potm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["potx","application/vnd.openxmlformats-officedocument.presentationml.template"],["ppa","application/vnd.ms-powerpoint"],["ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"],["ppd","application/vnd.cups-ppd"],["ppm","image/x-portable-pixmap"],["pps","application/vnd.ms-powerpoint"],["ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"],["ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"],["ppt","application/powerpoint"],["pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["pqa","application/vnd.palm"],["prc","application/x-pilot"],["pre","application/vnd.lotus-freelance"],["prf","application/pics-rules"],["provx","application/provenance+xml"],["ps","application/postscript"],["psb","application/vnd.3gpp.pic-bw-small"],["psd","application/x-photoshop"],["psf","application/x-font-linux-psf"],["pskcxml","application/pskc+xml"],["pti","image/prs.pti"],["ptid","application/vnd.pvi.ptid1"],["pub","application/x-mspublisher"],["pvb","application/vnd.3gpp.pic-bw-var"],["pwn","application/vnd.3m.post-it-notes"],["pya","audio/vnd.ms-playready.media.pya"],["pyv","video/vnd.ms-playready.media.pyv"],["qam","application/vnd.epson.quickanime"],["qbo","application/vnd.intu.qbo"],["qfx","application/vnd.intu.qfx"],["qps","application/vnd.publishare-delta-tree"],["qt","video/quicktime"],["qwd","application/vnd.quark.quarkxpress"],["qwt","application/vnd.quark.quarkxpress"],["qxb","application/vnd.quark.quarkxpress"],["qxd","application/vnd.quark.quarkxpress"],["qxl","application/vnd.quark.quarkxpress"],["qxt","application/vnd.quark.quarkxpress"],["ra","audio/x-realaudio"],["ram","audio/x-pn-realaudio"],["raml","application/raml+yaml"],["rapd","application/route-apd+xml"],["rar","application/x-rar"],["ras","image/x-cmu-raster"],["rcprofile","application/vnd.ipunplugged.rcprofile"],["rdf","application/rdf+xml"],["rdz","application/vnd.data-vision.rdz"],["relo","application/p2p-overlay+xml"],["rep","application/vnd.businessobjects"],["res","application/x-dtbresource+xml"],["rgb","image/x-rgb"],["rif","application/reginfo+xml"],["rip","audio/vnd.rip"],["ris","application/x-research-info-systems"],["rl","application/resource-lists+xml"],["rlc","image/vnd.fujixerox.edmics-rlc"],["rld","application/resource-lists-diff+xml"],["rm","audio/x-pn-realaudio"],["rmi","audio/midi"],["rmp","audio/x-pn-realaudio-plugin"],["rms","application/vnd.jcp.javame.midlet-rms"],["rmvb","application/vnd.rn-realmedia-vbr"],["rnc","application/relax-ng-compact-syntax"],["rng","application/xml"],["roa","application/rpki-roa"],["roff","text/troff"],["rp9","application/vnd.cloanto.rp9"],["rpm","audio/x-pn-realaudio-plugin"],["rpss","application/vnd.nokia.radio-presets"],["rpst","application/vnd.nokia.radio-preset"],["rq","application/sparql-query"],["rs","application/rls-services+xml"],["rsa","application/x-pkcs7"],["rsat","application/atsc-rsat+xml"],["rsd","application/rsd+xml"],["rsheet","application/urc-ressheet+xml"],["rss","application/rss+xml"],["rtf","text/rtf"],["rtx","text/richtext"],["run","application/x-makeself"],["rusd","application/route-usd+xml"],["rv","video/vnd.rn-realvideo"],["s","text/x-asm"],["s3m","audio/s3m"],["saf","application/vnd.yamaha.smaf-audio"],["sass","text/x-sass"],["sbml","application/sbml+xml"],["sc","application/vnd.ibm.secure-container"],["scd","application/x-msschedule"],["scm","application/vnd.lotus-screencam"],["scq","application/scvp-cv-request"],["scs","application/scvp-cv-response"],["scss","text/x-scss"],["scurl","text/vnd.curl.scurl"],["sda","application/vnd.stardivision.draw"],["sdc","application/vnd.stardivision.calc"],["sdd","application/vnd.stardivision.impress"],["sdkd","application/vnd.solent.sdkm+xml"],["sdkm","application/vnd.solent.sdkm+xml"],["sdp","application/sdp"],["sdw","application/vnd.stardivision.writer"],["sea","application/octet-stream"],["see","application/vnd.seemail"],["seed","application/vnd.fdsn.seed"],["sema","application/vnd.sema"],["semd","application/vnd.semd"],["semf","application/vnd.semf"],["senmlx","application/senml+xml"],["sensmlx","application/sensml+xml"],["ser","application/java-serialized-object"],["setpay","application/set-payment-initiation"],["setreg","application/set-registration-initiation"],["sfd-hdstx","application/vnd.hydrostatix.sof-data"],["sfs","application/vnd.spotfire.sfs"],["sfv","text/x-sfv"],["sgi","image/sgi"],["sgl","application/vnd.stardivision.writer-global"],["sgm","text/sgml"],["sgml","text/sgml"],["sh","application/x-sh"],["shar","application/x-shar"],["shex","text/shex"],["shf","application/shf+xml"],["shtml","text/html"],["sid","image/x-mrsid-image"],["sieve","application/sieve"],["sig","application/pgp-signature"],["sil","audio/silk"],["silo","model/mesh"],["sis","application/vnd.symbian.install"],["sisx","application/vnd.symbian.install"],["sit","application/x-stuffit"],["sitx","application/x-stuffitx"],["siv","application/sieve"],["skd","application/vnd.koan"],["skm","application/vnd.koan"],["skp","application/vnd.koan"],["skt","application/vnd.koan"],["sldm","application/vnd.ms-powerpoint.slide.macroenabled.12"],["sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"],["slim","text/slim"],["slm","text/slim"],["sls","application/route-s-tsid+xml"],["slt","application/vnd.epson.salt"],["sm","application/vnd.stepmania.stepchart"],["smf","application/vnd.stardivision.math"],["smi","application/smil"],["smil","application/smil"],["smv","video/x-smv"],["smzip","application/vnd.stepmania.package"],["snd","audio/basic"],["snf","application/x-font-snf"],["so","application/octet-stream"],["spc","application/x-pkcs7-certificates"],["spdx","text/spdx"],["spf","application/vnd.yamaha.smaf-phrase"],["spl","application/x-futuresplash"],["spot","text/vnd.in3d.spot"],["spp","application/scvp-vp-response"],["spq","application/scvp-vp-request"],["spx","audio/ogg"],["sql","application/x-sql"],["src","application/x-wais-source"],["srt","application/x-subrip"],["sru","application/sru+xml"],["srx","application/sparql-results+xml"],["ssdl","application/ssdl+xml"],["sse","application/vnd.kodak-descriptor"],["ssf","application/vnd.epson.ssf"],["ssml","application/ssml+xml"],["sst","application/octet-stream"],["st","application/vnd.sailingtracker.track"],["stc","application/vnd.sun.xml.calc.template"],["std","application/vnd.sun.xml.draw.template"],["stf","application/vnd.wt.stf"],["sti","application/vnd.sun.xml.impress.template"],["stk","application/hyperstudio"],["stl","model/stl"],["stpx","model/step+xml"],["stpxz","model/step-xml+zip"],["stpz","model/step+zip"],["str","application/vnd.pg.format"],["stw","application/vnd.sun.xml.writer.template"],["styl","text/stylus"],["stylus","text/stylus"],["sub","text/vnd.dvb.subtitle"],["sus","application/vnd.sus-calendar"],["susp","application/vnd.sus-calendar"],["sv4cpio","application/x-sv4cpio"],["sv4crc","application/x-sv4crc"],["svc","application/vnd.dvb.service"],["svd","application/vnd.svd"],["svg","image/svg+xml"],["svgz","image/svg+xml"],["swa","application/x-director"],["swf","application/x-shockwave-flash"],["swi","application/vnd.aristanetworks.swi"],["swidtag","application/swid+xml"],["sxc","application/vnd.sun.xml.calc"],["sxd","application/vnd.sun.xml.draw"],["sxg","application/vnd.sun.xml.writer.global"],["sxi","application/vnd.sun.xml.impress"],["sxm","application/vnd.sun.xml.math"],["sxw","application/vnd.sun.xml.writer"],["t","text/troff"],["t3","application/x-t3vm-image"],["t38","image/t38"],["taglet","application/vnd.mynfc"],["tao","application/vnd.tao.intent-module-archive"],["tap","image/vnd.tencent.tap"],["tar","application/x-tar"],["tcap","application/vnd.3gpp2.tcap"],["tcl","application/x-tcl"],["td","application/urc-targetdesc+xml"],["teacher","application/vnd.smart.teacher"],["tei","application/tei+xml"],["teicorpus","application/tei+xml"],["tex","application/x-tex"],["texi","application/x-texinfo"],["texinfo","application/x-texinfo"],["text","text/plain"],["tfi","application/thraud+xml"],["tfm","application/x-tex-tfm"],["tfx","image/tiff-fx"],["tga","image/x-tga"],["tgz","application/x-tar"],["thmx","application/vnd.ms-officetheme"],["tif","image/tiff"],["tiff","image/tiff"],["tk","application/x-tcl"],["tmo","application/vnd.tmobile-livetv"],["toml","application/toml"],["torrent","application/x-bittorrent"],["tpl","application/vnd.groove-tool-template"],["tpt","application/vnd.trid.tpt"],["tr","text/troff"],["tra","application/vnd.trueapp"],["trig","application/trig"],["trm","application/x-msterminal"],["ts","video/mp2t"],["tsd","application/timestamped-data"],["tsv","text/tab-separated-values"],["ttc","font/collection"],["ttf","font/ttf"],["ttl","text/turtle"],["ttml","application/ttml+xml"],["twd","application/vnd.simtech-mindmapper"],["twds","application/vnd.simtech-mindmapper"],["txd","application/vnd.genomatix.tuxedo"],["txf","application/vnd.mobius.txf"],["txt","text/plain"],["u8dsn","message/global-delivery-status"],["u8hdr","message/global-headers"],["u8mdn","message/global-disposition-notification"],["u8msg","message/global"],["u32","application/x-authorware-bin"],["ubj","application/ubjson"],["udeb","application/x-debian-package"],["ufd","application/vnd.ufdl"],["ufdl","application/vnd.ufdl"],["ulx","application/x-glulx"],["umj","application/vnd.umajin"],["unityweb","application/vnd.unity"],["uoml","application/vnd.uoml+xml"],["uri","text/uri-list"],["uris","text/uri-list"],["urls","text/uri-list"],["usdz","model/vnd.usdz+zip"],["ustar","application/x-ustar"],["utz","application/vnd.uiq.theme"],["uu","text/x-uuencode"],["uva","audio/vnd.dece.audio"],["uvd","application/vnd.dece.data"],["uvf","application/vnd.dece.data"],["uvg","image/vnd.dece.graphic"],["uvh","video/vnd.dece.hd"],["uvi","image/vnd.dece.graphic"],["uvm","video/vnd.dece.mobile"],["uvp","video/vnd.dece.pd"],["uvs","video/vnd.dece.sd"],["uvt","application/vnd.dece.ttml+xml"],["uvu","video/vnd.uvvu.mp4"],["uvv","video/vnd.dece.video"],["uvva","audio/vnd.dece.audio"],["uvvd","application/vnd.dece.data"],["uvvf","application/vnd.dece.data"],["uvvg","image/vnd.dece.graphic"],["uvvh","video/vnd.dece.hd"],["uvvi","image/vnd.dece.graphic"],["uvvm","video/vnd.dece.mobile"],["uvvp","video/vnd.dece.pd"],["uvvs","video/vnd.dece.sd"],["uvvt","application/vnd.dece.ttml+xml"],["uvvu","video/vnd.uvvu.mp4"],["uvvv","video/vnd.dece.video"],["uvvx","application/vnd.dece.unspecified"],["uvvz","application/vnd.dece.zip"],["uvx","application/vnd.dece.unspecified"],["uvz","application/vnd.dece.zip"],["vbox","application/x-virtualbox-vbox"],["vbox-extpack","application/x-virtualbox-vbox-extpack"],["vcard","text/vcard"],["vcd","application/x-cdlink"],["vcf","text/x-vcard"],["vcg","application/vnd.groove-vcard"],["vcs","text/x-vcalendar"],["vcx","application/vnd.vcx"],["vdi","application/x-virtualbox-vdi"],["vds","model/vnd.sap.vds"],["vhd","application/x-virtualbox-vhd"],["vis","application/vnd.visionary"],["viv","video/vnd.vivo"],["vlc","application/videolan"],["vmdk","application/x-virtualbox-vmdk"],["vob","video/x-ms-vob"],["vor","application/vnd.stardivision.writer"],["vox","application/x-authorware-bin"],["vrml","model/vrml"],["vsd","application/vnd.visio"],["vsf","application/vnd.vsf"],["vss","application/vnd.visio"],["vst","application/vnd.visio"],["vsw","application/vnd.visio"],["vtf","image/vnd.valve.source.texture"],["vtt","text/vtt"],["vtu","model/vnd.vtu"],["vxml","application/voicexml+xml"],["w3d","application/x-director"],["wad","application/x-doom"],["wadl","application/vnd.sun.wadl+xml"],["war","application/java-archive"],["wasm","application/wasm"],["wav","audio/x-wav"],["wax","audio/x-ms-wax"],["wbmp","image/vnd.wap.wbmp"],["wbs","application/vnd.criticaltools.wbs+xml"],["wbxml","application/wbxml"],["wcm","application/vnd.ms-works"],["wdb","application/vnd.ms-works"],["wdp","image/vnd.ms-photo"],["weba","audio/webm"],["webapp","application/x-web-app-manifest+json"],["webm","video/webm"],["webmanifest","application/manifest+json"],["webp","image/webp"],["wg","application/vnd.pmi.widget"],["wgt","application/widget"],["wks","application/vnd.ms-works"],["wm","video/x-ms-wm"],["wma","audio/x-ms-wma"],["wmd","application/x-ms-wmd"],["wmf","image/wmf"],["wml","text/vnd.wap.wml"],["wmlc","application/wmlc"],["wmls","text/vnd.wap.wmlscript"],["wmlsc","application/vnd.wap.wmlscriptc"],["wmv","video/x-ms-wmv"],["wmx","video/x-ms-wmx"],["wmz","application/x-msmetafile"],["woff","font/woff"],["woff2","font/woff2"],["word","application/msword"],["wpd","application/vnd.wordperfect"],["wpl","application/vnd.ms-wpl"],["wps","application/vnd.ms-works"],["wqd","application/vnd.wqd"],["wri","application/x-mswrite"],["wrl","model/vrml"],["wsc","message/vnd.wfa.wsc"],["wsdl","application/wsdl+xml"],["wspolicy","application/wspolicy+xml"],["wtb","application/vnd.webturbo"],["wvx","video/x-ms-wvx"],["x3d","model/x3d+xml"],["x3db","model/x3d+fastinfoset"],["x3dbz","model/x3d+binary"],["x3dv","model/x3d-vrml"],["x3dvz","model/x3d+vrml"],["x3dz","model/x3d+xml"],["x32","application/x-authorware-bin"],["x_b","model/vnd.parasolid.transmit.binary"],["x_t","model/vnd.parasolid.transmit.text"],["xaml","application/xaml+xml"],["xap","application/x-silverlight-app"],["xar","application/vnd.xara"],["xav","application/xcap-att+xml"],["xbap","application/x-ms-xbap"],["xbd","application/vnd.fujixerox.docuworks.binder"],["xbm","image/x-xbitmap"],["xca","application/xcap-caps+xml"],["xcs","application/calendar+xml"],["xdf","application/xcap-diff+xml"],["xdm","application/vnd.syncml.dm+xml"],["xdp","application/vnd.adobe.xdp+xml"],["xdssc","application/dssc+xml"],["xdw","application/vnd.fujixerox.docuworks"],["xel","application/xcap-el+xml"],["xenc","application/xenc+xml"],["xer","application/patch-ops-error+xml"],["xfdf","application/vnd.adobe.xfdf"],["xfdl","application/vnd.xfdl"],["xht","application/xhtml+xml"],["xhtml","application/xhtml+xml"],["xhvml","application/xv+xml"],["xif","image/vnd.xiff"],["xl","application/excel"],["xla","application/vnd.ms-excel"],["xlam","application/vnd.ms-excel.addin.macroEnabled.12"],["xlc","application/vnd.ms-excel"],["xlf","application/xliff+xml"],["xlm","application/vnd.ms-excel"],["xls","application/vnd.ms-excel"],["xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"],["xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xlt","application/vnd.ms-excel"],["xltm","application/vnd.ms-excel.template.macroEnabled.12"],["xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"],["xlw","application/vnd.ms-excel"],["xm","audio/xm"],["xml","application/xml"],["xns","application/xcap-ns+xml"],["xo","application/vnd.olpc-sugar"],["xop","application/xop+xml"],["xpi","application/x-xpinstall"],["xpl","application/xproc+xml"],["xpm","image/x-xpixmap"],["xpr","application/vnd.is-xpr"],["xps","application/vnd.ms-xpsdocument"],["xpw","application/vnd.intercon.formnet"],["xpx","application/vnd.intercon.formnet"],["xsd","application/xml"],["xsl","application/xml"],["xslt","application/xslt+xml"],["xsm","application/vnd.syncml+xml"],["xspf","application/xspf+xml"],["xul","application/vnd.mozilla.xul+xml"],["xvm","application/xv+xml"],["xvml","application/xv+xml"],["xwd","image/x-xwindowdump"],["xyz","chemical/x-xyz"],["xz","application/x-xz"],["yaml","text/yaml"],["yang","application/yang"],["yin","application/yin+xml"],["yml","text/yaml"],["ymp","text/x-suse-ymp"],["z","application/x-compress"],["z1","application/x-zmachine"],["z2","application/x-zmachine"],["z3","application/x-zmachine"],["z4","application/x-zmachine"],["z5","application/x-zmachine"],["z6","application/x-zmachine"],["z7","application/x-zmachine"],["z8","application/x-zmachine"],["zaz","application/vnd.zzazz.deck+xml"],["zip","application/zip"],["zir","application/vnd.zul"],["zirz","application/vnd.zul"],["zmm","application/vnd.handheld-entertainment+xml"],["zsh","text/x-scriptzsh"]]);function Pg(e,t,n){const s=Nxt(e),{webkitRelativePath:r}=e,i=typeof t=="string"?t:typeof r=="string"&&r.length>0?r:`./${e.name}`;return typeof s.path!="string"&&dG(s,"path",i),dG(s,"relativePath",i),s}function Nxt(e){const{name:t}=e;if(t&&t.lastIndexOf(".")!==-1&&!e.type){const s=t.split(".").pop().toLowerCase(),r=_xt.get(s);r&&Object.defineProperty(e,"type",{value:r,writable:!1,configurable:!1,enumerable:!0})}return e}function dG(e,t,n){Object.defineProperty(e,t,{value:n,writable:!1,configurable:!1,enumerable:!0})}const jxt=[".DS_Store","Thumbs.db"];function Axt(e){return Ih(this,void 0,void 0,function*(){return UC(e)&&Rxt(e.dataTransfer)?Ixt(e.dataTransfer,e.type):Mxt(e)?Dxt(e):Array.isArray(e)&&e.every(t=>"getFile"in t&&typeof t.getFile=="function")?Oxt(e):[]})}function Rxt(e){return UC(e)}function Mxt(e){return UC(e)&&UC(e.target)}function UC(e){return typeof e=="object"&&e!==null}function Dxt(e){return JD(e.target.files).map(t=>Pg(t))}function Oxt(e){return Ih(this,void 0,void 0,function*(){return(yield Promise.all(e.map(n=>n.getFile()))).map(n=>Pg(n))})}function Ixt(e,t){return Ih(this,void 0,void 0,function*(){if(e.items){const n=JD(e.items).filter(r=>r.kind==="file");if(t!=="drop")return n;const s=yield Promise.all(n.map(Pxt));return fG(Vde(s))}return fG(JD(e.files).map(n=>Pg(n)))})}function fG(e){return e.filter(t=>jxt.indexOf(t.name)===-1)}function JD(e){if(e===null)return[];const t=[];for(let n=0;n<e.length;n++){const s=e[n];t.push(s)}return t}function Pxt(e){if(typeof e.webkitGetAsEntry!="function")return hG(e);const t=e.webkitGetAsEntry();return t&&t.isDirectory?qde(t):hG(e,t)}function Vde(e){return e.reduce((t,n)=>[...t,...Array.isArray(n)?Vde(n):[n]],[])}function hG(e,t){return Ih(this,void 0,void 0,function*(){var n;if(globalThis.isSecureContext&&typeof e.getAsFileSystemHandle=="function"){const i=yield e.getAsFileSystemHandle();if(i===null)throw new Error(`${e} is not a File`);if(i!==void 0){const o=yield i.getFile();return o.handle=i,Pg(o)}}const s=e.getAsFile();if(!s)throw new Error(`${e} is not a File`);return Pg(s,(n=t==null?void 0:t.fullPath)!==null&&n!==void 0?n:void 0)})}function Lxt(e){return Ih(this,void 0,void 0,function*(){return e.isDirectory?qde(e):Fxt(e)})}function qde(e){const t=e.createReader();return new Promise((n,s)=>{const r=[];function i(){t.readEntries(o=>Ih(this,void 0,void 0,function*(){if(o.length){const l=Promise.all(o.map(Lxt));r.push(l),i()}else try{const l=yield Promise.all(r);n(l)}catch(l){s(l)}}),o=>{s(o)})}i()})}function Fxt(e){return Ih(this,void 0,void 0,function*(){return new Promise((t,n)=>{e.file(s=>{const r=Pg(s,e.fullPath);t(r)},s=>{n(s)})})})}var bw={},mG;function zxt(){return mG||(mG=1,bw.__esModule=!0,bw.default=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(",");if(n.length===0)return!0;var s=e.name||"",r=(e.type||"").toLowerCase(),i=r.replace(/\/.*$/,"");return n.some(function(o){var l=o.trim().toLowerCase();return l.charAt(0)==="."?s.toLowerCase().endsWith(l):l.endsWith("/*")?i===l.replace(/\/.*$/,""):r===l})}return!0}),bw}var Bxt=zxt();const jR=hl(Bxt);function pG(e){return Uxt(e)||Hxt(e)||Kde(e)||$xt()}function $xt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
1275
1275
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Hxt(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Uxt(e){if(Array.isArray(e))return eO(e)}function gG(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),n.push.apply(n,s)}return n}function xG(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?gG(Object(n),!0).forEach(function(s){Gde(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gG(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function Gde(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Iv(e,t){return Gxt(e)||qxt(e,t)||Kde(e,t)||Vxt()}function Vxt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
1276
1276
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Kde(e,t){if(e){if(typeof e=="string")return eO(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eO(e,t)}}function eO(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,s=new Array(t);n<t;n++)s[n]=e[n];return s}function qxt(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var s=[],r=!0,i=!1,o,l;try{for(n=n.call(e);!(r=(o=n.next()).done)&&(s.push(o.value),!(t&&s.length===t));r=!0);}catch(c){i=!0,l=c}finally{try{!r&&n.return!=null&&n.return()}finally{if(i)throw l}}return s}}function Gxt(e){if(Array.isArray(e))return e}var Kxt=typeof jR=="function"?jR:jR.default,Wxt="file-invalid-type",Yxt="file-too-large",Zxt="file-too-small",Xxt="too-many-files",Qxt=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",n=t.split(","),s=n.length>1?"one of ".concat(n.join(", ")):n[0];return{code:Wxt,message:"File type must be ".concat(s)}},yG=function(t){return{code:Yxt,message:"File is larger than ".concat(t," ").concat(t===1?"byte":"bytes")}},vG=function(t){return{code:Zxt,message:"File is smaller than ".concat(t," ").concat(t===1?"byte":"bytes")}},Jxt={code:Xxt,message:"Too many files"};function eyt(e){return e.type===""&&typeof e.getAsFile=="function"}function Wde(e,t){var n=e.type==="application/x-moz-file"||Kxt(e,t)||eyt(e);return[n,n?null:Qxt(t)]}function Yde(e,t,n){if(Nf(e.size))if(Nf(t)&&Nf(n)){if(e.size>n)return[!1,yG(n)];if(e.size<t)return[!1,vG(t)]}else{if(Nf(t)&&e.size<t)return[!1,vG(t)];if(Nf(n)&&e.size>n)return[!1,yG(n)]}return[!0,null]}function Nf(e){return e!=null}function tyt(e){var t=e.files,n=e.accept,s=e.minSize,r=e.maxSize,i=e.multiple,o=e.maxFiles,l=e.validator;return!i&&t.length>1||i&&o>=1&&t.length>o?!1:t.every(function(c){var u=Wde(c,n),d=Iv(u,1),f=d[0],m=Yde(c,s,r),g=Iv(m,1),y=g[0],b=l?l(c):null;return f&&y&&!b})}function VC(e){return typeof e.isPropagationStopped=="function"?e.isPropagationStopped():typeof e.cancelBubble<"u"?e.cancelBubble:!1}function ey(e){return e.dataTransfer?Array.prototype.some.call(e.dataTransfer.types,function(t){return t==="Files"||t==="application/x-moz-file"}):!!e.target&&!!e.target.files}function bG(e){e.preventDefault()}function nyt(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function syt(e){return e.indexOf("Edge/")!==-1}function ryt(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return nyt(e)||syt(e)}function Bo(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(s){for(var r=arguments.length,i=new Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];return t.some(function(l){return!VC(s)&&l&&l.apply(void 0,[s].concat(i)),VC(s)})}}function iyt(){return"showOpenFilePicker"in window}function ayt(e){if(Nf(e)){var t=Object.entries(e).filter(function(n){var s=Iv(n,2),r=s[0],i=s[1],o=!0;return Zde(r)||(console.warn('Skipped "'.concat(r,'" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.')),o=!1),(!Array.isArray(i)||!i.every(Xde))&&(console.warn('Skipped "'.concat(r,'" because an invalid file extension was provided.')),o=!1),o}).reduce(function(n,s){var r=Iv(s,2),i=r[0],o=r[1];return xG(xG({},n),{},Gde({},i,o))},{});return[{description:"Files",accept:t}]}return e}function oyt(e){if(Nf(e))return Object.entries(e).reduce(function(t,n){var s=Iv(n,2),r=s[0],i=s[1];return[].concat(pG(t),[r],pG(i))},[]).filter(function(t){return Zde(t)||Xde(t)}).join(",")}function lyt(e){return e instanceof DOMException&&(e.name==="AbortError"||e.code===e.ABORT_ERR)}function cyt(e){return e instanceof DOMException&&(e.name==="SecurityError"||e.code===e.SECURITY_ERR)}function Zde(e){return e==="audio/*"||e==="video/*"||e==="image/*"||e==="text/*"||e==="application/*"||/\w+\/[-+.\w]+/g.test(e)}function Xde(e){return/^.*\.[\w]+$/.test(e)}var uyt=["children"],dyt=["open"],fyt=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],hyt=["refKey","onChange","onClick"];function SG(e){return gyt(e)||pyt(e)||Qde(e)||myt()}function myt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
1277
1277
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function pyt(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function gyt(e){if(Array.isArray(e))return tO(e)}function AR(e,t){return vyt(e)||yyt(e,t)||Qde(e,t)||xyt()}function xyt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
@@ -1280,7 +1280,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1280
1280
|
${ot.map(kn=>`- ${kn}`).join(`
|
|
1281
1281
|
`)}
|
|
1282
1282
|
|
|
1283
|
-
${Ce}`),m.clearFiles()}return t?t(Ce):Ce},[m,f,t]),y=x.useCallback(le=>{c.handleTaskEvent(le);const Ce=c.tasks.map(Ge=>Ge.id===le.task.id?{...Ge,...le.task}:Ge);u.handleTaskEvent(le,Ce)},[c,u]);x.useCallback(le=>{r(le),i.invalidateQueries({queryKey:["session",le]})},[r,i]);const b=x.useCallback(le=>{r(le,{replace:!0}),i.invalidateQueries({queryKey:["session",le]})},[r,i]),{messages:S,input:w,setInput:C,handleSubmit:T,submitContent:E,status:j,error:_,sessionBusy:N,stop:R,isLoadingHistory:O,sessionStatus:M,streamStartTime:L,estimatedTokens:P,isTextStreaming:$,isWaitingForUser:q,waitingType:K,activeInteraction:B,pendingInteractions:V,markToolCallResponded:Q,isRateLimited:re,rateLimitRetryAfter:U,systemStatus:G,promptSuggestions:W,syncConnectionState:F,retryMessage:X,tryNativeCommand:J}=Zft(e,{transformContent:g,onTaskEvent:y,onSessionIdChangeReplace:b,launchRuntime:n,onStreamingDone:x.useCallback(()=>{d&&Mwe(),i.invalidateQueries({queryKey:["commands"]})},[d,i])}),{permissionMode:ae}=Pne(e,M,j==="streaming"),{handleToolRef:oe,focusedOptionIndex:de}=tht(B),{isAtBottom:me,hasNewMessages:Re,scrollToBottom:Fe,handleScrollStateChange:Le}=nht(S,o);aht(j,q,c.activeForm,$),x.useEffect(()=>{var le;(le=l.current)==null||le.focus()},[e]);const Xe=x.useRef(null);x.useEffect(()=>{var le;s&&Xe.current!==s&&S.length===0&&(Xe.current=s,C(s),(le=l.current)==null||le.focus())},[s,S.length,C]);const ze=ude(e??""),{data:Mt}=uce(f,e??void 0,ze.runtime??void 0),Ft=x.useMemo(()=>{const le=new Set(gq.map(Ge=>Ge.command)),Ce=((Mt==null?void 0:Mt.commands)??[]).filter(Ge=>!le.has(Ge.command));return[...gq,...Ce]},[Mt]),{data:Pe}=vxt(f),He=x.useMemo(()=>Pe!=null&&Pe.files?cht(Pe.files):[],[Pe]),gt=iht({input:w,setInput:C,commands:Ft,fileEntries:He,chatInputRef:l}),Ct=x.useCallback(()=>{const le=[...S].reverse().find(Ce=>Ce.role==="user");le!=null&&le.content&&E(le.content)},[S,E]),cn=x.useCallback(()=>{const le=[...S].reverse().find(Ce=>Ce.role==="user");le!=null&&le.content&&X(le.content)},[S,X]),Nt=j==="idle"&&W.length>0&&w.length===0,ts=nvt(j,_,S),Ln=x.useMemo(()=>S.some(le=>le.role==="user"),[S]),Oe=x.useCallback(le=>{var Ce;C(le),(Ce=l.current)==null||Ce.focus()},[C]);return a.jsxs("div",{"data-testid":"chat-panel",className:"mx-auto flex h-full w-full max-w-7xl flex-col",children:[a.jsx(N0t,{messages:S,sessionId:e,isLoadingHistory:O,isTextStreaming:$,isAtBottom:me,hasNewMessages:Re,scrollToBottom:Fe,onScrollStateChange:Le,activeToolCallId:(B==null?void 0:B.toolCallId)??null,onToolRef:oe,focusedOptionIndex:de,onToolDecided:Q,onRetry:Ct,inputZoneToolCallId:(B==null?void 0:B.toolCallId)??null,messageListRef:o}),a.jsx(Jyt,{terminalReason:M==null?void 0:M.terminalReason}),a.jsx(Wyt,{status:j,streamStartTime:L,estimatedTokens:P,permissionMode:ae,isWaitingForUser:q??!1,waitingType:K??"approval",isRateLimited:re??!1,rateLimitRetryAfter:U??null,systemStatus:G}),a.jsx(Ue,{children:Nt&&a.jsx(rvt,{suggestions:W,onChipClick:Oe})}),a.jsx(Dyt,{celebration:u.activeCelebration,onComplete:u.clearCelebration}),a.jsx(Myt,{tasks:c.tasks,taskMap:c.taskMap,activeForm:c.activeForm,isCollapsed:c.isCollapsed,onToggleCollapse:c.toggleCollapse,celebratingTaskId:u.celebratingTaskId,onCelebrationComplete:u.clearCelebration,statusTimestamps:c.statusTimestamps}),ts&&a.jsx(tvt,{sessionId:e,onRetry:Ln?Ct:void 0}),_&&a.jsx("div",{className:"mx-4 mb-2",children:a.jsx(KP,{message:_.message,heading:_.heading,subtext:_.message,onRetry:_.retryable?cn:void 0})}),a.jsx(Cyt,{chatInputRef:l,input:w,autocomplete:gt,handleSubmit:T,submitContent:E,tryNativeCommand:J,status:j,sessionBusy:N,stop:R,setInput:C,sessionId:e??"",sessionStatus:M,fileUpload:{pendingFiles:m.pendingFiles,onFilesSelected:m.addFiles,onFileRemove:m.removeFile,isUploading:m.isUploading},interaction:{active:B,pendingApprovals:V.filter(le=>le.interactiveType==="approval"),focusedOptionIndex:de,onToolRef:oe,onToolDecided:Q},sync:{connectionState:F}})]})}const avt={url:ha,markdown:Qg,json:Gte,image:nMe,pdf:qh,widget:W5,mcp_app:ZM,file:Jte,model3d:mAe,csv:nDe,browser:ha};function ovt({documents:e,activeDocumentId:t,onActivate:n,onClose:s}){return e.length===0?null:a.jsx("div",{role:"tablist","aria-label":"Open canvas documents",className:"flex items-stretch gap-1 overflow-x-auto border-b px-2 py-1",children:e.map(r=>{const i=avt[r.contentType],o=r.id===t;return a.jsxs("div",{role:"tab","aria-selected":o,className:Y("group flex shrink-0 items-center gap-1.5 rounded-md py-1 pr-1 pl-2 text-xs transition-colors",o?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/60 hover:text-foreground"),children:[a.jsxs("button",{type:"button",onClick:()=>n(r.id),className:"focus-ring flex items-center gap-1.5 rounded-sm",children:[a.jsx(i,{className:"size-3.5 shrink-0"}),a.jsx("span",{className:"max-w-40 truncate font-medium",children:r.sourceLabel})]}),a.jsx("button",{type:"button",onClick:()=>s(r.id),"aria-label":`Close ${r.sourceLabel}`,className:"focus-ring hover:bg-background/80 rounded-sm p-0.5 opacity-60 transition-opacity group-hover:opacity-100",children:a.jsx(es,{className:"size-3"})})]},r.id)})})}const lvt="allow-scripts allow-forms allow-popups allow-modals",cvt="allow-scripts allow-same-origin allow-popups allow-forms allow-modals allow-downloads",uvt=new Set(["javascript:","data:","blob:"]),dvt=new Set(["localhost","127.0.0.1","0.0.0.0","[::1]","::1"]);function tfe(e){return dvt.has(e)||e.endsWith(".localhost")}function fvt(e){return e==="https:"?443:80}function nfe(e){let t;try{t=new URL(e)}catch{return{mode:"serve",path:e}}return uvt.has(t.protocol)?{mode:"blocked"}:t.protocol==="file:"?{mode:"serve",path:decodeURIComponent(t.pathname)}:t.protocol==="http:"||t.protocol==="https:"?tfe(t.hostname)?{mode:"proxy",port:t.port?Number(t.port):fvt(t.protocol),path:`${t.pathname}${t.search}`}:{mode:"external",url:e}:{mode:"blocked"}}function hvt(e){const t=e.trim();if(t===""||/^[a-z][a-z0-9+.-]*:\/\//i.test(t)||t.startsWith("/")||t.startsWith("./")||t.startsWith("../"))return t;const n=t.split("/")[0];if(t.includes("/")&&!n.includes(".")&&!n.includes(":"))return t;const r=n.split(":")[0];return`${tfe(r)?"http":"https"}://${t}`}function mvt(e){const t=nfe(e);if(t.mode==="serve")return{kind:"local",path:t.path};if(t.mode==="blocked")return{kind:"raw",text:e};try{const n=new URL(e),s=n.host.replace(/^www\./,""),r=n.pathname==="/"&&n.search===""&&n.hash===""?"":`${n.pathname}${n.search}${n.hash}`;return{kind:"url",host:s,rest:r}}catch{return{kind:"raw",text:e}}}function pvt({content:e}){const t=je(),n=we(E=>E.selectedCwd),[s,r]=x.useState([e.url]),[i,o]=x.useState(0),[l,c]=x.useState(0),u=s[i],d=x.useMemo(()=>nfe(u),[u]),[f,m]=x.useState(null),[g,y]=x.useState(null);x.useEffect(()=>{let E=!1;async function j(){if(y(null),m(null),d.mode!=="blocked"){if(d.mode==="external"){m(d.url);return}if(d.mode==="serve"&&n===null){y("no-session");return}try{let _;if(d.mode==="proxy"){const N=await t.createProxyUrl(d.port),R=d.path.replace(/^\//,"");_=N&&R?N+R:N}else _=await t.createServeUrl(n,d.path);if(E)return;_===null?y("unsupported"):m(_)}catch{E||y("failed")}}}return j(),()=>{E=!0}},[d,n,t,l]);const b=x.useCallback(E=>{r(j=>[...j.slice(0,i+1),E]),o(j=>j+1)},[i]),S=i>0,w=i<s.length-1,C=x.useCallback(E=>{const j=hvt(E);j&&j!==u?b(j):c(_=>_+1)},[u,b]),T=()=>window.open(u,"_blank","noopener,noreferrer");return a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsxs("div",{className:"border-border/60 flex h-9 items-center gap-1 border-b px-2",children:[a.jsx(Sw,{label:"Back",disabled:!S,onClick:()=>o(E=>E-1),children:a.jsx(ov,{className:"size-4"})}),a.jsx(Sw,{label:"Forward",disabled:!w,onClick:()=>o(E=>E+1),children:a.jsx(uh,{className:"size-4"})}),a.jsx(Sw,{label:"Reload",onClick:()=>c(E=>E+1),children:a.jsx(k3e,{className:"size-4"})}),a.jsx(gvt,{url:u,onSubmit:C}),a.jsx(Sw,{label:"Open in system browser",onClick:T,children:a.jsx(fa,{className:"size-4"})})]}),a.jsx(vvt,{target:d,resolvedSrc:f,resolveError:g,reloadNonce:l,title:e.title??"Embedded browser",onOpenExternally:T})]})}function gvt({url:e,onSubmit:t}){const[n,s]=x.useState(!1),[r,i]=x.useState(e);if(!n)return a.jsx(yvt,{url:e,onActivate:()=>{i(e),s(!0)}});const o=l=>{l.preventDefault(),s(!1),t(r)};return a.jsx("form",{onSubmit:o,className:"min-w-0 flex-1",children:a.jsx(sn,{"aria-label":"Address",autoFocus:!0,value:r,onChange:l=>i(l.target.value),onFocus:l=>l.currentTarget.select(),onBlur:()=>s(!1),onKeyDown:l=>{l.key==="Escape"&&(l.preventDefault(),s(!1))},spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",className:"h-7 w-full text-sm"})})}function xvt(e){return e.kind==="local"?e.path:e.kind==="url"?`${e.host}${e.rest}`:e.text}function yvt({url:e,onActivate:t}){const n=x.useMemo(()=>mvt(e),[e]);return a.jsxs("button",{type:"button","aria-label":`Address: ${xvt(n)}`,onClick:t,className:"text-muted-foreground hover:bg-muted focus-ring flex h-7 min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 text-left text-sm transition-colors",children:[n.kind==="local"&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"bg-muted-foreground/15 rounded px-1 py-0.5 text-[10px] font-medium tracking-wide uppercase",children:"local"}),a.jsx("span",{className:"text-foreground truncate",children:n.path})]}),n.kind==="url"&&a.jsxs("span",{className:"truncate",children:[a.jsx("span",{className:"text-foreground",children:n.host}),a.jsx("span",{className:"text-muted-foreground",children:n.rest})]}),n.kind==="raw"&&a.jsx("span",{className:"truncate",children:n.text})]})}function vvt({target:e,resolvedSrc:t,resolveError:n,reloadNonce:s,title:r,onOpenExternally:i}){if(e.mode==="blocked")return a.jsx(ty,{children:"This address can’t be displayed for security reasons."});if(n==="no-session")return a.jsx(ty,{children:"Open a session to preview local files."});if(n==="unsupported")return a.jsx(ty,{children:"Local previews aren’t available in this environment."});if(n==="failed")return a.jsx(ty,{children:"This preview couldn’t be loaded."});if(t===null)return a.jsx(ty,{children:"Loading…"});const o=e.mode==="external",l=o?cvt:lvt;return a.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[a.jsx("iframe",{src:t,sandbox:l,className:"min-h-0 w-full flex-1 border-0",title:r},`${t}:${s}`),o&&a.jsxs("div",{className:"text-muted-foreground border-border/60 flex items-center justify-between gap-2 border-t px-3 py-1.5 text-xs",children:[a.jsx("span",{children:"This site can’t always be embedded here."}),a.jsx("button",{type:"button",onClick:i,className:"text-foreground hover:underline",children:"Open in system browser"})]})]})}function Sw({label:e,disabled:t,onClick:n,children:s}){return a.jsx("button",{type:"button","aria-label":e,disabled:t,onClick:n,className:Y("text-muted-foreground hover:text-foreground hover:bg-muted focus-ring rounded-md p-1.5 transition-colors",t&&"pointer-events-none opacity-40"),children:s})}function ty({children:e}){return a.jsx("div",{className:"text-muted-foreground flex min-h-0 flex-1 flex-col items-center justify-center p-8 text-center",children:e})}function bvt({sourcePath:e,cwd:t,loadedContent:n}){const s=je(),[r,i]=x.useState("idle"),[o,l]=x.useState(null),c=x.useRef(null),u=x.useRef(n),d=x.useRef(Promise.resolve()),f=!!(e&&t),m=x.useCallback(async(w,C)=>{const T=await s.writeFile(t,e,w,C);return T.ok?(c.current=T.hash,u.current=w,l(null),i("saved"),"saved"):(l(T.conflict),i("conflict"),"conflict")},[s,t,e]),g=x.useCallback(w=>{if(!f)return Promise.resolve("idle");const C=d.current.catch(()=>{}).then(async()=>{if(w===u.current)return i("saved"),"saved";i("saving");try{const T=c.current!==null?{expectedHash:c.current}:{expectedContent:u.current};return await m(w,T)}catch{return i("error"),"error"}});return d.current=C.then(()=>{}),C},[f,m]),y=x.useCallback(w=>{if(!o)return Promise.resolve();const C=o.currentHash,T=d.current.catch(()=>{}).then(async()=>{i("saving");try{await m(w,{expectedHash:C})}catch{i("error")}});return d.current=T,T},[o,m]),b=x.useCallback(()=>({hash:c.current,content:u.current}),[]),S=x.useCallback(()=>{if(!o)return null;const w=o.currentContent;return c.current=o.currentHash,u.current=w,l(null),i("idle"),w},[o]);return{status:r,conflict:o,canSave:f,save:g,overwrite:y,adoptDisk:S,getConfirmedBase:b}}const NG=x.lazy(()=>ks(()=>import("./BlintzCanvas-YWLFAfxE.js"),__vite__mapDeps([0,1,2])).then(e=>({default:e.BlintzCanvas}))),Svt=500;function wvt(e){switch(e){case"saving":return"Saving…";case"saved":return"Saved";case"error":return"Couldn't save";default:return null}}function kvt({content:e,documentId:t,onContentChange:n}){const[s,r]=x.useState(!1),[i,o]=x.useState(e.content),l=we(O=>O.canvasSessionId),c=we(O=>O.setDocumentEditing),u=we(O=>O.selectedCwd),d=bvt({sourcePath:e.sourcePath,cwd:u,loadedContent:e.content}),f=d.canSave,m=x.useRef(null),g=x.useRef(null),y=x.useRef(i),b=x.useRef(e),S=x.useRef(n),w=x.useRef(d.save);x.useEffect(()=>{y.current=i,b.current=e,S.current=n,w.current=d.save});const C=x.useCallback(O=>{we.getState().canvasSessionId===m.current&&(S.current({...b.current,content:O}),w.current(O))},[]),T=x.useCallback(O=>{o(O),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,C(O)},Svt)},[C]),E=()=>{m.current=we.getState().canvasSessionId,o(e.content),r(!0),c(t,!0)},j=()=>{g.current&&(clearTimeout(g.current),g.current=null,C(y.current)),r(!1),c(t,!1)};x.useEffect(()=>{s&&l!==m.current&&(g.current&&(clearTimeout(g.current),g.current=null),r(!1),c(t,!1))},[l,s,t,c]),x.useEffect(()=>()=>{g.current&&(clearTimeout(g.current),g.current=null,C(y.current)),c(t,!1)},[C,t,c]);const _=()=>{const O=d.adoptDisk();O!=null&&(n({...e,content:O}),o(O))},N=()=>{d.overwrite(y.current)},R=wvt(d.status);return a.jsxs("div",{className:"relative flex h-full flex-col",children:[a.jsxs("div",{className:"sticky top-0 z-10 flex h-0 items-start justify-end gap-2 pr-2",children:[f&&R&&a.jsx("span",{className:"text-muted-foreground mt-3 text-xs","aria-live":"polite",children:R}),f&&a.jsx(ge,{type:"button",variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-foreground mt-2",onClick:s?j:E,"aria-label":s?"Finish editing":"Edit document",children:s?a.jsx(Lt,{className:"size-4"}):a.jsx(KE,{className:"size-4"})})]}),d.status==="conflict"&&a.jsxs("div",{className:"bg-destructive/10 text-destructive mx-2 mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 rounded-md px-3 py-2 text-sm",children:[a.jsx("span",{className:"flex-1",children:"This file changed on disk since you opened it."}),a.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-7",onClick:_,children:"Reload"}),a.jsx(ge,{type:"button",variant:"destructive",size:"sm",className:"h-7",onClick:N,children:"Overwrite"})]}),a.jsx("div",{className:"flex-1 px-2 pb-6",children:a.jsx(x.Suspense,{fallback:a.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading editor…"}),children:s?a.jsx(NG,{value:i,editable:!0,onChange:T},"edit"):a.jsx(NG,{value:e.content,editable:!1},"view")})})]})}function Cvt({content:e}){return a.jsx("div",{className:"p-4 font-mono text-sm",children:a.jsx(sfe,{value:e.data,depth:0})})}const Evt=20;function sfe({value:e,depth:t,keyName:n}){const[s,r]=x.useState(t>2),i=x.useCallback(()=>r(d=>!d),[]);if(t>=Evt)return a.jsx(ny,{keyName:n,value:"[max depth]",className:"text-muted-foreground"});if(e===null)return a.jsx(ny,{keyName:n,value:"null",className:"text-muted-foreground"});if(typeof e=="boolean")return a.jsx(ny,{keyName:n,value:String(e),className:"text-blue-500"});if(typeof e=="number")return a.jsx(ny,{keyName:n,value:String(e),className:"text-green-500"});if(typeof e=="string")return a.jsx(ny,{keyName:n,value:`"${e}"`,className:"text-amber-500"});const o=Array.isArray(e),l=o?e.map((d,f)=>[String(f),d]):Object.entries(e),c=o?"[":"{",u=o?"]":"}";return a.jsxs("div",{style:{paddingLeft:t>0?16:0},children:[a.jsxs("button",{type:"button",className:"hover:bg-muted -ml-0.5 inline-flex items-center gap-0.5 rounded px-0.5",onClick:i,children:[a.jsx(Rs,{className:Y("size-3 transition-transform",!s&&"rotate-90")}),n!=null&&a.jsxs("span",{className:"text-foreground",children:[n,": "]}),a.jsxs("span",{className:"text-muted-foreground",children:[c,s&&` ... ${l.length} items `,s&&u]})]}),!s&&a.jsxs(a.Fragment,{children:[l.map(([d,f])=>a.jsx(sfe,{keyName:o?void 0:d,value:f,depth:t+1},d)),a.jsx("div",{className:"text-muted-foreground",children:u})]})]})}function ny({keyName:e,value:t,className:n}){return a.jsxs("div",{style:{paddingLeft:16},children:[e!=null&&a.jsxs("span",{className:"text-foreground",children:[e,": "]}),a.jsx("span",{className:n,children:t})]})}var $a=function(e,t){return Number(e.toFixed(t))},Tvt=function(e,t){return t},ys=function(e,t,n){n&&typeof n=="function"&&n(e,t)},_vt=function(e){return-Math.cos(e*Math.PI)/2+.5},Nvt=function(e){return e},jvt=function(e){return e*e},Avt=function(e){return e*(2-e)},Rvt=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Mvt=function(e){return e*e*e},Dvt=function(e){return--e*e*e+1},Ovt=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},Ivt=function(e){return e*e*e*e},Pvt=function(e){return 1- --e*e*e*e},Lvt=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Fvt=function(e){return e*e*e*e*e},zvt=function(e){return 1+--e*e*e*e*e},Bvt=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},rfe={easeOut:_vt,linear:Nvt,easeInQuad:jvt,easeOutQuad:Avt,easeInOutQuad:Rvt,easeInCubic:Mvt,easeOutCubic:Dvt,easeInOutCubic:Ovt,easeInQuart:Ivt,easeOutQuart:Pvt,easeInOutQuart:Lvt,easeInQuint:Fvt,easeOutQuint:zvt,easeInOutQuint:Bvt},ife=function(e){typeof e=="number"&&cancelAnimationFrame(e)},lo=function(e){e.mounted&&(ife(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function afe(e,t,n,s){if(e.mounted){var r=new Date().getTime(),i=1;lo(e),e.animation=function(){if(!e.mounted)return ife(e.animation);var o=new Date().getTime()-r,l=o/n,c=rfe[t],u=c(l);o>=n?(s(i),e.animation=null):e.animation&&(s(u),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function $vt(e){var t=e.scale,n=e.positionX,s=e.positionY;return!(Number.isNaN(t)||Number.isNaN(n)||Number.isNaN(s))}function Kd(e,t,n,s){var r=$vt(t);if(!(!e.mounted||!r)){var i=e.setTransformState,o=e.transformState,l=o.scale,c=o.positionX,u=o.positionY,d=t.scale-l,f=t.positionX-c,m=t.positionY-u;n===0?i(t.scale,t.positionX,t.positionY):afe(e,s,n,function(g){var y=l+d*g,b=c+f*g,S=u+m*g;i(y,b,S)})}}function Hvt(e,t,n){var s=e.offsetWidth,r=e.offsetHeight,i=t.offsetWidth,o=t.offsetHeight,l=i*n,c=o*n,u=s-l,d=r-c;return{wrapperWidth:s,wrapperHeight:r,newContentWidth:l,newDiffWidth:u,newContentHeight:c,newDiffHeight:d}}var Uvt=function(e,t,n,s,r,i,o){var l=e>t?n*(o?1:.5):0,c=s>r?i*(o?1:.5):0,u=e-t-l,d=l,f=s-r-c,m=c;return{minPositionX:u,maxPositionX:d,minPositionY:f,maxPositionY:m}},YP=function(e,t){var n=e.wrapperComponent,s=e.contentComponent,r=e.setup.centerZoomedOut;if(!n||!s)throw new Error("Components are not mounted");var i=Hvt(n,s,t),o=i.wrapperWidth,l=i.wrapperHeight,c=i.newContentWidth,u=i.newDiffWidth,d=i.newContentHeight,f=i.newDiffHeight,m=Uvt(o,c,u,l,d,f,!!r);return m},rO=function(e,t,n,s){return s?e<t?$a(t,2):e>n?$a(n,2):$a(e,2):$a(e,2)},ah=function(e,t){var n=YP(e,t);return e.bounds=n,n};function Qb(e,t,n,s,r,i,o){var l=n.minPositionX,c=n.minPositionY,u=n.maxPositionX,d=n.maxPositionY,f=0,m=0;o&&(f=r,m=i);var g=rO(e,l-f,u+f,s),y=rO(t,c-m,d+m,s);return{x:g,y}}function x_(e,t,n,s,r,i){var o=e.transformState,l=o.scale,c=o.positionX,u=o.positionY,d=s-l;if(typeof t!="number"||typeof n!="number")return console.error("Mouse X and Y position were not provided!"),{x:c,y:u};var f=c-t*d,m=u-n*d,g=Qb(f,m,r,i,0,0,null);return g}function Jb(e,t,n,s,r){var i=r?s:0,o=t-i;return!Number.isNaN(n)&&e>=n?n:!Number.isNaN(t)&&e<=o?o:e}var jG=function(e,t){var n=e.setup.panning.excluded,s=e.isInitialized,r=e.wrapperComponent,i=t.target,o="shadowRoot"in i&&"composedPath"in t,l=o?t.composedPath().some(function(d){return d instanceof Element?r==null?void 0:r.contains(d):!1}):r==null?void 0:r.contains(i),c=s&&i&&l;if(!c)return!1;var u=y_(i,n);return!u},AG=function(e){var t=e.isInitialized,n=e.isPanning,s=e.setup,r=s.panning.disabled,i=t&&n&&!r;return!!i},Vvt=function(e,t){var n=e.transformState,s=n.positionX,r=n.positionY;e.isPanning=!0;var i=t.clientX,o=t.clientY;e.startCoords={x:i-s,y:o-r}},qvt=function(e,t){var n=t.touches,s=e.transformState,r=s.positionX,i=s.positionY;e.isPanning=!0;var o=n.length===1;if(o){var l=n[0].clientX,c=n[0].clientY;e.startCoords={x:l-r,y:c-i}}};function Gvt(e){var t=e.transformState,n=t.positionX,s=t.positionY,r=t.scale,i=e.setup,o=i.disabled,l=i.limitToBounds,c=i.centerZoomedOut,u=e.wrapperComponent;if(!(o||!u||!e.bounds)){var d=e.bounds,f=d.maxPositionX,m=d.minPositionX,g=d.maxPositionY,y=d.minPositionY,b=n>f||n<m,S=s>g||s<y,w=n>f?u.offsetWidth:e.setup.minPositionX||0,C=s>g?u.offsetHeight:e.setup.minPositionY||0,T=x_(e,w,C,r,e.bounds,l||c),E=T.x,j=T.y;return{scale:r,positionX:b?E:n,positionY:S?j:s}}}function ofe(e,t,n,s,r){var i=e.setup.limitToBounds,o=e.wrapperComponent,l=e.bounds,c=e.transformState,u=c.scale,d=c.positionX,f=c.positionY;if(!(o===null||l===null||t===d&&n===f)){var m=Qb(t,n,l,i,s,r,o),g=m.x,y=m.y;e.setTransformState(u,g,y)}}var Kvt=function(e,t,n){var s=e.startCoords,r=e.transformState,i=e.setup.panning,o=i.lockAxisX,l=i.lockAxisY,c=r.positionX,u=r.positionY;if(!s)return{x:c,y:u};var d=t-s.x,f=n-s.y,m=o?c:d,g=l?u:f;return{x:m,y:g}},Sd=function(e,t){var n=e.setup,s=e.transformState,r=s.scale,i=n.minScale,o=n.disablePadding;return t>0&&r>=i&&!o?t:0},Wvt=function(e){var t=e.mounted,n=e.setup,s=n.disabled,r=n.velocityAnimation,i=e.transformState.scale,o=r.disabled,l=!o||i>1||!s||t;return!!l},Yvt=function(e){var t=e.mounted,n=e.velocity,s=e.bounds,r=e.setup,i=r.disabled,o=r.velocityAnimation,l=e.transformState.scale,c=o.disabled,u=!c||l>1||!i||t;return!(!u||!n||!s)};function Zvt(e,t){var n=e.setup.velocityAnimation,s=n.equalToMove,r=n.animationTime,i=n.sensitivity;return s?r*t*i:r}function RG(e,t,n,s,r,i,o,l,c,u){if(r){if(t>o&&n>o){var d=o+(e-o)*u;return d>c?c:d<o?o:d}if(t<i&&n<i){var d=i+(e-i)*u;return d<l?l:d>i?i:d}}return s?t:rO(e,i,o,r)}function Xvt(e,t){var n=1;return t?Math.min(n,e.offsetWidth/window.innerWidth):n}function Qvt(e,t){var n=Wvt(e);if(n){var s=e.lastMousePosition,r=e.velocityTime,i=e.setup,o=e.wrapperComponent,l=i.velocityAnimation.equalToMove,c=Date.now();if(s&&r&&o){var u=Xvt(o,l),d=t.x-s.x,f=t.y-s.y,m=d/u,g=f/u,y=c-r,b=d*d+f*f,S=Math.sqrt(b)/y;e.velocity={velocityX:m,velocityY:g,total:S}}e.lastMousePosition=t,e.velocityTime=c}}function Jvt(e){var t=e.velocity,n=e.bounds,s=e.setup,r=e.wrapperComponent,i=Yvt(e);if(!(!i||!t||!n||!r)){var o=t.velocityX,l=t.velocityY,c=t.total,u=n.maxPositionX,d=n.minPositionX,f=n.maxPositionY,m=n.minPositionY,g=s.limitToBounds,y=s.alignmentAnimation,b=s.zoomAnimation,S=s.panning,w=S.lockAxisY,C=S.lockAxisX,T=b.animationType,E=y.sizeX,j=y.sizeY,_=y.velocityAlignmentTime,N=_,R=Zvt(e,c),O=Math.max(R,N),M=Sd(e,E),L=Sd(e,j),P=M*r.offsetWidth/100,$=L*r.offsetHeight/100,q=u+P,K=d-P,B=f+$,V=m-$,Q=e.transformState,re=new Date().getTime();afe(e,T,O,function(U){var G=e.transformState,W=G.scale,F=G.positionX,X=G.positionY,J=new Date().getTime()-re,ae=J/N,oe=rfe[y.animationType],de=1-oe(Math.min(1,ae)),me=1-U,Re=F+o*me,Fe=X+l*me,Le=RG(Re,Q.positionX,F,C,g,d,u,K,q,de),Xe=RG(Fe,Q.positionY,X,w,g,m,f,V,B,de);(F!==Re||X!==Fe)&&e.setTransformState(W,Le,Xe)})}}function MG(e,t){var n=e.transformState.scale;lo(e),ah(e,n),window.TouchEvent!==void 0&&t instanceof TouchEvent?qvt(e,t):Vvt(e,t)}function ZP(e,t){var n=e.transformState.scale,s=e.setup,r=s.minScale,i=s.alignmentAnimation,o=i.disabled,l=i.sizeX,c=i.sizeY,u=i.animationTime,d=i.animationType,f=o||n<r||!l&&!c;if(!f){var m=Gvt(e);m&&Kd(e,m,t??u,d)}}function DG(e,t,n){var s=e.startCoords,r=e.setup,i=r.alignmentAnimation,o=i.sizeX,l=i.sizeY;if(s){var c=Kvt(e,t,n),u=c.x,d=c.y,f=Sd(e,o),m=Sd(e,l);Qvt(e,{x:u,y:d}),ofe(e,u,d,f,m)}}function ebt(e){if(e.isPanning){var t=e.setup.panning.velocityDisabled,n=e.velocity,s=e.wrapperComponent,r=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var i=s==null?void 0:s.getBoundingClientRect(),o=r==null?void 0:r.getBoundingClientRect(),l=(i==null?void 0:i.width)||0,c=(i==null?void 0:i.height)||0,u=(o==null?void 0:o.width)||0,d=(o==null?void 0:o.height)||0,f=l<u||c<d,m=!t&&n&&(n==null?void 0:n.total)>.1&&f;m?Jvt(e):ZP(e)}}function XP(e,t,n,s){var r=e.setup,i=r.minScale,o=r.maxScale,l=r.limitToBounds,c=Jb($a(t,2),i,o,0,!1),u=ah(e,c),d=x_(e,n,s,c,u,l),f=d.x,m=d.y;return{scale:c,positionX:f,positionY:m}}function lfe(e,t,n){var s=e.transformState.scale,r=e.wrapperComponent,i=e.setup,o=i.minScale,l=i.limitToBounds,c=i.zoomAnimation,u=c.disabled,d=c.animationTime,f=c.animationType,m=u||s>=o;if((s>=1||l)&&ZP(e),!(m||!r||!e.mounted)){var g=t||r.offsetWidth/2,y=n||r.offsetHeight/2,b=XP(e,o,g,y);b&&Kd(e,b,d,f)}}var id=function(){return id=Object.assign||function(t){for(var n,s=1,r=arguments.length;s<r;s++){n=arguments[s];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},id.apply(this,arguments)};function OG(e,t,n){for(var s=0,r=t.length,i;s<r;s++)(i||!(s in t))&&(i||(i=Array.prototype.slice.call(t,0,s)),i[s]=t[s]);return e.concat(i||Array.prototype.slice.call(t))}var ww={scale:1,positionX:0,positionY:0},sy={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,disablePadding:!1,smooth:!0,wheel:{step:.2,disabled:!1,smoothStep:.001,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,allowLeftClickPan:!0,allowMiddleClickPan:!0,allowRightClickPan:!0,wheelPanning:!1,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},alignmentAnimation:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivity:1,animationTime:400,animationType:"easeOut",equalToMove:!0}},iO={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},cfe=function(e){var t,n,s,r;return{previousScale:(t=e.initialScale)!==null&&t!==void 0?t:ww.scale,scale:(n=e.initialScale)!==null&&n!==void 0?n:ww.scale,positionX:(s=e.initialPositionX)!==null&&s!==void 0?s:ww.positionX,positionY:(r=e.initialPositionY)!==null&&r!==void 0?r:ww.positionY}},IG=function(e){var t=id({},sy);return Object.keys(e).forEach(function(n){var s=typeof e[n]<"u",r=typeof sy[n]<"u";if(r&&s){var i=Object.prototype.toString.call(sy[n]),o=i==="[object Object]",l=i==="[object Array]";o?t[n]=id(id({},sy[n]),e[n]):l?t[n]=OG(OG([],sy[n],!0),e[n]):t[n]=e[n]}}),t},ufe=function(e,t,n){var s=e.transformState.scale,r=e.wrapperComponent,i=e.setup,o=i.maxScale,l=i.minScale,c=i.zoomAnimation,u=i.smooth,d=c.size;if(!r)throw new Error("Wrapper is not mounted");var f=u?s*Math.exp(t*n):s+t*n,m=Jb($a(f,3),l,o,d,!1);return m};function dfe(e,t,n,s,r){var i=e.wrapperComponent,o=e.transformState,l=o.scale,c=o.positionX,u=o.positionY;if(!i)return console.error("No WrapperComponent found");var d=i.offsetWidth,f=i.offsetHeight,m=(d/2-c)/l,g=(f/2-u)/l,y=ufe(e,t,n),b=XP(e,y,m,g);if(!b)return console.error("Error during zoom event. New transformation state was not calculated.");Kd(e,b,s,r)}function ffe(e,t,n,s){var r=e.setup,i=e.wrapperComponent,o=r.limitToBounds,l=cfe(e.props),c=e.transformState,u=c.scale,d=c.positionX,f=c.positionY;if(i){var m=YP(e,l.scale),g=Qb(l.positionX,l.positionY,m,o,0,0,i),y={scale:l.scale,positionX:g.x,positionY:g.y};u===l.scale&&d===l.positionX&&f===l.positionY||(s==null||s(),Kd(e,y,t,n))}}function tbt(e,t,n,s){var r=e.getBoundingClientRect(),i=t.getBoundingClientRect(),o=n.getBoundingClientRect(),l=i.x*s.scale,c=i.y*s.scale;return{x:(r.x-o.x+l)/s.scale,y:(r.y-o.y+c)/s.scale}}function nbt(e,t,n){var s=e.wrapperComponent,r=e.contentComponent,i=e.transformState,o=e.setup,l=o.limitToBounds,c=o.minScale,u=o.maxScale;if(!s||!r)return i;var d=s.getBoundingClientRect(),f=t.getBoundingClientRect(),m=tbt(t,s,r,i),g=m.x,y=m.y,b=f.width/i.scale,S=f.height/i.scale,w=s.offsetWidth/b,C=s.offsetHeight/S,T=Jb(n||Math.min(w,C),c,u,0,!1),E=(d.width-b*T)/2,j=(d.height-S*T)/2,_=(d.left-g)*T+E,N=(d.top-y)*T+j,R=YP(e,T),O=Qb(_,N,R,l,0,0,s),M=O.x,L=O.y;return{positionX:M,positionY:L,scale:T}}var sbt=function(e){return function(t,n,s){t===void 0&&(t=.5),n===void 0&&(n=300),s===void 0&&(s="easeOut"),dfe(e,1,t,n,s)}},rbt=function(e){return function(t,n,s){t===void 0&&(t=.5),n===void 0&&(n=300),s===void 0&&(s="easeOut"),dfe(e,-1,t,n,s)}},ibt=function(e){return function(t,n,s,r,i){r===void 0&&(r=300),i===void 0&&(i="easeOut");var o=e.transformState,l=o.positionX,c=o.positionY,u=o.scale,d=e.wrapperComponent,f=e.contentComponent,m=e.setup.disabled;if(!(m||!d||!f)){var g={positionX:Number.isNaN(t)?l:t,positionY:Number.isNaN(n)?c:n,scale:Number.isNaN(s)?u:s};Kd(e,g,r,i)}}},abt=function(e){return function(t,n){t===void 0&&(t=200),n===void 0&&(n="easeOut"),ffe(e,t,n)}},obt=function(e){return function(t,n,s){n===void 0&&(n=200),s===void 0&&(s="easeOut");var r=e.transformState,i=e.wrapperComponent,o=e.contentComponent;if(i&&o){var l=hfe(t||r.scale,i,o);Kd(e,l,n,s)}}},lbt=function(e){return function(t,n,s,r){s===void 0&&(s=600),r===void 0&&(r="easeOut"),lo(e);var i=e.wrapperComponent,o=typeof t=="string"?document.getElementById(t):t;if(i&&o&&i.contains(o)){var l=nbt(e,o,n);Kd(e,l,s,r)}}},GC=function(e){return{instance:e,zoomIn:sbt(e),zoomOut:rbt(e),setTransform:ibt(e),resetTransform:abt(e),centerView:obt(e),zoomToElement:lbt(e)}},cbt=function(e){return{instance:e,state:e.transformState}},ls=function(e){var t={};return Object.assign(t,cbt(e)),Object.assign(t,GC(e)),t},RR=!1;function MR(){try{var e={get passive(){return RR=!0,!1}};return e}catch{return RR=!1,RR}}var kw=".".concat(iO.wrapperClass),y_=function(e,t){return t.some(function(n){return e.matches("".concat(kw," ").concat(n,", ").concat(kw," .").concat(n,", ").concat(kw," ").concat(n," *, ").concat(kw," .").concat(n," *"))})},aO=function(e){e&&clearTimeout(e)},ubt=function(e,t,n){return"translate(".concat(e,"px, ").concat(t,"px) scale(").concat(n,")")},hfe=function(e,t,n){var s=n.offsetWidth*e,r=n.offsetHeight*e,i=(t.offsetWidth-s)/2,o=(t.offsetHeight-r)/2;return{scale:e,positionX:i,positionY:o}};function dbt(e){return function(t){e.forEach(function(n){typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var fbt=function(e,t){var n=e.setup.wheel,s=n.disabled,r=n.wheelDisabled,i=n.touchPadDisabled,o=n.excluded,l=e.isInitialized,c=e.isPanning,u=t.target,d=l&&!c&&!s&&u;if(!d||r&&!t.ctrlKey||i&&t.ctrlKey)return!1;var f=y_(u,o);return!f},hbt=function(e){return e?e.deltaY<0?1:-1:0};function mbt(e,t){var n=hbt(e),s=Tvt(t,n);return s}function mfe(e,t,n){var s=t.getBoundingClientRect(),r=0,i=0;if("clientX"in e)r=(e.clientX-s.left)/n,i=(e.clientY-s.top)/n;else{var o=e.touches[0];r=(o.clientX-s.left)/n,i=(o.clientY-s.top)/n}return(Number.isNaN(r)||Number.isNaN(i))&&console.error("No mouse or touch offset found"),{x:r,y:i}}var pbt=function(e,t,n,s,r){var i=e.transformState.scale,o=e.wrapperComponent,l=e.setup,c=l.maxScale,u=l.minScale,d=l.zoomAnimation,f=l.disablePadding,m=d.size,g=d.disabled;if(!o)throw new Error("Wrapper is not mounted");var y=i+t*n,b=s?!1:!g,S=Jb($a(y,3),u,c,m,b&&!f);return S},gbt=function(e,t){var n=e.previousWheelEvent,s=e.transformState.scale,r=e.setup,i=r.maxScale,o=r.minScale;return n?s<i||s>o||Math.sign(n.deltaY)!==Math.sign(t.deltaY)||n.deltaY>0&&n.deltaY<t.deltaY||n.deltaY<0&&n.deltaY>t.deltaY||Math.sign(n.deltaY)!==Math.sign(t.deltaY):!1},xbt=function(e,t){var n=e.setup.pinch,s=n.disabled,r=n.excluded,i=e.isInitialized,o=t.target,l=i&&!s&&o;if(!l)return!1;var c=y_(o,r);return!c},ybt=function(e){var t=e.setup.pinch.disabled,n=e.isInitialized,s=e.pinchStartDistance,r=n&&!t&&s;return!!r},vbt=function(e,t,n){var s=n.getBoundingClientRect(),r=e.touches,i=$a(r[0].clientX-s.left,5),o=$a(r[0].clientY-s.top,5),l=$a(r[1].clientX-s.left,5),c=$a(r[1].clientY-s.top,5);return{x:(i+l)/2/t,y:(o+c)/2/t}},pfe=function(e){return Math.sqrt(Math.pow(e.touches[0].pageX-e.touches[1].pageX,2)+Math.pow(e.touches[0].pageY-e.touches[1].pageY,2))},bbt=function(e,t){var n=e.pinchStartScale,s=e.pinchStartDistance,r=e.setup,i=r.maxScale,o=r.minScale,l=r.zoomAnimation,c=r.disablePadding,u=l.size,d=l.disabled;if(!n||s===null||!t)throw new Error("Pinch touches distance was not provided");if(t<0)return e.transformState.scale;var f=t/s,m=f*n;return Jb($a(m,2),o,i,u,!d&&!c)},Sbt=160,wbt=100,kbt=function(e,t){var n=e.props,s=n.onWheelStart,r=n.onZoomStart;e.wheelStopEventTimer||(lo(e),ys(ls(e),t,s),ys(ls(e),t,r))},Cbt=function(e,t){var n=e.props,s=n.onWheel,r=n.onZoom,i=e.contentComponent,o=e.setup,l=e.transformState,c=l.scale,u=o.limitToBounds,d=o.centerZoomedOut,f=o.zoomAnimation,m=o.wheel,g=o.disablePadding,y=o.smooth,b=f.size,S=f.disabled,w=m.step,C=m.smoothStep;if(!i)throw new Error("Component not mounted");t.preventDefault(),t.stopPropagation();var T=mbt(t,null),E=y?C*Math.abs(t.deltaY):w,j=pbt(e,T,E,!t.ctrlKey);if(c!==j){var _=ah(e,j),N=mfe(t,i,c),R=S||b===0||d||g,O=u&&R,M=x_(e,N.x,N.y,j,_,O),L=M.x,P=M.y;e.previousWheelEvent=t,e.setTransformState(j,L,P),ys(ls(e),t,s),ys(ls(e),t,r)}},Ebt=function(e,t){var n=e.props,s=n.onWheelStop,r=n.onZoomStop;aO(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(lfe(e,t.x,t.y),e.wheelAnimationTimer=null)},wbt);var i=gbt(e,t);i&&(aO(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,ys(ls(e),t,s),ys(ls(e),t,r))},Sbt))},gfe=function(e){for(var t=0,n=0,s=0;s<2;s+=1)t+=e.touches[s].clientX,n+=e.touches[s].clientY;var r=t/2,i=n/2;return{x:r,y:i}},Tbt=function(e,t){var n=pfe(t);e.pinchStartDistance=n,e.lastDistance=n,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var s=gfe(t);e.pinchLastCenterX=s.x,e.pinchLastCenterY=s.y,lo(e)},_bt=function(e,t){var n=e.contentComponent,s=e.pinchStartDistance,r=e.wrapperComponent,i=e.transformState.scale,o=e.setup,l=o.limitToBounds,c=o.centerZoomedOut,u=o.zoomAnimation,d=o.alignmentAnimation,f=u.disabled,m=u.size;if(!(s===null||!n)){var g=vbt(t,i,n);if(!(!Number.isFinite(g.x)||!Number.isFinite(g.y))){var y=pfe(t),b=bbt(e,y),S=gfe(t),w=S.x-(e.pinchLastCenterX||0),C=S.y-(e.pinchLastCenterY||0);if(!(b===i&&w===0&&C===0)){e.pinchLastCenterX=S.x,e.pinchLastCenterY=S.y;var T=ah(e,b),E=f||m===0||c,j=l&&E,_=x_(e,g.x,g.y,b,T,j),N=_.x,R=_.y;e.pinchMidpoint=g,e.lastDistance=y;var O=d.sizeX,M=d.sizeY,L=Sd(e,O),P=Sd(e,M),$=N+w,q=R+C,K=Qb($,q,T,l,L,P,r),B=K.x,V=K.y;e.setTransformState(b,B,V)}}}},Nbt=function(e){var t=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,lfe(e,t==null?void 0:t.x,t==null?void 0:t.y)},xfe=function(e,t){var n=e.props.onZoomStop,s=e.setup.doubleClick.animationTime;aO(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,ys(ls(e),t,n)},s)},jbt=function(e,t){var n=e.props,s=n.onZoomStart,r=n.onZoom,i=e.setup.doubleClick,o=i.animationTime,l=i.animationType;ys(ls(e),t,s),ffe(e,o,l,function(){return ys(ls(e),t,r)}),xfe(e,t)};function Abt(e,t){return e==="toggle"?t===1?1:-1:e==="zoomOut"?-1:1}function Rbt(e,t){var n=e.setup,s=e.doubleClickStopEventTimer,r=e.transformState,i=e.contentComponent,o=r.scale,l=e.props,c=l.onZoomStart,u=l.onZoom,d=n.doubleClick,f=d.disabled,m=d.mode,g=d.step,y=d.animationTime,b=d.animationType;if(!f&&!s){if(m==="reset")return jbt(e,t);if(!i)return console.error("No ContentComponent found");var S=Abt(m,e.transformState.scale),w=ufe(e,S,g);if(o!==w){ys(ls(e),t,c);var C=mfe(t,i,o),T=XP(e,w,C.x,C.y);if(!T)return console.error("Error during zoom event. New transformation state was not calculated.");ys(ls(e),t,u),Kd(e,T,y,b),xfe(e,t)}}}var Mbt=function(e,t){var n=e.isInitialized,s=e.setup,r=e.wrapperComponent,i=s.doubleClick,o=i.disabled,l=i.excluded,c=t.target,u=r==null?void 0:r.contains(c),d=n&&c&&u&&!o;if(!d)return!1;var f=y_(c,l);return!f},Dbt=(function(){function e(t){var n=this;this.mounted=!0,this.pinchLastCenterX=null,this.pinchLastCenterY=null,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.lastTouch=null,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.animate=!1,this.animation=null,this.maxBounds=null,this.pressedKeys={},this.mount=function(){n.initializeWindowEvents()},this.unmount=function(){n.cleanupWindowEvents()},this.update=function(s){n.props=s,ah(n,n.transformState.scale),n.setup=IG(s)},this.initializeWindowEvents=function(){var s,r,i=MR(),o=(s=n.wrapperComponent)===null||s===void 0?void 0:s.ownerDocument,l=o==null?void 0:o.defaultView;(r=n.wrapperComponent)===null||r===void 0||r.addEventListener("wheel",n.onWheelPanning,i),l==null||l.addEventListener("mousedown",n.onPanningStart,i),l==null||l.addEventListener("mousemove",n.onPanning,i),l==null||l.addEventListener("mouseup",n.onPanningStop,i),o==null||o.addEventListener("mouseleave",n.clearPanning,i),l==null||l.addEventListener("keyup",n.setKeyUnPressed,i),l==null||l.addEventListener("keydown",n.setKeyPressed,i)},this.cleanupWindowEvents=function(){var s,r,i=MR(),o=(s=n.wrapperComponent)===null||s===void 0?void 0:s.ownerDocument,l=o==null?void 0:o.defaultView;l==null||l.removeEventListener("mousedown",n.onPanningStart,i),l==null||l.removeEventListener("mousemove",n.onPanning,i),l==null||l.removeEventListener("mouseup",n.onPanningStop,i),o==null||o.removeEventListener("mouseleave",n.clearPanning,i),l==null||l.removeEventListener("keyup",n.setKeyUnPressed,i),l==null||l.removeEventListener("keydown",n.setKeyPressed,i),document.removeEventListener("mouseleave",n.clearPanning,i),lo(n),(r=n.observer)===null||r===void 0||r.disconnect()},this.handleInitializeWrapperEvents=function(s){var r=MR();s.addEventListener("wheel",n.onWheelZoom,r),s.addEventListener("dblclick",n.onDoubleClick,r),s.addEventListener("touchstart",n.onTouchPanningStart,r),s.addEventListener("touchmove",n.onTouchPanning,r),s.addEventListener("touchend",n.onTouchPanningStop,r)},this.handleInitialize=function(s,r){var i=!1,o=n.setup.centerOnInit,l=function(c,u){for(var d=0,f=c;d<f.length;d++){var m=f[d];if(m.target===u)return!0}return!1};n.applyTransformation(),n.onInitCallbacks.forEach(function(c){c(ls(n))}),n.observer=new ResizeObserver(function(c){if(l(c,s)||l(c,r))if(o&&!i){var u=r.offsetWidth,d=r.offsetHeight;(u>0||d>0)&&(i=!0,n.setCenter())}else lo(n),ah(n,n.transformState.scale),ZP(n,0)}),n.observer.observe(s),n.observer.observe(r)},this.onWheelZoom=function(s){var r=n.setup.disabled;if(!r){var i=fbt(n,s);if(i){var o=n.isPressingKeys(n.setup.wheel.activationKeys);o&&(kbt(n,s),Cbt(n,s),Ebt(n,s))}}},this.onWheelPanning=function(s){var r=n.setup,i=r.disabled,o=r.wheel,l=r.panning;if(!(!n.wrapperComponent||!n.contentComponent||i||!o.wheelDisabled||l.disabled||!l.wheelPanning||s.ctrlKey)){s.preventDefault(),s.stopPropagation();var c=n.transformState,u=c.positionX,d=c.positionY,f=u-s.deltaX,m=d-s.deltaY,g=l.lockAxisX?u:f,y=l.lockAxisY?d:m,b=n.setup.alignmentAnimation,S=b.sizeX,w=b.sizeY,C=Sd(n,S),T=Sd(n,w);g===u&&y===d||ofe(n,g,y,C,T)}},this.onPanningStart=function(s){var r=n.setup.disabled,i=n.props.onPanningStart;if(!r){var o=jG(n,s);if(o){var l=n.isPressingKeys(n.setup.panning.activationKeys);l&&(s.button===0&&!n.setup.panning.allowLeftClickPan||s.button===1&&!n.setup.panning.allowMiddleClickPan||s.button===2&&!n.setup.panning.allowRightClickPan||(s.preventDefault(),s.stopPropagation(),lo(n),MG(n,s),ys(ls(n),s,i)))}}},this.onPanning=function(s){var r=n.setup.disabled,i=n.props.onPanning;if(!r){var o=AG(n);if(o){var l=n.isPressingKeys(n.setup.panning.activationKeys);l&&(s.preventDefault(),s.stopPropagation(),DG(n,s.clientX,s.clientY),ys(ls(n),s,i))}}},this.onPanningStop=function(s){var r=n.props.onPanningStop;n.isPanning&&(ebt(n),ys(ls(n),s,r))},this.onPinchStart=function(s){var r=n.setup.disabled,i=n.props,o=i.onPinchingStart,l=i.onZoomStart;if(!r){var c=xbt(n,s);c&&(Tbt(n,s),lo(n),ys(ls(n),s,o),ys(ls(n),s,l))}},this.onPinch=function(s){var r=n.setup.disabled,i=n.props,o=i.onPinching,l=i.onZoom;if(!r){var c=ybt(n);c&&(s.preventDefault(),s.stopPropagation(),_bt(n,s),ys(ls(n),s,o),ys(ls(n),s,l))}},this.onPinchStop=function(s){var r=n.props,i=r.onPinchingStop,o=r.onZoomStop;n.pinchStartScale&&(Nbt(n),ys(ls(n),s,i),ys(ls(n),s,o))},this.onTouchPanningStart=function(s){var r=n.setup.disabled,i=n.props.onPanningStart;if(!r){var o=jG(n,s);if(o){var l=n.lastTouch&&+new Date-n.lastTouch<200&&s.touches.length===1;if(!l){n.lastTouch=+new Date,lo(n);var c=s.touches,u=c.length===1,d=c.length===2;u&&(lo(n),MG(n,s),ys(ls(n),s,i)),d&&n.onPinchStart(s)}}}},this.onTouchPanning=function(s){var r=n.setup.disabled,i=n.props.onPanning;if(n.isPanning&&s.touches.length===1){if(r)return;var o=AG(n);if(!o)return;s.preventDefault(),s.stopPropagation();var l=s.touches[0];DG(n,l.clientX,l.clientY),ys(ls(n),s,i)}else s.touches.length>1&&n.onPinch(s)},this.onTouchPanningStop=function(s){n.onPanningStop(s),n.onPinchStop(s)},this.onDoubleClick=function(s){var r=n.setup.disabled;if(!r){var i=Mbt(n,s);i&&Rbt(n,s)}},this.clearPanning=function(s){n.isPanning&&n.onPanningStop(s)},this.setKeyPressed=function(s){n.pressedKeys[s.key]=!0},this.setKeyUnPressed=function(s){n.pressedKeys[s.key]=!1},this.isPressingKeys=function(s){return s.length?!!s.find(function(r){return n.pressedKeys[r]}):!0},this.setTransformState=function(s,r,i){var o=n.props.onTransformed;if(!Number.isNaN(s)&&!Number.isNaN(r)&&!Number.isNaN(i)){s!==n.transformState.scale&&(n.transformState.previousScale=n.transformState.scale,n.transformState.scale=s),n.transformState.positionX=r,n.transformState.positionY=i,n.applyTransformation();var l=ls(n);n.onChangeCallbacks.forEach(function(c){return c(l)}),ys(l,{scale:s,positionX:r,positionY:i},o)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(n.wrapperComponent&&n.contentComponent){var s=hfe(n.transformState.scale,n.wrapperComponent,n.contentComponent);n.setTransformState(s.scale,s.positionX,s.positionY)}},this.handleTransformStyles=function(s,r,i){return n.props.customTransform?n.props.customTransform(s,r,i):ubt(s,r,i)},this.applyTransformation=function(){if(!(!n.mounted||!n.contentComponent)){var s=n.transformState,r=s.scale,i=s.positionX,o=s.positionY,l=n.handleTransformStyles(i,o,r);n.contentComponent.style.transform=l}},this.getContext=function(){return ls(n)},this.onChange=function(s){return n.onChangeCallbacks.has(s)||n.onChangeCallbacks.add(s),function(){n.onChangeCallbacks.delete(s)}},this.onInit=function(s){return n.onInitCallbacks.has(s)||n.onInitCallbacks.add(s),function(){n.onInitCallbacks.delete(s)}},this.init=function(s,r){n.cleanupWindowEvents(),n.wrapperComponent=s,n.contentComponent=r,ah(n,n.transformState.scale),n.handleInitializeWrapperEvents(s),n.handleInitialize(s,r),n.initializeWindowEvents(),n.isInitialized=!0;var i=ls(n);ys(i,void 0,n.props.onInit)},this.props=t,this.setup=IG(this.props),this.transformState=cfe(this.props)}return e})(),v_=he.createContext(null),Obt=function(e,t){return typeof e=="function"?e(t):e},Ibt=he.forwardRef(function(e,t){var n=x.useRef(new Dbt(e)).current,s=Obt(e.children,GC(n));return x.useImperativeHandle(t,function(){return GC(n)},[n]),x.useEffect(function(){n.update(e)},[n,e]),he.createElement(v_.Provider,{value:n},s)});he.forwardRef(function(e,t){var n=x.useRef(null),s=x.useContext(v_);return x.useEffect(function(){return s.onChange(function(r){if(n.current){var i=0,o=0;n.current.style.transform=s.handleTransformStyles(i,o,1/r.instance.transformState.scale)}})},[s]),he.createElement("div",id({},e,{ref:dbt([n,t])}))});function Pbt(e,t){t===void 0&&(t={});var n=t.insertAt;if(!(typeof document>"u")){var s=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",n==="top"&&s.firstChild?s.insertBefore(r,s.firstChild):s.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}var Lbt=`.transform-component-module_wrapper__SPB86 {
|
|
1283
|
+
${Ce}`),m.clearFiles()}return t?t(Ce):Ce},[m,f,t]),y=x.useCallback(le=>{c.handleTaskEvent(le);const Ce=c.tasks.map(Ge=>Ge.id===le.task.id?{...Ge,...le.task}:Ge);u.handleTaskEvent(le,Ce)},[c,u]);x.useCallback(le=>{r(le),i.invalidateQueries({queryKey:["session",le]})},[r,i]);const b=x.useCallback(le=>{r(le,{replace:!0}),i.invalidateQueries({queryKey:["session",le]})},[r,i]),{messages:S,input:w,setInput:C,handleSubmit:T,submitContent:E,status:j,error:_,sessionBusy:N,stop:R,isLoadingHistory:O,sessionStatus:M,streamStartTime:L,estimatedTokens:P,isTextStreaming:$,isWaitingForUser:q,waitingType:K,activeInteraction:B,pendingInteractions:V,markToolCallResponded:Q,isRateLimited:re,rateLimitRetryAfter:U,systemStatus:G,promptSuggestions:W,syncConnectionState:F,retryMessage:X,tryNativeCommand:J}=Zft(e,{transformContent:g,onTaskEvent:y,onSessionIdChangeReplace:b,launchRuntime:n,onStreamingDone:x.useCallback(()=>{d&&Mwe(),i.invalidateQueries({queryKey:["commands"]})},[d,i])}),{permissionMode:ae}=Pne(e,M,j==="streaming"),{handleToolRef:oe,focusedOptionIndex:de}=tht(B),{isAtBottom:me,hasNewMessages:Re,scrollToBottom:Fe,handleScrollStateChange:Le}=nht(S,o);aht(j,q,c.activeForm,$),x.useEffect(()=>{var le;(le=l.current)==null||le.focus()},[e]);const Xe=x.useRef(null);x.useEffect(()=>{var le;s&&Xe.current!==s&&S.length===0&&(Xe.current=s,C(s),(le=l.current)==null||le.focus())},[s,S.length,C]);const ze=ude(e??""),{data:Mt}=uce(f,e??void 0,ze.runtime??void 0),Ft=x.useMemo(()=>{const le=new Set(gq.map(Ge=>Ge.command)),Ce=((Mt==null?void 0:Mt.commands)??[]).filter(Ge=>!le.has(Ge.command));return[...gq,...Ce]},[Mt]),{data:Pe}=vxt(f),He=x.useMemo(()=>Pe!=null&&Pe.files?cht(Pe.files):[],[Pe]),gt=iht({input:w,setInput:C,commands:Ft,fileEntries:He,chatInputRef:l}),Ct=x.useCallback(()=>{const le=[...S].reverse().find(Ce=>Ce.role==="user");le!=null&&le.content&&E(le.content)},[S,E]),cn=x.useCallback(()=>{const le=[...S].reverse().find(Ce=>Ce.role==="user");le!=null&&le.content&&X(le.content)},[S,X]),Nt=j==="idle"&&W.length>0&&w.length===0,ts=nvt(j,_,S),Ln=x.useMemo(()=>S.some(le=>le.role==="user"),[S]),Oe=x.useCallback(le=>{var Ce;C(le),(Ce=l.current)==null||Ce.focus()},[C]);return a.jsxs("div",{"data-testid":"chat-panel",className:"mx-auto flex h-full w-full max-w-7xl flex-col",children:[a.jsx(N0t,{messages:S,sessionId:e,isLoadingHistory:O,isTextStreaming:$,isAtBottom:me,hasNewMessages:Re,scrollToBottom:Fe,onScrollStateChange:Le,activeToolCallId:(B==null?void 0:B.toolCallId)??null,onToolRef:oe,focusedOptionIndex:de,onToolDecided:Q,onRetry:Ct,inputZoneToolCallId:(B==null?void 0:B.toolCallId)??null,messageListRef:o}),a.jsx(Jyt,{terminalReason:M==null?void 0:M.terminalReason}),a.jsx(Wyt,{status:j,streamStartTime:L,estimatedTokens:P,permissionMode:ae,isWaitingForUser:q??!1,waitingType:K??"approval",isRateLimited:re??!1,rateLimitRetryAfter:U??null,systemStatus:G}),a.jsx(Ue,{children:Nt&&a.jsx(rvt,{suggestions:W,onChipClick:Oe})}),a.jsx(Dyt,{celebration:u.activeCelebration,onComplete:u.clearCelebration}),a.jsx(Myt,{tasks:c.tasks,taskMap:c.taskMap,activeForm:c.activeForm,isCollapsed:c.isCollapsed,onToggleCollapse:c.toggleCollapse,celebratingTaskId:u.celebratingTaskId,onCelebrationComplete:u.clearCelebration,statusTimestamps:c.statusTimestamps}),ts&&a.jsx(tvt,{sessionId:e,onRetry:Ln?Ct:void 0}),_&&a.jsx("div",{className:"mx-4 mb-2",children:a.jsx(KP,{message:_.message,heading:_.heading,subtext:_.message,onRetry:_.retryable?cn:void 0})}),a.jsx(Cyt,{chatInputRef:l,input:w,autocomplete:gt,handleSubmit:T,submitContent:E,tryNativeCommand:J,status:j,sessionBusy:N,stop:R,setInput:C,sessionId:e??"",sessionStatus:M,fileUpload:{pendingFiles:m.pendingFiles,onFilesSelected:m.addFiles,onFileRemove:m.removeFile,isUploading:m.isUploading},interaction:{active:B,pendingApprovals:V.filter(le=>le.interactiveType==="approval"),focusedOptionIndex:de,onToolRef:oe,onToolDecided:Q},sync:{connectionState:F}})]})}const avt={url:ha,markdown:Qg,json:Gte,image:nMe,pdf:qh,widget:W5,mcp_app:ZM,file:Jte,model3d:mAe,csv:nDe,browser:ha};function ovt({documents:e,activeDocumentId:t,onActivate:n,onClose:s}){return e.length===0?null:a.jsx("div",{role:"tablist","aria-label":"Open canvas documents",className:"flex items-stretch gap-1 overflow-x-auto border-b px-2 py-1",children:e.map(r=>{const i=avt[r.contentType],o=r.id===t;return a.jsxs("div",{role:"tab","aria-selected":o,className:Y("group flex shrink-0 items-center gap-1.5 rounded-md py-1 pr-1 pl-2 text-xs transition-colors",o?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/60 hover:text-foreground"),children:[a.jsxs("button",{type:"button",onClick:()=>n(r.id),className:"focus-ring flex items-center gap-1.5 rounded-sm",children:[a.jsx(i,{className:"size-3.5 shrink-0"}),a.jsx("span",{className:"max-w-40 truncate font-medium",children:r.sourceLabel})]}),a.jsx("button",{type:"button",onClick:()=>s(r.id),"aria-label":`Close ${r.sourceLabel}`,className:"focus-ring hover:bg-background/80 rounded-sm p-0.5 opacity-60 transition-opacity group-hover:opacity-100",children:a.jsx(es,{className:"size-3"})})]},r.id)})})}const lvt="allow-scripts allow-forms allow-popups allow-modals",cvt="allow-scripts allow-same-origin allow-popups allow-forms allow-modals allow-downloads",uvt=new Set(["javascript:","data:","blob:"]),dvt=new Set(["localhost","127.0.0.1","0.0.0.0","[::1]","::1"]);function tfe(e){return dvt.has(e)||e.endsWith(".localhost")}function fvt(e){return e==="https:"?443:80}function nfe(e){let t;try{t=new URL(e)}catch{return{mode:"serve",path:e}}return uvt.has(t.protocol)?{mode:"blocked"}:t.protocol==="file:"?{mode:"serve",path:decodeURIComponent(t.pathname)}:t.protocol==="http:"||t.protocol==="https:"?tfe(t.hostname)?{mode:"proxy",port:t.port?Number(t.port):fvt(t.protocol),path:`${t.pathname}${t.search}`}:{mode:"external",url:e}:{mode:"blocked"}}function hvt(e){const t=e.trim();if(t===""||/^[a-z][a-z0-9+.-]*:\/\//i.test(t)||t.startsWith("/")||t.startsWith("./")||t.startsWith("../"))return t;const n=t.split("/")[0];if(t.includes("/")&&!n.includes(".")&&!n.includes(":"))return t;const r=n.split(":")[0];return`${tfe(r)?"http":"https"}://${t}`}function mvt(e){const t=nfe(e);if(t.mode==="serve")return{kind:"local",path:t.path};if(t.mode==="blocked")return{kind:"raw",text:e};try{const n=new URL(e),s=n.host.replace(/^www\./,""),r=n.pathname==="/"&&n.search===""&&n.hash===""?"":`${n.pathname}${n.search}${n.hash}`;return{kind:"url",host:s,rest:r}}catch{return{kind:"raw",text:e}}}function pvt({content:e}){const t=je(),n=we(E=>E.selectedCwd),[s,r]=x.useState([e.url]),[i,o]=x.useState(0),[l,c]=x.useState(0),u=s[i],d=x.useMemo(()=>nfe(u),[u]),[f,m]=x.useState(null),[g,y]=x.useState(null);x.useEffect(()=>{let E=!1;async function j(){if(y(null),m(null),d.mode!=="blocked"){if(d.mode==="external"){m(d.url);return}if(d.mode==="serve"&&n===null){y("no-session");return}try{let _;if(d.mode==="proxy"){const N=await t.createProxyUrl(d.port),R=d.path.replace(/^\//,"");_=N&&R?N+R:N}else _=await t.createServeUrl(n,d.path);if(E)return;_===null?y("unsupported"):m(_)}catch{E||y("failed")}}}return j(),()=>{E=!0}},[d,n,t,l]);const b=x.useCallback(E=>{r(j=>[...j.slice(0,i+1),E]),o(j=>j+1)},[i]),S=i>0,w=i<s.length-1,C=x.useCallback(E=>{const j=hvt(E);j&&j!==u?b(j):c(_=>_+1)},[u,b]),T=()=>window.open(u,"_blank","noopener,noreferrer");return a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsxs("div",{className:"border-border/60 flex h-9 items-center gap-1 border-b px-2",children:[a.jsx(Sw,{label:"Back",disabled:!S,onClick:()=>o(E=>E-1),children:a.jsx(ov,{className:"size-4"})}),a.jsx(Sw,{label:"Forward",disabled:!w,onClick:()=>o(E=>E+1),children:a.jsx(uh,{className:"size-4"})}),a.jsx(Sw,{label:"Reload",onClick:()=>c(E=>E+1),children:a.jsx(k3e,{className:"size-4"})}),a.jsx(gvt,{url:u,onSubmit:C}),a.jsx(Sw,{label:"Open in system browser",onClick:T,children:a.jsx(fa,{className:"size-4"})})]}),a.jsx(vvt,{target:d,resolvedSrc:f,resolveError:g,reloadNonce:l,title:e.title??"Embedded browser",onOpenExternally:T})]})}function gvt({url:e,onSubmit:t}){const[n,s]=x.useState(!1),[r,i]=x.useState(e);if(!n)return a.jsx(yvt,{url:e,onActivate:()=>{i(e),s(!0)}});const o=l=>{l.preventDefault(),s(!1),t(r)};return a.jsx("form",{onSubmit:o,className:"min-w-0 flex-1",children:a.jsx(sn,{"aria-label":"Address",autoFocus:!0,value:r,onChange:l=>i(l.target.value),onFocus:l=>l.currentTarget.select(),onBlur:()=>s(!1),onKeyDown:l=>{l.key==="Escape"&&(l.preventDefault(),s(!1))},spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",className:"h-7 w-full text-sm"})})}function xvt(e){return e.kind==="local"?e.path:e.kind==="url"?`${e.host}${e.rest}`:e.text}function yvt({url:e,onActivate:t}){const n=x.useMemo(()=>mvt(e),[e]);return a.jsxs("button",{type:"button","aria-label":`Address: ${xvt(n)}`,onClick:t,className:"text-muted-foreground hover:bg-muted focus-ring flex h-7 min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 text-left text-sm transition-colors",children:[n.kind==="local"&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"bg-muted-foreground/15 rounded px-1 py-0.5 text-[10px] font-medium tracking-wide uppercase",children:"local"}),a.jsx("span",{className:"text-foreground truncate",children:n.path})]}),n.kind==="url"&&a.jsxs("span",{className:"truncate",children:[a.jsx("span",{className:"text-foreground",children:n.host}),a.jsx("span",{className:"text-muted-foreground",children:n.rest})]}),n.kind==="raw"&&a.jsx("span",{className:"truncate",children:n.text})]})}function vvt({target:e,resolvedSrc:t,resolveError:n,reloadNonce:s,title:r,onOpenExternally:i}){if(e.mode==="blocked")return a.jsx(ty,{children:"This address can’t be displayed for security reasons."});if(n==="no-session")return a.jsx(ty,{children:"Open a session to preview local files."});if(n==="unsupported")return a.jsx(ty,{children:"Local previews aren’t available in this environment."});if(n==="failed")return a.jsx(ty,{children:"This preview couldn’t be loaded."});if(t===null)return a.jsx(ty,{children:"Loading…"});const o=e.mode==="external",l=o?cvt:lvt;return a.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[a.jsx("iframe",{src:t,sandbox:l,className:"min-h-0 w-full flex-1 border-0",title:r},`${t}:${s}`),o&&a.jsxs("div",{className:"text-muted-foreground border-border/60 flex items-center justify-between gap-2 border-t px-3 py-1.5 text-xs",children:[a.jsx("span",{children:"This site can’t always be embedded here."}),a.jsx("button",{type:"button",onClick:i,className:"text-foreground hover:underline",children:"Open in system browser"})]})]})}function Sw({label:e,disabled:t,onClick:n,children:s}){return a.jsx("button",{type:"button","aria-label":e,disabled:t,onClick:n,className:Y("text-muted-foreground hover:text-foreground hover:bg-muted focus-ring rounded-md p-1.5 transition-colors",t&&"pointer-events-none opacity-40"),children:s})}function ty({children:e}){return a.jsx("div",{className:"text-muted-foreground flex min-h-0 flex-1 flex-col items-center justify-center p-8 text-center",children:e})}function bvt({sourcePath:e,cwd:t,loadedContent:n}){const s=je(),[r,i]=x.useState("idle"),[o,l]=x.useState(null),c=x.useRef(null),u=x.useRef(n),d=x.useRef(Promise.resolve()),f=!!(e&&t),m=x.useCallback(async(w,C)=>{const T=await s.writeFile(t,e,w,C);return T.ok?(c.current=T.hash,u.current=w,l(null),i("saved"),"saved"):(l(T.conflict),i("conflict"),"conflict")},[s,t,e]),g=x.useCallback(w=>{if(!f)return Promise.resolve("idle");const C=d.current.catch(()=>{}).then(async()=>{if(w===u.current)return i("saved"),"saved";i("saving");try{const T=c.current!==null?{expectedHash:c.current}:{expectedContent:u.current};return await m(w,T)}catch{return i("error"),"error"}});return d.current=C.then(()=>{}),C},[f,m]),y=x.useCallback(w=>{if(!o)return Promise.resolve();const C=o.currentHash,T=d.current.catch(()=>{}).then(async()=>{i("saving");try{await m(w,{expectedHash:C})}catch{i("error")}});return d.current=T,T},[o,m]),b=x.useCallback(()=>({hash:c.current,content:u.current}),[]),S=x.useCallback(()=>{if(!o)return null;const w=o.currentContent;return c.current=o.currentHash,u.current=w,l(null),i("idle"),w},[o]);return{status:r,conflict:o,canSave:f,save:g,overwrite:y,adoptDisk:S,getConfirmedBase:b}}const NG=x.lazy(()=>ks(()=>import("./BlintzCanvas-BC2wvdMT.js"),__vite__mapDeps([0,1,2])).then(e=>({default:e.BlintzCanvas}))),Svt=500;function wvt(e){switch(e){case"saving":return"Saving…";case"saved":return"Saved";case"error":return"Couldn't save";default:return null}}function kvt({content:e,documentId:t,onContentChange:n}){const[s,r]=x.useState(!1),[i,o]=x.useState(e.content),l=we(O=>O.canvasSessionId),c=we(O=>O.setDocumentEditing),u=we(O=>O.selectedCwd),d=bvt({sourcePath:e.sourcePath,cwd:u,loadedContent:e.content}),f=d.canSave,m=x.useRef(null),g=x.useRef(null),y=x.useRef(i),b=x.useRef(e),S=x.useRef(n),w=x.useRef(d.save);x.useEffect(()=>{y.current=i,b.current=e,S.current=n,w.current=d.save});const C=x.useCallback(O=>{we.getState().canvasSessionId===m.current&&(S.current({...b.current,content:O}),w.current(O))},[]),T=x.useCallback(O=>{o(O),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,C(O)},Svt)},[C]),E=()=>{m.current=we.getState().canvasSessionId,o(e.content),r(!0),c(t,!0)},j=()=>{g.current&&(clearTimeout(g.current),g.current=null,C(y.current)),r(!1),c(t,!1)};x.useEffect(()=>{s&&l!==m.current&&(g.current&&(clearTimeout(g.current),g.current=null),r(!1),c(t,!1))},[l,s,t,c]),x.useEffect(()=>()=>{g.current&&(clearTimeout(g.current),g.current=null,C(y.current)),c(t,!1)},[C,t,c]);const _=()=>{const O=d.adoptDisk();O!=null&&(n({...e,content:O}),o(O))},N=()=>{d.overwrite(y.current)},R=wvt(d.status);return a.jsxs("div",{className:"relative flex h-full flex-col",children:[a.jsxs("div",{className:"sticky top-0 z-10 flex h-0 items-start justify-end gap-2 pr-2",children:[f&&R&&a.jsx("span",{className:"text-muted-foreground mt-3 text-xs","aria-live":"polite",children:R}),f&&a.jsx(ge,{type:"button",variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-foreground mt-2",onClick:s?j:E,"aria-label":s?"Finish editing":"Edit document",children:s?a.jsx(Lt,{className:"size-4"}):a.jsx(KE,{className:"size-4"})})]}),d.status==="conflict"&&a.jsxs("div",{className:"bg-destructive/10 text-destructive mx-2 mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 rounded-md px-3 py-2 text-sm",children:[a.jsx("span",{className:"flex-1",children:"This file changed on disk since you opened it."}),a.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"h-7",onClick:_,children:"Reload"}),a.jsx(ge,{type:"button",variant:"destructive",size:"sm",className:"h-7",onClick:N,children:"Overwrite"})]}),a.jsx("div",{className:"flex-1 px-2 pb-6",children:a.jsx(x.Suspense,{fallback:a.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading editor…"}),children:s?a.jsx(NG,{value:i,editable:!0,onChange:T},"edit"):a.jsx(NG,{value:e.content,editable:!1},"view")})})]})}function Cvt({content:e}){return a.jsx("div",{className:"p-4 font-mono text-sm",children:a.jsx(sfe,{value:e.data,depth:0})})}const Evt=20;function sfe({value:e,depth:t,keyName:n}){const[s,r]=x.useState(t>2),i=x.useCallback(()=>r(d=>!d),[]);if(t>=Evt)return a.jsx(ny,{keyName:n,value:"[max depth]",className:"text-muted-foreground"});if(e===null)return a.jsx(ny,{keyName:n,value:"null",className:"text-muted-foreground"});if(typeof e=="boolean")return a.jsx(ny,{keyName:n,value:String(e),className:"text-blue-500"});if(typeof e=="number")return a.jsx(ny,{keyName:n,value:String(e),className:"text-green-500"});if(typeof e=="string")return a.jsx(ny,{keyName:n,value:`"${e}"`,className:"text-amber-500"});const o=Array.isArray(e),l=o?e.map((d,f)=>[String(f),d]):Object.entries(e),c=o?"[":"{",u=o?"]":"}";return a.jsxs("div",{style:{paddingLeft:t>0?16:0},children:[a.jsxs("button",{type:"button",className:"hover:bg-muted -ml-0.5 inline-flex items-center gap-0.5 rounded px-0.5",onClick:i,children:[a.jsx(Rs,{className:Y("size-3 transition-transform",!s&&"rotate-90")}),n!=null&&a.jsxs("span",{className:"text-foreground",children:[n,": "]}),a.jsxs("span",{className:"text-muted-foreground",children:[c,s&&` ... ${l.length} items `,s&&u]})]}),!s&&a.jsxs(a.Fragment,{children:[l.map(([d,f])=>a.jsx(sfe,{keyName:o?void 0:d,value:f,depth:t+1},d)),a.jsx("div",{className:"text-muted-foreground",children:u})]})]})}function ny({keyName:e,value:t,className:n}){return a.jsxs("div",{style:{paddingLeft:16},children:[e!=null&&a.jsxs("span",{className:"text-foreground",children:[e,": "]}),a.jsx("span",{className:n,children:t})]})}var $a=function(e,t){return Number(e.toFixed(t))},Tvt=function(e,t){return t},ys=function(e,t,n){n&&typeof n=="function"&&n(e,t)},_vt=function(e){return-Math.cos(e*Math.PI)/2+.5},Nvt=function(e){return e},jvt=function(e){return e*e},Avt=function(e){return e*(2-e)},Rvt=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Mvt=function(e){return e*e*e},Dvt=function(e){return--e*e*e+1},Ovt=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},Ivt=function(e){return e*e*e*e},Pvt=function(e){return 1- --e*e*e*e},Lvt=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Fvt=function(e){return e*e*e*e*e},zvt=function(e){return 1+--e*e*e*e*e},Bvt=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},rfe={easeOut:_vt,linear:Nvt,easeInQuad:jvt,easeOutQuad:Avt,easeInOutQuad:Rvt,easeInCubic:Mvt,easeOutCubic:Dvt,easeInOutCubic:Ovt,easeInQuart:Ivt,easeOutQuart:Pvt,easeInOutQuart:Lvt,easeInQuint:Fvt,easeOutQuint:zvt,easeInOutQuint:Bvt},ife=function(e){typeof e=="number"&&cancelAnimationFrame(e)},lo=function(e){e.mounted&&(ife(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function afe(e,t,n,s){if(e.mounted){var r=new Date().getTime(),i=1;lo(e),e.animation=function(){if(!e.mounted)return ife(e.animation);var o=new Date().getTime()-r,l=o/n,c=rfe[t],u=c(l);o>=n?(s(i),e.animation=null):e.animation&&(s(u),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function $vt(e){var t=e.scale,n=e.positionX,s=e.positionY;return!(Number.isNaN(t)||Number.isNaN(n)||Number.isNaN(s))}function Kd(e,t,n,s){var r=$vt(t);if(!(!e.mounted||!r)){var i=e.setTransformState,o=e.transformState,l=o.scale,c=o.positionX,u=o.positionY,d=t.scale-l,f=t.positionX-c,m=t.positionY-u;n===0?i(t.scale,t.positionX,t.positionY):afe(e,s,n,function(g){var y=l+d*g,b=c+f*g,S=u+m*g;i(y,b,S)})}}function Hvt(e,t,n){var s=e.offsetWidth,r=e.offsetHeight,i=t.offsetWidth,o=t.offsetHeight,l=i*n,c=o*n,u=s-l,d=r-c;return{wrapperWidth:s,wrapperHeight:r,newContentWidth:l,newDiffWidth:u,newContentHeight:c,newDiffHeight:d}}var Uvt=function(e,t,n,s,r,i,o){var l=e>t?n*(o?1:.5):0,c=s>r?i*(o?1:.5):0,u=e-t-l,d=l,f=s-r-c,m=c;return{minPositionX:u,maxPositionX:d,minPositionY:f,maxPositionY:m}},YP=function(e,t){var n=e.wrapperComponent,s=e.contentComponent,r=e.setup.centerZoomedOut;if(!n||!s)throw new Error("Components are not mounted");var i=Hvt(n,s,t),o=i.wrapperWidth,l=i.wrapperHeight,c=i.newContentWidth,u=i.newDiffWidth,d=i.newContentHeight,f=i.newDiffHeight,m=Uvt(o,c,u,l,d,f,!!r);return m},rO=function(e,t,n,s){return s?e<t?$a(t,2):e>n?$a(n,2):$a(e,2):$a(e,2)},ah=function(e,t){var n=YP(e,t);return e.bounds=n,n};function Qb(e,t,n,s,r,i,o){var l=n.minPositionX,c=n.minPositionY,u=n.maxPositionX,d=n.maxPositionY,f=0,m=0;o&&(f=r,m=i);var g=rO(e,l-f,u+f,s),y=rO(t,c-m,d+m,s);return{x:g,y}}function x_(e,t,n,s,r,i){var o=e.transformState,l=o.scale,c=o.positionX,u=o.positionY,d=s-l;if(typeof t!="number"||typeof n!="number")return console.error("Mouse X and Y position were not provided!"),{x:c,y:u};var f=c-t*d,m=u-n*d,g=Qb(f,m,r,i,0,0,null);return g}function Jb(e,t,n,s,r){var i=r?s:0,o=t-i;return!Number.isNaN(n)&&e>=n?n:!Number.isNaN(t)&&e<=o?o:e}var jG=function(e,t){var n=e.setup.panning.excluded,s=e.isInitialized,r=e.wrapperComponent,i=t.target,o="shadowRoot"in i&&"composedPath"in t,l=o?t.composedPath().some(function(d){return d instanceof Element?r==null?void 0:r.contains(d):!1}):r==null?void 0:r.contains(i),c=s&&i&&l;if(!c)return!1;var u=y_(i,n);return!u},AG=function(e){var t=e.isInitialized,n=e.isPanning,s=e.setup,r=s.panning.disabled,i=t&&n&&!r;return!!i},Vvt=function(e,t){var n=e.transformState,s=n.positionX,r=n.positionY;e.isPanning=!0;var i=t.clientX,o=t.clientY;e.startCoords={x:i-s,y:o-r}},qvt=function(e,t){var n=t.touches,s=e.transformState,r=s.positionX,i=s.positionY;e.isPanning=!0;var o=n.length===1;if(o){var l=n[0].clientX,c=n[0].clientY;e.startCoords={x:l-r,y:c-i}}};function Gvt(e){var t=e.transformState,n=t.positionX,s=t.positionY,r=t.scale,i=e.setup,o=i.disabled,l=i.limitToBounds,c=i.centerZoomedOut,u=e.wrapperComponent;if(!(o||!u||!e.bounds)){var d=e.bounds,f=d.maxPositionX,m=d.minPositionX,g=d.maxPositionY,y=d.minPositionY,b=n>f||n<m,S=s>g||s<y,w=n>f?u.offsetWidth:e.setup.minPositionX||0,C=s>g?u.offsetHeight:e.setup.minPositionY||0,T=x_(e,w,C,r,e.bounds,l||c),E=T.x,j=T.y;return{scale:r,positionX:b?E:n,positionY:S?j:s}}}function ofe(e,t,n,s,r){var i=e.setup.limitToBounds,o=e.wrapperComponent,l=e.bounds,c=e.transformState,u=c.scale,d=c.positionX,f=c.positionY;if(!(o===null||l===null||t===d&&n===f)){var m=Qb(t,n,l,i,s,r,o),g=m.x,y=m.y;e.setTransformState(u,g,y)}}var Kvt=function(e,t,n){var s=e.startCoords,r=e.transformState,i=e.setup.panning,o=i.lockAxisX,l=i.lockAxisY,c=r.positionX,u=r.positionY;if(!s)return{x:c,y:u};var d=t-s.x,f=n-s.y,m=o?c:d,g=l?u:f;return{x:m,y:g}},Sd=function(e,t){var n=e.setup,s=e.transformState,r=s.scale,i=n.minScale,o=n.disablePadding;return t>0&&r>=i&&!o?t:0},Wvt=function(e){var t=e.mounted,n=e.setup,s=n.disabled,r=n.velocityAnimation,i=e.transformState.scale,o=r.disabled,l=!o||i>1||!s||t;return!!l},Yvt=function(e){var t=e.mounted,n=e.velocity,s=e.bounds,r=e.setup,i=r.disabled,o=r.velocityAnimation,l=e.transformState.scale,c=o.disabled,u=!c||l>1||!i||t;return!(!u||!n||!s)};function Zvt(e,t){var n=e.setup.velocityAnimation,s=n.equalToMove,r=n.animationTime,i=n.sensitivity;return s?r*t*i:r}function RG(e,t,n,s,r,i,o,l,c,u){if(r){if(t>o&&n>o){var d=o+(e-o)*u;return d>c?c:d<o?o:d}if(t<i&&n<i){var d=i+(e-i)*u;return d<l?l:d>i?i:d}}return s?t:rO(e,i,o,r)}function Xvt(e,t){var n=1;return t?Math.min(n,e.offsetWidth/window.innerWidth):n}function Qvt(e,t){var n=Wvt(e);if(n){var s=e.lastMousePosition,r=e.velocityTime,i=e.setup,o=e.wrapperComponent,l=i.velocityAnimation.equalToMove,c=Date.now();if(s&&r&&o){var u=Xvt(o,l),d=t.x-s.x,f=t.y-s.y,m=d/u,g=f/u,y=c-r,b=d*d+f*f,S=Math.sqrt(b)/y;e.velocity={velocityX:m,velocityY:g,total:S}}e.lastMousePosition=t,e.velocityTime=c}}function Jvt(e){var t=e.velocity,n=e.bounds,s=e.setup,r=e.wrapperComponent,i=Yvt(e);if(!(!i||!t||!n||!r)){var o=t.velocityX,l=t.velocityY,c=t.total,u=n.maxPositionX,d=n.minPositionX,f=n.maxPositionY,m=n.minPositionY,g=s.limitToBounds,y=s.alignmentAnimation,b=s.zoomAnimation,S=s.panning,w=S.lockAxisY,C=S.lockAxisX,T=b.animationType,E=y.sizeX,j=y.sizeY,_=y.velocityAlignmentTime,N=_,R=Zvt(e,c),O=Math.max(R,N),M=Sd(e,E),L=Sd(e,j),P=M*r.offsetWidth/100,$=L*r.offsetHeight/100,q=u+P,K=d-P,B=f+$,V=m-$,Q=e.transformState,re=new Date().getTime();afe(e,T,O,function(U){var G=e.transformState,W=G.scale,F=G.positionX,X=G.positionY,J=new Date().getTime()-re,ae=J/N,oe=rfe[y.animationType],de=1-oe(Math.min(1,ae)),me=1-U,Re=F+o*me,Fe=X+l*me,Le=RG(Re,Q.positionX,F,C,g,d,u,K,q,de),Xe=RG(Fe,Q.positionY,X,w,g,m,f,V,B,de);(F!==Re||X!==Fe)&&e.setTransformState(W,Le,Xe)})}}function MG(e,t){var n=e.transformState.scale;lo(e),ah(e,n),window.TouchEvent!==void 0&&t instanceof TouchEvent?qvt(e,t):Vvt(e,t)}function ZP(e,t){var n=e.transformState.scale,s=e.setup,r=s.minScale,i=s.alignmentAnimation,o=i.disabled,l=i.sizeX,c=i.sizeY,u=i.animationTime,d=i.animationType,f=o||n<r||!l&&!c;if(!f){var m=Gvt(e);m&&Kd(e,m,t??u,d)}}function DG(e,t,n){var s=e.startCoords,r=e.setup,i=r.alignmentAnimation,o=i.sizeX,l=i.sizeY;if(s){var c=Kvt(e,t,n),u=c.x,d=c.y,f=Sd(e,o),m=Sd(e,l);Qvt(e,{x:u,y:d}),ofe(e,u,d,f,m)}}function ebt(e){if(e.isPanning){var t=e.setup.panning.velocityDisabled,n=e.velocity,s=e.wrapperComponent,r=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var i=s==null?void 0:s.getBoundingClientRect(),o=r==null?void 0:r.getBoundingClientRect(),l=(i==null?void 0:i.width)||0,c=(i==null?void 0:i.height)||0,u=(o==null?void 0:o.width)||0,d=(o==null?void 0:o.height)||0,f=l<u||c<d,m=!t&&n&&(n==null?void 0:n.total)>.1&&f;m?Jvt(e):ZP(e)}}function XP(e,t,n,s){var r=e.setup,i=r.minScale,o=r.maxScale,l=r.limitToBounds,c=Jb($a(t,2),i,o,0,!1),u=ah(e,c),d=x_(e,n,s,c,u,l),f=d.x,m=d.y;return{scale:c,positionX:f,positionY:m}}function lfe(e,t,n){var s=e.transformState.scale,r=e.wrapperComponent,i=e.setup,o=i.minScale,l=i.limitToBounds,c=i.zoomAnimation,u=c.disabled,d=c.animationTime,f=c.animationType,m=u||s>=o;if((s>=1||l)&&ZP(e),!(m||!r||!e.mounted)){var g=t||r.offsetWidth/2,y=n||r.offsetHeight/2,b=XP(e,o,g,y);b&&Kd(e,b,d,f)}}var id=function(){return id=Object.assign||function(t){for(var n,s=1,r=arguments.length;s<r;s++){n=arguments[s];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},id.apply(this,arguments)};function OG(e,t,n){for(var s=0,r=t.length,i;s<r;s++)(i||!(s in t))&&(i||(i=Array.prototype.slice.call(t,0,s)),i[s]=t[s]);return e.concat(i||Array.prototype.slice.call(t))}var ww={scale:1,positionX:0,positionY:0},sy={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,disablePadding:!1,smooth:!0,wheel:{step:.2,disabled:!1,smoothStep:.001,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,allowLeftClickPan:!0,allowMiddleClickPan:!0,allowRightClickPan:!0,wheelPanning:!1,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},alignmentAnimation:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivity:1,animationTime:400,animationType:"easeOut",equalToMove:!0}},iO={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},cfe=function(e){var t,n,s,r;return{previousScale:(t=e.initialScale)!==null&&t!==void 0?t:ww.scale,scale:(n=e.initialScale)!==null&&n!==void 0?n:ww.scale,positionX:(s=e.initialPositionX)!==null&&s!==void 0?s:ww.positionX,positionY:(r=e.initialPositionY)!==null&&r!==void 0?r:ww.positionY}},IG=function(e){var t=id({},sy);return Object.keys(e).forEach(function(n){var s=typeof e[n]<"u",r=typeof sy[n]<"u";if(r&&s){var i=Object.prototype.toString.call(sy[n]),o=i==="[object Object]",l=i==="[object Array]";o?t[n]=id(id({},sy[n]),e[n]):l?t[n]=OG(OG([],sy[n],!0),e[n]):t[n]=e[n]}}),t},ufe=function(e,t,n){var s=e.transformState.scale,r=e.wrapperComponent,i=e.setup,o=i.maxScale,l=i.minScale,c=i.zoomAnimation,u=i.smooth,d=c.size;if(!r)throw new Error("Wrapper is not mounted");var f=u?s*Math.exp(t*n):s+t*n,m=Jb($a(f,3),l,o,d,!1);return m};function dfe(e,t,n,s,r){var i=e.wrapperComponent,o=e.transformState,l=o.scale,c=o.positionX,u=o.positionY;if(!i)return console.error("No WrapperComponent found");var d=i.offsetWidth,f=i.offsetHeight,m=(d/2-c)/l,g=(f/2-u)/l,y=ufe(e,t,n),b=XP(e,y,m,g);if(!b)return console.error("Error during zoom event. New transformation state was not calculated.");Kd(e,b,s,r)}function ffe(e,t,n,s){var r=e.setup,i=e.wrapperComponent,o=r.limitToBounds,l=cfe(e.props),c=e.transformState,u=c.scale,d=c.positionX,f=c.positionY;if(i){var m=YP(e,l.scale),g=Qb(l.positionX,l.positionY,m,o,0,0,i),y={scale:l.scale,positionX:g.x,positionY:g.y};u===l.scale&&d===l.positionX&&f===l.positionY||(s==null||s(),Kd(e,y,t,n))}}function tbt(e,t,n,s){var r=e.getBoundingClientRect(),i=t.getBoundingClientRect(),o=n.getBoundingClientRect(),l=i.x*s.scale,c=i.y*s.scale;return{x:(r.x-o.x+l)/s.scale,y:(r.y-o.y+c)/s.scale}}function nbt(e,t,n){var s=e.wrapperComponent,r=e.contentComponent,i=e.transformState,o=e.setup,l=o.limitToBounds,c=o.minScale,u=o.maxScale;if(!s||!r)return i;var d=s.getBoundingClientRect(),f=t.getBoundingClientRect(),m=tbt(t,s,r,i),g=m.x,y=m.y,b=f.width/i.scale,S=f.height/i.scale,w=s.offsetWidth/b,C=s.offsetHeight/S,T=Jb(n||Math.min(w,C),c,u,0,!1),E=(d.width-b*T)/2,j=(d.height-S*T)/2,_=(d.left-g)*T+E,N=(d.top-y)*T+j,R=YP(e,T),O=Qb(_,N,R,l,0,0,s),M=O.x,L=O.y;return{positionX:M,positionY:L,scale:T}}var sbt=function(e){return function(t,n,s){t===void 0&&(t=.5),n===void 0&&(n=300),s===void 0&&(s="easeOut"),dfe(e,1,t,n,s)}},rbt=function(e){return function(t,n,s){t===void 0&&(t=.5),n===void 0&&(n=300),s===void 0&&(s="easeOut"),dfe(e,-1,t,n,s)}},ibt=function(e){return function(t,n,s,r,i){r===void 0&&(r=300),i===void 0&&(i="easeOut");var o=e.transformState,l=o.positionX,c=o.positionY,u=o.scale,d=e.wrapperComponent,f=e.contentComponent,m=e.setup.disabled;if(!(m||!d||!f)){var g={positionX:Number.isNaN(t)?l:t,positionY:Number.isNaN(n)?c:n,scale:Number.isNaN(s)?u:s};Kd(e,g,r,i)}}},abt=function(e){return function(t,n){t===void 0&&(t=200),n===void 0&&(n="easeOut"),ffe(e,t,n)}},obt=function(e){return function(t,n,s){n===void 0&&(n=200),s===void 0&&(s="easeOut");var r=e.transformState,i=e.wrapperComponent,o=e.contentComponent;if(i&&o){var l=hfe(t||r.scale,i,o);Kd(e,l,n,s)}}},lbt=function(e){return function(t,n,s,r){s===void 0&&(s=600),r===void 0&&(r="easeOut"),lo(e);var i=e.wrapperComponent,o=typeof t=="string"?document.getElementById(t):t;if(i&&o&&i.contains(o)){var l=nbt(e,o,n);Kd(e,l,s,r)}}},GC=function(e){return{instance:e,zoomIn:sbt(e),zoomOut:rbt(e),setTransform:ibt(e),resetTransform:abt(e),centerView:obt(e),zoomToElement:lbt(e)}},cbt=function(e){return{instance:e,state:e.transformState}},ls=function(e){var t={};return Object.assign(t,cbt(e)),Object.assign(t,GC(e)),t},RR=!1;function MR(){try{var e={get passive(){return RR=!0,!1}};return e}catch{return RR=!1,RR}}var kw=".".concat(iO.wrapperClass),y_=function(e,t){return t.some(function(n){return e.matches("".concat(kw," ").concat(n,", ").concat(kw," .").concat(n,", ").concat(kw," ").concat(n," *, ").concat(kw," .").concat(n," *"))})},aO=function(e){e&&clearTimeout(e)},ubt=function(e,t,n){return"translate(".concat(e,"px, ").concat(t,"px) scale(").concat(n,")")},hfe=function(e,t,n){var s=n.offsetWidth*e,r=n.offsetHeight*e,i=(t.offsetWidth-s)/2,o=(t.offsetHeight-r)/2;return{scale:e,positionX:i,positionY:o}};function dbt(e){return function(t){e.forEach(function(n){typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var fbt=function(e,t){var n=e.setup.wheel,s=n.disabled,r=n.wheelDisabled,i=n.touchPadDisabled,o=n.excluded,l=e.isInitialized,c=e.isPanning,u=t.target,d=l&&!c&&!s&&u;if(!d||r&&!t.ctrlKey||i&&t.ctrlKey)return!1;var f=y_(u,o);return!f},hbt=function(e){return e?e.deltaY<0?1:-1:0};function mbt(e,t){var n=hbt(e),s=Tvt(t,n);return s}function mfe(e,t,n){var s=t.getBoundingClientRect(),r=0,i=0;if("clientX"in e)r=(e.clientX-s.left)/n,i=(e.clientY-s.top)/n;else{var o=e.touches[0];r=(o.clientX-s.left)/n,i=(o.clientY-s.top)/n}return(Number.isNaN(r)||Number.isNaN(i))&&console.error("No mouse or touch offset found"),{x:r,y:i}}var pbt=function(e,t,n,s,r){var i=e.transformState.scale,o=e.wrapperComponent,l=e.setup,c=l.maxScale,u=l.minScale,d=l.zoomAnimation,f=l.disablePadding,m=d.size,g=d.disabled;if(!o)throw new Error("Wrapper is not mounted");var y=i+t*n,b=s?!1:!g,S=Jb($a(y,3),u,c,m,b&&!f);return S},gbt=function(e,t){var n=e.previousWheelEvent,s=e.transformState.scale,r=e.setup,i=r.maxScale,o=r.minScale;return n?s<i||s>o||Math.sign(n.deltaY)!==Math.sign(t.deltaY)||n.deltaY>0&&n.deltaY<t.deltaY||n.deltaY<0&&n.deltaY>t.deltaY||Math.sign(n.deltaY)!==Math.sign(t.deltaY):!1},xbt=function(e,t){var n=e.setup.pinch,s=n.disabled,r=n.excluded,i=e.isInitialized,o=t.target,l=i&&!s&&o;if(!l)return!1;var c=y_(o,r);return!c},ybt=function(e){var t=e.setup.pinch.disabled,n=e.isInitialized,s=e.pinchStartDistance,r=n&&!t&&s;return!!r},vbt=function(e,t,n){var s=n.getBoundingClientRect(),r=e.touches,i=$a(r[0].clientX-s.left,5),o=$a(r[0].clientY-s.top,5),l=$a(r[1].clientX-s.left,5),c=$a(r[1].clientY-s.top,5);return{x:(i+l)/2/t,y:(o+c)/2/t}},pfe=function(e){return Math.sqrt(Math.pow(e.touches[0].pageX-e.touches[1].pageX,2)+Math.pow(e.touches[0].pageY-e.touches[1].pageY,2))},bbt=function(e,t){var n=e.pinchStartScale,s=e.pinchStartDistance,r=e.setup,i=r.maxScale,o=r.minScale,l=r.zoomAnimation,c=r.disablePadding,u=l.size,d=l.disabled;if(!n||s===null||!t)throw new Error("Pinch touches distance was not provided");if(t<0)return e.transformState.scale;var f=t/s,m=f*n;return Jb($a(m,2),o,i,u,!d&&!c)},Sbt=160,wbt=100,kbt=function(e,t){var n=e.props,s=n.onWheelStart,r=n.onZoomStart;e.wheelStopEventTimer||(lo(e),ys(ls(e),t,s),ys(ls(e),t,r))},Cbt=function(e,t){var n=e.props,s=n.onWheel,r=n.onZoom,i=e.contentComponent,o=e.setup,l=e.transformState,c=l.scale,u=o.limitToBounds,d=o.centerZoomedOut,f=o.zoomAnimation,m=o.wheel,g=o.disablePadding,y=o.smooth,b=f.size,S=f.disabled,w=m.step,C=m.smoothStep;if(!i)throw new Error("Component not mounted");t.preventDefault(),t.stopPropagation();var T=mbt(t,null),E=y?C*Math.abs(t.deltaY):w,j=pbt(e,T,E,!t.ctrlKey);if(c!==j){var _=ah(e,j),N=mfe(t,i,c),R=S||b===0||d||g,O=u&&R,M=x_(e,N.x,N.y,j,_,O),L=M.x,P=M.y;e.previousWheelEvent=t,e.setTransformState(j,L,P),ys(ls(e),t,s),ys(ls(e),t,r)}},Ebt=function(e,t){var n=e.props,s=n.onWheelStop,r=n.onZoomStop;aO(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(lfe(e,t.x,t.y),e.wheelAnimationTimer=null)},wbt);var i=gbt(e,t);i&&(aO(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,ys(ls(e),t,s),ys(ls(e),t,r))},Sbt))},gfe=function(e){for(var t=0,n=0,s=0;s<2;s+=1)t+=e.touches[s].clientX,n+=e.touches[s].clientY;var r=t/2,i=n/2;return{x:r,y:i}},Tbt=function(e,t){var n=pfe(t);e.pinchStartDistance=n,e.lastDistance=n,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var s=gfe(t);e.pinchLastCenterX=s.x,e.pinchLastCenterY=s.y,lo(e)},_bt=function(e,t){var n=e.contentComponent,s=e.pinchStartDistance,r=e.wrapperComponent,i=e.transformState.scale,o=e.setup,l=o.limitToBounds,c=o.centerZoomedOut,u=o.zoomAnimation,d=o.alignmentAnimation,f=u.disabled,m=u.size;if(!(s===null||!n)){var g=vbt(t,i,n);if(!(!Number.isFinite(g.x)||!Number.isFinite(g.y))){var y=pfe(t),b=bbt(e,y),S=gfe(t),w=S.x-(e.pinchLastCenterX||0),C=S.y-(e.pinchLastCenterY||0);if(!(b===i&&w===0&&C===0)){e.pinchLastCenterX=S.x,e.pinchLastCenterY=S.y;var T=ah(e,b),E=f||m===0||c,j=l&&E,_=x_(e,g.x,g.y,b,T,j),N=_.x,R=_.y;e.pinchMidpoint=g,e.lastDistance=y;var O=d.sizeX,M=d.sizeY,L=Sd(e,O),P=Sd(e,M),$=N+w,q=R+C,K=Qb($,q,T,l,L,P,r),B=K.x,V=K.y;e.setTransformState(b,B,V)}}}},Nbt=function(e){var t=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,lfe(e,t==null?void 0:t.x,t==null?void 0:t.y)},xfe=function(e,t){var n=e.props.onZoomStop,s=e.setup.doubleClick.animationTime;aO(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,ys(ls(e),t,n)},s)},jbt=function(e,t){var n=e.props,s=n.onZoomStart,r=n.onZoom,i=e.setup.doubleClick,o=i.animationTime,l=i.animationType;ys(ls(e),t,s),ffe(e,o,l,function(){return ys(ls(e),t,r)}),xfe(e,t)};function Abt(e,t){return e==="toggle"?t===1?1:-1:e==="zoomOut"?-1:1}function Rbt(e,t){var n=e.setup,s=e.doubleClickStopEventTimer,r=e.transformState,i=e.contentComponent,o=r.scale,l=e.props,c=l.onZoomStart,u=l.onZoom,d=n.doubleClick,f=d.disabled,m=d.mode,g=d.step,y=d.animationTime,b=d.animationType;if(!f&&!s){if(m==="reset")return jbt(e,t);if(!i)return console.error("No ContentComponent found");var S=Abt(m,e.transformState.scale),w=ufe(e,S,g);if(o!==w){ys(ls(e),t,c);var C=mfe(t,i,o),T=XP(e,w,C.x,C.y);if(!T)return console.error("Error during zoom event. New transformation state was not calculated.");ys(ls(e),t,u),Kd(e,T,y,b),xfe(e,t)}}}var Mbt=function(e,t){var n=e.isInitialized,s=e.setup,r=e.wrapperComponent,i=s.doubleClick,o=i.disabled,l=i.excluded,c=t.target,u=r==null?void 0:r.contains(c),d=n&&c&&u&&!o;if(!d)return!1;var f=y_(c,l);return!f},Dbt=(function(){function e(t){var n=this;this.mounted=!0,this.pinchLastCenterX=null,this.pinchLastCenterY=null,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.lastTouch=null,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.animate=!1,this.animation=null,this.maxBounds=null,this.pressedKeys={},this.mount=function(){n.initializeWindowEvents()},this.unmount=function(){n.cleanupWindowEvents()},this.update=function(s){n.props=s,ah(n,n.transformState.scale),n.setup=IG(s)},this.initializeWindowEvents=function(){var s,r,i=MR(),o=(s=n.wrapperComponent)===null||s===void 0?void 0:s.ownerDocument,l=o==null?void 0:o.defaultView;(r=n.wrapperComponent)===null||r===void 0||r.addEventListener("wheel",n.onWheelPanning,i),l==null||l.addEventListener("mousedown",n.onPanningStart,i),l==null||l.addEventListener("mousemove",n.onPanning,i),l==null||l.addEventListener("mouseup",n.onPanningStop,i),o==null||o.addEventListener("mouseleave",n.clearPanning,i),l==null||l.addEventListener("keyup",n.setKeyUnPressed,i),l==null||l.addEventListener("keydown",n.setKeyPressed,i)},this.cleanupWindowEvents=function(){var s,r,i=MR(),o=(s=n.wrapperComponent)===null||s===void 0?void 0:s.ownerDocument,l=o==null?void 0:o.defaultView;l==null||l.removeEventListener("mousedown",n.onPanningStart,i),l==null||l.removeEventListener("mousemove",n.onPanning,i),l==null||l.removeEventListener("mouseup",n.onPanningStop,i),o==null||o.removeEventListener("mouseleave",n.clearPanning,i),l==null||l.removeEventListener("keyup",n.setKeyUnPressed,i),l==null||l.removeEventListener("keydown",n.setKeyPressed,i),document.removeEventListener("mouseleave",n.clearPanning,i),lo(n),(r=n.observer)===null||r===void 0||r.disconnect()},this.handleInitializeWrapperEvents=function(s){var r=MR();s.addEventListener("wheel",n.onWheelZoom,r),s.addEventListener("dblclick",n.onDoubleClick,r),s.addEventListener("touchstart",n.onTouchPanningStart,r),s.addEventListener("touchmove",n.onTouchPanning,r),s.addEventListener("touchend",n.onTouchPanningStop,r)},this.handleInitialize=function(s,r){var i=!1,o=n.setup.centerOnInit,l=function(c,u){for(var d=0,f=c;d<f.length;d++){var m=f[d];if(m.target===u)return!0}return!1};n.applyTransformation(),n.onInitCallbacks.forEach(function(c){c(ls(n))}),n.observer=new ResizeObserver(function(c){if(l(c,s)||l(c,r))if(o&&!i){var u=r.offsetWidth,d=r.offsetHeight;(u>0||d>0)&&(i=!0,n.setCenter())}else lo(n),ah(n,n.transformState.scale),ZP(n,0)}),n.observer.observe(s),n.observer.observe(r)},this.onWheelZoom=function(s){var r=n.setup.disabled;if(!r){var i=fbt(n,s);if(i){var o=n.isPressingKeys(n.setup.wheel.activationKeys);o&&(kbt(n,s),Cbt(n,s),Ebt(n,s))}}},this.onWheelPanning=function(s){var r=n.setup,i=r.disabled,o=r.wheel,l=r.panning;if(!(!n.wrapperComponent||!n.contentComponent||i||!o.wheelDisabled||l.disabled||!l.wheelPanning||s.ctrlKey)){s.preventDefault(),s.stopPropagation();var c=n.transformState,u=c.positionX,d=c.positionY,f=u-s.deltaX,m=d-s.deltaY,g=l.lockAxisX?u:f,y=l.lockAxisY?d:m,b=n.setup.alignmentAnimation,S=b.sizeX,w=b.sizeY,C=Sd(n,S),T=Sd(n,w);g===u&&y===d||ofe(n,g,y,C,T)}},this.onPanningStart=function(s){var r=n.setup.disabled,i=n.props.onPanningStart;if(!r){var o=jG(n,s);if(o){var l=n.isPressingKeys(n.setup.panning.activationKeys);l&&(s.button===0&&!n.setup.panning.allowLeftClickPan||s.button===1&&!n.setup.panning.allowMiddleClickPan||s.button===2&&!n.setup.panning.allowRightClickPan||(s.preventDefault(),s.stopPropagation(),lo(n),MG(n,s),ys(ls(n),s,i)))}}},this.onPanning=function(s){var r=n.setup.disabled,i=n.props.onPanning;if(!r){var o=AG(n);if(o){var l=n.isPressingKeys(n.setup.panning.activationKeys);l&&(s.preventDefault(),s.stopPropagation(),DG(n,s.clientX,s.clientY),ys(ls(n),s,i))}}},this.onPanningStop=function(s){var r=n.props.onPanningStop;n.isPanning&&(ebt(n),ys(ls(n),s,r))},this.onPinchStart=function(s){var r=n.setup.disabled,i=n.props,o=i.onPinchingStart,l=i.onZoomStart;if(!r){var c=xbt(n,s);c&&(Tbt(n,s),lo(n),ys(ls(n),s,o),ys(ls(n),s,l))}},this.onPinch=function(s){var r=n.setup.disabled,i=n.props,o=i.onPinching,l=i.onZoom;if(!r){var c=ybt(n);c&&(s.preventDefault(),s.stopPropagation(),_bt(n,s),ys(ls(n),s,o),ys(ls(n),s,l))}},this.onPinchStop=function(s){var r=n.props,i=r.onPinchingStop,o=r.onZoomStop;n.pinchStartScale&&(Nbt(n),ys(ls(n),s,i),ys(ls(n),s,o))},this.onTouchPanningStart=function(s){var r=n.setup.disabled,i=n.props.onPanningStart;if(!r){var o=jG(n,s);if(o){var l=n.lastTouch&&+new Date-n.lastTouch<200&&s.touches.length===1;if(!l){n.lastTouch=+new Date,lo(n);var c=s.touches,u=c.length===1,d=c.length===2;u&&(lo(n),MG(n,s),ys(ls(n),s,i)),d&&n.onPinchStart(s)}}}},this.onTouchPanning=function(s){var r=n.setup.disabled,i=n.props.onPanning;if(n.isPanning&&s.touches.length===1){if(r)return;var o=AG(n);if(!o)return;s.preventDefault(),s.stopPropagation();var l=s.touches[0];DG(n,l.clientX,l.clientY),ys(ls(n),s,i)}else s.touches.length>1&&n.onPinch(s)},this.onTouchPanningStop=function(s){n.onPanningStop(s),n.onPinchStop(s)},this.onDoubleClick=function(s){var r=n.setup.disabled;if(!r){var i=Mbt(n,s);i&&Rbt(n,s)}},this.clearPanning=function(s){n.isPanning&&n.onPanningStop(s)},this.setKeyPressed=function(s){n.pressedKeys[s.key]=!0},this.setKeyUnPressed=function(s){n.pressedKeys[s.key]=!1},this.isPressingKeys=function(s){return s.length?!!s.find(function(r){return n.pressedKeys[r]}):!0},this.setTransformState=function(s,r,i){var o=n.props.onTransformed;if(!Number.isNaN(s)&&!Number.isNaN(r)&&!Number.isNaN(i)){s!==n.transformState.scale&&(n.transformState.previousScale=n.transformState.scale,n.transformState.scale=s),n.transformState.positionX=r,n.transformState.positionY=i,n.applyTransformation();var l=ls(n);n.onChangeCallbacks.forEach(function(c){return c(l)}),ys(l,{scale:s,positionX:r,positionY:i},o)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(n.wrapperComponent&&n.contentComponent){var s=hfe(n.transformState.scale,n.wrapperComponent,n.contentComponent);n.setTransformState(s.scale,s.positionX,s.positionY)}},this.handleTransformStyles=function(s,r,i){return n.props.customTransform?n.props.customTransform(s,r,i):ubt(s,r,i)},this.applyTransformation=function(){if(!(!n.mounted||!n.contentComponent)){var s=n.transformState,r=s.scale,i=s.positionX,o=s.positionY,l=n.handleTransformStyles(i,o,r);n.contentComponent.style.transform=l}},this.getContext=function(){return ls(n)},this.onChange=function(s){return n.onChangeCallbacks.has(s)||n.onChangeCallbacks.add(s),function(){n.onChangeCallbacks.delete(s)}},this.onInit=function(s){return n.onInitCallbacks.has(s)||n.onInitCallbacks.add(s),function(){n.onInitCallbacks.delete(s)}},this.init=function(s,r){n.cleanupWindowEvents(),n.wrapperComponent=s,n.contentComponent=r,ah(n,n.transformState.scale),n.handleInitializeWrapperEvents(s),n.handleInitialize(s,r),n.initializeWindowEvents(),n.isInitialized=!0;var i=ls(n);ys(i,void 0,n.props.onInit)},this.props=t,this.setup=IG(this.props),this.transformState=cfe(this.props)}return e})(),v_=he.createContext(null),Obt=function(e,t){return typeof e=="function"?e(t):e},Ibt=he.forwardRef(function(e,t){var n=x.useRef(new Dbt(e)).current,s=Obt(e.children,GC(n));return x.useImperativeHandle(t,function(){return GC(n)},[n]),x.useEffect(function(){n.update(e)},[n,e]),he.createElement(v_.Provider,{value:n},s)});he.forwardRef(function(e,t){var n=x.useRef(null),s=x.useContext(v_);return x.useEffect(function(){return s.onChange(function(r){if(n.current){var i=0,o=0;n.current.style.transform=s.handleTransformStyles(i,o,1/r.instance.transformState.scale)}})},[s]),he.createElement("div",id({},e,{ref:dbt([n,t])}))});function Pbt(e,t){t===void 0&&(t={});var n=t.insertAt;if(!(typeof document>"u")){var s=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",n==="top"&&s.firstChild?s.insertBefore(r,s.firstChild):s.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}var Lbt=`.transform-component-module_wrapper__SPB86 {
|
|
1284
1284
|
position: relative;
|
|
1285
1285
|
width: -moz-fit-content;
|
|
1286
1286
|
width: fit-content;
|
|
@@ -1313,4 +1313,4 @@ ${Ce}`),m.clearFiles()}return t?t(Ce):Ce},[m,f,t]),y=x.useCallback(le=>{c.handle
|
|
|
1313
1313
|
}
|
|
1314
1314
|
`,PG={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};Pbt(Lbt);var Fbt=function(e){var t=e.children,n=e.wrapperClass,s=n===void 0?"":n,r=e.contentClass,i=r===void 0?"":r,o=e.wrapperStyle,l=e.contentStyle,c=e.wrapperProps,u=c===void 0?{}:c,d=e.contentProps,f=d===void 0?{}:d,m=x.useContext(v_),g=m.init,y=m.cleanupWindowEvents,b=x.useRef(null),S=x.useRef(null);return x.useEffect(function(){var w=b.current,C=S.current;return w!==null&&C!==null&&g&&(g==null||g(w,C)),function(){y==null||y()}},[]),he.createElement("div",id({},u,{ref:b,className:"".concat(iO.wrapperClass," ").concat(PG.wrapper," ").concat(s),style:o}),he.createElement("div",id({},f,{ref:S,className:"".concat(iO.contentClass," ").concat(PG.content," ").concat(i),style:l}),t))},zbt=function(){var e=x.useContext(v_);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Bbt=function(){var e=zbt();return GC(e)};const $bt=new Set(["http:","https:"]);function Hbt(e){const t=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);return!t||t[1].length===1?null:`${t[1].toLowerCase()}:`}const Ubt={image:"data:image/",pdf:"data:application/pdf"};function yfe(e,t,n){const s=e.trim();if(s.startsWith("data:"))return s.toLowerCase().startsWith(Ubt[t])?{url:s,error:null}:{url:null,error:"unsupported-data"};const r=Hbt(s);if(r!==null)return $bt.has(r)?{url:s,error:null}:{url:null,error:"blocked"};const i=n(s);return i?{url:i,error:null}:{url:null,error:"local-unavailable"}}function vfe(e,t){switch(e){case"blocked":return`This ${t} source can't be displayed for security reasons.`;case"unsupported-data":return`This data URI isn't a valid ${t} source.`;case"local-unavailable":return`Local ${t} files can't be displayed here.`}}function Vbt({content:e}){const t=je(),n=we(d=>d.selectedCwd),s=x.useMemo(()=>yfe(e.src,"image",d=>t.mediaUrl(n??"",d)),[e.src,t,n]),[r,i]=x.useState("loading"),[o,l]=x.useState(e.src);o!==e.src&&(l(e.src),i("loading"));const c=e.alt??e.title??"Canvas image";if(s.url===null){const d=s.error?vfe(s.error,"image"):"";return a.jsx(LG,{children:d})}const u=s.url;return a.jsxs("div",{className:"bg-muted/40 relative flex h-full items-center justify-center",children:[r==="loading"&&a.jsx("p",{className:"text-muted-foreground absolute text-sm","aria-live":"polite",children:"Loading image…"}),r==="error"?a.jsx(LG,{children:"This image couldn’t be loaded."}):a.jsxs(Ibt,{centerOnInit:!0,doubleClick:{mode:"toggle"},wheel:{step:.15},children:[a.jsx(qbt,{}),a.jsx(Fbt,{wrapperClass:"!h-full !w-full",contentClass:"!h-full !w-full flex items-center justify-center",children:a.jsx("img",{src:u,alt:c,onLoad:()=>i("loaded"),onError:()=>i("error"),className:Y("max-h-full max-w-full object-contain transition-opacity",r==="loaded"?"opacity-100":"opacity-0")})})]})]})}function qbt(){const{zoomIn:e,zoomOut:t,resetTransform:n}=Bbt();return a.jsxs("div",{className:"absolute top-2 right-2 z-10 flex gap-1",children:[a.jsx(DR,{label:"Zoom in",onClick:()=>e(),children:a.jsx(BDe,{className:"size-4"})}),a.jsx(DR,{label:"Zoom out",onClick:()=>t(),children:a.jsx(FDe,{className:"size-4"})}),a.jsx(DR,{label:"Reset zoom",onClick:()=>n(),children:a.jsx(_Me,{className:"size-4"})})]})}function DR({label:e,onClick:t,children:n}){return a.jsx("button",{type:"button",onClick:t,"aria-label":e,className:"bg-background/80 text-muted-foreground hover:text-foreground focus-ring rounded-md border p-1.5 backdrop-blur transition-colors",children:n})}function LG({children:e}){return a.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:a.jsx("p",{children:e})})}function Gbt({content:e}){const t=je(),n=we(o=>o.selectedCwd),s=x.useMemo(()=>yfe(e.src,"pdf",o=>t.mediaUrl(n??"",o)),[e.src,t,n]);if(s.url===null){const o=s.error?vfe(s.error,"pdf"):"";return a.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:a.jsx("p",{children:o})})}const r=s.url,i=e.title??"PDF document";return a.jsx("object",{data:r,type:"application/pdf",title:i,className:"h-full w-full",children:a.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[a.jsx("p",{children:"This PDF can’t be shown here."}),a.jsxs("a",{href:r,target:"_blank",rel:"noreferrer",className:"text-foreground focus-ring rounded-md underline underline-offset-4",children:["Open ",i," in a new tab"]})]})})}function Kbt({content:e}){const[t]=Vc(),n=Tde(e.definition);return a.jsx("div",{className:"p-4",children:n.ok?a.jsx(Ede,{document:n.document,sessionId:t??void 0}):a.jsx(_de,{error:n.error,raw:n.raw})})}function Wbt({content:e}){const[t]=Vc();return t?a.jsx("div",{className:"h-full w-full",children:a.jsx(Fde,{sessionId:t,serverName:e.serverName,uri:e.uri,title:e.title})}):null}const Ybt=[{icon:Qg,label:"Markdown",description:"Render a document",action:()=>({type:"markdown",content:`# Untitled
|
|
1315
1315
|
|
|
1316
|
-
Start writing...`,title:"Document"})},{icon:Gte,label:"JSON",description:"Inspect structured data",action:()=>({type:"json",data:{message:"Your data here"},title:"JSON Data"})},{icon:ha,label:"Web Page",description:"Embed a URL",action:()=>({type:"url",url:"https://dorkos.ai",title:"Web Page"})}];function OR(e,t,n,s){return e.split("").reduce((i,o)=>i+o.charCodeAt(0),0)*(t+1)*7%(s-n)+n}function Zbt({onAction:e}){const t=Ds(),n=x.useId(),s=x.useMemo(()=>Array.from({length:6},(r,i)=>({x:OR(n,i*3,10,90),y:OR(n,i*3+1,10,80),size:OR(n,i*3+2,24,56),delay:i*.4})),[n]);return a.jsxs("div",{className:"relative flex h-full flex-col items-center justify-center overflow-hidden px-6",children:[!t&&s.map((r,i)=>a.jsx(te.div,{className:"border-border/40 absolute rounded-lg border",style:{left:`${r.x}%`,top:`${r.y}%`,width:r.size,height:r.size},initial:{opacity:0,scale:.6,rotate:-10},animate:{opacity:[0,.15,.08,.15],scale:[.6,1,.9,1],rotate:[-10,0,5,0]},transition:{duration:8,delay:r.delay,repeat:1/0,repeatType:"reverse",ease:"easeInOut"}},i)),a.jsxs(te.div,{className:"relative z-10 flex max-w-sm flex-col items-center gap-6 text-center",initial:t?!1:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.4,ease:"easeOut"},children:[a.jsx(te.div,{className:"bg-muted/50 text-muted-foreground flex size-14 items-center justify-center rounded-2xl",initial:t?!1:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.3,delay:.1},children:a.jsx(Jg,{className:"size-7"})}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"A blank canvas"}),a.jsxs("p",{className:"text-muted-foreground text-sm leading-relaxed",children:["Your agent can render documents, data, and web pages here.",a.jsx("br",{}),"Or pick a starting point below."]})]}),a.jsx(te.div,{className:"mt-2 flex w-full flex-col gap-2",initial:"hidden",animate:"visible",variants:t?{}:{visible:{transition:{staggerChildren:.08,delayChildren:.25}}},children:Ybt.map(({icon:r,label:i,description:o,action:l})=>a.jsxs(te.button,{variants:t?{}:{hidden:{opacity:0,y:8},visible:{opacity:1,y:0}},transition:{duration:.25},className:"border-border hover:bg-accent/50 flex items-center gap-3 rounded-lg border px-4 py-3 text-left transition-colors",onClick:()=>e(l()),children:[a.jsx(r,{className:"text-muted-foreground size-4 shrink-0"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("span",{className:"text-sm font-medium",children:i}),a.jsx("span",{className:"text-muted-foreground ml-2 text-xs",children:o})]})]},i))})]})]})}const Xbt=x.lazy(()=>ks(()=>import("./CanvasFileContent-gn5aMM24.js"),[]).then(e=>({default:e.CanvasFileContent}))),Qbt=x.lazy(()=>ks(()=>import("./CanvasModel3dContent-C3PJHVs8.js"),__vite__mapDeps([3,4])).then(e=>({default:e.CanvasModel3dContent}))),Jbt=x.lazy(()=>ks(()=>import("./CanvasCsvContent-Dcuaf91X.js"),__vite__mapDeps([5,4])).then(e=>({default:e.CanvasCsvContent})));function e1t({documentId:e,content:t,onContentChange:n}){switch(t.type){case"url":case"browser":return a.jsx(pvt,{content:t},`${e}:${t.url}`);case"markdown":return a.jsx(kvt,{documentId:e,content:t,onContentChange:n},t.sourcePath??"generated");case"json":return a.jsx(Cvt,{content:t});case"image":return a.jsx(Vbt,{content:t});case"pdf":return a.jsx(Gbt,{content:t});case"widget":return a.jsx(Kbt,{content:t});case"mcp_app":return a.jsx(Wbt,{content:t});case"file":return a.jsx(x.Suspense,{fallback:a.jsx(IR,{}),children:a.jsx(Xbt,{documentId:e,content:t})});case"model3d":return a.jsx(x.Suspense,{fallback:a.jsx(IR,{}),children:a.jsx(Qbt,{content:t})});case"csv":return a.jsx(x.Suspense,{fallback:a.jsx(IR,{}),children:a.jsx(Jbt,{content:t})})}}function IR(){return a.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading…"})}function oO(){const e=we(c=>c.openDocuments),t=we(c=>c.activeDocumentId),n=we(c=>c.activateCanvasDocument),s=we(c=>c.closeCanvasDocument),r=we(c=>c.setActiveDocumentContent),i=we(c=>c.openCanvasDocument),o=e.find(c=>c.id===t)??null,l=e.map(c=>({id:c.id,sourceLabel:c.sourceLabel,contentType:c.content.type}));return a.jsxs(a.Fragment,{children:[a.jsx(ovt,{documents:l,activeDocumentId:t,onActivate:n,onClose:s}),a.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:o?a.jsx(e1t,{documentId:o.id,content:o.content,onContentChange:r}):a.jsx(Zbt,{onAction:i})})]})}function t1t(){return a.jsx("div",{"data-slot":"canvas",className:"flex h-full flex-col overflow-hidden",children:a.jsx(oO,{})})}function n1t(){const e=we(r=>r.canvasOpen),t=we(r=>r.setCanvasOpen),n=Us();if(!e)return null;const s=()=>t(!1);return n?a.jsx(Al,{open:!0,onOpenChange:r=>!r&&s(),children:a.jsxs(Rl,{side:"right",showCloseButton:!1,className:"bg-sidebar text-sidebar-foreground flex w-full flex-col gap-0 p-0 sm:max-w-full",children:[a.jsxs(Ml,{className:"sr-only",children:[a.jsx(Dl,{children:"Canvas"}),a.jsx(Hd,{children:"Agent-driven content pane."})]}),a.jsx(oO,{})]})}):a.jsxs(a.Fragment,{children:[a.jsx(HP,{className:"group relative flex w-2 items-center justify-center",children:a.jsx("div",{className:"bg-border group-hover:bg-ring h-full w-px transition-colors"})}),a.jsx(o_,{id:"agent-canvas",order:2,defaultSize:50,minSize:20,collapsible:!0,onCollapse:s,children:a.jsx("div",{className:"bg-sidebar text-sidebar-foreground flex h-full flex-col overflow-hidden rounded-lg border",children:a.jsx(oO,{})})})]})}function bfe(e){const t=we(n=>n.loadCanvasForSession);x.useEffect(()=>{e&&t(e)},[e,t])}const s1t=Object.freeze(Object.defineProperty({__proto__:null,AgentCanvas:n1t,CanvasContent:t1t,useCanvasPersistence:bfe},Symbol.toStringTag,{value:"Module"}));function r1t(){const[e]=Vc(),{runtime:t,prompt:n}=sI();return bfe(e),ydt(),a.jsx(ivt,{sessionId:e,launchRuntime:t,launchPrompt:n})}function i1t({onClearFilters:e,filterDescription:t}){return a.jsxs(te.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3,ease:"easeOut"},className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[a.jsx(hne,{className:"text-muted-foreground/50 size-10"}),a.jsx("p",{className:"text-muted-foreground text-sm",children:t?`No agents match ${t}`:"No agents match your filters"}),a.jsx(ge,{variant:"outline",size:"sm",onClick:e,children:"Clear filters"})]})}const lO=wne({search:bne({fields:[e=>nn(e),e=>e.name,e=>e.description,e=>e.capabilities.join(" ")]}),status:Hp({field:e=>e.healthStatus,options:["active","inactive","stale","unreachable"],multi:!0,label:"Status",labels:{active:"Active",inactive:"Inactive",stale:"Stale",unreachable:"Unreachable"},colors:{active:"text-emerald-400",inactive:"text-amber-400",stale:"text-muted-foreground",unreachable:"text-red-400"}}),runtime:Hp({field:e=>e.runtime,options:["claude-code","cursor","codex","other"],label:"Runtime",labels:{"claude-code":"Claude Code",cursor:"Cursor",codex:"Codex",other:"Other"}}),lastSeen:KOe({field:e=>e.lastSeenAt,presets:["1h","24h","7d","30d"],label:"Last seen"}),namespace:Hp({field:e=>e.namespace,options:[],dynamic:!0,label:"Namespace"})}),FG={name:{label:"Name",accessor:e=>nn(e)},lastSeen:{label:"Last seen",accessor:e=>e.lastSeenAt??"",direction:"desc"},status:{label:"Status",accessor:e=>e.healthStatus},registered:{label:"Registered",accessor:e=>e.registeredAt,direction:"desc"}},a1t={active:{label:"Active",dotClass:"bg-emerald-500"},inactive:{label:"Inactive",dotClass:"bg-amber-500"},stale:{label:"Stale",dotClass:"bg-muted-foreground/50"},unreachable:{label:"Unreachable",dotClass:"bg-red-500"}};function o1t({status:e}){const t=a1t[e];return a.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[a.jsx("span",{className:Y("size-2 rounded-full",t.dotClass)}),a.jsx("span",{className:"text-muted-foreground text-xs",children:t.label})]})}function l1t(e){return[{accessorKey:"name",header:"Agent",cell:({row:t})=>{const n=t.original,{color:s,emoji:r}=Dd(n);return a.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2 text-left",onClick:()=>e.onNavigate(n.projectPath??""),children:[a.jsx(Vb,{color:s,emoji:r,size:"xs",healthStatus:n.healthStatus}),a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"block truncate text-sm font-medium hover:underline",children:nn(n)}),n.description&&a.jsx("span",{className:"text-muted-foreground block max-w-[300px] truncate text-xs max-sm:hidden",children:n.description})]}),n.isDefault&&a.jsxs(zt,{variant:"outline",className:"shrink-0 text-[10px]",children:[a.jsx(YE,{className:"mr-0.5 size-2.5 fill-current"}),"Default"]})]})}},{accessorKey:"healthStatus",header:"Status",cell:({row:t})=>a.jsx(o1t,{status:t.original.healthStatus})},{accessorKey:"runtime",header:"Runtime",meta:{hideOnMobile:!0},cell:({row:t})=>a.jsx(zt,{variant:"secondary",className:"text-xs",children:t.original.runtime})},{accessorKey:"projectPath",header:"Project",meta:{hideOnMobile:!0},cell:({row:t})=>{const n=t.original.projectPath;if(!n)return a.jsx("span",{className:"text-muted-foreground text-xs",children:"—"});const s=n.split("/").filter(Boolean),r=s.length<=2?n:s.slice(-2).join("/");return a.jsx("span",{className:"text-muted-foreground max-w-[200px] truncate font-mono text-xs",children:r})}},{accessorKey:"sessionCount",header:"Sessions",meta:{hideOnMobile:!0},cell:({row:t})=>{const n=t.original.sessionCount;return n===0?a.jsx("span",{className:"text-muted-foreground text-xs",children:"—"}):a.jsxs(zt,{variant:"outline",className:"text-xs",children:[n," active"]})}},{accessorKey:"lastSeenAt",header:"Last Seen",cell:({row:t})=>a.jsx("span",{className:"text-muted-foreground text-xs tabular-nums",children:t.original.lastSeenAt?ii(t.original.lastSeenAt):"Never"})},{id:"actions",header:"",cell:({row:t})=>{const n=t.original;return a.jsxs("div",{className:"flex items-center justify-end gap-1",children:[a.jsx(ge,{variant:"ghost",size:"sm",className:"size-8 p-0",onClick:s=>{s.stopPropagation(),e.onStartSession(n.projectPath??"")},"aria-label":`Chat with ${nn(n)}`,children:a.jsx(Rd,{className:"size-4"})}),a.jsx(ge,{variant:"ghost",size:"sm",className:"size-8 p-0",onClick:s=>{s.stopPropagation(),e.onManage(n.projectPath??"")},"aria-label":`Manage ${nn(n)}`,children:a.jsx(qa,{className:"size-4"})})]})}}]}function c1t({agents:e,isLoading:t}){var w;const n=Hn(),s=je(),r=Ane(lO,{debounce:{search:200}}),{sessions:i}=bl(),o=x.useMemo(()=>[...new Set(e.map(C=>C.namespace).filter(C=>!!C))],[e]),l=x.useMemo(()=>Sne(e,lO,r.values,FG,{field:r.sortField,direction:r.sortDirection}),[e,r.values,r.sortField,r.sortDirection]),c=x.useMemo(()=>{const C={};for(const T of e)C[T.id]=rI(i,T.projectPath??null).length;return C},[e,i]),{data:u}=st({queryKey:["config"],queryFn:()=>s.getConfig(),staleTime:3e4}),d=x.useMemo(()=>l.map(C=>{var T;return{...C,sessionCount:c[C.id]??0,isDefault:((T=u==null?void 0:u.agents)==null?void 0:T.defaultAgent)===C.name}}),[l,c,(w=u==null?void 0:u.agents)==null?void 0:w.defaultAgent]),f=we(C=>C.setRightPanelOpen),m=we(C=>C.setActiveRightPanelTab),g=x.useCallback(C=>{yd.getState().openHub(C),m("agent-hub"),f(!0)},[m,f]),y=x.useCallback(C=>{n({to:"/session",search:{dir:C}})},[n]),b=x.useCallback(C=>{n({to:"/session",search:{dir:C}})},[n]),S=x.useMemo(()=>l1t({onNavigate:y,onManage:g,onStartSession:b}),[y,g,b]);return t?a.jsx("div",{className:"space-y-3 p-4",children:Array.from({length:3}).map((C,T)=>a.jsx(Jt,{className:"h-14 w-full rounded-xl"},T))}):a.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[a.jsxs(ji,{state:r,children:[a.jsx(ji.Search,{placeholder:"Filter agents..."}),a.jsx(ji.Primary,{name:"status"}),a.jsx(ji.AddFilter,{dynamicOptions:{namespace:o}}),a.jsx(ji.Sort,{options:FG}),a.jsx(ji.ResultCount,{count:l.length,total:e.length,noun:"agent"}),a.jsx(ji.ActiveFilters,{})]}),a.jsx(No,{className:"min-h-0 flex-1",children:a.jsx("div",{className:"px-4 pb-4",children:l.length===0&&e.length>0?a.jsx(i1t,{onClearFilters:r.clearAll,filterDescription:r.describeActive()}):a.jsx(d9e,{columns:S,data:d,emptyMessage:"No agents registered.",className:"border-0"})})})]})}const u1t={animate:{transition:{staggerChildren:.1}}},d1t={initial:{opacity:0},animate:{opacity:.2,transition:{duration:.3}}};function PR(){return a.jsxs(te.div,{variants:d1t,className:"rounded-xl border border-dashed px-4 py-3",children:[a.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[a.jsx("div",{className:"bg-muted size-3 rounded-full"}),a.jsx("div",{className:"bg-muted h-3 w-32 rounded"}),a.jsx("div",{className:"bg-muted h-3 w-16 rounded"}),a.jsx("div",{className:"bg-muted ml-auto h-3 w-10 rounded"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"bg-muted h-2.5 w-48 rounded"}),a.jsx("div",{className:"bg-muted h-2.5 w-20 rounded"})]})]})}function f1t(){const[e,t]=x.useState(!1);return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"relative w-full max-w-2xl px-4",children:[a.jsxs(te.div,{variants:u1t,initial:"initial",animate:"animate",className:"space-y-3",children:[a.jsx(PR,{}),a.jsx(PR,{}),a.jsx(PR,{})]}),a.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-4",children:[a.jsx("p",{className:"text-lg font-semibold",children:"Import Your Projects"}),a.jsxs(ge,{size:"sm",className:"gap-1.5",onClick:()=>t(!0),children:[a.jsx(N3e,{className:"size-3.5"}),"Search for Projects"]})]})]}),a.jsx(fi,{open:e,onOpenChange:t,children:a.jsxs(hi,{className:"max-w-2xl",children:[a.jsx(va,{children:a.jsx(Li,{children:"Import Projects"})}),a.jsx(mue,{})]})})]})}function h1t(){const{data:e,isLoading:t}=pJe(),n=(e==null?void 0:e.denied)??[];return t?a.jsx("div",{className:"flex items-center justify-center p-8",children:a.jsx(Sn,{className:"text-muted-foreground size-5 animate-spin"})}):n.length===0?a.jsx(pue,{icon:xb,headline:"No blocked paths",description:"When you deny agent paths during discovery, they appear here. This is a healthy state."}):a.jsx("div",{className:"space-y-2 p-4",children:n.map(s=>a.jsxs("div",{className:"flex items-center justify-between rounded-xl border px-4 py-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"font-mono text-sm",children:s.path}),s.reason&&a.jsx("p",{className:"text-muted-foreground text-xs",children:s.reason})]}),a.jsx(zt,{variant:"outline",className:"text-xs",children:s.deniedBy})]},s.path))})}function m1t(){return a.jsx(Alt,{})}const p1t=x.lazy(()=>ks(()=>import("./TopologyGraph-xyvgCKHX.js"),__vite__mapDeps([6,7])).then(e=>({default:e.TopologyGraph})));function g1t(){const{view:e,agent:t}=ml({from:"/_shell/agents"}),n=t,s=Hn(),r=Us(),i=we(S=>S.setRightPanelOpen),o=we(S=>S.setActiveRightPanelTab),{open:l}=Wh(),[,c]=Id(),{data:u,isLoading:d,isError:f,refetch:m}=pP(),g=x.useMemo(()=>(u==null?void 0:u.namespaces.flatMap(S=>S.agents))??[],[u]),b=!(g.length>0)&&!d&&!f&&(e==="list"||e==="topology");return f?a.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[a.jsx("div",{className:"bg-destructive/10 rounded-xl p-3",children:a.jsx(fr,{className:"text-destructive size-6"})}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm font-medium",children:"Could not load agents"}),a.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"The mesh API is unreachable. Check that the server is running correctly."})]}),a.jsx(ge,{size:"sm",onClick:()=>void m(),className:"mt-1",children:"Retry"})]}):a.jsx(Ue,{mode:"wait",initial:!1,children:b?a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex h-full flex-col items-center justify-center",children:a.jsx(f1t,{})},"mode-a"):a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex h-full flex-col",children:a.jsxs(Ue,{mode:"wait",initial:!1,children:[e==="list"&&a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex h-full flex-col",children:a.jsx(c1t,{agents:g,isLoading:d})},"view-list"),e==="topology"&&a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"relative flex-1 overflow-hidden",children:a.jsxs("div",{className:"flex h-full",children:[a.jsx(te.div,{layout:!0,className:"min-w-0 flex-1",transition:{type:"spring",stiffness:300,damping:30},children:a.jsx("div",{className:"absolute inset-0",children:a.jsx(x.Suspense,{fallback:a.jsxs("div",{className:"text-muted-foreground flex h-full items-center justify-center text-sm",children:[a.jsx(Sn,{className:"mr-2 size-4 animate-spin"}),"Loading topology..."]}),children:a.jsx(p1t,{onSelectAgent:S=>s({to:"/agents",search:w=>({...w,agent:S})}),onOpenSettings:(S,w)=>{yd.getState().openHub(w),o("agent-hub"),i(!0)},onOpenChat:S=>c(S),onOpenAdapterCatalog:()=>l(),onGoToDiscovery:()=>s({to:"/agents",search:S=>({...S,view:"list"})})})})})}),r?a.jsx(Zh,{open:!!n,onOpenChange:S=>!S&&s({to:"/agents",search:w=>({...w,agent:void 0})}),children:a.jsx(Xh,{children:n&&a.jsx(BV,{agentId:n,onClose:()=>s({to:"/agents",search:S=>({...S,agent:void 0})})})})}):a.jsx(Ue,{children:n&&a.jsx(te.div,{initial:{width:0,opacity:0},animate:{width:256,opacity:1},exit:{width:0,opacity:0},transition:{type:"spring",stiffness:300,damping:30},className:"bg-background overflow-y-auto border-l",children:a.jsx(BV,{agentId:n,onClose:()=>s({to:"/agents",search:S=>({...S,agent:void 0})})})})})]})},"view-topology"),e==="denied"&&a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:a.jsx(h1t,{})},"view-denied"),e==="access"&&a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:a.jsx(m1t,{})},"view-access")]})},"mode-b")})}const x1t={initial:{opacity:0,y:6},animate:{opacity:1,y:0,transition:{duration:.2,ease:"easeOut"}}};function y1t(){const e=x.useId(),t=x.useMemo(()=>`${e.split("").reduce((s,r)=>s+r.charCodeAt(0),0)%40+50}%`,[e]);return a.jsxs(Tc,{children:[a.jsx(ra,{className:"w-28 py-1.5 pr-0 pl-2 max-sm:hidden",children:a.jsx(Jt,{className:"h-3 w-20"})}),a.jsx(ra,{className:"w-24 py-1.5 pr-0 max-sm:hidden",children:a.jsx(Jt,{className:"h-5 w-20 rounded-full"})}),a.jsx(ra,{className:"py-1.5 max-sm:pl-2",children:a.jsx(Jt,{className:"h-3 rounded",style:{width:t}})}),a.jsx(ra,{className:"w-16 py-1.5 max-sm:w-10"})]})}function v1t(){return a.jsxs("div",{"data-slot":"activity-timeline-skeleton",className:"space-y-1",children:[a.jsx("div",{className:"py-2",children:a.jsx(Jt,{className:"h-3 w-16 rounded"})}),a.jsx(f0,{children:a.jsx(h0,{children:Array.from({length:5}).map((e,t)=>a.jsx(y1t,{},t))})})]})}function b1t({items:e,isLoading:t,isFiltered:n,className:s}){const r=x.useMemo(()=>Bat(e,new Date),[e]),{containerRef:i,handleKeyDown:o}=Fat(e.length);return t&&e.length===0?a.jsx("div",{"data-slot":"activity-timeline",className:Y("px-4",s),children:a.jsx(v1t,{})}):e.length===0?a.jsx("div",{"data-slot":"activity-timeline",className:Y(s),children:a.jsx(Zat,{isFiltered:n})}):a.jsx("div",{ref:i,onKeyDown:o,"data-slot":"activity-timeline",className:Y("px-4",s),children:r.map(l=>a.jsxs("section",{children:[a.jsx(qat,{label:l.label}),a.jsx(te.div,{variants:x1t,initial:"initial",animate:"animate",children:a.jsx(f0,{children:a.jsx(h0,{children:l.items.map(c=>a.jsx(sue,{item:c},c.id))})})})]},l.label))})}function S1t({onLoadMore:e,isFetching:t,hasNextPage:n,className:s}){return n?a.jsx(te.div,{"data-slot":"activity-load-more",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.1},className:Y("flex justify-center px-4 py-4",s),children:a.jsxs(ge,{variant:"outline",size:"sm",onClick:e,disabled:t,className:"gap-2",children:[t&&a.jsx(Sn,{className:"size-3.5 animate-spin","aria-hidden":!0}),"Load 50 more events"]})}):null}function w1t(){const{queryFilters:e,isFiltered:t}=NP(),n=Lat(),{data:s,isLoading:r,isFetchingNextPage:i,hasNextPage:o,fetchNextPage:l}=Pat(e),c=x.useMemo(()=>(s==null?void 0:s.pages.flatMap(u=>u.items))??[],[s]);return a.jsx(No,{className:"h-full",children:a.jsxs("div",{className:"mx-auto max-w-4xl space-y-4 py-6 sm:py-8",children:[a.jsx(sot,{lastVisitedAt:n,items:c,className:"mx-4"}),a.jsx(b1t,{items:c,isLoading:r,isFiltered:t}),a.jsx(S1t,{onLoadMore:()=>void l(),isFetching:i,hasNextPage:!!o})]})})}function k1t(){const e=Ud(),{data:t=[],isLoading:n,isError:s,refetch:r}=WT(e),[i,o]=x.useState(!1),[l,c]=x.useState(),[u,d]=x.useState(null),f=t.some(N=>N.agentId),{data:m}=ba(void 0,f||!n),g=x.useMemo(()=>{const N=new Map;for(const R of(m==null?void 0:m.agents)??[])N.set(R.id,R);return N},[m]),{externalTrigger:y,clear:b}=Ub(),[S,w]=x.useState(!1);y&&!S&&!i?(w(!0),c(void 0),o(!0),b()):!y&&S&&w(!1);const C=N=>{d(N),c(void 0),o(!0)},T=()=>{d(null),c(void 0),o(!0)},E=N=>{c(N),o(!0)},j=N=>{o(N),N||d(null)};if(!e)return a.jsx(h4,{icon:pce.tasks,name:"Tasks",description:"Tasks runs AI agent tasks on a schedule. Start DorkOS with the --tasks flag to enable it.",command:"dorkos --tasks"});if(s)return a.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[a.jsx("div",{className:"bg-destructive/10 rounded-xl p-3",children:a.jsx(fr,{className:"text-destructive size-6"})}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm font-medium",children:"Could not load tasks"}),a.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"The tasks API is unreachable. Check that the server is running correctly."})]}),a.jsx(ge,{size:"sm",onClick:()=>void r(),className:"mt-1",children:"Retry"})]});const _=t.length>0;return a.jsxs(a.Fragment,{children:[!_&&!n?a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.15},className:"flex h-full flex-col items-center justify-center",children:a.jsx(kce,{onCreateWithPreset:C,onCreateBlank:T})}):a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.15},className:"flex h-full flex-col",children:a.jsx(uet,{tasks:t,isLoading:n,agentMap:g,onEditTask:E})}),a.jsx(SD,{open:i,onOpenChange:j,editTask:l,initialPreset:u})]})}function C1t(){const e=je(),t=Hde();return Bt({mutationFn:({id:n,pinned:s})=>e.pinWorkspace(n,s),onSuccess:()=>t()})}function E1t(){const e=je(),t=Hde();return Bt({mutationFn:({id:n,force:s})=>e.removeWorkspace(n,s),onSuccess:n=>{if(n.removed)return t()}})}function T1t({workspace:e}){const t=C1t(),n=E1t(),[s,r]=x.useState(!1),[i,o]=x.useState(!1),l=async c=>{const u=await n.mutateAsync({id:e.id,force:c});if(!u.removed&&u.blocked==="dirty"){o(!0);return}r(!1),o(!1)};return a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx(ge,{variant:"ghost",size:"sm","aria-label":e.pinned?"Unpin workspace":"Pin workspace",onClick:()=>t.mutate({id:e.id,pinned:!e.pinned}),disabled:t.isPending,children:e.pinned?a.jsx(Z5,{className:"size-4"}):a.jsx(gb,{className:"size-4"})})}),a.jsx(yn,{side:"top",children:e.pinned?"Unpin — allow automatic cleanup":"Pin — exempt from automatic cleanup"})]}),a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx(ge,{variant:"ghost",size:"sm","aria-label":"Remove workspace",onClick:()=>{o(!1),r(!0)},children:a.jsx(wo,{className:"size-4"})})}),a.jsx(yn,{side:"top",children:"Remove — delete this workspace’s checkout"})]}),a.jsx(Sl,{open:s,onOpenChange:c=>{r(c),c||o(!1)},children:a.jsxs(ko,{children:[a.jsxs(wl,{children:[a.jsx(Co,{children:i?"Force remove workspace?":"Remove workspace?"}),a.jsx(Eo,{children:i?`${e.key} has uncommitted or unpushed work. Force-removing deletes it permanently.`:`Remove the ${e.key} workspace? Its checkout will be deleted.`})]}),a.jsxs(kl,{children:[a.jsx(_o,{children:"Cancel"}),a.jsx(To,{onClick:c=>{c.preventDefault(),l(i)},disabled:n.isPending,children:i?"Force remove":"Remove"})]})]})})]})}const _1t={ready:"bg-emerald-500",provisioning:"bg-amber-500",failed:"bg-destructive",removing:"bg-muted-foreground"};function N1t({workspace:e}){var r,i,o;const t=Hn(),n=Bce(e.portBase),s=(((r=e.dirty)==null?void 0:r.uncommitted.length)??0)+(((i=e.dirty)==null?void 0:i.untracked.length)??0)+(((o=e.dirty)==null?void 0:o.unpushed)??0);return a.jsxs("div",{className:"bg-card rounded-xl border p-4",children:[a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx($p,{className:"text-muted-foreground size-4 shrink-0"}),a.jsx("span",{className:"truncate font-medium",children:e.key}),e.pinned&&a.jsx(gb,{className:"text-muted-foreground size-3.5 shrink-0"})]}),a.jsxs("div",{className:"text-muted-foreground mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs",children:[a.jsxs("span",{className:"inline-flex items-center gap-1",children:[a.jsx("span",{className:Y("size-1.5 rounded-full",_1t[e.status])}),e.status]}),a.jsxs("span",{children:["· ",e.provider]}),a.jsxs("span",{title:`DORKOS ${n.DORKOS_PORT} · VITE ${n.VITE_PORT} · SITE ${n.SITE_PORT}`,children:["· :",n.DORKOS_PORT]}),e.dirty&&(e.dirty.dirty?a.jsxs("span",{className:"text-amber-600",children:["· ● ",s," changes"]}):a.jsx("span",{children:"· clean"}))]})]}),a.jsx(T1t,{workspace:e})]}),a.jsx("div",{className:"mt-3 border-t border-dashed pt-3",children:e.sessions.length===0?a.jsx("p",{className:"text-muted-foreground text-xs",children:"No sessions"}):a.jsx("ul",{className:"flex flex-col gap-1.5",children:e.sessions.map(l=>a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>t({to:"/session",search:{session:l.sessionId,dir:e.path}}),className:"text-foreground/80 hover:text-foreground focus-visible:ring-ring inline-flex w-full items-center gap-2 truncate rounded text-left text-xs focus-visible:ring-2 focus-visible:outline-none",children:[a.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-emerald-500"}),a.jsx("span",{className:"truncate",children:l.title||l.sessionId})]})},l.sessionId))})})]})}function j1t(){const{workspaces:e,isLoading:t}=H0t(),n=x.useMemo(()=>{const s=new Map;for(const r of e){const i=s.get(r.projectKey)??[];i.push(r),s.set(r.projectKey,i)}return[...s.entries()].sort(([r],[i])=>r.localeCompare(i))},[e]);return a.jsxs("div",{className:"container-default mx-auto px-4 py-6",children:[a.jsxs("header",{className:"mb-6",children:[a.jsx("h1",{className:"text-xl font-semibold",children:"Workspaces"}),a.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Isolated, server-managed checkouts — one per unit of work, bound to sessions via cwd."})]}),t?a.jsx("p",{className:"text-muted-foreground text-sm",children:"Loading workspaces…"}):n.length===0?a.jsxs("div",{className:"bg-card rounded-xl border p-10 text-center",children:[a.jsx(ene,{className:"text-muted-foreground/60 mx-auto size-8"}),a.jsx("p",{className:"mt-3 font-medium",children:"No workspaces yet"}),a.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"A workspace is provisioned the first time an agent session is bound to a unit of work."})]}):a.jsx("div",{className:"flex flex-col gap-8",children:n.map(([s,r])=>a.jsxs("section",{children:[a.jsxs("h2",{className:"mb-3 flex items-center gap-2 text-sm font-semibold",children:[s,a.jsx(zt,{variant:"secondary",children:r.length})]}),a.jsx("div",{className:"flex flex-col gap-2",children:r.map(i=>a.jsx(N1t,{workspace:i},i.id))})]},s))})]})}function A1t(){return a.jsx("div",{className:"flex h-full flex-col overflow-y-auto",children:a.jsx(Nut,{})})}function R1t(){return a.jsx("div",{className:"flex h-full flex-col",children:a.jsx(Rut,{})})}const Sfe=c0e()({component:()=>a.jsx(SO,{}),notFoundComponent:$le}),Yc=Lc({getParentRoute:()=>Sfe,id:"_shell",component:kdt}),M1t=vb(se({session:z().optional(),dir:z().optional(),runtime:z().optional(),prompt:z().optional()})),D1t=vb(se({detail:Je(["dead-letter","failed-run","offline-agent"]).optional(),itemId:z().optional()})),O1t=vb(se({view:Je(["list","topology","denied","access"]).optional().default("list"),sort:z().optional().default("lastSeen:desc"),agent:z().optional()}).merge(lO.searchValidator)),I1t=vb(Mut),P1t=Lc({getParentRoute:()=>Yc,path:"/",validateSearch:Kv(D1t),component:Fdt,beforeLoad:({location:e})=>{const t=new URLSearchParams(e.searchStr),n=t.get("session");if(n)throw yk({to:"/session",search:{session:n,dir:t.get("dir")??void 0}})}});function L1t({context:{queryClient:e},location:t}){const n=new URLSearchParams(t.searchStr);if(n.get("session"))return;const r=n.get("dir")??void 0,i=n.get("runtime")??void 0,o=n.get("prompt")??void 0,l=e.getQueryData(["sessions",r??null]);throw l&&l.length>0?yk({to:"/session",search:{session:l[0].id,dir:r,runtime:i},replace:!0}):yk({to:"/session",search:{session:crypto.randomUUID(),dir:r,runtime:i,prompt:o},replace:!0})}const F1t=Lc({getParentRoute:()=>Yc,path:"/session",validateSearch:Kv(M1t),component:r1t,loader:L1t}),z1t=Lc({getParentRoute:()=>Yc,path:"/agents",validateSearch:Kv(O1t),component:g1t}),B1t=Lc({getParentRoute:()=>Yc,path:"/tasks",component:k1t}),$1t=Lc({getParentRoute:()=>Yc,path:"/workspaces",component:j1t}),H1t=Lc({getParentRoute:()=>Yc,path:"/marketplace",validateSearch:Kv(I1t),component:A1t}),U1t=Lc({getParentRoute:()=>Yc,path:"/marketplace/sources",component:R1t}),V1t=vb(se({categories:z().optional(),actorType:z().optional(),actorId:z().optional(),since:z().optional()})),q1t=Lc({getParentRoute:()=>Yc,path:"/activity",validateSearch:Kv(V1t),component:w1t}),G1t=Sfe.addChildren([Yc.addChildren([P1t,F1t,z1t,B1t,$1t,q1t,H1t,U1t])]);function K1t(e){return C0e({routeTree:G1t,context:{queryClient:e},defaultPreload:"intent",defaultErrorComponent:rQe,defaultNotFoundComponent:$le})}const W1t=["session.started","session.ended","session.switched","turn.started","turn.completed","tool.activity","relay.message"],Y1t=["session","turn","tool","relay"],Z1t=[...W1t,...Y1t];function X1t(e){return e.slice(0,e.indexOf("."))}function zG(e,t){return t.includes(e)||t.includes(X1t(e))}const Q1t=se({events:ft(Je(Z1t)).optional()}),J1t=se({key:z().regex(/^[a-z][a-z0-9_]*$/),label:z().min(1),description:z().optional(),placeholder:z().optional(),required:rt().default(!1),group:z().optional()}),eSt=se({label:z().min(1),value:pl([z(),Ee()])}),tSt=se({type:Je(["text","number","boolean","select"]),key:z().regex(/^[a-z][a-z0-9_]*$/),label:z().min(1),description:z().optional(),placeholder:z().optional(),default:pl([z(),Ee(),rt()]).optional(),required:rt().default(!1),group:z().optional(),options:ft(eSt).optional(),min:Ee().optional(),max:Ee().optional()}),nSt=se({baseUrl:z().url(),authHeader:z().default("Authorization"),authType:Je(["Bearer","Basic","Token","Custom"]).default("Bearer"),authSecret:z(),pathRewrite:Br(z(),z()).optional()}),sSt=se({serverEntry:z().default("./server.ts"),externalHosts:ft(z().url()).optional(),secrets:ft(J1t).optional(),settings:ft(tSt).optional()});se({id:z().min(1).regex(/^[a-z0-9][a-z0-9-]*$/),name:z().min(1),version:z().regex(/^\d+\.\d+\.\d+$/),description:z().optional(),author:z().optional(),minHostVersion:z().optional(),contributions:Br(z(),rt()).optional(),permissions:ft(z()).optional(),capabilities:Q1t.optional(),serverCapabilities:sSt.optional(),dataProxy:nSt.optional(),defaultEnabled:rt().optional(),canDisable:rt().optional()});const rSt=50,wfe="puzzle";function BG(e,t,n=[]){const s=[];return{api:{id:e,registerComponent(i,o,l,c){const u=iSt(i,`${e}:${o}`,l,c),d=t.registry.register(i,u);return s.push(d),d},registerCommand(i,o,l,c){const u=`ext:${e}:${i}`,d={id:`${e}:${i}`,label:o,icon:(c==null?void 0:c.icon)??wfe,action:u,shortcut:c==null?void 0:c.shortcut,category:"feature"},f=t.registry.register("command-palette.items",d);t.registerCommandHandler(u,l);const m=()=>{f(),t.unregisterCommandHandler(u)};return s.push(m),m},registerDialog(i,o){const l=`${e}:${i}`,c={id:l,component:o,openStateKey:`ext-dialog:${l}`},u=t.registry.register("dialog",c);s.push(u);let d=!1;return{open:()=>{d=!0},close:()=>{d=!1},get _openState(){return d}}},registerSettingsTab(i,o,l){const c={id:`${e}:${i}`,label:o,icon:void 0,component:l},u=t.registry.register("settings.tabs",c);return s.push(u),u},executeCommand(i){Kk(t.dispatcherContext,i,"agent")},openCanvas(i){Kk(t.dispatcherContext,{action:"open_canvas",content:i},"agent")},navigate(i){t.navigate({to:i})},getState(){const i=t.appStore.getState();return $G(i)},subscribe(i,o){const l=t.appStore.subscribe(c=>i($G(c)),o);return s.push(l),l},events:{subscribe(i,o){const l=i.filter(d=>zG(d,n)),c=i.filter(d=>!zG(d,n));if(c.length>0&&console.warn(`[ExtensionAPI] ${e}: events.subscribe rejected undeclared kind(s): ${c.join(", ")}. Add them to manifest capabilities.events.`),l.length===0)return()=>{};const u=t.eventBridge.subscribe(l,o);return s.push(u),u}},async loadData(){const i=await fetch(`/api/extensions/${e}/data`);if(i.status===204)return null;if(!i.ok)throw new Error(`loadData failed: ${i.status}`);return i.json()},async saveData(i){const o=await fetch(`/api/extensions/${e}/data`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!o.ok)throw new Error(`saveData failed: ${o.status}`)},notify(i,o){const l=(o==null?void 0:o.type)??"info";Ye[l](i)},isSlotAvailable(i){return t.availableSlots.has(i)}},cleanups:s}}function $G(e){const t=e??{};return{currentCwd:t.selectedCwd??null,activeSessionId:t.sessionId??null,agentId:null}}function iSt(e,t,n,s){const r={id:t,priority:(s==null?void 0:s.priority)??rSt};switch(e){case"dashboard.sections":return{...r,component:n};case"sidebar.tabs":return{...r,component:n,label:t,icon:void 0};case"sidebar.footer":return{...r,onClick:()=>{},label:t,icon:void 0};case"header.actions":return{...r,onClick:()=>{},label:t,icon:void 0};case"right-panel":return{...r,component:n,title:t,icon:void 0,headerActions:void 0,visibleWhen:void 0};case"settings.tabs":return{...r,component:n,label:t,icon:void 0};case"dialog":return{...r,component:n,openStateKey:`ext:${t}`};case"command-palette.items":return{...r,label:t,icon:wfe,action:`ext:${t}`,category:"feature"};default:return console.warn("[ExtensionAPI] Unknown slot:",e),{...r,component:n}}}function aSt({extensionId:e,status:t}){const[n,s]=x.useState(String(t.value??"")),[r,i]=x.useState(!1),o=async()=>{i(!0);try{const l=await fetch(`/api/extensions/${e}/settings/${t.key}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})});if(!l.ok)throw new Error(`${l.status}`);Ye.success(`${t.label} saved`)}catch{Ye.error(`Failed to save ${t.label}`)}finally{i(!1)}};return a.jsx(cs,{label:t.label,description:t.description??"",orientation:"vertical",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(sn,{value:n,onChange:l=>s(l.target.value),placeholder:t.placeholder??t.key,className:"h-8 min-w-0 flex-1 text-sm",onKeyDown:l=>{l.key==="Enter"&&o()}}),a.jsx(ge,{size:"sm",onClick:o,disabled:r,className:"h-8",children:"Save"})]})})}function oSt({extensionId:e,status:t}){const[n,s]=x.useState(String(t.value??"")),[r,i]=x.useState(!1),o=async()=>{const l=Number(n);if(!Number.isNaN(l)){i(!0);try{const c=await fetch(`/api/extensions/${e}/settings/${t.key}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:l})});if(!c.ok)throw new Error(`${c.status}`);Ye.success(`${t.label} saved`)}catch{Ye.error(`Failed to save ${t.label}`)}finally{i(!1)}}};return a.jsx(cs,{label:t.label,description:t.description??"",orientation:"vertical",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(sn,{type:"number",value:n,onChange:l=>s(l.target.value),placeholder:t.placeholder??t.key,min:t.min,max:t.max,className:"h-8 min-w-0 flex-1 text-sm",onKeyDown:l=>{l.key==="Enter"&&o()}}),a.jsx(ge,{size:"sm",onClick:o,disabled:r,className:"h-8",children:"Save"})]})})}function lSt({extensionId:e,status:t,onChanged:n}){const[s,r]=x.useState(!1),i=!!t.value,o=async l=>{r(!0);try{const c=await fetch(`/api/extensions/${e}/settings/${t.key}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:l})});if(!c.ok)throw new Error(`${c.status}`);Ye.success(`${t.label} ${l?"enabled":"disabled"}`),await n()}catch{Ye.error(`Failed to update ${t.label}`)}finally{r(!1)}};return a.jsx(cs,{label:t.label,description:t.description??"",children:a.jsx(sr,{checked:i,onCheckedChange:o,disabled:s})})}function cSt({extensionId:e,status:t,onChanged:n}){const[s,r]=x.useState(!1),i=async o=>{var l;r(!0);try{const u=((l=t.options)==null?void 0:l.every(f=>typeof f.value=="number"))?Number(o):o,d=await fetch(`/api/extensions/${e}/settings/${t.key}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:u})});if(!d.ok)throw new Error(`${d.status}`);Ye.success(`${t.label} updated`),await n()}catch{Ye.error(`Failed to update ${t.label}`)}finally{r(!1)}};return a.jsx(cs,{label:t.label,description:t.description??"",orientation:"vertical",children:a.jsxs(On,{value:String(t.value??""),onValueChange:i,disabled:s,children:[a.jsx(_n,{className:"h-8 text-sm",children:a.jsx(In,{})}),a.jsx(Nn,{children:(t.options??[]).map(o=>a.jsx(mt,{value:String(o.value),children:o.label},String(o.value)))})]})})}function uSt(e,t,n,s){const r=new Map,i=(o,l)=>{r.has(o)||r.set(o,[]),r.get(o).push(l)};for(const o of e)i(o.group,{kind:"secret",declaration:o,isSet:t.get(o.key)??!1});for(const o of s){const l=n.find(c=>c.key===o.key);l&&i(l.group,{kind:"setting",declaration:l,status:o})}return r}function dSt({extensionId:e,secrets:t,settings:n}){const[s,r]=x.useState(new Map),[i,o]=x.useState([]),[l,c]=x.useState(!0),u=x.useCallback(async()=>{try{const[y,b]=await Promise.all([t.length>0?fetch(`/api/extensions/${e}/secrets`):Promise.resolve(null),n.length>0?fetch(`/api/extensions/${e}/settings`):Promise.resolve(null)]);if(y!=null&&y.ok){const S=await y.json();r(new Map(S.map(w=>[w.key,w.isSet])))}if(b!=null&&b.ok){const S=await b.json();o(S)}}catch{}finally{c(!1)}},[e,t.length,n.length]);if(x.useEffect(()=>{u()},[u]),l)return a.jsx(vr,{children:a.jsx(dr,{children:a.jsx("div",{className:"text-muted-foreground py-4 text-center text-sm",children:"Loading…"})})});const d=uSt(t,s,n,i),f=d.get(void 0),m=[...d.entries()].filter(([y])=>y!==void 0);function g(y){if(y.kind==="secret")return a.jsx(hSt,{extensionId:e,secret:y.declaration,isSet:y.isSet,onChanged:u},y.declaration.key);switch(y.status.type){case"text":return a.jsx(aSt,{extensionId:e,status:y.status},y.declaration.key);case"number":return a.jsx(oSt,{extensionId:e,status:y.status},y.declaration.key);case"boolean":return a.jsx(lSt,{extensionId:e,status:y.status,onChanged:u},y.declaration.key);case"select":return a.jsx(cSt,{extensionId:e,status:y.status,onChanged:u},y.declaration.key)}}return a.jsxs(a.Fragment,{children:[f&&f.length>0&&a.jsx(vr,{children:a.jsx(dr,{children:f.map(g)})}),m.map(([y,b])=>a.jsx(fSt,{groupName:y,items:b,renderItem:g},y))]})}function fSt({groupName:e,items:t,renderItem:n}){const[s,r]=x.useState(!0);return a.jsx(WI,{open:s,onOpenChange:r,trigger:e,children:t.map(n)})}function hSt({extensionId:e,secret:t,isSet:n,onChanged:s}){const[r,i]=x.useState(""),[o,l]=x.useState(!1),c=async()=>{if(r.trim()){l(!0);try{const f=await fetch(`/api/extensions/${e}/secrets/${t.key}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:r})});if(!f.ok)throw new Error(`${f.status}`);i(""),Ye.success(`${t.label} saved`),await s()}catch{Ye.error(`Failed to save ${t.label}`)}finally{l(!1)}}},u=async()=>{l(!0);try{const f=await fetch(`/api/extensions/${e}/secrets/${t.key}`,{method:"DELETE"});if(!f.ok)throw new Error(`${f.status}`);Ye.success(`${t.label} removed`),await s()}catch{Ye.error(`Failed to remove ${t.label}`)}finally{l(!1)}},d=t.description??(t.required?"Required":"Optional");return n?a.jsx(cs,{label:t.label,description:d,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(zt,{variant:"outline",className:"text-muted-foreground gap-1",children:[a.jsx(Lt,{className:"size-3"}),"Configured"]}),a.jsxs(ge,{variant:"ghost",size:"sm",onClick:u,disabled:o,className:"text-muted-foreground hover:text-destructive h-7 px-2 text-xs",children:[a.jsx(es,{className:"size-3"}),"Clear"]})]})}):a.jsx(cs,{label:t.label,description:d,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(il,{value:r,onChange:f=>i(f.target.value),placeholder:t.placeholder??t.key,className:"h-8 w-48 text-sm",onKeyDown:f=>{f.key==="Enter"&&c()}}),a.jsx(ge,{size:"sm",onClick:c,disabled:o||!r.trim(),className:"h-8",children:"Save"})]})})}async function HG(){const e=await fetch("/api/extensions");return e.ok?e.json():(console.error("[extensions] Failed to fetch extension list:",e.status),[])}async function mSt(e){try{return await ks(()=>import(`/api/extensions/${e}/bundle`),[])}catch(t){return console.error(`[extensions] Failed to import ${e}:`,t),null}}async function UG(e){if(!(!e.hasServerEntry&&!e.hasDataProxy))try{const t=await fetch(`/api/extensions/${e.id}/init-server`,{method:"POST"});if(!t.ok){const n=await t.json().catch(()=>({error:"Unknown error"}));console.warn(`[extensions] Server init failed for ${e.id}:`,n.error??t.statusText)}}catch(t){console.error(`[extensions] Server init error for ${e.id}:`,t)}}class pSt{constructor(t){Ze(this,"loaded",new Map);Ze(this,"deps");Ze(this,"disposed",!1);this.deps=t}async initialize(){var o;const t=await HG(),n=t.filter(l=>l.status==="compiled"&&l.bundleReady);if(n.length===0)return console.log("[extensions] No extensions to load"),{extensions:t,loaded:this.loaded};const s=await Promise.all(n.map(async l=>({rec:l,module:await mSt(l.id)}))),r=[],i=[];for(const{rec:l,module:c}of s){if(this.disposed)break;if(c)try{const{api:u,cleanups:d}=BG(l.id,this.deps,((o=l.manifest.capabilities)==null?void 0:o.events)??[]),f=c.activate(u);this.autoRegisterConfigTab(l,d);const m={id:l.id,manifest:l.manifest,module:c,api:u,cleanups:d,deactivate:typeof f=="function"?f:void 0};this.loaded.set(l.id,m),r.push(`${l.manifest.name} v${l.manifest.version}`),i.push(UG(l))}catch(u){console.error(`[extensions] Failed to activate ${l.id}:`,u)}}return await Promise.all(i),r.length>0&&console.log(`[extensions] Activated: ${r.join(", ")}`),{extensions:t,loaded:this.loaded}}deactivateAll(){var t;this.disposed=!0;for(const[n,s]of this.loaded){try{(t=s.deactivate)==null||t.call(s)}catch(r){console.error(`[extensions] Error calling deactivate for ${n}:`,r)}for(const r of s.cleanups)try{r()}catch(i){console.error(`[extensions] Error in cleanup for ${n}:`,i)}}this.loaded.clear()}async reloadExtensions(t){var s;for(const r of t){const i=this.loaded.get(r);if(i){try{(s=i.deactivate)==null||s.call(i)}catch(o){console.error(`[extensions] Error deactivating ${r}:`,o)}for(const o of i.cleanups)try{o()}catch(l){console.error(`[extensions] Error in cleanup for ${r}:`,l)}this.loaded.delete(r)}}const n=await HG();for(const r of t){const i=n.find(o=>o.id===r);if(!(!i||i.status!=="compiled"||!i.bundleReady))try{const o=await ks(()=>import(`/api/extensions/${r}/bundle?t=${Date.now()}`),[]),{api:l,cleanups:c}=BG(r,this.deps),u=o.activate(l);this.autoRegisterConfigTab(i,c),this.loaded.set(r,{id:r,manifest:i.manifest,module:o,api:l,cleanups:c,deactivate:typeof u=="function"?u:void 0}),await UG(i),console.log(`[extensions] Hot-reloaded: ${i.manifest.name} v${i.manifest.version}`)}catch(o){console.error(`[extensions] Failed to hot-reload ${r}:`,o)}}return{extensions:n,loaded:this.loaded}}getLoaded(){return this.loaded}autoRegisterConfigTab(t,n){var d,f;const s=(d=t.manifest.serverCapabilities)==null?void 0:d.secrets,r=(f=t.manifest.serverCapabilities)==null?void 0:f.settings;if(!(s!=null&&s.length)&&!(r!=null&&r.length))return;const i=t.id,o=`${i}:settings`,l=s??[],c=r??[],u=this.deps.registry.register("settings.tabs",{id:o,label:t.manifest.name,icon:qa,component:function(){return x.createElement(dSt,{extensionId:i,secrets:l,settings:c})},priority:90});n.push(u)}}const VG=1500;async function gSt(e){try{const t=await fetch("/api/extensions/cwd-changed",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e})});return t.ok?await t.json():(console.error("[extensions] CWD change notification failed:",t.status),null)}catch(t){return console.error("[extensions] CWD change notification error:",t),null}}function xSt(){const e=we(n=>n.selectedCwd),t=x.useRef(void 0);x.useEffect(()=>{if(t.current===void 0){t.current=e;return}t.current!==e&&(t.current=e,gSt(e).then(n=>{!n||!n.changed||(Ye.info("Project extensions changed. Reloading...",{duration:VG}),setTimeout(()=>{location.reload()},VG))}))},[e])}const Eh={all:["extensions"],lists:()=>[...Eh.all,"list"],detail:e=>[...Eh.all,"detail",e]};function YSt(){return st({queryKey:Eh.lists(),queryFn:async()=>{const e=await fetch("/api/extensions");if(!e.ok)throw new Error(`Failed to fetch extensions: ${e.status}`);return e.json()},staleTime:1e4,refetchInterval:3e4,refetchIntervalInBackground:!1})}function ZSt(){const e=et();return Bt({mutationFn:async t=>{const n=await fetch(`/api/extensions/${t}/enable`,{method:"POST"});if(!n.ok)throw new Error(`Failed to enable extension '${t}': ${n.status}`);return n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:Eh.lists()})}})}function XSt(){const e=et();return Bt({mutationFn:async t=>{const n=await fetch(`/api/extensions/${t}/disable`,{method:"POST"});if(!n.ok)throw new Error(`Failed to disable extension '${t}': ${n.status}`);return n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:Eh.lists()})}})}function QSt(){const e=et();return Bt({mutationFn:async()=>{const t=await fetch("/api/extensions/reload",{method:"POST"});if(!t.ok)throw new Error(`Failed to reload extensions: ${t.status}`);return t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:Eh.lists()})}})}const kfe={extensions:[],loaded:new Map,ready:!1},Cfe=x.createContext(kfe);function JSt(){return x.useContext(Cfe)}function ySt({deps:e,children:t}){const[n,s]=x.useState(kfe),r=x.useRef(null),i=et();return xSt(),x.useEffect(()=>{const o=new pSt(e);return r.current=o,o.initialize().then(({extensions:l,loaded:c})=>{s({extensions:l,loaded:c,ready:!0})}).catch(l=>{console.error("[extensions] Failed to initialize:",l),s(c=>({...c,ready:!0}))}),()=>{o.deactivateAll(),r.current=null}},[]),kg("extension_reloaded",o=>{const l=r.current;if(!l)return;const c=o;(async()=>{try{const{extensions:u,loaded:d}=await l.reloadExtensions(c.extensionIds);s({extensions:u,loaded:d,ready:!0}),i.invalidateQueries({queryKey:Eh.lists()})}catch(u){console.error("[extensions] Hot reload failed:",u)}})()}),a.jsx(Cfe.Provider,{value:n,children:t})}function vSt(e){if(typeof e!="object"||e===null)return null;const t=e;return typeof t.id=="string"&&typeof t.from=="string"&&typeof t.subject=="string"?{messageId:t.id,from:t.from,subject:t.subject}:null}class bSt{constructor(t,n={}){Ze(this,"subscriptions",new Set);Ze(this,"seenSessions",new Set);Ze(this,"turns",new Map);Ze(this,"cleanups",[]);Ze(this,"now");this.now=n.now??(()=>Date.now()),this.connect(t)}subscribe(t,n){const s={kinds:new Set(t),handler:n};return this.subscriptions.add(s),()=>{this.subscriptions.delete(s)}}dispose(){for(const t of this.cleanups)t();this.cleanups.length=0,this.subscriptions.clear(),this.turns.clear(),this.seenSessions.clear()}connect(t){this.cleanups.push(t.subscribeSessionEvent((n,s)=>this.onSessionEvent(n,s)),t.subscribeListEvent(n=>this.onListEvent(n)),t.subscribeAttachedSessionChange((n,s)=>this.emit({kind:"session.switched",sessionId:n,previousSessionId:s})),t.subscribeEvent("relay_message",n=>{const s=vSt(n);s&&this.emit({kind:"relay.message",...s})}))}onSessionEvent(t,n){switch(n.type){case"turn_start":this.turns.set(t,{startedAt:this.now(),toolCallCount:0}),this.emit({kind:"turn.started",sessionId:t});break;case"tool_call":{const s=this.turns.get(t);s&&(s.toolCallCount+=1),this.emit({kind:"tool.activity",sessionId:t,toolName:n.toolName,status:"started"});break}case"tool_result":this.emit({kind:"tool.activity",sessionId:t,toolName:n.toolName,status:"completed"});break;case"turn_end":{const s=this.turns.get(t);this.turns.delete(t),this.emit({kind:"turn.completed",sessionId:t,durationMs:s?this.now()-s.startedAt:null,toolCallCount:(s==null?void 0:s.toolCallCount)??0,terminalReason:n.terminalReason});break}}}onListEvent(t){switch(t.type){case"session_upserted":{const n=t.session.id;this.seenSessions.has(n)||(this.seenSessions.add(n),this.emit({kind:"session.started",sessionId:n}));break}case"session_removed":this.seenSessions.delete(t.sessionId),this.emit({kind:"session.ended",sessionId:t.sessionId});break}}emit(t){for(const n of this.subscriptions)n.kinds.has(t.kind)&&n.handler(t)}}function SSt(e){return new bSt(e)}function wSt(){const{register:e}=nI.getState();for(const t of klt)e("command-palette.items",t);for(const t of Clt)e("command-palette.items",t);for(const t of vat)e("sidebar.footer",t);for(const t of bat)e("sidebar.tabs",t);for(const t of sft)e("dashboard.sections",t);for(const t of Oit)e("dialog",t);e("settings.tabs",{id:"extensions",label:"Extensions",icon:X5,component:x.lazy(()=>ks(()=>import("./index-BkmzUjFL.js"),[]).then(t=>({default:t.ExtensionsSettingsTab}))),priority:70}),e("right-panel",{id:"agent-hub",title:"Agent Profile",icon:Md,component:x.lazy(()=>ks(()=>import("./index-C2pa1dy_.js"),[]).then(t=>({default:t.AgentHub}))),visibleWhen:({pathname:t})=>!t.startsWith("/marketplace"),priority:10}),e("right-panel",{id:"files",title:"Files",icon:BRe,component:x.lazy(()=>ks(()=>import("./index-DWocbnZZ.js"),[]).then(t=>({default:t.FileExplorer}))),headerActions:x.lazy(()=>ks(()=>import("./index-DWocbnZZ.js"),[]).then(t=>({default:t.FileExplorerActions}))),visibleWhen:({pathname:t})=>t==="/session",priority:15}),e("right-panel",{id:"canvas",title:"Canvas",icon:dne,component:x.lazy(()=>ks(()=>Promise.resolve().then(()=>s1t),void 0).then(t=>({default:t.CanvasContent}))),visibleWhen:({pathname:t})=>t==="/session",priority:20}),e("right-panel",{id:"terminal",title:"Terminal",icon:Z3e,component:x.lazy(()=>ks(()=>import("./index-Ced3HTl7.js"),__vite__mapDeps([8,9])).then(t=>({default:t.TerminalPanel}))),visibleWhen:({pathname:t,transport:n})=>t==="/session"&&(n==null?void 0:n.supportsTerminal)===!0,priority:25})}const kSt=x.createContext(null),LR={didCatch:!1,error:null};class CSt extends x.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=LR}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(...t){var s,r;const{error:n}=this.state;n!==null&&((r=(s=this.props).onReset)==null||r.call(s,{args:t,reason:"imperative-api"}),this.setState(LR))}componentDidCatch(t,n){var s,r;(r=(s=this.props).onError)==null||r.call(s,t,n)}componentDidUpdate(t,n){var i,o;const{didCatch:s}=this.state,{resetKeys:r}=this.props;s&&n.error!==null&&ESt(t.resetKeys,r)&&((o=(i=this.props).onReset)==null||o.call(i,{next:r,prev:t.resetKeys,reason:"keys"}),this.setState(LR))}render(){const{children:t,fallbackRender:n,FallbackComponent:s,fallback:r}=this.props,{didCatch:i,error:o}=this.state;let l=t;if(i){const c={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")l=n(c);else if(s)l=x.createElement(s,c);else if(r!==void 0)l=r;else throw o}return x.createElement(kSt.Provider,{value:{didCatch:i,error:o,resetErrorBoundary:this.resetErrorBoundary}},l)}}function ESt(e=[],t=[]){return e.length!==t.length||e.some((n,s)=>!Object.is(n,t[s]))}globalThis.React=he;const TSt=null;he.lazy(()=>ks(()=>import("./index-zioTSqyj.js"),[]).then(e=>({default:e.ReactQueryDevtoolsPanel})));he.lazy(()=>ks(()=>import("./index-BzFClKht.js").then(e=>e.w),[]).then(e=>({default:e.TanStackRouterDevtoolsPanel})));function _St(){return window.location.pathname.startsWith("/dev"),a.jsxs(Epe,{client:tI,children:[a.jsx(sbe,{transport:Tfe,children:a.jsx(C5e,{children:a.jsxs(ySt,{deps:_fe,children:[a.jsx(Zst,{children:a.jsx(_0e,{router:NSt})}),a.jsx(Xst,{})]})})}),!1]})}const NSt=K1t(tI),Efe=dZ(),Tfe=new VSe(Efe);nr.useHttpSource(Efe);const qG=new Map,_fe={registry:nI.getState(),dispatcherContext:{store:we.getState(),setTheme:e=>{document.documentElement.classList.toggle("dark",e==="dark")},supportsTerminal:Tfe.supportsTerminal},navigate:e=>{console.warn("[extensions] navigate called before router ready:",e)},appStore:we,availableSlots:new Set(["sidebar.footer","sidebar.tabs","dashboard.sections","header.actions","command-palette.items","dialog","settings.tabs","right-panel"]),registerCommandHandler:(e,t)=>{qG.set(e,t)},unregisterCommandHandler:e=>{qG.delete(e)},eventBridge:SSt(nr)};nr.subscribeUiCommand(e=>Kk(_fe.dispatcherContext,e,"agent"));wSt();Jme.createRoot(document.getElementById("root"),{onCaughtError:(e,t)=>{console.error("[dorkos:caught]",e,t.componentStack)},onUncaughtError:(e,t)=>{console.error("[dorkos:uncaught]",e,t.componentStack)}}).render(a.jsx(he.StrictMode,{children:a.jsx(CSt,{FallbackComponent:iQe,children:a.jsx(_St,{})})}));const jSt=Object.freeze(Object.defineProperty({__proto__:null,Mermaid:Lle},Symbol.toStringTag,{value:"Module"}));export{dr as $,pZe as A,ge as B,Lt as C,QSt as D,ma as E,bSt as F,pSt as G,ySt as H,BG as I,SSt as J,JSt as K,HSt as L,TK as M,Zf as N,MK as O,KE as P,g8 as Q,xa as R,Qce as S,Jce as T,am as U,Ud as V,Sst as W,GQe as X,tP as Y,vr as Z,ks as _,iI as a,Nr as a$,WI as a0,cs as a1,sn as a2,gn as a3,xn as a4,yn as a5,S3e as a6,s_ as a7,Hn as a8,une as a9,$p as aA,QM as aB,K5 as aC,Qte as aD,Bt as aE,ua as aF,da as aG,VSt as aH,eJe as aI,cce as aJ,qSt as aK,nJe as aL,Cx as aM,On as aN,_n as aO,In as aP,Nn as aQ,mt as aR,nn as aS,CJe as aT,ii as aU,vP as aV,rce as aW,a0 as aX,o0 as aY,Xte as aZ,Qh as a_,ODe as aa,Rs as ab,hl as ac,Eht as ad,Oi as ae,Vv as af,xe as ag,gl as ah,Kk as ai,Aie as aj,Rie as ak,Sn as al,$c as am,th as an,qh as ao,Mie as ap,Ny as aq,z3 as ar,Sl as as,ko as at,wl as au,Co as av,Eo as aw,kl as ax,_o as ay,To as az,oce as b,$b as b$,DRe as b0,rd as b1,wy as b2,$Qe as b3,c0 as b4,u0 as b5,Cs as b6,d0 as b7,USt as b8,Gb as b9,yRe as bA,hi as bB,va as bC,Li as bD,Ga as bE,Ab as bF,xb as bG,F3e as bH,kDe as bI,wo as bJ,jb as bK,f8e as bL,ov as bM,Dd as bN,ZQe as bO,Eet as bP,Tce as bQ,te as bR,Ue as bS,Vb as bT,JQe as bU,YO as bV,ZO as bW,E9 as bX,Det as bY,Md as bZ,Hh as b_,PQe as ba,ZT as bb,lJe as bc,cJe as bd,TJe as be,mce as bf,Fce as bg,Gk as bh,WE as bi,im as bj,Ka as bk,Mc as bl,es as bm,qa as bn,Z3e as bo,Ds as bp,xv as bq,aT as br,RFe as bs,ml as bt,yd as bu,dce as bv,hJe as bw,pJe as bx,fi as by,d8e as bz,je as c,_Qe as c0,GSt as c1,WSt as c2,Jt as c3,_ce as c4,QHe as c5,oUe as c6,jUe as c7,kv as c8,ZHe as c9,RJe as cA,ha as cB,RSt as cC,EJe as cD,pP as cE,Hb as cF,iae as ca,ioe as cb,he as cc,Wa as cd,aYe as ce,iWe as cf,dl as cg,Rp as ch,m4 as ci,Bqe as cj,cTe as ck,oTe as cl,hTe as cm,ln as cn,Et as co,uHe as cp,lTe as cq,aTe as cr,zSt as cs,XHe as ct,bn as cu,DSt as cv,QRe as cw,Vh as cx,Uc as cy,Pi as cz,et as d,UI as e,we as f,Owe as g,yb as h,st as i,a as j,bvt as k,Y as l,k3e as m,rE as n,fr as o,Xg as p,X5 as q,x as r,Hs as s,Ye as t,KSt as u,zt as v,sr as w,YSt as x,ZSt as y,XSt as z};
|
|
1316
|
+
Start writing...`,title:"Document"})},{icon:Gte,label:"JSON",description:"Inspect structured data",action:()=>({type:"json",data:{message:"Your data here"},title:"JSON Data"})},{icon:ha,label:"Web Page",description:"Embed a URL",action:()=>({type:"url",url:"https://dorkos.ai",title:"Web Page"})}];function OR(e,t,n,s){return e.split("").reduce((i,o)=>i+o.charCodeAt(0),0)*(t+1)*7%(s-n)+n}function Zbt({onAction:e}){const t=Ds(),n=x.useId(),s=x.useMemo(()=>Array.from({length:6},(r,i)=>({x:OR(n,i*3,10,90),y:OR(n,i*3+1,10,80),size:OR(n,i*3+2,24,56),delay:i*.4})),[n]);return a.jsxs("div",{className:"relative flex h-full flex-col items-center justify-center overflow-hidden px-6",children:[!t&&s.map((r,i)=>a.jsx(te.div,{className:"border-border/40 absolute rounded-lg border",style:{left:`${r.x}%`,top:`${r.y}%`,width:r.size,height:r.size},initial:{opacity:0,scale:.6,rotate:-10},animate:{opacity:[0,.15,.08,.15],scale:[.6,1,.9,1],rotate:[-10,0,5,0]},transition:{duration:8,delay:r.delay,repeat:1/0,repeatType:"reverse",ease:"easeInOut"}},i)),a.jsxs(te.div,{className:"relative z-10 flex max-w-sm flex-col items-center gap-6 text-center",initial:t?!1:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.4,ease:"easeOut"},children:[a.jsx(te.div,{className:"bg-muted/50 text-muted-foreground flex size-14 items-center justify-center rounded-2xl",initial:t?!1:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.3,delay:.1},children:a.jsx(Jg,{className:"size-7"})}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"A blank canvas"}),a.jsxs("p",{className:"text-muted-foreground text-sm leading-relaxed",children:["Your agent can render documents, data, and web pages here.",a.jsx("br",{}),"Or pick a starting point below."]})]}),a.jsx(te.div,{className:"mt-2 flex w-full flex-col gap-2",initial:"hidden",animate:"visible",variants:t?{}:{visible:{transition:{staggerChildren:.08,delayChildren:.25}}},children:Ybt.map(({icon:r,label:i,description:o,action:l})=>a.jsxs(te.button,{variants:t?{}:{hidden:{opacity:0,y:8},visible:{opacity:1,y:0}},transition:{duration:.25},className:"border-border hover:bg-accent/50 flex items-center gap-3 rounded-lg border px-4 py-3 text-left transition-colors",onClick:()=>e(l()),children:[a.jsx(r,{className:"text-muted-foreground size-4 shrink-0"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("span",{className:"text-sm font-medium",children:i}),a.jsx("span",{className:"text-muted-foreground ml-2 text-xs",children:o})]})]},i))})]})]})}const Xbt=x.lazy(()=>ks(()=>import("./CanvasFileContent-BsJsR4E1.js"),[]).then(e=>({default:e.CanvasFileContent}))),Qbt=x.lazy(()=>ks(()=>import("./CanvasModel3dContent-ohjBCAJd.js"),__vite__mapDeps([3,4])).then(e=>({default:e.CanvasModel3dContent}))),Jbt=x.lazy(()=>ks(()=>import("./CanvasCsvContent-RYl7B_ua.js"),__vite__mapDeps([5,4])).then(e=>({default:e.CanvasCsvContent})));function e1t({documentId:e,content:t,onContentChange:n}){switch(t.type){case"url":case"browser":return a.jsx(pvt,{content:t},`${e}:${t.url}`);case"markdown":return a.jsx(kvt,{documentId:e,content:t,onContentChange:n},t.sourcePath??"generated");case"json":return a.jsx(Cvt,{content:t});case"image":return a.jsx(Vbt,{content:t});case"pdf":return a.jsx(Gbt,{content:t});case"widget":return a.jsx(Kbt,{content:t});case"mcp_app":return a.jsx(Wbt,{content:t});case"file":return a.jsx(x.Suspense,{fallback:a.jsx(IR,{}),children:a.jsx(Xbt,{documentId:e,content:t})});case"model3d":return a.jsx(x.Suspense,{fallback:a.jsx(IR,{}),children:a.jsx(Qbt,{content:t})});case"csv":return a.jsx(x.Suspense,{fallback:a.jsx(IR,{}),children:a.jsx(Jbt,{content:t})})}}function IR(){return a.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading…"})}function oO(){const e=we(c=>c.openDocuments),t=we(c=>c.activeDocumentId),n=we(c=>c.activateCanvasDocument),s=we(c=>c.closeCanvasDocument),r=we(c=>c.setActiveDocumentContent),i=we(c=>c.openCanvasDocument),o=e.find(c=>c.id===t)??null,l=e.map(c=>({id:c.id,sourceLabel:c.sourceLabel,contentType:c.content.type}));return a.jsxs(a.Fragment,{children:[a.jsx(ovt,{documents:l,activeDocumentId:t,onActivate:n,onClose:s}),a.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:o?a.jsx(e1t,{documentId:o.id,content:o.content,onContentChange:r}):a.jsx(Zbt,{onAction:i})})]})}function t1t(){return a.jsx("div",{"data-slot":"canvas",className:"flex h-full flex-col overflow-hidden",children:a.jsx(oO,{})})}function n1t(){const e=we(r=>r.canvasOpen),t=we(r=>r.setCanvasOpen),n=Us();if(!e)return null;const s=()=>t(!1);return n?a.jsx(Al,{open:!0,onOpenChange:r=>!r&&s(),children:a.jsxs(Rl,{side:"right",showCloseButton:!1,className:"bg-sidebar text-sidebar-foreground flex w-full flex-col gap-0 p-0 sm:max-w-full",children:[a.jsxs(Ml,{className:"sr-only",children:[a.jsx(Dl,{children:"Canvas"}),a.jsx(Hd,{children:"Agent-driven content pane."})]}),a.jsx(oO,{})]})}):a.jsxs(a.Fragment,{children:[a.jsx(HP,{className:"group relative flex w-2 items-center justify-center",children:a.jsx("div",{className:"bg-border group-hover:bg-ring h-full w-px transition-colors"})}),a.jsx(o_,{id:"agent-canvas",order:2,defaultSize:50,minSize:20,collapsible:!0,onCollapse:s,children:a.jsx("div",{className:"bg-sidebar text-sidebar-foreground flex h-full flex-col overflow-hidden rounded-lg border",children:a.jsx(oO,{})})})]})}function bfe(e){const t=we(n=>n.loadCanvasForSession);x.useEffect(()=>{e&&t(e)},[e,t])}const s1t=Object.freeze(Object.defineProperty({__proto__:null,AgentCanvas:n1t,CanvasContent:t1t,useCanvasPersistence:bfe},Symbol.toStringTag,{value:"Module"}));function r1t(){const[e]=Vc(),{runtime:t,prompt:n}=sI();return bfe(e),ydt(),a.jsx(ivt,{sessionId:e,launchRuntime:t,launchPrompt:n})}function i1t({onClearFilters:e,filterDescription:t}){return a.jsxs(te.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3,ease:"easeOut"},className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[a.jsx(hne,{className:"text-muted-foreground/50 size-10"}),a.jsx("p",{className:"text-muted-foreground text-sm",children:t?`No agents match ${t}`:"No agents match your filters"}),a.jsx(ge,{variant:"outline",size:"sm",onClick:e,children:"Clear filters"})]})}const lO=wne({search:bne({fields:[e=>nn(e),e=>e.name,e=>e.description,e=>e.capabilities.join(" ")]}),status:Hp({field:e=>e.healthStatus,options:["active","inactive","stale","unreachable"],multi:!0,label:"Status",labels:{active:"Active",inactive:"Inactive",stale:"Stale",unreachable:"Unreachable"},colors:{active:"text-emerald-400",inactive:"text-amber-400",stale:"text-muted-foreground",unreachable:"text-red-400"}}),runtime:Hp({field:e=>e.runtime,options:["claude-code","cursor","codex","other"],label:"Runtime",labels:{"claude-code":"Claude Code",cursor:"Cursor",codex:"Codex",other:"Other"}}),lastSeen:KOe({field:e=>e.lastSeenAt,presets:["1h","24h","7d","30d"],label:"Last seen"}),namespace:Hp({field:e=>e.namespace,options:[],dynamic:!0,label:"Namespace"})}),FG={name:{label:"Name",accessor:e=>nn(e)},lastSeen:{label:"Last seen",accessor:e=>e.lastSeenAt??"",direction:"desc"},status:{label:"Status",accessor:e=>e.healthStatus},registered:{label:"Registered",accessor:e=>e.registeredAt,direction:"desc"}},a1t={active:{label:"Active",dotClass:"bg-emerald-500"},inactive:{label:"Inactive",dotClass:"bg-amber-500"},stale:{label:"Stale",dotClass:"bg-muted-foreground/50"},unreachable:{label:"Unreachable",dotClass:"bg-red-500"}};function o1t({status:e}){const t=a1t[e];return a.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[a.jsx("span",{className:Y("size-2 rounded-full",t.dotClass)}),a.jsx("span",{className:"text-muted-foreground text-xs",children:t.label})]})}function l1t(e){return[{accessorKey:"name",header:"Agent",cell:({row:t})=>{const n=t.original,{color:s,emoji:r}=Dd(n);return a.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2 text-left",onClick:()=>e.onNavigate(n.projectPath??""),children:[a.jsx(Vb,{color:s,emoji:r,size:"xs",healthStatus:n.healthStatus}),a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"block truncate text-sm font-medium hover:underline",children:nn(n)}),n.description&&a.jsx("span",{className:"text-muted-foreground block max-w-[300px] truncate text-xs max-sm:hidden",children:n.description})]}),n.isDefault&&a.jsxs(zt,{variant:"outline",className:"shrink-0 text-[10px]",children:[a.jsx(YE,{className:"mr-0.5 size-2.5 fill-current"}),"Default"]})]})}},{accessorKey:"healthStatus",header:"Status",cell:({row:t})=>a.jsx(o1t,{status:t.original.healthStatus})},{accessorKey:"runtime",header:"Runtime",meta:{hideOnMobile:!0},cell:({row:t})=>a.jsx(zt,{variant:"secondary",className:"text-xs",children:t.original.runtime})},{accessorKey:"projectPath",header:"Project",meta:{hideOnMobile:!0},cell:({row:t})=>{const n=t.original.projectPath;if(!n)return a.jsx("span",{className:"text-muted-foreground text-xs",children:"—"});const s=n.split("/").filter(Boolean),r=s.length<=2?n:s.slice(-2).join("/");return a.jsx("span",{className:"text-muted-foreground max-w-[200px] truncate font-mono text-xs",children:r})}},{accessorKey:"sessionCount",header:"Sessions",meta:{hideOnMobile:!0},cell:({row:t})=>{const n=t.original.sessionCount;return n===0?a.jsx("span",{className:"text-muted-foreground text-xs",children:"—"}):a.jsxs(zt,{variant:"outline",className:"text-xs",children:[n," active"]})}},{accessorKey:"lastSeenAt",header:"Last Seen",cell:({row:t})=>a.jsx("span",{className:"text-muted-foreground text-xs tabular-nums",children:t.original.lastSeenAt?ii(t.original.lastSeenAt):"Never"})},{id:"actions",header:"",cell:({row:t})=>{const n=t.original;return a.jsxs("div",{className:"flex items-center justify-end gap-1",children:[a.jsx(ge,{variant:"ghost",size:"sm",className:"size-8 p-0",onClick:s=>{s.stopPropagation(),e.onStartSession(n.projectPath??"")},"aria-label":`Chat with ${nn(n)}`,children:a.jsx(Rd,{className:"size-4"})}),a.jsx(ge,{variant:"ghost",size:"sm",className:"size-8 p-0",onClick:s=>{s.stopPropagation(),e.onManage(n.projectPath??"")},"aria-label":`Manage ${nn(n)}`,children:a.jsx(qa,{className:"size-4"})})]})}}]}function c1t({agents:e,isLoading:t}){var w;const n=Hn(),s=je(),r=Ane(lO,{debounce:{search:200}}),{sessions:i}=bl(),o=x.useMemo(()=>[...new Set(e.map(C=>C.namespace).filter(C=>!!C))],[e]),l=x.useMemo(()=>Sne(e,lO,r.values,FG,{field:r.sortField,direction:r.sortDirection}),[e,r.values,r.sortField,r.sortDirection]),c=x.useMemo(()=>{const C={};for(const T of e)C[T.id]=rI(i,T.projectPath??null).length;return C},[e,i]),{data:u}=st({queryKey:["config"],queryFn:()=>s.getConfig(),staleTime:3e4}),d=x.useMemo(()=>l.map(C=>{var T;return{...C,sessionCount:c[C.id]??0,isDefault:((T=u==null?void 0:u.agents)==null?void 0:T.defaultAgent)===C.name}}),[l,c,(w=u==null?void 0:u.agents)==null?void 0:w.defaultAgent]),f=we(C=>C.setRightPanelOpen),m=we(C=>C.setActiveRightPanelTab),g=x.useCallback(C=>{yd.getState().openHub(C),m("agent-hub"),f(!0)},[m,f]),y=x.useCallback(C=>{n({to:"/session",search:{dir:C}})},[n]),b=x.useCallback(C=>{n({to:"/session",search:{dir:C}})},[n]),S=x.useMemo(()=>l1t({onNavigate:y,onManage:g,onStartSession:b}),[y,g,b]);return t?a.jsx("div",{className:"space-y-3 p-4",children:Array.from({length:3}).map((C,T)=>a.jsx(Jt,{className:"h-14 w-full rounded-xl"},T))}):a.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[a.jsxs(ji,{state:r,children:[a.jsx(ji.Search,{placeholder:"Filter agents..."}),a.jsx(ji.Primary,{name:"status"}),a.jsx(ji.AddFilter,{dynamicOptions:{namespace:o}}),a.jsx(ji.Sort,{options:FG}),a.jsx(ji.ResultCount,{count:l.length,total:e.length,noun:"agent"}),a.jsx(ji.ActiveFilters,{})]}),a.jsx(No,{className:"min-h-0 flex-1",children:a.jsx("div",{className:"px-4 pb-4",children:l.length===0&&e.length>0?a.jsx(i1t,{onClearFilters:r.clearAll,filterDescription:r.describeActive()}):a.jsx(d9e,{columns:S,data:d,emptyMessage:"No agents registered.",className:"border-0"})})})]})}const u1t={animate:{transition:{staggerChildren:.1}}},d1t={initial:{opacity:0},animate:{opacity:.2,transition:{duration:.3}}};function PR(){return a.jsxs(te.div,{variants:d1t,className:"rounded-xl border border-dashed px-4 py-3",children:[a.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[a.jsx("div",{className:"bg-muted size-3 rounded-full"}),a.jsx("div",{className:"bg-muted h-3 w-32 rounded"}),a.jsx("div",{className:"bg-muted h-3 w-16 rounded"}),a.jsx("div",{className:"bg-muted ml-auto h-3 w-10 rounded"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"bg-muted h-2.5 w-48 rounded"}),a.jsx("div",{className:"bg-muted h-2.5 w-20 rounded"})]})]})}function f1t(){const[e,t]=x.useState(!1);return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"relative w-full max-w-2xl px-4",children:[a.jsxs(te.div,{variants:u1t,initial:"initial",animate:"animate",className:"space-y-3",children:[a.jsx(PR,{}),a.jsx(PR,{}),a.jsx(PR,{})]}),a.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-4",children:[a.jsx("p",{className:"text-lg font-semibold",children:"Import Your Projects"}),a.jsxs(ge,{size:"sm",className:"gap-1.5",onClick:()=>t(!0),children:[a.jsx(N3e,{className:"size-3.5"}),"Search for Projects"]})]})]}),a.jsx(fi,{open:e,onOpenChange:t,children:a.jsxs(hi,{className:"max-w-2xl",children:[a.jsx(va,{children:a.jsx(Li,{children:"Import Projects"})}),a.jsx(mue,{})]})})]})}function h1t(){const{data:e,isLoading:t}=pJe(),n=(e==null?void 0:e.denied)??[];return t?a.jsx("div",{className:"flex items-center justify-center p-8",children:a.jsx(Sn,{className:"text-muted-foreground size-5 animate-spin"})}):n.length===0?a.jsx(pue,{icon:xb,headline:"No blocked paths",description:"When you deny agent paths during discovery, they appear here. This is a healthy state."}):a.jsx("div",{className:"space-y-2 p-4",children:n.map(s=>a.jsxs("div",{className:"flex items-center justify-between rounded-xl border px-4 py-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"font-mono text-sm",children:s.path}),s.reason&&a.jsx("p",{className:"text-muted-foreground text-xs",children:s.reason})]}),a.jsx(zt,{variant:"outline",className:"text-xs",children:s.deniedBy})]},s.path))})}function m1t(){return a.jsx(Alt,{})}const p1t=x.lazy(()=>ks(()=>import("./TopologyGraph-Dehijt2P.js"),__vite__mapDeps([6,7])).then(e=>({default:e.TopologyGraph})));function g1t(){const{view:e,agent:t}=ml({from:"/_shell/agents"}),n=t,s=Hn(),r=Us(),i=we(S=>S.setRightPanelOpen),o=we(S=>S.setActiveRightPanelTab),{open:l}=Wh(),[,c]=Id(),{data:u,isLoading:d,isError:f,refetch:m}=pP(),g=x.useMemo(()=>(u==null?void 0:u.namespaces.flatMap(S=>S.agents))??[],[u]),b=!(g.length>0)&&!d&&!f&&(e==="list"||e==="topology");return f?a.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[a.jsx("div",{className:"bg-destructive/10 rounded-xl p-3",children:a.jsx(fr,{className:"text-destructive size-6"})}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm font-medium",children:"Could not load agents"}),a.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"The mesh API is unreachable. Check that the server is running correctly."})]}),a.jsx(ge,{size:"sm",onClick:()=>void m(),className:"mt-1",children:"Retry"})]}):a.jsx(Ue,{mode:"wait",initial:!1,children:b?a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex h-full flex-col items-center justify-center",children:a.jsx(f1t,{})},"mode-a"):a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex h-full flex-col",children:a.jsxs(Ue,{mode:"wait",initial:!1,children:[e==="list"&&a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex h-full flex-col",children:a.jsx(c1t,{agents:g,isLoading:d})},"view-list"),e==="topology"&&a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"relative flex-1 overflow-hidden",children:a.jsxs("div",{className:"flex h-full",children:[a.jsx(te.div,{layout:!0,className:"min-w-0 flex-1",transition:{type:"spring",stiffness:300,damping:30},children:a.jsx("div",{className:"absolute inset-0",children:a.jsx(x.Suspense,{fallback:a.jsxs("div",{className:"text-muted-foreground flex h-full items-center justify-center text-sm",children:[a.jsx(Sn,{className:"mr-2 size-4 animate-spin"}),"Loading topology..."]}),children:a.jsx(p1t,{onSelectAgent:S=>s({to:"/agents",search:w=>({...w,agent:S})}),onOpenSettings:(S,w)=>{yd.getState().openHub(w),o("agent-hub"),i(!0)},onOpenChat:S=>c(S),onOpenAdapterCatalog:()=>l(),onGoToDiscovery:()=>s({to:"/agents",search:S=>({...S,view:"list"})})})})})}),r?a.jsx(Zh,{open:!!n,onOpenChange:S=>!S&&s({to:"/agents",search:w=>({...w,agent:void 0})}),children:a.jsx(Xh,{children:n&&a.jsx(BV,{agentId:n,onClose:()=>s({to:"/agents",search:S=>({...S,agent:void 0})})})})}):a.jsx(Ue,{children:n&&a.jsx(te.div,{initial:{width:0,opacity:0},animate:{width:256,opacity:1},exit:{width:0,opacity:0},transition:{type:"spring",stiffness:300,damping:30},className:"bg-background overflow-y-auto border-l",children:a.jsx(BV,{agentId:n,onClose:()=>s({to:"/agents",search:S=>({...S,agent:void 0})})})})})]})},"view-topology"),e==="denied"&&a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:a.jsx(h1t,{})},"view-denied"),e==="access"&&a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:a.jsx(m1t,{})},"view-access")]})},"mode-b")})}const x1t={initial:{opacity:0,y:6},animate:{opacity:1,y:0,transition:{duration:.2,ease:"easeOut"}}};function y1t(){const e=x.useId(),t=x.useMemo(()=>`${e.split("").reduce((s,r)=>s+r.charCodeAt(0),0)%40+50}%`,[e]);return a.jsxs(Tc,{children:[a.jsx(ra,{className:"w-28 py-1.5 pr-0 pl-2 max-sm:hidden",children:a.jsx(Jt,{className:"h-3 w-20"})}),a.jsx(ra,{className:"w-24 py-1.5 pr-0 max-sm:hidden",children:a.jsx(Jt,{className:"h-5 w-20 rounded-full"})}),a.jsx(ra,{className:"py-1.5 max-sm:pl-2",children:a.jsx(Jt,{className:"h-3 rounded",style:{width:t}})}),a.jsx(ra,{className:"w-16 py-1.5 max-sm:w-10"})]})}function v1t(){return a.jsxs("div",{"data-slot":"activity-timeline-skeleton",className:"space-y-1",children:[a.jsx("div",{className:"py-2",children:a.jsx(Jt,{className:"h-3 w-16 rounded"})}),a.jsx(f0,{children:a.jsx(h0,{children:Array.from({length:5}).map((e,t)=>a.jsx(y1t,{},t))})})]})}function b1t({items:e,isLoading:t,isFiltered:n,className:s}){const r=x.useMemo(()=>Bat(e,new Date),[e]),{containerRef:i,handleKeyDown:o}=Fat(e.length);return t&&e.length===0?a.jsx("div",{"data-slot":"activity-timeline",className:Y("px-4",s),children:a.jsx(v1t,{})}):e.length===0?a.jsx("div",{"data-slot":"activity-timeline",className:Y(s),children:a.jsx(Zat,{isFiltered:n})}):a.jsx("div",{ref:i,onKeyDown:o,"data-slot":"activity-timeline",className:Y("px-4",s),children:r.map(l=>a.jsxs("section",{children:[a.jsx(qat,{label:l.label}),a.jsx(te.div,{variants:x1t,initial:"initial",animate:"animate",children:a.jsx(f0,{children:a.jsx(h0,{children:l.items.map(c=>a.jsx(sue,{item:c},c.id))})})})]},l.label))})}function S1t({onLoadMore:e,isFetching:t,hasNextPage:n,className:s}){return n?a.jsx(te.div,{"data-slot":"activity-load-more",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.1},className:Y("flex justify-center px-4 py-4",s),children:a.jsxs(ge,{variant:"outline",size:"sm",onClick:e,disabled:t,className:"gap-2",children:[t&&a.jsx(Sn,{className:"size-3.5 animate-spin","aria-hidden":!0}),"Load 50 more events"]})}):null}function w1t(){const{queryFilters:e,isFiltered:t}=NP(),n=Lat(),{data:s,isLoading:r,isFetchingNextPage:i,hasNextPage:o,fetchNextPage:l}=Pat(e),c=x.useMemo(()=>(s==null?void 0:s.pages.flatMap(u=>u.items))??[],[s]);return a.jsx(No,{className:"h-full",children:a.jsxs("div",{className:"mx-auto max-w-4xl space-y-4 py-6 sm:py-8",children:[a.jsx(sot,{lastVisitedAt:n,items:c,className:"mx-4"}),a.jsx(b1t,{items:c,isLoading:r,isFiltered:t}),a.jsx(S1t,{onLoadMore:()=>void l(),isFetching:i,hasNextPage:!!o})]})})}function k1t(){const e=Ud(),{data:t=[],isLoading:n,isError:s,refetch:r}=WT(e),[i,o]=x.useState(!1),[l,c]=x.useState(),[u,d]=x.useState(null),f=t.some(N=>N.agentId),{data:m}=ba(void 0,f||!n),g=x.useMemo(()=>{const N=new Map;for(const R of(m==null?void 0:m.agents)??[])N.set(R.id,R);return N},[m]),{externalTrigger:y,clear:b}=Ub(),[S,w]=x.useState(!1);y&&!S&&!i?(w(!0),c(void 0),o(!0),b()):!y&&S&&w(!1);const C=N=>{d(N),c(void 0),o(!0)},T=()=>{d(null),c(void 0),o(!0)},E=N=>{c(N),o(!0)},j=N=>{o(N),N||d(null)};if(!e)return a.jsx(h4,{icon:pce.tasks,name:"Tasks",description:"Tasks runs AI agent tasks on a schedule. Start DorkOS with the --tasks flag to enable it.",command:"dorkos --tasks"});if(s)return a.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[a.jsx("div",{className:"bg-destructive/10 rounded-xl p-3",children:a.jsx(fr,{className:"text-destructive size-6"})}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm font-medium",children:"Could not load tasks"}),a.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"The tasks API is unreachable. Check that the server is running correctly."})]}),a.jsx(ge,{size:"sm",onClick:()=>void r(),className:"mt-1",children:"Retry"})]});const _=t.length>0;return a.jsxs(a.Fragment,{children:[!_&&!n?a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.15},className:"flex h-full flex-col items-center justify-center",children:a.jsx(kce,{onCreateWithPreset:C,onCreateBlank:T})}):a.jsx(te.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.15},className:"flex h-full flex-col",children:a.jsx(uet,{tasks:t,isLoading:n,agentMap:g,onEditTask:E})}),a.jsx(SD,{open:i,onOpenChange:j,editTask:l,initialPreset:u})]})}function C1t(){const e=je(),t=Hde();return Bt({mutationFn:({id:n,pinned:s})=>e.pinWorkspace(n,s),onSuccess:()=>t()})}function E1t(){const e=je(),t=Hde();return Bt({mutationFn:({id:n,force:s})=>e.removeWorkspace(n,s),onSuccess:n=>{if(n.removed)return t()}})}function T1t({workspace:e}){const t=C1t(),n=E1t(),[s,r]=x.useState(!1),[i,o]=x.useState(!1),l=async c=>{const u=await n.mutateAsync({id:e.id,force:c});if(!u.removed&&u.blocked==="dirty"){o(!0);return}r(!1),o(!1)};return a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx(ge,{variant:"ghost",size:"sm","aria-label":e.pinned?"Unpin workspace":"Pin workspace",onClick:()=>t.mutate({id:e.id,pinned:!e.pinned}),disabled:t.isPending,children:e.pinned?a.jsx(Z5,{className:"size-4"}):a.jsx(gb,{className:"size-4"})})}),a.jsx(yn,{side:"top",children:e.pinned?"Unpin — allow automatic cleanup":"Pin — exempt from automatic cleanup"})]}),a.jsxs(gn,{children:[a.jsx(xn,{asChild:!0,children:a.jsx(ge,{variant:"ghost",size:"sm","aria-label":"Remove workspace",onClick:()=>{o(!1),r(!0)},children:a.jsx(wo,{className:"size-4"})})}),a.jsx(yn,{side:"top",children:"Remove — delete this workspace’s checkout"})]}),a.jsx(Sl,{open:s,onOpenChange:c=>{r(c),c||o(!1)},children:a.jsxs(ko,{children:[a.jsxs(wl,{children:[a.jsx(Co,{children:i?"Force remove workspace?":"Remove workspace?"}),a.jsx(Eo,{children:i?`${e.key} has uncommitted or unpushed work. Force-removing deletes it permanently.`:`Remove the ${e.key} workspace? Its checkout will be deleted.`})]}),a.jsxs(kl,{children:[a.jsx(_o,{children:"Cancel"}),a.jsx(To,{onClick:c=>{c.preventDefault(),l(i)},disabled:n.isPending,children:i?"Force remove":"Remove"})]})]})})]})}const _1t={ready:"bg-emerald-500",provisioning:"bg-amber-500",failed:"bg-destructive",removing:"bg-muted-foreground"};function N1t({workspace:e}){var r,i,o;const t=Hn(),n=Bce(e.portBase),s=(((r=e.dirty)==null?void 0:r.uncommitted.length)??0)+(((i=e.dirty)==null?void 0:i.untracked.length)??0)+(((o=e.dirty)==null?void 0:o.unpushed)??0);return a.jsxs("div",{className:"bg-card rounded-xl border p-4",children:[a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx($p,{className:"text-muted-foreground size-4 shrink-0"}),a.jsx("span",{className:"truncate font-medium",children:e.key}),e.pinned&&a.jsx(gb,{className:"text-muted-foreground size-3.5 shrink-0"})]}),a.jsxs("div",{className:"text-muted-foreground mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs",children:[a.jsxs("span",{className:"inline-flex items-center gap-1",children:[a.jsx("span",{className:Y("size-1.5 rounded-full",_1t[e.status])}),e.status]}),a.jsxs("span",{children:["· ",e.provider]}),a.jsxs("span",{title:`DORKOS ${n.DORKOS_PORT} · VITE ${n.VITE_PORT} · SITE ${n.SITE_PORT}`,children:["· :",n.DORKOS_PORT]}),e.dirty&&(e.dirty.dirty?a.jsxs("span",{className:"text-amber-600",children:["· ● ",s," changes"]}):a.jsx("span",{children:"· clean"}))]})]}),a.jsx(T1t,{workspace:e})]}),a.jsx("div",{className:"mt-3 border-t border-dashed pt-3",children:e.sessions.length===0?a.jsx("p",{className:"text-muted-foreground text-xs",children:"No sessions"}):a.jsx("ul",{className:"flex flex-col gap-1.5",children:e.sessions.map(l=>a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>t({to:"/session",search:{session:l.sessionId,dir:e.path}}),className:"text-foreground/80 hover:text-foreground focus-visible:ring-ring inline-flex w-full items-center gap-2 truncate rounded text-left text-xs focus-visible:ring-2 focus-visible:outline-none",children:[a.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-emerald-500"}),a.jsx("span",{className:"truncate",children:l.title||l.sessionId})]})},l.sessionId))})})]})}function j1t(){const{workspaces:e,isLoading:t}=H0t(),n=x.useMemo(()=>{const s=new Map;for(const r of e){const i=s.get(r.projectKey)??[];i.push(r),s.set(r.projectKey,i)}return[...s.entries()].sort(([r],[i])=>r.localeCompare(i))},[e]);return a.jsxs("div",{className:"container-default mx-auto px-4 py-6",children:[a.jsxs("header",{className:"mb-6",children:[a.jsx("h1",{className:"text-xl font-semibold",children:"Workspaces"}),a.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Isolated, server-managed checkouts — one per unit of work, bound to sessions via cwd."})]}),t?a.jsx("p",{className:"text-muted-foreground text-sm",children:"Loading workspaces…"}):n.length===0?a.jsxs("div",{className:"bg-card rounded-xl border p-10 text-center",children:[a.jsx(ene,{className:"text-muted-foreground/60 mx-auto size-8"}),a.jsx("p",{className:"mt-3 font-medium",children:"No workspaces yet"}),a.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"A workspace is provisioned the first time an agent session is bound to a unit of work."})]}):a.jsx("div",{className:"flex flex-col gap-8",children:n.map(([s,r])=>a.jsxs("section",{children:[a.jsxs("h2",{className:"mb-3 flex items-center gap-2 text-sm font-semibold",children:[s,a.jsx(zt,{variant:"secondary",children:r.length})]}),a.jsx("div",{className:"flex flex-col gap-2",children:r.map(i=>a.jsx(N1t,{workspace:i},i.id))})]},s))})]})}function A1t(){return a.jsx("div",{className:"flex h-full flex-col overflow-y-auto",children:a.jsx(Nut,{})})}function R1t(){return a.jsx("div",{className:"flex h-full flex-col",children:a.jsx(Rut,{})})}const Sfe=c0e()({component:()=>a.jsx(SO,{}),notFoundComponent:$le}),Yc=Lc({getParentRoute:()=>Sfe,id:"_shell",component:kdt}),M1t=vb(se({session:z().optional(),dir:z().optional(),runtime:z().optional(),prompt:z().optional()})),D1t=vb(se({detail:Je(["dead-letter","failed-run","offline-agent"]).optional(),itemId:z().optional()})),O1t=vb(se({view:Je(["list","topology","denied","access"]).optional().default("list"),sort:z().optional().default("lastSeen:desc"),agent:z().optional()}).merge(lO.searchValidator)),I1t=vb(Mut),P1t=Lc({getParentRoute:()=>Yc,path:"/",validateSearch:Kv(D1t),component:Fdt,beforeLoad:({location:e})=>{const t=new URLSearchParams(e.searchStr),n=t.get("session");if(n)throw yk({to:"/session",search:{session:n,dir:t.get("dir")??void 0}})}});function L1t({context:{queryClient:e},location:t}){const n=new URLSearchParams(t.searchStr);if(n.get("session"))return;const r=n.get("dir")??void 0,i=n.get("runtime")??void 0,o=n.get("prompt")??void 0,l=e.getQueryData(["sessions",r??null]);throw l&&l.length>0?yk({to:"/session",search:{session:l[0].id,dir:r,runtime:i},replace:!0}):yk({to:"/session",search:{session:crypto.randomUUID(),dir:r,runtime:i,prompt:o},replace:!0})}const F1t=Lc({getParentRoute:()=>Yc,path:"/session",validateSearch:Kv(M1t),component:r1t,loader:L1t}),z1t=Lc({getParentRoute:()=>Yc,path:"/agents",validateSearch:Kv(O1t),component:g1t}),B1t=Lc({getParentRoute:()=>Yc,path:"/tasks",component:k1t}),$1t=Lc({getParentRoute:()=>Yc,path:"/workspaces",component:j1t}),H1t=Lc({getParentRoute:()=>Yc,path:"/marketplace",validateSearch:Kv(I1t),component:A1t}),U1t=Lc({getParentRoute:()=>Yc,path:"/marketplace/sources",component:R1t}),V1t=vb(se({categories:z().optional(),actorType:z().optional(),actorId:z().optional(),since:z().optional()})),q1t=Lc({getParentRoute:()=>Yc,path:"/activity",validateSearch:Kv(V1t),component:w1t}),G1t=Sfe.addChildren([Yc.addChildren([P1t,F1t,z1t,B1t,$1t,q1t,H1t,U1t])]);function K1t(e){return C0e({routeTree:G1t,context:{queryClient:e},defaultPreload:"intent",defaultErrorComponent:rQe,defaultNotFoundComponent:$le})}const W1t=["session.started","session.ended","session.switched","turn.started","turn.completed","tool.activity","relay.message"],Y1t=["session","turn","tool","relay"],Z1t=[...W1t,...Y1t];function X1t(e){return e.slice(0,e.indexOf("."))}function zG(e,t){return t.includes(e)||t.includes(X1t(e))}const Q1t=se({events:ft(Je(Z1t)).optional()}),J1t=se({key:z().regex(/^[a-z][a-z0-9_]*$/),label:z().min(1),description:z().optional(),placeholder:z().optional(),required:rt().default(!1),group:z().optional()}),eSt=se({label:z().min(1),value:pl([z(),Ee()])}),tSt=se({type:Je(["text","number","boolean","select"]),key:z().regex(/^[a-z][a-z0-9_]*$/),label:z().min(1),description:z().optional(),placeholder:z().optional(),default:pl([z(),Ee(),rt()]).optional(),required:rt().default(!1),group:z().optional(),options:ft(eSt).optional(),min:Ee().optional(),max:Ee().optional()}),nSt=se({baseUrl:z().url(),authHeader:z().default("Authorization"),authType:Je(["Bearer","Basic","Token","Custom"]).default("Bearer"),authSecret:z(),pathRewrite:Br(z(),z()).optional()}),sSt=se({serverEntry:z().default("./server.ts"),externalHosts:ft(z().url()).optional(),secrets:ft(J1t).optional(),settings:ft(tSt).optional()});se({id:z().min(1).regex(/^[a-z0-9][a-z0-9-]*$/),name:z().min(1),version:z().regex(/^\d+\.\d+\.\d+$/),description:z().optional(),author:z().optional(),minHostVersion:z().optional(),contributions:Br(z(),rt()).optional(),permissions:ft(z()).optional(),capabilities:Q1t.optional(),serverCapabilities:sSt.optional(),dataProxy:nSt.optional(),defaultEnabled:rt().optional(),canDisable:rt().optional()});const rSt=50,wfe="puzzle";function BG(e,t,n=[]){const s=[];return{api:{id:e,registerComponent(i,o,l,c){const u=iSt(i,`${e}:${o}`,l,c),d=t.registry.register(i,u);return s.push(d),d},registerCommand(i,o,l,c){const u=`ext:${e}:${i}`,d={id:`${e}:${i}`,label:o,icon:(c==null?void 0:c.icon)??wfe,action:u,shortcut:c==null?void 0:c.shortcut,category:"feature"},f=t.registry.register("command-palette.items",d);t.registerCommandHandler(u,l);const m=()=>{f(),t.unregisterCommandHandler(u)};return s.push(m),m},registerDialog(i,o){const l=`${e}:${i}`,c={id:l,component:o,openStateKey:`ext-dialog:${l}`},u=t.registry.register("dialog",c);s.push(u);let d=!1;return{open:()=>{d=!0},close:()=>{d=!1},get _openState(){return d}}},registerSettingsTab(i,o,l){const c={id:`${e}:${i}`,label:o,icon:void 0,component:l},u=t.registry.register("settings.tabs",c);return s.push(u),u},executeCommand(i){Kk(t.dispatcherContext,i,"agent")},openCanvas(i){Kk(t.dispatcherContext,{action:"open_canvas",content:i},"agent")},navigate(i){t.navigate({to:i})},getState(){const i=t.appStore.getState();return $G(i)},subscribe(i,o){const l=t.appStore.subscribe(c=>i($G(c)),o);return s.push(l),l},events:{subscribe(i,o){const l=i.filter(d=>zG(d,n)),c=i.filter(d=>!zG(d,n));if(c.length>0&&console.warn(`[ExtensionAPI] ${e}: events.subscribe rejected undeclared kind(s): ${c.join(", ")}. Add them to manifest capabilities.events.`),l.length===0)return()=>{};const u=t.eventBridge.subscribe(l,o);return s.push(u),u}},async loadData(){const i=await fetch(`/api/extensions/${e}/data`);if(i.status===204)return null;if(!i.ok)throw new Error(`loadData failed: ${i.status}`);return i.json()},async saveData(i){const o=await fetch(`/api/extensions/${e}/data`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!o.ok)throw new Error(`saveData failed: ${o.status}`)},notify(i,o){const l=(o==null?void 0:o.type)??"info";Ye[l](i)},isSlotAvailable(i){return t.availableSlots.has(i)}},cleanups:s}}function $G(e){const t=e??{};return{currentCwd:t.selectedCwd??null,activeSessionId:t.sessionId??null,agentId:null}}function iSt(e,t,n,s){const r={id:t,priority:(s==null?void 0:s.priority)??rSt};switch(e){case"dashboard.sections":return{...r,component:n};case"sidebar.tabs":return{...r,component:n,label:t,icon:void 0};case"sidebar.footer":return{...r,onClick:()=>{},label:t,icon:void 0};case"header.actions":return{...r,onClick:()=>{},label:t,icon:void 0};case"right-panel":return{...r,component:n,title:t,icon:void 0,headerActions:void 0,visibleWhen:void 0};case"settings.tabs":return{...r,component:n,label:t,icon:void 0};case"dialog":return{...r,component:n,openStateKey:`ext:${t}`};case"command-palette.items":return{...r,label:t,icon:wfe,action:`ext:${t}`,category:"feature"};default:return console.warn("[ExtensionAPI] Unknown slot:",e),{...r,component:n}}}function aSt({extensionId:e,status:t}){const[n,s]=x.useState(String(t.value??"")),[r,i]=x.useState(!1),o=async()=>{i(!0);try{const l=await fetch(`/api/extensions/${e}/settings/${t.key}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})});if(!l.ok)throw new Error(`${l.status}`);Ye.success(`${t.label} saved`)}catch{Ye.error(`Failed to save ${t.label}`)}finally{i(!1)}};return a.jsx(cs,{label:t.label,description:t.description??"",orientation:"vertical",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(sn,{value:n,onChange:l=>s(l.target.value),placeholder:t.placeholder??t.key,className:"h-8 min-w-0 flex-1 text-sm",onKeyDown:l=>{l.key==="Enter"&&o()}}),a.jsx(ge,{size:"sm",onClick:o,disabled:r,className:"h-8",children:"Save"})]})})}function oSt({extensionId:e,status:t}){const[n,s]=x.useState(String(t.value??"")),[r,i]=x.useState(!1),o=async()=>{const l=Number(n);if(!Number.isNaN(l)){i(!0);try{const c=await fetch(`/api/extensions/${e}/settings/${t.key}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:l})});if(!c.ok)throw new Error(`${c.status}`);Ye.success(`${t.label} saved`)}catch{Ye.error(`Failed to save ${t.label}`)}finally{i(!1)}}};return a.jsx(cs,{label:t.label,description:t.description??"",orientation:"vertical",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(sn,{type:"number",value:n,onChange:l=>s(l.target.value),placeholder:t.placeholder??t.key,min:t.min,max:t.max,className:"h-8 min-w-0 flex-1 text-sm",onKeyDown:l=>{l.key==="Enter"&&o()}}),a.jsx(ge,{size:"sm",onClick:o,disabled:r,className:"h-8",children:"Save"})]})})}function lSt({extensionId:e,status:t,onChanged:n}){const[s,r]=x.useState(!1),i=!!t.value,o=async l=>{r(!0);try{const c=await fetch(`/api/extensions/${e}/settings/${t.key}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:l})});if(!c.ok)throw new Error(`${c.status}`);Ye.success(`${t.label} ${l?"enabled":"disabled"}`),await n()}catch{Ye.error(`Failed to update ${t.label}`)}finally{r(!1)}};return a.jsx(cs,{label:t.label,description:t.description??"",children:a.jsx(sr,{checked:i,onCheckedChange:o,disabled:s})})}function cSt({extensionId:e,status:t,onChanged:n}){const[s,r]=x.useState(!1),i=async o=>{var l;r(!0);try{const u=((l=t.options)==null?void 0:l.every(f=>typeof f.value=="number"))?Number(o):o,d=await fetch(`/api/extensions/${e}/settings/${t.key}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:u})});if(!d.ok)throw new Error(`${d.status}`);Ye.success(`${t.label} updated`),await n()}catch{Ye.error(`Failed to update ${t.label}`)}finally{r(!1)}};return a.jsx(cs,{label:t.label,description:t.description??"",orientation:"vertical",children:a.jsxs(On,{value:String(t.value??""),onValueChange:i,disabled:s,children:[a.jsx(_n,{className:"h-8 text-sm",children:a.jsx(In,{})}),a.jsx(Nn,{children:(t.options??[]).map(o=>a.jsx(mt,{value:String(o.value),children:o.label},String(o.value)))})]})})}function uSt(e,t,n,s){const r=new Map,i=(o,l)=>{r.has(o)||r.set(o,[]),r.get(o).push(l)};for(const o of e)i(o.group,{kind:"secret",declaration:o,isSet:t.get(o.key)??!1});for(const o of s){const l=n.find(c=>c.key===o.key);l&&i(l.group,{kind:"setting",declaration:l,status:o})}return r}function dSt({extensionId:e,secrets:t,settings:n}){const[s,r]=x.useState(new Map),[i,o]=x.useState([]),[l,c]=x.useState(!0),u=x.useCallback(async()=>{try{const[y,b]=await Promise.all([t.length>0?fetch(`/api/extensions/${e}/secrets`):Promise.resolve(null),n.length>0?fetch(`/api/extensions/${e}/settings`):Promise.resolve(null)]);if(y!=null&&y.ok){const S=await y.json();r(new Map(S.map(w=>[w.key,w.isSet])))}if(b!=null&&b.ok){const S=await b.json();o(S)}}catch{}finally{c(!1)}},[e,t.length,n.length]);if(x.useEffect(()=>{u()},[u]),l)return a.jsx(vr,{children:a.jsx(dr,{children:a.jsx("div",{className:"text-muted-foreground py-4 text-center text-sm",children:"Loading…"})})});const d=uSt(t,s,n,i),f=d.get(void 0),m=[...d.entries()].filter(([y])=>y!==void 0);function g(y){if(y.kind==="secret")return a.jsx(hSt,{extensionId:e,secret:y.declaration,isSet:y.isSet,onChanged:u},y.declaration.key);switch(y.status.type){case"text":return a.jsx(aSt,{extensionId:e,status:y.status},y.declaration.key);case"number":return a.jsx(oSt,{extensionId:e,status:y.status},y.declaration.key);case"boolean":return a.jsx(lSt,{extensionId:e,status:y.status,onChanged:u},y.declaration.key);case"select":return a.jsx(cSt,{extensionId:e,status:y.status,onChanged:u},y.declaration.key)}}return a.jsxs(a.Fragment,{children:[f&&f.length>0&&a.jsx(vr,{children:a.jsx(dr,{children:f.map(g)})}),m.map(([y,b])=>a.jsx(fSt,{groupName:y,items:b,renderItem:g},y))]})}function fSt({groupName:e,items:t,renderItem:n}){const[s,r]=x.useState(!0);return a.jsx(WI,{open:s,onOpenChange:r,trigger:e,children:t.map(n)})}function hSt({extensionId:e,secret:t,isSet:n,onChanged:s}){const[r,i]=x.useState(""),[o,l]=x.useState(!1),c=async()=>{if(r.trim()){l(!0);try{const f=await fetch(`/api/extensions/${e}/secrets/${t.key}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:r})});if(!f.ok)throw new Error(`${f.status}`);i(""),Ye.success(`${t.label} saved`),await s()}catch{Ye.error(`Failed to save ${t.label}`)}finally{l(!1)}}},u=async()=>{l(!0);try{const f=await fetch(`/api/extensions/${e}/secrets/${t.key}`,{method:"DELETE"});if(!f.ok)throw new Error(`${f.status}`);Ye.success(`${t.label} removed`),await s()}catch{Ye.error(`Failed to remove ${t.label}`)}finally{l(!1)}},d=t.description??(t.required?"Required":"Optional");return n?a.jsx(cs,{label:t.label,description:d,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(zt,{variant:"outline",className:"text-muted-foreground gap-1",children:[a.jsx(Lt,{className:"size-3"}),"Configured"]}),a.jsxs(ge,{variant:"ghost",size:"sm",onClick:u,disabled:o,className:"text-muted-foreground hover:text-destructive h-7 px-2 text-xs",children:[a.jsx(es,{className:"size-3"}),"Clear"]})]})}):a.jsx(cs,{label:t.label,description:d,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(il,{value:r,onChange:f=>i(f.target.value),placeholder:t.placeholder??t.key,className:"h-8 w-48 text-sm",onKeyDown:f=>{f.key==="Enter"&&c()}}),a.jsx(ge,{size:"sm",onClick:c,disabled:o||!r.trim(),className:"h-8",children:"Save"})]})})}async function HG(){const e=await fetch("/api/extensions");return e.ok?e.json():(console.error("[extensions] Failed to fetch extension list:",e.status),[])}async function mSt(e){try{return await ks(()=>import(`/api/extensions/${e}/bundle`),[])}catch(t){return console.error(`[extensions] Failed to import ${e}:`,t),null}}async function UG(e){if(!(!e.hasServerEntry&&!e.hasDataProxy))try{const t=await fetch(`/api/extensions/${e.id}/init-server`,{method:"POST"});if(!t.ok){const n=await t.json().catch(()=>({error:"Unknown error"}));console.warn(`[extensions] Server init failed for ${e.id}:`,n.error??t.statusText)}}catch(t){console.error(`[extensions] Server init error for ${e.id}:`,t)}}class pSt{constructor(t){Ze(this,"loaded",new Map);Ze(this,"deps");Ze(this,"disposed",!1);this.deps=t}async initialize(){var o;const t=await HG(),n=t.filter(l=>l.status==="compiled"&&l.bundleReady);if(n.length===0)return console.log("[extensions] No extensions to load"),{extensions:t,loaded:this.loaded};const s=await Promise.all(n.map(async l=>({rec:l,module:await mSt(l.id)}))),r=[],i=[];for(const{rec:l,module:c}of s){if(this.disposed)break;if(c)try{const{api:u,cleanups:d}=BG(l.id,this.deps,((o=l.manifest.capabilities)==null?void 0:o.events)??[]),f=c.activate(u);this.autoRegisterConfigTab(l,d);const m={id:l.id,manifest:l.manifest,module:c,api:u,cleanups:d,deactivate:typeof f=="function"?f:void 0};this.loaded.set(l.id,m),r.push(`${l.manifest.name} v${l.manifest.version}`),i.push(UG(l))}catch(u){console.error(`[extensions] Failed to activate ${l.id}:`,u)}}return await Promise.all(i),r.length>0&&console.log(`[extensions] Activated: ${r.join(", ")}`),{extensions:t,loaded:this.loaded}}deactivateAll(){var t;this.disposed=!0;for(const[n,s]of this.loaded){try{(t=s.deactivate)==null||t.call(s)}catch(r){console.error(`[extensions] Error calling deactivate for ${n}:`,r)}for(const r of s.cleanups)try{r()}catch(i){console.error(`[extensions] Error in cleanup for ${n}:`,i)}}this.loaded.clear()}async reloadExtensions(t){var s;for(const r of t){const i=this.loaded.get(r);if(i){try{(s=i.deactivate)==null||s.call(i)}catch(o){console.error(`[extensions] Error deactivating ${r}:`,o)}for(const o of i.cleanups)try{o()}catch(l){console.error(`[extensions] Error in cleanup for ${r}:`,l)}this.loaded.delete(r)}}const n=await HG();for(const r of t){const i=n.find(o=>o.id===r);if(!(!i||i.status!=="compiled"||!i.bundleReady))try{const o=await ks(()=>import(`/api/extensions/${r}/bundle?t=${Date.now()}`),[]),{api:l,cleanups:c}=BG(r,this.deps),u=o.activate(l);this.autoRegisterConfigTab(i,c),this.loaded.set(r,{id:r,manifest:i.manifest,module:o,api:l,cleanups:c,deactivate:typeof u=="function"?u:void 0}),await UG(i),console.log(`[extensions] Hot-reloaded: ${i.manifest.name} v${i.manifest.version}`)}catch(o){console.error(`[extensions] Failed to hot-reload ${r}:`,o)}}return{extensions:n,loaded:this.loaded}}getLoaded(){return this.loaded}autoRegisterConfigTab(t,n){var d,f;const s=(d=t.manifest.serverCapabilities)==null?void 0:d.secrets,r=(f=t.manifest.serverCapabilities)==null?void 0:f.settings;if(!(s!=null&&s.length)&&!(r!=null&&r.length))return;const i=t.id,o=`${i}:settings`,l=s??[],c=r??[],u=this.deps.registry.register("settings.tabs",{id:o,label:t.manifest.name,icon:qa,component:function(){return x.createElement(dSt,{extensionId:i,secrets:l,settings:c})},priority:90});n.push(u)}}const VG=1500;async function gSt(e){try{const t=await fetch("/api/extensions/cwd-changed",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e})});return t.ok?await t.json():(console.error("[extensions] CWD change notification failed:",t.status),null)}catch(t){return console.error("[extensions] CWD change notification error:",t),null}}function xSt(){const e=we(n=>n.selectedCwd),t=x.useRef(void 0);x.useEffect(()=>{if(t.current===void 0){t.current=e;return}t.current!==e&&(t.current=e,gSt(e).then(n=>{!n||!n.changed||(Ye.info("Project extensions changed. Reloading...",{duration:VG}),setTimeout(()=>{location.reload()},VG))}))},[e])}const Eh={all:["extensions"],lists:()=>[...Eh.all,"list"],detail:e=>[...Eh.all,"detail",e]};function YSt(){return st({queryKey:Eh.lists(),queryFn:async()=>{const e=await fetch("/api/extensions");if(!e.ok)throw new Error(`Failed to fetch extensions: ${e.status}`);return e.json()},staleTime:1e4,refetchInterval:3e4,refetchIntervalInBackground:!1})}function ZSt(){const e=et();return Bt({mutationFn:async t=>{const n=await fetch(`/api/extensions/${t}/enable`,{method:"POST"});if(!n.ok)throw new Error(`Failed to enable extension '${t}': ${n.status}`);return n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:Eh.lists()})}})}function XSt(){const e=et();return Bt({mutationFn:async t=>{const n=await fetch(`/api/extensions/${t}/disable`,{method:"POST"});if(!n.ok)throw new Error(`Failed to disable extension '${t}': ${n.status}`);return n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:Eh.lists()})}})}function QSt(){const e=et();return Bt({mutationFn:async()=>{const t=await fetch("/api/extensions/reload",{method:"POST"});if(!t.ok)throw new Error(`Failed to reload extensions: ${t.status}`);return t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:Eh.lists()})}})}const kfe={extensions:[],loaded:new Map,ready:!1},Cfe=x.createContext(kfe);function JSt(){return x.useContext(Cfe)}function ySt({deps:e,children:t}){const[n,s]=x.useState(kfe),r=x.useRef(null),i=et();return xSt(),x.useEffect(()=>{const o=new pSt(e);return r.current=o,o.initialize().then(({extensions:l,loaded:c})=>{s({extensions:l,loaded:c,ready:!0})}).catch(l=>{console.error("[extensions] Failed to initialize:",l),s(c=>({...c,ready:!0}))}),()=>{o.deactivateAll(),r.current=null}},[]),kg("extension_reloaded",o=>{const l=r.current;if(!l)return;const c=o;(async()=>{try{const{extensions:u,loaded:d}=await l.reloadExtensions(c.extensionIds);s({extensions:u,loaded:d,ready:!0}),i.invalidateQueries({queryKey:Eh.lists()})}catch(u){console.error("[extensions] Hot reload failed:",u)}})()}),a.jsx(Cfe.Provider,{value:n,children:t})}function vSt(e){if(typeof e!="object"||e===null)return null;const t=e;return typeof t.id=="string"&&typeof t.from=="string"&&typeof t.subject=="string"?{messageId:t.id,from:t.from,subject:t.subject}:null}class bSt{constructor(t,n={}){Ze(this,"subscriptions",new Set);Ze(this,"seenSessions",new Set);Ze(this,"turns",new Map);Ze(this,"cleanups",[]);Ze(this,"now");this.now=n.now??(()=>Date.now()),this.connect(t)}subscribe(t,n){const s={kinds:new Set(t),handler:n};return this.subscriptions.add(s),()=>{this.subscriptions.delete(s)}}dispose(){for(const t of this.cleanups)t();this.cleanups.length=0,this.subscriptions.clear(),this.turns.clear(),this.seenSessions.clear()}connect(t){this.cleanups.push(t.subscribeSessionEvent((n,s)=>this.onSessionEvent(n,s)),t.subscribeListEvent(n=>this.onListEvent(n)),t.subscribeAttachedSessionChange((n,s)=>this.emit({kind:"session.switched",sessionId:n,previousSessionId:s})),t.subscribeEvent("relay_message",n=>{const s=vSt(n);s&&this.emit({kind:"relay.message",...s})}))}onSessionEvent(t,n){switch(n.type){case"turn_start":this.turns.set(t,{startedAt:this.now(),toolCallCount:0}),this.emit({kind:"turn.started",sessionId:t});break;case"tool_call":{const s=this.turns.get(t);s&&(s.toolCallCount+=1),this.emit({kind:"tool.activity",sessionId:t,toolName:n.toolName,status:"started"});break}case"tool_result":this.emit({kind:"tool.activity",sessionId:t,toolName:n.toolName,status:"completed"});break;case"turn_end":{const s=this.turns.get(t);this.turns.delete(t),this.emit({kind:"turn.completed",sessionId:t,durationMs:s?this.now()-s.startedAt:null,toolCallCount:(s==null?void 0:s.toolCallCount)??0,terminalReason:n.terminalReason});break}}}onListEvent(t){switch(t.type){case"session_upserted":{const n=t.session.id;this.seenSessions.has(n)||(this.seenSessions.add(n),this.emit({kind:"session.started",sessionId:n}));break}case"session_removed":this.seenSessions.delete(t.sessionId),this.emit({kind:"session.ended",sessionId:t.sessionId});break}}emit(t){for(const n of this.subscriptions)n.kinds.has(t.kind)&&n.handler(t)}}function SSt(e){return new bSt(e)}function wSt(){const{register:e}=nI.getState();for(const t of klt)e("command-palette.items",t);for(const t of Clt)e("command-palette.items",t);for(const t of vat)e("sidebar.footer",t);for(const t of bat)e("sidebar.tabs",t);for(const t of sft)e("dashboard.sections",t);for(const t of Oit)e("dialog",t);e("settings.tabs",{id:"extensions",label:"Extensions",icon:X5,component:x.lazy(()=>ks(()=>import("./index-CaH1aFVg.js"),[]).then(t=>({default:t.ExtensionsSettingsTab}))),priority:70}),e("right-panel",{id:"agent-hub",title:"Agent Profile",icon:Md,component:x.lazy(()=>ks(()=>import("./index-CK2kZcMG.js"),[]).then(t=>({default:t.AgentHub}))),visibleWhen:({pathname:t})=>!t.startsWith("/marketplace"),priority:10}),e("right-panel",{id:"files",title:"Files",icon:BRe,component:x.lazy(()=>ks(()=>import("./index-D1ekLRaV.js"),[]).then(t=>({default:t.FileExplorer}))),headerActions:x.lazy(()=>ks(()=>import("./index-D1ekLRaV.js"),[]).then(t=>({default:t.FileExplorerActions}))),visibleWhen:({pathname:t})=>t==="/session",priority:15}),e("right-panel",{id:"canvas",title:"Canvas",icon:dne,component:x.lazy(()=>ks(()=>Promise.resolve().then(()=>s1t),void 0).then(t=>({default:t.CanvasContent}))),visibleWhen:({pathname:t})=>t==="/session",priority:20}),e("right-panel",{id:"terminal",title:"Terminal",icon:Z3e,component:x.lazy(()=>ks(()=>import("./index-DiQETlwd.js"),__vite__mapDeps([8,9])).then(t=>({default:t.TerminalPanel}))),visibleWhen:({pathname:t,transport:n})=>t==="/session"&&(n==null?void 0:n.supportsTerminal)===!0,priority:25})}const kSt=x.createContext(null),LR={didCatch:!1,error:null};class CSt extends x.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=LR}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(...t){var s,r;const{error:n}=this.state;n!==null&&((r=(s=this.props).onReset)==null||r.call(s,{args:t,reason:"imperative-api"}),this.setState(LR))}componentDidCatch(t,n){var s,r;(r=(s=this.props).onError)==null||r.call(s,t,n)}componentDidUpdate(t,n){var i,o;const{didCatch:s}=this.state,{resetKeys:r}=this.props;s&&n.error!==null&&ESt(t.resetKeys,r)&&((o=(i=this.props).onReset)==null||o.call(i,{next:r,prev:t.resetKeys,reason:"keys"}),this.setState(LR))}render(){const{children:t,fallbackRender:n,FallbackComponent:s,fallback:r}=this.props,{didCatch:i,error:o}=this.state;let l=t;if(i){const c={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")l=n(c);else if(s)l=x.createElement(s,c);else if(r!==void 0)l=r;else throw o}return x.createElement(kSt.Provider,{value:{didCatch:i,error:o,resetErrorBoundary:this.resetErrorBoundary}},l)}}function ESt(e=[],t=[]){return e.length!==t.length||e.some((n,s)=>!Object.is(n,t[s]))}globalThis.React=he;const TSt=null;he.lazy(()=>ks(()=>import("./index-zioTSqyj.js"),[]).then(e=>({default:e.ReactQueryDevtoolsPanel})));he.lazy(()=>ks(()=>import("./index-C6SlFkyv.js").then(e=>e.w),[]).then(e=>({default:e.TanStackRouterDevtoolsPanel})));function _St(){return window.location.pathname.startsWith("/dev"),a.jsxs(Epe,{client:tI,children:[a.jsx(sbe,{transport:Tfe,children:a.jsx(C5e,{children:a.jsxs(ySt,{deps:_fe,children:[a.jsx(Zst,{children:a.jsx(_0e,{router:NSt})}),a.jsx(Xst,{})]})})}),!1]})}const NSt=K1t(tI),Efe=dZ(),Tfe=new VSe(Efe);nr.useHttpSource(Efe);const qG=new Map,_fe={registry:nI.getState(),dispatcherContext:{store:we.getState(),setTheme:e=>{document.documentElement.classList.toggle("dark",e==="dark")},supportsTerminal:Tfe.supportsTerminal},navigate:e=>{console.warn("[extensions] navigate called before router ready:",e)},appStore:we,availableSlots:new Set(["sidebar.footer","sidebar.tabs","dashboard.sections","header.actions","command-palette.items","dialog","settings.tabs","right-panel"]),registerCommandHandler:(e,t)=>{qG.set(e,t)},unregisterCommandHandler:e=>{qG.delete(e)},eventBridge:SSt(nr)};nr.subscribeUiCommand(e=>Kk(_fe.dispatcherContext,e,"agent"));wSt();Jme.createRoot(document.getElementById("root"),{onCaughtError:(e,t)=>{console.error("[dorkos:caught]",e,t.componentStack)},onUncaughtError:(e,t)=>{console.error("[dorkos:uncaught]",e,t.componentStack)}}).render(a.jsx(he.StrictMode,{children:a.jsx(CSt,{FallbackComponent:iQe,children:a.jsx(_St,{})})}));const jSt=Object.freeze(Object.defineProperty({__proto__:null,Mermaid:Lle},Symbol.toStringTag,{value:"Module"}));export{dr as $,pZe as A,ge as B,Lt as C,QSt as D,ma as E,bSt as F,pSt as G,ySt as H,BG as I,SSt as J,JSt as K,HSt as L,TK as M,Zf as N,MK as O,KE as P,g8 as Q,xa as R,Qce as S,Jce as T,am as U,Ud as V,Sst as W,GQe as X,tP as Y,vr as Z,ks as _,iI as a,Nr as a$,WI as a0,cs as a1,sn as a2,gn as a3,xn as a4,yn as a5,S3e as a6,s_ as a7,Hn as a8,une as a9,$p as aA,QM as aB,K5 as aC,Qte as aD,Bt as aE,ua as aF,da as aG,VSt as aH,eJe as aI,cce as aJ,qSt as aK,nJe as aL,Cx as aM,On as aN,_n as aO,In as aP,Nn as aQ,mt as aR,nn as aS,CJe as aT,ii as aU,vP as aV,rce as aW,a0 as aX,o0 as aY,Xte as aZ,Qh as a_,ODe as aa,Rs as ab,hl as ac,Eht as ad,Oi as ae,Vv as af,xe as ag,gl as ah,Kk as ai,Aie as aj,Rie as ak,Sn as al,$c as am,th as an,qh as ao,Mie as ap,Ny as aq,z3 as ar,Sl as as,ko as at,wl as au,Co as av,Eo as aw,kl as ax,_o as ay,To as az,oce as b,$b as b$,DRe as b0,rd as b1,wy as b2,$Qe as b3,c0 as b4,u0 as b5,Cs as b6,d0 as b7,USt as b8,Gb as b9,yRe as bA,hi as bB,va as bC,Li as bD,Ga as bE,Ab as bF,xb as bG,F3e as bH,kDe as bI,wo as bJ,jb as bK,f8e as bL,ov as bM,Dd as bN,ZQe as bO,Eet as bP,Tce as bQ,te as bR,Ue as bS,Vb as bT,JQe as bU,YO as bV,ZO as bW,E9 as bX,Det as bY,Md as bZ,Hh as b_,PQe as ba,ZT as bb,lJe as bc,cJe as bd,TJe as be,mce as bf,Fce as bg,Gk as bh,WE as bi,im as bj,Ka as bk,Mc as bl,es as bm,qa as bn,Z3e as bo,Ds as bp,xv as bq,aT as br,RFe as bs,ml as bt,yd as bu,dce as bv,hJe as bw,pJe as bx,fi as by,d8e as bz,je as c,_Qe as c0,GSt as c1,WSt as c2,Jt as c3,_ce as c4,QHe as c5,oUe as c6,jUe as c7,kv as c8,ZHe as c9,RJe as cA,ha as cB,RSt as cC,EJe as cD,pP as cE,Hb as cF,iae as ca,ioe as cb,he as cc,Wa as cd,aYe as ce,iWe as cf,dl as cg,Rp as ch,m4 as ci,Bqe as cj,cTe as ck,oTe as cl,hTe as cm,ln as cn,Et as co,uHe as cp,lTe as cq,aTe as cr,zSt as cs,XHe as ct,bn as cu,DSt as cv,QRe as cw,Vh as cx,Uc as cy,Pi as cz,et as d,UI as e,we as f,Owe as g,yb as h,st as i,a as j,bvt as k,Y as l,k3e as m,rE as n,fr as o,Xg as p,X5 as q,x as r,Hs as s,Ye as t,KSt as u,zt as v,sr as w,YSt as x,ZSt as y,XSt as z};
|