@euraika-labs/pan-ui 0.7.0 → 0.7.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.
Files changed (25) hide show
  1. package/.next/standalone/package.json +1 -1
  2. package/.next/static/chunks/1257.395895f93de63e8d.js +1 -0
  3. package/.next/static/chunks/2433-bbcb48ffbdc15ce7.js +1 -0
  4. package/.next/static/chunks/{3140.a3aebdd856baf0d3.js → 3140.edb5839e5b9986a9.js} +1 -1
  5. package/.next/static/chunks/app/chat/{page-f3942a49cfe4b77b.js → page-8e941e75074dda93.js} +1 -1
  6. package/.next/static/chunks/app/extensions/{page-e0ed118aa408f2e3.js → page-97611bf7fedd7072.js} +1 -1
  7. package/.next/static/chunks/app/marketplace/{page-e9f839ad75b7f4a8.js → page-d9a4cdeb605d3b23.js} +1 -1
  8. package/.next/static/chunks/app/plugins/page-3c351f43e298b9a1.js +1 -0
  9. package/.next/static/chunks/app/settings/health/page-017959e72f77dedc.js +1 -0
  10. package/.next/static/chunks/app/settings/page-882dfc9ed730aaed.js +1 -0
  11. package/.next/static/chunks/app/skills/[id]/{page-241027df81583175.js → page-ce5077e8468bb7aa.js} +1 -1
  12. package/.next/static/chunks/app/skills/page-ef7c206ea7f039f9.js +1 -0
  13. package/.next/static/chunks/{webpack-3f60b0ecd96bfc29.js → webpack-22e2d008c9d8a257.js} +1 -1
  14. package/.next/static/css/16c1f909f514ee8b.css +3 -0
  15. package/README.md +17 -0
  16. package/package.json +1 -1
  17. package/.next/static/chunks/1257.5a9a3f3bc1e6e4ed.js +0 -1
  18. package/.next/static/chunks/9860-b632f9e287faaf54.js +0 -1
  19. package/.next/static/chunks/app/plugins/page-12765968a2205454.js +0 -1
  20. package/.next/static/chunks/app/settings/health/page-61496548509805ea.js +0 -1
  21. package/.next/static/chunks/app/settings/page-c2f930a6fe7cde0f.js +0 -1
  22. package/.next/static/chunks/app/skills/page-cdeae1ae5c2ca918.js +0 -1
  23. package/.next/static/css/371b679522737b32.css +0 -3
  24. /package/.next/static/{1rIKKfgwcoD-Sz4I0QlZE → O-G97ksgneYIbDYJxggaQ}/_buildManifest.js +0 -0
  25. /package/.next/static/{1rIKKfgwcoD-Sz4I0QlZE → O-G97ksgneYIbDYJxggaQ}/_ssgManifest.js +0 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@euraika-labs/pan-ui",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Beautiful WebUI for Hermes Agent — chat, skills, plugins, memory, profiles, and runtime diagnostics in one workspace.",
5
5
  "keywords": [
6
6
  "hermes",
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1257],{685:(e,t,r)=>{function l(e,t){return"builtin"===e?"Built in for every workspace":"global"===e?"Installed for all profiles":t?"Profile scoped \xb7 ".concat(t):"Profile scoped"}function s(e){switch(e){case"built-in":return"Official";case"verified":return"Verified";case"custom":return"Community";case"local-process":return"Local";default:return e}}function a(e){switch(e){case"built-in":return"Official";case"verified":return"Verified";case"custom":return"Community";case"self-hosted":return"Self-hosted";case"local-process":return"Local process";default:return"Unknown source"}}function n(e){switch(e){case"read":case"low":return"Low risk";case"write":case"medium":return"Writes data";case"execute":return"Executes commands";case"admin":case"high":return"High privilege";default:return e}}function d(e){let t=String(null!=e?e:"unknown");return"needs-auth"===t?"Needs auth":"expired"===t?"Auth expired":"none"===t?"No auth required":"unknown"===t?"Auth unknown":"Auth connected"}function o(e){switch(e){case"enabled":return"Enabled by policy";case"blocked":return"Blocked by policy";case"approval-gated":return"Approval required";case"policy-limited":return"Policy limited";default:return"Governance unknown"}}function i(e){switch(e){case"auto":return"Auto approve";case"on-request":return"On request";case"always":return"Always ask";default:return"Policy inherited"}}function c(e){switch(e){case"global":return"Visible to every profile";case"profile":return"Visible only in this profile";case"session":return"Loaded only in the active session";default:return e}}r.d(t,{B6:()=>i,BX:()=>d,CF:()=>a,CV:()=>s,Ow:()=>o,VJ:()=>l,b:()=>n,mF:()=>c})},1257:(e,t,r)=>{r.r(t),r.d(t,{SkillsScreen:()=>M});var l=r(5155),s=r(2115),a=r(63),n=r(6907),d=r(7910),o=r(7801),i=r(9867),c=r(5880),u=r(9068),m=r(9347),x=r(6651),p=r(5229),h=r(8734),g=r(2056),f=r(9678),b=r(8584),y=r(2619),v=r.n(y),j=r(7726),k=r(1613),N=r(685);function w(e){var t;let{skill:r,loadedInCurrentSession:s=!1,sessionId:a}=e,n=a?"/skills/".concat(r.id,"?session=").concat(encodeURIComponent(a)):"/skills/".concat(r.id),d=null==(t=r.linkedFiles)?void 0:t.reduce((e,t)=>(e[t.group]=(e[t.group]||0)+1,e),{});return(0,l.jsxs)(v(),{href:n,"aria-label":r.id,className:"block rounded-2xl border border-border/70 bg-card p-4 shadow-sm transition hover:-translate-y-0.5 hover:bg-muted/40 hover:shadow-md",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,l.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("h3",{className:"truncate text-sm font-semibold",children:r.name}),r.category?(0,l.jsxs)("span",{className:"hidden shrink-0 items-center gap-1 rounded-md bg-muted/60 px-1.5 py-0.5 text-3xs text-muted-foreground sm:inline-flex",children:[(0,l.jsx)(h.A,{className:"h-2.5 w-2.5"}),r.category]}):null]}),(0,l.jsx)("p",{className:"mt-1 line-clamp-2 text-xs leading-5 text-muted-foreground",children:r.description})]}),(0,l.jsxs)("div",{className:"space-y-1.5 text-right text-3xs",children:[(0,l.jsx)("p",{className:"rounded-full border border-border/60 px-2 py-0.5",children:(0,N.VJ)(r.scope,r.ownerProfileId)}),(0,l.jsx)("p",{className:"rounded-full border border-border/60 px-2 py-0.5",children:(0,N.CV)(r.provenance)})]})]}),r.tags&&r.tags.length>0?(0,l.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1",children:[r.tags.slice(0,4).map(e=>(0,l.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded-md bg-primary/8 px-1.5 py-0.5 text-3xs text-muted-foreground",children:[(0,l.jsx)(j.A,{className:"h-2 w-2"}),e]},e)),r.tags.length>4?(0,l.jsxs)("span",{className:"rounded-md bg-muted/50 px-1.5 py-0.5 text-3xs text-muted-foreground",children:["+",r.tags.length-4]}):null]}):null,(0,l.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-1.5 text-xs",children:[(0,l.jsx)("span",{className:"rounded-full px-2 py-0.5 ".concat(r.enabled?"bg-success/15 text-foreground":"bg-muted text-muted-foreground"),children:r.enabled?"Enabled":r.installed?"Installed":"Available"}),s?(0,l.jsx)("span",{className:"rounded-full bg-primary/10 px-2 py-0.5 text-foreground",children:"Loaded"}):null,d&&Object.keys(d).length>0?(0,l.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border border-border/50 px-2 py-0.5 text-muted-foreground",children:[(0,l.jsx)(k.A,{className:"h-3 w-3"}),Object.entries(d).map(e=>{let[t,r]=e;return"".concat(r," ").concat(t)}).join(", ")]}):null,r.updatedAt?(0,l.jsx)("span",{className:"rounded-full border border-border/50 px-2 py-0.5 text-muted-foreground",children:new Date(r.updatedAt).toLocaleDateString()}):null]})]})}var A=r(9318),C=r(2604);function S(e){let{level:t}=e;return"trusted"===t?(0,l.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/15 px-2 py-0.5 text-3xs font-medium text-emerald-400",children:[(0,l.jsx)(n.A,{className:"h-2.5 w-2.5"}),"Trusted"]}):"official"===t?(0,l.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-blue-500/15 px-2 py-0.5 text-3xs font-medium text-blue-400",children:[(0,l.jsx)(d.A,{className:"h-2.5 w-2.5"}),"Official"]}):(0,l.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-amber-500/15 px-2 py-0.5 text-3xs font-medium text-amber-400",children:[(0,l.jsx)(o.A,{className:"h-2.5 w-2.5"}),"Community"]})}function L(e){let{audits:t}=e;return t?(0,l.jsx)("div",{className:"flex gap-1",children:Object.entries(t).map(e=>{let[t,r]=e;return(0,l.jsxs)("span",{className:"rounded-full px-1.5 py-0.5 text-[9px] font-medium ".concat("Pass"===r?"bg-emerald-500/15 text-emerald-400":"Warn"===r?"bg-amber-500/15 text-amber-400":"bg-red-500/15 text-red-400"),children:[t,": ",r]},t)})}):null}function I(e){var t,r;let{skill:s,onInstall:a,installing:n,installsLocked:d}=e;return(0,l.jsxs)("div",{className:"flex flex-col rounded-2xl border border-border/70 bg-card p-4 shadow-sm transition hover:-translate-y-0.5 hover:shadow-md",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,l.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("h3",{className:"truncate text-sm font-semibold",children:s.name}),(0,l.jsx)(S,{level:s.trustLevel})]}),(0,l.jsx)("p",{className:"mt-0.5 text-2xs text-muted-foreground",children:s.repo})]}),null!=s.installs?(0,l.jsxs)("span",{className:"shrink-0 rounded-lg bg-muted/50 px-2 py-0.5 text-3xs text-muted-foreground",children:[(0,l.jsx)(i.A,{className:"mr-0.5 inline h-2.5 w-2.5"}),s.installs.toLocaleString()]}):null]}),(0,l.jsx)("p",{className:"mt-2 line-clamp-3 flex-1 text-xs leading-5 text-muted-foreground",children:(null==(t=s.detail)?void 0:t.summary)||s.description}),(null==(r=s.detail)?void 0:r.securityAudits)?(0,l.jsx)("div",{className:"mt-2",children:(0,l.jsx)(L,{audits:s.detail.securityAudits})}):null,(0,l.jsxs)("div",{className:"mt-3 flex items-center gap-2",children:[(0,l.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),a()},disabled:d,className:"rounded-xl bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm transition hover:opacity-90 disabled:opacity-50",children:n?"Installing…":d?"Please wait…":"Install"}),s.detailUrl?(0,l.jsxs)("a",{href:s.detailUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-xl border border-border/50 px-2.5 py-1.5 text-xs text-muted-foreground transition hover:bg-muted/40",onClick:e=>e.stopPropagation(),children:[(0,l.jsx)(c.A,{className:"h-3 w-3"}),"skills.sh"]}):null,s.repoUrl?(0,l.jsxs)("a",{href:s.repoUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-xl border border-border/50 px-2.5 py-1.5 text-xs text-muted-foreground transition hover:bg-muted/40",onClick:e=>e.stopPropagation(),children:[(0,l.jsx)(u.A,{className:"h-3 w-3"}),"Repo"]}):null]})]})}function M(){var e,t,r,n,d,o;let i=(0,a.useRouter)(),c=(0,a.useSearchParams)().get("session"),[u,y]=(0,s.useState)("installed"),[v,j]=(0,s.useState)(null),[k,N]=(0,s.useState)(""),[S,L]=(0,s.useState)(""),[M,P]=(0,s.useState)(""),V=(0,A.a$)("installed"===u),F=(0,A.$P)(),q=(0,A.vb)(S||void 0),O=(0,A.jM)(),[E,H]=(0,s.useState)(null),[z,U]=(0,s.useState)(null),[_,D]=(0,s.useState)(null),[B,T]=(0,s.useState)([]),{selectedProfileId:R,activeSessionId:G,setActiveSessionId:J}=(0,C.j)();(0,s.useEffect)(()=>{c&&(c!==G&&J(c),i.replace("/skills",{scroll:!1}))},[G,c,i,J]);let W=(0,b.Ux)(R,null!=c?c:G),$=new Set((null==(t=W.data)||null==(e=t.loadedSkillIds)?void 0:e.length)?W.data.loadedSkillIds:["skill-authoring"]),X=null!=(d=V.data)?d:[],K=(0,s.useMemo)(()=>{var e;let t=new Set;for(let e of X)e.category&&t.add(e.category);for(let r of null!=(e=F.data)?e:[])t.add(r);return Array.from(t).sort()},[X,F.data]),Q=(0,s.useMemo)(()=>{let e=X;if(v&&(e=e.filter(e=>e.category===v)),k.trim()){let t=k.toLowerCase();e=e.filter(e=>{var r,l;return e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||(null==(r=e.tags)?void 0:r.some(e=>e.toLowerCase().includes(t)))||(null==(l=e.category)?void 0:l.toLowerCase().includes(t))})}return e},[X,v,k]),Y=(null!=(o=null==(r=q.data)?void 0:r.skills)?o:[]).filter(e=>!B.includes(e.identifier)),Z=X.filter(e=>e.enabled).length,ee=X.filter(e=>e.linkedFiles&&e.linkedFiles.length>0).length;async function et(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!E||E===e.id){H(e.id),D(null);try{await O.mutateAsync({identifier:e.identifier,force:t}),U(null),T(t=>t.includes(e.identifier)?t:[e.identifier,...t])}catch(s){let r=s instanceof Error?s.message:String(s),l=s instanceof f.h?"blocked_scan"===s.code:r.toLowerCase().includes("use --force to override");if(!t&&l)return void U({skill:e,message:r});D(r)}finally{H(null)}}}return(0,l.jsxs)("div",{className:"h-full overflow-y-auto space-y-5 p-4 pb-8 lg:p-6 lg:pb-10",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("h1",{className:"text-2xl font-semibold",children:"Skills"}),(0,l.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"installed"===u?(0,l.jsxs)(l.Fragment,{children:["Browse ",X.length," installed skills across ",K.length," categories.",Z>0?" ".concat(Z," enabled."):"",ee>0?" ".concat(ee," include references, scripts, or templates."):""]}):(0,l.jsxs)(l.Fragment,{children:["Discover skills from skills.sh and other registries. ",Y.length," available to install",(null==(n=q.data)?void 0:n.total)?" (".concat(q.data.total," total, ").concat(q.data.total-Y.length," already installed)"):"","."]})})]}),_?(0,l.jsx)("div",{className:"rounded-2xl border border-danger/30 bg-danger/10 p-4 text-sm text-foreground",children:_}):null,(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsxs)("button",{type:"button",onClick:()=>y("installed"),className:"rounded-xl px-4 py-2 text-sm font-medium transition ".concat("installed"===u?"bg-primary text-primary-foreground shadow-sm":"border border-border/70 text-muted-foreground hover:bg-card"),children:["Installed (",X.length,")"]}),(0,l.jsxs)("button",{type:"button",onClick:()=>y("discover"),className:"rounded-xl px-4 py-2 text-sm font-medium transition ".concat("discover"===u?"bg-primary text-primary-foreground shadow-sm":"border border-border/70 text-muted-foreground hover:bg-card"),children:[(0,l.jsx)(m.A,{className:"mr-1 inline h-3.5 w-3.5"}),"Discover"]})]}),"installed"===u?(0,l.jsxs)("div",{className:"relative flex-1 min-w-[200px] max-w-md",children:[(0,l.jsx)(x.A,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),(0,l.jsx)("input",{type:"text",placeholder:"Search skills by name, tag, or category…",value:k,onChange:e=>N(e.target.value),className:"w-full rounded-xl border border-border/70 bg-background/80 py-2 pl-9 pr-8 text-sm outline-none placeholder:text-muted-foreground focus:ring-2 focus:ring-primary/30"}),k?(0,l.jsx)("button",{type:"button",onClick:()=>N(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:(0,l.jsx)(p.A,{className:"h-4 w-4"})}):null]}):(0,l.jsxs)("form",{className:"relative flex-1 min-w-[200px] max-w-md",onSubmit:e=>{e.preventDefault(),L(M)},children:[(0,l.jsx)(x.A,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),(0,l.jsx)("input",{type:"text",placeholder:"Search skills.sh (e.g. kubernetes, react, python)…",value:M,onChange:e=>P(e.target.value),className:"w-full rounded-xl border border-border/70 bg-background/80 py-2 pl-9 pr-8 text-sm outline-none placeholder:text-muted-foreground focus:ring-2 focus:ring-primary/30"}),M?(0,l.jsx)("button",{type:"button",onClick:()=>{P(""),L("")},className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:(0,l.jsx)(p.A,{className:"h-4 w-4"})}):null]})]}),"installed"===u?(0,l.jsxs)(l.Fragment,{children:[K.length>0?(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,l.jsx)(h.A,{className:"h-4 w-4 text-muted-foreground"}),(0,l.jsx)("button",{type:"button",onClick:()=>j(null),className:"rounded-lg px-3 py-1 text-xs font-medium transition ".concat(v?"border border-border/50 text-muted-foreground hover:bg-card":"bg-primary/15 text-foreground ring-1 ring-primary/30"),children:"All"}),K.map(e=>{let t=X.filter(t=>t.category===e).length;return(0,l.jsxs)("button",{type:"button",onClick:()=>j(v===e?null:e),className:"rounded-lg px-3 py-1 text-xs font-medium transition ".concat(v===e?"bg-primary/15 text-foreground ring-1 ring-primary/30":"border border-border/50 text-muted-foreground hover:bg-card"),children:[e," (",t,")"]},e)})]}):null,V.isLoading?(0,l.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading skill data…"}):null,$.size?(0,l.jsxs)("div",{className:"rounded-2xl border border-border/70 bg-card/80 p-3 text-sm text-muted-foreground",children:[(0,l.jsx)("span",{className:"font-medium text-foreground",children:"Loaded in current session:"}),(0,l.jsx)("span",{className:"ml-2",children:Array.from($).join(", ")})]}):null,V.isLoading||0!==Q.length?null:(0,l.jsx)("div",{className:"rounded-2xl border border-dashed border-border/70 bg-card/60 p-5 text-sm text-muted-foreground",children:k||v?'No skills match "'.concat(k||v,'". Try a different filter.'):"No installed skills were detected for the current runtime/profile scope."}),(0,l.jsx)("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:Q.map(e=>(0,l.jsx)(w,{skill:e,loadedInCurrentSession:$.has(e.id),sessionId:null!=c?c:G},e.id))})]}):null,"discover"===u?(0,l.jsxs)(l.Fragment,{children:[z?(0,l.jsx)("div",{className:"fixed inset-0 z-30 flex items-center justify-center bg-black/50 p-4",children:(0,l.jsxs)("div",{className:"w-full max-w-2xl rounded-2xl border border-border bg-background p-5 shadow-xl",children:[(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("div",{className:"mt-0.5 flex h-10 w-10 items-center justify-center rounded-xl bg-amber-500/15 text-amber-400",children:(0,l.jsx)(g.A,{className:"h-5 w-5"})}),(0,l.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,l.jsx)("h3",{className:"text-lg font-semibold text-foreground",children:"Security scan blocked this install"}),(0,l.jsxs)("p",{className:"mt-1 text-sm text-muted-foreground",children:[z.skill.name," comes from a community source and triggered a caution verdict. Pan blocked the default install to avoid silently pulling in risky skills."]})]})]}),(0,l.jsx)("div",{className:"mt-4 rounded-2xl border border-border/70 bg-card/60 p-4 text-sm text-foreground",children:(0,l.jsx)("pre",{className:"whitespace-pre-wrap break-words text-xs leading-6 text-muted-foreground",children:z.message})}),(0,l.jsx)("p",{className:"mt-4 text-sm text-muted-foreground",children:"If you trust this skill and understand the findings above, you can force the install once. Otherwise, cancel and pick a different skill."}),(0,l.jsxs)("div",{className:"mt-5 flex justify-end gap-2",children:[(0,l.jsx)("button",{type:"button",onClick:()=>U(null),className:"rounded-lg border border-border px-4 py-2 text-sm",children:"Cancel"}),(0,l.jsx)("button",{type:"button",onClick:()=>void et(z.skill,!0),disabled:E===z.skill.id,className:"rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50",children:E===z.skill.id?"Installing…":"Install anyway"})]})]})}):null,q.isLoading?(0,l.jsx)("p",{className:"text-sm text-muted-foreground",children:"Searching skills.sh…"}):null,q.isLoading||0!==Y.length?null:(0,l.jsx)("div",{className:"rounded-2xl border border-dashed border-border/70 bg-card/60 p-5 text-sm text-muted-foreground",children:S?'No skills found for "'.concat(S,'". Try a different search term.'):"No discoverable skills found. The skills.sh cache may need to be populated — run `hermes skills browse` in your terminal."}),E?(0,l.jsx)("div",{className:"rounded-2xl border border-border/70 bg-card/60 p-4 text-sm text-muted-foreground",children:"A skill install is in progress. Pan temporarily locks the other install buttons so you do not fire overlapping installs and end up with stale cards."}):null,(0,l.jsx)("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:Y.map(e=>(0,l.jsx)(I,{skill:e,onInstall:()=>et(e),installing:E===e.id,installsLocked:!!E},e.id))})]}):null]})}},1613:(e,t,r)=>{r.d(t,{A:()=>l});let l=(0,r(1847).A)("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]])},5880:(e,t,r)=>{r.d(t,{A:()=>l});let l=(0,r(1847).A)("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]])},7726:(e,t,r)=>{r.d(t,{A:()=>l});let l=(0,r(1847).A)("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]])},7910:(e,t,r)=>{r.d(t,{A:()=>l});let l=(0,r(1847).A)("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]])},8734:(e,t,r)=>{r.d(t,{A:()=>l});let l=(0,r(1847).A)("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]])},9068:(e,t,r)=>{r.d(t,{A:()=>l});let l=(0,r(1847).A)("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]])},9347:(e,t,r)=>{r.d(t,{A:()=>l});let l=(0,r(1847).A)("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]])},9867:(e,t,r)=>{r.d(t,{A:()=>l});let l=(0,r(1847).A)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]])}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2433],{2056:(e,a,t)=>{t.d(a,{A:()=>l});let l=(0,t(1847).A)("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},2932:(e,a,t)=>{t.d(a,{eS:()=>p,pp:()=>c,W5:()=>u,Gu:()=>d});var l=t(5155),o=t(5299);let i=(0,t(1847).A)("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);var n=t(2056),r=t(4269);function s(e){return"banner"===e?"rounded-xl border border-border/60 bg-card/50 p-4 shadow-[var(--shadow-card)]":"rounded-2xl border border-border/60 bg-card/55 p-6 shadow-[var(--shadow-card)]"}function d(e){var a;let{title:t,message:i,description:n,layout:d="card",className:c,children:p}=e,u=null!=(a=null!=t?t:i)?a:"Loading…";return(0,l.jsxs)("div",{className:(0,r.cn)(s(d),c),children:[(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)(o.A,{className:"mt-0.5 h-4 w-4 animate-spin text-primary"}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("p",{className:"font-semibold text-foreground",children:u}),n?(0,l.jsx)("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:n}):null]})]}),p?(0,l.jsx)("div",{className:"mt-4",children:p}):null]})}function c(e){let{title:a,description:t,icon:o,primaryAction:n,secondaryAction:d,action:c,layout:p="card",className:u}=e,m=null!=n?n:c;return(0,l.jsx)("div",{className:(0,r.cn)(s(p),"border-dashed",u),children:(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("div",{className:"mt-0.5 text-primary",children:null!=o?o:(0,l.jsx)(i,{className:"h-4 w-4"})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("p",{className:"font-semibold text-foreground",children:a}),(0,l.jsx)("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:t}),m||d?(0,l.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[m,d]}):null]})]})})}function p(e){let{title:a,description:t,severity:o="warning",icon:i,details:d,primaryAction:c,secondaryAction:p,layout:u="card",className:m}=e;return(0,l.jsx)("div",{className:(0,r.cn)(s(u),"danger"===o?"border-danger/35 bg-danger/10":"border-warning/35 bg-warning/10",m),children:(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("div",{className:(0,r.cn)("mt-0.5","danger"===o?"text-danger":"text-warning"),children:null!=i?i:(0,l.jsx)(n.A,{className:"h-4 w-4"})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("p",{className:"font-semibold text-foreground",children:a}),(0,l.jsx)("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:t}),d?(0,l.jsx)("div",{className:"mt-2 text-xs leading-5 text-muted-foreground",children:d}):null,c||p?(0,l.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[c,p]}):null]})]})})}function u(e){let{title:a="Something went wrong",error:t,message:o,description:i,primaryAction:d,secondaryAction:c,layout:p="card",className:u}=e,m=null!=o?o:t,j="string"==typeof m?m:m instanceof Error?m.message:null;return(0,l.jsx)("div",{className:(0,r.cn)(s(p),"border-danger/35 bg-danger/10",u),children:(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)(n.A,{className:"mt-0.5 h-4 w-4 text-danger"}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("p",{className:"font-semibold text-foreground",children:a}),i?(0,l.jsx)("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:i}):null,j?(0,l.jsx)("p",{className:"mt-1 text-sm leading-6 text-foreground",children:j}):null,d||c?(0,l.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[d,c]}):null]})]})})}},4412:(e,a,t)=>{t.d(a,{O:()=>i});var l=t(5155),o=t(4269);function i(e){let{count:a=6,className:t,cardClassName:i}=e;return(0,l.jsx)("div",{className:(0,o.cn)("grid gap-4 md:grid-cols-2 xl:grid-cols-3",t),children:Array.from({length:a}).map((e,a)=>(0,l.jsx)("div",{className:(0,o.cn)("h-40 animate-pulse rounded-2xl border border-border/50 bg-card/50",i)},a))})}},5299:(e,a,t)=>{t.d(a,{A:()=>l});let l=(0,t(1847).A)("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},6670:(e,a,t)=>{t.d(a,{J:()=>r,K:()=>s});var l=t(2454),o=t(9776),i=t(549),n=t(9678);function r(e){let a=e?"?q=".concat(encodeURIComponent(e)):"";return(0,l.I)({queryKey:["hub-mcp",null!=e?e:""],queryFn:()=>(0,n.n)("/api/extensions/hub".concat(a))})}function s(){let e=(0,o.jE)();return(0,i.n)({mutationFn:e=>(0,n.n)("/api/extensions/hub/install",{method:"POST",body:JSON.stringify(e)}),onSuccess:()=>{e.invalidateQueries({queryKey:["hub-mcp"]}),e.invalidateQueries({queryKey:["extensions"]})}})}},9054:(e,a,t)=>{t.d(a,{HB:()=>m,C5:()=>j,d:()=>p,iF:()=>u,YM:()=>Y});var l=t(4879);l.gM("type",[l.Ik({type:l.eu("assistant.delta"),delta:l.Yj()}),l.Ik({type:l.eu("run.phase"),phase:l.k5(["drafting","tool-started","waiting-approval","completed"]),label:l.Yj()}),l.Ik({type:l.eu("tool.started"),toolCallId:l.Yj(),toolName:l.Yj(),riskLevel:l.k5(["read","write","execute","admin"]).optional(),provenance:l.k5(["built-in","verified","custom","self-hosted","local-process"]).optional()}),l.Ik({type:l.eu("tool.awaiting_approval"),toolCallId:l.Yj(),toolName:l.Yj(),summary:l.Yj(),riskLevel:l.k5(["read","write","execute","admin"]).optional(),governance:l.k5(["enabled","blocked","approval-gated","policy-limited"]).optional()}),l.Ik({type:l.eu("tool.completed"),toolCallId:l.Yj(),toolName:l.Yj(),output:l.Yj().optional(),riskLevel:l.k5(["read","write","execute","admin"]).optional()}),l.Ik({type:l.eu("artifact.emitted"),artifactId:l.Yj(),artifactType:l.Yj(),label:l.Yj(),content:l.Yj().optional()}),l.Ik({type:l.eu("source.emitted"),source:l.Ik({id:l.Yj(),title:l.Yj(),href:l.Yj().optional(),snippet:l.Yj().optional(),sourceType:l.k5(["web","file","workspace","integration","unknown"]),provenance:l.k5(["built-in","verified","custom","self-hosted","local-process"]),note:l.Yj().optional(),label:l.Yj().optional()})}),l.Ik({type:l.eu("error"),message:l.Yj()})]),l.Ik({model:l.Yj(),provider:l.Yj(),policyPreset:l.k5(["safe-chat","research","builder","full-power"]),memoryMode:l.k5(["standard","minimal"])}),l.Ik({id:l.Yj(),title:l.Yj(),updatedAt:l.Yj(),preview:l.Yj().optional()});let o=l.Ik({id:l.Yj(),name:l.Yj(),description:l.Yj(),enabled:l.zM(),riskLevel:l.k5(["read","write","execute","admin"]),scope:l.k5(["global","profile","session"]),approvalPolicy:l.k5(["auto","on-request","always"]).optional(),lastUsedAt:l.Yj().optional()}),i=l.Ik({command:l.Yj().optional(),url:l.Yj().optional(),authType:l.k5(["none","api-key","oauth"]).optional(),token:l.Yj().optional()}),n=l.Ik({source:l.k5(["live","cache","persisted","failed"]),errorText:l.Yj().nullable().optional(),remediation:l.YO(l.Yj()).optional(),discoveredTools:l.ai().optional(),probedAt:l.Yj().optional()}),r=l.Ik({id:l.Yj(),name:l.Yj(),description:l.Yj(),health:l.k5(["healthy","degraded","blocked","failed"]),riskLevel:l.k5(["read","write","execute","admin"]),authState:l.k5(["connected","needs-auth","expired"]),governance:l.k5(["enabled","blocked","approval-gated","policy-limited"]),provenance:l.k5(["built-in","verified","custom","self-hosted","local-process"]),approvalPolicy:l.k5(["auto","on-request","always"]),type:l.k5(["mcp","native","builtin"]),installed:l.zM(),config:i,capabilities:l.YO(o),toolCount:l.ai(),profilesUsing:l.YO(l.Yj()),diagnostics:n.optional(),version:l.Yj().optional(),updatedAt:l.Yj().optional()}),s=l.Ik({id:l.Yj(),name:l.Yj(),sourceExtensionId:l.Yj(),sourceExtensionName:l.Yj(),category:l.k5(["mcp","builtin","native"]),riskLevel:l.k5(["read","write","execute","admin"]),enabled:l.zM(),approvalPolicy:l.k5(["auto","on-request","always"]),lastUsedAt:l.Yj().optional(),scope:l.k5(["global","profile","session"])});l.Ik({id:l.Yj(),createdAt:l.Yj(),action:l.Yj(),targetType:l.Yj(),targetId:l.Yj(),detail:l.Yj()}),l.Ik({id:l.Yj(),content:l.Yj(),updatedAt:l.Yj().optional(),scope:l.k5(["user","agent"])}),l.Ik({activeProfileId:l.Yj().nullable(),activeSessionId:l.Yj().nullable(),activeSessionTitle:l.Yj().optional(),activeSessionPreview:l.Yj().optional(),loadedSkillIds:l.YO(l.Yj()),model:l.Yj().optional(),provider:l.Yj().optional(),policyPreset:l.k5(["safe-chat","research","builder","full-power"]).optional(),memoryMode:l.k5(["standard","minimal"]).optional(),userMemory:l.YO(l.Yj()),agentMemory:l.YO(l.Yj())}),l.Ik({id:l.Yj(),name:l.Yj(),modelDefault:l.Yj().optional(),policyPreset:l.k5(["safe-chat","research","builder","full-power"]).optional(),sessionCount:l.ai().optional(),skillCount:l.ai().optional(),extensionCount:l.ai().optional(),active:l.zM().optional()}),l.Ik({id:l.Yj(),title:l.Yj(),updatedAt:l.Yj(),status:l.k5(["active","archived"]),preview:l.Yj().optional(),parentSessionId:l.Yj().optional()});let d=l.Ik({path:l.Yj(),name:l.Yj(),group:l.Yj()}),c=l.Ik({id:l.Yj(),name:l.Yj(),description:l.Yj(),source:l.k5(["bundled","local","hub","agent-created"]),scope:l.k5(["builtin","global","profile"]),provenance:l.k5(["built-in","verified","custom","local-process"]),installed:l.zM(),enabled:l.zM(),content:l.Yj(),loadedInSessions:l.YO(l.Yj()).optional(),ownerProfileId:l.Yj().nullable().optional(),filePath:l.Yj().optional(),version:l.Yj().optional(),updatedAt:l.Yj().optional(),impliedTools:l.YO(l.Yj()).optional(),category:l.Yj().optional(),tags:l.YO(l.Yj()).optional(),relatedSkills:l.YO(l.Yj()).optional(),linkedFiles:l.YO(d).optional(),author:l.Yj().optional()}),p=e=>c.parse(e),u=e=>c.array().parse(e),m=e=>r.parse(e),j=e=>r.array().parse(e),Y=e=>s.array().parse(e)}}]);
@@ -1 +1 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3140],{3140:(e,s,t)=>{t.r(s),t.d(s,{PluginsScreen:()=>b});var r=t(5155),n=t(2115),l=t(8599),a=t(1375),d=t(962),i=t(1847);let o=(0,i.A)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);var u=t(4269);let c={user:"bg-blue-500/15 text-blue-400",builtin:"bg-emerald-500/15 text-emerald-400",pip:"bg-amber-500/15 text-amber-400"};function m(e){let{plugin:s,onToggle:t,onRemove:n}=e;return(0,r.jsxs)("div",{className:"rounded-2xl border border-border bg-card p-5 shadow-sm",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h3",{className:"truncate text-lg font-semibold",children:s.name}),(0,r.jsxs)("span",{className:"shrink-0 rounded-full bg-muted/70 px-2 py-0.5 text-2xs text-muted-foreground",children:["v",s.version]})]}),s.author&&(0,r.jsxs)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["by ",s.author]})]}),(0,r.jsx)("span",{className:(0,u.cn)("shrink-0 rounded-full px-2 py-0.5 text-2xs font-medium",c[s.source]),children:s.source})]}),s.description&&(0,r.jsx)("p",{className:"mt-3 text-sm leading-relaxed text-muted-foreground",children:s.description}),s.providedTools.length>0&&(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("p",{className:"text-2xs font-medium uppercase tracking-label text-muted-foreground",children:"Tools"}),(0,r.jsx)("div",{className:"mt-1 flex flex-wrap gap-1",children:s.providedTools.map(e=>(0,r.jsx)("span",{className:"rounded-md bg-muted/50 px-1.5 py-0.5 text-2xs text-muted-foreground",children:e},e))})]}),s.providedHooks.length>0&&(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsx)("p",{className:"text-2xs font-medium uppercase tracking-label text-muted-foreground",children:"Hooks"}),(0,r.jsx)("div",{className:"mt-1 flex flex-wrap gap-1",children:s.providedHooks.map(e=>(0,r.jsx)("span",{className:"rounded-md bg-muted/50 px-1.5 py-0.5 text-2xs text-muted-foreground",children:e},e))})]}),(0,r.jsxs)("div",{className:"mt-4 flex items-center justify-between border-t border-border/70 pt-4",children:[(0,r.jsxs)("label",{className:"flex cursor-pointer items-center gap-2",children:[(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":s.enabled,onClick:()=>t(s.id,!s.enabled),className:(0,u.cn)("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors",s.enabled?"bg-primary":"bg-muted"),children:(0,r.jsx)("span",{className:(0,u.cn)("pointer-events-none block h-4 w-4 rounded-full bg-white shadow-sm transition-transform",s.enabled?"translate-x-[18px]":"translate-x-0.5")})}),(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:s.enabled?"Enabled":"Disabled"})]}),"user"===s.source&&n&&(0,r.jsxs)("button",{type:"button",onClick:()=>n(s.id),className:"flex items-center gap-1.5 rounded-lg border border-danger/30 bg-danger/10 px-2.5 py-1.5 text-xs text-danger transition hover:bg-danger/20",children:[(0,r.jsx)(o,{className:"h-3.5 w-3.5"}),"Remove"]})]})]})}let x=(0,i.A)("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);var p=t(5299);let g=/^[a-zA-Z0-9][a-zA-Z0-9._-]*\/[a-zA-Z0-9._-]+$/;function h(e){let{open:s,onClose:t}=e,[l,a]=(0,n.useState)(""),[i,o]=(0,n.useState)(null),u=(0,d.c$)();if(!s)return null;let c=g.test(l);async function m(){if(!l.trim())return void o("Repository is required.");if(!c)return void o("Invalid format. Use owner/repo (for example nousresearch/hermes-plugin-web).");o(null);try{await u.mutateAsync({identifier:l.trim()}),a(""),o(null),t()}catch(e){o(function(e){let s=e.toLowerCase();return s.includes("plugin.yaml")?"This repository cloned successfully, but it is not a valid Hermes plugin yet. A valid plugin repo must include a plugin.yaml manifest.":s.includes("__init__.py")?"This repository is missing the required __init__.py plugin entrypoint, so Pan cannot treat it as a real plugin.":s.includes("already exists")||s.includes("already installed")?"That plugin is already installed in this workspace.":e}(e instanceof Error?e.message:String(e)))}}return(0,r.jsx)("div",{className:"fixed inset-0 z-30 flex items-center justify-center bg-black/50 p-4",children:(0,r.jsxs)("div",{className:"w-full max-w-md rounded-2xl border border-border bg-background p-5 shadow-xl",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(x,{className:"h-5 w-5 text-primary"}),(0,r.jsx)("h3",{className:"text-lg font-semibold",children:"Install plugin"})]}),(0,r.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Install a repo-based plugin when you need custom hooks or tool bundles beyond MCP servers and built-in integrations."}),(0,r.jsxs)("div",{className:"mt-4 rounded-xl border border-border/70 bg-card/60 p-3 text-sm text-muted-foreground",children:[(0,r.jsx)("p",{className:"font-medium text-foreground",children:"What counts as a valid plugin repo?"}),(0,r.jsxs)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-xs leading-5",children:[(0,r.jsxs)("li",{children:["Use the GitHub format ",(0,r.jsx)("span",{className:"font-medium text-foreground",children:"owner/repo"}),"."]}),(0,r.jsxs)("li",{children:["The repository must contain a ",(0,r.jsx)("span",{className:"font-medium text-foreground",children:"plugin.yaml"})," manifest."]}),(0,r.jsxs)("li",{children:["The repository must also include the required ",(0,r.jsx)("span",{className:"font-medium text-foreground",children:"__init__.py"})," entrypoint."]})]})]}),(0,r.jsxs)("div",{className:"mt-4",children:[(0,r.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"GitHub repository"}),(0,r.jsx)("input",{value:l,onChange:e=>{a(e.target.value),o(null)},placeholder:"owner/repo",className:"mt-1 w-full rounded-lg border bg-background px-3 py-2 text-sm outline-none placeholder:text-muted-foreground/50 focus:border-primary/50 ".concat(i?"border-red-500/70":"border-input"),autoFocus:!0,onKeyDown:e=>{"Enter"===e.key&&m()}}),!l||c||i?null:(0,r.jsx)("p",{className:"mt-1 text-xs text-amber-400",children:"Format: owner/repo (for example nousresearch/hermes-plugin-web)"}),l||i?null:(0,r.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Pan validates the repo before counting the install as successful."})]}),i?(0,r.jsx)("div",{className:"mt-3 rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-400",children:i}):null,u.isSuccess?(0,r.jsx)("div",{className:"mt-3 rounded-lg border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-sm text-emerald-400",children:"Plugin installed successfully."}):null,(0,r.jsxs)("div",{className:"mt-5 flex justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:function(){a(""),o(null),u.reset(),t()},className:"rounded-lg border border-border px-4 py-2 text-sm",children:"Cancel"}),(0,r.jsxs)("button",{type:"button",onClick:()=>void m(),disabled:u.isPending||!l.trim()||!c,className:"flex items-center gap-2 rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50",children:[u.isPending?(0,r.jsx)(p.A,{className:"h-4 w-4 animate-spin"}):null,u.isPending?"Installing…":"Install plugin"]})]})]})})}function b(){var e;let s=(0,d.qw)(),t=(0,d.P4)(),i=(0,d.Ho)(),[o,u]=(0,n.useState)(!1),c=null!=(e=s.data)?e:[];function x(e,s){t.mutateAsync({id:e,enabled:s})}function p(e){i.mutateAsync(e)}return(0,r.jsxs)("div",{className:"h-full overflow-y-auto space-y-6 p-4 pb-8 lg:p-6 lg:pb-10",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-4 md:flex-row md:items-start md:justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-2xl font-semibold",children:"Plugins"}),(0,r.jsx)("p",{className:"mt-2 max-w-3xl text-sm text-muted-foreground",children:"Plugins are repo-based extensions for custom hooks and bundled tools. Use MCP servers for live external systems, and use plugins when you need deeper runtime customization."})]}),(0,r.jsx)("button",{type:"button",onClick:()=>u(!0),className:"rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",children:"Install plugin"})]}),(0,r.jsxs)("div",{className:"rounded-2xl border border-border/60 bg-card/55 p-4 text-sm text-muted-foreground shadow-sm",children:[(0,r.jsx)("p",{className:"font-medium text-foreground",children:"How plugins differ from integrations"}),(0,r.jsx)("p",{className:"mt-2",children:"Integrations and MCP servers focus on what the agent can reach right now. Plugins focus on adding custom hooks, packaged tools, and deeper behavior changes to the runtime."})]}),s.isLoading?(0,r.jsx)(a.Gu,{title:"Loading plugins…",description:"Reading installed plugins and their tool/hook metadata for this workspace."}):null,s.isError?(0,r.jsx)(a.W5,{title:"Could not load plugins",error:s.error,description:"Pan could not read the installed plugin inventory right now."}):null,s.isSuccess&&0===c.length?(0,r.jsx)(a.pp,{title:"No plugins installed",description:"Plugins are optional and usually come after skills and MCP servers. Install one when you need repo-based hooks, tool bundles, or runtime customization.",icon:(0,r.jsx)(l.A,{className:"h-5 w-5"}),primaryAction:(0,r.jsx)("button",{type:"button",onClick:()=>u(!0),className:"rounded-2xl bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",children:"Install your first plugin"})}):null,s.isSuccess&&c.length>0?(0,r.jsx)("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:c.map(e=>(0,r.jsx)(m,{plugin:e,onToggle:x,onRemove:p},e.id))}):null,(0,r.jsx)(h,{open:o,onClose:()=>u(!1)})]})}}}]);
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3140],{3140:(e,s,t)=>{t.r(s),t.d(s,{PluginsScreen:()=>b});var r=t(5155),n=t(2115),l=t(8599),a=t(2932),d=t(962),i=t(1847);let o=(0,i.A)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);var u=t(4269);let c={user:"bg-blue-500/15 text-blue-400",builtin:"bg-emerald-500/15 text-emerald-400",pip:"bg-amber-500/15 text-amber-400"};function m(e){let{plugin:s,onToggle:t,onRemove:n}=e;return(0,r.jsxs)("div",{className:"rounded-2xl border border-border bg-card p-5 shadow-sm",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h3",{className:"truncate text-lg font-semibold",children:s.name}),(0,r.jsxs)("span",{className:"shrink-0 rounded-full bg-muted/70 px-2 py-0.5 text-2xs text-muted-foreground",children:["v",s.version]})]}),s.author&&(0,r.jsxs)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["by ",s.author]})]}),(0,r.jsx)("span",{className:(0,u.cn)("shrink-0 rounded-full px-2 py-0.5 text-2xs font-medium",c[s.source]),children:s.source})]}),s.description&&(0,r.jsx)("p",{className:"mt-3 text-sm leading-relaxed text-muted-foreground",children:s.description}),s.providedTools.length>0&&(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("p",{className:"text-2xs font-medium uppercase tracking-label text-muted-foreground",children:"Tools"}),(0,r.jsx)("div",{className:"mt-1 flex flex-wrap gap-1",children:s.providedTools.map(e=>(0,r.jsx)("span",{className:"rounded-md bg-muted/50 px-1.5 py-0.5 text-2xs text-muted-foreground",children:e},e))})]}),s.providedHooks.length>0&&(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsx)("p",{className:"text-2xs font-medium uppercase tracking-label text-muted-foreground",children:"Hooks"}),(0,r.jsx)("div",{className:"mt-1 flex flex-wrap gap-1",children:s.providedHooks.map(e=>(0,r.jsx)("span",{className:"rounded-md bg-muted/50 px-1.5 py-0.5 text-2xs text-muted-foreground",children:e},e))})]}),(0,r.jsxs)("div",{className:"mt-4 flex items-center justify-between border-t border-border/70 pt-4",children:[(0,r.jsxs)("label",{className:"flex cursor-pointer items-center gap-2",children:[(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":s.enabled,onClick:()=>t(s.id,!s.enabled),className:(0,u.cn)("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors",s.enabled?"bg-primary":"bg-muted"),children:(0,r.jsx)("span",{className:(0,u.cn)("pointer-events-none block h-4 w-4 rounded-full bg-white shadow-sm transition-transform",s.enabled?"translate-x-[18px]":"translate-x-0.5")})}),(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:s.enabled?"Enabled":"Disabled"})]}),"user"===s.source&&n&&(0,r.jsxs)("button",{type:"button",onClick:()=>n(s.id),className:"flex items-center gap-1.5 rounded-lg border border-danger/30 bg-danger/10 px-2.5 py-1.5 text-xs text-danger transition hover:bg-danger/20",children:[(0,r.jsx)(o,{className:"h-3.5 w-3.5"}),"Remove"]})]})]})}let x=(0,i.A)("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);var p=t(5299);let g=/^[a-zA-Z0-9][a-zA-Z0-9._-]*\/[a-zA-Z0-9._-]+$/;function h(e){let{open:s,onClose:t}=e,[l,a]=(0,n.useState)(""),[i,o]=(0,n.useState)(null),u=(0,d.c$)();if(!s)return null;let c=g.test(l);async function m(){if(!l.trim())return void o("Repository is required.");if(!c)return void o("Invalid format. Use owner/repo (for example nousresearch/hermes-plugin-web).");o(null);try{await u.mutateAsync({identifier:l.trim()}),a(""),o(null),t()}catch(e){o(function(e){let s=e.toLowerCase();return s.includes("plugin.yaml")?"This repository cloned successfully, but it is not a valid Hermes plugin yet. A valid plugin repo must include a plugin.yaml manifest.":s.includes("__init__.py")?"This repository is missing the required __init__.py plugin entrypoint, so Pan cannot treat it as a real plugin.":s.includes("already exists")||s.includes("already installed")?"That plugin is already installed in this workspace.":e}(e instanceof Error?e.message:String(e)))}}return(0,r.jsx)("div",{className:"fixed inset-0 z-30 flex items-center justify-center bg-black/50 p-4",children:(0,r.jsxs)("div",{className:"w-full max-w-md rounded-2xl border border-border bg-background p-5 shadow-xl",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(x,{className:"h-5 w-5 text-primary"}),(0,r.jsx)("h3",{className:"text-lg font-semibold",children:"Install plugin"})]}),(0,r.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Install a repo-based plugin when you need custom hooks or tool bundles beyond MCP servers and built-in integrations."}),(0,r.jsxs)("div",{className:"mt-4 rounded-xl border border-border/70 bg-card/60 p-3 text-sm text-muted-foreground",children:[(0,r.jsx)("p",{className:"font-medium text-foreground",children:"What counts as a valid plugin repo?"}),(0,r.jsxs)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-xs leading-5",children:[(0,r.jsxs)("li",{children:["Use the GitHub format ",(0,r.jsx)("span",{className:"font-medium text-foreground",children:"owner/repo"}),"."]}),(0,r.jsxs)("li",{children:["The repository must contain a ",(0,r.jsx)("span",{className:"font-medium text-foreground",children:"plugin.yaml"})," manifest."]}),(0,r.jsxs)("li",{children:["The repository must also include the required ",(0,r.jsx)("span",{className:"font-medium text-foreground",children:"__init__.py"})," entrypoint."]})]})]}),(0,r.jsxs)("div",{className:"mt-4",children:[(0,r.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"GitHub repository"}),(0,r.jsx)("input",{value:l,onChange:e=>{a(e.target.value),o(null)},placeholder:"owner/repo",className:"mt-1 w-full rounded-lg border bg-background px-3 py-2 text-sm outline-none placeholder:text-muted-foreground/50 focus:border-primary/50 ".concat(i?"border-red-500/70":"border-input"),autoFocus:!0,onKeyDown:e=>{"Enter"===e.key&&m()}}),!l||c||i?null:(0,r.jsx)("p",{className:"mt-1 text-xs text-amber-400",children:"Format: owner/repo (for example nousresearch/hermes-plugin-web)"}),l||i?null:(0,r.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Pan validates the repo before counting the install as successful."})]}),i?(0,r.jsx)("div",{className:"mt-3 rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-400",children:i}):null,u.isSuccess?(0,r.jsx)("div",{className:"mt-3 rounded-lg border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-sm text-emerald-400",children:"Plugin installed successfully."}):null,(0,r.jsxs)("div",{className:"mt-5 flex justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:function(){a(""),o(null),u.reset(),t()},className:"rounded-lg border border-border px-4 py-2 text-sm",children:"Cancel"}),(0,r.jsxs)("button",{type:"button",onClick:()=>void m(),disabled:u.isPending||!l.trim()||!c,className:"flex items-center gap-2 rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50",children:[u.isPending?(0,r.jsx)(p.A,{className:"h-4 w-4 animate-spin"}):null,u.isPending?"Installing…":"Install plugin"]})]})]})})}function b(){var e;let s=(0,d.qw)(),t=(0,d.P4)(),i=(0,d.Ho)(),[o,u]=(0,n.useState)(!1),c=null!=(e=s.data)?e:[];function x(e,s){t.mutateAsync({id:e,enabled:s})}function p(e){i.mutateAsync(e)}return(0,r.jsxs)("div",{className:"h-full overflow-y-auto space-y-6 p-4 pb-8 lg:p-6 lg:pb-10",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-4 md:flex-row md:items-start md:justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-2xl font-semibold",children:"Plugins"}),(0,r.jsx)("p",{className:"mt-2 max-w-3xl text-sm text-muted-foreground",children:"Plugins are repo-based extensions for custom hooks and bundled tools. Use MCP servers for live external systems, and use plugins when you need deeper runtime customization."})]}),(0,r.jsx)("button",{type:"button",onClick:()=>u(!0),className:"rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",children:"Install plugin"})]}),(0,r.jsxs)("div",{className:"rounded-2xl border border-border/60 bg-card/55 p-4 text-sm text-muted-foreground shadow-sm",children:[(0,r.jsx)("p",{className:"font-medium text-foreground",children:"How plugins differ from integrations"}),(0,r.jsx)("p",{className:"mt-2",children:"Integrations and MCP servers focus on what the agent can reach right now. Plugins focus on adding custom hooks, packaged tools, and deeper behavior changes to the runtime."})]}),s.isLoading?(0,r.jsx)(a.Gu,{title:"Loading plugins…",description:"Reading installed plugins and their tool/hook metadata for this workspace."}):null,s.isError?(0,r.jsx)(a.W5,{title:"Could not load plugins",error:s.error,description:"Pan could not read the installed plugin inventory right now."}):null,s.isSuccess&&0===c.length?(0,r.jsx)(a.pp,{title:"No plugins installed",description:"Plugins are optional and usually come after skills and MCP servers. Install one when you need repo-based hooks, tool bundles, or runtime customization.",icon:(0,r.jsx)(l.A,{className:"h-5 w-5"}),primaryAction:(0,r.jsx)("button",{type:"button",onClick:()=>u(!0),className:"rounded-2xl bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",children:"Install your first plugin"})}):null,s.isSuccess&&c.length>0?(0,r.jsx)("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:c.map(e=>(0,r.jsx)(m,{plugin:e,onToggle:x,onRemove:p},e.id))}):null,(0,r.jsx)(h,{open:o,onClose:()=>u(!1)})]})}}}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8457],{21:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(1847).A)("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},711:(e,t,r)=>{"use strict";r.d(t,{ChatScreen:()=>eh});var a=r(5155),l=r(3804),n=r(2115),s=r(63),o=r(9678),d=r(1119),i=r(2604),c=r(4033),u=r(1847);let m=(0,u.A)("Paperclip",[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]]);var p=r(7910),x=r(3842);let h=(0,u.A)("SendHorizontal",[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]]);var b=r(549);function f(e){let{attachment:t,onRemove:r}=e;return(0,a.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-full border border-border bg-background px-3 py-1 text-xs text-muted-foreground",children:[(0,a.jsx)("span",{children:t.name}),(0,a.jsxs)("span",{children:[Math.max(1,Math.round(t.size/1024))," KB"]}),r?(0,a.jsx)("button",{type:"button",onClick:()=>r(t.id),className:"text-foreground",children:"\xd7"}):null]})}function g(e){let{disabled:t,onTranscript:r}=e;return(0,a.jsx)("button",{type:"button",disabled:t,onClick:()=>r("Voice input captured from mock microphone control."),className:"rounded-lg border border-border/70 bg-background/80 px-3 py-2 text-sm font-medium text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50","aria-label":"Voice input",children:"Mic"})}function y(e){let{disabled:t,statusNote:r,chips:l=[],starterPrompts:s=[],onSend:o}=e,[i,u]=(0,n.useState)(""),[y,v]=(0,n.useState)([]),[j,w]=(0,n.useState)(!1),N=(0,n.useRef)(null),k=(0,b.n)({mutationFn:async e=>{let t=new FormData;t.append("file",e);let r=await fetch("/api/uploads",{method:"POST",body:t});if(!r.ok)throw Error("Upload failed");let a=await r.json();return(0,d.x)("attachment.uploaded",{name:e.name,size:e.size}),a.attachment}}),S=j?l:l.slice(0,3),A=async e=>{let t=await k.mutateAsync(e);v(e=>[...e,t])},C=async e=>{e.preventDefault();let r=i.trim();if(!r&&0===y.length||t)return;let a=y.map(e=>e.id);u(""),v([]),(0,d.x)("chat.send",{attachmentCount:a.length}),await o(r||"Sent with attachments only.",a)};return(0,a.jsx)("form",{onSubmit:C,className:"shrink-0 border-t border-border/70 bg-background/80 p-2 md:p-3",children:(0,a.jsxs)("div",{className:"rounded-xl border border-border/70 card-default p-3 shadow-[var(--shadow-soft)]",onDragOver:e=>e.preventDefault(),onDrop:e=>{var t;e.preventDefault();let r=null==(t=e.dataTransfer.files)?void 0:t[0];r&&A(r)},children:[(0,a.jsxs)("div",{className:"mb-2 flex flex-wrap items-center gap-1.5",children:[S.map(e=>(0,a.jsx)("span",{className:"rounded-full border border-border/70 bg-background/80 px-3 py-1 text-xs font-medium text-foreground",children:e.label},e.key)),l.length>S.length?(0,a.jsxs)("span",{className:"text-xs text-muted-foreground",children:["+",l.length-S.length," more in details"]}):null,(0,a.jsxs)("button",{type:"button",onClick:()=>w(e=>!e),"aria-expanded":j,"aria-controls":"chat-composer-details",className:"inline-flex items-center gap-1 rounded-full border border-border/70 bg-background/60 px-3 py-1 text-xs font-medium text-muted-foreground",children:["Details",(0,a.jsx)(c.A,{className:"h-3.5 w-3.5 transition ".concat(j?"rotate-180":"")})]})]}),j?(0,a.jsxs)("div",{id:"chat-composer-details",className:"mb-3 grid gap-3 rounded-lg border border-border/70 bg-background/60 p-3 text-xs text-muted-foreground md:grid-cols-3",children:[(0,a.jsxs)("div",{className:"rounded-xl border border-border/70 bg-card/60 p-3",children:[(0,a.jsx)("p",{className:"font-semibold text-foreground",children:"Prompt first"}),(0,a.jsx)("p",{className:"mt-1",children:"Keep the ask short and outcome-oriented. Pan can gather tools, files, and approvals as the run unfolds."})]}),(0,a.jsxs)("div",{className:"rounded-xl border border-border/70 bg-card/60 p-3",children:[(0,a.jsx)("p",{className:"font-semibold text-foreground",children:"Visible context"}),(0,a.jsx)("p",{className:"mt-1",children:"Model, mode, tools, files, and profile stay inspectable without turning the composer into a dashboard."})]}),(0,a.jsxs)("div",{className:"rounded-xl border border-border/70 bg-card/60 p-3",children:[(0,a.jsx)("p",{className:"font-semibold text-foreground",children:"Attachments"}),(0,a.jsx)("p",{className:"mt-1",children:"Drop a file anywhere on the composer or use Attach to add screenshots, notes, and code snippets."})]})]}):null,y.length?(0,a.jsx)("div",{className:"mb-3 flex flex-wrap gap-2",children:y.map(e=>(0,a.jsx)(f,{attachment:e,onRemove:e=>v(t=>t.filter(t=>t.id!==e))},e.id))}):null,!i.trim()&&0===y.length&&s.length>0?(0,a.jsxs)("div",{className:"mb-3 rounded-xl border border-border/70 bg-background/60 p-3",children:[(0,a.jsx)("p",{className:"text-xs font-semibold uppercase tracking-label text-muted-foreground",children:"Try one of these"}),(0,a.jsx)("div",{className:"mt-3 flex flex-wrap gap-2",children:s.map(e=>(0,a.jsx)("button",{type:"button",onClick:()=>u(e),className:"rounded-2xl border border-border/70 bg-background/80 px-3 py-2 text-left text-xs font-medium leading-5 text-foreground transition hover:bg-card",children:e},e))})]}):null,(0,a.jsx)("textarea",{value:i,onChange:e=>u(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),C(e))},placeholder:t?"Agent is unavailable right now.":"Ask Pan to research, plan, debug, or build…",className:"min-h-14 w-full resize-none bg-transparent px-3 text-sm leading-7 outline-none placeholder:text-muted-foreground",disabled:t}),(0,a.jsxs)("div",{className:"mt-3 flex flex-col gap-3 xl:flex-row xl:items-center xl:justify-between",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("input",{ref:N,type:"file",className:"hidden",onChange:async e=>{var t;let r=null==(t=e.target.files)?void 0:t[0];r&&(await A(r),e.currentTarget.value="")}}),(0,a.jsxs)("button",{type:"button",onClick:()=>{var e;return null==(e=N.current)?void 0:e.click()},className:"inline-flex items-center gap-2 rounded-2xl border border-border/70 bg-background/80 px-3 py-2 text-sm font-medium text-foreground",children:[(0,a.jsx)(m,{className:"h-4 w-4"}),"Attach"]}),(0,a.jsx)(g,{disabled:t,onTranscript:e=>u(t=>"".concat(t).concat(t?" ":"").concat(e))}),r?(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:r}):null]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsxs)("span",{className:"hidden items-center gap-1 text-xs text-muted-foreground md:inline-flex",children:[(0,a.jsx)(p.A,{className:"h-3.5 w-3.5"}),"Context stays visible"]}),(0,a.jsxs)("span",{className:"hidden items-center gap-1 text-xs text-muted-foreground md:inline-flex",children:[(0,a.jsx)(x.A,{className:"h-3.5 w-3.5"}),"Tools stay inspectable"]}),(0,a.jsxs)("button",{type:"submit",disabled:t||!i.trim()&&0===y.length,className:"inline-flex items-center justify-center gap-2 rounded-2xl brand-gradient px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-[var(--shadow-card)] transition hover:-translate-y-0.5 disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)(h,{className:"h-4 w-4"}),"Send"]})]})]})]})})}let v=(0,u.A)("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);function j(e){let{onRename:t,onArchive:r,onDelete:l,onFork:s}=e,[o,d]=(0,n.useState)(!1);return(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("button",{type:"button",onClick:()=>d(e=>!e),className:"rounded-md border border-border/70 bg-background/80 px-2.5 py-1 text-2xs font-medium text-muted-foreground hover:bg-card",children:"Manage"}),o?(0,a.jsxs)("div",{className:"absolute right-0 top-10 z-10 w-40 rounded-lg border border-border/70 bg-background p-2 shadow-lg",children:[(0,a.jsx)("button",{type:"button",onClick:()=>{d(!1),t()},className:"block w-full rounded-md px-3 py-2 text-left text-sm hover:bg-card",children:"Rename"}),(0,a.jsx)("button",{type:"button",onClick:()=>{d(!1),s()},className:"block w-full rounded-md px-3 py-2 text-left text-sm hover:bg-card",children:"Fork"}),(0,a.jsx)("button",{type:"button",onClick:()=>{d(!1),r()},className:"block w-full rounded-md px-3 py-2 text-left text-sm hover:bg-card",children:"Archive"}),(0,a.jsx)("button",{type:"button",onClick:()=>{d(!1),l()},className:"block w-full rounded-md px-3 py-2 text-left text-sm text-danger hover:bg-card",children:"Delete"})]}):null]})}var w=r(592),N=r(4269);function k(e){var t,r,l;let{value:s,provider:o,onChange:d,ariaLabel:i="Model switcher",disabled:u,className:m}=e,p=null!=(r=function(e,t){var r,a,l;let s=(0,w.w)(),o=(0,n.useMemo)(()=>{var r,a,l,n;let o=new Map;for(let e of null!=(l=null==(r=s.data)?void 0:r.modelOptions)?l:[])o.set(e.id,e);return e&&!o.has(e)&&o.set(e,{id:e,label:e,provider:t||(null==(n=s.data)?void 0:n.provider)||"unknown",source:"session-current"}),!o.size&&(null==(a=s.data)?void 0:a.modelDefault)&&o.set(s.data.modelDefault,{id:s.data.modelDefault,label:s.data.modelDefault,provider:s.data.provider||"unknown",source:"runtime-default"}),Array.from(o.values())},[e,t,null==(r=s.data)?void 0:r.modelDefault,null==(a=s.data)?void 0:a.modelOptions,null==(l=s.data)?void 0:l.provider]);return{...s,data:o}}(s,o).data)?r:[];(0,n.useEffect)(()=>{!s&&p[0]&&d(p[0].id,p[0].provider)},[d,p,s]);let x=null!=(l=null==(t=p.find(e=>e.id===s))?void 0:t.label)?l:s;return(0,a.jsxs)("div",{className:(0,N.cn)("relative",m),children:[(0,a.jsx)("select",{value:x,onChange:e=>{let t=p.find(t=>t.label===e.target.value||t.id===e.target.value);t&&d(t.id,t.provider)},className:"min-w-[14rem] appearance-none rounded-2xl border border-border/70 bg-background/85 px-4 py-2.5 pr-10 text-sm font-medium outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/20 disabled:cursor-not-allowed disabled:opacity-60","aria-label":i,disabled:u||0===p.length,children:p.map(e=>(0,a.jsxs)("option",{value:e.label,children:[e.label," \xb7 ",e.provider]},e.id))}),(0,a.jsx)(c.A,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"})]})}var S=r(2263),A=r(4695);function C(e){let{title:t,settings:r,profileLabel:l,loadedSkillIds:n,runtimeConnected:s,controlsDisabled:o,isPersisted:d,archived:i,runtimeSummary:c,hasMessages:u,onOpenSettings:m,onRename:p,onArchive:x,onDelete:h,onFork:b,onModelChange:f}=e,g=(null!=n?n:[]).filter(e=>"skill-authoring"!==e),y=[l&&"Profile ".concat(l),r.model?"Model ".concat(r.model):"Default model",r.policyPreset&&"Mode ".concat(r.policyPreset)].filter(Boolean).join(" \xb7 ");return(0,a.jsx)("div",{className:(0,N.cn)("shrink-0 border-b border-border/60 bg-card/70 px-5",u?"py-2.5":"py-4"),children:(0,a.jsxs)("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0 space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs font-semibold uppercase tracking-label text-muted-foreground",children:"Chat"}),(0,a.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-3",children:[(0,a.jsx)("h2",{className:"truncate text-xl font-semibold tracking-tight text-foreground",children:t}),i?(0,a.jsx)(S.W,{label:"Archived",tone:"warning"}):null,d?(0,a.jsx)(S.W,{label:"Saved chat",tone:"success"}):(0,a.jsx)(S.W,{label:"New chat",tone:"warning"})]}),(0,a.jsx)("p",{className:"mt-2 text-xs leading-5 text-muted-foreground",children:y}),u&&c?(0,a.jsx)("p",{className:"mt-2 max-w-3xl text-sm leading-6 text-muted-foreground",children:c}):null]}),u?null:(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(0,a.jsx)(S.W,{label:s?"Runtime connected":"Runtime degraded",tone:(0,A.OX)(s?"healthy":"degraded")}),g.length?(0,a.jsx)(S.W,{label:"".concat(g.length," skill").concat(1===g.length?"":"s"," loaded"),tone:"accent"}):null]}),u?null:(0,a.jsxs)("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:["Start with one clear request. Attach a file or load a skill only when the task needs more context.",g.length?" Loaded: ".concat(g.slice(0,2).join(", ")).concat(g.length>2?" +".concat(g.length-2," more"):"","."):""]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 lg:max-w-[360px] lg:justify-end",children:[(0,a.jsx)(k,{value:r.model,provider:r.provider,onChange:f,ariaLabel:"Header model switcher",disabled:o}),(0,a.jsxs)("button",{type:"button",onClick:m,disabled:o,"aria-label":"Settings",className:"inline-flex items-center gap-2 rounded-2xl border border-border/70 bg-background/80 px-3 py-2.5 text-sm font-medium text-foreground shadow-[var(--shadow-card)] transition hover:-translate-y-0.5 hover:bg-card disabled:cursor-not-allowed disabled:opacity-60",children:[(0,a.jsx)(v,{className:"h-4 w-4"}),"Settings"]}),(0,a.jsx)(j,{onRename:p,onArchive:x,onDelete:h,onFork:b})]})]})})}var M=r(2619),P=r.n(M),D=r(5740);function L(e){var t,r;let{event:l,onApprove:n,onReject:s}=e;return(0,a.jsxs)("div",{className:"rounded-lg border border-approval/35 bg-approval/10 p-4 shadow-[var(--shadow-card)]",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs uppercase tracking-label text-muted-foreground",children:"Approval needed"}),(0,a.jsx)("h4",{className:"mt-1 text-sm font-semibold text-foreground",children:l.toolName}),(0,a.jsx)("p",{className:"mt-2 text-sm leading-6 text-foreground",children:l.summary})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)(S.W,{label:null!=(t=l.governance)?t:"approval-gated",tone:(0,A.fh)(null!=(r=l.governance)?r:"approval-gated")}),l.riskLevel?(0,a.jsx)(S.W,{label:"".concat(l.riskLevel," risk"),tone:(0,A.yD)(l.riskLevel)}):null]})]}),(0,a.jsxs)("div",{className:"mt-4 flex gap-2",children:[(0,a.jsx)("button",{type:"button",onClick:()=>n(l.toolCallId),className:"rounded-xl bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow-[var(--shadow-card)]",children:"Approve"}),(0,a.jsx)("button",{type:"button",onClick:()=>s(l.toolCallId),className:"rounded-xl border border-border px-4 py-2 text-sm text-foreground",children:"Reject"})]})]})}function T(e){let{artifact:t,onOpen:r}=e;return(0,a.jsxs)("button",{type:"button",onClick:()=>r(t.artifactId),className:"w-full rounded-2xl border border-border bg-card p-4 text-left shadow-sm transition hover:bg-muted/40",children:[(0,a.jsxs)("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:["Artifact \xb7 ",t.artifactType]}),(0,a.jsx)("h4",{className:"mt-1 text-sm font-semibold",children:t.label}),t.content?(0,a.jsx)("p",{className:"mt-2 line-clamp-3 text-sm text-muted-foreground",children:t.content}):null]})}var R=r(8192);let I=(0,u.A)("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);function _(e){let{text:t}=e;return(0,a.jsx)("button",{type:"button",onClick:()=>{"speechSynthesis"in window&&(window.speechSynthesis.cancel(),window.speechSynthesis.speak(new SpeechSynthesisUtterance(t)))},className:"rounded-md border border-border px-2 py-1 text-2xs text-muted-foreground","aria-label":"Play voice",children:"TTS"})}function E(e){var t;let{message:r}=e,l="user"===r.role;return(0,a.jsxs)("div",{className:(0,N.cn)("flex w-full gap-3",l?"justify-end":"justify-start"),children:[l?null:(0,a.jsx)("div",{className:"mt-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-2xl bg-[linear-gradient(135deg,hsl(var(--primary)),hsl(var(--accent)))] text-primary-foreground shadow-[var(--shadow-card)]",children:(0,a.jsx)(R.A,{className:"h-4 w-4"})}),(0,a.jsxs)("div",{className:(0,N.cn)("max-w-[88%] space-y-2",l&&"items-end"),children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 px-1",children:[(0,a.jsx)("p",{className:"text-2xs font-semibold uppercase tracking-label text-muted-foreground",children:l?"You":"Pan"}),(0,a.jsx)("p",{className:"text-2xs uppercase tracking-label text-muted-foreground",children:new Date(r.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),(0,a.jsxs)("div",{className:(0,N.cn)("rounded-lg border px-4 py-3 text-sm shadow-[var(--shadow-card)]",l?"border-primary/15 bg-[linear-gradient(135deg,hsl(var(--primary))/0.98,hsl(var(--accent))/0.92)] text-primary-foreground":"border-border/70 bg-card/80 text-card-foreground"),children:[(0,a.jsx)("p",{className:"whitespace-pre-wrap leading-7",children:r.content}),(null==(t=r.attachments)?void 0:t.length)?(0,a.jsx)("div",{className:"mt-3 flex flex-wrap gap-2",children:r.attachments.map(e=>(0,a.jsx)(f,{attachment:e},e.id))}):null,l?null:(0,a.jsx)("div",{className:"mt-3 flex items-center gap-2",children:(0,a.jsx)(_,{text:r.content})})]})]}),l?(0,a.jsx)("div",{className:"mt-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-2xl border border-border/70 bg-background/80 text-foreground shadow-[var(--shadow-card)]",children:(0,a.jsx)(I,{className:"h-4 w-4"})}):null]})}var O=r(9043),z=r(1375);function W(e){let t=[...e].reverse().find(e=>"run.phase"===e.type);if((null==t?void 0:t.type)==="run.phase")return t.label;if([...e].reverse().find(e=>"tool.awaiting_approval"===e.type))return"Waiting for approval before the agent can continue.";let r=[...e].reverse().find(e=>"tool.started"===e.type);return(null==r?void 0:r.type)==="tool.started"?"".concat(r.toolName," is running."):"Pan is responding…"}function q(e){var t;let{messages:r,runEvents:l,artifacts:s,streamingMessage:o,isStreaming:d,isLoading:i,onApprove:c,onReject:u,onOpenArtifact:m}=e,p=l.filter(e=>"assistant.delta"!==e.type&&"source.emitted"!==e.type),x=[...l].reverse().find(e=>"run.phase"===e.type),h=l.filter(e=>"tool.awaiting_approval"===e.type).length,b=(0,n.useRef)(null),f=(0,n.useRef)(null),g=(0,n.useRef)(!1);return(0,n.useEffect)(()=>{let e=b.current;if(!e)return;let t=()=>{g.current=e.scrollHeight-e.scrollTop-e.clientHeight>80};return e.addEventListener("scroll",t,{passive:!0}),()=>e.removeEventListener("scroll",t)},[]),(0,n.useEffect)(()=>{if(g.current)return;let e=b.current;e&&e.scrollTo({top:e.scrollHeight,behavior:d?"instant":"smooth"})},[r,o,d,l.length]),(0,a.jsxs)("div",{ref:b,className:"flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto px-5 py-5",children:[i?(0,a.jsx)(z.Gu,{title:"Loading chat…",description:"Fetching messages, events, and artifacts for the active chat."}):null,i||0!==r.length?null:(0,a.jsx)(z.pp,{title:"Start a chat",description:(0,a.jsxs)(a.Fragment,{children:["Research, plan, debug, or build. Runtime activity, approvals, sources, and generated outputs stay legible instead of being buried inside assistant prose.",(0,a.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[(0,a.jsx)(S.W,{label:"Chat-first",tone:"accent"}),(0,a.jsx)(S.W,{label:"Tool-aware",tone:"success"}),(0,a.jsx)(S.W,{label:"Approval-ready",tone:"warning"})]})]}),icon:(0,a.jsx)(D.A,{className:"h-4 w-4"}),primaryAction:(0,a.jsx)(P(),{href:"/skills",className:"rounded-2xl bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",children:"Browse skills"}),secondaryAction:(0,a.jsx)(P(),{href:"/marketplace",className:"rounded-2xl border border-border/70 bg-background/80 px-4 py-2 text-sm font-medium text-foreground",children:"Open marketplace"})}),(d||p.length>0)&&!i?(0,a.jsx)("div",{className:"rounded-lg border border-border/70 bg-background/60 p-4 shadow-[var(--shadow-card)]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-2xs font-semibold uppercase tracking-label text-muted-foreground",children:"Runtime activity"}),(0,a.jsx)("p",{className:"mt-1 text-sm font-medium text-foreground",children:d?W(l):null!=(t=null==x?void 0:x.label)?t:"No active tool run"})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(null==x?void 0:x.type)==="run.phase"?(0,a.jsx)(S.W,{label:x.phase,tone:"accent"}):null,(0,a.jsx)(S.W,{label:"".concat(p.length," events"),tone:"muted"}),h?(0,a.jsx)(S.W,{label:"".concat(h," approvals"),tone:"warning"}):null]})]})}):null,r.map(e=>(0,a.jsx)(E,{message:e},e.id)),p.map((e,t)=>{if("tool.started"===e.type||"tool.completed"===e.type)return(0,a.jsx)(O.J,{event:e},"".concat(e.type,"-").concat(e.toolCallId,"-").concat(t));if("tool.awaiting_approval"===e.type)return(0,a.jsx)(L,{event:e,onApprove:c,onReject:u},"".concat(e.type,"-").concat(e.toolCallId,"-").concat(t));if("artifact.emitted"===e.type){var r;let l=null!=(r=s.find(t=>t.artifactId===e.artifactId))?r:e;return(0,a.jsx)(T,{artifact:l,onOpen:m},"".concat(e.type,"-").concat(e.artifactId,"-").concat(t))}return"run.phase"===e.type?(0,a.jsx)("div",{className:"rounded-lg border border-border/70 bg-background/80 px-4 py-3 text-sm text-muted-foreground shadow-[var(--shadow-card)]",children:e.label},"".concat(e.type,"-").concat(t)):"error"===e.type?(0,a.jsx)(z.W5,{error:e.message,layout:"banner"},"".concat(e.type,"-").concat(t)):null}),d?(0,a.jsxs)("div",{className:"flex justify-start gap-3",children:[(0,a.jsx)("div",{className:"mt-1 flex h-9 w-9 items-center justify-center rounded-2xl bg-[linear-gradient(135deg,hsl(var(--primary)),hsl(var(--accent)))] text-primary-foreground shadow-[var(--shadow-card)]",children:(0,a.jsx)(D.A,{className:"h-4 w-4"})}),(0,a.jsxs)("div",{className:"max-w-[88%] rounded-lg border border-border/70 bg-card/80 px-4 py-3 text-sm shadow-[var(--shadow-card)]",children:[(0,a.jsx)("p",{className:"whitespace-pre-wrap leading-7",children:o||"…"}),(0,a.jsx)("p",{className:"mt-3 text-2xs uppercase tracking-label text-muted-foreground",children:W(l)})]})]}):null,(0,a.jsx)("div",{ref:f,"aria-hidden":"true",className:"h-px shrink-0"})]})}var F=r(9776);function H(e){if(!e)return null;let t=e.title||e.label||e.name||e.href||e.url;return t?{id:String(e.id||e.href||e.url||e.label||t),title:String(t),href:e.href||e.url?String(e.href||e.url):void 0,snippet:e.snippet||e.quote||e.description?String(e.snippet||e.quote||e.description):void 0,sourceType:function(e){switch(String(e||"").toLowerCase()){case"web":case"url":return"web";case"file":return"file";case"workspace":return"workspace";case"integration":return"integration";default:return"unknown"}}(e.sourceType||e.kind||e.type),provenance:function(e){switch(String(e||"").toLowerCase()){case"builtin":case"built-in":return"built-in";case"verified":return"verified";case"self-hosted":case"self_hosted":return"self-hosted";case"local-process":case"local_process":return"local-process";default:return"custom"}}(e.provenance),note:e.note?String(e.note):void 0,label:e.label?String(e.label):void 0}:null}var U=r(6288);function J(e){let{open:t,title:r,description:l,confirmLabel:n,confirmClassName:s,onClose:o,onConfirm:d}=e;return t?(0,a.jsx)("div",{className:"fixed inset-0 z-30 flex items-center justify-center bg-black/50 p-4",children:(0,a.jsxs)("div",{className:"w-full max-w-md rounded-2xl border border-border bg-background p-5 shadow-xl",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:r}),(0,a.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:l}),(0,a.jsxs)("div",{className:"mt-5 flex justify-end gap-2",children:[(0,a.jsx)("button",{type:"button",onClick:o,className:"rounded-lg border border-border px-4 py-2 text-sm",children:"Cancel"}),(0,a.jsx)("button",{type:"button",onClick:()=>void d(),className:null!=s?s:"rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",children:n})]})]})}):null}function K(e){let{open:t,initialTitle:r,onClose:l,onSubmit:s}=e,[o,d]=(0,n.useState)(r);return((0,n.useEffect)(()=>{d(r)},[r]),t)?(0,a.jsx)("div",{className:"fixed inset-0 z-30 flex items-center justify-center bg-black/50 p-4",children:(0,a.jsxs)("div",{className:"w-full max-w-md rounded-2xl border border-border bg-background p-5 shadow-xl",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Rename session"}),(0,a.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Give this conversation a clearer title."}),(0,a.jsx)("input",{"aria-label":"Rename session input",value:o,onChange:e=>d(e.target.value),className:"mt-4 w-full rounded-lg border border-input bg-background px-3 py-2 text-sm outline-none focus:border-primary"}),(0,a.jsxs)("div",{className:"mt-5 flex justify-end gap-2",children:[(0,a.jsx)("button",{type:"button",onClick:l,className:"rounded-lg border border-border px-4 py-2 text-sm",children:"Cancel"}),(0,a.jsx)("button",{type:"button",onClick:()=>void s(o),className:"rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",children:"Save"})]})]})}):null}var V=r(6191);let B=(0,u.A)("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]),G=(0,u.A)("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),Q=(0,u.A)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]),Y=(0,u.A)("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]);function X(e){let{value:t,onChange:r}=e;return(0,a.jsx)("div",{className:"border-b border-border/70 px-4 pb-3 pt-1",children:(0,a.jsx)("input",{value:t,onChange:e=>r(e.target.value),placeholder:"Search sessions…",className:"w-full rounded-2xl border border-border/70 bg-background/85 px-4 py-3 text-sm outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/20"})})}let Z=(0,u.A)("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]),$=(0,u.A)("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]),ee=(0,u.A)("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]),et=(0,u.A)("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);var er=r(7586);let ea=(0,u.A)("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]),el=(0,u.A)("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);var en=r(803),es=r(9068),eo=r(21);let ed={webui:{label:"WebUI",icon:Z,classes:"border-border/60 bg-muted/60 text-muted-foreground"},whatsapp:{label:"WhatsApp",icon:$,classes:"border-emerald-500/40 bg-emerald-500/10 text-emerald-400"},discord:{label:"Discord",icon:ee,classes:"border-indigo-500/40 bg-indigo-500/10 text-indigo-300"},telegram:{label:"Telegram",icon:et,classes:"border-sky-500/40 bg-sky-500/10 text-sky-300"},signal:{label:"Signal",icon:er.A,classes:"border-blue-500/40 bg-blue-500/10 text-blue-300"},slack:{label:"Slack",icon:ee,classes:"border-fuchsia-500/40 bg-fuchsia-500/10 text-fuchsia-300"},matrix:{label:"Matrix",icon:er.A,classes:"border-teal-500/40 bg-teal-500/10 text-teal-300"},mattermost:{label:"Mattermost",icon:er.A,classes:"border-cyan-500/40 bg-cyan-500/10 text-cyan-300"},sms:{label:"SMS",icon:ea,classes:"border-amber-500/40 bg-amber-500/10 text-amber-300"},email:{label:"Email",icon:el,classes:"border-rose-500/40 bg-rose-500/10 text-rose-300"},cli:{label:"CLI",icon:en.A,classes:"border-slate-500/40 bg-slate-500/10 text-slate-300"},api:{label:"API",icon:es.A,classes:"border-violet-500/40 bg-violet-500/10 text-violet-300"},unknown:{label:"Unknown",icon:eo.A,classes:"border-border/50 bg-muted/40 text-muted-foreground"}};function ei(e){var t;return null!=(t=ed[null!=e?e:"unknown"])?t:ed.unknown}let ec=["webui","whatsapp","discord","telegram","signal","slack","matrix","mattermost","sms","email","cli","api","unknown"];function eu(e){let{source:t,iconOnly:r,className:l}=e,n=ei(t),s=n.icon;return(0,a.jsxs)("span",{title:n.label,"aria-label":"Session source: ".concat(n.label),className:(0,N.cn)("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-3xs uppercase tracking-label",n.classes,r&&"h-5 w-5 justify-center px-0",l),children:[(0,a.jsx)(s,{className:"h-3 w-3","aria-hidden":"true"}),r?null:(0,a.jsx)("span",{children:n.label})]})}function em(e){var t;return null!=(t=e.source)?t:"unknown"}function ep(e){let{sessions:t,selectedSessionId:r,search:l,isLoading:s,onSearchChange:o,onNewChat:d,onSelectSession:c,onResumeSession:u}=e,[m,p]=(0,n.useState)(25),[x,h]=(0,n.useState)("all"),{sidebarCompact:b,toggleSidebarCompact:f}=(0,i.j)(),g=(0,n.useMemo)(()=>{let e=new Set;for(let r of t)e.add(em(r));return ec.filter(t=>e.has(t))},[t]),y=g.length>1,v=(0,n.useMemo)(()=>{let e=l.trim()?t.filter(e=>!e.parentSessionId):t;return"all"===x?e:e.filter(e=>em(e)===x)},[t,l,x]),j=v.filter(e=>e.pinned&&!e.archived),w=v.filter(e=>!e.pinned&&!e.archived),k=v.filter(e=>e.archived),[S,A]=(0,n.useState)(!1),C=[{label:"Pinned",items:j},{label:"Recent",items:w.slice(0,m)},{label:"Archived",items:S?k:k.slice(0,5)}].filter(e=>e.items.length>0),M=w.length>m,P=!S&&k.length>5;return(0,a.jsxs)("aside",{className:"flex h-full max-h-full flex-col overflow-hidden rounded-xl border border-border/70 bg-card/60 shadow-[var(--shadow-soft)]",children:[(0,a.jsxs)("div",{className:(0,N.cn)("border-b border-border/60",b?"p-3":"p-4"),children:[(0,a.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-2",children:[(0,a.jsx)("p",{className:"text-xs font-semibold uppercase tracking-label text-muted-foreground",children:"Chats"}),(0,a.jsx)("button",{type:"button",onClick:f,className:"rounded-full border border-border/70 bg-background/80 px-2.5 py-1 text-3xs font-medium uppercase tracking-label text-muted-foreground",children:b?"Comfort":"Compact"})]}),(0,a.jsxs)("button",{type:"button",onClick:d,className:(0,N.cn)("flex w-full items-center justify-center gap-2 rounded-lg brand-gradient text-sm font-semibold text-primary-foreground shadow-[var(--shadow-card)] transition hover:-translate-y-0.5",b?"px-3 py-2.5":"px-4 py-3"),children:[(0,a.jsx)(V.A,{className:"h-4 w-4"}),"New chat"]}),(0,a.jsxs)("p",{className:"mt-3 text-xs leading-5 text-muted-foreground",children:[v.length," chats \xb7 ",j.length," pinned \xb7 ",k.length," archived"]})]}),(0,a.jsx)(X,{value:l,onChange:o}),y?(0,a.jsxs)("div",{className:(0,N.cn)("border-b border-border/70 px-3",b?"pb-2":"pb-3"),children:[(0,a.jsx)("div",{className:"mb-1.5 px-1 text-2xs font-semibold uppercase tracking-label text-muted-foreground",children:"Source"}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[(0,a.jsx)("button",{type:"button",onClick:()=>h("all"),className:(0,N.cn)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-3xs uppercase tracking-label transition","all"===x?"border-primary/60 bg-primary/15 text-primary":"border-border/60 bg-muted/40 text-muted-foreground hover:bg-muted/60"),children:"All"}),g.map(e=>{let t=ei(e),r=t.icon,l=x===e;return(0,a.jsxs)("button",{type:"button",onClick:()=>h(e),className:(0,N.cn)("inline-flex items-center gap-1 rounded-full border px-2.5 py-0.5 text-3xs uppercase tracking-label transition",l?t.classes.replace("/10","/20").replace("/40","/60"):"border-border/60 bg-muted/40 text-muted-foreground hover:bg-muted/60"),title:t.label,children:[(0,a.jsx)(r,{className:"h-3 w-3","aria-hidden":"true"}),t.label]},e)})]})]}):null,(0,a.jsxs)("div",{className:(0,N.cn)("flex-1 overflow-y-auto",b?"space-y-3 p-2":"space-y-4 p-3"),children:[s?(0,a.jsx)(z.Gu,{layout:"banner",title:"Loading chats…"}):null,s||0!==v.length?null:(0,a.jsx)(z.pp,{layout:"banner",title:"all"===x?"No chats found":"No ".concat(ei(x).label," chats"),description:"all"===x?"Try a different search term or start a new chat.":"Change the source filter or start a new chat."}),C.map(e=>(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-2 text-2xs font-semibold uppercase tracking-label text-muted-foreground",children:[(0,a.jsx)("span",{children:e.label}),(0,a.jsx)("span",{children:e.items.length})]}),e.items.map(e=>{var t;let l=function(e){let t=em(e);return"webui"!==t&&"unknown"!==t}(e);return(0,a.jsxs)("button",{type:"button",onClick:()=>c(e.id),"aria-label":/\(fork\)/i.test(e.title)&&r!==e.id?e.title:"Open session ".concat(e.id),className:(0,N.cn)("w-full rounded-xl border text-left transition",b?"px-3 py-2.5":"px-4 py-3",r===e.id?"border-primary/30 bg-primary/10 shadow-[var(--shadow-card)] ring-1 ring-primary/10":"border-border/60 bg-background/70 hover:border-border/70 hover:bg-card/50"),children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("p",{"aria-hidden":"true",className:"truncate text-sm font-semibold text-foreground",children:e.title}),e.pinned?(0,a.jsx)(B,{className:"h-3.5 w-3.5 text-muted-foreground","aria-hidden":"true"}):null,e.parentSessionId?(0,a.jsx)(G,{className:"h-3.5 w-3.5 text-muted-foreground","aria-hidden":"true"}):null]}),(0,a.jsx)("p",{"aria-hidden":"true",className:(0,N.cn)("mt-1 text-xs leading-5 text-muted-foreground",b?"line-clamp-1":"line-clamp-2"),children:(t=e.preview)?t.length>88?"".concat(t.slice(0,85),"…"):t:"No messages yet."})]}),(0,a.jsxs)("div",{className:"flex shrink-0 flex-col items-end gap-1",children:[(0,a.jsx)(eu,{source:em(e),iconOnly:b}),l&&u&&r===e.id?(0,a.jsxs)("span",{role:"button",tabIndex:0,onClick:t=>{t.stopPropagation(),null==u||u(e.id)},onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),t.stopPropagation(),null==u||u(e.id))},"aria-label":"Resume ".concat(ei(em(e)).label," session"),className:(0,N.cn)("inline-flex items-center rounded-full border border-primary/50 bg-primary/10 text-3xs uppercase tracking-label text-primary transition hover:bg-primary/20 cursor-pointer",b?"h-5 w-5 justify-center px-0 py-0":"gap-1 px-2 py-0.5"),children:[(0,a.jsx)(Q,{className:"h-3 w-3"}),b?null:"Resume"]}):null]})]}),(0,a.jsxs)("div",{className:(0,N.cn)("flex items-center justify-between gap-2 text-2xs text-muted-foreground",b?"mt-2":"mt-3"),children:[(0,a.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,a.jsx)(Y,{className:"h-3.5 w-3.5"}),new Date(e.updatedAt).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})]}),!b&&e.workspaceLabel&&r===e.id?(0,a.jsx)("span",{children:e.workspaceLabel}):null]})]},e.id)})]},e.label)),M?(0,a.jsxs)("button",{type:"button",onClick:()=>p(e=>e+25),className:"mx-2 mt-2 rounded-xl border border-border/70 bg-background/80 px-3 py-2 text-xs font-medium text-muted-foreground transition hover:bg-card",children:["Show more (",w.length-m," remaining)"]}):null,P?(0,a.jsxs)("button",{type:"button",onClick:()=>A(!0),className:"mx-2 mt-2 rounded-xl border border-border/70 bg-background/80 px-3 py-2 text-xs font-medium text-muted-foreground transition hover:bg-card",children:["Show all archived (",k.length-5," more)"]}):null]})]})}function ex(e){let{open:t,settings:r,saving:l,error:s,disabled:o,onClose:d,onSave:i}=e,[c,u]=(0,n.useState)(r);return((0,n.useEffect)(()=>{u(r)},[r]),t)?(0,a.jsx)("div",{className:"fixed inset-0 z-30 flex justify-end bg-black/45 backdrop-blur-sm",children:(0,a.jsxs)("div",{className:"h-full w-full max-w-md border-l border-border/70 bg-background/95 p-5 shadow-[var(--shadow-elevated)]",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Session controls"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Model selection is runtime-backed. Policy and memory settings are session guidance stored with this chat."})]}),(0,a.jsx)("button",{type:"button",onClick:d,className:"rounded-2xl border border-border/70 bg-background/80 px-3 py-2 text-sm font-medium text-foreground",children:"Close"})]}),(0,a.jsxs)("div",{className:"mt-6 space-y-5 rounded-lg border border-border/70 bg-card/60 p-4 shadow-[var(--shadow-card)]",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{htmlFor:"chat-model",className:"text-sm font-medium",children:"Model"}),(0,a.jsx)("div",{id:"chat-model",children:(0,a.jsx)(k,{value:c.model,provider:c.provider,onChange:(e,t)=>u(r=>({...r,model:e,provider:t})),ariaLabel:"Settings model switcher",disabled:o||l,className:"w-full"})})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{htmlFor:"policy-preset",className:"text-sm font-medium",children:"Policy preset"}),(0,a.jsxs)("select",{id:"policy-preset",value:c.policyPreset,onChange:e=>u(t=>({...t,policyPreset:e.target.value})),className:"w-full rounded-2xl border border-input bg-background/85 px-4 py-3 text-sm outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/20",disabled:o||l,children:[(0,a.jsx)("option",{value:"safe-chat",children:"Safe Chat"}),(0,a.jsx)("option",{value:"research",children:"Research"}),(0,a.jsx)("option",{value:"builder",children:"Builder"}),(0,a.jsx)("option",{value:"full-power",children:"Full Power"})]})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{htmlFor:"memory-mode",className:"text-sm font-medium",children:"Memory mode"}),(0,a.jsxs)("select",{id:"memory-mode",value:c.memoryMode,onChange:e=>u(t=>({...t,memoryMode:e.target.value})),className:"w-full rounded-2xl border border-input bg-background/85 px-4 py-3 text-sm outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/20",disabled:o||l,children:[(0,a.jsx)("option",{value:"standard",children:"Standard"}),(0,a.jsx)("option",{value:"minimal",children:"Minimal"})]})]})]}),s?(0,a.jsx)("div",{className:"mt-4 rounded-2xl border border-danger/30 bg-danger/10 px-4 py-3 text-sm text-foreground",children:s}):null,(0,a.jsx)("div",{className:"mt-8 flex justify-end",children:(0,a.jsx)("button",{type:"button",onClick:()=>void i(c),disabled:o||l,className:"rounded-2xl bg-[linear-gradient(135deg,hsl(var(--primary)),hsl(var(--accent)))] px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-[var(--shadow-card)] disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving…":"Save settings"})})]})}):null}function eh(){var e,t,r,c,u,m,p,x,h,f,g,v,j,N,k,S,A,M,P,D;let L=(0,s.useSearchParams)(),T=L.get("session"),R=L.get("loadedSkill"),[I,_]=(0,n.useState)(""),[E,O]=(0,n.useState)(null),[W,V]=(0,n.useState)([]),[B,G]=(0,n.useState)(""),[Q,Y]=(0,n.useState)(!1),[X,Z]=(0,n.useState)(!1),[$,ee]=(0,n.useState)(!1),[et,er]=(0,n.useState)(!1),[ea,el]=(0,n.useState)(null),[en,es]=(0,n.useState)(null),[eo,ed]=(0,n.useState)({model:"",provider:"unknown",policyPreset:"safe-chat",memoryMode:"standard"}),ei=(0,U.te)(I),ec=(0,w.w)(),eu=(0,U.oz)(),em=(0,U.Kp)(),eh=(0,U.Sv)(),eb=(0,U.tS)(),ef=(0,U.QV)(),eg=(0,U.Or)(),ey=function(){let e=(0,F.jE)();return(0,b.n)({mutationFn:async e=>{var t,r;let{sessionId:a,message:l,attachmentIds:n,onEvent:s}=e,d=await fetch("/api/chat/stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:a,message:l,attachmentIds:n})});if(!d.ok||!d.body){let e=await d.json().catch(()=>null);throw new o.h(d.status,null!=(t=null==e?void 0:e.error)?t:"Unable to stream response",null==e?void 0:e.code,e)}let i=d.body.getReader(),c=new TextDecoder,u="",m=!1;for(;!m;){let{value:e,done:t}=await i.read();if(m=t,t||!e)break;let a=(u+=c.decode(e,{stream:!0})).split("\n\n");for(let e of(u=null!=(r=a.pop())?r:"",a))for(let t of function(e){let t=[];for(let o of e.split("\n\n"))for(let e of o.split("\n").filter(e=>e.startsWith("data:"))){var r,a,l,n,s;let o=e.replace(/^data:\s*/,"").trim();if(!o||"[DONE]"===o)continue;let d=function(e){try{return JSON.parse(e)}catch(e){return null}}(o);if(!d)continue;if("assistant.delta"===d.type||"run.phase"===d.type||"tool.started"===d.type||"tool.awaiting_approval"===d.type||"tool.completed"===d.type||"artifact.emitted"===d.type||"source.emitted"===d.type||"error"===d.type){t.push(d);continue}if("response.output_text.delta"===d.type&&d.delta){t.push({type:"assistant.delta",delta:String(d.delta)});continue}if("response.output_item.added"===d.type&&(null==(r=d.item)?void 0:r.type)==="function_call"){t.push({type:"tool.started",toolCallId:String(d.item.call_id||d.item.id||"tool-call"),toolName:String(d.item.name||"function_call"),riskLevel:"execute",provenance:"local-process"});continue}if("response.output_item.done"===d.type&&(null==(a=d.item)?void 0:a.type)==="function_call"){t.push({type:"tool.completed",toolCallId:String(d.item.call_id||d.item.id||"tool-call"),toolName:String(d.item.name||"function_call"),output:"string"==typeof d.item.arguments?d.item.arguments:JSON.stringify(d.item.arguments||{}),riskLevel:"execute"});continue}if("response.output_item.added"===d.type&&(null==(l=d.item)?void 0:l.type)==="file_search_call"){t.push({type:"tool.started",toolCallId:String(d.item.call_id||d.item.id||"file-search"),toolName:"file_search",riskLevel:"read",provenance:"built-in"});continue}let i=H(d.source||d.citation||(null==(n=d.metadata)?void 0:n.source)||null);if(i&&t.push({type:"source.emitted",source:i}),("response.completed"===d.type||"response.output_item.done"===d.type)&&Array.isArray(null==(s=d.response)?void 0:s.output))for(let e of d.response.output){if((null==e?void 0:e.type)==="message"&&Array.isArray(e.content))for(let r of e.content){((null==r?void 0:r.type)==="output_text"||(null==r?void 0:r.type)==="text")&&r.text&&t.push({type:"assistant.delta",delta:String(r.text)});let e=H((null==r?void 0:r.source)||(null==r?void 0:r.citation)||null);e&&t.push({type:"source.emitted",source:e})}(null==e?void 0:e.type)==="function_call"&&t.push({type:"tool.completed",toolCallId:String(e.call_id||e.id||"tool-call"),toolName:String(e.name||"function_call"),output:"string"==typeof e.arguments?e.arguments:JSON.stringify(e.arguments||{}),riskLevel:"execute"})}}return t}("".concat(e,"\n\n")))null==s||s(t)}return a},onSuccess:async t=>{await e.invalidateQueries({queryKey:["sessions"]}),await e.invalidateQueries({queryKey:["session",t]})}})}(),{runEvents:ev,artifacts:ej,addRunEvent:ew,addArtifact:eN,resetRunState:ek,selectArtifact:eS,updateApprovalState:eA,activeSessionId:eC,setActiveSessionId:eM,selectedProfileId:eP,recentlyLoadedSkillIds:eD,sessionLoadedSkillIds:eL}=(0,i.j)();(0,n.useEffect)(()=>{var e,t;if(!(null==(e=ei.data)?void 0:e.length))return;let r=T&&ei.data.some(e=>e.id===T)?T:null,a=eC&&ei.data.some(e=>e.id===eC)?eC:null,l=null!=(t=null!=r?r:a)?t:ei.data[0].id;(!E||T&&E!==T&&l===T)&&O(l)},[eC,T,E,ei.data]),(0,n.useEffect)(()=>{if(E&&ei.data&&!ei.data.some(e=>e.id===E)){var e,t;O(null!=(t=null==(e=ei.data[0])?void 0:e.id)?t:null)}},[E,ei.data]);let eT=(0,U.wV)(E);(0,n.useEffect)(()=>{E&&eM(E)},[E,eM]),(0,n.useEffect)(()=>{var e,t;if(null==(e=eT.data)?void 0:e.settings)return void ed(eT.data.settings);(null==(t=ec.data)?void 0:t.modelDefault)&&ed(e=>{var t,r;return{...e,model:(null==(t=ec.data)?void 0:t.modelDefault)||e.model,provider:(null==(r=ec.data)?void 0:r.provider)||e.provider}})},[null==(e=ec.data)?void 0:e.modelDefault,null==(t=ec.data)?void 0:t.provider,null==(r=eT.data)?void 0:r.settings]);let eR=(0,n.useMemo)(()=>{var e,t;return[...null!=(t=null==(e=eT.data)?void 0:e.messages)?t:[],...W]},[W,null==(c=eT.data)?void 0:c.messages]),eI=null!=(v=null==(u=ec.data)?void 0:u.apiReachable)&&v,e_=null!=(j=null==(m=ec.data)?void 0:m.available)&&j,eE=null!=(N=null==(p=ec.data)?void 0:p.mockMode)&&N,eO=e_&&!eI,ez=eO&&!eE||eg.isPending,eW=null!=(k=null==(x=eT.data)?void 0:x.title)?k:"New chat",eq=null!=(A=null!=(S=null==(h=ec.data)?void 0:h.activeProfile)?S:eP)?A:"default",eF=!!(E&&eT.data),eH=[{key:"model",label:"Model \xb7 ".concat(eo.model||"default")},{key:"tools",label:"Tools \xb7 ".concat(eI?"runtime live":"degraded")},{key:"profile",label:"Profile \xb7 ".concat(eq)},{key:"mode",label:"Mode \xb7 ".concat(eo.policyPreset)},{key:"files",label:"Files \xb7 ".concat(ej.length)}],eU=E&&null!=(M=eL[E])?M:[],eJ=Array.from(new Set([R,...null!=eU?eU:[],...null!=eD?eD:[],...null!=(P=null==(f=eT.data)?void 0:f.loadedSkillIds)?P:[]].filter(Boolean))),eK=eI?"Talking to ".concat(eo.provider," via the live runtime."):eE?"Mock mode is active for chat flows, approvals, sources, and artifacts.":e_?"Runtime is detected but the API is unreachable, so sending is paused until connectivity returns.":"Runtime was not detected. The UI can still show saved local state and explicit fallback labels.",eV=e=>{es(null),el(null),ek(),V([]),G(""),O(e),eM(e)},eB=async()=>{es(null),el(null),ek(),O(null),eM(null),V([]),G("")},eG=async(e,t)=>{let r=E;r||(O(r=(await eu.mutateAsync()).session.id),eM(r));let a={id:"optimistic-".concat(Date.now()),role:"user",content:e,createdAt:new Date().toISOString()};ek(),es(null),V(e=>[...e,a]),G("");let l=!1;try{await ey.mutateAsync({sessionId:r,message:e,attachmentIds:t,onEvent:e=>{if("assistant.delta"===e.type)return void G(t=>t+e.delta);ew(e),"artifact.emitted"===e.type&&eN({artifactId:e.artifactId,artifactType:e.artifactType,label:e.label,content:e.content})}})}catch(t){l=!0;let e=t instanceof Error?t.message:"Unable to send message.";t instanceof o.h&&503===t.status?(es("Message saved, but the runtime API is unavailable right now. Check diagnostics or retry when the backend comes back."),await Promise.all([eT.refetch(),ei.refetch(),ec.refetch()])):es(e),V([]),G("")}l||(await eT.refetch(),V([]),G(""))},eQ=async(e,t)=>{if(E){el(null),es(null),ed(r=>({...r,model:e,provider:t}));try{await eg.mutateAsync({sessionId:E,settings:{model:e,provider:t}})}catch(e){ed(eo),el(e instanceof Error?e.message:"Unable to update session settings.")}}},eY=async e=>{if(E){el(null),es(null),ed(t=>({...t,...e}));try{await eg.mutateAsync({sessionId:E,settings:e}),er(!1)}catch(e){ed(eo),el(e instanceof Error?e.message:"Unable to update session settings.")}}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid h-full gap-5 lg:grid-cols-[320px_minmax(0,1fr)]",children:[(0,a.jsx)(ep,{sessions:null!=(D=ei.data)?D:[],selectedSessionId:E,search:I,isLoading:ei.isLoading,onSearchChange:_,onNewChat:()=>void eB(),onSelectSession:eV,onResumeSession:eV}),(0,a.jsxs)("section",{className:"flex min-w-0 flex-col overflow-hidden rounded-xl border border-border/70 bg-card/60 shadow-[var(--shadow-elevated)]",children:[eE?(0,a.jsx)("div",{className:"border-b border-warning/30 bg-warning/10 px-5 py-3 text-sm text-foreground",children:"Mock mode is active for chat flows, approvals, sources, and artifacts."}):null,(0,a.jsx)(C,{title:eW,settings:eo,profileLabel:eq,loadedSkillIds:eJ,runtimeConnected:eI,controlsDisabled:ez,isPersisted:eF,archived:null==(g=eT.data)?void 0:g.archived,runtimeSummary:eK,hasMessages:eR.length>0,onOpenSettings:()=>{el(null),er(!0)},onRename:()=>Y(!0),onArchive:()=>Z(!0),onDelete:()=>ee(!0),onFork:()=>{E&&ef.mutateAsync(E).then(e=>{let{session:t}=e;ek(),_(""),O(t.id),eM(t.id),V([]),G("")})},onModelChange:(e,t)=>{eQ(e,t)}}),(0,a.jsx)(q,{messages:eR,runEvents:ev,artifacts:ej,streamingMessage:B,isStreaming:ey.isPending,isLoading:eT.isLoading,onApprove:e=>{(0,d.x)("approval.approved",{toolCallId:e}),fetch("/api/runtime/approvals/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"approved"})}).catch(()=>void 0),eA(e,!0)},onReject:e=>{(0,d.x)("approval.rejected",{toolCallId:e}),fetch("/api/runtime/approvals/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"rejected"})}).catch(()=>void 0),eA(e,!1)},onOpenArtifact:e=>eS(e)}),eO&&!eE?(0,a.jsx)("div",{className:"mx-4 mb-0",children:(0,a.jsx)(z.eS,{layout:"banner",title:"Runtime API is currently unavailable",description:"You can still inspect saved chats, approvals, sources, and artifacts, but sending new messages is paused until the backend reconnects.",primaryAction:(0,a.jsxs)("button",{type:"button",onClick:()=>void ec.refetch(),className:"inline-flex items-center gap-2 rounded-2xl border border-border/70 bg-background/80 px-3 py-2 text-sm font-medium text-foreground",children:[(0,a.jsx)(l.A,{className:"h-4 w-4"}),"Retry runtime"]}),secondaryAction:(0,a.jsx)("a",{href:"/settings/health",className:"rounded-2xl border border-border/70 bg-background/80 px-3 py-2 text-sm font-medium text-foreground",children:"Open diagnostics"})})}):null,en?(0,a.jsx)("div",{className:"mx-4 mt-4",children:(0,a.jsx)(z.W5,{error:en,layout:"banner"})}):null,ea?(0,a.jsx)("div",{className:"mx-4 mt-4",children:(0,a.jsx)(z.W5,{error:ea,layout:"banner"})}):null,(0,a.jsx)(y,{disabled:ey.isPending||eO&&!eE,statusNote:eO&&!eE?"Runtime offline — sending is paused until it reconnects.":eE?"Mock mode active \xb7 Enter to send \xb7 Shift+Enter for newline \xb7 drag files to attach.":0===eR.length?"Start with one request. You can add files or open details if the task needs more context.":"Enter to send \xb7 Shift+Enter for newline \xb7 drag files to attach.",chips:eH,starterPrompts:0===eR.length?["Summarize this context and give me the best next step","Help me turn the current task into an implementation plan","Review the current context and point out risks or open questions"]:[],onSend:eG})]})]}),(0,a.jsx)(K,{open:Q,initialTitle:eW,onClose:()=>Y(!1),onSubmit:async e=>{E&&(Y(!1),await em.mutateAsync({sessionId:E,title:e}))}}),(0,a.jsx)(J,{open:X,title:"Archive session",description:"Archive this conversation but keep it available in history and search.",confirmLabel:"Archive",onClose:()=>Z(!1),onConfirm:async()=>{E&&(await eh.mutateAsync(E),Z(!1))}}),(0,a.jsx)(J,{open:$,title:"Delete session",description:"This permanently removes the selected conversation from the current chat history.",confirmLabel:"Delete",confirmClassName:"rounded-2xl bg-danger px-4 py-2 text-sm font-medium text-white",onClose:()=>ee(!1),onConfirm:async()=>{E&&(await eb.mutateAsync(E),ek(),ee(!1),E==E&&O(null))}}),(0,a.jsx)(ex,{open:et,settings:eo,saving:eg.isPending,error:ea,disabled:eO&&!eE,onClose:()=>er(!1),onSave:eY})]})}},803:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(1847).A)("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]])},1119:(e,t,r)=>{"use strict";function a(e,t){fetch("/api/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event:e,source:"client",payload:null!=t?t:{}}),keepalive:!0}).catch(()=>void 0),console.debug("[telemetry]",e,null!=t?t:{})}r.d(t,{x:()=>a})},1375:(e,t,r)=>{"use strict";r.d(t,{eS:()=>m,pp:()=>u,W5:()=>p,Gu:()=>c});var a=r(5155),l=r(5299),n=r(1847);let s=(0,n.A)("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]),o=(0,n.A)("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);var d=r(4269);function i(e){return"banner"===e?"rounded-xl border border-border/60 bg-card/50 p-4 shadow-[var(--shadow-card)]":"rounded-2xl border border-border/60 bg-card/55 p-6 shadow-[var(--shadow-card)]"}function c(e){var t;let{title:r,message:n,description:s,layout:o="card",className:c,children:u}=e,m=null!=(t=null!=r?r:n)?t:"Loading…";return(0,a.jsxs)("div",{className:(0,d.cn)(i(o),c),children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)(l.A,{className:"mt-0.5 h-4 w-4 animate-spin text-primary"}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"font-semibold text-foreground",children:m}),s?(0,a.jsx)("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:s}):null]})]}),u?(0,a.jsx)("div",{className:"mt-4",children:u}):null]})}function u(e){let{title:t,description:r,icon:l,primaryAction:n,secondaryAction:o,action:c,layout:u="card",className:m}=e,p=null!=n?n:c;return(0,a.jsx)("div",{className:(0,d.cn)(i(u),"border-dashed",m),children:(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("div",{className:"mt-0.5 text-primary",children:null!=l?l:(0,a.jsx)(s,{className:"h-4 w-4"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"font-semibold text-foreground",children:t}),(0,a.jsx)("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:r}),p||o?(0,a.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[p,o]}):null]})]})})}function m(e){let{title:t,description:r,severity:l="warning",icon:n,details:s,primaryAction:c,secondaryAction:u,layout:m="card",className:p}=e;return(0,a.jsx)("div",{className:(0,d.cn)(i(m),"danger"===l?"border-danger/35 bg-danger/10":"border-warning/35 bg-warning/10",p),children:(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("div",{className:(0,d.cn)("mt-0.5","danger"===l?"text-danger":"text-warning"),children:null!=n?n:(0,a.jsx)(o,{className:"h-4 w-4"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"font-semibold text-foreground",children:t}),(0,a.jsx)("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:r}),s?(0,a.jsx)("div",{className:"mt-2 text-xs leading-5 text-muted-foreground",children:s}):null,c||u?(0,a.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[c,u]}):null]})]})})}function p(e){let{title:t="Something went wrong",error:r,message:l,description:n,primaryAction:s,secondaryAction:c,layout:u="card",className:m}=e,p=null!=l?l:r,x="string"==typeof p?p:p instanceof Error?p.message:null;return(0,a.jsx)("div",{className:(0,d.cn)(i(u),"border-danger/35 bg-danger/10",m),children:(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)(o,{className:"mt-0.5 h-4 w-4 text-danger"}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"font-semibold text-foreground",children:t}),n?(0,a.jsx)("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:n}):null,x?(0,a.jsx)("p",{className:"mt-1 text-sm leading-6 text-foreground",children:x}):null,s||c?(0,a.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[s,c]}):null]})]})})}},3804:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(1847).A)("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]])},3842:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(1847).A)("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]])},5299:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(1847).A)("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},5303:(e,t,r)=>{Promise.resolve().then(r.bind(r,1935)),Promise.resolve().then(r.bind(r,9136)),Promise.resolve().then(r.bind(r,6981)),Promise.resolve().then(r.bind(r,711))},7910:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(1847).A)("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]])},9068:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(1847).A)("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]])}},e=>{e.O(0,[2231,1635,5097,8441,1255,7358],()=>e(e.s=5303)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8457],{21:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(1847).A)("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},711:(e,t,r)=>{"use strict";r.d(t,{ChatScreen:()=>eh});var a=r(5155),l=r(3804),n=r(2115),s=r(63),o=r(9678),d=r(1119),i=r(2604),c=r(4033),u=r(1847);let m=(0,u.A)("Paperclip",[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]]);var p=r(7910),x=r(3842);let h=(0,u.A)("SendHorizontal",[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]]);var b=r(549);function f(e){let{attachment:t,onRemove:r}=e;return(0,a.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-full border border-border bg-background px-3 py-1 text-xs text-muted-foreground",children:[(0,a.jsx)("span",{children:t.name}),(0,a.jsxs)("span",{children:[Math.max(1,Math.round(t.size/1024))," KB"]}),r?(0,a.jsx)("button",{type:"button",onClick:()=>r(t.id),className:"text-foreground",children:"\xd7"}):null]})}function g(e){let{disabled:t,onTranscript:r}=e;return(0,a.jsx)("button",{type:"button",disabled:t,onClick:()=>r("Voice input captured from mock microphone control."),className:"rounded-lg border border-border/70 bg-background/80 px-3 py-2 text-sm font-medium text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50","aria-label":"Voice input",children:"Mic"})}function y(e){let{disabled:t,statusNote:r,chips:l=[],starterPrompts:s=[],onSend:o}=e,[i,u]=(0,n.useState)(""),[y,v]=(0,n.useState)([]),[j,w]=(0,n.useState)(!1),N=(0,n.useRef)(null),k=(0,b.n)({mutationFn:async e=>{let t=new FormData;t.append("file",e);let r=await fetch("/api/uploads",{method:"POST",body:t});if(!r.ok)throw Error("Upload failed");let a=await r.json();return(0,d.x)("attachment.uploaded",{name:e.name,size:e.size}),a.attachment}}),S=j?l:l.slice(0,3),A=async e=>{let t=await k.mutateAsync(e);v(e=>[...e,t])},C=async e=>{e.preventDefault();let r=i.trim();if(!r&&0===y.length||t)return;let a=y.map(e=>e.id);u(""),v([]),(0,d.x)("chat.send",{attachmentCount:a.length}),await o(r||"Sent with attachments only.",a)};return(0,a.jsx)("form",{onSubmit:C,className:"shrink-0 border-t border-border/70 bg-background/80 p-2 md:p-3",children:(0,a.jsxs)("div",{className:"rounded-xl border border-border/70 card-default p-3 shadow-[var(--shadow-soft)]",onDragOver:e=>e.preventDefault(),onDrop:e=>{var t;e.preventDefault();let r=null==(t=e.dataTransfer.files)?void 0:t[0];r&&A(r)},children:[(0,a.jsxs)("div",{className:"mb-2 flex flex-wrap items-center gap-1.5",children:[S.map(e=>(0,a.jsx)("span",{className:"rounded-full border border-border/70 bg-background/80 px-3 py-1 text-xs font-medium text-foreground",children:e.label},e.key)),l.length>S.length?(0,a.jsxs)("span",{className:"text-xs text-muted-foreground",children:["+",l.length-S.length," more in details"]}):null,(0,a.jsxs)("button",{type:"button",onClick:()=>w(e=>!e),"aria-expanded":j,"aria-controls":"chat-composer-details",className:"inline-flex items-center gap-1 rounded-full border border-border/70 bg-background/60 px-3 py-1 text-xs font-medium text-muted-foreground",children:["Details",(0,a.jsx)(c.A,{className:"h-3.5 w-3.5 transition ".concat(j?"rotate-180":"")})]})]}),j?(0,a.jsxs)("div",{id:"chat-composer-details",className:"mb-3 grid gap-3 rounded-lg border border-border/70 bg-background/60 p-3 text-xs text-muted-foreground md:grid-cols-3",children:[(0,a.jsxs)("div",{className:"rounded-xl border border-border/70 bg-card/60 p-3",children:[(0,a.jsx)("p",{className:"font-semibold text-foreground",children:"Prompt first"}),(0,a.jsx)("p",{className:"mt-1",children:"Keep the ask short and outcome-oriented. Pan can gather tools, files, and approvals as the run unfolds."})]}),(0,a.jsxs)("div",{className:"rounded-xl border border-border/70 bg-card/60 p-3",children:[(0,a.jsx)("p",{className:"font-semibold text-foreground",children:"Visible context"}),(0,a.jsx)("p",{className:"mt-1",children:"Model, mode, tools, files, and profile stay inspectable without turning the composer into a dashboard."})]}),(0,a.jsxs)("div",{className:"rounded-xl border border-border/70 bg-card/60 p-3",children:[(0,a.jsx)("p",{className:"font-semibold text-foreground",children:"Attachments"}),(0,a.jsx)("p",{className:"mt-1",children:"Drop a file anywhere on the composer or use Attach to add screenshots, notes, and code snippets."})]})]}):null,y.length?(0,a.jsx)("div",{className:"mb-3 flex flex-wrap gap-2",children:y.map(e=>(0,a.jsx)(f,{attachment:e,onRemove:e=>v(t=>t.filter(t=>t.id!==e))},e.id))}):null,!i.trim()&&0===y.length&&s.length>0?(0,a.jsxs)("div",{className:"mb-3 rounded-xl border border-border/70 bg-background/60 p-3",children:[(0,a.jsx)("p",{className:"text-xs font-semibold uppercase tracking-label text-muted-foreground",children:"Try one of these"}),(0,a.jsx)("div",{className:"mt-3 flex flex-wrap gap-2",children:s.map(e=>(0,a.jsx)("button",{type:"button",onClick:()=>u(e),className:"rounded-2xl border border-border/70 bg-background/80 px-3 py-2 text-left text-xs font-medium leading-5 text-foreground transition hover:bg-card",children:e},e))})]}):null,(0,a.jsx)("textarea",{value:i,onChange:e=>u(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),C(e))},placeholder:t?"Agent is unavailable right now.":"Ask Pan to research, plan, debug, or build…",className:"min-h-14 w-full resize-none bg-transparent px-3 text-sm leading-7 outline-none placeholder:text-muted-foreground",disabled:t}),(0,a.jsxs)("div",{className:"mt-3 flex flex-col gap-3 xl:flex-row xl:items-center xl:justify-between",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("input",{ref:N,type:"file",className:"hidden",onChange:async e=>{var t;let r=null==(t=e.target.files)?void 0:t[0];r&&(await A(r),e.currentTarget.value="")}}),(0,a.jsxs)("button",{type:"button",onClick:()=>{var e;return null==(e=N.current)?void 0:e.click()},className:"inline-flex items-center gap-2 rounded-2xl border border-border/70 bg-background/80 px-3 py-2 text-sm font-medium text-foreground",children:[(0,a.jsx)(m,{className:"h-4 w-4"}),"Attach"]}),(0,a.jsx)(g,{disabled:t,onTranscript:e=>u(t=>"".concat(t).concat(t?" ":"").concat(e))}),r?(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:r}):null]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsxs)("span",{className:"hidden items-center gap-1 text-xs text-muted-foreground md:inline-flex",children:[(0,a.jsx)(p.A,{className:"h-3.5 w-3.5"}),"Context stays visible"]}),(0,a.jsxs)("span",{className:"hidden items-center gap-1 text-xs text-muted-foreground md:inline-flex",children:[(0,a.jsx)(x.A,{className:"h-3.5 w-3.5"}),"Tools stay inspectable"]}),(0,a.jsxs)("button",{type:"submit",disabled:t||!i.trim()&&0===y.length,className:"inline-flex items-center justify-center gap-2 rounded-2xl brand-gradient px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-[var(--shadow-card)] transition hover:-translate-y-0.5 disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)(h,{className:"h-4 w-4"}),"Send"]})]})]})]})})}let v=(0,u.A)("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);function j(e){let{onRename:t,onArchive:r,onDelete:l,onFork:s}=e,[o,d]=(0,n.useState)(!1);return(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("button",{type:"button",onClick:()=>d(e=>!e),className:"rounded-md border border-border/70 bg-background/80 px-2.5 py-1 text-2xs font-medium text-muted-foreground hover:bg-card",children:"Manage"}),o?(0,a.jsxs)("div",{className:"absolute right-0 top-10 z-10 w-40 rounded-lg border border-border/70 bg-background p-2 shadow-lg",children:[(0,a.jsx)("button",{type:"button",onClick:()=>{d(!1),t()},className:"block w-full rounded-md px-3 py-2 text-left text-sm hover:bg-card",children:"Rename"}),(0,a.jsx)("button",{type:"button",onClick:()=>{d(!1),s()},className:"block w-full rounded-md px-3 py-2 text-left text-sm hover:bg-card",children:"Fork"}),(0,a.jsx)("button",{type:"button",onClick:()=>{d(!1),r()},className:"block w-full rounded-md px-3 py-2 text-left text-sm hover:bg-card",children:"Archive"}),(0,a.jsx)("button",{type:"button",onClick:()=>{d(!1),l()},className:"block w-full rounded-md px-3 py-2 text-left text-sm text-danger hover:bg-card",children:"Delete"})]}):null]})}var w=r(592),N=r(4269);function k(e){var t,r,l;let{value:s,provider:o,onChange:d,ariaLabel:i="Model switcher",disabled:u,className:m}=e,p=null!=(r=function(e,t){var r,a,l;let s=(0,w.w)(),o=(0,n.useMemo)(()=>{var r,a,l,n;let o=new Map;for(let e of null!=(l=null==(r=s.data)?void 0:r.modelOptions)?l:[])o.set(e.id,e);return e&&!o.has(e)&&o.set(e,{id:e,label:e,provider:t||(null==(n=s.data)?void 0:n.provider)||"unknown",source:"session-current"}),!o.size&&(null==(a=s.data)?void 0:a.modelDefault)&&o.set(s.data.modelDefault,{id:s.data.modelDefault,label:s.data.modelDefault,provider:s.data.provider||"unknown",source:"runtime-default"}),Array.from(o.values())},[e,t,null==(r=s.data)?void 0:r.modelDefault,null==(a=s.data)?void 0:a.modelOptions,null==(l=s.data)?void 0:l.provider]);return{...s,data:o}}(s,o).data)?r:[];(0,n.useEffect)(()=>{!s&&p[0]&&d(p[0].id,p[0].provider)},[d,p,s]);let x=null!=(l=null==(t=p.find(e=>e.id===s))?void 0:t.label)?l:s;return(0,a.jsxs)("div",{className:(0,N.cn)("relative",m),children:[(0,a.jsx)("select",{value:x,onChange:e=>{let t=p.find(t=>t.label===e.target.value||t.id===e.target.value);t&&d(t.id,t.provider)},className:"min-w-[14rem] appearance-none rounded-2xl border border-border/70 bg-background/85 px-4 py-2.5 pr-10 text-sm font-medium outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/20 disabled:cursor-not-allowed disabled:opacity-60","aria-label":i,disabled:u||0===p.length,children:p.map(e=>(0,a.jsxs)("option",{value:e.label,children:[e.label," \xb7 ",e.provider]},e.id))}),(0,a.jsx)(c.A,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"})]})}var S=r(2263),A=r(4695);function C(e){let{title:t,settings:r,profileLabel:l,loadedSkillIds:n,runtimeConnected:s,controlsDisabled:o,isPersisted:d,archived:i,runtimeSummary:c,hasMessages:u,onOpenSettings:m,onRename:p,onArchive:x,onDelete:h,onFork:b,onModelChange:f}=e,g=(null!=n?n:[]).filter(e=>"skill-authoring"!==e),y=[l&&"Profile ".concat(l),r.model?"Model ".concat(r.model):"Default model",r.policyPreset&&"Mode ".concat(r.policyPreset)].filter(Boolean).join(" \xb7 ");return(0,a.jsx)("div",{className:(0,N.cn)("shrink-0 border-b border-border/60 bg-card/70 px-5",u?"py-2.5":"py-4"),children:(0,a.jsxs)("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0 space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs font-semibold uppercase tracking-label text-muted-foreground",children:"Chat"}),(0,a.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-3",children:[(0,a.jsx)("h2",{className:"truncate text-xl font-semibold tracking-tight text-foreground",children:t}),i?(0,a.jsx)(S.W,{label:"Archived",tone:"warning"}):null,d?(0,a.jsx)(S.W,{label:"Saved chat",tone:"success"}):(0,a.jsx)(S.W,{label:"New chat",tone:"warning"})]}),(0,a.jsx)("p",{className:"mt-2 text-xs leading-5 text-muted-foreground",children:y}),u&&c?(0,a.jsx)("p",{className:"mt-2 max-w-3xl text-sm leading-6 text-muted-foreground",children:c}):null]}),u?null:(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(0,a.jsx)(S.W,{label:s?"Runtime connected":"Runtime degraded",tone:(0,A.OX)(s?"healthy":"degraded")}),g.length?(0,a.jsx)(S.W,{label:"".concat(g.length," skill").concat(1===g.length?"":"s"," loaded"),tone:"accent"}):null]}),u?null:(0,a.jsxs)("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:["Start with one clear request. Attach a file or load a skill only when the task needs more context.",g.length?" Loaded: ".concat(g.slice(0,2).join(", ")).concat(g.length>2?" +".concat(g.length-2," more"):"","."):""]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 lg:max-w-[360px] lg:justify-end",children:[(0,a.jsx)(k,{value:r.model,provider:r.provider,onChange:f,ariaLabel:"Header model switcher",disabled:o}),(0,a.jsxs)("button",{type:"button",onClick:m,disabled:o,"aria-label":"Settings",className:"inline-flex items-center gap-2 rounded-2xl border border-border/70 bg-background/80 px-3 py-2.5 text-sm font-medium text-foreground shadow-[var(--shadow-card)] transition hover:-translate-y-0.5 hover:bg-card disabled:cursor-not-allowed disabled:opacity-60",children:[(0,a.jsx)(v,{className:"h-4 w-4"}),"Settings"]}),(0,a.jsx)(j,{onRename:p,onArchive:x,onDelete:h,onFork:b})]})]})})}var M=r(2619),P=r.n(M),D=r(5740);function L(e){var t,r;let{event:l,onApprove:n,onReject:s}=e;return(0,a.jsxs)("div",{className:"rounded-lg border border-approval/35 bg-approval/10 p-4 shadow-[var(--shadow-card)]",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs uppercase tracking-label text-muted-foreground",children:"Approval needed"}),(0,a.jsx)("h4",{className:"mt-1 text-sm font-semibold text-foreground",children:l.toolName}),(0,a.jsx)("p",{className:"mt-2 text-sm leading-6 text-foreground",children:l.summary})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)(S.W,{label:null!=(t=l.governance)?t:"approval-gated",tone:(0,A.fh)(null!=(r=l.governance)?r:"approval-gated")}),l.riskLevel?(0,a.jsx)(S.W,{label:"".concat(l.riskLevel," risk"),tone:(0,A.yD)(l.riskLevel)}):null]})]}),(0,a.jsxs)("div",{className:"mt-4 flex gap-2",children:[(0,a.jsx)("button",{type:"button",onClick:()=>n(l.toolCallId),className:"rounded-xl bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow-[var(--shadow-card)]",children:"Approve"}),(0,a.jsx)("button",{type:"button",onClick:()=>s(l.toolCallId),className:"rounded-xl border border-border px-4 py-2 text-sm text-foreground",children:"Reject"})]})]})}function T(e){let{artifact:t,onOpen:r}=e;return(0,a.jsxs)("button",{type:"button",onClick:()=>r(t.artifactId),className:"w-full rounded-2xl border border-border bg-card p-4 text-left shadow-sm transition hover:bg-muted/40",children:[(0,a.jsxs)("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:["Artifact \xb7 ",t.artifactType]}),(0,a.jsx)("h4",{className:"mt-1 text-sm font-semibold",children:t.label}),t.content?(0,a.jsx)("p",{className:"mt-2 line-clamp-3 text-sm text-muted-foreground",children:t.content}):null]})}var R=r(8192);let I=(0,u.A)("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);function _(e){let{text:t}=e;return(0,a.jsx)("button",{type:"button",onClick:()=>{"speechSynthesis"in window&&(window.speechSynthesis.cancel(),window.speechSynthesis.speak(new SpeechSynthesisUtterance(t)))},className:"rounded-md border border-border px-2 py-1 text-2xs text-muted-foreground","aria-label":"Play voice",children:"TTS"})}function E(e){var t;let{message:r}=e,l="user"===r.role;return(0,a.jsxs)("div",{className:(0,N.cn)("flex w-full gap-3",l?"justify-end":"justify-start"),children:[l?null:(0,a.jsx)("div",{className:"mt-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-2xl bg-[linear-gradient(135deg,hsl(var(--primary)),hsl(var(--accent)))] text-primary-foreground shadow-[var(--shadow-card)]",children:(0,a.jsx)(R.A,{className:"h-4 w-4"})}),(0,a.jsxs)("div",{className:(0,N.cn)("max-w-[88%] space-y-2",l&&"items-end"),children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 px-1",children:[(0,a.jsx)("p",{className:"text-2xs font-semibold uppercase tracking-label text-muted-foreground",children:l?"You":"Pan"}),(0,a.jsx)("p",{className:"text-2xs uppercase tracking-label text-muted-foreground",children:new Date(r.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),(0,a.jsxs)("div",{className:(0,N.cn)("rounded-lg border px-4 py-3 text-sm shadow-[var(--shadow-card)]",l?"border-primary/15 bg-[linear-gradient(135deg,hsl(var(--primary))/0.98,hsl(var(--accent))/0.92)] text-primary-foreground":"border-border/70 bg-card/80 text-card-foreground"),children:[(0,a.jsx)("p",{className:"whitespace-pre-wrap leading-7",children:r.content}),(null==(t=r.attachments)?void 0:t.length)?(0,a.jsx)("div",{className:"mt-3 flex flex-wrap gap-2",children:r.attachments.map(e=>(0,a.jsx)(f,{attachment:e},e.id))}):null,l?null:(0,a.jsx)("div",{className:"mt-3 flex items-center gap-2",children:(0,a.jsx)(_,{text:r.content})})]})]}),l?(0,a.jsx)("div",{className:"mt-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-2xl border border-border/70 bg-background/80 text-foreground shadow-[var(--shadow-card)]",children:(0,a.jsx)(I,{className:"h-4 w-4"})}):null]})}var O=r(9043),z=r(2932);function W(e){let t=[...e].reverse().find(e=>"run.phase"===e.type);if((null==t?void 0:t.type)==="run.phase")return t.label;if([...e].reverse().find(e=>"tool.awaiting_approval"===e.type))return"Waiting for approval before the agent can continue.";let r=[...e].reverse().find(e=>"tool.started"===e.type);return(null==r?void 0:r.type)==="tool.started"?"".concat(r.toolName," is running."):"Pan is responding…"}function q(e){var t;let{messages:r,runEvents:l,artifacts:s,streamingMessage:o,isStreaming:d,isLoading:i,onApprove:c,onReject:u,onOpenArtifact:m}=e,p=l.filter(e=>"assistant.delta"!==e.type&&"source.emitted"!==e.type),x=[...l].reverse().find(e=>"run.phase"===e.type),h=l.filter(e=>"tool.awaiting_approval"===e.type).length,b=(0,n.useRef)(null),f=(0,n.useRef)(null),g=(0,n.useRef)(!1);return(0,n.useEffect)(()=>{let e=b.current;if(!e)return;let t=()=>{g.current=e.scrollHeight-e.scrollTop-e.clientHeight>80};return e.addEventListener("scroll",t,{passive:!0}),()=>e.removeEventListener("scroll",t)},[]),(0,n.useEffect)(()=>{if(g.current)return;let e=b.current;e&&e.scrollTo({top:e.scrollHeight,behavior:d?"instant":"smooth"})},[r,o,d,l.length]),(0,a.jsxs)("div",{ref:b,className:"flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto px-5 py-5",children:[i?(0,a.jsx)(z.Gu,{title:"Loading chat…",description:"Fetching messages, events, and artifacts for the active chat."}):null,i||0!==r.length?null:(0,a.jsx)(z.pp,{title:"Start a chat",description:(0,a.jsxs)(a.Fragment,{children:["Research, plan, debug, or build. Runtime activity, approvals, sources, and generated outputs stay legible instead of being buried inside assistant prose.",(0,a.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[(0,a.jsx)(S.W,{label:"Chat-first",tone:"accent"}),(0,a.jsx)(S.W,{label:"Tool-aware",tone:"success"}),(0,a.jsx)(S.W,{label:"Approval-ready",tone:"warning"})]})]}),icon:(0,a.jsx)(D.A,{className:"h-4 w-4"}),primaryAction:(0,a.jsx)(P(),{href:"/skills",className:"rounded-2xl bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",children:"Browse skills"}),secondaryAction:(0,a.jsx)(P(),{href:"/marketplace",className:"rounded-2xl border border-border/70 bg-background/80 px-4 py-2 text-sm font-medium text-foreground",children:"Open marketplace"})}),(d||p.length>0)&&!i?(0,a.jsx)("div",{className:"rounded-lg border border-border/70 bg-background/60 p-4 shadow-[var(--shadow-card)]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-2xs font-semibold uppercase tracking-label text-muted-foreground",children:"Runtime activity"}),(0,a.jsx)("p",{className:"mt-1 text-sm font-medium text-foreground",children:d?W(l):null!=(t=null==x?void 0:x.label)?t:"No active tool run"})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(null==x?void 0:x.type)==="run.phase"?(0,a.jsx)(S.W,{label:x.phase,tone:"accent"}):null,(0,a.jsx)(S.W,{label:"".concat(p.length," events"),tone:"muted"}),h?(0,a.jsx)(S.W,{label:"".concat(h," approvals"),tone:"warning"}):null]})]})}):null,r.map(e=>(0,a.jsx)(E,{message:e},e.id)),p.map((e,t)=>{if("tool.started"===e.type||"tool.completed"===e.type)return(0,a.jsx)(O.J,{event:e},"".concat(e.type,"-").concat(e.toolCallId,"-").concat(t));if("tool.awaiting_approval"===e.type)return(0,a.jsx)(L,{event:e,onApprove:c,onReject:u},"".concat(e.type,"-").concat(e.toolCallId,"-").concat(t));if("artifact.emitted"===e.type){var r;let l=null!=(r=s.find(t=>t.artifactId===e.artifactId))?r:e;return(0,a.jsx)(T,{artifact:l,onOpen:m},"".concat(e.type,"-").concat(e.artifactId,"-").concat(t))}return"run.phase"===e.type?(0,a.jsx)("div",{className:"rounded-lg border border-border/70 bg-background/80 px-4 py-3 text-sm text-muted-foreground shadow-[var(--shadow-card)]",children:e.label},"".concat(e.type,"-").concat(t)):"error"===e.type?(0,a.jsx)(z.W5,{error:e.message,layout:"banner"},"".concat(e.type,"-").concat(t)):null}),d?(0,a.jsxs)("div",{className:"flex justify-start gap-3",children:[(0,a.jsx)("div",{className:"mt-1 flex h-9 w-9 items-center justify-center rounded-2xl bg-[linear-gradient(135deg,hsl(var(--primary)),hsl(var(--accent)))] text-primary-foreground shadow-[var(--shadow-card)]",children:(0,a.jsx)(D.A,{className:"h-4 w-4"})}),(0,a.jsxs)("div",{className:"max-w-[88%] rounded-lg border border-border/70 bg-card/80 px-4 py-3 text-sm shadow-[var(--shadow-card)]",children:[(0,a.jsx)("p",{className:"whitespace-pre-wrap leading-7",children:o||"…"}),(0,a.jsx)("p",{className:"mt-3 text-2xs uppercase tracking-label text-muted-foreground",children:W(l)})]})]}):null,(0,a.jsx)("div",{ref:f,"aria-hidden":"true",className:"h-px shrink-0"})]})}var F=r(9776);function H(e){if(!e)return null;let t=e.title||e.label||e.name||e.href||e.url;return t?{id:String(e.id||e.href||e.url||e.label||t),title:String(t),href:e.href||e.url?String(e.href||e.url):void 0,snippet:e.snippet||e.quote||e.description?String(e.snippet||e.quote||e.description):void 0,sourceType:function(e){switch(String(e||"").toLowerCase()){case"web":case"url":return"web";case"file":return"file";case"workspace":return"workspace";case"integration":return"integration";default:return"unknown"}}(e.sourceType||e.kind||e.type),provenance:function(e){switch(String(e||"").toLowerCase()){case"builtin":case"built-in":return"built-in";case"verified":return"verified";case"self-hosted":case"self_hosted":return"self-hosted";case"local-process":case"local_process":return"local-process";default:return"custom"}}(e.provenance),note:e.note?String(e.note):void 0,label:e.label?String(e.label):void 0}:null}var U=r(6288);function J(e){let{open:t,title:r,description:l,confirmLabel:n,confirmClassName:s,onClose:o,onConfirm:d}=e;return t?(0,a.jsx)("div",{className:"fixed inset-0 z-30 flex items-center justify-center bg-black/50 p-4",children:(0,a.jsxs)("div",{className:"w-full max-w-md rounded-2xl border border-border bg-background p-5 shadow-xl",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:r}),(0,a.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:l}),(0,a.jsxs)("div",{className:"mt-5 flex justify-end gap-2",children:[(0,a.jsx)("button",{type:"button",onClick:o,className:"rounded-lg border border-border px-4 py-2 text-sm",children:"Cancel"}),(0,a.jsx)("button",{type:"button",onClick:()=>void d(),className:null!=s?s:"rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",children:n})]})]})}):null}function K(e){let{open:t,initialTitle:r,onClose:l,onSubmit:s}=e,[o,d]=(0,n.useState)(r);return((0,n.useEffect)(()=>{d(r)},[r]),t)?(0,a.jsx)("div",{className:"fixed inset-0 z-30 flex items-center justify-center bg-black/50 p-4",children:(0,a.jsxs)("div",{className:"w-full max-w-md rounded-2xl border border-border bg-background p-5 shadow-xl",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Rename session"}),(0,a.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Give this conversation a clearer title."}),(0,a.jsx)("input",{"aria-label":"Rename session input",value:o,onChange:e=>d(e.target.value),className:"mt-4 w-full rounded-lg border border-input bg-background px-3 py-2 text-sm outline-none focus:border-primary"}),(0,a.jsxs)("div",{className:"mt-5 flex justify-end gap-2",children:[(0,a.jsx)("button",{type:"button",onClick:l,className:"rounded-lg border border-border px-4 py-2 text-sm",children:"Cancel"}),(0,a.jsx)("button",{type:"button",onClick:()=>void s(o),className:"rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",children:"Save"})]})]})}):null}var V=r(6191);let B=(0,u.A)("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]),G=(0,u.A)("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),Q=(0,u.A)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]),Y=(0,u.A)("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]);function X(e){let{value:t,onChange:r}=e;return(0,a.jsx)("div",{className:"border-b border-border/70 px-4 pb-3 pt-1",children:(0,a.jsx)("input",{value:t,onChange:e=>r(e.target.value),placeholder:"Search sessions…",className:"w-full rounded-2xl border border-border/70 bg-background/85 px-4 py-3 text-sm outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/20"})})}let Z=(0,u.A)("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]),$=(0,u.A)("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]),ee=(0,u.A)("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]),et=(0,u.A)("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);var er=r(7586);let ea=(0,u.A)("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]),el=(0,u.A)("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);var en=r(803),es=r(9068),eo=r(21);let ed={webui:{label:"WebUI",icon:Z,classes:"border-border/60 bg-muted/60 text-muted-foreground"},whatsapp:{label:"WhatsApp",icon:$,classes:"border-emerald-500/40 bg-emerald-500/10 text-emerald-400"},discord:{label:"Discord",icon:ee,classes:"border-indigo-500/40 bg-indigo-500/10 text-indigo-300"},telegram:{label:"Telegram",icon:et,classes:"border-sky-500/40 bg-sky-500/10 text-sky-300"},signal:{label:"Signal",icon:er.A,classes:"border-blue-500/40 bg-blue-500/10 text-blue-300"},slack:{label:"Slack",icon:ee,classes:"border-fuchsia-500/40 bg-fuchsia-500/10 text-fuchsia-300"},matrix:{label:"Matrix",icon:er.A,classes:"border-teal-500/40 bg-teal-500/10 text-teal-300"},mattermost:{label:"Mattermost",icon:er.A,classes:"border-cyan-500/40 bg-cyan-500/10 text-cyan-300"},sms:{label:"SMS",icon:ea,classes:"border-amber-500/40 bg-amber-500/10 text-amber-300"},email:{label:"Email",icon:el,classes:"border-rose-500/40 bg-rose-500/10 text-rose-300"},cli:{label:"CLI",icon:en.A,classes:"border-slate-500/40 bg-slate-500/10 text-slate-300"},api:{label:"API",icon:es.A,classes:"border-violet-500/40 bg-violet-500/10 text-violet-300"},unknown:{label:"Unknown",icon:eo.A,classes:"border-border/50 bg-muted/40 text-muted-foreground"}};function ei(e){var t;return null!=(t=ed[null!=e?e:"unknown"])?t:ed.unknown}let ec=["webui","whatsapp","discord","telegram","signal","slack","matrix","mattermost","sms","email","cli","api","unknown"];function eu(e){let{source:t,iconOnly:r,className:l}=e,n=ei(t),s=n.icon;return(0,a.jsxs)("span",{title:n.label,"aria-label":"Session source: ".concat(n.label),className:(0,N.cn)("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-3xs uppercase tracking-label",n.classes,r&&"h-5 w-5 justify-center px-0",l),children:[(0,a.jsx)(s,{className:"h-3 w-3","aria-hidden":"true"}),r?null:(0,a.jsx)("span",{children:n.label})]})}function em(e){var t;return null!=(t=e.source)?t:"unknown"}function ep(e){let{sessions:t,selectedSessionId:r,search:l,isLoading:s,onSearchChange:o,onNewChat:d,onSelectSession:c,onResumeSession:u}=e,[m,p]=(0,n.useState)(25),[x,h]=(0,n.useState)("all"),{sidebarCompact:b,toggleSidebarCompact:f}=(0,i.j)(),g=(0,n.useMemo)(()=>{let e=new Set;for(let r of t)e.add(em(r));return ec.filter(t=>e.has(t))},[t]),y=g.length>1,v=(0,n.useMemo)(()=>{let e=l.trim()?t.filter(e=>!e.parentSessionId):t;return"all"===x?e:e.filter(e=>em(e)===x)},[t,l,x]),j=v.filter(e=>e.pinned&&!e.archived),w=v.filter(e=>!e.pinned&&!e.archived),k=v.filter(e=>e.archived),[S,A]=(0,n.useState)(!1),C=[{label:"Pinned",items:j},{label:"Recent",items:w.slice(0,m)},{label:"Archived",items:S?k:k.slice(0,5)}].filter(e=>e.items.length>0),M=w.length>m,P=!S&&k.length>5;return(0,a.jsxs)("aside",{className:"flex h-full max-h-full flex-col overflow-hidden rounded-xl border border-border/70 bg-card/60 shadow-[var(--shadow-soft)]",children:[(0,a.jsxs)("div",{className:(0,N.cn)("border-b border-border/60",b?"p-3":"p-4"),children:[(0,a.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-2",children:[(0,a.jsx)("p",{className:"text-xs font-semibold uppercase tracking-label text-muted-foreground",children:"Chats"}),(0,a.jsx)("button",{type:"button",onClick:f,className:"rounded-full border border-border/70 bg-background/80 px-2.5 py-1 text-3xs font-medium uppercase tracking-label text-muted-foreground",children:b?"Comfort":"Compact"})]}),(0,a.jsxs)("button",{type:"button",onClick:d,className:(0,N.cn)("flex w-full items-center justify-center gap-2 rounded-lg brand-gradient text-sm font-semibold text-primary-foreground shadow-[var(--shadow-card)] transition hover:-translate-y-0.5",b?"px-3 py-2.5":"px-4 py-3"),children:[(0,a.jsx)(V.A,{className:"h-4 w-4"}),"New chat"]}),(0,a.jsxs)("p",{className:"mt-3 text-xs leading-5 text-muted-foreground",children:[v.length," chats \xb7 ",j.length," pinned \xb7 ",k.length," archived"]})]}),(0,a.jsx)(X,{value:l,onChange:o}),y?(0,a.jsxs)("div",{className:(0,N.cn)("border-b border-border/70 px-3",b?"pb-2":"pb-3"),children:[(0,a.jsx)("div",{className:"mb-1.5 px-1 text-2xs font-semibold uppercase tracking-label text-muted-foreground",children:"Source"}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[(0,a.jsx)("button",{type:"button",onClick:()=>h("all"),className:(0,N.cn)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-3xs uppercase tracking-label transition","all"===x?"border-primary/60 bg-primary/15 text-primary":"border-border/60 bg-muted/40 text-muted-foreground hover:bg-muted/60"),children:"All"}),g.map(e=>{let t=ei(e),r=t.icon,l=x===e;return(0,a.jsxs)("button",{type:"button",onClick:()=>h(e),className:(0,N.cn)("inline-flex items-center gap-1 rounded-full border px-2.5 py-0.5 text-3xs uppercase tracking-label transition",l?t.classes.replace("/10","/20").replace("/40","/60"):"border-border/60 bg-muted/40 text-muted-foreground hover:bg-muted/60"),title:t.label,children:[(0,a.jsx)(r,{className:"h-3 w-3","aria-hidden":"true"}),t.label]},e)})]})]}):null,(0,a.jsxs)("div",{className:(0,N.cn)("flex-1 overflow-y-auto",b?"space-y-3 p-2":"space-y-4 p-3"),children:[s?(0,a.jsx)(z.Gu,{layout:"banner",title:"Loading chats…"}):null,s||0!==v.length?null:(0,a.jsx)(z.pp,{layout:"banner",title:"all"===x?"No chats found":"No ".concat(ei(x).label," chats"),description:"all"===x?"Try a different search term or start a new chat.":"Change the source filter or start a new chat."}),C.map(e=>(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-2 text-2xs font-semibold uppercase tracking-label text-muted-foreground",children:[(0,a.jsx)("span",{children:e.label}),(0,a.jsx)("span",{children:e.items.length})]}),e.items.map(e=>{var t;let l=function(e){let t=em(e);return"webui"!==t&&"unknown"!==t}(e);return(0,a.jsxs)("button",{type:"button",onClick:()=>c(e.id),"aria-label":/\(fork\)/i.test(e.title)&&r!==e.id?e.title:"Open session ".concat(e.id),className:(0,N.cn)("w-full rounded-xl border text-left transition",b?"px-3 py-2.5":"px-4 py-3",r===e.id?"border-primary/30 bg-primary/10 shadow-[var(--shadow-card)] ring-1 ring-primary/10":"border-border/60 bg-background/70 hover:border-border/70 hover:bg-card/50"),children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("p",{"aria-hidden":"true",className:"truncate text-sm font-semibold text-foreground",children:e.title}),e.pinned?(0,a.jsx)(B,{className:"h-3.5 w-3.5 text-muted-foreground","aria-hidden":"true"}):null,e.parentSessionId?(0,a.jsx)(G,{className:"h-3.5 w-3.5 text-muted-foreground","aria-hidden":"true"}):null]}),(0,a.jsx)("p",{"aria-hidden":"true",className:(0,N.cn)("mt-1 text-xs leading-5 text-muted-foreground",b?"line-clamp-1":"line-clamp-2"),children:(t=e.preview)?t.length>88?"".concat(t.slice(0,85),"…"):t:"No messages yet."})]}),(0,a.jsxs)("div",{className:"flex shrink-0 flex-col items-end gap-1",children:[(0,a.jsx)(eu,{source:em(e),iconOnly:b}),l&&u&&r===e.id?(0,a.jsxs)("span",{role:"button",tabIndex:0,onClick:t=>{t.stopPropagation(),null==u||u(e.id)},onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),t.stopPropagation(),null==u||u(e.id))},"aria-label":"Resume ".concat(ei(em(e)).label," session"),className:(0,N.cn)("inline-flex items-center rounded-full border border-primary/50 bg-primary/10 text-3xs uppercase tracking-label text-primary transition hover:bg-primary/20 cursor-pointer",b?"h-5 w-5 justify-center px-0 py-0":"gap-1 px-2 py-0.5"),children:[(0,a.jsx)(Q,{className:"h-3 w-3"}),b?null:"Resume"]}):null]})]}),(0,a.jsxs)("div",{className:(0,N.cn)("flex items-center justify-between gap-2 text-2xs text-muted-foreground",b?"mt-2":"mt-3"),children:[(0,a.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,a.jsx)(Y,{className:"h-3.5 w-3.5"}),new Date(e.updatedAt).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})]}),!b&&e.workspaceLabel&&r===e.id?(0,a.jsx)("span",{children:e.workspaceLabel}):null]})]},e.id)})]},e.label)),M?(0,a.jsxs)("button",{type:"button",onClick:()=>p(e=>e+25),className:"mx-2 mt-2 rounded-xl border border-border/70 bg-background/80 px-3 py-2 text-xs font-medium text-muted-foreground transition hover:bg-card",children:["Show more (",w.length-m," remaining)"]}):null,P?(0,a.jsxs)("button",{type:"button",onClick:()=>A(!0),className:"mx-2 mt-2 rounded-xl border border-border/70 bg-background/80 px-3 py-2 text-xs font-medium text-muted-foreground transition hover:bg-card",children:["Show all archived (",k.length-5," more)"]}):null]})]})}function ex(e){let{open:t,settings:r,saving:l,error:s,disabled:o,onClose:d,onSave:i}=e,[c,u]=(0,n.useState)(r);return((0,n.useEffect)(()=>{u(r)},[r]),t)?(0,a.jsx)("div",{className:"fixed inset-0 z-30 flex justify-end bg-black/45 backdrop-blur-sm",children:(0,a.jsxs)("div",{className:"h-full w-full max-w-md border-l border-border/70 bg-background/95 p-5 shadow-[var(--shadow-elevated)]",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Session controls"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Model selection is runtime-backed. Policy and memory settings are session guidance stored with this chat."})]}),(0,a.jsx)("button",{type:"button",onClick:d,className:"rounded-2xl border border-border/70 bg-background/80 px-3 py-2 text-sm font-medium text-foreground",children:"Close"})]}),(0,a.jsxs)("div",{className:"mt-6 space-y-5 rounded-lg border border-border/70 bg-card/60 p-4 shadow-[var(--shadow-card)]",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{htmlFor:"chat-model",className:"text-sm font-medium",children:"Model"}),(0,a.jsx)("div",{id:"chat-model",children:(0,a.jsx)(k,{value:c.model,provider:c.provider,onChange:(e,t)=>u(r=>({...r,model:e,provider:t})),ariaLabel:"Settings model switcher",disabled:o||l,className:"w-full"})})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{htmlFor:"policy-preset",className:"text-sm font-medium",children:"Policy preset"}),(0,a.jsxs)("select",{id:"policy-preset",value:c.policyPreset,onChange:e=>u(t=>({...t,policyPreset:e.target.value})),className:"w-full rounded-2xl border border-input bg-background/85 px-4 py-3 text-sm outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/20",disabled:o||l,children:[(0,a.jsx)("option",{value:"safe-chat",children:"Safe Chat"}),(0,a.jsx)("option",{value:"research",children:"Research"}),(0,a.jsx)("option",{value:"builder",children:"Builder"}),(0,a.jsx)("option",{value:"full-power",children:"Full Power"})]})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{htmlFor:"memory-mode",className:"text-sm font-medium",children:"Memory mode"}),(0,a.jsxs)("select",{id:"memory-mode",value:c.memoryMode,onChange:e=>u(t=>({...t,memoryMode:e.target.value})),className:"w-full rounded-2xl border border-input bg-background/85 px-4 py-3 text-sm outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/20",disabled:o||l,children:[(0,a.jsx)("option",{value:"standard",children:"Standard"}),(0,a.jsx)("option",{value:"minimal",children:"Minimal"})]})]})]}),s?(0,a.jsx)("div",{className:"mt-4 rounded-2xl border border-danger/30 bg-danger/10 px-4 py-3 text-sm text-foreground",children:s}):null,(0,a.jsx)("div",{className:"mt-8 flex justify-end",children:(0,a.jsx)("button",{type:"button",onClick:()=>void i(c),disabled:o||l,className:"rounded-2xl bg-[linear-gradient(135deg,hsl(var(--primary)),hsl(var(--accent)))] px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-[var(--shadow-card)] disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving…":"Save settings"})})]})}):null}function eh(){var e,t,r,c,u,m,p,x,h,f,g,v,j,N,k,S,A,M,P,D;let L=(0,s.useSearchParams)(),T=L.get("session"),R=L.get("loadedSkill"),[I,_]=(0,n.useState)(""),[E,O]=(0,n.useState)(null),[W,V]=(0,n.useState)([]),[B,G]=(0,n.useState)(""),[Q,Y]=(0,n.useState)(!1),[X,Z]=(0,n.useState)(!1),[$,ee]=(0,n.useState)(!1),[et,er]=(0,n.useState)(!1),[ea,el]=(0,n.useState)(null),[en,es]=(0,n.useState)(null),[eo,ed]=(0,n.useState)({model:"",provider:"unknown",policyPreset:"safe-chat",memoryMode:"standard"}),ei=(0,U.te)(I),ec=(0,w.w)(),eu=(0,U.oz)(),em=(0,U.Kp)(),eh=(0,U.Sv)(),eb=(0,U.tS)(),ef=(0,U.QV)(),eg=(0,U.Or)(),ey=function(){let e=(0,F.jE)();return(0,b.n)({mutationFn:async e=>{var t,r;let{sessionId:a,message:l,attachmentIds:n,onEvent:s}=e,d=await fetch("/api/chat/stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:a,message:l,attachmentIds:n})});if(!d.ok||!d.body){let e=await d.json().catch(()=>null);throw new o.h(d.status,null!=(t=null==e?void 0:e.error)?t:"Unable to stream response",null==e?void 0:e.code,e)}let i=d.body.getReader(),c=new TextDecoder,u="",m=!1;for(;!m;){let{value:e,done:t}=await i.read();if(m=t,t||!e)break;let a=(u+=c.decode(e,{stream:!0})).split("\n\n");for(let e of(u=null!=(r=a.pop())?r:"",a))for(let t of function(e){let t=[];for(let o of e.split("\n\n"))for(let e of o.split("\n").filter(e=>e.startsWith("data:"))){var r,a,l,n,s;let o=e.replace(/^data:\s*/,"").trim();if(!o||"[DONE]"===o)continue;let d=function(e){try{return JSON.parse(e)}catch(e){return null}}(o);if(!d)continue;if("assistant.delta"===d.type||"run.phase"===d.type||"tool.started"===d.type||"tool.awaiting_approval"===d.type||"tool.completed"===d.type||"artifact.emitted"===d.type||"source.emitted"===d.type||"error"===d.type){t.push(d);continue}if("response.output_text.delta"===d.type&&d.delta){t.push({type:"assistant.delta",delta:String(d.delta)});continue}if("response.output_item.added"===d.type&&(null==(r=d.item)?void 0:r.type)==="function_call"){t.push({type:"tool.started",toolCallId:String(d.item.call_id||d.item.id||"tool-call"),toolName:String(d.item.name||"function_call"),riskLevel:"execute",provenance:"local-process"});continue}if("response.output_item.done"===d.type&&(null==(a=d.item)?void 0:a.type)==="function_call"){t.push({type:"tool.completed",toolCallId:String(d.item.call_id||d.item.id||"tool-call"),toolName:String(d.item.name||"function_call"),output:"string"==typeof d.item.arguments?d.item.arguments:JSON.stringify(d.item.arguments||{}),riskLevel:"execute"});continue}if("response.output_item.added"===d.type&&(null==(l=d.item)?void 0:l.type)==="file_search_call"){t.push({type:"tool.started",toolCallId:String(d.item.call_id||d.item.id||"file-search"),toolName:"file_search",riskLevel:"read",provenance:"built-in"});continue}let i=H(d.source||d.citation||(null==(n=d.metadata)?void 0:n.source)||null);if(i&&t.push({type:"source.emitted",source:i}),("response.completed"===d.type||"response.output_item.done"===d.type)&&Array.isArray(null==(s=d.response)?void 0:s.output))for(let e of d.response.output){if((null==e?void 0:e.type)==="message"&&Array.isArray(e.content))for(let r of e.content){((null==r?void 0:r.type)==="output_text"||(null==r?void 0:r.type)==="text")&&r.text&&t.push({type:"assistant.delta",delta:String(r.text)});let e=H((null==r?void 0:r.source)||(null==r?void 0:r.citation)||null);e&&t.push({type:"source.emitted",source:e})}(null==e?void 0:e.type)==="function_call"&&t.push({type:"tool.completed",toolCallId:String(e.call_id||e.id||"tool-call"),toolName:String(e.name||"function_call"),output:"string"==typeof e.arguments?e.arguments:JSON.stringify(e.arguments||{}),riskLevel:"execute"})}}return t}("".concat(e,"\n\n")))null==s||s(t)}return a},onSuccess:async t=>{await e.invalidateQueries({queryKey:["sessions"]}),await e.invalidateQueries({queryKey:["session",t]})}})}(),{runEvents:ev,artifacts:ej,addRunEvent:ew,addArtifact:eN,resetRunState:ek,selectArtifact:eS,updateApprovalState:eA,activeSessionId:eC,setActiveSessionId:eM,selectedProfileId:eP,recentlyLoadedSkillIds:eD,sessionLoadedSkillIds:eL}=(0,i.j)();(0,n.useEffect)(()=>{var e,t;if(!(null==(e=ei.data)?void 0:e.length))return;let r=T&&ei.data.some(e=>e.id===T)?T:null,a=eC&&ei.data.some(e=>e.id===eC)?eC:null,l=null!=(t=null!=r?r:a)?t:ei.data[0].id;(!E||T&&E!==T&&l===T)&&O(l)},[eC,T,E,ei.data]),(0,n.useEffect)(()=>{if(E&&ei.data&&!ei.data.some(e=>e.id===E)){var e,t;O(null!=(t=null==(e=ei.data[0])?void 0:e.id)?t:null)}},[E,ei.data]);let eT=(0,U.wV)(E);(0,n.useEffect)(()=>{E&&eM(E)},[E,eM]),(0,n.useEffect)(()=>{var e,t;if(null==(e=eT.data)?void 0:e.settings)return void ed(eT.data.settings);(null==(t=ec.data)?void 0:t.modelDefault)&&ed(e=>{var t,r;return{...e,model:(null==(t=ec.data)?void 0:t.modelDefault)||e.model,provider:(null==(r=ec.data)?void 0:r.provider)||e.provider}})},[null==(e=ec.data)?void 0:e.modelDefault,null==(t=ec.data)?void 0:t.provider,null==(r=eT.data)?void 0:r.settings]);let eR=(0,n.useMemo)(()=>{var e,t;return[...null!=(t=null==(e=eT.data)?void 0:e.messages)?t:[],...W]},[W,null==(c=eT.data)?void 0:c.messages]),eI=null!=(v=null==(u=ec.data)?void 0:u.apiReachable)&&v,e_=null!=(j=null==(m=ec.data)?void 0:m.available)&&j,eE=null!=(N=null==(p=ec.data)?void 0:p.mockMode)&&N,eO=e_&&!eI,ez=eO&&!eE||eg.isPending,eW=null!=(k=null==(x=eT.data)?void 0:x.title)?k:"New chat",eq=null!=(A=null!=(S=null==(h=ec.data)?void 0:h.activeProfile)?S:eP)?A:"default",eF=!!(E&&eT.data),eH=[{key:"model",label:"Model \xb7 ".concat(eo.model||"default")},{key:"tools",label:"Tools \xb7 ".concat(eI?"runtime live":"degraded")},{key:"profile",label:"Profile \xb7 ".concat(eq)},{key:"mode",label:"Mode \xb7 ".concat(eo.policyPreset)},{key:"files",label:"Files \xb7 ".concat(ej.length)}],eU=E&&null!=(M=eL[E])?M:[],eJ=Array.from(new Set([R,...null!=eU?eU:[],...null!=eD?eD:[],...null!=(P=null==(f=eT.data)?void 0:f.loadedSkillIds)?P:[]].filter(Boolean))),eK=eI?"Talking to ".concat(eo.provider," via the live runtime."):eE?"Mock mode is active for chat flows, approvals, sources, and artifacts.":e_?"Runtime is detected but the API is unreachable, so sending is paused until connectivity returns.":"Runtime was not detected. The UI can still show saved local state and explicit fallback labels.",eV=e=>{es(null),el(null),ek(),V([]),G(""),O(e),eM(e)},eB=async()=>{es(null),el(null),ek(),O(null),eM(null),V([]),G("")},eG=async(e,t)=>{let r=E;r||(O(r=(await eu.mutateAsync()).session.id),eM(r));let a={id:"optimistic-".concat(Date.now()),role:"user",content:e,createdAt:new Date().toISOString()};ek(),es(null),V(e=>[...e,a]),G("");let l=!1;try{await ey.mutateAsync({sessionId:r,message:e,attachmentIds:t,onEvent:e=>{if("assistant.delta"===e.type)return void G(t=>t+e.delta);ew(e),"artifact.emitted"===e.type&&eN({artifactId:e.artifactId,artifactType:e.artifactType,label:e.label,content:e.content})}})}catch(t){l=!0;let e=t instanceof Error?t.message:"Unable to send message.";t instanceof o.h&&503===t.status?(es("Message saved, but the runtime API is unavailable right now. Check diagnostics or retry when the backend comes back."),await Promise.all([eT.refetch(),ei.refetch(),ec.refetch()])):es(e),V([]),G("")}l||(await eT.refetch(),V([]),G(""))},eQ=async(e,t)=>{if(E){el(null),es(null),ed(r=>({...r,model:e,provider:t}));try{await eg.mutateAsync({sessionId:E,settings:{model:e,provider:t}})}catch(e){ed(eo),el(e instanceof Error?e.message:"Unable to update session settings.")}}},eY=async e=>{if(E){el(null),es(null),ed(t=>({...t,...e}));try{await eg.mutateAsync({sessionId:E,settings:e}),er(!1)}catch(e){ed(eo),el(e instanceof Error?e.message:"Unable to update session settings.")}}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid h-full gap-5 lg:grid-cols-[320px_minmax(0,1fr)]",children:[(0,a.jsx)(ep,{sessions:null!=(D=ei.data)?D:[],selectedSessionId:E,search:I,isLoading:ei.isLoading,onSearchChange:_,onNewChat:()=>void eB(),onSelectSession:eV,onResumeSession:eV}),(0,a.jsxs)("section",{className:"flex min-w-0 flex-col overflow-hidden rounded-xl border border-border/70 bg-card/60 shadow-[var(--shadow-elevated)]",children:[eE?(0,a.jsx)("div",{className:"border-b border-warning/30 bg-warning/10 px-5 py-3 text-sm text-foreground",children:"Mock mode is active for chat flows, approvals, sources, and artifacts."}):null,(0,a.jsx)(C,{title:eW,settings:eo,profileLabel:eq,loadedSkillIds:eJ,runtimeConnected:eI,controlsDisabled:ez,isPersisted:eF,archived:null==(g=eT.data)?void 0:g.archived,runtimeSummary:eK,hasMessages:eR.length>0,onOpenSettings:()=>{el(null),er(!0)},onRename:()=>Y(!0),onArchive:()=>Z(!0),onDelete:()=>ee(!0),onFork:()=>{E&&ef.mutateAsync(E).then(e=>{let{session:t}=e;ek(),_(""),O(t.id),eM(t.id),V([]),G("")})},onModelChange:(e,t)=>{eQ(e,t)}}),(0,a.jsx)(q,{messages:eR,runEvents:ev,artifacts:ej,streamingMessage:B,isStreaming:ey.isPending,isLoading:eT.isLoading,onApprove:e=>{(0,d.x)("approval.approved",{toolCallId:e}),fetch("/api/runtime/approvals/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"approved"})}).catch(()=>void 0),eA(e,!0)},onReject:e=>{(0,d.x)("approval.rejected",{toolCallId:e}),fetch("/api/runtime/approvals/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"rejected"})}).catch(()=>void 0),eA(e,!1)},onOpenArtifact:e=>eS(e)}),eO&&!eE?(0,a.jsx)("div",{className:"mx-4 mb-0",children:(0,a.jsx)(z.eS,{layout:"banner",title:"Runtime API is currently unavailable",description:"You can still inspect saved chats, approvals, sources, and artifacts, but sending new messages is paused until the backend reconnects.",primaryAction:(0,a.jsxs)("button",{type:"button",onClick:()=>void ec.refetch(),className:"inline-flex items-center gap-2 rounded-2xl border border-border/70 bg-background/80 px-3 py-2 text-sm font-medium text-foreground",children:[(0,a.jsx)(l.A,{className:"h-4 w-4"}),"Retry runtime"]}),secondaryAction:(0,a.jsx)("a",{href:"/settings/health",className:"rounded-2xl border border-border/70 bg-background/80 px-3 py-2 text-sm font-medium text-foreground",children:"Open diagnostics"})})}):null,en?(0,a.jsx)("div",{className:"mx-4 mt-4",children:(0,a.jsx)(z.W5,{error:en,layout:"banner"})}):null,ea?(0,a.jsx)("div",{className:"mx-4 mt-4",children:(0,a.jsx)(z.W5,{error:ea,layout:"banner"})}):null,(0,a.jsx)(y,{disabled:ey.isPending||eO&&!eE,statusNote:eO&&!eE?"Runtime offline — sending is paused until it reconnects.":eE?"Mock mode active \xb7 Enter to send \xb7 Shift+Enter for newline \xb7 drag files to attach.":0===eR.length?"Start with one request. You can add files or open details if the task needs more context.":"Enter to send \xb7 Shift+Enter for newline \xb7 drag files to attach.",chips:eH,starterPrompts:0===eR.length?["Summarize this context and give me the best next step","Help me turn the current task into an implementation plan","Review the current context and point out risks or open questions"]:[],onSend:eG})]})]}),(0,a.jsx)(K,{open:Q,initialTitle:eW,onClose:()=>Y(!1),onSubmit:async e=>{E&&(Y(!1),await em.mutateAsync({sessionId:E,title:e}))}}),(0,a.jsx)(J,{open:X,title:"Archive session",description:"Archive this conversation but keep it available in history and search.",confirmLabel:"Archive",onClose:()=>Z(!1),onConfirm:async()=>{E&&(await eh.mutateAsync(E),Z(!1))}}),(0,a.jsx)(J,{open:$,title:"Delete session",description:"This permanently removes the selected conversation from the current chat history.",confirmLabel:"Delete",confirmClassName:"rounded-2xl bg-danger px-4 py-2 text-sm font-medium text-white",onClose:()=>ee(!1),onConfirm:async()=>{E&&(await eb.mutateAsync(E),ek(),ee(!1),E==E&&O(null))}}),(0,a.jsx)(ex,{open:et,settings:eo,saving:eg.isPending,error:ea,disabled:eO&&!eE,onClose:()=>er(!1),onSave:eY})]})}},803:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(1847).A)("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]])},1119:(e,t,r)=>{"use strict";function a(e,t){fetch("/api/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event:e,source:"client",payload:null!=t?t:{}}),keepalive:!0}).catch(()=>void 0),console.debug("[telemetry]",e,null!=t?t:{})}r.d(t,{x:()=>a})},2056:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(1847).A)("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},2932:(e,t,r)=>{"use strict";r.d(t,{eS:()=>u,pp:()=>c,W5:()=>m,Gu:()=>i});var a=r(5155),l=r(5299);let n=(0,r(1847).A)("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);var s=r(2056),o=r(4269);function d(e){return"banner"===e?"rounded-xl border border-border/60 bg-card/50 p-4 shadow-[var(--shadow-card)]":"rounded-2xl border border-border/60 bg-card/55 p-6 shadow-[var(--shadow-card)]"}function i(e){var t;let{title:r,message:n,description:s,layout:i="card",className:c,children:u}=e,m=null!=(t=null!=r?r:n)?t:"Loading…";return(0,a.jsxs)("div",{className:(0,o.cn)(d(i),c),children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)(l.A,{className:"mt-0.5 h-4 w-4 animate-spin text-primary"}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"font-semibold text-foreground",children:m}),s?(0,a.jsx)("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:s}):null]})]}),u?(0,a.jsx)("div",{className:"mt-4",children:u}):null]})}function c(e){let{title:t,description:r,icon:l,primaryAction:s,secondaryAction:i,action:c,layout:u="card",className:m}=e,p=null!=s?s:c;return(0,a.jsx)("div",{className:(0,o.cn)(d(u),"border-dashed",m),children:(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("div",{className:"mt-0.5 text-primary",children:null!=l?l:(0,a.jsx)(n,{className:"h-4 w-4"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"font-semibold text-foreground",children:t}),(0,a.jsx)("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:r}),p||i?(0,a.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[p,i]}):null]})]})})}function u(e){let{title:t,description:r,severity:l="warning",icon:n,details:i,primaryAction:c,secondaryAction:u,layout:m="card",className:p}=e;return(0,a.jsx)("div",{className:(0,o.cn)(d(m),"danger"===l?"border-danger/35 bg-danger/10":"border-warning/35 bg-warning/10",p),children:(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("div",{className:(0,o.cn)("mt-0.5","danger"===l?"text-danger":"text-warning"),children:null!=n?n:(0,a.jsx)(s.A,{className:"h-4 w-4"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"font-semibold text-foreground",children:t}),(0,a.jsx)("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:r}),i?(0,a.jsx)("div",{className:"mt-2 text-xs leading-5 text-muted-foreground",children:i}):null,c||u?(0,a.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[c,u]}):null]})]})})}function m(e){let{title:t="Something went wrong",error:r,message:l,description:n,primaryAction:i,secondaryAction:c,layout:u="card",className:m}=e,p=null!=l?l:r,x="string"==typeof p?p:p instanceof Error?p.message:null;return(0,a.jsx)("div",{className:(0,o.cn)(d(u),"border-danger/35 bg-danger/10",m),children:(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)(s.A,{className:"mt-0.5 h-4 w-4 text-danger"}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"font-semibold text-foreground",children:t}),n?(0,a.jsx)("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:n}):null,x?(0,a.jsx)("p",{className:"mt-1 text-sm leading-6 text-foreground",children:x}):null,i||c?(0,a.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[i,c]}):null]})]})})}},3804:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(1847).A)("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]])},3842:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(1847).A)("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]])},5299:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(1847).A)("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},5303:(e,t,r)=>{Promise.resolve().then(r.bind(r,1935)),Promise.resolve().then(r.bind(r,9136)),Promise.resolve().then(r.bind(r,6981)),Promise.resolve().then(r.bind(r,711))},7910:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(1847).A)("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]])},9068:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(1847).A)("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]])}},e=>{e.O(0,[2231,1635,5097,8441,1255,7358],()=>e(e.s=5303)),_N_E=e.O()}]);