@principal-ade/panel-layouts 0.3.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";require('./index.css');var De=Object.defineProperty;var Fe=(o,e,t)=>e in o?De(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var se=(o,e,t)=>Fe(o,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ne=require("@principal-ade/panels"),c=require("react"),s=require("react/jsx-runtime"),V=require("@principal-ade/industry-theme");class ve{constructor(){se(this,"storageKey","panel-layouts")}async load(e){try{const t=localStorage.getItem(`${this.storageKey}:${e}`);return t?JSON.parse(t):null}catch(t){return console.error(`Failed to load panel layout for ${e}:`,t),null}}async save(e,t){try{localStorage.setItem(`${this.storageKey}:${e}`,JSON.stringify(t))}catch(r){console.error(`Failed to save panel layout for ${e}:`,r)}}}function qe(o){const{viewKey:e,defaultSizes:t,panelType:r,adapter:a=new ve}=o,[i,l]=c.useState(t),[n,g]=c.useState(o.collapsed),d=c.useRef(o.collapsed),m=c.useRef({}),h=c.useRef(null),y=c.useRef(null);c.useEffect(()=>{(async()=>{const w=await a.load(e);w!=null&&w.sizes&&(l(w.sizes),S(w.sizes))})()},[e]);const S=c.useCallback(k=>{"left"in k&&k.left>0&&(m.current.left=k.left),"middle"in k&&k.middle>0&&(m.current.middle=k.middle),"right"in k&&k.right>0&&(m.current.right=k.right)},[]),f=c.useCallback(k=>{const w=m.current[k];if(w&&w>0)return w;if(k==="left"&&"left"in t&&t.left>0)return t.left;if(k==="right"&&"right"in t&&t.right>0)return t.right},[t]),p=c.useRef(t);c.useEffect(()=>{("left"in t&&t.left!==p.current.left||"middle"in t&&"middle"in p.current&&t.middle!==p.current.middle||"right"in t&&t.right!==p.current.right)&&(l(t),S(t),p.current=t)},[t,S]),c.useEffect(()=>{const k=o.collapsed.left!==d.current.left,w="right"in o.collapsed&&"right"in d.current&&o.collapsed.right!==d.current.right;(k||w)&&(g(o.collapsed),d.current={...o.collapsed})},[o.collapsed.left,o.collapsed.right]);const u=c.useCallback(async k=>{try{await a.save(e,{sizes:k})}catch(w){console.error(`Failed to save panel preferences for ${e}:`,w)}},[e,a]),C=c.useCallback(k=>{const w={...k};let b=!0;if("left"in k){const j=!!(n!=null&&n.left),P=k.left;if(j){const $=f("left");$!==void 0&&$>0?w.left=$:b=!1}else P===0&&(b=!1)}if(r==="three-panel"&&"right"in k){const j=!!(n!=null&&n.right),P=k.right;if(j){const $=f("right");$!==void 0&&$>0?w.right=$:b=!1}else P===0&&(b=!1)}if(l(w),S(w),h.current&&(clearTimeout(h.current),h.current=null),!b){y.current=null;return}y.current=w,h.current=setTimeout(()=>{const j=y.current;j&&(u(j),y.current=null),h.current=null},500)},[n,f,r,u,S]);c.useEffect(()=>()=>{if(h.current){const k=y.current;k&&(u(k),y.current=null),clearTimeout(h.current),h.current=null}},[u]);const I=c.useCallback(async()=>{},[]),A=c.useCallback(async()=>{},[]),v=c.useCallback(async()=>{},[]),E=c.useCallback(async()=>{},[]);return r==="three-panel"?{type:"three-panel",sizes:i,collapsed:n,handlePanelResize:C,handleLeftCollapseComplete:I,handleLeftExpandComplete:A,handleRightCollapseComplete:v,handleRightExpandComplete:E}:{type:"two-panel",sizes:i,collapsed:n,handlePanelResize:C,handleLeftCollapseComplete:I,handleLeftExpandComplete:A}}class Te{constructor(){se(this,"PRESETS_KEY","panel-layouts:workspace-presets");se(this,"REPO_STATE_PREFIX","panel-layouts:repo-state:")}async loadWorkspacePresets(){try{const e=localStorage.getItem(this.PRESETS_KEY);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to load workspace presets:",e),{}}}async saveWorkspacePresets(e){try{localStorage.setItem(this.PRESETS_KEY,JSON.stringify(e))}catch(t){throw console.error("Failed to save workspace presets:",t),t}}async loadRepositoryState(e){try{const t=`${this.REPO_STATE_PREFIX}${e}`,r=localStorage.getItem(t);return r?JSON.parse(r):null}catch(t){return console.error(`Failed to load repository state for ${e}:`,t),null}}async saveRepositoryState(e,t){try{const r=`${this.REPO_STATE_PREFIX}${e}`;localStorage.setItem(r,JSON.stringify(t))}catch(r){throw console.error(`Failed to save repository state for ${e}:`,r),r}}async loadAllRepositoryStates(){try{const e={};for(let t=0;t<localStorage.length;t++){const r=localStorage.key(t);if(r&&r.startsWith(this.REPO_STATE_PREFIX)){const a=r.substring(this.REPO_STATE_PREFIX.length),i=localStorage.getItem(r);if(i)try{e[a]=JSON.parse(i)}catch(l){console.error(`Failed to parse repository state for ${a}:`,l)}}}return e}catch(e){return console.error("Failed to load all repository states:",e),{}}}}class L{static setAdapter(e){this.adapter=e}static async getWorkspaceLayouts(){const e=this.getBuiltInWorkspaceLayouts();return{...await this.adapter.loadWorkspacePresets(),...e}}static async getWorkspaceLayout(e){return(await this.getWorkspaceLayouts())[e]||null}static async createWorkspaceLayout(e){const t=await this.adapter.loadWorkspacePresets(),r=this.generateWorkspaceId(e.name),a={id:r,name:e.name,description:e.description,layout:e.layout,defaultSizes:e.defaultSizes,defaultCollapsed:e.defaultCollapsed,createdAt:Date.now(),updatedAt:Date.now(),isBuiltIn:!1},i={...t,[r]:a};return await this.adapter.saveWorkspacePresets(i),a}static async updateWorkspaceLayout(e,t){const r=await this.adapter.loadWorkspacePresets(),a=r[e];if(!a)return console.error(`Workspace layout ${e} not found`),null;if(a.isBuiltIn)return console.error(`Cannot update built-in workspace layout ${e}`),null;const i={...a,...t,id:e,createdAt:a.createdAt,updatedAt:Date.now()},l={...r,[e]:i};return await this.adapter.saveWorkspacePresets(l),i}static async deleteWorkspaceLayout(e){const t=await this.adapter.loadWorkspacePresets(),r=t[e];if(!r)return console.error(`Workspace layout ${e} not found`),!1;if(r.isBuiltIn)return console.error(`Cannot delete built-in workspace layout ${e}`),!1;const a={...t};return delete a[e],await this.adapter.saveWorkspacePresets(a),!0}static async getRepositoryState(e){return await this.adapter.loadRepositoryState(e)}static async setRepositoryState(e,t){await this.adapter.saveRepositoryState(e,t)}static async updateRepositorySizes(e,t){const r=await this.getRepositoryState(e);r&&await this.setRepositoryState(e,{...r,sizes:t})}static async updateRepositoryCollapsed(e,t){const r=await this.getRepositoryState(e);r&&await this.setRepositoryState(e,{...r,collapsed:t})}static hasStateDeviation(e,t){const r=t.defaultSizes?JSON.stringify(e.sizes)!==JSON.stringify(t.defaultSizes):!1,a=t.defaultCollapsed?JSON.stringify(e.collapsed)!==JSON.stringify(t.defaultCollapsed):!1;return{hasSizeDeviation:r,hasCollapsedDeviation:a}}static async updateWorkspaceFromRepositoryState(e,t){const r=await this.getWorkspaceLayout(e),a=await this.getRepositoryState(t);if(!r||!a||r.isBuiltIn){console.error("Cannot update built-in workspace or workspace/state not found");return}await this.updateWorkspaceLayout(e,{defaultSizes:a.sizes,defaultCollapsed:a.collapsed})}static async resetRepositoryToWorkspaceDefaults(e,t){const r=await this.getWorkspaceLayout(t);if(!r){console.error(`Workspace ${t} not found`);return}const a=await this.getRepositoryState(e);a&&await this.setRepositoryState(e,{...a,sizes:r.defaultSizes||{left:20,middle:45,right:35},collapsed:r.defaultCollapsed||{left:!1,right:!1}})}static isLayoutMatchingWorkspace(e,t){return this.areLayoutsEqual(e,t.layout)}static async findMatchingWorkspace(e){const t=await this.getWorkspaceLayouts();for(const[r,a]of Object.entries(t))if(this.isLayoutMatchingWorkspace(e,a))return r;return null}static areLayoutsEqual(e,t){return JSON.stringify(e)===JSON.stringify(t)}static generateWorkspaceId(e){return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"-")}-${Date.now()}`}static getBuiltInWorkspaceLayouts(){const e=Date.now();return{"project-management":{id:"project-management",name:"Project Management",description:"Tasks, dependencies, issues, file tree, docs, drawings, multi terminal, city visualization, code viewer, markdown slides, and excalidraw",layout:{left:{type:"tabs",panels:["tasks","dependencies","gitIssues","fileTree","docs","drawings"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:"multiTerminal",right:{type:"tabs",panels:["cityVisualization","codeViewer","markdownViewer","excalidrawDiagram"],config:{defaultActiveTab:0,tabPosition:"top"}}},defaultSizes:{left:20,middle:45,right:35},defaultCollapsed:{left:!1,right:!1},createdAt:e,updatedAt:e,isBuiltIn:!0},"code-review":{id:"code-review",name:"Code Review",description:"Git changes, pull requests, and file tree on left, git diff and code viewer in middle, city map on right",layout:{left:{type:"tabs",panels:["gitChanges","gitPullRequests","fileTree"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:{type:"tabs",panels:["gitDiff","codeViewer"],config:{defaultActiveTab:0,tabPosition:"top"}},right:"cityVisualization"},defaultSizes:{left:20,middle:50,right:30},defaultCollapsed:{left:!1,right:!1},createdAt:e,updatedAt:e,isBuiltIn:!0},documentation:{id:"documentation",name:"Documentation",description:"Docs, markdown viewer, and code viewer",layout:{left:"docs",middle:"markdownViewer",right:"codeViewer"},defaultSizes:{left:20,middle:50,right:30},defaultCollapsed:{left:!1,right:!0},createdAt:e,updatedAt:e,isBuiltIn:!0},"agent-work":{id:"agent-work",name:"Agent Work",description:"Tasks, agent sessions, file tree, agent context, git changes, docs, multi terminal, city map, agent events, code viewer, and markdown slides",layout:{left:{type:"tabs",panels:["tasks","agentSessions","fileTree","agentContext","gitChanges","docs"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:"multiTerminal",right:{type:"tabs",panels:["cityVisualization","agentEvents","codeViewer","markdownViewer"],config:{defaultActiveTab:0,tabPosition:"top"}}},defaultSizes:{left:20,middle:45,right:35},defaultCollapsed:{left:!1,right:!1},createdAt:e,updatedAt:e,isBuiltIn:!0},"quality-check":{id:"quality-check",name:"Quality Check",description:"Package information, tools, and dependencies on left; city visualization map in middle; multi terminal and code viewer on right (collapsed)",layout:{left:{type:"tabs",panels:["packageInfo","tools","dependencies"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:"cityVisualization",right:{type:"tabs",panels:["multiTerminal","codeViewer"],config:{defaultActiveTab:0,tabPosition:"top"}}},defaultSizes:{left:20,middle:45,right:35},defaultCollapsed:{left:!1,right:!0},createdAt:e,updatedAt:e,isBuiltIn:!0},drawing:{id:"drawing",name:"Drawing",description:"Drawings and docs, excalidraw diagram, multi terminal and markdown viewer",layout:{left:{type:"tabs",panels:["drawings","docs"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:"excalidrawDiagram",right:{type:"tabs",panels:["multiTerminal","markdownViewer"],config:{defaultActiveTab:0,tabPosition:"top"}}},defaultSizes:{left:20,middle:50,right:30},defaultCollapsed:{left:!1,right:!0},createdAt:e,updatedAt:e,isBuiltIn:!0},"old-school":{id:"old-school",name:"Old School",description:"File tree, search, git changes, and docs on left; code viewer and markdown viewer in middle; multi terminal and city map on right (collapsed)",layout:{left:{type:"tabs",panels:["fileTree","search","gitChanges","docs"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:{type:"tabs",panels:["codeViewer","markdownViewer"],config:{defaultActiveTab:0,tabPosition:"top"}},right:{type:"tabs",panels:["multiTerminal","cityVisualization"],config:{defaultActiveTab:0,tabPosition:"top"}}},defaultSizes:{left:20,middle:50,right:30},defaultCollapsed:{left:!1,right:!0},createdAt:e,updatedAt:e,isBuiltIn:!0},"principal-office":{id:"principal-office",name:"Principal Office",description:"Alexandria docs on left, MDX editor in middle, multi terminal on right",layout:{left:"docs",middle:"mdxEditor",right:"multiTerminal"},defaultSizes:{left:20,middle:50,right:30},defaultCollapsed:{left:!1,right:!1},createdAt:e,updatedAt:e,isBuiltIn:!0}}}static async initializeWorkspaceLayouts(){const e=await this.adapter.loadWorkspacePresets();Object.keys(e).length}}se(L,"adapter",new Te);function Oe(o={}){const{repositoryKey:e,autoInitialize:t=!1,defaultWorkspaceId:r}=o,[a,i]=c.useState({}),[l,n]=c.useState(null),[g,d]=c.useState(null),[m,h]=c.useState(!0),[y,S]=c.useState(null),f=c.useCallback(async()=>{try{h(!0),S(null);const b=await L.getWorkspaceLayouts();if(i(b),e){let j=await L.getRepositoryState(e);if(!j&&t){const P=r||"project-management",$=await L.getWorkspaceLayout(P);$&&(j={workspaceId:P,sizes:$.defaultSizes||{left:20,middle:45,right:35},collapsed:$.defaultCollapsed||{left:!1,right:!1}},await L.setRepositoryState(e,j))}if(n(j),j!=null&&j.workspaceId){const P=await L.getWorkspaceLayout(j.workspaceId);d(P)}else d(null)}}catch(b){S(b),console.error("Failed to load workspace data:",b)}finally{h(!1)}},[e,t,r]);c.useEffect(()=>{f()},[f]);const p=c.useCallback(async b=>await L.getWorkspaceLayout(b),[]),u=c.useCallback(async b=>{const j=await L.createWorkspaceLayout(b);return await f(),j},[f]),C=c.useCallback(async(b,j)=>{const P=await L.updateWorkspaceLayout(b,j);return await f(),P},[f]),I=c.useCallback(async b=>{const j=await L.deleteWorkspaceLayout(b);return j&&await f(),j},[f]),A=c.useCallback(async b=>{if(!e){console.error("Cannot apply workspace without repositoryKey");return}const j=await L.getWorkspaceLayout(b);if(!j){console.error(`Workspace ${b} not found`);return}const P={workspaceId:b,sizes:j.defaultSizes||{left:20,middle:45,right:35},collapsed:j.defaultCollapsed||{left:!1,right:!1}};await L.setRepositoryState(e,P),await f()},[e,f]),v=c.useCallback(async b=>{if(!e){console.error("Cannot update sizes without repositoryKey");return}await L.updateRepositorySizes(e,b),await f()},[e,f]),E=c.useCallback(async b=>{if(!e){console.error("Cannot update collapsed without repositoryKey");return}await L.updateRepositoryCollapsed(e,b),await f()},[e,f]),k=c.useCallback(async()=>{if(!e||!(l!=null&&l.workspaceId)){console.error("Cannot reset without repositoryKey and active workspace");return}await L.resetRepositoryToWorkspaceDefaults(e,l.workspaceId),await f()},[e,l==null?void 0:l.workspaceId,f]),w=c.useCallback(async()=>{await f()},[f]);return{workspaces:a,repositoryState:l,activeWorkspace:g,loading:m,error:y,getWorkspace:p,createWorkspace:u,updateWorkspace:C,deleteWorkspace:I,applyWorkspace:A,updateSizes:v,updateCollapsed:E,resetToDefaults:k,refresh:w}}function Ne(o={}){const{initialFocus:e=null,collapsed:t={},panelType:r="three-panel",onFocusChange:a,events:i,getPanelId:l}=o,[n,g]=c.useState(e),d=c.useCallback(p=>{const u=n;if(g(p),a==null||a(p),i&&l){if(u){const I=l(u);I&&i.emit({type:"panel:blur",source:"panel-layouts",timestamp:Date.now(),payload:{panelId:I,panelSlot:u,nextPanelId:l(p)}})}const C=l(p);C&&i.emit({type:"panel:focus",source:"panel-layouts",timestamp:Date.now(),payload:{panelId:C,panelSlot:p,source:"keyboard-shortcut"}})}},[n,a,i,l]),m=c.useCallback(()=>{const p=n;if(g(null),a==null||a(null),i&&l&&p){const u=l(p);u&&i.emit({type:"panel:blur",source:"panel-layouts",timestamp:Date.now(),payload:{panelId:u,panelSlot:p}})}},[n,a,i,l]),h=c.useCallback(()=>{const p=[];return t.left||p.push("left"),p.push("middle"),r==="three-panel"&&!t.right&&p.push("right"),p},[t,r]),y=c.useCallback(()=>{const p=h();if(p.length===0)return;if(n===null){d(p[0]);return}const u=p.indexOf(n);if(u===-1){d(p[0]);return}const C=(u+1)%p.length;d(p[C])},[n,h,d]),S=c.useCallback(()=>{const p=h();if(p.length===0)return;if(n===null){d(p[p.length-1]);return}const u=p.indexOf(n);if(u===-1){d(p[p.length-1]);return}const C=u===0?p.length-1:u-1;d(p[C])},[n,h,d]),f=c.useCallback(p=>n===p,[n]);return{focusedPanel:n,setFocus:d,clearFocus:m,focusNext:y,focusPrevious:S,isFocused:f}}function Ve(o){const{enabled:e=!0,focusedPanel:t,collapsed:r,panelType:a,setFocus:i,onExpand:l,onCollapse:n}=o,g=c.useRef(t),d=c.useRef(r),m=c.useRef(a);c.useEffect(()=>{g.current=t},[t]),c.useEffect(()=>{d.current=r},[r]),c.useEffect(()=>{m.current=a},[a]);const h=c.useCallback(y=>{if(!y.altKey||y.ctrlKey||y.metaKey||y.shiftKey)return;const S=y.code,f=g.current,p=d.current,u=m.current;S==="Digit1"||S==="Numpad1"?(y.preventDefault(),p.left?l("left"):f!=="left"?i("left"):(n("left"),i("middle"))):S==="Digit2"||S==="Numpad2"?(y.preventDefault(),i("middle")):(S==="Digit3"||S==="Numpad3")&&u==="three-panel"&&(y.preventDefault(),p.right?l("right"):f!=="right"?i("right"):(n("right"),i("middle")))},[i,l,n]);c.useEffect(()=>{if(e)return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h)}},[e,h])}function Be(o,e,t,r){c.useEffect(()=>{const a=e.on("panel:focus",l=>{l.payload.panelId===o&&t()});let i;return r&&(i=e.on("panel:blur",l=>{l.payload.panelId===o&&r()})),()=>{a(),i==null||i()}},[o,e,t,r])}const Ke=({isFocused:o,className:e="",style:t={}})=>{if(!o)return null;const r={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",border:"2px solid var(--panel-focus-border-color, #0066cc)",borderRadius:"4px",boxShadow:"0 0 0 1px var(--panel-focus-shadow-color, rgba(0, 102, 204, 0.2))",zIndex:1e3,transition:"opacity 0.15s ease-in-out",...t};return s.jsx("div",{className:`panel-focus-indicator ${e}`,style:r,role:"presentation","aria-hidden":"true"})},je="focus-mode-overlay-keyframes",Qe=()=>{if(typeof document>"u"||document.getElementById(je))return;const o=document.createElement("style");o.id=je,o.textContent=`
1
+ "use strict";require('./index.css');var De=Object.defineProperty;var Fe=(o,e,t)=>e in o?De(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var se=(o,e,t)=>Fe(o,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ne=require("@principal-ade/panels"),i=require("react"),s=require("react/jsx-runtime"),H=require("@principal-ade/industry-theme");class Ce{constructor(){se(this,"storageKey","panel-layouts")}async load(e){try{const t=localStorage.getItem(`${this.storageKey}:${e}`);return t?JSON.parse(t):null}catch(t){return console.error(`Failed to load panel layout for ${e}:`,t),null}}async save(e,t){try{localStorage.setItem(`${this.storageKey}:${e}`,JSON.stringify(t))}catch(r){console.error(`Failed to save panel layout for ${e}:`,r)}}}function qe(o){const{viewKey:e,defaultSizes:t,panelType:r,adapter:a=new Ce}=o,[l,c]=i.useState(t),[n,m]=i.useState(o.collapsed),d=i.useRef(o.collapsed),b=i.useRef({}),f=i.useRef(null),h=i.useRef(null);i.useEffect(()=>{(async()=>{const k=await a.load(e);k!=null&&k.sizes&&(c(k.sizes),v(k.sizes))})()},[e]);const v=i.useCallback(w=>{"left"in w&&w.left>0&&(b.current.left=w.left),"middle"in w&&w.middle>0&&(b.current.middle=w.middle),"right"in w&&w.right>0&&(b.current.right=w.right)},[]),g=i.useCallback(w=>{const k=b.current[w];if(k&&k>0)return k;if(w==="left"&&"left"in t&&t.left>0)return t.left;if(w==="right"&&"right"in t&&t.right>0)return t.right},[t]),p=i.useRef(t);i.useEffect(()=>{("left"in t&&t.left!==p.current.left||"middle"in t&&"middle"in p.current&&t.middle!==p.current.middle||"right"in t&&t.right!==p.current.right)&&(c(t),v(t),p.current=t)},[t,v]),i.useEffect(()=>{const w=o.collapsed.left!==d.current.left,k="right"in o.collapsed&&"right"in d.current&&o.collapsed.right!==d.current.right;(w||k)&&(m(o.collapsed),d.current={...o.collapsed})},[o.collapsed.left,o.collapsed.right]);const u=i.useCallback(async w=>{try{await a.save(e,{sizes:w})}catch(k){console.error(`Failed to save panel preferences for ${e}:`,k)}},[e,a]),j=i.useCallback(w=>{const k={...w};let x=!0;if("left"in w){const T=!!(n!=null&&n.left),A=w.left;if(T){const I=g("left");I!==void 0&&I>0?k.left=I:x=!1}else A===0&&(x=!1)}if(r==="three-panel"&&"right"in w){const T=!!(n!=null&&n.right),A=w.right;if(T){const I=g("right");I!==void 0&&I>0?k.right=I:x=!1}else A===0&&(x=!1)}if(c(k),v(k),f.current&&(clearTimeout(f.current),f.current=null),!x){h.current=null;return}h.current=k,f.current=setTimeout(()=>{const T=h.current;T&&(u(T),h.current=null),f.current=null},500)},[n,g,r,u,v]);i.useEffect(()=>()=>{if(f.current){const w=h.current;w&&(u(w),h.current=null),clearTimeout(f.current),f.current=null}},[u]);const $=i.useCallback(async()=>{},[]),L=i.useCallback(async()=>{},[]),C=i.useCallback(async()=>{},[]),E=i.useCallback(async()=>{},[]);return r==="three-panel"?{type:"three-panel",sizes:l,collapsed:n,handlePanelResize:j,handleLeftCollapseComplete:$,handleLeftExpandComplete:L,handleRightCollapseComplete:C,handleRightExpandComplete:E}:{type:"two-panel",sizes:l,collapsed:n,handlePanelResize:j,handleLeftCollapseComplete:$,handleLeftExpandComplete:L}}class Te{constructor(){se(this,"PRESETS_KEY","panel-layouts:workspace-presets");se(this,"REPO_STATE_PREFIX","panel-layouts:repo-state:")}async loadWorkspacePresets(){try{const e=localStorage.getItem(this.PRESETS_KEY);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to load workspace presets:",e),{}}}async saveWorkspacePresets(e){try{localStorage.setItem(this.PRESETS_KEY,JSON.stringify(e))}catch(t){throw console.error("Failed to save workspace presets:",t),t}}async loadRepositoryState(e){try{const t=`${this.REPO_STATE_PREFIX}${e}`,r=localStorage.getItem(t);return r?JSON.parse(r):null}catch(t){return console.error(`Failed to load repository state for ${e}:`,t),null}}async saveRepositoryState(e,t){try{const r=`${this.REPO_STATE_PREFIX}${e}`;localStorage.setItem(r,JSON.stringify(t))}catch(r){throw console.error(`Failed to save repository state for ${e}:`,r),r}}async loadAllRepositoryStates(){try{const e={};for(let t=0;t<localStorage.length;t++){const r=localStorage.key(t);if(r&&r.startsWith(this.REPO_STATE_PREFIX)){const a=r.substring(this.REPO_STATE_PREFIX.length),l=localStorage.getItem(r);if(l)try{e[a]=JSON.parse(l)}catch(c){console.error(`Failed to parse repository state for ${a}:`,c)}}}return e}catch(e){return console.error("Failed to load all repository states:",e),{}}}}class W{static setAdapter(e){this.adapter=e}static async getWorkspaceLayouts(){const e=this.getBuiltInWorkspaceLayouts();return{...await this.adapter.loadWorkspacePresets(),...e}}static async getWorkspaceLayout(e){return(await this.getWorkspaceLayouts())[e]||null}static async createWorkspaceLayout(e){const t=await this.adapter.loadWorkspacePresets(),r=this.generateWorkspaceId(e.name),a={id:r,name:e.name,description:e.description,layout:e.layout,defaultSizes:e.defaultSizes,defaultCollapsed:e.defaultCollapsed,createdAt:Date.now(),updatedAt:Date.now(),isBuiltIn:!1},l={...t,[r]:a};return await this.adapter.saveWorkspacePresets(l),a}static async updateWorkspaceLayout(e,t){const r=await this.adapter.loadWorkspacePresets(),a=r[e];if(!a)return console.error(`Workspace layout ${e} not found`),null;if(a.isBuiltIn)return console.error(`Cannot update built-in workspace layout ${e}`),null;const l={...a,...t,id:e,createdAt:a.createdAt,updatedAt:Date.now()},c={...r,[e]:l};return await this.adapter.saveWorkspacePresets(c),l}static async deleteWorkspaceLayout(e){const t=await this.adapter.loadWorkspacePresets(),r=t[e];if(!r)return console.error(`Workspace layout ${e} not found`),!1;if(r.isBuiltIn)return console.error(`Cannot delete built-in workspace layout ${e}`),!1;const a={...t};return delete a[e],await this.adapter.saveWorkspacePresets(a),!0}static async getRepositoryState(e){return await this.adapter.loadRepositoryState(e)}static async setRepositoryState(e,t){await this.adapter.saveRepositoryState(e,t)}static async updateRepositorySizes(e,t){const r=await this.getRepositoryState(e);r&&await this.setRepositoryState(e,{...r,sizes:t})}static async updateRepositoryCollapsed(e,t){const r=await this.getRepositoryState(e);r&&await this.setRepositoryState(e,{...r,collapsed:t})}static hasStateDeviation(e,t){const r=t.defaultSizes?JSON.stringify(e.sizes)!==JSON.stringify(t.defaultSizes):!1,a=t.defaultCollapsed?JSON.stringify(e.collapsed)!==JSON.stringify(t.defaultCollapsed):!1;return{hasSizeDeviation:r,hasCollapsedDeviation:a}}static async updateWorkspaceFromRepositoryState(e,t){const r=await this.getWorkspaceLayout(e),a=await this.getRepositoryState(t);if(!r||!a||r.isBuiltIn){console.error("Cannot update built-in workspace or workspace/state not found");return}await this.updateWorkspaceLayout(e,{defaultSizes:a.sizes,defaultCollapsed:a.collapsed})}static async resetRepositoryToWorkspaceDefaults(e,t){const r=await this.getWorkspaceLayout(t);if(!r){console.error(`Workspace ${t} not found`);return}const a=await this.getRepositoryState(e);a&&await this.setRepositoryState(e,{...a,sizes:r.defaultSizes||{left:20,middle:45,right:35},collapsed:r.defaultCollapsed||{left:!1,right:!1}})}static isLayoutMatchingWorkspace(e,t){return this.areLayoutsEqual(e,t.layout)}static async findMatchingWorkspace(e){const t=await this.getWorkspaceLayouts();for(const[r,a]of Object.entries(t))if(this.isLayoutMatchingWorkspace(e,a))return r;return null}static areLayoutsEqual(e,t){return JSON.stringify(e)===JSON.stringify(t)}static generateWorkspaceId(e){return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"-")}-${Date.now()}`}static getBuiltInWorkspaceLayouts(){const e=Date.now();return{"project-management":{id:"project-management",name:"Project Management",description:"Tasks, dependencies, issues, file tree, docs, drawings, multi terminal, city visualization, code viewer, markdown slides, and excalidraw",layout:{left:{type:"tabs",panels:["tasks","dependencies","gitIssues","fileTree","docs","drawings"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:"multiTerminal",right:{type:"tabs",panels:["cityVisualization","codeViewer","markdownViewer","excalidrawDiagram"],config:{defaultActiveTab:0,tabPosition:"top"}}},defaultSizes:{left:20,middle:45,right:35},defaultCollapsed:{left:!1,right:!1},createdAt:e,updatedAt:e,isBuiltIn:!0},"code-review":{id:"code-review",name:"Code Review",description:"Git changes, pull requests, and file tree on left, git diff and code viewer in middle, city map on right",layout:{left:{type:"tabs",panels:["gitChanges","gitPullRequests","fileTree"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:{type:"tabs",panels:["gitDiff","codeViewer"],config:{defaultActiveTab:0,tabPosition:"top"}},right:"cityVisualization"},defaultSizes:{left:20,middle:50,right:30},defaultCollapsed:{left:!1,right:!1},createdAt:e,updatedAt:e,isBuiltIn:!0},documentation:{id:"documentation",name:"Documentation",description:"Docs, markdown viewer, and code viewer",layout:{left:"docs",middle:"markdownViewer",right:"codeViewer"},defaultSizes:{left:20,middle:50,right:30},defaultCollapsed:{left:!1,right:!0},createdAt:e,updatedAt:e,isBuiltIn:!0},"agent-work":{id:"agent-work",name:"Agent Work",description:"Tasks, agent sessions, file tree, agent context, git changes, docs, multi terminal, city map, agent events, code viewer, and markdown slides",layout:{left:{type:"tabs",panels:["tasks","agentSessions","fileTree","agentContext","gitChanges","docs"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:"multiTerminal",right:{type:"tabs",panels:["cityVisualization","agentEvents","codeViewer","markdownViewer"],config:{defaultActiveTab:0,tabPosition:"top"}}},defaultSizes:{left:20,middle:45,right:35},defaultCollapsed:{left:!1,right:!1},createdAt:e,updatedAt:e,isBuiltIn:!0},"quality-check":{id:"quality-check",name:"Quality Check",description:"Package information, tools, and dependencies on left; city visualization map in middle; multi terminal and code viewer on right (collapsed)",layout:{left:{type:"tabs",panels:["packageInfo","tools","dependencies"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:"cityVisualization",right:{type:"tabs",panels:["multiTerminal","codeViewer"],config:{defaultActiveTab:0,tabPosition:"top"}}},defaultSizes:{left:20,middle:45,right:35},defaultCollapsed:{left:!1,right:!0},createdAt:e,updatedAt:e,isBuiltIn:!0},drawing:{id:"drawing",name:"Drawing",description:"Drawings and docs, excalidraw diagram, multi terminal and markdown viewer",layout:{left:{type:"tabs",panels:["drawings","docs"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:"excalidrawDiagram",right:{type:"tabs",panels:["multiTerminal","markdownViewer"],config:{defaultActiveTab:0,tabPosition:"top"}}},defaultSizes:{left:20,middle:50,right:30},defaultCollapsed:{left:!1,right:!0},createdAt:e,updatedAt:e,isBuiltIn:!0},"old-school":{id:"old-school",name:"Old School",description:"File tree, search, git changes, and docs on left; code viewer and markdown viewer in middle; multi terminal and city map on right (collapsed)",layout:{left:{type:"tabs",panels:["fileTree","search","gitChanges","docs"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:{type:"tabs",panels:["codeViewer","markdownViewer"],config:{defaultActiveTab:0,tabPosition:"top"}},right:{type:"tabs",panels:["multiTerminal","cityVisualization"],config:{defaultActiveTab:0,tabPosition:"top"}}},defaultSizes:{left:20,middle:50,right:30},defaultCollapsed:{left:!1,right:!0},createdAt:e,updatedAt:e,isBuiltIn:!0},"principal-office":{id:"principal-office",name:"Principal Office",description:"Alexandria docs on left, MDX editor in middle, multi terminal on right",layout:{left:"docs",middle:"mdxEditor",right:"multiTerminal"},defaultSizes:{left:20,middle:50,right:30},defaultCollapsed:{left:!1,right:!1},createdAt:e,updatedAt:e,isBuiltIn:!0}}}static async initializeWorkspaceLayouts(){const e=await this.adapter.loadWorkspacePresets();Object.keys(e).length}}se(W,"adapter",new Te);function Oe(o={}){const{repositoryKey:e,autoInitialize:t=!1,defaultWorkspaceId:r}=o,[a,l]=i.useState({}),[c,n]=i.useState(null),[m,d]=i.useState(null),[b,f]=i.useState(!0),[h,v]=i.useState(null),g=i.useCallback(async()=>{try{f(!0),v(null);const x=await W.getWorkspaceLayouts();if(l(x),e){let T=await W.getRepositoryState(e);if(!T&&t){const A=r||"project-management",I=await W.getWorkspaceLayout(A);I&&(T={workspaceId:A,sizes:I.defaultSizes||{left:20,middle:45,right:35},collapsed:I.defaultCollapsed||{left:!1,right:!1}},await W.setRepositoryState(e,T))}if(n(T),T!=null&&T.workspaceId){const A=await W.getWorkspaceLayout(T.workspaceId);d(A)}else d(null)}}catch(x){v(x),console.error("Failed to load workspace data:",x)}finally{f(!1)}},[e,t,r]);i.useEffect(()=>{g()},[g]);const p=i.useCallback(async x=>await W.getWorkspaceLayout(x),[]),u=i.useCallback(async x=>{const T=await W.createWorkspaceLayout(x);return await g(),T},[g]),j=i.useCallback(async(x,T)=>{const A=await W.updateWorkspaceLayout(x,T);return await g(),A},[g]),$=i.useCallback(async x=>{const T=await W.deleteWorkspaceLayout(x);return T&&await g(),T},[g]),L=i.useCallback(async x=>{if(!e){console.error("Cannot apply workspace without repositoryKey");return}const T=await W.getWorkspaceLayout(x);if(!T){console.error(`Workspace ${x} not found`);return}const A={workspaceId:x,sizes:T.defaultSizes||{left:20,middle:45,right:35},collapsed:T.defaultCollapsed||{left:!1,right:!1}};await W.setRepositoryState(e,A),await g()},[e,g]),C=i.useCallback(async x=>{if(!e){console.error("Cannot update sizes without repositoryKey");return}await W.updateRepositorySizes(e,x),await g()},[e,g]),E=i.useCallback(async x=>{if(!e){console.error("Cannot update collapsed without repositoryKey");return}await W.updateRepositoryCollapsed(e,x),await g()},[e,g]),w=i.useCallback(async()=>{if(!e||!(c!=null&&c.workspaceId)){console.error("Cannot reset without repositoryKey and active workspace");return}await W.resetRepositoryToWorkspaceDefaults(e,c.workspaceId),await g()},[e,c==null?void 0:c.workspaceId,g]),k=i.useCallback(async()=>{await g()},[g]);return{workspaces:a,repositoryState:c,activeWorkspace:m,loading:b,error:h,getWorkspace:p,createWorkspace:u,updateWorkspace:j,deleteWorkspace:$,applyWorkspace:L,updateSizes:C,updateCollapsed:E,resetToDefaults:w,refresh:k}}function Ne(o={}){const{initialFocus:e=null,collapsed:t={},panelType:r="three-panel",onFocusChange:a,events:l,getPanelId:c}=o,[n,m]=i.useState(e),d=i.useCallback(p=>{const u=n;if(m(p),a==null||a(p),l&&c){if(u){const $=c(u);$&&l.emit({type:"panel:blur",source:"panel-layouts",timestamp:Date.now(),payload:{panelId:$,panelSlot:u,nextPanelId:c(p)}})}const j=c(p);j&&l.emit({type:"panel:focus",source:"panel-layouts",timestamp:Date.now(),payload:{panelId:j,panelSlot:p,source:"keyboard-shortcut"}})}},[n,a,l,c]),b=i.useCallback(()=>{const p=n;if(m(null),a==null||a(null),l&&c&&p){const u=c(p);u&&l.emit({type:"panel:blur",source:"panel-layouts",timestamp:Date.now(),payload:{panelId:u,panelSlot:p}})}},[n,a,l,c]),f=i.useCallback(()=>{const p=[];return t.left||p.push("left"),p.push("middle"),r==="three-panel"&&!t.right&&p.push("right"),p},[t,r]),h=i.useCallback(()=>{const p=f();if(p.length===0)return;if(n===null){d(p[0]);return}const u=p.indexOf(n);if(u===-1){d(p[0]);return}const j=(u+1)%p.length;d(p[j])},[n,f,d]),v=i.useCallback(()=>{const p=f();if(p.length===0)return;if(n===null){d(p[p.length-1]);return}const u=p.indexOf(n);if(u===-1){d(p[p.length-1]);return}const j=u===0?p.length-1:u-1;d(p[j])},[n,f,d]),g=i.useCallback(p=>n===p,[n]);return{focusedPanel:n,setFocus:d,clearFocus:b,focusNext:h,focusPrevious:v,isFocused:g}}function Ve(o){const{enabled:e=!0,focusedPanel:t,collapsed:r,panelType:a,setFocus:l,onExpand:c,onCollapse:n}=o,m=i.useRef(t),d=i.useRef(r),b=i.useRef(a);i.useEffect(()=>{m.current=t},[t]),i.useEffect(()=>{d.current=r},[r]),i.useEffect(()=>{b.current=a},[a]);const f=i.useCallback(h=>{if(!h.altKey||h.ctrlKey||h.metaKey||h.shiftKey)return;const v=h.code,g=m.current,p=d.current,u=b.current;v==="Digit1"||v==="Numpad1"?(h.preventDefault(),p.left?c("left"):g!=="left"?l("left"):(n("left"),l("middle"))):v==="Digit2"||v==="Numpad2"?(h.preventDefault(),l("middle")):(v==="Digit3"||v==="Numpad3")&&u==="three-panel"&&(h.preventDefault(),p.right?c("right"):g!=="right"?l("right"):(n("right"),l("middle")))},[l,c,n]);i.useEffect(()=>{if(e)return window.addEventListener("keydown",f),()=>{window.removeEventListener("keydown",f)}},[e,f])}function Be(o,e,t,r){i.useEffect(()=>{const a=e.on("panel:focus",c=>{c.payload.panelId===o&&t()});let l;return r&&(l=e.on("panel:blur",c=>{c.payload.panelId===o&&r()})),()=>{a(),l==null||l()}},[o,e,t,r])}const Ke=({isFocused:o,className:e="",style:t={}})=>{if(!o)return null;const r={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",border:"2px solid var(--panel-focus-border-color, #0066cc)",borderRadius:"4px",boxShadow:"0 0 0 1px var(--panel-focus-shadow-color, rgba(0, 102, 204, 0.2))",zIndex:1e3,transition:"opacity 0.15s ease-in-out",...t};return s.jsx("div",{className:`panel-focus-indicator ${e}`,style:r,role:"presentation","aria-hidden":"true"})},ve="focus-mode-overlay-keyframes",He=()=>{if(typeof document>"u"||document.getElementById(ve))return;const o=document.createElement("style");o.id=ve,o.textContent=`
2
2
  @keyframes focus-overlay-vignette-drift {
3
3
  0%, 100% {
4
4
  background-position: 50% 50%;
@@ -42,25 +42,25 @@
42
42
  to { background-position: 0px 150px; }
43
43
  }
44
44
 
45
- `,document.head.appendChild(o)},He=({active:o,variant:e="soft-fade",effects:t=[],opacity:r=.95,animationDuration:a=300,cascadeDelay:i=0,color:l,className:n="",style:g={}})=>{const{theme:d}=V.useTheme(),[m,h]=c.useState(!1);c.useEffect(()=>{Qe()},[]),c.useEffect(()=>{if(o){const D=setTimeout(()=>h(!0),i);return()=>clearTimeout(D)}else h(!1)},[o,i]);const y=l||d.colors.background,f={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:999,overflow:"hidden",...(()=>{switch(e){case"soft-fade":return{backgroundColor:y,opacity:m?r:0,transition:`opacity ${a}ms ease-out`};case"cascading-fade":return{backgroundColor:y,opacity:m?r:0,transition:`opacity ${a}ms ease-out`,transitionDelay:m?"0ms":`${i}ms`};default:return{backgroundColor:y,opacity:m?r:0,transition:`opacity ${a}ms ease-out`}}})(),...g},p=t.includes("vignette-drift"),u=t.includes("radial-breathing"),C=t.includes("snowfall"),I=(D,F)=>{const U=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(D);if(!U)return`rgba(255, 255, 255, ${F})`;const q=parseInt(U[1],16),B=parseInt(U[2],16),Z=parseInt(U[3],16);return`rgba(${q}, ${B}, ${Z}, ${F})`},A=d.colors.primary,v={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",opacity:m?1:0,transition:`opacity ${a}ms ease-out`,background:`radial-gradient(circle at 50% 50%, ${I(A,.12)} 0%, ${I(A,.06)} 25%, transparent 50%)`,backgroundSize:"150% 150%",animation:m?"focus-overlay-vignette-drift 12s ease-in-out infinite":"none"},E={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",opacity:m?1:0,transition:`opacity ${a}ms ease-out`,background:`radial-gradient(circle at center, ${I(A,.15)} 0%, ${I(A,.06)} 30%, transparent 55%)`,animation:m?"focus-overlay-radial-breathing 4s ease-in-out infinite":"none"},k=I(A,.6),w=I(A,.4),b=I(A,.25),j={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",opacity:m?1:0,transition:`opacity ${a}ms ease-out`},P={...j,background:`
46
- radial-gradient(circle, ${k} 0%, ${k} 3px, transparent 3px),
47
- radial-gradient(circle, ${k} 0%, ${k} 3px, transparent 3px),
48
- radial-gradient(circle, ${k} 0%, ${k} 3px, transparent 3px),
49
- radial-gradient(circle, ${k} 0%, ${k} 3px, transparent 3px)
50
- `,backgroundSize:"150px 150px",backgroundPosition:"10px 20px, 60px 80px, 110px 40px, 40px 120px",animation:m?"focus-overlay-snowfall-1 4s linear infinite":"none"},$={...j,background:`
51
- radial-gradient(circle, ${w} 0%, ${w} 2px, transparent 2px),
52
- radial-gradient(circle, ${w} 0%, ${w} 2px, transparent 2px),
53
- radial-gradient(circle, ${w} 0%, ${w} 2px, transparent 2px),
54
- radial-gradient(circle, ${w} 0%, ${w} 2px, transparent 2px),
55
- radial-gradient(circle, ${w} 0%, ${w} 2px, transparent 2px)
56
- `,backgroundSize:"150px 150px",backgroundPosition:"30px 10px, 90px 60px, 15px 100px, 120px 30px, 70px 130px",animation:m?"focus-overlay-snowfall-2 7s linear infinite":"none"},T={...j,background:`
57
- radial-gradient(circle, ${b} 0%, ${b} 1.5px, transparent 1.5px),
58
- radial-gradient(circle, ${b} 0%, ${b} 1.5px, transparent 1.5px),
59
- radial-gradient(circle, ${b} 0%, ${b} 1.5px, transparent 1.5px),
60
- radial-gradient(circle, ${b} 0%, ${b} 1.5px, transparent 1.5px),
61
- radial-gradient(circle, ${b} 0%, ${b} 1.5px, transparent 1.5px),
62
- radial-gradient(circle, ${b} 0%, ${b} 1.5px, transparent 1.5px)
63
- `,backgroundSize:"150px 150px",backgroundPosition:"20px 5px, 80px 45px, 45px 90px, 130px 20px, 5px 70px, 100px 110px",animation:m?"focus-overlay-snowfall-3 12s linear infinite":"none"};return s.jsxs("div",{className:`focus-mode-overlay focus-mode-overlay--${e} ${n}`,style:f,role:"presentation","aria-hidden":"true","data-active":o,"data-variant":e,children:[p&&s.jsx("div",{className:"focus-mode-overlay__vignette-drift",style:v}),u&&s.jsx("div",{className:"focus-mode-overlay__radial-breathing",style:E}),C&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"focus-mode-overlay__snowfall-layer-3",style:T}),s.jsx("div",{className:"focus-mode-overlay__snowfall-layer-2",style:$}),s.jsx("div",{className:"focus-mode-overlay__snowfall-layer-1",style:P})]})]})},ce=({value:o,onChange:e,onSubmit:t,onClose:r,onHistoryPrevious:a,onHistoryNext:i,mode:l,status:n,placeholder:g="What would you like to do?",disabled:d=!1,autoFocus:m=!0,agentAvailable:h=!0,showAutocomplete:y=!1,onAutocompleteNext:S,onAutocompletePrevious:f,onAutocompleteAccept:p})=>{const{theme:u}=V.useTheme(),C=c.useRef(null);c.useEffect(()=>{m&&C.current&&C.current.focus()},[m]);const I=v=>{switch(v.stopPropagation(),v.key){case"Enter":v.preventDefault(),t();break;case"Escape":v.preventDefault(),r();break;case"Tab":y&&p&&(v.preventDefault(),p());break;case"ArrowUp":v.preventDefault(),y&&f?f():a();break;case"ArrowDown":v.preventDefault(),y&&S?S():i();break}},A=n==="thinking"||n==="executing";return s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:u.colors.background,borderBottom:`1px solid ${u.colors.border}`},children:[s.jsx("span",{style:{color:l==="quick-command"?u.colors.info:h?u.colors.primary:u.colors.textMuted,fontFamily:u.fonts.monospace,fontSize:u.fontSizes[1],userSelect:"none",display:"flex",alignItems:"center"},children:l==="quick-command"?s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("polyline",{points:"4 17 10 11 4 5"}),s.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]}):h?s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),s.jsx("circle",{cx:"12",cy:"5",r:"2"}),s.jsx("path",{d:"M12 7v4"}),s.jsx("line",{x1:"8",y1:"16",x2:"8",y2:"16"}),s.jsx("line",{x1:"16",y1:"16",x2:"16",y2:"16"})]}):">"}),s.jsx("input",{ref:C,"data-agent-command-palette-input":!0,type:"text",value:o,onChange:v=>e(v.target.value),onKeyDown:I,placeholder:g,disabled:d||A,style:{flex:1,backgroundColor:"transparent",border:"none",outline:"none",color:u.colors.text,fontFamily:u.fonts.monospace,fontSize:u.fontSizes[1],caretColor:u.colors.primary}}),A&&s.jsxs("span",{style:{color:u.colors.info,fontSize:u.fontSizes[0],display:"flex",alignItems:"center",gap:"4px"},children:[s.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:u.colors.info,animation:"pulse 1s ease-in-out infinite"}}),n==="thinking"?"Thinking...":"Executing..."]}),!A&&s.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:u.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${u.colors.border}`,fontSize:u.fontSizes[0],color:u.colors.textMuted},children:"Alt+P"})]})};ce.displayName="AgentCommandInput";const Je=({status:o})=>{const{theme:e}=V.useTheme(),t={display:"inline-flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",fontSize:e.fontSizes[0]};switch(o){case"pending":return s.jsx("span",{style:{...t,color:e.colors.textMuted},children:"○"});case"running":return s.jsx("span",{style:{...t,color:e.colors.info,animation:"spin 1s linear infinite"},children:"◐"});case"success":return s.jsx("span",{style:{...t,color:e.colors.success},children:"✓"});case"error":return s.jsx("span",{style:{...t,color:e.colors.error},children:"✗"})}},Ge=o=>{const e=Object.entries(o);return e.length===0?"":e.map(([t,r])=>t==="args"&&Array.isArray(r)?r.join(", "):typeof r=="string"?`"${r}"`:JSON.stringify(r)).join(", ")},Ue=({tool:o,compact:e})=>{const{theme:t}=V.useTheme(),r=Ge(o.args);return s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:e?"4px 0":"8px 0",fontFamily:t.fonts.monospace,fontSize:t.fontSizes[1]},children:[s.jsx(Je,{status:o.status}),s.jsxs("span",{style:{color:t.colors.text},children:[o.name,r&&s.jsxs("span",{style:{color:t.colors.textMuted},children:["(",r,")"]})]}),o.status==="running"&&s.jsx("span",{style:{marginLeft:"auto",color:t.colors.info,fontSize:t.fontSizes[0]},children:"[running]"}),o.status==="success"&&s.jsx("span",{style:{marginLeft:"auto",color:t.colors.success,fontSize:t.fontSizes[0]},children:"[done]"}),o.status==="error"&&s.jsx("span",{style:{marginLeft:"auto",color:t.colors.error,fontSize:t.fontSizes[0]},title:o.error,children:"[error]"})]})},de=({tools:o,compact:e=!1})=>{const{theme:t}=V.useTheme();return o.length===0?null:s.jsx("div",{style:{padding:e?"8px 16px":"12px 16px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"4px",margin:"8px 16px"},children:o.map(r=>s.jsx(Ue,{tool:r,compact:e},r.id))})};de.displayName="ToolExecutionList";const pe=({response:o,streaming:e=!1})=>{const{theme:t}=V.useTheme();if(!o)return null;const r=o.toLowerCase().startsWith("error"),a=o.toLowerCase().startsWith("done")||o.toLowerCase().startsWith("executed");return s.jsxs("div",{style:{padding:"12px 16px",color:r?t.colors.error:a?t.colors.success:t.colors.text,fontSize:t.fontSizes[1],display:"flex",alignItems:"center",gap:"8px"},children:[a&&s.jsx("span",{children:"✓"}),r&&s.jsx("span",{children:"✗"}),s.jsxs("span",{children:[o,e&&s.jsx("span",{style:{display:"inline-block",width:"2px",height:"14px",backgroundColor:t.colors.primary,marginLeft:"2px",animation:"blink 1s step-end infinite"}})]})]})};pe.displayName="AgentResponseDisplay";function Ce({text:o,matchedIndices:e,highlightColor:t}){if(!e.length)return s.jsx(s.Fragment,{children:o});const r=new Set(e),a=o.split("");return s.jsx(s.Fragment,{children:a.map((i,l)=>s.jsx("span",{style:{color:r.has(l)?t:"inherit",fontWeight:r.has(l)?600:"inherit"},children:i},l))})}const ue=({matches:o,argumentMatches:e=[],currentArg:t,isEnteringArgs:r=!1,selectedIndex:a,onSelect:i,maxVisible:l=6})=>{const{theme:n}=V.useTheme(),g=c.useRef(null),d=c.useRef(null);if(c.useEffect(()=>{d.current&&g.current&&d.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[a]),r&&e.length>0){const S=40*l;return s.jsxs("div",{ref:g,style:{maxHeight:`${S}px`,overflowY:"auto",borderTop:`1px solid ${n.colors.border}`},children:[t&&s.jsxs("div",{style:{padding:"8px 16px",fontSize:n.fontSizes[0],color:n.colors.textMuted,backgroundColor:n.colors.backgroundSecondary,borderBottom:`1px solid ${n.colors.border}`},children:[s.jsx("span",{style:{color:n.colors.textSecondary},children:t.name}),t.description&&s.jsxs("span",{style:{marginLeft:"8px"},children:["— ",t.description]})]}),e.map((f,p)=>{const u=p===a;return s.jsxs("div",{ref:u?d:void 0,onClick:()=>i(p),style:{display:"flex",alignItems:"center",gap:"12px",padding:"8px 16px",cursor:"pointer",backgroundColor:u?n.colors.backgroundSecondary:"transparent",borderLeft:u?`2px solid ${n.colors.primary}`:"2px solid transparent",transition:"background-color 100ms ease"},onMouseEnter:C=>{u||(C.currentTarget.style.backgroundColor=n.colors.backgroundSecondary)},onMouseLeave:C=>{u||(C.currentTarget.style.backgroundColor="transparent")},children:[s.jsx("span",{style:{fontFamily:n.fonts.monospace,fontSize:n.fontSizes[1],color:n.colors.text,flex:1},children:s.jsx(Ce,{text:f.option,matchedIndices:f.matchedIndices,highlightColor:n.colors.primary})}),u&&s.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:n.colors.backgroundTertiary,borderRadius:"3px",border:`1px solid ${n.colors.border}`,fontSize:n.fontSizes[0],color:n.colors.textMuted,flexShrink:0},children:"Tab"})]},`${f.option}-${p}`)})]})}if(o.length===0)return null;const h=48*l;return s.jsx("div",{ref:g,style:{maxHeight:`${h}px`,overflowY:"auto",borderTop:`1px solid ${n.colors.border}`},children:o.map((y,S)=>{const f=S===a,p=y.command;return s.jsxs("div",{ref:f?d:void 0,onClick:()=>i(S),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 16px",cursor:"pointer",backgroundColor:f?n.colors.backgroundSecondary:"transparent",borderLeft:f?`2px solid ${n.colors.primary}`:"2px solid transparent",transition:"background-color 100ms ease"},onMouseEnter:u=>{f||(u.currentTarget.style.backgroundColor=n.colors.backgroundSecondary)},onMouseLeave:u=>{f||(u.currentTarget.style.backgroundColor="transparent")},children:[s.jsx("span",{style:{color:n.colors.info,fontFamily:n.fonts.monospace,fontSize:n.fontSizes[1],flexShrink:0},children:"/"}),s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsxs("div",{style:{fontFamily:n.fonts.monospace,fontSize:n.fontSizes[1],color:n.colors.text},children:[s.jsx(Ce,{text:p.name,matchedIndices:y.matchedOn===p.name?y.matchedIndices:[],highlightColor:n.colors.primary}),y.matchedOn!==p.name&&s.jsxs("span",{style:{color:n.colors.textMuted,marginLeft:"8px",fontSize:n.fontSizes[0]},children:["(alias: ",y.matchedOn,")"]})]}),s.jsx("div",{style:{fontSize:n.fontSizes[0],color:n.colors.textMuted,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:p.description})]}),p.args&&p.args.length>0&&s.jsx("div",{style:{fontSize:n.fontSizes[0],color:n.colors.textMuted,fontFamily:n.fonts.monospace,flexShrink:0},children:p.args.map((u,C)=>s.jsxs("span",{children:[C>0&&" ",s.jsx("span",{style:{color:u.required?n.colors.warning:n.colors.textMuted},children:u.required?`<${u.name}>`:`[${u.name}]`})]},u.name))}),f&&s.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:n.colors.backgroundTertiary,borderRadius:"3px",border:`1px solid ${n.colors.border}`,fontSize:n.fontSizes[0],color:n.colors.textMuted,flexShrink:0},children:"Tab"})]},`${p.name}-${S}`)})})};ue.displayName="QuickCommandAutocomplete";const Ie=({palette:o,config:e})=>{const{theme:t}=V.useTheme(),r=c.useRef(null),{isOpen:a,close:i,query:l,setQuery:n,mode:g,status:d,pendingTools:m,completedTools:h,agentResponse:y,submit:S,historyPrevious:f,historyNext:p,suggestions:u,agentAvailable:C,quickCommandMatches:I,argumentOptionMatches:A,parsedQuery:v,currentArgDef:E,selectedAutocompleteIndex:k,autocompleteNext:w,autocompletePrevious:b,autocompleteAccept:j,showAutocomplete:P}=o;c.useEffect(()=>{if(!a)return;const N=W=>{r.current&&!r.current.contains(W.target)&&i()},K=setTimeout(()=>{document.addEventListener("mousedown",N)},100);return()=>{clearTimeout(K),document.removeEventListener("mousedown",N)}},[a,i]);const[$,T]=c.useState(!1),[D,F]=c.useState(!1);if(c.useEffect(()=>{if(a)F(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{T(!0)})});else{T(!1);const N=setTimeout(()=>{F(!1)},150);return()=>clearTimeout(N)}},[a]),!D)return null;const U=C?(e==null?void 0:e.placeholder)||"What would you like to do?":"Quick command mode (agent unavailable)",q=[...h,...m],B=q.length>0,Z=y&&d!=="idle",ee=C&&!l&&d==="idle"&&u.length>0,Y=(g==="quick-command"||!C)&&d==="idle",te=!C&&g!=="quick-command"&&d==="idle";return s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{position:"fixed",inset:0,zIndex:999},onClick:i}),s.jsxs("div",{ref:r,className:e==null?void 0:e.className,style:{position:"fixed",bottom:0,left:0,right:0,maxHeight:"50vh",backgroundColor:t.colors.background,borderTop:`1px solid ${t.colors.border}`,boxShadow:t.shadows[2],zIndex:1e3,display:"flex",flexDirection:"column-reverse",overflow:"hidden",transform:$?"translateY(0)":"translateY(100%)",transition:"transform 150ms ease-out",...e==null?void 0:e.style},children:[s.jsxs("div",{children:[s.jsx(ce,{value:l,onChange:n,onSubmit:S,onClose:i,onHistoryPrevious:f,onHistoryNext:p,mode:g,status:d,placeholder:U,agentAvailable:C,showAutocomplete:P,onAutocompleteNext:w,onAutocompletePrevious:b,onAutocompleteAccept:j}),s.jsxs("div",{style:{padding:"8px 16px",borderTop:`1px solid ${t.colors.border}`,display:"flex",gap:"16px",fontSize:t.fontSizes[0],color:t.colors.textMuted,backgroundColor:t.colors.background},children:[s.jsxs("span",{children:[s.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"Enter"})," ","Execute"]}),s.jsxs("span",{children:[s.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"Esc"})," ","Close"]}),s.jsxs("span",{children:[s.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"↑↓"})," ","History"]}),s.jsxs("span",{style:{marginLeft:"auto"},children:[s.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"/"})," ","Quick command"]})]})]}),s.jsxs("div",{style:{overflow:"auto"},children:[B&&s.jsx(de,{tools:q,compact:q.length>3}),Z&&s.jsx(pe,{response:y,streaming:d==="thinking"}),ee&&s.jsxs("div",{style:{padding:"12px 16px",display:"flex",gap:"8px",flexWrap:"wrap"},children:[s.jsx("span",{style:{color:t.colors.textMuted,fontSize:t.fontSizes[0],marginRight:"4px"},children:"Try:"}),u.map((N,K)=>s.jsxs("button",{onClick:()=>{n(N)},style:{padding:"4px 10px",backgroundColor:t.colors.backgroundSecondary,border:`1px solid ${t.colors.border}`,borderRadius:"12px",color:t.colors.textSecondary,fontSize:t.fontSizes[0],cursor:"pointer",transition:"background-color 150ms ease"},onMouseEnter:W=>{W.currentTarget.style.backgroundColor=t.colors.backgroundTertiary},onMouseLeave:W=>{W.currentTarget.style.backgroundColor=t.colors.backgroundSecondary},children:['"',N,'"']},K))]}),te&&s.jsxs("div",{style:{padding:"12px 16px",fontSize:t.fontSizes[0],color:t.colors.warning,display:"flex",alignItems:"center",gap:"8px"},children:[s.jsx("span",{children:"Agent unavailable."}),s.jsxs("span",{style:{color:t.colors.textMuted},children:["Use quick commands (start with ",s.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"/"}),")"]})]}),Y&&s.jsxs("div",{style:{padding:"12px 16px",fontSize:t.fontSizes[0],color:t.colors.textMuted,fontFamily:t.fonts.monospace},children:[s.jsx("div",{style:{marginBottom:"8px",color:t.colors.textSecondary},children:"Quick commands:"}),s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[s.jsxs("div",{children:[s.jsx("span",{style:{color:t.colors.info},children:"/toggle"})," ",s.jsx("span",{style:{color:t.colors.textMuted},children:"<left|right>"})," ","- Toggle sidebar visibility"]}),s.jsxs("div",{children:[s.jsx("span",{style:{color:t.colors.info},children:"/switch"})," ",s.jsx("span",{style:{color:t.colors.textMuted},children:"<slot> <panel>"})," ","- Switch panel content"]}),s.jsxs("div",{children:[s.jsx("span",{style:{color:t.colors.info},children:"/collapse"})," ","- Collapse all sidebars"]}),s.jsxs("div",{children:[s.jsx("span",{style:{color:t.colors.info},children:"/expand"})," ","- Expand all sidebars"]})]})]}),P&&s.jsx(ue,{matches:I,argumentMatches:A,currentArg:E,isEnteringArgs:v.isEnteringArgs,selectedIndex:k,onSelect:N=>{var W;if(v.isEnteringArgs){const Q=A[N];if(Q){let J=`/${v.commandName}`;for(const oe of v.enteredArgs)J+=` ${oe}`;J+=` ${Q.option}`;const ae=v.currentArgIndex+1;((W=v.command)==null?void 0:W.args)&&ae<v.command.args.length&&(J+=" "),n(J)}return}const K=I[N];if(K){const Q=K.command;let J=`/${Q.name}`;Q.args&&Q.args.length>0&&(J+=" "),n(J)}}})]})]}),s.jsx("style",{children:`
45
+ `,document.head.appendChild(o)},Qe=({active:o,variant:e="soft-fade",effects:t=[],opacity:r=.95,animationDuration:a=300,cascadeDelay:l=0,color:c,hideOnHover:n=!0,className:m="",style:d={}})=>{const{theme:b}=H.useTheme(),[f,h]=i.useState(!1),[v,g]=i.useState(!1),p=i.useRef(null);i.useEffect(()=>{He()},[]),i.useEffect(()=>{if(!n||!o){g(!1);return}const J=V=>{if(p.current){const R=p.current.getBoundingClientRect(),Y=V.clientX>=R.left&&V.clientX<=R.right&&V.clientY>=R.top&&V.clientY<=R.bottom;g(Y)}};return document.addEventListener("mousemove",J),()=>document.removeEventListener("mousemove",J)},[n,o]),i.useEffect(()=>{if(o){const J=setTimeout(()=>h(!0),l);return()=>clearTimeout(J)}else h(!1)},[o,l]);const u=c||b.colors.background,j=()=>{switch(e){case"soft-fade":return{backgroundColor:u,opacity:f?r:0,transition:`opacity ${a}ms ease-out`};case"cascading-fade":return{backgroundColor:u,opacity:f?r:0,transition:`opacity ${a}ms ease-out`,transitionDelay:f?"0ms":`${l}ms`};default:return{backgroundColor:u,opacity:f?r:0,transition:`opacity ${a}ms ease-out`}}},$=n&&v,L={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:999,overflow:"hidden",...j(),...$?{opacity:0}:{},...d},C=t.includes("vignette-drift"),E=t.includes("radial-breathing"),w=t.includes("snowfall"),k=(J,V)=>{const R=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(J);if(!R)return`rgba(255, 255, 255, ${V})`;const Y=parseInt(R[1],16),O=parseInt(R[2],16),K=parseInt(R[3],16);return`rgba(${Y}, ${O}, ${K}, ${V})`},x=b.colors.primary,T={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",opacity:f?1:0,transition:`opacity ${a}ms ease-out`,background:`radial-gradient(circle at 50% 50%, ${k(x,.12)} 0%, ${k(x,.06)} 25%, transparent 50%)`,backgroundSize:"150% 150%",animation:f?"focus-overlay-vignette-drift 12s ease-in-out infinite":"none"},A={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",opacity:f?1:0,transition:`opacity ${a}ms ease-out`,background:`radial-gradient(circle at center, ${k(x,.15)} 0%, ${k(x,.06)} 30%, transparent 55%)`,animation:f?"focus-overlay-radial-breathing 4s ease-in-out infinite":"none"},I=k(x,.6),S=k(x,.4),P=k(x,.25),q={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",opacity:f?1:0,transition:`opacity ${a}ms ease-out`},te={...q,background:`
46
+ radial-gradient(circle, ${I} 0%, ${I} 3px, transparent 3px),
47
+ radial-gradient(circle, ${I} 0%, ${I} 3px, transparent 3px),
48
+ radial-gradient(circle, ${I} 0%, ${I} 3px, transparent 3px),
49
+ radial-gradient(circle, ${I} 0%, ${I} 3px, transparent 3px)
50
+ `,backgroundSize:"150px 150px",backgroundPosition:"10px 20px, 60px 80px, 110px 40px, 40px 120px",animation:f?"focus-overlay-snowfall-1 4s linear infinite":"none"},N={...q,background:`
51
+ radial-gradient(circle, ${S} 0%, ${S} 2px, transparent 2px),
52
+ radial-gradient(circle, ${S} 0%, ${S} 2px, transparent 2px),
53
+ radial-gradient(circle, ${S} 0%, ${S} 2px, transparent 2px),
54
+ radial-gradient(circle, ${S} 0%, ${S} 2px, transparent 2px),
55
+ radial-gradient(circle, ${S} 0%, ${S} 2px, transparent 2px)
56
+ `,backgroundSize:"150px 150px",backgroundPosition:"30px 10px, 90px 60px, 15px 100px, 120px 30px, 70px 130px",animation:f?"focus-overlay-snowfall-2 7s linear infinite":"none"},Q={...q,background:`
57
+ radial-gradient(circle, ${P} 0%, ${P} 1.5px, transparent 1.5px),
58
+ radial-gradient(circle, ${P} 0%, ${P} 1.5px, transparent 1.5px),
59
+ radial-gradient(circle, ${P} 0%, ${P} 1.5px, transparent 1.5px),
60
+ radial-gradient(circle, ${P} 0%, ${P} 1.5px, transparent 1.5px),
61
+ radial-gradient(circle, ${P} 0%, ${P} 1.5px, transparent 1.5px),
62
+ radial-gradient(circle, ${P} 0%, ${P} 1.5px, transparent 1.5px)
63
+ `,backgroundSize:"150px 150px",backgroundPosition:"20px 5px, 80px 45px, 45px 90px, 130px 20px, 5px 70px, 100px 110px",animation:f?"focus-overlay-snowfall-3 12s linear infinite":"none"};return s.jsxs("div",{ref:p,className:`focus-mode-overlay focus-mode-overlay--${e} ${m}`,style:L,role:"presentation","aria-hidden":"true","data-active":o,"data-variant":e,children:[C&&s.jsx("div",{className:"focus-mode-overlay__vignette-drift",style:T}),E&&s.jsx("div",{className:"focus-mode-overlay__radial-breathing",style:A}),w&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"focus-mode-overlay__snowfall-layer-3",style:Q}),s.jsx("div",{className:"focus-mode-overlay__snowfall-layer-2",style:N}),s.jsx("div",{className:"focus-mode-overlay__snowfall-layer-1",style:te})]})]})},ce=({value:o,onChange:e,onSubmit:t,onClose:r,onHistoryPrevious:a,onHistoryNext:l,mode:c,status:n,placeholder:m="What would you like to do?",disabled:d=!1,autoFocus:b=!0,agentAvailable:f=!0,showAutocomplete:h=!1,onAutocompleteNext:v,onAutocompletePrevious:g,onAutocompleteAccept:p})=>{const{theme:u}=H.useTheme(),j=i.useRef(null);i.useEffect(()=>{b&&j.current&&j.current.focus()},[b]);const $=C=>{switch(C.stopPropagation(),C.key){case"Enter":C.preventDefault(),t();break;case"Escape":C.preventDefault(),r();break;case"Tab":h&&p&&(C.preventDefault(),p());break;case"ArrowUp":C.preventDefault(),h&&g?g():a();break;case"ArrowDown":C.preventDefault(),h&&v?v():l();break}},L=n==="thinking"||n==="executing";return s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:u.colors.background,borderBottom:`1px solid ${u.colors.border}`},children:[s.jsx("span",{style:{color:c==="quick-command"?u.colors.info:f?u.colors.primary:u.colors.textMuted,fontFamily:u.fonts.monospace,fontSize:u.fontSizes[1],userSelect:"none",display:"flex",alignItems:"center"},children:c==="quick-command"?s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("polyline",{points:"4 17 10 11 4 5"}),s.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]}):f?s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),s.jsx("circle",{cx:"12",cy:"5",r:"2"}),s.jsx("path",{d:"M12 7v4"}),s.jsx("line",{x1:"8",y1:"16",x2:"8",y2:"16"}),s.jsx("line",{x1:"16",y1:"16",x2:"16",y2:"16"})]}):">"}),s.jsx("input",{ref:j,"data-agent-command-palette-input":!0,type:"text",value:o,onChange:C=>e(C.target.value),onKeyDown:$,placeholder:m,disabled:d||L,style:{flex:1,backgroundColor:"transparent",border:"none",outline:"none",color:u.colors.text,fontFamily:u.fonts.monospace,fontSize:u.fontSizes[1],caretColor:u.colors.primary}}),L&&s.jsxs("span",{style:{color:u.colors.info,fontSize:u.fontSizes[0],display:"flex",alignItems:"center",gap:"4px"},children:[s.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:u.colors.info,animation:"pulse 1s ease-in-out infinite"}}),n==="thinking"?"Thinking...":"Executing..."]}),!L&&s.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:u.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${u.colors.border}`,fontSize:u.fontSizes[0],color:u.colors.textMuted},children:"Alt+P"})]})};ce.displayName="AgentCommandInput";const Je=({status:o})=>{const{theme:e}=H.useTheme(),t={display:"inline-flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",fontSize:e.fontSizes[0]};switch(o){case"pending":return s.jsx("span",{style:{...t,color:e.colors.textMuted},children:"○"});case"running":return s.jsx("span",{style:{...t,color:e.colors.info,animation:"spin 1s linear infinite"},children:"◐"});case"success":return s.jsx("span",{style:{...t,color:e.colors.success},children:"✓"});case"error":return s.jsx("span",{style:{...t,color:e.colors.error},children:"✗"})}},Ge=o=>{const e=Object.entries(o);return e.length===0?"":e.map(([t,r])=>t==="args"&&Array.isArray(r)?r.join(", "):typeof r=="string"?`"${r}"`:JSON.stringify(r)).join(", ")},Ue=({tool:o,compact:e})=>{const{theme:t}=H.useTheme(),r=Ge(o.args);return s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:e?"4px 0":"8px 0",fontFamily:t.fonts.monospace,fontSize:t.fontSizes[1]},children:[s.jsx(Je,{status:o.status}),s.jsxs("span",{style:{color:t.colors.text},children:[o.name,r&&s.jsxs("span",{style:{color:t.colors.textMuted},children:["(",r,")"]})]}),o.status==="running"&&s.jsx("span",{style:{marginLeft:"auto",color:t.colors.info,fontSize:t.fontSizes[0]},children:"[running]"}),o.status==="success"&&s.jsx("span",{style:{marginLeft:"auto",color:t.colors.success,fontSize:t.fontSizes[0]},children:"[done]"}),o.status==="error"&&s.jsx("span",{style:{marginLeft:"auto",color:t.colors.error,fontSize:t.fontSizes[0]},title:o.error,children:"[error]"})]})},de=({tools:o,compact:e=!1})=>{const{theme:t}=H.useTheme();return o.length===0?null:s.jsx("div",{style:{padding:e?"8px 16px":"12px 16px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"4px",margin:"8px 16px"},children:o.map(r=>s.jsx(Ue,{tool:r,compact:e},r.id))})};de.displayName="ToolExecutionList";const pe=({response:o,streaming:e=!1})=>{const{theme:t}=H.useTheme();if(!o)return null;const r=o.toLowerCase().startsWith("error"),a=o.toLowerCase().startsWith("done")||o.toLowerCase().startsWith("executed");return s.jsxs("div",{style:{padding:"12px 16px",color:r?t.colors.error:a?t.colors.success:t.colors.text,fontSize:t.fontSizes[1],display:"flex",alignItems:"center",gap:"8px"},children:[a&&s.jsx("span",{children:"✓"}),r&&s.jsx("span",{children:"✗"}),s.jsxs("span",{children:[o,e&&s.jsx("span",{style:{display:"inline-block",width:"2px",height:"14px",backgroundColor:t.colors.primary,marginLeft:"2px",animation:"blink 1s step-end infinite"}})]})]})};pe.displayName="AgentResponseDisplay";function je({text:o,matchedIndices:e,highlightColor:t}){if(!e.length)return s.jsx(s.Fragment,{children:o});const r=new Set(e),a=o.split("");return s.jsx(s.Fragment,{children:a.map((l,c)=>s.jsx("span",{style:{color:r.has(c)?t:"inherit",fontWeight:r.has(c)?600:"inherit"},children:l},c))})}const ue=({matches:o,argumentMatches:e=[],currentArg:t,isEnteringArgs:r=!1,selectedIndex:a,onSelect:l,maxVisible:c=6})=>{const{theme:n}=H.useTheme(),m=i.useRef(null),d=i.useRef(null);if(i.useEffect(()=>{d.current&&m.current&&d.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[a]),r&&e.length>0){const v=40*c;return s.jsxs("div",{ref:m,style:{maxHeight:`${v}px`,overflowY:"auto",borderTop:`1px solid ${n.colors.border}`},children:[t&&s.jsxs("div",{style:{padding:"8px 16px",fontSize:n.fontSizes[0],color:n.colors.textMuted,backgroundColor:n.colors.backgroundSecondary,borderBottom:`1px solid ${n.colors.border}`},children:[s.jsx("span",{style:{color:n.colors.textSecondary},children:t.name}),t.description&&s.jsxs("span",{style:{marginLeft:"8px"},children:["— ",t.description]})]}),e.map((g,p)=>{const u=p===a;return s.jsxs("div",{ref:u?d:void 0,onClick:()=>l(p),style:{display:"flex",alignItems:"center",gap:"12px",padding:"8px 16px",cursor:"pointer",backgroundColor:u?n.colors.backgroundSecondary:"transparent",borderLeft:u?`2px solid ${n.colors.primary}`:"2px solid transparent",transition:"background-color 100ms ease"},onMouseEnter:j=>{u||(j.currentTarget.style.backgroundColor=n.colors.backgroundSecondary)},onMouseLeave:j=>{u||(j.currentTarget.style.backgroundColor="transparent")},children:[s.jsx("span",{style:{fontFamily:n.fonts.monospace,fontSize:n.fontSizes[1],color:n.colors.text,flex:1},children:s.jsx(je,{text:g.option,matchedIndices:g.matchedIndices,highlightColor:n.colors.primary})}),u&&s.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:n.colors.backgroundTertiary,borderRadius:"3px",border:`1px solid ${n.colors.border}`,fontSize:n.fontSizes[0],color:n.colors.textMuted,flexShrink:0},children:"Tab"})]},`${g.option}-${p}`)})]})}if(o.length===0)return null;const f=48*c;return s.jsx("div",{ref:m,style:{maxHeight:`${f}px`,overflowY:"auto",borderTop:`1px solid ${n.colors.border}`},children:o.map((h,v)=>{const g=v===a,p=h.command;return s.jsxs("div",{ref:g?d:void 0,onClick:()=>l(v),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 16px",cursor:"pointer",backgroundColor:g?n.colors.backgroundSecondary:"transparent",borderLeft:g?`2px solid ${n.colors.primary}`:"2px solid transparent",transition:"background-color 100ms ease"},onMouseEnter:u=>{g||(u.currentTarget.style.backgroundColor=n.colors.backgroundSecondary)},onMouseLeave:u=>{g||(u.currentTarget.style.backgroundColor="transparent")},children:[s.jsx("span",{style:{color:n.colors.info,fontFamily:n.fonts.monospace,fontSize:n.fontSizes[1],flexShrink:0},children:"/"}),s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsxs("div",{style:{fontFamily:n.fonts.monospace,fontSize:n.fontSizes[1],color:n.colors.text},children:[s.jsx(je,{text:p.name,matchedIndices:h.matchedOn===p.name?h.matchedIndices:[],highlightColor:n.colors.primary}),h.matchedOn!==p.name&&s.jsxs("span",{style:{color:n.colors.textMuted,marginLeft:"8px",fontSize:n.fontSizes[0]},children:["(alias: ",h.matchedOn,")"]})]}),s.jsx("div",{style:{fontSize:n.fontSizes[0],color:n.colors.textMuted,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:p.description})]}),p.args&&p.args.length>0&&s.jsx("div",{style:{fontSize:n.fontSizes[0],color:n.colors.textMuted,fontFamily:n.fonts.monospace,flexShrink:0},children:p.args.map((u,j)=>s.jsxs("span",{children:[j>0&&" ",s.jsx("span",{style:{color:u.required?n.colors.warning:n.colors.textMuted},children:u.required?`<${u.name}>`:`[${u.name}]`})]},u.name))}),g&&s.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:n.colors.backgroundTertiary,borderRadius:"3px",border:`1px solid ${n.colors.border}`,fontSize:n.fontSizes[0],color:n.colors.textMuted,flexShrink:0},children:"Tab"})]},`${p.name}-${v}`)})})};ue.displayName="QuickCommandAutocomplete";const Ie=({palette:o,config:e})=>{const{theme:t}=H.useTheme(),r=i.useRef(null),{isOpen:a,close:l,query:c,setQuery:n,mode:m,status:d,pendingTools:b,completedTools:f,agentResponse:h,submit:v,historyPrevious:g,historyNext:p,suggestions:u,agentAvailable:j,quickCommandMatches:$,argumentOptionMatches:L,parsedQuery:C,currentArgDef:E,selectedAutocompleteIndex:w,autocompleteNext:k,autocompletePrevious:x,autocompleteAccept:T,showAutocomplete:A}=o;i.useEffect(()=>{if(!a)return;const O=_=>{r.current&&!r.current.contains(_.target)&&l()},K=setTimeout(()=>{document.addEventListener("mousedown",O)},100);return()=>{clearTimeout(K),document.removeEventListener("mousedown",O)}},[a,l]);const[I,S]=i.useState(!1),[P,q]=i.useState(!1);if(i.useEffect(()=>{if(a)q(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{S(!0)})});else{S(!1);const O=setTimeout(()=>{q(!1)},150);return()=>clearTimeout(O)}},[a]),!P)return null;const te=j?(e==null?void 0:e.placeholder)||"What would you like to do?":"Quick command mode (agent unavailable)",N=[...f,...b],Q=N.length>0,J=h&&d!=="idle",V=j&&!c&&d==="idle"&&u.length>0,R=(m==="quick-command"||!j)&&d==="idle",Y=!j&&m!=="quick-command"&&d==="idle";return s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{position:"fixed",inset:0,zIndex:999},onClick:l}),s.jsxs("div",{ref:r,className:e==null?void 0:e.className,style:{position:"fixed",bottom:0,left:0,right:0,maxHeight:"50vh",backgroundColor:t.colors.background,borderTop:`1px solid ${t.colors.border}`,boxShadow:t.shadows[2],zIndex:1e3,display:"flex",flexDirection:"column-reverse",overflow:"hidden",transform:I?"translateY(0)":"translateY(100%)",transition:"transform 150ms ease-out",...e==null?void 0:e.style},children:[s.jsxs("div",{children:[s.jsx(ce,{value:c,onChange:n,onSubmit:v,onClose:l,onHistoryPrevious:g,onHistoryNext:p,mode:m,status:d,placeholder:te,agentAvailable:j,showAutocomplete:A,onAutocompleteNext:k,onAutocompletePrevious:x,onAutocompleteAccept:T}),s.jsxs("div",{style:{padding:"8px 16px",borderTop:`1px solid ${t.colors.border}`,display:"flex",gap:"16px",fontSize:t.fontSizes[0],color:t.colors.textMuted,backgroundColor:t.colors.background},children:[s.jsxs("span",{children:[s.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"Enter"})," ","Execute"]}),s.jsxs("span",{children:[s.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"Esc"})," ","Close"]}),s.jsxs("span",{children:[s.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"↑↓"})," ","History"]}),s.jsxs("span",{style:{marginLeft:"auto"},children:[s.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"/"})," ","Quick command"]})]})]}),s.jsxs("div",{style:{overflow:"auto"},children:[Q&&s.jsx(de,{tools:N,compact:N.length>3}),J&&s.jsx(pe,{response:h,streaming:d==="thinking"}),V&&s.jsxs("div",{style:{padding:"12px 16px",display:"flex",gap:"8px",flexWrap:"wrap"},children:[s.jsx("span",{style:{color:t.colors.textMuted,fontSize:t.fontSizes[0],marginRight:"4px"},children:"Try:"}),u.map((O,K)=>s.jsxs("button",{onClick:()=>{n(O)},style:{padding:"4px 10px",backgroundColor:t.colors.backgroundSecondary,border:`1px solid ${t.colors.border}`,borderRadius:"12px",color:t.colors.textSecondary,fontSize:t.fontSizes[0],cursor:"pointer",transition:"background-color 150ms ease"},onMouseEnter:_=>{_.currentTarget.style.backgroundColor=t.colors.backgroundTertiary},onMouseLeave:_=>{_.currentTarget.style.backgroundColor=t.colors.backgroundSecondary},children:['"',O,'"']},K))]}),Y&&s.jsxs("div",{style:{padding:"12px 16px",fontSize:t.fontSizes[0],color:t.colors.warning,display:"flex",alignItems:"center",gap:"8px"},children:[s.jsx("span",{children:"Agent unavailable."}),s.jsxs("span",{style:{color:t.colors.textMuted},children:["Use quick commands (start with ",s.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"/"}),")"]})]}),R&&s.jsxs("div",{style:{padding:"12px 16px",fontSize:t.fontSizes[0],color:t.colors.textMuted,fontFamily:t.fonts.monospace},children:[s.jsx("div",{style:{marginBottom:"8px",color:t.colors.textSecondary},children:"Quick commands:"}),s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[s.jsxs("div",{children:[s.jsx("span",{style:{color:t.colors.info},children:"/toggle"})," ",s.jsx("span",{style:{color:t.colors.textMuted},children:"<left|right>"})," ","- Toggle sidebar visibility"]}),s.jsxs("div",{children:[s.jsx("span",{style:{color:t.colors.info},children:"/switch"})," ",s.jsx("span",{style:{color:t.colors.textMuted},children:"<slot> <panel>"})," ","- Switch panel content"]}),s.jsxs("div",{children:[s.jsx("span",{style:{color:t.colors.info},children:"/collapse"})," ","- Collapse all sidebars"]}),s.jsxs("div",{children:[s.jsx("span",{style:{color:t.colors.info},children:"/expand"})," ","- Expand all sidebars"]})]})]}),A&&s.jsx(ue,{matches:$,argumentMatches:L,currentArg:E,isEnteringArgs:C.isEnteringArgs,selectedIndex:w,onSelect:O=>{var _;if(C.isEnteringArgs){const G=L[O];if(G){let X=`/${C.commandName}`;for(const oe of C.enteredArgs)X+=` ${oe}`;X+=` ${G.option}`;const ae=C.currentArgIndex+1;((_=C.command)==null?void 0:_.args)&&ae<C.command.args.length&&(X+=" "),n(X)}return}const K=$[O];if(K){const G=K.command;let X=`/${G.name}`;G.args&&G.args.length>0&&(X+=" "),n(X)}}})]})]}),s.jsx("style",{children:`
64
64
  @keyframes pulse {
65
65
  0%, 100% { opacity: 1; }
66
66
  50% { opacity: 0.5; }
@@ -73,11 +73,11 @@
73
73
  0%, 100% { opacity: 1; }
74
74
  50% { opacity: 0; }
75
75
  }
76
- `})]})};Ie.displayName="AgentCommandPalette";function re(o,e){const t=o.toLowerCase(),r=e.toLowerCase();if(!t)return{score:0,matchedIndices:[]};const a=[];let i=0,l=0,n=0,g=-1;for(let d=0;d<r.length&&i<t.length;d++)r[d]===t[i]&&(a.push(d),g===d-1?(n++,l+=n*2):n=1,d===0&&(l+=10),d>0&&/[_\-\s]/.test(e[d-1])&&(l+=5),l+=1,g=d,i++);return i<t.length?null:(l-=e.length*.1,t===r&&(l+=20),r.startsWith(t)&&(l+=15),{score:l,matchedIndices:a})}function Ae(o,e,t=10){const r=o.replace(/^\//,"").trim();if(!r)return e.slice(0,t).map(i=>({command:i,score:0,matchedIndices:[],matchedOn:i.name}));const a=[];for(const i of e){const l=re(r,i.name);if(l){a.push({command:i,score:l.score,matchedIndices:l.matchedIndices,matchedOn:i.name});continue}if(i.aliases)for(const n of i.aliases){const g=re(r,n);if(g){a.push({command:i,score:g.score-2,matchedIndices:g.matchedIndices,matchedOn:n});break}}}return a.sort((i,l)=>l.score-i.score).slice(0,t)}function Ye(o,e){const r=o.replace(/^\//,"").split(/\s+/),a=r[0]||"",i=o.endsWith(" ")&&o.trim().length>0,l=e.find(g=>{var d;return g.name.toLowerCase()===a.toLowerCase()||((d=g.aliases)==null?void 0:d.some(m=>m.toLowerCase()===a.toLowerCase()))})||null;if(!l)return{commandName:a,command:null,enteredArgs:[],currentArgValue:"",currentArgIndex:-1,isEnteringArgs:!1};const n=r.slice(1);if(i)return{commandName:l.name,command:l,enteredArgs:n,currentArgValue:"",currentArgIndex:n.length,isEnteringArgs:!0};if(n.length>0){const g=n.slice(0,-1),d=n[n.length-1];return{commandName:l.name,command:l,enteredArgs:g,currentArgValue:d,currentArgIndex:g.length,isEnteringArgs:!0}}return{commandName:l.name,command:l,enteredArgs:[],currentArgValue:"",currentArgIndex:-1,isEnteringArgs:!1}}function Xe(o,e,t=10){if(!e.length)return[];if(!o)return e.slice(0,t).map(a=>({option:a,score:0,matchedIndices:[]}));const r=[];for(const a of e){const i=re(o,a);i&&r.push({option:a,score:i.score,matchedIndices:i.matchedIndices})}return r.sort((a,i)=>i.score-a.score).slice(0,t)}const Ze=["hide sidebars","show terminal","focus editor"];function et({events:o,keyboard:e={key:"p",altKey:!0},config:t={},onExecuteTool:r,initialSuggestions:a=Ze,agentAvailable:i=!0,quickCommands:l=[]}={}){const[n,g]=c.useState(!1),[d,m]=c.useState(""),[h,y]=c.useState("natural"),[S,f]=c.useState("idle"),[p,u]=c.useState([]),[C,I]=c.useState([]),[A,v]=c.useState(""),[E,k]=c.useState([]),[w,b]=c.useState(-1),j=c.useMemo(()=>a,[a]),[P,$]=c.useState(-1),T=c.useMemo(()=>h!=="quick-command"||!l.length?{commandName:"",command:null,enteredArgs:[],currentArgValue:"",currentArgIndex:-1,isEnteringArgs:!1}:Ye(d,l),[d,h,l]),D=c.useMemo(()=>h!=="quick-command"||!l.length||T.isEnteringArgs?[]:Ae(d,l),[d,h,l,T.isEnteringArgs]),F=c.useMemo(()=>{var z;if(!T.isEnteringArgs||!((z=T.command)!=null&&z.args))return[];const x=T.command.args[T.currentArgIndex];return x!=null&&x.options?Xe(T.currentArgValue,x.options):[]},[T]),U=c.useMemo(()=>{var x;return!T.isEnteringArgs||!((x=T.command)!=null&&x.args)?null:T.command.args[T.currentArgIndex]||null},[T]),q=c.useMemo(()=>h!=="quick-command"||S!=="idle"||d.length===0?!1:D.length>0||F.length>0,[h,S,d.length,D.length,F.length]),B=c.useMemo(()=>T.isEnteringArgs?F.length:D.length,[T.isEnteringArgs,F.length,D.length]);c.useEffect(()=>{$(B>0?0:-1)},[B]);const Z=c.useCallback(x=>{m(x),y(x.startsWith("/")?"quick-command":"natural")},[]),ee=c.useCallback(()=>{g(!0),i?(m(""),y("natural")):(m("/"),y("quick-command")),f("idle"),u([]),I([]),v(""),b(-1),o==null||o.emit({type:"agent-command-palette:opened",source:"agent-command-palette",timestamp:Date.now(),payload:{}})},[o,i]),Y=c.useCallback(()=>{g(!1),o==null||o.emit({type:"agent-command-palette:closed",source:"agent-command-palette",timestamp:Date.now(),payload:{}})},[o]),te=c.useCallback(()=>{n?Y():ee()},[n,ee,Y]),N=c.useCallback(()=>{m(""),y("natural"),f("idle"),u([]),I([]),v(""),b(-1)},[]),K=c.useCallback(x=>{const z={...x,status:"pending"};return u(R=>[...R,z]),z},[]),W=c.useCallback((x,z,R,G)=>{u(_=>{const M=_.find(H=>H.id===x);if(!M)return _;const O={...M,status:z,result:R,error:G};return z==="success"||z==="error"?(I(H=>[...H,O]),_.filter(H=>H.id!==x)):_.map(H=>H.id===x?O:H)})},[]),Q=c.useCallback(async x=>{const z=x.replace(/^\//,"").trim().split(/\s+/),R=z[0],G=z.slice(1);if(!R)return;f("executing");const _=`quick-${Date.now()}`;K({id:_,name:R,args:{args:G}}),W(_,"running");try{if(r){const O=await r(R,{args:G});W(_,"success",String(O))}else W(_,"success","Tool executed (no handler)");k(O=>[{query:x,timestamp:Date.now(),toolsExecuted:[R],success:!0},...O.slice(0,(t.maxHistoryEntries||50)-1)]),f("complete"),v(`Executed: ${R}`);const M=t.autoCloseDelay??1e3;M>0&&setTimeout(()=>Y(),M)}catch(M){const O=M instanceof Error?M.message:"Unknown error";W(_,"error",void 0,O),f("error"),v(`Error: ${O}`)}},[r,K,W,t.autoCloseDelay,t.maxHistoryEntries,Y]),J=c.useCallback(()=>{if(d.trim()){if(h==="quick-command"){Q(d);return}if(!i){v("Agent unavailable. Use quick commands (start with /)."),f("error");return}f("thinking"),o==null||o.emit({type:"agent-command-palette:submit",source:"agent-command-palette",timestamp:Date.now(),payload:{query:d,mode:h}}),k(x=>[{query:d,timestamp:Date.now(),toolsExecuted:[],success:!0},...x.slice(0,(t.maxHistoryEntries||50)-1)])}},[d,h,Q,o,t.maxHistoryEntries,i]),ae=c.useCallback(()=>{if(E.length===0)return;const x=w<E.length-1?w+1:w;b(x),E[x]&&(m(E[x].query),y(E[x].query.startsWith("/")?"quick-command":"natural"))},[E,w]),Se=c.useCallback(()=>{if(w<=0){b(-1),m(""),y("natural");return}const x=w-1;b(x),E[x]&&(m(E[x].query),y(E[x].query.startsWith("/")?"quick-command":"natural"))},[E,w]),oe=c.useCallback(x=>{const{key:z="p",altKey:R=!0,ctrlKey:G=!1,metaKey:_=!1,shiftKey:M=!1}=e,O=x.altKey===R&&x.ctrlKey===G&&x.metaKey===_&&x.shiftKey===M;if((R?x.code===`Key${z.toUpperCase()}`:x.key.toLowerCase()===z.toLowerCase())&&O){const X=x.target;if(!X.closest("[data-agent-command-palette-input]")&&(X.tagName==="INPUT"||X.tagName==="TEXTAREA"||X.isContentEditable))return;x.preventDefault(),te()}},[e,te]);c.useEffect(()=>(window.addEventListener("keydown",oe),()=>window.removeEventListener("keydown",oe)),[oe]);const Re=c.useCallback(()=>{q&&$(x=>x<B-1?x+1:0)},[q,B]),_e=c.useCallback(()=>{q&&$(x=>x>0?x-1:B-1)},[q,B]),Me=c.useCallback(()=>{var G;if(!q||P<0)return;if(T.isEnteringArgs){const _=F[P];if(!_)return;let M=`/${T.commandName}`;for(const X of T.enteredArgs)M+=` ${X}`;M+=` ${_.option}`;const O=T.currentArgIndex+1;((G=T.command)==null?void 0:G.args)&&O<T.command.args.length&&(M+=" "),m(M),$(-1);return}const x=D[P];if(!x)return;const z=x.command;let R=`/${z.name}`;z.args&&z.args.length>0&&(R+=" "),m(R),$(-1)},[q,P,T,F,D]);return{agentAvailable:i,isOpen:n,open:ee,close:Y,toggle:te,query:d,setQuery:Z,mode:h,status:S,setStatus:f,pendingTools:p,completedTools:C,agentResponse:A,setAgentResponse:v,submit:J,executeQuickCommand:Q,addPendingTool:K,updateToolStatus:W,history:E,historyPrevious:ae,historyNext:Se,suggestions:j,clear:N,quickCommandMatches:D,argumentOptionMatches:F,parsedQuery:T,currentArgDef:U,selectedAutocompleteIndex:P,autocompleteNext:Re,autocompletePrevious:_e,autocompleteAccept:Me,showAutocomplete:q}}const fe={name:"get_visible_panels",description:"Get the current visibility state of all panel slots (left, middle, right). Returns which panels are active in each slot and whether side panels are collapsed.",inputs:{type:"object",properties:{},required:[]},outputs:{type:"object",properties:{left:{type:"object",properties:{panelId:{type:"string",description:"The ID of the panel in the left slot"},collapsed:{type:"boolean",description:"Whether the left panel is collapsed"},size:{type:"number",description:"Width percentage of the left panel"}}},middle:{type:"object",properties:{panelId:{type:"string",description:"The ID of the panel in the middle slot"},size:{type:"number",description:"Width percentage of the middle panel"}}},right:{type:"object",properties:{panelId:{type:"string",description:"The ID of the panel in the right slot"},collapsed:{type:"boolean",description:"Whether the right panel is collapsed"},size:{type:"number",description:"Width percentage of the right panel"}}},workspaceId:{type:"string",description:"The ID of the currently active workspace layout"}}},tags:["panel","layout","visibility","state","query"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:get-visibility"}},ge={name:"get_panel_state",description:"Get the current state of a specific panel. Returns panel-specific state data if the panel supports state queries.",inputs:{type:"object",properties:{panelId:{type:"string",description:'The ID of the panel to query state from (e.g., "file-tree", "terminal")'}},required:["panelId"]},outputs:{type:"object",properties:{panelId:{type:"string",description:"The queried panel ID"},hasState:{type:"boolean",description:"Whether the panel supports state queries"},state:{type:"object",description:"The panel state (shape depends on the panel)"}}},tags:["panel","state","query"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:get-state"}},he={name:"list_panels_with_state",description:"Get a list of all panels that support state queries. Use this to discover which panels can be queried with get_panel_state.",inputs:{type:"object",properties:{},required:[]},outputs:{type:"object",properties:{panels:{type:"array",items:{type:"object",properties:{panelId:{type:"string",description:"The panel ID"},name:{type:"string",description:"The panel display name"},description:{type:"string",description:"Description of the state this panel provides"}}},description:"List of panels that support state queries"}}},tags:["panel","state","query","discovery"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:list-state-panels"}},me={name:"toggle_panel",description:"Collapse or expand a side panel to give more space to the main content area.",inputs:{type:"object",properties:{panel:{type:"string",enum:["left","right"],description:'Which panel to toggle: "left" or "right"'}},required:["panel"]},outputs:{type:"object",properties:{success:{type:"boolean"},panel:{type:"string"},action:{type:"string"}}},tags:["panel","layout","toggle","collapse","expand","sidebar"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:toggle"}},ye={name:"collapse_all_panels",description:"Collapse both left and right panels to maximize the main content area. Useful for focus mode.",inputs:{type:"object",properties:{},required:[]},outputs:{type:"object",properties:{success:{type:"boolean"},action:{type:"string"}}},tags:["panel","layout","collapse","focus","maximize"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:collapse-all"}},xe={name:"expand_all_panels",description:"Expand both left and right panels to show all content. Restores the default layout.",inputs:{type:"object",properties:{},required:[]},outputs:{type:"object",properties:{success:{type:"boolean"},action:{type:"string"}}},tags:["panel","layout","expand","restore","show"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:expand-all"}},be={name:"switch_panel",description:"Change which content is displayed in a panel slot (left, middle, or right).",inputs:{type:"object",properties:{slot:{type:"string",enum:["left","middle","right"],description:'Which slot to change: "left", "middle", or "right"'},panel:{type:"string",description:"The panel ID to display in the slot"}},required:["slot","panel"]},outputs:{type:"object",properties:{success:{type:"boolean"},slot:{type:"string"},panel:{type:"string"}}},tags:["panel","layout","switch","navigation","view"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:switch"}},ke={name:"focus_panel",description:"Set focus to a specific panel slot for keyboard navigation.",inputs:{type:"object",properties:{slot:{type:"string",enum:["left","middle","right"],description:'Which slot to focus: "left", "middle", or "right"'}},required:["slot"]},outputs:{type:"object",properties:{success:{type:"boolean"},slot:{type:"string"}}},tags:["panel","focus","navigation","keyboard"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:focus"}},we={name:"reset_layout",description:"Reset panel sizes to the default layout configuration.",inputs:{type:"object",properties:{},required:[]},outputs:{type:"object",properties:{success:{type:"boolean"},action:{type:"string"}}},tags:["panel","layout","reset","default","restore"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:reset-layout"}},Pe=[fe,ge,he,me,ye,xe,be,ke,we],tt=[fe,ge,he],ot=[me,ye,xe,be,ke,we],st={id:"panel-layouts",name:"Panel Layouts",description:"Generic panel layout and state query operations",tools:Pe};function $e(o){const e={};if(o.inputs.properties)for(const[t,r]of Object.entries(o.inputs.properties)){const a=r;e[t]={type:a.type||"string",description:a.description,...a.enum&&{enum:a.enum}}}return{name:o.name,description:o.description,parameters:{type:"object",properties:e,required:o.inputs.required||[]}}}function rt(o){return{functionDeclarations:o.map($e)}}function Ee(o){return{type:"function",function:{name:o.name,description:o.description,parameters:o.inputs}}}function nt(o){return o.map(Ee)}function ze(o){return{name:o.name,description:o.description,input_schema:o.inputs}}function at(o){return o.map(ze)}function Le(o){return{name:o.name,description:o.description,parameters:o.inputs}}function it(o){return o.map(Le)}function lt(o,e={}){const{header:t="You have access to the following tools:",includeParameters:r=!0}=e,a=o.map(i=>{let l=`- ${i.name}: ${i.description}`;if(r&&i.inputs.properties){const n=Object.entries(i.inputs.properties).map(([g,d])=>{var y;const m=d,h=(y=i.inputs.required)!=null&&y.includes(g)?" (required)":"";return` - ${g}: ${m.description||m.type}${h}`}).join(`
77
- `);n&&(l+=`
78
- ${n}`)}return l});return`${t}
76
+ `})]})};Ie.displayName="AgentCommandPalette";function re(o,e){const t=o.toLowerCase(),r=e.toLowerCase();if(!t)return{score:0,matchedIndices:[]};const a=[];let l=0,c=0,n=0,m=-1;for(let d=0;d<r.length&&l<t.length;d++)r[d]===t[l]&&(a.push(d),m===d-1?(n++,c+=n*2):n=1,d===0&&(c+=10),d>0&&/[_\-\s]/.test(e[d-1])&&(c+=5),c+=1,m=d,l++);return l<t.length?null:(c-=e.length*.1,t===r&&(c+=20),r.startsWith(t)&&(c+=15),{score:c,matchedIndices:a})}function Ae(o,e,t=10){const r=o.replace(/^\//,"").trim();if(!r)return e.slice(0,t).map(l=>({command:l,score:0,matchedIndices:[],matchedOn:l.name}));const a=[];for(const l of e){const c=re(r,l.name);if(c){a.push({command:l,score:c.score,matchedIndices:c.matchedIndices,matchedOn:l.name});continue}if(l.aliases)for(const n of l.aliases){const m=re(r,n);if(m){a.push({command:l,score:m.score-2,matchedIndices:m.matchedIndices,matchedOn:n});break}}}return a.sort((l,c)=>c.score-l.score).slice(0,t)}function Ye(o,e){const r=o.replace(/^\//,"").split(/\s+/),a=r[0]||"",l=o.endsWith(" ")&&o.trim().length>0,c=e.find(m=>{var d;return m.name.toLowerCase()===a.toLowerCase()||((d=m.aliases)==null?void 0:d.some(b=>b.toLowerCase()===a.toLowerCase()))})||null;if(!c)return{commandName:a,command:null,enteredArgs:[],currentArgValue:"",currentArgIndex:-1,isEnteringArgs:!1};const n=r.slice(1);if(l)return{commandName:c.name,command:c,enteredArgs:n,currentArgValue:"",currentArgIndex:n.length,isEnteringArgs:!0};if(n.length>0){const m=n.slice(0,-1),d=n[n.length-1];return{commandName:c.name,command:c,enteredArgs:m,currentArgValue:d,currentArgIndex:m.length,isEnteringArgs:!0}}return{commandName:c.name,command:c,enteredArgs:[],currentArgValue:"",currentArgIndex:-1,isEnteringArgs:!1}}function Xe(o,e,t=10){if(!e.length)return[];if(!o)return e.slice(0,t).map(a=>({option:a,score:0,matchedIndices:[]}));const r=[];for(const a of e){const l=re(o,a);l&&r.push({option:a,score:l.score,matchedIndices:l.matchedIndices})}return r.sort((a,l)=>l.score-a.score).slice(0,t)}const Ze=["hide sidebars","show terminal","focus editor"];function et({events:o,keyboard:e={key:"p",altKey:!0},config:t={},onExecuteTool:r,initialSuggestions:a=Ze,agentAvailable:l=!0,quickCommands:c=[]}={}){const[n,m]=i.useState(!1),[d,b]=i.useState(""),[f,h]=i.useState("natural"),[v,g]=i.useState("idle"),[p,u]=i.useState([]),[j,$]=i.useState([]),[L,C]=i.useState(""),[E,w]=i.useState([]),[k,x]=i.useState(-1),T=i.useMemo(()=>a,[a]),[A,I]=i.useState(-1),S=i.useMemo(()=>f!=="quick-command"||!c.length?{commandName:"",command:null,enteredArgs:[],currentArgValue:"",currentArgIndex:-1,isEnteringArgs:!1}:Ye(d,c),[d,f,c]),P=i.useMemo(()=>f!=="quick-command"||!c.length||S.isEnteringArgs?[]:Ae(d,c),[d,f,c,S.isEnteringArgs]),q=i.useMemo(()=>{var z;if(!S.isEnteringArgs||!((z=S.command)!=null&&z.args))return[];const y=S.command.args[S.currentArgIndex];return y!=null&&y.options?Xe(S.currentArgValue,y.options):[]},[S]),te=i.useMemo(()=>{var y;return!S.isEnteringArgs||!((y=S.command)!=null&&y.args)?null:S.command.args[S.currentArgIndex]||null},[S]),N=i.useMemo(()=>f!=="quick-command"||v!=="idle"||d.length===0?!1:P.length>0||q.length>0,[f,v,d.length,P.length,q.length]),Q=i.useMemo(()=>S.isEnteringArgs?q.length:P.length,[S.isEnteringArgs,q.length,P.length]);i.useEffect(()=>{I(Q>0?0:-1)},[Q]);const J=i.useCallback(y=>{b(y),h(y.startsWith("/")?"quick-command":"natural")},[]),V=i.useCallback(()=>{m(!0),l?(b(""),h("natural")):(b("/"),h("quick-command")),g("idle"),u([]),$([]),C(""),x(-1),o==null||o.emit({type:"agent-command-palette:opened",source:"agent-command-palette",timestamp:Date.now(),payload:{}})},[o,l]),R=i.useCallback(()=>{m(!1),o==null||o.emit({type:"agent-command-palette:closed",source:"agent-command-palette",timestamp:Date.now(),payload:{}})},[o]),Y=i.useCallback(()=>{n?R():V()},[n,V,R]),O=i.useCallback(()=>{b(""),h("natural"),g("idle"),u([]),$([]),C(""),x(-1)},[]),K=i.useCallback(y=>{const z={...y,status:"pending"};return u(M=>[...M,z]),z},[]),_=i.useCallback((y,z,M,Z)=>{u(D=>{const F=D.find(U=>U.id===y);if(!F)return D;const B={...F,status:z,result:M,error:Z};return z==="success"||z==="error"?($(U=>[...U,B]),D.filter(U=>U.id!==y)):D.map(U=>U.id===y?B:U)})},[]),G=i.useCallback(async y=>{const z=y.replace(/^\//,"").trim().split(/\s+/),M=z[0],Z=z.slice(1);if(!M)return;g("executing");const D=`quick-${Date.now()}`;K({id:D,name:M,args:{args:Z}}),_(D,"running");try{if(r){const B=await r(M,{args:Z});_(D,"success",String(B))}else _(D,"success","Tool executed (no handler)");w(B=>[{query:y,timestamp:Date.now(),toolsExecuted:[M],success:!0},...B.slice(0,(t.maxHistoryEntries||50)-1)]),g("complete"),C(`Executed: ${M}`);const F=t.autoCloseDelay??1e3;F>0&&setTimeout(()=>R(),F)}catch(F){const B=F instanceof Error?F.message:"Unknown error";_(D,"error",void 0,B),g("error"),C(`Error: ${B}`)}},[r,K,_,t.autoCloseDelay,t.maxHistoryEntries,R]),X=i.useCallback(()=>{if(d.trim()){if(f==="quick-command"){G(d);return}if(!l){C("Agent unavailable. Use quick commands (start with /)."),g("error");return}g("thinking"),o==null||o.emit({type:"agent-command-palette:submit",source:"agent-command-palette",timestamp:Date.now(),payload:{query:d,mode:f}}),w(y=>[{query:d,timestamp:Date.now(),toolsExecuted:[],success:!0},...y.slice(0,(t.maxHistoryEntries||50)-1)])}},[d,f,G,o,t.maxHistoryEntries,l]),ae=i.useCallback(()=>{if(E.length===0)return;const y=k<E.length-1?k+1:k;x(y),E[y]&&(b(E[y].query),h(E[y].query.startsWith("/")?"quick-command":"natural"))},[E,k]),Se=i.useCallback(()=>{if(k<=0){x(-1),b(""),h("natural");return}const y=k-1;x(y),E[y]&&(b(E[y].query),h(E[y].query.startsWith("/")?"quick-command":"natural"))},[E,k]),oe=i.useCallback(y=>{const{key:z="p",altKey:M=!0,ctrlKey:Z=!1,metaKey:D=!1,shiftKey:F=!1}=e,B=y.altKey===M&&y.ctrlKey===Z&&y.metaKey===D&&y.shiftKey===F;if((M?y.code===`Key${z.toUpperCase()}`:y.key.toLowerCase()===z.toLowerCase())&&B){const ee=y.target;if(!ee.closest("[data-agent-command-palette-input]")&&(ee.tagName==="INPUT"||ee.tagName==="TEXTAREA"||ee.isContentEditable))return;y.preventDefault(),Y()}},[e,Y]);i.useEffect(()=>(window.addEventListener("keydown",oe),()=>window.removeEventListener("keydown",oe)),[oe]);const We=i.useCallback(()=>{N&&I(y=>y<Q-1?y+1:0)},[N,Q]),_e=i.useCallback(()=>{N&&I(y=>y>0?y-1:Q-1)},[N,Q]),Me=i.useCallback(()=>{var Z;if(!N||A<0)return;if(S.isEnteringArgs){const D=q[A];if(!D)return;let F=`/${S.commandName}`;for(const ee of S.enteredArgs)F+=` ${ee}`;F+=` ${D.option}`;const B=S.currentArgIndex+1;((Z=S.command)==null?void 0:Z.args)&&B<S.command.args.length&&(F+=" "),b(F),I(-1);return}const y=P[A];if(!y)return;const z=y.command;let M=`/${z.name}`;z.args&&z.args.length>0&&(M+=" "),b(M),I(-1)},[N,A,S,q,P]);return{agentAvailable:l,isOpen:n,open:V,close:R,toggle:Y,query:d,setQuery:J,mode:f,status:v,setStatus:g,pendingTools:p,completedTools:j,agentResponse:L,setAgentResponse:C,submit:X,executeQuickCommand:G,addPendingTool:K,updateToolStatus:_,history:E,historyPrevious:ae,historyNext:Se,suggestions:T,clear:O,quickCommandMatches:P,argumentOptionMatches:q,parsedQuery:S,currentArgDef:te,selectedAutocompleteIndex:A,autocompleteNext:We,autocompletePrevious:_e,autocompleteAccept:Me,showAutocomplete:N}}const fe={name:"get_visible_panels",description:"Get the current visibility state of all panel slots (left, middle, right). Returns which panels are active in each slot and whether side panels are collapsed.",inputs:{type:"object",properties:{},required:[]},outputs:{type:"object",properties:{left:{type:"object",properties:{panelId:{type:"string",description:"The ID of the panel in the left slot"},collapsed:{type:"boolean",description:"Whether the left panel is collapsed"},size:{type:"number",description:"Width percentage of the left panel"}}},middle:{type:"object",properties:{panelId:{type:"string",description:"The ID of the panel in the middle slot"},size:{type:"number",description:"Width percentage of the middle panel"}}},right:{type:"object",properties:{panelId:{type:"string",description:"The ID of the panel in the right slot"},collapsed:{type:"boolean",description:"Whether the right panel is collapsed"},size:{type:"number",description:"Width percentage of the right panel"}}},workspaceId:{type:"string",description:"The ID of the currently active workspace layout"}}},tags:["panel","layout","visibility","state","query"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:get-visibility"}},ge={name:"get_panel_state",description:"Get the current state of a specific panel. Returns panel-specific state data if the panel supports state queries.",inputs:{type:"object",properties:{panelId:{type:"string",description:'The ID of the panel to query state from (e.g., "file-tree", "terminal")'}},required:["panelId"]},outputs:{type:"object",properties:{panelId:{type:"string",description:"The queried panel ID"},hasState:{type:"boolean",description:"Whether the panel supports state queries"},state:{type:"object",description:"The panel state (shape depends on the panel)"}}},tags:["panel","state","query"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:get-state"}},me={name:"list_panels_with_state",description:"Get a list of all panels that support state queries. Use this to discover which panels can be queried with get_panel_state.",inputs:{type:"object",properties:{},required:[]},outputs:{type:"object",properties:{panels:{type:"array",items:{type:"object",properties:{panelId:{type:"string",description:"The panel ID"},name:{type:"string",description:"The panel display name"},description:{type:"string",description:"Description of the state this panel provides"}}},description:"List of panels that support state queries"}}},tags:["panel","state","query","discovery"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:list-state-panels"}},he={name:"toggle_panel",description:"Collapse or expand a side panel to give more space to the main content area.",inputs:{type:"object",properties:{panel:{type:"string",enum:["left","right"],description:'Which panel to toggle: "left" or "right"'}},required:["panel"]},outputs:{type:"object",properties:{success:{type:"boolean"},panel:{type:"string"},action:{type:"string"}}},tags:["panel","layout","toggle","collapse","expand","sidebar"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:toggle"}},ye={name:"collapse_all_panels",description:"Collapse both left and right panels to maximize the main content area. Useful for focus mode.",inputs:{type:"object",properties:{},required:[]},outputs:{type:"object",properties:{success:{type:"boolean"},action:{type:"string"}}},tags:["panel","layout","collapse","focus","maximize"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:collapse-all"}},xe={name:"expand_all_panels",description:"Expand both left and right panels to show all content. Restores the default layout.",inputs:{type:"object",properties:{},required:[]},outputs:{type:"object",properties:{success:{type:"boolean"},action:{type:"string"}}},tags:["panel","layout","expand","restore","show"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:expand-all"}},be={name:"switch_panel",description:"Change which content is displayed in a panel slot (left, middle, or right).",inputs:{type:"object",properties:{slot:{type:"string",enum:["left","middle","right"],description:'Which slot to change: "left", "middle", or "right"'},panel:{type:"string",description:"The panel ID to display in the slot"}},required:["slot","panel"]},outputs:{type:"object",properties:{success:{type:"boolean"},slot:{type:"string"},panel:{type:"string"}}},tags:["panel","layout","switch","navigation","view"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:switch"}},ke={name:"focus_panel",description:"Set focus to a specific panel slot for keyboard navigation.",inputs:{type:"object",properties:{slot:{type:"string",enum:["left","middle","right"],description:'Which slot to focus: "left", "middle", or "right"'}},required:["slot"]},outputs:{type:"object",properties:{success:{type:"boolean"},slot:{type:"string"}}},tags:["panel","focus","navigation","keyboard"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:focus"}},we={name:"reset_layout",description:"Reset panel sizes to the default layout configuration.",inputs:{type:"object",properties:{},required:[]},outputs:{type:"object",properties:{success:{type:"boolean"},action:{type:"string"}}},tags:["panel","layout","reset","default","restore"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:reset-layout"}},Pe=[fe,ge,me,he,ye,xe,be,ke,we],tt=[fe,ge,me],ot=[he,ye,xe,be,ke,we],st={id:"panel-layouts",name:"Panel Layouts",description:"Generic panel layout and state query operations",tools:Pe};function $e(o){const e={};if(o.inputs.properties)for(const[t,r]of Object.entries(o.inputs.properties)){const a=r;e[t]={type:a.type||"string",description:a.description,...a.enum&&{enum:a.enum}}}return{name:o.name,description:o.description,parameters:{type:"object",properties:e,required:o.inputs.required||[]}}}function rt(o){return{functionDeclarations:o.map($e)}}function Ee(o){return{type:"function",function:{name:o.name,description:o.description,parameters:o.inputs}}}function nt(o){return o.map(Ee)}function ze(o){return{name:o.name,description:o.description,input_schema:o.inputs}}function at(o){return o.map(ze)}function Le(o){return{name:o.name,description:o.description,parameters:o.inputs}}function it(o){return o.map(Le)}function lt(o,e={}){const{header:t="You have access to the following tools:",includeParameters:r=!0}=e,a=o.map(l=>{let c=`- ${l.name}: ${l.description}`;if(r&&l.inputs.properties){const n=Object.entries(l.inputs.properties).map(([m,d])=>{var h;const b=d,f=(h=l.inputs.required)!=null&&h.includes(m)?" (required)":"";return` - ${m}: ${b.description||b.type}${f}`}).join(`
77
+ `);n&&(c+=`
78
+ ${n}`)}return c});return`${t}
79
79
 
80
80
  ${a.join(`
81
81
 
82
- `)}`}const ct=({size:o=18})=>s.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),s.jsx("path",{d:"M9 3v18"})]}),dt=({size:o=18})=>s.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),s.jsx("path",{d:"M9 3v18"}),s.jsx("path",{d:"m16 15-3-3 3-3"})]}),pt=({size:o=18})=>s.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),s.jsx("path",{d:"M15 3v18"})]}),ut=({size:o=18})=>s.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),s.jsx("path",{d:"M15 3v18"}),s.jsx("path",{d:"m8 9 3 3-3 3"})]}),ie=({isCollapsed:o,onToggle:e,side:t="left",iconSize:r=18,style:a,shortcutHint:i="Cmd/Ctrl+B",title:l,className:n})=>{const{theme:g}=V.useTheme(),d=()=>t==="right"?o?s.jsx(pt,{size:r}):s.jsx(ut,{size:r}):o?s.jsx(ct,{size:r}):s.jsx(dt,{size:r}),m=()=>`${o?"Show":"Hide"} ${t==="right"?"Right Panel":"Sidebar"}${i?` (${i})`:""}`;return s.jsx("button",{onClick:e,title:l??m(),className:n,style:{background:"transparent",border:"none",color:o?g.colors.textSecondary:g.colors.primary,cursor:"pointer",padding:"6px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s",width:"32px",height:"32px",...a},onMouseEnter:h=>{h.currentTarget.style.backgroundColor=g.colors.backgroundTertiary,h.currentTarget.style.color=g.colors.primary},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent",h.currentTarget.style.color=o?g.colors.textSecondary:g.colors.primary},children:d()})},ft=({size:o=14})=>s.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M8 3 4 7l4 4"}),s.jsx("path",{d:"M4 7h16"}),s.jsx("path",{d:"m16 21 4-4-4-4"}),s.jsx("path",{d:"M20 17H4"})]}),gt=({size:o=14})=>s.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"m16 3 4 4-4 4"}),s.jsx("path",{d:"M20 7H4"}),s.jsx("path",{d:"m8 21-4-4 4-4"}),s.jsx("path",{d:"M4 17h16"})]}),le=({onSwitch:o,variant:e="left-middle",iconSize:t=14,style:r,title:a,className:i})=>{const{theme:l}=V.useTheme(),n=()=>e==="left-middle"?"Switch left and middle panels":"Switch right and middle panels",g=e==="left-middle"?ft:gt;return s.jsx("button",{onClick:o,title:a??n(),className:i,style:{background:"transparent",border:"none",color:l.colors.textSecondary,cursor:"pointer",padding:"6px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s",width:"32px",height:"32px",...r},onMouseEnter:d=>{d.currentTarget.style.backgroundColor=l.colors.backgroundTertiary,d.currentTarget.style.color=l.colors.text},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent",d.currentTarget.style.color=l.colors.textSecondary},children:s.jsx(g,{size:t})})},ht=({size:o=14})=>s.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),s.jsx("path",{d:"M3 9h18"}),s.jsx("path",{d:"M9 21V9"})]}),We=({onConfigure:o,iconSize:e=14,style:t,title:r="Configure panel layout",className:a})=>{const{theme:i}=V.useTheme();return s.jsx("button",{onClick:o,title:r,className:a,style:{background:"transparent",border:"none",color:i.colors.textSecondary,cursor:"pointer",padding:"6px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s",width:"32px",height:"32px",...t},onMouseEnter:l=>{l.currentTarget.style.backgroundColor=i.colors.backgroundTertiary,l.currentTarget.style.color=i.colors.text},onMouseLeave:l=>{l.currentTarget.style.backgroundColor="transparent",l.currentTarget.style.color=i.colors.textSecondary},children:s.jsx(ht,{size:e})})},mt=({leftSidebarCollapsed:o=!1,onToggleLeftSidebar:e,showLeftSidebarControl:t=!1,rightSidebarCollapsed:r=!1,onToggleRightSidebar:a,showRightSidebarControl:i=!1,onSwitchLeftMiddlePanels:l,showSwitchLeftMiddle:n=!1,onSwitchRightMiddlePanels:g,showSwitchRightMiddle:d=!1,onConfigurePanels:m,showConfigureButton:h=!1,gap:y=4,style:S,className:f,iconSize:p,leftCollapseButtonProps:u,rightCollapseButtonProps:C,leftMiddleSwitchButtonProps:I,rightMiddleSwitchButtonProps:A,configureButtonProps:v})=>t&&e||n&&l||h&&m||d&&g||i&&a?s.jsxs("div",{className:f,style:{display:"flex",alignItems:"center",gap:`${y}px`,...S},children:[t&&e&&s.jsx(ie,{isCollapsed:o,onToggle:e,side:"left",iconSize:p??18,...u}),n&&l&&s.jsx(le,{onSwitch:l,variant:"left-middle",iconSize:p??14,...I}),h&&m&&s.jsx(We,{onConfigure:m,iconSize:p??14,...v}),d&&g&&s.jsx(le,{onSwitch:g,variant:"right-middle",iconSize:p??14,...A}),i&&a&&s.jsx(ie,{isCollapsed:r,onToggle:a,side:"right",iconSize:p??18,...C})]}):null;Object.defineProperty(exports,"EditableConfigurablePanelLayout",{enumerable:!0,get:()=>ne.EditableConfigurablePanelLayout});Object.defineProperty(exports,"ResponsiveConfigurablePanelLayout",{enumerable:!0,get:()=>ne.ResponsiveConfigurablePanelLayout});Object.defineProperty(exports,"mapThemeToPanelVars",{enumerable:!0,get:()=>ne.mapThemeToPanelVars});Object.defineProperty(exports,"mapThemeToTabVars",{enumerable:!0,get:()=>ne.mapThemeToTabVars});exports.AgentCommandInput=ce;exports.AgentCommandPalette=Ie;exports.AgentResponseDisplay=pe;exports.FocusIndicator=Ke;exports.FocusModeOverlay=He;exports.LocalStoragePersistenceAdapter=ve;exports.LocalStorageWorkspaceAdapter=Te;exports.PanelCollapseButton=ie;exports.PanelConfigureButton=We;exports.PanelControls=mt;exports.PanelSwitchButton=le;exports.QuickCommandAutocomplete=ue;exports.ToolExecutionList=de;exports.WorkspaceLayoutService=L;exports.collapseAllPanelsTool=ye;exports.expandAllPanelsTool=xe;exports.focusPanelTool=ke;exports.fuzzyMatch=re;exports.generateToolsSystemPrompt=lt;exports.getPanelStateTool=ge;exports.getVisiblePanelsTool=fe;exports.layoutActionTools=ot;exports.layoutTools=Pe;exports.layoutToolsMetadata=st;exports.listPanelsWithStateTool=he;exports.resetLayoutTool=we;exports.searchQuickCommands=Ae;exports.stateQueryTools=tt;exports.switchPanelTool=be;exports.togglePanelTool=me;exports.toolToAIFunction=Le;exports.toolToAnthropicFormat=ze;exports.toolToGeminiFunction=$e;exports.toolToOpenAIFunction=Ee;exports.toolsToAIFunctions=it;exports.toolsToAnthropicFormat=at;exports.toolsToGeminiFormat=rt;exports.toolsToOpenAIFormat=nt;exports.useAgentCommandPalette=et;exports.usePanelFocus=Ne;exports.usePanelFocusListener=Be;exports.usePanelKeyboardShortcuts=Ve;exports.usePanelPersistence=qe;exports.useWorkspace=Oe;
82
+ `)}`}const ct=({size:o=18})=>s.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),s.jsx("path",{d:"M9 3v18"})]}),dt=({size:o=18})=>s.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),s.jsx("path",{d:"M9 3v18"}),s.jsx("path",{d:"m16 15-3-3 3-3"})]}),pt=({size:o=18})=>s.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),s.jsx("path",{d:"M15 3v18"})]}),ut=({size:o=18})=>s.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),s.jsx("path",{d:"M15 3v18"}),s.jsx("path",{d:"m8 9 3 3-3 3"})]}),ie=({isCollapsed:o,onToggle:e,side:t="left",iconSize:r=18,style:a,shortcutHint:l="Cmd/Ctrl+B",title:c,className:n})=>{const{theme:m}=H.useTheme(),d=()=>t==="right"?o?s.jsx(pt,{size:r}):s.jsx(ut,{size:r}):o?s.jsx(ct,{size:r}):s.jsx(dt,{size:r}),b=()=>`${o?"Show":"Hide"} ${t==="right"?"Right Panel":"Sidebar"}${l?` (${l})`:""}`;return s.jsx("button",{onClick:e,title:c??b(),className:n,style:{background:"transparent",border:"none",color:o?m.colors.textSecondary:m.colors.primary,cursor:"pointer",padding:"6px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s",width:"32px",height:"32px",...a},onMouseEnter:f=>{f.currentTarget.style.backgroundColor=m.colors.backgroundTertiary,f.currentTarget.style.color=m.colors.primary},onMouseLeave:f=>{f.currentTarget.style.backgroundColor="transparent",f.currentTarget.style.color=o?m.colors.textSecondary:m.colors.primary},children:d()})},ft=({size:o=14})=>s.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M8 3 4 7l4 4"}),s.jsx("path",{d:"M4 7h16"}),s.jsx("path",{d:"m16 21 4-4-4-4"}),s.jsx("path",{d:"M20 17H4"})]}),gt=({size:o=14})=>s.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"m16 3 4 4-4 4"}),s.jsx("path",{d:"M20 7H4"}),s.jsx("path",{d:"m8 21-4-4 4-4"}),s.jsx("path",{d:"M4 17h16"})]}),le=({onSwitch:o,variant:e="left-middle",iconSize:t=14,style:r,title:a,className:l})=>{const{theme:c}=H.useTheme(),n=()=>e==="left-middle"?"Switch left and middle panels":"Switch right and middle panels",m=e==="left-middle"?ft:gt;return s.jsx("button",{onClick:o,title:a??n(),className:l,style:{background:"transparent",border:"none",color:c.colors.textSecondary,cursor:"pointer",padding:"6px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s",width:"32px",height:"32px",...r},onMouseEnter:d=>{d.currentTarget.style.backgroundColor=c.colors.backgroundTertiary,d.currentTarget.style.color=c.colors.text},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent",d.currentTarget.style.color=c.colors.textSecondary},children:s.jsx(m,{size:t})})},mt=({size:o=14})=>s.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),s.jsx("path",{d:"M3 9h18"}),s.jsx("path",{d:"M9 21V9"})]}),Re=({onConfigure:o,iconSize:e=14,style:t,title:r="Configure panel layout",className:a})=>{const{theme:l}=H.useTheme();return s.jsx("button",{onClick:o,title:r,className:a,style:{background:"transparent",border:"none",color:l.colors.textSecondary,cursor:"pointer",padding:"6px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s",width:"32px",height:"32px",...t},onMouseEnter:c=>{c.currentTarget.style.backgroundColor=l.colors.backgroundTertiary,c.currentTarget.style.color=l.colors.text},onMouseLeave:c=>{c.currentTarget.style.backgroundColor="transparent",c.currentTarget.style.color=l.colors.textSecondary},children:s.jsx(mt,{size:e})})},ht=({leftSidebarCollapsed:o=!1,onToggleLeftSidebar:e,showLeftSidebarControl:t=!1,rightSidebarCollapsed:r=!1,onToggleRightSidebar:a,showRightSidebarControl:l=!1,onSwitchLeftMiddlePanels:c,showSwitchLeftMiddle:n=!1,onSwitchRightMiddlePanels:m,showSwitchRightMiddle:d=!1,onConfigurePanels:b,showConfigureButton:f=!1,gap:h=4,style:v,className:g,iconSize:p,leftCollapseButtonProps:u,rightCollapseButtonProps:j,leftMiddleSwitchButtonProps:$,rightMiddleSwitchButtonProps:L,configureButtonProps:C})=>t&&e||n&&c||f&&b||d&&m||l&&a?s.jsxs("div",{className:g,style:{display:"flex",alignItems:"center",gap:`${h}px`,...v},children:[t&&e&&s.jsx(ie,{isCollapsed:o,onToggle:e,side:"left",iconSize:p??18,...u}),n&&c&&s.jsx(le,{onSwitch:c,variant:"left-middle",iconSize:p??14,...$}),f&&b&&s.jsx(Re,{onConfigure:b,iconSize:p??14,...C}),d&&m&&s.jsx(le,{onSwitch:m,variant:"right-middle",iconSize:p??14,...L}),l&&a&&s.jsx(ie,{isCollapsed:r,onToggle:a,side:"right",iconSize:p??18,...j})]}):null;Object.defineProperty(exports,"EditableConfigurablePanelLayout",{enumerable:!0,get:()=>ne.EditableConfigurablePanelLayout});Object.defineProperty(exports,"ResponsiveConfigurablePanelLayout",{enumerable:!0,get:()=>ne.ResponsiveConfigurablePanelLayout});Object.defineProperty(exports,"mapThemeToPanelVars",{enumerable:!0,get:()=>ne.mapThemeToPanelVars});Object.defineProperty(exports,"mapThemeToTabVars",{enumerable:!0,get:()=>ne.mapThemeToTabVars});exports.AgentCommandInput=ce;exports.AgentCommandPalette=Ie;exports.AgentResponseDisplay=pe;exports.FocusIndicator=Ke;exports.FocusModeOverlay=Qe;exports.LocalStoragePersistenceAdapter=Ce;exports.LocalStorageWorkspaceAdapter=Te;exports.PanelCollapseButton=ie;exports.PanelConfigureButton=Re;exports.PanelControls=ht;exports.PanelSwitchButton=le;exports.QuickCommandAutocomplete=ue;exports.ToolExecutionList=de;exports.WorkspaceLayoutService=W;exports.collapseAllPanelsTool=ye;exports.expandAllPanelsTool=xe;exports.focusPanelTool=ke;exports.fuzzyMatch=re;exports.generateToolsSystemPrompt=lt;exports.getPanelStateTool=ge;exports.getVisiblePanelsTool=fe;exports.layoutActionTools=ot;exports.layoutTools=Pe;exports.layoutToolsMetadata=st;exports.listPanelsWithStateTool=me;exports.resetLayoutTool=we;exports.searchQuickCommands=Ae;exports.stateQueryTools=tt;exports.switchPanelTool=be;exports.togglePanelTool=he;exports.toolToAIFunction=Le;exports.toolToAnthropicFormat=ze;exports.toolToGeminiFunction=$e;exports.toolToOpenAIFunction=Ee;exports.toolsToAIFunctions=it;exports.toolsToAnthropicFormat=at;exports.toolsToGeminiFormat=rt;exports.toolsToOpenAIFormat=nt;exports.useAgentCommandPalette=et;exports.usePanelFocus=Ne;exports.usePanelFocusListener=Be;exports.usePanelKeyboardShortcuts=Ve;exports.usePanelPersistence=qe;exports.useWorkspace=Oe;
83
83
  //# sourceMappingURL=index.js.map