@principal-ade/panel-layouts 0.2.4 → 0.2.6

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,8 +1,21 @@
1
- "use strict";require('./index.css');var de=Object.defineProperty;var ue=(t,e,o)=>e in t?de(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var A=(t,e,o)=>ue(t,typeof e!="symbol"?e+"":e,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("@principal-ade/panels"),l=require("react"),c=require("react/jsx-runtime"),W=require("@principal-ade/industry-theme");class q{constructor(){A(this,"storageKey","panel-layouts")}async load(e){try{const o=localStorage.getItem(`${this.storageKey}:${e}`);return o?JSON.parse(o):null}catch(o){return console.error(`Failed to load panel layout for ${e}:`,o),null}}async save(e,o){try{localStorage.setItem(`${this.storageKey}:${e}`,JSON.stringify(o))}catch(a){console.error(`Failed to save panel layout for ${e}:`,a)}}}function pe(t){const{viewKey:e,defaultSizes:o,panelType:a,adapter:s=new q}=t,[n,r]=l.useState(o),[i,p]=l.useState(t.collapsed),f=l.useRef(t.collapsed),x=l.useRef({}),u=l.useRef(null),y=l.useRef(null);l.useEffect(()=>{(async()=>{const v=await s.load(e);v!=null&&v.sizes&&(r(v.sizes),h(v.sizes))})()},[e]);const h=l.useCallback(k=>{"left"in k&&k.left>0&&(x.current.left=k.left),"middle"in k&&k.middle>0&&(x.current.middle=k.middle),"right"in k&&k.right>0&&(x.current.right=k.right)},[]),m=l.useCallback(k=>{const v=x.current[k];if(v&&v>0)return v;if(k==="left"&&"left"in o&&o.left>0)return o.left;if(k==="right"&&"right"in o&&o.right>0)return o.right},[o]),d=l.useRef(o);l.useEffect(()=>{("left"in o&&o.left!==d.current.left||"middle"in o&&"middle"in d.current&&o.middle!==d.current.middle||"right"in o&&o.right!==d.current.right)&&(r(o),h(o),d.current=o)},[o,h]),l.useEffect(()=>{const k=t.collapsed.left!==f.current.left,v="right"in t.collapsed&&"right"in f.current&&t.collapsed.right!==f.current.right;(k||v)&&(p(t.collapsed),f.current={...t.collapsed})},[t.collapsed.left,t.collapsed.right]);const b=l.useCallback(async k=>{try{await s.save(e,{sizes:k})}catch(v){console.error(`Failed to save panel preferences for ${e}:`,v)}},[e,s]),S=l.useCallback(k=>{const v={...k};let C=!0;if("left"in k){const w=!!(i!=null&&i.left),g=k.left;if(w){const T=m("left");T!==void 0&&T>0?v.left=T:C=!1}else g===0&&(C=!1)}if(a==="three-panel"&&"right"in k){const w=!!(i!=null&&i.right),g=k.right;if(w){const T=m("right");T!==void 0&&T>0?v.right=T:C=!1}else g===0&&(C=!1)}if(r(v),h(v),u.current&&(clearTimeout(u.current),u.current=null),!C){y.current=null;return}y.current=v,u.current=setTimeout(()=>{const w=y.current;w&&(b(w),y.current=null),u.current=null},500)},[i,m,a,b,h]);l.useEffect(()=>()=>{if(u.current){const k=y.current;k&&(b(k),y.current=null),clearTimeout(u.current),u.current=null}},[b]);const j=l.useCallback(async()=>{},[]),R=l.useCallback(async()=>{},[]),L=l.useCallback(async()=>{},[]),E=l.useCallback(async()=>{},[]);return a==="three-panel"?{type:"three-panel",sizes:n,collapsed:i,handlePanelResize:S,handleLeftCollapseComplete:j,handleLeftExpandComplete:R,handleRightCollapseComplete:L,handleRightExpandComplete:E}:{type:"two-panel",sizes:n,collapsed:i,handlePanelResize:S,handleLeftCollapseComplete:j,handleLeftExpandComplete:R}}class B{constructor(){A(this,"PRESETS_KEY","panel-layouts:workspace-presets");A(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(o){throw console.error("Failed to save workspace presets:",o),o}}async loadRepositoryState(e){try{const o=`${this.REPO_STATE_PREFIX}${e}`,a=localStorage.getItem(o);return a?JSON.parse(a):null}catch(o){return console.error(`Failed to load repository state for ${e}:`,o),null}}async saveRepositoryState(e,o){try{const a=`${this.REPO_STATE_PREFIX}${e}`;localStorage.setItem(a,JSON.stringify(o))}catch(a){throw console.error(`Failed to save repository state for ${e}:`,a),a}}async loadAllRepositoryStates(){try{const e={};for(let o=0;o<localStorage.length;o++){const a=localStorage.key(o);if(a&&a.startsWith(this.REPO_STATE_PREFIX)){const s=a.substring(this.REPO_STATE_PREFIX.length),n=localStorage.getItem(a);if(n)try{e[s]=JSON.parse(n)}catch(r){console.error(`Failed to parse repository state for ${s}:`,r)}}}return e}catch(e){return console.error("Failed to load all repository states:",e),{}}}}class P{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 o=await this.adapter.loadWorkspacePresets(),a=this.generateWorkspaceId(e.name),s={id:a,name:e.name,description:e.description,layout:e.layout,defaultSizes:e.defaultSizes,defaultCollapsed:e.defaultCollapsed,createdAt:Date.now(),updatedAt:Date.now(),isBuiltIn:!1},n={...o,[a]:s};return await this.adapter.saveWorkspacePresets(n),s}static async updateWorkspaceLayout(e,o){const a=await this.adapter.loadWorkspacePresets(),s=a[e];if(!s)return console.error(`Workspace layout ${e} not found`),null;if(s.isBuiltIn)return console.error(`Cannot update built-in workspace layout ${e}`),null;const n={...s,...o,id:e,createdAt:s.createdAt,updatedAt:Date.now()},r={...a,[e]:n};return await this.adapter.saveWorkspacePresets(r),n}static async deleteWorkspaceLayout(e){const o=await this.adapter.loadWorkspacePresets(),a=o[e];if(!a)return console.error(`Workspace layout ${e} not found`),!1;if(a.isBuiltIn)return console.error(`Cannot delete built-in workspace layout ${e}`),!1;const s={...o};return delete s[e],await this.adapter.saveWorkspacePresets(s),!0}static async getRepositoryState(e){return await this.adapter.loadRepositoryState(e)}static async setRepositoryState(e,o){await this.adapter.saveRepositoryState(e,o)}static async updateRepositorySizes(e,o){const a=await this.getRepositoryState(e);a&&await this.setRepositoryState(e,{...a,sizes:o})}static async updateRepositoryCollapsed(e,o){const a=await this.getRepositoryState(e);a&&await this.setRepositoryState(e,{...a,collapsed:o})}static hasStateDeviation(e,o){const a=o.defaultSizes?JSON.stringify(e.sizes)!==JSON.stringify(o.defaultSizes):!1,s=o.defaultCollapsed?JSON.stringify(e.collapsed)!==JSON.stringify(o.defaultCollapsed):!1;return{hasSizeDeviation:a,hasCollapsedDeviation:s}}static async updateWorkspaceFromRepositoryState(e,o){const a=await this.getWorkspaceLayout(e),s=await this.getRepositoryState(o);if(!a||!s||a.isBuiltIn){console.error("Cannot update built-in workspace or workspace/state not found");return}await this.updateWorkspaceLayout(e,{defaultSizes:s.sizes,defaultCollapsed:s.collapsed})}static async resetRepositoryToWorkspaceDefaults(e,o){const a=await this.getWorkspaceLayout(o);if(!a){console.error(`Workspace ${o} not found`);return}const s=await this.getRepositoryState(e);s&&await this.setRepositoryState(e,{...s,sizes:a.defaultSizes||{left:20,middle:45,right:35},collapsed:a.defaultCollapsed||{left:!1,right:!1}})}static isLayoutMatchingWorkspace(e,o){return this.areLayoutsEqual(e,o.layout)}static async findMatchingWorkspace(e){const o=await this.getWorkspaceLayouts();for(const[a,s]of Object.entries(o))if(this.isLayoutMatchingWorkspace(e,s))return a;return null}static areLayoutsEqual(e,o){return JSON.stringify(e)===JSON.stringify(o)}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}}A(P,"adapter",new B);function fe(t={}){const{repositoryKey:e,autoInitialize:o=!1,defaultWorkspaceId:a}=t,[s,n]=l.useState({}),[r,i]=l.useState(null),[p,f]=l.useState(null),[x,u]=l.useState(!0),[y,h]=l.useState(null),m=l.useCallback(async()=>{try{u(!0),h(null);const C=await P.getWorkspaceLayouts();if(n(C),e){let w=await P.getRepositoryState(e);if(!w&&o){const g=a||"project-management",T=await P.getWorkspaceLayout(g);T&&(w={workspaceId:g,sizes:T.defaultSizes||{left:20,middle:45,right:35},collapsed:T.defaultCollapsed||{left:!1,right:!1}},await P.setRepositoryState(e,w))}if(i(w),w!=null&&w.workspaceId){const g=await P.getWorkspaceLayout(w.workspaceId);f(g)}else f(null)}}catch(C){h(C),console.error("Failed to load workspace data:",C)}finally{u(!1)}},[e,o,a]);l.useEffect(()=>{m()},[m]);const d=l.useCallback(async C=>await P.getWorkspaceLayout(C),[]),b=l.useCallback(async C=>{const w=await P.createWorkspaceLayout(C);return await m(),w},[m]),S=l.useCallback(async(C,w)=>{const g=await P.updateWorkspaceLayout(C,w);return await m(),g},[m]),j=l.useCallback(async C=>{const w=await P.deleteWorkspaceLayout(C);return w&&await m(),w},[m]),R=l.useCallback(async C=>{if(!e){console.error("Cannot apply workspace without repositoryKey");return}const w=await P.getWorkspaceLayout(C);if(!w){console.error(`Workspace ${C} not found`);return}const g={workspaceId:C,sizes:w.defaultSizes||{left:20,middle:45,right:35},collapsed:w.defaultCollapsed||{left:!1,right:!1}};await P.setRepositoryState(e,g),await m()},[e,m]),L=l.useCallback(async C=>{if(!e){console.error("Cannot update sizes without repositoryKey");return}await P.updateRepositorySizes(e,C),await m()},[e,m]),E=l.useCallback(async C=>{if(!e){console.error("Cannot update collapsed without repositoryKey");return}await P.updateRepositoryCollapsed(e,C),await m()},[e,m]),k=l.useCallback(async()=>{if(!e||!(r!=null&&r.workspaceId)){console.error("Cannot reset without repositoryKey and active workspace");return}await P.resetRepositoryToWorkspaceDefaults(e,r.workspaceId),await m()},[e,r==null?void 0:r.workspaceId,m]),v=l.useCallback(async()=>{await m()},[m]);return{workspaces:s,repositoryState:r,activeWorkspace:p,loading:x,error:y,getWorkspace:d,createWorkspace:b,updateWorkspace:S,deleteWorkspace:j,applyWorkspace:R,updateSizes:L,updateCollapsed:E,resetToDefaults:k,refresh:v}}function me(t={}){const{initialFocus:e=null,collapsed:o={},panelType:a="three-panel",onFocusChange:s,events:n,getPanelId:r}=t,[i,p]=l.useState(e),f=l.useCallback(d=>{const b=i;if(p(d),s==null||s(d),n&&r){if(b){const j=r(b);j&&n.emit({type:"panel:blur",source:"panel-layouts",timestamp:Date.now(),payload:{panelId:j,panelSlot:b,nextPanelId:r(d)}})}const S=r(d);S&&n.emit({type:"panel:focus",source:"panel-layouts",timestamp:Date.now(),payload:{panelId:S,panelSlot:d,source:"keyboard-shortcut"}})}},[i,s,n,r]),x=l.useCallback(()=>{const d=i;if(p(null),s==null||s(null),n&&r&&d){const b=r(d);b&&n.emit({type:"panel:blur",source:"panel-layouts",timestamp:Date.now(),payload:{panelId:b,panelSlot:d}})}},[i,s,n,r]),u=l.useCallback(()=>{const d=[];return o.left||d.push("left"),d.push("middle"),a==="three-panel"&&!o.right&&d.push("right"),d},[o,a]),y=l.useCallback(()=>{const d=u();if(d.length===0)return;if(i===null){f(d[0]);return}const b=d.indexOf(i);if(b===-1){f(d[0]);return}const S=(b+1)%d.length;f(d[S])},[i,u,f]),h=l.useCallback(()=>{const d=u();if(d.length===0)return;if(i===null){f(d[d.length-1]);return}const b=d.indexOf(i);if(b===-1){f(d[d.length-1]);return}const S=b===0?d.length-1:b-1;f(d[S])},[i,u,f]),m=l.useCallback(d=>i===d,[i]);return{focusedPanel:i,setFocus:f,clearFocus:x,focusNext:y,focusPrevious:h,isFocused:m}}function ye(t){const{enabled:e=!0,focusedPanel:o,collapsed:a,panelType:s,setFocus:n,onExpand:r,onCollapse:i}=t,p=l.useRef(o),f=l.useRef(a),x=l.useRef(s);l.useEffect(()=>{p.current=o},[o]),l.useEffect(()=>{f.current=a},[a]),l.useEffect(()=>{x.current=s},[s]);const u=l.useCallback(y=>{if(!y.altKey||y.ctrlKey||y.metaKey||y.shiftKey)return;const h=y.code,m=p.current,d=f.current,b=x.current;h==="Digit1"||h==="Numpad1"?(y.preventDefault(),d.left?r("left"):m!=="left"?n("left"):(i("left"),n("middle"))):h==="Digit2"||h==="Numpad2"?(y.preventDefault(),n("middle")):(h==="Digit3"||h==="Numpad3")&&b==="three-panel"&&(y.preventDefault(),d.right?r("right"):m!=="right"?n("right"):(i("right"),n("middle")))},[n,r,i]);l.useEffect(()=>{if(e)return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u)}},[e,u])}function he(t,e,o,a){l.useEffect(()=>{const s=e.on("panel:focus",r=>{r.payload.panelId===t&&o()});let n;return a&&(n=e.on("panel:blur",r=>{r.payload.panelId===t&&a()})),()=>{s(),n==null||n()}},[t,e,o,a])}const ge=({isFocused:t,className:e="",style:o={}})=>{if(!t)return null;const a={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",...o};return c.jsx("div",{className:`panel-focus-indicator ${e}`,style:a,role:"presentation","aria-hidden":"true"})},K=({value:t,onChange:e,placeholder:o="> Type a command...",onClose:a,onEnter:s})=>{const{theme:n}=W.useTheme(),r=l.useRef(null);l.useEffect(()=>{r.current&&r.current.focus()},[]);const i=p=>{switch(p.key){case"Enter":p.preventDefault(),s==null||s();break;case"Escape":p.preventDefault(),a();break}};return c.jsx("div",{style:{padding:"0",borderBottom:`1px solid ${n.colors.border}`,backgroundColor:n.colors.background},children:c.jsx("input",{ref:r,type:"text",value:t,onChange:p=>e(p.target.value),onKeyDown:i,placeholder:o,style:{width:"100%",padding:"16px 20px",fontSize:"16px",fontFamily:n.fonts.monospace,backgroundColor:"transparent",border:"none",outline:"none",color:n.colors.text,caretColor:n.colors.primary},autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1})})},O=l.forwardRef(({command:t,isSelected:e,onClick:o,onMouseEnter:a},s)=>{const{theme:n}=W.useTheme(),{label:r,description:i,icon:p,shortcut:f}=t,[x,u]=l.useState(!1);return c.jsxs("div",{ref:s,onClick:o,onMouseEnter:()=>{u(!0),a()},onMouseLeave:()=>u(!1),style:{padding:"10px 16px",cursor:"pointer",backgroundColor:e||x?n.colors.backgroundSecondary:"transparent",borderLeft:e||x?`3px solid ${n.colors.primary}`:"3px solid transparent",transition:"all 0.1s ease",display:"flex",alignItems:"center",gap:"12px"},onMouseDown:y=>{y.preventDefault()},children:[p&&c.jsx("div",{style:{flexShrink:0,width:"20px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"16px",color:e||x?n.colors.primary:n.colors.textSecondary},children:p}),c.jsxs("div",{style:{flex:1,minWidth:0},children:[c.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:e||x?n.colors.text:n.colors.textSecondary,marginBottom:i?"2px":0},children:r}),i&&c.jsx("div",{style:{fontSize:"12px",color:n.colors.textMuted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i})]}),f&&c.jsx("div",{style:{flexShrink:0,fontSize:"11px",color:n.colors.textMuted,padding:"2px 8px",backgroundColor:n.colors.background,border:`1px solid ${n.colors.border}`,borderRadius:"4px",fontFamily:n.fonts.monospace},children:f})]})});O.displayName="CommandItem";const V=({commands:t,selectedIndex:e,onSelect:o,onHover:a,maxResults:s=10})=>{const{theme:n}=W.useTheme(),r=l.useRef(null),i=l.useRef(null),p=t.slice(0,s);l.useEffect(()=>{if(i.current&&r.current){const u=i.current,y=r.current,h=u.offsetTop,m=h+u.offsetHeight,d=y.scrollTop,b=y.clientHeight;h<d?y.scrollTop=h-8:m>d+b&&(y.scrollTop=m-b+8)}},[e]);const f=p.reduce((u,y,h)=>{const m=y.category||"Other";return u[m]||(u[m]=[]),u[m].push({command:y,index:h}),u},{}),x=Object.keys(f).sort((u,y)=>u==="Other"?1:y==="Other"?-1:u.localeCompare(y));return c.jsxs("div",{ref:r,style:{overflowY:"auto",maxHeight:"400px",padding:"8px 0"},children:[x.map(u=>c.jsxs("div",{children:[x.length>1&&c.jsx("div",{style:{padding:"8px 16px 4px",fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:n.colors.textMuted,letterSpacing:"0.5px"},children:u}),f[u].map(({command:y,index:h})=>c.jsx(O,{command:y,isSelected:h===e,onClick:()=>o(y),onMouseEnter:()=>a(h),ref:h===e?i:void 0},y.id))]},u)),t.length>s&&c.jsxs("div",{style:{padding:"8px 16px",fontSize:"12px",color:n.colors.textMuted,textAlign:"center",borderTop:`1px solid ${n.colors.border}`},children:["Showing ",s," of ",t.length," results"]})]})},xe=({commandPalette:t,config:e})=>{const{theme:o}=W.useTheme(),a=l.useRef(null),{isOpen:s,close:n,query:r,setQuery:i,filteredCommands:p,selectedIndex:f,setSelectedIndex:x,executeSelected:u}=t;if(l.useEffect(()=>{if(!s)return;const m=b=>{a.current&&!a.current.contains(b.target)&&n()},d=setTimeout(()=>{document.addEventListener("mousedown",m)},100);return()=>{clearTimeout(d),document.removeEventListener("mousedown",m)}},[s,n]),!s)return null;const y=(e==null?void 0:e.maxHeight)||"50vh",h=(e==null?void 0:e.placeholder)||"> Type a command...";return c.jsxs(c.Fragment,{children:[c.jsx("div",{style:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(2px)",zIndex:999},onClick:n}),c.jsxs("div",{ref:a,className:e==null?void 0:e.className,style:{position:"fixed",bottom:0,left:0,right:0,maxHeight:y,backgroundColor:o.colors.surface,borderTop:`1px solid ${o.colors.border}`,boxShadow:o.shadows[2],zIndex:1e3,display:"flex",flexDirection:"column-reverse",...e==null?void 0:e.style},children:[c.jsxs("div",{children:[c.jsx(K,{value:r,onChange:i,placeholder:h,onClose:n,onEnter:u}),c.jsxs("div",{style:{padding:"8px 16px",borderTop:`1px solid ${o.colors.border}`,display:"flex",gap:"16px",fontSize:"12px",color:o.colors.textMuted,backgroundColor:o.colors.background},children:[c.jsxs("span",{children:[c.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:o.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${o.colors.border}`},children:"Enter"})," Execute"]}),c.jsxs("span",{children:[c.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:o.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${o.colors.border}`},children:"Esc"})," Close"]})]})]}),p.length>0&&c.jsx(V,{commands:p,selectedIndex:f,onSelect:m=>{t.executeCommand(m.id)},onHover:x,maxResults:e==null?void 0:e.maxResults}),r&&p.length===0&&c.jsxs("div",{style:{padding:"24px 16px",color:o.colors.textMuted,textAlign:"center",fontSize:"14px"},children:['No commands found for "',r,'"']})]})]})};class M{constructor(){A(this,"commands",new Map);A(this,"listeners",new Set)}registerCommands(e){e.forEach(o=>{this.commands.set(o.id,o)}),this.notifyListeners()}registerCommand(e){this.commands.set(e.id,e),this.notifyListeners()}unregisterCommands(e){e.forEach(o=>{this.commands.delete(o)}),this.notifyListeners()}unregisterCommand(e){this.commands.delete(e),this.notifyListeners()}getCommands(e){const o=Array.from(this.commands.values());return e?o.filter(a=>a.isAvailable?a.isAvailable(e):!0):o}getCommand(e){return this.commands.get(e)}async executeCommand(e,o){var s,n;const a=this.commands.get(e);if(!a){console.warn(`Command not found: ${e}`);return}if(a.isAvailable&&!a.isAvailable(o)){console.warn(`Command not available: ${e}`);return}try{await a.execute(o),(s=o.events)==null||s.emit({type:"command:executed",source:"command-palette",timestamp:Date.now(),payload:{commandId:a.id,commandLabel:a.label}})}catch(r){console.error(`Error executing command ${e}:`,r),(n=o.events)==null||n.emit({type:"command:error",source:"command-palette",timestamp:Date.now(),payload:{commandId:a.id,error:r instanceof Error?r.message:String(r)}})}}searchCommands(e,o){const a=this.getCommands(o);if(!e.trim())return this.sortCommands(a);const s=e.toLowerCase();return a.map(r=>{var p,f;let i=0;return r.label.toLowerCase()===s?i+=1e3:r.label.toLowerCase().startsWith(s)?i+=500:r.label.toLowerCase().includes(s)&&(i+=250),(p=r.description)!=null&&p.toLowerCase().includes(s)&&(i+=100),r.keywords&&r.keywords.some(u=>u.toLowerCase().includes(s))&&(i+=150),(f=r.category)!=null&&f.toLowerCase().includes(s)&&(i+=50),i>0&&r.priority&&(i+=r.priority),{command:r,score:i}}).filter(r=>r.score>0).sort((r,i)=>i.score-r.score).map(r=>r.command)}sortCommands(e){return e.sort((o,a)=>{const s=(a.priority||0)-(o.priority||0);if(s!==0)return s;const n=o.category||"",r=a.category||"",i=n.localeCompare(r);return i!==0?i:o.label.localeCompare(a.label)})}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}clear(){this.commands.clear(),this.notifyListeners()}get size(){return this.commands.size}notifyListeners(){this.listeners.forEach(e=>e())}}let z=null;function be(){return z||(z=new M),z}function ke(){z=null}function we({context:t,commands:e=[],keyboard:o={key:" ",altKey:!0},config:a={},registry:s}){const[n,r]=l.useState(!1),[i,p]=l.useState(""),[f,x]=l.useState(0),[u,y]=l.useState([]),h=l.useMemo(()=>s||new M,[s]),m=l.useMemo(()=>({...t,closeCommandPalette:()=>r(!1)}),[t]);l.useEffect(()=>{let g=!0;const T=h.subscribe(()=>{if(g){const I=h.getCommands(m);y(I)}});if(e.length>0)h.registerCommands(e);else{const I=h.getCommands(m);y(I)}return()=>{g=!1,T()}},[h]);const d=l.useMemo(()=>(a.fuzzySearch===!1,h.searchCommands(i,m)),[i,h,m,a.fuzzySearch]);l.useEffect(()=>{x(0)},[d]);const b=l.useCallback(()=>{var g;r(!0),p(""),x(0),(g=t.events)==null||g.emit({type:"command-palette:opened",source:"command-palette",timestamp:Date.now(),payload:{}})},[t.events]),S=l.useCallback(()=>{var g;r(!1),p(""),x(0),(g=t.events)==null||g.emit({type:"command-palette:closed",source:"command-palette",timestamp:Date.now(),payload:{}})},[t.events]),j=l.useCallback(()=>{n?S():b()},[n,b,S]),R=l.useCallback(async g=>{await h.executeCommand(g,m),S()},[h,m,S]),L=l.useCallback(()=>{x(g=>{const T=a.maxResults||d.length,I=Math.min(d.length,T)-1;return g<I?g+1:0})},[d.length,a.maxResults]),E=l.useCallback(()=>{x(g=>{const T=a.maxResults||d.length,I=Math.min(d.length,T)-1;return g>0?g-1:I})},[d.length,a.maxResults]),k=l.useCallback(async()=>{const g=d[0];g&&await R(g.id)},[d,R]),v=l.useCallback(g=>{h.registerCommands(g)},[h]),C=l.useCallback(g=>{h.unregisterCommands(g)},[h]),w=l.useCallback(g=>{const{key:T=" ",altKey:I=!0,ctrlKey:ne=!1,metaKey:le=!1,shiftKey:ie=!1}=o,ce=g.altKey===I&&g.ctrlKey===ne&&g.metaKey===le&&g.shiftKey===ie;if((T===" "?g.code==="Space":g.key===T)&&ce){const _=g.target;if(_.tagName==="INPUT"||_.tagName==="TEXTAREA"||_.isContentEditable)return;g.preventDefault(),j()}},[o,j]);return l.useEffect(()=>(window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)),[w]),{isOpen:n,open:b,close:S,toggle:j,query:i,setQuery:p,filteredCommands:d,executeCommand:R,selectedIndex:f,setSelectedIndex:x,selectNext:L,selectPrevious:E,executeSelected:k,commands:u,registerCommands:v,unregisterCommands:C}}const J=[{id:"panel.focus.left",label:"Focus Left Panel",description:"Set focus to the left panel",icon:"◀",category:"Panel Navigation",shortcut:"Alt+1",priority:100,keywords:["left","sidebar","focus","switch"],execute:t=>{t.setFocus("left")},isAvailable:t=>t.focusedPanel!=="left"},{id:"panel.focus.middle",label:"Focus Middle Panel",description:"Set focus to the middle panel",icon:"▣",category:"Panel Navigation",shortcut:"Alt+2",priority:100,keywords:["middle","center","main","focus","switch"],execute:t=>{t.setFocus("middle")},isAvailable:t=>t.focusedPanel!=="middle"},{id:"panel.focus.right",label:"Focus Right Panel",description:"Set focus to the right panel",icon:"▶",category:"Panel Navigation",shortcut:"Alt+3",priority:100,keywords:["right","sidebar","focus","switch"],execute:t=>{t.setFocus("right")},isAvailable:t=>t.focusedPanel!=="right"},{id:"panel.toggle.left",label:"Toggle Left Panel",description:"Expand or collapse the left panel",icon:"◀◀",category:"Panel Control",keywords:["toggle","left","collapse","expand","hide","show"],priority:80,execute:t=>{var e;(e=t.events)==null||e.emit({type:"panel:toggle",source:"command-palette",timestamp:Date.now(),payload:{panelId:"left"}})}},{id:"panel.toggle.right",label:"Toggle Right Panel",description:"Expand or collapse the right panel",icon:"▶▶",category:"Panel Control",keywords:["toggle","right","collapse","expand","hide","show"],priority:80,execute:t=>{var e;(e=t.events)==null||e.emit({type:"panel:toggle",source:"command-palette",timestamp:Date.now(),payload:{panelId:"right"}})}},{id:"panel.collapse.all",label:"Collapse All Panels",description:"Collapse all side panels to maximize middle panel",icon:"⬌",category:"Panel Control",keywords:["collapse","hide","all","maximize","focus mode"],priority:70,execute:t=>{var e;(e=t.events)==null||e.emit({type:"panel:collapse-all",source:"command-palette",timestamp:Date.now(),payload:{}})}},{id:"panel.expand.all",label:"Expand All Panels",description:"Expand all side panels to default layout",icon:"⬍",category:"Panel Control",keywords:["expand","show","all","restore","default"],priority:70,execute:t=>{var e;(e=t.events)==null||e.emit({type:"panel:expand-all",source:"command-palette",timestamp:Date.now(),payload:{}})}},{id:"panel.refresh",label:"Refresh Panel Data",description:"Reload data for the currently focused panel",icon:"↻",category:"Panel Control",keywords:["refresh","reload","update","sync"],priority:60,execute:t=>{var o;const e=t.focusedPanel;e&&((o=t.events)==null||o.emit({type:"panel:refresh",source:"command-palette",timestamp:Date.now(),payload:{panelId:e}}))},isAvailable:t=>t.focusedPanel!==null},{id:"panel.reset.layout",label:"Reset Panel Layout",description:"Reset panel sizes to default layout",icon:"⟲",category:"Panel Control",keywords:["reset","layout","default","restore"],priority:50,execute:t=>{var e;(e=t.events)==null||e.emit({type:"panel:reset-layout",source:"command-palette",timestamp:Date.now(),payload:{}})}}];function Ce(){return J}const H={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"}},G={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"}},X={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"}},Y={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"}},Q={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"}},U={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"}},Z=[H,G,X,Y,Q,U],ve={id:"panel-layouts",name:"Panel Layouts",description:"Generic panel layout operations",tools:Z};function ee(t,e,o={}){const{categoryPrefix:a="Panel Tools",basePriority:s=50,includePanelInCategory:n=!0}=o,r=n?`${a} > ${t.panelId}`:a,i=Pe(t.inputs);return{id:`tool.${t.qualifiedName}`,label:Se(t.name),description:t.description,category:r,keywords:[...t.tags,t.panelId,"tool"],priority:s,execute:async p=>{var x;if(i){console.warn(`Tool "${t.qualifiedName}" requires parameters. Invoke programmatically with: registry.invokeTool('${t.qualifiedName}', { ... })`),(x=p.events)==null||x.emit({type:"tool:requires-parameters",source:"command-palette",timestamp:Date.now(),payload:{toolName:t.qualifiedName,inputs:t.inputs}});return}const f=await e.invokeTool(t.qualifiedName,{},"command-palette");f.success||console.error(`Tool invocation failed: ${f.error}`),p.closeCommandPalette()}}}function N(t,e={}){return t.getAllTools().map(a=>ee(a,t,e))}function Te(t,e={}){return()=>N(t,e)}function Se(t){return t.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function Pe(t){return!(t.type!=="object"||!t.required||t.required.length===0)}function je(t,e={}){return N(t,e)}function Re(t){const{inputs:e}=t;if(e.type!=="object"||!e.properties)return[];const o=new Set(e.required||[]),a=[];for(const[s,n]of Object.entries(e.properties))a.push({name:s,type:n.type||"unknown",description:n.description||"",required:o.has(s),default:n.default,enum:n.enum});return a}function te(t){const e={};if(t.inputs.properties)for(const[o,a]of Object.entries(t.inputs.properties)){const s=a;e[o]={type:s.type||"string",description:s.description,...s.enum&&{enum:s.enum}}}return{name:t.name,description:t.description,parameters:{type:"object",properties:e,required:t.inputs.required||[]}}}function Ie(t){return{functionDeclarations:t.map(te)}}function oe(t){return{type:"function",function:{name:t.name,description:t.description,parameters:t.inputs}}}function Le(t){return t.map(oe)}function ae(t){return{name:t.name,description:t.description,input_schema:t.inputs}}function Ae(t){return t.map(ae)}function se(t){return{name:t.name,description:t.description,parameters:t.inputs}}function We(t){return t.map(se)}function Ee(t,e={}){const{header:o="You have access to the following tools:",includeParameters:a=!0}=e,s=t.map(n=>{let r=`- ${n.name}: ${n.description}`;if(a&&n.inputs.properties){const i=Object.entries(n.inputs.properties).map(([p,f])=>{var y;const x=f,u=(y=n.inputs.required)!=null&&y.includes(p)?" (required)":"";return` - ${p}: ${x.description||x.type}${u}`}).join(`
2
- `);i&&(r+=`
3
- ${i}`)}return r});return`${o}
1
+ "use strict";require('./index.css');var Ie=Object.defineProperty;var Re=(o,e,t)=>e in o?Ie(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var N=(o,e,t)=>Re(o,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const J=require("@principal-ade/panels"),n=require("react"),a=require("react/jsx-runtime"),W=require("@principal-ade/industry-theme");class ye{constructor(){N(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(s){console.error(`Failed to save panel layout for ${e}:`,s)}}}function Ae(o){const{viewKey:e,defaultSizes:t,panelType:s,adapter:r=new ye}=o,[l,i]=n.useState(t),[c,u]=n.useState(o.collapsed),f=n.useRef(o.collapsed),h=n.useRef({}),p=n.useRef(null),m=n.useRef(null);n.useEffect(()=>{(async()=>{const S=await r.load(e);S!=null&&S.sizes&&(i(S.sizes),x(S.sizes))})()},[e]);const x=n.useCallback(b=>{"left"in b&&b.left>0&&(h.current.left=b.left),"middle"in b&&b.middle>0&&(h.current.middle=b.middle),"right"in b&&b.right>0&&(h.current.right=b.right)},[]),y=n.useCallback(b=>{const S=h.current[b];if(S&&S>0)return S;if(b==="left"&&"left"in t&&t.left>0)return t.left;if(b==="right"&&"right"in t&&t.right>0)return t.right},[t]),d=n.useRef(t);n.useEffect(()=>{("left"in t&&t.left!==d.current.left||"middle"in t&&"middle"in d.current&&t.middle!==d.current.middle||"right"in t&&t.right!==d.current.right)&&(i(t),x(t),d.current=t)},[t,x]),n.useEffect(()=>{const b=o.collapsed.left!==f.current.left,S="right"in o.collapsed&&"right"in f.current&&o.collapsed.right!==f.current.right;(b||S)&&(u(o.collapsed),f.current={...o.collapsed})},[o.collapsed.left,o.collapsed.right]);const k=n.useCallback(async b=>{try{await r.save(e,{sizes:b})}catch(S){console.error(`Failed to save panel preferences for ${e}:`,S)}},[e,r]),P=n.useCallback(b=>{const S={...b};let C=!0;if("left"in b){const w=!!(c!=null&&c.left),g=b.left;if(w){const T=y("left");T!==void 0&&T>0?S.left=T:C=!1}else g===0&&(C=!1)}if(s==="three-panel"&&"right"in b){const w=!!(c!=null&&c.right),g=b.right;if(w){const T=y("right");T!==void 0&&T>0?S.right=T:C=!1}else g===0&&(C=!1)}if(i(S),x(S),p.current&&(clearTimeout(p.current),p.current=null),!C){m.current=null;return}m.current=S,p.current=setTimeout(()=>{const w=m.current;w&&(k(w),m.current=null),p.current=null},500)},[c,y,s,k,x]);n.useEffect(()=>()=>{if(p.current){const b=m.current;b&&(k(b),m.current=null),clearTimeout(p.current),p.current=null}},[k]);const I=n.useCallback(async()=>{},[]),j=n.useCallback(async()=>{},[]),L=n.useCallback(async()=>{},[]),R=n.useCallback(async()=>{},[]);return s==="three-panel"?{type:"three-panel",sizes:l,collapsed:c,handlePanelResize:P,handleLeftCollapseComplete:I,handleLeftExpandComplete:j,handleRightCollapseComplete:L,handleRightExpandComplete:R}:{type:"two-panel",sizes:l,collapsed:c,handlePanelResize:P,handleLeftCollapseComplete:I,handleLeftExpandComplete:j}}class he{constructor(){N(this,"PRESETS_KEY","panel-layouts:workspace-presets");N(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}`,s=localStorage.getItem(t);return s?JSON.parse(s):null}catch(t){return console.error(`Failed to load repository state for ${e}:`,t),null}}async saveRepositoryState(e,t){try{const s=`${this.REPO_STATE_PREFIX}${e}`;localStorage.setItem(s,JSON.stringify(t))}catch(s){throw console.error(`Failed to save repository state for ${e}:`,s),s}}async loadAllRepositoryStates(){try{const e={};for(let t=0;t<localStorage.length;t++){const s=localStorage.key(t);if(s&&s.startsWith(this.REPO_STATE_PREFIX)){const r=s.substring(this.REPO_STATE_PREFIX.length),l=localStorage.getItem(s);if(l)try{e[r]=JSON.parse(l)}catch(i){console.error(`Failed to parse repository state for ${r}:`,i)}}}return e}catch(e){return console.error("Failed to load all repository states:",e),{}}}}class A{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(),s=this.generateWorkspaceId(e.name),r={id:s,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,[s]:r};return await this.adapter.saveWorkspacePresets(l),r}static async updateWorkspaceLayout(e,t){const s=await this.adapter.loadWorkspacePresets(),r=s[e];if(!r)return console.error(`Workspace layout ${e} not found`),null;if(r.isBuiltIn)return console.error(`Cannot update built-in workspace layout ${e}`),null;const l={...r,...t,id:e,createdAt:r.createdAt,updatedAt:Date.now()},i={...s,[e]:l};return await this.adapter.saveWorkspacePresets(i),l}static async deleteWorkspaceLayout(e){const t=await this.adapter.loadWorkspacePresets(),s=t[e];if(!s)return console.error(`Workspace layout ${e} not found`),!1;if(s.isBuiltIn)return console.error(`Cannot delete built-in workspace layout ${e}`),!1;const r={...t};return delete r[e],await this.adapter.saveWorkspacePresets(r),!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 s=await this.getRepositoryState(e);s&&await this.setRepositoryState(e,{...s,sizes:t})}static async updateRepositoryCollapsed(e,t){const s=await this.getRepositoryState(e);s&&await this.setRepositoryState(e,{...s,collapsed:t})}static hasStateDeviation(e,t){const s=t.defaultSizes?JSON.stringify(e.sizes)!==JSON.stringify(t.defaultSizes):!1,r=t.defaultCollapsed?JSON.stringify(e.collapsed)!==JSON.stringify(t.defaultCollapsed):!1;return{hasSizeDeviation:s,hasCollapsedDeviation:r}}static async updateWorkspaceFromRepositoryState(e,t){const s=await this.getWorkspaceLayout(e),r=await this.getRepositoryState(t);if(!s||!r||s.isBuiltIn){console.error("Cannot update built-in workspace or workspace/state not found");return}await this.updateWorkspaceLayout(e,{defaultSizes:r.sizes,defaultCollapsed:r.collapsed})}static async resetRepositoryToWorkspaceDefaults(e,t){const s=await this.getWorkspaceLayout(t);if(!s){console.error(`Workspace ${t} not found`);return}const r=await this.getRepositoryState(e);r&&await this.setRepositoryState(e,{...r,sizes:s.defaultSizes||{left:20,middle:45,right:35},collapsed:s.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[s,r]of Object.entries(t))if(this.isLayoutMatchingWorkspace(e,r))return s;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}}N(A,"adapter",new he);function Ee(o={}){const{repositoryKey:e,autoInitialize:t=!1,defaultWorkspaceId:s}=o,[r,l]=n.useState({}),[i,c]=n.useState(null),[u,f]=n.useState(null),[h,p]=n.useState(!0),[m,x]=n.useState(null),y=n.useCallback(async()=>{try{p(!0),x(null);const C=await A.getWorkspaceLayouts();if(l(C),e){let w=await A.getRepositoryState(e);if(!w&&t){const g=s||"project-management",T=await A.getWorkspaceLayout(g);T&&(w={workspaceId:g,sizes:T.defaultSizes||{left:20,middle:45,right:35},collapsed:T.defaultCollapsed||{left:!1,right:!1}},await A.setRepositoryState(e,w))}if(c(w),w!=null&&w.workspaceId){const g=await A.getWorkspaceLayout(w.workspaceId);f(g)}else f(null)}}catch(C){x(C),console.error("Failed to load workspace data:",C)}finally{p(!1)}},[e,t,s]);n.useEffect(()=>{y()},[y]);const d=n.useCallback(async C=>await A.getWorkspaceLayout(C),[]),k=n.useCallback(async C=>{const w=await A.createWorkspaceLayout(C);return await y(),w},[y]),P=n.useCallback(async(C,w)=>{const g=await A.updateWorkspaceLayout(C,w);return await y(),g},[y]),I=n.useCallback(async C=>{const w=await A.deleteWorkspaceLayout(C);return w&&await y(),w},[y]),j=n.useCallback(async C=>{if(!e){console.error("Cannot apply workspace without repositoryKey");return}const w=await A.getWorkspaceLayout(C);if(!w){console.error(`Workspace ${C} not found`);return}const g={workspaceId:C,sizes:w.defaultSizes||{left:20,middle:45,right:35},collapsed:w.defaultCollapsed||{left:!1,right:!1}};await A.setRepositoryState(e,g),await y()},[e,y]),L=n.useCallback(async C=>{if(!e){console.error("Cannot update sizes without repositoryKey");return}await A.updateRepositorySizes(e,C),await y()},[e,y]),R=n.useCallback(async C=>{if(!e){console.error("Cannot update collapsed without repositoryKey");return}await A.updateRepositoryCollapsed(e,C),await y()},[e,y]),b=n.useCallback(async()=>{if(!e||!(i!=null&&i.workspaceId)){console.error("Cannot reset without repositoryKey and active workspace");return}await A.resetRepositoryToWorkspaceDefaults(e,i.workspaceId),await y()},[e,i==null?void 0:i.workspaceId,y]),S=n.useCallback(async()=>{await y()},[y]);return{workspaces:r,repositoryState:i,activeWorkspace:u,loading:h,error:m,getWorkspace:d,createWorkspace:k,updateWorkspace:P,deleteWorkspace:I,applyWorkspace:j,updateSizes:L,updateCollapsed:R,resetToDefaults:b,refresh:S}}function Le(o={}){const{initialFocus:e=null,collapsed:t={},panelType:s="three-panel",onFocusChange:r,events:l,getPanelId:i}=o,[c,u]=n.useState(e),f=n.useCallback(d=>{const k=c;if(u(d),r==null||r(d),l&&i){if(k){const I=i(k);I&&l.emit({type:"panel:blur",source:"panel-layouts",timestamp:Date.now(),payload:{panelId:I,panelSlot:k,nextPanelId:i(d)}})}const P=i(d);P&&l.emit({type:"panel:focus",source:"panel-layouts",timestamp:Date.now(),payload:{panelId:P,panelSlot:d,source:"keyboard-shortcut"}})}},[c,r,l,i]),h=n.useCallback(()=>{const d=c;if(u(null),r==null||r(null),l&&i&&d){const k=i(d);k&&l.emit({type:"panel:blur",source:"panel-layouts",timestamp:Date.now(),payload:{panelId:k,panelSlot:d}})}},[c,r,l,i]),p=n.useCallback(()=>{const d=[];return t.left||d.push("left"),d.push("middle"),s==="three-panel"&&!t.right&&d.push("right"),d},[t,s]),m=n.useCallback(()=>{const d=p();if(d.length===0)return;if(c===null){f(d[0]);return}const k=d.indexOf(c);if(k===-1){f(d[0]);return}const P=(k+1)%d.length;f(d[P])},[c,p,f]),x=n.useCallback(()=>{const d=p();if(d.length===0)return;if(c===null){f(d[d.length-1]);return}const k=d.indexOf(c);if(k===-1){f(d[d.length-1]);return}const P=k===0?d.length-1:k-1;f(d[P])},[c,p,f]),y=n.useCallback(d=>c===d,[c]);return{focusedPanel:c,setFocus:f,clearFocus:h,focusNext:m,focusPrevious:x,isFocused:y}}function We(o){const{enabled:e=!0,focusedPanel:t,collapsed:s,panelType:r,setFocus:l,onExpand:i,onCollapse:c}=o,u=n.useRef(t),f=n.useRef(s),h=n.useRef(r);n.useEffect(()=>{u.current=t},[t]),n.useEffect(()=>{f.current=s},[s]),n.useEffect(()=>{h.current=r},[r]);const p=n.useCallback(m=>{if(!m.altKey||m.ctrlKey||m.metaKey||m.shiftKey)return;const x=m.code,y=u.current,d=f.current,k=h.current;x==="Digit1"||x==="Numpad1"?(m.preventDefault(),d.left?i("left"):y!=="left"?l("left"):(c("left"),l("middle"))):x==="Digit2"||x==="Numpad2"?(m.preventDefault(),l("middle")):(x==="Digit3"||x==="Numpad3")&&k==="three-panel"&&(m.preventDefault(),d.right?i("right"):y!=="right"?l("right"):(c("right"),l("middle")))},[l,i,c]);n.useEffect(()=>{if(e)return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[e,p])}function De(o,e,t,s){n.useEffect(()=>{const r=e.on("panel:focus",i=>{i.payload.panelId===o&&t()});let l;return s&&(l=e.on("panel:blur",i=>{i.payload.panelId===o&&s()})),()=>{r(),l==null||l()}},[o,e,t,s])}const _e=({isFocused:o,className:e="",style:t={}})=>{if(!o)return null;const s={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 a.jsx("div",{className:`panel-focus-indicator ${e}`,style:s,role:"presentation","aria-hidden":"true"})},ge=({value:o,onChange:e,placeholder:t="> Type a command...",onClose:s,onEnter:r})=>{const{theme:l}=W.useTheme(),i=n.useRef(null);n.useEffect(()=>{i.current&&i.current.focus()},[]);const c=u=>{switch(u.key){case"Enter":u.preventDefault(),r==null||r();break;case"Escape":u.preventDefault(),s();break}};return a.jsx("div",{style:{padding:"0",borderBottom:`1px solid ${l.colors.border}`,backgroundColor:l.colors.background},children:a.jsx("input",{ref:i,type:"text",value:o,onChange:u=>e(u.target.value),onKeyDown:c,placeholder:t,style:{width:"100%",padding:"16px 20px",fontSize:"16px",fontFamily:l.fonts.monospace,backgroundColor:"transparent",border:"none",outline:"none",color:l.colors.text,caretColor:l.colors.primary},autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1})})},Z=n.forwardRef(({command:o,isSelected:e,onClick:t,onMouseEnter:s},r)=>{const{theme:l}=W.useTheme(),{label:i,description:c,icon:u,shortcut:f}=o,[h,p]=n.useState(!1);return a.jsxs("div",{ref:r,onClick:t,onMouseEnter:()=>{p(!0),s()},onMouseLeave:()=>p(!1),style:{padding:"10px 16px",cursor:"pointer",backgroundColor:e||h?l.colors.backgroundSecondary:"transparent",borderLeft:e||h?`3px solid ${l.colors.primary}`:"3px solid transparent",transition:"all 0.1s ease",display:"flex",alignItems:"center",gap:"12px"},onMouseDown:m=>{m.preventDefault()},children:[u&&a.jsx("div",{style:{flexShrink:0,width:"20px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"16px",color:e||h?l.colors.primary:l.colors.textSecondary},children:u}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:e||h?l.colors.text:l.colors.textSecondary,marginBottom:c?"2px":0},children:i}),c&&a.jsx("div",{style:{fontSize:"12px",color:l.colors.textMuted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c})]}),f&&a.jsx("div",{style:{flexShrink:0,fontSize:"11px",color:l.colors.textMuted,padding:"2px 8px",backgroundColor:l.colors.background,border:`1px solid ${l.colors.border}`,borderRadius:"4px",fontFamily:l.fonts.monospace},children:f})]})});Z.displayName="CommandItem";const xe=({commands:o,selectedIndex:e,onSelect:t,onHover:s,maxResults:r=10})=>{const{theme:l}=W.useTheme(),i=n.useRef(null),c=n.useRef(null),u=o.slice(0,r);n.useEffect(()=>{if(c.current&&i.current){const p=c.current,m=i.current,x=p.offsetTop,y=x+p.offsetHeight,d=m.scrollTop,k=m.clientHeight;x<d?m.scrollTop=x-8:y>d+k&&(m.scrollTop=y-k+8)}},[e]);const f=u.reduce((p,m,x)=>{const y=m.category||"Other";return p[y]||(p[y]=[]),p[y].push({command:m,index:x}),p},{}),h=Object.keys(f).sort((p,m)=>p==="Other"?1:m==="Other"?-1:p.localeCompare(m));return a.jsxs("div",{ref:i,style:{overflowY:"auto",maxHeight:"400px",padding:"8px 0"},children:[h.map(p=>a.jsxs("div",{children:[h.length>1&&a.jsx("div",{style:{padding:"8px 16px 4px",fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:l.colors.textMuted,letterSpacing:"0.5px"},children:p}),f[p].map(({command:m,index:x})=>a.jsx(Z,{command:m,isSelected:x===e,onClick:()=>t(m),onMouseEnter:()=>s(x),ref:x===e?c:void 0},m.id))]},p)),o.length>r&&a.jsxs("div",{style:{padding:"8px 16px",fontSize:"12px",color:l.colors.textMuted,textAlign:"center",borderTop:`1px solid ${l.colors.border}`},children:["Showing ",r," of ",o.length," results"]})]})},ze=({commandPalette:o,config:e})=>{const{theme:t}=W.useTheme(),s=n.useRef(null),{isOpen:r,close:l,query:i,setQuery:c,filteredCommands:u,selectedIndex:f,setSelectedIndex:h,executeSelected:p}=o;if(n.useEffect(()=>{if(!r)return;const y=k=>{s.current&&!s.current.contains(k.target)&&l()},d=setTimeout(()=>{document.addEventListener("mousedown",y)},100);return()=>{clearTimeout(d),document.removeEventListener("mousedown",y)}},[r,l]),!r)return null;const m=(e==null?void 0:e.maxHeight)||"50vh",x=(e==null?void 0:e.placeholder)||"> Type a command...";return a.jsxs(a.Fragment,{children:[a.jsx("div",{style:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(2px)",zIndex:999},onClick:l}),a.jsxs("div",{ref:s,className:e==null?void 0:e.className,style:{position:"fixed",bottom:0,left:0,right:0,maxHeight:m,backgroundColor:t.colors.surface,borderTop:`1px solid ${t.colors.border}`,boxShadow:t.shadows[2],zIndex:1e3,display:"flex",flexDirection:"column-reverse",...e==null?void 0:e.style},children:[a.jsxs("div",{children:[a.jsx(ge,{value:i,onChange:c,placeholder:x,onClose:l,onEnter:p}),a.jsxs("div",{style:{padding:"8px 16px",borderTop:`1px solid ${t.colors.border}`,display:"flex",gap:"16px",fontSize:"12px",color:t.colors.textMuted,backgroundColor:t.colors.background},children:[a.jsxs("span",{children:[a.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"Enter"})," Execute"]}),a.jsxs("span",{children:[a.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"Esc"})," Close"]})]})]}),u.length>0&&a.jsx(xe,{commands:u,selectedIndex:f,onSelect:y=>{o.executeCommand(y.id)},onHover:h,maxResults:e==null?void 0:e.maxResults}),i&&u.length===0&&a.jsxs("div",{style:{padding:"24px 16px",color:t.colors.textMuted,textAlign:"center",fontSize:"14px"},children:['No commands found for "',i,'"']})]})]})};class ee{constructor(){N(this,"commands",new Map);N(this,"listeners",new Set)}registerCommands(e){e.forEach(t=>{this.commands.set(t.id,t)}),this.notifyListeners()}registerCommand(e){this.commands.set(e.id,e),this.notifyListeners()}unregisterCommands(e){e.forEach(t=>{this.commands.delete(t)}),this.notifyListeners()}unregisterCommand(e){this.commands.delete(e),this.notifyListeners()}getCommands(e){const t=Array.from(this.commands.values());return e?t.filter(s=>s.isAvailable?s.isAvailable(e):!0):t}getCommand(e){return this.commands.get(e)}async executeCommand(e,t){var r,l;const s=this.commands.get(e);if(!s){console.warn(`Command not found: ${e}`);return}if(s.isAvailable&&!s.isAvailable(t)){console.warn(`Command not available: ${e}`);return}try{await s.execute(t),(r=t.events)==null||r.emit({type:"command:executed",source:"command-palette",timestamp:Date.now(),payload:{commandId:s.id,commandLabel:s.label}})}catch(i){console.error(`Error executing command ${e}:`,i),(l=t.events)==null||l.emit({type:"command:error",source:"command-palette",timestamp:Date.now(),payload:{commandId:s.id,error:i instanceof Error?i.message:String(i)}})}}searchCommands(e,t){const s=this.getCommands(t);if(!e.trim())return this.sortCommands(s);const r=e.toLowerCase();return s.map(i=>{var u,f;let c=0;return i.label.toLowerCase()===r?c+=1e3:i.label.toLowerCase().startsWith(r)?c+=500:i.label.toLowerCase().includes(r)&&(c+=250),(u=i.description)!=null&&u.toLowerCase().includes(r)&&(c+=100),i.keywords&&i.keywords.some(p=>p.toLowerCase().includes(r))&&(c+=150),(f=i.category)!=null&&f.toLowerCase().includes(r)&&(c+=50),c>0&&i.priority&&(c+=i.priority),{command:i,score:c}}).filter(i=>i.score>0).sort((i,c)=>c.score-i.score).map(i=>i.command)}sortCommands(e){return e.sort((t,s)=>{const r=(s.priority||0)-(t.priority||0);if(r!==0)return r;const l=t.category||"",i=s.category||"",c=l.localeCompare(i);return c!==0?c:t.label.localeCompare(s.label)})}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}clear(){this.commands.clear(),this.notifyListeners()}get size(){return this.commands.size}notifyListeners(){this.listeners.forEach(e=>e())}}let G=null;function qe(){return G||(G=new ee),G}function $e(){G=null}function Fe({context:o,commands:e=[],keyboard:t={key:" ",altKey:!0},config:s={},registry:r}){const[l,i]=n.useState(!1),[c,u]=n.useState(""),[f,h]=n.useState(0),[p,m]=n.useState([]),x=n.useMemo(()=>r||new ee,[r]),y=n.useMemo(()=>({...o,closeCommandPalette:()=>i(!1)}),[o]);n.useEffect(()=>{let g=!0;const T=x.subscribe(()=>{if(g){const E=x.getCommands(y);m(E)}});if(e.length>0)x.registerCommands(e);else{const E=x.getCommands(y);m(E)}return()=>{g=!1,T()}},[x]);const d=n.useMemo(()=>(s.fuzzySearch===!1,x.searchCommands(c,y)),[c,x,y,s.fuzzySearch]);n.useEffect(()=>{h(0)},[d]);const k=n.useCallback(()=>{var g;i(!0),u(""),h(0),(g=o.events)==null||g.emit({type:"command-palette:opened",source:"command-palette",timestamp:Date.now(),payload:{}})},[o.events]),P=n.useCallback(()=>{var g;i(!1),u(""),h(0),(g=o.events)==null||g.emit({type:"command-palette:closed",source:"command-palette",timestamp:Date.now(),payload:{}})},[o.events]),I=n.useCallback(()=>{l?P():k()},[l,k,P]),j=n.useCallback(async g=>{await x.executeCommand(g,y),P()},[x,y,P]),L=n.useCallback(()=>{h(g=>{const T=s.maxResults||d.length,E=Math.min(d.length,T)-1;return g<E?g+1:0})},[d.length,s.maxResults]),R=n.useCallback(()=>{h(g=>{const T=s.maxResults||d.length,E=Math.min(d.length,T)-1;return g>0?g-1:E})},[d.length,s.maxResults]),b=n.useCallback(async()=>{const g=d[0];g&&await j(g.id)},[d,j]),S=n.useCallback(g=>{x.registerCommands(g)},[x]),C=n.useCallback(g=>{x.unregisterCommands(g)},[x]),w=n.useCallback(g=>{const{key:T=" ",altKey:E=!0,ctrlKey:$=!1,metaKey:O=!1,shiftKey:B=!1}=t,Q=g.altKey===E&&g.ctrlKey===$&&g.metaKey===O&&g.shiftKey===B;if((T===" "?g.code==="Space":g.key===T)&&Q){const V=g.target;if(V.tagName==="INPUT"||V.tagName==="TEXTAREA"||V.isContentEditable)return;g.preventDefault(),I()}},[t,I]);return n.useEffect(()=>(window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)),[w]),{isOpen:l,open:k,close:P,toggle:I,query:c,setQuery:u,filteredCommands:d,executeCommand:j,selectedIndex:f,setSelectedIndex:h,selectNext:L,selectPrevious:R,executeSelected:b,commands:p,registerCommands:S,unregisterCommands:C}}const be=[{id:"panel.focus.left",label:"Focus Left Panel",description:"Set focus to the left panel",icon:"◀",category:"Panel Navigation",shortcut:"Alt+1",priority:100,keywords:["left","sidebar","focus","switch"],execute:o=>{o.setFocus("left")},isAvailable:o=>o.focusedPanel!=="left"},{id:"panel.focus.middle",label:"Focus Middle Panel",description:"Set focus to the middle panel",icon:"▣",category:"Panel Navigation",shortcut:"Alt+2",priority:100,keywords:["middle","center","main","focus","switch"],execute:o=>{o.setFocus("middle")},isAvailable:o=>o.focusedPanel!=="middle"},{id:"panel.focus.right",label:"Focus Right Panel",description:"Set focus to the right panel",icon:"▶",category:"Panel Navigation",shortcut:"Alt+3",priority:100,keywords:["right","sidebar","focus","switch"],execute:o=>{o.setFocus("right")},isAvailable:o=>o.focusedPanel!=="right"},{id:"panel.toggle.left",label:"Toggle Left Panel",description:"Expand or collapse the left panel",icon:"◀◀",category:"Panel Control",keywords:["toggle","left","collapse","expand","hide","show"],priority:80,execute:o=>{var e;(e=o.events)==null||e.emit({type:"panel:toggle",source:"command-palette",timestamp:Date.now(),payload:{panelId:"left"}})}},{id:"panel.toggle.right",label:"Toggle Right Panel",description:"Expand or collapse the right panel",icon:"▶▶",category:"Panel Control",keywords:["toggle","right","collapse","expand","hide","show"],priority:80,execute:o=>{var e;(e=o.events)==null||e.emit({type:"panel:toggle",source:"command-palette",timestamp:Date.now(),payload:{panelId:"right"}})}},{id:"panel.collapse.all",label:"Collapse All Panels",description:"Collapse all side panels to maximize middle panel",icon:"⬌",category:"Panel Control",keywords:["collapse","hide","all","maximize","focus mode"],priority:70,execute:o=>{var e;(e=o.events)==null||e.emit({type:"panel:collapse-all",source:"command-palette",timestamp:Date.now(),payload:{}})}},{id:"panel.expand.all",label:"Expand All Panels",description:"Expand all side panels to default layout",icon:"⬍",category:"Panel Control",keywords:["expand","show","all","restore","default"],priority:70,execute:o=>{var e;(e=o.events)==null||e.emit({type:"panel:expand-all",source:"command-palette",timestamp:Date.now(),payload:{}})}},{id:"panel.refresh",label:"Refresh Panel Data",description:"Reload data for the currently focused panel",icon:"↻",category:"Panel Control",keywords:["refresh","reload","update","sync"],priority:60,execute:o=>{var t;const e=o.focusedPanel;e&&((t=o.events)==null||t.emit({type:"panel:refresh",source:"command-palette",timestamp:Date.now(),payload:{panelId:e}}))},isAvailable:o=>o.focusedPanel!==null},{id:"panel.reset.layout",label:"Reset Panel Layout",description:"Reset panel sizes to default layout",icon:"⟲",category:"Panel Control",keywords:["reset","layout","default","restore"],priority:50,execute:o=>{var e;(e=o.events)==null||e.emit({type:"panel:reset-layout",source:"command-palette",timestamp:Date.now(),payload:{}})}}];function Me(){return be}const te=({value:o,onChange:e,onSubmit:t,onClose:s,onHistoryPrevious:r,onHistoryNext:l,mode:i,status:c,placeholder:u="What would you like to do?",disabled:f=!1,autoFocus:h=!0})=>{const{theme:p}=W.useTheme(),m=n.useRef(null);n.useEffect(()=>{h&&m.current&&m.current.focus()},[h]);const x=d=>{switch(d.key){case"Enter":d.preventDefault(),t();break;case"Escape":d.preventDefault(),s();break;case"ArrowUp":d.preventDefault(),r();break;case"ArrowDown":d.preventDefault(),l();break}},y=c==="thinking"||c==="executing";return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:p.colors.background,borderBottom:`1px solid ${p.colors.border}`},children:[a.jsx("span",{style:{color:i==="quick-command"?p.colors.info:p.colors.textMuted,fontFamily:p.fonts.monospace,fontSize:"14px",userSelect:"none"},children:i==="quick-command"?"/":">"}),a.jsx("input",{ref:m,"data-agent-command-palette-input":!0,type:"text",value:o,onChange:d=>e(d.target.value),onKeyDown:x,placeholder:u,disabled:f||y,style:{flex:1,backgroundColor:"transparent",border:"none",outline:"none",color:p.colors.text,fontFamily:p.fonts.monospace,fontSize:"14px",caretColor:p.colors.primary}}),y&&a.jsxs("span",{style:{color:p.colors.info,fontSize:"12px",display:"flex",alignItems:"center",gap:"4px"},children:[a.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:p.colors.info,animation:"pulse 1s ease-in-out infinite"}}),c==="thinking"?"Thinking...":"Executing..."]}),!y&&a.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:p.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${p.colors.border}`,fontSize:"11px",color:p.colors.textMuted},children:"Alt+P"})]})};te.displayName="AgentCommandInput";const Oe=({status:o})=>{const{theme:e}=W.useTheme(),t={display:"inline-flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",fontSize:"12px"};switch(o){case"pending":return a.jsx("span",{style:{...t,color:e.colors.textMuted},children:"○"});case"running":return a.jsx("span",{style:{...t,color:e.colors.info,animation:"spin 1s linear infinite"},children:"◐"});case"success":return a.jsx("span",{style:{...t,color:e.colors.success},children:"✓"});case"error":return a.jsx("span",{style:{...t,color:e.colors.error},children:"✗"})}},Ne=o=>{const e=Object.entries(o);return e.length===0?"":e.map(([t,s])=>t==="args"&&Array.isArray(s)?s.join(", "):typeof s=="string"?`"${s}"`:JSON.stringify(s)).join(", ")},Ke=({tool:o,compact:e})=>{const{theme:t}=W.useTheme(),s=Ne(o.args);return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:e?"4px 0":"8px 0",fontFamily:t.fonts.monospace,fontSize:"13px"},children:[a.jsx(Oe,{status:o.status}),a.jsxs("span",{style:{color:t.colors.text},children:[o.name,s&&a.jsxs("span",{style:{color:t.colors.textMuted},children:["(",s,")"]})]}),o.status==="running"&&a.jsx("span",{style:{marginLeft:"auto",color:t.colors.info,fontSize:"11px"},children:"[running]"}),o.status==="success"&&a.jsx("span",{style:{marginLeft:"auto",color:t.colors.success,fontSize:"11px"},children:"[done]"}),o.status==="error"&&a.jsx("span",{style:{marginLeft:"auto",color:t.colors.error,fontSize:"11px"},title:o.error,children:"[error]"})]})},oe=({tools:o,compact:e=!1})=>{const{theme:t}=W.useTheme();return o.length===0?null:a.jsx("div",{style:{padding:e?"8px 16px":"12px 16px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"4px",margin:"8px 16px"},children:o.map(s=>a.jsx(Ke,{tool:s,compact:e},s.id))})};oe.displayName="ToolExecutionList";const se=({response:o,streaming:e=!1})=>{const{theme:t}=W.useTheme();if(!o)return null;const s=o.toLowerCase().startsWith("error"),r=o.toLowerCase().startsWith("done")||o.toLowerCase().startsWith("executed");return a.jsxs("div",{style:{padding:"12px 16px",color:s?t.colors.error:r?t.colors.success:t.colors.text,fontSize:"13px",display:"flex",alignItems:"center",gap:"8px"},children:[r&&a.jsx("span",{children:"✓"}),s&&a.jsx("span",{children:"✗"}),a.jsxs("span",{children:[o,e&&a.jsx("span",{style:{display:"inline-block",width:"2px",height:"14px",backgroundColor:t.colors.primary,marginLeft:"2px",animation:"blink 1s step-end infinite"}})]})]})};se.displayName="AgentResponseDisplay";const ke=({palette:o,config:e})=>{const{theme:t}=W.useTheme(),s=n.useRef(null),{isOpen:r,close:l,query:i,setQuery:c,mode:u,status:f,pendingTools:h,completedTools:p,agentResponse:m,submit:x,historyPrevious:y,historyNext:d,suggestions:k}=o;n.useEffect(()=>{if(!r)return;const T=$=>{s.current&&!s.current.contains($.target)&&l()},E=setTimeout(()=>{document.addEventListener("mousedown",T)},100);return()=>{clearTimeout(E),document.removeEventListener("mousedown",T)}},[r,l]);const[P,I]=n.useState(!1),[j,L]=n.useState(!1);if(n.useEffect(()=>{if(r)L(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{I(!0)})});else{I(!1);const T=setTimeout(()=>{L(!1)},150);return()=>clearTimeout(T)}},[r]),!j)return null;const R=(e==null?void 0:e.placeholder)||"What would you like to do?",b=[...p,...h],S=b.length>0,C=m&&f!=="idle",w=!i&&f==="idle"&&k.length>0,g=u==="quick-command"&&f==="idle";return a.jsxs(a.Fragment,{children:[a.jsx("div",{style:{position:"fixed",inset:0,zIndex:999},onClick:l}),a.jsxs("div",{ref:s,className:e==null?void 0:e.className,style:{position:"fixed",bottom:0,left:0,right:0,maxHeight:"50vh",backgroundColor:t.colors.surface,borderTop:`1px solid ${t.colors.border}`,boxShadow:t.shadows[2],zIndex:1e3,display:"flex",flexDirection:"column-reverse",overflow:"hidden",transform:P?"translateY(0)":"translateY(100%)",transition:"transform 150ms ease-out",...e==null?void 0:e.style},children:[a.jsxs("div",{children:[a.jsx(te,{value:i,onChange:c,onSubmit:x,onClose:l,onHistoryPrevious:y,onHistoryNext:d,mode:u,status:f,placeholder:R}),a.jsxs("div",{style:{padding:"8px 16px",borderTop:`1px solid ${t.colors.border}`,display:"flex",gap:"16px",fontSize:"12px",color:t.colors.textMuted,backgroundColor:t.colors.background},children:[a.jsxs("span",{children:[a.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"Enter"})," ","Execute"]}),a.jsxs("span",{children:[a.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"Esc"})," ","Close"]}),a.jsxs("span",{children:[a.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"↑↓"})," ","History"]}),a.jsxs("span",{style:{marginLeft:"auto"},children:[a.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"/"})," ","Quick command"]})]})]}),a.jsxs("div",{style:{overflow:"auto"},children:[S&&a.jsx(oe,{tools:b,compact:b.length>3}),C&&a.jsx(se,{response:m,streaming:f==="thinking"}),w&&a.jsxs("div",{style:{padding:"12px 16px",display:"flex",gap:"8px",flexWrap:"wrap"},children:[a.jsx("span",{style:{color:t.colors.textMuted,fontSize:"12px",marginRight:"4px"},children:"Try:"}),k.map((T,E)=>a.jsxs("button",{onClick:()=>{c(T)},style:{padding:"4px 10px",backgroundColor:t.colors.backgroundSecondary,border:`1px solid ${t.colors.border}`,borderRadius:"12px",color:t.colors.textSecondary,fontSize:"12px",cursor:"pointer",transition:"background-color 150ms ease"},onMouseEnter:$=>{$.currentTarget.style.backgroundColor=t.colors.backgroundTertiary},onMouseLeave:$=>{$.currentTarget.style.backgroundColor=t.colors.backgroundSecondary},children:['"',T,'"']},E))]}),g&&a.jsxs("div",{style:{padding:"12px 16px",fontSize:"12px",color:t.colors.textMuted,fontFamily:t.fonts.monospace},children:[a.jsx("div",{style:{marginBottom:"8px",color:t.colors.textSecondary},children:"Quick commands:"}),a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[a.jsxs("div",{children:[a.jsx("span",{style:{color:t.colors.info},children:"/toggle"})," ",a.jsx("span",{style:{color:t.colors.textMuted},children:"<left|right>"})," ","- Toggle sidebar visibility"]}),a.jsxs("div",{children:[a.jsx("span",{style:{color:t.colors.info},children:"/switch"})," ",a.jsx("span",{style:{color:t.colors.textMuted},children:"<slot> <panel>"})," ","- Switch panel content"]}),a.jsxs("div",{children:[a.jsx("span",{style:{color:t.colors.info},children:"/collapse"})," ","- Collapse all sidebars"]}),a.jsxs("div",{children:[a.jsx("span",{style:{color:t.colors.info},children:"/expand"})," ","- Expand all sidebars"]})]})]})]})]}),a.jsx("style",{children:`
2
+ @keyframes pulse {
3
+ 0%, 100% { opacity: 1; }
4
+ 50% { opacity: 0.5; }
5
+ }
6
+ @keyframes spin {
7
+ from { transform: rotate(0deg); }
8
+ to { transform: rotate(360deg); }
9
+ }
10
+ @keyframes blink {
11
+ 0%, 100% { opacity: 1; }
12
+ 50% { opacity: 0; }
13
+ }
14
+ `})]})};ke.displayName="AgentCommandPalette";const Be=["hide sidebars","show terminal","focus editor"];function Ve({events:o,keyboard:e={key:"p",altKey:!0},config:t={},onExecuteTool:s,initialSuggestions:r=Be}={}){const[l,i]=n.useState(!1),[c,u]=n.useState(""),[f,h]=n.useState("natural"),[p,m]=n.useState("idle"),[x,y]=n.useState([]),[d,k]=n.useState([]),[P,I]=n.useState(""),[j,L]=n.useState([]),[R,b]=n.useState(-1),S=n.useMemo(()=>r,[r]),C=n.useCallback(v=>{u(v),h(v.startsWith("/")?"quick-command":"natural")},[]),w=n.useCallback(()=>{i(!0),u(""),h("natural"),m("idle"),y([]),k([]),I(""),b(-1),o==null||o.emit({type:"agent-command-palette:opened",source:"agent-command-palette",timestamp:Date.now(),payload:{}})},[o]),g=n.useCallback(()=>{i(!1),o==null||o.emit({type:"agent-command-palette:closed",source:"agent-command-palette",timestamp:Date.now(),payload:{}})},[o]),T=n.useCallback(()=>{l?g():w()},[l,w,g]),E=n.useCallback(()=>{u(""),h("natural"),m("idle"),y([]),k([]),I(""),b(-1)},[]),$=n.useCallback(v=>{const D={...v,status:"pending"};return y(_=>[..._,D]),D},[]),O=n.useCallback((v,D,_,K)=>{y(z=>{const F=z.find(M=>M.id===v);if(!F)return z;const q={...F,status:D,result:_,error:K};return D==="success"||D==="error"?(k(M=>[...M,q]),z.filter(M=>M.id!==v)):z.map(M=>M.id===v?q:M)})},[]),B=n.useCallback(async v=>{const D=v.replace(/^\//,"").trim().split(/\s+/),_=D[0],K=D.slice(1);if(!_)return;m("executing");const z=`quick-${Date.now()}`;$({id:z,name:_,args:{args:K}}),O(z,"running");try{if(s){const q=await s(_,{args:K});O(z,"success",String(q))}else O(z,"success","Tool executed (no handler)");L(q=>[{query:v,timestamp:Date.now(),toolsExecuted:[_],success:!0},...q.slice(0,(t.maxHistoryEntries||50)-1)]),m("complete"),I(`Executed: ${_}`);const F=t.autoCloseDelay??1e3;F>0&&setTimeout(()=>g(),F)}catch(F){const q=F instanceof Error?F.message:"Unknown error";O(z,"error",void 0,q),m("error"),I(`Error: ${q}`)}},[s,$,O,t.autoCloseDelay,t.maxHistoryEntries,g]),Q=n.useCallback(()=>{if(c.trim()){if(f==="quick-command"){B(c);return}m("thinking"),o==null||o.emit({type:"agent-command-palette:submit",source:"agent-command-palette",timestamp:Date.now(),payload:{query:c,mode:f}}),L(v=>[{query:c,timestamp:Date.now(),toolsExecuted:[],success:!0},...v.slice(0,(t.maxHistoryEntries||50)-1)])}},[c,f,B,o,t.maxHistoryEntries]),me=n.useCallback(()=>{if(j.length===0)return;const v=R<j.length-1?R+1:R;b(v),j[v]&&(u(j[v].query),h(j[v].query.startsWith("/")?"quick-command":"natural"))},[j,R]),V=n.useCallback(()=>{if(R<=0){b(-1),u(""),h("natural");return}const v=R-1;b(v),j[v]&&(u(j[v].query),h(j[v].query.startsWith("/")?"quick-command":"natural"))},[j,R]),U=n.useCallback(v=>{const{key:D="p",altKey:_=!0,ctrlKey:K=!1,metaKey:z=!1,shiftKey:F=!1}=e,q=v.altKey===_&&v.ctrlKey===K&&v.metaKey===z&&v.shiftKey===F;if((_?v.code===`Key${D.toUpperCase()}`:v.key.toLowerCase()===D.toLowerCase())&&q){const H=v.target;if(!H.closest("[data-agent-command-palette-input]")&&(H.tagName==="INPUT"||H.tagName==="TEXTAREA"||H.isContentEditable))return;v.preventDefault(),T()}},[e,T]);return n.useEffect(()=>(window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)),[U]),{isOpen:l,open:w,close:g,toggle:T,query:c,setQuery:C,mode:f,status:p,pendingTools:x,completedTools:d,agentResponse:P,submit:Q,executeQuickCommand:B,history:j,historyPrevious:me,historyNext:V,suggestions:S,clear:E}}const ae={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"}},re={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"}},ne={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"}},le={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"}},ie={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"}},ce={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"}},de={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"}},pe={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"}},ue={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"}},we=[ae,re,ne,le,ie,ce,de,pe,ue],He=[ae,re,ne],Ge=[le,ie,ce,de,pe,ue],Je={id:"panel-layouts",name:"Panel Layouts",description:"Generic panel layout and state query operations",tools:we};function Ce(o,e,t={}){const{categoryPrefix:s="Panel Tools",basePriority:r=50,includePanelInCategory:l=!0}=t,i=l?`${s} > ${o.panelId}`:s,c=Xe(o.inputs);return{id:`tool.${o.qualifiedName}`,label:Ue(o.name),description:o.description,category:i,keywords:[...o.tags,o.panelId,"tool"],priority:r,execute:async u=>{var h;if(c){console.warn(`Tool "${o.qualifiedName}" requires parameters. Invoke programmatically with: registry.invokeTool('${o.qualifiedName}', { ... })`),(h=u.events)==null||h.emit({type:"tool:requires-parameters",source:"command-palette",timestamp:Date.now(),payload:{toolName:o.qualifiedName,inputs:o.inputs}});return}const f=await e.invokeTool(o.qualifiedName,{},"command-palette");f.success||console.error(`Tool invocation failed: ${f.error}`),u.closeCommandPalette()}}}function fe(o,e={}){return o.getAllTools().map(s=>Ce(s,o,e))}function Qe(o,e={}){return()=>fe(o,e)}function Ue(o){return o.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function Xe(o){return!(o.type!=="object"||!o.required||o.required.length===0)}function Ye(o,e={}){return fe(o,e)}function Ze(o){const{inputs:e}=o;if(e.type!=="object"||!e.properties)return[];const t=new Set(e.required||[]),s=[];for(const[r,l]of Object.entries(e.properties))s.push({name:r,type:l.type||"unknown",description:l.description||"",required:t.has(r),default:l.default,enum:l.enum});return s}function Te(o){const e={};if(o.inputs.properties)for(const[t,s]of Object.entries(o.inputs.properties)){const r=s;e[t]={type:r.type||"string",description:r.description,...r.enum&&{enum:r.enum}}}return{name:o.name,description:o.description,parameters:{type:"object",properties:e,required:o.inputs.required||[]}}}function et(o){return{functionDeclarations:o.map(Te)}}function ve(o){return{type:"function",function:{name:o.name,description:o.description,parameters:o.inputs}}}function tt(o){return o.map(ve)}function Se(o){return{name:o.name,description:o.description,input_schema:o.inputs}}function ot(o){return o.map(Se)}function je(o){return{name:o.name,description:o.description,parameters:o.inputs}}function st(o){return o.map(je)}function at(o,e={}){const{header:t="You have access to the following tools:",includeParameters:s=!0}=e,r=o.map(l=>{let i=`- ${l.name}: ${l.description}`;if(s&&l.inputs.properties){const c=Object.entries(l.inputs.properties).map(([u,f])=>{var m;const h=f,p=(m=l.inputs.required)!=null&&m.includes(u)?" (required)":"";return` - ${u}: ${h.description||h.type}${p}`}).join(`
15
+ `);c&&(i+=`
16
+ ${c}`)}return i});return`${t}
4
17
 
5
- ${s.join(`
18
+ ${r.join(`
6
19
 
7
- `)}`}const ze=({size:t=18})=>c.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),c.jsx("path",{d:"M9 3v18"})]}),De=({size:t=18})=>c.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),c.jsx("path",{d:"M9 3v18"}),c.jsx("path",{d:"m16 15-3-3 3-3"})]}),_e=({size:t=18})=>c.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),c.jsx("path",{d:"M15 3v18"})]}),Fe=({size:t=18})=>c.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),c.jsx("path",{d:"M15 3v18"}),c.jsx("path",{d:"m8 9 3 3-3 3"})]}),F=({isCollapsed:t,onToggle:e,side:o="left",iconSize:a=18,style:s,shortcutHint:n="Cmd/Ctrl+B",title:r,className:i})=>{const{theme:p}=W.useTheme(),f=()=>o==="right"?t?c.jsx(_e,{size:a}):c.jsx(Fe,{size:a}):t?c.jsx(ze,{size:a}):c.jsx(De,{size:a}),x=()=>`${t?"Show":"Hide"} ${o==="right"?"Right Panel":"Sidebar"}${n?` (${n})`:""}`;return c.jsx("button",{onClick:e,title:r??x(),className:i,style:{background:"transparent",border:"none",color:t?p.colors.textSecondary:p.colors.primary,cursor:"pointer",padding:"6px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s",width:"32px",height:"32px",...s},onMouseEnter:u=>{u.currentTarget.style.backgroundColor=p.colors.backgroundTertiary,u.currentTarget.style.color=p.colors.primary},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent",u.currentTarget.style.color=t?p.colors.textSecondary:p.colors.primary},children:f()})},$e=({size:t=14})=>c.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M8 3 4 7l4 4"}),c.jsx("path",{d:"M4 7h16"}),c.jsx("path",{d:"m16 21 4-4-4-4"}),c.jsx("path",{d:"M20 17H4"})]}),Oe=({size:t=14})=>c.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"m16 3 4 4-4 4"}),c.jsx("path",{d:"M20 7H4"}),c.jsx("path",{d:"m8 21-4-4 4-4"}),c.jsx("path",{d:"M4 17h16"})]}),$=({onSwitch:t,variant:e="left-middle",iconSize:o=14,style:a,title:s,className:n})=>{const{theme:r}=W.useTheme(),i=()=>e==="left-middle"?"Switch left and middle panels":"Switch right and middle panels",p=e==="left-middle"?$e:Oe;return c.jsx("button",{onClick:t,title:s??i(),className:n,style:{background:"transparent",border:"none",color:r.colors.textSecondary,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=r.colors.backgroundTertiary,f.currentTarget.style.color=r.colors.text},onMouseLeave:f=>{f.currentTarget.style.backgroundColor="transparent",f.currentTarget.style.color=r.colors.textSecondary},children:c.jsx(p,{size:o})})},Me=({size:t=14})=>c.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),c.jsx("path",{d:"M3 9h18"}),c.jsx("path",{d:"M9 21V9"})]}),re=({onConfigure:t,iconSize:e=14,style:o,title:a="Configure panel layout",className:s})=>{const{theme:n}=W.useTheme();return c.jsx("button",{onClick:t,title:a,className:s,style:{background:"transparent",border:"none",color:n.colors.textSecondary,cursor:"pointer",padding:"6px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s",width:"32px",height:"32px",...o},onMouseEnter:r=>{r.currentTarget.style.backgroundColor=n.colors.backgroundTertiary,r.currentTarget.style.color=n.colors.text},onMouseLeave:r=>{r.currentTarget.style.backgroundColor="transparent",r.currentTarget.style.color=n.colors.textSecondary},children:c.jsx(Me,{size:e})})},Ne=({leftSidebarCollapsed:t=!1,onToggleLeftSidebar:e,showLeftSidebarControl:o=!1,rightSidebarCollapsed:a=!1,onToggleRightSidebar:s,showRightSidebarControl:n=!1,onSwitchLeftMiddlePanels:r,showSwitchLeftMiddle:i=!1,onSwitchRightMiddlePanels:p,showSwitchRightMiddle:f=!1,onConfigurePanels:x,showConfigureButton:u=!1,gap:y=4,style:h,className:m,iconSize:d,leftCollapseButtonProps:b,rightCollapseButtonProps:S,leftMiddleSwitchButtonProps:j,rightMiddleSwitchButtonProps:R,configureButtonProps:L})=>o&&e||i&&r||u&&x||f&&p||n&&s?c.jsxs("div",{className:m,style:{display:"flex",alignItems:"center",gap:`${y}px`,...h},children:[o&&e&&c.jsx(F,{isCollapsed:t,onToggle:e,side:"left",iconSize:d??18,...b}),i&&r&&c.jsx($,{onSwitch:r,variant:"left-middle",iconSize:d??14,...j}),u&&x&&c.jsx(re,{onConfigure:x,iconSize:d??14,...L}),f&&p&&c.jsx($,{onSwitch:p,variant:"right-middle",iconSize:d??14,...R}),n&&s&&c.jsx(F,{isCollapsed:a,onToggle:s,side:"right",iconSize:d??18,...S})]}):null;Object.defineProperty(exports,"EditableConfigurablePanelLayout",{enumerable:!0,get:()=>D.EditableConfigurablePanelLayout});Object.defineProperty(exports,"ResponsiveConfigurablePanelLayout",{enumerable:!0,get:()=>D.ResponsiveConfigurablePanelLayout});Object.defineProperty(exports,"mapThemeToPanelVars",{enumerable:!0,get:()=>D.mapThemeToPanelVars});Object.defineProperty(exports,"mapThemeToTabVars",{enumerable:!0,get:()=>D.mapThemeToTabVars});exports.CommandInput=K;exports.CommandItem=O;exports.CommandList=V;exports.CommandPalette=xe;exports.CommandRegistryService=M;exports.FocusIndicator=ge;exports.LocalStoragePersistenceAdapter=q;exports.LocalStorageWorkspaceAdapter=B;exports.PanelCollapseButton=F;exports.PanelConfigureButton=re;exports.PanelControls=Ne;exports.PanelSwitchButton=$;exports.WorkspaceLayoutService=P;exports.collapseAllPanelsTool=G;exports.createToolCommandsProvider=Te;exports.expandAllPanelsTool=X;exports.focusPanelTool=Q;exports.generateToolsSystemPrompt=Ee;exports.getGlobalCommandRegistry=be;exports.getPanelCommands=Ce;exports.getToolParameterInfo=Re;exports.layoutTools=Z;exports.layoutToolsMetadata=ve;exports.panelCommands=J;exports.resetGlobalCommandRegistry=ke;exports.resetLayoutTool=U;exports.switchPanelTool=Y;exports.togglePanelTool=H;exports.toolToAIFunction=se;exports.toolToAnthropicFormat=ae;exports.toolToCommand=ee;exports.toolToGeminiFunction=te;exports.toolToOpenAIFunction=oe;exports.toolsToAIFunctions=We;exports.toolsToAnthropicFormat=Ae;exports.toolsToCommands=N;exports.toolsToGeminiFormat=Ie;exports.toolsToOpenAIFormat=Le;exports.useCommandPalette=we;exports.usePanelFocus=me;exports.usePanelFocusListener=he;exports.usePanelKeyboardShortcuts=ye;exports.usePanelPersistence=pe;exports.useToolCommands=je;exports.useWorkspace=fe;
20
+ `)}`}const rt=({size:o=18})=>a.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),a.jsx("path",{d:"M9 3v18"})]}),nt=({size:o=18})=>a.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),a.jsx("path",{d:"M9 3v18"}),a.jsx("path",{d:"m16 15-3-3 3-3"})]}),lt=({size:o=18})=>a.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),a.jsx("path",{d:"M15 3v18"})]}),it=({size:o=18})=>a.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),a.jsx("path",{d:"M15 3v18"}),a.jsx("path",{d:"m8 9 3 3-3 3"})]}),X=({isCollapsed:o,onToggle:e,side:t="left",iconSize:s=18,style:r,shortcutHint:l="Cmd/Ctrl+B",title:i,className:c})=>{const{theme:u}=W.useTheme(),f=()=>t==="right"?o?a.jsx(lt,{size:s}):a.jsx(it,{size:s}):o?a.jsx(rt,{size:s}):a.jsx(nt,{size:s}),h=()=>`${o?"Show":"Hide"} ${t==="right"?"Right Panel":"Sidebar"}${l?` (${l})`:""}`;return a.jsx("button",{onClick:e,title:i??h(),className:c,style:{background:"transparent",border:"none",color:o?u.colors.textSecondary:u.colors.primary,cursor:"pointer",padding:"6px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s",width:"32px",height:"32px",...r},onMouseEnter:p=>{p.currentTarget.style.backgroundColor=u.colors.backgroundTertiary,p.currentTarget.style.color=u.colors.primary},onMouseLeave:p=>{p.currentTarget.style.backgroundColor="transparent",p.currentTarget.style.color=o?u.colors.textSecondary:u.colors.primary},children:f()})},ct=({size:o=14})=>a.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M8 3 4 7l4 4"}),a.jsx("path",{d:"M4 7h16"}),a.jsx("path",{d:"m16 21 4-4-4-4"}),a.jsx("path",{d:"M20 17H4"})]}),dt=({size:o=14})=>a.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"m16 3 4 4-4 4"}),a.jsx("path",{d:"M20 7H4"}),a.jsx("path",{d:"m8 21-4-4 4-4"}),a.jsx("path",{d:"M4 17h16"})]}),Y=({onSwitch:o,variant:e="left-middle",iconSize:t=14,style:s,title:r,className:l})=>{const{theme:i}=W.useTheme(),c=()=>e==="left-middle"?"Switch left and middle panels":"Switch right and middle panels",u=e==="left-middle"?ct:dt;return a.jsx("button",{onClick:o,title:r??c(),className:l,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",...s},onMouseEnter:f=>{f.currentTarget.style.backgroundColor=i.colors.backgroundTertiary,f.currentTarget.style.color=i.colors.text},onMouseLeave:f=>{f.currentTarget.style.backgroundColor="transparent",f.currentTarget.style.color=i.colors.textSecondary},children:a.jsx(u,{size:t})})},pt=({size:o=14})=>a.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),a.jsx("path",{d:"M3 9h18"}),a.jsx("path",{d:"M9 21V9"})]}),Pe=({onConfigure:o,iconSize:e=14,style:t,title:s="Configure panel layout",className:r})=>{const{theme:l}=W.useTheme();return a.jsx("button",{onClick:o,title:s,className:r,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:i=>{i.currentTarget.style.backgroundColor=l.colors.backgroundTertiary,i.currentTarget.style.color=l.colors.text},onMouseLeave:i=>{i.currentTarget.style.backgroundColor="transparent",i.currentTarget.style.color=l.colors.textSecondary},children:a.jsx(pt,{size:e})})},ut=({leftSidebarCollapsed:o=!1,onToggleLeftSidebar:e,showLeftSidebarControl:t=!1,rightSidebarCollapsed:s=!1,onToggleRightSidebar:r,showRightSidebarControl:l=!1,onSwitchLeftMiddlePanels:i,showSwitchLeftMiddle:c=!1,onSwitchRightMiddlePanels:u,showSwitchRightMiddle:f=!1,onConfigurePanels:h,showConfigureButton:p=!1,gap:m=4,style:x,className:y,iconSize:d,leftCollapseButtonProps:k,rightCollapseButtonProps:P,leftMiddleSwitchButtonProps:I,rightMiddleSwitchButtonProps:j,configureButtonProps:L})=>t&&e||c&&i||p&&h||f&&u||l&&r?a.jsxs("div",{className:y,style:{display:"flex",alignItems:"center",gap:`${m}px`,...x},children:[t&&e&&a.jsx(X,{isCollapsed:o,onToggle:e,side:"left",iconSize:d??18,...k}),c&&i&&a.jsx(Y,{onSwitch:i,variant:"left-middle",iconSize:d??14,...I}),p&&h&&a.jsx(Pe,{onConfigure:h,iconSize:d??14,...L}),f&&u&&a.jsx(Y,{onSwitch:u,variant:"right-middle",iconSize:d??14,...j}),l&&r&&a.jsx(X,{isCollapsed:s,onToggle:r,side:"right",iconSize:d??18,...P})]}):null;Object.defineProperty(exports,"EditableConfigurablePanelLayout",{enumerable:!0,get:()=>J.EditableConfigurablePanelLayout});Object.defineProperty(exports,"ResponsiveConfigurablePanelLayout",{enumerable:!0,get:()=>J.ResponsiveConfigurablePanelLayout});Object.defineProperty(exports,"mapThemeToPanelVars",{enumerable:!0,get:()=>J.mapThemeToPanelVars});Object.defineProperty(exports,"mapThemeToTabVars",{enumerable:!0,get:()=>J.mapThemeToTabVars});exports.AgentCommandInput=te;exports.AgentCommandPalette=ke;exports.AgentResponseDisplay=se;exports.CommandInput=ge;exports.CommandItem=Z;exports.CommandList=xe;exports.CommandPalette=ze;exports.CommandRegistryService=ee;exports.FocusIndicator=_e;exports.LocalStoragePersistenceAdapter=ye;exports.LocalStorageWorkspaceAdapter=he;exports.PanelCollapseButton=X;exports.PanelConfigureButton=Pe;exports.PanelControls=ut;exports.PanelSwitchButton=Y;exports.ToolExecutionList=oe;exports.WorkspaceLayoutService=A;exports.collapseAllPanelsTool=ie;exports.createToolCommandsProvider=Qe;exports.expandAllPanelsTool=ce;exports.focusPanelTool=pe;exports.generateToolsSystemPrompt=at;exports.getGlobalCommandRegistry=qe;exports.getPanelCommands=Me;exports.getPanelStateTool=re;exports.getToolParameterInfo=Ze;exports.getVisiblePanelsTool=ae;exports.layoutActionTools=Ge;exports.layoutTools=we;exports.layoutToolsMetadata=Je;exports.listPanelsWithStateTool=ne;exports.panelCommands=be;exports.resetGlobalCommandRegistry=$e;exports.resetLayoutTool=ue;exports.stateQueryTools=He;exports.switchPanelTool=de;exports.togglePanelTool=le;exports.toolToAIFunction=je;exports.toolToAnthropicFormat=Se;exports.toolToCommand=Ce;exports.toolToGeminiFunction=Te;exports.toolToOpenAIFunction=ve;exports.toolsToAIFunctions=st;exports.toolsToAnthropicFormat=ot;exports.toolsToCommands=fe;exports.toolsToGeminiFormat=et;exports.toolsToOpenAIFormat=tt;exports.useAgentCommandPalette=Ve;exports.useCommandPalette=Fe;exports.usePanelFocus=Le;exports.usePanelFocusListener=De;exports.usePanelKeyboardShortcuts=We;exports.usePanelPersistence=Ae;exports.useToolCommands=Ye;exports.useWorkspace=Ee;
8
21
  //# sourceMappingURL=index.js.map