@agi-cli/web-ui 0.1.49 → 0.1.51

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.
@@ -261,7 +261,7 @@ Error generating stack: `+s.message+`
261
261
  *
262
262
  * This source code is licensed under the ISC license.
263
263
  * See the LICENSE file in the root directory of this source tree.
264
- */const P0=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Qh=Ae("x",P0),Ot=te.forwardRef(({className:e="",variant:n="primary",size:a="md",...i},l)=>{const u="inline-flex items-center justify-center rounded font-medium transition-colors focus-visible:outline-none disabled:opacity-50 disabled:cursor-not-allowed",c={primary:"bg-primary text-primary-foreground hover:bg-primary/90",secondary:"bg-muted text-foreground hover:bg-muted/80 border border-border",ghost:"text-muted-foreground hover:text-foreground hover:bg-muted/50"},d={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-sm",lg:"px-6 py-3 text-base",icon:"w-10 h-10 p-0"};return y.jsx("button",{ref:l,className:`${u} ${c[n]} ${d[a]} ${e}`,...i})});Ot.displayName="Button";const G0=te.memo(function({theme:n,onToggleTheme:a}){return y.jsxs("header",{className:"h-14 border-b border-border bg-background px-4 flex items-center justify-between",children:[y.jsx("h1",{className:"text-lg font-semibold text-foreground",children:"AGI"}),y.jsx("div",{className:"flex items-center gap-2",children:y.jsx(Ot,{variant:"ghost",size:"icon",onClick:a,title:`Switch to ${n==="dark"?"light":"dark"} mode`,"aria-label":`Switch to ${n==="dark"?"light":"dark"} mode`,children:n==="dark"?y.jsx(B0,{className:"w-4 h-4"}):y.jsx(R0,{className:"w-4 h-4"})})})]})}),Wv=e=>{let n;const a=new Set,i=(g,b)=>{const h=typeof g=="function"?g(n):g;if(!Object.is(h,n)){const E=n;n=b??(typeof h!="object"||h===null)?h:Object.assign({},n,h),a.forEach(S=>S(n,E))}},l=()=>n,d={setState:i,getState:l,getInitialState:()=>f,subscribe:g=>(a.add(g),()=>a.delete(g))},f=n=e(i,l,d);return d},H0=(e=>e?Wv(e):Wv),$0=e=>e;function V0(e,n=$0){const a=En.useSyncExternalStore(e.subscribe,En.useCallback(()=>n(e.getState()),[e,n]),En.useCallback(()=>n(e.getInitialState()),[e,n]));return En.useDebugValue(a),a}const Xv=e=>{const n=H0(e),a=i=>V0(n,i);return Object.assign(a,n),a},Ww=(e=>e?Xv(e):Xv),tn=Ww(e=>({isExpanded:!1,selectedFile:null,selectedFileStaged:!1,isDiffOpen:!1,isCommitModalOpen:!1,wasSessionListCollapsed:!1,toggleSidebar:()=>e(n=>({isExpanded:!n.isExpanded})),expandSidebar:()=>e({isExpanded:!0}),collapseSidebar:()=>e({isExpanded:!1,isDiffOpen:!1,selectedFile:null}),openDiff:(n,a)=>e({selectedFile:n,selectedFileStaged:a,isDiffOpen:!0,isExpanded:!0}),closeDiff:()=>e({isDiffOpen:!1,selectedFile:null}),switchFile:(n,a)=>e({selectedFile:n,selectedFileStaged:a}),openCommitModal:()=>e({isCommitModalOpen:!0}),closeCommitModal:()=>e({isCommitModalOpen:!1}),setSessionListCollapsed:n=>e({wasSessionListCollapsed:n})}));function Y0(e,n){let a;try{a=e()}catch{return}return{getItem:l=>{var u;const c=f=>f===null?null:JSON.parse(f,void 0),d=(u=a.getItem(l))!=null?u:null;return d instanceof Promise?d.then(c):c(d)},setItem:(l,u)=>a.setItem(l,JSON.stringify(u,void 0)),removeItem:l=>a.removeItem(l)}}const Ih=e=>n=>{try{const a=e(n);return a instanceof Promise?a:{then(i){return Ih(i)(a)},catch(i){return this}}}catch(a){return{then(i){return this},catch(i){return Ih(i)(a)}}}},K0=(e,n)=>(a,i,l)=>{let u={storage:Y0(()=>localStorage),partialize:x=>x,version:0,merge:(x,C)=>({...C,...x}),...n},c=!1;const d=new Set,f=new Set;let g=u.storage;if(!g)return e((...x)=>{console.warn(`[zustand persist middleware] Unable to update item '${u.name}', the given storage is currently unavailable.`),a(...x)},i,l);const b=()=>{const x=u.partialize({...i()});return g.setItem(u.name,{state:x,version:u.version})},h=l.setState;l.setState=(x,C)=>(h(x,C),b());const E=e((...x)=>(a(...x),b()),i,l);l.getInitialState=()=>E;let S;const _=()=>{var x,C;if(!g)return;c=!1,d.forEach(A=>{var N;return A((N=i())!=null?N:E)});const T=((C=u.onRehydrateStorage)==null?void 0:C.call(u,(x=i())!=null?x:E))||void 0;return Ih(g.getItem.bind(g))(u.name).then(A=>{if(A)if(typeof A.version=="number"&&A.version!==u.version){if(u.migrate){const N=u.migrate(A.state,A.version);return N instanceof Promise?N.then(L=>[!0,L]):[!0,N]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,A.state];return[!1,void 0]}).then(A=>{var N;const[L,U]=A;if(S=u.merge(U,(N=i())!=null?N:E),a(S,!0),L)return b()}).then(()=>{T?.(S,void 0),S=i(),c=!0,f.forEach(A=>A(S))}).catch(A=>{T?.(void 0,A)})};return l.persist={setOptions:x=>{u={...u,...x},x.storage&&(g=x.storage)},clearStorage:()=>{g?.removeItem(u.name)},getOptions:()=>u,rehydrate:()=>_(),hasHydrated:()=>c,onHydrate:x=>(d.add(x),()=>{d.delete(x)}),onFinishHydration:x=>(f.add(x),()=>{f.delete(x)})},u.skipHydration||_(),S||E},W0=K0,Ja=Ww()(W0(e=>({isCollapsed:!1,wasCollapsedBeforeDiff:null,toggleCollapse:()=>e(n=>({isCollapsed:!n.isCollapsed})),setCollapsed:n=>e({isCollapsed:n}),setWasCollapsedBeforeDiff:n=>e({wasCollapsedBeforeDiff:n})}),{name:"sidebar-storage",partialize:e=>({isCollapsed:e.isCollapsed})})),X0=te.memo(function({children:n,onNewSession:a}){const i=tn(c=>c.isDiffOpen),l=Ja(c=>c.isCollapsed),u=Ja(c=>c.toggleCollapse);return l?y.jsxs("aside",{className:"w-12 border-r border-border bg-background flex flex-col transition-all duration-300 ease-in-out",children:[y.jsx("div",{className:"h-14 border-b border-border flex items-center justify-center",children:y.jsx(Ot,{variant:"ghost",size:"icon",onClick:a,title:"New session",className:"rounded-full",children:y.jsx(Yv,{className:"w-4 h-4"})})}),y.jsx("div",{className:"flex-1 cursor-pointer hover:bg-muted/50 transition-colors",onClick:i?void 0:u,title:i?void 0:"Expand sidebar"}),y.jsx("div",{className:"border-t border-border p-2 flex items-center justify-center",children:y.jsx(Ot,{variant:"ghost",size:"icon",onClick:u,title:"Expand sidebar",disabled:i,className:"transition-transform duration-200 hover:scale-110",children:y.jsx(_n,{className:"w-4 h-4"})})})]}):y.jsxs("aside",{className:"w-64 border-r border-border bg-background flex flex-col transition-all duration-300 ease-in-out",children:[y.jsx("div",{className:"h-14 border-b border-border px-4 flex items-center",children:y.jsxs(Ot,{variant:"primary",size:"sm",onClick:a,className:"flex-1",children:[y.jsx(Yv,{className:"w-4 h-4 mr-2"}),"New Session"]})}),y.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-hide",children:n}),y.jsx("div",{className:"border-t border-border p-2 flex items-center justify-end",children:y.jsx(Ot,{variant:"ghost",size:"icon",onClick:u,title:"Collapse sidebar",disabled:i,className:"transition-transform duration-200 hover:scale-110",children:y.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"transition-transform duration-300",role:"img","aria-label":"Collapse sidebar",children:[y.jsx("title",{children:"Collapse sidebar"}),y.jsx("path",{d:"M15 18l-6-6 6-6"})]})})})]})});function Z0(){const e=window;return e.AGI_SERVER_URL?e.AGI_SERVER_URL:e.__AGI_API_URL__?e.__AGI_API_URL__:"http://localhost:9100"}const Xw=Z0();class Q0{get baseUrl(){const n=window;return n.AGI_SERVER_URL?n.AGI_SERVER_URL:Xw}async request(n,a){const i=`${this.baseUrl}${n}`,l=await fetch(i,{...a,headers:{"Content-Type":"application/json",...a?.headers}});if(!l.ok){const u=await l.json().catch(()=>({error:"Unknown error"}));throw new Error(u.error||`HTTP ${l.status}`)}return l.json()}async getSessions(){return this.request("/v1/sessions")}async createSession(n){return this.request("/v1/sessions",{method:"POST",body:JSON.stringify(n)})}async abortSession(n){return this.request(`/v1/sessions/${n}/abort`,{method:"DELETE"})}async getMessages(n){return this.request(`/v1/sessions/${n}/messages`)}async sendMessage(n,a){return this.request(`/v1/sessions/${n}/messages`,{method:"POST",body:JSON.stringify(a)})}getStreamUrl(n){return`${this.baseUrl}/v1/sessions/${n}/stream`}async getConfig(){return this.request("/v1/config")}async getModels(n){return this.request(`/v1/config/providers/${n}/models`)}async getGitStatus(){return(await this.request("/v1/git/status")).data}async getGitDiff(n,a=!1){const i=new URLSearchParams({file:n,staged:String(a)});return(await this.request(`/v1/git/diff?${i}`)).data}async generateCommitMessage(){return(await this.request("/v1/git/generate-commit-message",{method:"POST",body:JSON.stringify({})})).data}async stageFiles(n){return(await this.request("/v1/git/stage",{method:"POST",body:JSON.stringify({files:n})})).data}async unstageFiles(n){return(await this.request("/v1/git/unstage",{method:"POST",body:JSON.stringify({files:n})})).data}async commitChanges(n){return(await this.request("/v1/git/commit",{method:"POST",body:JSON.stringify({message:n})})).data}async getGitBranch(){return(await this.request("/v1/git/branch")).data}}const Ht=new Q0;function Zw(){const e=tn(n=>n.isExpanded);return ai({queryKey:["git","status"],queryFn:()=>Ht.getGitStatus(),refetchInterval:e?5e3:!1,retry:1,staleTime:3e3})}function J0(e,n=!1){return ai({queryKey:["git","diff",e,n],queryFn:()=>e?Ht.getGitDiff(e,n):null,enabled:!!e,retry:1,refetchInterval:!1})}function eL(){return ii({mutationFn:()=>Ht.generateCommitMessage()})}function Qw(){const e=or();return ii({mutationFn:n=>Ht.stageFiles(n),onSuccess:()=>{e.invalidateQueries({queryKey:["git","status"]})}})}function tL(){const e=or();return ii({mutationFn:n=>Ht.unstageFiles(n),onSuccess:()=>{e.invalidateQueries({queryKey:["git","status"]})}})}function nL(){const e=or();return ii({mutationFn:n=>Ht.commitChanges(n),onSuccess:()=>{e.invalidateQueries({queryKey:["git","status"]}),e.invalidateQueries({queryKey:["git","branch"]})}})}const rL=te.memo(function(){const n=tn(u=>u.isExpanded),a=tn(u=>u.toggleSidebar),{data:i}=Zw();if(n)return null;const l=(i?.staged?.length??0)+(i?.unstaged?.length??0)+(i?.untracked?.length??0);return y.jsx("div",{className:"w-12 border-l border-border bg-background flex flex-col items-center py-4",children:y.jsxs("button",{type:"button",onClick:a,className:"relative p-2 rounded hover:bg-muted transition-colors",title:"Open Git sidebar",children:[y.jsx(Pl,{className:"w-5 h-5 text-muted-foreground"}),l>0&&y.jsx("span",{className:"absolute -top-1 -right-1 w-5 h-5 bg-primary text-primary-foreground text-xs rounded-full flex items-center justify-center font-semibold",children:l>9?"9+":l})]})})});function xc({file:e,staged:n,showModifiedIndicator:a=!1}){const{openDiff:i}=tn(),l=Qw(),u=tL(),[c,d]=te.useState(n),f=async x=>{x.stopPropagation();const C=x.target.checked;d(C);try{C?await l.mutateAsync([e.path]):await u.mutateAsync([e.path])}catch(T){d(!C),console.error("Failed to stage/unstage file:",T)}},g=()=>{i(e.path,n)},h=(()=>{switch(e.status){case"added":case"untracked":return{icon:l0,color:"text-green-500",label:"A",labelColor:"text-green-500"};case"deleted":return{icon:d0,color:"text-red-500",label:"D",labelColor:"text-red-500"};case"modified":return{icon:Ul,color:"text-blue-500",label:"M",labelColor:"text-blue-500"};case"renamed":return{icon:Ul,color:"text-purple-500",label:"R",labelColor:"text-purple-500"};default:return{icon:Ul,color:"text-muted-foreground",label:"?",labelColor:"text-muted-foreground"}}})(),E=h.icon,_=(x=>{const C=x.split("/"),T=C[C.length-1];return C.length===1?T:`../${C[C.length-2]}/${T}`})(e.path);return y.jsxs("button",{type:"button",className:"flex items-center gap-2 px-3 py-2 hover:bg-muted/50 cursor-pointer group transition-colors w-full text-left",onClick:g,children:[y.jsx("input",{type:"checkbox",checked:c,onChange:f,onClick:x=>x.stopPropagation(),className:"w-4 h-4 rounded border-border","aria-label":`${c?"Unstage":"Stage"} ${e.path}`}),y.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[y.jsx(E,{className:`w-4 h-4 flex-shrink-0 ${h.color}`}),y.jsx("div",{className:"flex-1 min-w-0",children:y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"text-sm text-foreground truncate font-mono",title:e.path,children:_}),y.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[y.jsx("span",{className:`text-xs font-semibold ${h.labelColor}`,children:h.label}),a&&y.jsx("div",{title:"Also modified in working directory",children:y.jsx($w,{className:"w-3.5 h-3.5 text-orange-500"})})]})]})})]}),e.insertions!==void 0||e.deletions!==void 0?y.jsxs("div",{className:"flex items-center gap-2 text-xs flex-shrink-0",children:[e.insertions!==void 0&&e.insertions>0&&y.jsxs("span",{className:"text-green-500",children:["+",e.insertions]}),e.deletions!==void 0&&e.deletions>0&&y.jsxs("span",{className:"text-red-500",children:["-",e.deletions]})]}):null,n&&!a&&y.jsx(Hw,{className:"w-4 h-4 text-green-500 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]})}function aL({status:e}){const{openCommitModal:n}=tn(),a=Qw(),i=e.staged.length>0,l=e.unstaged.length>0||e.untracked.length>0,u=[...e.unstaged,...e.untracked],c=u.length>0,d=new Set(e.unstaged.map(g=>g.path)),f=()=>{const g=u.map(b=>b.path);g.length>0&&a.mutate(g)};return y.jsxs("div",{className:"flex flex-col",children:[i&&y.jsxs("div",{className:"border-b border-border",children:[y.jsxs("div",{className:"px-4 py-2 bg-muted/50 flex items-center justify-between",children:[y.jsxs("span",{className:"text-xs font-semibold text-foreground uppercase",children:["Staged Changes (",e.staged.length,")"]}),e.staged.length>0&&y.jsxs(Ot,{variant:"primary",size:"sm",onClick:n,className:"h-6 text-xs",children:[y.jsx(Gl,{className:"w-3 h-3 mr-1"}),"Commit"]})]}),y.jsx("div",{className:"divide-y divide-border",children:e.staged.map(g=>y.jsx(xc,{file:g,staged:!0,showModifiedIndicator:d.has(g.path)},g.path))})]}),l&&y.jsxs("div",{children:[y.jsxs("div",{className:"px-4 py-2 bg-muted/50 flex items-center justify-between",children:[y.jsxs("span",{className:"text-xs font-semibold text-foreground uppercase",children:["Changes (",e.unstaged.length+e.untracked.length,")"]}),c&&y.jsxs(Ot,{variant:"ghost",size:"sm",onClick:f,title:"Stage all changes",className:"h-6 text-xs",children:[y.jsx(U0,{className:"w-3 h-3 mr-1"}),"Stage All"]})]}),y.jsxs("div",{className:"divide-y divide-border",children:[e.unstaged.map(g=>y.jsx(xc,{file:g,staged:!1},g.path)),e.untracked.map(g=>y.jsx(xc,{file:g,staged:!1},g.path))]})]}),!i&&!l&&y.jsx("div",{className:"p-4 text-sm text-muted-foreground text-center",children:"No changes"})]})}const iL=te.memo(function(){const n=tn(b=>b.isExpanded),a=tn(b=>b.collapseSidebar),{data:i,isLoading:l,refetch:u}=Zw(),c=or();te.useEffect(()=>{n&&c.invalidateQueries({queryKey:["git","status"]})},[n,c]);const d=()=>{u()};if(!n)return null;const g=[...i?.staged||[],...i?.unstaged||[],...i?.untracked||[]].length;return y.jsxs("div",{className:"w-80 border-l border-border bg-background flex flex-col h-full",children:[y.jsxs("div",{className:"h-14 border-b border-border px-4 flex items-center justify-between",children:[y.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[y.jsx(Pl,{className:"w-4 h-4 text-muted-foreground"}),y.jsxs("span",{className:"font-medium text-foreground",children:["Git Changes",g>0&&y.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",g,")"]})]})]}),y.jsx(Ot,{variant:"ghost",size:"icon",onClick:a,title:"Close sidebar",children:y.jsx(_n,{className:"w-4 h-4"})})]}),y.jsx("div",{className:"flex-1 overflow-y-auto",children:l?y.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading git status..."}):!i||g===0?y.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"No changes detected"}):y.jsx(aL,{status:i})}),i?.branch&&y.jsxs("div",{className:"border-t border-border px-4 py-2 text-xs text-muted-foreground flex items-center justify-between",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(Pl,{className:"w-3 h-3"}),y.jsx("span",{children:i.branch}),i.ahead>0&&y.jsxs("span",{className:"text-green-500",children:["↑",i.ahead]}),i.behind>0&&y.jsxs("span",{className:"text-orange-500",children:["↓",i.behind]})]}),y.jsx(Ot,{variant:"ghost",size:"icon",onClick:d,title:"Refresh git status",className:"h-6 w-6 transition-transform duration-200 hover:scale-110",disabled:l,children:y.jsx(I0,{className:`w-3 h-3 ${l?"animate-spin":""}`})})]})]})});function oL(e,n){if(e==null)return{};var a={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(n.indexOf(i)!==-1)continue;a[i]=e[i]}return a}function lL(e,n){if(e==null)return{};var a,i,l=oL(e,n);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(i=0;i<u.length;i++)a=u[i],n.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(l[a]=e[a])}return l}function Oh(e,n){(n==null||n>e.length)&&(n=e.length);for(var a=0,i=Array(n);a<n;a++)i[a]=e[a];return i}function sL(e){if(Array.isArray(e))return Oh(e)}function uL(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function cL(e,n){if(e){if(typeof e=="string")return Oh(e,n);var a={}.toString.call(e).slice(8,-1);return a==="Object"&&e.constructor&&(a=e.constructor.name),a==="Map"||a==="Set"?Array.from(e):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?Oh(e,n):void 0}}function dL(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
264
+ */const P0=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Qh=Ae("x",P0),Ot=te.forwardRef(({className:e="",variant:n="primary",size:a="md",...i},l)=>{const u="inline-flex items-center justify-center rounded font-medium transition-colors focus-visible:outline-none disabled:opacity-50 disabled:cursor-not-allowed",c={primary:"bg-primary text-primary-foreground hover:bg-primary/90",secondary:"bg-muted text-foreground hover:bg-muted/80 border border-border",ghost:"text-muted-foreground hover:text-foreground hover:bg-muted/50"},d={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-sm",lg:"px-6 py-3 text-base",icon:"w-10 h-10 p-0"};return y.jsx("button",{ref:l,className:`${u} ${c[n]} ${d[a]} ${e}`,...i})});Ot.displayName="Button";const G0=te.memo(function({theme:n,onToggleTheme:a}){return y.jsxs("header",{className:"h-14 border-b border-border bg-background px-4 flex items-center justify-between",children:[y.jsx("h1",{className:"text-lg font-semibold text-foreground",children:"AGI"}),y.jsx("div",{className:"flex items-center gap-2",children:y.jsx(Ot,{variant:"ghost",size:"icon",onClick:a,title:`Switch to ${n==="dark"?"light":"dark"} mode`,"aria-label":`Switch to ${n==="dark"?"light":"dark"} mode`,children:n==="dark"?y.jsx(B0,{className:"w-4 h-4"}):y.jsx(R0,{className:"w-4 h-4"})})})]})}),Wv=e=>{let n;const a=new Set,i=(g,b)=>{const h=typeof g=="function"?g(n):g;if(!Object.is(h,n)){const E=n;n=b??(typeof h!="object"||h===null)?h:Object.assign({},n,h),a.forEach(S=>S(n,E))}},l=()=>n,d={setState:i,getState:l,getInitialState:()=>f,subscribe:g=>(a.add(g),()=>a.delete(g))},f=n=e(i,l,d);return d},H0=(e=>e?Wv(e):Wv),$0=e=>e;function V0(e,n=$0){const a=En.useSyncExternalStore(e.subscribe,En.useCallback(()=>n(e.getState()),[e,n]),En.useCallback(()=>n(e.getInitialState()),[e,n]));return En.useDebugValue(a),a}const Xv=e=>{const n=H0(e),a=i=>V0(n,i);return Object.assign(a,n),a},Ww=(e=>e?Xv(e):Xv),tn=Ww(e=>({isExpanded:!1,selectedFile:null,selectedFileStaged:!1,isDiffOpen:!1,isCommitModalOpen:!1,wasSessionListCollapsed:!1,toggleSidebar:()=>e(n=>({isExpanded:!n.isExpanded})),expandSidebar:()=>e({isExpanded:!0}),collapseSidebar:()=>e({isExpanded:!1,isDiffOpen:!1,selectedFile:null}),openDiff:(n,a)=>e({selectedFile:n,selectedFileStaged:a,isDiffOpen:!0,isExpanded:!0}),closeDiff:()=>e({isDiffOpen:!1,selectedFile:null}),switchFile:(n,a)=>e({selectedFile:n,selectedFileStaged:a}),openCommitModal:()=>e({isCommitModalOpen:!0}),closeCommitModal:()=>e({isCommitModalOpen:!1}),setSessionListCollapsed:n=>e({wasSessionListCollapsed:n})}));function Y0(e,n){let a;try{a=e()}catch{return}return{getItem:l=>{var u;const c=f=>f===null?null:JSON.parse(f,void 0),d=(u=a.getItem(l))!=null?u:null;return d instanceof Promise?d.then(c):c(d)},setItem:(l,u)=>a.setItem(l,JSON.stringify(u,void 0)),removeItem:l=>a.removeItem(l)}}const Ih=e=>n=>{try{const a=e(n);return a instanceof Promise?a:{then(i){return Ih(i)(a)},catch(i){return this}}}catch(a){return{then(i){return this},catch(i){return Ih(i)(a)}}}},K0=(e,n)=>(a,i,l)=>{let u={storage:Y0(()=>localStorage),partialize:x=>x,version:0,merge:(x,C)=>({...C,...x}),...n},c=!1;const d=new Set,f=new Set;let g=u.storage;if(!g)return e((...x)=>{console.warn(`[zustand persist middleware] Unable to update item '${u.name}', the given storage is currently unavailable.`),a(...x)},i,l);const b=()=>{const x=u.partialize({...i()});return g.setItem(u.name,{state:x,version:u.version})},h=l.setState;l.setState=(x,C)=>(h(x,C),b());const E=e((...x)=>(a(...x),b()),i,l);l.getInitialState=()=>E;let S;const _=()=>{var x,C;if(!g)return;c=!1,d.forEach(A=>{var N;return A((N=i())!=null?N:E)});const T=((C=u.onRehydrateStorage)==null?void 0:C.call(u,(x=i())!=null?x:E))||void 0;return Ih(g.getItem.bind(g))(u.name).then(A=>{if(A)if(typeof A.version=="number"&&A.version!==u.version){if(u.migrate){const N=u.migrate(A.state,A.version);return N instanceof Promise?N.then(L=>[!0,L]):[!0,N]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,A.state];return[!1,void 0]}).then(A=>{var N;const[L,U]=A;if(S=u.merge(U,(N=i())!=null?N:E),a(S,!0),L)return b()}).then(()=>{T?.(S,void 0),S=i(),c=!0,f.forEach(A=>A(S))}).catch(A=>{T?.(void 0,A)})};return l.persist={setOptions:x=>{u={...u,...x},x.storage&&(g=x.storage)},clearStorage:()=>{g?.removeItem(u.name)},getOptions:()=>u,rehydrate:()=>_(),hasHydrated:()=>c,onHydrate:x=>(d.add(x),()=>{d.delete(x)}),onFinishHydration:x=>(f.add(x),()=>{f.delete(x)})},u.skipHydration||_(),S||E},W0=K0,Ja=Ww()(W0(e=>({isCollapsed:!1,wasCollapsedBeforeDiff:null,toggleCollapse:()=>e(n=>({isCollapsed:!n.isCollapsed})),setCollapsed:n=>e({isCollapsed:n}),setWasCollapsedBeforeDiff:n=>e({wasCollapsedBeforeDiff:n})}),{name:"sidebar-storage",partialize:e=>({isCollapsed:e.isCollapsed})})),X0=te.memo(function({children:n,onNewSession:a}){const i=tn(c=>c.isDiffOpen),l=Ja(c=>c.isCollapsed),u=Ja(c=>c.toggleCollapse);return l?y.jsxs("aside",{className:"w-12 border-r border-border bg-background flex flex-col transition-all duration-300 ease-in-out",children:[y.jsx("div",{className:"h-14 border-b border-border flex items-center justify-center",children:y.jsx(Ot,{variant:"ghost",size:"icon",onClick:a,title:"New session",className:"rounded-full",children:y.jsx(Yv,{className:"w-4 h-4"})})}),y.jsx("button",{type:"button",className:"flex-1 cursor-pointer hover:bg-muted/50 transition-colors",onClick:i?void 0:u,title:i?void 0:"Expand sidebar","aria-label":"Expand sidebar"}),y.jsx("div",{className:"border-t border-border p-2 flex items-center justify-center",children:y.jsx(Ot,{variant:"ghost",size:"icon",onClick:u,title:"Expand sidebar",disabled:i,className:"transition-transform duration-200 hover:scale-110",children:y.jsx(_n,{className:"w-4 h-4"})})})]}):y.jsxs("aside",{className:"w-64 border-r border-border bg-background flex flex-col transition-all duration-300 ease-in-out",children:[y.jsx("div",{className:"h-14 border-b border-border px-4 flex items-center",children:y.jsxs(Ot,{variant:"primary",size:"sm",onClick:a,className:"flex-1",children:[y.jsx(Yv,{className:"w-4 h-4 mr-2"}),"New Session"]})}),y.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-hide",children:n}),y.jsx("div",{className:"border-t border-border p-2 flex items-center justify-end",children:y.jsx(Ot,{variant:"ghost",size:"icon",onClick:u,title:"Collapse sidebar",disabled:i,className:"transition-transform duration-200 hover:scale-110",children:y.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"transition-transform duration-300",role:"img","aria-label":"Collapse sidebar",children:[y.jsx("title",{children:"Collapse sidebar"}),y.jsx("path",{d:"M15 18l-6-6 6-6"})]})})})]})});function Z0(){const e=window;return e.AGI_SERVER_URL?e.AGI_SERVER_URL:e.__AGI_API_URL__?e.__AGI_API_URL__:"http://localhost:9100"}const Xw=Z0();class Q0{get baseUrl(){const n=window;return n.AGI_SERVER_URL?n.AGI_SERVER_URL:Xw}async request(n,a){const i=`${this.baseUrl}${n}`,l=await fetch(i,{...a,headers:{"Content-Type":"application/json",...a?.headers}});if(!l.ok){const u=await l.json().catch(()=>({error:"Unknown error"}));throw new Error(u.error||`HTTP ${l.status}`)}return l.json()}async getSessions(){return this.request("/v1/sessions")}async createSession(n){return this.request("/v1/sessions",{method:"POST",body:JSON.stringify(n)})}async abortSession(n){return this.request(`/v1/sessions/${n}/abort`,{method:"DELETE"})}async getMessages(n){return this.request(`/v1/sessions/${n}/messages`)}async sendMessage(n,a){return this.request(`/v1/sessions/${n}/messages`,{method:"POST",body:JSON.stringify(a)})}getStreamUrl(n){return`${this.baseUrl}/v1/sessions/${n}/stream`}async getConfig(){return this.request("/v1/config")}async getModels(n){return this.request(`/v1/config/providers/${n}/models`)}async getGitStatus(){return(await this.request("/v1/git/status")).data}async getGitDiff(n,a=!1){const i=new URLSearchParams({file:n,staged:String(a)});return(await this.request(`/v1/git/diff?${i}`)).data}async generateCommitMessage(){return(await this.request("/v1/git/generate-commit-message",{method:"POST",body:JSON.stringify({})})).data}async stageFiles(n){return(await this.request("/v1/git/stage",{method:"POST",body:JSON.stringify({files:n})})).data}async unstageFiles(n){return(await this.request("/v1/git/unstage",{method:"POST",body:JSON.stringify({files:n})})).data}async commitChanges(n){return(await this.request("/v1/git/commit",{method:"POST",body:JSON.stringify({message:n})})).data}async getGitBranch(){return(await this.request("/v1/git/branch")).data}}const Ht=new Q0;function Zw(){const e=tn(n=>n.isExpanded);return ai({queryKey:["git","status"],queryFn:()=>Ht.getGitStatus(),refetchInterval:e?5e3:!1,retry:1,staleTime:3e3})}function J0(e,n=!1){return ai({queryKey:["git","diff",e,n],queryFn:()=>e?Ht.getGitDiff(e,n):null,enabled:!!e,retry:1,refetchInterval:!1})}function eL(){return ii({mutationFn:()=>Ht.generateCommitMessage()})}function Qw(){const e=or();return ii({mutationFn:n=>Ht.stageFiles(n),onSuccess:()=>{e.invalidateQueries({queryKey:["git","status"]})}})}function tL(){const e=or();return ii({mutationFn:n=>Ht.unstageFiles(n),onSuccess:()=>{e.invalidateQueries({queryKey:["git","status"]})}})}function nL(){const e=or();return ii({mutationFn:n=>Ht.commitChanges(n),onSuccess:()=>{e.invalidateQueries({queryKey:["git","status"]}),e.invalidateQueries({queryKey:["git","branch"]})}})}const rL=te.memo(function(){const n=tn(u=>u.isExpanded),a=tn(u=>u.toggleSidebar),{data:i}=Zw();if(n)return null;const l=(i?.staged?.length??0)+(i?.unstaged?.length??0)+(i?.untracked?.length??0);return y.jsx("div",{className:"w-12 border-l border-border bg-background flex flex-col items-center py-4",children:y.jsxs("button",{type:"button",onClick:a,className:"relative p-2 rounded hover:bg-muted transition-colors",title:"Open Git sidebar",children:[y.jsx(Pl,{className:"w-5 h-5 text-muted-foreground"}),l>0&&y.jsx("span",{className:"absolute -top-1 -right-1 w-5 h-5 bg-primary text-primary-foreground text-xs rounded-full flex items-center justify-center font-semibold",children:l>9?"9+":l})]})})});function xc({file:e,staged:n,showModifiedIndicator:a=!1}){const{openDiff:i}=tn(),l=Qw(),u=tL(),[c,d]=te.useState(n),f=async x=>{x.stopPropagation();const C=x.target.checked;d(C);try{C?await l.mutateAsync([e.path]):await u.mutateAsync([e.path])}catch(T){d(!C),console.error("Failed to stage/unstage file:",T)}},g=()=>{i(e.path,n)},h=(()=>{switch(e.status){case"added":case"untracked":return{icon:l0,color:"text-green-500",label:"A",labelColor:"text-green-500"};case"deleted":return{icon:d0,color:"text-red-500",label:"D",labelColor:"text-red-500"};case"modified":return{icon:Ul,color:"text-blue-500",label:"M",labelColor:"text-blue-500"};case"renamed":return{icon:Ul,color:"text-purple-500",label:"R",labelColor:"text-purple-500"};default:return{icon:Ul,color:"text-muted-foreground",label:"?",labelColor:"text-muted-foreground"}}})(),E=h.icon,_=(x=>{const C=x.split("/"),T=C[C.length-1];return C.length===1?T:`../${C[C.length-2]}/${T}`})(e.path);return y.jsxs("button",{type:"button",className:"flex items-center gap-2 px-3 py-2 hover:bg-muted/50 cursor-pointer group transition-colors w-full text-left",onClick:g,children:[y.jsx("input",{type:"checkbox",checked:c,onChange:f,onClick:x=>x.stopPropagation(),className:"w-4 h-4 rounded border-border","aria-label":`${c?"Unstage":"Stage"} ${e.path}`}),y.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[y.jsx(E,{className:`w-4 h-4 flex-shrink-0 ${h.color}`}),y.jsx("div",{className:"flex-1 min-w-0",children:y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"text-sm text-foreground truncate font-mono",title:e.path,children:_}),y.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[y.jsx("span",{className:`text-xs font-semibold ${h.labelColor}`,children:h.label}),a&&y.jsx("div",{title:"Also modified in working directory",children:y.jsx($w,{className:"w-3.5 h-3.5 text-orange-500"})})]})]})})]}),e.insertions!==void 0||e.deletions!==void 0?y.jsxs("div",{className:"flex items-center gap-2 text-xs flex-shrink-0",children:[e.insertions!==void 0&&e.insertions>0&&y.jsxs("span",{className:"text-green-500",children:["+",e.insertions]}),e.deletions!==void 0&&e.deletions>0&&y.jsxs("span",{className:"text-red-500",children:["-",e.deletions]})]}):null,n&&!a&&y.jsx(Hw,{className:"w-4 h-4 text-green-500 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]})}function aL({status:e}){const{openCommitModal:n}=tn(),a=Qw(),i=e.staged.length>0,l=e.unstaged.length>0||e.untracked.length>0,u=[...e.unstaged,...e.untracked],c=u.length>0,d=new Set(e.unstaged.map(g=>g.path)),f=()=>{const g=u.map(b=>b.path);g.length>0&&a.mutate(g)};return y.jsxs("div",{className:"flex flex-col",children:[i&&y.jsxs("div",{className:"border-b border-border",children:[y.jsxs("div",{className:"px-4 py-2 bg-muted/50 flex items-center justify-between",children:[y.jsxs("span",{className:"text-xs font-semibold text-foreground uppercase",children:["Staged Changes (",e.staged.length,")"]}),e.staged.length>0&&y.jsxs(Ot,{variant:"primary",size:"sm",onClick:n,className:"h-6 text-xs",children:[y.jsx(Gl,{className:"w-3 h-3 mr-1"}),"Commit"]})]}),y.jsx("div",{className:"divide-y divide-border",children:e.staged.map(g=>y.jsx(xc,{file:g,staged:!0,showModifiedIndicator:d.has(g.path)},g.path))})]}),l&&y.jsxs("div",{children:[y.jsxs("div",{className:"px-4 py-2 bg-muted/50 flex items-center justify-between",children:[y.jsxs("span",{className:"text-xs font-semibold text-foreground uppercase",children:["Changes (",e.unstaged.length+e.untracked.length,")"]}),c&&y.jsxs(Ot,{variant:"ghost",size:"sm",onClick:f,title:"Stage all changes",className:"h-6 text-xs",children:[y.jsx(U0,{className:"w-3 h-3 mr-1"}),"Stage All"]})]}),y.jsxs("div",{className:"divide-y divide-border",children:[e.unstaged.map(g=>y.jsx(xc,{file:g,staged:!1},g.path)),e.untracked.map(g=>y.jsx(xc,{file:g,staged:!1},g.path))]})]}),!i&&!l&&y.jsx("div",{className:"p-4 text-sm text-muted-foreground text-center",children:"No changes"})]})}const iL=te.memo(function(){const n=tn(b=>b.isExpanded),a=tn(b=>b.collapseSidebar),{data:i,isLoading:l,refetch:u}=Zw(),c=or();te.useEffect(()=>{n&&c.invalidateQueries({queryKey:["git","status"]})},[n,c]);const d=()=>{u()};if(!n)return null;const g=[...i?.staged||[],...i?.unstaged||[],...i?.untracked||[]].length;return y.jsxs("div",{className:"w-80 border-l border-border bg-background flex flex-col h-full",children:[y.jsxs("div",{className:"h-14 border-b border-border px-4 flex items-center justify-between",children:[y.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[y.jsx(Pl,{className:"w-4 h-4 text-muted-foreground"}),y.jsxs("span",{className:"font-medium text-foreground",children:["Git Changes",g>0&&y.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",g,")"]})]})]}),y.jsx(Ot,{variant:"ghost",size:"icon",onClick:a,title:"Close sidebar",children:y.jsx(_n,{className:"w-4 h-4"})})]}),y.jsx("div",{className:"flex-1 overflow-y-auto",children:l?y.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading git status..."}):!i||g===0?y.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"No changes detected"}):y.jsx(aL,{status:i})}),i?.branch&&y.jsxs("div",{className:"border-t border-border px-4 py-2 text-xs text-muted-foreground flex items-center justify-between",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(Pl,{className:"w-3 h-3"}),y.jsx("span",{children:i.branch}),i.ahead>0&&y.jsxs("span",{className:"text-green-500",children:["↑",i.ahead]}),i.behind>0&&y.jsxs("span",{className:"text-orange-500",children:["↓",i.behind]})]}),y.jsx(Ot,{variant:"ghost",size:"icon",onClick:d,title:"Refresh git status",className:"h-6 w-6 transition-transform duration-200 hover:scale-110",disabled:l,children:y.jsx(I0,{className:`w-3 h-3 ${l?"animate-spin":""}`})})]})]})});function oL(e,n){if(e==null)return{};var a={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(n.indexOf(i)!==-1)continue;a[i]=e[i]}return a}function lL(e,n){if(e==null)return{};var a,i,l=oL(e,n);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(i=0;i<u.length;i++)a=u[i],n.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(l[a]=e[a])}return l}function Oh(e,n){(n==null||n>e.length)&&(n=e.length);for(var a=0,i=Array(n);a<n;a++)i[a]=e[a];return i}function sL(e){if(Array.isArray(e))return Oh(e)}function uL(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function cL(e,n){if(e){if(typeof e=="string")return Oh(e,n);var a={}.toString.call(e).slice(8,-1);return a==="Object"&&e.constructor&&(a=e.constructor.name),a==="Map"||a==="Set"?Array.from(e):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?Oh(e,n):void 0}}function dL(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
265
265
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Lh(e){return sL(e)||uL(e)||cL(e)||dL()}function uo(e){"@babel/helpers - typeof";return uo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},uo(e)}function pL(e,n){if(uo(e)!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var i=a.call(e,n);if(uo(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function fL(e){var n=pL(e,"string");return uo(n)=="symbol"?n:n+""}function Jw(e,n,a){return(n=fL(n))in e?Object.defineProperty(e,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[n]=a,e}function Dh(){return Dh=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var i in a)({}).hasOwnProperty.call(a,i)&&(e[i]=a[i])}return e},Dh.apply(null,arguments)}function Zv(e,n){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),a.push.apply(a,i)}return a}function ei(e){for(var n=1;n<arguments.length;n++){var a=arguments[n]!=null?arguments[n]:{};n%2?Zv(Object(a),!0).forEach(function(i){Jw(e,i,a[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):Zv(Object(a)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(a,i))})}return e}function gL(e){var n=e.length;if(n===0||n===1)return e;if(n===2)return[e[0],e[1],"".concat(e[0],".").concat(e[1]),"".concat(e[1],".").concat(e[0])];if(n===3)return[e[0],e[1],e[2],"".concat(e[0],".").concat(e[1]),"".concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[0]),"".concat(e[1],".").concat(e[2]),"".concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[1],".").concat(e[0])];if(n>=4)return[e[0],e[1],e[2],e[3],"".concat(e[0],".").concat(e[1]),"".concat(e[0],".").concat(e[2]),"".concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[0]),"".concat(e[1],".").concat(e[2]),"".concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[1]),"".concat(e[2],".").concat(e[3]),"".concat(e[3],".").concat(e[0]),"".concat(e[3],".").concat(e[1]),"".concat(e[3],".").concat(e[2]),"".concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[1],".").concat(e[3]),"".concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[2],".").concat(e[3]),"".concat(e[0],".").concat(e[3],".").concat(e[1]),"".concat(e[0],".").concat(e[3],".").concat(e[2]),"".concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[1],".").concat(e[2],".").concat(e[3]),"".concat(e[1],".").concat(e[3],".").concat(e[0]),"".concat(e[1],".").concat(e[3],".").concat(e[2]),"".concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[0],".").concat(e[3]),"".concat(e[2],".").concat(e[1],".").concat(e[0]),"".concat(e[2],".").concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[3],".").concat(e[0]),"".concat(e[2],".").concat(e[3],".").concat(e[1]),"".concat(e[3],".").concat(e[0],".").concat(e[1]),"".concat(e[3],".").concat(e[0],".").concat(e[2]),"".concat(e[3],".").concat(e[1],".").concat(e[0]),"".concat(e[3],".").concat(e[1],".").concat(e[2]),"".concat(e[3],".").concat(e[2],".").concat(e[0]),"".concat(e[3],".").concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[1],".").concat(e[2],".").concat(e[3]),"".concat(e[0],".").concat(e[1],".").concat(e[3],".").concat(e[2]),"".concat(e[0],".").concat(e[2],".").concat(e[1],".").concat(e[3]),"".concat(e[0],".").concat(e[2],".").concat(e[3],".").concat(e[1]),"".concat(e[0],".").concat(e[3],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[3],".").concat(e[2],".").concat(e[1]),"".concat(e[1],".").concat(e[0],".").concat(e[2],".").concat(e[3]),"".concat(e[1],".").concat(e[0],".").concat(e[3],".").concat(e[2]),"".concat(e[1],".").concat(e[2],".").concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[2],".").concat(e[3],".").concat(e[0]),"".concat(e[1],".").concat(e[3],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[3],".").concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[0],".").concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[0],".").concat(e[3],".").concat(e[1]),"".concat(e[2],".").concat(e[1],".").concat(e[0],".").concat(e[3]),"".concat(e[2],".").concat(e[1],".").concat(e[3],".").concat(e[0]),"".concat(e[2],".").concat(e[3],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[3],".").concat(e[1],".").concat(e[0]),"".concat(e[3],".").concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[3],".").concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[3],".").concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[3],".").concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[3],".").concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[3],".").concat(e[2],".").concat(e[1],".").concat(e[0])]}var Ac={};function mL(e){if(e.length===0||e.length===1)return e;var n=e.join(".");return Ac[n]||(Ac[n]=gL(e)),Ac[n]}function hL(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0,i=e.filter(function(u){return u!=="token"}),l=mL(i);return l.reduce(function(u,c){return ei(ei({},u),a[c])},n)}function Qv(e){return e.join(" ")}function bL(e,n){var a=0;return function(i){return a+=1,i.map(function(l,u){return ek({node:l,stylesheet:e,useInlineStyles:n,key:"code-segment-".concat(a,"-").concat(u)})})}}function ek(e){var n=e.node,a=e.stylesheet,i=e.style,l=i===void 0?{}:i,u=e.useInlineStyles,c=e.key,d=n.properties,f=n.type,g=n.tagName,b=n.value;if(f==="text")return b;if(g){var h=bL(a,u),E;if(!u)E=ei(ei({},d),{},{className:Qv(d.className)});else{var S=Object.keys(a).reduce(function(T,A){return A.split(".").forEach(function(N){T.includes(N)||T.push(N)}),T},[]),_=d.className&&d.className.includes("token")?["token"]:[],x=d.className&&_.concat(d.className.filter(function(T){return!S.includes(T)}));E=ei(ei({},d),{},{className:Qv(x)||void 0,style:hL(d.className,Object.assign({},d.style,l),a)})}var C=h(n.children);return En.createElement(g,Dh({key:c},E),C)}}const yL=(function(e,n){var a=e.listLanguages();return a.indexOf(n)!==-1});var EL=["language","children","style","customStyle","codeTagProps","useInlineStyles","showLineNumbers","showInlineLineNumbers","startingLineNumber","lineNumberContainerStyle","lineNumberStyle","wrapLines","wrapLongLines","lineProps","renderer","PreTag","CodeTag","code","astGenerator"];function Jv(e,n){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),a.push.apply(a,i)}return a}function Dr(e){for(var n=1;n<arguments.length;n++){var a=arguments[n]!=null?arguments[n]:{};n%2?Jv(Object(a),!0).forEach(function(i){Jw(e,i,a[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):Jv(Object(a)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(a,i))})}return e}var SL=/\n/g;function vL(e){return e.match(SL)}function TL(e){var n=e.lines,a=e.startingLineNumber,i=e.style;return n.map(function(l,u){var c=u+a;return En.createElement("span",{key:"line-".concat(u),className:"react-syntax-highlighter-line-number",style:typeof i=="function"?i(c):i},"".concat(c,`
266
266
  `))})}function xL(e){var n=e.codeString,a=e.codeStyle,i=e.containerStyle,l=i===void 0?{float:"left",paddingRight:"10px"}:i,u=e.numberStyle,c=u===void 0?{}:u,d=e.startingLineNumber;return En.createElement("code",{style:Object.assign({},a,l)},TL({lines:n.replace(/\n$/,"").split(`
267
267
  `),style:c,startingLineNumber:d}))}function AL(e){return"".concat(e.toString().length,".25em")}function tk(e,n){return{type:"element",tagName:"span",properties:{key:"line-number--".concat(e),className:["comment","linenumber","react-syntax-highlighter-line-number"],style:n},children:[{type:"text",value:e}]}}function nk(e,n,a){var i={display:"inline-block",minWidth:AL(a),paddingRight:"1em",textAlign:"right",userSelect:"none"},l=typeof e=="function"?e(n):e,u=Dr(Dr({},i),l);return u}function Fl(e){var n=e.children,a=e.lineNumber,i=e.lineNumberStyle,l=e.largestLineNumber,u=e.showInlineLineNumbers,c=e.lineProps,d=c===void 0?{}:c,f=e.className,g=f===void 0?[]:f,b=e.showLineNumbers,h=e.wrapLongLines,E=e.wrapLines,S=E===void 0?!1:E,_=S?Dr({},typeof d=="function"?d(a):d):{};if(_.className=_.className?[].concat(Lh(_.className.trim().split(/\s+/)),Lh(g)):g,a&&u){var x=nk(i,a,l);n.unshift(tk(a,x))}return h&b&&(_.style=Dr({display:"flex"},_.style)),{type:"element",tagName:"span",properties:_,children:n}}function rk(e){for(var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],i=0;i<e.length;i++){var l=e[i];if(l.type==="text")a.push(Fl({children:[l],className:Lh(new Set(n))}));else if(l.children){var u=n.concat(l.properties.className);rk(l.children,u).forEach(function(c){return a.push(c)})}}return a}function _L(e,n,a,i,l,u,c,d,f){var g,b=rk(e.value),h=[],E=-1,S=0;function _(U,w){var M=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return Fl({children:U,lineNumber:w,lineNumberStyle:d,largestLineNumber:c,showInlineLineNumbers:l,lineProps:a,className:M,showLineNumbers:i,wrapLongLines:f,wrapLines:n})}function x(U,w){if(i&&w&&l){var M=nk(d,w,c);U.unshift(tk(w,M))}return U}function C(U,w){var M=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return n||M.length>0?_(U,w,M):x(U,w)}for(var T=function(){var w=b[S],M=w.children[0].value,H=vL(M);if(H){var j=M.split(`
@@ -314,4 +314,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
314
314
  `))}function f(S,_,x,C){const T=x.enter("tableCell"),A=x.enter("phrasing"),N=x.containerPhrasing(S,{...C,before:u,after:u});return A(),T(),N}function g(S,_){return X4(S,{align:_,alignDelimiters:i,padding:a,stringLength:l})}function b(S,_,x){const C=S.children;let T=-1;const A=[],N=_.enter("table");for(;++T<C.length;)A[T]=h(C[T],_,x);return N(),A}function h(S,_,x){const C=S.children;let T=-1;const A=[],N=_.enter("tableRow");for(;++T<C.length;)A[T]=f(C[T],S,_,x);return N(),A}function E(S,_,x){let C=gC.inlineCode(S,_,x);return x.stack.includes("tableCell")&&(C=C.replace(/\|/g,"\\$&")),C}}function FH(){return{exit:{taskListCheckValueChecked:Rw,taskListCheckValueUnchecked:Rw,paragraph:zH}}}function BH(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:jH}}}function Rw(e){const n=this.stack[this.stack.length-2];n.type,n.checked=e.type==="taskListCheckValueChecked"}function zH(e){const n=this.stack[this.stack.length-2];if(n&&n.type==="listItem"&&typeof n.checked=="boolean"){const a=this.stack[this.stack.length-1];a.type;const i=a.children[0];if(i&&i.type==="text"){const l=n.children;let u=-1,c;for(;++u<l.length;){const d=l[u];if(d.type==="paragraph"){c=d;break}}c===a&&(i.value=i.value.slice(1),i.value.length===0?a.children.shift():a.position&&i.position&&typeof i.position.start.offset=="number"&&(i.position.start.column++,i.position.start.offset++,a.position.start=Object.assign({},i.position.start)))}}this.exit(e)}function jH(e,n,a,i){const l=e.children[0],u=typeof e.checked=="boolean"&&l&&l.type==="paragraph",c="["+(e.checked?"x":" ")+"] ",d=a.createTracker(i);u&&d.move(c);let f=gC.listItem(e,n,a,{...i,...d.current()});return u&&(f=f.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,g)),f;function g(b){return b+c}}function qH(){return[E4(),j4(),H4(),CH(),FH()]}function PH(e){return{extensions:[S4(),q4(e),$4(),UH(e),BH()]}}const GH={tokenize:WH,partial:!0},mC={tokenize:XH,partial:!0},hC={tokenize:ZH,partial:!0},bC={tokenize:QH,partial:!0},HH={tokenize:JH,partial:!0},yC={name:"wwwAutolink",tokenize:YH,previous:SC},EC={name:"protocolAutolink",tokenize:KH,previous:vC},lr={name:"emailAutolink",tokenize:VH,previous:TC},Fn={};function $H(){return{text:Fn}}let aa=48;for(;aa<123;)Fn[aa]=lr,aa++,aa===58?aa=65:aa===91&&(aa=97);Fn[43]=lr;Fn[45]=lr;Fn[46]=lr;Fn[95]=lr;Fn[72]=[lr,EC];Fn[104]=[lr,EC];Fn[87]=[lr,yC];Fn[119]=[lr,yC];function VH(e,n,a){const i=this;let l,u;return c;function c(h){return!$h(h)||!TC.call(i,i.previous)||Nb(i.events)?a(h):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),d(h))}function d(h){return $h(h)?(e.consume(h),d):h===64?(e.consume(h),f):a(h)}function f(h){return h===46?e.check(HH,b,g)(h):h===45||h===95||Rt(h)?(u=!0,e.consume(h),f):b(h)}function g(h){return e.consume(h),l=!0,f}function b(h){return u&&l&&It(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),n(h)):a(h)}}function YH(e,n,a){const i=this;return l;function l(c){return c!==87&&c!==119||!SC.call(i,i.previous)||Nb(i.events)?a(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(GH,e.attempt(mC,e.attempt(hC,u),a),a)(c))}function u(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),n(c)}}function KH(e,n,a){const i=this;let l="",u=!1;return c;function c(h){return(h===72||h===104)&&vC.call(i,i.previous)&&!Nb(i.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),l+=String.fromCodePoint(h),e.consume(h),d):a(h)}function d(h){if(It(h)&&l.length<5)return l+=String.fromCodePoint(h),e.consume(h),d;if(h===58){const E=l.toLowerCase();if(E==="http"||E==="https")return e.consume(h),f}return a(h)}function f(h){return h===47?(e.consume(h),u?g:(u=!0,f)):a(h)}function g(h){return h===null||$l(h)||Ve(h)||sa(h)||es(h)?a(h):e.attempt(mC,e.attempt(hC,b),a)(h)}function b(h){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),n(h)}}function WH(e,n,a){let i=0;return l;function l(c){return(c===87||c===119)&&i<3?(i++,e.consume(c),l):c===46&&i===3?(e.consume(c),u):a(c)}function u(c){return c===null?a(c):n(c)}}function XH(e,n,a){let i,l,u;return c;function c(g){return g===46||g===95?e.check(bC,f,d)(g):g===null||Ve(g)||sa(g)||g!==45&&es(g)?f(g):(u=!0,e.consume(g),c)}function d(g){return g===95?i=!0:(l=i,i=void 0),e.consume(g),c}function f(g){return l||i||!u?a(g):n(g)}}function ZH(e,n){let a=0,i=0;return l;function l(c){return c===40?(a++,e.consume(c),l):c===41&&i<a?u(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?e.check(bC,n,u)(c):c===null||Ve(c)||sa(c)?n(c):(e.consume(c),l)}function u(c){return c===41&&i++,e.consume(c),l}}function QH(e,n,a){return i;function i(d){return d===33||d===34||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===63||d===95||d===126?(e.consume(d),i):d===38?(e.consume(d),u):d===93?(e.consume(d),l):d===60||d===null||Ve(d)||sa(d)?n(d):a(d)}function l(d){return d===null||d===40||d===91||Ve(d)||sa(d)?n(d):i(d)}function u(d){return It(d)?c(d):a(d)}function c(d){return d===59?(e.consume(d),i):It(d)?(e.consume(d),c):a(d)}}function JH(e,n,a){return i;function i(u){return e.consume(u),l}function l(u){return Rt(u)?a(u):n(u)}}function SC(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Ve(e)}function vC(e){return!It(e)}function TC(e){return!(e===47||$h(e))}function $h(e){return e===43||e===45||e===46||e===95||Rt(e)}function Nb(e){let n=e.length,a=!1;for(;n--;){const i=e[n][1];if((i.type==="labelLink"||i.type==="labelImage")&&!i._balanced){a=!0;break}if(i._gfmAutolinkLiteralWalkedInto){a=!1;break}}return e.length>0&&!a&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),a}const e3={tokenize:s3,partial:!0};function t3(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:i3,continuation:{tokenize:o3},exit:l3}},text:{91:{name:"gfmFootnoteCall",tokenize:a3},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:n3,resolveTo:r3}}}}function n3(e,n,a){const i=this;let l=i.events.length;const u=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let c;for(;l--;){const f=i.events[l][1];if(f.type==="labelImage"){c=f;break}if(f.type==="gfmFootnoteCall"||f.type==="labelLink"||f.type==="label"||f.type==="image"||f.type==="link")break}return d;function d(f){if(!c||!c._balanced)return a(f);const g=An(i.sliceSerialize({start:c.end,end:i.now()}));return g.codePointAt(0)!==94||!u.includes(g.slice(1))?a(f):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),n(f))}}function r3(e,n){let a=e.length;for(;a--;)if(e[a][1].type==="labelImage"&&e[a][0]==="enter"){e[a][1];break}e[a+1][1].type="data",e[a+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},e[a+3][1].start),end:Object.assign({},e[e.length-1][1].end)},l={type:"gfmFootnoteCallMarker",start:Object.assign({},e[a+3][1].end),end:Object.assign({},e[a+3][1].end)};l.end.column++,l.end.offset++,l.end._bufferIndex++;const u={type:"gfmFootnoteCallString",start:Object.assign({},l.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},u.start),end:Object.assign({},u.end)},d=[e[a+1],e[a+2],["enter",i,n],e[a+3],e[a+4],["enter",l,n],["exit",l,n],["enter",u,n],["enter",c,n],["exit",c,n],["exit",u,n],e[e.length-2],e[e.length-1],["exit",i,n]];return e.splice(a,e.length-a+1,...d),e}function a3(e,n,a){const i=this,l=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u=0,c;return d;function d(h){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),f}function f(h){return h!==94?a(h):(e.enter("gfmFootnoteCallMarker"),e.consume(h),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",g)}function g(h){if(u>999||h===93&&!c||h===null||h===91||Ve(h))return a(h);if(h===93){e.exit("chunkString");const E=e.exit("gfmFootnoteCallString");return l.includes(An(i.sliceSerialize(E)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),n):a(h)}return Ve(h)||(c=!0),u++,e.consume(h),h===92?b:g}function b(h){return h===91||h===92||h===93?(e.consume(h),u++,g):g(h)}}function i3(e,n,a){const i=this,l=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u,c=0,d;return f;function f(_){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(_),e.exit("gfmFootnoteDefinitionLabelMarker"),g}function g(_){return _===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(_),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",b):a(_)}function b(_){if(c>999||_===93&&!d||_===null||_===91||Ve(_))return a(_);if(_===93){e.exit("chunkString");const x=e.exit("gfmFootnoteDefinitionLabelString");return u=An(i.sliceSerialize(x)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(_),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),E}return Ve(_)||(d=!0),c++,e.consume(_),_===92?h:b}function h(_){return _===91||_===92||_===93?(e.consume(_),c++,b):b(_)}function E(_){return _===58?(e.enter("definitionMarker"),e.consume(_),e.exit("definitionMarker"),l.includes(u)||l.push(u),De(e,S,"gfmFootnoteDefinitionWhitespace")):a(_)}function S(_){return n(_)}}function o3(e,n,a){return e.check(mo,n,e.attempt(e3,n,a))}function l3(e){e.exit("gfmFootnoteDefinition")}function s3(e,n,a){const i=this;return De(e,l,"gfmFootnoteDefinitionIndent",5);function l(u){const c=i.events[i.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?n(u):a(u)}}function u3(e){let a=(e||{}).singleTilde;const i={name:"strikethrough",tokenize:u,resolveAll:l};return a==null&&(a=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function l(c,d){let f=-1;for(;++f<c.length;)if(c[f][0]==="enter"&&c[f][1].type==="strikethroughSequenceTemporary"&&c[f][1]._close){let g=f;for(;g--;)if(c[g][0]==="exit"&&c[g][1].type==="strikethroughSequenceTemporary"&&c[g][1]._open&&c[f][1].end.offset-c[f][1].start.offset===c[g][1].end.offset-c[g][1].start.offset){c[f][1].type="strikethroughSequence",c[g][1].type="strikethroughSequence";const b={type:"strikethrough",start:Object.assign({},c[g][1].start),end:Object.assign({},c[f][1].end)},h={type:"strikethroughText",start:Object.assign({},c[g][1].end),end:Object.assign({},c[f][1].start)},E=[["enter",b,d],["enter",c[g][1],d],["exit",c[g][1],d],["enter",h,d]],S=d.parser.constructs.insideSpan.null;S&&nn(E,E.length,0,ts(S,c.slice(g+1,f),d)),nn(E,E.length,0,[["exit",h,d],["enter",c[f][1],d],["exit",c[f][1],d],["exit",b,d]]),nn(c,g-1,f-g+3,E),f=g+E.length-2;break}}for(f=-1;++f<c.length;)c[f][1].type==="strikethroughSequenceTemporary"&&(c[f][1].type="data");return c}function u(c,d,f){const g=this.previous,b=this.events;let h=0;return E;function E(_){return g===126&&b[b.length-1][1].type!=="characterEscape"?f(_):(c.enter("strikethroughSequenceTemporary"),S(_))}function S(_){const x=ni(g);if(_===126)return h>1?f(_):(c.consume(_),h++,S);if(h<2&&!a)return f(_);const C=c.exit("strikethroughSequenceTemporary"),T=ni(_);return C._open=!T||T===2&&!!x,C._close=!x||x===2&&!!T,d(_)}}}class c3{constructor(){this.map=[]}add(n,a,i){d3(this,n,a,i)}consume(n){if(this.map.sort(function(u,c){return u[0]-c[0]}),this.map.length===0)return;let a=this.map.length;const i=[];for(;a>0;)a-=1,i.push(n.slice(this.map[a][0]+this.map[a][1]),this.map[a][2]),n.length=this.map[a][0];i.push(n.slice()),n.length=0;let l=i.pop();for(;l;){for(const u of l)n.push(u);l=i.pop()}this.map.length=0}}function d3(e,n,a,i){let l=0;if(!(a===0&&i.length===0)){for(;l<e.map.length;){if(e.map[l][0]===n){e.map[l][1]+=a,e.map[l][2].push(...i);return}l+=1}e.map.push([n,a,i])}}function p3(e,n){let a=!1;const i=[];for(;n<e.length;){const l=e[n];if(a){if(l[0]==="enter")l[1].type==="tableContent"&&i.push(e[n+1][1].type==="tableDelimiterMarker"?"left":"none");else if(l[1].type==="tableContent"){if(e[n-1][1].type==="tableDelimiterMarker"){const u=i.length-1;i[u]=i[u]==="left"?"center":"right"}}else if(l[1].type==="tableDelimiterRow")break}else l[0]==="enter"&&l[1].type==="tableDelimiterRow"&&(a=!0);n+=1}return i}function f3(){return{flow:{null:{name:"table",tokenize:g3,resolveAll:m3}}}}function g3(e,n,a){const i=this;let l=0,u=0,c;return d;function d(F){let K=i.events.length-1;for(;K>-1;){const oe=i.events[K][1].type;if(oe==="lineEnding"||oe==="linePrefix")K--;else break}const Q=K>-1?i.events[K][1].type:null,ne=Q==="tableHead"||Q==="tableRow"?w:f;return ne===w&&i.parser.lazy[i.now().line]?a(F):ne(F)}function f(F){return e.enter("tableHead"),e.enter("tableRow"),g(F)}function g(F){return F===124||(c=!0,u+=1),b(F)}function b(F){return F===null?a(F):be(F)?u>1?(u=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(F),e.exit("lineEnding"),S):a(F):Ne(F)?De(e,b,"whitespace")(F):(u+=1,c&&(c=!1,l+=1),F===124?(e.enter("tableCellDivider"),e.consume(F),e.exit("tableCellDivider"),c=!0,b):(e.enter("data"),h(F)))}function h(F){return F===null||F===124||Ve(F)?(e.exit("data"),b(F)):(e.consume(F),F===92?E:h)}function E(F){return F===92||F===124?(e.consume(F),h):h(F)}function S(F){return i.interrupt=!1,i.parser.lazy[i.now().line]?a(F):(e.enter("tableDelimiterRow"),c=!1,Ne(F)?De(e,_,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):_(F))}function _(F){return F===45||F===58?C(F):F===124?(c=!0,e.enter("tableCellDivider"),e.consume(F),e.exit("tableCellDivider"),x):U(F)}function x(F){return Ne(F)?De(e,C,"whitespace")(F):C(F)}function C(F){return F===58?(u+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(F),e.exit("tableDelimiterMarker"),T):F===45?(u+=1,T(F)):F===null||be(F)?L(F):U(F)}function T(F){return F===45?(e.enter("tableDelimiterFiller"),A(F)):U(F)}function A(F){return F===45?(e.consume(F),A):F===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(F),e.exit("tableDelimiterMarker"),N):(e.exit("tableDelimiterFiller"),N(F))}function N(F){return Ne(F)?De(e,L,"whitespace")(F):L(F)}function L(F){return F===124?_(F):F===null||be(F)?!c||l!==u?U(F):(e.exit("tableDelimiterRow"),e.exit("tableHead"),n(F)):U(F)}function U(F){return a(F)}function w(F){return e.enter("tableRow"),M(F)}function M(F){return F===124?(e.enter("tableCellDivider"),e.consume(F),e.exit("tableCellDivider"),M):F===null||be(F)?(e.exit("tableRow"),n(F)):Ne(F)?De(e,M,"whitespace")(F):(e.enter("data"),H(F))}function H(F){return F===null||F===124||Ve(F)?(e.exit("data"),M(F)):(e.consume(F),F===92?j:H)}function j(F){return F===92||F===124?(e.consume(F),H):H(F)}}function m3(e,n){let a=-1,i=!0,l=0,u=[0,0,0,0],c=[0,0,0,0],d=!1,f=0,g,b,h;const E=new c3;for(;++a<e.length;){const S=e[a],_=S[1];S[0]==="enter"?_.type==="tableHead"?(d=!1,f!==0&&(Nw(E,n,f,g,b),b=void 0,f=0),g={type:"table",start:Object.assign({},_.start),end:Object.assign({},_.end)},E.add(a,0,[["enter",g,n]])):_.type==="tableRow"||_.type==="tableDelimiterRow"?(i=!0,h=void 0,u=[0,0,0,0],c=[0,a+1,0,0],d&&(d=!1,b={type:"tableBody",start:Object.assign({},_.start),end:Object.assign({},_.end)},E.add(a,0,[["enter",b,n]])),l=_.type==="tableDelimiterRow"?2:b?3:1):l&&(_.type==="data"||_.type==="tableDelimiterMarker"||_.type==="tableDelimiterFiller")?(i=!1,c[2]===0&&(u[1]!==0&&(c[0]=c[1],h=Ml(E,n,u,l,void 0,h),u=[0,0,0,0]),c[2]=a)):_.type==="tableCellDivider"&&(i?i=!1:(u[1]!==0&&(c[0]=c[1],h=Ml(E,n,u,l,void 0,h)),u=c,c=[u[1],a,0,0])):_.type==="tableHead"?(d=!0,f=a):_.type==="tableRow"||_.type==="tableDelimiterRow"?(f=a,u[1]!==0?(c[0]=c[1],h=Ml(E,n,u,l,a,h)):c[1]!==0&&(h=Ml(E,n,c,l,a,h)),l=0):l&&(_.type==="data"||_.type==="tableDelimiterMarker"||_.type==="tableDelimiterFiller")&&(c[3]=a)}for(f!==0&&Nw(E,n,f,g,b),E.consume(n.events),a=-1;++a<n.events.length;){const S=n.events[a];S[0]==="enter"&&S[1].type==="table"&&(S[1]._align=p3(n.events,a))}return e}function Ml(e,n,a,i,l,u){const c=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",d="tableContent";a[0]!==0&&(u.end=Object.assign({},Qa(n.events,a[0])),e.add(a[0],0,[["exit",u,n]]));const f=Qa(n.events,a[1]);if(u={type:c,start:Object.assign({},f),end:Object.assign({},f)},e.add(a[1],0,[["enter",u,n]]),a[2]!==0){const g=Qa(n.events,a[2]),b=Qa(n.events,a[3]),h={type:d,start:Object.assign({},g),end:Object.assign({},b)};if(e.add(a[2],0,[["enter",h,n]]),i!==2){const E=n.events[a[2]],S=n.events[a[3]];if(E[1].end=Object.assign({},S[1].end),E[1].type="chunkText",E[1].contentType="text",a[3]>a[2]+1){const _=a[2]+1,x=a[3]-a[2]-1;e.add(_,x,[])}}e.add(a[3]+1,0,[["exit",h,n]])}return l!==void 0&&(u.end=Object.assign({},Qa(n.events,l)),e.add(l,0,[["exit",u,n]]),u=void 0),u}function Nw(e,n,a,i,l){const u=[],c=Qa(n.events,a);l&&(l.end=Object.assign({},c),u.push(["exit",l,n])),i.end=Object.assign({},c),u.push(["exit",i,n]),e.add(a+1,0,u)}function Qa(e,n){const a=e[n],i=a[0]==="enter"?"start":"end";return a[1][i]}const h3={name:"tasklistCheck",tokenize:y3};function b3(){return{text:{91:h3}}}function y3(e,n,a){const i=this;return l;function l(f){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?a(f):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(f),e.exit("taskListCheckMarker"),u)}function u(f){return Ve(f)?(e.enter("taskListCheckValueUnchecked"),e.consume(f),e.exit("taskListCheckValueUnchecked"),c):f===88||f===120?(e.enter("taskListCheckValueChecked"),e.consume(f),e.exit("taskListCheckValueChecked"),c):a(f)}function c(f){return f===93?(e.enter("taskListCheckMarker"),e.consume(f),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),d):a(f)}function d(f){return be(f)?n(f):Ne(f)?e.check({tokenize:E3},n,a)(f):a(f)}}function E3(e,n,a){return De(e,i,"whitespace");function i(l){return l===null?a(l):n(l)}}function S3(e){return Ok([$H(),t3(),u3(e),f3(),b3()])}const v3={};function xC(e){const n=this,a=e||v3,i=n.data(),l=i.micromarkExtensions||(i.micromarkExtensions=[]),u=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),c=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);l.push(S3(a)),u.push(qH()),c.push(PH(a))}function Lt(e){return e?e>=1e3?`${(e/1e3).toFixed(1)}s`:`${e}ms`:""}function T3(e){const n=e.split(".").pop()?.toLowerCase();return{js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",php:"php",sh:"bash",bash:"bash",zsh:"bash",sql:"sql",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",html:"html",css:"css",scss:"scss",md:"markdown",txt:"text"}[n||""]||"text"}function x3({contentJson:e,toolDurationMs:n,isExpanded:a,onToggle:i}){const l=e.result||{},u=String(l.path||""),c=String(l.content||""),d=c.split(`
315
315
  `),f=Lt(n),g=T3(u);return y.jsxs("div",{className:"text-xs",children:[y.jsxs("button",{type:"button",onClick:i,className:"flex items-center gap-2 text-blue-700 dark:text-blue-300 transition-colors hover:text-blue-600 dark:hover:text-blue-200 w-full min-w-0",children:[y.jsx(_n,{className:`h-3 w-3 flex-shrink-0 transition-transform ${a?"rotate-90":""}`}),y.jsx("span",{className:"font-medium flex-shrink-0",children:"read"}),y.jsx("span",{className:"text-muted-foreground/70 flex-shrink-0",children:"·"}),y.jsx("span",{className:"text-foreground/70 truncate min-w-0",style:{direction:"rtl",unicodeBidi:"plaintext"},title:u,children:u}),y.jsxs("span",{className:"text-muted-foreground/80 flex-shrink-0 whitespace-nowrap",children:["· ",d.length," lines · ",f]})]}),a&&c&&y.jsx("div",{className:"mt-2 ml-5 bg-card/60 border border-border rounded-lg overflow-hidden max-h-96 overflow-y-auto max-w-full",children:y.jsx("div",{className:"overflow-x-auto max-w-full",children:y.jsx(Rn,{language:g,style:Un,customStyle:{margin:0,padding:"0.75rem",fontSize:"0.75rem",lineHeight:"1.5",background:"transparent",maxWidth:"100%"},showLineNumbers:!0,wrapLines:!0,wrapLongLines:!0,children:c})})})]})}function A3(e){const n=e.split(`
316
316
  `),a=[];let i=0,l=0,u=!1;for(const c of n){const d=c.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(d){i=parseInt(d[1],10),l=parseInt(d[2],10),u=!0,a.push({content:c,type:"header"});continue}if(c.startsWith("***")||c.startsWith("diff ")||c.startsWith("index ")||c.startsWith("---")||c.startsWith("+++")){a.push({content:c,type:"meta"});continue}u?c.startsWith("+")?a.push({content:c,type:"add",newLineNum:l++}):c.startsWith("-")?a.push({content:c,type:"remove",oldLineNum:i++}):c.startsWith(" ")||c===""?a.push({content:c,type:"context",oldLineNum:i++,newLineNum:l++}):a.push({content:c,type:"context"}):a.push({content:c,type:"meta"})}return a}function AC({patch:e}){const n=A3(e);return y.jsx("div",{className:"bg-card/60 border border-border rounded-lg overflow-hidden max-h-96 max-w-full",children:y.jsx("div",{className:"overflow-x-auto overflow-y-auto max-h-96 text-xs font-mono",children:n.map((a,i)=>{const l=`line-${i}-${a.content.slice(0,20)}`;if(a.type==="meta"||a.type==="header")return y.jsx("div",{className:`px-3 py-0.5 whitespace-pre-wrap break-all ${a.type==="header"?"text-muted-foreground/80 bg-muted/20":"text-muted-foreground/80"}`,children:a.content},l);let u="",c="";switch(a.type){case"add":u="text-emerald-700 dark:text-emerald-300",c="bg-emerald-500/10";break;case"remove":u="text-red-600 dark:text-red-300",c="bg-red-500/10";break;default:u="text-muted-foreground"}return y.jsxs("div",{className:`flex ${c}`,children:[y.jsx("div",{className:"px-2 py-0.5 text-right text-muted-foreground/40 select-none w-12 flex-shrink-0",children:a.oldLineNum||""}),y.jsx("div",{className:"px-2 py-0.5 text-right text-muted-foreground/40 select-none w-12 flex-shrink-0 border-r border-border/50",children:a.newLineNum||""}),y.jsx("div",{className:`px-3 py-0.5 flex-1 min-w-0 whitespace-pre-wrap break-all ${u}`,children:a.content})]},l)})})})}function _3({contentJson:e,toolDurationMs:n,isExpanded:a,onToggle:i}){const l=e.result||{},u=e.artifact,c=String(l.path||""),d=Number(l.bytes||0),f=u?.patch?String(u.patch):"",g=Lt(n);return y.jsxs("div",{className:"text-xs",children:[y.jsxs("button",{type:"button",onClick:()=>f&&i(),className:`flex items-center gap-2 text-emerald-700 dark:text-emerald-300 transition-colors min-w-0 ${f?"hover:text-emerald-600 dark:hover:text-emerald-200":""}`,children:[f&&(a?y.jsx(Ur,{className:"h-3 w-3 flex-shrink-0"}):y.jsx(_n,{className:"h-3 w-3 flex-shrink-0"})),!f&&y.jsx("div",{className:"w-3 flex-shrink-0"}),y.jsx("span",{className:"font-medium flex-shrink-0",children:"write"}),y.jsx("span",{className:"text-muted-foreground/70 flex-shrink-0",children:"·"}),y.jsx("span",{className:"text-foreground/70 min-w-0 flex-shrink overflow-hidden",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:c,children:c}),y.jsxs("span",{className:"text-muted-foreground/80 whitespace-nowrap flex-shrink-0",children:["· ",d," bytes · ",g]})]}),a&&f&&y.jsx("div",{className:"mt-2 ml-5",children:y.jsx(AC,{patch:f})})]})}function R3({contentJson:e,toolDurationMs:n}){const a=e.artifact,i=Lt(n),l=a?.summary||{},u=Number(l.files||0),c=Number(l.additions||0),d=Number(l.deletions||0),f=a?.patch?String(a.patch):"";return y.jsxs("div",{className:"text-xs space-y-2",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"font-medium text-purple-700 dark:text-purple-300",children:"edit"}),y.jsx("span",{className:"text-muted-foreground/70",children:"·"}),y.jsxs("span",{className:"text-foreground/70",children:[u," ",u===1?"file":"files"]}),y.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["+",c]}),y.jsxs("span",{className:"text-red-600 dark:text-red-400",children:["-",d]}),y.jsxs("span",{className:"text-muted-foreground/80",children:["· ",i]})]}),f&&y.jsx(AC,{patch:f})]})}function N3({contentJson:e,toolDurationMs:n,isExpanded:a,onToggle:i}){const l=e.result||{},u=e.args||{},c=String(l.stdout||""),d=String(l.stderr||""),f=Number(l.exitCode??0),g=String(u.cmd||""),b=Lt(n),h=c.length>0||d.length>0;return y.jsxs("div",{className:"text-xs",children:[y.jsxs("button",{type:"button",onClick:()=>h&&i(),className:`flex items-center gap-2 text-muted-foreground transition-colors w-full min-w-0 ${h?"hover:text-foreground":""}`,children:[h&&(a?y.jsx(Ur,{className:"h-3 w-3 flex-shrink-0"}):y.jsx(_n,{className:"h-3 w-3 flex-shrink-0"})),!h&&y.jsx("div",{className:"w-3 flex-shrink-0"}),y.jsx("span",{className:"font-medium flex-shrink-0",children:"bash"}),y.jsx("span",{className:"text-muted-foreground/70 flex-shrink-0",children:"·"}),y.jsx("span",{className:"text-foreground/70 truncate min-w-0",title:g,children:g}),y.jsxs("span",{className:`flex-shrink-0 whitespace-nowrap ${f===0?"text-emerald-600 dark:text-emerald-400":"text-red-600 dark:text-red-400"}`,children:["· exit ",f," · ",b]})]}),a&&h&&y.jsx("div",{className:"mt-2 ml-5 bg-card/60 border border-border rounded-lg overflow-hidden max-h-96 overflow-y-auto max-w-full",children:y.jsxs("div",{className:"overflow-x-auto max-w-full",children:[c&&y.jsxs("div",{className:"mb-2",children:[y.jsx("div",{className:"text-xs text-muted-foreground px-3 py-1 border-b border-border bg-muted/30",children:"stdout"}),y.jsx(Rn,{language:"bash",style:Un,customStyle:{margin:0,padding:"0.75rem",fontSize:"0.75rem",lineHeight:"1.5",background:"transparent",maxWidth:"100%"},wrapLines:!0,wrapLongLines:!0,children:c})]}),d&&y.jsxs("div",{children:[y.jsx("div",{className:"text-xs text-red-600 dark:text-red-400 px-3 py-1 border-b border-border bg-red-500/10",children:"stderr"}),y.jsx(Rn,{language:"bash",style:Un,customStyle:{margin:0,padding:"0.75rem",fontSize:"0.75rem",lineHeight:"1.5",background:"transparent",maxWidth:"100%"},wrapLines:!0,wrapLongLines:!0,children:d})]})]})})]})}function w3({contentJson:e,toolDurationMs:n}){const a=e.result||{},i=String(a.summary||""),l=Lt(n);return y.jsxs("div",{className:"text-xs space-y-2",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"font-medium text-blue-700 dark:text-blue-300",children:"git status"}),y.jsx("span",{className:"text-muted-foreground/70",children:"·"}),y.jsx("span",{className:"text-muted-foreground/80",children:l})]}),i&&y.jsx("div",{className:"bg-card/60 border border-border rounded-lg overflow-hidden max-h-96 overflow-y-auto max-w-full",children:y.jsx("div",{className:"overflow-x-auto max-w-full",children:y.jsx(Rn,{language:"bash",style:Un,customStyle:{margin:0,padding:"0.75rem",fontSize:"0.75rem",lineHeight:"1.5",background:"transparent",maxWidth:"100%"},wrapLines:!0,wrapLongLines:!0,children:i})})})]})}function k3({contentJson:e,toolDurationMs:n}){const a=e.result||{},i=String(a.diff||""),l=Lt(n);return y.jsxs("div",{className:"text-xs space-y-2",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"font-medium text-purple-700 dark:text-purple-300",children:"git diff"}),y.jsx("span",{className:"text-muted-foreground/70",children:"·"}),y.jsx("span",{className:"text-muted-foreground/80",children:l})]}),i&&y.jsx("div",{className:"bg-card/60 border border-border rounded-lg overflow-hidden max-h-96 overflow-y-auto max-w-full",children:y.jsx("div",{className:"overflow-x-auto max-w-full",children:y.jsx(Rn,{language:"diff",style:Un,customStyle:{margin:0,padding:"0.75rem",fontSize:"0.75rem",lineHeight:"1.5",background:"transparent",maxWidth:"100%"},wrapLines:!0,wrapLongLines:!0,children:i})})})]})}function C3({contentJson:e,toolDurationMs:n}){const a=e.result||{},i=String(a.message||""),l=Lt(n);return y.jsxs("div",{className:"text-xs space-y-2",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"font-medium text-emerald-700 dark:text-emerald-300",children:"git commit"}),y.jsx("span",{className:"text-muted-foreground/70",children:"·"}),y.jsx("span",{className:"text-muted-foreground/80",children:l})]}),i&&y.jsx("div",{className:"bg-card/60 border border-border rounded-lg overflow-hidden max-w-full",children:y.jsx("div",{className:"overflow-x-auto max-w-full",children:y.jsx(Rn,{language:"bash",style:Un,customStyle:{margin:0,padding:"0.75rem",fontSize:"0.75rem",lineHeight:"1.5",background:"transparent",maxWidth:"100%"},wrapLines:!0,wrapLongLines:!0,children:i})})})]})}function I3({contentJson:e,toolDurationMs:n}){const a=e.result||{},i=String(a.output||""),l=Lt(n);return y.jsxs("div",{className:"text-xs space-y-2",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"font-medium text-purple-700 dark:text-purple-300",children:"apply patch"}),y.jsx("span",{className:"text-muted-foreground/70",children:"·"}),y.jsx("span",{className:"text-muted-foreground/80",children:l})]}),i&&y.jsx("div",{className:"bg-card/60 border border-border rounded-lg overflow-hidden max-h-96 overflow-y-auto max-w-full",children:y.jsx("div",{className:"overflow-x-auto max-w-full",children:y.jsx(Rn,{language:"bash",style:Un,customStyle:{margin:0,padding:"0.75rem",fontSize:"0.75rem",lineHeight:"1.5",background:"transparent",maxWidth:"100%"},wrapLines:!0,wrapLongLines:!0,children:i})})})]})}function O3({contentJson:e,toolDurationMs:n,isExpanded:a,onToggle:i}){const u=(e.result||{}).entries||[],c=Lt(n);return y.jsxs("div",{className:"text-xs",children:[y.jsxs("button",{type:"button",onClick:i,className:"flex items-center gap-2 text-cyan-700 dark:text-cyan-300 transition-colors hover:text-cyan-600 dark:hover:text-cyan-200",children:[a?y.jsx(Ur,{className:"h-3 w-3"}):y.jsx(_n,{className:"h-3 w-3"}),y.jsx("span",{className:"font-medium",children:"ls"}),y.jsx("span",{className:"text-muted-foreground/70",children:"·"}),y.jsxs("span",{className:"text-foreground/70",children:[u.length," ",u.length===1?"entry":"entries"]}),y.jsxs("span",{className:"text-muted-foreground/80",children:["· ",c]})]}),a&&y.jsx("div",{className:"mt-2 ml-5 space-y-0.5 max-h-96 overflow-y-auto",children:u.map((d,f)=>{const g=d;return y.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-mono text-foreground/80",children:[g.isDirectory?y.jsx(h0,{className:"h-3 w-3 text-blue-500"}):y.jsx(Ul,{className:"h-3 w-3 text-muted-foreground"}),y.jsx("span",{children:g.name})]},`${g.name}-${f}`)})})]})}function L3({contentJson:e,toolDurationMs:n,isExpanded:a,onToggle:i}){const l=e.result||{},u=String(l.tree||""),c=u.split(`
317
- `).length,d=Lt(n);return y.jsxs("div",{className:"text-xs",children:[y.jsxs("button",{type:"button",onClick:i,className:"flex items-center gap-2 text-cyan-700 dark:text-cyan-300 transition-colors hover:text-cyan-600 dark:hover:text-cyan-200",children:[a?y.jsx(Ur,{className:"h-3 w-3"}):y.jsx(_n,{className:"h-3 w-3"}),y.jsx("span",{className:"font-medium",children:"tree"}),y.jsx("span",{className:"text-muted-foreground/70",children:"·"}),y.jsxs("span",{className:"text-foreground/70",children:[c," ",c===1?"line":"lines"]}),y.jsxs("span",{className:"text-muted-foreground/80",children:["· ",d]})]}),a&&u&&y.jsx("div",{className:"mt-2 ml-5 bg-card/60 border border-border rounded-lg overflow-hidden max-h-96 overflow-y-auto max-w-full",children:y.jsx("div",{className:"overflow-x-auto max-w-full",children:y.jsx(Rn,{language:"bash",style:Un,customStyle:{margin:0,padding:"0.75rem",fontSize:"0.75rem",lineHeight:"1.5",background:"transparent",maxWidth:"100%"},wrapLines:!0,wrapLongLines:!0,children:u})})})]})}function D3({contentJson:e,toolDurationMs:n,isExpanded:a,onToggle:i}){const u=(e.result||{}).matches||[],c=Lt(n);return y.jsxs("div",{className:"text-xs",children:[y.jsxs("button",{type:"button",onClick:i,className:"flex items-center gap-2 text-amber-700 dark:text-amber-300 transition-colors hover:text-amber-600 dark:hover:text-amber-200",children:[a?y.jsx(Ur,{className:"h-3 w-3"}):y.jsx(_n,{className:"h-3 w-3"}),y.jsx("span",{className:"font-medium",children:"search"}),y.jsx("span",{className:"text-muted-foreground/70",children:"·"}),y.jsxs("span",{className:"text-foreground/70",children:[u.length," ",u.length===1?"match":"matches"]}),y.jsxs("span",{className:"text-muted-foreground/80",children:["· ",c]})]}),a&&y.jsx("div",{className:"mt-2 ml-5 space-y-1 max-h-96 overflow-y-auto",children:u.map((d,f)=>{const g=d;return y.jsxs("div",{className:"text-xs font-mono bg-card/60 border border-border rounded px-2 py-1",children:[y.jsxs("div",{className:"text-blue-600 dark:text-blue-400 truncate",children:[g.file,":",g.line]}),y.jsx("div",{className:"text-foreground/80 truncate",children:g.text})]},`${g.file}-${g.line}-${f}`)})})]})}function M3({toolDurationMs:e}){const n=Lt(e);return y.jsx("div",{className:"text-xs",children:y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"font-medium text-emerald-700 dark:text-emerald-300",children:"Done"}),n&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-muted-foreground/70",children:"·"}),y.jsx("span",{className:"text-muted-foreground/80",children:n})]})]})})}function U3({toolName:e,contentJson:n,toolDurationMs:a}){const i=n.result,l=Lt(a);return y.jsxs("div",{className:"text-xs space-y-2",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"font-medium text-foreground",children:e}),y.jsx("span",{className:"text-muted-foreground/70",children:"·"}),y.jsx("span",{className:"text-muted-foreground/80",children:l})]}),i&&y.jsx("div",{className:"bg-card/60 border border-border rounded-lg overflow-hidden max-h-96 overflow-y-auto max-w-full",children:y.jsx("div",{className:"overflow-x-auto max-w-full",children:y.jsx(Rn,{language:"json",style:Un,customStyle:{margin:0,padding:"0.75rem",fontSize:"0.75rem",lineHeight:"1.5",background:"transparent",maxWidth:"100%"},wrapLines:!0,wrapLongLines:!0,children:JSON.stringify(i,null,2)})})})]})}function F3({contentJson:e,toolDurationMs:n}){return y.jsx("div",{className:"text-xs",children:y.jsxs("div",{className:"text-muted-foreground",children:[y.jsxs("div",{children:["Tool: ",e.name]}),y.jsxs("div",{children:["Duration: ",n,"ms"]}),y.jsx("pre",{className:"mt-2 text-[10px] bg-card border border-border p-2 rounded overflow-x-auto",children:JSON.stringify(e,null,2)})]})})}function B3({contentJson:e}){const n=e.result||{},a=n.items||[],i=n.note;return y.jsx("div",{className:"text-xs",children:y.jsxs("div",{className:"bg-blue-500/10 border border-blue-500/30 dark:bg-blue-500/5 dark:border-blue-500/20 rounded-lg p-3 space-y-2",children:[i&&y.jsx("div",{className:"text-blue-700 dark:text-blue-300 text-sm font-medium mb-3",children:i}),y.jsx("div",{className:"space-y-1.5",children:a.map((l,u)=>y.jsxs("div",{className:"flex items-start gap-2",children:[l.status==="completed"&&y.jsx(V1,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300 flex-shrink-0 mt-0.5"}),l.status==="in_progress"&&y.jsx(B1,{className:"h-4 w-4 text-blue-700 dark:text-blue-300 flex-shrink-0 mt-0.5 animate-pulse"}),l.status==="pending"&&y.jsx(X1,{className:"h-4 w-4 text-muted-foreground flex-shrink-0 mt-0.5"}),y.jsx("span",{className:`text-sm ${l.status==="completed"?"text-muted-foreground line-through":l.status==="in_progress"?"text-foreground":"text-muted-foreground/80"}`,children:l.step})]},`${l.step}-${u}`))})]})})}function z3({contentJson:e}){const n=e.result||{},a=String(n.message||"Processing..."),i=n.stage?String(n.stage):void 0,l=n.pct?Number(n.pct):void 0;return y.jsxs("div",{className:"flex items-center gap-2 text-sm text-violet-700 dark:text-violet-300 animate-pulse",children:[i&&y.jsxs("span",{className:"text-muted-foreground/80",children:["[",i,"]"]}),y.jsx("span",{children:a}),l!==void 0&&y.jsxs("span",{className:"text-muted-foreground/80",children:["(",l,"%)"]})]})}function j3({contentJson:e,toolDurationMs:n,isExpanded:a,onToggle:i}){const l=e.result||{},[u,c]=te.useState(new Set),d=S=>{c(_=>{const x=new Set(_);return x.has(S)?x.delete(S):x.add(S),x})},f="results"in l,g=l.results||[],b=l;if(f){const S=Lt(n);return y.jsxs("div",{className:"text-xs",children:[y.jsxs("button",{type:"button",onClick:i,className:"flex items-center gap-2 text-purple-700 dark:text-purple-300 transition-colors hover:text-purple-600 dark:hover:text-purple-200",children:[a?y.jsx(Ur,{className:"h-3 w-3"}):y.jsx(_n,{className:"h-3 w-3"}),y.jsx("span",{className:"font-medium",children:"web search"}),y.jsx("span",{className:"text-muted-foreground/70",children:"·"}),y.jsxs("span",{className:"text-foreground/70",children:[g.length," ",g.length===1?"result":"results"]}),y.jsxs("span",{className:"text-muted-foreground/80",children:["· ",S]})]}),a&&y.jsx("div",{className:"mt-2 ml-5 space-y-2 max-h-96 overflow-y-auto",children:g.map((_,x)=>y.jsxs("div",{className:"bg-card/60 border border-border rounded-lg p-3 space-y-1",children:[y.jsxs("a",{href:_.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-blue-600 dark:text-blue-400 hover:underline font-medium",children:[_.title,y.jsx(a0,{className:"h-3 w-3"})]}),y.jsx("p",{className:"text-muted-foreground text-xs",children:_.snippet}),y.jsx("p",{className:"text-xs text-muted-foreground/70 truncate",children:_.url})]},`${_.url}-${x}`))})]})}const h=Lt(n),E=b.url&&b.url.length>60?`${b.url.slice(0,60)}...`:b.url;return y.jsxs("div",{className:"text-xs",children:[y.jsxs("button",{type:"button",onClick:()=>d(0),className:"flex items-center gap-2 text-purple-700 dark:text-purple-300 transition-colors hover:text-purple-600 dark:hover:text-purple-200 w-full text-left",children:[u.has(0)?y.jsx(Ur,{className:"h-3 w-3 flex-shrink-0"}):y.jsx(_n,{className:"h-3 w-3 flex-shrink-0"}),y.jsx("span",{className:"font-medium flex-shrink-0",children:"web fetch"}),y.jsx("span",{className:"text-muted-foreground/70 flex-shrink-0",children:"·"}),y.jsx("a",{href:b.url,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:underline truncate flex-1 min-w-0",onClick:S=>S.stopPropagation(),children:E}),y.jsxs("span",{className:"text-muted-foreground/80 flex-shrink-0",children:["· ",h]})]}),u.has(0)&&b.content&&y.jsx("div",{className:"mt-2 ml-5 bg-card/60 border border-border rounded-lg p-3 max-h-96 overflow-y-auto",children:y.jsx("div",{className:"text-xs text-foreground/80 whitespace-pre-wrap break-words",children:b.content})})]})}function q3({contentJson:e,debug:n}){const[a,i]=te.useState(!1);let l,u,c,d=!1;e.error&&typeof e.error=="object"?(l=e.error,l.message&&typeof l.message=="string"&&(u=l.message),l.type&&typeof l.type=="string"&&(c=l.type)):e.details&&typeof e.details=="object"?(l=e.details,e.message&&typeof e.message=="string"&&(u=e.message),e.type&&typeof e.type=="string"&&(c=e.type),e.isAborted===!0&&(d=!0)):(e.message&&typeof e.message=="string"&&(u=e.message),e.type&&typeof e.type=="string"&&(c=e.type),e.isAborted===!0&&(d=!0),l=e);let f;if(l?.responseBody&&typeof l.responseBody=="string")try{const E=JSON.parse(l.responseBody);E.error&&typeof E.error=="object"&&(f={type:typeof E.error.type=="string"?E.error.type:void 0,message:typeof E.error.message=="string"?E.error.message:void 0})}catch{}const g=E=>{if(E==null)return y.jsx("span",{className:"text-muted-foreground",children:"null"});if(typeof E=="boolean")return y.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:String(E)});if(typeof E=="number")return y.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:E});if(typeof E=="string"){if(E.startsWith("{")||E.startsWith("["))try{const S=JSON.parse(E);return y.jsx("pre",{className:"mt-1 p-2 bg-muted/50 rounded text-xs overflow-x-auto",children:y.jsx("code",{children:JSON.stringify(S,null,2)})})}catch{}return y.jsx("span",{className:"text-foreground",children:E})}return typeof E=="object"?y.jsx("pre",{className:"mt-1 p-2 bg-muted/50 rounded text-xs overflow-x-auto",children:y.jsx("code",{children:JSON.stringify(E,null,2)})}):y.jsx("span",{className:"text-foreground",children:String(E)})},b=["name","statusCode","url","model","isRetryable","cause"],h=new Set;return y.jsxs("div",{className:"space-y-2 text-sm",children:[d&&y.jsx("div",{className:"text-amber-600 dark:text-amber-400 font-medium",children:"Request aborted"}),f?.message&&y.jsxs("div",{className:"space-y-1",children:[y.jsx("div",{className:"font-medium text-red-600 dark:text-red-400",children:"API Error:"}),y.jsx("div",{className:"text-foreground",children:f.message}),f.type&&y.jsxs("div",{className:"text-xs text-muted-foreground",children:["Type: ",f.type]})]}),!f?.message&&u&&y.jsxs("div",{className:"space-y-1",children:[y.jsx("div",{className:"font-medium text-red-600 dark:text-red-400",children:"Error:"}),y.jsx("div",{className:"text-foreground",children:u}),c&&y.jsxs("div",{className:"text-xs text-muted-foreground",children:["Type: ",c]})]}),l&&y.jsx("div",{className:"space-y-1.5",children:b.map(E=>{const S=l[E];return S==null?null:(h.add(E),y.jsxs("div",{className:"flex gap-2",children:[y.jsxs("span",{className:"font-medium text-muted-foreground min-w-[100px]",children:[E,":"]}),g(S)]},E))})}),l&&y.jsxs("div",{className:"mt-3 border-t border-border pt-2",children:[y.jsxs("button",{type:"button",onClick:()=>i(!a),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[a?y.jsx(Ur,{className:"h-3 w-3"}):y.jsx(_n,{className:"h-3 w-3"}),a?"Hide":"View"," Raw Error Details"]}),a&&y.jsx("div",{className:"mt-2",children:y.jsx("pre",{className:"p-3 bg-muted/50 rounded text-xs overflow-x-auto max-h-96 overflow-y-auto",children:y.jsx("code",{children:JSON.stringify(l,null,2)})})})]}),n&&y.jsxs("details",{className:"mt-4 text-xs",children:[y.jsx("summary",{className:"cursor-pointer text-muted-foreground",children:"Debug Info"}),y.jsx("pre",{className:"mt-2 p-2 bg-muted/30 rounded overflow-x-auto",children:y.jsx("code",{children:JSON.stringify({contentJson:e,errorDetails:l,apiError:f},null,2)})})]})]})}function ww({toolName:e,contentJson:n,toolDurationMs:a,debug:i}){const[l,u]=te.useState(!1),c={contentJson:n,toolDurationMs:a??void 0,isExpanded:l,onToggle:()=>u(!l)};if(i)return y.jsx(F3,{...c,toolName:e});switch(e){case"read":return y.jsx(x3,{...c});case"write":return y.jsx(_3,{...c});case"edit":return y.jsx(R3,{...c});case"bash":return y.jsx(N3,{...c});case"git_status":return y.jsx(w3,{...c});case"git_diff":return y.jsx(k3,{...c});case"git_commit":return y.jsx(C3,{...c});case"apply_patch":return y.jsx(I3,{...c});case"ls":return y.jsx(O3,{...c});case"tree":return y.jsx(L3,{...c});case"ripgrep":case"grep":case"glob":return y.jsx(D3,{...c});case"websearch":return y.jsx(j3,{...c});case"finish":return y.jsx(M3,{...c});case"update_plan":return y.jsx(B3,{...c});case"progress_update":return y.jsx(z3,{...c});case"error":return y.jsx(q3,{...c});default:return y.jsx(U3,{...c,toolName:e})}}function Vh(e){const n=e.contentJson;if(n&&typeof n=="object")return n;try{if(e.content){const a=JSON.parse(e.content);if(a&&typeof a=="object"&&!Array.isArray(a))return a}}catch{}return null}function P3(e){const n=Vh(e);if(!n)return;const a=n.args;if(a&&typeof a=="object"&&!Array.isArray(a))return a}function G3(e){if(!e)return null;const n=["cmd","command","script","input"];for(const a of n){const i=e[a];if(typeof i=="string"&&i.trim().length>0)return i.trim()}return null}function H3(e,n){if(!n)return null;const a=[{key:"path",match:!0},{key:"file",match:!0},{key:"target",match:!0},{key:"cwd",match:!0},{key:"query",match:!0},{key:"pattern",match:!0},{key:"glob",match:!0},{key:"dir",match:!0}];for(const{key:i}of a){const l=n[i];if(typeof l=="string"&&l.trim().length>0)return{key:i,value:l.trim()}}if(e==="bash"){const i=n.command;if(typeof i=="string"&&i.trim().length>0)return{key:"command",value:i.trim()}}return null}function $3(e,n){if(!e)return null;const a=[];for(const[l,u]of Object.entries(e))if(!(n&&l===n)){if(typeof u=="string"||typeof u=="number"){const c=`${l}=${String(u)}`;a.push(c)}if(a.length>=3)break}if(!a.length)return null;const i=a.join(" ");return i.length>120?`${i.slice(0,117)}…`:i}const kw=te.memo(function({part:n,showLine:a,isLastToolCall:i,isLastProgressUpdate:l}){if(n.type==="tool_call"&&!i||n.type==="tool_result"&&n.toolName==="progress_update"&&!l)return null;if(n.type==="text"){const h=n.contentJson||n.content;let E="";if(h&&typeof h=="object"&&"text"in h?E=String(h.text):typeof h=="string"&&(E=h),!E||!E.trim())return null}const u=n.type==="tool_call"||n.type==="tool_result",c=["flex-1","min-w-0","max-w-full"];u?c.push("pt-0.5","mt-[1px]"):c.push("pt-0"),n.type==="text"&&c.push("-mt-0.5");const d=c.join(" "),f=()=>{if(n.type==="tool_call")return y.jsx(Kw,{className:"h-4 w-4 text-amber-600 dark:text-amber-300 animate-spin"});if(n.type==="error")return Vh(n)?.isAborted===!0?y.jsx(w0,{className:"h-4 w-4 text-amber-600 dark:text-amber-400"}):y.jsx($w,{className:"h-4 w-4 text-red-600 dark:text-red-400"});if(n.type==="tool_result"){const h=n.toolName||"";return h==="read"?y.jsx(u0,{className:"h-4 w-4 text-blue-600 dark:text-blue-300"}):h==="write"?y.jsx(Vv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300"}):h==="edit"?y.jsx(Vv,{className:"h-4 w-4 text-purple-600 dark:text-purple-300"}):h==="ls"?y.jsx(v0,{className:"h-4 w-4 text-cyan-600 dark:text-cyan-300"}):h==="tree"?y.jsx(g0,{className:"h-4 w-4 text-cyan-600 dark:text-cyan-300"}):h==="bash"?y.jsx(Kv,{className:"h-4 w-4 text-muted-foreground"}):h==="ripgrep"||h==="grep"||h==="glob"?y.jsx(L0,{className:"h-4 w-4 text-amber-600 dark:text-amber-300"}):h==="apply_patch"?y.jsx($v,{className:"h-4 w-4 text-purple-600 dark:text-purple-300"}):h==="git_status"?y.jsx(Pl,{className:"h-4 w-4 text-blue-600 dark:text-blue-300"}):h==="git_diff"?y.jsx($v,{className:"h-4 w-4 text-purple-600 dark:text-purple-300"}):h==="git_commit"?y.jsx(Gl,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300"}):h==="finish"?y.jsx(Hw,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300"}):y.jsx(Kv,{className:"h-4 w-4 text-muted-foreground"})}return y.jsx(Hl,{className:"h-4 w-4 text-violet-600 dark:text-violet-300"})},g=()=>{const h=n.toolName||"";let E;try{n.contentJson&&typeof n.contentJson=="object"?E=n.contentJson:typeof n.content=="string"?E=JSON.parse(n.content):E={}}catch{E={result:n.content}}return y.jsx(ww,{toolName:h,contentJson:E,toolDurationMs:n.toolDurationMs,debug:!1})},b=()=>{if(n.type==="text"){let h="";const E=n.contentJson||n.content;return E&&typeof E=="object"&&"text"in E?h=String(E.text):typeof E=="string"?h=E:E&&(h=JSON.stringify(E,null,2)),y.jsx("div",{className:"text-base text-foreground leading-relaxed markdown-content max-w-full overflow-hidden",children:y.jsx(Jk,{remarkPlugins:[xC],children:h})})}if(n.type==="error"){let h;try{n.contentJson&&typeof n.contentJson=="object"?h=n.contentJson:typeof n.content=="string"?h=JSON.parse(n.content):h={}}catch{h={message:n.content||"Unknown error"}}return y.jsx(ww,{toolName:"error",contentJson:h,toolDurationMs:n.toolDurationMs,debug:!1})}if(n.type==="tool_call"){const h=Vh(n),E=n.toolName||(typeof h?.name=="string"?h.name:"tool"),S=E.replace(/_/g," "),_=P3(n),x=H3(E,_),C=$3(_,x?.key),T=E==="bash"?G3(_):null,A=[];T?A.push({key:"cmd",node:y.jsx("code",{className:"font-mono text-foreground/90 truncate max-w-xs",children:T})}):x&&A.push({key:"primary",node:y.jsx("code",{className:"font-mono text-foreground/85 truncate max-w-xs",children:x.value})}),C&&A.push({key:"args",node:y.jsx("span",{className:"text-muted-foreground/80 truncate max-w-xs",children:C})}),A.length===0&&A.push({key:"running",node:y.jsx("span",{className:"text-muted-foreground/75",children:"running…"})});const N=["flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-foreground/80 max-w-full"];return n.ephemeral&&N.push("animate-pulse"),y.jsxs("div",{className:N.join(" "),children:[y.jsx("span",{className:"font-medium text-foreground",children:S}),A.map(L=>y.jsxs(te.Fragment,{children:[y.jsx("span",{className:"text-muted-foreground/65",children:"·"}),L.node]},L.key))]})}return n.type==="tool_result"?g():null};return y.jsxs("div",{className:"flex gap-3 pb-2 relative max-w-full overflow-hidden",children:[y.jsxs("div",{className:"flex-shrink-0 w-6 flex items-start justify-center relative pt-0.5",children:[y.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full relative z-10 bg-background",children:f()}),a&&y.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 w-[2px] bg-border z-0",style:{top:"1.25rem",bottom:"-0.5rem"}})]}),y.jsx("div",{className:d,children:b()})]})},(e,n)=>e.part.id===n.part.id&&e.part.content===n.part.content&&e.part.contentJson===n.part.contentJson&&e.part.ephemeral===n.part.ephemeral&&e.part.completedAt===n.part.completedAt&&e.showLine===n.showLine&&e.isLastToolCall===n.isLastToolCall&&e.isLastProgressUpdate===n.isLastProgressUpdate),Cw=["Generating...","Cooking up something...","Thinking...","Processing...","Working on it...","Crafting response...","Brewing magic...","Computing..."];function V3(e){const n=e.split("").reduce((a,i)=>a+i.charCodeAt(0),0);return Cw[n%Cw.length]}const Y3=te.memo(function({message:n,showHeader:a,hasNextAssistantMessage:i}){const l=n.parts||[],u=l.some(S=>S.toolName==="finish"),c=l.reduce((S,_,x)=>_.type==="tool_result"&&_.toolName==="progress_update"?x:S,-1),d=c>=0?l[c]:null,f=l.some(S=>!(S.type==="tool_result"&&S.toolName==="progress_update")),g=l.findIndex(S=>!(S.type==="tool_result"&&S.toolName==="progress_update")),b=n.status==="pending"&&!u&&!!d,h=n.status==="pending"&&!u&&!d,E=S=>S?new Date(S).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"";return y.jsxs("div",{className:"relative",children:[a&&y.jsx("div",{className:"pb-2",children:y.jsxs("div",{className:"inline-flex items-center bg-violet-500/10 border border-violet-500/30 dark:bg-violet-500/5 dark:border-violet-500/20 rounded-full pr-4",children:[y.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-violet-500/50 bg-violet-500/20 dark:bg-violet-500/10",children:y.jsx(Hl,{className:"h-3.5 w-3.5 text-violet-700 dark:text-violet-300"})}),y.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground pl-3",children:[n.agent&&y.jsx("span",{className:"font-medium text-violet-700 dark:text-violet-300",children:n.agent}),n.agent&&n.provider&&y.jsx("span",{children:"·"}),n.provider&&y.jsx("span",{className:"text-muted-foreground",children:n.provider}),n.model&&y.jsx("span",{children:"·"}),n.model&&y.jsx("span",{className:"text-muted-foreground",children:n.model}),n.createdAt&&y.jsx("span",{children:"·"}),n.createdAt&&y.jsx("span",{className:"text-muted-foreground",children:E(n.createdAt)})]})]})}),y.jsxs("div",{className:"relative ml-1",children:[l.map((S,_)=>{const x=_===l.length-1,C=!x||i,T=S.type==="tool_call"&&x;return S.type==="tool_result"&&S.toolName==="progress_update"?null:y.jsx(kw,{part:S,showLine:C,isFirstPart:_===g&&!a,isLastToolCall:T},S.id)}),b&&d&&y.jsx(kw,{part:d,showLine:i,isFirstPart:!f&&!a,isLastProgressUpdate:!0},d.id),h&&y.jsxs("div",{className:"flex gap-3 pb-2 relative",children:[y.jsx("div",{className:"flex-shrink-0 w-6 flex items-start justify-center relative pt-0.5",children:y.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full relative z-10 bg-card text-violet-700 dark:bg-background dark:text-violet-300",children:y.jsx(Hl,{className:"h-4 w-4"})})}),y.jsx("div",{className:"flex-1 pt-0.5",children:y.jsx("div",{className:"text-base text-foreground animate-pulse",children:V3(n.id)})})]})]})]})},(e,n)=>{const a=e.message.parts||[],i=n.message.parts||[];if(a.length!==i.length)return!1;for(let l=0;l<a.length;l++){const u=a[l],c=i[l];if(u.id!==c.id||u.content!==c.content||u.contentJson!==c.contentJson||u.ephemeral!==c.ephemeral||u.completedAt!==c.completedAt)return!1}return e.message.id===n.message.id&&e.message.status===n.message.status&&e.message.completedAt===n.message.completedAt&&e.showHeader===n.showHeader&&e.hasNextAssistantMessage===n.hasNextAssistantMessage&&e.isLastMessage===n.isLastMessage}),K3=te.memo(function({message:n}){const i=(n.parts||[])[0];if(!i)return null;let l="";const u=i.contentJson||i.content;u&&typeof u=="object"&&"text"in u?l=String(u.text):typeof u=="string"?l=u:u&&(l=JSON.stringify(u,null,2));const c=d=>d?new Date(d).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"";return y.jsx("div",{className:"relative pb-8 pt-6",children:y.jsxs("div",{className:"flex gap-4 justify-end",children:[y.jsxs("div",{className:"flex flex-col items-end max-w-2xl",children:[y.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground pb-2 justify-end",children:[y.jsx("span",{className:"font-medium text-emerald-700 dark:text-emerald-300",children:"You"}),n.createdAt&&y.jsx("span",{children:"·"}),n.createdAt&&y.jsx("span",{children:c(n.createdAt)})]}),y.jsx("div",{className:"text-sm text-foreground leading-relaxed prose prose-invert prose-sm [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 bg-emerald-500/5 border border-emerald-500/20 rounded-xl px-4 py-3 max-w-full break-words overflow-wrap-anywhere",children:y.jsx(Jk,{remarkPlugins:[xC],children:l})})]}),y.jsx("div",{className:"flex-shrink-0 w-8 flex items-start justify-center",children:y.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full border-2 border-emerald-500/50 bg-emerald-500/20 dark:bg-emerald-500/10 relative z-10 bg-background",children:y.jsx(q0,{className:"h-4 w-4 text-emerald-700 dark:text-emerald-300"})})})]})})},(e,n)=>{const a=e.message.parts?.[0],i=n.message.parts?.[0];return e.message.id===n.message.id&&a?.content===i?.content&&a?.contentJson===i?.contentJson&&e.message.createdAt===n.message.createdAt});function W3({session:e}){const n=te.useMemo(()=>{const u=e.totalInputTokens||0,c=e.totalOutputTokens||0;return u+c},[e.totalInputTokens,e.totalOutputTokens]),a=te.useMemo(()=>{const u=e.totalInputTokens||0,c=e.totalOutputTokens||0,d=30,f=60,g=u/1e6*d,b=c/1e6*f;return g+b},[e.totalInputTokens,e.totalOutputTokens]),i=u=>{if(!u)return"0s";const c=Math.floor(u/1e3),d=Math.floor(c/60),f=Math.floor(d/60);if(f>0){const g=d%60;return`${f}h ${g}m`}if(d>0){const g=c%60;return`${d}m ${g}s`}return`${c}s`},l=u=>u.toLocaleString("en-US");return y.jsx("div",{className:"border-b border-border bg-background/95 backdrop-blur-sm",children:y.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-6",children:[y.jsx("h1",{className:"text-2xl font-semibold text-foreground mb-4",children:e.title||"Untitled Session"}),y.jsxs("div",{className:"flex flex-wrap gap-6 text-sm",children:[y.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[y.jsx(Yw,{className:"w-4 h-4"}),y.jsxs("div",{className:"flex flex-col",children:[y.jsx("span",{className:"text-xs uppercase tracking-wide opacity-70",children:"Total Tokens"}),y.jsx("span",{className:"text-foreground font-medium",children:l(n)}),(e.totalInputTokens||e.totalOutputTokens)&&y.jsxs("span",{className:"text-xs opacity-60",children:[l(e.totalInputTokens||0)," in /"," ",l(e.totalOutputTokens||0)," out"]})]})]}),y.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[y.jsx(Q1,{className:"w-4 h-4"}),y.jsxs("div",{className:"flex flex-col",children:[y.jsx("span",{className:"text-xs uppercase tracking-wide opacity-70",children:"Tool Time"}),y.jsx("span",{className:"text-foreground font-medium",children:i(e.totalToolTimeMs)})]})]}),a>0&&y.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[y.jsx(Vw,{className:"w-4 h-4"}),y.jsxs("div",{className:"flex flex-col",children:[y.jsx("span",{className:"text-xs uppercase tracking-wide opacity-70",children:"Est. Cost"}),y.jsxs("span",{className:"text-foreground font-medium",children:["$",a.toFixed(4)]})]})]}),y.jsx("div",{className:"flex items-center gap-2 text-muted-foreground ml-auto",children:y.jsxs("div",{className:"flex flex-col items-end",children:[y.jsx("span",{className:"text-xs uppercase tracking-wide opacity-70",children:"Model"}),y.jsx("span",{className:"text-foreground font-medium",children:e.model}),y.jsxs("span",{className:"text-xs opacity-60",children:[e.provider," · ",e.agent]})]})})]})]})})}function X3({sessionId:e,onStop:n,disabled:a}){const[i,l]=te.useState(!1),u=async()=>{if(!i){l(!0);try{await Ht.abortSession(e),n?.()}catch(c){console.error("Failed to abort stream:",c)}finally{setTimeout(()=>l(!1),1e3)}}};return y.jsxs("button",{type:"button",onClick:u,disabled:a||i,className:"flex items-center gap-1.5 text-sm text-destructive hover:text-destructive/80 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",title:"Stop generation",children:[y.jsx(K1,{className:"w-4 h-4"}),y.jsx("span",{className:"font-medium",children:i?"Stopping...":"Stop"})]})}function Z3({session:e,isVisible:n,isGenerating:a}){const i=te.useMemo(()=>{const c=e.totalInputTokens||0,d=e.totalOutputTokens||0;return c+d},[e.totalInputTokens,e.totalOutputTokens]),l=te.useMemo(()=>{const c=e.totalInputTokens||0,d=e.totalOutputTokens||0,f=30,g=60,b=c/1e6*f,h=d/1e6*g;return b+h},[e.totalInputTokens,e.totalOutputTokens]),u=c=>c.toLocaleString("en-US");return y.jsx("div",{className:`absolute top-0 left-0 right-0 h-14 border-b border-border bg-background/95 backdrop-blur-sm z-30 transition-transform duration-200 ${n?"translate-y-0":"-translate-y-full"}`,children:y.jsxs("div",{className:"h-full px-6 flex items-center justify-between gap-6 text-sm",children:[y.jsx("div",{className:"flex-shrink-0",children:a&&y.jsx(X3,{sessionId:e.id})}),y.jsxs("div",{className:"flex items-center gap-6",children:[y.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[y.jsx(Yw,{className:"w-4 h-4"}),y.jsx("span",{className:"text-foreground font-medium",children:u(i)})]}),l>0&&y.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[y.jsx(Vw,{className:"w-4 h-4"}),y.jsxs("span",{className:"text-foreground font-medium",children:["$",l.toFixed(4)]})]})]})]})})}const Q3=te.memo(function({messages:n,session:a,isGenerating:i}){const l=te.useRef(null),u=te.useRef(null),c=te.useRef(null),[d,f]=te.useState(!0),[g,b]=te.useState(!1),h=te.useRef(0),E=te.useRef(0),S=()=>{const C=u.current;if(!C)return;const{scrollTop:T,scrollHeight:A,clientHeight:N}=C,L=A-T-N;f(L<100);const U=c.current;if(U){const w=U.getBoundingClientRect(),M=C.getBoundingClientRect();b(w.bottom<M.top)}};te.useEffect(()=>{n.length>E.current&&f(!0),E.current=n.length},[n.length]),te.useEffect(()=>{const C=u.current;!C||!d||requestAnimationFrame(()=>{if(!l.current||!C)return;const{scrollHeight:T}=C,N=T!==h.current?"smooth":"instant";l.current.scrollIntoView({behavior:N}),h.current=T})},[n,d]);const _=()=>{f(!0),l.current?.scrollIntoView({behavior:"smooth"})},x=te.useMemo(()=>n.filter(C=>C.role!=="system"),[n]);return n.length===0?y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:"No messages yet. Start a conversation below."}):y.jsxs("div",{className:"absolute inset-0 flex flex-col",children:[a&&y.jsx(Z3,{session:a,isVisible:g,isGenerating:i}),y.jsxs("div",{ref:u,className:"flex-1 overflow-y-auto",onScroll:S,children:[y.jsx("div",{ref:c,children:a&&y.jsx(W3,{session:a})}),y.jsx("div",{className:"p-6 pb-32",children:y.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[x.map((C,T)=>{const A=x[T-1],N=x[T+1],L=T===x.length-1;if(C.role==="user")return y.jsx(K3,{message:C,isFirst:T===0},C.id);if(C.role==="assistant"){const U=!A||A.role!=="assistant",w=N&&N.role==="assistant";return y.jsx(Y3,{message:C,showHeader:U,hasNextAssistantMessage:w,isLastMessage:L},C.id)}return null}),y.jsx("div",{ref:l})]})})]}),!d&&y.jsxs("button",{type:"button",onClick:_,className:"absolute bottom-36 left-1/2 -translate-x-1/2 flex items-center gap-2 px-4 py-2 bg-background border border-border rounded-full shadow-lg hover:bg-muted/50 transition-all text-sm text-foreground z-10",children:[y.jsx(U1,{className:"w-4 h-4"}),y.jsx("span",{children:"Scroll to bottom"})]})]})}),J3=te.memo(function({sessionId:n}){const{data:a=[],isLoading:i}=Xz(n),{data:l=[]}=bk();Jz(n);const u=te.useMemo(()=>l.find(d=>d.id===n),[l,n]),c=te.useMemo(()=>a.some(d=>d.role==="assistant"&&d.status==="pending"),[a]);return i?y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:"Loading messages..."}):y.jsx(Q3,{messages:a,session:u,isGenerating:c})}),e$=te.memo(function({onSend:n,disabled:a,onConfigClick:i}){const[l,u]=te.useState(""),c=te.useRef(null);te.useEffect(()=>{c.current?.focus()},[]);const d=te.useCallback(()=>{const h=c.current;h&&(h.style.height="auto",h.style.height=`${h.scrollHeight}px`)},[]);te.useEffect(()=>{d()},[d,l]);const f=te.useCallback(()=>{l.trim()&&!a&&(n(l),u(""),c.current&&(c.current.style.height="auto"),c.current?.focus())},[l,a,n]),g=te.useCallback(h=>{u(h.target.value)},[]),b=te.useCallback(h=>{h.key==="Enter"&&!h.shiftKey&&(h.preventDefault(),f())},[f]);return y.jsx("div",{className:"absolute bottom-0 left-0 right-0 pt-16 pb-8 px-4 bg-gradient-to-t from-background via-background to-transparent pointer-events-none z-20",children:y.jsx("div",{className:"max-w-3xl mx-auto pointer-events-auto",children:y.jsxs("div",{className:"flex items-end gap-1 bg-card rounded-3xl border border-border p-1 focus-within:border-primary/60 focus-within:ring-1 focus-within:ring-primary/40 transition-colors",children:[i&&y.jsx("button",{type:"button",onClick:i,className:"flex items-center justify-center w-10 h-10 rounded-full hover:bg-background/50 transition-colors text-muted-foreground hover:text-foreground flex-shrink-0",children:y.jsx(n0,{className:"w-4 h-4"})}),y.jsx(ub,{ref:c,value:l,onChange:g,onKeyDown:b,placeholder:"Type a message...",disabled:a,rows:1,className:"border-0 bg-transparent pl-1 pr-2 py-2 max-h-[200px] overflow-y-auto leading-normal resize-none scrollbar-hide",style:{height:"2.5rem"}}),y.jsx("button",{type:"button",onClick:f,disabled:a||!l.trim(),className:`flex items-center justify-center w-10 h-10 rounded-full transition-colors flex-shrink-0 ${l.trim()?"bg-primary hover:bg-primary/90 text-primary-foreground":"bg-transparent text-muted-foreground"}`,children:y.jsx(j1,{className:"w-4 h-4"})})]})})})});function t$(){return ai({queryKey:["config"],queryFn:()=>Ht.getConfig()})}function n$(e){return ai({queryKey:["models",e],queryFn:()=>e?Ht.getModels(e):null,enabled:!!e})}function r$({isOpen:e,onClose:n,agent:a,provider:i,model:l,onAgentChange:u,onProviderChange:c,onModelChange:d}){const{data:f,isLoading:g}=t$(),{data:b,isLoading:h}=n$(i),E=te.useId(),S=te.useId(),_=te.useId();if(te.useEffect(()=>{f&&!a&&!i&&!l&&(u(f.defaults.agent),c(f.defaults.provider),d(f.defaults.model))},[f,a,i,l,u,c,d]),te.useEffect(()=>{b&&b.models.length>0&&(b.models.some(A=>A.id===l)||d(b.default||b.models[0].id))},[b,l,d]),!e)return null;const x=T=>{T.target===T.currentTarget&&n()},C=T=>{T.key==="Escape"&&n()};return y.jsxs(y.Fragment,{children:[y.jsx("button",{type:"button",className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50 cursor-default",onClick:x,onKeyDown:C,"aria-label":"Close modal"}),y.jsx("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-50 w-full max-w-md",children:y.jsxs("div",{className:"bg-background border border-border rounded-lg shadow-lg",children:[y.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[y.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Configuration"}),y.jsx("button",{type:"button",onClick:n,className:"text-muted-foreground hover:text-foreground transition-colors",children:y.jsx(Qh,{className:"h-5 w-5"})})]}),y.jsx("div",{className:"p-4 space-y-4",children:g?y.jsx("div",{className:"text-center text-muted-foreground py-8",children:"Loading configuration..."}):f?y.jsxs(y.Fragment,{children:[y.jsxs("div",{children:[y.jsx("label",{htmlFor:E,className:"block text-sm font-medium text-foreground mb-2",children:"Agent"}),y.jsx("select",{id:E,value:a,onChange:T=>u(T.target.value),className:"w-full bg-background border border-border rounded px-3 py-2 text-foreground outline-none focus:border-violet-500 transition-colors",children:f.agents.map(T=>y.jsx("option",{value:T,children:T},T))})]}),y.jsxs("div",{children:[y.jsx("label",{htmlFor:S,className:"block text-sm font-medium text-foreground mb-2",children:"Provider"}),y.jsx("select",{id:S,value:i,onChange:T=>c(T.target.value),className:"w-full bg-background border border-border rounded px-3 py-2 text-foreground outline-none focus:border-violet-500 transition-colors",children:f.providers.map(T=>y.jsx("option",{value:T,children:T},T))})]}),y.jsxs("div",{children:[y.jsx("label",{htmlFor:_,className:"block text-sm font-medium text-foreground mb-2",children:"Model"}),y.jsx("select",{id:_,value:l,onChange:T=>d(T.target.value),disabled:h||!b,className:"w-full bg-background border border-border rounded px-3 py-2 text-foreground outline-none focus:border-violet-500 transition-colors disabled:opacity-50",children:b?.models.map(T=>y.jsx("option",{value:T.id,children:T.label},T.id))})]})]}):null})]})})]})}const a$=te.memo(function({sessionId:n}){const[a,i]=te.useState(""),[l,u]=te.useState(""),[c,d]=te.useState(""),[f,g]=te.useState(!1),[b,h]=te.useState(0),E=Zz(n);te.useEffect(()=>{h(N=>N+1)},[n]);const S=te.useCallback(async N=>{try{await E.mutateAsync({content:N,agent:a||void 0,provider:l||void 0,model:c||void 0})}catch(L){console.error("Failed to send message:",L)}},[E,a,l,c]),_=te.useCallback(()=>{g(N=>!N)},[]),x=te.useCallback(()=>{g(!1)},[]),C=te.useCallback(N=>{i(N)},[]),T=te.useCallback(N=>{u(N)},[]),A=te.useCallback(N=>{d(N)},[]);return y.jsxs(y.Fragment,{children:[y.jsx(r$,{isOpen:f,onClose:x,agent:a,provider:l,model:c,onAgentChange:C,onProviderChange:T,onModelChange:A}),y.jsx(e$,{onSend:S,disabled:E.isPending,onConfigClick:_},b)]})}),_C="agi-theme",Iw="dark";function i$(){if(typeof window>"u")return Iw;const e=window.localStorage.getItem(_C);return e==="light"||e==="dark"?e:Iw}function o$(){const[e,n]=te.useState(()=>i$());te.useEffect(()=>{if(typeof document>"u")return;const i=document.documentElement;e==="dark"?i.classList.add("dark"):i.classList.remove("dark");try{window.localStorage.setItem(_C,e)}catch(l){console.warn("Failed to persist theme preference",l)}},[e]);const a=te.useCallback(()=>{n(i=>i==="dark"?"light":"dark")},[]);return te.useMemo(()=>({theme:e,setTheme:n,toggleTheme:a}),[e,a])}function l$(){const[e,n]=te.useState(null);return te.useEffect(()=>{(async()=>{try{const u=`${window.AGI_SERVER_URL||Xw}/v1/config/cwd`;console.log("[useWorkingDirectory] Fetching from:",u);const c=await fetch(u);if(!c.ok)throw console.error("[useWorkingDirectory] Failed:",c.status,c.statusText),new Error(`Failed to fetch working directory: ${c.status}`);const d=await c.json();console.log("[useWorkingDirectory] Success:",d),d.dirName&&(console.log("[useWorkingDirectory] Setting title to:",d.dirName),n(d.dirName),document.title=d.dirName)}catch(i){console.error("[useWorkingDirectory] Error:",i),document.title="AGI"}})()},[]),e}const s$=new b1({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1,structuralSharing:!0}}});function u$(){const[e,n]=te.useState(),a=Yz(),{theme:i,toggleTheme:l}=o$();l$();const u=te.useCallback(async()=>{try{const c=await a.mutateAsync({agent:"general"});n(c.id)}catch(c){console.error("Failed to create session:",c)}},[a]);return y.jsx(Vz,{onNewSession:u,theme:i,onToggleTheme:l,sidebar:y.jsx(Wz,{activeSessionId:e,onSelectSession:n}),children:e?y.jsxs(y.Fragment,{children:[y.jsx(J3,{sessionId:e}),y.jsx(a$,{sessionId:e})]}):y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:"Select a session or create a new one to start"})})}function c$(){return y.jsx(y1,{client:s$,children:y.jsx(u$,{})})}const RC=document.getElementById("root");if(!RC)throw new Error("Root element not found");KO.createRoot(RC).render(y.jsx(te.StrictMode,{children:y.jsx(c$,{})}));
317
+ `).length,d=Lt(n);return y.jsxs("div",{className:"text-xs",children:[y.jsxs("button",{type:"button",onClick:i,className:"flex items-center gap-2 text-cyan-700 dark:text-cyan-300 transition-colors hover:text-cyan-600 dark:hover:text-cyan-200",children:[a?y.jsx(Ur,{className:"h-3 w-3"}):y.jsx(_n,{className:"h-3 w-3"}),y.jsx("span",{className:"font-medium",children:"tree"}),y.jsx("span",{className:"text-muted-foreground/70",children:"·"}),y.jsxs("span",{className:"text-foreground/70",children:[c," ",c===1?"line":"lines"]}),y.jsxs("span",{className:"text-muted-foreground/80",children:["· ",d]})]}),a&&u&&y.jsx("div",{className:"mt-2 ml-5 bg-card/60 border border-border rounded-lg overflow-hidden max-h-96 overflow-y-auto max-w-full",children:y.jsx("div",{className:"overflow-x-auto max-w-full",children:y.jsx(Rn,{language:"bash",style:Un,customStyle:{margin:0,padding:"0.75rem",fontSize:"0.75rem",lineHeight:"1.5",background:"transparent",maxWidth:"100%"},wrapLines:!0,wrapLongLines:!0,children:u})})})]})}function D3({contentJson:e,toolDurationMs:n,isExpanded:a,onToggle:i}){const u=(e.result||{}).matches||[],c=Lt(n);return y.jsxs("div",{className:"text-xs",children:[y.jsxs("button",{type:"button",onClick:i,className:"flex items-center gap-2 text-amber-700 dark:text-amber-300 transition-colors hover:text-amber-600 dark:hover:text-amber-200",children:[a?y.jsx(Ur,{className:"h-3 w-3"}):y.jsx(_n,{className:"h-3 w-3"}),y.jsx("span",{className:"font-medium",children:"search"}),y.jsx("span",{className:"text-muted-foreground/70",children:"·"}),y.jsxs("span",{className:"text-foreground/70",children:[u.length," ",u.length===1?"match":"matches"]}),y.jsxs("span",{className:"text-muted-foreground/80",children:["· ",c]})]}),a&&y.jsx("div",{className:"mt-2 ml-5 space-y-1 max-h-96 overflow-y-auto",children:u.map((d,f)=>{const g=d;return y.jsxs("div",{className:"text-xs font-mono bg-card/60 border border-border rounded px-2 py-1",children:[y.jsxs("div",{className:"text-blue-600 dark:text-blue-400 truncate",children:[g.file,":",g.line]}),y.jsx("div",{className:"text-foreground/80 truncate",children:g.text})]},`${g.file}-${g.line}-${f}`)})})]})}function M3({toolDurationMs:e}){const n=Lt(e);return y.jsx("div",{className:"text-xs",children:y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"font-medium text-emerald-700 dark:text-emerald-300",children:"Done"}),n&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-muted-foreground/70",children:"·"}),y.jsx("span",{className:"text-muted-foreground/80",children:n})]})]})})}function U3({toolName:e,contentJson:n,toolDurationMs:a}){const i=n.result,l=Lt(a);return y.jsxs("div",{className:"text-xs space-y-2",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"font-medium text-foreground",children:e}),y.jsx("span",{className:"text-muted-foreground/70",children:"·"}),y.jsx("span",{className:"text-muted-foreground/80",children:l})]}),i&&y.jsx("div",{className:"bg-card/60 border border-border rounded-lg overflow-hidden max-h-96 overflow-y-auto max-w-full",children:y.jsx("div",{className:"overflow-x-auto max-w-full",children:y.jsx(Rn,{language:"json",style:Un,customStyle:{margin:0,padding:"0.75rem",fontSize:"0.75rem",lineHeight:"1.5",background:"transparent",maxWidth:"100%"},wrapLines:!0,wrapLongLines:!0,children:JSON.stringify(i,null,2)})})})]})}function F3({contentJson:e,toolDurationMs:n}){return y.jsx("div",{className:"text-xs",children:y.jsxs("div",{className:"text-muted-foreground",children:[y.jsxs("div",{children:["Tool: ",e.name]}),y.jsxs("div",{children:["Duration: ",n,"ms"]}),y.jsx("pre",{className:"mt-2 text-[10px] bg-card border border-border p-2 rounded overflow-x-auto",children:JSON.stringify(e,null,2)})]})})}function B3({contentJson:e}){const n=e.result||{},a=n.items||[],i=n.note;return y.jsx("div",{className:"text-xs",children:y.jsxs("div",{className:"bg-blue-500/10 border border-blue-500/30 dark:bg-blue-500/5 dark:border-blue-500/20 rounded-lg p-3 space-y-2",children:[i&&y.jsx("div",{className:"text-blue-700 dark:text-blue-300 text-sm font-medium mb-3",children:i}),y.jsx("div",{className:"space-y-1.5",children:a.map((l,u)=>y.jsxs("div",{className:"flex items-start gap-2",children:[l.status==="completed"&&y.jsx(V1,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300 flex-shrink-0 mt-0.5"}),l.status==="in_progress"&&y.jsx(B1,{className:"h-4 w-4 text-blue-700 dark:text-blue-300 flex-shrink-0 mt-0.5 animate-pulse"}),l.status==="pending"&&y.jsx(X1,{className:"h-4 w-4 text-muted-foreground flex-shrink-0 mt-0.5"}),y.jsx("span",{className:`text-sm ${l.status==="completed"?"text-muted-foreground line-through":l.status==="in_progress"?"text-foreground":"text-muted-foreground/80"}`,children:l.step})]},`${l.step}-${u}`))})]})})}function z3({contentJson:e}){const n=e.result||{},a=String(n.message||"Processing..."),i=n.stage?String(n.stage):void 0,l=n.pct?Number(n.pct):void 0;return y.jsxs("div",{className:"flex items-center gap-2 text-sm text-violet-700 dark:text-violet-300 animate-pulse",children:[i&&y.jsxs("span",{className:"text-muted-foreground/80",children:["[",i,"]"]}),y.jsx("span",{children:a}),l!==void 0&&y.jsxs("span",{className:"text-muted-foreground/80",children:["(",l,"%)"]})]})}function j3({contentJson:e,toolDurationMs:n,isExpanded:a,onToggle:i}){const l=e.result||{},[u,c]=te.useState(new Set),d=S=>{c(_=>{const x=new Set(_);return x.has(S)?x.delete(S):x.add(S),x})},f="results"in l,g=l.results||[],b=l;if(f){const S=Lt(n);return y.jsxs("div",{className:"text-xs",children:[y.jsxs("button",{type:"button",onClick:i,className:"flex items-center gap-2 text-purple-700 dark:text-purple-300 transition-colors hover:text-purple-600 dark:hover:text-purple-200",children:[a?y.jsx(Ur,{className:"h-3 w-3"}):y.jsx(_n,{className:"h-3 w-3"}),y.jsx("span",{className:"font-medium",children:"web search"}),y.jsx("span",{className:"text-muted-foreground/70",children:"·"}),y.jsxs("span",{className:"text-foreground/70",children:[g.length," ",g.length===1?"result":"results"]}),y.jsxs("span",{className:"text-muted-foreground/80",children:["· ",S]})]}),a&&y.jsx("div",{className:"mt-2 ml-5 space-y-2 max-h-96 overflow-y-auto",children:g.map((_,x)=>y.jsxs("div",{className:"bg-card/60 border border-border rounded-lg p-3 space-y-1",children:[y.jsxs("a",{href:_.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-blue-600 dark:text-blue-400 hover:underline font-medium",children:[_.title,y.jsx(a0,{className:"h-3 w-3"})]}),y.jsx("p",{className:"text-muted-foreground text-xs",children:_.snippet}),y.jsx("p",{className:"text-xs text-muted-foreground/70 truncate",children:_.url})]},`${_.url}-${x}`))})]})}const h=Lt(n),E=b.url&&b.url.length>60?`${b.url.slice(0,60)}...`:b.url;return y.jsxs("div",{className:"text-xs",children:[y.jsxs("button",{type:"button",onClick:()=>d(0),className:"flex items-center gap-2 text-purple-700 dark:text-purple-300 transition-colors hover:text-purple-600 dark:hover:text-purple-200 w-full text-left",children:[u.has(0)?y.jsx(Ur,{className:"h-3 w-3 flex-shrink-0"}):y.jsx(_n,{className:"h-3 w-3 flex-shrink-0"}),y.jsx("span",{className:"font-medium flex-shrink-0",children:"web fetch"}),y.jsx("span",{className:"text-muted-foreground/70 flex-shrink-0",children:"·"}),y.jsx("a",{href:b.url,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:underline truncate flex-1 min-w-0",onClick:S=>S.stopPropagation(),children:E}),y.jsxs("span",{className:"text-muted-foreground/80 flex-shrink-0",children:["· ",h]})]}),u.has(0)&&b.content&&y.jsx("div",{className:"mt-2 ml-5 bg-card/60 border border-border rounded-lg p-3 max-h-96 overflow-y-auto",children:y.jsx("div",{className:"text-xs text-foreground/80 whitespace-pre-wrap break-words",children:b.content})})]})}function q3({contentJson:e,debug:n}){const[a,i]=te.useState(!1);let l,u,c,d=!1;e.error&&typeof e.error=="object"?(l=e.error,l.message&&typeof l.message=="string"&&(u=l.message),l.type&&typeof l.type=="string"&&(c=l.type)):e.details&&typeof e.details=="object"?(l=e.details,e.message&&typeof e.message=="string"&&(u=e.message),e.type&&typeof e.type=="string"&&(c=e.type),e.isAborted===!0&&(d=!0)):(e.message&&typeof e.message=="string"&&(u=e.message),e.type&&typeof e.type=="string"&&(c=e.type),e.isAborted===!0&&(d=!0),l=e);let f;if(l?.responseBody&&typeof l.responseBody=="string")try{const E=JSON.parse(l.responseBody);E.error&&typeof E.error=="object"&&(f={type:typeof E.error.type=="string"?E.error.type:void 0,message:typeof E.error.message=="string"?E.error.message:void 0})}catch{}const g=E=>{if(E==null)return y.jsx("span",{className:"text-muted-foreground",children:"null"});if(typeof E=="boolean")return y.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:String(E)});if(typeof E=="number")return y.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:E});if(typeof E=="string"){if(E.startsWith("{")||E.startsWith("["))try{const S=JSON.parse(E);return y.jsx("pre",{className:"mt-1 p-2 bg-muted/50 rounded text-xs overflow-x-auto",children:y.jsx("code",{children:JSON.stringify(S,null,2)})})}catch{}return y.jsx("span",{className:"text-foreground",children:E})}return typeof E=="object"?y.jsx("pre",{className:"mt-1 p-2 bg-muted/50 rounded text-xs overflow-x-auto",children:y.jsx("code",{children:JSON.stringify(E,null,2)})}):y.jsx("span",{className:"text-foreground",children:String(E)})},b=["name","statusCode","url","model","isRetryable","cause"],h=new Set;return y.jsxs("div",{className:"space-y-2 text-sm",children:[d&&y.jsx("div",{className:"text-amber-600 dark:text-amber-400 font-medium",children:"Request aborted"}),f?.message&&y.jsxs("div",{className:"space-y-1",children:[y.jsx("div",{className:"font-medium text-red-600 dark:text-red-400",children:"API Error:"}),y.jsx("div",{className:"text-foreground",children:f.message}),f.type&&y.jsxs("div",{className:"text-xs text-muted-foreground",children:["Type: ",f.type]})]}),!f?.message&&u&&y.jsxs("div",{className:"space-y-1",children:[y.jsx("div",{className:"font-medium text-red-600 dark:text-red-400",children:"Error:"}),y.jsx("div",{className:"text-foreground",children:u}),c&&y.jsxs("div",{className:"text-xs text-muted-foreground",children:["Type: ",c]})]}),l&&y.jsx("div",{className:"space-y-1.5",children:b.map(E=>{const S=l[E];return S==null?null:(h.add(E),y.jsxs("div",{className:"flex gap-2",children:[y.jsxs("span",{className:"font-medium text-muted-foreground min-w-[100px]",children:[E,":"]}),g(S)]},E))})}),l&&y.jsxs("div",{className:"mt-3 border-t border-border pt-2",children:[y.jsxs("button",{type:"button",onClick:()=>i(!a),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[a?y.jsx(Ur,{className:"h-3 w-3"}):y.jsx(_n,{className:"h-3 w-3"}),a?"Hide":"View"," Raw Error Details"]}),a&&y.jsx("div",{className:"mt-2",children:y.jsx("pre",{className:"p-3 bg-muted/50 rounded text-xs overflow-x-auto max-h-96 overflow-y-auto",children:y.jsx("code",{children:JSON.stringify(l,null,2)})})})]}),n&&y.jsxs("details",{className:"mt-4 text-xs",children:[y.jsx("summary",{className:"cursor-pointer text-muted-foreground",children:"Debug Info"}),y.jsx("pre",{className:"mt-2 p-2 bg-muted/30 rounded overflow-x-auto",children:y.jsx("code",{children:JSON.stringify({contentJson:e,errorDetails:l,apiError:f},null,2)})})]})]})}function ww({toolName:e,contentJson:n,toolDurationMs:a,debug:i}){const[l,u]=te.useState(!1),c={contentJson:n,toolDurationMs:a??void 0,isExpanded:l,onToggle:()=>u(!l)};if(i)return y.jsx(F3,{...c,toolName:e});switch(e){case"read":return y.jsx(x3,{...c});case"write":return y.jsx(_3,{...c});case"edit":return y.jsx(R3,{...c});case"bash":return y.jsx(N3,{...c});case"git_status":return y.jsx(w3,{...c});case"git_diff":return y.jsx(k3,{...c});case"git_commit":return y.jsx(C3,{...c});case"apply_patch":return y.jsx(I3,{...c});case"ls":return y.jsx(O3,{...c});case"tree":return y.jsx(L3,{...c});case"ripgrep":case"grep":case"glob":return y.jsx(D3,{...c});case"websearch":return y.jsx(j3,{...c});case"finish":return y.jsx(M3,{...c});case"update_plan":return y.jsx(B3,{...c});case"progress_update":return y.jsx(z3,{...c});case"error":return y.jsx(q3,{...c});default:return y.jsx(U3,{...c,toolName:e})}}function Vh(e){const n=e.contentJson;if(n&&typeof n=="object")return n;try{if(e.content){const a=JSON.parse(e.content);if(a&&typeof a=="object"&&!Array.isArray(a))return a}}catch{}return null}function P3(e){const n=Vh(e);if(!n)return;const a=n.args;if(a&&typeof a=="object"&&!Array.isArray(a))return a}function G3(e){if(!e)return null;const n=["cmd","command","script","input"];for(const a of n){const i=e[a];if(typeof i=="string"&&i.trim().length>0)return i.trim()}return null}function H3(e,n){if(!n)return null;const a=[{key:"path",match:!0},{key:"file",match:!0},{key:"target",match:!0},{key:"cwd",match:!0},{key:"query",match:!0},{key:"pattern",match:!0},{key:"glob",match:!0},{key:"dir",match:!0}];for(const{key:i}of a){const l=n[i];if(typeof l=="string"&&l.trim().length>0)return{key:i,value:l.trim()}}if(e==="bash"){const i=n.command;if(typeof i=="string"&&i.trim().length>0)return{key:"command",value:i.trim()}}return null}function $3(e,n){if(!e)return null;const a=[];for(const[l,u]of Object.entries(e))if(!(n&&l===n)){if(typeof u=="string"||typeof u=="number"){const c=`${l}=${String(u)}`;a.push(c)}if(a.length>=3)break}if(!a.length)return null;const i=a.join(" ");return i.length>120?`${i.slice(0,117)}…`:i}const kw=te.memo(function({part:n,showLine:a,isLastToolCall:i,isLastProgressUpdate:l}){if(n.type==="tool_call"&&!i||n.type==="tool_result"&&n.toolName==="progress_update"&&!l)return null;if(n.type==="text"){const h=n.contentJson||n.content;let E="";if(h&&typeof h=="object"&&"text"in h?E=String(h.text):typeof h=="string"&&(E=h),!E||!E.trim())return null}const u=n.type==="tool_call"||n.type==="tool_result",c=["flex-1","min-w-0","max-w-full"];u?c.push("pt-0.5","mt-[1px]"):c.push("pt-0"),n.type==="text"&&c.push("-mt-0.5");const d=c.join(" "),f=()=>{if(n.type==="tool_call")return y.jsx(Kw,{className:"h-4 w-4 text-amber-600 dark:text-amber-300 animate-spin"});if(n.type==="error")return Vh(n)?.isAborted===!0?y.jsx(w0,{className:"h-4 w-4 text-amber-600 dark:text-amber-400"}):y.jsx($w,{className:"h-4 w-4 text-red-600 dark:text-red-400"});if(n.type==="tool_result"){const h=n.toolName||"";return h==="read"?y.jsx(u0,{className:"h-4 w-4 text-blue-600 dark:text-blue-300"}):h==="write"?y.jsx(Vv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300"}):h==="edit"?y.jsx(Vv,{className:"h-4 w-4 text-purple-600 dark:text-purple-300"}):h==="ls"?y.jsx(v0,{className:"h-4 w-4 text-cyan-600 dark:text-cyan-300"}):h==="tree"?y.jsx(g0,{className:"h-4 w-4 text-cyan-600 dark:text-cyan-300"}):h==="bash"?y.jsx(Kv,{className:"h-4 w-4 text-muted-foreground"}):h==="ripgrep"||h==="grep"||h==="glob"?y.jsx(L0,{className:"h-4 w-4 text-amber-600 dark:text-amber-300"}):h==="apply_patch"?y.jsx($v,{className:"h-4 w-4 text-purple-600 dark:text-purple-300"}):h==="git_status"?y.jsx(Pl,{className:"h-4 w-4 text-blue-600 dark:text-blue-300"}):h==="git_diff"?y.jsx($v,{className:"h-4 w-4 text-purple-600 dark:text-purple-300"}):h==="git_commit"?y.jsx(Gl,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300"}):h==="finish"?y.jsx(Hw,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300"}):y.jsx(Kv,{className:"h-4 w-4 text-muted-foreground"})}return y.jsx(Hl,{className:"h-4 w-4 text-violet-600 dark:text-violet-300"})},g=()=>{const h=n.toolName||"";let E;try{n.contentJson&&typeof n.contentJson=="object"?E=n.contentJson:typeof n.content=="string"?E=JSON.parse(n.content):E={}}catch{E={result:n.content}}return y.jsx(ww,{toolName:h,contentJson:E,toolDurationMs:n.toolDurationMs,debug:!1})},b=()=>{if(n.type==="text"){let h="";const E=n.contentJson||n.content;return E&&typeof E=="object"&&"text"in E?h=String(E.text):typeof E=="string"?h=E:E&&(h=JSON.stringify(E,null,2)),y.jsx("div",{className:"text-base text-foreground leading-relaxed markdown-content max-w-full overflow-hidden",children:y.jsx(Jk,{remarkPlugins:[xC],children:h})})}if(n.type==="error"){let h;try{n.contentJson&&typeof n.contentJson=="object"?h=n.contentJson:typeof n.content=="string"?h=JSON.parse(n.content):h={}}catch{h={message:n.content||"Unknown error"}}return y.jsx(ww,{toolName:"error",contentJson:h,toolDurationMs:n.toolDurationMs,debug:!1})}if(n.type==="tool_call"){const h=Vh(n),E=n.toolName||(typeof h?.name=="string"?h.name:"tool"),S=E.replace(/_/g," "),_=P3(n),x=H3(E,_),C=$3(_,x?.key),T=E==="bash"?G3(_):null,A=[];T?A.push({key:"cmd",node:y.jsx("code",{className:"font-mono text-foreground/90 truncate max-w-xs",children:T})}):x&&A.push({key:"primary",node:y.jsx("code",{className:"font-mono text-foreground/85 truncate max-w-xs",children:x.value})}),C&&A.push({key:"args",node:y.jsx("span",{className:"text-muted-foreground/80 truncate max-w-xs",children:C})}),A.length===0&&A.push({key:"running",node:y.jsx("span",{className:"text-muted-foreground/75",children:"running…"})});const N=["flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-foreground/80 max-w-full"];return n.ephemeral&&N.push("animate-pulse"),y.jsxs("div",{className:N.join(" "),children:[y.jsx("span",{className:"font-medium text-foreground",children:S}),A.map(L=>y.jsxs(te.Fragment,{children:[y.jsx("span",{className:"text-muted-foreground/65",children:"·"}),L.node]},L.key))]})}return n.type==="tool_result"?g():null};return y.jsxs("div",{className:"flex gap-3 pb-2 relative max-w-full overflow-hidden",children:[y.jsxs("div",{className:"flex-shrink-0 w-6 flex items-start justify-center relative pt-0.5",children:[y.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full relative z-10 bg-background",children:f()}),a&&y.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 w-[2px] bg-border z-0",style:{top:"1.25rem",bottom:"-0.5rem"}})]}),y.jsx("div",{className:d,children:b()})]})},(e,n)=>e.part.id===n.part.id&&e.part.content===n.part.content&&e.part.contentJson===n.part.contentJson&&e.part.ephemeral===n.part.ephemeral&&e.part.completedAt===n.part.completedAt&&e.showLine===n.showLine&&e.isLastToolCall===n.isLastToolCall&&e.isLastProgressUpdate===n.isLastProgressUpdate),Cw=["Generating...","Cooking up something...","Thinking...","Processing...","Working on it...","Crafting response...","Brewing magic...","Computing..."];function V3(e){const n=e.split("").reduce((a,i)=>a+i.charCodeAt(0),0);return Cw[n%Cw.length]}const Y3=te.memo(function({message:n,showHeader:a,hasNextAssistantMessage:i}){const l=n.parts||[],u=l.some(S=>S.toolName==="finish"),c=l.reduce((S,_,x)=>_.type==="tool_result"&&_.toolName==="progress_update"?x:S,-1),d=c>=0?l[c]:null,f=l.some(S=>!(S.type==="tool_result"&&S.toolName==="progress_update")),g=l.findIndex(S=>!(S.type==="tool_result"&&S.toolName==="progress_update")),b=n.status==="pending"&&!u&&!!d,h=n.status==="pending"&&!u&&!d,E=S=>S?new Date(S).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"";return y.jsxs("div",{className:"relative",children:[a&&y.jsx("div",{className:"pb-2",children:y.jsxs("div",{className:"inline-flex items-center bg-violet-500/10 border border-violet-500/30 dark:bg-violet-500/5 dark:border-violet-500/20 rounded-full pr-4",children:[y.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-violet-500/50 bg-violet-500/20 dark:bg-violet-500/10",children:y.jsx(Hl,{className:"h-3.5 w-3.5 text-violet-700 dark:text-violet-300"})}),y.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground pl-3",children:[n.agent&&y.jsx("span",{className:"font-medium text-violet-700 dark:text-violet-300",children:n.agent}),n.agent&&n.provider&&y.jsx("span",{children:"·"}),n.provider&&y.jsx("span",{className:"text-muted-foreground",children:n.provider}),n.model&&y.jsx("span",{children:"·"}),n.model&&y.jsx("span",{className:"text-muted-foreground",children:n.model}),n.createdAt&&y.jsx("span",{children:"·"}),n.createdAt&&y.jsx("span",{className:"text-muted-foreground",children:E(n.createdAt)})]})]})}),y.jsxs("div",{className:"relative ml-1",children:[l.map((S,_)=>{const x=_===l.length-1,C=!x||i,T=S.type==="tool_call"&&x;return S.type==="tool_result"&&S.toolName==="progress_update"?null:y.jsx(kw,{part:S,showLine:C,isFirstPart:_===g&&!a,isLastToolCall:T},S.id)}),b&&d&&y.jsx(kw,{part:d,showLine:i,isFirstPart:!f&&!a,isLastProgressUpdate:!0},d.id),h&&y.jsxs("div",{className:"flex gap-3 pb-2 relative",children:[y.jsx("div",{className:"flex-shrink-0 w-6 flex items-start justify-center relative pt-0.5",children:y.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full relative z-10 bg-card text-violet-700 dark:bg-background dark:text-violet-300",children:y.jsx(Hl,{className:"h-4 w-4"})})}),y.jsx("div",{className:"flex-1 pt-0.5",children:y.jsx("div",{className:"text-base text-foreground animate-pulse",children:V3(n.id)})})]})]})]})},(e,n)=>{const a=e.message.parts||[],i=n.message.parts||[];if(a.length!==i.length)return!1;for(let l=0;l<a.length;l++){const u=a[l],c=i[l];if(u.id!==c.id||u.content!==c.content||u.contentJson!==c.contentJson||u.ephemeral!==c.ephemeral||u.completedAt!==c.completedAt)return!1}return e.message.id===n.message.id&&e.message.status===n.message.status&&e.message.completedAt===n.message.completedAt&&e.showHeader===n.showHeader&&e.hasNextAssistantMessage===n.hasNextAssistantMessage&&e.isLastMessage===n.isLastMessage}),K3=te.memo(function({message:n}){const i=(n.parts||[])[0];if(!i)return null;let l="";const u=i.contentJson||i.content;u&&typeof u=="object"&&"text"in u?l=String(u.text):typeof u=="string"?l=u:u&&(l=JSON.stringify(u,null,2));const c=d=>d?new Date(d).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"";return y.jsx("div",{className:"relative pb-8 pt-6",children:y.jsxs("div",{className:"flex gap-4 justify-end",children:[y.jsxs("div",{className:"flex flex-col items-end max-w-2xl",children:[y.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground pb-2 justify-end",children:[y.jsx("span",{className:"font-medium text-emerald-700 dark:text-emerald-300",children:"You"}),n.createdAt&&y.jsx("span",{children:"·"}),n.createdAt&&y.jsx("span",{children:c(n.createdAt)})]}),y.jsx("div",{className:"text-sm text-foreground leading-relaxed prose prose-invert prose-sm [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 bg-emerald-500/5 border border-emerald-500/20 rounded-xl px-4 py-3 max-w-full break-words overflow-wrap-anywhere",children:y.jsx(Jk,{remarkPlugins:[xC],children:l})})]}),y.jsx("div",{className:"flex-shrink-0 w-8 flex items-start justify-center",children:y.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full border-2 border-emerald-500/50 bg-emerald-500/20 dark:bg-emerald-500/10 relative z-10 bg-background",children:y.jsx(q0,{className:"h-4 w-4 text-emerald-700 dark:text-emerald-300"})})})]})})},(e,n)=>{const a=e.message.parts?.[0],i=n.message.parts?.[0];return e.message.id===n.message.id&&a?.content===i?.content&&a?.contentJson===i?.contentJson&&e.message.createdAt===n.message.createdAt});function W3({session:e}){const n=te.useMemo(()=>{const u=e.totalInputTokens||0,c=e.totalOutputTokens||0;return u+c},[e.totalInputTokens,e.totalOutputTokens]),a=te.useMemo(()=>{const u=e.totalInputTokens||0,c=e.totalOutputTokens||0,d=30,f=60,g=u/1e6*d,b=c/1e6*f;return g+b},[e.totalInputTokens,e.totalOutputTokens]),i=u=>{if(!u)return"0s";const c=Math.floor(u/1e3),d=Math.floor(c/60),f=Math.floor(d/60);if(f>0){const g=d%60;return`${f}h ${g}m`}if(d>0){const g=c%60;return`${d}m ${g}s`}return`${c}s`},l=u=>u.toLocaleString("en-US");return y.jsx("div",{className:"border-b border-border bg-background/95 backdrop-blur-sm",children:y.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-6",children:[y.jsx("h1",{className:"text-2xl font-semibold text-foreground mb-4",children:e.title||"Untitled Session"}),y.jsxs("div",{className:"flex flex-wrap gap-6 text-sm",children:[y.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[y.jsx(Yw,{className:"w-4 h-4"}),y.jsxs("div",{className:"flex flex-col",children:[y.jsx("span",{className:"text-xs uppercase tracking-wide opacity-70",children:"Total Tokens"}),y.jsx("span",{className:"text-foreground font-medium",children:l(n)}),(e.totalInputTokens||e.totalOutputTokens)&&y.jsxs("span",{className:"text-xs opacity-60",children:[l(e.totalInputTokens||0)," in /"," ",l(e.totalOutputTokens||0)," out"]})]})]}),y.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[y.jsx(Q1,{className:"w-4 h-4"}),y.jsxs("div",{className:"flex flex-col",children:[y.jsx("span",{className:"text-xs uppercase tracking-wide opacity-70",children:"Tool Time"}),y.jsx("span",{className:"text-foreground font-medium",children:i(e.totalToolTimeMs)})]})]}),a>0&&y.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[y.jsx(Vw,{className:"w-4 h-4"}),y.jsxs("div",{className:"flex flex-col",children:[y.jsx("span",{className:"text-xs uppercase tracking-wide opacity-70",children:"Est. Cost"}),y.jsxs("span",{className:"text-foreground font-medium",children:["$",a.toFixed(4)]})]})]}),y.jsx("div",{className:"flex items-center gap-2 text-muted-foreground ml-auto",children:y.jsxs("div",{className:"flex flex-col items-end",children:[y.jsx("span",{className:"text-xs uppercase tracking-wide opacity-70",children:"Model"}),y.jsx("span",{className:"text-foreground font-medium",children:e.model}),y.jsxs("span",{className:"text-xs opacity-60",children:[e.provider," · ",e.agent]})]})})]})]})})}function X3({sessionId:e,onStop:n,disabled:a}){const[i,l]=te.useState(!1),u=async()=>{if(!i){l(!0);try{await Ht.abortSession(e),n?.()}catch(c){console.error("Failed to abort stream:",c)}finally{setTimeout(()=>l(!1),1e3)}}};return y.jsxs("button",{type:"button",onClick:u,disabled:a||i,className:"flex items-center gap-1.5 text-sm text-destructive hover:text-destructive/80 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",title:"Stop generation",children:[y.jsx(K1,{className:"w-4 h-4"}),y.jsx("span",{className:"font-medium",children:i?"Stopping...":"Stop"})]})}function Z3({session:e,isVisible:n,isGenerating:a}){const i=te.useMemo(()=>{const c=e.totalInputTokens||0,d=e.totalOutputTokens||0;return c+d},[e.totalInputTokens,e.totalOutputTokens]),l=te.useMemo(()=>{const c=e.totalInputTokens||0,d=e.totalOutputTokens||0,f=30,g=60,b=c/1e6*f,h=d/1e6*g;return b+h},[e.totalInputTokens,e.totalOutputTokens]),u=c=>c.toLocaleString("en-US");return y.jsx("div",{className:`absolute top-0 left-0 right-0 h-14 border-b border-border bg-background/95 backdrop-blur-sm z-30 transition-transform duration-200 ${n?"translate-y-0":"-translate-y-full"}`,children:y.jsxs("div",{className:"h-full px-6 flex items-center justify-between gap-6 text-sm",children:[y.jsx("div",{className:"flex-shrink-0",children:a&&y.jsx(X3,{sessionId:e.id})}),y.jsxs("div",{className:"flex items-center gap-6",children:[y.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[y.jsx(Yw,{className:"w-4 h-4"}),y.jsx("span",{className:"text-foreground font-medium",children:u(i)})]}),l>0&&y.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[y.jsx(Vw,{className:"w-4 h-4"}),y.jsxs("span",{className:"text-foreground font-medium",children:["$",l.toFixed(4)]})]})]})]})})}const Q3=te.memo(function({messages:n,session:a,isGenerating:i}){const l=te.useRef(null),u=te.useRef(null),c=te.useRef(null),[d,f]=te.useState(!0),[g,b]=te.useState(!1),h=te.useRef(0),E=te.useRef(0),S=()=>{const C=u.current;if(!C)return;const{scrollTop:T,scrollHeight:A,clientHeight:N}=C,L=A-T-N;f(L<100);const U=c.current;if(U){const w=U.getBoundingClientRect(),M=C.getBoundingClientRect();b(w.bottom<M.top)}};te.useEffect(()=>{n.length>E.current&&f(!0),E.current=n.length},[n.length]),te.useEffect(()=>{const C=u.current;!C||!d||requestAnimationFrame(()=>{if(!l.current||!C)return;const{scrollHeight:T}=C,N=T!==h.current?"smooth":"instant";l.current.scrollIntoView({behavior:N}),h.current=T})},[n,d]);const _=()=>{f(!0),l.current?.scrollIntoView({behavior:"smooth"})},x=te.useMemo(()=>n.filter(C=>C.role!=="system"),[n]);return n.length===0?y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:"No messages yet. Start a conversation below."}):y.jsxs("div",{className:"absolute inset-0 flex flex-col",children:[a&&y.jsx(Z3,{session:a,isVisible:g,isGenerating:i}),y.jsxs("div",{ref:u,className:"flex-1 overflow-y-auto",onScroll:S,children:[y.jsx("div",{ref:c,children:a&&y.jsx(W3,{session:a})}),y.jsx("div",{className:"p-6 pb-32",children:y.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[x.map((C,T)=>{const A=x[T-1],N=x[T+1],L=T===x.length-1;if(C.role==="user")return y.jsx(K3,{message:C,isFirst:T===0},C.id);if(C.role==="assistant"){const U=!A||A.role!=="assistant",w=N&&N.role==="assistant";return y.jsx(Y3,{message:C,showHeader:U,hasNextAssistantMessage:w,isLastMessage:L},C.id)}return null}),y.jsx("div",{ref:l})]})})]}),!d&&y.jsxs("button",{type:"button",onClick:_,className:"absolute bottom-36 left-1/2 -translate-x-1/2 flex items-center gap-2 px-4 py-2 bg-background border border-border rounded-full shadow-lg hover:bg-muted/50 transition-all text-sm text-foreground z-10",children:[y.jsx(U1,{className:"w-4 h-4"}),y.jsx("span",{children:"Scroll to bottom"})]})]})}),J3=te.memo(function({sessionId:n}){const{data:a=[],isLoading:i}=Xz(n),{data:l=[]}=bk();Jz(n);const u=te.useMemo(()=>l.find(d=>d.id===n),[l,n]),c=te.useMemo(()=>a.some(d=>d.role==="assistant"&&d.status==="pending"),[a]);return i?y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:"Loading messages..."}):y.jsx(Q3,{messages:a,session:u,isGenerating:c})}),e$=te.memo(function({onSend:n,disabled:a,onConfigClick:i}){const[l,u]=te.useState(""),c=te.useRef(null);te.useEffect(()=>{c.current?.focus()},[]);const d=te.useCallback(()=>{const h=c.current;h&&(h.style.height="auto",h.style.height=`${h.scrollHeight}px`)},[]);te.useEffect(()=>{d()},[d,l]);const f=te.useCallback(()=>{l.trim()&&!a&&(n(l),u(""),c.current&&(c.current.style.height="auto"),c.current?.focus())},[l,a,n]),g=te.useCallback(h=>{u(h.target.value)},[]),b=te.useCallback(h=>{h.key==="Enter"&&!h.shiftKey&&(h.preventDefault(),f())},[f]);return y.jsx("div",{className:"absolute bottom-0 left-0 right-0 pt-16 pb-8 px-4 bg-gradient-to-t from-background via-background to-transparent pointer-events-none z-20",children:y.jsx("div",{className:"max-w-3xl mx-auto pointer-events-auto",children:y.jsxs("div",{className:"flex items-end gap-1 bg-card rounded-3xl border border-border p-1 focus-within:border-primary/60 focus-within:ring-1 focus-within:ring-primary/40 transition-colors",children:[i&&y.jsx("button",{type:"button",onClick:i,className:"flex items-center justify-center w-10 h-10 rounded-full hover:bg-background/50 transition-colors text-muted-foreground hover:text-foreground flex-shrink-0",children:y.jsx(n0,{className:"w-4 h-4"})}),y.jsx(ub,{ref:c,value:l,onChange:g,onKeyDown:b,placeholder:"Type a message...",disabled:a,rows:1,className:"border-0 bg-transparent pl-1 pr-2 py-2 max-h-[200px] overflow-y-auto leading-normal resize-none scrollbar-hide",style:{height:"2.5rem"}}),y.jsx("button",{type:"button",onClick:f,disabled:a||!l.trim(),className:`flex items-center justify-center w-10 h-10 rounded-full transition-colors flex-shrink-0 ${l.trim()?"bg-primary hover:bg-primary/90 text-primary-foreground":"bg-transparent text-muted-foreground"}`,children:y.jsx(j1,{className:"w-4 h-4"})})]})})})});function t$(){return ai({queryKey:["config"],queryFn:()=>Ht.getConfig()})}function n$(e){return ai({queryKey:["models",e],queryFn:()=>e?Ht.getModels(e):null,enabled:!!e})}function r$({isOpen:e,onClose:n,agent:a,provider:i,model:l,onAgentChange:u,onProviderChange:c,onModelChange:d}){const{data:f,isLoading:g}=t$(),{data:b,isLoading:h}=n$(i),E=te.useId(),S=te.useId(),_=te.useId();if(te.useEffect(()=>{f&&!a&&!i&&!l&&(u(f.defaults.agent),c(f.defaults.provider),d(f.defaults.model))},[f,a,i,l,u,c,d]),te.useEffect(()=>{b&&b.models.length>0&&(b.models.some(A=>A.id===l)||d(b.default||b.models[0].id))},[b,l,d]),!e)return null;const x=T=>{T.target===T.currentTarget&&n()},C=T=>{T.key==="Escape"&&n()};return y.jsxs(y.Fragment,{children:[y.jsx("button",{type:"button",className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50 cursor-default",onClick:x,onKeyDown:C,"aria-label":"Close modal"}),y.jsx("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-50 w-full max-w-md",children:y.jsxs("div",{className:"bg-background border border-border rounded-lg shadow-lg",children:[y.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[y.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Configuration"}),y.jsx("button",{type:"button",onClick:n,className:"text-muted-foreground hover:text-foreground transition-colors",children:y.jsx(Qh,{className:"h-5 w-5"})})]}),y.jsx("div",{className:"p-4 space-y-4",children:g?y.jsx("div",{className:"text-center text-muted-foreground py-8",children:"Loading configuration..."}):f?y.jsxs(y.Fragment,{children:[y.jsxs("div",{children:[y.jsx("label",{htmlFor:E,className:"block text-sm font-medium text-foreground mb-2",children:"Agent"}),y.jsx("select",{id:E,value:a,onChange:T=>u(T.target.value),className:"w-full bg-background border border-border rounded px-3 py-2 text-foreground outline-none focus:border-violet-500 transition-colors",children:f.agents.map(T=>y.jsx("option",{value:T,children:T},T))})]}),y.jsxs("div",{children:[y.jsx("label",{htmlFor:S,className:"block text-sm font-medium text-foreground mb-2",children:"Provider"}),y.jsx("select",{id:S,value:i,onChange:T=>c(T.target.value),className:"w-full bg-background border border-border rounded px-3 py-2 text-foreground outline-none focus:border-violet-500 transition-colors",children:f.providers.map(T=>y.jsx("option",{value:T,children:T},T))})]}),y.jsxs("div",{children:[y.jsx("label",{htmlFor:_,className:"block text-sm font-medium text-foreground mb-2",children:"Model"}),y.jsx("select",{id:_,value:l,onChange:T=>d(T.target.value),disabled:h||!b,className:"w-full bg-background border border-border rounded px-3 py-2 text-foreground outline-none focus:border-violet-500 transition-colors disabled:opacity-50",children:b?.models.map(T=>y.jsx("option",{value:T.id,children:T.label},T.id))})]})]}):null})]})})]})}const a$=te.memo(function({sessionId:n}){const[a,i]=te.useState(""),[l,u]=te.useState(""),[c,d]=te.useState(""),[f,g]=te.useState(!1),[b,h]=te.useState(0),E=Zz(n);te.useEffect(()=>{h(N=>N+1)},[]);const S=te.useCallback(async N=>{try{await E.mutateAsync({content:N,agent:a||void 0,provider:l||void 0,model:c||void 0})}catch(L){console.error("Failed to send message:",L)}},[E,a,l,c]),_=te.useCallback(()=>{g(N=>!N)},[]),x=te.useCallback(()=>{g(!1)},[]),C=te.useCallback(N=>{i(N)},[]),T=te.useCallback(N=>{u(N)},[]),A=te.useCallback(N=>{d(N)},[]);return y.jsxs(y.Fragment,{children:[y.jsx(r$,{isOpen:f,onClose:x,agent:a,provider:l,model:c,onAgentChange:C,onProviderChange:T,onModelChange:A}),y.jsx(e$,{onSend:S,disabled:E.isPending,onConfigClick:_},b)]})}),_C="agi-theme",Iw="dark";function i$(){if(typeof window>"u")return Iw;const e=window.localStorage.getItem(_C);return e==="light"||e==="dark"?e:Iw}function o$(){const[e,n]=te.useState(()=>i$());te.useEffect(()=>{if(typeof document>"u")return;const i=document.documentElement;e==="dark"?i.classList.add("dark"):i.classList.remove("dark");try{window.localStorage.setItem(_C,e)}catch(l){console.warn("Failed to persist theme preference",l)}},[e]);const a=te.useCallback(()=>{n(i=>i==="dark"?"light":"dark")},[]);return te.useMemo(()=>({theme:e,setTheme:n,toggleTheme:a}),[e,a])}function l$(){const[e,n]=te.useState(null);return te.useEffect(()=>{(async()=>{try{const u=`${window.AGI_SERVER_URL||Xw}/v1/config/cwd`;console.log("[useWorkingDirectory] Fetching from:",u);const c=await fetch(u);if(!c.ok)throw console.error("[useWorkingDirectory] Failed:",c.status,c.statusText),new Error(`Failed to fetch working directory: ${c.status}`);const d=await c.json();console.log("[useWorkingDirectory] Success:",d),d.dirName&&(console.log("[useWorkingDirectory] Setting title to:",d.dirName),n(d.dirName),document.title=d.dirName)}catch(i){console.error("[useWorkingDirectory] Error:",i),document.title="AGI"}})()},[]),e}const s$=new b1({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1,structuralSharing:!0}}});function u$(){const[e,n]=te.useState(),a=Yz(),{theme:i,toggleTheme:l}=o$();l$();const u=te.useCallback(async()=>{try{const c=await a.mutateAsync({agent:"general"});n(c.id)}catch(c){console.error("Failed to create session:",c)}},[a]);return y.jsx(Vz,{onNewSession:u,theme:i,onToggleTheme:l,sidebar:y.jsx(Wz,{activeSessionId:e,onSelectSession:n}),children:e?y.jsxs(y.Fragment,{children:[y.jsx(J3,{sessionId:e}),y.jsx(a$,{sessionId:e})]}):y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:"Select a session or create a new one to start"})})}function c$(){return y.jsx(y1,{client:s$,children:y.jsx(u$,{})})}const RC=document.getElementById("root");if(!RC)throw new Error("Root element not found");KO.createRoot(RC).render(y.jsx(te.StrictMode,{children:y.jsx(c$,{})}));
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Loading...</title>
8
- <script type="module" crossorigin src="/assets/index-KPI_9X2q.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-vVR1i8Eb.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-BcbY2mjE.css">
10
10
  </head>
11
11
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agi-cli/web-ui",
3
- "version": "0.1.49",
3
+ "version": "0.1.51",
4
4
  "description": "Embeddable web UI for AGI CLI - pre-built static assets",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",