tide-commander 1.99.0 → 1.100.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/assets/{BossLogsModal-CDel834o.js → BossLogsModal-CgiqbrpI.js} +1 -1
  2. package/dist/assets/{BossSpawnModal-BB9wL5VV.js → BossSpawnModal-Dm-Rlit6.js} +1 -1
  3. package/dist/assets/{ControlsModal-D5RE5MvT.js → ControlsModal-CS5PL1Dr.js} +1 -1
  4. package/dist/assets/{DockerLogsModal-B27P1JpZ.js → DockerLogsModal-CoDsW7Zf.js} +1 -1
  5. package/dist/assets/{EmbeddedEditor-DP1jqsT_.js → EmbeddedEditor-B53miU1u.js} +1 -1
  6. package/dist/assets/{GmailOAuthSetup-DvuL5G8Q.js → GmailOAuthSetup-DHYC56vA.js} +1 -1
  7. package/dist/assets/{GoogleOAuthSetup-CG6bSCjv.js → GoogleOAuthSetup-BrXFYUFW.js} +1 -1
  8. package/dist/assets/{IframeModal-ClnUGmJV.js → IframeModal-BrGdxNuG.js} +1 -1
  9. package/dist/assets/{IntegrationsPanel-0vdfxZRq.js → IntegrationsPanel-B5D_jOhk.js} +2 -2
  10. package/dist/assets/{LogViewerModal-DLQlrZ4O.js → LogViewerModal-KHXuxGNe.js} +1 -1
  11. package/dist/assets/{MonitoringModal-DiC9TNCy.js → MonitoringModal-Co_fx9fM.js} +1 -1
  12. package/dist/assets/{PM2LogsModal-BgPrnaP5.js → PM2LogsModal-CzSWbJw2.js} +1 -1
  13. package/dist/assets/{RestoreArchivedAreaModal-CIN1OrOW.js → RestoreArchivedAreaModal-DEgMLH7w.js} +1 -1
  14. package/dist/assets/{Scene2DCanvas-Bap6brvv.js → Scene2DCanvas-bKf_xYPZ.js} +1 -1
  15. package/dist/assets/{SceneManager-CidCW0PR.js → SceneManager-Djv8JsV0.js} +1 -1
  16. package/dist/assets/{SkillsPanel-DHQTPaP2.js → SkillsPanel-DolU9i4d.js} +1 -1
  17. package/dist/assets/{SlackMultiInstanceSetup-CQK4D89W.js → SlackMultiInstanceSetup-sRiMZQ6x.js} +1 -1
  18. package/dist/assets/{SpawnModal-Cx_k3HHC.js → SpawnModal-Cwb4vyWw.js} +1 -1
  19. package/dist/assets/{SubordinateAssignmentModal-C1DOv51H.js → SubordinateAssignmentModal-D2AUyLhd.js} +1 -1
  20. package/dist/assets/{TriggerManagerPanel-jP5RBK2L.js → TriggerManagerPanel-WEJXvsjq.js} +1 -1
  21. package/dist/assets/{WorkflowEditorPanel-Dh6mZ8M4.js → WorkflowEditorPanel-CqCKn-BW.js} +1 -1
  22. package/dist/assets/{index-DP5sMNS9.js → index-BGpBSg5x.js} +1 -1
  23. package/dist/assets/{index-B-ttQFx4.js → index-Bi9RecAa.js} +2 -2
  24. package/dist/assets/{index-enJvXAbe.js → index-BqTABon1.js} +1 -1
  25. package/dist/assets/{index-DsKaX6TJ.js → index-C2z1QKUl.js} +1 -1
  26. package/dist/assets/{index-BXnThzaG.js → index-CJXhFnBD.js} +1 -1
  27. package/dist/assets/{index-DfEbuBH8.js → index-C_tlEtg3.js} +1 -1
  28. package/dist/assets/{index-D96LXKm4.js → index-Ck5CfDGK.js} +1 -1
  29. package/dist/assets/{index-Cwlm-Pqi.js → index-D1nrHGW6.js} +3 -3
  30. package/dist/assets/{index-CYwFXTQZ.js → index-DThdfn9f.js} +1 -1
  31. package/dist/assets/{main-B7wf_xU_.js → main-CBiZdw6w.js} +4 -4
  32. package/dist/assets/{web-IGuhG0xr.js → web-C6kv8URU.js} +1 -1
  33. package/dist/assets/{web-BHmmnvF7.js → web-hRik7e7W.js} +1 -1
  34. package/dist/assets/{web-SOehUGgT.js → web-ns0ZWeh3.js} +1 -1
  35. package/dist/index.html +1 -1
  36. package/dist/src/packages/server/cli.js +26 -0
  37. package/package.json +1 -1
@@ -1 +1 @@
1
- import{j as d,I as H,ah as He,U as Je,W as Xe,bX as Ze,r as A,s as ee,bY as be,_ as qe,ab as fe,u as Ce}from"./main-B7wf_xU_.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function q(t){return Array.isArray?Array.isArray(t):Pe(t)==="[object Array]"}function et(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function tt(t){return t==null?"":et(t)}function X(t){return typeof t=="string"}function $e(t){return typeof t=="number"}function st(t){return t===!0||t===!1||nt(t)&&Pe(t)=="[object Boolean]"}function Te(t){return typeof t=="object"}function nt(t){return Te(t)&&t!==null}function O(t){return t!=null}function me(t){return!t.trim().length}function Pe(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const rt="Incorrect 'index' type",it=t=>`Invalid value for key ${t}`,ct=t=>`Pattern length exceeds max of ${t}.`,ot=t=>`Missing ${t} property in key`,at=t=>`Property 'weight' in key '${t}' must be a positive integer`,ve=Object.prototype.hasOwnProperty;class ut{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(n=>{let r=Ke(n);this._keys.push(r),this._keyMap[r.id]=r,s+=r.weight}),this._keys.forEach(n=>{n.weight/=s})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Ke(t){let e=null,s=null,n=null,r=1,i=null;if(X(t)||q(t))n=t,e=Se(t),s=pe(t);else{if(!ve.call(t,"name"))throw new Error(ot("name"));const c=t.name;if(n=c,ve.call(t,"weight")&&(r=t.weight,r<=0))throw new Error(at(c));e=Se(c),s=pe(c),i=t.getFn}return{path:e,id:s,weight:r,src:n,getFn:i}}function Se(t){return q(t)?t:t.split(".")}function pe(t){return q(t)?t.join("."):t}function lt(t,e){let s=[],n=!1;const r=(i,c,a)=>{if(O(i))if(!c[a])s.push(i);else{let u=c[a];const l=i[u];if(!O(l))return;if(a===c.length-1&&(X(l)||$e(l)||st(l)))s.push(tt(l));else if(q(l)){n=!0;for(let h=0,f=l.length;h<f;h+=1)r(l[h],c,a+1)}else c.length&&r(l,c,a+1)}};return r(t,X(e)?e.split("."):e,0),n?s:s[0]}const ht={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},dt={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},ft={location:0,threshold:.6,distance:100},mt={useExtendedSearch:!1,getFn:lt,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var p={...dt,...ht,...ft,...mt};const pt=/[^ ]+/g;function gt(t=1,e=3){const s=new Map,n=Math.pow(10,e);return{get(r){const i=r.match(pt).length;if(s.has(i))return s.get(i);const c=1/Math.pow(i,.5*t),a=parseFloat(Math.round(c*n)/n);return s.set(i,a),a},clear(){s.clear()}}}class we{constructor({getFn:e=p.getFn,fieldNormWeight:s=p.fieldNormWeight}={}){this.norm=gt(s,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((s,n)=>{this._keysMap[s.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,X(this.docs[0])?this.docs.forEach((e,s)=>{this._addString(e,s)}):this.docs.forEach((e,s)=>{this._addObject(e,s)}),this.norm.clear())}add(e){const s=this.size();X(e)?this._addString(e,s):this._addObject(e,s)}removeAt(e){this.records.splice(e,1);for(let s=e,n=this.size();s<n;s+=1)this.records[s].i-=1}getValueForItemAtKeyId(e,s){return e[this._keysMap[s]]}size(){return this.records.length}_addString(e,s){if(!O(e)||me(e))return;let n={v:e,i:s,n:this.norm.get(e)};this.records.push(n)}_addObject(e,s){let n={i:s,$:{}};this.keys.forEach((r,i)=>{let c=r.getFn?r.getFn(e):this.getFn(e,r.path);if(O(c)){if(q(c)){let a=[];const u=[{nestedArrIndex:-1,value:c}];for(;u.length;){const{nestedArrIndex:l,value:h}=u.pop();if(O(h))if(X(h)&&!me(h)){let f={v:h,i:l,n:this.norm.get(h)};a.push(f)}else q(h)&&h.forEach((f,m)=>{u.push({nestedArrIndex:m,value:f})})}n.$[i]=a}else if(X(c)&&!me(c)){let a={v:c,n:this.norm.get(c)};n.$[i]=a}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function Oe(t,e,{getFn:s=p.getFn,fieldNormWeight:n=p.fieldNormWeight}={}){const r=new we({getFn:s,fieldNormWeight:n});return r.setKeys(t.map(Ke)),r.setSources(e),r.create(),r}function At(t,{getFn:e=p.getFn,fieldNormWeight:s=p.fieldNormWeight}={}){const{keys:n,records:r}=t,i=new we({getFn:e,fieldNormWeight:s});return i.setKeys(n),i.setIndexRecords(r),i}function le(t,{errors:e=0,currentLocation:s=0,expectedLocation:n=0,distance:r=p.distance,ignoreLocation:i=p.ignoreLocation}={}){const c=e/t.length;if(i)return c;const a=Math.abs(n-s);return r?c+a/r:a?1:c}function yt(t=[],e=p.minMatchCharLength){let s=[],n=-1,r=-1,i=0;for(let c=t.length;i<c;i+=1){let a=t[i];a&&n===-1?n=i:!a&&n!==-1&&(r=i-1,r-n+1>=e&&s.push([n,r]),n=-1)}return t[i-1]&&i-n>=e&&s.push([n,i-1]),s}const ne=32;function xt(t,e,s,{location:n=p.location,distance:r=p.distance,threshold:i=p.threshold,findAllMatches:c=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,includeMatches:u=p.includeMatches,ignoreLocation:l=p.ignoreLocation}={}){if(e.length>ne)throw new Error(ct(ne));const h=e.length,f=t.length,m=Math.max(0,Math.min(n,f));let g=i,y=m;const b=a>1||u,k=b?Array(f):[];let S;for(;(S=t.indexOf(e,y))>-1;){let x=le(e,{currentLocation:S,expectedLocation:m,distance:r,ignoreLocation:l});if(g=Math.min(x,g),y=S+h,b){let E=0;for(;E<h;)k[S+E]=1,E+=1}}y=-1;let _=[],W=1,z=h+f;const re=1<<h-1;for(let x=0;x<h;x+=1){let E=0,I=z;for(;E<I;)le(e,{errors:x,currentLocation:m+I,expectedLocation:m,distance:r,ignoreLocation:l})<=g?E=I:z=I,I=Math.floor((z-E)/2+E);z=I;let $=Math.max(1,m-I+1),T=c?f:Math.min(m+I,f)+h,V=Array(T+2);V[T+1]=(1<<x)-1;for(let j=T;j>=$;j-=1){let Z=j-1,ae=s[t.charAt(Z)];if(b&&(k[Z]=+!!ae),V[j]=(V[j+1]<<1|1)&ae,x&&(V[j]|=(_[j+1]|_[j])<<1|1|_[j+1]),V[j]&re&&(W=le(e,{errors:x,currentLocation:Z,expectedLocation:m,distance:r,ignoreLocation:l}),W<=g)){if(g=W,y=Z,y<=m)break;$=Math.max(1,2*m-y)}}if(le(e,{errors:x+1,currentLocation:m,expectedLocation:m,distance:r,ignoreLocation:l})>g)break;_=V}const G={isMatch:y>=0,score:Math.max(.001,W)};if(b){const x=yt(k,a);x.length?u&&(G.indices=x):G.isMatch=!1}return G}function Et(t){let e={};for(let s=0,n=t.length;s<n;s+=1){const r=t.charAt(s);e[r]=(e[r]||0)|1<<n-s-1}return e}const he=String.prototype.normalize?(t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(t=>t);class ze{constructor(e,{location:s=p.location,threshold:n=p.threshold,distance:r=p.distance,includeMatches:i=p.includeMatches,findAllMatches:c=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,isCaseSensitive:u=p.isCaseSensitive,ignoreDiacritics:l=p.ignoreDiacritics,ignoreLocation:h=p.ignoreLocation}={}){if(this.options={location:s,threshold:n,distance:r,includeMatches:i,findAllMatches:c,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h},e=u?e:e.toLowerCase(),e=l?he(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const f=(g,y)=>{this.chunks.push({pattern:g,alphabet:Et(g),startIndex:y})},m=this.pattern.length;if(m>ne){let g=0;const y=m%ne,b=m-y;for(;g<b;)f(this.pattern.substr(g,ne),g),g+=ne;if(y){const k=m-ne;f(this.pattern.substr(k),k)}}else f(this.pattern,0)}searchIn(e){const{isCaseSensitive:s,ignoreDiacritics:n,includeMatches:r}=this.options;if(e=s?e:e.toLowerCase(),e=n?he(e):e,this.pattern===e){let b={isMatch:!0,score:0};return r&&(b.indices=[[0,e.length-1]]),b}const{location:i,distance:c,threshold:a,findAllMatches:u,minMatchCharLength:l,ignoreLocation:h}=this.options;let f=[],m=0,g=!1;this.chunks.forEach(({pattern:b,alphabet:k,startIndex:S})=>{const{isMatch:_,score:W,indices:z}=xt(e,b,k,{location:i+S,distance:c,threshold:a,findAllMatches:u,minMatchCharLength:l,includeMatches:r,ignoreLocation:h});_&&(g=!0),m+=W,_&&z&&(f=[...f,...z])});let y={isMatch:g,score:g?m/this.chunks.length:1};return g&&r&&(y.indices=f),y}}class te{constructor(e){this.pattern=e}static isMultiMatch(e){return ke(e,this.multiRegex)}static isSingleMatch(e){return ke(e,this.singleRegex)}search(){}}function ke(t,e){const s=t.match(e);return s?s[1]:null}class Ct extends te{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const s=e===this.pattern;return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class wt extends te{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const n=e.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class Ft extends te{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const s=e.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Mt extends te{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const s=!e.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}}class It extends te{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const s=e.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class Dt extends te{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const s=!e.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}}class Qe extends te{constructor(e,{location:s=p.location,threshold:n=p.threshold,distance:r=p.distance,includeMatches:i=p.includeMatches,findAllMatches:c=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,isCaseSensitive:u=p.isCaseSensitive,ignoreDiacritics:l=p.ignoreDiacritics,ignoreLocation:h=p.ignoreLocation}={}){super(e),this._bitapSearch=new ze(e,{location:s,threshold:n,distance:r,includeMatches:i,findAllMatches:c,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class We extends te{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let s=0,n;const r=[],i=this.pattern.length;for(;(n=e.indexOf(this.pattern,s))>-1;)s=n+i,r.push([n,s-1]);const c=!!r.length;return{isMatch:c,score:c?0:1,indices:r}}}const ge=[Ct,We,Ft,Mt,Dt,It,wt,Qe],je=ge.length,Bt=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,bt="|";function vt(t,e={}){return t.split(bt).map(s=>{let n=s.trim().split(Bt).filter(i=>i&&!!i.trim()),r=[];for(let i=0,c=n.length;i<c;i+=1){const a=n[i];let u=!1,l=-1;for(;!u&&++l<je;){const h=ge[l];let f=h.isMultiMatch(a);f&&(r.push(new h(f,e)),u=!0)}if(!u)for(l=-1;++l<je;){const h=ge[l];let f=h.isSingleMatch(a);if(f){r.push(new h(f,e));break}}}return r})}const St=new Set([Qe.type,We.type]);class kt{constructor(e,{isCaseSensitive:s=p.isCaseSensitive,ignoreDiacritics:n=p.ignoreDiacritics,includeMatches:r=p.includeMatches,minMatchCharLength:i=p.minMatchCharLength,ignoreLocation:c=p.ignoreLocation,findAllMatches:a=p.findAllMatches,location:u=p.location,threshold:l=p.threshold,distance:h=p.distance}={}){this.query=null,this.options={isCaseSensitive:s,ignoreDiacritics:n,includeMatches:r,minMatchCharLength:i,findAllMatches:a,ignoreLocation:c,location:u,threshold:l,distance:h},e=s?e:e.toLowerCase(),e=n?he(e):e,this.pattern=e,this.query=vt(this.pattern,this.options)}static condition(e,s){return s.useExtendedSearch}searchIn(e){const s=this.query;if(!s)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:r,ignoreDiacritics:i}=this.options;e=r?e:e.toLowerCase(),e=i?he(e):e;let c=0,a=[],u=0;for(let l=0,h=s.length;l<h;l+=1){const f=s[l];a.length=0,c=0;for(let m=0,g=f.length;m<g;m+=1){const y=f[m],{isMatch:b,indices:k,score:S}=y.search(e);if(b){if(c+=1,u+=S,n){const _=y.constructor.type;St.has(_)?a=[...a,...k]:a.push(k)}}else{u=0,c=0,a.length=0;break}}if(c){let m={isMatch:!0,score:u/c};return n&&(m.indices=a),m}}return{isMatch:!1,score:1}}}const Ae=[];function jt(...t){Ae.push(...t)}function ye(t,e){for(let s=0,n=Ae.length;s<n;s+=1){let r=Ae[s];if(r.condition(t,e))return new r(t,e)}return new ze(t,e)}const de={AND:"$and",OR:"$or"},xe={PATH:"$path",PATTERN:"$val"},Ee=t=>!!(t[de.AND]||t[de.OR]),Nt=t=>!!t[xe.PATH],Rt=t=>!q(t)&&Te(t)&&!Ee(t),Ne=t=>({[de.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function Ve(t,e,{auto:s=!0}={}){const n=r=>{let i=Object.keys(r);const c=Nt(r);if(!c&&i.length>1&&!Ee(r))return n(Ne(r));if(Rt(r)){const u=c?r[xe.PATH]:i[0],l=c?r[xe.PATTERN]:r[u];if(!X(l))throw new Error(it(u));const h={keyId:pe(u),pattern:l};return s&&(h.searcher=ye(l,e)),h}let a={children:[],operator:i[0]};return i.forEach(u=>{const l=r[u];q(l)&&l.forEach(h=>{a.children.push(n(h))})}),a};return Ee(t)||(t=Ne(t)),n(t)}function _t(t,{ignoreFieldNorm:e=p.ignoreFieldNorm}){t.forEach(s=>{let n=1;s.matches.forEach(({key:r,norm:i,score:c})=>{const a=r?r.weight:null;n*=Math.pow(c===0&&a?Number.EPSILON:c,(a||1)*(e?1:i))}),s.score=n})}function Lt(t,e){const s=t.matches;e.matches=[],O(s)&&s.forEach(n=>{if(!O(n.indices)||!n.indices.length)return;const{indices:r,value:i}=n;let c={indices:r,value:i};n.key&&(c.key=n.key.src),n.idx>-1&&(c.refIndex=n.idx),e.matches.push(c)})}function $t(t,e){e.score=t.score}function Tt(t,e,{includeMatches:s=p.includeMatches,includeScore:n=p.includeScore}={}){const r=[];return s&&r.push(Lt),n&&r.push($t),t.map(i=>{const{idx:c}=i,a={item:e[c],refIndex:c};return r.length&&r.forEach(u=>{u(i,a)}),a})}class J{constructor(e,s={},n){this.options={...p,...s},this.options.useExtendedSearch,this._keyStore=new ut(this.options.keys),this.setCollection(e,n)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof we))throw new Error(rt);this._myIndex=s||Oe(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){O(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let n=0,r=this._docs.length;n<r;n+=1){const i=this._docs[n];e(i,n)&&(this.removeAt(n),n-=1,r-=1,s.push(i))}return s}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:s=-1}={}){const{includeMatches:n,includeScore:r,shouldSort:i,sortFn:c,ignoreFieldNorm:a}=this.options;let u=X(e)?X(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return _t(u,{ignoreFieldNorm:a}),i&&u.sort(c),$e(s)&&s>-1&&(u=u.slice(0,s)),Tt(u,this._docs,{includeMatches:n,includeScore:r})}_searchStringList(e){const s=ye(e,this.options),{records:n}=this._myIndex,r=[];return n.forEach(({v:i,i:c,n:a})=>{if(!O(i))return;const{isMatch:u,score:l,indices:h}=s.searchIn(i);u&&r.push({item:i,idx:c,matches:[{score:l,value:i,norm:a,indices:h}]})}),r}_searchLogical(e){const s=Ve(e,this.options),n=(a,u,l)=>{if(!a.children){const{keyId:f,searcher:m}=a,g=this._findMatches({key:this._keyStore.get(f),value:this._myIndex.getValueForItemAtKeyId(u,f),searcher:m});return g&&g.length?[{idx:l,item:u,matches:g}]:[]}const h=[];for(let f=0,m=a.children.length;f<m;f+=1){const g=a.children[f],y=n(g,u,l);if(y.length)h.push(...y);else if(a.operator===de.AND)return[]}return h},r=this._myIndex.records,i={},c=[];return r.forEach(({$:a,i:u})=>{if(O(a)){let l=n(s,a,u);l.length&&(i[u]||(i[u]={idx:u,item:a,matches:[]},c.push(i[u])),l.forEach(({matches:h})=>{i[u].matches.push(...h)}))}}),c}_searchObjectList(e){const s=ye(e,this.options),{keys:n,records:r}=this._myIndex,i=[];return r.forEach(({$:c,i:a})=>{if(!O(c))return;let u=[];n.forEach((l,h)=>{u.push(...this._findMatches({key:l,value:c[h],searcher:s}))}),u.length&&i.push({idx:a,item:c,matches:u})}),i}_findMatches({key:e,value:s,searcher:n}){if(!O(s))return[];let r=[];if(q(s))s.forEach(({v:i,i:c,n:a})=>{if(!O(i))return;const{isMatch:u,score:l,indices:h}=n.searchIn(i);u&&r.push({score:l,key:e,value:i,idx:c,norm:a,indices:h})});else{const{v:i,n:c}=s,{isMatch:a,score:u,indices:l}=n.searchIn(i);a&&r.push({score:u,key:e,value:i,norm:c,indices:l})}return r}}J.version="7.1.0";J.createIndex=Oe;J.parseIndex=At;J.config=p;J.parseQuery=Ve;jt(kt);const Re={".ts":"file-code",".tsx":"atom",".js":"file-code",".jsx":"atom",".py":"file-code",".rs":"file-code",".go":"file-code",".md":"file-text",".json":"clipboard",".yaml":"gear",".yml":"gear",".css":"palette",".scss":"palette",".html":"globe",".sql":"database",".sh":"terminal",".env":"lock",".toml":"gear",".lock":"lock",default:"file-text"};function Pt(t){switch(t){case"scout":return"class-scout";case"builder":return"class-builder";case"debugger":return"class-debugger";case"architect":return"class-architect";case"warrior":return"class-warrior";case"support":return"class-support";case"boss":return"class-boss";default:return"class-default"}}function Kt(t,e=16){var r;const s="."+(((r=t.split(".").pop())==null?void 0:r.toLowerCase())??""),n=Re[s]||Re.default;return d.jsx(H,{name:n,size:e})}function Jt(t,e=16){return d.jsx(H,{name:Pt(t),size:e,weight:"fill"})}function Ue(t){const e=Math.floor(t/1e3),s=Math.floor(e/60),n=Math.floor(s/60),r=Math.floor(n/24);return r>0?`${r}d ${n%24}h ago`:n>0?`${n}h ${s%60}m ago`:s>0?`${s}m ago`:"just now"}function Xt(t){const s=Date.now()-t;return Ue(s)}function _e(t){switch(t){case"agent":return"Agent";case"command":return"Command";case"area":return"Area";case"modified-file":return"Changed";case"building":return"Server";default:return t}}const Le=["command","agent","building","area","modified-file"];function Ot({isOpen:t,onClose:e,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:r,onOpenFileExplorer:i,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=He(),f=Je(),m=Xe(),g=Ze(),y=A.useRef(e);y.current=e;const b=A.useRef(s);b.current=s;const k=A.useRef(n);k.current=n;const S=A.useRef(r);S.current=r;const _=A.useRef(i);_.current=i;const W=A.useRef(c);W.current=c;const z=A.useRef(a);z.current=a;const re=A.useRef(u);re.current=u;const G=A.useRef(l);G.current=l;const[x,E]=A.useState(""),[I,$]=A.useState(0);A.useEffect(()=>{t&&(E(""),$(0))},[t]);const T=ee.getShortcuts(),V=A.useMemo(()=>{if(!t)return[];const o=T.find(F=>F.id==="spawn-agent"),w=T.find(F=>F.id==="toggle-commander");return[{id:"cmd-spawn",type:"command",title:"Spawn New Agent",subtitle:o?be(o):"Alt+N",icon:d.jsx(H,{name:"plus",size:16}),action:()=>{y.current(),b.current()}},{id:"cmd-commander",type:"command",title:"Commander View",subtitle:w?be(w):"Ctrl+K",icon:d.jsx(H,{name:"dashboard",size:16}),action:()=>{y.current(),k.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:d.jsx(H,{name:"gear",size:16}),action:()=>{y.current(),S.current()}},{id:"cmd-monitoring",type:"command",title:"Monitoring & Logs",subtitle:"Triggers, workflows, events",icon:d.jsx(H,{name:"chart-line",size:16}),action:()=>{var F;y.current(),(F=G.current)==null||F.call(G)}}]},[t,T]),oe=A.useMemo(()=>t?Array.from(h.values()).map(o=>{const w=(g||[]).filter(K=>K.agentId===o.id).map(K=>K.filePath),F=[...new Set(w)],M=F.map(K=>K.split("/").pop()||K),v=[];o.lastAssignedTask&&v.push(o.lastAssignedTask);const N=`${o.class} • ${o.status} • ${o.cwd}`;let D=`${o.name} ${N}`;M.length>0&&(D+=` ${M.join(" ")} ${F.join(" ")}`),v.length>0&&(D+=` ${v.join(" ")}`);const P=Date.now()-o.lastActivity;let Q;return o.lastAssignedTask&&(o.lastAssignedTask.length>150?Q=o.lastAssignedTask.slice(0,150)+"...":Q=o.lastAssignedTask),{id:`agent-${o.id}`,type:"agent",title:o.name,subtitle:N,lastUserInput:Q,timeAway:P,icon:d.jsx(qe,{agent:o,size:20}),_searchText:D,_modifiedFiles:F,_userQueries:v,action:()=>{y.current(),ee.selectAgent(o.id),ee.getState().viewMode!=="flat"&&ee.requestTerminalExpand()}}}):[],[t,h,g]),j=A.useMemo(()=>t?Array.from(f.values()).map(o=>{var w;return{id:`area-${o.id}`,type:"area",title:o.name,subtitle:`${o.assignedAgentIds.length} agents • ${((w=o.directories)==null?void 0:w.length)||0} folders`,icon:d.jsx(H,{name:"map",size:16}),action:()=>{y.current(),ee.selectArea(o.id)}}}):[],[t,f]),Z=A.useMemo(()=>t?Array.from(m.values()).filter(o=>o.type==="server"||o.type==="boss"||o.type==="database").map(o=>{var D,P,Q,K;const w=o.status==="running"?"#4ade80":o.status==="stopped"?"#f87171":"#facc15",F=o.type==="boss"?"crown":o.type==="database"?"database":"desktop";let v=`${o.type==="boss"?"Boss":o.type==="database"?"Database":"Server"} • ${o.status}`;if(o.type==="database"&&((P=(D=o.database)==null?void 0:D.connections)!=null&&P.length)){const L=o.database.connections[0];v+=` • ${L.engine} @ ${L.host}`}else o.cwd&&(v+=` • ${o.cwd}`);let N=`${o.name} ${o.type} ${o.status} ${o.cwd||""} ${((Q=o.pm2)==null?void 0:Q.name)||""}`;if(o.type==="database"&&((K=o.database)!=null&&K.connections))for(const L of o.database.connections)N+=` ${L.name} ${L.engine} ${L.host} ${L.database||""} mysql postgresql sql`;return{id:`building-${o.id}`,type:"building",title:o.name,subtitle:v,icon:d.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[d.jsx(H,{name:"status-pending",size:10,weight:"fill",color:w}),d.jsx(H,{name:F,size:16})]}),_searchText:N,action:()=>{var L;y.current(),o.type==="boss"?z.current(o.id):o.type==="database"?re.current(o.id):(L=o.pm2)!=null&&L.enabled&&W.current(o.id)}}}):[],[t,m]),ae=A.useMemo(()=>{if(!t)return[];const o=g||[],w=new Set,F=[];for(const M of o){if(w.has(M.filePath))continue;w.add(M.filePath);const v=M.filePath.split("/").pop()||M.filePath,N=M.action==="created"?"Created":M.action==="modified"?"Modified":M.action==="deleted"?"Deleted":"Read";if(F.push({id:`modified-${M.filePath}-${M.timestamp}`,type:"modified-file",title:v,subtitle:`${N} by ${M.agentName} • ${M.filePath}`,matchedText:M.filePath,icon:M.action==="deleted"?d.jsx(H,{name:"trash",size:16}):Kt(M.filePath),action:()=>{y.current();const D=Array.from(ee.getState().areas.values());for(const P of D)for(const Q of P.directories||[])if(M.filePath.startsWith(Q)){ee.setFileViewerPath(M.filePath),_.current(P.id);return}ee.selectAgent(M.agentId)}}),F.length>=50)break}return F},[t,g]),Fe=A.useMemo(()=>new J(oe,{keys:["title","subtitle","_searchText","lastUserInput"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[oe]),Me=A.useMemo(()=>new J(V,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[V]),Ie=A.useMemo(()=>new J(j,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[j]),De=A.useMemo(()=>new J(ae,{keys:["title","subtitle","matchedText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[ae]),Be=A.useMemo(()=>new J(Z,{keys:["title","subtitle","_searchText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[Z]),U=A.useMemo(()=>{if(!x.trim()){const C=[];C.push(...Z);const B=[...oe].sort((R,Y)=>{const ie=R.timeAway??0,ce=Y.timeAway??0;return ie-ce});C.push(...B),C.push(...V.slice(0,2)),C.push(...j.slice(0,2));const se={};return Le.forEach((R,Y)=>{se[R]=Y}),C.sort((R,Y)=>(se[R.type]??999)-(se[Y.type]??999)),C}const o=x.toLowerCase(),w=Fe.search(x).slice(0,8),F=Me.search(x).slice(0,3),M=Ie.search(x).slice(0,2),v=De.search(x).slice(0,3),N=Be.search(x).filter(C=>{const B=C.score??1;return`${C.item.title} ${C.item.subtitle||""} ${C.item._searchText||""}`.toLowerCase().includes(o)||B<=.2}).slice(0,4),D=[],P=[],Q=[];for(const C of w){const B={...C.item};if(B._modifiedFiles&&B._modifiedFiles.length>0){const R=B._modifiedFiles.filter(Y=>{var ue;const ie=((ue=Y.split("/").pop())==null?void 0:ue.toLowerCase())||"",ce=Y.toLowerCase();return ie.includes(o)||ce.includes(o)});R.length>0&&(B.matchedFiles=R)}if(B._userQueries&&B._userQueries.length>0){const R=B._userQueries.find(Y=>Y.toLowerCase().includes(o));if(R)if(R.length>200){const ie=R.toLowerCase().indexOf(o),ce=Math.max(0,ie-60),ue=Math.min(R.length,ie+o.length+100);B.matchedQuery=(ce>0?"...":"")+R.slice(ce,ue)+(ue<R.length?"...":"")}else B.matchedQuery=R}const se=B.title.toLowerCase();se===o||se.startsWith(o)?P.push(B):Q.push(B)}const K=(C,B)=>(C.timeAway??Number.POSITIVE_INFINITY)-(B.timeAway??Number.POSITIVE_INFINITY);P.sort(K),Q.sort(K);for(const C of P)D.push(C);for(const C of N)D.push(C.item);for(const C of Q)D.push(C);for(const C of F)D.push(C.item);for(const C of M)D.push(C.item);for(const C of v)D.push(C.item);const L={};return Le.forEach((C,B)=>{L[C]=B}),D.sort((C,B)=>(L[C.type]??999)-(L[B.type]??999)),D},[x,Fe,Me,Ie,De,Be,V,oe,j,Z]);A.useEffect(()=>{I>=U.length&&$(Math.max(0,U.length-1))},[U.length,I]);const Ye=A.useCallback(o=>{if(o.altKey&&!o.ctrlKey&&!o.metaKey&&(o.key==="p"||o.key==="n"||o.key==="P"||o.key==="N")){o.preventDefault(),o.stopPropagation(),o.nativeEvent.stopImmediatePropagation();const w=o.key.toLowerCase();$(w==="p"?F=>F>0?F-1:U.length-1:F=>F<U.length-1?F+1:0);return}switch(o.key){case"Escape":o.preventDefault(),y.current();break;case"ArrowUp":o.preventDefault(),$(w=>w>0?w-1:U.length-1);break;case"ArrowDown":o.preventDefault(),$(w=>w<U.length-1?w+1:0);break;case"Enter":o.preventDefault(),U[I]&&U[I].action();break}},[U,I]),Ge=A.useCallback((o,w)=>{if(!w||!o)return o;const F=o.toLowerCase(),M=w.toLowerCase(),v=[];let N=0,D=F.indexOf(M),P=0;for(;D!==-1;)D>N&&v.push(o.slice(N,D)),v.push(fe.createElement("mark",{key:P++,className:"spotlight-highlight"},o.slice(D,D+w.length))),N=D+w.length,D=F.indexOf(M,N);return N<o.length&&v.push(o.slice(N)),v.length>0?fe.createElement(fe.Fragment,null,...v):o},[]);return{query:x,setQuery:E,selectedIndex:I,setSelectedIndex:$,results:U,handleKeyDown:Ye,highlightMatch:Ge}}const zt=A.forwardRef(function({query:e,onQueryChange:s,onKeyDown:n,onResetSelection:r},i){const{t:c}=Ce(["common"]);return d.jsxs("div",{className:"spotlight-input-wrapper",children:[d.jsx("span",{className:"spotlight-search-icon",children:"⌘"}),d.jsx("input",{ref:i,type:"text",className:"spotlight-input",placeholder:c("common:search.spotlightPlaceholder"),value:e,onChange:a=>{s(a.target.value),r()},onKeyDown:n,autoFocus:!0,spellCheck:!1}),d.jsxs("div",{className:"spotlight-input-hints",children:[d.jsx("span",{className:"spotlight-shortcut-hint",children:"↑↓"}),d.jsx("span",{className:"spotlight-shortcut-hint",children:"Enter"}),d.jsx("span",{className:"spotlight-shortcut-hint",children:"Esc"})]})]})}),Qt=A.memo(function({result:e,isSelected:s,query:n,highlightMatch:r,onClick:i,onMouseEnter:c}){const a=e.activityText||e.matchedFiles&&e.matchedFiles.length>0||e.matchedQuery;return d.jsxs("div",{className:`spotlight-item ${s?"selected":""} ${e.activityText?"has-activity":""}`,onClick:i,onMouseEnter:c,role:"option","aria-selected":s,children:[d.jsx("span",{className:"spotlight-item-icon","aria-hidden":"true",children:e.icon}),d.jsxs("div",{className:"spotlight-item-content",children:[d.jsxs("div",{className:"spotlight-item-header",children:[d.jsx("span",{className:"spotlight-item-title",children:r(e.title,n)}),d.jsx("span",{className:`spotlight-item-type ${e.type}`,"aria-label":_e(e.type),children:_e(e.type)})]}),e.subtitle&&d.jsx("span",{className:"spotlight-item-subtitle",children:r(e.subtitle,n)}),e.activityText&&d.jsx("span",{className:"spotlight-item-activity",children:r(e.activityText,n)}),a&&d.jsxs("div",{className:"spotlight-item-details",children:[e.matchedFiles&&e.matchedFiles.length>0&&d.jsx("span",{className:"spotlight-item-files",children:e.matchedFiles.map((u,l)=>d.jsxs("span",{className:"file-badge",children:[l>0&&d.jsx("span",{className:"file-separator",children:"•"}),r(u.split("/").pop()||u,n)]},u))}),e.matchedQuery&&d.jsx("span",{className:"spotlight-item-query",children:r(e.matchedQuery,n)})]}),e.timeAway!==void 0&&d.jsx("span",{className:"spotlight-item-time",children:d.jsxs("span",{className:"spotlight-time-away",children:["Idle: ",Ue(e.timeAway)]})}),e.lastUserInput&&!e.matchedQuery&&d.jsxs("span",{className:"spotlight-item-last-input",children:['"',r(e.lastUserInput,n),'"']})]})]})}),Wt=A.forwardRef(function({results:e,selectedIndex:s,query:n,highlightMatch:r,onSelectIndex:i},c){const{t:a}=Ce(["terminal"]),u=A.useRef(!1);A.useEffect(()=>{u.current=!1},[e]),A.useEffect(()=>{const f=typeof c=="function"?null:c==null?void 0:c.current;if(!f)return;const m=()=>{u.current=!0};return f.addEventListener("mousemove",m),()=>{f.removeEventListener("mousemove",m)}},[c,e]);const l={command:a("terminal:spotlight.categories.commands"),agent:a("terminal:spotlight.categories.agents"),building:a("terminal:spotlight.categories.infrastructure"),area:a("terminal:spotlight.categories.areas"),"modified-file":a("terminal:spotlight.categories.modifiedFiles")},h=A.useMemo(()=>{const f=[];let m=null,g=[];return e.forEach((y,b)=>{y.type!==m&&(m!==null&&g.length>0&&f.push([m,g]),m=y.type,g=[]),g.push({result:y,index:b})}),m!==null&&g.length>0&&f.push([m,g]),f},[e]);return A.useEffect(()=>{if(!c||typeof c=="function")return;const f=c.current;if(!f)return;const m=f.querySelector(".spotlight-item.selected");m&&m.scrollIntoView({block:"nearest",behavior:"smooth"})},[s,c]),e.length===0?d.jsx("div",{className:"spotlight-results",ref:c,children:d.jsx("div",{className:"spotlight-empty",children:a("terminal:spotlight.noResults")})}):d.jsx("div",{className:"spotlight-results",ref:c,children:h.map(([f,m])=>d.jsxs("div",{children:[h.length>1&&d.jsx("div",{className:"spotlight-category-header",children:l[f]||f}),m.map(({result:g,index:y})=>d.jsx(Qt,{result:g,isSelected:y===s,query:n,highlightMatch:r,onClick:()=>g.action(),onMouseEnter:()=>{u.current&&i(y)}},g.id))]},f))})}),Vt=A.memo(function(){const{t:e}=Ce(["terminal"]);return d.jsxs("div",{className:"spotlight-footer",children:[d.jsxs("div",{className:"spotlight-footer-left",children:[d.jsxs("span",{className:"spotlight-footer-hint",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," ",d.jsx("kbd",{children:"Alt+N"}),d.jsx("kbd",{children:"Alt+P"})," ",e("terminal:spotlight.navigate")]}),d.jsxs("span",{className:"spotlight-footer-hint",children:[d.jsx("kbd",{children:"Enter"})," ",e("terminal:spotlight.select")]})]}),d.jsx("div",{className:"spotlight-footer-right",children:d.jsxs("span",{className:"spotlight-footer-hint",children:[d.jsx("kbd",{children:"Esc"})," ",e("common:buttons.close")]})})]})}),Ut=768;function Zt({isOpen:t,onClose:e,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:r,onOpenFileExplorer:i,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=A.useRef(null),f=A.useRef(null),m=A.useRef(null),g=A.useRef(0),{query:y,setQuery:b,selectedIndex:k,setSelectedIndex:S,results:_,handleKeyDown:W,highlightMatch:z}=Ot({isOpen:t,onClose:e,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:r,onOpenFileExplorer:i,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l});g.current=_.length,A.useEffect(()=>{t&&setTimeout(()=>{var x;(x=h.current)==null||x.focus()},50)},[t]),A.useEffect(()=>{if(!t)return;const x=window.visualViewport;if(!x||window.innerWidth>Ut)return;const E=()=>{const I=f.current;I&&(I.style.height=`${x.height}px`,I.style.top=`${x.offsetTop}px`)};return E(),x.addEventListener("resize",E),x.addEventListener("scroll",E),()=>{x.removeEventListener("resize",E),x.removeEventListener("scroll",E);const I=f.current;I&&(I.style.height="",I.style.top="")}},[t]),A.useEffect(()=>{if(!t)return;const x=E=>{if(E.key==="Escape"){E.preventDefault(),E.stopPropagation(),E.stopImmediatePropagation(),e();return}if(E.altKey&&!E.ctrlKey&&!E.metaKey&&(E.key==="n"||E.key==="p"||E.key==="N"||E.key==="P")){E.preventDefault(),E.stopPropagation(),E.stopImmediatePropagation();const I=E.key.toLowerCase(),$=g.current;S(I==="p"?T=>T>0?T-1:$-1:T=>T<$-1?T+1:0);return}};return window.addEventListener("keydown",x,{capture:!0}),()=>{window.removeEventListener("keydown",x,{capture:!0})}},[t,e]);const re=A.useCallback(x=>{x.target===x.currentTarget&&e()},[e]),G=A.useCallback(()=>{S(0)},[S]);return t?d.jsx("div",{ref:f,className:"spotlight-overlay",onClick:re,children:d.jsxs("div",{className:"spotlight-modal",children:[d.jsx(zt,{ref:h,query:y,onQueryChange:b,onKeyDown:W,onResetSelection:G}),d.jsx(Wt,{ref:m,results:_,selectedIndex:k,query:y,highlightMatch:z,onSelectIndex:S}),d.jsx(Vt,{})]})}):null}export{Re as FILE_ICON_NAMES,Zt as Spotlight,Vt as SpotlightFooter,zt as SpotlightInput,Qt as SpotlightItem,Wt as SpotlightResults,Ue as formatDuration,Xt as formatRelativeTime,Jt as getAgentIcon,Kt as getFileIconFromPath,_e as getTypeLabel,Ot as useSpotlightSearch};
1
+ import{j as d,I as H,ah as He,U as Je,W as Xe,bX as Ze,r as A,s as ee,bY as be,_ as qe,ab as fe,u as Ce}from"./main-CBiZdw6w.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function q(t){return Array.isArray?Array.isArray(t):Pe(t)==="[object Array]"}function et(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function tt(t){return t==null?"":et(t)}function X(t){return typeof t=="string"}function $e(t){return typeof t=="number"}function st(t){return t===!0||t===!1||nt(t)&&Pe(t)=="[object Boolean]"}function Te(t){return typeof t=="object"}function nt(t){return Te(t)&&t!==null}function O(t){return t!=null}function me(t){return!t.trim().length}function Pe(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const rt="Incorrect 'index' type",it=t=>`Invalid value for key ${t}`,ct=t=>`Pattern length exceeds max of ${t}.`,ot=t=>`Missing ${t} property in key`,at=t=>`Property 'weight' in key '${t}' must be a positive integer`,ve=Object.prototype.hasOwnProperty;class ut{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(n=>{let r=Ke(n);this._keys.push(r),this._keyMap[r.id]=r,s+=r.weight}),this._keys.forEach(n=>{n.weight/=s})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Ke(t){let e=null,s=null,n=null,r=1,i=null;if(X(t)||q(t))n=t,e=Se(t),s=pe(t);else{if(!ve.call(t,"name"))throw new Error(ot("name"));const c=t.name;if(n=c,ve.call(t,"weight")&&(r=t.weight,r<=0))throw new Error(at(c));e=Se(c),s=pe(c),i=t.getFn}return{path:e,id:s,weight:r,src:n,getFn:i}}function Se(t){return q(t)?t:t.split(".")}function pe(t){return q(t)?t.join("."):t}function lt(t,e){let s=[],n=!1;const r=(i,c,a)=>{if(O(i))if(!c[a])s.push(i);else{let u=c[a];const l=i[u];if(!O(l))return;if(a===c.length-1&&(X(l)||$e(l)||st(l)))s.push(tt(l));else if(q(l)){n=!0;for(let h=0,f=l.length;h<f;h+=1)r(l[h],c,a+1)}else c.length&&r(l,c,a+1)}};return r(t,X(e)?e.split("."):e,0),n?s:s[0]}const ht={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},dt={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},ft={location:0,threshold:.6,distance:100},mt={useExtendedSearch:!1,getFn:lt,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var p={...dt,...ht,...ft,...mt};const pt=/[^ ]+/g;function gt(t=1,e=3){const s=new Map,n=Math.pow(10,e);return{get(r){const i=r.match(pt).length;if(s.has(i))return s.get(i);const c=1/Math.pow(i,.5*t),a=parseFloat(Math.round(c*n)/n);return s.set(i,a),a},clear(){s.clear()}}}class we{constructor({getFn:e=p.getFn,fieldNormWeight:s=p.fieldNormWeight}={}){this.norm=gt(s,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((s,n)=>{this._keysMap[s.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,X(this.docs[0])?this.docs.forEach((e,s)=>{this._addString(e,s)}):this.docs.forEach((e,s)=>{this._addObject(e,s)}),this.norm.clear())}add(e){const s=this.size();X(e)?this._addString(e,s):this._addObject(e,s)}removeAt(e){this.records.splice(e,1);for(let s=e,n=this.size();s<n;s+=1)this.records[s].i-=1}getValueForItemAtKeyId(e,s){return e[this._keysMap[s]]}size(){return this.records.length}_addString(e,s){if(!O(e)||me(e))return;let n={v:e,i:s,n:this.norm.get(e)};this.records.push(n)}_addObject(e,s){let n={i:s,$:{}};this.keys.forEach((r,i)=>{let c=r.getFn?r.getFn(e):this.getFn(e,r.path);if(O(c)){if(q(c)){let a=[];const u=[{nestedArrIndex:-1,value:c}];for(;u.length;){const{nestedArrIndex:l,value:h}=u.pop();if(O(h))if(X(h)&&!me(h)){let f={v:h,i:l,n:this.norm.get(h)};a.push(f)}else q(h)&&h.forEach((f,m)=>{u.push({nestedArrIndex:m,value:f})})}n.$[i]=a}else if(X(c)&&!me(c)){let a={v:c,n:this.norm.get(c)};n.$[i]=a}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function Oe(t,e,{getFn:s=p.getFn,fieldNormWeight:n=p.fieldNormWeight}={}){const r=new we({getFn:s,fieldNormWeight:n});return r.setKeys(t.map(Ke)),r.setSources(e),r.create(),r}function At(t,{getFn:e=p.getFn,fieldNormWeight:s=p.fieldNormWeight}={}){const{keys:n,records:r}=t,i=new we({getFn:e,fieldNormWeight:s});return i.setKeys(n),i.setIndexRecords(r),i}function le(t,{errors:e=0,currentLocation:s=0,expectedLocation:n=0,distance:r=p.distance,ignoreLocation:i=p.ignoreLocation}={}){const c=e/t.length;if(i)return c;const a=Math.abs(n-s);return r?c+a/r:a?1:c}function yt(t=[],e=p.minMatchCharLength){let s=[],n=-1,r=-1,i=0;for(let c=t.length;i<c;i+=1){let a=t[i];a&&n===-1?n=i:!a&&n!==-1&&(r=i-1,r-n+1>=e&&s.push([n,r]),n=-1)}return t[i-1]&&i-n>=e&&s.push([n,i-1]),s}const ne=32;function xt(t,e,s,{location:n=p.location,distance:r=p.distance,threshold:i=p.threshold,findAllMatches:c=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,includeMatches:u=p.includeMatches,ignoreLocation:l=p.ignoreLocation}={}){if(e.length>ne)throw new Error(ct(ne));const h=e.length,f=t.length,m=Math.max(0,Math.min(n,f));let g=i,y=m;const b=a>1||u,k=b?Array(f):[];let S;for(;(S=t.indexOf(e,y))>-1;){let x=le(e,{currentLocation:S,expectedLocation:m,distance:r,ignoreLocation:l});if(g=Math.min(x,g),y=S+h,b){let E=0;for(;E<h;)k[S+E]=1,E+=1}}y=-1;let _=[],W=1,z=h+f;const re=1<<h-1;for(let x=0;x<h;x+=1){let E=0,I=z;for(;E<I;)le(e,{errors:x,currentLocation:m+I,expectedLocation:m,distance:r,ignoreLocation:l})<=g?E=I:z=I,I=Math.floor((z-E)/2+E);z=I;let $=Math.max(1,m-I+1),T=c?f:Math.min(m+I,f)+h,V=Array(T+2);V[T+1]=(1<<x)-1;for(let j=T;j>=$;j-=1){let Z=j-1,ae=s[t.charAt(Z)];if(b&&(k[Z]=+!!ae),V[j]=(V[j+1]<<1|1)&ae,x&&(V[j]|=(_[j+1]|_[j])<<1|1|_[j+1]),V[j]&re&&(W=le(e,{errors:x,currentLocation:Z,expectedLocation:m,distance:r,ignoreLocation:l}),W<=g)){if(g=W,y=Z,y<=m)break;$=Math.max(1,2*m-y)}}if(le(e,{errors:x+1,currentLocation:m,expectedLocation:m,distance:r,ignoreLocation:l})>g)break;_=V}const G={isMatch:y>=0,score:Math.max(.001,W)};if(b){const x=yt(k,a);x.length?u&&(G.indices=x):G.isMatch=!1}return G}function Et(t){let e={};for(let s=0,n=t.length;s<n;s+=1){const r=t.charAt(s);e[r]=(e[r]||0)|1<<n-s-1}return e}const he=String.prototype.normalize?(t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(t=>t);class ze{constructor(e,{location:s=p.location,threshold:n=p.threshold,distance:r=p.distance,includeMatches:i=p.includeMatches,findAllMatches:c=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,isCaseSensitive:u=p.isCaseSensitive,ignoreDiacritics:l=p.ignoreDiacritics,ignoreLocation:h=p.ignoreLocation}={}){if(this.options={location:s,threshold:n,distance:r,includeMatches:i,findAllMatches:c,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h},e=u?e:e.toLowerCase(),e=l?he(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const f=(g,y)=>{this.chunks.push({pattern:g,alphabet:Et(g),startIndex:y})},m=this.pattern.length;if(m>ne){let g=0;const y=m%ne,b=m-y;for(;g<b;)f(this.pattern.substr(g,ne),g),g+=ne;if(y){const k=m-ne;f(this.pattern.substr(k),k)}}else f(this.pattern,0)}searchIn(e){const{isCaseSensitive:s,ignoreDiacritics:n,includeMatches:r}=this.options;if(e=s?e:e.toLowerCase(),e=n?he(e):e,this.pattern===e){let b={isMatch:!0,score:0};return r&&(b.indices=[[0,e.length-1]]),b}const{location:i,distance:c,threshold:a,findAllMatches:u,minMatchCharLength:l,ignoreLocation:h}=this.options;let f=[],m=0,g=!1;this.chunks.forEach(({pattern:b,alphabet:k,startIndex:S})=>{const{isMatch:_,score:W,indices:z}=xt(e,b,k,{location:i+S,distance:c,threshold:a,findAllMatches:u,minMatchCharLength:l,includeMatches:r,ignoreLocation:h});_&&(g=!0),m+=W,_&&z&&(f=[...f,...z])});let y={isMatch:g,score:g?m/this.chunks.length:1};return g&&r&&(y.indices=f),y}}class te{constructor(e){this.pattern=e}static isMultiMatch(e){return ke(e,this.multiRegex)}static isSingleMatch(e){return ke(e,this.singleRegex)}search(){}}function ke(t,e){const s=t.match(e);return s?s[1]:null}class Ct extends te{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const s=e===this.pattern;return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class wt extends te{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const n=e.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class Ft extends te{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const s=e.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Mt extends te{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const s=!e.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}}class It extends te{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const s=e.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class Dt extends te{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const s=!e.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}}class Qe extends te{constructor(e,{location:s=p.location,threshold:n=p.threshold,distance:r=p.distance,includeMatches:i=p.includeMatches,findAllMatches:c=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,isCaseSensitive:u=p.isCaseSensitive,ignoreDiacritics:l=p.ignoreDiacritics,ignoreLocation:h=p.ignoreLocation}={}){super(e),this._bitapSearch=new ze(e,{location:s,threshold:n,distance:r,includeMatches:i,findAllMatches:c,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class We extends te{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let s=0,n;const r=[],i=this.pattern.length;for(;(n=e.indexOf(this.pattern,s))>-1;)s=n+i,r.push([n,s-1]);const c=!!r.length;return{isMatch:c,score:c?0:1,indices:r}}}const ge=[Ct,We,Ft,Mt,Dt,It,wt,Qe],je=ge.length,Bt=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,bt="|";function vt(t,e={}){return t.split(bt).map(s=>{let n=s.trim().split(Bt).filter(i=>i&&!!i.trim()),r=[];for(let i=0,c=n.length;i<c;i+=1){const a=n[i];let u=!1,l=-1;for(;!u&&++l<je;){const h=ge[l];let f=h.isMultiMatch(a);f&&(r.push(new h(f,e)),u=!0)}if(!u)for(l=-1;++l<je;){const h=ge[l];let f=h.isSingleMatch(a);if(f){r.push(new h(f,e));break}}}return r})}const St=new Set([Qe.type,We.type]);class kt{constructor(e,{isCaseSensitive:s=p.isCaseSensitive,ignoreDiacritics:n=p.ignoreDiacritics,includeMatches:r=p.includeMatches,minMatchCharLength:i=p.minMatchCharLength,ignoreLocation:c=p.ignoreLocation,findAllMatches:a=p.findAllMatches,location:u=p.location,threshold:l=p.threshold,distance:h=p.distance}={}){this.query=null,this.options={isCaseSensitive:s,ignoreDiacritics:n,includeMatches:r,minMatchCharLength:i,findAllMatches:a,ignoreLocation:c,location:u,threshold:l,distance:h},e=s?e:e.toLowerCase(),e=n?he(e):e,this.pattern=e,this.query=vt(this.pattern,this.options)}static condition(e,s){return s.useExtendedSearch}searchIn(e){const s=this.query;if(!s)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:r,ignoreDiacritics:i}=this.options;e=r?e:e.toLowerCase(),e=i?he(e):e;let c=0,a=[],u=0;for(let l=0,h=s.length;l<h;l+=1){const f=s[l];a.length=0,c=0;for(let m=0,g=f.length;m<g;m+=1){const y=f[m],{isMatch:b,indices:k,score:S}=y.search(e);if(b){if(c+=1,u+=S,n){const _=y.constructor.type;St.has(_)?a=[...a,...k]:a.push(k)}}else{u=0,c=0,a.length=0;break}}if(c){let m={isMatch:!0,score:u/c};return n&&(m.indices=a),m}}return{isMatch:!1,score:1}}}const Ae=[];function jt(...t){Ae.push(...t)}function ye(t,e){for(let s=0,n=Ae.length;s<n;s+=1){let r=Ae[s];if(r.condition(t,e))return new r(t,e)}return new ze(t,e)}const de={AND:"$and",OR:"$or"},xe={PATH:"$path",PATTERN:"$val"},Ee=t=>!!(t[de.AND]||t[de.OR]),Nt=t=>!!t[xe.PATH],Rt=t=>!q(t)&&Te(t)&&!Ee(t),Ne=t=>({[de.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function Ve(t,e,{auto:s=!0}={}){const n=r=>{let i=Object.keys(r);const c=Nt(r);if(!c&&i.length>1&&!Ee(r))return n(Ne(r));if(Rt(r)){const u=c?r[xe.PATH]:i[0],l=c?r[xe.PATTERN]:r[u];if(!X(l))throw new Error(it(u));const h={keyId:pe(u),pattern:l};return s&&(h.searcher=ye(l,e)),h}let a={children:[],operator:i[0]};return i.forEach(u=>{const l=r[u];q(l)&&l.forEach(h=>{a.children.push(n(h))})}),a};return Ee(t)||(t=Ne(t)),n(t)}function _t(t,{ignoreFieldNorm:e=p.ignoreFieldNorm}){t.forEach(s=>{let n=1;s.matches.forEach(({key:r,norm:i,score:c})=>{const a=r?r.weight:null;n*=Math.pow(c===0&&a?Number.EPSILON:c,(a||1)*(e?1:i))}),s.score=n})}function Lt(t,e){const s=t.matches;e.matches=[],O(s)&&s.forEach(n=>{if(!O(n.indices)||!n.indices.length)return;const{indices:r,value:i}=n;let c={indices:r,value:i};n.key&&(c.key=n.key.src),n.idx>-1&&(c.refIndex=n.idx),e.matches.push(c)})}function $t(t,e){e.score=t.score}function Tt(t,e,{includeMatches:s=p.includeMatches,includeScore:n=p.includeScore}={}){const r=[];return s&&r.push(Lt),n&&r.push($t),t.map(i=>{const{idx:c}=i,a={item:e[c],refIndex:c};return r.length&&r.forEach(u=>{u(i,a)}),a})}class J{constructor(e,s={},n){this.options={...p,...s},this.options.useExtendedSearch,this._keyStore=new ut(this.options.keys),this.setCollection(e,n)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof we))throw new Error(rt);this._myIndex=s||Oe(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){O(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let n=0,r=this._docs.length;n<r;n+=1){const i=this._docs[n];e(i,n)&&(this.removeAt(n),n-=1,r-=1,s.push(i))}return s}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:s=-1}={}){const{includeMatches:n,includeScore:r,shouldSort:i,sortFn:c,ignoreFieldNorm:a}=this.options;let u=X(e)?X(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return _t(u,{ignoreFieldNorm:a}),i&&u.sort(c),$e(s)&&s>-1&&(u=u.slice(0,s)),Tt(u,this._docs,{includeMatches:n,includeScore:r})}_searchStringList(e){const s=ye(e,this.options),{records:n}=this._myIndex,r=[];return n.forEach(({v:i,i:c,n:a})=>{if(!O(i))return;const{isMatch:u,score:l,indices:h}=s.searchIn(i);u&&r.push({item:i,idx:c,matches:[{score:l,value:i,norm:a,indices:h}]})}),r}_searchLogical(e){const s=Ve(e,this.options),n=(a,u,l)=>{if(!a.children){const{keyId:f,searcher:m}=a,g=this._findMatches({key:this._keyStore.get(f),value:this._myIndex.getValueForItemAtKeyId(u,f),searcher:m});return g&&g.length?[{idx:l,item:u,matches:g}]:[]}const h=[];for(let f=0,m=a.children.length;f<m;f+=1){const g=a.children[f],y=n(g,u,l);if(y.length)h.push(...y);else if(a.operator===de.AND)return[]}return h},r=this._myIndex.records,i={},c=[];return r.forEach(({$:a,i:u})=>{if(O(a)){let l=n(s,a,u);l.length&&(i[u]||(i[u]={idx:u,item:a,matches:[]},c.push(i[u])),l.forEach(({matches:h})=>{i[u].matches.push(...h)}))}}),c}_searchObjectList(e){const s=ye(e,this.options),{keys:n,records:r}=this._myIndex,i=[];return r.forEach(({$:c,i:a})=>{if(!O(c))return;let u=[];n.forEach((l,h)=>{u.push(...this._findMatches({key:l,value:c[h],searcher:s}))}),u.length&&i.push({idx:a,item:c,matches:u})}),i}_findMatches({key:e,value:s,searcher:n}){if(!O(s))return[];let r=[];if(q(s))s.forEach(({v:i,i:c,n:a})=>{if(!O(i))return;const{isMatch:u,score:l,indices:h}=n.searchIn(i);u&&r.push({score:l,key:e,value:i,idx:c,norm:a,indices:h})});else{const{v:i,n:c}=s,{isMatch:a,score:u,indices:l}=n.searchIn(i);a&&r.push({score:u,key:e,value:i,norm:c,indices:l})}return r}}J.version="7.1.0";J.createIndex=Oe;J.parseIndex=At;J.config=p;J.parseQuery=Ve;jt(kt);const Re={".ts":"file-code",".tsx":"atom",".js":"file-code",".jsx":"atom",".py":"file-code",".rs":"file-code",".go":"file-code",".md":"file-text",".json":"clipboard",".yaml":"gear",".yml":"gear",".css":"palette",".scss":"palette",".html":"globe",".sql":"database",".sh":"terminal",".env":"lock",".toml":"gear",".lock":"lock",default:"file-text"};function Pt(t){switch(t){case"scout":return"class-scout";case"builder":return"class-builder";case"debugger":return"class-debugger";case"architect":return"class-architect";case"warrior":return"class-warrior";case"support":return"class-support";case"boss":return"class-boss";default:return"class-default"}}function Kt(t,e=16){var r;const s="."+(((r=t.split(".").pop())==null?void 0:r.toLowerCase())??""),n=Re[s]||Re.default;return d.jsx(H,{name:n,size:e})}function Jt(t,e=16){return d.jsx(H,{name:Pt(t),size:e,weight:"fill"})}function Ue(t){const e=Math.floor(t/1e3),s=Math.floor(e/60),n=Math.floor(s/60),r=Math.floor(n/24);return r>0?`${r}d ${n%24}h ago`:n>0?`${n}h ${s%60}m ago`:s>0?`${s}m ago`:"just now"}function Xt(t){const s=Date.now()-t;return Ue(s)}function _e(t){switch(t){case"agent":return"Agent";case"command":return"Command";case"area":return"Area";case"modified-file":return"Changed";case"building":return"Server";default:return t}}const Le=["command","agent","building","area","modified-file"];function Ot({isOpen:t,onClose:e,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:r,onOpenFileExplorer:i,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=He(),f=Je(),m=Xe(),g=Ze(),y=A.useRef(e);y.current=e;const b=A.useRef(s);b.current=s;const k=A.useRef(n);k.current=n;const S=A.useRef(r);S.current=r;const _=A.useRef(i);_.current=i;const W=A.useRef(c);W.current=c;const z=A.useRef(a);z.current=a;const re=A.useRef(u);re.current=u;const G=A.useRef(l);G.current=l;const[x,E]=A.useState(""),[I,$]=A.useState(0);A.useEffect(()=>{t&&(E(""),$(0))},[t]);const T=ee.getShortcuts(),V=A.useMemo(()=>{if(!t)return[];const o=T.find(F=>F.id==="spawn-agent"),w=T.find(F=>F.id==="toggle-commander");return[{id:"cmd-spawn",type:"command",title:"Spawn New Agent",subtitle:o?be(o):"Alt+N",icon:d.jsx(H,{name:"plus",size:16}),action:()=>{y.current(),b.current()}},{id:"cmd-commander",type:"command",title:"Commander View",subtitle:w?be(w):"Ctrl+K",icon:d.jsx(H,{name:"dashboard",size:16}),action:()=>{y.current(),k.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:d.jsx(H,{name:"gear",size:16}),action:()=>{y.current(),S.current()}},{id:"cmd-monitoring",type:"command",title:"Monitoring & Logs",subtitle:"Triggers, workflows, events",icon:d.jsx(H,{name:"chart-line",size:16}),action:()=>{var F;y.current(),(F=G.current)==null||F.call(G)}}]},[t,T]),oe=A.useMemo(()=>t?Array.from(h.values()).map(o=>{const w=(g||[]).filter(K=>K.agentId===o.id).map(K=>K.filePath),F=[...new Set(w)],M=F.map(K=>K.split("/").pop()||K),v=[];o.lastAssignedTask&&v.push(o.lastAssignedTask);const N=`${o.class} • ${o.status} • ${o.cwd}`;let D=`${o.name} ${N}`;M.length>0&&(D+=` ${M.join(" ")} ${F.join(" ")}`),v.length>0&&(D+=` ${v.join(" ")}`);const P=Date.now()-o.lastActivity;let Q;return o.lastAssignedTask&&(o.lastAssignedTask.length>150?Q=o.lastAssignedTask.slice(0,150)+"...":Q=o.lastAssignedTask),{id:`agent-${o.id}`,type:"agent",title:o.name,subtitle:N,lastUserInput:Q,timeAway:P,icon:d.jsx(qe,{agent:o,size:20}),_searchText:D,_modifiedFiles:F,_userQueries:v,action:()=>{y.current(),ee.selectAgent(o.id),ee.getState().viewMode!=="flat"&&ee.requestTerminalExpand()}}}):[],[t,h,g]),j=A.useMemo(()=>t?Array.from(f.values()).map(o=>{var w;return{id:`area-${o.id}`,type:"area",title:o.name,subtitle:`${o.assignedAgentIds.length} agents • ${((w=o.directories)==null?void 0:w.length)||0} folders`,icon:d.jsx(H,{name:"map",size:16}),action:()=>{y.current(),ee.selectArea(o.id)}}}):[],[t,f]),Z=A.useMemo(()=>t?Array.from(m.values()).filter(o=>o.type==="server"||o.type==="boss"||o.type==="database").map(o=>{var D,P,Q,K;const w=o.status==="running"?"#4ade80":o.status==="stopped"?"#f87171":"#facc15",F=o.type==="boss"?"crown":o.type==="database"?"database":"desktop";let v=`${o.type==="boss"?"Boss":o.type==="database"?"Database":"Server"} • ${o.status}`;if(o.type==="database"&&((P=(D=o.database)==null?void 0:D.connections)!=null&&P.length)){const L=o.database.connections[0];v+=` • ${L.engine} @ ${L.host}`}else o.cwd&&(v+=` • ${o.cwd}`);let N=`${o.name} ${o.type} ${o.status} ${o.cwd||""} ${((Q=o.pm2)==null?void 0:Q.name)||""}`;if(o.type==="database"&&((K=o.database)!=null&&K.connections))for(const L of o.database.connections)N+=` ${L.name} ${L.engine} ${L.host} ${L.database||""} mysql postgresql sql`;return{id:`building-${o.id}`,type:"building",title:o.name,subtitle:v,icon:d.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[d.jsx(H,{name:"status-pending",size:10,weight:"fill",color:w}),d.jsx(H,{name:F,size:16})]}),_searchText:N,action:()=>{var L;y.current(),o.type==="boss"?z.current(o.id):o.type==="database"?re.current(o.id):(L=o.pm2)!=null&&L.enabled&&W.current(o.id)}}}):[],[t,m]),ae=A.useMemo(()=>{if(!t)return[];const o=g||[],w=new Set,F=[];for(const M of o){if(w.has(M.filePath))continue;w.add(M.filePath);const v=M.filePath.split("/").pop()||M.filePath,N=M.action==="created"?"Created":M.action==="modified"?"Modified":M.action==="deleted"?"Deleted":"Read";if(F.push({id:`modified-${M.filePath}-${M.timestamp}`,type:"modified-file",title:v,subtitle:`${N} by ${M.agentName} • ${M.filePath}`,matchedText:M.filePath,icon:M.action==="deleted"?d.jsx(H,{name:"trash",size:16}):Kt(M.filePath),action:()=>{y.current();const D=Array.from(ee.getState().areas.values());for(const P of D)for(const Q of P.directories||[])if(M.filePath.startsWith(Q)){ee.setFileViewerPath(M.filePath),_.current(P.id);return}ee.selectAgent(M.agentId)}}),F.length>=50)break}return F},[t,g]),Fe=A.useMemo(()=>new J(oe,{keys:["title","subtitle","_searchText","lastUserInput"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[oe]),Me=A.useMemo(()=>new J(V,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[V]),Ie=A.useMemo(()=>new J(j,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[j]),De=A.useMemo(()=>new J(ae,{keys:["title","subtitle","matchedText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[ae]),Be=A.useMemo(()=>new J(Z,{keys:["title","subtitle","_searchText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[Z]),U=A.useMemo(()=>{if(!x.trim()){const C=[];C.push(...Z);const B=[...oe].sort((R,Y)=>{const ie=R.timeAway??0,ce=Y.timeAway??0;return ie-ce});C.push(...B),C.push(...V.slice(0,2)),C.push(...j.slice(0,2));const se={};return Le.forEach((R,Y)=>{se[R]=Y}),C.sort((R,Y)=>(se[R.type]??999)-(se[Y.type]??999)),C}const o=x.toLowerCase(),w=Fe.search(x).slice(0,8),F=Me.search(x).slice(0,3),M=Ie.search(x).slice(0,2),v=De.search(x).slice(0,3),N=Be.search(x).filter(C=>{const B=C.score??1;return`${C.item.title} ${C.item.subtitle||""} ${C.item._searchText||""}`.toLowerCase().includes(o)||B<=.2}).slice(0,4),D=[],P=[],Q=[];for(const C of w){const B={...C.item};if(B._modifiedFiles&&B._modifiedFiles.length>0){const R=B._modifiedFiles.filter(Y=>{var ue;const ie=((ue=Y.split("/").pop())==null?void 0:ue.toLowerCase())||"",ce=Y.toLowerCase();return ie.includes(o)||ce.includes(o)});R.length>0&&(B.matchedFiles=R)}if(B._userQueries&&B._userQueries.length>0){const R=B._userQueries.find(Y=>Y.toLowerCase().includes(o));if(R)if(R.length>200){const ie=R.toLowerCase().indexOf(o),ce=Math.max(0,ie-60),ue=Math.min(R.length,ie+o.length+100);B.matchedQuery=(ce>0?"...":"")+R.slice(ce,ue)+(ue<R.length?"...":"")}else B.matchedQuery=R}const se=B.title.toLowerCase();se===o||se.startsWith(o)?P.push(B):Q.push(B)}const K=(C,B)=>(C.timeAway??Number.POSITIVE_INFINITY)-(B.timeAway??Number.POSITIVE_INFINITY);P.sort(K),Q.sort(K);for(const C of P)D.push(C);for(const C of N)D.push(C.item);for(const C of Q)D.push(C);for(const C of F)D.push(C.item);for(const C of M)D.push(C.item);for(const C of v)D.push(C.item);const L={};return Le.forEach((C,B)=>{L[C]=B}),D.sort((C,B)=>(L[C.type]??999)-(L[B.type]??999)),D},[x,Fe,Me,Ie,De,Be,V,oe,j,Z]);A.useEffect(()=>{I>=U.length&&$(Math.max(0,U.length-1))},[U.length,I]);const Ye=A.useCallback(o=>{if(o.altKey&&!o.ctrlKey&&!o.metaKey&&(o.key==="p"||o.key==="n"||o.key==="P"||o.key==="N")){o.preventDefault(),o.stopPropagation(),o.nativeEvent.stopImmediatePropagation();const w=o.key.toLowerCase();$(w==="p"?F=>F>0?F-1:U.length-1:F=>F<U.length-1?F+1:0);return}switch(o.key){case"Escape":o.preventDefault(),y.current();break;case"ArrowUp":o.preventDefault(),$(w=>w>0?w-1:U.length-1);break;case"ArrowDown":o.preventDefault(),$(w=>w<U.length-1?w+1:0);break;case"Enter":o.preventDefault(),U[I]&&U[I].action();break}},[U,I]),Ge=A.useCallback((o,w)=>{if(!w||!o)return o;const F=o.toLowerCase(),M=w.toLowerCase(),v=[];let N=0,D=F.indexOf(M),P=0;for(;D!==-1;)D>N&&v.push(o.slice(N,D)),v.push(fe.createElement("mark",{key:P++,className:"spotlight-highlight"},o.slice(D,D+w.length))),N=D+w.length,D=F.indexOf(M,N);return N<o.length&&v.push(o.slice(N)),v.length>0?fe.createElement(fe.Fragment,null,...v):o},[]);return{query:x,setQuery:E,selectedIndex:I,setSelectedIndex:$,results:U,handleKeyDown:Ye,highlightMatch:Ge}}const zt=A.forwardRef(function({query:e,onQueryChange:s,onKeyDown:n,onResetSelection:r},i){const{t:c}=Ce(["common"]);return d.jsxs("div",{className:"spotlight-input-wrapper",children:[d.jsx("span",{className:"spotlight-search-icon",children:"⌘"}),d.jsx("input",{ref:i,type:"text",className:"spotlight-input",placeholder:c("common:search.spotlightPlaceholder"),value:e,onChange:a=>{s(a.target.value),r()},onKeyDown:n,autoFocus:!0,spellCheck:!1}),d.jsxs("div",{className:"spotlight-input-hints",children:[d.jsx("span",{className:"spotlight-shortcut-hint",children:"↑↓"}),d.jsx("span",{className:"spotlight-shortcut-hint",children:"Enter"}),d.jsx("span",{className:"spotlight-shortcut-hint",children:"Esc"})]})]})}),Qt=A.memo(function({result:e,isSelected:s,query:n,highlightMatch:r,onClick:i,onMouseEnter:c}){const a=e.activityText||e.matchedFiles&&e.matchedFiles.length>0||e.matchedQuery;return d.jsxs("div",{className:`spotlight-item ${s?"selected":""} ${e.activityText?"has-activity":""}`,onClick:i,onMouseEnter:c,role:"option","aria-selected":s,children:[d.jsx("span",{className:"spotlight-item-icon","aria-hidden":"true",children:e.icon}),d.jsxs("div",{className:"spotlight-item-content",children:[d.jsxs("div",{className:"spotlight-item-header",children:[d.jsx("span",{className:"spotlight-item-title",children:r(e.title,n)}),d.jsx("span",{className:`spotlight-item-type ${e.type}`,"aria-label":_e(e.type),children:_e(e.type)})]}),e.subtitle&&d.jsx("span",{className:"spotlight-item-subtitle",children:r(e.subtitle,n)}),e.activityText&&d.jsx("span",{className:"spotlight-item-activity",children:r(e.activityText,n)}),a&&d.jsxs("div",{className:"spotlight-item-details",children:[e.matchedFiles&&e.matchedFiles.length>0&&d.jsx("span",{className:"spotlight-item-files",children:e.matchedFiles.map((u,l)=>d.jsxs("span",{className:"file-badge",children:[l>0&&d.jsx("span",{className:"file-separator",children:"•"}),r(u.split("/").pop()||u,n)]},u))}),e.matchedQuery&&d.jsx("span",{className:"spotlight-item-query",children:r(e.matchedQuery,n)})]}),e.timeAway!==void 0&&d.jsx("span",{className:"spotlight-item-time",children:d.jsxs("span",{className:"spotlight-time-away",children:["Idle: ",Ue(e.timeAway)]})}),e.lastUserInput&&!e.matchedQuery&&d.jsxs("span",{className:"spotlight-item-last-input",children:['"',r(e.lastUserInput,n),'"']})]})]})}),Wt=A.forwardRef(function({results:e,selectedIndex:s,query:n,highlightMatch:r,onSelectIndex:i},c){const{t:a}=Ce(["terminal"]),u=A.useRef(!1);A.useEffect(()=>{u.current=!1},[e]),A.useEffect(()=>{const f=typeof c=="function"?null:c==null?void 0:c.current;if(!f)return;const m=()=>{u.current=!0};return f.addEventListener("mousemove",m),()=>{f.removeEventListener("mousemove",m)}},[c,e]);const l={command:a("terminal:spotlight.categories.commands"),agent:a("terminal:spotlight.categories.agents"),building:a("terminal:spotlight.categories.infrastructure"),area:a("terminal:spotlight.categories.areas"),"modified-file":a("terminal:spotlight.categories.modifiedFiles")},h=A.useMemo(()=>{const f=[];let m=null,g=[];return e.forEach((y,b)=>{y.type!==m&&(m!==null&&g.length>0&&f.push([m,g]),m=y.type,g=[]),g.push({result:y,index:b})}),m!==null&&g.length>0&&f.push([m,g]),f},[e]);return A.useEffect(()=>{if(!c||typeof c=="function")return;const f=c.current;if(!f)return;const m=f.querySelector(".spotlight-item.selected");m&&m.scrollIntoView({block:"nearest",behavior:"smooth"})},[s,c]),e.length===0?d.jsx("div",{className:"spotlight-results",ref:c,children:d.jsx("div",{className:"spotlight-empty",children:a("terminal:spotlight.noResults")})}):d.jsx("div",{className:"spotlight-results",ref:c,children:h.map(([f,m])=>d.jsxs("div",{children:[h.length>1&&d.jsx("div",{className:"spotlight-category-header",children:l[f]||f}),m.map(({result:g,index:y})=>d.jsx(Qt,{result:g,isSelected:y===s,query:n,highlightMatch:r,onClick:()=>g.action(),onMouseEnter:()=>{u.current&&i(y)}},g.id))]},f))})}),Vt=A.memo(function(){const{t:e}=Ce(["terminal"]);return d.jsxs("div",{className:"spotlight-footer",children:[d.jsxs("div",{className:"spotlight-footer-left",children:[d.jsxs("span",{className:"spotlight-footer-hint",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," ",d.jsx("kbd",{children:"Alt+N"}),d.jsx("kbd",{children:"Alt+P"})," ",e("terminal:spotlight.navigate")]}),d.jsxs("span",{className:"spotlight-footer-hint",children:[d.jsx("kbd",{children:"Enter"})," ",e("terminal:spotlight.select")]})]}),d.jsx("div",{className:"spotlight-footer-right",children:d.jsxs("span",{className:"spotlight-footer-hint",children:[d.jsx("kbd",{children:"Esc"})," ",e("common:buttons.close")]})})]})}),Ut=768;function Zt({isOpen:t,onClose:e,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:r,onOpenFileExplorer:i,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=A.useRef(null),f=A.useRef(null),m=A.useRef(null),g=A.useRef(0),{query:y,setQuery:b,selectedIndex:k,setSelectedIndex:S,results:_,handleKeyDown:W,highlightMatch:z}=Ot({isOpen:t,onClose:e,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:r,onOpenFileExplorer:i,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l});g.current=_.length,A.useEffect(()=>{t&&setTimeout(()=>{var x;(x=h.current)==null||x.focus()},50)},[t]),A.useEffect(()=>{if(!t)return;const x=window.visualViewport;if(!x||window.innerWidth>Ut)return;const E=()=>{const I=f.current;I&&(I.style.height=`${x.height}px`,I.style.top=`${x.offsetTop}px`)};return E(),x.addEventListener("resize",E),x.addEventListener("scroll",E),()=>{x.removeEventListener("resize",E),x.removeEventListener("scroll",E);const I=f.current;I&&(I.style.height="",I.style.top="")}},[t]),A.useEffect(()=>{if(!t)return;const x=E=>{if(E.key==="Escape"){E.preventDefault(),E.stopPropagation(),E.stopImmediatePropagation(),e();return}if(E.altKey&&!E.ctrlKey&&!E.metaKey&&(E.key==="n"||E.key==="p"||E.key==="N"||E.key==="P")){E.preventDefault(),E.stopPropagation(),E.stopImmediatePropagation();const I=E.key.toLowerCase(),$=g.current;S(I==="p"?T=>T>0?T-1:$-1:T=>T<$-1?T+1:0);return}};return window.addEventListener("keydown",x,{capture:!0}),()=>{window.removeEventListener("keydown",x,{capture:!0})}},[t,e]);const re=A.useCallback(x=>{x.target===x.currentTarget&&e()},[e]),G=A.useCallback(()=>{S(0)},[S]);return t?d.jsx("div",{ref:f,className:"spotlight-overlay",onClick:re,children:d.jsxs("div",{className:"spotlight-modal",children:[d.jsx(zt,{ref:h,query:y,onQueryChange:b,onKeyDown:W,onResetSelection:G}),d.jsx(Wt,{ref:m,results:_,selectedIndex:k,query:y,highlightMatch:z,onSelectIndex:S}),d.jsx(Vt,{})]})}):null}export{Re as FILE_ICON_NAMES,Zt as Spotlight,Vt as SpotlightFooter,zt as SpotlightInput,Qt as SpotlightItem,Wt as SpotlightResults,Ue as formatDuration,Xt as formatRelativeTime,Jt as getAgentIcon,Kt as getFileIconFromPath,_e as getTypeLabel,Ot as useSpotlightSearch};
@@ -1 +1 @@
1
- import{ab as as,u as ts,ar as vs,as as bs,at as zs,j as s,I as F,_ as Is,au as Es,av as $s,aw as Ds,ax as Ms,r as c,a2 as Ls,ah as Ss,W as Xs,U as Ps,H as Rs,ay as Ys,az as Us,aA as Gs,aB as ms,aC as _s,s as M,aD as Fs,n as G}from"./main-B7wf_xU_.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const fs=as.memo(({agent:a,isSelected:A,isKeyboardFocused:L=!1,onSelect:S,onDoubleClick:n,onChat:g,onFocus:h,onKill:w,onDragStart:X})=>{const{t:x}=ts(["dashboard","common"]),P=vs().has(a.id),N=bs(a.status),H=zs(a),j=Ms(H),I=a.taskLabel?s.jsxs(s.Fragment,{children:[s.jsx(F,{name:"task",size:12})," ",a.taskLabel]}):a.currentTask||a.lastAssignedTask,m=a.status==="idle"&&a.lastActivity>0,[,B]=as.useState(0);return as.useEffect(()=>{if(!m)return;const b=window.setInterval(()=>B(T=>T+1),15e3);return()=>window.clearInterval(b)},[m]),s.jsxs("div",{className:`dash-card dash-card--${N} ${A?"dash-card--selected":""} ${L?"dash-card--keyboard-focused":""}`,"data-agent-id":a.id,onClick:S,onDoubleClick:b=>{b.stopPropagation(),n()},onDragStart:b=>{X==null||X(a),b.dataTransfer.effectAllowed="move"},draggable:!0,title:x("cards.doubleClickHint"),children:[s.jsxs("div",{className:"dash-card__row1",children:[s.jsx("span",{className:`dash-card__status-dot dash-card__status-dot--${N}`}),s.jsx("span",{className:"dash-card__name",children:a.name}),s.jsxs("span",{className:"dash-card__class",children:[s.jsx(Is,{agent:a,size:14})," ",a.class]}),s.jsxs("span",{className:`dash-card__provider dash-card__provider--${a.provider}`,children:[s.jsx(F,{name:a.provider==="codex"||a.provider==="opencode"?"status-pending":"robot",size:11,weight:a.provider==="codex"||a.provider==="opencode"?"fill":"regular",color:a.provider==="codex"?"#a16207":a.provider==="opencode"?"#4ade80":void 0})," ",a.provider]}),P&&s.jsx("span",{className:"dash-card__unseen-badge",title:"New output available - click to view",children:"!"})]}),s.jsxs("div",{className:"dash-card__row2",children:[s.jsx("span",{className:`dash-card__status dash-card__status--${N}`,children:P?"Unseen":a.status}),s.jsxs("div",{className:"dash-card__context",children:[s.jsx("div",{className:"dash-card__context-bar",children:s.jsx("div",{className:`dash-card__context-fill dash-card__context-fill--${j}`,style:{width:`${H}%`}})}),s.jsxs("span",{className:`dash-card__context-pct dash-card__context-pct--${j}`,children:[H,"%"]})]})]}),s.jsxs("div",{className:"dash-card__row3",children:[s.jsxs("span",{className:"dash-card__workdir",title:a.cwd,children:[s.jsx(F,{name:"folder",size:11})," ",a.cwd.split("/").pop()||a.cwd]}),m&&s.jsxs("span",{className:"dash-card__idle-time",style:{color:Ds(a.lastActivity)},title:$s(a.lastActivity),children:[s.jsx(F,{name:"status-waiting-input",size:10})," ",Es(a.lastActivity)]})]}),I&&s.jsx("div",{className:"dash-card__row4",children:s.jsx("span",{className:"dash-card__task",children:I})}),s.jsxs("div",{className:"dash-card__actions",children:[g&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--chat",onClick:b=>{b.stopPropagation(),g()},title:x("cards.openTerminal"),children:x("cards.chat")}),w&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--danger",onClick:b=>{b.stopPropagation(),w()},title:x("cards.killAgent"),children:x("cards.stop")})]})]})});fs.displayName="AgentCard";const ws=({buildings:a,onSelectBuilding:A})=>{const{t:L}=ts(["dashboard"]),S=c.useMemo(()=>Array.from(a.values()).sort((n,g)=>n.name.localeCompare(g.name)),[a]);return s.jsxs("div",{className:"dashboard-view__buildings",children:[s.jsxs("div",{className:"dashboard-view__buildings-header",children:[s.jsx("span",{className:"dashboard-view__buildings-title",children:L("buildings.title")}),s.jsx("span",{className:"dashboard-view__buildings-count",children:S.length})]}),s.jsx("div",{className:"dashboard-view__buildings-row",children:S.map(n=>{const g=bs(n.status),h=Ls(n.type);return s.jsxs("button",{className:`dash-pill dash-pill--${g}`,onClick:()=>A==null?void 0:A(n.id),title:`${n.name} (${n.type}) - ${n.status}`,children:[s.jsx("span",{className:"dash-pill__icon",children:s.jsx(F,{name:h,size:14})}),s.jsx("span",{className:"dash-pill__name",children:n.name}),s.jsx("span",{className:`dash-pill__dot dash-pill__dot--${g}`})]},n.id)})})]})};ws.displayName="BuildingPills";function Zs({onSelectAgent:a,onFocusAgent:A,onKillAgent:L,onSelectBuilding:S,onOpenTerminal:n,onFocusZone:g}){const{t:h}=ts(["dashboard","common"]),w=Ss(),X=Xs(),x=Ps(),rs=Rs(),P=vs(),[N,H]=c.useState(""),[j,I]=c.useState("all"),[m,B]=c.useState("zone"),[b,T]=c.useState(new Set),[k,J]=c.useState(null),[ps,Z]=c.useState(null),[R,Q]=c.useState(!1),[p,W]=c.useState(null),K=c.useMemo(()=>{const e=Array.from(w.values());return{total:e.length,working:e.filter(i=>i.status==="working"||i.status==="waiting"||i.status==="waiting_permission").length,idle:e.filter(i=>i.status==="idle").length,error:e.filter(i=>i.status==="error"||i.status==="offline"||i.status==="orphaned").length}},[w]),ns=c.useMemo(()=>m==="zone"?Ys(w,x):m==="status"?Us(w,P):Gs(w),[w,x,m,P]),V=c.useMemo(()=>{const e=N.toLowerCase().trim(),i=ns.map(l=>({...l,agents:l.agents.filter(_=>{if(j==="working"){if(_.status!=="working"&&_.status!=="waiting"&&_.status!=="waiting_permission")return!1}else if(j==="error"&&_.status!=="error"&&_.status!=="offline"&&_.status!=="orphaned")return!1;return!(e&&!_.name.toLowerCase().includes(e)&&!_.class.toLowerCase().includes(e))})}));return m==="zone"?i:i.filter(l=>l.agents.length>0)},[ns,j,N,m]),O=c.useCallback(e=>e.area?`area:${e.area.id}`:`${m}:${e.label}`,[m]),C=c.useMemo(()=>{const e=[];return V.forEach(i=>{const l=O(i);if(b.has(l))return;const _=m==="status"?ms(i.agents,{prioritizeRecentlyIdle:!0}):_s(i.agents);e.push(..._)}),e},[V,b,m,O]),gs=c.useCallback(e=>{T(i=>{const l=new Set(i);return l.has(e)?l.delete(e):l.add(e),l})},[]),xs=c.useCallback(e=>{n==null||n(e)},[n]),js=c.useCallback(e=>{J(e)},[]),Ns=c.useCallback((e,i)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",Z(i)},[]),ks=c.useCallback(()=>{Z(null)},[]),Cs=c.useCallback(e=>{if(!k)return;if(e===null){const E=M.getState(),t=Array.from(E.areas.values()).find(r=>r.assignedAgentIds.includes(k.id));t&&M.unassignAgentFromArea(k.id,t.id),J(null),Z(null);return}const i=x.get(e);if(!i)return;const l=Array.from(w.values()),_=Fs(i,l,k.position);M.updateAgent({...k,position:{...k.position,x:_.x,z:_.z}}),M.assignAgentToArea(k.id,e),J(null),Z(null)},[k,x,w]);return c.useEffect(()=>{if(C.length===0){Q(!1),W(null);return}R&&(!p||!C.some(e=>e.id===p))&&(W(C[0].id),a==null||a(C[0].id))},[C,R,p,a]),c.useEffect(()=>{const e=t=>t instanceof HTMLElement?t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"||t.isContentEditable:!1,i=t=>t instanceof HTMLElement?!!t.closest(".guake-terminal")||t.classList.contains("guake-input")||t.classList.contains("agent-panel-input"):!1,l=t=>{const r=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).find(z=>z.dataset.agentId===t);r==null||r.scrollIntoView({block:"nearest",inline:"nearest"})},_=(t,r)=>{var ds,os,cs,ls,us,hs;const z=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).map(d=>{const u=d.dataset.agentId;if(!u)return null;const y=d.getBoundingClientRect();return{id:u,centerX:y.left+y.width/2,centerY:y.top+y.height/2,height:y.height}}).filter(d=>d!==null).sort((d,u)=>d.centerY-u.centerY||d.centerX-u.centerX);if(z.length===0)return t;const ss=z.reduce((d,u)=>d+u.height,0)/z.length,es=Math.max(18,ss*.6),f=[];for(const d of z){const u=f[f.length-1];if(!u){f.push([{id:d.id,centerX:d.centerX,centerY:d.centerY}]);continue}const y=u.reduce((ys,As)=>ys+As.centerY,0)/u.length;Math.abs(d.centerY-y)<=es?u.push({id:d.id,centerX:d.centerX,centerY:d.centerY}):f.push([{id:d.id,centerX:d.centerX,centerY:d.centerY}])}f.forEach(d=>d.sort((u,y)=>u.centerX-y.centerX));const Y=f.findIndex(d=>d.some(u=>u.id===t));if(Y===-1)return((os=(ds=f[0])==null?void 0:ds[0])==null?void 0:os.id)??t;const $=f[Y],v=$.findIndex(d=>d.id===t);if(v===-1)return((ls=(cs=f[0])==null?void 0:cs[0])==null?void 0:ls.id)??t;if(r==="left")return((us=$[Math.max(0,v-1)])==null?void 0:us.id)??t;if(r==="right")return((hs=$[Math.min($.length-1,v+1)])==null?void 0:hs.id)??t;const q=r==="up"?Math.max(0,Y-1):Math.min(f.length-1,Y+1),o=f[q],U=$[v].centerX;let D=o[0],is=Math.abs(D.centerX-U);for(const d of o){const u=Math.abs(d.centerX-U);u<is&&(D=d,is=u)}return(D==null?void 0:D.id)??t},E=t=>{const r=M.getShortcuts(),z=r.find(o=>o.id==="dashboard-selector-toggle"),ss=r.find(o=>o.id==="dashboard-vim-left"),es=r.find(o=>o.id==="dashboard-vim-down"),f=r.find(o=>o.id==="dashboard-vim-up"),Y=r.find(o=>o.id==="dashboard-vim-right"),$=r.find(o=>o.id==="open-terminal"),v=M.getState();if(e(t.target))if(!v.terminalOpen&&i(t.target)&&document.activeElement instanceof HTMLElement)document.activeElement.blur();else return;if(G(t,z)){if(C.length===0)return;t.preventDefault(),t.stopPropagation(),Q(!0),W(o=>{const U=o&&C.some(D=>D.id===o)?o:C[0].id;return a==null||a(U),window.setTimeout(()=>l(U),0),U});return}const q=G(t,ss)||t.key==="ArrowLeft"?"left":G(t,es)||t.key==="ArrowDown"?"down":G(t,f)||t.key==="ArrowUp"?"up":G(t,Y)||t.key==="ArrowRight"?"right":null;if(q&&R&&p){t.preventDefault(),t.stopPropagation();const o=_(p,q);o!==p&&(W(o),a==null||a(o),window.setTimeout(()=>l(o),0));return}if(G(t,$)){if(v.terminalOpen)return;if(R&&p&&v.agents.has(p)){t.preventDefault(),n==null||n(p);return}if(v.selectedAgentIds.size===1){t.preventDefault();const o=Array.from(v.selectedAgentIds)[0];n==null||n(o);return}if(v.lastSelectedAgentId&&v.agents.has(v.lastSelectedAgentId)){t.preventDefault(),n==null||n(v.lastSelectedAgentId);return}}};return document.addEventListener("keydown",E,!0),()=>document.removeEventListener("keydown",E,!0)},[C,R,p,n,a]),c.useEffect(()=>{const e=document.activeElement;e instanceof HTMLElement&&e.closest(".guake-terminal")&&!M.getState().terminalOpen&&e.blur()},[]),s.jsxs("div",{className:"dashboard-view",children:[s.jsxs("div",{className:"dashboard-view__topbar",children:[s.jsxs("div",{className:"dashboard-view__metrics",children:[s.jsxs("button",{className:`dashboard-view__metric-btn ${j==="all"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.total}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:labels.agents")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--working ${j==="working"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("working"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.working}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.working")})]}),s.jsxs("button",{className:"dashboard-view__metric-btn dashboard-view__metric-btn--idle ",onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.idle}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.idle")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--error ${j==="error"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("error"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.error}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.error")})]})]}),s.jsx("input",{className:"dashboard-view__search",type:"text",placeholder:h("searchPlaceholder"),value:N,onChange:e=>H(e.target.value)})]}),s.jsxs("div",{className:"dashboard-view__grouping",children:[s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="zone"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>B("zone"),children:h("grouping.byZone")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="status"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>B("status"),children:h("grouping.byStatus")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="activity"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>B("activity"),children:h("grouping.byActivity")})]}),s.jsxs("div",{className:"dashboard-view__content",children:[V.map(e=>{const i=O(e),l=b.has(i),_=m==="status"?ms(e.agents,{prioritizeRecentlyIdle:!0}):_s(e.agents),E=e.agents.filter(r=>r.status==="working"||r.status==="waiting"||r.status==="waiting_permission").length,t=e.agents.filter(r=>P.has(r.id)).length;return s.jsxs("div",{className:`dashboard-view__zone ${ps===(e.area?e.area.id:null)&&k?"dashboard-view__zone--drag-over":""}`,onDragOver:r=>Ns(r,e.area?e.area.id:null),onDragLeave:ks,onDrop:()=>Cs(e.area?e.area.id:null),children:[s.jsxs("div",{className:"dashboard-view__zone-header",onClick:()=>gs(i),children:[s.jsxs("div",{className:"dashboard-view__zone-left",children:[s.jsx("span",{className:`dashboard-view__zone-chevron ${l?"dashboard-view__zone-chevron--collapsed":""}`,children:s.jsx(F,{name:"caret-down",size:12})}),s.jsx("span",{className:"dashboard-view__zone-dot",style:{backgroundColor:e.color}}),s.jsx("span",{className:"dashboard-view__zone-name",children:e.label}),s.jsxs("span",{className:"dashboard-view__zone-count",children:[h("agentCount",{count:e.agents.length}),E>0&&s.jsxs("span",{className:"dashboard-view__zone-working",children:[" · ",E," ",h("working")]}),t>0&&s.jsxs("span",{className:"dashboard-view__zone-unseen",children:[" · ",t," Unseen"]})]})]}),e.area&&g&&s.jsx("button",{className:"dashboard-view__zone-focus",onClick:r=>{r.stopPropagation(),g(e.area.id)},title:h("focusZone"),children:h("focusZone")})]}),!l&&s.jsx("div",{className:"dashboard-view__zone-grid",children:_.map(r=>s.jsx(fs,{agent:r,isSelected:rs.has(r.id),isKeyboardFocused:R&&p===r.id,onSelect:()=>{a==null||a(r.id),Q(!0),W(r.id)},onDoubleClick:()=>xs(r.id),onChat:()=>n==null?void 0:n(r.id),onFocus:A?()=>A(r.id):void 0,onKill:L?()=>L(r.id):void 0,onDragStart:js},r.id))})]},i)}),V.length===0&&s.jsx("div",{className:"dashboard-view__empty",children:N?h("noAgentsMatching",{search:N}):h("noAgentsSpawned")}),X.size>0&&s.jsx(ws,{buildings:X,onSelectBuilding:S})]})]})}export{Zs as DashboardView};
1
+ import{ab as as,u as ts,ar as vs,as as bs,at as zs,j as s,I as F,_ as Is,au as Es,av as $s,aw as Ds,ax as Ms,r as c,a2 as Ls,ah as Ss,W as Xs,U as Ps,H as Rs,ay as Ys,az as Us,aA as Gs,aB as ms,aC as _s,s as M,aD as Fs,n as G}from"./main-CBiZdw6w.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const fs=as.memo(({agent:a,isSelected:A,isKeyboardFocused:L=!1,onSelect:S,onDoubleClick:n,onChat:g,onFocus:h,onKill:w,onDragStart:X})=>{const{t:x}=ts(["dashboard","common"]),P=vs().has(a.id),N=bs(a.status),H=zs(a),j=Ms(H),I=a.taskLabel?s.jsxs(s.Fragment,{children:[s.jsx(F,{name:"task",size:12})," ",a.taskLabel]}):a.currentTask||a.lastAssignedTask,m=a.status==="idle"&&a.lastActivity>0,[,B]=as.useState(0);return as.useEffect(()=>{if(!m)return;const b=window.setInterval(()=>B(T=>T+1),15e3);return()=>window.clearInterval(b)},[m]),s.jsxs("div",{className:`dash-card dash-card--${N} ${A?"dash-card--selected":""} ${L?"dash-card--keyboard-focused":""}`,"data-agent-id":a.id,onClick:S,onDoubleClick:b=>{b.stopPropagation(),n()},onDragStart:b=>{X==null||X(a),b.dataTransfer.effectAllowed="move"},draggable:!0,title:x("cards.doubleClickHint"),children:[s.jsxs("div",{className:"dash-card__row1",children:[s.jsx("span",{className:`dash-card__status-dot dash-card__status-dot--${N}`}),s.jsx("span",{className:"dash-card__name",children:a.name}),s.jsxs("span",{className:"dash-card__class",children:[s.jsx(Is,{agent:a,size:14})," ",a.class]}),s.jsxs("span",{className:`dash-card__provider dash-card__provider--${a.provider}`,children:[s.jsx(F,{name:a.provider==="codex"||a.provider==="opencode"?"status-pending":"robot",size:11,weight:a.provider==="codex"||a.provider==="opencode"?"fill":"regular",color:a.provider==="codex"?"#a16207":a.provider==="opencode"?"#4ade80":void 0})," ",a.provider]}),P&&s.jsx("span",{className:"dash-card__unseen-badge",title:"New output available - click to view",children:"!"})]}),s.jsxs("div",{className:"dash-card__row2",children:[s.jsx("span",{className:`dash-card__status dash-card__status--${N}`,children:P?"Unseen":a.status}),s.jsxs("div",{className:"dash-card__context",children:[s.jsx("div",{className:"dash-card__context-bar",children:s.jsx("div",{className:`dash-card__context-fill dash-card__context-fill--${j}`,style:{width:`${H}%`}})}),s.jsxs("span",{className:`dash-card__context-pct dash-card__context-pct--${j}`,children:[H,"%"]})]})]}),s.jsxs("div",{className:"dash-card__row3",children:[s.jsxs("span",{className:"dash-card__workdir",title:a.cwd,children:[s.jsx(F,{name:"folder",size:11})," ",a.cwd.split("/").pop()||a.cwd]}),m&&s.jsxs("span",{className:"dash-card__idle-time",style:{color:Ds(a.lastActivity)},title:$s(a.lastActivity),children:[s.jsx(F,{name:"status-waiting-input",size:10})," ",Es(a.lastActivity)]})]}),I&&s.jsx("div",{className:"dash-card__row4",children:s.jsx("span",{className:"dash-card__task",children:I})}),s.jsxs("div",{className:"dash-card__actions",children:[g&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--chat",onClick:b=>{b.stopPropagation(),g()},title:x("cards.openTerminal"),children:x("cards.chat")}),w&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--danger",onClick:b=>{b.stopPropagation(),w()},title:x("cards.killAgent"),children:x("cards.stop")})]})]})});fs.displayName="AgentCard";const ws=({buildings:a,onSelectBuilding:A})=>{const{t:L}=ts(["dashboard"]),S=c.useMemo(()=>Array.from(a.values()).sort((n,g)=>n.name.localeCompare(g.name)),[a]);return s.jsxs("div",{className:"dashboard-view__buildings",children:[s.jsxs("div",{className:"dashboard-view__buildings-header",children:[s.jsx("span",{className:"dashboard-view__buildings-title",children:L("buildings.title")}),s.jsx("span",{className:"dashboard-view__buildings-count",children:S.length})]}),s.jsx("div",{className:"dashboard-view__buildings-row",children:S.map(n=>{const g=bs(n.status),h=Ls(n.type);return s.jsxs("button",{className:`dash-pill dash-pill--${g}`,onClick:()=>A==null?void 0:A(n.id),title:`${n.name} (${n.type}) - ${n.status}`,children:[s.jsx("span",{className:"dash-pill__icon",children:s.jsx(F,{name:h,size:14})}),s.jsx("span",{className:"dash-pill__name",children:n.name}),s.jsx("span",{className:`dash-pill__dot dash-pill__dot--${g}`})]},n.id)})})]})};ws.displayName="BuildingPills";function Zs({onSelectAgent:a,onFocusAgent:A,onKillAgent:L,onSelectBuilding:S,onOpenTerminal:n,onFocusZone:g}){const{t:h}=ts(["dashboard","common"]),w=Ss(),X=Xs(),x=Ps(),rs=Rs(),P=vs(),[N,H]=c.useState(""),[j,I]=c.useState("all"),[m,B]=c.useState("zone"),[b,T]=c.useState(new Set),[k,J]=c.useState(null),[ps,Z]=c.useState(null),[R,Q]=c.useState(!1),[p,W]=c.useState(null),K=c.useMemo(()=>{const e=Array.from(w.values());return{total:e.length,working:e.filter(i=>i.status==="working"||i.status==="waiting"||i.status==="waiting_permission").length,idle:e.filter(i=>i.status==="idle").length,error:e.filter(i=>i.status==="error"||i.status==="offline"||i.status==="orphaned").length}},[w]),ns=c.useMemo(()=>m==="zone"?Ys(w,x):m==="status"?Us(w,P):Gs(w),[w,x,m,P]),V=c.useMemo(()=>{const e=N.toLowerCase().trim(),i=ns.map(l=>({...l,agents:l.agents.filter(_=>{if(j==="working"){if(_.status!=="working"&&_.status!=="waiting"&&_.status!=="waiting_permission")return!1}else if(j==="error"&&_.status!=="error"&&_.status!=="offline"&&_.status!=="orphaned")return!1;return!(e&&!_.name.toLowerCase().includes(e)&&!_.class.toLowerCase().includes(e))})}));return m==="zone"?i:i.filter(l=>l.agents.length>0)},[ns,j,N,m]),O=c.useCallback(e=>e.area?`area:${e.area.id}`:`${m}:${e.label}`,[m]),C=c.useMemo(()=>{const e=[];return V.forEach(i=>{const l=O(i);if(b.has(l))return;const _=m==="status"?ms(i.agents,{prioritizeRecentlyIdle:!0}):_s(i.agents);e.push(..._)}),e},[V,b,m,O]),gs=c.useCallback(e=>{T(i=>{const l=new Set(i);return l.has(e)?l.delete(e):l.add(e),l})},[]),xs=c.useCallback(e=>{n==null||n(e)},[n]),js=c.useCallback(e=>{J(e)},[]),Ns=c.useCallback((e,i)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",Z(i)},[]),ks=c.useCallback(()=>{Z(null)},[]),Cs=c.useCallback(e=>{if(!k)return;if(e===null){const E=M.getState(),t=Array.from(E.areas.values()).find(r=>r.assignedAgentIds.includes(k.id));t&&M.unassignAgentFromArea(k.id,t.id),J(null),Z(null);return}const i=x.get(e);if(!i)return;const l=Array.from(w.values()),_=Fs(i,l,k.position);M.updateAgent({...k,position:{...k.position,x:_.x,z:_.z}}),M.assignAgentToArea(k.id,e),J(null),Z(null)},[k,x,w]);return c.useEffect(()=>{if(C.length===0){Q(!1),W(null);return}R&&(!p||!C.some(e=>e.id===p))&&(W(C[0].id),a==null||a(C[0].id))},[C,R,p,a]),c.useEffect(()=>{const e=t=>t instanceof HTMLElement?t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"||t.isContentEditable:!1,i=t=>t instanceof HTMLElement?!!t.closest(".guake-terminal")||t.classList.contains("guake-input")||t.classList.contains("agent-panel-input"):!1,l=t=>{const r=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).find(z=>z.dataset.agentId===t);r==null||r.scrollIntoView({block:"nearest",inline:"nearest"})},_=(t,r)=>{var ds,os,cs,ls,us,hs;const z=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).map(d=>{const u=d.dataset.agentId;if(!u)return null;const y=d.getBoundingClientRect();return{id:u,centerX:y.left+y.width/2,centerY:y.top+y.height/2,height:y.height}}).filter(d=>d!==null).sort((d,u)=>d.centerY-u.centerY||d.centerX-u.centerX);if(z.length===0)return t;const ss=z.reduce((d,u)=>d+u.height,0)/z.length,es=Math.max(18,ss*.6),f=[];for(const d of z){const u=f[f.length-1];if(!u){f.push([{id:d.id,centerX:d.centerX,centerY:d.centerY}]);continue}const y=u.reduce((ys,As)=>ys+As.centerY,0)/u.length;Math.abs(d.centerY-y)<=es?u.push({id:d.id,centerX:d.centerX,centerY:d.centerY}):f.push([{id:d.id,centerX:d.centerX,centerY:d.centerY}])}f.forEach(d=>d.sort((u,y)=>u.centerX-y.centerX));const Y=f.findIndex(d=>d.some(u=>u.id===t));if(Y===-1)return((os=(ds=f[0])==null?void 0:ds[0])==null?void 0:os.id)??t;const $=f[Y],v=$.findIndex(d=>d.id===t);if(v===-1)return((ls=(cs=f[0])==null?void 0:cs[0])==null?void 0:ls.id)??t;if(r==="left")return((us=$[Math.max(0,v-1)])==null?void 0:us.id)??t;if(r==="right")return((hs=$[Math.min($.length-1,v+1)])==null?void 0:hs.id)??t;const q=r==="up"?Math.max(0,Y-1):Math.min(f.length-1,Y+1),o=f[q],U=$[v].centerX;let D=o[0],is=Math.abs(D.centerX-U);for(const d of o){const u=Math.abs(d.centerX-U);u<is&&(D=d,is=u)}return(D==null?void 0:D.id)??t},E=t=>{const r=M.getShortcuts(),z=r.find(o=>o.id==="dashboard-selector-toggle"),ss=r.find(o=>o.id==="dashboard-vim-left"),es=r.find(o=>o.id==="dashboard-vim-down"),f=r.find(o=>o.id==="dashboard-vim-up"),Y=r.find(o=>o.id==="dashboard-vim-right"),$=r.find(o=>o.id==="open-terminal"),v=M.getState();if(e(t.target))if(!v.terminalOpen&&i(t.target)&&document.activeElement instanceof HTMLElement)document.activeElement.blur();else return;if(G(t,z)){if(C.length===0)return;t.preventDefault(),t.stopPropagation(),Q(!0),W(o=>{const U=o&&C.some(D=>D.id===o)?o:C[0].id;return a==null||a(U),window.setTimeout(()=>l(U),0),U});return}const q=G(t,ss)||t.key==="ArrowLeft"?"left":G(t,es)||t.key==="ArrowDown"?"down":G(t,f)||t.key==="ArrowUp"?"up":G(t,Y)||t.key==="ArrowRight"?"right":null;if(q&&R&&p){t.preventDefault(),t.stopPropagation();const o=_(p,q);o!==p&&(W(o),a==null||a(o),window.setTimeout(()=>l(o),0));return}if(G(t,$)){if(v.terminalOpen)return;if(R&&p&&v.agents.has(p)){t.preventDefault(),n==null||n(p);return}if(v.selectedAgentIds.size===1){t.preventDefault();const o=Array.from(v.selectedAgentIds)[0];n==null||n(o);return}if(v.lastSelectedAgentId&&v.agents.has(v.lastSelectedAgentId)){t.preventDefault(),n==null||n(v.lastSelectedAgentId);return}}};return document.addEventListener("keydown",E,!0),()=>document.removeEventListener("keydown",E,!0)},[C,R,p,n,a]),c.useEffect(()=>{const e=document.activeElement;e instanceof HTMLElement&&e.closest(".guake-terminal")&&!M.getState().terminalOpen&&e.blur()},[]),s.jsxs("div",{className:"dashboard-view",children:[s.jsxs("div",{className:"dashboard-view__topbar",children:[s.jsxs("div",{className:"dashboard-view__metrics",children:[s.jsxs("button",{className:`dashboard-view__metric-btn ${j==="all"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.total}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:labels.agents")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--working ${j==="working"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("working"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.working}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.working")})]}),s.jsxs("button",{className:"dashboard-view__metric-btn dashboard-view__metric-btn--idle ",onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.idle}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.idle")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--error ${j==="error"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("error"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.error}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.error")})]})]}),s.jsx("input",{className:"dashboard-view__search",type:"text",placeholder:h("searchPlaceholder"),value:N,onChange:e=>H(e.target.value)})]}),s.jsxs("div",{className:"dashboard-view__grouping",children:[s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="zone"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>B("zone"),children:h("grouping.byZone")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="status"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>B("status"),children:h("grouping.byStatus")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="activity"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>B("activity"),children:h("grouping.byActivity")})]}),s.jsxs("div",{className:"dashboard-view__content",children:[V.map(e=>{const i=O(e),l=b.has(i),_=m==="status"?ms(e.agents,{prioritizeRecentlyIdle:!0}):_s(e.agents),E=e.agents.filter(r=>r.status==="working"||r.status==="waiting"||r.status==="waiting_permission").length,t=e.agents.filter(r=>P.has(r.id)).length;return s.jsxs("div",{className:`dashboard-view__zone ${ps===(e.area?e.area.id:null)&&k?"dashboard-view__zone--drag-over":""}`,onDragOver:r=>Ns(r,e.area?e.area.id:null),onDragLeave:ks,onDrop:()=>Cs(e.area?e.area.id:null),children:[s.jsxs("div",{className:"dashboard-view__zone-header",onClick:()=>gs(i),children:[s.jsxs("div",{className:"dashboard-view__zone-left",children:[s.jsx("span",{className:`dashboard-view__zone-chevron ${l?"dashboard-view__zone-chevron--collapsed":""}`,children:s.jsx(F,{name:"caret-down",size:12})}),s.jsx("span",{className:"dashboard-view__zone-dot",style:{backgroundColor:e.color}}),s.jsx("span",{className:"dashboard-view__zone-name",children:e.label}),s.jsxs("span",{className:"dashboard-view__zone-count",children:[h("agentCount",{count:e.agents.length}),E>0&&s.jsxs("span",{className:"dashboard-view__zone-working",children:[" · ",E," ",h("working")]}),t>0&&s.jsxs("span",{className:"dashboard-view__zone-unseen",children:[" · ",t," Unseen"]})]})]}),e.area&&g&&s.jsx("button",{className:"dashboard-view__zone-focus",onClick:r=>{r.stopPropagation(),g(e.area.id)},title:h("focusZone"),children:h("focusZone")})]}),!l&&s.jsx("div",{className:"dashboard-view__zone-grid",children:_.map(r=>s.jsx(fs,{agent:r,isSelected:rs.has(r.id),isKeyboardFocused:R&&p===r.id,onSelect:()=>{a==null||a(r.id),Q(!0),W(r.id)},onDoubleClick:()=>xs(r.id),onChat:()=>n==null?void 0:n(r.id),onFocus:A?()=>A(r.id):void 0,onKill:L?()=>L(r.id):void 0,onDragStart:js},r.id))})]},i)}),V.length===0&&s.jsx("div",{className:"dashboard-view__empty",children:N?h("noAgentsMatching",{search:N}):h("noAgentsSpawned")}),X.size>0&&s.jsx(ws,{buildings:X,onSelectBuilding:S})]})]})}export{Zs as DashboardView};
@@ -1,4 +1,4 @@
1
- import{r as l,aT as Re,aU as Ye,j as e,I as $,u as Y,aV as ts,a2 as ns,f as Ve,s as E,aW as hs,k as is,l as me,aX as X,aY as ms,aM as gs,aZ as fs,C as ge,a_ as J,aJ as we,a$ as xs,b0 as bs,b1 as js,b2 as ws,b3 as Ce,b4 as os,b5 as ys,b6 as Be,b7 as vs,b8 as Ns,b9 as ks,ba as Cs,bb as Ss,bc as Ts,bd as As,aF as _s,J as Es,S as ke,be as Is,bf as Ps,aH as $s,bg as Ue,K as Pe,aQ as Ls,bh as ze,bi as Ds}from"./main-B7wf_xU_.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ke="deivid11/tide-commander",Fs=`https://api.github.com/repos/${Ke}/releases/latest`,Os=`https://api.github.com/repos/${Ke}/releases?per_page=3`,Rs=3600*1e3,Je="app_update_dismissed_version",Ze="1.99.0";function Us(){var x,b;const[s,t]=l.useState({isChecking:!1,updateAvailable:!1,updateInfo:null,recentReleases:[],error:null,currentVersion:Ze}),a=((b=(x=Re)==null?void 0:x.getPlatform)==null?void 0:b.call(x))==="android"||!1,o=p=>p.replace(/^v/,"").split(".").map(m=>parseInt(m,10)||0),r=(p,f)=>{const m=o(p),y=o(f),j=Math.max(m.length,y.length);for(let h=0;h<j;h++){const _=m[h]||0,D=y[h]||0;if(_>D)return 1;if(_<D)return-1}return 0},d=async p=>{var m,y;if(Re&&Ye&&((y=(m=Re).isNativePlatform)==null?void 0:y.call(m))===!0){const j=await Ye.get({url:p,headers:{Accept:"application/vnd.github.v3+json"}});return{data:j.data,status:j.status}}else{const j=await fetch(p,{headers:{Accept:"application/vnd.github.v3+json"}});return j.ok?{data:await j.json(),status:j.status}:{data:null,status:j.status}}},c=l.useCallback(async(p=!1)=>{t(f=>({...f,isChecking:!0,error:null}));try{const[f,m]=await Promise.all([d(Fs),d(Os)]);if(f.status!==200)throw new Error(`GitHub API error: ${f.status}`);const y=f.data,j=y.tag_name;let h=[];m.status===200&&m.data&&(h=m.data.map(A=>({version:A.tag_name,name:A.name,publishedAt:A.published_at,releaseUrl:A.html_url})));const _=localStorage.getItem(Je);if(!p&&_===j)return t(A=>({...A,isChecking:!1,updateAvailable:!1,recentReleases:h})),null;if(!(r(j,Ze)>0))return t(A=>({...A,isChecking:!1,updateAvailable:!1,recentReleases:h})),null;const P=y.assets.find(A=>A.name.endsWith(".apk")&&A.content_type==="application/vnd.android.package-archive"),C={version:j,name:y.name,changelog:y.body,releaseUrl:y.html_url,apkUrl:(P==null?void 0:P.browser_download_url)||null,apkSize:(P==null?void 0:P.size)||null,publishedAt:y.published_at};return t(A=>({...A,isChecking:!1,updateAvailable:!0,updateInfo:C,recentReleases:h})),C}catch(f){const m=f instanceof Error?f.message:"Failed to check for updates";return t(y=>({...y,isChecking:!1,error:m})),null}},[]),n=l.useCallback(async()=>{var p,f,m;if(!((p=s.updateInfo)!=null&&p.apkUrl)){(f=s.updateInfo)!=null&&f.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}if(!a){(m=s.updateInfo)!=null&&m.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}try{window.open(s.updateInfo.apkUrl,"_system"),t(y=>({...y,error:null}))}catch(y){const j=y instanceof Error?y.message:"Failed to open download";t(h=>({...h,error:j}))}},[s.updateInfo,a]),u=l.useCallback(()=>{s.updateInfo&&localStorage.setItem(Je,s.updateInfo.version),t(p=>({...p,updateAvailable:!1,updateInfo:null}))},[s.updateInfo]),w=l.useCallback(()=>{var p;(p=s.updateInfo)!=null&&p.releaseUrl?window.open(s.updateInfo.releaseUrl,"_blank"):window.open(`https://github.com/${Ke}/releases`,"_blank")},[s.updateInfo]);return l.useEffect(()=>{if(!a)return;const p=setTimeout(()=>{c()},5e3),f=setInterval(()=>{c()},Rs);return()=>{clearTimeout(p),clearInterval(f)}},[a,c]),{...s,isAndroid:a,checkForUpdate:c,downloadAndInstall:n,dismissUpdate:u,openReleasePage:w}}const ls="tide-toolbox-collapse";function zs(s,t){try{const a=localStorage.getItem(`${ls}-${s}`);if(a!==null)return a==="true"}catch{}return t}function Ms(s,t){try{localStorage.setItem(`${ls}-${s}`,String(t))}catch{}}function W({title:s,storageKey:t,defaultOpen:a=!1,forceOpen:o=!1,children:r,headerExtra:d}){const[c,n]=l.useState(()=>t?zs(t,a):a),u=()=>{const x=!c;n(x),t&&Ms(t,x)},w=o||c;return e.jsxs("div",{className:`collapsible-section ${w?"open":"collapsed"}`,children:[e.jsxs("button",{className:"collapsible-header",onClick:u,children:[e.jsx("span",{className:"collapsible-title",children:s}),e.jsxs("span",{className:"collapsible-header-right",children:[d,e.jsx("span",{className:"collapsible-arrow",children:e.jsx($,{name:w?"caret-down":"caret-right",size:10})})]})]}),w&&e.jsx("div",{className:"collapsible-content",children:r})]})}function Bs({area:s,isSelected:t,onClick:a,onDelete:o}){const{t:r}=Y(["config","common"]),d=s.assignedAgentIds.length,c=s.type==="rectangle"?r("config:areas.rect"):r("config:areas.circle");return e.jsxs("div",{className:`area-item ${t?"selected":""}`,onClick:a,children:[e.jsx("div",{className:"area-color-dot",style:{backgroundColor:s.color}}),e.jsxs("div",{className:"area-info",children:[e.jsx("div",{className:"area-name",children:s.name}),e.jsxs("div",{className:"area-meta",children:[c," ",d>0&&`• ${d} ${d>1?r("common:labels.agents").toLowerCase():r("common:labels.agent").toLowerCase()}`]})]}),e.jsx("button",{className:"area-delete-btn",onClick:o,title:r("config:areas.deleteArea"),children:"×"})]})}function Vs({building:s,isSelected:t,onClick:a,onEdit:o}){var n;const{t:r}=Y(["config"]),d=((n=s.pm2Status)==null?void 0:n.ports)||[],c=(u,w)=>{u.stopPropagation(),window.open(`http://${window.location.hostname}:${w}`,"_blank")};return e.jsxs("div",{className:`building-item ${t?"selected":""}`,onClick:a,children:[e.jsx("div",{className:"building-status-dot",style:{backgroundColor:ts[s.status]},title:s.status}),e.jsx("div",{className:"building-icon",children:e.jsx($,{name:ns(s.type),size:16})}),e.jsxs("div",{className:"building-info",children:[e.jsx("div",{className:"building-name",children:s.name}),e.jsxs("div",{className:"building-meta",children:[s.type,d.length>0&&e.jsx("span",{className:"building-ports",children:d.map(u=>e.jsxs("a",{href:`http://${window.location.hostname}:${u}`,className:"building-port-link",onClick:w=>c(w,u),title:`Open :${u}`,children:[":",u]},u))})]})]}),e.jsx("button",{className:"building-edit-btn",onClick:u=>{u.stopPropagation(),o()},title:r("config:buildings.editBuilding"),children:e.jsx($,{name:"gear",size:14})})]})}function Ks({building:s,onClose:t,onOpenModal:a}){var w,x,b,p,f,m,y,j;const{t:o}=Y(["config","common"]),{buildingLogs:r}=Ve(),d=E.getBuildingLogs(s.id),c=hs[s.style||"server-rack"],n=h=>{E.sendBuildingCommand(s.id,h)},u=h=>{window.open(h,"_blank")};return e.jsxs("div",{className:"building-editor",children:[e.jsxs("div",{className:"building-editor-header",children:[e.jsxs("div",{className:"building-editor-title-row",children:[e.jsx("span",{className:"building-editor-icon",children:e.jsx($,{name:ns(s.type),size:18})}),e.jsx("span",{className:"building-editor-title",children:s.name}),e.jsx("span",{className:"building-editor-status",style:{backgroundColor:ts[s.status]},children:s.status})]}),e.jsx("button",{className:"building-editor-close",onClick:t,children:"×"})]}),e.jsx("div",{className:"building-editor-section",children:e.jsxs("div",{className:"building-editor-info-grid",children:[e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("common:labels.type")}),e.jsx("span",{className:"building-editor-info-value",children:s.type})]}),e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.style")}),e.jsx("span",{className:"building-editor-info-value",children:c.label})]}),s.cwd&&e.jsxs("div",{className:"building-editor-info-item building-editor-info-wide",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.directory")}),e.jsx("span",{className:"building-editor-info-value building-editor-cwd",title:s.cwd,children:s.cwd.split("/").pop()||s.cwd})]})]})}),s.type==="server"&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.actions")}),e.jsxs("div",{className:"building-editor-actions",children:[e.jsxs("button",{className:"building-editor-action-btn start",onClick:()=>n("start"),disabled:!((w=s.commands)!=null&&w.start)||s.status==="running",title:((x=s.commands)==null?void 0:x.start)||o("config:buildings.noStartCommand"),children:[e.jsx($,{name:"play",size:12})," ",o("common:buttons.start")]}),e.jsxs("button",{className:"building-editor-action-btn stop",onClick:()=>n("stop"),disabled:!((b=s.commands)!=null&&b.stop)||s.status==="stopped",title:((p=s.commands)==null?void 0:p.stop)||o("config:buildings.noStopCommand"),children:[e.jsx($,{name:"stop",size:12,weight:"fill"})," ",o("common:buttons.stop")]}),e.jsxs("button",{className:"building-editor-action-btn restart",onClick:()=>n("restart"),disabled:!((f=s.commands)!=null&&f.restart),title:((m=s.commands)==null?void 0:m.restart)||o("config:buildings.noRestartCommand"),children:[e.jsx($,{name:"refresh",size:12})," ",o("common:buttons.retry")]}),e.jsxs("button",{className:"building-editor-action-btn health",onClick:()=>n("healthCheck"),disabled:!((y=s.commands)!=null&&y.healthCheck),title:((j=s.commands)==null?void 0:j.healthCheck)||o("config:buildings.noHealthCheck"),children:[e.jsx($,{name:"heart",size:12})," Health"]})]})]}),s.urls&&s.urls.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.links")}),e.jsx("div",{className:"building-editor-links",children:s.urls.map((h,_)=>e.jsxs("button",{className:"building-editor-link",onClick:()=>u(h.url),title:h.url,children:[e.jsx($,{name:"link",size:12})," ",h.label||h.url]},_))})]}),d.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsxs("div",{className:"building-editor-section-title",children:[o("config:buildings.recentLogs"),e.jsx("button",{className:"building-editor-clear-logs",onClick:()=>E.clearBuildingLogs(s.id),title:o("common:buttons.clear"),children:o("common:buttons.clear")})]}),e.jsx("div",{className:"building-editor-logs",children:d.slice(-5).map((h,_)=>e.jsx("div",{className:"building-editor-log-entry",children:h},_))})]}),e.jsx("div",{className:"building-editor-footer",children:e.jsxs("button",{className:"building-editor-edit-btn",onClick:a,children:[e.jsx($,{name:"gear",size:12})," ",o("config:buildings.fullSettings")]})})]})}async function Hs(s,t){const a=X(),o=await fetch(me(`/api/areas/${s}/logo`),{method:"POST",headers:{"Content-Type":t.type||"image/png","X-Filename":encodeURIComponent(t.name),...a?{Authorization:`Bearer ${a}`}:{}},body:t});if(!o.ok){const r=await o.json().catch(()=>({error:o.statusText}));throw new Error(r.error||`Upload failed: ${o.statusText}`)}return o.json()}async function Ws(s){const t=X(),a=await fetch(me(`/api/areas/${s}/logo`),{method:"DELETE",headers:{...t?{Authorization:`Bearer ${t}`}:{}}});if(!a.ok)throw new Error(`Failed to delete logo: ${a.statusText}`)}function qs(s){return is(me(`/api/areas/logos/${s}`))}const Gs=[{key:"center",labelKey:"posCenter"},{key:"top-left",labelKey:"posTopLeft"},{key:"top-right",labelKey:"posTopRight"},{key:"bottom-left",labelKey:"posBottomLeft"},{key:"bottom-right",labelKey:"posBottomRight"}];function Ys({area:s,onClose:t,onOpenFolder:a}){var ce;const{t:o}=Y(["config","common"]),[r,d]=l.useState(s.name),[c,n]=l.useState(s.prompt||""),[u,w]=l.useState(!1),[x,b]=l.useState(""),[p,f]=l.useState(!1),m=l.useRef(null);l.useEffect(()=>{d(s.name)},[s.id,s.name]),l.useEffect(()=>{n(s.prompt||"")},[s.id,s.prompt]);const y=k=>{const O=k.target.value;d(O),E.updateArea(s.id,{name:O})},j=k=>{E.updateArea(s.id,{color:k})},h=k=>{const O=k.target.value;n(O),E.updateArea(s.id,{prompt:O})},_=()=>{x.trim()&&(E.addDirectoryToArea(s.id,x.trim()),b(""),w(!1))},D=(k,O)=>{O.stopPropagation(),E.removeDirectoryFromArea(s.id,k)},P=()=>{E.bringAreaToFront(s.id)},C=()=>{E.sendAreaToBack(s.id)},A=l.useCallback(()=>{let k=2,O=2;s.type==="rectangle"&&s.width&&s.height?(k=s.width,O=s.height):s.type==="circle"&&s.radius&&(k=s.radius*1.414,O=s.radius*1.414);const B=Math.min(k,O)*.4;return{width:Math.round(B*10)/10,height:Math.round(B*10)/10}},[s.type,s.width,s.height,s.radius]),V=async k=>{var B;const O=(B=k.target.files)==null?void 0:B[0];if(O){f(!0);try{const v=await Hs(s.id,O),F=A();E.updateArea(s.id,{logo:{filename:v.filename,position:"center",width:F.width,height:F.height,keepAspectRatio:!0,opacity:.8}})}catch(v){console.error("Failed to upload logo:",v)}finally{f(!1),m.current&&(m.current.value="")}}},M=async()=>{try{await Ws(s.id),E.updateArea(s.id,{logo:void 0})}catch(k){console.error("Failed to remove logo:",k)}},K=k=>{s.logo&&E.updateArea(s.id,{logo:{...s.logo,position:k}})},N=k=>{if(!s.logo)return;const O=parseFloat(k.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.width>0){const B=s.logo.height/s.logo.width;E.updateArea(s.id,{logo:{...s.logo,width:O,height:Math.round(O*B*10)/10}})}else E.updateArea(s.id,{logo:{...s.logo,width:O}})},S=k=>{if(!s.logo)return;const O=parseFloat(k.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.height>0){const B=s.logo.width/s.logo.height;E.updateArea(s.id,{logo:{...s.logo,height:O,width:Math.round(O*B*10)/10}})}else E.updateArea(s.id,{logo:{...s.logo,height:O}})},H=()=>{s.logo&&E.updateArea(s.id,{logo:{...s.logo,keepAspectRatio:!s.logo.keepAspectRatio}})},Z=k=>{s.logo&&E.updateArea(s.id,{logo:{...s.logo,opacity:parseFloat(k.target.value)}})};return e.jsxs("div",{className:"area-editor",children:[e.jsxs("div",{className:"area-editor-header",children:[e.jsx("span",{className:"area-editor-title",children:o("config:areas.editArea")}),e.jsx("button",{className:"area-editor-close",onClick:t,children:"×"})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("common:labels.name")}),e.jsx("input",{type:"text",className:"area-editor-input",value:r,onChange:y,placeholder:o("config:areas.areaName")})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.color")}),e.jsx("div",{className:"color-picker-row",children:ms.map(k=>e.jsx("div",{className:`color-swatch ${s.color===k?"selected":""}`,style:{backgroundColor:k},onClick:()=>j(k)},k))})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.layer")}),e.jsxs("div",{className:"area-layer-buttons",children:[e.jsxs("button",{className:"area-layer-btn",onClick:P,title:o("config:areas.bringToFront"),children:[e.jsx($,{name:"arrow-up",size:12})," ",o("config:areas.front")]}),e.jsxs("button",{className:"area-layer-btn",onClick:C,title:o("config:areas.sendToBack"),children:[e.jsx($,{name:"arrow-down",size:12})," ",o("config:areas.back")]})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.logo")}),e.jsxs("div",{className:"area-logo-section",children:[(ce=s.logo)!=null&&ce.filename?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"area-logo-preview",children:[e.jsx("img",{src:qs(s.logo.filename),alt:"Logo",className:"area-logo-thumbnail"}),e.jsx("button",{className:"area-logo-remove-btn",onClick:M,children:o("config:areas.removeLogo")}),e.jsx("button",{className:"area-logo-replace-btn",onClick:()=>{var k;return(k=m.current)==null?void 0:k.click()},disabled:p,children:p?"...":e.jsx($,{name:"refresh",size:12})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoPosition")}),e.jsx("div",{className:"area-logo-position-row",children:Gs.map(({key:k,labelKey:O})=>{var B;return e.jsx("button",{className:`area-logo-pos-btn ${((B=s.logo)==null?void 0:B.position)===k?"active":""}`,onClick:()=>K(k),children:o(`config:areas.${O}`)},k)})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoSize")}),e.jsxs("div",{className:"area-logo-size-row",children:[e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoWidth")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.width,onChange:N,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoHeight")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.height,onChange:S,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-aspect-label",title:o("config:areas.keepAspectRatio"),children:[e.jsx("input",{type:"checkbox",checked:s.logo.keepAspectRatio,onChange:H}),o("config:areas.keepAspectRatio")]})]})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoOpacity")}),e.jsxs("div",{className:"area-logo-opacity-row",children:[e.jsx("input",{type:"range",min:0,max:1,step:.05,value:s.logo.opacity??.8,onChange:Z,className:"area-logo-opacity-slider"}),e.jsxs("span",{className:"area-logo-opacity-value",children:[Math.round((s.logo.opacity??.8)*100),"%"]})]})]})]}):e.jsx("button",{className:"area-logo-upload-btn",onClick:()=>{var k;return(k=m.current)==null?void 0:k.click()},disabled:p,children:p?"...":o("config:areas.uploadLogo")}),e.jsx("input",{ref:m,type:"file",accept:"image/*",style:{display:"none"},onChange:V})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.folders",{count:s.directories.length})}),e.jsxs("div",{className:"area-folders-list",children:[s.directories.map(k=>e.jsxs("div",{className:"area-folder-item",title:k,children:[e.jsx("span",{className:"area-folder-icon clickable",onClick:()=>a==null?void 0:a(s.id),title:o("config:areas.openFolder"),children:e.jsx($,{name:"folder",size:14})}),e.jsx("span",{className:"area-folder-path",children:k.split("/").pop()||k}),e.jsx("button",{className:"area-folder-remove",onClick:O=>D(k,O),title:o("config:areas.removeFolder"),children:"×"})]},k)),u?e.jsxs("div",{className:"area-add-folder-inline",children:[e.jsx(gs,{value:x,onChange:b,onSubmit:_,placeholder:o("config:areas.folderPlaceholder"),className:"area-add-folder-input",directoriesOnly:!0,autoFocus:!0}),e.jsx("button",{className:"area-add-folder-confirm",onClick:_,children:"+"})]}):e.jsx("button",{className:"area-add-folder-btn",onClick:()=>w(!0),children:o("config:areas.addFolder")})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.prompt","Prompt")}),e.jsx("textarea",{className:"area-editor-input",value:c,onChange:h,placeholder:o("config:areas.promptPlaceholder","System prompt for agents in this area..."),rows:4,style:{resize:"vertical",fontFamily:"monospace",fontSize:12}}),e.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4},children:o("config:areas.promptHint","This prompt is injected into agents assigned to this area. Takes effect on next context refresh.")})]}),s.assignedAgentIds.length>0&&e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.assignedAgents",{count:s.assignedAgentIds.length})}),e.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:o("config:areas.rightClickUnassign")})]})]})}function Js(){const{t:s}=Y(["config","common"]),t=fs(),[a,o]=l.useState(!1),[r,d]=l.useState(null),[c,n]=l.useState({name:"",key:"",value:"",description:""}),[u,w]=l.useState(null),x=()=>{o(!0),d(null),n({name:"",key:"",value:"",description:""})},b=h=>{d(h.id),o(!1),n({name:h.name,key:h.key,value:h.value,description:h.description||""})},p=()=>{o(!1),d(null),n({name:"",key:"",value:"",description:""})},f=()=>{!c.name.trim()||!c.key.trim()||(r?E.updateSecret(r,{name:c.name.trim(),key:c.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:c.value,description:c.description.trim()||void 0}):E.createSecret({name:c.name.trim(),key:c.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:c.value,description:c.description.trim()||void 0}),p())},m=h=>{w(h)},y=()=>{u&&(E.deleteSecret(u),r===u&&p())},j=h=>{navigator.clipboard.writeText(`{{${h}}}`)};return e.jsxs("div",{className:"secrets-section",children:[e.jsx("div",{className:"secrets-description",children:s("config:secrets.description",{placeholder:"{{KEY}}"})}),e.jsx("div",{className:"secrets-list",children:t.length===0&&!a?e.jsx("div",{className:"secrets-empty",children:s("config:secrets.noSecrets")}):t.map(h=>e.jsxs("div",{className:`secret-item ${r===h.id?"editing":""}`,children:[e.jsxs("div",{className:"secret-item-header",children:[e.jsxs("div",{className:"secret-item-info",children:[e.jsx("span",{className:"secret-item-name",children:h.name}),e.jsx("code",{className:"secret-item-key",onClick:()=>j(h.key),title:s("config:secrets.copyPlaceholder"),children:`{{${h.key}}}`})]}),e.jsxs("div",{className:"secret-item-actions",children:[e.jsx("button",{className:"secret-item-btn edit",onClick:()=>b(h),title:s("common:buttons.edit"),children:e.jsx($,{name:"edit",size:12})}),e.jsx("button",{className:"secret-item-btn delete",onClick:()=>m(h.id),title:s("common:buttons.delete"),children:"×"})]})]}),h.description&&e.jsx("div",{className:"secret-item-description",children:h.description})]},h.id))}),(a||r)&&e.jsxs("div",{className:"secret-form",children:[e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.name")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.namePlaceholder"),value:c.name,onChange:h=>n({...c,name:h.target.value}),autoFocus:!0})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:"Key"}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.keyPlaceholder"),value:c.key,onChange:h=>n({...c,key:h.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")})}),e.jsx("span",{className:"secret-form-hint",children:s("config:secrets.usedAs",{placeholder:`{{${c.key||"KEY"}}}`})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("config:secrets.secretValue")}),e.jsx("input",{type:"password",className:"secret-form-input",placeholder:s("config:secrets.valuePlaceholder"),value:c.value,onChange:h=>n({...c,value:h.target.value})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.description")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.descriptionPlaceholder"),value:c.description,onChange:h=>n({...c,description:h.target.value})})]}),e.jsxs("div",{className:"secret-form-actions",children:[e.jsx("button",{className:"secret-form-btn cancel",onClick:p,children:s("common:buttons.cancel")}),e.jsx("button",{className:"secret-form-btn save",onClick:f,disabled:!c.name.trim()||!c.key.trim(),children:s(r?"config:secrets.update":"common:buttons.add")})]})]}),!a&&!r&&e.jsx("button",{className:"secrets-add-btn",onClick:x,children:s("config:secrets.addSecret")}),e.jsx(ge,{isOpen:u!==null,title:s("common:buttons.delete"),message:s("config:secrets.deleteConfirm"),confirmLabel:s("common:buttons.delete"),cancelLabel:s("common:buttons.cancel"),variant:"danger",onConfirm:y,onClose:()=>w(null)})]})}async function Zs(){const s=X(),t=await fetch(`${J()}/api/agents/system-settings/prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!t.ok)throw new Error(`Failed to fetch system prompt: ${t.statusText}`);return(await t.json()).prompt||""}async function Xs(s){const t=X(),a=await fetch(`${J()}/api/agents/system-settings/prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({prompt:s})});if(!a.ok)throw new Error(`Failed to update system prompt: ${a.statusText}`)}async function Qs(){const s=X(),t=await fetch(`${J()}/api/agents/system-settings/prompt`,{method:"DELETE",headers:{Authorization:`Bearer ${s}`}});if(!t.ok)throw new Error(`Failed to clear system prompt: ${t.statusText}`)}async function ea(){const s=X(),t=await fetch(`${J()}/api/agents/system-settings/echo-prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!t.ok)throw new Error(`Failed to fetch echo prompt setting: ${t.statusText}`);return(await t.json()).enabled||!1}async function sa(s){const t=X(),a=await fetch(`${J()}/api/agents/system-settings/echo-prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({enabled:s})});if(!a.ok)throw new Error(`Failed to update echo prompt setting: ${a.statusText}`)}async function aa(){const s=X(),t=await fetch(`${J()}/api/agents/system-settings/codex-binary`,{headers:{Authorization:`Bearer ${s}`}});if(!t.ok)throw new Error(`Failed to fetch codex binary path: ${t.statusText}`);return(await t.json()).path||""}async function ta(s){const t=X(),a=await fetch(`${J()}/api/agents/system-settings/codex-binary`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({path:s})});if(!a.ok)throw new Error(`Failed to update codex binary path: ${a.statusText}`)}async function na(){const s=X(),t=await fetch(`${J()}/api/agents/system-settings/tmux-mode`,{headers:{Authorization:`Bearer ${s}`}});if(!t.ok)throw new Error(`Failed to fetch tmux mode setting: ${t.statusText}`);return(await t.json()).enabled||!1}async function ia(s){const t=X(),a=await fetch(`${J()}/api/agents/system-settings/tmux-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({enabled:s})});if(!a.ok)throw new Error(`Failed to update tmux mode setting: ${a.statusText}`)}async function oa(){const s=X(),t=await fetch(`${J()}/api/agents/system-settings/backup`,{headers:{Authorization:`Bearer ${s}`}});if(!t.ok)throw new Error(`Failed to fetch backup status: ${t.statusText}`);return t.json()}async function la(s){const t=X(),a=await fetch(`${J()}/api/agents/system-settings/backup`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({enabled:s})});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.error||`Failed to update backup setting: ${a.statusText}`)}return a.json()}function ca({checked:s,onChange:t,disabled:a}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,disabled:a,onChange:o=>t(o.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function ra(){const{t:s}=Y(["config","common"]),[t,a]=l.useState([]),[o,r]=l.useState(new Set),[d,c]=l.useState(new Set),[n,u]=l.useState(!1),[w,x]=l.useState(!1),[b,p]=l.useState(null),[f,m]=l.useState(null),[y,j]=l.useState(null),[h,_]=l.useState(null),[D,P]=l.useState(!1),[C,A]=l.useState(null);l.useEffect(()=>{we(me("/api/config/categories")).then(v=>v.json()).then(v=>{const F=Array.isArray(v)?v:[];a(F),r(new Set(F.map(R=>R.id)))}).catch(v=>console.error("Failed to fetch config categories:",v))},[]),l.useEffect(()=>{oa().then(_).catch(v=>{console.error("Failed to fetch backup status:",v),A(v.message||"Failed to fetch backup status")})},[]);const V=async v=>{if(!D){P(!0),A(null);try{const F=await la(v);_(F)}catch(F){A(F.message||"Failed to update backup setting")}finally{P(!1)}}},M=v=>{r(F=>{const R=new Set(F);return R.has(v)?R.delete(v):R.add(v),R})},K=v=>{c(F=>{const R=new Set(F);return R.has(v)?R.delete(v):R.add(v),R})},N=()=>r(new Set(t.map(v=>v.id))),S=()=>r(new Set),H=()=>{f&&c(new Set(f.categories.map(v=>v.id)))},Z=()=>c(new Set),ce=async()=>{var v;if(o.size!==0){u(!0),j(null);try{const F=Array.from(o).join(","),R=await we(me(`/api/config/export?categories=${F}`));if(!R.ok)throw new Error("Export failed");const Q=await R.blob(),ae=window.URL.createObjectURL(Q),ee=document.createElement("a");ee.href=ae;const T=R.headers.get("Content-Disposition"),q=((v=T==null?void 0:T.match(/filename="(.+)"/))==null?void 0:v[1])||"tide-commander-config.zip";ee.download=q,document.body.appendChild(ee),ee.click(),document.body.removeChild(ee),window.URL.revokeObjectURL(ae),j({type:"success",text:s("config:data.exportSuccess")})}catch(F){j({type:"error",text:F.message||"Export failed"})}finally{u(!1)}}},k=async v=>{var R;const F=(R=v.target.files)==null?void 0:R[0];if(F){p(F),j(null),m(null),c(new Set);try{const Q=await we(me("/api/config/preview"),{method:"POST",headers:{"Content-Type":"application/zip"},body:await F.arrayBuffer()});if(!Q.ok){const T=await Q.json();throw new Error(T.error||"Failed to preview config file")}const ae=await Q.json(),ee=Array.isArray(ae.categories)?ae.categories:[];m({...ae,categories:ee}),c(new Set(ee.map(T=>T.id)))}catch(Q){j({type:"error",text:Q.message||"Failed to read config file"}),p(null)}}},O=async()=>{if(!(!b||d.size===0)){x(!0),j(null);try{const v=Array.from(d).join(","),F=await we(me(`/api/config/import?categories=${v}`),{method:"POST",headers:{"Content-Type":"application/zip"},body:await b.arrayBuffer()}),R=await F.json();if(!F.ok)throw new Error(R.error||"Import failed");j({type:"success",text:R.message||s("config:data.importSuccess")}),p(null),m(null),c(new Set)}catch(v){j({type:"error",text:v.message||"Import failed"})}finally{x(!1)}}},B=()=>{p(null),m(null),c(new Set),j(null)};return e.jsxs("div",{className:"data-section",children:[y&&e.jsx("div",{className:`data-message data-message-${y.type}`,children:y.text}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:"Hourly Backups"}),e.jsx(ca,{checked:!!(h!=null&&h.enabled),disabled:D||!h,onChange:V})]}),e.jsxs("div",{className:"data-backup-info",children:[h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:["Saves a compressed snapshot of your data every hour to"," ",e.jsx("code",{children:h.backupDir}),". Identical snapshots are skipped. Keeps the 8 newest plus one from each of the 2 most recent prior days."]}),!h.scriptExists&&e.jsxs("div",{style:{marginTop:6,color:"var(--dracula-red, #ff5555)"},children:["Backup script not found at ",e.jsx("code",{children:h.scriptPath})]}),h.lastRunAt&&e.jsxs("div",{style:{marginTop:6},children:["Last run: ",new Date(h.lastRunAt).toLocaleString(),h.lastRunOk===!0&&" — ok",h.lastRunOk===!1&&h.lastRunError&&e.jsxs("span",{style:{color:"var(--dracula-red, #ff5555)"},children:[" — ",h.lastRunError]})]})]}):e.jsx("div",{children:"Loading backup status…"}),C&&e.jsx("div",{className:"data-message data-message-error",style:{marginTop:6},children:C})]})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:s("config:data.exportData")}),e.jsxs("div",{className:"data-select-controls",children:[e.jsx("button",{className:"data-select-btn",onClick:N,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:S,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:t.map(v=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:o.has(v.id),onChange:()=>M(v.id)}),e.jsx("span",{className:"data-category-name",children:v.name})]},v.id))}),e.jsx("button",{className:"data-action-btn export",onClick:ce,disabled:n||o.size===0,children:n?s("config:data.exporting"):s("config:data.exportCount",{count:o.size})})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsx("div",{className:"data-subsection-header",children:e.jsx("span",{className:"data-subsection-title",children:s("config:data.importData")})}),b?f?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"data-import-info",children:[e.jsx("div",{className:"data-import-file",children:b.name}),e.jsxs("div",{className:"data-import-date",children:[s("config:data.exported"),": ",new Date(f.exportedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-subtitle",children:s("config:data.selectToImport")}),e.jsxs("div",{className:"data-select-controls",children:[e.jsx("button",{className:"data-select-btn",onClick:H,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:Z,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:f.categories.map(v=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:d.has(v.id),onChange:()=>K(v.id)}),e.jsx("span",{className:"data-category-name",children:v.name}),v.fileCount&&e.jsxs("span",{className:"data-category-count",children:["(",v.fileCount," ",s("config:data.files"),")"]})]},v.id))}),e.jsxs("div",{className:"data-import-actions",children:[e.jsx("button",{className:"data-action-btn cancel",onClick:B,children:s("common:buttons.cancel")}),e.jsx("button",{className:"data-action-btn import",onClick:O,disabled:w||d.size===0,children:w?s("config:data.importing"):s("config:data.importCount",{count:d.size})})]})]}):e.jsx("div",{className:"data-loading",children:s("config:data.readingFile")}):e.jsxs("label",{className:"data-file-input",children:[e.jsx("input",{type:"file",accept:".zip",onChange:k,style:{display:"none"}}),e.jsx("span",{className:"data-file-input-label",children:s("config:data.selectFile")})]})]})]})}async function da(){const s=await we(`${J()}/api/system/install-info`);if(!s.ok)throw new Error(`Failed to fetch install info: ${s.statusText}`);return s.json()}function ua(s,t){const a=new AbortController;return(async()=>{try{const o=await fetch(is(`${J()}/api/system/self-update`),{method:"POST",signal:a.signal,headers:{Accept:"text/event-stream"}});if(!o.ok||!o.body){const n=await o.text().catch(()=>"");let u=null;try{u=JSON.parse(n)}catch{}const w=u&&typeof u=="object"&&"error"in u&&typeof u.error=="string"?u.error:`Self-update failed: ${o.status} ${o.statusText}`;s({type:"error",message:w}),t(new Error(w));return}const r=o.body.getReader(),d=new TextDecoder("utf-8");let c="";for(;;){const{value:n,done:u}=await r.read();if(u)break;c+=d.decode(n,{stream:!0});let w=c.indexOf(`
1
+ import{r as l,aT as Re,aU as Ye,j as e,I as $,u as Y,aV as ts,a2 as ns,f as Ve,s as E,aW as hs,k as is,l as me,aX as X,aY as ms,aM as gs,aZ as fs,C as ge,a_ as J,aJ as we,a$ as xs,b0 as bs,b1 as js,b2 as ws,b3 as Ce,b4 as os,b5 as ys,b6 as Be,b7 as vs,b8 as Ns,b9 as ks,ba as Cs,bb as Ss,bc as Ts,bd as As,aF as _s,J as Es,S as ke,be as Is,bf as Ps,aH as $s,bg as Ue,K as Pe,aQ as Ls,bh as ze,bi as Ds}from"./main-CBiZdw6w.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ke="deivid11/tide-commander",Fs=`https://api.github.com/repos/${Ke}/releases/latest`,Os=`https://api.github.com/repos/${Ke}/releases?per_page=3`,Rs=3600*1e3,Je="app_update_dismissed_version",Ze="1.100.0";function Us(){var x,b;const[s,t]=l.useState({isChecking:!1,updateAvailable:!1,updateInfo:null,recentReleases:[],error:null,currentVersion:Ze}),a=((b=(x=Re)==null?void 0:x.getPlatform)==null?void 0:b.call(x))==="android"||!1,o=p=>p.replace(/^v/,"").split(".").map(m=>parseInt(m,10)||0),r=(p,f)=>{const m=o(p),y=o(f),j=Math.max(m.length,y.length);for(let h=0;h<j;h++){const _=m[h]||0,D=y[h]||0;if(_>D)return 1;if(_<D)return-1}return 0},d=async p=>{var m,y;if(Re&&Ye&&((y=(m=Re).isNativePlatform)==null?void 0:y.call(m))===!0){const j=await Ye.get({url:p,headers:{Accept:"application/vnd.github.v3+json"}});return{data:j.data,status:j.status}}else{const j=await fetch(p,{headers:{Accept:"application/vnd.github.v3+json"}});return j.ok?{data:await j.json(),status:j.status}:{data:null,status:j.status}}},c=l.useCallback(async(p=!1)=>{t(f=>({...f,isChecking:!0,error:null}));try{const[f,m]=await Promise.all([d(Fs),d(Os)]);if(f.status!==200)throw new Error(`GitHub API error: ${f.status}`);const y=f.data,j=y.tag_name;let h=[];m.status===200&&m.data&&(h=m.data.map(A=>({version:A.tag_name,name:A.name,publishedAt:A.published_at,releaseUrl:A.html_url})));const _=localStorage.getItem(Je);if(!p&&_===j)return t(A=>({...A,isChecking:!1,updateAvailable:!1,recentReleases:h})),null;if(!(r(j,Ze)>0))return t(A=>({...A,isChecking:!1,updateAvailable:!1,recentReleases:h})),null;const P=y.assets.find(A=>A.name.endsWith(".apk")&&A.content_type==="application/vnd.android.package-archive"),C={version:j,name:y.name,changelog:y.body,releaseUrl:y.html_url,apkUrl:(P==null?void 0:P.browser_download_url)||null,apkSize:(P==null?void 0:P.size)||null,publishedAt:y.published_at};return t(A=>({...A,isChecking:!1,updateAvailable:!0,updateInfo:C,recentReleases:h})),C}catch(f){const m=f instanceof Error?f.message:"Failed to check for updates";return t(y=>({...y,isChecking:!1,error:m})),null}},[]),n=l.useCallback(async()=>{var p,f,m;if(!((p=s.updateInfo)!=null&&p.apkUrl)){(f=s.updateInfo)!=null&&f.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}if(!a){(m=s.updateInfo)!=null&&m.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}try{window.open(s.updateInfo.apkUrl,"_system"),t(y=>({...y,error:null}))}catch(y){const j=y instanceof Error?y.message:"Failed to open download";t(h=>({...h,error:j}))}},[s.updateInfo,a]),u=l.useCallback(()=>{s.updateInfo&&localStorage.setItem(Je,s.updateInfo.version),t(p=>({...p,updateAvailable:!1,updateInfo:null}))},[s.updateInfo]),w=l.useCallback(()=>{var p;(p=s.updateInfo)!=null&&p.releaseUrl?window.open(s.updateInfo.releaseUrl,"_blank"):window.open(`https://github.com/${Ke}/releases`,"_blank")},[s.updateInfo]);return l.useEffect(()=>{if(!a)return;const p=setTimeout(()=>{c()},5e3),f=setInterval(()=>{c()},Rs);return()=>{clearTimeout(p),clearInterval(f)}},[a,c]),{...s,isAndroid:a,checkForUpdate:c,downloadAndInstall:n,dismissUpdate:u,openReleasePage:w}}const ls="tide-toolbox-collapse";function zs(s,t){try{const a=localStorage.getItem(`${ls}-${s}`);if(a!==null)return a==="true"}catch{}return t}function Ms(s,t){try{localStorage.setItem(`${ls}-${s}`,String(t))}catch{}}function W({title:s,storageKey:t,defaultOpen:a=!1,forceOpen:o=!1,children:r,headerExtra:d}){const[c,n]=l.useState(()=>t?zs(t,a):a),u=()=>{const x=!c;n(x),t&&Ms(t,x)},w=o||c;return e.jsxs("div",{className:`collapsible-section ${w?"open":"collapsed"}`,children:[e.jsxs("button",{className:"collapsible-header",onClick:u,children:[e.jsx("span",{className:"collapsible-title",children:s}),e.jsxs("span",{className:"collapsible-header-right",children:[d,e.jsx("span",{className:"collapsible-arrow",children:e.jsx($,{name:w?"caret-down":"caret-right",size:10})})]})]}),w&&e.jsx("div",{className:"collapsible-content",children:r})]})}function Bs({area:s,isSelected:t,onClick:a,onDelete:o}){const{t:r}=Y(["config","common"]),d=s.assignedAgentIds.length,c=s.type==="rectangle"?r("config:areas.rect"):r("config:areas.circle");return e.jsxs("div",{className:`area-item ${t?"selected":""}`,onClick:a,children:[e.jsx("div",{className:"area-color-dot",style:{backgroundColor:s.color}}),e.jsxs("div",{className:"area-info",children:[e.jsx("div",{className:"area-name",children:s.name}),e.jsxs("div",{className:"area-meta",children:[c," ",d>0&&`• ${d} ${d>1?r("common:labels.agents").toLowerCase():r("common:labels.agent").toLowerCase()}`]})]}),e.jsx("button",{className:"area-delete-btn",onClick:o,title:r("config:areas.deleteArea"),children:"×"})]})}function Vs({building:s,isSelected:t,onClick:a,onEdit:o}){var n;const{t:r}=Y(["config"]),d=((n=s.pm2Status)==null?void 0:n.ports)||[],c=(u,w)=>{u.stopPropagation(),window.open(`http://${window.location.hostname}:${w}`,"_blank")};return e.jsxs("div",{className:`building-item ${t?"selected":""}`,onClick:a,children:[e.jsx("div",{className:"building-status-dot",style:{backgroundColor:ts[s.status]},title:s.status}),e.jsx("div",{className:"building-icon",children:e.jsx($,{name:ns(s.type),size:16})}),e.jsxs("div",{className:"building-info",children:[e.jsx("div",{className:"building-name",children:s.name}),e.jsxs("div",{className:"building-meta",children:[s.type,d.length>0&&e.jsx("span",{className:"building-ports",children:d.map(u=>e.jsxs("a",{href:`http://${window.location.hostname}:${u}`,className:"building-port-link",onClick:w=>c(w,u),title:`Open :${u}`,children:[":",u]},u))})]})]}),e.jsx("button",{className:"building-edit-btn",onClick:u=>{u.stopPropagation(),o()},title:r("config:buildings.editBuilding"),children:e.jsx($,{name:"gear",size:14})})]})}function Ks({building:s,onClose:t,onOpenModal:a}){var w,x,b,p,f,m,y,j;const{t:o}=Y(["config","common"]),{buildingLogs:r}=Ve(),d=E.getBuildingLogs(s.id),c=hs[s.style||"server-rack"],n=h=>{E.sendBuildingCommand(s.id,h)},u=h=>{window.open(h,"_blank")};return e.jsxs("div",{className:"building-editor",children:[e.jsxs("div",{className:"building-editor-header",children:[e.jsxs("div",{className:"building-editor-title-row",children:[e.jsx("span",{className:"building-editor-icon",children:e.jsx($,{name:ns(s.type),size:18})}),e.jsx("span",{className:"building-editor-title",children:s.name}),e.jsx("span",{className:"building-editor-status",style:{backgroundColor:ts[s.status]},children:s.status})]}),e.jsx("button",{className:"building-editor-close",onClick:t,children:"×"})]}),e.jsx("div",{className:"building-editor-section",children:e.jsxs("div",{className:"building-editor-info-grid",children:[e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("common:labels.type")}),e.jsx("span",{className:"building-editor-info-value",children:s.type})]}),e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.style")}),e.jsx("span",{className:"building-editor-info-value",children:c.label})]}),s.cwd&&e.jsxs("div",{className:"building-editor-info-item building-editor-info-wide",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.directory")}),e.jsx("span",{className:"building-editor-info-value building-editor-cwd",title:s.cwd,children:s.cwd.split("/").pop()||s.cwd})]})]})}),s.type==="server"&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.actions")}),e.jsxs("div",{className:"building-editor-actions",children:[e.jsxs("button",{className:"building-editor-action-btn start",onClick:()=>n("start"),disabled:!((w=s.commands)!=null&&w.start)||s.status==="running",title:((x=s.commands)==null?void 0:x.start)||o("config:buildings.noStartCommand"),children:[e.jsx($,{name:"play",size:12})," ",o("common:buttons.start")]}),e.jsxs("button",{className:"building-editor-action-btn stop",onClick:()=>n("stop"),disabled:!((b=s.commands)!=null&&b.stop)||s.status==="stopped",title:((p=s.commands)==null?void 0:p.stop)||o("config:buildings.noStopCommand"),children:[e.jsx($,{name:"stop",size:12,weight:"fill"})," ",o("common:buttons.stop")]}),e.jsxs("button",{className:"building-editor-action-btn restart",onClick:()=>n("restart"),disabled:!((f=s.commands)!=null&&f.restart),title:((m=s.commands)==null?void 0:m.restart)||o("config:buildings.noRestartCommand"),children:[e.jsx($,{name:"refresh",size:12})," ",o("common:buttons.retry")]}),e.jsxs("button",{className:"building-editor-action-btn health",onClick:()=>n("healthCheck"),disabled:!((y=s.commands)!=null&&y.healthCheck),title:((j=s.commands)==null?void 0:j.healthCheck)||o("config:buildings.noHealthCheck"),children:[e.jsx($,{name:"heart",size:12})," Health"]})]})]}),s.urls&&s.urls.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.links")}),e.jsx("div",{className:"building-editor-links",children:s.urls.map((h,_)=>e.jsxs("button",{className:"building-editor-link",onClick:()=>u(h.url),title:h.url,children:[e.jsx($,{name:"link",size:12})," ",h.label||h.url]},_))})]}),d.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsxs("div",{className:"building-editor-section-title",children:[o("config:buildings.recentLogs"),e.jsx("button",{className:"building-editor-clear-logs",onClick:()=>E.clearBuildingLogs(s.id),title:o("common:buttons.clear"),children:o("common:buttons.clear")})]}),e.jsx("div",{className:"building-editor-logs",children:d.slice(-5).map((h,_)=>e.jsx("div",{className:"building-editor-log-entry",children:h},_))})]}),e.jsx("div",{className:"building-editor-footer",children:e.jsxs("button",{className:"building-editor-edit-btn",onClick:a,children:[e.jsx($,{name:"gear",size:12})," ",o("config:buildings.fullSettings")]})})]})}async function Hs(s,t){const a=X(),o=await fetch(me(`/api/areas/${s}/logo`),{method:"POST",headers:{"Content-Type":t.type||"image/png","X-Filename":encodeURIComponent(t.name),...a?{Authorization:`Bearer ${a}`}:{}},body:t});if(!o.ok){const r=await o.json().catch(()=>({error:o.statusText}));throw new Error(r.error||`Upload failed: ${o.statusText}`)}return o.json()}async function Ws(s){const t=X(),a=await fetch(me(`/api/areas/${s}/logo`),{method:"DELETE",headers:{...t?{Authorization:`Bearer ${t}`}:{}}});if(!a.ok)throw new Error(`Failed to delete logo: ${a.statusText}`)}function qs(s){return is(me(`/api/areas/logos/${s}`))}const Gs=[{key:"center",labelKey:"posCenter"},{key:"top-left",labelKey:"posTopLeft"},{key:"top-right",labelKey:"posTopRight"},{key:"bottom-left",labelKey:"posBottomLeft"},{key:"bottom-right",labelKey:"posBottomRight"}];function Ys({area:s,onClose:t,onOpenFolder:a}){var ce;const{t:o}=Y(["config","common"]),[r,d]=l.useState(s.name),[c,n]=l.useState(s.prompt||""),[u,w]=l.useState(!1),[x,b]=l.useState(""),[p,f]=l.useState(!1),m=l.useRef(null);l.useEffect(()=>{d(s.name)},[s.id,s.name]),l.useEffect(()=>{n(s.prompt||"")},[s.id,s.prompt]);const y=k=>{const O=k.target.value;d(O),E.updateArea(s.id,{name:O})},j=k=>{E.updateArea(s.id,{color:k})},h=k=>{const O=k.target.value;n(O),E.updateArea(s.id,{prompt:O})},_=()=>{x.trim()&&(E.addDirectoryToArea(s.id,x.trim()),b(""),w(!1))},D=(k,O)=>{O.stopPropagation(),E.removeDirectoryFromArea(s.id,k)},P=()=>{E.bringAreaToFront(s.id)},C=()=>{E.sendAreaToBack(s.id)},A=l.useCallback(()=>{let k=2,O=2;s.type==="rectangle"&&s.width&&s.height?(k=s.width,O=s.height):s.type==="circle"&&s.radius&&(k=s.radius*1.414,O=s.radius*1.414);const B=Math.min(k,O)*.4;return{width:Math.round(B*10)/10,height:Math.round(B*10)/10}},[s.type,s.width,s.height,s.radius]),V=async k=>{var B;const O=(B=k.target.files)==null?void 0:B[0];if(O){f(!0);try{const v=await Hs(s.id,O),F=A();E.updateArea(s.id,{logo:{filename:v.filename,position:"center",width:F.width,height:F.height,keepAspectRatio:!0,opacity:.8}})}catch(v){console.error("Failed to upload logo:",v)}finally{f(!1),m.current&&(m.current.value="")}}},M=async()=>{try{await Ws(s.id),E.updateArea(s.id,{logo:void 0})}catch(k){console.error("Failed to remove logo:",k)}},K=k=>{s.logo&&E.updateArea(s.id,{logo:{...s.logo,position:k}})},N=k=>{if(!s.logo)return;const O=parseFloat(k.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.width>0){const B=s.logo.height/s.logo.width;E.updateArea(s.id,{logo:{...s.logo,width:O,height:Math.round(O*B*10)/10}})}else E.updateArea(s.id,{logo:{...s.logo,width:O}})},S=k=>{if(!s.logo)return;const O=parseFloat(k.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.height>0){const B=s.logo.width/s.logo.height;E.updateArea(s.id,{logo:{...s.logo,height:O,width:Math.round(O*B*10)/10}})}else E.updateArea(s.id,{logo:{...s.logo,height:O}})},H=()=>{s.logo&&E.updateArea(s.id,{logo:{...s.logo,keepAspectRatio:!s.logo.keepAspectRatio}})},Z=k=>{s.logo&&E.updateArea(s.id,{logo:{...s.logo,opacity:parseFloat(k.target.value)}})};return e.jsxs("div",{className:"area-editor",children:[e.jsxs("div",{className:"area-editor-header",children:[e.jsx("span",{className:"area-editor-title",children:o("config:areas.editArea")}),e.jsx("button",{className:"area-editor-close",onClick:t,children:"×"})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("common:labels.name")}),e.jsx("input",{type:"text",className:"area-editor-input",value:r,onChange:y,placeholder:o("config:areas.areaName")})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.color")}),e.jsx("div",{className:"color-picker-row",children:ms.map(k=>e.jsx("div",{className:`color-swatch ${s.color===k?"selected":""}`,style:{backgroundColor:k},onClick:()=>j(k)},k))})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.layer")}),e.jsxs("div",{className:"area-layer-buttons",children:[e.jsxs("button",{className:"area-layer-btn",onClick:P,title:o("config:areas.bringToFront"),children:[e.jsx($,{name:"arrow-up",size:12})," ",o("config:areas.front")]}),e.jsxs("button",{className:"area-layer-btn",onClick:C,title:o("config:areas.sendToBack"),children:[e.jsx($,{name:"arrow-down",size:12})," ",o("config:areas.back")]})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.logo")}),e.jsxs("div",{className:"area-logo-section",children:[(ce=s.logo)!=null&&ce.filename?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"area-logo-preview",children:[e.jsx("img",{src:qs(s.logo.filename),alt:"Logo",className:"area-logo-thumbnail"}),e.jsx("button",{className:"area-logo-remove-btn",onClick:M,children:o("config:areas.removeLogo")}),e.jsx("button",{className:"area-logo-replace-btn",onClick:()=>{var k;return(k=m.current)==null?void 0:k.click()},disabled:p,children:p?"...":e.jsx($,{name:"refresh",size:12})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoPosition")}),e.jsx("div",{className:"area-logo-position-row",children:Gs.map(({key:k,labelKey:O})=>{var B;return e.jsx("button",{className:`area-logo-pos-btn ${((B=s.logo)==null?void 0:B.position)===k?"active":""}`,onClick:()=>K(k),children:o(`config:areas.${O}`)},k)})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoSize")}),e.jsxs("div",{className:"area-logo-size-row",children:[e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoWidth")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.width,onChange:N,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoHeight")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.height,onChange:S,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-aspect-label",title:o("config:areas.keepAspectRatio"),children:[e.jsx("input",{type:"checkbox",checked:s.logo.keepAspectRatio,onChange:H}),o("config:areas.keepAspectRatio")]})]})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoOpacity")}),e.jsxs("div",{className:"area-logo-opacity-row",children:[e.jsx("input",{type:"range",min:0,max:1,step:.05,value:s.logo.opacity??.8,onChange:Z,className:"area-logo-opacity-slider"}),e.jsxs("span",{className:"area-logo-opacity-value",children:[Math.round((s.logo.opacity??.8)*100),"%"]})]})]})]}):e.jsx("button",{className:"area-logo-upload-btn",onClick:()=>{var k;return(k=m.current)==null?void 0:k.click()},disabled:p,children:p?"...":o("config:areas.uploadLogo")}),e.jsx("input",{ref:m,type:"file",accept:"image/*",style:{display:"none"},onChange:V})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.folders",{count:s.directories.length})}),e.jsxs("div",{className:"area-folders-list",children:[s.directories.map(k=>e.jsxs("div",{className:"area-folder-item",title:k,children:[e.jsx("span",{className:"area-folder-icon clickable",onClick:()=>a==null?void 0:a(s.id),title:o("config:areas.openFolder"),children:e.jsx($,{name:"folder",size:14})}),e.jsx("span",{className:"area-folder-path",children:k.split("/").pop()||k}),e.jsx("button",{className:"area-folder-remove",onClick:O=>D(k,O),title:o("config:areas.removeFolder"),children:"×"})]},k)),u?e.jsxs("div",{className:"area-add-folder-inline",children:[e.jsx(gs,{value:x,onChange:b,onSubmit:_,placeholder:o("config:areas.folderPlaceholder"),className:"area-add-folder-input",directoriesOnly:!0,autoFocus:!0}),e.jsx("button",{className:"area-add-folder-confirm",onClick:_,children:"+"})]}):e.jsx("button",{className:"area-add-folder-btn",onClick:()=>w(!0),children:o("config:areas.addFolder")})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.prompt","Prompt")}),e.jsx("textarea",{className:"area-editor-input",value:c,onChange:h,placeholder:o("config:areas.promptPlaceholder","System prompt for agents in this area..."),rows:4,style:{resize:"vertical",fontFamily:"monospace",fontSize:12}}),e.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4},children:o("config:areas.promptHint","This prompt is injected into agents assigned to this area. Takes effect on next context refresh.")})]}),s.assignedAgentIds.length>0&&e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.assignedAgents",{count:s.assignedAgentIds.length})}),e.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:o("config:areas.rightClickUnassign")})]})]})}function Js(){const{t:s}=Y(["config","common"]),t=fs(),[a,o]=l.useState(!1),[r,d]=l.useState(null),[c,n]=l.useState({name:"",key:"",value:"",description:""}),[u,w]=l.useState(null),x=()=>{o(!0),d(null),n({name:"",key:"",value:"",description:""})},b=h=>{d(h.id),o(!1),n({name:h.name,key:h.key,value:h.value,description:h.description||""})},p=()=>{o(!1),d(null),n({name:"",key:"",value:"",description:""})},f=()=>{!c.name.trim()||!c.key.trim()||(r?E.updateSecret(r,{name:c.name.trim(),key:c.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:c.value,description:c.description.trim()||void 0}):E.createSecret({name:c.name.trim(),key:c.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:c.value,description:c.description.trim()||void 0}),p())},m=h=>{w(h)},y=()=>{u&&(E.deleteSecret(u),r===u&&p())},j=h=>{navigator.clipboard.writeText(`{{${h}}}`)};return e.jsxs("div",{className:"secrets-section",children:[e.jsx("div",{className:"secrets-description",children:s("config:secrets.description",{placeholder:"{{KEY}}"})}),e.jsx("div",{className:"secrets-list",children:t.length===0&&!a?e.jsx("div",{className:"secrets-empty",children:s("config:secrets.noSecrets")}):t.map(h=>e.jsxs("div",{className:`secret-item ${r===h.id?"editing":""}`,children:[e.jsxs("div",{className:"secret-item-header",children:[e.jsxs("div",{className:"secret-item-info",children:[e.jsx("span",{className:"secret-item-name",children:h.name}),e.jsx("code",{className:"secret-item-key",onClick:()=>j(h.key),title:s("config:secrets.copyPlaceholder"),children:`{{${h.key}}}`})]}),e.jsxs("div",{className:"secret-item-actions",children:[e.jsx("button",{className:"secret-item-btn edit",onClick:()=>b(h),title:s("common:buttons.edit"),children:e.jsx($,{name:"edit",size:12})}),e.jsx("button",{className:"secret-item-btn delete",onClick:()=>m(h.id),title:s("common:buttons.delete"),children:"×"})]})]}),h.description&&e.jsx("div",{className:"secret-item-description",children:h.description})]},h.id))}),(a||r)&&e.jsxs("div",{className:"secret-form",children:[e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.name")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.namePlaceholder"),value:c.name,onChange:h=>n({...c,name:h.target.value}),autoFocus:!0})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:"Key"}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.keyPlaceholder"),value:c.key,onChange:h=>n({...c,key:h.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")})}),e.jsx("span",{className:"secret-form-hint",children:s("config:secrets.usedAs",{placeholder:`{{${c.key||"KEY"}}}`})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("config:secrets.secretValue")}),e.jsx("input",{type:"password",className:"secret-form-input",placeholder:s("config:secrets.valuePlaceholder"),value:c.value,onChange:h=>n({...c,value:h.target.value})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.description")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.descriptionPlaceholder"),value:c.description,onChange:h=>n({...c,description:h.target.value})})]}),e.jsxs("div",{className:"secret-form-actions",children:[e.jsx("button",{className:"secret-form-btn cancel",onClick:p,children:s("common:buttons.cancel")}),e.jsx("button",{className:"secret-form-btn save",onClick:f,disabled:!c.name.trim()||!c.key.trim(),children:s(r?"config:secrets.update":"common:buttons.add")})]})]}),!a&&!r&&e.jsx("button",{className:"secrets-add-btn",onClick:x,children:s("config:secrets.addSecret")}),e.jsx(ge,{isOpen:u!==null,title:s("common:buttons.delete"),message:s("config:secrets.deleteConfirm"),confirmLabel:s("common:buttons.delete"),cancelLabel:s("common:buttons.cancel"),variant:"danger",onConfirm:y,onClose:()=>w(null)})]})}async function Zs(){const s=X(),t=await fetch(`${J()}/api/agents/system-settings/prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!t.ok)throw new Error(`Failed to fetch system prompt: ${t.statusText}`);return(await t.json()).prompt||""}async function Xs(s){const t=X(),a=await fetch(`${J()}/api/agents/system-settings/prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({prompt:s})});if(!a.ok)throw new Error(`Failed to update system prompt: ${a.statusText}`)}async function Qs(){const s=X(),t=await fetch(`${J()}/api/agents/system-settings/prompt`,{method:"DELETE",headers:{Authorization:`Bearer ${s}`}});if(!t.ok)throw new Error(`Failed to clear system prompt: ${t.statusText}`)}async function ea(){const s=X(),t=await fetch(`${J()}/api/agents/system-settings/echo-prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!t.ok)throw new Error(`Failed to fetch echo prompt setting: ${t.statusText}`);return(await t.json()).enabled||!1}async function sa(s){const t=X(),a=await fetch(`${J()}/api/agents/system-settings/echo-prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({enabled:s})});if(!a.ok)throw new Error(`Failed to update echo prompt setting: ${a.statusText}`)}async function aa(){const s=X(),t=await fetch(`${J()}/api/agents/system-settings/codex-binary`,{headers:{Authorization:`Bearer ${s}`}});if(!t.ok)throw new Error(`Failed to fetch codex binary path: ${t.statusText}`);return(await t.json()).path||""}async function ta(s){const t=X(),a=await fetch(`${J()}/api/agents/system-settings/codex-binary`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({path:s})});if(!a.ok)throw new Error(`Failed to update codex binary path: ${a.statusText}`)}async function na(){const s=X(),t=await fetch(`${J()}/api/agents/system-settings/tmux-mode`,{headers:{Authorization:`Bearer ${s}`}});if(!t.ok)throw new Error(`Failed to fetch tmux mode setting: ${t.statusText}`);return(await t.json()).enabled||!1}async function ia(s){const t=X(),a=await fetch(`${J()}/api/agents/system-settings/tmux-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({enabled:s})});if(!a.ok)throw new Error(`Failed to update tmux mode setting: ${a.statusText}`)}async function oa(){const s=X(),t=await fetch(`${J()}/api/agents/system-settings/backup`,{headers:{Authorization:`Bearer ${s}`}});if(!t.ok)throw new Error(`Failed to fetch backup status: ${t.statusText}`);return t.json()}async function la(s){const t=X(),a=await fetch(`${J()}/api/agents/system-settings/backup`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({enabled:s})});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.error||`Failed to update backup setting: ${a.statusText}`)}return a.json()}function ca({checked:s,onChange:t,disabled:a}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,disabled:a,onChange:o=>t(o.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function ra(){const{t:s}=Y(["config","common"]),[t,a]=l.useState([]),[o,r]=l.useState(new Set),[d,c]=l.useState(new Set),[n,u]=l.useState(!1),[w,x]=l.useState(!1),[b,p]=l.useState(null),[f,m]=l.useState(null),[y,j]=l.useState(null),[h,_]=l.useState(null),[D,P]=l.useState(!1),[C,A]=l.useState(null);l.useEffect(()=>{we(me("/api/config/categories")).then(v=>v.json()).then(v=>{const F=Array.isArray(v)?v:[];a(F),r(new Set(F.map(R=>R.id)))}).catch(v=>console.error("Failed to fetch config categories:",v))},[]),l.useEffect(()=>{oa().then(_).catch(v=>{console.error("Failed to fetch backup status:",v),A(v.message||"Failed to fetch backup status")})},[]);const V=async v=>{if(!D){P(!0),A(null);try{const F=await la(v);_(F)}catch(F){A(F.message||"Failed to update backup setting")}finally{P(!1)}}},M=v=>{r(F=>{const R=new Set(F);return R.has(v)?R.delete(v):R.add(v),R})},K=v=>{c(F=>{const R=new Set(F);return R.has(v)?R.delete(v):R.add(v),R})},N=()=>r(new Set(t.map(v=>v.id))),S=()=>r(new Set),H=()=>{f&&c(new Set(f.categories.map(v=>v.id)))},Z=()=>c(new Set),ce=async()=>{var v;if(o.size!==0){u(!0),j(null);try{const F=Array.from(o).join(","),R=await we(me(`/api/config/export?categories=${F}`));if(!R.ok)throw new Error("Export failed");const Q=await R.blob(),ae=window.URL.createObjectURL(Q),ee=document.createElement("a");ee.href=ae;const T=R.headers.get("Content-Disposition"),q=((v=T==null?void 0:T.match(/filename="(.+)"/))==null?void 0:v[1])||"tide-commander-config.zip";ee.download=q,document.body.appendChild(ee),ee.click(),document.body.removeChild(ee),window.URL.revokeObjectURL(ae),j({type:"success",text:s("config:data.exportSuccess")})}catch(F){j({type:"error",text:F.message||"Export failed"})}finally{u(!1)}}},k=async v=>{var R;const F=(R=v.target.files)==null?void 0:R[0];if(F){p(F),j(null),m(null),c(new Set);try{const Q=await we(me("/api/config/preview"),{method:"POST",headers:{"Content-Type":"application/zip"},body:await F.arrayBuffer()});if(!Q.ok){const T=await Q.json();throw new Error(T.error||"Failed to preview config file")}const ae=await Q.json(),ee=Array.isArray(ae.categories)?ae.categories:[];m({...ae,categories:ee}),c(new Set(ee.map(T=>T.id)))}catch(Q){j({type:"error",text:Q.message||"Failed to read config file"}),p(null)}}},O=async()=>{if(!(!b||d.size===0)){x(!0),j(null);try{const v=Array.from(d).join(","),F=await we(me(`/api/config/import?categories=${v}`),{method:"POST",headers:{"Content-Type":"application/zip"},body:await b.arrayBuffer()}),R=await F.json();if(!F.ok)throw new Error(R.error||"Import failed");j({type:"success",text:R.message||s("config:data.importSuccess")}),p(null),m(null),c(new Set)}catch(v){j({type:"error",text:v.message||"Import failed"})}finally{x(!1)}}},B=()=>{p(null),m(null),c(new Set),j(null)};return e.jsxs("div",{className:"data-section",children:[y&&e.jsx("div",{className:`data-message data-message-${y.type}`,children:y.text}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:"Hourly Backups"}),e.jsx(ca,{checked:!!(h!=null&&h.enabled),disabled:D||!h,onChange:V})]}),e.jsxs("div",{className:"data-backup-info",children:[h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:["Saves a compressed snapshot of your data every hour to"," ",e.jsx("code",{children:h.backupDir}),". Identical snapshots are skipped. Keeps the 8 newest plus one from each of the 2 most recent prior days."]}),!h.scriptExists&&e.jsxs("div",{style:{marginTop:6,color:"var(--dracula-red, #ff5555)"},children:["Backup script not found at ",e.jsx("code",{children:h.scriptPath})]}),h.lastRunAt&&e.jsxs("div",{style:{marginTop:6},children:["Last run: ",new Date(h.lastRunAt).toLocaleString(),h.lastRunOk===!0&&" — ok",h.lastRunOk===!1&&h.lastRunError&&e.jsxs("span",{style:{color:"var(--dracula-red, #ff5555)"},children:[" — ",h.lastRunError]})]})]}):e.jsx("div",{children:"Loading backup status…"}),C&&e.jsx("div",{className:"data-message data-message-error",style:{marginTop:6},children:C})]})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:s("config:data.exportData")}),e.jsxs("div",{className:"data-select-controls",children:[e.jsx("button",{className:"data-select-btn",onClick:N,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:S,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:t.map(v=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:o.has(v.id),onChange:()=>M(v.id)}),e.jsx("span",{className:"data-category-name",children:v.name})]},v.id))}),e.jsx("button",{className:"data-action-btn export",onClick:ce,disabled:n||o.size===0,children:n?s("config:data.exporting"):s("config:data.exportCount",{count:o.size})})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsx("div",{className:"data-subsection-header",children:e.jsx("span",{className:"data-subsection-title",children:s("config:data.importData")})}),b?f?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"data-import-info",children:[e.jsx("div",{className:"data-import-file",children:b.name}),e.jsxs("div",{className:"data-import-date",children:[s("config:data.exported"),": ",new Date(f.exportedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-subtitle",children:s("config:data.selectToImport")}),e.jsxs("div",{className:"data-select-controls",children:[e.jsx("button",{className:"data-select-btn",onClick:H,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:Z,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:f.categories.map(v=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:d.has(v.id),onChange:()=>K(v.id)}),e.jsx("span",{className:"data-category-name",children:v.name}),v.fileCount&&e.jsxs("span",{className:"data-category-count",children:["(",v.fileCount," ",s("config:data.files"),")"]})]},v.id))}),e.jsxs("div",{className:"data-import-actions",children:[e.jsx("button",{className:"data-action-btn cancel",onClick:B,children:s("common:buttons.cancel")}),e.jsx("button",{className:"data-action-btn import",onClick:O,disabled:w||d.size===0,children:w?s("config:data.importing"):s("config:data.importCount",{count:d.size})})]})]}):e.jsx("div",{className:"data-loading",children:s("config:data.readingFile")}):e.jsxs("label",{className:"data-file-input",children:[e.jsx("input",{type:"file",accept:".zip",onChange:k,style:{display:"none"}}),e.jsx("span",{className:"data-file-input-label",children:s("config:data.selectFile")})]})]})]})}async function da(){const s=await we(`${J()}/api/system/install-info`);if(!s.ok)throw new Error(`Failed to fetch install info: ${s.statusText}`);return s.json()}function ua(s,t){const a=new AbortController;return(async()=>{try{const o=await fetch(is(`${J()}/api/system/self-update`),{method:"POST",signal:a.signal,headers:{Accept:"text/event-stream"}});if(!o.ok||!o.body){const n=await o.text().catch(()=>"");let u=null;try{u=JSON.parse(n)}catch{}const w=u&&typeof u=="object"&&"error"in u&&typeof u.error=="string"?u.error:`Self-update failed: ${o.status} ${o.statusText}`;s({type:"error",message:w}),t(new Error(w));return}const r=o.body.getReader(),d=new TextDecoder("utf-8");let c="";for(;;){const{value:n,done:u}=await r.read();if(u)break;c+=d.decode(n,{stream:!0});let w=c.indexOf(`
2
2
 
3
3
  `);for(;w!==-1;){const x=c.slice(0,w);c=c.slice(w+2);const b=x.split(`
4
4
  `);let p="message",f="";for(const m of b)m.startsWith(":")||(m.startsWith("event:")?p=m.slice(6).trim():m.startsWith("data:")&&(f+=(f?`
@@ -1,4 +1,4 @@
1
- import{bo as Oe,r as t,s as I,l as ye,bp as Ee,aJ as _e,j as e,I as z,u as fe,bq as ze,br as Te,bs as Ue,bt as Be,m as Ke,bu as We,bv as De,bw as Ve,a6 as qe,a7 as Ge,bx as Je,aS as Ye,J as Me,S as oe,aM as Xe,aI as Qe,_ as Ze,K as Ie,ah as et,U as tt,by as st,n as X,bz as nt}from"./main-B7wf_xU_.js";import{FileExplorerPanel as at}from"./index-Cwlm-Pqi.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ne={status:"all",activity:"all",sort:"activity"},lt={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},Ae=20,me=3,ot={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},ct=12e4;function rt(s){return s.trim().replace(/\r\n/g,`
1
+ import{bo as Oe,r as t,s as I,l as ye,bp as Ee,aJ as _e,j as e,I as z,u as fe,bq as ze,br as Te,bs as Ue,bt as Be,m as Ke,bu as We,bv as De,bw as Ve,a6 as qe,a7 as Ge,bx as Je,aS as Ye,J as Me,S as oe,aM as Xe,aI as Qe,_ as Ze,K as Ie,ah as et,U as tt,by as st,n as X,bz as nt}from"./main-CBiZdw6w.js";import{FileExplorerPanel as at}from"./index-D1nrHGW6.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ne={status:"all",activity:"all",sort:"activity"},lt={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},Ae=20,me=3,ot={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},ct=12e4;function rt(s){return s.trim().replace(/\r\n/g,`
2
2
  `)}function $e(s,a){return`${s}:${rt(a)}`}function it(s,a,l,f){if(s.uuid&&a.has(s.uuid))return!1;if(s.uuid)return!0;const p=s.isUserPrompt?"user":"assistant",d=$e(p,s.text),M=s.timestamp||0,A=l.get(d);return A!==void 0&&Math.abs(M-A)<=ct?!1:M>f}function dt({isOpen:s,agents:a}){const l=Oe(),[f,p]=t.useState(new Map),d=t.useRef(new Set);t.useRef(a);const M=t.useMemo(()=>Array.from(a.keys()).sort().join(","),[a]),A=t.useMemo(()=>Array.from(a.values()).map(j=>`${j.id}:${j.sessionId||""}`).sort().join(","),[a]);t.useEffect(()=>{s||(d.current.clear(),p(new Map))},[s]),t.useEffect(()=>{if(!s)return;const j=new Set(Array.from(a.keys()));for(const i of d.current)j.has(i)||d.current.delete(i);let h=null;l>0&&(h=I.preserveOutputs(),d.current.clear());const v=async(i,C,F=0)=>{if(d.current.add(i.id),F>0&&await new Promise(x=>setTimeout(x,F)),p(x=>{const k=new Map(x);return k.set(i.id,{agentId:i.id,messages:[],loading:!0,hasMore:!1,totalCount:0}),k}),!i.sessionId){C&&C.length>0&&I.mergeOutputsWithHistory(i.id,[],C),p(x=>{const k=new Map(x);return k.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),k});return}try{const k=await(await _e(ye(`/api/agents/${i.id}/history?limit=${Ee}&offset=0`))).json(),P=k.messages||[],W=P.length>0?Math.max(...P.map(w=>w.timestamp?new Date(w.timestamp).getTime():0)):0,J=new Set(P.map(w=>w.uuid).filter(w=>!!w)),V=new Map;for(const w of P){if(w.type!=="user"&&w.type!=="assistant")continue;const c=$e(w.type,w.content),L=w.timestamp?new Date(w.timestamp).getTime():0,K=V.get(c)??0;L>K&&V.set(c,L)}const q=I.getOutputs(i.id),B=(C&&C.length>0?[...C,...q]:q).filter(w=>it(w,J,V,W));I.clearOutputs(i.id);for(const w of B)I.addOutput(i.id,w);p(w=>{const c=new Map(w);return c.set(i.id,{agentId:i.id,messages:P,loading:!1,hasMore:k.hasMore||!1,totalCount:k.totalCount||0}),c})}catch(x){if(console.error(`Failed to load history for ${i.name}:`,x),C&&C.length>0){I.clearOutputs(i.id);for(const k of C)I.addOutput(i.id,k)}p(k=>{const P=new Map(k);return P.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),P})}},u=l>0?500:0,D=Array.from(a.values());for(const i of D)if(!d.current.has(i.id)){const C=h==null?void 0:h.get(i.id);v(i,C,u)}},[s,M,A,l]);const R=t.useRef(a),N=t.useRef(f);R.current=a,N.current=f;const b=t.useCallback(async j=>{const h=R.current.get(j),v=N.current.get(j);if(!(h!=null&&h.sessionId)||!v||!v.hasMore)return;const u=v.messages.length;try{const i=await(await fetch(ye(`/api/agents/${j}/history?limit=${Ee}&offset=${u}`))).json();i.messages&&i.messages.length>0&&p(C=>{const F=new Map(C),x=C.get(j);return x&&F.set(j,{...x,messages:[...i.messages,...x.messages],hasMore:i.hasMore||!1}),F})}catch(D){console.error(`Failed to load more history for agent ${j}:`,D)}},[]),E=t.useCallback(j=>{d.current.delete(j),p(h=>{const v=new Map(h),u=h.get(j);return u&&v.set(j,{...u,messages:[],hasMore:!1,totalCount:0,loading:!1}),v})},[]);return{histories:f,loadMoreHistory:b,clearAgentHistory:E}}function ut({command:s,onCommandChange:a,useTextarea:l,forceTextarea:f,onForceTextarea:p,onSend:d,canSend:M,attachedFiles:A,onAddFile:R,onRemoveFile:N,uploadFile:b,onAddPastedText:E,placeholder:j="Message...",className:h="",compact:v=!1,inputRef:u}){const D=t.useRef(null),i=t.useRef(null),C=t.useRef(l);t.useEffect(()=>{if(l&&!C.current&&i.current){const c=i.current;c.focus(),c.selectionStart=c.selectionEnd=c.value.length}C.current=l},[l]),t.useEffect(()=>{const c=i.current;if(!c||!l)return;c.style.height="auto";const L=v?120:180,K=Math.min(c.scrollHeight,L);c.style.height=`${K}px`},[s,l,v]);const F=t.useCallback(async c=>{const L=c.clipboardData.items;for(const _ of L)if(_.type.startsWith("image/")){c.preventDefault();const $=_.getAsFile();if($){const H=await b($);H&&R(H)}return}const K=c.clipboardData.files;if(K.length>0){c.preventDefault();for(const _ of K){const $=await b(_);$&&R($)}return}const U=c.clipboardData.getData("text"),te=(U.match(/\n/g)||[]).length+1;if(te>5){c.preventDefault();const $=`[Pasted text #${E(U)} +${te} lines]`,H=c.target,se=H.selectionStart||0,ae=H.selectionEnd||0,ne=s.slice(0,se)+$+s.slice(ae);a(ne),l||p(!0)}},[s,a,l,p,b,R,E]),x=t.useCallback(async c=>{const L=c.target.files;if(L){for(const K of L){const U=await b(K);U&&R(U)}D.current&&(D.current.value="")}},[b,R]),k=t.useCallback(c=>{if(c.key==="Enter"&&c.shiftKey){l||(c.preventDefault(),p(!0));return}c.key==="Enter"&&(c.preventDefault(),d())},[l,p,d]),P=t.useCallback(c=>{},[]),W=t.useCallback(c=>{c.button===1&&(c.preventDefault(),c.stopPropagation())},[]),J=t.useCallback(c=>{i.current=c,u==null||u(c)},[u]),V=v?"agent-panel-input":"guake-input",q=v?"agent-panel-input-container":"guake-input-container",Q=v?"agent-panel-attach-btn":"guake-attach-btn",B=v?"agent-panel-send-btn":"",w=l?v?"agent-panel-input-expanded":"guake-input-expanded":"";return e.jsxs(e.Fragment,{children:[A.length>0&&e.jsx("div",{className:v?"agent-panel-attachments":"guake-attachments",children:A.map(c=>e.jsxs("div",{className:`${v?"agent-panel-attachment":"guake-attachment"} ${c.isImage?"is-image":""}`,children:[e.jsx("span",{className:v?"agent-panel-attachment-icon":"guake-attachment-icon",children:e.jsx(z,{name:c.isImage?"file":"paperclip",size:12})}),e.jsx("span",{className:v?"agent-panel-attachment-name":"guake-attachment-name",title:c.path,children:c.name}),!v&&e.jsxs("span",{className:"guake-attachment-size",children:["(",Math.round(c.size/1024),"KB)"]}),e.jsx("button",{className:v?"agent-panel-attachment-remove":"guake-attachment-remove",onClick:()=>N(c.id),title:"Remove",children:"×"})]},c.id))}),e.jsxs("div",{className:`${V} ${w} ${h}`,children:[e.jsx("input",{ref:D,type:"file",multiple:!0,onChange:x,style:{display:"none"},accept:"*"}),e.jsxs("div",{className:q,onAuxClick:W,children:[e.jsx("button",{className:Q,onClick:()=>{var c;return(c=D.current)==null?void 0:c.click()},title:"Attach file (or paste image)",children:e.jsx(z,{name:"paperclip",size:14})}),l?e.jsx("textarea",{ref:J,placeholder:j,value:s,onChange:c=>a(c.target.value),onKeyDown:k,onPaste:F,onMouseDown:P}):e.jsx("input",{ref:u,type:"text",placeholder:j,value:s,onChange:c=>a(c.target.value),onKeyDown:k,onPaste:F,onMouseDown:P}),e.jsx("button",{className:B,onClick:d,disabled:!M,title:"Send",children:e.jsx(z,{name:"send",size:14})})]})]})]})}function mt(s){const a=Math.floor(s/1e3),l=Math.floor(a/60),f=a%60;return`${l}:${f.toString().padStart(2,"0")}`}const ft=t.memo(function({agentId:a,isWorking:l,timestamp:f}){const{t:p}=fe(["terminal"]),[d,M]=t.useState(0);return t.useEffect(()=>{if(!l||!f){M(0);return}M(Date.now()-f);const A=setInterval(()=>{M(Date.now()-f)},1e3);return()=>clearInterval(A)},[l,f]),l?e.jsxs("div",{className:"guake-stop-bar",children:[e.jsx("span",{className:"guake-elapsed-timer",children:mt(d)}),e.jsxs("button",{className:"guake-stop-btn",onClick:()=>I.stopAgent(a),title:p("terminal:input.stopOperation"),children:[e.jsx("span",{className:"stop-icon",children:e.jsx(z,{name:"stop",size:12,weight:"fill"})}),e.jsx("span",{className:"stop-label",children:p("terminal:input.stop")})]})]}):null});function pt({agent:s,history:a,outputs:l,isExpanded:f,isFocused:p,advancedView:d,onExpand:M,onFocus:A,inputRef:R,onLoadMore:N,onClearHistory:b}){const{t:E}=fe(["terminal","common"]),j=ze(s.id),h=t.useRef(null),[v,u]=t.useState(!1),D=t.useRef(0),i=t.useRef(!1),[C,F]=t.useState(!0),[x,k]=t.useState(!1),[P,W]=t.useState(null),[J,V]=t.useState(null),[q,Q]=t.useState(null);Te(`commander-image-modal-${s.id}`,P!==null,()=>W(null));const{command:B,setCommand:w,forceTextarea:c,setForceTextarea:L,useTextarea:K,setPastedTexts:U,incrementPastedCount:te,resetPastedCount:_,attachedFiles:$,setAttachedFiles:H,removeAttachedFile:se,uploadFile:ae,expandPastedTexts:ne}=Ue({selectedAgentId:s.id}),le=B.trim().length>0||$.length>0,n=Be({outputs:l,viewMode:d?"advanced":"simple"}),o=t.useMemo(()=>{const S=Ke(s);return{usedPercent:S.usedPercent,freePercent:S.freePercent,hasData:!!s.contextStats,totalTokens:S.totalTokens,contextWindow:S.contextWindow}},[s.contextStats,s.contextUsed,s.contextLimit]),g=t.useCallback(()=>{!v&&(a!=null&&a.hasMore)&&N&&(u(!0),D.current=h.current?h.current.scrollHeight-h.current.scrollTop:0,N())},[v,a==null?void 0:a.hasMore,N]);t.useEffect(()=>{v&&a&&!a.loading&&u(!1)},[a,v]);const m=t.useCallback(()=>{i.current=!0,F(!1)},[]),T=t.useRef(f),Z=t.useRef(p);t.useEffect(()=>{(f&&!T.current||p&&!Z.current)&&(i.current=!1,F(!0),k(!0)),T.current=f,Z.current=p},[f,p]);const ee=t.useRef(a==null?void 0:a.loading);t.useEffect(()=>{ee.current&&!(a!=null&&a.loading)&&(i.current=!1,F(!0),k(!0)),ee.current=a==null?void 0:a.loading},[a==null?void 0:a.loading]),t.useEffect(()=>{if(!x)return;const S=h.current;if(!S)return;const y=performance.now();let O=0,ue=-1,ke;const Re=()=>{const{scrollTop:Fe,scrollHeight:Se,clientHeight:Le}=S,He=Se-Fe-Le<=2;if(Math.abs(Se-ue)<=1&&He?O+=1:O=0,ue=Se,O>=3){k(!1);return}if(performance.now()-y>5e3){k(!1);return}ke=requestAnimationFrame(Re)};return ke=requestAnimationFrame(Re),()=>cancelAnimationFrame(ke)},[x]),t.useEffect(()=>{i.current||F(!0)},[n.length]);const G=t.useCallback(()=>!1,[]),ie=t.useCallback(S=>{const y=te();return U(O=>new Map(O).set(y,S)),y},[te,U]),he=t.useCallback(S=>{H(y=>[...y,S])},[H]),xe=t.useCallback(()=>{if(!le)return;if(B.trim()==="/clear"&&$.length===0){I.clearContext(s.id),b(),w(""),L(!1),U(new Map),H([]),_();return}let S=ne(B.trim());if($.length>0){const y=$.map(O=>O.isImage?`[Image: ${O.path}]`:`[File: ${O.path}]`).join(`
3
3
  `);S=S?`${S}
4
4