@pi-chamber/web 0.3.2 → 0.3.3

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 (39) hide show
  1. package/dist/assets/{CommitSection-DLIvjYbM.js → CommitSection-BAYzLtBf.js} +1 -1
  2. package/dist/assets/{DiagramEditor-Tw3ZWHML.js → DiagramEditor-D1yc4joK.js} +1 -1
  3. package/dist/assets/{DiagramView-CK6R7taL.js → DiagramView-CAlJiG11.js} +1 -1
  4. package/dist/assets/{DiffView-vrxi5oWp.js → DiffView-DGD9DMS7.js} +1 -1
  5. package/dist/assets/{FilesView-BD_h3EVr.js → FilesView-DB5VI7EN.js} +1 -1
  6. package/dist/assets/{GitView-BwNKqK0K.js → GitView-CFlPcSn9.js} +3 -3
  7. package/dist/assets/{JsonTreeView-CmY7QgEX.js → JsonTreeView-CoX1ZscV.js} +1 -1
  8. package/dist/assets/{MarkdownRendererImpl-CpI-25Xk.js → MarkdownRendererImpl-V1HMFCjr.js} +1 -1
  9. package/dist/assets/{PatchDiff-CrIWbYj7.js → PatchDiff-D6Gs7K5B.js} +1 -1
  10. package/dist/assets/{PierreDiffViewer-B410mdbq.js → PierreDiffViewer-COYd5Qr-.js} +1 -1
  11. package/dist/assets/{SessionSwitcherDropdown-DROjbyIu.js → SessionSwitcherDropdown-o1RjhCfF.js} +8 -8
  12. package/dist/assets/{SettingsView-CsJItYZh.js → SettingsView-BYqvfMTS.js} +3 -3
  13. package/dist/assets/{SettingsWindow-C9s4AX72.js → SettingsWindow-CtNS0tQn.js} +1 -1
  14. package/dist/assets/{ToolOutputDialog-b_R4tAZu.js → ToolOutputDialog-2zKUdGYL.js} +1 -1
  15. package/dist/assets/{ToolPartDiffPreview-CfnliaE9.js → ToolPartDiffPreview-CBFC9min.js} +1 -1
  16. package/dist/assets/{VirtualizedFileDiff-CQz2fSZI.js → VirtualizedFileDiff-UMgLcO4Q.js} +1 -1
  17. package/dist/assets/{collapsible-CR4U9tjw.js → collapsible-Kx4bmsQM.js} +1 -1
  18. package/dist/assets/{computeVirtualFileMetrics-C7vXPUYT.js → computeVirtualFileMetrics-DdOCbMyK.js} +1 -1
  19. package/dist/assets/{contextFileOpenGuard-DtTHRnq1.js → contextFileOpenGuard-BRldMp0d.js} +1 -1
  20. package/dist/assets/{index-DZG82DE1.js → index-CuSNEV7s.js} +1 -1
  21. package/dist/assets/{isDiffPlainText-zTq-4A04.js → isDiffPlainText-CGIf0q8p.js} +1 -1
  22. package/dist/assets/{isFilePlainText-CLgIdzE5.js → isFilePlainText-D4hgTRxT.js} +1 -1
  23. package/dist/assets/{main-BVWtJYSk.js → main-By_pvk90.js} +2 -2
  24. package/dist/assets/{main-DXYHsqzA.js → main-CmkRaMOR.js} +4 -4
  25. package/dist/assets/{markdownCore-CN0pApQE.js → markdownCore-CAVCyFnI.js} +1 -1
  26. package/dist/assets/{miniChat-BrbRq5NQ.js → miniChat-_XK2gGZE.js} +2 -2
  27. package/dist/assets/{mobile-DTPtCn5N.js → mobile-B4E4JqAf.js} +2 -2
  28. package/dist/assets/{renderElectronMiniChatApp-CM8qBaye.js → renderElectronMiniChatApp-Ca4hZgIz.js} +1 -1
  29. package/dist/assets/{renderMobileApp-KS_pt-qc.js → renderMobileApp-ClA5Cnmw.js} +4 -4
  30. package/dist/assets/{useInlineCommentController-CwNNjgc7.js → useInlineCommentController-DD31jQNC.js} +1 -1
  31. package/dist/assets/{usePanelSlide-DkorgQJ5.js → usePanelSlide-a4c67FIY.js} +2 -2
  32. package/dist/assets/{useWindowTitle-B9wt_3ZQ.js → useWindowTitle-DoHrUC5r.js} +1 -1
  33. package/dist/assets/{vendor-codemirror-language-data-x89A7Wy0.js → vendor-codemirror-language-data-Dp_Z-0GD.js} +2 -2
  34. package/dist/assets/{web-components-BEPfE4kU.js → web-components-Cct1r-wn.js} +1 -1
  35. package/dist/index.html +1 -1
  36. package/dist/mini-chat.html +1 -1
  37. package/dist/mobile.html +1 -1
  38. package/package.json +1 -1
  39. package/server/lib/pi/session-daemon/session-daemon.js +1 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-heic2any-L8hyfc24.js","assets/vendor-react-DYyjh7Q0.js","assets/vendor-scheduler-7OC5HNn7.js","assets/document-attachments-BslE4Ns7.js","assets/vendor-fflate-C7GOKjkv.js","assets/permissionStore-BRcQ9Jgt.js","assets/vendor-zustand-CnsBKjP5.js","assets/vendor-sonner-CW8w438f.js","assets/MarkdownRendererImpl-CpI-25Xk.js","assets/vendor-morphdom-B7dS_VPB.js","assets/vendor-beautiful-mermaid-r4GK_usS.js","assets/vendor-elkjs-CRCLNXjf.js","assets/vendor-entities-C3BA0AJP.js","assets/index-BAqpUCjs.js","assets/index-riABQmQ_.css","assets/runtimeSurface-CkHYYg0E.js","assets/markdownCore-CN0pApQE.js","assets/vendor-marked-i_gIkIP3.js","assets/vendor-katex-CHD9BdDO.js","assets/vendor-katex-Cp579UoJ.css","assets/vendor-dompurify-r8glNMJW.js","assets/vendor-remend-BWYYytN3.js","assets/registerCustomTheme-BBXUCRnG.js","assets/themeResolver-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-DL8r2fgQ.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-react-dom-sVFnuruh.js","assets/vendor-floating-ui-dom-Bkw82kL9.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-use-sync-external-store-B7OScDIw.js","assets/vendor-dnd-kit-core-GipZW2tY.js","assets/vendor-dnd-kit-utilities-CrOcp0Bp.js","assets/vendor-dnd-kit-accessibility-Cv52zwWT.js","assets/vendor-dnd-kit-sortable-Ct2QxIHb.js","assets/vendor-cmdk-BCEUzcHE.js","assets/vendor-radix-ui-react-dialog-jX3Dld8c.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-D1GnwnP9.js","assets/vendor-radix-ui-react-context-CM4yFQ2I.js","assets/vendor-radix-ui-react-id-BcxRjnbX.js","assets/vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js","assets/vendor-radix-ui-react-use-controllable-state-C_ecoh35.js","assets/vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js","assets/vendor-radix-ui-react-primitive-CfpW6_IT.js","assets/vendor-radix-ui-react-slot-BxUc3Pvz.js","assets/vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js","assets/vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js","assets/vendor-radix-ui-react-focus-scope-C2K7lNPv.js","assets/vendor-radix-ui-react-portal-xlJWBfDg.js","assets/vendor-radix-ui-react-presence-Btn-Dp7L.js","assets/vendor-radix-ui-react-focus-guards-D5MZ0nQs.js","assets/vendor-react-remove-scroll-CfeMe0DL.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-C9YRs2nU.js","assets/vendor-react-style-singleton-B1H4bWSG.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-C-AuTczP.js","assets/vendor-use-callback-ref-CJB0R85I.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-E2vgV9K3.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-DSzLbZiS.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-BUlYhQ3o.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-BS2SpSAZ.js","assets/vendor-codemirror-lang-json-CqayksDf.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-Ba8JZ6fp.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-DK27qQri.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-CvO36Y1p.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-x89A7Wy0.js","assets/vendor-codemirror-lang-python-_2bIYTiJ.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-RrgJ8H_6.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tanstack-react-virtual-IrbCBGJ4.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-DJASDzNt.js","assets/vendor-motion-dom-DJLgZh4Q.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/ToolOutputDialog-b_R4tAZu.js","assets/JsonTreeView-CmY7QgEX.js","assets/web-components-BEPfE4kU.js","assets/computeVirtualFileMetrics-C7vXPUYT.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/Virtualizer-BxW2CJGB.js","assets/isFilePlainText-CLgIdzE5.js","assets/PatchDiff-CrIWbYj7.js","assets/VirtualizedFileDiff-CQz2fSZI.js","assets/isDiffPlainText-zTq-4A04.js","assets/vendor-diff-C3JhlQdm.js","assets/appThemeRegistry-BK0dHKa6.js","assets/ToolPartDiffPreview-CfnliaE9.js"])))=>i.map(i=>d[i]);
2
- import{as as s3,at as u9,au as i1,av as U2,aw as o3,a as We,U as Je,d as yt,w as Wn,ax as Jp,m as w1,R as Bi,r as V1,ay as r3,ao as f9,T as Nn,e as Ti,q as i3,az as po,aA as Xp,aB as Qp,aC as eg,aD as tg,aE as ng,aF as sg,aG as og,aH as rg,aI as ig,aJ as ag,aK as lc,aL as lg,aM as cg,aN as dg,aO as ug,aP as fg,aQ as hg,aR as mg,aS as pg,aT as gg,aU as yg,aV as vg,aW as bg,aX as xg,aY as wg,aZ as Mg,a_ as Cg,J as S1,a$ as a3,E as tt,ap as Sg,b0 as _g,Q as kg,b1 as cc,b2 as Ag,b3 as Hg,b4 as Lg,L as jg,b5 as Ig,b6 as L2,aq as Vo,ar as T0,am as T2,u as he,b7 as Fl,al as h9,b8 as dc,P as wr,b9 as La,s as Hs,ba as Bg,bb as Tg,bc as Vg,bd as Ng,h as Pg,be as Eg,bf as uc,a3 as m9,bg as Ur,a4 as j2,bh as p9,bi as zg,bj as Dg,bk as fc,bl as hc,bm as No,bn as $l,bo as Rg,bp as Po,i as Ot,o as Og,C as Zg,A as Fg,B as $g,bq as go,br as qg,a1 as E0,bs as Ug,bt as Gg,bu as Mr,a2 as Wg,a0 as Kg,bv as Yg,bw as Jg,bx as Xg,by as g9,bz as Qg,H as tn,I as ey,K as y9,bA as mc,bB as ty,bC as ql,ab as Ul,bD as ny,ac as sy,bE as oy,bF as ry,bG as iy}from"./index-BAqpUCjs.js";import{c as W1,p as yo,d as $0,u as pc}from"./vendor-zustand-CnsBKjP5.js";import{r as ae,R as d,j as i,b as V0}from"./vendor-react-DYyjh7Q0.js";import{W as ay,s as ly,a as cy,b as dy,c as uy}from"./vendor-simplewebauthn-browser-VDA66rT_.js";import{_ as V2}from"./vendor-vite-runtime-DD1OZmLC.js";import{m as fy,n as hy,D as my,g as py,j as gy,h as yy,i as vy,e as by,f as xy,o as wy,T as My,p as Cy,q as Sy,r as _y,s as ky,t as Ay,u as Hy,v as Ly,w as jy,M as Iy,b as By,c as Ty,d as l3,S as Vy,x as Ny,y as Py,z as Ey,P as v9,A as b9,B as x9,E as w9,F as M9,G as zy,H as Dy,I as Ry,J as Oy,K as Zy,L as Fy,N as $y,O as qy,Q as Uy,R as Gy,U as Wy,V as Ky}from"./vendor-base-ui-DL8r2fgQ.js";import{i as D2}from"./runtimeSurface-CkHYYg0E.js";import{c as Gr,d as Pn,T as C9,M as c3,D as Wr,e as Kr,P as Yy,h as Jy,a as Xy}from"./vendor-dnd-kit-core-GipZW2tY.js";import{S as Yr,v as Gl,u as Vi,a as S9,r as Qy}from"./vendor-dnd-kit-sortable-Ct2QxIHb.js";import{C as Ni}from"./vendor-dnd-kit-utilities-CrOcp0Bp.js";import{_ as q0}from"./vendor-cmdk-BCEUzcHE.js";import{S as ev,x as tv,H as nv,o as _9,m as sv}from"./vendor-codemirror-language-E2vgV9K3.js";import{a as Ee,h as ov,t as rv}from"./vendor-lezer-highlight-CDMHUZ74.js";import{javascript as Mn}from"./vendor-codemirror-lang-javascript-BUlYhQ3o.js";import{json as k9}from"./vendor-codemirror-lang-json-CqayksDf.js";import{css as A9}from"./vendor-codemirror-lang-css-Ba8JZ6fp.js";import{html as Wl}from"./vendor-codemirror-lang-html-DK27qQri.js";import{markdown as H9}from"./vendor-codemirror-lang-markdown-CvO36Y1p.js";import{l as L9}from"./vendor-codemirror-language-data-x89A7Wy0.js";import{python as j9}from"./vendor-codemirror-lang-python-_2bIYTiJ.js";import{h as iv,s as av,j as lv}from"./vendor-codemirror-commands-RrgJ8H_6.js";import{S as cv,i as I9,k as dv,E as uv,P as fv,o as B9}from"./vendor-codemirror-state-CNWM3Q8V.js";import{E as $2,D as hv,d as mv,k as gc,p as yc}from"./vendor-codemirror-view-DSzLbZiS.js";import{c as T9}from"./vendor-class-variance-authority-5VPnzWs2.js";import{u as V9}from"./vendor-tanstack-react-virtual-IrbCBGJ4.js";import{m as Eo,a as vc}from"./vendor-framer-motion-DJASDzNt.js";import{e as pv}from"./vendor-tanstack-virtual-core-Dubg10g5.js";import{toast as as,Toaster as gv}from"./vendor-sonner-CW8w438f.js";import{c as yv}from"./vendor-clsx-B-dksMZM.js";import{t as vv}from"./vendor-tailwind-merge-CPcsbTWB.js";import{F as N9}from"./vendor-fuse.js-Dw8P0qyA.js";const bv=24;class A0{constructor(t,n,s){this.parent=t,this.overlay=n,this.depth=s}static empty(){return new A0(null,new Map,0)}static from(t){return new A0(null,new Map(t),0)}get(t){return this.overlay.has(t)?this.overlay.get(t):this.parent?.get(t)}has(t){return this.overlay.has(t)?!0:this.parent?.has(t)??!1}set(t,n){return this.overlay.set(t,n),this}fork(){return this.depth>=bv?this.compact().fork():new A0(this,new Map,this.depth+1)}compact(){if(!this.parent)return this;const t=new Map;return this.collect(t),new A0(null,t,0)}get size(){return this.parent?[...this.entries()].length:this.overlay.size}*entries(){const t=new Set;yield*this.walk(t)}*values(){for(const[,t]of this.entries())yield t}*keys(){for(const[t]of this.entries())yield t}[Symbol.iterator](){return this.entries()}*walk(t){for(const[n,s]of this.overlay)t.has(n)||(t.add(n),yield[n,s]);this.parent&&(yield*this.parent.walk(t))}collect(t){this.parent?.collect(t);for(const[n,s]of this.overlay)t.set(n,s)}}const xv=256,P9=(e,t)=>{if(!t)return e;if(!e)return t;if(t===e)return e;if(t.startsWith(e))return t;if(e.startsWith(t))return e;const n=Math.min(xv,e.length,t.length);for(let s=n;s>0;s-=1)if(e.endsWith(t.slice(0,s)))return e+t.slice(s);return e+t},Zt=["off","minimal","low","medium","high","xhigh","max"],wv={off:"Off",minimal:"Minimal",low:"Low",medium:"Medium",high:"High",xhigh:"Extra high",max:"Max"},c2=e=>e==="off"||e==="minimal"||e==="low"||e==="medium"||e==="high"||e==="xhigh"||e==="max",nt=e=>c2(e)?e:null,Mv=(e,t)=>{const n=e.filter(c2),s=n.length>0?n:["off"];if(t&&s.includes(t))return t;const o=Zt.indexOf(t);if(o===-1)return s[0];for(let r=o+1;r<Zt.length;r+=1)if(s.includes(Zt[r]))return Zt[r];for(let r=o-1;r>=0;r-=1)if(s.includes(Zt[r]))return Zt[r];return s[0]},d3=e=>{if(Array.isArray(e?.thinkingLevels)&&e.thinkingLevels.length>0){const t=e.thinkingLevels,n=Zt.filter(s=>t.includes(s));return n.length>0?n:["off"]}return e?.reasoning===!0||e?.supportsThinking===!0?Zt.filter(t=>t!=="xhigh"&&t!=="max"):["off"]},Pi=e=>e.some(t=>t!=="off"&&c2(t)),E9=e=>{const t=d3(e);return Pi(t)?t:[]},s0=e=>e?c2(e)?wv[e]:`${e.charAt(0).toUpperCase()}${e.slice(1)}`:"Default",Cv=(e,t)=>t<=1||!Number.isFinite(e)?0:Math.min(t-1,Math.max(0,Math.round(e*(t-1)))),u3=(e,t,n)=>{const s=e.filter(c2);if(!Pi(s))return;const o=[void 0,...s],r=c2(t)&&s.includes(t)?t:void 0,a=o.indexOf(r);return o[(a+n+o.length)%o.length]},z9=e=>{if(!e)return;const t=e.providerId.trim(),n=e.modelId.trim();if(!(!t||!n))return`${t}/${n}`},D9=(e,t)=>{if(!(!t||!e))return nt(e[t])??void 0},Sv=e=>{if(e.thinking)return e.thinking;const t=z9(e.model);return D9(e.defaultThinkingByModel,t)??nt(e.defaultThinking)??void 0},zo=e=>{const t=d3(e);if(!Pi(t))return;const n=z9({providerId:e.providerId,modelId:e.modelId}),s=D9(e.defaultThinkingByModel,n)??(c2(e.previousThinking)?e.previousThinking:void 0)??nt(e.defaultThinking)??void 0;if(s)return Mv(t,s)},bc=e=>{if(!e)return;const t=e.providerId.trim(),n=e.modelId.trim();if(!(!t||!n))return{providerId:t,modelId:n}},_v=e=>{let t;if(e.messages)for(const o of e.messages){if(o.role!=="assistant")continue;const r=bc(o.model),a=nt(o.thinkingLevel)??void 0;if(!r&&!a)continue;const l=typeof o.createdAt=="number"&&Number.isFinite(o.createdAt)?o.createdAt:0;(!t||l>=t.createdAt)&&(t={createdAt:l,...r?{model:r}:{},...a?{thinkingLevel:a}:{}})}const n=t?.model??bc(e.model),s=t?.thinkingLevel??nt(e.thinking)??void 0;return{...n?{model:n}:{},...s?{thinking:s}:{}}},Kl=e=>e?A0.from(e):A0.empty(),R9=()=>({bySession:new Map,lastSequence:new Map}),O9=()=>Kl(),v0=(e,t,n)=>{t&&(e.lastMutatedMessageId=e.messages.get(t)?.id??t,e.lastMutationKind=n)},nn=e=>{e.parts=e.parts.fork()},kv=(e,t,n)=>{const s=e.bySession.get(t);if(s)return s;const o={sessionId:t,directory:n,lastSequence:-1,lifecycle:"idle",messages:new Map,partOrder:new Map,parts:O9(),toolsByCallId:new Map,streamingMessages:new Set,queue:{steering:0,followUp:0}};return e.bySession.set(t,o),o},Ei=(e,t)=>e.startsWith(`user-${t}-`),Av=250,xc=new WeakMap,wc=new WeakMap,vo=e=>{const t=xc.get(e.messages);if(t&&t.size===e.messages.size)return t.list;const n=new Set,s=[];for(const o of e.messages.values())n.has(o.id)||(n.add(o.id),s.push(o));for(let o=1;o<s.length;o+=1){const r=s[o-1],a=s[o];if(!(!r||!a||a.createdAt>=r.createdAt)){s.sort((l,c)=>l.createdAt-c.createdAt);break}}return xc.set(e.messages,{size:e.messages.size,list:s}),s},Z9=(e,t,n)=>{if(!t)return;let s,o=Number.POSITIVE_INFINITY;for(const r of vo(e)){if(r.role!=="user"||r.text!==t||Ei(r.id,e.sessionId))continue;const a=Math.abs(r.createdAt-n);a<=Av&&a<o&&(s=r,o=a)}return s},Hv=(e,t,n)=>{if(n.role==="user"&&Ei(t,e.sessionId)){const s=Z9(e,n.text,n.createdAt);if(s){e.messages.set(t,s);return}}e.messages.set(t,n)},zi=(e,t)=>{if(!t)return;const n=e.messages.get(t)?.id;if(n)return n;if(Ei(t,e.sessionId)){const s=vo(e);for(let o=s.length-1;o>=0;o-=1){const r=s[o];if(r?.role==="user")return r.id}}return t},Lv=(e,t,n)=>{const s=e.messages.get(t.messageId);if(s)return s;if(t.role==="user"&&Ei(t.messageId,e.sessionId)){const a=Z9(e,t.text??"",t.startedAt);if(a)return e.messages.set(t.messageId,a),a}const o=zi(e,t.parentId),r={id:t.messageId,sessionId:e.sessionId,directory:n,role:t.role,...o?{parentId:o}:{},createdAt:t.startedAt,text:t.role==="user"?t.text??"":"",thinking:"",streaming:t.role==="assistant",...t.model?{model:t.model}:{},...t.thinkingLevel?{thinkingLevel:t.thinkingLevel}:{}};return e.messages.set(t.messageId,r),r},F9=(e,t,n,s)=>{const o=s??`${t.id}:${n}`,r=e.parts.get(o);if(r)return r;const a={id:o,index:(e.partOrder.get(t.id)??[]).length,type:n,text:"",streaming:!0};e.parts.set(o,a);const l=[...e.partOrder.get(t.id)??[]];return l.includes(a.id)||l.push(a.id),e.partOrder.set(t.id,l),a},jv=(e,t)=>{if(!e.messages.get(t))return{text:"",thinking:""};const s=e.partOrder.get(t)??[];let o="",r="";for(const a of s){const l=e.parts.get(a);l&&(l.type==="text"?o+=l.text:l.type==="thinking"&&(r+=l.text))}return{text:o,thinking:r}},Mc=(e,t,n,s)=>{const r=(e.partOrder.get(t)??[]).map(c=>e.parts.get(c)).filter(c=>c?.type===n);if(r.length===0){if(!s)return;const c=e.messages.get(t);if(!c)return;const u=F9(e,c,n);e.parts.set(u.id,{...u,text:s,streaming:!1});return}const[a,...l]=r;if(a){e.parts.set(a.id,{...a,text:s,streaming:!1});for(const c of l)e.parts.set(c.id,{...c,text:"",streaming:!1})}},Iv=(e,t)=>{if(t.state==="retry"){e.lifecycle="retry",e.retry={...t.attempt!==void 0?{attempt:t.attempt}:{},...t.next!==void 0?{next:t.next}:{},...t.message!==void 0?{message:t.message}:{}};return}if(t.state==="busy"&&e.retry){e.lifecycle="retry";return}if(e.lifecycle=t.state,e.retry=void 0,t.state!=="busy"){e.streamingMessages=new Set,e.messages=new Map(e.messages);for(const[n,s]of e.messages)s.streaming&&e.messages.set(n,{...s,streaming:!1})}},Bv=(e,t,n)=>{Lv(e,n,t)},f3=(e,t)=>{const n=e.messages.get(t);if(n&&n.role==="assistant")return n;const s=vo(e);for(let r=s.length-1;r>=0;r-=1){const a=s[r];if(a.role==="assistant"&&(a.streaming||a.durationMs===void 0))return e.messages.set(t,a),!e.partOrder.has(t)&&e.partOrder.has(a.id)&&e.partOrder.set(t,e.partOrder.get(a.id)),a}const o=s[s.length-1];if(o&&o.role==="assistant")return e.messages.set(t,o),!e.partOrder.has(t)&&e.partOrder.has(o.id)&&e.partOrder.set(t,e.partOrder.get(o.id)),o},Tv=(e,t,n)=>{const s=new Set(e.partOrder.get(t)??[]);if(s.size!==0)for(const[o,r]of e.parts)!r.streaming||!n(r)||!s.has(r.id)&&!s.has(o)||e.parts.set(o,{...r,streaming:!1})},$9=(e,t)=>{Tv(e,t,n=>n.type==="thinking")},Cc=(e,t,n)=>{const s=f3(e,t.messageId);if(!s)return!1;s.streaming=!0,e.streamingMessages.add(s.id),e.streamingMessages.add(t.messageId),n==="text"&&$9(e,s.id);const o=t.partId??`${s.id}:${n}`;let r=e.parts.get(o);if(!r){const l=t.contentIndex;if(typeof l=="number"){const c=[`${s.id}:${n}:${l}`,`${s.id}:${l}`,`${s.id}:${n}`];for(const u of c){const f=e.parts.get(u);if(f&&f.type===n){r=f;break}}if(!r){const u=e.partOrder.get(s.id)??[];for(const f of u){const h=e.parts.get(f);if(h&&h.type===n&&h.index===l){r=h;break}}}}}if(r){if(r.type!==n)return!1;const l={...r,text:P9(r.text,t.delta),streaming:!0};return e.parts.set(r.id,l),o!==r.id&&e.parts.set(o,l),!0}const a=F9(e,s,n,o);return e.parts.set(a.id,{...a,text:t.delta,streaming:!0}),!0},Vv=(e,t)=>{const n=f3(e,t.messageId);if(!n)return;const{text:s,thinking:o}=jv(e,n.id);n.text=typeof t.text=="string"?t.text:s,n.thinking=typeof t.thinking=="string"?t.thinking:o,Mc(e,n.id,"text",n.text),Mc(e,n.id,"thinking",n.thinking),n.streaming=!1,typeof t.durationMs=="number"?n.durationMs=t.durationMs:typeof n.createdAt=="number"&&n.createdAt>0&&(n.durationMs=Math.max(100,Date.now()-n.createdAt)),t.thinkingLevel&&(n.thinkingLevel=t.thinkingLevel),t.error&&(n.error=t.error),t.usage&&(n.usage=t.usage),t.continuing!==!0&&!t.error&&(e.streamingMessages.delete(n.id),e.streamingMessages.delete(t.messageId))},ja=(e,t,n)=>{const s=e.toolsByCallId.get(n.toolCallId)??n.messageId,o=f3(e,s);if(!o)return!1;$9(e,o.id),t!=="end"&&(o.streaming=!0,e.streamingMessages.add(o.id));const r=e.parts.get(n.partId)??Array.from(e.parts.values()).find(c=>c.type==="tool"&&c.tool?.toolCallId===n.toolCallId);if(t==="start"&&!r){const c={id:n.partId,index:(e.partOrder.get(o.id)??[]).length,type:"tool",text:"",streaming:!1,tool:{toolCallId:n.toolCallId,name:n.name,...n.input!==void 0?{input:n.input}:{},state:n.state,...n.startedAt!==void 0?{startedAt:n.startedAt}:{}}};e.parts.set(c.id,c);const u=[...e.partOrder.get(o.id)??[]];return u.push(c.id),e.partOrder.set(o.id,u),e.toolsByCallId.set(n.toolCallId,o.id),!0}if(!r||r.type!=="tool")return!1;const a={...r},l=r.tool;return a.tool={toolCallId:n.toolCallId,name:n.name,...n.input!==void 0?{input:n.input}:l?.input!==void 0?{input:l.input}:{},...n.output!==void 0?{output:n.output}:l?.output!==void 0?{output:l.output}:{},...n.error!==void 0?{error:n.error}:l?.error!==void 0?{error:l.error}:{},...n.metadata!==void 0?{metadata:n.metadata}:l?.metadata!==void 0?{metadata:l.metadata}:{},...n.isError!==void 0?{isError:n.isError}:l?.isError!==void 0?{isError:l.isError}:{},state:n.state,...n.startedAt!==void 0?{startedAt:n.startedAt}:l?.startedAt!==void 0?{startedAt:l.startedAt}:{},...n.endedAt!==void 0?{endedAt:n.endedAt}:l?.endedAt!==void 0?{endedAt:l.endedAt}:{}},t==="end"&&(a.streaming=!1),e.parts.set(a.id,a),!0},Nv=(e,t)=>{if(e.lifecycle="interrupted",e.retry=void 0,!!t){for(const n of e.streamingMessages){const s=e.messages.get(n);s&&(s.streaming=!1,s.error={code:"SESSION_INTERRUPTED"})}e.streamingMessages.clear()}},Pv=(e,t,n)=>{e.lifecycle="error",e.retry=void 0;const s=Date.now();e.parts=e.parts.fork(),e.partOrder=new Map(e.partOrder);for(const o of e.streamingMessages){const r=e.messages.get(o);if(r){r.streaming=!1,r.error={code:t,...n?{message:n}:{}},r.durationMs===void 0&&r.createdAt>0&&(r.durationMs=Math.max(100,s-r.createdAt));for(const a of e.partOrder.get(o)??[]){const l=e.parts.get(a);if(!l)continue;const c=l.tool?.state==="running"||l.tool?.state==="pending";if(!l.streaming&&!c)continue;const u={...l,streaming:!1};c&&u.tool&&(u.tool={...u.tool,state:"error",...n?{error:n}:{},endedAt:u.tool.endedAt??s}),e.parts.set(a,u)}}}e.streamingMessages.clear()},Sc=(e,t)=>{const n=e.lastSequence.get(t.sessionId)??-1;if(t.sequence<=n)return{state:e,didApply:!1};const s=e.bySession.get(t.sessionId),o=s?{...s,lastSequence:t.sequence,...t.name==="session.lifecycle"?{lifecycle:t.payload.state}:{},...t.name==="session.queue"?{queue:{...t.payload}}:{},...t.name==="session.model"?{model:t.payload.model}:{},...t.name==="session.thinking"?{thinking:t.payload.thinking}:{}}:{sessionId:t.sessionId,directory:t.directory,lastSequence:t.sequence,lifecycle:"idle",messages:new Map,partOrder:new Map,parts:O9(),toolsByCallId:new Map,streamingMessages:new Set,queue:{steering:0,followUp:0}};switch(t.name){case"session.snapshot":t.payload?.snapshot&&(o.lifecycle=t.payload.snapshot.lifecycle??(t.payload.snapshot.isStreaming?"busy":"idle"),o.retry=o.lifecycle==="retry"?t.payload.snapshot.retry:void 0,t.payload.snapshot.model&&(o.model=t.payload.snapshot.model),t.payload.snapshot.thinking&&(o.thinking=t.payload.snapshot.thinking),t.payload.snapshot.queue&&(o.queue={...t.payload.snapshot.queue}),U9(o,{isStreaming:t.payload.snapshot.isStreaming,lifecycle:o.lifecycle,...t.payload.snapshot.retry?{retry:t.payload.snapshot.retry}:{},settleWhenIdle:!0}));break;case"session.lifecycle":Iv(o,t.payload);break;case"assistant.message.start":o.lifecycle=o.retry?"retry":"busy",o.messages=new Map(o.messages),o.streamingMessages=new Set(o.streamingMessages),Bv(o,t.directory,t.payload),t.payload.role==="assistant"&&o.streamingMessages.add(t.payload.messageId),v0(o,t.payload.messageId,"structure");break;case"assistant.message.delta":nn(o),Cc(o,t.payload,"text")&&(o.lifecycle="busy",o.retry=void 0),v0(o,t.payload.messageId,"part");break;case"assistant.message.end":o.messages=new Map(o.messages),nn(o),o.partOrder=new Map(o.partOrder),o.streamingMessages=new Set(o.streamingMessages),Vv(o,t.payload),v0(o,t.payload.messageId,"structure");break;case"assistant.thinking.delta":nn(o),Cc(o,t.payload,"thinking")&&(o.lifecycle="busy",o.retry=void 0),v0(o,t.payload.messageId,"part");break;case"session.tool.start":nn(o),o.partOrder=new Map(o.partOrder),o.toolsByCallId=new Map(o.toolsByCallId),ja(o,"start",t.payload)&&(o.lifecycle="busy",o.retry=void 0),v0(o,t.payload.messageId,"part");break;case"session.tool.update":nn(o),ja(o,"update",t.payload)&&(o.lifecycle="busy",o.retry=void 0),v0(o,t.payload.messageId,"part");break;case"session.tool.end":nn(o),ja(o,"end",t.payload)&&(o.lifecycle="busy",o.retry=void 0),v0(o,t.payload.messageId,"part");break;case"session.queue":o.queue={steering:t.payload.steering,followUp:t.payload.followUp};break;case"session.model":o.model=t.payload.model;break;case"session.thinking":o.thinking=t.payload.thinking;break;case"session.compaction":break;case"session.updated":break;case"session.error":o.messages=new Map(o.messages),o.streamingMessages=new Set(o.streamingMessages);for(const a of o.streamingMessages){const l=o.messages.get(a);l&&o.messages.set(a,{...l})}Pv(o,t.payload.code,t.payload.message);break;case"session.interrupted":o.messages=new Map(o.messages),o.streamingMessages=new Set(o.streamingMessages);for(const a of o.streamingMessages){const l=o.messages.get(a);l&&o.messages.set(a,{...l})}Nv(o,t.payload.streaming);break}const r={bySession:new Map(e.bySession),lastSequence:new Map(e.lastSequence)};return r.bySession.set(t.sessionId,o),r.lastSequence.set(t.sessionId,t.sequence),{state:r,didApply:!0,sessionId:t.sessionId}},Ev=e=>{const t=wc.get(e);if(t)return t;const n={id:e.id,type:e.type,text:e.text,streaming:e.streaming,...e.tool?{tool:e.tool}:{},...e.attachment?{attachment:e.attachment}:{}};return wc.set(e,n),n},zv=(e,t)=>{const n=new Set,s=new Set;for(let o=t.length-1;o>=0;o-=1){const r=t[o];if(!r||r.role!=="assistant")continue;const a=zi(e,r.parentId);if(!a)continue;const l=!!(r.text||r.thinking||(e.partOrder.get(r.id)?.length??0)>0);if(r.error&&!l&&n.has(a)){s.add(r.id);continue}r.error||n.add(a)}return s},Dv=(e,t,n,s)=>n.id===t.id&&n.role===t.role&&n.parentId===zi(e,t.parentId)&&n.text===t.text&&n.thinking===t.thinking&&n.streaming===t.streaming&&n.createdAt===t.createdAt&&n.durationMs===t.durationMs&&n.error===t.error&&n.model===t.model&&n.thinkingLevel===t.thinkingLevel&&n.usage===t.usage&&n.parts.length===s.length&&n.parts.every((o,r)=>o===s[r]),Rv=(e,t,n)=>{const s=e.partOrder.get(t.id)??[],o=[];for(const a of s){const l=e.parts.get(a);l&&o.push(Ev(l))}if(n&&Dv(e,t,n,o))return n;const r=zi(e,t.parentId);return{id:t.id,role:t.role,...r?{parentId:r}:{},text:t.text,thinking:t.thinking,streaming:t.streaming,createdAt:t.createdAt,...t.durationMs!==void 0?{durationMs:t.durationMs}:{},...t.error?{error:t.error}:{},...t.model?{model:t.model}:{},...t.thinkingLevel?{thinkingLevel:t.thinkingLevel}:{},...t.usage?{usage:t.usage}:{},parts:o}},q9=(e,t)=>{const n=vo(e),s=zv(e,n),o=t?new Map(t.projection.messages.map(a=>[a.id,a])):null,r=[];for(const a of n)s.has(a.id)||r.push(Rv(e,a,o?.get(a.id)));return t&&t.projection.sessionId===e.sessionId&&t.projection.directory===e.directory&&t.projection.lifecycle===e.lifecycle&&t.projection.model===e.model&&t.projection.thinking===e.thinking&&t.projection.queue.steering===e.queue.steering&&t.projection.queue.followUp===e.queue.followUp&&t.projection.messages.length===r.length&&t.projection.messages.every((a,l)=>a===r[l])?t.projection:{sessionId:e.sessionId,directory:e.directory,lifecycle:e.lifecycle,...e.model?{model:e.model}:{},...e.thinking?{thinking:e.thinking}:{},queue:{...e.queue},messages:r}},U9=(e,t)=>{const n=[],s=[];for(const[l,c]of e.parts){const u=c.tool?.state;if(c.type!=="tool"||u!=="running"&&u!=="pending")continue;s.push(l);const f=c.tool?.toolCallId?e.toolsByCallId.get(c.tool.toolCallId):void 0;f&&n.push(f)}if(!(t?.isStreaming===!0||t?.lifecycle==="busy"||t?.lifecycle==="retry"||t?.inferFromRunningTools===!0&&n.length>0)){if(e.retry=void 0,t?.settleWhenIdle){e.streamingMessages=new Set,e.messages=new Map(e.messages);for(const[l,c]of e.messages)c.streaming&&e.messages.set(l,{...c,streaming:!1})}return}e.lifecycle=t?.lifecycle==="retry"?"retry":"busy",e.retry=e.lifecycle==="retry"?t?.retry:void 0,e.streamingMessages=new Set(e.streamingMessages);for(const l of s){const c=e.parts.get(l);c&&e.parts.set(l,{...c,streaming:!0})}let r=n[n.length-1];if(!r){const l=vo(e);for(let c=l.length-1;c>=0;c-=1){const u=l[c];if(u?.role==="assistant"){r=u.id;break}}}if(!r)return;const a=e.messages.get(r);!a||a.role!=="assistant"||(e.messages.set(r,{...a,streaming:!0}),e.streamingMessages.add(r))},h3=e=>{const t=R9(),n=kv(t,e.session.id,e.session.directory);n.lastSequence=e.lastSequence;for(const{message:o,parts:r}of e.messages){const a={id:o.id,sessionId:e.session.id,directory:e.session.directory,role:o.role,...o.parentId?{parentId:o.parentId}:{},createdAt:o.createdAt,text:o.text??"",thinking:o.role==="assistant"?o.thinking??"":"",streaming:!1,...o.role==="assistant"&&o.durationMs!==void 0?{durationMs:o.durationMs}:{},...o.role==="assistant"&&o.error?{error:o.error}:{},...o.role==="assistant"&&o.model?{model:o.model}:{},...o.role==="assistant"&&o.thinkingLevel?{thinkingLevel:o.thinkingLevel}:{},...o.role==="assistant"&&o.usage?{usage:o.usage}:{}};n.messages.set(o.id,a);const l=[];for(const c of r){const u={id:c.id,index:c.index,type:c.type,text:c.text??"",streaming:!1,...c.type==="tool"?{tool:{toolCallId:c.toolCallId??c.id,name:c.name??"unknown",...c.input!==void 0?{input:c.input}:{},...c.output!==void 0?{output:c.output}:{},...typeof c.error=="string"?{error:c.error}:{},...c.metadata!==void 0?{metadata:c.metadata}:{},...c.isError!==void 0?{isError:c.isError}:{},state:c.state??"completed",...c.startedAt!==void 0?{startedAt:c.startedAt}:{},...c.endedAt!==void 0?{endedAt:c.endedAt}:{}}}:{},...c.type==="attachment"&&c.attachment?{attachment:c.attachment}:{}};n.parts.set(c.id,u),l.push(c.id),c.type==="tool"&&c.toolCallId&&n.toolsByCallId.set(c.toolCallId,o.id)}n.partOrder.set(o.id,l)}const s=_v({model:e.session.model,thinking:e.session.thinking,messages:n.messages.values()});return s.model&&(n.model=s.model),s.thinking&&(n.thinking=s.thinking),U9(n,{...e.isStreaming!==void 0?{isStreaming:e.isStreaming}:{},...e.lifecycle?{lifecycle:e.lifecycle}:{},...e.retry?{retry:e.retry}:{},inferFromRunningTools:!0}),t.lastSequence.set(e.session.id,e.lastSequence),{state:t,session:n}},Ov={fetchHealth:u9,createStream:s3},Ia=e=>e instanceof U2?{code:e.code,...e.message?{message:e.message}:{},...e.status!==void 0?{status:e.status}:{}}:e instanceof Error?{code:"DAEMON_REQUEST_FAILED",message:e.message}:{code:"DAEMON_REQUEST_FAILED"},Zv=async(e,t=Ov)=>{const n={phase:"idle",reducerState:{bySession:new Map,lastSequence:new Map},lastSequence:new Map,stream:null,errors:[],health:{state:"pending"}},s=async l=>e.retry?e.retry(l):l();n.phase="runtime-probe";const o=e.initialHealth??await s(()=>t.fetchHealth(e.signal,e.runtimeKey));if(o.state==="ready")n.health={state:"ready",protocolVersion:o.protocolVersion,capabilities:[...o.capabilities]};else return n.health={state:"unavailable",protocolVersion:o.protocolVersion,error:{code:o.error?.code??"DAEMON_UNAVAILABLE",...o.error?.message?{message:o.error.message}:{}}},n.phase="failed",n.errors.push({phase:"runtime-probe",error:n.health.error}),n;n.phase="session-list";const r=l=>{for(const c of l)n.lastSequence.set(c.session.id,-1)};if(e.initialSessions)r(e.initialSessions);else try{const l=await s(()=>i1.listSessions({...e.scope,directory:e.directory,...e.runtimeKey?{runtimeKey:e.runtimeKey}:{}}));r(l.sessions)}catch(l){n.errors.push({phase:"session-list",error:Ia(l)})}if(e.selectedSessionId){n.phase="session-hydrate";try{const l=await s(()=>i1.getSession(e.selectedSessionId,{...e.scope,directory:e.directory,...e.runtimeKey?{runtimeKey:e.runtimeKey}:{}})),{state:c}=h3({session:l.session,lastSequence:l.lastSequence,...l.isStreaming!==void 0?{isStreaming:l.isStreaming}:{},...l.lifecycle?{lifecycle:l.lifecycle}:{},messages:l.messages.map(u=>({message:u.message,parts:u.parts.map(f=>({id:f.id,index:f.index,type:f.type,text:f.type==="text"||f.type==="thinking"?f.text:void 0,...f.type==="tool"?{toolCallId:f.toolCallId,name:f.name,...f.input!==void 0?{input:f.input}:{},...f.output!==void 0?{output:f.output}:{},...f.isError!==void 0?{isError:f.isError}:{},state:f.state,...f.startedAt!==void 0?{startedAt:f.startedAt}:{},...f.endedAt!==void 0?{endedAt:f.endedAt}:{}}:{},...f.type==="attachment"?{attachment:f.attachment}:{}}))}))});n.reducerState=c,n.lastSequence.set(l.session.id,l.lastSequence)}catch(l){n.errors.push({phase:"session-hydrate",error:Ia(l)})}}n.phase="stream-attach";try{const l=e.selectedSessionId?n.lastSequence.get(e.selectedSessionId):e.fromSequence,c=t.createStream({onEvent:e.onEvent,onDisconnect:u=>e.onStreamDisconnect?.(u),onReconnect:()=>e.onStreamReconnect?.(),onTransportSwitch:()=>e.onTransportSwitch?.()},{...typeof l=="number"&&l>=0?{fromSequence:l}:{},...e.runtimeKey?{runtimeKey:e.runtimeKey}:{},signal:e.signal});n.stream=c}catch(l){n.errors.push({phase:"stream-attach",error:Ia(l)})}const a=n.errors.some(l=>l.phase==="runtime-probe");return n.phase=a?"failed":"ready",n},Fv=e=>({sessionId:e.sessionId,directory:e.directory,isStreaming:e.isStreaming,lastSequence:e.lastSequence,queue:e.queue??{steering:0,followUp:0},...e.model?{model:e.model}:{},...e.thinking?{thinking:e.thinking}:{},...e.lastText?{lastText:e.lastText}:{},...e.lastThinking?{lastThinking:e.lastThinking}:{},...e.lastToolPart?{lastToolPart:e.lastToolPart}:{},lifecycle:e.lifecycle}),$v=()=>({bySession:new Map,lastSequence:new Map}),qv=(e,t)=>{const n=e.lastSequence.get(t.sessionId)??-1;if(t.lastSequence<=n)return{state:e,didUpdate:!1};const s={bySession:new Map(e.bySession),lastSequence:new Map(e.lastSequence)};return s.bySession.set(t.sessionId,Fv(t)),s.lastSequence.set(t.sessionId,t.lastSequence),{state:s,didUpdate:!0}},Uv={fetchHealth:u9,createStream:s3},_c=e=>e instanceof U2?{code:e.code,...e.message?{message:e.message}:{},...e.status!==void 0?{status:e.status}:{}}:e instanceof Error?{code:"DAEMON_REQUEST_FAILED",message:e.message}:{code:"DAEMON_REQUEST_FAILED"},Gv=async(e,t=Uv)=>{const n={phase:"idle",snapshotState:$v(),reducerState:{bySession:new Map,lastSequence:new Map},stream:null,lastSequence:e.lastKnownSequence??-1},s=async r=>e.retry?e.retry(r):r();n.phase="health-check";const o=await s(()=>t.fetchHealth(e.signal,e.runtimeKey));if(o.state!=="ready")return n.phase="unavailable",n.error={code:o.error?.code??"DAEMON_UNAVAILABLE",...o.error?.message?{message:o.error.message}:{}},n;n.phase="snapshot-fetch";try{const r=await s(()=>i1.getSession(e.sessionId,{directory:e.directory,...e.runtimeKey?{runtimeKey:e.runtimeKey}:{}})),a=h3({session:r.session,lastSequence:r.lastSequence,...r.isStreaming!==void 0?{isStreaming:r.isStreaming}:{},...r.lifecycle?{lifecycle:r.lifecycle}:{},messages:r.messages.map(u=>({message:u.message,parts:u.parts.map(f=>({id:f.id,index:f.index,type:f.type,text:f.type==="text"||f.type==="thinking"?f.text:void 0,...f.type==="tool"?{toolCallId:f.toolCallId,name:f.name,...f.input!==void 0?{input:f.input}:{},...f.output!==void 0?{output:f.output}:{},...f.isError!==void 0?{isError:f.isError}:{},state:f.state,...f.startedAt!==void 0?{startedAt:f.startedAt}:{},...f.endedAt!==void 0?{endedAt:f.endedAt}:{}}:{},...f.type==="attachment"?{attachment:f.attachment}:{}}))}))});n.reducerState=a.state;const l={protocolVersion:1,kind:"event",name:"session.snapshot",sequence:r.lastSequence,sessionId:r.session.id,directory:r.session.directory,payload:{snapshot:{sessionId:r.session.id,directory:r.session.directory,lastSequence:r.lastSequence,isStreaming:r.isStreaming===!0,queue:{steering:0,followUp:0},lifecycle:r.lifecycle??(r.isStreaming?"busy":"idle"),...r.session.model?{model:r.session.model}:{},...r.session.thinking?{thinking:r.session.thinking}:{}}}},c=qv(n.snapshotState,l.payload.snapshot);n.snapshotState=c.state,n.lastSequence=Math.max(e.lastKnownSequence??-1,r.lastSequence)}catch(r){const a=_c(r);return a.code==="INVALID_SESSION",n.phase="failed",n.error=a,n}n.phase="stream-attach";try{n.stream=t.createStream({onEvent:e.onEvent,onDisconnect:r=>e.onStreamDisconnect?.(r),onReconnect:()=>e.onStreamReconnect?.(),onTransportSwitch:()=>e.onTransportSwitch?.()},{fromSequence:n.lastSequence,...e.runtimeKey?{runtimeKey:e.runtimeKey}:{},signal:e.signal})}catch(r){return n.phase="failed",n.error=_c(r),n}return n.phase="ready",n},Wv=new Set(["assistant.message.delta","assistant.thinking.delta","session.tool.update"]),Kv=e=>Wv.has(e.name),Jr=e=>e.name==="assistant.message.delta"||e.name==="assistant.thinking.delta"?e:null,Yv=(e,t)=>{const n=Jr(e),s=Jr(t);return!n||!s||n.name!==s.name||n.sessionId!==s.sessionId?!1:n.payload.messageId===s.payload.messageId&&n.payload.contentIndex===s.payload.contentIndex&&(n.payload.partId??"")===(s.payload.partId??"")},Jv=(e,t)=>{const n=Jr(e),s=Jr(t);return!n||!s||n.name!==s.name?t:{...s,payload:{...s.payload,delta:P9(n.payload.delta,s.payload.delta)}}},Ba=e=>{const t=[];for(const n of e){const s=t[t.length-1];s&&Yv(s,n)?t[t.length-1]=Jv(s,n):t.push(n)}return t};class Xv{constructor(t){this.publish=t}buffer=[];scheduled="none";generation=0;rafId=0;push(t){if(!Kv(t)){const n=this.takeBuffer();this.publish(Ba([...n,t]));return}this.buffer.push(t),this.schedule()}flush(){const t=this.takeBuffer();t.length!==0&&this.publish(Ba(t))}dispose(){this.flush()}takeBuffer(){if(this.generation+=1,this.scheduled="none",this.rafId&&typeof globalThis.cancelAnimationFrame=="function"&&globalThis.cancelAnimationFrame(this.rafId),this.rafId=0,this.buffer.length===0)return[];const t=this.buffer;return this.buffer=[],t}schedule(){if(this.scheduled!=="none")return;const t=++this.generation,n=()=>{if(t!==this.generation)return;this.scheduled="none",this.rafId=0;const s=this.buffer;this.buffer=[],s.length!==0&&this.publish(Ba(s))};if(typeof globalThis.requestAnimationFrame=="function"){this.scheduled="frame",this.rafId=globalThis.requestAnimationFrame(n);return}this.scheduled="microtask",queueMicrotask(n)}}function G9(e,t=50){if(typeof e!="string"||e.trim().length===0)return"";const s=e.replace(/```[\s\S]*?```/g," ").replace(/`[^`]+`/g," ").replace(/\[attachment:[^\]]+\]/g," ").replace(/(^|\s)@[\w.-]+/g," ").replace(/<[^>]+>/g," ").replace(/\r\n/g,`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-heic2any-L8hyfc24.js","assets/vendor-react-DYyjh7Q0.js","assets/vendor-scheduler-7OC5HNn7.js","assets/document-attachments-BslE4Ns7.js","assets/vendor-fflate-C7GOKjkv.js","assets/permissionStore-BRcQ9Jgt.js","assets/vendor-zustand-CnsBKjP5.js","assets/vendor-sonner-CW8w438f.js","assets/MarkdownRendererImpl-V1HMFCjr.js","assets/vendor-morphdom-B7dS_VPB.js","assets/vendor-beautiful-mermaid-r4GK_usS.js","assets/vendor-elkjs-CRCLNXjf.js","assets/vendor-entities-C3BA0AJP.js","assets/index-BAqpUCjs.js","assets/index-riABQmQ_.css","assets/runtimeSurface-CkHYYg0E.js","assets/markdownCore-CAVCyFnI.js","assets/vendor-marked-i_gIkIP3.js","assets/vendor-katex-CHD9BdDO.js","assets/vendor-katex-Cp579UoJ.css","assets/vendor-dompurify-r8glNMJW.js","assets/vendor-remend-BWYYytN3.js","assets/registerCustomTheme-BBXUCRnG.js","assets/themeResolver-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-DL8r2fgQ.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-react-dom-sVFnuruh.js","assets/vendor-floating-ui-dom-Bkw82kL9.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-use-sync-external-store-B7OScDIw.js","assets/vendor-dnd-kit-core-GipZW2tY.js","assets/vendor-dnd-kit-utilities-CrOcp0Bp.js","assets/vendor-dnd-kit-accessibility-Cv52zwWT.js","assets/vendor-dnd-kit-sortable-Ct2QxIHb.js","assets/vendor-cmdk-BCEUzcHE.js","assets/vendor-radix-ui-react-dialog-jX3Dld8c.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-D1GnwnP9.js","assets/vendor-radix-ui-react-context-CM4yFQ2I.js","assets/vendor-radix-ui-react-id-BcxRjnbX.js","assets/vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js","assets/vendor-radix-ui-react-use-controllable-state-C_ecoh35.js","assets/vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js","assets/vendor-radix-ui-react-primitive-CfpW6_IT.js","assets/vendor-radix-ui-react-slot-BxUc3Pvz.js","assets/vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js","assets/vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js","assets/vendor-radix-ui-react-focus-scope-C2K7lNPv.js","assets/vendor-radix-ui-react-portal-xlJWBfDg.js","assets/vendor-radix-ui-react-presence-Btn-Dp7L.js","assets/vendor-radix-ui-react-focus-guards-D5MZ0nQs.js","assets/vendor-react-remove-scroll-CfeMe0DL.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-C9YRs2nU.js","assets/vendor-react-style-singleton-B1H4bWSG.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-C-AuTczP.js","assets/vendor-use-callback-ref-CJB0R85I.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-E2vgV9K3.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-DSzLbZiS.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-BUlYhQ3o.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-BS2SpSAZ.js","assets/vendor-codemirror-lang-json-CqayksDf.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-Ba8JZ6fp.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-DK27qQri.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-CvO36Y1p.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-Dp_Z-0GD.js","assets/vendor-codemirror-lang-python-_2bIYTiJ.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-RrgJ8H_6.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tanstack-react-virtual-IrbCBGJ4.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-DJASDzNt.js","assets/vendor-motion-dom-DJLgZh4Q.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/ToolOutputDialog-2zKUdGYL.js","assets/JsonTreeView-CoX1ZscV.js","assets/web-components-Cct1r-wn.js","assets/computeVirtualFileMetrics-DdOCbMyK.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/Virtualizer-BxW2CJGB.js","assets/isFilePlainText-D4hgTRxT.js","assets/PatchDiff-D6Gs7K5B.js","assets/VirtualizedFileDiff-UMgLcO4Q.js","assets/isDiffPlainText-CGIf0q8p.js","assets/vendor-diff-C3JhlQdm.js","assets/appThemeRegistry-BK0dHKa6.js","assets/ToolPartDiffPreview-CBFC9min.js"])))=>i.map(i=>d[i]);
2
+ import{as as s3,at as u9,au as i1,av as U2,aw as o3,a as We,U as Je,d as yt,w as Wn,ax as Jp,m as w1,R as Bi,r as V1,ay as r3,ao as f9,T as Nn,e as Ti,q as i3,az as po,aA as Xp,aB as Qp,aC as eg,aD as tg,aE as ng,aF as sg,aG as og,aH as rg,aI as ig,aJ as ag,aK as lc,aL as lg,aM as cg,aN as dg,aO as ug,aP as fg,aQ as hg,aR as mg,aS as pg,aT as gg,aU as yg,aV as vg,aW as bg,aX as xg,aY as wg,aZ as Mg,a_ as Cg,J as S1,a$ as a3,E as tt,ap as Sg,b0 as _g,Q as kg,b1 as cc,b2 as Ag,b3 as Hg,b4 as Lg,L as jg,b5 as Ig,b6 as L2,aq as Vo,ar as T0,am as T2,u as he,b7 as Fl,al as h9,b8 as dc,P as wr,b9 as La,s as Hs,ba as Bg,bb as Tg,bc as Vg,bd as Ng,h as Pg,be as Eg,bf as uc,a3 as m9,bg as Ur,a4 as j2,bh as p9,bi as zg,bj as Dg,bk as fc,bl as hc,bm as No,bn as $l,bo as Rg,bp as Po,i as Ot,o as Og,C as Zg,A as Fg,B as $g,bq as go,br as qg,a1 as E0,bs as Ug,bt as Gg,bu as Mr,a2 as Wg,a0 as Kg,bv as Yg,bw as Jg,bx as Xg,by as g9,bz as Qg,H as tn,I as ey,K as y9,bA as mc,bB as ty,bC as ql,ab as Ul,bD as ny,ac as sy,bE as oy,bF as ry,bG as iy}from"./index-BAqpUCjs.js";import{c as W1,p as yo,d as $0,u as pc}from"./vendor-zustand-CnsBKjP5.js";import{r as ae,R as d,j as i,b as V0}from"./vendor-react-DYyjh7Q0.js";import{W as ay,s as ly,a as cy,b as dy,c as uy}from"./vendor-simplewebauthn-browser-VDA66rT_.js";import{_ as V2}from"./vendor-vite-runtime-DD1OZmLC.js";import{m as fy,n as hy,D as my,g as py,j as gy,h as yy,i as vy,e as by,f as xy,o as wy,T as My,p as Cy,q as Sy,r as _y,s as ky,t as Ay,u as Hy,v as Ly,w as jy,M as Iy,b as By,c as Ty,d as l3,S as Vy,x as Ny,y as Py,z as Ey,P as v9,A as b9,B as x9,E as w9,F as M9,G as zy,H as Dy,I as Ry,J as Oy,K as Zy,L as Fy,N as $y,O as qy,Q as Uy,R as Gy,U as Wy,V as Ky}from"./vendor-base-ui-DL8r2fgQ.js";import{i as D2}from"./runtimeSurface-CkHYYg0E.js";import{c as Gr,d as Pn,T as C9,M as c3,D as Wr,e as Kr,P as Yy,h as Jy,a as Xy}from"./vendor-dnd-kit-core-GipZW2tY.js";import{S as Yr,v as Gl,u as Vi,a as S9,r as Qy}from"./vendor-dnd-kit-sortable-Ct2QxIHb.js";import{C as Ni}from"./vendor-dnd-kit-utilities-CrOcp0Bp.js";import{_ as q0}from"./vendor-cmdk-BCEUzcHE.js";import{S as ev,x as tv,H as nv,o as _9,m as sv}from"./vendor-codemirror-language-E2vgV9K3.js";import{a as Ee,h as ov,t as rv}from"./vendor-lezer-highlight-CDMHUZ74.js";import{javascript as Mn}from"./vendor-codemirror-lang-javascript-BUlYhQ3o.js";import{json as k9}from"./vendor-codemirror-lang-json-CqayksDf.js";import{css as A9}from"./vendor-codemirror-lang-css-Ba8JZ6fp.js";import{html as Wl}from"./vendor-codemirror-lang-html-DK27qQri.js";import{markdown as H9}from"./vendor-codemirror-lang-markdown-CvO36Y1p.js";import{l as L9}from"./vendor-codemirror-language-data-Dp_Z-0GD.js";import{python as j9}from"./vendor-codemirror-lang-python-_2bIYTiJ.js";import{h as iv,s as av,j as lv}from"./vendor-codemirror-commands-RrgJ8H_6.js";import{S as cv,i as I9,k as dv,E as uv,P as fv,o as B9}from"./vendor-codemirror-state-CNWM3Q8V.js";import{E as $2,D as hv,d as mv,k as gc,p as yc}from"./vendor-codemirror-view-DSzLbZiS.js";import{c as T9}from"./vendor-class-variance-authority-5VPnzWs2.js";import{u as V9}from"./vendor-tanstack-react-virtual-IrbCBGJ4.js";import{m as Eo,a as vc}from"./vendor-framer-motion-DJASDzNt.js";import{e as pv}from"./vendor-tanstack-virtual-core-Dubg10g5.js";import{toast as as,Toaster as gv}from"./vendor-sonner-CW8w438f.js";import{c as yv}from"./vendor-clsx-B-dksMZM.js";import{t as vv}from"./vendor-tailwind-merge-CPcsbTWB.js";import{F as N9}from"./vendor-fuse.js-Dw8P0qyA.js";const bv=24;class A0{constructor(t,n,s){this.parent=t,this.overlay=n,this.depth=s}static empty(){return new A0(null,new Map,0)}static from(t){return new A0(null,new Map(t),0)}get(t){return this.overlay.has(t)?this.overlay.get(t):this.parent?.get(t)}has(t){return this.overlay.has(t)?!0:this.parent?.has(t)??!1}set(t,n){return this.overlay.set(t,n),this}fork(){return this.depth>=bv?this.compact().fork():new A0(this,new Map,this.depth+1)}compact(){if(!this.parent)return this;const t=new Map;return this.collect(t),new A0(null,t,0)}get size(){return this.parent?[...this.entries()].length:this.overlay.size}*entries(){const t=new Set;yield*this.walk(t)}*values(){for(const[,t]of this.entries())yield t}*keys(){for(const[t]of this.entries())yield t}[Symbol.iterator](){return this.entries()}*walk(t){for(const[n,s]of this.overlay)t.has(n)||(t.add(n),yield[n,s]);this.parent&&(yield*this.parent.walk(t))}collect(t){this.parent?.collect(t);for(const[n,s]of this.overlay)t.set(n,s)}}const xv=256,P9=(e,t)=>{if(!t)return e;if(!e)return t;if(t===e)return e;if(t.startsWith(e))return t;if(e.startsWith(t))return e;const n=Math.min(xv,e.length,t.length);for(let s=n;s>0;s-=1)if(e.endsWith(t.slice(0,s)))return e+t.slice(s);return e+t},Zt=["off","minimal","low","medium","high","xhigh","max"],wv={off:"Off",minimal:"Minimal",low:"Low",medium:"Medium",high:"High",xhigh:"Extra high",max:"Max"},c2=e=>e==="off"||e==="minimal"||e==="low"||e==="medium"||e==="high"||e==="xhigh"||e==="max",nt=e=>c2(e)?e:null,Mv=(e,t)=>{const n=e.filter(c2),s=n.length>0?n:["off"];if(t&&s.includes(t))return t;const o=Zt.indexOf(t);if(o===-1)return s[0];for(let r=o+1;r<Zt.length;r+=1)if(s.includes(Zt[r]))return Zt[r];for(let r=o-1;r>=0;r-=1)if(s.includes(Zt[r]))return Zt[r];return s[0]},d3=e=>{if(Array.isArray(e?.thinkingLevels)&&e.thinkingLevels.length>0){const t=e.thinkingLevels,n=Zt.filter(s=>t.includes(s));return n.length>0?n:["off"]}return e?.reasoning===!0||e?.supportsThinking===!0?Zt.filter(t=>t!=="xhigh"&&t!=="max"):["off"]},Pi=e=>e.some(t=>t!=="off"&&c2(t)),E9=e=>{const t=d3(e);return Pi(t)?t:[]},s0=e=>e?c2(e)?wv[e]:`${e.charAt(0).toUpperCase()}${e.slice(1)}`:"Default",Cv=(e,t)=>t<=1||!Number.isFinite(e)?0:Math.min(t-1,Math.max(0,Math.round(e*(t-1)))),u3=(e,t,n)=>{const s=e.filter(c2);if(!Pi(s))return;const o=[void 0,...s],r=c2(t)&&s.includes(t)?t:void 0,a=o.indexOf(r);return o[(a+n+o.length)%o.length]},z9=e=>{if(!e)return;const t=e.providerId.trim(),n=e.modelId.trim();if(!(!t||!n))return`${t}/${n}`},D9=(e,t)=>{if(!(!t||!e))return nt(e[t])??void 0},Sv=e=>{if(e.thinking)return e.thinking;const t=z9(e.model);return D9(e.defaultThinkingByModel,t)??nt(e.defaultThinking)??void 0},zo=e=>{const t=d3(e);if(!Pi(t))return;const n=z9({providerId:e.providerId,modelId:e.modelId}),s=D9(e.defaultThinkingByModel,n)??(c2(e.previousThinking)?e.previousThinking:void 0)??nt(e.defaultThinking)??void 0;if(s)return Mv(t,s)},bc=e=>{if(!e)return;const t=e.providerId.trim(),n=e.modelId.trim();if(!(!t||!n))return{providerId:t,modelId:n}},_v=e=>{let t;if(e.messages)for(const o of e.messages){if(o.role!=="assistant")continue;const r=bc(o.model),a=nt(o.thinkingLevel)??void 0;if(!r&&!a)continue;const l=typeof o.createdAt=="number"&&Number.isFinite(o.createdAt)?o.createdAt:0;(!t||l>=t.createdAt)&&(t={createdAt:l,...r?{model:r}:{},...a?{thinkingLevel:a}:{}})}const n=t?.model??bc(e.model),s=t?.thinkingLevel??nt(e.thinking)??void 0;return{...n?{model:n}:{},...s?{thinking:s}:{}}},Kl=e=>e?A0.from(e):A0.empty(),R9=()=>({bySession:new Map,lastSequence:new Map}),O9=()=>Kl(),v0=(e,t,n)=>{t&&(e.lastMutatedMessageId=e.messages.get(t)?.id??t,e.lastMutationKind=n)},nn=e=>{e.parts=e.parts.fork()},kv=(e,t,n)=>{const s=e.bySession.get(t);if(s)return s;const o={sessionId:t,directory:n,lastSequence:-1,lifecycle:"idle",messages:new Map,partOrder:new Map,parts:O9(),toolsByCallId:new Map,streamingMessages:new Set,queue:{steering:0,followUp:0}};return e.bySession.set(t,o),o},Ei=(e,t)=>e.startsWith(`user-${t}-`),Av=250,xc=new WeakMap,wc=new WeakMap,vo=e=>{const t=xc.get(e.messages);if(t&&t.size===e.messages.size)return t.list;const n=new Set,s=[];for(const o of e.messages.values())n.has(o.id)||(n.add(o.id),s.push(o));for(let o=1;o<s.length;o+=1){const r=s[o-1],a=s[o];if(!(!r||!a||a.createdAt>=r.createdAt)){s.sort((l,c)=>l.createdAt-c.createdAt);break}}return xc.set(e.messages,{size:e.messages.size,list:s}),s},Z9=(e,t,n)=>{if(!t)return;let s,o=Number.POSITIVE_INFINITY;for(const r of vo(e)){if(r.role!=="user"||r.text!==t||Ei(r.id,e.sessionId))continue;const a=Math.abs(r.createdAt-n);a<=Av&&a<o&&(s=r,o=a)}return s},Hv=(e,t,n)=>{if(n.role==="user"&&Ei(t,e.sessionId)){const s=Z9(e,n.text,n.createdAt);if(s){e.messages.set(t,s);return}}e.messages.set(t,n)},zi=(e,t)=>{if(!t)return;const n=e.messages.get(t)?.id;if(n)return n;if(Ei(t,e.sessionId)){const s=vo(e);for(let o=s.length-1;o>=0;o-=1){const r=s[o];if(r?.role==="user")return r.id}}return t},Lv=(e,t,n)=>{const s=e.messages.get(t.messageId);if(s)return s;if(t.role==="user"&&Ei(t.messageId,e.sessionId)){const a=Z9(e,t.text??"",t.startedAt);if(a)return e.messages.set(t.messageId,a),a}const o=zi(e,t.parentId),r={id:t.messageId,sessionId:e.sessionId,directory:n,role:t.role,...o?{parentId:o}:{},createdAt:t.startedAt,text:t.role==="user"?t.text??"":"",thinking:"",streaming:t.role==="assistant",...t.model?{model:t.model}:{},...t.thinkingLevel?{thinkingLevel:t.thinkingLevel}:{}};return e.messages.set(t.messageId,r),r},F9=(e,t,n,s)=>{const o=s??`${t.id}:${n}`,r=e.parts.get(o);if(r)return r;const a={id:o,index:(e.partOrder.get(t.id)??[]).length,type:n,text:"",streaming:!0};e.parts.set(o,a);const l=[...e.partOrder.get(t.id)??[]];return l.includes(a.id)||l.push(a.id),e.partOrder.set(t.id,l),a},jv=(e,t)=>{if(!e.messages.get(t))return{text:"",thinking:""};const s=e.partOrder.get(t)??[];let o="",r="";for(const a of s){const l=e.parts.get(a);l&&(l.type==="text"?o+=l.text:l.type==="thinking"&&(r+=l.text))}return{text:o,thinking:r}},Mc=(e,t,n,s)=>{const r=(e.partOrder.get(t)??[]).map(c=>e.parts.get(c)).filter(c=>c?.type===n);if(r.length===0){if(!s)return;const c=e.messages.get(t);if(!c)return;const u=F9(e,c,n);e.parts.set(u.id,{...u,text:s,streaming:!1});return}const[a,...l]=r;if(a){e.parts.set(a.id,{...a,text:s,streaming:!1});for(const c of l)e.parts.set(c.id,{...c,text:"",streaming:!1})}},Iv=(e,t)=>{if(t.state==="retry"){e.lifecycle="retry",e.retry={...t.attempt!==void 0?{attempt:t.attempt}:{},...t.next!==void 0?{next:t.next}:{},...t.message!==void 0?{message:t.message}:{}};return}if(t.state==="busy"&&e.retry){e.lifecycle="retry";return}if(e.lifecycle=t.state,e.retry=void 0,t.state!=="busy"){e.streamingMessages=new Set,e.messages=new Map(e.messages);for(const[n,s]of e.messages)s.streaming&&e.messages.set(n,{...s,streaming:!1})}},Bv=(e,t,n)=>{Lv(e,n,t)},f3=(e,t)=>{const n=e.messages.get(t);if(n&&n.role==="assistant")return n;const s=vo(e);for(let r=s.length-1;r>=0;r-=1){const a=s[r];if(a.role==="assistant"&&(a.streaming||a.durationMs===void 0))return e.messages.set(t,a),!e.partOrder.has(t)&&e.partOrder.has(a.id)&&e.partOrder.set(t,e.partOrder.get(a.id)),a}const o=s[s.length-1];if(o&&o.role==="assistant")return e.messages.set(t,o),!e.partOrder.has(t)&&e.partOrder.has(o.id)&&e.partOrder.set(t,e.partOrder.get(o.id)),o},Tv=(e,t,n)=>{const s=new Set(e.partOrder.get(t)??[]);if(s.size!==0)for(const[o,r]of e.parts)!r.streaming||!n(r)||!s.has(r.id)&&!s.has(o)||e.parts.set(o,{...r,streaming:!1})},$9=(e,t)=>{Tv(e,t,n=>n.type==="thinking")},Cc=(e,t,n)=>{const s=f3(e,t.messageId);if(!s)return!1;s.streaming=!0,e.streamingMessages.add(s.id),e.streamingMessages.add(t.messageId),n==="text"&&$9(e,s.id);const o=t.partId??`${s.id}:${n}`;let r=e.parts.get(o);if(!r){const l=t.contentIndex;if(typeof l=="number"){const c=[`${s.id}:${n}:${l}`,`${s.id}:${l}`,`${s.id}:${n}`];for(const u of c){const f=e.parts.get(u);if(f&&f.type===n){r=f;break}}if(!r){const u=e.partOrder.get(s.id)??[];for(const f of u){const h=e.parts.get(f);if(h&&h.type===n&&h.index===l){r=h;break}}}}}if(r){if(r.type!==n)return!1;const l={...r,text:P9(r.text,t.delta),streaming:!0};return e.parts.set(r.id,l),o!==r.id&&e.parts.set(o,l),!0}const a=F9(e,s,n,o);return e.parts.set(a.id,{...a,text:t.delta,streaming:!0}),!0},Vv=(e,t)=>{const n=f3(e,t.messageId);if(!n)return;const{text:s,thinking:o}=jv(e,n.id);n.text=typeof t.text=="string"?t.text:s,n.thinking=typeof t.thinking=="string"?t.thinking:o,Mc(e,n.id,"text",n.text),Mc(e,n.id,"thinking",n.thinking),n.streaming=!1,typeof t.durationMs=="number"?n.durationMs=t.durationMs:typeof n.createdAt=="number"&&n.createdAt>0&&(n.durationMs=Math.max(100,Date.now()-n.createdAt)),t.thinkingLevel&&(n.thinkingLevel=t.thinkingLevel),t.error&&(n.error=t.error),t.usage&&(n.usage=t.usage),t.continuing!==!0&&!t.error&&(e.streamingMessages.delete(n.id),e.streamingMessages.delete(t.messageId))},ja=(e,t,n)=>{const s=e.toolsByCallId.get(n.toolCallId)??n.messageId,o=f3(e,s);if(!o)return!1;$9(e,o.id),t!=="end"&&(o.streaming=!0,e.streamingMessages.add(o.id));const r=e.parts.get(n.partId)??Array.from(e.parts.values()).find(c=>c.type==="tool"&&c.tool?.toolCallId===n.toolCallId);if(t==="start"&&!r){const c={id:n.partId,index:(e.partOrder.get(o.id)??[]).length,type:"tool",text:"",streaming:!1,tool:{toolCallId:n.toolCallId,name:n.name,...n.input!==void 0?{input:n.input}:{},state:n.state,...n.startedAt!==void 0?{startedAt:n.startedAt}:{}}};e.parts.set(c.id,c);const u=[...e.partOrder.get(o.id)??[]];return u.push(c.id),e.partOrder.set(o.id,u),e.toolsByCallId.set(n.toolCallId,o.id),!0}if(!r||r.type!=="tool")return!1;const a={...r},l=r.tool;return a.tool={toolCallId:n.toolCallId,name:n.name,...n.input!==void 0?{input:n.input}:l?.input!==void 0?{input:l.input}:{},...n.output!==void 0?{output:n.output}:l?.output!==void 0?{output:l.output}:{},...n.error!==void 0?{error:n.error}:l?.error!==void 0?{error:l.error}:{},...n.metadata!==void 0?{metadata:n.metadata}:l?.metadata!==void 0?{metadata:l.metadata}:{},...n.isError!==void 0?{isError:n.isError}:l?.isError!==void 0?{isError:l.isError}:{},state:n.state,...n.startedAt!==void 0?{startedAt:n.startedAt}:l?.startedAt!==void 0?{startedAt:l.startedAt}:{},...n.endedAt!==void 0?{endedAt:n.endedAt}:l?.endedAt!==void 0?{endedAt:l.endedAt}:{}},t==="end"&&(a.streaming=!1),e.parts.set(a.id,a),!0},Nv=(e,t)=>{if(e.lifecycle="interrupted",e.retry=void 0,!!t){for(const n of e.streamingMessages){const s=e.messages.get(n);s&&(s.streaming=!1,s.error={code:"SESSION_INTERRUPTED"})}e.streamingMessages.clear()}},Pv=(e,t,n)=>{e.lifecycle="error",e.retry=void 0;const s=Date.now();e.parts=e.parts.fork(),e.partOrder=new Map(e.partOrder);for(const o of e.streamingMessages){const r=e.messages.get(o);if(r){r.streaming=!1,r.error={code:t,...n?{message:n}:{}},r.durationMs===void 0&&r.createdAt>0&&(r.durationMs=Math.max(100,s-r.createdAt));for(const a of e.partOrder.get(o)??[]){const l=e.parts.get(a);if(!l)continue;const c=l.tool?.state==="running"||l.tool?.state==="pending";if(!l.streaming&&!c)continue;const u={...l,streaming:!1};c&&u.tool&&(u.tool={...u.tool,state:"error",...n?{error:n}:{},endedAt:u.tool.endedAt??s}),e.parts.set(a,u)}}}e.streamingMessages.clear()},Sc=(e,t)=>{const n=e.lastSequence.get(t.sessionId)??-1;if(t.sequence<=n)return{state:e,didApply:!1};const s=e.bySession.get(t.sessionId),o=s?{...s,lastSequence:t.sequence,...t.name==="session.lifecycle"?{lifecycle:t.payload.state}:{},...t.name==="session.queue"?{queue:{...t.payload}}:{},...t.name==="session.model"?{model:t.payload.model}:{},...t.name==="session.thinking"?{thinking:t.payload.thinking}:{}}:{sessionId:t.sessionId,directory:t.directory,lastSequence:t.sequence,lifecycle:"idle",messages:new Map,partOrder:new Map,parts:O9(),toolsByCallId:new Map,streamingMessages:new Set,queue:{steering:0,followUp:0}};switch(t.name){case"session.snapshot":t.payload?.snapshot&&(o.lifecycle=t.payload.snapshot.lifecycle??(t.payload.snapshot.isStreaming?"busy":"idle"),o.retry=o.lifecycle==="retry"?t.payload.snapshot.retry:void 0,t.payload.snapshot.model&&(o.model=t.payload.snapshot.model),t.payload.snapshot.thinking&&(o.thinking=t.payload.snapshot.thinking),t.payload.snapshot.queue&&(o.queue={...t.payload.snapshot.queue}),U9(o,{isStreaming:t.payload.snapshot.isStreaming,lifecycle:o.lifecycle,...t.payload.snapshot.retry?{retry:t.payload.snapshot.retry}:{},settleWhenIdle:!0}));break;case"session.lifecycle":Iv(o,t.payload);break;case"assistant.message.start":o.lifecycle=o.retry?"retry":"busy",o.messages=new Map(o.messages),o.streamingMessages=new Set(o.streamingMessages),Bv(o,t.directory,t.payload),t.payload.role==="assistant"&&o.streamingMessages.add(t.payload.messageId),v0(o,t.payload.messageId,"structure");break;case"assistant.message.delta":nn(o),Cc(o,t.payload,"text")&&(o.lifecycle="busy",o.retry=void 0),v0(o,t.payload.messageId,"part");break;case"assistant.message.end":o.messages=new Map(o.messages),nn(o),o.partOrder=new Map(o.partOrder),o.streamingMessages=new Set(o.streamingMessages),Vv(o,t.payload),v0(o,t.payload.messageId,"structure");break;case"assistant.thinking.delta":nn(o),Cc(o,t.payload,"thinking")&&(o.lifecycle="busy",o.retry=void 0),v0(o,t.payload.messageId,"part");break;case"session.tool.start":nn(o),o.partOrder=new Map(o.partOrder),o.toolsByCallId=new Map(o.toolsByCallId),ja(o,"start",t.payload)&&(o.lifecycle="busy",o.retry=void 0),v0(o,t.payload.messageId,"part");break;case"session.tool.update":nn(o),ja(o,"update",t.payload)&&(o.lifecycle="busy",o.retry=void 0),v0(o,t.payload.messageId,"part");break;case"session.tool.end":nn(o),ja(o,"end",t.payload)&&(o.lifecycle="busy",o.retry=void 0),v0(o,t.payload.messageId,"part");break;case"session.queue":o.queue={steering:t.payload.steering,followUp:t.payload.followUp};break;case"session.model":o.model=t.payload.model;break;case"session.thinking":o.thinking=t.payload.thinking;break;case"session.compaction":break;case"session.updated":break;case"session.error":o.messages=new Map(o.messages),o.streamingMessages=new Set(o.streamingMessages);for(const a of o.streamingMessages){const l=o.messages.get(a);l&&o.messages.set(a,{...l})}Pv(o,t.payload.code,t.payload.message);break;case"session.interrupted":o.messages=new Map(o.messages),o.streamingMessages=new Set(o.streamingMessages);for(const a of o.streamingMessages){const l=o.messages.get(a);l&&o.messages.set(a,{...l})}Nv(o,t.payload.streaming);break}const r={bySession:new Map(e.bySession),lastSequence:new Map(e.lastSequence)};return r.bySession.set(t.sessionId,o),r.lastSequence.set(t.sessionId,t.sequence),{state:r,didApply:!0,sessionId:t.sessionId}},Ev=e=>{const t=wc.get(e);if(t)return t;const n={id:e.id,type:e.type,text:e.text,streaming:e.streaming,...e.tool?{tool:e.tool}:{},...e.attachment?{attachment:e.attachment}:{}};return wc.set(e,n),n},zv=(e,t)=>{const n=new Set,s=new Set;for(let o=t.length-1;o>=0;o-=1){const r=t[o];if(!r||r.role!=="assistant")continue;const a=zi(e,r.parentId);if(!a)continue;const l=!!(r.text||r.thinking||(e.partOrder.get(r.id)?.length??0)>0);if(r.error&&!l&&n.has(a)){s.add(r.id);continue}r.error||n.add(a)}return s},Dv=(e,t,n,s)=>n.id===t.id&&n.role===t.role&&n.parentId===zi(e,t.parentId)&&n.text===t.text&&n.thinking===t.thinking&&n.streaming===t.streaming&&n.createdAt===t.createdAt&&n.durationMs===t.durationMs&&n.error===t.error&&n.model===t.model&&n.thinkingLevel===t.thinkingLevel&&n.usage===t.usage&&n.parts.length===s.length&&n.parts.every((o,r)=>o===s[r]),Rv=(e,t,n)=>{const s=e.partOrder.get(t.id)??[],o=[];for(const a of s){const l=e.parts.get(a);l&&o.push(Ev(l))}if(n&&Dv(e,t,n,o))return n;const r=zi(e,t.parentId);return{id:t.id,role:t.role,...r?{parentId:r}:{},text:t.text,thinking:t.thinking,streaming:t.streaming,createdAt:t.createdAt,...t.durationMs!==void 0?{durationMs:t.durationMs}:{},...t.error?{error:t.error}:{},...t.model?{model:t.model}:{},...t.thinkingLevel?{thinkingLevel:t.thinkingLevel}:{},...t.usage?{usage:t.usage}:{},parts:o}},q9=(e,t)=>{const n=vo(e),s=zv(e,n),o=t?new Map(t.projection.messages.map(a=>[a.id,a])):null,r=[];for(const a of n)s.has(a.id)||r.push(Rv(e,a,o?.get(a.id)));return t&&t.projection.sessionId===e.sessionId&&t.projection.directory===e.directory&&t.projection.lifecycle===e.lifecycle&&t.projection.model===e.model&&t.projection.thinking===e.thinking&&t.projection.queue.steering===e.queue.steering&&t.projection.queue.followUp===e.queue.followUp&&t.projection.messages.length===r.length&&t.projection.messages.every((a,l)=>a===r[l])?t.projection:{sessionId:e.sessionId,directory:e.directory,lifecycle:e.lifecycle,...e.model?{model:e.model}:{},...e.thinking?{thinking:e.thinking}:{},queue:{...e.queue},messages:r}},U9=(e,t)=>{const n=[],s=[];for(const[l,c]of e.parts){const u=c.tool?.state;if(c.type!=="tool"||u!=="running"&&u!=="pending")continue;s.push(l);const f=c.tool?.toolCallId?e.toolsByCallId.get(c.tool.toolCallId):void 0;f&&n.push(f)}if(!(t?.isStreaming===!0||t?.lifecycle==="busy"||t?.lifecycle==="retry"||t?.inferFromRunningTools===!0&&n.length>0)){if(e.retry=void 0,t?.settleWhenIdle){e.streamingMessages=new Set,e.messages=new Map(e.messages);for(const[l,c]of e.messages)c.streaming&&e.messages.set(l,{...c,streaming:!1})}return}e.lifecycle=t?.lifecycle==="retry"?"retry":"busy",e.retry=e.lifecycle==="retry"?t?.retry:void 0,e.streamingMessages=new Set(e.streamingMessages);for(const l of s){const c=e.parts.get(l);c&&e.parts.set(l,{...c,streaming:!0})}let r=n[n.length-1];if(!r){const l=vo(e);for(let c=l.length-1;c>=0;c-=1){const u=l[c];if(u?.role==="assistant"){r=u.id;break}}}if(!r)return;const a=e.messages.get(r);!a||a.role!=="assistant"||(e.messages.set(r,{...a,streaming:!0}),e.streamingMessages.add(r))},h3=e=>{const t=R9(),n=kv(t,e.session.id,e.session.directory);n.lastSequence=e.lastSequence;for(const{message:o,parts:r}of e.messages){const a={id:o.id,sessionId:e.session.id,directory:e.session.directory,role:o.role,...o.parentId?{parentId:o.parentId}:{},createdAt:o.createdAt,text:o.text??"",thinking:o.role==="assistant"?o.thinking??"":"",streaming:!1,...o.role==="assistant"&&o.durationMs!==void 0?{durationMs:o.durationMs}:{},...o.role==="assistant"&&o.error?{error:o.error}:{},...o.role==="assistant"&&o.model?{model:o.model}:{},...o.role==="assistant"&&o.thinkingLevel?{thinkingLevel:o.thinkingLevel}:{},...o.role==="assistant"&&o.usage?{usage:o.usage}:{}};n.messages.set(o.id,a);const l=[];for(const c of r){const u={id:c.id,index:c.index,type:c.type,text:c.text??"",streaming:!1,...c.type==="tool"?{tool:{toolCallId:c.toolCallId??c.id,name:c.name??"unknown",...c.input!==void 0?{input:c.input}:{},...c.output!==void 0?{output:c.output}:{},...typeof c.error=="string"?{error:c.error}:{},...c.metadata!==void 0?{metadata:c.metadata}:{},...c.isError!==void 0?{isError:c.isError}:{},state:c.state??"completed",...c.startedAt!==void 0?{startedAt:c.startedAt}:{},...c.endedAt!==void 0?{endedAt:c.endedAt}:{}}}:{},...c.type==="attachment"&&c.attachment?{attachment:c.attachment}:{}};n.parts.set(c.id,u),l.push(c.id),c.type==="tool"&&c.toolCallId&&n.toolsByCallId.set(c.toolCallId,o.id)}n.partOrder.set(o.id,l)}const s=_v({model:e.session.model,thinking:e.session.thinking,messages:n.messages.values()});return s.model&&(n.model=s.model),s.thinking&&(n.thinking=s.thinking),U9(n,{...e.isStreaming!==void 0?{isStreaming:e.isStreaming}:{},...e.lifecycle?{lifecycle:e.lifecycle}:{},...e.retry?{retry:e.retry}:{},inferFromRunningTools:!0}),t.lastSequence.set(e.session.id,e.lastSequence),{state:t,session:n}},Ov={fetchHealth:u9,createStream:s3},Ia=e=>e instanceof U2?{code:e.code,...e.message?{message:e.message}:{},...e.status!==void 0?{status:e.status}:{}}:e instanceof Error?{code:"DAEMON_REQUEST_FAILED",message:e.message}:{code:"DAEMON_REQUEST_FAILED"},Zv=async(e,t=Ov)=>{const n={phase:"idle",reducerState:{bySession:new Map,lastSequence:new Map},lastSequence:new Map,stream:null,errors:[],health:{state:"pending"}},s=async l=>e.retry?e.retry(l):l();n.phase="runtime-probe";const o=e.initialHealth??await s(()=>t.fetchHealth(e.signal,e.runtimeKey));if(o.state==="ready")n.health={state:"ready",protocolVersion:o.protocolVersion,capabilities:[...o.capabilities]};else return n.health={state:"unavailable",protocolVersion:o.protocolVersion,error:{code:o.error?.code??"DAEMON_UNAVAILABLE",...o.error?.message?{message:o.error.message}:{}}},n.phase="failed",n.errors.push({phase:"runtime-probe",error:n.health.error}),n;n.phase="session-list";const r=l=>{for(const c of l)n.lastSequence.set(c.session.id,-1)};if(e.initialSessions)r(e.initialSessions);else try{const l=await s(()=>i1.listSessions({...e.scope,directory:e.directory,...e.runtimeKey?{runtimeKey:e.runtimeKey}:{}}));r(l.sessions)}catch(l){n.errors.push({phase:"session-list",error:Ia(l)})}if(e.selectedSessionId){n.phase="session-hydrate";try{const l=await s(()=>i1.getSession(e.selectedSessionId,{...e.scope,directory:e.directory,...e.runtimeKey?{runtimeKey:e.runtimeKey}:{}})),{state:c}=h3({session:l.session,lastSequence:l.lastSequence,...l.isStreaming!==void 0?{isStreaming:l.isStreaming}:{},...l.lifecycle?{lifecycle:l.lifecycle}:{},messages:l.messages.map(u=>({message:u.message,parts:u.parts.map(f=>({id:f.id,index:f.index,type:f.type,text:f.type==="text"||f.type==="thinking"?f.text:void 0,...f.type==="tool"?{toolCallId:f.toolCallId,name:f.name,...f.input!==void 0?{input:f.input}:{},...f.output!==void 0?{output:f.output}:{},...f.isError!==void 0?{isError:f.isError}:{},state:f.state,...f.startedAt!==void 0?{startedAt:f.startedAt}:{},...f.endedAt!==void 0?{endedAt:f.endedAt}:{}}:{},...f.type==="attachment"?{attachment:f.attachment}:{}}))}))});n.reducerState=c,n.lastSequence.set(l.session.id,l.lastSequence)}catch(l){n.errors.push({phase:"session-hydrate",error:Ia(l)})}}n.phase="stream-attach";try{const l=e.selectedSessionId?n.lastSequence.get(e.selectedSessionId):e.fromSequence,c=t.createStream({onEvent:e.onEvent,onDisconnect:u=>e.onStreamDisconnect?.(u),onReconnect:()=>e.onStreamReconnect?.(),onTransportSwitch:()=>e.onTransportSwitch?.()},{...typeof l=="number"&&l>=0?{fromSequence:l}:{},...e.runtimeKey?{runtimeKey:e.runtimeKey}:{},signal:e.signal});n.stream=c}catch(l){n.errors.push({phase:"stream-attach",error:Ia(l)})}const a=n.errors.some(l=>l.phase==="runtime-probe");return n.phase=a?"failed":"ready",n},Fv=e=>({sessionId:e.sessionId,directory:e.directory,isStreaming:e.isStreaming,lastSequence:e.lastSequence,queue:e.queue??{steering:0,followUp:0},...e.model?{model:e.model}:{},...e.thinking?{thinking:e.thinking}:{},...e.lastText?{lastText:e.lastText}:{},...e.lastThinking?{lastThinking:e.lastThinking}:{},...e.lastToolPart?{lastToolPart:e.lastToolPart}:{},lifecycle:e.lifecycle}),$v=()=>({bySession:new Map,lastSequence:new Map}),qv=(e,t)=>{const n=e.lastSequence.get(t.sessionId)??-1;if(t.lastSequence<=n)return{state:e,didUpdate:!1};const s={bySession:new Map(e.bySession),lastSequence:new Map(e.lastSequence)};return s.bySession.set(t.sessionId,Fv(t)),s.lastSequence.set(t.sessionId,t.lastSequence),{state:s,didUpdate:!0}},Uv={fetchHealth:u9,createStream:s3},_c=e=>e instanceof U2?{code:e.code,...e.message?{message:e.message}:{},...e.status!==void 0?{status:e.status}:{}}:e instanceof Error?{code:"DAEMON_REQUEST_FAILED",message:e.message}:{code:"DAEMON_REQUEST_FAILED"},Gv=async(e,t=Uv)=>{const n={phase:"idle",snapshotState:$v(),reducerState:{bySession:new Map,lastSequence:new Map},stream:null,lastSequence:e.lastKnownSequence??-1},s=async r=>e.retry?e.retry(r):r();n.phase="health-check";const o=await s(()=>t.fetchHealth(e.signal,e.runtimeKey));if(o.state!=="ready")return n.phase="unavailable",n.error={code:o.error?.code??"DAEMON_UNAVAILABLE",...o.error?.message?{message:o.error.message}:{}},n;n.phase="snapshot-fetch";try{const r=await s(()=>i1.getSession(e.sessionId,{directory:e.directory,...e.runtimeKey?{runtimeKey:e.runtimeKey}:{}})),a=h3({session:r.session,lastSequence:r.lastSequence,...r.isStreaming!==void 0?{isStreaming:r.isStreaming}:{},...r.lifecycle?{lifecycle:r.lifecycle}:{},messages:r.messages.map(u=>({message:u.message,parts:u.parts.map(f=>({id:f.id,index:f.index,type:f.type,text:f.type==="text"||f.type==="thinking"?f.text:void 0,...f.type==="tool"?{toolCallId:f.toolCallId,name:f.name,...f.input!==void 0?{input:f.input}:{},...f.output!==void 0?{output:f.output}:{},...f.isError!==void 0?{isError:f.isError}:{},state:f.state,...f.startedAt!==void 0?{startedAt:f.startedAt}:{},...f.endedAt!==void 0?{endedAt:f.endedAt}:{}}:{},...f.type==="attachment"?{attachment:f.attachment}:{}}))}))});n.reducerState=a.state;const l={protocolVersion:1,kind:"event",name:"session.snapshot",sequence:r.lastSequence,sessionId:r.session.id,directory:r.session.directory,payload:{snapshot:{sessionId:r.session.id,directory:r.session.directory,lastSequence:r.lastSequence,isStreaming:r.isStreaming===!0,queue:{steering:0,followUp:0},lifecycle:r.lifecycle??(r.isStreaming?"busy":"idle"),...r.session.model?{model:r.session.model}:{},...r.session.thinking?{thinking:r.session.thinking}:{}}}},c=qv(n.snapshotState,l.payload.snapshot);n.snapshotState=c.state,n.lastSequence=Math.max(e.lastKnownSequence??-1,r.lastSequence)}catch(r){const a=_c(r);return a.code==="INVALID_SESSION",n.phase="failed",n.error=a,n}n.phase="stream-attach";try{n.stream=t.createStream({onEvent:e.onEvent,onDisconnect:r=>e.onStreamDisconnect?.(r),onReconnect:()=>e.onStreamReconnect?.(),onTransportSwitch:()=>e.onTransportSwitch?.()},{fromSequence:n.lastSequence,...e.runtimeKey?{runtimeKey:e.runtimeKey}:{},signal:e.signal})}catch(r){return n.phase="failed",n.error=_c(r),n}return n.phase="ready",n},Wv=new Set(["assistant.message.delta","assistant.thinking.delta","session.tool.update"]),Kv=e=>Wv.has(e.name),Jr=e=>e.name==="assistant.message.delta"||e.name==="assistant.thinking.delta"?e:null,Yv=(e,t)=>{const n=Jr(e),s=Jr(t);return!n||!s||n.name!==s.name||n.sessionId!==s.sessionId?!1:n.payload.messageId===s.payload.messageId&&n.payload.contentIndex===s.payload.contentIndex&&(n.payload.partId??"")===(s.payload.partId??"")},Jv=(e,t)=>{const n=Jr(e),s=Jr(t);return!n||!s||n.name!==s.name?t:{...s,payload:{...s.payload,delta:P9(n.payload.delta,s.payload.delta)}}},Ba=e=>{const t=[];for(const n of e){const s=t[t.length-1];s&&Yv(s,n)?t[t.length-1]=Jv(s,n):t.push(n)}return t};class Xv{constructor(t){this.publish=t}buffer=[];scheduled="none";generation=0;rafId=0;push(t){if(!Kv(t)){const n=this.takeBuffer();this.publish(Ba([...n,t]));return}this.buffer.push(t),this.schedule()}flush(){const t=this.takeBuffer();t.length!==0&&this.publish(Ba(t))}dispose(){this.flush()}takeBuffer(){if(this.generation+=1,this.scheduled="none",this.rafId&&typeof globalThis.cancelAnimationFrame=="function"&&globalThis.cancelAnimationFrame(this.rafId),this.rafId=0,this.buffer.length===0)return[];const t=this.buffer;return this.buffer=[],t}schedule(){if(this.scheduled!=="none")return;const t=++this.generation,n=()=>{if(t!==this.generation)return;this.scheduled="none",this.rafId=0;const s=this.buffer;this.buffer=[],s.length!==0&&this.publish(Ba(s))};if(typeof globalThis.requestAnimationFrame=="function"){this.scheduled="frame",this.rafId=globalThis.requestAnimationFrame(n);return}this.scheduled="microtask",queueMicrotask(n)}}function G9(e,t=50){if(typeof e!="string"||e.trim().length===0)return"";const s=e.replace(/```[\s\S]*?```/g," ").replace(/`[^`]+`/g," ").replace(/\[attachment:[^\]]+\]/g," ").replace(/(^|\s)@[\w.-]+/g," ").replace(/<[^>]+>/g," ").replace(/\r\n/g,`
3
3
  `).split(`
4
4
  `).map(r=>r.trim()).find(r=>r.length>0);if(!s)return"";const o=s.replace(/\s+/g," ");return o.length<=t?o:`${o.slice(0,t).trimEnd()}…`}const Qv=200,W9=1440*60*1e3,eb=3e4,tb=15e3,nb=9e4,Yl="oc.session-activity.v1",sb=new Set,ob=new Map,ot=W1(()=>({startedAt:new Map,settledMs:new Map})),z0=new Map;let m3=0,Xr=null;const rb=()=>typeof performance<"u"&&Number.isFinite(performance.timeOrigin)?performance.timeOrigin:Date.now();let p3=rb();const K9=(e,t)=>e.start<=t&&t-e.start<=W9&&e.seen<=t&&p3-e.seen<=eb,ib=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;const{start:t,seen:n}=e;return typeof t!="number"||!Number.isFinite(t)||typeof n!="number"||!Number.isFinite(n)?null:{start:t,seen:n}},ab=()=>{const e=new Map;let t=null;try{t=o3().getItem(Yl)}catch{return e}if(!t)return e;let n;try{n=JSON.parse(t)}catch{return e}if(!n||typeof n!="object"||Array.isArray(n))return e;const s=Date.now();for(const[o,r]of Object.entries(n)){const a=ib(r);a&&K9(a,s)&&e.set(o,a)}return e},Di=()=>(Xr??=ab(),Xr),lb=e=>e-p3>nb?(Xr?.clear(),ob):Di(),N0=(e,t)=>{const n={};for(const[s,o]of Di())K9(o,t)&&(n[s]=o);for(const[s,o]of e)n[s]={start:o,seen:z0.get(s)??t};m3=t;try{const s=o3();if(Object.keys(n).length===0){s.removeItem(Yl);return}s.setItem(Yl,JSON.stringify(n))}catch{}},Ta=()=>{const{startedAt:e}=ot.getState();if(e.size===0)return;const t=Date.now();for(const n of e.keys())z0.set(n,t);N0(e,t)};let kc=!1;const Y9=()=>{if(!(kc||typeof window>"u")){kc=!0;try{window.addEventListener("pagehide",Ta,{capture:!0}),typeof document<"u"&&(document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&Ta()}),document.addEventListener("freeze",Ta))}catch{}}},cb=e=>{for(;e.size>Qv;){const t=e.keys().next();if(t.done)return;e.delete(t.value)}},Ac=(e,t)=>{const n=Date.now(),s=lb(n),o=ot.getState(),r={started:null,settled:null};let a=!1,l=!1;const c=()=>r.started??=new Map(o.startedAt),u=()=>r.settled??=new Map(o.settledMs);for(const h of e)a=!0,z0.set(h,n),!(r.started??o.startedAt).has(h)&&(c().set(h,s.get(h)?.start??n),(r.settled??o.settledMs).has(h)&&u().delete(h));const f=(h,m)=>{c().delete(h),z0.delete(h),u().set(h,Math.max(0,n-m))};if(t!==null)if(t.source==="event"){Di().delete(t.sessionId)&&(l=!0);const h=o.startedAt.get(t.sessionId);h!==void 0&&f(t.sessionId,h)}else for(const[h,m]of o.startedAt)e.has(h)||t.isCovered(h)&&f(h,m);if(r.settled&&cb(r.settled),(r.started||r.settled)&&ot.setState({startedAt:r.started??o.startedAt,settledMs:r.settled??o.settledMs}),r.started){r.started.size>0&&Y9(),N0(r.started,n);return}if(l){N0(o.startedAt,n);return}a&&o.startedAt.size>0&&n-m3>=tb&&N0(o.startedAt,n)},Hc=(e,t)=>{if(t==="active"){Ac(new Set([e]),null);return}Ac(sb,{source:"event",sessionId:e})},sn=(e,t,n)=>{if(!Number.isFinite(t))return;const s=Date.now(),o=Number.isFinite(n)?n-s:0,r=t-o;if(s-r>W9||r>s+6e4)return;const a=ot.getState();if(a.startedAt.get(e)===r)return;const c=new Map(a.startedAt);c.set(e,r);const u=new Map(a.settledMs);u.delete(e),z0.set(e,s),ot.setState({startedAt:c,settledMs:u}),Y9(),N0(c,s)},db=e=>{const t=Di().delete(e),n=ot.getState(),s=n.startedAt.has(e),o=n.settledMs.has(e);if(z0.delete(e),!s&&!o){t&&N0(n.startedAt,Date.now());return}let r=n.startedAt;if(s){const l=new Map(n.startedAt);l.delete(e),r=l}let a=n.settledMs;if(o){const l=new Map(n.settledMs);l.delete(e),a=l}ot.setState({startedAt:r,settledMs:a}),(s||t)&&N0(r,Date.now())},JR=(e={})=>{Xr=null,z0.clear(),m3=0,p3=e.pageLoadAt??Date.now(),ot.setState({startedAt:new Map,settledMs:new Map})},ub=e=>ot(ae.useCallback(t=>t.startedAt.get(e),[e])),fb=e=>ot(ae.useCallback(t=>t.settledMs.get(e),[e])),XR=(e,t)=>ot(ae.useCallback(n=>t?n.startedAt.has(e):n.settledMs.has(e),[t,e])),Jl="oc.sessions.pinned.v2",hb="oc.sessions.pinned",Cr=yt(),Xl=(e,t,n)=>{const s=Je(t);return!e||!s||!n?null:JSON.stringify([e,s,n])},J9=e=>{try{const t=JSON.parse(e);if(!Array.isArray(t)||t.length!==3)return null;const[n,s,o]=t;if(typeof n!="string"||typeof s!="string"||typeof o!="string")return null;const r=Je(s);return!n||!r||r!==s||!o?null:[n,r,o]}catch{return null}},Lc=(e,t,n)=>{if(!t)return!1;const s=Xl(We(),t,n);return s?e.has(s):!1},mb=()=>{Cr.removeItem(hb);const e=Cr.getItem(Jl);if(e===null)return{ids:new Set,touchedAt:{}};try{const t=JSON.parse(e);if(t.version!==2||!t.sessions||typeof t.sessions!="object")return{ids:new Set,touchedAt:{}};const n=Object.entries(t.sessions).filter(([s,o])=>J9(s)&&typeof o=="number"&&Number.isFinite(o)).sort((s,o)=>o[1]-s[1]);return{ids:new Set(n.map(([s])=>s)),touchedAt:Object.fromEntries(n)}}catch{return Cr.removeItem(Jl),{ids:new Set,touchedAt:{}}}},jc=(e,t)=>{const n=[...e].filter(s=>J9(s)!==null).map(s=>[s,t[s]??Date.now()]).sort((s,o)=>o[1]-s[1]);return{ids:new Set(n.map(([s])=>s)),touchedAt:Object.fromEntries(n)}},Ic=({ids:e,touchedAt:t})=>{const n=Object.fromEntries([...e].map(s=>[s,t[s]??Date.now()]));Cr.setItem(Jl,JSON.stringify({version:2,sessions:n}))},Bc=mb(),pb=W1((e,t)=>({ids:Bc.ids,touchedAt:Bc.touchedAt,setIds:n=>{const s=t().ids,o=typeof n=="function"?n(s):n;if(o===s)return;const r=jc(o,t().touchedAt);e(r),Ic(r)},toggle:n=>{const s=Xl(We(),n.directory,n.sessionId);if(!s)return;const o=new Set(t().ids),r={...t().touchedAt};o.has(s)?(o.delete(s),delete r[s]):(o.add(s),r[s]=Date.now());const a=jc(o,r);e(a),Ic(a)},clearPinnedSession:(n,s,o)=>{const r=Xl(n,s,o);if(!r||!t().ids.has(r))return;const a=new Set(t().ids);a.delete(r),t().setIds(a)}})),QR=new Map,Qr=new Map,En=new Map;let Sr=0;const zn=W1(()=>({rankById:new Map})),Tc=()=>(Sr=Math.max(Sr+1,Date.now()),Sr),gb=(e,t=!1)=>{const n=[...e];n.length!==0&&zn.setState(s=>{const o=new Map(s.rankById),r=t?Tc():null;for(const a of n)o.set(a,r??Tc());return{rankById:o}})},yb=(e,t)=>{const n=Qr.get(e);Qr.set(e,t),t==="active"&&n!=="active"&&gb([e])},vb=e=>{Qr.delete(e),En.delete(e),zn.setState(t=>{if(!t.rankById.has(e))return t;const n=new Map(t.rankById);return n.delete(e),{rankById:n}})},eO=()=>{Qr.clear(),En.clear(),Sr=0,zn.setState({rankById:new Map})},Ql=e=>typeof e=="number"&&Number.isFinite(e)?e:0,X9=e=>Ql(e.time?.updated)||Ql(e.time?.created),bb=e=>Ql(e.time?.created),e4=e=>e.parentID??null,Vc=e=>{const t=e;return Je(t.directory??null)??Je(t.project?.worktree??null)},Ls=(e,t)=>{const n=En.get(e.id),s=t?"created":"updated",o=n?.[s];if(o!==void 0)return o;const r=t?bb(e):X9(e);return En.set(e.id,{...n,[s]:r}),r},xb=e=>{const t=zn.getState().rankById;let n=!1;for(const s of e){const o=X9(s);if(t.get(s.id)!==void 0)continue;const r=En.get(s.id);r?.updated!==void 0&&r.updated>=o||(En.set(s.id,{...r,updated:o}),n=!0)}n&&zn.setState(s=>({rankById:new Map(s.rankById)}))},Nc=(e,t,n=!1)=>t.get(e.id)??Ls(e,n),t4=(e,t,n,s)=>{const o=Lc(n,Vc(e),e.id),r=Lc(n,Vc(t),t.id);if(o!==r)return o?-1:1;const a=Ls(e,o),l=Ls(t,r);if(e4(e)===e4(t)){const f=Nc(t,s,r)-Nc(e,s,o);if(f!==0)return f}const c=l-a;if(c!==0)return c;const u=Ls(t,!0)-Ls(e,!0);return u!==0?u:e.id.localeCompare(t.id)},tO=(e,t,n)=>{const s=new Set(e.map(f=>f.id)),o=[],r=new Map;for(const f of e){const h=e4(f);if(!h||!s.has(h)){o.push(f);continue}const m=r.get(h);m?m.push(f):r.set(h,[f])}const a=(f,h)=>t4(f,h,t,n);o.sort(a);for(const f of r.values())f.sort(a);const l=[],c=new Set,u=f=>{if(!c.has(f.id)){c.add(f.id),l.push(f);for(const h of r.get(f.id)??[])u(h)}};for(const f of o)u(f);for(const f of e)u(f);return l},Pc=500,wb=1e3*60*60*24*30;function Mb(e){const t=Date.now()-wb,n=e.filter(s=>s.time>=t);return n.length<=Pc?n:n.slice(n.length-Pc)}function Va(e){const t={session:{unseenCount:{},unseenHasError:{}},project:{unseenCount:{},unseenHasError:{}}};for(const n of e)n.viewed||(n.session&&(t.session.unseenCount[n.session]=(t.session.unseenCount[n.session]??0)+1,n.type==="error"&&(t.session.unseenHasError[n.session]=!0)),n.directory&&(t.project.unseenCount[n.directory]=(t.project.unseenCount[n.directory]??0)+1,n.type==="error"&&(t.project.unseenHasError[n.directory]=!0)));return t}const g3=W1((e,t)=>({list:[],index:{session:{unseenCount:{},unseenHasError:{}},project:{unseenCount:{},unseenHasError:{}}},append:n=>{const s=t().list,o=Mb([...s,n]);e({list:o,index:Va(o)})},markSessionViewed:n=>{const s=t();if((s.index.session.unseenCount[n]??0)===0)return;const r=s.list.map(a=>a.session===n&&!a.viewed?{...a,viewed:!0}:a);e({list:r,index:Va(r)})},markProjectViewed:n=>{const s=t();if((s.index.project.unseenCount[n]??0)===0)return;const r=s.list.map(a=>a.directory===n&&!a.viewed?{...a,viewed:!0}:a);e({list:r,index:Va(r)})},sessionUnseenCount:n=>t().index.session.unseenCount[n]??0,sessionHasError:n=>t().index.session.unseenHasError[n]??!1,projectUnseenCount:n=>t().index.project.unseenCount[n]??0,projectHasError:n=>t().index.project.unseenHasError[n]??!1}));function y3(e){g3.getState().markSessionViewed(e)}function Cb(e,t){const n=g3.getState();(n.index.session.unseenCount[e]??0)>0||n.append({type:"turn-complete",session:e,directory:t,time:Date.now(),viewed:!1})}function Sb(e){return g3(t=>t.index.session.unseenCount[e]??0)}const v3=(e,t)=>`${e}::${t}`,U0=W1(e=>({byKey:new Map,setEntry:t=>e(n=>{const s=new Map(n.byKey);return s.set(v3(t.runtimeKey,t.sessionId),t),{byKey:s}}),clearForSession:t=>e(n=>{const s=new Map(n.byKey);let o=!1;for(const r of s.keys())r.endsWith(`::${t}`)&&(s.delete(r),o=!0);return o?{byKey:s}:n}),clearAll:()=>e({byKey:new Map}),clearForRuntime:t=>e(n=>{const s=`${t}::`,o=new Map(n.byKey);let r=!1;for(const a of o.keys())a.startsWith(s)&&(o.delete(a),r=!0);return r?{byKey:o}:n})}));typeof window<"u"&&Wn(e=>{e.runtimeKey!==e.previousRuntimeKey&&e.previousRuntimeKey&&U0.getState().clearForRuntime(e.previousRuntimeKey)});const Q9=(e,t,n)=>{const s=We();U0.getState().setEntry({sessionId:e,runtimeKey:s,targetEntryId:t.targetEntryId,previousLeafId:t.previousLeafId,newLeafId:t.newLeafId,...t.editorText!==void 0?{editorText:t.editorText}:{},abandoned:n,createdAt:Date.now()})},_r=e=>{U0.getState().clearForSession(e)},kr=()=>{U0.getState().clearAll()},eu=e=>{const t=We();return U0.getState().byKey.get(v3(t,e))},tu=e=>U0(t=>{if(e)return t.byKey.get(v3(We(),e))}),nu=Object.freeze(Object.defineProperty({__proto__:null,clearAllRevertNavigations:kr,clearRevertNavigation:_r,getRevertNavigation:eu,setRevertNavigation:Q9,useRevertNavigation:tu,useRevertNavigationStore:U0},Symbol.toStringTag,{value:"Module"})),_b=async(e,t,n)=>{if(e.length===0)return[];const s=Math.max(1,Math.min(t,e.length)),o=new Array(e.length);let r=0;const a=async()=>{for(;;){const l=r;if(r+=1,l>=e.length)return;o[l]=await n(e[l])}};return await Promise.all(Array.from({length:s},()=>a())),o},kb=()=>({byId:new Map,byDirectory:new Map,listStatusByDirectory:new Map}),js=(e,t,n,s,o)=>{if(e.byId.has(t))return e;const r=Dn(n),a=o??Date.now(),l={id:t,directory:r,parentId:null,title:"",archived:!1,createdAt:a,updatedAt:a,lifecycle:s,hydrated:!1},c=new Map(e.byId);c.set(t,l);const u=e.byDirectory.get(r),f=new Map(e.byDirectory);return u&&u.includes(t)?f.set(r,u):u?f.set(r,[t,...u]):f.set(r,[t]),{...e,byId:c,byDirectory:f}},Dn=e=>Je(e)??e,su=(e,t)=>e.id===t.id&&e.directory===t.directory&&e.parentId===t.parentId&&e.title===t.title&&e.archived===t.archived&&e.createdAt===t.createdAt&&e.updatedAt===t.updatedAt&&e.preview===t.preview&&e.messageCount===t.messageCount&&e.lifecycle===t.lifecycle&&e.retry===t.retry&&e.hydrated===t.hydrated,Ab=(e,t,n,s)=>{const o=t.get(n)??[];for(const r of o){if(s.includes(r))continue;const a=e.get(r);a&&a.directory!==n||e.delete(r)}t.set(n,[...s])},Na=(e,t,n,s)=>{const o=Dn(t),r=[];let a=null,l=null;for(const m of n){const p=m?.session;if(!p?.id||!p.directory)continue;const g=Dn(p.directory);if(g!==o)continue;const y=typeof p.timeArchived=="number"?p.timeArchived>0:!!p.archived,M=e.byId.get(p.id),b=typeof m.updatedAt=="number"&&Number.isFinite(m.updatedAt)?m.updatedAt:typeof p.updatedAt=="number"&&Number.isFinite(p.updatedAt)?p.updatedAt:s,v={id:p.id,directory:g,parentId:p.parentId??null,title:p.title??"",archived:y,createdAt:p.createdAt,updatedAt:M?M.updatedAt:b,...typeof m.preview=="string"?{preview:m.preview}:{},...typeof p.messageCount=="number"?{messageCount:p.messageCount}:{},lifecycle:M?.lifecycle??"idle",...M?.retry?{retry:M.retry}:{},hydrated:M?.hydrated??!1};if(M&&su(M,v)){r.push(p.id);continue}a||(a=new Map(e.byId),l=new Map(e.byDirectory)),a.set(p.id,v),r.push(p.id)}const u=e.byDirectory.get(o)??[],f=u.length!==r.length||u.some((m,p)=>m!==r[p]);if(!a&&!f){if(e.listStatusByDirectory.get(o)!=="ready"){const m=new Map(e.listStatusByDirectory);return m.set(o,"ready"),{...e,listStatusByDirectory:m}}return e}a||(a=new Map(e.byId)),l||(l=new Map(e.byDirectory)),Ab(a,l,o,r);let h=null;return e.listStatusByDirectory.get(o)!=="ready"&&(h=new Map(e.listStatusByDirectory),h.set(o,"ready")),{byId:a,byDirectory:l,listStatusByDirectory:h??e.listStatusByDirectory}},Hb=(e,t)=>{const n=Dn(t),s=e.listStatusByDirectory.get(n);if(s==="loading"||s==="ready")return e;const o=new Map(e.listStatusByDirectory);return o.set(n,"loading"),{...e,listStatusByDirectory:o}},Lb=(e,t)=>{const n=Dn(t);if(e.listStatusByDirectory.get(n)==="failed")return e;const o=new Map(e.listStatusByDirectory);return o.set(n,"failed"),{...e,listStatusByDirectory:o}},Do=(e,t,n,s)=>{const o=e.byId.get(t);if(!o)return e;const r=n==="retry"?s:void 0;if(o.lifecycle===n&&o.retry===r)return e;const a=new Map(e.byId);return a.set(t,{...o,lifecycle:n,retry:r}),{...e,byId:a}},Pa=(e,t,n)=>{const s=e.byId.get(t);if(!s||s.hydrated===n)return e;const o=new Map(e.byId);return o.set(t,{...s,hydrated:n}),{...e,byId:o}},Ea=(e,t,n,s)=>{const o=e.byId.get(t);if(!o||o.title===n&&o.updatedAt===s)return e;const r=new Map(e.byId);return r.set(t,{...o,title:n,updatedAt:s}),{...e,byId:r}},Ec=(e,t,n,s)=>{const o=e.byId.get(t);if(!o){if(!s)return e;const a=js(e,t,s.directory,s.lifecycle,n),l=a.byId.get(t);if(!l||l.updatedAt===n)return a;const c=new Map(a.byId);return c.set(t,{...l,updatedAt:n}),{...a,byId:c}}if(o.updatedAt>=n&&o.lifecycle===(s?.lifecycle??o.lifecycle))return e;const r=new Map(e.byId);return r.set(t,{...o,updatedAt:Math.max(o.updatedAt,n),...s?.lifecycle?{lifecycle:s.lifecycle}:{}}),{...e,byId:r}},jb=(e,t,n,s)=>{const o=e.byId.get(t);if(!o||o.archived===n&&o.updatedAt===s)return e;const r=new Map(e.byId);return r.set(t,{...o,archived:n,updatedAt:s}),{...e,byId:r}},zc=(e,t)=>{const n=e.byId.get(t.id);if(n&&su(n,t))return e;const s=new Map(e.byId);s.set(t.id,t);const o=e.byDirectory.get(t.directory);if(o){const a=o.filter(c=>c!==t.id),l=new Map(e.byDirectory);return l.set(t.directory,[t.id,...a]),{...e,byId:s,byDirectory:l}}const r=new Map(e.byDirectory);return r.set(t.directory,[t.id]),{...e,byId:s,byDirectory:r}},Ib=(e,t)=>{const n=e.byId.get(t);if(!n)return e;const s=new Map(e.byId);s.delete(t);const o=e.byDirectory.get(n.directory);let r=null;if(o){const a=o.filter(l=>l!==t);r=new Map(e.byDirectory),a.length===0?r.delete(n.directory):r.set(n.directory,a)}return{byId:s,byDirectory:r??e.byDirectory,listStatusByDirectory:e.listStatusByDirectory}},Dc=new WeakMap,Ri=e=>{const t=Dc.get(e);if(t)return t;const n={id:e.id,directory:e.directory,parentID:e.parentId,title:e.title,time:{created:e.createdAt,updated:e.updatedAt,...e.archived?{archived:e.updatedAt}:{}}};return Dc.set(e,n),n},Rc=[],Bb=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0},ei=(e,t)=>{const n=t?.archived??!1,s=t?.directory;let o;if(typeof s=="string"&&s.length>0)o=e.byDirectory.get(Dn(s))??[];else{if(s===null||s==="")return Rc;o=[...e.byId.keys()]}const r=[];for(const a of o){const l=e.byId.get(a);l&&!!l.archived===n&&r.push(Ri(l))}return r.length===0?Rc:r},nO=e=>{const t=[];for(const n of e.byId.values())(n.lifecycle==="busy"||n.lifecycle==="retry")&&t.push(n.id);return t.sort(),t.join("|")},Tb=2,Vb=(e,t)=>_b([...e],Tb,async n=>t(n)),za=e=>e==="busy"||e==="retry"?e:e==="error"?"error":"idle",Nb=e=>{if(e.name==="session.lifecycle"){const t=e.payload.state;return t==="busy"||t==="retry"||t==="error"?t:t==="idle"?"idle":void 0}if(e.name==="assistant.message.start")return"busy";if(e.name==="session.error")return"error"},Oc="*",v2="catalog",H2="chrome",Da=16,Pb=300,Eb=new Set(["DAEMON_UNAVAILABLE","DAEMON_TIMEOUT","DAEMON_START_TIMEOUT","DAEMON_REQUEST_FAILED"]),Ro=()=>({directory:null,sessions:[],selectedSessionId:null,reducer:R9(),connection:"loading",error:null,showArchived:!1,hydratedSessionIds:new Set,sessionLoadErrorById:new Map,focusPending:!1,sessionsListStatus:"idle",catalog:kb()}),b0=e=>e instanceof U2?e:new U2("DAEMON_REQUEST_FAILED",e instanceof Error?e.message:void 0),Zc=e=>e instanceof U2&&e.code==="INVALID_SESSION",zb=e=>e instanceof U2&&e.code==="SESSION_RUNTIME_CONFLICT",Fc=async()=>{await new Promise(e=>setTimeout(e,Pb))};let $c=null;const y1=()=>($c??=new Db,$c);class Db{state=Ro();listenersByTopic=new Map;stream=null;streamGeneration=0;streamReadyRevision=0;runtimeGeneration=0;focusGeneration=0;recovering=!1;pendingFocus=null;pendingPreferredSessionId=null;hydratedSessionIds=new Set;activityPhaseById=new Map;pendingPromptById=new Set;promptGenerationById=new Map;lastAccessById=new Map;lastAccessClock=0;lastSelectedByDirectory=new Map;directoryRefreshGenerationByDirectory=new Map;evictionScheduled=!1;restoringTranscriptById=new Set;hydrateInflightById=new Map;navigationGenerationById=new Map;navigationCounter=0;cadence=new Xv(t=>this.commitEvents(t));unsubscribeRuntime=Wn(t=>{if(t.runtimeKey===t.previousRuntimeKey){this.reconnectAfterTransportSwitch();return}this.resetForRuntime()});getRuntimeGeneration=()=>this.runtimeGeneration;getFocusGeneration=()=>this.focusGeneration;hasClusterAttached=()=>this.stream!==null||this.state.connection==="ready";getState=()=>this.state;subscribe=(t,n=Oc)=>{let s=this.listenersByTopic.get(n);return s||(s=new Set,this.listenersByTopic.set(n,s)),s.add(t),()=>{const o=this.listenersByTopic.get(n);o&&o.delete(t)}};dispose=()=>{this.runtimeGeneration+=1,this.focusGeneration+=1,this.pendingFocus=null,this.pendingPreferredSessionId=null,this.hydratedSessionIds.clear(),this.activityPhaseById.clear(),this.pendingPromptById.clear(),this.promptGenerationById.clear(),this.lastAccessById.clear(),this.lastAccessClock=0,this.lastSelectedByDirectory.clear(),this.directoryRefreshGenerationByDirectory.clear(),this.evictionScheduled=!1,this.restoringTranscriptById.clear(),this.hydrateInflightById.clear(),this.cadence.dispose(),this.stream?.dispose(),this.stream=null,this.streamGeneration+=1,this.streamReadyRevision+=1,this.unsubscribeRuntime(),kr(),this.navigationGenerationById.clear(),this.navigationCounter=0,this.state=Ro(),this.emitBroadcast(),this.listenersByTopic.clear()};setShowArchived=t=>{t!==this.state.showArchived&&(this.state={...this.state,showArchived:t},this.emitChrome())};clearError=()=>{this.state.error&&(this.state={...this.state,error:null},this.emitChrome())};reportError=t=>{const n=b0(t);this.state={...this.state,error:n,connection:"error"},this.emitChrome(),this.ensureConnectionRecovery(n)};ensureConnectionRecovery(t){if(this.stream||!Eb.has(t.code))return;const n=this.runtimeGeneration,s=We(),o=this.streamGeneration+1;this.streamGeneration=o;const r=this.streamCursor();let a=null;a=s3({onEvent:()=>{},onReconnect:()=>{if(n!==this.runtimeGeneration||s!==We()||o!==this.streamGeneration||this.stream!==a)return;a?.dispose(),this.stream=null,this.streamGeneration+=1,this.streamReadyRevision+=1;const{directory:l,selectedSessionId:c}=this.state;this.start({...l?{directory:l}:{},...c?{sessionId:c}:{}})}},{...r!==void 0?{fromSequence:r}:{},runtimeKey:s}),this.stream=a}failSessionLoad(t,n){const s=new Map(this.state.sessionLoadErrorById);s.set(t,n);const o=this.state.selectedSessionId===t;this.state={...this.state,sessionLoadErrorById:s,focusPending:o?!1:this.state.focusPending},this.emitChrome()}clearSessionLoadError(t){if(!this.state.sessionLoadErrorById.has(t))return;const n=new Map(this.state.sessionLoadErrorById);n.delete(t),this.state={...this.state,sessionLoadErrorById:n},this.emitChrome()}clear=()=>{this.runtimeGeneration+=1,this.focusGeneration+=1,this.pendingFocus=null,this.pendingPreferredSessionId=null,this.hydratedSessionIds.clear(),this.activityPhaseById.clear(),this.pendingPromptById.clear(),this.promptGenerationById.clear(),this.lastAccessById.clear(),this.lastAccessClock=0,this.lastSelectedByDirectory.clear(),this.directoryRefreshGenerationByDirectory.clear(),this.evictionScheduled=!1,this.restoringTranscriptById.clear(),this.hydrateInflightById.clear(),this.cadence.dispose(),this.stream?.dispose(),this.stream=null,this.streamGeneration+=1,this.streamReadyRevision+=1,this.state={...Ro(),connection:"ready"},kr(),this.navigationGenerationById.clear(),this.navigationCounter=0,this.emitBroadcast()};async refreshDirectoryCatalog(t){const n=Je(t);if(!n)return{ok:!1,error:b0(new U2("INVALID_ARGUMENT","directory is required"))};const s=We(),o=(this.directoryRefreshGenerationByDirectory.get(n)??0)+1;this.directoryRefreshGenerationByDirectory.set(n,o);const r=this.runtimeGeneration,a=Hb(this.state.catalog,n);a!==this.state.catalog&&(this.state={...this.state,catalog:a},this.emit([v2]));try{const l=await i1.listSessions({directory:n,runtimeKey:s});if(this.directoryRefreshGenerationByDirectory.get(n)!==o)return{ok:!0};if(r!==this.runtimeGeneration)return{ok:!0};if(s!==We())return{ok:!0};const c=Na(this.state.catalog,n,l.sessions,Date.now());return c!==this.state.catalog&&(this.state={...this.state,catalog:c},this.emit([v2])),{ok:!0}}catch(l){if(this.directoryRefreshGenerationByDirectory.get(n)!==o)return{ok:!0};if(r!==this.runtimeGeneration)return{ok:!0};if(s!==We())return{ok:!0};const c=b0(l),u=Lb(this.state.catalog,n),f=Je(this.state.directory)===n,h=[];return u!==this.state.catalog&&(this.state={...this.state,catalog:u},h.push(v2)),f&&(this.state={...this.state,error:c},h.push(H2)),h.length>0&&this.emit(h),{ok:!1,error:c}}}async refreshAllDirectoryCatalogs(t){const n=[...new Set(t)].map(s=>Je(s)).filter(s=>!!s);n.length!==0&&await Vb(n,s=>this.refreshDirectoryCatalog(s))}async start(t={}){if(this.hasClusterAttached()&&this.state.connection!=="error"&&this.state.connection!=="unavailable"){await this.focusProject(t.directory??null,t.sessionId??null);return}try{const n=typeof t.directory=="string"&&t.directory.trim()?t.directory:null;if(n){await this.open(n,t.sessionId);return}if(t.sessionId&&!t.sessionDirectoryKnown)try{const r=await i1.getSession(t.sessionId,{directory:n??void 0,runtimeKey:We()});if(r?.session?.directory){await this.open(r.session.directory,t.sessionId);return}}catch{}const s=await i1.listProjects({runtimeKey:We()}),o=s.projects.find(r=>r.selected)?.directory??s.projects[0]?.directory;if(!o){await this.connectWithoutProject();return}await this.open(o,t.sessionId)}catch(n){this.reportError(n)}}async connectWithoutProject(){if(this.hasClusterAttached()&&this.state.connection!=="error"&&this.state.connection!=="unavailable"){await this.focusProject(null,null);return}const t=++this.runtimeGeneration;this.focusGeneration=t,this.pendingFocus=null,this.pendingPreferredSessionId=null,this.state={...this.state,directory:null,sessions:[],selectedSessionId:null,connection:"loading",sessionsListStatus:"idle",focusPending:!1,error:null},this.emitChrome();try{const n=await i1.health({runtimeKey:We()});if(t!==this.runtimeGeneration)return;if(n.state!=="ready")throw new U2(n.error?.code??"DAEMON_UNAVAILABLE",n.error?.message);this.state={...this.state,directory:null,sessions:[],selectedSessionId:null,connection:"ready",sessionsListStatus:"idle",focusPending:!1,error:null},this.emitChrome()}catch(n){t===this.runtimeGeneration&&this.reportError(n)}}async focusProject(t,n){const s=typeof t=="string"&&t.trim()?t.trim():null,o=Je(s)===Je(this.state.directory),r=n??null;if(o){if(!r||r===this.state.selectedSessionId)return;await this.select(r);return}if(!s){this.state={...this.state,directory:null,sessions:[],sessionsListStatus:"idle",focusPending:!1,error:null},this.emitChrome();return}const a=++this.focusGeneration;this.pendingFocus={directory:s,expected:a,preferredSessionId:r},this.pendingPreferredSessionId=r;const l=!!r&&this.hydratedSessionIds.has(r);this.state={...this.state,directory:s,sessions:[],selectedSessionId:l?r:r??null,sessionsListStatus:"loading",focusPending:!l,error:null},this.emitChrome(),l&&this.touchLastAccess(r),await this.resolveFocus(a,s)}async resolveFocus(t,n){const s=We(),o=this.runtimeGeneration,r=this.pendingPreferredSessionId;let a=n;try{try{const g=await i1.selectProject(n,{runtimeKey:s});if(t!==this.focusGeneration||o!==this.runtimeGeneration)return;a=g.directory,Je(a)!==Je(this.state.directory)&&(this.state={...this.state,directory:a},this.emitChrome())}catch(g){if(!this.shouldRetryFocusError(g))throw g;if(await Fc(),t!==this.focusGeneration||o!==this.runtimeGeneration)return;a=(await i1.selectProject(n,{runtimeKey:s})).directory,Je(a)!==Je(this.state.directory)&&(this.state={...this.state,directory:a},this.emitChrome())}const l=await this.fetchFocusListWithRetry(a,t,o,s);if(l.kind==="stale")return;if(l.kind==="failed"){this.failFocus(t,l.error);return}const c=l.payload;if(t!==this.focusGeneration||o!==this.runtimeGeneration)return;let u=r?c.sessions.find(g=>g.session.id===r):void 0;if(r&&!u)try{const g=await i1.getSession(r,{directory:a,runtimeKey:s});if(g?.session?.id){if(g.session.directory&&Je(g.session.directory)!==Je(a)&&t===this.focusGeneration){await this.focusProject(g.session.directory,r);return}c.sessions.unshift({session:g.session,updatedAt:g.session.updatedAt}),u={session:g.session,updatedAt:g.session.updatedAt}}}catch{}if(t!==this.focusGeneration||o!==this.runtimeGeneration)return;const f=u?.session.id??(r||(c.sessions.find(g=>!g.session.archived)?.session.id??c.sessions[0]?.session.id??null));this.pendingPreferredSessionId=null;const h=Na(this.state.catalog,a,c.sessions,Date.now()),m=h!==this.state.catalog;this.state={...this.state,sessions:c.sessions,selectedSessionId:f??this.state.selectedSessionId,sessionsListStatus:"ready",focusPending:!!f&&!this.hydratedSessionIds.has(f),error:null,catalog:h};const p=[H2];m&&p.push(v2),this.emit(p),f&&this.touchLastAccess(f),f&&!this.hydratedSessionIds.has(f)?(await this.hydrate(f,this.runtimeGeneration),t===this.focusGeneration&&this.state.focusPending&&this.state.selectedSessionId===f&&this.hydratedSessionIds.has(f)&&(this.state={...this.state,focusPending:!1},this.emitChrome())):f&&this.hydratedSessionIds.has(f)&&this.state.focusPending&&(this.state={...this.state,focusPending:!1},this.emitChrome())}catch(l){t===this.focusGeneration&&o===this.runtimeGeneration&&this.failFocus(t,b0(l))}finally{t===this.focusGeneration&&this.pendingFocus?.expected===t&&(this.pendingFocus=null)}}failFocus(t,n){t===this.focusGeneration&&(this.state={...this.state,sessions:[],sessionsListStatus:"failed",focusPending:!1,error:n},this.emitChrome())}shouldRetryFocusError(t){if(t instanceof U2){if(t.code==="DAEMON_UNAVAILABLE")return!0;const n=t.status;return typeof n=="number"&&n>=500&&n<600||n===408||n===429}return!0}async fetchFocusListWithRetry(t,n,s,o){try{const r=await i1.listSessions({directory:t,runtimeKey:o});return n!==this.focusGeneration||s!==this.runtimeGeneration?{kind:"stale"}:{kind:"ok",payload:r}}catch(r){if(!this.shouldRetryFocusError(r))return{kind:"failed",error:b0(r)};if(await Fc(),n!==this.focusGeneration||s!==this.runtimeGeneration)return{kind:"stale"};try{const a=await i1.listSessions({directory:t,runtimeKey:o});return n!==this.focusGeneration||s!==this.runtimeGeneration?{kind:"stale"}:{kind:"ok",payload:a}}catch(a){return{kind:"failed",error:b0(a)}}}}async open(t,n){if(this.hasClusterAttached()&&this.state.connection!=="error"&&this.state.connection!=="unavailable"){if(Je(t)===Je(this.state.directory)){n&&n!==this.state.selectedSessionId&&await this.select(n);return}await this.focusProject(t,n??null);return}if(t===this.state.directory&&this.state.connection==="loading"){n&&n!==this.state.selectedSessionId&&(this.pendingPreferredSessionId=n,this.state={...this.state,selectedSessionId:n,error:null},this.emitChrome());return}if(t===this.state.directory&&this.state.connection==="ready"){n&&n!==this.state.selectedSessionId&&await this.select(n);return}const s=++this.runtimeGeneration;this.focusGeneration=s,this.pendingFocus=null,this.pendingPreferredSessionId=n??null,this.hydratedSessionIds.clear(),this.activityPhaseById.clear(),this.pendingPromptById.clear(),this.promptGenerationById.clear(),this.lastAccessById.clear(),this.lastAccessClock=0,this.lastSelectedByDirectory.clear(),this.directoryRefreshGenerationByDirectory.clear(),this.evictionScheduled=!1,this.restoringTranscriptById.clear(),this.hydrateInflightById.clear(),this.cadence.dispose(),this.stream?.dispose(),this.stream=null,this.state={...this.state,directory:t,selectedSessionId:n??null,connection:"loading",hydratedSessionIds:new Set,reducer:{bySession:new Map(this.state.reducer.bySession),lastSequence:new Map(this.state.reducer.lastSequence)}},this.emitChrome();const o=We();try{const r=await i1.selectProject(t,{runtimeKey:o});if(s!==this.runtimeGeneration)return;const a={directory:r.directory,runtimeKey:o};r.directory!==t&&(this.state={...this.state,directory:r.directory},this.emitChrome());const l=await i1.health(a);if(s!==this.runtimeGeneration)return;if(l.state!=="ready")throw new U2(l.error?.code??"DAEMON_UNAVAILABLE",l.error?.message);const c={state:"ready",protocolVersion:l.protocolVersion,capabilities:[...l.capabilities]},u=await i1.listSessions(a);if(s!==this.runtimeGeneration)return;const f=this.pendingPreferredSessionId??n;let h=f?u.sessions.find(M=>M.session.id===f):void 0;if(f&&!h)try{const M=await i1.getSession(f,{directory:t,runtimeKey:o});if(M?.session?.directory&&M.session.directory!==t){if(s!==this.runtimeGeneration)return;await this.open(M.session.directory,f);return}M?.session?.id&&(u.sessions.unshift({session:M.session,updatedAt:M.session.updatedAt}),h={session:M.session,updatedAt:M.session.updatedAt})}catch{}const m=h?.session.id??(f||(u.sessions.find(M=>!M.session.archived)?.session.id??u.sessions[0]?.session.id??null));this.pendingPreferredSessionId=null;const p=Na(this.state.catalog,r.directory,u.sessions,Date.now()),g=p!==this.state.catalog;this.state={...this.state,sessions:u.sessions,selectedSessionId:m,connection:"ready",catalog:p};const y=[H2];g&&y.push(v2),this.emit(y),m&&await this.hydrate(m,s,void 0,{initialHealth:c,initialSessions:u.sessions})}catch(r){s===this.runtimeGeneration&&this.reportError(r)}}async select(t,n){if(!t)return;const s=n??this.state.reducer.bySession.get(t)?.directory??this.state.sessions.find(r=>r.session.id===t)?.session.directory;if(s&&Je(s)!==Je(this.state.directory)){if(this.stream!==null){await this.focusProject(s,t);return}await this.open(s,t);return}if(this.state.connection==="loading"){if(this.state.selectedSessionId===t)return;this.pendingPreferredSessionId=t,this.state={...this.state,selectedSessionId:t,error:null},this.emitChrome();return}if(!this.state.directory){await this.focusProject(null,t);return}if(t===this.state.selectedSessionId){this.touchLastAccess(t);const r=this.state.reducer.bySession.get(t);(!this.hydratedSessionIds.has(t)||!r||r.messages.size===0)&&await this.hydrate(t,this.runtimeGeneration),this.scheduleIdleEviction();return}this.state.directory&&this.lastSelectedByDirectory.set(this.state.directory,t),this.cadence.flush(),this.state={...this.state,selectedSessionId:t,error:null,focusPending:!1},this.emitChrome(),this.touchLastAccess(t);const o=this.state.reducer.bySession.get(t);if(this.stream&&this.hydratedSessionIds.has(t)&&o&&o.messages.size>0){this.scheduleIdleEviction();return}await this.hydrate(t,this.runtimeGeneration)}lastSelectedSessionForDirectory(t){return t?this.lastSelectedByDirectory.get(t)??null:null}async ensureHydrated(t){if(!t)return;const n=this.state.reducer.bySession.get(t);if(this.hydratedSessionIds.has(t)&&n&&n.messages.size>0){this.touchLastAccess(t);return}await this.hydrate(t,this.runtimeGeneration)}async create(t,n){const s=n?.directory||this.directory(),o=this.runtimeGeneration,r=await i1.getSettings({directory:s,runtimeKey:We()}),a=n?.model??r.pichamber.defaultModel,l=Sv({thinking:n?.thinking,model:a,defaultThinkingByModel:r.pichamber.defaultThinkingByModel,defaultThinking:r.pichamber.defaultThinking}),c=await i1.createSession({cwd:s,...t?{title:t}:{},...a?{model:a}:{},...l?{thinking:l}:{}},{directory:s,runtimeKey:We()});if(o!==this.runtimeGeneration)return c.session.id;this.state={...this.state,sessions:[{session:c.session,updatedAt:c.session.updatedAt},...this.state.sessions],selectedSessionId:c.session.id};const u=zc(this.state.catalog,this.recordFromPiSession(c.session)),f=u!==this.state.catalog;this.state={...this.state,catalog:u};const h=[H2];return f&&h.push(v2),this.emit(h),await this.hydrate(c.session.id,o,c),c.session.id}async rename(t,n){await i1.renameSession({sessionId:t,title:n},this.scope());const s=Date.now(),o=Ea(this.state.catalog,t,n,s),r=o!==this.state.catalog;this.state={...this.state,sessions:this.state.sessions.map(l=>l.session.id===t?{...l,session:{...l.session,title:n}}:l),catalog:o};const a=[H2];r&&a.push(v2),this.emit(a)}async archive(t,n){const s=this.state.sessions.find(c=>c.session.id===t)?.session.directory;await i1.archiveSession({sessionId:t,archived:n},this.scope(s));const o=Date.now(),r=jb(this.state.catalog,t,n,o),a=r!==this.state.catalog;this.state={...this.state,sessions:this.state.sessions.map(c=>c.session.id===t?{...c,session:{...c.session,archived:n}}:c),catalog:r};const l=[H2];a&&l.push(v2),this.emit(l)}async remove(t){const n=this.runtimeGeneration;if(await i1.deleteSession({sessionId:t,ignoreMissing:!0},this.scope()),n!==this.runtimeGeneration)return;db(t),vb(t),_r(t),this.navigationGenerationById.delete(t);const s=this.state.sessions.filter(f=>f.session.id!==t),o=this.state.selectedSessionId===t?s.find(f=>!f.session.archived)?.session.id??null:this.state.selectedSessionId,r=new Map(this.state.reducer.bySession);r.delete(t);const a=new Map(this.state.reducer.lastSequence);a.delete(t),this.hydratedSessionIds.delete(t),this.activityPhaseById.delete(t),this.pendingPromptById.delete(t),this.promptGenerationById.delete(t),this.lastAccessById.delete(t);const l=Ib(this.state.catalog,t),c=l!==this.state.catalog;this.state={...this.state,sessions:s,selectedSessionId:o,hydratedSessionIds:new Set(this.hydratedSessionIds),reducer:{bySession:r,lastSequence:a},catalog:l};const u=[`session:${t}`,H2];c&&u.push(v2),this.emit(u),o&&o!==this.state.selectedSessionId&&await this.hydrate(o,n)}async fork(t,n){const s=this.state.sessions.find(a=>a.session.id===t)?.session.title??this.state.catalog.byId.get(t)?.title??"",o=await i1.forkSession({sessionId:t,...n?{messageId:n}:{}},this.scope());this.upsertAndHydrate(o);const r=o.session.title?.trim()||s.trim()||"Untitled";if(!r.includes("(Fork)")){const a=`${r} (Fork)`;this.rename(o.session.id,a).catch(()=>{})}}async clone(t){const n=await i1.cloneSession({sessionId:t},this.scope());this.upsertAndHydrate(n)}async navigate(t,n){const s=this.state.reducer.bySession.get(t),o=s?[...s.messages.values()]:[],r=new Map;for(const c of o){const u=typeof c.text=="string"?c.text.trim():"";u&&r.set(c.id,u)}const a=this.runtimeGeneration,l=(this.navigationGenerationById.get(t)??0)+1;this.navigationGenerationById.set(t,l),this.navigationCounter=Math.max(this.navigationCounter,l),this.hydrateInflightById.delete(t);try{const c=await i1.navigateSession(t,n,this.scope());if((this.navigationGenerationById.get(t)??0)!==l||a!==this.runtimeGeneration)return c;const u=this.sessionFromDetail(c);this.commitNavigationSession(u);const f=c.navigation;if(f&&typeof f.targetEntryId=="string"){const h=new Set(c.messages.map(M=>M.message.id)),m=o.filter(M=>!h.has(M.id)).map(M=>{const b=(r.get(M.id)??"").replace(/\s+/g," ").slice(0,120)||"[No text]",v=M.role==="assistant"?"assistant":"user";return{id:M.id,role:v,preview:b}}),p=eu(t),g=new Set(m.map(M=>M.id)),y=[...m];for(const M of p?.abandoned??[])!h.has(M.id)&&!g.has(M.id)&&(y.push(M),g.add(M.id));y.length===0?_r(t):Q9(t,p?{...f,previousLeafId:p.previousLeafId}:f,y)}return c}catch(c){throw this.navigationGenerationById.get(t)===l&&(l<=1?this.navigationGenerationById.delete(t):this.navigationGenerationById.set(t,l-1)),c}}async prompt(t,n,s,o){const r=this.runtimeGeneration;let a=this.state.reducer.bySession.get(t);if(!a||a.messages.size===0){if(await this.hydrate(t,r),r!==this.runtimeGeneration)return;a=this.state.reducer.bySession.get(t)}const l=a?{...a,lifecycle:"busy"}:{sessionId:t,directory:this.state.directory??this.state.sessions.find(y=>y.session.id===t)?.session.directory??"",lastSequence:this.state.reducer.lastSequence.get(t)??-1,lifecycle:"busy",messages:new Map,partOrder:new Map,parts:Kl(),toolsByCallId:new Map,streamingMessages:new Set,queue:{steering:0,followUp:0}},c=new Map(this.state.reducer.bySession);c.set(t,l),this.state={...this.state,reducer:{...this.state.reducer,bySession:c}};const u=(this.promptGenerationById.get(t)??0)+1;this.promptGenerationById.set(t,u),this.pendingPromptById.add(t),this.promoteSession(t,"active",{reorder:!0}),this.touchSessionList(t);const f=Date.now(),h=Ec(Do(this.state.catalog,t,"busy"),t,f,{directory:l.directory||this.state.directory||"",lifecycle:"busy"}),m=h!==this.state.catalog;this.state={...this.state,catalog:h};const p=[`session:${t}`,H2];m&&p.push(v2),this.emit(p);const g={sessionId:t,text:n,messageId:`msg_${crypto.randomUUID()}`,...o?.length?{attachments:o}:{}};try{let y;return s==="steer"?y=await i1.sendSteer(g,this.scope()):s==="followUp"?y=await i1.sendFollowUp(g,this.scope()):y=await i1.sendPrompt(g,this.scope()),_r(t),y}catch(y){if(Jp("prompt-send",y),this.promptGenerationById.get(t)===u){this.pendingPromptById.delete(t);const M=this.state.reducer.bySession.get(t);if(M?.lifecycle==="busy"&&M.streamingMessages.size===0){const b=new Map(this.state.reducer.bySession);b.set(t,{...M,lifecycle:"error"}),this.state={...this.state,reducer:{...this.state.reducer,bySession:b}},this.promoteSession(t,"settled"),this.emit([`session:${t}`,H2])}}throw y}}abort=t=>i1.abortSession({sessionId:t},this.scope());compact=t=>i1.compactSession({sessionId:t},this.scope());setModel=(t,n,s)=>i1.setSessionModel({sessionId:t,model:{providerId:n,modelId:s}},this.scope());setThinking=(t,n)=>i1.setSessionThinking({sessionId:t,thinking:n},this.scope());tree=t=>i1.getSessionTree(t,this.scope());providers=()=>i1.listProviders({runtimeKey:We()});upload=t=>i1.createAttachment(t,this.scope());selected(){const t=this.state.selectedSessionId,n=t?this.state.reducer.bySession.get(t):void 0;return n?q9(n):null}sessionFromDetail(t){return h3({session:t.session,lastSequence:t.lastSequence,...t.isStreaming!==void 0?{isStreaming:t.isStreaming}:{},...t.lifecycle?{lifecycle:t.lifecycle}:{},messages:t.messages}).session}recordFromPiSession(t,n){const s=n?.now??Date.now(),o=this.state.catalog.byId.get(t.id),r=Je(t.directory)??t.directory,a=typeof t.timeArchived=="number"?t.timeArchived>0:!!t.archived;return{id:t.id,directory:r,parentId:t.parentId??null,title:t.title??"",archived:a,createdAt:t.createdAt,updatedAt:typeof t.updatedAt=="number"&&Number.isFinite(t.updatedAt)?t.updatedAt:s,...typeof t.messageCount=="number"?{messageCount:t.messageCount}:{},lifecycle:o?.lifecycle??"idle",hydrated:o?.hydrated??!1}}mergeHydratedSession(t,n){if(!n||n.sessionId!==t.sessionId)return t;const o=n.lifecycle==="busy"||n.lifecycle==="retry"||n.lastSequence>t.lastSequence;if(n.messages.size===0&&!o)return t;const r={...t,lifecycle:o?n.lifecycle:t.lifecycle,lastSequence:Math.max(t.lastSequence,n.lastSequence),messages:new Map(t.messages),partOrder:new Map(t.partOrder),parts:Kl(t.parts),toolsByCallId:new Map(t.toolsByCallId),streamingMessages:new Set(o?n.streamingMessages:t.streamingMessages),queue:n.queue.steering>0||n.queue.followUp>0?n.queue:t.queue,...n.model&&(o||!t.model)?{model:n.model}:{},...n.thinking&&(o||!t.thinking)?{thinking:n.thinking}:{}};if(o){for(const[a,l]of n.messages)Hv(r,a,l);for(const[a,l]of n.partOrder){r.partOrder.set(a,l);for(const c of l){const u=n.parts.get(c);u&&r.parts.set(c,u)}}for(const[a,l]of n.toolsByCallId)r.toolsByCallId.set(a,l)}return r}touchLastAccess(t){t&&(this.lastAccessClock+=1,this.lastAccessById.set(t,this.lastAccessClock))}commitNavigationSession(t){this.cadence.flush();const n=this.state.reducer.bySession.get(t.sessionId),s=n?{...t,lastSequence:Math.max(t.lastSequence,n.lastSequence),...n.model&&!t.model?{model:n.model}:{},...n.thinking&&!t.thinking?{thinking:n.thinking}:{},queue:n.queue.steering>0||n.queue.followUp>0?n.queue:t.queue}:t,o={bySession:new Map(this.state.reducer.bySession),lastSequence:new Map(this.state.reducer.lastSequence)};o.bySession.set(s.sessionId,s),o.lastSequence.set(s.sessionId,s.lastSequence),this.hydratedSessionIds.add(s.sessionId),this.touchLastAccess(s.sessionId);const a=this.state.selectedSessionId===s.sessionId?!1:this.state.focusPending&&!this.hydratedSessionIds.has(this.state.selectedSessionId??"");let l=this.state.sessionLoadErrorById;if(l.has(s.sessionId)){const m=new Map(l);m.delete(s.sessionId),l=m}const c=za(s.lifecycle);let u=this.state.catalog;u.byId.has(s.sessionId)||(u=js(u,s.sessionId,s.directory,c)),u=Pa(u,s.sessionId,!0),u=Do(u,s.sessionId,c,s.retry);const f=u!==this.state.catalog;this.state={...this.state,reducer:o,error:null,focusPending:a,hydratedSessionIds:new Set(this.hydratedSessionIds),sessionLoadErrorById:l,catalog:u};const h=[`session:${s.sessionId}`,H2];f&&h.push(v2),this.emit(h),this.scheduleIdleEviction()}commitHydratedSession(t,n=[]){this.cadence.flush();const s=this.state.reducer.bySession.get(t.sessionId),o=this.mergeHydratedSession(t,s);(o.lifecycle==="busy"||o.lifecycle==="retry")&&Hc(o.sessionId,"active");let r={bySession:new Map(this.state.reducer.bySession),lastSequence:new Map(this.state.reducer.lastSequence)};r.bySession.set(o.sessionId,o),r.lastSequence.set(o.sessionId,o.lastSequence);for(const y of n){const M=Sc(r,y);r=M.state,M.didApply&&this.observeActivity(y)}this.hydratedSessionIds.add(o.sessionId),this.touchLastAccess(o.sessionId);const l=this.state.selectedSessionId===o.sessionId?!1:this.state.focusPending&&!this.hydratedSessionIds.has(this.state.selectedSessionId??"");let c=this.state.sessionLoadErrorById;if(c.has(o.sessionId)){const y=new Map(c);y.delete(o.sessionId),c=y}let u=this.applyCatalogFromEvents(n,r);const f=r.bySession.get(o.sessionId),h=f?.lifecycle,m=h?za(h):void 0;u.byId.has(o.sessionId)||(u=js(u,o.sessionId,o.directory,m??"idle")),u=Pa(u,o.sessionId,!0),m!==void 0&&(u=Do(u,o.sessionId,m,f?.retry));const p=u!==this.state.catalog;this.state={...this.state,reducer:r,error:null,focusPending:l,hydratedSessionIds:new Set(this.hydratedSessionIds),sessionLoadErrorById:c,catalog:u};const g=[`session:${o.sessionId}`,H2];p&&g.push(v2),this.emit(g),this.scheduleIdleEviction()}async hydrate(t,n,s,o){if(n!==this.runtimeGeneration)return;const r=this.hydrateInflightById.get(t);if(r)return r;const a=this.hydrateUnshared(t,n,s,o).finally(()=>{this.hydrateInflightById.get(t)===a&&this.hydrateInflightById.delete(t)});return this.hydrateInflightById.set(t,a),a}async hydrateUnshared(t,n,s,o){if(n!==this.runtimeGeneration)return;const a=this.state.sessions.find(h=>h.session.id===t)?.session.directory||this.directory(),l=We(),c=this.state.reducer.bySession.get(t),u=!!(c&&c.messages.size>0),f=this.navigationGenerationById.get(t)??0;if(!o?.force&&this.stream&&this.hydratedSessionIds.has(t)&&u&&!s){(this.state.connection!=="ready"||this.state.error)&&(this.state={...this.state,connection:"ready",error:null},this.emitChrome());return}this.clearSessionLoadError(t);try{if(this.stream){const b=s??await i1.getSession(t,{directory:a,runtimeKey:l});if(n!==this.runtimeGeneration||b.session.id!==t||(this.navigationGenerationById.get(t)??0)!==f)return;(b.lifecycle==="busy"||b.lifecycle==="retry")&&typeof b.runStartedAt=="number"&&sn(b.session.id,b.runStartedAt,b.serverNow),this.commitHydratedSession(this.sessionFromDetail(b));return}const h=[];let m=!1;const p=b=>{n===this.runtimeGeneration&&(m?this.apply(b):h.push(b))},g=this.streamGeneration+1;this.streamGeneration=g;const y=await Zv({directory:a,selectedSessionId:t,runtimeKey:l,...o?.initialHealth?{initialHealth:o.initialHealth}:{},...o?.initialSessions?{initialSessions:o.initialSessions}:{},onEvent:p,onStreamDisconnect:()=>{this.reconnect(this.state.selectedSessionId??t,n,l)},onStreamReconnect:()=>this.markStreamReconnected(n,l,g)});if(n!==this.runtimeGeneration){y.stream?.dispose();return}let M=s?this.sessionFromDetail(s):y.reducerState.bySession.get(t);if(s&&(s.lifecycle==="busy"||s.lifecycle==="retry")&&typeof s.runStartedAt=="number"&&sn(s.session.id,s.runStartedAt,s.serverNow),!M)try{const b=s??await i1.getSession(t,{directory:a,runtimeKey:l});if(n!==this.runtimeGeneration){y.stream?.dispose();return}(b.lifecycle==="busy"||b.lifecycle==="retry")&&typeof b.runStartedAt=="number"&&sn(b.session.id,b.runStartedAt,b.serverNow),M=this.sessionFromDetail(b)}catch(b){if(this.stream=y.stream,m=!0,n===this.runtimeGeneration&&Zc(b)){this.failSessionLoad(t,b);return}throw y.stream?.dispose(),this.stream=null,b}if(M.sessionId!==t){y.stream?.dispose();return}if((this.navigationGenerationById.get(t)??0)!==f){y.stream?.dispose();return}this.stream=y.stream,this.commitHydratedSession(M,h),m=!0}catch(h){if(n!==this.runtimeGeneration)return;if(Zc(h)){this.failSessionLoad(t,h);return}if(zb(h)){try{const m=await i1.getSession(t,{directory:a,runtimeKey:l});if(n!==this.runtimeGeneration||m.session.id!==t||(this.navigationGenerationById.get(t)??0)!==f)return;(m.lifecycle==="busy"||m.lifecycle==="retry")&&typeof m.runStartedAt=="number"&&sn(m.session.id,m.runStartedAt,m.serverNow),this.commitHydratedSession(this.sessionFromDetail(m))}catch(m){if(n!==this.runtimeGeneration)return;this.failSessionLoad(t,b0(m))}return}this.reportError(h)}}markStreamReconnected(t,n,s){t!==this.runtimeGeneration||n!==We()||s!==this.streamGeneration||(this.streamReadyRevision+=1,!(this.state.connection==="ready"&&!this.state.error)&&(this.state={...this.state,connection:"ready",error:null},this.emitChrome()))}async reconnect(t,n,s){if(this.recovering||n!==this.runtimeGeneration)return;this.recovering=!0,this.cadence.flush();const o=this.stream,r=this.streamReadyRevision,a=this.streamGeneration+1,l=this.streamCursor();try{const c=await Gv({directory:this.directory(),sessionId:t,runtimeKey:s,lastKnownSequence:l,onEvent:u=>this.apply(u),onStreamDisconnect:()=>{this.reconnect(this.state.selectedSessionId??t,n,s)},onStreamReconnect:()=>this.markStreamReconnected(n,s,a)});if(n!==this.runtimeGeneration||s!==We()){c.stream?.dispose();return}if(r!==this.streamReadyRevision){c.stream?.dispose();return}if(c.phase==="ready"){o?.dispose(),this.streamGeneration=a,this.stream=c.stream;const u={bySession:new Map(this.state.reducer.bySession),lastSequence:new Map(this.state.reducer.lastSequence)},f=[];for(const[y,M]of c.reducerState.bySession.entries()){const b=this.mergeHydratedSession(M,u.bySession.get(y));u.bySession.set(y,b),u.lastSequence.set(y,b.lastSequence),this.touchLastAccess(y),f.push(y)}for(const y of c.reducerState.bySession.keys())this.hydratedSessionIds.add(y);const h=this.applyCatalogFromEvents([],u),m=h!==this.state.catalog;this.state={...this.state,reducer:u,connection:"ready",error:null,hydratedSessionIds:new Set(this.hydratedSessionIds),...m?{catalog:h}:{}};const p=[H2];for(const y of f)p.push(`session:${y}`);m&&p.push(v2),this.emit(p);const g=Math.max(l??-1,c.lastSequence);for(const[y,M]of this.state.reducer.bySession.entries())y!==t&&(M.lastSequence>=g||this.hydratedSessionIds.has(y)&&i1.getSession(y,{directory:this.directory(),runtimeKey:s}).then(b=>{if(n!==this.runtimeGeneration)return;const v=this.sessionFromDetail(b);this.commitHydratedSession(v)}).catch(()=>{}));this.scheduleIdleEviction()}else this.reportError(new U2(c.error?.code??"DAEMON_UNAVAILABLE",c.error?.message))}finally{this.recovering=!1}}apply(t){this.cadence.push(t)}observeActivity(t){if(t.name==="session.lifecycle"){const n=t.payload.state==="busy"||t.payload.state==="retry";n&&typeof t.payload.runStartedAt=="number"&&sn(t.sessionId,t.payload.runStartedAt,t.payload.serverNow),this.promoteSession(t.sessionId,n?"active":"settled",{notifyIfSettled:!0})}else if(t.name==="session.snapshot"){const n=t.payload.snapshot,s=!!n.isStreaming;s&&typeof n.runStartedAt=="number"&&sn(t.sessionId,n.runStartedAt,n.serverNow),this.promoteSession(t.sessionId,s?"active":"settled")}else t.name==="assistant.message.start"?this.promoteSession(t.sessionId,"active"):(t.name==="session.interrupted"||t.name==="session.error")&&this.promoteSession(t.sessionId,"settled",{notifyIfSettled:!0})}notePromptProgress(t){if(t.name==="assistant.message.start"||t.name==="session.lifecycle"&&(t.payload.state==="busy"||t.payload.state==="retry")){this.pendingPromptById.delete(t.sessionId);return}(t.name==="session.error"||t.name==="session.interrupted"||t.name==="session.lifecycle"&&t.payload.state!=="busy"&&t.payload.state!=="retry")&&this.pendingPromptById.delete(t.sessionId)}retainPendingPrompt(t,n){if(!this.pendingPromptById.has(n))return t;const s=t.bySession.get(n);if(!s||s.lifecycle==="busy"||s.lifecycle==="retry")return t;const o=new Map(t.bySession);return o.set(n,{...s,lifecycle:"busy"}),{...t,bySession:o}}promoteSession(t,n,s){const o=this.activityPhaseById.get(t);this.activityPhaseById.set(t,n),Hc(t,n),s?.reorder&&yb(t,n),n==="settled"&&s?.notifyIfSettled&&o==="active"&&this.state.selectedSessionId!==t&&Cb(t,this.state.directory??void 0)}touchSessionList(t){const n=this.state.sessions.findIndex(a=>a.session.id===t);if(n<0)return;const s=Date.now(),o=this.state.sessions[n];if(!o)return;const r=this.state.sessions.slice();r.splice(n,1),r.unshift({...o,updatedAt:s,session:{...o.session,updatedAt:s}}),this.state={...this.state,sessions:r}}restoreTranscript(t){if(!t||this.restoringTranscriptById.has(t))return;this.restoringTranscriptById.add(t);const n=this.runtimeGeneration;this.hydrate(t,n,void 0,{force:!0}).finally(()=>{this.restoringTranscriptById.delete(t)})}commitEvents(t){if(t.length===0)return;let n=this.state.reducer,s=!1,o=!1;const r=new Set,a=new Set;for(const f of t){const h=!n.bySession.has(f.sessionId),m=(n.lastSequence.get(f.sessionId)??-1)>=0,p=Sc(n,f);if(n=p.state,!!p.didApply){if(h&&m&&r.add(f.sessionId),f.name==="session.snapshot"&&r.add(f.sessionId),s=!0,a.add(f.sessionId),this.notePromptProgress(f),this.pendingPromptById.has(f.sessionId)&&f.name==="session.snapshot"&&!f.payload.snapshot.isStreaming){n=this.retainPendingPrompt(n,f.sessionId),this.promoteSession(f.sessionId,"active");continue}this.observeActivity(f),this.lastAccessClock+=1,this.lastAccessById.set(f.sessionId,this.lastAccessClock),o=!0}}if(!s)return;this.state={...this.state,reducer:n};const l=this.applyCatalogFromEvents(t,n),c=l!==this.state.catalog;c&&(this.state={...this.state,catalog:l});const u=[];c&&u.push(v2);for(const f of a)u.push(`session:${f}`);u.length>0&&this.emit(u),o&&this.scheduleIdleEviction();for(const f of r)this.restoreTranscript(f)}applyCatalogFromEvents(t,n){let s=this.state.catalog;for(const o of t){const r=n.bySession.get(o.sessionId),a=r?.lifecycle,l=Nb(o);if(l!==void 0&&!s.byId.has(o.sessionId)&&(s=js(s,o.sessionId,o.directory,l)),a!==void 0&&(s=Do(s,o.sessionId,za(a),r?.retry)),o.name==="session.updated"){const c=typeof o.payload.title=="string"?o.payload.title.trim():"";if(c){s.byId.has(o.sessionId)||(s=js(s,o.sessionId,o.directory,l??"idle"));const u=s.byId.get(o.sessionId);s=Ea(s,o.sessionId,c,u?.updatedAt??Date.now())}}if(o.name==="assistant.message.start"&&o.payload.role==="user"){s=Ec(s,o.sessionId,Date.now(),{directory:o.directory,lifecycle:"busy"});const c=s.byId.get(o.sessionId),u=G9(o.payload.text??"");u&&c&&c.title.trim().length===0&&(s=Ea(s,o.sessionId,u,c.updatedAt))}}return s}scheduleIdleEviction(){this.evictionScheduled||this.state.reducer.bySession.size<=Da||(this.evictionScheduled=!0,queueMicrotask(()=>{this.evictionScheduled=!1,this.evictIdleTranscripts()}))}evictIdleTranscripts(){const t=this.state.reducer.bySession;if(t.size<=Da)return;const n=new Set;this.state.selectedSessionId&&n.add(this.state.selectedSessionId);for(const[m,p]of t)(p.lifecycle==="busy"||p.lifecycle==="retry")&&n.add(m);for(const m of this.pendingPromptById)n.add(m);const s=[];for(const m of t.keys()){if(n.has(m))continue;const p=this.lastAccessById.get(m)??0;s.push([m,p])}s.sort((m,p)=>m[1]-p[1]);let o=null,r=null,a=null,l=null;const c=[];let u=0;for(const[m]of s){if(t.size-u<=Da)break;o||(o=new Map(t)),r||(r=new Set(this.hydratedSessionIds)),a||(a=new Map(this.lastAccessById)),o.delete(m),r.delete(m),a.delete(m),this.activityPhaseById.delete(m),l=l??this.state.catalog,l=Pa(l,m,!1),u+=1,c.push(m)}if(!o||!r||!a)return;this.lastAccessById=a;const f=!!l&&l!==this.state.catalog;this.state={...this.state,reducer:{bySession:o,lastSequence:new Map(this.state.reducer.lastSequence)},hydratedSessionIds:r,...l?{catalog:l}:{}};const h=[H2];for(const m of c)h.push(`session:${m}`);f&&h.push(v2),this.emit(h)}async upsertAndHydrate(t){const n=this.runtimeGeneration,s=zc(this.state.catalog,this.recordFromPiSession(t.session)),o=s!==this.state.catalog;this.state={...this.state,sessions:[{session:t.session,updatedAt:t.session.updatedAt},...this.state.sessions.filter(a=>a.session.id!==t.session.id)],selectedSessionId:t.session.id,catalog:s};const r=[H2];o&&r.push(v2),this.emit(r),await this.hydrate(t.session.id,n,t)}directory(){if(!this.state.directory)throw new U2("DAEMON_UNAVAILABLE");return this.state.directory}streamCursor(){let t=-1;for(const n of this.state.reducer.lastSequence.values())n>t&&(t=n);return t>=0?t:void 0}scope(t){return{directory:t||this.directory(),runtimeKey:We()}}reconnectAfterTransportSwitch(){const t=this.state.selectedSessionId;!this.stream||!t||!this.state.directory||this.reconnect(t,this.runtimeGeneration,We())}resetForRuntime(){this.runtimeGeneration+=1,this.focusGeneration+=1,this.pendingFocus=null,this.pendingPreferredSessionId=null,this.hydratedSessionIds.clear(),this.activityPhaseById.clear(),this.pendingPromptById.clear(),this.promptGenerationById.clear(),this.lastAccessById.clear(),this.lastAccessClock=0,this.lastSelectedByDirectory.clear(),this.directoryRefreshGenerationByDirectory.clear(),this.evictionScheduled=!1,this.restoringTranscriptById.clear(),this.hydrateInflightById.clear(),this.cadence.dispose(),this.stream?.dispose(),this.stream=null,this.streamGeneration+=1,this.streamReadyRevision+=1,this.state=Ro(),kr(),this.navigationGenerationById.clear(),this.navigationCounter=0,this.emitBroadcast()}emit(t){if(t.length===0)return;const n=new Set;for(const o of t){const r=this.listenersByTopic.get(o);if(r)for(const a of r)n.has(a)||(n.add(a),a())}const s=this.listenersByTopic.get(Oc);if(s)for(const o of s)n.has(o)||(n.add(o),o())}emitBroadcast(){const t=new Set;for(const n of this.listenersByTopic.values())for(const s of n)t.has(s)||(t.add(s),s())}emitChrome(){this.emit([H2])}}const Rb=e=>{if(e.authenticated!==!0)return!1;const t=e.models;return Array.isArray(t)?t.length>0:t&&typeof t=="object"?Object.keys(t).length>0:!1},Ob=e=>e.filter(Rb),Ra=()=>y1().getState().directory??w1.getState().currentDirectory??void 0,p2={getDirectory:()=>Ra()??null,setDirectory:e=>{e&&y1().focusProject(e,null)},checkHealth:async()=>(await i1.health({runtimeKey:We()})).state==="ready",clearConfigCache:()=>{},getProvidersForConfig:async()=>{const e=await i1.listProviders({runtimeKey:We()});return{providers:Ob(e.providers).map(n=>({id:n.id,name:n.label??n.id,authenticated:n.authenticated===!0,models:Object.fromEntries(n.models.map(s=>[s.id,{id:s.id,name:s.label??s.id,providerID:s.providerId,reasoning:s.supportsThinking===!0,...Number.isSafeInteger(s.contextWindow)?{limit:{context:s.contextWindow}}:{},...Array.isArray(s.thinkingLevels)&&s.thinkingLevels.length>0?{thinkingLevels:s.thinkingLevels}:{}}]))})),default:e.default?{[e.default.providerId]:e.default.modelId}:{}}},listAgents:async(...e)=>[],getSessionStatusForDirectory:async()=>null,updateSession:async(e,t)=>{t.time?.archived&&await y1().archive(e,!0)},deleteSession:async e=>{await y1().remove(e)},sendMessage:async()=>{},sendCommand:async()=>{},shellSession:async()=>{},getSdkClient:()=>({experimental:{session:{list:async()=>({data:(await i1.listSessions({runtimeKey:We(),directory:Ra()??void 0})).sessions.map(n=>({id:n.session.id,directory:n.session.directory,title:n.session.title,time:{created:n.session.createdAt,updated:n.session.updatedAt,...n.session.archived?{archived:n.session.timeArchived}:{}}}))})}},path:{get:async()=>({data:{directory:Ra()}})},project:{current:async()=>({data:null})}})},qc=new Set;function Zb(e){return qc.add(e),()=>{qc.delete(e)}}function Uc(e,t){return e.scopes.includes("all")||e.scopes.includes(t)}const P0=e=>typeof e=="string"?e.trim():"",Gc=(e,t)=>!t||t<=0||e.length<=t?e:t<=3?e.slice(0,t):`${e.slice(0,t-3)}...`,Fb={ai:"AI",api:"API",ernie:"ERNIE",glm:"GLM",gpt:"GPT",it:"IT",lfm:"LFM",lm:"LM",oss:"OSS",pdf:"PDF",rp:"RP",slerp:"SLERP",tars:"TARS",ui:"UI",vl:"VL",vlm:"VLM",aion:"Aion",anthropic:"Anthropic",chatgpt:"ChatGPT",claude:"Claude",codex:"Codex",codestral:"Codestral",command:"Command",deepseek:"DeepSeek",gemini:"Gemini",gemma:"Gemma",grok:"Grok",hunyuan:"Hunyuan",kimi:"Kimi",llama:"Llama",minimax:"MiniMax",mistral:"Mistral",mixtral:"Mixtral",nemotron:"Nemotron",openai:"OpenAI",qwen:"Qwen",rekaai:"RekaAI"},Wc=e=>e?e[0].toUpperCase()+e.slice(1).toLowerCase():"",$b=e=>{const t=e.startsWith("~")?e.slice(1):e,n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t},qb=e=>{const t=e.lastIndexOf(":");return t<=0||t>=e.length-1?{base:e,suffix:""}:{base:e.slice(0,t),suffix:e.slice(t+1)}},Ub=e=>{const t=e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").split(/[-_\s]+/).map(s=>s.trim()).filter(Boolean),n=[];for(let s=0;s<t.length;s+=1){const o=t[s],r=t[s+1],a=t[s+2];if(/^(19|20)\d{2}$/.test(o)&&/^\d{2}$/.test(r??"")&&/^\d{2}$/.test(a??"")){n.push(`${o}-${r}-${a}`),s+=2;continue}if(/^\d$/.test(o)&&/^\d$/.test(r??"")){n.push(`${o}.${r}`),s+=1;continue}n.push(o)}return n},Gb=e=>{const t=e.toLowerCase(),n=Fb[t];if(n)return n;const s=t.match(/^qwen(\d(?:\.\d+)?)$/);return s?`Qwen${s[1]}`:/^o\d/.test(t)?t:/^v\d/.test(t)?`V${e.slice(1).toUpperCase()}`:/^\d+[on]$/.test(t)?t:/^[a-z]\d+[a-z]?$/.test(t)?t.toUpperCase():/^\d+(?:x\d+)?[a-z]+$/.test(t)?t.replace(/[a-z]+$/i,o=>o.toUpperCase()):/^\d+(?:\.\d+)?[a-z]$/.test(t)?t.replace(/[a-z]$/i,o=>o.toUpperCase()):/^[a-z]+\d+(?:\.\d+)?[a-z]*$/.test(t)?Wc(t).replace(/([a-z])(\d)/i,"$1$2"):Wc(e)},Wb=e=>{const t=[...e];return t[0]==="GPT"&&t[1]&&/^(?:\d|\d+[a-z]|OSS$)/i.test(t[1])&&t.splice(0,2,`GPT-${t[1]}`),t[0]==="GLM"&&t[1]&&/^\d/.test(t[1])&&t.splice(0,2,`GLM-${t[1]}`),t[0]==="LFM"&&t[1]&&/^\d/.test(t[1])&&t.splice(0,2,`LFM${t[1]}`),t[0]==="Qwen"&&t[1]&&/^\d/.test(t[1])&&t.splice(0,2,`Qwen${t[1]}`),t},Kb=e=>{const t=P0(e).toLowerCase();return t?t==="free"||t==="thinking"?t:ou(t):""},ou=e=>{const t=P0(e);if(!t)return"";const{base:n,suffix:s}=qb($b(t)),o=Wb(Ub(n).map(Gb));if(o.length>=2){const c=o[o.length-1],u=o[o.length-2];c==="Reasoning"&&u==="Non"&&o.splice(o.length-2,2,"(Non-Reasoning)")}const r=o[o.length-1];/^(19|20)\d{2}-\d{2}-\d{2}$/.test(r??"")&&(o[o.length-1]=`(${r})`);const a=o.join(" ").replace(/\s+\(/g," (").trim(),l=Kb(s);return l?`${a} (${l})`:a},b3=(e,t,n={})=>{const s=P0(e?.name);if(s)return Gc(s,n.maxLength);const o=P0(e?.id)||P0(t);return o?Gc(ou(o),n.maxLength):n.fallbackLabel??""},Yb=(e,t)=>{const n=e?.models;if(!(!n||!t))return Array.isArray(n)?n.find(s=>P0(s.id)===t):n[t]},ru=(e,t,n={})=>{const s=P0(t),o=Yb(e,s);return b3(o,s,n)},Kc=e=>e==="primary"||e==="all"||e===void 0||e===null,Jb=e=>{if(!e||e.trim().length===0)return s0(void 0);const t=e.trim();return/^\d+(\.\d+)?$/.test(t)?t:s0(t)},Xb=e=>typeof e=="object"&&e!==null,Oo=new Map,n2=W1()(yo((e,t)=>({sessionModelSelections:new Map,sessionAgentSelections:new Map,sessionAgentModelSelections:new Map,lastUsedProvider:null,saveSessionModelSelection:(n,s,o)=>e(r=>{const a=new Map(r.sessionModelSelections);return a.delete(n),a.set(n,{providerId:s,modelId:o}),{sessionModelSelections:a,lastUsedProvider:{providerID:s,modelID:o}}}),getSessionModelSelection:n=>t().sessionModelSelections.get(n)??null,saveSessionAgentSelection:(n,s)=>e(o=>{if(o.sessionAgentSelections.get(n)===s)return o;const r=new Map(o.sessionAgentSelections);return r.delete(n),r.set(n,s),{sessionAgentSelections:r}}),getSessionAgentSelection:n=>t().sessionAgentSelections.get(n)??null,saveAgentModelForSession:(n,s,o,r)=>e(a=>{const l=a.sessionAgentModelSelections.get(n)?.get(s);if(l?.providerId===o&&l?.modelId===r)return a;const c=new Map(a.sessionAgentModelSelections),u=new Map(c.get(n)??new Map);return c.delete(n),u.set(s,{providerId:o,modelId:r}),c.set(n,u),{sessionAgentModelSelections:c}}),getAgentModelForSession:(n,s)=>t().sessionAgentModelSelections.get(n)?.get(s)??null,saveAgentModelVariantForSession:(n,s,o,r,a)=>{const l=`${o}/${r}`;let c=Oo.get(n);if(!c&&a&&(c=new Map,Oo.set(n,c)),!c)return;let u=c.get(s);if(!u&&a&&(u=new Map,c.set(s,u)),!!u){if(!a){u.delete(l),u.size===0&&c.delete(s),c.size===0&&Oo.delete(n);return}u.set(l,a)}},getAgentModelVariantForSession:(n,s,o,r)=>{const a=`${o}/${r}`;return Oo.get(n)?.get(s)?.get(a)}}),{name:"selection-store",version:1,storage:Bi(),partialize:e=>{const t=Array.from(e.sessionModelSelections.entries()).slice(-150),n=Array.from(e.sessionAgentSelections.entries()).slice(-150),s=Array.from(e.sessionAgentModelSelections.entries()).slice(-150).map(([o,r])=>[o,Array.from(r.entries())]);return{sessionModelSelections:t,sessionAgentSelections:n,sessionAgentModelSelections:s,lastUsedProvider:e.lastUsedProvider}},merge:(e,t)=>{const n=Xb(e)?e:void 0,s=new Map;return Array.isArray(n?.sessionAgentModelSelections)&&n.sessionAgentModelSelections.forEach(([o,r])=>{s.set(o,new Map(r))}),{...t,lastUsedProvider:n?.lastUsedProvider??t.lastUsedProvider,sessionModelSelections:new Map(n?.sessionModelSelections??[]),sessionAgentSelections:new Map(n?.sessionAgentSelections??[]),sessionAgentModelSelections:s}},migrate:e=>e})),pt=yt(),n4="projects",s4="activeProjectId",Qb=()=>{if(typeof window>"u")return"";const e=window.__PICHAMBER_LOCAL_ORIGIN__;return typeof e=="string"?e.trim().replace(/\/+$/,""):""},x3=()=>{const e=Ti().trim().replace(/\/+$/,"");return e||""},Oi=()=>{const e=x3();return e?`${n4}:${encodeURIComponent(e)}`:n4},iu=()=>{const e=x3();return e?`${s4}:${encodeURIComponent(e)}`:s4},au=()=>{const e=x3();if(!e)return!0;const t=Qb();return!!(t&&e===t)},ex=(e,t)=>{const n=e.trim();return!n.startsWith("~")||!t?n:n==="~"?t:n.startsWith("~/")||n.startsWith("~\\")?`${t}${n.slice(1)}`:n},tx=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,lu=e=>{if(typeof e!="string")return;const t=e.trim();if(!t)return;const n=t.indexOf("/");if(!(n<=0||n>=t.length-1))return t},cu=e=>{if(typeof e!="string")return null;const t=e.trim();return t&&tx.test(t)?t.toLowerCase():null},w3=e=>{const t=e.trim();if(!t)return"";const n=pt.getItem("homeDirectory")||w1.getState().homeDirectory||"",o=ex(t,n).replace(/\\/g,"/");return o==="/"?"/":o.length>1?o.replace(/\/+$/,""):o},nx=e=>{const t=w3(e);if(!t||t==="/")return"Root";const n=t.split("/").filter(Boolean);return(n[n.length-1]||t).replace(/[-_]/g," ").replace(/\b\w/g,o=>o.toUpperCase())},sx=e=>{if(!e||typeof e!="object")return;const t=e,n=typeof t.mime=="string"?t.mime.trim():"",s=typeof t.updatedAt=="number"&&Number.isFinite(t.updatedAt)?Math.max(0,Math.round(t.updatedAt)):0,o=t.source==="custom"||t.source==="auto"?t.source:null;if(!(!n||!s||!o))return{mime:n,updatedAt:s,source:o}},ox=e=>{const t=typeof e.type=="string"?e.type.trim().toLowerCase():"";if(t==="image/png"||t==="image/jpeg"||t==="image/svg+xml")return t;const n=e.name.toLowerCase();return n.endsWith(".png")?"image/png":n.endsWith(".jpg")||n.endsWith(".jpeg")?"image/jpeg":n.endsWith(".svg")?"image/svg+xml":null},rx=async e=>await new Promise((t,n)=>{const s=new FileReader;s.onerror=()=>{n(new Error("Failed to read icon file"))},s.onload=()=>{const o=typeof s.result=="string"?s.result:"";if(!o){n(new Error("Failed to read icon file"));return}t(o)},s.readAsDataURL(e)}),du=e=>{if(!Array.isArray(e))return[];const t=[],n=new Set,s=new Set;for(const o of e){if(!o||typeof o!="object")continue;const r=o,a=typeof r.path=="string"?r.path.trim():"";if(!a)continue;const l=w3(a);if(!l)continue;const c=r3(l);if(!c||n.has(c)||s.has(l))continue;n.add(c),s.add(l);const u={id:c,path:l};if(typeof r.label=="string"&&r.label.trim().length>0&&(u.label=r.label.trim()),typeof r.icon=="string"&&r.icon.trim().length>0&&(u.icon=r.icon.trim()),r.iconImage===null)u.iconImage=null;else{const h=sx(r.iconImage);h&&(u.iconImage=h)}typeof r.color=="string"&&r.color.trim().length>0&&(u.color=r.color.trim());const f=lu(r.defaultModel);if(f&&(u.defaultModel=f),r.iconBackground===null)u.iconBackground=null;else{const h=cu(r.iconBackground);h&&(u.iconBackground=h)}typeof r.addedAt=="number"&&Number.isFinite(r.addedAt)&&r.addedAt>=0&&(u.addedAt=r.addedAt),typeof r.lastOpenedAt=="number"&&Number.isFinite(r.lastOpenedAt)&&r.lastOpenedAt>=0&&(u.lastOpenedAt=r.lastOpenedAt),typeof r.sidebarCollapsed=="boolean"&&(u.sidebarCollapsed=r.sidebarCollapsed),t.push(u)}return t},ix=()=>{try{const e=pt.getItem(Oi())||(au()?pt.getItem(n4):null);return e?du(JSON.parse(e)):[]}catch{return[]}},ax=()=>{try{const e=pt.getItem(Oi()+":manualOrder");if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}},Yc=()=>{try{const e=pt.getItem(iu())||(au()?pt.getItem(s4):null);if(typeof e=="string"&&e.trim().length>0)return e.trim()}catch{return null}return null},uu=(e,t)=>{try{pt.setItem(Oi(),JSON.stringify(e))}catch{}try{const n=iu();t?pt.setItem(n,t):pt.removeItem(n)}catch{}},on=(e,t,n)=>{uu(e,t),n&&fu(n),Nn({projects:e,activeProjectId:t??void 0})},fu=e=>{try{pt.setItem(Oi()+":manualOrder",JSON.stringify(e))}catch{}},o4=ix(),lx=o4.some(e=>e.id===Yc())?Yc():o4[0]?.id??null,j1=W1()($0((e,t)=>({projects:o4,activeProjectId:lx,manualProjectOrder:ax(),validateProjectPath:n=>{if(typeof n!="string"||n.trim().length===0)return{ok:!1,reason:"Provide a directory path."};const s=w3(n);return s?{ok:!0,normalizedPath:s}:{ok:!1,reason:"Directory path cannot be empty."}},addProject:(n,s)=>{const{validateProjectPath:o}=t(),r=o(n);if(!r.ok||!r.normalizedPath)return null;const a=r.normalizedPath,l=t().projects.find(p=>p.path===a);if(l)return t().setActiveProject(l.id),l;const c=Date.now(),u=s?.label?.trim()||nx(a),h={id:r3(a),path:a,label:u,addedAt:c,lastOpenedAt:c},m=[...t().projects,h];return e({projects:m}),f9()&&console.info("[ProjectsStore] Added project",h),t().setActiveProject(h.id),h},removeProject:n=>{const s=t(),o=s.projects.filter(l=>l.id!==n);let r=s.activeProjectId;s.activeProjectId===n&&(r=o[0]?.id??null);const a=t().manualProjectOrder.filter(l=>l!==n);if(e({projects:o,activeProjectId:r,manualProjectOrder:a}),on(o,r,a),r){const l=o.find(c=>c.id===r);l&&(p2.setDirectory(l.path),w1.getState().setDirectory(l.path,{showOverlay:!1}))}else w1.getState().goHome()},setActiveProject:n=>{const{projects:s,activeProjectId:o}=t();if(o===n)return;const r=s.find(c=>c.id===n);if(!r)return;const a=Date.now(),l=s.map(c=>c.id===n?{...c,lastOpenedAt:a}:c);e({projects:l,activeProjectId:n}),on(l,n,t().manualProjectOrder),p2.setDirectory(r.path),w1.getState().setDirectory(r.path,{showOverlay:!1})},setActiveProjectIdOnly:n=>{const{projects:s,activeProjectId:o}=t();if(o===n||!s.find(c=>c.id===n))return;const a=Date.now(),l=s.map(c=>c.id===n?{...c,lastOpenedAt:a}:c);e({projects:l,activeProjectId:n}),on(l,n,t().manualProjectOrder)},renameProject:(n,s)=>{const o=s.trim();if(!o)return;const{projects:r,activeProjectId:a}=t(),l=r.map(c=>c.id===n?{...c,label:o}:c);e({projects:l}),on(l,a,t().manualProjectOrder)},updateProjectMeta:(n,s)=>{const{projects:o,activeProjectId:r}=t(),a=o.map(l=>{if(l.id!==n)return l;const c={...l};if(s.label!==void 0){const u=s.label.trim();u&&(c.label=u)}if(s.icon!==void 0&&(c.icon=s.icon),s.color!==void 0&&(c.color=s.color),s.iconBackground!==void 0&&(c.iconBackground=cu(s.iconBackground)),s.defaultModel!==void 0){const u=lu(s.defaultModel);u?c.defaultModel=u:delete c.defaultModel}return c});e({projects:a}),on(a,r,t().manualProjectOrder)},uploadProjectIcon:async(n,s)=>{const o=ox(s);if(!o)return{ok:!1,error:"Only PNG, JPEG, and SVG are supported"};if(!Number.isFinite(s.size)||s.size<=0)return{ok:!1,error:"Icon file is empty"};if(s.size>5*1024*1024)return{ok:!1,error:"Icon exceeds size limit (5 MB)"};try{const a=(await rx(s)).replace(/^data:[^;]+;/i,`data:${o};`),l=await V1(`/api/projects/${encodeURIComponent(n)}/icon`,{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({dataUrl:a})});if(!l.ok)return{ok:!1,error:(await l.json().catch(()=>null))?.error||"Failed to upload project icon"};const c=await l.json().catch(()=>null);return c?.settings&&t().synchronizeFromSettings(c.settings),{ok:!0}}catch(r){return{ok:!1,error:(r instanceof Error?r.message:String(r))||"Failed to upload project icon"}}},removeProjectIcon:async n=>{try{const s=await V1(`/api/projects/${encodeURIComponent(n)}/icon`,{method:"DELETE",headers:{Accept:"application/json"}});if(!s.ok)return{ok:!1,error:(await s.json().catch(()=>null))?.error||"Failed to remove project icon"};const o=await s.json().catch(()=>null);return o?.settings&&t().synchronizeFromSettings(o.settings),{ok:!0}}catch(s){return{ok:!1,error:(s instanceof Error?s.message:String(s))||"Failed to remove project icon"}}},discoverProjectIcon:async()=>({ok:!0,skipped:!0,reason:"unsupported"}),reorderProjects:(n,s)=>{const{projects:o,activeProjectId:r}=t();if(n<0||n>=o.length||s<0||s>=o.length||n===s)return;const a=[...o],[l]=a.splice(n,1);a.splice(s,0,l);const c=a.map(u=>u.id);e({projects:a,manualProjectOrder:c}),on(a,r,c)},resetForRuntimeSwitch:()=>{e({projects:[],activeProjectId:null,manualProjectOrder:[]})},synchronizeFromSettings:n=>{const s=du(n.projects??[]),o=typeof n.activeProjectId=="string"&&n.activeProjectId.trim()?n.activeProjectId.trim():null,r=t(),a=JSON.stringify(r.projects)!==JSON.stringify(s),l=r.activeProjectId!==o;if(!a&&!l)return;const c=new Set(s.map(f=>f.id)),u=t().manualProjectOrder.filter(f=>c.has(f));if(e({projects:s,activeProjectId:o,manualProjectOrder:u}),uu(s,o),fu(u),o){const f=s.find(h=>h.id===o);f&&(p2.setDirectory(f.path),w1.getState().setDirectory(f.path,{showOverlay:!1}))}},getActiveProject:()=>{const{projects:n,activeProjectId:s}=t();return s?n.find(o=>o.id===s)??null:null}}),{name:"projects-store"}));typeof window<"u"&&window.addEventListener("pichamber:settings-synced",e=>{const t=e.detail;t&&typeof t=="object"&&j1.getState().synchronizeFromSettings(t)});const Oa=Je,cx=(e,t)=>{const n=Oa(t);if(!n)return null;let s=null;for(const o of e){const r=Oa(o.path);r&&(n!==r&&!n.startsWith(`${r}/`)||(!s||r.length>(Oa(s.path)?.length??0))&&(s=o))}return s},Kt=(e,t,n)=>cx(e,(typeof t=="string"?t:n)??null),M3=e=>{if(!e)return null;const t=e.indexOf("/");return t<=0||t>=e.length-1?null:{providerId:e.slice(0,t),modelId:e.slice(t+1)}},Jc=500,dx=()=>{if(typeof window>"u")return!1;try{return new URLSearchParams(window.location.search).get("startupTrace")==="1"||window.localStorage?.getItem("PICHAMBER_STARTUP_TRACE")==="1"}catch{return!1}},m1=(e,t)=>{if(!dx())return;const n=typeof performance<"u"?performance.now():Date.now();window.__PICHAMBER_STARTUP_TRACE_START__??=n,window.__PICHAMBER_STARTUP_TRACE__??=[],window.__PICHAMBER_STARTUP_TRACE__.push({t:Math.round(n-window.__PICHAMBER_STARTUP_TRACE_START__),name:e,...t?{data:t}:{}}),window.__PICHAMBER_STARTUP_TRACE__.length>Jc&&window.__PICHAMBER_STARTUP_TRACE__.splice(0,window.__PICHAMBER_STARTUP_TRACE__.length-Jc)},ux=()=>{const e=typeof window<"u"?window.__PICHAMBER_STARTUP_TRACE__??[]:[],t=e.findIndex(s=>s.name==="ModelControls:ready"),n=t>=0?Math.min(e.length,t+8):e.length;return e.slice(0,n).filter(s=>s.name.includes("checkConnection")||s.name.includes("checkHealth")||s.name.includes("initializeApp")||s.name.includes("initApp")||s.name.includes("loadProviders")||s.name.includes("loadAgents")||s.name.includes("config.defaults")||s.name.includes("modelsMetadata")||s.name.includes("ModelControls")||s.name.includes("activateDirectory")||s.name.includes("opencodeClient:setDirectory"))};typeof window<"u"&&(window.__PICHAMBER_STARTUP_TRACE_SUMMARY__=ux);const Ar=async(e,t,n)=>{const s=typeof performance<"u"?performance.now():Date.now();m1(`${e}:start`,n);try{const o=await t(),r=typeof performance<"u"?performance.now():Date.now();return m1(`${e}:end`,{durationMs:Math.round(r-s)}),o}catch(o){const r=typeof performance<"u"?performance.now():Date.now();throw m1(`${e}:error`,{durationMs:Math.round(r-s),error:o instanceof Error?o.message:String(o)}),o}},C3=2048,Xc=new WeakMap,fx=e=>e==="running"||e==="pending",hu=e=>{if(e==null)return 0;if(typeof e=="string")return e.length;if(typeof e=="number"||typeof e=="boolean")return String(e).length;try{return JSON.stringify(e)?.length??0}catch{return C3+1}},hx=e=>{if(!e)return e;const t=e.patch??e.diff??e.filediff?.patch??e.filediff?.diff;if(hu(t)<=C3)return e;const n={...e};if(delete n.patch,delete n.diff,n.filediff&&typeof n.filediff=="object"){const s={...n.filediff};delete s.patch,delete s.diff,n.filediff=s}return n.deferredBody=!0,n},S3=(e,t)=>{if(e.type==="thinking")return{id:e.id,type:"reasoning",text:e.text,streaming:e.streaming};if(e.type==="attachment")return{id:e.id,type:"file",filename:e.attachment?.name,mime:e.attachment?.mime};if(e.type==="tool"){const n=fx(e.tool?.state),s=t?.full===!0||n,o=!s&&hu(e.tool?.output)>C3,r=s?e.tool?.metadata:hx(e.tool?.metadata),a=!!(!s&&(o||r?.deferredBody));return{id:e.id,type:"tool",tool:e.tool?.name,callID:e.tool?.toolCallId,state:{status:e.tool?.state==="running"||e.tool?.state==="pending"?"running":e.tool?.state==="error"?"error":e.tool?.state==="cancelled"?"cancelled":"completed",input:e.tool?.input,...o?{}:{output:e.tool?.output},error:e.tool?.error,time:{start:e.tool?.startedAt,end:e.tool?.endedAt},metadata:r,...a?{deferredBody:!0}:{}}}}return{id:e.id,type:"text",text:e.text}},mu=e=>({id:e.id,directory:e.directory,parentID:e.parentId??null,title:e.title,time:{created:e.createdAt,updated:e.updatedAt,...e.archived?{archived:e.timeArchived??e.updatedAt}:{}}}),mx=e=>mu(e.session),px=(e,t)=>{const n=[];if(e.parts.length>0){const a=e.parts.some(c=>c.type==="thinking"),l=e.parts.some(c=>c.type==="text");!a&&e.thinking&&n.push({id:`${e.id}:thinking`,type:"reasoning",text:e.thinking,streaming:!1}),n.push(...e.parts.map(c=>S3(c))),!l&&e.text&&n.push({id:`${e.id}:text`,type:"text",text:e.text})}else e.thinking&&n.push({id:`${e.id}:thinking`,type:"reasoning",text:e.thinking,streaming:!1}),e.text&&n.push({id:`${e.id}:text`,type:"text",text:e.text});const o=e.role==="assistant"&&!e.streaming?e.error?"error":"stop":void 0;return{info:{id:e.id,sessionID:t,role:e.role,...e.parentId?{parentID:e.parentId}:{},time:{created:e.createdAt,...e.streaming?{}:typeof e.durationMs=="number"&&e.durationMs>0?{completed:e.createdAt+e.durationMs}:{completed:e.createdAt}},...e.durationMs!==void 0?{durationMs:e.durationMs}:{},...e.error?{error:{name:e.error.code,message:e.error.message}}:{},...e.model?{model:{providerID:e.model.providerId,modelID:e.model.modelId},providerID:e.model.providerId,modelID:e.model.modelId}:{},...e.thinkingLevel?{variant:e.thinkingLevel}:{},...e.role==="assistant"&&e.usage?{usage:{input:e.usage.input,output:e.usage.output,cacheRead:e.usage.cacheRead,cacheWrite:e.usage.cacheWrite,totalTokens:e.usage.totalTokens,cost:e.usage.cost},cost:e.usage.cost.total}:{},...o?{finish:o}:{}},parts:n}},gx=e=>e?e.messages.map(t=>{const n=Xc.get(t);if(n&&n.info.sessionID===e.sessionId)return n;const s=px(t,e.sessionId);return Xc.set(t,s),s}):[];function r4(...e){}let Zo=null;function yx(e){if(Zo&&Zo.source===e)return Zo.mapped;const t=e.map(mx);return Zo={source:e,mapped:t},t}function vx(){return ei(y1().getState().catalog,{archived:!1})}function oo(){const e=y1().getState().catalog;return[...ei(e,{archived:!1}),...ei(e,{archived:!0})]}function bx(e){const t=y1().getState();return t.catalog.byId.get(e)?.directory??t.sessions.find(n=>n.session.id===e)?.session.directory??t.directory}function Is(e,t){return[]}function sO(e,t){return{hasMessages:!0,renderable:!0,missingPartMessageIDs:[]}}function pu(e,t){return[]}const xx="https://models.dev/api.json",ti="__add_provider__",x0="zen",Qc="big-pickle",wx=4,Mx=e=>{if(!e||typeof e!="object"||Array.isArray(e))return;const t={};for(const[n,s]of Object.entries(e)){if(!M3(n))continue;const o=nt(s);o&&(t[n]=o)}return t},Cx=async()=>{try{const e=await V1("/api/pi/settings",{method:"GET",headers:{Accept:"application/json"}});if(!e.ok)return{ok:!1};const n=(await e.json())?.pichamber,s=n?.defaultModel;let o;if(s&&typeof s.providerId=="string"&&typeof s.modelId=="string"){const r=s.providerId.trim(),a=s.modelId.trim();r&&a&&(o=`${r}/${a}`)}return{ok:!0,defaultModel:o,defaultThinking:nt(n?.defaultThinking)??void 0,defaultThinkingByModel:Mx(n?.defaultThinkingByModel)}}catch{return{ok:!1}}},Sx=async()=>{m1("config.defaults:start");const e=typeof performance<"u"?performance.now():Date.now(),t=(n,s)=>{const o=typeof performance<"u"?performance.now():Date.now();return m1("config.defaults:end",{source:n,durationMs:Math.round(o-e),hasDefaultModel:!!s.defaultModel}),s};try{const n=await Cx(),s=(p,g)=>n.ok?t(p,{...g,defaultModel:n.defaultModel,defaultThinking:n.defaultThinking,defaultThinkingByModel:n.defaultThinkingByModel}):t(p,g),o=i3()?.settings;if(o)try{const g=(await o.load())?.settings;if(g){const y=typeof g?.defaultModel=="string"?g.defaultModel.trim():"",M=typeof g?.defaultVariant=="string"?g.defaultVariant.trim():"",b=typeof g?.gitmojiEnabled=="boolean"?g.gitmojiEnabled:void 0,v=typeof g?.defaultFileViewerPreview=="boolean"?g.defaultFileViewerPreview:void 0,x=typeof g?.zenModel=="string"?g.zenModel.trim():"",S=g?.messageStreamTransport==="ws"||g?.messageStreamTransport==="sse"||g?.messageStreamTransport==="auto"?g.messageStreamTransport:void 0;return s("runtime-settings",{defaultModel:y.length>0?y:void 0,defaultVariant:M.length>0?M:void 0,autoCreateWorktree:typeof g?.autoCreateWorktree=="boolean"?g.autoCreateWorktree:void 0,gitmojiEnabled:b,defaultFileViewerPreview:v,zenModel:x.length>0?x:void 0,messageStreamTransport:S})}}catch{}const r=await V1("/api/pi/ui-settings",{method:"GET",headers:{Accept:"application/json"}});if(!r.ok)return s("settings-route-not-ok",{});const a=await r.json(),l=typeof a?.defaultModel=="string"?a.defaultModel.trim():"",c=typeof a?.defaultVariant=="string"?a.defaultVariant.trim():"",u=typeof a?.gitmojiEnabled=="boolean"?a.gitmojiEnabled:void 0,f=typeof a?.defaultFileViewerPreview=="boolean"?a.defaultFileViewerPreview:void 0,h=typeof a?.zenModel=="string"?a.zenModel.trim():"",m=a?.messageStreamTransport==="ws"||a?.messageStreamTransport==="sse"||a?.messageStreamTransport==="auto"?a.messageStreamTransport:void 0;return s("settings-route",{defaultModel:l.length>0?l:void 0,defaultVariant:c.length>0?c:void 0,autoCreateWorktree:typeof a?.autoCreateWorktree=="boolean"?a.autoCreateWorktree:void 0,gitmojiEnabled:u,defaultFileViewerPreview:f,zenModel:h.length>0?h:void 0,messageStreamTransport:m})}catch(n){return m1("config.defaults:error",{error:n instanceof Error?n.message:String(n)}),t("error",{})}},_n=e=>M3(e),_x=e=>e?.toLowerCase?.()??"",e6=e=>e===ti?"":e??"",w0=(e,t)=>e===ti?ti:t,Ft=e=>{if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0},Lt=(e,t,n)=>{const s=e.find(o=>o.id===t);return s?s.models.some(o=>o.id===n):!1},kx=({providers:e,currentProviderId:t,currentModelId:n,currentVariant:s,settingsDefaultModel:o,settingsDefaultVariant:r})=>{const a=(u,f,h)=>{if(!h)return;const m=e.find(p=>p.id===u)?.models.find(p=>p.id===f);return m?.variants&&Object.prototype.hasOwnProperty.call(m.variants,h)?h:void 0};if(t&&n&&Lt(e,t,n))return{providerId:t,modelId:n,variant:a(t,n,s)};if(o){const u=_n(o);if(u&&Lt(e,u.providerId,u.modelId))return{providerId:u.providerId,modelId:u.modelId,variant:a(u.providerId,u.modelId,r)}}const l=e.find(u=>u.authenticated&&u.models.length>0)||e.find(u=>u.models.length>0)||e[0],c=l?.models[0];return l&&c?{providerId:l.id,modelId:c.id}:null},Za=({agents:e,providers:t,projectDefaultModel:n,settingsDefaultModel:s,settingsDefaultVariant:o,opencodeDefaultAgent:r,opencodeDefaultModel:a})=>{if(e.length===0)return{agentName:void 0};const l=(g,y,M)=>{if(!M)return;const b=t.find(v=>v.id===g)?.models.find(v=>v.id===y);return b?.variants&&Object.prototype.hasOwnProperty.call(b.variants,M)?M:void 0},c=e.filter(g=>Kc(g.mode));let u;if(r){const g=e.find(y=>y.name===r);g&&Kc(g.mode)&&g.hidden!==!0&&(u=g)}if(u||(u=c.find(g=>g.name==="build")||c[0]||e[0]),!u)return{agentName:void 0};let f,h,m;const p=n||s;if(p){const g=_n(p);g&&Lt(t,g.providerId,g.modelId)&&(f=g.providerId,h=g.modelId,m=l(f,h,n?void 0:o))}if(!f&&u.model?.providerID&&u.model?.modelID&&Lt(t,u.model.providerID,u.model.modelID)&&(f=u.model.providerID,h=u.model.modelID,m=l(f,h,u.variant)),!f&&a){const g=_n(a);g&&Lt(t,g.providerId,g.modelId)&&(f=g.providerId,h=g.modelId)}if(!f){const g=t.find(M=>M.authenticated&&M.models.length>0)||t.find(M=>M.models.length>0)||t[0],y=g?.models[0];g&&y&&(f=g.id,h=y.id)}return{agentName:u.name,providerId:f,modelId:h,variant:m}},Fa=({providers:e,settingsZenModel:t})=>{const n=Ft(t);if(!Array.isArray(e)||e.length===0)return n?{providerId:x0,modelId:n}:null;if(n&&Lt(e,x0,n))return{providerId:x0,modelId:n};if(Lt(e,x0,Qc))return{providerId:x0,modelId:Qc};const s=e.find(o=>o.id===x0);if(s?.models.length){const o=Math.floor(Math.random()*s.models.length),r=Ft(s.models[o]?.id);if(r)return{providerId:x0,modelId:r}}return null},ro=e=>typeof e=="object"&&e!==null,ni=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"),Ax=e=>{if(!ro(e))return!1;const t=e;if(t.modalities){const{input:n,output:s}=t.modalities;if(n&&!ni(n)||s&&!ni(s))return!1}return!0},Hx=e=>{if(!ro(e))return!1;const t=e;return t.models===void 0||ro(t.models)},gu=(e,t)=>{const n=_x(e);return!n||!t?"":`${n}/${t}`},t6=e=>{if(!e)return[];const t=[];return e.text&&t.push("text"),e.audio&&t.push("audio"),e.image&&t.push("image"),e.video&&t.push("video"),e.pdf&&t.push("pdf"),t},Lx=(e,t)=>({id:t.id,providerId:e,name:t.name,tool_call:t.capabilities?.toolcall,reasoning:t.capabilities?.reasoning,temperature:t.capabilities?.temperature,attachment:t.capabilities?.attachment,modalities:t.capabilities?{input:t6(t.capabilities.input),output:t6(t.capabilities.output)}:void 0,cost:t.cost?{input:t.cost.input,output:t.cost.output,cache_read:t.cost.cache?.read,cache_write:t.cost.cache?.write}:void 0,limit:t.limit,release_date:t.release_date}),jx=e=>{const t=new Map;if(!ro(e))return t;for(const[n,s]of Object.entries(e)){if(!Hx(s))continue;const o=typeof s.id=="string"&&s.id.length>0?s.id:n,r=s.models;if(!(!r||!ro(r)))for(const[a,l]of Object.entries(r)){if(!Ax(l))continue;const c=typeof a=="string"&&a.length>0?a:l.id;if(!c||typeof c!="string"||c.length===0)continue;const u={id:typeof l.id=="string"&&l.id.length>0?l.id:c,providerId:o,name:typeof l.name=="string"?l.name:void 0,tool_call:typeof l.tool_call=="boolean"?l.tool_call:void 0,reasoning:typeof l.reasoning=="boolean"?l.reasoning:void 0,temperature:typeof l.temperature=="boolean"?l.temperature:void 0,attachment:typeof l.attachment=="boolean"?l.attachment:void 0,structured_output:typeof l.structured_output=="boolean"?l.structured_output:void 0,modalities:l.modalities?{input:ni(l.modalities.input)?l.modalities.input:void 0,output:ni(l.modalities.output)?l.modalities.output:void 0}:void 0,cost:l.cost,limit:l.limit,knowledge:typeof l.knowledge=="string"?l.knowledge:void 0,release_date:typeof l.release_date=="string"?l.release_date:void 0,last_updated:typeof l.last_updated=="string"?l.last_updated:void 0},f=gu(o,c);f&&t.set(f,u)}}return t},Ix=async()=>{if(typeof fetch!="function")return new Map;const e=[xx];for(const t of e){const n=typeof AbortController<"u"?new AbortController:void 0,s=n?setTimeout(()=>n.abort(),8e3):void 0;try{const o=/^https?:\/\//i.test(t),r={signal:n?.signal,headers:{Accept:"application/json"},cache:"no-store"};o?r.mode="cors":r.credentials="same-origin";const a=o?await fetch(t,r):await V1(t,r);if(!a.ok)throw new Error(`Metadata request to ${t} returned status ${a.status}`);const l=await a.json();return jx(l)}catch(o){o?.name==="AbortError"?console.warn(`Model metadata request aborted (${t})`):console.warn(`Failed to fetch model metadata from ${t}:`,o)}finally{s&&clearTimeout(s)}}return new Map};let Hr=null;const Bx=(e,t)=>{e().size>0||Hr||(m1("modelsMetadata:queued"),Hr=Ar("modelsMetadata",Ix).then(s=>(s.size>0&&(m1("modelsMetadata:set",{entries:s.size}),t(s)),s)).catch(()=>new Map).finally(()=>{Hr=null}))},Lr=e=>new Promise(t=>setTimeout(t,e)),Tx=800,Vx=async(e=Tx)=>Promise.race([p2.checkHealth().catch(()=>!1),Lr(Math.max(1,e)).then(()=>!1)]),_3="__global__",Ut=e=>{const t=typeof e=="string"?e.trim():"";return t.length>0?t:_3},z2=e=>e===_3?null:e,Nx=()=>{if(typeof window>"u")return _3;const e=p2.getDirectory()??w1.getState().currentDirectory;return Ts(e)},yu="oc.worktreeProjectMap.v2",i4="oc.worktreeProjectMap",Px=8,n6=new Map,vu=()=>{try{const e=typeof localStorage<"u"?localStorage.getItem(yu):null;if(!e)return{version:2,legacyClaimed:!1,runtimes:{}};const t=JSON.parse(e);return t.version!==2||!t.runtimes||typeof t.runtimes!="object"?{version:2,legacyClaimed:!1,runtimes:{}}:{version:2,legacyClaimed:t.legacyClaimed===!0,runtimes:t.runtimes}}catch{return{version:2,legacyClaimed:!1,runtimes:{}}}},bu=e=>{const t=Object.fromEntries(Object.entries(e.runtimes).sort(([,n],[,s])=>s.updatedAt-n.updatedAt).slice(0,Px));localStorage.setItem(yu,JSON.stringify({...e,runtimes:t}))},xu=()=>{const e=We()||"default",t=n6.get(e);if(t)return t;const n=vu();let s=n.runtimes[e]?.entries??null;if(!s&&!n.legacyClaimed)try{const r=typeof localStorage<"u"?localStorage.getItem(i4):null;s=r?JSON.parse(r):{},n.legacyClaimed=!0,n.runtimes[e]={updatedAt:Date.now(),entries:s},bu(n),localStorage.removeItem(i4)}catch{s={}}const o=s??{};return n6.set(e,o),o},Ex=(e,t)=>{if(!e||!t||e===t)return;const n=xu();if(n[e]!==t){n[e]=t;try{const s=We()||"default",o=vu();o.legacyClaimed=!0,o.runtimes[s]={updatedAt:Date.now(),entries:n},bu(o),localStorage.removeItem(i4)}catch{}}},Rs=e=>{const t=Je(e);return t===null?null:t||"/"},zx=()=>{try{return j1.getState().projects.map(e=>Rs(e.path)).filter(e=>!!e)}catch{return[]}},Dx=()=>{try{const{projects:e,activeProjectId:t}=j1.getState(),n=t?e.find(s=>s.id===t):null;return Rs(n?.path??e[0]?.path??null)}catch{return null}},Bs=e=>{const t=Rs(e),n=zx();if(!t)return null;if(n.includes(t))return t;const s=Rs(xu()[t]);if(s)return s;try{const o=Kt(j1.getState().projects,null,t),r=Rs(o?.path??null);if(r&&r!==t)return Ex(t,r),r}catch{return null}return null},Ts=e=>Ut(Bs(e)),s6=new Map,$a=new Map,Rx=3e4,Ox=1e3,o6=(e,t)=>{const n=e.get(t);return typeof n=="number"&&Date.now()-n<Rx},Zx=e=>{const t=e.directoryScoped,n=e.activeDirectoryKey;if(!t||!n)return e;const s=t[n];if(!s)return e;const o={...e};return(!e.providers||e.providers.length===0)&&s.providers?.length&&(o.providers=s.providers),(!e.agents||e.agents.length===0)&&s.agents?.length&&(o.agents=s.agents),(!e.defaultProviders||Object.keys(e.defaultProviders).length===0)&&s.defaultProviders&&Object.keys(s.defaultProviders).length>0&&(o.defaultProviders=s.defaultProviders),s.opencodeDefaultAgent!==void 0&&(o.opencodeDefaultAgent=s.opencodeDefaultAgent),s.opencodeDefaultModel!==void 0&&(o.opencodeDefaultModel=s.opencodeDefaultModel),s.selectionSource&&(o.selectionSource=s.selectionSource),o},Fx=(e=[],t=[])=>({providers:e,agents:t,currentProviderId:"",currentModelId:"",currentVariant:void 0,currentAgentName:void 0,selectedProviderId:"",agentModelSelections:{},defaultProviders:{},opencodeDefaultAgent:void 0,opencodeDefaultModel:void 0,selectionSource:"auto"}),$x=(e,t,n,s)=>{if(!s)return!0;const o=e.find(r=>r.id===t)?.models.find(r=>r.id===n);return!!o?.variants&&Object.prototype.hasOwnProperty.call(o.variants,s)},r6=({agents:e,providers:t,currentAgentName:n,currentProviderId:s,currentModelId:o,currentVariant:r,selectionSource:a,resolvedAgentName:l,resolvedProviderId:c,resolvedModelId:u,resolvedVariant:f})=>{const h=n&&e.some(g=>g.name===n)?n:void 0,m=!!s&&!!o&&Lt(t,s,o)&&$x(t,s,o,r),p=a==="manual"&&(!!h||m);return{agentName:p?h??l:l,providerId:p&&m?s:c,modelId:p&&m?o:u,variant:p&&m?r:f,selectionSource:p?"manual":"auto"}},Fo=new Map,qa=new Map;let $o=null;const $e=W1()($0(yo((e,t)=>({activeDirectoryKey:Nx(),directoryScoped:{},providers:[],agents:[],currentProviderId:"",currentModelId:"",currentVariant:void 0,currentAgentName:void 0,selectedProviderId:"",agentModelSelections:{},defaultProviders:{},selectionSource:"auto",isConnected:!1,hasEverConnected:!1,connectionPhase:"connecting",lastDisconnectReason:null,isInitialized:!1,modelsMetadata:new Map,settingsDefaultModel:void 0,settingsDefaultVariant:void 0,settingsDefaultThinking:void 0,settingsDefaultThinkingByModel:{},opencodeDefaultAgent:void 0,opencodeDefaultModel:void 0,settingsAutoCreateWorktree:!1,settingsGitmojiEnabled:!1,settingsDefaultFileViewerPreview:!1,settingsZenModel:void 0,activateDirectory:async n=>{const s=Bs(n);if(!s){m1("activateDirectory:skippedUnknownDirectory",{directory:n});return}const o=Ut(s);let r=!1,a=!1;e(l=>{const c=l.directoryScoped[o];return c?(r=c.providers.length>0,a=c.agents.length>0,{activeDirectoryKey:o,providers:c.providers,agents:c.agents,currentProviderId:c.currentProviderId,currentModelId:c.currentModelId,currentVariant:c.currentVariant,currentAgentName:c.currentAgentName,selectedProviderId:c.selectedProviderId,agentModelSelections:c.agentModelSelections,defaultProviders:c.defaultProviders,opencodeDefaultAgent:c.opencodeDefaultAgent,opencodeDefaultModel:c.opencodeDefaultModel,selectionSource:c.selectionSource??"auto"}):{activeDirectoryKey:o,providers:[],agents:[],currentProviderId:"",currentModelId:"",currentAgentName:void 0,selectedProviderId:"",agentModelSelections:{},defaultProviders:{},opencodeDefaultAgent:void 0,opencodeDefaultModel:void 0,selectionSource:"auto"}}),t().isConnected&&(r?o6(s6,o)?m1("activateDirectory:providersFresh",{directoryKey:o}):(m1("activateDirectory:refreshProvidersBackground",{directoryKey:o}),t().loadProviders({directory:z2(o),source:"activateDirectory:refresh"})):await t().loadProviders({directory:z2(o),source:"activateDirectory"}),a?o6($a,o)?m1("activateDirectory:agentsFresh",{directoryKey:o}):(m1("activateDirectory:refreshAgentsBackground",{directoryKey:o}),t().loadAgents({directory:z2(o),source:"activateDirectory:refresh"})):await t().loadAgents({directory:z2(o),source:"activateDirectory"}))},invalidateProviderCache:n=>{const s=n===void 0?null:Ut(n);e(o=>{const r={};let a=!1;const l={...o.directoryScoped},c=u=>u.providers.length===0&&Object.keys(u.defaultProviders).length===0?u:(a=!0,{...u,providers:[],defaultProviders:{}});if(s){const u=o.directoryScoped[s];u&&(l[s]=c(u))}else for(const[u,f]of Object.entries(o.directoryScoped))l[u]=c(f);return a&&(r.directoryScoped=l),(s===null||s===o.activeDirectoryKey)&&(o.providers.length>0&&(r.providers=[]),Object.keys(o.defaultProviders).length>0&&(r.defaultProviders={})),Object.keys(r).length>0?r:o})},loadProviders:async n=>{const s=n?.directory??z2(t().activeDirectoryKey),o=Bs(s);if(!o){m1("loadProviders:skippedUnknownDirectory",{requestedDirectory:s,source:n?.source??"unknown"});return}const r=o??p2.getDirectory()??null,a=Ut(o),l=n?.source??"unknown";m1("loadProviders:called",{directoryKey:a,source:l,requestedDirectory:s,effectiveDirectory:r});const c=Fo.get(a);if(c)return m1("loadProviders:deduped",{directoryKey:a,source:l,requestedDirectory:s,effectiveDirectory:r}),c;const u=(async()=>{const f=typeof performance<"u"?performance.now():Date.now();m1("loadProviders:start",{directoryKey:a,source:l,requestedDirectory:s,effectiveDirectory:r});const h=t().directoryScoped[a],m=h?.providers??(t().activeDirectoryKey===a?t().providers:[]),p=h?.defaultProviders??(t().activeDirectoryKey===a?t().defaultProviders:{});let g=null;for(let y=0;y<3;y++)try{Bx(()=>t().modelsMetadata,C=>e({modelsMetadata:C}));const M=await Ar("loadProviders:api",()=>p2.getProvidersForConfig(z2(a)),{directoryKey:a,source:l,requestedDirectory:s,effectiveDirectory:r,attempt:y+1}),b=Array.isArray(M?.providers)?M.providers:[],v=M?.default||{},x=b.map(C=>{const w=C.models??{},_=Object.keys(w).map(L=>w[L]);return{...C,models:_}});e(C=>{const w=C.directoryScoped[a]??{providers:[],agents:[],currentProviderId:"",currentModelId:"",currentAgentName:void 0,selectedProviderId:"",agentModelSelections:{},defaultProviders:{}},_=C.activeDirectoryKey===a?C.currentProviderId:w.currentProviderId,L=C.activeDirectoryKey===a?C.currentModelId:w.currentModelId,A=C.activeDirectoryKey===a?C.currentVariant:w.currentVariant,N=kx({providers:x,currentProviderId:_,currentModelId:L,currentVariant:A,settingsDefaultModel:C.settingsDefaultModel,settingsDefaultVariant:C.settingsDefaultVariant}),k=C.activeDirectoryKey===a?C.selectedProviderId:w.selectedProviderId,V=k===ti||x.some(P=>P.id===k)?k:N?.providerId??x[0]?.id??"",H={...w,providers:x,defaultProviders:v,currentProviderId:N?.providerId??"",currentModelId:N?.modelId??"",currentVariant:N?.variant,selectedProviderId:V},D={directoryScoped:{...C.directoryScoped,[a]:H}};return C.activeDirectoryKey===a&&(D.providers=x,D.defaultProviders=v,D.currentProviderId=H.currentProviderId,D.currentModelId=H.currentModelId,D.currentVariant=H.currentVariant,D.selectedProviderId=V),D});const S=typeof performance<"u"?performance.now():Date.now();m1("loadProviders:end",{directoryKey:a,source:l,requestedDirectory:s,effectiveDirectory:r,durationMs:Math.round(S-f),providers:x.length,models:x.reduce((C,w)=>C+w.models.length,0)}),s6.set(a,Date.now());return}catch(M){g=M,m1("loadProviders:attemptError",{directoryKey:a,source:l,requestedDirectory:s,effectiveDirectory:r,attempt:y+1,error:M instanceof Error?M.message:String(M)});const b=200*(y+1);await new Promise(v=>setTimeout(v,b))}console.error("Failed to load providers:",g),m1("loadProviders:error",{directoryKey:a,source:l,requestedDirectory:s,effectiveDirectory:r,error:g instanceof Error?g.message:String(g)}),e(y=>{const b={...y.directoryScoped[a]??{providers:[],agents:[],currentProviderId:"",currentModelId:"",currentAgentName:void 0,selectedProviderId:"",agentModelSelections:{},defaultProviders:{}},providers:m,defaultProviders:p},v={directoryScoped:{...y.directoryScoped,[a]:b}};if(y.activeDirectoryKey===a&&(v.providers=m,v.defaultProviders=p,!y.currentProviderId&&!y.currentModelId&&y.settingsDefaultModel)){const x=_n(y.settingsDefaultModel);if(x){const S=m.find(C=>C.id===x.providerId);if(S?.models.some(C=>C.id===x.modelId)){const C=S.models.find(_=>_.id===x.modelId),w=y.settingsDefaultVariant&&C?.variants?.[y.settingsDefaultVariant]?y.settingsDefaultVariant:void 0;v.currentProviderId=x.providerId,v.currentModelId=x.modelId,v.currentVariant=w,v.selectedProviderId=x.providerId,b.currentProviderId=x.providerId,b.currentModelId=x.modelId,b.currentVariant=w,b.selectedProviderId=x.providerId}}}return v})})().finally(()=>Fo.delete(a));return Fo.set(a,u),u},setProvider:n=>{const{providers:s}=t(),o=s.find(l=>l.id===n);if(!o)return;const a=o.models[0]?.id||"";e(l=>{const c=l.activeDirectoryKey,f={...l.directoryScoped[c]??{providers:l.providers,agents:l.agents,currentProviderId:l.currentProviderId,currentModelId:l.currentModelId,currentVariant:l.currentVariant,currentAgentName:l.currentAgentName,selectedProviderId:l.selectedProviderId,agentModelSelections:l.agentModelSelections,defaultProviders:l.defaultProviders},currentProviderId:n,currentModelId:a,selectedProviderId:n,selectionSource:"manual"};return{currentProviderId:n,currentModelId:a,selectedProviderId:n,selectionSource:"manual",directoryScoped:{...l.directoryScoped,[c]:f}}})},setModel:n=>{e(s=>{const o=s.activeDirectoryKey,a={...s.directoryScoped[o]??{providers:s.providers,agents:s.agents,currentProviderId:s.currentProviderId,currentModelId:s.currentModelId,currentVariant:s.currentVariant,currentAgentName:s.currentAgentName,selectedProviderId:s.selectedProviderId,agentModelSelections:s.agentModelSelections,defaultProviders:s.defaultProviders},currentModelId:n,selectionSource:"manual"};return{currentModelId:n,selectionSource:"manual",directoryScoped:{...s.directoryScoped,[o]:a}}})},setCurrentVariant:n=>{e(s=>{if(s.currentVariant===n)return s;const o=s.activeDirectoryKey,a={...s.directoryScoped[o]??{providers:s.providers,agents:s.agents,currentProviderId:s.currentProviderId,currentModelId:s.currentModelId,currentVariant:s.currentVariant,currentAgentName:s.currentAgentName,selectedProviderId:s.selectedProviderId,agentModelSelections:s.agentModelSelections,defaultProviders:s.defaultProviders},currentVariant:n,selectionSource:"manual"};return{currentVariant:n,selectionSource:"manual",directoryScoped:{...s.directoryScoped,[o]:a}}})},getCurrentModelVariants:()=>E9(t().getCurrentModel()),cycleCurrentVariant:()=>{const n=u3(t().getCurrentModelVariants(),t().currentVariant,1);t().setCurrentVariant(n)},setSelectedProvider:n=>{e(s=>{const o=s.activeDirectoryKey,a={...s.directoryScoped[o]??{providers:s.providers,agents:s.agents,currentProviderId:s.currentProviderId,currentModelId:s.currentModelId,currentAgentName:s.currentAgentName,selectedProviderId:s.selectedProviderId,agentModelSelections:s.agentModelSelections,defaultProviders:s.defaultProviders},selectedProviderId:n,selectionSource:"manual"};return{selectedProviderId:n,selectionSource:"manual",directoryScoped:{...s.directoryScoped,[o]:a}}})},saveAgentModelSelection:(n,s,o)=>{e(r=>{const a=r.activeDirectoryKey,l={...r.agentModelSelections,[n]:{providerId:s,modelId:o}},u={...r.directoryScoped[a]??{providers:r.providers,agents:r.agents,currentProviderId:r.currentProviderId,currentModelId:r.currentModelId,currentAgentName:r.currentAgentName,selectedProviderId:r.selectedProviderId,agentModelSelections:r.agentModelSelections,defaultProviders:r.defaultProviders},agentModelSelections:l,selectionSource:"manual"};return{agentModelSelections:l,selectionSource:"manual",directoryScoped:{...r.directoryScoped,[a]:u}}})},getAgentModelSelection:n=>{const{agentModelSelections:s}=t();return s[n]||null},loadAgents:async n=>{const s=n?.directory??z2(t().activeDirectoryKey),o=Bs(s);if(!o)return m1("loadAgents:skippedUnknownDirectory",{requestedDirectory:s,source:n?.source??"unknown"}),!1;const r=o??p2.getDirectory()??null,a=Ut(o),l=n?.source??"unknown";m1("loadAgents:called",{directoryKey:a,source:l,requestedDirectory:s,effectiveDirectory:r});const c=qa.get(a);if(c)return m1("loadAgents:deduped",{directoryKey:a,source:l,requestedDirectory:s,effectiveDirectory:r}),c;const u=(async()=>{const f=typeof performance<"u"?performance.now():Date.now();m1("loadAgents:start",{directoryKey:a,source:l,requestedDirectory:s,effectiveDirectory:r});const m=t().directoryScoped[a]?.agents??(t().activeDirectoryKey===a?t().agents:[]);let p=null;for(let g=0;g<3;g++)try{const y=z2(a),M=void 0??void 0,[b,v]=await Promise.all([Ar("loadAgents:api",()=>p2.listAgents(y),{directoryKey:a,source:l,requestedDirectory:s,effectiveDirectory:r,attempt:g+1}),Sx()]),x=Array.isArray(b)?b:[],S=Fo.get(a);S&&(m1("loadAgents:awaitProviders",{directoryKey:a,source:l}),await S);const C=void 0??void 0,w=C!==void 0,_=w?Ft(C.default_agent):void 0,L=w?Ft(C.model):void 0,A=t().activeDirectoryKey===a?t().providers:t().directoryScoped[a]?.providers??[],N=Ft(t().settingsZenModel),k=Ft(v.zenModel),V=Fa({providers:A,settingsZenModel:N}),H=Fa({providers:A,settingsZenModel:k}),R=(V||H)?.modelId||k||N;e(ee=>{const ue=ee.directoryScoped[a]??{providers:A,agents:m,currentProviderId:"",currentModelId:"",currentAgentName:void 0,selectedProviderId:"",agentModelSelections:{},defaultProviders:{}},J=w?_:ue.opencodeDefaultAgent??(ee.activeDirectoryKey===a?ee.opencodeDefaultAgent:void 0),Y=w?L:ue.opencodeDefaultModel??(ee.activeDirectoryKey===a?ee.opencodeDefaultModel:void 0),oe={...ue,providers:A,agents:x,opencodeDefaultAgent:J,opencodeDefaultModel:Y},te={settingsDefaultModel:v.defaultModel,settingsDefaultVariant:v.defaultVariant,settingsDefaultThinking:v.defaultThinking,settingsDefaultThinkingByModel:v.defaultThinkingByModel??{},settingsAutoCreateWorktree:v.autoCreateWorktree??!1,settingsGitmojiEnabled:v.gitmojiEnabled??!1,settingsDefaultFileViewerPreview:v.defaultFileViewerPreview??!1,settingsZenModel:R,directoryScoped:{...ee.directoryScoped,[a]:oe}};return ee.activeDirectoryKey===a&&(te.agents=x,te.opencodeDefaultAgent=J,te.opencodeDefaultModel=Y),te});const $=t(),O=$.directoryScoped[a],I=O?.opencodeDefaultAgent??($.activeDirectoryKey===a?$.opencodeDefaultAgent:void 0),q=O?.opencodeDefaultModel??($.activeDirectoryKey===a?$.opencodeDefaultModel:void 0);if(R&&R!==k&&R&&Nn({zenModel:R,gitProviderId:"",gitModelId:""}).catch(()=>{}),x.length===0){e(ue=>{const Y={...ue.directoryScoped[a]??{providers:A,agents:[],currentProviderId:"",currentModelId:"",currentVariant:void 0,currentAgentName:void 0,selectedProviderId:"",agentModelSelections:{},defaultProviders:{}},providers:A,agents:[],currentAgentName:void 0},oe={directoryScoped:{...ue.directoryScoped,[a]:Y}};return ue.activeDirectoryKey===a&&(oe.currentAgentName=void 0),oe});const ee=typeof performance<"u"?performance.now():Date.now();return m1("loadAgents:end",{directoryKey:a,source:l,requestedDirectory:s,effectiveDirectory:r,durationMs:Math.round(ee-f),agents:x.length}),$a.set(a,Date.now()),!0}const K=(ee,ue)=>{const J=A.find(Y=>Y.id===ee);return J?J.models.some(Y=>Y.id===ue):!1},W={};if(v.defaultModel){const ee=_n(v.defaultModel);if(!ee||!K(ee.providerId,ee.modelId))W.defaultModel="";else if(v.defaultVariant){const Y=A.find(oe=>oe.id===ee.providerId)?.models.find(oe=>oe.id===ee.modelId)?.variants;Y&&Object.prototype.hasOwnProperty.call(Y,v.defaultVariant)||(W.defaultVariant="")}}const ge=Za({agents:x,providers:A,settingsDefaultModel:v.defaultModel,settingsDefaultVariant:v.defaultVariant,opencodeDefaultAgent:I,opencodeDefaultModel:q}),Z=ge.agentName??x[0].name,fe=ge.providerId,ie=ge.modelId,E=ge.variant;e(ee=>{const ue=ee.directoryScoped[a]??{providers:A,agents:x,currentProviderId:"",currentModelId:"",currentAgentName:void 0,selectedProviderId:"",agentModelSelections:{},defaultProviders:{}},J=ee.activeDirectoryKey===a,Y=J?ee.currentAgentName:ue.currentAgentName,oe=J?ee.currentProviderId:ue.currentProviderId,te=J?ee.currentModelId:ue.currentModelId,pe=J?ee.currentVariant:ue.currentVariant,He=J?ee.selectionSource:ue.selectionSource??"auto",je=r6({agents:x,providers:A,currentAgentName:Y,currentProviderId:oe,currentModelId:te,currentVariant:pe,selectionSource:He,resolvedAgentName:Z,resolvedProviderId:fe,resolvedModelId:ie,resolvedVariant:E}),Pe={...ue,providers:A,agents:x,currentAgentName:je.agentName,currentProviderId:je.providerId??ue.currentProviderId,currentModelId:je.modelId??ue.currentModelId,currentVariant:je.variant,opencodeDefaultAgent:I,opencodeDefaultModel:q,selectionSource:je.selectionSource},X={directoryScoped:{...ee.directoryScoped,[a]:Pe}};return J&&(X.currentAgentName=je.agentName,X.opencodeDefaultAgent=I,X.opencodeDefaultModel=q,je.providerId&&je.modelId&&(X.currentProviderId=je.providerId,X.currentModelId=je.modelId,X.currentVariant=je.variant),X.selectionSource=je.selectionSource),X}),Object.keys(W).length>0&&(e({settingsDefaultModel:W.defaultModel!==void 0?void 0:t().settingsDefaultModel,settingsDefaultVariant:W.defaultVariant!==void 0?void 0:t().settingsDefaultVariant,settingsDefaultAgent:W.defaultAgent!==void 0?void 0:t().settingsDefaultAgent}),Nn(W).catch(()=>{}));const ce=typeof performance<"u"?performance.now():Date.now();return m1("loadAgents:end",{directoryKey:a,source:l,requestedDirectory:s,effectiveDirectory:r,durationMs:Math.round(ce-f),agents:x.length}),$a.set(a,Date.now()),!0}catch(y){p=y,m1("loadAgents:attemptError",{directoryKey:a,source:l,requestedDirectory:s,effectiveDirectory:r,attempt:g+1,error:y instanceof Error?y.message:String(y)});const M=200*(g+1);await new Promise(b=>setTimeout(b,M))}return console.error("Failed to load agents:",p),m1("loadAgents:error",{directoryKey:a,source:l,requestedDirectory:s,effectiveDirectory:r,error:p instanceof Error?p.message:String(p)}),e(g=>{const y=g.activeDirectoryKey===a?g.providers:g.directoryScoped[a]?.providers??[],b={...g.directoryScoped[a]??{providers:y,agents:[],currentProviderId:"",currentModelId:"",currentAgentName:void 0,selectedProviderId:"",agentModelSelections:{},defaultProviders:{}},providers:y,agents:m},v={directoryScoped:{...g.directoryScoped,[a]:b}};return g.activeDirectoryKey===a&&(v.agents=m),v}),!1})().finally(()=>qa.delete(a));return qa.set(a,u),u},invalidateModelMetadataCache:()=>{Hr=null,e({modelsMetadata:new Map})},setAgent:n=>{const{agents:s,providers:o,settingsDefaultModel:r,settingsDefaultVariant:a,currentProviderId:l,currentModelId:c}=t();if(e(u=>{const f=u.activeDirectoryKey,m={...u.directoryScoped[f]??{providers:u.providers,agents:u.agents,currentProviderId:u.currentProviderId,currentModelId:u.currentModelId,currentAgentName:u.currentAgentName,selectedProviderId:u.selectedProviderId,agentModelSelections:u.agentModelSelections,defaultProviders:u.defaultProviders},currentAgentName:n,selectionSource:"manual"};return{currentAgentName:n,selectionSource:"manual",directoryScoped:{...u.directoryScoped,[f]:m}}}),n){const{currentSessionId:u}=Be.getState(),f=n2.getState();u&&f.saveSessionAgentSelection(u,n),u&&Be.getState().isPiChamberCreatedSession(u)&&(f.getAgentModelForSession(u,n)||Be.getState().initializeNewPiChamberSession(u,s))}if(n){const{currentSessionId:u}=Be.getState(),f=(g,y,M)=>{e(b=>{const v=b.activeDirectoryKey,S={...b.directoryScoped[v]??{providers:b.providers,agents:b.agents,currentProviderId:b.currentProviderId,currentModelId:b.currentModelId,currentVariant:b.currentVariant,currentAgentName:b.currentAgentName,selectedProviderId:b.selectedProviderId,agentModelSelections:b.agentModelSelections,defaultProviders:b.defaultProviders},currentProviderId:g,currentModelId:y,currentVariant:M,selectedProviderId:w0(b.selectedProviderId,g),selectionSource:"manual"};return{currentProviderId:g,currentModelId:y,currentVariant:M,selectedProviderId:w0(b.selectedProviderId,g),selectionSource:"manual",directoryScoped:{...b.directoryScoped,[v]:S}}})},h=(g,y,M)=>{const v=o.find(S=>S.id===g)?.models.find(S=>S.id===y)?.variants;if(!v)return;const x=u?n2.getState().getAgentModelVariantForSession(u,n,g,y):void 0;for(const S of[x,M,a])if(S&&Object.prototype.hasOwnProperty.call(v,S))return S},m=s.find(g=>g.name===n);if(u){const g=n2.getState().getAgentModelForSession(u,n);if(g&&Lt(o,g.providerId,g.modelId)){const y=h(g.providerId,g.modelId,m?.variant);(l!==g.providerId||c!==g.modelId||t().currentVariant!==y)&&f(g.providerId,g.modelId,y);return}}const p=m?.model;if(p?.providerID&&p?.modelID){const{providerID:g,modelID:y}=p;if(o.find(v=>v.id===g)?.models.find(v=>v.id===y)){f(g,y,h(g,y,m?.variant));return}}if(r){const g=_n(r);if(g&&o.find(M=>M.id===g.providerId)?.models.some(M=>M.id===g.modelId)){f(g.providerId,g.modelId,h(g.providerId,g.modelId,m?.variant));return}}}},applyDefaultModelAgentSelection:n=>{const{agents:s,providers:o,settingsDefaultModel:r,settingsDefaultVariant:a,opencodeDefaultAgent:l,opencodeDefaultModel:c}=t();if(s.length===0||o.length===0)return;const{agentName:u,providerId:f,modelId:h,variant:m}=Za({agents:s,providers:o,projectDefaultModel:n?.projectDefaultModel,settingsDefaultModel:r,settingsDefaultVariant:a,opencodeDefaultAgent:l,opencodeDefaultModel:c});u&&e(p=>{const g=p.activeDirectoryKey,M={...p.directoryScoped[g]??{providers:p.providers,agents:p.agents,currentProviderId:p.currentProviderId,currentModelId:p.currentModelId,currentVariant:p.currentVariant,currentAgentName:p.currentAgentName,selectedProviderId:p.selectedProviderId,agentModelSelections:p.agentModelSelections,defaultProviders:p.defaultProviders},currentAgentName:u,...f&&h?{currentProviderId:f,currentModelId:h,currentVariant:m,selectedProviderId:w0(p.selectedProviderId,f)}:{},selectionSource:"auto"},b={currentAgentName:u,selectionSource:"auto",directoryScoped:{...p.directoryScoped,[g]:M}};return f&&h&&(b.currentProviderId=f,b.currentModelId=h,b.currentVariant=m,b.selectedProviderId=w0(p.selectedProviderId,f)),b})},applyOpenCodeConfigDefaults:(n,s="syncConfig",o)=>{const r=n??z2(t().activeDirectoryKey),a=Ts(r),l=o??void 0??void 0;if(!l)return;const c=Ft(l.default_agent),u=Ft(l.model);e(f=>{const h=f.directoryScoped[a],m=f.activeDirectoryKey===a,p=m?f.providers:h?.providers??[],g=m?f.agents:h?.agents??[],y=h??Fx(p,g),M=y.opencodeDefaultAgent!==c||y.opencodeDefaultModel!==u||m&&(f.opencodeDefaultAgent!==c||f.opencodeDefaultModel!==u),b={...y,providers:p,agents:g,opencodeDefaultAgent:c,opencodeDefaultModel:u},v={directoryScoped:{...f.directoryScoped,[a]:b}};m&&(v.opencodeDefaultAgent=c,v.opencodeDefaultModel=u);const x=m?f.selectionSource:h?.selectionSource??"auto";if(p.length===0||g.length===0)return M?v:f;const S=Za({agents:g,providers:p,settingsDefaultModel:f.settingsDefaultModel,settingsDefaultVariant:f.settingsDefaultVariant,opencodeDefaultAgent:c,opencodeDefaultModel:u});if(!S.agentName)return M?v:f;const C=m?f.currentAgentName:y.currentAgentName,w=m?f.currentProviderId:y.currentProviderId,_=m?f.currentModelId:y.currentModelId,L=m?f.currentVariant:y.currentVariant,A=m?f.selectedProviderId:y.selectedProviderId,N=r6({agents:g,providers:p,currentAgentName:C,currentProviderId:w,currentModelId:_,currentVariant:L,selectionSource:x,resolvedAgentName:S.agentName,resolvedProviderId:S.providerId,resolvedModelId:S.modelId,resolvedVariant:S.variant}),k={...b,providers:p,agents:g,currentAgentName:N.agentName,...N.providerId&&N.modelId?{currentProviderId:N.providerId,currentModelId:N.modelId,currentVariant:N.variant,selectedProviderId:w0(A,N.providerId)}:{},selectionSource:N.selectionSource},V=y.currentAgentName!==k.currentAgentName||y.currentProviderId!==k.currentProviderId||y.currentModelId!==k.currentModelId||y.currentVariant!==k.currentVariant||y.selectedProviderId!==k.selectedProviderId||(y.selectionSource??"auto")!==k.selectionSource||m&&(f.currentAgentName!==N.agentName||f.selectionSource!==N.selectionSource||N.providerId!==void 0&&N.modelId!==void 0&&(f.currentProviderId!==N.providerId||f.currentModelId!==N.modelId||f.currentVariant!==N.variant||f.selectedProviderId!==w0(A,N.providerId)));return!M&&!V?f:(v.directoryScoped={...f.directoryScoped,[a]:k},m&&(v.currentAgentName=N.agentName,v.selectionSource=N.selectionSource,N.providerId&&N.modelId&&(v.currentProviderId=N.providerId,v.currentModelId=N.modelId,v.currentVariant=N.variant,v.selectedProviderId=w0(A,N.providerId))),m1("loadAgents:opencodeConfigDefaultsApplied",{directoryKey:a,eventDirectory:r,source:s}),v)})},setSettingsDefaultModel:n=>{e({settingsDefaultModel:n})},setSettingsDefaultVariant:n=>{e({settingsDefaultVariant:n})},setSettingsDefaultThinking:n=>{e({settingsDefaultThinking:n})},setSettingsDefaultThinkingByModel:n=>{e({settingsDefaultThinkingByModel:n})},setSettingsAutoCreateWorktree:n=>{e({settingsAutoCreateWorktree:n})},setSettingsGitmojiEnabled:n=>{e({settingsGitmojiEnabled:n})},setSettingsDefaultFileViewerPreview:n=>{e({settingsDefaultFileViewerPreview:n})},setSettingsZenModel:n=>{e({settingsZenModel:n})},getResolvedGitGenerationModel:()=>{const n=t();return Fa({providers:n.providers,settingsZenModel:n.settingsZenModel})},probeConnection:async n=>{if(await Vx(n?.timeoutMs))return e({isConnected:!0,hasEverConnected:!0,connectionPhase:"connected"}),!0;const o=t();return o.isConnected?!0:(e({isConnected:!1,connectionPhase:o.hasEverConnected?"reconnecting":"connecting",lastDisconnectReason:"health_probe_unhealthy"}),!1)},checkConnection:async()=>{m1("checkConnection:start");const n=5;let s=0,o=null;for(;s<n;)try{m1("checkConnection:attempt",{attempt:s+1});const r=await Ar("checkConnection:health",()=>p2.checkHealth(),{attempt:s+1});if(!r&&s<n-1){const l=t().hasEverConnected;e({isConnected:!1,connectionPhase:l?"reconnecting":"connecting",lastDisconnectReason:"health_check_unhealthy"}),s+=1,await Lr(400*s);continue}const a=t().hasEverConnected;return e(r?{isConnected:!0,hasEverConnected:!0,connectionPhase:"connected"}:{isConnected:!1,connectionPhase:a?"reconnecting":"connecting",lastDisconnectReason:"health_check_unhealthy"}),m1("checkConnection:end",{healthy:r,attempts:s+1}),r}catch(r){o=r,s+=1;const a=400*s;await Lr(a)}return o&&console.warn("[ConfigStore] Failed to reach OpenCode after retrying:",o),e({isConnected:!1,connectionPhase:t().hasEverConnected?"reconnecting":"connecting",lastDisconnectReason:"health_check_failed"}),m1("checkConnection:end",{healthy:!1,attempts:n}),!1},initializeApp:async()=>{if($o)return m1("initializeApp:deduped"),$o;const n=(async()=>{const s=typeof performance<"u"?performance.now():Date.now();m1("initializeApp:start");try{const o=f9();o&&console.log("Starting app initialization...");const r=await t().checkConnection();if(o&&console.log("Connection check result:",r),!r){o&&console.log("Server not connected"),e({isConnected:!1,connectionPhase:t().hasEverConnected?"reconnecting":"connecting"});return}o&&console.log("Initializing app..."),m1("initApp:skipped",{reason:"checkConnection already verified health"});const a=p2.getDirectory()??w1.getState().currentDirectory??z2(t().activeDirectoryKey),l=Kt(j1.getState().projects,null,a??null),c=Bs(l?.path??a??null),u=c??Dx();if(!u){m1("initializeApp:noProjectConfigDirectory"),e({isInitialized:!0,isConnected:!0,hasEverConnected:!0,connectionPhase:"connected"});return}!c&&a!==u&&(m1("initializeApp:normalizedUnknownDirectoryToProject",{initialDirectory:a,configDirectory:u}),p2.setDirectory(u),w1.getState().setDirectory(u,{showOverlay:!1}));const f=Ut(u);t().activeDirectoryKey!==f&&e({activeDirectoryKey:f}),o&&console.log("Loading providers and agents..."),await Promise.all([t().loadProviders({directory:u,source:"initializeApp"}),t().loadAgents({directory:u,source:"initializeApp"})]),e({isInitialized:!0,isConnected:!0,hasEverConnected:!0,connectionPhase:"connected"}),t().prewarmProjectConfigs(u);const h=typeof performance<"u"?performance.now():Date.now();m1("initializeApp:end",{durationMs:Math.round(h-s),providers:t().providers.length,agents:t().agents.length}),o&&console.log("App initialized successfully")}catch(o){console.error("Failed to initialize app:",o),e({isInitialized:!1,isConnected:!1,connectionPhase:t().hasEverConnected?"reconnecting":"connecting",lastDisconnectReason:"init_error"}),m1("initializeApp:error",{error:o instanceof Error?o.message:String(o)})}})().finally(()=>{$o=null});return $o=n,n},prewarmProjectConfigs:async n=>{if(!t().isConnected)return;const s=Ts(n??z2(t().activeDirectoryKey)),o=j1.getState().projects.map(l=>l.path).filter(l=>typeof l=="string"&&l.trim().length>0),r=new Set([s]),a=[];for(const l of o){const c=Ts(l);if(r.has(c))continue;r.add(c);const u=t().directoryScoped[c];if(u?.providers.length&&u.agents.length)continue;const f=z2(c);f&&a.push(f)}for(const l of a){if(await Lr(Ox),!t().isConnected)return;const c=Ts(l),u=t().directoryScoped[c],f=[];u?.providers.length||f.push(t().loadProviders({directory:l,source:"projectConfigPrewarm"})),u?.agents.length||f.push(t().loadAgents({directory:l,source:"projectConfigPrewarm"})),f.length>0&&await Promise.allSettled(f)}},getCurrentProvider:()=>{const{providers:n,currentProviderId:s}=t();return n.find(o=>o.id===s)},getCurrentModel:()=>{const n=t().getCurrentProvider(),{currentModelId:s}=t();if(n)return n.models.find(o=>o.id===s)},getCurrentAgent:()=>{const{agents:n,currentAgentName:s}=t();if(s)return n.find(o=>o.name===s)},getModelMetadata:(n,s)=>{const o=gu(n,s);if(!o)return;const{modelsMetadata:r,providers:a}=t(),l=r.get(o);if(l)return l;const c=a.find(f=>f.id===n);if(!c)return;const u=c.models.find(f=>f.id===s);if(u)return Lx(n,u)},getVisibleAgents:()=>{const{agents:n}=t();return n}}),{name:"config-store",storage:Bi(),merge:(e,t)=>Zx({...t,...e&&typeof e=="object"?e:{}}),partialize:e=>({activeDirectoryKey:e.activeDirectoryKey,directoryScoped:Object.fromEntries(Object.entries(e.directoryScoped).map(([t,n])=>[t,{...n,selectedProviderId:e6(n.selectedProviderId)}])),providers:e.providers,agents:e.agents,currentProviderId:e.currentProviderId,currentModelId:e.currentModelId,currentVariant:e.currentVariant,currentAgentName:e.currentAgentName,selectedProviderId:e6(e.selectedProviderId),agentModelSelections:e.agentModelSelections,defaultProviders:e.defaultProviders,settingsDefaultModel:e.settingsDefaultModel,settingsDefaultVariant:e.settingsDefaultVariant,settingsDefaultThinking:e.settingsDefaultThinking,settingsDefaultThinkingByModel:e.settingsDefaultThinkingByModel,settingsAutoCreateWorktree:e.settingsAutoCreateWorktree,settingsGitmojiEnabled:e.settingsGitmojiEnabled,settingsDefaultFileViewerPreview:e.settingsDefaultFileViewerPreview,settingsZenModel:e.settingsZenModel})})));typeof window<"u"&&(window.__zustand_config_store__=$e);const qx=async e=>{const t=$e.getState(),n=Array.from(new Set([t.activeDirectoryKey,...Object.keys(t.directoryScoped)])).filter(a=>a.length>0);t.invalidateProviderCache();let s=0;const o=Math.min(wx,n.length),r=Array.from({length:o},async()=>{for(;s<n.length;){const a=n[s];s+=1,await $e.getState().loadProviders({directory:z2(a),source:e})}});await Promise.all(r)};let i6=null;i6||(i6=Zb(async e=>{const t=[];if(Uc(e,"agents")){const{loadAgents:n}=$e.getState();t.push(n({source:"configChange:agents"}).then(()=>{}))}Uc(e,"providers")&&t.push(qx("configChange:providers")),t.length>0&&await Promise.all(t)}));let a6=null;typeof window<"u"&&!a6&&(a6=w1.subscribe((e,t)=>{const n=Ut(e.currentDirectory),s=Ut(t.currentDirectory);n!==s&&(m1("directoryStore:changed",{previous:s,next:n}),$e.getState().activateDirectory(e.currentDirectory))}));const Ux="pichamber_session_load_perf",a4=1e3,Gx=new Set(["bootstrap.directory","bootstrap.sessions.all","bootstrap.sessions.archived","bootstrap.sessions.roots","global-sessions.active","global-sessions.archived","session-messages.initial","session-messages.older","session-messages.page","session-messages.refresh","session-messages.visible","session-prefetch"]),Wx=new Set(["action-demand","current-directory","initial","initial-page","known-project","known-worktree","older","pagination","prefetch","project-expanded","refresh","selected-session","server-connected","worktree-expanded"]),Kx=new Set(["complete","error","stale","deduplicated","canceled"]),wu=()=>{if(po())return!0;if(typeof window>"u")return!1;try{return window.localStorage.getItem(Ux)==="1"}catch{return!1}};function Yx(){return typeof window>"u"?0:window.__pichamberSessionLoadPerformance?.events.length??0}function Jx(){typeof window>"u"||window.__pichamberSessionLoadPerformance&&(window.__pichamberSessionLoadPerformance.events=[])}const l6=()=>typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now(),Xx=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0?e:void 0,Ua=e=>Number.isInteger(e)&&Number(e)>=0?Number(e):void 0;function Qx(e){if(!wu()||!Gx.has(e.operation)||e.caller!==void 0&&!Wx.has(e.caller))return()=>{};const t=l6();return(n,s)=>{if(typeof window>"u"||!Kx.has(n))return;const o=window.__pichamberSessionLoadPerformance??{events:[]},r=Xx(e.queuedMs),a=Ua(e.requestLimit),l=Ua(s?.retryCount??e.retryCount),c=Ua(s?.recordCount??e.recordCount);o.events.push({operation:e.operation,...e.caller!==void 0?{caller:e.caller}:{},...r!==void 0?{queuedMs:r}:{},...a!==void 0?{requestLimit:a}:{},...typeof e.cursorPresent=="boolean"?{cursorPresent:e.cursorPresent}:{},outcome:n,durationMs:Math.max(0,l6()-t),...l!==void 0?{retryCount:l}:{},...c!==void 0?{recordCount:c}:{},at:Date.now()}),o.events.length>a4&&o.events.splice(0,o.events.length-a4),window.__pichamberSessionLoadPerformance=o}}const c6="pichamber.chat.first_message_visible";function ew(e){const t=e?.enabled??wu,n=e?.requestFrame??(c=>window.requestAnimationFrame(c)),s=e?.cancelFrame??(c=>window.cancelAnimationFrame(c)),o=e?.markVisible??(()=>{performance.mark(c6),performance.clearMarks(c6)}),r=e?.startEvent??Qx,a=new Set;let l=null;return{schedule(c,u){if(!t()||a.has(c))return()=>{};l&&(s(l.frame),l=null);const f=r({operation:"session-messages.visible",caller:"selected-session",recordCount:u}),h=n(()=>{l?.key!==c||l.frame!==h||(l=null,a.add(c),a.size>a4&&a.delete(a.values().next().value),o(),f("complete"))});return l={key:c,frame:h},()=>{l?.key!==c||l.frame!==h||(s(h),l=null)}}}}const tw=e=>!!e.time?.archived,jr=e=>{const t=[],n=[];for(const s of e)tw(s)?n.push(s):t.push(s);return{active:t,archived:n}};let rn=null,Ht=0;const o0=e=>{const t=e;return Je(t.directory??null)??Je(t.project?.worktree??null)},Zi=(e,t)=>{if(!t)return e;const n=e,s=t,o=Je(n.directory??null),r=Je(n.project?.worktree??null),a=Je(s.directory??null),l=Je(s.project?.worktree??null);let c=!1;const u={...n};return!o&&a&&(u.directory=s.directory,c=!0),!r&&l?(u.project={...s.project??{},...n.project??{},worktree:s.project?.worktree},c=!0):!n.project&&s.project&&(u.project=s.project,c=!0),c?u:e},Os=e=>{const t=new Map;for(const n of e){const s=o0(n);if(!s)continue;const o=t.get(s);if(o){o.push(n);continue}t.set(s,[n])}return t},si=e=>[e.id,e.title??"",e.time?.created??0,e.time?.updated??0,e.time?.archived??0,e.share?.url??"",JSON.stringify(e.metadata??null),o0(e)??""].join(":"),Cn=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(si(e[n])!==si(t[n]))return!1;return!0},d6=e=>{const t=e.time?.updated;if(typeof t=="number"&&Number.isFinite(t))return t;const n=e.time?.created;return typeof n=="number"&&Number.isFinite(n)?n:0},nw=e=>[...e].sort((t,n)=>{const s=d6(n)-d6(t);return s!==0?s:n.id.localeCompare(t.id)}),u6=e=>{const t=new Set;for(const n of e){const s=Je(n);s&&t.add(s)}return t},$t=(e,t,n)=>{if(n.size===0)return e;const s=new Map(e.map(a=>[a.id,a])),o=new Map;for(const a of t)a?.id&&o.set(a.id,Zi(a,s.get(a.id)));const r=e.filter(a=>{if(o.has(a.id))return!1;const l=o0(a);return!l||!n.has(l)});return nw([...o.values(),...r])},f6=async(e,t)=>{const n=Je(y1().getState().directory),s=[...e].sort((h,m)=>h===n?-1:m===n?1:h.localeCompare(m)),o=Ht,r=y1().getState().catalog,a=s.filter(h=>{const m=Je(h);return(m?r.listStatusByDirectory.get(m):void 0)!=="ready"});if(a.length>0&&await y1().refreshAllDirectoryCatalogs(a),o!==Ht)return{directories:new Set,sessions:[],errors:[]};if(t!==We())return{directories:new Set,sessions:[],errors:[]};const l=y1().getState().catalog,c=new Set,u=[],f=[];for(const h of s){const m=Je(h),p=l.listStatusByDirectory.get(m??h);if(p==="failed"){f.push(new Error(`session list failed for ${h}`));continue}if(p!=="ready")continue;const g=l.byDirectory.get(m??h);if(g){for(const y of g){const M=l.byId.get(y);M&&u.push(Ri(M))}c.add(h)}}return{directories:c,sessions:u,errors:f}},oi=(e,t)=>{const n=e.findIndex(r=>r.id===t.id);if(n===-1)return[t,...e];const s=Zi(t,e[n]);if(si(e[n])===si(s))return e;const o=[...e];return o[n]=s,o},h6=(e,t)=>{const n=e.findIndex(s=>s.id===t);return n===-1?e:[...e.slice(0,n),...e.slice(n+1)]},Ga=(e,t)=>{if(!t||t.length===0)return e;if(e.length===0)return t;const n=new Map(e.map(r=>[r.id,r]));t.forEach(r=>{n.set(r.id,Zi(r,n.get(r.id)))});const s=[],o=new Set;return e.forEach(r=>{const a=n.get(r.id);a&&(s.push(a),o.add(r.id))}),t.forEach(r=>{if(o.has(r.id))return;const a=n.get(r.id);a&&(s.push(a),o.add(r.id))}),s},Vs=(e,t,n,s)=>{const o=Cn(e.activeSessions,t)?e.activeSessions:t,r=Cn(e.archivedSessions,n)?e.archivedSessions:n,a=o===e.activeSessions?e.sessionsByDirectory:Os(o);return o===e.activeSessions&&r===e.archivedSessions&&a===e.sessionsByDirectory&&e.hasLoaded&&e.status===s?e:{activeSessions:o,archivedSessions:r,sessionsByDirectory:a,hasLoaded:!0,status:s}},qo=(e,t,n,s)=>{const o=new Set;for(const[u,f]of e.mutationRevisionBySessionId)f>s&&o.add(u);if(o.size===0)return{activeSessions:t,archivedSessions:n};const r=new Map(e.activeSessions.map(u=>[u.id,u])),a=new Map(e.archivedSessions.map(u=>[u.id,u]));let l=t.filter(u=>!o.has(u.id)),c=n.filter(u=>!o.has(u.id));for(const u of o){const f=r.get(u),h=a.get(u);f?l=oi(l,f):h&&(c=oi(c,h))}return{activeSessions:l,archivedSessions:c}},l4=(e,t)=>{const n=e.mutationRevision+1,s=new Map(e.mutationRevisionBySessionId);for(const o of t)s.set(o,n);return{mutationRevision:n,mutationRevisionBySessionId:s}},m6=(e,t)=>{const n=l4(e,t.map(r=>r.id));let s=e.activeSessions,o=e.archivedSessions;for(const r of t){const a=s.find(u=>u.id===r.id)??o.find(u=>u.id===r.id)??null,l=Zi(r,a),c=!!l.time?.archived;s=c?h6(s,r.id):oi(s,l),o=c?oi(o,l):h6(o,r.id)}return s===e.activeSessions&&o===e.archivedSessions?n:{activeSessions:s,archivedSessions:o,sessionsByDirectory:s===e.activeSessions?e.sessionsByDirectory:Os(s),...n}},Yt=W1((e,t)=>({activeSessions:[],archivedSessions:[],sessionsByDirectory:new Map,mutationRevision:0,mutationRevisionBySessionId:new Map,hasLoaded:!1,status:"idle",applySnapshot:(n,s,o="ready")=>{xb(n),e(r=>Vs(r,n,s,o))},resetForRuntimeSwitch:()=>{Ht+=1,rn=null,Zs&&(Zs(),Zs=null),e({activeSessions:[],archivedSessions:[],sessionsByDirectory:new Map,mutationRevision:0,mutationRevisionBySessionId:new Map,hasLoaded:!1,status:"idle"})},loadSessions:async n=>{if(rn)return rn;p6(),e(l=>l.status==="loading"?l:{status:"loading"});const s=Ht,o=t().mutationRevision,r=(async()=>{try{const l=We(),c=j1.getState().projects.map(x=>x.path).filter(x=>typeof x=="string"&&x.length>0),u=y1().getState().directory,f=u6([...c,...u?[u]:[]]);if(f.size>0){const x=await f6(f,l);if(s!==Ht)return{activeSessions:[],archivedSessions:[]};const{active:S,archived:C}=jr(x.sessions);e(_=>{let L=$t(_.activeSessions,S,x.directories);L=Ga(L,n),Cn(_.activeSessions,L)&&(L=_.activeSessions);let A=$t(_.archivedSessions,C,x.directories);Cn(_.archivedSessions,A)&&(A=_.archivedSessions);const N=qo(_,L,A,o),k=x.directories.size>0?"ready":x.errors.length>0?"error":"ready";return Vs(_,N.activeSessions,N.archivedSessions,k)});const w=t();return{activeSessions:w.activeSessions,archivedSessions:w.archivedSessions}}const m=y1().getState(),p=Je(m.directory),g=m.focusPending||m.sessionsListStatus==="loading"||m.sessionsListStatus==="idle"||m.connection==="loading";if(!p||g){const x=t();return{activeSessions:x.activeSessions,archivedSessions:x.archivedSessions}}const y=Mu(m.catalog,[p]);if(s!==Ht)return{activeSessions:[],archivedSessions:[]};const{active:M,archived:b}=jr(y);e(x=>{const S=new Set([p]),C=$t(x.activeSessions,M,S),w=$t(x.archivedSessions,b,S),_=qo(x,C,w,o);return Vs(x,_.activeSessions,_.archivedSessions,"ready")});const v=t();return{activeSessions:v.activeSessions,archivedSessions:v.archivedSessions}}catch(l){if(s!==Ht)return{activeSessions:[],archivedSessions:[]};console.warn("[GlobalSessions] Failed to load sessions, using fallback snapshot:",l),e(u=>{const f=qo(u,Ga(u.activeSessions,n),u.archivedSessions,o);return Vs(u,f.activeSessions,f.archivedSessions,"error")});const c=t();return{activeSessions:c.activeSessions,archivedSessions:c.archivedSessions}}})();rn=r;const a=()=>{rn===r&&(rn=null)};return r.then(a,a),r},refreshSessionsForDirectories:async(n,s)=>{const o=u6(n);if(o.size===0){const h=t();return{activeSessions:h.activeSessions,archivedSessions:h.archivedSessions}}p6();const r=Ht,a=t().mutationRevision,l=await f6(o,We());if(r!==Ht){const h=t();return{activeSessions:h.activeSessions,archivedSessions:h.archivedSessions}}const{active:c,archived:u}=jr(l.sessions);e(h=>{let m=$t(h.activeSessions,c,l.directories);m=Ga(m,s),Cn(h.activeSessions,m)&&(m=h.activeSessions);let p=$t(h.archivedSessions,u,l.directories);Cn(h.archivedSessions,p)&&(p=h.archivedSessions);const g=qo(h,m,p,a);m=g.activeSessions,p=g.archivedSessions;const y=m===h.activeSessions?h.sessionsByDirectory:Os(m);return m===h.activeSessions&&p===h.archivedSessions&&y===h.sessionsByDirectory?h:{activeSessions:m,archivedSessions:p,sessionsByDirectory:y}});const f=t();return{activeSessions:f.activeSessions,archivedSessions:f.archivedSessions}},upsertSession:n=>{e(s=>m6(s,[n]))},upsertSessions:n=>{n.length!==0&&e(s=>m6(s,n))},removeSessions:n=>{const s=n instanceof Set?n:new Set(n);s.size!==0&&e(o=>{const r=l4(o,s),a=o.activeSessions.filter(c=>!s.has(c.id)),l=o.archivedSessions.filter(c=>!s.has(c.id));return a.length===o.activeSessions.length&&l.length===o.archivedSessions.length?r:{activeSessions:a,archivedSessions:l,sessionsByDirectory:Os(a),...r}})},archiveSessions:(n,s=Date.now())=>{const o=n instanceof Set?n:new Set(n);o.size!==0&&e(r=>{const a=l4(r,o),l=[],c=r.activeSessions.filter(f=>o.has(f.id)?(l.push({...f,time:{...f.time,archived:s}}),!1):!0);if(l.length===0)return a;const u=r.archivedSessions.filter(f=>!o.has(f.id));return{activeSessions:c,archivedSessions:[...l,...u],sessionsByDirectory:Os(c),...a}})}}));let Zs=null;const sw=()=>{const e=y1().getState();if(e.connection==="loading"||e.focusPending||e.sessionsListStatus==="loading"||e.sessionsListStatus==="idle")return;const t=Je(e.directory);if(!t)return;const n=Mu(e.catalog,[t]),{active:s,archived:o}=jr(n),r=new Set([t]);Yt.setState(a=>{const l=$t(a.activeSessions,s,r),c=$t(a.archivedSessions,o,r);return Vs(a,l,c,"ready")})},Mu=(e,t)=>{const n=[],s=new Set;for(const o of t){const r=Je(o);if(!r)continue;const a=e.byDirectory.get(r);if(a)for(const l of a){if(s.has(l))continue;const c=e.byId.get(l);c&&(n.push(Ri(c)),s.add(l))}}return n},p6=()=>{Zs||(Zs=y1().subscribe(sw))},g6=async e=>{const t=Yt.getState();return t.hasLoaded&&t.status!=="error"?{activeSessions:t.activeSessions,archivedSessions:t.archivedSessions}:t.loadSessions(e)},oO=async e=>Yt.getState().loadSessions(e),kn="oc.sessions.folders",An="oc.sessions.folderCollapse",ri="oc.sessions.folders.v2.index",Cu="/api/pi/session-folders",ow=250,b2=yt(),Wa=o3();let H0=null,c4=!1,Ir=!1,Fs,$s,qs=null,Us=null,Rn=null,rt=We(),Hn=0,ii=0;const ai=new Map,r0=(e,t)=>`${e}.v2:${encodeURIComponent(t)}`,k3=()=>{try{const e=JSON.parse(b2.getItem(ri)??"");return e.version===2&&Array.isArray(e.runtimes)?{version:2,legacyClaimed:!!e.legacyClaimed,runtimes:e.runtimes}:{version:2,legacyClaimed:!1,runtimes:[]}}catch{return{version:2,legacyClaimed:!1,runtimes:[]}}},io=(e,t=Date.now(),n=b2)=>{const s=k3(),o=[{runtimeKey:e,updatedAt:t},...s.runtimes.filter(r=>r.runtimeKey!==e)];n.setItem(ri,JSON.stringify({version:2,legacyClaimed:s.legacyClaimed,runtimes:o}))},Su=e=>{const t=k3();if(t.legacyClaimed)return;const n=b2.getItem(kn),s=b2.getItem(An);n&&b2.setItem(r0(kn,e),n),s&&b2.setItem(r0(An,e),s);const o={...t,legacyClaimed:!0};b2.setItem(ri,JSON.stringify(o)),b2.getItem(ri)===JSON.stringify(o)&&(b2.removeItem(kn),b2.removeItem(An)),io(e,0)},rw=(e,t)=>{if(typeof window>"u")return;H0&&clearTimeout(H0);const n=JSON.parse(JSON.stringify(e)),s=Array.from(t),o=rt,r=Hn;H0=setTimeout(()=>{if(H0=null,o!==We()||r!==Hn)return;const a=Math.max(Date.now(),(ai.get(o)??0)+1);ai.set(o,a),V1(Cu,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({version:1,foldersMap:n,collapsedFolderIds:s,updatedAt:a})}).catch(()=>{})},ow)},y6=(e=rt)=>{try{Su(e);const t=b2.getItem(r0(kn,e));if(!t)return{};const n=JSON.parse(t);if(!n||typeof n!="object"||Array.isArray(n))return{};const s={};for(const[o,r]of Object.entries(n)){if(!Array.isArray(r))continue;const a=[];for(const l of r){if(!l||typeof l!="object")continue;const c=l,u=typeof c.id=="string"?c.id.trim():"",f=typeof c.name=="string"?c.name.trim():"",h=typeof c.createdAt=="number"?c.createdAt:0;if(!u||!f)continue;const m=Array.isArray(c.sessionIds)?c.sessionIds.filter(g=>typeof g=="string"&&g.trim().length>0):[],p=typeof c.parentId=="string"?c.parentId:null;a.push({id:u,name:f,sessionIds:m,createdAt:h,parentId:p})}a.length>0&&(s[o]=a)}return s}catch{return{}}},v6=(e=rt)=>{try{Su(e);const t=b2.getItem(r0(An,e));if(!t)return new Set;const n=JSON.parse(t);return Array.isArray(n)?new Set(n.filter(s=>typeof s=="string")):new Set}catch{return new Set}},_u=e=>{qs=e,Rn=rt,clearTimeout(Fs),Fs=setTimeout(()=>{try{const t=Rn??rt;b2.setItem(r0(kn,t),JSON.stringify(e)),io(t),qs=null}catch{}},300)},ku=e=>{Us=e,Rn=rt,clearTimeout($s),$s=setTimeout(()=>{try{const t=Rn??rt;b2.setItem(r0(An,t),JSON.stringify(Array.from(e))),io(t),Us=null}catch{}},300)},Au=()=>{Fs&&clearTimeout(Fs),$s&&clearTimeout($s),Fs=void 0,$s=void 0;const e=Rn??rt;let t=!1;if(qs!==null){const n=r0(kn,e),s=JSON.stringify(qs);b2.setItem(n,s),Wa.setItem(n,s),qs=null,t=!0}if(Us!==null){const n=r0(An,e),s=JSON.stringify(Array.from(Us));b2.setItem(n,s),Wa.setItem(n,s),Us=null,t=!0}if(t){const n=Date.now();io(e,n),io(e,n,Wa)}Rn=null};if(typeof window<"u"){const e=()=>{try{Au()}catch{}};window.addEventListener("pagehide",e,{capture:!0}),window.addEventListener("beforeunload",e,{capture:!0}),typeof document<"u"&&(document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&e()}),document.addEventListener("freeze",e))}const _t=(e,t)=>{ii+=1,_u(e),ku(t),rw(e,t)},iw=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`folder_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,ls=(e,t,n)=>{const s=new Set(t.map(r=>r.id));let o=null;for(const r of e)!s.has(r.id)&&n.has(r.id)&&(o||(o=new Set(n)),o.delete(r.id));return o},Hu=W1()($0((e,t)=>({foldersMap:y6(),collapsedFolderIds:v6(),resetForRuntimeSwitch:n=>{try{Au()}catch{}rt=n,Hn+=1,ii=0,c4=!1,Ir=!1,H0&&clearTimeout(H0),H0=null,e({foldersMap:y6(n),collapsedFolderIds:v6(n)}),queueMicrotask(()=>{Lu()})},getFoldersForScope:n=>n?t().foldersMap[n]??[]:[],createFolder:(n,s,o)=>{const r=s.trim()||"New folder",a={id:iw(),name:r,sessionIds:[],createdAt:Date.now(),parentId:o??null},l=t().foldersMap,c=l[n]??[],u={...l,[n]:[...c,a]};return e({foldersMap:u}),_t(u,t().collapsedFolderIds),a},renameFolder:(n,s,o)=>{const r=o.trim();if(!r||!n)return;const a=t().foldersMap,l=a[n];if(!l)return;const c=l.map(f=>f.id===s?{...f,name:r}:f),u={...a,[n]:c};e({foldersMap:u}),_t(u,t().collapsedFolderIds)},deleteFolder:(n,s)=>{if(!n)return;const o=t().foldersMap,r=o[n];if(!r)return;const a=new Set([s]);let l=!0;for(;l;){l=!1;for(const m of r)m.parentId&&a.has(m.parentId)&&!a.has(m.id)&&(a.add(m.id),l=!0)}const c=r.filter(m=>!a.has(m.id)),u={...o,[n]:c},f=t().collapsedFolderIds,h=ls(r,c,f);e(h?{foldersMap:u,collapsedFolderIds:h}:{foldersMap:u}),_t(u,h??f)},addSessionToFolder:(n,s,o)=>{if(!n||!s||!o)return;const r=t().foldersMap,a=r[n];if(!a)return;const l=a.find(m=>m.id===s);if(!l)return;const c=a.reduce((m,p)=>m+(p.sessionIds.includes(o)?1:0),0);if(l.sessionIds.includes(o)&&c===1)return;const u=a.map(m=>{const p=m.sessionIds.filter(g=>g!==o);return m.id===s?{...m,sessionIds:[...p,o]}:p.length!==m.sessionIds.length?{...m,sessionIds:p}:m}),f={...r,[n]:u},h=ls(a,u,t().collapsedFolderIds);e(h?{foldersMap:f,collapsedFolderIds:h}:{foldersMap:f}),_t(f,h??t().collapsedFolderIds)},addSessionsToFolder:(n,s,o)=>{if(!n||!s||o.length===0)return;const r=t().foldersMap,a=r[n];if(!a)return;const l=new Set(o.filter(p=>typeof p=="string"&&p.length>0));if(l.size===0)return;const c=a.find(p=>p.id===s);if(!c)return;let u=!1;for(const p of a){for(const g of l)if(p.sessionIds.includes(g)&&(p.id!==s||!c.sessionIds.includes(g))){u=!0;break}if(u)break}if(!u){for(const p of l)if(!c.sessionIds.includes(p)){u=!0;break}}if(!u)return;const f=a.map(p=>{const g=p.sessionIds.filter(y=>!l.has(y));return p.id===s?{...p,sessionIds:[...g,...l]}:g.length!==p.sessionIds.length?{...p,sessionIds:g}:p}),h={...r,[n]:f},m=ls(a,f,t().collapsedFolderIds);e(m?{foldersMap:h,collapsedFolderIds:m}:{foldersMap:h}),_t(h,m??t().collapsedFolderIds)},removeSessionsFromFolders:(n,s)=>{if(!n||s.length===0)return;const o=t().foldersMap,r=o[n];if(!r)return;const a=new Set(s.filter(h=>typeof h=="string"&&h.length>0));if(a.size===0)return;let l=!1;const c=r.map(h=>{const m=h.sessionIds.filter(p=>!a.has(p));return m.length!==h.sessionIds.length?(l=!0,{...h,sessionIds:m}):h});if(!l)return;const u={...o,[n]:c},f=ls(r,c,t().collapsedFolderIds);e(f?{foldersMap:u,collapsedFolderIds:f}:{foldersMap:u}),_t(u,f??t().collapsedFolderIds)},removeSessionFromFolder:(n,s)=>{if(!n||!s)return;const o=t().foldersMap,r=o[n];if(!r)return;let a=!1;const l=r.map(f=>{const h=f.sessionIds.filter(m=>m!==s);return h.length!==f.sessionIds.length?(a=!0,{...f,sessionIds:h}):f});if(!a)return;const c={...o,[n]:l},u=ls(r,l,t().collapsedFolderIds);e(u?{foldersMap:c,collapsedFolderIds:u}:{foldersMap:c}),_t(c,u??t().collapsedFolderIds)},removeSessionEverywhere:(n,s)=>{if(!n||n!==rt||n!==We()||!s)return;const o=t().foldersMap;let r=null;for(const[a,l]of Object.entries(o)){let c=!1;const u=l.map(f=>{const h=f.sessionIds.filter(m=>m!==s);return h.length===f.sessionIds.length?f:(c=!0,{...f,sessionIds:h})});c&&(r??={...o},r[a]=u)}r&&(e({foldersMap:r}),_t(r,t().collapsedFolderIds))},toggleFolderCollapse:n=>{const s=t().collapsedFolderIds,o=new Set(s);o.has(n)?o.delete(n):o.add(n),e({collapsedFolderIds:o}),_t(t().foldersMap,o)},getSessionFolderId:(n,s)=>{if(!n||!s)return null;const o=t().foldersMap[n];if(!o)return null;for(const r of o)if(r.sessionIds.includes(s))return r.id;return null}}),{name:"session-folders-store"})),Lu=async()=>{if(c4||Ir||typeof window>"u")return;Ir=!0;const e=rt,t=Hn,n=ii;let s=!1;try{const o=await V1(Cu).catch(()=>null);if(!o||!o.ok)return;const r=await o.json().catch(()=>null);if(!r)return;if(r.exists===!1){s=!0;return}const a=r.foldersMap&&typeof r.foldersMap=="object"?r.foldersMap:{},l=Array.isArray(r.collapsedFolderIds)?new Set(r.collapsedFolderIds.filter(h=>typeof h=="string")):new Set;if(t!==Hn||e!==We())return;const c=k3().runtimes.find(h=>h.runtimeKey===e)?.updatedAt??0,u=typeof r.updatedAt=="number"&&Number.isFinite(r.updatedAt)?r.updatedAt:0;u>0&&ai.set(e,Math.max(ai.get(e)??0,u)),(r.exists===!0||u>0)&&ii===n&&u>=c&&(Hu.setState({foldersMap:a,collapsedFolderIds:l}),_u(a),ku(l)),s=!0}catch{}finally{t===Hn&&e===We()&&(Ir=!1,s&&(c4=!0))}},aw=()=>{typeof window>"u"||Lu()};aw();const lw=5e3,Gs=new Map,Ws=new Map,d4=e=>{const t=We();Gs.delete(t),Ws.delete(t),(!t||t==="local")&&(Gs.clear(),Ws.clear())},R2=W1()($0(yo((e,t)=>({selectedSkillName:null,skills:[],isLoading:!1,setSelectedSkill:n=>e({selectedSkillName:n}),loadSkills:async()=>{const n=We(),s=Date.now(),o=Gs.get(n)??0;if(o>0&&s-o<lw)return!0;const r=Ws.get(n);if(r)return r;const a=(async()=>{e({isLoading:!0});try{const c=(await i1.listResources({runtimeKey:n})).skills.map(u=>({id:u.id,name:u.name,path:u.id,scope:u.location==="project"?"project":"user",source:"agents",...u.description?{description:u.description}:{},location:u.location,...typeof u.content=="string"&&u.content.length>0?{content:u.content}:{},...u.editable===!0?{editable:!0}:{}}));return e(u=>({skills:c,isLoading:!1,...u.selectedSkillName&&!c.some(f=>f.name===u.selectedSkillName)?{selectedSkillName:null}:{}})),Gs.set(n,Date.now()),!0}catch{return e({isLoading:!1}),!1}})();Ws.set(n,a);try{return await a}finally{Ws.delete(n)}},renameSkill:async()=>!1,updateSkillContent:async(n,s)=>{const o=t().skills.find(r=>r.name===n);if(!o)return!1;try{const a=(await i1.updateResource({resourceId:o.id,content:s},{runtimeKey:We()})).skills.map(l=>({id:l.id,name:l.name,path:l.id,scope:l.location==="project"?"project":"user",source:"agents",...l.description?{description:l.description}:{},location:l.location,...typeof l.content=="string"&&l.content.length>0?{content:l.content}:{},...l.editable===!0?{editable:!0}:{}}));return e({skills:a}),Gs.set(We(),Date.now()),!0}catch{return!1}},getSkillByName:n=>t().skills.find(s=>s.name===n)}),{name:"skills-store",storage:Bi(),partialize:e=>({selectedSkillName:e.selectedSkillName})}),{name:"skills-store"})),rO=Object.freeze(Object.defineProperty({__proto__:null,invalidateSkillsLoadCache:d4,useSkillsStore:R2},Symbol.toStringTag,{value:"Module"})),Ln=new Map,b6=e=>{Ln.set(e,(Ln.get(e)??0)+1)},cw=e=>(Ln.get(e)??0)>0,dw=e=>{const t=Ln.get(e)??0;return t<=0?!1:(t===1?Ln.delete(e):Ln.set(e,t-1),!0)},uw=e=>e.filter(s=>s?.type==="text").map(s=>(s.text||s.content||"").trim()).filter(s=>s.length>0).join(`
5
5
  `).replace(/\n\s*\n+/g,`
@@ -365,9 +365,9 @@ ${n}
365
365
 
366
366
  :root:not(.dark) {
367
367
  ${n}
368
- }`,document.documentElement.classList.remove("dark"),document.documentElement.classList.add("light")),s.textContent=o;const r=document.getElementById("opencode-theme-variables");r&&r.remove(),document.head.appendChild(s),document.documentElement.setAttribute("data-theme",t.metadata.variant)}generatePrimaryColors(t){const n=[];return n.push(` --primary-base: ${t.base};`),n.push(` --primary-hover: ${t.hover||this.darken(t.base,10)};`),n.push(` --primary-active: ${t.active||this.darken(t.base,20)};`),n.push(` --primary-foreground: ${t.foreground||"#ffffff"};`),n.push(` --primary-muted: ${t.muted||this.opacity(t.base,.5)};`),n.push(` --primary-emphasis: ${t.emphasis||this.lighten(t.base,10)};`),n}generateSurfaceColors(t){const n=[];return n.push(` --surface-background: ${t.background};`),n.push(` --surface-foreground: ${t.foreground};`),n.push(` --surface-muted: ${t.muted};`),n.push(` --surface-muted-foreground: ${t.mutedForeground};`),n.push(` --surface-elevated: ${t.elevated};`),n.push(` --surface-elevated-foreground: ${t.elevatedForeground};`),n.push(` --surface-overlay: ${t.overlay};`),n.push(` --surface-subtle: ${t.subtle};`),n}generateInteractiveColors(t){const n=[];return n.push(` --interactive-border: ${t.border};`),n.push(` --interactive-border-hover: ${t.borderHover};`),n.push(` --interactive-border-focus: ${t.borderFocus};`),n.push(` --interactive-selection: ${t.selection};`),n.push(` --interactive-selection-foreground: ${t.selectionForeground};`),n.push(` --interactive-focus: ${t.focus};`),n.push(` --interactive-focus-ring: ${t.focusRing};`),n.push(` --interactive-cursor: ${t.cursor};`),n.push(` --interactive-hover: ${t.hover};`),n.push(` --interactive-active: ${t.active};`),n}generateStatusColors(t){const n=[];return n.push(` --status-error: ${t.error};`),n.push(` --status-error-foreground: ${t.errorForeground};`),n.push(` --status-error-background: ${t.errorBackground};`),n.push(` --status-error-border: ${t.errorBorder};`),n.push(` --status-warning: ${t.warning};`),n.push(` --status-warning-foreground: ${t.warningForeground};`),n.push(` --status-warning-background: ${t.warningBackground};`),n.push(` --status-warning-border: ${t.warningBorder};`),n.push(` --status-success: ${t.success};`),n.push(` --status-success-foreground: ${t.successForeground};`),n.push(` --status-success-background: ${t.successBackground};`),n.push(` --status-success-border: ${t.successBorder};`),n.push(` --status-info: ${t.info};`),n.push(` --status-info-foreground: ${t.infoForeground};`),n.push(` --status-info-background: ${t.infoBackground};`),n.push(` --status-info-border: ${t.infoBorder};`),n}generatePullRequestColors(t){const n=[],s=t.colors.pr;return n.push(` --pr-open: ${s?.open||t.colors.status.success};`),n.push(` --pr-draft: ${s?.draft||t.colors.surface.mutedForeground};`),n.push(` --pr-blocked: ${s?.blocked||t.colors.status.warning};`),n.push(` --pr-merged: ${s?.merged||(t.metadata.variant==="dark"?"#8957e5":"#8250df")};`),n.push(` --pr-closed: ${s?.closed||t.colors.status.error};`),n}generateSyntaxColors(t){const n=[];n.push(` --syntax-background: ${t.base.background};`),n.push(` --syntax-foreground: ${t.base.foreground};`),n.push(` --syntax-comment: ${t.base.comment};`),n.push(` --syntax-keyword: ${t.base.keyword};`),n.push(` --syntax-string: ${t.base.string};`),n.push(` --syntax-number: ${t.base.number};`),n.push(` --syntax-function: ${t.base.function};`),n.push(` --syntax-variable: ${t.base.variable};`),n.push(` --syntax-type: ${t.base.type};`),n.push(` --syntax-operator: ${t.base.operator};`);const s=this.generateSyntaxTokens(t);for(const[o,r]of Object.entries(s))n.push(` --syntax-${this.kebabCase(o)}: ${r};`);return n}generateSyntaxTokens(t){const n=t.base,s=t.tokens||{};return{commentDoc:s.commentDoc||this.lighten(n.comment,10),stringEscape:s.stringEscape||this.darken(n.string,20),stringInterpolation:s.stringInterpolation||n.variable,stringRegex:s.stringRegex||this.adjustHue(n.string,15),keywordControl:s.keywordControl||n.keyword,keywordOperator:s.keywordOperator||n.operator,keywordImport:s.keywordImport||this.lighten(n.keyword,10),keywordReturn:s.keywordReturn||this.emphasize(n.keyword),functionCall:s.functionCall||this.lighten(n.function,5),functionBuiltin:s.functionBuiltin||this.darken(n.function,10),method:s.method||n.function,methodCall:s.methodCall||this.lighten(n.function,5),variableBuiltin:s.variableBuiltin||this.emphasize(n.variable),variableProperty:s.variableProperty||this.lighten(n.variable,10),variableReadonly:s.variableReadonly||n.number,parameter:s.parameter||n.variable,typePrimitive:s.typePrimitive||this.darken(n.type,10),typeInterface:s.typeInterface||n.type,className:s.className||this.emphasize(n.type),enum:s.enum||n.type,boolean:s.boolean||n.number,null:s.null||this.opacity(n.number,.7),constant:s.constant||n.number,punctuation:s.punctuation||this.opacity(n.foreground,.7),delimiter:s.delimiter||this.opacity(n.foreground,.8),bracket:s.bracket||n.foreground,tag:s.tag||n.keyword,tagAttribute:s.tagAttribute||n.variable,tagAttributeValue:s.tagAttributeValue||n.string,tagBracket:s.tagBracket||this.opacity(n.foreground,.8),decorator:s.decorator||n.function,annotation:s.annotation||n.function,namespace:s.namespace||this.opacity(n.type,.8),module:s.module||this.opacity(n.type,.8),...s}}generateComponentColors(t,n){const s=[];return t.markdown?s.push(...this.generateMarkdownColors(t.markdown,n)):s.push(...this.generateDefaultMarkdownColors(n)),t.chat?s.push(...this.generateChatColors(t.chat,n)):s.push(...this.generateDefaultChatColors(n)),t.tools?s.push(...this.generateToolColors(t.tools,n)):s.push(...this.generateDefaultToolColors(n)),s}generateMarkdownColors(t,n){const s=[],o=n.colors.primary.base,r=n.colors.chat?.background||n.colors.surface.background;return s.push(` --markdown-heading1: ${t.heading1||o};`),s.push(` --markdown-heading2: ${t.heading2||this.opacity(o,.9)};`),s.push(` --markdown-heading3: ${t.heading3||this.opacity(o,.8)};`),s.push(` --markdown-heading4: ${t.heading4||n.colors.surface.foreground};`),s.push(` --markdown-link: ${t.link||o};`),s.push(` --markdown-link-hover: ${t.linkHover||n.colors.primary.hover||this.darken(o,10)};`),s.push(` --markdown-inline-code: ${t.inlineCode||n.colors.syntax.base.string};`),s.push(` --markdown-inline-code-bg: ${t.inlineCodeBackground||r};`),s.push(` --markdown-blockquote: ${t.blockquote||n.colors.surface.mutedForeground};`),s.push(` --markdown-blockquote-border: ${t.blockquoteBorder||n.colors.interactive.border};`),s.push(` --markdown-list-marker: ${t.listMarker||this.opacity(o,.6)};`),s.push(` --markdown-bold: ${t.bold||n.colors.surface.foreground};`),s.push(` --markdown-italic: ${t.italic||this.opacity(n.colors.surface.foreground,.9)};`),s.push(` --markdown-strikethrough: ${t.strikethrough||n.colors.surface.mutedForeground};`),s.push(` --markdown-hr: ${t.hr||n.colors.interactive.border};`),s}generateDefaultMarkdownColors(t){const n=[],s=t.colors.primary.base,o=t.colors.chat?.background||t.colors.surface.background;return n.push(` --markdown-heading1: ${s};`),n.push(` --markdown-heading2: ${this.opacity(s,.9)};`),n.push(` --markdown-heading3: ${this.opacity(s,.8)};`),n.push(` --markdown-heading4: ${t.colors.surface.foreground};`),n.push(` --markdown-link: ${s};`),n.push(` --markdown-link-hover: ${t.colors.primary.hover||this.darken(s,10)};`),n.push(` --markdown-inline-code: ${t.colors.syntax.base.string};`),n.push(` --markdown-inline-code-bg: ${o};`),n.push(` --markdown-blockquote: ${t.colors.surface.mutedForeground};`),n.push(` --markdown-blockquote-border: ${t.colors.interactive.border};`),n.push(` --markdown-list-marker: ${this.opacity(s,.6)};`),n.push(` --markdown-bold: ${t.colors.surface.foreground};`),n.push(` --markdown-italic: ${this.opacity(t.colors.surface.foreground,.9)};`),n.push(` --markdown-strikethrough: ${t.colors.surface.mutedForeground};`),n.push(` --markdown-hr: ${t.colors.interactive.border};`),n}generateChatColors(t,n){const s=[],o=t.background||n.colors.surface.background;return s.push(` --chat-background: ${o};`),s.push(` --chat-user-message: ${t.userMessage||n.colors.surface.foreground};`),s.push(` --chat-user-message-bg: ${t.userMessageBackground||n.colors.surface.elevated};`),s.push(` --chat-assistant-message: ${t.assistantMessage||n.colors.surface.foreground};`),s.push(` --chat-assistant-message-bg: ${t.assistantMessageBackground||n.colors.surface.muted};`),s.push(` --chat-timestamp: ${t.timestamp||n.colors.surface.mutedForeground};`),s.push(` --chat-divider: ${t.divider||n.colors.interactive.border};`),s.push(` --chat-typing: ${t.typing||n.colors.surface.mutedForeground};`),s}generateDefaultChatColors(t){const n=[];return n.push(` --chat-background: ${t.colors.surface.background};`),n.push(` --chat-user-message: ${t.colors.surface.foreground};`),n.push(` --chat-user-message-bg: ${t.colors.surface.elevated};`),n.push(` --chat-assistant-message: ${t.colors.surface.foreground};`),n.push(` --chat-assistant-message-bg: ${t.colors.surface.muted};`),n.push(` --chat-timestamp: ${t.colors.surface.mutedForeground};`),n.push(` --chat-divider: ${t.colors.interactive.border};`),n.push(` --chat-typing: ${t.colors.surface.mutedForeground};`),n}generateToolColors(t,n){const s=[];return s.push(` --tools-background: ${t?.background||this.opacity(n.colors.surface.muted,.2)};`),s.push(` --tools-border: ${t?.border||this.opacity(n.colors.interactive.border,.3)};`),s.push(` --tools-header-hover: ${t?.headerHover||this.opacity(n.colors.surface.muted,.3)};`),s.push(` --tools-icon: ${t?.icon||n.colors.surface.mutedForeground};`),s.push(` --tools-title: ${t?.title||n.colors.surface.foreground};`),s.push(` --tools-description: ${t?.description||this.opacity(n.colors.surface.mutedForeground,.6)};`),t?.edit?(s.push(` --tools-edit-added: ${t.edit.added||n.colors.status.success};`),s.push(` --tools-edit-added-bg: ${t.edit.addedBackground||n.colors.status.successBackground};`),s.push(` --tools-edit-removed: ${t.edit.removed||n.colors.status.error};`),s.push(` --tools-edit-removed-bg: ${t.edit.removedBackground||n.colors.status.errorBackground};`),s.push(` --tools-edit-modified: ${t.edit.modified||n.colors.status.info};`),s.push(` --tools-edit-modified-bg: ${t.edit.modifiedBackground||n.colors.status.infoBackground};`),s.push(` --tools-edit-line-number: ${t.edit.lineNumber||this.opacity(n.colors.surface.mutedForeground,.6)};`)):(s.push(` --tools-edit-added: ${n.colors.status.success};`),s.push(` --tools-edit-added-bg: ${n.colors.status.successBackground};`),s.push(` --tools-edit-removed: ${n.colors.status.error};`),s.push(` --tools-edit-removed-bg: ${n.colors.status.errorBackground};`),s.push(` --tools-edit-modified: ${n.colors.status.info};`),s.push(` --tools-edit-modified-bg: ${n.colors.status.infoBackground};`),s.push(` --tools-edit-line-number: ${this.opacity(n.colors.surface.mutedForeground,.6)};`)),s}generateDefaultToolColors(t){const n=[];return n.push(` --tools-background: ${this.opacity(t.colors.surface.muted,.2)};`),n.push(` --tools-border: ${this.opacity(t.colors.interactive.border,.3)};`),n.push(` --tools-header-hover: ${this.opacity(t.colors.surface.muted,.3)};`),n.push(` --tools-icon: ${t.colors.surface.mutedForeground};`),n.push(` --tools-title: ${t.colors.surface.foreground};`),n.push(` --tools-description: ${this.opacity(t.colors.surface.mutedForeground,.6)};`),n.push(` --tools-edit-added: ${t.colors.status.success};`),n.push(` --tools-edit-added-bg: ${this.addTransparency(this.removeTransparency(t.colors.status.successBackground),.15)};`),n.push(` --tools-edit-removed: ${t.colors.status.error};`),n.push(` --tools-edit-removed-bg: ${this.addTransparency(this.removeTransparency(t.colors.status.errorBackground),.15)};`),n.push(` --tools-edit-modified: ${t.colors.status.info};`),n.push(` --tools-edit-modified-bg: ${this.addTransparency(this.removeTransparency(t.colors.status.infoBackground),.15)};`),n.push(` --tools-edit-line-number: ${this.opacity(t.colors.surface.mutedForeground,.6)};`),n}generateConfigVariables(t){const n=[];return t&&(t.fonts&&(t.fonts.sans&&(n.push(` --font-sans: ${t.fonts.sans};`),n.push(` --font-family-sans: ${t.fonts.sans};`)),t.fonts.mono&&(n.push(` --font-mono: ${t.fonts.mono};`),n.push(` --font-family-mono: ${t.fonts.mono};`)),t.fonts.heading&&n.push(` --font-heading: ${t.fonts.heading};`)),t.transitions&&(t.transitions.fast&&n.push(` --transition-fast: ${t.transitions.fast};`),t.transitions.normal&&n.push(` --transition-normal: ${t.transitions.normal};`),t.transitions.slow&&n.push(` --transition-slow: ${t.transitions.slow};`))),n}generateTypographyVariables(){const t=[],n=Sg;return t.push(" /* Semantic Typography Variables */"),t.push(" --ui-regular-font-weight: 400;"),t.push(" /* Markdown content - all markdown elements use same size */"),t.push(` --text-markdown: ${n.markdown};`),t.push(" /* Code content - all code elements use same size */"),t.push(` --text-code: ${n.code};`),t.push(" /* UI headers - dialog titles, panel headers */"),t.push(` --text-ui-header: ${n.uiHeader};`),t.push(" /* UI labels - buttons, menus, navigation */"),t.push(` --text-ui-label: ${n.uiLabel};`),t.push(" /* Metadata - timestamps, status, helper text */"),t.push(` --text-meta: ${n.meta};`),t.push(" /* Micro text - badges, shortcuts, indicators */"),t.push(` --text-micro: ${n.micro};`),t.push(" /* Settings page titles - larger than section headers */"),t.push(` --text-settings-page-title: ${n.settingsPageTitle};`),t.push(" /* Heading line height and letter spacing */"),t.push(" --h1-line-height: 1.25rem;"),t.push(" --h2-line-height: 1.25rem;"),t.push(" --h3-line-height: 1.5rem;"),t.push(" --h4-line-height: 1.5rem;"),t.push(" --h5-line-height: 1.5rem;"),t.push(" --h6-line-height: 1.5rem;"),t.push(" --h1-letter-spacing: -0.025em;"),t.push(" --h2-letter-spacing: -0.02em;"),t.push(" --h3-letter-spacing: -0.015em;"),t.push(" --h4-letter-spacing: -0.01em;"),t.push(" --h5-letter-spacing: 0;"),t.push(" --h6-letter-spacing: 0.01em;"),t.push(" /* UI element line height and letter spacing */"),t.push(" --ui-button-line-height: 1.375rem;"),t.push(" --ui-button-letter-spacing: 0.02em;"),t.push(" --ui-button-font-weight: 500;"),t.push(" --ui-label-line-height: 1rem;"),t.push(" --ui-label-letter-spacing: 0.03em;"),t.push(" --ui-label-font-weight: 500;"),t.push(" --ui-caption-line-height: 1rem;"),t.push(" --ui-caption-letter-spacing: 0.025em;"),t.push(" --ui-caption-font-weight: var(--ui-regular-font-weight, 400);"),t.push(" /* Markdown line height and letter spacing */"),t.push(" --markdown-body-line-height: 1.5rem;"),t.push(" --markdown-body-letter-spacing: 0;"),t.push(" --markdown-body-font-weight: var(--ui-regular-font-weight, 400);"),t.push(" --markdown-h1-line-height: 1.25rem;"),t.push(" --markdown-h1-letter-spacing: -0.025em;"),t.push(" --markdown-h2-line-height: 1.25rem;"),t.push(" --markdown-h2-letter-spacing: -0.02em;"),t.push(" --markdown-h3-line-height: 1.5rem;"),t.push(" --markdown-h3-letter-spacing: -0.015em;"),t.push(" --markdown-h4-line-height: 1.5rem;"),t.push(" --markdown-h4-letter-spacing: -0.01em;"),t.push(" --markdown-h5-line-height: 1.5rem;"),t.push(" --markdown-h5-letter-spacing: 0;"),t.push(" --markdown-h6-line-height: 1.5rem;"),t.push(" --markdown-h6-letter-spacing: 0.01em;"),t.push(" --markdown-list-line-height: 1.375rem;"),t.push(" --markdown-code-block-line-height: 1rem;"),t.push(" --ui-button-small-line-height: 1.25rem;"),t.push(" --ui-button-small-letter-spacing: 0.02em;"),t.push(" --ui-button-small-font-weight: 500;"),t.push(" --markdown-body-small-line-height: 1.375rem;"),t.push(" --markdown-body-small-letter-spacing: 0;"),t.push(" --markdown-body-small-font-weight: var(--ui-regular-font-weight, 400);"),t.push(" --ui-button-large-line-height: 1.5rem;"),t.push(" --ui-button-large-letter-spacing: 0.02em;"),t.push(" --ui-button-large-font-weight: 500;"),t.push(" --markdown-body-large-line-height: 1.625rem;"),t.push(" --markdown-body-large-letter-spacing: 0;"),t.push(" --markdown-body-large-font-weight: var(--ui-regular-font-weight, 400);"),t.push(" /* Code line height and letter spacing */"),t.push(" --code-inline-line-height: 1rem;"),t.push(" --code-inline-letter-spacing: 0;"),t.push(" --code-inline-font-weight: 400;"),t.push(" --code-block-line-height: round(1.4rem, 1px);"),t.push(" --code-block-letter-spacing: 0;"),t.push(" --code-block-font-weight: 400;"),t.push(" --code-line-numbers-line-height: 1.25rem;"),t.push(" --code-line-numbers-letter-spacing: 0;"),t.push(" --code-line-numbers-font-weight: 400;"),t.push(" /* Additional UI element line height and letter spacing */"),t.push(" --ui-badge-line-height: 1rem;"),t.push(" --ui-badge-letter-spacing: 0.025em;"),t.push(" --ui-badge-font-weight: 500;"),t.push(" --ui-tooltip-line-height: 1rem;"),t.push(" --ui-tooltip-letter-spacing: 0.025em;"),t.push(" --ui-tooltip-font-weight: var(--ui-regular-font-weight, 400);"),t.push(" --ui-input-line-height: 1.375rem;"),t.push(" --ui-input-letter-spacing: 0.02em;"),t.push(" --ui-input-font-weight: var(--ui-regular-font-weight, 400);"),t.push(" --ui-helper-text-line-height: 1rem;"),t.push(" --ui-helper-text-letter-spacing: 0.025em;"),t.push(" --ui-helper-text-font-weight: var(--ui-regular-font-weight, 400);"),t.push(" /* Additional markdown line height and letter spacing */"),t.push(" --markdown-blockquote-line-height: 1.5rem;"),t.push(" --markdown-blockquote-letter-spacing: 0;"),t.push(" --markdown-blockquote-font-weight: var(--ui-regular-font-weight, 400);"),t.push(" --markdown-list-letter-spacing: 0;"),t.push(" --markdown-list-font-weight: var(--ui-regular-font-weight, 400);"),t.push(" --markdown-link-line-height: 1.5rem;"),t.push(" --markdown-link-letter-spacing: 0;"),t.push(" --markdown-link-font-weight: var(--ui-regular-font-weight, 400);"),t.push(" --markdown-code-line-height: round(1.35em, 1px);"),t.push(" --markdown-code-letter-spacing: 0;"),t.push(" --markdown-code-font-weight: 400;"),t.push(" --markdown-code-block-letter-spacing: 0;"),t.push(" --markdown-code-block-font-weight: 400;"),t}initializeInheritanceMap(){this.inheritanceMap.set("header.background","surface.background"),this.inheritanceMap.set("header.foreground","surface.foreground"),this.inheritanceMap.set("header.logoTint","primary.base"),this.inheritanceMap.set("header.divider","interactive.border"),this.inheritanceMap.set("sidebar.background","surface.muted"),this.inheritanceMap.set("sidebar.foreground","surface.mutedForeground"),this.inheritanceMap.set("sidebar.hover","interactive.hover"),this.inheritanceMap.set("sidebar.active","primary.base"),this.inheritanceMap.set("sidebar.activeForeground","primary.foreground")}opacity(t,n){return t.startsWith("#")?`${t}${Math.round(n*255).toString(16).padStart(2,"0")}`:t.startsWith("rgb")?t.replace("rgb","rgba").replace(")",`, ${n})`):t}removeTransparency(t){return t.startsWith("#")?t.length===9?t.slice(0,7):t.length===5?t.slice(0,4):t:t.startsWith("rgba")?t.replace("rgba","rgb").replace(/,\s*[\d.]+\)$/,")"):t}addTransparency(t,n){if(t.startsWith("#")){const s=t.slice(1);if(s.length===3){const o=parseInt(s[0]+s[0],16),r=parseInt(s[1]+s[1],16),a=parseInt(s[2]+s[2],16);return`rgba(${o}, ${r}, ${a}, ${n})`}else if(s.length===6){const o=parseInt(s.slice(0,2),16),r=parseInt(s.slice(2,4),16),a=parseInt(s.slice(4,6),16);return`rgba(${o}, ${r}, ${a}, ${n})`}}return t.startsWith("rgb")?t.replace("rgb","rgba").replace(")",`, ${n})`):t}darken(t,n){if(t.startsWith("#")){const s=parseInt(t.slice(1),16),o=Math.round(2.55*n),r=(s>>16)-o,a=(s>>8&255)-o,l=(s&255)-o;return"#"+(16777216+(r<255?r<0?0:r:255)*65536+(a<255?a<0?0:a:255)*256+(l<255?l<0?0:l:255)).toString(16).slice(1)}return t}lighten(t,n){if(t.startsWith("#")){const s=parseInt(t.slice(1),16),o=Math.round(2.55*n),r=(s>>16)+o,a=(s>>8&255)+o,l=(s&255)+o;return"#"+(16777216+(r<255?r<0?0:r:255)*65536+(a<255?a<0?0:a:255)*256+(l<255?l<0?0:l:255)).toString(16).slice(1)}return t}adjustHue(t,n){return this.lighten(t,n/10)}emphasize(t){return this.lighten(t,15)}kebabCase(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}}const I6=(e,t)=>t.reduce((n,s)=>n&&typeof n=="object"?n[s]:void 0,e),mC=e=>typeof e=="string"&&e.trim().length>0,B6=e=>{if(!e||typeof e!="object")return!1;const t=[["metadata","id"],["metadata","name"],["metadata","variant"],["colors","primary","base"],["colors","primary","foreground"],["colors","surface","background"],["colors","surface","foreground"],["colors","surface","muted"],["colors","surface","mutedForeground"],["colors","surface","elevated"],["colors","surface","elevatedForeground"],["colors","surface","subtle"],["colors","interactive","border"],["colors","interactive","selection"],["colors","interactive","selectionForeground"],["colors","interactive","focusRing"],["colors","interactive","hover"],["colors","status","error"],["colors","status","errorForeground"],["colors","status","errorBackground"],["colors","status","errorBorder"],["colors","status","warning"],["colors","status","warningForeground"],["colors","status","warningBackground"],["colors","status","warningBorder"],["colors","status","success"],["colors","status","successForeground"],["colors","status","successBackground"],["colors","status","successBorder"],["colors","status","info"],["colors","status","infoForeground"],["colors","status","infoBackground"],["colors","status","infoBorder"],["colors","syntax","base","background"],["colors","syntax","base","foreground"],["colors","syntax","base","keyword"],["colors","syntax","base","string"],["colors","syntax","base","number"],["colors","syntax","base","function"],["colors","syntax","base","variable"],["colors","syntax","base","type"],["colors","syntax","base","comment"],["colors","syntax","base","operator"],["colors","syntax","highlights","diffAdded"],["colors","syntax","highlights","diffRemoved"],["colors","syntax","highlights","lineNumber"]];for(const s of t)if(!mC(I6(e,s)))return!1;const n=I6(e,["metadata","variant"]);return n==="light"||n==="dark"},pC=Hg,gC=Ag,yC=e=>jg(e==="dark"),vC=typeof window<"u"?d.useLayoutEffect:d.useEffect,bC=()=>{if(typeof document>"u")return;const e=document.documentElement;e.classList.add("oc-theme-switching");const t=window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{e.classList.remove("oc-theme-switching")})});return()=>{window.cancelAnimationFrame(t),e.classList.remove("oc-theme-switching")}},xC=e=>{let t=pC,n=gC,s="system";if(typeof window<"u"){const o=localStorage.getItem("themeMode"),r=localStorage.getItem("lightThemeId"),a=localStorage.getItem("darkThemeId"),l=localStorage.getItem("useSystemTheme"),c=localStorage.getItem("selectedThemeId"),u=localStorage.getItem("selectedThemeVariant");if(o==="light"||o==="dark"||o==="system")s=o;else if(l!==null){if(l==="true")s="system";else if(c){const h=cc(c);h&&(s=h.metadata.variant==="dark"?"dark":"light",h.metadata.variant==="dark"?n=h.metadata.id:t=h.metadata.id)}}else(u==="light"||u==="dark")&&(s=u);typeof r=="string"&&r.trim().length>0&&(t=r.trim()),typeof a=="string"&&a.trim().length>0&&(n=a.trim())}if(e){const o=cc(e);o&&(o.metadata.variant==="light"?t=o.metadata.id:n=o.metadata.id)}return{themeMode:s,lightThemeId:t,darkThemeId:n}};function WO({children:e,defaultThemeId:t}){const n=ae.useMemo(()=>new hC,[]),[s,o]=ae.useState(()=>xC(t)),[r,a]=ae.useState(()=>typeof window>"u"?!0:window.matchMedia("(prefers-color-scheme: dark)").matches),[l,c]=ae.useState([]),[u,f]=ae.useState([]),[h,m]=ae.useState(!1),p=ae.useMemo(()=>S1(),[]),g=ae.useRef(0),y=ae.useMemo(()=>{const k=[],V=new Set,H=D=>{const P=D.metadata.id;V.has(P)||(V.add(P),k.push(D))};return l.forEach(H),u.forEach(H),_g.forEach(H),k},[l,u]);ae.useEffect(()=>{const k=V=>{const H=V.detail;if(!B6(H))return;const D=Lg(H);f(P=>{const R=P.findIndex(O=>O.metadata.id===D.metadata.id);if(R<0)return[...P,D];const $=[...P];return $[R]=D,$})};return window.addEventListener("pichamber:theme-hmr",k),()=>window.removeEventListener("pichamber:theme-hmr",k)},[]);const M=ae.useCallback(k=>y.find(V=>V.metadata.id===k),[y]),b=ae.useCallback((k,V)=>{const H=M(k);return H&&H.metadata.variant===V?H:y.find(P=>P.metadata.variant===V)??yC(V)},[y,M]),v=ae.useMemo(()=>s.themeMode==="light"?b(s.lightThemeId,"light"):s.themeMode==="dark"||r?b(s.darkThemeId,"dark"):b(s.lightThemeId,"light"),[b,s,r]),x=ae.useCallback(async()=>{if(typeof window>"u")return;const k=We(),V=++g.current;m(!0);try{const H=await V1("/api/pi/themes",{method:"GET",credentials:kg()?"omit":"include",headers:{Accept:"application/json"}});if(H.status===401||!H.ok)return;const D=await H.json();if(V!==g.current||k!==We())return;const R=(Array.isArray(D?.themes)?D.themes:[]).filter(B6);c(R)}catch{}finally{V===g.current&&k===We()&&m(!1)}},[]);ae.useEffect(()=>{x()},[x]),ae.useEffect(()=>Wn(k=>{k.runtimeKey!==k.previousRuntimeKey&&(g.current+=1,c([]),m(!1),x())}),[x]);const S=ae.useCallback(k=>{if(typeof document>"u")return;const V=k.colors.surface.background;document.body.style.backgroundColor=V;let H=document.querySelector('meta[name="theme-color"]');H||(H=document.createElement("meta"),H.setAttribute("name","theme-color"),document.head.appendChild(H)),H.setAttribute("content",V);const D=k.metadata.variant==="dark"?"(prefers-color-scheme: dark)":"(prefers-color-scheme: light)";let P=document.querySelector(`meta[name="theme-color"][media="${D}"]`);P||(P=document.createElement("meta"),P.setAttribute("name","theme-color"),P.setAttribute("media",D),document.head.appendChild(P)),P.setAttribute("content",V)},[]);vC(()=>{if(typeof window>"u")return;const k=bC();n.apply(v),S(v);const V=document.documentElement;return V.classList.remove("light","dark"),V.classList.add(v.metadata.variant),k},[n,v,S]),ae.useEffect(()=>{if(s.themeMode!=="system"||typeof window>"u")return;const k=window.matchMedia("(prefers-color-scheme: dark)"),V=H=>{a(H.matches)};return a(k.matches),k.addEventListener("change",V),()=>k.removeEventListener("change",V)},[s.themeMode]),ae.useEffect(()=>{if(typeof window>"u")return;localStorage.setItem("themeMode",s.themeMode),localStorage.setItem("lightThemeId",s.lightThemeId),localStorage.setItem("darkThemeId",s.darkThemeId),localStorage.setItem("useSystemTheme",String(s.themeMode==="system")),localStorage.setItem("selectedThemeId",v.metadata.id),localStorage.setItem("selectedThemeVariant",v.metadata.variant==="light"?"light":"dark");const k=b(s.lightThemeId,"light"),V=b(s.darkThemeId,"dark");localStorage.setItem("splashBgLight",k.colors.surface.background),localStorage.setItem("splashFgLight",k.colors.surface.foreground),localStorage.setItem("splashBgDark",V.colors.surface.background),localStorage.setItem("splashFgDark",V.colors.surface.foreground)},[s,v,b]),ae.useEffect(()=>{if(typeof window>"u")return;const k=V=>{V.storageArea===window.localStorage&&(V.key!=="themeMode"&&V.key!=="lightThemeId"&&V.key!=="darkThemeId"||o(H=>{const D=localStorage.getItem("themeMode"),P=D==="light"||D==="dark"||D==="system"?D:H.themeMode,R=localStorage.getItem("lightThemeId"),$=typeof R=="string"&&R.trim().length>0?R.trim():H.lightThemeId,O=localStorage.getItem("darkThemeId"),I=typeof O=="string"&&O.trim().length>0?O.trim():H.darkThemeId;return P===H.themeMode&&$===H.lightThemeId&&I===H.darkThemeId?H:{themeMode:P,lightThemeId:$,darkThemeId:I}}))};return window.addEventListener("storage",k),()=>window.removeEventListener("storage",k)},[]),ae.useEffect(()=>{const k=b(s.lightThemeId,"light"),V=b(s.darkThemeId,"dark");Nn({themeId:v.metadata.id,themeVariant:v.metadata.variant==="light"?"light":"dark",useSystemTheme:s.themeMode==="system",lightThemeId:s.lightThemeId,darkThemeId:s.darkThemeId,splashBgLight:k.colors.surface.background,splashFgLight:k.colors.surface.foreground,splashBgDark:V.colors.surface.background,splashFgDark:V.colors.surface.foreground})},[v.metadata.id,v.metadata.variant,b,s.themeMode,s.lightThemeId,s.darkThemeId]),ae.useEffect(()=>{p&&(async()=>await fC(s.themeMode,v.metadata.variant))()},[v.metadata.variant,p,s.themeMode]),ae.useEffect(()=>{if(typeof window>"u")return;const k=V=>{const H=V.detail;H&&o(D=>{let P=D.themeMode;H.useSystemTheme===!0?P="system":H.useSystemTheme===!1&&(H.themeVariant==="dark"||H.themeVariant==="light")&&(P=H.themeVariant);let R=D.lightThemeId;typeof H.lightThemeId=="string"&&H.lightThemeId.length>0&&(R=H.lightThemeId.trim());let $=D.darkThemeId;return typeof H.darkThemeId=="string"&&H.darkThemeId.length>0&&($=H.darkThemeId.trim()),P===D.themeMode&&R===D.lightThemeId&&$===D.darkThemeId?D:{themeMode:P,lightThemeId:R,darkThemeId:$}})};return window.addEventListener("pichamber:settings-synced",k),()=>window.removeEventListener("pichamber:settings-synced",k)},[]);const C=ae.useCallback(k=>{const V=y.find(H=>H.metadata.id===k);V&&o(H=>V.metadata.variant==="dark"?H.darkThemeId===V.metadata.id&&H.themeMode==="dark"?H:{...H,darkThemeId:V.metadata.id,themeMode:"dark"}:H.lightThemeId===V.metadata.id&&H.themeMode==="light"?H:{...H,lightThemeId:V.metadata.id,themeMode:"light"})},[y]),w=ae.useCallback(k=>{s.themeMode!==k&&(o(V=>({...V,themeMode:k})),Nn({themeVariant:k==="system"?v.metadata.variant:k,useSystemTheme:k==="system"}))},[v.metadata.variant,s.themeMode]),_=ae.useCallback(k=>{if(k){o(H=>H.themeMode==="system"?H:{...H,themeMode:"system"});return}const V=v.metadata.variant==="dark"?"dark":"light";o(H=>H.themeMode===V?H:{...H,themeMode:V})},[v.metadata.variant]),L=ae.useCallback(k=>{const V=y.find(H=>H.metadata.id===k&&H.metadata.variant==="light");V&&o(H=>H.lightThemeId===V.metadata.id?H:{...H,lightThemeId:V.metadata.id})},[y]),A=ae.useCallback(k=>{const V=y.find(H=>H.metadata.id===k&&H.metadata.variant==="dark");V&&o(H=>H.darkThemeId===V.metadata.id?H:{...H,darkThemeId:V.metadata.id})},[y]),N={currentTheme:v,availableThemes:y,setTheme:C,customThemesLoading:h,reloadCustomThemes:x,isSystemPreference:s.themeMode==="system",setSystemPreference:_,themeMode:s.themeMode,setThemeMode:w,lightThemeId:s.lightThemeId,darkThemeId:s.darkThemeId,setLightThemePreference:L,setDarkThemePreference:A};return i.jsx(N3.Provider,{value:N,children:e})}const mn={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536},af={isMobile:!1,isTablet:!1,isDesktop:!0,deviceType:"desktop",screenWidth:1024,breakpoint:"lg",hasTouchInput:!1,hasTouchOnlyPointer:!1},wC=()=>typeof window>"u"?!1:new URLSearchParams(window.location.search).get("surface")==="desktop",MC=e=>{if(typeof navigator>"u")return{isExplicitTablet:!1};const t=navigator.userAgent||"",n=navigator.platform||"",s=/iPad/i.test(t)||(/Macintosh|MacIntel/i.test(t)||/MacIntel/i.test(n))&&e>1,o=/Android/i.test(t)&&!/Mobile/i.test(t),r=/Tablet/i.test(t);return{isExplicitTablet:s||o||r}},CC=(e,t,n)=>{if(typeof window>"u")return;const s=document.documentElement;s.classList.remove("device-mobile","device-tablet","device-desktop"),s.classList.add(t==="mobile"?"device-mobile":t==="tablet"?"device-tablet":"device-desktop"),e?(s.classList.add("desktop-runtime"),s.classList.remove("mobile-pointer")):(s.classList.remove("desktop-runtime"),n?s.classList.add("mobile-pointer"):s.classList.remove("mobile-pointer"))};function P3(){const e=window.innerWidth,t=typeof window.matchMedia=="function",n=t?window.matchMedia("(pointer: coarse)"):null,s=t?window.matchMedia("(hover: none)"):null,o=n?.matches??!1,r=s?.matches??!1,a=typeof navigator<"u"?navigator.maxTouchPoints??0:0,l=S1()||wC(),{isExplicitTablet:c}=MC(a),u=o||r||a>0,f=o||r,h=e>mn.md&&e<=mn.lg,m=e<=mn.md;let p=u&&m,g=u&&!p&&(h||c),y=!u||!g&&e>mn.lg,M="desktop";l?(p=!1,g=!1,y=!0,M="desktop"):D2()?(p=!0,g=!1,y=!1,M="mobile"):p?M="mobile":g?M="tablet":(y=!0,M="desktop"),CC(l,M,u);let b="xs";for(const[v,x]of Object.entries(mn))e>=x&&(b=v);return{isMobile:p,isTablet:g,isDesktop:y,deviceType:M,screenWidth:e,breakpoint:b,hasTouchInput:u,hasTouchOnlyPointer:f}}const SC=(e,t)=>e.isMobile===t.isMobile&&e.isTablet===t.isTablet&&e.isDesktop===t.isDesktop&&e.deviceType===t.deviceType&&e.screenWidth===t.screenWidth&&e.breakpoint===t.breakpoint&&e.hasTouchInput===t.hasTouchInput&&e.hasTouchOnlyPointer===t.hasTouchOnlyPointer,Pr=new Set;let Xt=null,jn,ds=null;const _C=()=>typeof window>"u"?af:(Xt||(Xt=P3()),Xt),kC=()=>{for(const e of Pr)e()},AC=()=>{jn=void 0;const e=P3();Xt&&SC(Xt,e)||(Xt=e,kC())},Wo=()=>{typeof window>"u"||jn!==void 0||(jn=window.requestAnimationFrame(AC))},di=(e,t)=>e?typeof e.addEventListener=="function"?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):typeof e.addListener=="function"?(e.addListener(t),()=>e.removeListener(t)):()=>{}:()=>{},HC=()=>{if(typeof window>"u")return()=>{};Xt=P3(),window.addEventListener("resize",Wo);const e=typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null,t=typeof window.matchMedia=="function"?window.matchMedia("(hover: none)"):null,n=di(e,Wo),s=di(t,Wo);return()=>{window.removeEventListener("resize",Wo),n(),s(),jn!==void 0&&(window.cancelAnimationFrame(jn),jn=void 0)}},LC=e=>typeof window>"u"?()=>{}:(Pr.add(e),ds||(ds=HC()),()=>{Pr.delete(e),Pr.size===0&&ds&&(ds(),ds=null,Xt=null)}),jC=()=>typeof window>"u"?!1:!!(navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)")?.matches||window.matchMedia?.("(display-mode: fullscreen)")?.matches),T6=()=>{if(typeof window>"u"||S1())return!1;const e=typeof navigator<"u"?navigator.maxTouchPoints??0:0;return jC()&&e>0&&window.innerWidth>mn.md};function KO(){const[e,t]=d.useState(()=>T6());return d.useEffect(()=>{if(typeof window>"u")return;const n=()=>t(T6()),s=window.matchMedia?.("(display-mode: standalone)"),o=window.matchMedia?.("(display-mode: fullscreen)");n(),window.addEventListener("resize",n),window.addEventListener("focus",n);const r=l=>{l&&(typeof l.addEventListener=="function"?l.addEventListener("change",n):typeof l.addListener=="function"&&l.addListener(n))},a=l=>{l&&(typeof l.removeEventListener=="function"?l.removeEventListener("change",n):typeof l.removeListener=="function"&&l.removeListener(n))};return r(s),r(o),()=>{window.removeEventListener("resize",n),window.removeEventListener("focus",n),a(s),a(o)}},[]),e}const IC=()=>typeof window>"u"?"portrait":window.matchMedia?.("(orientation: landscape)")?.matches?"landscape":"portrait";function YO(){const[e,t]=d.useState(IC);return d.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const n=window.matchMedia("(orientation: landscape)"),s=()=>t(n.matches?"landscape":"portrait");return s(),di(n,s)},[]),e}const BC=600,TC=1e3,E3=()=>{if(typeof window>"u")return{enabled:!1,roomyForPanels:!1};const e=window.innerWidth,t=window.innerHeight,n=Ig()||Math.min(e,t)>=BC;return{enabled:n,roomyForPanels:n&&e>t&&e>=TC}},VC=(e,t)=>e.enabled===t.enabled&&e.roomyForPanels===t.roomyForPanels,lf={enabled:!1,roomyForPanels:!1},Er=new Set;let Qt=null,In,us=null;const NC=()=>typeof window>"u"?lf:(Qt||(Qt=E3()),Qt),PC=()=>{for(const e of Er)e()},EC=()=>{In=void 0;const e=E3();Qt&&VC(Qt,e)||(Qt=e,PC())},Qa=()=>{typeof window>"u"||In!==void 0||(In=window.requestAnimationFrame(EC))},zC=()=>{if(typeof window>"u")return()=>{};Qt=E3(),window.addEventListener("resize",Qa);const e=typeof window.matchMedia=="function"?window.matchMedia("(orientation: landscape)"):null,t=di(e,Qa);return()=>{window.removeEventListener("resize",Qa),t(),In!==void 0&&(window.cancelAnimationFrame(In),In=void 0)}},DC=e=>typeof window>"u"?()=>{}:(Er.add(e),us||(us=zC()),()=>{Er.delete(e),Er.size===0&&us&&(us(),us=null,Qt=null)});function Kn(){return d.useSyncExternalStore(DC,NC,()=>lf)}function c0(){return d.useSyncExternalStore(LC,_C,()=>af)}let el=null;const z3=()=>(el??=V2(()=>import("./MarkdownRendererImpl-CpI-25Xk.js"),__vite__mapDeps([8,1,2,9,10,11,12,13,6,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,7,108,109])).catch(e=>{throw el=null,e}),el),JO=()=>{z3().catch(()=>{})},RC={threshold:.4,distance:100,ignoreLocation:!0,preferSubstring:!0};function OC(e,t,n){if(!t)return!0;if(!e)return!1;const s={...RC,...n};return s.preferSubstring&&e.toLowerCase().includes(t.toLowerCase())?!0:new N9([e],{threshold:s.threshold,distance:s.distance,ignoreLocation:s.ignoreLocation}).search(t).length>0}function XO(e,t,n,s){if(!t)return e.map(f=>({item:f,score:0}));const o=s?.limit??e.length,r=s?.threshold??.3,a=s?.noFuzzy??!1,l=t.toLowerCase(),c=[],u=[];for(const f of e){const h=n(f);if(!h)continue;const p=h.toLowerCase().indexOf(l);if(p===0){c.push({item:f,score:-1});continue}if(p>0){c.push({item:f,score:p/1e3});continue}a||u.push({item:f,text:h})}if(u.length>0){const f=new N9(u.map(h=>h.text),{threshold:r,ignoreLocation:!0,distance:100,includeScore:!0,minMatchCharLength:2});for(const h of f.search(t))c.push({item:u[h.refIndex].item,score:h.score??1})}return c.sort((f,h)=>f.score-h.score),c.slice(0,o)}function B(...e){return vv(yv(e))}const it=()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),ZC=()=>typeof navigator>"u"?!1:/Windows/.test(navigator.userAgent||""),QO=()=>it()?"Reveal in Finder":ZC()?"Open in File Explorer":"Open in File Manager",eZ=e=>it()&&S1()?e.metaKey:e.ctrlKey,tZ=()=>it()&&S1()?"⌘":"Ctrl",tl=(e,t)=>{const n=e??"",s=Math.max(16,t?.maxLength??45);if(n.length<=s)return n;const o=n.split("/");if(o.length<=1)return n;const r=o.pop()??"";if(!r)return n;const a=Math.max(0,s-(r.length+2));if(a<=0)return`…/${r}`;let l="";for(const c of o){if(!c)continue;const u=l?`${l}/${c}`:c;if(u.length>a)break;l=u}if(!l){const c=o[0]??"";l=c?c.slice(0,a):""}return l?`${l}…/${r}`:`…/${r}`},ui=e=>e?e==="/"?"/":e.replace(/\/+$/,""):"";function nZ(e,t){if(!e)return"";const n=ui(e);if(n==="/")return"/";const s=t?ui(t):void 0;if(s&&s!=="/"){if(n===s)return"~";if(n.startsWith(`${s}/`)){const o=n.slice(s.length+1);return o?`~/${o}`:"~"}}return n}function fi(e,t){if(!e)return"/";const n=ui(e);if(!n||n==="/")return"/";const s=t?ui(t):void 0;return s&&s!=="/"&&n===s?"~":n.split("/").pop()||n||"/"}function e0(e,t){return OC(e,t)}function FC(...e){return t=>{for(const n of e)n&&(typeof n=="function"?n(t):n.current=t)}}function $C(e,t){const n={...t};for(const s in e){const o=t[s],r=e[s];/^on[A-Z]/.test(s)&&typeof o=="function"&&typeof r=="function"?n[s]=(...a)=>{r(...a),o(...a)}:s==="className"&&typeof o=="string"&&typeof r=="string"?n[s]=`${r} ${o}`:s==="style"&&typeof o=="object"&&typeof r=="object"?n[s]={...r,...o}:n[s]=r}return n}const qC=ae.forwardRef(function({children:t,...n},s){if(!ae.isValidElement(t))return null;const o=t;return ae.cloneElement(o,{...$C(o.props,n),ref:FC(s,o.ref)})}),UC=["bg-[color-mix(in_srgb,var(--primary-base)_10%,var(--background))]","text-[var(--primary-base)]","border border-[color-mix(in_srgb,var(--primary-base)_12%,transparent)]","hover:bg-[color-mix(in_srgb,var(--primary-base)_16%,var(--background))]","active:bg-[color-mix(in_srgb,var(--primary-base)_22%,var(--background))]","dark:bg-[color-mix(in_srgb,var(--primary-base)_16%,transparent)]","dark:border-[color-mix(in_srgb,var(--primary-base)_20%,transparent)]","dark:hover:bg-[color-mix(in_srgb,var(--primary-base)_22%,transparent)]","dark:active:bg-[color-mix(in_srgb,var(--primary-base)_30%,transparent)]"].join(" "),GC=["bg-[color-mix(in_srgb,var(--status-error)_7%,var(--background))]","text-[var(--status-error)]","border border-[color-mix(in_srgb,var(--status-error)_9%,transparent)]","hover:bg-[color-mix(in_srgb,var(--status-error)_11%,var(--background))]","active:bg-[color-mix(in_srgb,var(--status-error)_16%,var(--background))]","dark:bg-[color-mix(in_srgb,var(--status-error)_9%,transparent)]","dark:border-[color-mix(in_srgb,var(--status-error)_14%,transparent)]","dark:hover:bg-[color-mix(in_srgb,var(--status-error)_14%,transparent)]","dark:active:bg-[color-mix(in_srgb,var(--status-error)_20%,transparent)]"].join(" "),WC=["bg-[color-mix(in_srgb,var(--status-info)_4%,var(--background))]","text-[var(--status-info)]","border border-[color-mix(in_srgb,var(--status-info)_8%,transparent)]","hover:bg-[color-mix(in_srgb,var(--status-info)_7%,var(--background))]","active:bg-[color-mix(in_srgb,var(--status-info)_10%,var(--background))]","dark:bg-[color-mix(in_srgb,var(--status-info)_7%,transparent)]","dark:border-[color-mix(in_srgb,var(--status-info)_12%,transparent)]","dark:hover:bg-[color-mix(in_srgb,var(--status-info)_10%,transparent)]","dark:active:bg-[color-mix(in_srgb,var(--status-info)_14%,transparent)]"].join(" "),KC=T9(["group relative inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] typography-ui-label font-medium lowercase tracking-[0.01em] shrink-0 select-none","transition-[background-color,border-color,color,opacity] duration-150 ease-out outline-none","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive","disabled:pointer-events-none disabled:opacity-50","[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"],{variants:{variant:{default:UC,destructive:B(GC,"focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40"),info:WC,neutral:"bg-interactive-hover text-foreground border border-border/60 hover:bg-interactive-active",outline:"bg-[var(--surface-elevated)] text-foreground border border-border/60 hover:bg-interactive-hover hover:text-foreground",chip:B("border border-border/60 bg-transparent text-foreground hover:bg-interactive-hover hover:text-foreground","aria-pressed:bg-[color-mix(in_srgb,var(--primary-base)_10%,var(--background))]","aria-pressed:text-[var(--primary-base)]","aria-pressed:border-[color-mix(in_srgb,var(--primary-base)_12%,transparent)]","aria-pressed:hover:bg-[color-mix(in_srgb,var(--primary-base)_16%,var(--background))]","aria-pressed:hover:text-[var(--primary-base)]","dark:aria-pressed:bg-[color-mix(in_srgb,var(--primary-base)_16%,transparent)]","dark:aria-pressed:border-[color-mix(in_srgb,var(--primary-base)_20%,transparent)]","dark:aria-pressed:hover:bg-[color-mix(in_srgb,var(--primary-base)_22%,transparent)]"),secondary:"bg-interactive-hover text-foreground hover:bg-interactive-active",ghost:"text-foreground hover:bg-interactive-hover hover:text-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-3.5 has-[>svg]:px-3",sm:"h-8 gap-1.5 px-2.5 has-[>svg]:px-2 rounded-[9px] supports-[corner-shape:squircle]:rounded-[50px]",xs:"h-6 gap-1 px-2 typography-micro has-[>svg]:px-1.5 rounded-[7px] supports-[corner-shape:squircle]:rounded-[50px]",lg:"h-10 px-4 has-[>svg]:px-3.5 rounded-[12px] supports-[corner-shape:squircle]:rounded-[50px]",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function a1({className:e,variant:t,size:n,asChild:s=!1,type:o,...r}){const a=s?qC:"button",l=s?o===void 0?{}:{type:o}:{type:o??"button"};return i.jsx(a,{"data-slot":"button",className:B(KC({variant:t,size:n,className:e})),...l,...r})}const YC={add:'<path d="M11 11V5H13V11H19V13H13V19H11V13H5V11H11Z" fill="currentColor"/>',"add-circle":'<path d="M11 11V7H13V11H17V13H13V17H11V13H7V11H11ZM12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20Z" fill="currentColor"/>',"ai-agent":'<path d="M12 2C17.5228 2 22 6.47715 22 12C22 14.7096 20.9205 17.1697 19.1709 18.9697C17.3551 20.8376 14.8124 22 12 22C9.18756 22 6.64488 20.8376 4.8291 18.9697C3.07949 17.1697 2 14.7096 2 12C2 6.47715 6.47715 2 12 2ZM12 16C10.0022 16 8.20124 16.8375 6.9248 18.1816C8.30642 19.3175 10.0724 20 12 20C13.9274 20 15.6927 19.3173 17.0742 18.1816C15.7978 16.8377 13.9975 16 12 16ZM12 4C7.58172 4 4 7.58172 4 12C4 13.7701 4.57462 15.4044 5.54785 16.7295C7.1822 15.0483 9.46797 14 12 14C14.5318 14 16.8169 15.0485 18.4512 16.7295C19.4246 15.4043 20 13.7703 20 12C20 7.58172 16.4183 4 12 4ZM11.5293 5.31934C11.7058 4.89329 12.2943 4.89329 12.4707 5.31934L12.7236 5.93066C13.1556 6.97343 13.9615 7.80622 14.9746 8.25684L15.6924 8.5752C16.1029 8.75796 16.1028 9.35627 15.6924 9.53906L14.9326 9.87695C13.9448 10.3163 13.1534 11.1193 12.7139 12.1279L12.4668 12.6934C12.2864 13.1074 11.7137 13.1074 11.5332 12.6934L11.2871 12.1279C10.8476 11.1193 10.0552 10.3163 9.06738 9.87695L8.30762 9.53906C7.89719 9.35628 7.89717 8.75795 8.30762 8.5752L9.02539 8.25684C10.0385 7.80623 10.8445 6.97345 11.2764 5.93066L11.5293 5.31934Z" fill="currentColor"/>',"ai-agent-fill":'<path d="M12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2ZM12 15C9.71266 15 7.65042 15.961 6.19238 17.5C7.65042 19.039 9.71266 20 12 20C14.2871 20 16.3486 19.0387 17.8066 17.5C16.3486 15.9613 14.2871 15 12 15ZM12.4707 5.31934C12.2943 4.89337 11.7058 4.89339 11.5293 5.31934L11.2764 5.93066C10.8445 6.97341 10.0384 7.80621 9.02539 8.25684L8.30762 8.57617C7.89751 8.75905 7.89744 9.35625 8.30762 9.53906L9.06738 9.87695C10.0551 10.3163 10.8476 11.1193 11.2871 12.1279L11.5332 12.6934C11.7138 13.1073 12.2863 13.1073 12.4668 12.6934L12.7139 12.1279C13.1534 11.1194 13.9449 10.3163 14.9326 9.87695L15.6924 9.53906C16.1026 9.35624 16.1025 8.75907 15.6924 8.57617L14.9746 8.25684C13.9616 7.8062 13.1556 6.9734 12.7236 5.93066L12.4707 5.31934Z" fill="currentColor"/>',"ai-generate-2":'<path d="M20.4668 8.69379L20.7134 8.12811C21.1529 7.11947 21.9445 6.31641 22.9323 5.87708L23.6919 5.53922C24.1027 5.35653 24.1027 4.75881 23.6919 4.57612L22.9748 4.25714C21.9616 3.80651 21.1558 2.97373 20.7238 1.93083L20.4706 1.31953C20.2942 0.893489 19.7058 0.893489 19.5293 1.31953L19.2761 1.93083C18.8442 2.97373 18.0384 3.80651 17.0252 4.25714L16.308 4.57612C15.8973 4.75881 15.8973 5.35653 16.308 5.53922L17.0677 5.87708C18.0555 6.31641 18.8471 7.11947 19.2866 8.12811L19.5331 8.69379C19.7136 9.10792 20.2864 9.10792 20.4668 8.69379ZM5.79993 16H7.95399L8.55399 14.5H11.4459L12.0459 16H14.1999L10.9999 8H8.99993L5.79993 16ZM9.99993 10.8852L10.6459 12.5H9.35399L9.99993 10.8852ZM15 16V8H17V16H15ZM3 3C2.44772 3 2 3.44772 2 4V20C2 20.5523 2.44772 21 3 21H21C21.5523 21 22 20.5523 22 20V11H20V19H4V5H14V3H3Z" fill="currentColor"/>',alert:'<path d="M12.8659 3.00017L22.3922 19.5002C22.6684 19.9785 22.5045 20.5901 22.0262 20.8662C21.8742 20.954 21.7017 21.0002 21.5262 21.0002H2.47363C1.92135 21.0002 1.47363 20.5525 1.47363 20.0002C1.47363 19.8246 1.51984 19.6522 1.60761 19.5002L11.1339 3.00017C11.41 2.52187 12.0216 2.358 12.4999 2.63414C12.6519 2.72191 12.7782 2.84815 12.8659 3.00017ZM4.20568 19.0002H19.7941L11.9999 5.50017L4.20568 19.0002ZM10.9999 16.0002H12.9999V18.0002H10.9999V16.0002ZM10.9999 9.00017H12.9999V14.0002H10.9999V9.00017Z" fill="currentColor"/>',"align-justify":'<path d="M3 4H21V6H3V4ZM3 19H21V21H3V19ZM3 14H21V16H3V14ZM3 9H21V11H3V9Z" fill="currentColor"/>',apple:'<path d="M15.778 8.20793C15.3053 8.1711 14.7974 8.28434 14.0197 8.58067C14.085 8.55577 13.2775 8.87173 13.0511 8.95077C12.5494 9.12593 12.1364 9.22198 11.6734 9.22198C11.2151 9.22198 10.7925 9.13042 10.3078 8.96683C10.1524 8.91441 9.99616 8.8564 9.80283 8.7809C9.71993 8.74852 9.41997 8.62947 9.3544 8.60379C8.70626 8.34996 8.34154 8.25434 8.03885 8.26181C6.88626 8.2765 5.79557 8.9421 5.16246 10.0442C3.87037 12.2875 4.58583 16.3428 6.47459 19.075C7.4802 20.5189 8.03062 21.035 8.25199 21.0279C8.4743 21.0183 8.63777 20.9713 9.03567 20.8026C9.11485 20.7689 9.11485 20.7689 9.202 20.7317C10.2077 20.3032 10.9118 20.114 11.9734 20.114C12.9944 20.114 13.6763 20.2997 14.6416 20.7159C14.7302 20.7542 14.7302 20.7542 14.8097 20.7884C15.2074 20.9588 15.3509 20.9962 15.6016 20.9902C15.9591 20.9846 16.4003 20.5726 17.3791 19.1362C17.6471 18.7447 17.884 18.3333 18.0895 17.9168C17.9573 17.8077 17.826 17.6917 17.6975 17.5693C16.4086 16.3408 15.6114 14.6845 15.5895 12.6391C15.5756 11.0186 16.1057 9.61487 16.999 8.45797C16.6293 8.3142 16.2216 8.23805 15.778 8.20793ZM15.9334 6.21398C16.6414 6.26198 18.6694 6.47798 19.9894 8.40998C19.8814 8.46998 17.5654 9.81397 17.5894 12.622C17.6254 15.982 20.5294 17.098 20.5654 17.11C20.5414 17.194 20.0974 18.706 19.0294 20.266C18.1054 21.622 17.1454 22.966 15.6334 22.99C14.1454 23.026 13.6654 22.114 11.9734 22.114C10.2694 22.114 9.74138 22.966 8.33738 23.026C6.87338 23.074 5.76938 21.562 4.83338 20.218C2.92538 17.458 1.47338 12.442 3.42938 9.04597C4.40138 7.35397 6.12938 6.28598 8.01338 6.26198C9.44138 6.22598 10.7974 7.22198 11.6734 7.22198C12.5374 7.22198 14.0854 6.06998 15.9334 6.21398ZM14.7934 4.38998C14.0134 5.32598 12.7414 6.05798 11.5054 5.96198C11.3374 4.68998 11.9614 3.35798 12.6814 2.52998C13.4854 1.59398 14.8294 0.897976 15.9454 0.849976C16.0894 2.14598 15.5734 3.45398 14.7934 4.38998Z" fill="currentColor"/>',archive:'<path d="M3 10H2V4.00293C2 3.44903 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.43788 22 4.00293V10H21V20.0015C21 20.553 20.5551 21 20.0066 21H3.9934C3.44476 21 3 20.5525 3 20.0015V10ZM19 10H5V19H19V10ZM4 5V8H20V5H4ZM9 12H15V14H9V12Z" fill="currentColor"/>',"archive-stack":'<path d="M4 5H20V3H4V5ZM20 9H4V7H20V9ZM3 11H10V13H14V11H21V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V11ZM16 13V15H8V13H5V19H19V13H16Z" fill="currentColor"/>',"arrow-down":'<path d="M13.0001 16.1716L18.3641 10.8076L19.7783 12.2218L12.0001 20L4.22192 12.2218L5.63614 10.8076L11.0001 16.1716V4H13.0001V16.1716Z" fill="currentColor"/>',"arrow-down-s":'<path d="M11.9999 13.1714L16.9497 8.22168L18.3639 9.63589L11.9999 15.9999L5.63599 9.63589L7.0502 8.22168L11.9999 13.1714Z" fill="currentColor"/>',"arrow-go-back":'<path d="M5.82843 6.99955L8.36396 9.53509L6.94975 10.9493L2 5.99955L6.94975 1.0498L8.36396 2.46402L5.82843 4.99955H13C17.4183 4.99955 21 8.58127 21 12.9996C21 17.4178 17.4183 20.9996 13 20.9996H4V18.9996H13C16.3137 18.9996 19 16.3133 19 12.9996C19 9.68584 16.3137 6.99955 13 6.99955H5.82843Z" fill="currentColor"/>',"arrow-go-forward":'<path d="M18.1716 6.99955H11C7.68629 6.99955 5 9.68584 5 12.9996C5 16.3133 7.68629 18.9996 11 18.9996H20V20.9996H11C6.58172 20.9996 3 17.4178 3 12.9996C3 8.58127 6.58172 4.99955 11 4.99955H18.1716L15.636 2.46402L17.0503 1.0498L22 5.99955L17.0503 10.9493L15.636 9.53509L18.1716 6.99955Z" fill="currentColor"/>',"arrow-left":'<path d="M7.82843 10.9999H20V12.9999H7.82843L13.1924 18.3638L11.7782 19.778L4 11.9999L11.7782 4.22168L13.1924 5.63589L7.82843 10.9999Z" fill="currentColor"/>',"arrow-left-right":'<path d="M16.0503 12.0498L21 16.9996L16.0503 21.9493L14.636 20.5351L17.172 17.9988L4 17.9996V15.9996L17.172 15.9988L14.636 13.464L16.0503 12.0498ZM7.94975 2.0498L9.36396 3.46402L6.828 5.9988L20 5.99955V7.99955L6.828 7.9988L9.36396 10.5351L7.94975 11.9493L3 6.99955L7.94975 2.0498Z" fill="currentColor"/>',"arrow-left-s":'<path d="M10.8284 12.0007L15.7782 16.9504L14.364 18.3646L8 12.0007L14.364 5.63672L15.7782 7.05093L10.8284 12.0007Z" fill="currentColor"/>',"arrow-right":'<path d="M16.1716 10.9999L10.8076 5.63589L12.2218 4.22168L20 11.9999L12.2218 19.778L10.8076 18.3638L16.1716 12.9999H4V10.9999H16.1716Z" fill="currentColor"/>',"arrow-right-s":'<path d="M13.1717 12.0007L8.22192 7.05093L9.63614 5.63672L16.0001 12.0007L9.63614 18.3646L8.22192 16.9504L13.1717 12.0007Z" fill="currentColor"/>',"arrow-up":'<path d="M13.0001 7.82843V20H11.0001V7.82843L5.63614 13.1924L4.22192 11.7782L12.0001 4L19.7783 11.7782L18.3641 13.1924L13.0001 7.82843Z" fill="currentColor"/>',"arrow-up-double":'<path d="M12 4.83582L5.79291 11.0429L7.20712 12.4571L12 7.66424L16.7929 12.4571L18.2071 11.0429L12 4.83582ZM12 10.4857L5.79291 16.6928L7.20712 18.107L12 13.3141L16.7929 18.107L18.2071 16.6928L12 10.4857Z" fill="currentColor"/>',"arrow-up-s":'<path d="M11.9999 10.8284L7.0502 15.7782L5.63599 14.364L11.9999 8L18.3639 14.364L16.9497 15.7782L11.9999 10.8284Z" fill="currentColor"/>',"attachment-2":'<path d="M14.8287 7.75737L9.1718 13.4142C8.78127 13.8047 8.78127 14.4379 9.1718 14.8284C9.56232 15.219 10.1955 15.219 10.586 14.8284L16.2429 9.17158C17.4144 8.00001 17.4144 6.10052 16.2429 4.92894C15.0713 3.75737 13.1718 3.75737 12.0002 4.92894L6.34337 10.5858C4.39075 12.5384 4.39075 15.7042 6.34337 17.6569C8.29599 19.6095 11.4618 19.6095 13.4144 17.6569L19.0713 12L20.4855 13.4142L14.8287 19.0711C12.095 21.8047 7.66283 21.8047 4.92916 19.0711C2.19549 16.3374 2.19549 11.9053 4.92916 9.17158L10.586 3.51473C12.5386 1.56211 15.7045 1.56211 17.6571 3.51473C19.6097 5.46735 19.6097 8.63317 17.6571 10.5858L12.0002 16.2427C10.8287 17.4142 8.92916 17.4142 7.75759 16.2427C6.58601 15.0711 6.58601 13.1716 7.75759 12L13.4144 6.34316L14.8287 7.75737Z" fill="currentColor"/>',"bar-chart-2":'<path d="M2 13H8V21H2V13ZM16 8H22V21H16V8ZM9 3H15V21H9V3ZM4 15V19H6V15H4ZM11 5V19H13V5H11ZM18 10V19H20V10H18Z" fill="currentColor"/>',"bar-chart-box":'<path d="M3 3H21C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3ZM4 5V19H20V5H4ZM7 13H9V17H7V13ZM11 7H13V17H11V7ZM15 10H17V17H15V10Z" fill="currentColor"/>',book:'<path d="M3 18.5V5C3 3.34315 4.34315 2 6 2H20C20.5523 2 21 2.44772 21 3V21C21 21.5523 20.5523 22 20 22H6.5C4.567 22 3 20.433 3 18.5ZM19 20V17H6.5C5.67157 17 5 17.6716 5 18.5C5 19.3284 5.67157 20 6.5 20H19ZM5 15.3368C5.45463 15.1208 5.9632 15 6.5 15H19V4H6C5.44772 4 5 4.44772 5 5V15.3368Z" fill="currentColor"/>',"book-open":'<path d="M13 21V23H11V21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H9C10.1947 3 11.2671 3.52375 12 4.35418C12.7329 3.52375 13.8053 3 15 3H21C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H13ZM20 19V5H15C13.8954 5 13 5.89543 13 7V19H20ZM11 19V7C11 5.89543 10.1046 5 9 5H4V19H11Z" fill="currentColor"/>',booklet:'<path d="M20.0049 2C21.1068 2 22 2.89821 22 3.9908V20.0092C22 21.1087 21.1074 22 20.0049 22H4V18H2V16H4V13H2V11H4V8H2V6H4V2H20.0049ZM8 4H6V20H8V4ZM20 4H10V20H20V4Z" fill="currentColor"/>',braces:'<path d="M4 18V14.3C4 13.4716 3.32843 12.8 2.5 12.8H2V11.2H2.5C3.32843 11.2 4 10.5284 4 9.7V6C4 4.34315 5.34315 3 7 3H8V5H7C6.44772 5 6 5.44772 6 6V10.1C6 10.9858 5.42408 11.7372 4.62623 12C5.42408 12.2628 6 13.0142 6 13.9V18C6 18.5523 6.44772 19 7 19H8V21H7C5.34315 21 4 19.6569 4 18ZM20 14.3V18C20 19.6569 18.6569 21 17 21H16V19H17C17.5523 19 18 18.5523 18 18V13.9C18 13.0142 18.5759 12.2628 19.3738 12C18.5759 11.7372 18 10.9858 18 10.1V6C18 5.44772 17.5523 5 17 5H16V3H17C18.6569 3 20 4.34315 20 6V9.7C20 10.5284 20.6716 11.2 21.5 11.2H22V12.8H21.5C20.6716 12.8 20 13.4716 20 14.3Z" fill="currentColor"/>',brain:'<path d="M9 4C10.1046 4 11 4.89543 11 6V12.8271C10.1058 12.1373 8.96602 11.7305 7.6644 11.5136L7.3356 13.4864C8.71622 13.7165 9.59743 14.1528 10.1402 14.7408C10.67 15.3147 11 16.167 11 17.5C11 18.8807 9.88071 20 8.5 20C7.11929 20 6 18.8807 6 17.5V17.1493C6.43007 17.2926 6.87634 17.4099 7.3356 17.4864L7.6644 15.5136C6.92149 15.3898 6.1752 15.1144 5.42909 14.7599C4.58157 14.3573 4 13.499 4 12.5C4 11.6653 4.20761 11.0085 4.55874 10.5257C4.90441 10.0504 5.4419 9.6703 6.24254 9.47014L7 9.28078V6C7 4.89543 7.89543 4 9 4ZM12 3.35418C11.2671 2.52376 10.1947 2 9 2C6.79086 2 5 3.79086 5 6V7.77422C4.14895 8.11644 3.45143 8.64785 2.94126 9.34933C2.29239 10.2415 2 11.3347 2 12.5C2 14.0652 2.79565 15.4367 4 16.2422V17.5C4 19.9853 6.01472 22 8.5 22C9.91363 22 11.175 21.3482 12 20.3287C12.825 21.3482 14.0864 22 15.5 22C17.9853 22 20 19.9853 20 17.5V16.2422C21.2044 15.4367 22 14.0652 22 12.5C22 11.3347 21.7076 10.2415 21.0587 9.34933C20.5486 8.64785 19.8511 8.11644 19 7.77422V6C19 3.79086 17.2091 2 15 2C13.8053 2 12.7329 2.52376 12 3.35418ZM18 17.1493V17.5C18 18.8807 16.8807 20 15.5 20C14.1193 20 13 18.8807 13 17.5C13 16.167 13.33 15.3147 13.8598 14.7408C14.4026 14.1528 15.2838 13.7165 16.6644 13.4864L16.3356 11.5136C15.034 11.7305 13.8942 12.1373 13 12.8271V6C13 4.89543 13.8954 4 15 4C16.1046 4 17 4.89543 17 6V9.28078L17.7575 9.47014C18.5581 9.6703 19.0956 10.0504 19.4413 10.5257C19.7924 11.0085 20 11.6653 20 12.5C20 13.499 19.4184 14.3573 18.5709 14.7599C17.8248 15.1144 17.0785 15.3898 16.3356 15.5136L16.6644 17.4864C17.1237 17.4099 17.5699 17.2926 18 17.1493Z" fill="currentColor"/>',"brain-ai-3":'<path d="M19.5 4.7832V7.6709L22 9.11426V14.8867L19.499 16.3311L19.5 19.2178L14.5 22.1045L12 20.6611L9.5 22.1045L4.5 19.2178V16.3311L2 14.8877L2.00098 9.11328L4.5 7.66992V4.78418L9.5 1.89746L11.999 3.34082L14.501 1.89648L19.5 4.7832ZM13 5.07227V7H11V5.07324L9.5 4.20703L6.49902 5.93848V8.8252L4 10.2676V13.7334L6.5 15.1768V18.0635L9.5 19.7959L11 18.9287V17H13V18.9297L14.5 19.7959L17.5 18.0625V15.1768L20 13.7324V10.2695L17.499 8.8252L17.5 5.9375L14.501 4.20605L13 5.07227ZM14.2646 13.1602C14.3529 12.9473 14.6472 12.9473 14.7354 13.1602L14.8623 13.4648C15.0783 13.986 15.4807 14.4027 15.9873 14.6279L16.3457 14.7871C16.5511 14.8784 16.5511 15.1773 16.3457 15.2686L15.9658 15.4375C15.4721 15.6571 15.0761 16.0586 14.8564 16.5625L14.7334 16.8447C14.6432 17.0517 14.3569 17.0517 14.2666 16.8447L14.1436 16.5625C13.9239 16.0586 13.5279 15.6571 13.0342 15.4375L12.6543 15.2686C12.4489 15.1773 12.4489 14.8784 12.6543 14.7871L13.0127 14.6279C13.5193 14.4027 13.9217 13.986 14.1377 13.4648L14.2646 13.1602ZM9.58789 7.7793C9.74239 7.40671 10.2577 7.4067 10.4121 7.7793L10.6338 8.31445C11.0118 9.22695 11.7161 9.95624 12.6025 10.3506L13.2305 10.6289C13.5899 10.7887 13.5897 11.3117 13.2305 11.4717L12.5654 11.7676C11.7013 12.152 11.0086 12.8548 10.624 13.7373L10.4082 14.2324C10.2504 14.5948 9.74973 14.5948 9.5918 14.2324L9.37598 13.7373C8.99143 12.8548 8.29875 12.152 7.43457 11.7676L6.76953 11.4717C6.41033 11.3117 6.41022 10.7887 6.76953 10.6289L7.39746 10.3506C8.2839 9.95624 8.98832 9.22697 9.36621 8.31445L9.58789 7.7793Z" fill="currentColor"/>',briefcase:'<path d="M7 5V2C7 1.44772 7.44772 1 8 1H16C16.5523 1 17 1.44772 17 2V5H21C21.5523 5 22 5.44772 22 6V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V6C2 5.44772 2.44772 5 3 5H7ZM4 16V19H20V16H4ZM4 14H20V7H4V14ZM9 3V5H15V3H9ZM11 11H13V13H11V11Z" fill="currentColor"/>',bug:'<path d="M13 19.9C15.2822 19.4367 17 17.419 17 15V12C17 11.299 16.8564 10.6219 16.5846 10H7.41538C7.14358 10.6219 7 11.299 7 12V15C7 17.419 8.71776 19.4367 11 19.9V14H13V19.9ZM5.5358 17.6907C5.19061 16.8623 5 15.9534 5 15H2V13H5V12C5 11.3573 5.08661 10.7348 5.2488 10.1436L3.0359 8.86602L4.0359 7.13397L6.05636 8.30049C6.11995 8.19854 6.18609 8.09835 6.25469 8H17.7453C17.8139 8.09835 17.88 8.19854 17.9436 8.30049L19.9641 7.13397L20.9641 8.86602L18.7512 10.1436C18.9134 10.7348 19 11.3573 19 12V13H22V15H19C19 15.9534 18.8094 16.8623 18.4642 17.6907L20.9641 19.134L19.9641 20.866L17.4383 19.4077C16.1549 20.9893 14.1955 22 12 22C9.80453 22 7.84512 20.9893 6.56171 19.4077L4.0359 20.866L3.0359 19.134L5.5358 17.6907ZM8 6C8 3.79086 9.79086 2 12 2C14.2091 2 16 3.79086 16 6H8Z" fill="currentColor"/>',calendar:'<path d="M9 1V3H15V1H17V3H21C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H7V1H9ZM20 11H4V19H20V11ZM7 5H4V9H20V5H17V7H15V5H9V7H7V5Z" fill="currentColor"/>',"calendar-schedule":'<path d="M7 3V1H9V3H15V1H17V3H21C21.5523 3 22 3.44772 22 4V9H20V5H17V7H15V5H9V7H7V5H4V19H10V21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H7ZM17 12C14.7909 12 13 13.7909 13 16C13 18.2091 14.7909 20 17 20C19.2091 20 21 18.2091 21 16C21 13.7909 19.2091 12 17 12ZM11 16C11 12.6863 13.6863 10 17 10C20.3137 10 23 12.6863 23 16C23 19.3137 20.3137 22 17 22C13.6863 22 11 19.3137 11 16ZM16 13V16.4142L18.2929 18.7071L19.7071 17.2929L18 15.5858V13H16Z" fill="currentColor"/>',camera:'<path d="M9.82843 5L7.82843 7H4V19H20V7H16.1716L14.1716 5H9.82843ZM9 3H15L17 5H21C21.5523 5 22 5.44772 22 6V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V6C2 5.44772 2.44772 5 3 5H7L9 3ZM12 18C8.96243 18 6.5 15.5376 6.5 12.5C6.5 9.46243 8.96243 7 12 7C15.0376 7 17.5 9.46243 17.5 12.5C17.5 15.5376 15.0376 18 12 18ZM12 16C13.933 16 15.5 14.433 15.5 12.5C15.5 10.567 13.933 9 12 9C10.067 9 8.5 10.567 8.5 12.5C8.5 14.433 10.067 16 12 16Z" fill="currentColor"/>',"chat-1":'<path d="M10 3H14C18.4183 3 22 6.58172 22 11C22 15.4183 18.4183 19 14 19V22.5C9 20.5 2 17.5 2 11C2 6.58172 5.58172 3 10 3ZM12 17H14C17.3137 17 20 14.3137 20 11C20 7.68629 17.3137 5 14 5H10C6.68629 5 4 7.68629 4 11C4 14.61 6.46208 16.9656 12 19.4798V17Z" fill="currentColor"/>',"chat-3":'<path d="M7.29117 20.8242L2 22L3.17581 16.7088C2.42544 15.3056 2 13.7025 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C10.2975 22 8.6944 21.5746 7.29117 20.8242ZM7.58075 18.711L8.23428 19.0605C9.38248 19.6745 10.6655 20 12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 13.3345 4.32549 14.6175 4.93949 15.7657L5.28896 16.4192L4.63416 19.3658L7.58075 18.711Z" fill="currentColor"/>',"chat-4":'<path d="M5.76282 17H20V5H4V18.3851L5.76282 17ZM6.45455 19L2 22.5V4C2 3.44772 2.44772 3 3 3H21C21.5523 3 22 3.44772 22 4V18C22 18.5523 21.5523 19 21 19H6.45455Z" fill="currentColor"/>',"chat-ai-3":'<path d="M12 1.99996C12.8632 1.99996 13.701 2.10973 14.5 2.31539L14 4.25192C13.3608 4.0874 12.6906 3.99997 12 3.99997C7.58174 3.99997 4.00002 7.58172 4 12C4 13.3344 4.3255 14.6174 4.93945 15.7656L5.28906 16.4189L4.63379 19.3662L7.58105 18.7109L8.23438 19.0605C9.38255 19.6745 10.6656 20 12 20C16.4183 20 20 16.4183 20 12C20 11.6771 19.9805 11.3587 19.9434 11.0459L21.9297 10.8095C21.976 11.1999 22 11.5972 22 12C22 17.5228 17.5228 22 12 22C10.2975 22 8.69425 21.5746 7.29102 20.8242L2 22L3.17578 16.709C2.42541 15.3057 2 13.7025 2 12C2.00002 6.47714 6.47717 1.99996 12 1.99996ZM19.5293 1.3193C19.7058 0.893513 20.2942 0.8935 20.4707 1.3193L20.7236 1.93063C21.1555 2.97343 21.9615 3.80614 22.9746 4.2568L23.6914 4.57614C24.1022 4.75882 24.1022 5.35635 23.6914 5.53903L22.9326 5.87692C21.945 6.3162 21.1534 7.11943 20.7139 8.1279L20.4668 8.69333C20.2863 9.10747 19.7136 9.10747 19.5332 8.69333L19.2861 8.1279C18.8466 7.11942 18.0551 6.3162 17.0674 5.87692L16.3076 5.53903C15.8974 5.35618 15.8974 4.75895 16.3076 4.57614L17.0254 4.2568C18.0384 3.80614 18.8445 2.97343 19.2764 1.93063L19.5293 1.3193Z" fill="currentColor"/>',"chat-history":'<path d="M12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C10.298 22 8.69525 21.5748 7.29229 20.8248L2 22L3.17629 16.7097C2.42562 15.3063 2 13.7028 2 12C2 6.47715 6.47715 2 12 2ZM12 4C7.58172 4 4 7.58172 4 12C4 13.3347 4.32563 14.6181 4.93987 15.7664L5.28952 16.4201L4.63445 19.3663L7.58189 18.7118L8.23518 19.061C9.38315 19.6747 10.6659 20 12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4ZM13 7V12H17V14H11V7H13Z" fill="currentColor"/>',"chat-new":'<path d="M14 3V5H4V18.3851L5.76282 17H20V10H22V18C22 18.5523 21.5523 19 21 19H6.45455L2 22.5V4C2 3.44772 2.44772 3 3 3H14ZM19 3V0H21V3H24V5H21V8H19V5H16V3H19Z" fill="currentColor"/>',"chat-thread":'<path d="M2 22L7.29117 20.8242C8.6944 21.5746 10.2975 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 13.7025 2.42544 15.3056 3.17581 16.7088L2 22ZM8.23428 19.0605L7.58075 18.711L4.63416 19.3658L5.28896 16.4192L4.93949 15.7657C4.32549 14.6175 4 13.3345 4 12C4 7.58172 7.58172 4 12 4C16.4183 4 20 7.58172 20 12C20 16.4183 16.4183 20 12 20C10.6655 20 9.38248 19.6745 8.23428 19.0605ZM15.4487 7H13.4411L13.2661 9.00024H11.2584L11.4334 7H9.42577L9.25077 9.00024H7V11.0002H9.0758L8.90082 13.0002H7V15.0002H8.72584L8.55089 17H10.5585L10.7335 15.0002H12.7411L12.5662 17H14.5738L14.7488 15.0002H17V13.0002H14.9237L15.0987 11.0002H17V9.00024H15.2737L15.4487 7ZM11.0834 11.0002H13.0911L12.9161 13.0002H10.9085L11.0834 11.0002Z" fill="currentColor"/>',check:'<path d="M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z" fill="currentColor"/>',checkbox:'<path d="M4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM5 5V19H19V5H5ZM11.0026 16L6.75999 11.7574L8.17421 10.3431L11.0026 13.1716L16.6595 7.51472L18.0737 8.92893L11.0026 16Z" fill="currentColor"/>',"checkbox-blank":'<path d="M4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM5 5V19H19V5H5Z" fill="currentColor"/>',"checkbox-blank-circle-fill":'<path d="M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z" fill="currentColor"/>',"checkbox-circle":'<path d="M4 12C4 7.58172 7.58172 4 12 4C16.4183 4 20 7.58172 20 12C20 16.4183 16.4183 20 12 20C7.58172 20 4 16.4183 4 12ZM12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2ZM17.4571 9.45711L16.0429 8.04289L11 13.0858L8.20711 10.2929L6.79289 11.7071L11 15.9142L17.4571 9.45711Z" fill="currentColor"/>',"checkbox-multiple":'<path d="M6.99979 7V3C6.99979 2.44772 7.4475 2 7.99979 2H20.9998C21.5521 2 21.9998 2.44772 21.9998 3V16C21.9998 16.5523 21.5521 17 20.9998 17H17V20.9925C17 21.5489 16.551 22 15.9925 22H3.00728C2.45086 22 2 21.5511 2 20.9925L2.00276 8.00748C2.00288 7.45107 2.4518 7 3.01025 7H6.99979ZM8.99979 7H15.9927C16.549 7 17 7.44892 17 8.00748V15H19.9998V4H8.99979V7ZM15 9H4.00255L4.00021 20H15V9ZM8.50242 18L4.96689 14.4645L6.3811 13.0503L8.50242 15.1716L12.7451 10.9289L14.1593 12.3431L8.50242 18Z" fill="currentColor"/>',clipboard:'<path d="M7 4V2H17V4H20.0066C20.5552 4 21 4.44495 21 4.9934V21.0066C21 21.5552 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5551 3 21.0066V4.9934C3 4.44476 3.44495 4 3.9934 4H7ZM7 6H5V20H19V6H17V8H7V6ZM9 4V6H15V4H9Z" fill="currentColor"/>',close:'<path d="M11.9997 10.5865L16.9495 5.63672L18.3637 7.05093L13.4139 12.0007L18.3637 16.9504L16.9495 18.3646L11.9997 13.4149L7.04996 18.3646L5.63574 16.9504L10.5855 12.0007L5.63574 7.05093L7.04996 5.63672L11.9997 10.5865Z" fill="currentColor"/>',"close-circle":'<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM12 10.5858L14.8284 7.75736L16.2426 9.17157L13.4142 12L16.2426 14.8284L14.8284 16.2426L12 13.4142L9.17157 16.2426L7.75736 14.8284L10.5858 12L7.75736 9.17157L9.17157 7.75736L12 10.5858Z" fill="currentColor"/>',cloud:'<path d="M12 2C15.866 2 19 5.13401 19 9C19 9.11351 18.9973 9.22639 18.992 9.33857C21.3265 10.16 23 12.3846 23 15C23 18.3137 20.3137 21 17 21H7C3.68629 21 1 18.3137 1 15C1 12.3846 2.67346 10.16 5.00804 9.33857C5.0027 9.22639 5 9.11351 5 9C5 5.13401 8.13401 2 12 2ZM12 4C9.23858 4 7 6.23858 7 9C7 9.08147 7.00193 9.16263 7.00578 9.24344L7.07662 10.7309L5.67183 11.2252C4.0844 11.7837 3 13.2889 3 15C3 17.2091 4.79086 19 7 19H17C19.2091 19 21 17.2091 21 15C21 12.79 19.21 11 17 11C15.233 11 13.7337 12.1457 13.2042 13.7347L11.3064 13.1021C12.1005 10.7185 14.35 9 17 9C17 6.23858 14.7614 4 12 4Z" fill="currentColor"/>',"cloud-off":'<path d="M3.51472 2.10051L22.6066 21.1924L21.1924 22.6066L19.1782 20.5924C18.503 20.8556 17.7684 21 17 21H7C3.68629 21 1 18.3137 1 15C1 12.3846 2.67346 10.16 5.00804 9.33857C5.0027 9.22639 5 9.11351 5 9C5 8.22228 5.12683 7.47418 5.36094 6.77527L2.10051 3.51472L3.51472 2.10051ZM7 9C7 9.08147 7.00193 9.16263 7.00578 9.24344L7.07662 10.7309L5.67183 11.2252C4.0844 11.7837 3 13.2889 3 15C3 17.2091 4.79086 19 7 19H17C17.1858 19 17.3687 18.9873 17.5478 18.9628L7.03043 8.44519C7.01032 8.62736 7 8.81247 7 9ZM12 2C15.866 2 19 5.13401 19 9C19 9.11351 18.9973 9.22639 18.992 9.33857C21.3265 10.16 23 12.3846 23 15C23 16.0883 22.7103 17.1089 22.2037 17.9889L20.7111 16.4955C20.8974 16.0335 21 15.5287 21 15C21 12.79 19.21 11 17 11C16.4711 11 15.9661 11.1027 15.5039 11.2892L14.0111 9.7964C14.8912 9.28978 15.9118 9 17 9C17 6.23858 14.7614 4 12 4C10.9295 4 9.93766 4.33639 9.12428 4.90922L7.69418 3.48056C8.88169 2.55284 10.3763 2 12 2Z" fill="currentColor"/>',code:'<path d="M23 12L15.9289 19.0711L14.5147 17.6569L20.1716 12L14.5147 6.34317L15.9289 4.92896L23 12ZM3.82843 12L9.48528 17.6569L8.07107 19.0711L1 12L8.07107 4.92896L9.48528 6.34317L3.82843 12Z" fill="currentColor"/>',"code-ai":'<path d="M17.7134 10.1281L17.4668 10.6938C17.2864 11.1079 16.7136 11.1079 16.5331 10.6938L16.2866 10.1281C15.8471 9.11947 15.0555 8.31641 14.0677 7.87708L13.308 7.53922C12.8973 7.35653 12.8973 6.75881 13.308 6.57612L14.0252 6.25714C15.0384 5.80651 15.8442 4.97373 16.2761 3.93083L16.5293 3.31953C16.7058 2.89349 17.2942 2.89349 17.4706 3.31953L17.7238 3.93083C18.1558 4.97373 18.9616 5.80651 19.9748 6.25714L20.6919 6.57612C21.1027 6.75881 21.1027 7.35653 20.6919 7.53922L19.9323 7.87708C18.9445 8.31641 18.1529 9.11947 17.7134 10.1281ZM2.82843 12.0001L7.07107 16.2428L5.65685 17.657L0 12.0001L5.65685 6.34326L7.07107 7.75748L2.82843 12.0001ZM18.3429 17.6572L23.9998 12.0003L21.1714 9.17188L19.7571 10.5861L21.1714 12.0003L16.9287 16.2429L18.3429 17.6572Z" fill="currentColor"/>',"code-box":'<path d="M3 3H21C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3ZM4 5V19H20V5H4ZM20 12L16.4645 15.5355L15.0503 14.1213L17.1716 12L15.0503 9.87868L16.4645 8.46447L20 12ZM6.82843 12L8.94975 14.1213L7.53553 15.5355L4 12L7.53553 8.46447L8.94975 9.87868L6.82843 12ZM11.2443 17H9.11597L12.7557 7H14.884L11.2443 17Z" fill="currentColor"/>',"code-sslash":'<path d="M24 12L18.3431 17.6569L16.9289 16.2426L21.1716 12L16.9289 7.75736L18.3431 6.34315L24 12ZM2.82843 12L7.07107 16.2426L5.65685 17.6569L0 12L5.65685 6.34315L7.07107 7.75736L2.82843 12ZM9.78845 21H7.66009L14.2116 3H16.3399L9.78845 21Z" fill="currentColor"/>',"collapse-vertical":'<path d="M11.9995 13.4995 16.9492 18.4493 15.535 19.8635 12.9995 17.3279 12.9995 22.9995H10.9995L10.9995 17.3279 8.46643 19.861 7.05222 18.4468 11.9995 13.4995ZM10.9995.999512 10.9995 6.67035 8.46448 4.13535 7.05026 5.54956 12 10.4995 16.9497 5.54977 15.5355 4.13555 12.9995 6.67157V.999512L10.9995.999512Z" fill="currentColor"/>',command:'<path d="M10 8H14V6.5C14 4.567 15.567 3 17.5 3C19.433 3 21 4.567 21 6.5C21 8.433 19.433 10 17.5 10H16V14H17.5C19.433 14 21 15.567 21 17.5C21 19.433 19.433 21 17.5 21C15.567 21 14 19.433 14 17.5V16H10V17.5C10 19.433 8.433 21 6.5 21C4.567 21 3 19.433 3 17.5C3 15.567 4.567 14 6.5 14H8V10H6.5C4.567 10 3 8.433 3 6.5C3 4.567 4.567 3 6.5 3C8.433 3 10 4.567 10 6.5V8ZM8 8V6.5C8 5.67157 7.32843 5 6.5 5C5.67157 5 5 5.67157 5 6.5C5 7.32843 5.67157 8 6.5 8H8ZM8 16H6.5C5.67157 16 5 16.6716 5 17.5C5 18.3284 5.67157 19 6.5 19C7.32843 19 8 18.3284 8 17.5V16ZM16 8H17.5C18.3284 8 19 7.32843 19 6.5C19 5.67157 18.3284 5 17.5 5C16.6716 5 16 5.67157 16 6.5V8ZM16 16V17.5C16 18.3284 16.6716 19 17.5 19C18.3284 19 19 18.3284 19 17.5C19 16.6716 18.3284 16 17.5 16H16ZM10 10V14H14V10H10Z" fill="currentColor"/>',"compass-3":'<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM16.5 7.5L14 14L7.5 16.5L10 10L16.5 7.5ZM12 13C12.5523 13 13 12.5523 13 12C13 11.4477 12.5523 11 12 11C11.4477 11 11 11.4477 11 12C11 12.5523 11.4477 13 12 13Z" fill="currentColor"/>',computer:'<path d="M4 16H20V5H4V16ZM13 18V20H17V22H7V20H11V18H2.9918C2.44405 18 2 17.5511 2 16.9925V4.00748C2 3.45107 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44892 22 4.00748V16.9925C22 17.5489 21.5447 18 21.0082 18H13Z" fill="currentColor"/>',"contract-up-down":'<path d="M5.79285 5.20718 12 11.4143 18.2071 5.20718 16.7928 3.79297 12 8.58586 7.20706 3.79297 5.79285 5.20718ZM18.2072 18.7928 12.0001 12.5857 5.793 18.7928 7.20721 20.207 12.0001 15.4141 16.793 20.207 18.2072 18.7928Z" fill="currentColor"/>',"corner-down-left":'<path d="M19.0001 13.9999L19.0002 5L17.0002 4.99997L17.0001 11.9999L6.8283 12L10.778 8.05024L9.36382 6.63603L2.99986 13L9.36382 19.364L10.778 17.9497L6.82826 14L19.0001 13.9999Z" fill="currentColor"/>',cursor:'<path d="M15.3873 13.4975L17.9403 20.5117L13.2418 22.2218L10.6889 15.2076L6.79004 17.6529L8.4086 1.63318L19.9457 12.8646L15.3873 13.4975ZM15.3768 19.3163L12.6618 11.8568L15.6212 11.4459L9.98201 5.9561L9.19088 13.7863L11.7221 12.1988L14.4371 19.6583L15.3768 19.3163Z" fill="currentColor"/>',"database-2":'<path d="M5 12.5C5 12.8134 5.46101 13.3584 6.53047 13.8931C7.91405 14.5849 9.87677 15 12 15C14.1232 15 16.0859 14.5849 17.4695 13.8931C18.539 13.3584 19 12.8134 19 12.5V10.3287C17.35 11.3482 14.8273 12 12 12C9.17273 12 6.64996 11.3482 5 10.3287V12.5ZM19 15.3287C17.35 16.3482 14.8273 17 12 17C9.17273 17 6.64996 16.3482 5 15.3287V17.5C5 17.8134 5.46101 18.3584 6.53047 18.8931C7.91405 19.5849 9.87677 20 12 20C14.1232 20 16.0859 19.5849 17.4695 18.8931C18.539 18.3584 19 17.8134 19 17.5V15.3287ZM3 17.5V7.5C3 5.01472 7.02944 3 12 3C16.9706 3 21 5.01472 21 7.5V17.5C21 19.9853 16.9706 22 12 22C7.02944 22 3 19.9853 3 17.5ZM12 10C14.1232 10 16.0859 9.58492 17.4695 8.89313C18.539 8.3584 19 7.81342 19 7.5C19 7.18658 18.539 6.6416 17.4695 6.10687C16.0859 5.41508 14.1232 5 12 5C9.87677 5 7.91405 5.41508 6.53047 6.10687C5.46101 6.6416 5 7.18658 5 7.5C5 7.81342 5.46101 8.3584 6.53047 8.89313C7.91405 9.58492 9.87677 10 12 10Z" fill="currentColor"/>',"delete-bin":'<path d="M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM18 8H6V20H18V8ZM9 11H11V17H9V11ZM13 11H15V17H13V11ZM9 4V6H15V4H9Z" fill="currentColor"/>',"discord-fill":'<path d="M19.3034 5.33716C17.9344 4.71103 16.4805 4.2547 14.9629 4C14.7719 4.32899 14.5596 4.77471 14.411 5.12492C12.7969 4.89144 11.1944 4.89144 9.60255 5.12492C9.45397 4.77471 9.2311 4.32899 9.05068 4C7.52251 4.2547 6.06861 4.71103 4.70915 5.33716C1.96053 9.39111 1.21766 13.3495 1.5891 17.2549C3.41443 18.5815 5.17612 19.388 6.90701 19.9187C7.33151 19.3456 7.71356 18.73 8.04255 18.0827C7.41641 17.8492 6.82211 17.5627 6.24904 17.2231C6.39762 17.117 6.5462 17.0003 6.68416 16.8835C10.1438 18.4648 13.8911 18.4648 17.3082 16.8835C17.4568 17.0003 17.5948 17.117 17.7434 17.2231C17.1703 17.5627 16.576 17.8492 15.9499 18.0827C16.2789 18.73 16.6609 19.3456 17.0854 19.9187C18.8152 19.388 20.5875 18.5815 22.4033 17.2549C22.8596 12.7341 21.6806 8.80747 19.3034 5.33716ZM8.5201 14.8459C7.48007 14.8459 6.63107 13.9014 6.63107 12.7447C6.63107 11.5879 7.45884 10.6434 8.5201 10.6434C9.57071 10.6434 10.4303 11.5879 10.4091 12.7447C10.4091 13.9014 9.57071 14.8459 8.5201 14.8459ZM15.4936 14.8459C14.4535 14.8459 13.6034 13.9014 13.6034 12.7447C13.6034 11.5879 14.4323 10.6434 15.4936 10.6434C16.5442 10.6434 17.4038 11.5879 17.3825 12.7447C17.3825 13.9014 16.5548 14.8459 15.4936 14.8459Z" fill="currentColor"/>',"donut-chart":'<path d="M10.9999 2.04938L11 4.06188C7.05371 4.55396 4 7.92036 4 12C4 16.4183 7.58172 20 12 20C13.8487 20 15.5509 19.3729 16.9055 18.3199L18.3289 19.7428C16.605 21.1536 14.4014 22 12 22C6.47715 22 2 17.5228 2 12C2 6.81468 5.94662 2.55115 10.9999 2.04938ZM21.9506 13.0001C21.7509 15.0111 20.9555 16.8468 19.7433 18.3283L18.3199 16.9055C19.1801 15.799 19.756 14.4606 19.9381 12.9999L21.9506 13.0001ZM13.0011 2.04948C17.725 2.51902 21.4815 6.27589 21.9506 10.9999L19.9381 11C19.4869 7.38162 16.6192 4.51364 13.001 4.062L13.0011 2.04948Z" fill="currentColor"/>',"donut-chart-fill":'<path d="M10.9999 2.04938L11 5.07088C7.6077 5.55612 5 8.47352 5 12C5 15.866 8.13401 19 12 19C13.5723 19 15.0236 18.4816 16.1922 17.6064L18.3289 19.7428C16.605 21.1536 14.4014 22 12 22C6.47715 22 2 17.5228 2 12C2 6.81468 5.94662 2.55115 10.9999 2.04938ZM21.9506 13.0001C21.7509 15.0111 20.9555 16.8468 19.7433 18.3283L17.6064 16.1922C18.2926 15.2759 18.7595 14.1859 18.9291 13L21.9506 13.0001ZM13.0011 2.04948C17.725 2.51902 21.4815 6.27589 21.9506 10.9999L18.9291 10.9998C18.4905 7.93452 16.0661 5.50992 13.001 5.07103L13.0011 2.04948Z" fill="currentColor"/>',download:'<path d="M3 19H21V21H3V19ZM13 13.1716L19.0711 7.1005L20.4853 8.51472L12 17L3.51472 8.51472L4.92893 7.1005L11 13.1716V2H13V13.1716Z" fill="currentColor"/>',"download-cloud":'<path d="M1 14.5C1 12.1716 2.22429 10.1291 4.06426 8.9812C4.56469 5.044 7.92686 2 12 2C16.0731 2 19.4353 5.044 19.9357 8.9812C21.7757 10.1291 23 12.1716 23 14.5C23 17.9216 20.3562 20.7257 17 20.9811L7 21C3.64378 20.7257 1 17.9216 1 14.5ZM16.8483 18.9868C19.1817 18.8093 21 16.8561 21 14.5C21 12.927 20.1884 11.4962 18.8771 10.6781L18.0714 10.1754L17.9517 9.23338C17.5735 6.25803 15.0288 4 12 4C8.97116 4 6.42647 6.25803 6.0483 9.23338L5.92856 10.1754L5.12288 10.6781C3.81156 11.4962 3 12.927 3 14.5C3 16.8561 4.81833 18.8093 7.1517 18.9868L7.325 19H16.675L16.8483 18.9868ZM13 12H16L12 17L8 12H11V8H13V12Z" fill="currentColor"/>',"drag-move-2":'<path d="M11 11V5.82843L9.17157 7.65685L7.75736 6.24264L12 2L16.2426 6.24264L14.8284 7.65685L13 5.82843V11H18.1716L16.3431 9.17157L17.7574 7.75736L22 12L17.7574 16.2426L16.3431 14.8284L18.1716 13H13V18.1716L14.8284 16.3431L16.2426 17.7574L12 22L7.75736 17.7574L9.17157 16.3431L11 18.1716V13H5.82843L7.65685 14.8284L6.24264 16.2426L2 12L6.24264 7.75736L7.65685 9.17157L5.82843 11H11Z" fill="currentColor"/>',draggable:'<path d="M8.5 7C9.32843 7 10 6.32843 10 5.5C10 4.67157 9.32843 4 8.5 4C7.67157 4 7 4.67157 7 5.5C7 6.32843 7.67157 7 8.5 7ZM8.5 13.5C9.32843 13.5 10 12.8284 10 12C10 11.1716 9.32843 10.5 8.5 10.5C7.67157 10.5 7 11.1716 7 12C7 12.8284 7.67157 13.5 8.5 13.5ZM10 18.5C10 19.3284 9.32843 20 8.5 20C7.67157 20 7 19.3284 7 18.5C7 17.6716 7.67157 17 8.5 17C9.32843 17 10 17.6716 10 18.5ZM15.5 7C16.3284 7 17 6.32843 17 5.5C17 4.67157 16.3284 4 15.5 4C14.6716 4 14 4.67157 14 5.5C14 6.32843 14.6716 7 15.5 7ZM17 12C17 12.8284 16.3284 13.5 15.5 13.5C14.6716 13.5 14 12.8284 14 12C14 11.1716 14.6716 10.5 15.5 10.5C16.3284 10.5 17 11.1716 17 12ZM15.5 20C16.3284 20 17 19.3284 17 18.5C17 17.6716 16.3284 17 15.5 17C14.6716 17 14 17.6716 14 18.5C14 19.3284 14.6716 20 15.5 20Z" fill="currentColor"/>',edit:'<path d="M6.41421 15.89L16.5563 5.74785L15.1421 4.33363L5 14.4758V15.89H6.41421ZM7.24264 17.89H3V13.6473L14.435 2.21231C14.8256 1.82179 15.4587 1.82179 15.8492 2.21231L18.6777 5.04074C19.0682 5.43126 19.0682 6.06443 18.6777 6.45495L7.24264 17.89ZM3 19.89H21V21.89H3V19.89Z" fill="currentColor"/>',"edit-2":'<path d="M5 18.89H6.41421L15.7279 9.57627L14.3137 8.16206L5 17.4758V18.89ZM21 20.89H3V16.6473L16.435 3.21231C16.8256 2.82179 17.4587 2.82179 17.8492 3.21231L20.6777 6.04074C21.0682 6.43126 21.0682 7.06443 20.6777 7.45495L9.24264 18.89H21V20.89ZM15.7279 6.74785L17.1421 8.16206L18.5563 6.74785L17.1421 5.33363L15.7279 6.74785Z" fill="currentColor"/>',"emotion-happy":'<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM7 13H9C9 14.6569 10.3431 16 12 16C13.6569 16 15 14.6569 15 13H17C17 15.7614 14.7614 18 12 18C9.23858 18 7 15.7614 7 13ZM8 11C7.17157 11 6.5 10.3284 6.5 9.5C6.5 8.67157 7.17157 8 8 8C8.82843 8 9.5 8.67157 9.5 9.5C9.5 10.3284 8.82843 11 8 11ZM16 11C15.1716 11 14.5 10.3284 14.5 9.5C14.5 8.67157 15.1716 8 16 8C16.8284 8 17.5 8.67157 17.5 9.5C17.5 10.3284 16.8284 11 16 11Z" fill="currentColor"/>',"equalizer-2":'<path d="M5 7C5 6.17157 5.67157 5.5 6.5 5.5C7.32843 5.5 8 6.17157 8 7C8 7.82843 7.32843 8.5 6.5 8.5C5.67157 8.5 5 7.82843 5 7ZM6.5 3.5C4.567 3.5 3 5.067 3 7C3 8.933 4.567 10.5 6.5 10.5C8.433 10.5 10 8.933 10 7C10 5.067 8.433 3.5 6.5 3.5ZM12 8H20V6H12V8ZM16 17C16 16.1716 16.6716 15.5 17.5 15.5C18.3284 15.5 19 16.1716 19 17C19 17.8284 18.3284 18.5 17.5 18.5C16.6716 18.5 16 17.8284 16 17ZM17.5 13.5C15.567 13.5 14 15.067 14 17C14 18.933 15.567 20.5 17.5 20.5C19.433 20.5 21 18.933 21 17C21 15.067 19.433 13.5 17.5 13.5ZM4 16V18H12V16H4Z" fill="currentColor"/>',"error-warning":'<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM11 15H13V17H11V15ZM11 7H13V13H11V7Z" fill="currentColor"/>',"expand-up-down":'<path d="M18.2072 9.0428 12.0001 2.83569 5.793 9.0428 7.20721 10.457 12.0001 5.66412 16.793 10.457 18.2072 9.0428ZM5.79285 14.9572 12 21.1643 18.2071 14.9572 16.7928 13.543 12 18.3359 7.20706 13.543 5.79285 14.9572Z" fill="currentColor"/>',"external-link":'<path d="M10 6V8H5V19H16V14H18V20C18 20.5523 17.5523 21 17 21H4C3.44772 21 3 20.5523 3 20V7C3 6.44772 3.44772 6 4 6H10ZM21 3V11H19L18.9999 6.413L11.2071 14.2071L9.79289 12.7929L17.5849 5H13V3H21Z" fill="currentColor"/>',eye:'<path d="M12.0003 3C17.3924 3 21.8784 6.87976 22.8189 12C21.8784 17.1202 17.3924 21 12.0003 21C6.60812 21 2.12215 17.1202 1.18164 12C2.12215 6.87976 6.60812 3 12.0003 3ZM12.0003 19C16.2359 19 19.8603 16.052 20.7777 12C19.8603 7.94803 16.2359 5 12.0003 5C7.7646 5 4.14022 7.94803 3.22278 12C4.14022 16.052 7.7646 19 12.0003 19ZM12.0003 16.5C9.51498 16.5 7.50026 14.4853 7.50026 12C7.50026 9.51472 9.51498 7.5 12.0003 7.5C14.4855 7.5 16.5003 9.51472 16.5003 12C16.5003 14.4853 14.4855 16.5 12.0003 16.5ZM12.0003 14.5C13.381 14.5 14.5003 13.3807 14.5003 12C14.5003 10.6193 13.381 9.5 12.0003 9.5C10.6196 9.5 9.50026 10.6193 9.50026 12C9.50026 13.3807 10.6196 14.5 12.0003 14.5Z" fill="currentColor"/>',"eye-off":'<path d="M17.8827 19.2968C16.1814 20.3755 14.1638 21.0002 12.0003 21.0002C6.60812 21.0002 2.12215 17.1204 1.18164 12.0002C1.61832 9.62282 2.81932 7.5129 4.52047 5.93457L1.39366 2.80777L2.80788 1.39355L22.6069 21.1925L21.1927 22.6068L17.8827 19.2968ZM5.9356 7.3497C4.60673 8.56015 3.6378 10.1672 3.22278 12.0002C4.14022 16.0521 7.7646 19.0002 12.0003 19.0002C13.5997 19.0002 15.112 18.5798 16.4243 17.8384L14.396 15.8101C13.7023 16.2472 12.8808 16.5002 12.0003 16.5002C9.51498 16.5002 7.50026 14.4854 7.50026 12.0002C7.50026 11.1196 7.75317 10.2981 8.19031 9.60442L5.9356 7.3497ZM12.9139 14.328L9.67246 11.0866C9.5613 11.3696 9.50026 11.6777 9.50026 12.0002C9.50026 13.3809 10.6196 14.5002 12.0003 14.5002C12.3227 14.5002 12.6309 14.4391 12.9139 14.328ZM20.8068 16.5925L19.376 15.1617C20.0319 14.2268 20.5154 13.1586 20.7777 12.0002C19.8603 7.94818 16.2359 5.00016 12.0003 5.00016C11.1544 5.00016 10.3329 5.11773 9.55249 5.33818L7.97446 3.76015C9.22127 3.26959 10.5793 3.00016 12.0003 3.00016C17.3924 3.00016 21.8784 6.87992 22.8189 12.0002C22.5067 13.6998 21.8038 15.2628 20.8068 16.5925ZM11.7229 7.50857C11.8146 7.50299 11.9071 7.50016 12.0003 7.50016C14.4855 7.50016 16.5003 9.51488 16.5003 12.0002C16.5003 12.0933 16.4974 12.1858 16.4919 12.2775L11.7229 7.50857Z" fill="currentColor"/>',file:'<path d="M9 2.00318V2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8L9 2.00318ZM5.82918 8H9V4.83086L5.82918 8ZM11 4V9C11 9.55228 10.5523 10 10 10H5V20H19V4H11Z" fill="currentColor"/>',"file-add":'<path d="M15 4H5V20H19V8H15V4ZM3 2.9918C3 2.44405 3.44749 2 3.9985 2H16L20.9997 7L21 20.9925C21 21.5489 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918ZM11 11V8H13V11H16V13H13V16H11V13H8V11H11Z" fill="currentColor"/>',"file-check":'<path d="M12 20V22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918C3 2.44405 3.44749 2 3.9985 2H16L20.9998 7V14H19V8H15V4H5V20H12ZM14.4646 19.4647L18.0001 23.0002L22.9498 18.0505L21.5356 16.6362L18.0001 20.1718L15.8788 18.0505L14.4646 19.4647Z" fill="currentColor"/>',"file-check-fill":'<path d="M20.9998 7L16 2H3.9985C3.44749 2 3 2.44405 3 2.9918V21.0082C3 21.5447 3.44476 22 3.9934 22H12.3414C12.1203 21.3744 12 20.7013 12 20C12 16.6863 14.6863 14 18 14C19.0928 14 20.1174 14.2922 20.9999 14.8026L20.9998 7ZM14.4646 19.4647L18.0001 23.0002L22.9498 18.0505L21.5356 16.6362L18.0001 20.1718L15.8788 18.0505L14.4646 19.4647Z" fill="currentColor"/>',"file-code":'<path d="M15 4H5V20H19V8H15V4ZM3 2.9918C3 2.44405 3.44749 2 3.9985 2H16L20.9997 7L21 20.9925C21 21.5489 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918ZM17.6569 12L14.1213 15.5355L12.7071 14.1213L14.8284 12L12.7071 9.87868L14.1213 8.46447L17.6569 12ZM6.34315 12L9.87868 8.46447L11.2929 9.87868L9.17157 12L11.2929 14.1213L9.87868 15.5355L6.34315 12Z" fill="currentColor"/>',"file-copy":'<path d="M6.9998 6V3C6.9998 2.44772 7.44752 2 7.9998 2H19.9998C20.5521 2 20.9998 2.44772 20.9998 3V17C20.9998 17.5523 20.5521 18 19.9998 18H16.9998V20.9991C16.9998 21.5519 16.5499 22 15.993 22H4.00666C3.45059 22 3 21.5554 3 20.9991L3.0026 7.00087C3.0027 6.44811 3.45264 6 4.00942 6H6.9998ZM5.00242 8L5.00019 20H14.9998V8H5.00242ZM8.9998 6H16.9998V16H18.9998V4H8.9998V6Z" fill="currentColor"/>',"file-copy-2":'<path d="M6.9998 6V3C6.9998 2.44772 7.44752 2 7.9998 2H19.9998C20.5521 2 20.9998 2.44772 20.9998 3V17C20.9998 17.5523 20.5521 18 19.9998 18H16.9998V20.9991C16.9998 21.5519 16.5499 22 15.993 22H4.00666C3.45059 22 3 21.5554 3 20.9991L3.0026 7.00087C3.0027 6.44811 3.45264 6 4.00942 6H6.9998ZM5.00242 8L5.00019 20H14.9998V8H5.00242ZM8.9998 6H16.9998V16H18.9998V4H8.9998V6ZM7 11H13V13H7V11ZM7 15H13V17H7V15Z" fill="currentColor"/>',"file-download":'<path d="M13 12H16L12 16L8 12H11V8H13V12ZM15 4H5V20H19V8H15V4ZM3 2.9918C3 2.44405 3.44749 2 3.9985 2H16L20.9997 7L21 20.9925C21 21.5489 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918Z" fill="currentColor"/>',"file-edit":'<path d="M21 6.75736L19 8.75736V4H10V9H5V20H19V17.2426L21 15.2426V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V6.75736ZM21.7782 8.80761L23.1924 10.2218L15.4142 18L13.9979 17.9979L14 16.5858L21.7782 8.80761Z" fill="currentColor"/>',"file-image":'<path d="M15 8V4H5V20H19V8H15ZM3 2.9918C3 2.44405 3.44749 2 3.9985 2H16L20.9997 7L21 20.9925C21 21.5489 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918ZM11 9.5C11 10.3284 10.3284 11 9.5 11C8.67157 11 8 10.3284 8 9.5C8 8.67157 8.67157 8 9.5 8C10.3284 8 11 8.67157 11 9.5ZM17.5 17L13.5 10L8 17H17.5Z" fill="currentColor"/>',"file-list-2":'<path d="M20 22H4C3.44772 22 3 21.5523 3 21V3C3 2.44772 3.44772 2 4 2H20C20.5523 2 21 2.44772 21 3V21C21 21.5523 20.5523 22 20 22ZM19 20V4H5V20H19ZM8 7H16V9H8V7ZM8 11H16V13H8V11ZM8 15H13V17H8V15Z" fill="currentColor"/>',"file-music":'<path d="M16 8V10H13V14.5C13 15.8807 11.8807 17 10.5 17C9.11929 17 8 15.8807 8 14.5C8 13.1193 9.11929 12 10.5 12C10.6712 12 10.8384 12.0172 11 12.05V8H15V4H5V20H19V8H16ZM3 2.9918C3 2.44405 3.44749 2 3.9985 2H16L20.9997 7L21 20.9925C21 21.5489 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918Z" fill="currentColor"/>',"file-pdf":'<path d="M12 16H8V8H12C14.2091 8 16 9.79086 16 12C16 14.2091 14.2091 16 12 16ZM10 10V14H12C13.1046 14 14 13.1046 14 12C14 10.8954 13.1046 10 12 10H10ZM15 4H5V20H19V8H15V4ZM3 2.9918C3 2.44405 3.44749 2 3.9985 2H16L20.9997 7L21 20.9925C21 21.5489 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918Z" fill="currentColor"/>',"file-search":'<path d="M15 4H5V20H19V8H15V4ZM3 2.9918C3 2.44405 3.44749 2 3.9985 2H16L20.9997 7L21 20.9925C21 21.5489 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918ZM13.529 14.4464C11.9951 15.3524 9.98633 15.1464 8.66839 13.8284C7.1063 12.2663 7.1063 9.73367 8.66839 8.17157C10.2305 6.60948 12.7631 6.60948 14.3252 8.17157C15.6432 9.48951 15.8492 11.4983 14.9432 13.0322L17.1537 15.2426L15.7395 16.6569L13.529 14.4464ZM12.911 12.4142C13.6921 11.6332 13.6921 10.3668 12.911 9.58579C12.13 8.80474 10.8637 8.80474 10.0826 9.58579C9.30156 10.3668 9.30156 11.6332 10.0826 12.4142C10.8637 13.1953 12.13 13.1953 12.911 12.4142Z" fill="currentColor"/>',"file-text":'<path d="M21 8V20.9932C21 21.5501 20.5552 22 20.0066 22H3.9934C3.44495 22 3 21.556 3 21.0082V2.9918C3 2.45531 3.4487 2 4.00221 2H14.9968L21 8ZM19 9H14V4H5V20H19V9ZM8 7H11V9H8V7ZM8 11H16V13H8V11ZM8 15H16V17H8V15Z" fill="currentColor"/>',"file-transfer":'<path d="M15 4H5V20H19V8H15V4ZM3 2.9918C3 2.44405 3.44749 2 3.9985 2H16L20.9997 7L21 20.9925C21 21.5489 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918ZM12 11V8L16 12L12 16V13H8V11H12Z" fill="currentColor"/>',"file-video":'<path d="M15 4V8H19V20H5V4H15ZM3.9985 2C3.44749 2 3 2.44405 3 2.9918V21.0082C3 21.5447 3.44476 22 3.9934 22H20.0066C20.5551 22 21 21.5489 21 20.9925L20.9997 7L16 2H3.9985ZM15.0008 11.667L10.1219 8.41435C10.0562 8.37054 9.979 8.34717 9.9 8.34717C9.6791 8.34717 9.5 8.52625 9.5 8.74717V15.2524C9.5 15.3314 9.5234 15.4086 9.5672 15.4743C9.6897 15.6581 9.9381 15.7078 10.1219 15.5852L15.0008 12.3326C15.0447 12.3033 15.0824 12.2656 15.1117 12.2217C15.2343 12.0379 15.1846 11.7895 15.0008 11.667Z" fill="currentColor"/>',fingerprint:'<path d="M17.0003 13V14C17.0003 16.7696 16.3364 19.445 15.0853 21.8455L14.8585 22.2663L13.1116 21.2924C14.2716 19.2115 14.9211 16.8817 14.9935 14.4559L15.0003 14V13H17.0003ZM11.0003 10H13.0003V14L12.9948 14.3787C12.9153 17.1495 11.9645 19.7731 10.3038 21.928L10.073 22.2189L8.52406 20.9536C10.0408 19.0969 10.9145 16.8017 10.9943 14.3663L11.0003 14V10ZM12.0003 6C14.7617 6 17.0003 8.23858 17.0003 11H15.0003C15.0003 9.34315 13.6571 8 12.0003 8C10.3434 8 9.00025 9.34315 9.00025 11V14C9.00025 16.2354 8.1806 18.3444 6.72928 19.9768L6.51767 20.2067L5.06955 18.8273C6.23328 17.6056 6.92099 16.0118 6.99381 14.3027L7.00025 14V11C7.00025 8.23858 9.23883 6 12.0003 6ZM12.0003 2C16.9708 2 21.0003 6.02944 21.0003 11V14C21.0003 15.6979 20.7985 17.3699 20.4035 18.9903L20.2647 19.5285L18.3349 19.0032C18.726 17.5662 18.9475 16.0808 18.9919 14.5684L19.0003 14V11C19.0003 7.13401 15.8662 4 12.0003 4C10.4279 4 8.97663 4.51841 7.80805 5.39364L6.38308 3.96769C7.92267 2.73631 9.87547 2 12.0003 2ZM4.96794 5.38282L6.39389 6.8078C5.5635 7.91652 5.0543 9.27971 5.00431 10.7593L4.99961 10.999L5.00378 13C5.00378 14.1195 4.73991 15.2026 4.24263 16.1772L4.08648 16.4663L2.34961 15.4747C2.72889 14.8103 2.95077 14.0681 2.99539 13.2924L3.00378 13L3.00361 11C3.00025 8.87522 3.73656 6.92242 4.96794 5.38282Z" fill="currentColor"/>',flashlight:'<path d="M13 9H21L11 24V15H4L13 0V9ZM11 11V7.22063L7.53238 13H13V17.3944L17.263 11H11Z" fill="currentColor"/>',flask:'<path d="M15.9994 2V4H14.9994V7.24291C14.9994 8.40051 15.2506 9.54432 15.7357 10.5954L20.017 19.8714C20.3641 20.6236 20.0358 21.5148 19.2836 21.8619C19.0865 21.9529 18.8721 22 18.655 22H5.34375C4.51532 22 3.84375 21.3284 3.84375 20.5C3.84375 20.2829 3.89085 20.0685 3.98181 19.8714L8.26306 10.5954C8.74816 9.54432 8.99939 8.40051 8.99939 7.24291V4H7.99939V2H15.9994ZM13.3873 10.0012H10.6115C10.5072 10.3644 10.3823 10.7221 10.2371 11.0724L10.079 11.4335L6.12439 20H17.8734L13.9198 11.4335C13.7054 10.9691 13.5276 10.4902 13.3873 10.0012ZM10.9994 7.24291C10.9994 7.49626 10.9898 7.7491 10.9706 8.00087H13.0282C13.0189 7.87982 13.0119 7.75852 13.0072 7.63704L12.9994 7.24291V4H10.9994V7.24291Z" fill="currentColor"/>',folder:'<path d="M4 5V19H20V7H11.5858L9.58579 5H4ZM12.4142 5H21C21.5523 5 22 5.44772 22 6V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H10.4142L12.4142 5Z" fill="currentColor"/>',"folder-3":'<path d="M12.4142 5H21C21.5523 5 22 5.44772 22 6V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H10.4142L12.4142 5ZM4 7V19H20V7H4Z" fill="currentColor"/>',"folder-3-fill":'<path d="M22 8V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V7H21C21.5523 7 22 7.44772 22 8ZM12.4142 5H2V4C2 3.44772 2.44772 3 3 3H10.4142L12.4142 5Z" fill="currentColor"/>',"folder-6":'<path d="M2 4C2 3.44772 2.44772 3 3 3H10.4142L12.4142 5H21C21.5523 5 22 5.44772 22 6V20C22 20.5523 21.5523 21 21 21L3 21C2.45 21 2 20.55 2 20V4ZM10.5858 6L9.58579 5H4V7H9.58579L10.5858 6ZM4 9V19L20 19V7H12.4142L10.4142 9H4Z" fill="currentColor"/>',"folder-add":'<path d="M12.4142 5H21C21.5523 5 22 5.44772 22 6V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H10.4142L12.4142 5ZM4 5V19H20V7H11.5858L9.58579 5H4ZM11 12V9H13V12H16V14H13V17H11V14H8V12H11Z" fill="currentColor"/>',"folder-open":'<path d="M3 21C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H10.4142L12.4142 5H20C20.5523 5 21 5.44772 21 6V9H19V7H11.5858L9.58579 5H4V16.998L5.5 11H22.5L20.1894 20.2425C20.0781 20.6877 19.6781 21 19.2192 21H3ZM19.9384 13H7.06155L5.56155 19H18.4384L19.9384 13Z" fill="currentColor"/>',"folder-open-fill":'<path d="M3 21C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H10.4142L12.4142 5H20C20.5523 5 21 5.44772 21 6V9H4V18.996L6 11H22.5L20.1894 20.2425C20.0781 20.6877 19.6781 21 19.2192 21H3Z" fill="currentColor"/>',"folder-received":'<path d="M22 13H20V7H11.5858L9.58579 5H4V19H13V21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H10.4142L12.4142 5H21C21.5523 5 22 5.44772 22 6V13ZM20 17H23V19H20V22.5L15 18L20 13.5V17Z" fill="currentColor"/>',"folder-shared":'<path d="M22 13H20V7H11.5858L9.58579 5H4V19H13V21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H10.4142L12.4142 5H21C21.5523 5 22 5.44772 22 6V13ZM18 17V13.5L23 18L18 22.5V19H15V17H18Z" fill="currentColor"/>',folders:'<path d="M6 7V4C6 3.44772 6.44772 3 7 3H13.4142L15.4142 5H21C21.5523 5 22 5.44772 22 6V16C22 16.5523 21.5523 17 21 17H18V20C18 20.5523 17.5523 21 17 21H3C2.44772 21 2 20.5523 2 20V8C2 7.44772 2.44772 7 3 7H6ZM6 9H4V19H16V17H6V9ZM8 5V15H20V7H14.5858L12.5858 5H8Z" fill="currentColor"/>',fullscreen:'<path d="M8 3V5H4V9H2V3H8ZM2 21V15H4V19H8V21H2ZM22 21H16V19H20V15H22V21ZM22 9H20V5H16V3H22V9Z" fill="currentColor"/>',"fullscreen-exit":'<path d="M18 7H22V9H16V3H18V7ZM8 9H2V7H6V3H8V9ZM18 17V21H16V15H22V17H18ZM8 15V21H6V17H2V15H8Z" fill="currentColor"/>',gamepad:'<path d="M17 4C20.3137 4 23 6.68629 23 10V14C23 17.3137 20.3137 20 17 20H7C3.68629 20 1 17.3137 1 14V10C1 6.68629 3.68629 4 7 4H17ZM17 6H7C4.8578 6 3.10892 7.68397 3.0049 9.80036L3 10V14C3 16.1422 4.68397 17.8911 6.80036 17.9951L7 18H17C19.1422 18 20.8911 16.316 20.9951 14.1996L21 14V10C21 7.8578 19.316 6.10892 17.1996 6.0049L17 6ZM10 9V11H12V13H9.999L10 15H8L7.999 13H6V11H8V9H10ZM18 13V15H16V13H18ZM16 9V11H14V9H16Z" fill="currentColor"/>',"git-branch":'<path d="M7.10508 15.2101C8.21506 15.6501 9 16.7334 9 18C9 19.6569 7.65685 21 6 21C4.34315 21 3 19.6569 3 18C3 16.6938 3.83481 15.5825 5 15.1707V8.82929C3.83481 8.41746 3 7.30622 3 6C3 4.34315 4.34315 3 6 3C7.65685 3 9 4.34315 9 6C9 7.30622 8.16519 8.41746 7 8.82929V11.9996C7.83566 11.3719 8.87439 11 10 11H14C15.3835 11 16.5482 10.0635 16.8949 8.78991C15.7849 8.34988 15 7.26661 15 6C15 4.34315 16.3431 3 18 3C19.6569 3 21 4.34315 21 6C21 7.3332 20.1303 8.46329 18.9274 8.85392C18.5222 11.2085 16.4703 13 14 13H10C8.61653 13 7.45179 13.9365 7.10508 15.2101ZM6 17C5.44772 17 5 17.4477 5 18C5 18.5523 5.44772 19 6 19C6.55228 19 7 18.5523 7 18C7 17.4477 6.55228 17 6 17ZM6 5C5.44772 5 5 5.44772 5 6C5 6.55228 5.44772 7 6 7C6.55228 7 7 6.55228 7 6C7 5.44772 6.55228 5 6 5ZM18 5C17.4477 5 17 5.44772 17 6C17 6.55228 17.4477 7 18 7C18.5523 7 19 6.55228 19 6C19 5.44772 18.5523 5 18 5Z" fill="currentColor"/>',"git-close-pull-request":'<path d="M6 5C5.44772 5 5 5.44772 5 6C5 6.55228 5.44772 7 6 7C6.55228 7 7 6.55228 7 6C7 5.44772 6.55228 5 6 5ZM3 6C3 4.34315 4.34315 3 6 3C7.65685 3 9 4.34315 9 6C9 7.30622 8.16519 8.41746 7 8.82929V15.1707C8.16519 15.5825 9 16.6938 9 18C9 19.6569 7.65685 21 6 21C4.34315 21 3 19.6569 3 18C3 16.6938 3.83481 15.5825 5 15.1707V8.82929C3.83481 8.41746 3 7.30622 3 6ZM15.2929 3.29289C15.6834 2.90237 16.3166 2.90237 16.7071 3.29289L18 4.58579L19.2929 3.29289C19.6834 2.90237 20.3166 2.90237 20.7071 3.29289C21.0976 3.68342 21.0976 4.31658 20.7071 4.70711L19.4142 6L20.7071 7.29289C21.0976 7.68342 21.0976 8.31658 20.7071 8.70711C20.3166 9.09763 19.6834 9.09763 19.2929 8.70711L18 7.41421L16.7071 8.70711C16.3166 9.09763 15.6834 9.09763 15.2929 8.70711C14.9024 8.31658 14.9024 7.68342 15.2929 7.29289L16.5858 6L15.2929 4.70711C14.9024 4.31658 14.9024 3.68342 15.2929 3.29289ZM18 10C18.5523 10 19 10.4477 19 11V15.1707C20.1652 15.5825 21 16.6938 21 18C21 19.6569 19.6569 21 18 21C16.3431 21 15 19.6569 15 18C15 16.6938 15.8348 15.5825 17 15.1707V11C17 10.4477 17.4477 10 18 10ZM6 17C5.44772 17 5 17.4477 5 18C5 18.5523 5.44772 19 6 19C6.55228 19 7 18.5523 7 18C7 17.4477 6.55228 17 6 17ZM18 17C17.4477 17 17 17.4477 17 18C17 18.5523 17.4477 19 18 19C18.5523 19 19 18.5523 19 18C19 17.4477 18.5523 17 18 17Z" fill="currentColor"/>',"git-commit":'<path d="M15.874 13C15.4299 14.7252 13.8638 16 12 16C10.1362 16 8.57006 14.7252 8.12602 13H3V11H8.12602C8.57006 9.27477 10.1362 8 12 8C13.8638 8 15.4299 9.27477 15.874 11H21V13H15.874ZM12 14C13.1046 14 14 13.1046 14 12C14 10.8954 13.1046 10 12 10C10.8954 10 10 10.8954 10 12C10 13.1046 10.8954 14 12 14Z" fill="currentColor"/>',"git-merge":'<path d="M7.10508 8.78991C7.45179 10.0635 8.61653 11 10 11H14C16.4703 11 18.5222 12.7915 18.9274 15.1461C20.1303 15.5367 21 16.6668 21 18C21 19.6569 19.6569 21 18 21C16.3431 21 15 19.6569 15 18C15 16.7334 15.7849 15.6501 16.8949 15.2101C16.5482 13.9365 15.3835 13 14 13H10C8.87439 13 7.83566 12.6281 7 12.0004V15.1707C8.16519 15.5825 9 16.6938 9 18C9 19.6569 7.65685 21 6 21C4.34315 21 3 19.6569 3 18C3 16.6938 3.83481 15.5825 5 15.1707V8.82929C3.83481 8.41746 3 7.30622 3 6C3 4.34315 4.34315 3 6 3C7.65685 3 9 4.34315 9 6C9 7.26661 8.21506 8.34988 7.10508 8.78991ZM6 7C6.55228 7 7 6.55228 7 6C7 5.44772 6.55228 5 6 5C5.44772 5 5 5.44772 5 6C5 6.55228 5.44772 7 6 7ZM6 19C6.55228 19 7 18.5523 7 18C7 17.4477 6.55228 17 6 17C5.44772 17 5 17.4477 5 18C5 18.5523 5.44772 19 6 19ZM18 19C18.5523 19 19 18.5523 19 18C19 17.4477 18.5523 17 18 17C17.4477 17 17 17.4477 17 18C17 18.5523 17.4477 19 18 19Z" fill="currentColor"/>',"git-pr-draft":'<path d="M5 6C5 5.44772 5.44772 5 6 5C6.55228 5 7 5.44772 7 6C7 6.55228 6.55228 7 6 7C5.44772 7 5 6.55228 5 6ZM6 3C4.34315 3 3 4.34315 3 6C3 7.30622 3.83481 8.41746 5 8.82929V15.1707C3.83481 15.5825 3 16.6938 3 18C3 19.6569 4.34315 21 6 21C7.65685 21 9 19.6569 9 18C9 16.6938 8.16519 15.5825 7 15.1707V8.82929C8.16519 8.41746 9 7.30622 9 6C9 4.34315 7.65685 3 6 3ZM5 18C5 17.4477 5.44772 17 6 17C6.55228 17 7 17.4477 7 18C7 18.5523 6.55228 19 6 19C5.44772 19 5 18.5523 5 18ZM18 17C17.4477 17 17 17.4477 17 18C17 18.5523 17.4477 19 18 19C18.5523 19 19 18.5523 19 18C19 17.4477 18.5523 17 18 17ZM15 18C15 16.3431 16.3431 15 18 15C19.6569 15 21 16.3431 21 18C21 19.6569 19.6569 21 18 21C16.3431 21 15 19.6569 15 18ZM18 7.5C18.8284 7.5 19.5 6.82843 19.5 6C19.5 5.17157 18.8284 4.5 18 4.5C17.1716 4.5 16.5 5.17157 16.5 6C16.5 6.82843 17.1716 7.5 18 7.5ZM19.5 11.5C19.5 12.3284 18.8284 13 18 13C17.1716 13 16.5 12.3284 16.5 11.5C16.5 10.6716 17.1716 10 18 10C18.8284 10 19.5 10.6716 19.5 11.5Z" fill="currentColor"/>',"git-pull-request":'<path d="M15 5H17C18.1046 5 19 5.89543 19 7V15.1707C20.1652 15.5825 21 16.6938 21 18C21 19.6569 19.6569 21 18 21C16.3431 21 15 19.6569 15 18C15 16.6938 15.8348 15.5825 17 15.1707V7H15V10L10.5 6L15 2V5ZM5 8.82929C3.83481 8.41746 3 7.30622 3 6C3 4.34315 4.34315 3 6 3C7.65685 3 9 4.34315 9 6C9 7.30622 8.16519 8.41746 7 8.82929V15.1707C8.16519 15.5825 9 16.6938 9 18C9 19.6569 7.65685 21 6 21C4.34315 21 3 19.6569 3 18C3 16.6938 3.83481 15.5825 5 15.1707V8.82929ZM6 7C6.55228 7 7 6.55228 7 6C7 5.44772 6.55228 5 6 5C5.44772 5 5 5.44772 5 6C5 6.55228 5.44772 7 6 7ZM6 19C6.55228 19 7 18.5523 7 18C7 17.4477 6.55228 17 6 17C5.44772 17 5 17.4477 5 18C5 18.5523 5.44772 19 6 19ZM18 19C18.5523 19 19 18.5523 19 18C19 17.4477 18.5523 17 18 17C17.4477 17 17 17.4477 17 18C17 18.5523 17.4477 19 18 19Z" fill="currentColor"/>',"git-repository":'<path d="M13 21V23.5L10 21.5L7 23.5V21H6.5C4.567 21 3 19.433 3 17.5V5C3 3.34315 4.34315 2 6 2H20C20.5523 2 21 2.44772 21 3V20C21 20.5523 20.5523 21 20 21H13ZM13 19H19V16H6.5C5.67157 16 5 16.6716 5 17.5C5 18.3284 5.67157 19 6.5 19H7V17H13V19ZM19 14V4H6V14.0354C6.1633 14.0121 6.33024 14 6.5 14H19ZM7 5H9V7H7V5ZM7 8H9V10H7V8ZM7 11H9V13H7V11Z" fill="currentColor"/>',github:'<path d="M5.88401 18.6533C5.58404 18.4526 5.32587 18.1975 5.0239 17.8369C4.91473 17.7065 4.47283 17.1524 4.55811 17.2583C4.09533 16.6833 3.80296 16.417 3.50156 16.3089C2.9817 16.1225 2.7114 15.5499 2.89784 15.0301C3.08428 14.5102 3.65685 14.2399 4.17672 14.4263C4.92936 14.6963 5.43847 15.1611 6.12425 16.0143C6.03025 15.8974 6.46364 16.441 6.55731 16.5529C6.74784 16.7804 6.88732 16.9182 6.99629 16.9911C7.20118 17.1283 7.58451 17.1874 8.14709 17.1311C8.17065 16.7489 8.24136 16.3783 8.34919 16.0358C5.38097 15.3104 3.70116 13.3952 3.70116 9.63971C3.70116 8.40085 4.0704 7.28393 4.75917 6.3478C4.5415 5.45392 4.57433 4.37284 5.06092 3.15636C5.1725 2.87739 5.40361 2.66338 5.69031 2.57352C5.77242 2.54973 5.81791 2.53915 5.89878 2.52673C6.70167 2.40343 7.83573 2.69705 9.31449 3.62336C10.181 3.41879 11.0885 3.315 12.0012 3.315C12.9129 3.315 13.8196 3.4186 14.6854 3.62277C16.1619 2.69 17.2986 2.39649 18.1072 2.52651C18.1919 2.54013 18.2645 2.55783 18.3249 2.57766C18.6059 2.66991 18.8316 2.88179 18.9414 3.15636C19.4279 4.37256 19.4608 5.45344 19.2433 6.3472C19.9342 7.28337 20.3012 8.39208 20.3012 9.63971C20.3012 13.3968 18.627 15.3048 15.6588 16.032C15.7837 16.447 15.8496 16.9105 15.8496 17.4121C15.8496 18.0765 15.8471 18.711 15.8424 19.4225C15.8412 19.6127 15.8397 19.8159 15.8375 20.1281C16.2129 20.2109 16.5229 20.5077 16.6031 20.9089C16.7114 21.4504 16.3602 21.9773 15.8186 22.0856C14.6794 22.3134 13.8353 21.5538 13.8353 20.5611C13.8353 20.4708 13.836 20.3417 13.8375 20.1145C13.8398 19.8015 13.8412 19.599 13.8425 19.4094C13.8471 18.7019 13.8496 18.0716 13.8496 17.4121C13.8496 16.7148 13.6664 16.2602 13.4237 16.051C12.7627 15.4812 13.0977 14.3973 13.965 14.2999C16.9314 13.9666 18.3012 12.8177 18.3012 9.63971C18.3012 8.68508 17.9893 7.89571 17.3881 7.23559C17.1301 6.95233 17.0567 6.54659 17.199 6.19087C17.3647 5.77663 17.4354 5.23384 17.2941 4.57702L17.2847 4.57968C16.7928 4.71886 16.1744 5.0198 15.4261 5.5285C15.182 5.69438 14.8772 5.74401 14.5932 5.66413C13.7729 5.43343 12.8913 5.315 12.0012 5.315C11.111 5.315 10.2294 5.43343 9.40916 5.66413C9.12662 5.74359 8.82344 5.69492 8.57997 5.53101C7.8274 5.02439 7.2056 4.72379 6.71079 4.58376C6.56735 5.23696 6.63814 5.77782 6.80336 6.19087C6.94565 6.54659 6.87219 6.95233 6.61423 7.23559C6.01715 7.8912 5.70116 8.69376 5.70116 9.63971C5.70116 12.8116 7.07225 13.9683 10.023 14.2999C10.8883 14.3971 11.2246 15.4769 10.5675 16.0482C10.3751 16.2156 10.1384 16.7802 10.1384 17.4121V20.5611C10.1384 21.5474 9.30356 22.2869 8.17878 22.09C7.63476 21.9948 7.27093 21.4766 7.36613 20.9326C7.43827 20.5204 7.75331 20.2116 8.13841 20.1276V19.1381C7.22829 19.1994 6.47656 19.0498 5.88401 18.6533Z" fill="currentColor"/>',"github-fill":'<path d="M12.001 2C6.47598 2 2.00098 6.475 2.00098 12C2.00098 16.425 4.86348 20.1625 8.83848 21.4875C9.33848 21.575 9.52598 21.275 9.52598 21.0125C9.52598 20.775 9.51348 19.9875 9.51348 19.15C7.00098 19.6125 6.35098 18.5375 6.15098 17.975C6.03848 17.6875 5.55098 16.8 5.12598 16.5625C4.77598 16.375 4.27598 15.9125 5.11348 15.9C5.90098 15.8875 6.46348 16.625 6.65098 16.925C7.55098 18.4375 8.98848 18.0125 9.56348 17.75C9.65098 17.1 9.91348 16.6625 10.201 16.4125C7.97598 16.1625 5.65098 15.3 5.65098 11.475C5.65098 10.3875 6.03848 9.4875 6.67598 8.7875C6.57598 8.5375 6.22598 7.5125 6.77598 6.1375C6.77598 6.1375 7.61348 5.875 9.52598 7.1625C10.326 6.9375 11.176 6.825 12.026 6.825C12.876 6.825 13.726 6.9375 14.526 7.1625C16.4385 5.8625 17.276 6.1375 17.276 6.1375C17.826 7.5125 17.476 8.5375 17.376 8.7875C18.0135 9.4875 18.401 10.375 18.401 11.475C18.401 15.3125 16.0635 16.1625 13.8385 16.4125C14.201 16.725 14.5135 17.325 14.5135 18.2625C14.5135 19.6 14.501 20.675 14.501 21.0125C14.501 21.275 14.6885 21.5875 15.1885 21.4875C19.259 20.1133 21.9999 16.2963 22.001 12C22.001 6.475 17.526 2 12.001 2Z" fill="currentColor"/>',global:'<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM9.71002 19.6674C8.74743 17.6259 8.15732 15.3742 8.02731 13H4.06189C4.458 16.1765 6.71639 18.7747 9.71002 19.6674ZM10.0307 13C10.1811 15.4388 10.8778 17.7297 12 19.752C13.1222 17.7297 13.8189 15.4388 13.9693 13H10.0307ZM19.9381 13H15.9727C15.8427 15.3742 15.2526 17.6259 14.29 19.6674C17.2836 18.7747 19.542 16.1765 19.9381 13ZM4.06189 11H8.02731C8.15732 8.62577 8.74743 6.37407 9.71002 4.33256C6.71639 5.22533 4.458 7.8235 4.06189 11ZM10.0307 11H13.9693C13.8189 8.56122 13.1222 6.27025 12 4.24799C10.8778 6.27025 10.1811 8.56122 10.0307 11ZM14.29 4.33256C15.2526 6.37407 15.8427 8.62577 15.9727 11H19.9381C19.542 7.8235 17.2836 5.22533 14.29 4.33256Z" fill="currentColor"/>',"graduation-cap":'<path d="M4 11.3333L0 9L12 2L24 9V17.5H22V10.1667L20 11.3333V18.0113L19.7774 18.2864C17.9457 20.5499 15.1418 22 12 22C8.85817 22 6.05429 20.5499 4.22263 18.2864L4 18.0113V11.3333ZM6 12.5V17.2917C7.46721 18.954 9.61112 20 12 20C14.3889 20 16.5328 18.954 18 17.2917V12.5L12 16L6 12.5ZM3.96927 9L12 13.6846L20.0307 9L12 4.31541L3.96927 9Z" fill="currentColor"/>',hammer:'<path d="M20 2C20.5523 2 21 2.44772 21 3V8C21 8.55228 20.5523 9 20 9H15V22C15 22.5523 14.5523 23 14 23H10C9.44772 23 9 22.5523 9 22V9H3.5C2.94772 9 2.5 8.55228 2.5 8V5.61803C2.5 5.23926 2.714 4.893 3.05279 4.72361L8.5 2H20ZM15 4H8.97214L4.5 6.23607V7H11V21H13V7H15V4ZM19 4H17V7H19V4Z" fill="currentColor"/>',heart:'<path d="M12.001 4.52853C14.35 2.42 17.98 2.49 20.2426 4.75736C22.5053 7.02472 22.583 10.637 20.4786 12.993L11.9999 21.485L3.52138 12.993C1.41705 10.637 1.49571 7.01901 3.75736 4.75736C6.02157 2.49315 9.64519 2.41687 12.001 4.52853ZM18.827 6.1701C17.3279 4.66794 14.9076 4.60701 13.337 6.01687L12.0019 7.21524L10.6661 6.01781C9.09098 4.60597 6.67506 4.66808 5.17157 6.17157C3.68183 7.66131 3.60704 10.0473 4.97993 11.6232L11.9999 18.6543L19.0201 11.6232C20.3935 10.0467 20.319 7.66525 18.827 6.1701Z" fill="currentColor"/>',history:'<path d="M12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12H4C4 16.4183 7.58172 20 12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C9.25022 4 6.82447 5.38734 5.38451 7.50024L8 7.5V9.5H2V3.5H4L3.99989 5.99918C5.82434 3.57075 8.72873 2 12 2ZM13 7L12.9998 11.585L16.2426 14.8284L14.8284 16.2426L10.9998 12.413L11 7H13Z" fill="currentColor"/>',home:'<path d="M21 20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V9.48907C3 9.18048 3.14247 8.88917 3.38606 8.69972L11.3861 2.47749C11.7472 2.19663 12.2528 2.19663 12.6139 2.47749L20.6139 8.69972C20.8575 8.88917 21 9.18048 21 9.48907V20ZM19 19V9.97815L12 4.53371L5 9.97815V19H19Z" fill="currentColor"/>',"home-office":'<path d="M12.6727 1.61162 20.7999 9H17.8267L12 3.70302 6 9.15757V19.0001H11V21.0001H5C4.44772 21.0001 4 20.5524 4 20.0001V11.0001L1 11.0001 11.3273 1.61162C11.7087 1.26488 12.2913 1.26488 12.6727 1.61162ZM14 11H23V18H14V11ZM16 13V16H21V13H16ZM24 21H13V19H24V21Z" fill="currentColor"/>',hourglass:'<path d="M6 4H4V2H20V4H18V6C18 7.61543 17.1838 8.91468 16.1561 9.97667C15.4532 10.703 14.598 11.372 13.7309 12C14.598 12.628 15.4532 13.297 16.1561 14.0233C17.1838 15.0853 18 16.3846 18 18V20H20V22H4V20H6V18C6 16.3846 6.81616 15.0853 7.8439 14.0233C8.54682 13.297 9.40202 12.628 10.2691 12C9.40202 11.372 8.54682 10.703 7.8439 9.97667C6.81616 8.91468 6 7.61543 6 6V4ZM8 4V6C8 6.88457 8.43384 7.71032 9.2811 8.58583C10.008 9.33699 10.9548 10.0398 12 10.7781C13.0452 10.0398 13.992 9.33699 14.7189 8.58583C15.5662 7.71032 16 6.88457 16 6V4H8ZM12 13.2219C10.9548 13.9602 10.008 14.663 9.2811 15.4142C8.43384 16.2897 8 17.1154 8 18V20H16V18C16 17.1154 15.5662 16.2897 14.7189 15.4142C13.992 14.663 13.0452 13.9602 12 13.2219Z" fill="currentColor"/>',"hourglass-fill":'<path d="M6 4H4V2H20V4H18V6C18 7.61543 17.1838 8.91468 16.1561 9.97667C15.4532 10.703 14.598 11.372 13.7309 12C14.598 12.628 15.4532 13.297 16.1561 14.0233C17.1838 15.0853 18 16.3846 18 18V20H20V22H4V20H6V18C6 16.3846 6.81616 15.0853 7.8439 14.0233C8.54682 13.297 9.40202 12.628 10.2691 12C9.40202 11.372 8.54682 10.703 7.8439 9.97667C6.81616 8.91468 6 7.61543 6 6V4ZM8 4V6C8 6.68514 8.26026 7.33499 8.77131 8H15.2287C15.7397 7.33499 16 6.68514 16 6V4H8ZM12 13.2219C10.9548 13.9602 10.008 14.663 9.2811 15.4142C9.09008 15.6116 8.92007 15.8064 8.77131 16H15.2287C15.0799 15.8064 14.9099 15.6116 14.7189 15.4142C13.992 14.663 13.0452 13.9602 12 13.2219Z" fill="currentColor"/>',"image-download":'<path d="M21 15V19H24L20 23L16 19H19V15H21ZM21.0078 3C21.5555 3 21.9999 3.44482 22 3.99316V13H20V5H4V18.999L14 9L17 12V14.8291L14 11.8281L6.82715 19H14V21H2.99219C2.44451 21 2.00013 20.5552 2 20.0068V3.99316C2.00013 3.44463 2.45577 3 2.99219 3H21.0078ZM8 7C9.10457 7 10 7.89543 10 9C10 10.1046 9.10457 11 8 11C6.89543 11 6 10.1046 6 9C6 7.89543 6.89543 7 8 7Z" fill="currentColor"/>',"inbox-archive":'<path d="M20 3L22 7V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V7.00353L4 3H20ZM20 9H4V19H20V9ZM13 10V14H16L12 18L8 14H11V10H13ZM18.7639 5H5.23656L4.23744 7H19.7639L18.7639 5Z" fill="currentColor"/>',"inbox-unarchive":'<path d="M20 3L22 7V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V7.00353L4 3H20ZM20 9H4V19H20V9ZM12 10L16 14H13V18H11V14H8L12 10ZM18.764 5H5.236L4.237 7H19.764L18.764 5Z" fill="currentColor"/>',"inbox-unarchive-fill":'<path d="M20 3L22 7V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V7.00353L4 3H20ZM12 10L8 14H11V18H13V14H16L12 10ZM18.764 5H5.236L4.237 7H19.764L18.764 5Z" fill="currentColor"/>',information:'<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM11 7H13V9H11V7ZM11 11H13V17H11V11Z" fill="currentColor"/>',key:'<path d="M12.917 13C12.441 15.8377 9.973 18 7 18C3.68629 18 1 15.3137 1 12C1 8.68629 3.68629 6 7 6C9.973 6 12.441 8.16229 12.917 11H23V13H21V17H19V13H17V17H15V13H12.917ZM7 16C9.20914 16 11 14.2091 11 12C11 9.79086 9.20914 8 7 8C4.79086 8 3 9.79086 3 12C3 14.2091 4.79086 16 7 16Z" fill="currentColor"/>',"layout-column":'<path d="M11 5H5V19H11V5ZM13 5V19H19V5H13ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3Z" fill="currentColor"/>',"layout-left":'<path d="M21 3C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H21ZM7 5H4V19H7V5ZM20 5H9V19H20V5Z" fill="currentColor"/>',"layout-right":'<path d="M21 3C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H21ZM15 5H4V19H15V5ZM20 5H17V19H20V5Z" fill="currentColor"/>',leaf:'<path d="M20.998 3V5C20.998 14.6274 15.6255 19 8.99805 19L5.24077 18.9999C5.0786 19.912 4.99805 20.907 4.99805 22H2.99805C2.99805 20.6373 3.11376 19.3997 3.34381 18.2682C3.1133 16.9741 2.99805 15.2176 2.99805 13C2.99805 7.47715 7.4752 3 12.998 3C14.998 3 16.998 4 20.998 3ZM12.998 5C8.57977 5 4.99805 8.58172 4.99805 13C4.99805 13.3624 5.00125 13.7111 5.00759 14.0459C6.26198 12.0684 8.09902 10.5048 10.5019 9.13176L11.4942 10.8682C8.6393 12.4996 6.74554 14.3535 5.77329 16.9998L8.99805 17C15.0132 17 18.8692 13.0269 18.9949 5.38766C17.6229 5.52113 16.3481 5.436 14.7754 5.20009C13.6243 5.02742 13.3988 5 12.998 5Z" fill="currentColor"/>',lightbulb:'<path d="M9.97308 18H11V13H13V18H14.0269C14.1589 16.7984 14.7721 15.8065 15.7676 14.7226C15.8797 14.6006 16.5988 13.8564 16.6841 13.7501C17.5318 12.6931 18 11.385 18 10C18 6.68629 15.3137 4 12 4C8.68629 4 6 6.68629 6 10C6 11.3843 6.46774 12.6917 7.31462 13.7484C7.40004 13.855 8.12081 14.6012 8.23154 14.7218C9.22766 15.8064 9.84103 16.7984 9.97308 18ZM10 20V21H14V20H10ZM5.75395 14.9992C4.65645 13.6297 4 11.8915 4 10C4 5.58172 7.58172 2 12 2C16.4183 2 20 5.58172 20 10C20 11.8925 19.3428 13.6315 18.2443 15.0014C17.624 15.7748 16 17 16 18.5V21C16 22.1046 15.1046 23 14 23H10C8.89543 23 8 22.1046 8 21V18.5C8 17 6.37458 15.7736 5.75395 14.9992Z" fill="currentColor"/>',"link-unlink-m":'<path d="M17.657 14.8284L16.2428 13.4142L17.657 12C19.2191 10.4379 19.2191 7.90526 17.657 6.34316C16.0949 4.78106 13.5622 4.78106 12.0001 6.34316L10.5859 7.75737L9.17171 6.34316L10.5859 4.92895C12.9291 2.5858 16.7281 2.5858 19.0712 4.92895C21.4143 7.27209 21.4143 11.0711 19.0712 13.4142L17.657 14.8284ZM14.8286 17.6569L13.4143 19.0711C11.0712 21.4142 7.27221 21.4142 4.92907 19.0711C2.58592 16.7279 2.58592 12.9289 4.92907 10.5858L6.34328 9.17159L7.75749 10.5858L6.34328 12C4.78118 13.5621 4.78118 16.0948 6.34328 17.6569C7.90538 19.219 10.438 19.219 12.0001 17.6569L13.4143 16.2427L14.8286 17.6569ZM14.8286 7.75737L16.2428 9.17159L9.17171 16.2427L7.75749 14.8284L14.8286 7.75737ZM5.77539 2.29291L7.70724 1.77527L8.74252 5.63897L6.81067 6.15661L5.77539 2.29291ZM15.2578 18.3611L17.1896 17.8434L18.2249 21.7071L16.293 22.2248L15.2578 18.3611ZM2.29303 5.77527L6.15673 6.81054L5.63909 8.7424L1.77539 7.70712L2.29303 5.77527ZM18.3612 15.2576L22.2249 16.2929L21.7072 18.2248L17.8435 17.1895L18.3612 15.2576Z" fill="currentColor"/>',"list-check-2":'<path d="M11 4H21V6H11V4ZM11 8H17V10H11V8ZM11 14H21V16H11V14ZM11 18H17V20H11V18ZM3 4H9V10H3V4ZM5 6V8H7V6H5ZM3 14H9V20H3V14ZM5 16V18H7V16H5Z" fill="currentColor"/>',"list-check-3":'<path d="M8.00008 6V9H5.00008V6H8.00008ZM3.00008 4V11H10.0001V4H3.00008ZM13.0001 4H21.0001V6H13.0001V4ZM13.0001 11H21.0001V13H13.0001V11ZM13.0001 18H21.0001V20H13.0001V18ZM10.7072 16.2071L9.29297 14.7929L6.00008 18.0858L4.20718 16.2929L2.79297 17.7071L6.00008 20.9142L10.7072 16.2071Z" fill="currentColor"/>',"list-indefinite":'<path d="M13 4H21V6H13V4ZM13 11H21V13H13V11ZM13 18H21V20H13V18ZM6.5 19C5.39543 19 4.5 18.1046 4.5 17C4.5 15.8954 5.39543 15 6.5 15C7.60457 15 8.5 15.8954 8.5 17C8.5 18.1046 7.60457 19 6.5 19ZM6.5 21C8.70914 21 10.5 19.2091 10.5 17C10.5 14.7909 8.70914 13 6.5 13C4.29086 13 2.5 14.7909 2.5 17C2.5 19.2091 4.29086 21 6.5 21ZM5 6V9H8V6H5ZM3 4H10V11H3V4Z" fill="currentColor"/>',"list-unordered":'<path d="M8 4H21V6H8V4ZM4.5 6.5C3.67157 6.5 3 5.82843 3 5C3 4.17157 3.67157 3.5 4.5 3.5C5.32843 3.5 6 4.17157 6 5C6 5.82843 5.32843 6.5 4.5 6.5ZM4.5 13.5C3.67157 13.5 3 12.8284 3 12C3 11.1716 3.67157 10.5 4.5 10.5C5.32843 10.5 6 11.1716 6 12C6 12.8284 5.32843 13.5 4.5 13.5ZM4.5 20.4C3.67157 20.4 3 19.7284 3 18.9C3 18.0716 3.67157 17.4 4.5 17.4C5.32843 17.4 6 18.0716 6 18.9C6 19.7284 5.32843 20.4 4.5 20.4ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z" fill="currentColor"/>',loader:'<path d="M11.9995 2C12.5518 2 12.9995 2.44772 12.9995 3V6C12.9995 6.55228 12.5518 7 11.9995 7C11.4472 7 10.9995 6.55228 10.9995 6V3C10.9995 2.44772 11.4472 2 11.9995 2ZM11.9995 17C12.5518 17 12.9995 17.4477 12.9995 18V21C12.9995 21.5523 12.5518 22 11.9995 22C11.4472 22 10.9995 21.5523 10.9995 21V18C10.9995 17.4477 11.4472 17 11.9995 17ZM20.6597 7C20.9359 7.47829 20.772 8.08988 20.2937 8.36602L17.6956 9.86602C17.2173 10.1422 16.6057 9.97829 16.3296 9.5C16.0535 9.02171 16.2173 8.41012 16.6956 8.13398L19.2937 6.63397C19.772 6.35783 20.3836 6.52171 20.6597 7ZM7.66935 14.5C7.94549 14.9783 7.78161 15.5899 7.30332 15.866L4.70525 17.366C4.22695 17.6422 3.61536 17.4783 3.33922 17C3.06308 16.5217 3.22695 15.9101 3.70525 15.634L6.30332 14.134C6.78161 13.8578 7.3932 14.0217 7.66935 14.5ZM20.6597 17C20.3836 17.4783 19.772 17.6422 19.2937 17.366L16.6956 15.866C16.2173 15.5899 16.0535 14.9783 16.3296 14.5C16.6057 14.0217 17.2173 13.8578 17.6956 14.134L20.2937 15.634C20.772 15.9101 20.9359 16.5217 20.6597 17ZM7.66935 9.5C7.3932 9.97829 6.78161 10.1422 6.30332 9.86602L3.70525 8.36602C3.22695 8.08988 3.06308 7.47829 3.33922 7C3.61536 6.52171 4.22695 6.35783 4.70525 6.63397L7.30332 8.13398C7.78161 8.41012 7.94549 9.02171 7.66935 9.5Z" fill="currentColor"/>',"loader-4":'<path d="M18.364 5.63604L16.9497 7.05025C15.683 5.7835 13.933 5 12 5C8.13401 5 5 8.13401 5 12C5 15.866 8.13401 19 12 19C15.866 19 19 15.866 19 12H21C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C14.4853 3 16.7353 4.00736 18.364 5.63604Z" fill="currentColor"/>',lock:'<path d="M19 10H20C20.5523 10 21 10.4477 21 11V21C21 21.5523 20.5523 22 20 22H4C3.44772 22 3 21.5523 3 21V11C3 10.4477 3.44772 10 4 10H5V9C5 5.13401 8.13401 2 12 2C15.866 2 19 5.13401 19 9V10ZM5 12V20H19V12H5ZM11 14H13V18H11V14ZM17 10V9C17 6.23858 14.7614 4 12 4C9.23858 4 7 6.23858 7 9V10H17Z" fill="currentColor"/>',"lock-2":'<path d="M6 8V7C6 3.68629 8.68629 1 12 1C15.3137 1 18 3.68629 18 7V8H20C20.5523 8 21 8.44772 21 9V21C21 21.5523 20.5523 22 20 22H4C3.44772 22 3 21.5523 3 21V9C3 8.44772 3.44772 8 4 8H6ZM19 10H5V20H19V10ZM11 15.7324C10.4022 15.3866 10 14.7403 10 14C10 12.8954 10.8954 12 12 12C13.1046 12 14 12.8954 14 14C14 14.7403 13.5978 15.3866 13 15.7324V18H11V15.7324ZM8 8H16V7C16 4.79086 14.2091 3 12 3C9.79086 3 8 4.79086 8 7V8Z" fill="currentColor"/>',"lock-unlock":'<path d="M7 10H20C20.5523 10 21 10.4477 21 11V21C21 21.5523 20.5523 22 20 22H4C3.44772 22 3 21.5523 3 21V11C3 10.4477 3.44772 10 4 10H5V9C5 5.13401 8.13401 2 12 2C14.7405 2 17.1131 3.5748 18.2624 5.86882L16.4731 6.76344C15.6522 5.12486 13.9575 4 12 4C9.23858 4 7 6.23858 7 9V10ZM5 12V20H19V12H5ZM10 15H14V17H10V15Z" fill="currentColor"/>',"loop-right-ai":'<path d="M22 12C22 17.5228 17.5228 22 12 22C8.72774 22 5.82382 20.4286 4 18.001V20.5H2V14.5H8V16.5H5.38477C6.82543 18.6137 9.25151 20 12 20C16.4183 20 20 16.4183 20 12H22ZM11.5293 8.31934C11.7059 7.8935 12.2943 7.89349 12.4707 8.31934L12.7236 8.93066C13.1556 9.97346 13.9615 10.8062 14.9746 11.2568L15.6924 11.5762C16.1026 11.759 16.1026 12.3562 15.6924 12.5391L14.9326 12.877C13.9449 13.3162 13.1534 14.1194 12.7139 15.1279L12.4668 15.6934C12.2864 16.1075 11.7137 16.1075 11.5332 15.6934L11.2871 15.1279C10.8476 14.1193 10.0552 13.3163 9.06738 12.877L8.30762 12.5391C7.89744 12.3562 7.89741 11.759 8.30762 11.5762L9.02539 11.2568C10.0385 10.8062 10.8445 9.97348 11.2764 8.93066L11.5293 8.31934ZM12 2C15.2723 2 18.1762 3.57144 20 5.99902V3.5H22V9.5H16V7.5H18.6152C17.1746 5.38634 14.7485 4 12 4C7.58172 4 4 7.58172 4 12H2C2 6.47715 6.47715 2 12 2Z" fill="currentColor"/>',macbook:'<path d="M4 5V16H20V5H4ZM2 4.00748C2 3.45107 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44892 22 4.00748V18H2V4.00748ZM1 19H23V21H1V19Z" fill="currentColor"/>',"menu-2":'<path d="M3 4H21V6H3V4ZM3 11H15V13H3V11ZM3 18H21V20H3V18Z" fill="currentColor"/>',"menu-fold-2":'<path d="M4.40347 3.90332L2.98926 5.31753L6.17124 8.49951L2.98926 11.6815L4.40347 13.0957L8.99967 8.49951L4.40347 3.90332ZM20.9997 19.9995V17.9995H2.99967V19.9995H20.9997ZM20.9997 12.9995V10.9995H11.9997V12.9995H20.9997ZM20.9997 5.99951V3.99951H11.9997V5.99951H20.9997Z" fill="currentColor"/>',"menu-search":'<path d="M15.5 5C13.567 5 12 6.567 12 8.5C12 10.433 13.567 12 15.5 12C17.433 12 19 10.433 19 8.5C19 6.567 17.433 5 15.5 5ZM10 8.5C10 5.46243 12.4624 3 15.5 3C18.5376 3 21 5.46243 21 8.5C21 9.6575 20.6424 10.7315 20.0317 11.6175L22.7071 14.2929L21.2929 15.7071L18.6175 13.0317C17.7315 13.6424 16.6575 14 15.5 14C12.4624 14 10 11.5376 10 8.5ZM3 4H8V6H3V4ZM3 11H8V13H3V11ZM21 18V20H3V18H21Z" fill="currentColor"/>',mic:'<path d="M11.9998 3C10.3429 3 8.99976 4.34315 8.99976 6V10C8.99976 11.6569 10.3429 13 11.9998 13C13.6566 13 14.9998 11.6569 14.9998 10V6C14.9998 4.34315 13.6566 3 11.9998 3ZM11.9998 1C14.7612 1 16.9998 3.23858 16.9998 6V10C16.9998 12.7614 14.7612 15 11.9998 15C9.23833 15 6.99976 12.7614 6.99976 10V6C6.99976 3.23858 9.23833 1 11.9998 1ZM3.05469 11H5.07065C5.55588 14.3923 8.47329 17 11.9998 17C15.5262 17 18.4436 14.3923 18.9289 11H20.9448C20.4837 15.1716 17.1714 18.4839 12.9998 18.9451V23H10.9998V18.9451C6.82814 18.4839 3.51584 15.1716 3.05469 11Z" fill="currentColor"/>',more:'<path d="M4.5 10.5C3.675 10.5 3 11.175 3 12C3 12.825 3.675 13.5 4.5 13.5C5.325 13.5 6 12.825 6 12C6 11.175 5.325 10.5 4.5 10.5ZM19.5 10.5C18.675 10.5 18 11.175 18 12C18 12.825 18.675 13.5 19.5 13.5C20.325 13.5 21 12.825 21 12C21 11.175 20.325 10.5 19.5 10.5ZM12 10.5C11.175 10.5 10.5 11.175 10.5 12C10.5 12.825 11.175 13.5 12 13.5C12.825 13.5 13.5 12.825 13.5 12C13.5 11.175 12.825 10.5 12 10.5Z" fill="currentColor"/>',"more-2":'<path d="M12 3C11.175 3 10.5 3.675 10.5 4.5C10.5 5.325 11.175 6 12 6C12.825 6 13.5 5.325 13.5 4.5C13.5 3.675 12.825 3 12 3ZM12 18C11.175 18 10.5 18.675 10.5 19.5C10.5 20.325 11.175 21 12 21C12.825 21 13.5 20.325 13.5 19.5C13.5 18.675 12.825 18 12 18ZM12 10.5C11.175 10.5 10.5 11.175 10.5 12C10.5 12.825 11.175 13.5 12 13.5C12.825 13.5 13.5 12.825 13.5 12C13.5 11.175 12.825 10.5 12 10.5Z" fill="currentColor"/>',"more-2-fill":'<path d="M12 3C10.9 3 10 3.9 10 5C10 6.1 10.9 7 12 7C13.1 7 14 6.1 14 5C14 3.9 13.1 3 12 3ZM12 17C10.9 17 10 17.9 10 19C10 20.1 10.9 21 12 21C13.1 21 14 20.1 14 19C14 17.9 13.1 17 12 17ZM12 10C10.9 10 10 10.9 10 12C10 13.1 10.9 14 12 14C13.1 14 14 13.1 14 12C14 10.9 13.1 10 12 10Z" fill="currentColor"/>',"more-fill":'<path d="M5 10C3.9 10 3 10.9 3 12C3 13.1 3.9 14 5 14C6.1 14 7 13.1 7 12C7 10.9 6.1 10 5 10ZM19 10C17.9 10 17 10.9 17 12C17 13.1 17.9 14 19 14C20.1 14 21 13.1 21 12C21 10.9 20.1 10 19 10ZM12 10C10.9 10 10 10.9 10 12C10 13.1 10.9 14 12 14C13.1 14 14 13.1 14 12C14 10.9 13.1 10 12 10Z" fill="currentColor"/>',music:'<path d="M12 13.5351V3H20V5H14V17C14 19.2091 12.2091 21 10 21C7.79086 21 6 19.2091 6 17C6 14.7909 7.79086 13 10 13C10.7286 13 11.4117 13.1948 12 13.5351ZM10 19C11.1046 19 12 18.1046 12 17C12 15.8954 11.1046 15 10 15C8.89543 15 8 15.8954 8 17C8 18.1046 8.89543 19 10 19Z" fill="currentColor"/>',"node-tree":'<path d="M10 2C10.5523 2 11 2.44772 11 3V7C11 7.55228 10.5523 8 10 8H8V10H13V9C13 8.44772 13.4477 8 14 8H20C20.5523 8 21 8.44772 21 9V13C21 13.5523 20.5523 14 20 14H14C13.4477 14 13 13.5523 13 13V12H8V18H13V17C13 16.4477 13.4477 16 14 16H20C20.5523 16 21 16.4477 21 17V21C21 21.5523 20.5523 22 20 22H14C13.4477 22 13 21.5523 13 21V20H7C6.44772 20 6 19.5523 6 19V8H4C3.44772 8 3 7.55228 3 7V3C3 2.44772 3.44772 2 4 2H10ZM19 18H15V20H19V18ZM19 10H15V12H19V10ZM9 4H5V6H9V4Z" fill="currentColor"/>',"notification-3":'<path d="M20 17H22V19H2V17H4V10C4 5.58172 7.58172 2 12 2C16.4183 2 20 5.58172 20 10V17ZM18 17V10C18 6.68629 15.3137 4 12 4C8.68629 4 6 6.68629 6 10V17H18ZM9 21H15V23H9V21Z" fill="currentColor"/>',pichamber:'<polygon points="12 2.5 3.5 7.4 3.5 17.2 12 22.1 20.5 17.2 20.5 7.4" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><polyline points="3.5 7.4 12 12.3 20.5 7.4" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><line x1="12" y1="12.3" x2="12" y2="22.1" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/><path d="m12 5.5 3.7 2.1L12 9.7 8.3 7.6 12 5.5Zm0 1.5-1 .6 1 .6 1-.6-1-.6Z" fill="currentColor" fill-rule="evenodd"/>',palette:'<path d="M12 2C17.5222 2 22 5.97778 22 10.8889C22 13.9556 19.5111 16.4444 16.4444 16.4444H14.4778C13.5556 16.4444 12.8111 17.1889 12.8111 18.1111C12.8111 18.5333 12.9778 18.9222 13.2333 19.2111C13.5 19.5111 13.6667 19.9 13.6667 20.3333C13.6667 21.2556 12.9 22 12 22C6.47778 22 2 17.5222 2 12C2 6.47778 6.47778 2 12 2ZM10.8111 18.1111C10.8111 16.0843 12.451 14.4444 14.4778 14.4444H16.4444C18.4065 14.4444 20 12.851 20 10.8889C20 7.1392 16.4677 4 12 4C7.58235 4 4 7.58235 4 12C4 16.19 7.2226 19.6285 11.324 19.9718C10.9948 19.4168 10.8111 18.7761 10.8111 18.1111ZM7.5 12C6.67157 12 6 11.3284 6 10.5C6 9.67157 6.67157 9 7.5 9C8.32843 9 9 9.67157 9 10.5C9 11.3284 8.32843 12 7.5 12ZM16.5 12C15.6716 12 15 11.3284 15 10.5C15 9.67157 15.6716 9 16.5 9C17.3284 9 18 9.67157 18 10.5C18 11.3284 17.3284 12 16.5 12ZM12 9C11.1716 9 10.5 8.32843 10.5 7.5C10.5 6.67157 11.1716 6 12 6C12.8284 6 13.5 6.67157 13.5 7.5C13.5 8.32843 12.8284 9 12 9Z" fill="currentColor"/>',pause:'<path d="M6 5H8V19H6V5ZM16 5H18V19H16V5Z" fill="currentColor"/>',pencil:'<path d="M15.7279 9.57627L14.3137 8.16206L5 17.4758V18.89H6.41421L15.7279 9.57627ZM17.1421 8.16206L18.5563 6.74785L17.1421 5.33363L15.7279 6.74785L17.1421 8.16206ZM7.24264 20.89H3V16.6473L16.435 3.21231C16.8256 2.82179 17.4587 2.82179 17.8492 3.21231L20.6777 6.04074C21.0682 6.43126 21.0682 7.06443 20.6777 7.45495L7.24264 20.89Z" fill="currentColor"/>',"pencil-ai":'<path d="M16.4356 3.21188C16.8261 2.82185 17.4592 2.82157 17.8496 3.21188L20.6777 6.04099C21.0681 6.43152 21.0682 7.06457 20.6777 7.45505L7.2422 20.8896H3.00001V16.6475L16.4356 3.21188ZM5.00001 17.4756V18.8896H6.41407L15.7276 9.57615L14.3135 8.16208L5.00001 17.4756ZM4.5293 1.3193C4.70583 0.893505 5.29418 0.893508 5.47071 1.3193L5.72364 1.93063C6.15555 2.97342 6.96155 3.80613 7.97462 4.2568L8.69239 4.57614C9.10267 4.75896 9.10262 5.35616 8.69239 5.53903L7.93263 5.87692C6.94497 6.3162 6.15339 7.11943 5.71387 8.1279L5.4668 8.69334C5.28636 9.10747 4.71366 9.10747 4.53321 8.69334L4.28614 8.1279C3.84661 7.11943 3.05506 6.3162 2.06739 5.87692L1.30762 5.53903C0.897483 5.35617 0.897435 4.75896 1.30762 4.57614L2.0254 4.2568C3.03845 3.80614 3.84446 2.97344 4.27637 1.93063L4.5293 1.3193ZM15.7276 6.74802L17.1426 8.16208L18.5567 6.74802L17.1426 5.33395L15.7276 6.74802Z" fill="currentColor"/>',"pencil-ai-2":'<path d="M18.5293 15.3193C18.7058 14.8934 19.2942 14.8934 19.4707 15.3193L19.7236 15.9307C20.1556 16.9735 20.9615 17.8062 21.9746 18.2568L22.6914 18.5762C23.1022 18.7589 23.1022 19.3564 22.6914 19.5391L21.9326 19.877C20.9449 20.3163 20.1534 21.1194 19.7139 22.1279L19.4668 22.6934C19.2863 23.1075 18.7136 23.1075 18.5332 22.6934L18.2861 22.1279C17.8466 21.1194 17.0551 20.3163 16.0674 19.877L15.3076 19.5391C14.8974 19.3562 14.8974 18.759 15.3076 18.5762L16.0254 18.2568C17.0385 17.8062 17.8444 16.9735 18.2764 15.9307L18.5293 15.3193ZM16.4346 3.21193C16.8251 2.82141 17.4591 2.82141 17.8496 3.21193L20.6777 6.04103C21.0681 6.43157 21.0682 7.06464 20.6777 7.45509L7.24219 20.8897H3V16.6475L16.4346 3.21193ZM5 17.4756V18.8897H6.41406L15.7275 9.57618L14.3135 8.16212L5 17.4756ZM15.7275 6.74806L17.1426 8.16212L18.5566 6.74806L17.1426 5.334L15.7275 6.74806Z" fill="currentColor"/>',"pencil-ruler-2":'<path d="M7.05033 14.1213L4.929 16.2427L7.75743 19.0711L19.0711 7.75737L16.2427 4.92894L14.1214 7.05026L15.5356 8.46448L14.1214 9.87869L12.7072 8.46448L11.293 9.87869L12.7072 11.2929L11.293 12.7071L9.87875 11.2929L8.46454 12.7071L9.87875 14.1213L8.46454 15.5355L7.05033 14.1213ZM16.9498 2.80762L21.1925 7.05026C21.583 7.44079 21.583 8.07395 21.1925 8.46448L8.46454 21.1924C8.07401 21.5829 7.44085 21.5829 7.05033 21.1924L2.80768 16.9498C2.41716 16.5592 2.41716 15.9261 2.80768 15.5355L15.5356 2.80762C15.9261 2.4171 16.5593 2.4171 16.9498 2.80762ZM14.1214 18.3635L15.5356 16.9493L17.7781 19.1918H19.1923V17.7776L16.9498 15.5351L18.364 14.1208L20.9997 16.7565V20.9999H16.7578L14.1214 18.3635ZM5.63597 9.87806L2.80754 7.04963C2.41702 6.65911 2.41702 6.02594 2.80754 5.63542L5.63597 2.80699C6.02649 2.41647 6.65966 2.41647 7.05018 2.80699L9.87861 5.63542L8.4644 7.04963L6.34308 4.92831L4.92886 6.34253L7.05018 8.46385L5.63597 9.87806Z" fill="currentColor"/>',"picture-in-picture-2":'<path d="M21 3C21.5523 3 22 3.44772 22 4V11H20V5H4V19H10V21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H21ZM21 13C21.5523 13 22 13.4477 22 14V20C22 20.5523 21.5523 21 21 21H13C12.4477 21 12 20.5523 12 20V14C12 13.4477 12.4477 13 13 13H21ZM20 15H14V19H20V15ZM6.70711 6.29289L8.95689 8.54289L11 6.5V12H5.5L7.54289 9.95689L5.29289 7.70711L6.70711 6.29289Z" fill="currentColor"/>',"pie-chart":'<path d="M9 2.4578V4.58152C6.06817 5.76829 4 8.64262 4 12C4 16.4183 7.58172 20 12 20C15.3574 20 18.2317 17.9318 19.4185 15H21.5422C20.2679 19.0571 16.4776 22 12 22C6.47715 22 2 17.5228 2 12C2 7.52236 4.94289 3.73207 9 2.4578ZM12 2C17.5228 2 22 6.47715 22 12C22 12.3375 21.9833 12.6711 21.9506 13H11V2.04938C11.3289 2.01672 11.6625 2 12 2ZM13 4.06189V11H19.9381C19.4869 7.38128 16.6187 4.51314 13 4.06189Z" fill="currentColor"/>',play:'<path d="M16.3944 12.0001L10 7.7371V16.263L16.3944 12.0001ZM19.376 12.4161L8.77735 19.4818C8.54759 19.635 8.23715 19.5729 8.08397 19.3432C8.02922 19.261 8 19.1645 8 19.0658V4.93433C8 4.65818 8.22386 4.43433 8.5 4.43433C8.59871 4.43433 8.69522 4.46355 8.77735 4.5183L19.376 11.584C19.6057 11.7372 19.6678 12.0477 19.5146 12.2774C19.478 12.3323 19.4309 12.3795 19.376 12.4161Z" fill="currentColor"/>',"play-list-add":'<path d="M2 18H12V20H2V18ZM2 11H22V13H2V11ZM2 4H22V6H2V4ZM18 18V15H20V18H23V20H20V23H18V20H15V18H18Z" fill="currentColor"/>',plug:'<path d="M13 18V20H19V22H13C11.8954 22 11 21.1046 11 20V18H8C5.79086 18 4 16.2091 4 14V7C4 6.44772 4.44772 6 5 6H8V2H10V6H14V2H16V6H19C19.5523 6 20 6.44772 20 7V14C20 16.2091 18.2091 18 16 18H13ZM8 16H16C17.1046 16 18 15.1046 18 14V11H6V14C6 15.1046 6.89543 16 8 16ZM18 8H6V9H18V8ZM12 14.5C11.4477 14.5 11 14.0523 11 13.5C11 12.9477 11.4477 12.5 12 12.5C12.5523 12.5 13 12.9477 13 13.5C13 14.0523 12.5523 14.5 12 14.5Z" fill="currentColor"/>',"plug-2":'<path d="M13 18V20H19V22H13C11.8954 22 11 21.1046 11 20V18H8C5.79086 18 4 16.2091 4 14V7C4 6.44772 4.44772 6 5 6H7V2H9V6H15V2H17V6H19C19.5523 6 20 6.44772 20 7V14C20 16.2091 18.2091 18 16 18H13ZM8 16H16C17.1046 16 18 15.1046 18 14V11H6V14C6 15.1046 6.89543 16 8 16ZM18 8H6V9H18V8ZM12 14.5C11.4477 14.5 11 14.0523 11 13.5C11 12.9477 11.4477 12.5 12 12.5C12.5523 12.5 13 12.9477 13 13.5C13 14.0523 12.5523 14.5 12 14.5ZM11 2H13V5H11V2Z" fill="currentColor"/>',pulse:'<path d="M9 7.53861L15 21.5386L18.6594 13H23V11H17.3406L15 16.4614L9 2.46143L5.3406 11H1V13H6.6594L9 7.53861Z" fill="currentColor"/>',pushpin:'<path d="M13.8273 1.69L22.3126 10.1753L20.8984 11.5895L20.1913 10.8824L15.9486 15.125L15.2415 18.6606L13.8273 20.0748L9.58466 15.8321L4.63492 20.7819L3.2207 19.3677L8.17045 14.4179L3.92781 10.1753L5.34202 8.76107L8.87756 8.05396L13.1202 3.81132L12.4131 3.10422L13.8273 1.69ZM14.5344 5.22554L9.86358 9.89637L7.0417 10.4607L13.5418 16.9609L14.1062 14.139L18.7771 9.46818L14.5344 5.22554Z" fill="currentColor"/>',"pushpin-2":'<path d="M18 3V5H17V11L19 14V16H13V23H11V16H5V14L7 11V5H6V3H18ZM9 5V11.6056L7.4037 14H16.5963L15 11.6056V5H9Z" fill="currentColor"/>',"pushpin-2-fill":'<path d="M18 3V5H17V11L19 14V16H13V23H11V16H5V14L7 11V5H6V3H18Z" fill="currentColor"/>',question:'<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM11 15H13V17H11V15ZM13 13.3551V14H11V12.5C11 11.9477 11.4477 11.5 12 11.5C12.8284 11.5 13.5 10.8284 13.5 10C13.5 9.17157 12.8284 8.5 12 8.5C11.2723 8.5 10.6656 9.01823 10.5288 9.70577L8.56731 9.31346C8.88637 7.70919 10.302 6.5 12 6.5C13.933 6.5 15.5 8.067 15.5 10C15.5 11.5855 14.4457 12.9248 13 13.3551Z" fill="currentColor"/>',"record-circle":'<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM12 15C10.3431 15 9 13.6569 9 12C9 10.3431 10.3431 9 12 9C13.6569 9 15 10.3431 15 12C15 13.6569 13.6569 15 12 15Z" fill="currentColor"/>',refresh:'<path d="M5.46257 4.43262C7.21556 2.91688 9.5007 2 12 2C17.5228 2 22 6.47715 22 12C22 14.1361 21.3302 16.1158 20.1892 17.7406L17 12H20C20 7.58172 16.4183 4 12 4C9.84982 4 7.89777 4.84827 6.46023 6.22842L5.46257 4.43262ZM18.5374 19.5674C16.7844 21.0831 14.4993 22 12 22C6.47715 22 2 17.5228 2 12C2 9.86386 2.66979 7.88416 3.8108 6.25944L7 12H4C4 16.4183 7.58172 20 12 20C14.1502 20 16.1022 19.1517 17.5398 17.7716L18.5374 19.5674Z" fill="currentColor"/>',restart:'<path d="M18.5374 19.5674C16.7844 21.0831 14.4993 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 14.1361 21.3302 16.1158 20.1892 17.7406L17 12H20C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20C14.1502 20 16.1022 19.1517 17.5398 17.7716L18.5374 19.5674Z" fill="currentColor"/>',robot:'<path d="M13 4.05493C17.5 4.55237 21 8.36745 21 13V22H3V13C3 8.36745 6.50005 4.55237 11 4.05493V1H13V4.05493ZM19 20V13C19 9.13401 15.866 6 12 6C8.13401 6 5 9.13401 5 13V20H19ZM12 18C9.23858 18 7 15.7614 7 13C7 10.2386 9.23858 8 12 8C14.7614 8 17 10.2386 17 13C17 15.7614 14.7614 18 12 18ZM12 16C13.6569 16 15 14.6569 15 13C15 11.3431 13.6569 10 12 10C10.3431 10 9 11.3431 9 13C9 14.6569 10.3431 16 12 16ZM12 14C11.4477 14 11 13.5523 11 13C11 12.4477 11.4477 12 12 12C12.5523 12 13 12.4477 13 13C13 13.5523 12.5523 14 12 14Z" fill="currentColor"/>',"robot-2":'<path d="M13.5 2C13.5 2.44425 13.3069 2.84339 13 3.11805V5H18C19.6569 5 21 6.34315 21 8V18C21 19.6569 19.6569 21 18 21H6C4.34315 21 3 19.6569 3 18V8C3 6.34315 4.34315 5 6 5H11V3.11805C10.6931 2.84339 10.5 2.44425 10.5 2C10.5 1.17157 11.1716 0.5 12 0.5C12.8284 0.5 13.5 1.17157 13.5 2ZM6 7C5.44772 7 5 7.44772 5 8V18C5 18.5523 5.44772 19 6 19H18C18.5523 19 19 18.5523 19 18V8C19 7.44772 18.5523 7 18 7H13H11H6ZM2 10H0V16H2V10ZM22 10H24V16H22V10ZM9 14.5C9.82843 14.5 10.5 13.8284 10.5 13C10.5 12.1716 9.82843 11.5 9 11.5C8.17157 11.5 7.5 12.1716 7.5 13C7.5 13.8284 8.17157 14.5 9 14.5ZM15 14.5C15.8284 14.5 16.5 13.8284 16.5 13C16.5 12.1716 15.8284 11.5 15 11.5C14.1716 11.5 13.5 12.1716 13.5 13C13.5 13.8284 14.1716 14.5 15 14.5Z" fill="currentColor"/>',rocket:'<path d="M4.99958 12.9999C4.99958 7.91198 7.90222 3.5636 11.9996 1.81799C16.0969 3.5636 18.9996 7.91198 18.9996 12.9999C18.9996 13.8229 18.9236 14.6264 18.779 15.4027L20.7194 17.2353C20.8845 17.3913 20.9238 17.6389 20.815 17.8383L18.3196 22.4133C18.1873 22.6557 17.8836 22.7451 17.6412 22.6128C17.5993 22.59 17.5608 22.5612 17.5271 22.5274L15.2925 20.2928C15.1049 20.1053 14.8506 19.9999 14.5854 19.9999H9.41379C9.14857 19.9999 8.89422 20.1053 8.70668 20.2928L6.47209 22.5274C6.27683 22.7227 5.96025 22.7227 5.76498 22.5274C5.73122 22.4937 5.70246 22.4552 5.67959 22.4133L3.18412 17.8383C3.07537 17.6389 3.11464 17.3913 3.27975 17.2353L5.22014 15.4027C5.07551 14.6264 4.99958 13.8229 4.99958 12.9999ZM6.47542 19.6957L7.29247 18.8786C7.85508 18.316 8.61814 17.9999 9.41379 17.9999H14.5854C15.381 17.9999 16.1441 18.316 16.7067 18.8786L17.5237 19.6957L18.5056 17.8955L17.4058 16.8568C16.9117 16.3901 16.6884 15.7045 16.8128 15.0364C16.9366 14.3722 16.9996 13.6911 16.9996 12.9999C16.9996 9.13037 15.0045 5.69965 11.9996 4.04033C8.99462 5.69965 6.99958 9.13037 6.99958 12.9999C6.99958 13.6911 7.06255 14.3722 7.18631 15.0364C7.31078 15.7045 7.08746 16.3901 6.59338 16.8568L5.49353 17.8955L6.47542 19.6957ZM11.9996 12.9999C10.895 12.9999 9.99958 12.1045 9.99958 10.9999C9.99958 9.89537 10.895 8.99994 11.9996 8.99994C13.1041 8.99994 13.9996 9.89537 13.9996 10.9999C13.9996 12.1045 13.1041 12.9999 11.9996 12.9999Z" fill="currentColor"/>',route:'<path d="M4 15V8.5C4 6.01472 6.01472 4 8.5 4C10.9853 4 13 6.01472 13 8.5V15.5C13 16.8807 14.1193 18 15.5 18C16.8807 18 18 16.8807 18 15.5V8.82929C16.8348 8.41746 16 7.30622 16 6C16 4.34315 17.3431 3 19 3C20.6569 3 22 4.34315 22 6C22 7.30622 21.1652 8.41746 20 8.82929V15.5C20 17.9853 17.9853 20 15.5 20C13.0147 20 11 17.9853 11 15.5V8.5C11 7.11929 9.88071 6 8.5 6C7.11929 6 6 7.11929 6 8.5V15H9L5 20L1 15H4ZM19 7C19.5523 7 20 6.55228 20 6C20 5.44772 19.5523 5 19 5C18.4477 5 18 5.44772 18 6C18 6.55228 18.4477 7 19 7Z" fill="currentColor"/>',"save-3":'<path d="M18 19H19V6.82843L17.1716 5H16V9H7V5H5V19H6V12H18V19ZM4 3H18L20.7071 5.70711C20.8946 5.89464 21 6.149 21 6.41421V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM8 14V19H16V14H8Z" fill="currentColor"/>',"scales-3":'<path d="M12.9985 2L12.9979 3.278L17.9985 4.94591L21.631 3.73509L22.2634 5.63246L19.2319 6.643L22.3272 15.1549C21.2353 16.2921 19.6996 17 17.9985 17C16.2975 17 14.7618 16.2921 13.6699 15.1549L16.7639 6.643L12.9979 5.387V19H16.9985V21H6.99854V19H10.9979V5.387L7.23192 6.643L10.3272 15.1549C9.23528 16.2921 7.69957 17 5.99854 17C4.2975 17 2.76179 16.2921 1.66992 15.1549L4.76392 6.643L1.73363 5.63246L2.36608 3.73509L5.99854 4.94591L10.9979 3.278L10.9985 2H12.9985ZM17.9985 9.10267L16.04 14.4892C16.628 14.8201 17.2979 15 17.9985 15C18.6992 15 19.3691 14.8201 19.957 14.4892L17.9985 9.10267ZM5.99854 9.10267L4.04004 14.4892C4.62795 14.8201 5.29792 15 5.99854 15C6.69916 15 7.36912 14.8201 7.95703 14.4892L5.99854 9.10267Z" fill="currentColor"/>',"scan-2":'<path d="M5.67127 4.25705L13.4142 12L12 13.4142L8.55382 9.96803C8.20193 10.5635 8 11.2582 8 12C8 14.2091 9.79086 16 12 16C14.2091 16 16 14.2091 16 12C16 9.87494 14.3429 8.13693 12.2503 8.00771L10.4459 6.20323C10.9416 6.07067 11.4625 6 12 6C15.3137 6 18 8.68629 18 12C18 15.3137 15.3137 18 12 18C8.68629 18 6 15.3137 6 12C6 10.7042 6.41079 9.50428 7.10925 8.52347L5.68014 7.09436C4.62708 8.44904 4 10.1513 4 12C4 16.4183 7.58172 20 12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C10.8915 4 9.83557 4.22547 8.8757 4.63306L7.37443 3.13179C8.75768 2.40883 10.3311 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 8.87842 3.43029 6.09091 5.67127 4.25705Z" fill="currentColor"/>',scissors:'<path d="M9.44618 8.02867L12 10.5825L18.7279 3.85457C19.509 3.07352 20.7753 3.07352 21.5563 3.85457L9.44618 15.9647C9.79807 16.5603 10 17.2549 10 17.9967C10 20.2058 8.20914 21.9967 6 21.9967C3.79086 21.9967 2 20.2058 2 17.9967C2 15.7876 3.79086 13.9967 6 13.9967C6.74181 13.9967 7.43645 14.1986 8.03197 14.5505L10.5858 11.9967L8.03197 9.44289C7.43645 9.79478 6.74181 9.9967 6 9.9967C3.79086 9.9967 2 8.20584 2 5.9967C2 3.78756 3.79086 1.9967 6 1.9967C8.20914 1.9967 10 3.78756 10 5.9967C10 6.73851 9.79807 7.43316 9.44618 8.02867ZM14.8255 13.408L21.5563 20.1388C20.7753 20.9199 19.509 20.9199 18.7279 20.1388L13.4113 14.8222L14.8255 13.408ZM7.41421 16.5825C7.05228 16.2206 6.55228 15.9967 6 15.9967C4.89543 15.9967 4 16.8921 4 17.9967C4 19.1013 4.89543 19.9967 6 19.9967C7.10457 19.9967 8 19.1013 8 17.9967C8 17.4444 7.77614 16.9444 7.41421 16.5825ZM7.41421 7.41092C7.77614 7.04899 8 6.54899 8 5.9967C8 4.89213 7.10457 3.9967 6 3.9967C4.89543 3.9967 4 4.89213 4 5.9967C4 7.10127 4.89543 7.9967 6 7.9967C6.55228 7.9967 7.05228 7.77285 7.41421 7.41092Z" fill="currentColor"/>',search:'<path d="M18.031 16.6168L22.3137 20.8995L20.8995 22.3137L16.6168 18.031C15.0769 19.263 13.124 20 11 20C6.032 20 2 15.968 2 11C2 6.032 6.032 2 11 2C15.968 2 20 6.032 20 11C20 13.124 19.263 15.0769 18.031 16.6168ZM16.0247 15.8748C17.2475 14.6146 18 12.8956 18 11C18 7.1325 14.8675 4 11 4C7.1325 4 4 7.1325 4 11C4 14.8675 7.1325 18 11 18C12.8956 18 14.6146 17.2475 15.8748 16.0247L16.0247 15.8748Z" fill="currentColor"/>',"search-eye":'<path d="M18.031 16.6168L22.3137 20.8995L20.8995 22.3137L16.6168 18.031C15.0769 19.263 13.124 20 11 20C6.032 20 2 15.968 2 11C2 6.032 6.032 2 11 2C15.968 2 20 6.032 20 11C20 13.124 19.263 15.0769 18.031 16.6168ZM16.0247 15.8748C17.2475 14.6146 18 12.8956 18 11C18 7.1325 14.8675 4 11 4C7.1325 4 4 7.1325 4 11C4 14.8675 7.1325 18 11 18C12.8956 18 14.6146 17.2475 15.8748 16.0247L16.0247 15.8748ZM12.1779 7.17624C11.4834 7.48982 11 8.18846 11 9C11 10.1046 11.8954 11 13 11C13.8115 11 14.5102 10.5166 14.8238 9.82212C14.9383 10.1945 15 10.59 15 11C15 13.2091 13.2091 15 11 15C8.79086 15 7 13.2091 7 11C7 8.79086 8.79086 7 11 7C11.41 7 11.8055 7.06167 12.1779 7.17624Z" fill="currentColor"/>',"send-plane":'<path d="M21.7267 2.95694L16.2734 22.0432C16.1225 22.5716 15.7979 22.5956 15.5563 22.1126L11 13L1.9229 9.36919C1.41322 9.16532 1.41953 8.86022 1.95695 8.68108L21.0432 2.31901C21.5716 2.14285 21.8747 2.43866 21.7267 2.95694ZM19.0353 5.09647L6.81221 9.17085L12.4488 11.4255L15.4895 17.5068L19.0353 5.09647Z" fill="currentColor"/>',"send-plane-2":'<path d="M3.5 1.34558C3.58425 1.34558 3.66714 1.36687 3.74096 1.40747L22.2034 11.5618C22.4454 11.6949 22.5337 11.9989 22.4006 12.2409C22.3549 12.324 22.2865 12.3924 22.2034 12.4381L3.74096 22.5924C3.499 22.7255 3.19497 22.6372 3.06189 22.3953C3.02129 22.3214 3 22.2386 3 22.1543V1.84558C3 1.56944 3.22386 1.34558 3.5 1.34558ZM5 4.38249V10.9999H10V12.9999H5V19.6174L18.8499 11.9999L5 4.38249Z" fill="currentColor"/>',server:'<path d="M5 11H19V5H5V11ZM21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20C20.5523 3 21 3.44772 21 4ZM19 13H5V19H19V13ZM7 15H10V17H7V15ZM7 7H10V9H7V7Z" fill="currentColor"/>',"settings-3":'<path d="M3.33946 17.0002C2.90721 16.2515 2.58277 15.4702 2.36133 14.6741C3.3338 14.1779 3.99972 13.1668 3.99972 12.0002C3.99972 10.8345 3.3348 9.824 2.36353 9.32741C2.81025 7.71651 3.65857 6.21627 4.86474 4.99001C5.7807 5.58416 6.98935 5.65534 7.99972 5.072C9.01009 4.48866 9.55277 3.40635 9.4962 2.31604C11.1613 1.8846 12.8847 1.90004 14.5031 2.31862C14.4475 3.40806 14.9901 4.48912 15.9997 5.072C17.0101 5.65532 18.2187 5.58416 19.1346 4.99007C19.7133 5.57986 20.2277 6.25151 20.66 7.00021C21.0922 7.7489 21.4167 8.53025 21.6381 9.32628C20.6656 9.82247 19.9997 10.8336 19.9997 12.0002C19.9997 13.166 20.6646 14.1764 21.6359 14.673C21.1892 16.2839 20.3409 17.7841 19.1347 19.0104C18.2187 18.4163 17.0101 18.3451 15.9997 18.9284C14.9893 19.5117 14.4467 20.5941 14.5032 21.6844C12.8382 22.1158 11.1148 22.1004 9.49633 21.6818C9.55191 20.5923 9.00929 19.5113 7.99972 18.9284C6.98938 18.3451 5.78079 18.4162 4.86484 19.0103C4.28617 18.4205 3.77172 17.7489 3.33946 17.0002ZM8.99972 17.1964C10.0911 17.8265 10.8749 18.8227 11.2503 19.9659C11.7486 20.0133 12.2502 20.014 12.7486 19.9675C13.1238 18.8237 13.9078 17.8268 14.9997 17.1964C16.0916 16.5659 17.347 16.3855 18.5252 16.6324C18.8146 16.224 19.0648 15.7892 19.2729 15.334C18.4706 14.4373 17.9997 13.2604 17.9997 12.0002C17.9997 10.74 18.4706 9.5632 19.2729 8.6665C19.1688 8.4405 19.0538 8.21822 18.9279 8.00021C18.802 7.78219 18.667 7.57148 18.5233 7.36842C17.3457 7.61476 16.0911 7.43414 14.9997 6.80405C13.9083 6.17395 13.1246 5.17768 12.7491 4.03455C12.2509 3.98714 11.7492 3.98646 11.2509 4.03292C10.8756 5.17671 10.0916 6.17364 8.99972 6.80405C7.9078 7.43447 6.65245 7.61494 5.47428 7.36803C5.18485 7.77641 4.93463 8.21117 4.72656 8.66637C5.52881 9.56311 5.99972 10.74 5.99972 12.0002C5.99972 13.2604 5.52883 14.4372 4.72656 15.3339C4.83067 15.5599 4.94564 15.7822 5.07152 16.0002C5.19739 16.2182 5.3324 16.4289 5.47612 16.632C6.65377 16.3857 7.90838 16.5663 8.99972 17.1964ZM11.9997 15.0002C10.3429 15.0002 8.99972 13.6571 8.99972 12.0002C8.99972 10.3434 10.3429 9.00021 11.9997 9.00021C13.6566 9.00021 14.9997 10.3434 14.9997 12.0002C14.9997 13.6571 13.6566 15.0002 11.9997 15.0002ZM11.9997 13.0002C12.552 13.0002 12.9997 12.5525 12.9997 12.0002C12.9997 11.4479 12.552 11.0002 11.9997 11.0002C11.4474 11.0002 10.9997 11.4479 10.9997 12.0002C10.9997 12.5525 11.4474 13.0002 11.9997 13.0002Z" fill="currentColor"/>',"share-2":'<path d="M12 2.58582L18.2071 8.79292L16.7929 10.2071L13 6.41424V16H11V6.41424L7.20711 10.2071L5.79289 8.79292L12 2.58582ZM3 18V14H5V18C5 18.5523 5.44772 19 6 19H18C18.5523 19 19 18.5523 19 18V14H21V18C21 19.6569 19.6569 21 18 21H6C4.34315 21 3 19.6569 3 18Z" fill="currentColor"/>',shield:'<path d="M3.78307 2.82598L12 1L20.2169 2.82598C20.6745 2.92766 21 3.33347 21 3.80217V13.7889C21 15.795 19.9974 17.6684 18.3282 18.7812L12 23L5.6718 18.7812C4.00261 17.6684 3 15.795 3 13.7889V3.80217C3 3.33347 3.32553 2.92766 3.78307 2.82598ZM5 4.60434V13.7889C5 15.1263 5.6684 16.3752 6.7812 17.1171L12 20.5963L17.2188 17.1171C18.3316 16.3752 19 15.1263 19 13.7889V4.60434L12 3.04879L5 4.60434Z" fill="currentColor"/>',"shield-check":'<path d="M12 1L20.2169 2.82598C20.6745 2.92766 21 3.33347 21 3.80217V13.7889C21 15.795 19.9974 17.6684 18.3282 18.7812L12 23L5.6718 18.7812C4.00261 17.6684 3 15.795 3 13.7889V3.80217C3 3.33347 3.32553 2.92766 3.78307 2.82598L12 1ZM12 3.04879L5 4.60434V13.7889C5 15.1263 5.6684 16.3752 6.7812 17.1171L12 20.5963L17.2188 17.1171C18.3316 16.3752 19 15.1263 19 13.7889V4.60434L12 3.04879ZM16.4524 8.22183L17.8666 9.63604L11.5026 16L7.25999 11.7574L8.67421 10.3431L11.5019 13.1709L16.4524 8.22183Z" fill="currentColor"/>',"shield-keyhole":'<path d="M12 1L20.2169 2.82598C20.6745 2.92766 21 3.33347 21 3.80217V13.7889C21 15.795 19.9974 17.6684 18.3282 18.7812L12 23L5.6718 18.7812C4.00261 17.6684 3 15.795 3 13.7889V3.80217C3 3.33347 3.32553 2.92766 3.78307 2.82598L12 1ZM12 3.04879L5 4.60434V13.7889C5 15.1263 5.6684 16.3752 6.7812 17.1171L12 20.5963L17.2188 17.1171C18.3316 16.3752 19 15.1263 19 13.7889V4.60434L12 3.04879ZM12 7C13.1046 7 14 7.89543 14 9C14 9.73984 13.5983 10.3858 13.0011 10.7318L13 15H11L10.9999 10.7324C10.4022 10.3866 10 9.74025 10 9C10 7.89543 10.8954 7 12 7Z" fill="currentColor"/>',"shield-user":'<path d="M3.78307 2.82598L12 1L20.2169 2.82598C20.6745 2.92766 21 3.33347 21 3.80217V13.7889C21 15.795 19.9974 17.6684 18.3282 18.7812L12 23L5.6718 18.7812C4.00261 17.6684 3 15.795 3 13.7889V3.80217C3 3.33347 3.32553 2.92766 3.78307 2.82598ZM5 4.60434V13.7889C5 15.1263 5.6684 16.3752 6.7812 17.1171L12 20.5963L17.2188 17.1171C18.3316 16.3752 19 15.1263 19 13.7889V4.60434L12 3.04879L5 4.60434ZM12 11C10.6193 11 9.5 9.88071 9.5 8.5C9.5 7.11929 10.6193 6 12 6C13.3807 6 14.5 7.11929 14.5 8.5C14.5 9.88071 13.3807 11 12 11ZM7.52746 16C7.77619 13.75 9.68372 12 12 12C14.3163 12 16.2238 13.75 16.4725 16H7.52746Z" fill="currentColor"/>',shuffle:'<path d="M18 17.8832V16L23 19L18 22V19.9095C14.9224 19.4698 12.2513 17.4584 11.0029 14.5453L11 14.5386L10.9971 14.5453C9.57893 17.8544 6.32508 20 2.72483 20H2V18H2.72483C5.52503 18 8.05579 16.3312 9.15885 13.7574L9.91203 12L9.15885 10.2426C8.05579 7.66878 5.52503 6 2.72483 6H2V4H2.72483C6.32508 4 9.57893 6.14557 10.9971 9.45473L11 9.46141L11.0029 9.45473C12.2513 6.5416 14.9224 4.53022 18 4.09051V2L23 5L18 8V6.11684C15.7266 6.53763 13.7737 8.0667 12.8412 10.2426L12.088 12L12.8412 13.7574C13.7737 15.9333 15.7266 17.4624 18 17.8832Z" fill="currentColor"/>',"slash-commands-2":'<path d="M5 2C3.34315 2 2 3.34315 2 5V19C2 20.6569 3.34315 22 5 22H19C20.6569 22 22 20.6569 22 19V5C22 3.34315 20.6569 2 19 2H5ZM4 5C4 4.44772 4.44772 4 5 4H19C19.5523 4 20 4.44772 20 5V19C20 19.5523 19.5523 20 19 20H5C4.44772 20 4 19.5523 4 19V5ZM9.72318 18L16.5803 6H14.2768L7.41968 18H9.72318Z" fill="currentColor"/>',smartphone:'<path d="M7 4V20H17V4H7ZM6 2H18C18.5523 2 19 2.44772 19 3V21C19 21.5523 18.5523 22 18 22H6C5.44772 22 5 21.5523 5 21V3C5 2.44772 5.44772 2 6 2ZM12 17C12.5523 17 13 17.4477 13 18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18C11 17.4477 11.4477 17 12 17Z" fill="currentColor"/>',sparkling:'<path d="M14 4.4375C15.3462 4.4375 16.4375 3.34619 16.4375 2H17.5625C17.5625 3.34619 18.6538 4.4375 20 4.4375V5.5625C18.6538 5.5625 17.5625 6.65381 17.5625 8H16.4375C16.4375 6.65381 15.3462 5.5625 14 5.5625V4.4375ZM1 11C4.31371 11 7 8.31371 7 5H9C9 8.31371 11.6863 11 15 11V13C11.6863 13 9 15.6863 9 19H7C7 15.6863 4.31371 13 1 13V11ZM4.87601 12C6.18717 12.7276 7.27243 13.8128 8 15.124 8.72757 13.8128 9.81283 12.7276 11.124 12 9.81283 11.2724 8.72757 10.1872 8 8.87601 7.27243 10.1872 6.18717 11.2724 4.87601 12ZM17.25 14C17.25 15.7949 15.7949 17.25 14 17.25V18.75C15.7949 18.75 17.25 20.2051 17.25 22H18.75C18.75 20.2051 20.2051 18.75 22 18.75V17.25C20.2051 17.25 18.75 15.7949 18.75 14H17.25Z" fill="currentColor"/>',"split-cells-horizontal":'<path d="M20 3C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20ZM11 5H5V19H11V15H13V19H19V5H13V9H11V5ZM15 9L18 12L15 15V13H9V15L6 12L9 9V11H15V9Z" fill="currentColor"/>',stack:'<path d="M20.0833 15.1999L21.2854 15.9212C21.5221 16.0633 21.5989 16.3704 21.4569 16.6072C21.4146 16.6776 21.3557 16.7365 21.2854 16.7787L12.5144 22.0412C12.1977 22.2313 11.8021 22.2313 11.4854 22.0412L2.71451 16.7787C2.47772 16.6366 2.40093 16.3295 2.54301 16.0927C2.58523 16.0223 2.64413 15.9634 2.71451 15.9212L3.9166 15.1999L11.9999 20.0499L20.0833 15.1999ZM20.0833 10.4999L21.2854 11.2212C21.5221 11.3633 21.5989 11.6704 21.4569 11.9072C21.4146 11.9776 21.3557 12.0365 21.2854 12.0787L11.9999 17.6499L2.71451 12.0787C2.47772 11.9366 2.40093 11.6295 2.54301 11.3927C2.58523 11.3223 2.64413 11.2634 2.71451 11.2212L3.9166 10.4999L11.9999 15.3499L20.0833 10.4999ZM12.5144 1.30864L21.2854 6.5712C21.5221 6.71327 21.5989 7.0204 21.4569 7.25719C21.4146 7.32757 21.3557 7.38647 21.2854 7.42869L11.9999 12.9999L2.71451 7.42869C2.47772 7.28662 2.40093 6.97949 2.54301 6.7427C2.58523 6.67232 2.64413 6.61343 2.71451 6.5712L11.4854 1.30864C11.8021 1.11864 12.1977 1.11864 12.5144 1.30864ZM11.9999 3.33233L5.88723 6.99995L11.9999 10.6676L18.1126 6.99995L11.9999 3.33233Z" fill="currentColor"/>',star:'<path d="M12.0006 18.26L4.94715 22.2082L6.52248 14.2799L0.587891 8.7918L8.61493 7.84006L12.0006 0.5L15.3862 7.84006L23.4132 8.7918L17.4787 14.2799L19.054 22.2082L12.0006 18.26ZM12.0006 15.968L16.2473 18.3451L15.2988 13.5717L18.8719 10.2674L14.039 9.69434L12.0006 5.27502L9.96214 9.69434L5.12921 10.2674L8.70231 13.5717L7.75383 18.3451L12.0006 15.968Z" fill="currentColor"/>',"star-fill":'<path d="M12.0006 18.26L4.94715 22.2082L6.52248 14.2799L0.587891 8.7918L8.61493 7.84006L12.0006 0.5L15.3862 7.84006L23.4132 8.7918L17.4787 14.2799L19.054 22.2082L12.0006 18.26Z" fill="currentColor"/>',"sticky-note":'<path d="M21 15L15 20.996L4.00221 21C3.4487 21 3 20.5551 3 20.0066V3.9934C3 3.44476 3.44495 3 3.9934 3H20.0066C20.5552 3 21 3.45576 21 4.00247V15ZM19 5H5V19H13V14C13 13.4872 13.386 13.0645 13.8834 13.0067L14 13L19 12.999V5ZM18.171 14.999L15 15V18.169L18.171 14.999Z" fill="currentColor"/>',stop:'<path d="M7 7V17H17V7H7ZM6 5H18C18.5523 5 19 5.44772 19 6V18C19 18.5523 18.5523 19 18 19H6C5.44772 19 5 18.5523 5 18V6C5 5.44772 5.44772 5 6 5Z" fill="currentColor"/>',subtract:'<path d="M5 11V13H19V11H5Z" fill="currentColor"/>',survey:'<path d="M17 2V4H20.0066C20.5552 4 21 4.44495 21 4.9934V21.0066C21 21.5552 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5551 3 21.0066V4.9934C3 4.44476 3.44495 4 3.9934 4H7V2H17ZM7 6H5V20H19V6H17V8H7V6ZM9 16V18H7V16H9ZM9 13V15H7V13H9ZM9 10V12H7V10H9ZM15 4H9V6H15V4Z" fill="currentColor"/>',target:'<path d="M12 1.99999C12.5523 1.99999 13 2.4477 13 2.99999C12.9999 3.55224 12.5522 3.99999 12 3.99999C7.58172 3.99999 4 7.58171 4 12C4.00004 16.4182 7.58174 20 12 20C16.4182 20 19.9999 16.4182 20 12C20 11.4477 20.4477 11 21 11C21.5523 11 22 11.4477 22 12C21.9999 17.5228 17.5228 22 12 22C6.47717 22 2.00004 17.5228 2 12C2 6.47714 6.47715 1.99999 12 1.99999ZM12 5.99999C12.5523 5.99999 13 6.4477 13 6.99999C12.9999 7.55224 12.5522 7.99999 12 7.99999C9.79085 7.99999 7.99999 9.79085 7.99999 12C8.00004 14.2091 9.79088 16 12 16C14.2091 16 15.9999 14.2091 16 12C16 11.4477 16.4477 11 17 11C17.5523 11 18 11.4477 18 12C17.9999 15.3137 15.3137 18 12 18C8.68631 18 6.00004 15.3137 6 12C6 8.68628 8.68629 5.99999 12 5.99999ZM17.6562 2.10057C18.0468 1.71005 18.6807 1.71005 19.0713 2.10057C19.4614 2.49105 19.4615 3.12419 19.0713 3.51463L18.3633 4.22069L18.3642 4.22167C17.9737 4.61219 17.9737 5.2452 18.3642 5.63573C18.7548 6.02612 19.3878 6.02621 19.7783 5.63573L20.4853 4.9287C20.8759 4.53839 21.5089 4.53826 21.8994 4.9287C22.2899 5.31915 22.2897 5.95222 21.8994 6.34276L19.7783 8.46483C19.5909 8.65223 19.3363 8.75671 19.0713 8.75682H16.6572L12.707 12.707C12.3165 13.0974 11.6834 13.0974 11.293 12.707C10.9025 12.3165 10.9026 11.6835 11.293 11.293L15.2422 7.34374V4.9287C15.2422 4.66356 15.3477 4.40916 15.5351 4.22167L17.6562 2.10057Z" fill="currentColor"/>',"target-fill":'<path d="M12 2C12.5523 2 13 2.44772 13 3C13 3.55228 12.5523 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20C16.4183 20 20 16.4183 20 12C20 11.4477 20.4477 11 21 11C21.5523 11 22 11.4477 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2ZM12 6C12.5523 6 13 6.44772 13 7C13 7.55228 12.5523 8 12 8C9.79086 8 8 9.79086 8 12C8 14.2091 9.79086 16 12 16C14.2091 16 16 14.2091 16 12C16 11.4477 16.4477 11 17 11C17.5523 11 18 11.4477 18 12C18 15.3137 15.3137 18 12 18C8.68629 18 6 15.3137 6 12C6 8.68629 8.68629 6 12 6ZM18.5713 2.10059C18.8474 2.1006 19.0712 2.32449 19.0713 2.60059V4.42969C19.0716 4.70553 19.2954 4.92866 19.5713 4.92871H21.3994C21.6754 4.92871 21.8992 5.15275 21.8994 5.42871V6.34375L20.0107 8.23242C19.6358 8.60719 19.1268 8.81824 18.5967 8.81836H16.5967L12.707 12.707C12.3165 13.0974 11.6835 13.0975 11.293 12.707C10.9027 12.3165 10.9026 11.6834 11.293 11.293L15.1826 7.4043V5.4043C15.1826 4.87411 15.3928 4.36526 15.7676 3.99023L17.6572 2.10059H18.5713Z" fill="currentColor"/>',task:'<path d="M19 4H5V20H19V4ZM3 2.9918C3 2.44405 3.44749 2 3.9985 2H19.9997C20.5519 2 20.9996 2.44772 20.9997 3L21 20.9925C21 21.5489 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918ZM11.2929 13.1213L15.5355 8.87868L16.9497 10.2929L11.2929 15.9497L7.40381 12.0607L8.81802 10.6464L11.2929 13.1213Z" fill="currentColor"/>',terminal:'<path d="M10.9999 12L3.92886 19.0711L2.51465 17.6569L8.1715 12L2.51465 6.34317L3.92886 4.92896L10.9999 12ZM10.9999 19H20.9999V21H10.9999V19Z" fill="currentColor"/>',"terminal-box":'<path d="M3 3H21C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3ZM4 5V19H20V5H4ZM12 15H18V17H12V15ZM8.66685 12L5.83842 9.17157L7.25264 7.75736L11.4953 12L7.25264 16.2426L5.83842 14.8284L8.66685 12Z" fill="currentColor"/>',"terminal-window":'<path d="M20 9V5H4V9H20ZM20 11H4V19H20V11ZM3 3H21C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3ZM5 12H8V17H5V12ZM5 6H7V8H5V6ZM9 6H11V8H9V6Z" fill="currentColor"/>',text:'<path d="M13 6V21H11V6H5V4H19V6H13Z" fill="currentColor"/>',"text-wrap":'<path d="M15 18H16.5C17.8807 18 19 16.8807 19 15.5C19 14.1193 17.8807 13 16.5 13H3V11H16.5C18.9853 11 21 13.0147 21 15.5C21 17.9853 18.9853 20 16.5 20H15V22L11 19L15 16V18ZM3 4H21V6H3V4ZM9 18V20H3V18H9Z" fill="currentColor"/>',time:'<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM13 12H17V14H11V7H13V12Z" fill="currentColor"/>',timer:'<path d="M17.6177 5.9681L19.0711 4.51472L20.4853 5.92893L19.0319 7.38231C20.2635 8.92199 21 10.875 21 13C21 17.9706 16.9706 22 12 22C7.02944 22 3 17.9706 3 13C3 8.02944 7.02944 4 12 4C14.125 4 16.078 4.73647 17.6177 5.9681ZM12 20C15.866 20 19 16.866 19 13C19 9.13401 15.866 6 12 6C8.13401 6 5 9.13401 5 13C5 16.866 8.13401 20 12 20ZM11 8H13V14H11V8ZM8 1H16V3H8V1Z" fill="currentColor"/>',tools:'<path d="M5.32943 3.27158C6.56252 2.8332 7.9923 3.10749 8.97927 4.09446C10.1002 5.21537 10.3019 6.90741 9.5843 8.23385L20.293 18.9437L18.8788 20.3579L8.16982 9.64875C6.84325 10.3669 5.15069 10.1654 4.02952 9.04421C3.04227 8.05696 2.7681 6.62665 3.20701 5.39332L5.44373 7.63C6.02952 8.21578 6.97927 8.21578 7.56505 7.63C8.15084 7.04421 8.15084 6.09446 7.56505 5.50868L5.32943 3.27158ZM15.6968 5.15512L18.8788 3.38736L20.293 4.80157L18.5252 7.98355L16.7574 8.3371L14.6361 10.4584L13.2219 9.04421L15.3432 6.92289L15.6968 5.15512ZM8.97927 13.2868L10.3935 14.7011L5.09018 20.0044C4.69966 20.3949 4.06649 20.3949 3.67597 20.0044C3.31334 19.6417 3.28744 19.0699 3.59826 18.6774L3.67597 18.5902L8.97927 13.2868Z" fill="currentColor"/>',"twitter-xfill":'<path d="M17.6874 3.0625L12.6907 8.77425L8.37045 3.0625H2.11328L9.58961 12.8387L2.50378 20.9375H5.53795L11.0068 14.6886L15.7863 20.9375H21.8885L14.095 10.6342L20.7198 3.0625H17.6874ZM16.6232 19.1225L5.65436 4.78217H7.45745L18.3034 19.1225H16.6232Z" fill="currentColor"/>',unpin:'<path d="M20.9701 17.1716 19.5559 18.5858 16.0214 15.0513 15.9476 15.1251 15.2405 18.6606 13.8263 20.0748 9.58369 15.8322 4.63394 20.7819 3.21973 19.3677 8.16947 14.418 3.92683 10.1753 5.34105 8.7611 8.87658 8.05399 8.95029 7.98028 5.41373 4.44371 6.82794 3.0295 20.9701 17.1716ZM10.3645 9.39449 9.86261 9.8964 7.04072 10.4608 13.5409 16.9609 14.1052 14.139 14.6071 13.6371 10.3645 9.39449ZM18.7761 9.46821 17.4356 10.8087 18.8498 12.2229 20.1903 10.8824 20.8974 11.5895 22.3116 10.1753 13.8263 1.69003 12.4121 3.10425 13.1192 3.81135 11.7787 5.15185 13.1929 6.56607 14.5334 5.22557 18.7761 9.46821Z" fill="currentColor"/>',user:'<path d="M4 22C4 17.5817 7.58172 14 12 14C16.4183 14 20 17.5817 20 22H18C18 18.6863 15.3137 16 12 16C8.68629 16 6 18.6863 6 22H4ZM12 13C8.685 13 6 10.315 6 7C6 3.685 8.685 1 12 1C15.315 1 18 3.685 18 7C18 10.315 15.315 13 12 13ZM12 11C14.21 11 16 9.21 16 7C16 4.79 14.21 3 12 3C9.79 3 8 4.79 8 7C8 9.21 9.79 11 12 11Z" fill="currentColor"/>',"user-3":'<path d="M20 22H18V20C18 18.3431 16.6569 17 15 17H9C7.34315 17 6 18.3431 6 20V22H4V20C4 17.2386 6.23858 15 9 15H15C17.7614 15 20 17.2386 20 20V22ZM12 13C8.68629 13 6 10.3137 6 7C6 3.68629 8.68629 1 12 1C15.3137 1 18 3.68629 18 7C18 10.3137 15.3137 13 12 13ZM12 11C14.2091 11 16 9.20914 16 7C16 4.79086 14.2091 3 12 3C9.79086 3 8 4.79086 8 7C8 9.20914 9.79086 11 12 11Z" fill="currentColor"/>',"volume-up":'<path d="M6.60282 10.0001L10 7.22056V16.7796L6.60282 14.0001H3V10.0001H6.60282ZM2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z" fill="currentColor"/>',window:'<path d="M21 3C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H21ZM20 11H4V19H20V11ZM20 5H4V9H20V5ZM11 6V8H9V6H11ZM7 6V8H5V6H7Z" fill="currentColor"/>'},V6="pichamber-icon-sprite";let nl=!1;function JC(){if(nl||typeof document>"u")return;const e=document.body;if(!e)return;if(document.getElementById(V6)){nl=!0;return}const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.id=V6,n.setAttribute("aria-hidden","true"),n.style.display="none",n.innerHTML=Object.entries(YC).map(([s,o])=>`<symbol id="oc-${s}" viewBox="0 0 24 24">${o}</symbol>`).join(""),e.insertBefore(n,e.firstChild),nl=!0}const z=d.memo(({name:e,className:t,...n})=>(typeof document<"u"&&JC(),i.jsx("svg",{className:B("remixicon",t),viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",...n,children:i.jsx("use",{href:`#oc-${e}`})})));z.displayName="Icon";const y4=ae.memo(function({checked:t,onChange:n,disabled:s=!1,indeterminate:o,ariaLabel:r,className:a,iconClassName:l}){const c="h-[14px] w-[14px] min-h-[14px] min-w-[14px]",u="h-[10px] w-[10px] min-h-[10px] min-w-[10px]",f=t||o;return i.jsx(fy,{checked:t,onCheckedChange:h=>n(!!h),disabled:s,indeterminate:o,"aria-label":r,className:B("group/checkbox relative flex shrink-0 self-center items-center justify-center rounded-[4px] border outline-none",c,"transition-[background-color,border-color,box-shadow] duration-200 ease-out",f?"border-[color:color-mix(in_srgb,var(--primary-base)_65%,var(--interactive-border))] bg-transparent shadow-none hover:bg-[var(--interactive-hover)] hover:border-[color:color-mix(in_srgb,var(--primary-base)_75%,var(--interactive-border))]":"border-[var(--interactive-border)] bg-transparent shadow-none hover:bg-[var(--interactive-hover)] hover:border-[var(--interactive-border)]","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-transparent","disabled:cursor-not-allowed disabled:opacity-50",a),children:i.jsx(hy,{keepMounted:!0,className:B("flex items-center justify-center text-[var(--primary-base)]","data-[unchecked]:hidden",l),children:o?i.jsx(z,{name:"subtract",className:B(u,"text-[var(--primary-base)]")}):i.jsx(z,{name:"check",className:B(u,"text-[var(--primary-base)]")})})})});function Bt({className:e,type:t,...n}){return i.jsx("input",{type:t,"data-slot":"input",className:B("text-foreground file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground bg-[var(--surface-elevated)] appearance-none flex h-9 w-full min-w-0 rounded-lg px-3 py-1 typography-markdown outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:typography-ui-label file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:typography-ui-label","ring-1 ring-inset ring-border/60 transition duration-200 ease-out","hover:[&:not(:focus)]:bg-[var(--surface-subtle)] hover:[&:not(:focus)]:ring-transparent","focus:ring-2 focus:ring-[var(--interactive-focus-ring)] focus-visible:outline-none","aria-invalid:ring-[var(--status-error)] aria-invalid:focus:ring-[var(--status-error)]",e),spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",...n})}const N6=async e=>{const t=await gt(e);t.ok||console.error("Failed to copy to clipboard:",t.error)},hi=e=>e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(hi).join(" ").trim():ae.isValidElement(e)?hi(e.props?.children):"",XC=e=>typeof e=="function"?e():e,P6=(e,t)=>{const n=hi(XC(t?.description));return n.length>0?n:hi(e)},Ue={...as,success:(e,t)=>as.success(e,{...t,action:t?.action||{label:"OK",onClick:()=>{}}}),info:(e,t)=>as.info(e,{...t,action:t?.action||{label:"OK",onClick:()=>{}}}),error:(e,t)=>as.error(e,{...t,action:t?.action||{label:"Copy",onClick:()=>N6(P6(e,t))}}),warning:(e,t)=>as.warning(e,{...t,action:t?.action||{label:"Copy",onClick:()=>N6(P6(e,t))}})};let Ko=0;function QC(e,t){return e&&ae.isValidElement(t)?{render:t}:{children:t}}function On({...e}){return i.jsx(my,{...e})}function eS({asChild:e,children:t,...n}){const s=QC(e,t);return i.jsx(wy,{"data-slot":"dialog-trigger",...n,...s})}function tS({...e}){return i.jsx(by,{...e})}const cf=ae.forwardRef(({className:e,...t},n)=>(ae.useEffect(()=>(Ko+=1,document.documentElement.classList.add("oc-dialog-open"),()=>{Ko=Math.max(0,Ko-1),Ko===0&&document.documentElement.classList.remove("oc-dialog-open")}),[]),i.jsx(xy,{ref:n,"data-slot":"dialog-overlay",className:B("oc-glass-backdrop fixed inset-0 z-50 bg-black/25 dark:bg-black/40","transition-opacity duration-150 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0",e),...t})));cf.displayName="DialogOverlay";function Zn({className:e,children:t,showCloseButton:n=!0,...s}){return i.jsxs(tS,{children:[i.jsx(cf,{className:"rounded-none"}),i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none p-4",children:i.jsxs(py,{"data-slot":"dialog-content","data-state-slot":"dialog",className:B("relative pointer-events-auto bg-background text-foreground flex flex-col w-full max-w-lg max-h-full gap-4 rounded-xl border p-6 shadow-none overflow-y-auto pwa-dialog-content origin-center","transition-all duration-150 ease-out","data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]","data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]","data-[nested-dialog-open]:brightness-[0.55] dark:data-[nested-dialog-open]:brightness-[0.4]",e),...s,children:[t,n&&i.jsxs(gy,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[open]:bg-interactive-active data-[open]:text-foreground absolute top-2 right-2 rounded-lg opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none text-muted-foreground hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[i.jsx(z,{name:"close"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})})]})}function Fn({className:e,...t}){return i.jsx("div",{"data-slot":"dialog-header",className:B("flex flex-col gap-2 text-center sm:text-left",e),...t})}function sZ({className:e,...t}){return i.jsx("div",{"data-slot":"dialog-footer",className:B("flex flex-col-reverse gap-2 bottom-safe-area sm:flex-row sm:justify-end",e),...t})}function $n({className:e,...t}){return i.jsx(yy,{"data-slot":"dialog-title",className:B("typography-markdown leading-none font-semibold text-foreground",e),...t})}function ao({className:e,...t}){return i.jsx(vy,{"data-slot":"dialog-description",className:B("text-muted-foreground typography-ui-label",e),...t})}const nS=600,sS=1600,E6=10,df=ae.createContext(null);class uf extends ae.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback??null:this.props.children}}function oS({delayDuration:e=0,skipDelayDuration:t,delay:n,closeDelay:s,...o}){return i.jsx(My,{delay:n??e,closeDelay:s??t,...o})}function q1({delayDuration:e,open:t,onOpenChange:n,...s}){const[o,r]=ae.useState(!1),a=ae.useRef(null),l=ae.useRef(null),c=ae.useRef(null),u=ae.useRef(!1),f=t!==void 0,h=f?t:o,m=ae.useCallback(()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)},[]),p=ae.useCallback(()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},[]),g=ae.useCallback(v=>{f||r(v)},[f]),y=ae.useMemo(()=>({handlePointerDown:v=>{v.pointerType!=="touch"&&v.pointerType!=="pen"||(m(),p(),c.current={x:v.clientX,y:v.clientY},a.current=window.setTimeout(()=>{f||(u.current=!0,g(!0))},nS))},handlePointerMove:v=>{const x=c.current;if(!x)return;const S=Math.abs(v.clientX-x.x),C=Math.abs(v.clientY-x.y);(S>E6||C>E6)&&(m(),c.current=null)},handlePointerEnd:()=>{m(),c.current=null,u.current&&(p(),l.current=window.setTimeout(()=>{u.current=!1,g(!1)},sS))},handleClickCapture:v=>{u.current&&(u.current=!1,v.preventDefault(),v.stopPropagation())},handleContextMenu:v=>{u.current&&v.preventDefault()}}),[p,m,f,g]);ae.useEffect(()=>()=>{m(),p()},[p,m]);const M=ae.useCallback((v,x)=>{f||r(v),n?.(v,x)},[f,n]),b=i.jsx(df.Provider,{value:y,children:i.jsx(Cy,{open:h,onOpenChange:M,...s})});return e===void 0?b:i.jsx(oS,{delayDuration:e,children:b})}function U1({asChild:e,children:t,onPointerDown:n,onPointerMove:s,onPointerUp:o,onPointerCancel:r,onClickCapture:a,onContextMenu:l,...c}){const u=ae.useContext(df),f=e&&ae.isValidElement(t)?{render:t}:{children:t};return i.jsx(uf,{fallback:t,children:i.jsx(Sy,{"data-slot":"tooltip-trigger",onPointerDown:h=>{n?.(h),u?.handlePointerDown(h)},onPointerMove:h=>{s?.(h),u?.handlePointerMove(h)},onPointerUp:h=>{o?.(h),u?.handlePointerEnd()},onPointerCancel:h=>{r?.(h),u?.handlePointerEnd()},onClickCapture:h=>{u?.handleClickCapture(h),!h.defaultPrevented&&a?.(h)},onContextMenu:h=>{u?.handleContextMenu(h),!h.defaultPrevented&&l?.(h)},...c,...f})})}function G1({className:e,sideOffset:t=0,side:n,align:s,children:o,style:r,...a}){return i.jsx(uf,{children:i.jsx(_y,{children:i.jsx(ky,{sideOffset:t,side:n,align:s,className:"z-50",children:i.jsxs(Ay,{"data-slot":"tooltip-content",className:B("oc-glass-tooltip text-[var(--surface-elevated-foreground)] border border-border/60 transition-all duration-150 ease-out data-[starting-style]:opacity-0 data-[starting-style]:scale-95 data-[ending-style]:opacity-0 data-[ending-style]:scale-95 data-[instant]:transition-none data-[instant]:duration-0 z-50 w-fit origin-[var(--transform-origin)] rounded-xl px-3 py-1.5 typography-meta text-balance overflow-hidden",e),style:{...r},...a,children:[o,i.jsx(Hy,{className:"fill-[var(--surface-elevated)] z-50 size-2"})]})})})})}const T1="local",ff=e=>({id:T1,label:"Local",url:e||Ki()}),Ki=()=>typeof window>"u"?"":window.__PICHAMBER_LOCAL_ORIGIN__||window.location.origin,Ys=e=>e.id===T1?"local":`host:${e.id}`,hf=e=>{const t=typeof window>"u"?"":window.location.href,n=e.find(f=>f.id===T1)?.url||Ki(),s=Ti(),o=L2(n)||n,r=L2(t)||t,a=We(),l=e.find(f=>f.relay&&Ys(f)===a);if(l)return{id:l.id,label:l.label,url:l.url};if(s&&Vo(s,n))return{id:T1,label:"Local",url:o};const c=e.find(f=>s?Vo(s,T0(f)):!1);if(c)return{id:c.id,label:c.label,url:L2(T0(c))||T0(c)};if(t&&Vo(t,n))return{id:T1,label:"Local",url:o};const u=e.find(f=>t?Vo(t,f.url):!1);return u?{id:u.id,label:u.label,url:L2(u.url)||u.url}:t.startsWith("pichamber-ui://")?{id:T1,label:"Local",url:o}:{id:"custom",label:T2(r||"Instance"),url:r}},oZ=Object.freeze(Object.defineProperty({__proto__:null,LOCAL_HOST_ID:T1,buildLocalDesktopHost:ff,getLocalDesktopOrigin:Ki,resolveCurrentDesktopHost:hf,runtimeKeyForDesktopHost:Ys},Symbol.toStringTag,{value:"Module"})),q2=e=>typeof e=="object"&&e!==null,H1=(e,t)=>{const n=e[t];return typeof n=="string"?n:null},X1=(e,t)=>{const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:null},st=(e,t)=>{const n=e[t];return typeof n=="boolean"?n:null},rS=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):[],d0=()=>a3()?(e,t)=>tt(e,t):null,z6=e=>{if(!q2(e))return;const t=st(e,"enabled")??!1,s=H1(e,"store")?.toLowerCase()==="settings"?"settings":"never",o=H1(e,"value");return{enabled:t,store:s,...o?{value:o}:{}}},iS=e=>e==="remote"||e==="dynamic"?e:"local",aS=e=>{if(!q2(e))return null;const t=H1(e,"id");if(!t)return null;const n=st(e,"enabled")??!0,s=iS(H1(e,"type")),o=H1(e,"localHost")||H1(e,"local_host")||void 0,r=X1(e,"localPort")??X1(e,"local_port")??void 0,a=H1(e,"remoteHost")||H1(e,"remote_host")||void 0,l=X1(e,"remotePort")??X1(e,"remote_port")??void 0;return{id:t,enabled:n,type:s,...o?{localHost:o}:{},...typeof r=="number"?{localPort:r}:{},...a?{remoteHost:a}:{},...typeof l=="number"?{remotePort:l}:{}}},lS=e=>{if(!q2(e))return null;const t=H1(e,"id"),n=H1(e,"sshCommand")||H1(e,"ssh_command");if(!t||!n)return null;const s=H1(e,"nickname"),o=e.sshParsed,r=q2(o)?{destination:H1(o,"destination")||"",args:rS(o.args)}:void 0,a=q2(e.remoteOpenchamber)?e.remoteOpenchamber:q2(e.remote_pichamber)?e.remote_pichamber:{},l=q2(e.localForward)?e.localForward:q2(e.local_forward)?e.local_forward:{},c=q2(e.auth)?e.auth:{},f=H1(a,"mode")?.toLowerCase()==="external"?"external":"managed",h=H1(a,"installMethod")||H1(a,"install_method"),m=h==="npm"||h==="download_release"||h==="upload_bundle"?h:"bun",p=H1(l,"bindHost")||H1(l,"bind_host")||"127.0.0.1",g=p==="localhost"||p==="0.0.0.0"?p:"127.0.0.1",M=(Array.isArray(e.portForwards)?e.portForwards:Array.isArray(e.port_forwards)?e.port_forwards:[]).map(C=>aS(C)).filter(C=>!!C),b=X1(a,"preferredPort")??X1(a,"preferred_port"),v=X1(l,"preferredLocalPort")??X1(l,"preferred_local_port"),x=z6(c.sshPassword||c.ssh_password),S=z6(c.pichamberPassword||c.pichamberPassword||c.pichamber_password);return{id:t,...s?{nickname:s}:{},sshCommand:n,...r&&r.destination?{sshParsed:r}:{},connectionTimeoutSec:X1(e,"connectionTimeoutSec")??X1(e,"connection_timeout_sec")??60,remoteOpenchamber:{mode:f,keepRunning:st(a,"keepRunning")??st(a,"keep_running")??!0,...b?{preferredPort:b}:{},installMethod:m,uploadBundleOverSsh:st(a,"uploadBundleOverSsh")??st(a,"upload_bundle_over_ssh")??!1},localForward:{...v?{preferredLocalPort:v}:{},bindHost:g},auth:{...x?{sshPassword:x}:{},...S?{pichamberPassword:S}:{}},portForwards:M}},cS=e=>{switch(e){case"config_resolved":case"auth_check":case"master_connecting":case"remote_probe":case"installing":case"updating":case"server_detecting":case"server_starting":case"forwarding":case"ready":case"degraded":case"error":return e;default:return"idle"}},mf=e=>{if(!q2(e))return null;const t=H1(e,"id");return t?{id:t,phase:cS(H1(e,"phase")),...H1(e,"detail")?{detail:H1(e,"detail")||void 0}:{},...H1(e,"localUrl")||H1(e,"local_url")?{localUrl:H1(e,"localUrl")||H1(e,"local_url")||void 0}:{},...typeof(X1(e,"localPort")??X1(e,"local_port"))=="number"?{localPort:X1(e,"localPort")??X1(e,"local_port")??void 0}:{},...typeof(X1(e,"remotePort")??X1(e,"remote_port"))=="number"?{remotePort:X1(e,"remotePort")??X1(e,"remote_port")??void 0}:{},startedByUs:st(e,"startedByUs")??st(e,"started_by_us")??!1,retryAttempt:X1(e,"retryAttempt")??X1(e,"retry_attempt")??0,requiresUserAction:st(e,"requiresUserAction")??st(e,"requires_user_action")??!1,updatedAtMs:X1(e,"updatedAtMs")??X1(e,"updated_at_ms")??Date.now()}:null},dS=e=>{if(!q2(e))return null;const t=H1(e,"host"),n=H1(e,"source"),s=H1(e,"sshCommand")||H1(e,"ssh_command");return!t||!n||!s?null:{host:t,source:n,sshCommand:s,pattern:st(e,"pattern")??!1}},rZ=(e,t)=>({id:e,sshCommand:t,connectionTimeoutSec:60,remoteOpenchamber:{mode:"managed",keepRunning:!0,installMethod:"bun",uploadBundleOverSsh:!1},localForward:{bindHost:"127.0.0.1"},auth:{},portForwards:[]}),uS=async()=>{const e=d0();if(!e)return{instances:[]};const t=await e("desktop_ssh_instances_get");return q2(t)?{instances:(Array.isArray(t.instances)?t.instances:Array.isArray(t.desktopSshInstances)?t.desktopSshInstances:[]).map(o=>lS(o)).filter(o=>!!o)}:{instances:[]}},iZ=async e=>{const t=d0();t&&await t("desktop_ssh_instances_set",{config:{instances:e.instances}})},aZ=async()=>{const e=d0();if(!e)return[];const t=await e("desktop_ssh_import_hosts");return Array.isArray(t)?t.map(n=>dS(n)).filter(n=>!!n):[]},D6=async e=>{const t=d0();t&&await t("desktop_ssh_connect",{id:e})},fS=async e=>{const t=d0();t&&await t("desktop_ssh_disconnect",{id:e})},D3=async e=>{const t=d0();if(!t)return[];const n=await t("desktop_ssh_status",{...e?{id:e}:{}});return Array.isArray(n)?n.map(s=>mf(s)).filter(s=>!!s):[]},lZ=async(e,t)=>{const n=d0();if(!n)return[];const s=await n("desktop_ssh_logs",{id:e,limit:t});return Array.isArray(s)?s.filter(o=>typeof o=="string"):[]},cZ=async e=>{const t=d0();t&&await t("desktop_ssh_logs_clear",{id:e})},dZ=async e=>{if(!a3())return async()=>{};const n=window.__PICHAMBER_DESKTOP__?.listen;if(typeof n!="function")return async()=>{};const s=await n("pichamber:ssh-instance-status",o=>{const r=mf(o?.payload);r&&e(r)});return async()=>{await s()}},R6=9e4,mi="SSH connection cancelled",O6={},fs=e=>{const t=L2(e);if(!t)return e.trim();try{const n=new URL(t);return n.pathname.endsWith("/")||(n.pathname=`${n.pathname}/`),n.toString()}catch{return t}},sl=async()=>wr()?Ng().catch(()=>""):"",hS=e=>e==="ok"?"bg-status-success":e==="auth"||e==="update-recommended"?"bg-status-warning":e==="incompatible"||e==="wrong-service"||e==="unreachable"?"bg-status-error":e==="checking"?"bg-status-info":"bg-muted-foreground/40",mS=e=>e==="ok"?"text-[var(--status-success)]":e==="auth"||e==="update-recommended"?"text-[var(--status-warning)]":e==="incompatible"||e==="wrong-service"||e==="unreachable"?"text-[var(--status-error)]":"text-muted-foreground",ol=e=>e==="unreachable"||e==="wrong-service"||e==="incompatible",Yo=e=>e==="unreachable"||e==="wrong-service"||e==="incompatible",pS=e=>e==="ok"?"Connected":e==="auth"?"Auth required":e==="checking"?"Checking":e==="update-recommended"?"Update recommended":e==="incompatible"?"Incompatible":e==="wrong-service"?"Wrong service":e==="unreachable"?"Unreachable":"Unknown",gS=e=>new Promise(t=>window.setTimeout(t,e)),Z6=e=>{switch(e){case"ready":return"Ready";case"error":return"Error";case"degraded":return"Reconnecting";case"config_resolved":return"Resolving config";case"auth_check":return"Checking auth";case"master_connecting":return"Connecting SSH";case"remote_probe":return"Probing remote";case"installing":return"Installing";case"updating":return"Updating";case"server_detecting":return"Detecting server";case"server_starting":return"Starting server";case"forwarding":return"Forwarding ports";default:return"Idle"}},yS=e=>!e||e==="idle"?null:e==="ready"?"ok":e==="error"?"unreachable":"auth",F6=async()=>{const e=await D3().catch(()=>[]),t={};for(const n of e)t[n.id]=n;return t},$6=async(e,t,n,s)=>{const o=Date.now()+t;for(;Date.now()<o;){if(s?.())throw new Error(mi);const a=(await D3(e).catch(()=>[])).find(l=>l.id===e);if(a){if(n(a),a.phase==="ready")return a;if(a.phase==="error")throw new Error(a.detail||"SSH connection failed")}await gS(700)}throw s?.()?new Error(mi):new Error("Timed out waiting for SSH connection")};function vS({open:e,onOpenChange:t,embedded:n=!1,onHostSwitched:s}){const o=he(T=>T.setSettingsDialogOpen),r=he(T=>T.setSettingsPage),[a,l]=ae.useState([]),[c,u]=ae.useState(null),[f,h]=ae.useState(()=>({...O6}));ae.useEffect(()=>{Object.assign(O6,f)},[f]);const[m,p]=ae.useState(!1),[g,y]=ae.useState(!1),[M,b]=ae.useState(!1),[v,x]=ae.useState(null),[S,C]=ae.useState({}),[w,_]=ae.useState({}),[L,A]=ae.useState({open:!1,hostId:null,hostLabel:"",phase:"idle",detail:null,error:null}),[N,k]=ae.useState(""),[V,H]=ae.useState(()=>Ki()),[D,P]=ae.useState(null),[R,$]=ae.useState(""),[O,I]=ae.useState(""),[q,G]=ae.useState(0),K=ae.useRef(0),W=ae.useMemo(()=>{const T=ff(V),Q=a.map(se=>({...se,url:L2(se.url)||se.url}));return[T,...Q]},[a,V]);ae.useEffect(()=>Wn(()=>G(T=>T+1)),[]);const ge=ae.useMemo(()=>hf(W),[W,q]),Z=ae.useMemo(()=>{const T=c||T1;return W.find(Q=>Q.id===T)?.label||"Local"},[W,c]),fe=ae.useCallback(async(T,Q)=>{if(S1()){b(!0),k("");try{const se=T.filter(ye=>ye.id!==T1);await Fl({hosts:se,defaultHostId:Q}),l(se),u(Q)}catch(se){k(se instanceof Error?se.message:"Failed to save")}finally{b(!1)}}},[]),ie=ae.useCallback(()=>{r("remote-instances"),o(!0),t(!1)},[t,o,r]),E=ae.useCallback(async()=>{if(S1()){p(!0),k("");try{const[T,Q,se]=await Promise.all([h9(),uS().catch(()=>({instances:[]})),F6()]);T.localOrigin&&H(T.localOrigin);const ye={};for(const le of Q.instances)ye[le.id]=!0;l(T.hosts||[]),u(T.defaultHostId??null),C(ye),_(se)}catch(T){k(T instanceof Error?T.message:"Failed to load"),l([]),u(null),C({}),_({})}finally{p(!1)}}},[]),ce=ae.useCallback(async T=>{if(S1()){y(!0);try{const Q=await sl(),se=await Promise.all(T.map(async le=>{const ne=le.id===T1?Q:le.clientToken||"",Ce=async()=>{const Ve=await dc(le.relay,{clientToken:ne,requestHeaders:le.requestHeaders||null}).catch(()=>({status:"unreachable",latencyMs:0}));return{status:Ve.status,latencyMs:Ve.latencyMs,...Ve.status==="ok"?{via:"relay"}:{}}};if(le.relay&&!le.apiUrl)return[le.id,await Ce()];const Se=L2(wr()?T0(le):le.url);if(!Se)return[le.id,{status:"unreachable",latencyMs:0}];const Ae=await La(Se,{clientToken:ne||null,requestHeaders:le.requestHeaders||null}).catch(()=>({status:"unreachable",latencyMs:0}));if(ol(Ae.status)&&le.relay){const Ve=await Ce();if(Ve.status==="ok")return[le.id,Ve]}return[le.id,{status:Ae.status,latencyMs:Ae.latencyMs}]})),ye={};for(const[le,ne]of se)ye[le]=ne;h(ye)}finally{y(!1)}}},[]);ae.useEffect(()=>{if(!e){P(null),$(""),I(""),x(null),A({open:!1,hostId:null,hostLabel:"",phase:"idle",detail:null,error:null}),k("");return}E()},[e,E]),ae.useEffect(()=>{e&&ce(W)},[e,W,ce]),ae.useEffect(()=>{if(!e||!S1())return;let T=!1;const Q=async()=>{const ye=await F6();T||_(ye)};Q();const se=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||Q()},1500);return()=>{T=!0,window.clearInterval(se)}},[e]);const ee=ae.useCallback(async T=>{const Q=(Se,Ae)=>{Ae&&Pg({relayUrl:Se.relayUrl,serverId:Se.serverId,hostEncPubJwk:Se.hostEncPubJwk},Ae),Hs({apiBaseUrl:typeof window<"u"?window.location.origin:"",clientToken:T.clientToken||null,runtimeKey:Ys(T),relay:Se}),Eg(T.id)},se=T.id===T1?V:L2(T.url)||"",ye=T.id===T1?V:L2(T0(T))||"",le=!!T.relay&&!T.apiUrl&&T.id!==T1;if(!se&&!le)return;if(wr()){if(!ye&&!T.relay)return;x(T.id);const Se=T.id===T1?await sl():T.clientToken||"",Ae=f[T.id];if(Ae?.status==="ok"){Ae.via==="relay"&&T.relay?Q(T.relay):ye?Hs({apiBaseUrl:ye,clientToken:Se||null,requestHeaders:T.requestHeaders||null,runtimeKey:Ys(T)}):T.relay&&Q(T.relay),s?.(),x(null);return}let Ve={status:"unreachable",latencyMs:0},Me=null;if(ye){const qe=await La(ye,{clientToken:Se||null,requestHeaders:T.requestHeaders||null}).catch(()=>({status:"unreachable",latencyMs:0}));Ve={status:qe.status,latencyMs:qe.latencyMs},ol(qe.status)||(Me="direct")}let Ie;if(!Me&&T.relay){const qe=await dc(T.relay,{keepTunnel:!0,clientToken:Se||null,requestHeaders:T.requestHeaders||null}).catch(()=>({status:"unreachable",latencyMs:0}));qe.status==="ok"&&(Ve={status:qe.status,latencyMs:qe.latencyMs,via:"relay"},Me="relay",Ie="tunnel"in qe?qe.tunnel:void 0)}if(h(qe=>({...qe,[T.id]:Ve})),!Me){Ue.error(`Instance \\"${T2(T.label)}\\" is unreachable`),x(null);return}Me==="relay"&&T.relay?Q(T.relay,Ie):Hs({apiBaseUrl:ye,clientToken:Se||null,requestHeaders:T.requestHeaders||null,runtimeKey:Ys(T)}),s?.(),x(null);return}const ne=!!S[T.id];if(T.id!==T1&&ne&&S1()){let Se=w[T.id];const Ae=await D3(T.id).then(Ie=>Ie.find(qe=>qe.id===T.id)||null).catch(()=>null);Ae&&(Se=Ae,_(Ie=>({...Ie,[T.id]:Ae})));const Ve=L2(Se?.localUrl||T.url||"");if(Se?.phase==="ready"&&Ve){const Ie=fs(Ve);s?.(),window.location.assign(Ie);return}x(T.id);const Me=K.current+1;K.current=Me,A({open:!0,hostId:T.id,hostLabel:T2(T.label),phase:"master_connecting",detail:null,error:null});try{if(await D6(T.id),Me!==K.current)return;const Ie=await $6(T.id,R6,de=>{_(Le=>({...Le,[de.id]:de})),A(Le=>({...Le,phase:de.phase,detail:de.detail||null}))},()=>Me!==K.current);if(Me!==K.current)return;const qe=L2(Ie.localUrl||"")||se,n1=fs(qe);s?.(),window.location.assign(n1);return}catch(Ie){if(Me!==K.current)return;const qe=Ie instanceof Error?Ie.message:String(Ie);if(qe===mi)return;A(n1=>({...n1,error:qe})),Ue.error(`SSH instance \\"${T2(T.label)}\\" failed to connect`,{description:qe});return}finally{Me===K.current&&x(null)}}if(T.id!==T1&&S1()){x(T.id);const Se=await La(se,{clientToken:T.clientToken||null,requestHeaders:T.requestHeaders||null}).catch(()=>({status:"unreachable",latencyMs:0}));if(h(Ae=>({...Ae,[T.id]:{status:Se.status,latencyMs:Se.latencyMs}})),ol(Se.status)){Ue.error(`Instance \\"${T2(T.label)}\\" is unreachable`),x(null);return}}const Ce=fs(se);s?.();try{window.location.assign(Ce)}catch{window.location.href=Ce}},[V,s,S,w,f]),ue=ae.useCallback(()=>{P(null),$(""),I("")},[]),J=ae.useCallback(T=>{T.stopPropagation()},[]),Y=ae.useCallback(async()=>{if(!D)return;if(D===T1){ue();return}const T=Bg(O);if(!T){k("Invalid URL (must be http/https)");return}const Q=T.persistedUrl,se=(R||T2(Q)).trim(),ye=a.map(le=>le.id===D?{...le,label:se,url:Q,apiUrl:Q}:le);await fe(ye,c),ue(),T.redeemUrl&&window.location.assign(T.redeemUrl)},[ue,a,c,R,O,D,fe]),oe=ae.useCallback(async T=>{await fe(a,T===T1?T1:T)},[a,fe]),te=ae.useCallback(T=>{const Q=le=>{Ue.error("Failed to open new window",{description:le instanceof Error?le.message:String(le)})};if(T.relay&&T.id!==T1){Tg(T.id).catch(Q);return}const se=T.id===T1?V:T0(T);if(!se)return;const ye=fs(se);Vg(ye,{clientToken:T.clientToken||null,requestHeaders:T.requestHeaders||null}).catch(Q)},[V]),pe=ae.useCallback(async()=>{K.current+=1,x(null),A(Q=>({...Q,open:!1,hostId:null,error:null,detail:null,phase:"idle"}));const T=fs(V);if(wr()){const Q=await sl();Hs({apiBaseUrl:V,clientToken:Q||null,runtimeKey:"local"}),s?.();return}s?.(),window.location.assign(T)},[V,s]),He=ae.useCallback(async()=>{const T=L.hostId||v;K.current+=1,x(null),A({open:!1,hostId:null,hostLabel:"",phase:"idle",detail:null,error:null}),!(!T||T===T1||!S1())&&await fS(T).catch(()=>{})},[L.hostId,v]),je=ae.useCallback(()=>{const T=L.hostId;if(!T)return;const Q=W.find(se=>se.id===T);Q&&ee(Q)},[W,ee,L.hostId]),Pe=ae.useCallback(async T=>{if(S1()){x(T.id);try{await D6(T.id),(await $6(T.id,R6,se=>{_(ye=>({...ye,[se.id]:se}))})).phase==="ready"&&Ue.success(`SSH instance \\"${T2(T.label)}\\" connected`)}catch(Q){const se=Q instanceof Error?Q.message:String(Q);se!==mi&&Ue.error(`SSH instance \\"${T2(T.label)}\\" failed to connect`,{description:se})}finally{x(null)}}},[]);if(!S1())return null;const X=S1(),me=i.jsxs(i.Fragment,{children:[n?i.jsx("div",{className:"flex-shrink-0 border-b border-[var(--interactive-border)] px-3 py-2",children:i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"min-w-0 flex items-baseline gap-1.5 typography-ui-label",children:[i.jsx("span",{className:"font-medium text-foreground",children:"Current"}),i.jsx("span",{className:"max-w-[9rem] truncate text-muted-foreground",children:T2(ge.label)}),i.jsx("span",{className:"text-muted-foreground/50",children:"•"}),i.jsx("span",{className:"font-medium text-foreground",children:"Default"}),i.jsx("span",{className:"max-w-[9rem] truncate text-muted-foreground",children:T2(Z)})]}),i.jsx("button",{type:"button",className:B("inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors","hover:text-foreground hover:bg-interactive-hover","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),onClick:()=>{ce(W)},disabled:!X||m||g,"aria-label":"Refresh instances",children:i.jsx(z,{name:"refresh",className:B("h-4 w-4",g&&"animate-spin")})})]})}):i.jsxs(Fn,{className:"flex-shrink-0",children:[i.jsxs($n,{className:"flex items-center gap-2",children:[i.jsx(z,{name:"server",className:"h-5 w-5"}),"Instance"]}),i.jsx(ao,{children:"Switch between Local and remote PiChamber servers"})]}),!n&&i.jsxs("div",{className:"flex items-center justify-between gap-2 flex-shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[i.jsx("span",{className:"typography-meta text-muted-foreground",children:"Current:"}),i.jsx("span",{className:"typography-ui-label text-foreground truncate",children:T2(ge.label)}),i.jsx("span",{className:"typography-meta text-muted-foreground",children:"Current default:"}),i.jsx("span",{className:"typography-ui-label text-foreground truncate",children:T2(Z)})]}),i.jsx("div",{className:"flex items-center gap-1",children:i.jsxs(a1,{type:"button",size:"sm",variant:"ghost",onClick:()=>{ce(W)},disabled:!X||m||g,children:[i.jsx(z,{name:"refresh",className:B("h-4 w-4",g&&"animate-spin")}),"Refresh"]})})]}),!X&&i.jsx("div",{className:"flex-shrink-0 rounded-lg border border-border/50 bg-muted/20 p-3",children:i.jsx("div",{className:"typography-meta text-muted-foreground",children:"Instance switcher is limited on this page. Use Local to recover."})}),i.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:i.jsx("div",{className:B("space-y-1",n&&"space-y-1.5 px-3 py-1"),children:m?i.jsx("div",{className:"px-2 py-2 text-muted-foreground text-sm",children:"Loading..."}):W.map(T=>{const Q=T.id===T1,se=!!S[T.id],ye=T.id===ge.id,le=(c||T1)===T.id,ne=f[T.id]||null,Ce=w[T.id]||null,Se=se?yS(Ce?.phase):ne?.status??"checking",Ae=D===T.id,Ve=Q?V:L2(T.url)||T.url,Me=T.id===T1?"Local":T2(T.label),Ie=T.relay&&!T.apiUrl?"via PiChamber Relay":T2(Ve);return i.jsxs("div",{className:B("group flex items-center gap-2 px-2.5 py-2 rounded-md overflow-hidden",n&&"rounded-xl bg-[var(--surface-muted)] px-3 py-2.5",n&&ye&&"bg-[var(--interactive-selection)]/25",Ae?"bg-interactive-hover/20":"hover:bg-interactive-hover/30"),children:[i.jsxs("button",{type:"button",className:B("flex items-center gap-2 flex-1 min-w-0 text-left",Ae&&"pointer-events-none opacity-70"),onClick:()=>{ee(T)},disabled:v===T.id,"aria-label":`Switch to ${Me}`,children:[i.jsx("span",{className:B("h-2 w-2 rounded-full flex-shrink-0",hS(Se))}),i.jsxs("div",{className:"flex-1 min-w-0 space-y-0.5",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[i.jsx("span",{className:"typography-ui-label font-medium truncate text-foreground",children:Me}),ye&&i.jsx("span",{className:"typography-micro flex-shrink-0 text-muted-foreground bg-muted px-1 rounded leading-none pb-px border border-border/50",children:"Current"}),se&&i.jsx("span",{className:"typography-micro flex-shrink-0 px-1 rounded leading-none pb-px text-[var(--status-info)] bg-[var(--status-info)]/10",children:"SSH"})]}),i.jsxs("div",{className:B("typography-micro truncate",mS(Se)),children:[se?Z6(Ce?.phase):pS(Se),!se&&Se==="ok"&&typeof ne?.latencyMs=="number"?` · ${Math.max(0,Math.round(ne.latencyMs))}ms ping`:"",!se&&ne?.via==="relay"?" · Relay":""]}),i.jsx("div",{className:"typography-micro text-muted-foreground/70 truncate font-mono",children:Ie})]})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[se&&!Q&&(Ce?.phase==="idle"||!Ce?.phase?i.jsxs(a1,{type:"button",variant:"outline",size:"sm",className:"h-8 px-2.5",disabled:v===T.id,onClick:qe=>{qe.stopPropagation(),Pe(T)},children:[v===T.id?i.jsx(z,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}):i.jsx(z,{name:"plug-2",className:"h-3.5 w-3.5"}),"Connect"]}):i.jsx("div",{className:"h-8 w-8 opacity-0 pointer-events-none","aria-hidden":"true"})),i.jsxs(q1,{children:[i.jsx(U1,{asChild:!0,children:i.jsx("button",{type:"button",className:B("h-8 w-8 rounded-md inline-flex items-center justify-center hover:bg-interactive-hover transition-colors",le?"text-primary hover:text-primary/80":"text-muted-foreground/60 hover:text-primary/80"),onClick:()=>{oe(T.id)},"aria-label":le?"Default instance":"Set as default",disabled:M||!le&&Yo(Se),children:le?i.jsx(z,{name:"star-fill",className:"h-4 w-4"}):i.jsx(z,{name:"star",className:"h-4 w-4"})})}),i.jsx(G1,{sideOffset:6,children:le?"Default":"Set as default"})]}),i.jsxs(q1,{children:[i.jsx(U1,{asChild:!0,children:i.jsx("button",{type:"button",className:B("h-8 w-8 rounded-md inline-flex items-center justify-center hover:bg-interactive-hover transition-colors",Yo(Se)?"text-muted-foreground/30 cursor-not-allowed":"text-muted-foreground/60 hover:text-foreground"),onClick:qe=>{qe.stopPropagation(),te(T)},disabled:Yo(Se),"aria-label":"Open in new window",children:i.jsx(z,{name:"window",className:"h-4 w-4"})})}),i.jsx(G1,{sideOffset:6,children:Yo(Se)?"Instance unreachable":"Open in new window"})]})]})]},T.id)})})}),X&&D&&D!==T1&&i.jsxs("div",{className:"flex-shrink-0 rounded-lg border border-border/50 bg-muted/20 p-3",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:"Edit instance"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(a1,{type:"button",variant:"outline",size:"sm",onClick:ue,disabled:M,children:"Cancel"}),i.jsxs(a1,{type:"button",size:"sm",onClick:()=>{Y()},disabled:M,children:[M?i.jsx(z,{name:"loader-4",className:"h-4 w-4 animate-spin"}):null,"Save"]})]})]}),i.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-2 sm:grid-cols-2",children:[i.jsx(Bt,{value:R,onChange:T=>$(T.target.value),onKeyDown:J,placeholder:"Label",disabled:M}),i.jsx(Bt,{value:O,onChange:T=>I(T.target.value),onKeyDown:J,placeholder:"https://host:port",disabled:M})]})]}),i.jsx("div",{className:"flex-shrink-0 border-t border-[var(--interactive-border)]",children:i.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-2 py-2 text-left text-muted-foreground hover:text-foreground hover:bg-interactive-hover/30 transition-colors",onClick:ie,children:[i.jsx(z,{name:"add",className:"h-4 w-4"}),i.jsx("span",{className:"typography-ui-label",children:"Add instance"})]})}),N&&i.jsx("div",{className:"flex-shrink-0 typography-meta text-status-error",children:N})]}),U=i.jsx(On,{open:L.open,onOpenChange:T=>{if(!T&&v){He();return}A(Q=>({...Q,open:T,...T?{}:{hostId:null,error:null,detail:null,phase:"idle"}}))},children:i.jsxs(Zn,{className:"w-[min(28rem,calc(100vw-2rem))] max-w-none",children:[i.jsxs(Fn,{children:[i.jsxs($n,{className:"flex items-center gap-2",children:[i.jsx(z,{name:"loader-4",className:B("h-4 w-4",!L.error&&"animate-spin")}),`Connecting to ${L.hostLabel||"SSH instance"}`]}),i.jsx(ao,{children:L.error?L.error:L.detail||Z6(L.phase)})]}),L.error?i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(a1,{type:"button",size:"sm",variant:"outline",onClick:()=>{pe()},children:"Switch to Local"}),i.jsx(a1,{type:"button",size:"sm",onClick:je,disabled:!L.hostId,children:"Retry"})]}):null]})});return n?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"w-full max-h-[70vh] flex flex-col overflow-hidden gap-2",children:me}),U]}):i.jsxs(i.Fragment,{children:[i.jsx(On,{open:e,onOpenChange:t,children:i.jsx(Zn,{className:"w-[min(42rem,calc(100vw-2rem))] max-w-none max-h-[70vh] flex flex-col overflow-hidden gap-3",children:me})}),U]})}function q6(){const[e,t]=ae.useState(!1);return S1()?i.jsxs(i.Fragment,{children:[i.jsxs(a1,{type:"button",variant:"ghost",size:"sm","data-oc-host-switcher":!0,className:"w-full justify-center",onClick:()=>t(!0),children:[i.jsx(z,{name:"server",className:"h-4 w-4"}),"Switch instance"]}),i.jsx(vS,{open:e,onOpenChange:t})]}):null}const R3=({className:e="",width:t=70,height:n=70,isAnimated:s=!1})=>{const o=of(),a=ae.useId().replace(/[^a-zA-Z0-9_-]/g,""),l=`pc-shimmer-mask-${a}`,c=`pc-shimmer-grad-${a}`,u=ae.useMemo(()=>{if(o)return o.currentTheme.colors.surface.foreground;if(typeof window<"u"){const f=getComputedStyle(document.documentElement).getPropertyValue("--splash-stroke").trim();return f||(window.matchMedia("(prefers-color-scheme: dark)").matches?"white":"black")}return"white"},[o]);return i.jsxs("svg",{width:t,height:n,viewBox:"0 0 100 100",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,role:"img","aria-label":"PiChamber logo",children:[s?i.jsxs(i.Fragment,{children:[i.jsxs("defs",{children:[i.jsxs("linearGradient",{id:c,gradientUnits:"userSpaceOnUse",x1:"0",y1:"0",x2:"100",y2:"100",children:[i.jsx("stop",{offset:"0%",stopColor:u,stopOpacity:"0"}),i.jsx("stop",{offset:"35%",stopColor:u,stopOpacity:"0"}),i.jsx("stop",{offset:"50%",stopColor:u,stopOpacity:"1"}),i.jsx("stop",{offset:"65%",stopColor:u,stopOpacity:"0"}),i.jsx("stop",{offset:"100%",stopColor:u,stopOpacity:"0"})]}),i.jsx("mask",{id:l,maskUnits:"userSpaceOnUse",maskContentUnits:"userSpaceOnUse",x:"0",y:"0",width:"100",height:"100",children:i.jsxs("g",{fill:"none",children:[i.jsx("path",{d:"M50 3 91 27 50 51 9 27Z",fill:"white",opacity:"0.3"}),i.jsx("path",{d:"M9 27 50 51V97L9 73Z",fill:"white",opacity:"0.55"}),i.jsx("path",{d:"M50 51 91 27V73L50 97Z",fill:"white",opacity:"0.85"}),i.jsx("path",{d:"M50 3 91 27V73L50 97 9 73V27Z",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M28 31H72 M38 31V68 M62 31V55C62 64 67 68 75 68",stroke:"white",strokeWidth:"6",strokeLinecap:"round",strokeLinejoin:"round"})]})})]}),i.jsx("style",{children:"@keyframes pc-shimmer-anim{0%{transform:translate(-110px,-110px)}100%{transform:translate(110px,110px)}}.pc-shimmer-sweep{animation:pc-shimmer-anim 1.8s cubic-bezier(0.4,0,0.2,1) infinite}@media (prefers-reduced-motion:reduce){.pc-shimmer-sweep{animation:none}}"})]}):null,i.jsx("path",{d:"M50 3 91 27 50 51 9 27Z",fill:u,opacity:s?.04:.08}),i.jsx("path",{d:"M9 27 50 51V97L9 73Z",fill:u,opacity:s?.08:.14}),i.jsx("path",{d:"M50 51 91 27V73L50 97Z",fill:u,opacity:s?.13:.22}),i.jsx("path",{d:"M50 3 91 27V73L50 97 9 73V27Z",stroke:u,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",opacity:s?.6:1}),i.jsx("path",{d:"M28 31H72 M38 31V68 M62 31V55C62 64 67 68 75 68",stroke:u,strokeWidth:"6",strokeLinecap:"round",strokeLinejoin:"round",opacity:s?.75:1}),s?i.jsx("g",{mask:`url(#${l})`,children:i.jsx("rect",{x:"-50",y:"-50",width:"200",height:"200",fill:`url(#${c})`,className:"pc-shimmer-sweep"})}):null]})},bS=(e,t)=>e.apiBaseUrl===t.apiBaseUrl&&e.runtimeKey===t.runtimeKey,xS=e=>e.shouldUseDesktopShellPasswordLogin?"locked":"error",wS="/auth/passkey/authenticate/options",MS="/auth/passkey/authenticate/verify",CS="/auth/passkey/register/options",SS="/auth/passkey/register/verify",pf="/api/passkeys",_S="/auth/passkey/status",kS="/api/auth/reset",zr={enabled:!1,hasPasskeys:!1,passkeyCount:0,rpID:null},lo=async(e,t)=>V1(e,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:t===void 0?void 0:JSON.stringify(t)}),O0=async(e,t)=>{try{const n=await e.json();if(n&&typeof n.error=="string"&&n.error.trim())return n.error}catch{}return t},rl=e=>e instanceof cy&&e.code==="ERROR_CEREMONY_ABORTED",U6=()=>{ay.cancelCeremony()},gf=()=>typeof window>"u"?{supported:!1,reason:"Passkeys are unavailable outside the browser."}:window.isSecureContext?{supported:!0,reason:""}:{supported:!1,reason:"Passkeys require HTTPS or localhost."},AS=async()=>{const e=gf();if(!e.supported)throw new Error(e.reason);const t=typeof navigator.userAgent=="string"&&navigator.userAgent.trim()?navigator.userAgent:"This device",n=await lo(CS,{label:t});if(!n.ok)throw new Error(await O0(n,"Could not start passkey setup."));const{requestId:s,optionsJSON:o}=await n.json(),r=await ly({optionsJSON:o}),a=await lo(SS,{requestId:s,response:r});if(!a.ok)throw new Error(await O0(a,"Could not finish passkey setup."));return a.json().catch(()=>null)},HS=async(e,t={})=>{const n=gf();if(!n.supported)throw new Error(n.reason);const s=await lo(wS);if(!s.ok)throw new Error(await O0(s,"Passkey sign-in is not available right now."));const{requestId:o,optionsJSON:r}=await s.json(),a=await dy({optionsJSON:r}),l=await lo(MS,{requestId:o,response:a,trustDevice:e,issueClientToken:t.issueClientToken===!0,clientLabel:t.clientLabel,clientKind:t.clientKind,dedupeKey:t.dedupeKey});if(!l.ok)throw new Error(await O0(l,"Passkey sign-in failed."));return l.json().catch(()=>null)},LS=async()=>{const e=await V1(_S,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!e.ok)return zr;const t=await e.json().catch(()=>null);return{enabled:t?.enabled===!0,hasPasskeys:t?.hasPasskeys===!0,passkeyCount:typeof t?.passkeyCount=="number"?t.passkeyCount:0,rpID:typeof t?.rpID=="string"&&t.rpID?t.rpID:null}},uZ=async()=>{const e=await V1(pf,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!e.ok)throw new Error(await O0(e,"Could not load passkeys."));const t=await e.json().catch(()=>null);return Array.isArray(t?.passkeys)?t.passkeys:[]},fZ=async e=>{const t=await V1(`${pf}/${encodeURIComponent(e)}`,{method:"DELETE",credentials:"include",headers:{Accept:"application/json"}});if(!t.ok)throw new Error(await O0(t,"Could not remove passkey."));return t.json().catch(()=>null)},hZ=async()=>{const e=await lo(kS);if(!e.ok)throw new Error(await O0(e,"Could not clear saved authentication."));return e.json().catch(()=>null)},yf="/auth/session",jS=4,IS=1500,vf="pichamber.uiAuth.trustDevice",BS="desktop-local",TS="desktop-local",VS=()=>{if(typeof window>"u")return"";const e=window.__PICHAMBER_LOCAL_ORIGIN__;return typeof e=="string"?e.trim():""},v4=(e,t)=>{const n=L2(e),s=L2(t);if(!n||!s)return!1;try{return new URL(n).origin===new URL(s).origin}catch{return!1}},Dr=()=>S1(),NS=e=>{const t=e.replace(/^\[|\]$/g,"");return t==="localhost"||t==="127.0.0.1"||t==="::1"},bf=()=>{if(!S1())return!1;const e=VS();if(!e)return!1;const n=Ti()||(typeof window<"u"?window.location.origin:"");if(v4(e,n))return!0;try{const s=L2(n);return!!(s&&NS(new URL(s).hostname))}catch{return!1}},O3=()=>bf()?{clientKind:BS,dedupeKey:TS}:{},PS=async()=>await V1(yf,{method:"GET",credentials:"include",headers:{Accept:"application/json"}}),ES=()=>typeof window>"u"?!1:window.localStorage.getItem(vf)==="true",zS=async(e,t)=>{const n=Dr();return await V1(yf,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({password:e,trustDevice:t,issueClientToken:n,clientLabel:"PiChamber Desktop",...O3()})})},DS=async()=>{if(!S1())return"";const e=await V1("/api/client-auth/clients",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({label:"PiChamber Desktop",...O3()})}).catch(()=>null);if(!e?.ok)return"";const t=await e.json().catch(()=>null);return typeof t?.token=="string"?t.token.trim():""},il=()=>S1()&&!bf(),pn=()=>({apiBaseUrl:Ti(),runtimeKey:We()}),D1=e=>bS(e,pn()),al=async(e,t,n,s)=>{if(!S1()||typeof window>"u")return null;const o=await tt("desktop_remote_password_login",{url:n.apiBaseUrl,password:e,trustDevice:t,requestHeaders:s}).catch(()=>null);if(!o||typeof o!="object")return null;const r=o.token,a=o.status;return{token:typeof r=="string"?r.trim():"",...typeof a=="number"?{status:a}:{}}},RS=async(e,t)=>{if(!S1()||!t||!D1(e))return!1;const n=await h9().catch(()=>null);if(!n||!D1(e))return!1;if(n.localOrigin&&v4(n.localOrigin,e.apiBaseUrl))return await Fl({hosts:n.hosts,defaultHostId:n.defaultHostId,initialHostChoiceCompleted:n.initialHostChoiceCompleted,localClientToken:t}).catch(()=>{}),D1(e);let s=!1;const o=n.hosts.map(r=>!v4(T0(r),e.apiBaseUrl)||r.clientToken===t?r:(s=!0,{...r,clientToken:t}));return s?D1(e)?(await Fl({hosts:o,defaultHostId:n.defaultHostId,initialHostChoiceCompleted:n.initialHostChoiceCompleted}).catch(()=>{}),D1(e)):!1:!0},Jo=async(e,t,n)=>!e||!D1(t)||!await RS(t,e)||!D1(t)?!1:(Hs({apiBaseUrl:t.apiBaseUrl,clientToken:e,requestHeaders:Object.keys(n).length>0?n:null,runtimeKey:t.runtimeKey}),!0),xf=({children:e})=>{const t=d.useMemo(()=>({height:"var(--oc-wco-titlebar-height, 0px)",right:"var(--oc-wco-right-inset, 0px)"}),[]);return i.jsxs("div",{className:"relative flex min-h-screen items-center justify-center overflow-hidden bg-background text-foreground",style:{fontFamily:'"Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", sans-serif'},children:[i.jsx("div",{className:"app-region-drag fixed left-0 top-0 z-20",style:t,"aria-hidden":!0}),i.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-55",style:{background:"radial-gradient(120% 140% at 50% -20%, var(--surface-overlay) 0%, transparent 68%)"}}),i.jsx("div",{className:"pointer-events-none absolute inset-0",style:{backgroundColor:"var(--surface-subtle)",opacity:.22}}),i.jsx("div",{className:"app-region-no-drag relative z-10 flex w-full justify-center px-4 py-12 sm:px-6",children:e})]})},OS=()=>i.jsx("div",{className:"flex h-full min-h-screen w-full items-center justify-center overflow-hidden bg-background text-foreground",children:i.jsx(R3,{width:120,height:120,isAnimated:!0})}),G6=({onRetry:e,errorType:t="network",retryAfter:n,children:s})=>{const o=t==="rate-limit",r=n?Math.ceil(n/60):1;return i.jsx(xf,{children:i.jsxs("div",{className:"flex flex-col items-center gap-6 text-center",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx("h1",{className:"typography-ui-header font-semibold text-destructive",children:o?"Too many attempts":"Unable to reach server"}),i.jsx("p",{className:"typography-meta text-muted-foreground max-w-xs",children:o?r>1?`Please wait ${r} minutes before trying again.`:`Please wait ${r} minute before trying again.`:"We could not verify the UI session. If you're opening PiChamber from another device on your local network, make sure Desktop Network Access is enabled on the desktop app and use the LAN address shown in Settings."})]}),i.jsx(a1,{type:"button",onClick:e,className:"w-full max-w-xs",children:"Retry"}),s]})})},mZ=({children:e})=>{const n=d.useMemo(()=>S1(),[]),[s,o]=d.useState(()=>"pending"),[r,a]=d.useState(""),[l,c]=d.useState(!1),[u,f]=d.useState(""),[h,m]=d.useState(void 0),[p,g]=d.useState(!1),[y,M]=d.useState(zr),[b,v]=d.useState(!1),[x,S]=d.useState(!1),[C,w]=d.useState(()=>ES()),[_,L]=d.useState(null),A=d.useRef(null),N=d.useRef(!1);d.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(vf,C?"true":"false")},[C]);const k=d.useCallback(async(ie=pn())=>{try{const E=await LS();return D1(ie)&&M(E),E}catch{return D1(ie)&&M(zr),zr}},[!1]);d.useEffect(()=>{let ie=!1;return(async()=>{try{if(!window.isSecureContext||!uy()){ie||v(!1);return}ie||v(!0)}catch{ie||v(!1)}})(),()=>{ie=!0}},[!1]);const V=d.useRef(0),H=d.useRef(null),D=d.useRef(null),P=d.useCallback(()=>{H.current!==null&&(window.clearTimeout(H.current),H.current=null)},[]),R=d.useCallback(()=>{V.current=0,P()},[P]),$=d.useCallback(()=>V.current>=jS?!1:(V.current+=1,P(),H.current=window.setTimeout(()=>{H.current=null,D.current?.()},IS*V.current),!0),[P]);d.useEffect(()=>P,[P]);const O=d.useCallback(async()=>{const ie=pn();o(E=>E==="authenticated"?E:"pending");try{const[E,ce]=await Promise.all([PS(),k(ie)]),ee=await E.text();if(!D1(ie))return;if(E.ok){R(),o("authenticated"),g(!1),f(""),m(void 0);return}if(E.status===401){let ue={};try{ue=JSON.parse(ee)}catch{ue={}}R(),g(ue.tunnelLocked===!0),M(ce),o("locked"),m(void 0);return}if(E.status===429){let ue={};try{ue=JSON.parse(ee)}catch{ue={}}R(),m(ue.retryAfter),g(!1),o("rate-limited");return}if($())return;o("error"),g(!1)}catch(E){if(!D1(ie))return;if(console.warn("Failed to check session status:",E),xS({shouldUseDesktopShellPasswordLogin:il()})==="locked"){o("locked"),m(void 0),g(!1);return}if($())return;o("error"),g(!1)}},[k,R,$,!1]);d.useEffect(()=>{D.current=O},[O]),d.useEffect(()=>{O()},[O,!1]),d.useEffect(()=>Wn(()=>{U6(),a(""),f(""),m(void 0),g(!1),c(!1),L(null),S(!1),R(),o("pending"),O()}),[O,R,!1]),d.useEffect(()=>{s==="locked"&&(N.current=!1)},[!1,s]),d.useEffect(()=>{s==="locked"&&A.current&&(A.current.focus(),A.current.select())},[s]),d.useEffect(()=>{s==="authenticated"&&(N.current=!0)},[!1,s]);const I=async ie=>{ie.preventDefault(),await K(!1)},q=d.useCallback(async()=>{const ie=pn();L("register"),S(!0);try{await AS()}finally{D1(ie)&&(L(null),S(!1))}D1(ie)&&await k(ie)},[k]),G=d.useCallback(()=>{U6(),L(null),S(!1)},[]),K=d.useCallback(async ie=>{if(p||!r||l)return;x&&G();const E=pn(),ce=uc();c(!0),f("");try{if(il()){const ue=await al(r,C,E,ce);if(!D1(E))return;if(ue?.token){if(a(""),g(!1),!await Jo(ue.token,E,ce))return;o("authenticated");return}if(ue?.status===401){f("Incorrect password. Try again."),g(!1),o("locked");return}if(ue?.status===429){m(void 0),g(!1),o("rate-limited");return}}const ee=await zS(r,C);if(!D1(E))return;if(ee.ok){const ue=await ee.json().catch(()=>null);if(!D1(E))return;const J=Dr();let Y="";if(J&&(Y=typeof ue?.clientToken=="string"&&ue.clientToken.trim()?ue.clientToken.trim():"",!Y)){const oe=await al(r,C,E,ce);if(!D1(E)||(Y=oe?.token||await DS(),!D1(E)))return}if(a(""),g(!1),Y&&!await Jo(Y,E,ce))return;if(ie&&b)try{if(await q(),!D1(E))return;Ue.success("Passkey added"),o("authenticated");return}catch(oe){if(rl(oe))Ue.message("Passkey setup canceled");else{const te=oe instanceof Error?oe.message:"Passkey setup failed.";Ue.error(te)}o("authenticated");return}o("authenticated");return}if(ee.status===401){f("Incorrect password. Try again."),g(!1),o("locked");return}if(ee.status===429){const ue=await ee.json().catch(()=>({}));m(ue.retryAfter),g(!1),o("rate-limited");return}f("Unexpected response from server."),g(!1),o("error")}catch(ee){if(!D1(E))return;console.warn("Failed to submit UI password:",ee);const ue=il()?await al(r,C,E,ce):null;if(!D1(E))return;if(ue?.token){if(a(""),g(!1),!await Jo(ue.token,E,ce))return;o("authenticated");return}if(ue?.status===401){f("Incorrect password. Try again."),g(!1),o("locked");return}if(ue?.status===429){m(void 0),g(!1),o("rate-limited");return}f("Network error. Check connection and retry."),g(!1),o("error")}finally{D1(E)&&c(!1)}},[G,x,l,p,r,q,b,C]),W=d.useCallback(async()=>{if(l||!b)return;if(x){G();return}S(!0),L("auth"),f("");const ie=pn(),E=uc();try{const ce=await HS(C,{issueClientToken:Dr(),clientLabel:"PiChamber Desktop",...O3()}),ee=Dr()&&typeof ce?.clientToken=="string"&&ce.clientToken.trim()?ce.clientToken.trim():"";if(!D1(ie)||ee&&!await Jo(ee,ie,E))return;a(""),o("authenticated")}catch(ce){if(!D1(ie))return;if(rl(ce))f("");else{const ee=ce instanceof Error?ce.message:"Passkey sign-in was canceled.";f(ee)}}finally{D1(ie)&&(L(null),S(!1))}},[G,x,l,b,C]),ge=d.useCallback(async()=>{if(!(l||p||!b)){if(x){G();return}if(s!=="authenticated"){if(!r){f("Enter your password to add a passkey.");return}await K(!0);return}f("");try{await q(),Ue.success("Passkey added")}catch(ie){if(rl(ie)){Ue.message("Passkey setup canceled");return}const E=ie instanceof Error?ie.message:"Passkey setup failed.";Ue.error(E)}}},[G,K,x,l,p,r,q,s,b]),Z=b&&y.enabled,fe=Z&&y.hasPasskeys;return s==="pending"?i.jsx(OS,{}):s==="error"?i.jsx(G6,{onRetry:()=>{R(),O()},errorType:"network",children:n&&i.jsxs("div",{className:"w-full max-w-xs",children:[i.jsx(q6,{}),i.jsx("p",{className:"mt-1 text-center typography-micro text-muted-foreground",children:"Use Local if remote is unreachable."})]})}):s==="rate-limited"?i.jsx(G6,{onRetry:()=>{O()},errorType:"rate-limit",retryAfter:h}):s==="locked"?i.jsx(xf,{children:i.jsxs("div",{className:"flex flex-col items-center gap-6 w-full max-w-xs",children:[i.jsxs("div",{className:"flex flex-col items-center gap-1 text-center",children:[i.jsx("h1",{className:"text-xl font-semibold text-foreground",children:p?"Tunnel access required":"Unlock PiChamber"}),i.jsx("p",{className:"typography-meta text-muted-foreground",children:p?"Open this tunnel using the one-time connect link from the desktop app.":"This session is password-protected."})]}),!p&&i.jsxs("form",{onSubmit:I,className:"w-full space-y-2",children:[fe&&i.jsxs(a1,{type:"button",variant:"outline",className:"w-full",onClick:()=>{W()},disabled:l||x&&_!=="auth",children:[x?i.jsx(z,{name:"loader-4",className:"h-4 w-4 animate-spin"}):i.jsx(z,{name:"lock-unlock",className:"h-4 w-4"}),i.jsx("span",{children:x&&_==="auth"?"Cancel passkey":"Use passkey"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx(z,{name:"lock",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground/60"}),i.jsx(Bt,{id:"pichamber-ui-password",ref:A,type:"password",autoComplete:"current-password",placeholder:"Enter password",value:r,onChange:ie=>{a(ie.target.value),u&&f("")},className:"pl-10","aria-invalid":!!u||void 0,"aria-describedby":u?"oc-ui-auth-error":void 0,disabled:l})]}),i.jsx(a1,{type:"submit",size:"icon",disabled:!r||l,"aria-label":l?"Unlocking":"Unlock",children:l?i.jsx(z,{name:"loader-4",className:"h-4 w-4 animate-spin"}):i.jsx(z,{name:"lock-unlock",className:"h-4 w-4"})})]}),Z?i.jsxs("div",{className:"flex items-center justify-between pt-1",children:[i.jsxs("label",{className:"flex items-center gap-2 text-center typography-micro text-muted-foreground",children:[i.jsx(y4,{checked:C,onChange:w,disabled:l,ariaLabel:"Trust this device",className:"size-4",iconClassName:"size-4"}),i.jsx("span",{children:"Trust this device"})]}),i.jsx(a1,{type:"button",variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground",onClick:()=>{ge()},disabled:l,children:x&&_==="register"?"Cancel passkey setup":"Add passkey"})]}):i.jsxs("label",{className:"flex items-center justify-center gap-2 pt-1 text-center typography-micro text-muted-foreground",children:[i.jsx(y4,{checked:C,onChange:w,disabled:l,ariaLabel:"Trust this device",className:"size-4",iconClassName:"size-4"}),i.jsx("span",{children:"Trust this device"})]}),u&&i.jsx("p",{id:"oc-ui-auth-error",className:"typography-meta text-destructive",children:u})]}),n&&i.jsxs("div",{className:"w-full",children:[i.jsx(q6,{}),i.jsx("p",{className:"mt-1 text-center typography-micro text-muted-foreground",children:"Use Local if remote is unreachable."})]})]})}):i.jsx(i.Fragment,{children:e})},ZS=1e3,W6=.5,K6={length:0,offset:0},Y6=(e,t)=>Math.abs(e.length-t.length)<W6&&Math.abs(e.offset-t.offset)<W6,wf=({containerRef:e,minThumbSize:t=32,hideDelayMs:n=1e3,className:s,disableHorizontal:o=!1,observeMutations:r=!0,suppressVisibility:a=!1,userIntentOnly:l=!1})=>{const[c,u]=d.useState(!1),[f,h]=d.useState({length:0,offset:0}),[m,p]=d.useState({length:0,offset:0}),g=d.useRef(null),y=d.useRef(null),M=d.useRef(null),b=d.useRef(!1),v=d.useRef(!1),x=d.useRef(0),S=d.useRef({pointerX:0,pointerY:0,scrollTop:0,scrollLeft:0}),C=d.useRef(null),w=d.useRef(new Set),_=d.useCallback(()=>{const G=e.current;if(!G)return;const{scrollHeight:K,clientHeight:W,scrollTop:ge,scrollWidth:Z,clientWidth:fe,scrollLeft:ie}=G,E=8;let ce=K6;if(K>W){const ue=Math.max(W-E*2,0),J=W/K*ue,Y=Math.max(t,Math.min(ue,J)),oe=Math.max(ue-Y,0),te=Math.max(K-W,1),pe=ge/te*oe;ce={length:Y,offset:pe}}h(ue=>Y6(ue,ce)?ue:ce);let ee=K6;if(!o&&Z>fe){const ue=Math.max(fe-E*2,0),J=fe/Z*ue,Y=Math.max(t,Math.min(ue,J)),oe=Math.max(ue-Y,0),te=Math.max(Z-fe,1),pe=ie/te*oe;ee={length:Y,offset:pe}}p(ue=>Y6(ue,ee)?ue:ee)},[e,t,o]),L=d.useCallback(()=>{M.current===null&&(M.current=requestAnimationFrame(()=>{M.current=null,_()}))},[_]),A=d.useCallback((G,K)=>{if(!K){w.current.clear();return}const W=new Set;W.add(G),Array.from(G.children).forEach(ge=>{W.add(ge)}),w.current.forEach(ge=>{W.has(ge)||K.unobserve(ge)}),W.forEach(ge=>{w.current.has(ge)||K.observe(ge)}),w.current=W},[]),N=d.useCallback(()=>{g.current&&clearTimeout(g.current),!v.current&&(g.current=setTimeout(()=>u(!1),n))},[n]),k=d.useCallback(()=>{x.current=Date.now()},[]),V=d.useCallback(()=>{y.current&&cancelAnimationFrame(y.current),y.current=requestAnimationFrame(()=>{if(_(),a&&!b.current){u(!1);return}if(l&&!b.current&&!(Date.now()-x.current<=ZS)){u(!1);return}u(!0),N()})},[N,a,_,l]);d.useEffect(()=>{const G=e.current;if(!G)return;_(),u(!1);const K=()=>V(),W=E=>{(E.key==="ArrowUp"||E.key==="ArrowDown"||E.key==="PageUp"||E.key==="PageDown"||E.key==="Home"||E.key==="End"||E.key===" ")&&k()};G.addEventListener("scroll",K,{passive:!0}),l&&(G.addEventListener("wheel",k,{passive:!0}),G.addEventListener("touchstart",k,{passive:!0}),G.addEventListener("touchmove",k,{passive:!0}),G.addEventListener("keydown",W));const ge=typeof ResizeObserver<"u"?new ResizeObserver(()=>{L()}):null;A(G,ge);const Z=r&&typeof MutationObserver<"u"?new MutationObserver(()=>{A(G,ge),L()}):null;Z?.observe(G,{childList:!0});const fe=()=>L(),ie=()=>L();return G.addEventListener("input",fe,!0),G.addEventListener("load",ie,!0),()=>{G.removeEventListener("scroll",K),G.removeEventListener("input",fe,!0),G.removeEventListener("load",ie,!0),l&&(G.removeEventListener("wheel",k),G.removeEventListener("touchstart",k),G.removeEventListener("touchmove",k),G.removeEventListener("keydown",W)),ge?.disconnect(),Z?.disconnect(),w.current.clear(),g.current&&clearTimeout(g.current),y.current&&cancelAnimationFrame(y.current),M.current&&cancelAnimationFrame(M.current)}},[e,V,k,r,L,A,_,l]),d.useEffect(()=>{a&&(b.current||(u(!1),g.current&&(clearTimeout(g.current),g.current=null)))},[a]);const H=(G,K)=>{const W=e.current;W&&(b.current=!0,S.current={pointerX:G.clientX,pointerY:G.clientY,scrollTop:W.scrollTop,scrollLeft:W.scrollLeft},C.current=K,k(),u(!0),g.current&&clearTimeout(g.current),G.currentTarget.setPointerCapture(G.pointerId))},D=G=>{if(!b.current)return;const K=e.current;if(!K)return;const W=C.current;if(W==="vertical"){const{pointerY:ge,scrollTop:Z}=S.current,fe=G.clientY-ge,ie=K.clientHeight,E=Math.max(ie-f.length,1),ce=Math.max(K.scrollHeight-K.clientHeight,1),ee=fe/E*ce;K.scrollTop=Z+ee}else if(W==="horizontal"){const{pointerX:ge,scrollLeft:Z}=S.current,fe=G.clientX-ge,ie=K.clientWidth,E=Math.max(ie-m.length,1),ce=Math.max(K.scrollWidth-K.clientWidth,1),ee=fe/E*ce;K.scrollLeft=Z+ee}},P=G=>{b.current&&(b.current=!1,G.currentTarget.releasePointerCapture(G.pointerId),N())},R=d.useCallback(()=>{v.current=!0,g.current&&(clearTimeout(g.current),g.current=null)},[]),$=d.useCallback(()=>{v.current=!1,N()},[N]),O=f.length>0,I=m.length>0;if(!O&&!I)return null;const q=8;return i.jsxs("div",{className:B("overlay-scrollbar",s),"aria-hidden":"true",style:{opacity:c?1:0},children:[O&&i.jsx("div",{className:"overlay-scrollbar__thumb overlay-scrollbar__thumb--vertical","data-overlay-scrollbar-thumb":"vertical",style:{height:`${f.length}px`,top:`${q+f.offset}px`,right:`${q/2}px`},onPointerDown:G=>H(G,"vertical"),onPointerMove:D,onPointerUp:P,onPointerCancel:P,onMouseEnter:R,onMouseLeave:$}),I&&i.jsx("div",{className:"overlay-scrollbar__thumb overlay-scrollbar__thumb--horizontal","data-overlay-scrollbar-thumb":"horizontal",style:{width:`${m.length}px`,left:`${q+m.offset}px`,bottom:`${q/2}px`},onPointerDown:G=>H(G,"horizontal"),onPointerMove:D,onPointerUp:P,onPointerCancel:P,onMouseEnter:R,onMouseLeave:$})]})};wf.displayName="OverlayScrollbar";const Mf=wf;function FS(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n&&typeof n=="object"&&(n.current=t)})}}const Yi=d.forwardRef(({as:e="div",orientation:t="vertical",offset:n=0,size:s=48,isEnabled:o=!0,hideTopShadow:r=!1,hideBottomShadow:a=!1,observeMutations:l=!0,onVisibilityChange:c,style:u,className:f,children:h,...m},p)=>{const g=d.useRef(null),y=d.useRef("none"),M=m["data-scroll-shadow"];delete m["data-scroll-shadow"];const b=d.useMemo(()=>{const C={...u};return C["--scroll-shadow-size"]=`${s}px`,C},[s,u]),v=d.useCallback((C,w,_,L,A)=>{const N=`${L}${A.charAt(0).toUpperCase()}${A.slice(1)}Scroll`;w&&_?(C.dataset[N]="true",C.removeAttribute(`data-${L}-scroll`),C.removeAttribute(`data-${A}-scroll`)):(C.dataset[`${L}Scroll`]=String(w),C.dataset[`${A}Scroll`]=String(_),C.removeAttribute(`data-${L}-${A}-scroll`))},[]),x=d.useCallback(C=>{["top","bottom","top-bottom","left","right","left-right"].forEach(w=>{C.removeAttribute(`data-${w}-scroll`)})},[]),S=d.useCallback(()=>{const C=g.current;if(!C)return;if(!o){x(C);return}const w=1,_=t==="vertical"?C.scrollTop>n+w:C.scrollLeft>n+w;let L=t==="vertical"?C.scrollHeight-(C.scrollTop+C.clientHeight)>n+w:C.scrollWidth-(C.scrollLeft+C.clientWidth)>n+w;const A=r&&t==="vertical"?!1:_;a&&t==="vertical"&&(L=!1),v(C,A,L,t==="vertical"?"top":"left",t==="vertical"?"bottom":"right");const N=A&&L?"both":A?t==="vertical"?"top":"left":L?t==="vertical"?"bottom":"right":"none";N!==y.current&&(y.current=N,c?.(N))},[x,r,a,o,n,c,t,v]);return d.useEffect(()=>{const C=g.current;if(!C)return;let w=null;const _=()=>{w===null&&(w=requestAnimationFrame(()=>{w=null,S()}))},L=()=>S(),A=typeof ResizeObserver<"u"?new ResizeObserver(_):null,N=l&&typeof MutationObserver<"u"?new MutationObserver(_):null;return S(),C.addEventListener("scroll",L,{passive:!0}),A?.observe(C),N?.observe(C,{childList:!0,subtree:!0,characterData:!0}),()=>{w!==null&&cancelAnimationFrame(w),C.removeEventListener("scroll",L),A?.disconnect(),N?.disconnect()}},[S,l]),i.jsx(e,{...m,ref:FS(g,p),className:f,"data-orientation":t,"data-scroll-shadow":M??!0,style:b,children:h})});Yi.displayName="ScrollShadow";const vt=d.forwardRef(({className:e,outerClassName:t,children:n,style:s,minThumbSize:o,hideDelayMs:r,as:a="div",scrollbarClassName:l,disableHorizontal:c=!1,observeMutations:u=!0,fillContainer:f=!0,preventOverscroll:h=!1,useScrollShadow:m=!1,scrollShadowSize:p,hideTopScrollShadow:g=!1,userIntentOnly:y=!1,...M},b)=>{const v=d.useRef(null);return d.useImperativeHandle(b,()=>v.current,[]),i.jsxs("div",{className:B("relative flex flex-col min-h-0 w-full overflow-hidden",h&&"overscroll-none",t),children:[m?i.jsx(Yi,{as:a,ref:v,size:p,hideTopShadow:g,className:B("overlay-scrollbar-target overlay-scrollbar-container",h&&"overscroll-none",f?"flex-1 min-h-0 w-full":"flex-none w-full h-auto",c?"overflow-y-auto overflow-x-hidden":"overflow-auto",e),style:s,observeMutations:u,...M,children:n}):i.jsx(a,{ref:v,className:B("overlay-scrollbar-target overlay-scrollbar-container",h&&"overscroll-none",f?"flex-1 min-h-0 w-full":"flex-none w-full h-auto",c?"overflow-y-auto overflow-x-hidden":"overflow-auto",e),style:s,...M,children:n}),i.jsx(Mf,{containerRef:v,minThumbSize:o,hideDelayMs:r,className:l,disableHorizontal:c,observeMutations:u,userIntentOnly:y})]})});vt.displayName="ScrollableOverlay";const J6="pichamber:chunk-import-reload",$S=250,qS=3e4,US=[/Importing a module script failed/i,/Failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/Loading chunk \S+ failed/i,/ChunkLoadError/i];function Cf(e){if(e instanceof Error)return`${e.name}
368
+ }`,document.documentElement.classList.remove("dark"),document.documentElement.classList.add("light")),s.textContent=o;const r=document.getElementById("opencode-theme-variables");r&&r.remove(),document.head.appendChild(s),document.documentElement.setAttribute("data-theme",t.metadata.variant)}generatePrimaryColors(t){const n=[];return n.push(` --primary-base: ${t.base};`),n.push(` --primary-hover: ${t.hover||this.darken(t.base,10)};`),n.push(` --primary-active: ${t.active||this.darken(t.base,20)};`),n.push(` --primary-foreground: ${t.foreground||"#ffffff"};`),n.push(` --primary-muted: ${t.muted||this.opacity(t.base,.5)};`),n.push(` --primary-emphasis: ${t.emphasis||this.lighten(t.base,10)};`),n}generateSurfaceColors(t){const n=[];return n.push(` --surface-background: ${t.background};`),n.push(` --surface-foreground: ${t.foreground};`),n.push(` --surface-muted: ${t.muted};`),n.push(` --surface-muted-foreground: ${t.mutedForeground};`),n.push(` --surface-elevated: ${t.elevated};`),n.push(` --surface-elevated-foreground: ${t.elevatedForeground};`),n.push(` --surface-overlay: ${t.overlay};`),n.push(` --surface-subtle: ${t.subtle};`),n}generateInteractiveColors(t){const n=[];return n.push(` --interactive-border: ${t.border};`),n.push(` --interactive-border-hover: ${t.borderHover};`),n.push(` --interactive-border-focus: ${t.borderFocus};`),n.push(` --interactive-selection: ${t.selection};`),n.push(` --interactive-selection-foreground: ${t.selectionForeground};`),n.push(` --interactive-focus: ${t.focus};`),n.push(` --interactive-focus-ring: ${t.focusRing};`),n.push(` --interactive-cursor: ${t.cursor};`),n.push(` --interactive-hover: ${t.hover};`),n.push(` --interactive-active: ${t.active};`),n}generateStatusColors(t){const n=[];return n.push(` --status-error: ${t.error};`),n.push(` --status-error-foreground: ${t.errorForeground};`),n.push(` --status-error-background: ${t.errorBackground};`),n.push(` --status-error-border: ${t.errorBorder};`),n.push(` --status-warning: ${t.warning};`),n.push(` --status-warning-foreground: ${t.warningForeground};`),n.push(` --status-warning-background: ${t.warningBackground};`),n.push(` --status-warning-border: ${t.warningBorder};`),n.push(` --status-success: ${t.success};`),n.push(` --status-success-foreground: ${t.successForeground};`),n.push(` --status-success-background: ${t.successBackground};`),n.push(` --status-success-border: ${t.successBorder};`),n.push(` --status-info: ${t.info};`),n.push(` --status-info-foreground: ${t.infoForeground};`),n.push(` --status-info-background: ${t.infoBackground};`),n.push(` --status-info-border: ${t.infoBorder};`),n}generatePullRequestColors(t){const n=[],s=t.colors.pr;return n.push(` --pr-open: ${s?.open||t.colors.status.success};`),n.push(` --pr-draft: ${s?.draft||t.colors.surface.mutedForeground};`),n.push(` --pr-blocked: ${s?.blocked||t.colors.status.warning};`),n.push(` --pr-merged: ${s?.merged||(t.metadata.variant==="dark"?"#8957e5":"#8250df")};`),n.push(` --pr-closed: ${s?.closed||t.colors.status.error};`),n}generateSyntaxColors(t){const n=[];n.push(` --syntax-background: ${t.base.background};`),n.push(` --syntax-foreground: ${t.base.foreground};`),n.push(` --syntax-comment: ${t.base.comment};`),n.push(` --syntax-keyword: ${t.base.keyword};`),n.push(` --syntax-string: ${t.base.string};`),n.push(` --syntax-number: ${t.base.number};`),n.push(` --syntax-function: ${t.base.function};`),n.push(` --syntax-variable: ${t.base.variable};`),n.push(` --syntax-type: ${t.base.type};`),n.push(` --syntax-operator: ${t.base.operator};`);const s=this.generateSyntaxTokens(t);for(const[o,r]of Object.entries(s))n.push(` --syntax-${this.kebabCase(o)}: ${r};`);return n}generateSyntaxTokens(t){const n=t.base,s=t.tokens||{};return{commentDoc:s.commentDoc||this.lighten(n.comment,10),stringEscape:s.stringEscape||this.darken(n.string,20),stringInterpolation:s.stringInterpolation||n.variable,stringRegex:s.stringRegex||this.adjustHue(n.string,15),keywordControl:s.keywordControl||n.keyword,keywordOperator:s.keywordOperator||n.operator,keywordImport:s.keywordImport||this.lighten(n.keyword,10),keywordReturn:s.keywordReturn||this.emphasize(n.keyword),functionCall:s.functionCall||this.lighten(n.function,5),functionBuiltin:s.functionBuiltin||this.darken(n.function,10),method:s.method||n.function,methodCall:s.methodCall||this.lighten(n.function,5),variableBuiltin:s.variableBuiltin||this.emphasize(n.variable),variableProperty:s.variableProperty||this.lighten(n.variable,10),variableReadonly:s.variableReadonly||n.number,parameter:s.parameter||n.variable,typePrimitive:s.typePrimitive||this.darken(n.type,10),typeInterface:s.typeInterface||n.type,className:s.className||this.emphasize(n.type),enum:s.enum||n.type,boolean:s.boolean||n.number,null:s.null||this.opacity(n.number,.7),constant:s.constant||n.number,punctuation:s.punctuation||this.opacity(n.foreground,.7),delimiter:s.delimiter||this.opacity(n.foreground,.8),bracket:s.bracket||n.foreground,tag:s.tag||n.keyword,tagAttribute:s.tagAttribute||n.variable,tagAttributeValue:s.tagAttributeValue||n.string,tagBracket:s.tagBracket||this.opacity(n.foreground,.8),decorator:s.decorator||n.function,annotation:s.annotation||n.function,namespace:s.namespace||this.opacity(n.type,.8),module:s.module||this.opacity(n.type,.8),...s}}generateComponentColors(t,n){const s=[];return t.markdown?s.push(...this.generateMarkdownColors(t.markdown,n)):s.push(...this.generateDefaultMarkdownColors(n)),t.chat?s.push(...this.generateChatColors(t.chat,n)):s.push(...this.generateDefaultChatColors(n)),t.tools?s.push(...this.generateToolColors(t.tools,n)):s.push(...this.generateDefaultToolColors(n)),s}generateMarkdownColors(t,n){const s=[],o=n.colors.primary.base,r=n.colors.chat?.background||n.colors.surface.background;return s.push(` --markdown-heading1: ${t.heading1||o};`),s.push(` --markdown-heading2: ${t.heading2||this.opacity(o,.9)};`),s.push(` --markdown-heading3: ${t.heading3||this.opacity(o,.8)};`),s.push(` --markdown-heading4: ${t.heading4||n.colors.surface.foreground};`),s.push(` --markdown-link: ${t.link||o};`),s.push(` --markdown-link-hover: ${t.linkHover||n.colors.primary.hover||this.darken(o,10)};`),s.push(` --markdown-inline-code: ${t.inlineCode||n.colors.syntax.base.string};`),s.push(` --markdown-inline-code-bg: ${t.inlineCodeBackground||r};`),s.push(` --markdown-blockquote: ${t.blockquote||n.colors.surface.mutedForeground};`),s.push(` --markdown-blockquote-border: ${t.blockquoteBorder||n.colors.interactive.border};`),s.push(` --markdown-list-marker: ${t.listMarker||this.opacity(o,.6)};`),s.push(` --markdown-bold: ${t.bold||n.colors.surface.foreground};`),s.push(` --markdown-italic: ${t.italic||this.opacity(n.colors.surface.foreground,.9)};`),s.push(` --markdown-strikethrough: ${t.strikethrough||n.colors.surface.mutedForeground};`),s.push(` --markdown-hr: ${t.hr||n.colors.interactive.border};`),s}generateDefaultMarkdownColors(t){const n=[],s=t.colors.primary.base,o=t.colors.chat?.background||t.colors.surface.background;return n.push(` --markdown-heading1: ${s};`),n.push(` --markdown-heading2: ${this.opacity(s,.9)};`),n.push(` --markdown-heading3: ${this.opacity(s,.8)};`),n.push(` --markdown-heading4: ${t.colors.surface.foreground};`),n.push(` --markdown-link: ${s};`),n.push(` --markdown-link-hover: ${t.colors.primary.hover||this.darken(s,10)};`),n.push(` --markdown-inline-code: ${t.colors.syntax.base.string};`),n.push(` --markdown-inline-code-bg: ${o};`),n.push(` --markdown-blockquote: ${t.colors.surface.mutedForeground};`),n.push(` --markdown-blockquote-border: ${t.colors.interactive.border};`),n.push(` --markdown-list-marker: ${this.opacity(s,.6)};`),n.push(` --markdown-bold: ${t.colors.surface.foreground};`),n.push(` --markdown-italic: ${this.opacity(t.colors.surface.foreground,.9)};`),n.push(` --markdown-strikethrough: ${t.colors.surface.mutedForeground};`),n.push(` --markdown-hr: ${t.colors.interactive.border};`),n}generateChatColors(t,n){const s=[],o=t.background||n.colors.surface.background;return s.push(` --chat-background: ${o};`),s.push(` --chat-user-message: ${t.userMessage||n.colors.surface.foreground};`),s.push(` --chat-user-message-bg: ${t.userMessageBackground||n.colors.surface.elevated};`),s.push(` --chat-assistant-message: ${t.assistantMessage||n.colors.surface.foreground};`),s.push(` --chat-assistant-message-bg: ${t.assistantMessageBackground||n.colors.surface.muted};`),s.push(` --chat-timestamp: ${t.timestamp||n.colors.surface.mutedForeground};`),s.push(` --chat-divider: ${t.divider||n.colors.interactive.border};`),s.push(` --chat-typing: ${t.typing||n.colors.surface.mutedForeground};`),s}generateDefaultChatColors(t){const n=[];return n.push(` --chat-background: ${t.colors.surface.background};`),n.push(` --chat-user-message: ${t.colors.surface.foreground};`),n.push(` --chat-user-message-bg: ${t.colors.surface.elevated};`),n.push(` --chat-assistant-message: ${t.colors.surface.foreground};`),n.push(` --chat-assistant-message-bg: ${t.colors.surface.muted};`),n.push(` --chat-timestamp: ${t.colors.surface.mutedForeground};`),n.push(` --chat-divider: ${t.colors.interactive.border};`),n.push(` --chat-typing: ${t.colors.surface.mutedForeground};`),n}generateToolColors(t,n){const s=[];return s.push(` --tools-background: ${t?.background||this.opacity(n.colors.surface.muted,.2)};`),s.push(` --tools-border: ${t?.border||this.opacity(n.colors.interactive.border,.3)};`),s.push(` --tools-header-hover: ${t?.headerHover||this.opacity(n.colors.surface.muted,.3)};`),s.push(` --tools-icon: ${t?.icon||n.colors.surface.mutedForeground};`),s.push(` --tools-title: ${t?.title||n.colors.surface.foreground};`),s.push(` --tools-description: ${t?.description||this.opacity(n.colors.surface.mutedForeground,.6)};`),t?.edit?(s.push(` --tools-edit-added: ${t.edit.added||n.colors.status.success};`),s.push(` --tools-edit-added-bg: ${t.edit.addedBackground||n.colors.status.successBackground};`),s.push(` --tools-edit-removed: ${t.edit.removed||n.colors.status.error};`),s.push(` --tools-edit-removed-bg: ${t.edit.removedBackground||n.colors.status.errorBackground};`),s.push(` --tools-edit-modified: ${t.edit.modified||n.colors.status.info};`),s.push(` --tools-edit-modified-bg: ${t.edit.modifiedBackground||n.colors.status.infoBackground};`),s.push(` --tools-edit-line-number: ${t.edit.lineNumber||this.opacity(n.colors.surface.mutedForeground,.6)};`)):(s.push(` --tools-edit-added: ${n.colors.status.success};`),s.push(` --tools-edit-added-bg: ${n.colors.status.successBackground};`),s.push(` --tools-edit-removed: ${n.colors.status.error};`),s.push(` --tools-edit-removed-bg: ${n.colors.status.errorBackground};`),s.push(` --tools-edit-modified: ${n.colors.status.info};`),s.push(` --tools-edit-modified-bg: ${n.colors.status.infoBackground};`),s.push(` --tools-edit-line-number: ${this.opacity(n.colors.surface.mutedForeground,.6)};`)),s}generateDefaultToolColors(t){const n=[];return n.push(` --tools-background: ${this.opacity(t.colors.surface.muted,.2)};`),n.push(` --tools-border: ${this.opacity(t.colors.interactive.border,.3)};`),n.push(` --tools-header-hover: ${this.opacity(t.colors.surface.muted,.3)};`),n.push(` --tools-icon: ${t.colors.surface.mutedForeground};`),n.push(` --tools-title: ${t.colors.surface.foreground};`),n.push(` --tools-description: ${this.opacity(t.colors.surface.mutedForeground,.6)};`),n.push(` --tools-edit-added: ${t.colors.status.success};`),n.push(` --tools-edit-added-bg: ${this.addTransparency(this.removeTransparency(t.colors.status.successBackground),.15)};`),n.push(` --tools-edit-removed: ${t.colors.status.error};`),n.push(` --tools-edit-removed-bg: ${this.addTransparency(this.removeTransparency(t.colors.status.errorBackground),.15)};`),n.push(` --tools-edit-modified: ${t.colors.status.info};`),n.push(` --tools-edit-modified-bg: ${this.addTransparency(this.removeTransparency(t.colors.status.infoBackground),.15)};`),n.push(` --tools-edit-line-number: ${this.opacity(t.colors.surface.mutedForeground,.6)};`),n}generateConfigVariables(t){const n=[];return t&&(t.fonts&&(t.fonts.sans&&(n.push(` --font-sans: ${t.fonts.sans};`),n.push(` --font-family-sans: ${t.fonts.sans};`)),t.fonts.mono&&(n.push(` --font-mono: ${t.fonts.mono};`),n.push(` --font-family-mono: ${t.fonts.mono};`)),t.fonts.heading&&n.push(` --font-heading: ${t.fonts.heading};`)),t.transitions&&(t.transitions.fast&&n.push(` --transition-fast: ${t.transitions.fast};`),t.transitions.normal&&n.push(` --transition-normal: ${t.transitions.normal};`),t.transitions.slow&&n.push(` --transition-slow: ${t.transitions.slow};`))),n}generateTypographyVariables(){const t=[],n=Sg;return t.push(" /* Semantic Typography Variables */"),t.push(" --ui-regular-font-weight: 400;"),t.push(" /* Markdown content - all markdown elements use same size */"),t.push(` --text-markdown: ${n.markdown};`),t.push(" /* Code content - all code elements use same size */"),t.push(` --text-code: ${n.code};`),t.push(" /* UI headers - dialog titles, panel headers */"),t.push(` --text-ui-header: ${n.uiHeader};`),t.push(" /* UI labels - buttons, menus, navigation */"),t.push(` --text-ui-label: ${n.uiLabel};`),t.push(" /* Metadata - timestamps, status, helper text */"),t.push(` --text-meta: ${n.meta};`),t.push(" /* Micro text - badges, shortcuts, indicators */"),t.push(` --text-micro: ${n.micro};`),t.push(" /* Settings page titles - larger than section headers */"),t.push(` --text-settings-page-title: ${n.settingsPageTitle};`),t.push(" /* Heading line height and letter spacing */"),t.push(" --h1-line-height: 1.25rem;"),t.push(" --h2-line-height: 1.25rem;"),t.push(" --h3-line-height: 1.5rem;"),t.push(" --h4-line-height: 1.5rem;"),t.push(" --h5-line-height: 1.5rem;"),t.push(" --h6-line-height: 1.5rem;"),t.push(" --h1-letter-spacing: -0.025em;"),t.push(" --h2-letter-spacing: -0.02em;"),t.push(" --h3-letter-spacing: -0.015em;"),t.push(" --h4-letter-spacing: -0.01em;"),t.push(" --h5-letter-spacing: 0;"),t.push(" --h6-letter-spacing: 0.01em;"),t.push(" /* UI element line height and letter spacing */"),t.push(" --ui-button-line-height: 1.375rem;"),t.push(" --ui-button-letter-spacing: 0.02em;"),t.push(" --ui-button-font-weight: 500;"),t.push(" --ui-label-line-height: 1rem;"),t.push(" --ui-label-letter-spacing: 0.03em;"),t.push(" --ui-label-font-weight: 500;"),t.push(" --ui-caption-line-height: 1rem;"),t.push(" --ui-caption-letter-spacing: 0.025em;"),t.push(" --ui-caption-font-weight: var(--ui-regular-font-weight, 400);"),t.push(" /* Markdown line height and letter spacing */"),t.push(" --markdown-body-line-height: 1.5rem;"),t.push(" --markdown-body-letter-spacing: 0;"),t.push(" --markdown-body-font-weight: var(--ui-regular-font-weight, 400);"),t.push(" --markdown-h1-line-height: 1.25rem;"),t.push(" --markdown-h1-letter-spacing: -0.025em;"),t.push(" --markdown-h2-line-height: 1.25rem;"),t.push(" --markdown-h2-letter-spacing: -0.02em;"),t.push(" --markdown-h3-line-height: 1.5rem;"),t.push(" --markdown-h3-letter-spacing: -0.015em;"),t.push(" --markdown-h4-line-height: 1.5rem;"),t.push(" --markdown-h4-letter-spacing: -0.01em;"),t.push(" --markdown-h5-line-height: 1.5rem;"),t.push(" --markdown-h5-letter-spacing: 0;"),t.push(" --markdown-h6-line-height: 1.5rem;"),t.push(" --markdown-h6-letter-spacing: 0.01em;"),t.push(" --markdown-list-line-height: 1.375rem;"),t.push(" --markdown-code-block-line-height: 1rem;"),t.push(" --ui-button-small-line-height: 1.25rem;"),t.push(" --ui-button-small-letter-spacing: 0.02em;"),t.push(" --ui-button-small-font-weight: 500;"),t.push(" --markdown-body-small-line-height: 1.375rem;"),t.push(" --markdown-body-small-letter-spacing: 0;"),t.push(" --markdown-body-small-font-weight: var(--ui-regular-font-weight, 400);"),t.push(" --ui-button-large-line-height: 1.5rem;"),t.push(" --ui-button-large-letter-spacing: 0.02em;"),t.push(" --ui-button-large-font-weight: 500;"),t.push(" --markdown-body-large-line-height: 1.625rem;"),t.push(" --markdown-body-large-letter-spacing: 0;"),t.push(" --markdown-body-large-font-weight: var(--ui-regular-font-weight, 400);"),t.push(" /* Code line height and letter spacing */"),t.push(" --code-inline-line-height: 1rem;"),t.push(" --code-inline-letter-spacing: 0;"),t.push(" --code-inline-font-weight: 400;"),t.push(" --code-block-line-height: round(1.4rem, 1px);"),t.push(" --code-block-letter-spacing: 0;"),t.push(" --code-block-font-weight: 400;"),t.push(" --code-line-numbers-line-height: 1.25rem;"),t.push(" --code-line-numbers-letter-spacing: 0;"),t.push(" --code-line-numbers-font-weight: 400;"),t.push(" /* Additional UI element line height and letter spacing */"),t.push(" --ui-badge-line-height: 1rem;"),t.push(" --ui-badge-letter-spacing: 0.025em;"),t.push(" --ui-badge-font-weight: 500;"),t.push(" --ui-tooltip-line-height: 1rem;"),t.push(" --ui-tooltip-letter-spacing: 0.025em;"),t.push(" --ui-tooltip-font-weight: var(--ui-regular-font-weight, 400);"),t.push(" --ui-input-line-height: 1.375rem;"),t.push(" --ui-input-letter-spacing: 0.02em;"),t.push(" --ui-input-font-weight: var(--ui-regular-font-weight, 400);"),t.push(" --ui-helper-text-line-height: 1rem;"),t.push(" --ui-helper-text-letter-spacing: 0.025em;"),t.push(" --ui-helper-text-font-weight: var(--ui-regular-font-weight, 400);"),t.push(" /* Additional markdown line height and letter spacing */"),t.push(" --markdown-blockquote-line-height: 1.5rem;"),t.push(" --markdown-blockquote-letter-spacing: 0;"),t.push(" --markdown-blockquote-font-weight: var(--ui-regular-font-weight, 400);"),t.push(" --markdown-list-letter-spacing: 0;"),t.push(" --markdown-list-font-weight: var(--ui-regular-font-weight, 400);"),t.push(" --markdown-link-line-height: 1.5rem;"),t.push(" --markdown-link-letter-spacing: 0;"),t.push(" --markdown-link-font-weight: var(--ui-regular-font-weight, 400);"),t.push(" --markdown-code-line-height: round(1.35em, 1px);"),t.push(" --markdown-code-letter-spacing: 0;"),t.push(" --markdown-code-font-weight: 400;"),t.push(" --markdown-code-block-letter-spacing: 0;"),t.push(" --markdown-code-block-font-weight: 400;"),t}initializeInheritanceMap(){this.inheritanceMap.set("header.background","surface.background"),this.inheritanceMap.set("header.foreground","surface.foreground"),this.inheritanceMap.set("header.logoTint","primary.base"),this.inheritanceMap.set("header.divider","interactive.border"),this.inheritanceMap.set("sidebar.background","surface.muted"),this.inheritanceMap.set("sidebar.foreground","surface.mutedForeground"),this.inheritanceMap.set("sidebar.hover","interactive.hover"),this.inheritanceMap.set("sidebar.active","primary.base"),this.inheritanceMap.set("sidebar.activeForeground","primary.foreground")}opacity(t,n){return t.startsWith("#")?`${t}${Math.round(n*255).toString(16).padStart(2,"0")}`:t.startsWith("rgb")?t.replace("rgb","rgba").replace(")",`, ${n})`):t}removeTransparency(t){return t.startsWith("#")?t.length===9?t.slice(0,7):t.length===5?t.slice(0,4):t:t.startsWith("rgba")?t.replace("rgba","rgb").replace(/,\s*[\d.]+\)$/,")"):t}addTransparency(t,n){if(t.startsWith("#")){const s=t.slice(1);if(s.length===3){const o=parseInt(s[0]+s[0],16),r=parseInt(s[1]+s[1],16),a=parseInt(s[2]+s[2],16);return`rgba(${o}, ${r}, ${a}, ${n})`}else if(s.length===6){const o=parseInt(s.slice(0,2),16),r=parseInt(s.slice(2,4),16),a=parseInt(s.slice(4,6),16);return`rgba(${o}, ${r}, ${a}, ${n})`}}return t.startsWith("rgb")?t.replace("rgb","rgba").replace(")",`, ${n})`):t}darken(t,n){if(t.startsWith("#")){const s=parseInt(t.slice(1),16),o=Math.round(2.55*n),r=(s>>16)-o,a=(s>>8&255)-o,l=(s&255)-o;return"#"+(16777216+(r<255?r<0?0:r:255)*65536+(a<255?a<0?0:a:255)*256+(l<255?l<0?0:l:255)).toString(16).slice(1)}return t}lighten(t,n){if(t.startsWith("#")){const s=parseInt(t.slice(1),16),o=Math.round(2.55*n),r=(s>>16)+o,a=(s>>8&255)+o,l=(s&255)+o;return"#"+(16777216+(r<255?r<0?0:r:255)*65536+(a<255?a<0?0:a:255)*256+(l<255?l<0?0:l:255)).toString(16).slice(1)}return t}adjustHue(t,n){return this.lighten(t,n/10)}emphasize(t){return this.lighten(t,15)}kebabCase(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}}const I6=(e,t)=>t.reduce((n,s)=>n&&typeof n=="object"?n[s]:void 0,e),mC=e=>typeof e=="string"&&e.trim().length>0,B6=e=>{if(!e||typeof e!="object")return!1;const t=[["metadata","id"],["metadata","name"],["metadata","variant"],["colors","primary","base"],["colors","primary","foreground"],["colors","surface","background"],["colors","surface","foreground"],["colors","surface","muted"],["colors","surface","mutedForeground"],["colors","surface","elevated"],["colors","surface","elevatedForeground"],["colors","surface","subtle"],["colors","interactive","border"],["colors","interactive","selection"],["colors","interactive","selectionForeground"],["colors","interactive","focusRing"],["colors","interactive","hover"],["colors","status","error"],["colors","status","errorForeground"],["colors","status","errorBackground"],["colors","status","errorBorder"],["colors","status","warning"],["colors","status","warningForeground"],["colors","status","warningBackground"],["colors","status","warningBorder"],["colors","status","success"],["colors","status","successForeground"],["colors","status","successBackground"],["colors","status","successBorder"],["colors","status","info"],["colors","status","infoForeground"],["colors","status","infoBackground"],["colors","status","infoBorder"],["colors","syntax","base","background"],["colors","syntax","base","foreground"],["colors","syntax","base","keyword"],["colors","syntax","base","string"],["colors","syntax","base","number"],["colors","syntax","base","function"],["colors","syntax","base","variable"],["colors","syntax","base","type"],["colors","syntax","base","comment"],["colors","syntax","base","operator"],["colors","syntax","highlights","diffAdded"],["colors","syntax","highlights","diffRemoved"],["colors","syntax","highlights","lineNumber"]];for(const s of t)if(!mC(I6(e,s)))return!1;const n=I6(e,["metadata","variant"]);return n==="light"||n==="dark"},pC=Hg,gC=Ag,yC=e=>jg(e==="dark"),vC=typeof window<"u"?d.useLayoutEffect:d.useEffect,bC=()=>{if(typeof document>"u")return;const e=document.documentElement;e.classList.add("oc-theme-switching");const t=window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{e.classList.remove("oc-theme-switching")})});return()=>{window.cancelAnimationFrame(t),e.classList.remove("oc-theme-switching")}},xC=e=>{let t=pC,n=gC,s="system";if(typeof window<"u"){const o=localStorage.getItem("themeMode"),r=localStorage.getItem("lightThemeId"),a=localStorage.getItem("darkThemeId"),l=localStorage.getItem("useSystemTheme"),c=localStorage.getItem("selectedThemeId"),u=localStorage.getItem("selectedThemeVariant");if(o==="light"||o==="dark"||o==="system")s=o;else if(l!==null){if(l==="true")s="system";else if(c){const h=cc(c);h&&(s=h.metadata.variant==="dark"?"dark":"light",h.metadata.variant==="dark"?n=h.metadata.id:t=h.metadata.id)}}else(u==="light"||u==="dark")&&(s=u);typeof r=="string"&&r.trim().length>0&&(t=r.trim()),typeof a=="string"&&a.trim().length>0&&(n=a.trim())}if(e){const o=cc(e);o&&(o.metadata.variant==="light"?t=o.metadata.id:n=o.metadata.id)}return{themeMode:s,lightThemeId:t,darkThemeId:n}};function WO({children:e,defaultThemeId:t}){const n=ae.useMemo(()=>new hC,[]),[s,o]=ae.useState(()=>xC(t)),[r,a]=ae.useState(()=>typeof window>"u"?!0:window.matchMedia("(prefers-color-scheme: dark)").matches),[l,c]=ae.useState([]),[u,f]=ae.useState([]),[h,m]=ae.useState(!1),p=ae.useMemo(()=>S1(),[]),g=ae.useRef(0),y=ae.useMemo(()=>{const k=[],V=new Set,H=D=>{const P=D.metadata.id;V.has(P)||(V.add(P),k.push(D))};return l.forEach(H),u.forEach(H),_g.forEach(H),k},[l,u]);ae.useEffect(()=>{const k=V=>{const H=V.detail;if(!B6(H))return;const D=Lg(H);f(P=>{const R=P.findIndex(O=>O.metadata.id===D.metadata.id);if(R<0)return[...P,D];const $=[...P];return $[R]=D,$})};return window.addEventListener("pichamber:theme-hmr",k),()=>window.removeEventListener("pichamber:theme-hmr",k)},[]);const M=ae.useCallback(k=>y.find(V=>V.metadata.id===k),[y]),b=ae.useCallback((k,V)=>{const H=M(k);return H&&H.metadata.variant===V?H:y.find(P=>P.metadata.variant===V)??yC(V)},[y,M]),v=ae.useMemo(()=>s.themeMode==="light"?b(s.lightThemeId,"light"):s.themeMode==="dark"||r?b(s.darkThemeId,"dark"):b(s.lightThemeId,"light"),[b,s,r]),x=ae.useCallback(async()=>{if(typeof window>"u")return;const k=We(),V=++g.current;m(!0);try{const H=await V1("/api/pi/themes",{method:"GET",credentials:kg()?"omit":"include",headers:{Accept:"application/json"}});if(H.status===401||!H.ok)return;const D=await H.json();if(V!==g.current||k!==We())return;const R=(Array.isArray(D?.themes)?D.themes:[]).filter(B6);c(R)}catch{}finally{V===g.current&&k===We()&&m(!1)}},[]);ae.useEffect(()=>{x()},[x]),ae.useEffect(()=>Wn(k=>{k.runtimeKey!==k.previousRuntimeKey&&(g.current+=1,c([]),m(!1),x())}),[x]);const S=ae.useCallback(k=>{if(typeof document>"u")return;const V=k.colors.surface.background;document.body.style.backgroundColor=V;let H=document.querySelector('meta[name="theme-color"]');H||(H=document.createElement("meta"),H.setAttribute("name","theme-color"),document.head.appendChild(H)),H.setAttribute("content",V);const D=k.metadata.variant==="dark"?"(prefers-color-scheme: dark)":"(prefers-color-scheme: light)";let P=document.querySelector(`meta[name="theme-color"][media="${D}"]`);P||(P=document.createElement("meta"),P.setAttribute("name","theme-color"),P.setAttribute("media",D),document.head.appendChild(P)),P.setAttribute("content",V)},[]);vC(()=>{if(typeof window>"u")return;const k=bC();n.apply(v),S(v);const V=document.documentElement;return V.classList.remove("light","dark"),V.classList.add(v.metadata.variant),k},[n,v,S]),ae.useEffect(()=>{if(s.themeMode!=="system"||typeof window>"u")return;const k=window.matchMedia("(prefers-color-scheme: dark)"),V=H=>{a(H.matches)};return a(k.matches),k.addEventListener("change",V),()=>k.removeEventListener("change",V)},[s.themeMode]),ae.useEffect(()=>{if(typeof window>"u")return;localStorage.setItem("themeMode",s.themeMode),localStorage.setItem("lightThemeId",s.lightThemeId),localStorage.setItem("darkThemeId",s.darkThemeId),localStorage.setItem("useSystemTheme",String(s.themeMode==="system")),localStorage.setItem("selectedThemeId",v.metadata.id),localStorage.setItem("selectedThemeVariant",v.metadata.variant==="light"?"light":"dark");const k=b(s.lightThemeId,"light"),V=b(s.darkThemeId,"dark");localStorage.setItem("splashBgLight",k.colors.surface.background),localStorage.setItem("splashFgLight",k.colors.surface.foreground),localStorage.setItem("splashBgDark",V.colors.surface.background),localStorage.setItem("splashFgDark",V.colors.surface.foreground)},[s,v,b]),ae.useEffect(()=>{if(typeof window>"u")return;const k=V=>{V.storageArea===window.localStorage&&(V.key!=="themeMode"&&V.key!=="lightThemeId"&&V.key!=="darkThemeId"||o(H=>{const D=localStorage.getItem("themeMode"),P=D==="light"||D==="dark"||D==="system"?D:H.themeMode,R=localStorage.getItem("lightThemeId"),$=typeof R=="string"&&R.trim().length>0?R.trim():H.lightThemeId,O=localStorage.getItem("darkThemeId"),I=typeof O=="string"&&O.trim().length>0?O.trim():H.darkThemeId;return P===H.themeMode&&$===H.lightThemeId&&I===H.darkThemeId?H:{themeMode:P,lightThemeId:$,darkThemeId:I}}))};return window.addEventListener("storage",k),()=>window.removeEventListener("storage",k)},[]),ae.useEffect(()=>{const k=b(s.lightThemeId,"light"),V=b(s.darkThemeId,"dark");Nn({themeId:v.metadata.id,themeVariant:v.metadata.variant==="light"?"light":"dark",useSystemTheme:s.themeMode==="system",lightThemeId:s.lightThemeId,darkThemeId:s.darkThemeId,splashBgLight:k.colors.surface.background,splashFgLight:k.colors.surface.foreground,splashBgDark:V.colors.surface.background,splashFgDark:V.colors.surface.foreground})},[v.metadata.id,v.metadata.variant,b,s.themeMode,s.lightThemeId,s.darkThemeId]),ae.useEffect(()=>{p&&(async()=>await fC(s.themeMode,v.metadata.variant))()},[v.metadata.variant,p,s.themeMode]),ae.useEffect(()=>{if(typeof window>"u")return;const k=V=>{const H=V.detail;H&&o(D=>{let P=D.themeMode;H.useSystemTheme===!0?P="system":H.useSystemTheme===!1&&(H.themeVariant==="dark"||H.themeVariant==="light")&&(P=H.themeVariant);let R=D.lightThemeId;typeof H.lightThemeId=="string"&&H.lightThemeId.length>0&&(R=H.lightThemeId.trim());let $=D.darkThemeId;return typeof H.darkThemeId=="string"&&H.darkThemeId.length>0&&($=H.darkThemeId.trim()),P===D.themeMode&&R===D.lightThemeId&&$===D.darkThemeId?D:{themeMode:P,lightThemeId:R,darkThemeId:$}})};return window.addEventListener("pichamber:settings-synced",k),()=>window.removeEventListener("pichamber:settings-synced",k)},[]);const C=ae.useCallback(k=>{const V=y.find(H=>H.metadata.id===k);V&&o(H=>V.metadata.variant==="dark"?H.darkThemeId===V.metadata.id&&H.themeMode==="dark"?H:{...H,darkThemeId:V.metadata.id,themeMode:"dark"}:H.lightThemeId===V.metadata.id&&H.themeMode==="light"?H:{...H,lightThemeId:V.metadata.id,themeMode:"light"})},[y]),w=ae.useCallback(k=>{s.themeMode!==k&&(o(V=>({...V,themeMode:k})),Nn({themeVariant:k==="system"?v.metadata.variant:k,useSystemTheme:k==="system"}))},[v.metadata.variant,s.themeMode]),_=ae.useCallback(k=>{if(k){o(H=>H.themeMode==="system"?H:{...H,themeMode:"system"});return}const V=v.metadata.variant==="dark"?"dark":"light";o(H=>H.themeMode===V?H:{...H,themeMode:V})},[v.metadata.variant]),L=ae.useCallback(k=>{const V=y.find(H=>H.metadata.id===k&&H.metadata.variant==="light");V&&o(H=>H.lightThemeId===V.metadata.id?H:{...H,lightThemeId:V.metadata.id})},[y]),A=ae.useCallback(k=>{const V=y.find(H=>H.metadata.id===k&&H.metadata.variant==="dark");V&&o(H=>H.darkThemeId===V.metadata.id?H:{...H,darkThemeId:V.metadata.id})},[y]),N={currentTheme:v,availableThemes:y,setTheme:C,customThemesLoading:h,reloadCustomThemes:x,isSystemPreference:s.themeMode==="system",setSystemPreference:_,themeMode:s.themeMode,setThemeMode:w,lightThemeId:s.lightThemeId,darkThemeId:s.darkThemeId,setLightThemePreference:L,setDarkThemePreference:A};return i.jsx(N3.Provider,{value:N,children:e})}const mn={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536},af={isMobile:!1,isTablet:!1,isDesktop:!0,deviceType:"desktop",screenWidth:1024,breakpoint:"lg",hasTouchInput:!1,hasTouchOnlyPointer:!1},wC=()=>typeof window>"u"?!1:new URLSearchParams(window.location.search).get("surface")==="desktop",MC=e=>{if(typeof navigator>"u")return{isExplicitTablet:!1};const t=navigator.userAgent||"",n=navigator.platform||"",s=/iPad/i.test(t)||(/Macintosh|MacIntel/i.test(t)||/MacIntel/i.test(n))&&e>1,o=/Android/i.test(t)&&!/Mobile/i.test(t),r=/Tablet/i.test(t);return{isExplicitTablet:s||o||r}},CC=(e,t,n)=>{if(typeof window>"u")return;const s=document.documentElement;s.classList.remove("device-mobile","device-tablet","device-desktop"),s.classList.add(t==="mobile"?"device-mobile":t==="tablet"?"device-tablet":"device-desktop"),e?(s.classList.add("desktop-runtime"),s.classList.remove("mobile-pointer")):(s.classList.remove("desktop-runtime"),n?s.classList.add("mobile-pointer"):s.classList.remove("mobile-pointer"))};function P3(){const e=window.innerWidth,t=typeof window.matchMedia=="function",n=t?window.matchMedia("(pointer: coarse)"):null,s=t?window.matchMedia("(hover: none)"):null,o=n?.matches??!1,r=s?.matches??!1,a=typeof navigator<"u"?navigator.maxTouchPoints??0:0,l=S1()||wC(),{isExplicitTablet:c}=MC(a),u=o||r||a>0,f=o||r,h=e>mn.md&&e<=mn.lg,m=e<=mn.md;let p=u&&m,g=u&&!p&&(h||c),y=!u||!g&&e>mn.lg,M="desktop";l?(p=!1,g=!1,y=!0,M="desktop"):D2()?(p=!0,g=!1,y=!1,M="mobile"):p?M="mobile":g?M="tablet":(y=!0,M="desktop"),CC(l,M,u);let b="xs";for(const[v,x]of Object.entries(mn))e>=x&&(b=v);return{isMobile:p,isTablet:g,isDesktop:y,deviceType:M,screenWidth:e,breakpoint:b,hasTouchInput:u,hasTouchOnlyPointer:f}}const SC=(e,t)=>e.isMobile===t.isMobile&&e.isTablet===t.isTablet&&e.isDesktop===t.isDesktop&&e.deviceType===t.deviceType&&e.screenWidth===t.screenWidth&&e.breakpoint===t.breakpoint&&e.hasTouchInput===t.hasTouchInput&&e.hasTouchOnlyPointer===t.hasTouchOnlyPointer,Pr=new Set;let Xt=null,jn,ds=null;const _C=()=>typeof window>"u"?af:(Xt||(Xt=P3()),Xt),kC=()=>{for(const e of Pr)e()},AC=()=>{jn=void 0;const e=P3();Xt&&SC(Xt,e)||(Xt=e,kC())},Wo=()=>{typeof window>"u"||jn!==void 0||(jn=window.requestAnimationFrame(AC))},di=(e,t)=>e?typeof e.addEventListener=="function"?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):typeof e.addListener=="function"?(e.addListener(t),()=>e.removeListener(t)):()=>{}:()=>{},HC=()=>{if(typeof window>"u")return()=>{};Xt=P3(),window.addEventListener("resize",Wo);const e=typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null,t=typeof window.matchMedia=="function"?window.matchMedia("(hover: none)"):null,n=di(e,Wo),s=di(t,Wo);return()=>{window.removeEventListener("resize",Wo),n(),s(),jn!==void 0&&(window.cancelAnimationFrame(jn),jn=void 0)}},LC=e=>typeof window>"u"?()=>{}:(Pr.add(e),ds||(ds=HC()),()=>{Pr.delete(e),Pr.size===0&&ds&&(ds(),ds=null,Xt=null)}),jC=()=>typeof window>"u"?!1:!!(navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)")?.matches||window.matchMedia?.("(display-mode: fullscreen)")?.matches),T6=()=>{if(typeof window>"u"||S1())return!1;const e=typeof navigator<"u"?navigator.maxTouchPoints??0:0;return jC()&&e>0&&window.innerWidth>mn.md};function KO(){const[e,t]=d.useState(()=>T6());return d.useEffect(()=>{if(typeof window>"u")return;const n=()=>t(T6()),s=window.matchMedia?.("(display-mode: standalone)"),o=window.matchMedia?.("(display-mode: fullscreen)");n(),window.addEventListener("resize",n),window.addEventListener("focus",n);const r=l=>{l&&(typeof l.addEventListener=="function"?l.addEventListener("change",n):typeof l.addListener=="function"&&l.addListener(n))},a=l=>{l&&(typeof l.removeEventListener=="function"?l.removeEventListener("change",n):typeof l.removeListener=="function"&&l.removeListener(n))};return r(s),r(o),()=>{window.removeEventListener("resize",n),window.removeEventListener("focus",n),a(s),a(o)}},[]),e}const IC=()=>typeof window>"u"?"portrait":window.matchMedia?.("(orientation: landscape)")?.matches?"landscape":"portrait";function YO(){const[e,t]=d.useState(IC);return d.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const n=window.matchMedia("(orientation: landscape)"),s=()=>t(n.matches?"landscape":"portrait");return s(),di(n,s)},[]),e}const BC=600,TC=1e3,E3=()=>{if(typeof window>"u")return{enabled:!1,roomyForPanels:!1};const e=window.innerWidth,t=window.innerHeight,n=Ig()||Math.min(e,t)>=BC;return{enabled:n,roomyForPanels:n&&e>t&&e>=TC}},VC=(e,t)=>e.enabled===t.enabled&&e.roomyForPanels===t.roomyForPanels,lf={enabled:!1,roomyForPanels:!1},Er=new Set;let Qt=null,In,us=null;const NC=()=>typeof window>"u"?lf:(Qt||(Qt=E3()),Qt),PC=()=>{for(const e of Er)e()},EC=()=>{In=void 0;const e=E3();Qt&&VC(Qt,e)||(Qt=e,PC())},Qa=()=>{typeof window>"u"||In!==void 0||(In=window.requestAnimationFrame(EC))},zC=()=>{if(typeof window>"u")return()=>{};Qt=E3(),window.addEventListener("resize",Qa);const e=typeof window.matchMedia=="function"?window.matchMedia("(orientation: landscape)"):null,t=di(e,Qa);return()=>{window.removeEventListener("resize",Qa),t(),In!==void 0&&(window.cancelAnimationFrame(In),In=void 0)}},DC=e=>typeof window>"u"?()=>{}:(Er.add(e),us||(us=zC()),()=>{Er.delete(e),Er.size===0&&us&&(us(),us=null,Qt=null)});function Kn(){return d.useSyncExternalStore(DC,NC,()=>lf)}function c0(){return d.useSyncExternalStore(LC,_C,()=>af)}let el=null;const z3=()=>(el??=V2(()=>import("./MarkdownRendererImpl-V1HMFCjr.js"),__vite__mapDeps([8,1,2,9,10,11,12,13,6,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,7,108,109])).catch(e=>{throw el=null,e}),el),JO=()=>{z3().catch(()=>{})},RC={threshold:.4,distance:100,ignoreLocation:!0,preferSubstring:!0};function OC(e,t,n){if(!t)return!0;if(!e)return!1;const s={...RC,...n};return s.preferSubstring&&e.toLowerCase().includes(t.toLowerCase())?!0:new N9([e],{threshold:s.threshold,distance:s.distance,ignoreLocation:s.ignoreLocation}).search(t).length>0}function XO(e,t,n,s){if(!t)return e.map(f=>({item:f,score:0}));const o=s?.limit??e.length,r=s?.threshold??.3,a=s?.noFuzzy??!1,l=t.toLowerCase(),c=[],u=[];for(const f of e){const h=n(f);if(!h)continue;const p=h.toLowerCase().indexOf(l);if(p===0){c.push({item:f,score:-1});continue}if(p>0){c.push({item:f,score:p/1e3});continue}a||u.push({item:f,text:h})}if(u.length>0){const f=new N9(u.map(h=>h.text),{threshold:r,ignoreLocation:!0,distance:100,includeScore:!0,minMatchCharLength:2});for(const h of f.search(t))c.push({item:u[h.refIndex].item,score:h.score??1})}return c.sort((f,h)=>f.score-h.score),c.slice(0,o)}function B(...e){return vv(yv(e))}const it=()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),ZC=()=>typeof navigator>"u"?!1:/Windows/.test(navigator.userAgent||""),QO=()=>it()?"Reveal in Finder":ZC()?"Open in File Explorer":"Open in File Manager",eZ=e=>it()&&S1()?e.metaKey:e.ctrlKey,tZ=()=>it()&&S1()?"⌘":"Ctrl",tl=(e,t)=>{const n=e??"",s=Math.max(16,t?.maxLength??45);if(n.length<=s)return n;const o=n.split("/");if(o.length<=1)return n;const r=o.pop()??"";if(!r)return n;const a=Math.max(0,s-(r.length+2));if(a<=0)return`…/${r}`;let l="";for(const c of o){if(!c)continue;const u=l?`${l}/${c}`:c;if(u.length>a)break;l=u}if(!l){const c=o[0]??"";l=c?c.slice(0,a):""}return l?`${l}…/${r}`:`…/${r}`},ui=e=>e?e==="/"?"/":e.replace(/\/+$/,""):"";function nZ(e,t){if(!e)return"";const n=ui(e);if(n==="/")return"/";const s=t?ui(t):void 0;if(s&&s!=="/"){if(n===s)return"~";if(n.startsWith(`${s}/`)){const o=n.slice(s.length+1);return o?`~/${o}`:"~"}}return n}function fi(e,t){if(!e)return"/";const n=ui(e);if(!n||n==="/")return"/";const s=t?ui(t):void 0;return s&&s!=="/"&&n===s?"~":n.split("/").pop()||n||"/"}function e0(e,t){return OC(e,t)}function FC(...e){return t=>{for(const n of e)n&&(typeof n=="function"?n(t):n.current=t)}}function $C(e,t){const n={...t};for(const s in e){const o=t[s],r=e[s];/^on[A-Z]/.test(s)&&typeof o=="function"&&typeof r=="function"?n[s]=(...a)=>{r(...a),o(...a)}:s==="className"&&typeof o=="string"&&typeof r=="string"?n[s]=`${r} ${o}`:s==="style"&&typeof o=="object"&&typeof r=="object"?n[s]={...r,...o}:n[s]=r}return n}const qC=ae.forwardRef(function({children:t,...n},s){if(!ae.isValidElement(t))return null;const o=t;return ae.cloneElement(o,{...$C(o.props,n),ref:FC(s,o.ref)})}),UC=["bg-[color-mix(in_srgb,var(--primary-base)_10%,var(--background))]","text-[var(--primary-base)]","border border-[color-mix(in_srgb,var(--primary-base)_12%,transparent)]","hover:bg-[color-mix(in_srgb,var(--primary-base)_16%,var(--background))]","active:bg-[color-mix(in_srgb,var(--primary-base)_22%,var(--background))]","dark:bg-[color-mix(in_srgb,var(--primary-base)_16%,transparent)]","dark:border-[color-mix(in_srgb,var(--primary-base)_20%,transparent)]","dark:hover:bg-[color-mix(in_srgb,var(--primary-base)_22%,transparent)]","dark:active:bg-[color-mix(in_srgb,var(--primary-base)_30%,transparent)]"].join(" "),GC=["bg-[color-mix(in_srgb,var(--status-error)_7%,var(--background))]","text-[var(--status-error)]","border border-[color-mix(in_srgb,var(--status-error)_9%,transparent)]","hover:bg-[color-mix(in_srgb,var(--status-error)_11%,var(--background))]","active:bg-[color-mix(in_srgb,var(--status-error)_16%,var(--background))]","dark:bg-[color-mix(in_srgb,var(--status-error)_9%,transparent)]","dark:border-[color-mix(in_srgb,var(--status-error)_14%,transparent)]","dark:hover:bg-[color-mix(in_srgb,var(--status-error)_14%,transparent)]","dark:active:bg-[color-mix(in_srgb,var(--status-error)_20%,transparent)]"].join(" "),WC=["bg-[color-mix(in_srgb,var(--status-info)_4%,var(--background))]","text-[var(--status-info)]","border border-[color-mix(in_srgb,var(--status-info)_8%,transparent)]","hover:bg-[color-mix(in_srgb,var(--status-info)_7%,var(--background))]","active:bg-[color-mix(in_srgb,var(--status-info)_10%,var(--background))]","dark:bg-[color-mix(in_srgb,var(--status-info)_7%,transparent)]","dark:border-[color-mix(in_srgb,var(--status-info)_12%,transparent)]","dark:hover:bg-[color-mix(in_srgb,var(--status-info)_10%,transparent)]","dark:active:bg-[color-mix(in_srgb,var(--status-info)_14%,transparent)]"].join(" "),KC=T9(["group relative inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] typography-ui-label font-medium lowercase tracking-[0.01em] shrink-0 select-none","transition-[background-color,border-color,color,opacity] duration-150 ease-out outline-none","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive","disabled:pointer-events-none disabled:opacity-50","[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"],{variants:{variant:{default:UC,destructive:B(GC,"focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40"),info:WC,neutral:"bg-interactive-hover text-foreground border border-border/60 hover:bg-interactive-active",outline:"bg-[var(--surface-elevated)] text-foreground border border-border/60 hover:bg-interactive-hover hover:text-foreground",chip:B("border border-border/60 bg-transparent text-foreground hover:bg-interactive-hover hover:text-foreground","aria-pressed:bg-[color-mix(in_srgb,var(--primary-base)_10%,var(--background))]","aria-pressed:text-[var(--primary-base)]","aria-pressed:border-[color-mix(in_srgb,var(--primary-base)_12%,transparent)]","aria-pressed:hover:bg-[color-mix(in_srgb,var(--primary-base)_16%,var(--background))]","aria-pressed:hover:text-[var(--primary-base)]","dark:aria-pressed:bg-[color-mix(in_srgb,var(--primary-base)_16%,transparent)]","dark:aria-pressed:border-[color-mix(in_srgb,var(--primary-base)_20%,transparent)]","dark:aria-pressed:hover:bg-[color-mix(in_srgb,var(--primary-base)_22%,transparent)]"),secondary:"bg-interactive-hover text-foreground hover:bg-interactive-active",ghost:"text-foreground hover:bg-interactive-hover hover:text-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-3.5 has-[>svg]:px-3",sm:"h-8 gap-1.5 px-2.5 has-[>svg]:px-2 rounded-[9px] supports-[corner-shape:squircle]:rounded-[50px]",xs:"h-6 gap-1 px-2 typography-micro has-[>svg]:px-1.5 rounded-[7px] supports-[corner-shape:squircle]:rounded-[50px]",lg:"h-10 px-4 has-[>svg]:px-3.5 rounded-[12px] supports-[corner-shape:squircle]:rounded-[50px]",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function a1({className:e,variant:t,size:n,asChild:s=!1,type:o,...r}){const a=s?qC:"button",l=s?o===void 0?{}:{type:o}:{type:o??"button"};return i.jsx(a,{"data-slot":"button",className:B(KC({variant:t,size:n,className:e})),...l,...r})}const YC={add:'<path d="M11 11V5H13V11H19V13H13V19H11V13H5V11H11Z" fill="currentColor"/>',"add-circle":'<path d="M11 11V7H13V11H17V13H13V17H11V13H7V11H11ZM12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20Z" fill="currentColor"/>',"ai-agent":'<path d="M12 2C17.5228 2 22 6.47715 22 12C22 14.7096 20.9205 17.1697 19.1709 18.9697C17.3551 20.8376 14.8124 22 12 22C9.18756 22 6.64488 20.8376 4.8291 18.9697C3.07949 17.1697 2 14.7096 2 12C2 6.47715 6.47715 2 12 2ZM12 16C10.0022 16 8.20124 16.8375 6.9248 18.1816C8.30642 19.3175 10.0724 20 12 20C13.9274 20 15.6927 19.3173 17.0742 18.1816C15.7978 16.8377 13.9975 16 12 16ZM12 4C7.58172 4 4 7.58172 4 12C4 13.7701 4.57462 15.4044 5.54785 16.7295C7.1822 15.0483 9.46797 14 12 14C14.5318 14 16.8169 15.0485 18.4512 16.7295C19.4246 15.4043 20 13.7703 20 12C20 7.58172 16.4183 4 12 4ZM11.5293 5.31934C11.7058 4.89329 12.2943 4.89329 12.4707 5.31934L12.7236 5.93066C13.1556 6.97343 13.9615 7.80622 14.9746 8.25684L15.6924 8.5752C16.1029 8.75796 16.1028 9.35627 15.6924 9.53906L14.9326 9.87695C13.9448 10.3163 13.1534 11.1193 12.7139 12.1279L12.4668 12.6934C12.2864 13.1074 11.7137 13.1074 11.5332 12.6934L11.2871 12.1279C10.8476 11.1193 10.0552 10.3163 9.06738 9.87695L8.30762 9.53906C7.89719 9.35628 7.89717 8.75795 8.30762 8.5752L9.02539 8.25684C10.0385 7.80623 10.8445 6.97345 11.2764 5.93066L11.5293 5.31934Z" fill="currentColor"/>',"ai-agent-fill":'<path d="M12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2ZM12 15C9.71266 15 7.65042 15.961 6.19238 17.5C7.65042 19.039 9.71266 20 12 20C14.2871 20 16.3486 19.0387 17.8066 17.5C16.3486 15.9613 14.2871 15 12 15ZM12.4707 5.31934C12.2943 4.89337 11.7058 4.89339 11.5293 5.31934L11.2764 5.93066C10.8445 6.97341 10.0384 7.80621 9.02539 8.25684L8.30762 8.57617C7.89751 8.75905 7.89744 9.35625 8.30762 9.53906L9.06738 9.87695C10.0551 10.3163 10.8476 11.1193 11.2871 12.1279L11.5332 12.6934C11.7138 13.1073 12.2863 13.1073 12.4668 12.6934L12.7139 12.1279C13.1534 11.1194 13.9449 10.3163 14.9326 9.87695L15.6924 9.53906C16.1026 9.35624 16.1025 8.75907 15.6924 8.57617L14.9746 8.25684C13.9616 7.8062 13.1556 6.9734 12.7236 5.93066L12.4707 5.31934Z" fill="currentColor"/>',"ai-generate-2":'<path d="M20.4668 8.69379L20.7134 8.12811C21.1529 7.11947 21.9445 6.31641 22.9323 5.87708L23.6919 5.53922C24.1027 5.35653 24.1027 4.75881 23.6919 4.57612L22.9748 4.25714C21.9616 3.80651 21.1558 2.97373 20.7238 1.93083L20.4706 1.31953C20.2942 0.893489 19.7058 0.893489 19.5293 1.31953L19.2761 1.93083C18.8442 2.97373 18.0384 3.80651 17.0252 4.25714L16.308 4.57612C15.8973 4.75881 15.8973 5.35653 16.308 5.53922L17.0677 5.87708C18.0555 6.31641 18.8471 7.11947 19.2866 8.12811L19.5331 8.69379C19.7136 9.10792 20.2864 9.10792 20.4668 8.69379ZM5.79993 16H7.95399L8.55399 14.5H11.4459L12.0459 16H14.1999L10.9999 8H8.99993L5.79993 16ZM9.99993 10.8852L10.6459 12.5H9.35399L9.99993 10.8852ZM15 16V8H17V16H15ZM3 3C2.44772 3 2 3.44772 2 4V20C2 20.5523 2.44772 21 3 21H21C21.5523 21 22 20.5523 22 20V11H20V19H4V5H14V3H3Z" fill="currentColor"/>',alert:'<path d="M12.8659 3.00017L22.3922 19.5002C22.6684 19.9785 22.5045 20.5901 22.0262 20.8662C21.8742 20.954 21.7017 21.0002 21.5262 21.0002H2.47363C1.92135 21.0002 1.47363 20.5525 1.47363 20.0002C1.47363 19.8246 1.51984 19.6522 1.60761 19.5002L11.1339 3.00017C11.41 2.52187 12.0216 2.358 12.4999 2.63414C12.6519 2.72191 12.7782 2.84815 12.8659 3.00017ZM4.20568 19.0002H19.7941L11.9999 5.50017L4.20568 19.0002ZM10.9999 16.0002H12.9999V18.0002H10.9999V16.0002ZM10.9999 9.00017H12.9999V14.0002H10.9999V9.00017Z" fill="currentColor"/>',"align-justify":'<path d="M3 4H21V6H3V4ZM3 19H21V21H3V19ZM3 14H21V16H3V14ZM3 9H21V11H3V9Z" fill="currentColor"/>',apple:'<path d="M15.778 8.20793C15.3053 8.1711 14.7974 8.28434 14.0197 8.58067C14.085 8.55577 13.2775 8.87173 13.0511 8.95077C12.5494 9.12593 12.1364 9.22198 11.6734 9.22198C11.2151 9.22198 10.7925 9.13042 10.3078 8.96683C10.1524 8.91441 9.99616 8.8564 9.80283 8.7809C9.71993 8.74852 9.41997 8.62947 9.3544 8.60379C8.70626 8.34996 8.34154 8.25434 8.03885 8.26181C6.88626 8.2765 5.79557 8.9421 5.16246 10.0442C3.87037 12.2875 4.58583 16.3428 6.47459 19.075C7.4802 20.5189 8.03062 21.035 8.25199 21.0279C8.4743 21.0183 8.63777 20.9713 9.03567 20.8026C9.11485 20.7689 9.11485 20.7689 9.202 20.7317C10.2077 20.3032 10.9118 20.114 11.9734 20.114C12.9944 20.114 13.6763 20.2997 14.6416 20.7159C14.7302 20.7542 14.7302 20.7542 14.8097 20.7884C15.2074 20.9588 15.3509 20.9962 15.6016 20.9902C15.9591 20.9846 16.4003 20.5726 17.3791 19.1362C17.6471 18.7447 17.884 18.3333 18.0895 17.9168C17.9573 17.8077 17.826 17.6917 17.6975 17.5693C16.4086 16.3408 15.6114 14.6845 15.5895 12.6391C15.5756 11.0186 16.1057 9.61487 16.999 8.45797C16.6293 8.3142 16.2216 8.23805 15.778 8.20793ZM15.9334 6.21398C16.6414 6.26198 18.6694 6.47798 19.9894 8.40998C19.8814 8.46998 17.5654 9.81397 17.5894 12.622C17.6254 15.982 20.5294 17.098 20.5654 17.11C20.5414 17.194 20.0974 18.706 19.0294 20.266C18.1054 21.622 17.1454 22.966 15.6334 22.99C14.1454 23.026 13.6654 22.114 11.9734 22.114C10.2694 22.114 9.74138 22.966 8.33738 23.026C6.87338 23.074 5.76938 21.562 4.83338 20.218C2.92538 17.458 1.47338 12.442 3.42938 9.04597C4.40138 7.35397 6.12938 6.28598 8.01338 6.26198C9.44138 6.22598 10.7974 7.22198 11.6734 7.22198C12.5374 7.22198 14.0854 6.06998 15.9334 6.21398ZM14.7934 4.38998C14.0134 5.32598 12.7414 6.05798 11.5054 5.96198C11.3374 4.68998 11.9614 3.35798 12.6814 2.52998C13.4854 1.59398 14.8294 0.897976 15.9454 0.849976C16.0894 2.14598 15.5734 3.45398 14.7934 4.38998Z" fill="currentColor"/>',archive:'<path d="M3 10H2V4.00293C2 3.44903 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.43788 22 4.00293V10H21V20.0015C21 20.553 20.5551 21 20.0066 21H3.9934C3.44476 21 3 20.5525 3 20.0015V10ZM19 10H5V19H19V10ZM4 5V8H20V5H4ZM9 12H15V14H9V12Z" fill="currentColor"/>',"archive-stack":'<path d="M4 5H20V3H4V5ZM20 9H4V7H20V9ZM3 11H10V13H14V11H21V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V11ZM16 13V15H8V13H5V19H19V13H16Z" fill="currentColor"/>',"arrow-down":'<path d="M13.0001 16.1716L18.3641 10.8076L19.7783 12.2218L12.0001 20L4.22192 12.2218L5.63614 10.8076L11.0001 16.1716V4H13.0001V16.1716Z" fill="currentColor"/>',"arrow-down-s":'<path d="M11.9999 13.1714L16.9497 8.22168L18.3639 9.63589L11.9999 15.9999L5.63599 9.63589L7.0502 8.22168L11.9999 13.1714Z" fill="currentColor"/>',"arrow-go-back":'<path d="M5.82843 6.99955L8.36396 9.53509L6.94975 10.9493L2 5.99955L6.94975 1.0498L8.36396 2.46402L5.82843 4.99955H13C17.4183 4.99955 21 8.58127 21 12.9996C21 17.4178 17.4183 20.9996 13 20.9996H4V18.9996H13C16.3137 18.9996 19 16.3133 19 12.9996C19 9.68584 16.3137 6.99955 13 6.99955H5.82843Z" fill="currentColor"/>',"arrow-go-forward":'<path d="M18.1716 6.99955H11C7.68629 6.99955 5 9.68584 5 12.9996C5 16.3133 7.68629 18.9996 11 18.9996H20V20.9996H11C6.58172 20.9996 3 17.4178 3 12.9996C3 8.58127 6.58172 4.99955 11 4.99955H18.1716L15.636 2.46402L17.0503 1.0498L22 5.99955L17.0503 10.9493L15.636 9.53509L18.1716 6.99955Z" fill="currentColor"/>',"arrow-left":'<path d="M7.82843 10.9999H20V12.9999H7.82843L13.1924 18.3638L11.7782 19.778L4 11.9999L11.7782 4.22168L13.1924 5.63589L7.82843 10.9999Z" fill="currentColor"/>',"arrow-left-right":'<path d="M16.0503 12.0498L21 16.9996L16.0503 21.9493L14.636 20.5351L17.172 17.9988L4 17.9996V15.9996L17.172 15.9988L14.636 13.464L16.0503 12.0498ZM7.94975 2.0498L9.36396 3.46402L6.828 5.9988L20 5.99955V7.99955L6.828 7.9988L9.36396 10.5351L7.94975 11.9493L3 6.99955L7.94975 2.0498Z" fill="currentColor"/>',"arrow-left-s":'<path d="M10.8284 12.0007L15.7782 16.9504L14.364 18.3646L8 12.0007L14.364 5.63672L15.7782 7.05093L10.8284 12.0007Z" fill="currentColor"/>',"arrow-right":'<path d="M16.1716 10.9999L10.8076 5.63589L12.2218 4.22168L20 11.9999L12.2218 19.778L10.8076 18.3638L16.1716 12.9999H4V10.9999H16.1716Z" fill="currentColor"/>',"arrow-right-s":'<path d="M13.1717 12.0007L8.22192 7.05093L9.63614 5.63672L16.0001 12.0007L9.63614 18.3646L8.22192 16.9504L13.1717 12.0007Z" fill="currentColor"/>',"arrow-up":'<path d="M13.0001 7.82843V20H11.0001V7.82843L5.63614 13.1924L4.22192 11.7782L12.0001 4L19.7783 11.7782L18.3641 13.1924L13.0001 7.82843Z" fill="currentColor"/>',"arrow-up-double":'<path d="M12 4.83582L5.79291 11.0429L7.20712 12.4571L12 7.66424L16.7929 12.4571L18.2071 11.0429L12 4.83582ZM12 10.4857L5.79291 16.6928L7.20712 18.107L12 13.3141L16.7929 18.107L18.2071 16.6928L12 10.4857Z" fill="currentColor"/>',"arrow-up-s":'<path d="M11.9999 10.8284L7.0502 15.7782L5.63599 14.364L11.9999 8L18.3639 14.364L16.9497 15.7782L11.9999 10.8284Z" fill="currentColor"/>',"attachment-2":'<path d="M14.8287 7.75737L9.1718 13.4142C8.78127 13.8047 8.78127 14.4379 9.1718 14.8284C9.56232 15.219 10.1955 15.219 10.586 14.8284L16.2429 9.17158C17.4144 8.00001 17.4144 6.10052 16.2429 4.92894C15.0713 3.75737 13.1718 3.75737 12.0002 4.92894L6.34337 10.5858C4.39075 12.5384 4.39075 15.7042 6.34337 17.6569C8.29599 19.6095 11.4618 19.6095 13.4144 17.6569L19.0713 12L20.4855 13.4142L14.8287 19.0711C12.095 21.8047 7.66283 21.8047 4.92916 19.0711C2.19549 16.3374 2.19549 11.9053 4.92916 9.17158L10.586 3.51473C12.5386 1.56211 15.7045 1.56211 17.6571 3.51473C19.6097 5.46735 19.6097 8.63317 17.6571 10.5858L12.0002 16.2427C10.8287 17.4142 8.92916 17.4142 7.75759 16.2427C6.58601 15.0711 6.58601 13.1716 7.75759 12L13.4144 6.34316L14.8287 7.75737Z" fill="currentColor"/>',"bar-chart-2":'<path d="M2 13H8V21H2V13ZM16 8H22V21H16V8ZM9 3H15V21H9V3ZM4 15V19H6V15H4ZM11 5V19H13V5H11ZM18 10V19H20V10H18Z" fill="currentColor"/>',"bar-chart-box":'<path d="M3 3H21C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3ZM4 5V19H20V5H4ZM7 13H9V17H7V13ZM11 7H13V17H11V7ZM15 10H17V17H15V10Z" fill="currentColor"/>',book:'<path d="M3 18.5V5C3 3.34315 4.34315 2 6 2H20C20.5523 2 21 2.44772 21 3V21C21 21.5523 20.5523 22 20 22H6.5C4.567 22 3 20.433 3 18.5ZM19 20V17H6.5C5.67157 17 5 17.6716 5 18.5C5 19.3284 5.67157 20 6.5 20H19ZM5 15.3368C5.45463 15.1208 5.9632 15 6.5 15H19V4H6C5.44772 4 5 4.44772 5 5V15.3368Z" fill="currentColor"/>',"book-open":'<path d="M13 21V23H11V21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H9C10.1947 3 11.2671 3.52375 12 4.35418C12.7329 3.52375 13.8053 3 15 3H21C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H13ZM20 19V5H15C13.8954 5 13 5.89543 13 7V19H20ZM11 19V7C11 5.89543 10.1046 5 9 5H4V19H11Z" fill="currentColor"/>',booklet:'<path d="M20.0049 2C21.1068 2 22 2.89821 22 3.9908V20.0092C22 21.1087 21.1074 22 20.0049 22H4V18H2V16H4V13H2V11H4V8H2V6H4V2H20.0049ZM8 4H6V20H8V4ZM20 4H10V20H20V4Z" fill="currentColor"/>',braces:'<path d="M4 18V14.3C4 13.4716 3.32843 12.8 2.5 12.8H2V11.2H2.5C3.32843 11.2 4 10.5284 4 9.7V6C4 4.34315 5.34315 3 7 3H8V5H7C6.44772 5 6 5.44772 6 6V10.1C6 10.9858 5.42408 11.7372 4.62623 12C5.42408 12.2628 6 13.0142 6 13.9V18C6 18.5523 6.44772 19 7 19H8V21H7C5.34315 21 4 19.6569 4 18ZM20 14.3V18C20 19.6569 18.6569 21 17 21H16V19H17C17.5523 19 18 18.5523 18 18V13.9C18 13.0142 18.5759 12.2628 19.3738 12C18.5759 11.7372 18 10.9858 18 10.1V6C18 5.44772 17.5523 5 17 5H16V3H17C18.6569 3 20 4.34315 20 6V9.7C20 10.5284 20.6716 11.2 21.5 11.2H22V12.8H21.5C20.6716 12.8 20 13.4716 20 14.3Z" fill="currentColor"/>',brain:'<path d="M9 4C10.1046 4 11 4.89543 11 6V12.8271C10.1058 12.1373 8.96602 11.7305 7.6644 11.5136L7.3356 13.4864C8.71622 13.7165 9.59743 14.1528 10.1402 14.7408C10.67 15.3147 11 16.167 11 17.5C11 18.8807 9.88071 20 8.5 20C7.11929 20 6 18.8807 6 17.5V17.1493C6.43007 17.2926 6.87634 17.4099 7.3356 17.4864L7.6644 15.5136C6.92149 15.3898 6.1752 15.1144 5.42909 14.7599C4.58157 14.3573 4 13.499 4 12.5C4 11.6653 4.20761 11.0085 4.55874 10.5257C4.90441 10.0504 5.4419 9.6703 6.24254 9.47014L7 9.28078V6C7 4.89543 7.89543 4 9 4ZM12 3.35418C11.2671 2.52376 10.1947 2 9 2C6.79086 2 5 3.79086 5 6V7.77422C4.14895 8.11644 3.45143 8.64785 2.94126 9.34933C2.29239 10.2415 2 11.3347 2 12.5C2 14.0652 2.79565 15.4367 4 16.2422V17.5C4 19.9853 6.01472 22 8.5 22C9.91363 22 11.175 21.3482 12 20.3287C12.825 21.3482 14.0864 22 15.5 22C17.9853 22 20 19.9853 20 17.5V16.2422C21.2044 15.4367 22 14.0652 22 12.5C22 11.3347 21.7076 10.2415 21.0587 9.34933C20.5486 8.64785 19.8511 8.11644 19 7.77422V6C19 3.79086 17.2091 2 15 2C13.8053 2 12.7329 2.52376 12 3.35418ZM18 17.1493V17.5C18 18.8807 16.8807 20 15.5 20C14.1193 20 13 18.8807 13 17.5C13 16.167 13.33 15.3147 13.8598 14.7408C14.4026 14.1528 15.2838 13.7165 16.6644 13.4864L16.3356 11.5136C15.034 11.7305 13.8942 12.1373 13 12.8271V6C13 4.89543 13.8954 4 15 4C16.1046 4 17 4.89543 17 6V9.28078L17.7575 9.47014C18.5581 9.6703 19.0956 10.0504 19.4413 10.5257C19.7924 11.0085 20 11.6653 20 12.5C20 13.499 19.4184 14.3573 18.5709 14.7599C17.8248 15.1144 17.0785 15.3898 16.3356 15.5136L16.6644 17.4864C17.1237 17.4099 17.5699 17.2926 18 17.1493Z" fill="currentColor"/>',"brain-ai-3":'<path d="M19.5 4.7832V7.6709L22 9.11426V14.8867L19.499 16.3311L19.5 19.2178L14.5 22.1045L12 20.6611L9.5 22.1045L4.5 19.2178V16.3311L2 14.8877L2.00098 9.11328L4.5 7.66992V4.78418L9.5 1.89746L11.999 3.34082L14.501 1.89648L19.5 4.7832ZM13 5.07227V7H11V5.07324L9.5 4.20703L6.49902 5.93848V8.8252L4 10.2676V13.7334L6.5 15.1768V18.0635L9.5 19.7959L11 18.9287V17H13V18.9297L14.5 19.7959L17.5 18.0625V15.1768L20 13.7324V10.2695L17.499 8.8252L17.5 5.9375L14.501 4.20605L13 5.07227ZM14.2646 13.1602C14.3529 12.9473 14.6472 12.9473 14.7354 13.1602L14.8623 13.4648C15.0783 13.986 15.4807 14.4027 15.9873 14.6279L16.3457 14.7871C16.5511 14.8784 16.5511 15.1773 16.3457 15.2686L15.9658 15.4375C15.4721 15.6571 15.0761 16.0586 14.8564 16.5625L14.7334 16.8447C14.6432 17.0517 14.3569 17.0517 14.2666 16.8447L14.1436 16.5625C13.9239 16.0586 13.5279 15.6571 13.0342 15.4375L12.6543 15.2686C12.4489 15.1773 12.4489 14.8784 12.6543 14.7871L13.0127 14.6279C13.5193 14.4027 13.9217 13.986 14.1377 13.4648L14.2646 13.1602ZM9.58789 7.7793C9.74239 7.40671 10.2577 7.4067 10.4121 7.7793L10.6338 8.31445C11.0118 9.22695 11.7161 9.95624 12.6025 10.3506L13.2305 10.6289C13.5899 10.7887 13.5897 11.3117 13.2305 11.4717L12.5654 11.7676C11.7013 12.152 11.0086 12.8548 10.624 13.7373L10.4082 14.2324C10.2504 14.5948 9.74973 14.5948 9.5918 14.2324L9.37598 13.7373C8.99143 12.8548 8.29875 12.152 7.43457 11.7676L6.76953 11.4717C6.41033 11.3117 6.41022 10.7887 6.76953 10.6289L7.39746 10.3506C8.2839 9.95624 8.98832 9.22697 9.36621 8.31445L9.58789 7.7793Z" fill="currentColor"/>',briefcase:'<path d="M7 5V2C7 1.44772 7.44772 1 8 1H16C16.5523 1 17 1.44772 17 2V5H21C21.5523 5 22 5.44772 22 6V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V6C2 5.44772 2.44772 5 3 5H7ZM4 16V19H20V16H4ZM4 14H20V7H4V14ZM9 3V5H15V3H9ZM11 11H13V13H11V11Z" fill="currentColor"/>',bug:'<path d="M13 19.9C15.2822 19.4367 17 17.419 17 15V12C17 11.299 16.8564 10.6219 16.5846 10H7.41538C7.14358 10.6219 7 11.299 7 12V15C7 17.419 8.71776 19.4367 11 19.9V14H13V19.9ZM5.5358 17.6907C5.19061 16.8623 5 15.9534 5 15H2V13H5V12C5 11.3573 5.08661 10.7348 5.2488 10.1436L3.0359 8.86602L4.0359 7.13397L6.05636 8.30049C6.11995 8.19854 6.18609 8.09835 6.25469 8H17.7453C17.8139 8.09835 17.88 8.19854 17.9436 8.30049L19.9641 7.13397L20.9641 8.86602L18.7512 10.1436C18.9134 10.7348 19 11.3573 19 12V13H22V15H19C19 15.9534 18.8094 16.8623 18.4642 17.6907L20.9641 19.134L19.9641 20.866L17.4383 19.4077C16.1549 20.9893 14.1955 22 12 22C9.80453 22 7.84512 20.9893 6.56171 19.4077L4.0359 20.866L3.0359 19.134L5.5358 17.6907ZM8 6C8 3.79086 9.79086 2 12 2C14.2091 2 16 3.79086 16 6H8Z" fill="currentColor"/>',calendar:'<path d="M9 1V3H15V1H17V3H21C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H7V1H9ZM20 11H4V19H20V11ZM7 5H4V9H20V5H17V7H15V5H9V7H7V5Z" fill="currentColor"/>',"calendar-schedule":'<path d="M7 3V1H9V3H15V1H17V3H21C21.5523 3 22 3.44772 22 4V9H20V5H17V7H15V5H9V7H7V5H4V19H10V21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H7ZM17 12C14.7909 12 13 13.7909 13 16C13 18.2091 14.7909 20 17 20C19.2091 20 21 18.2091 21 16C21 13.7909 19.2091 12 17 12ZM11 16C11 12.6863 13.6863 10 17 10C20.3137 10 23 12.6863 23 16C23 19.3137 20.3137 22 17 22C13.6863 22 11 19.3137 11 16ZM16 13V16.4142L18.2929 18.7071L19.7071 17.2929L18 15.5858V13H16Z" fill="currentColor"/>',camera:'<path d="M9.82843 5L7.82843 7H4V19H20V7H16.1716L14.1716 5H9.82843ZM9 3H15L17 5H21C21.5523 5 22 5.44772 22 6V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V6C2 5.44772 2.44772 5 3 5H7L9 3ZM12 18C8.96243 18 6.5 15.5376 6.5 12.5C6.5 9.46243 8.96243 7 12 7C15.0376 7 17.5 9.46243 17.5 12.5C17.5 15.5376 15.0376 18 12 18ZM12 16C13.933 16 15.5 14.433 15.5 12.5C15.5 10.567 13.933 9 12 9C10.067 9 8.5 10.567 8.5 12.5C8.5 14.433 10.067 16 12 16Z" fill="currentColor"/>',"chat-1":'<path d="M10 3H14C18.4183 3 22 6.58172 22 11C22 15.4183 18.4183 19 14 19V22.5C9 20.5 2 17.5 2 11C2 6.58172 5.58172 3 10 3ZM12 17H14C17.3137 17 20 14.3137 20 11C20 7.68629 17.3137 5 14 5H10C6.68629 5 4 7.68629 4 11C4 14.61 6.46208 16.9656 12 19.4798V17Z" fill="currentColor"/>',"chat-3":'<path d="M7.29117 20.8242L2 22L3.17581 16.7088C2.42544 15.3056 2 13.7025 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C10.2975 22 8.6944 21.5746 7.29117 20.8242ZM7.58075 18.711L8.23428 19.0605C9.38248 19.6745 10.6655 20 12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 13.3345 4.32549 14.6175 4.93949 15.7657L5.28896 16.4192L4.63416 19.3658L7.58075 18.711Z" fill="currentColor"/>',"chat-4":'<path d="M5.76282 17H20V5H4V18.3851L5.76282 17ZM6.45455 19L2 22.5V4C2 3.44772 2.44772 3 3 3H21C21.5523 3 22 3.44772 22 4V18C22 18.5523 21.5523 19 21 19H6.45455Z" fill="currentColor"/>',"chat-ai-3":'<path d="M12 1.99996C12.8632 1.99996 13.701 2.10973 14.5 2.31539L14 4.25192C13.3608 4.0874 12.6906 3.99997 12 3.99997C7.58174 3.99997 4.00002 7.58172 4 12C4 13.3344 4.3255 14.6174 4.93945 15.7656L5.28906 16.4189L4.63379 19.3662L7.58105 18.7109L8.23438 19.0605C9.38255 19.6745 10.6656 20 12 20C16.4183 20 20 16.4183 20 12C20 11.6771 19.9805 11.3587 19.9434 11.0459L21.9297 10.8095C21.976 11.1999 22 11.5972 22 12C22 17.5228 17.5228 22 12 22C10.2975 22 8.69425 21.5746 7.29102 20.8242L2 22L3.17578 16.709C2.42541 15.3057 2 13.7025 2 12C2.00002 6.47714 6.47717 1.99996 12 1.99996ZM19.5293 1.3193C19.7058 0.893513 20.2942 0.8935 20.4707 1.3193L20.7236 1.93063C21.1555 2.97343 21.9615 3.80614 22.9746 4.2568L23.6914 4.57614C24.1022 4.75882 24.1022 5.35635 23.6914 5.53903L22.9326 5.87692C21.945 6.3162 21.1534 7.11943 20.7139 8.1279L20.4668 8.69333C20.2863 9.10747 19.7136 9.10747 19.5332 8.69333L19.2861 8.1279C18.8466 7.11942 18.0551 6.3162 17.0674 5.87692L16.3076 5.53903C15.8974 5.35618 15.8974 4.75895 16.3076 4.57614L17.0254 4.2568C18.0384 3.80614 18.8445 2.97343 19.2764 1.93063L19.5293 1.3193Z" fill="currentColor"/>',"chat-history":'<path d="M12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C10.298 22 8.69525 21.5748 7.29229 20.8248L2 22L3.17629 16.7097C2.42562 15.3063 2 13.7028 2 12C2 6.47715 6.47715 2 12 2ZM12 4C7.58172 4 4 7.58172 4 12C4 13.3347 4.32563 14.6181 4.93987 15.7664L5.28952 16.4201L4.63445 19.3663L7.58189 18.7118L8.23518 19.061C9.38315 19.6747 10.6659 20 12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4ZM13 7V12H17V14H11V7H13Z" fill="currentColor"/>',"chat-new":'<path d="M14 3V5H4V18.3851L5.76282 17H20V10H22V18C22 18.5523 21.5523 19 21 19H6.45455L2 22.5V4C2 3.44772 2.44772 3 3 3H14ZM19 3V0H21V3H24V5H21V8H19V5H16V3H19Z" fill="currentColor"/>',"chat-thread":'<path d="M2 22L7.29117 20.8242C8.6944 21.5746 10.2975 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 13.7025 2.42544 15.3056 3.17581 16.7088L2 22ZM8.23428 19.0605L7.58075 18.711L4.63416 19.3658L5.28896 16.4192L4.93949 15.7657C4.32549 14.6175 4 13.3345 4 12C4 7.58172 7.58172 4 12 4C16.4183 4 20 7.58172 20 12C20 16.4183 16.4183 20 12 20C10.6655 20 9.38248 19.6745 8.23428 19.0605ZM15.4487 7H13.4411L13.2661 9.00024H11.2584L11.4334 7H9.42577L9.25077 9.00024H7V11.0002H9.0758L8.90082 13.0002H7V15.0002H8.72584L8.55089 17H10.5585L10.7335 15.0002H12.7411L12.5662 17H14.5738L14.7488 15.0002H17V13.0002H14.9237L15.0987 11.0002H17V9.00024H15.2737L15.4487 7ZM11.0834 11.0002H13.0911L12.9161 13.0002H10.9085L11.0834 11.0002Z" fill="currentColor"/>',check:'<path d="M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z" fill="currentColor"/>',checkbox:'<path d="M4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM5 5V19H19V5H5ZM11.0026 16L6.75999 11.7574L8.17421 10.3431L11.0026 13.1716L16.6595 7.51472L18.0737 8.92893L11.0026 16Z" fill="currentColor"/>',"checkbox-blank":'<path d="M4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM5 5V19H19V5H5Z" fill="currentColor"/>',"checkbox-blank-circle-fill":'<path d="M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z" fill="currentColor"/>',"checkbox-circle":'<path d="M4 12C4 7.58172 7.58172 4 12 4C16.4183 4 20 7.58172 20 12C20 16.4183 16.4183 20 12 20C7.58172 20 4 16.4183 4 12ZM12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2ZM17.4571 9.45711L16.0429 8.04289L11 13.0858L8.20711 10.2929L6.79289 11.7071L11 15.9142L17.4571 9.45711Z" fill="currentColor"/>',"checkbox-multiple":'<path d="M6.99979 7V3C6.99979 2.44772 7.4475 2 7.99979 2H20.9998C21.5521 2 21.9998 2.44772 21.9998 3V16C21.9998 16.5523 21.5521 17 20.9998 17H17V20.9925C17 21.5489 16.551 22 15.9925 22H3.00728C2.45086 22 2 21.5511 2 20.9925L2.00276 8.00748C2.00288 7.45107 2.4518 7 3.01025 7H6.99979ZM8.99979 7H15.9927C16.549 7 17 7.44892 17 8.00748V15H19.9998V4H8.99979V7ZM15 9H4.00255L4.00021 20H15V9ZM8.50242 18L4.96689 14.4645L6.3811 13.0503L8.50242 15.1716L12.7451 10.9289L14.1593 12.3431L8.50242 18Z" fill="currentColor"/>',clipboard:'<path d="M7 4V2H17V4H20.0066C20.5552 4 21 4.44495 21 4.9934V21.0066C21 21.5552 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5551 3 21.0066V4.9934C3 4.44476 3.44495 4 3.9934 4H7ZM7 6H5V20H19V6H17V8H7V6ZM9 4V6H15V4H9Z" fill="currentColor"/>',close:'<path d="M11.9997 10.5865L16.9495 5.63672L18.3637 7.05093L13.4139 12.0007L18.3637 16.9504L16.9495 18.3646L11.9997 13.4149L7.04996 18.3646L5.63574 16.9504L10.5855 12.0007L5.63574 7.05093L7.04996 5.63672L11.9997 10.5865Z" fill="currentColor"/>',"close-circle":'<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM12 10.5858L14.8284 7.75736L16.2426 9.17157L13.4142 12L16.2426 14.8284L14.8284 16.2426L12 13.4142L9.17157 16.2426L7.75736 14.8284L10.5858 12L7.75736 9.17157L9.17157 7.75736L12 10.5858Z" fill="currentColor"/>',cloud:'<path d="M12 2C15.866 2 19 5.13401 19 9C19 9.11351 18.9973 9.22639 18.992 9.33857C21.3265 10.16 23 12.3846 23 15C23 18.3137 20.3137 21 17 21H7C3.68629 21 1 18.3137 1 15C1 12.3846 2.67346 10.16 5.00804 9.33857C5.0027 9.22639 5 9.11351 5 9C5 5.13401 8.13401 2 12 2ZM12 4C9.23858 4 7 6.23858 7 9C7 9.08147 7.00193 9.16263 7.00578 9.24344L7.07662 10.7309L5.67183 11.2252C4.0844 11.7837 3 13.2889 3 15C3 17.2091 4.79086 19 7 19H17C19.2091 19 21 17.2091 21 15C21 12.79 19.21 11 17 11C15.233 11 13.7337 12.1457 13.2042 13.7347L11.3064 13.1021C12.1005 10.7185 14.35 9 17 9C17 6.23858 14.7614 4 12 4Z" fill="currentColor"/>',"cloud-off":'<path d="M3.51472 2.10051L22.6066 21.1924L21.1924 22.6066L19.1782 20.5924C18.503 20.8556 17.7684 21 17 21H7C3.68629 21 1 18.3137 1 15C1 12.3846 2.67346 10.16 5.00804 9.33857C5.0027 9.22639 5 9.11351 5 9C5 8.22228 5.12683 7.47418 5.36094 6.77527L2.10051 3.51472L3.51472 2.10051ZM7 9C7 9.08147 7.00193 9.16263 7.00578 9.24344L7.07662 10.7309L5.67183 11.2252C4.0844 11.7837 3 13.2889 3 15C3 17.2091 4.79086 19 7 19H17C17.1858 19 17.3687 18.9873 17.5478 18.9628L7.03043 8.44519C7.01032 8.62736 7 8.81247 7 9ZM12 2C15.866 2 19 5.13401 19 9C19 9.11351 18.9973 9.22639 18.992 9.33857C21.3265 10.16 23 12.3846 23 15C23 16.0883 22.7103 17.1089 22.2037 17.9889L20.7111 16.4955C20.8974 16.0335 21 15.5287 21 15C21 12.79 19.21 11 17 11C16.4711 11 15.9661 11.1027 15.5039 11.2892L14.0111 9.7964C14.8912 9.28978 15.9118 9 17 9C17 6.23858 14.7614 4 12 4C10.9295 4 9.93766 4.33639 9.12428 4.90922L7.69418 3.48056C8.88169 2.55284 10.3763 2 12 2Z" fill="currentColor"/>',code:'<path d="M23 12L15.9289 19.0711L14.5147 17.6569L20.1716 12L14.5147 6.34317L15.9289 4.92896L23 12ZM3.82843 12L9.48528 17.6569L8.07107 19.0711L1 12L8.07107 4.92896L9.48528 6.34317L3.82843 12Z" fill="currentColor"/>',"code-ai":'<path d="M17.7134 10.1281L17.4668 10.6938C17.2864 11.1079 16.7136 11.1079 16.5331 10.6938L16.2866 10.1281C15.8471 9.11947 15.0555 8.31641 14.0677 7.87708L13.308 7.53922C12.8973 7.35653 12.8973 6.75881 13.308 6.57612L14.0252 6.25714C15.0384 5.80651 15.8442 4.97373 16.2761 3.93083L16.5293 3.31953C16.7058 2.89349 17.2942 2.89349 17.4706 3.31953L17.7238 3.93083C18.1558 4.97373 18.9616 5.80651 19.9748 6.25714L20.6919 6.57612C21.1027 6.75881 21.1027 7.35653 20.6919 7.53922L19.9323 7.87708C18.9445 8.31641 18.1529 9.11947 17.7134 10.1281ZM2.82843 12.0001L7.07107 16.2428L5.65685 17.657L0 12.0001L5.65685 6.34326L7.07107 7.75748L2.82843 12.0001ZM18.3429 17.6572L23.9998 12.0003L21.1714 9.17188L19.7571 10.5861L21.1714 12.0003L16.9287 16.2429L18.3429 17.6572Z" fill="currentColor"/>',"code-box":'<path d="M3 3H21C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3ZM4 5V19H20V5H4ZM20 12L16.4645 15.5355L15.0503 14.1213L17.1716 12L15.0503 9.87868L16.4645 8.46447L20 12ZM6.82843 12L8.94975 14.1213L7.53553 15.5355L4 12L7.53553 8.46447L8.94975 9.87868L6.82843 12ZM11.2443 17H9.11597L12.7557 7H14.884L11.2443 17Z" fill="currentColor"/>',"code-sslash":'<path d="M24 12L18.3431 17.6569L16.9289 16.2426L21.1716 12L16.9289 7.75736L18.3431 6.34315L24 12ZM2.82843 12L7.07107 16.2426L5.65685 17.6569L0 12L5.65685 6.34315L7.07107 7.75736L2.82843 12ZM9.78845 21H7.66009L14.2116 3H16.3399L9.78845 21Z" fill="currentColor"/>',"collapse-vertical":'<path d="M11.9995 13.4995 16.9492 18.4493 15.535 19.8635 12.9995 17.3279 12.9995 22.9995H10.9995L10.9995 17.3279 8.46643 19.861 7.05222 18.4468 11.9995 13.4995ZM10.9995.999512 10.9995 6.67035 8.46448 4.13535 7.05026 5.54956 12 10.4995 16.9497 5.54977 15.5355 4.13555 12.9995 6.67157V.999512L10.9995.999512Z" fill="currentColor"/>',command:'<path d="M10 8H14V6.5C14 4.567 15.567 3 17.5 3C19.433 3 21 4.567 21 6.5C21 8.433 19.433 10 17.5 10H16V14H17.5C19.433 14 21 15.567 21 17.5C21 19.433 19.433 21 17.5 21C15.567 21 14 19.433 14 17.5V16H10V17.5C10 19.433 8.433 21 6.5 21C4.567 21 3 19.433 3 17.5C3 15.567 4.567 14 6.5 14H8V10H6.5C4.567 10 3 8.433 3 6.5C3 4.567 4.567 3 6.5 3C8.433 3 10 4.567 10 6.5V8ZM8 8V6.5C8 5.67157 7.32843 5 6.5 5C5.67157 5 5 5.67157 5 6.5C5 7.32843 5.67157 8 6.5 8H8ZM8 16H6.5C5.67157 16 5 16.6716 5 17.5C5 18.3284 5.67157 19 6.5 19C7.32843 19 8 18.3284 8 17.5V16ZM16 8H17.5C18.3284 8 19 7.32843 19 6.5C19 5.67157 18.3284 5 17.5 5C16.6716 5 16 5.67157 16 6.5V8ZM16 16V17.5C16 18.3284 16.6716 19 17.5 19C18.3284 19 19 18.3284 19 17.5C19 16.6716 18.3284 16 17.5 16H16ZM10 10V14H14V10H10Z" fill="currentColor"/>',"compass-3":'<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM16.5 7.5L14 14L7.5 16.5L10 10L16.5 7.5ZM12 13C12.5523 13 13 12.5523 13 12C13 11.4477 12.5523 11 12 11C11.4477 11 11 11.4477 11 12C11 12.5523 11.4477 13 12 13Z" fill="currentColor"/>',computer:'<path d="M4 16H20V5H4V16ZM13 18V20H17V22H7V20H11V18H2.9918C2.44405 18 2 17.5511 2 16.9925V4.00748C2 3.45107 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44892 22 4.00748V16.9925C22 17.5489 21.5447 18 21.0082 18H13Z" fill="currentColor"/>',"contract-up-down":'<path d="M5.79285 5.20718 12 11.4143 18.2071 5.20718 16.7928 3.79297 12 8.58586 7.20706 3.79297 5.79285 5.20718ZM18.2072 18.7928 12.0001 12.5857 5.793 18.7928 7.20721 20.207 12.0001 15.4141 16.793 20.207 18.2072 18.7928Z" fill="currentColor"/>',"corner-down-left":'<path d="M19.0001 13.9999L19.0002 5L17.0002 4.99997L17.0001 11.9999L6.8283 12L10.778 8.05024L9.36382 6.63603L2.99986 13L9.36382 19.364L10.778 17.9497L6.82826 14L19.0001 13.9999Z" fill="currentColor"/>',cursor:'<path d="M15.3873 13.4975L17.9403 20.5117L13.2418 22.2218L10.6889 15.2076L6.79004 17.6529L8.4086 1.63318L19.9457 12.8646L15.3873 13.4975ZM15.3768 19.3163L12.6618 11.8568L15.6212 11.4459L9.98201 5.9561L9.19088 13.7863L11.7221 12.1988L14.4371 19.6583L15.3768 19.3163Z" fill="currentColor"/>',"database-2":'<path d="M5 12.5C5 12.8134 5.46101 13.3584 6.53047 13.8931C7.91405 14.5849 9.87677 15 12 15C14.1232 15 16.0859 14.5849 17.4695 13.8931C18.539 13.3584 19 12.8134 19 12.5V10.3287C17.35 11.3482 14.8273 12 12 12C9.17273 12 6.64996 11.3482 5 10.3287V12.5ZM19 15.3287C17.35 16.3482 14.8273 17 12 17C9.17273 17 6.64996 16.3482 5 15.3287V17.5C5 17.8134 5.46101 18.3584 6.53047 18.8931C7.91405 19.5849 9.87677 20 12 20C14.1232 20 16.0859 19.5849 17.4695 18.8931C18.539 18.3584 19 17.8134 19 17.5V15.3287ZM3 17.5V7.5C3 5.01472 7.02944 3 12 3C16.9706 3 21 5.01472 21 7.5V17.5C21 19.9853 16.9706 22 12 22C7.02944 22 3 19.9853 3 17.5ZM12 10C14.1232 10 16.0859 9.58492 17.4695 8.89313C18.539 8.3584 19 7.81342 19 7.5C19 7.18658 18.539 6.6416 17.4695 6.10687C16.0859 5.41508 14.1232 5 12 5C9.87677 5 7.91405 5.41508 6.53047 6.10687C5.46101 6.6416 5 7.18658 5 7.5C5 7.81342 5.46101 8.3584 6.53047 8.89313C7.91405 9.58492 9.87677 10 12 10Z" fill="currentColor"/>',"delete-bin":'<path d="M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM18 8H6V20H18V8ZM9 11H11V17H9V11ZM13 11H15V17H13V11ZM9 4V6H15V4H9Z" fill="currentColor"/>',"discord-fill":'<path d="M19.3034 5.33716C17.9344 4.71103 16.4805 4.2547 14.9629 4C14.7719 4.32899 14.5596 4.77471 14.411 5.12492C12.7969 4.89144 11.1944 4.89144 9.60255 5.12492C9.45397 4.77471 9.2311 4.32899 9.05068 4C7.52251 4.2547 6.06861 4.71103 4.70915 5.33716C1.96053 9.39111 1.21766 13.3495 1.5891 17.2549C3.41443 18.5815 5.17612 19.388 6.90701 19.9187C7.33151 19.3456 7.71356 18.73 8.04255 18.0827C7.41641 17.8492 6.82211 17.5627 6.24904 17.2231C6.39762 17.117 6.5462 17.0003 6.68416 16.8835C10.1438 18.4648 13.8911 18.4648 17.3082 16.8835C17.4568 17.0003 17.5948 17.117 17.7434 17.2231C17.1703 17.5627 16.576 17.8492 15.9499 18.0827C16.2789 18.73 16.6609 19.3456 17.0854 19.9187C18.8152 19.388 20.5875 18.5815 22.4033 17.2549C22.8596 12.7341 21.6806 8.80747 19.3034 5.33716ZM8.5201 14.8459C7.48007 14.8459 6.63107 13.9014 6.63107 12.7447C6.63107 11.5879 7.45884 10.6434 8.5201 10.6434C9.57071 10.6434 10.4303 11.5879 10.4091 12.7447C10.4091 13.9014 9.57071 14.8459 8.5201 14.8459ZM15.4936 14.8459C14.4535 14.8459 13.6034 13.9014 13.6034 12.7447C13.6034 11.5879 14.4323 10.6434 15.4936 10.6434C16.5442 10.6434 17.4038 11.5879 17.3825 12.7447C17.3825 13.9014 16.5548 14.8459 15.4936 14.8459Z" fill="currentColor"/>',"donut-chart":'<path d="M10.9999 2.04938L11 4.06188C7.05371 4.55396 4 7.92036 4 12C4 16.4183 7.58172 20 12 20C13.8487 20 15.5509 19.3729 16.9055 18.3199L18.3289 19.7428C16.605 21.1536 14.4014 22 12 22C6.47715 22 2 17.5228 2 12C2 6.81468 5.94662 2.55115 10.9999 2.04938ZM21.9506 13.0001C21.7509 15.0111 20.9555 16.8468 19.7433 18.3283L18.3199 16.9055C19.1801 15.799 19.756 14.4606 19.9381 12.9999L21.9506 13.0001ZM13.0011 2.04948C17.725 2.51902 21.4815 6.27589 21.9506 10.9999L19.9381 11C19.4869 7.38162 16.6192 4.51364 13.001 4.062L13.0011 2.04948Z" fill="currentColor"/>',"donut-chart-fill":'<path d="M10.9999 2.04938L11 5.07088C7.6077 5.55612 5 8.47352 5 12C5 15.866 8.13401 19 12 19C13.5723 19 15.0236 18.4816 16.1922 17.6064L18.3289 19.7428C16.605 21.1536 14.4014 22 12 22C6.47715 22 2 17.5228 2 12C2 6.81468 5.94662 2.55115 10.9999 2.04938ZM21.9506 13.0001C21.7509 15.0111 20.9555 16.8468 19.7433 18.3283L17.6064 16.1922C18.2926 15.2759 18.7595 14.1859 18.9291 13L21.9506 13.0001ZM13.0011 2.04948C17.725 2.51902 21.4815 6.27589 21.9506 10.9999L18.9291 10.9998C18.4905 7.93452 16.0661 5.50992 13.001 5.07103L13.0011 2.04948Z" fill="currentColor"/>',download:'<path d="M3 19H21V21H3V19ZM13 13.1716L19.0711 7.1005L20.4853 8.51472L12 17L3.51472 8.51472L4.92893 7.1005L11 13.1716V2H13V13.1716Z" fill="currentColor"/>',"download-cloud":'<path d="M1 14.5C1 12.1716 2.22429 10.1291 4.06426 8.9812C4.56469 5.044 7.92686 2 12 2C16.0731 2 19.4353 5.044 19.9357 8.9812C21.7757 10.1291 23 12.1716 23 14.5C23 17.9216 20.3562 20.7257 17 20.9811L7 21C3.64378 20.7257 1 17.9216 1 14.5ZM16.8483 18.9868C19.1817 18.8093 21 16.8561 21 14.5C21 12.927 20.1884 11.4962 18.8771 10.6781L18.0714 10.1754L17.9517 9.23338C17.5735 6.25803 15.0288 4 12 4C8.97116 4 6.42647 6.25803 6.0483 9.23338L5.92856 10.1754L5.12288 10.6781C3.81156 11.4962 3 12.927 3 14.5C3 16.8561 4.81833 18.8093 7.1517 18.9868L7.325 19H16.675L16.8483 18.9868ZM13 12H16L12 17L8 12H11V8H13V12Z" fill="currentColor"/>',"drag-move-2":'<path d="M11 11V5.82843L9.17157 7.65685L7.75736 6.24264L12 2L16.2426 6.24264L14.8284 7.65685L13 5.82843V11H18.1716L16.3431 9.17157L17.7574 7.75736L22 12L17.7574 16.2426L16.3431 14.8284L18.1716 13H13V18.1716L14.8284 16.3431L16.2426 17.7574L12 22L7.75736 17.7574L9.17157 16.3431L11 18.1716V13H5.82843L7.65685 14.8284L6.24264 16.2426L2 12L6.24264 7.75736L7.65685 9.17157L5.82843 11H11Z" fill="currentColor"/>',draggable:'<path d="M8.5 7C9.32843 7 10 6.32843 10 5.5C10 4.67157 9.32843 4 8.5 4C7.67157 4 7 4.67157 7 5.5C7 6.32843 7.67157 7 8.5 7ZM8.5 13.5C9.32843 13.5 10 12.8284 10 12C10 11.1716 9.32843 10.5 8.5 10.5C7.67157 10.5 7 11.1716 7 12C7 12.8284 7.67157 13.5 8.5 13.5ZM10 18.5C10 19.3284 9.32843 20 8.5 20C7.67157 20 7 19.3284 7 18.5C7 17.6716 7.67157 17 8.5 17C9.32843 17 10 17.6716 10 18.5ZM15.5 7C16.3284 7 17 6.32843 17 5.5C17 4.67157 16.3284 4 15.5 4C14.6716 4 14 4.67157 14 5.5C14 6.32843 14.6716 7 15.5 7ZM17 12C17 12.8284 16.3284 13.5 15.5 13.5C14.6716 13.5 14 12.8284 14 12C14 11.1716 14.6716 10.5 15.5 10.5C16.3284 10.5 17 11.1716 17 12ZM15.5 20C16.3284 20 17 19.3284 17 18.5C17 17.6716 16.3284 17 15.5 17C14.6716 17 14 17.6716 14 18.5C14 19.3284 14.6716 20 15.5 20Z" fill="currentColor"/>',edit:'<path d="M6.41421 15.89L16.5563 5.74785L15.1421 4.33363L5 14.4758V15.89H6.41421ZM7.24264 17.89H3V13.6473L14.435 2.21231C14.8256 1.82179 15.4587 1.82179 15.8492 2.21231L18.6777 5.04074C19.0682 5.43126 19.0682 6.06443 18.6777 6.45495L7.24264 17.89ZM3 19.89H21V21.89H3V19.89Z" fill="currentColor"/>',"edit-2":'<path d="M5 18.89H6.41421L15.7279 9.57627L14.3137 8.16206L5 17.4758V18.89ZM21 20.89H3V16.6473L16.435 3.21231C16.8256 2.82179 17.4587 2.82179 17.8492 3.21231L20.6777 6.04074C21.0682 6.43126 21.0682 7.06443 20.6777 7.45495L9.24264 18.89H21V20.89ZM15.7279 6.74785L17.1421 8.16206L18.5563 6.74785L17.1421 5.33363L15.7279 6.74785Z" fill="currentColor"/>',"emotion-happy":'<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM7 13H9C9 14.6569 10.3431 16 12 16C13.6569 16 15 14.6569 15 13H17C17 15.7614 14.7614 18 12 18C9.23858 18 7 15.7614 7 13ZM8 11C7.17157 11 6.5 10.3284 6.5 9.5C6.5 8.67157 7.17157 8 8 8C8.82843 8 9.5 8.67157 9.5 9.5C9.5 10.3284 8.82843 11 8 11ZM16 11C15.1716 11 14.5 10.3284 14.5 9.5C14.5 8.67157 15.1716 8 16 8C16.8284 8 17.5 8.67157 17.5 9.5C17.5 10.3284 16.8284 11 16 11Z" fill="currentColor"/>',"equalizer-2":'<path d="M5 7C5 6.17157 5.67157 5.5 6.5 5.5C7.32843 5.5 8 6.17157 8 7C8 7.82843 7.32843 8.5 6.5 8.5C5.67157 8.5 5 7.82843 5 7ZM6.5 3.5C4.567 3.5 3 5.067 3 7C3 8.933 4.567 10.5 6.5 10.5C8.433 10.5 10 8.933 10 7C10 5.067 8.433 3.5 6.5 3.5ZM12 8H20V6H12V8ZM16 17C16 16.1716 16.6716 15.5 17.5 15.5C18.3284 15.5 19 16.1716 19 17C19 17.8284 18.3284 18.5 17.5 18.5C16.6716 18.5 16 17.8284 16 17ZM17.5 13.5C15.567 13.5 14 15.067 14 17C14 18.933 15.567 20.5 17.5 20.5C19.433 20.5 21 18.933 21 17C21 15.067 19.433 13.5 17.5 13.5ZM4 16V18H12V16H4Z" fill="currentColor"/>',"error-warning":'<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM11 15H13V17H11V15ZM11 7H13V13H11V7Z" fill="currentColor"/>',"expand-up-down":'<path d="M18.2072 9.0428 12.0001 2.83569 5.793 9.0428 7.20721 10.457 12.0001 5.66412 16.793 10.457 18.2072 9.0428ZM5.79285 14.9572 12 21.1643 18.2071 14.9572 16.7928 13.543 12 18.3359 7.20706 13.543 5.79285 14.9572Z" fill="currentColor"/>',"external-link":'<path d="M10 6V8H5V19H16V14H18V20C18 20.5523 17.5523 21 17 21H4C3.44772 21 3 20.5523 3 20V7C3 6.44772 3.44772 6 4 6H10ZM21 3V11H19L18.9999 6.413L11.2071 14.2071L9.79289 12.7929L17.5849 5H13V3H21Z" fill="currentColor"/>',eye:'<path d="M12.0003 3C17.3924 3 21.8784 6.87976 22.8189 12C21.8784 17.1202 17.3924 21 12.0003 21C6.60812 21 2.12215 17.1202 1.18164 12C2.12215 6.87976 6.60812 3 12.0003 3ZM12.0003 19C16.2359 19 19.8603 16.052 20.7777 12C19.8603 7.94803 16.2359 5 12.0003 5C7.7646 5 4.14022 7.94803 3.22278 12C4.14022 16.052 7.7646 19 12.0003 19ZM12.0003 16.5C9.51498 16.5 7.50026 14.4853 7.50026 12C7.50026 9.51472 9.51498 7.5 12.0003 7.5C14.4855 7.5 16.5003 9.51472 16.5003 12C16.5003 14.4853 14.4855 16.5 12.0003 16.5ZM12.0003 14.5C13.381 14.5 14.5003 13.3807 14.5003 12C14.5003 10.6193 13.381 9.5 12.0003 9.5C10.6196 9.5 9.50026 10.6193 9.50026 12C9.50026 13.3807 10.6196 14.5 12.0003 14.5Z" fill="currentColor"/>',"eye-off":'<path d="M17.8827 19.2968C16.1814 20.3755 14.1638 21.0002 12.0003 21.0002C6.60812 21.0002 2.12215 17.1204 1.18164 12.0002C1.61832 9.62282 2.81932 7.5129 4.52047 5.93457L1.39366 2.80777L2.80788 1.39355L22.6069 21.1925L21.1927 22.6068L17.8827 19.2968ZM5.9356 7.3497C4.60673 8.56015 3.6378 10.1672 3.22278 12.0002C4.14022 16.0521 7.7646 19.0002 12.0003 19.0002C13.5997 19.0002 15.112 18.5798 16.4243 17.8384L14.396 15.8101C13.7023 16.2472 12.8808 16.5002 12.0003 16.5002C9.51498 16.5002 7.50026 14.4854 7.50026 12.0002C7.50026 11.1196 7.75317 10.2981 8.19031 9.60442L5.9356 7.3497ZM12.9139 14.328L9.67246 11.0866C9.5613 11.3696 9.50026 11.6777 9.50026 12.0002C9.50026 13.3809 10.6196 14.5002 12.0003 14.5002C12.3227 14.5002 12.6309 14.4391 12.9139 14.328ZM20.8068 16.5925L19.376 15.1617C20.0319 14.2268 20.5154 13.1586 20.7777 12.0002C19.8603 7.94818 16.2359 5.00016 12.0003 5.00016C11.1544 5.00016 10.3329 5.11773 9.55249 5.33818L7.97446 3.76015C9.22127 3.26959 10.5793 3.00016 12.0003 3.00016C17.3924 3.00016 21.8784 6.87992 22.8189 12.0002C22.5067 13.6998 21.8038 15.2628 20.8068 16.5925ZM11.7229 7.50857C11.8146 7.50299 11.9071 7.50016 12.0003 7.50016C14.4855 7.50016 16.5003 9.51488 16.5003 12.0002C16.5003 12.0933 16.4974 12.1858 16.4919 12.2775L11.7229 7.50857Z" fill="currentColor"/>',file:'<path d="M9 2.00318V2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8L9 2.00318ZM5.82918 8H9V4.83086L5.82918 8ZM11 4V9C11 9.55228 10.5523 10 10 10H5V20H19V4H11Z" fill="currentColor"/>',"file-add":'<path d="M15 4H5V20H19V8H15V4ZM3 2.9918C3 2.44405 3.44749 2 3.9985 2H16L20.9997 7L21 20.9925C21 21.5489 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918ZM11 11V8H13V11H16V13H13V16H11V13H8V11H11Z" fill="currentColor"/>',"file-check":'<path d="M12 20V22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918C3 2.44405 3.44749 2 3.9985 2H16L20.9998 7V14H19V8H15V4H5V20H12ZM14.4646 19.4647L18.0001 23.0002L22.9498 18.0505L21.5356 16.6362L18.0001 20.1718L15.8788 18.0505L14.4646 19.4647Z" fill="currentColor"/>',"file-check-fill":'<path d="M20.9998 7L16 2H3.9985C3.44749 2 3 2.44405 3 2.9918V21.0082C3 21.5447 3.44476 22 3.9934 22H12.3414C12.1203 21.3744 12 20.7013 12 20C12 16.6863 14.6863 14 18 14C19.0928 14 20.1174 14.2922 20.9999 14.8026L20.9998 7ZM14.4646 19.4647L18.0001 23.0002L22.9498 18.0505L21.5356 16.6362L18.0001 20.1718L15.8788 18.0505L14.4646 19.4647Z" fill="currentColor"/>',"file-code":'<path d="M15 4H5V20H19V8H15V4ZM3 2.9918C3 2.44405 3.44749 2 3.9985 2H16L20.9997 7L21 20.9925C21 21.5489 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918ZM17.6569 12L14.1213 15.5355L12.7071 14.1213L14.8284 12L12.7071 9.87868L14.1213 8.46447L17.6569 12ZM6.34315 12L9.87868 8.46447L11.2929 9.87868L9.17157 12L11.2929 14.1213L9.87868 15.5355L6.34315 12Z" fill="currentColor"/>',"file-copy":'<path d="M6.9998 6V3C6.9998 2.44772 7.44752 2 7.9998 2H19.9998C20.5521 2 20.9998 2.44772 20.9998 3V17C20.9998 17.5523 20.5521 18 19.9998 18H16.9998V20.9991C16.9998 21.5519 16.5499 22 15.993 22H4.00666C3.45059 22 3 21.5554 3 20.9991L3.0026 7.00087C3.0027 6.44811 3.45264 6 4.00942 6H6.9998ZM5.00242 8L5.00019 20H14.9998V8H5.00242ZM8.9998 6H16.9998V16H18.9998V4H8.9998V6Z" fill="currentColor"/>',"file-copy-2":'<path d="M6.9998 6V3C6.9998 2.44772 7.44752 2 7.9998 2H19.9998C20.5521 2 20.9998 2.44772 20.9998 3V17C20.9998 17.5523 20.5521 18 19.9998 18H16.9998V20.9991C16.9998 21.5519 16.5499 22 15.993 22H4.00666C3.45059 22 3 21.5554 3 20.9991L3.0026 7.00087C3.0027 6.44811 3.45264 6 4.00942 6H6.9998ZM5.00242 8L5.00019 20H14.9998V8H5.00242ZM8.9998 6H16.9998V16H18.9998V4H8.9998V6ZM7 11H13V13H7V11ZM7 15H13V17H7V15Z" fill="currentColor"/>',"file-download":'<path d="M13 12H16L12 16L8 12H11V8H13V12ZM15 4H5V20H19V8H15V4ZM3 2.9918C3 2.44405 3.44749 2 3.9985 2H16L20.9997 7L21 20.9925C21 21.5489 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918Z" fill="currentColor"/>',"file-edit":'<path d="M21 6.75736L19 8.75736V4H10V9H5V20H19V17.2426L21 15.2426V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V6.75736ZM21.7782 8.80761L23.1924 10.2218L15.4142 18L13.9979 17.9979L14 16.5858L21.7782 8.80761Z" fill="currentColor"/>',"file-image":'<path d="M15 8V4H5V20H19V8H15ZM3 2.9918C3 2.44405 3.44749 2 3.9985 2H16L20.9997 7L21 20.9925C21 21.5489 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918ZM11 9.5C11 10.3284 10.3284 11 9.5 11C8.67157 11 8 10.3284 8 9.5C8 8.67157 8.67157 8 9.5 8C10.3284 8 11 8.67157 11 9.5ZM17.5 17L13.5 10L8 17H17.5Z" fill="currentColor"/>',"file-list-2":'<path d="M20 22H4C3.44772 22 3 21.5523 3 21V3C3 2.44772 3.44772 2 4 2H20C20.5523 2 21 2.44772 21 3V21C21 21.5523 20.5523 22 20 22ZM19 20V4H5V20H19ZM8 7H16V9H8V7ZM8 11H16V13H8V11ZM8 15H13V17H8V15Z" fill="currentColor"/>',"file-music":'<path d="M16 8V10H13V14.5C13 15.8807 11.8807 17 10.5 17C9.11929 17 8 15.8807 8 14.5C8 13.1193 9.11929 12 10.5 12C10.6712 12 10.8384 12.0172 11 12.05V8H15V4H5V20H19V8H16ZM3 2.9918C3 2.44405 3.44749 2 3.9985 2H16L20.9997 7L21 20.9925C21 21.5489 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918Z" fill="currentColor"/>',"file-pdf":'<path d="M12 16H8V8H12C14.2091 8 16 9.79086 16 12C16 14.2091 14.2091 16 12 16ZM10 10V14H12C13.1046 14 14 13.1046 14 12C14 10.8954 13.1046 10 12 10H10ZM15 4H5V20H19V8H15V4ZM3 2.9918C3 2.44405 3.44749 2 3.9985 2H16L20.9997 7L21 20.9925C21 21.5489 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918Z" fill="currentColor"/>',"file-search":'<path d="M15 4H5V20H19V8H15V4ZM3 2.9918C3 2.44405 3.44749 2 3.9985 2H16L20.9997 7L21 20.9925C21 21.5489 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918ZM13.529 14.4464C11.9951 15.3524 9.98633 15.1464 8.66839 13.8284C7.1063 12.2663 7.1063 9.73367 8.66839 8.17157C10.2305 6.60948 12.7631 6.60948 14.3252 8.17157C15.6432 9.48951 15.8492 11.4983 14.9432 13.0322L17.1537 15.2426L15.7395 16.6569L13.529 14.4464ZM12.911 12.4142C13.6921 11.6332 13.6921 10.3668 12.911 9.58579C12.13 8.80474 10.8637 8.80474 10.0826 9.58579C9.30156 10.3668 9.30156 11.6332 10.0826 12.4142C10.8637 13.1953 12.13 13.1953 12.911 12.4142Z" fill="currentColor"/>',"file-text":'<path d="M21 8V20.9932C21 21.5501 20.5552 22 20.0066 22H3.9934C3.44495 22 3 21.556 3 21.0082V2.9918C3 2.45531 3.4487 2 4.00221 2H14.9968L21 8ZM19 9H14V4H5V20H19V9ZM8 7H11V9H8V7ZM8 11H16V13H8V11ZM8 15H16V17H8V15Z" fill="currentColor"/>',"file-transfer":'<path d="M15 4H5V20H19V8H15V4ZM3 2.9918C3 2.44405 3.44749 2 3.9985 2H16L20.9997 7L21 20.9925C21 21.5489 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918ZM12 11V8L16 12L12 16V13H8V11H12Z" fill="currentColor"/>',"file-video":'<path d="M15 4V8H19V20H5V4H15ZM3.9985 2C3.44749 2 3 2.44405 3 2.9918V21.0082C3 21.5447 3.44476 22 3.9934 22H20.0066C20.5551 22 21 21.5489 21 20.9925L20.9997 7L16 2H3.9985ZM15.0008 11.667L10.1219 8.41435C10.0562 8.37054 9.979 8.34717 9.9 8.34717C9.6791 8.34717 9.5 8.52625 9.5 8.74717V15.2524C9.5 15.3314 9.5234 15.4086 9.5672 15.4743C9.6897 15.6581 9.9381 15.7078 10.1219 15.5852L15.0008 12.3326C15.0447 12.3033 15.0824 12.2656 15.1117 12.2217C15.2343 12.0379 15.1846 11.7895 15.0008 11.667Z" fill="currentColor"/>',fingerprint:'<path d="M17.0003 13V14C17.0003 16.7696 16.3364 19.445 15.0853 21.8455L14.8585 22.2663L13.1116 21.2924C14.2716 19.2115 14.9211 16.8817 14.9935 14.4559L15.0003 14V13H17.0003ZM11.0003 10H13.0003V14L12.9948 14.3787C12.9153 17.1495 11.9645 19.7731 10.3038 21.928L10.073 22.2189L8.52406 20.9536C10.0408 19.0969 10.9145 16.8017 10.9943 14.3663L11.0003 14V10ZM12.0003 6C14.7617 6 17.0003 8.23858 17.0003 11H15.0003C15.0003 9.34315 13.6571 8 12.0003 8C10.3434 8 9.00025 9.34315 9.00025 11V14C9.00025 16.2354 8.1806 18.3444 6.72928 19.9768L6.51767 20.2067L5.06955 18.8273C6.23328 17.6056 6.92099 16.0118 6.99381 14.3027L7.00025 14V11C7.00025 8.23858 9.23883 6 12.0003 6ZM12.0003 2C16.9708 2 21.0003 6.02944 21.0003 11V14C21.0003 15.6979 20.7985 17.3699 20.4035 18.9903L20.2647 19.5285L18.3349 19.0032C18.726 17.5662 18.9475 16.0808 18.9919 14.5684L19.0003 14V11C19.0003 7.13401 15.8662 4 12.0003 4C10.4279 4 8.97663 4.51841 7.80805 5.39364L6.38308 3.96769C7.92267 2.73631 9.87547 2 12.0003 2ZM4.96794 5.38282L6.39389 6.8078C5.5635 7.91652 5.0543 9.27971 5.00431 10.7593L4.99961 10.999L5.00378 13C5.00378 14.1195 4.73991 15.2026 4.24263 16.1772L4.08648 16.4663L2.34961 15.4747C2.72889 14.8103 2.95077 14.0681 2.99539 13.2924L3.00378 13L3.00361 11C3.00025 8.87522 3.73656 6.92242 4.96794 5.38282Z" fill="currentColor"/>',flashlight:'<path d="M13 9H21L11 24V15H4L13 0V9ZM11 11V7.22063L7.53238 13H13V17.3944L17.263 11H11Z" fill="currentColor"/>',flask:'<path d="M15.9994 2V4H14.9994V7.24291C14.9994 8.40051 15.2506 9.54432 15.7357 10.5954L20.017 19.8714C20.3641 20.6236 20.0358 21.5148 19.2836 21.8619C19.0865 21.9529 18.8721 22 18.655 22H5.34375C4.51532 22 3.84375 21.3284 3.84375 20.5C3.84375 20.2829 3.89085 20.0685 3.98181 19.8714L8.26306 10.5954C8.74816 9.54432 8.99939 8.40051 8.99939 7.24291V4H7.99939V2H15.9994ZM13.3873 10.0012H10.6115C10.5072 10.3644 10.3823 10.7221 10.2371 11.0724L10.079 11.4335L6.12439 20H17.8734L13.9198 11.4335C13.7054 10.9691 13.5276 10.4902 13.3873 10.0012ZM10.9994 7.24291C10.9994 7.49626 10.9898 7.7491 10.9706 8.00087H13.0282C13.0189 7.87982 13.0119 7.75852 13.0072 7.63704L12.9994 7.24291V4H10.9994V7.24291Z" fill="currentColor"/>',folder:'<path d="M4 5V19H20V7H11.5858L9.58579 5H4ZM12.4142 5H21C21.5523 5 22 5.44772 22 6V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H10.4142L12.4142 5Z" fill="currentColor"/>',"folder-3":'<path d="M12.4142 5H21C21.5523 5 22 5.44772 22 6V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H10.4142L12.4142 5ZM4 7V19H20V7H4Z" fill="currentColor"/>',"folder-3-fill":'<path d="M22 8V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V7H21C21.5523 7 22 7.44772 22 8ZM12.4142 5H2V4C2 3.44772 2.44772 3 3 3H10.4142L12.4142 5Z" fill="currentColor"/>',"folder-6":'<path d="M2 4C2 3.44772 2.44772 3 3 3H10.4142L12.4142 5H21C21.5523 5 22 5.44772 22 6V20C22 20.5523 21.5523 21 21 21L3 21C2.45 21 2 20.55 2 20V4ZM10.5858 6L9.58579 5H4V7H9.58579L10.5858 6ZM4 9V19L20 19V7H12.4142L10.4142 9H4Z" fill="currentColor"/>',"folder-add":'<path d="M12.4142 5H21C21.5523 5 22 5.44772 22 6V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H10.4142L12.4142 5ZM4 5V19H20V7H11.5858L9.58579 5H4ZM11 12V9H13V12H16V14H13V17H11V14H8V12H11Z" fill="currentColor"/>',"folder-open":'<path d="M3 21C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H10.4142L12.4142 5H20C20.5523 5 21 5.44772 21 6V9H19V7H11.5858L9.58579 5H4V16.998L5.5 11H22.5L20.1894 20.2425C20.0781 20.6877 19.6781 21 19.2192 21H3ZM19.9384 13H7.06155L5.56155 19H18.4384L19.9384 13Z" fill="currentColor"/>',"folder-open-fill":'<path d="M3 21C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H10.4142L12.4142 5H20C20.5523 5 21 5.44772 21 6V9H4V18.996L6 11H22.5L20.1894 20.2425C20.0781 20.6877 19.6781 21 19.2192 21H3Z" fill="currentColor"/>',"folder-received":'<path d="M22 13H20V7H11.5858L9.58579 5H4V19H13V21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H10.4142L12.4142 5H21C21.5523 5 22 5.44772 22 6V13ZM20 17H23V19H20V22.5L15 18L20 13.5V17Z" fill="currentColor"/>',"folder-shared":'<path d="M22 13H20V7H11.5858L9.58579 5H4V19H13V21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H10.4142L12.4142 5H21C21.5523 5 22 5.44772 22 6V13ZM18 17V13.5L23 18L18 22.5V19H15V17H18Z" fill="currentColor"/>',folders:'<path d="M6 7V4C6 3.44772 6.44772 3 7 3H13.4142L15.4142 5H21C21.5523 5 22 5.44772 22 6V16C22 16.5523 21.5523 17 21 17H18V20C18 20.5523 17.5523 21 17 21H3C2.44772 21 2 20.5523 2 20V8C2 7.44772 2.44772 7 3 7H6ZM6 9H4V19H16V17H6V9ZM8 5V15H20V7H14.5858L12.5858 5H8Z" fill="currentColor"/>',fullscreen:'<path d="M8 3V5H4V9H2V3H8ZM2 21V15H4V19H8V21H2ZM22 21H16V19H20V15H22V21ZM22 9H20V5H16V3H22V9Z" fill="currentColor"/>',"fullscreen-exit":'<path d="M18 7H22V9H16V3H18V7ZM8 9H2V7H6V3H8V9ZM18 17V21H16V15H22V17H18ZM8 15V21H6V17H2V15H8Z" fill="currentColor"/>',gamepad:'<path d="M17 4C20.3137 4 23 6.68629 23 10V14C23 17.3137 20.3137 20 17 20H7C3.68629 20 1 17.3137 1 14V10C1 6.68629 3.68629 4 7 4H17ZM17 6H7C4.8578 6 3.10892 7.68397 3.0049 9.80036L3 10V14C3 16.1422 4.68397 17.8911 6.80036 17.9951L7 18H17C19.1422 18 20.8911 16.316 20.9951 14.1996L21 14V10C21 7.8578 19.316 6.10892 17.1996 6.0049L17 6ZM10 9V11H12V13H9.999L10 15H8L7.999 13H6V11H8V9H10ZM18 13V15H16V13H18ZM16 9V11H14V9H16Z" fill="currentColor"/>',"git-branch":'<path d="M7.10508 15.2101C8.21506 15.6501 9 16.7334 9 18C9 19.6569 7.65685 21 6 21C4.34315 21 3 19.6569 3 18C3 16.6938 3.83481 15.5825 5 15.1707V8.82929C3.83481 8.41746 3 7.30622 3 6C3 4.34315 4.34315 3 6 3C7.65685 3 9 4.34315 9 6C9 7.30622 8.16519 8.41746 7 8.82929V11.9996C7.83566 11.3719 8.87439 11 10 11H14C15.3835 11 16.5482 10.0635 16.8949 8.78991C15.7849 8.34988 15 7.26661 15 6C15 4.34315 16.3431 3 18 3C19.6569 3 21 4.34315 21 6C21 7.3332 20.1303 8.46329 18.9274 8.85392C18.5222 11.2085 16.4703 13 14 13H10C8.61653 13 7.45179 13.9365 7.10508 15.2101ZM6 17C5.44772 17 5 17.4477 5 18C5 18.5523 5.44772 19 6 19C6.55228 19 7 18.5523 7 18C7 17.4477 6.55228 17 6 17ZM6 5C5.44772 5 5 5.44772 5 6C5 6.55228 5.44772 7 6 7C6.55228 7 7 6.55228 7 6C7 5.44772 6.55228 5 6 5ZM18 5C17.4477 5 17 5.44772 17 6C17 6.55228 17.4477 7 18 7C18.5523 7 19 6.55228 19 6C19 5.44772 18.5523 5 18 5Z" fill="currentColor"/>',"git-close-pull-request":'<path d="M6 5C5.44772 5 5 5.44772 5 6C5 6.55228 5.44772 7 6 7C6.55228 7 7 6.55228 7 6C7 5.44772 6.55228 5 6 5ZM3 6C3 4.34315 4.34315 3 6 3C7.65685 3 9 4.34315 9 6C9 7.30622 8.16519 8.41746 7 8.82929V15.1707C8.16519 15.5825 9 16.6938 9 18C9 19.6569 7.65685 21 6 21C4.34315 21 3 19.6569 3 18C3 16.6938 3.83481 15.5825 5 15.1707V8.82929C3.83481 8.41746 3 7.30622 3 6ZM15.2929 3.29289C15.6834 2.90237 16.3166 2.90237 16.7071 3.29289L18 4.58579L19.2929 3.29289C19.6834 2.90237 20.3166 2.90237 20.7071 3.29289C21.0976 3.68342 21.0976 4.31658 20.7071 4.70711L19.4142 6L20.7071 7.29289C21.0976 7.68342 21.0976 8.31658 20.7071 8.70711C20.3166 9.09763 19.6834 9.09763 19.2929 8.70711L18 7.41421L16.7071 8.70711C16.3166 9.09763 15.6834 9.09763 15.2929 8.70711C14.9024 8.31658 14.9024 7.68342 15.2929 7.29289L16.5858 6L15.2929 4.70711C14.9024 4.31658 14.9024 3.68342 15.2929 3.29289ZM18 10C18.5523 10 19 10.4477 19 11V15.1707C20.1652 15.5825 21 16.6938 21 18C21 19.6569 19.6569 21 18 21C16.3431 21 15 19.6569 15 18C15 16.6938 15.8348 15.5825 17 15.1707V11C17 10.4477 17.4477 10 18 10ZM6 17C5.44772 17 5 17.4477 5 18C5 18.5523 5.44772 19 6 19C6.55228 19 7 18.5523 7 18C7 17.4477 6.55228 17 6 17ZM18 17C17.4477 17 17 17.4477 17 18C17 18.5523 17.4477 19 18 19C18.5523 19 19 18.5523 19 18C19 17.4477 18.5523 17 18 17Z" fill="currentColor"/>',"git-commit":'<path d="M15.874 13C15.4299 14.7252 13.8638 16 12 16C10.1362 16 8.57006 14.7252 8.12602 13H3V11H8.12602C8.57006 9.27477 10.1362 8 12 8C13.8638 8 15.4299 9.27477 15.874 11H21V13H15.874ZM12 14C13.1046 14 14 13.1046 14 12C14 10.8954 13.1046 10 12 10C10.8954 10 10 10.8954 10 12C10 13.1046 10.8954 14 12 14Z" fill="currentColor"/>',"git-merge":'<path d="M7.10508 8.78991C7.45179 10.0635 8.61653 11 10 11H14C16.4703 11 18.5222 12.7915 18.9274 15.1461C20.1303 15.5367 21 16.6668 21 18C21 19.6569 19.6569 21 18 21C16.3431 21 15 19.6569 15 18C15 16.7334 15.7849 15.6501 16.8949 15.2101C16.5482 13.9365 15.3835 13 14 13H10C8.87439 13 7.83566 12.6281 7 12.0004V15.1707C8.16519 15.5825 9 16.6938 9 18C9 19.6569 7.65685 21 6 21C4.34315 21 3 19.6569 3 18C3 16.6938 3.83481 15.5825 5 15.1707V8.82929C3.83481 8.41746 3 7.30622 3 6C3 4.34315 4.34315 3 6 3C7.65685 3 9 4.34315 9 6C9 7.26661 8.21506 8.34988 7.10508 8.78991ZM6 7C6.55228 7 7 6.55228 7 6C7 5.44772 6.55228 5 6 5C5.44772 5 5 5.44772 5 6C5 6.55228 5.44772 7 6 7ZM6 19C6.55228 19 7 18.5523 7 18C7 17.4477 6.55228 17 6 17C5.44772 17 5 17.4477 5 18C5 18.5523 5.44772 19 6 19ZM18 19C18.5523 19 19 18.5523 19 18C19 17.4477 18.5523 17 18 17C17.4477 17 17 17.4477 17 18C17 18.5523 17.4477 19 18 19Z" fill="currentColor"/>',"git-pr-draft":'<path d="M5 6C5 5.44772 5.44772 5 6 5C6.55228 5 7 5.44772 7 6C7 6.55228 6.55228 7 6 7C5.44772 7 5 6.55228 5 6ZM6 3C4.34315 3 3 4.34315 3 6C3 7.30622 3.83481 8.41746 5 8.82929V15.1707C3.83481 15.5825 3 16.6938 3 18C3 19.6569 4.34315 21 6 21C7.65685 21 9 19.6569 9 18C9 16.6938 8.16519 15.5825 7 15.1707V8.82929C8.16519 8.41746 9 7.30622 9 6C9 4.34315 7.65685 3 6 3ZM5 18C5 17.4477 5.44772 17 6 17C6.55228 17 7 17.4477 7 18C7 18.5523 6.55228 19 6 19C5.44772 19 5 18.5523 5 18ZM18 17C17.4477 17 17 17.4477 17 18C17 18.5523 17.4477 19 18 19C18.5523 19 19 18.5523 19 18C19 17.4477 18.5523 17 18 17ZM15 18C15 16.3431 16.3431 15 18 15C19.6569 15 21 16.3431 21 18C21 19.6569 19.6569 21 18 21C16.3431 21 15 19.6569 15 18ZM18 7.5C18.8284 7.5 19.5 6.82843 19.5 6C19.5 5.17157 18.8284 4.5 18 4.5C17.1716 4.5 16.5 5.17157 16.5 6C16.5 6.82843 17.1716 7.5 18 7.5ZM19.5 11.5C19.5 12.3284 18.8284 13 18 13C17.1716 13 16.5 12.3284 16.5 11.5C16.5 10.6716 17.1716 10 18 10C18.8284 10 19.5 10.6716 19.5 11.5Z" fill="currentColor"/>',"git-pull-request":'<path d="M15 5H17C18.1046 5 19 5.89543 19 7V15.1707C20.1652 15.5825 21 16.6938 21 18C21 19.6569 19.6569 21 18 21C16.3431 21 15 19.6569 15 18C15 16.6938 15.8348 15.5825 17 15.1707V7H15V10L10.5 6L15 2V5ZM5 8.82929C3.83481 8.41746 3 7.30622 3 6C3 4.34315 4.34315 3 6 3C7.65685 3 9 4.34315 9 6C9 7.30622 8.16519 8.41746 7 8.82929V15.1707C8.16519 15.5825 9 16.6938 9 18C9 19.6569 7.65685 21 6 21C4.34315 21 3 19.6569 3 18C3 16.6938 3.83481 15.5825 5 15.1707V8.82929ZM6 7C6.55228 7 7 6.55228 7 6C7 5.44772 6.55228 5 6 5C5.44772 5 5 5.44772 5 6C5 6.55228 5.44772 7 6 7ZM6 19C6.55228 19 7 18.5523 7 18C7 17.4477 6.55228 17 6 17C5.44772 17 5 17.4477 5 18C5 18.5523 5.44772 19 6 19ZM18 19C18.5523 19 19 18.5523 19 18C19 17.4477 18.5523 17 18 17C17.4477 17 17 17.4477 17 18C17 18.5523 17.4477 19 18 19Z" fill="currentColor"/>',"git-repository":'<path d="M13 21V23.5L10 21.5L7 23.5V21H6.5C4.567 21 3 19.433 3 17.5V5C3 3.34315 4.34315 2 6 2H20C20.5523 2 21 2.44772 21 3V20C21 20.5523 20.5523 21 20 21H13ZM13 19H19V16H6.5C5.67157 16 5 16.6716 5 17.5C5 18.3284 5.67157 19 6.5 19H7V17H13V19ZM19 14V4H6V14.0354C6.1633 14.0121 6.33024 14 6.5 14H19ZM7 5H9V7H7V5ZM7 8H9V10H7V8ZM7 11H9V13H7V11Z" fill="currentColor"/>',github:'<path d="M5.88401 18.6533C5.58404 18.4526 5.32587 18.1975 5.0239 17.8369C4.91473 17.7065 4.47283 17.1524 4.55811 17.2583C4.09533 16.6833 3.80296 16.417 3.50156 16.3089C2.9817 16.1225 2.7114 15.5499 2.89784 15.0301C3.08428 14.5102 3.65685 14.2399 4.17672 14.4263C4.92936 14.6963 5.43847 15.1611 6.12425 16.0143C6.03025 15.8974 6.46364 16.441 6.55731 16.5529C6.74784 16.7804 6.88732 16.9182 6.99629 16.9911C7.20118 17.1283 7.58451 17.1874 8.14709 17.1311C8.17065 16.7489 8.24136 16.3783 8.34919 16.0358C5.38097 15.3104 3.70116 13.3952 3.70116 9.63971C3.70116 8.40085 4.0704 7.28393 4.75917 6.3478C4.5415 5.45392 4.57433 4.37284 5.06092 3.15636C5.1725 2.87739 5.40361 2.66338 5.69031 2.57352C5.77242 2.54973 5.81791 2.53915 5.89878 2.52673C6.70167 2.40343 7.83573 2.69705 9.31449 3.62336C10.181 3.41879 11.0885 3.315 12.0012 3.315C12.9129 3.315 13.8196 3.4186 14.6854 3.62277C16.1619 2.69 17.2986 2.39649 18.1072 2.52651C18.1919 2.54013 18.2645 2.55783 18.3249 2.57766C18.6059 2.66991 18.8316 2.88179 18.9414 3.15636C19.4279 4.37256 19.4608 5.45344 19.2433 6.3472C19.9342 7.28337 20.3012 8.39208 20.3012 9.63971C20.3012 13.3968 18.627 15.3048 15.6588 16.032C15.7837 16.447 15.8496 16.9105 15.8496 17.4121C15.8496 18.0765 15.8471 18.711 15.8424 19.4225C15.8412 19.6127 15.8397 19.8159 15.8375 20.1281C16.2129 20.2109 16.5229 20.5077 16.6031 20.9089C16.7114 21.4504 16.3602 21.9773 15.8186 22.0856C14.6794 22.3134 13.8353 21.5538 13.8353 20.5611C13.8353 20.4708 13.836 20.3417 13.8375 20.1145C13.8398 19.8015 13.8412 19.599 13.8425 19.4094C13.8471 18.7019 13.8496 18.0716 13.8496 17.4121C13.8496 16.7148 13.6664 16.2602 13.4237 16.051C12.7627 15.4812 13.0977 14.3973 13.965 14.2999C16.9314 13.9666 18.3012 12.8177 18.3012 9.63971C18.3012 8.68508 17.9893 7.89571 17.3881 7.23559C17.1301 6.95233 17.0567 6.54659 17.199 6.19087C17.3647 5.77663 17.4354 5.23384 17.2941 4.57702L17.2847 4.57968C16.7928 4.71886 16.1744 5.0198 15.4261 5.5285C15.182 5.69438 14.8772 5.74401 14.5932 5.66413C13.7729 5.43343 12.8913 5.315 12.0012 5.315C11.111 5.315 10.2294 5.43343 9.40916 5.66413C9.12662 5.74359 8.82344 5.69492 8.57997 5.53101C7.8274 5.02439 7.2056 4.72379 6.71079 4.58376C6.56735 5.23696 6.63814 5.77782 6.80336 6.19087C6.94565 6.54659 6.87219 6.95233 6.61423 7.23559C6.01715 7.8912 5.70116 8.69376 5.70116 9.63971C5.70116 12.8116 7.07225 13.9683 10.023 14.2999C10.8883 14.3971 11.2246 15.4769 10.5675 16.0482C10.3751 16.2156 10.1384 16.7802 10.1384 17.4121V20.5611C10.1384 21.5474 9.30356 22.2869 8.17878 22.09C7.63476 21.9948 7.27093 21.4766 7.36613 20.9326C7.43827 20.5204 7.75331 20.2116 8.13841 20.1276V19.1381C7.22829 19.1994 6.47656 19.0498 5.88401 18.6533Z" fill="currentColor"/>',"github-fill":'<path d="M12.001 2C6.47598 2 2.00098 6.475 2.00098 12C2.00098 16.425 4.86348 20.1625 8.83848 21.4875C9.33848 21.575 9.52598 21.275 9.52598 21.0125C9.52598 20.775 9.51348 19.9875 9.51348 19.15C7.00098 19.6125 6.35098 18.5375 6.15098 17.975C6.03848 17.6875 5.55098 16.8 5.12598 16.5625C4.77598 16.375 4.27598 15.9125 5.11348 15.9C5.90098 15.8875 6.46348 16.625 6.65098 16.925C7.55098 18.4375 8.98848 18.0125 9.56348 17.75C9.65098 17.1 9.91348 16.6625 10.201 16.4125C7.97598 16.1625 5.65098 15.3 5.65098 11.475C5.65098 10.3875 6.03848 9.4875 6.67598 8.7875C6.57598 8.5375 6.22598 7.5125 6.77598 6.1375C6.77598 6.1375 7.61348 5.875 9.52598 7.1625C10.326 6.9375 11.176 6.825 12.026 6.825C12.876 6.825 13.726 6.9375 14.526 7.1625C16.4385 5.8625 17.276 6.1375 17.276 6.1375C17.826 7.5125 17.476 8.5375 17.376 8.7875C18.0135 9.4875 18.401 10.375 18.401 11.475C18.401 15.3125 16.0635 16.1625 13.8385 16.4125C14.201 16.725 14.5135 17.325 14.5135 18.2625C14.5135 19.6 14.501 20.675 14.501 21.0125C14.501 21.275 14.6885 21.5875 15.1885 21.4875C19.259 20.1133 21.9999 16.2963 22.001 12C22.001 6.475 17.526 2 12.001 2Z" fill="currentColor"/>',global:'<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM9.71002 19.6674C8.74743 17.6259 8.15732 15.3742 8.02731 13H4.06189C4.458 16.1765 6.71639 18.7747 9.71002 19.6674ZM10.0307 13C10.1811 15.4388 10.8778 17.7297 12 19.752C13.1222 17.7297 13.8189 15.4388 13.9693 13H10.0307ZM19.9381 13H15.9727C15.8427 15.3742 15.2526 17.6259 14.29 19.6674C17.2836 18.7747 19.542 16.1765 19.9381 13ZM4.06189 11H8.02731C8.15732 8.62577 8.74743 6.37407 9.71002 4.33256C6.71639 5.22533 4.458 7.8235 4.06189 11ZM10.0307 11H13.9693C13.8189 8.56122 13.1222 6.27025 12 4.24799C10.8778 6.27025 10.1811 8.56122 10.0307 11ZM14.29 4.33256C15.2526 6.37407 15.8427 8.62577 15.9727 11H19.9381C19.542 7.8235 17.2836 5.22533 14.29 4.33256Z" fill="currentColor"/>',"graduation-cap":'<path d="M4 11.3333L0 9L12 2L24 9V17.5H22V10.1667L20 11.3333V18.0113L19.7774 18.2864C17.9457 20.5499 15.1418 22 12 22C8.85817 22 6.05429 20.5499 4.22263 18.2864L4 18.0113V11.3333ZM6 12.5V17.2917C7.46721 18.954 9.61112 20 12 20C14.3889 20 16.5328 18.954 18 17.2917V12.5L12 16L6 12.5ZM3.96927 9L12 13.6846L20.0307 9L12 4.31541L3.96927 9Z" fill="currentColor"/>',hammer:'<path d="M20 2C20.5523 2 21 2.44772 21 3V8C21 8.55228 20.5523 9 20 9H15V22C15 22.5523 14.5523 23 14 23H10C9.44772 23 9 22.5523 9 22V9H3.5C2.94772 9 2.5 8.55228 2.5 8V5.61803C2.5 5.23926 2.714 4.893 3.05279 4.72361L8.5 2H20ZM15 4H8.97214L4.5 6.23607V7H11V21H13V7H15V4ZM19 4H17V7H19V4Z" fill="currentColor"/>',heart:'<path d="M12.001 4.52853C14.35 2.42 17.98 2.49 20.2426 4.75736C22.5053 7.02472 22.583 10.637 20.4786 12.993L11.9999 21.485L3.52138 12.993C1.41705 10.637 1.49571 7.01901 3.75736 4.75736C6.02157 2.49315 9.64519 2.41687 12.001 4.52853ZM18.827 6.1701C17.3279 4.66794 14.9076 4.60701 13.337 6.01687L12.0019 7.21524L10.6661 6.01781C9.09098 4.60597 6.67506 4.66808 5.17157 6.17157C3.68183 7.66131 3.60704 10.0473 4.97993 11.6232L11.9999 18.6543L19.0201 11.6232C20.3935 10.0467 20.319 7.66525 18.827 6.1701Z" fill="currentColor"/>',history:'<path d="M12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12H4C4 16.4183 7.58172 20 12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C9.25022 4 6.82447 5.38734 5.38451 7.50024L8 7.5V9.5H2V3.5H4L3.99989 5.99918C5.82434 3.57075 8.72873 2 12 2ZM13 7L12.9998 11.585L16.2426 14.8284L14.8284 16.2426L10.9998 12.413L11 7H13Z" fill="currentColor"/>',home:'<path d="M21 20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V9.48907C3 9.18048 3.14247 8.88917 3.38606 8.69972L11.3861 2.47749C11.7472 2.19663 12.2528 2.19663 12.6139 2.47749L20.6139 8.69972C20.8575 8.88917 21 9.18048 21 9.48907V20ZM19 19V9.97815L12 4.53371L5 9.97815V19H19Z" fill="currentColor"/>',"home-office":'<path d="M12.6727 1.61162 20.7999 9H17.8267L12 3.70302 6 9.15757V19.0001H11V21.0001H5C4.44772 21.0001 4 20.5524 4 20.0001V11.0001L1 11.0001 11.3273 1.61162C11.7087 1.26488 12.2913 1.26488 12.6727 1.61162ZM14 11H23V18H14V11ZM16 13V16H21V13H16ZM24 21H13V19H24V21Z" fill="currentColor"/>',hourglass:'<path d="M6 4H4V2H20V4H18V6C18 7.61543 17.1838 8.91468 16.1561 9.97667C15.4532 10.703 14.598 11.372 13.7309 12C14.598 12.628 15.4532 13.297 16.1561 14.0233C17.1838 15.0853 18 16.3846 18 18V20H20V22H4V20H6V18C6 16.3846 6.81616 15.0853 7.8439 14.0233C8.54682 13.297 9.40202 12.628 10.2691 12C9.40202 11.372 8.54682 10.703 7.8439 9.97667C6.81616 8.91468 6 7.61543 6 6V4ZM8 4V6C8 6.88457 8.43384 7.71032 9.2811 8.58583C10.008 9.33699 10.9548 10.0398 12 10.7781C13.0452 10.0398 13.992 9.33699 14.7189 8.58583C15.5662 7.71032 16 6.88457 16 6V4H8ZM12 13.2219C10.9548 13.9602 10.008 14.663 9.2811 15.4142C8.43384 16.2897 8 17.1154 8 18V20H16V18C16 17.1154 15.5662 16.2897 14.7189 15.4142C13.992 14.663 13.0452 13.9602 12 13.2219Z" fill="currentColor"/>',"hourglass-fill":'<path d="M6 4H4V2H20V4H18V6C18 7.61543 17.1838 8.91468 16.1561 9.97667C15.4532 10.703 14.598 11.372 13.7309 12C14.598 12.628 15.4532 13.297 16.1561 14.0233C17.1838 15.0853 18 16.3846 18 18V20H20V22H4V20H6V18C6 16.3846 6.81616 15.0853 7.8439 14.0233C8.54682 13.297 9.40202 12.628 10.2691 12C9.40202 11.372 8.54682 10.703 7.8439 9.97667C6.81616 8.91468 6 7.61543 6 6V4ZM8 4V6C8 6.68514 8.26026 7.33499 8.77131 8H15.2287C15.7397 7.33499 16 6.68514 16 6V4H8ZM12 13.2219C10.9548 13.9602 10.008 14.663 9.2811 15.4142C9.09008 15.6116 8.92007 15.8064 8.77131 16H15.2287C15.0799 15.8064 14.9099 15.6116 14.7189 15.4142C13.992 14.663 13.0452 13.9602 12 13.2219Z" fill="currentColor"/>',"image-download":'<path d="M21 15V19H24L20 23L16 19H19V15H21ZM21.0078 3C21.5555 3 21.9999 3.44482 22 3.99316V13H20V5H4V18.999L14 9L17 12V14.8291L14 11.8281L6.82715 19H14V21H2.99219C2.44451 21 2.00013 20.5552 2 20.0068V3.99316C2.00013 3.44463 2.45577 3 2.99219 3H21.0078ZM8 7C9.10457 7 10 7.89543 10 9C10 10.1046 9.10457 11 8 11C6.89543 11 6 10.1046 6 9C6 7.89543 6.89543 7 8 7Z" fill="currentColor"/>',"inbox-archive":'<path d="M20 3L22 7V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V7.00353L4 3H20ZM20 9H4V19H20V9ZM13 10V14H16L12 18L8 14H11V10H13ZM18.7639 5H5.23656L4.23744 7H19.7639L18.7639 5Z" fill="currentColor"/>',"inbox-unarchive":'<path d="M20 3L22 7V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V7.00353L4 3H20ZM20 9H4V19H20V9ZM12 10L16 14H13V18H11V14H8L12 10ZM18.764 5H5.236L4.237 7H19.764L18.764 5Z" fill="currentColor"/>',"inbox-unarchive-fill":'<path d="M20 3L22 7V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V7.00353L4 3H20ZM12 10L8 14H11V18H13V14H16L12 10ZM18.764 5H5.236L4.237 7H19.764L18.764 5Z" fill="currentColor"/>',information:'<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM11 7H13V9H11V7ZM11 11H13V17H11V11Z" fill="currentColor"/>',key:'<path d="M12.917 13C12.441 15.8377 9.973 18 7 18C3.68629 18 1 15.3137 1 12C1 8.68629 3.68629 6 7 6C9.973 6 12.441 8.16229 12.917 11H23V13H21V17H19V13H17V17H15V13H12.917ZM7 16C9.20914 16 11 14.2091 11 12C11 9.79086 9.20914 8 7 8C4.79086 8 3 9.79086 3 12C3 14.2091 4.79086 16 7 16Z" fill="currentColor"/>',"layout-column":'<path d="M11 5H5V19H11V5ZM13 5V19H19V5H13ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3Z" fill="currentColor"/>',"layout-left":'<path d="M21 3C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H21ZM7 5H4V19H7V5ZM20 5H9V19H20V5Z" fill="currentColor"/>',"layout-right":'<path d="M21 3C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H21ZM15 5H4V19H15V5ZM20 5H17V19H20V5Z" fill="currentColor"/>',leaf:'<path d="M20.998 3V5C20.998 14.6274 15.6255 19 8.99805 19L5.24077 18.9999C5.0786 19.912 4.99805 20.907 4.99805 22H2.99805C2.99805 20.6373 3.11376 19.3997 3.34381 18.2682C3.1133 16.9741 2.99805 15.2176 2.99805 13C2.99805 7.47715 7.4752 3 12.998 3C14.998 3 16.998 4 20.998 3ZM12.998 5C8.57977 5 4.99805 8.58172 4.99805 13C4.99805 13.3624 5.00125 13.7111 5.00759 14.0459C6.26198 12.0684 8.09902 10.5048 10.5019 9.13176L11.4942 10.8682C8.6393 12.4996 6.74554 14.3535 5.77329 16.9998L8.99805 17C15.0132 17 18.8692 13.0269 18.9949 5.38766C17.6229 5.52113 16.3481 5.436 14.7754 5.20009C13.6243 5.02742 13.3988 5 12.998 5Z" fill="currentColor"/>',lightbulb:'<path d="M9.97308 18H11V13H13V18H14.0269C14.1589 16.7984 14.7721 15.8065 15.7676 14.7226C15.8797 14.6006 16.5988 13.8564 16.6841 13.7501C17.5318 12.6931 18 11.385 18 10C18 6.68629 15.3137 4 12 4C8.68629 4 6 6.68629 6 10C6 11.3843 6.46774 12.6917 7.31462 13.7484C7.40004 13.855 8.12081 14.6012 8.23154 14.7218C9.22766 15.8064 9.84103 16.7984 9.97308 18ZM10 20V21H14V20H10ZM5.75395 14.9992C4.65645 13.6297 4 11.8915 4 10C4 5.58172 7.58172 2 12 2C16.4183 2 20 5.58172 20 10C20 11.8925 19.3428 13.6315 18.2443 15.0014C17.624 15.7748 16 17 16 18.5V21C16 22.1046 15.1046 23 14 23H10C8.89543 23 8 22.1046 8 21V18.5C8 17 6.37458 15.7736 5.75395 14.9992Z" fill="currentColor"/>',"link-unlink-m":'<path d="M17.657 14.8284L16.2428 13.4142L17.657 12C19.2191 10.4379 19.2191 7.90526 17.657 6.34316C16.0949 4.78106 13.5622 4.78106 12.0001 6.34316L10.5859 7.75737L9.17171 6.34316L10.5859 4.92895C12.9291 2.5858 16.7281 2.5858 19.0712 4.92895C21.4143 7.27209 21.4143 11.0711 19.0712 13.4142L17.657 14.8284ZM14.8286 17.6569L13.4143 19.0711C11.0712 21.4142 7.27221 21.4142 4.92907 19.0711C2.58592 16.7279 2.58592 12.9289 4.92907 10.5858L6.34328 9.17159L7.75749 10.5858L6.34328 12C4.78118 13.5621 4.78118 16.0948 6.34328 17.6569C7.90538 19.219 10.438 19.219 12.0001 17.6569L13.4143 16.2427L14.8286 17.6569ZM14.8286 7.75737L16.2428 9.17159L9.17171 16.2427L7.75749 14.8284L14.8286 7.75737ZM5.77539 2.29291L7.70724 1.77527L8.74252 5.63897L6.81067 6.15661L5.77539 2.29291ZM15.2578 18.3611L17.1896 17.8434L18.2249 21.7071L16.293 22.2248L15.2578 18.3611ZM2.29303 5.77527L6.15673 6.81054L5.63909 8.7424L1.77539 7.70712L2.29303 5.77527ZM18.3612 15.2576L22.2249 16.2929L21.7072 18.2248L17.8435 17.1895L18.3612 15.2576Z" fill="currentColor"/>',"list-check-2":'<path d="M11 4H21V6H11V4ZM11 8H17V10H11V8ZM11 14H21V16H11V14ZM11 18H17V20H11V18ZM3 4H9V10H3V4ZM5 6V8H7V6H5ZM3 14H9V20H3V14ZM5 16V18H7V16H5Z" fill="currentColor"/>',"list-check-3":'<path d="M8.00008 6V9H5.00008V6H8.00008ZM3.00008 4V11H10.0001V4H3.00008ZM13.0001 4H21.0001V6H13.0001V4ZM13.0001 11H21.0001V13H13.0001V11ZM13.0001 18H21.0001V20H13.0001V18ZM10.7072 16.2071L9.29297 14.7929L6.00008 18.0858L4.20718 16.2929L2.79297 17.7071L6.00008 20.9142L10.7072 16.2071Z" fill="currentColor"/>',"list-indefinite":'<path d="M13 4H21V6H13V4ZM13 11H21V13H13V11ZM13 18H21V20H13V18ZM6.5 19C5.39543 19 4.5 18.1046 4.5 17C4.5 15.8954 5.39543 15 6.5 15C7.60457 15 8.5 15.8954 8.5 17C8.5 18.1046 7.60457 19 6.5 19ZM6.5 21C8.70914 21 10.5 19.2091 10.5 17C10.5 14.7909 8.70914 13 6.5 13C4.29086 13 2.5 14.7909 2.5 17C2.5 19.2091 4.29086 21 6.5 21ZM5 6V9H8V6H5ZM3 4H10V11H3V4Z" fill="currentColor"/>',"list-unordered":'<path d="M8 4H21V6H8V4ZM4.5 6.5C3.67157 6.5 3 5.82843 3 5C3 4.17157 3.67157 3.5 4.5 3.5C5.32843 3.5 6 4.17157 6 5C6 5.82843 5.32843 6.5 4.5 6.5ZM4.5 13.5C3.67157 13.5 3 12.8284 3 12C3 11.1716 3.67157 10.5 4.5 10.5C5.32843 10.5 6 11.1716 6 12C6 12.8284 5.32843 13.5 4.5 13.5ZM4.5 20.4C3.67157 20.4 3 19.7284 3 18.9C3 18.0716 3.67157 17.4 4.5 17.4C5.32843 17.4 6 18.0716 6 18.9C6 19.7284 5.32843 20.4 4.5 20.4ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z" fill="currentColor"/>',loader:'<path d="M11.9995 2C12.5518 2 12.9995 2.44772 12.9995 3V6C12.9995 6.55228 12.5518 7 11.9995 7C11.4472 7 10.9995 6.55228 10.9995 6V3C10.9995 2.44772 11.4472 2 11.9995 2ZM11.9995 17C12.5518 17 12.9995 17.4477 12.9995 18V21C12.9995 21.5523 12.5518 22 11.9995 22C11.4472 22 10.9995 21.5523 10.9995 21V18C10.9995 17.4477 11.4472 17 11.9995 17ZM20.6597 7C20.9359 7.47829 20.772 8.08988 20.2937 8.36602L17.6956 9.86602C17.2173 10.1422 16.6057 9.97829 16.3296 9.5C16.0535 9.02171 16.2173 8.41012 16.6956 8.13398L19.2937 6.63397C19.772 6.35783 20.3836 6.52171 20.6597 7ZM7.66935 14.5C7.94549 14.9783 7.78161 15.5899 7.30332 15.866L4.70525 17.366C4.22695 17.6422 3.61536 17.4783 3.33922 17C3.06308 16.5217 3.22695 15.9101 3.70525 15.634L6.30332 14.134C6.78161 13.8578 7.3932 14.0217 7.66935 14.5ZM20.6597 17C20.3836 17.4783 19.772 17.6422 19.2937 17.366L16.6956 15.866C16.2173 15.5899 16.0535 14.9783 16.3296 14.5C16.6057 14.0217 17.2173 13.8578 17.6956 14.134L20.2937 15.634C20.772 15.9101 20.9359 16.5217 20.6597 17ZM7.66935 9.5C7.3932 9.97829 6.78161 10.1422 6.30332 9.86602L3.70525 8.36602C3.22695 8.08988 3.06308 7.47829 3.33922 7C3.61536 6.52171 4.22695 6.35783 4.70525 6.63397L7.30332 8.13398C7.78161 8.41012 7.94549 9.02171 7.66935 9.5Z" fill="currentColor"/>',"loader-4":'<path d="M18.364 5.63604L16.9497 7.05025C15.683 5.7835 13.933 5 12 5C8.13401 5 5 8.13401 5 12C5 15.866 8.13401 19 12 19C15.866 19 19 15.866 19 12H21C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C14.4853 3 16.7353 4.00736 18.364 5.63604Z" fill="currentColor"/>',lock:'<path d="M19 10H20C20.5523 10 21 10.4477 21 11V21C21 21.5523 20.5523 22 20 22H4C3.44772 22 3 21.5523 3 21V11C3 10.4477 3.44772 10 4 10H5V9C5 5.13401 8.13401 2 12 2C15.866 2 19 5.13401 19 9V10ZM5 12V20H19V12H5ZM11 14H13V18H11V14ZM17 10V9C17 6.23858 14.7614 4 12 4C9.23858 4 7 6.23858 7 9V10H17Z" fill="currentColor"/>',"lock-2":'<path d="M6 8V7C6 3.68629 8.68629 1 12 1C15.3137 1 18 3.68629 18 7V8H20C20.5523 8 21 8.44772 21 9V21C21 21.5523 20.5523 22 20 22H4C3.44772 22 3 21.5523 3 21V9C3 8.44772 3.44772 8 4 8H6ZM19 10H5V20H19V10ZM11 15.7324C10.4022 15.3866 10 14.7403 10 14C10 12.8954 10.8954 12 12 12C13.1046 12 14 12.8954 14 14C14 14.7403 13.5978 15.3866 13 15.7324V18H11V15.7324ZM8 8H16V7C16 4.79086 14.2091 3 12 3C9.79086 3 8 4.79086 8 7V8Z" fill="currentColor"/>',"lock-unlock":'<path d="M7 10H20C20.5523 10 21 10.4477 21 11V21C21 21.5523 20.5523 22 20 22H4C3.44772 22 3 21.5523 3 21V11C3 10.4477 3.44772 10 4 10H5V9C5 5.13401 8.13401 2 12 2C14.7405 2 17.1131 3.5748 18.2624 5.86882L16.4731 6.76344C15.6522 5.12486 13.9575 4 12 4C9.23858 4 7 6.23858 7 9V10ZM5 12V20H19V12H5ZM10 15H14V17H10V15Z" fill="currentColor"/>',"loop-right-ai":'<path d="M22 12C22 17.5228 17.5228 22 12 22C8.72774 22 5.82382 20.4286 4 18.001V20.5H2V14.5H8V16.5H5.38477C6.82543 18.6137 9.25151 20 12 20C16.4183 20 20 16.4183 20 12H22ZM11.5293 8.31934C11.7059 7.8935 12.2943 7.89349 12.4707 8.31934L12.7236 8.93066C13.1556 9.97346 13.9615 10.8062 14.9746 11.2568L15.6924 11.5762C16.1026 11.759 16.1026 12.3562 15.6924 12.5391L14.9326 12.877C13.9449 13.3162 13.1534 14.1194 12.7139 15.1279L12.4668 15.6934C12.2864 16.1075 11.7137 16.1075 11.5332 15.6934L11.2871 15.1279C10.8476 14.1193 10.0552 13.3163 9.06738 12.877L8.30762 12.5391C7.89744 12.3562 7.89741 11.759 8.30762 11.5762L9.02539 11.2568C10.0385 10.8062 10.8445 9.97348 11.2764 8.93066L11.5293 8.31934ZM12 2C15.2723 2 18.1762 3.57144 20 5.99902V3.5H22V9.5H16V7.5H18.6152C17.1746 5.38634 14.7485 4 12 4C7.58172 4 4 7.58172 4 12H2C2 6.47715 6.47715 2 12 2Z" fill="currentColor"/>',macbook:'<path d="M4 5V16H20V5H4ZM2 4.00748C2 3.45107 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44892 22 4.00748V18H2V4.00748ZM1 19H23V21H1V19Z" fill="currentColor"/>',"menu-2":'<path d="M3 4H21V6H3V4ZM3 11H15V13H3V11ZM3 18H21V20H3V18Z" fill="currentColor"/>',"menu-fold-2":'<path d="M4.40347 3.90332L2.98926 5.31753L6.17124 8.49951L2.98926 11.6815L4.40347 13.0957L8.99967 8.49951L4.40347 3.90332ZM20.9997 19.9995V17.9995H2.99967V19.9995H20.9997ZM20.9997 12.9995V10.9995H11.9997V12.9995H20.9997ZM20.9997 5.99951V3.99951H11.9997V5.99951H20.9997Z" fill="currentColor"/>',"menu-search":'<path d="M15.5 5C13.567 5 12 6.567 12 8.5C12 10.433 13.567 12 15.5 12C17.433 12 19 10.433 19 8.5C19 6.567 17.433 5 15.5 5ZM10 8.5C10 5.46243 12.4624 3 15.5 3C18.5376 3 21 5.46243 21 8.5C21 9.6575 20.6424 10.7315 20.0317 11.6175L22.7071 14.2929L21.2929 15.7071L18.6175 13.0317C17.7315 13.6424 16.6575 14 15.5 14C12.4624 14 10 11.5376 10 8.5ZM3 4H8V6H3V4ZM3 11H8V13H3V11ZM21 18V20H3V18H21Z" fill="currentColor"/>',mic:'<path d="M11.9998 3C10.3429 3 8.99976 4.34315 8.99976 6V10C8.99976 11.6569 10.3429 13 11.9998 13C13.6566 13 14.9998 11.6569 14.9998 10V6C14.9998 4.34315 13.6566 3 11.9998 3ZM11.9998 1C14.7612 1 16.9998 3.23858 16.9998 6V10C16.9998 12.7614 14.7612 15 11.9998 15C9.23833 15 6.99976 12.7614 6.99976 10V6C6.99976 3.23858 9.23833 1 11.9998 1ZM3.05469 11H5.07065C5.55588 14.3923 8.47329 17 11.9998 17C15.5262 17 18.4436 14.3923 18.9289 11H20.9448C20.4837 15.1716 17.1714 18.4839 12.9998 18.9451V23H10.9998V18.9451C6.82814 18.4839 3.51584 15.1716 3.05469 11Z" fill="currentColor"/>',more:'<path d="M4.5 10.5C3.675 10.5 3 11.175 3 12C3 12.825 3.675 13.5 4.5 13.5C5.325 13.5 6 12.825 6 12C6 11.175 5.325 10.5 4.5 10.5ZM19.5 10.5C18.675 10.5 18 11.175 18 12C18 12.825 18.675 13.5 19.5 13.5C20.325 13.5 21 12.825 21 12C21 11.175 20.325 10.5 19.5 10.5ZM12 10.5C11.175 10.5 10.5 11.175 10.5 12C10.5 12.825 11.175 13.5 12 13.5C12.825 13.5 13.5 12.825 13.5 12C13.5 11.175 12.825 10.5 12 10.5Z" fill="currentColor"/>',"more-2":'<path d="M12 3C11.175 3 10.5 3.675 10.5 4.5C10.5 5.325 11.175 6 12 6C12.825 6 13.5 5.325 13.5 4.5C13.5 3.675 12.825 3 12 3ZM12 18C11.175 18 10.5 18.675 10.5 19.5C10.5 20.325 11.175 21 12 21C12.825 21 13.5 20.325 13.5 19.5C13.5 18.675 12.825 18 12 18ZM12 10.5C11.175 10.5 10.5 11.175 10.5 12C10.5 12.825 11.175 13.5 12 13.5C12.825 13.5 13.5 12.825 13.5 12C13.5 11.175 12.825 10.5 12 10.5Z" fill="currentColor"/>',"more-2-fill":'<path d="M12 3C10.9 3 10 3.9 10 5C10 6.1 10.9 7 12 7C13.1 7 14 6.1 14 5C14 3.9 13.1 3 12 3ZM12 17C10.9 17 10 17.9 10 19C10 20.1 10.9 21 12 21C13.1 21 14 20.1 14 19C14 17.9 13.1 17 12 17ZM12 10C10.9 10 10 10.9 10 12C10 13.1 10.9 14 12 14C13.1 14 14 13.1 14 12C14 10.9 13.1 10 12 10Z" fill="currentColor"/>',"more-fill":'<path d="M5 10C3.9 10 3 10.9 3 12C3 13.1 3.9 14 5 14C6.1 14 7 13.1 7 12C7 10.9 6.1 10 5 10ZM19 10C17.9 10 17 10.9 17 12C17 13.1 17.9 14 19 14C20.1 14 21 13.1 21 12C21 10.9 20.1 10 19 10ZM12 10C10.9 10 10 10.9 10 12C10 13.1 10.9 14 12 14C13.1 14 14 13.1 14 12C14 10.9 13.1 10 12 10Z" fill="currentColor"/>',music:'<path d="M12 13.5351V3H20V5H14V17C14 19.2091 12.2091 21 10 21C7.79086 21 6 19.2091 6 17C6 14.7909 7.79086 13 10 13C10.7286 13 11.4117 13.1948 12 13.5351ZM10 19C11.1046 19 12 18.1046 12 17C12 15.8954 11.1046 15 10 15C8.89543 15 8 15.8954 8 17C8 18.1046 8.89543 19 10 19Z" fill="currentColor"/>',"node-tree":'<path d="M10 2C10.5523 2 11 2.44772 11 3V7C11 7.55228 10.5523 8 10 8H8V10H13V9C13 8.44772 13.4477 8 14 8H20C20.5523 8 21 8.44772 21 9V13C21 13.5523 20.5523 14 20 14H14C13.4477 14 13 13.5523 13 13V12H8V18H13V17C13 16.4477 13.4477 16 14 16H20C20.5523 16 21 16.4477 21 17V21C21 21.5523 20.5523 22 20 22H14C13.4477 22 13 21.5523 13 21V20H7C6.44772 20 6 19.5523 6 19V8H4C3.44772 8 3 7.55228 3 7V3C3 2.44772 3.44772 2 4 2H10ZM19 18H15V20H19V18ZM19 10H15V12H19V10ZM9 4H5V6H9V4Z" fill="currentColor"/>',"notification-3":'<path d="M20 17H22V19H2V17H4V10C4 5.58172 7.58172 2 12 2C16.4183 2 20 5.58172 20 10V17ZM18 17V10C18 6.68629 15.3137 4 12 4C8.68629 4 6 6.68629 6 10V17H18ZM9 21H15V23H9V21Z" fill="currentColor"/>',pichamber:'<polygon points="12 2.5 3.5 7.4 3.5 17.2 12 22.1 20.5 17.2 20.5 7.4" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><polyline points="3.5 7.4 12 12.3 20.5 7.4" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><line x1="12" y1="12.3" x2="12" y2="22.1" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/><path d="m12 5.5 3.7 2.1L12 9.7 8.3 7.6 12 5.5Zm0 1.5-1 .6 1 .6 1-.6-1-.6Z" fill="currentColor" fill-rule="evenodd"/>',palette:'<path d="M12 2C17.5222 2 22 5.97778 22 10.8889C22 13.9556 19.5111 16.4444 16.4444 16.4444H14.4778C13.5556 16.4444 12.8111 17.1889 12.8111 18.1111C12.8111 18.5333 12.9778 18.9222 13.2333 19.2111C13.5 19.5111 13.6667 19.9 13.6667 20.3333C13.6667 21.2556 12.9 22 12 22C6.47778 22 2 17.5222 2 12C2 6.47778 6.47778 2 12 2ZM10.8111 18.1111C10.8111 16.0843 12.451 14.4444 14.4778 14.4444H16.4444C18.4065 14.4444 20 12.851 20 10.8889C20 7.1392 16.4677 4 12 4C7.58235 4 4 7.58235 4 12C4 16.19 7.2226 19.6285 11.324 19.9718C10.9948 19.4168 10.8111 18.7761 10.8111 18.1111ZM7.5 12C6.67157 12 6 11.3284 6 10.5C6 9.67157 6.67157 9 7.5 9C8.32843 9 9 9.67157 9 10.5C9 11.3284 8.32843 12 7.5 12ZM16.5 12C15.6716 12 15 11.3284 15 10.5C15 9.67157 15.6716 9 16.5 9C17.3284 9 18 9.67157 18 10.5C18 11.3284 17.3284 12 16.5 12ZM12 9C11.1716 9 10.5 8.32843 10.5 7.5C10.5 6.67157 11.1716 6 12 6C12.8284 6 13.5 6.67157 13.5 7.5C13.5 8.32843 12.8284 9 12 9Z" fill="currentColor"/>',pause:'<path d="M6 5H8V19H6V5ZM16 5H18V19H16V5Z" fill="currentColor"/>',pencil:'<path d="M15.7279 9.57627L14.3137 8.16206L5 17.4758V18.89H6.41421L15.7279 9.57627ZM17.1421 8.16206L18.5563 6.74785L17.1421 5.33363L15.7279 6.74785L17.1421 8.16206ZM7.24264 20.89H3V16.6473L16.435 3.21231C16.8256 2.82179 17.4587 2.82179 17.8492 3.21231L20.6777 6.04074C21.0682 6.43126 21.0682 7.06443 20.6777 7.45495L7.24264 20.89Z" fill="currentColor"/>',"pencil-ai":'<path d="M16.4356 3.21188C16.8261 2.82185 17.4592 2.82157 17.8496 3.21188L20.6777 6.04099C21.0681 6.43152 21.0682 7.06457 20.6777 7.45505L7.2422 20.8896H3.00001V16.6475L16.4356 3.21188ZM5.00001 17.4756V18.8896H6.41407L15.7276 9.57615L14.3135 8.16208L5.00001 17.4756ZM4.5293 1.3193C4.70583 0.893505 5.29418 0.893508 5.47071 1.3193L5.72364 1.93063C6.15555 2.97342 6.96155 3.80613 7.97462 4.2568L8.69239 4.57614C9.10267 4.75896 9.10262 5.35616 8.69239 5.53903L7.93263 5.87692C6.94497 6.3162 6.15339 7.11943 5.71387 8.1279L5.4668 8.69334C5.28636 9.10747 4.71366 9.10747 4.53321 8.69334L4.28614 8.1279C3.84661 7.11943 3.05506 6.3162 2.06739 5.87692L1.30762 5.53903C0.897483 5.35617 0.897435 4.75896 1.30762 4.57614L2.0254 4.2568C3.03845 3.80614 3.84446 2.97344 4.27637 1.93063L4.5293 1.3193ZM15.7276 6.74802L17.1426 8.16208L18.5567 6.74802L17.1426 5.33395L15.7276 6.74802Z" fill="currentColor"/>',"pencil-ai-2":'<path d="M18.5293 15.3193C18.7058 14.8934 19.2942 14.8934 19.4707 15.3193L19.7236 15.9307C20.1556 16.9735 20.9615 17.8062 21.9746 18.2568L22.6914 18.5762C23.1022 18.7589 23.1022 19.3564 22.6914 19.5391L21.9326 19.877C20.9449 20.3163 20.1534 21.1194 19.7139 22.1279L19.4668 22.6934C19.2863 23.1075 18.7136 23.1075 18.5332 22.6934L18.2861 22.1279C17.8466 21.1194 17.0551 20.3163 16.0674 19.877L15.3076 19.5391C14.8974 19.3562 14.8974 18.759 15.3076 18.5762L16.0254 18.2568C17.0385 17.8062 17.8444 16.9735 18.2764 15.9307L18.5293 15.3193ZM16.4346 3.21193C16.8251 2.82141 17.4591 2.82141 17.8496 3.21193L20.6777 6.04103C21.0681 6.43157 21.0682 7.06464 20.6777 7.45509L7.24219 20.8897H3V16.6475L16.4346 3.21193ZM5 17.4756V18.8897H6.41406L15.7275 9.57618L14.3135 8.16212L5 17.4756ZM15.7275 6.74806L17.1426 8.16212L18.5566 6.74806L17.1426 5.334L15.7275 6.74806Z" fill="currentColor"/>',"pencil-ruler-2":'<path d="M7.05033 14.1213L4.929 16.2427L7.75743 19.0711L19.0711 7.75737L16.2427 4.92894L14.1214 7.05026L15.5356 8.46448L14.1214 9.87869L12.7072 8.46448L11.293 9.87869L12.7072 11.2929L11.293 12.7071L9.87875 11.2929L8.46454 12.7071L9.87875 14.1213L8.46454 15.5355L7.05033 14.1213ZM16.9498 2.80762L21.1925 7.05026C21.583 7.44079 21.583 8.07395 21.1925 8.46448L8.46454 21.1924C8.07401 21.5829 7.44085 21.5829 7.05033 21.1924L2.80768 16.9498C2.41716 16.5592 2.41716 15.9261 2.80768 15.5355L15.5356 2.80762C15.9261 2.4171 16.5593 2.4171 16.9498 2.80762ZM14.1214 18.3635L15.5356 16.9493L17.7781 19.1918H19.1923V17.7776L16.9498 15.5351L18.364 14.1208L20.9997 16.7565V20.9999H16.7578L14.1214 18.3635ZM5.63597 9.87806L2.80754 7.04963C2.41702 6.65911 2.41702 6.02594 2.80754 5.63542L5.63597 2.80699C6.02649 2.41647 6.65966 2.41647 7.05018 2.80699L9.87861 5.63542L8.4644 7.04963L6.34308 4.92831L4.92886 6.34253L7.05018 8.46385L5.63597 9.87806Z" fill="currentColor"/>',"picture-in-picture-2":'<path d="M21 3C21.5523 3 22 3.44772 22 4V11H20V5H4V19H10V21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H21ZM21 13C21.5523 13 22 13.4477 22 14V20C22 20.5523 21.5523 21 21 21H13C12.4477 21 12 20.5523 12 20V14C12 13.4477 12.4477 13 13 13H21ZM20 15H14V19H20V15ZM6.70711 6.29289L8.95689 8.54289L11 6.5V12H5.5L7.54289 9.95689L5.29289 7.70711L6.70711 6.29289Z" fill="currentColor"/>',"pie-chart":'<path d="M9 2.4578V4.58152C6.06817 5.76829 4 8.64262 4 12C4 16.4183 7.58172 20 12 20C15.3574 20 18.2317 17.9318 19.4185 15H21.5422C20.2679 19.0571 16.4776 22 12 22C6.47715 22 2 17.5228 2 12C2 7.52236 4.94289 3.73207 9 2.4578ZM12 2C17.5228 2 22 6.47715 22 12C22 12.3375 21.9833 12.6711 21.9506 13H11V2.04938C11.3289 2.01672 11.6625 2 12 2ZM13 4.06189V11H19.9381C19.4869 7.38128 16.6187 4.51314 13 4.06189Z" fill="currentColor"/>',play:'<path d="M16.3944 12.0001L10 7.7371V16.263L16.3944 12.0001ZM19.376 12.4161L8.77735 19.4818C8.54759 19.635 8.23715 19.5729 8.08397 19.3432C8.02922 19.261 8 19.1645 8 19.0658V4.93433C8 4.65818 8.22386 4.43433 8.5 4.43433C8.59871 4.43433 8.69522 4.46355 8.77735 4.5183L19.376 11.584C19.6057 11.7372 19.6678 12.0477 19.5146 12.2774C19.478 12.3323 19.4309 12.3795 19.376 12.4161Z" fill="currentColor"/>',"play-list-add":'<path d="M2 18H12V20H2V18ZM2 11H22V13H2V11ZM2 4H22V6H2V4ZM18 18V15H20V18H23V20H20V23H18V20H15V18H18Z" fill="currentColor"/>',plug:'<path d="M13 18V20H19V22H13C11.8954 22 11 21.1046 11 20V18H8C5.79086 18 4 16.2091 4 14V7C4 6.44772 4.44772 6 5 6H8V2H10V6H14V2H16V6H19C19.5523 6 20 6.44772 20 7V14C20 16.2091 18.2091 18 16 18H13ZM8 16H16C17.1046 16 18 15.1046 18 14V11H6V14C6 15.1046 6.89543 16 8 16ZM18 8H6V9H18V8ZM12 14.5C11.4477 14.5 11 14.0523 11 13.5C11 12.9477 11.4477 12.5 12 12.5C12.5523 12.5 13 12.9477 13 13.5C13 14.0523 12.5523 14.5 12 14.5Z" fill="currentColor"/>',"plug-2":'<path d="M13 18V20H19V22H13C11.8954 22 11 21.1046 11 20V18H8C5.79086 18 4 16.2091 4 14V7C4 6.44772 4.44772 6 5 6H7V2H9V6H15V2H17V6H19C19.5523 6 20 6.44772 20 7V14C20 16.2091 18.2091 18 16 18H13ZM8 16H16C17.1046 16 18 15.1046 18 14V11H6V14C6 15.1046 6.89543 16 8 16ZM18 8H6V9H18V8ZM12 14.5C11.4477 14.5 11 14.0523 11 13.5C11 12.9477 11.4477 12.5 12 12.5C12.5523 12.5 13 12.9477 13 13.5C13 14.0523 12.5523 14.5 12 14.5ZM11 2H13V5H11V2Z" fill="currentColor"/>',pulse:'<path d="M9 7.53861L15 21.5386L18.6594 13H23V11H17.3406L15 16.4614L9 2.46143L5.3406 11H1V13H6.6594L9 7.53861Z" fill="currentColor"/>',pushpin:'<path d="M13.8273 1.69L22.3126 10.1753L20.8984 11.5895L20.1913 10.8824L15.9486 15.125L15.2415 18.6606L13.8273 20.0748L9.58466 15.8321L4.63492 20.7819L3.2207 19.3677L8.17045 14.4179L3.92781 10.1753L5.34202 8.76107L8.87756 8.05396L13.1202 3.81132L12.4131 3.10422L13.8273 1.69ZM14.5344 5.22554L9.86358 9.89637L7.0417 10.4607L13.5418 16.9609L14.1062 14.139L18.7771 9.46818L14.5344 5.22554Z" fill="currentColor"/>',"pushpin-2":'<path d="M18 3V5H17V11L19 14V16H13V23H11V16H5V14L7 11V5H6V3H18ZM9 5V11.6056L7.4037 14H16.5963L15 11.6056V5H9Z" fill="currentColor"/>',"pushpin-2-fill":'<path d="M18 3V5H17V11L19 14V16H13V23H11V16H5V14L7 11V5H6V3H18Z" fill="currentColor"/>',question:'<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM11 15H13V17H11V15ZM13 13.3551V14H11V12.5C11 11.9477 11.4477 11.5 12 11.5C12.8284 11.5 13.5 10.8284 13.5 10C13.5 9.17157 12.8284 8.5 12 8.5C11.2723 8.5 10.6656 9.01823 10.5288 9.70577L8.56731 9.31346C8.88637 7.70919 10.302 6.5 12 6.5C13.933 6.5 15.5 8.067 15.5 10C15.5 11.5855 14.4457 12.9248 13 13.3551Z" fill="currentColor"/>',"record-circle":'<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM12 15C10.3431 15 9 13.6569 9 12C9 10.3431 10.3431 9 12 9C13.6569 9 15 10.3431 15 12C15 13.6569 13.6569 15 12 15Z" fill="currentColor"/>',refresh:'<path d="M5.46257 4.43262C7.21556 2.91688 9.5007 2 12 2C17.5228 2 22 6.47715 22 12C22 14.1361 21.3302 16.1158 20.1892 17.7406L17 12H20C20 7.58172 16.4183 4 12 4C9.84982 4 7.89777 4.84827 6.46023 6.22842L5.46257 4.43262ZM18.5374 19.5674C16.7844 21.0831 14.4993 22 12 22C6.47715 22 2 17.5228 2 12C2 9.86386 2.66979 7.88416 3.8108 6.25944L7 12H4C4 16.4183 7.58172 20 12 20C14.1502 20 16.1022 19.1517 17.5398 17.7716L18.5374 19.5674Z" fill="currentColor"/>',restart:'<path d="M18.5374 19.5674C16.7844 21.0831 14.4993 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 14.1361 21.3302 16.1158 20.1892 17.7406L17 12H20C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20C14.1502 20 16.1022 19.1517 17.5398 17.7716L18.5374 19.5674Z" fill="currentColor"/>',robot:'<path d="M13 4.05493C17.5 4.55237 21 8.36745 21 13V22H3V13C3 8.36745 6.50005 4.55237 11 4.05493V1H13V4.05493ZM19 20V13C19 9.13401 15.866 6 12 6C8.13401 6 5 9.13401 5 13V20H19ZM12 18C9.23858 18 7 15.7614 7 13C7 10.2386 9.23858 8 12 8C14.7614 8 17 10.2386 17 13C17 15.7614 14.7614 18 12 18ZM12 16C13.6569 16 15 14.6569 15 13C15 11.3431 13.6569 10 12 10C10.3431 10 9 11.3431 9 13C9 14.6569 10.3431 16 12 16ZM12 14C11.4477 14 11 13.5523 11 13C11 12.4477 11.4477 12 12 12C12.5523 12 13 12.4477 13 13C13 13.5523 12.5523 14 12 14Z" fill="currentColor"/>',"robot-2":'<path d="M13.5 2C13.5 2.44425 13.3069 2.84339 13 3.11805V5H18C19.6569 5 21 6.34315 21 8V18C21 19.6569 19.6569 21 18 21H6C4.34315 21 3 19.6569 3 18V8C3 6.34315 4.34315 5 6 5H11V3.11805C10.6931 2.84339 10.5 2.44425 10.5 2C10.5 1.17157 11.1716 0.5 12 0.5C12.8284 0.5 13.5 1.17157 13.5 2ZM6 7C5.44772 7 5 7.44772 5 8V18C5 18.5523 5.44772 19 6 19H18C18.5523 19 19 18.5523 19 18V8C19 7.44772 18.5523 7 18 7H13H11H6ZM2 10H0V16H2V10ZM22 10H24V16H22V10ZM9 14.5C9.82843 14.5 10.5 13.8284 10.5 13C10.5 12.1716 9.82843 11.5 9 11.5C8.17157 11.5 7.5 12.1716 7.5 13C7.5 13.8284 8.17157 14.5 9 14.5ZM15 14.5C15.8284 14.5 16.5 13.8284 16.5 13C16.5 12.1716 15.8284 11.5 15 11.5C14.1716 11.5 13.5 12.1716 13.5 13C13.5 13.8284 14.1716 14.5 15 14.5Z" fill="currentColor"/>',rocket:'<path d="M4.99958 12.9999C4.99958 7.91198 7.90222 3.5636 11.9996 1.81799C16.0969 3.5636 18.9996 7.91198 18.9996 12.9999C18.9996 13.8229 18.9236 14.6264 18.779 15.4027L20.7194 17.2353C20.8845 17.3913 20.9238 17.6389 20.815 17.8383L18.3196 22.4133C18.1873 22.6557 17.8836 22.7451 17.6412 22.6128C17.5993 22.59 17.5608 22.5612 17.5271 22.5274L15.2925 20.2928C15.1049 20.1053 14.8506 19.9999 14.5854 19.9999H9.41379C9.14857 19.9999 8.89422 20.1053 8.70668 20.2928L6.47209 22.5274C6.27683 22.7227 5.96025 22.7227 5.76498 22.5274C5.73122 22.4937 5.70246 22.4552 5.67959 22.4133L3.18412 17.8383C3.07537 17.6389 3.11464 17.3913 3.27975 17.2353L5.22014 15.4027C5.07551 14.6264 4.99958 13.8229 4.99958 12.9999ZM6.47542 19.6957L7.29247 18.8786C7.85508 18.316 8.61814 17.9999 9.41379 17.9999H14.5854C15.381 17.9999 16.1441 18.316 16.7067 18.8786L17.5237 19.6957L18.5056 17.8955L17.4058 16.8568C16.9117 16.3901 16.6884 15.7045 16.8128 15.0364C16.9366 14.3722 16.9996 13.6911 16.9996 12.9999C16.9996 9.13037 15.0045 5.69965 11.9996 4.04033C8.99462 5.69965 6.99958 9.13037 6.99958 12.9999C6.99958 13.6911 7.06255 14.3722 7.18631 15.0364C7.31078 15.7045 7.08746 16.3901 6.59338 16.8568L5.49353 17.8955L6.47542 19.6957ZM11.9996 12.9999C10.895 12.9999 9.99958 12.1045 9.99958 10.9999C9.99958 9.89537 10.895 8.99994 11.9996 8.99994C13.1041 8.99994 13.9996 9.89537 13.9996 10.9999C13.9996 12.1045 13.1041 12.9999 11.9996 12.9999Z" fill="currentColor"/>',route:'<path d="M4 15V8.5C4 6.01472 6.01472 4 8.5 4C10.9853 4 13 6.01472 13 8.5V15.5C13 16.8807 14.1193 18 15.5 18C16.8807 18 18 16.8807 18 15.5V8.82929C16.8348 8.41746 16 7.30622 16 6C16 4.34315 17.3431 3 19 3C20.6569 3 22 4.34315 22 6C22 7.30622 21.1652 8.41746 20 8.82929V15.5C20 17.9853 17.9853 20 15.5 20C13.0147 20 11 17.9853 11 15.5V8.5C11 7.11929 9.88071 6 8.5 6C7.11929 6 6 7.11929 6 8.5V15H9L5 20L1 15H4ZM19 7C19.5523 7 20 6.55228 20 6C20 5.44772 19.5523 5 19 5C18.4477 5 18 5.44772 18 6C18 6.55228 18.4477 7 19 7Z" fill="currentColor"/>',"save-3":'<path d="M18 19H19V6.82843L17.1716 5H16V9H7V5H5V19H6V12H18V19ZM4 3H18L20.7071 5.70711C20.8946 5.89464 21 6.149 21 6.41421V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM8 14V19H16V14H8Z" fill="currentColor"/>',"scales-3":'<path d="M12.9985 2L12.9979 3.278L17.9985 4.94591L21.631 3.73509L22.2634 5.63246L19.2319 6.643L22.3272 15.1549C21.2353 16.2921 19.6996 17 17.9985 17C16.2975 17 14.7618 16.2921 13.6699 15.1549L16.7639 6.643L12.9979 5.387V19H16.9985V21H6.99854V19H10.9979V5.387L7.23192 6.643L10.3272 15.1549C9.23528 16.2921 7.69957 17 5.99854 17C4.2975 17 2.76179 16.2921 1.66992 15.1549L4.76392 6.643L1.73363 5.63246L2.36608 3.73509L5.99854 4.94591L10.9979 3.278L10.9985 2H12.9985ZM17.9985 9.10267L16.04 14.4892C16.628 14.8201 17.2979 15 17.9985 15C18.6992 15 19.3691 14.8201 19.957 14.4892L17.9985 9.10267ZM5.99854 9.10267L4.04004 14.4892C4.62795 14.8201 5.29792 15 5.99854 15C6.69916 15 7.36912 14.8201 7.95703 14.4892L5.99854 9.10267Z" fill="currentColor"/>',"scan-2":'<path d="M5.67127 4.25705L13.4142 12L12 13.4142L8.55382 9.96803C8.20193 10.5635 8 11.2582 8 12C8 14.2091 9.79086 16 12 16C14.2091 16 16 14.2091 16 12C16 9.87494 14.3429 8.13693 12.2503 8.00771L10.4459 6.20323C10.9416 6.07067 11.4625 6 12 6C15.3137 6 18 8.68629 18 12C18 15.3137 15.3137 18 12 18C8.68629 18 6 15.3137 6 12C6 10.7042 6.41079 9.50428 7.10925 8.52347L5.68014 7.09436C4.62708 8.44904 4 10.1513 4 12C4 16.4183 7.58172 20 12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C10.8915 4 9.83557 4.22547 8.8757 4.63306L7.37443 3.13179C8.75768 2.40883 10.3311 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 8.87842 3.43029 6.09091 5.67127 4.25705Z" fill="currentColor"/>',scissors:'<path d="M9.44618 8.02867L12 10.5825L18.7279 3.85457C19.509 3.07352 20.7753 3.07352 21.5563 3.85457L9.44618 15.9647C9.79807 16.5603 10 17.2549 10 17.9967C10 20.2058 8.20914 21.9967 6 21.9967C3.79086 21.9967 2 20.2058 2 17.9967C2 15.7876 3.79086 13.9967 6 13.9967C6.74181 13.9967 7.43645 14.1986 8.03197 14.5505L10.5858 11.9967L8.03197 9.44289C7.43645 9.79478 6.74181 9.9967 6 9.9967C3.79086 9.9967 2 8.20584 2 5.9967C2 3.78756 3.79086 1.9967 6 1.9967C8.20914 1.9967 10 3.78756 10 5.9967C10 6.73851 9.79807 7.43316 9.44618 8.02867ZM14.8255 13.408L21.5563 20.1388C20.7753 20.9199 19.509 20.9199 18.7279 20.1388L13.4113 14.8222L14.8255 13.408ZM7.41421 16.5825C7.05228 16.2206 6.55228 15.9967 6 15.9967C4.89543 15.9967 4 16.8921 4 17.9967C4 19.1013 4.89543 19.9967 6 19.9967C7.10457 19.9967 8 19.1013 8 17.9967C8 17.4444 7.77614 16.9444 7.41421 16.5825ZM7.41421 7.41092C7.77614 7.04899 8 6.54899 8 5.9967C8 4.89213 7.10457 3.9967 6 3.9967C4.89543 3.9967 4 4.89213 4 5.9967C4 7.10127 4.89543 7.9967 6 7.9967C6.55228 7.9967 7.05228 7.77285 7.41421 7.41092Z" fill="currentColor"/>',search:'<path d="M18.031 16.6168L22.3137 20.8995L20.8995 22.3137L16.6168 18.031C15.0769 19.263 13.124 20 11 20C6.032 20 2 15.968 2 11C2 6.032 6.032 2 11 2C15.968 2 20 6.032 20 11C20 13.124 19.263 15.0769 18.031 16.6168ZM16.0247 15.8748C17.2475 14.6146 18 12.8956 18 11C18 7.1325 14.8675 4 11 4C7.1325 4 4 7.1325 4 11C4 14.8675 7.1325 18 11 18C12.8956 18 14.6146 17.2475 15.8748 16.0247L16.0247 15.8748Z" fill="currentColor"/>',"search-eye":'<path d="M18.031 16.6168L22.3137 20.8995L20.8995 22.3137L16.6168 18.031C15.0769 19.263 13.124 20 11 20C6.032 20 2 15.968 2 11C2 6.032 6.032 2 11 2C15.968 2 20 6.032 20 11C20 13.124 19.263 15.0769 18.031 16.6168ZM16.0247 15.8748C17.2475 14.6146 18 12.8956 18 11C18 7.1325 14.8675 4 11 4C7.1325 4 4 7.1325 4 11C4 14.8675 7.1325 18 11 18C12.8956 18 14.6146 17.2475 15.8748 16.0247L16.0247 15.8748ZM12.1779 7.17624C11.4834 7.48982 11 8.18846 11 9C11 10.1046 11.8954 11 13 11C13.8115 11 14.5102 10.5166 14.8238 9.82212C14.9383 10.1945 15 10.59 15 11C15 13.2091 13.2091 15 11 15C8.79086 15 7 13.2091 7 11C7 8.79086 8.79086 7 11 7C11.41 7 11.8055 7.06167 12.1779 7.17624Z" fill="currentColor"/>',"send-plane":'<path d="M21.7267 2.95694L16.2734 22.0432C16.1225 22.5716 15.7979 22.5956 15.5563 22.1126L11 13L1.9229 9.36919C1.41322 9.16532 1.41953 8.86022 1.95695 8.68108L21.0432 2.31901C21.5716 2.14285 21.8747 2.43866 21.7267 2.95694ZM19.0353 5.09647L6.81221 9.17085L12.4488 11.4255L15.4895 17.5068L19.0353 5.09647Z" fill="currentColor"/>',"send-plane-2":'<path d="M3.5 1.34558C3.58425 1.34558 3.66714 1.36687 3.74096 1.40747L22.2034 11.5618C22.4454 11.6949 22.5337 11.9989 22.4006 12.2409C22.3549 12.324 22.2865 12.3924 22.2034 12.4381L3.74096 22.5924C3.499 22.7255 3.19497 22.6372 3.06189 22.3953C3.02129 22.3214 3 22.2386 3 22.1543V1.84558C3 1.56944 3.22386 1.34558 3.5 1.34558ZM5 4.38249V10.9999H10V12.9999H5V19.6174L18.8499 11.9999L5 4.38249Z" fill="currentColor"/>',server:'<path d="M5 11H19V5H5V11ZM21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20C20.5523 3 21 3.44772 21 4ZM19 13H5V19H19V13ZM7 15H10V17H7V15ZM7 7H10V9H7V7Z" fill="currentColor"/>',"settings-3":'<path d="M3.33946 17.0002C2.90721 16.2515 2.58277 15.4702 2.36133 14.6741C3.3338 14.1779 3.99972 13.1668 3.99972 12.0002C3.99972 10.8345 3.3348 9.824 2.36353 9.32741C2.81025 7.71651 3.65857 6.21627 4.86474 4.99001C5.7807 5.58416 6.98935 5.65534 7.99972 5.072C9.01009 4.48866 9.55277 3.40635 9.4962 2.31604C11.1613 1.8846 12.8847 1.90004 14.5031 2.31862C14.4475 3.40806 14.9901 4.48912 15.9997 5.072C17.0101 5.65532 18.2187 5.58416 19.1346 4.99007C19.7133 5.57986 20.2277 6.25151 20.66 7.00021C21.0922 7.7489 21.4167 8.53025 21.6381 9.32628C20.6656 9.82247 19.9997 10.8336 19.9997 12.0002C19.9997 13.166 20.6646 14.1764 21.6359 14.673C21.1892 16.2839 20.3409 17.7841 19.1347 19.0104C18.2187 18.4163 17.0101 18.3451 15.9997 18.9284C14.9893 19.5117 14.4467 20.5941 14.5032 21.6844C12.8382 22.1158 11.1148 22.1004 9.49633 21.6818C9.55191 20.5923 9.00929 19.5113 7.99972 18.9284C6.98938 18.3451 5.78079 18.4162 4.86484 19.0103C4.28617 18.4205 3.77172 17.7489 3.33946 17.0002ZM8.99972 17.1964C10.0911 17.8265 10.8749 18.8227 11.2503 19.9659C11.7486 20.0133 12.2502 20.014 12.7486 19.9675C13.1238 18.8237 13.9078 17.8268 14.9997 17.1964C16.0916 16.5659 17.347 16.3855 18.5252 16.6324C18.8146 16.224 19.0648 15.7892 19.2729 15.334C18.4706 14.4373 17.9997 13.2604 17.9997 12.0002C17.9997 10.74 18.4706 9.5632 19.2729 8.6665C19.1688 8.4405 19.0538 8.21822 18.9279 8.00021C18.802 7.78219 18.667 7.57148 18.5233 7.36842C17.3457 7.61476 16.0911 7.43414 14.9997 6.80405C13.9083 6.17395 13.1246 5.17768 12.7491 4.03455C12.2509 3.98714 11.7492 3.98646 11.2509 4.03292C10.8756 5.17671 10.0916 6.17364 8.99972 6.80405C7.9078 7.43447 6.65245 7.61494 5.47428 7.36803C5.18485 7.77641 4.93463 8.21117 4.72656 8.66637C5.52881 9.56311 5.99972 10.74 5.99972 12.0002C5.99972 13.2604 5.52883 14.4372 4.72656 15.3339C4.83067 15.5599 4.94564 15.7822 5.07152 16.0002C5.19739 16.2182 5.3324 16.4289 5.47612 16.632C6.65377 16.3857 7.90838 16.5663 8.99972 17.1964ZM11.9997 15.0002C10.3429 15.0002 8.99972 13.6571 8.99972 12.0002C8.99972 10.3434 10.3429 9.00021 11.9997 9.00021C13.6566 9.00021 14.9997 10.3434 14.9997 12.0002C14.9997 13.6571 13.6566 15.0002 11.9997 15.0002ZM11.9997 13.0002C12.552 13.0002 12.9997 12.5525 12.9997 12.0002C12.9997 11.4479 12.552 11.0002 11.9997 11.0002C11.4474 11.0002 10.9997 11.4479 10.9997 12.0002C10.9997 12.5525 11.4474 13.0002 11.9997 13.0002Z" fill="currentColor"/>',"share-2":'<path d="M12 2.58582L18.2071 8.79292L16.7929 10.2071L13 6.41424V16H11V6.41424L7.20711 10.2071L5.79289 8.79292L12 2.58582ZM3 18V14H5V18C5 18.5523 5.44772 19 6 19H18C18.5523 19 19 18.5523 19 18V14H21V18C21 19.6569 19.6569 21 18 21H6C4.34315 21 3 19.6569 3 18Z" fill="currentColor"/>',shield:'<path d="M3.78307 2.82598L12 1L20.2169 2.82598C20.6745 2.92766 21 3.33347 21 3.80217V13.7889C21 15.795 19.9974 17.6684 18.3282 18.7812L12 23L5.6718 18.7812C4.00261 17.6684 3 15.795 3 13.7889V3.80217C3 3.33347 3.32553 2.92766 3.78307 2.82598ZM5 4.60434V13.7889C5 15.1263 5.6684 16.3752 6.7812 17.1171L12 20.5963L17.2188 17.1171C18.3316 16.3752 19 15.1263 19 13.7889V4.60434L12 3.04879L5 4.60434Z" fill="currentColor"/>',"shield-check":'<path d="M12 1L20.2169 2.82598C20.6745 2.92766 21 3.33347 21 3.80217V13.7889C21 15.795 19.9974 17.6684 18.3282 18.7812L12 23L5.6718 18.7812C4.00261 17.6684 3 15.795 3 13.7889V3.80217C3 3.33347 3.32553 2.92766 3.78307 2.82598L12 1ZM12 3.04879L5 4.60434V13.7889C5 15.1263 5.6684 16.3752 6.7812 17.1171L12 20.5963L17.2188 17.1171C18.3316 16.3752 19 15.1263 19 13.7889V4.60434L12 3.04879ZM16.4524 8.22183L17.8666 9.63604L11.5026 16L7.25999 11.7574L8.67421 10.3431L11.5019 13.1709L16.4524 8.22183Z" fill="currentColor"/>',"shield-keyhole":'<path d="M12 1L20.2169 2.82598C20.6745 2.92766 21 3.33347 21 3.80217V13.7889C21 15.795 19.9974 17.6684 18.3282 18.7812L12 23L5.6718 18.7812C4.00261 17.6684 3 15.795 3 13.7889V3.80217C3 3.33347 3.32553 2.92766 3.78307 2.82598L12 1ZM12 3.04879L5 4.60434V13.7889C5 15.1263 5.6684 16.3752 6.7812 17.1171L12 20.5963L17.2188 17.1171C18.3316 16.3752 19 15.1263 19 13.7889V4.60434L12 3.04879ZM12 7C13.1046 7 14 7.89543 14 9C14 9.73984 13.5983 10.3858 13.0011 10.7318L13 15H11L10.9999 10.7324C10.4022 10.3866 10 9.74025 10 9C10 7.89543 10.8954 7 12 7Z" fill="currentColor"/>',"shield-user":'<path d="M3.78307 2.82598L12 1L20.2169 2.82598C20.6745 2.92766 21 3.33347 21 3.80217V13.7889C21 15.795 19.9974 17.6684 18.3282 18.7812L12 23L5.6718 18.7812C4.00261 17.6684 3 15.795 3 13.7889V3.80217C3 3.33347 3.32553 2.92766 3.78307 2.82598ZM5 4.60434V13.7889C5 15.1263 5.6684 16.3752 6.7812 17.1171L12 20.5963L17.2188 17.1171C18.3316 16.3752 19 15.1263 19 13.7889V4.60434L12 3.04879L5 4.60434ZM12 11C10.6193 11 9.5 9.88071 9.5 8.5C9.5 7.11929 10.6193 6 12 6C13.3807 6 14.5 7.11929 14.5 8.5C14.5 9.88071 13.3807 11 12 11ZM7.52746 16C7.77619 13.75 9.68372 12 12 12C14.3163 12 16.2238 13.75 16.4725 16H7.52746Z" fill="currentColor"/>',shuffle:'<path d="M18 17.8832V16L23 19L18 22V19.9095C14.9224 19.4698 12.2513 17.4584 11.0029 14.5453L11 14.5386L10.9971 14.5453C9.57893 17.8544 6.32508 20 2.72483 20H2V18H2.72483C5.52503 18 8.05579 16.3312 9.15885 13.7574L9.91203 12L9.15885 10.2426C8.05579 7.66878 5.52503 6 2.72483 6H2V4H2.72483C6.32508 4 9.57893 6.14557 10.9971 9.45473L11 9.46141L11.0029 9.45473C12.2513 6.5416 14.9224 4.53022 18 4.09051V2L23 5L18 8V6.11684C15.7266 6.53763 13.7737 8.0667 12.8412 10.2426L12.088 12L12.8412 13.7574C13.7737 15.9333 15.7266 17.4624 18 17.8832Z" fill="currentColor"/>',"slash-commands-2":'<path d="M5 2C3.34315 2 2 3.34315 2 5V19C2 20.6569 3.34315 22 5 22H19C20.6569 22 22 20.6569 22 19V5C22 3.34315 20.6569 2 19 2H5ZM4 5C4 4.44772 4.44772 4 5 4H19C19.5523 4 20 4.44772 20 5V19C20 19.5523 19.5523 20 19 20H5C4.44772 20 4 19.5523 4 19V5ZM9.72318 18L16.5803 6H14.2768L7.41968 18H9.72318Z" fill="currentColor"/>',smartphone:'<path d="M7 4V20H17V4H7ZM6 2H18C18.5523 2 19 2.44772 19 3V21C19 21.5523 18.5523 22 18 22H6C5.44772 22 5 21.5523 5 21V3C5 2.44772 5.44772 2 6 2ZM12 17C12.5523 17 13 17.4477 13 18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18C11 17.4477 11.4477 17 12 17Z" fill="currentColor"/>',sparkling:'<path d="M14 4.4375C15.3462 4.4375 16.4375 3.34619 16.4375 2H17.5625C17.5625 3.34619 18.6538 4.4375 20 4.4375V5.5625C18.6538 5.5625 17.5625 6.65381 17.5625 8H16.4375C16.4375 6.65381 15.3462 5.5625 14 5.5625V4.4375ZM1 11C4.31371 11 7 8.31371 7 5H9C9 8.31371 11.6863 11 15 11V13C11.6863 13 9 15.6863 9 19H7C7 15.6863 4.31371 13 1 13V11ZM4.87601 12C6.18717 12.7276 7.27243 13.8128 8 15.124 8.72757 13.8128 9.81283 12.7276 11.124 12 9.81283 11.2724 8.72757 10.1872 8 8.87601 7.27243 10.1872 6.18717 11.2724 4.87601 12ZM17.25 14C17.25 15.7949 15.7949 17.25 14 17.25V18.75C15.7949 18.75 17.25 20.2051 17.25 22H18.75C18.75 20.2051 20.2051 18.75 22 18.75V17.25C20.2051 17.25 18.75 15.7949 18.75 14H17.25Z" fill="currentColor"/>',"split-cells-horizontal":'<path d="M20 3C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20ZM11 5H5V19H11V15H13V19H19V5H13V9H11V5ZM15 9L18 12L15 15V13H9V15L6 12L9 9V11H15V9Z" fill="currentColor"/>',stack:'<path d="M20.0833 15.1999L21.2854 15.9212C21.5221 16.0633 21.5989 16.3704 21.4569 16.6072C21.4146 16.6776 21.3557 16.7365 21.2854 16.7787L12.5144 22.0412C12.1977 22.2313 11.8021 22.2313 11.4854 22.0412L2.71451 16.7787C2.47772 16.6366 2.40093 16.3295 2.54301 16.0927C2.58523 16.0223 2.64413 15.9634 2.71451 15.9212L3.9166 15.1999L11.9999 20.0499L20.0833 15.1999ZM20.0833 10.4999L21.2854 11.2212C21.5221 11.3633 21.5989 11.6704 21.4569 11.9072C21.4146 11.9776 21.3557 12.0365 21.2854 12.0787L11.9999 17.6499L2.71451 12.0787C2.47772 11.9366 2.40093 11.6295 2.54301 11.3927C2.58523 11.3223 2.64413 11.2634 2.71451 11.2212L3.9166 10.4999L11.9999 15.3499L20.0833 10.4999ZM12.5144 1.30864L21.2854 6.5712C21.5221 6.71327 21.5989 7.0204 21.4569 7.25719C21.4146 7.32757 21.3557 7.38647 21.2854 7.42869L11.9999 12.9999L2.71451 7.42869C2.47772 7.28662 2.40093 6.97949 2.54301 6.7427C2.58523 6.67232 2.64413 6.61343 2.71451 6.5712L11.4854 1.30864C11.8021 1.11864 12.1977 1.11864 12.5144 1.30864ZM11.9999 3.33233L5.88723 6.99995L11.9999 10.6676L18.1126 6.99995L11.9999 3.33233Z" fill="currentColor"/>',star:'<path d="M12.0006 18.26L4.94715 22.2082L6.52248 14.2799L0.587891 8.7918L8.61493 7.84006L12.0006 0.5L15.3862 7.84006L23.4132 8.7918L17.4787 14.2799L19.054 22.2082L12.0006 18.26ZM12.0006 15.968L16.2473 18.3451L15.2988 13.5717L18.8719 10.2674L14.039 9.69434L12.0006 5.27502L9.96214 9.69434L5.12921 10.2674L8.70231 13.5717L7.75383 18.3451L12.0006 15.968Z" fill="currentColor"/>',"star-fill":'<path d="M12.0006 18.26L4.94715 22.2082L6.52248 14.2799L0.587891 8.7918L8.61493 7.84006L12.0006 0.5L15.3862 7.84006L23.4132 8.7918L17.4787 14.2799L19.054 22.2082L12.0006 18.26Z" fill="currentColor"/>',"sticky-note":'<path d="M21 15L15 20.996L4.00221 21C3.4487 21 3 20.5551 3 20.0066V3.9934C3 3.44476 3.44495 3 3.9934 3H20.0066C20.5552 3 21 3.45576 21 4.00247V15ZM19 5H5V19H13V14C13 13.4872 13.386 13.0645 13.8834 13.0067L14 13L19 12.999V5ZM18.171 14.999L15 15V18.169L18.171 14.999Z" fill="currentColor"/>',stop:'<path d="M7 7V17H17V7H7ZM6 5H18C18.5523 5 19 5.44772 19 6V18C19 18.5523 18.5523 19 18 19H6C5.44772 19 5 18.5523 5 18V6C5 5.44772 5.44772 5 6 5Z" fill="currentColor"/>',subtract:'<path d="M5 11V13H19V11H5Z" fill="currentColor"/>',survey:'<path d="M17 2V4H20.0066C20.5552 4 21 4.44495 21 4.9934V21.0066C21 21.5552 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5551 3 21.0066V4.9934C3 4.44476 3.44495 4 3.9934 4H7V2H17ZM7 6H5V20H19V6H17V8H7V6ZM9 16V18H7V16H9ZM9 13V15H7V13H9ZM9 10V12H7V10H9ZM15 4H9V6H15V4Z" fill="currentColor"/>',target:'<path d="M12 1.99999C12.5523 1.99999 13 2.4477 13 2.99999C12.9999 3.55224 12.5522 3.99999 12 3.99999C7.58172 3.99999 4 7.58171 4 12C4.00004 16.4182 7.58174 20 12 20C16.4182 20 19.9999 16.4182 20 12C20 11.4477 20.4477 11 21 11C21.5523 11 22 11.4477 22 12C21.9999 17.5228 17.5228 22 12 22C6.47717 22 2.00004 17.5228 2 12C2 6.47714 6.47715 1.99999 12 1.99999ZM12 5.99999C12.5523 5.99999 13 6.4477 13 6.99999C12.9999 7.55224 12.5522 7.99999 12 7.99999C9.79085 7.99999 7.99999 9.79085 7.99999 12C8.00004 14.2091 9.79088 16 12 16C14.2091 16 15.9999 14.2091 16 12C16 11.4477 16.4477 11 17 11C17.5523 11 18 11.4477 18 12C17.9999 15.3137 15.3137 18 12 18C8.68631 18 6.00004 15.3137 6 12C6 8.68628 8.68629 5.99999 12 5.99999ZM17.6562 2.10057C18.0468 1.71005 18.6807 1.71005 19.0713 2.10057C19.4614 2.49105 19.4615 3.12419 19.0713 3.51463L18.3633 4.22069L18.3642 4.22167C17.9737 4.61219 17.9737 5.2452 18.3642 5.63573C18.7548 6.02612 19.3878 6.02621 19.7783 5.63573L20.4853 4.9287C20.8759 4.53839 21.5089 4.53826 21.8994 4.9287C22.2899 5.31915 22.2897 5.95222 21.8994 6.34276L19.7783 8.46483C19.5909 8.65223 19.3363 8.75671 19.0713 8.75682H16.6572L12.707 12.707C12.3165 13.0974 11.6834 13.0974 11.293 12.707C10.9025 12.3165 10.9026 11.6835 11.293 11.293L15.2422 7.34374V4.9287C15.2422 4.66356 15.3477 4.40916 15.5351 4.22167L17.6562 2.10057Z" fill="currentColor"/>',"target-fill":'<path d="M12 2C12.5523 2 13 2.44772 13 3C13 3.55228 12.5523 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20C16.4183 20 20 16.4183 20 12C20 11.4477 20.4477 11 21 11C21.5523 11 22 11.4477 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2ZM12 6C12.5523 6 13 6.44772 13 7C13 7.55228 12.5523 8 12 8C9.79086 8 8 9.79086 8 12C8 14.2091 9.79086 16 12 16C14.2091 16 16 14.2091 16 12C16 11.4477 16.4477 11 17 11C17.5523 11 18 11.4477 18 12C18 15.3137 15.3137 18 12 18C8.68629 18 6 15.3137 6 12C6 8.68629 8.68629 6 12 6ZM18.5713 2.10059C18.8474 2.1006 19.0712 2.32449 19.0713 2.60059V4.42969C19.0716 4.70553 19.2954 4.92866 19.5713 4.92871H21.3994C21.6754 4.92871 21.8992 5.15275 21.8994 5.42871V6.34375L20.0107 8.23242C19.6358 8.60719 19.1268 8.81824 18.5967 8.81836H16.5967L12.707 12.707C12.3165 13.0974 11.6835 13.0975 11.293 12.707C10.9027 12.3165 10.9026 11.6834 11.293 11.293L15.1826 7.4043V5.4043C15.1826 4.87411 15.3928 4.36526 15.7676 3.99023L17.6572 2.10059H18.5713Z" fill="currentColor"/>',task:'<path d="M19 4H5V20H19V4ZM3 2.9918C3 2.44405 3.44749 2 3.9985 2H19.9997C20.5519 2 20.9996 2.44772 20.9997 3L21 20.9925C21 21.5489 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918ZM11.2929 13.1213L15.5355 8.87868L16.9497 10.2929L11.2929 15.9497L7.40381 12.0607L8.81802 10.6464L11.2929 13.1213Z" fill="currentColor"/>',terminal:'<path d="M10.9999 12L3.92886 19.0711L2.51465 17.6569L8.1715 12L2.51465 6.34317L3.92886 4.92896L10.9999 12ZM10.9999 19H20.9999V21H10.9999V19Z" fill="currentColor"/>',"terminal-box":'<path d="M3 3H21C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3ZM4 5V19H20V5H4ZM12 15H18V17H12V15ZM8.66685 12L5.83842 9.17157L7.25264 7.75736L11.4953 12L7.25264 16.2426L5.83842 14.8284L8.66685 12Z" fill="currentColor"/>',"terminal-window":'<path d="M20 9V5H4V9H20ZM20 11H4V19H20V11ZM3 3H21C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3ZM5 12H8V17H5V12ZM5 6H7V8H5V6ZM9 6H11V8H9V6Z" fill="currentColor"/>',text:'<path d="M13 6V21H11V6H5V4H19V6H13Z" fill="currentColor"/>',"text-wrap":'<path d="M15 18H16.5C17.8807 18 19 16.8807 19 15.5C19 14.1193 17.8807 13 16.5 13H3V11H16.5C18.9853 11 21 13.0147 21 15.5C21 17.9853 18.9853 20 16.5 20H15V22L11 19L15 16V18ZM3 4H21V6H3V4ZM9 18V20H3V18H9Z" fill="currentColor"/>',time:'<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM13 12H17V14H11V7H13V12Z" fill="currentColor"/>',timer:'<path d="M17.6177 5.9681L19.0711 4.51472L20.4853 5.92893L19.0319 7.38231C20.2635 8.92199 21 10.875 21 13C21 17.9706 16.9706 22 12 22C7.02944 22 3 17.9706 3 13C3 8.02944 7.02944 4 12 4C14.125 4 16.078 4.73647 17.6177 5.9681ZM12 20C15.866 20 19 16.866 19 13C19 9.13401 15.866 6 12 6C8.13401 6 5 9.13401 5 13C5 16.866 8.13401 20 12 20ZM11 8H13V14H11V8ZM8 1H16V3H8V1Z" fill="currentColor"/>',tools:'<path d="M5.32943 3.27158C6.56252 2.8332 7.9923 3.10749 8.97927 4.09446C10.1002 5.21537 10.3019 6.90741 9.5843 8.23385L20.293 18.9437L18.8788 20.3579L8.16982 9.64875C6.84325 10.3669 5.15069 10.1654 4.02952 9.04421C3.04227 8.05696 2.7681 6.62665 3.20701 5.39332L5.44373 7.63C6.02952 8.21578 6.97927 8.21578 7.56505 7.63C8.15084 7.04421 8.15084 6.09446 7.56505 5.50868L5.32943 3.27158ZM15.6968 5.15512L18.8788 3.38736L20.293 4.80157L18.5252 7.98355L16.7574 8.3371L14.6361 10.4584L13.2219 9.04421L15.3432 6.92289L15.6968 5.15512ZM8.97927 13.2868L10.3935 14.7011L5.09018 20.0044C4.69966 20.3949 4.06649 20.3949 3.67597 20.0044C3.31334 19.6417 3.28744 19.0699 3.59826 18.6774L3.67597 18.5902L8.97927 13.2868Z" fill="currentColor"/>',"twitter-xfill":'<path d="M17.6874 3.0625L12.6907 8.77425L8.37045 3.0625H2.11328L9.58961 12.8387L2.50378 20.9375H5.53795L11.0068 14.6886L15.7863 20.9375H21.8885L14.095 10.6342L20.7198 3.0625H17.6874ZM16.6232 19.1225L5.65436 4.78217H7.45745L18.3034 19.1225H16.6232Z" fill="currentColor"/>',unpin:'<path d="M20.9701 17.1716 19.5559 18.5858 16.0214 15.0513 15.9476 15.1251 15.2405 18.6606 13.8263 20.0748 9.58369 15.8322 4.63394 20.7819 3.21973 19.3677 8.16947 14.418 3.92683 10.1753 5.34105 8.7611 8.87658 8.05399 8.95029 7.98028 5.41373 4.44371 6.82794 3.0295 20.9701 17.1716ZM10.3645 9.39449 9.86261 9.8964 7.04072 10.4608 13.5409 16.9609 14.1052 14.139 14.6071 13.6371 10.3645 9.39449ZM18.7761 9.46821 17.4356 10.8087 18.8498 12.2229 20.1903 10.8824 20.8974 11.5895 22.3116 10.1753 13.8263 1.69003 12.4121 3.10425 13.1192 3.81135 11.7787 5.15185 13.1929 6.56607 14.5334 5.22557 18.7761 9.46821Z" fill="currentColor"/>',user:'<path d="M4 22C4 17.5817 7.58172 14 12 14C16.4183 14 20 17.5817 20 22H18C18 18.6863 15.3137 16 12 16C8.68629 16 6 18.6863 6 22H4ZM12 13C8.685 13 6 10.315 6 7C6 3.685 8.685 1 12 1C15.315 1 18 3.685 18 7C18 10.315 15.315 13 12 13ZM12 11C14.21 11 16 9.21 16 7C16 4.79 14.21 3 12 3C9.79 3 8 4.79 8 7C8 9.21 9.79 11 12 11Z" fill="currentColor"/>',"user-3":'<path d="M20 22H18V20C18 18.3431 16.6569 17 15 17H9C7.34315 17 6 18.3431 6 20V22H4V20C4 17.2386 6.23858 15 9 15H15C17.7614 15 20 17.2386 20 20V22ZM12 13C8.68629 13 6 10.3137 6 7C6 3.68629 8.68629 1 12 1C15.3137 1 18 3.68629 18 7C18 10.3137 15.3137 13 12 13ZM12 11C14.2091 11 16 9.20914 16 7C16 4.79086 14.2091 3 12 3C9.79086 3 8 4.79086 8 7C8 9.20914 9.79086 11 12 11Z" fill="currentColor"/>',"volume-up":'<path d="M6.60282 10.0001L10 7.22056V16.7796L6.60282 14.0001H3V10.0001H6.60282ZM2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z" fill="currentColor"/>',window:'<path d="M21 3C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H21ZM20 11H4V19H20V11ZM20 5H4V9H20V5ZM11 6V8H9V6H11ZM7 6V8H5V6H7Z" fill="currentColor"/>'},V6="pichamber-icon-sprite";let nl=!1;function JC(){if(nl||typeof document>"u")return;const e=document.body;if(!e)return;if(document.getElementById(V6)){nl=!0;return}const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.id=V6,n.setAttribute("aria-hidden","true"),n.style.display="none",n.innerHTML=Object.entries(YC).map(([s,o])=>`<symbol id="oc-${s}" viewBox="0 0 24 24">${o}</symbol>`).join(""),e.insertBefore(n,e.firstChild),nl=!0}const z=d.memo(({name:e,className:t,...n})=>(typeof document<"u"&&JC(),i.jsx("svg",{className:B("remixicon",t),viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",...n,children:i.jsx("use",{href:`#oc-${e}`})})));z.displayName="Icon";const y4=ae.memo(function({checked:t,onChange:n,disabled:s=!1,indeterminate:o,ariaLabel:r,className:a,iconClassName:l}){const c="h-[14px] w-[14px] min-h-[14px] min-w-[14px]",u="h-[10px] w-[10px] min-h-[10px] min-w-[10px]",f=t||o;return i.jsx(fy,{checked:t,onCheckedChange:h=>n(!!h),disabled:s,indeterminate:o,"aria-label":r,className:B("group/checkbox relative flex shrink-0 self-center items-center justify-center rounded-[4px] border outline-none",c,"transition-[background-color,border-color,box-shadow] duration-200 ease-out",f?"border-[color:color-mix(in_srgb,var(--primary-base)_65%,var(--interactive-border))] bg-transparent shadow-none hover:bg-[var(--interactive-hover)] hover:border-[color:color-mix(in_srgb,var(--primary-base)_75%,var(--interactive-border))]":"border-[var(--interactive-border)] bg-transparent shadow-none hover:bg-[var(--interactive-hover)] hover:border-[var(--interactive-border)]","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-transparent","disabled:cursor-not-allowed disabled:opacity-50",a),children:i.jsx(hy,{keepMounted:!0,className:B("flex items-center justify-center text-[var(--primary-base)]","data-[unchecked]:hidden",l),children:o?i.jsx(z,{name:"subtract",className:B(u,"text-[var(--primary-base)]")}):i.jsx(z,{name:"check",className:B(u,"text-[var(--primary-base)]")})})})});function Bt({className:e,type:t,...n}){return i.jsx("input",{type:t,"data-slot":"input",className:B("text-foreground file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground bg-[var(--surface-elevated)] appearance-none flex h-9 w-full min-w-0 rounded-lg px-3 py-1 typography-markdown outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:typography-ui-label file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:typography-ui-label","ring-1 ring-inset ring-border/60 transition duration-200 ease-out","hover:[&:not(:focus)]:bg-[var(--surface-subtle)] hover:[&:not(:focus)]:ring-transparent","focus:ring-2 focus:ring-[var(--interactive-focus-ring)] focus-visible:outline-none","aria-invalid:ring-[var(--status-error)] aria-invalid:focus:ring-[var(--status-error)]",e),spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",...n})}const N6=async e=>{const t=await gt(e);t.ok||console.error("Failed to copy to clipboard:",t.error)},hi=e=>e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(hi).join(" ").trim():ae.isValidElement(e)?hi(e.props?.children):"",XC=e=>typeof e=="function"?e():e,P6=(e,t)=>{const n=hi(XC(t?.description));return n.length>0?n:hi(e)},Ue={...as,success:(e,t)=>as.success(e,{...t,action:t?.action||{label:"OK",onClick:()=>{}}}),info:(e,t)=>as.info(e,{...t,action:t?.action||{label:"OK",onClick:()=>{}}}),error:(e,t)=>as.error(e,{...t,action:t?.action||{label:"Copy",onClick:()=>N6(P6(e,t))}}),warning:(e,t)=>as.warning(e,{...t,action:t?.action||{label:"Copy",onClick:()=>N6(P6(e,t))}})};let Ko=0;function QC(e,t){return e&&ae.isValidElement(t)?{render:t}:{children:t}}function On({...e}){return i.jsx(my,{...e})}function eS({asChild:e,children:t,...n}){const s=QC(e,t);return i.jsx(wy,{"data-slot":"dialog-trigger",...n,...s})}function tS({...e}){return i.jsx(by,{...e})}const cf=ae.forwardRef(({className:e,...t},n)=>(ae.useEffect(()=>(Ko+=1,document.documentElement.classList.add("oc-dialog-open"),()=>{Ko=Math.max(0,Ko-1),Ko===0&&document.documentElement.classList.remove("oc-dialog-open")}),[]),i.jsx(xy,{ref:n,"data-slot":"dialog-overlay",className:B("oc-glass-backdrop fixed inset-0 z-50 bg-black/25 dark:bg-black/40","transition-opacity duration-150 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0",e),...t})));cf.displayName="DialogOverlay";function Zn({className:e,children:t,showCloseButton:n=!0,...s}){return i.jsxs(tS,{children:[i.jsx(cf,{className:"rounded-none"}),i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none p-4",children:i.jsxs(py,{"data-slot":"dialog-content","data-state-slot":"dialog",className:B("relative pointer-events-auto bg-background text-foreground flex flex-col w-full max-w-lg max-h-full gap-4 rounded-xl border p-6 shadow-none overflow-y-auto pwa-dialog-content origin-center","transition-all duration-150 ease-out","data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]","data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]","data-[nested-dialog-open]:brightness-[0.55] dark:data-[nested-dialog-open]:brightness-[0.4]",e),...s,children:[t,n&&i.jsxs(gy,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[open]:bg-interactive-active data-[open]:text-foreground absolute top-2 right-2 rounded-lg opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none text-muted-foreground hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[i.jsx(z,{name:"close"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})})]})}function Fn({className:e,...t}){return i.jsx("div",{"data-slot":"dialog-header",className:B("flex flex-col gap-2 text-center sm:text-left",e),...t})}function sZ({className:e,...t}){return i.jsx("div",{"data-slot":"dialog-footer",className:B("flex flex-col-reverse gap-2 bottom-safe-area sm:flex-row sm:justify-end",e),...t})}function $n({className:e,...t}){return i.jsx(yy,{"data-slot":"dialog-title",className:B("typography-markdown leading-none font-semibold text-foreground",e),...t})}function ao({className:e,...t}){return i.jsx(vy,{"data-slot":"dialog-description",className:B("text-muted-foreground typography-ui-label",e),...t})}const nS=600,sS=1600,E6=10,df=ae.createContext(null);class uf extends ae.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback??null:this.props.children}}function oS({delayDuration:e=0,skipDelayDuration:t,delay:n,closeDelay:s,...o}){return i.jsx(My,{delay:n??e,closeDelay:s??t,...o})}function q1({delayDuration:e,open:t,onOpenChange:n,...s}){const[o,r]=ae.useState(!1),a=ae.useRef(null),l=ae.useRef(null),c=ae.useRef(null),u=ae.useRef(!1),f=t!==void 0,h=f?t:o,m=ae.useCallback(()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)},[]),p=ae.useCallback(()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},[]),g=ae.useCallback(v=>{f||r(v)},[f]),y=ae.useMemo(()=>({handlePointerDown:v=>{v.pointerType!=="touch"&&v.pointerType!=="pen"||(m(),p(),c.current={x:v.clientX,y:v.clientY},a.current=window.setTimeout(()=>{f||(u.current=!0,g(!0))},nS))},handlePointerMove:v=>{const x=c.current;if(!x)return;const S=Math.abs(v.clientX-x.x),C=Math.abs(v.clientY-x.y);(S>E6||C>E6)&&(m(),c.current=null)},handlePointerEnd:()=>{m(),c.current=null,u.current&&(p(),l.current=window.setTimeout(()=>{u.current=!1,g(!1)},sS))},handleClickCapture:v=>{u.current&&(u.current=!1,v.preventDefault(),v.stopPropagation())},handleContextMenu:v=>{u.current&&v.preventDefault()}}),[p,m,f,g]);ae.useEffect(()=>()=>{m(),p()},[p,m]);const M=ae.useCallback((v,x)=>{f||r(v),n?.(v,x)},[f,n]),b=i.jsx(df.Provider,{value:y,children:i.jsx(Cy,{open:h,onOpenChange:M,...s})});return e===void 0?b:i.jsx(oS,{delayDuration:e,children:b})}function U1({asChild:e,children:t,onPointerDown:n,onPointerMove:s,onPointerUp:o,onPointerCancel:r,onClickCapture:a,onContextMenu:l,...c}){const u=ae.useContext(df),f=e&&ae.isValidElement(t)?{render:t}:{children:t};return i.jsx(uf,{fallback:t,children:i.jsx(Sy,{"data-slot":"tooltip-trigger",onPointerDown:h=>{n?.(h),u?.handlePointerDown(h)},onPointerMove:h=>{s?.(h),u?.handlePointerMove(h)},onPointerUp:h=>{o?.(h),u?.handlePointerEnd()},onPointerCancel:h=>{r?.(h),u?.handlePointerEnd()},onClickCapture:h=>{u?.handleClickCapture(h),!h.defaultPrevented&&a?.(h)},onContextMenu:h=>{u?.handleContextMenu(h),!h.defaultPrevented&&l?.(h)},...c,...f})})}function G1({className:e,sideOffset:t=0,side:n,align:s,children:o,style:r,...a}){return i.jsx(uf,{children:i.jsx(_y,{children:i.jsx(ky,{sideOffset:t,side:n,align:s,className:"z-50",children:i.jsxs(Ay,{"data-slot":"tooltip-content",className:B("oc-glass-tooltip text-[var(--surface-elevated-foreground)] border border-border/60 transition-all duration-150 ease-out data-[starting-style]:opacity-0 data-[starting-style]:scale-95 data-[ending-style]:opacity-0 data-[ending-style]:scale-95 data-[instant]:transition-none data-[instant]:duration-0 z-50 w-fit origin-[var(--transform-origin)] rounded-xl px-3 py-1.5 typography-meta text-balance overflow-hidden",e),style:{...r},...a,children:[o,i.jsx(Hy,{className:"fill-[var(--surface-elevated)] z-50 size-2"})]})})})})}const T1="local",ff=e=>({id:T1,label:"Local",url:e||Ki()}),Ki=()=>typeof window>"u"?"":window.__PICHAMBER_LOCAL_ORIGIN__||window.location.origin,Ys=e=>e.id===T1?"local":`host:${e.id}`,hf=e=>{const t=typeof window>"u"?"":window.location.href,n=e.find(f=>f.id===T1)?.url||Ki(),s=Ti(),o=L2(n)||n,r=L2(t)||t,a=We(),l=e.find(f=>f.relay&&Ys(f)===a);if(l)return{id:l.id,label:l.label,url:l.url};if(s&&Vo(s,n))return{id:T1,label:"Local",url:o};const c=e.find(f=>s?Vo(s,T0(f)):!1);if(c)return{id:c.id,label:c.label,url:L2(T0(c))||T0(c)};if(t&&Vo(t,n))return{id:T1,label:"Local",url:o};const u=e.find(f=>t?Vo(t,f.url):!1);return u?{id:u.id,label:u.label,url:L2(u.url)||u.url}:t.startsWith("pichamber-ui://")?{id:T1,label:"Local",url:o}:{id:"custom",label:T2(r||"Instance"),url:r}},oZ=Object.freeze(Object.defineProperty({__proto__:null,LOCAL_HOST_ID:T1,buildLocalDesktopHost:ff,getLocalDesktopOrigin:Ki,resolveCurrentDesktopHost:hf,runtimeKeyForDesktopHost:Ys},Symbol.toStringTag,{value:"Module"})),q2=e=>typeof e=="object"&&e!==null,H1=(e,t)=>{const n=e[t];return typeof n=="string"?n:null},X1=(e,t)=>{const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:null},st=(e,t)=>{const n=e[t];return typeof n=="boolean"?n:null},rS=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):[],d0=()=>a3()?(e,t)=>tt(e,t):null,z6=e=>{if(!q2(e))return;const t=st(e,"enabled")??!1,s=H1(e,"store")?.toLowerCase()==="settings"?"settings":"never",o=H1(e,"value");return{enabled:t,store:s,...o?{value:o}:{}}},iS=e=>e==="remote"||e==="dynamic"?e:"local",aS=e=>{if(!q2(e))return null;const t=H1(e,"id");if(!t)return null;const n=st(e,"enabled")??!0,s=iS(H1(e,"type")),o=H1(e,"localHost")||H1(e,"local_host")||void 0,r=X1(e,"localPort")??X1(e,"local_port")??void 0,a=H1(e,"remoteHost")||H1(e,"remote_host")||void 0,l=X1(e,"remotePort")??X1(e,"remote_port")??void 0;return{id:t,enabled:n,type:s,...o?{localHost:o}:{},...typeof r=="number"?{localPort:r}:{},...a?{remoteHost:a}:{},...typeof l=="number"?{remotePort:l}:{}}},lS=e=>{if(!q2(e))return null;const t=H1(e,"id"),n=H1(e,"sshCommand")||H1(e,"ssh_command");if(!t||!n)return null;const s=H1(e,"nickname"),o=e.sshParsed,r=q2(o)?{destination:H1(o,"destination")||"",args:rS(o.args)}:void 0,a=q2(e.remoteOpenchamber)?e.remoteOpenchamber:q2(e.remote_pichamber)?e.remote_pichamber:{},l=q2(e.localForward)?e.localForward:q2(e.local_forward)?e.local_forward:{},c=q2(e.auth)?e.auth:{},f=H1(a,"mode")?.toLowerCase()==="external"?"external":"managed",h=H1(a,"installMethod")||H1(a,"install_method"),m=h==="npm"||h==="download_release"||h==="upload_bundle"?h:"bun",p=H1(l,"bindHost")||H1(l,"bind_host")||"127.0.0.1",g=p==="localhost"||p==="0.0.0.0"?p:"127.0.0.1",M=(Array.isArray(e.portForwards)?e.portForwards:Array.isArray(e.port_forwards)?e.port_forwards:[]).map(C=>aS(C)).filter(C=>!!C),b=X1(a,"preferredPort")??X1(a,"preferred_port"),v=X1(l,"preferredLocalPort")??X1(l,"preferred_local_port"),x=z6(c.sshPassword||c.ssh_password),S=z6(c.pichamberPassword||c.pichamberPassword||c.pichamber_password);return{id:t,...s?{nickname:s}:{},sshCommand:n,...r&&r.destination?{sshParsed:r}:{},connectionTimeoutSec:X1(e,"connectionTimeoutSec")??X1(e,"connection_timeout_sec")??60,remoteOpenchamber:{mode:f,keepRunning:st(a,"keepRunning")??st(a,"keep_running")??!0,...b?{preferredPort:b}:{},installMethod:m,uploadBundleOverSsh:st(a,"uploadBundleOverSsh")??st(a,"upload_bundle_over_ssh")??!1},localForward:{...v?{preferredLocalPort:v}:{},bindHost:g},auth:{...x?{sshPassword:x}:{},...S?{pichamberPassword:S}:{}},portForwards:M}},cS=e=>{switch(e){case"config_resolved":case"auth_check":case"master_connecting":case"remote_probe":case"installing":case"updating":case"server_detecting":case"server_starting":case"forwarding":case"ready":case"degraded":case"error":return e;default:return"idle"}},mf=e=>{if(!q2(e))return null;const t=H1(e,"id");return t?{id:t,phase:cS(H1(e,"phase")),...H1(e,"detail")?{detail:H1(e,"detail")||void 0}:{},...H1(e,"localUrl")||H1(e,"local_url")?{localUrl:H1(e,"localUrl")||H1(e,"local_url")||void 0}:{},...typeof(X1(e,"localPort")??X1(e,"local_port"))=="number"?{localPort:X1(e,"localPort")??X1(e,"local_port")??void 0}:{},...typeof(X1(e,"remotePort")??X1(e,"remote_port"))=="number"?{remotePort:X1(e,"remotePort")??X1(e,"remote_port")??void 0}:{},startedByUs:st(e,"startedByUs")??st(e,"started_by_us")??!1,retryAttempt:X1(e,"retryAttempt")??X1(e,"retry_attempt")??0,requiresUserAction:st(e,"requiresUserAction")??st(e,"requires_user_action")??!1,updatedAtMs:X1(e,"updatedAtMs")??X1(e,"updated_at_ms")??Date.now()}:null},dS=e=>{if(!q2(e))return null;const t=H1(e,"host"),n=H1(e,"source"),s=H1(e,"sshCommand")||H1(e,"ssh_command");return!t||!n||!s?null:{host:t,source:n,sshCommand:s,pattern:st(e,"pattern")??!1}},rZ=(e,t)=>({id:e,sshCommand:t,connectionTimeoutSec:60,remoteOpenchamber:{mode:"managed",keepRunning:!0,installMethod:"bun",uploadBundleOverSsh:!1},localForward:{bindHost:"127.0.0.1"},auth:{},portForwards:[]}),uS=async()=>{const e=d0();if(!e)return{instances:[]};const t=await e("desktop_ssh_instances_get");return q2(t)?{instances:(Array.isArray(t.instances)?t.instances:Array.isArray(t.desktopSshInstances)?t.desktopSshInstances:[]).map(o=>lS(o)).filter(o=>!!o)}:{instances:[]}},iZ=async e=>{const t=d0();t&&await t("desktop_ssh_instances_set",{config:{instances:e.instances}})},aZ=async()=>{const e=d0();if(!e)return[];const t=await e("desktop_ssh_import_hosts");return Array.isArray(t)?t.map(n=>dS(n)).filter(n=>!!n):[]},D6=async e=>{const t=d0();t&&await t("desktop_ssh_connect",{id:e})},fS=async e=>{const t=d0();t&&await t("desktop_ssh_disconnect",{id:e})},D3=async e=>{const t=d0();if(!t)return[];const n=await t("desktop_ssh_status",{...e?{id:e}:{}});return Array.isArray(n)?n.map(s=>mf(s)).filter(s=>!!s):[]},lZ=async(e,t)=>{const n=d0();if(!n)return[];const s=await n("desktop_ssh_logs",{id:e,limit:t});return Array.isArray(s)?s.filter(o=>typeof o=="string"):[]},cZ=async e=>{const t=d0();t&&await t("desktop_ssh_logs_clear",{id:e})},dZ=async e=>{if(!a3())return async()=>{};const n=window.__PICHAMBER_DESKTOP__?.listen;if(typeof n!="function")return async()=>{};const s=await n("pichamber:ssh-instance-status",o=>{const r=mf(o?.payload);r&&e(r)});return async()=>{await s()}},R6=9e4,mi="SSH connection cancelled",O6={},fs=e=>{const t=L2(e);if(!t)return e.trim();try{const n=new URL(t);return n.pathname.endsWith("/")||(n.pathname=`${n.pathname}/`),n.toString()}catch{return t}},sl=async()=>wr()?Ng().catch(()=>""):"",hS=e=>e==="ok"?"bg-status-success":e==="auth"||e==="update-recommended"?"bg-status-warning":e==="incompatible"||e==="wrong-service"||e==="unreachable"?"bg-status-error":e==="checking"?"bg-status-info":"bg-muted-foreground/40",mS=e=>e==="ok"?"text-[var(--status-success)]":e==="auth"||e==="update-recommended"?"text-[var(--status-warning)]":e==="incompatible"||e==="wrong-service"||e==="unreachable"?"text-[var(--status-error)]":"text-muted-foreground",ol=e=>e==="unreachable"||e==="wrong-service"||e==="incompatible",Yo=e=>e==="unreachable"||e==="wrong-service"||e==="incompatible",pS=e=>e==="ok"?"Connected":e==="auth"?"Auth required":e==="checking"?"Checking":e==="update-recommended"?"Update recommended":e==="incompatible"?"Incompatible":e==="wrong-service"?"Wrong service":e==="unreachable"?"Unreachable":"Unknown",gS=e=>new Promise(t=>window.setTimeout(t,e)),Z6=e=>{switch(e){case"ready":return"Ready";case"error":return"Error";case"degraded":return"Reconnecting";case"config_resolved":return"Resolving config";case"auth_check":return"Checking auth";case"master_connecting":return"Connecting SSH";case"remote_probe":return"Probing remote";case"installing":return"Installing";case"updating":return"Updating";case"server_detecting":return"Detecting server";case"server_starting":return"Starting server";case"forwarding":return"Forwarding ports";default:return"Idle"}},yS=e=>!e||e==="idle"?null:e==="ready"?"ok":e==="error"?"unreachable":"auth",F6=async()=>{const e=await D3().catch(()=>[]),t={};for(const n of e)t[n.id]=n;return t},$6=async(e,t,n,s)=>{const o=Date.now()+t;for(;Date.now()<o;){if(s?.())throw new Error(mi);const a=(await D3(e).catch(()=>[])).find(l=>l.id===e);if(a){if(n(a),a.phase==="ready")return a;if(a.phase==="error")throw new Error(a.detail||"SSH connection failed")}await gS(700)}throw s?.()?new Error(mi):new Error("Timed out waiting for SSH connection")};function vS({open:e,onOpenChange:t,embedded:n=!1,onHostSwitched:s}){const o=he(T=>T.setSettingsDialogOpen),r=he(T=>T.setSettingsPage),[a,l]=ae.useState([]),[c,u]=ae.useState(null),[f,h]=ae.useState(()=>({...O6}));ae.useEffect(()=>{Object.assign(O6,f)},[f]);const[m,p]=ae.useState(!1),[g,y]=ae.useState(!1),[M,b]=ae.useState(!1),[v,x]=ae.useState(null),[S,C]=ae.useState({}),[w,_]=ae.useState({}),[L,A]=ae.useState({open:!1,hostId:null,hostLabel:"",phase:"idle",detail:null,error:null}),[N,k]=ae.useState(""),[V,H]=ae.useState(()=>Ki()),[D,P]=ae.useState(null),[R,$]=ae.useState(""),[O,I]=ae.useState(""),[q,G]=ae.useState(0),K=ae.useRef(0),W=ae.useMemo(()=>{const T=ff(V),Q=a.map(se=>({...se,url:L2(se.url)||se.url}));return[T,...Q]},[a,V]);ae.useEffect(()=>Wn(()=>G(T=>T+1)),[]);const ge=ae.useMemo(()=>hf(W),[W,q]),Z=ae.useMemo(()=>{const T=c||T1;return W.find(Q=>Q.id===T)?.label||"Local"},[W,c]),fe=ae.useCallback(async(T,Q)=>{if(S1()){b(!0),k("");try{const se=T.filter(ye=>ye.id!==T1);await Fl({hosts:se,defaultHostId:Q}),l(se),u(Q)}catch(se){k(se instanceof Error?se.message:"Failed to save")}finally{b(!1)}}},[]),ie=ae.useCallback(()=>{r("remote-instances"),o(!0),t(!1)},[t,o,r]),E=ae.useCallback(async()=>{if(S1()){p(!0),k("");try{const[T,Q,se]=await Promise.all([h9(),uS().catch(()=>({instances:[]})),F6()]);T.localOrigin&&H(T.localOrigin);const ye={};for(const le of Q.instances)ye[le.id]=!0;l(T.hosts||[]),u(T.defaultHostId??null),C(ye),_(se)}catch(T){k(T instanceof Error?T.message:"Failed to load"),l([]),u(null),C({}),_({})}finally{p(!1)}}},[]),ce=ae.useCallback(async T=>{if(S1()){y(!0);try{const Q=await sl(),se=await Promise.all(T.map(async le=>{const ne=le.id===T1?Q:le.clientToken||"",Ce=async()=>{const Ve=await dc(le.relay,{clientToken:ne,requestHeaders:le.requestHeaders||null}).catch(()=>({status:"unreachable",latencyMs:0}));return{status:Ve.status,latencyMs:Ve.latencyMs,...Ve.status==="ok"?{via:"relay"}:{}}};if(le.relay&&!le.apiUrl)return[le.id,await Ce()];const Se=L2(wr()?T0(le):le.url);if(!Se)return[le.id,{status:"unreachable",latencyMs:0}];const Ae=await La(Se,{clientToken:ne||null,requestHeaders:le.requestHeaders||null}).catch(()=>({status:"unreachable",latencyMs:0}));if(ol(Ae.status)&&le.relay){const Ve=await Ce();if(Ve.status==="ok")return[le.id,Ve]}return[le.id,{status:Ae.status,latencyMs:Ae.latencyMs}]})),ye={};for(const[le,ne]of se)ye[le]=ne;h(ye)}finally{y(!1)}}},[]);ae.useEffect(()=>{if(!e){P(null),$(""),I(""),x(null),A({open:!1,hostId:null,hostLabel:"",phase:"idle",detail:null,error:null}),k("");return}E()},[e,E]),ae.useEffect(()=>{e&&ce(W)},[e,W,ce]),ae.useEffect(()=>{if(!e||!S1())return;let T=!1;const Q=async()=>{const ye=await F6();T||_(ye)};Q();const se=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||Q()},1500);return()=>{T=!0,window.clearInterval(se)}},[e]);const ee=ae.useCallback(async T=>{const Q=(Se,Ae)=>{Ae&&Pg({relayUrl:Se.relayUrl,serverId:Se.serverId,hostEncPubJwk:Se.hostEncPubJwk},Ae),Hs({apiBaseUrl:typeof window<"u"?window.location.origin:"",clientToken:T.clientToken||null,runtimeKey:Ys(T),relay:Se}),Eg(T.id)},se=T.id===T1?V:L2(T.url)||"",ye=T.id===T1?V:L2(T0(T))||"",le=!!T.relay&&!T.apiUrl&&T.id!==T1;if(!se&&!le)return;if(wr()){if(!ye&&!T.relay)return;x(T.id);const Se=T.id===T1?await sl():T.clientToken||"",Ae=f[T.id];if(Ae?.status==="ok"){Ae.via==="relay"&&T.relay?Q(T.relay):ye?Hs({apiBaseUrl:ye,clientToken:Se||null,requestHeaders:T.requestHeaders||null,runtimeKey:Ys(T)}):T.relay&&Q(T.relay),s?.(),x(null);return}let Ve={status:"unreachable",latencyMs:0},Me=null;if(ye){const qe=await La(ye,{clientToken:Se||null,requestHeaders:T.requestHeaders||null}).catch(()=>({status:"unreachable",latencyMs:0}));Ve={status:qe.status,latencyMs:qe.latencyMs},ol(qe.status)||(Me="direct")}let Ie;if(!Me&&T.relay){const qe=await dc(T.relay,{keepTunnel:!0,clientToken:Se||null,requestHeaders:T.requestHeaders||null}).catch(()=>({status:"unreachable",latencyMs:0}));qe.status==="ok"&&(Ve={status:qe.status,latencyMs:qe.latencyMs,via:"relay"},Me="relay",Ie="tunnel"in qe?qe.tunnel:void 0)}if(h(qe=>({...qe,[T.id]:Ve})),!Me){Ue.error(`Instance \\"${T2(T.label)}\\" is unreachable`),x(null);return}Me==="relay"&&T.relay?Q(T.relay,Ie):Hs({apiBaseUrl:ye,clientToken:Se||null,requestHeaders:T.requestHeaders||null,runtimeKey:Ys(T)}),s?.(),x(null);return}const ne=!!S[T.id];if(T.id!==T1&&ne&&S1()){let Se=w[T.id];const Ae=await D3(T.id).then(Ie=>Ie.find(qe=>qe.id===T.id)||null).catch(()=>null);Ae&&(Se=Ae,_(Ie=>({...Ie,[T.id]:Ae})));const Ve=L2(Se?.localUrl||T.url||"");if(Se?.phase==="ready"&&Ve){const Ie=fs(Ve);s?.(),window.location.assign(Ie);return}x(T.id);const Me=K.current+1;K.current=Me,A({open:!0,hostId:T.id,hostLabel:T2(T.label),phase:"master_connecting",detail:null,error:null});try{if(await D6(T.id),Me!==K.current)return;const Ie=await $6(T.id,R6,de=>{_(Le=>({...Le,[de.id]:de})),A(Le=>({...Le,phase:de.phase,detail:de.detail||null}))},()=>Me!==K.current);if(Me!==K.current)return;const qe=L2(Ie.localUrl||"")||se,n1=fs(qe);s?.(),window.location.assign(n1);return}catch(Ie){if(Me!==K.current)return;const qe=Ie instanceof Error?Ie.message:String(Ie);if(qe===mi)return;A(n1=>({...n1,error:qe})),Ue.error(`SSH instance \\"${T2(T.label)}\\" failed to connect`,{description:qe});return}finally{Me===K.current&&x(null)}}if(T.id!==T1&&S1()){x(T.id);const Se=await La(se,{clientToken:T.clientToken||null,requestHeaders:T.requestHeaders||null}).catch(()=>({status:"unreachable",latencyMs:0}));if(h(Ae=>({...Ae,[T.id]:{status:Se.status,latencyMs:Se.latencyMs}})),ol(Se.status)){Ue.error(`Instance \\"${T2(T.label)}\\" is unreachable`),x(null);return}}const Ce=fs(se);s?.();try{window.location.assign(Ce)}catch{window.location.href=Ce}},[V,s,S,w,f]),ue=ae.useCallback(()=>{P(null),$(""),I("")},[]),J=ae.useCallback(T=>{T.stopPropagation()},[]),Y=ae.useCallback(async()=>{if(!D)return;if(D===T1){ue();return}const T=Bg(O);if(!T){k("Invalid URL (must be http/https)");return}const Q=T.persistedUrl,se=(R||T2(Q)).trim(),ye=a.map(le=>le.id===D?{...le,label:se,url:Q,apiUrl:Q}:le);await fe(ye,c),ue(),T.redeemUrl&&window.location.assign(T.redeemUrl)},[ue,a,c,R,O,D,fe]),oe=ae.useCallback(async T=>{await fe(a,T===T1?T1:T)},[a,fe]),te=ae.useCallback(T=>{const Q=le=>{Ue.error("Failed to open new window",{description:le instanceof Error?le.message:String(le)})};if(T.relay&&T.id!==T1){Tg(T.id).catch(Q);return}const se=T.id===T1?V:T0(T);if(!se)return;const ye=fs(se);Vg(ye,{clientToken:T.clientToken||null,requestHeaders:T.requestHeaders||null}).catch(Q)},[V]),pe=ae.useCallback(async()=>{K.current+=1,x(null),A(Q=>({...Q,open:!1,hostId:null,error:null,detail:null,phase:"idle"}));const T=fs(V);if(wr()){const Q=await sl();Hs({apiBaseUrl:V,clientToken:Q||null,runtimeKey:"local"}),s?.();return}s?.(),window.location.assign(T)},[V,s]),He=ae.useCallback(async()=>{const T=L.hostId||v;K.current+=1,x(null),A({open:!1,hostId:null,hostLabel:"",phase:"idle",detail:null,error:null}),!(!T||T===T1||!S1())&&await fS(T).catch(()=>{})},[L.hostId,v]),je=ae.useCallback(()=>{const T=L.hostId;if(!T)return;const Q=W.find(se=>se.id===T);Q&&ee(Q)},[W,ee,L.hostId]),Pe=ae.useCallback(async T=>{if(S1()){x(T.id);try{await D6(T.id),(await $6(T.id,R6,se=>{_(ye=>({...ye,[se.id]:se}))})).phase==="ready"&&Ue.success(`SSH instance \\"${T2(T.label)}\\" connected`)}catch(Q){const se=Q instanceof Error?Q.message:String(Q);se!==mi&&Ue.error(`SSH instance \\"${T2(T.label)}\\" failed to connect`,{description:se})}finally{x(null)}}},[]);if(!S1())return null;const X=S1(),me=i.jsxs(i.Fragment,{children:[n?i.jsx("div",{className:"flex-shrink-0 border-b border-[var(--interactive-border)] px-3 py-2",children:i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"min-w-0 flex items-baseline gap-1.5 typography-ui-label",children:[i.jsx("span",{className:"font-medium text-foreground",children:"Current"}),i.jsx("span",{className:"max-w-[9rem] truncate text-muted-foreground",children:T2(ge.label)}),i.jsx("span",{className:"text-muted-foreground/50",children:"•"}),i.jsx("span",{className:"font-medium text-foreground",children:"Default"}),i.jsx("span",{className:"max-w-[9rem] truncate text-muted-foreground",children:T2(Z)})]}),i.jsx("button",{type:"button",className:B("inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors","hover:text-foreground hover:bg-interactive-hover","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),onClick:()=>{ce(W)},disabled:!X||m||g,"aria-label":"Refresh instances",children:i.jsx(z,{name:"refresh",className:B("h-4 w-4",g&&"animate-spin")})})]})}):i.jsxs(Fn,{className:"flex-shrink-0",children:[i.jsxs($n,{className:"flex items-center gap-2",children:[i.jsx(z,{name:"server",className:"h-5 w-5"}),"Instance"]}),i.jsx(ao,{children:"Switch between Local and remote PiChamber servers"})]}),!n&&i.jsxs("div",{className:"flex items-center justify-between gap-2 flex-shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[i.jsx("span",{className:"typography-meta text-muted-foreground",children:"Current:"}),i.jsx("span",{className:"typography-ui-label text-foreground truncate",children:T2(ge.label)}),i.jsx("span",{className:"typography-meta text-muted-foreground",children:"Current default:"}),i.jsx("span",{className:"typography-ui-label text-foreground truncate",children:T2(Z)})]}),i.jsx("div",{className:"flex items-center gap-1",children:i.jsxs(a1,{type:"button",size:"sm",variant:"ghost",onClick:()=>{ce(W)},disabled:!X||m||g,children:[i.jsx(z,{name:"refresh",className:B("h-4 w-4",g&&"animate-spin")}),"Refresh"]})})]}),!X&&i.jsx("div",{className:"flex-shrink-0 rounded-lg border border-border/50 bg-muted/20 p-3",children:i.jsx("div",{className:"typography-meta text-muted-foreground",children:"Instance switcher is limited on this page. Use Local to recover."})}),i.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:i.jsx("div",{className:B("space-y-1",n&&"space-y-1.5 px-3 py-1"),children:m?i.jsx("div",{className:"px-2 py-2 text-muted-foreground text-sm",children:"Loading..."}):W.map(T=>{const Q=T.id===T1,se=!!S[T.id],ye=T.id===ge.id,le=(c||T1)===T.id,ne=f[T.id]||null,Ce=w[T.id]||null,Se=se?yS(Ce?.phase):ne?.status??"checking",Ae=D===T.id,Ve=Q?V:L2(T.url)||T.url,Me=T.id===T1?"Local":T2(T.label),Ie=T.relay&&!T.apiUrl?"via PiChamber Relay":T2(Ve);return i.jsxs("div",{className:B("group flex items-center gap-2 px-2.5 py-2 rounded-md overflow-hidden",n&&"rounded-xl bg-[var(--surface-muted)] px-3 py-2.5",n&&ye&&"bg-[var(--interactive-selection)]/25",Ae?"bg-interactive-hover/20":"hover:bg-interactive-hover/30"),children:[i.jsxs("button",{type:"button",className:B("flex items-center gap-2 flex-1 min-w-0 text-left",Ae&&"pointer-events-none opacity-70"),onClick:()=>{ee(T)},disabled:v===T.id,"aria-label":`Switch to ${Me}`,children:[i.jsx("span",{className:B("h-2 w-2 rounded-full flex-shrink-0",hS(Se))}),i.jsxs("div",{className:"flex-1 min-w-0 space-y-0.5",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[i.jsx("span",{className:"typography-ui-label font-medium truncate text-foreground",children:Me}),ye&&i.jsx("span",{className:"typography-micro flex-shrink-0 text-muted-foreground bg-muted px-1 rounded leading-none pb-px border border-border/50",children:"Current"}),se&&i.jsx("span",{className:"typography-micro flex-shrink-0 px-1 rounded leading-none pb-px text-[var(--status-info)] bg-[var(--status-info)]/10",children:"SSH"})]}),i.jsxs("div",{className:B("typography-micro truncate",mS(Se)),children:[se?Z6(Ce?.phase):pS(Se),!se&&Se==="ok"&&typeof ne?.latencyMs=="number"?` · ${Math.max(0,Math.round(ne.latencyMs))}ms ping`:"",!se&&ne?.via==="relay"?" · Relay":""]}),i.jsx("div",{className:"typography-micro text-muted-foreground/70 truncate font-mono",children:Ie})]})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[se&&!Q&&(Ce?.phase==="idle"||!Ce?.phase?i.jsxs(a1,{type:"button",variant:"outline",size:"sm",className:"h-8 px-2.5",disabled:v===T.id,onClick:qe=>{qe.stopPropagation(),Pe(T)},children:[v===T.id?i.jsx(z,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}):i.jsx(z,{name:"plug-2",className:"h-3.5 w-3.5"}),"Connect"]}):i.jsx("div",{className:"h-8 w-8 opacity-0 pointer-events-none","aria-hidden":"true"})),i.jsxs(q1,{children:[i.jsx(U1,{asChild:!0,children:i.jsx("button",{type:"button",className:B("h-8 w-8 rounded-md inline-flex items-center justify-center hover:bg-interactive-hover transition-colors",le?"text-primary hover:text-primary/80":"text-muted-foreground/60 hover:text-primary/80"),onClick:()=>{oe(T.id)},"aria-label":le?"Default instance":"Set as default",disabled:M||!le&&Yo(Se),children:le?i.jsx(z,{name:"star-fill",className:"h-4 w-4"}):i.jsx(z,{name:"star",className:"h-4 w-4"})})}),i.jsx(G1,{sideOffset:6,children:le?"Default":"Set as default"})]}),i.jsxs(q1,{children:[i.jsx(U1,{asChild:!0,children:i.jsx("button",{type:"button",className:B("h-8 w-8 rounded-md inline-flex items-center justify-center hover:bg-interactive-hover transition-colors",Yo(Se)?"text-muted-foreground/30 cursor-not-allowed":"text-muted-foreground/60 hover:text-foreground"),onClick:qe=>{qe.stopPropagation(),te(T)},disabled:Yo(Se),"aria-label":"Open in new window",children:i.jsx(z,{name:"window",className:"h-4 w-4"})})}),i.jsx(G1,{sideOffset:6,children:Yo(Se)?"Instance unreachable":"Open in new window"})]})]})]},T.id)})})}),X&&D&&D!==T1&&i.jsxs("div",{className:"flex-shrink-0 rounded-lg border border-border/50 bg-muted/20 p-3",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:"Edit instance"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(a1,{type:"button",variant:"outline",size:"sm",onClick:ue,disabled:M,children:"Cancel"}),i.jsxs(a1,{type:"button",size:"sm",onClick:()=>{Y()},disabled:M,children:[M?i.jsx(z,{name:"loader-4",className:"h-4 w-4 animate-spin"}):null,"Save"]})]})]}),i.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-2 sm:grid-cols-2",children:[i.jsx(Bt,{value:R,onChange:T=>$(T.target.value),onKeyDown:J,placeholder:"Label",disabled:M}),i.jsx(Bt,{value:O,onChange:T=>I(T.target.value),onKeyDown:J,placeholder:"https://host:port",disabled:M})]})]}),i.jsx("div",{className:"flex-shrink-0 border-t border-[var(--interactive-border)]",children:i.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-2 py-2 text-left text-muted-foreground hover:text-foreground hover:bg-interactive-hover/30 transition-colors",onClick:ie,children:[i.jsx(z,{name:"add",className:"h-4 w-4"}),i.jsx("span",{className:"typography-ui-label",children:"Add instance"})]})}),N&&i.jsx("div",{className:"flex-shrink-0 typography-meta text-status-error",children:N})]}),U=i.jsx(On,{open:L.open,onOpenChange:T=>{if(!T&&v){He();return}A(Q=>({...Q,open:T,...T?{}:{hostId:null,error:null,detail:null,phase:"idle"}}))},children:i.jsxs(Zn,{className:"w-[min(28rem,calc(100vw-2rem))] max-w-none",children:[i.jsxs(Fn,{children:[i.jsxs($n,{className:"flex items-center gap-2",children:[i.jsx(z,{name:"loader-4",className:B("h-4 w-4",!L.error&&"animate-spin")}),`Connecting to ${L.hostLabel||"SSH instance"}`]}),i.jsx(ao,{children:L.error?L.error:L.detail||Z6(L.phase)})]}),L.error?i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(a1,{type:"button",size:"sm",variant:"outline",onClick:()=>{pe()},children:"Switch to Local"}),i.jsx(a1,{type:"button",size:"sm",onClick:je,disabled:!L.hostId,children:"Retry"})]}):null]})});return n?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"w-full max-h-[70vh] flex flex-col overflow-hidden gap-2",children:me}),U]}):i.jsxs(i.Fragment,{children:[i.jsx(On,{open:e,onOpenChange:t,children:i.jsx(Zn,{className:"w-[min(42rem,calc(100vw-2rem))] max-w-none max-h-[70vh] flex flex-col overflow-hidden gap-3",children:me})}),U]})}function q6(){const[e,t]=ae.useState(!1);return S1()?i.jsxs(i.Fragment,{children:[i.jsxs(a1,{type:"button",variant:"ghost",size:"sm","data-oc-host-switcher":!0,className:"w-full justify-center",onClick:()=>t(!0),children:[i.jsx(z,{name:"server",className:"h-4 w-4"}),"Switch instance"]}),i.jsx(vS,{open:e,onOpenChange:t})]}):null}const R3=({className:e="",width:t=70,height:n=70,isAnimated:s=!1})=>{const o=of(),a=ae.useId().replace(/[^a-zA-Z0-9_-]/g,""),l=`pc-shimmer-mask-${a}`,c=`pc-shimmer-grad-${a}`,u=ae.useMemo(()=>{if(o)return o.currentTheme.colors.surface.foreground;if(typeof window<"u"){const f=getComputedStyle(document.documentElement).getPropertyValue("--splash-stroke").trim();return f||(window.matchMedia("(prefers-color-scheme: dark)").matches?"white":"black")}return"white"},[o]);return i.jsxs("svg",{width:t,height:n,viewBox:"0 0 100 100",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,role:"img","aria-label":"PiChamber logo",children:[s?i.jsxs(i.Fragment,{children:[i.jsxs("defs",{children:[i.jsxs("linearGradient",{id:c,gradientUnits:"userSpaceOnUse",x1:"0",y1:"0",x2:"100",y2:"100",children:[i.jsx("stop",{offset:"0%",stopColor:u,stopOpacity:"0"}),i.jsx("stop",{offset:"35%",stopColor:u,stopOpacity:"0"}),i.jsx("stop",{offset:"50%",stopColor:u,stopOpacity:"1"}),i.jsx("stop",{offset:"65%",stopColor:u,stopOpacity:"0"}),i.jsx("stop",{offset:"100%",stopColor:u,stopOpacity:"0"})]}),i.jsx("mask",{id:l,maskUnits:"userSpaceOnUse",maskContentUnits:"userSpaceOnUse",x:"0",y:"0",width:"100",height:"100",children:i.jsxs("g",{fill:"none",children:[i.jsx("path",{d:"M50 3 91 27 50 51 9 27Z",fill:"white",opacity:"0.3"}),i.jsx("path",{d:"M9 27 50 51V97L9 73Z",fill:"white",opacity:"0.55"}),i.jsx("path",{d:"M50 51 91 27V73L50 97Z",fill:"white",opacity:"0.85"}),i.jsx("path",{d:"M50 3 91 27V73L50 97 9 73V27Z",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M28 31H72 M38 31V68 M62 31V55C62 64 67 68 75 68",stroke:"white",strokeWidth:"6",strokeLinecap:"round",strokeLinejoin:"round"})]})})]}),i.jsx("style",{children:"@keyframes pc-shimmer-anim{0%{transform:translate(-110px,-110px)}100%{transform:translate(110px,110px)}}.pc-shimmer-sweep{animation:pc-shimmer-anim 1.8s cubic-bezier(0.4,0,0.2,1) infinite}@media (prefers-reduced-motion:reduce){.pc-shimmer-sweep{animation:none}}"})]}):null,i.jsx("path",{d:"M50 3 91 27 50 51 9 27Z",fill:u,opacity:s?.04:.08}),i.jsx("path",{d:"M9 27 50 51V97L9 73Z",fill:u,opacity:s?.08:.14}),i.jsx("path",{d:"M50 51 91 27V73L50 97Z",fill:u,opacity:s?.13:.22}),i.jsx("path",{d:"M50 3 91 27V73L50 97 9 73V27Z",stroke:u,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",opacity:s?.6:1}),i.jsx("path",{d:"M28 31H72 M38 31V68 M62 31V55C62 64 67 68 75 68",stroke:u,strokeWidth:"6",strokeLinecap:"round",strokeLinejoin:"round",opacity:s?.75:1}),s?i.jsx("g",{mask:`url(#${l})`,children:i.jsx("rect",{x:"-50",y:"-50",width:"200",height:"200",fill:`url(#${c})`,className:"pc-shimmer-sweep"})}):null]})},bS=(e,t)=>e.apiBaseUrl===t.apiBaseUrl&&e.runtimeKey===t.runtimeKey,xS=e=>e.shouldUseDesktopShellPasswordLogin?"locked":"error",wS="/auth/passkey/authenticate/options",MS="/auth/passkey/authenticate/verify",CS="/auth/passkey/register/options",SS="/auth/passkey/register/verify",pf="/api/passkeys",_S="/auth/passkey/status",kS="/api/auth/reset",zr={enabled:!1,hasPasskeys:!1,passkeyCount:0,rpID:null},lo=async(e,t)=>V1(e,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:t===void 0?void 0:JSON.stringify(t)}),O0=async(e,t)=>{try{const n=await e.json();if(n&&typeof n.error=="string"&&n.error.trim())return n.error}catch{}return t},rl=e=>e instanceof cy&&e.code==="ERROR_CEREMONY_ABORTED",U6=()=>{ay.cancelCeremony()},gf=()=>typeof window>"u"?{supported:!1,reason:"Passkeys are unavailable outside the browser."}:window.isSecureContext?{supported:!0,reason:""}:{supported:!1,reason:"Passkeys require HTTPS or localhost."},AS=async()=>{const e=gf();if(!e.supported)throw new Error(e.reason);const t=typeof navigator.userAgent=="string"&&navigator.userAgent.trim()?navigator.userAgent:"This device",n=await lo(CS,{label:t});if(!n.ok)throw new Error(await O0(n,"Could not start passkey setup."));const{requestId:s,optionsJSON:o}=await n.json(),r=await ly({optionsJSON:o}),a=await lo(SS,{requestId:s,response:r});if(!a.ok)throw new Error(await O0(a,"Could not finish passkey setup."));return a.json().catch(()=>null)},HS=async(e,t={})=>{const n=gf();if(!n.supported)throw new Error(n.reason);const s=await lo(wS);if(!s.ok)throw new Error(await O0(s,"Passkey sign-in is not available right now."));const{requestId:o,optionsJSON:r}=await s.json(),a=await dy({optionsJSON:r}),l=await lo(MS,{requestId:o,response:a,trustDevice:e,issueClientToken:t.issueClientToken===!0,clientLabel:t.clientLabel,clientKind:t.clientKind,dedupeKey:t.dedupeKey});if(!l.ok)throw new Error(await O0(l,"Passkey sign-in failed."));return l.json().catch(()=>null)},LS=async()=>{const e=await V1(_S,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!e.ok)return zr;const t=await e.json().catch(()=>null);return{enabled:t?.enabled===!0,hasPasskeys:t?.hasPasskeys===!0,passkeyCount:typeof t?.passkeyCount=="number"?t.passkeyCount:0,rpID:typeof t?.rpID=="string"&&t.rpID?t.rpID:null}},uZ=async()=>{const e=await V1(pf,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!e.ok)throw new Error(await O0(e,"Could not load passkeys."));const t=await e.json().catch(()=>null);return Array.isArray(t?.passkeys)?t.passkeys:[]},fZ=async e=>{const t=await V1(`${pf}/${encodeURIComponent(e)}`,{method:"DELETE",credentials:"include",headers:{Accept:"application/json"}});if(!t.ok)throw new Error(await O0(t,"Could not remove passkey."));return t.json().catch(()=>null)},hZ=async()=>{const e=await lo(kS);if(!e.ok)throw new Error(await O0(e,"Could not clear saved authentication."));return e.json().catch(()=>null)},yf="/auth/session",jS=4,IS=1500,vf="pichamber.uiAuth.trustDevice",BS="desktop-local",TS="desktop-local",VS=()=>{if(typeof window>"u")return"";const e=window.__PICHAMBER_LOCAL_ORIGIN__;return typeof e=="string"?e.trim():""},v4=(e,t)=>{const n=L2(e),s=L2(t);if(!n||!s)return!1;try{return new URL(n).origin===new URL(s).origin}catch{return!1}},Dr=()=>S1(),NS=e=>{const t=e.replace(/^\[|\]$/g,"");return t==="localhost"||t==="127.0.0.1"||t==="::1"},bf=()=>{if(!S1())return!1;const e=VS();if(!e)return!1;const n=Ti()||(typeof window<"u"?window.location.origin:"");if(v4(e,n))return!0;try{const s=L2(n);return!!(s&&NS(new URL(s).hostname))}catch{return!1}},O3=()=>bf()?{clientKind:BS,dedupeKey:TS}:{},PS=async()=>await V1(yf,{method:"GET",credentials:"include",headers:{Accept:"application/json"}}),ES=()=>typeof window>"u"?!1:window.localStorage.getItem(vf)==="true",zS=async(e,t)=>{const n=Dr();return await V1(yf,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({password:e,trustDevice:t,issueClientToken:n,clientLabel:"PiChamber Desktop",...O3()})})},DS=async()=>{if(!S1())return"";const e=await V1("/api/client-auth/clients",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({label:"PiChamber Desktop",...O3()})}).catch(()=>null);if(!e?.ok)return"";const t=await e.json().catch(()=>null);return typeof t?.token=="string"?t.token.trim():""},il=()=>S1()&&!bf(),pn=()=>({apiBaseUrl:Ti(),runtimeKey:We()}),D1=e=>bS(e,pn()),al=async(e,t,n,s)=>{if(!S1()||typeof window>"u")return null;const o=await tt("desktop_remote_password_login",{url:n.apiBaseUrl,password:e,trustDevice:t,requestHeaders:s}).catch(()=>null);if(!o||typeof o!="object")return null;const r=o.token,a=o.status;return{token:typeof r=="string"?r.trim():"",...typeof a=="number"?{status:a}:{}}},RS=async(e,t)=>{if(!S1()||!t||!D1(e))return!1;const n=await h9().catch(()=>null);if(!n||!D1(e))return!1;if(n.localOrigin&&v4(n.localOrigin,e.apiBaseUrl))return await Fl({hosts:n.hosts,defaultHostId:n.defaultHostId,initialHostChoiceCompleted:n.initialHostChoiceCompleted,localClientToken:t}).catch(()=>{}),D1(e);let s=!1;const o=n.hosts.map(r=>!v4(T0(r),e.apiBaseUrl)||r.clientToken===t?r:(s=!0,{...r,clientToken:t}));return s?D1(e)?(await Fl({hosts:o,defaultHostId:n.defaultHostId,initialHostChoiceCompleted:n.initialHostChoiceCompleted}).catch(()=>{}),D1(e)):!1:!0},Jo=async(e,t,n)=>!e||!D1(t)||!await RS(t,e)||!D1(t)?!1:(Hs({apiBaseUrl:t.apiBaseUrl,clientToken:e,requestHeaders:Object.keys(n).length>0?n:null,runtimeKey:t.runtimeKey}),!0),xf=({children:e})=>{const t=d.useMemo(()=>({height:"var(--oc-wco-titlebar-height, 0px)",right:"var(--oc-wco-right-inset, 0px)"}),[]);return i.jsxs("div",{className:"relative flex min-h-screen items-center justify-center overflow-hidden bg-background text-foreground",style:{fontFamily:'"Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", sans-serif'},children:[i.jsx("div",{className:"app-region-drag fixed left-0 top-0 z-20",style:t,"aria-hidden":!0}),i.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-55",style:{background:"radial-gradient(120% 140% at 50% -20%, var(--surface-overlay) 0%, transparent 68%)"}}),i.jsx("div",{className:"pointer-events-none absolute inset-0",style:{backgroundColor:"var(--surface-subtle)",opacity:.22}}),i.jsx("div",{className:"app-region-no-drag relative z-10 flex w-full justify-center px-4 py-12 sm:px-6",children:e})]})},OS=()=>i.jsx("div",{className:"flex h-full min-h-screen w-full items-center justify-center overflow-hidden bg-background text-foreground",children:i.jsx(R3,{width:120,height:120,isAnimated:!0})}),G6=({onRetry:e,errorType:t="network",retryAfter:n,children:s})=>{const o=t==="rate-limit",r=n?Math.ceil(n/60):1;return i.jsx(xf,{children:i.jsxs("div",{className:"flex flex-col items-center gap-6 text-center",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx("h1",{className:"typography-ui-header font-semibold text-destructive",children:o?"Too many attempts":"Unable to reach server"}),i.jsx("p",{className:"typography-meta text-muted-foreground max-w-xs",children:o?r>1?`Please wait ${r} minutes before trying again.`:`Please wait ${r} minute before trying again.`:"We could not verify the UI session. If you're opening PiChamber from another device on your local network, make sure Desktop Network Access is enabled on the desktop app and use the LAN address shown in Settings."})]}),i.jsx(a1,{type:"button",onClick:e,className:"w-full max-w-xs",children:"Retry"}),s]})})},mZ=({children:e})=>{const n=d.useMemo(()=>S1(),[]),[s,o]=d.useState(()=>"pending"),[r,a]=d.useState(""),[l,c]=d.useState(!1),[u,f]=d.useState(""),[h,m]=d.useState(void 0),[p,g]=d.useState(!1),[y,M]=d.useState(zr),[b,v]=d.useState(!1),[x,S]=d.useState(!1),[C,w]=d.useState(()=>ES()),[_,L]=d.useState(null),A=d.useRef(null),N=d.useRef(!1);d.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(vf,C?"true":"false")},[C]);const k=d.useCallback(async(ie=pn())=>{try{const E=await LS();return D1(ie)&&M(E),E}catch{return D1(ie)&&M(zr),zr}},[!1]);d.useEffect(()=>{let ie=!1;return(async()=>{try{if(!window.isSecureContext||!uy()){ie||v(!1);return}ie||v(!0)}catch{ie||v(!1)}})(),()=>{ie=!0}},[!1]);const V=d.useRef(0),H=d.useRef(null),D=d.useRef(null),P=d.useCallback(()=>{H.current!==null&&(window.clearTimeout(H.current),H.current=null)},[]),R=d.useCallback(()=>{V.current=0,P()},[P]),$=d.useCallback(()=>V.current>=jS?!1:(V.current+=1,P(),H.current=window.setTimeout(()=>{H.current=null,D.current?.()},IS*V.current),!0),[P]);d.useEffect(()=>P,[P]);const O=d.useCallback(async()=>{const ie=pn();o(E=>E==="authenticated"?E:"pending");try{const[E,ce]=await Promise.all([PS(),k(ie)]),ee=await E.text();if(!D1(ie))return;if(E.ok){R(),o("authenticated"),g(!1),f(""),m(void 0);return}if(E.status===401){let ue={};try{ue=JSON.parse(ee)}catch{ue={}}R(),g(ue.tunnelLocked===!0),M(ce),o("locked"),m(void 0);return}if(E.status===429){let ue={};try{ue=JSON.parse(ee)}catch{ue={}}R(),m(ue.retryAfter),g(!1),o("rate-limited");return}if($())return;o("error"),g(!1)}catch(E){if(!D1(ie))return;if(console.warn("Failed to check session status:",E),xS({shouldUseDesktopShellPasswordLogin:il()})==="locked"){o("locked"),m(void 0),g(!1);return}if($())return;o("error"),g(!1)}},[k,R,$,!1]);d.useEffect(()=>{D.current=O},[O]),d.useEffect(()=>{O()},[O,!1]),d.useEffect(()=>Wn(()=>{U6(),a(""),f(""),m(void 0),g(!1),c(!1),L(null),S(!1),R(),o("pending"),O()}),[O,R,!1]),d.useEffect(()=>{s==="locked"&&(N.current=!1)},[!1,s]),d.useEffect(()=>{s==="locked"&&A.current&&(A.current.focus(),A.current.select())},[s]),d.useEffect(()=>{s==="authenticated"&&(N.current=!0)},[!1,s]);const I=async ie=>{ie.preventDefault(),await K(!1)},q=d.useCallback(async()=>{const ie=pn();L("register"),S(!0);try{await AS()}finally{D1(ie)&&(L(null),S(!1))}D1(ie)&&await k(ie)},[k]),G=d.useCallback(()=>{U6(),L(null),S(!1)},[]),K=d.useCallback(async ie=>{if(p||!r||l)return;x&&G();const E=pn(),ce=uc();c(!0),f("");try{if(il()){const ue=await al(r,C,E,ce);if(!D1(E))return;if(ue?.token){if(a(""),g(!1),!await Jo(ue.token,E,ce))return;o("authenticated");return}if(ue?.status===401){f("Incorrect password. Try again."),g(!1),o("locked");return}if(ue?.status===429){m(void 0),g(!1),o("rate-limited");return}}const ee=await zS(r,C);if(!D1(E))return;if(ee.ok){const ue=await ee.json().catch(()=>null);if(!D1(E))return;const J=Dr();let Y="";if(J&&(Y=typeof ue?.clientToken=="string"&&ue.clientToken.trim()?ue.clientToken.trim():"",!Y)){const oe=await al(r,C,E,ce);if(!D1(E)||(Y=oe?.token||await DS(),!D1(E)))return}if(a(""),g(!1),Y&&!await Jo(Y,E,ce))return;if(ie&&b)try{if(await q(),!D1(E))return;Ue.success("Passkey added"),o("authenticated");return}catch(oe){if(rl(oe))Ue.message("Passkey setup canceled");else{const te=oe instanceof Error?oe.message:"Passkey setup failed.";Ue.error(te)}o("authenticated");return}o("authenticated");return}if(ee.status===401){f("Incorrect password. Try again."),g(!1),o("locked");return}if(ee.status===429){const ue=await ee.json().catch(()=>({}));m(ue.retryAfter),g(!1),o("rate-limited");return}f("Unexpected response from server."),g(!1),o("error")}catch(ee){if(!D1(E))return;console.warn("Failed to submit UI password:",ee);const ue=il()?await al(r,C,E,ce):null;if(!D1(E))return;if(ue?.token){if(a(""),g(!1),!await Jo(ue.token,E,ce))return;o("authenticated");return}if(ue?.status===401){f("Incorrect password. Try again."),g(!1),o("locked");return}if(ue?.status===429){m(void 0),g(!1),o("rate-limited");return}f("Network error. Check connection and retry."),g(!1),o("error")}finally{D1(E)&&c(!1)}},[G,x,l,p,r,q,b,C]),W=d.useCallback(async()=>{if(l||!b)return;if(x){G();return}S(!0),L("auth"),f("");const ie=pn(),E=uc();try{const ce=await HS(C,{issueClientToken:Dr(),clientLabel:"PiChamber Desktop",...O3()}),ee=Dr()&&typeof ce?.clientToken=="string"&&ce.clientToken.trim()?ce.clientToken.trim():"";if(!D1(ie)||ee&&!await Jo(ee,ie,E))return;a(""),o("authenticated")}catch(ce){if(!D1(ie))return;if(rl(ce))f("");else{const ee=ce instanceof Error?ce.message:"Passkey sign-in was canceled.";f(ee)}}finally{D1(ie)&&(L(null),S(!1))}},[G,x,l,b,C]),ge=d.useCallback(async()=>{if(!(l||p||!b)){if(x){G();return}if(s!=="authenticated"){if(!r){f("Enter your password to add a passkey.");return}await K(!0);return}f("");try{await q(),Ue.success("Passkey added")}catch(ie){if(rl(ie)){Ue.message("Passkey setup canceled");return}const E=ie instanceof Error?ie.message:"Passkey setup failed.";Ue.error(E)}}},[G,K,x,l,p,r,q,s,b]),Z=b&&y.enabled,fe=Z&&y.hasPasskeys;return s==="pending"?i.jsx(OS,{}):s==="error"?i.jsx(G6,{onRetry:()=>{R(),O()},errorType:"network",children:n&&i.jsxs("div",{className:"w-full max-w-xs",children:[i.jsx(q6,{}),i.jsx("p",{className:"mt-1 text-center typography-micro text-muted-foreground",children:"Use Local if remote is unreachable."})]})}):s==="rate-limited"?i.jsx(G6,{onRetry:()=>{O()},errorType:"rate-limit",retryAfter:h}):s==="locked"?i.jsx(xf,{children:i.jsxs("div",{className:"flex flex-col items-center gap-6 w-full max-w-xs",children:[i.jsxs("div",{className:"flex flex-col items-center gap-1 text-center",children:[i.jsx("h1",{className:"text-xl font-semibold text-foreground",children:p?"Tunnel access required":"Unlock PiChamber"}),i.jsx("p",{className:"typography-meta text-muted-foreground",children:p?"Open this tunnel using the one-time connect link from the desktop app.":"This session is password-protected."})]}),!p&&i.jsxs("form",{onSubmit:I,className:"w-full space-y-2",children:[fe&&i.jsxs(a1,{type:"button",variant:"outline",className:"w-full",onClick:()=>{W()},disabled:l||x&&_!=="auth",children:[x?i.jsx(z,{name:"loader-4",className:"h-4 w-4 animate-spin"}):i.jsx(z,{name:"lock-unlock",className:"h-4 w-4"}),i.jsx("span",{children:x&&_==="auth"?"Cancel passkey":"Use passkey"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx(z,{name:"lock",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground/60"}),i.jsx(Bt,{id:"pichamber-ui-password",ref:A,type:"password",autoComplete:"current-password",placeholder:"Enter password",value:r,onChange:ie=>{a(ie.target.value),u&&f("")},className:"pl-10","aria-invalid":!!u||void 0,"aria-describedby":u?"oc-ui-auth-error":void 0,disabled:l})]}),i.jsx(a1,{type:"submit",size:"icon",disabled:!r||l,"aria-label":l?"Unlocking":"Unlock",children:l?i.jsx(z,{name:"loader-4",className:"h-4 w-4 animate-spin"}):i.jsx(z,{name:"lock-unlock",className:"h-4 w-4"})})]}),Z?i.jsxs("div",{className:"flex items-center justify-between pt-1",children:[i.jsxs("label",{className:"flex items-center gap-2 text-center typography-micro text-muted-foreground",children:[i.jsx(y4,{checked:C,onChange:w,disabled:l,ariaLabel:"Trust this device",className:"size-4",iconClassName:"size-4"}),i.jsx("span",{children:"Trust this device"})]}),i.jsx(a1,{type:"button",variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground",onClick:()=>{ge()},disabled:l,children:x&&_==="register"?"Cancel passkey setup":"Add passkey"})]}):i.jsxs("label",{className:"flex items-center justify-center gap-2 pt-1 text-center typography-micro text-muted-foreground",children:[i.jsx(y4,{checked:C,onChange:w,disabled:l,ariaLabel:"Trust this device",className:"size-4",iconClassName:"size-4"}),i.jsx("span",{children:"Trust this device"})]}),u&&i.jsx("p",{id:"oc-ui-auth-error",className:"typography-meta text-destructive",children:u})]}),n&&i.jsxs("div",{className:"w-full",children:[i.jsx(q6,{}),i.jsx("p",{className:"mt-1 text-center typography-micro text-muted-foreground",children:"Use Local if remote is unreachable."})]})]})}):i.jsx(i.Fragment,{children:e})},ZS=1e3,W6=.5,K6={length:0,offset:0},Y6=(e,t)=>Math.abs(e.length-t.length)<W6&&Math.abs(e.offset-t.offset)<W6,wf=({containerRef:e,minThumbSize:t=32,hideDelayMs:n=1e3,className:s,disableHorizontal:o=!1,observeMutations:r=!0,suppressVisibility:a=!1,userIntentOnly:l=!1})=>{const[c,u]=d.useState(!1),[f,h]=d.useState({length:0,offset:0}),[m,p]=d.useState({length:0,offset:0}),g=d.useRef(null),y=d.useRef(null),M=d.useRef(null),b=d.useRef(!1),v=d.useRef(!1),x=d.useRef(0),S=d.useRef({pointerX:0,pointerY:0,scrollTop:0,scrollLeft:0}),C=d.useRef(null),w=d.useRef(new Set),_=d.useCallback(()=>{const G=e.current;if(!G)return;const{scrollHeight:K,clientHeight:W,scrollTop:ge,scrollWidth:Z,clientWidth:fe,scrollLeft:ie}=G,E=8;let ce=K6;if(K>W){const ue=Math.max(W-E*2,0),J=W/K*ue,Y=Math.max(t,Math.min(ue,J)),oe=Math.max(ue-Y,0),te=Math.max(K-W,1),pe=ge/te*oe;ce={length:Y,offset:pe}}h(ue=>Y6(ue,ce)?ue:ce);let ee=K6;if(!o&&Z>fe){const ue=Math.max(fe-E*2,0),J=fe/Z*ue,Y=Math.max(t,Math.min(ue,J)),oe=Math.max(ue-Y,0),te=Math.max(Z-fe,1),pe=ie/te*oe;ee={length:Y,offset:pe}}p(ue=>Y6(ue,ee)?ue:ee)},[e,t,o]),L=d.useCallback(()=>{M.current===null&&(M.current=requestAnimationFrame(()=>{M.current=null,_()}))},[_]),A=d.useCallback((G,K)=>{if(!K){w.current.clear();return}const W=new Set;W.add(G),Array.from(G.children).forEach(ge=>{W.add(ge)}),w.current.forEach(ge=>{W.has(ge)||K.unobserve(ge)}),W.forEach(ge=>{w.current.has(ge)||K.observe(ge)}),w.current=W},[]),N=d.useCallback(()=>{g.current&&clearTimeout(g.current),!v.current&&(g.current=setTimeout(()=>u(!1),n))},[n]),k=d.useCallback(()=>{x.current=Date.now()},[]),V=d.useCallback(()=>{y.current&&cancelAnimationFrame(y.current),y.current=requestAnimationFrame(()=>{if(_(),a&&!b.current){u(!1);return}if(l&&!b.current&&!(Date.now()-x.current<=ZS)){u(!1);return}u(!0),N()})},[N,a,_,l]);d.useEffect(()=>{const G=e.current;if(!G)return;_(),u(!1);const K=()=>V(),W=E=>{(E.key==="ArrowUp"||E.key==="ArrowDown"||E.key==="PageUp"||E.key==="PageDown"||E.key==="Home"||E.key==="End"||E.key===" ")&&k()};G.addEventListener("scroll",K,{passive:!0}),l&&(G.addEventListener("wheel",k,{passive:!0}),G.addEventListener("touchstart",k,{passive:!0}),G.addEventListener("touchmove",k,{passive:!0}),G.addEventListener("keydown",W));const ge=typeof ResizeObserver<"u"?new ResizeObserver(()=>{L()}):null;A(G,ge);const Z=r&&typeof MutationObserver<"u"?new MutationObserver(()=>{A(G,ge),L()}):null;Z?.observe(G,{childList:!0});const fe=()=>L(),ie=()=>L();return G.addEventListener("input",fe,!0),G.addEventListener("load",ie,!0),()=>{G.removeEventListener("scroll",K),G.removeEventListener("input",fe,!0),G.removeEventListener("load",ie,!0),l&&(G.removeEventListener("wheel",k),G.removeEventListener("touchstart",k),G.removeEventListener("touchmove",k),G.removeEventListener("keydown",W)),ge?.disconnect(),Z?.disconnect(),w.current.clear(),g.current&&clearTimeout(g.current),y.current&&cancelAnimationFrame(y.current),M.current&&cancelAnimationFrame(M.current)}},[e,V,k,r,L,A,_,l]),d.useEffect(()=>{a&&(b.current||(u(!1),g.current&&(clearTimeout(g.current),g.current=null)))},[a]);const H=(G,K)=>{const W=e.current;W&&(b.current=!0,S.current={pointerX:G.clientX,pointerY:G.clientY,scrollTop:W.scrollTop,scrollLeft:W.scrollLeft},C.current=K,k(),u(!0),g.current&&clearTimeout(g.current),G.currentTarget.setPointerCapture(G.pointerId))},D=G=>{if(!b.current)return;const K=e.current;if(!K)return;const W=C.current;if(W==="vertical"){const{pointerY:ge,scrollTop:Z}=S.current,fe=G.clientY-ge,ie=K.clientHeight,E=Math.max(ie-f.length,1),ce=Math.max(K.scrollHeight-K.clientHeight,1),ee=fe/E*ce;K.scrollTop=Z+ee}else if(W==="horizontal"){const{pointerX:ge,scrollLeft:Z}=S.current,fe=G.clientX-ge,ie=K.clientWidth,E=Math.max(ie-m.length,1),ce=Math.max(K.scrollWidth-K.clientWidth,1),ee=fe/E*ce;K.scrollLeft=Z+ee}},P=G=>{b.current&&(b.current=!1,G.currentTarget.releasePointerCapture(G.pointerId),N())},R=d.useCallback(()=>{v.current=!0,g.current&&(clearTimeout(g.current),g.current=null)},[]),$=d.useCallback(()=>{v.current=!1,N()},[N]),O=f.length>0,I=m.length>0;if(!O&&!I)return null;const q=8;return i.jsxs("div",{className:B("overlay-scrollbar",s),"aria-hidden":"true",style:{opacity:c?1:0},children:[O&&i.jsx("div",{className:"overlay-scrollbar__thumb overlay-scrollbar__thumb--vertical","data-overlay-scrollbar-thumb":"vertical",style:{height:`${f.length}px`,top:`${q+f.offset}px`,right:`${q/2}px`},onPointerDown:G=>H(G,"vertical"),onPointerMove:D,onPointerUp:P,onPointerCancel:P,onMouseEnter:R,onMouseLeave:$}),I&&i.jsx("div",{className:"overlay-scrollbar__thumb overlay-scrollbar__thumb--horizontal","data-overlay-scrollbar-thumb":"horizontal",style:{width:`${m.length}px`,left:`${q+m.offset}px`,bottom:`${q/2}px`},onPointerDown:G=>H(G,"horizontal"),onPointerMove:D,onPointerUp:P,onPointerCancel:P,onMouseEnter:R,onMouseLeave:$})]})};wf.displayName="OverlayScrollbar";const Mf=wf;function FS(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n&&typeof n=="object"&&(n.current=t)})}}const Yi=d.forwardRef(({as:e="div",orientation:t="vertical",offset:n=0,size:s=48,isEnabled:o=!0,hideTopShadow:r=!1,hideBottomShadow:a=!1,observeMutations:l=!0,onVisibilityChange:c,style:u,className:f,children:h,...m},p)=>{const g=d.useRef(null),y=d.useRef("none"),M=m["data-scroll-shadow"];delete m["data-scroll-shadow"];const b=d.useMemo(()=>{const C={...u};return C["--scroll-shadow-size"]=`${s}px`,C},[s,u]),v=d.useCallback((C,w,_,L,A)=>{const N=`${L}${A.charAt(0).toUpperCase()}${A.slice(1)}Scroll`;w&&_?(C.dataset[N]="true",C.removeAttribute(`data-${L}-scroll`),C.removeAttribute(`data-${A}-scroll`)):(C.dataset[`${L}Scroll`]=String(w),C.dataset[`${A}Scroll`]=String(_),C.removeAttribute(`data-${L}-${A}-scroll`))},[]),x=d.useCallback(C=>{["top","bottom","top-bottom","left","right","left-right"].forEach(w=>{C.removeAttribute(`data-${w}-scroll`)})},[]),S=d.useCallback(()=>{const C=g.current;if(!C)return;if(!o){x(C);return}const w=1,_=t==="vertical"?C.scrollTop>n+w:C.scrollLeft>n+w;let L=t==="vertical"?C.scrollHeight-(C.scrollTop+C.clientHeight)>n+w:C.scrollWidth-(C.scrollLeft+C.clientWidth)>n+w;const A=r&&t==="vertical"?!1:_;a&&t==="vertical"&&(L=!1),v(C,A,L,t==="vertical"?"top":"left",t==="vertical"?"bottom":"right");const N=A&&L?"both":A?t==="vertical"?"top":"left":L?t==="vertical"?"bottom":"right":"none";N!==y.current&&(y.current=N,c?.(N))},[x,r,a,o,n,c,t,v]);return d.useEffect(()=>{const C=g.current;if(!C)return;let w=null;const _=()=>{w===null&&(w=requestAnimationFrame(()=>{w=null,S()}))},L=()=>S(),A=typeof ResizeObserver<"u"?new ResizeObserver(_):null,N=l&&typeof MutationObserver<"u"?new MutationObserver(_):null;return S(),C.addEventListener("scroll",L,{passive:!0}),A?.observe(C),N?.observe(C,{childList:!0,subtree:!0,characterData:!0}),()=>{w!==null&&cancelAnimationFrame(w),C.removeEventListener("scroll",L),A?.disconnect(),N?.disconnect()}},[S,l]),i.jsx(e,{...m,ref:FS(g,p),className:f,"data-orientation":t,"data-scroll-shadow":M??!0,style:b,children:h})});Yi.displayName="ScrollShadow";const vt=d.forwardRef(({className:e,outerClassName:t,children:n,style:s,minThumbSize:o,hideDelayMs:r,as:a="div",scrollbarClassName:l,disableHorizontal:c=!1,observeMutations:u=!0,fillContainer:f=!0,preventOverscroll:h=!1,useScrollShadow:m=!1,scrollShadowSize:p,hideTopScrollShadow:g=!1,userIntentOnly:y=!1,...M},b)=>{const v=d.useRef(null);return d.useImperativeHandle(b,()=>v.current,[]),i.jsxs("div",{className:B("relative flex flex-col min-h-0 w-full overflow-hidden",h&&"overscroll-none",t),children:[m?i.jsx(Yi,{as:a,ref:v,size:p,hideTopShadow:g,className:B("overlay-scrollbar-target overlay-scrollbar-container",h&&"overscroll-none",f?"flex-1 min-h-0 w-full":"flex-none w-full h-auto",c?"overflow-y-auto overflow-x-hidden":"overflow-auto",e),style:s,observeMutations:u,...M,children:n}):i.jsx(a,{ref:v,className:B("overlay-scrollbar-target overlay-scrollbar-container",h&&"overscroll-none",f?"flex-1 min-h-0 w-full":"flex-none w-full h-auto",c?"overflow-y-auto overflow-x-hidden":"overflow-auto",e),style:s,...M,children:n}),i.jsx(Mf,{containerRef:v,minThumbSize:o,hideDelayMs:r,className:l,disableHorizontal:c,observeMutations:u,userIntentOnly:y})]})});vt.displayName="ScrollableOverlay";const J6="pichamber:chunk-import-reload",$S=250,qS=3e4,US=[/Importing a module script failed/i,/Failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/Loading chunk \S+ failed/i,/ChunkLoadError/i];function Cf(e){if(e instanceof Error)return`${e.name}
369
369
  ${e.message}
370
- ${e.stack??""}`;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function X6(e){const t=Cf(e);return US.some(n=>n.test(t))}function GS(e){return`0.3.2:${Cf(e).slice(0,500)}`}function WS(e){if(typeof window>"u")return;const t=Date.now(),n=GS(e);let s=null;try{const r=window.sessionStorage.getItem(J6);if(r)try{s=JSON.parse(r)}catch{s=null}}catch{return}const o=typeof s?.timestamp=="number"?s.timestamp:0;if(!(s?.signature===n&&t-o<qS)){try{window.sessionStorage.setItem(J6,JSON.stringify({signature:n,timestamp:t}))}catch{return}window.setTimeout(()=>{window.location.reload()},0)}}async function KS(e,t={}){const n=t.retries??1;let s;for(let o=0;o<=n;o+=1)try{return await e()}catch(r){if(s=r,!X6(r)||o>=n)break;await new Promise(a=>setTimeout(a,$S*(o+1)))}throw X6(s)&&WS(s),s}const bo=e=>ae.lazy(()=>KS(e)),YS=bo(()=>z3().then(e=>({default:e.MarkdownRenderer}))),JS=bo(()=>z3().then(e=>({default:e.SimpleMarkdownRenderer}))),XS=i.jsx("div",{className:"break-words w-full min-w-0"}),QS=e=>e==="tool"?"markdown-content markdown-tool":e==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",Sf=e=>!D2()||typeof e.content!="string"||e.content.length===0?XS:i.jsx("div",{className:B("break-words w-full min-w-0 whitespace-pre-wrap",QS(e.variant),typeof e.className=="string"?e.className:void 0),children:e.content}),_f=e=>i.jsx(d.Suspense,{fallback:i.jsx(Sf,{...e}),children:i.jsx(YS,{...e})}),xo=e=>i.jsx(d.Suspense,{fallback:i.jsx(Sf,{...e}),children:i.jsx(JS,{...e})}),Ji=e=>{try{return new URL(e)}catch{return null}},pZ=e=>{const t=Ji(e.trim());return t?t.protocol==="http:"||t.protocol==="https:":!1},e_=e=>{const t=Ji(e.trim());return!t||t.protocol!=="http:"&&t.protocol!=="https:"?null:`https://icons.duckduckgo.com/ip3/${t.hostname.toLowerCase()}.ico`},t_=new Set(["localhost","127.0.0.1","0.0.0.0","::1"]),n_=e=>{const t=Ji(e.trim());return!t||t.protocol!=="http:"&&t.protocol!=="https:"?!1:t_.has(t.hostname.toLowerCase())},s_=/\bhttps?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[::1\])(?::\d{2,5})?(?:\/[^\s<>"'`\u0000-\u001f]*)?/gi,Q6=e=>{if(!e)return[];const t=e.match(s_);if(!t||t.length===0)return[];const n=new Set,s=[];for(const o of t){const r=o.replace(/[),.;:!?'"`]+$/g,"");!r||!n_(r)||n.has(r)||(n.add(r),s.push(r))}return s},e8=async e=>{if(typeof window>"u")return!1;const t=e.trim();if(!t)return!1;const n=Ji(t);if(!n||n.protocol!=="http:"&&n.protocol!=="https:")return!1;const s=n.toString(),o=window.__PICHAMBER_DESKTOP__;if(o?.openExternal)try{return await o.openExternal(s),!0}catch{}try{return window.open(s,"_blank","noopener,noreferrer"),!0}catch{return!1}},kf=e=>({id:"",...e}),gZ=[],o_=(...e)=>e.filter(Boolean).join(":"),Rt=W1()(()=>({drafts:{},addDraft:()=>{},updateDraft:()=>{},removeDraft:()=>{},getDrafts:()=>[],consumeDrafts:()=>[],restoreDrafts:()=>{},clearSessionDrafts:()=>{}})),r_=5e3,C0=new Map,Js=new Map,i_=e=>{const t=We();C0.delete(t),Js.delete(t),(!t||t==="local")&&(C0.clear(),Js.clear())};let hs=0,ll=null;const Xo=e=>e.prompts.map(t=>({name:t.name,content:t.content??"",aliases:[],...t.description?{description:t.description}:{},filePath:t.id,source:t.location==="project"?"project":"global",editable:t.editable===!0})),L0=W1()($0((e,t)=>({snippets:[],isLoading:!1,selectedSnippetName:null,snippetDraft:null,setSelectedSnippet:n=>e({selectedSnippetName:n}),setSnippetDraft:n=>e({snippetDraft:n}),loadSnippets:async()=>{const n=We(),s=Date.now(),o=C0.get(n)??hs;if(o>0&&s-o<r_)return!0;const r=Js.get(n)??ll;if(r)return r;const a=(async()=>{e({isLoading:!0});try{const l=await i1.listResources({runtimeKey:n}),c=Xo(l);return e(u=>({snippets:c,isLoading:!1,...u.selectedSnippetName&&!c.some(f=>f.name===u.selectedSnippetName)?{selectedSnippetName:null}:{}})),hs=Date.now(),C0.set(n,Date.now()),!0}catch{return e({isLoading:!1}),!1}})();ll=a,Js.set(n,a);try{return await a}finally{ll=null,Js.delete(n)}},createSnippet:async(n,s,o={})=>{const r=We();try{const a=await i1.createPromptTemplate({name:n,content:s,description:o.description??"",location:o.scope??"global"},{runtimeKey:r});return e({snippets:Xo(a),snippetDraft:null,selectedSnippetName:n}),hs=Date.now(),C0.set(r,Date.now()),!0}catch{return!1}},updateSnippet:async(n,s)=>{const o=We(),r=t().snippets.find(a=>a.name===n);if(!r||s.content===void 0)return!1;try{const a=await i1.updateResource({resourceId:r.filePath,content:s.content},{runtimeKey:o});return e({snippets:Xo(a)}),hs=Date.now(),C0.set(o,Date.now()),!0}catch{return!1}},deleteSnippet:async n=>{const s=We(),o=t().snippets.find(r=>r.name===n);if(!o)return!1;try{const r=await i1.deletePromptTemplate(o.filePath,{runtimeKey:s});return e({snippets:Xo(r),...t().selectedSnippetName===n?{selectedSnippetName:null}:{}}),hs=Date.now(),C0.set(s,Date.now()),!0}catch{return!1}},expandText:async n=>{if(!n||!n.includes("#"))return n;const s=new Map;for(const o of t().snippets){const r=o.name.toLowerCase();s.has(r)||s.set(r,o.content);for(const a of o.aliases??[]){const l=a.toLowerCase();s.has(l)||s.set(l,o.content)}}return s.size===0?n:n.replace(/(^|\s)#([A-Za-z0-9][A-Za-z0-9_-]*)/g,(o,r,a)=>{const l=s.get(a.toLowerCase());return l!==void 0?`${r}${l}`:o})},getSnippetByName:n=>t().snippets.find(s=>s.name===n)}),{name:"snippets-store"})),yZ=Object.freeze(Object.defineProperty({__proto__:null,invalidateSnippetsLoadCache:i_,useSnippetsStore:L0},Symbol.toStringTag,{value:"Module"})),a_=/\n*<terminal_context>\n([\s\S]*?)\n<\/terminal_context>\s*$/,l_=e=>{const t=e.terminalId.trim(),n=e.terminalLabel.trim(),s=e.text.replace(/\r\n?/g,`
370
+ ${e.stack??""}`;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function X6(e){const t=Cf(e);return US.some(n=>n.test(t))}function GS(e){return`0.3.3:${Cf(e).slice(0,500)}`}function WS(e){if(typeof window>"u")return;const t=Date.now(),n=GS(e);let s=null;try{const r=window.sessionStorage.getItem(J6);if(r)try{s=JSON.parse(r)}catch{s=null}}catch{return}const o=typeof s?.timestamp=="number"?s.timestamp:0;if(!(s?.signature===n&&t-o<qS)){try{window.sessionStorage.setItem(J6,JSON.stringify({signature:n,timestamp:t}))}catch{return}window.setTimeout(()=>{window.location.reload()},0)}}async function KS(e,t={}){const n=t.retries??1;let s;for(let o=0;o<=n;o+=1)try{return await e()}catch(r){if(s=r,!X6(r)||o>=n)break;await new Promise(a=>setTimeout(a,$S*(o+1)))}throw X6(s)&&WS(s),s}const bo=e=>ae.lazy(()=>KS(e)),YS=bo(()=>z3().then(e=>({default:e.MarkdownRenderer}))),JS=bo(()=>z3().then(e=>({default:e.SimpleMarkdownRenderer}))),XS=i.jsx("div",{className:"break-words w-full min-w-0"}),QS=e=>e==="tool"?"markdown-content markdown-tool":e==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",Sf=e=>!D2()||typeof e.content!="string"||e.content.length===0?XS:i.jsx("div",{className:B("break-words w-full min-w-0 whitespace-pre-wrap",QS(e.variant),typeof e.className=="string"?e.className:void 0),children:e.content}),_f=e=>i.jsx(d.Suspense,{fallback:i.jsx(Sf,{...e}),children:i.jsx(YS,{...e})}),xo=e=>i.jsx(d.Suspense,{fallback:i.jsx(Sf,{...e}),children:i.jsx(JS,{...e})}),Ji=e=>{try{return new URL(e)}catch{return null}},pZ=e=>{const t=Ji(e.trim());return t?t.protocol==="http:"||t.protocol==="https:":!1},e_=e=>{const t=Ji(e.trim());return!t||t.protocol!=="http:"&&t.protocol!=="https:"?null:`https://icons.duckduckgo.com/ip3/${t.hostname.toLowerCase()}.ico`},t_=new Set(["localhost","127.0.0.1","0.0.0.0","::1"]),n_=e=>{const t=Ji(e.trim());return!t||t.protocol!=="http:"&&t.protocol!=="https:"?!1:t_.has(t.hostname.toLowerCase())},s_=/\bhttps?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[::1\])(?::\d{2,5})?(?:\/[^\s<>"'`\u0000-\u001f]*)?/gi,Q6=e=>{if(!e)return[];const t=e.match(s_);if(!t||t.length===0)return[];const n=new Set,s=[];for(const o of t){const r=o.replace(/[),.;:!?'"`]+$/g,"");!r||!n_(r)||n.has(r)||(n.add(r),s.push(r))}return s},e8=async e=>{if(typeof window>"u")return!1;const t=e.trim();if(!t)return!1;const n=Ji(t);if(!n||n.protocol!=="http:"&&n.protocol!=="https:")return!1;const s=n.toString(),o=window.__PICHAMBER_DESKTOP__;if(o?.openExternal)try{return await o.openExternal(s),!0}catch{}try{return window.open(s,"_blank","noopener,noreferrer"),!0}catch{return!1}},kf=e=>({id:"",...e}),gZ=[],o_=(...e)=>e.filter(Boolean).join(":"),Rt=W1()(()=>({drafts:{},addDraft:()=>{},updateDraft:()=>{},removeDraft:()=>{},getDrafts:()=>[],consumeDrafts:()=>[],restoreDrafts:()=>{},clearSessionDrafts:()=>{}})),r_=5e3,C0=new Map,Js=new Map,i_=e=>{const t=We();C0.delete(t),Js.delete(t),(!t||t==="local")&&(C0.clear(),Js.clear())};let hs=0,ll=null;const Xo=e=>e.prompts.map(t=>({name:t.name,content:t.content??"",aliases:[],...t.description?{description:t.description}:{},filePath:t.id,source:t.location==="project"?"project":"global",editable:t.editable===!0})),L0=W1()($0((e,t)=>({snippets:[],isLoading:!1,selectedSnippetName:null,snippetDraft:null,setSelectedSnippet:n=>e({selectedSnippetName:n}),setSnippetDraft:n=>e({snippetDraft:n}),loadSnippets:async()=>{const n=We(),s=Date.now(),o=C0.get(n)??hs;if(o>0&&s-o<r_)return!0;const r=Js.get(n)??ll;if(r)return r;const a=(async()=>{e({isLoading:!0});try{const l=await i1.listResources({runtimeKey:n}),c=Xo(l);return e(u=>({snippets:c,isLoading:!1,...u.selectedSnippetName&&!c.some(f=>f.name===u.selectedSnippetName)?{selectedSnippetName:null}:{}})),hs=Date.now(),C0.set(n,Date.now()),!0}catch{return e({isLoading:!1}),!1}})();ll=a,Js.set(n,a);try{return await a}finally{ll=null,Js.delete(n)}},createSnippet:async(n,s,o={})=>{const r=We();try{const a=await i1.createPromptTemplate({name:n,content:s,description:o.description??"",location:o.scope??"global"},{runtimeKey:r});return e({snippets:Xo(a),snippetDraft:null,selectedSnippetName:n}),hs=Date.now(),C0.set(r,Date.now()),!0}catch{return!1}},updateSnippet:async(n,s)=>{const o=We(),r=t().snippets.find(a=>a.name===n);if(!r||s.content===void 0)return!1;try{const a=await i1.updateResource({resourceId:r.filePath,content:s.content},{runtimeKey:o});return e({snippets:Xo(a)}),hs=Date.now(),C0.set(o,Date.now()),!0}catch{return!1}},deleteSnippet:async n=>{const s=We(),o=t().snippets.find(r=>r.name===n);if(!o)return!1;try{const r=await i1.deletePromptTemplate(o.filePath,{runtimeKey:s});return e({snippets:Xo(r),...t().selectedSnippetName===n?{selectedSnippetName:null}:{}}),hs=Date.now(),C0.set(s,Date.now()),!0}catch{return!1}},expandText:async n=>{if(!n||!n.includes("#"))return n;const s=new Map;for(const o of t().snippets){const r=o.name.toLowerCase();s.has(r)||s.set(r,o.content);for(const a of o.aliases??[]){const l=a.toLowerCase();s.has(l)||s.set(l,o.content)}}return s.size===0?n:n.replace(/(^|\s)#([A-Za-z0-9][A-Za-z0-9_-]*)/g,(o,r,a)=>{const l=s.get(a.toLowerCase());return l!==void 0?`${r}${l}`:o})},getSnippetByName:n=>t().snippets.find(s=>s.name===n)}),{name:"snippets-store"})),yZ=Object.freeze(Object.defineProperty({__proto__:null,invalidateSnippetsLoadCache:i_,useSnippetsStore:L0},Symbol.toStringTag,{value:"Module"})),a_=/\n*<terminal_context>\n([\s\S]*?)\n<\/terminal_context>\s*$/,l_=e=>{const t=e.terminalId.trim(),n=e.terminalLabel.trim(),s=e.text.replace(/\r\n?/g,`
371
371
  `).replace(/^\n+|\n+$/g,"");if(!t||!n||!s)return null;const o=Math.max(1,Math.floor(e.startLine));return{terminalId:t,terminalLabel:n,startLine:o,endLine:Math.max(o,Math.floor(e.endLine)),text:s}},c_=(e,t)=>{const n=t.map(l_).filter(r=>r!==null);if(n.length===0)return e;const o=["<terminal_context>",...n.flatMap((r,a)=>[`- ${r.terminalLabel} lines ${r.startLine}-${r.endLine}:`,...r.text.split(`
372
372
  `).map((l,c)=>` ${r.startLine+c} | ${l}`),...a===n.length-1?[]:[""]]),"</terminal_context>"].join(`
373
373
  `);return e.trim()?`${e.trim()}
@@ -6948,7 +6948,7 @@ ${$8}`:""},n0="__unassigned__",vh={mod:"mod",shift:"shift",alt:"alt",option:"alt
6948
6948
  `)?`${t}
6949
6949
  `:`${t}
6950
6950
 
6951
- `;return`${e}${n}${s}`}function o7(e,t){const n=t.trim();if(!n)return e;if(!e)return`${n} `;const s=/[\s\n]$/.test(e)?"":" ";return`${e}${s}${n} `}function uj(e,t,n){if(!e)return e;const s=t.length>0&&!/\s$/.test(t)&&!/^\s/.test(e)&&!/[([{]$/.test(t),o=n.length>0&&!/\s$/.test(e)&&!/^\s/.test(n)&&!/^[\])}.,;:!?]/.test(n);return`${s?" ":""}${e}${o?" ":""}`}function fj(e,t){return e?`${e}${/\s$/.test(e)?"":" "}${t}`:t}const hj=/^(https?:\/\/|mailto:)\S+$/i;function mj(e,t){return hj.test(e)&&!/\s/.test(e)&&t.trim().length>0&&!t.includes("](")}const Vh="file://";function pj(e){let t=e.replace(/\\/g,"/");return/^[A-Za-z]:/.test(t)&&(t=`/${t}`),t.split("/").map((n,s)=>s===1&&/^[A-Za-z]:$/.test(n)?n:encodeURIComponent(n)).join("/")}function gj(e){const t=e.replace(/\\/g,"/").trim();return t.toLowerCase().startsWith(Vh)?t:`file://${pj(t)}`}function yj(e){return e.startsWith("/")||e.startsWith("\\\\")||/^[A-Za-z]:[\\/]/.test(e)}function r7(e){const t=e.trim().replace(/^['"]+|['"]+$/g,"");return!t||/[\r\n]/.test(t)?null:t.toLowerCase().startsWith(Vh)||yj(t)?t:null}function V4(e,t,n=0){if(!(n>6||e==null)){if(typeof e=="string"){t.add(e);return}if(Array.isArray(e)){for(const s of e)V4(s,t,n+1);return}if(typeof e=="object")for(const s of Object.values(e))V4(s,t,n+1)}}function vj(e){const t=new Set,n=s=>{const o=r7(s);if(o){t.add(o);return}for(const r of s.split(/\r?\n/)){const a=r7(r);a&&t.add(a)}};n(e);try{const s=JSON.parse(e),o=new Set;V4(s,o);for(const r of o)n(r)}catch{}return Array.from(t)}function qt(e){if(typeof e!="string")return null;const t=e.trim();if(!t)return null;const n=t.replace(/\\/g,"/");return n==="/"?"/":n.length>1?n.replace(/\/+$/,""):n}function bj(e,t){const n=e.replace(/\\/g,"/").trim(),s=(t||"").replace(/\\/g,"/").replace(/\/+$/,"");if(!s||n===s)return n;const o=`${s}/`;return n.startsWith(o)?n.slice(o.length):n}const xj=["CodeFiles","codefiles","application/vnd.code.tree","application/vnd.code.tree.explorer","text/uri-list","text/plain"],wj="application/x-pichamber-file-path",Mj=["files","text/uri-list","codefiles",wj];function Cj(e,t){try{return e.getData(t)}catch{return""}}function ur(e){if(!e)return!1;if(e.files&&e.files.length>0)return!0;if(e.types){const t=Array.from(e.types).map(n=>n.toLowerCase());if(Mj.some(n=>t.includes(n))||t.some(n=>n.includes("vnd.code.tree")))return!0}for(const t of xj){const n=Cj(e,t);if(n&&vj(n).length>0)return!0}return!1}function Sj(e){if(!e)return[];const t=Array.from(e.files||[]);return t.length>0?t:Array.from(e.items||[]).filter(n=>n.kind==="file").map(n=>n.getAsFile()).filter(n=>!!n)}function _j(e,t){let n="",s=[],o;const r=[],a=[],l=h=>{for(const m of t.collectSkillNames(h))a.includes(m)||a.push(m)},c=h=>{!o&&h&&(o=h)},u=h=>{const m=t.parseAgentMention(h);c(m.agentName);const p=t.extractFileMentions(m.text);return l(p.text),p};if(e.queued.forEach((h,m)=>{const p=u(h.content),g=[...t.sanitizeAttachments(h.attachments),...p.attachments];if(m===0){n=p.text,s=g;return}r.push({text:p.text,attachments:g})}),e.composerText!==null){const h=u(e.composerText.replace(/^\n+|\n+$/g,"")),m=[...t.sanitizeAttachments(e.composerAttachments),...h.attachments];e.queued.length===0?(n=h.text,s=m):r.push({text:h.text,attachments:m})}if(e.inlineComments.length>0){const h=e.queued.length>0&&r.length>0?r[r.length-1]:null;h?h.text=t.appendComments(h.text,e.inlineComments):n=t.appendComments(n,e.inlineComments)}for(const h of e.syntheticTexts)r.push({text:h,synthetic:!0});e.linkedIssueContext&&r.push({text:e.linkedIssueContext,synthetic:!0}),e.linkedPr&&(r.push({text:e.linkedPr.instructions,synthetic:!0}),r.push({text:e.linkedPr.context,synthetic:!0}));const f=t.buildSkillInstruction(a);return f&&r.push({text:f,synthetic:!0}),{primaryText:n,primaryAttachments:s,additionalParts:r,agentMentionName:o,isEmpty:!n&&s.length===0&&r.length===0}}const kj=e=>({visible:{topic_line:e?` focused on: ${e}`:""},instructions:{topic_block:e?`The user asked you to focus this summary on: ${e}. Prioritize that topic; mention unrelated threads only in passing.`:""}}),Aj=[{name:"summary",visiblePrompt:"session.summary.visible",instructionsPrompt:"session.summary.instructions",errorToastKey:"Failed to generate summary",requires:"session",buildVariables:kj},{name:"plan-feature",visiblePrompt:"session.plan.visible",instructionsPrompt:"session.plan.instructions",errorToastKey:"Failed to start feature planning",requires:"session-or-draft"},{name:"catch-up",visiblePrompt:"session.catchup.visible",instructionsPrompt:"session.catchup.instructions",errorToastKey:"Failed to catch up",requires:"session-or-draft"},{name:"debug",visiblePrompt:"session.debug.visible",instructionsPrompt:"session.debug.instructions",errorToastKey:"Failed to start debugging",requires:"session-or-draft"},{name:"weigh",visiblePrompt:"session.weigh.visible",instructionsPrompt:"session.weigh.instructions",errorToastKey:"Failed to weigh options",requires:"session-or-draft"},{name:"explore",visiblePrompt:"session.explore.visible",instructionsPrompt:"session.explore.instructions",errorToastKey:"Failed to start the tour",requires:"session-or-draft"}],Hj=new Map(Aj.map(e=>[e.name,e]));function Lj(e){const t=e.trimStart();if(!t.startsWith("/"))return null;const n=t.slice(1),s=n.trim().split(/\s+/)[0]?.toLowerCase()??"";return s?{name:s,argument:n.slice(s.length).trim()}:null}function jj(e){return Hj.get(e)??null}function Ij(e,t){return e.requires==="session"?t.hasSession:t.hasSession||t.hasDraft}function Bj(e,t){const n=e.buildVariables?.(t)??{};return{visible:n.visible??{},instructions:n.instructions??{}}}function Tj(e){const{enabled:t,openAutocomplete:n,message:s,editorRef:o,containerRef:r}=e,[a,l]=d.useState(null),c=d.useCallback(()=>{if(!t){l(null);return}if(n===null){l(null);return}const u=o.current,f=r.current;if(!u||!f)return;const h=u.caretCoords();if(!h)return;const m=f.getBoundingClientRect(),p=h.top-m.top,g=h.left-m.left,y=8,M=260,b=p-y,v=m.height-p-y,x=v>=M||v>=b?"below":"above",S=n==="mention"?520:n==="skill"?360:450,C=Math.max(y,Math.min(g-24,m.width-S-y)),w=Math.max(120,Math.min(M,x==="below"?v:b));l({top:x==="below"?p+22:p-6,left:C,place:x,maxHeight:w})},[r,o,t,n]);return d.useLayoutEffect(()=>{c()},[c,s,n,t]),d.useEffect(()=>{if(!t)return;const u=()=>c();return window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u)}},[t,c]),{position:a,update:c}}const da=-1,N4={index:da,stashedDraft:""},P4=e=>({state:e,text:null});function Vj(e,t,n){if(t.length===0)return P4(e);if(e.index===da)return{state:{index:0,stashedDraft:n},text:t[0]};if(e.index>=t.length-1)return P4(e);const s=e.index+1;return{state:{...e,index:s},text:t[s]}}function Nj(e,t){if(e.index===da)return P4(e);if(e.index===0)return{state:N4,text:e.stashedDraft};const n=e.index-1;return{state:{...e,index:n},text:t[n]}}function Pj(e){const[t,n]=d.useState(N4),s=d.useCallback(a=>{const l=Vj(t,e,a);return l.text===null?null:(n(l.state),l.text)},[e,t]),o=d.useCallback(()=>{const a=Nj(t,e);return a.text===null?null:(n(a.state),a.text)},[e,t]),r=d.useCallback(()=>n(N4),[]);return{isBrowsing:t.index!==da,older:s,newer:o,reset:r}}const Ej=500;function i7(e,t){return`${e}\0${[...t].sort().join("\0")}`}function zj(e){const{message:t,messageRef:n,setMessage:s,confirmedMentionsRef:o,identity:r,persistEnabled:a,initialDraft:l,onIdentityChange:c,onDraftRestored:u}=e,f=d.useRef(null),h=d.useRef(!1),m=d.useRef(new Map),p=d.useRef(l.identity),g=d.useRef({onIdentityChange:c,onDraftRestored:u});g.current={onIdentityChange:c,onDraftRestored:u},d.useEffect(()=>{p.current=r},[r]);const y=d.useCallback((x,S)=>{if(!x)return;const C=S0(x),w=new Set;for(const L of o.current)S.includes(`@${L}`)&&w.add(L);o.current=w;const _=i7(S,w);m.current.get(C)!==_&&(pi(x,S,w),m.current.set(C,_))},[o]),M=d.useCallback(()=>{f.current&&(clearTimeout(f.current),f.current=null)},[]),b=d.useRef(!1);d.useEffect(()=>{if(!b.current&&(b.current=!0,!!l.text)){if(!a){s(""),pi(l.identity,"",[]);return}requestAnimationFrame(()=>g.current.onDraftRestored?.())}},[a]);const v=d.useRef(l.identity);return d.useEffect(()=>{const x=v.current,S=x?S0(x):null,C=r?S0(r):null;if(S===C)return;if(v.current=r,g.current.onIdentityChange?.(),M(),h.current=!0,!a){s(""),o.current=new Set;return}y(x,n.current);const w=Lf(r);s(w.text),o.current=w.confirmedMentions,w.text&&requestAnimationFrame(()=>g.current.onDraftRestored?.())},[M,o,r,n,a,y,s]),d.useEffect(()=>h_(x=>{const S=S0(x);m.current.set(S,i7("",[]));const C=p.current;!C||S0(C)!==S||(M(),h.current=!0,n.current="",o.current=new Set,s(""))}),[M,o,n,s]),d.useEffect(()=>{if(!a){M(),y(r,"");return}if(h.current){h.current=!1;return}M();const x=t,S=r;return f.current=setTimeout(()=>{f.current=null,y(S,x)},Ej),M},[M,r,t,a,y]),d.useEffect(()=>{const x=()=>{M(),a&&y(p.current,n.current)},S=()=>{document.visibilityState==="hidden"&&x()};return document.addEventListener("visibilitychange",S),document.addEventListener("freeze",x),window.addEventListener("pagehide",x),()=>{document.removeEventListener("visibilitychange",S),document.removeEventListener("freeze",x),window.removeEventListener("pagehide",x),x()}},[M,n,a,y]),{persistNow:y}}const Dj=3e4;function f5(e){return e.label?.trim()||fi(e.path)}function Rj(e){const t=j1(R=>R.projects),n=j1(R=>R.activeProjectId),s=j1(R=>R.setActiveProjectIdOnly),o=Be(R=>R.newSessionDraft),r=Be(R=>R.currentSessionId),a=Be(R=>R.currentSessionDirectory),l=Be(R=>R.setNewSessionDraftTarget),c=Be(R=>R.openNewSessionDraft),u=!!o?.open,f=h2(R=>R.fetchStatus),{git:h}=ra(),m=d.useMemo(()=>{if(u){const $=o?.selectedProjectId?t.find(O=>O.id===o.selectedProjectId)??null:null;if($)return $}else if(r){const $=Kt(t,void 0,a);if($)return $}const R=n?t.find($=>$.id===n)??null:null;return R||(t[0]??null)},[n,a,r,u,o?.selectedProjectId,t]),p=d.useMemo(()=>qt(m?.path??null),[m?.path]),g=m?f5(m):null;d.useEffect(()=>{if(!e||!u||!n||o?.selectedProjectId===n)return;const R=t.find($=>$.id===n);R&&l({projectId:R.id,directoryOverride:R.path})},[n,e,u,o?.selectedProjectId,t,l]);const y=HA(p),M=h2(R=>p?R.directories.get(p)?.lastBranchesFetch??0:0),b=Qi(p),v=!!y?.all,x=h2(R=>R.fetchBranches),[S,C]=d.useState(!1);d.useEffect(()=>{!e||!p||!h||b!==null||f(p,h,{silent:!0})},[f,h,b,p,e]),d.useEffect(()=>{if(!e||!p||!m||!h||b!==!0){C(!1);return}const R=!M||Date.now()-M>Dj;if(v&&!R){C(!1);return}let $=!1;return C(!v),x(p,h).finally(()=>{$||C(!1)}),()=>{$=!0}},[x,h,m,M,v,b,p,e]);const w=y?.current?.trim()??"",_=d.useMemo(()=>{if(!m)return null;const R=qt(m.path);return!R||!w?null:{value:R,label:w}},[m,w]),L=d.useMemo(()=>u?qt(o?.directoryOverride??null)??p:qt(a??null)??p,[a,u,o?.directoryOverride,p]),A=d.useMemo(()=>{const R=[];return _&&R.push(_),!L||R.some($=>$.value===L)?R:[...R,{value:L,label:fi(L)}]},[_,L]),N=d.useMemo(()=>{const R=L??A[0]?.value??null;return R?A.find($=>$.value===R)?.label??fi(R):null},[A,L]),k=d.useMemo(()=>L?_?.value===L:!0,[_?.value,L]),V=d.useMemo(()=>b!==!0||S?!1:!!_,[S,_,b]),H=d.useCallback((R,$)=>{if(n!==R&&s(R),u){l({projectId:R,directoryOverride:$},{force:!0});return}c({selectedProjectId:R,directoryOverride:$})},[n,u,c,s,l]),D=d.useCallback(R=>{const $=t.find(I=>I.id===R);if(!$)return;const O=qt($.path);O&&(m?.id===R&&L===O||H(R,O))},[H,t,L,m?.id]),P=d.useCallback(R=>{if(!m)return;const $=qt(R);!$||L===$||H(m.id,$)},[H,L,m]);return{projects:t,selectedDraftProject:m,selectedDraftProjectPath:p,draftProjectLabel:g,selectedDraftDirectory:L,selectedDraftBranchLabel:N,selectedDraftBranchIsKnown:k,projectRootBranchOption:_,worktreeBranchOptions:[],draftBranchItems:A,shouldShowDraftBranchSelector:V,handleDraftProjectChange:D,handleDraftDirectoryChange:P}}function Oj(e){const{isMobile:t,editorRef:n,formRef:s,setExpandedInput:o,holders:r,alwaysExpanded:a=!1}=e,[l,c]=d.useState(a&&t),[u,f]=d.useState(!1),[h,m]=d.useState(!1),p=d.useRef(null),g=d.useRef(0),y=d.useRef(!1),M=d.useRef(null);d.useEffect(()=>()=>{M.current!==null&&window.clearTimeout(M.current)},[]);const b=d.useRef(l);d.useEffect(()=>{b.current=l});const v=d.useRef(a);v.current=a,d.useEffect(()=>{!t||!a||c(!0)},[a,t]),d.useLayoutEffect(()=>{if(!t||typeof document>"u")return;const P=document.documentElement;return P.classList.toggle("oc-composer-expanded",l&&!a),()=>P.classList.remove("oc-composer-expanded")},[a,l,t]);const x=d.useCallback(()=>{if(p.current="focus",V0.flushSync(()=>c(!0)),Ot()){requestAnimationFrame(()=>{n.current?.focus({preventScroll:!0})});return}n.current?.focus({preventScroll:!1})},[n]);d.useEffect(()=>{if(!t||typeof document>"u")return;let P=document.getElementById("mobile-overlay-root");P||(P=document.createElement("div"),P.id="mobile-overlay-root",document.body.appendChild(P));const R=P,$=()=>m(R.childElementCount>0);$();const O=new MutationObserver($);return O.observe(R,{childList:!0}),()=>O.disconnect()},[t]);const S=h||r.controlsPanelOpen||r.attachMenuOpen||r.issuePickerOpen||r.prPickerOpen,C=d.useRef(!1);C.current=r.issuePickerOpen||r.prPickerOpen;const w=d.useRef(!1),_=d.useRef(0),L=d.useRef(0);d.useEffect(()=>{if(!t||Ot()||typeof window>"u"||!window.matchMedia?.("(display-mode: standalone)")?.matches)return;const P=()=>{_.current+=1},R=()=>{if(_.current=Math.max(0,_.current-1),w.current){w.current=!1;return}if(!y.current||C.current||_.current>0)return;y.current=!1,L.current=Date.now()+600,n.current?.focus(),n.current?.isFocused()&&f(!0);const $=()=>{const O=n.current;O?.isFocused()&&(s.current??O.getScrollDOM())?.scrollIntoView({block:"end"})};window.setTimeout($,300),window.setTimeout($,650)};return window.addEventListener("oc:mobile-overlay-opened",P),window.addEventListener("oc:mobile-overlay-closed",R),()=>{window.removeEventListener("oc:mobile-overlay-opened",P),window.removeEventListener("oc:mobile-overlay-closed",R)}},[n,s,t]),d.useEffect(()=>{if(!t)return;if(S){(u||Date.now()-g.current<800)&&(y.current=!0);return}if(!y.current)return;const P=window.setTimeout(()=>{y.current=!1,n.current?.focus({preventScroll:Ot()})},180);return()=>window.clearTimeout(P)},[n,u,t,S]);const A=u||h||r.controlsPanelOpen||r.attachMenuOpen||r.draftPickerOpen||r.issuePickerOpen||r.prPickerOpen||r.isDragging;d.useEffect(()=>{if(!t||!l||A||a)return;const P=window.setTimeout(()=>{n.current?.isFocused()||(p.current=null,c(!1),o(!1))},250);return()=>window.clearTimeout(P)},[a,A,n,l,t,o]);const N=d.useRef(!1);N.current=A,d.useEffect(()=>{if(!t||Ot()||typeof document>"u")return;const P=document.documentElement;return u?P.classList.add("oc-browser-keyboard-open"):(P.classList.remove("oc-browser-keyboard-open"),window.matchMedia?.("(display-mode: standalone)")?.matches&&window.setTimeout(()=>{P.classList.contains("oc-browser-keyboard-open")||(window.scrollTo(0,0),document.body.scrollTop=0,P.scrollTop=0)},350)),()=>P.classList.remove("oc-browser-keyboard-open")},[u,t]),d.useEffect(()=>{if(!t||typeof window>"u")return;const P=R=>{const $=R.detail;!$||$.open!==!1||!b.current||v.current||N.current||(p.current=null,V0.flushSync(()=>{c(!1),o(!1)}))};return window.addEventListener("oc:keyboard-intent",P),()=>window.removeEventListener("oc:keyboard-intent",P)},[a,t,o]);const k=d.useCallback(()=>{t&&(Ot()&&ZA(),M.current!==null&&(window.clearTimeout(M.current),M.current=null),p.current=null,f(!0))},[t]),V=d.useCallback(()=>{if(t){if(Date.now()<L.current){const P=n.current;if(P){P.focus(),window.setTimeout(()=>{Date.now()<L.current&&!P.isFocused()&&P.focus()},50);return}}if(g.current=Date.now(),Ot()){V0.flushSync(()=>f(!1));return}M.current!==null&&window.clearTimeout(M.current),M.current=window.setTimeout(()=>{M.current=null,f(!1)},120)}},[n,t]),H=d.useCallback(()=>{w.current=!0},[]),D=d.useCallback(()=>{y.current=!1},[]);return{expanded:l,focused:u,overlayHostBusy:h,expand:x,onEditorFocus:k,onEditorBlur:V,skipNextOverlayCloseRestore:H,cancelOverlayCloseRestore:D}}function a7(e){e.style.position="",e.style.left="",e.style.right="",e.style.width="",e.style.top="",e.style.height="",e.style.zIndex="",e.style.background=""}function Zj(e){const{isMobile:t,isFullscreen:n,isDraftScreen:s,isFocused:o,formRef:r,editorRef:a}=e;d.useLayoutEffect(()=>{if(!t||!n||Ot())return;const l=window.visualViewport,c=r.current,u=a.current;if(!l||!c)return;document.documentElement.classList.add("oc-browser-kb-fullscreen");const f=()=>{const h=Math.max(0,Math.floor(l.offsetTop)),m=document.documentElement.clientHeight;c.style.position="fixed",c.style.left="0",c.style.right="0",c.style.top=`${h}px`,c.style.height=`${Math.floor(Math.min(l.height,m-h))}px`,c.style.zIndex="40",c.style.background="var(--background)"};return f(),l.addEventListener("resize",f),l.addEventListener("scroll",f),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{l.removeEventListener("resize",f),l.removeEventListener("scroll",f),window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0),document.documentElement.classList.remove("oc-browser-kb-fullscreen"),a7(c),requestAnimationFrame(()=>{u?.isFocused()&&u.getScrollDOM()?.scrollIntoView({block:"nearest"})})}},[a,r,n,t]),d.useLayoutEffect(()=>{if(!t||Ot()||!s||n||!o)return;const l=window.visualViewport,c=r.current;if(!l||!c)return;const u=c.getBoundingClientRect();c.style.position="fixed",c.style.left=`${Math.floor(u.left)}px`,c.style.width=`${Math.floor(u.width)}px`,c.style.zIndex="40",c.style.background="var(--background)";let f=Number.NaN,h=0;const m=()=>{const p=document.documentElement.clientHeight,g=l.offsetTop+l.height,y=Math.max(0,Math.floor(Math.min(g,p)-c.offsetHeight));y!==f&&(f=y,c.style.top=`${y}px`),h=requestAnimationFrame(m)};return m(),()=>{cancelAnimationFrame(h),a7(c)}},[r,s,o,n,t])}const Fj=T9(["border-input flex items-center justify-between gap-2 rounded-md border bg-transparent","typography-ui-label whitespace-nowrap shadow-none outline-none text-left","hover:bg-interactive-hover data-[popup-open]:bg-interactive-active","focus-visible:outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","disabled:cursor-not-allowed disabled:opacity-50","[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='text-'])]:text-muted-foreground"].join(" "),{variants:{size:{sm:"h-6 min-h-6 px-2 [&_svg:not([class*='size-'])]:size-3.5",default:"h-8 min-h-8 px-3 [&_svg:not([class*='size-'])]:size-4"}},defaultVariants:{size:"default"}}),h5=ae.createContext(null),$j=e=>e?e.closest('[data-slot="dialog-content"], [role="dialog"]'):null;function l7({onValueChange:e,modal:t=!1,...n}){const[s,o]=ae.useState(null),r=ae.useMemo(()=>({portalContainer:s,setPortalContainer:o}),[s]),a=ae.useCallback((l,c)=>{typeof l=="string"&&e?.(l,c)},[e]);return i.jsx(h5.Provider,{value:r,children:i.jsx(zy,{...n,modal:t,onValueChange:a})})}function qj({...e}){return i.jsx(Wy,{"data-slot":"select-group",...e})}function c7({placeholder:e,children:t,...n}){return i.jsx(Oy,{"data-slot":"select-value",...n,children:s=>{const o=typeof s=="string"||s===void 0?s:s===null?void 0:String(s);return typeof t=="function"?t(o):t??(o===void 0||o===""?e:o)}})}function d7({className:e,size:t="default",children:n,asChild:s,onPointerDownCapture:o,onFocusCapture:r,...a}){const l=ae.useContext(h5),c=ae.useCallback(f=>{if(!l)return;const h=f instanceof HTMLElement?f:null;l.setPortalContainer($j(h))},[l]),u=s&&ae.isValidElement(n)?{render:n}:null;return i.jsx(Dy,{"data-slot":"select-trigger","data-size":t,className:B(Fj({size:t==="settings"||t==="lg"?"default":"sm"}),"w-fit data-[placeholder]:text-muted-foreground aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2",e),onPointerDownCapture:f=>{c(f.currentTarget),o?.(f)},onFocusCapture:f=>{c(f.currentTarget),r?.(f)},...a,...u??{},children:u?void 0:i.jsxs(i.Fragment,{children:[n,i.jsx(Ry,{children:i.jsx(z,{name:"arrow-down-s",className:"size-4 opacity-50"})})]})})}function u7({className:e,children:t,position:n="popper",fitContent:s=!1,portalToBody:o=!1,sideOffset:r,side:a,align:l,...c}){const u=ae.useContext(h5),f=n==="item-aligned",h=u?.portalContainer??null;return i.jsx(Zy,{container:o?void 0:h||void 0,children:i.jsx(Fy,{alignItemWithTrigger:f,sideOffset:r,side:a,align:l,className:"absolute z-[120] pointer-events-auto",children:i.jsx($y,{"data-slot":"select-content",style:{color:"var(--surface-elevated-foreground)"},className:B("oc-glass-popover oc-glass-floating pointer-events-auto transition-all duration-150 ease-out data-[starting-style]:opacity-0 data-[starting-style]:scale-95 data-[ending-style]:opacity-0 data-[ending-style]:scale-95 relative z-[120] max-h-[var(--available-height)] min-w-[8rem] origin-[var(--transform-origin)] overflow-x-hidden rounded-xl",!f&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",s&&"w-max min-w-0",e),...c,children:i.jsx(vt,{outerClassName:B("max-h-[var(--available-height)]",s?"w-max":"w-full"),className:B("p-1",!f&&(s?"w-max min-w-0 scroll-my-1":"w-full min-w-[var(--anchor-width)] scroll-my-1")),preventOverscroll:!0,children:t})})})})}function Uj({className:e,...t}){return i.jsx(Ky,{"data-slot":"select-label",className:B("text-muted-foreground px-2 py-1.5 typography-meta",e),...t})}function Cl({className:e,children:t,...n}){return i.jsxs(qy,{"data-slot":"select-item",className:B("data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover data-[selected]:bg-interactive-selection data-[selected]:text-interactive-selection-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-pointer items-center gap-2 rounded-lg py-1.5 pr-8 pl-2 typography-ui-label outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...n,children:[i.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:i.jsx(Uy,{children:i.jsx(z,{name:"check",className:"size-4"})})}),i.jsx(Gy,{children:t})]})}const Nh=(e,t)=>e.length<=t?e:`${e.slice(0,t)}...`;function Ci({project:e}){const t=he(a=>a.isMobile),{enabled:n}=Kn(),s=t&&!n,o=f5(e),r=s?Nh(o,20):o;return i.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[i.jsx(z,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),i.jsx("span",{className:"truncate text-muted-foreground",children:r})]})}const f7="h-7 min-w-0 w-fit max-w-[48vw] gap-1 border-transparent bg-transparent px-1.5 text-muted-foreground typography-micro font-normal hover:bg-transparent hover:text-foreground data-[popup-open]:bg-transparent [&_svg]:size-3.5 [&_svg]:opacity-70 sm:max-w-[20rem]";function Gj(e){const{projects:t,selectedProject:n,selectedDirectory:s,selectedBranchLabel:o,selectedBranchIsKnown:r,projectRootBranchOption:a,showBranchSelector:l,showProjectSelector:c=!0,endAccessory:u,onProjectChange:f,onDirectoryChange:h,theme:m}=e;return i.jsxs("div",{className:"mb-3 flex min-w-0 w-full items-center justify-between gap-2 pl-2 pr-1",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[c?i.jsxs(l7,{value:n.id,onValueChange:f,children:[i.jsx(d7,{size:"sm",className:f7,children:i.jsx(c7,{children:i.jsx(Ci,{project:n,theme:m})})}),i.jsx(u7,{className:"w-max min-w-48",children:t.map(p=>i.jsx(Cl,{value:p.id,className:"max-w-[24rem] truncate",children:i.jsx(Ci,{project:p,theme:m})},p.id))})]}):null,l?i.jsxs(l7,{value:s??a?.value,onValueChange:h,children:[i.jsx(d7,{size:"sm",className:f7,children:i.jsx(c7,{children:o??"Branch"})}),i.jsxs(u7,{className:"w-max min-w-48",children:[a?i.jsxs(qj,{children:[i.jsx(Uj,{children:"Project root"}),i.jsx(Cl,{value:a.value,className:"max-w-[24rem] truncate",children:a.label},a.value)]}):null,s&&!r?i.jsx(Cl,{value:s,className:"max-w-[24rem] truncate",children:o}):null]})]}):null]}),u?i.jsx("div",{className:"min-w-0 shrink-0",children:u}):null]})}function Wj(e){const{selectedProject:t,selectedBranchLabel:n,showBranchSelector:s,showProjectSelector:o=!0,endAccessory:r,theme:a,onOpenPicker:l}=e,{enabled:c}=Kn(),u=n?c?n:Nh(n,26):null;return i.jsxs("div",{className:"mb-1.5 flex min-w-0 w-full items-center justify-between gap-2 pl-2 pr-1",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-x-2",children:[o?i.jsxs("button",{type:"button",className:"inline-flex h-7 min-w-0 max-w-[42vw] flex-shrink cursor-pointer items-center gap-1 rounded-lg px-1.5 typography-micro font-medium text-foreground/80 hover:bg-[var(--interactive-hover)]",onClick:()=>l("project"),children:[i.jsx(Ci,{project:t,theme:a}),i.jsx(z,{name:"arrow-down-s",className:"h-3 w-3 flex-shrink-0 text-muted-foreground"})]}):null,s?i.jsxs("button",{type:"button",className:"inline-flex h-7 min-w-0 max-w-[42vw] flex-shrink cursor-pointer items-center gap-1 rounded-lg px-1.5 typography-micro font-medium text-foreground/80 hover:bg-[var(--interactive-hover)]",onClick:()=>l("branch"),children:[i.jsx(z,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground"}),i.jsx("span",{className:"truncate",children:u??"Branch"}),i.jsx(z,{name:"arrow-down-s",className:"h-3 w-3 flex-shrink-0 text-muted-foreground"})]}):null]}),r?i.jsx("div",{className:"min-w-0 shrink-0",children:r}):null]})}function Kj(e){const{projects:t,selectedProject:n,selectedDirectory:s,selectedBranchLabel:o,selectedBranchIsKnown:r,projectRootBranchOption:a,onProjectChange:l,onDirectoryChange:c,theme:u,openPicker:f,onOpenPickerChange:h,showProjectSelector:m=!0,showBranchSelector:p}=e,[g,y]=d.useState(""),[M,b]=d.useState("");d.useEffect(()=>{f!=="project"&&y(""),f!=="branch"&&b("")},[f]);const v=d.useMemo(()=>{const x=g.trim().toLowerCase();return x?t.filter(S=>f5(S).toLowerCase().includes(x)||S.path.toLowerCase().includes(x)):t},[g,t]);return i.jsxs(i.Fragment,{children:[i.jsx(t0,{open:m&&f==="project",onClose:()=>h(null),title:"Project",children:i.jsxs("div",{className:"flex flex-col py-1",children:[t.length>5?i.jsx("div",{className:"px-3 pb-2 pt-1",children:i.jsx(Bt,{value:g,onChange:x=>y(x.target.value),placeholder:"Search projects...",className:"h-8 typography-meta",autoFocus:!0})}):null,i.jsx("div",{className:"max-h-[60vh] overflow-y-auto px-2",children:v.map(x=>{const S=x.id===n.id;return i.jsxs("button",{type:"button",onClick:()=>{l(x.id),h(null)},className:`flex w-full cursor-pointer items-center justify-between gap-2 rounded-lg px-3 py-2 text-left typography-ui-label transition-colors hover:bg-[var(--interactive-hover)] ${S?"bg-[var(--interactive-hover)] font-medium text-foreground":"text-foreground/80"}`,children:[i.jsx(Ci,{project:x,theme:u}),S?i.jsx(z,{name:"check",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):null]},x.id)})})]})}),i.jsx(t0,{open:p&&f==="branch",onClose:()=>h(null),title:"Branch",children:i.jsx("div",{className:"flex flex-col py-1",children:i.jsx("div",{className:"max-h-[60vh] overflow-y-auto px-2",children:(()=>{const x=s??a?.value??null,S=M.trim().toLowerCase(),C=_=>!S||_.toLowerCase().includes(S),w=(_,L,A)=>i.jsxs("button",{type:"button",onClick:()=>{c(_),h(null)},className:`flex w-full cursor-pointer items-center justify-between gap-2 rounded-lg px-3 py-2 text-left typography-ui-label transition-colors hover:bg-[var(--interactive-hover)] ${_===x?"bg-[var(--interactive-hover)] font-medium text-foreground":"text-foreground/80"}`,children:[i.jsx("span",{className:"truncate",children:L}),_===x?i.jsx(z,{name:"check",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):null]},A??_);return i.jsxs(i.Fragment,{children:[a&&C(a.label)?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"px-2 pb-1 pt-1.5 text-muted-foreground typography-meta",children:"Project root"}),w(a.value,a.label)]}):null,s&&!r&&C(o??"")?w(s,o??s,"unknown-current"):null]})})()})})})]})}const ua=(e,t)=>{const[n,s]=d.useState(void 0);return d.useLayoutEffect(()=>{if(!t)return;const o=()=>{const r=e.current;if(!r)return;const a=r.closest("main");if(!a)return;const l=window.visualViewport?.offsetTop??0,c=Math.max(a.getBoundingClientRect().top,l),u=r.getBoundingClientRect().bottom-c-8,f=Math.max(120,Math.floor(u));s(h=>h===f?h:f)};return o(),window.addEventListener("resize",o),window.addEventListener("oc:keyboard-settled",o),window.visualViewport?.addEventListener("resize",o),window.visualViewport?.addEventListener("scroll",o),()=>{window.removeEventListener("resize",o),window.removeEventListener("oc:keyboard-settled",o),window.visualViewport?.removeEventListener("resize",o),window.visualViewport?.removeEventListener("scroll",o)}}),t?n:void 0};function h7(e,t){const n=e.searchAliases??[],s=[...n,...e.name===t.name?[]:[t.name],...t.description?[t.description]:[],...t.searchAliases??[]].filter((r,a,l)=>r!==e.description&&l.indexOf(r)===a);return s.length===n.length&&s.every((r,a)=>r===n[a])?e:{...e,searchAliases:s}}function Yj(e,t,n){const s=[],o=new Map,r=(a,l)=>{for(const c of a){const u=l(c),f=c.name,h=o.get(f);if(!h){o.set(f,{index:s.length,item:c,precedence:u}),s.push(c);continue}const m=u>h.precedence?h7(c,h.item):h7(h.item,c);s[h.index]=m,o.set(f,{index:h.index,item:m,precedence:Math.max(h.precedence,u)})}};return r(e,()=>3),r(t,a=>a.isBuiltIn?3:a.isSkill?1:0),r(n,()=>2),s}function Jj(e,t){return e0(e.name,t)||!!(e.description&&e0(e.description,t))||!!e.searchAliases?.some(n=>e0(n,t))}const fa="text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0",m7=B(fa,"bg-[color-mix(in_srgb,var(--primary-base)_12%,transparent)] text-[color-mix(in_srgb,var(--primary-base)_70%,transparent)] border-[color-mix(in_srgb,var(--primary-base)_24%,transparent)]"),Xj=B(fa,"bg-[color-mix(in_srgb,var(--status-success)_12%,transparent)] text-[color-mix(in_srgb,var(--status-success)_70%,transparent)] border-[color-mix(in_srgb,var(--status-success)_24%,transparent)]"),Qj=B(fa,"bg-[color-mix(in_srgb,var(--status-info)_12%,transparent)] text-[color-mix(in_srgb,var(--status-info)_70%,transparent)] border-[color-mix(in_srgb,var(--status-info)_24%,transparent)]"),Sl=B(fa,"bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60"),Ph=d.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,style:s},o)=>{const r=Be(D=>D.currentSessionId),l=$i(r??"").length>0,c=!!r,u=Be(D=>!!D.newSessionDraft?.open),f=c||u,h=he(D=>D.isMobile),m=c&&!h,[p,g]=d.useState([]),[y,M]=d.useState(!1),b=R2(D=>D.skills),v=R2(D=>D.loadSkills),[x,S]=d.useState(0),C=d.useRef(0),w=d.useRef(!1),_=d.useRef([]),L=d.useRef(null),A=ua(L,h),N=d.useRef(!1),k=d.useRef(null),V=d.useRef(!1);d.useEffect(()=>{const D=P=>{const R=P.target;!R||!L.current||L.current.contains(R)||n()};return document.addEventListener("pointerdown",D,!0),()=>{document.removeEventListener("pointerdown",D,!0)}},[n]),d.useEffect(()=>{v()},[v]),d.useEffect(()=>{(async()=>{M(!0);try{const P=b.map((q,G)=>({id:`skill:${q.scope}:${q.source??"opencode"}:${q.name}:${G}`,name:q.name,source:"skill",description:q.description,isSkill:!0,scope:q.scope})),R=[...c&&!l?[{id:"pichamber:init",name:"init",source:"pichamber",description:"Create/update AGENTS.md file",isBuiltIn:!0}]:[],...c?[{id:"pichamber:undo",name:"undo",source:"pichamber",description:"Undo the last message",isBuiltIn:!0},{id:"pichamber:redo",name:"redo",source:"pichamber",description:"Redo previously undone messages",isBuiltIn:!0},{id:"pichamber:timeline",name:"timeline",source:"pichamber",description:"Open the conversation timeline",isBuiltIn:!0}]:[],{id:"pichamber:compact",name:"compact",source:"pichamber",description:"Compress session history using AI to reduce context size",isBuiltIn:!0},...c?[{id:"pichamber:summary",name:"summary",source:"pichamber",description:"Non-destructive session summary. Optional topic hint after the command.",isPiChamber:!0}]:[],...f?[{id:"pichamber:plan-feature",name:"plan-feature",source:"pichamber",description:"Start a guided, back-and-forth planning session for a new feature.",isPiChamber:!0}]:[],...f?[{id:"pichamber:catch-up",name:"catch-up",source:"pichamber",description:"Re-establish context: what you were doing and where to pick up.",isPiChamber:!0}]:[],...f?[{id:"pichamber:debug",name:"debug",source:"pichamber",description:"Guided root-cause investigation for a bug before proposing a fix.",isPiChamber:!0}]:[],...f?[{id:"pichamber:weigh",name:"weigh",source:"pichamber",description:"Weigh 2-3 approaches with trade-offs and a recommendation before you commit.",isPiChamber:!0}]:[],...f?[{id:"pichamber:explore",name:"explore",source:"pichamber",description:"Get oriented in this codebase: a high-level tour of the architecture and main parts.",isPiChamber:!0}]:[]],$=Yj(R,[],P),O=!l,I=(e?$.filter(q=>Jj(q,e)):$).filter(q=>O||q.name!=="init");I.sort((q,G)=>{const K=q.name.toLowerCase().startsWith(e.toLowerCase()),W=G.name.toLowerCase().startsWith(e.toLowerCase());return K&&!W?-1:!K&&W?1:q.name.localeCompare(G.name)}),g(I)}catch{const P=!l,R=[...c&&!l?[{id:"pichamber:init",name:"init",source:"pichamber",description:"Create/update AGENTS.md file",isBuiltIn:!0}]:[],...c?[{id:"pichamber:undo",name:"undo",source:"pichamber",description:"Undo the last message",isBuiltIn:!0},{id:"pichamber:redo",name:"redo",source:"pichamber",description:"Redo previously undone messages",isBuiltIn:!0},{id:"pichamber:timeline",name:"timeline",source:"pichamber",description:"Open the conversation timeline",isBuiltIn:!0}]:[],{id:"pichamber:compact",name:"compact",source:"pichamber",description:"Compress session history using AI to reduce context size",isBuiltIn:!0},...c?[{id:"pichamber:summary",name:"summary",source:"pichamber",description:"Non-destructive session summary. Optional topic hint after the command.",isPiChamber:!0}]:[],...f?[{id:"pichamber:plan-feature",name:"plan-feature",source:"pichamber",description:"Start a guided, back-and-forth planning session for a new feature.",isPiChamber:!0}]:[],...f?[{id:"pichamber:catch-up",name:"catch-up",source:"pichamber",description:"Re-establish context: what you were doing and where to pick up.",isPiChamber:!0}]:[],...f?[{id:"pichamber:debug",name:"debug",source:"pichamber",description:"Guided root-cause investigation for a bug before proposing a fix.",isPiChamber:!0}]:[],...f?[{id:"pichamber:weigh",name:"weigh",source:"pichamber",description:"Weigh 2-3 approaches with trade-offs and a recommendation before you commit.",isPiChamber:!0}]:[],...f?[{id:"pichamber:explore",name:"explore",source:"pichamber",description:"Get oriented in this codebase: a high-level tour of the architecture and main parts.",isPiChamber:!0}]:[]],$=(e?R.filter(O=>e0(O.name,e)||O.description&&e0(O.description,e)):R).filter(O=>P||O.name!=="init");g($)}finally{M(!1)}})()},[e,l,c,f,m,b]),d.useEffect(()=>{S(0)},[p]),d.useEffect(()=>{C.current=x},[x]),d.useEffect(()=>{_.current[x]?.scrollIntoView({block:"nearest"})},[x]),d.useImperativeHandle(o,()=>({handleKeyDown:D=>{const P=p.length;if(D==="Escape"){n();return}if(P!==0){if(D==="ArrowDown"){w.current=!0,S(R=>(R+1)%P);return}if(D==="ArrowUp"){w.current=!0,S(R=>(R-1+P)%P);return}if(D==="Enter"||D==="Tab"){const R=(C.current%P+P)%P,$=p[R];$&&t($)}}}}),[p,n,t]);const H=D=>{switch(D.name){case"init":return i.jsx(z,{name:"file",className:"h-3.5 w-3.5 text-green-500"});case"undo":return i.jsx(z,{name:"arrow-go-back",className:"h-3.5 w-3.5 text-orange-500"});case"redo":return i.jsx(z,{name:"arrow-go-forward",className:"h-3.5 w-3.5 text-orange-500"});case"timeline":return i.jsx(z,{name:"time",className:"h-3.5 w-3.5"});case"compact":return i.jsx(z,{name:"scissors",className:"h-3.5 w-3.5 text-purple-500"});case"review":return i.jsx(z,{name:"search-eye",className:"h-3.5 w-3.5 text-blue-500"});case"test":case"build":case"run":return i.jsx(z,{name:"terminal-box",className:"h-3.5 w-3.5 text-cyan-500"});default:return D.isBuiltIn?i.jsx(z,{name:"flashlight",className:"h-3.5 w-3.5 text-yellow-500"}):i.jsx(z,{name:"command",className:"h-3.5 w-3.5 text-muted-foreground"})}};return i.jsxs("div",{ref:L,className:"absolute z-[100] min-w-0 w-full max-w-[450px] max-h-64 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col",style:A!==void 0?{...s,maxHeight:A}:s,children:[i.jsx(vt,{preventOverscroll:!0,outerClassName:"flex-1 min-h-0",className:"px-0 pb-2",children:y?i.jsx("div",{className:"flex items-center justify-center py-4",children:i.jsx(z,{name:"refresh",className:"h-4 w-4 animate-spin text-muted-foreground"})}):i.jsxs("div",{children:[p.map((D,P)=>{const R=D.isBuiltIn,$=D.isPiChamber;return i.jsxs("div",{ref:O=>{_.current[P]=O},className:B("flex gap-2 px-3 py-2 cursor-pointer rounded-lg",h?"items-center":"items-start",P===x&&"bg-interactive-selection"),onMouseDown:O=>O.preventDefault(),onPointerDown:O=>{O.pointerType==="touch"&&(k.current={x:O.clientX,y:O.clientY},V.current=!1)},onPointerMove:O=>{if(O.pointerType!=="touch"||!k.current)return;const I=O.clientX-k.current.x,q=O.clientY-k.current.y;Math.hypot(I,q)>6&&(V.current=!0)},onPointerUp:O=>{if(O.pointerType!=="touch")return;const I=V.current;k.current=null,V.current=!1,!I&&(O.preventDefault(),O.stopPropagation(),N.current=!0,t(D))},onPointerCancel:()=>{k.current=null,V.current=!1},onClick:()=>{if(N.current){N.current=!1;return}t(D)},onMouseMove:()=>{w.current=!1,S(P)},children:[i.jsx("div",{className:B(!h&&"mt-0.5"),children:H(D)}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"typography-ui-label font-medium",children:["/",D.name]}),D.isSkill?i.jsx("span",{className:m7,children:"skill"}):i.jsx("span",{className:m7,children:"command"}),$?i.jsx("span",{className:Sl,children:"PiChamber"}):R?i.jsx("span",{className:Sl,children:"system"}):D.scope?i.jsx("span",{className:D.scope==="project"?Qj:Xj,children:D.scope}):null,D.agent&&i.jsx("span",{className:Sl,children:D.agent})]}),D.description&&!h&&i.jsx("div",{className:"typography-meta text-muted-foreground mt-0.5 truncate",children:D.description})]})]},D.id)}),p.length===0&&i.jsx("div",{className:"px-3 py-2 typography-ui-label text-muted-foreground",children:"No commands found"})]})}),!h&&i.jsx("div",{className:"px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground",children:"↑↓ navigate • Enter select • Esc close"})]})});Ph.displayName="CommandAutocomplete";const eI=d.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onClose:s,style:o},r)=>{const a=gh()??"",l=j1(Y=>Y.activeProjectId),c=j1(d.useCallback(Y=>Y.projects.find(oe=>oe.id===l)?.path??null,[l])),u=d.useMemo(()=>{const Y=c||a;return Y?Y.replace(/\\/g,"/").replace(/\/+$/,""):null},[c,a]),f=Og(d.useCallback(Y=>u?Y.byRoot[u]:void 0,[u])),h=$e(Y=>Y.getVisibleAgents),m=Zg(Y=>Y.searchFiles),p=o5(e,180),g=Fg(),y=$g(),[M,b]=d.useState([]),[v,x]=d.useState([]),[S,C]=d.useState([]),[w,_]=d.useState(!1),L=d.useRef(0),[A,N]=d.useState(0),k=d.useRef(0),[V,H]=d.useState(360),[D,P]=d.useState({}),[R,$]=d.useState({}),O=d.useRef([]),I=d.useRef([]),q=d.useRef([]),G=d.useRef(null),K=he(Y=>Y.isMobile),W=ua(G,K),ge=(e??"").trim(),Z=d.useMemo(()=>{if(!u||!f)return[];const Y=[f.selectedPath,...f.openPaths.slice().reverse()].filter(He=>typeof He=="string"&&He.length>0),oe=new Set,te=ge.toLowerCase();return Y.filter(He=>{if(oe.has(He))return!1;oe.add(He);const je=He.startsWith(`${u}/`)?He.slice(u.length+1):He;return te?je.toLowerCase().includes(te):!0}).slice(0,6).map(He=>{const je=He.replace(/\\/g,"/"),Pe=je.split("/").filter(Boolean).pop()||je,X=je.startsWith(`${u}/`)?je.slice(u.length+1):je;return{name:Pe,path:je,relativePath:X,extension:Pe.includes(".")?Pe.split(".").pop()?.toLowerCase():void 0}})},[ge,u,f]),fe=d.useMemo(()=>ge.length>0?S:S.slice(0,2),[S,ge.length]),ie=v,E=Z,ce=M;d.useEffect(()=>{const Y=oe=>{const te=oe.target;!te||!G.current||G.current.contains(te)||s()};return document.addEventListener("pointerdown",Y,!0),()=>{document.removeEventListener("pointerdown",Y,!0)}},[s]),d.useEffect(()=>{if(!a){b([]);return}const oe=(p??"").trim().replace(/^\.\//,"").replace(/^\/+/,"").toLowerCase();if(!oe){b([]);return}let te=!1;return L.current++,_(!0),m(a,oe,80,{includeHidden:g,respectGitignore:!y,type:"file"}).then(pe=>{if(te)return;const He=new Set(Z.map(je=>je.path));b(pe.filter(je=>!He.has(je.path)).slice(0,15))}).catch(()=>{te||b([])}).finally(()=>{te||(L.current--,L.current<=0&&(L.current=0,_(!1)))}),()=>{te=!0,L.current=Math.max(0,L.current-1),L.current<=0&&_(!1)}},[a,p,Z,m,g,y]),d.useEffect(()=>{if(!a){x([]);return}const oe=(p??"").trim().replace(/^\.\//,"").replace(/^\/+/,"").toLowerCase();if(!oe){x([]);return}let te=!1;return L.current++,_(!0),m(a,oe,20,{includeHidden:g,respectGitignore:!y,type:"directory"}).then(pe=>{te||x(pe.slice(0,10))}).catch(()=>{te||x([])}).finally(()=>{te||(L.current--,L.current<=0&&(L.current=0,_(!1)))}),()=>{te=!0,L.current=Math.max(0,L.current-1),L.current<=0&&_(!1)}},[a,p,m,g,y]),d.useEffect(()=>{const Y=h(),oe=(e??"").trim().toLowerCase(),te=Y.filter(pe=>pe.mode&&pe.mode!=="primary").filter(pe=>oe?`${pe.name??""} ${pe.description??""}`.toLowerCase().includes(oe):!0).map(pe=>({name:pe.name??"",description:typeof pe.description=="string"?pe.description:void 0,mode:typeof pe.mode=="string"?pe.mode:void 0})).sort((pe,He)=>pe.name.localeCompare(He.name));C(te)},[h,e]),d.useEffect(()=>{N(0),P({}),$({})},[ce,ie,E.length,fe.length]),d.useEffect(()=>{k.current=A},[A]),d.useEffect(()=>{O.current[A]?.scrollIntoView({block:"nearest"})},[A]),d.useEffect(()=>{let Y=null;const oe=()=>{Y!==null&&cancelAnimationFrame(Y),Y=requestAnimationFrame(()=>{const te={},pe={};I.current.forEach((He,je)=>{if(!He)return;const X=q.current[je]?.offsetWidth??He.scrollWidth,me=Math.max(0,X-He.clientWidth),U=me>8;if(te[je]=U,U){const T=Math.max(.6,me/110);pe[je]=T}}),P(te),$(pe)})};return oe(),window.addEventListener("resize",oe),()=>{Y!==null&&cancelAnimationFrame(Y),window.removeEventListener("resize",oe)}},[ce,ie]),d.useEffect(()=>{const Y=I.current[A];if(!Y)return;const oe=()=>{const pe=Y.clientWidth;pe>0&&H(pe)};if(oe(),typeof ResizeObserver>"u")return;const te=new ResizeObserver(oe);return te.observe(Y),()=>{te.disconnect()}},[A]);const ee=d.useCallback(Y=>{t(Y)},[t]),ue=d.useCallback(Y=>{n?.(Y)},[n]);d.useImperativeHandle(r,()=>({handleKeyDown:Y=>{if(Y==="Escape"){s();return}const oe=fe.length+ie.length+E.length+ce.length;if(oe!==0){if(Y==="ArrowDown"){N(te=>(te+1)%oe);return}if(Y==="ArrowUp"){N(te=>(te-1+oe)%oe);return}if(Y==="Enter"||Y==="Tab"){const te=(k.current%oe+oe)%oe;if(te<fe.length){const Pe=fe[te];Pe&&ue(Pe.name);return}const pe=te-fe.length;if(pe<ie.length){const Pe=ie[pe];Pe&&ee(Pe);return}const He=pe-ie.length,je=He<E.length?E[He]:ce[He-E.length];je&&ee(je)}}}}),[ce,ie,E,fe,s,ee,ue]);const J=Y=>{switch(Y.extension?.toLowerCase()){case"ts":case"tsx":case"js":case"jsx":return i.jsx(z,{name:"code",className:"h-3.5 w-3.5 text-[var(--status-info)]"});case"json":return i.jsx(z,{name:"code",className:"h-3.5 w-3.5 text-[var(--status-warning)]"});case"md":case"mdx":return i.jsx(z,{name:"file",className:"h-3.5 w-3.5 text-muted-foreground"});case"png":case"jpg":case"jpeg":case"gif":case"svg":return i.jsx(z,{name:"file-image",className:"h-3.5 w-3.5 text-[var(--status-success)]"});default:return i.jsx(z,{name:"file-pdf",className:"h-3.5 w-3.5 text-muted-foreground"})}};return i.jsxs("div",{ref:G,className:"absolute z-[100] min-w-0 w-full max-w-[640px] max-h-64 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col",style:W!==void 0?{...o,maxHeight:W}:o,children:[i.jsx(vt,{preventOverscroll:!0,outerClassName:"flex-1 min-h-0",className:"px-0",children:w?i.jsx("div",{className:"flex items-center justify-center py-4",children:i.jsx(z,{name:"refresh",className:"h-4 w-4 animate-spin text-muted-foreground"})}):i.jsxs("div",{className:"pb-2",children:[fe.map((Y,oe)=>{const te=A===oe;return i.jsx("div",{ref:pe=>{O.current[oe]=pe},className:B("flex items-start gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg",te&&"bg-interactive-selection"),onClick:()=>ue(Y.name),onMouseMove:()=>N(oe),children:i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"font-semibold truncate",children:["@",Y.name]}),Y.description&&!K?i.jsx("div",{className:"typography-meta text-muted-foreground truncate",children:Y.description}):null]})},`agent-${Y.name}`)}),fe.length===2&&ge.length===0&&S.length>2&&i.jsx("div",{className:"px-3 py-1 typography-meta text-muted-foreground",children:"Type to search more agents"}),fe.length>0&&(ie.length>0||E.length>0||ce.length>0)&&i.jsx("div",{className:"my-1 border-t border-border/60"}),ie.map((Y,oe)=>{const te=fe.length+oe,pe=Y.relativePath||Y.name,He=tl(pe,{maxLength:60}),je=A===te;return i.jsxs("div",{ref:Pe=>{O.current[te]=Pe},className:B("flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg",je&&"bg-interactive-selection"),onClick:()=>ee(Y),onMouseMove:()=>N(te),children:[i.jsx(z,{name:"folder-3-fill",className:"h-3.5 w-3.5 text-primary/60"}),i.jsx("span",{className:"flex-1 min-w-0 truncate","aria-label":pe,children:He})]},`dir-${Y.path}`)}),ie.length>0&&(E.length>0||ce.length>0)&&i.jsx("div",{className:"my-1 border-t border-border/60"}),E.map((Y,oe)=>{const te=fe.length+ie.length+oe,pe=Y.relativePath||Y.name,He=tl(pe,{maxLength:60}),je=A===te,Pe=D[te]??!1,X=R[te]??2.6;return i.jsxs("div",{ref:me=>{O.current[te]=me},className:B("flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg",je&&"bg-interactive-selection"),onClick:()=>ee(Y),onMouseMove:()=>N(te),children:[J(Y),i.jsxs("span",{ref:me=>{I.current[te]=me},className:"relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container",style:je?{"--file-mention-marquee-width":`${V}px`,"--file-mention-marquee-duration":`${X}s`}:void 0,"aria-label":pe,children:[i.jsx("span",{ref:me=>{q.current[te]=me},className:"absolute invisible whitespace-nowrap pointer-events-none","aria-hidden":!0,children:pe}),Pe&&je?i.jsx("span",{className:"inline-block whitespace-nowrap file-mention-marquee",children:pe}):i.jsx("span",{className:"block truncate",children:He})]})]},`recent-${Y.path}`)}),E.length>0&&ce.length>0&&i.jsx("div",{className:"my-1 border-t border-border/60"}),ce.map((Y,oe)=>{const te=fe.length+ie.length+E.length+oe,pe=Y.relativePath||Y.name,He=tl(pe,{maxLength:60}),je=A===te,Pe=D[te]??!1,X=R[te]??2.6,me=i.jsxs("div",{ref:U=>{O.current[te]=U},className:B("flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg",je&&"bg-interactive-selection"),onClick:()=>ee(Y),onMouseMove:()=>N(te),children:[J(Y),i.jsxs("span",{ref:U=>{I.current[te]=U},className:"relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container",style:je?{"--file-mention-marquee-width":`${V}px`,"--file-mention-marquee-duration":`${X}s`}:void 0,"aria-label":pe,children:[i.jsx("span",{ref:U=>{q.current[te]=U},className:"absolute invisible whitespace-nowrap pointer-events-none","aria-hidden":!0,children:pe}),Pe&&je?i.jsx("span",{className:"inline-block whitespace-nowrap file-mention-marquee",children:pe}):i.jsx("span",{className:"block truncate",children:He})]})]});return i.jsx(d.Fragment,{children:me},Y.path)}),ce.length===0&&ie.length===0&&E.length===0&&fe.length===0&&i.jsx("div",{className:"px-3 py-2 typography-ui-label text-muted-foreground",children:"No matches found"})]})}),!K&&i.jsx("div",{className:"px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground",children:"↑↓ navigate • Enter select • Esc close"})]})}),Eh=d.forwardRef(({searchQuery:e,onSkillSelect:t,onClose:n,style:s},o)=>{const r=d.useRef(null),a=he(C=>C.isMobile),l=ua(r,a),[c,u]=d.useState(0),f=d.useRef(0),h=d.useRef(!1),[m,p]=d.useState([]),g=d.useRef([]),y=d.useRef(!1),M=d.useRef(null),b=d.useRef(!1),v=R2(C=>C.skills),x=R2(C=>C.loadSkills);d.useEffect(()=>{x()},[x]),d.useEffect(()=>{const C=e.trim(),_=[...C.length?v.filter(L=>e0(L.name,C)):v].sort((L,A)=>L.scope==="project"&&A.scope!=="project"?-1:L.scope!=="project"&&A.scope==="project"?1:L.name.localeCompare(A.name));p(_),u(0)},[v,e]),d.useEffect(()=>{f.current=c},[c]),d.useEffect(()=>{g.current[c]?.scrollIntoView({block:"nearest"})},[c]),d.useEffect(()=>{const C=w=>{const _=w.target;!_||!r.current||r.current.contains(_)||n()};return document.addEventListener("pointerdown",C,!0),()=>{document.removeEventListener("pointerdown",C,!0)}},[n]),d.useImperativeHandle(o,()=>({handleKeyDown:C=>{if(C==="Escape"){n();return}if(m.length){if(C==="ArrowDown"){h.current=!0,u(w=>(w+1)%m.length);return}if(C==="ArrowUp"){h.current=!0,u(w=>(w-1+m.length)%m.length);return}if(C==="Enter"||C==="Tab"){const w=(f.current%m.length+m.length)%m.length,_=m[w];_&&t(_.name)}}}}),[m,t,n]);const S=(C,w)=>{const _=C.scope==="project",L=C.source||"opencode";return i.jsx("div",{ref:A=>{g.current[w]=A},className:B("flex gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label",a?"items-center":"items-start",w===c&&"bg-interactive-selection"),onMouseDown:A=>A.preventDefault(),onPointerDown:A=>{A.pointerType==="touch"&&(M.current={x:A.clientX,y:A.clientY},b.current=!1)},onPointerMove:A=>{if(A.pointerType!=="touch"||!M.current)return;const N=A.clientX-M.current.x,k=A.clientY-M.current.y;Math.hypot(N,k)>6&&(b.current=!0)},onPointerUp:A=>{if(A.pointerType!=="touch")return;const N=b.current;M.current=null,b.current=!1,!N&&(A.preventDefault(),A.stopPropagation(),y.current=!0,t(C.name))},onPointerCancel:()=>{M.current=null,b.current=!1},onClick:()=>{if(y.current){y.current=!1;return}t(C.name)},onMouseMove:()=>{h.current=!1,u(w)},children:i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-semibold truncate",children:C.name}),i.jsx("span",{className:B("text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0 transition-colors",_?"bg-[var(--status-info-background)] text-[var(--status-info)] border-[var(--status-info-border)]":"bg-[var(--status-success-background)] text-[var(--status-success)] border-[var(--status-success-border)]"),children:C.scope}),i.jsx("span",{className:"text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0 bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60",children:L})]}),C.description&&!a&&i.jsx("div",{className:"typography-meta text-muted-foreground mt-0.5 truncate",children:C.description})]})},`${C.name}-${C.scope}`)};return i.jsxs("div",{ref:r,className:"absolute z-[100] min-w-0 w-full max-w-[450px] max-h-60 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col",style:l!==void 0?{...s,maxHeight:l}:s,children:[i.jsx(vt,{preventOverscroll:!0,outerClassName:"flex-1 min-h-0",className:"px-0 pb-2",children:m.length?i.jsx("div",{children:m.map((C,w)=>S(C,w))}):i.jsx("div",{className:"px-3 py-2 typography-ui-label text-muted-foreground",children:"No skills found"})}),!a&&i.jsx("div",{className:"px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground",children:"↑↓ navigate • Enter select • Esc close"})]})});Eh.displayName="SkillAutocomplete";function tI(e){return(e.description||e.content).replace(/\s+/g," ").trim().slice(0,120)}const zh=d.forwardRef(({searchQuery:e,onSnippetSelect:t,onClose:n,style:s},o)=>{const r=d.useRef(null),a=he(w=>w.isMobile),l=ua(r,a),[c,u]=d.useState(0),f=d.useRef(0),[h,m]=d.useState([]),p=d.useRef([]),g=L0(w=>w.snippets),y=L0(w=>w.loadSnippets),M=L0(w=>w.setSnippetDraft),b=L0(w=>w.setSelectedSnippet),v=he(w=>w.setSettingsDialogOpen),x=he(w=>w.setSettingsPage);d.useEffect(()=>{y()},[y]),d.useEffect(()=>{const w=e.trim(),L=[...w.length?g.filter(A=>e0(A.name,w)||A.aliases.some(N=>e0(N,w))):g].sort((A,N)=>A.source==="project"&&N.source!=="project"?-1:A.source!=="project"&&N.source==="project"?1:A.name.localeCompare(N.name));m(L),u(L.length?1:0)},[e,g]),d.useEffect(()=>{f.current=c,p.current[c]?.scrollIntoView({block:"nearest"})},[c]),d.useEffect(()=>{const w=_=>{const L=_.target;L&&r.current&&!r.current.contains(L)&&n()};return document.addEventListener("pointerdown",w,!0),()=>document.removeEventListener("pointerdown",w,!0)},[n]);const S=d.useCallback(w=>{const _=e.trim(),L=w.aliases.includes(_)?_:w.name;t(w,L)},[t,e]),C=d.useCallback(()=>{const w=new Set(g.map(A=>A.name));let _="new-snippet",L=1;for(;w.has(_);)_=`new-snippet-${L++}`;M({name:_,scope:"global"}),b(_),x("snippets"),v(!0),n()},[n,b,v,x,M,g]);return d.useImperativeHandle(o,()=>({handleKeyDown:w=>{if(w==="Escape"){n();return}const _=h.length+1;if(w==="ArrowDown"){u(L=>(L+1)%_);return}if(w==="ArrowUp"){u(L=>(L-1+_)%_);return}if(w==="Enter"||w==="Tab"){if(f.current===0){C();return}const L=h[f.current-1];L&&S(L)}}}),[S,h,n,C]),i.jsxs("div",{ref:r,className:"absolute z-[100] min-w-0 w-full max-w-[450px] max-h-60 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col",style:l!==void 0?{...s,maxHeight:l}:s,children:[i.jsxs(vt,{preventOverscroll:!0,outerClassName:"flex-1 min-h-0",className:"px-0 pb-2",children:[i.jsxs("div",{ref:w=>{p.current[0]=w},className:B("flex items-center gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label",c===0&&"bg-interactive-selection"),onClick:C,onMouseMove:()=>u(0),children:[i.jsx(z,{name:"add",className:"h-3.5 w-3.5 text-muted-foreground"}),i.jsx("span",{className:"font-medium text-foreground",children:"+ Add new snippet"})]}),h.length?h.map((w,_)=>i.jsx("div",{ref:L=>{p.current[_+1]=L},className:B("flex gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label",a?"items-center":"items-start",_+1===c&&"bg-interactive-selection"),onClick:()=>S(w),onMouseMove:()=>u(_+1),children:i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"font-semibold truncate",children:["#",w.name]}),i.jsx("span",{className:"text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0 bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60",children:w.source==="global"?"global":"project"})]}),!a&&i.jsx("div",{className:"typography-meta text-muted-foreground mt-0.5 truncate",children:tI(w)})]})},`${w.source}:${w.filePath}`)):i.jsx("div",{className:"px-3 py-2 typography-ui-label text-muted-foreground",children:"No snippets found"})]}),!a&&i.jsx("div",{className:"px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground",children:"↑↓ navigate • Enter select • Esc close"})]})});zh.displayName="SnippetAutocomplete";const nI={mention:520,command:450,snippet:450,skill:360};function sI(e,t){if(t)return{left:`${t.left}px`,top:`${t.top}px`,bottom:"auto",width:`min(${nI[e]}px, calc(100% - ${t.left+8}px))`,maxHeight:`${t.maxHeight}px`,transform:t.place==="above"?"translateY(-100%)":void 0}}function oI(e){const{open:t,query:n,overlayPosition:s,onClose:o}=e;if(!t)return null;const r=sI(t,s);switch(t){case"command":return i.jsx(Ph,{ref:e.commandRef,searchQuery:n,onCommandSelect:e.onCommandSelect,onClose:o,style:r});case"skill":return i.jsx(Eh,{ref:e.skillRef,searchQuery:n,onSkillSelect:e.onSkillSelect,onClose:o,style:r});case"snippet":return i.jsx(zh,{ref:e.snippetRef,searchQuery:n,onSnippetSelect:e.onSnippetSelect,onClose:o,style:r});case"mention":return i.jsx(eI,{ref:e.mentionRef,searchQuery:n,onFileSelect:e.onFileSelect,onAgentSelect:e.onAgentSelect,onClose:o,style:r})}}function Dh(e){return i.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",viewBox:"0 0 256 256",...e,children:[i.jsx("path",{d:"M208,56V200a8,8,0,0,1-8,8H56a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8H200A8,8,0,0,1,208,56Z",opacity:"0.2"}),i.jsx("path",{d:"M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,160H56V56H200V200Z"})]})}const rI=d.memo(function(t){const{isMobile:n,footerIconButtonClass:s,sendIconSizeClass:o,stopIconSizeClass:r,canSend:a,canAbort:l,hasContent:c,currentSessionId:u,newSessionDraftOpen:f,onPrimaryAction:h,onQueueMessage:m,onAbort:p}=t,g=i.jsx("button",{type:n?"button":"submit",disabled:!a||!u&&!f,onClick:y=>{n&&(y.preventDefault(),h())},className:B(s,a&&(u||f)?"text-primary hover:text-primary":"opacity-30"),"aria-label":"Send message",children:i.jsx(z,{name:"send-plane-2",className:B(o)})});return l?i.jsxs("div",{className:"relative",children:[c?i.jsx("button",{type:"button",disabled:!u,onClick:y=>{n&&y.preventDefault(),m()},className:B(s,"absolute z-20 bottom-full left-1/2 -translate-x-1/2 mb-1",u?"text-primary hover:text-primary":"opacity-30"),"aria-label":"Queue message",children:i.jsx(z,{name:"send-plane-2",className:B(o,"-rotate-90")})}):null,i.jsx("button",{type:"button",onClick:p,className:B(s,"text-[var(--status-error)] hover:text-[var(--status-error)]"),"aria-label":"Stop generating",children:i.jsx(Dh,{className:B(r)})})]}):g},(e,t)=>e.isMobile===t.isMobile&&e.footerIconButtonClass===t.footerIconButtonClass&&e.sendIconSizeClass===t.sendIconSizeClass&&e.stopIconSizeClass===t.stopIconSizeClass&&e.canSend===t.canSend&&e.canAbort===t.canAbort&&e.hasContent===t.hasContent&&e.currentSessionId===t.currentSessionId&&e.newSessionDraftOpen===t.newSessionDraftOpen&&e.onPrimaryAction===t.onPrimaryAction&&e.onQueueMessage===t.onQueueMessage&&e.onAbort===t.onAbort),Rh=d.memo(function(t){const{footerIconButtonClass:n,iconSizeClass:s,handlePickLocalFiles:o,openIssuePicker:r,openPrPicker:a,onOpenSettings:l,hideAddButton:c=!1}=t;return c&&!l?null:i.jsxs("div",{className:"flex items-center gap-x-1.5",children:[c?null:i.jsx("div",{className:"relative inline-flex",children:t.onOpenMobileSheet?i.jsx("button",{type:"button",className:n,onClick:t.onOpenMobileSheet,onMouseDown:u=>u.preventDefault(),onPointerDownCapture:u=>{u.pointerType==="touch"&&u.preventDefault()},title:"Add attachment","aria-label":"Add attachment",children:i.jsx(z,{name:"add-circle",className:B(s,"text-current")})}):i.jsxs($3,{onOpenChange:t.onMenuOpenChange,children:[i.jsx(q3,{asChild:!0,children:i.jsx("button",{type:"button",className:n,title:"Add attachment","aria-label":"Add attachment",children:i.jsx(z,{name:"add-circle",className:B(s,"text-current")})})}),i.jsxs(U3,{align:"start",children:[i.jsxs(ul,{onSelect:()=>{requestAnimationFrame(o)},children:[i.jsx(z,{name:"attachment-2"}),"Attach files"]}),i.jsxs(ul,{onSelect:()=>{requestAnimationFrame(r)},children:[i.jsx(z,{name:"github"}),"Link GitHub Issue"]}),i.jsxs(ul,{onSelect:()=>{requestAnimationFrame(a)},children:[i.jsx(z,{name:"git-pull-request"}),"Link GitHub PR"]})]})]})}),l?i.jsx("button",{type:"button",onClick:l,className:n,title:"Model and agent settings","aria-label":"Model and agent settings",children:i.jsx(z,{name:"ai-agent",className:B(s,"text-current")})}):null]})},(e,t)=>e.footerIconButtonClass===t.footerIconButtonClass&&e.iconSizeClass===t.iconSizeClass&&e.onOpenSettings===t.onOpenSettings&&e.onMenuOpenChange===t.onMenuOpenChange&&e.onOpenMobileSheet===t.onOpenMobileSheet&&e.hideAddButton===t.hideAddButton);function iI(e){const{isMobile:t,isInline:n,alignToolsEnd:s,sessionId:o,newSessionDraftOpen:r,children:a,leadingExtra:l,footerPaddingClass:c,footerGapClass:u,footerIconButtonClass:f,iconSizeClass:h,sendIconSizeClass:m,stopIconSizeClass:p,canSend:g,canAbort:y,hasContent:M,onOpenSettings:b,onPickLocalFiles:v,onOpenIssuePicker:x,onOpenPrPicker:S,onOpenAttachSheet:C,onPrimaryAction:w,onQueueMessage:_,onAbort:L}=e,A=i.jsx(Rh,{footerIconButtonClass:f,iconSizeClass:h,handlePickLocalFiles:v,openIssuePicker:x,openPrPicker:S,onOpenSettings:b,onOpenMobileSheet:t?C:void 0,hideAddButton:t}),N=i.jsx(rI,{isMobile:t,footerIconButtonClass:f,sendIconSizeClass:m,stopIconSizeClass:p,canSend:g,canAbort:y,hasContent:M,currentSessionId:o,newSessionDraftOpen:r,onPrimaryAction:w,onQueueMessage:_,onAbort:L});if(t)return i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-transparent",children:[i.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:a}),i.jsx("div",{className:B("flex-shrink-0",c,"flex items-center gap-x-1.5"),"data-chat-input-footer":"true",children:i.jsxs("div",{className:"flex w-full items-center justify-between gap-x-1.5",children:[i.jsxs("div",{className:"composer-mobile-actions flex min-w-0 items-center gap-x-2 overflow-x-auto pl-1","data-no-drawer-swipe":"true",children:[A,l?i.jsx("div",{className:"w-max shrink-0",children:l}):null]}),i.jsx("div",{className:"flex min-w-0 shrink-0 items-center justify-end gap-x-1",children:N})]})})]});if(n){const k=s?"self-end":"self-center";return i.jsxs("div",{className:B("grid grid-cols-[auto_minmax(0,1fr)_auto] bg-transparent",c,u),"data-chat-input-footer":"true",children:[i.jsx("div",{className:B("flex min-w-0 items-center",u,k),children:A}),i.jsx("div",{className:"min-w-0",children:a}),i.jsx("div",{className:B("flex min-w-0 items-center justify-end",u,k),children:N})]})}return i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-transparent",children:[i.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:a}),i.jsxs("div",{className:B("flex flex-shrink-0 items-center justify-between",c,u),"data-chat-input-footer":"true",children:[i.jsxs("div",{className:B("flex min-w-0 items-center",u),children:[A,l?i.jsx("div",{className:"w-max min-w-0 shrink-0",children:l}):null]}),i.jsx("div",{className:B("flex flex-shrink-0 items-center",u),children:N})]})]})}function aI(e){const{message:t,sessionId:n,newSessionDraftOpen:s,canAbort:o,footerIconButtonClass:r,iconSizeClass:a,stopIconSizeClass:l,theme:c,onExpand:u,onNewSession:f,onPickLocalFiles:h,onOpenIssuePicker:m,onOpenPrPicker:p,onOpenAttachSheet:g,onAbort:y}=e;return i.jsx("div",{className:"flex flex-col",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("div",{className:"flex h-11 min-w-0 flex-1 items-center gap-x-0.5 rounded-full border border-border/80 pl-2 pr-1 shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]",style:{backgroundColor:c?.colors?.surface?.subtle},children:[i.jsx(Rh,{footerIconButtonClass:r,iconSizeClass:a,handlePickLocalFiles:h,openIssuePicker:m,openPrPicker:p,onOpenMobileSheet:g}),i.jsx("button",{type:"button",className:"flex h-full min-w-0 flex-1 cursor-text items-center px-1.5 text-left",onClick:u,children:i.jsx("span",{className:B("truncate typography-ui-label",t.trim()?"text-foreground":"text-muted-foreground"),children:t.trim()?t:n||s?"Use @ / ! # for helpers":"Select or create a session to start chatting"})}),o?i.jsx("button",{type:"button",className:B(r,"text-[var(--status-error)] hover:text-[var(--status-error)]"),onMouseDown:M=>M.preventDefault(),onPointerDownCapture:M=>{M.pointerType==="touch"&&M.preventDefault()},onClick:M=>{M.stopPropagation(),y()},title:"Stop generating","aria-label":"Stop generating",children:i.jsx(Dh,{className:B(l)})}):null]}),i.jsx("div",{className:B("flex-shrink-0 transition-all duration-200 ease-out",s?"w-0 opacity-0 overflow-hidden":"w-11 opacity-100"),children:i.jsx("button",{type:"button",className:"flex h-11 w-11 cursor-pointer items-center justify-center rounded-full border border-border/80 text-foreground shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]",style:{backgroundColor:c?.colors?.surface?.subtle},onClick:f,disabled:s,title:"New chat","aria-label":"New chat",children:i.jsx(z,{name:"add",className:"h-5 w-5 text-current"})})})]})})}function vs(e){return i.jsxs("div",{className:"inline-flex items-center gap-1.5 rounded-xl border px-2.5 py-1",style:{backgroundColor:e.colors?.surface?.elevated,borderColor:e.colors?.interactive?.border},children:[e.icon,i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:e.label}),i.jsx("span",{className:"text-xs font-semibold",style:{color:e.colors?.status?.info},children:e.count}),i.jsx("button",{type:"button",className:"ml-1 inline-flex h-4 w-4 items-center justify-center rounded-full text-muted-foreground hover:bg-interactive-hover hover:text-foreground",style:{minHeight:0,minWidth:0},onClick:e.onRemove,"aria-label":e.removeLabel,title:e.removeLabel,children:i.jsx(z,{name:"close",className:"h-3 w-3"})})]})}function lI(e){const{terminalDrafts:t,reviewCount:n,prCommentCount:s,prCheckCount:o,previewConsoleCount:r,previewAnnotationCount:a,draftTarget:l,onRemoveDraft:c,onRemoveReviewDrafts:u,onRemovePreviewDrafts:f,colors:h}=e;return i.jsxs("div",{className:"flex flex-wrap items-center gap-2 pb-2",children:[t.map(m=>i.jsxs("div",{className:"inline-flex max-w-full items-center gap-1.5 rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2.5 py-1",title:m.code,children:[i.jsx(z,{name:"terminal",className:"h-3.5 w-3.5"}),i.jsx("span",{className:"truncate text-xs font-medium text-[var(--surface-mutedForeground)]",children:`${m.fileLabel}, lines ${m.startLine}-${m.endLine}`}),i.jsx("button",{type:"button",className:"ml-1 inline-flex h-4 w-4 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]",onClick:()=>l&&m.id&&c(l,m.id),"aria-label":"Remove terminal context",title:"Remove terminal context",children:i.jsx(z,{name:"close",className:"h-3 w-3"})})]},m.id)),n>0?i.jsx(vs,{label:"Review comments:",count:n,removeLabel:"Remove review comments",onRemove:u,colors:h}):null,s>0?i.jsx(vs,{label:"PR comments",count:s,removeLabel:"Remove PR comments context",onRemove:()=>f("pr-comment"),colors:h,icon:i.jsx(z,{name:"git-pull-request",className:"h-3.5 w-3.5 text-muted-foreground"})}):null,o>0?i.jsx(vs,{label:"Failed PR checks",count:o,removeLabel:"Remove PR checks context",onRemove:()=>f("pr-check"),colors:h,icon:i.jsx(z,{name:"close-circle",className:"h-3.5 w-3.5 text-[var(--status-error)]"})}):null,r>0?i.jsx(vs,{label:"Dev Server logs:",count:r,removeLabel:"Remove Dev Server logs",onRemove:()=>f("preview-console"),colors:h}):null,a>0?i.jsx(vs,{label:"Preview annotations:",count:a,removeLabel:"Remove preview context",onRemove:()=>f("preview-annotation"),colors:h}):null]})}function p7(e){const{numberLabel:t,title:n,url:s,author:o,branches:r,openInBrowserLabel:a,removeLabel:l,onReopenPicker:c,onRemove:u}=e;return i.jsx("div",{className:"pb-2 w-full px-1",children:i.jsxs("div",{className:"flex w-full items-center gap-1.5 text-sm h-5 px-1",children:[i.jsxs("button",{type:"button",onClick:c,className:"flex min-w-0 flex-1 items-center gap-1.5 text-left hover:opacity-80 transition-opacity",children:[o?.avatarUrl?i.jsx("img",{src:o.avatarUrl,alt:o.login,className:"h-5 w-5 rounded-full flex-shrink-0"}):null,i.jsxs("span",{className:"text-muted-foreground flex-shrink-0",children:[t,o?i.jsx("span",{className:"ml-1",children:`by ${o.login}`}):null]}),i.jsx("span",{className:"text-foreground truncate",children:n}),r?i.jsxs("span",{className:"text-muted-foreground flex-shrink-0 typography-meta",children:[r.head," → ",r.base]}):null]}),i.jsxs("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[i.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center h-6 w-6 hover:bg-[var(--interactive-hover)] rounded-full transition-colors","aria-label":a,children:i.jsx(z,{name:"external-link",className:"h-4 w-4 text-muted-foreground"})}),i.jsx("button",{type:"button",onClick:u,className:"flex items-center justify-center h-6 w-6 hover:bg-[var(--interactive-hover)] rounded-full transition-colors","aria-label":l,title:l,children:i.jsx(z,{name:"close",className:"h-4 w-4 text-muted-foreground"})})]})]})})}const Oh=d.memo(({sessionId:e})=>{const t=Be(v=>v.restoreToMessage),n=Be(v=>v.forkFromMessage),s=Be(v=>v.handleSlashRedo),[o,r]=d.useState(null),[a,l]=d.useState(null),[c,u]=d.useState(!0),f=tu(e),h=f?.targetEntryId,m=d.useMemo(()=>f?f.abandoned.filter(v=>v.role==="user"):[],[f]),p="No text content",g=d.useMemo(()=>!f||m.length===0?[]:m.map(v=>({id:v.id,text:v.preview?.replace(/\s+/g," ").trim()||p})),[m,f,p]),y=g[0]?.id;d.useEffect(()=>{u(!0)},[h,y]);const M=d.useCallback(async v=>{if(!(!e||o)){r(v);try{const x=m.findIndex(C=>C.id===v),S=x>=0?m[x+1]:void 0;S?(await t(e,S.id),Ue.success("Restored messages through this point")):await s(e)}catch(x){Ue.error(x instanceof Error?x.message:"Failed to restore messages")}finally{r(null)}}},[m,s,t,o,e]),b=d.useCallback(async v=>{if(!(!e||a)){l(v);try{await n(e,v)}catch(x){Ue.error(x instanceof Error?x.message:"Failed to fork session")}finally{l(null)}}},[n,a,e]);return!e||g.length===0?null:i.jsx("div",{className:"pb-2 w-full px-1",children:i.jsxs("div",{className:"rounded-xl border border-border/60 bg-[var(--surface-elevated)] text-[var(--surface-elevated-foreground)] shadow-sm overflow-hidden",children:[i.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-[var(--interactive-hover)] transition-colors",onClick:()=>u(v=>!v),"aria-expanded":!c,children:[i.jsxs("span",{className:"typography-ui-label font-medium text-foreground flex-shrink-0",children:["Reverted"," messages ",g.length]}),i.jsx(z,{name:"arrow-down-s",className:B("ml-auto h-4 w-4 text-muted-foreground transition-transform",!c&&"rotate-180"),"aria-hidden":"true"})]}),!c&&i.jsx("div",{className:"px-3 pb-3 flex flex-col gap-1.5 max-h-[10.5rem] overflow-y-auto",children:g.map(v=>i.jsxs("div",{className:"flex min-w-0 items-center gap-2 py-1",children:[i.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:v.text}),i.jsxs(a1,{type:"button",variant:"secondary",size:"xs",disabled:!!(o||a),onClick:()=>{b(v.id)},children:[a===v.id?i.jsx(z,{name:"loader-4",className:"h-3 w-3 animate-spin","aria-hidden":"true"}):i.jsx(z,{name:"git-branch",className:"h-3 w-3","aria-hidden":"true"}),"Fork"]}),i.jsxs(a1,{type:"button",variant:"secondary",size:"xs",disabled:!!(o||a),onClick:()=>{M(v.id)},children:[o===v.id?i.jsx(z,{name:"loader-4",className:"h-3 w-3 animate-spin","aria-hidden":"true"}):i.jsx(z,{name:"arrow-go-forward",className:"h-3 w-3","aria-hidden":"true"}),"Restore"]})]},v.id))})]})})});Oh.displayName="RevertedMessageDock";const cI=bo(()=>V2(()=>import("./ToolOutputDialog-b_R4tAZu.js"),__vite__mapDeps([110,1,2,111,112,113,25,114,26,27,28,29,30,31,32,33,34,35,36,37,38,39,115,23,24,116,117,118,119,120,121,122,123,124,125,126,127,128,13,6,14,129,22,103,104,40,41,42,43,44,45,46,15,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,105,106,107,7,108,109]))),dI=5,uI=16,fI=4,g7=[],y7=[],hI=560,mI=(e,t)=>e.name===t?e:new File([e],t,{type:e.type,lastModified:e.lastModified}),v7=e=>e.includes("@")?"paste":"manual",pI=(e,t)=>{if(t.size===0)return[];const n=new Set,s=new Map;for(const c of t){const u=c.toLowerCase();n.add(u),s.has(u)||s.set(u,c)}const r=yL(e,"/",n,"case-insensitive").map(c=>s.get(c.toLowerCase())??c),a=new Set,l=[];for(const c of r){const u=c.toLowerCase();a.has(u)||(a.add(u),l.push(c))}return l},gI=e=>e.length===0?null:`The user explicitly mentioned these skills in their message: ${e.map(n=>`/${n}`).join(", ")}. Use the corresponding skill tool when it is relevant to accomplishing the user's request.`,yI=(e,t)=>Is().some(n=>n.role==="user"),b7=d.memo(Uk),vI=d.memo(Rf),bI=e=>{const t=Be.getState(),n=t.newSessionDraft?.open?t.newSessionDraft.bootstrapPendingDirectory??t.newSessionDraft.directoryOverride:null,s=e?t.getDirectoryForSession(e)??t.currentSessionDirectory:n??w1.getState().currentDirectory;return Af(We(),s,e)},Zh=({onOpenSettings:e,scrollToBottom:t})=>{const n=d.useRef(null),s=d.useRef(null),o=d.useRef({text:"",confirmedMentions:new Set}),[r,a]=d.useState(()=>{const j=Be.getState().currentSessionId,_e=bI(j),De=Lf(_e);return s.current=_e,o.current=De,De.text&&(n.current=De.text),De.text}),l=d.useRef(o.current.confirmedMentions),[c,u]=d.useState("normal"),[f,h]=d.useState(!1),[m,p]=d.useState(!1),[g,y]=d.useState(null),[M,b]=d.useState(""),v=d.useCallback(()=>y(null),[]),[x,S]=d.useState(null),[C,w]=d.useState(!1),[_,L]=d.useState(null),[A,N]=d.useState(""),k=d.useRef(null),V=d.useRef(cj()).current;d.useEffect(()=>()=>{V.view?.destroy(),V.view=null},[V]);const H=d.useRef(null),D=d.useRef(0),P=d.useRef(null),R=d.useRef(0),$=d.useRef(!1),O=d.useRef(null),I=d.useRef(!1),q=d.useRef(null),G=d.useRef(null),K=d.useRef(null),W=d.useRef(null),ge=d.useRef(r),Z=d.useRef(s.current),fe=d.useRef(new Set),ie=d.useRef((...j)=>Promise.resolve(Be.getState().sendMessage(...j))).current,E=Be(j=>j.currentSessionId),ce=w1(j=>j.currentDirectory),ee=bt()??ce,ue=Be(d.useCallback(j=>E?j.getDirectoryForSession(E):null,[E])),J=We();d.useEffect(()=>(d4(),R2.getState().loadSkills(),Wn(()=>{d4(),R2.getState().loadSkills()})),[ee]);const Y=d.useMemo(()=>Af(J,ue??ee,E),[J,ee,ue,E]),oe=Be(j=>j.newSessionDraft),te=!!oe?.open,pe=Be(j=>j.setNewSessionDraftTarget),He=Be(j=>j.openNewSessionDraft),je=Be(j=>j.abortPromptSessionId),Pe=Be(j=>j.clearAbortPrompt),X=R1(j=>j.attachedFiles),me=R1(j=>j.addAttachedFile),U=R1(j=>j.clearAttachedFiles),T=R1(j=>j.consumePendingInputText),Q=R1(j=>j.pendingPresetSubmit),se=R1(j=>j.pendingInputText),ye=R1(j=>j.pendingRevertText),le=R1(j=>j.consumePendingRevertText),ne=R1(j=>j.consumePendingSyntheticParts),Ce=Be(j=>j.acknowledgeSessionAbort),Se=d.useCallback(j=>qu(j??E??""),[E]),Ae=$e(j=>j.currentProviderId),Ve=$e(j=>j.currentModelId),Me=$e(j=>j.getModelMetadata);$e(j=>j.modelsMetadata),$e(j=>j.providers);const Ie=Ae&&Ve?Me(Ae,Ve):void 0,qe=$e(j=>j.currentVariant),n1=$e(j=>j.currentAgentName);$e(j=>j.setAgent);const Le=$e(j=>j.getVisibleAgents)(),xe=he(j=>j.isMobile),Te=ta()==="mini-chat",Qe=qA(),{enabled:M1}=Kn(),C1=xe&&!M1,_1=he(j=>j.setImagePreviewOpen),m2=he(j=>j.inputBarOffset),at=he(j=>j.persistChatDraft),F1=he(j=>j.inputSpellcheckEnabled),re=he(j=>j.isExpandedInput),Ne=he(j=>j.setExpandedInput),Oe=he(j=>j.setTimelineDialogOpen),{git:Ke}=ra(),{currentTheme:c1}=Nt(),u1=gh(),v1=Qi(ee),L1=h2(j=>ee?j.directories.get(ee)?.status??null:null),s2=h2(j=>j.ensureStatus),K1=h2(j=>j.fetchStatus),I2=h2(j=>j.clearDiffCache),[ke,e1]=d.useState(!1),[Re,f1]=d.useState(!1),[Y1,C2]=d.useState({open:!1,title:"",content:""}),[S2,K2]=d.useState(!1);d.useEffect(()=>{Y1.open&&K2(!0)},[Y1.open]);const O1=d.useRef({modelKey:`${Ae??""}/${Ve??""}`,modalitySignature:Ie?.modalities?.input?.slice().sort().join(",")??null,attachmentIds:new Set});d.useEffect(()=>{const j=`${Ae??""}/${Ve??""}`,_e=Ie?.modalities?.input,De=_e?.slice().sort().join(",")??null,s1=O1.current,t1=s1.modelKey!==j,o1=s1.modalitySignature===null&&De!==null,r1=t1||o1?X:X.filter(p1=>!s1.attachmentIds.has(p1.id));if(O1.current={modelKey:j,modalitySignature:De,attachmentIds:new Set(X.map(p1=>p1.id))},!_e||r1.length===0)return;const g1=vM(r1,_e);if(g1.length===0)return;const k1=Array.from(new Set(g1.map(({modality:p1})=>p1))),P2={text:"Text",image:"Image",pdf:"PDF",audio:"Audio",video:"Video"},y2=g1.map(({attachment:p1})=>p1.filename),r2=y2.length>3?`${y2.slice(0,3).join(", ")} (+${y2.length-3})`:y2.join(", ");Ue.warning(`${Ie.name??Ve??""} does not support ${k1.map(p1=>P2[p1]).join(", ")} input required by ${r2}. You can still send the message, but these attachments may be ignored.`,{id:`attachment-modalities:${j}`})},[X,Ve,Ie,Ae]);const g2=d.useCallback(j=>{j.image&&(C2(j),_1(!0))},[_1]),e2=d.useCallback(j=>{C2(_e=>({..._e,open:j})),_1(j)},[_1]);d.useEffect(()=>{!ee||!Ke||s2(ee,Ke)},[ee,Ke,s2]),d.useEffect(()=>{if(!(!ee||!Ke))return yh.onGitRefreshHint(j=>{qt(j.directory)===qt(ee)&&(j.paths?.length&&I2(ee,j.paths),K1(ee,Ke,{silent:!0}))})},[I2,ee,Ke,K1]);const Y2=!1,J2=re&&xe,o2=J2,[B2,lt]=d.useState(1),d2=!xe&&!Te,_2=!!(te&&d2&&!o2),be=!xe&&!o2&&!d2,Ge=xe||d2?"1.5rem":"9999px",b1=xe||Re;d.useEffect(()=>{const j=P.current;if(!j)return;const _e=s1=>{const t1=s1>0&&s1<hI;f1(o1=>o1===t1?o1:t1)};if(_e(j.clientWidth),typeof ResizeObserver>"u"){const s1=()=>_e(j.clientWidth);return window.addEventListener("resize",s1),()=>window.removeEventListener("resize",s1)}const De=new ResizeObserver(s1=>{_e(s1[0]?.contentRect.width??j.clientWidth)});return De.observe(j),()=>De.disconnect()},[]);const d1=d.useMemo(()=>new Set(Le.map(j=>j.name.toLowerCase())),[Le]),Ye=d.useRef(d1);Ye.current=d1;const a2=R2(j=>j.skills),k2=d.useMemo(()=>{const j=new Set(["init","review","undo","redo","timeline","compact","summary","plan-feature","catch-up","debug","weigh","explore"]);for(const _e of a2)j.add(_e.name.toLowerCase());return j},[a2]),X2=L0(j=>j.snippets),f0=d.useMemo(()=>{const j=new Set;for(const _e of X2){j.add(_e.name.toLowerCase());for(const De of _e.aliases??[])j.add(De.toLowerCase())}return j},[X2]),h0=d.useMemo(()=>X.map(j=>j.filename),[X]),m0=d.useMemo(()=>({inputMode:c,knownAgentNames:d1,confirmedMentions:l.current,knownSlashNames:k2,knownSnippetTriggers:f0,attachmentFilenames:h0}),[h0,c,d1,k2,f0]),Xn=d.useCallback(j=>[...j??[]].map(_e=>({..._e,dataUrl:_e.source==="server"&&_e.serverPath?gj(_e.serverPath):_e.dataUrl})),[]),pa=d.useCallback(j=>({sanitizedText:j,attachments:[]}),[]),ct=d.useRef(null),ko=d.useRef(!1),[Ao,Qn]=d.useState(!1),[Ho,F]=d.useState(!1),[we,ze]=d.useState(null),[Ze,x1]=d.useState(null),I1=E?m9(E,ue??ee):null,A2=I1?Ur(I1):null,Fe=j2(j=>j.followUpBehavior),Xe=j2(d.useCallback(j=>A2?j.queuedMessages[A2]??g7:g7,[A2])),h1=j2(j=>j.addToQueue),$1=j2(j=>j.clearQueue),P1=j2(j=>j.removeFromQueue),E1=E??(te?"draft":""),u2=ue??ee,z1=d.useMemo(()=>E1&&u2?{directory:u2,sessionKey:E1}:null,[u2,E1]),f2=z1?o_(J,z1.directory,z1.sessionKey):null,p0=Rt(d.useCallback(j=>f2?(j.drafts[f2]??[]).length:0,[f2])),xt=Rt(d.useCallback(j=>{const _e=f2?j.drafts[f2]??[]:[];let De=0,s1=0,t1=0,o1=0,r1=0,g1=0;for(const k1 of _e)k1.source==="preview-console"?De+=1:k1.source==="preview-annotation"?s1+=1:k1.source==="terminal"?o1+=1:k1.source==="pr-comment"?r1+=1:k1.source==="pr-check"?g1+=1:t1+=1;return`${De}:${s1}:${t1}:${o1}:${r1}:${g1}`},[f2])),dt=Rt(j=>j.consumeDrafts),wt=Rt(j=>j.removeDraft),g0=p0>0,[W0,ga,ya,K0,Y0,J1]=xt.split(":").map(j=>Number(j)||0),Mt=K0>0?(f2?Rt.getState().drafts[f2]??[]:[]).filter(j=>j.source==="terminal"):[],ut=d.useCallback(j=>{if(!z1)return;const _e=Rt.getState().getDrafts(z1);for(const De of _e)De.source===j&&wt(z1,De.id)},[z1,wt]),Cp=d.useCallback(()=>{if(!z1)return;const j=Rt.getState().getDrafts(z1);for(const _e of j)_e.source!=="preview-console"&&_e.source!=="preview-annotation"&&_e.source!=="terminal"&&_e.source!=="pr-comment"&&_e.source!=="pr-check"&&wt(z1,_e.id)},[z1,wt]),va=Pj(Gw(E??""));d.useEffect(()=>{ge.current=r},[r]),d.useEffect(()=>{Z.current=Y},[Y]);const{persistNow:Sp}=zj({message:r,messageRef:ge,setMessage:a,confirmedMentionsRef:l,identity:Y,persistEnabled:at,initialDraft:{text:n.current??"",identity:s.current},onIdentityChange:()=>u("normal"),onDraftRestored:()=>k.current?.selectAll()}),P5=d.useRef(te);d.useEffect(()=>{!P5.current&&te&&requestAnimationFrame(()=>{xe?k.current?.focus({preventScroll:!0}):k.current?.focus()}),P5.current=te},[te,xe]);const{phase:es}=s5();d.useEffect(()=>{if(se!==null){const j=T();j?.text&&(j.mode==="append"?a(_e=>{const De=j.text;return De.trim()?dj(_e,De):_e}):j.mode==="append-inline"?a(_e=>o7(_e,j.text)):a(j.text),setTimeout(()=>{k.current?.focus()},0))}},[se,T]),d.useEffect(()=>{if(ye!==null){const j=le();j&&r.trim().length===0&&(a(j),setTimeout(()=>{k.current?.focus()},0))}},[ye,le,r]);const ba=r.trim().length>0||X.length>0||g0,xa=Xe.length>0,_p=(ba||xa)&&!!(Ae&&Ve),E5=es!=="idle",ts=d.useCallback(()=>{const j=k.current?.getValue()??r;return{message:j,hasContent:j.trim().length>0||X.length>0||g0}},[X.length,g0,r]),ns=d.useRef(async()=>{}),ss=d.useCallback(()=>{const j=ts();if(!j.hasContent||!E||!I1)return;const _e=z1?dt(z1):[];let De=j.message.replace(/^\n+|\n+$/g,"");_e.length>0&&(De=s8(De,_e));const s1=Xn(X);h1(I1,{content:De,attachments:s1.length>0?s1:void 0,sendConfig:Ae&&Ve?{providerID:Ae,modelID:Ve,agent:n1??void 0,variant:qe??void 0}:void 0}),a(""),s1.length>0&&U(),xe||k.current?.focus()},[ts,E,I1,z1,X,Xn,h1,U,xe,dt,Ae,Ve,n1,qe]),kp=d.useCallback(j=>{a(j),setTimeout(()=>{k.current?.focus()},0)},[]),Ap=d.useCallback(j=>{ns.current({queuedOnly:!0,queuedMessageId:j,delivery:"steer"})},[]),wa=d.useCallback(()=>{Qn(!0)},[]),Ma=d.useCallback(()=>{F(!0)},[]),z5=(j,_e)=>{const De=j instanceof Error?j.message:"";return De.toLowerCase().includes("runtime changed")?"Message failed to send. Attachments restored.":De||_e},Lo=async j=>{const _e=j?.queuedOnly??!1,De=j?.queuedMessageId,s1=j?.delivery==="steer"&&es!=="idle"?"steer":void 0,t1=I1,o1=j?.presetText!=null?{message:j.presetText,hasContent:j.presetText.trim().length>0||X.length>0||g0}:ts(),r1=I1?j2.getState().sendingIds[Ur(I1)]??y7:y7,g1=(De?Xe.filter(l1=>l1.id===De):Xe).filter(l1=>!r1.includes(l1.id));if(_e){if(g1.length===0||!E)return}else if(!o1.hasContent&&!xa||!E&&!te)return;const k1=_e?g1[0]?.sendConfig:void 0,P2=k1?.providerID??Ae,y2=k1?.modelID??Ve,r2=k1?.agent??n1,p1=k1?.variant??qe;if(!P2||!y2){console.warn("Cannot send message: provider or model not selected"),Ue.error("Select a provider and model before sending a message.");return}if(E&&!_e){const[l1,t2]=await Promise.all([fM(),hM()]);if(l1||t2){ss();return}}const B1=t1?{target:t1,...s1?{delivery:s1}:{}}:s1?{delivery:s1}:void 0,O2=ne(),Ct=_e?null:z1,St=Ct?dt(Ct):[],rs=new Set(R2.getState().skills.map(l1=>l1.name)),X0=_j({queued:g1,composerText:!_e&&o1.hasContent?o1.message:null,composerAttachments:X,inlineComments:St,syntheticTexts:O2?.map(l1=>l1.text)??[],linkedIssueContext:we?.contextText??null,linkedPr:Ze?{instructions:Ze.instructionsText,context:Ze.contextText}:null},{parseAgentMention:l1=>{const{sanitizedText:t2,mention:A1}=Df(l1,Le);return{text:t2,agentName:A1?.name}},extractFileMentions:l1=>{const{sanitizedText:t2,attachments:A1}=pa(l1);return{text:t2,attachments:A1}},sanitizeAttachments:Xn,collectSkillNames:l1=>pI(l1,rs),appendComments:(l1,t2)=>s8(l1,t2),buildSkillInstruction:gI});let Et=X0.primaryText;const{primaryAttachments:rc,additionalParts:is,agentMentionName:ic}=X0;if(X0.isEmpty)return;t1&&De?P1(t1,De):t1&&xa&&$1(t1),_e||(a(""),l.current.clear(),Sp(Y,""),va.reset(),X.length>0&&U(),Ne(!1)),xe&&k.current?.blur();const ac=c==="normal"?Lj(Et):null;if(ac){const{name:l1,argument:t2}=ac;if(l1==="undo"&&E){await Be.getState().handleSlashUndo(E),t?.();return}if(l1==="redo"&&E){await Be.getState().handleSlashRedo(E),t?.();return}if(l1==="timeline"&&E){Oe(!0);return}if(l1==="compact"&&E){try{await S6(),await i1.compactSession({sessionId:E})}catch(en){Ue.error(z5(en,"Failed to compact session"))}return}const A1=jj(l1),Q0=A1!==null&&Ij(A1,{hasSession:!!E,hasDraft:te});if(A1&&Q0){const en=Bj(A1,t2);try{await S6();const Ha=await R0(A1.visiblePrompt,en.visible),Yp=await R0(A1.instructionsPrompt,en.instructions);await ie(Ha,P2,y2,r2,[],ic,[{text:Yp,synthetic:!0}],p1,c,B1),t?.()}catch(Ha){Ue.error(z5(Ha,A1.errorToastKey))}return}}if(t1?.directory,te||(E?!yI():!1)){const l1=await ZH().catch(()=>null);l1&&is.push({text:FH(l1),synthetic:!0})}if(c!=="shell")try{const l1=L0.getState().expandText;Et=await l1(Et);for(const t2 of is)t2.synthetic||(t2.text=await l1(t2.text))}catch(l1){console.warn("[ChatInput] Failed to expand snippets, sending original text:",l1)}const zt=[...rc,...is.flatMap(l1=>l1.attachments??[])],Wp=ie(Et,P2,y2,r2,rc,ic,is.length>0?is:void 0,p1,c,B1),Kp=()=>{Ct&&St.length>0&&Rt.getState().restoreDrafts(Ct,St)};typeof window>"u"?t?.():window.requestAnimationFrame(()=>{t?.()}),Wp.then(()=>{const l1=we?{attachment:we,kind:"issue"}:Ze?{attachment:Ze,kind:"pull"}:null,t2=Be.getState(),A1=E??t2.currentSessionId,Q0=E?ue??ee:t2.currentSessionDirectory??(A1?t2.getDirectoryForSession(A1):null)??ee;l1&&A1&&$u(A1,Q0,kf({url:l1.attachment.url,number:l1.attachment.number,title:l1.attachment.title,kind:l1.kind,author:l1.attachment.author,linkedAt:Date.now()}),!0).catch(()=>{}),we&&ze(null),Ze&&x1(null)}).catch(l1=>{const t2=l1 instanceof Error?l1.message:typeof l1=="string"?l1:String(l1??""),A1=t2.toLowerCase();console.error("Message send failed:",t2||l1),Kp();const Q0=k.current?.getValue()??ge.current;te&&o1.message&&(!Q0||Q0===o1.message)&&(a(o1.message),pi(Y,o1.message,l.current));const en=A1.includes("timeout")||A1.includes("timed out")||A1.includes("may still be processing")||A1.includes("being processed")||A1.includes("failed to fetch")||A1.includes("networkerror")||A1.includes("network error")||A1.includes("gateway timeout")||A1==="failed to send message";if(A1.includes("payload too large")||A1.includes("413")||A1.includes("entity too large")){Ue.error("Attachments are too large to send. Please try reducing the number or size of images."),zt.length>0&&R1.getState().setAttachedFiles(zt);return}if(en){zt.length>0&&(R1.getState().setAttachedFiles(zt),Ue.error("Failed to send attachments. Try fewer files or smaller images."));return}if(A1.includes("runtime changed")){zt.length>0&&R1.getState().setAttachedFiles(zt),Ue.error("Message failed to send. Attachments restored.");return}zt.length>0&&R1.getState().setAttachedFiles(zt),Ue.error(t2||"Message failed to send. Attachments restored.")}),xe||k.current?.focus()};ns.current=Lo;const D5=d.useCallback(()=>{const j=ts(),_e=c==="normal"&&j.hasContent&&E&&es!=="idle";Fe==="queue"&&_e?ss():Fe==="steer"&&_e?ns.current({delivery:"steer"}):ns.current()},[c,ts,E,es,Fe,ss]),Ca=d.useCallback((j,_e)=>{const De=(k.current?.getValue()??ge.current).trim(),s1=De?`${j}${_e==="command"?" ":`
6951
+ `;return`${e}${n}${s}`}function o7(e,t){const n=t.trim();if(!n)return e;if(!e)return`${n} `;const s=/[\s\n]$/.test(e)?"":" ";return`${e}${s}${n} `}function uj(e,t,n){if(!e)return e;const s=t.length>0&&!/\s$/.test(t)&&!/^\s/.test(e)&&!/[([{]$/.test(t),o=n.length>0&&!/\s$/.test(e)&&!/^\s/.test(n)&&!/^[\])}.,;:!?]/.test(n);return`${s?" ":""}${e}${o?" ":""}`}function fj(e,t){return e?`${e}${/\s$/.test(e)?"":" "}${t}`:t}const hj=/^(https?:\/\/|mailto:)\S+$/i;function mj(e,t){return hj.test(e)&&!/\s/.test(e)&&t.trim().length>0&&!t.includes("](")}const Vh="file://";function pj(e){let t=e.replace(/\\/g,"/");return/^[A-Za-z]:/.test(t)&&(t=`/${t}`),t.split("/").map((n,s)=>s===1&&/^[A-Za-z]:$/.test(n)?n:encodeURIComponent(n)).join("/")}function gj(e){const t=e.replace(/\\/g,"/").trim();return t.toLowerCase().startsWith(Vh)?t:`file://${pj(t)}`}function yj(e){return e.startsWith("/")||e.startsWith("\\\\")||/^[A-Za-z]:[\\/]/.test(e)}function r7(e){const t=e.trim().replace(/^['"]+|['"]+$/g,"");return!t||/[\r\n]/.test(t)?null:t.toLowerCase().startsWith(Vh)||yj(t)?t:null}function V4(e,t,n=0){if(!(n>6||e==null)){if(typeof e=="string"){t.add(e);return}if(Array.isArray(e)){for(const s of e)V4(s,t,n+1);return}if(typeof e=="object")for(const s of Object.values(e))V4(s,t,n+1)}}function vj(e){const t=new Set,n=s=>{const o=r7(s);if(o){t.add(o);return}for(const r of s.split(/\r?\n/)){const a=r7(r);a&&t.add(a)}};n(e);try{const s=JSON.parse(e),o=new Set;V4(s,o);for(const r of o)n(r)}catch{}return Array.from(t)}function qt(e){if(typeof e!="string")return null;const t=e.trim();if(!t)return null;const n=t.replace(/\\/g,"/");return n==="/"?"/":n.length>1?n.replace(/\/+$/,""):n}function bj(e,t){const n=e.replace(/\\/g,"/").trim(),s=(t||"").replace(/\\/g,"/").replace(/\/+$/,"");if(!s||n===s)return n;const o=`${s}/`;return n.startsWith(o)?n.slice(o.length):n}const xj=["CodeFiles","codefiles","application/vnd.code.tree","application/vnd.code.tree.explorer","text/uri-list","text/plain"],wj="application/x-pichamber-file-path",Mj=["files","text/uri-list","codefiles",wj];function Cj(e,t){try{return e.getData(t)}catch{return""}}function ur(e){if(!e)return!1;if(e.files&&e.files.length>0)return!0;if(e.types){const t=Array.from(e.types).map(n=>n.toLowerCase());if(Mj.some(n=>t.includes(n))||t.some(n=>n.includes("vnd.code.tree")))return!0}for(const t of xj){const n=Cj(e,t);if(n&&vj(n).length>0)return!0}return!1}function Sj(e){if(!e)return[];const t=Array.from(e.files||[]);return t.length>0?t:Array.from(e.items||[]).filter(n=>n.kind==="file").map(n=>n.getAsFile()).filter(n=>!!n)}function _j(e,t){let n="",s=[],o;const r=[],a=[],l=h=>{for(const m of t.collectSkillNames(h))a.includes(m)||a.push(m)},c=h=>{!o&&h&&(o=h)},u=h=>{const m=t.parseAgentMention(h);c(m.agentName);const p=t.extractFileMentions(m.text);return l(p.text),p};if(e.queued.forEach((h,m)=>{const p=u(h.content),g=[...t.sanitizeAttachments(h.attachments),...p.attachments];if(m===0){n=p.text,s=g;return}r.push({text:p.text,attachments:g})}),e.composerText!==null){const h=u(e.composerText.replace(/^\n+|\n+$/g,"")),m=[...t.sanitizeAttachments(e.composerAttachments),...h.attachments];e.queued.length===0?(n=h.text,s=m):r.push({text:h.text,attachments:m})}if(e.inlineComments.length>0){const h=e.queued.length>0&&r.length>0?r[r.length-1]:null;h?h.text=t.appendComments(h.text,e.inlineComments):n=t.appendComments(n,e.inlineComments)}for(const h of e.syntheticTexts)r.push({text:h,synthetic:!0});e.linkedIssueContext&&r.push({text:e.linkedIssueContext,synthetic:!0}),e.linkedPr&&(r.push({text:e.linkedPr.instructions,synthetic:!0}),r.push({text:e.linkedPr.context,synthetic:!0}));const f=t.buildSkillInstruction(a);return f&&r.push({text:f,synthetic:!0}),{primaryText:n,primaryAttachments:s,additionalParts:r,agentMentionName:o,isEmpty:!n&&s.length===0&&r.length===0}}const kj=e=>({visible:{topic_line:e?` focused on: ${e}`:""},instructions:{topic_block:e?`The user asked you to focus this summary on: ${e}. Prioritize that topic; mention unrelated threads only in passing.`:""}}),Aj=[{name:"summary",visiblePrompt:"session.summary.visible",instructionsPrompt:"session.summary.instructions",errorToastKey:"Failed to generate summary",requires:"session",buildVariables:kj},{name:"plan-feature",visiblePrompt:"session.plan.visible",instructionsPrompt:"session.plan.instructions",errorToastKey:"Failed to start feature planning",requires:"session-or-draft"},{name:"catch-up",visiblePrompt:"session.catchup.visible",instructionsPrompt:"session.catchup.instructions",errorToastKey:"Failed to catch up",requires:"session-or-draft"},{name:"debug",visiblePrompt:"session.debug.visible",instructionsPrompt:"session.debug.instructions",errorToastKey:"Failed to start debugging",requires:"session-or-draft"},{name:"weigh",visiblePrompt:"session.weigh.visible",instructionsPrompt:"session.weigh.instructions",errorToastKey:"Failed to weigh options",requires:"session-or-draft"},{name:"explore",visiblePrompt:"session.explore.visible",instructionsPrompt:"session.explore.instructions",errorToastKey:"Failed to start the tour",requires:"session-or-draft"}],Hj=new Map(Aj.map(e=>[e.name,e]));function Lj(e){const t=e.trimStart();if(!t.startsWith("/"))return null;const n=t.slice(1),s=n.trim().split(/\s+/)[0]?.toLowerCase()??"";return s?{name:s,argument:n.slice(s.length).trim()}:null}function jj(e){return Hj.get(e)??null}function Ij(e,t){return e.requires==="session"?t.hasSession:t.hasSession||t.hasDraft}function Bj(e,t){const n=e.buildVariables?.(t)??{};return{visible:n.visible??{},instructions:n.instructions??{}}}function Tj(e){const{enabled:t,openAutocomplete:n,message:s,editorRef:o,containerRef:r}=e,[a,l]=d.useState(null),c=d.useCallback(()=>{if(!t){l(null);return}if(n===null){l(null);return}const u=o.current,f=r.current;if(!u||!f)return;const h=u.caretCoords();if(!h)return;const m=f.getBoundingClientRect(),p=h.top-m.top,g=h.left-m.left,y=8,M=260,b=p-y,v=m.height-p-y,x=v>=M||v>=b?"below":"above",S=n==="mention"?520:n==="skill"?360:450,C=Math.max(y,Math.min(g-24,m.width-S-y)),w=Math.max(120,Math.min(M,x==="below"?v:b));l({top:x==="below"?p+22:p-6,left:C,place:x,maxHeight:w})},[r,o,t,n]);return d.useLayoutEffect(()=>{c()},[c,s,n,t]),d.useEffect(()=>{if(!t)return;const u=()=>c();return window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u)}},[t,c]),{position:a,update:c}}const da=-1,N4={index:da,stashedDraft:""},P4=e=>({state:e,text:null});function Vj(e,t,n){if(t.length===0)return P4(e);if(e.index===da)return{state:{index:0,stashedDraft:n},text:t[0]};if(e.index>=t.length-1)return P4(e);const s=e.index+1;return{state:{...e,index:s},text:t[s]}}function Nj(e,t){if(e.index===da)return P4(e);if(e.index===0)return{state:N4,text:e.stashedDraft};const n=e.index-1;return{state:{...e,index:n},text:t[n]}}function Pj(e){const[t,n]=d.useState(N4),s=d.useCallback(a=>{const l=Vj(t,e,a);return l.text===null?null:(n(l.state),l.text)},[e,t]),o=d.useCallback(()=>{const a=Nj(t,e);return a.text===null?null:(n(a.state),a.text)},[e,t]),r=d.useCallback(()=>n(N4),[]);return{isBrowsing:t.index!==da,older:s,newer:o,reset:r}}const Ej=500;function i7(e,t){return`${e}\0${[...t].sort().join("\0")}`}function zj(e){const{message:t,messageRef:n,setMessage:s,confirmedMentionsRef:o,identity:r,persistEnabled:a,initialDraft:l,onIdentityChange:c,onDraftRestored:u}=e,f=d.useRef(null),h=d.useRef(!1),m=d.useRef(new Map),p=d.useRef(l.identity),g=d.useRef({onIdentityChange:c,onDraftRestored:u});g.current={onIdentityChange:c,onDraftRestored:u},d.useEffect(()=>{p.current=r},[r]);const y=d.useCallback((x,S)=>{if(!x)return;const C=S0(x),w=new Set;for(const L of o.current)S.includes(`@${L}`)&&w.add(L);o.current=w;const _=i7(S,w);m.current.get(C)!==_&&(pi(x,S,w),m.current.set(C,_))},[o]),M=d.useCallback(()=>{f.current&&(clearTimeout(f.current),f.current=null)},[]),b=d.useRef(!1);d.useEffect(()=>{if(!b.current&&(b.current=!0,!!l.text)){if(!a){s(""),pi(l.identity,"",[]);return}requestAnimationFrame(()=>g.current.onDraftRestored?.())}},[a]);const v=d.useRef(l.identity);return d.useEffect(()=>{const x=v.current,S=x?S0(x):null,C=r?S0(r):null;if(S===C)return;if(v.current=r,g.current.onIdentityChange?.(),M(),h.current=!0,!a){s(""),o.current=new Set;return}y(x,n.current);const w=Lf(r);s(w.text),o.current=w.confirmedMentions,w.text&&requestAnimationFrame(()=>g.current.onDraftRestored?.())},[M,o,r,n,a,y,s]),d.useEffect(()=>h_(x=>{const S=S0(x);m.current.set(S,i7("",[]));const C=p.current;!C||S0(C)!==S||(M(),h.current=!0,n.current="",o.current=new Set,s(""))}),[M,o,n,s]),d.useEffect(()=>{if(!a){M(),y(r,"");return}if(h.current){h.current=!1;return}M();const x=t,S=r;return f.current=setTimeout(()=>{f.current=null,y(S,x)},Ej),M},[M,r,t,a,y]),d.useEffect(()=>{const x=()=>{M(),a&&y(p.current,n.current)},S=()=>{document.visibilityState==="hidden"&&x()};return document.addEventListener("visibilitychange",S),document.addEventListener("freeze",x),window.addEventListener("pagehide",x),()=>{document.removeEventListener("visibilitychange",S),document.removeEventListener("freeze",x),window.removeEventListener("pagehide",x),x()}},[M,n,a,y]),{persistNow:y}}const Dj=3e4;function f5(e){return e.label?.trim()||fi(e.path)}function Rj(e){const t=j1(R=>R.projects),n=j1(R=>R.activeProjectId),s=j1(R=>R.setActiveProjectIdOnly),o=Be(R=>R.newSessionDraft),r=Be(R=>R.currentSessionId),a=Be(R=>R.currentSessionDirectory),l=Be(R=>R.setNewSessionDraftTarget),c=Be(R=>R.openNewSessionDraft),u=!!o?.open,f=h2(R=>R.fetchStatus),{git:h}=ra(),m=d.useMemo(()=>{if(u){const $=o?.selectedProjectId?t.find(O=>O.id===o.selectedProjectId)??null:null;if($)return $}else if(r){const $=Kt(t,void 0,a);if($)return $}const R=n?t.find($=>$.id===n)??null:null;return R||(t[0]??null)},[n,a,r,u,o?.selectedProjectId,t]),p=d.useMemo(()=>qt(m?.path??null),[m?.path]),g=m?f5(m):null;d.useEffect(()=>{if(!e||!u||!n||o?.selectedProjectId===n)return;const R=t.find($=>$.id===n);R&&l({projectId:R.id,directoryOverride:R.path})},[n,e,u,o?.selectedProjectId,t,l]);const y=HA(p),M=h2(R=>p?R.directories.get(p)?.lastBranchesFetch??0:0),b=Qi(p),v=!!y?.all,x=h2(R=>R.fetchBranches),[S,C]=d.useState(!1);d.useEffect(()=>{!e||!p||!h||b!==null||f(p,h,{silent:!0})},[f,h,b,p,e]),d.useEffect(()=>{if(!e||!p||!m||!h||b!==!0){C(!1);return}const R=!M||Date.now()-M>Dj;if(v&&!R){C(!1);return}let $=!1;return C(!v),x(p,h).finally(()=>{$||C(!1)}),()=>{$=!0}},[x,h,m,M,v,b,p,e]);const w=y?.current?.trim()??"",_=d.useMemo(()=>{if(!m)return null;const R=qt(m.path);return!R||!w?null:{value:R,label:w}},[m,w]),L=d.useMemo(()=>u?qt(o?.directoryOverride??null)??p:qt(a??null)??p,[a,u,o?.directoryOverride,p]),A=d.useMemo(()=>{const R=[];return _&&R.push(_),!L||R.some($=>$.value===L)?R:[...R,{value:L,label:fi(L)}]},[_,L]),N=d.useMemo(()=>{const R=L??A[0]?.value??null;return R?A.find($=>$.value===R)?.label??fi(R):null},[A,L]),k=d.useMemo(()=>L?_?.value===L:!0,[_?.value,L]),V=d.useMemo(()=>b!==!0||S?!1:!!_,[S,_,b]),H=d.useCallback((R,$)=>{if(n!==R&&s(R),u){l({projectId:R,directoryOverride:$},{force:!0});return}c({selectedProjectId:R,directoryOverride:$})},[n,u,c,s,l]),D=d.useCallback(R=>{const $=t.find(I=>I.id===R);if(!$)return;const O=qt($.path);O&&(m?.id===R&&L===O||H(R,O))},[H,t,L,m?.id]),P=d.useCallback(R=>{if(!m)return;const $=qt(R);!$||L===$||H(m.id,$)},[H,L,m]);return{projects:t,selectedDraftProject:m,selectedDraftProjectPath:p,draftProjectLabel:g,selectedDraftDirectory:L,selectedDraftBranchLabel:N,selectedDraftBranchIsKnown:k,projectRootBranchOption:_,worktreeBranchOptions:[],draftBranchItems:A,shouldShowDraftBranchSelector:V,handleDraftProjectChange:D,handleDraftDirectoryChange:P}}function Oj(e){const{isMobile:t,editorRef:n,formRef:s,setExpandedInput:o,holders:r,alwaysExpanded:a=!1}=e,[l,c]=d.useState(a&&t),[u,f]=d.useState(!1),[h,m]=d.useState(!1),p=d.useRef(null),g=d.useRef(0),y=d.useRef(!1),M=d.useRef(null);d.useEffect(()=>()=>{M.current!==null&&window.clearTimeout(M.current)},[]);const b=d.useRef(l);d.useEffect(()=>{b.current=l});const v=d.useRef(a);v.current=a,d.useEffect(()=>{!t||!a||c(!0)},[a,t]),d.useLayoutEffect(()=>{if(!t||typeof document>"u")return;const P=document.documentElement;return P.classList.toggle("oc-composer-expanded",l&&!a),()=>P.classList.remove("oc-composer-expanded")},[a,l,t]);const x=d.useCallback(()=>{if(p.current="focus",V0.flushSync(()=>c(!0)),Ot()){requestAnimationFrame(()=>{n.current?.focus({preventScroll:!0})});return}n.current?.focus({preventScroll:!1})},[n]);d.useEffect(()=>{if(!t||typeof document>"u")return;let P=document.getElementById("mobile-overlay-root");P||(P=document.createElement("div"),P.id="mobile-overlay-root",document.body.appendChild(P));const R=P,$=()=>m(R.childElementCount>0);$();const O=new MutationObserver($);return O.observe(R,{childList:!0}),()=>O.disconnect()},[t]);const S=h||r.controlsPanelOpen||r.attachMenuOpen||r.issuePickerOpen||r.prPickerOpen,C=d.useRef(!1);C.current=r.issuePickerOpen||r.prPickerOpen;const w=d.useRef(!1),_=d.useRef(0),L=d.useRef(0);d.useEffect(()=>{if(!t||Ot()||typeof window>"u"||!window.matchMedia?.("(display-mode: standalone)")?.matches)return;const P=()=>{_.current+=1},R=()=>{if(_.current=Math.max(0,_.current-1),w.current){w.current=!1;return}if(!y.current||C.current||_.current>0)return;y.current=!1,L.current=Date.now()+600,n.current?.focus(),n.current?.isFocused()&&f(!0);const $=()=>{const O=n.current;O?.isFocused()&&(s.current??O.getScrollDOM())?.scrollIntoView({block:"end"})};window.setTimeout($,300),window.setTimeout($,650)};return window.addEventListener("oc:mobile-overlay-opened",P),window.addEventListener("oc:mobile-overlay-closed",R),()=>{window.removeEventListener("oc:mobile-overlay-opened",P),window.removeEventListener("oc:mobile-overlay-closed",R)}},[n,s,t]),d.useEffect(()=>{if(!t)return;if(S){(u||Date.now()-g.current<800)&&(y.current=!0);return}if(!y.current)return;const P=window.setTimeout(()=>{y.current=!1,n.current?.focus({preventScroll:Ot()})},180);return()=>window.clearTimeout(P)},[n,u,t,S]);const A=u||h||r.controlsPanelOpen||r.attachMenuOpen||r.draftPickerOpen||r.issuePickerOpen||r.prPickerOpen||r.isDragging;d.useEffect(()=>{if(!t||!l||A||a)return;const P=window.setTimeout(()=>{n.current?.isFocused()||(p.current=null,c(!1),o(!1))},250);return()=>window.clearTimeout(P)},[a,A,n,l,t,o]);const N=d.useRef(!1);N.current=A,d.useEffect(()=>{if(!t||Ot()||typeof document>"u")return;const P=document.documentElement;return u?P.classList.add("oc-browser-keyboard-open"):(P.classList.remove("oc-browser-keyboard-open"),window.matchMedia?.("(display-mode: standalone)")?.matches&&window.setTimeout(()=>{P.classList.contains("oc-browser-keyboard-open")||(window.scrollTo(0,0),document.body.scrollTop=0,P.scrollTop=0)},350)),()=>P.classList.remove("oc-browser-keyboard-open")},[u,t]),d.useEffect(()=>{if(!t||typeof window>"u")return;const P=R=>{const $=R.detail;!$||$.open!==!1||!b.current||v.current||N.current||(p.current=null,V0.flushSync(()=>{c(!1),o(!1)}))};return window.addEventListener("oc:keyboard-intent",P),()=>window.removeEventListener("oc:keyboard-intent",P)},[a,t,o]);const k=d.useCallback(()=>{t&&(Ot()&&ZA(),M.current!==null&&(window.clearTimeout(M.current),M.current=null),p.current=null,f(!0))},[t]),V=d.useCallback(()=>{if(t){if(Date.now()<L.current){const P=n.current;if(P){P.focus(),window.setTimeout(()=>{Date.now()<L.current&&!P.isFocused()&&P.focus()},50);return}}if(g.current=Date.now(),Ot()){V0.flushSync(()=>f(!1));return}M.current!==null&&window.clearTimeout(M.current),M.current=window.setTimeout(()=>{M.current=null,f(!1)},120)}},[n,t]),H=d.useCallback(()=>{w.current=!0},[]),D=d.useCallback(()=>{y.current=!1},[]);return{expanded:l,focused:u,overlayHostBusy:h,expand:x,onEditorFocus:k,onEditorBlur:V,skipNextOverlayCloseRestore:H,cancelOverlayCloseRestore:D}}function a7(e){e.style.position="",e.style.left="",e.style.right="",e.style.width="",e.style.top="",e.style.height="",e.style.zIndex="",e.style.background=""}function Zj(e){const{isMobile:t,isFullscreen:n,isDraftScreen:s,isFocused:o,formRef:r,editorRef:a}=e;d.useLayoutEffect(()=>{if(!t||!n||Ot())return;const l=window.visualViewport,c=r.current,u=a.current;if(!l||!c)return;document.documentElement.classList.add("oc-browser-kb-fullscreen");const f=()=>{const h=Math.max(0,Math.floor(l.offsetTop)),m=document.documentElement.clientHeight;c.style.position="fixed",c.style.left="0",c.style.right="0",c.style.top=`${h}px`,c.style.height=`${Math.floor(Math.min(l.height,m-h))}px`,c.style.zIndex="40",c.style.background="var(--background)"};return f(),l.addEventListener("resize",f),l.addEventListener("scroll",f),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{l.removeEventListener("resize",f),l.removeEventListener("scroll",f),window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0),document.documentElement.classList.remove("oc-browser-kb-fullscreen"),a7(c),requestAnimationFrame(()=>{u?.isFocused()&&u.getScrollDOM()?.scrollIntoView({block:"nearest"})})}},[a,r,n,t]),d.useLayoutEffect(()=>{if(!t||Ot()||!s||n||!o)return;const l=window.visualViewport,c=r.current;if(!l||!c)return;const u=c.getBoundingClientRect();c.style.position="fixed",c.style.left=`${Math.floor(u.left)}px`,c.style.width=`${Math.floor(u.width)}px`,c.style.zIndex="40",c.style.background="var(--background)";let f=Number.NaN,h=0;const m=()=>{const p=document.documentElement.clientHeight,g=l.offsetTop+l.height,y=Math.max(0,Math.floor(Math.min(g,p)-c.offsetHeight));y!==f&&(f=y,c.style.top=`${y}px`),h=requestAnimationFrame(m)};return m(),()=>{cancelAnimationFrame(h),a7(c)}},[r,s,o,n,t])}const Fj=T9(["border-input flex items-center justify-between gap-2 rounded-md border bg-transparent","typography-ui-label whitespace-nowrap shadow-none outline-none text-left","hover:bg-interactive-hover data-[popup-open]:bg-interactive-active","focus-visible:outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","disabled:cursor-not-allowed disabled:opacity-50","[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='text-'])]:text-muted-foreground"].join(" "),{variants:{size:{sm:"h-6 min-h-6 px-2 [&_svg:not([class*='size-'])]:size-3.5",default:"h-8 min-h-8 px-3 [&_svg:not([class*='size-'])]:size-4"}},defaultVariants:{size:"default"}}),h5=ae.createContext(null),$j=e=>e?e.closest('[data-slot="dialog-content"], [role="dialog"]'):null;function l7({onValueChange:e,modal:t=!1,...n}){const[s,o]=ae.useState(null),r=ae.useMemo(()=>({portalContainer:s,setPortalContainer:o}),[s]),a=ae.useCallback((l,c)=>{typeof l=="string"&&e?.(l,c)},[e]);return i.jsx(h5.Provider,{value:r,children:i.jsx(zy,{...n,modal:t,onValueChange:a})})}function qj({...e}){return i.jsx(Wy,{"data-slot":"select-group",...e})}function c7({placeholder:e,children:t,...n}){return i.jsx(Oy,{"data-slot":"select-value",...n,children:s=>{const o=typeof s=="string"||s===void 0?s:s===null?void 0:String(s);return typeof t=="function"?t(o):t??(o===void 0||o===""?e:o)}})}function d7({className:e,size:t="default",children:n,asChild:s,onPointerDownCapture:o,onFocusCapture:r,...a}){const l=ae.useContext(h5),c=ae.useCallback(f=>{if(!l)return;const h=f instanceof HTMLElement?f:null;l.setPortalContainer($j(h))},[l]),u=s&&ae.isValidElement(n)?{render:n}:null;return i.jsx(Dy,{"data-slot":"select-trigger","data-size":t,className:B(Fj({size:t==="settings"||t==="lg"?"default":"sm"}),"w-fit data-[placeholder]:text-muted-foreground aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2",e),onPointerDownCapture:f=>{c(f.currentTarget),o?.(f)},onFocusCapture:f=>{c(f.currentTarget),r?.(f)},...a,...u??{},children:u?void 0:i.jsxs(i.Fragment,{children:[n,i.jsx(Ry,{children:i.jsx(z,{name:"arrow-down-s",className:"size-4 opacity-50"})})]})})}function u7({className:e,children:t,position:n="popper",fitContent:s=!1,portalToBody:o=!1,sideOffset:r,side:a,align:l,...c}){const u=ae.useContext(h5),f=n==="item-aligned",h=u?.portalContainer??null;return i.jsx(Zy,{container:o?void 0:h||void 0,children:i.jsx(Fy,{alignItemWithTrigger:f,sideOffset:r,side:a,align:l,className:"absolute z-[120] pointer-events-auto",children:i.jsx($y,{"data-slot":"select-content",style:{color:"var(--surface-elevated-foreground)"},className:B("oc-glass-popover oc-glass-floating pointer-events-auto transition-all duration-150 ease-out data-[starting-style]:opacity-0 data-[starting-style]:scale-95 data-[ending-style]:opacity-0 data-[ending-style]:scale-95 relative z-[120] max-h-[var(--available-height)] min-w-[8rem] origin-[var(--transform-origin)] overflow-x-hidden rounded-xl",!f&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",s&&"w-max min-w-0",e),...c,children:i.jsx(vt,{outerClassName:B("max-h-[var(--available-height)]",s?"w-max":"w-full"),className:B("p-1",!f&&(s?"w-max min-w-0 scroll-my-1":"w-full min-w-[var(--anchor-width)] scroll-my-1")),preventOverscroll:!0,children:t})})})})}function Uj({className:e,...t}){return i.jsx(Ky,{"data-slot":"select-label",className:B("text-muted-foreground px-2 py-1.5 typography-meta",e),...t})}function Cl({className:e,children:t,...n}){return i.jsxs(qy,{"data-slot":"select-item",className:B("data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover data-[selected]:bg-interactive-selection data-[selected]:text-interactive-selection-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-pointer items-center gap-2 rounded-lg py-1.5 pr-8 pl-2 typography-ui-label outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...n,children:[i.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:i.jsx(Uy,{children:i.jsx(z,{name:"check",className:"size-4"})})}),i.jsx(Gy,{children:t})]})}const Nh=(e,t)=>e.length<=t?e:`${e.slice(0,t)}...`;function Ci({project:e}){const t=he(a=>a.isMobile),{enabled:n}=Kn(),s=t&&!n,o=f5(e),r=s?Nh(o,20):o;return i.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[i.jsx(z,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),i.jsx("span",{className:"truncate text-muted-foreground",children:r})]})}const f7="h-7 min-w-0 w-fit max-w-[48vw] gap-1 border-transparent bg-transparent px-1.5 text-muted-foreground typography-micro font-normal hover:bg-transparent hover:text-foreground data-[popup-open]:bg-transparent [&_svg]:size-3.5 [&_svg]:opacity-70 sm:max-w-[20rem]";function Gj(e){const{projects:t,selectedProject:n,selectedDirectory:s,selectedBranchLabel:o,selectedBranchIsKnown:r,projectRootBranchOption:a,showBranchSelector:l,showProjectSelector:c=!0,endAccessory:u,onProjectChange:f,onDirectoryChange:h,theme:m}=e;return i.jsxs("div",{className:"mb-3 flex min-w-0 w-full items-center justify-between gap-2 pl-2 pr-1",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[c?i.jsxs(l7,{value:n.id,onValueChange:f,children:[i.jsx(d7,{size:"sm",className:f7,children:i.jsx(c7,{children:i.jsx(Ci,{project:n,theme:m})})}),i.jsx(u7,{className:"w-max min-w-48",children:t.map(p=>i.jsx(Cl,{value:p.id,className:"max-w-[24rem] truncate",children:i.jsx(Ci,{project:p,theme:m})},p.id))})]}):null,l?i.jsxs(l7,{value:s??a?.value,onValueChange:h,children:[i.jsx(d7,{size:"sm",className:f7,children:i.jsx(c7,{children:o??"Branch"})}),i.jsxs(u7,{className:"w-max min-w-48",children:[a?i.jsxs(qj,{children:[i.jsx(Uj,{children:"Project root"}),i.jsx(Cl,{value:a.value,className:"max-w-[24rem] truncate",children:a.label},a.value)]}):null,s&&!r?i.jsx(Cl,{value:s,className:"max-w-[24rem] truncate",children:o}):null]})]}):null]}),u?i.jsx("div",{className:"min-w-0 shrink-0",children:u}):null]})}function Wj(e){const{selectedProject:t,selectedBranchLabel:n,showBranchSelector:s,showProjectSelector:o=!0,endAccessory:r,theme:a,onOpenPicker:l}=e,{enabled:c}=Kn(),u=n?c?n:Nh(n,26):null;return i.jsxs("div",{className:"mb-1.5 flex min-w-0 w-full items-center justify-between gap-2 pl-2 pr-1",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-x-2",children:[o?i.jsxs("button",{type:"button",className:"inline-flex h-7 min-w-0 max-w-[42vw] flex-shrink cursor-pointer items-center gap-1 rounded-lg px-1.5 typography-micro font-medium text-foreground/80 hover:bg-[var(--interactive-hover)]",onClick:()=>l("project"),children:[i.jsx(Ci,{project:t,theme:a}),i.jsx(z,{name:"arrow-down-s",className:"h-3 w-3 flex-shrink-0 text-muted-foreground"})]}):null,s?i.jsxs("button",{type:"button",className:"inline-flex h-7 min-w-0 max-w-[42vw] flex-shrink cursor-pointer items-center gap-1 rounded-lg px-1.5 typography-micro font-medium text-foreground/80 hover:bg-[var(--interactive-hover)]",onClick:()=>l("branch"),children:[i.jsx(z,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground"}),i.jsx("span",{className:"truncate",children:u??"Branch"}),i.jsx(z,{name:"arrow-down-s",className:"h-3 w-3 flex-shrink-0 text-muted-foreground"})]}):null]}),r?i.jsx("div",{className:"min-w-0 shrink-0",children:r}):null]})}function Kj(e){const{projects:t,selectedProject:n,selectedDirectory:s,selectedBranchLabel:o,selectedBranchIsKnown:r,projectRootBranchOption:a,onProjectChange:l,onDirectoryChange:c,theme:u,openPicker:f,onOpenPickerChange:h,showProjectSelector:m=!0,showBranchSelector:p}=e,[g,y]=d.useState(""),[M,b]=d.useState("");d.useEffect(()=>{f!=="project"&&y(""),f!=="branch"&&b("")},[f]);const v=d.useMemo(()=>{const x=g.trim().toLowerCase();return x?t.filter(S=>f5(S).toLowerCase().includes(x)||S.path.toLowerCase().includes(x)):t},[g,t]);return i.jsxs(i.Fragment,{children:[i.jsx(t0,{open:m&&f==="project",onClose:()=>h(null),title:"Project",children:i.jsxs("div",{className:"flex flex-col py-1",children:[t.length>5?i.jsx("div",{className:"px-3 pb-2 pt-1",children:i.jsx(Bt,{value:g,onChange:x=>y(x.target.value),placeholder:"Search projects...",className:"h-8 typography-meta",autoFocus:!0})}):null,i.jsx("div",{className:"max-h-[60vh] overflow-y-auto px-2",children:v.map(x=>{const S=x.id===n.id;return i.jsxs("button",{type:"button",onClick:()=>{l(x.id),h(null)},className:`flex w-full cursor-pointer items-center justify-between gap-2 rounded-lg px-3 py-2 text-left typography-ui-label transition-colors hover:bg-[var(--interactive-hover)] ${S?"bg-[var(--interactive-hover)] font-medium text-foreground":"text-foreground/80"}`,children:[i.jsx(Ci,{project:x,theme:u}),S?i.jsx(z,{name:"check",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):null]},x.id)})})]})}),i.jsx(t0,{open:p&&f==="branch",onClose:()=>h(null),title:"Branch",children:i.jsx("div",{className:"flex flex-col py-1",children:i.jsx("div",{className:"max-h-[60vh] overflow-y-auto px-2",children:(()=>{const x=s??a?.value??null,S=M.trim().toLowerCase(),C=_=>!S||_.toLowerCase().includes(S),w=(_,L,A)=>i.jsxs("button",{type:"button",onClick:()=>{c(_),h(null)},className:`flex w-full cursor-pointer items-center justify-between gap-2 rounded-lg px-3 py-2 text-left typography-ui-label transition-colors hover:bg-[var(--interactive-hover)] ${_===x?"bg-[var(--interactive-hover)] font-medium text-foreground":"text-foreground/80"}`,children:[i.jsx("span",{className:"truncate",children:L}),_===x?i.jsx(z,{name:"check",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):null]},A??_);return i.jsxs(i.Fragment,{children:[a&&C(a.label)?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"px-2 pb-1 pt-1.5 text-muted-foreground typography-meta",children:"Project root"}),w(a.value,a.label)]}):null,s&&!r&&C(o??"")?w(s,o??s,"unknown-current"):null]})})()})})})]})}const ua=(e,t)=>{const[n,s]=d.useState(void 0);return d.useLayoutEffect(()=>{if(!t)return;const o=()=>{const r=e.current;if(!r)return;const a=r.closest("main");if(!a)return;const l=window.visualViewport?.offsetTop??0,c=Math.max(a.getBoundingClientRect().top,l),u=r.getBoundingClientRect().bottom-c-8,f=Math.max(120,Math.floor(u));s(h=>h===f?h:f)};return o(),window.addEventListener("resize",o),window.addEventListener("oc:keyboard-settled",o),window.visualViewport?.addEventListener("resize",o),window.visualViewport?.addEventListener("scroll",o),()=>{window.removeEventListener("resize",o),window.removeEventListener("oc:keyboard-settled",o),window.visualViewport?.removeEventListener("resize",o),window.visualViewport?.removeEventListener("scroll",o)}}),t?n:void 0};function h7(e,t){const n=e.searchAliases??[],s=[...n,...e.name===t.name?[]:[t.name],...t.description?[t.description]:[],...t.searchAliases??[]].filter((r,a,l)=>r!==e.description&&l.indexOf(r)===a);return s.length===n.length&&s.every((r,a)=>r===n[a])?e:{...e,searchAliases:s}}function Yj(e,t,n){const s=[],o=new Map,r=(a,l)=>{for(const c of a){const u=l(c),f=c.name,h=o.get(f);if(!h){o.set(f,{index:s.length,item:c,precedence:u}),s.push(c);continue}const m=u>h.precedence?h7(c,h.item):h7(h.item,c);s[h.index]=m,o.set(f,{index:h.index,item:m,precedence:Math.max(h.precedence,u)})}};return r(e,()=>3),r(t,a=>a.isBuiltIn?3:a.isSkill?1:0),r(n,()=>2),s}function Jj(e,t){return e0(e.name,t)||!!(e.description&&e0(e.description,t))||!!e.searchAliases?.some(n=>e0(n,t))}const fa="text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0",m7=B(fa,"bg-[color-mix(in_srgb,var(--primary-base)_12%,transparent)] text-[color-mix(in_srgb,var(--primary-base)_70%,transparent)] border-[color-mix(in_srgb,var(--primary-base)_24%,transparent)]"),Xj=B(fa,"bg-[color-mix(in_srgb,var(--status-success)_12%,transparent)] text-[color-mix(in_srgb,var(--status-success)_70%,transparent)] border-[color-mix(in_srgb,var(--status-success)_24%,transparent)]"),Qj=B(fa,"bg-[color-mix(in_srgb,var(--status-info)_12%,transparent)] text-[color-mix(in_srgb,var(--status-info)_70%,transparent)] border-[color-mix(in_srgb,var(--status-info)_24%,transparent)]"),Sl=B(fa,"bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60"),Ph=d.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,style:s},o)=>{const r=Be(D=>D.currentSessionId),l=$i(r??"").length>0,c=!!r,u=Be(D=>!!D.newSessionDraft?.open),f=c||u,h=he(D=>D.isMobile),m=c&&!h,[p,g]=d.useState([]),[y,M]=d.useState(!1),b=R2(D=>D.skills),v=R2(D=>D.loadSkills),[x,S]=d.useState(0),C=d.useRef(0),w=d.useRef(!1),_=d.useRef([]),L=d.useRef(null),A=ua(L,h),N=d.useRef(!1),k=d.useRef(null),V=d.useRef(!1);d.useEffect(()=>{const D=P=>{const R=P.target;!R||!L.current||L.current.contains(R)||n()};return document.addEventListener("pointerdown",D,!0),()=>{document.removeEventListener("pointerdown",D,!0)}},[n]),d.useEffect(()=>{v()},[v]),d.useEffect(()=>{(async()=>{M(!0);try{const P=b.map((q,G)=>({id:`skill:${q.scope}:${q.source??"opencode"}:${q.name}:${G}`,name:q.name,source:"skill",description:q.description,isSkill:!0,scope:q.scope})),R=[...c&&!l?[{id:"pichamber:init",name:"init",source:"pichamber",description:"Create/update AGENTS.md file",isBuiltIn:!0}]:[],...c?[{id:"pichamber:undo",name:"undo",source:"pichamber",description:"Undo the last message",isBuiltIn:!0},{id:"pichamber:redo",name:"redo",source:"pichamber",description:"Redo previously undone messages",isBuiltIn:!0},{id:"pichamber:timeline",name:"timeline",source:"pichamber",description:"Open the conversation timeline",isBuiltIn:!0}]:[],{id:"pichamber:compact",name:"compact",source:"pichamber",description:"Compress session history using AI to reduce context size",isBuiltIn:!0},...c?[{id:"pichamber:summary",name:"summary",source:"pichamber",description:"Non-destructive session summary. Optional topic hint after the command.",isPiChamber:!0}]:[],...f?[{id:"pichamber:plan-feature",name:"plan-feature",source:"pichamber",description:"Start a guided, back-and-forth planning session for a new feature.",isPiChamber:!0}]:[],...f?[{id:"pichamber:catch-up",name:"catch-up",source:"pichamber",description:"Re-establish context: what you were doing and where to pick up.",isPiChamber:!0}]:[],...f?[{id:"pichamber:debug",name:"debug",source:"pichamber",description:"Guided root-cause investigation for a bug before proposing a fix.",isPiChamber:!0}]:[],...f?[{id:"pichamber:weigh",name:"weigh",source:"pichamber",description:"Weigh 2-3 approaches with trade-offs and a recommendation before you commit.",isPiChamber:!0}]:[],...f?[{id:"pichamber:explore",name:"explore",source:"pichamber",description:"Get oriented in this codebase: a high-level tour of the architecture and main parts.",isPiChamber:!0}]:[]],$=Yj(R,[],P),O=!l,I=(e?$.filter(q=>Jj(q,e)):$).filter(q=>O||q.name!=="init");I.sort((q,G)=>{const K=q.name.toLowerCase().startsWith(e.toLowerCase()),W=G.name.toLowerCase().startsWith(e.toLowerCase());return K&&!W?-1:!K&&W?1:q.name.localeCompare(G.name)}),g(I)}catch{const P=!l,R=[...c&&!l?[{id:"pichamber:init",name:"init",source:"pichamber",description:"Create/update AGENTS.md file",isBuiltIn:!0}]:[],...c?[{id:"pichamber:undo",name:"undo",source:"pichamber",description:"Undo the last message",isBuiltIn:!0},{id:"pichamber:redo",name:"redo",source:"pichamber",description:"Redo previously undone messages",isBuiltIn:!0},{id:"pichamber:timeline",name:"timeline",source:"pichamber",description:"Open the conversation timeline",isBuiltIn:!0}]:[],{id:"pichamber:compact",name:"compact",source:"pichamber",description:"Compress session history using AI to reduce context size",isBuiltIn:!0},...c?[{id:"pichamber:summary",name:"summary",source:"pichamber",description:"Non-destructive session summary. Optional topic hint after the command.",isPiChamber:!0}]:[],...f?[{id:"pichamber:plan-feature",name:"plan-feature",source:"pichamber",description:"Start a guided, back-and-forth planning session for a new feature.",isPiChamber:!0}]:[],...f?[{id:"pichamber:catch-up",name:"catch-up",source:"pichamber",description:"Re-establish context: what you were doing and where to pick up.",isPiChamber:!0}]:[],...f?[{id:"pichamber:debug",name:"debug",source:"pichamber",description:"Guided root-cause investigation for a bug before proposing a fix.",isPiChamber:!0}]:[],...f?[{id:"pichamber:weigh",name:"weigh",source:"pichamber",description:"Weigh 2-3 approaches with trade-offs and a recommendation before you commit.",isPiChamber:!0}]:[],...f?[{id:"pichamber:explore",name:"explore",source:"pichamber",description:"Get oriented in this codebase: a high-level tour of the architecture and main parts.",isPiChamber:!0}]:[]],$=(e?R.filter(O=>e0(O.name,e)||O.description&&e0(O.description,e)):R).filter(O=>P||O.name!=="init");g($)}finally{M(!1)}})()},[e,l,c,f,m,b]),d.useEffect(()=>{S(0)},[p]),d.useEffect(()=>{C.current=x},[x]),d.useEffect(()=>{_.current[x]?.scrollIntoView({block:"nearest"})},[x]),d.useImperativeHandle(o,()=>({handleKeyDown:D=>{const P=p.length;if(D==="Escape"){n();return}if(P!==0){if(D==="ArrowDown"){w.current=!0,S(R=>(R+1)%P);return}if(D==="ArrowUp"){w.current=!0,S(R=>(R-1+P)%P);return}if(D==="Enter"||D==="Tab"){const R=(C.current%P+P)%P,$=p[R];$&&t($)}}}}),[p,n,t]);const H=D=>{switch(D.name){case"init":return i.jsx(z,{name:"file",className:"h-3.5 w-3.5 text-green-500"});case"undo":return i.jsx(z,{name:"arrow-go-back",className:"h-3.5 w-3.5 text-orange-500"});case"redo":return i.jsx(z,{name:"arrow-go-forward",className:"h-3.5 w-3.5 text-orange-500"});case"timeline":return i.jsx(z,{name:"time",className:"h-3.5 w-3.5"});case"compact":return i.jsx(z,{name:"scissors",className:"h-3.5 w-3.5 text-purple-500"});case"review":return i.jsx(z,{name:"search-eye",className:"h-3.5 w-3.5 text-blue-500"});case"test":case"build":case"run":return i.jsx(z,{name:"terminal-box",className:"h-3.5 w-3.5 text-cyan-500"});default:return D.isBuiltIn?i.jsx(z,{name:"flashlight",className:"h-3.5 w-3.5 text-yellow-500"}):i.jsx(z,{name:"command",className:"h-3.5 w-3.5 text-muted-foreground"})}};return i.jsxs("div",{ref:L,className:"absolute z-[100] min-w-0 w-full max-w-[450px] max-h-64 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col",style:A!==void 0?{...s,maxHeight:A}:s,children:[i.jsx(vt,{preventOverscroll:!0,outerClassName:"flex-1 min-h-0",className:"px-0 pb-2",children:y?i.jsx("div",{className:"flex items-center justify-center py-4",children:i.jsx(z,{name:"refresh",className:"h-4 w-4 animate-spin text-muted-foreground"})}):i.jsxs("div",{children:[p.map((D,P)=>{const R=D.isBuiltIn,$=D.isPiChamber;return i.jsxs("div",{ref:O=>{_.current[P]=O},className:B("flex gap-2 px-3 py-2 cursor-pointer rounded-lg",h?"items-center":"items-start",P===x&&"bg-interactive-selection"),onMouseDown:O=>O.preventDefault(),onPointerDown:O=>{O.pointerType==="touch"&&(k.current={x:O.clientX,y:O.clientY},V.current=!1)},onPointerMove:O=>{if(O.pointerType!=="touch"||!k.current)return;const I=O.clientX-k.current.x,q=O.clientY-k.current.y;Math.hypot(I,q)>6&&(V.current=!0)},onPointerUp:O=>{if(O.pointerType!=="touch")return;const I=V.current;k.current=null,V.current=!1,!I&&(O.preventDefault(),O.stopPropagation(),N.current=!0,t(D))},onPointerCancel:()=>{k.current=null,V.current=!1},onClick:()=>{if(N.current){N.current=!1;return}t(D)},onMouseMove:()=>{w.current=!1,S(P)},children:[i.jsx("div",{className:B(!h&&"mt-0.5"),children:H(D)}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"typography-ui-label font-medium",children:["/",D.name]}),D.isSkill?i.jsx("span",{className:m7,children:"skill"}):i.jsx("span",{className:m7,children:"command"}),$?i.jsx("span",{className:Sl,children:"PiChamber"}):R?i.jsx("span",{className:Sl,children:"system"}):D.scope?i.jsx("span",{className:D.scope==="project"?Qj:Xj,children:D.scope}):null,D.agent&&i.jsx("span",{className:Sl,children:D.agent})]}),D.description&&!h&&i.jsx("div",{className:"typography-meta text-muted-foreground mt-0.5 truncate",children:D.description})]})]},D.id)}),p.length===0&&i.jsx("div",{className:"px-3 py-2 typography-ui-label text-muted-foreground",children:"No commands found"})]})}),!h&&i.jsx("div",{className:"px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground",children:"↑↓ navigate • Enter select • Esc close"})]})});Ph.displayName="CommandAutocomplete";const eI=d.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onClose:s,style:o},r)=>{const a=gh()??"",l=j1(Y=>Y.activeProjectId),c=j1(d.useCallback(Y=>Y.projects.find(oe=>oe.id===l)?.path??null,[l])),u=d.useMemo(()=>{const Y=c||a;return Y?Y.replace(/\\/g,"/").replace(/\/+$/,""):null},[c,a]),f=Og(d.useCallback(Y=>u?Y.byRoot[u]:void 0,[u])),h=$e(Y=>Y.getVisibleAgents),m=Zg(Y=>Y.searchFiles),p=o5(e,180),g=Fg(),y=$g(),[M,b]=d.useState([]),[v,x]=d.useState([]),[S,C]=d.useState([]),[w,_]=d.useState(!1),L=d.useRef(0),[A,N]=d.useState(0),k=d.useRef(0),[V,H]=d.useState(360),[D,P]=d.useState({}),[R,$]=d.useState({}),O=d.useRef([]),I=d.useRef([]),q=d.useRef([]),G=d.useRef(null),K=he(Y=>Y.isMobile),W=ua(G,K),ge=(e??"").trim(),Z=d.useMemo(()=>{if(!u||!f)return[];const Y=[f.selectedPath,...f.openPaths.slice().reverse()].filter(He=>typeof He=="string"&&He.length>0),oe=new Set,te=ge.toLowerCase();return Y.filter(He=>{if(oe.has(He))return!1;oe.add(He);const je=He.startsWith(`${u}/`)?He.slice(u.length+1):He;return te?je.toLowerCase().includes(te):!0}).slice(0,6).map(He=>{const je=He.replace(/\\/g,"/"),Pe=je.split("/").filter(Boolean).pop()||je,X=je.startsWith(`${u}/`)?je.slice(u.length+1):je;return{name:Pe,path:je,relativePath:X,extension:Pe.includes(".")?Pe.split(".").pop()?.toLowerCase():void 0}})},[ge,u,f]),fe=d.useMemo(()=>ge.length>0?S:S.slice(0,2),[S,ge.length]),ie=v,E=Z,ce=M;d.useEffect(()=>{const Y=oe=>{const te=oe.target;!te||!G.current||G.current.contains(te)||s()};return document.addEventListener("pointerdown",Y,!0),()=>{document.removeEventListener("pointerdown",Y,!0)}},[s]),d.useEffect(()=>{if(!a){b([]);return}const oe=(p??"").trim().replace(/^\.\//,"").replace(/^\/+/,"").toLowerCase();if(!oe){b([]);return}let te=!1;return L.current++,_(!0),m(a,oe,80,{includeHidden:g,respectGitignore:!y,type:"file"}).then(pe=>{if(te)return;const He=new Set(Z.map(je=>je.path));b(pe.filter(je=>!He.has(je.path)).slice(0,15))}).catch(()=>{te||b([])}).finally(()=>{te||(L.current--,L.current<=0&&(L.current=0,_(!1)))}),()=>{te=!0,L.current=Math.max(0,L.current-1),L.current<=0&&_(!1)}},[a,p,Z,m,g,y]),d.useEffect(()=>{if(!a){x([]);return}const oe=(p??"").trim().replace(/^\.\//,"").replace(/^\/+/,"").toLowerCase();if(!oe){x([]);return}let te=!1;return L.current++,_(!0),m(a,oe,20,{includeHidden:g,respectGitignore:!y,type:"directory"}).then(pe=>{te||x(pe.slice(0,10))}).catch(()=>{te||x([])}).finally(()=>{te||(L.current--,L.current<=0&&(L.current=0,_(!1)))}),()=>{te=!0,L.current=Math.max(0,L.current-1),L.current<=0&&_(!1)}},[a,p,m,g,y]),d.useEffect(()=>{const Y=h(),oe=(e??"").trim().toLowerCase(),te=Y.filter(pe=>pe.mode&&pe.mode!=="primary").filter(pe=>oe?`${pe.name??""} ${pe.description??""}`.toLowerCase().includes(oe):!0).map(pe=>({name:pe.name??"",description:typeof pe.description=="string"?pe.description:void 0,mode:typeof pe.mode=="string"?pe.mode:void 0})).sort((pe,He)=>pe.name.localeCompare(He.name));C(te)},[h,e]),d.useEffect(()=>{N(0),P({}),$({})},[ce,ie,E.length,fe.length]),d.useEffect(()=>{k.current=A},[A]),d.useEffect(()=>{O.current[A]?.scrollIntoView({block:"nearest"})},[A]),d.useEffect(()=>{let Y=null;const oe=()=>{Y!==null&&cancelAnimationFrame(Y),Y=requestAnimationFrame(()=>{const te={},pe={};I.current.forEach((He,je)=>{if(!He)return;const X=q.current[je]?.offsetWidth??He.scrollWidth,me=Math.max(0,X-He.clientWidth),U=me>8;if(te[je]=U,U){const T=Math.max(.6,me/110);pe[je]=T}}),P(te),$(pe)})};return oe(),window.addEventListener("resize",oe),()=>{Y!==null&&cancelAnimationFrame(Y),window.removeEventListener("resize",oe)}},[ce,ie]),d.useEffect(()=>{const Y=I.current[A];if(!Y)return;const oe=()=>{const pe=Y.clientWidth;pe>0&&H(pe)};if(oe(),typeof ResizeObserver>"u")return;const te=new ResizeObserver(oe);return te.observe(Y),()=>{te.disconnect()}},[A]);const ee=d.useCallback(Y=>{t(Y)},[t]),ue=d.useCallback(Y=>{n?.(Y)},[n]);d.useImperativeHandle(r,()=>({handleKeyDown:Y=>{if(Y==="Escape"){s();return}const oe=fe.length+ie.length+E.length+ce.length;if(oe!==0){if(Y==="ArrowDown"){N(te=>(te+1)%oe);return}if(Y==="ArrowUp"){N(te=>(te-1+oe)%oe);return}if(Y==="Enter"||Y==="Tab"){const te=(k.current%oe+oe)%oe;if(te<fe.length){const Pe=fe[te];Pe&&ue(Pe.name);return}const pe=te-fe.length;if(pe<ie.length){const Pe=ie[pe];Pe&&ee(Pe);return}const He=pe-ie.length,je=He<E.length?E[He]:ce[He-E.length];je&&ee(je)}}}}),[ce,ie,E,fe,s,ee,ue]);const J=Y=>{switch(Y.extension?.toLowerCase()){case"ts":case"tsx":case"js":case"jsx":return i.jsx(z,{name:"code",className:"h-3.5 w-3.5 text-[var(--status-info)]"});case"json":return i.jsx(z,{name:"code",className:"h-3.5 w-3.5 text-[var(--status-warning)]"});case"md":case"mdx":return i.jsx(z,{name:"file",className:"h-3.5 w-3.5 text-muted-foreground"});case"png":case"jpg":case"jpeg":case"gif":case"svg":return i.jsx(z,{name:"file-image",className:"h-3.5 w-3.5 text-[var(--status-success)]"});default:return i.jsx(z,{name:"file-pdf",className:"h-3.5 w-3.5 text-muted-foreground"})}};return i.jsxs("div",{ref:G,className:"absolute z-[100] min-w-0 w-full max-w-[640px] max-h-64 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col",style:W!==void 0?{...o,maxHeight:W}:o,children:[i.jsx(vt,{preventOverscroll:!0,outerClassName:"flex-1 min-h-0",className:"px-0",children:w?i.jsx("div",{className:"flex items-center justify-center py-4",children:i.jsx(z,{name:"refresh",className:"h-4 w-4 animate-spin text-muted-foreground"})}):i.jsxs("div",{className:"pb-2",children:[fe.map((Y,oe)=>{const te=A===oe;return i.jsx("div",{ref:pe=>{O.current[oe]=pe},className:B("flex items-start gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg",te&&"bg-interactive-selection"),onClick:()=>ue(Y.name),onMouseMove:()=>N(oe),children:i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"font-semibold truncate",children:["@",Y.name]}),Y.description&&!K?i.jsx("div",{className:"typography-meta text-muted-foreground truncate",children:Y.description}):null]})},`agent-${Y.name}`)}),fe.length===2&&ge.length===0&&S.length>2&&i.jsx("div",{className:"px-3 py-1 typography-meta text-muted-foreground",children:"Type to search more agents"}),fe.length>0&&(ie.length>0||E.length>0||ce.length>0)&&i.jsx("div",{className:"my-1 border-t border-border/60"}),ie.map((Y,oe)=>{const te=fe.length+oe,pe=Y.relativePath||Y.name,He=tl(pe,{maxLength:60}),je=A===te;return i.jsxs("div",{ref:Pe=>{O.current[te]=Pe},className:B("flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg",je&&"bg-interactive-selection"),onClick:()=>ee(Y),onMouseMove:()=>N(te),children:[i.jsx(z,{name:"folder-3-fill",className:"h-3.5 w-3.5 text-primary/60"}),i.jsx("span",{className:"flex-1 min-w-0 truncate","aria-label":pe,children:He})]},`dir-${Y.path}`)}),ie.length>0&&(E.length>0||ce.length>0)&&i.jsx("div",{className:"my-1 border-t border-border/60"}),E.map((Y,oe)=>{const te=fe.length+ie.length+oe,pe=Y.relativePath||Y.name,He=tl(pe,{maxLength:60}),je=A===te,Pe=D[te]??!1,X=R[te]??2.6;return i.jsxs("div",{ref:me=>{O.current[te]=me},className:B("flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg",je&&"bg-interactive-selection"),onClick:()=>ee(Y),onMouseMove:()=>N(te),children:[J(Y),i.jsxs("span",{ref:me=>{I.current[te]=me},className:"relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container",style:je?{"--file-mention-marquee-width":`${V}px`,"--file-mention-marquee-duration":`${X}s`}:void 0,"aria-label":pe,children:[i.jsx("span",{ref:me=>{q.current[te]=me},className:"absolute invisible whitespace-nowrap pointer-events-none","aria-hidden":!0,children:pe}),Pe&&je?i.jsx("span",{className:"inline-block whitespace-nowrap file-mention-marquee",children:pe}):i.jsx("span",{className:"block truncate",children:He})]})]},`recent-${Y.path}`)}),E.length>0&&ce.length>0&&i.jsx("div",{className:"my-1 border-t border-border/60"}),ce.map((Y,oe)=>{const te=fe.length+ie.length+E.length+oe,pe=Y.relativePath||Y.name,He=tl(pe,{maxLength:60}),je=A===te,Pe=D[te]??!1,X=R[te]??2.6,me=i.jsxs("div",{ref:U=>{O.current[te]=U},className:B("flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg",je&&"bg-interactive-selection"),onClick:()=>ee(Y),onMouseMove:()=>N(te),children:[J(Y),i.jsxs("span",{ref:U=>{I.current[te]=U},className:"relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container",style:je?{"--file-mention-marquee-width":`${V}px`,"--file-mention-marquee-duration":`${X}s`}:void 0,"aria-label":pe,children:[i.jsx("span",{ref:U=>{q.current[te]=U},className:"absolute invisible whitespace-nowrap pointer-events-none","aria-hidden":!0,children:pe}),Pe&&je?i.jsx("span",{className:"inline-block whitespace-nowrap file-mention-marquee",children:pe}):i.jsx("span",{className:"block truncate",children:He})]})]});return i.jsx(d.Fragment,{children:me},Y.path)}),ce.length===0&&ie.length===0&&E.length===0&&fe.length===0&&i.jsx("div",{className:"px-3 py-2 typography-ui-label text-muted-foreground",children:"No matches found"})]})}),!K&&i.jsx("div",{className:"px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground",children:"↑↓ navigate • Enter select • Esc close"})]})}),Eh=d.forwardRef(({searchQuery:e,onSkillSelect:t,onClose:n,style:s},o)=>{const r=d.useRef(null),a=he(C=>C.isMobile),l=ua(r,a),[c,u]=d.useState(0),f=d.useRef(0),h=d.useRef(!1),[m,p]=d.useState([]),g=d.useRef([]),y=d.useRef(!1),M=d.useRef(null),b=d.useRef(!1),v=R2(C=>C.skills),x=R2(C=>C.loadSkills);d.useEffect(()=>{x()},[x]),d.useEffect(()=>{const C=e.trim(),_=[...C.length?v.filter(L=>e0(L.name,C)):v].sort((L,A)=>L.scope==="project"&&A.scope!=="project"?-1:L.scope!=="project"&&A.scope==="project"?1:L.name.localeCompare(A.name));p(_),u(0)},[v,e]),d.useEffect(()=>{f.current=c},[c]),d.useEffect(()=>{g.current[c]?.scrollIntoView({block:"nearest"})},[c]),d.useEffect(()=>{const C=w=>{const _=w.target;!_||!r.current||r.current.contains(_)||n()};return document.addEventListener("pointerdown",C,!0),()=>{document.removeEventListener("pointerdown",C,!0)}},[n]),d.useImperativeHandle(o,()=>({handleKeyDown:C=>{if(C==="Escape"){n();return}if(m.length){if(C==="ArrowDown"){h.current=!0,u(w=>(w+1)%m.length);return}if(C==="ArrowUp"){h.current=!0,u(w=>(w-1+m.length)%m.length);return}if(C==="Enter"||C==="Tab"){const w=(f.current%m.length+m.length)%m.length,_=m[w];_&&t(_.name)}}}}),[m,t,n]);const S=(C,w)=>{const _=C.scope==="project",L=C.source||"opencode";return i.jsx("div",{ref:A=>{g.current[w]=A},className:B("flex gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label",a?"items-center":"items-start",w===c&&"bg-interactive-selection"),onMouseDown:A=>A.preventDefault(),onPointerDown:A=>{A.pointerType==="touch"&&(M.current={x:A.clientX,y:A.clientY},b.current=!1)},onPointerMove:A=>{if(A.pointerType!=="touch"||!M.current)return;const N=A.clientX-M.current.x,k=A.clientY-M.current.y;Math.hypot(N,k)>6&&(b.current=!0)},onPointerUp:A=>{if(A.pointerType!=="touch")return;const N=b.current;M.current=null,b.current=!1,!N&&(A.preventDefault(),A.stopPropagation(),y.current=!0,t(C.name))},onPointerCancel:()=>{M.current=null,b.current=!1},onClick:()=>{if(y.current){y.current=!1;return}t(C.name)},onMouseMove:()=>{h.current=!1,u(w)},children:i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-semibold truncate",children:C.name}),i.jsx("span",{className:B("text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0 transition-colors",_?"bg-[var(--status-info-background)] text-[var(--status-info)] border-[var(--status-info-border)]":"bg-[var(--status-success-background)] text-[var(--status-success)] border-[var(--status-success-border)]"),children:C.scope}),i.jsx("span",{className:"text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0 bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60",children:L})]}),C.description&&!a&&i.jsx("div",{className:"typography-meta text-muted-foreground mt-0.5 truncate",children:C.description})]})},`${C.name}-${C.scope}`)};return i.jsxs("div",{ref:r,className:"absolute z-[100] min-w-0 w-full max-w-[450px] max-h-60 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col",style:l!==void 0?{...s,maxHeight:l}:s,children:[i.jsx(vt,{preventOverscroll:!0,outerClassName:"flex-1 min-h-0",className:"px-0 pb-2",children:m.length?i.jsx("div",{children:m.map((C,w)=>S(C,w))}):i.jsx("div",{className:"px-3 py-2 typography-ui-label text-muted-foreground",children:"No skills found"})}),!a&&i.jsx("div",{className:"px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground",children:"↑↓ navigate • Enter select • Esc close"})]})});Eh.displayName="SkillAutocomplete";function tI(e){return(e.description||e.content).replace(/\s+/g," ").trim().slice(0,120)}const zh=d.forwardRef(({searchQuery:e,onSnippetSelect:t,onClose:n,style:s},o)=>{const r=d.useRef(null),a=he(w=>w.isMobile),l=ua(r,a),[c,u]=d.useState(0),f=d.useRef(0),[h,m]=d.useState([]),p=d.useRef([]),g=L0(w=>w.snippets),y=L0(w=>w.loadSnippets),M=L0(w=>w.setSnippetDraft),b=L0(w=>w.setSelectedSnippet),v=he(w=>w.setSettingsDialogOpen),x=he(w=>w.setSettingsPage);d.useEffect(()=>{y()},[y]),d.useEffect(()=>{const w=e.trim(),L=[...w.length?g.filter(A=>e0(A.name,w)||A.aliases.some(N=>e0(N,w))):g].sort((A,N)=>A.source==="project"&&N.source!=="project"?-1:A.source!=="project"&&N.source==="project"?1:A.name.localeCompare(N.name));m(L),u(L.length?1:0)},[e,g]),d.useEffect(()=>{f.current=c,p.current[c]?.scrollIntoView({block:"nearest"})},[c]),d.useEffect(()=>{const w=_=>{const L=_.target;L&&r.current&&!r.current.contains(L)&&n()};return document.addEventListener("pointerdown",w,!0),()=>document.removeEventListener("pointerdown",w,!0)},[n]);const S=d.useCallback(w=>{const _=e.trim(),L=w.aliases.includes(_)?_:w.name;t(w,L)},[t,e]),C=d.useCallback(()=>{const w=new Set(g.map(A=>A.name));let _="new-snippet",L=1;for(;w.has(_);)_=`new-snippet-${L++}`;M({name:_,scope:"global"}),b(_),x("snippets"),v(!0),n()},[n,b,v,x,M,g]);return d.useImperativeHandle(o,()=>({handleKeyDown:w=>{if(w==="Escape"){n();return}const _=h.length+1;if(w==="ArrowDown"){u(L=>(L+1)%_);return}if(w==="ArrowUp"){u(L=>(L-1+_)%_);return}if(w==="Enter"||w==="Tab"){if(f.current===0){C();return}const L=h[f.current-1];L&&S(L)}}}),[S,h,n,C]),i.jsxs("div",{ref:r,className:"absolute z-[100] min-w-0 w-full max-w-[450px] max-h-60 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col",style:l!==void 0?{...s,maxHeight:l}:s,children:[i.jsxs(vt,{preventOverscroll:!0,outerClassName:"flex-1 min-h-0",className:"px-0 pb-2",children:[i.jsxs("div",{ref:w=>{p.current[0]=w},className:B("flex items-center gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label",c===0&&"bg-interactive-selection"),onClick:C,onMouseMove:()=>u(0),children:[i.jsx(z,{name:"add",className:"h-3.5 w-3.5 text-muted-foreground"}),i.jsx("span",{className:"font-medium text-foreground",children:"+ Add new snippet"})]}),h.length?h.map((w,_)=>i.jsx("div",{ref:L=>{p.current[_+1]=L},className:B("flex gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label",a?"items-center":"items-start",_+1===c&&"bg-interactive-selection"),onClick:()=>S(w),onMouseMove:()=>u(_+1),children:i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"font-semibold truncate",children:["#",w.name]}),i.jsx("span",{className:"text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0 bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60",children:w.source==="global"?"global":"project"})]}),!a&&i.jsx("div",{className:"typography-meta text-muted-foreground mt-0.5 truncate",children:tI(w)})]})},`${w.source}:${w.filePath}`)):i.jsx("div",{className:"px-3 py-2 typography-ui-label text-muted-foreground",children:"No snippets found"})]}),!a&&i.jsx("div",{className:"px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground",children:"↑↓ navigate • Enter select • Esc close"})]})});zh.displayName="SnippetAutocomplete";const nI={mention:520,command:450,snippet:450,skill:360};function sI(e,t){if(t)return{left:`${t.left}px`,top:`${t.top}px`,bottom:"auto",width:`min(${nI[e]}px, calc(100% - ${t.left+8}px))`,maxHeight:`${t.maxHeight}px`,transform:t.place==="above"?"translateY(-100%)":void 0}}function oI(e){const{open:t,query:n,overlayPosition:s,onClose:o}=e;if(!t)return null;const r=sI(t,s);switch(t){case"command":return i.jsx(Ph,{ref:e.commandRef,searchQuery:n,onCommandSelect:e.onCommandSelect,onClose:o,style:r});case"skill":return i.jsx(Eh,{ref:e.skillRef,searchQuery:n,onSkillSelect:e.onSkillSelect,onClose:o,style:r});case"snippet":return i.jsx(zh,{ref:e.snippetRef,searchQuery:n,onSnippetSelect:e.onSnippetSelect,onClose:o,style:r});case"mention":return i.jsx(eI,{ref:e.mentionRef,searchQuery:n,onFileSelect:e.onFileSelect,onAgentSelect:e.onAgentSelect,onClose:o,style:r})}}function Dh(e){return i.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",viewBox:"0 0 256 256",...e,children:[i.jsx("path",{d:"M208,56V200a8,8,0,0,1-8,8H56a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8H200A8,8,0,0,1,208,56Z",opacity:"0.2"}),i.jsx("path",{d:"M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,160H56V56H200V200Z"})]})}const rI=d.memo(function(t){const{isMobile:n,footerIconButtonClass:s,sendIconSizeClass:o,stopIconSizeClass:r,canSend:a,canAbort:l,hasContent:c,currentSessionId:u,newSessionDraftOpen:f,onPrimaryAction:h,onQueueMessage:m,onAbort:p}=t,g=i.jsx("button",{type:n?"button":"submit",disabled:!a||!u&&!f,onClick:y=>{n&&(y.preventDefault(),h())},className:B(s,a&&(u||f)?"text-primary hover:text-primary":"opacity-30"),"aria-label":"Send message",children:i.jsx(z,{name:"send-plane-2",className:B(o)})});return l?i.jsxs("div",{className:"relative",children:[c?i.jsx("button",{type:"button",disabled:!u,onClick:y=>{n&&y.preventDefault(),m()},className:B(s,"absolute z-20 bottom-full left-1/2 -translate-x-1/2 mb-1",u?"text-primary hover:text-primary":"opacity-30"),"aria-label":"Queue message",children:i.jsx(z,{name:"send-plane-2",className:B(o,"-rotate-90")})}):null,i.jsx("button",{type:"button",onClick:p,className:B(s,"text-[var(--status-error)] hover:text-[var(--status-error)]"),"aria-label":"Stop generating",children:i.jsx(Dh,{className:B(r)})})]}):g},(e,t)=>e.isMobile===t.isMobile&&e.footerIconButtonClass===t.footerIconButtonClass&&e.sendIconSizeClass===t.sendIconSizeClass&&e.stopIconSizeClass===t.stopIconSizeClass&&e.canSend===t.canSend&&e.canAbort===t.canAbort&&e.hasContent===t.hasContent&&e.currentSessionId===t.currentSessionId&&e.newSessionDraftOpen===t.newSessionDraftOpen&&e.onPrimaryAction===t.onPrimaryAction&&e.onQueueMessage===t.onQueueMessage&&e.onAbort===t.onAbort),Rh=d.memo(function(t){const{footerIconButtonClass:n,iconSizeClass:s,handlePickLocalFiles:o,openIssuePicker:r,openPrPicker:a,onOpenSettings:l,hideAddButton:c=!1}=t;return c&&!l?null:i.jsxs("div",{className:"flex items-center gap-x-1.5",children:[c?null:i.jsx("div",{className:"relative inline-flex",children:t.onOpenMobileSheet?i.jsx("button",{type:"button",className:n,onClick:t.onOpenMobileSheet,onMouseDown:u=>u.preventDefault(),onPointerDownCapture:u=>{u.pointerType==="touch"&&u.preventDefault()},title:"Add attachment","aria-label":"Add attachment",children:i.jsx(z,{name:"add-circle",className:B(s,"text-current")})}):i.jsxs($3,{onOpenChange:t.onMenuOpenChange,children:[i.jsx(q3,{asChild:!0,children:i.jsx("button",{type:"button",className:n,title:"Add attachment","aria-label":"Add attachment",children:i.jsx(z,{name:"add-circle",className:B(s,"text-current")})})}),i.jsxs(U3,{align:"start",children:[i.jsxs(ul,{onSelect:()=>{requestAnimationFrame(o)},children:[i.jsx(z,{name:"attachment-2"}),"Attach files"]}),i.jsxs(ul,{onSelect:()=>{requestAnimationFrame(r)},children:[i.jsx(z,{name:"github"}),"Link GitHub Issue"]}),i.jsxs(ul,{onSelect:()=>{requestAnimationFrame(a)},children:[i.jsx(z,{name:"git-pull-request"}),"Link GitHub PR"]})]})]})}),l?i.jsx("button",{type:"button",onClick:l,className:n,title:"Model and agent settings","aria-label":"Model and agent settings",children:i.jsx(z,{name:"ai-agent",className:B(s,"text-current")})}):null]})},(e,t)=>e.footerIconButtonClass===t.footerIconButtonClass&&e.iconSizeClass===t.iconSizeClass&&e.onOpenSettings===t.onOpenSettings&&e.onMenuOpenChange===t.onMenuOpenChange&&e.onOpenMobileSheet===t.onOpenMobileSheet&&e.hideAddButton===t.hideAddButton);function iI(e){const{isMobile:t,isInline:n,alignToolsEnd:s,sessionId:o,newSessionDraftOpen:r,children:a,leadingExtra:l,footerPaddingClass:c,footerGapClass:u,footerIconButtonClass:f,iconSizeClass:h,sendIconSizeClass:m,stopIconSizeClass:p,canSend:g,canAbort:y,hasContent:M,onOpenSettings:b,onPickLocalFiles:v,onOpenIssuePicker:x,onOpenPrPicker:S,onOpenAttachSheet:C,onPrimaryAction:w,onQueueMessage:_,onAbort:L}=e,A=i.jsx(Rh,{footerIconButtonClass:f,iconSizeClass:h,handlePickLocalFiles:v,openIssuePicker:x,openPrPicker:S,onOpenSettings:b,onOpenMobileSheet:t?C:void 0,hideAddButton:t}),N=i.jsx(rI,{isMobile:t,footerIconButtonClass:f,sendIconSizeClass:m,stopIconSizeClass:p,canSend:g,canAbort:y,hasContent:M,currentSessionId:o,newSessionDraftOpen:r,onPrimaryAction:w,onQueueMessage:_,onAbort:L});if(t)return i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-transparent",children:[i.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:a}),i.jsx("div",{className:B("flex-shrink-0",c,"flex items-center gap-x-1.5"),"data-chat-input-footer":"true",children:i.jsxs("div",{className:"flex w-full items-center justify-between gap-x-1.5",children:[i.jsxs("div",{className:"composer-mobile-actions flex min-w-0 items-center gap-x-2 overflow-x-auto pl-1","data-no-drawer-swipe":"true",children:[A,l?i.jsx("div",{className:"w-max shrink-0",children:l}):null]}),i.jsx("div",{className:"flex min-w-0 shrink-0 items-center justify-end gap-x-1",children:N})]})})]});if(n){const k=s?"self-end":"self-center";return i.jsxs("div",{className:B("grid grid-cols-[auto_minmax(0,1fr)_auto] bg-transparent",c,u),"data-chat-input-footer":"true",children:[i.jsx("div",{className:B("flex min-w-0 items-center",u,k),children:A}),i.jsx("div",{className:"min-w-0",children:a}),i.jsx("div",{className:B("flex min-w-0 items-center justify-end",u,k),children:N})]})}return i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-transparent",children:[i.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:a}),i.jsxs("div",{className:B("flex flex-shrink-0 items-center justify-between",c,u),"data-chat-input-footer":"true",children:[i.jsxs("div",{className:B("flex min-w-0 items-center",u),children:[A,l?i.jsx("div",{className:"w-max min-w-0 shrink-0",children:l}):null]}),i.jsx("div",{className:B("flex flex-shrink-0 items-center",u),children:N})]})]})}function aI(e){const{message:t,sessionId:n,newSessionDraftOpen:s,canAbort:o,footerIconButtonClass:r,iconSizeClass:a,stopIconSizeClass:l,theme:c,onExpand:u,onNewSession:f,onPickLocalFiles:h,onOpenIssuePicker:m,onOpenPrPicker:p,onOpenAttachSheet:g,onAbort:y}=e;return i.jsx("div",{className:"flex flex-col",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("div",{className:"flex h-11 min-w-0 flex-1 items-center gap-x-0.5 rounded-full border border-border/80 pl-2 pr-1 shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]",style:{backgroundColor:c?.colors?.surface?.subtle},children:[i.jsx(Rh,{footerIconButtonClass:r,iconSizeClass:a,handlePickLocalFiles:h,openIssuePicker:m,openPrPicker:p,onOpenMobileSheet:g}),i.jsx("button",{type:"button",className:"flex h-full min-w-0 flex-1 cursor-text items-center px-1.5 text-left",onClick:u,children:i.jsx("span",{className:B("truncate typography-ui-label",t.trim()?"text-foreground":"text-muted-foreground"),children:t.trim()?t:n||s?"Use @ / ! # for helpers":"Select or create a session to start chatting"})}),o?i.jsx("button",{type:"button",className:B(r,"text-[var(--status-error)] hover:text-[var(--status-error)]"),onMouseDown:M=>M.preventDefault(),onPointerDownCapture:M=>{M.pointerType==="touch"&&M.preventDefault()},onClick:M=>{M.stopPropagation(),y()},title:"Stop generating","aria-label":"Stop generating",children:i.jsx(Dh,{className:B(l)})}):null]}),i.jsx("div",{className:B("flex-shrink-0 transition-all duration-200 ease-out",s?"w-0 opacity-0 overflow-hidden":"w-11 opacity-100"),children:i.jsx("button",{type:"button",className:"flex h-11 w-11 cursor-pointer items-center justify-center rounded-full border border-border/80 text-foreground shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]",style:{backgroundColor:c?.colors?.surface?.subtle},onClick:f,disabled:s,title:"New chat","aria-label":"New chat",children:i.jsx(z,{name:"add",className:"h-5 w-5 text-current"})})})]})})}function vs(e){return i.jsxs("div",{className:"inline-flex items-center gap-1.5 rounded-xl border px-2.5 py-1",style:{backgroundColor:e.colors?.surface?.elevated,borderColor:e.colors?.interactive?.border},children:[e.icon,i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:e.label}),i.jsx("span",{className:"text-xs font-semibold",style:{color:e.colors?.status?.info},children:e.count}),i.jsx("button",{type:"button",className:"ml-1 inline-flex h-4 w-4 items-center justify-center rounded-full text-muted-foreground hover:bg-interactive-hover hover:text-foreground",style:{minHeight:0,minWidth:0},onClick:e.onRemove,"aria-label":e.removeLabel,title:e.removeLabel,children:i.jsx(z,{name:"close",className:"h-3 w-3"})})]})}function lI(e){const{terminalDrafts:t,reviewCount:n,prCommentCount:s,prCheckCount:o,previewConsoleCount:r,previewAnnotationCount:a,draftTarget:l,onRemoveDraft:c,onRemoveReviewDrafts:u,onRemovePreviewDrafts:f,colors:h}=e;return i.jsxs("div",{className:"flex flex-wrap items-center gap-2 pb-2",children:[t.map(m=>i.jsxs("div",{className:"inline-flex max-w-full items-center gap-1.5 rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2.5 py-1",title:m.code,children:[i.jsx(z,{name:"terminal",className:"h-3.5 w-3.5"}),i.jsx("span",{className:"truncate text-xs font-medium text-[var(--surface-mutedForeground)]",children:`${m.fileLabel}, lines ${m.startLine}-${m.endLine}`}),i.jsx("button",{type:"button",className:"ml-1 inline-flex h-4 w-4 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]",onClick:()=>l&&m.id&&c(l,m.id),"aria-label":"Remove terminal context",title:"Remove terminal context",children:i.jsx(z,{name:"close",className:"h-3 w-3"})})]},m.id)),n>0?i.jsx(vs,{label:"Review comments:",count:n,removeLabel:"Remove review comments",onRemove:u,colors:h}):null,s>0?i.jsx(vs,{label:"PR comments",count:s,removeLabel:"Remove PR comments context",onRemove:()=>f("pr-comment"),colors:h,icon:i.jsx(z,{name:"git-pull-request",className:"h-3.5 w-3.5 text-muted-foreground"})}):null,o>0?i.jsx(vs,{label:"Failed PR checks",count:o,removeLabel:"Remove PR checks context",onRemove:()=>f("pr-check"),colors:h,icon:i.jsx(z,{name:"close-circle",className:"h-3.5 w-3.5 text-[var(--status-error)]"})}):null,r>0?i.jsx(vs,{label:"Dev Server logs:",count:r,removeLabel:"Remove Dev Server logs",onRemove:()=>f("preview-console"),colors:h}):null,a>0?i.jsx(vs,{label:"Preview annotations:",count:a,removeLabel:"Remove preview context",onRemove:()=>f("preview-annotation"),colors:h}):null]})}function p7(e){const{numberLabel:t,title:n,url:s,author:o,branches:r,openInBrowserLabel:a,removeLabel:l,onReopenPicker:c,onRemove:u}=e;return i.jsx("div",{className:"pb-2 w-full px-1",children:i.jsxs("div",{className:"flex w-full items-center gap-1.5 text-sm h-5 px-1",children:[i.jsxs("button",{type:"button",onClick:c,className:"flex min-w-0 flex-1 items-center gap-1.5 text-left hover:opacity-80 transition-opacity",children:[o?.avatarUrl?i.jsx("img",{src:o.avatarUrl,alt:o.login,className:"h-5 w-5 rounded-full flex-shrink-0"}):null,i.jsxs("span",{className:"text-muted-foreground flex-shrink-0",children:[t,o?i.jsx("span",{className:"ml-1",children:`by ${o.login}`}):null]}),i.jsx("span",{className:"text-foreground truncate",children:n}),r?i.jsxs("span",{className:"text-muted-foreground flex-shrink-0 typography-meta",children:[r.head," → ",r.base]}):null]}),i.jsxs("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[i.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center h-6 w-6 hover:bg-[var(--interactive-hover)] rounded-full transition-colors","aria-label":a,children:i.jsx(z,{name:"external-link",className:"h-4 w-4 text-muted-foreground"})}),i.jsx("button",{type:"button",onClick:u,className:"flex items-center justify-center h-6 w-6 hover:bg-[var(--interactive-hover)] rounded-full transition-colors","aria-label":l,title:l,children:i.jsx(z,{name:"close",className:"h-4 w-4 text-muted-foreground"})})]})]})})}const Oh=d.memo(({sessionId:e})=>{const t=Be(v=>v.restoreToMessage),n=Be(v=>v.forkFromMessage),s=Be(v=>v.handleSlashRedo),[o,r]=d.useState(null),[a,l]=d.useState(null),[c,u]=d.useState(!0),f=tu(e),h=f?.targetEntryId,m=d.useMemo(()=>f?f.abandoned.filter(v=>v.role==="user"):[],[f]),p="No text content",g=d.useMemo(()=>!f||m.length===0?[]:m.map(v=>({id:v.id,text:v.preview?.replace(/\s+/g," ").trim()||p})),[m,f,p]),y=g[0]?.id;d.useEffect(()=>{u(!0)},[h,y]);const M=d.useCallback(async v=>{if(!(!e||o)){r(v);try{const x=m.findIndex(C=>C.id===v),S=x>=0?m[x+1]:void 0;S?(await t(e,S.id),Ue.success("Restored messages through this point")):await s(e)}catch(x){Ue.error(x instanceof Error?x.message:"Failed to restore messages")}finally{r(null)}}},[m,s,t,o,e]),b=d.useCallback(async v=>{if(!(!e||a)){l(v);try{await n(e,v)}catch(x){Ue.error(x instanceof Error?x.message:"Failed to fork session")}finally{l(null)}}},[n,a,e]);return!e||g.length===0?null:i.jsx("div",{className:"pb-2 w-full px-1",children:i.jsxs("div",{className:"rounded-xl border border-border/60 bg-[var(--surface-elevated)] text-[var(--surface-elevated-foreground)] shadow-sm overflow-hidden",children:[i.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-[var(--interactive-hover)] transition-colors",onClick:()=>u(v=>!v),"aria-expanded":!c,children:[i.jsxs("span",{className:"typography-ui-label font-medium text-foreground flex-shrink-0",children:["Reverted"," messages ",g.length]}),i.jsx(z,{name:"arrow-down-s",className:B("ml-auto h-4 w-4 text-muted-foreground transition-transform",!c&&"rotate-180"),"aria-hidden":"true"})]}),!c&&i.jsx("div",{className:"px-3 pb-3 flex flex-col gap-1.5 max-h-[10.5rem] overflow-y-auto",children:g.map(v=>i.jsxs("div",{className:"flex min-w-0 items-center gap-2 py-1",children:[i.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:v.text}),i.jsxs(a1,{type:"button",variant:"secondary",size:"xs",disabled:!!(o||a),onClick:()=>{b(v.id)},children:[a===v.id?i.jsx(z,{name:"loader-4",className:"h-3 w-3 animate-spin","aria-hidden":"true"}):i.jsx(z,{name:"git-branch",className:"h-3 w-3","aria-hidden":"true"}),"Fork"]}),i.jsxs(a1,{type:"button",variant:"secondary",size:"xs",disabled:!!(o||a),onClick:()=>{M(v.id)},children:[o===v.id?i.jsx(z,{name:"loader-4",className:"h-3 w-3 animate-spin","aria-hidden":"true"}):i.jsx(z,{name:"arrow-go-forward",className:"h-3 w-3","aria-hidden":"true"}),"Restore"]})]},v.id))})]})})});Oh.displayName="RevertedMessageDock";const cI=bo(()=>V2(()=>import("./ToolOutputDialog-2zKUdGYL.js"),__vite__mapDeps([110,1,2,111,112,113,25,114,26,27,28,29,30,31,32,33,34,35,36,37,38,39,115,23,24,116,117,118,119,120,121,122,123,124,125,126,127,128,13,6,14,129,22,103,104,40,41,42,43,44,45,46,15,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,105,106,107,7,108,109]))),dI=5,uI=16,fI=4,g7=[],y7=[],hI=560,mI=(e,t)=>e.name===t?e:new File([e],t,{type:e.type,lastModified:e.lastModified}),v7=e=>e.includes("@")?"paste":"manual",pI=(e,t)=>{if(t.size===0)return[];const n=new Set,s=new Map;for(const c of t){const u=c.toLowerCase();n.add(u),s.has(u)||s.set(u,c)}const r=yL(e,"/",n,"case-insensitive").map(c=>s.get(c.toLowerCase())??c),a=new Set,l=[];for(const c of r){const u=c.toLowerCase();a.has(u)||(a.add(u),l.push(c))}return l},gI=e=>e.length===0?null:`The user explicitly mentioned these skills in their message: ${e.map(n=>`/${n}`).join(", ")}. Use the corresponding skill tool when it is relevant to accomplishing the user's request.`,yI=(e,t)=>Is().some(n=>n.role==="user"),b7=d.memo(Uk),vI=d.memo(Rf),bI=e=>{const t=Be.getState(),n=t.newSessionDraft?.open?t.newSessionDraft.bootstrapPendingDirectory??t.newSessionDraft.directoryOverride:null,s=e?t.getDirectoryForSession(e)??t.currentSessionDirectory:n??w1.getState().currentDirectory;return Af(We(),s,e)},Zh=({onOpenSettings:e,scrollToBottom:t})=>{const n=d.useRef(null),s=d.useRef(null),o=d.useRef({text:"",confirmedMentions:new Set}),[r,a]=d.useState(()=>{const j=Be.getState().currentSessionId,_e=bI(j),De=Lf(_e);return s.current=_e,o.current=De,De.text&&(n.current=De.text),De.text}),l=d.useRef(o.current.confirmedMentions),[c,u]=d.useState("normal"),[f,h]=d.useState(!1),[m,p]=d.useState(!1),[g,y]=d.useState(null),[M,b]=d.useState(""),v=d.useCallback(()=>y(null),[]),[x,S]=d.useState(null),[C,w]=d.useState(!1),[_,L]=d.useState(null),[A,N]=d.useState(""),k=d.useRef(null),V=d.useRef(cj()).current;d.useEffect(()=>()=>{V.view?.destroy(),V.view=null},[V]);const H=d.useRef(null),D=d.useRef(0),P=d.useRef(null),R=d.useRef(0),$=d.useRef(!1),O=d.useRef(null),I=d.useRef(!1),q=d.useRef(null),G=d.useRef(null),K=d.useRef(null),W=d.useRef(null),ge=d.useRef(r),Z=d.useRef(s.current),fe=d.useRef(new Set),ie=d.useRef((...j)=>Promise.resolve(Be.getState().sendMessage(...j))).current,E=Be(j=>j.currentSessionId),ce=w1(j=>j.currentDirectory),ee=bt()??ce,ue=Be(d.useCallback(j=>E?j.getDirectoryForSession(E):null,[E])),J=We();d.useEffect(()=>(d4(),R2.getState().loadSkills(),Wn(()=>{d4(),R2.getState().loadSkills()})),[ee]);const Y=d.useMemo(()=>Af(J,ue??ee,E),[J,ee,ue,E]),oe=Be(j=>j.newSessionDraft),te=!!oe?.open,pe=Be(j=>j.setNewSessionDraftTarget),He=Be(j=>j.openNewSessionDraft),je=Be(j=>j.abortPromptSessionId),Pe=Be(j=>j.clearAbortPrompt),X=R1(j=>j.attachedFiles),me=R1(j=>j.addAttachedFile),U=R1(j=>j.clearAttachedFiles),T=R1(j=>j.consumePendingInputText),Q=R1(j=>j.pendingPresetSubmit),se=R1(j=>j.pendingInputText),ye=R1(j=>j.pendingRevertText),le=R1(j=>j.consumePendingRevertText),ne=R1(j=>j.consumePendingSyntheticParts),Ce=Be(j=>j.acknowledgeSessionAbort),Se=d.useCallback(j=>qu(j??E??""),[E]),Ae=$e(j=>j.currentProviderId),Ve=$e(j=>j.currentModelId),Me=$e(j=>j.getModelMetadata);$e(j=>j.modelsMetadata),$e(j=>j.providers);const Ie=Ae&&Ve?Me(Ae,Ve):void 0,qe=$e(j=>j.currentVariant),n1=$e(j=>j.currentAgentName);$e(j=>j.setAgent);const Le=$e(j=>j.getVisibleAgents)(),xe=he(j=>j.isMobile),Te=ta()==="mini-chat",Qe=qA(),{enabled:M1}=Kn(),C1=xe&&!M1,_1=he(j=>j.setImagePreviewOpen),m2=he(j=>j.inputBarOffset),at=he(j=>j.persistChatDraft),F1=he(j=>j.inputSpellcheckEnabled),re=he(j=>j.isExpandedInput),Ne=he(j=>j.setExpandedInput),Oe=he(j=>j.setTimelineDialogOpen),{git:Ke}=ra(),{currentTheme:c1}=Nt(),u1=gh(),v1=Qi(ee),L1=h2(j=>ee?j.directories.get(ee)?.status??null:null),s2=h2(j=>j.ensureStatus),K1=h2(j=>j.fetchStatus),I2=h2(j=>j.clearDiffCache),[ke,e1]=d.useState(!1),[Re,f1]=d.useState(!1),[Y1,C2]=d.useState({open:!1,title:"",content:""}),[S2,K2]=d.useState(!1);d.useEffect(()=>{Y1.open&&K2(!0)},[Y1.open]);const O1=d.useRef({modelKey:`${Ae??""}/${Ve??""}`,modalitySignature:Ie?.modalities?.input?.slice().sort().join(",")??null,attachmentIds:new Set});d.useEffect(()=>{const j=`${Ae??""}/${Ve??""}`,_e=Ie?.modalities?.input,De=_e?.slice().sort().join(",")??null,s1=O1.current,t1=s1.modelKey!==j,o1=s1.modalitySignature===null&&De!==null,r1=t1||o1?X:X.filter(p1=>!s1.attachmentIds.has(p1.id));if(O1.current={modelKey:j,modalitySignature:De,attachmentIds:new Set(X.map(p1=>p1.id))},!_e||r1.length===0)return;const g1=vM(r1,_e);if(g1.length===0)return;const k1=Array.from(new Set(g1.map(({modality:p1})=>p1))),P2={text:"Text",image:"Image",pdf:"PDF",audio:"Audio",video:"Video"},y2=g1.map(({attachment:p1})=>p1.filename),r2=y2.length>3?`${y2.slice(0,3).join(", ")} (+${y2.length-3})`:y2.join(", ");Ue.warning(`${Ie.name??Ve??""} does not support ${k1.map(p1=>P2[p1]).join(", ")} input required by ${r2}. You can still send the message, but these attachments may be ignored.`,{id:`attachment-modalities:${j}`})},[X,Ve,Ie,Ae]);const g2=d.useCallback(j=>{j.image&&(C2(j),_1(!0))},[_1]),e2=d.useCallback(j=>{C2(_e=>({..._e,open:j})),_1(j)},[_1]);d.useEffect(()=>{!ee||!Ke||s2(ee,Ke)},[ee,Ke,s2]),d.useEffect(()=>{if(!(!ee||!Ke))return yh.onGitRefreshHint(j=>{qt(j.directory)===qt(ee)&&(j.paths?.length&&I2(ee,j.paths),K1(ee,Ke,{silent:!0}))})},[I2,ee,Ke,K1]);const Y2=!1,J2=re&&xe,o2=J2,[B2,lt]=d.useState(1),d2=!xe&&!Te,_2=!!(te&&d2&&!o2),be=!xe&&!o2&&!d2,Ge=xe||d2?"1.5rem":"9999px",b1=xe||Re;d.useEffect(()=>{const j=P.current;if(!j)return;const _e=s1=>{const t1=s1>0&&s1<hI;f1(o1=>o1===t1?o1:t1)};if(_e(j.clientWidth),typeof ResizeObserver>"u"){const s1=()=>_e(j.clientWidth);return window.addEventListener("resize",s1),()=>window.removeEventListener("resize",s1)}const De=new ResizeObserver(s1=>{_e(s1[0]?.contentRect.width??j.clientWidth)});return De.observe(j),()=>De.disconnect()},[]);const d1=d.useMemo(()=>new Set(Le.map(j=>j.name.toLowerCase())),[Le]),Ye=d.useRef(d1);Ye.current=d1;const a2=R2(j=>j.skills),k2=d.useMemo(()=>{const j=new Set(["init","review","undo","redo","timeline","compact","summary","plan-feature","catch-up","debug","weigh","explore"]);for(const _e of a2)j.add(_e.name.toLowerCase());return j},[a2]),X2=L0(j=>j.snippets),f0=d.useMemo(()=>{const j=new Set;for(const _e of X2){j.add(_e.name.toLowerCase());for(const De of _e.aliases??[])j.add(De.toLowerCase())}return j},[X2]),h0=d.useMemo(()=>X.map(j=>j.filename),[X]),m0=d.useMemo(()=>({inputMode:c,knownAgentNames:d1,confirmedMentions:l.current,knownSlashNames:k2,knownSnippetTriggers:f0,attachmentFilenames:h0}),[h0,c,d1,k2,f0]),Xn=d.useCallback(j=>[...j??[]].map(_e=>({..._e,dataUrl:_e.source==="server"&&_e.serverPath?gj(_e.serverPath):_e.dataUrl})),[]),pa=d.useCallback(j=>({sanitizedText:j,attachments:[]}),[]),ct=d.useRef(null),ko=d.useRef(!1),[Ao,Qn]=d.useState(!1),[Ho,F]=d.useState(!1),[we,ze]=d.useState(null),[Ze,x1]=d.useState(null),I1=E?m9(E,ue??ee):null,A2=I1?Ur(I1):null,Fe=j2(j=>j.followUpBehavior),Xe=j2(d.useCallback(j=>A2?j.queuedMessages[A2]??g7:g7,[A2])),h1=j2(j=>j.addToQueue),$1=j2(j=>j.clearQueue),P1=j2(j=>j.removeFromQueue),E1=E??(te?"draft":""),u2=ue??ee,z1=d.useMemo(()=>E1&&u2?{directory:u2,sessionKey:E1}:null,[u2,E1]),f2=z1?o_(J,z1.directory,z1.sessionKey):null,p0=Rt(d.useCallback(j=>f2?(j.drafts[f2]??[]).length:0,[f2])),xt=Rt(d.useCallback(j=>{const _e=f2?j.drafts[f2]??[]:[];let De=0,s1=0,t1=0,o1=0,r1=0,g1=0;for(const k1 of _e)k1.source==="preview-console"?De+=1:k1.source==="preview-annotation"?s1+=1:k1.source==="terminal"?o1+=1:k1.source==="pr-comment"?r1+=1:k1.source==="pr-check"?g1+=1:t1+=1;return`${De}:${s1}:${t1}:${o1}:${r1}:${g1}`},[f2])),dt=Rt(j=>j.consumeDrafts),wt=Rt(j=>j.removeDraft),g0=p0>0,[W0,ga,ya,K0,Y0,J1]=xt.split(":").map(j=>Number(j)||0),Mt=K0>0?(f2?Rt.getState().drafts[f2]??[]:[]).filter(j=>j.source==="terminal"):[],ut=d.useCallback(j=>{if(!z1)return;const _e=Rt.getState().getDrafts(z1);for(const De of _e)De.source===j&&wt(z1,De.id)},[z1,wt]),Cp=d.useCallback(()=>{if(!z1)return;const j=Rt.getState().getDrafts(z1);for(const _e of j)_e.source!=="preview-console"&&_e.source!=="preview-annotation"&&_e.source!=="terminal"&&_e.source!=="pr-comment"&&_e.source!=="pr-check"&&wt(z1,_e.id)},[z1,wt]),va=Pj(Gw(E??""));d.useEffect(()=>{ge.current=r},[r]),d.useEffect(()=>{Z.current=Y},[Y]);const{persistNow:Sp}=zj({message:r,messageRef:ge,setMessage:a,confirmedMentionsRef:l,identity:Y,persistEnabled:at,initialDraft:{text:n.current??"",identity:s.current},onIdentityChange:()=>u("normal"),onDraftRestored:()=>k.current?.selectAll()}),P5=d.useRef(te);d.useEffect(()=>{!P5.current&&te&&requestAnimationFrame(()=>{xe?k.current?.focus({preventScroll:!0}):k.current?.focus()}),P5.current=te},[te,xe]);const{phase:es}=s5();d.useEffect(()=>{if(se!==null){const j=T();j?.text&&(j.mode==="append"?a(_e=>{const De=j.text;return De.trim()?dj(_e,De):_e}):j.mode==="append-inline"?a(_e=>o7(_e,j.text)):a(j.text),setTimeout(()=>{k.current?.focus()},0))}},[se,T]),d.useEffect(()=>{if(ye!==null){const j=le();j&&r.trim().length===0&&(a(j),setTimeout(()=>{k.current?.focus()},0))}},[ye,le,r]);const ba=r.trim().length>0||X.length>0||g0,xa=Xe.length>0,_p=(ba||xa)&&!!(Ae&&Ve),E5=es!=="idle",ts=d.useCallback(()=>{const j=k.current?.getValue()??r;return{message:j,hasContent:j.trim().length>0||X.length>0||g0}},[X.length,g0,r]),ns=d.useRef(async()=>{}),ss=d.useCallback(()=>{const j=ts();if(!j.hasContent||!E||!I1)return;const _e=z1?dt(z1):[];let De=j.message.replace(/^\n+|\n+$/g,"");_e.length>0&&(De=s8(De,_e));const s1=Xn(X);h1(I1,{content:De,attachments:s1.length>0?s1:void 0,sendConfig:Ae&&Ve?{providerID:Ae,modelID:Ve,agent:n1??void 0,variant:qe??void 0}:void 0}),a(""),s1.length>0&&U(),xe||k.current?.focus()},[ts,E,I1,z1,X,Xn,h1,U,xe,dt,Ae,Ve,n1,qe]),kp=d.useCallback(j=>{a(j),setTimeout(()=>{k.current?.focus()},0)},[]),Ap=d.useCallback(j=>{ns.current({queuedOnly:!0,queuedMessageId:j,delivery:"steer"})},[]),wa=d.useCallback(()=>{Qn(!0)},[]),Ma=d.useCallback(()=>{F(!0)},[]),z5=(j,_e)=>{const De=j instanceof Error?j.message:"";return De.toLowerCase().includes("runtime changed")?"Message failed to send. Attachments restored.":De||_e},Lo=async j=>{const _e=j?.queuedOnly??!1,De=j?.queuedMessageId,s1=j?.delivery==="steer"&&es!=="idle"?"steer":void 0,t1=I1,o1=j?.presetText!=null?{message:j.presetText,hasContent:j.presetText.trim().length>0||X.length>0||g0}:ts(),r1=I1?j2.getState().sendingIds[Ur(I1)]??y7:y7,g1=(De?Xe.filter(l1=>l1.id===De):Xe).filter(l1=>!r1.includes(l1.id));if(_e){if(g1.length===0||!E)return}else if(!o1.hasContent&&!xa||!E&&!te)return;const k1=_e?g1[0]?.sendConfig:void 0,P2=k1?.providerID??Ae,y2=k1?.modelID??Ve,r2=k1?.agent??n1,p1=k1?.variant??qe;if(!P2||!y2){console.warn("Cannot send message: provider or model not selected"),Ue.error("Select a provider and model before sending a message.");return}if(E&&!_e){const[l1,t2]=await Promise.all([fM(),hM()]);if(l1||t2){ss();return}}const B1=t1?{target:t1,...s1?{delivery:s1}:{}}:s1?{delivery:s1}:void 0,O2=ne(),Ct=_e?null:z1,St=Ct?dt(Ct):[],rs=new Set(R2.getState().skills.map(l1=>l1.name)),X0=_j({queued:g1,composerText:!_e&&o1.hasContent?o1.message:null,composerAttachments:X,inlineComments:St,syntheticTexts:O2?.map(l1=>l1.text)??[],linkedIssueContext:we?.contextText??null,linkedPr:Ze?{instructions:Ze.instructionsText,context:Ze.contextText}:null},{parseAgentMention:l1=>{const{sanitizedText:t2,mention:A1}=Df(l1,Le);return{text:t2,agentName:A1?.name}},extractFileMentions:l1=>{const{sanitizedText:t2,attachments:A1}=pa(l1);return{text:t2,attachments:A1}},sanitizeAttachments:Xn,collectSkillNames:l1=>pI(l1,rs),appendComments:(l1,t2)=>s8(l1,t2),buildSkillInstruction:gI});let Et=X0.primaryText;const{primaryAttachments:rc,additionalParts:is,agentMentionName:ic}=X0;if(X0.isEmpty)return;t1&&De?P1(t1,De):t1&&xa&&$1(t1),_e||(a(""),l.current.clear(),Sp(Y,""),va.reset(),X.length>0&&U(),Ne(!1)),xe&&k.current?.blur();const ac=c==="normal"?Lj(Et):null;if(ac){const{name:l1,argument:t2}=ac;if(l1==="undo"&&E){await Be.getState().handleSlashUndo(E),t?.();return}if(l1==="redo"&&E){await Be.getState().handleSlashRedo(E),t?.();return}if(l1==="timeline"&&E){Oe(!0);return}if(l1==="compact"&&E){try{await S6(),await i1.compactSession({sessionId:E})}catch(en){Ue.error(z5(en,"Failed to compact session"))}return}const A1=jj(l1),Q0=A1!==null&&Ij(A1,{hasSession:!!E,hasDraft:te});if(A1&&Q0){const en=Bj(A1,t2);try{await S6();const Ha=await R0(A1.visiblePrompt,en.visible),Yp=await R0(A1.instructionsPrompt,en.instructions);await ie(Ha,P2,y2,r2,[],ic,[{text:Yp,synthetic:!0}],p1,c,B1),t?.()}catch(Ha){Ue.error(z5(Ha,A1.errorToastKey))}return}}if(t1?.directory,te||(E?!yI():!1)){const l1=await ZH().catch(()=>null);l1&&is.push({text:FH(l1),synthetic:!0})}if(c!=="shell")try{const l1=L0.getState().expandText;Et=await l1(Et);for(const t2 of is)t2.synthetic||(t2.text=await l1(t2.text))}catch(l1){console.warn("[ChatInput] Failed to expand snippets, sending original text:",l1)}const zt=[...rc,...is.flatMap(l1=>l1.attachments??[])],Wp=ie(Et,P2,y2,r2,rc,ic,is.length>0?is:void 0,p1,c,B1),Kp=()=>{Ct&&St.length>0&&Rt.getState().restoreDrafts(Ct,St)};typeof window>"u"?t?.():window.requestAnimationFrame(()=>{t?.()}),Wp.then(()=>{const l1=we?{attachment:we,kind:"issue"}:Ze?{attachment:Ze,kind:"pull"}:null,t2=Be.getState(),A1=E??t2.currentSessionId,Q0=E?ue??ee:t2.currentSessionDirectory??(A1?t2.getDirectoryForSession(A1):null)??ee;l1&&A1&&$u(A1,Q0,kf({url:l1.attachment.url,number:l1.attachment.number,title:l1.attachment.title,kind:l1.kind,author:l1.attachment.author,linkedAt:Date.now()}),!0).catch(()=>{}),we&&ze(null),Ze&&x1(null)}).catch(l1=>{const t2=l1 instanceof Error?l1.message:typeof l1=="string"?l1:String(l1??""),A1=t2.toLowerCase();console.error("Message send failed:",t2||l1),Kp();const Q0=k.current?.getValue()??ge.current;te&&o1.message&&(!Q0||Q0===o1.message)&&(a(o1.message),pi(Y,o1.message,l.current));const en=A1.includes("timeout")||A1.includes("timed out")||A1.includes("may still be processing")||A1.includes("being processed")||A1.includes("failed to fetch")||A1.includes("networkerror")||A1.includes("network error")||A1.includes("gateway timeout")||A1==="failed to send message";if(A1.includes("payload too large")||A1.includes("413")||A1.includes("entity too large")){Ue.error("Attachments are too large to send. Please try reducing the number or size of images."),zt.length>0&&R1.getState().setAttachedFiles(zt);return}if(en){zt.length>0&&(R1.getState().setAttachedFiles(zt),Ue.error("Failed to send attachments. Try fewer files or smaller images."));return}if(A1.includes("runtime changed")){zt.length>0&&R1.getState().setAttachedFiles(zt),Ue.error("Message failed to send. Attachments restored.");return}zt.length>0&&R1.getState().setAttachedFiles(zt),Ue.error(t2||"Message failed to send. Attachments restored.")}),xe||k.current?.focus()};ns.current=Lo;const D5=d.useCallback(()=>{const j=ts(),_e=c==="normal"&&j.hasContent&&E&&es!=="idle";Fe==="queue"&&_e?ss():Fe==="steer"&&_e?ns.current({delivery:"steer"}):ns.current()},[c,ts,E,es,Fe,ss]),Ca=d.useCallback((j,_e)=>{const De=(k.current?.getValue()??ge.current).trim(),s1=De?`${j}${_e==="command"?" ":`
6952
6952
  `}${De}`:j;ns.current({presetText:s1})},[]);d.useEffect(()=>{if(Q==null)return;const j=R1.getState().consumePendingPresetSubmit();j&&Ca(j.text,j.type)},[Q,Ca]);const Hp=j=>{if(UA(j))return;if(c==="shell"&&j.key==="Escape"){j.preventDefault(),u("normal");return}if(c==="shell"&&j.key==="Backspace"&&r.length===0){j.preventDefault(),u("normal");return}if(g==="command"&&G.current&&(j.key==="Enter"||j.key==="ArrowUp"||j.key==="ArrowDown"||j.key==="Escape"||j.key==="Tab")){j.preventDefault(),j.stopPropagation(),G.current.handleKeyDown(j.key);return}if(g==="skill"&&K.current&&(j.key==="Enter"||j.key==="ArrowUp"||j.key==="ArrowDown"||j.key==="Escape"||j.key==="Tab")){j.preventDefault(),j.stopPropagation(),K.current.handleKeyDown(j.key);return}if(g==="snippet"&&W.current&&(j.key==="Enter"||j.key==="ArrowUp"||j.key==="ArrowDown"||j.key==="Escape"||j.key==="Tab")){j.preventDefault(),j.stopPropagation(),W.current.handleKeyDown(j.key);return}if(g==="mention"&&q.current&&(j.key==="Enter"||j.key==="ArrowUp"||j.key==="ArrowDown"||j.key==="Escape"||j.key==="Tab")){j.preventDefault(),j.stopPropagation(),q.current.handleKeyDown(j.key);return}const _e=g!==null,De=k.current?.getSelection().start===0&&k.current?.getSelection().end===0,s1=k.current?.getSelection().start===r.length&&k.current?.getSelection().end===r.length,t1=!_e&&(r.length===0||De),o1=!_e&&(r.length===0||s1);if(c==="normal"&&!_e&&!j.metaKey&&!j.ctrlKey&&!j.altKey){const r1=k.current,g1=r1?.getSelection().start??-1,k1=r1?.getSelection().end??-1;if(r1&&g1>=0){const P2=(r2,p1,B1)=>{j.preventDefault(),a(r2),k.current?.setSelection(p1,B1),N2(r2,B1)},y2={"`":["`","`"],"*":["*","*"],_:["_","_"],"~":["~","~"],"(":["(",")"],"[":["[","]"],"{":["{","}"],'"':['"','"'],"'":["'","'"]};if(k1>g1&&y2[j.key]){const[r2,p1]=y2[j.key],B1=r.slice(g1,k1),O2=`${r.slice(0,g1)}${r2}${B1}${p1}${r.slice(k1)}`;P2(O2,g1+r2.length,k1+r2.length);return}if(j.key==="`"&&g1===k1){const r2=r.slice(0,g1);if(/(^|\n)``$/.test(r2)){const p1=r.slice(k1),B1=`${r2}\`
6953
6953
 
6954
6954
  \`\`\`${p1}`,O2=r2.length+2;P2(B1,O2,O2);return}}}}if(j.key==="ArrowUp"&&t1){j.preventDefault();const r1=va.older(r);r1!==null&&(a(r1),requestAnimationFrame(()=>k.current?.setSelection(0,0)));return}if(j.key==="ArrowDown"&&o1){j.preventDefault();const r1=va.newer();r1!==null&&a(r1);return}if(j.key==="Enter"&&!j.shiftKey&&(!xe||j.ctrlKey||j.metaKey)){j.preventDefault();const r1=j.ctrlKey||j.metaKey,g1=c==="normal"&&ba&&E&&es!=="idle";Fe==="queue"?r1||!g1?Lo():ss():r1||!g1?Lo():Lo({delivery:"steer"})}},{update:Lp}=Tj({enabled:Y2,openAutocomplete:g,message:r,editorRef:k,containerRef:P}),jo=d.useCallback(()=>{ct.current&&(clearTimeout(ct.current),ct.current=null),e1(!0),ct.current=setTimeout(()=>{e1(!1),ct.current=null},1800)},[]),R5=d.useCallback(()=>{Pe(),jo(),Se(E||void 0)},[Se,Pe,E,jo]),N2=d.useCallback((j,_e,De="manual",s1)=>{const t1=wL(j,_e,{inputMode:c,inputSource:De,insertedText:s1});y(t1?.kind??null),b(t1?.query??"")},[c]),O5=d.useCallback((j,_e="manual")=>{if(!j)return;const De=k.current;if(!De){const g1=r+j;a(g1),N2(g1,g1.length,_e,j);return}const{start:s1,end:t1}=De.getSelection(),o1=`${r.substring(0,s1)}${j}${r.substring(t1)}`,r1=s1+j.length;De.insertText(j),N2(o1,r1,_e,j)},[r,N2]),Sa=d.useCallback(()=>{$.current=!1,O.current&&(clearTimeout(O.current),O.current=null)},[]),_a=d.useCallback(()=>{$.current=!0,O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{$.current=!1,O.current=null},700)},[]),jp=({value:j,selection:_e,fromPaste:De,insertedText:s1})=>{const t1=De?s1:"",o1=t1.includes("@")||$.current;$.current&&Sa();const r1=o1?"paste":"manual";if(c==="normal"&&j.startsWith("!")){const g1=j.slice(1),k1=Math.max(0,_e.start-1);u("shell"),a(g1),v(),requestAnimationFrame(()=>k.current?.setSelection(k1));return}a(j),N2(j,_e.start,r1,t1)};d.useEffect(()=>()=>{Sa()},[Sa]);const Ip=d.useCallback(async j=>{const _e=j.clipboardData;if(!_e)return;const De={...j,clipboardData:_e,preventDefault:()=>j.preventDefault()};if(c==="normal"&&(E||te)){const p1=k.current,B1=p1?.getSelection().start??-1,O2=p1?.getSelection().end??-1;if(p1&&O2>B1){const St=De.clipboardData.getData("text").trim(),rs=r.slice(B1,O2);if(mj(St,rs)){De.preventDefault();const X0=`${r.slice(0,B1)}[${rs}](${St})${r.slice(O2)}`,Et=B1+1+rs.length+2+St.length+1;a(X0),k.current?.setSelection(Et,Et),N2(X0,Et,v7(St),St);return}}}const s1=new Map;Array.from(De.clipboardData.files||[]).forEach(p1=>{p1.type.startsWith("image/")&&s1.set(`${p1.name}-${p1.size}`,p1)}),Array.from(De.clipboardData.items||[]).forEach(p1=>{if(p1.kind==="file"&&p1.type.startsWith("image/")){const B1=p1.getAsFile();B1&&s1.set(`${B1.name}-${B1.size}`,B1)}});const t1=Array.from(s1.values()),o1=De.clipboardData.getData("text");if(t1.length===0){o1.includes("@")&&_a();return}if(!E&&!te){o1.includes("@")&&_a();return}De.preventDefault();const r1=rL(t1,[...X.map(p1=>p1.filename),...fe.current]),g1=iL(r1),k1=k.current,P2=k1?.getSelection().start??r.length,y2=k1?.getSelection().end??r.length,r2=uj(fj(o1,g1),r.slice(0,P2),r.slice(y2));O5(r2,v7(r2));for(let p1=0;p1<t1.length;p1+=1){const B1=r1[p1],O2=mI(t1[p1],B1);fe.current.add(B1);try{await me(O2)}catch(Ct){console.error("Clipboard image attach failed",Ct),Ue.error(Ct instanceof Error?Ct.message:"Failed to attach image from clipboard")}finally{fe.current.delete(B1)}}},[me,X,E,c,_a,r,te,O5,a,N2]),Bp=j=>{const _e=k.current?.getSelection().start||0,s1=r.substring(0,_e).lastIndexOf("@"),t1=j.relativePath&&j.relativePath.trim().length>0?j.relativePath.trim():Ep(j.path)||j.name;if(l.current.add(t1),s1!==-1){const o1=r.substring(0,s1)+`@${t1} `+r.substring(_e);a(o1);const r1=s1+t1.length+2;requestAnimationFrame(()=>{k.current&&k.current.setSelection(r1),N2(o1,r1)})}else if(k.current){const o1=r.substring(0,_e)+`@${t1} `+r.substring(_e);a(o1);const r1=_e+t1.length+2;requestAnimationFrame(()=>{k.current&&k.current.setSelection(r1),N2(o1,r1)})}v(),k.current?.focus()},Tp=j=>{const De=k.current?.getSelection().start??r.length,t1=r.substring(0,De).lastIndexOf("@");if(t1!==-1){const o1=r.substring(0,t1)+`@${j} `+r.substring(De);a(o1);const r1=t1+j.length+2;requestAnimationFrame(()=>{k.current&&k.current.setSelection(r1),N2(o1,r1)})}else if(k.current){const o1=r.substring(0,De)+`@${j} `+r.substring(De);a(o1);const r1=De+j.length+2;requestAnimationFrame(()=>{k.current&&k.current.setSelection(r1),N2(o1,r1)})}v(),k.current?.focus()},Vp=j=>{const De=k.current?.getSelection().start??r.length,t1=r.substring(0,De).lastIndexOf("/");if(t1!==-1){const o1=r.substring(0,t1)+`/${j} `+r.substring(De);a(o1);const r1=t1+j.length+2;requestAnimationFrame(()=>{k.current&&k.current.setSelection(r1),N2(o1,r1)})}v(),k.current?.focus()},Np=(j,_e)=>{const s1=k.current?.getSelection().start??r.length,o1=r.substring(0,s1).lastIndexOf("#"),r1=o1!==-1?o1:s1,g1=`${r.substring(0,r1)}#${_e} ${r.substring(s1)}`;a(g1);const k1=r1+_e.length+2;requestAnimationFrame(()=>{k.current&&k.current.setSelection(k1),N2(g1,k1)}),v(),k.current?.focus()},Pp=j=>{a(`/${j.name} `),v();const _e=()=>{if(k.current){try{k.current.focus({preventScroll:!0})}catch{k.current.focus()}k.current.setSelection(k.current.getValue().length,k.current.getValue().length)}};requestAnimationFrame(()=>{_e(),requestAnimationFrame(_e)}),setTimeout(_e,60)};d.useEffect(()=>{E&&k.current&&!xe&&k.current.focus()},[E,xe]),d.useEffect(()=>{xe||S(null)},[xe]),d.useEffect(()=>{je&&je!==E&&Pe()},[je,E,Pe]),d.useEffect(()=>{I.current=!!(E||te)},[E,te]);const Ep=d.useCallback(j=>bj(j,u1||""),[u1]),Z5=j=>{if(!ur(j.dataTransfer))return;j.preventDefault(),j.stopPropagation(),R.current++;const _e=j.dataTransfer.types?.includes("application/x-pichamber-file-path")??!1;_e!==m&&p(_e),(E||te)&&!f&&h(!0)},F5=j=>{ur(j.dataTransfer)&&(j.preventDefault(),j.stopPropagation(),j.dataTransfer.dropEffect="copy",(E||te)&&!f&&h(!0))},zp=j=>{j.preventDefault(),j.stopPropagation(),R.current--,R.current<=0&&(R.current=0,h(!1),p(!1))},$5=()=>{R.current=0,h(!1),p(!1)},q5=async j=>{if(R.current=0,!ur(j.dataTransfer)||(j.preventDefault(),j.stopPropagation(),h(!1),!E&&!te))return;const De=j.dataTransfer.getData("application/x-pichamber-file-path");if(De&&De!=="."){l.current.add(De);const t1=`@${De}`,o1=k.current,r1=ge.current;if(o1){const{start:g1,end:k1}=o1.getSelection(),P2=r1.slice(0,g1),y2=r1.slice(k1),r2=P2.length>0&&!/\s$/.test(P2),p1=y2.length>0&&!/^\s/.test(y2),B1=`${r2?" ":""}${t1}${p1?" ":""}`;o1.replaceRange(g1,k1,B1),D.current=g1+B1.length,o1.focus()}else a(g1=>o7(g1,t1));return}const s1=Sj(j.dataTransfer);if(s1.length>0){let t1=!1;for(const o1 of s1)try{t1=await me(o1)||t1}catch(r1){console.error("File attach failed",r1)}t1||Ue.error("Failed to attach file")}},U5=j=>{ur(j.dataTransfer)&&j.preventDefault()},G5=d.useRef(null),W5=d.useCallback(async j=>{const _e=Array.isArray(j)?j:Array.from(j);let De=!1;for(const s1 of _e)try{De=await me(s1)||De}catch(t1){console.error("File attach failed",t1)}_e.length>0&&!De&&Ue.error("Failed to attach file")},[me]),Io=d.useCallback(()=>{G5.current?.click()},[]),Dp=d.useCallback(async j=>{const _e=j.target.files;_e&&(await W5(_e),j.target.value="")},[W5]),Rp="gap-x-1.5 gap-y-0",Op=!0,y0=(te||!!E)&&!Te,{projects:K5,selectedDraftProject:Q2,selectedDraftDirectory:os,selectedDraftBranchLabel:ka,selectedDraftBranchIsKnown:Y5,projectRootBranchOption:J5,draftBranchItems:Bo,shouldShowDraftBranchSelector:J0,handleDraftProjectChange:X5,handleDraftDirectoryChange:Q5}=Rj(y0),ec=!!(y0&&Q2&&(te||J0)),To=d.useMemo(()=>Te||v1!==!0||!L1||L1.isClean?!1:Gf(L1.files,L1.diffStats,ee).length>0,[ee,L1,v1,Te])?i.jsx(Xf,{align:ec?"end":"start"}):null;d.useEffect(()=>{!y0||!te||!Q2||!os||oe?.preserveDirectoryOverride||Bo.some(_e=>_e.value===os)||pe({projectId:Q2.id,directoryOverride:Q2.path})},[Bo,oe?.preserveDirectoryOverride,os,Q2,pe,y0]);const Pt=Oj({isMobile:xe,editorRef:k,formRef:H,setExpandedInput:Ne,alwaysExpanded:xe||Qe||M1,holders:{controlsPanelOpen:!!x,attachMenuOpen:C,draftPickerOpen:_!==null,issuePickerOpen:Ao,prPickerOpen:Ho,isDragging:f}}),Zp=Pt.expanded,Fp=Pt.focused,$p=d.useCallback(()=>{te||He(ee?{directoryOverride:ee}:void 0)},[te,He,ee]),tc=d.useCallback(()=>{w(!0),k.current?.blur()},[]);d.useEffect(()=>{N("")},[_]),Zj({isMobile:xe,isFullscreen:J2,isDraftScreen:te,isFocused:Fp,formRef:H,editorRef:k});const qp=xe?"px-1.5 py-1.5":be?"px-1.5 py-1":"px-3 py-2",Up=xe?"h-8 w-8":"h-6 w-6",Gp="h-4 w-4",nc=xe?"h-6 w-6":"h-5 w-5",Aa="h-[18px] w-[18px]",sc="flex cursor-pointer items-center justify-center text-foreground transition-none outline-none focus:outline-none flex-shrink-0 disabled:cursor-not-allowed",oc=B(sc,Up);return d.useEffect(()=>{const j=!!je&&je===E;!ko.current&&j&&!ke&&(jo(),E&&Ce(E)),ko.current=j},[je,Ce,E,ke,jo]),d.useEffect(()=>()=>{ct.current&&(clearTimeout(ct.current),ct.current=null)},[]),i.jsxs(i.Fragment,{children:[i.jsxs("form",{ref:H,onSubmit:j=>{j.preventDefault(),D5()},className:B("relative w-full pt-0 pb-4",Y2,J2&&"flex h-full min-h-0 flex-col pt-2",xe&&"bottom-safe-area oc-mobile-composer"),style:xe&&m2>0?{marginBottom:`${m2}px`}:void 0,children:[i.jsxs("div",{className:B("chat-input-column relative overflow-visible",o2&&"flex flex-1 min-h-0 flex-col"),children:[i.jsx(M4,{onShowPopup:g2}),i.jsx(Nf,{onEditMessage:kp,onSendMessage:Ap}),g0?i.jsx(lI,{terminalDrafts:Mt,reviewCount:ya,prCommentCount:Y0,prCheckCount:J1,previewConsoleCount:W0,previewAnnotationCount:ga,draftTarget:z1,onRemoveDraft:wt,onRemoveReviewDrafts:Cp,onRemovePreviewDrafts:ut,colors:c1.colors}):null,we?i.jsx(p7,{numberLabel:`#${we.number}`,title:we.title,url:we.url,author:we.author,openInBrowserLabel:"Open issue in browser",removeLabel:"Remove linked issue",onReopenPicker:()=>Qn(!0),onRemove:()=>ze(null)}):null,Ze?i.jsx(p7,{numberLabel:`PR #${Ze.number}`,title:Ze.title,url:Ze.url,author:Ze.author,branches:{head:Ze.head,base:Ze.base},openInBrowserLabel:"Open pull request in browser",removeLabel:"Remove linked pull request",onReopenPicker:()=>F(!0),onRemove:()=>x1(null)}):null,i.jsx(Oh,{sessionId:E,directory:ue??ee}),i.jsx(vI,{showAbortStatus:ke,showAssistantStatus:!1,showTodos:Op,leftAccessory:ec||te||!To?null:To}),!C1&&y0&&Q2&&(te||J0)?i.jsx(Gj,{projects:K5,selectedProject:Q2,selectedDirectory:os,selectedBranchLabel:ka,selectedBranchIsKnown:Y5,projectRootBranchOption:J5,branchItems:Bo,showBranchSelector:J0,showProjectSelector:te,endAccessory:To,onProjectChange:X5,onDirectoryChange:Q5,theme:c1}):null,C1&&y0&&Q2&&(te||J0)?i.jsx(Wj,{selectedProject:Q2,selectedBranchLabel:ka,showBranchSelector:J0,showProjectSelector:te,endAccessory:To,theme:c1,onOpenPicker:L}):null,i.jsx("div",{className:B(!xe&&"contents",xe&&"relative",J2&&"flex min-h-0 flex-1 flex-col"),children:xe&&!Zp?i.jsx(aI,{message:r,sessionId:E,directory:ue??ee,newSessionDraftOpen:te,canAbort:E5,footerIconButtonClass:oc,iconSizeClass:Aa,stopIconSizeClass:nc,theme:c1,onExpand:Pt.expand,onNewSession:$p,onPickLocalFiles:Io,onOpenIssuePicker:wa,onOpenPrPicker:Ma,onOpenAttachSheet:tc,onAbort:R5}):i.jsx(i.Fragment,{children:i.jsxs("div",{className:B("flex flex-col relative overflow-visible",o2&&"flex-1 min-h-0",d2&&!o2&&"min-h-[7rem]","border border-border/80","shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]","focus-within:ring-1",c==="shell"?"focus-within:ring-[color:color-mix(in_srgb,var(--status-info)_45%,transparent)]":"focus-within:ring-primary/30",f&&"ring-2 ring-primary ring-offset-2"),style:{borderRadius:Ge,backgroundColor:c1?.colors?.surface?.subtle},ref:P,onDropCapture:U5,onDragEnter:Z5,onDragOver:F5,onDragLeave:zp,onDrop:q5,onDragEnd:$5,children:[f&&i.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-background/90 rounded-xl",children:i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"inline-flex justify-center",children:i.jsx("button",{type:"button",className:sc,onClick:()=>Io(),title:"Attach files","aria-label":"Attach files",children:i.jsx(z,{name:"attachment-2",className:B(Aa,"text-current")})})}),i.jsx("p",{className:"mt-2 typography-ui-label text-muted-foreground",children:m?"Drop to insert as mention":"Drop files here to attach"})]})}),i.jsx(oI,{open:g,query:M,overlayPosition:null,commandRef:G,skillRef:K,snippetRef:W,mentionRef:q,onCommandSelect:Pp,onSkillSelect:Vp,onSnippetSelect:Np,onFileSelect:Bp,onAgentSelect:Tp,onClose:v}),i.jsx(iI,{isMobile:xe,isInline:be,alignToolsEnd:B2>1,sessionId:E,directory:ue??ee,newSessionDraftOpen:te,messageLength:r.length,leadingExtra:d2||xe?i.jsx(b7,{keepLabels:!0,className:"w-max shrink-0",mobilePanel:xe?x:void 0,onMobilePanelChange:xe?S:void 0}):null,radius:Ge,footerPaddingClass:qp,footerGapClass:Rp,footerIconButtonClass:oc,iconSizeClass:Aa,sendIconSizeClass:Gp,stopIconSizeClass:nc,canSend:_p,canAbort:E5,hasContent:!!ba,onOpenSettings:e,onPickLocalFiles:Io,onOpenIssuePicker:wa,onOpenPrPicker:Ma,onOpenAttachSheet:tc,onPrimaryAction:D5,onQueueMessage:ss,onAbort:R5,children:i.jsxs("div",{className:B("overflow-hidden",o2&&"flex flex-1 min-h-0 flex-col"),children:[i.jsx("div",{className:B("relative z-10 flex flex-wrap items-center gap-1",be?"px-0":"px-3 pt-1"),children:i.jsx(M4,{onShowPopup:g2})}),i.jsx("div",{className:B("relative overflow-hidden",o2&&"flex flex-1 min-h-0 flex-col"),onDragEnter:Z5,onDragOver:F5,onDropCapture:U5,onDrop:q5,onDragEnd:$5,children:i.jsx(lj,{ref:k,viewStore:V,"data-testid":"chat-input",value:r,languageContext:m0,onChange:jp,onKeyDown:j=>(Hp(j),j.defaultPrevented),onPaste:Ip,onSelectionChange:j=>{D.current=j.start,Lp()},onVisualLineCount:j=>{lt(_e=>_e===j?_e:j)},onFocus:Pt.onEditorFocus,onBlur:Pt.onEditorBlur,placeholder:E||te?c==="shell"?"Enter shell command...":_2?"Plan, build, / for skills, @ for context":b1?"Use @ / ! # for helpers":"@ for files/agents; / for commands and skills; ! for shell; # for snippets":"Select or create a session to start chatting",editable:!!(E||te),autoCorrect:!1,autoCapitalize:"none",spellCheck:xe||F1,fillContainer:o2,maxLines:xe?uI:dI,boundSelector:xe?"[data-composer-bound]":void 0,boundGapPx:fI,className:B("relative z-10",be?"min-h-0 px-1.5 py-1.5":"min-h-[52px] px-3",o2?B("h-full min-h-0",xe?"py-2.5":"py-4"):xe?"py-2.5":be?void 0:"pt-3 pb-2",c==="shell"?"font-mono":"typography-markdown md:typography-ui-label")})})]})})]})})}),d2||xe?null:i.jsx("div",{className:"mt-1.5 flex w-full shrink-0 items-center pl-2",children:i.jsx(b7,{className:"w-full min-w-0"})})]}),te&&!Y2&&!xe&&!Te?i.jsx(ph,{onSubmit:j=>Ca(j.submitText,j.ref.type),className:"chat-input-column mt-3"}):null]}),i.jsx(WA,{open:Ao,onOpenChange:Qn,mode:"select",onSelect:j=>{ze(j),x1(null)}}),i.jsx(JA,{open:Ho,onOpenChange:F,onSelect:j=>{x1(j),ze(null)}}),S2?i.jsx(d.Suspense,{fallback:null,children:i.jsx(cI,{popup:Y1,onOpenChange:e2,isMobile:xe})}):null,i.jsx("input",{ref:G5,type:"file",multiple:!0,className:"hidden",onChange:Dp,accept:gM}),xe?i.jsx(t0,{open:C,title:"Add attachment",onClose:()=>w(!1),children:i.jsxs("div",{className:"flex flex-col px-3 pb-4 pt-1",children:[i.jsxs("button",{type:"button",className:"flex w-full cursor-pointer items-center gap-2.5 rounded-lg px-2 py-3 text-left typography-ui-label hover:bg-[var(--interactive-hover)]",onClick:()=>{Pt.cancelOverlayCloseRestore(),w(!1),requestAnimationFrame(Io)},children:[i.jsx(z,{name:"attachment-2",className:"h-[18px] w-[18px] flex-shrink-0 text-muted-foreground"}),"Attach files"]}),i.jsxs("button",{type:"button",className:"flex w-full cursor-pointer items-center gap-2.5 rounded-lg px-2 py-3 text-left typography-ui-label hover:bg-[var(--interactive-hover)]",onClick:()=>{Pt.skipNextOverlayCloseRestore(),w(!1),requestAnimationFrame(wa)},children:[i.jsx(z,{name:"github",className:"h-[18px] w-[18px] flex-shrink-0 text-muted-foreground"}),"Link GitHub Issue"]}),i.jsxs("button",{type:"button",className:"flex w-full cursor-pointer items-center gap-2.5 rounded-lg px-2 py-3 text-left typography-ui-label hover:bg-[var(--interactive-hover)]",onClick:()=>{Pt.skipNextOverlayCloseRestore(),w(!1),requestAnimationFrame(Ma)},children:[i.jsx(z,{name:"git-pull-request",className:"h-[18px] w-[18px] flex-shrink-0 text-muted-foreground"}),"Link GitHub PR"]})]})}):null,C1&&y0&&Q2?i.jsx(Kj,{projects:K5,selectedProject:Q2,selectedDirectory:os,selectedBranchLabel:ka,selectedBranchIsKnown:Y5,projectRootBranchOption:J5,branchItems:Bo,showBranchSelector:J0,showProjectSelector:te,onProjectChange:X5,onDirectoryChange:Q5,theme:c1,openPicker:_,onOpenPickerChange:L,query:A,onQueryChange:N}):null]})};Zh.displayName="ChatInput";const bs=d.memo(Zh),Fh=W1()(()=>({ready:!0,error:null})),xI=({isNewSession:e=!1})=>{const{currentTheme:t}=Nt(),n=Fh(o=>o.error),s=t?.colors?.surface?.mutedForeground||"var(--muted-foreground)";return i.jsxs("div",{className:"flex flex-col items-center justify-center min-h-full w-full gap-6",children:[i.jsx(R3,{width:120,height:120,isAnimated:!e,className:e?"opacity-20":void 0}),n?i.jsxs("div",{className:"flex flex-col items-center gap-2 max-w-md text-center px-4",children:[i.jsx("span",{className:"text-body-md font-medium text-destructive",children:"PiChamber is not reachable"}),i.jsx("span",{className:"text-body-sm",style:{color:s},children:typeof n=="string"?n:n?.message||String(n)})]}):e?i.jsx("span",{className:"text-body-md",style:{color:s},children:"Start a new chat"}):null]})},x7=d.memo(xI);class B0{static instance;sessionStartTimes=new Map;seenMessageIds=new Set;messageCreationTimes=new Map;constructor(){}static getInstance(){return B0.instance||(B0.instance=new B0),B0.instance}recordSessionStart(t){this.sessionStartTimes.set(t,Date.now())}getSessionStartTime(t){return this.sessionStartTimes.get(t)}shouldAnimateMessage(t,n){if(t.role!=="assistant"||this.seenMessageIds.has(t.id))return!1;const s=this.sessionStartTimes.get(n);if(!s)return this.seenMessageIds.add(t.id),this.messageCreationTimes.set(t.id,t.time.created),!1;const o=t.time.created>s-5e3;return this.seenMessageIds.add(t.id),this.messageCreationTimes.set(t.id,t.time.created),o}clearSession(t){this.sessionStartTimes.delete(t)}hasSessionTiming(t){return this.sessionStartTimes.has(t)}hasBeenAnimated(t){return this.seenMessageIds.has(t)}markMessageAsAnimated(t,n){this.seenMessageIds.add(t),this.messageCreationTimes.set(t,n)}clearAll(){this.sessionStartTimes.clear(),this.seenMessageIds.clear(),this.messageCreationTimes.clear()}getDebugInfo(){return{sessionStartTimes:new Map(this.sessionStartTimes),seenMessageIds:new Set(this.seenMessageIds),messageCreationTimes:new Map(this.messageCreationTimes)}}}const E4="#pichamber-skill:",z4="#pichamber-agent:",wI=e=>`https://opencode.ai/docs/agents/#${encodeURIComponent(e)}`,MI=e=>`${E4}${encodeURIComponent(e)}`,CI=e=>`${z4}${encodeURIComponent(e)}`,SI=e=>{if(!e?.startsWith(E4))return null;try{return decodeURIComponent(e.slice(E4.length))}catch{return null}},rF=e=>{if(!e?.startsWith(z4))return null;try{return decodeURIComponent(e.slice(z4.length))}catch{return null}},D4=/(^|\s)\/([a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?)/g,_I=/(```[\s\S]*?```|~~~[\s\S]*?~~~)/g,kI=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;"),$h=(e,t)=>e.split(_I).map((n,s)=>s%2===1?n:t(n)).join(""),AI=e=>$h(e,t=>t.replace(/ *\n/g,`
@@ -6988,7 +6988,7 @@ ${o}`);if(c)return[{id:`${n}-0`,title:s(t),patch:c.patch,renderMode:"diff"}]}ret
6988
6988
  `),r=o.length,a=o.map(l=>`+${l}`).join(`
6989
6989
  `);return["--- /dev/null",`+++ b/${s}`,`@@ -0,0 +1,${r} @@`,a].join(`
6990
6990
  `)},Li=e=>{const t=e.trim().replace(/\\/g,"/").replace(/\/{2,}/g,"/");return!t||t==="/"?t:t.replace(/\/+$/,"")},mt=(e,t)=>{const n=Li(e),s=Li(t);if(!n)return"";if(!s)return n;if(n===s)return".";const o=`${s}/`;return n.startsWith(o)?n.slice(o.length):n},kT=5,no=e=>typeof e=="object"&&e!==null,AT=e=>{if(!no(e))return null;const t=typeof e.message=="string"?e.message.trim():"";if(!t)return null;const n=typeof e.severity=="number"&&Number.isFinite(e.severity)?Math.trunc(e.severity):void 0;if(n!==void 0&&n!==1)return null;const s=no(e.range)?e.range:void 0,o=s&&no(s.start)?s.start:void 0,r=typeof o?.line=="number"&&Number.isFinite(o.line)?Math.max(0,Math.trunc(o.line)):0,a=typeof o?.character=="number"&&Number.isFinite(o.character)?Math.max(0,Math.trunc(o.character)):0;return{message:t,line:r+1,character:a+1}},HT=(e,t,n,s)=>{if(!["edit","multiedit","write","apply_patch"].includes(e))return null;const o=p5(e,t,n);if(!o||!n||!no(n.diagnostics))return null;const r=Li(o),a=r.startsWith("/")?r:`${Li(s)}/${r}`.replace(/\/+/g,"/"),l=n.diagnostics[r]??n.diagnostics[a];if(!Array.isArray(l))return null;const c=l.map(f=>AT(f)).filter(f=>!!f);if(c.length===0)return null;const u=c.slice(0,kT);return{displayPath:r.startsWith("/")?mt(r,s):r,diagnostics:u,remaining:Math.max(0,c.length-u.length)}},LT=e=>{const t=e.match(/^User has answered your questions:\s*(.+?)\.\s*You can now/s);if(!t)return null;const n=[],s=t[1],o=/"([^"]+)"="([^"]*(?:[^"\\]|\\.)*)"/g;let r;for(;(r=o.exec(s))!==null;)n.push({question:r[1],answer:r[2]});return n.length>0?n:null},bm=(e,t,n)=>{const s=t,o=s.metadata,r=s.input;if(e.tool==="apply_patch"){const a=Array.isArray(o?.files)?o?.files:[],l=a[0],c=l?.relativePath||l?.filePath;return a.length>1?null:typeof c=="string"?mt(c,n):null}if((e.tool==="edit"||e.tool==="multiedit")&&r){const a=r?.filePath||r?.file_path||r?.path||o?.filePath||o?.file_path||o?.path;if(typeof a=="string")return mt(a,n)}if(e.tool==="read"&&r){const a=r?.filePath||r?.file_path||r?.path||o?.filePath||o?.file_path||o?.path;if(typeof a=="string")return mt(a,n)}if(e.tool&&["write","create","file_write"].includes(e.tool)&&r){const a=r?.filePath||r?.file_path||r?.path;if(typeof a=="string")return mt(a,n)}if(e.tool==="lsp"&&r){const a=r?.filePath||r?.file_path||r?.path;if(typeof a=="string")return mt(a,n)}return null},jT=(e,t)=>{if(!e)return"";const n=typeof e.operation=="string"?e.operation:"lsp";if(n==="workspaceSymbol"){const c=typeof e.query=="string"&&e.query.trim().length>0?` "${e.query.trim()}"`:"";return`${n}${c}`}const s=typeof e.filePath=="string"?e.filePath:typeof e.file_path=="string"?e.file_path:typeof e.path=="string"?e.path:"",o=s?mt(s,t):"";if(n==="documentSymbol")return o?`${n} ${o}`:n;const r=typeof e.line=="number"&&Number.isFinite(e.line)?Math.trunc(e.line):void 0,a=typeof e.character=="number"&&Number.isFinite(e.character)?Math.trunc(e.character):void 0,l=r!==void 0&&a!==void 0?`:${r}:${a}`:"";return o?`${n} ${o}${l}`:n},IT=(e,t,n)=>{const s=t,o=s.metadata,r=s.input,a=bm(e,t,n);if(a)return a;if(e.tool==="apply_patch"){const c=Array.isArray(o?.files)?o?.files:[];return c.length>1?`${c.length} files`:""}if(e.tool==="question"&&r?.questions&&Array.isArray(r.questions)){const c=r.questions.length;return`Asked ${c} question${c!==1?"s":""}`}if(e.tool==="bash"&&r?.command&&typeof r.command=="string")return r.command.split(`
6991
- `)[0].substring(0,100);if(e.tool==="task"&&r?.description&&typeof r.description=="string")return r.description.substring(0,80);if(e.tool==="lsp")return jT(r,n);const l=r?.description||o?.description||"title"in t&&t.title||"";return pT(e.tool,l,r)},v5=({children:e,maxHeightClass:t="max-h-[60vh]",className:n,outerClassName:s,disableHorizontal:o=!1,followKey:r})=>{const a=d.useRef(null),l=d.useRef(!0);return d.useLayoutEffect(()=>{const c=a.current;if(r===void 0){l.current=!0;return}!c||!l.current||(c.scrollTop=c.scrollHeight)},[r]),i.jsx("div",{className:B("w-full min-w-0 flex-none overflow-hidden",s),children:i.jsx(Yi,{ref:a,"data-scrollable":"true",onWheelCapture:c=>{r!==void 0&&c.deltaY<0&&(l.current=!1)},onScroll:c=>{if(r===void 0)return;const u=c.currentTarget;l.current=u.scrollHeight-u.scrollTop-u.clientHeight<=2},className:B("tool-output-surface p-2 rounded-xl w-full min-w-0",t,o?"overflow-y-auto overflow-x-hidden":"overflow-auto",n),children:i.jsx("div",{className:"w-full min-w-0",children:e})})})},BT=(e,t,n,s)=>t.tool==="bash"?"bash":WI(Uh(e,t.tool||"",n),t.tool||"",s),TT=(e,t,n)=>t.tool==="bash"?e:Uh(e,t.tool||"",n),VT=({output:e})=>{const t=d.useRef(null),n=d.useRef("");return d.useLayoutEffect(()=>{const s=t.current;if(!s)return;const o=s.firstChild,r=o instanceof globalThis.Text?o:document.createTextNode("");r!==o&&s.replaceChildren(r);const a=uT(e,mm),l=dT(n.current,a);l===void 0?r.data=a:l.length>0&&r.appendData(l),n.current=a},[e]),i.jsx("pre",{ref:t,className:"m-0 whitespace-pre-wrap break-words",style:{...K4,lineHeight:"round(var(--code-block-line-height), 1px)",overflowWrap:"break-word"}})},W4=({output:e,part:t,metadata:n,input:s,isStreaming:o=!1})=>{const r=TT(e,t,n),a=BT(e,t,n,s),l=d.useMemo(()=>$I(r),[r]),[c,u]=d.useState("summary"),[f,h]=d.useState(!1);d.useEffect(()=>{u("summary"),h(!1)},[r]);const m=d.useCallback((g,y)=>{y.stopPropagation(),u(g)},[]),p=d.useCallback(async g=>{if(g.stopPropagation(),!(await gt(r)).ok){Ue.error("Failed to copy output");return}h(!0),typeof window<"u"&&window.setTimeout(()=>h(!1),1200)},[r]);return t.tool==="bash"&&o?i.jsx("div",{className:"typography-code text-muted-foreground/90",children:i.jsx(VT,{output:r})}):l.isJson?i.jsxs("div",{className:"tool-output-surface relative p-2 rounded-xl w-full min-w-0",children:[i.jsxs("div",{className:"absolute right-2 top-2 z-10 flex items-center gap-1",children:[i.jsx(a1,{variant:"ghost",size:"icon",className:B("h-6 w-6 rounded-md text-muted-foreground hover:text-foreground",c==="summary"&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),onClick:g=>m("summary",g),onPointerDown:g=>g.stopPropagation(),"aria-label":"Show navigable JSON",title:"Show navigable JSON",children:i.jsx(z,{name:"list-unordered",className:"h-3.5 w-3.5"})}),i.jsx(a1,{variant:"ghost",size:"icon",className:B("h-6 w-6 rounded-md text-muted-foreground hover:text-foreground",c==="formatted"&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),onClick:g=>m("formatted",g),onPointerDown:g=>g.stopPropagation(),"aria-label":"Show formatted JSON",title:"Show formatted JSON",children:i.jsx(z,{name:"node-tree",className:"h-3.5 w-3.5"})}),i.jsx(a1,{variant:"ghost",size:"icon",className:B("h-6 w-6 rounded-md text-muted-foreground hover:text-foreground",c==="raw"&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),onClick:g=>m("raw",g),onPointerDown:g=>g.stopPropagation(),"aria-label":"Show raw JSON",title:"Show raw JSON",children:i.jsx(z,{name:"code-box",className:"h-3.5 w-3.5"})}),i.jsx(a1,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-md bg-[var(--surface-elevated)]/80 text-muted-foreground hover:text-foreground",onClick:p,onPointerDown:g=>g.stopPropagation(),"aria-label":f?"Copied output":"Copy output",title:f?"Copied output":"Copy output",children:i.jsx(z,{name:f?"check":"file-copy",className:"h-3.5 w-3.5"})})]}),c==="summary"?i.jsx(Wh,{data:l.data}):c==="formatted"?i.jsx(aB,{data:l.data,initiallyExpandedDepth:1,maxHeight:"400px"}):i.jsx("div",{className:"typography-code pr-12 text-muted-foreground/90",children:i.jsx(Si,{language:"json",code:r,style:K4,codeStyle:Y7.style,wrap:!0})})]}):i.jsx("div",{className:t.tool==="bash"?"typography-code text-muted-foreground/90":void 0,children:i.jsx(Si,{language:a,code:r,style:K4,codeStyle:Y7.style,wrap:!0})})};W4.displayName="ToolScrollableTextOutput";const xm=e=>{const t=e.state?.title;if(typeof t=="string"&&t.trim().length>0)return t;const n=e.state?.input;if(n&&typeof n=="object"){const s=n.filePath??n.file_path??n.path;if(typeof s=="string"&&s.trim().length>0)return s.trim();const o=n.url;if(typeof o=="string"&&o.trim().length>0)return o.trim()}return""},NT=new Set(["read","view","file_read","cat","write","create","file_write","edit","multiedit","apply_patch"]),PT=(e,t)=>{if(!NT.has(e.toLowerCase()))return!1;const n=t.trim();if(!n||n==="Patch"||/^\d+\s+files$/.test(n))return!1;if(n.includes("/")||n.includes("\\"))return!0;const s=n.split(/[\\/]/).pop()||n;return s.startsWith(".")||s.includes(".")?!0:/^[A-Za-z0-9_-]+$/.test(s)},Gn=e=>{const t=ha(e.tool),n=e.state?.status??"",s=xm(e);return`${e.id??""}${t}${n}${s}`},ET=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(Gn(e[n])!==Gn(t[n]))return!1;return!0},wm=d.memo(({entry:e,isMobile:t,animateTailText:n,showToolFileIcons:s})=>{const o=ha(e.tool),r=o.length>0?o:"tool",a=xm(e),l=a.trim().length>0,c=e.state?.status,u=wo(r).displayName;return i.jsx(ho,{animate:n,wipe:!0,children:i.jsxs("div",{className:B("flex gap-2 min-w-0 w-full",c==="error"&&t?"items-start":"items-center"),children:[i.jsx("span",{className:"flex-shrink-0 text-foreground/80",children:mo(r)}),i.jsx("span",{className:"typography-meta text-foreground/80 flex-shrink-0",style:{color:"var(--tools-title)"},title:u,children:u}),l?c!=="error"&&PT(r,a)?Y4(a,n,!0,s):c==="error"?i.jsx("span",{className:B("typography-meta flex-1 min-w-0 text-[var(--status-error)]",t?"whitespace-normal break-words":"truncate"),children:a}):i.jsx(Vt,{variant:n?"generate-effect":"static",className:"typography-meta flex-1 min-w-0 truncate text-muted-foreground/70",style:{color:"var(--tools-description)"},title:a,children:a}):null]})})},(e,t)=>e.isMobile===t.isMobile&&e.animateTailText===t.animateTailText&&e.showToolFileIcons===t.showToolFileIcons&&Gn(e.entry)===Gn(t.entry));wm.displayName="TaskSummaryEntryRow";const Mm=d.memo(({entries:e,isExpanded:t,isMobile:n,animateTailText:s,showToolFileIcons:o})=>{const r=t?e:e.slice(-6),a=Math.max(0,e.length-r.length),l=e.length-r.length;return i.jsx(v5,{maxHeightClass:t?"max-h-[40vh]":"max-h-56",disableHorizontal:!0,children:i.jsxs("div",{className:"w-full min-w-0 space-y-1",children:[a>0?i.jsxs("div",{className:"typography-micro text-muted-foreground/70",children:["+",a," more…"]}):null,r.map((c,u)=>{const f=t?u:l+u,h=c.id??`${Gn(c)}:${f}`;return i.jsx(wm,{entry:c,isMobile:n,animateTailText:s,showToolFileIcons:o},h)})]})})},(e,t)=>e.isExpanded===t.isExpanded&&e.isMobile===t.isMobile&&e.animateTailText===t.animateTailText&&e.showToolFileIcons===t.showToolFileIcons&&ET(e.entries,t.entries));Mm.displayName="TaskSummaryEntriesList";const zT=({entries:e,isExpanded:t,isMobile:n,output:s,sessionId:o,onShowPopup:r,input:a,animateTailText:l=!0,isActive:c=!1})=>{const u=bt(),f=Be(v=>v.setCurrentSession),h=he(v=>v.showToolFileIcons),m=typeof s=="string"?xB(s):"",p=m.length>0,[g,y]=d.useState(!1),M=v=>{v.stopPropagation(),o&&u&&f(o,u)},b=typeof a?.subagent_type=="string"?a.subagent_type:"subagent";return e.length===0&&!p&&!o?i.jsx("div",{className:"relative pr-2 pb-2 pt-2 space-y-2 pl-[1.4375rem]",children:i.jsx("div",{className:"typography-meta text-muted-foreground/70",children:c?"Waiting for subagent activity...":"No subagent session id on task metadata."})}):i.jsxs("div",{className:B("relative pr-2 pb-2 pt-2 space-y-2 pl-[1.4375rem]",'before:absolute before:left-[0.4375rem] before:w-px before:bg-border/80 before:content-[""]',"before:top-[-0.25rem] before:bottom-0"),children:[e.length>0?i.jsx(Mm,{entries:e,isExpanded:t,isMobile:n,animateTailText:l,showToolFileIcons:h}):null,o&&i.jsxs("button",{type:"button",className:"flex items-center gap-2 typography-meta text-primary hover:text-primary/80 w-full",onPointerDown:v=>v.stopPropagation(),onClick:M,children:[i.jsx(z,{name:"external-link",className:"h-3.5 w-3.5 flex-shrink-0"}),i.jsx("span",{className:"typography-meta text-primary font-medium",children:`Open ${b.charAt(0).toUpperCase()+b.slice(1)} subtask`})]}),p?i.jsxs("div",{className:B("space-y-1",(e.length>0||o)&&"pt-1"),children:[i.jsxs("button",{type:"button",className:"flex items-center gap-2 typography-meta text-foreground/80 hover:text-foreground w-full",onPointerDown:v=>v.stopPropagation(),onClick:v=>{v.stopPropagation(),y(x=>!x)},children:[g?i.jsx(z,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0"}):i.jsx(z,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0"}),i.jsx("span",{className:"typography-meta text-foreground/80 font-medium",children:"Output"})]}),g?i.jsx(v5,{maxHeightClass:"max-h-[50vh]",children:i.jsx("div",{className:"w-full min-w-0",children:i.jsx(xo,{content:m,variant:"tool",onShowPopup:r})})}):null]}):null]})},K4={...qg.getCollapsedStyles(),padding:0,overflow:"visible"},Y7={style:{background:"transparent",backgroundColor:"transparent"}},Cm={color:"var(--status-error)"},DT={color:"var(--tools-icon)"},Sm={color:"var(--status-error)"},RT={color:"var(--tools-title)"},J7=(e,t=!0)=>{const n=e.lastIndexOf("/");if(n===-1)return i.jsx("span",{className:B("min-w-0 truncate typography-ui-label text-foreground",t&&"flex-1"),style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:e,children:e});const s=e.slice(0,n),o=e.slice(n+1),r=s.startsWith("/"),a=r?s.slice(1):s;return i.jsxs("span",{className:B("min-w-0 flex items-baseline overflow-hidden typography-ui-label",t&&"flex-1"),title:e,children:[r?i.jsx("span",{className:"flex-shrink-0 text-muted-foreground",children:"/"}):null,i.jsx("span",{className:"min-w-0 truncate text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:a}),i.jsxs("span",{className:"flex-shrink-0",children:[i.jsx("span",{className:"text-muted-foreground",children:"/"}),i.jsx("span",{className:"text-foreground",children:o})]})]})},Y4=(e,t=!0,n=!0,s=!0)=>{const o=e.lastIndexOf("/");if(o===-1)return i.jsxs("span",{className:B("min-w-0 inline-flex items-center gap-1 overflow-hidden",n&&"flex-1"),title:e,children:[s?i.jsx(Tt,{filePath:e,className:"h-3.5 w-3.5 flex-shrink-0"}):null,i.jsx(Vt,{variant:t?"generate-effect":"static",className:B("min-w-0 truncate whitespace-nowrap",Gt,n&&"flex-1"),style:{color:"var(--tools-title)"},children:e})]});const r=e.slice(0,o),a=e.slice(o+1),l=r.startsWith("/"),c=l?r.slice(1):r;return i.jsxs("span",{className:B("min-w-0 inline-flex items-center gap-1 overflow-hidden",n&&"flex-1"),title:e,children:[s?i.jsx(Tt,{filePath:e,className:"h-3.5 w-3.5 flex-shrink-0"}):null,i.jsxs("span",{className:B("min-w-0 inline-flex max-w-full items-baseline overflow-hidden",Gt,n&&"flex-1"),children:[l?i.jsx("span",{className:"flex-shrink-0",style:{color:"var(--tools-description)"},children:"/"}):null,i.jsx("span",{className:"min-w-0 shrink truncate whitespace-nowrap",style:{color:"var(--tools-description)",direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:c}),i.jsx("span",{className:"flex-shrink-0",style:{color:"var(--tools-description)"},children:"/"}),i.jsx(Vt,{variant:t?"generate-effect":"static",className:"flex-shrink-0",style:{color:"var(--tools-title)"},children:a})]})]})},OT=bo(()=>V2(()=>import("./ToolPartDiffPreview-CfnliaE9.js"),__vite__mapDeps([130,1,2,125,112,113,25,114,26,27,28,29,30,31,32,33,34,35,36,37,38,39,115,23,24,116,117,118,119,120,121,122,123,126,127,128,129,22,13,6,14,40,41,42,43,44,45,46,15,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,7,108,109]))),X7=({diff:e,diffViewMode:t})=>i.jsx(d.Suspense,{fallback:i.jsx(qh,{diff:e}),children:i.jsx(OT,{diff:e,diffViewMode:t})}),_m=d.memo(({part:e,state:t,currentDirectory:n,isExpanded:s,onShowPopup:o})=>{const r=e5(),[a,l]=d.useState("unified"),c=t,u=c.metadata,f=c.input,h=cT(e.tool||"",c.output,u?.output,t.status),m=typeof h=="string"&&h.length>0,p=typeof h=="string"?h:"",g=e.tool==="bash"&&t.status==="running",y=g5({text:p,isStreaming:g,identityKey:e.id,allowTextReplacement:g}),M=g?y:p,b=c.attachments,v=no(u?.filediff)?u.filediff:void 0,x=x2(u?.patch)??x2(u?.diff)??x2(v?.patch)??x2(v?.diff)??null,S=d.useMemo(()=>iT(u,x??void 0,O=>mt(O,n)),[n,x,u]),C=S.some(O=>O.renderMode==="diff"),w=e.tool==="pichamber"||e.tool==="apply_patch"||e.tool==="edit"||e.tool==="multiedit",_=d.useMemo(()=>HT(e.tool||"",f,u,n),[n,f,u,e.tool]),L=d.useMemo(()=>!f||typeof f!="object"||Object.keys(f).length===0?"":"command"in f&&typeof f.command=="string"&&e.tool==="bash"?S7(f,e.tool):typeof f.content=="string"?f.content??"":S7(f,e.tool),[f,e.tool]),A=!w&&L.trim().length>0,N=e.tool==="write"||e.tool==="create"||e.tool==="file_write",k=e.tool==="todowrite"||e.tool==="todoread",V=d.useMemo(()=>Array.isArray(f?.todos)?JSON.stringify(f.todos):M,[f?.todos,M]),H=d.useMemo(()=>{if(!N||!A)return;const O=typeof f?.filePath=="string"?f.filePath:typeof f?.file_path=="string"?f.file_path:typeof f?.path=="string"?f.path:void 0;return _T(O,L)},[A,f?.filePath,f?.file_path,f?.path,L,N]);d.useEffect(()=>{l("unified")},[e.id]);const D=(O,I)=>i.jsx(v5,{maxHeightClass:I?.maxHeightClass,className:I?.className,disableHorizontal:I?.disableHorizontal,outerClassName:I?.outerClassName,followKey:I?.followKey,children:O}),P=()=>{const O=K=>Co(n,K.filePath??K.title),I=(K,W)=>{W.stopPropagation();const ge=eo(K.patch),Z=O(K);he.getState().openContextFileAtLine(n,Z,ge??1,1),r?.openFiles()},q=(K,W)=>{W.stopPropagation();const ge=O(K),Z=he.getState(),fe=mt(ge,n);if(Z.isMobile){Z.navigateToDiff(fe);return}Z.openContextDiff(n,fe)},G=()=>_?i.jsxs("div",{className:"tool-output-surface rounded-xl border p-2 space-y-2",style:{borderColor:"var(--status-error-border)",backgroundColor:"var(--status-error-background)"},children:[i.jsx("div",{className:"typography-meta font-medium",style:{color:"var(--status-error)"},children:"LSP errors"}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("div",{className:"flex items-center gap-1 min-w-0",children:J7(_.displayPath,!1)}),i.jsx("div",{className:"space-y-1",children:_.diagnostics.map((K,W)=>i.jsx("div",{className:"rounded-md border px-2 py-1",style:{borderColor:"var(--status-error-border)",backgroundColor:"var(--surface-elevated)"},children:i.jsxs("div",{className:"flex items-start gap-2 min-w-0",children:[i.jsxs("span",{className:"typography-micro shrink-0",style:{color:"var(--status-error)"},children:["[",K.line,":",K.character,"]"]}),i.jsx("span",{className:"typography-meta text-foreground whitespace-pre-wrap break-words",children:K.message})]})},`${_.displayPath}:${K.line}:${K.character}:${W}`))}),_.remaining>0?i.jsx("div",{className:"typography-micro text-muted-foreground",children:`+${_.remaining} more errors`}):null]})]}):null;if(e.tool==="question"){if(t.status==="completed"&&m){const W=LT(M);if(W&&W.length>0)return D(i.jsx("div",{className:"space-y-2",children:W.map((ge,Z)=>i.jsxs("div",{className:"space-y-0.5",children:[i.jsx("div",{className:"typography-micro text-muted-foreground",children:ge.question}),i.jsx("div",{className:"typography-meta text-foreground whitespace-pre-wrap",children:ge.answer})]},Z))}),{maxHeightClass:"max-h-[40vh]"})}if(t.status==="error"&&"error"in t)return i.jsxs("div",{children:[i.jsx("div",{className:"typography-meta font-medium text-muted-foreground mb-1",children:"Error:"}),i.jsx("div",{className:"typography-meta p-2 rounded-xl border",style:{backgroundColor:"var(--status-error-background)",color:"var(--status-error)",borderColor:"var(--status-error-border)"},children:F2(t.error)})]});const K=f;return K?.questions&&Array.isArray(K.questions)&&K.questions.length>0?D(i.jsx("div",{className:"space-y-2",children:K.questions.map((W,ge)=>i.jsxs("div",{className:"space-y-0.5",children:[W.header?i.jsx("div",{className:"typography-micro text-muted-foreground",children:F2(W.header)}):null,i.jsx("div",{className:"typography-meta text-foreground",children:F2(W.question)}),Array.isArray(W.options)&&W.options.length>0?i.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:W.options.map(Z=>i.jsx("span",{className:"typography-micro px-1.5 py-0.5 rounded bg-muted/30 border border-border/30 text-muted-foreground",children:F2(Z.label)},F2(Z.label)))}):null]},ge))}),{maxHeightClass:"max-h-[40vh]"}):i.jsx("div",{className:"typography-meta text-muted-foreground",children:"Awaiting response..."})}if(e.tool==="task"&&m)return D(i.jsx("div",{className:"w-full min-w-0",children:i.jsx(xo,{content:F2(M),variant:"tool",onShowPopup:o})}));if((e.tool==="edit"||e.tool==="multiedit"||e.tool==="apply_patch"||e.tool==="write")&&(S.length>0||_))return D(i.jsxs("div",{className:"space-y-3",children:[S.map(K=>i.jsxs("div",{className:"w-full min-w-0",children:[i.jsxs("div",{className:"mb-1 flex min-w-0 items-center gap-1 px-2 py-1",children:[i.jsx("div",{className:"min-w-0 flex-1 typography-meta font-medium text-muted-foreground",children:J7(K.title)}),i.jsx(a1,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 text-muted-foreground hover:text-foreground",onClick:W=>I(K,W),"aria-label":"Open file at first change",title:"Open file at first change",children:i.jsx(z,{name:"file-edit",className:"h-3.5 w-3.5"})}),i.jsx(a1,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 text-muted-foreground hover:text-foreground",onClick:W=>q(K,W),"aria-label":"Open file diff",title:"Open file diff",children:i.jsx(z,{name:"git-pull-request",className:"h-3.5 w-3.5"})})]}),K.renderMode==="diff"?i.jsx(X7,{diff:K.patch,diffViewMode:a}):i.jsx(qh,{diff:K.patch})]},K.id)),G()]}),{className:"p-1"});if(e.tool==="write"&&_)return D(i.jsx("div",{className:"space-y-3",children:G()}),{className:"p-1"});if(N)return null;if(m&&M.trim()){const K=i.jsx(W4,{output:F2(M),part:e,metadata:u,input:f,isStreaming:g});return D(K,{className:e.tool==="bash"?"p-1 rounded-none":"p-1",maxHeightClass:g?"max-h-64":e.tool==="bash"?"max-h-[46vh]":void 0,followKey:g?M:void 0})}return D(i.jsx("div",{className:"typography-meta text-muted-foreground/70",children:"No output produced"}),{maxHeightClass:"max-h-60"})},R=M.trim().length>0,$=t.status==="completed"&&"output"in t||e.tool==="bash"&&R;if(k){if(t.status==="error"&&"error"in t)return i.jsxs("div",{className:"relative pr-2 pb-2 pt-2 space-y-2 pl-4",children:[i.jsx("div",{className:"typography-meta font-medium text-muted-foreground/80 mb-1",children:"Error:"}),i.jsx("div",{className:"typography-meta p-2 rounded-xl border",style:{backgroundColor:"var(--status-error-background)",color:"var(--status-error)",borderColor:"var(--status-error-border)"},children:t.error})]});const O=GI(V,{total:"Total",inProgress:"In Progress",pending:"Pending",completed:"Completed",cancelled:"Cancelled"},{unstyled:!0});return i.jsx("div",{className:"relative pr-2 pb-2 pt-2 space-y-2 pl-4",children:D(O??i.jsx(W4,{output:V,part:e,metadata:u,input:f}),{className:"p-2",maxHeightClass:"max-h-[46vh]"})})}return i.jsxs("div",{className:B("relative pr-2 pb-2 pt-2 space-y-2 pl-4"),children:[e.tool==="question"?P():i.jsxs(i.Fragment,{children:[A?i.jsx("div",{className:"my-1",children:D(e.tool==="bash"?i.jsx("pre",{className:"tool-input-text whitespace-pre-wrap break-words typography-code text-muted-foreground/90 m-0 p-0",children:L}):N&&H?i.jsx(X7,{diff:H,diffViewMode:a}):i.jsx("blockquote",{className:"tool-input-text whitespace-pre-wrap break-words typography-meta italic text-muted-foreground/70",children:L}),{maxHeightClass:N&&H&&s?"max-h-[50vh]":"max-h-60",className:e.tool==="bash"?"tool-input-surface p-0 rounded-none":"tool-input-surface"})}):null,$&&i.jsxs("div",{children:[(e.tool==="edit"||e.tool==="multiedit"||e.tool==="apply_patch"||e.tool==="write")&&C?i.jsx("div",{className:"mb-1 flex items-center justify-end gap-2",children:i.jsx(fB,{mode:a,onModeChange:l,className:"h-5 w-5 p-0"})}):null,P()]}),t.status==="error"&&"error"in t&&i.jsxs("div",{children:[i.jsx("div",{className:"typography-meta font-medium text-muted-foreground/80 mb-1",children:"Error:"}),i.jsx("div",{className:"typography-meta p-2 rounded-xl border",style:{backgroundColor:"var(--status-error-background)",color:"var(--status-error)",borderColor:"var(--status-error-border)"},children:F2(t.error)})]})]}),Array.isArray(b)&&b.length>0&&t.status==="completed"?i.jsx(Xi,{files:b,onShowPopup:o,compact:!0}):null]})});_m.displayName="ToolExpandedContent";const ZT=({part:e,isExpanded:t,onToggle:n,isMobile:s,onContentChange:o,onShowPopup:r,animateTailText:a=!0})=>{const l=Be(Me=>Me.currentSessionId),c=e.state?.deferredBody===!0,u=Kw(l,e.id,t&&c),f=t&&u&&u.type==="tool"?u:e,h=f.state,m=h,p=m.metadata,g=m.input,y=he(Me=>Me.showToolFileIcons),M=bt()??"",b=ha(e.tool),v=b==="task",x=h?.status,S=x==="completed"||x==="error"||x==="aborted"||x==="failed"||x==="timeout"||x==="cancelled",C=x==="completed",w=x==="error"||x==="failed",[_,L]=d.useState(!S),A=d.useRef(e.id),N=d.useRef(!S);d.useEffect(()=>{A.current!==e.id&&(A.current=e.id,N.current=!S,L(!S))},[S,e.id]),d.useEffect(()=>{S||L(!0)},[S]),d.useEffect(()=>{if(!S){N.current=!0;return}if(!N.current)return;if(!C||!bT.has(b)){N.current=!1;return}if(!M)return;N.current=!1;const Ie=QB(b,g,p).map(qe=>mt(qe,M));yh.requestGitRefresh({directory:M,...Ie.length>0?{paths:Ie}:{}})},[M,g,S,C,p,b]);const k=S||v,V=d.useRef(o);V.current=o;const H=d.useRef(null);d.useLayoutEffect(()=>{if(v)return;const Me=H.current;Me&&(Me.style.height=t?"auto":"0px",Me.style.overflow=t?"visible":"hidden",k&&V.current?.("structural"))},[t,v,k]);const D=e.metadata,P=m.time,[R,$]=d.useState(()=>({start:typeof P?.start=="number"?P.start:void 0,end:typeof P?.end=="number"?P.end:void 0})),[O,I]=d.useState(void 0),[q,G]=d.useState(void 0);d.useEffect(()=>{$({}),I(void 0),G(void 0)},[e.id]),d.useEffect(()=>{S||typeof P?.start!="number"&&I(Me=>Me??Date.now())},[S,P?.start]),d.useEffect(()=>{$(Me=>{const Ie={...Me};let qe=!1;return typeof P?.start=="number"&&(typeof Me.start!="number"||P.start<Me.start)&&(Ie.start=P.start,qe=!0),typeof P?.end=="number"&&(typeof Me.end!="number"||P.end>Me.end)&&(Ie.end=P.end,qe=!0),qe?Ie:Me})},[P?.end,P?.start]);const K=d.useMemo(()=>{if(typeof O=="number")return O;const Me=[R.start,P?.start].filter(Ie=>typeof Ie=="number");if(Me.length!==0)return Math.min(...Me)},[O,R.start,P?.start]),W=d.useMemo(()=>typeof m.output=="string"?m.output:void 0,[m.output]),ge=d.useMemo(()=>Jh(W),[W]),Z=d.useMemo(()=>{if(!v)return[];const Me=p,Ie=Yh(Me?.summary??Me?.entries??Me?.tools??Me?.calls);return Ie.length>0?Ie:ge.summaryEntries},[v,p,ge.summaryEntries]),fe=S&&Z.length>0,ie=d.useMemo(()=>{if(!v)return;const Me=H7(p);if(Me)return Me;const Ie=H7(D);return Ie||(ge.sessionId?ge.sessionId:yB(W))},[v,p,ge.sessionId,D,W]);d.useEffect(()=>{if(typeof P?.end=="number"||typeof R.end=="number"){G(void 0);return}typeof K=="number"&&S&&G(Me=>Me??Date.now())},[K,S,R.end,P?.end]);const E=S?R.end??P?.end??q:void 0,ce=!S&&_,ee=S,ue=gB({isTaskTool:v,isExpanded:t,isActive:ce,hasFinalMetadataSummary:fe,taskSessionId:ie})?ie??"":"",J=Ui(ue);Jw(ue);const Y=d.useMemo(()=>!v||!ie?[]:!Array.isArray(J)||J.length===0?[]:bB(J),[J,v,ie]),oe=d.useMemo(()=>Y.length>0?Y:Z,[Y,Z]),te=d.useMemo(()=>oe.map(Gn).join("\0"),[oe]),pe=d.useRef(null);d.useEffect(()=>{if(!v){pe.current=null;return}const Me=pe.current;pe.current=te,!(Me===null||Me===te||oe.length===0)&&V.current?.("structural")},[v,oe.length,te]);const He=d.useMemo(()=>b==="edit"||b==="multiedit"||b==="apply_patch"?CT(p):null,[p,b]),je=d.useMemo(()=>b==="write"?ST(g):null,[g,b]),Pe=b==="apply_patch"&&Array.isArray(p?.files)&&(p?.files).length>1,X=b!==e.tool?{...e,tool:b}:e,me=h?bm(X,h,M):void 0,U=h?IT(X,h,M):void 0,T=wo(b||e.tool||"").displayName,Q=d.useMemo(()=>{if(b==="bash"||b==="apply_patch"||b==="lsp"||me&&(b==="apply_patch"||b==="edit"||b==="multiedit"||b==="write"))return null;const Me=m.title;if(typeof Me=="string"&&Me.trim().length>0)return Me;const Ie=g?.description;return typeof Ie=="string"&&Ie.trim().length>0?Ie:null},[me,b,m,g]),se=d.useContext(Mo),ye=(Me,Ie)=>{se?.editor&&(Ie.stopPropagation(),vT({currentDirectory:M,editor:se.editor,file:Me}))},le=Me=>{if(v||!se?.editor){n(e.id);return}let Ie,qe;if(b==="edit"||b==="multiedit")Ie=g?.filePath||g?.file_path||g?.path||p?.filePath||p?.file_path||p?.path,typeof Ie=="string"&&(qe=F7(b,p,Ie));else if(b==="apply_patch")Ie=p5(b,g,p),typeof Ie=="string"&&(qe=F7(b,p,Ie));else if(["write","create","file_write"].includes(b))Ie=g?.filePath||g?.file_path||g?.path||p?.filePath||p?.file_path||p?.path;else if(b==="lsp"){Ie=g?.filePath||g?.file_path||g?.path;const n1=g?.line;qe=typeof n1=="number"&&Number.isFinite(n1)?Math.trunc(n1):void 0}if(typeof Ie=="string"){Me.stopPropagation();const n1=Co(M,Ie);se.editor.openFile(n1,qe)}else n(e.id)},ne=Me=>{Me.key!=="Enter"&&Me.key!==" "||(Me.preventDefault(),le(Me))},Ce=!v&&w?Cm:DT,Se=!v&&w?Sm:RT,Ae=K7(v&&(oe.length>0||ce||ee||!!ie)),Ve=K7(!v&&t);return!ee&&!ce&&!v?null:i.jsxs("div",{children:[i.jsxs("div",{className:B("group/tool flex gap-1.5 pr-2 pl-px py-1.5 rounded-xl",Pe?"flex-wrap items-start cursor-pointer":"items-center cursor-pointer"),onClick:Pe?()=>n(e.id):le,onKeyDown:Pe?Me=>{Me.target===Me.currentTarget&&(Me.key!=="Enter"&&Me.key!==" "||(Me.preventDefault(),n(e.id)))}:ne,role:"button",tabIndex:0,children:[i.jsx("div",{className:B("flex gap-1.5",Pe?"w-full min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5":"items-center flex-shrink-0"),children:Pe?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex h-5 flex-shrink-0 items-center gap-1.5",children:[i.jsxs("span",{className:"relative h-3.5 w-3.5 flex-shrink-0",children:[i.jsx("span",{className:B("absolute inset-0 flex items-center justify-center transition-opacity",t?"opacity-0":"group-hover/tool:opacity-0"),style:Ce,children:mo(b||e.tool)}),i.jsx(z,{name:t?"arrow-down-s":"arrow-right-s",className:B("absolute inset-0 h-3.5 w-3.5 transition-opacity",t?"opacity-100":"opacity-0 group-hover/tool:opacity-100")})]}),i.jsx($4,{active:!!(ce&&!w),minDurationMs:300,className:B(G4,"flex-shrink-0"),style:Se,children:T})]}),i.jsx(yT,{metadata:p,animate:a,showFileIcons:y,textClassName:Gt,openDiffLabel:"Open file diff",onFileClick:se?.editor?ye:void 0})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"relative h-5 w-3.5 flex-shrink-0 cursor-pointer",onClick:Me=>{Me.stopPropagation(),n(e.id)},children:[i.jsx("div",{className:B("absolute inset-0 flex items-center justify-center transition-opacity",t&&"opacity-0",!t&&"group-hover/tool:opacity-0"),style:Ce,children:mo(b||e.tool||"")}),i.jsx("div",{className:B("absolute inset-0 transition-opacity flex items-center justify-center",t&&"opacity-100",!t&&"opacity-0 group-hover/tool:opacity-100"),children:t?i.jsx(z,{name:"arrow-down-s",className:"h-3.5 w-3.5"}):i.jsx(z,{name:"arrow-right-s",className:"h-3.5 w-3.5"})})]}),i.jsx("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:i.jsx($4,{active:!!(ce&&!w),minDurationMs:300,className:B(G4,"flex-shrink-0"),style:Se,title:T,children:T})}),b==="bash"&&typeof K=="number"?i.jsx("span",{className:B("flex-shrink-0 tabular-nums text-muted-foreground/80",Gt),children:i.jsx(wT,{start:K,end:typeof E=="number"?E:void 0,active:!!(ce&&typeof E!="number")})}):null]})}),!Pe&&i.jsx("div",{className:B("flex items-center gap-1 flex-1 min-w-0",Gt),style:{color:"var(--tools-description)"},children:i.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:[Q&&i.jsx("span",{className:B("min-w-0 truncate",Gt),style:{color:"var(--tools-description)",opacity:.8},title:Q,children:Q}),!Q&&b==="lsp"&&me?Y4(me,a,!1,y):null,!Q&&b!=="lsp"&&U&&(me&&U===me?Y4(me,a,!1,y):i.jsx(Vt,{variant:a?"generate-effect":"static",className:B("min-w-0 truncate",Gt),style:{color:"var(--tools-description)"},title:U,children:U})),He&&i.jsxs("span",{className:"flex-shrink-0 inline-flex items-center gap-0 typography-meta",style:{fontSize:"0.8rem",lineHeight:"1"},children:[i.jsxs("span",{style:{color:"var(--status-success)"},children:["+",He.added]}),i.jsx("span",{style:{color:"var(--tools-description)"},children:"/"}),i.jsxs("span",{style:{color:"var(--status-error)"},children:["-",He.removed]})]}),je&&i.jsx("span",{className:"flex-shrink-0 inline-flex items-center gap-0 typography-meta",style:{fontSize:"0.8rem",lineHeight:"1"},children:i.jsxs("span",{style:{color:"var(--status-success)"},children:["+",je]})})]})})]}),Ae?i.jsx(zT,{entries:oe,isExpanded:t,isMobile:s,output:W,sessionId:ie,onShowPopup:r,input:g,animateTailText:a,isActive:ce}):null,v?null:i.jsx("div",{ref:H,"aria-hidden":!t,style:{height:t?"auto":"0px",overflow:t?"visible":"hidden",overflowAnchor:"none"},children:Ve?i.jsxs("div",{className:"relative ml-2 pl-3",children:[i.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute left-0 top-px bottom-0 w-px",style:{backgroundColor:"var(--tools-border)"}}),h?i.jsx(_m,{part:f,state:h,currentDirectory:M,isExpanded:t,onShowPopup:r}):null]}):null})]})};class FT extends d.Component{state={hasError:!1};static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidUpdate(t){t.resetKey!==this.props.resetKey&&this.state.hasError&&this.setState({hasError:!1,error:void 0})}componentDidCatch(t){}render(){if(!this.state.hasError)return this.props.children;const t=this.state.error?.message;return i.jsxs("div",{className:"flex items-center gap-1.5 pr-2 pl-px py-1.5 rounded-xl min-w-0",children:[i.jsx("div",{className:"h-3.5 w-3.5 flex-shrink-0",style:Cm,children:mo(this.props.toolName)}),i.jsx("span",{className:B(G4,"flex-shrink-0"),style:Sm,children:this.props.displayName}),t?i.jsxs("span",{className:B(Gt,"min-w-0 truncate"),style:{color:"var(--tools-description)"},title:t,children:[this.props.errorLabel,": ",t]}):null]})}}const $T=e=>{const t=ha(e.part.tool)||"tool",n=wo(t).displayName;return i.jsx(FT,{displayName:n,errorLabel:"Error:",resetKey:e.part,toolName:t,children:i.jsx(ZT,{...e})})},km=d.memo($T,(e,t)=>So([e.part],[t.part])&&e.isExpanded===t.isExpanded&&e.isMobile===t.isMobile&&e.alwaysShowActions===t.alwaysShowActions&&e.onContentChange===t.onContentChange&&e.onShowPopup===t.onShowPopup&&e.animateTailText===t.animateTailText),qT=e=>e.isStreaming?e.throttledTextContent:e.textContent,UT=e=>!e.isFinalized&&e.displayTextContent.trim().length===0?!1:e.displayTextContent.trim().length>0,GT=({result:e})=>{const[t,n]=d.useState(!1),s=d.useRef(null);d.useEffect(()=>()=>{s.current!==null&&window.clearTimeout(s.current)},[]);const o=d.useMemo(()=>e.kind==="commit"?[e.subject,...e.highlights.map(a=>`- ${a}`)].join(`
6991
+ `)[0].substring(0,100);if(e.tool==="task"&&r?.description&&typeof r.description=="string")return r.description.substring(0,80);if(e.tool==="lsp")return jT(r,n);const l=r?.description||o?.description||"title"in t&&t.title||"";return pT(e.tool,l,r)},v5=({children:e,maxHeightClass:t="max-h-[60vh]",className:n,outerClassName:s,disableHorizontal:o=!1,followKey:r})=>{const a=d.useRef(null),l=d.useRef(!0);return d.useLayoutEffect(()=>{const c=a.current;if(r===void 0){l.current=!0;return}!c||!l.current||(c.scrollTop=c.scrollHeight)},[r]),i.jsx("div",{className:B("w-full min-w-0 flex-none overflow-hidden",s),children:i.jsx(Yi,{ref:a,"data-scrollable":"true",onWheelCapture:c=>{r!==void 0&&c.deltaY<0&&(l.current=!1)},onScroll:c=>{if(r===void 0)return;const u=c.currentTarget;l.current=u.scrollHeight-u.scrollTop-u.clientHeight<=2},className:B("tool-output-surface p-2 rounded-xl w-full min-w-0",t,o?"overflow-y-auto overflow-x-hidden":"overflow-auto",n),children:i.jsx("div",{className:"w-full min-w-0",children:e})})})},BT=(e,t,n,s)=>t.tool==="bash"?"bash":WI(Uh(e,t.tool||"",n),t.tool||"",s),TT=(e,t,n)=>t.tool==="bash"?e:Uh(e,t.tool||"",n),VT=({output:e})=>{const t=d.useRef(null),n=d.useRef("");return d.useLayoutEffect(()=>{const s=t.current;if(!s)return;const o=s.firstChild,r=o instanceof globalThis.Text?o:document.createTextNode("");r!==o&&s.replaceChildren(r);const a=uT(e,mm),l=dT(n.current,a);l===void 0?r.data=a:l.length>0&&r.appendData(l),n.current=a},[e]),i.jsx("pre",{ref:t,className:"m-0 whitespace-pre-wrap break-words",style:{...K4,lineHeight:"round(var(--code-block-line-height), 1px)",overflowWrap:"break-word"}})},W4=({output:e,part:t,metadata:n,input:s,isStreaming:o=!1})=>{const r=TT(e,t,n),a=BT(e,t,n,s),l=d.useMemo(()=>$I(r),[r]),[c,u]=d.useState("summary"),[f,h]=d.useState(!1);d.useEffect(()=>{u("summary"),h(!1)},[r]);const m=d.useCallback((g,y)=>{y.stopPropagation(),u(g)},[]),p=d.useCallback(async g=>{if(g.stopPropagation(),!(await gt(r)).ok){Ue.error("Failed to copy output");return}h(!0),typeof window<"u"&&window.setTimeout(()=>h(!1),1200)},[r]);return t.tool==="bash"&&o?i.jsx("div",{className:"typography-code text-muted-foreground/90",children:i.jsx(VT,{output:r})}):l.isJson?i.jsxs("div",{className:"tool-output-surface relative p-2 rounded-xl w-full min-w-0",children:[i.jsxs("div",{className:"absolute right-2 top-2 z-10 flex items-center gap-1",children:[i.jsx(a1,{variant:"ghost",size:"icon",className:B("h-6 w-6 rounded-md text-muted-foreground hover:text-foreground",c==="summary"&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),onClick:g=>m("summary",g),onPointerDown:g=>g.stopPropagation(),"aria-label":"Show navigable JSON",title:"Show navigable JSON",children:i.jsx(z,{name:"list-unordered",className:"h-3.5 w-3.5"})}),i.jsx(a1,{variant:"ghost",size:"icon",className:B("h-6 w-6 rounded-md text-muted-foreground hover:text-foreground",c==="formatted"&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),onClick:g=>m("formatted",g),onPointerDown:g=>g.stopPropagation(),"aria-label":"Show formatted JSON",title:"Show formatted JSON",children:i.jsx(z,{name:"node-tree",className:"h-3.5 w-3.5"})}),i.jsx(a1,{variant:"ghost",size:"icon",className:B("h-6 w-6 rounded-md text-muted-foreground hover:text-foreground",c==="raw"&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),onClick:g=>m("raw",g),onPointerDown:g=>g.stopPropagation(),"aria-label":"Show raw JSON",title:"Show raw JSON",children:i.jsx(z,{name:"code-box",className:"h-3.5 w-3.5"})}),i.jsx(a1,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-md bg-[var(--surface-elevated)]/80 text-muted-foreground hover:text-foreground",onClick:p,onPointerDown:g=>g.stopPropagation(),"aria-label":f?"Copied output":"Copy output",title:f?"Copied output":"Copy output",children:i.jsx(z,{name:f?"check":"file-copy",className:"h-3.5 w-3.5"})})]}),c==="summary"?i.jsx(Wh,{data:l.data}):c==="formatted"?i.jsx(aB,{data:l.data,initiallyExpandedDepth:1,maxHeight:"400px"}):i.jsx("div",{className:"typography-code pr-12 text-muted-foreground/90",children:i.jsx(Si,{language:"json",code:r,style:K4,codeStyle:Y7.style,wrap:!0})})]}):i.jsx("div",{className:t.tool==="bash"?"typography-code text-muted-foreground/90":void 0,children:i.jsx(Si,{language:a,code:r,style:K4,codeStyle:Y7.style,wrap:!0})})};W4.displayName="ToolScrollableTextOutput";const xm=e=>{const t=e.state?.title;if(typeof t=="string"&&t.trim().length>0)return t;const n=e.state?.input;if(n&&typeof n=="object"){const s=n.filePath??n.file_path??n.path;if(typeof s=="string"&&s.trim().length>0)return s.trim();const o=n.url;if(typeof o=="string"&&o.trim().length>0)return o.trim()}return""},NT=new Set(["read","view","file_read","cat","write","create","file_write","edit","multiedit","apply_patch"]),PT=(e,t)=>{if(!NT.has(e.toLowerCase()))return!1;const n=t.trim();if(!n||n==="Patch"||/^\d+\s+files$/.test(n))return!1;if(n.includes("/")||n.includes("\\"))return!0;const s=n.split(/[\\/]/).pop()||n;return s.startsWith(".")||s.includes(".")?!0:/^[A-Za-z0-9_-]+$/.test(s)},Gn=e=>{const t=ha(e.tool),n=e.state?.status??"",s=xm(e);return`${e.id??""}${t}${n}${s}`},ET=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(Gn(e[n])!==Gn(t[n]))return!1;return!0},wm=d.memo(({entry:e,isMobile:t,animateTailText:n,showToolFileIcons:s})=>{const o=ha(e.tool),r=o.length>0?o:"tool",a=xm(e),l=a.trim().length>0,c=e.state?.status,u=wo(r).displayName;return i.jsx(ho,{animate:n,wipe:!0,children:i.jsxs("div",{className:B("flex gap-2 min-w-0 w-full",c==="error"&&t?"items-start":"items-center"),children:[i.jsx("span",{className:"flex-shrink-0 text-foreground/80",children:mo(r)}),i.jsx("span",{className:"typography-meta text-foreground/80 flex-shrink-0",style:{color:"var(--tools-title)"},title:u,children:u}),l?c!=="error"&&PT(r,a)?Y4(a,n,!0,s):c==="error"?i.jsx("span",{className:B("typography-meta flex-1 min-w-0 text-[var(--status-error)]",t?"whitespace-normal break-words":"truncate"),children:a}):i.jsx(Vt,{variant:n?"generate-effect":"static",className:"typography-meta flex-1 min-w-0 truncate text-muted-foreground/70",style:{color:"var(--tools-description)"},title:a,children:a}):null]})})},(e,t)=>e.isMobile===t.isMobile&&e.animateTailText===t.animateTailText&&e.showToolFileIcons===t.showToolFileIcons&&Gn(e.entry)===Gn(t.entry));wm.displayName="TaskSummaryEntryRow";const Mm=d.memo(({entries:e,isExpanded:t,isMobile:n,animateTailText:s,showToolFileIcons:o})=>{const r=t?e:e.slice(-6),a=Math.max(0,e.length-r.length),l=e.length-r.length;return i.jsx(v5,{maxHeightClass:t?"max-h-[40vh]":"max-h-56",disableHorizontal:!0,children:i.jsxs("div",{className:"w-full min-w-0 space-y-1",children:[a>0?i.jsxs("div",{className:"typography-micro text-muted-foreground/70",children:["+",a," more…"]}):null,r.map((c,u)=>{const f=t?u:l+u,h=c.id??`${Gn(c)}:${f}`;return i.jsx(wm,{entry:c,isMobile:n,animateTailText:s,showToolFileIcons:o},h)})]})})},(e,t)=>e.isExpanded===t.isExpanded&&e.isMobile===t.isMobile&&e.animateTailText===t.animateTailText&&e.showToolFileIcons===t.showToolFileIcons&&ET(e.entries,t.entries));Mm.displayName="TaskSummaryEntriesList";const zT=({entries:e,isExpanded:t,isMobile:n,output:s,sessionId:o,onShowPopup:r,input:a,animateTailText:l=!0,isActive:c=!1})=>{const u=bt(),f=Be(v=>v.setCurrentSession),h=he(v=>v.showToolFileIcons),m=typeof s=="string"?xB(s):"",p=m.length>0,[g,y]=d.useState(!1),M=v=>{v.stopPropagation(),o&&u&&f(o,u)},b=typeof a?.subagent_type=="string"?a.subagent_type:"subagent";return e.length===0&&!p&&!o?i.jsx("div",{className:"relative pr-2 pb-2 pt-2 space-y-2 pl-[1.4375rem]",children:i.jsx("div",{className:"typography-meta text-muted-foreground/70",children:c?"Waiting for subagent activity...":"No subagent session id on task metadata."})}):i.jsxs("div",{className:B("relative pr-2 pb-2 pt-2 space-y-2 pl-[1.4375rem]",'before:absolute before:left-[0.4375rem] before:w-px before:bg-border/80 before:content-[""]',"before:top-[-0.25rem] before:bottom-0"),children:[e.length>0?i.jsx(Mm,{entries:e,isExpanded:t,isMobile:n,animateTailText:l,showToolFileIcons:h}):null,o&&i.jsxs("button",{type:"button",className:"flex items-center gap-2 typography-meta text-primary hover:text-primary/80 w-full",onPointerDown:v=>v.stopPropagation(),onClick:M,children:[i.jsx(z,{name:"external-link",className:"h-3.5 w-3.5 flex-shrink-0"}),i.jsx("span",{className:"typography-meta text-primary font-medium",children:`Open ${b.charAt(0).toUpperCase()+b.slice(1)} subtask`})]}),p?i.jsxs("div",{className:B("space-y-1",(e.length>0||o)&&"pt-1"),children:[i.jsxs("button",{type:"button",className:"flex items-center gap-2 typography-meta text-foreground/80 hover:text-foreground w-full",onPointerDown:v=>v.stopPropagation(),onClick:v=>{v.stopPropagation(),y(x=>!x)},children:[g?i.jsx(z,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0"}):i.jsx(z,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0"}),i.jsx("span",{className:"typography-meta text-foreground/80 font-medium",children:"Output"})]}),g?i.jsx(v5,{maxHeightClass:"max-h-[50vh]",children:i.jsx("div",{className:"w-full min-w-0",children:i.jsx(xo,{content:m,variant:"tool",onShowPopup:r})})}):null]}):null]})},K4={...qg.getCollapsedStyles(),padding:0,overflow:"visible"},Y7={style:{background:"transparent",backgroundColor:"transparent"}},Cm={color:"var(--status-error)"},DT={color:"var(--tools-icon)"},Sm={color:"var(--status-error)"},RT={color:"var(--tools-title)"},J7=(e,t=!0)=>{const n=e.lastIndexOf("/");if(n===-1)return i.jsx("span",{className:B("min-w-0 truncate typography-ui-label text-foreground",t&&"flex-1"),style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:e,children:e});const s=e.slice(0,n),o=e.slice(n+1),r=s.startsWith("/"),a=r?s.slice(1):s;return i.jsxs("span",{className:B("min-w-0 flex items-baseline overflow-hidden typography-ui-label",t&&"flex-1"),title:e,children:[r?i.jsx("span",{className:"flex-shrink-0 text-muted-foreground",children:"/"}):null,i.jsx("span",{className:"min-w-0 truncate text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:a}),i.jsxs("span",{className:"flex-shrink-0",children:[i.jsx("span",{className:"text-muted-foreground",children:"/"}),i.jsx("span",{className:"text-foreground",children:o})]})]})},Y4=(e,t=!0,n=!0,s=!0)=>{const o=e.lastIndexOf("/");if(o===-1)return i.jsxs("span",{className:B("min-w-0 inline-flex items-center gap-1 overflow-hidden",n&&"flex-1"),title:e,children:[s?i.jsx(Tt,{filePath:e,className:"h-3.5 w-3.5 flex-shrink-0"}):null,i.jsx(Vt,{variant:t?"generate-effect":"static",className:B("min-w-0 truncate whitespace-nowrap",Gt,n&&"flex-1"),style:{color:"var(--tools-title)"},children:e})]});const r=e.slice(0,o),a=e.slice(o+1),l=r.startsWith("/"),c=l?r.slice(1):r;return i.jsxs("span",{className:B("min-w-0 inline-flex items-center gap-1 overflow-hidden",n&&"flex-1"),title:e,children:[s?i.jsx(Tt,{filePath:e,className:"h-3.5 w-3.5 flex-shrink-0"}):null,i.jsxs("span",{className:B("min-w-0 inline-flex max-w-full items-baseline overflow-hidden",Gt,n&&"flex-1"),children:[l?i.jsx("span",{className:"flex-shrink-0",style:{color:"var(--tools-description)"},children:"/"}):null,i.jsx("span",{className:"min-w-0 shrink truncate whitespace-nowrap",style:{color:"var(--tools-description)",direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:c}),i.jsx("span",{className:"flex-shrink-0",style:{color:"var(--tools-description)"},children:"/"}),i.jsx(Vt,{variant:t?"generate-effect":"static",className:"flex-shrink-0",style:{color:"var(--tools-title)"},children:a})]})]})},OT=bo(()=>V2(()=>import("./ToolPartDiffPreview-CBFC9min.js"),__vite__mapDeps([130,1,2,125,112,113,25,114,26,27,28,29,30,31,32,33,34,35,36,37,38,39,115,23,24,116,117,118,119,120,121,122,123,126,127,128,129,22,13,6,14,40,41,42,43,44,45,46,15,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,7,108,109]))),X7=({diff:e,diffViewMode:t})=>i.jsx(d.Suspense,{fallback:i.jsx(qh,{diff:e}),children:i.jsx(OT,{diff:e,diffViewMode:t})}),_m=d.memo(({part:e,state:t,currentDirectory:n,isExpanded:s,onShowPopup:o})=>{const r=e5(),[a,l]=d.useState("unified"),c=t,u=c.metadata,f=c.input,h=cT(e.tool||"",c.output,u?.output,t.status),m=typeof h=="string"&&h.length>0,p=typeof h=="string"?h:"",g=e.tool==="bash"&&t.status==="running",y=g5({text:p,isStreaming:g,identityKey:e.id,allowTextReplacement:g}),M=g?y:p,b=c.attachments,v=no(u?.filediff)?u.filediff:void 0,x=x2(u?.patch)??x2(u?.diff)??x2(v?.patch)??x2(v?.diff)??null,S=d.useMemo(()=>iT(u,x??void 0,O=>mt(O,n)),[n,x,u]),C=S.some(O=>O.renderMode==="diff"),w=e.tool==="pichamber"||e.tool==="apply_patch"||e.tool==="edit"||e.tool==="multiedit",_=d.useMemo(()=>HT(e.tool||"",f,u,n),[n,f,u,e.tool]),L=d.useMemo(()=>!f||typeof f!="object"||Object.keys(f).length===0?"":"command"in f&&typeof f.command=="string"&&e.tool==="bash"?S7(f,e.tool):typeof f.content=="string"?f.content??"":S7(f,e.tool),[f,e.tool]),A=!w&&L.trim().length>0,N=e.tool==="write"||e.tool==="create"||e.tool==="file_write",k=e.tool==="todowrite"||e.tool==="todoread",V=d.useMemo(()=>Array.isArray(f?.todos)?JSON.stringify(f.todos):M,[f?.todos,M]),H=d.useMemo(()=>{if(!N||!A)return;const O=typeof f?.filePath=="string"?f.filePath:typeof f?.file_path=="string"?f.file_path:typeof f?.path=="string"?f.path:void 0;return _T(O,L)},[A,f?.filePath,f?.file_path,f?.path,L,N]);d.useEffect(()=>{l("unified")},[e.id]);const D=(O,I)=>i.jsx(v5,{maxHeightClass:I?.maxHeightClass,className:I?.className,disableHorizontal:I?.disableHorizontal,outerClassName:I?.outerClassName,followKey:I?.followKey,children:O}),P=()=>{const O=K=>Co(n,K.filePath??K.title),I=(K,W)=>{W.stopPropagation();const ge=eo(K.patch),Z=O(K);he.getState().openContextFileAtLine(n,Z,ge??1,1),r?.openFiles()},q=(K,W)=>{W.stopPropagation();const ge=O(K),Z=he.getState(),fe=mt(ge,n);if(Z.isMobile){Z.navigateToDiff(fe);return}Z.openContextDiff(n,fe)},G=()=>_?i.jsxs("div",{className:"tool-output-surface rounded-xl border p-2 space-y-2",style:{borderColor:"var(--status-error-border)",backgroundColor:"var(--status-error-background)"},children:[i.jsx("div",{className:"typography-meta font-medium",style:{color:"var(--status-error)"},children:"LSP errors"}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("div",{className:"flex items-center gap-1 min-w-0",children:J7(_.displayPath,!1)}),i.jsx("div",{className:"space-y-1",children:_.diagnostics.map((K,W)=>i.jsx("div",{className:"rounded-md border px-2 py-1",style:{borderColor:"var(--status-error-border)",backgroundColor:"var(--surface-elevated)"},children:i.jsxs("div",{className:"flex items-start gap-2 min-w-0",children:[i.jsxs("span",{className:"typography-micro shrink-0",style:{color:"var(--status-error)"},children:["[",K.line,":",K.character,"]"]}),i.jsx("span",{className:"typography-meta text-foreground whitespace-pre-wrap break-words",children:K.message})]})},`${_.displayPath}:${K.line}:${K.character}:${W}`))}),_.remaining>0?i.jsx("div",{className:"typography-micro text-muted-foreground",children:`+${_.remaining} more errors`}):null]})]}):null;if(e.tool==="question"){if(t.status==="completed"&&m){const W=LT(M);if(W&&W.length>0)return D(i.jsx("div",{className:"space-y-2",children:W.map((ge,Z)=>i.jsxs("div",{className:"space-y-0.5",children:[i.jsx("div",{className:"typography-micro text-muted-foreground",children:ge.question}),i.jsx("div",{className:"typography-meta text-foreground whitespace-pre-wrap",children:ge.answer})]},Z))}),{maxHeightClass:"max-h-[40vh]"})}if(t.status==="error"&&"error"in t)return i.jsxs("div",{children:[i.jsx("div",{className:"typography-meta font-medium text-muted-foreground mb-1",children:"Error:"}),i.jsx("div",{className:"typography-meta p-2 rounded-xl border",style:{backgroundColor:"var(--status-error-background)",color:"var(--status-error)",borderColor:"var(--status-error-border)"},children:F2(t.error)})]});const K=f;return K?.questions&&Array.isArray(K.questions)&&K.questions.length>0?D(i.jsx("div",{className:"space-y-2",children:K.questions.map((W,ge)=>i.jsxs("div",{className:"space-y-0.5",children:[W.header?i.jsx("div",{className:"typography-micro text-muted-foreground",children:F2(W.header)}):null,i.jsx("div",{className:"typography-meta text-foreground",children:F2(W.question)}),Array.isArray(W.options)&&W.options.length>0?i.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5",children:W.options.map(Z=>i.jsx("span",{className:"typography-micro px-1.5 py-0.5 rounded bg-muted/30 border border-border/30 text-muted-foreground",children:F2(Z.label)},F2(Z.label)))}):null]},ge))}),{maxHeightClass:"max-h-[40vh]"}):i.jsx("div",{className:"typography-meta text-muted-foreground",children:"Awaiting response..."})}if(e.tool==="task"&&m)return D(i.jsx("div",{className:"w-full min-w-0",children:i.jsx(xo,{content:F2(M),variant:"tool",onShowPopup:o})}));if((e.tool==="edit"||e.tool==="multiedit"||e.tool==="apply_patch"||e.tool==="write")&&(S.length>0||_))return D(i.jsxs("div",{className:"space-y-3",children:[S.map(K=>i.jsxs("div",{className:"w-full min-w-0",children:[i.jsxs("div",{className:"mb-1 flex min-w-0 items-center gap-1 px-2 py-1",children:[i.jsx("div",{className:"min-w-0 flex-1 typography-meta font-medium text-muted-foreground",children:J7(K.title)}),i.jsx(a1,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 text-muted-foreground hover:text-foreground",onClick:W=>I(K,W),"aria-label":"Open file at first change",title:"Open file at first change",children:i.jsx(z,{name:"file-edit",className:"h-3.5 w-3.5"})}),i.jsx(a1,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 text-muted-foreground hover:text-foreground",onClick:W=>q(K,W),"aria-label":"Open file diff",title:"Open file diff",children:i.jsx(z,{name:"git-pull-request",className:"h-3.5 w-3.5"})})]}),K.renderMode==="diff"?i.jsx(X7,{diff:K.patch,diffViewMode:a}):i.jsx(qh,{diff:K.patch})]},K.id)),G()]}),{className:"p-1"});if(e.tool==="write"&&_)return D(i.jsx("div",{className:"space-y-3",children:G()}),{className:"p-1"});if(N)return null;if(m&&M.trim()){const K=i.jsx(W4,{output:F2(M),part:e,metadata:u,input:f,isStreaming:g});return D(K,{className:e.tool==="bash"?"p-1 rounded-none":"p-1",maxHeightClass:g?"max-h-64":e.tool==="bash"?"max-h-[46vh]":void 0,followKey:g?M:void 0})}return D(i.jsx("div",{className:"typography-meta text-muted-foreground/70",children:"No output produced"}),{maxHeightClass:"max-h-60"})},R=M.trim().length>0,$=t.status==="completed"&&"output"in t||e.tool==="bash"&&R;if(k){if(t.status==="error"&&"error"in t)return i.jsxs("div",{className:"relative pr-2 pb-2 pt-2 space-y-2 pl-4",children:[i.jsx("div",{className:"typography-meta font-medium text-muted-foreground/80 mb-1",children:"Error:"}),i.jsx("div",{className:"typography-meta p-2 rounded-xl border",style:{backgroundColor:"var(--status-error-background)",color:"var(--status-error)",borderColor:"var(--status-error-border)"},children:t.error})]});const O=GI(V,{total:"Total",inProgress:"In Progress",pending:"Pending",completed:"Completed",cancelled:"Cancelled"},{unstyled:!0});return i.jsx("div",{className:"relative pr-2 pb-2 pt-2 space-y-2 pl-4",children:D(O??i.jsx(W4,{output:V,part:e,metadata:u,input:f}),{className:"p-2",maxHeightClass:"max-h-[46vh]"})})}return i.jsxs("div",{className:B("relative pr-2 pb-2 pt-2 space-y-2 pl-4"),children:[e.tool==="question"?P():i.jsxs(i.Fragment,{children:[A?i.jsx("div",{className:"my-1",children:D(e.tool==="bash"?i.jsx("pre",{className:"tool-input-text whitespace-pre-wrap break-words typography-code text-muted-foreground/90 m-0 p-0",children:L}):N&&H?i.jsx(X7,{diff:H,diffViewMode:a}):i.jsx("blockquote",{className:"tool-input-text whitespace-pre-wrap break-words typography-meta italic text-muted-foreground/70",children:L}),{maxHeightClass:N&&H&&s?"max-h-[50vh]":"max-h-60",className:e.tool==="bash"?"tool-input-surface p-0 rounded-none":"tool-input-surface"})}):null,$&&i.jsxs("div",{children:[(e.tool==="edit"||e.tool==="multiedit"||e.tool==="apply_patch"||e.tool==="write")&&C?i.jsx("div",{className:"mb-1 flex items-center justify-end gap-2",children:i.jsx(fB,{mode:a,onModeChange:l,className:"h-5 w-5 p-0"})}):null,P()]}),t.status==="error"&&"error"in t&&i.jsxs("div",{children:[i.jsx("div",{className:"typography-meta font-medium text-muted-foreground/80 mb-1",children:"Error:"}),i.jsx("div",{className:"typography-meta p-2 rounded-xl border",style:{backgroundColor:"var(--status-error-background)",color:"var(--status-error)",borderColor:"var(--status-error-border)"},children:F2(t.error)})]})]}),Array.isArray(b)&&b.length>0&&t.status==="completed"?i.jsx(Xi,{files:b,onShowPopup:o,compact:!0}):null]})});_m.displayName="ToolExpandedContent";const ZT=({part:e,isExpanded:t,onToggle:n,isMobile:s,onContentChange:o,onShowPopup:r,animateTailText:a=!0})=>{const l=Be(Me=>Me.currentSessionId),c=e.state?.deferredBody===!0,u=Kw(l,e.id,t&&c),f=t&&u&&u.type==="tool"?u:e,h=f.state,m=h,p=m.metadata,g=m.input,y=he(Me=>Me.showToolFileIcons),M=bt()??"",b=ha(e.tool),v=b==="task",x=h?.status,S=x==="completed"||x==="error"||x==="aborted"||x==="failed"||x==="timeout"||x==="cancelled",C=x==="completed",w=x==="error"||x==="failed",[_,L]=d.useState(!S),A=d.useRef(e.id),N=d.useRef(!S);d.useEffect(()=>{A.current!==e.id&&(A.current=e.id,N.current=!S,L(!S))},[S,e.id]),d.useEffect(()=>{S||L(!0)},[S]),d.useEffect(()=>{if(!S){N.current=!0;return}if(!N.current)return;if(!C||!bT.has(b)){N.current=!1;return}if(!M)return;N.current=!1;const Ie=QB(b,g,p).map(qe=>mt(qe,M));yh.requestGitRefresh({directory:M,...Ie.length>0?{paths:Ie}:{}})},[M,g,S,C,p,b]);const k=S||v,V=d.useRef(o);V.current=o;const H=d.useRef(null);d.useLayoutEffect(()=>{if(v)return;const Me=H.current;Me&&(Me.style.height=t?"auto":"0px",Me.style.overflow=t?"visible":"hidden",k&&V.current?.("structural"))},[t,v,k]);const D=e.metadata,P=m.time,[R,$]=d.useState(()=>({start:typeof P?.start=="number"?P.start:void 0,end:typeof P?.end=="number"?P.end:void 0})),[O,I]=d.useState(void 0),[q,G]=d.useState(void 0);d.useEffect(()=>{$({}),I(void 0),G(void 0)},[e.id]),d.useEffect(()=>{S||typeof P?.start!="number"&&I(Me=>Me??Date.now())},[S,P?.start]),d.useEffect(()=>{$(Me=>{const Ie={...Me};let qe=!1;return typeof P?.start=="number"&&(typeof Me.start!="number"||P.start<Me.start)&&(Ie.start=P.start,qe=!0),typeof P?.end=="number"&&(typeof Me.end!="number"||P.end>Me.end)&&(Ie.end=P.end,qe=!0),qe?Ie:Me})},[P?.end,P?.start]);const K=d.useMemo(()=>{if(typeof O=="number")return O;const Me=[R.start,P?.start].filter(Ie=>typeof Ie=="number");if(Me.length!==0)return Math.min(...Me)},[O,R.start,P?.start]),W=d.useMemo(()=>typeof m.output=="string"?m.output:void 0,[m.output]),ge=d.useMemo(()=>Jh(W),[W]),Z=d.useMemo(()=>{if(!v)return[];const Me=p,Ie=Yh(Me?.summary??Me?.entries??Me?.tools??Me?.calls);return Ie.length>0?Ie:ge.summaryEntries},[v,p,ge.summaryEntries]),fe=S&&Z.length>0,ie=d.useMemo(()=>{if(!v)return;const Me=H7(p);if(Me)return Me;const Ie=H7(D);return Ie||(ge.sessionId?ge.sessionId:yB(W))},[v,p,ge.sessionId,D,W]);d.useEffect(()=>{if(typeof P?.end=="number"||typeof R.end=="number"){G(void 0);return}typeof K=="number"&&S&&G(Me=>Me??Date.now())},[K,S,R.end,P?.end]);const E=S?R.end??P?.end??q:void 0,ce=!S&&_,ee=S,ue=gB({isTaskTool:v,isExpanded:t,isActive:ce,hasFinalMetadataSummary:fe,taskSessionId:ie})?ie??"":"",J=Ui(ue);Jw(ue);const Y=d.useMemo(()=>!v||!ie?[]:!Array.isArray(J)||J.length===0?[]:bB(J),[J,v,ie]),oe=d.useMemo(()=>Y.length>0?Y:Z,[Y,Z]),te=d.useMemo(()=>oe.map(Gn).join("\0"),[oe]),pe=d.useRef(null);d.useEffect(()=>{if(!v){pe.current=null;return}const Me=pe.current;pe.current=te,!(Me===null||Me===te||oe.length===0)&&V.current?.("structural")},[v,oe.length,te]);const He=d.useMemo(()=>b==="edit"||b==="multiedit"||b==="apply_patch"?CT(p):null,[p,b]),je=d.useMemo(()=>b==="write"?ST(g):null,[g,b]),Pe=b==="apply_patch"&&Array.isArray(p?.files)&&(p?.files).length>1,X=b!==e.tool?{...e,tool:b}:e,me=h?bm(X,h,M):void 0,U=h?IT(X,h,M):void 0,T=wo(b||e.tool||"").displayName,Q=d.useMemo(()=>{if(b==="bash"||b==="apply_patch"||b==="lsp"||me&&(b==="apply_patch"||b==="edit"||b==="multiedit"||b==="write"))return null;const Me=m.title;if(typeof Me=="string"&&Me.trim().length>0)return Me;const Ie=g?.description;return typeof Ie=="string"&&Ie.trim().length>0?Ie:null},[me,b,m,g]),se=d.useContext(Mo),ye=(Me,Ie)=>{se?.editor&&(Ie.stopPropagation(),vT({currentDirectory:M,editor:se.editor,file:Me}))},le=Me=>{if(v||!se?.editor){n(e.id);return}let Ie,qe;if(b==="edit"||b==="multiedit")Ie=g?.filePath||g?.file_path||g?.path||p?.filePath||p?.file_path||p?.path,typeof Ie=="string"&&(qe=F7(b,p,Ie));else if(b==="apply_patch")Ie=p5(b,g,p),typeof Ie=="string"&&(qe=F7(b,p,Ie));else if(["write","create","file_write"].includes(b))Ie=g?.filePath||g?.file_path||g?.path||p?.filePath||p?.file_path||p?.path;else if(b==="lsp"){Ie=g?.filePath||g?.file_path||g?.path;const n1=g?.line;qe=typeof n1=="number"&&Number.isFinite(n1)?Math.trunc(n1):void 0}if(typeof Ie=="string"){Me.stopPropagation();const n1=Co(M,Ie);se.editor.openFile(n1,qe)}else n(e.id)},ne=Me=>{Me.key!=="Enter"&&Me.key!==" "||(Me.preventDefault(),le(Me))},Ce=!v&&w?Cm:DT,Se=!v&&w?Sm:RT,Ae=K7(v&&(oe.length>0||ce||ee||!!ie)),Ve=K7(!v&&t);return!ee&&!ce&&!v?null:i.jsxs("div",{children:[i.jsxs("div",{className:B("group/tool flex gap-1.5 pr-2 pl-px py-1.5 rounded-xl",Pe?"flex-wrap items-start cursor-pointer":"items-center cursor-pointer"),onClick:Pe?()=>n(e.id):le,onKeyDown:Pe?Me=>{Me.target===Me.currentTarget&&(Me.key!=="Enter"&&Me.key!==" "||(Me.preventDefault(),n(e.id)))}:ne,role:"button",tabIndex:0,children:[i.jsx("div",{className:B("flex gap-1.5",Pe?"w-full min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5":"items-center flex-shrink-0"),children:Pe?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex h-5 flex-shrink-0 items-center gap-1.5",children:[i.jsxs("span",{className:"relative h-3.5 w-3.5 flex-shrink-0",children:[i.jsx("span",{className:B("absolute inset-0 flex items-center justify-center transition-opacity",t?"opacity-0":"group-hover/tool:opacity-0"),style:Ce,children:mo(b||e.tool)}),i.jsx(z,{name:t?"arrow-down-s":"arrow-right-s",className:B("absolute inset-0 h-3.5 w-3.5 transition-opacity",t?"opacity-100":"opacity-0 group-hover/tool:opacity-100")})]}),i.jsx($4,{active:!!(ce&&!w),minDurationMs:300,className:B(G4,"flex-shrink-0"),style:Se,children:T})]}),i.jsx(yT,{metadata:p,animate:a,showFileIcons:y,textClassName:Gt,openDiffLabel:"Open file diff",onFileClick:se?.editor?ye:void 0})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"relative h-5 w-3.5 flex-shrink-0 cursor-pointer",onClick:Me=>{Me.stopPropagation(),n(e.id)},children:[i.jsx("div",{className:B("absolute inset-0 flex items-center justify-center transition-opacity",t&&"opacity-0",!t&&"group-hover/tool:opacity-0"),style:Ce,children:mo(b||e.tool||"")}),i.jsx("div",{className:B("absolute inset-0 transition-opacity flex items-center justify-center",t&&"opacity-100",!t&&"opacity-0 group-hover/tool:opacity-100"),children:t?i.jsx(z,{name:"arrow-down-s",className:"h-3.5 w-3.5"}):i.jsx(z,{name:"arrow-right-s",className:"h-3.5 w-3.5"})})]}),i.jsx("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:i.jsx($4,{active:!!(ce&&!w),minDurationMs:300,className:B(G4,"flex-shrink-0"),style:Se,title:T,children:T})}),b==="bash"&&typeof K=="number"?i.jsx("span",{className:B("flex-shrink-0 tabular-nums text-muted-foreground/80",Gt),children:i.jsx(wT,{start:K,end:typeof E=="number"?E:void 0,active:!!(ce&&typeof E!="number")})}):null]})}),!Pe&&i.jsx("div",{className:B("flex items-center gap-1 flex-1 min-w-0",Gt),style:{color:"var(--tools-description)"},children:i.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:[Q&&i.jsx("span",{className:B("min-w-0 truncate",Gt),style:{color:"var(--tools-description)",opacity:.8},title:Q,children:Q}),!Q&&b==="lsp"&&me?Y4(me,a,!1,y):null,!Q&&b!=="lsp"&&U&&(me&&U===me?Y4(me,a,!1,y):i.jsx(Vt,{variant:a?"generate-effect":"static",className:B("min-w-0 truncate",Gt),style:{color:"var(--tools-description)"},title:U,children:U})),He&&i.jsxs("span",{className:"flex-shrink-0 inline-flex items-center gap-0 typography-meta",style:{fontSize:"0.8rem",lineHeight:"1"},children:[i.jsxs("span",{style:{color:"var(--status-success)"},children:["+",He.added]}),i.jsx("span",{style:{color:"var(--tools-description)"},children:"/"}),i.jsxs("span",{style:{color:"var(--status-error)"},children:["-",He.removed]})]}),je&&i.jsx("span",{className:"flex-shrink-0 inline-flex items-center gap-0 typography-meta",style:{fontSize:"0.8rem",lineHeight:"1"},children:i.jsxs("span",{style:{color:"var(--status-success)"},children:["+",je]})})]})})]}),Ae?i.jsx(zT,{entries:oe,isExpanded:t,isMobile:s,output:W,sessionId:ie,onShowPopup:r,input:g,animateTailText:a,isActive:ce}):null,v?null:i.jsx("div",{ref:H,"aria-hidden":!t,style:{height:t?"auto":"0px",overflow:t?"visible":"hidden",overflowAnchor:"none"},children:Ve?i.jsxs("div",{className:"relative ml-2 pl-3",children:[i.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute left-0 top-px bottom-0 w-px",style:{backgroundColor:"var(--tools-border)"}}),h?i.jsx(_m,{part:f,state:h,currentDirectory:M,isExpanded:t,onShowPopup:r}):null]}):null})]})};class FT extends d.Component{state={hasError:!1};static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidUpdate(t){t.resetKey!==this.props.resetKey&&this.state.hasError&&this.setState({hasError:!1,error:void 0})}componentDidCatch(t){}render(){if(!this.state.hasError)return this.props.children;const t=this.state.error?.message;return i.jsxs("div",{className:"flex items-center gap-1.5 pr-2 pl-px py-1.5 rounded-xl min-w-0",children:[i.jsx("div",{className:"h-3.5 w-3.5 flex-shrink-0",style:Cm,children:mo(this.props.toolName)}),i.jsx("span",{className:B(G4,"flex-shrink-0"),style:Sm,children:this.props.displayName}),t?i.jsxs("span",{className:B(Gt,"min-w-0 truncate"),style:{color:"var(--tools-description)"},title:t,children:[this.props.errorLabel,": ",t]}):null]})}}const $T=e=>{const t=ha(e.part.tool)||"tool",n=wo(t).displayName;return i.jsx(FT,{displayName:n,errorLabel:"Error:",resetKey:e.part,toolName:t,children:i.jsx(ZT,{...e})})},km=d.memo($T,(e,t)=>So([e.part],[t.part])&&e.isExpanded===t.isExpanded&&e.isMobile===t.isMobile&&e.alwaysShowActions===t.alwaysShowActions&&e.onContentChange===t.onContentChange&&e.onShowPopup===t.onShowPopup&&e.animateTailText===t.animateTailText),qT=e=>e.isStreaming?e.throttledTextContent:e.textContent,UT=e=>!e.isFinalized&&e.displayTextContent.trim().length===0?!1:e.displayTextContent.trim().length>0,GT=({result:e})=>{const[t,n]=d.useState(!1),s=d.useRef(null);d.useEffect(()=>()=>{s.current!==null&&window.clearTimeout(s.current)},[]);const o=d.useMemo(()=>e.kind==="commit"?[e.subject,...e.highlights.map(a=>`- ${a}`)].join(`
6992
6992
  `):[e.title,e.body].filter(Boolean).join(`
6993
6993
 
6994
6994
  `),[e]),r=d.useCallback(async()=>{(await gt(o||e.raw)).ok&&(s.current!==null&&window.clearTimeout(s.current),n(!0),s.current=window.setTimeout(()=>{s.current=null,n(!1)},2e3))},[o,e.raw]);return i.jsxs("div",{"data-component":"generated-json-result",className:"my-4 group overflow-hidden rounded-2xl border border-border/80 bg-[var(--surface-elevated)]",children:[i.jsxs("div",{className:"flex items-center justify-between border-b border-border/70 px-3 py-1.5",children:[i.jsx("span",{className:"font-mono text-[13px] text-muted-foreground",children:e.kind==="commit"?"Generated commit message":"Generated pull request"}),i.jsx(a1,{type:"button",variant:"ghost",size:"xs",onClick:()=>{r()},title:t?"Copied":"Copy","aria-label":t?"Copied":"Copy",className:"text-muted-foreground hover:text-foreground md:opacity-0 md:group-hover:opacity-100",children:t?i.jsx(z,{name:"check",className:"size-3.5"}):i.jsx(z,{name:"file-copy",className:"size-3.5"})})]}),i.jsx("div",{className:"space-y-3 px-3 py-3",children:e.kind==="commit"?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"typography-ui-label text-foreground",children:e.subject}),e.highlights.length>0?i.jsx("ul",{className:"space-y-1 text-sm text-muted-foreground",children:e.highlights.map((a,l)=>i.jsxs("li",{className:"flex gap-2",children:[i.jsx("span",{className:"text-muted-foreground/70",children:"-"}),i.jsx("span",{children:a})]},`${l}-${a}`))}):null]}):i.jsxs(i.Fragment,{children:[e.title?i.jsxs("div",{children:[i.jsx("div",{className:"typography-micro uppercase tracking-[0.12em] text-muted-foreground",children:"Title"}),i.jsx("div",{className:"mt-1 typography-ui-label text-foreground",children:e.title})]}):null,e.body?i.jsxs("div",{children:[i.jsx("div",{className:"typography-micro uppercase tracking-[0.12em] text-muted-foreground",children:"Body"}),i.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-words text-sm leading-relaxed text-muted-foreground font-sans",children:e.body})]}):null]})})]})},WT=e=>{const t=e.trim(),n=[],s=t.match(/^```(?:json)?\s*([\s\S]*?)```$/i);s?.[1]&&n.push(s[1].trim()),t.startsWith("{")&&t.endsWith("}")&&n.push(t);const o=[];for(const r of n)try{const a=JSON.parse(r);a&&typeof a=="object"&&!Array.isArray(a)&&o.push(a)}catch{}return o},KT=e=>{for(const t of WT(e)){const n=typeof t.subject=="string"?t.subject.trim():"",s=Array.isArray(t.highlights)?t.highlights.filter(a=>typeof a=="string").map(a=>a.trim()).filter(Boolean).slice(0,3):[];if(n)return{kind:"commit",subject:n,highlights:s,raw:JSON.stringify({subject:n,highlights:s},null,2)};const o=typeof t.title=="string"?t.title.trim():"",r=typeof t.body=="string"?t.body.trim():"";if(o||r)return{kind:"pr",title:o,body:r,raw:JSON.stringify({title:o,body:r},null,2)}}return null},YT=({part:e,messageId:t,streamPhase:n,onShowPopup:s})=>{const o=e,r=typeof o.text=="string"?o.text:"",a=typeof o.content=="string"?o.content:"",l=typeof o.value=="string"?o.value:"",c=[r,a,l].reduce((v,x)=>x.length>v.length?x:v,""),h=n==="streaming"||n==="cooldown";E0("ui.assistant_text_part.render"),h&&E0("ui.assistant_text_part.render.streaming");const m=g5({text:c,isStreaming:h,identityKey:`${t}:${e.id??"text"}`}),p=qT({textContent:c,throttledTextContent:m,isStreaming:h});Ug("ui.assistant_text_part.display_len",p.length);const g=o.time,y=!!(g&&typeof g.end<"u");if(!(e.type==="text"||e.type==="reasoning")||!UT({displayTextContent:p,isFinalized:y}))return null;const b=!h&&y?KT(p):null;return b?i.jsx("div",{className:"group/assistant-text relative my-1 w-full min-w-0 break-words",children:i.jsx(GT,{result:b})},e.id||`${t}-text`):i.jsx("div",{className:"group/assistant-text relative my-1 w-full min-w-0 break-words",children:i.jsx(_f,{content:p,part:e,messageId:t,isAnimated:!1,isStreaming:h,variant:e.type==="reasoning"?"reasoning":"assistant",enableFileReferences:y,onShowPopup:s})},e.id||`${t}-text`)},Q7=d.memo(YT),Am="!text-[length:var(--text-meta)] !leading-5 sm:!leading-6 tracking-normal",Hl=B("typography-meta font-medium",Am),ed=B("typography-meta",Am),JT=e=>typeof e!="string"||e.trim().length===0?"":e.split(`
@@ -7022,14 +7022,14 @@ ${n}`:n},id=8,pV=280,gV=({containerRef:e})=>{const[t,n]=d.useState({x:0,y:0,show
7022
7022
  ${C2.cssText}
7023
7023
  transform: none;
7024
7024
  contain: none;
7025
- `,g2.querySelectorAll('[data-message-actions="true"]').forEach(_2=>{_2.style.display="none"}),g2.querySelectorAll('[data-message-action-group="true"]').forEach(_2=>{_2.style.display="none"});const J2=g2.querySelectorAll('[aria-label^="Message time:"]'),o2=new Set;J2.forEach(_2=>{const Ge=_2.getAttribute("aria-label")?.replace("Message time:","").trim();if(!Ge||_2.textContent?.includes(Ge))return;const b1=document.createElement("span");b1.style.marginLeft="4px",b1.textContent=Ge,_2.appendChild(b1);const Ye=_2.parentElement?.parentElement;!Ye||o2.has(Ye)||(Ye.style.justifyContent="flex-start",o2.add(Ye))}),Re.appendChild(g2),document.body.appendChild(Re);const B2=await f1(Re,{quality:1,pixelRatio:2,backgroundColor:K2}),lt=`message-${t}.png`,d2=document.createElement("a");d2.download=lt,d2.href=B2,document.body.appendChild(d2),d2.click(),document.body.removeChild(d2),Ue.success("Image saved")}catch(f1){console.error("Failed to generate image:",f1),Ue.error("Failed to generate image")}finally{Re&&Re.parentNode&&Re.parentNode.removeChild(Re)}},[t]),_1=!!_,m2=L==="info"?"information":"error-warning",at=M1,F1=!!w?.isWorking,re=se&&(v||!!_)&&!F1,Ne=T&&at&&!re,Oe=d.useMemo(()=>i.jsx(rN,{hasCopyableText:M1,isTouchContext:I,onCopyMessage:x,onShareImage:C1,sessionId:e,messageId:t,isLatestMessage:c}),[M1,c,I,t,x,e,C1]),Ke=d.useMemo(()=>{if(!Ne)return-1;let ke=-1;for(let e1=0;e1<Z.length;e1+=1){const Re=Z[e1];!Re||Re.type!=="text"||(ke=e1)}return ke},[Ne,Z]),c1=Ne&&Ke<0,u1=d.useMemo(()=>{const ke=[];let e1=0;for(;e1<Z.length;){const Re=Z[e1];if(Re.type==="text"){ke.push(i.jsx("div",{ref:$,"data-message-text-export-source":"true",children:i.jsx(Q7,{part:Re,sessionId:e,messageId:t,streamPhase:le,onContentChange:b,onShowPopup:g})},`assistant-text-${t}-${e1}`)),Ne&&e1===Ke&&ke.push(i.jsx("div",{className:dd,"data-message-actions":"true",children:i.jsx("div",{className:"flex items-center gap-1.5","data-message-action-group":"true",children:Oe})},`message-actions-${t}`)),e1++;continue}if(Re.type==="reasoning"){C&&(me?ke.push(i.jsx(Im,{part:Re,messageId:t,streamPhase:le,onContentChange:b,collapseByDefault:U},`reasoning-${t}-${e1}`)):ke.push(i.jsx(Q7,{part:Re,sessionId:e,messageId:t,streamPhase:le,onContentChange:b,onShowPopup:g},`reasoning-${t}-${e1}`))),e1++;continue}if(Re.type==="tool"){const f1=Re,Y1=f1.tool?.toLowerCase()??"";if(pm(Y1)){ke.push(i.jsx(It,{children:i.jsx(ho,{animate:Y.has(f1.id),wipe:!0,children:i.jsx(km,{part:f1,isExpanded:m.has(f1.id),onToggle:p,isMobile:u,alwaysShowActions:q,onContentChange:b,onShowPopup:g,animateTailText:Y.has(f1.id)})})},`tool-${f1.id}`)),e1++;continue}ke.push(i.jsx(It,{children:i.jsx(ho,{animate:Y.has(f1.id),wipe:!0,children:i.jsx($m,{toolName:Y1,activities:[{id:f1.id,turnId:"",messageId:t,partIndex:0,part:f1,kind:"tool"}],animateTailText:Y.has(f1.id)})})},`static-tools-${f1.id}`)),e1++;continue}e1++}return ke},[q,Y,me,U,m,u,Ke,t,Oe,e,b,g,p,Ne,le,C,Z]),v1=d.useMemo(()=>{if(!se||F1)return;if(typeof l=="number"&&l>0)return jl(l);if(typeof r=="number"&&typeof a=="number"&&r>a)return jl(r-a);const ke=w?.userMessageCreatedAt;if(typeof ke=="number"&&typeof r=="number"&&r>ke)return jl(r-ke)},[se,F1,l,r,a,w?.userMessageCreatedAt]),L1=d.useMemo(()=>{const ke=typeof r=="number"&&r>0?r:typeof a=="number"&&a>0?a:null;if(ke===null)return null;const e1=Om(ke,Q);return e1.length>0?e1:null},[r,a,Q]),s2="text-sm text-muted-foreground/60 tabular-nums flex items-center gap-1",K1=!pe&&!u,I2=i.jsx(i.Fragment,{children:K1&&He?i.jsxs(q1,{children:[i.jsx(U1,{asChild:!0,children:i.jsx(a1,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground bg-transparent hover:text-foreground hover:!bg-transparent active:!bg-transparent focus-visible:!bg-transparent focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":"Open preview",onPointerDown:ke=>ke.stopPropagation(),onClick:()=>{const ke=X??(je?Pe(je):null);ke&&te(ke,He)},children:i.jsx(z,{name:"global",className:"h-4 w-4"})})}),i.jsx(G1,{sideOffset:6,children:"Open preview"})]}):null});return i.jsxs("div",{ref:R,"data-message-text-export-root":"true",className:B("relative w-full group/message"),style:qm,children:[i.jsx(gV,{containerRef:R}),i.jsxs("div",{children:[i.jsxs("div",{className:"message-content-text leading-relaxed overflow-hidden text-foreground/90 [&_p:last-child]:mb-0 [&_ul:last-child]:mb-0 [&_ol:last-child]:mb-0",children:[u1,_1&&i.jsx(It,{children:i.jsx("div",{className:B("group/assistant-text relative mt-3 p-3 rounded-lg border break-words max-w-full",L==="info"?"bg-[var(--status-info-background)] border-[var(--status-info-border)]":"bg-[var(--status-error-background)] border-[var(--status-error-border)]"),children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(z,{name:m2,className:B("h-4 w-4 shrink-0",L==="info"?"text-[var(--status-info)]":"text-[var(--status-error)]")}),i.jsx("div",{className:"min-w-0 flex-1 break-words",children:i.jsx(xo,{content:_??"",onShowPopup:g,className:"[&_.markdown-content>*:first-child]:mt-0 [&_.markdown-content>*:last-child]:mb-0",enableFileReferences:!1})})]})})},"assistant-error")]}),i.jsx(Xi,{files:n,onShowPopup:g}),c1&&i.jsx("div",{className:dd,"data-message-actions":"true",children:i.jsx("div",{className:"flex items-center gap-1.5","data-message-action-group":"true",children:Oe})}),re&&i.jsxs("div",{className:"mt-2 mb-1 flex flex-wrap items-center justify-start gap-x-3 gap-y-1.5",style:GV,children:[i.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-1 text-sm text-muted-foreground/60",children:[N?i.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[W&&G?i.jsx("img",{src:G,alt:"",className:"h-3.5 w-3.5 flex-shrink-0",style:{filter:H?"brightness(0.9) contrast(1.1) invert(1)":"brightness(0.9) contrast(1.1)"},onError:K}):i.jsx(z,{name:"brain-ai-3",className:"h-3.5 w-3.5 flex-shrink-0",style:{color:`var(${UV(k).var})`}}),i.jsx("span",{className:"truncate",children:N})]}):null,V&&!["default","none"].includes(V.toLowerCase())?i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(z,{name:"brain-ai-3",className:"h-3.5 w-3.5 flex-shrink-0"}),i.jsx("span",{className:"message-footer__label",children:V[0].toLowerCase()+V.slice(1)})]}):null,k?i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(z,{name:"ai-agent",className:"h-3.5 w-3.5 flex-shrink-0"}),i.jsx("span",{className:"message-footer__label",children:k})]}):null,v1?i.jsxs(q1,{children:[i.jsx(U1,{asChild:!0,children:i.jsxs("span",{className:"text-sm text-muted-foreground/60 tabular-nums flex items-center gap-1",children:[i.jsx(z,{name:"hourglass",className:"h-3.5 w-3.5"}),i.jsx("span",{className:"message-footer__label",children:v1})]})}),i.jsx(G1,{children:v1})]}):null,L1?i.jsxs(q1,{children:[i.jsx(U1,{asChild:!0,children:i.jsxs("span",{className:s2,"aria-label":`Message time: ${L1}`,children:[i.jsx(z,{name:"time",className:"h-3.5 w-3.5"}),i.jsx("span",{className:"message-footer__label",children:L1})]})}),i.jsx(G1,{children:L1})]}):null,!pe&&se&&ye?i.jsx(Bm,{activityParts:w?.activityParts}):null,!pe&&se&&ye?i.jsx(XV,{files:w?.changedFiles,isInteractive:w?.isLatestTurn===!0}):null]}),i.jsxs("div",{className:B("flex items-center gap-1.5",q||I?void 0:"pointer-events-none opacity-0 transition-opacity duration-150 focus-within:pointer-events-auto focus-within:opacity-100 group-hover/message:pointer-events-auto group-hover/message:opacity-100"),"data-message-action-group":"true",children:[Oe,I2]})]})]})]})}),Il=d.memo(({isUser:e,...t})=>e?i.jsx(oN,{sessionId:t.sessionId,messageId:t.messageId,parts:t.parts,messageCreatedAt:t.messageCreatedAt,isMobile:t.isMobile,alwaysShowActions:t.alwaysShowActions,hasTouchInput:t.hasTouchInput,hasTextContent:t.hasTextContent,onCopyMessage:t.onCopyMessage,copiedMessage:t.copiedMessage,onShowPopup:t.onShowPopup,agentMention:t.agentMention,userActionsMode:t.userActionsMode,stickyUserHeaderEnabled:t.stickyUserHeaderEnabled}):i.jsx(iN,{...t})),ji=e=>{const t=e,n=t?.clientRole,s=t?.role;return t?.userMessageMarker===!0||n==="user"||s==="user"||t?.origin==="user"||t?.source==="user"?{role:"user",isUser:!0}:{role:n||s||"assistant",isUser:!1}},Gm="GitHub issue context (JSON)",Wm="GitHub pull request context (JSON)",pd=e=>typeof e=="number"&&Number.isFinite(e)&&e>0,gd=(e,t)=>{const n=e.trimStart();if(!n.startsWith(t))return null;const s=n.indexOf("{");if(s<0)return null;try{return JSON.parse(n.slice(s))}catch{return null}},aN=e=>{const t=gd(e,Gm);if(t){const s=t.issue,o=s?.number,r=s?.title,a=s?.url;return!pd(o)||typeof r!="string"||typeof a!="string"?null:{type:"file",mime:"application/vnd.github.issue-link",filename:`Issue #${o}: ${r}`,url:a}}const n=gd(e,Wm);if(n){const s=n.pr,o=s?.number,r=s?.title,a=s?.url;return!pd(o)||typeof r!="string"||typeof a!="string"?null:{type:"file",mime:"application/vnd.github.pull-request-link",filename:`PR #${o}: ${r}`,url:a}}return null},lN=e=>!!e.trim().startsWith("The following tool was executed by the user"),k5=e=>e.filter(t=>{if(!(t.synthetic===!0))return!0;if(t.type!=="text")return!1;const s=t.text;if(typeof s!="string")return!1;const o=s.trimStart();return lN(s)||o.startsWith(Gm)||o.startsWith(Wm)}).map(t=>{const n=t;if(n.type==="compaction")return{type:"text",text:"/compact"};if(n.type==="text"){const s=typeof n.text=="string"?n.text.trim():"";if(n.synthetic===!0){const r=aN(s);if(r)return r}if(s.startsWith("The following tool was executed by the user"))return{type:"text",text:"/shell"}}return t}),yd=new WeakMap,Ii=e=>{if(!e||!ji(e.info).isUser)return!1;const t=yd.get(e.parts);if(t!==void 0)return t;const n=k5(ma(e.parts)),s=Vm(n,{includeReasoning:!0}).length===0;return yd.set(e.parts,s),s},cN="Authentication failed for this provider. Please re-authenticate and retry.",dN=e=>{if(typeof e!="string")return!1;const t=e.toLowerCase().trim();if(!t)return!1;if(t.includes("token refresh failed")||t.includes("unauthorized")||t.includes("invalid token")||t.includes("expired token"))return!0;const n=t.includes("oauth"),s=t.includes("failed")||t.includes("invalid")||t.includes("expired");if(n&&s)return!0;const o=/\b401\b/.test(t),r=t.includes("auth")||t.includes("token")||t.includes("unauthorized");return o&&r},uN=bo(()=>V2(()=>import("./ToolOutputDialog-b_R4tAZu.js"),__vite__mapDeps([110,1,2,111,112,113,25,114,26,27,28,29,30,31,32,33,34,35,36,37,38,39,115,23,24,116,117,118,119,120,121,122,123,124,125,126,127,128,13,6,14,129,22,103,104,40,41,42,43,44,45,46,15,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,105,106,107,7,108,109]))),Km=4e3,vn=new Map,bn=new Map,fN=new Set(["bash","shell","cmd","terminal"]),hN=new Set(["apply_patch","edit","write","multiedit","str_replace","str_replace_based_edit_tool","create","file_write"]),mN=e=>{if(typeof e!="string")return"";const t=e.trim().toLowerCase();if(!t)return"";const n=t.replace(/:\d+$/,"");if(!n.includes("."))return n;const s=n.split(".").filter(Boolean);return s[s.length-1]??n},vd=e=>{const t=vn.get(e);return t?new Set(t):new Set},bd=(e,t)=>{if(vn.size>=Km&&!vn.has(e)){const n=vn.keys().next().value;typeof n=="string"&&vn.delete(n)}vn.set(e,new Set(t))},xd=e=>{const t=bn.get(e);return t?new Set(t):new Set},wd=(e,t)=>{if(bn.size>=Km&&!bn.has(e)){const n=bn.keys().next().value;typeof n=="string"&&bn.delete(n)}bn.set(e,new Set(t))};function Bl(e){const[t,n]=d.useState(e);return d.useEffect(()=>{e!=null&&n(e)},[e]),e??t}const Z2=(e,t)=>{if(typeof e=="object"&&e!==null)return e[t]},M0=e=>{if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0},Md=e=>{const t=Z2(e,"model"),n=typeof t=="object"&&t!==null?t:null;return{providerId:M0(Z2(e,"providerID"))??M0(n?.providerID)??M0(n?.providerId),modelId:M0(Z2(e,"modelID"))??M0(n?.modelID)??M0(n?.modelId)}},pN=({message:e,previousMessage:t,nextMessage:n,onContentChange:s,animationHandlers:o,turnGroupingContext:r,assistantHeaderMessageId:a,isInActiveTurn:l=!1,activeStreamingPhase:c=null,animateUserOnMount:u=!1,onUserAnimationConsumed:f})=>{const{isMobile:h,isTablet:m,hasTouchInput:p}=c0(),g=h||m,{currentTheme:y}=Nt(),M=d.useRef(null),b=n2(be=>be.getAgentModelForSession),v=n2(be=>be.getSessionModelSelection);E0("ui.chat_message.render"),l&&E0("ui.chat_message.render.streaming");const x=$e(be=>be.providers),{showReasoningTraces:S,stickyUserHeader:C,showExpandedBashTools:w,showExpandedEditTools:_}=he(pc(be=>({showReasoningTraces:be.showReasoningTraces,stickyUserHeader:be.stickyUserHeader,showExpandedBashTools:be.showExpandedBashTools,showExpandedEditTools:be.showExpandedEditTools}))),[L,A]=d.useState(null),[N,k]=d.useState(!1),[V,H]=d.useState(()=>vd(e.info.id)),[D,P]=d.useState(()=>xd(e.info.id)),[R,$]=d.useState({open:!1,title:"",content:""});d.useEffect(()=>{H(vd(e.info.id)),P(xd(e.info.id))},[e.info.id]);const I=d.useMemo(()=>ji(e.info),[e.info]).isUser,q=I&&(h||!C),G=I&&!h&&C&&!q,K=e.info.sessionID,{currentContextAgent:W,savedSessionAgentSelection:ge}=W3(pc(be=>({currentContextAgent:l&&K?be.currentAgentContext.get(K):void 0,savedSessionAgentSelection:l&&K?be.sessionAgentSelections.get(K):void 0}))),Z=d.useMemo(()=>{const be=ma(e.parts);return I?k5(be):be},[I,e.parts]),fe=d.useMemo(()=>{if(I||!t)return null;const be=Z2(t.info,"clientRole"),Ge=Z2(t.info,"role");if((typeof be=="string"?be:typeof Ge=="string"?Ge:void 0)!=="user")return null;const d1=Z2(t.info,"mode"),Ye=Z2(t.info,"agent"),a2=Md(t.info),k2=Z2(t.info,"variant"),X2=typeof d1=="string"&&d1.trim().length>0?d1:typeof Ye=="string"&&Ye.trim().length>0?Ye:void 0,f0=a2.providerId,h0=a2.modelId,m0=typeof k2=="string"&&k2.trim().length>0?k2:void 0;return!X2&&!f0&&!h0&&!m0?null:{agentName:X2,providerId:f0,modelId:h0,variant:m0}},[I,t]),ie=d.useMemo(()=>{if(I)return;const be=Z2(e.info,"mode");if(typeof be=="string"&&be.trim().length>0)return be;const Ge=Z2(e.info,"agent");if(typeof Ge=="string"&&Ge.trim().length>0)return Ge;if(fe?.agentName)return fe.agentName;if(K)return W||(ge??void 0)},[I,e.info,fe,K,W,ge]),E=I?{providerId:void 0,modelId:void 0}:Md(e.info),ce=E.providerId??null,ee=E.modelId??null,ue=d.useMemo(()=>{if(I||!K)return null;if(fe?.providerId&&fe?.modelId)return{providerId:fe.providerId,modelId:fe.modelId};if(ie){const Ge=b(K,ie);if(Ge?.providerId&&Ge?.modelId)return Ge}const be=v(K);return be?.providerId&&be?.modelId?be:null},[I,K,ie,fe,b,v]),J=d.useMemo(()=>I?null:typeof ce=="string"&&ce.trim().length>0?ce:ue?.providerId??null,[I,ce,ue]),Y=d.useMemo(()=>I?null:typeof ee=="string"&&ee.trim().length>0?ee:ue?.modelId??null,[I,ee,ue]),oe=d.useMemo(()=>{if(I)return;const be=J&&x.length>0?x.find(Ge=>Ge.id===J):void 0;return ru(be,Y)||void 0},[I,J,Y,x]),te=d.useMemo(()=>{if(I||!J||!Y)return!1;const be=x.find(d1=>d1.id===J);if(!be?.models||!Array.isArray(be.models))return!1;const b1=be.models.find(d1=>d1.id===Y)?.variants;return!!(b1&&Object.keys(b1).length>0)},[I,Y,J,x]),pe=Bl(ie),He=Bl(J??void 0),je=Bl(oe),Pe=pe??void 0,X=He??null,me=je??void 0,U=d.useMemo(()=>{const be=e.info.time;return typeof be?.completed=="number"?be.completed:null},[e.info.time]),T=d.useMemo(()=>{const be=e.info.time;return typeof be?.created=="number"?be.created:null},[e.info.time]),Q=d.useMemo(()=>I?!0:!!(U&&U>0),[I,U]),se=d.useMemo(()=>{const be=e.info.finish;return typeof be=="string"?be:void 0},[e.info]),ye=d.useMemo(()=>Vm(Z,{includeReasoning:S}),[Z,S]),le=ye,ne=d.useMemo(()=>I?[]:ye.filter(be=>be.type==="text"),[I,ye]),Ce=d.useMemo(()=>I?[]:ye.filter(Ge=>Ge.type==="tool"),[I,ye]),Se=d.useMemo(()=>I?[]:(r?.activityParts??[]).filter(Ge=>Ge.kind==="tool").map(Ge=>Ge.part).filter(Ge=>Ge.type==="tool"),[I,r?.activityParts]),Ae=d.useMemo(()=>{if(!w&&!_)return new Set;const be=new Set;for(const Ge of[...Ce,...Se]){const b1=typeof Ge?.id=="string"?Ge.id:"";if(!b1)continue;const d1=mN(Ge.tool);if(d1){if(w&&fN.has(d1)){be.add(b1);continue}_&&hN.has(d1)&&be.add(b1)}}return be},[w,_,Ce,Se]),Ve=d.useMemo(()=>{if(Ae.size===0&&D.size===0)return V;const be=new Set(V);return Ae.forEach(Ge=>{D.has(Ge)||be.add(Ge)}),D.forEach(Ge=>{be.delete(Ge)}),be},[D,Ae,V]),Me=d.useMemo(()=>{if(!I)return;const be=Z.find(Ye=>Ye.type==="agent");if(!be)return;const Ge=be,b1=typeof Ge.name=="string"?Ge.name:void 0;if(!b1)return;const d1=Ge.source&&typeof Ge.source.value=="string"&&Ge.source.value.trim().length>0?Ge.source.value:`@${b1}`;return{name:b1,token:d1}},[I,Z]),Ie=I&&le.length===0,qe=!Q&&typeof se!="string",n1=d.useMemo(()=>I?!1:ne.length===0||Ce.length===0?qe:!0,[ne.length,Ce.length,qe,I]),de=y?.metadata.variant,Le=d.useMemo(()=>de?de==="dark":typeof document<"u"?document.documentElement.classList.contains("dark"):!1,[de]),xe=d.useMemo(()=>I?!1:B0.getInstance().shouldAnimateMessage(e.info,e.info.sessionID),[e.info,I]),[ve,Te]=d.useState(!1),Qe=d.useMemo(()=>n?ji(n.info):null,[n]),M1=!!r,C1=r?.isLastAssistantInTurn??!1,_1=d.useMemo(()=>!I&&Ii(t),[I,t]),m2=d.useMemo(()=>!I&&Ii(n),[I,n]),at=d.useMemo(()=>I?!1:M1?!C1:Qe?!Qe.isUser&&Qe.role==="assistant":!1,[M1,C1,I,Qe]),F1=d.useMemo(()=>Q?"completed":l?c??"streaming":"completed",[c,l,Q]);d.useEffect(()=>{!I||!u||f?.(e.info.id)},[u,I,e.info.id,f]),d.useEffect(()=>{Te(!1)},[e.info.id]),d.useEffect(()=>{const be=a??r?.headerMessageId;if(I||!be||be!==e.info.id)return;(F1==="streaming"||F1==="cooldown")&&Te(!0)},[a,I,e.info.id,F1,r?.headerMessageId]);const re=d.useMemo(()=>{if(I)return!0;const be=a??r?.headerMessageId;return be?e.info.id===be?F1==="completed"?!0:ve||(F1==="streaming"||F1==="cooldown"):!1:!0},[a,ve,I,r,F1,e.info.id]),Ne=d.useCallback(be=>{gt(be).then(Ge=>{Ge.ok&&(A(be),setTimeout(()=>A(null),2e3))})},[]),Oe=I?void 0:M0(Z2(e.info,"variant"))??r?.userMessageVariant??fe?.variant,Ke=I?void 0:te?Oe??"Default":Oe,c1=d.useMemo(()=>{if(I)return;const be=e.info?.error;if(!be)return;const Ge=typeof be.data?.message=="string"?be.data.message:void 0,b1=typeof be.message=="string"?be.message:void 0,d1=typeof be.name=="string"?be.name:void 0,Ye=Ge||b1||d1;if(Ye)return d1==="SessionRetry"?{text:`Retrying after an error:
7025
+ `,g2.querySelectorAll('[data-message-actions="true"]').forEach(_2=>{_2.style.display="none"}),g2.querySelectorAll('[data-message-action-group="true"]').forEach(_2=>{_2.style.display="none"});const J2=g2.querySelectorAll('[aria-label^="Message time:"]'),o2=new Set;J2.forEach(_2=>{const Ge=_2.getAttribute("aria-label")?.replace("Message time:","").trim();if(!Ge||_2.textContent?.includes(Ge))return;const b1=document.createElement("span");b1.style.marginLeft="4px",b1.textContent=Ge,_2.appendChild(b1);const Ye=_2.parentElement?.parentElement;!Ye||o2.has(Ye)||(Ye.style.justifyContent="flex-start",o2.add(Ye))}),Re.appendChild(g2),document.body.appendChild(Re);const B2=await f1(Re,{quality:1,pixelRatio:2,backgroundColor:K2}),lt=`message-${t}.png`,d2=document.createElement("a");d2.download=lt,d2.href=B2,document.body.appendChild(d2),d2.click(),document.body.removeChild(d2),Ue.success("Image saved")}catch(f1){console.error("Failed to generate image:",f1),Ue.error("Failed to generate image")}finally{Re&&Re.parentNode&&Re.parentNode.removeChild(Re)}},[t]),_1=!!_,m2=L==="info"?"information":"error-warning",at=M1,F1=!!w?.isWorking,re=se&&(v||!!_)&&!F1,Ne=T&&at&&!re,Oe=d.useMemo(()=>i.jsx(rN,{hasCopyableText:M1,isTouchContext:I,onCopyMessage:x,onShareImage:C1,sessionId:e,messageId:t,isLatestMessage:c}),[M1,c,I,t,x,e,C1]),Ke=d.useMemo(()=>{if(!Ne)return-1;let ke=-1;for(let e1=0;e1<Z.length;e1+=1){const Re=Z[e1];!Re||Re.type!=="text"||(ke=e1)}return ke},[Ne,Z]),c1=Ne&&Ke<0,u1=d.useMemo(()=>{const ke=[];let e1=0;for(;e1<Z.length;){const Re=Z[e1];if(Re.type==="text"){ke.push(i.jsx("div",{ref:$,"data-message-text-export-source":"true",children:i.jsx(Q7,{part:Re,sessionId:e,messageId:t,streamPhase:le,onContentChange:b,onShowPopup:g})},`assistant-text-${t}-${e1}`)),Ne&&e1===Ke&&ke.push(i.jsx("div",{className:dd,"data-message-actions":"true",children:i.jsx("div",{className:"flex items-center gap-1.5","data-message-action-group":"true",children:Oe})},`message-actions-${t}`)),e1++;continue}if(Re.type==="reasoning"){C&&(me?ke.push(i.jsx(Im,{part:Re,messageId:t,streamPhase:le,onContentChange:b,collapseByDefault:U},`reasoning-${t}-${e1}`)):ke.push(i.jsx(Q7,{part:Re,sessionId:e,messageId:t,streamPhase:le,onContentChange:b,onShowPopup:g},`reasoning-${t}-${e1}`))),e1++;continue}if(Re.type==="tool"){const f1=Re,Y1=f1.tool?.toLowerCase()??"";if(pm(Y1)){ke.push(i.jsx(It,{children:i.jsx(ho,{animate:Y.has(f1.id),wipe:!0,children:i.jsx(km,{part:f1,isExpanded:m.has(f1.id),onToggle:p,isMobile:u,alwaysShowActions:q,onContentChange:b,onShowPopup:g,animateTailText:Y.has(f1.id)})})},`tool-${f1.id}`)),e1++;continue}ke.push(i.jsx(It,{children:i.jsx(ho,{animate:Y.has(f1.id),wipe:!0,children:i.jsx($m,{toolName:Y1,activities:[{id:f1.id,turnId:"",messageId:t,partIndex:0,part:f1,kind:"tool"}],animateTailText:Y.has(f1.id)})})},`static-tools-${f1.id}`)),e1++;continue}e1++}return ke},[q,Y,me,U,m,u,Ke,t,Oe,e,b,g,p,Ne,le,C,Z]),v1=d.useMemo(()=>{if(!se||F1)return;if(typeof l=="number"&&l>0)return jl(l);if(typeof r=="number"&&typeof a=="number"&&r>a)return jl(r-a);const ke=w?.userMessageCreatedAt;if(typeof ke=="number"&&typeof r=="number"&&r>ke)return jl(r-ke)},[se,F1,l,r,a,w?.userMessageCreatedAt]),L1=d.useMemo(()=>{const ke=typeof r=="number"&&r>0?r:typeof a=="number"&&a>0?a:null;if(ke===null)return null;const e1=Om(ke,Q);return e1.length>0?e1:null},[r,a,Q]),s2="text-sm text-muted-foreground/60 tabular-nums flex items-center gap-1",K1=!pe&&!u,I2=i.jsx(i.Fragment,{children:K1&&He?i.jsxs(q1,{children:[i.jsx(U1,{asChild:!0,children:i.jsx(a1,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground bg-transparent hover:text-foreground hover:!bg-transparent active:!bg-transparent focus-visible:!bg-transparent focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":"Open preview",onPointerDown:ke=>ke.stopPropagation(),onClick:()=>{const ke=X??(je?Pe(je):null);ke&&te(ke,He)},children:i.jsx(z,{name:"global",className:"h-4 w-4"})})}),i.jsx(G1,{sideOffset:6,children:"Open preview"})]}):null});return i.jsxs("div",{ref:R,"data-message-text-export-root":"true",className:B("relative w-full group/message"),style:qm,children:[i.jsx(gV,{containerRef:R}),i.jsxs("div",{children:[i.jsxs("div",{className:"message-content-text leading-relaxed overflow-hidden text-foreground/90 [&_p:last-child]:mb-0 [&_ul:last-child]:mb-0 [&_ol:last-child]:mb-0",children:[u1,_1&&i.jsx(It,{children:i.jsx("div",{className:B("group/assistant-text relative mt-3 p-3 rounded-lg border break-words max-w-full",L==="info"?"bg-[var(--status-info-background)] border-[var(--status-info-border)]":"bg-[var(--status-error-background)] border-[var(--status-error-border)]"),children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(z,{name:m2,className:B("h-4 w-4 shrink-0",L==="info"?"text-[var(--status-info)]":"text-[var(--status-error)]")}),i.jsx("div",{className:"min-w-0 flex-1 break-words",children:i.jsx(xo,{content:_??"",onShowPopup:g,className:"[&_.markdown-content>*:first-child]:mt-0 [&_.markdown-content>*:last-child]:mb-0",enableFileReferences:!1})})]})})},"assistant-error")]}),i.jsx(Xi,{files:n,onShowPopup:g}),c1&&i.jsx("div",{className:dd,"data-message-actions":"true",children:i.jsx("div",{className:"flex items-center gap-1.5","data-message-action-group":"true",children:Oe})}),re&&i.jsxs("div",{className:"mt-2 mb-1 flex flex-wrap items-center justify-start gap-x-3 gap-y-1.5",style:GV,children:[i.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-1 text-sm text-muted-foreground/60",children:[N?i.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[W&&G?i.jsx("img",{src:G,alt:"",className:"h-3.5 w-3.5 flex-shrink-0",style:{filter:H?"brightness(0.9) contrast(1.1) invert(1)":"brightness(0.9) contrast(1.1)"},onError:K}):i.jsx(z,{name:"brain-ai-3",className:"h-3.5 w-3.5 flex-shrink-0",style:{color:`var(${UV(k).var})`}}),i.jsx("span",{className:"truncate",children:N})]}):null,V&&!["default","none"].includes(V.toLowerCase())?i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(z,{name:"brain-ai-3",className:"h-3.5 w-3.5 flex-shrink-0"}),i.jsx("span",{className:"message-footer__label",children:V[0].toLowerCase()+V.slice(1)})]}):null,k?i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(z,{name:"ai-agent",className:"h-3.5 w-3.5 flex-shrink-0"}),i.jsx("span",{className:"message-footer__label",children:k})]}):null,v1?i.jsxs(q1,{children:[i.jsx(U1,{asChild:!0,children:i.jsxs("span",{className:"text-sm text-muted-foreground/60 tabular-nums flex items-center gap-1",children:[i.jsx(z,{name:"hourglass",className:"h-3.5 w-3.5"}),i.jsx("span",{className:"message-footer__label",children:v1})]})}),i.jsx(G1,{children:v1})]}):null,L1?i.jsxs(q1,{children:[i.jsx(U1,{asChild:!0,children:i.jsxs("span",{className:s2,"aria-label":`Message time: ${L1}`,children:[i.jsx(z,{name:"time",className:"h-3.5 w-3.5"}),i.jsx("span",{className:"message-footer__label",children:L1})]})}),i.jsx(G1,{children:L1})]}):null,!pe&&se&&ye?i.jsx(Bm,{activityParts:w?.activityParts}):null,!pe&&se&&ye?i.jsx(XV,{files:w?.changedFiles,isInteractive:w?.isLatestTurn===!0}):null]}),i.jsxs("div",{className:B("flex items-center gap-1.5",q||I?void 0:"pointer-events-none opacity-0 transition-opacity duration-150 focus-within:pointer-events-auto focus-within:opacity-100 group-hover/message:pointer-events-auto group-hover/message:opacity-100"),"data-message-action-group":"true",children:[Oe,I2]})]})]})]})}),Il=d.memo(({isUser:e,...t})=>e?i.jsx(oN,{sessionId:t.sessionId,messageId:t.messageId,parts:t.parts,messageCreatedAt:t.messageCreatedAt,isMobile:t.isMobile,alwaysShowActions:t.alwaysShowActions,hasTouchInput:t.hasTouchInput,hasTextContent:t.hasTextContent,onCopyMessage:t.onCopyMessage,copiedMessage:t.copiedMessage,onShowPopup:t.onShowPopup,agentMention:t.agentMention,userActionsMode:t.userActionsMode,stickyUserHeaderEnabled:t.stickyUserHeaderEnabled}):i.jsx(iN,{...t})),ji=e=>{const t=e,n=t?.clientRole,s=t?.role;return t?.userMessageMarker===!0||n==="user"||s==="user"||t?.origin==="user"||t?.source==="user"?{role:"user",isUser:!0}:{role:n||s||"assistant",isUser:!1}},Gm="GitHub issue context (JSON)",Wm="GitHub pull request context (JSON)",pd=e=>typeof e=="number"&&Number.isFinite(e)&&e>0,gd=(e,t)=>{const n=e.trimStart();if(!n.startsWith(t))return null;const s=n.indexOf("{");if(s<0)return null;try{return JSON.parse(n.slice(s))}catch{return null}},aN=e=>{const t=gd(e,Gm);if(t){const s=t.issue,o=s?.number,r=s?.title,a=s?.url;return!pd(o)||typeof r!="string"||typeof a!="string"?null:{type:"file",mime:"application/vnd.github.issue-link",filename:`Issue #${o}: ${r}`,url:a}}const n=gd(e,Wm);if(n){const s=n.pr,o=s?.number,r=s?.title,a=s?.url;return!pd(o)||typeof r!="string"||typeof a!="string"?null:{type:"file",mime:"application/vnd.github.pull-request-link",filename:`PR #${o}: ${r}`,url:a}}return null},lN=e=>!!e.trim().startsWith("The following tool was executed by the user"),k5=e=>e.filter(t=>{if(!(t.synthetic===!0))return!0;if(t.type!=="text")return!1;const s=t.text;if(typeof s!="string")return!1;const o=s.trimStart();return lN(s)||o.startsWith(Gm)||o.startsWith(Wm)}).map(t=>{const n=t;if(n.type==="compaction")return{type:"text",text:"/compact"};if(n.type==="text"){const s=typeof n.text=="string"?n.text.trim():"";if(n.synthetic===!0){const r=aN(s);if(r)return r}if(s.startsWith("The following tool was executed by the user"))return{type:"text",text:"/shell"}}return t}),yd=new WeakMap,Ii=e=>{if(!e||!ji(e.info).isUser)return!1;const t=yd.get(e.parts);if(t!==void 0)return t;const n=k5(ma(e.parts)),s=Vm(n,{includeReasoning:!0}).length===0;return yd.set(e.parts,s),s},cN="Authentication failed for this provider. Please re-authenticate and retry.",dN=e=>{if(typeof e!="string")return!1;const t=e.toLowerCase().trim();if(!t)return!1;if(t.includes("token refresh failed")||t.includes("unauthorized")||t.includes("invalid token")||t.includes("expired token"))return!0;const n=t.includes("oauth"),s=t.includes("failed")||t.includes("invalid")||t.includes("expired");if(n&&s)return!0;const o=/\b401\b/.test(t),r=t.includes("auth")||t.includes("token")||t.includes("unauthorized");return o&&r},uN=bo(()=>V2(()=>import("./ToolOutputDialog-2zKUdGYL.js"),__vite__mapDeps([110,1,2,111,112,113,25,114,26,27,28,29,30,31,32,33,34,35,36,37,38,39,115,23,24,116,117,118,119,120,121,122,123,124,125,126,127,128,13,6,14,129,22,103,104,40,41,42,43,44,45,46,15,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,105,106,107,7,108,109]))),Km=4e3,vn=new Map,bn=new Map,fN=new Set(["bash","shell","cmd","terminal"]),hN=new Set(["apply_patch","edit","write","multiedit","str_replace","str_replace_based_edit_tool","create","file_write"]),mN=e=>{if(typeof e!="string")return"";const t=e.trim().toLowerCase();if(!t)return"";const n=t.replace(/:\d+$/,"");if(!n.includes("."))return n;const s=n.split(".").filter(Boolean);return s[s.length-1]??n},vd=e=>{const t=vn.get(e);return t?new Set(t):new Set},bd=(e,t)=>{if(vn.size>=Km&&!vn.has(e)){const n=vn.keys().next().value;typeof n=="string"&&vn.delete(n)}vn.set(e,new Set(t))},xd=e=>{const t=bn.get(e);return t?new Set(t):new Set},wd=(e,t)=>{if(bn.size>=Km&&!bn.has(e)){const n=bn.keys().next().value;typeof n=="string"&&bn.delete(n)}bn.set(e,new Set(t))};function Bl(e){const[t,n]=d.useState(e);return d.useEffect(()=>{e!=null&&n(e)},[e]),e??t}const Z2=(e,t)=>{if(typeof e=="object"&&e!==null)return e[t]},M0=e=>{if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0},Md=e=>{const t=Z2(e,"model"),n=typeof t=="object"&&t!==null?t:null;return{providerId:M0(Z2(e,"providerID"))??M0(n?.providerID)??M0(n?.providerId),modelId:M0(Z2(e,"modelID"))??M0(n?.modelID)??M0(n?.modelId)}},pN=({message:e,previousMessage:t,nextMessage:n,onContentChange:s,animationHandlers:o,turnGroupingContext:r,assistantHeaderMessageId:a,isInActiveTurn:l=!1,activeStreamingPhase:c=null,animateUserOnMount:u=!1,onUserAnimationConsumed:f})=>{const{isMobile:h,isTablet:m,hasTouchInput:p}=c0(),g=h||m,{currentTheme:y}=Nt(),M=d.useRef(null),b=n2(be=>be.getAgentModelForSession),v=n2(be=>be.getSessionModelSelection);E0("ui.chat_message.render"),l&&E0("ui.chat_message.render.streaming");const x=$e(be=>be.providers),{showReasoningTraces:S,stickyUserHeader:C,showExpandedBashTools:w,showExpandedEditTools:_}=he(pc(be=>({showReasoningTraces:be.showReasoningTraces,stickyUserHeader:be.stickyUserHeader,showExpandedBashTools:be.showExpandedBashTools,showExpandedEditTools:be.showExpandedEditTools}))),[L,A]=d.useState(null),[N,k]=d.useState(!1),[V,H]=d.useState(()=>vd(e.info.id)),[D,P]=d.useState(()=>xd(e.info.id)),[R,$]=d.useState({open:!1,title:"",content:""});d.useEffect(()=>{H(vd(e.info.id)),P(xd(e.info.id))},[e.info.id]);const I=d.useMemo(()=>ji(e.info),[e.info]).isUser,q=I&&(h||!C),G=I&&!h&&C&&!q,K=e.info.sessionID,{currentContextAgent:W,savedSessionAgentSelection:ge}=W3(pc(be=>({currentContextAgent:l&&K?be.currentAgentContext.get(K):void 0,savedSessionAgentSelection:l&&K?be.sessionAgentSelections.get(K):void 0}))),Z=d.useMemo(()=>{const be=ma(e.parts);return I?k5(be):be},[I,e.parts]),fe=d.useMemo(()=>{if(I||!t)return null;const be=Z2(t.info,"clientRole"),Ge=Z2(t.info,"role");if((typeof be=="string"?be:typeof Ge=="string"?Ge:void 0)!=="user")return null;const d1=Z2(t.info,"mode"),Ye=Z2(t.info,"agent"),a2=Md(t.info),k2=Z2(t.info,"variant"),X2=typeof d1=="string"&&d1.trim().length>0?d1:typeof Ye=="string"&&Ye.trim().length>0?Ye:void 0,f0=a2.providerId,h0=a2.modelId,m0=typeof k2=="string"&&k2.trim().length>0?k2:void 0;return!X2&&!f0&&!h0&&!m0?null:{agentName:X2,providerId:f0,modelId:h0,variant:m0}},[I,t]),ie=d.useMemo(()=>{if(I)return;const be=Z2(e.info,"mode");if(typeof be=="string"&&be.trim().length>0)return be;const Ge=Z2(e.info,"agent");if(typeof Ge=="string"&&Ge.trim().length>0)return Ge;if(fe?.agentName)return fe.agentName;if(K)return W||(ge??void 0)},[I,e.info,fe,K,W,ge]),E=I?{providerId:void 0,modelId:void 0}:Md(e.info),ce=E.providerId??null,ee=E.modelId??null,ue=d.useMemo(()=>{if(I||!K)return null;if(fe?.providerId&&fe?.modelId)return{providerId:fe.providerId,modelId:fe.modelId};if(ie){const Ge=b(K,ie);if(Ge?.providerId&&Ge?.modelId)return Ge}const be=v(K);return be?.providerId&&be?.modelId?be:null},[I,K,ie,fe,b,v]),J=d.useMemo(()=>I?null:typeof ce=="string"&&ce.trim().length>0?ce:ue?.providerId??null,[I,ce,ue]),Y=d.useMemo(()=>I?null:typeof ee=="string"&&ee.trim().length>0?ee:ue?.modelId??null,[I,ee,ue]),oe=d.useMemo(()=>{if(I)return;const be=J&&x.length>0?x.find(Ge=>Ge.id===J):void 0;return ru(be,Y)||void 0},[I,J,Y,x]),te=d.useMemo(()=>{if(I||!J||!Y)return!1;const be=x.find(d1=>d1.id===J);if(!be?.models||!Array.isArray(be.models))return!1;const b1=be.models.find(d1=>d1.id===Y)?.variants;return!!(b1&&Object.keys(b1).length>0)},[I,Y,J,x]),pe=Bl(ie),He=Bl(J??void 0),je=Bl(oe),Pe=pe??void 0,X=He??null,me=je??void 0,U=d.useMemo(()=>{const be=e.info.time;return typeof be?.completed=="number"?be.completed:null},[e.info.time]),T=d.useMemo(()=>{const be=e.info.time;return typeof be?.created=="number"?be.created:null},[e.info.time]),Q=d.useMemo(()=>I?!0:!!(U&&U>0),[I,U]),se=d.useMemo(()=>{const be=e.info.finish;return typeof be=="string"?be:void 0},[e.info]),ye=d.useMemo(()=>Vm(Z,{includeReasoning:S}),[Z,S]),le=ye,ne=d.useMemo(()=>I?[]:ye.filter(be=>be.type==="text"),[I,ye]),Ce=d.useMemo(()=>I?[]:ye.filter(Ge=>Ge.type==="tool"),[I,ye]),Se=d.useMemo(()=>I?[]:(r?.activityParts??[]).filter(Ge=>Ge.kind==="tool").map(Ge=>Ge.part).filter(Ge=>Ge.type==="tool"),[I,r?.activityParts]),Ae=d.useMemo(()=>{if(!w&&!_)return new Set;const be=new Set;for(const Ge of[...Ce,...Se]){const b1=typeof Ge?.id=="string"?Ge.id:"";if(!b1)continue;const d1=mN(Ge.tool);if(d1){if(w&&fN.has(d1)){be.add(b1);continue}_&&hN.has(d1)&&be.add(b1)}}return be},[w,_,Ce,Se]),Ve=d.useMemo(()=>{if(Ae.size===0&&D.size===0)return V;const be=new Set(V);return Ae.forEach(Ge=>{D.has(Ge)||be.add(Ge)}),D.forEach(Ge=>{be.delete(Ge)}),be},[D,Ae,V]),Me=d.useMemo(()=>{if(!I)return;const be=Z.find(Ye=>Ye.type==="agent");if(!be)return;const Ge=be,b1=typeof Ge.name=="string"?Ge.name:void 0;if(!b1)return;const d1=Ge.source&&typeof Ge.source.value=="string"&&Ge.source.value.trim().length>0?Ge.source.value:`@${b1}`;return{name:b1,token:d1}},[I,Z]),Ie=I&&le.length===0,qe=!Q&&typeof se!="string",n1=d.useMemo(()=>I?!1:ne.length===0||Ce.length===0?qe:!0,[ne.length,Ce.length,qe,I]),de=y?.metadata.variant,Le=d.useMemo(()=>de?de==="dark":typeof document<"u"?document.documentElement.classList.contains("dark"):!1,[de]),xe=d.useMemo(()=>I?!1:B0.getInstance().shouldAnimateMessage(e.info,e.info.sessionID),[e.info,I]),[ve,Te]=d.useState(!1),Qe=d.useMemo(()=>n?ji(n.info):null,[n]),M1=!!r,C1=r?.isLastAssistantInTurn??!1,_1=d.useMemo(()=>!I&&Ii(t),[I,t]),m2=d.useMemo(()=>!I&&Ii(n),[I,n]),at=d.useMemo(()=>I?!1:M1?!C1:Qe?!Qe.isUser&&Qe.role==="assistant":!1,[M1,C1,I,Qe]),F1=d.useMemo(()=>Q?"completed":l?c??"streaming":"completed",[c,l,Q]);d.useEffect(()=>{!I||!u||f?.(e.info.id)},[u,I,e.info.id,f]),d.useEffect(()=>{Te(!1)},[e.info.id]),d.useEffect(()=>{const be=a??r?.headerMessageId;if(I||!be||be!==e.info.id)return;(F1==="streaming"||F1==="cooldown")&&Te(!0)},[a,I,e.info.id,F1,r?.headerMessageId]);const re=d.useMemo(()=>{if(I)return!0;const be=a??r?.headerMessageId;return be?e.info.id===be?F1==="completed"?!0:ve||(F1==="streaming"||F1==="cooldown"):!1:!0},[a,ve,I,r,F1,e.info.id]),Ne=d.useCallback(be=>{gt(be).then(Ge=>{Ge.ok&&(A(be),setTimeout(()=>A(null),2e3))})},[]),Oe=I?void 0:M0(Z2(e.info,"variant"))??r?.userMessageVariant??fe?.variant,Ke=I?void 0:te?Oe??"Default":Oe,c1=d.useMemo(()=>{if(I)return;const be=e.info?.error;if(!be)return;const Ge=typeof be.data?.message=="string"?be.data.message:void 0,b1=typeof be.message=="string"?be.message:void 0,d1=typeof be.name=="string"?be.name:void 0,Ye=Ge||b1||d1;if(Ye)return d1==="SessionRetry"?{text:`Retrying after an error:
7026
7026
  \`${Ye}\``,variant:"info"}:dN(Ye)?{text:cN,variant:"error"}:Ye.trim().toLowerCase()==="aborted"?{text:"The running turn was stopped before the next message could be sent.",variant:"info"}:{text:`Failed to send message with error:
7027
7027
  \`${Ye}\``,variant:"error"}},[I,e.info]),u1=c1?.text,v1=c1?.variant,L1=d.useMemo(()=>{if(I){const be=le.filter(Ye=>Ye.type==="text").map(Ye=>{const a2=Ye.shellAction?.output;return typeof a2=="string"?a2.trim():""}).filter(Ye=>Ye.length>0);if(be.length>0)return be.join(`
7028
7028
 
7029
7029
  `);const Ge=le.filter(Ye=>Ye.type==="text").map(Ye=>{const a2=Ye.shellAction?.command;return typeof a2=="string"?a2.trim():""}).filter(Ye=>Ye.length>0);return Ge.length>0?Ge.join(`
7030
7030
  `):le.filter(Ye=>Ye.type==="text").map(Ye=>(Ye.text||Ye.content||"").trim()).filter(Ye=>Ye.length>0).join(`
7031
7031
  `).replace(/\n\s*\n+/g,`
7032
- `)}return u1&&u1.trim().length>0?u1:uw(le)},[u1,le,I]),s2=L1.length>0,K1=d.useCallback(async()=>{let be;if(I)be=await gt(L1);else{const{renderMarkdownSync:Ge}=await V2(async()=>{const{renderMarkdownSync:b1}=await import("./markdownCore-CN0pApQE.js").then(d1=>d1.m);return{renderMarkdownSync:b1}},__vite__mapDeps([16,17,18,19,20,21]));be=await iC(L1,Ge(L1))}return be.ok?(I&&(k(!0),setTimeout(()=>k(!1),2e3)),!0):!1},[I,L1]),I2=d.useCallback(be=>{const Ge=Ae.has(be),b1=Ve.has(be);if(Ge){P(d1=>{const Ye=new Set(d1);return b1?Ye.add(be):Ye.delete(be),wd(e.info.id,Ye),Ye}),b1||H(d1=>{const Ye=new Set(d1);return Ye.delete(be),bd(e.info.id,Ye),Ye});return}H(d1=>{const Ye=new Set(d1);return Ye.has(be)?Ye.delete(be):Ye.add(be),bd(e.info.id,Ye),Ye}),P(d1=>{if(!d1.has(be))return d1;const Ye=new Set(d1);return Ye.delete(be),wd(e.info.id,Ye),Ye})},[Ae,Ve,e.info.id]),ke=o??null,e1=d.useRef(!1),Re=d.useRef(!1),f1=d.useRef(!1),Y1=d.useRef(!1),C2=d.useRef(!1),S2=d.useRef(!1);d.useEffect(()=>{Re.current=!1,f1.current=!1,Y1.current=!1,C2.current=!1,e1.current=!1,S2.current=!1},[e.info.id]);const K2=d.useCallback(()=>{I||e1.current||(e1.current=!0,s?.("structural"))},[I,s]),O1=he(be=>be.setImagePreviewOpen),g2=d.useCallback(be=>{(be.image||be.mermaid)&&($(be),O1(!0))},[O1]),e2=d.useCallback(be=>{$(Ge=>({...Ge,open:be})),O1(be)},[O1]),Y2=!!Z2(e.info,"animationSettled"),J2=F1==="streaming"||F1==="cooldown";J2&&(S2.current=!0);const o2=d.useMemo(()=>I?!1:ye.some(be=>be.type==="reasoning"),[I,ye]),B2=xe&&!Y2&&!J2&&!S2.current,lt=!I&&xe&&ne.length>0&&!n1;if(d.useEffect(()=>{if(ke?.onStreamingCandidate){if(!lt){f1.current&&(o2&&ke?.onReasoningBlock?ke.onReasoningBlock():ke?.onReservationCancelled&&ke.onReservationCancelled(),f1.current=!1);return}C2.current||(C2.current=!0,ke.onStreamingCandidate(),f1.current=!0)}},[ke,lt,o2]),d.useEffect(()=>{ke?.onAnimationStart&&B2&&(Y1.current||(ke.onAnimationStart(),Y1.current=!0))},[ke,B2]),d.useEffect(()=>{if(I)return;const be=ke?.onAnimatedHeightChange;if(!be||!(B2||lt))return;const b1=M.current;if(!b1)return;if(typeof window>"u"||typeof ResizeObserver>"u"){be(b1.getBoundingClientRect().height);return}let d1=null;const Ye=k2=>{if(typeof window>"u"){be(k2);return}d1!==null&&window.cancelAnimationFrame(d1),d1=window.requestAnimationFrame(()=>{be(k2)})},a2=new ResizeObserver(k2=>{const X2=k2[0];X2&&Ye(X2.contentRect.height)});return a2.observe(b1),Ye(b1.getBoundingClientRect().height),()=>{d1!==null&&(window.cancelAnimationFrame(d1),d1=null),a2.disconnect()}},[B2,I,ke,lt]),Ie)return null;const d2=!I&&re&&!_1&&C?h?"pt-4":"pt-6":"pt-0";return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:B("group w-full",I?h?"pt-2":"pt-4":d2,I||at||m2?"pb-0":"pb-2"),id:`message-${e.info.id}`,"data-message-id":e.info.id,ref:M,children:i.jsx("div",{className:"chat-message-column relative",children:I?le.length===0?null:i.jsx(It,{forceAnimation:!0,skipAnimation:!u,ignoreContextDisabled:!0,respectReducedMotion:!0,children:i.jsx("div",{className:B("relative flex justify-end",h?void 0:"group/user-shell"),children:i.jsxs("div",{className:B("max-w-[85%]",G?"pb-5":void 0),children:[i.jsx("div",{style:{backgroundColor:"var(--chat-user-message-bg)",borderRadius:"var(--radius-xl)",borderBottomRightRadius:"var(--radius-sm)"},className:"px-5 py-3 shadow-none border border-primary/5",children:i.jsx(Il,{sessionId:e.info.sessionID,messageId:e.info.id,parts:le,isUser:I,isMessageCompleted:Q,messageFinish:se,messageCreatedAt:T??void 0,isMobile:h,alwaysShowActions:g,hasTouchInput:p,copiedCode:L,onCopyCode:Ne,expandedTools:V,onToggleTool:I2,onShowPopup:g2,streamPhase:F1,allowAnimation:B2,onContentChange:s,shouldShowHeader:!1,hasTextContent:s2,onCopyMessage:K1,copiedMessage:N,showReasoningTraces:S,onAuxiliaryContentComplete:K2,agentMention:Me,errorMessage:u1,errorVariant:v1,isLatestMessage:!n,userActionsMode:q?"external-content":"inline",stickyUserHeaderEnabled:C})}),q?i.jsx(Il,{sessionId:e.info.sessionID,messageId:e.info.id,parts:le,isUser:I,isMessageCompleted:Q,messageFinish:se,messageCreatedAt:T??void 0,isMobile:h,alwaysShowActions:g,hasTouchInput:p,copiedCode:L,onCopyCode:Ne,expandedTools:V,onToggleTool:I2,onShowPopup:g2,streamPhase:F1,allowAnimation:B2,onContentChange:s,shouldShowHeader:!1,hasTextContent:s2,onCopyMessage:K1,copiedMessage:N,showReasoningTraces:S,onAuxiliaryContentComplete:K2,agentMention:Me,errorMessage:u1,errorVariant:v1,isLatestMessage:!n,userActionsMode:"external-actions",stickyUserHeaderEnabled:C}):null]})})}):i.jsx("div",{className:"relative",children:i.jsx(Il,{sessionId:e.info.sessionID,messageId:e.info.id,parts:ye,isUser:I,isMessageCompleted:Q,isLatestMessage:!n,messageFinish:se,messageCompletedAt:U??void 0,messageCreatedAt:T??void 0,durationMs:e.info.durationMs,isMobile:h,alwaysShowActions:g,hasTouchInput:p,copiedCode:L,onCopyCode:Ne,expandedTools:Ve,onToggleTool:I2,onShowPopup:g2,streamPhase:F1,allowAnimation:B2,onContentChange:s,shouldShowHeader:re,hasTextContent:s2,onCopyMessage:K1,copiedMessage:N,onAuxiliaryContentComplete:K2,showReasoningTraces:S,agentMention:Me,turnGroupingContext:r,errorMessage:u1,errorVariant:v1,footerProviderID:X,footerModelName:me,footerAgentName:Pe,footerVariant:Ke,isDarkTheme:Le})})})}),i.jsx(d.Suspense,{fallback:null,children:i.jsx(uN,{popup:R,onOpenChange:e2,isMobile:h})})]})},gN=d.memo(pN,(e,t)=>Qh({info:e.message.info,parts:e.message.parts},{info:t.message.info,parts:t.message.parts})&&Ai(e.previousMessage?{info:e.previousMessage.info,parts:e.previousMessage.parts}:void 0,t.previousMessage?{info:t.previousMessage.info,parts:t.previousMessage.parts}:void 0)&&Ai(e.nextMessage?{info:e.nextMessage.info,parts:e.nextMessage.parts}:void 0,t.nextMessage?{info:t.nextMessage.info,parts:t.nextMessage.parts}:void 0)&&e.isInActiveTurn===t.isInActiveTurn&&e.activeStreamingPhase===t.activeStreamingPhase&&e.assistantHeaderMessageId===t.assistantHeaderMessageId&&e.animateUserOnMount===t.animateUserOnMount&&e.onUserAnimationConsumed===t.onUserAnimationConsumed&&tm(e.turnGroupingContext,t.turnGroupingContext,e.message.info.id,ji(e.message.info).isUser)),yN=d.memo(function({message:t,renderMessage:n}){return n(t)},(e,t)=>e.message===t.message),vN=({assistantMessages:e,renderMessage:t})=>i.jsx("div",{className:"relative z-0",children:e.map(n=>i.jsx(yN,{message:n,renderMessage:t},n.info.id))}),bN=d.memo(vN),xN=d.memo(function({userMessage:t,stickyUserHeader:n,renderMessage:s}){const o=s(t);return n?i.jsxs("div",{className:"sticky top-0 z-20 relative bg-[var(--surface-background)] [overflow-anchor:none]",children:[i.jsx("div",{className:"relative z-10",children:o}),i.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 top-full z-0 h-4 bg-gradient-to-b from-[var(--surface-background)] to-transparent sm:h-8"})]}):o},(e,t)=>e.userMessage===t.userMessage&&e.stickyUserHeader===t.stickyUserHeader),wN=({turn:e,stickyUserHeader:t=!0,renderMessage:n})=>i.jsxs("section",{className:"relative w-full",id:`turn-${e.turnId}`,"data-turn-id":e.turnId,"data-scroll-spy-id":e.turnId,children:[i.jsx(xN,{userMessage:e.userMessage,stickyUserHeader:t,renderMessage:n}),i.jsx(bN,{assistantMessages:e.assistantMessages,renderMessage:n})]}),MN=d.memo(wN),A5=2,Ym=2,CN=72,SN=(e,t=A5)=>t+Math.max(0,e),_N=(e,t,n,s=A5)=>{const o=SN(n,s);return t<=o?!1:e<t-o},kN=(e,t,n=A5)=>Math.max(0,t-n-e),AN=(e,t,n=Ym)=>e+Math.max(0,Math.min(n,t)),HN=({foldedCount:e,onLoadOlder:t,onLoadAll:n})=>{const s=Math.min(Ym,e),o=e>s;return i.jsx("div",{className:"chat-message-column flex flex-col items-center py-4",children:i.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[i.jsxs(a1,{type:"button",variant:"secondary",size:"sm",onClick:t,"aria-label":"Load older history",className:"gap-1.5 rounded-full px-3.5",children:[i.jsx(z,{name:"history",className:"size-3.5"}),"Load older history"]}),o?i.jsx(a1,{type:"button",variant:"ghost",size:"sm",onClick:n,"aria-label":"Load all history",className:"rounded-full px-3.5 text-[var(--surface-mutedForeground)]",children:"Load all history"}):null]})})},LN=d.memo(HN),jN=new Set(["task"]),IN=e=>typeof e=="string"&&jN.has(e.toLowerCase()),BN=e=>{const t=e.state?.time?.end;if(typeof t=="number")return t;const n=e.time?.end;return typeof n=="number"?n:void 0},Cd=e=>{const t=e.text;if(typeof t=="string"&&t.trim().length>0)return t;const n=e.content;if(typeof n=="string"&&n.trim().length>0)return n},TN=e=>{const t=e.info.finish;return typeof t=="string"?t:void 0},VN=e=>e.info.summary===!0,NN=(e,t,n,s)=>({id:n.id??`${t}-part-${s}-${n.type}`,turnId:e,messageId:t,part:n,partIndex:s,endedAt:BN(n)}),PN=e=>{const t=[];let n=!1,s=!1;e.assistantMessages.forEach(h=>{h.parts.forEach(m=>{if(m.type==="tool"){n=!0;return}m.type==="reasoning"&&Cd(m)&&(s=!0)})});const o=new Map,r=[],a=new Map;let l=null;e.assistantMessages.forEach(h=>{const m=TN(h),p=h.parts.some(y=>y.type==="tool"),g=VN(h);h.parts.forEach((y,M)=>{const b=y.type==="tool",v=y.type==="reasoning"||y.type==="text"?Cd(y):void 0,x=y.id??`${h.info.id}-part-${M}-${y.type}`,S=b?y.tool:void 0,C=b&&IN(S);if(C){const N=x;o.has(N)||(o.set(N,h.info.id),r.push(N)),l=N}const w=y.type==="text"&&typeof v=="string"&&(m==="stop"||typeof m!="string")&&e.summarySourceMessageId===h.info.id&&e.summarySourcePartId===x;let _=null;if(b?_="tool":y.type==="reasoning"?v&&(_="reasoning"):e.showTextJustificationActivity&&y.type==="text"&&v&&(g||!w&&(p||typeof m=="string"&&m!=="stop"))&&(_="justification"),!_)return;const L={...NN(e.turnId,h.info.id,y,M),kind:_};if(t.push(L),_==="tool"&&C)return;const A=a.get(l)??[];A.push(L),a.set(l,A)})});const c=[],u=h=>{if(h.length===0)return;const m=new Map;h.forEach(g=>{m.set(g.messageId,(m.get(g.messageId)??0)+1)});let p;for(const g of e.assistantMessages)(m.get(g.info.id)??0)>0&&!p&&(p=g.info.id);return p};return[null,...r].forEach(h=>{const m=a.get(h)??[];if(m.length===0)return;const p=h===null?u(m):o.get(h);p&&c.push({id:`${e.turnId}:${p}:${h??"start"}`,anchorMessageId:p,afterToolPartId:h,parts:m})}),{activityParts:t,activitySegments:c,hasTools:n,hasReasoning:s}},EN=e=>{const t=new Map,n=new Map,s=new Map,o=new Set;e.forEach(l=>{t.set(l.turnId,l);const c=l.assistantMessages[0]?.info.id,u=l.assistantMessages[l.assistantMessages.length-1]?.info.id;n.set(l.userMessageId,l.turnId),o.add(l.userMessageId),s.set(l.userMessageId,{turnId:l.turnId,messageId:l.userMessageId,userMessageId:l.userMessageId,isUserMessage:!0,isAssistantMessage:!1,isFirstAssistantInTurn:!1,isLastAssistantInTurn:!1,headerMessageId:l.headerMessageId}),l.assistantMessageIds.forEach(f=>{n.set(f,l.turnId),o.add(f),s.set(f,{turnId:l.turnId,messageId:f,userMessageId:l.userMessageId,isUserMessage:!1,isAssistantMessage:!0,isFirstAssistantInTurn:f===c,isLastAssistantInTurn:f===u,headerMessageId:l.headerMessageId})})});const r=e.length>0?e[e.length-1]:null,a=new Set;return r&&(a.add(r.userMessageId),r.assistantMessageIds.forEach(l=>{a.add(l)})),{turns:e,indexes:{turnById:t,messageToTurnId:n,messageMetaById:s},lastTurnId:r?.turnId??null,lastTurnMessageIds:a,ungroupedMessageIds:new Set}},Sd=e=>{const t=e.text;if(typeof t=="string"&&t.trim().length>0)return t;const n=e.content;if(typeof n=="string"&&n.trim().length>0)return n},_d=e=>e.info.summary===!0,zN=e=>{for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(!(!n||_d(n)||n.info.finish!=="stop"))for(let o=n.parts.length-1;o>=0;o-=1){const r=n.parts[o];if(!r||r.type!=="text")continue;const a=Sd(r);if(a)return{text:a,sourceMessageId:n.info.id,sourcePartId:r.id??`${n.info.id}-part-${o}-text`}}}for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n&&!_d(n))for(let s=n.parts.length-1;s>=0;s-=1){const o=n.parts[s];if(!o||o.type!=="text")continue;const r=Sd(o);if(r)return{text:r,sourceMessageId:n.info.id,sourcePartId:o.id??`${n.info.id}-part-${s}-text`}}}return{}},DN=e=>{const n=e.info.summary?.diffs;if(!Array.isArray(n)||n.length===0)return;let s=0,o=0,r=0;if(n.forEach(a=>{if(!a)return;const l=typeof a.additions=="number"?a.additions:0,c=typeof a.deletions=="number"?a.deletions:0;(l!==0||c!==0)&&(r+=1),s+=l,o+=c}),r!==0)return{additions:s,deletions:o,files:r}},RN=e=>{const n=e.info.summary?.diffs;if(!Array.isArray(n)||n.length===0)return;const s=n.map(o=>{if(!o||typeof o.file!="string"||o.file.trim().length===0)return null;const r=typeof o.additions=="number"?o.additions:0,a=typeof o.deletions=="number"?o.deletions:0;return r===0&&a===0?null:{file:o.file,additions:r,deletions:a}}).filter(o=>o!==null);return s.length>0?s:void 0},$r=e=>{const t=e.info.clientRole??e.info.role;return typeof t=="string"?t:""},Jm=e=>{const t=e.info.parentID;if(!(typeof t!="string"||t.trim().length===0))return t},ON=e=>{const t=e.info.time?.created;return typeof t=="number"?t:void 0},ZN=e=>{const t=e.info.time?.completed;return typeof t=="number"?t:void 0},FN=e=>{const t=e.info?.summary?.body;return typeof t!="string"?void 0:t.trim().length>0?t:void 0},Tl=(e,t)=>{const n=$r(e);return{messageId:e.info.id,role:n,parentMessageId:Jm(e),message:e,order:t}},$N=(e,t)=>{const n=ON(e);let s,o=!1;t.forEach(a=>{const l=ZN(a);typeof l=="number"?s=Math.max(s??0,l):o=!0});const r=typeof n=="number"&&typeof s=="number"&&s>=n?s-n:void 0;return{isStreaming:o,isRetrying:t.length>1,startedAt:n,completedAt:s,durationMs:r}},qN={previousProjection:null,showTextJustificationActivity:!1,showTurnChangedFiles:!1,mergeHiddenUserTurns:void 0},UN=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0},GN=(e,t)=>e.userMessage===t.userMessage&&e.headerMessageId===t.headerMessageId&&UN(e.assistantMessages,t.assistantMessages),kd=(e,t)=>{e.summary=zN(e.assistantMessages),e.summaryText=e.summary.text??FN(e.userMessage),e.diffStats=DN(e.userMessage),e.changedFiles=t.showTurnChangedFiles?RN(e.userMessage):void 0;const n=PN({turnId:e.turnId,assistantMessages:e.assistantMessages,summarySourceMessageId:e.summary.sourceMessageId,summarySourcePartId:e.summary.sourcePartId,showTextJustificationActivity:t.showTextJustificationActivity});return e.activityParts=n.activityParts,e.activitySegments=n.activitySegments,e.hasTools=n.hasTools,e.hasReasoning=n.hasReasoning,e.stream=$N(e.userMessage,e.assistantMessages),e.startedAt=e.stream.startedAt,e.completedAt=e.stream.completedAt,e.durationMs=e.stream.durationMs,e},WN=(e,t)=>{const n=t.previousProjection;if(!n||n.turns.length===0||e.length===0)return e.map(a=>kd(a,t));let s=n.turns.length===e.length,o=!1;const r=e.map((a,l)=>{const c=n.indexes.turnById.get(a.turnId);return c&&GN(c,a)?(o=!0,n.turns[l]!==c&&(s=!1),c):(s=!1,kd(a,t))});return s&&o?n.turns:r},Xm=(e,t)=>{const n={...qN,...t},s=[],o=new Map,r=new Set,a=n.mergeHiddenUserTurns;e.forEach((f,h)=>{if($r(f)!=="user")return;const p=s[s.length-1];if(a&&p&&Ii(f)){o.set(f.info.id,p),p.messages.push(Tl(f,h)),r.add(f.info.id);return}const y={turnId:f.info.id,userMessageId:f.info.id,userMessage:f,headerMessageId:void 0,messages:[Tl(f,h)],assistantMessageIds:[],assistantMessages:[],activityParts:[],activitySegments:[],summary:{},summaryText:void 0,hasTools:!1,hasReasoning:!1,diffStats:void 0,changedFiles:void 0,stream:{isStreaming:!1,isRetrying:!1}};s.push(y),o.set(y.userMessageId,y),r.add(f.info.id)}),e.forEach((f,h)=>{if($r(f)!=="assistant")return;const p=Jm(f),g=p?o.get(p):void 0;g&&(g.assistantMessages.push(f),g.assistantMessageIds.push(f.info.id),g.messages.push(Tl(f,h)),g.headerMessageId||(g.headerMessageId=f.info.id),r.add(f.info.id))});const l=WN(s,n),c=EN(l),u=new Set;return e.forEach(f=>{$r(f)!=="assistant"&&(r.has(f.info.id)||u.add(f.info.id))}),{...c,ungroupedMessageIds:u}},KN=30,YN=4,Wt=new Map,Ad=new WeakMap;let Hd=1;const JN=()=>D2()?YN:KN,Vl=e=>{const t=Ad.get(e);if(t!==void 0)return t;const n=Hd;return Hd+=1,Ad.set(e,n),n},XN=e=>e.map(t=>{const n=Vl(t.info),s=Vl(t.parts),o=t.parts.map(r=>Vl(r)).join(",");return`${n}:${s}:${o}`}).join(";"),QN=(e,t,n,s,o)=>{const r=t.length>0?t[t.length-1]:void 0,a=r?.info?.id??"",l=r?.parts?.length??0;return[e,t.length,a,l,XN(t),n?"1":"0",s?"1":"0",o].join("|")},eP=e=>{const t=Wt.get(e);return t&&(Wt.delete(e),Wt.set(e,t)),t},tP=(e,t)=>{Wt.delete(e);const n=JN();for(;Wt.size>=n;){const s=Wt.keys().next().value;if(typeof s!="string")break;Wt.delete(s)}Wt.set(e,t)},nP=(e,t)=>{const n=d.useRef(null),s=d.useRef([]),o=d.useRef(void 0),r=d.useRef(t.sessionKey),a=d.useRef(t.showTextJustificationActivity),l=d.useRef(t.showTurnChangedFiles);(r.current!==t.sessionKey||a.current!==t.showTextJustificationActivity||l.current!==t.showTurnChangedFiles)&&(r.current=t.sessionKey,a.current=t.showTextJustificationActivity,l.current=t.showTurnChangedFiles,n.current=null,s.current=[],o.current=void 0),d.useEffect(()=>{n.current=null,s.current=[],o.current=void 0},[t.sessionKey,t.showTextJustificationActivity,t.showTurnChangedFiles]);const c=d.useMemo(()=>{const h=t.sessionKey??"",m=QN(h,e,t.showTextJustificationActivity,t.showTurnChangedFiles,"merge"),p=eP(m);return p?(n.current=p,p):Mr("ui.turns.projection_ms",()=>{const g=Xm(e,{previousProjection:n.current,showTextJustificationActivity:t.showTextJustificationActivity,showTurnChangedFiles:t.showTurnChangedFiles,mergeHiddenUserTurns:!0});return n.current=g,tP(m,g),g})},[e,t.showTextJustificationActivity,t.showTurnChangedFiles,t.sessionKey]),u=d.useMemo(()=>{const h=c.turns.length<=1?[]:c.turns.slice(0,-1),m=s.current;if(m.length===h.length){let p=!0;for(let g=0;g<h.length;g+=1)if(m[g]!==h[g]){p=!1;break}if(p)return m}return s.current=h,h},[c.turns]),f=d.useMemo(()=>{const h=c.turns.length===0?void 0:c.turns[c.turns.length-1];return o.current===h?o.current:(o.current=h,h)},[c.turns]);return{projection:c,staticTurns:u,streamingTurn:f}},Ld=e=>{const t=e.info;return(typeof t.clientRole=="string"?t.clientRole:null)??(typeof t.role=="string"?t.role:null)??null},sP=(e,t)=>{if(!t.sessionId)return e;const n={name:"SessionRetry",message:t.message,data:{message:t.message}};let s=-1;for(let u=e.length-1;u>=0;u-=1)if(Ld(e[u])==="user"){s=u;break}if(s<0)return e;let o=-1;for(let u=e.length-1;u>s;u-=1)if(Ld(e[u])==="assistant"){o=u;break}if(o>=0)return e.map((u,f)=>f!==o?u:{...u,info:{...u.info,error:n}});const r=typeof t.confirmedAt=="number"?t.confirmedAt:t.fallbackTimestamp,l={info:{id:`synthetic_retry_notice_${t.sessionId}`,sessionID:t.sessionId,role:"assistant",parentID:e[s].info.id,time:{created:r,completed:r},finish:"stop",error:n},parts:[]},c=e.slice();return c.splice(s+1,0,l),c},oP=e=>{const t=e.info;if(t.finish==="stop"||t.finish==="error")return!0;const n=t.time?.completed,s=t.status;return typeof n!="number"||n<=0?!1:typeof s=="string"?s==="completed":!0},rP=e=>{const{activeStreamingMessageId:t,assistantMessages:n}=e;if(t&&n.some(s=>s.info.id===t))return t;for(let s=n.length-1;s>=0;s--)if(!oP(n[s]))return n[s].info.id;return null},iP=e=>e.isRetrying===!0||!!e.activeStreamingMessageId&&e.messageId===e.activeStreamingMessageId,Qm=e=>e.parts.some(t=>t?.type==="compaction"),aP=e=>{if(!Qm(e))return e;let t=!1;const n=e.parts.map(r=>r?.type!=="compaction"?r:(t=!0,{type:"text",text:"/compact"})),o=e.info.clientRole!=="user";return!t&&!o?e:{...e,info:o?{...e.info,clientRole:"user"}:e.info,parts:t?n:e.parts}},lP=e=>{const t=ma(e.parts);return t.length===e.parts.length?e:{...e,parts:t}},jd=new WeakMap,ep=e=>{const t=jd.get(e);if(t)return t;const n=lP(e),s=aP(n),o=mw(s.parts),r=o===s.parts?s:{...s,parts:o};return jd.set(e,r),r},Id=(e,t,n)=>e.info.id!==t||e.parts===n?e:ep({...e,parts:n}),cP=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const s=e[n],o=t[n];if(!s||!o||s.id!==o.id||s.type!==o.type||s.type!=="text"&&s!==o)return!1}return!0},Bd=(e,t)=>{if(e.messages.length===0)return e.messages;const n=new Map(t.map(r=>[r.info.id,r]));let s=!1;const o=e.messages.map(r=>{const a=n.get(r.messageId);return!a||a===r.message?r:(s=!0,{...r,message:a})});return s?o:e.messages},dP=(e,t)=>{const n=t.activeStreamingMessageId;if(!n)return e;if(e.kind==="ungrouped"){const m=Id(e.message,n,t.liveParts);return m===e.message?e:{...e,message:m}}let s=!1;const o=e.turn.assistantMessages.map(m=>{const p=Id(m,n,t.liveParts);return p!==m&&(s=!0),p});if(!s)return e;const r=e.turn.assistantMessages.find(m=>m.info.id===n),a=o.find(m=>m.info.id===n);if(!!(r&&a&&cP(r.parts,a.parts)))return{...e,turn:{...e.turn,assistantMessages:o,messages:Bd(e.turn,o)}};const c=new Map(o.map(m=>[m.info.id,m])),u=e.turn.messages.length>0?e.turn.messages.slice().sort((m,p)=>m.order-p.order).map(m=>c.get(m.messageId)??m.message):[e.turn.userMessage,...o],h=Xm(u,{showTextJustificationActivity:t.showTextJustificationActivity,showTurnChangedFiles:t.showTurnChangedFiles,mergeHiddenUserTurns:t.mergeHiddenUserTurns}).turns[0]??{...e.turn,assistantMessages:o,assistantMessageIds:o.map(m=>m.info.id),messages:Bd(e.turn,o)};return{...e,turn:h}},tp="The following tool was executed by the user",H5=e=>{const t=e.info;return(typeof t.clientRole=="string"?t.clientRole:null)??(typeof t.role=="string"?t.role:null)??null},uP=e=>{const t=e.info;return typeof t.parentID=="string"&&t.parentID.length>0?t.parentID:null},np=e=>!e||H5(e)!=="user"?!1:e.parts.some(t=>{if(t?.type!=="text")return!1;const n=t.text;return t.synthetic===!0&&typeof n=="string"&&n.trim().startsWith(tp)}),sp=(e,t)=>{if(H5(e)!=="assistant")return{hide:!1,details:null};if(t&&uP(e)!==t)return{hide:!1,details:null};if(e.parts.length!==1)return{hide:!1,details:null};const n=e.parts[0];if(n?.type!=="tool")return{hide:!1,details:null};if((typeof n.tool=="string"?n.tool.toLowerCase():"")!=="bash")return{hide:!1,details:null};const o=typeof n.state?.input?.command=="string"?n.state.input.command:void 0,r=(typeof n.state?.output=="string"?n.state.output:void 0)??(typeof n.state?.metadata?.output=="string"?n.state.metadata.output:void 0),a=typeof n.state?.status=="string"?n.state.status:void 0;return{hide:!0,details:{command:o,output:r,status:a}}},fP=(e,t)=>{const n=e[t];if(!n)return null;const s=n.info.id;for(let o=t+1;o<e.length;o+=1){const r=e[o];if(H5(r)==="user")break;const{hide:a,details:l}=sp(r,s);if(a){const c=typeof l?.command=="string"?l.command.trim():"";return c.length>0?c:null}}return null},Td=e=>!!(e&&e.clientHeight>0),hP=5,mP=[],pP=new Set,gP=16,yP=(e,t)=>e===t?!0:!e||!t||e.length!==t.length?!1:e.every((n,s)=>n===t[s]),vP=320,bP=8,xP=16,wP=()=>D2()?xP:bP,MP=30,CP=180,SP=5,_P=120,kP=1200,AP=80,HP=160,Vd=1500,LP=1.5,jP=90,IP=(e,t)=>{if(e.length===0||t.length<=e.length||e[e.length-1]?.key!==t[t.length-1]?.key)return!1;const n=e[0]?.key;return t.findIndex(o=>o.key===n)>0},k0=new Map,BP=32,xn=new Map,Nd=e=>xn.get(e)??0,TP=(e,t)=>{if(xn.size>=BP&&!xn.has(e)){const n=xn.keys().next().value;typeof n=="string"&&xn.delete(n)}xn.set(e,t)},VP=(e,t)=>{const n=k0.get(e);if(n){if(yP(n.keys,t))return n.items;k0.delete(e)}},NP=(e,t,n)=>{if(!(!n||t.length===0))for(k0.delete(e),k0.set(e,{keys:t.slice(),items:n.takeSnapshot()});k0.size>gP;){const s=k0.keys().next().value;if(typeof s!="string")break;k0.delete(s)}},yr=e=>{const t=d.useRef(e);return d.useEffect(()=>{t.current=e},[e]),d.useCallback((...n)=>t.current(...n),[])},F0=e=>{const t=e.info;return(typeof t.clientRole=="string"?t.clientRole:null)??(typeof t.role=="string"?t.role:null)??null},PP=e=>e.info.error?.name==="SessionRetry",EP=e=>{const t=e.text;if(typeof t=="string")return t;const n=e.content;return typeof n=="string"?n:""},zP=(e,t)=>{if(F0(e)!=="system")return e;const s=OP(e);return!s||!t.has(s)||e.info.clientRole==="assistant"?e:{...e,info:{...e.info,clientRole:"assistant"}}},DP=e=>!e||F0(e)!=="user"?!1:e.parts.some(t=>t?.type==="subtask"),RP=e=>{if(!e)return null;const t=e.info.id;return typeof t=="string"&&t.trim().length>0?t:null},OP=e=>{const t=e.info.parentID;return typeof t=="string"&&t.trim().length>0?t:null},Pd=(e,t,n)=>{if(typeof window>"u")return!1;let s=e;for(;s&&s!==t;){if(window.getComputedStyle(s).position==="sticky"&&s.getBoundingClientRect().top<=n+1)return!0;s=s.parentElement}return!1},ZP=e=>{const t=e,n=t.state?.metadata,s=(typeof n?.sessionID=="string"&&n.sessionID.trim().length>0?n.sessionID.trim():null)??(typeof n?.sessionId=="string"&&n.sessionId.trim().length>0?n.sessionId.trim():null);if(s)return s;const o=t.state?.output;if(typeof o=="string"){const r=o.match(/task_id\s*:\s*([^\s<"']+)/i);if(r?.[1])return r[1]}return null},FP=e=>{if(F0(e)!=="assistant")return{hide:!1,taskSessionId:null};if(e.parts.length!==1)return{hide:!1,taskSessionId:null};const t=e.parts[0];return t?.type!=="tool"?{hide:!1,taskSessionId:null}:(typeof t.tool=="string"?t.tool.toLowerCase():"")!=="task"?{hide:!1,taskSessionId:null}:{hide:!0,taskSessionId:ZP(e.parts[0])}},$P=(e,t)=>{if(!t)return e;const n=e.parts.map(s=>{if(s?.type!=="subtask")return s;const o=s.taskSessionID;return typeof o=="string"&&o.trim().length>0?s:{...s,taskSessionID:t}});return{...e,parts:n}},qP=(e,t)=>{const n=typeof t?.command=="string"?t.command.trim():"",s=typeof t?.output=="string"?t.output:"",o=typeof t?.status=="string"?t.status.trim():"",r=[];let a=!1;for(const l of e.parts){if(!a&&l?.type==="text"){const c=l.text;if(l.synthetic===!0&&typeof c=="string"&&c.trim().startsWith(tp)){r.push({type:"text",text:"/shell",shellAction:{...n?{command:n}:{},...s?{output:s}:{},...o?{status:o}:{}}}),a=!0;continue}}r.push(l)}return a||r.push({type:"text",text:"/shell",shellAction:{...n?{command:n}:{},...s?{output:s}:{},...o?{status:o}:{}}}),{...e,parts:r}},L5=d.memo(({message:e,previousMessage:t,nextMessage:n,turnGroupingContext:s,assistantHeaderMessageId:o,isInActiveTurn:r,activeStreamingPhase:a,animateUserOnMount:l,onUserAnimationConsumed:c,onContentChange:u,animationHandlers:f,scrollToBottom:h})=>i.jsx(gN,{message:e,previousMessage:t,nextMessage:n,animateUserOnMount:l,onUserAnimationConsumed:c,onContentChange:u,animationHandlers:f,scrollToBottom:h,turnGroupingContext:s,assistantHeaderMessageId:o,isInActiveTurn:r,activeStreamingPhase:a}),(e,t)=>{const n=e.turnGroupingContext,s=t.turnGroupingContext;return Qh(e.message,t.message)&&Ai(e.previousMessage,t.previousMessage)&&Ai(e.nextMessage,t.nextMessage)&&e.animateUserOnMount===t.animateUserOnMount&&e.onUserAnimationConsumed===t.onUserAnimationConsumed&&e.onContentChange===t.onContentChange&&e.scrollToBottom===t.scrollToBottom&&tm(n,s,e.message.info.id,F0(e.message)==="user")&&e.assistantHeaderMessageId===t.assistantHeaderMessageId&&e.isInActiveTurn===t.isInActiveTurn&&e.activeStreamingPhase===t.activeStreamingPhase&&e.animationHandlers?.onChunk===t.animationHandlers?.onChunk&&e.animationHandlers?.onComplete===t.animationHandlers?.onComplete&&e.animationHandlers?.onStreamingCandidate===t.animationHandlers?.onStreamingCandidate&&e.animationHandlers?.onAnimationStart===t.animationHandlers?.onAnimationStart&&e.animationHandlers?.onReservationCancelled===t.animationHandlers?.onReservationCancelled&&e.animationHandlers?.onReasoningBlock===t.animationHandlers?.onReasoningBlock&&e.animationHandlers?.onAnimatedHeightChange===t.animationHandlers?.onAnimatedHeightChange});L5.displayName="MessageRow";const op=d.memo(({turn:e,isLastTurn:t,nextEntryFirstMessage:n,onMessageContentChange:s,getAnimationHandlers:o,scrollToBottom:r,stickyUserHeader:a=!0,shouldAnimateUserMessage:l,onUserAnimationConsumed:c,activeStreamingMessageId:u,activeStreamingPhase:f})=>{const h=d.useMemo(()=>Ii(e.userMessage),[e.userMessage]),m=d.useMemo(()=>{const w=[e.userMessage,...e.assistantMessages],_=new Map;return w.forEach((L,A)=>{_.set(L.info.id,A)}),{ordered:w,lookup:_}},[e.assistantMessages,e.userMessage]),p=d.useMemo(()=>rP({activeStreamingMessageId:u,assistantMessages:e.assistantMessages}),[u,e.assistantMessages]),g=e.assistantMessages,y=d.useMemo(()=>{const w=new Map;return g.forEach((_,L)=>{w.set(_.info.id,L)}),w},[g]),M=d.useMemo(()=>UP(e,p),[e,p]),b=d.useMemo(()=>M&&p?p:g[0]?.info.id,[p,M,g]),v=e.activityParts,x=e.activitySegments,S=d.useMemo(()=>{const w=e.userMessage.info.time?.created,_=e.userMessage.info,L=_?.model?.variant??_?.variant,A=typeof L=="string"&&L.trim().length>0?L:void 0;return{turnId:e.turnId,summaryBody:e.summaryText,activityParts:v,activityGroupSegments:x,headerMessageId:e.headerMessageId,hasTools:e.hasTools,hasReasoning:e.hasReasoning,diffStats:e.diffStats,changedFiles:e.changedFiles,userMessageCreatedAt:typeof w=="number"?w:void 0,userMessageVariant:A}},[e.changedFiles,e.diffStats,e.hasReasoning,e.hasTools,e.headerMessageId,e.summaryText,e.turnId,e.userMessage.info,v,x]),C=d.useCallback(w=>{const L=F0(w)==="user",A=m.lookup.get(w.info.id),N=y.get(w.info.id)??-1,k=N>=0,V=N===0,H=N===g.length-1,P=!!b&&w.info.id===b||V||H,R=g[0]?.info.id??e.headerMessageId,$=L?void 0:k?V?e.userMessage:void 0:typeof A=="number"&&A>0?m.ordered[A-1]:void 0,O=k&&H?n:void 0,I=k?{turnId:e.turnId,activityOwnerMessageId:b,isFirstAssistantInTurn:V,isLastAssistantInTurn:H,isLatestTurn:t,isWorking:iP({messageId:w.info.id,activeStreamingMessageId:u,isRetrying:PP(w)}),hasTools:e.hasTools,hasReasoning:e.hasReasoning,...P?{summaryBody:S.summaryBody,activityParts:S.activityParts,activityGroupSegments:S.activityGroupSegments,headerMessageId:S.headerMessageId,diffStats:S.diffStats,changedFiles:S.changedFiles,userMessageCreatedAt:S.userMessageCreatedAt,userMessageVariant:S.userMessageVariant}:{}}:void 0;return i.jsx(L5,{message:w,previousMessage:$,nextMessage:O,turnGroupingContext:I,assistantHeaderMessageId:R,isInActiveTurn:!!p&&w.info.id===p,activeStreamingPhase:w.info.id===p?f:null,animateUserOnMount:l(w),onUserAnimationConsumed:c,onContentChange:s,animationHandlers:o(w.info.id),scrollToBottom:r},w.info.id)},[o,t,n,m.lookup,m.ordered,s,r,e.headerMessageId,e.hasReasoning,e.hasTools,e.turnId,e.userMessage,S,p,u,f,g,y,b,l,c]);return i.jsx(MN,{turn:e,stickyUserHeader:a&&!h,renderMessage:C})});op.displayName="TurnBlock";const rp=d.memo(({message:e,previousMessage:t,nextMessage:n,onMessageContentChange:s,getAnimationHandlers:o,scrollToBottom:r,shouldAnimateUserMessage:a,onUserAnimationConsumed:l,activeStreamingMessageId:c,activeStreamingPhase:u})=>i.jsx(L5,{message:e,previousMessage:t,nextMessage:n,animateUserOnMount:a(e),onUserAnimationConsumed:l,onContentChange:s,animationHandlers:o(e.info.id),scrollToBottom:r,isInActiveTurn:!!c&&e.info.id===c,activeStreamingPhase:e.info.id===c?u:null}));rp.displayName="UngroupedMessageRow";const UP=(e,t)=>t?e.userMessage.info.id===t?!0:e.assistantMessages.some(n=>n.info.id===t):!1,j5=d.memo(({entry:e,onMessageContentChange:t,getAnimationHandlers:n,scrollToBottom:s,stickyUserHeader:o,sessionIsWorking:r,shouldAnimateUserMessage:a,onUserAnimationConsumed:l,activeStreamingMessageId:c,activeStreamingPhase:u,onLoadOlderHistory:f,onLoadAllHistory:h})=>(E0("ui.message_list_entry.render"),e.kind==="ungrouped"?i.jsx(rp,{message:e.message,previousMessage:e.previousMessage,nextMessage:e.nextMessage,onMessageContentChange:t,getAnimationHandlers:n,scrollToBottom:s,shouldAnimateUserMessage:a,onUserAnimationConsumed:l,activeStreamingMessageId:c,activeStreamingPhase:u}):e.kind==="history-gate"?i.jsx(LN,{foldedCount:e.turns.length,onLoadOlder:()=>f?.(e.turns.length),onLoadAll:()=>h?.(e.turns.length)}):i.jsx(op,{turn:e.turn,isLastTurn:e.isLastTurn,nextEntryFirstMessage:e.nextEntryFirstMessage,sessionIsWorking:r,shouldAnimateUserMessage:a,onUserAnimationConsumed:l,activeStreamingMessageId:c,activeStreamingPhase:u,onMessageContentChange:t,getAnimationHandlers:n,scrollToBottom:s,stickyUserHeader:o})));j5.displayName="MessageListEntry";const ip=d.memo(({entries:e,engine:t,contentRef:n,scrollRef:s,registerTanstackVirtualizer:o,virtualizerKey:r,onMessageContentChange:a,getAnimationHandlers:l,scrollToBottom:c,stickyUserHeader:u,shouldAnimateUserMessage:f,onUserAnimationConsumed:h,onLoadOlderHistory:m,onLoadAllHistory:p})=>{const g=t==="tanstack",y=d.useRef(!1),M=d.useRef(0),b=d.useRef(null),v=g&&D2();d.useEffect(()=>{if(!v)return;const O=s?.current;if(!O)return;const I=()=>{y.current=!0},q=()=>{y.current=!1},G=()=>{M.current=performance.now()};return O.addEventListener("touchstart",I,{passive:!0}),O.addEventListener("touchend",q,{passive:!0}),O.addEventListener("touchcancel",q,{passive:!0}),O.addEventListener("scroll",G,{passive:!0}),()=>{O.removeEventListener("touchstart",I),O.removeEventListener("touchend",q),O.removeEventListener("touchcancel",q),O.removeEventListener("scroll",G)}},[v,s]);const x=d.useCallback(()=>y.current||performance.now()-M.current<HP,[]),S=d.useCallback(()=>{const O=s?.current;return O?O.scrollTop<O.clientHeight*LP:!0},[s]),[C,w]=d.useState(e);let _=C;e!==C?v&&IP(C,e)&&x()&&!S()&&(b.current===null||performance.now()-b.current<Vd)?b.current===null&&(b.current=performance.now()):(b.current=null,w(e),_=e):b.current!==null&&(b.current=null);const[,L]=d.useReducer(O=>O+1,0);d.useEffect(()=>{if(!v)return;const O=window.setInterval(()=>{if(b.current===null)return;const I=performance.now()-b.current>=Vd;(!x()||S()||I)&&L()},jP);return()=>window.clearInterval(O)},[v,x,S]);const A=d.useRef(_);A.current=_;const[N]=d.useState(()=>g?VP(r,e.map(O=>O.key)):void 0),k=d.useRef(null),V=d.useRef(vP),[H,D]=d.useState(null);d.useLayoutEffect(()=>{if(!g){D(K=>K===null?K:null);return}let O,I=0;const q=()=>{const K=s?.current??null;return Td(K)?(D(W=>W===K?W:K),!0):!1};if(q())return;const G=s?.current;return G?(O=new ResizeObserver(()=>{q()&&O?.disconnect()}),O.observe(G)):typeof window<"u"&&(I=window.requestAnimationFrame(()=>{if(q())return;const K=s?.current;K&&(O=new ResizeObserver(()=>{q()&&O?.disconnect()}),O.observe(K))})),()=>{I&&window.cancelAnimationFrame(I),O?.disconnect()}},[g,s,r]);const P=g&&Td(H),R=V9({count:_.length,enabled:P,getScrollElement:()=>H,estimateSize:O=>A.current[O]?.kind==="history-gate"?CN:V.current,overscan:wP(),scrollToFn:(O,I,q)=>{const G=k.current;G&&(G.style.height=`${q.getTotalSize()}px`),pv(O,I,q)},getItemKey:O=>A.current[O]?.key??`index:${O}`,anchorTo:"end",initialOffset:()=>Number.MAX_SAFE_INTEGER,initialMeasurementsCache:N});R.shouldAdjustScrollPositionOnItemSizeChange=(O,I,q)=>{if(q.isAtEnd(AP))return!1;const G=q.range?.startIndex;return G!==void 0&&O.index<G},d.useEffect(()=>{if(!g)return;const O=R.itemSizeCache;if(O.size>=SP){let I=0;for(const q of O.values())I+=q;V.current=Math.min(kP,Math.max(_P,Math.round(I/O.size)))}}),d.useEffect(()=>{if(P)return o?.(R),()=>{NP(r,A.current.map(O=>O.key),R),o?.(null)}},[P,o,R,r]);const $=d.useCallback(O=>i.jsx(j5,{entry:O,onMessageContentChange:a,getAnimationHandlers:l,scrollToBottom:c,stickyUserHeader:u,sessionIsWorking:!1,shouldAnimateUserMessage:f,onUserAnimationConsumed:h,activeStreamingMessageId:null,activeStreamingPhase:null,onLoadOlderHistory:m,onLoadAllHistory:p},O.key),[l,p,m,a,h,c,f,u]);if(t==="none"||t==="tanstack"&&!P)return i.jsx("div",{ref:n,className:"relative w-full",children:_.map(O=>i.jsx("div",{"data-turn-entry":O.key,children:$(O)},O.key))});if(t==="tanstack"){const O=R.getVirtualItems(),I=O[0]?.start??0;return i.jsx("div",{ref:k,className:"relative w-full",style:{height:R.getTotalSize()},children:i.jsx("div",{style:{paddingTop:`${I}px`},children:O.map(q=>{const G=_[q.index];return G?i.jsx("div",{"data-index":q.index,ref:R.measureElement,"data-turn-entry":G.key,children:$(G)},G.key):null})})})}return null});ip.displayName="StaticHistoryList";const ap=({entry:e,sessionId:t,directory:n,onMessageContentChange:s,getAnimationHandlers:o,scrollToBottom:r,stickyUserHeader:a,sessionIsWorking:l,showTurnChangedFiles:c,shouldAnimateUserMessage:u,onUserAnimationConsumed:f,activeStreamingMessageId:h,activeStreamingPhase:m})=>{const p=Ew(t,h??"",n),g=d.useMemo(()=>dP(e,{activeStreamingMessageId:h,liveParts:p,showTextJustificationActivity:!1,showTurnChangedFiles:c,mergeHiddenUserTurns:!0}),[h,e,p,c]);return i.jsx(j5,{entry:g,onMessageContentChange:s,getAnimationHandlers:o,scrollToBottom:r,stickyUserHeader:a,sessionIsWorking:l,shouldAnimateUserMessage:u,onUserAnimationConsumed:f,activeStreamingMessageId:h,activeStreamingPhase:m})};ap.displayName="StreamingTailContent";const lp=d.forwardRef(({sessionKey:e,messages:t,sessionIsWorking:n=!1,activeStreamingMessageId:s=null,activeStreamingPhase:o=null,retryOverlay:r=null,onMessageContentChange:a,getAnimationHandlers:l,scrollToBottom:c,scrollRef:u,directory:f},h)=>{Wg("react.message_list_render"),E0("ui.message_list.render");const m=he(X=>X.stickyUserHeader),p=he(X=>X.showTurnChangedFiles),[g,y]=d.useState(()=>Nd(e)),M=d.useRef(null),b=d.useRef(null),v=d.useCallback(()=>{const X=u?.current;if(!X)return null;const me=X.getBoundingClientRect(),U=Array.from(X.querySelectorAll("[data-message-id]")).find(T=>T.getBoundingClientRect().bottom>me.top+1&&!Pd(T,X,me.top));return{top:X.scrollTop,height:X.scrollHeight,anchor:U?.dataset.messageId?{messageId:U.dataset.messageId,offsetTop:U.getBoundingClientRect().top-me.top}:null}},[u]),x=d.useCallback(X=>{y(me=>{const U=typeof X=="function"?X(me):X;return TP(e,U),U})},[e]),S=d.useCallback(X=>{M.current=v(),x(me=>AN(me,X))},[v,x]),C=d.useCallback(X=>{M.current=v(),x(me=>me+X)},[v,x]),w=d.useCallback((X,me,U)=>{const T=me.findIndex(Q=>Q.turnId===X);T<0||(b.current=X,x(Q=>Math.max(Q,kN(T,U))))},[x]);d.useLayoutEffect(()=>{y(Nd(e)),b.current=null},[e]);const _=d.useRef({sessionKey:void 0,previousOrder:[],animatedIds:new Set}),L=yr(l),A=yr(()=>{c?.()}),N=d.useMemo(()=>Mr("ui.message_list.base_display_ms",()=>{const X=new Set,me=new Map,U=[];for(const se of t){const ye=se.info?.id;typeof ye=="string"&&me.set(ye,se)}for(let se=0;se<t.length;se+=1){const ye=t[se],le=ye.info?.id;if(typeof le=="string"){if(X.has(le))continue;X.add(le)}U.push(ep(typeof le=="string"?me.get(le)??ye:ye))}const T=[],Q=new Set;for(let se=0;se<U.length;se+=1){const ye=U[se],le=zP(ye,Q);(Qm(ye)||ye.parts.some(Ce=>Ce.type==="text"&&EP(Ce).trim()==="/compact"))&&Q.add(ye.info.id);const ne=T.length>0?T[T.length-1]:void 0;if(DP(ne)){const Ce=FP(le);if(Ce.hide){T[T.length-1]=$P(ne,Ce.taskSessionId);continue}}if(np(ne)){const Ce=sp(le,RP(ne));if(Ce.hide){T[T.length-1]=qP(ne,Ce.details);continue}}T.push(le)}return T}),[t]),k=d.useRef(null),V=d.useCallback(()=>u?.current?u.current:typeof document>"u"?null:document.querySelector('[data-scrollbar="chat"]'),[u]),H=d.useMemo(()=>Mr("ui.message_list.retry_overlay_ms",()=>sP(N,{sessionId:r?.sessionId??null,message:r?.message??"Quota limit reached. Retrying automatically.",confirmedAt:r?.confirmedAt,fallbackTimestamp:r?.fallbackTimestamp??0})),[N,r]),{projection:D,staticTurns:P,streamingTurn:R}=nP(H,{sessionKey:e,showTextJustificationActivity:!1,showTurnChangedFiles:p}),$=D.ungroupedMessageIds.size>0,O=$?H:mP,I=$?D.ungroupedMessageIds:pP,q=d.useMemo(()=>Mr("ui.message_list.render_entries_ms",()=>{const X=P.map(T=>({kind:"turn",key:`turn:${T.turnId}`,turn:T,isLastTurn:T.turnId===D.lastTurnId}));if(I.size===0)return X;const me=new Map;X.forEach(T=>{me.set(T.turn.userMessage.info.id,T)});const U=[];return O.forEach((T,Q)=>{const se=me.get(T.info.id);if(se){U.push(se);return}I.has(T.info.id)&&U.push({kind:"ungrouped",key:`msg:${T.info.id}`,message:T,previousMessage:Q>0?O[Q-1]:void 0,nextMessage:Q<O.length-1?O[Q+1]:void 0})}),U}),[D.lastTurnId,O,I,P]),G=d.useMemo(()=>{if(R)return{kind:"turn",key:`turn:${R.turnId}`,turn:R,isLastTurn:R.turnId===D.lastTurnId};if(D.ungroupedMessageIds.size===0)return;const X=H[H.length-1];if(!(!X||!D.ungroupedMessageIds.has(X.info.id)))return{kind:"ungrouped",key:`msg:${X.info.id}`,message:X,previousMessage:H.length>1?H[H.length-2]:void 0,nextMessage:void 0}},[H,D.lastTurnId,D.ungroupedMessageIds,R]);G&&E0("ui.message_list.render.streaming");const K=G?G.kind==="turn"?G.turn.userMessage:G.message:void 0,W=d.useMemo(()=>{const X=q.map((se,ye)=>{if(se.kind!=="turn")return se;const le=ye<q.length-1?(()=>{const ne=q[ye+1];return ne&&ne.kind==="turn"?ne.turn.userMessage:ne?.kind==="ungrouped"?ne.message:void 0})():K;return le?{...se,nextEntryFirstMessage:le}:se});let me=0;for(const se of X)se.kind==="turn"&&(me+=1);let U=-1;const T=[],Q=[];for(const se of X){if(se.kind!=="turn"){Q.push(se);continue}if(U+=1,_N(U,me,g)){T.push(se.turn);continue}Q.push(se)}return T.length===0?Q:[{kind:"history-gate",key:"history-gate",turns:T},...Q]},[g,q,K]);d.useLayoutEffect(()=>{const X=M.current;if(X){M.current=null;const Q=u?.current;if(Q){const se=X.anchor?.messageId?Q.querySelector(`[data-message-id="${X.anchor.messageId}"]`):null;if(se&&X.anchor){const ye=Q.getBoundingClientRect(),le=se.getBoundingClientRect().top-ye.top-X.anchor.offsetTop;le!==0&&(Q.scrollTop+=le)}else{const ye=Q.scrollHeight-X.height;ye>0?Q.scrollTop=X.top+ye:Q.scrollTop=X.top}}}const me=b.current;if(!me)return;b.current=null,V()?.querySelector(`[data-turn-id="${me}"]`)?.scrollIntoView({block:"start"})},[W,V,u]);const ge=D2()||W.length>=hP,Z=ge?"tanstack":"none",fe=d.useRef(null),ie=d.useCallback(X=>{fe.current=X},[]),E=d.useMemo(()=>G?[...W,G]:W,[W,G]),ce=yr(X=>{a(X)}),ee=yr(X=>{a(X)}),ue=d.useMemo(()=>t.filter(X=>F0(X)==="user").map(X=>X.info.id),[t]);{const X=_.current;X.sessionKey!==e&&(X.sessionKey=e,X.previousOrder=ue,X.animatedIds=new Set);const me=X.previousOrder;if(ue.length>me.length&&me.every((T,Q)=>ue[Q]===T)&&cw(e))for(let T=me.length;T<ue.length;T+=1){const Q=ue[T];if(Q&&!X.animatedIds.has(Q)){if(!dw(e))break;X.animatedIds.add(Q)}}X.previousOrder=ue}const J=d.useCallback(X=>F0(X)!=="user"?!1:_.current.animatedIds.has(X.info.id),[]),Y=d.useCallback(X=>{_.current.animatedIds.delete(X)},[]),oe=d.useMemo(()=>{const X=new Map;return E.forEach((me,U)=>{if(me.kind==="ungrouped"){X.set(me.message.info.id,U);return}if(me.kind==="history-gate"){me.turns.forEach(T=>{X.set(T.userMessage.info.id,U),T.assistantMessages.forEach(Q=>{X.set(Q.info.id,U)})});return}X.set(me.turn.userMessage.info.id,U),me.turn.assistantMessages.forEach(T=>{X.set(T.info.id,U)})}),X},[E]),te=d.useMemo(()=>{const X=new Map;return E.forEach((me,U)=>{me.kind==="turn"&&X.set(me.turn.turnId,U),me.kind==="history-gate"&&me.turns.forEach(T=>{X.set(T.turnId,U)})}),X},[E]),pe=d.useCallback(X=>{const me=V();return me?me.querySelector(`[data-message-id="${X}"]`):null},[V]),He=d.useCallback(X=>{if(X<0||X>=W.length||!ge)return!1;const me=fe.current;return me?(me.scrollToIndex(X,{align:"start",behavior:"auto"}),!0):!1},[W.length,ge]),je=d.useCallback((X,me="auto")=>{const U=V();if(!U)return!1;const T=pe(X);if(!T)return!1;const Q=U.getBoundingClientRect(),le=T.getBoundingClientRect().top-Q.top+U.scrollTop-50;return U.scrollTo({top:le,behavior:me}),!0},[pe,V]);return d.useEffect(()=>{if(!h)return;const X={scrollToTurnId:(U,T)=>{const Q=W.find(Se=>Se.kind==="history-gate");if(Q?.kind==="history-gate"){const Se=W.reduce((Ae,Ve)=>Ve.kind==="turn"?Ae+1:Ae,0);w(U,Q.turns,Q.turns.length+Se)}const se=T?.behavior??"auto",ye=te.get(U);if(ye===void 0)return!1;const le=V();if(!le)return!1;const ne=le.querySelector(`[data-turn-id="${U}"]`);return ne?(ne.scrollIntoView({behavior:se,block:"start"}),!0):G!==void 0&&ye>=W.length?!1:He(ye)},scrollToMessageId:(U,T)=>{const Q=T?.behavior??"auto",se=oe.get(U);if(se===void 0)return!1;const ye=E[se];if(ye?.kind==="history-gate"){const le=ye.turns.find(ne=>ne.userMessage.info.id===U||ne.assistantMessages.some(Ce=>Ce.info.id===U));if(le){const ne=W.reduce((Ce,Se)=>Se.kind==="turn"?Ce+1:Ce,0);w(le.turnId,ye.turns,ye.turns.length+ne)}}return je(U,Q)||(G!==void 0&&se>=W.length?!1:He(se))},holdViewportAnchor:U=>{const T=V();if(!T||typeof window>"u")return;let Q=0,se=0,ye=!1;const le=()=>{ye=!0,T.removeEventListener("touchstart",le),T.removeEventListener("wheel",le)};T.addEventListener("touchstart",le,{passive:!0}),T.addEventListener("wheel",le,{passive:!0});const ne=()=>{if(ye)return;const Ce=pe(U.messageId);if(Ce){const Se=Ce.getBoundingClientRect().top-T.getBoundingClientRect().top-U.offsetTop;Math.abs(Se)>.5?(T.scrollTop+=Se,se=0):se+=1}if(Q+=1,se>=MP||Q>=CP){T.removeEventListener("touchstart",le),T.removeEventListener("wheel",le);return}window.requestAnimationFrame(ne)};window.requestAnimationFrame(ne)},isHistoryVirtualized:()=>ge,captureViewportAnchor:()=>{const U=V();if(!U)return null;const T=U.getBoundingClientRect(),Q=Array.from(U.querySelectorAll("[data-message-id]")),se=Q.find(le=>le.getBoundingClientRect().bottom<=T.top+1?!1:typeof window>"u"?!0:!Pd(le,U,T.top))??Q.find(le=>le.getBoundingClientRect().bottom>T.top+1);if(!se)return null;const ye=se.dataset.messageId;return ye?{messageId:ye,offsetTop:se.getBoundingClientRect().top-T.top}:null},restoreViewportAnchor:U=>{const T=V();if(!T||!oe.has(U.messageId))return!1;const Q=()=>{const se=pe(U.messageId);if(!se)return!1;const ye=T.getBoundingClientRect(),ne=se.getBoundingClientRect().top-ye.top-U.offsetTop;return ne!==0&&(T.scrollTop+=ne),!0};if(!Q()){const se=oe.get(U.messageId);if(typeof se=="number"&&se<W.length)return He(se)}return Q()},scrollToBottom:()=>{if(ge&&W.length>0&&fe.current){fe.current.scrollToEnd();return}const U=V();U&&(U.scrollTop=U.scrollHeight+4096)}};if(typeof h=="function")return h(X),()=>{h(null)};const me=h;return me.current=X,()=>{me.current=null}},[E,pe,W,oe,V,w,He,je,ge,G,te,h]),i.jsx("div",{children:i.jsx(sd,{disabled:!1,children:i.jsxs("div",{className:"relative w-full",children:[i.jsx(sd,{disabled:ge,children:i.jsx(ip,{entries:W,engine:Z,contentRef:k,scrollRef:u,registerTanstackVirtualizer:ie,virtualizerKey:e,onMessageContentChange:ce,getAnimationHandlers:L,scrollToBottom:A,stickyUserHeader:m,shouldAnimateUserMessage:J,onUserAnimationConsumed:Y,onLoadOlderHistory:S,onLoadAllHistory:C},e)}),G?i.jsx(ap,{entry:G,sessionId:e??null,directory:f,onMessageContentChange:ee,getAnimationHandlers:L,scrollToBottom:A,stickyUserHeader:m,sessionIsWorking:n,showTurnChangedFiles:p,shouldAnimateUserMessage:J,onUserAnimationConsumed:Y,activeStreamingMessageId:s,activeStreamingPhase:o}):null]})})})});lp.displayName="MessageList";const GP=d.memo(lp),WP={activity:"idle",hasWorkingContext:!1,hasActiveTools:!1,isWorking:!1,isStreaming:!1,isCooldown:!1,lifecyclePhase:null,statusText:null,isGenericStatus:!0,isWaitingForPermission:!1,canAbort:!1,compactionDeadline:null,activePartType:void 0,activeToolName:void 0,wasAborted:!1,abortActive:!1,lastCompletionId:null,isComplete:!1,retryInfo:null},Ed=[],cp="\0",KP=new Set(["edit","write","multiedit","apply_patch"]),YP={read:"reading file",write:"writing file",edit:"editing file",multiedit:"editing files",apply_patch:"applying patch",bash:"running command",grep:"searching content",glob:"finding files",list:"listing directory",task:"delegating task",webfetch:"fetching URL",websearch:"searching web",codesearch:"web code search",todowrite:"updating todos",todoread:"reading todos",skill:"learning skill",question:"asking question",plan_enter:"switching to planning",plan_exit:"switching to building"},zd=["working","processing","preparing","warming up","gears turning","computing","calculating","analyzing","wheels spinning","calibrating","synthesizing","connecting dots","inspecting logic","weighing options"],Dd=e=>YP[e]??`using ${e}`,JP=e=>{let t=0;for(let n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)},XP=e=>zd[JP(e)%zd.length]??"working",QP=(e,t)=>{let n,s;if(!A3(e))for(let a=e.length-1;a>=0;a-=1){const l=e[a];if(l)switch(l.type){case"reasoning":{const c=l.time??Rd(l);(!c||typeof c.end>"u")&&!n&&(n="reasoning");break}case"tool":{const c=l.state?.status;if((c==="running"||c==="pending")&&!n){const u=oE(l);KP.has(u)?(n="editing",s=u):(n="tool",s=u)}break}case"text":{const c=sE(l)??"";if(typeof c=="string"&&c.trim().length>0){const u=Rd(l);(!u||typeof u.end>"u")&&!n&&(n="text")}break}}}const o=n===void 0,r=n==="editing"?s==="multiedit"?Dd(s):"editing file":n==="tool"&&s?Dd(s):n==="reasoning"?"thinking":n==="text"?"composing":XP(t);return{activePartType:n,activeToolName:s,statusText:r,isGenericStatus:o}},eE=e=>[e.activePartType??"",e.activeToolName??"",e.statusText,e.isGenericStatus?"1":"0"].join(cp),tE=e=>{const[t,n,s="working",o]=e.split(cp);return{activePartType:t==="text"||t==="tool"||t==="reasoning"||t==="editing"?t:void 0,activeToolName:n||void 0,statusText:s,isGenericStatus:o==="1"}},nE=e=>e.type==="reasoning",dp=e=>e.type==="text",sE=e=>{if(dp(e))return e.text;const t=e;if(typeof t.text=="string")return t.text;if(typeof t.content=="string")return t.content;if(typeof t.value=="string")return t.value},Rd=e=>(dp(e)||nE(e),e.time),oE=e=>{if(e.tool)return e.tool;const t=e;return typeof t.name=="string"?t.name:"tool"},rE=e=>{let t=null,n=null;for(let s=e.length-1;s>=0;s-=1){const o=e[s];if(o?.role!=="assistant")continue;const r=o;t=o.id,n=typeof r.parentID=="string"&&r.parentID.trim().length>0?r.parentID:null;break}if(!t||!n)return{assistantId:t,model:null};for(let s=e.length-1;s>=0;s-=1){const o=e[s];if(o?.role!=="user"||o.id!==n)continue;const r=o,a=typeof r.model?.providerID=="string"?r.model.providerID.trim():"",l=typeof r.model?.modelID=="string"?r.model.modelID.trim():"";return{assistantId:t,model:a&&l?{providerId:a,modelId:l}:null}}return{assistantId:t,model:null}};function iE(){const e=Be(v=>v.currentSessionId);Be(v=>v.currentSessionDirectory);const t=$i(e??""),n=d.useMemo(()=>rE(t),[t]),s=n.assistantId,o=ci(d.useCallback(v=>{const x=`${e??""}:${s??""}`,S=s?v.part[s]??Ed:Ed;return eE(QP(S,x))},[e,s])),r=Ru(),a=Ou(),l=Be(d.useCallback(v=>e?v.sessionAbortFlags?.get(e)??null:null,[e])),{phase:c,isWorking:u}=s5(),f=qi(e??""),h=f?.type==="retry"?f.attempt:void 0,m=f?.type==="retry"?f.next:void 0,p=d.useMemo(()=>tE(o),[o]),g=d.useMemo(()=>{const v=!!(l&&!l.acknowledged);return{wasAborted:v,abortActive:v}},[l]),y=d.useMemo(()=>{if(g.wasAborted)return{...WP,wasAborted:!0,abortActive:g.abortActive,activity:"idle",hasWorkingContext:!1,isWorking:!1,isStreaming:!1,isCooldown:!1,statusText:null,canAbort:!1,retryInfo:null};const v=u,x=c==="busy",S=!1,C=c==="retry";let w="idle";v&&(p.activePartType==="tool"||p.activePartType==="editing"?w="tooling":w="streaming");const _=C?{attempt:h,next:m}:null;return{activity:w,hasWorkingContext:v,hasActiveTools:p.activePartType==="tool"||p.activePartType==="editing",isWorking:v,isStreaming:x,isCooldown:S,lifecyclePhase:x?"streaming":null,statusText:v?p.statusText:null,isGenericStatus:v?p.isGenericStatus:!0,isWaitingForPermission:!1,canAbort:v,compactionDeadline:null,activePartType:v?p.activePartType:void 0,activeToolName:v?p.activeToolName:void 0,wasAborted:!1,abortActive:!1,lastCompletionId:null,isComplete:!1,retryInfo:_}},[c,u,p,g,h,m]),M=d.useMemo(()=>({isActive:u&&p.activePartType==="text",characterCount:0}),[u,p.activePartType]),b=d.useMemo(()=>{if(y.wasAborted||y.abortActive)return y;const v=r.length>0,x=a.length>0;return!v&&!x?y:x?{...y,statusText:null,isWorking:!1,hasWorkingContext:!1,hasActiveTools:!1,canAbort:!1,activePartType:void 0,activeToolName:void 0,retryInfo:null}:{...y,statusText:"waiting for permission",isWaitingForPermission:!0,canAbort:!1,retryInfo:null}},[y,r,a]);return{activeModel:n.model,forming:M,working:b}}const up=d.memo(()=>{const e=Be(c=>c.currentSessionId),t=Be(d.useCallback(c=>e?c.sessionAbortFlags?.get(e)??null:null,[e])),{activeModel:n,working:s}=iE(),o=$e(c=>c.currentAgentName),r=$e(c=>c.providers),a=d.useMemo(()=>{if(!n)return null;const c=r.length>0?r.find(u=>u.id===n.providerId):void 0;return ru(c,n.modelId)||null},[n,r]),l=!!(t&&!t.acknowledged);return i.jsx(Rf,{isWorking:s.isWorking,statusText:s.statusText,isGenericStatus:s.isGenericStatus,isWaitingForPermission:s.isWaitingForPermission,wasAborted:l||s.wasAborted,abortActive:l||s.abortActive,retryInfo:s.retryInfo,showAssistantStatus:!0,showTodos:!1,agentName:o,modelName:a,providerId:n?.providerId??null})});up.displayName="StatusRowContainer";const aE=({visible:e,onClick:t})=>i.jsx("div",{className:B("absolute bottom-full left-1/2 -translate-x-1/2 mb-2 transition-all duration-150",e?"opacity-100 translate-y-0 scale-100 pointer-events-auto":"opacity-0 translate-y-2 scale-95 pointer-events-none"),children:i.jsx(a1,{variant:"outline",size:"sm",onClick:t,className:"size-8 rounded-full [corner-shape:round] p-0 shadow-none bg-background/95 hover:bg-interactive-hover","aria-label":"Scroll to bottom",children:i.jsx(z,{name:"arrow-down",className:"h-4 w-4"})})}),lE=d.memo(aE);function Q4(e){return e.filter(t=>t.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
7032
+ `)}return u1&&u1.trim().length>0?u1:uw(le)},[u1,le,I]),s2=L1.length>0,K1=d.useCallback(async()=>{let be;if(I)be=await gt(L1);else{const{renderMarkdownSync:Ge}=await V2(async()=>{const{renderMarkdownSync:b1}=await import("./markdownCore-CAVCyFnI.js").then(d1=>d1.m);return{renderMarkdownSync:b1}},__vite__mapDeps([16,17,18,19,20,21]));be=await iC(L1,Ge(L1))}return be.ok?(I&&(k(!0),setTimeout(()=>k(!1),2e3)),!0):!1},[I,L1]),I2=d.useCallback(be=>{const Ge=Ae.has(be),b1=Ve.has(be);if(Ge){P(d1=>{const Ye=new Set(d1);return b1?Ye.add(be):Ye.delete(be),wd(e.info.id,Ye),Ye}),b1||H(d1=>{const Ye=new Set(d1);return Ye.delete(be),bd(e.info.id,Ye),Ye});return}H(d1=>{const Ye=new Set(d1);return Ye.has(be)?Ye.delete(be):Ye.add(be),bd(e.info.id,Ye),Ye}),P(d1=>{if(!d1.has(be))return d1;const Ye=new Set(d1);return Ye.delete(be),wd(e.info.id,Ye),Ye})},[Ae,Ve,e.info.id]),ke=o??null,e1=d.useRef(!1),Re=d.useRef(!1),f1=d.useRef(!1),Y1=d.useRef(!1),C2=d.useRef(!1),S2=d.useRef(!1);d.useEffect(()=>{Re.current=!1,f1.current=!1,Y1.current=!1,C2.current=!1,e1.current=!1,S2.current=!1},[e.info.id]);const K2=d.useCallback(()=>{I||e1.current||(e1.current=!0,s?.("structural"))},[I,s]),O1=he(be=>be.setImagePreviewOpen),g2=d.useCallback(be=>{(be.image||be.mermaid)&&($(be),O1(!0))},[O1]),e2=d.useCallback(be=>{$(Ge=>({...Ge,open:be})),O1(be)},[O1]),Y2=!!Z2(e.info,"animationSettled"),J2=F1==="streaming"||F1==="cooldown";J2&&(S2.current=!0);const o2=d.useMemo(()=>I?!1:ye.some(be=>be.type==="reasoning"),[I,ye]),B2=xe&&!Y2&&!J2&&!S2.current,lt=!I&&xe&&ne.length>0&&!n1;if(d.useEffect(()=>{if(ke?.onStreamingCandidate){if(!lt){f1.current&&(o2&&ke?.onReasoningBlock?ke.onReasoningBlock():ke?.onReservationCancelled&&ke.onReservationCancelled(),f1.current=!1);return}C2.current||(C2.current=!0,ke.onStreamingCandidate(),f1.current=!0)}},[ke,lt,o2]),d.useEffect(()=>{ke?.onAnimationStart&&B2&&(Y1.current||(ke.onAnimationStart(),Y1.current=!0))},[ke,B2]),d.useEffect(()=>{if(I)return;const be=ke?.onAnimatedHeightChange;if(!be||!(B2||lt))return;const b1=M.current;if(!b1)return;if(typeof window>"u"||typeof ResizeObserver>"u"){be(b1.getBoundingClientRect().height);return}let d1=null;const Ye=k2=>{if(typeof window>"u"){be(k2);return}d1!==null&&window.cancelAnimationFrame(d1),d1=window.requestAnimationFrame(()=>{be(k2)})},a2=new ResizeObserver(k2=>{const X2=k2[0];X2&&Ye(X2.contentRect.height)});return a2.observe(b1),Ye(b1.getBoundingClientRect().height),()=>{d1!==null&&(window.cancelAnimationFrame(d1),d1=null),a2.disconnect()}},[B2,I,ke,lt]),Ie)return null;const d2=!I&&re&&!_1&&C?h?"pt-4":"pt-6":"pt-0";return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:B("group w-full",I?h?"pt-2":"pt-4":d2,I||at||m2?"pb-0":"pb-2"),id:`message-${e.info.id}`,"data-message-id":e.info.id,ref:M,children:i.jsx("div",{className:"chat-message-column relative",children:I?le.length===0?null:i.jsx(It,{forceAnimation:!0,skipAnimation:!u,ignoreContextDisabled:!0,respectReducedMotion:!0,children:i.jsx("div",{className:B("relative flex justify-end",h?void 0:"group/user-shell"),children:i.jsxs("div",{className:B("max-w-[85%]",G?"pb-5":void 0),children:[i.jsx("div",{style:{backgroundColor:"var(--chat-user-message-bg)",borderRadius:"var(--radius-xl)",borderBottomRightRadius:"var(--radius-sm)"},className:"px-5 py-3 shadow-none border border-primary/5",children:i.jsx(Il,{sessionId:e.info.sessionID,messageId:e.info.id,parts:le,isUser:I,isMessageCompleted:Q,messageFinish:se,messageCreatedAt:T??void 0,isMobile:h,alwaysShowActions:g,hasTouchInput:p,copiedCode:L,onCopyCode:Ne,expandedTools:V,onToggleTool:I2,onShowPopup:g2,streamPhase:F1,allowAnimation:B2,onContentChange:s,shouldShowHeader:!1,hasTextContent:s2,onCopyMessage:K1,copiedMessage:N,showReasoningTraces:S,onAuxiliaryContentComplete:K2,agentMention:Me,errorMessage:u1,errorVariant:v1,isLatestMessage:!n,userActionsMode:q?"external-content":"inline",stickyUserHeaderEnabled:C})}),q?i.jsx(Il,{sessionId:e.info.sessionID,messageId:e.info.id,parts:le,isUser:I,isMessageCompleted:Q,messageFinish:se,messageCreatedAt:T??void 0,isMobile:h,alwaysShowActions:g,hasTouchInput:p,copiedCode:L,onCopyCode:Ne,expandedTools:V,onToggleTool:I2,onShowPopup:g2,streamPhase:F1,allowAnimation:B2,onContentChange:s,shouldShowHeader:!1,hasTextContent:s2,onCopyMessage:K1,copiedMessage:N,showReasoningTraces:S,onAuxiliaryContentComplete:K2,agentMention:Me,errorMessage:u1,errorVariant:v1,isLatestMessage:!n,userActionsMode:"external-actions",stickyUserHeaderEnabled:C}):null]})})}):i.jsx("div",{className:"relative",children:i.jsx(Il,{sessionId:e.info.sessionID,messageId:e.info.id,parts:ye,isUser:I,isMessageCompleted:Q,isLatestMessage:!n,messageFinish:se,messageCompletedAt:U??void 0,messageCreatedAt:T??void 0,durationMs:e.info.durationMs,isMobile:h,alwaysShowActions:g,hasTouchInput:p,copiedCode:L,onCopyCode:Ne,expandedTools:Ve,onToggleTool:I2,onShowPopup:g2,streamPhase:F1,allowAnimation:B2,onContentChange:s,shouldShowHeader:re,hasTextContent:s2,onCopyMessage:K1,copiedMessage:N,onAuxiliaryContentComplete:K2,showReasoningTraces:S,agentMention:Me,turnGroupingContext:r,errorMessage:u1,errorVariant:v1,footerProviderID:X,footerModelName:me,footerAgentName:Pe,footerVariant:Ke,isDarkTheme:Le})})})}),i.jsx(d.Suspense,{fallback:null,children:i.jsx(uN,{popup:R,onOpenChange:e2,isMobile:h})})]})},gN=d.memo(pN,(e,t)=>Qh({info:e.message.info,parts:e.message.parts},{info:t.message.info,parts:t.message.parts})&&Ai(e.previousMessage?{info:e.previousMessage.info,parts:e.previousMessage.parts}:void 0,t.previousMessage?{info:t.previousMessage.info,parts:t.previousMessage.parts}:void 0)&&Ai(e.nextMessage?{info:e.nextMessage.info,parts:e.nextMessage.parts}:void 0,t.nextMessage?{info:t.nextMessage.info,parts:t.nextMessage.parts}:void 0)&&e.isInActiveTurn===t.isInActiveTurn&&e.activeStreamingPhase===t.activeStreamingPhase&&e.assistantHeaderMessageId===t.assistantHeaderMessageId&&e.animateUserOnMount===t.animateUserOnMount&&e.onUserAnimationConsumed===t.onUserAnimationConsumed&&tm(e.turnGroupingContext,t.turnGroupingContext,e.message.info.id,ji(e.message.info).isUser)),yN=d.memo(function({message:t,renderMessage:n}){return n(t)},(e,t)=>e.message===t.message),vN=({assistantMessages:e,renderMessage:t})=>i.jsx("div",{className:"relative z-0",children:e.map(n=>i.jsx(yN,{message:n,renderMessage:t},n.info.id))}),bN=d.memo(vN),xN=d.memo(function({userMessage:t,stickyUserHeader:n,renderMessage:s}){const o=s(t);return n?i.jsxs("div",{className:"sticky top-0 z-20 relative bg-[var(--surface-background)] [overflow-anchor:none]",children:[i.jsx("div",{className:"relative z-10",children:o}),i.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 top-full z-0 h-4 bg-gradient-to-b from-[var(--surface-background)] to-transparent sm:h-8"})]}):o},(e,t)=>e.userMessage===t.userMessage&&e.stickyUserHeader===t.stickyUserHeader),wN=({turn:e,stickyUserHeader:t=!0,renderMessage:n})=>i.jsxs("section",{className:"relative w-full",id:`turn-${e.turnId}`,"data-turn-id":e.turnId,"data-scroll-spy-id":e.turnId,children:[i.jsx(xN,{userMessage:e.userMessage,stickyUserHeader:t,renderMessage:n}),i.jsx(bN,{assistantMessages:e.assistantMessages,renderMessage:n})]}),MN=d.memo(wN),A5=2,Ym=2,CN=72,SN=(e,t=A5)=>t+Math.max(0,e),_N=(e,t,n,s=A5)=>{const o=SN(n,s);return t<=o?!1:e<t-o},kN=(e,t,n=A5)=>Math.max(0,t-n-e),AN=(e,t,n=Ym)=>e+Math.max(0,Math.min(n,t)),HN=({foldedCount:e,onLoadOlder:t,onLoadAll:n})=>{const s=Math.min(Ym,e),o=e>s;return i.jsx("div",{className:"chat-message-column flex flex-col items-center py-4",children:i.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[i.jsxs(a1,{type:"button",variant:"secondary",size:"sm",onClick:t,"aria-label":"Load older history",className:"gap-1.5 rounded-full px-3.5",children:[i.jsx(z,{name:"history",className:"size-3.5"}),"Load older history"]}),o?i.jsx(a1,{type:"button",variant:"ghost",size:"sm",onClick:n,"aria-label":"Load all history",className:"rounded-full px-3.5 text-[var(--surface-mutedForeground)]",children:"Load all history"}):null]})})},LN=d.memo(HN),jN=new Set(["task"]),IN=e=>typeof e=="string"&&jN.has(e.toLowerCase()),BN=e=>{const t=e.state?.time?.end;if(typeof t=="number")return t;const n=e.time?.end;return typeof n=="number"?n:void 0},Cd=e=>{const t=e.text;if(typeof t=="string"&&t.trim().length>0)return t;const n=e.content;if(typeof n=="string"&&n.trim().length>0)return n},TN=e=>{const t=e.info.finish;return typeof t=="string"?t:void 0},VN=e=>e.info.summary===!0,NN=(e,t,n,s)=>({id:n.id??`${t}-part-${s}-${n.type}`,turnId:e,messageId:t,part:n,partIndex:s,endedAt:BN(n)}),PN=e=>{const t=[];let n=!1,s=!1;e.assistantMessages.forEach(h=>{h.parts.forEach(m=>{if(m.type==="tool"){n=!0;return}m.type==="reasoning"&&Cd(m)&&(s=!0)})});const o=new Map,r=[],a=new Map;let l=null;e.assistantMessages.forEach(h=>{const m=TN(h),p=h.parts.some(y=>y.type==="tool"),g=VN(h);h.parts.forEach((y,M)=>{const b=y.type==="tool",v=y.type==="reasoning"||y.type==="text"?Cd(y):void 0,x=y.id??`${h.info.id}-part-${M}-${y.type}`,S=b?y.tool:void 0,C=b&&IN(S);if(C){const N=x;o.has(N)||(o.set(N,h.info.id),r.push(N)),l=N}const w=y.type==="text"&&typeof v=="string"&&(m==="stop"||typeof m!="string")&&e.summarySourceMessageId===h.info.id&&e.summarySourcePartId===x;let _=null;if(b?_="tool":y.type==="reasoning"?v&&(_="reasoning"):e.showTextJustificationActivity&&y.type==="text"&&v&&(g||!w&&(p||typeof m=="string"&&m!=="stop"))&&(_="justification"),!_)return;const L={...NN(e.turnId,h.info.id,y,M),kind:_};if(t.push(L),_==="tool"&&C)return;const A=a.get(l)??[];A.push(L),a.set(l,A)})});const c=[],u=h=>{if(h.length===0)return;const m=new Map;h.forEach(g=>{m.set(g.messageId,(m.get(g.messageId)??0)+1)});let p;for(const g of e.assistantMessages)(m.get(g.info.id)??0)>0&&!p&&(p=g.info.id);return p};return[null,...r].forEach(h=>{const m=a.get(h)??[];if(m.length===0)return;const p=h===null?u(m):o.get(h);p&&c.push({id:`${e.turnId}:${p}:${h??"start"}`,anchorMessageId:p,afterToolPartId:h,parts:m})}),{activityParts:t,activitySegments:c,hasTools:n,hasReasoning:s}},EN=e=>{const t=new Map,n=new Map,s=new Map,o=new Set;e.forEach(l=>{t.set(l.turnId,l);const c=l.assistantMessages[0]?.info.id,u=l.assistantMessages[l.assistantMessages.length-1]?.info.id;n.set(l.userMessageId,l.turnId),o.add(l.userMessageId),s.set(l.userMessageId,{turnId:l.turnId,messageId:l.userMessageId,userMessageId:l.userMessageId,isUserMessage:!0,isAssistantMessage:!1,isFirstAssistantInTurn:!1,isLastAssistantInTurn:!1,headerMessageId:l.headerMessageId}),l.assistantMessageIds.forEach(f=>{n.set(f,l.turnId),o.add(f),s.set(f,{turnId:l.turnId,messageId:f,userMessageId:l.userMessageId,isUserMessage:!1,isAssistantMessage:!0,isFirstAssistantInTurn:f===c,isLastAssistantInTurn:f===u,headerMessageId:l.headerMessageId})})});const r=e.length>0?e[e.length-1]:null,a=new Set;return r&&(a.add(r.userMessageId),r.assistantMessageIds.forEach(l=>{a.add(l)})),{turns:e,indexes:{turnById:t,messageToTurnId:n,messageMetaById:s},lastTurnId:r?.turnId??null,lastTurnMessageIds:a,ungroupedMessageIds:new Set}},Sd=e=>{const t=e.text;if(typeof t=="string"&&t.trim().length>0)return t;const n=e.content;if(typeof n=="string"&&n.trim().length>0)return n},_d=e=>e.info.summary===!0,zN=e=>{for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(!(!n||_d(n)||n.info.finish!=="stop"))for(let o=n.parts.length-1;o>=0;o-=1){const r=n.parts[o];if(!r||r.type!=="text")continue;const a=Sd(r);if(a)return{text:a,sourceMessageId:n.info.id,sourcePartId:r.id??`${n.info.id}-part-${o}-text`}}}for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n&&!_d(n))for(let s=n.parts.length-1;s>=0;s-=1){const o=n.parts[s];if(!o||o.type!=="text")continue;const r=Sd(o);if(r)return{text:r,sourceMessageId:n.info.id,sourcePartId:o.id??`${n.info.id}-part-${s}-text`}}}return{}},DN=e=>{const n=e.info.summary?.diffs;if(!Array.isArray(n)||n.length===0)return;let s=0,o=0,r=0;if(n.forEach(a=>{if(!a)return;const l=typeof a.additions=="number"?a.additions:0,c=typeof a.deletions=="number"?a.deletions:0;(l!==0||c!==0)&&(r+=1),s+=l,o+=c}),r!==0)return{additions:s,deletions:o,files:r}},RN=e=>{const n=e.info.summary?.diffs;if(!Array.isArray(n)||n.length===0)return;const s=n.map(o=>{if(!o||typeof o.file!="string"||o.file.trim().length===0)return null;const r=typeof o.additions=="number"?o.additions:0,a=typeof o.deletions=="number"?o.deletions:0;return r===0&&a===0?null:{file:o.file,additions:r,deletions:a}}).filter(o=>o!==null);return s.length>0?s:void 0},$r=e=>{const t=e.info.clientRole??e.info.role;return typeof t=="string"?t:""},Jm=e=>{const t=e.info.parentID;if(!(typeof t!="string"||t.trim().length===0))return t},ON=e=>{const t=e.info.time?.created;return typeof t=="number"?t:void 0},ZN=e=>{const t=e.info.time?.completed;return typeof t=="number"?t:void 0},FN=e=>{const t=e.info?.summary?.body;return typeof t!="string"?void 0:t.trim().length>0?t:void 0},Tl=(e,t)=>{const n=$r(e);return{messageId:e.info.id,role:n,parentMessageId:Jm(e),message:e,order:t}},$N=(e,t)=>{const n=ON(e);let s,o=!1;t.forEach(a=>{const l=ZN(a);typeof l=="number"?s=Math.max(s??0,l):o=!0});const r=typeof n=="number"&&typeof s=="number"&&s>=n?s-n:void 0;return{isStreaming:o,isRetrying:t.length>1,startedAt:n,completedAt:s,durationMs:r}},qN={previousProjection:null,showTextJustificationActivity:!1,showTurnChangedFiles:!1,mergeHiddenUserTurns:void 0},UN=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0},GN=(e,t)=>e.userMessage===t.userMessage&&e.headerMessageId===t.headerMessageId&&UN(e.assistantMessages,t.assistantMessages),kd=(e,t)=>{e.summary=zN(e.assistantMessages),e.summaryText=e.summary.text??FN(e.userMessage),e.diffStats=DN(e.userMessage),e.changedFiles=t.showTurnChangedFiles?RN(e.userMessage):void 0;const n=PN({turnId:e.turnId,assistantMessages:e.assistantMessages,summarySourceMessageId:e.summary.sourceMessageId,summarySourcePartId:e.summary.sourcePartId,showTextJustificationActivity:t.showTextJustificationActivity});return e.activityParts=n.activityParts,e.activitySegments=n.activitySegments,e.hasTools=n.hasTools,e.hasReasoning=n.hasReasoning,e.stream=$N(e.userMessage,e.assistantMessages),e.startedAt=e.stream.startedAt,e.completedAt=e.stream.completedAt,e.durationMs=e.stream.durationMs,e},WN=(e,t)=>{const n=t.previousProjection;if(!n||n.turns.length===0||e.length===0)return e.map(a=>kd(a,t));let s=n.turns.length===e.length,o=!1;const r=e.map((a,l)=>{const c=n.indexes.turnById.get(a.turnId);return c&&GN(c,a)?(o=!0,n.turns[l]!==c&&(s=!1),c):(s=!1,kd(a,t))});return s&&o?n.turns:r},Xm=(e,t)=>{const n={...qN,...t},s=[],o=new Map,r=new Set,a=n.mergeHiddenUserTurns;e.forEach((f,h)=>{if($r(f)!=="user")return;const p=s[s.length-1];if(a&&p&&Ii(f)){o.set(f.info.id,p),p.messages.push(Tl(f,h)),r.add(f.info.id);return}const y={turnId:f.info.id,userMessageId:f.info.id,userMessage:f,headerMessageId:void 0,messages:[Tl(f,h)],assistantMessageIds:[],assistantMessages:[],activityParts:[],activitySegments:[],summary:{},summaryText:void 0,hasTools:!1,hasReasoning:!1,diffStats:void 0,changedFiles:void 0,stream:{isStreaming:!1,isRetrying:!1}};s.push(y),o.set(y.userMessageId,y),r.add(f.info.id)}),e.forEach((f,h)=>{if($r(f)!=="assistant")return;const p=Jm(f),g=p?o.get(p):void 0;g&&(g.assistantMessages.push(f),g.assistantMessageIds.push(f.info.id),g.messages.push(Tl(f,h)),g.headerMessageId||(g.headerMessageId=f.info.id),r.add(f.info.id))});const l=WN(s,n),c=EN(l),u=new Set;return e.forEach(f=>{$r(f)!=="assistant"&&(r.has(f.info.id)||u.add(f.info.id))}),{...c,ungroupedMessageIds:u}},KN=30,YN=4,Wt=new Map,Ad=new WeakMap;let Hd=1;const JN=()=>D2()?YN:KN,Vl=e=>{const t=Ad.get(e);if(t!==void 0)return t;const n=Hd;return Hd+=1,Ad.set(e,n),n},XN=e=>e.map(t=>{const n=Vl(t.info),s=Vl(t.parts),o=t.parts.map(r=>Vl(r)).join(",");return`${n}:${s}:${o}`}).join(";"),QN=(e,t,n,s,o)=>{const r=t.length>0?t[t.length-1]:void 0,a=r?.info?.id??"",l=r?.parts?.length??0;return[e,t.length,a,l,XN(t),n?"1":"0",s?"1":"0",o].join("|")},eP=e=>{const t=Wt.get(e);return t&&(Wt.delete(e),Wt.set(e,t)),t},tP=(e,t)=>{Wt.delete(e);const n=JN();for(;Wt.size>=n;){const s=Wt.keys().next().value;if(typeof s!="string")break;Wt.delete(s)}Wt.set(e,t)},nP=(e,t)=>{const n=d.useRef(null),s=d.useRef([]),o=d.useRef(void 0),r=d.useRef(t.sessionKey),a=d.useRef(t.showTextJustificationActivity),l=d.useRef(t.showTurnChangedFiles);(r.current!==t.sessionKey||a.current!==t.showTextJustificationActivity||l.current!==t.showTurnChangedFiles)&&(r.current=t.sessionKey,a.current=t.showTextJustificationActivity,l.current=t.showTurnChangedFiles,n.current=null,s.current=[],o.current=void 0),d.useEffect(()=>{n.current=null,s.current=[],o.current=void 0},[t.sessionKey,t.showTextJustificationActivity,t.showTurnChangedFiles]);const c=d.useMemo(()=>{const h=t.sessionKey??"",m=QN(h,e,t.showTextJustificationActivity,t.showTurnChangedFiles,"merge"),p=eP(m);return p?(n.current=p,p):Mr("ui.turns.projection_ms",()=>{const g=Xm(e,{previousProjection:n.current,showTextJustificationActivity:t.showTextJustificationActivity,showTurnChangedFiles:t.showTurnChangedFiles,mergeHiddenUserTurns:!0});return n.current=g,tP(m,g),g})},[e,t.showTextJustificationActivity,t.showTurnChangedFiles,t.sessionKey]),u=d.useMemo(()=>{const h=c.turns.length<=1?[]:c.turns.slice(0,-1),m=s.current;if(m.length===h.length){let p=!0;for(let g=0;g<h.length;g+=1)if(m[g]!==h[g]){p=!1;break}if(p)return m}return s.current=h,h},[c.turns]),f=d.useMemo(()=>{const h=c.turns.length===0?void 0:c.turns[c.turns.length-1];return o.current===h?o.current:(o.current=h,h)},[c.turns]);return{projection:c,staticTurns:u,streamingTurn:f}},Ld=e=>{const t=e.info;return(typeof t.clientRole=="string"?t.clientRole:null)??(typeof t.role=="string"?t.role:null)??null},sP=(e,t)=>{if(!t.sessionId)return e;const n={name:"SessionRetry",message:t.message,data:{message:t.message}};let s=-1;for(let u=e.length-1;u>=0;u-=1)if(Ld(e[u])==="user"){s=u;break}if(s<0)return e;let o=-1;for(let u=e.length-1;u>s;u-=1)if(Ld(e[u])==="assistant"){o=u;break}if(o>=0)return e.map((u,f)=>f!==o?u:{...u,info:{...u.info,error:n}});const r=typeof t.confirmedAt=="number"?t.confirmedAt:t.fallbackTimestamp,l={info:{id:`synthetic_retry_notice_${t.sessionId}`,sessionID:t.sessionId,role:"assistant",parentID:e[s].info.id,time:{created:r,completed:r},finish:"stop",error:n},parts:[]},c=e.slice();return c.splice(s+1,0,l),c},oP=e=>{const t=e.info;if(t.finish==="stop"||t.finish==="error")return!0;const n=t.time?.completed,s=t.status;return typeof n!="number"||n<=0?!1:typeof s=="string"?s==="completed":!0},rP=e=>{const{activeStreamingMessageId:t,assistantMessages:n}=e;if(t&&n.some(s=>s.info.id===t))return t;for(let s=n.length-1;s>=0;s--)if(!oP(n[s]))return n[s].info.id;return null},iP=e=>e.isRetrying===!0||!!e.activeStreamingMessageId&&e.messageId===e.activeStreamingMessageId,Qm=e=>e.parts.some(t=>t?.type==="compaction"),aP=e=>{if(!Qm(e))return e;let t=!1;const n=e.parts.map(r=>r?.type!=="compaction"?r:(t=!0,{type:"text",text:"/compact"})),o=e.info.clientRole!=="user";return!t&&!o?e:{...e,info:o?{...e.info,clientRole:"user"}:e.info,parts:t?n:e.parts}},lP=e=>{const t=ma(e.parts);return t.length===e.parts.length?e:{...e,parts:t}},jd=new WeakMap,ep=e=>{const t=jd.get(e);if(t)return t;const n=lP(e),s=aP(n),o=mw(s.parts),r=o===s.parts?s:{...s,parts:o};return jd.set(e,r),r},Id=(e,t,n)=>e.info.id!==t||e.parts===n?e:ep({...e,parts:n}),cP=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const s=e[n],o=t[n];if(!s||!o||s.id!==o.id||s.type!==o.type||s.type!=="text"&&s!==o)return!1}return!0},Bd=(e,t)=>{if(e.messages.length===0)return e.messages;const n=new Map(t.map(r=>[r.info.id,r]));let s=!1;const o=e.messages.map(r=>{const a=n.get(r.messageId);return!a||a===r.message?r:(s=!0,{...r,message:a})});return s?o:e.messages},dP=(e,t)=>{const n=t.activeStreamingMessageId;if(!n)return e;if(e.kind==="ungrouped"){const m=Id(e.message,n,t.liveParts);return m===e.message?e:{...e,message:m}}let s=!1;const o=e.turn.assistantMessages.map(m=>{const p=Id(m,n,t.liveParts);return p!==m&&(s=!0),p});if(!s)return e;const r=e.turn.assistantMessages.find(m=>m.info.id===n),a=o.find(m=>m.info.id===n);if(!!(r&&a&&cP(r.parts,a.parts)))return{...e,turn:{...e.turn,assistantMessages:o,messages:Bd(e.turn,o)}};const c=new Map(o.map(m=>[m.info.id,m])),u=e.turn.messages.length>0?e.turn.messages.slice().sort((m,p)=>m.order-p.order).map(m=>c.get(m.messageId)??m.message):[e.turn.userMessage,...o],h=Xm(u,{showTextJustificationActivity:t.showTextJustificationActivity,showTurnChangedFiles:t.showTurnChangedFiles,mergeHiddenUserTurns:t.mergeHiddenUserTurns}).turns[0]??{...e.turn,assistantMessages:o,assistantMessageIds:o.map(m=>m.info.id),messages:Bd(e.turn,o)};return{...e,turn:h}},tp="The following tool was executed by the user",H5=e=>{const t=e.info;return(typeof t.clientRole=="string"?t.clientRole:null)??(typeof t.role=="string"?t.role:null)??null},uP=e=>{const t=e.info;return typeof t.parentID=="string"&&t.parentID.length>0?t.parentID:null},np=e=>!e||H5(e)!=="user"?!1:e.parts.some(t=>{if(t?.type!=="text")return!1;const n=t.text;return t.synthetic===!0&&typeof n=="string"&&n.trim().startsWith(tp)}),sp=(e,t)=>{if(H5(e)!=="assistant")return{hide:!1,details:null};if(t&&uP(e)!==t)return{hide:!1,details:null};if(e.parts.length!==1)return{hide:!1,details:null};const n=e.parts[0];if(n?.type!=="tool")return{hide:!1,details:null};if((typeof n.tool=="string"?n.tool.toLowerCase():"")!=="bash")return{hide:!1,details:null};const o=typeof n.state?.input?.command=="string"?n.state.input.command:void 0,r=(typeof n.state?.output=="string"?n.state.output:void 0)??(typeof n.state?.metadata?.output=="string"?n.state.metadata.output:void 0),a=typeof n.state?.status=="string"?n.state.status:void 0;return{hide:!0,details:{command:o,output:r,status:a}}},fP=(e,t)=>{const n=e[t];if(!n)return null;const s=n.info.id;for(let o=t+1;o<e.length;o+=1){const r=e[o];if(H5(r)==="user")break;const{hide:a,details:l}=sp(r,s);if(a){const c=typeof l?.command=="string"?l.command.trim():"";return c.length>0?c:null}}return null},Td=e=>!!(e&&e.clientHeight>0),hP=5,mP=[],pP=new Set,gP=16,yP=(e,t)=>e===t?!0:!e||!t||e.length!==t.length?!1:e.every((n,s)=>n===t[s]),vP=320,bP=8,xP=16,wP=()=>D2()?xP:bP,MP=30,CP=180,SP=5,_P=120,kP=1200,AP=80,HP=160,Vd=1500,LP=1.5,jP=90,IP=(e,t)=>{if(e.length===0||t.length<=e.length||e[e.length-1]?.key!==t[t.length-1]?.key)return!1;const n=e[0]?.key;return t.findIndex(o=>o.key===n)>0},k0=new Map,BP=32,xn=new Map,Nd=e=>xn.get(e)??0,TP=(e,t)=>{if(xn.size>=BP&&!xn.has(e)){const n=xn.keys().next().value;typeof n=="string"&&xn.delete(n)}xn.set(e,t)},VP=(e,t)=>{const n=k0.get(e);if(n){if(yP(n.keys,t))return n.items;k0.delete(e)}},NP=(e,t,n)=>{if(!(!n||t.length===0))for(k0.delete(e),k0.set(e,{keys:t.slice(),items:n.takeSnapshot()});k0.size>gP;){const s=k0.keys().next().value;if(typeof s!="string")break;k0.delete(s)}},yr=e=>{const t=d.useRef(e);return d.useEffect(()=>{t.current=e},[e]),d.useCallback((...n)=>t.current(...n),[])},F0=e=>{const t=e.info;return(typeof t.clientRole=="string"?t.clientRole:null)??(typeof t.role=="string"?t.role:null)??null},PP=e=>e.info.error?.name==="SessionRetry",EP=e=>{const t=e.text;if(typeof t=="string")return t;const n=e.content;return typeof n=="string"?n:""},zP=(e,t)=>{if(F0(e)!=="system")return e;const s=OP(e);return!s||!t.has(s)||e.info.clientRole==="assistant"?e:{...e,info:{...e.info,clientRole:"assistant"}}},DP=e=>!e||F0(e)!=="user"?!1:e.parts.some(t=>t?.type==="subtask"),RP=e=>{if(!e)return null;const t=e.info.id;return typeof t=="string"&&t.trim().length>0?t:null},OP=e=>{const t=e.info.parentID;return typeof t=="string"&&t.trim().length>0?t:null},Pd=(e,t,n)=>{if(typeof window>"u")return!1;let s=e;for(;s&&s!==t;){if(window.getComputedStyle(s).position==="sticky"&&s.getBoundingClientRect().top<=n+1)return!0;s=s.parentElement}return!1},ZP=e=>{const t=e,n=t.state?.metadata,s=(typeof n?.sessionID=="string"&&n.sessionID.trim().length>0?n.sessionID.trim():null)??(typeof n?.sessionId=="string"&&n.sessionId.trim().length>0?n.sessionId.trim():null);if(s)return s;const o=t.state?.output;if(typeof o=="string"){const r=o.match(/task_id\s*:\s*([^\s<"']+)/i);if(r?.[1])return r[1]}return null},FP=e=>{if(F0(e)!=="assistant")return{hide:!1,taskSessionId:null};if(e.parts.length!==1)return{hide:!1,taskSessionId:null};const t=e.parts[0];return t?.type!=="tool"?{hide:!1,taskSessionId:null}:(typeof t.tool=="string"?t.tool.toLowerCase():"")!=="task"?{hide:!1,taskSessionId:null}:{hide:!0,taskSessionId:ZP(e.parts[0])}},$P=(e,t)=>{if(!t)return e;const n=e.parts.map(s=>{if(s?.type!=="subtask")return s;const o=s.taskSessionID;return typeof o=="string"&&o.trim().length>0?s:{...s,taskSessionID:t}});return{...e,parts:n}},qP=(e,t)=>{const n=typeof t?.command=="string"?t.command.trim():"",s=typeof t?.output=="string"?t.output:"",o=typeof t?.status=="string"?t.status.trim():"",r=[];let a=!1;for(const l of e.parts){if(!a&&l?.type==="text"){const c=l.text;if(l.synthetic===!0&&typeof c=="string"&&c.trim().startsWith(tp)){r.push({type:"text",text:"/shell",shellAction:{...n?{command:n}:{},...s?{output:s}:{},...o?{status:o}:{}}}),a=!0;continue}}r.push(l)}return a||r.push({type:"text",text:"/shell",shellAction:{...n?{command:n}:{},...s?{output:s}:{},...o?{status:o}:{}}}),{...e,parts:r}},L5=d.memo(({message:e,previousMessage:t,nextMessage:n,turnGroupingContext:s,assistantHeaderMessageId:o,isInActiveTurn:r,activeStreamingPhase:a,animateUserOnMount:l,onUserAnimationConsumed:c,onContentChange:u,animationHandlers:f,scrollToBottom:h})=>i.jsx(gN,{message:e,previousMessage:t,nextMessage:n,animateUserOnMount:l,onUserAnimationConsumed:c,onContentChange:u,animationHandlers:f,scrollToBottom:h,turnGroupingContext:s,assistantHeaderMessageId:o,isInActiveTurn:r,activeStreamingPhase:a}),(e,t)=>{const n=e.turnGroupingContext,s=t.turnGroupingContext;return Qh(e.message,t.message)&&Ai(e.previousMessage,t.previousMessage)&&Ai(e.nextMessage,t.nextMessage)&&e.animateUserOnMount===t.animateUserOnMount&&e.onUserAnimationConsumed===t.onUserAnimationConsumed&&e.onContentChange===t.onContentChange&&e.scrollToBottom===t.scrollToBottom&&tm(n,s,e.message.info.id,F0(e.message)==="user")&&e.assistantHeaderMessageId===t.assistantHeaderMessageId&&e.isInActiveTurn===t.isInActiveTurn&&e.activeStreamingPhase===t.activeStreamingPhase&&e.animationHandlers?.onChunk===t.animationHandlers?.onChunk&&e.animationHandlers?.onComplete===t.animationHandlers?.onComplete&&e.animationHandlers?.onStreamingCandidate===t.animationHandlers?.onStreamingCandidate&&e.animationHandlers?.onAnimationStart===t.animationHandlers?.onAnimationStart&&e.animationHandlers?.onReservationCancelled===t.animationHandlers?.onReservationCancelled&&e.animationHandlers?.onReasoningBlock===t.animationHandlers?.onReasoningBlock&&e.animationHandlers?.onAnimatedHeightChange===t.animationHandlers?.onAnimatedHeightChange});L5.displayName="MessageRow";const op=d.memo(({turn:e,isLastTurn:t,nextEntryFirstMessage:n,onMessageContentChange:s,getAnimationHandlers:o,scrollToBottom:r,stickyUserHeader:a=!0,shouldAnimateUserMessage:l,onUserAnimationConsumed:c,activeStreamingMessageId:u,activeStreamingPhase:f})=>{const h=d.useMemo(()=>Ii(e.userMessage),[e.userMessage]),m=d.useMemo(()=>{const w=[e.userMessage,...e.assistantMessages],_=new Map;return w.forEach((L,A)=>{_.set(L.info.id,A)}),{ordered:w,lookup:_}},[e.assistantMessages,e.userMessage]),p=d.useMemo(()=>rP({activeStreamingMessageId:u,assistantMessages:e.assistantMessages}),[u,e.assistantMessages]),g=e.assistantMessages,y=d.useMemo(()=>{const w=new Map;return g.forEach((_,L)=>{w.set(_.info.id,L)}),w},[g]),M=d.useMemo(()=>UP(e,p),[e,p]),b=d.useMemo(()=>M&&p?p:g[0]?.info.id,[p,M,g]),v=e.activityParts,x=e.activitySegments,S=d.useMemo(()=>{const w=e.userMessage.info.time?.created,_=e.userMessage.info,L=_?.model?.variant??_?.variant,A=typeof L=="string"&&L.trim().length>0?L:void 0;return{turnId:e.turnId,summaryBody:e.summaryText,activityParts:v,activityGroupSegments:x,headerMessageId:e.headerMessageId,hasTools:e.hasTools,hasReasoning:e.hasReasoning,diffStats:e.diffStats,changedFiles:e.changedFiles,userMessageCreatedAt:typeof w=="number"?w:void 0,userMessageVariant:A}},[e.changedFiles,e.diffStats,e.hasReasoning,e.hasTools,e.headerMessageId,e.summaryText,e.turnId,e.userMessage.info,v,x]),C=d.useCallback(w=>{const L=F0(w)==="user",A=m.lookup.get(w.info.id),N=y.get(w.info.id)??-1,k=N>=0,V=N===0,H=N===g.length-1,P=!!b&&w.info.id===b||V||H,R=g[0]?.info.id??e.headerMessageId,$=L?void 0:k?V?e.userMessage:void 0:typeof A=="number"&&A>0?m.ordered[A-1]:void 0,O=k&&H?n:void 0,I=k?{turnId:e.turnId,activityOwnerMessageId:b,isFirstAssistantInTurn:V,isLastAssistantInTurn:H,isLatestTurn:t,isWorking:iP({messageId:w.info.id,activeStreamingMessageId:u,isRetrying:PP(w)}),hasTools:e.hasTools,hasReasoning:e.hasReasoning,...P?{summaryBody:S.summaryBody,activityParts:S.activityParts,activityGroupSegments:S.activityGroupSegments,headerMessageId:S.headerMessageId,diffStats:S.diffStats,changedFiles:S.changedFiles,userMessageCreatedAt:S.userMessageCreatedAt,userMessageVariant:S.userMessageVariant}:{}}:void 0;return i.jsx(L5,{message:w,previousMessage:$,nextMessage:O,turnGroupingContext:I,assistantHeaderMessageId:R,isInActiveTurn:!!p&&w.info.id===p,activeStreamingPhase:w.info.id===p?f:null,animateUserOnMount:l(w),onUserAnimationConsumed:c,onContentChange:s,animationHandlers:o(w.info.id),scrollToBottom:r},w.info.id)},[o,t,n,m.lookup,m.ordered,s,r,e.headerMessageId,e.hasReasoning,e.hasTools,e.turnId,e.userMessage,S,p,u,f,g,y,b,l,c]);return i.jsx(MN,{turn:e,stickyUserHeader:a&&!h,renderMessage:C})});op.displayName="TurnBlock";const rp=d.memo(({message:e,previousMessage:t,nextMessage:n,onMessageContentChange:s,getAnimationHandlers:o,scrollToBottom:r,shouldAnimateUserMessage:a,onUserAnimationConsumed:l,activeStreamingMessageId:c,activeStreamingPhase:u})=>i.jsx(L5,{message:e,previousMessage:t,nextMessage:n,animateUserOnMount:a(e),onUserAnimationConsumed:l,onContentChange:s,animationHandlers:o(e.info.id),scrollToBottom:r,isInActiveTurn:!!c&&e.info.id===c,activeStreamingPhase:e.info.id===c?u:null}));rp.displayName="UngroupedMessageRow";const UP=(e,t)=>t?e.userMessage.info.id===t?!0:e.assistantMessages.some(n=>n.info.id===t):!1,j5=d.memo(({entry:e,onMessageContentChange:t,getAnimationHandlers:n,scrollToBottom:s,stickyUserHeader:o,sessionIsWorking:r,shouldAnimateUserMessage:a,onUserAnimationConsumed:l,activeStreamingMessageId:c,activeStreamingPhase:u,onLoadOlderHistory:f,onLoadAllHistory:h})=>(E0("ui.message_list_entry.render"),e.kind==="ungrouped"?i.jsx(rp,{message:e.message,previousMessage:e.previousMessage,nextMessage:e.nextMessage,onMessageContentChange:t,getAnimationHandlers:n,scrollToBottom:s,shouldAnimateUserMessage:a,onUserAnimationConsumed:l,activeStreamingMessageId:c,activeStreamingPhase:u}):e.kind==="history-gate"?i.jsx(LN,{foldedCount:e.turns.length,onLoadOlder:()=>f?.(e.turns.length),onLoadAll:()=>h?.(e.turns.length)}):i.jsx(op,{turn:e.turn,isLastTurn:e.isLastTurn,nextEntryFirstMessage:e.nextEntryFirstMessage,sessionIsWorking:r,shouldAnimateUserMessage:a,onUserAnimationConsumed:l,activeStreamingMessageId:c,activeStreamingPhase:u,onMessageContentChange:t,getAnimationHandlers:n,scrollToBottom:s,stickyUserHeader:o})));j5.displayName="MessageListEntry";const ip=d.memo(({entries:e,engine:t,contentRef:n,scrollRef:s,registerTanstackVirtualizer:o,virtualizerKey:r,onMessageContentChange:a,getAnimationHandlers:l,scrollToBottom:c,stickyUserHeader:u,shouldAnimateUserMessage:f,onUserAnimationConsumed:h,onLoadOlderHistory:m,onLoadAllHistory:p})=>{const g=t==="tanstack",y=d.useRef(!1),M=d.useRef(0),b=d.useRef(null),v=g&&D2();d.useEffect(()=>{if(!v)return;const O=s?.current;if(!O)return;const I=()=>{y.current=!0},q=()=>{y.current=!1},G=()=>{M.current=performance.now()};return O.addEventListener("touchstart",I,{passive:!0}),O.addEventListener("touchend",q,{passive:!0}),O.addEventListener("touchcancel",q,{passive:!0}),O.addEventListener("scroll",G,{passive:!0}),()=>{O.removeEventListener("touchstart",I),O.removeEventListener("touchend",q),O.removeEventListener("touchcancel",q),O.removeEventListener("scroll",G)}},[v,s]);const x=d.useCallback(()=>y.current||performance.now()-M.current<HP,[]),S=d.useCallback(()=>{const O=s?.current;return O?O.scrollTop<O.clientHeight*LP:!0},[s]),[C,w]=d.useState(e);let _=C;e!==C?v&&IP(C,e)&&x()&&!S()&&(b.current===null||performance.now()-b.current<Vd)?b.current===null&&(b.current=performance.now()):(b.current=null,w(e),_=e):b.current!==null&&(b.current=null);const[,L]=d.useReducer(O=>O+1,0);d.useEffect(()=>{if(!v)return;const O=window.setInterval(()=>{if(b.current===null)return;const I=performance.now()-b.current>=Vd;(!x()||S()||I)&&L()},jP);return()=>window.clearInterval(O)},[v,x,S]);const A=d.useRef(_);A.current=_;const[N]=d.useState(()=>g?VP(r,e.map(O=>O.key)):void 0),k=d.useRef(null),V=d.useRef(vP),[H,D]=d.useState(null);d.useLayoutEffect(()=>{if(!g){D(K=>K===null?K:null);return}let O,I=0;const q=()=>{const K=s?.current??null;return Td(K)?(D(W=>W===K?W:K),!0):!1};if(q())return;const G=s?.current;return G?(O=new ResizeObserver(()=>{q()&&O?.disconnect()}),O.observe(G)):typeof window<"u"&&(I=window.requestAnimationFrame(()=>{if(q())return;const K=s?.current;K&&(O=new ResizeObserver(()=>{q()&&O?.disconnect()}),O.observe(K))})),()=>{I&&window.cancelAnimationFrame(I),O?.disconnect()}},[g,s,r]);const P=g&&Td(H),R=V9({count:_.length,enabled:P,getScrollElement:()=>H,estimateSize:O=>A.current[O]?.kind==="history-gate"?CN:V.current,overscan:wP(),scrollToFn:(O,I,q)=>{const G=k.current;G&&(G.style.height=`${q.getTotalSize()}px`),pv(O,I,q)},getItemKey:O=>A.current[O]?.key??`index:${O}`,anchorTo:"end",initialOffset:()=>Number.MAX_SAFE_INTEGER,initialMeasurementsCache:N});R.shouldAdjustScrollPositionOnItemSizeChange=(O,I,q)=>{if(q.isAtEnd(AP))return!1;const G=q.range?.startIndex;return G!==void 0&&O.index<G},d.useEffect(()=>{if(!g)return;const O=R.itemSizeCache;if(O.size>=SP){let I=0;for(const q of O.values())I+=q;V.current=Math.min(kP,Math.max(_P,Math.round(I/O.size)))}}),d.useEffect(()=>{if(P)return o?.(R),()=>{NP(r,A.current.map(O=>O.key),R),o?.(null)}},[P,o,R,r]);const $=d.useCallback(O=>i.jsx(j5,{entry:O,onMessageContentChange:a,getAnimationHandlers:l,scrollToBottom:c,stickyUserHeader:u,sessionIsWorking:!1,shouldAnimateUserMessage:f,onUserAnimationConsumed:h,activeStreamingMessageId:null,activeStreamingPhase:null,onLoadOlderHistory:m,onLoadAllHistory:p},O.key),[l,p,m,a,h,c,f,u]);if(t==="none"||t==="tanstack"&&!P)return i.jsx("div",{ref:n,className:"relative w-full",children:_.map(O=>i.jsx("div",{"data-turn-entry":O.key,children:$(O)},O.key))});if(t==="tanstack"){const O=R.getVirtualItems(),I=O[0]?.start??0;return i.jsx("div",{ref:k,className:"relative w-full",style:{height:R.getTotalSize()},children:i.jsx("div",{style:{paddingTop:`${I}px`},children:O.map(q=>{const G=_[q.index];return G?i.jsx("div",{"data-index":q.index,ref:R.measureElement,"data-turn-entry":G.key,children:$(G)},G.key):null})})})}return null});ip.displayName="StaticHistoryList";const ap=({entry:e,sessionId:t,directory:n,onMessageContentChange:s,getAnimationHandlers:o,scrollToBottom:r,stickyUserHeader:a,sessionIsWorking:l,showTurnChangedFiles:c,shouldAnimateUserMessage:u,onUserAnimationConsumed:f,activeStreamingMessageId:h,activeStreamingPhase:m})=>{const p=Ew(t,h??"",n),g=d.useMemo(()=>dP(e,{activeStreamingMessageId:h,liveParts:p,showTextJustificationActivity:!1,showTurnChangedFiles:c,mergeHiddenUserTurns:!0}),[h,e,p,c]);return i.jsx(j5,{entry:g,onMessageContentChange:s,getAnimationHandlers:o,scrollToBottom:r,stickyUserHeader:a,sessionIsWorking:l,shouldAnimateUserMessage:u,onUserAnimationConsumed:f,activeStreamingMessageId:h,activeStreamingPhase:m})};ap.displayName="StreamingTailContent";const lp=d.forwardRef(({sessionKey:e,messages:t,sessionIsWorking:n=!1,activeStreamingMessageId:s=null,activeStreamingPhase:o=null,retryOverlay:r=null,onMessageContentChange:a,getAnimationHandlers:l,scrollToBottom:c,scrollRef:u,directory:f},h)=>{Wg("react.message_list_render"),E0("ui.message_list.render");const m=he(X=>X.stickyUserHeader),p=he(X=>X.showTurnChangedFiles),[g,y]=d.useState(()=>Nd(e)),M=d.useRef(null),b=d.useRef(null),v=d.useCallback(()=>{const X=u?.current;if(!X)return null;const me=X.getBoundingClientRect(),U=Array.from(X.querySelectorAll("[data-message-id]")).find(T=>T.getBoundingClientRect().bottom>me.top+1&&!Pd(T,X,me.top));return{top:X.scrollTop,height:X.scrollHeight,anchor:U?.dataset.messageId?{messageId:U.dataset.messageId,offsetTop:U.getBoundingClientRect().top-me.top}:null}},[u]),x=d.useCallback(X=>{y(me=>{const U=typeof X=="function"?X(me):X;return TP(e,U),U})},[e]),S=d.useCallback(X=>{M.current=v(),x(me=>AN(me,X))},[v,x]),C=d.useCallback(X=>{M.current=v(),x(me=>me+X)},[v,x]),w=d.useCallback((X,me,U)=>{const T=me.findIndex(Q=>Q.turnId===X);T<0||(b.current=X,x(Q=>Math.max(Q,kN(T,U))))},[x]);d.useLayoutEffect(()=>{y(Nd(e)),b.current=null},[e]);const _=d.useRef({sessionKey:void 0,previousOrder:[],animatedIds:new Set}),L=yr(l),A=yr(()=>{c?.()}),N=d.useMemo(()=>Mr("ui.message_list.base_display_ms",()=>{const X=new Set,me=new Map,U=[];for(const se of t){const ye=se.info?.id;typeof ye=="string"&&me.set(ye,se)}for(let se=0;se<t.length;se+=1){const ye=t[se],le=ye.info?.id;if(typeof le=="string"){if(X.has(le))continue;X.add(le)}U.push(ep(typeof le=="string"?me.get(le)??ye:ye))}const T=[],Q=new Set;for(let se=0;se<U.length;se+=1){const ye=U[se],le=zP(ye,Q);(Qm(ye)||ye.parts.some(Ce=>Ce.type==="text"&&EP(Ce).trim()==="/compact"))&&Q.add(ye.info.id);const ne=T.length>0?T[T.length-1]:void 0;if(DP(ne)){const Ce=FP(le);if(Ce.hide){T[T.length-1]=$P(ne,Ce.taskSessionId);continue}}if(np(ne)){const Ce=sp(le,RP(ne));if(Ce.hide){T[T.length-1]=qP(ne,Ce.details);continue}}T.push(le)}return T}),[t]),k=d.useRef(null),V=d.useCallback(()=>u?.current?u.current:typeof document>"u"?null:document.querySelector('[data-scrollbar="chat"]'),[u]),H=d.useMemo(()=>Mr("ui.message_list.retry_overlay_ms",()=>sP(N,{sessionId:r?.sessionId??null,message:r?.message??"Quota limit reached. Retrying automatically.",confirmedAt:r?.confirmedAt,fallbackTimestamp:r?.fallbackTimestamp??0})),[N,r]),{projection:D,staticTurns:P,streamingTurn:R}=nP(H,{sessionKey:e,showTextJustificationActivity:!1,showTurnChangedFiles:p}),$=D.ungroupedMessageIds.size>0,O=$?H:mP,I=$?D.ungroupedMessageIds:pP,q=d.useMemo(()=>Mr("ui.message_list.render_entries_ms",()=>{const X=P.map(T=>({kind:"turn",key:`turn:${T.turnId}`,turn:T,isLastTurn:T.turnId===D.lastTurnId}));if(I.size===0)return X;const me=new Map;X.forEach(T=>{me.set(T.turn.userMessage.info.id,T)});const U=[];return O.forEach((T,Q)=>{const se=me.get(T.info.id);if(se){U.push(se);return}I.has(T.info.id)&&U.push({kind:"ungrouped",key:`msg:${T.info.id}`,message:T,previousMessage:Q>0?O[Q-1]:void 0,nextMessage:Q<O.length-1?O[Q+1]:void 0})}),U}),[D.lastTurnId,O,I,P]),G=d.useMemo(()=>{if(R)return{kind:"turn",key:`turn:${R.turnId}`,turn:R,isLastTurn:R.turnId===D.lastTurnId};if(D.ungroupedMessageIds.size===0)return;const X=H[H.length-1];if(!(!X||!D.ungroupedMessageIds.has(X.info.id)))return{kind:"ungrouped",key:`msg:${X.info.id}`,message:X,previousMessage:H.length>1?H[H.length-2]:void 0,nextMessage:void 0}},[H,D.lastTurnId,D.ungroupedMessageIds,R]);G&&E0("ui.message_list.render.streaming");const K=G?G.kind==="turn"?G.turn.userMessage:G.message:void 0,W=d.useMemo(()=>{const X=q.map((se,ye)=>{if(se.kind!=="turn")return se;const le=ye<q.length-1?(()=>{const ne=q[ye+1];return ne&&ne.kind==="turn"?ne.turn.userMessage:ne?.kind==="ungrouped"?ne.message:void 0})():K;return le?{...se,nextEntryFirstMessage:le}:se});let me=0;for(const se of X)se.kind==="turn"&&(me+=1);let U=-1;const T=[],Q=[];for(const se of X){if(se.kind!=="turn"){Q.push(se);continue}if(U+=1,_N(U,me,g)){T.push(se.turn);continue}Q.push(se)}return T.length===0?Q:[{kind:"history-gate",key:"history-gate",turns:T},...Q]},[g,q,K]);d.useLayoutEffect(()=>{const X=M.current;if(X){M.current=null;const Q=u?.current;if(Q){const se=X.anchor?.messageId?Q.querySelector(`[data-message-id="${X.anchor.messageId}"]`):null;if(se&&X.anchor){const ye=Q.getBoundingClientRect(),le=se.getBoundingClientRect().top-ye.top-X.anchor.offsetTop;le!==0&&(Q.scrollTop+=le)}else{const ye=Q.scrollHeight-X.height;ye>0?Q.scrollTop=X.top+ye:Q.scrollTop=X.top}}}const me=b.current;if(!me)return;b.current=null,V()?.querySelector(`[data-turn-id="${me}"]`)?.scrollIntoView({block:"start"})},[W,V,u]);const ge=D2()||W.length>=hP,Z=ge?"tanstack":"none",fe=d.useRef(null),ie=d.useCallback(X=>{fe.current=X},[]),E=d.useMemo(()=>G?[...W,G]:W,[W,G]),ce=yr(X=>{a(X)}),ee=yr(X=>{a(X)}),ue=d.useMemo(()=>t.filter(X=>F0(X)==="user").map(X=>X.info.id),[t]);{const X=_.current;X.sessionKey!==e&&(X.sessionKey=e,X.previousOrder=ue,X.animatedIds=new Set);const me=X.previousOrder;if(ue.length>me.length&&me.every((T,Q)=>ue[Q]===T)&&cw(e))for(let T=me.length;T<ue.length;T+=1){const Q=ue[T];if(Q&&!X.animatedIds.has(Q)){if(!dw(e))break;X.animatedIds.add(Q)}}X.previousOrder=ue}const J=d.useCallback(X=>F0(X)!=="user"?!1:_.current.animatedIds.has(X.info.id),[]),Y=d.useCallback(X=>{_.current.animatedIds.delete(X)},[]),oe=d.useMemo(()=>{const X=new Map;return E.forEach((me,U)=>{if(me.kind==="ungrouped"){X.set(me.message.info.id,U);return}if(me.kind==="history-gate"){me.turns.forEach(T=>{X.set(T.userMessage.info.id,U),T.assistantMessages.forEach(Q=>{X.set(Q.info.id,U)})});return}X.set(me.turn.userMessage.info.id,U),me.turn.assistantMessages.forEach(T=>{X.set(T.info.id,U)})}),X},[E]),te=d.useMemo(()=>{const X=new Map;return E.forEach((me,U)=>{me.kind==="turn"&&X.set(me.turn.turnId,U),me.kind==="history-gate"&&me.turns.forEach(T=>{X.set(T.turnId,U)})}),X},[E]),pe=d.useCallback(X=>{const me=V();return me?me.querySelector(`[data-message-id="${X}"]`):null},[V]),He=d.useCallback(X=>{if(X<0||X>=W.length||!ge)return!1;const me=fe.current;return me?(me.scrollToIndex(X,{align:"start",behavior:"auto"}),!0):!1},[W.length,ge]),je=d.useCallback((X,me="auto")=>{const U=V();if(!U)return!1;const T=pe(X);if(!T)return!1;const Q=U.getBoundingClientRect(),le=T.getBoundingClientRect().top-Q.top+U.scrollTop-50;return U.scrollTo({top:le,behavior:me}),!0},[pe,V]);return d.useEffect(()=>{if(!h)return;const X={scrollToTurnId:(U,T)=>{const Q=W.find(Se=>Se.kind==="history-gate");if(Q?.kind==="history-gate"){const Se=W.reduce((Ae,Ve)=>Ve.kind==="turn"?Ae+1:Ae,0);w(U,Q.turns,Q.turns.length+Se)}const se=T?.behavior??"auto",ye=te.get(U);if(ye===void 0)return!1;const le=V();if(!le)return!1;const ne=le.querySelector(`[data-turn-id="${U}"]`);return ne?(ne.scrollIntoView({behavior:se,block:"start"}),!0):G!==void 0&&ye>=W.length?!1:He(ye)},scrollToMessageId:(U,T)=>{const Q=T?.behavior??"auto",se=oe.get(U);if(se===void 0)return!1;const ye=E[se];if(ye?.kind==="history-gate"){const le=ye.turns.find(ne=>ne.userMessage.info.id===U||ne.assistantMessages.some(Ce=>Ce.info.id===U));if(le){const ne=W.reduce((Ce,Se)=>Se.kind==="turn"?Ce+1:Ce,0);w(le.turnId,ye.turns,ye.turns.length+ne)}}return je(U,Q)||(G!==void 0&&se>=W.length?!1:He(se))},holdViewportAnchor:U=>{const T=V();if(!T||typeof window>"u")return;let Q=0,se=0,ye=!1;const le=()=>{ye=!0,T.removeEventListener("touchstart",le),T.removeEventListener("wheel",le)};T.addEventListener("touchstart",le,{passive:!0}),T.addEventListener("wheel",le,{passive:!0});const ne=()=>{if(ye)return;const Ce=pe(U.messageId);if(Ce){const Se=Ce.getBoundingClientRect().top-T.getBoundingClientRect().top-U.offsetTop;Math.abs(Se)>.5?(T.scrollTop+=Se,se=0):se+=1}if(Q+=1,se>=MP||Q>=CP){T.removeEventListener("touchstart",le),T.removeEventListener("wheel",le);return}window.requestAnimationFrame(ne)};window.requestAnimationFrame(ne)},isHistoryVirtualized:()=>ge,captureViewportAnchor:()=>{const U=V();if(!U)return null;const T=U.getBoundingClientRect(),Q=Array.from(U.querySelectorAll("[data-message-id]")),se=Q.find(le=>le.getBoundingClientRect().bottom<=T.top+1?!1:typeof window>"u"?!0:!Pd(le,U,T.top))??Q.find(le=>le.getBoundingClientRect().bottom>T.top+1);if(!se)return null;const ye=se.dataset.messageId;return ye?{messageId:ye,offsetTop:se.getBoundingClientRect().top-T.top}:null},restoreViewportAnchor:U=>{const T=V();if(!T||!oe.has(U.messageId))return!1;const Q=()=>{const se=pe(U.messageId);if(!se)return!1;const ye=T.getBoundingClientRect(),ne=se.getBoundingClientRect().top-ye.top-U.offsetTop;return ne!==0&&(T.scrollTop+=ne),!0};if(!Q()){const se=oe.get(U.messageId);if(typeof se=="number"&&se<W.length)return He(se)}return Q()},scrollToBottom:()=>{if(ge&&W.length>0&&fe.current){fe.current.scrollToEnd();return}const U=V();U&&(U.scrollTop=U.scrollHeight+4096)}};if(typeof h=="function")return h(X),()=>{h(null)};const me=h;return me.current=X,()=>{me.current=null}},[E,pe,W,oe,V,w,He,je,ge,G,te,h]),i.jsx("div",{children:i.jsx(sd,{disabled:!1,children:i.jsxs("div",{className:"relative w-full",children:[i.jsx(sd,{disabled:ge,children:i.jsx(ip,{entries:W,engine:Z,contentRef:k,scrollRef:u,registerTanstackVirtualizer:ie,virtualizerKey:e,onMessageContentChange:ce,getAnimationHandlers:L,scrollToBottom:A,stickyUserHeader:m,shouldAnimateUserMessage:J,onUserAnimationConsumed:Y,onLoadOlderHistory:S,onLoadAllHistory:C},e)}),G?i.jsx(ap,{entry:G,sessionId:e??null,directory:f,onMessageContentChange:ee,getAnimationHandlers:L,scrollToBottom:A,stickyUserHeader:m,sessionIsWorking:n,showTurnChangedFiles:p,shouldAnimateUserMessage:J,onUserAnimationConsumed:Y,activeStreamingMessageId:s,activeStreamingPhase:o}):null]})})})});lp.displayName="MessageList";const GP=d.memo(lp),WP={activity:"idle",hasWorkingContext:!1,hasActiveTools:!1,isWorking:!1,isStreaming:!1,isCooldown:!1,lifecyclePhase:null,statusText:null,isGenericStatus:!0,isWaitingForPermission:!1,canAbort:!1,compactionDeadline:null,activePartType:void 0,activeToolName:void 0,wasAborted:!1,abortActive:!1,lastCompletionId:null,isComplete:!1,retryInfo:null},Ed=[],cp="\0",KP=new Set(["edit","write","multiedit","apply_patch"]),YP={read:"reading file",write:"writing file",edit:"editing file",multiedit:"editing files",apply_patch:"applying patch",bash:"running command",grep:"searching content",glob:"finding files",list:"listing directory",task:"delegating task",webfetch:"fetching URL",websearch:"searching web",codesearch:"web code search",todowrite:"updating todos",todoread:"reading todos",skill:"learning skill",question:"asking question",plan_enter:"switching to planning",plan_exit:"switching to building"},zd=["working","processing","preparing","warming up","gears turning","computing","calculating","analyzing","wheels spinning","calibrating","synthesizing","connecting dots","inspecting logic","weighing options"],Dd=e=>YP[e]??`using ${e}`,JP=e=>{let t=0;for(let n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)},XP=e=>zd[JP(e)%zd.length]??"working",QP=(e,t)=>{let n,s;if(!A3(e))for(let a=e.length-1;a>=0;a-=1){const l=e[a];if(l)switch(l.type){case"reasoning":{const c=l.time??Rd(l);(!c||typeof c.end>"u")&&!n&&(n="reasoning");break}case"tool":{const c=l.state?.status;if((c==="running"||c==="pending")&&!n){const u=oE(l);KP.has(u)?(n="editing",s=u):(n="tool",s=u)}break}case"text":{const c=sE(l)??"";if(typeof c=="string"&&c.trim().length>0){const u=Rd(l);(!u||typeof u.end>"u")&&!n&&(n="text")}break}}}const o=n===void 0,r=n==="editing"?s==="multiedit"?Dd(s):"editing file":n==="tool"&&s?Dd(s):n==="reasoning"?"thinking":n==="text"?"composing":XP(t);return{activePartType:n,activeToolName:s,statusText:r,isGenericStatus:o}},eE=e=>[e.activePartType??"",e.activeToolName??"",e.statusText,e.isGenericStatus?"1":"0"].join(cp),tE=e=>{const[t,n,s="working",o]=e.split(cp);return{activePartType:t==="text"||t==="tool"||t==="reasoning"||t==="editing"?t:void 0,activeToolName:n||void 0,statusText:s,isGenericStatus:o==="1"}},nE=e=>e.type==="reasoning",dp=e=>e.type==="text",sE=e=>{if(dp(e))return e.text;const t=e;if(typeof t.text=="string")return t.text;if(typeof t.content=="string")return t.content;if(typeof t.value=="string")return t.value},Rd=e=>(dp(e)||nE(e),e.time),oE=e=>{if(e.tool)return e.tool;const t=e;return typeof t.name=="string"?t.name:"tool"},rE=e=>{let t=null,n=null;for(let s=e.length-1;s>=0;s-=1){const o=e[s];if(o?.role!=="assistant")continue;const r=o;t=o.id,n=typeof r.parentID=="string"&&r.parentID.trim().length>0?r.parentID:null;break}if(!t||!n)return{assistantId:t,model:null};for(let s=e.length-1;s>=0;s-=1){const o=e[s];if(o?.role!=="user"||o.id!==n)continue;const r=o,a=typeof r.model?.providerID=="string"?r.model.providerID.trim():"",l=typeof r.model?.modelID=="string"?r.model.modelID.trim():"";return{assistantId:t,model:a&&l?{providerId:a,modelId:l}:null}}return{assistantId:t,model:null}};function iE(){const e=Be(v=>v.currentSessionId);Be(v=>v.currentSessionDirectory);const t=$i(e??""),n=d.useMemo(()=>rE(t),[t]),s=n.assistantId,o=ci(d.useCallback(v=>{const x=`${e??""}:${s??""}`,S=s?v.part[s]??Ed:Ed;return eE(QP(S,x))},[e,s])),r=Ru(),a=Ou(),l=Be(d.useCallback(v=>e?v.sessionAbortFlags?.get(e)??null:null,[e])),{phase:c,isWorking:u}=s5(),f=qi(e??""),h=f?.type==="retry"?f.attempt:void 0,m=f?.type==="retry"?f.next:void 0,p=d.useMemo(()=>tE(o),[o]),g=d.useMemo(()=>{const v=!!(l&&!l.acknowledged);return{wasAborted:v,abortActive:v}},[l]),y=d.useMemo(()=>{if(g.wasAborted)return{...WP,wasAborted:!0,abortActive:g.abortActive,activity:"idle",hasWorkingContext:!1,isWorking:!1,isStreaming:!1,isCooldown:!1,statusText:null,canAbort:!1,retryInfo:null};const v=u,x=c==="busy",S=!1,C=c==="retry";let w="idle";v&&(p.activePartType==="tool"||p.activePartType==="editing"?w="tooling":w="streaming");const _=C?{attempt:h,next:m}:null;return{activity:w,hasWorkingContext:v,hasActiveTools:p.activePartType==="tool"||p.activePartType==="editing",isWorking:v,isStreaming:x,isCooldown:S,lifecyclePhase:x?"streaming":null,statusText:v?p.statusText:null,isGenericStatus:v?p.isGenericStatus:!0,isWaitingForPermission:!1,canAbort:v,compactionDeadline:null,activePartType:v?p.activePartType:void 0,activeToolName:v?p.activeToolName:void 0,wasAborted:!1,abortActive:!1,lastCompletionId:null,isComplete:!1,retryInfo:_}},[c,u,p,g,h,m]),M=d.useMemo(()=>({isActive:u&&p.activePartType==="text",characterCount:0}),[u,p.activePartType]),b=d.useMemo(()=>{if(y.wasAborted||y.abortActive)return y;const v=r.length>0,x=a.length>0;return!v&&!x?y:x?{...y,statusText:null,isWorking:!1,hasWorkingContext:!1,hasActiveTools:!1,canAbort:!1,activePartType:void 0,activeToolName:void 0,retryInfo:null}:{...y,statusText:"waiting for permission",isWaitingForPermission:!0,canAbort:!1,retryInfo:null}},[y,r,a]);return{activeModel:n.model,forming:M,working:b}}const up=d.memo(()=>{const e=Be(c=>c.currentSessionId),t=Be(d.useCallback(c=>e?c.sessionAbortFlags?.get(e)??null:null,[e])),{activeModel:n,working:s}=iE(),o=$e(c=>c.currentAgentName),r=$e(c=>c.providers),a=d.useMemo(()=>{if(!n)return null;const c=r.length>0?r.find(u=>u.id===n.providerId):void 0;return ru(c,n.modelId)||null},[n,r]),l=!!(t&&!t.acknowledged);return i.jsx(Rf,{isWorking:s.isWorking,statusText:s.statusText,isGenericStatus:s.isGenericStatus,isWaitingForPermission:s.isWaitingForPermission,wasAborted:l||s.wasAborted,abortActive:l||s.abortActive,retryInfo:s.retryInfo,showAssistantStatus:!0,showTodos:!1,agentName:o,modelName:a,providerId:n?.providerId??null})});up.displayName="StatusRowContainer";const aE=({visible:e,onClick:t})=>i.jsx("div",{className:B("absolute bottom-full left-1/2 -translate-x-1/2 mb-2 transition-all duration-150",e?"opacity-100 translate-y-0 scale-100 pointer-events-auto":"opacity-0 translate-y-2 scale-95 pointer-events-none"),children:i.jsx(a1,{variant:"outline",size:"sm",onClick:t,className:"size-8 rounded-full [corner-shape:round] p-0 shadow-none bg-background/95 hover:bg-interactive-hover","aria-label":"Scroll to bottom",children:i.jsx(z,{name:"arrow-down",className:"h-4 w-4"})})}),lE=d.memo(aE);function Q4(e){return e.filter(t=>t.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
7033
7033
  `)}function fp(e,t=80){const s=Q4(e).replace(/\n/g," ");return s.length>t?`${s.slice(0,t)}…`:s}const cE=160,Nl=28,dE=12,ws=6,uE=8,Ms=30,Cs=12,Od=18,fE=80,vr=4,hE=10,mE=14,pE=20,E2=54,Zd=4,gE=8,Fd=2,yE=160,vE=(e,t)=>e.map(n=>{const s=t.get(n)??[];return{turnId:n,preview:fp(s,cE)}}),bE=[1,.6,.35,.15],xE=(e,t,n)=>{const s=n?mE:hE;if(t===null)return s;const o=Math.abs(e-t),r=bE[o]??0;return Math.round(s+(pE-s)*r)};function wE({turnIds:e,previewsByTurnId:t,activeTurnId:n,onSelectTurn:s,canLoadEarlier:o,isLoadingOlder:r,onLoadEarlier:a}){const l=he(de=>de.isPromptNavigatorPanelOpen),c=he(de=>de.setPromptNavigatorPanelOpen),u=d.useRef(null),f=d.useRef(null),[h,m]=d.useState(null),[p,g]=d.useState(0),[y,M]=d.useState(!1),[b,v]=d.useState(ws);d.useEffect(()=>{const de=f.current?.parentElement;if(!de||typeof ResizeObserver>"u")return;const Le=()=>{const Te=de.querySelector(".chat-message-column");if(!Te){M(!1),v(ws);return}const Qe=de.getBoundingClientRect(),M1=Te.getBoundingClientRect(),C1=Qe.right-M1.right-uE-Nl;if(C1<=ws){v(ws);const _1=Qe.right-ws-Nl;M(M1.right>_1);return}v(C1),M(!1)};Le();const xe=new ResizeObserver(Le);xe.observe(de);const ve=de.querySelector(".chat-message-column");return ve&&xe.observe(ve),()=>xe.disconnect()},[e.length]);const x=d.useMemo(()=>vE(e,t),[t,e]),S=Math.min(x.length,Ms),C=Math.max(0,x.length-S),w=Math.min(p,C),_=w+S,L=w>0,A=_<x.length,N="[No text content]",k="Current prompt",V="Load more prompts",H=d.useMemo(()=>n?x.findIndex(de=>de.turnId===n):-1,[n,x]),D=d.useRef(w);D.current=w;const P=d.useRef(x.length);P.current=x.length;const R=d.useRef(null),$=d.useRef(null),O=d.useRef(0),I=d.useCallback(de=>{g(Le=>{const xe=P.current,ve=Math.min(xe,Ms),Te=Math.max(0,xe-ve),Qe=Math.min(Le,Te);return de<Qe?de:de>=Qe+ve?Math.min(Te,de-ve+1):Qe})},[]),q=d.useRef(x[0]?.turnId),G=d.useRef(x.length);d.useLayoutEffect(()=>{const de=q.current,Le=G.current,xe=x.length-Le;xe>0&&Le>0&&de&&x[0]?.turnId!==de&&(g(ve=>ve+xe),m(ve=>ve===null?null:ve+xe)),q.current=x[0]?.turnId,G.current=x.length},[x]),d.useEffect(()=>{if(h!==null)return;const de=H>=0?H:x.length-1;g(()=>{const Le=P.current,xe=Math.min(Le,Ms),ve=Math.max(0,Le-xe);return Math.max(0,Math.min(ve,de-Math.floor(xe/2)))})},[H,h,x.length]);const K=d.useCallback(de=>{const Le=u.current;if(!Le)return null;const xe=Le.getBoundingClientRect(),ve=Math.floor((de-xe.top)/Cs),Te=Math.min(P.current,Ms);return Te===0?null:Math.max(0,Math.min(Te-1,ve))},[]),W=d.useCallback(()=>{O.current=0,$.current!==null&&(window.clearInterval($.current),$.current=null)},[]),ge=d.useCallback(()=>{const de=O.current;if(de===0){W();return}const Le=P.current,xe=Math.min(Le,Ms),ve=Math.max(0,Le-xe),Te=Math.min(D.current,ve),Qe=Math.max(0,Math.min(ve,Te+de));if(Qe===Te){W();return}D.current=Qe,g(Qe);const M1=R.current;if(M1!==null){const C1=K(M1);C1!==null&&m(Math.min(Le-1,Qe+C1))}},[K,W]),Z=d.useCallback(de=>{const Le=u.current;if(!Le)return;const xe=Le.getBoundingClientRect(),ve=de-xe.top;let Te=0;if(ve<=Od&&L?Te=-1:ve>=xe.height-Od&&A&&(Te=1),O.current=Te,Te===0){W();return}$.current===null&&($.current=window.setInterval(ge,fE))},[ge,L,A,W]);d.useEffect(()=>()=>{$.current!==null&&window.clearInterval($.current)},[]);const fe=d.useRef(null),ie=d.useCallback(()=>{fe.current!==null&&(window.clearTimeout(fe.current),fe.current=null)},[]),E=d.useCallback(()=>{ie(),fe.current=window.setTimeout(()=>{fe.current=null,m(null)},yE)},[ie]);d.useEffect(()=>()=>{fe.current!==null&&window.clearTimeout(fe.current)},[]);const ce=d.useCallback(de=>{ie(),R.current=de.clientY;const Le=K(de.clientY);Le!==null&&m(Math.min(P.current-1,D.current+Le)),Z(de.clientY)},[ie,K,Z]),ee=d.useCallback(()=>{R.current=null,W(),E()},[E,W]),ue=d.useCallback(()=>{c(!1)},[c]),J=d.useCallback(de=>{if(de===null)return;const Le=x[de];Le&&(s(Le.turnId),W(),m(null),ue(),u.current?.blur())},[ue,s,x,W]),Y=d.useCallback(de=>{const Le=K(de.clientY);Le!==null&&J(Math.min(x.length-1,D.current+Le))},[J,x.length,K]);d.useEffect(()=>{if(!l)return;const de=u.current;!de||de===document.activeElement||(de.focus(),m(Le=>{if(Le!==null)return Le;const xe=H>=0?H:x.length-1;return I(xe),xe}))},[H,I,l,x.length]),d.useEffect(()=>()=>{c(!1)},[c]);const oe=d.useCallback(de=>{if(x.length===0)return;const Le=h??(H>=0?H:x.length-1),xe=ve=>{const Te=Math.max(0,Math.min(x.length-1,ve));I(Te),m(Te)};if(de.key==="ArrowUp"||de.key==="ArrowDown"){de.preventDefault(),xe(Le+(de.key==="ArrowUp"?-1:1));return}if(de.key==="Home"){de.preventDefault(),xe(0);return}if(de.key==="End"){de.preventDefault(),xe(x.length-1);return}if(de.key==="Enter"||de.key===" "){de.preventDefault(),J(Le);return}de.key==="Escape"&&(de.preventDefault(),m(null),ue(),u.current?.blur())},[H,ue,I,J,h,x]),te=d.useCallback(()=>{W(),m(null),ue()},[ue,W]),pe=d.useRef(null),He=d.useRef(h);He.current=h;const je=h!==null,Pe=d.useRef(0);d.useEffect(()=>{const de=pe.current;if(!de)return;const Le=xe=>{xe.preventDefault(),xe.stopPropagation(),Pe.current+=xe.deltaY;const ve=Math.trunc(Pe.current/E2);if(ve===0)return;Pe.current-=ve*E2;const Te=He.current;if(Te===null)return;const Qe=Math.max(0,Math.min(P.current-1,Te+ve));Qe!==Te&&(I(Qe),m(Qe))};return de.addEventListener("wheel",Le,{passive:!1}),()=>de.removeEventListener("wheel",Le)},[I,je]);const X=h!==null?x[h]:void 0,me=Math.min(x.length,gE),U=me*E2,T=x.length*E2-U,Q=de=>Math.max(0,Math.min(T,de)),se=d.useRef(null);let ye=0;if(h===null)se.current=null;else if(se.current===null)ye=Q(h*E2-(U-E2)/2),se.current=ye;else{let de=se.current;const Le=(h-Fd)*E2,xe=(h+1+Fd)*E2-U;de>Le?de=Le:de<xe&&(de=xe),ye=Q(de),se.current=ye}const le=Math.floor(ye/E2),ne=Math.max(0,le-vr),Ce=Math.min(x.length,le+me+vr),Se=ye>0,Ae=ye<T,Ve=Se||Ae?`linear-gradient(to bottom, ${Se?"transparent, black 10%":"black"}, ${Ae?"black 90%, transparent":"black"})`:void 0,Me=Math.max(0,w-vr),Ie=Math.min(x.length,_+vr),qe=x.slice(Me,Ie),n1=L||A?`linear-gradient(to bottom, ${L?"transparent, black 14%":"black"}, ${A?"black 86%, transparent":"black"})`:void 0;return x.length===0?null:i.jsx("nav",{ref:f,"aria-label":"Prompt navigation",className:"pointer-events-none absolute top-1/2 z-20 -translate-y-1/2",style:{right:`${b}px`},children:i.jsxs("div",{className:"pointer-events-auto flex flex-col items-end",children:[o?i.jsx("button",{type:"button",tabIndex:-1,className:B("-mr-px mb-1.5 flex size-5 shrink-0 items-center justify-center rounded-full","text-[var(--surface-mutedForeground)] transition-colors","hover:bg-[var(--interactive-hover)]/60 hover:text-[var(--surface-foreground)]",r?"cursor-wait opacity-70":void 0),"aria-label":V,title:V,disabled:r,onClick:de=>{de.stopPropagation(),r||a()},children:r?i.jsx(z,{name:"loader-4",className:"size-3.5 animate-spin"}):i.jsx(z,{name:"arrow-up-s",className:"size-3.5"})}):null,i.jsxs("div",{ref:u,role:"listbox",tabIndex:-1,"aria-activedescendant":X?`prompt-rail-tick-${X.turnId}`:void 0,className:"relative cursor-pointer outline-none",style:{width:`${y?dE:Nl}px`,height:`${S*Cs}px`},onMouseMove:ce,onMouseLeave:ee,onClick:Y,onKeyDown:oe,onBlur:te,children:[i.jsx("div",{className:"absolute inset-0 overflow-hidden",style:n1?{maskImage:n1,WebkitMaskImage:n1}:void 0,children:i.jsx("div",{className:"absolute inset-x-0 top-0 transition-transform duration-300 ease-out",style:{transform:`translateY(-${w*Cs}px)`},children:qe.map((de,Le)=>{const xe=Me+Le,ve=de.turnId===n,Te=h===xe,Qe=xE(xe,h,ve);return i.jsx("div",{id:`prompt-rail-tick-${de.turnId}`,role:"option","aria-selected":Te,"aria-current":ve?"true":void 0,"aria-label":de.preview.trim()||N,className:"pointer-events-none absolute right-1 flex items-center justify-end",style:{top:`${xe*Cs}px`,height:`${Cs}px`},children:i.jsx("span",{"aria-hidden":"true",className:B("block h-0.5 rounded-full transition-all duration-200 ease-out",ve?"bg-[var(--surface-foreground)]":Te?"bg-[var(--surface-foreground)]/80":"bg-[var(--surface-foreground)]/30"),style:{width:`${Qe}px`}})},de.turnId)})},x[0]?.turnId)}),X&&h!==null?i.jsx("div",{ref:pe,className:B("pointer-events-auto absolute right-full top-1/2 z-30 mr-3 -translate-y-1/2","w-[min(20rem,calc(100vw-6rem))] overflow-hidden rounded-xl","border border-[var(--interactive-border)]/60 bg-[var(--surface-elevated)] py-1 shadow-md"),onMouseEnter:ie,onMouseLeave:E,onMouseMove:de=>de.stopPropagation(),onClick:de=>de.stopPropagation(),children:i.jsx("div",{className:"relative overflow-hidden",style:{height:`${me*E2}px`,maskImage:Ve,WebkitMaskImage:Ve},children:i.jsx("div",{className:"absolute inset-x-0 top-0 transition-transform duration-200 ease-out",style:{height:`${x.length*E2}px`,transform:`translateY(-${ye}px)`},children:x.slice(ne,Ce).map((de,Le)=>{const xe=ne+Le,ve=de.turnId===n,Te=h===xe;return i.jsx("div",{role:"option","aria-selected":Te,"aria-current":ve?"true":void 0,title:ve?k:void 0,className:"absolute inset-x-0 cursor-pointer px-1.5",style:{top:`${xe*E2+Zd}px`,height:`${E2-Zd*2}px`},onMouseMove:()=>{ie(),He.current!==xe&&(I(xe),m(xe))},onClick:()=>J(xe),children:i.jsx("div",{className:B("flex h-full items-center rounded-lg border px-2 transition-colors",ve?"border-transparent bg-[var(--interactive-selection)]":Te?"border-[var(--interactive-border)]/60 bg-[var(--interactive-hover)]":"border-[var(--interactive-border)]/40"),children:i.jsx("span",{className:B("min-w-0 flex-1 line-clamp-2 [overflow-wrap:anywhere] typography-meta",ve?"text-[var(--interactive-selectionForeground)]":"text-[var(--surface-mutedForeground)]"),children:de.preview.trim()||N})})},de.turnId)})})})}):null]})]})})}const ME=100,CE=48,SE=.1,_E=e=>e.scrollHeight-e.scrollTop-e.clientHeight<=Math.max(CE,e.clientHeight*SE),kE=(e,t)=>{if(e.length===0)return;let n=0,s=e.length-1,o=0;for(;n<=s;){const r=n+s>>1,a=e[r]?.top;if(a===void 0)break;if(a<=t){o=r,n=r+1;continue}s=r-1}return e[o]?.id},AE=e=>{const t=e.raf??requestAnimationFrame,n=e.caf??cancelAnimationFrame,s=e.ResizeObserver??globalThis.ResizeObserver,o=e.MutationObserver??globalThis.MutationObserver;let r,a,l,c,u,f,h=!0;const m=new Map;let p=[];const g=()=>{c===void 0&&(c=t(()=>{c=void 0,M()}))},y=()=>{const L=r;if(!L){p=[],h=!1;return}const A=L.getBoundingClientRect().top;p=[...m].map(([N,k])=>({id:N,top:k.getBoundingClientRect().top-A+L.scrollTop})),p.sort((N,k)=>N.top-k.top),h=!1},M=()=>{const L=r;if(!L)return;h&&y();const A=_E(L)?p[p.length-1]?.id:kE(p,L.scrollTop+ME);!A||A===f||(f=A,e.onActive(A))},b=()=>{const L=r;if(L){if(clearTimeout(u),u=void 0,a?.disconnect(),a=void 0,s){a=new s(()=>{clearTimeout(u),u=setTimeout(()=>{h=!0,g()},100)}),a.observe(L);for(const A of m.values())a.observe(A)}if(l?.disconnect(),l=void 0,o){l=new o(()=>{h=!0,g()});const A={subtree:!0,childList:!0};s||(A.characterData=!0,A.characterDataOldValue=!1),l.observe(L,A)}h=!0,g()}},v=L=>{r!==L&&(r=L,f=void 0,b())},x=(L,A)=>{const N=m.get(A);N&&N!==L&&a?.unobserve(N),m.set(A,L),a&&a.observe(L),h=!0,g()},S=L=>{const A=m.get(L);A&&(a?.unobserve(A),m.delete(L),h=!0,g())},C=()=>{h=!0,g()},w=()=>{for(const L of m.values())a?.unobserve(L);m.clear(),p=[],f=void 0,h=!0};return{setContainer:v,register:x,unregister:S,onScroll:g,markDirty:C,clear:w,destroy:()=>{c!==void 0&&n(c),c=void 0,clearTimeout(u),u=void 0,w(),a?.disconnect(),l?.disconnect(),a=void 0,l=void 0,r=void 0},getActiveId:()=>f}},HE=.1,LE=40,jE=150,IE=2,$d=1500,qd=2,Ud=350,BE=300,TE=600,VE=8e3,Ss=()=>typeof performance<"u"?performance.now():Date.now(),NE=(e,t)=>{if(e)return LE;const n=t?.clientHeight??0;return n<=0?96:Math.max(48,n*HE)},hp=e=>e.scrollHeight-e.scrollTop-e.clientHeight,_s=e=>e.scrollHeight-e.clientHeight>1,Gd=(e,t)=>hp(e)<=NE(t,e),PE=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return!1;switch(e.key){case"ArrowUp":case"PageUp":case"Home":return!0;default:return!1}},EE=(e,t)=>{if(!(t instanceof Element))return null;const n=t.closest("[data-scrollable]");return!n||n===e||!(n instanceof HTMLElement)?null:n},Wd=(e,t)=>{const n=EE(e,t);return n?n.scrollTop>0:!1},zE=({currentSessionId:e,currentSessionKey:t,sessionMessageCount:n,sessionIsWorking:s,isMobile:o,onActiveTurnChange:r})=>{const a=d.useRef(null),[l,c]=d.useState(null),u=d.useRef(null),[f,h]=d.useState("following"),[m,p]=d.useState(!1),[g,y]=d.useState(!1),[M,b]=d.useState(!1),v=d.useRef("following"),x=d.useRef(o);x.current=o;const S=d.useRef(s);S.current=s;const C=d.useRef(!1),w=d.useRef(null),_=d.useRef(n);_.current=n;const L=d.useRef(e);L.current=e;const A=d.useRef(t);A.current=t;const N=d.useRef(null),k=d.useRef(null),V=d.useRef(null),H=d.useRef(0),D=d.useRef(!1),P=d.useRef(0),R=d.useRef(!1),$=d.useRef(null),O=d.useRef(null),I=d.useRef(0),q=d.useRef(null),G=d.useRef(null),K=d.useRef(null),W=Ks(ne=>ne.updateViewportAnchor);d.useLayoutEffect(()=>{a.current!==u.current&&(u.current=a.current,c(a.current))});const ge=d.useCallback(()=>S.current||C.current,[]),Z=d.useCallback(ne=>{v.current!==ne&&(v.current=ne,h(ne))},[]),fe=d.useCallback(ne=>{k.current={top:Math.max(0,ne.scrollHeight-ne.clientHeight),time:Ss()},V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{k.current=null,V.current=null},$d)},[]),ie=d.useCallback(ne=>{const Ce=k.current;return Ce?Ss()-Ce.time>$d?(k.current=null,!1):Math.abs(ne.scrollTop-Ce.top)<qd:!1},[]),E=d.useCallback(()=>Ss()<H.current,[]),ce=d.useCallback(()=>{R.current=!1,$.current&&(clearTimeout($.current),$.current=null),O.current&&(clearTimeout(O.current),O.current=null)},[]),ee=d.useCallback(()=>{$.current&&clearTimeout($.current),$.current=setTimeout(()=>{$.current=null,ce()},TE)},[ce]),ue=d.useCallback(()=>{const ne=a.current;ne&&(R.current=!0,I.current=ne.scrollHeight,ee(),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{O.current=null,ce()},VE))},[ee,ce]),J=d.useCallback(()=>{const ne=a.current;if(!ne){p(!1),y(!1);return}const Ce=_s(ne);if(p(Ce),!Ce){y(!1);return}const Se=v.current==="released"&&!Gd(ne,x.current);y(Se)},[]),Y=d.useCallback(ne=>{const Ce=a.current;if(!Ce)return;fe(Ce);const Se=Ce.scrollHeight+4096;if(ne==="smooth"){Ce.scrollTo({top:Se,behavior:ne});return}Ce.scrollTop=Se},[fe]),oe=d.useCallback((ne,Ce="auto")=>{const Se=a.current;!ne&&!ge()||(ne&&v.current!=="following"&&Z("following"),Se&&(!ne&&v.current!=="following"||Y(ne?Ce:"auto")))},[ge,Y,Z]),te=d.useCallback(()=>{const ne=a.current;if(ne){if(!_s(ne)){Z("following");return}v.current!=="released"&&(Z("released"),J())}},[Z,J]),pe=d.useCallback((ne="instant")=>{oe(!0,ne==="smooth"?"smooth":"auto")},[oe]),He=d.useCallback(()=>{oe(!0)},[oe]),je=d.useCallback(()=>{Z("released"),J()},[Z,J]),Pe=d.useCallback(()=>{ce(),te()},[ce,te]),X=d.useCallback(()=>{q.current!==null&&(clearTimeout(q.current),q.current=null);const ne=G.current;if(!ne)return;const Ce=a.current;if(!Ce){G.current=null;return}W(ne.sessionId,ne.anchor,{scrollTop:Ce.scrollTop,scrollHeight:Ce.scrollHeight,clientHeight:Ce.clientHeight}),G.current=null},[W]),me=d.useCallback(()=>{const ne=L.current;if(!ne)return;const Ce=a.current;if(!Ce)return;const{scrollTop:Se,scrollHeight:Ae,clientHeight:Ve}=Ce,Me=Ae>0?(Se+Ve/2)/Ae:0,Ie=Math.floor(Me*_.current);G.current={sessionId:ne,anchor:Ie},q.current===null&&(q.current=setTimeout(()=>{q.current=null,X()},jE))},[X]),U=d.useCallback(()=>{X()},[X]),T=d.useCallback(async()=>{const ne=A.current;return ne?a.current?(K.current=null,Z("following"),oe(!0),ue(),J(),!1):(K.current=ne,Z("following"),!1):!1},[ue,oe,Z,J]);d.useEffect(()=>{!e||!t||t===N.current||(N.current=t,B0.getInstance().recordSessionStart(e),X(),k.current=null,K.current&&K.current!==t&&(K.current=null))},[e,t,X]),d.useEffect(()=>{if(C.current=!1,w.current&&(clearTimeout(w.current),w.current=null),s){v.current==="following"&&oe(!0);return}C.current=!0,w.current=setTimeout(()=>{C.current=!1,w.current=null},BE)},[s,oe]),d.useEffect(()=>{b(f==="following"&&s)},[f,s]),d.useLayoutEffect(()=>{l&&K.current&&K.current===t&&T()},[l,t,T]);const Q=d.useCallback(()=>{const ne=a.current;if(!ne)return;const Ce=P.current;P.current=ne.scrollTop;const Se=ne.scrollTop>Ce+.5;if(J(),!_s(ne)){Z("following");return}if(Gd(ne,x.current)){const Ae=hp(ne)<=qd;(Se||v.current==="following"||Ae)&&Z("following"),me();return}if(v.current==="following"&&(ie(ne)||E())){oe(!1),me();return}te(),me()},[E,ie,me,oe,Z,te,J]);d.useEffect(()=>{const ne=l;if(!ne)return;P.current=ne.scrollTop;const Ce=n1=>{n1.deltaY>=0||Wd(ne,n1.target)||Pe()};let Se=null;const Ae=n1=>{const de=n1.touches.item(0);Se=de?de.clientY:null},Ve=n1=>{const de=n1.touches.item(0);if(!de){Se=null;return}const Le=Se;Se=de.clientY,!(Le===null||de.clientY-Le<=IE)&&(Wd(ne,n1.target)||Pe())},Me=()=>{Se=null},Ie=n1=>{PE(n1)&&Pe()},qe=n1=>{const de=n1.target;de instanceof Element&&de.closest("[data-overlay-scrollbar-thumb]")&&Pe()};return ne.addEventListener("scroll",Q,{passive:!0}),ne.addEventListener("wheel",Ce,{passive:!0}),ne.addEventListener("touchstart",Ae,{passive:!0}),ne.addEventListener("touchmove",Ve,{passive:!0}),ne.addEventListener("touchend",Me,{passive:!0}),ne.addEventListener("touchcancel",Me,{passive:!0}),ne.addEventListener("keydown",Ie),typeof window<"u"&&window.addEventListener("pointerdown",qe,!0),()=>{ne.removeEventListener("scroll",Q),ne.removeEventListener("wheel",Ce),ne.removeEventListener("touchstart",Ae),ne.removeEventListener("touchmove",Ve),ne.removeEventListener("touchend",Me),ne.removeEventListener("touchcancel",Me),ne.removeEventListener("keydown",Ie),typeof window<"u"&&window.removeEventListener("pointerdown",qe,!0)}},[l,Q,Pe]),d.useEffect(()=>{const ne=l;if(!ne||typeof ResizeObserver>"u")return;const Ce=new ResizeObserver(()=>{if(D.current){J();return}const Ae=a.current;if(Ae&&!_s(Ae)){Z("following"),J();return}if(J(),R.current&&Ae){const Ve=Ae.scrollHeight>I.current+1;I.current=Ae.scrollHeight,oe(!0),Ve&&ee();return}ge()&&v.current==="following"&&oe(!1)});Ce.observe(ne);const Se=ne.firstElementChild;return Se instanceof Element&&Ce.observe(Se),()=>Ce.disconnect()},[ee,l,ge,oe,Z,J]),d.useEffect(()=>{if(typeof window>"u")return;const ne=Se=>{const Ae=Se.detail;Ae&&(D.current=!0,H.current=Ss()+Ae.durationMs+Ud)},Ce=()=>{D.current=!1;const Se=a.current;if(!Se){J();return}v.current==="following"&&_s(Se)&&Y("auto"),J()};return window.addEventListener("oc:keyboard-anim",ne),window.addEventListener("oc:keyboard-settled",Ce),()=>{window.removeEventListener("oc:keyboard-anim",ne),window.removeEventListener("oc:keyboard-settled",Ce),D.current=!1}},[Y,J]),d.useEffect(()=>{J()},[n,J]);const se=d.useCallback(ne=>{if(ne==="animation"&&(H.current=Ss()+Ud),J(),R.current){oe(!0),ee();return}v.current==="following"&&oe(!1)},[ee,oe,J]),ye=d.useRef(new Map),le=d.useCallback(ne=>{const Ce=ye.current.get(ne);if(Ce)return Ce;const Se=()=>{v.current==="following"&&oe(!1)},Ae={onChunk:Se,onComplete:()=>{J()},onStreamingCandidate:()=>{},onAnimationStart:()=>{},onAnimatedHeightChange:Se,onReservationCancelled:()=>{},onReasoningBlock:()=>{}};return ye.current.set(ne,Ae),Ae},[oe,J]);return d.useEffect(()=>()=>{V.current&&(clearTimeout(V.current),V.current=null),w.current&&(clearTimeout(w.current),w.current=null),ce(),X(),q.current!==null&&(clearTimeout(q.current),q.current=null)},[ce,X]),d.useEffect(()=>{if(!r)return;const ne=l;if(!ne)return;let Ce=null;const Se=AE({onActive:de=>{de!==Ce&&(Ce=de,r(de))}});Se.setContainer(ne);const Ae=new Map,Ve=de=>{const Le=de.dataset.turnId;return Le?(Ae.set(Le,de),Se.register(de,Le),!0):!1},Me=de=>{const Le=de.dataset.turnId;return!Le||Ae.get(Le)!==de?!1:(Ae.delete(Le),Se.unregister(Le),!0)},Ie=de=>{if(!(de instanceof HTMLElement))return[];const Le=[];return de.matches("[data-turn-id]")&&Le.push(de),de.querySelectorAll("[data-turn-id]").forEach(xe=>Le.push(xe)),Le};ne.querySelectorAll("[data-turn-id]").forEach(Ve),Se.markDirty();const qe=new MutationObserver(de=>{let Le=!1;de.forEach(xe=>{xe.removedNodes.forEach(ve=>{Ie(ve).forEach(Te=>{Me(Te)&&(Le=!0)})}),xe.addedNodes.forEach(ve=>{Ie(ve).forEach(Te=>{Ve(Te)&&(Le=!0)})})}),Le&&Se.markDirty()});qe.observe(ne,{subtree:!0,childList:!0});const n1=()=>Se.onScroll();return ne.addEventListener("scroll",n1,{passive:!0}),()=>{ne.removeEventListener("scroll",n1),qe.disconnect(),Se.destroy()}},[l,r]),{scrollRef:a,state:f,isPinned:f==="following",isOverflowing:m,isFollowingProgrammatically:M,showScrollButton:g,notifyContentChange:se,getAnimationHandlers:le,goToBottom:pe,scrollToBottomOnSend:He,releaseAutoFollow:je,saveSnapshotNow:U,restoreSnapshot:T}},I5=e=>{const t=e.info.clientRole??e.info.role;return typeof t=="string"?t:""},B5=e=>{const t=e.info.parentID;if(!(typeof t!="string"||t.trim().length===0))return t},Kd=e=>{if(!e)return null;const t=I5(e),n=typeof e.info?.id=="string"?e.info.id:"",s=B5(e)??"";return`${n}::${t}::${s}`},DE=e=>({turnIds:[...e.turnIds],turnMessageStartIndexes:[...e.turnMessageStartIndexes],turnIndexById:new Map(e.turnIndexById),messageToTurnId:new Map(e.messageToTurnId),messageToTurnIndex:new Map(e.messageToTurnIndex),turnCount:e.turnCount}),RE=(e,t,n)=>{if(!e||!t)return null;if(t.length===n.length){let f=-1;for(let h=0;h<n.length;h+=1)if(t[h]!==n[h]){if(f!==-1)return null;f=h}return f===-1?e:f!==n.length-1?null:Kd(t[f])===Kd(n[f])?e:null}if(n.length!==t.length+1)return null;for(let f=0;f<t.length;f+=1)if(t[f]!==n[f])return null;const s=n[n.length-1];if(!s)return null;const o=I5(s),r=s.info.id,a=DE(e);if(o==="user"){const f=a.turnIds.length;return a.turnIds.push(r),a.turnMessageStartIndexes.push(n.length-1),a.turnIndexById.set(r,f),a.messageToTurnId.set(r,r),a.messageToTurnIndex.set(r,f),a.turnCount=a.turnIds.length,a}if(o!=="assistant"){const f=a.turnIds.length-1;if(f<0)return null;const h=a.turnIds[f];return h?(a.messageToTurnId.set(r,h),a.messageToTurnIndex.set(r,f),a):null}const l=B5(s);if(!l)return a;const c=a.turnIndexById.get(l);if(typeof c!="number"||c<0)return null;const u=a.turnIds[c];return u?(a.messageToTurnId.set(r,u),a.messageToTurnIndex.set(r,c),a):null},OE=e=>{const t=[],n=[],s=new Map,o=new Map,r=new Map,a=new Map;let l=-1;return e.forEach((c,u)=>{const f=I5(c),h=c.info.id;if(f==="user"){l=t.length,t.push(h),n.push(u),s.set(h,l),a.set(h,l),o.set(h,h),r.set(h,l);return}if(f!=="assistant"){if(l>=0){const y=t[l];y&&(o.set(h,y),r.set(h,l))}return}const m=B5(c);if(!m)return;const p=a.get(m);if(typeof p!="number"||p<0)return;const g=t[p];g&&(o.set(h,g),r.set(h,p))}),{turnIds:t,turnMessageStartIndexes:n,turnIndexById:s,messageToTurnId:o,messageToTurnIndex:r,turnCount:t.length}},qr=200,Yd={MAX_SESSIONS:3,ZOMBIE_TIMEOUT:600*1e3},mp=()=>qr,ZE=()=>Math.round(mp()*.6),FE={MAX_SESSIONS:Yd.MAX_SESSIONS,VIEWPORT_MESSAGES:Math.round(qr*.6),HISTORICAL_MESSAGES:qr,FETCH_BUFFER:20,HISTORY_CHUNK:qr,STREAMING_BUFFER:1/0,ZOMBIE_TIMEOUT:Yd.ZOMBIE_TIMEOUT},Jd=()=>{const e=mp(),t=ZE();return{...FE,HISTORICAL_MESSAGES:e,VIEWPORT_MESSAGES:t,HISTORY_CHUNK:e}},$E=30,qE=1200,UE=1.5,GE=e=>Math.max(qE,e*UE),WE=4,KE=30,YE=250,JE=2e3,XE=2500,wn=new Map,QE=()=>D2()?WE:$E,ez=e=>D2()?e.length<=KE:!0,Xd=(e,t)=>{if(wn.delete(e),!ez(t.messages))return;const n=QE();for(;wn.size>=n;){const s=wn.keys().next().value;if(typeof s!="string")break;wn.delete(s)}wn.set(e,t)},tz=e=>!e.sessionId||!e.isPinned||!e.canLoadEarlier||e.isLoadingOlder||e.pendingRevealWork?!1:e.scrollHeight<=e.clientHeight+1,Qd=e=>!!(e.previousOldestId&&e.currentOldestId&&e.currentOldestId!==e.previousOldestId&&e.previousNewestId&&e.currentNewestId&&e.currentNewestId===e.previousNewestId),nz=20,sz=4,e9=(e,t)=>{const n=e.style.overflow;if(e.style.overflow="hidden",e.scrollTop=t,e.scrollHeight,e.style.overflow=n,e.scrollTop=t,typeof window>"u")return;let s=!1,o=0;const r=()=>{s=!0};e.addEventListener("touchstart",r,{passive:!0,once:!0});const a=()=>{s||(e.scrollTop<t-sz&&(e.scrollTop=t),o+=1,o<nz?window.requestAnimationFrame(a):e.removeEventListener("touchstart",r))};window.requestAnimationFrame(a)},t9=(e,t,n)=>!e||!t||t===e?!1:n.some(s=>s.info.id===e),oz=({sessionId:e,sessionKey:t,messages:n,historyMeta:s,scrollRef:o,messageListRef:r,loadMoreMessages:a,goToBottom:l,releaseAutoFollow:c,isPinned:u,showScrollButton:f})=>{const h=d.useRef(null),m=d.useRef(null),p=d.useRef(null),g=d.useMemo(()=>{const U=t??"";p.current!==t&&(p.current=t,h.current=null,m.current=null);const T=U?wn.get(U):void 0;if(T&&T.messages===n)return Xd(U,T),h.current=T.model,m.current=n,T.model;const se=RE(h.current,m.current,n)??OE(n);return h.current=se,m.current=n,U&&n.length>0&&Xd(U,{messages:n,model:se}),se},[n,t]),[y,M]=d.useState(!1),[b,v]=d.useState(!1),[x,S]=d.useState(null),C=d.useRef(g),w=d.useRef(u),_=d.useRef(y),L=d.useRef(b),A=d.useRef(e),N=d.useRef({key:t});N.current.key!==t&&(N.current={key:t});const k=d.useRef(n),V=d.useRef(s),H=d.useRef(null),D=d.useRef([]),P=d.useRef(null),R=d.useRef(null),$=d.useRef(!1),O=d.useRef(null),I=d.useMemo(()=>{const U=Jd().HISTORICAL_MESSAGES,T=!1,Q=s?!s.complete:n.length>=U,se=!!s?.loading;return{hasBufferedTurns:T,hasMoreAboveTurns:Q,historyLoading:se,canLoadEarlier:Q}},[s,n.length]),q=d.useRef(I);C.current=g,w.current=u,_.current=y,L.current=b,q.current=I,A.current=e,k.current=n,V.current=s;const G=d.useCallback(()=>{$.current=!0,O.current!==null&&typeof window<"u"&&(window.clearTimeout(O.current),O.current=null)},[]),K=d.useCallback(()=>{if(typeof window>"u"){$.current=!1;return}O.current!==null&&window.clearTimeout(O.current),O.current=window.setTimeout(()=>{O.current=null,$.current=!1},JE)},[]);d.useLayoutEffect(()=>{if(H.current===t)return;O.current!==null&&typeof window<"u"&&(window.clearTimeout(O.current),O.current=null),$.current=!1,H.current=t;const U=P.current;U&&U.identity!==N.current&&(P.current=null,U.resolve(!1)),M(!1),v(!1),R.current=null,S(null)},[t]),d.useLayoutEffect(()=>{if(!u)return;const U=g.turnIds[g.turnIds.length-1];U&&S(T=>T===U?T:U)},[u,g.turnIds]);const W=d.useCallback(()=>{const U=D.current;U.length!==0&&(D.current=[],U.forEach(T=>T()))},[]),ge=d.useCallback(()=>new Promise(U=>{if(typeof window>"u"){U();return}let T=!1;const Q=()=>{T||(T=!0,window.clearTimeout(se),U())};D.current.push(Q);const se=window.setTimeout(Q,YE)}),[]),Z=d.useCallback(U=>{const T=P.current;T&&(P.current=null,T.resolve(U))},[]),fe=d.useCallback(()=>{const U=P.current;if(!U)return;if(U.identity!==N.current){Z(!1);return}if(U.kind==="turn"?r.current?.scrollToTurnId(U.id,{behavior:U.behavior})??!1:r.current?.scrollToMessageId(U.id,{behavior:U.behavior})??!1){U.turnId&&(R.current={turnId:U.turnId,expiresAt:Date.now()+XE},S(U.turnId)),Z(!0);return}typeof(U.kind==="turn"?C.current.turnIndexById.get(U.id):C.current.messageToTurnIndex.get(U.id))=="number"&&Z(!1)},[r,Z]);d.useEffect(()=>()=>{O.current!==null&&typeof window<"u"&&(window.clearTimeout(O.current),O.current=null),W(),Z(!1)},[W,Z]);const ie=n;d.useLayoutEffect(()=>{W(),fe()},[fe,ie,W]);const E=d.useRef(null),ce=d.useCallback(()=>r.current?.captureViewportAnchor()??null,[r]),ee=d.useCallback(U=>r.current?.restoreViewportAnchor(U)??!1,[r]),ue=d.useRef(null);d.useLayoutEffect(()=>{E.current=null,ue.current=null},[t]),d.useLayoutEffect(()=>{const U=o.current;if(!U)return;let T=E.current;const Q=ue.current,se=ie[0]?.info?.id??null,ye=ie[ie.length-1]?.info?.id??null,le=Q?Qd({previousOldestId:Q.oldestId,previousNewestId:Q.newestId,currentOldestId:se,currentNewestId:ye})||t9(Q.oldestId,se,ie):!1;T&&T.identity!==N.current&&(E.current=null,T=null);const ne=T?Qd({previousOldestId:T.oldestId,previousNewestId:T.newestId,currentOldestId:se,currentNewestId:ye})||t9(T.oldestId,se,ie):!1,Ce=le||ne,Se=!!(T&&(le||ne)),Ae=()=>{ue.current={oldestId:se,newestId:ye,scrollHeight:U.scrollHeight}},Ve=()=>{const Ie=E.current;Ie&&(E.current={...Ie,height:U.scrollHeight,top:U.scrollTop,anchor:ce(),oldestId:se,newestId:ye})};if(w.current){Ce?(E.current=null,l("instant")):T&&Ve(),Ae();return}const Me=r.current?.isHistoryVirtualized()??!1;if(T&&Se){if(E.current=null,Me){!T.historyVirtualized&&T.anchor&&ee(T.anchor),Ae();return}const Ie=U.scrollHeight-T.height,qe=()=>Ie<=0?!1:(U.scrollTop=T.top+Ie,!0);if(D2()&&Ie>0){e9(U,T.top+Ie),Ae();return}T.anchor&&ee(T.anchor)||qe()}else if(le&&Q&&!Me){const Ie=U.scrollHeight-Q.scrollHeight;if(Ie>0){const qe=U.scrollTop+Ie;D2()?e9(U,qe):U.scrollTop=qe}}else T&&Ve();Ae()},[ce,r,ie,o,ee,l]);const J=d.useCallback(async()=>!1,[]),Y=d.useCallback(async U=>{if(!A.current||!N.current.key||_.current||!q.current.hasMoreAboveTurns)return!1;const T=A.current,Q=N.current;if(!T||!Q.key)return!1;const se=()=>{E.current?.identity===Q&&(E.current=null)},ye=o.current,le=k.current,ne=le.length,Ce=le[0]?.info?.id??null,Se=V.current?.limit??Jd().HISTORICAL_MESSAGES;U.preserveViewport&&ye&&(E.current={identity:Q,height:ye.scrollHeight,top:ye.scrollTop,anchor:ce(),historyVirtualized:r.current?.isHistoryVirtualized()??!1,oldestId:Ce,newestId:le[le.length-1]?.info?.id??null}),G(),M(!0);try{let Ae=ne,Ve=Ce,Me=Se;const Ie=C.current.turnCount;for(;;){if(await a(T,"up"),N.current!==Q||(await ge(),N.current!==Q))return se(),!1;const qe=k.current,n1=qe.length,de=qe[0]?.info?.id??null,Le=V.current?.limit??Me,xe=n1>Ae||typeof Ve=="string"&&typeof de=="string"&&Ve!==de||Le>Me;if(C.current.turnCount-Ie>0)return!0;if(!xe)return se(),!1;if(!q.current.hasMoreAboveTurns)return!0;Ae=n1,Ve=de,Me=Le}}catch(Ae){throw se(),Ae}finally{N.current===Q&&(M(!1),K())}},[G,ce,a,r,o,K,ge]),oe=d.useCallback(async U=>{const T=N.current;G(),U?.userInitiated&&c();try{await Y({preserveViewport:!0})}finally{N.current===T&&K()}},[G,Y,c,K]),te=d.useCallback(()=>{if(D2())return;const U=o.current;U&&(w.current||U.scrollTop>=GE(U.clientHeight)||q.current.canLoadEarlier&&(_.current||L.current||oe({userInitiated:!0})))},[oe,o]),pe=d.useCallback(()=>{if(D2()||$.current)return;const U=o.current;U&&tz({sessionId:A.current,isPinned:w.current,canLoadEarlier:q.current.canLoadEarlier,isLoadingOlder:_.current,pendingRevealWork:L.current,scrollHeight:U.scrollHeight,clientHeight:U.clientHeight})&&oe()},[oe,o]);d.useEffect(()=>{if(typeof window>"u")return;const U=window.requestAnimationFrame(()=>{pe()});return()=>window.cancelAnimationFrame(U)},[I.canLoadEarlier,y,u,pe,b,ie.length,t]),d.useEffect(()=>{if(typeof window>"u"||typeof ResizeObserver>"u")return;const U=o.current;if(!U)return;let T=null;const Q=()=>{T===null&&(T=window.requestAnimationFrame(()=>{T=null,pe()}))},se=new ResizeObserver(Q);se.observe(U);const ye=U.firstElementChild;return ye instanceof Element&&se.observe(ye),Q(),()=>{T!==null&&window.cancelAnimationFrame(T),se.disconnect()}},[pe,o,t]);const He=d.useCallback(async(U,T)=>{if(!U||!A.current||!N.current.key)return!1;const Q=N.current;c(),v(!0);try{return N.current!==Q||typeof C.current.turnIndexById.get(U)!="number"?!1:!!await new Promise(le=>{P.current={identity:Q,kind:"turn",id:U,behavior:T?.behavior??"auto",turnId:U,resolve:le},fe()})}finally{N.current===Q&&v(!1)}},[fe,c]),je=d.useCallback(async(U,T)=>{if(!U||!A.current||!N.current.key)return!1;const Q=N.current;c(),v(!0);try{if(N.current!==Q)return!1;const se=C.current.messageToTurnId.get(U);return typeof C.current.messageToTurnIndex.get(U)!="number"?!1:!!await new Promise(ne=>{P.current={identity:Q,kind:"message",id:U,behavior:T?.behavior??"auto",turnId:se??null,resolve:ne},fe()})}finally{N.current===Q&&v(!1)}},[fe,c]),Pe=d.useCallback(async()=>{v(!1),M(!1),l("smooth")},[l]),X=d.useCallback(async()=>{v(!1),M(!1),l("instant")},[l]),me=d.useCallback(U=>{const T=R.current;if(T){if(U!==T.turnId&&Date.now()<T.expiresAt)return;R.current=null}S(U)},[]);return{turnIds:g.turnIds,turnStart:0,renderedMessages:ie,historySignals:I,isLoadingOlder:y,pendingRevealWork:b,activeTurnId:x,showScrollToBottom:f&&!b,turnWindowModel:g,loadEarlier:oe,revealBufferedTurns:J,resumeToBottom:Pe,resumeToBottomInstant:X,scrollToTurn:He,scrollToMessage:je,handleHistoryScroll:te,captureViewportAnchor:ce,restoreViewportAnchor:ee,handleActiveTurnChange:me}},rz=({open:e,onOpenChange:t,onScrollToMessage:n,onScrollByTurnOffset:s,onResumeToLatest:o,canLoadEarlier:r=!1,isLoadingEarlier:a=!1,onLoadEarlier:l,onRevert:c,onFork:u})=>{const{isMobile:f}=c0(),h=Be(I=>I.currentSessionId),[m,p]=d.useState(!1);d.useEffect(()=>{if(!h){p(!1);return}const I=()=>{try{const{getPiSessionStore:q}=require("@/apps/pi-session-store"),G=q().getState().reducer.bySession.get(h);p(G?.lifecycle==="busy"||G?.lifecycle==="retry")}catch{p(!1)}};I();try{const{getPiSessionStore:q}=require("@/apps/pi-session-store");return q().subscribe(I,`session:${h}`)}catch{return}},[h]);const g=Ui(h??""),[y,M]=d.useState(""),[b,v]=d.useState(0),x=d.useRef([]),S=d.useRef(null),C=d.useRef(null),w=d.useRef(!1),_=d.useRef(e),L=d.useCallback(I=>new Date(I).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),[]),A=d.useCallback(I=>new Date(I).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}),[]),N=d.useMemo(()=>g.filter(I=>I.info.role==="user").map(I=>({message:I})),[g]),k=d.useMemo(()=>{const I=y.trim();if(!I)return N;const q=I.toLowerCase();return N.filter(({message:G})=>Q4(G.parts).toLowerCase().includes(q))},[N,y]);d.useEffect(()=>{w.current||v(y.trim()?0:Math.max(0,k.length-1))},[k,y]),d.useEffect(()=>{x.current=x.current.slice(0,k.length)},[k.length]),d.useEffect(()=>{w.current||x.current[b]?.scrollIntoView({block:"nearest"})},[b]),d.useEffect(()=>{!w.current||C.current||a||(w.current=!1)},[k.length,a]),d.useLayoutEffect(()=>{const I=_.current;if(_.current=e,!e||I||w.current||y.trim())return;const q=S.current;q&&(q.scrollTop=q.scrollHeight)},[e,y]),d.useLayoutEffect(()=>{const I=C.current,q=S.current;if(!I||!q||a)return;C.current=null;const G=x.current.find(W=>W?.dataset.timelineMessageId===I.messageId);if(!G)return;const K=G.getBoundingClientRect().top-q.getBoundingClientRect().top;q.scrollTop+=K-I.top},[k.length,a]);const V=d.useCallback(()=>{const I=S.current;if(I){const q=I.getBoundingClientRect().top,G=x.current.find(K=>K?K.getBoundingClientRect().bottom>=q:!1);G?.dataset.timelineMessageId&&(C.current={messageId:G.dataset.timelineMessageId,top:G.getBoundingClientRect().top-q})}w.current=!0,l?.()},[l]),H=d.useCallback(async I=>{await n?.(I)!==!1&&t(!1)},[t,n]),D=d.useCallback(I=>{const q=k.length;if(q!==0){if(I.key==="ArrowDown"){I.preventDefault(),v(G=>(G+1)%q);return}if(I.key==="ArrowUp"){I.preventDefault(),v(G=>(G-1+q)%q);return}if(I.key==="Enter"){I.preventDefault();const G=(b%q+q)%q,K=k[G];K&&H(K.message.info.id)}}},[k,H,b]),P=d.useCallback(async()=>{const I=k.length;if(I===0||!c||m)return;const q=(b%I+I)%I,G=k[q];if(G)try{await c(G.message.info.id),t(!1)}catch(K){Ue.error(K instanceof Error?K.message:"Failed to revert")}},[k,m,c,t,b]),R=d.useCallback(async()=>{const I=k.length;if(I===0||!u||m)return;const q=(b%I+I)%I,G=k[q];if(G)try{await u(G.message.info.id),t(!1)}catch(K){Ue.error(K instanceof Error?K.message:"Failed to fork")}},[k,m,u,t,b]),$=d.useCallback(I=>{const q=k.length;if(q!==0){if(I.key==="ArrowDown"){I.preventDefault(),v(G=>(G+1)%q);return}if(I.key==="ArrowUp"){I.preventDefault(),v(G=>(G-1+q)%q);return}if(I.key==="Enter"){I.preventDefault();const G=(b%q+q)%q,K=k[G];K&&H(K.message.info.id)}}},[k,H,b]);if(d.useEffect(()=>{if(!e||f)return;const I=window.setTimeout(()=>S.current?.focus(),100);return()=>window.clearTimeout(I)},[e,f]),!h)return null;const O=k[(b%Math.max(1,k.length)+Math.max(1,k.length))%Math.max(1,k.length)]?.message??null;return i.jsx(On,{open:e,onOpenChange:t,children:i.jsxs(Zn,{className:B("flex flex-col",f?"max-w-full max-h-[85vh] rounded-t-2xl mt-auto":"max-w-2xl max-h-[70vh]"),children:[i.jsxs(Fn,{children:[i.jsxs($n,{className:"flex items-center gap-2",children:[i.jsx(z,{name:"time",className:"h-5 w-5"}),"Conversation Timeline"]}),i.jsx(ao,{children:f?"Tap a message, then Revert or Fork":"Arrow keys to move • Enter to jump"})]}),!f&&i.jsxs("div",{className:"relative mt-2",children:[i.jsx(z,{name:"search",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),i.jsx(Bt,{placeholder:"Search messages...",value:y,onChange:I=>M(I.target.value),onKeyDown:D,className:"pl-9 w-full"})]}),r&&l&&i.jsx("div",{className:"flex justify-center py-1",children:i.jsxs(a1,{type:"button",variant:"link",size:"sm",onClick:V,disabled:a,className:"h-auto px-1 py-0 text-muted-foreground hover:text-foreground",children:[a&&i.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),"Load older messages"]})}),i.jsx("div",{ref:S,tabIndex:0,onKeyDown:$,className:"flex-1 overflow-y-auto outline-none focus-visible:ring-1 focus-visible:ring-ring rounded","aria-label":"Message list",children:k.length===0?i.jsx("div",{className:"text-center text-muted-foreground py-8",children:y?"No messages found":"No messages in this session yet"}):k.map(({message:I},q)=>{const G=fp(I.parts),K=I.info.time?.created??0,W=L(K),ge=k[q-1],Z=ge?L(ge.message.info.time?.created??0):null,fe=W!==Z,ie=A(K),E=q===b,ce=y.trim()?az(Q4(I.parts),y):null;return i.jsxs(d.Fragment,{children:[fe&&i.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-3 bg-background/95 py-2 backdrop-blur-sm",children:[i.jsx("div",{className:"h-px flex-1 bg-border/60"}),i.jsx("span",{className:"typography-meta text-muted-foreground",children:W}),i.jsx("div",{className:"h-px flex-1 bg-border/60"})]}),i.jsxs("div",{ref:ee=>{x.current[q]=ee},"data-timeline-message-id":I.info.id,className:B("group flex items-center gap-3 py-1.5 hover:bg-interactive-hover/30 rounded transition-colors cursor-pointer",E&&"bg-interactive-selection text-interactive-selection-foreground"),onClick:()=>{H(I.info.id)},onMouseEnter:()=>v(q),children:[i.jsx("span",{className:B("typography-meta w-16 flex-shrink-0 text-right tabular-nums",E?"text-interactive-selection-foreground/70":"text-muted-foreground"),children:ie}),i.jsxs("p",{className:B("flex-1 min-w-0 typography-small truncate",E?"text-interactive-selection-foreground":"text-foreground"),children:[ce??(G||"[No text content]"),!ce&&G&&G.length>=80&&"…"]})]})]},I.info.id)})}),O&&i.jsxs("div",{className:B("flex gap-2 mt-3",f?"flex-col":"flex-row"),children:[i.jsxs(a1,{type:"button",variant:f?"default":"outline",size:f?"default":"sm",className:B(f&&"w-full justify-center h-11 text-base"),disabled:m,onClick:()=>{P()},children:[i.jsx(z,{name:"history",className:"h-4 w-4"}),"Revert"]}),i.jsxs(a1,{type:"button",variant:"outline",size:f?"default":"sm",className:B(f&&"w-full justify-center h-11 text-base"),disabled:m,onClick:()=>{R()},children:[i.jsx(z,{name:"git-branch",className:"h-4 w-4"}),"Fork"]})]})]})})},iz=e=>e.open?i.jsx(rz,{...e}):null;function az(e,t,n=30){const s=e.toLowerCase(),o=t.toLowerCase(),r=s.indexOf(o);if(r===-1)return null;const a=Math.max(0,r-n),l=Math.min(e.length,r+t.length+n);return`${a>0?"…":""}${e.slice(a,l).replace(/\n/g," ")}${l<e.length?"…":""}`}const lz=e=>{const t=e.startsWith("#")?e.slice(1):e;if(!t)return null;const n=t.match(/^turn-(.+)$/);if(n?.[1])return{kind:"turn",id:n[1]};const s=t.match(/^message-(.+)$/);return s?.[1]?{kind:"message",id:s[1]}:null},cz=(e,t,n)=>{if(n===0)return{kind:"noop"};if(e.length===0)return{kind:"noop"};const s=t?e.indexOf(t):e.length-1,r=(s>=0?s:e.length-1)+n;if(r>=e.length)return{kind:"resume"};const a=Math.max(0,r),l=e[a];return l?{kind:"turn",turnId:l}:{kind:"noop"}},br=e=>{if(typeof window>"u")return;const t=e?`#${e}`:"",n=`${window.location.pathname}${window.location.search}${t}`;window.history.replaceState(window.history.state,"",n)},dz=({sessionId:e,turnIds:t,activeTurnId:n,scrollToTurn:s,scrollToMessage:o,resumeToBottom:r})=>{const a=d.useRef(t),l=d.useRef(n);d.useEffect(()=>{a.current=t},[t]),d.useEffect(()=>{l.current=n},[n]);const c=d.useCallback(async(m,p)=>m?(p?.updateHash!==!1&&br(`turn-${m}`),s(m,{behavior:p?.behavior})):!1,[s]),u=d.useCallback(async(m,p)=>m?(p?.updateHash!==!1&&br(`message-${m}`),o(m,{behavior:p?.behavior})):!1,[o]),f=d.useCallback(async(m,p)=>{const g=a.current,y=cz(g,l.current,m);if(y.kind==="noop")return m===0;if(y.kind==="resume"){if(p?.resumePastEnd===!1){const M=g[g.length-1];return M?c(M,{behavior:"auto"}):!1}return br(null),r(),!0}return c(y.turnId,{behavior:"auto"})},[r,c]),h=d.useCallback(()=>{br(null),r()},[r]);return d.useEffect(()=>{if(!e||typeof window>"u")return;const m=()=>{const p=lz(window.location.hash);if(p){if(p.kind==="turn"){c(p.id,{behavior:"auto",updateHash:!1});return}u(p.id,{behavior:"auto",updateHash:!1})}};return m(),window.addEventListener("hashchange",m),()=>{window.removeEventListener("hashchange",m)}},[e,u,c,t.length]),{scrollToTurnId:c,scrollToMessageId:u,scrollByTurnOffset:f,resumeToLatest:h}},uz=(e,t,n)=>e?.parentID?!t:n;function fz(){return!1}async function hz(){return null}const mz=[],pz={type:"idle"},n9="pichamber:chat-force-scroll-bottom",gz="Quota limit reached. Retrying automatically.",yz={overflowAnchor:"none",overscrollBehavior:"contain",overscrollBehaviorY:"contain"},xr=e=>B("relative z-10 bg-background",e?"flex-1 min-h-0":"shrink-0"),vz=["a[href]","button","input","select","textarea",'[contenteditable="true"]','[role="button"]','[role="combobox"]','[role="dialog"]','[role="listbox"]','[role="menu"]','[role="menuitem"]','[role="option"]','[role="textbox"]',"[data-radix-popper-content-wrapper]"].join(","),bz=e=>e instanceof HTMLElement,T5=e=>bz(e)?!!e.closest(vz):!1,xz=(e,t)=>typeof document>"u"||!e||e===document.body||e===document.documentElement||T5(e)?!0:!t?.contains(e),wz=()=>{const{isCommandPaletteOpen:e,isHelpDialogOpen:t,isImagePreviewOpen:n,isSessionSwitcherOpen:s,isSettingsDialogOpen:o}=he.getState();return e||t||n||s||o},pp=d.memo(({currentSessionId:e,currentSessionKey:t,isDesktopExpandedInput:n,isMobile:s,stickyUserHeader:o,directory:r,scrollRef:a,messageListRef:l,pendingRevealWork:c,renderedMessages:u,isLoadingOlder:f,sessionIsWorking:h,streamingMessageId:m,activeStreamingPhase:p,retryOverlay:g,handleMessageContentChange:y,getAnimationHandlers:M,handleHistoryScroll:b,scrollToBottom:v,sessionQuestions:x,sessionPermissions:S,isProgrammaticFollowActive:C,showLoadOlderButton:w,onLoadOlder:_,turnIds:L,activeTurnId:A,onSelectTurn:N,showPromptNavigator:k,canLoadEarlierPrompts:V,isLoadingOlderPrompts:H,onLoadEarlierPrompts:D})=>{const P=d.useRef(new Map),R=d.useRef(new WeakMap),$=d.useRef(new Map),O=d.useRef(e);O.current!==e&&(O.current=e,$.current.clear());const I=d.useMemo(()=>{const W=new Map;for(let Z=0;Z<u.length;Z+=1){const fe=u[Z];if(fe.info.role!=="user")continue;if(np(fe)){const E=fP(u,Z)??"",ce=$.current.get(fe.info.id);if(ce&&ce.command===E)W.set(fe.info.id,ce.parts);else{const ee=[{type:"text",text:E?`$ ${E}`:"/shell"}];$.current.set(fe.info.id,{command:E,parts:ee}),W.set(fe.info.id,ee)}continue}if(A3(fe.parts))continue;let ie=R.current.get(fe.parts);ie||(ie=k5(fe.parts),R.current.set(fe.parts,ie)),ie.length!==0&&W.set(fe.info.id,ie)}const ge=P.current;if(ge.size===W.size){let Z=!0;for(const[fe,ie]of W)if(ge.get(fe)!==ie){Z=!1;break}if(Z)return ge}return P.current=W,W},[u]),q=d.useMemo(()=>L.filter(W=>I.has(W)),[I,L]),G=d.useMemo(()=>{if(!A||I.has(A))return A;const W=L.indexOf(A);for(let ge=W-1;ge>=0;ge-=1){const Z=L[ge];if(I.has(Z))return Z}return null},[A,I,L]),K=d.useCallback(W=>{W.defaultPrevented||T5(W.target)||typeof window<"u"&&window.getSelection()?.type==="Range"||a.current?.focus({preventScroll:!0})},[a]);return i.jsx("div",{className:B("relative min-h-0",n?"absolute inset-0 opacity-0 pointer-events-none":"flex-1"),"aria-hidden":n,children:i.jsxs("div",{className:"absolute inset-0",children:[i.jsx(Yi,{className:"absolute inset-0 overflow-y-auto overflow-x-hidden z-0 chat-scroll overlay-scrollbar-target",ref:a,style:yz,observeMutations:!1,hideTopShadow:s&&o,tabIndex:0,onClick:K,onScroll:b,"data-scroll-shadow":"true","data-scrollbar":"chat",children:i.jsxs("div",{className:"relative z-0 min-h-full",children:[w&&i.jsx("div",{className:"flex justify-center pt-3 pb-1",children:i.jsxs(a1,{variant:"secondary",size:"sm",onClick:_,disabled:f,children:[f&&i.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),"Load older messages"]})}),i.jsx(GP,{ref:l,sessionKey:e,disableStaging:c,messages:u,sessionIsWorking:h,activeStreamingMessageId:m,activeStreamingPhase:p,retryOverlay:g,onMessageContentChange:y,getAnimationHandlers:M,isLoadingOlder:f,scrollToBottom:v,scrollRef:a,directory:r},t),i.jsx("div",{className:"mb-3",children:i.jsx(up,{})}),i.jsx("div",{className:"flex-shrink-0",style:{height:s?"40px":"10vh"},"aria-hidden":"true"})]})}),i.jsx(Mf,{containerRef:a,suppressVisibility:C,userIntentOnly:!0,observeMutations:!1}),k&&q.length>=2?i.jsx(wE,{turnIds:q,previewsByTurnId:I,activeTurnId:G,onSelectTurn:N,canLoadEarlier:V,isLoadingOlder:H,onLoadEarlier:D}):null]})})},(e,t)=>e.currentSessionId===t.currentSessionId&&e.currentSessionKey===t.currentSessionKey&&e.isDesktopExpandedInput===t.isDesktopExpandedInput&&e.isMobile===t.isMobile&&e.stickyUserHeader===t.stickyUserHeader&&e.directory===t.directory&&e.scrollRef===t.scrollRef&&e.messageListRef===t.messageListRef&&e.pendingRevealWork===t.pendingRevealWork&&e.renderedMessages===t.renderedMessages&&e.isLoadingOlder===t.isLoadingOlder&&e.sessionIsWorking===t.sessionIsWorking&&e.streamingMessageId===t.streamingMessageId&&e.activeStreamingPhase===t.activeStreamingPhase&&e.retryOverlay===t.retryOverlay&&e.handleMessageContentChange===t.handleMessageContentChange&&e.getAnimationHandlers===t.getAnimationHandlers&&e.handleHistoryScroll===t.handleHistoryScroll&&e.scrollToBottom===t.scrollToBottom&&e.sessionQuestions===t.sessionQuestions&&e.sessionPermissions===t.sessionPermissions&&e.isProgrammaticFollowActive===t.isProgrammaticFollowActive&&e.showLoadOlderButton===t.showLoadOlderButton&&e.onLoadOlder===t.onLoadOlder&&e.turnIds===t.turnIds&&e.activeTurnId===t.activeTurnId&&e.onSelectTurn===t.onSelectTurn&&e.showPromptNavigator===t.showPromptNavigator&&e.canLoadEarlierPrompts===t.canLoadEarlierPrompts&&e.isLoadingOlderPrompts===t.isLoadingOlderPrompts&&e.onLoadEarlierPrompts===t.onLoadEarlierPrompts);pp.displayName="ChatViewport";const ks=()=>i.jsx("div",{className:"p-3",children:i.jsx("div",{className:"rounded-2xl border border-border/70 bg-[var(--surface-background)] px-4 py-3 typography-ui-label text-muted-foreground",children:"Subagent sessions cannot be prompted."})}),Mz=e=>e.label?.trim()||fi(e.path),Cz=(e,t)=>{if(!t)return e;const n=e.indexOf(t);return n===-1?e:i.jsxs(i.Fragment,{children:[e.slice(0,n),i.jsx("span",{className:"font-medium",children:t}),e.slice(n+t.length)]})},Sz=()=>{const e=Be(n=>n.newSessionDraft.selectedProjectId??null),t=j1(d.useCallback(n=>{const s=e??n.activeProjectId,o=(s?n.projects.find(r=>r.id===s):null)??n.projects[0]??null;return o?Mz(o):null},[e]));return i.jsxs("div",{className:"oc-draft-center flex min-h-0 flex-1 flex-col items-center justify-center px-6 text-center",children:[i.jsx("h1",{className:"text-balance text-3xl font-normal tracking-tight text-foreground",children:Cz(t?`What are we working on in ${t}?`:"What are we working on?",t)}),i.jsx(ph,{onSubmit:n=>R1.getState().requestPresetSubmit(n.submitText,n.ref.type),className:"oc-draft-starters mt-8 max-w-md"})]})},IF=({active:e=!0,autoOpenDraft:t=!0,readOnly:n=!1})=>{const s=Be(ve=>ve.currentSessionId),o=Be(ve=>ve.currentSessionDirectory),r=Be(ve=>ve.openNewSessionDraft),a=Be(ve=>ve.setCurrentSession),l=Be(ve=>ve.newSessionDraft),c=K3(),u=Fw(),f=o??u,h=s?JSON.stringify([We(),f,s]):null,m=d.useCallback(ve=>c.ensureSessionRenderable(ve,!1,f),[f,c]),p=d.useCallback((ve,Te)=>c.loadMore(ve,f),[f,c]),g=he(ve=>ve.isExpandedInput),y=he(ve=>ve.stickyUserHeader),M=he(ve=>ve.promptNavigatorEnabled),b=he(ve=>ve.allowPromptingSubagentSessions),v=he(ve=>ve.isTimelineDialogOpen),x=he(ve=>ve.setTimelineDialogOpen),S=Ww(s??""),C=S?"streaming":null,w=Yw(s??""),_=Zu(s??""),L=Ui(s??""),A=s?L:mz,N=Uw(s??""),[k]=d.useState(ew);d.useEffect(()=>{if(!(!e||!h||!_||A.length===0))return k.schedule(h,A.length)},[e,h,k,_,A.length]);const V=qi(s??"")??pz,H=zw(),D=Dw(),P=d.useMemo(()=>!D.some(ve=>ve.sessionID===s)&&fz(),[s,A,D]);d.useEffect(()=>{if(!(!e||!s||!f||!P))return hz(),()=>{}},[e,s,f,P,c]);const R=d.useMemo(()=>{if(!s||H.length>0||D.length>0)return!1;const ve=V.type??"idle";if(ve==="busy"||ve==="retry")return!0;const Te=A[A.length-1]?.info,Qe=typeof Te?.finish=="string"?Te.finish:void 0;return!!(Te&&Te.role==="assistant"&&typeof Te.time?.completed!="number"&&Qe!=="stop"&&Qe!=="error")},[s,A,H.length,D.length,V.type]),$=d.useMemo(()=>{if(!s||V.type!=="retry")return null;const ve=typeof V.message=="string"?(V.message??"").trim():"";return{sessionId:s,message:ve||gz,confirmedAt:V.confirmedAt}},[s,V]),[O,I]=d.useState(0),q=d.useRef(null);d.useEffect(()=>{if(!$||typeof $.confirmedAt=="number"){q.current=null,I(0);return}q.current!==$.sessionId&&(q.current=$.sessionId,I(Date.now()))},[$]);const G=d.useMemo(()=>$?{...$,fallbackTimestamp:O}:null,[$,O]),K=d.useMemo(()=>s?{limit:A.length,complete:N.complete||!N.cursor,loading:N.status==="loading"}:null,[s,N.complete,N.cursor,N.status,A.length]),{isMobile:W}=c0(),ge=ta(),Z=!!l?.open,fe=Fh(ve=>ve.error),ie=W&&g,E=W||ge==="mini-chat",ce=d.useRef(null),ee=Ow(s),ue=Rw();d.useCallback(()=>{},[ue,a]);const J=null,Y=uz(ee,b,n);d.useEffect(()=>{if(typeof window>"u"||!window.parent||window.parent===window)return;const ve=window.parent,Te=_1=>{he.getState().setAllowPromptingSubagentSessions(_1)},Qe=window,M1=_1=>{Te(_1.allowPromptingSubagentSessions)},C1=_1=>{if(_1.source!==ve||_1.origin!==window.location.origin)return;const m2=_1.data;m2?.type!=="pichamber:chat-settings-sync"||typeof m2.payload?.allowPromptingSubagentSessions!="boolean"||Te(m2.payload.allowPromptingSubagentSessions)};return Qe.__pichamberApplyChatSettingsSync=M1,window.addEventListener("message",C1),ve.postMessage({type:"pichamber:chat-settings-request"},window.location.origin),()=>{window.removeEventListener("message",C1),Qe.__pichamberApplyChatSettingsSync===M1&&delete Qe.__pichamberApplyChatSettingsSync}},[]),d.useEffect(()=>{Iu().sessionId||t&&!s&&!Z&&r({automatic:!0})},[t,s,Z,r]);const oe=d.useRef(()=>{}),te=d.useCallback(ve=>{oe.current(ve)},[]),{scrollRef:pe,notifyContentChange:He,getAnimationHandlers:je,goToBottom:Pe,scrollToBottomOnSend:X,releaseAutoFollow:me,restoreSnapshot:U,isPinned:T,isFollowingProgrammatically:Q,showScrollButton:se}=zE({currentSessionId:s,currentSessionKey:h,sessionMessageCount:w,sessionIsWorking:R,isMobile:W,onActiveTurnChange:te}),le=oz({sessionId:s,sessionKey:h,messages:A,historyMeta:K,scrollRef:pe,messageListRef:ce,loadMoreMessages:p,goToBottom:Pe,releaseAutoFollow:me,isPinned:T,showScrollButton:se}),ne=d.useCallback(()=>{Pe("instant")},[Pe]),Ce=D2()&&le.historySignals.canLoadEarlier,Se=le.loadEarlier,Ae=d.useCallback(()=>{Se({userInitiated:!0})},[Se]);d.useEffect(()=>{oe.current=le.handleActiveTurnChange},[le.handleActiveTurnChange]),d.useEffect(()=>{H.length===0&&D.length===0||He("permission")},[He,H,D]);const Ve=dz({sessionId:s,turnIds:le.turnIds,activeTurnId:le.activeTurnId,scrollToTurn:le.scrollToTurn,scrollToMessage:le.scrollToMessage,resumeToBottom:le.resumeToBottomInstant}),Me=d.useCallback(ve=>{Ve.scrollToTurnId(ve,{behavior:"smooth"})},[Ve]),Ie=le.historySignals.canLoadEarlier,qe=!W&&!ie&&M&&le.turnIds.length>=2;d.useEffect(()=>{qe||he.getState().setPromptNavigatorPanelOpen(!1)},[qe]),d.useEffect(()=>{if(typeof window>"u"||!s)return;const ve=Te=>{const Qe=Te;Qe.detail?.sessionId&&Qe.detail.sessionId!==s||Pe("instant")};return window.addEventListener(n9,ve),()=>{window.removeEventListener(n9,ve)}},[s,Pe]),d.useEffect(()=>{if(typeof window>"u"||!s||ie)return;const ve=Te=>{if(Te.defaultPrevented||Te.isComposing||Te.key!=="ArrowUp"&&Te.key!=="ArrowDown"||Te.altKey||Te.ctrlKey||Te.metaKey||Te.shiftKey)return;const{activeMainTab:Qe}=he.getState();if(Qe!=="chat"||wz())return;const M1=pe.current;if(xz(document.activeElement,M1)||T5(Te.target))return;Te.preventDefault();const C1=Te.key==="ArrowUp"?-1:1;Ve.scrollByTurnOffset(C1,{resumePastEnd:!1})};return window.addEventListener("keydown",ve),()=>{window.removeEventListener("keydown",ve)}},[s,ie,Ve,pe]),d.useLayoutEffect(()=>{const ve=pe.current;if(!ve)return;const Te=()=>{ve.style.setProperty("--chat-scroll-height",`${ve.clientHeight}px`)};Te();let Qe=0;const M1=()=>{Qe||(Qe=requestAnimationFrame(()=>{Qe=0,Te()}))};if(typeof ResizeObserver>"u")return window.addEventListener("resize",M1),()=>{Qe&&cancelAnimationFrame(Qe),window.removeEventListener("resize",M1)};const C1=new ResizeObserver(M1);return C1.observe(ve),()=>{Qe&&cancelAnimationFrame(Qe),C1.disconnect()}},[s,ie,pe]);const n1=d.useRef(null),Le=!!s&&(!!s&&!_||N.status==="loading"),xe=d.useCallback(()=>{!e||!s||c.ensureSessionRenderable(s,!0,f)},[e,s,f,c]);return d.useEffect(()=>{if(!e||!s||n1.current===h)return;const ve=typeof window<"u"&&window.location.hash.length>0;if(n1.current=h,ve){me();return}const Te=()=>{U()};typeof window>"u"?Te():window.requestAnimationFrame(Te)},[e,s,h,me,U]),d.useEffect(()=>{!e||!s||_||m(s)},[e,s,m,_]),!s&&!Z?t&&!fe?i.jsx("div",{className:"flex h-full flex-col bg-background"}):i.jsx("div",{className:"flex flex-col h-full bg-background",children:i.jsx(x7,{isNewSession:!0})}):!s&&Z?i.jsxs("div",{"data-composer-bound":!0,className:"relative flex h-full flex-col bg-background",children:[E&&!ie?i.jsx(Sz,{}):null,i.jsx("div",{className:B("relative z-10 flex min-h-0",ie?"flex-1 bg-background":E?"shrink-0 bg-background px-0":"flex-1 items-center justify-center bg-background px-0 pb-[6vh]"),children:Y?i.jsx(ks,{}):i.jsx(bs,{scrollToBottom:X})})]}):s?Le?N.status==="error"?i.jsxs("div",{"data-composer-bound":!0,className:"relative flex h-full flex-col bg-background",children:[J,i.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-6",children:i.jsxs("div",{className:"max-w-sm text-center",children:[i.jsx("div",{className:"mx-auto mb-3 flex size-9 items-center justify-center rounded-full bg-[color-mix(in_srgb,var(--status-error)_10%,transparent)] text-[var(--status-error)]",children:i.jsx(z,{name:"error-warning",className:"size-4"})}),i.jsx("p",{className:"typography-ui-label font-medium text-foreground",children:"Session could not be loaded"}),i.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:"Check the connection and try loading this session again."}),i.jsx(a1,{variant:"outline",size:"sm",className:"mt-4",onClick:xe,children:"Try again"})]})}),i.jsx("div",{className:xr(!1),children:Y?i.jsx(ks,{}):i.jsx(bs,{scrollToBottom:X})})]}):i.jsxs("div",{"data-composer-bound":!0,className:"relative flex flex-col h-full bg-background",children:[J,i.jsx("div",{className:B("relative min-h-0 flex items-center justify-center",ie?"absolute inset-0 opacity-0 pointer-events-none":"flex-1"),"aria-hidden":ie,children:i.jsx(R3,{width:120,height:120,isAnimated:!0})}),i.jsx("div",{className:xr(ie),children:Y?i.jsx(ks,{}):i.jsx(bs,{scrollToBottom:X})})]}):A.length===0&&!R?i.jsxs("div",{"data-composer-bound":!0,className:"relative flex flex-col h-full bg-background",children:[J,i.jsx("div",{className:B("relative min-h-0",ie?"absolute inset-0 opacity-0 pointer-events-none":"flex-1"),"aria-hidden":ie,children:ie?null:i.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:i.jsx(x7,{isNewSession:!1})})}),i.jsx("div",{className:xr(ie),children:Y?i.jsx(ks,{}):i.jsx(bs,{scrollToBottom:X})})]}):i.jsxs("div",{"data-composer-bound":!0,className:"relative flex min-w-0 flex-1 flex-col h-full bg-background",children:[J,i.jsx(pp,{currentSessionId:s,currentSessionKey:h??s,isDesktopExpandedInput:ie,isMobile:W,stickyUserHeader:y,directory:f,scrollRef:pe,messageListRef:ce,pendingRevealWork:le.pendingRevealWork,renderedMessages:le.renderedMessages,isLoadingOlder:le.isLoadingOlder,sessionIsWorking:R,streamingMessageId:S,activeStreamingPhase:C,retryOverlay:G,handleMessageContentChange:He,getAnimationHandlers:je,handleHistoryScroll:le.handleHistoryScroll,scrollToBottom:ne,sessionQuestions:D,sessionPermissions:H,isProgrammaticFollowActive:Q,showLoadOlderButton:Ce,onLoadOlder:Ae,turnIds:le.turnIds,activeTurnId:le.activeTurnId,onSelectTurn:Me,showPromptNavigator:qe,canLoadEarlierPrompts:Ie,isLoadingOlderPrompts:le.isLoadingOlder,onLoadEarlierPrompts:Ae}),i.jsxs("div",{className:xr(ie),children:[!ie&&A.length>0&&i.jsx(lE,{visible:le.showScrollToBottom,onClick:Ve.resumeToLatest}),Y?i.jsx(ks,{}):i.jsx(bs,{scrollToBottom:X})]}),i.jsx(iz,{open:v,onOpenChange:x,onScrollToMessage:le.scrollToMessage,onScrollByTurnOffset:Ve.scrollByTurnOffset,onResumeToLatest:ne,canLoadEarlier:le.historySignals.canLoadEarlier,isLoadingEarlier:le.isLoadingOlder,onLoadEarlier:Ae,onRevert:async ve=>{if(!s)return;const Te=ve.includes(":")?ve.split(":")[0]??ve:ve;await Be.getState().revertToMessage(s,Te)},onFork:async ve=>{if(!s)return;const Te=ve.includes(":")?ve.split(":")[0]??ve:ve;await Be.getState().forkFromMessage(s,Te)}})]}):null};function _z({className:e,...t}){return i.jsx("div",{"data-slot":"card",className:B("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-none",e),...t})}function kz({className:e,...t}){return i.jsx("div",{"data-slot":"card-header",className:B("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...t})}function Az({className:e,...t}){return i.jsx("div",{"data-slot":"card-title",className:B("leading-none font-semibold",e),...t})}function Hz({className:e,...t}){return i.jsx("div",{"data-slot":"card-content",className:B("px-6",e),...t})}class Lz extends d.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){this.setState({error:t,errorInfo:n,copied:!1}),console.error("Error caught by boundary:",t,n)}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};handleCopy=async()=>{const{strings:t}=this.props,n=this.state.error?String(this.state.error):t.unknownError,s=this.state.error?.stack?`
7034
7034
 
7035
7035
  Stack: