tide-commander 1.15.0 → 1.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/BossLogsModal-Con28VlO.js +1 -0
- package/dist/assets/BossSpawnModal-C4pYV2zv.js +1 -0
- package/dist/assets/ControlsModal-BoEPLHKr.js +1 -0
- package/dist/assets/DockerLogsModal-Cb9TrVMI.js +2 -0
- package/dist/assets/{EmbeddedEditor-BnOgJ3hN.js → EmbeddedEditor-CE9o6f4D.js} +1 -1
- package/dist/assets/IframeModal-D9x-ere3.js +1 -0
- package/dist/assets/IframeModal-DJkCGwT6.css +1 -0
- package/dist/assets/LogViewerModal-BilRZ0Fi.js +1 -0
- package/dist/assets/PM2LogsModal-CALqxDMt.js +2 -0
- package/dist/assets/RestoreArchivedAreaModal-DBmU9Ieo.js +1 -0
- package/dist/assets/SaveSnapshotModal-CyPk29Vj.js +1 -0
- package/dist/assets/Scene2DCanvas-DwXbvB-b.css +1 -0
- package/dist/assets/Scene2DCanvas-O6bRBIrg.js +1 -0
- package/dist/assets/SceneManager-4Fygy7Zp.js +104 -0
- package/dist/assets/SkillsPanel-Bh3_SMkP.js +28 -0
- package/dist/assets/SnapshotManager-y3U0Zr5V.js +1 -0
- package/dist/assets/SpawnModal-YFO34ZLb.js +1 -0
- package/dist/assets/SubordinateAssignmentModal-CxvN33cg.js +1 -0
- package/dist/assets/SupervisorPanel-BvuQ38FU.js +1 -0
- package/dist/assets/camera-BWSm1gAv.js +1 -0
- package/dist/assets/index-6ideF-X9.js +1 -0
- package/dist/assets/index-BZyCMBzi.css +1 -0
- package/dist/assets/index-Bykeknjl.css +1 -0
- package/dist/assets/index-CcFgN2Jx.js +8 -0
- package/dist/assets/index-D_6KseaN.js +1 -0
- package/dist/assets/index-DbUU1onA.js +20 -0
- package/dist/assets/index-DeiXPIBQ.js +5 -0
- package/dist/assets/index-DyuEOipR.css +1 -0
- package/dist/assets/index-JMf8ILr8.js +1 -0
- package/dist/assets/index-hLLvYkvu.js +10 -0
- package/dist/assets/index-yuV176Wx.js +2 -0
- package/dist/assets/main-BIeB-C3F.css +1 -0
- package/dist/assets/main-ocVprcIe.js +139 -0
- package/dist/assets/prism-c-BI05wwL9.js +1 -0
- package/dist/assets/prism-clojure-u3w_tjfy.js +1 -0
- package/dist/assets/prism-cpp-CcQnz8LL.js +1 -0
- package/dist/assets/prism-csharp-DFIAaw4Y.js +1 -0
- package/dist/assets/prism-diff-jN23ddHu.js +3 -0
- package/dist/assets/prism-docker-MnIa7k-I.js +1 -0
- package/dist/assets/prism-elixir-jP4m4T-8.js +1 -0
- package/dist/assets/prism-erlang-C3Aahqfa.js +1 -0
- package/dist/assets/prism-graphql-DJ177lJj.js +1 -0
- package/dist/assets/prism-groovy-CGzo1uDg.js +1 -0
- package/dist/assets/prism-haskell-BrMZM7_F.js +1 -0
- package/dist/assets/prism-ini-DX5Euru7.js +1 -0
- package/dist/assets/prism-java-BEsh8u4L.js +1 -0
- package/dist/assets/prism-kotlin-B1uvbSyh.js +1 -0
- package/dist/assets/prism-lua-Cp_o7ONA.js +1 -0
- package/dist/assets/prism-makefile-Dk8DMwhC.js +1 -0
- package/dist/assets/prism-markup-templating-Ct1xsyfA.js +1 -0
- package/dist/assets/prism-nginx-43e5TboO.js +1 -0
- package/dist/assets/prism-perl-ecHKp0bZ.js +1 -0
- package/dist/assets/prism-php-Ch-kk89U.js +1 -0
- package/dist/assets/prism-powershell-Ud14i9UV.js +1 -0
- package/dist/assets/prism-r-TxsGuNZJ.js +1 -0
- package/dist/assets/prism-ruby-zNpGDk6v.js +1 -0
- package/dist/assets/prism-scala-BjNo2HkN.js +1 -0
- package/dist/assets/prism-scss-BeuXx0O0.js +1 -0
- package/dist/assets/prism-swift--kriB360.js +1 -0
- package/dist/assets/prism-toml-BrQIw_NO.js +1 -0
- package/dist/assets/prism-vim-uciLQ2PQ.js +1 -0
- package/dist/assets/{vendor-three-DJ4p3FLF.js → vendor-three-PBVcEoyM.js} +1 -1
- package/dist/assets/web-Br31ijgV.js +1 -0
- package/dist/assets/web-neDQQDMB.js +1 -0
- package/dist/index.html +3 -3
- package/package.json +1 -1
- package/dist/assets/index-CPVBxiQT.js +0 -2
- package/dist/assets/main-CXiXIXlk.css +0 -1
- package/dist/assets/main-LsoatWu2.js +0 -311
- package/dist/assets/web-DDQTmJ-Z.js +0 -1
- package/dist/assets/web-DZHF6aSy.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as M,h as N,r as m,s as u,j as r}from"./main-ocVprcIe.js";import{L as v}from"./LogViewerModal-BilRZ0Fi.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react-uS-d4TUT.js";import"./vendor-three-PBVcEoyM.js";function C(o){const n=["#3498db","#2ecc71","#9b59b6","#e67e22","#1abc9c","#e74c3c","#f1c40f","#00bcd4"];let a=0;for(let t=0;t<o.length;t++)a=o.charCodeAt(t)+((a<<5)-a);return n[Math.abs(a)%n.length]}function w({building:o,isOpen:n,onClose:a}){const{t}=M(["terminal","common"]),{bossStreamingLogs:b,buildings:f}=N(),l=b.get(o.id)||[],[i,d]=m.useState(null),c=o.subordinateBuildingIds||[],g=c.map(e=>f.get(e)).filter(e=>e!==void 0);m.useEffect(()=>(n&&c.length>0&&u.startBossLogStreaming(o.id),()=>{o.id&&u.stopBossLogStreaming(o.id)}),[n,o.id,c.length]);const h=m.useMemo(()=>{const e=new Set;return l.forEach(s=>e.add(s.subordinateName)),Array.from(e)},[l]),p=m.useMemo(()=>(i?l.filter(s=>s.subordinateName===i):l).map((s,j)=>({text:s.chunk,lineNumber:j+1,sourceLabel:s.subordinateName,sourceColor:C(s.subordinateName),isError:s.isError})),[l,i]),x=g.some(e=>{var s;return(s=e.pm2)==null?void 0:s.enabled}),S=h.length>1?r.jsxs("select",{className:"toolbar-btn source-filter",value:i||"",onChange:e=>d(e.target.value||null),children:[r.jsx("option",{value:"",children:t("terminal:logs.allSources")}),h.map(e=>r.jsx("option",{value:e,children:e},e))]}):void 0,L=i?r.jsxs("div",{className:"shortcut",style:{marginLeft:"auto"},children:[r.jsxs("span",{children:[t("terminal:logs.filtered"),": ",i]}),r.jsx("button",{style:{background:"transparent",border:"none",color:"inherit",cursor:"pointer",marginLeft:"0.5rem"},onClick:()=>d(null),children:"x"})]}):void 0;return r.jsx(v,{isOpen:n,onClose:a,title:`${o.name} - ${t("terminal:logs.bossLogs")}`,icon:"👑",lines:p,isStreaming:c.length>0,streamingIndicatorLabel:`${g.length} ${t("terminal:logs.units")}`,onClear:()=>u.clearBossStreamingLogs(o.id),emptyMessage:x?l.length===0?t("terminal:logs.waitingForLogs"):t("terminal:logs.noMatchingLogs"):t("terminal:logs.noPM2Subordinates"),extraToolbar:S,extraFooter:L,modalClassName:"boss-logs-modal"})}export{w as BossLogsModal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as $e,h as Ae,G as Le,E as Ee,r as t,J as De,S as se,q as _e,K as R,A as ae,X as O,Y as j,j as s,M as Be,O as Ie,Q as T,U as A,V as L,W as Re,s as Oe}from"./main-ocVprcIe.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react-uS-d4TUT.js";import"./vendor-three-PBVcEoyM.js";function ne(p){const h=j.filter(S=>!p.has(`Boss ${S}`));return h.length===0?`Boss ${j[Math.floor(Math.random()*j.length)]}-${Date.now()%1e3}`:`Boss ${h[Math.floor(Math.random()*h.length)]}`}function Ue({isOpen:p,onClose:h,onSpawnStart:S,onSpawnEnd:E,spawnPosition:le}){const{t:n}=$e(["terminal","common"]),{agents:g}=Ae(),o=Le(),C=Ee(),[r,d]=t.useState(""),[k,te]=t.useState(()=>De(se.LAST_CWD)),[c,D]=t.useState("boss"),[q,P]=t.useState(!1),[ie,M]=t.useState(!1),[F,ce]=t.useState(!0),[U,oe]=t.useState("bypass"),[m,W]=t.useState("claude"),[f,N]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[G,re]=t.useState("haiku"),[K,de]=t.useState("gpt-5.3-codex"),[v,y]=t.useState(new Set),[z,_]=t.useState(new Set),[u,ue]=t.useState(""),[b,pe]=t.useState(""),[J,me]=t.useState(""),$=t.useRef(null),B=t.useRef(!1),H=t.useRef(!1),x=t.useMemo(()=>C.filter(e=>e.enabled),[C]),X=t.useMemo(()=>{if(!b.trim())return x;const e=b.toLowerCase();return x.filter(a=>a.name.toLowerCase().includes(e)||a.description.toLowerCase().includes(e)||a.slug.toLowerCase().includes(e))},[x,b]),he=t.useMemo(()=>{var a;const e=o.find(l=>l.id===c);return(a=e==null?void 0:e.defaultSkillIds)!=null&&a.length?C.filter(l=>e.defaultSkillIds.includes(l.id)):[]},[o,c,C]),we=["full-notifications","streaming-exec","task-label","report-task-to-boss"];t.useEffect(()=>{if(p&&!H.current&&x.length>0){const a=x.filter(l=>we.includes(l.slug)).map(l=>l.id);a.length>0&&_(new Set(a))}H.current=p},[p,x]);const xe=t.useCallback(e=>{_(a=>{const l=new Set(a);return l.has(e)?l.delete(e):l.add(e),l})},[]),i=t.useMemo(()=>o.find(e=>e.id===c),[o,c]),fe=t.useMemo(()=>{if(i!=null&&i.model)return i.model},[i]),be=t.useMemo(()=>{if(i!=null&&i.customModelPath)return _e(`/api/custom-models/${i.id}`)},[i]),je=i==null?void 0:i.modelScale,Ne=t.useMemo(()=>i?"scout":c==="boss"?"architect":c,[c,i]),Y=Array.from(g.values()).filter(e=>!e.isBoss&&e.class!=="boss"&&!e.bossId),Q=t.useMemo(()=>{if(!u.trim())return o;const e=u.toLowerCase();return o.filter(a=>a.name.toLowerCase().includes(e)||a.description.toLowerCase().includes(e)||a.id.toLowerCase().includes(e))},[o,u]),V=t.useMemo(()=>{if(!u.trim())return R;const e=u.toLowerCase();return R.filter(a=>{const l=ae[a.id];return l?a.name.toLowerCase().includes(e)||a.id.toLowerCase().includes(e)||l.description.toLowerCase().includes(e):!1})},[u]),Z=t.useMemo(()=>{if(!u.trim())return!0;const e=u.toLowerCase(),a=O.boss;return"boss".includes(e)||a.description.toLowerCase().includes(e)},[u]);t.useEffect(()=>{if(p&&!B.current){B.current=!0;const e=new Set(Array.from(g.values()).map(l=>l.name)),a=o.find(l=>l.id===c);if(a){const l=j.filter(w=>!e.has(`${a.name} ${w}`));if(l.length===0){const w=j[Math.floor(Math.random()*j.length)];d(`${a.name} ${w}-${Date.now()%1e3}`)}else d(`${a.name} ${l[Math.floor(Math.random()*l.length)]}`)}else d(ne(e));y(new Set),$.current&&($.current.focus(),$.current.select())}else p||(B.current=!1)},[p,g]),t.useEffect(()=>{if(!p)return;const e=o.find(a=>a.id===c);if(e)if(r.startsWith("Boss ")){const a=r.substring(5);d(`${e.name} ${a}`)}else{const a=o.find(l=>r.startsWith(l.name+" "));if(a){const l=r.substring(a.name.length+1);d(`${e.name} ${l}`)}else d(`${e.name} ${r}`)}else{const a=o.find(l=>r.startsWith(l.name+" "));if(a){const l=r.substring(a.name.length+1);d(`Boss ${l}`)}else r.startsWith("Boss ")||d(`Boss ${r}`)}},[c]);const ve=()=>{if(M(!1),!k.trim()){M(!0);return}if(!r.trim()){const l=new Set(Array.from(g.values()).map(w=>w.name));d(ne(l));return}Re(se.LAST_CWD,k),S();const e=J.trim()||void 0,a=Array.from(z);Oe.spawnBossAgent(r.trim(),c,k.trim(),le||void 0,Array.from(v),m==="claude"?F:!1,U,m,m==="codex"?f:void 0,m==="codex"?K:void 0,m==="claude"?G:void 0,e,a),d(""),y(new Set),_(new Set),E(),h()},Se=()=>{P(!1),d(""),y(new Set),E(),h()},ge=()=>{P(!1),M(!0),E()};t.useEffect(()=>(window.__bossSpawnModalSuccess=Se,window.__bossSpawnModalError=ge,()=>{delete window.__bossSpawnModalSuccess,delete window.__bossSpawnModalError}),[r]);const Ce=e=>{e.target===e.currentTarget&&h()},ke=e=>{e.key==="Escape"&&h()},Me=e=>{const a=new Set(v);a.has(e)?a.delete(e):a.add(e),y(a)};if(!p)return null;const I=O.boss;return s.jsx("div",{className:`modal-overlay ${p?"visible":""}`,onClick:Ce,onKeyDown:ke,children:s.jsxs("div",{className:"modal boss-spawn-modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("span",{className:"boss-header-icon",children:I.icon}),n("terminal:spawn.deployBossTitle")]}),s.jsxs("div",{className:"modal-body spawn-modal-body",children:[s.jsxs("div",{className:"spawn-top-section",children:[s.jsx("div",{className:"spawn-preview-compact",children:s.jsx(Be,{agentClass:Ne,modelFile:fe,customModelUrl:be,modelScale:je,width:100,height:120})}),s.jsxs("div",{className:"spawn-class-section",children:[s.jsx("div",{className:"spawn-class-label",children:n("terminal:spawn.bossClass")}),o.length+R.length+1>6&&s.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:n("terminal:spawn.filterClasses"),value:u,onChange:e=>ue(e.target.value)}),s.jsxs("div",{className:"class-selector-inline",children:[Q.map(e=>s.jsxs("button",{className:`class-chip ${c===e.id?"selected":""}`,onClick:()=>D(e.id),title:e.description,children:[s.jsx("span",{className:"class-chip-icon",children:e.icon}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)),Z&&s.jsxs("button",{className:`class-chip ${c==="boss"?"selected":""}`,onClick:()=>D("boss"),title:I.description,children:[s.jsx("span",{className:"class-chip-icon",children:I.icon}),s.jsx("span",{className:"class-chip-name",children:n("terminal:spawn.bossClassName")})]}),V.map(e=>{const a=ae[e.id];return a?s.jsxs("button",{className:`class-chip ${c===e.id?"selected":""}`,onClick:()=>D(e.id),title:a.description,children:[s.jsx("span",{className:"class-chip-icon",children:a.icon}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id):null}),u&&Q.length===0&&!Z&&V.length===0&&s.jsx("div",{className:"class-search-empty",children:n("terminal:spawn.noClassesMatch",{query:u})})]})]})]}),s.jsxs("div",{className:"spawn-form-section",children:[s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.name")}),s.jsx("input",{ref:$,type:"text",className:"spawn-input",placeholder:n("terminal:spawn.bossNamePlaceholder"),value:r,onChange:e=>d(e.target.value)})]}),s.jsxs("div",{className:"spawn-field spawn-field-wide",children:[s.jsx("label",{className:"spawn-label",children:n("terminal:spawn.workingDir")}),s.jsx(Ie,{value:k,onChange:e=>{te(e),M(!1)},placeholder:n("terminal:spawn.workingDirPlaceholder"),className:"spawn-input",hasError:ie,directoriesOnly:!0})]})]}),s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.runtime")}),s.jsxs("div",{className:"spawn-select-row",children:[s.jsxs("button",{className:`spawn-select-btn ${m==="claude"?"selected":""}`,onClick:()=>W("claude"),title:n("terminal:spawn.useClaudeCli"),children:[s.jsx("img",{src:"/assets/claude.ico",alt:"Claude",className:"spawn-provider-icon"}),s.jsx("span",{children:"Claude"})]}),s.jsxs("button",{className:`spawn-select-btn ${m==="codex"?"selected":""}`,onClick:()=>W("codex"),title:n("terminal:spawn.useCodexCli"),children:[s.jsx("img",{src:"/assets/codex.ico",alt:"Codex",className:"spawn-provider-icon"}),s.jsx("span",{children:"Codex"})]})]})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.permissions")}),s.jsx("div",{className:"spawn-select-row",children:Object.keys(T).map(e=>s.jsxs("button",{className:`spawn-select-btn ${U===e?"selected":""}`,onClick:()=>oe(e),title:T[e].description,children:[s.jsx("span",{children:e==="bypass"?"⚡":"🔐"}),s.jsx("span",{children:T[e].label})]},e))})]})]}),s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.model")}),m==="claude"?s.jsx("div",{className:"spawn-select-row",children:Object.keys(A).map(e=>s.jsxs("button",{className:`spawn-select-btn ${G===e?"selected":""}`,onClick:()=>re(e),title:A[e].description,children:[s.jsx("span",{children:A[e].icon}),s.jsx("span",{children:A[e].label})]},e))}):m==="codex"?s.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(L).map(e=>s.jsxs("button",{className:`spawn-select-btn ${K===e?"selected":""}`,onClick:()=>de(e),title:L[e].description,children:[s.jsx("span",{children:L[e].icon}),s.jsx("span",{children:L[e].label})]},e))}):s.jsx("div",{className:"spawn-inline-hint",children:n("terminal:spawn.codex.configuration")})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.browser")}),s.jsx("div",{className:"spawn-form-row spawn-options-row",children:s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:F,onChange:e=>ce(e.target.checked),disabled:m!=="claude"}),s.jsx("span",{children:n("terminal:spawn.chromeBrowser")})]})})]})]}),m==="codex"&&s.jsx("div",{className:"spawn-form-row",children:s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("terminal:spawn.codex.config")}),s.jsxs("div",{className:"spawn-options-row",style:{display:"flex",flexDirection:"column",gap:8},children:[s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:f.fullAuto!==!1,onChange:e=>N(a=>({...a,fullAuto:e.target.checked}))}),s.jsx("span",{children:n("terminal:spawn.codex.useFullAuto")})]}),s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:!!f.search,onChange:e=>N(a=>({...a,search:e.target.checked}))}),s.jsx("span",{children:n("terminal:spawn.codex.enableSearch")})]}),f.fullAuto===!1&&s.jsxs(s.Fragment,{children:[s.jsxs("select",{className:"spawn-input",value:f.sandbox||"workspace-write",onChange:e=>N(a=>({...a,sandbox:e.target.value})),children:[s.jsx("option",{value:"read-only",children:n("terminal:spawn.codex.sandboxReadOnly")}),s.jsx("option",{value:"workspace-write",children:n("terminal:spawn.codex.sandboxWorkspaceWrite")}),s.jsx("option",{value:"danger-full-access",children:n("terminal:spawn.codex.sandboxDangerFullAccess")})]}),s.jsxs("select",{className:"spawn-input",value:f.approvalMode||"on-request",onChange:e=>N(a=>({...a,approvalMode:e.target.value})),children:[s.jsx("option",{value:"untrusted",children:n("terminal:spawn.codex.approvalsUntrusted")}),s.jsx("option",{value:"on-failure",children:n("terminal:spawn.codex.approvalsOnFailure")}),s.jsx("option",{value:"on-request",children:n("terminal:spawn.codex.approvalsOnRequest")}),s.jsx("option",{value:"never",children:n("terminal:spawn.codex.approvalsNever")})]})]}),s.jsx("input",{type:"text",className:"spawn-input",placeholder:n("terminal:spawn.codex.profileOptional"),value:f.profile||"",onChange:e=>N(a=>({...a,profile:e.target.value||void 0}))})]})]})}),x.length>0&&s.jsxs("div",{className:"spawn-skills-section",children:[s.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.skills")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]})]}),x.length>6&&s.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:n("terminal:spawn.filterSkills"),value:b,onChange:e=>pe(e.target.value)}),s.jsxs("div",{className:"spawn-skills-inline",children:[X.map(e=>{const a=z.has(e.id);return he.some(w=>w.id===e.id)?null:s.jsxs("button",{className:`spawn-skill-chip ${a?"selected":""}`,onClick:()=>xe(e.id),title:e.description,children:[a&&s.jsx("span",{className:"spawn-skill-check",children:"✓"}),s.jsx("span",{children:e.name}),e.builtin&&s.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},e.id)}),b&&X.length===0&&s.jsx("div",{className:"skill-search-empty",children:n("terminal:spawn.noSkillsMatch",{query:b})})]})]}),s.jsxs("div",{className:"spawn-custom-instructions-section",children:[s.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.customInstructions")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]})]}),s.jsx("textarea",{className:"spawn-input spawn-textarea",placeholder:n("terminal:spawn.customInstructionsBossPlaceholder"),value:J,onChange:e=>me(e.target.value),rows:3})]}),s.jsxs("div",{className:"spawn-subordinates-section",children:[s.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.initialSubordinates")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]})]}),s.jsx("div",{className:"subordinates-selector-compact",children:Y.length===0?s.jsx("div",{className:"subordinates-empty",children:n("terminal:spawn.noAvailableAgents")}):Y.map(e=>{const a=v.has(e.id),l=O[e.class],w=o.find(ye=>ye.id===e.class),ee=l||w||{icon:"🤖",color:"#888888"};return s.jsxs("button",{className:`subordinate-chip ${a?"selected":""}`,onClick:()=>Me(e.id),children:[a&&s.jsx("span",{className:"subordinate-check",children:"✓"}),s.jsx("span",{className:"subordinate-chip-icon",style:{color:ee.color},children:ee.icon}),s.jsx("span",{className:"subordinate-chip-name",children:e.name})]},e.id)})}),v.size>0&&s.jsxs("div",{className:"subordinates-count",children:[v.size," ",n("common:labels.selected").toLowerCase()]})]})]})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:h,children:n("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-boss",onClick:ve,disabled:q,children:n(q?"common:buttons.deploying":"common:buttons2.deployBoss")})]})]})})}export{Ue as BossSpawnModal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as S,aX as I,r as m,aY as X,aW as w,j as e,h as _,aZ as W,a_ as Z,c as U,i as H,s as y,a$ as z,b0 as A}from"./main-ocVprcIe.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react-uS-d4TUT.js";import"./vendor-three-PBVcEoyM.js";function q({shortcut:t,onUpdate:n}){const{t:s}=S(["config","terminal"]),o=I(),[l,h]=m.useState(!1),[i,j]=m.useState(null),b=m.useRef(null),v=m.useMemo(()=>i?X(o,i,t.id,t.context):[],[i,o,t.id,t.context]);m.useEffect(()=>{if(!l)return;const p=c=>{if(c.preventDefault(),c.stopPropagation(),c.key==="Escape"&&!c.ctrlKey&&!c.altKey&&!c.shiftKey&&!c.metaKey){h(!1),j(null);return}if(["Control","Alt","Shift","Meta"].includes(c.key))return;let f=c.key;c.code.startsWith("Key")&&c.code.length===4?f=c.code.charAt(3).toLowerCase():c.code.startsWith("Digit")&&c.code.length===6?f=c.code.charAt(5):c.code==="Space"&&(f="Space");const x={key:f,modifiers:{ctrl:c.ctrlKey,alt:c.altKey,shift:c.shiftKey,meta:c.metaKey}};j(x)};return document.addEventListener("keydown",p,!0),()=>document.removeEventListener("keydown",p,!0)},[l]),m.useEffect(()=>{if(!l)return;const p=c=>{b.current&&!b.current.contains(c.target)&&(i&&v.length===0&&n(i),h(!1),j(null))};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[l,i,v,n]);const k=()=>{l?(i&&v.length===0&&n(i),h(!1),j(null)):(h(!0),j(null))},g=p=>{p.stopPropagation(),n({key:"",modifiers:{}})};let d;return l?i?d=w({...t,...i}):d=s("config:shortcuts.pressKeys"):t.key?d=w(t):d=s("config:shortcuts.notSet"),e.jsxs("div",{className:"key-capture-container",children:[e.jsx("button",{ref:b,className:`key-capture-input ${l?"capturing":""} ${v.length>0?"conflict":""} ${t.enabled?"":"disabled"}`,onClick:k,title:s(l?"config:shortcuts.pressKeysOrClick":"config:shortcuts.clickToChange"),children:e.jsx("span",{className:"key-capture-value",children:d})}),t.key&&!l&&e.jsx("button",{className:"key-capture-clear",onClick:g,title:s("config:shortcuts.clearShortcut"),children:"×"}),v.length>0&&e.jsx("div",{className:"key-capture-conflict",children:s("config:shortcuts.conflictsWith",{names:v.map(p=>s(`terminal:controls.shortcuts.${p.id}.name`,{defaultValue:p.name})).join(", ")})})]})}const V={global:"terminal:controls.contextGlobal",commander:"terminal:controls.contextCommander",toolbox:"terminal:controls.contextToolbox"},Q={global:"terminal:controls.contextGlobalDesc",commander:"terminal:controls.contextCommanderDesc",toolbox:"terminal:controls.contextToolboxDesc"},R={camera:["camera-pan","camera-orbit","camera-rotate","camera-zoom","camera-tilt"],interaction:["primary-action","selection-box","context-menu","move-command"]},J={camera:"terminal:controls.cameraControls",interaction:"terminal:controls.interaction"};function oe({isOpen:t,onClose:n}){const{t:s}=S(["terminal","common"]),o=_(),l=W(),h=Z(),[i,j]=m.useState("keyboard"),[b,v]=m.useState(""),[k,g]=m.useState("all"),[d,p]=m.useState(!1),[c,f]=m.useState(null),x=U.useRef(null),{handleMouseDown:D,handleClick:M}=H(n);if(m.useEffect(()=>{if(!t||d)return;const r=a=>{a.key==="Escape"&&(a.preventDefault(),a.stopPropagation(),n())};return document.addEventListener("keydown",r,!0),()=>document.removeEventListener("keydown",r,!0)},[t,n,d]),m.useEffect(()=>{t||(v(""),p(!1),f(null))},[t]),m.useEffect(()=>{if(!t||!d)return;const r=a=>{if(a.key==="Escape"){a.preventDefault(),a.stopPropagation(),p(!1),f(null);return}if(["Control","Alt","Shift","Meta"].includes(a.key))return;a.preventDefault(),a.stopPropagation();let u=a.key;a.code.startsWith("Key")&&a.code.length===4?u=a.code.charAt(3).toLowerCase():a.code.startsWith("Digit")&&a.code.length===6?u=a.code.charAt(5):a.code==="Space"&&(u="Space"),f({key:u,modifiers:{ctrl:a.ctrlKey,alt:a.altKey,shift:a.shiftKey,meta:a.metaKey}})};return document.addEventListener("keydown",r,!0),()=>document.removeEventListener("keydown",r,!0)},[t,d]),!t)return null;const E=o.shortcuts.filter(r=>{const a=s(`terminal:controls.shortcuts.${r.id}.name`,{defaultValue:r.name}),u=s(`terminal:controls.shortcuts.${r.id}.description`,{defaultValue:r.description});if(d&&c){const O=C=>C===" "||C==="Space"?"Space":C.length===1?C.toLowerCase():C,$=O(r.key),B=O(c.key);if(!(B.length===1&&/^[a-zA-Z]$/.test($)?`Key${$.toUpperCase()}`==`Key${B.toUpperCase()}`:$===B))return!1;const K=r.modifiers,T=c.modifiers;return(K.ctrl||!1)===(T.ctrl||!1)&&(K.alt||!1)===(T.alt||!1)&&(K.shift||!1)===(T.shift||!1)&&(K.meta||!1)===(T.meta||!1)}if(!b)return!0;const N=b.toLowerCase();return a.toLowerCase().includes(N)||u.toLowerCase().includes(N)||w(r).toLowerCase().includes(N)}),L=E.reduce((r,a)=>(r[a.context]||(r[a.context]=[]),r[a.context].push(a),r),{}),G=(r,a)=>{y.updateShortcut(r,a)},F=()=>{i==="keyboard"?confirm(s("terminal:controls.confirmResetKeyboard"))&&y.resetShortcuts():i==="mouse"?confirm(s("terminal:controls.confirmResetMouse"))&&y.resetMouseControls():i==="trackpad"&&confirm(s("terminal:controls.confirmResetTrackpad"))&&y.resetMouseControls()},P=["global","commander","toolbox"],Y=l.bindings.reduce((r,a)=>(R.camera.includes(a.action)?r.camera.push(a):R.interaction.includes(a.action)&&r.interaction.push(a),r),{camera:[],interaction:[]});return e.jsx("div",{className:"shortcuts-modal-overlay",onMouseDown:D,onClick:M,children:e.jsxs("div",{className:"shortcuts-modal controls-modal",children:[e.jsxs("div",{className:"shortcuts-modal-header",children:[e.jsxs("div",{className:"shortcuts-modal-title",children:[e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),e.jsx("span",{children:s("terminal:controls.title")})]}),e.jsx("button",{className:"shortcuts-modal-close",onClick:n,children:"×"})]}),e.jsxs("div",{className:"controls-main-tabs",children:[e.jsxs("button",{className:`controls-main-tab ${i==="keyboard"?"active":""}`,onClick:()=>j("keyboard"),children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M6 12h.01M18 12h.01M8 16h8"})]}),s("terminal:controls.keyboard")]}),e.jsxs("button",{className:`controls-main-tab ${i==="mouse"?"active":""}`,onClick:()=>j("mouse"),children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"6",y:"3",width:"12",height:"18",rx:"6"}),e.jsx("line",{x1:"12",y1:"7",x2:"12",y2:"11"})]}),s("terminal:controls.mouse")]}),e.jsxs("button",{className:`controls-main-tab ${i==="trackpad"?"active":""}`,onClick:()=>j("trackpad"),children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),s("terminal:controls.trackpad")]})]}),i==="keyboard"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shortcuts-modal-toolbar",children:[d?e.jsxs("div",{className:"shortcuts-search find-by-shortcut-active",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M6 12h.01M18 12h.01M8 16h8"})]}),c?e.jsxs("span",{className:"find-by-shortcut-display",children:[w({key:c.key,modifiers:c.modifiers}),e.jsx("button",{className:"shortcuts-search-clear",onClick:()=>f(null),children:"×"})]}):e.jsx("span",{className:"find-by-shortcut-prompt",children:s("terminal:controls.pressKeyCombination")})]}):e.jsxs("div",{className:"shortcuts-search",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"M21 21l-4.35-4.35"})]}),e.jsx("input",{ref:x,type:"text",placeholder:s("terminal:controls.searchShortcuts"),value:b,onChange:r=>v(r.target.value),autoFocus:!0}),b&&e.jsx("button",{className:"shortcuts-search-clear",onClick:()=>v(""),children:"×"})]}),e.jsx("button",{className:`shortcuts-find-by-key-btn ${d?"active":""}`,onClick:()=>{p(!d),f(null),v("")},title:s(d?"terminal:controls.switchToTextSearch":"terminal:controls.findByPressingKeys"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M6 12h.01M18 12h.01M8 16h8"})]})}),e.jsx("button",{className:"shortcuts-reset-all-btn",onClick:F,children:s("common:buttons.reset")})]}),e.jsxs("div",{className:"shortcuts-context-tabs",children:[e.jsxs("button",{className:`shortcuts-context-tab ${k==="all"?"active":""}`,onClick:()=>g("all"),children:[s("common:labels.all"),e.jsx("span",{className:"shortcuts-context-tab-count",children:E.length})]}),P.map(r=>{var u;const a=((u=L[r])==null?void 0:u.length)||0;return e.jsxs("button",{className:`shortcuts-context-tab ${k===r?"active":""}`,onClick:()=>g(r),children:[s(V[r]),e.jsx("span",{className:"shortcuts-context-tab-count",children:a})]},r)})]}),e.jsxs("div",{className:"shortcuts-modal-content",children:[P.map(r=>{const a=L[r]||[];return a.length===0||k!=="all"&&k!==r?null:e.jsxs("div",{className:"shortcuts-context-group",children:[k==="all"&&e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:s(V[r])}),e.jsx("span",{className:"shortcuts-context-description",children:s(Q[r])})]}),e.jsx("div",{className:"shortcuts-grid",children:a.map(u=>e.jsxs("div",{className:"shortcut-item",children:[e.jsxs("div",{className:"shortcut-item-info",children:[e.jsx("span",{className:"shortcut-item-name",children:s(`terminal:controls.shortcuts.${u.id}.name`,{defaultValue:u.name})}),e.jsx("span",{className:"shortcut-item-description",children:s(`terminal:controls.shortcuts.${u.id}.description`,{defaultValue:u.description})})]}),e.jsx(q,{shortcut:u,onUpdate:N=>G(u.id,N)})]},u.id))})]},r)}),E.length===0&&e.jsx("div",{className:"shortcuts-empty",children:d?c?e.jsx("p",{children:s("terminal:controls.noShortcutBoundTo",{keys:w({key:c.key,modifiers:c.modifiers})})}):e.jsx("p",{children:s("terminal:controls.pressKeyCombinationToFind")}):e.jsx("p",{children:s("terminal:controls.noShortcutsFound",{query:b})})})]})]}),i==="mouse"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shortcuts-modal-toolbar",children:[e.jsx("span",{className:"mouse-controls-subtitle",children:s("terminal:controls.cameraAndInteraction")}),e.jsx("button",{className:"shortcuts-reset-all-btn",onClick:F,children:s("common:buttons.reset")})]}),e.jsxs("div",{className:"shortcuts-modal-content mouse-controls-content",children:[e.jsx("div",{className:"mouse-controls-bindings",children:Object.entries(Y).map(([r,a])=>e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsx("div",{className:"shortcuts-context-header",children:e.jsx("span",{className:"shortcuts-context-label",children:s(J[r])})}),e.jsx("div",{className:"shortcuts-grid",children:a.map(u=>e.jsx(ee,{binding:u},u.id))})]},r))}),e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:s("terminal:controls.sensitivity")}),e.jsx("span",{className:"shortcuts-context-description",children:s("terminal:controls.adjustCameraSpeed")})]}),e.jsx(te,{sensitivity:l.sensitivity})]})]})]}),i==="trackpad"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shortcuts-modal-toolbar",children:[e.jsx("span",{className:"mouse-controls-subtitle",children:s("terminal:controls.trackpadGestureSettings")}),e.jsx("button",{className:"shortcuts-reset-all-btn",onClick:F,children:s("common:buttons.reset")})]}),e.jsx("div",{className:"shortcuts-modal-content trackpad-controls-content",children:e.jsx(se,{config:h})})]}),e.jsx("div",{className:"shortcuts-modal-footer",children:e.jsx("span",{className:"shortcuts-modal-hint",children:s(i==="keyboard"?d?"terminal:controls.hintFindByShortcut":"terminal:controls.hintKeyboard":i==="mouse"?"terminal:controls.hintMouse":"terminal:controls.hintTrackpad")})})]})})}function ee({binding:t}){const{t:n}=S(["terminal"]),s=W(),[o,l]=m.useState(!1),[h,i]=m.useState(null);m.useEffect(()=>{if(!o)return;const d=x=>{x.preventDefault(),x.stopPropagation();const M={0:"left",1:"middle",2:"right",3:"back",4:"forward"}[x.button];M&&i({button:M,modifiers:{ctrl:x.ctrlKey,alt:x.altKey,shift:x.shiftKey,meta:x.metaKey}})},p=x=>{x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),l(!1),i(null))},c=()=>{h&&z(s.bindings,h,t.id).length===0&&y.updateMouseBinding(t.id,{button:h.button,modifiers:h.modifiers}),l(!1),i(null)},f=setTimeout(()=>{document.addEventListener("mousedown",d,!0),document.addEventListener("keydown",p,!0),document.addEventListener("click",c,!0)},100);return()=>{clearTimeout(f),document.removeEventListener("mousedown",d,!0),document.removeEventListener("keydown",p,!0),document.removeEventListener("click",c,!0)}},[o,h,t.id,s.bindings]);const j=h?z(s.bindings,h,t.id):[],b=n(`terminal:controls.mouseBindings.${t.id}.name`,{defaultValue:t.name}),v=n(`terminal:controls.mouseBindings.${t.id}.description`,{defaultValue:t.description}),k=d=>n(`terminal:controls.mouseButtons.${d}`,{defaultValue:d}),g=h?A({...t,...h},k):A(t,k);return e.jsxs("div",{className:`shortcut-item ${t.enabled?"":"disabled"}`,children:[e.jsxs("div",{className:"shortcut-item-info",children:[e.jsx("span",{className:"shortcut-item-name",children:b}),e.jsx("span",{className:"shortcut-item-description",children:v})]}),e.jsxs("div",{className:"key-capture-container",children:[e.jsx("button",{className:`key-capture-input ${o?"capturing":""} ${j.length>0?"conflict":""}`,onClick:()=>l(!0),children:o?h?e.jsx("span",{className:"key-capture-value",style:{color:"#f1fa8c"},children:g}):e.jsx("span",{style:{color:"#6272a4",fontStyle:"italic"},children:n("terminal:controls.clickToCapture")}):e.jsx("span",{className:"key-capture-value",children:g})}),j.length>0&&e.jsxs("span",{className:"key-capture-conflict",children:[n("terminal:controls.conflicts"),": ",j.map(d=>n(`terminal:controls.mouseBindings.${d.id}.name`,{defaultValue:d.name})).join(", ")]})]})]})}function te({sensitivity:t}){const{t:n}=S(["terminal"]),s=m.useCallback((o,l)=>{y.updateCameraSensitivity({[o]:l})},[]);return e.jsxs("div",{className:"sensitivity-inline-settings",children:[e.jsxs("div",{className:"sensitivity-sliders",children:[e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:n("terminal:controls.panSpeed")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:t.panSpeed,onChange:o=>s("panSpeed",parseFloat(o.target.value))}),e.jsxs("span",{className:"sensitivity-slider-value",children:[t.panSpeed.toFixed(1),"x"]})]}),e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:n("terminal:controls.orbitSpeed")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:t.orbitSpeed,onChange:o=>s("orbitSpeed",parseFloat(o.target.value))}),e.jsxs("span",{className:"sensitivity-slider-value",children:[t.orbitSpeed.toFixed(1),"x"]})]}),e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:n("terminal:controls.zoomSpeed")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:t.zoomSpeed,onChange:o=>s("zoomSpeed",parseFloat(o.target.value))}),e.jsxs("span",{className:"sensitivity-slider-value",children:[t.zoomSpeed.toFixed(1),"x"]})]}),e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:n("terminal:controls.smoothing")}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:t.smoothing,onChange:o=>s("smoothing",parseFloat(o.target.value))}),e.jsx("span",{className:"sensitivity-slider-value",children:t.smoothing.toFixed(1)})]})]}),e.jsxs("div",{className:"sensitivity-checkboxes-inline",children:[e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:t.invertPanX,onChange:o=>s("invertPanX",o.target.checked)}),e.jsx("span",{children:n("terminal:controls.invertPanX")})]}),e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:t.invertPanY,onChange:o=>s("invertPanY",o.target.checked)}),e.jsx("span",{children:n("terminal:controls.invertPanY")})]}),e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:t.invertOrbitX,onChange:o=>s("invertOrbitX",o.target.checked)}),e.jsx("span",{children:n("terminal:controls.invertOrbitX")})]}),e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:t.invertOrbitY,onChange:o=>s("invertOrbitY",o.target.checked)}),e.jsx("span",{children:n("terminal:controls.invertOrbitY")})]})]})]})}function se({config:t}){const{t:n}=S(["terminal"]),s=m.useCallback((l,h)=>{y.updateTrackpadConfig({[l]:h})},[]),o=m.useCallback((l,h)=>{y.updateTrackpadConfig({sensitivity:{[l]:h}})},[]);return e.jsxs("div",{className:"trackpad-settings",children:[e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:n("terminal:controls.trackpadGestures")}),e.jsx("span",{className:"shortcuts-context-description",children:n("terminal:controls.enableTrackpadSupport")})]}),e.jsx("div",{className:"trackpad-toggle-row",children:e.jsxs("label",{className:"trackpad-toggle",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:l=>s("enabled",l.target.checked)}),e.jsx("span",{className:"trackpad-toggle-label",children:n("terminal:controls.enableTrackpadGestures")})]})})]}),e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:n("terminal:controls.gestureControls")}),e.jsx("span",{className:"shortcuts-context-description",children:n("terminal:controls.enableDisableGestures")})]}),e.jsxs("div",{className:"trackpad-gestures-grid",children:[e.jsxs("label",{className:`trackpad-gesture-item ${t.enabled?"":"disabled"}`,children:[e.jsx("input",{type:"checkbox",checked:t.pinchToZoom,onChange:l=>s("pinchToZoom",l.target.checked),disabled:!t.enabled}),e.jsxs("div",{className:"trackpad-gesture-info",children:[e.jsx("span",{className:"trackpad-gesture-name",children:n("terminal:controls.pinchToZoom")}),e.jsx("span",{className:"trackpad-gesture-desc",children:n("terminal:controls.pinchToZoomDesc")})]})]}),e.jsxs("label",{className:`trackpad-gesture-item ${t.enabled?"":"disabled"}`,children:[e.jsx("input",{type:"checkbox",checked:t.twoFingerPan,onChange:l=>s("twoFingerPan",l.target.checked),disabled:!t.enabled}),e.jsxs("div",{className:"trackpad-gesture-info",children:[e.jsx("span",{className:"trackpad-gesture-name",children:n("terminal:controls.twoFingerPan")}),e.jsx("span",{className:"trackpad-gesture-desc",children:n("terminal:controls.twoFingerPanDesc")})]})]}),e.jsxs("label",{className:`trackpad-gesture-item ${t.enabled?"":"disabled"}`,children:[e.jsx("input",{type:"checkbox",checked:t.shiftTwoFingerOrbit,onChange:l=>s("shiftTwoFingerOrbit",l.target.checked),disabled:!t.enabled}),e.jsxs("div",{className:"trackpad-gesture-info",children:[e.jsx("span",{className:"trackpad-gesture-name",children:n("terminal:controls.shiftTwoFingerOrbit")}),e.jsx("span",{className:"trackpad-gesture-desc",children:n("terminal:controls.shiftTwoFingerOrbitDesc")})]})]})]})]}),e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:n("terminal:controls.sensitivity")}),e.jsx("span",{className:"shortcuts-context-description",children:n("terminal:controls.adjustGestureSensitivity")})]}),e.jsxs("div",{className:"trackpad-sensitivity-sliders",children:[e.jsxs("div",{className:`trackpad-slider-row ${!t.enabled||!t.pinchToZoom?"disabled":""}`,children:[e.jsx("label",{children:n("terminal:controls.zoom")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:t.sensitivity.zoom,onChange:l=>o("zoom",parseFloat(l.target.value)),disabled:!t.enabled||!t.pinchToZoom}),e.jsxs("span",{className:"trackpad-slider-value",children:[t.sensitivity.zoom.toFixed(1),"x"]})]}),e.jsxs("div",{className:`trackpad-slider-row ${!t.enabled||!t.twoFingerPan?"disabled":""}`,children:[e.jsx("label",{children:n("terminal:controls.pan")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:t.sensitivity.pan,onChange:l=>o("pan",parseFloat(l.target.value)),disabled:!t.enabled||!t.twoFingerPan}),e.jsxs("span",{className:"trackpad-slider-value",children:[t.sensitivity.pan.toFixed(1),"x"]})]}),e.jsxs("div",{className:`trackpad-slider-row ${!t.enabled||!t.shiftTwoFingerOrbit?"disabled":""}`,children:[e.jsx("label",{children:n("terminal:controls.orbit")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:t.sensitivity.orbit,onChange:l=>o("orbit",parseFloat(l.target.value)),disabled:!t.enabled||!t.shiftTwoFingerOrbit}),e.jsxs("span",{className:"trackpad-slider-value",children:[t.sensitivity.orbit.toFixed(1),"x"]})]})]})]})]})}export{oe as ControlsModal};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{u as L,h as f,r as m,s as r,j as x}from"./main-ocVprcIe.js";import{L as S}from"./LogViewerModal-BilRZ0Fi.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react-uS-d4TUT.js";import"./vendor-three-PBVcEoyM.js";function h({building:t,isOpen:o,onClose:n}){var a;const{t:i}=L(["terminal"]),{streamingBuildingLogs:c,streamingBuildingIds:g}=f(),s=c.get(t.id)||"",p=g.has(t.id);m.useEffect(()=>{var e;return o&&((e=t.docker)!=null&&e.enabled)&&r.startLogStreaming(t.id,200),()=>{t.id&&r.stopLogStreaming(t.id)}},[o,t.id,(a=t.docker)==null?void 0:a.enabled]);const d=m.useMemo(()=>s.split(`
|
|
2
|
+
`).map((e,l)=>({text:e,lineNumber:l+1})),[s]);return x.jsx(S,{isOpen:o,onClose:n,title:`${t.name} - ${i("terminal:logs.dockerLogs")}`,icon:"🐳",lines:d,isStreaming:p,onClear:()=>r.clearStreamingLogs(t.id)})}export{h as DockerLogsModal};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{r as je,j as eO}from"./main-ocVprcIe.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react-uS-d4TUT.js";import"./vendor-three-PBVcEoyM.js";let xs=[],ec=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,O=0;e<t.length;e++)(e%2?ec:xs).push(O=O+t[e])})();function gu(t){if(t<768)return!1;for(let e=0,O=xs.length;;){let i=e+O>>1;if(t<xs[i])O=i;else if(t>=ec[i])e=i+1;else return!0;if(e==O)return!1}}function Bo(t){return t>=127462&&t<=127487}const No=8205;function Su(t,e,O=!0,i=!0){return(O?Oc:Xu)(t,e,i)}function Oc(t,e,O){if(e==t.length)return e;e&&tc(t.charCodeAt(e))&&ic(t.charCodeAt(e-1))&&e--;let i=wn(t,e);for(e+=Fo(i);e<t.length;){let r=wn(t,e);if(i==No||r==No||O&&gu(r))e+=Fo(r),i=r;else if(Bo(r)){let n=0,s=e-2;for(;s>=0&&Bo(wn(t,s));)n++,s-=2;if(n%2==0)break;e+=2}else break}return e}function Xu(t,e,O){for(;e>0;){let i=Oc(t,e-2,O);if(i<e)return i;e--}return 0}function wn(t,e){let O=t.charCodeAt(e);if(!ic(O)||e+1==t.length)return O;let i=t.charCodeAt(e+1);return tc(i)?(O-55296<<10)+(i-56320)+65536:O}function tc(t){return t>=56320&&t<57344}function ic(t){return t>=55296&&t<56320}function Fo(t){return t<65536?1:2}class G{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,O,i){[e,O]=Zt(this,e,O);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(O,this.length,r,1),sO.from(r,this.length-(O-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,O=this.length){[e,O]=Zt(this,e,O);let i=[];return this.decompose(e,O,i,0),sO.from(i,O-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let O=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new ti(this),n=new ti(e);for(let s=O,a=O;;){if(r.next(s),n.next(s),s=0,r.lineBreak!=n.lineBreak||r.done!=n.done||r.value!=n.value)return!1;if(a+=r.value.length,r.done||a>=i)return!0}}iter(e=1){return new ti(this,e)}iterRange(e,O=this.length){return new rc(this,e,O)}iterLines(e,O){let i;if(e==null)i=this.iter();else{O==null&&(O=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,O==this.lines+1?this.length:O<=1?0:this.line(O-1).to))}return new nc(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?G.empty:e.length<=32?new ie(e):sO.from(ie.split(e,[]))}}class ie extends G{constructor(e,O=Tu(e)){super(),this.text=e,this.length=O}get lines(){return this.text.length}get children(){return null}lineInner(e,O,i,r){for(let n=0;;n++){let s=this.text[n],a=r+s.length;if((O?i:a)>=e)return new yu(r,a,i,s);r=a+1,i++}}decompose(e,O,i,r){let n=e<=0&&O>=this.length?this:new ie(Ho(this.text,e,O),Math.min(O,this.length)-Math.max(0,e));if(r&1){let s=i.pop(),a=ur(n.text,s.text.slice(),0,n.length);if(a.length<=32)i.push(new ie(a,s.length+n.length));else{let o=a.length>>1;i.push(new ie(a.slice(0,o)),new ie(a.slice(o)))}}else i.push(n)}replace(e,O,i){if(!(i instanceof ie))return super.replace(e,O,i);[e,O]=Zt(this,e,O);let r=ur(this.text,ur(i.text,Ho(this.text,0,e)),O),n=this.length+i.length-(O-e);return r.length<=32?new ie(r,n):sO.from(ie.split(r,[]),n)}sliceString(e,O=this.length,i=`
|
|
2
2
|
`){[e,O]=Zt(this,e,O);let r="";for(let n=0,s=0;n<=O&&s<this.text.length;s++){let a=this.text[s],o=n+a.length;n>e&&s&&(r+=i),e<o&&O>n&&(r+=a.slice(Math.max(0,e-n),O-n)),n=o+1}return r}flatten(e){for(let O of this.text)e.push(O)}scanIdentical(){return 0}static split(e,O){let i=[],r=-1;for(let n of e)i.push(n),r+=n.length+1,i.length==32&&(O.push(new ie(i,r)),i=[],r=-1);return r>-1&&O.push(new ie(i,r)),O}}class sO extends G{constructor(e,O){super(),this.children=e,this.length=O,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,O,i,r){for(let n=0;;n++){let s=this.children[n],a=r+s.length,o=i+s.lines-1;if((O?o:a)>=e)return s.lineInner(e,O,i,r);r=a+1,i=o+1}}decompose(e,O,i,r){for(let n=0,s=0;s<=O&&n<this.children.length;n++){let a=this.children[n],o=s+a.length;if(e<=o&&O>=s){let l=r&((s<=e?1:0)|(o>=O?2:0));s>=e&&o<=O&&!l?i.push(a):a.decompose(e-s,O-s,i,l)}s=o+1}}replace(e,O,i){if([e,O]=Zt(this,e,O),i.lines<this.lines)for(let r=0,n=0;r<this.children.length;r++){let s=this.children[r],a=n+s.length;if(e>=n&&O<=a){let o=s.replace(e-n,O-n,i),l=this.lines-s.lines+o.lines;if(o.lines<l>>4&&o.lines>l>>6){let Q=this.children.slice();return Q[r]=o,new sO(Q,this.length-(O-e)+i.length)}return super.replace(n,a,o)}n=a+1}return super.replace(e,O,i)}sliceString(e,O=this.length,i=`
|
|
3
3
|
`){[e,O]=Zt(this,e,O);let r="";for(let n=0,s=0;n<this.children.length&&s<=O;n++){let a=this.children[n],o=s+a.length;s>e&&n&&(r+=i),e<o&&O>s&&(r+=a.sliceString(e-s,O-s,i)),s=o+1}return r}flatten(e){for(let O of this.children)O.flatten(e)}scanIdentical(e,O){if(!(e instanceof sO))return 0;let i=0,[r,n,s,a]=O>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=O,n+=O){if(r==s||n==a)return i;let o=this.children[r],l=e.children[n];if(o!=l)return i+o.scanIdentical(l,O);i+=o.length+1}}static from(e,O=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let f of e)i+=f.lines;if(i<32){let f=[];for(let d of e)d.flatten(f);return new ie(f,O)}let r=Math.max(32,i>>5),n=r<<1,s=r>>1,a=[],o=0,l=-1,Q=[];function $(f){let d;if(f.lines>n&&f instanceof sO)for(let u of f.children)$(u);else f.lines>s&&(o>s||!o)?(h(),a.push(f)):f instanceof ie&&o&&(d=Q[Q.length-1])instanceof ie&&f.lines+d.lines<=32?(o+=f.lines,l+=f.length+1,Q[Q.length-1]=new ie(d.text.concat(f.text),d.length+1+f.length)):(o+f.lines>r&&h(),o+=f.lines,l+=f.length+1,Q.push(f))}function h(){o!=0&&(a.push(Q.length==1?Q[0]:sO.from(Q,l)),l=-1,o=Q.length=0)}for(let f of e)$(f);return h(),a.length==1?a[0]:new sO(a,O)}}G.empty=new ie([""],0);function Tu(t){let e=-1;for(let O of t)e+=O.length+1;return e}function ur(t,e,O=0,i=1e9){for(let r=0,n=0,s=!0;n<t.length&&r<=i;n++){let a=t[n],o=r+a.length;o>=O&&(o>i&&(a=a.slice(0,i-r)),r<O&&(a=a.slice(O-r)),s?(e[e.length-1]+=a,s=!1):e.push(a)),r=o+1}return e}function Ho(t,e,O){return ur(t,[""],e,O)}class ti{constructor(e,O=1){this.dir=O,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[O>0?1:(e instanceof ie?e.text.length:e.children.length)<<1]}nextInner(e,O){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],n=this.offsets[i],s=n>>1,a=r instanceof ie?r.text.length:r.children.length;if(s==(O>0?a:0)){if(i==0)return this.done=!0,this.value="",this;O>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((n&1)==(O>0?0:1)){if(this.offsets[i]+=O,e==0)return this.lineBreak=!0,this.value=`
|
|
4
4
|
`,this;e--}else if(r instanceof ie){let o=r.text[s+(O<0?-1:0)];if(this.offsets[i]+=O,o.length>Math.max(0,e))return this.value=e==0?o:O>0?o.slice(e):o.slice(0,o.length-e),this;e-=o.length}else{let o=r.children[s+(O<0?-1:0)];e>o.length?(e-=o.length,this.offsets[i]+=O):(O<0&&this.offsets[i]--,this.nodes.push(o),this.offsets.push(O>0?1:(o instanceof ie?o.text.length:o.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class rc{constructor(e,O,i){this.value="",this.done=!1,this.cursor=new ti(e,O>i?-1:1),this.pos=O>i?e.length:0,this.from=Math.min(O,i),this.to=Math.max(O,i)}nextInner(e,O){if(O<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,O<0?this.pos-this.to:this.from-this.pos);let i=O<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*O,this.value=r.length<=i?r:O<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class nc{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:O,lineBreak:i,value:r}=this.inner.next(e);return O&&this.afterBreak?(this.value="",this.afterBreak=!1):O?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(G.prototype[Symbol.iterator]=function(){return this.iter()},ti.prototype[Symbol.iterator]=rc.prototype[Symbol.iterator]=nc.prototype[Symbol.iterator]=function(){return this});let yu=class{constructor(e,O,i,r){this.from=e,this.to=O,this.number=i,this.text=r}get length(){return this.to-this.from}};function Zt(t,e,O){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,O))]}function oe(t,e,O=!0,i=!0){return Su(t,e,O,i)}function bu(t){return t>=56320&&t<57344}function xu(t){return t>=55296&&t<56320}function $t(t,e){let O=t.charCodeAt(e);if(!xu(O)||e+1==t.length)return O;let i=t.charCodeAt(e+1);return bu(i)?(O-55296<<10)+(i-56320)+65536:O}function sc(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function Ri(t){return t<65536?1:2}const ws=/\r\n?|\n/;var de=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(de||(de={}));class hO{constructor(e){this.sections=e}get length(){let e=0;for(let O=0;O<this.sections.length;O+=2)e+=this.sections[O];return e}get newLength(){let e=0;for(let O=0;O<this.sections.length;O+=2){let i=this.sections[O+1];e+=i<0?this.sections[O]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let O=0,i=0,r=0;O<this.sections.length;){let n=this.sections[O++],s=this.sections[O++];s<0?(e(i,r,n),r+=n):r+=s,i+=n}}iterChangedRanges(e,O=!1){Ys(this,e,O)}get invertedDesc(){let e=[];for(let O=0;O<this.sections.length;){let i=this.sections[O++],r=this.sections[O++];r<0?e.push(i,r):e.push(r,i)}return new hO(e)}composeDesc(e){return this.empty?e:e.empty?this:ac(this,e)}mapDesc(e,O=!1){return e.empty?this:ks(this,e,O)}mapPos(e,O=-1,i=de.Simple){let r=0,n=0;for(let s=0;s<this.sections.length;){let a=this.sections[s++],o=this.sections[s++],l=r+a;if(o<0){if(l>e)return n+(e-r);n+=a}else{if(i!=de.Simple&&l>=e&&(i==de.TrackDel&&r<e&&l>e||i==de.TrackBefore&&r<e||i==de.TrackAfter&&l>e))return null;if(l>e||l==e&&O<0&&!a)return e==r||O<0?n:n+o;n+=o}r=l}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return n}touchesRange(e,O=e){for(let i=0,r=0;i<this.sections.length&&r<=O;){let n=this.sections[i++],s=this.sections[i++],a=r+n;if(s>=0&&r<=O&&a>=e)return r<e&&a>O?"cover":!0;r=a}return!1}toString(){let e="";for(let O=0;O<this.sections.length;){let i=this.sections[O++],r=this.sections[O++];e+=(e?" ":"")+i+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(O=>typeof O!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new hO(e)}static create(e){return new hO(e)}}class ne extends hO{constructor(e,O){super(e),this.inserted=O}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Ys(this,(O,i,r,n,s)=>e=e.replace(r,r+(i-O),s),!1),e}mapDesc(e,O=!1){return ks(this,e,O,!0)}invert(e){let O=this.sections.slice(),i=[];for(let r=0,n=0;r<O.length;r+=2){let s=O[r],a=O[r+1];if(a>=0){O[r]=a,O[r+1]=s;let o=r>>1;for(;i.length<o;)i.push(G.empty);i.push(s?e.slice(n,n+s):G.empty)}n+=s}return new ne(O,i)}compose(e){return this.empty?e:e.empty?this:ac(this,e,!0)}map(e,O=!1){return e.empty?this:ks(this,e,O,!0)}iterChanges(e,O=!1){Ys(this,e,O)}get desc(){return hO.create(this.sections)}filter(e){let O=[],i=[],r=[],n=new ci(this);e:for(let s=0,a=0;;){let o=s==e.length?1e9:e[s++];for(;a<o||a==o&&n.len==0;){if(n.done)break e;let Q=Math.min(n.len,o-a);fe(r,Q,-1);let $=n.ins==-1?-1:n.off==0?n.ins:0;fe(O,Q,$),$>0&&VO(i,O,n.text),n.forward(Q),a+=Q}let l=e[s++];for(;a<l;){if(n.done)break e;let Q=Math.min(n.len,l-a);fe(O,Q,-1),fe(r,Q,n.ins==-1?-1:n.off==0?n.ins:0),n.forward(Q),a+=Q}}return{changes:new ne(O,i),filtered:hO.create(r)}}toJSON(){let e=[];for(let O=0;O<this.sections.length;O+=2){let i=this.sections[O],r=this.sections[O+1];r<0?e.push(i):r==0?e.push([i]):e.push([i].concat(this.inserted[O>>1].toJSON()))}return e}static of(e,O,i){let r=[],n=[],s=0,a=null;function o(Q=!1){if(!Q&&!r.length)return;s<O&&fe(r,O-s,-1);let $=new ne(r,n);a=a?a.compose($.map(a)):$,r=[],n=[],s=0}function l(Q){if(Array.isArray(Q))for(let $ of Q)l($);else if(Q instanceof ne){if(Q.length!=O)throw new RangeError(`Mismatched change set length (got ${Q.length}, expected ${O})`);o(),a=a?a.compose(Q.map(a)):Q}else{let{from:$,to:h=$,insert:f}=Q;if($>h||$<0||h>O)throw new RangeError(`Invalid change range ${$} to ${h} (in doc of length ${O})`);let d=f?typeof f=="string"?G.of(f.split(i||ws)):f:G.empty,u=d.length;if($==h&&u==0)return;$<s&&o(),$>s&&fe(r,$-s,-1),fe(r,h-$,u),VO(n,r,d),s=h}}return l(e),o(!a),a}static empty(e){return new ne(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let O=[],i=[];for(let r=0;r<e.length;r++){let n=e[r];if(typeof n=="number")O.push(n,-1);else{if(!Array.isArray(n)||typeof n[0]!="number"||n.some((s,a)=>a&&typeof s!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(n.length==1)O.push(n[0],0);else{for(;i.length<r;)i.push(G.empty);i[r]=G.of(n.slice(1)),O.push(n[0],i[r].length)}}}return new ne(O,i)}static createSet(e,O){return new ne(e,O)}}function fe(t,e,O,i=!1){if(e==0&&O<=0)return;let r=t.length-2;r>=0&&O<=0&&O==t[r+1]?t[r]+=e:r>=0&&e==0&&t[r]==0?t[r+1]+=O:i?(t[r]+=e,t[r+1]+=O):t.push(e,O)}function VO(t,e,O){if(O.length==0)return;let i=e.length-2>>1;if(i<t.length)t[t.length-1]=t[t.length-1].append(O);else{for(;t.length<i;)t.push(G.empty);t.push(O)}}function Ys(t,e,O){let i=t.inserted;for(let r=0,n=0,s=0;s<t.sections.length;){let a=t.sections[s++],o=t.sections[s++];if(o<0)r+=a,n+=a;else{let l=r,Q=n,$=G.empty;for(;l+=a,Q+=o,o&&i&&($=$.append(i[s-2>>1])),!(O||s==t.sections.length||t.sections[s+1]<0);)a=t.sections[s++],o=t.sections[s++];e(r,l,n,Q,$),r=l,n=Q}}}function ks(t,e,O,i=!1){let r=[],n=i?[]:null,s=new ci(t),a=new ci(e);for(let o=-1;;){if(s.done&&a.len||a.done&&s.len)throw new Error("Mismatched change set lengths");if(s.ins==-1&&a.ins==-1){let l=Math.min(s.len,a.len);fe(r,l,-1),s.forward(l),a.forward(l)}else if(a.ins>=0&&(s.ins<0||o==s.i||s.off==0&&(a.len<s.len||a.len==s.len&&!O))){let l=a.len;for(fe(r,a.ins,-1);l;){let Q=Math.min(s.len,l);s.ins>=0&&o<s.i&&s.len<=Q&&(fe(r,0,s.ins),n&&VO(n,r,s.text),o=s.i),s.forward(Q),l-=Q}a.next()}else if(s.ins>=0){let l=0,Q=s.len;for(;Q;)if(a.ins==-1){let $=Math.min(Q,a.len);l+=$,Q-=$,a.forward($)}else if(a.ins==0&&a.len<Q)Q-=a.len,a.next();else break;fe(r,l,o<s.i?s.ins:0),n&&o<s.i&&VO(n,r,s.text),o=s.i,s.forward(s.len-Q)}else{if(s.done&&a.done)return n?ne.createSet(r,n):hO.create(r);throw new Error("Mismatched change set lengths")}}}function ac(t,e,O=!1){let i=[],r=O?[]:null,n=new ci(t),s=new ci(e);for(let a=!1;;){if(n.done&&s.done)return r?ne.createSet(i,r):hO.create(i);if(n.ins==0)fe(i,n.len,0,a),n.next();else if(s.len==0&&!s.done)fe(i,0,s.ins,a),r&&VO(r,i,s.text),s.next();else{if(n.done||s.done)throw new Error("Mismatched change set lengths");{let o=Math.min(n.len2,s.len),l=i.length;if(n.ins==-1){let Q=s.ins==-1?-1:s.off?0:s.ins;fe(i,o,Q,a),r&&Q&&VO(r,i,s.text)}else s.ins==-1?(fe(i,n.off?0:n.len,o,a),r&&VO(r,i,n.textBit(o))):(fe(i,n.off?0:n.len,s.off?0:s.ins,a),r&&!s.off&&VO(r,i,s.text));a=(n.ins>o||s.ins>=0&&s.len>o)&&(a||i.length>l),n.forward2(o),s.forward(o)}}}}class ci{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,O=this.i-2>>1;return O>=e.length?G.empty:e[O]}textBit(e){let{inserted:O}=this.set,i=this.i-2>>1;return i>=O.length&&!e?G.empty:O[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class JO{constructor(e,O,i){this.from=e,this.to=O,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,O=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,O):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new JO(i,r,this.flags)}extend(e,O=e){if(e<=this.anchor&&O>=this.anchor)return P.range(e,O);let i=Math.abs(e-this.anchor)>Math.abs(O-this.anchor)?e:O;return P.range(this.anchor,i)}eq(e,O=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!O||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return P.range(e.anchor,e.head)}static create(e,O,i){return new JO(e,O,i)}}class P{constructor(e,O){this.ranges=e,this.mainIndex=O}map(e,O=-1){return e.empty?this:P.create(this.ranges.map(i=>i.map(e,O)),this.mainIndex)}eq(e,O=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],O))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new P([this.main],0)}addRange(e,O=!0){return P.create([e].concat(this.ranges),O?0:this.mainIndex+1)}replaceRange(e,O=this.mainIndex){let i=this.ranges.slice();return i[O]=e,P.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new P(e.ranges.map(O=>JO.fromJSON(O)),e.main)}static single(e,O=e){return new P([P.range(e,O)],0)}static create(e,O=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;r<e.length;r++){let n=e[r];if(n.empty?n.from<=i:n.from<i)return P.normalized(e.slice(),O);i=n.to}return new P(e,O)}static cursor(e,O=0,i,r){return JO.create(e,e,(O==0?0:O<0?8:16)|(i==null?7:Math.min(6,i))|(r??16777215)<<6)}static range(e,O,i,r){let n=(i??16777215)<<6|(r==null?7:Math.min(6,r));return O<e?JO.create(O,e,48|n):JO.create(e,O,(O>e?8:0)|n)}static normalized(e,O=0){let i=e[O];e.sort((r,n)=>r.from-n.from),O=e.indexOf(i);for(let r=1;r<e.length;r++){let n=e[r],s=e[r-1];if(n.empty?n.from<=s.to:n.from<s.to){let a=s.from,o=Math.max(n.to,s.to);r<=O&&O--,e.splice(--r,2,n.anchor>n.head?P.range(o,a):P.range(a,o))}}return new P(e,O)}}function oc(t,e){for(let O of t.ranges)if(O.to>e)throw new RangeError("Selection points outside of document")}let Aa=0;class k{constructor(e,O,i,r,n){this.combine=e,this.compareInput=O,this.compare=i,this.isStatic=r,this.id=Aa++,this.default=e([]),this.extensions=typeof n=="function"?n(this):n}get reader(){return this}static define(e={}){return new k(e.combine||(O=>O),e.compareInput||((O,i)=>O===i),e.compare||(e.combine?(O,i)=>O===i:Ea),!!e.static,e.enables)}of(e){return new pr([],this,0,e)}compute(e,O){if(this.isStatic)throw new Error("Can't compute a static facet");return new pr(e,this,1,O)}computeN(e,O){if(this.isStatic)throw new Error("Can't compute a static facet");return new pr(e,this,2,O)}from(e,O){return O||(O=i=>i),this.compute([e],i=>O(i.field(e)))}}function Ea(t,e){return t==e||t.length==e.length&&t.every((O,i)=>O===e[i])}class pr{constructor(e,O,i,r){this.dependencies=e,this.facet=O,this.type=i,this.value=r,this.id=Aa++}dynamicSlot(e){var O;let i=this.value,r=this.facet.compareInput,n=this.id,s=e[n]>>1,a=this.type==2,o=!1,l=!1,Q=[];for(let $ of this.dependencies)$=="doc"?o=!0:$=="selection"?l=!0:(((O=e[$.id])!==null&&O!==void 0?O:1)&1)==0&&Q.push(e[$.id]);return{create($){return $.values[s]=i($),1},update($,h){if(o&&h.docChanged||l&&(h.docChanged||h.selection)||Zs($,Q)){let f=i($);if(a?!Ko(f,$.values[s],r):!r(f,$.values[s]))return $.values[s]=f,1}return 0},reconfigure:($,h)=>{let f,d=h.config.address[n];if(d!=null){let u=_r(h,d);if(this.dependencies.every(p=>p instanceof k?h.facet(p)===$.facet(p):p instanceof Ue?h.field(p,!1)==$.field(p,!1):!0)||(a?Ko(f=i($),u,r):r(f=i($),u)))return $.values[s]=u,0}else f=i($);return $.values[s]=f,1}}}}function Ko(t,e,O){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!O(t[i],e[i]))return!1;return!0}function Zs(t,e){let O=!1;for(let i of e)ii(t,i)&1&&(O=!0);return O}function wu(t,e,O){let i=O.map(o=>t[o.id]),r=O.map(o=>o.type),n=i.filter(o=>!(o&1)),s=t[e.id]>>1;function a(o){let l=[];for(let Q=0;Q<i.length;Q++){let $=_r(o,i[Q]);if(r[Q]==2)for(let h of $)l.push(h);else l.push($)}return e.combine(l)}return{create(o){for(let l of i)ii(o,l);return o.values[s]=a(o),1},update(o,l){if(!Zs(o,n))return 0;let Q=a(o);return e.compare(Q,o.values[s])?0:(o.values[s]=Q,1)},reconfigure(o,l){let Q=Zs(o,i),$=l.config.facets[e.id],h=l.facet(e);if($&&!Q&&Ea(O,$))return o.values[s]=h,0;let f=a(o);return e.compare(f,h)?(o.values[s]=h,0):(o.values[s]=f,1)}}}const Ii=k.define({static:!0});class Ue{constructor(e,O,i,r,n){this.id=e,this.createF=O,this.updateF=i,this.compareF=r,this.spec=n,this.provides=void 0}static define(e){let O=new Ue(Aa++,e.create,e.update,e.compare||((i,r)=>i===r),e);return e.provide&&(O.provides=e.provide(O)),O}create(e){let O=e.facet(Ii).find(i=>i.field==this);return((O==null?void 0:O.create)||this.createF)(e)}slot(e){let O=e[this.id]>>1;return{create:i=>(i.values[O]=this.create(i),1),update:(i,r)=>{let n=i.values[O],s=this.updateF(n,r);return this.compareF(n,s)?0:(i.values[O]=s,1)},reconfigure:(i,r)=>{let n=i.facet(Ii),s=r.facet(Ii),a;return(a=n.find(o=>o.field==this))&&a!=s.find(o=>o.field==this)?(i.values[O]=a.create(i),1):r.config.address[this.id]!=null?(i.values[O]=r.field(this),0):(i.values[O]=this.create(i),1)}}}init(e){return[this,Ii.of({field:this,create:e})]}get extension(){return this}}const FO={lowest:4,low:3,default:2,high:1,highest:0};function Lt(t){return e=>new lc(e,t)}const ct={highest:Lt(FO.highest),high:Lt(FO.high),default:Lt(FO.default),low:Lt(FO.low),lowest:Lt(FO.lowest)};class lc{constructor(e,O){this.inner=e,this.prec=O}}class $n{of(e){return new _s(this,e)}reconfigure(e){return $n.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class _s{constructor(e,O){this.compartment=e,this.inner=O}}class Zr{constructor(e,O,i,r,n,s){for(this.base=e,this.compartments=O,this.dynamicSlots=i,this.address=r,this.staticValues=n,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let O=this.address[e.id];return O==null?e.default:this.staticValues[O>>1]}static resolve(e,O,i){let r=[],n=Object.create(null),s=new Map;for(let h of Yu(e,O,s))h instanceof Ue?r.push(h):(n[h.facet.id]||(n[h.facet.id]=[])).push(h);let a=Object.create(null),o=[],l=[];for(let h of r)a[h.id]=l.length<<1,l.push(f=>h.slot(f));let Q=i==null?void 0:i.config.facets;for(let h in n){let f=n[h],d=f[0].facet,u=Q&&Q[h]||[];if(f.every(p=>p.type==0))if(a[d.id]=o.length<<1|1,Ea(u,f))o.push(i.facet(d));else{let p=d.combine(f.map(m=>m.value));o.push(i&&d.compare(p,i.facet(d))?i.facet(d):p)}else{for(let p of f)p.type==0?(a[p.id]=o.length<<1|1,o.push(p.value)):(a[p.id]=l.length<<1,l.push(m=>p.dynamicSlot(m)));a[d.id]=l.length<<1,l.push(p=>wu(p,d,f))}}let $=l.map(h=>h(a));return new Zr(e,s,$,a,o,n)}}function Yu(t,e,O){let i=[[],[],[],[],[]],r=new Map;function n(s,a){let o=r.get(s);if(o!=null){if(o<=a)return;let l=i[o].indexOf(s);l>-1&&i[o].splice(l,1),s instanceof _s&&O.delete(s.compartment)}if(r.set(s,a),Array.isArray(s))for(let l of s)n(l,a);else if(s instanceof _s){if(O.has(s.compartment))throw new RangeError("Duplicate use of compartment in extensions");let l=e.get(s.compartment)||s.inner;O.set(s.compartment,l),n(l,a)}else if(s instanceof lc)n(s.inner,s.prec);else if(s instanceof Ue)i[a].push(s),s.provides&&n(s.provides,a);else if(s instanceof pr)i[a].push(s),s.facet.extensions&&n(s.facet.extensions,FO.default);else{let l=s.extension;if(!l)throw new Error(`Unrecognized extension value in extension set (${s}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);n(l,a)}}return n(t,FO.default),i.reduce((s,a)=>s.concat(a))}function ii(t,e){if(e&1)return 2;let O=e>>1,i=t.status[O];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;t.status[O]=4;let r=t.computeSlot(t,t.config.dynamicSlots[O]);return t.status[O]=2|r}function _r(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const Qc=k.define(),vs=k.define({combine:t=>t.some(e=>e),static:!0}),$c=k.define({combine:t=>t.length?t[0]:void 0,static:!0}),cc=k.define(),hc=k.define(),fc=k.define(),dc=k.define({combine:t=>t.length?t[0]:!1});class ZO{constructor(e,O){this.type=e,this.value=O}static define(){return new ku}}class ku{of(e){return new ZO(this,e)}}class Zu{constructor(e){this.map=e}of(e){return new j(this,e)}}class j{constructor(e,O){this.type=e,this.value=O}map(e){let O=this.type.map(this.value,e);return O===void 0?void 0:O==this.value?this:new j(this.type,O)}is(e){return this.type==e}static define(e={}){return new Zu(e.map||(O=>O))}static mapEffects(e,O){if(!e.length)return e;let i=[];for(let r of e){let n=r.map(O);n&&i.push(n)}return i}}j.reconfigure=j.define();j.appendConfig=j.define();class re{constructor(e,O,i,r,n,s){this.startState=e,this.changes=O,this.selection=i,this.effects=r,this.annotations=n,this.scrollIntoView=s,this._doc=null,this._state=null,i&&oc(i,O.newLength),n.some(a=>a.type==re.time)||(this.annotations=n.concat(re.time.of(Date.now())))}static create(e,O,i,r,n,s){return new re(e,O,i,r,n,s)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let O of this.annotations)if(O.type==e)return O.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let O=this.annotation(re.userEvent);return!!(O&&(O==e||O.length>e.length&&O.slice(0,e.length)==e&&O[e.length]=="."))}}re.time=ZO.define();re.userEvent=ZO.define();re.addToHistory=ZO.define();re.remote=ZO.define();function _u(t,e){let O=[];for(let i=0,r=0;;){let n,s;if(i<t.length&&(r==e.length||e[r]>=t[i]))n=t[i++],s=t[i++];else if(r<e.length)n=e[r++],s=e[r++];else return O;!O.length||O[O.length-1]<n?O.push(n,s):O[O.length-1]<s&&(O[O.length-1]=s)}}function uc(t,e,O){var i;let r,n,s;return O?(r=e.changes,n=ne.empty(e.changes.length),s=t.changes.compose(e.changes)):(r=e.changes.map(t.changes),n=t.changes.mapDesc(e.changes,!0),s=t.changes.compose(r)),{changes:s,selection:e.selection?e.selection.map(n):(i=t.selection)===null||i===void 0?void 0:i.map(r),effects:j.mapEffects(t.effects,r).concat(j.mapEffects(e.effects,n)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function Rs(t,e,O){let i=e.selection,r=Tt(e.annotations);return e.userEvent&&(r=r.concat(re.userEvent.of(e.userEvent))),{changes:e.changes instanceof ne?e.changes:ne.of(e.changes||[],O,t.facet($c)),selection:i&&(i instanceof P?i:P.single(i.anchor,i.head)),effects:Tt(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function pc(t,e,O){let i=Rs(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(O=!1);for(let n=1;n<e.length;n++){e[n].filter===!1&&(O=!1);let s=!!e[n].sequential;i=uc(i,Rs(t,e[n],s?i.changes.newLength:t.doc.length),s)}let r=re.create(t,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return Ru(O?vu(r):r)}function vu(t){let e=t.startState,O=!0;for(let r of e.facet(cc)){let n=r(t);if(n===!1){O=!1;break}Array.isArray(n)&&(O=O===!0?n:_u(O,n))}if(O!==!0){let r,n;if(O===!1)n=t.changes.invertedDesc,r=ne.empty(e.doc.length);else{let s=t.changes.filter(O);r=s.changes,n=s.filtered.mapDesc(s.changes).invertedDesc}t=re.create(e,r,t.selection&&t.selection.map(n),j.mapEffects(t.effects,n),t.annotations,t.scrollIntoView)}let i=e.facet(hc);for(let r=i.length-1;r>=0;r--){let n=i[r](t);n instanceof re?t=n:Array.isArray(n)&&n.length==1&&n[0]instanceof re?t=n[0]:t=pc(e,Tt(n),!1)}return t}function Ru(t){let e=t.startState,O=e.facet(fc),i=t;for(let r=O.length-1;r>=0;r--){let n=O[r](t);n&&Object.keys(n).length&&(i=uc(i,Rs(e,n,t.changes.newLength),!0))}return i==t?t:re.create(e,t.changes,t.selection,i.effects,i.annotations,i.scrollIntoView)}const zu=[];function Tt(t){return t==null?zu:Array.isArray(t)?t:[t]}var J=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(J||(J={}));const qu=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let zs;try{zs=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Vu(t){if(zs)return zs.test(t);for(let e=0;e<t.length;e++){let O=t[e];if(/\w/.test(O)||O>""&&(O.toUpperCase()!=O.toLowerCase()||qu.test(O)))return!0}return!1}function Uu(t){return e=>{if(!/\S/.test(e))return J.Space;if(Vu(e))return J.Word;for(let O=0;O<t.length;O++)if(e.indexOf(t[O])>-1)return J.Word;return J.Other}}class A{constructor(e,O,i,r,n,s){this.config=e,this.doc=O,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=n,s&&(s._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)ii(this,a<<1);this.computeSlot=null}field(e,O=!0){let i=this.config.address[e.id];if(i==null){if(O)throw new RangeError("Field is not present in this state");return}return ii(this,i),_r(this,i)}update(...e){return pc(this,e,!0)}applyTransaction(e){let O=this.config,{base:i,compartments:r}=O;for(let a of e.effects)a.is($n.reconfigure)?(O&&(r=new Map,O.compartments.forEach((o,l)=>r.set(l,o)),O=null),r.set(a.value.compartment,a.value.extension)):a.is(j.reconfigure)?(O=null,i=a.value):a.is(j.appendConfig)&&(O=null,i=Tt(i).concat(a.value));let n;O?n=e.startState.values.slice():(O=Zr.resolve(i,r,this),n=new A(O,this.doc,this.selection,O.dynamicSlots.map(()=>null),(o,l)=>l.reconfigure(o,this),null).values);let s=e.startState.facet(vs)?e.newSelection:e.newSelection.asSingle();new A(O,e.newDoc,s,n,(a,o)=>o.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(O=>({changes:{from:O.from,to:O.to,insert:e},range:P.cursor(O.from+e.length)}))}changeByRange(e){let O=this.selection,i=e(O.ranges[0]),r=this.changes(i.changes),n=[i.range],s=Tt(i.effects);for(let a=1;a<O.ranges.length;a++){let o=e(O.ranges[a]),l=this.changes(o.changes),Q=l.map(r);for(let h=0;h<a;h++)n[h]=n[h].map(Q);let $=r.mapDesc(l,!0);n.push(o.range.map($)),r=r.compose(Q),s=j.mapEffects(s,Q).concat(j.mapEffects(Tt(o.effects),$))}return{changes:r,selection:P.create(n,O.mainIndex),effects:s}}changes(e=[]){return e instanceof ne?e:ne.of(e,this.doc.length,this.facet(A.lineSeparator))}toText(e){return G.of(e.split(this.facet(A.lineSeparator)||ws))}sliceDoc(e=0,O=this.doc.length){return this.doc.sliceString(e,O,this.lineBreak)}facet(e){let O=this.config.address[e.id];return O==null?e.default:(ii(this,O),_r(this,O))}toJSON(e){let O={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let r=e[i];r instanceof Ue&&this.config.address[r.id]!=null&&(O[i]=r.spec.toJSON(this.field(e[i]),this))}return O}static fromJSON(e,O={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(i){for(let n in i)if(Object.prototype.hasOwnProperty.call(e,n)){let s=i[n],a=e[n];r.push(s.init(o=>s.spec.fromJSON(a,o)))}}return A.create({doc:e.doc,selection:P.fromJSON(e.selection),extensions:O.extensions?r.concat([O.extensions]):r})}static create(e={}){let O=Zr.resolve(e.extensions||[],new Map),i=e.doc instanceof G?e.doc:G.of((e.doc||"").split(O.staticFacet(A.lineSeparator)||ws)),r=e.selection?e.selection instanceof P?e.selection:P.single(e.selection.anchor,e.selection.head):P.single(0);return oc(r,i.length),O.staticFacet(vs)||(r=r.asSingle()),new A(O,i,r,O.dynamicSlots.map(()=>null),(n,s)=>s.create(n),null)}get tabSize(){return this.facet(A.tabSize)}get lineBreak(){return this.facet(A.lineSeparator)||`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as K,r as a,j as e}from"./main-ocVprcIe.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react-uS-d4TUT.js";import"./vendor-three-PBVcEoyM.js";function ae({url:l,title:W,isOpen:g,onClose:I,initialWidth:H=480,initialHeight:B=360,minWidth:M=320,minHeight:b=240}){const{t:n}=K(["terminal","common"]),[Z,h]=a.useState(!0),[L,k]=a.useState(!1),[o,$]=a.useState({width:H,height:B}),[s,y]=a.useState(null),[f,z]=a.useState(1),[O,R]=a.useState(!1),[T,X]=a.useState(!1),N=a.useRef(null),U=a.useRef(null),d=a.useRef(null),r=a.useRef(null);a.useEffect(()=>{if(g&&!s){const t=Math.max(50,(window.innerWidth-o.width)/2),c=Math.max(50,(window.innerHeight-o.height)/2);y({x:t,y:c})}},[g,s,o.width,o.height]),a.useEffect(()=>{h(!0),k(!1)},[l]);const A=a.useCallback(()=>{h(!1)},[]),V=a.useCallback(()=>{h(!1),k(!0)},[]),Y=a.useCallback(()=>{N.current&&(h(!0),k(!1),N.current.src=l)},[l]),_=a.useCallback(()=>{window.open(l,"_blank")},[l]),q=a.useCallback(()=>{z(t=>Math.min(2,t+.25))},[]),F=a.useCallback(()=>{z(t=>Math.max(.25,t-.25))},[]),G=a.useCallback(()=>{z(1)},[]),J=a.useCallback(t=>{if(t.target.closest(".iframe-modal-btn"))return;t.preventDefault(),R(!0),d.current={startX:t.clientX,startY:t.clientY,startPosX:(s==null?void 0:s.x)??0,startPosY:(s==null?void 0:s.y)??0};const c=m=>{if(!d.current)return;const w=m.clientX-d.current.startX,j=m.clientY-d.current.startY;y({x:Math.max(0,Math.min(window.innerWidth-100,d.current.startPosX+w)),y:Math.max(0,Math.min(window.innerHeight-50,d.current.startPosY+j))})},x=()=>{d.current=null,R(!1),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",x)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",x)},[s]),i=a.useCallback((t,c)=>{t.preventDefault(),t.stopPropagation(),X(!0);const x={startX:t.clientX,startY:t.clientY,startW:o.width,startH:o.height,startPosX:(s==null?void 0:s.x)??0,startPosY:(s==null?void 0:s.y)??0,direction:c};r.current=x;const m=j=>{if(!r.current)return;const p=j.clientX-r.current.startX,C=j.clientY-r.current.startY,v=r.current.direction;let E=r.current.startW,D=r.current.startH,P=r.current.startPosX,S=r.current.startPosY;if(v.includes("e")&&(E=Math.max(M,r.current.startW+p)),v.includes("w")){const u=r.current.startW-p;u>=M&&(E=u,P=r.current.startPosX+p)}if(v.includes("s")&&(D=Math.max(b,r.current.startH+C)),v.includes("n")){const u=r.current.startH-C;u>=b&&(D=u,S=r.current.startPosY+C)}$({width:E,height:D}),y({x:P,y:S})},w=()=>{r.current=null,X(!1),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",w)};document.addEventListener("mousemove",m),document.addEventListener("mouseup",w)},[o,s,M,b]);return g?e.jsxs("div",{ref:U,className:`iframe-modal ${O?"dragging":""} ${T?"resizing":""}`,style:{left:(s==null?void 0:s.x)??0,top:(s==null?void 0:s.y)??0,width:o.width,height:o.height},children:[e.jsxs("div",{className:"iframe-modal-toolbar",onMouseDown:J,children:[e.jsx("div",{className:"iframe-modal-title",title:l,children:W||l}),e.jsxs("div",{className:"iframe-modal-actions",children:[e.jsx("button",{className:"iframe-modal-btn",onClick:F,title:n("terminal:iframeModal.zoomOut"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),e.jsxs("button",{className:"iframe-modal-btn iframe-modal-zoom-label",onClick:G,title:n("terminal:iframeModal.resetZoom"),children:[Math.round(f*100),"%"]}),e.jsx("button",{className:"iframe-modal-btn",onClick:q,title:n("terminal:iframeModal.zoomIn"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),e.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),e.jsx("div",{className:"iframe-modal-separator"}),e.jsx("button",{className:"iframe-modal-btn",onClick:Y,title:n("terminal:iframeModal.refresh"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M23 4v6h-6M1 20v-6h6"}),e.jsx("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]})}),e.jsx("button",{className:"iframe-modal-btn",onClick:_,title:n("terminal:iframeModal.openInBrowser"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}),e.jsx("button",{className:"iframe-modal-btn iframe-modal-close",onClick:I,title:n("common:buttons.close"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),e.jsxs("div",{className:"iframe-modal-content",children:[Z&&e.jsxs("div",{className:"iframe-modal-loading",children:[e.jsx("div",{className:"iframe-modal-spinner"}),e.jsx("span",{children:n("common:status.loading")})]}),L&&e.jsxs("div",{className:"iframe-modal-error",children:[e.jsx("span",{children:n("terminal:iframeModal.failedToLoad")}),e.jsx("button",{onClick:Y,children:n("terminal:iframeModal.retry")})]}),e.jsx("iframe",{ref:N,src:l,className:"iframe-modal-frame",onLoad:A,onError:V,style:{display:L?"none":"block",transform:`scale(${f})`,transformOrigin:"top left",width:`${100/f}%`,height:`${100/f}%`}})]}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-n",onMouseDown:t=>i(t,"n")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-s",onMouseDown:t=>i(t,"s")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-e",onMouseDown:t=>i(t,"e")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-w",onMouseDown:t=>i(t,"w")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-ne",onMouseDown:t=>i(t,"ne")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-nw",onMouseDown:t=>i(t,"nw")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-se",onMouseDown:t=>i(t,"se")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-sw",onMouseDown:t=>i(t,"sw")})]}):null}export{ae as IframeModal,ae as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.iframe-modal{position:fixed;z-index:10000;display:flex;flex-direction:column;background:#1a1a2e;border-radius:8px;box-shadow:0 8px 32px #00000080,0 0 0 1px #ffffff1a;overflow:hidden;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif}.iframe-modal.dragging,.iframe-modal.resizing{-webkit-user-select:none;user-select:none}.iframe-modal.dragging .iframe-modal-content,.iframe-modal.resizing .iframe-modal-content{pointer-events:none}.iframe-modal.dragging .iframe-modal-toolbar{cursor:grabbing}.iframe-modal-toolbar{display:flex;align-items:center;justify-content:space-between;padding:2px 4px;background:#0f0f1a;border-bottom:1px solid rgba(255,255,255,.1);gap:6px;flex-shrink:0;cursor:grab;-webkit-user-select:none;user-select:none}.iframe-modal-title{flex:1;font-size:10px;font-weight:500;color:#ffffffb3;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-left:4px}.iframe-modal-actions{display:flex;gap:1px;align-items:center}.iframe-modal-separator{width:1px;height:12px;background:#ffffff26;margin:0 2px}.iframe-modal-btn{display:flex;align-items:center;justify-content:center;min-width:20px;height:20px;padding:0 2px;background:transparent;border:none;border-radius:3px;color:#fff9;cursor:pointer;transition:all .15s ease}.iframe-modal-btn svg{width:12px;height:12px}.iframe-modal-btn:hover{background:#ffffff1a;color:#fff}.iframe-modal-btn:active{transform:scale(.95)}.iframe-modal-btn.iframe-modal-close:hover{background:#ef44444d;color:#ef4444}.iframe-modal-btn.iframe-modal-zoom-label{font-size:9px;font-weight:500;min-width:28px;padding:0 3px}.iframe-modal-content{flex:1;position:relative;overflow:hidden;background:#fff}.iframe-modal-frame{border:none;display:block}.iframe-modal-loading,.iframe-modal-error{position:absolute;top:0;left:0;right:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;background:#1a1a2e;color:#ffffffb3;font-size:13px;z-index:1}.iframe-modal-spinner{width:24px;height:24px;border:2px solid rgba(255,255,255,.2);border-top-color:#3b82f6;border-radius:50%;animation:iframe-modal-spin .8s linear infinite}@keyframes iframe-modal-spin{to{transform:rotate(360deg)}}.iframe-modal-error button{padding:6px 16px;background:#3b82f6;border:none;border-radius:4px;color:#fff;font-size:12px;cursor:pointer;transition:background .15s ease}.iframe-modal-error button:hover{background:#2563eb}.iframe-modal-resize-handle{position:absolute;z-index:10}.iframe-modal-resize-n,.iframe-modal-resize-s{left:12px;right:12px;height:8px;cursor:ns-resize}.iframe-modal-resize-n{top:-4px}.iframe-modal-resize-s{bottom:-4px}.iframe-modal-resize-e,.iframe-modal-resize-w{top:12px;bottom:12px;width:8px;cursor:ew-resize}.iframe-modal-resize-e{right:-4px}.iframe-modal-resize-w{left:-4px}.iframe-modal-resize-ne,.iframe-modal-resize-nw,.iframe-modal-resize-se,.iframe-modal-resize-sw{width:16px;height:16px}.iframe-modal-resize-ne{top:-4px;right:-4px;cursor:nesw-resize}.iframe-modal-resize-nw{top:-4px;left:-4px;cursor:nwse-resize}.iframe-modal-resize-se{bottom:-4px;right:-4px;cursor:nwse-resize}.iframe-modal-resize-sw{bottom:-4px;left:-4px;cursor:nesw-resize}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as ue,r as l,i as he,j as e,k as de}from"./main-ocVprcIe.js";function ge({isOpen:E,onClose:w,title:Q,icon:_,lines:c,isStreaming:P,onClear:q,emptyMessage:U,streamingIndicatorLabel:z,extraToolbar:J,extraFooter:X,modalClassName:Y}){const{t:a}=ue(["terminal","common"]),[u,$]=l.useState(""),[h,L]=l.useState(!1),[x,S]=l.useState(!1),[M,R]=l.useState(""),[k,p]=l.useState(!0),[D,Z]=l.useState(!0),[O,B]=l.useState(null),[r,ee]=l.useState([]),[m,j]=l.useState(0),[v,te]=l.useState(!1),[T,se]=l.useState(5),[F,C]=l.useState(null),[y,le]=l.useState(!0),o=l.useRef(null),I=l.useRef(null),A=l.useRef(null),H=l.useRef(!1),V=l.useRef(0),K=l.useMemo(()=>c.map(t=>t.text),[c]),b=l.useMemo(()=>{if(!u)return C(null),null;try{const t=v?u:u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=new RegExp(t,"gi");return C(null),s}catch(t){return C(t.message),null}},[u,v]),N=l.useMemo(()=>{if(!b)return[];const t=[];for(let s=0;s<K.length;s++)b.test(K[s])&&t.push(s),b.lastIndex=0;return t},[K,b]);l.useEffect(()=>{ee(N),m>=N.length&&j(Math.max(0,N.length-1))},[N]);const ne=l.useMemo(()=>{const t=c.map((i,f)=>({entry:i,originalIndex:f}));if(!u||!b||y)return t;if(N.length===0)return[];const s=new Set;for(const i of N){const f=Math.max(0,i-T),ie=Math.min(c.length-1,i+T);for(let G=f;G<=ie;G++)s.add(G)}const n=Array.from(s).sort((i,f)=>i-f),d=[];for(let i=0;i<n.length;i++){const f=n[i];i>0&&f-n[i-1]>1&&d.push({entry:{text:"",lineNumber:-1},originalIndex:-1,isSeparator:!0}),d.push({entry:c[f],originalIndex:f})}return d},[c,u,b,N,T,y]);l.useEffect(()=>{k&&o.current&&c.length>V.current&&(H.current=!0,requestAnimationFrame(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight),setTimeout(()=>{H.current=!1},50)})),V.current=c.length},[c.length,k]),l.useEffect(()=>{h&&I.current&&I.current.focus()},[h]),l.useEffect(()=>{x&&A.current&&A.current.focus()},[x]);const g=l.useCallback(t=>{if(!o.current)return;const n=t*18;o.current.scrollTop=n-100,B(t),setTimeout(()=>B(null),2e3)},[]);l.useEffect(()=>{if(!E)return;const t=s=>{if(s.key==="Escape"){s.preventDefault(),s.stopPropagation(),s.stopImmediatePropagation(),h?L(!1):x?S(!1):w();return}if(s.key==="/"&&!h&&!x&&(s.preventDefault(),L(!0)),s.key==="g"&&s.ctrlKey&&(s.preventDefault(),S(!0)),s.key==="End"&&s.ctrlKey&&o.current&&(o.current.scrollTop=o.current.scrollHeight),s.key==="Home"&&s.ctrlKey&&o.current&&(o.current.scrollTop=0),(s.key==="F3"||s.key==="Enter"&&h)&&r.length>0)if(s.preventDefault(),s.shiftKey){const n=(m-1+r.length)%r.length;j(n),g(r[n])}else{const n=(m+1)%r.length;j(n),g(r[n])}if(!h&&!x&&r.length>0){if(s.key==="n"&&!s.ctrlKey){s.preventDefault();const n=(m+1)%r.length;j(n),g(r[n])}else if(s.key==="N"){s.preventDefault();const n=(m-1+r.length)%r.length;j(n),g(r[n])}}!h&&!x&&o.current&&(s.key==="j"?(s.preventDefault(),o.current.scrollTop+=60,p(!1)):s.key==="k"?(s.preventDefault(),o.current.scrollTop-=60,p(!1)):s.key==="G"&&!s.ctrlKey?(s.preventDefault(),o.current.scrollTop=o.current.scrollHeight,p(!0)):s.key==="g"&&!s.ctrlKey&&(s.preventDefault(),o.current.scrollTop=0,p(!1)))};return window.addEventListener("keydown",t,{capture:!0}),()=>window.removeEventListener("keydown",t,{capture:!0})},[E,h,x,r,m,w,g]);const W=l.useCallback(()=>{const t=parseInt(M,10);!isNaN(t)&&t>0&&t<=c.length&&(g(t-1),p(!1)),S(!1),R("")},[M,c.length,g]),re=l.useCallback(()=>{if(H.current||!o.current)return;const{scrollTop:t,scrollHeight:s,clientHeight:n}=o.current,d=s-t-n<50;!d&&k&&p(!1),d&&!k&&p(!0)},[k]),ae=l.useCallback(t=>{if(!u||!b)return t;const s=v?u:u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");try{const n=new RegExp(`(${s})`,"gi");return t.replace(n,'<mark class="search-highlight">$1</mark>')}catch{return t}},[u,b,v]),{handleMouseDown:oe,handleClick:ce}=he(w);return E?e.jsx("div",{className:"pm2-logs-modal-overlay",onMouseDown:oe,onClick:ce,children:e.jsxs("div",{className:`pm2-logs-modal ${Y||""}`,children:[e.jsxs("div",{className:"pm2-logs-modal-header",children:[e.jsxs("div",{className:"header-left",children:[e.jsx("span",{className:"modal-icon",children:_}),e.jsx("span",{className:"modal-title",children:Q}),P&&e.jsxs("span",{className:"streaming-indicator",title:"Live streaming",children:[e.jsx("span",{className:"pulse"}),z||a("terminal:logs.live")]})]}),e.jsxs("div",{className:"header-right",children:[e.jsx("span",{className:"line-count",children:a("terminal:logs.lines",{count:c.length})}),e.jsx("button",{className:"modal-close",onClick:w,title:a("terminal:logs.closeEsc"),children:"×"})]})]}),e.jsxs("div",{className:"pm2-logs-modal-toolbar",children:[e.jsxs("div",{className:"toolbar-left",children:[e.jsxs("button",{className:`toolbar-btn ${h?"active":""}`,onClick:()=>L(!h),title:a("terminal:logs.searchShortcut"),children:["🔍 ",a("terminal:logs.search")]}),e.jsxs("button",{className:"toolbar-btn",onClick:()=>S(!0),title:a("terminal:logs.goToLineShortcut"),children:["⏬ ",a("terminal:logs.goToLine")]}),J,e.jsxs("button",{className:`toolbar-btn ${D?"active":""}`,onClick:()=>Z(!D),title:a("terminal:logs.toggleWrap"),children:["↩ ",a("terminal:logs.wrap")]}),e.jsxs("button",{className:`toolbar-btn ${k?"active":""}`,onClick:()=>p(!k),title:a("terminal:logs.autoScrollToBottom"),children:["↓ ",a("terminal:logs.auto")]})]}),e.jsx("div",{className:"toolbar-right",children:e.jsxs("button",{className:"toolbar-btn danger",onClick:q,title:a("terminal:logs.clear"),children:["🗑 ",a("terminal:logs.clear")]})})]}),h&&e.jsxs("div",{className:"pm2-logs-search-bar",children:[e.jsx("input",{ref:I,type:"text",placeholder:a(v?"terminal:logs.regexPlaceholder":"terminal:logs.searchPlaceholder"),value:u,onChange:t=>{$(t.target.value),j(0)},onKeyDown:t=>{t.key==="Escape"&&(L(!1),$(""),C(null))}}),e.jsx("button",{className:`toolbar-btn small ${v?"active":""}`,onClick:()=>te(!v),title:"Toggle regex mode",children:".*"}),e.jsx("button",{className:`toolbar-btn small ${y?"active":""}`,onClick:()=>le(!y),title:y?"Show all lines (highlight matches)":"Show only context around matches",children:y?"All":"Ctx"}),e.jsxs("div",{className:`context-control ${y?"hidden":""}`,title:"Lines of context around matches",children:[e.jsx("label",{children:"±"}),e.jsx("input",{type:"number",min:"0",max:"100",value:T,onChange:t=>se(Math.max(0,parseInt(t.target.value)||0)),className:"context-input"})]}),e.jsx("button",{className:"toolbar-btn small",onClick:()=>{if(r.length===0)return;const t=(m-1+r.length)%r.length;j(t),g(r[t])},disabled:r.length===0,title:"Previous match (Shift+F3)",children:"▲"}),e.jsx("button",{className:"toolbar-btn small",onClick:()=>{if(r.length===0)return;const t=(m+1)%r.length;j(t),g(r[t])},disabled:r.length===0,title:"Next match (F3)",children:"▼"}),u&&e.jsx("span",{className:"match-count",children:F?e.jsx("span",{className:"regex-error",title:F,children:a("terminal:logs.invalidRegex")}):r.length>0?`${m+1}/${r.length}`:a("terminal:logs.noMatches")}),e.jsx("button",{className:"search-close",onClick:()=>{L(!1),$(""),C(null)},children:"×"})]}),x&&e.jsxs("div",{className:"pm2-logs-goto-line",children:[e.jsxs("label",{children:[a("terminal:logs.goToLineLabel"),":"]}),e.jsx("input",{ref:A,type:"number",min:"1",max:c.length,placeholder:`1-${c.length}`,value:M,onChange:t=>R(t.target.value),onKeyDown:t=>{t.key==="Enter"?W():t.key==="Escape"&&(S(!1),R(""))}}),e.jsx("button",{onClick:W,children:a("terminal:logs.go")}),e.jsx("button",{onClick:()=>S(!1),children:a("common:buttons.cancel")})]}),e.jsx("div",{ref:o,className:`pm2-logs-content ${D?"wrap":"nowrap"}`,onScroll:re,children:c.length===0?e.jsx("div",{className:"logs-empty",children:U||a(P?"terminal:logs.waitingForLogs":"terminal:logs.noLogs")}):e.jsx("div",{className:"logs-lines",children:ne.map((t,s)=>{if("isSeparator"in t&&t.isSeparator)return e.jsxs("div",{className:"log-separator",children:[e.jsx("span",{className:"separator-line"}),e.jsx("span",{className:"separator-label",children:"…"}),e.jsx("span",{className:"separator-line"})]},`sep-${s}`);const{entry:n,originalIndex:d}=t,i=u&&N.includes(d);return e.jsxs("div",{className:`log-line ${O===d?"highlighted":""} ${r[m]===d?"current-match":""} ${i?"match-line":""} ${n.isError?"error-line":""}`,children:[e.jsx("span",{className:"line-number",children:n.lineNumber}),n.sourceLabel&&e.jsxs("span",{className:"boss-log-source",style:{color:n.sourceColor},children:["[",n.sourceLabel,"]"]}),e.jsx("span",{className:"line-content",dangerouslySetInnerHTML:{__html:ae(de(n.text))}})]},d)})})}),e.jsxs("div",{className:"pm2-logs-modal-footer",children:[e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"j"}),"/",e.jsx("kbd",{children:"k"})," Scroll"]}),e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"g"}),"/",e.jsx("kbd",{children:"G"})," Top/Bottom"]}),e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"/"})," Search"]}),e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"n"}),"/",e.jsx("kbd",{children:"N"})," Next/Prev match"]}),e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"Ctrl+G"})," Go to line"]}),e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"Esc"})," Close"]}),X]})]})}):null}export{ge as L};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{u as f,h as d,r as m,s as o,j as x}from"./main-ocVprcIe.js";import{L as S}from"./LogViewerModal-BilRZ0Fi.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react-uS-d4TUT.js";import"./vendor-three-PBVcEoyM.js";function B({building:t,isOpen:e,onClose:n}){var a;const{t:i}=f(["terminal"]),{streamingBuildingLogs:p,streamingBuildingIds:c}=d(),r=p.get(t.id)||"",g=c.has(t.id);m.useEffect(()=>{var s;return e&&((s=t.pm2)!=null&&s.enabled)&&o.startLogStreaming(t.id,200),()=>{t.id&&o.stopLogStreaming(t.id)}},[e,t.id,(a=t.pm2)==null?void 0:a.enabled]);const l=m.useMemo(()=>r.split(`
|
|
2
|
+
`).map((s,L)=>({text:s,lineNumber:L+1})),[r]);return x.jsx(S,{isOpen:e,onClose:n,title:`${t.name} - ${i("terminal:logs.pm2Logs")}`,icon:"📄",lines:l,isStreaming:g,onClear:()=>o.clearStreamingLogs(t.id)})}export{B as PM2LogsModal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as m,B as f,j as e,s as d}from"./main-ocVprcIe.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react-uS-d4TUT.js";import"./vendor-three-PBVcEoyM.js";function N(r){const t=Date.now()-r,i=Math.floor(t/1e3),a=Math.floor(i/60),c=Math.floor(a/60),n=Math.floor(c/24);return n>0?`${n} day${n>1?"s":""} ago`:c>0?`${c} hour${c>1?"s":""} ago`:a>0?`${a} min${a>1?"s":""} ago`:"just now"}function k({isOpen:r,restorePosition:l,onClose:t,onRestored:i}){const{t:a}=m(["terminal","common"]),c=f(),n=Array.from(c.values()).filter(s=>s.archived===!0),o=(s,j)=>{const x=j?void 0:l||void 0;d.restoreArchivedArea(s,x),i==null||i(),t()},h=()=>{for(const s of n)d.restoreArchivedArea(s.id);i==null||i(),t()},v=s=>{s.target===s.currentTarget&&t()},u=s=>{s.key==="Escape"&&t()};return r?e.jsx("div",{className:`modal-overlay ${r?"visible":""}`,onClick:v,onKeyDown:u,children:e.jsxs("div",{className:"modal restore-archived-modal",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("span",{className:"header-icon",children:"📦"}),a("terminal:areas.restoreArchivedZone")]}),e.jsx("div",{className:"modal-body restore-archived-body",children:n.length===0?e.jsx("div",{className:"archived-empty",children:a("terminal:areas.noArchivedZones")}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"restore-info",children:a("terminal:areas.restoreInfo")}),e.jsx("div",{className:"archived-list",children:n.map(s=>e.jsx(g,{area:s,onRestoreHere:()=>o(s.id,!1),onRestoreOriginal:()=>o(s.id,!0),hasRestorePosition:!!l},s.id))}),n.length>1&&e.jsx("div",{className:"restore-all-section",children:e.jsx("button",{className:"btn btn-secondary",onClick:h,children:a("terminal:areas.restoreAllOriginal")})})]})}),e.jsx("div",{className:"modal-footer",children:e.jsx("button",{className:"btn btn-secondary",onClick:t,children:a("common:buttons.cancel")})})]})}):null}function g({area:r,onRestoreHere:l,onRestoreOriginal:t,hasRestorePosition:i}){const{t:a}=m(["terminal","common"]),c=r.assignedAgentIds.length,n=r.directories.length;return e.jsxs("div",{className:"archived-item",children:[e.jsx("div",{className:"archived-item-color",style:{backgroundColor:r.color}}),e.jsxs("div",{className:"archived-item-info",children:[e.jsx("div",{className:"archived-item-name",children:r.name}),e.jsxs("div",{className:"archived-item-meta",children:[e.jsx("span",{className:"archived-item-type",children:r.type}),c>0&&e.jsx("span",{className:"archived-item-agents",children:a("terminal:areas.agentCount",{count:c})}),n>0&&e.jsx("span",{className:"archived-item-dirs",children:a("terminal:areas.folderCount",{count:n})}),r.archivedAt&&e.jsx("span",{className:"archived-item-time",children:N(r.archivedAt)})]})]}),e.jsxs("div",{className:"archived-item-actions",children:[i&&e.jsx("button",{className:"btn btn-small btn-primary",onClick:l,title:a("terminal:areas.placeAtClickedPosition"),children:a("terminal:areas.restoreHere")}),e.jsx("button",{className:"btn btn-small",onClick:t,title:a("terminal:areas.restoreToOriginal"),children:a(i?"terminal:areas.original":"terminal:areas.restore")})]})]})}export{k as RestoreArchivedAreaModal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as D,r as h,j as s}from"./main-ocVprcIe.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react-uS-d4TUT.js";import"./vendor-three-PBVcEoyM.js";function B({isOpen:t,onClose:n,agent:d,outputCount:b,trackedFiles:p,onSave:g,isSaving:l=!1,error:x}){const{t:a}=D(["terminal","common"]),m=h.useCallback(()=>{const z=new Date().toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return`${d.name} - ${z}`},[d.name]),[r,u]=h.useState(m()),[j,N]=h.useState("");h.useEffect(()=>{t&&(u(m()),N(""))},[t,m]);const y=async e=>{e.preventDefault(),r.trim()&&await g({agentId:d.id,title:r.trim(),description:j.trim()||void 0})},w=e=>{e.key==="Escape"&&n()};if(!t)return null;const i=(p==null?void 0:p.files)||[],o=i.filter(e=>e.type==="created"),c=i.filter(e=>e.type==="modified");return s.jsx("div",{className:"modal-overlay visible",onClick:n,onKeyDown:w,children:s.jsxs("div",{className:"modal snapshot-modal",onClick:e=>e.stopPropagation(),children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("span",{className:"snapshot-modal-icon",children:"⭐"}),a("terminal:snapshot.save")]}),s.jsxs("form",{onSubmit:y,children:[s.jsxs("div",{className:"modal-body",children:[s.jsxs("div",{className:"snapshot-field",children:[s.jsxs("label",{className:"snapshot-label",children:[a("common:labels.title")," ",s.jsx("span",{className:"snapshot-required",children:"*"})]}),s.jsx("input",{type:"text",className:"snapshot-input",value:r,onChange:e=>u(e.target.value),placeholder:a("terminal:snapshot.enterTitle"),autoFocus:!0,disabled:l})]}),s.jsxs("div",{className:"snapshot-field",children:[s.jsxs("label",{className:"snapshot-label",children:[a("common:labels.description")," ",s.jsx("span",{className:"snapshot-optional",children:a("common:labels.optional")})]}),s.jsx("textarea",{className:"snapshot-textarea",value:j,onChange:e=>N(e.target.value),placeholder:a("terminal:snapshot.whatWasAccomplished"),rows:3,disabled:l})]}),s.jsxs("div",{className:"snapshot-preview",children:[s.jsx("div",{className:"snapshot-preview-header",children:a("terminal:snapshot.whatWillBeCaptured")}),s.jsxs("div",{className:"snapshot-preview-stats",children:[s.jsxs("div",{className:"snapshot-stat",children:[s.jsx("span",{className:"snapshot-stat-icon",children:"💬"}),s.jsx("span",{className:"snapshot-stat-value",children:b}),s.jsx("span",{className:"snapshot-stat-label",children:a("terminal:snapshot.messages")})]}),s.jsxs("div",{className:"snapshot-stat",children:[s.jsx("span",{className:"snapshot-stat-icon",children:"📄"}),s.jsx("span",{className:"snapshot-stat-value",children:i.length}),s.jsx("span",{className:"snapshot-stat-label",children:a("terminal:snapshot.files")})]})]}),i.length>0&&s.jsxs("div",{className:"snapshot-files-preview",children:[o.length>0&&s.jsxs("div",{className:"snapshot-file-group",children:[s.jsxs("div",{className:"snapshot-file-group-label",children:[s.jsx("span",{className:"snapshot-file-type created",children:"+"}),a("terminal:snapshot.createdFiles",{count:o.length})]}),s.jsxs("div",{className:"snapshot-file-list",children:[o.slice(0,5).map(e=>s.jsxs("div",{className:"snapshot-file-item",children:[s.jsx("span",{className:"snapshot-file-path",title:e.path,children:v(e.path)}),e.size!==void 0&&s.jsx("span",{className:"snapshot-file-size",children:f(e.size)})]},e.path)),o.length>5&&s.jsx("div",{className:"snapshot-file-more",children:a("terminal:snapshot.more",{count:o.length-5})})]})]}),c.length>0&&s.jsxs("div",{className:"snapshot-file-group",children:[s.jsxs("div",{className:"snapshot-file-group-label",children:[s.jsx("span",{className:"snapshot-file-type modified",children:"~"}),a("terminal:snapshot.modifiedFiles",{count:c.length})]}),s.jsxs("div",{className:"snapshot-file-list",children:[c.slice(0,5).map(e=>s.jsxs("div",{className:"snapshot-file-item",children:[s.jsx("span",{className:"snapshot-file-path",title:e.path,children:v(e.path)}),e.size!==void 0&&s.jsx("span",{className:"snapshot-file-size",children:f(e.size)})]},e.path)),c.length>5&&s.jsx("div",{className:"snapshot-file-more",children:a("terminal:snapshot.more",{count:c.length-5})})]})]})]}),i.length===0&&s.jsx("div",{className:"snapshot-no-files",children:a("terminal:snapshot.noFilesChanged")})]}),x&&s.jsx("div",{className:"snapshot-error",children:x})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{type:"button",className:"btn btn-secondary",onClick:n,disabled:l,children:a("common:buttons.cancel")}),s.jsx("button",{type:"submit",className:"btn btn-primary",disabled:!r.trim()||l,children:l?a("terminal:snapshot.saving"):`⭐ ${a("terminal:snapshot.save")}`})]})]})]})})}function v(t){const n=t.split("/");return n[n.length-1]||t}function f(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}export{B as SaveSnapshotModal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.scene-2d-container{position:relative;width:100%;height:100%;overflow:hidden;background:#0a0c12;z-index:1}.scene-2d-container .scene-2d-canvas{display:block;width:100%;height:100%;cursor:default;background:transparent}.scene-2d-container .scene-2d-canvas.panning{cursor:grabbing}.scene-2d-container .scene-2d-canvas.selecting{cursor:crosshair}.scene-2d-container .scene-2d-badge{position:absolute;bottom:12px;left:12px;background:linear-gradient(135deg,#1a1f2ef2,#141820fa);color:#6a9aff;padding:6px 12px;border-radius:6px;font-size:11px;font-weight:600;letter-spacing:.5px;pointer-events:none;border:1px solid rgba(74,158,255,.25);box-shadow:0 2px 8px #0000004d,inset 0 1px #ffffff0d;text-transform:uppercase}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var Yt=Object.defineProperty;var $t=(k,t,s)=>t in k?Yt(k,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):k[t]=s;var u=(k,t,s)=>$t(k,typeof t!="symbol"?t+"":t,s);import{s as z,A as xt,l as bt,T as vt,m as _,n as Vt,S as _t,o as Nt,p as Ut,q as jt,F as nt,r as L,j as pt}from"./main-ocVprcIe.js";import{l as qt,s as Ct}from"./camera-BWSm1gAv.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react-uS-d4TUT.js";import"./vendor-three-PBVcEoyM.js";const ht=new Map,Kt=512,N=new Map,yt=256;class at{constructor(t,s){u(this,"ctx");u(this,"camera");u(this,"animationTime",0);this.ctx=t,this.camera=s}setAnimationTime(t){this.animationTime=t}roundedRect(t,s,e,i,o){this.ctx.moveTo(t+o,s),this.ctx.lineTo(t+e-o,s),this.ctx.arcTo(t+e,s,t+e,s+o,o),this.ctx.lineTo(t+e,s+i-o),this.ctx.arcTo(t+e,s+i,t+e-o,s+i,o),this.ctx.lineTo(t+o,s+i),this.ctx.arcTo(t,s+i,t,s+i-o,o),this.ctx.lineTo(t,s+o),this.ctx.arcTo(t,s,t+o,s,o)}roundedRectScreen(t,s,e,i,o){this.ctx.moveTo(t+o,s),this.ctx.lineTo(t+e-o,s),this.ctx.arcTo(t+e,s,t+e,s+o,o),this.ctx.lineTo(t+e,s+i-o),this.ctx.arcTo(t+e,s+i,t+e-o,s+i,o),this.ctx.lineTo(t+o,s+i),this.ctx.arcTo(t,s+i,t,s+i-o,o),this.ctx.lineTo(t,s+o),this.ctx.arcTo(t,s,t+o,s,o)}numberToHex(t){return`#${t.toString(16).padStart(6,"0")}`}hexToRgba(t,s){const e=Math.round(s*100)/100,i=`${t}|${e}`;let o=ht.get(i);if(o)return o;const n=parseInt(t.slice(1,3),16),l=parseInt(t.slice(3,5),16),a=parseInt(t.slice(5,7),16);return o=`rgba(${n}, ${l}, ${a}, ${e})`,ht.size>=Kt&&ht.clear(),ht.set(i,o),o}lightenColor(t,s){const e=`L|${t}|${s}`;let i=N.get(e);if(i)return i;const o=parseInt(t.slice(1,3),16),n=parseInt(t.slice(3,5),16),l=parseInt(t.slice(5,7),16),a=Math.min(255,Math.floor(o+(255-o)*s)),r=Math.min(255,Math.floor(n+(255-n)*s)),d=Math.min(255,Math.floor(l+(255-l)*s));return i=`#${a.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${d.toString(16).padStart(2,"0")}`,N.size>=yt&&N.clear(),N.set(e,i),i}darkenColor(t,s){const e=`D|${t}|${s}`;let i=N.get(e);if(i)return i;const o=parseInt(t.slice(1,3),16),n=parseInt(t.slice(3,5),16),l=parseInt(t.slice(5,7),16),a=Math.max(0,Math.floor(o*(1-s))),r=Math.max(0,Math.floor(n*(1-s))),d=Math.max(0,Math.floor(l*(1-s)));return i=`#${a.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${d.toString(16).padStart(2,"0")}`,N.size>=yt&&N.clear(),N.set(e,i),i}formatIdleTime(t){return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h`}easeOutCubic(t){return 1-Math.pow(1-t,3)}easeInCubic(t){return t*t*t}}const Jt=200;class Qt extends at{constructor(s,e){super(s,e);u(this,"toolAnimations",new Map)}update(s){this.animationTime+=s,this.updateToolAnimations()}getAnimationTime(){return this.animationTime}updateToolAnimations(){const s=performance.now(),e=[];for(const[i,o]of this.toolAnimations){const n=s-o.startTime,l=Math.min(1,n/Jt);o.fadeIn?o.opacity=this.easeOutCubic(l):(o.opacity=1-this.easeInCubic(l),l>=1&&e.push(i))}for(const i of e)this.toolAnimations.delete(i)}updateAgentTool(s,e){const i=this.toolAnimations.get(s),o=performance.now();e?(!i||i.tool!==e||!i.fadeIn)&&this.toolAnimations.set(s,{tool:e,startTime:o,fadeIn:!0,opacity:(i==null?void 0:i.opacity)??0}):i&&i.fadeIn&&(i.fadeIn=!1,i.startTime=o)}getToolAnimation(s){return this.toolAnimations.get(s)}}class te extends at{constructor(s,e){super(s,e);u(this,"groundGradient",null);u(this,"groundViewportW",0);u(this,"groundViewportH",0)}drawGround(s){const{width:e,height:i}=this.camera.getViewportSize();if(!this.groundGradient||e!==this.groundViewportW||i!==this.groundViewportH){const o=e/2,n=i/2,l=Math.sqrt(o*o+n*n)*1.2;this.groundGradient=this.ctx.createRadialGradient(o,n,0,o,n,l),this.groundGradient.addColorStop(0,"#1a1f2e"),this.groundGradient.addColorStop(.5,"#141820"),this.groundGradient.addColorStop(1,"#0a0c12"),this.groundViewportW=e,this.groundViewportH=i}this.ctx.fillStyle=this.groundGradient,this.ctx.fillRect(0,0,e,i)}drawGrid(s,e){const i=this.camera.getVisibleBounds(),o=this.camera.getZoom();let n=e;o<20&&(n=e*2),o<12&&(n=e*4);const l=Math.floor(i.minX/n)*n,a=Math.ceil(i.maxX/n)*n,r=Math.floor(i.minZ/n)*n,d=Math.ceil(i.maxZ/n)*n;this.camera.applyTransform(this.ctx);const h=s*.4,m=h*.5,f=1/o;for(let c=l;c<=a;c+=n){const g=Math.abs(c);let p=this.calculateGridAlpha(g,m,h);const P=Math.abs(c)%(n*5)<.001;p*=P?.12:.05,p>.005&&(this.ctx.strokeStyle=`rgba(100, 140, 180, ${p})`,this.ctx.lineWidth=P?f*1.5:f,this.ctx.beginPath(),this.ctx.moveTo(c,i.minZ),this.ctx.lineTo(c,i.maxZ),this.ctx.stroke())}for(let c=r;c<=d;c+=n){const g=Math.abs(c);let p=this.calculateGridAlpha(g,m,h);const P=Math.abs(c)%(n*5)<.001;p*=P?.12:.05,p>.005&&(this.ctx.strokeStyle=`rgba(100, 140, 180, ${p})`,this.ctx.lineWidth=P?f*1.5:f,this.ctx.beginPath(),this.ctx.moveTo(i.minX,c),this.ctx.lineTo(i.maxX,c),this.ctx.stroke())}this.camera.restoreTransform(this.ctx),this.drawOriginMarker(),o>15&&this.drawCoordinateLabels(n,m,h)}calculateGridAlpha(s,e,i){if(s<=e)return 1;if(s>=i)return 0;const o=(s-e)/(i-e);return 1-o*o}drawOriginMarker(){const s=this.camera.worldToScreen(0,0),{x:e,y:i}=s,o=12,n=this.ctx.createRadialGradient(e,i,0,e,i,o*2);n.addColorStop(0,"rgba(74, 158, 255, 0.15)"),n.addColorStop(1,"rgba(74, 158, 255, 0)"),this.ctx.fillStyle=n,this.ctx.beginPath(),this.ctx.arc(e,i,o*2,0,Math.PI*2),this.ctx.fill();const l=20,a=6;this.ctx.strokeStyle="rgba(74, 158, 255, 0.4)",this.ctx.lineWidth=1,this.ctx.beginPath(),this.ctx.moveTo(e-l,i),this.ctx.lineTo(e-a,i),this.ctx.moveTo(e+a,i),this.ctx.lineTo(e+l,i),this.ctx.moveTo(e,i-l),this.ctx.lineTo(e,i-a),this.ctx.moveTo(e,i+a),this.ctx.lineTo(e,i+l),this.ctx.stroke(),this.ctx.strokeStyle="rgba(74, 158, 255, 0.5)",this.ctx.lineWidth=1.5,this.ctx.beginPath(),this.ctx.arc(e,i,o,0,Math.PI*2),this.ctx.stroke(),this.ctx.fillStyle="rgba(74, 158, 255, 0.8)",this.ctx.beginPath(),this.ctx.arc(e,i,2,0,Math.PI*2),this.ctx.fill();const r=3;this.ctx.strokeStyle="rgba(74, 158, 255, 0.6)",this.ctx.lineWidth=1,this.ctx.beginPath(),this.ctx.moveTo(e,i-o),this.ctx.lineTo(e,i-o+r),this.ctx.moveTo(e,i+o),this.ctx.lineTo(e,i+o-r),this.ctx.moveTo(e-o,i),this.ctx.lineTo(e-o+r,i),this.ctx.moveTo(e+o,i),this.ctx.lineTo(e+o-r,i),this.ctx.stroke()}drawCoordinateLabels(s,e,i){const o=this.camera.getVisibleBounds(),n=s*5,l=Math.floor(o.minX/n)*n,a=Math.ceil(o.maxX/n)*n,r=Math.floor(o.minZ/n)*n,d=Math.ceil(o.maxZ/n)*n;this.ctx.font='10px "SF Mono", "Monaco", "Consolas", monospace',this.ctx.textBaseline="middle";for(let h=l;h<=a;h+=n){if(Math.abs(h)<.001)continue;const m=Math.abs(h),f=this.calculateGridAlpha(m,e,i)*.4;if(f>.02){const c=this.camera.worldToScreen(h,0);this.ctx.fillStyle=`rgba(100, 140, 180, ${f})`,this.ctx.textAlign="center",this.ctx.fillText(h.toString(),c.x,c.y+16)}}for(let h=r;h<=d;h+=n){if(Math.abs(h)<.001)continue;const m=Math.abs(h),f=this.calculateGridAlpha(m,e,i)*.4;if(f>.02){const c=this.camera.worldToScreen(0,h);this.ctx.fillStyle=`rgba(100, 140, 180, ${f})`,this.ctx.textAlign="left",this.ctx.fillText(h.toString(),c.x+16,c.y)}}}}class ee extends at{constructor(s,e){super(s,e);u(this,"logoImages",new Map);u(this,"loadingLogos",new Set)}drawArea(s,e=!1){this.camera.applyTransform(this.ctx);const{x:i,z:o}=s.position,n=s.color||"#4a9eff",l=this.camera.getZoom();if(s.type==="rectangle"&&"width"in s.size){const{width:a,height:r}=s.size,d=i-a/2,h=o-r/2;if(this.drawRectangleArea(d,h,a,r,n,l,e),s.label&&this.drawAreaLabel(s.label,i,h,n,l,"top"),s.logo&&this.drawAreaLogo(s,i,o,a,r),s.hasDirectories){const c=Math.max(1,Math.floor((a-.6)/.675)),g=d+.5*.8,p=h+.5*.8;s.directories.forEach((P,w)=>{var A;const b=Math.floor(w/c),S=w%c,x=((A=s.directoryGitCounts)==null?void 0:A[w])??0;this.drawFolderIcon(g+S*.675,p+b*.675,.5,n,l,x)})}e&&this.drawRectangleResizeHandles(i,o,a,r,n,l)}else if(s.type==="circle"&&"radius"in s.size){const{radius:a}=s.size;if(this.drawCircleArea(i,o,a,n,l,e),s.label&&this.drawAreaLabel(s.label,i,o-a,n,l,"top"),s.logo){const r=a*1.414,d=a*1.414;this.drawAreaLogo(s,i,o,r,d)}if(s.hasDirectories){const d=a*.707,h=.5*1.35,m=Math.max(1,Math.floor((a*1.414-.5)/h)),f=i-d+.5*.5,c=o-d+.5*.5;s.directories.forEach((g,p)=>{var S;const P=Math.floor(p/m),w=p%m,b=((S=s.directoryGitCounts)==null?void 0:S[p])??0;this.drawFolderIcon(f+w*h,c+P*h,.5,n,l,b)})}e&&this.drawCircleResizeHandles(i,o,a,n,l)}this.camera.restoreTransform(this.ctx)}drawRectangleArea(s,e,i,o,n,l,a=!1){const r=this.ctx,d=Math.min(i,o)*.08;a&&(r.strokeStyle=this.hexToRgba(n,.5*.8),r.lineWidth=4/l,r.beginPath(),r.rect(s-2/l,e-2/l,i+4/l,o+4/l),r.stroke());const h=a?.25:.15,m=r.createLinearGradient(s,e,s+i,e+o);m.addColorStop(0,this.hexToRgba(n,h)),m.addColorStop(.5,this.hexToRgba(n,h*.5)),m.addColorStop(1,this.hexToRgba(n,h*1.3)),r.fillStyle=m,r.beginPath(),r.rect(s,e,i,o),r.fill();const f=r.createLinearGradient(s,e,s+i,e);f.addColorStop(0,"transparent"),f.addColorStop(.2,this.hexToRgba(n,.3)),f.addColorStop(.8,this.hexToRgba(n,.3)),f.addColorStop(1,"transparent"),r.strokeStyle=f,r.lineWidth=2/l,r.beginPath(),r.moveTo(s+d,e+2/l),r.lineTo(s+i-d,e+2/l),r.stroke();const c=r.createLinearGradient(s,e+o,s+i,e+o);c.addColorStop(0,"transparent"),c.addColorStop(.2,this.hexToRgba(this.darkenColor(n,.5),.4)),c.addColorStop(.8,this.hexToRgba(this.darkenColor(n,.5),.4)),c.addColorStop(1,"transparent"),r.strokeStyle=c,r.lineWidth=2/l,r.beginPath(),r.moveTo(s+d,e+o-2/l),r.lineTo(s+i-d,e+o-2/l),r.stroke(),r.strokeStyle=this.hexToRgba(n,.7),r.lineWidth=2/l,r.setLineDash([8/l,4/l]),r.lineDashOffset=0,r.beginPath(),r.rect(s,e,i,o),r.stroke(),r.setLineDash([]),r.strokeStyle=this.hexToRgba(n,.9),r.lineWidth=3/l,r.lineCap="round",this.drawCornerMark(s,e,d,"top-left"),this.drawCornerMark(s+i,e,d,"top-right"),this.drawCornerMark(s,e+o,d,"bottom-left"),this.drawCornerMark(s+i,e+o,d,"bottom-right"),r.fillStyle=n;const g=3/l,p=[{x:s,y:e},{x:s+i,y:e},{x:s,y:e+o},{x:s+i,y:e+o}];for(const P of p)r.beginPath(),r.arc(P.x,P.y,g,0,Math.PI*2),r.fill()}drawCornerMark(s,e,i,o){const n=this.ctx;switch(n.beginPath(),o){case"top-left":n.moveTo(s,e+i),n.lineTo(s,e),n.lineTo(s+i,e);break;case"top-right":n.moveTo(s-i,e),n.lineTo(s,e),n.lineTo(s,e+i);break;case"bottom-left":n.moveTo(s,e-i),n.lineTo(s,e),n.lineTo(s+i,e);break;case"bottom-right":n.moveTo(s-i,e),n.lineTo(s,e),n.lineTo(s,e-i);break}n.stroke()}drawCircleArea(s,e,i,o,n,l=!1){const a=this.ctx;l&&(a.strokeStyle=this.hexToRgba(o,.5*.8),a.lineWidth=4/n,a.beginPath(),a.arc(s,e,i+3/n,0,Math.PI*2),a.stroke());const r=l?.3:.2,d=a.createRadialGradient(s,e-i*.3,0,s,e,i);d.addColorStop(0,this.hexToRgba(o,r)),d.addColorStop(.6,this.hexToRgba(o,r*.5)),d.addColorStop(1,this.hexToRgba(o,r*.9)),a.fillStyle=d,a.beginPath(),a.arc(s,e,i,0,Math.PI*2),a.fill();const h=a.createLinearGradient(s-i*.7,e-i,s+i*.7,e-i);h.addColorStop(0,"transparent"),h.addColorStop(.3,this.hexToRgba(o,.4)),h.addColorStop(.7,this.hexToRgba(o,.4)),h.addColorStop(1,"transparent"),a.strokeStyle=h,a.lineWidth=2/n,a.beginPath(),a.arc(s,e,i-2/n,-Math.PI*.8,-Math.PI*.2),a.stroke(),a.strokeStyle=this.hexToRgba(o,.7),a.lineWidth=2/n,a.setLineDash([8/n,4/n]),a.lineDashOffset=0,a.beginPath(),a.arc(s,e,i,0,Math.PI*2),a.stroke(),a.setLineDash([]);const m=8,f=3/n;a.fillStyle=o;for(let g=0;g<m;g++){const p=g/m*Math.PI*2-Math.PI/2,P=s+Math.cos(p)*i,w=e+Math.sin(p)*i;a.beginPath(),a.arc(P,w,f,0,Math.PI*2),a.fill()}const c=4.5/n;for(let g=0;g<4;g++){const p=g/4*Math.PI*2-Math.PI/2,P=s+Math.cos(p)*i,w=e+Math.sin(p)*i;a.beginPath(),a.arc(P,w,c,0,Math.PI*2),a.fill()}}drawAreaLabel(s,e,i,o,n,l){const a=this.ctx,r=11/n,d=6/n,h=l==="top"?-8/n:0;a.font=`bold ${r}px "Segoe UI", Arial, sans-serif`;const f=a.measureText(s).width,c=r,g=f+d*2,p=c+d,P=e-g/2,w=i+h-p/2,b=4/n,S=a.createLinearGradient(P,w,P,w+p);S.addColorStop(0,this.hexToRgba(this.darkenColor(o,.7),.9)),S.addColorStop(1,this.hexToRgba(this.darkenColor(o,.5),.9)),a.fillStyle=S,a.beginPath(),this.roundedRect(P,w,g,p,b),a.fill(),a.strokeStyle=this.hexToRgba(o,.8),a.lineWidth=1.5/n,a.beginPath(),this.roundedRect(P,w,g,p,b),a.stroke(),a.fillStyle=this.lightenColor(o,.3),a.textAlign="center",a.textBaseline="middle",a.fillText(s,e,i+h)}drawRectangleResizeHandles(s,e,i,o,n,l){const d=[{x:s-i/2,z:e-o/2},{x:s+i/2,z:e-o/2},{x:s-i/2,z:e+o/2},{x:s+i/2,z:e+o/2}];for(const m of d)this.drawResizeHandle(m.x,m.z,.25,"#ffffff",l,.9);const h=[{x:s,z:e-o/2},{x:s,z:e+o/2},{x:s+i/2,z:e},{x:s-i/2,z:e}];for(const m of h)this.drawResizeHandle(m.x,m.z,.25*.8,"#aaddff",l,.9);this.drawResizeHandle(s,e,.25*1.2,"#ffcc00",l,.9,!0)}drawCircleResizeHandles(s,e,i,o,n){this.drawResizeHandle(s+i,e,.25,"#ffffff",n,.9),this.drawResizeHandle(s,e,.25*1.2,"#ffcc00",n,.9,!0)}drawResizeHandle(s,e,i,o,n,l,a=!1){const r=this.ctx;r.save(),r.fillStyle="rgba(0, 0, 0, 0.5)",r.beginPath(),r.arc(s,e,i*1.3,0,Math.PI*2),r.fill();const d=r.createRadialGradient(s-i*.3,e-i*.3,0,s,e,i);if(d.addColorStop(0,this.lightenColor(o,.3)),d.addColorStop(.5,o),d.addColorStop(1,this.darkenColor(o,.2)),r.fillStyle=d,r.globalAlpha=l,r.beginPath(),r.arc(s,e,i,0,Math.PI*2),r.fill(),r.globalAlpha=1,r.strokeStyle="rgba(255, 255, 255, 0.8)",r.lineWidth=1.5/n,r.beginPath(),r.arc(s,e,i,0,Math.PI*2),r.stroke(),a){const h=i*.5;r.strokeStyle="rgba(0, 0, 0, 0.7)",r.lineWidth=2/n,r.lineCap="round",r.beginPath(),r.moveTo(s-h,e),r.lineTo(s+h,e),r.moveTo(s,e-h),r.lineTo(s,e+h),r.stroke()}r.restore()}drawFolderIcon(s,e,i,o,n,l=0){const a=this.ctx,r=i*.45;a.save(),a.fillStyle=this.hexToRgba(this.darkenColor(o,.6),.85),a.beginPath(),a.arc(s,e,r*1.1,0,Math.PI*2),a.fill(),a.strokeStyle=this.hexToRgba(o,.8),a.lineWidth=1.5/n,a.beginPath(),a.arc(s,e,r*1.1,0,Math.PI*2),a.stroke();const d=r*1.2,h=r*.9,m=d*.35,f=h*.2,c=h*.08,g=s-d/2,p=e-h/2;if(a.fillStyle=o,a.beginPath(),a.moveTo(g+c,p+f),a.lineTo(g+m,p+f),a.lineTo(g+m+f*.6,p),a.lineTo(g+m+m*.4,p),a.lineTo(g+c,p),a.arcTo(g,p,g,p+c,c),a.lineTo(g,p+h-c),a.arcTo(g,p+h,g+c,p+h,c),a.lineTo(g+d-c,p+h),a.arcTo(g+d,p+h,g+d,p+h-c,c),a.lineTo(g+d,p+f+c),a.arcTo(g+d,p+f,g+d-c,p+f,c),a.closePath(),a.fill(),a.strokeStyle=this.hexToRgba(this.lightenColor(o,.3),.6),a.lineWidth=1/n,a.beginPath(),a.moveTo(g+c,p+f+h*.08),a.lineTo(g+d-c,p+f+h*.08),a.stroke(),l>0){const P=r*.4,w=s+r*.7,b=e+r*.7;a.fillStyle="#e8943a",a.beginPath(),a.arc(w,b,P,0,Math.PI*2),a.fill(),a.strokeStyle="rgba(0, 0, 0, 0.6)",a.lineWidth=1.5/n,a.beginPath(),a.arc(w,b,P,0,Math.PI*2),a.stroke();const S=l>99?"99+":String(l),x=P*1.2;a.font=`bold ${x}px "Segoe UI", Arial, sans-serif`,a.fillStyle="#ffffff",a.textAlign="center",a.textBaseline="middle",a.fillText(S,w,b)}a.restore()}getLogoImage(s){const e=this.logoImages.get(s);if(e)return e;if(!this.loadingLogos.has(s)){this.loadingLogos.add(s);const i=new Image;i.crossOrigin="anonymous",i.onload=()=>{this.logoImages.set(s,i),this.loadingLogos.delete(s)},i.onerror=()=>{this.loadingLogos.delete(s)},i.src=s}return null}drawAreaLogo(s,e,i,o,n){const l=s.logo,a=this.getLogoImage(l.url);if(!a)return;const{position:r,width:d,height:h,opacity:m}=l,f=this.calculateLogoOffset(r,d,h,o,n),c=e+f.x-d/2,g=i+f.z-h/2,p=this.ctx;p.save(),p.globalAlpha=m,p.drawImage(a,c,g,d,h),p.restore()}calculateLogoOffset(s,e,i,o,n){if(s==="center")return{x:0,z:0};const l=e/2+.2,a=i/2+.2;switch(s){case"top-left":return{x:-o/2+l,z:-n/2+a};case"top-right":return{x:o/2-l,z:-n/2+a};case"bottom-left":return{x:-o/2+l,z:n/2-a};case"bottom-right":return{x:o/2-l,z:n/2-a};default:return{x:0,z:0}}}drawAreaPreview(s,e,i){const o=this.camera.getZoom(),n=this.ctx,l="#4a9eff";if(this.camera.applyTransform(n),i==="rectangle"){const a=Math.min(s.x,e.x),r=Math.max(s.x,e.x),d=Math.min(s.z,e.z),h=Math.max(s.z,e.z),m=r-a,f=h-d;if(m<.1&&f<.1){this.camera.restoreTransform(n);return}n.fillStyle="rgba(74, 158, 255, 0.2)",n.fillRect(a,d,m,f),n.setLineDash([6/o,4/o]),n.lineDashOffset=0,n.strokeStyle=l,n.lineWidth=2/o,n.strokeRect(a,d,m,f),n.setLineDash([])}else if(i==="circle"){const a=e.x-s.x,r=e.z-s.z,d=Math.sqrt(a*a+r*r);if(d<.1){this.camera.restoreTransform(n);return}n.fillStyle="rgba(74, 158, 255, 0.2)",n.beginPath(),n.arc(s.x,s.z,d,0,Math.PI*2),n.fill(),n.setLineDash([6/o,4/o]),n.lineDashOffset=0,n.strokeStyle=l,n.lineWidth=2/o,n.beginPath(),n.arc(s.x,s.z,d,0,Math.PI*2),n.stroke(),n.setLineDash([])}this.camera.restoreTransform(n)}}const It={idle:{color:"#4aff9e",glow:"rgba(74, 255, 158, 0.6)",darkColor:"#2a9a5e"},working:{color:"#4a9eff",glow:"rgba(74, 158, 255, 0.6)",darkColor:"#2a5e9a"},waiting:{color:"#ffcc00",glow:"rgba(255, 204, 0, 0.6)",darkColor:"#9a7a00"},waiting_permission:{color:"#ffcc00",glow:"rgba(255, 204, 0, 0.6)",darkColor:"#9a7a00"},orphaned:{color:"#ff00ff",glow:"rgba(255, 0, 255, 0.6)",darkColor:"#9a009a"},running:{color:"#4aff9e",glow:"rgba(74, 255, 158, 0.6)",darkColor:"#2a9a5e"},stopped:{color:"#8a8a8a",glow:"rgba(138, 138, 138, 0.6)",darkColor:"#5a5a5a"},starting:{color:"#4a9eff",glow:"rgba(74, 158, 255, 0.6)",darkColor:"#2a5e9a"},stopping:{color:"#ffaa00",glow:"rgba(255, 170, 0, 0.6)",darkColor:"#9a6a00"},unknown:{color:"#ffaa00",glow:"rgba(255, 170, 0, 0.6)",darkColor:"#9a6a00"},error:{color:"#ff4a4a",glow:"rgba(255, 74, 74, 0.6)",darkColor:"#9a2a2a"}},kt={"server-rack":{color:"#5a7a9a",darkColor:"#3a5a7a",emoji:"🖥️"},desktop:{color:"#7a9a7a",darkColor:"#5a7a5a",emoji:"💻"},"filing-cabinet":{color:"#9a8a6a",darkColor:"#7a6a4a",emoji:"🗄️"},factory:{color:"#9a6a6a",darkColor:"#7a4a4a",emoji:"🏭"},satellite:{color:"#6a6a9a",darkColor:"#4a4a7a",emoji:"📡"},crystal:{color:"#9a6a9a",darkColor:"#7a4a7a",emoji:"💎"},tower:{color:"#6a9a9a",darkColor:"#4a7a7a",emoji:"🗼"},dome:{color:"#7a7a9a",darkColor:"#5a5a7a",emoji:"🔮"},pyramid:{color:"#9a9a6a",darkColor:"#7a7a4a",emoji:"🔺"},"command-center":{color:"#ba9a5a",darkColor:"#9a7a3a",emoji:"🏛️"}};class se extends at{constructor(t,s){super(t,s)}drawBuilding(t,s,e=!1){const{x:i,z:o}=t.position,n=1.8*t.scale,l=kt[t.style]||kt["server-rack"],a=It[t.status]||It.stopped;let r=l.color,d=l.darkColor;t.color&&(r=t.color,d=this.darkenColor(t.color,.3)),this.camera.applyTransform(this.ctx);const h=.08,m=.12;if(this.ctx.fillStyle="rgba(0, 0, 0, 0.35)",this.ctx.beginPath(),this.roundedRect(i-n/2+h,o-n/2+m,n,n,.15),this.ctx.fill(),s){const W=.5+Math.sin(this.animationTime*4)*.2;this.ctx.strokeStyle=`rgba(255, 255, 255, ${W})`,this.ctx.lineWidth=4/this.camera.getZoom(),this.ctx.beginPath(),this.roundedRect(i-n/2-.05,o-n/2-.05,n+.1,n+.1,.2),this.ctx.stroke()}e&&!s&&(this.ctx.strokeStyle="rgba(255, 255, 255, 0.4)",this.ctx.lineWidth=2/this.camera.getZoom(),this.ctx.beginPath(),this.roundedRect(i-n/2,o-n/2,n,n,.15),this.ctx.stroke());const f=this.ctx.createLinearGradient(i-n/2,o-n/2,i+n/2,o+n/2);f.addColorStop(0,this.lightenColor(r,.2)),f.addColorStop(.3,r),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.beginPath(),this.roundedRect(i-n/2,o-n/2,n,n,.15),this.ctx.fill(),this.ctx.strokeStyle="rgba(255, 255, 255, 0.25)",this.ctx.lineWidth=2/this.camera.getZoom(),this.ctx.beginPath(),this.ctx.moveTo(i-n/2+.15,o-n/2+.02),this.ctx.lineTo(i+n/2-.15,o-n/2+.02),this.ctx.stroke(),this.ctx.strokeStyle="rgba(0, 0, 0, 0.3)",this.ctx.lineWidth=2/this.camera.getZoom(),this.ctx.beginPath(),this.ctx.moveTo(i-n/2+.15,o+n/2-.02),this.ctx.lineTo(i+n/2-.15,o+n/2-.02),this.ctx.stroke();const c=.6+Math.sin(this.animationTime*3)*.15;this.ctx.strokeStyle=this.hexToRgba(a.color,c),this.ctx.lineWidth=3/this.camera.getZoom(),this.ctx.beginPath(),this.roundedRect(i-n/2,o-n/2,n,n,.15),this.ctx.stroke(),this.ctx.strokeStyle="rgba(0, 0, 0, 0.4)",this.ctx.lineWidth=1/this.camera.getZoom(),this.ctx.beginPath(),this.roundedRect(i-n/2-.02,o-n/2-.02,n+.04,n+.04,.17),this.ctx.stroke();const g=.18*t.scale,p=i+n/2-g-.1,P=o-n/2+g+.1;this.ctx.fillStyle="rgba(0, 0, 0, 0.5)",this.ctx.beginPath(),this.ctx.arc(p,P,g+.03,0,Math.PI*2),this.ctx.fill();const w=this.ctx.createRadialGradient(p-g*.3,P-g*.3,0,p,P,g);w.addColorStop(0,this.lightenColor(a.color,.4)),w.addColorStop(1,a.color),this.ctx.fillStyle=w,this.ctx.beginPath(),this.ctx.arc(p,P,g,0,Math.PI*2),this.ctx.fill(),this.camera.restoreTransform(this.ctx);const b=this.camera.worldToScreen(i,o),S=n*this.camera.getZoom(),x=Math.max(8,S*.55);this.ctx.font=`${x}px "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", serif`,this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillStyle="rgba(0, 0, 0, 0.3)",this.ctx.fillText(l.emoji,b.x+1,b.y+1),this.ctx.fillText(l.emoji,b.x,b.y);const A=this.camera.worldToScreen(i,o+n/2+.25),D=Math.max(6,S*.22);this.ctx.font=`bold ${D}px "Segoe UI", Arial, sans-serif`;const y=this.ctx.measureText(t.name).width,T=6,M=D+6,J=this.ctx.createLinearGradient(A.x-y/2-T,A.y-M/2,A.x-y/2-T,A.y+M/2);if(J.addColorStop(0,"rgba(30, 35, 40, 0.9)"),J.addColorStop(1,"rgba(20, 25, 30, 0.95)"),this.ctx.fillStyle=J,this.ctx.beginPath(),this.roundedRectScreen(A.x-y/2-T,A.y-M/2,y+T*2,M,4),this.ctx.fill(),this.ctx.strokeStyle=this.hexToRgba(r,.6),this.ctx.lineWidth=1,this.ctx.beginPath(),this.roundedRectScreen(A.x-y/2-T,A.y-M/2,y+T*2,M,4),this.ctx.stroke(),this.ctx.fillStyle="#ffffff",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(t.name,A.x,A.y),t.gitChangesCount&&t.gitChangesCount>0){const W=this.camera.worldToScreen(i-n/2+.15,o-n/2+.15),Y=Math.max(5,S*.1),dt=t.gitChangesCount>99?"99+":String(t.gitChangesCount);this.ctx.fillStyle="#c89a5a",this.ctx.beginPath(),this.ctx.arc(W.x,W.y,Y,0,Math.PI*2),this.ctx.fill(),this.ctx.strokeStyle="rgba(0, 0, 0, 0.5)",this.ctx.lineWidth=1,this.ctx.beginPath(),this.ctx.arc(W.x,W.y,Y,0,Math.PI*2),this.ctx.stroke();const gt=Math.max(6,Y*1.2);this.ctx.font=`bold ${gt}px Arial`,this.ctx.fillStyle="#ffffff",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(dt,W.x,W.y)}}drawBossLine(t,s){this.camera.applyTransform(this.ctx),this.ctx.strokeStyle="rgba(255, 215, 0, 0.4)",this.ctx.lineWidth=2/this.camera.getZoom(),this.ctx.setLineDash([4/this.camera.getZoom(),4/this.camera.getZoom()]),this.ctx.beginPath(),this.ctx.moveTo(t.x,t.z),this.ctx.lineTo(s.x,s.z),this.ctx.stroke(),this.ctx.setLineDash([]),this.camera.restoreTransform(this.ctx)}}const ie=30;function oe(k,t,s){return Math.max(t,Math.min(s,k))}function Bt(k){return oe(Math.max(k,1)/ie,.5,1)}function ne(k){return Bt(k)}function ae(k,t){return Bt(k)}const Dt={idle:{color:"#4aff9e",glow:"rgba(74, 255, 158, 0.6)",darkColor:"#2a9a5e"},working:{color:"#4a9eff",glow:"rgba(74, 158, 255, 0.6)",darkColor:"#2a5e9a"},waiting:{color:"#ffcc00",glow:"rgba(255, 204, 0, 0.6)",darkColor:"#9a7a00"},waiting_permission:{color:"#ffcc00",glow:"rgba(255, 204, 0, 0.6)",darkColor:"#9a7a00"},error:{color:"#ff4a4a",glow:"rgba(255, 74, 74, 0.6)",darkColor:"#9a2a2a"},orphaned:{color:"#ff00ff",glow:"rgba(255, 0, 255, 0.6)",darkColor:"#9a009a"}};class re extends at{constructor(s,e,i){super(s,e);u(this,"effect");u(this,"frameCustomClasses",null);u(this,"frameUnseenOutput",null);this.effect=i}beginFrame(){const s=z.getState();this.frameCustomClasses=s.customAgentClasses,this.frameUnseenOutput=s.agentsWithUnseenOutput}getAgentClassIcon(s){var o;const e=xt[s];if(e)return e.icon;const i=(o=this.frameCustomClasses)==null?void 0:o.get(s);return i?i.icon:"🤖"}drawAgent(s,e,i,o,n){var zt;const{x:l,z:a}=s.position,d=s.isBoss?.7:.5,h=this.camera.getZoom(),m=ne(h),f=ae(h,n&&!!s.taskLabel),g=this.animationTime*8,p=s.status==="working",P=p?Math.abs(Math.sin(this.animationTime*4))*4*m:0,w=i?Math.sin(g*2)*.05:0,b=i?1+Math.sin(g*2)*.08:1,S=i?Math.sin(g)*.15:0,x=Dt[s.status]||Dt.idle,A=this.numberToHex(s.color),D=this.darkenColor(A,.4);this.lightenColor(A,.3);const y=this.getAgentClassIcon(s.class),T=this.camera.worldToScreen(l,a+w),M=d*this.camera.getZoom();this.ctx.save(),this.ctx.fillStyle="rgba(0, 0, 0, 0.35)",this.ctx.beginPath(),this.ctx.ellipse(T.x+3,T.y+3,M*1.05,M*.95,0,0,Math.PI*2),this.ctx.fill();const J=p?.75+Math.sin(this.animationTime*2.5)*.2:.85,W=M+6,Y=this.ctx.createRadialGradient(T.x,T.y,M,T.x,T.y,W+4);if(Y.addColorStop(0,"transparent"),Y.addColorStop(.5,this.hexToRgba(x.color,J*.5)),Y.addColorStop(1,"transparent"),this.ctx.beginPath(),this.ctx.arc(T.x,T.y,W+4,0,Math.PI*2),this.ctx.fillStyle=Y,this.ctx.fill(),this.ctx.beginPath(),this.ctx.arc(T.x,T.y,W,0,Math.PI*2),this.ctx.strokeStyle=this.hexToRgba(x.color,J*.8),this.ctx.lineWidth=2,this.ctx.stroke(),e){const I=s.isBoss?.4:.34,C=M+10,v=this.ctx.createRadialGradient(T.x,T.y,M+6,T.x,T.y,C+8);v.addColorStop(0,this.hexToRgba(A,I*.34)),v.addColorStop(.5,this.hexToRgba(A,I*.16)),v.addColorStop(1,"transparent"),this.ctx.beginPath(),this.ctx.arc(T.x,T.y,C+8,0,Math.PI*2),this.ctx.fillStyle=v,this.ctx.fill(),this.ctx.beginPath(),this.ctx.arc(T.x,T.y,C,0,Math.PI*2),this.ctx.strokeStyle=this.hexToRgba(A,s.isBoss?.44:.36),this.ctx.lineWidth=s.isBoss?2.2:1.8,this.ctx.setLineDash([8,4]),this.ctx.lineDashOffset=-this.animationTime*12,this.ctx.stroke(),this.ctx.setLineDash([])}if(i){const I=M*.25,C=T.y+M*.7;this.ctx.fillStyle="rgba(0, 0, 0, 0.3)",this.ctx.beginPath(),this.ctx.ellipse(T.x,C+4,M*.6,M*.15,0,0,Math.PI*2),this.ctx.fill(),this.ctx.fillStyle=D,this.ctx.beginPath(),this.ctx.arc(T.x-M*.3+S*this.camera.getZoom(),C,I,0,Math.PI*2),this.ctx.fill(),this.ctx.beginPath(),this.ctx.arc(T.x+M*.3-S*this.camera.getZoom(),C,I,0,Math.PI*2),this.ctx.fill()}const dt=i?M/b:M,gt=i?M*b:M,rt=this.ctx.createRadialGradient(T.x-M*.3,T.y-M*.3,0,T.x,T.y,M);rt.addColorStop(0,"#3a3a3a"),rt.addColorStop(.5,"#1a1a1a"),rt.addColorStop(1,"#0a0a0a"),this.ctx.beginPath(),i?this.ctx.ellipse(T.x,T.y,dt,gt,0,0,Math.PI*2):this.ctx.arc(T.x,T.y,M,0,Math.PI*2),this.ctx.fillStyle=rt,this.ctx.fill(),this.ctx.strokeStyle=this.hexToRgba(A,.6),this.ctx.lineWidth=2,this.ctx.stroke(),this.ctx.beginPath(),this.ctx.arc(T.x-M*.25,T.y-M*.25,M*.3,0,Math.PI*2),this.ctx.fillStyle="rgba(255, 255, 255, 0.1)",this.ctx.fill(),this.ctx.restore();const Lt=Math.max(12*m,M*1.1);if(this.ctx.font=`${Lt}px "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif`,this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(y,T.x,T.y+1-P),s.isBoss){const I=Math.max(10*m,M*.6);this.ctx.font=`${I}px "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", serif`,this.ctx.textAlign="center",this.ctx.textBaseline="bottom",this.ctx.fillText("👑",T.x,T.y-M-2)}if(i)for(let C=0;C<4;C++){const v=g+C*1.5,Z=T.x+Math.sin(v*1.5)*M*.5,R=T.y+M*.9+Math.abs(Math.sin(v))*8,X=2+Math.sin(v)*1,G=.4-Math.abs(Math.sin(v))*.3;this.ctx.beginPath(),this.ctx.arc(Z,R,X,0,Math.PI*2),this.ctx.fillStyle=`rgba(180, 180, 180, ${G})`,this.ctx.fill()}const ut=o*m,Q=T.y+M+12*m,Xt=o*f,et=Math.max(7,13*Xt);this.ctx.font=`bold ${et}px "Segoe UI", Arial, sans-serif`;const Zt=this.ctx.measureText(s.name).width,At=6*f,st=et+4*f,ft=s.provider==="claude"||s.provider==="codex",lt=ft?et*.45:0,Et=ft?et*.3:0,Mt=lt+Et,it=Zt+Mt+At*2,Ot=T.x+Mt/2,mt=this.ctx.createLinearGradient(T.x-it/2,Q-st/2,T.x-it/2,Q+st/2);if(mt.addColorStop(0,"rgba(30, 30, 40, 0.95)"),mt.addColorStop(1,"rgba(20, 20, 30, 0.95)"),this.ctx.beginPath(),this.roundedRectScreen(T.x-it/2,Q-st/2,it,st,4),this.ctx.fillStyle=mt,this.ctx.fill(),this.ctx.strokeStyle=this.hexToRgba(A,.6),this.ctx.lineWidth=1.5,this.ctx.stroke(),ft){const I=T.x-it/2+At+lt/2,C=Q,v=s.provider==="codex"?"#4a9eff":"#ff9e4a";this.ctx.beginPath(),this.ctx.arc(I,C,lt/2,0,Math.PI*2),this.ctx.fillStyle=v,this.ctx.fill(),this.ctx.strokeStyle="rgba(255, 255, 255, 0.9)",this.ctx.lineWidth=Math.max(1,lt*.12),this.ctx.stroke()}this.ctx.fillStyle=A,this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.font=`bold ${et}px "Segoe UI", Arial, sans-serif`,this.ctx.fillText(s.name,Ot,Q);const wt=bt(s).freePercent,ot=Math.max(0,Math.min(100,wt))/100,H=Q+st/2+8*m,F=100*m,j=14*m;if(this.ctx.beginPath(),this.roundedRectScreen(T.x-F/2,H,F,j,4),this.ctx.fillStyle="rgba(0, 0, 0, 0.7)",this.ctx.fill(),ot>0){let I,C;ot>.5?(I="#6a9a78",C="#4a7a58"):ot>.2?(I="#c89858",C="#a87838"):(I="#c85858",C="#a83838");const v=this.ctx.createLinearGradient(T.x-F/2,H,T.x-F/2+F*ot,H);v.addColorStop(0,I),v.addColorStop(1,C),this.ctx.beginPath(),this.roundedRectScreen(T.x-F/2,H,F*ot,j,4),this.ctx.fillStyle=v,this.ctx.fill()}this.ctx.beginPath(),this.roundedRectScreen(T.x-F/2,H,F,j,4),this.ctx.strokeStyle="rgba(100, 150, 150, 0.6)",this.ctx.lineWidth=1.5,this.ctx.stroke();const Wt=`${Math.round(wt)}%`,Gt=Math.max(6,10*m);if(this.ctx.font=`bold ${Gt}px "Segoe UI", Arial, sans-serif`,this.ctx.fillStyle="rgba(255, 255, 255, 0.95)",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(Wt,T.x,H+j/2),s.status==="idle"&&s.lastActivity>0){const I=Math.floor((Date.now()-s.lastActivity)/1e3);if(I>=5){const C=this.formatIdleTime(I),v=H+j+10*m;let Z,R,X;I<60?(Z="rgba(74, 158, 74, 0.9)",R="#aaffaa",X="💤"):(I<300,Z="rgba(158, 120, 50, 0.9)",R="#ffdd88",X="⏳");const G=Math.max(6,9*ut);this.ctx.font=`bold ${G}px "Segoe UI Emoji", "Apple Color Emoji", Arial`;const $=`${X} ${C}`,q=this.ctx.measureText($).width,V=5*m,K=G+3*m;this.ctx.beginPath(),this.roundedRectScreen(T.x-q/2-V,v-K/2,q+V*2,K,K/2),this.ctx.fillStyle=Z,this.ctx.fill(),this.ctx.fillStyle=R,this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText($,T.x,v)}}this.effect.updateAgentTool(s.id,s.currentTool);const tt=this.effect.getToolAnimation(s.id);if(tt&&tt.opacity>.01){const I=vt[tt.tool]||vt.default,C=H+j+10*m,v=tt.opacity,Z=tt.fadeIn?this.easeOutCubic(v):v,R=.8+.2*Z,X=Math.max(6,10*ut)*R;this.ctx.font=`bold ${X}px "Segoe UI Emoji", "Apple Color Emoji", Arial`;const G=`${I} ${tt.tool}`,$=this.ctx.measureText(G).width,q=6*m*R,V=X+4*m*R,K=(1-Z)*4*m,ct=C+K;this.ctx.beginPath(),this.roundedRectScreen(T.x-$/2-q,ct-V/2,$+q*2,V,V/2),this.ctx.fillStyle=`rgba(74, 118, 158, ${.9*v})`,this.ctx.fill(),this.ctx.strokeStyle=`rgba(74, 158, 255, ${.6*v})`,this.ctx.lineWidth=1,this.ctx.stroke(),this.ctx.fillStyle=`rgba(170, 221, 255, ${v})`,this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(G,T.x,ct)}if(n&&s.taskLabel){const I=Math.max(9,15*ut);this.ctx.font=`bold italic ${I}px "Segoe UI", Arial, sans-serif`;const C=s.taskLabel.length>30?s.taskLabel.substring(0,28)+"..":s.taskLabel,v=this.ctx.measureText(C).width,Z=6*m,R=I+5*m,X=H+j+10*m;this.ctx.beginPath(),this.roundedRectScreen(T.x-v/2-Z,X-R/2,v+Z*2,R,R/2),this.ctx.fillStyle="rgba(60, 60, 80, 0.8)",this.ctx.fill(),this.ctx.fillStyle="rgba(180, 195, 215, 0.95)",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(C,T.x,X)}if((zt=this.frameUnseenOutput)!=null&&zt.has(s.id)){const I=10*m,C=T.x+M*.7,v=T.y-M*.7,Z=this.ctx.createRadialGradient(C,v,0,C,v,I*1.5);Z.addColorStop(0,"rgba(74, 158, 255, 0.8)"),Z.addColorStop(1,"rgba(74, 158, 255, 0)"),this.ctx.beginPath(),this.ctx.arc(C,v,I*1.5,0,Math.PI*2),this.ctx.fillStyle=Z,this.ctx.fill();const R=I*.9,X=-Math.PI/2,G=X+2*Math.PI/3,$=X+4*Math.PI/3,q=C+R*Math.cos(X),V=v+R*Math.sin(X),K=C+R*Math.cos(G),ct=v+R*Math.sin(G),Ht=C+R*Math.cos($),Ft=v+R*Math.sin($);this.ctx.beginPath(),this.ctx.moveTo(q,V),this.ctx.lineTo(K,ct),this.ctx.lineTo(Ht,Ft),this.ctx.closePath(),this.ctx.fillStyle="#4a9eff",this.ctx.fill(),this.ctx.strokeStyle="#282a36",this.ctx.lineWidth=2,this.ctx.stroke(),this.ctx.fillStyle="#ffffff",this.ctx.font=`bold ${Math.max(8,I*1.2)}px Arial`,this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText("!",C,v+1)}}drawSelectionBox(s,e){const i=this.camera.getZoom(),o=Math.min(s.x,e.x),n=Math.max(s.x,e.x),l=Math.min(s.z,e.z),a=Math.max(s.z,e.z),r=n-o,d=a-l;if(r<.1&&d<.1)return;this.camera.applyTransform(this.ctx);const h=this.ctx,m="#4a9eff",f=this.animationTime*30%24,c=6/i,g=3/i;h.strokeStyle="rgba(74, 158, 255, 0.2)",h.lineWidth=6/i,h.beginPath(),h.rect(o,l,r,d),h.stroke();const p=h.createLinearGradient(o,l,n,a);p.addColorStop(0,"rgba(74, 158, 255, 0.15)"),p.addColorStop(.4,"rgba(74, 158, 255, 0.08)"),p.addColorStop(.6,"rgba(74, 158, 255, 0.12)"),p.addColorStop(1,"rgba(100, 180, 255, 0.18)"),h.fillStyle=p,h.beginPath(),h.rect(o,l,r,d),h.fill();const P=h.createLinearGradient(o,l,n,l);P.addColorStop(0,"transparent"),P.addColorStop(.2,"rgba(150, 200, 255, 0.4)"),P.addColorStop(.8,"rgba(150, 200, 255, 0.4)"),P.addColorStop(1,"transparent"),h.strokeStyle=P,h.lineWidth=1.5/i,h.beginPath(),h.moveTo(o+r*.1,l+1/i),h.lineTo(n-r*.1,l+1/i),h.stroke(),h.strokeStyle="rgba(74, 158, 255, 0.9)",h.lineWidth=2/i,h.setLineDash([c,g]),h.lineDashOffset=-f/i,h.beginPath(),h.rect(o,l,r,d),h.stroke(),h.setLineDash([]),h.strokeStyle="rgba(74, 158, 255, 0.3)",h.lineWidth=1/i,h.beginPath(),h.rect(o-1/i,l-1/i,r+2/i,d+2/i),h.stroke();const w=Math.min(r,d)*.15,S=Math.max(w,.3);h.strokeStyle=m,h.lineWidth=3/i,h.lineCap="round",this.drawSelectionCorner(o,l,S,"top-left"),this.drawSelectionCorner(n,l,S,"top-right"),this.drawSelectionCorner(o,a,S,"bottom-left"),this.drawSelectionCorner(n,a,S,"bottom-right");const x=3/i;h.fillStyle=m;const A=.6+Math.sin(this.animationTime*4)*.3,D=[{x:o,y:l},{x:n,y:l},{x:o,y:a},{x:n,y:a}];for(const y of D)h.fillStyle=`rgba(74, 158, 255, ${A*.35})`,h.beginPath(),h.arc(y.x,y.y,x*2.5,0,Math.PI*2),h.fill(),h.fillStyle=m,h.beginPath(),h.arc(y.x,y.y,x,0,Math.PI*2),h.fill();this.camera.restoreTransform(this.ctx)}drawSelectionCorner(s,e,i,o){const n=this.ctx;switch(n.beginPath(),o){case"top-left":n.moveTo(s,e+i),n.lineTo(s,e),n.lineTo(s+i,e);break;case"top-right":n.moveTo(s-i,e),n.lineTo(s,e),n.lineTo(s,e+i);break;case"bottom-left":n.moveTo(s,e-i),n.lineTo(s,e),n.lineTo(s+i,e);break;case"bottom-right":n.moveTo(s-i,e),n.lineTo(s,e),n.lineTo(s,e-i);break}n.stroke()}}class Rt{constructor(t,s){u(this,"grid");u(this,"area");u(this,"building");u(this,"agent");u(this,"effect");this.effect=new Qt(t,s),this.grid=new te(t,s),this.area=new ee(t,s),this.building=new se(t,s),this.agent=new re(t,s,this.effect)}update(t){this.effect.update(t);const s=this.effect.getAnimationTime();this.grid.setAnimationTime(s),this.area.setAnimationTime(s),this.building.setAnimationTime(s),this.agent.setAnimationTime(s)}drawGround(t){this.grid.drawGround(t)}drawGrid(t,s){this.grid.drawGrid(t,s)}drawArea(t,s=!1){this.area.drawArea(t,s)}drawBuilding(t,s,e=!1){this.building.drawBuilding(t,s,e)}beginAgentFrame(){this.agent.beginFrame()}drawAgent(t,s,e,i,o){this.agent.drawAgent(t,s,e,i,o)}drawBossLine(t,s){this.building.drawBossLine(t,s)}drawSelectionBox(t,s){this.agent.drawSelectionBox(t,s)}drawAreaPreview(t,s,e){this.area.drawAreaPreview(t,s,e)}updateAgentTool(t,s){this.effect.updateAgentTool(t,s)}getToolAnimation(t){return this.effect.getToolAnimation(t)}}const E=class E{constructor(t,s,e){u(this,"canvas");u(this,"camera");u(this,"scene");u(this,"isMouseDown",!1);u(this,"isPanning",!1);u(this,"isSelecting",!1);u(this,"lastMouseX",0);u(this,"lastMouseY",0);u(this,"mouseDownX",0);u(this,"mouseDownY",0);u(this,"mouseDownTime",0);u(this,"lastClickTime",0);u(this,"lastClickTarget",null);u(this,"doubleClickDelay",400);u(this,"selectionBox",null);u(this,"hoveredAgentId",null);u(this,"hoveredBuildingId",null);u(this,"isMouseInCanvas",!1);u(this,"isResizingArea",!1);u(this,"resizeHandleType",null);u(this,"isDraggingBuilding",!1);u(this,"draggingBuildingId",null);u(this,"buildingDragStartPos",null);u(this,"isDraggingAgent",!1);u(this,"draggingAgentId",null);u(this,"agentDragStartPos",null);u(this,"onMouseDown",t=>{const s=this.canvas.getBoundingClientRect(),e=t.clientX-s.left,i=t.clientY-s.top;if(this.isMouseDown=!0,this.mouseDownX=e,this.mouseDownY=i,this.lastMouseX=e,this.lastMouseY=i,this.mouseDownTime=Date.now(),t.button===1){this.isPanning=!0,this.canvas.classList.add("panning"),t.preventDefault();return}if(t.button===0){const o=this.camera.screenToWorld(e,i);if(this.scene.isInDrawingMode()){this.scene.startDrawing(o);return}const n=this.scene.getAreaHandleAtWorldPos(o.x,o.z);if(n){this.isResizingArea=!0,this.resizeHandleType=n.handleType,this.scene.startAreaResize(n.handleType,o);const r=n.handleType;this.canvas.style.cursor=r==="move"?"move":r==="n"||r==="s"?"ns-resize":r==="e"||r==="w"||r==="radius"?"ew-resize":r==="ne"||r==="sw"?"nesw-resize":"nwse-resize";return}const l=this.scene.getAgentAtScreenPos(e,i),a=this.scene.getBuildingAtScreenPos(e,i);if(l){this.draggingAgentId=l.id,this.agentDragStartPos={...o},this.isDraggingAgent=!1;return}if(a&&!l){this.draggingBuildingId=a.id,this.buildingDragStartPos={...o},this.isDraggingBuilding=!1;return}!l&&!a&&(this.isSelecting=!1,this.selectionBox={start:{...o},end:{...o}})}});u(this,"onMouseMove",t=>{var m,f;const s=this.canvas.getBoundingClientRect(),e=t.clientX-s.left,i=t.clientY-s.top;this.camera.setMousePosition(e,i),this.isMouseInCanvas=!0;const o=this.scene.getAgentAtScreenPos(e,i),n=(o==null?void 0:o.id)??null;n!==this.hoveredAgentId&&(this.hoveredAgentId=n,this.scene.handleAgentHover(n,n?{x:t.clientX,y:t.clientY}:null));const l=this.scene.getBuildingAtScreenPos(e,i),a=(l==null?void 0:l.id)??null;if(a!==this.hoveredBuildingId&&(this.hoveredBuildingId=a,(f=(m=this.scene).handleBuildingHover)==null||f.call(m,a)),!this.isMouseDown){const c=this.camera.screenToWorld(e,i),g=this.scene.getAreaHandleAtWorldPos(c.x,c.z);g?g.handleType==="move"?this.canvas.style.cursor="move":g.handleType==="nw"||g.handleType==="se"?this.canvas.style.cursor="nwse-resize":g.handleType==="ne"||g.handleType==="sw"?this.canvas.style.cursor="nesw-resize":g.handleType==="n"||g.handleType==="s"?this.canvas.style.cursor="ns-resize":(g.handleType==="e"||g.handleType==="w"||g.handleType==="radius")&&(this.canvas.style.cursor="ew-resize"):this.canvas.style.cursor=""}if(!this.isMouseDown){this.lastMouseX=e,this.lastMouseY=i;return}const r=e-this.lastMouseX,d=i-this.lastMouseY,h=this.camera.screenToWorld(e,i);if(this.scene.isCurrentlyDrawing()){this.scene.updateDrawing(h),this.lastMouseX=e,this.lastMouseY=i;return}if(this.isResizingArea){this.scene.updateAreaResize(h),this.lastMouseX=e,this.lastMouseY=i;return}if(this.draggingAgentId&&this.agentDragStartPos){const c=h.x-this.agentDragStartPos.x,g=h.z-this.agentDragStartPos.z,p=Math.sqrt(c*c+g*g);!this.isDraggingAgent&&p>.5&&(this.isDraggingAgent=!0,this.canvas.style.cursor="move"),this.isDraggingAgent&&this.scene.handleAgentDragMove(this.draggingAgentId,h),this.lastMouseX=e,this.lastMouseY=i;return}if(this.draggingBuildingId&&this.buildingDragStartPos){const c=h.x-this.buildingDragStartPos.x,g=h.z-this.buildingDragStartPos.z,p=Math.sqrt(c*c+g*g);!this.isDraggingBuilding&&p>.5&&(this.isDraggingBuilding=!0,this.scene.handleBuildingDragStart(this.draggingBuildingId,this.buildingDragStartPos),this.canvas.style.cursor="move"),this.isDraggingBuilding&&this.scene.handleBuildingDragMove(this.draggingBuildingId,h),this.lastMouseX=e,this.lastMouseY=i;return}this.isPanning?this.camera.panBy(r,d):this.selectionBox&&(Math.sqrt(Math.pow(e-this.mouseDownX,2)+Math.pow(i-this.mouseDownY,2))>5&&!this.isSelecting&&(this.isSelecting=!0,this.canvas.classList.add("selecting")),this.isSelecting&&(this.selectionBox.end={...h})),this.lastMouseX=e,this.lastMouseY=i});u(this,"onMouseUp",t=>{const s=this.canvas.getBoundingClientRect(),e=t.clientX-s.left,i=t.clientY-s.top,o=this.camera.screenToWorld(e,i);if(this.scene.isCurrentlyDrawing()){this.scene.finishDrawing(o),this.isMouseDown=!1;return}if(this.isResizingArea){this.scene.finishAreaResize(),this.isResizingArea=!1,this.resizeHandleType=null,this.canvas.style.cursor="",this.isMouseDown=!1;return}if(this.draggingAgentId)if(this.isDraggingAgent){this.scene.handleAgentDragEnd(this.draggingAgentId,o),this.draggingAgentId=null,this.agentDragStartPos=null,this.isDraggingAgent=!1,this.canvas.style.cursor="",this.isMouseDown=!1;return}else this.draggingAgentId=null,this.agentDragStartPos=null,this.isDraggingAgent=!1;if(this.draggingBuildingId)if(this.isDraggingBuilding){this.scene.handleBuildingDragEnd(this.draggingBuildingId,o),this.draggingBuildingId=null,this.buildingDragStartPos=null,this.isDraggingBuilding=!1,this.canvas.style.cursor="",this.isMouseDown=!1;return}else this.draggingBuildingId=null,this.buildingDragStartPos=null,this.isDraggingBuilding=!1,this.canvas.style.cursor="";const n=this.isSelecting,l=this.isPanning;if(n&&this.selectionBox&&(this.scene.handleSelectionBox(this.selectionBox.start,this.selectionBox.end),this.selectionBox=null),!l&&!n&&t.button===0){const a=Date.now()-this.mouseDownTime,r=Math.sqrt(Math.pow(e-this.mouseDownX,2)+Math.pow(i-this.mouseDownY,2));a<500&&r<10&&this.handleClick(e,i,t.shiftKey)}this.isMouseDown=!1,this.isPanning=!1,this.isSelecting=!1,this.canvas.classList.remove("panning","selecting")});u(this,"onMouseLeave",()=>{var e,i,o,n;this.isMouseDown=!1,this.isPanning=!1,this.isSelecting=!1,this.selectionBox=null,this.isMouseInCanvas=!1,this.canvas.classList.remove("panning","selecting"),this.canvas.style.cursor="",this.isResizingArea&&(this.scene.finishAreaResize(),this.isResizingArea=!1,this.resizeHandleType=null),this.isDraggingAgent&&this.draggingAgentId&&this.scene.handleAgentDragCancel(this.draggingAgentId),this.draggingAgentId=null,this.agentDragStartPos=null,this.isDraggingAgent=!1,this.isDraggingBuilding&&this.draggingBuildingId&&((i=(e=this.scene).handleBuildingDragCancel)==null||i.call(e,this.draggingBuildingId)),this.draggingBuildingId=null,this.buildingDragStartPos=null,this.isDraggingBuilding=!1,this.hoveredAgentId&&(this.hoveredAgentId=null,this.scene.handleAgentHover(null,null)),this.hoveredBuildingId&&(this.hoveredBuildingId=null,(n=(o=this.scene).handleBuildingHover)==null||n.call(o,null));const{width:t,height:s}=this.camera.getViewportSize();this.camera.setMousePosition(t/2,s/2)});u(this,"onWheel",t=>{t.preventDefault();const s=this.canvas.getBoundingClientRect(),e=t.clientX-s.left,i=t.clientY-s.top,o=!t.ctrlKey&&(Math.abs(t.deltaX)>0||t.deltaMode===0&&Math.abs(t.deltaY)<50);if(t.ctrlKey){const n=-t.deltaY*.01;this.camera.zoomAtPoint(e,i,n)}else if(o)this.camera.panBy(-t.deltaX,-t.deltaY);else{const n=-t.deltaY*.001;this.camera.zoomAtPoint(e,i,n)}});u(this,"onContextMenu",t=>{t.preventDefault();const s=this.canvas.getBoundingClientRect(),e=t.clientX-s.left,i=t.clientY-s.top,o=this.camera.screenToWorld(e,i),n=this.scene.getAgentAtScreenPos(e,i),l=this.scene.getBuildingAtScreenPos(e,i),a=this.scene.getAreaAtScreenPos(e,i);if(z.getState().selectedAgentIds.size>0&&!n&&!l){this.scene.handleMoveCommand({x:o.x,z:o.z}),this.scene.createMoveOrderEffect({x:o.x,z:o.z});return}let d=null;n?d={type:"agent",id:n.id}:l?d={type:"building",id:l.id}:a&&(d={type:"area",id:a.id}),this.scene.handleContextMenu({x:t.clientX,y:t.clientY},{x:o.x,z:o.z},d)});u(this,"onKeyDown",t=>{const s=t.target,e=z.getState(),i=s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable,o=s.closest(".guake-terminal"),n=o==null?void 0:o.classList.contains("collapsed"),l=z.getShortcuts(),a=l.find(m=>m.id==="next-agent"),r=l.find(m=>m.id==="prev-agent"),d=l.find(m=>m.id==="open-terminal"),h=l.find(m=>m.id==="toggle-spotlight");if(_(t,h)){console.log("[Scene2DInput] Spotlight shortcut detected, passing through");return}if(i)if((_(t,a)||_(t,r))&&n)s.blur();else if(_(t,d)&&n)s.blur();else return;if((_(t,a)||_(t,r))&&!e.terminalOpen){const m=this.getOrderedAgents(e.agents);if(m.length<=1)return;const f=e.selectedAgentIds.size===1?Array.from(e.selectedAgentIds)[0]:null,c=f?m.findIndex(p=>p.id===f):-1;let g;_(t,a)?g=c===-1?0:(c+1)%m.length:g=c===-1?m.length-1:(c-1+m.length)%m.length,t.preventDefault(),z.selectAgent(m[g].id);return}if(_(t,d)){if(console.log("[Scene2DInput] Space pressed",{guakeTerminal:!!o,isCollapsedTerminal:n,targetTag:s.tagName,terminalOpen:e.terminalOpen,selectedAgents:e.selectedAgentIds.size,selectedBuildings:e.selectedBuildingIds.size,selectedArea:e.selectedAreaId,lastSelectedAgentId:e.lastSelectedAgentId}),o&&!n){console.log("[Scene2DInput] Space: blocked - inside open terminal");return}if(s.tagName==="BUTTON"||s.tagName==="A"){console.log("[Scene2DInput] Space: blocked - button/link focused");return}if(e.terminalOpen){console.log("[Scene2DInput] Space: blocked - terminal already open");return}if(e.selectedBuildingIds.size>0||e.selectedAreaId!==null){console.log("[Scene2DInput] Space: blocked - building or area focused");return}if(e.selectedAgentIds.size===0){const m=e.lastSelectedAgentId;console.log("[Scene2DInput] Space: no agent selected, trying lastAgentId:",m),m&&e.agents.has(m)?(t.preventDefault(),z.selectAgent(m),z.setTerminalOpen(!0),console.log("[Scene2DInput] Space: opened terminal for last agent:",m)):console.log("[Scene2DInput] Space: no valid last agent to open");return}t.preventDefault(),console.log("[Scene2DInput] Space: opening terminal for selected agent"),z.setTerminalOpen(!0)}});u(this,"touchStartPositions",[]);u(this,"initialPinchDistance",0);u(this,"longPressTimer",null);u(this,"longPressTriggered",!1);u(this,"touchIsPanning",!1);u(this,"touchPanVelocityX",0);u(this,"touchPanVelocityY",0);u(this,"lastTouchMoveTime",0);u(this,"touchInertiaFrameId",null);u(this,"onTouchStart",t=>{t.preventDefault(),this.stopTouchInertia(),this.clearLongPressTimer(),this.longPressTriggered=!1,this.touchIsPanning=!1,this.touchPanVelocityX=0,this.touchPanVelocityY=0,this.lastTouchMoveTime=0;const s=this.canvas.getBoundingClientRect();if(this.touchStartPositions=Array.from(t.touches).map(e=>({x:e.clientX-s.left,y:e.clientY-s.top})),t.touches.length===1){const e=this.touchStartPositions[0].x,i=this.touchStartPositions[0].y;if(this.mouseDownX=e,this.mouseDownY=i,this.lastMouseX=e,this.lastMouseY=i,this.mouseDownTime=Date.now(),this.isMouseDown=!0,this.scene.isInDrawingMode()){const r=this.camera.screenToWorld(e,i);this.scene.startDrawing(r);return}const o=this.camera.screenToWorld(e,i),n=this.scene.getAreaHandleAtWorldPos(o.x,o.z);if(n){this.isResizingArea=!0,this.resizeHandleType=n.handleType,this.scene.startAreaResize(n.handleType,o);return}const l=t.touches[0].clientX,a=t.touches[0].clientY;this.longPressTimer=setTimeout(()=>{this.longPressTriggered=!0,this.longPressTimer=null,this.handleTouchLongPress(l,a),navigator.vibrate&&navigator.vibrate(50)},E.TOUCH_LONG_PRESS_DURATION)}else t.touches.length===2&&(this.clearLongPressTimer(),this.initialPinchDistance=this.getPinchDistance(t.touches),this.isPanning=!1)});u(this,"onTouchMove",t=>{t.preventDefault();const s=this.canvas.getBoundingClientRect();if(t.touches.length===1){const e=t.touches[0].clientX-s.left,i=t.touches[0].clientY-s.top;if(this.scene.isCurrentlyDrawing()){const a=this.camera.screenToWorld(e,i);this.scene.updateDrawing(a),this.lastMouseX=e,this.lastMouseY=i;return}if(this.isResizingArea){const a=this.camera.screenToWorld(e,i);this.scene.updateAreaResize(a),this.lastMouseX=e,this.lastMouseY=i;return}const o=e-this.mouseDownX,n=i-this.mouseDownY;if((Math.abs(o)>E.TOUCH_DRAG_THRESHOLD||Math.abs(n)>E.TOUCH_DRAG_THRESHOLD)&&(this.clearLongPressTimer(),this.touchIsPanning=!0),this.touchIsPanning){const a=this.lastTouchMoveTime>0?Math.max(1,t.timeStamp-this.lastTouchMoveTime):16,r=e-this.lastMouseX,d=i-this.lastMouseY,h=r/a,m=d/a;this.touchPanVelocityX=this.touchPanVelocityX*.7+h*.3,this.touchPanVelocityY=this.touchPanVelocityY*.7+m*.3,this.camera.panBy(r,d)}this.lastTouchMoveTime=t.timeStamp,this.lastMouseX=e,this.lastMouseY=i}else if(t.touches.length===2){this.clearLongPressTimer();const e=this.getPinchDistance(t.touches),i=(e-this.initialPinchDistance)*.01,o=(t.touches[0].clientX+t.touches[1].clientX)/2-s.left,n=(t.touches[0].clientY+t.touches[1].clientY)/2-s.top;this.camera.zoomAtPoint(o,n,i),this.initialPinchDistance=e}});u(this,"onTouchEnd",t=>{if(this.clearLongPressTimer(),t.touches.length===0&&this.touchStartPositions.length===1){if(this.scene.isCurrentlyDrawing()){const i=this.camera.screenToWorld(this.lastMouseX,this.lastMouseY);this.scene.finishDrawing(i),this.isMouseDown=!1,this.touchStartPositions=[],this.touchIsPanning=!1;return}if(this.isResizingArea){this.scene.finishAreaResize(),this.isResizingArea=!1,this.resizeHandleType=null,this.isMouseDown=!1,this.touchStartPositions=[],this.touchIsPanning=!1;return}if(this.longPressTriggered){this.longPressTriggered=!1,this.isMouseDown=!1,this.isPanning=!1,this.touchStartPositions=[],this.touchIsPanning=!1,this.touchPanVelocityX=0,this.touchPanVelocityY=0,this.lastTouchMoveTime=0;return}const s=Date.now()-this.mouseDownTime,e=Math.sqrt(Math.pow(this.lastMouseX-this.mouseDownX,2)+Math.pow(this.lastMouseY-this.mouseDownY,2));s<300&&e<20&&this.handleClick(this.lastMouseX,this.lastMouseY,!1),this.touchIsPanning&&this.startTouchInertia()}this.isMouseDown=!1,this.isPanning=!1,this.touchStartPositions=[],this.touchIsPanning=!1,this.lastTouchMoveTime=0});u(this,"onTouchCancel",()=>{this.stopTouchInertia(),this.clearLongPressTimer(),this.longPressTriggered=!1,this.isMouseDown=!1,this.isPanning=!1,this.touchStartPositions=[],this.touchIsPanning=!1,this.touchPanVelocityX=0,this.touchPanVelocityY=0,this.lastTouchMoveTime=0});this.canvas=t,this.camera=s,this.scene=e,this.setupEventListeners()}dispose(){this.stopTouchInertia(),this.canvas.removeEventListener("mousedown",this.onMouseDown),this.canvas.removeEventListener("mousemove",this.onMouseMove),this.canvas.removeEventListener("mouseup",this.onMouseUp),this.canvas.removeEventListener("mouseleave",this.onMouseLeave),this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("contextmenu",this.onContextMenu),this.canvas.removeEventListener("touchstart",this.onTouchStart),this.canvas.removeEventListener("touchmove",this.onTouchMove),this.canvas.removeEventListener("touchend",this.onTouchEnd),this.canvas.removeEventListener("touchcancel",this.onTouchCancel),document.removeEventListener("keydown",this.onKeyDown,!0),this.clearLongPressTimer()}setupEventListeners(){this.canvas.addEventListener("mousedown",this.onMouseDown),this.canvas.addEventListener("mousemove",this.onMouseMove),this.canvas.addEventListener("mouseup",this.onMouseUp),this.canvas.addEventListener("mouseleave",this.onMouseLeave),this.canvas.addEventListener("wheel",this.onWheel,{passive:!1}),this.canvas.addEventListener("contextmenu",this.onContextMenu),this.canvas.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.canvas.addEventListener("touchmove",this.onTouchMove,{passive:!1}),this.canvas.addEventListener("touchend",this.onTouchEnd),this.canvas.addEventListener("touchcancel",this.onTouchCancel),document.addEventListener("keydown",this.onKeyDown,!0)}getOrderedAgents(t){const s=Array.from(t.values()),e=new Set(s.map(f=>f.id)),o=Vt(_t.AGENT_ORDER,[]).filter(f=>e.has(f)),l=s.filter(f=>!o.includes(f.id)).sort((f,c)=>(f.createdAt||0)-(c.createdAt||0)).map(f=>f.id),a=[...o,...l],r=new Map(s.map(f=>[f.id,f])),d=a.map(f=>r.get(f)).filter(f=>f!==void 0),h=new Map;for(const f of d){const c=z.getAreaForAgent(f.id),g=(c==null?void 0:c.id)||null;h.has(g)||h.set(g,{area:c?{name:c.name}:null,agents:[]}),h.get(g).agents.push(f)}const m=Array.from(h.values());return m.sort((f,c)=>{var g,p;return!f.area&&c.area?1:f.area&&!c.area?-1:!f.area&&!c.area?0:(((g=f.area)==null?void 0:g.name)||"").localeCompare(((p=c.area)==null?void 0:p.name)||"")}),m.flatMap(f=>f.agents)}startTouchInertia(){if(Math.hypot(this.touchPanVelocityX,this.touchPanVelocityY)<E.TOUCH_INERTIA_MIN_SPEED)return;this.stopTouchInertia();let s=this.touchPanVelocityX,e=this.touchPanVelocityY,i=performance.now();const o=n=>{const l=Math.max(1,n-i);i=n,this.camera.panBy(s*l,e*l);const a=Math.pow(E.TOUCH_INERTIA_DECAY,l/(1e3/60));if(s*=a,e*=a,Math.hypot(s,e)<E.TOUCH_INERTIA_MIN_SPEED){this.touchInertiaFrameId=null,this.touchPanVelocityX=0,this.touchPanVelocityY=0;return}this.touchInertiaFrameId=requestAnimationFrame(o)};this.touchInertiaFrameId=requestAnimationFrame(o)}stopTouchInertia(){this.touchInertiaFrameId!==null&&(cancelAnimationFrame(this.touchInertiaFrameId),this.touchInertiaFrameId=null)}clearLongPressTimer(){this.longPressTimer&&(clearTimeout(this.longPressTimer),this.longPressTimer=null)}handleTouchLongPress(t,s){const e=this.canvas.getBoundingClientRect(),i=t-e.left,o=s-e.top,n=this.camera.screenToWorld(i,o),l=this.scene.getAgentAtScreenPos(i,o),a=this.scene.getBuildingAtScreenPos(i,o),r=this.scene.getAreaAtScreenPos(i,o);if(z.getState().selectedAgentIds.size>0&&!l&&!a){this.scene.handleMoveCommand({x:n.x,z:n.z}),this.scene.createMoveOrderEffect({x:n.x,z:n.z});return}let h=null;l?h={type:"agent",id:l.id}:a?h={type:"building",id:a.id}:r?h={type:"area",id:r.id}:h={type:"ground"},this.scene.handleContextMenu({x:t,y:s},{x:n.x,z:n.z},h)}getPinchDistance(t){return Math.sqrt(Math.pow(t[0].clientX-t[1].clientX,2)+Math.pow(t[0].clientY-t[1].clientY,2))}handleClick(t,s,e){const i=this.scene.getAgentAtScreenPos(t,s),o=this.scene.getBuildingAtScreenPos(t,s),n=Date.now();if(i)this.lastClickTarget===i.id&&n-this.lastClickTime<this.doubleClickDelay?(window.innerWidth<=768?z.openTerminalOnMobile(i.id):(z.selectAgent(i.id),z.setTerminalOpen(!0)),this.scene.handleAgentDoubleClick(i.id),this.lastClickTime=0,this.lastClickTarget=null):(this.scene.handleAgentClick(i.id,e),this.lastClickTime=n,this.lastClickTarget=i.id);else if(o)if(this.lastClickTarget===o.id&&n-this.lastClickTime<this.doubleClickDelay)this.scene.handleBuildingDoubleClick(o.id),this.lastClickTime=0,this.lastClickTarget=null;else{const l=this.canvas.getBoundingClientRect();this.scene.handleBuildingClick(o.id,{x:t+l.left,y:s+l.top}),this.lastClickTime=n,this.lastClickTarget=o.id}else{const l=this.scene.getAreaFolderIconAtScreenPos(t,s);if(l){this.scene.handleAreaFolderClick(l.areaId,l.folderPath),this.lastClickTime=0,this.lastClickTarget=null;return}const a=this.scene.getAreaAtScreenPos(t,s),r=this.camera.screenToWorld(t,s);if(a){const d=`area:${a.id}`;this.lastClickTarget===d&&n-this.lastClickTime<this.doubleClickDelay?(this.scene.selectArea(a.id),this.scene.handleAreaDoubleClick(a.id),this.lastClickTime=0,this.lastClickTarget=null):(this.scene.selectArea(a.id),this.lastClickTime=n,this.lastClickTarget=d)}else this.scene.selectArea(null),this.scene.handleGroundClick({x:r.x,z:r.z}),this.lastClickTime=0,this.lastClickTarget=null}}focusCameraOnAgent(t){const s=this.scene.getAgentData(t);s&&this.camera.focusOn(s.position.x,s.position.z,50)}focusCameraOnBuilding(t){const s=this.scene.getBuildingData(t);s&&this.camera.focusOn(s.position.x,s.position.z,40)}getSelectionBox(){return this.selectionBox}};u(E,"ENABLE_DOUBLE_CLICK_CAMERA_FOCUS",!1),u(E,"TOUCH_LONG_PRESS_DURATION",500),u(E,"TOUCH_DRAG_THRESHOLD",5),u(E,"TOUCH_INERTIA_DECAY",.9),u(E,"TOUCH_INERTIA_MIN_SPEED",.02);let St=E;class le{constructor(t,s){u(this,"viewportWidth");u(this,"viewportHeight");u(this,"posX",0);u(this,"posZ",0);u(this,"zoom",30);u(this,"minZoom",5);u(this,"maxZoom",150);u(this,"targetPosX",0);u(this,"targetPosZ",0);u(this,"targetZoom",30);u(this,"panSmoothing",.12);u(this,"zoomSmoothing",.15);u(this,"focusSmoothing",.08);u(this,"currentPanSmoothing",.12);u(this,"panLimitEnabled",!0);u(this,"panLimitRadius",50);u(this,"edgePanEnabled",!1);u(this,"edgePanMargin",40);u(this,"edgePanSpeed",8);u(this,"mouseScreenX",0);u(this,"mouseScreenY",0);u(this,"isAnimating",!1);u(this,"animationCallback",null);u(this,"saveTimeout",null);u(this,"needsSave",!1);this.viewportWidth=t,this.viewportHeight=s,this.loadState()}loadState(){const t=qt();t&&(this.posX=t.posX,this.posZ=t.posZ,this.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,t.zoom)),this.targetPosX=this.posX,this.targetPosZ=this.posZ,this.targetZoom=this.zoom)}scheduleSave(){this.needsSave=!0,!this.saveTimeout&&(this.saveTimeout=setTimeout(()=>{this.needsSave&&(Ct(this.posX,this.posZ,this.zoom),this.needsSave=!1),this.saveTimeout=null},500))}saveState(){this.saveTimeout&&(clearTimeout(this.saveTimeout),this.saveTimeout=null),Ct(this.posX,this.posZ,this.zoom),this.needsSave=!1}setViewportSize(t,s){this.viewportWidth=t,this.viewportHeight=s}getViewportSize(){return{width:this.viewportWidth,height:this.viewportHeight}}getPosition(){return{x:this.posX,z:this.posZ}}setPosition(t,s){const e=this.clampPosition(t,s);this.posX=e.x,this.posZ=e.z,this.targetPosX=e.x,this.targetPosZ=e.z}panTo(t,s,e=!0){const i=this.clampPosition(t,s);e?(this.targetPosX=i.x,this.targetPosZ=i.z,this.currentPanSmoothing=this.panSmoothing):(this.posX=i.x,this.posZ=i.z,this.targetPosX=i.x,this.targetPosZ=i.z)}panBy(t,s){const e=t/this.zoom,i=s/this.zoom,o=this.posX-e,n=this.posZ-i,l=this.clampPosition(o,n);this.posX=l.x,this.posZ=l.z,this.targetPosX=l.x,this.targetPosZ=l.z}focusOn(t,s,e,i){this.isAnimating=!0,this.animationCallback=i||null,this.currentPanSmoothing=this.focusSmoothing;const o=this.clampPosition(t,s);this.targetPosX=o.x,this.targetPosZ=o.z,e!==void 0&&(this.targetZoom=Math.max(this.minZoom,Math.min(this.maxZoom,e)))}focusOnBounds(t,s,e,i,o=2){const n=(t+s)/2,l=(e+i)/2,a=s-t+o*2,r=i-e+o*2,d=this.viewportWidth/a,h=this.viewportHeight/r,m=Math.min(d,h)*.9;this.focusOn(n,l,Math.max(this.minZoom,Math.min(this.maxZoom,m)))}getZoom(){return this.zoom}getZoomLimits(){return{min:this.minZoom,max:this.maxZoom}}setZoom(t){this.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,t)),this.targetZoom=this.zoom}setZoomLimits(t,s){this.minZoom=t,this.maxZoom=s,this.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.zoom)),this.targetZoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.targetZoom))}zoomTo(t,s=!0){const e=Math.max(this.minZoom,Math.min(this.maxZoom,t));s?this.targetZoom=e:(this.zoom=e,this.targetZoom=e)}zoomAtPoint(t,s,e,i=!0){const o=Math.max(this.minZoom,Math.min(this.maxZoom,this.targetZoom*(1+e)));if(i){const n=this.screenToWorld(t,s);this.targetZoom=o;const l=this.viewportWidth/2,a=this.viewportHeight/2,r=this.targetPosX+(t-l)/o,d=this.targetPosZ+(s-a)/o,h=n.x-r,m=n.z-d,f=this.clampPosition(this.targetPosX+h,this.targetPosZ+m);this.targetPosX=f.x,this.targetPosZ=f.z}else{const n=this.screenToWorld(t,s);this.zoom=o,this.targetZoom=o;const l=this.screenToWorld(t,s),a=this.clampPosition(this.posX+n.x-l.x,this.posZ+n.z-l.z);this.posX=a.x,this.posZ=a.z,this.targetPosX=a.x,this.targetPosZ=a.z}}setPanLimits(t,s){this.panLimitEnabled=t,s!==void 0&&(this.panLimitRadius=s)}getPanLimits(){return{enabled:this.panLimitEnabled,radius:this.panLimitRadius}}clampPosition(t,s){if(!this.panLimitEnabled)return{x:t,z:s};const e=Math.max(-this.panLimitRadius,Math.min(this.panLimitRadius,t)),i=Math.max(-this.panLimitRadius,Math.min(this.panLimitRadius,s));return{x:e,z:i}}setEdgePanning(t,s,e){this.edgePanEnabled=t,s!==void 0&&(this.edgePanMargin=s),e!==void 0&&(this.edgePanSpeed=e)}getEdgePanSettings(){return{enabled:this.edgePanEnabled,margin:this.edgePanMargin,speed:this.edgePanSpeed}}setMousePosition(t,s){this.mouseScreenX=t,this.mouseScreenY=s}processEdgePanning(t){if(!this.edgePanEnabled)return;let s=0,e=0;if(this.mouseScreenX<this.edgePanMargin?s=-1*(1-this.mouseScreenX/this.edgePanMargin):this.mouseScreenX>this.viewportWidth-this.edgePanMargin&&(s=1*(1-(this.viewportWidth-this.mouseScreenX)/this.edgePanMargin)),this.mouseScreenY<this.edgePanMargin?e=-1*(1-this.mouseScreenY/this.edgePanMargin):this.mouseScreenY>this.viewportHeight-this.edgePanMargin&&(e=1*(1-(this.viewportHeight-this.mouseScreenY)/this.edgePanMargin)),s!==0||e!==0){const i=this.edgePanSpeed*t,o=this.targetPosX+s*i,n=this.targetPosZ+e*i,l=this.clampPosition(o,n);this.targetPosX=l.x,this.targetPosZ=l.z}}screenToWorld(t,s){const e=this.viewportWidth/2,i=this.viewportHeight/2,o=this.posX+(t-e)/this.zoom,n=this.posZ+(s-i)/this.zoom;return{x:o,z:n}}worldToScreen(t,s){const e=this.viewportWidth/2,i=this.viewportHeight/2,o=e+(t-this.posX)*this.zoom,n=i+(s-this.posZ)*this.zoom;return{x:o,y:n}}getVisibleBounds(){const t=this.viewportWidth/2/this.zoom,s=this.viewportHeight/2/this.zoom;return{minX:this.posX-t,maxX:this.posX+t,minZ:this.posZ-s,maxZ:this.posZ+s}}isVisible(t,s,e=0){const i=this.getVisibleBounds();return t>=i.minX-e&&t<=i.maxX+e&&s>=i.minZ-e&&s<=i.maxZ+e}update(t=1/60){this.processEdgePanning(t);const s=1-Math.exp(-this.currentPanSmoothing*60*t),e=1-Math.exp(-this.zoomSmoothing*60*t),i=this.posX,o=this.posZ,n=this.zoom,l=.001,a=.01,r=Math.abs(this.targetPosX-this.posX)<l,d=Math.abs(this.targetPosZ-this.posZ)<l,h=Math.abs(this.targetZoom-this.zoom)<a;r?this.posX=this.targetPosX:this.posX+=(this.targetPosX-this.posX)*s,d?this.posZ=this.targetPosZ:this.posZ+=(this.targetPosZ-this.posZ)*s,h?this.zoom=this.targetZoom:this.zoom+=(this.targetZoom-this.zoom)*e;const m=r&&d,f=h;this.isAnimating&&m&&f&&(this.isAnimating=!1,this.currentPanSmoothing=this.panSmoothing,this.animationCallback&&(this.animationCallback(),this.animationCallback=null));const c=Math.abs(this.posX-i)>1e-4||Math.abs(this.posZ-o)>1e-4||Math.abs(this.zoom-n)>1e-4;return c&&this.scheduleSave(),c}isCurrentlyAnimating(){return Math.abs(this.posX-this.targetPosX)>.01||Math.abs(this.posZ-this.targetPosZ)>.01||Math.abs(this.zoom-this.targetZoom)>.1}applyTransform(t){t.save(),t.translate(this.viewportWidth/2,this.viewportHeight/2),t.scale(this.zoom,this.zoom),t.translate(-this.posX,-this.posZ)}restoreTransform(t){t.restore()}}const B={moveOrder:{primary:"#4aff9e",secondary:"#2ad87e"},bossLine:{primary:"#ffd700",secondary:"#ffaa00",glow:"rgba(255, 215, 0, 0.4)"},toolBubble:{background:["#2a3040","#1a2030"],border:"#4a9eff"}},O=class O{constructor(){u(this,"moveOrderEffects",[]);u(this,"toolBubbles",new Map);u(this,"statusParticles",[]);u(this,"animationTime",0)}update(t){const s=performance.now();this.animationTime+=t,this.moveOrderEffects=this.moveOrderEffects.filter(e=>s-e.startTime<e.duration);for(const[e,i]of this.toolBubbles)s-i.startTime>=i.duration&&this.toolBubbles.delete(e);this.statusParticles=this.statusParticles.filter(e=>s-e.startTime<e.duration);for(const e of this.statusParticles)e.position.x+=e.velocity.x*t,e.position.z+=e.velocity.z*t,e.velocity.z+=t*.5}hasActiveEffects(){return this.moveOrderEffects.length>0||this.toolBubbles.size>0||this.statusParticles.length>0}render(t,s){const e=performance.now();for(const i of this.moveOrderEffects)this.renderMoveOrderEffect(t,s,i,e);for(const i of this.statusParticles)this.renderStatusParticle(t,s,i,e);for(const i of this.toolBubbles.values())this.renderToolBubble(t,s,i,e)}addMoveOrderEffect(t){this.moveOrderEffects.push({position:{...t},startTime:performance.now(),duration:1500})}renderMoveOrderEffect(t,s,e,i){const o=Math.min(1,Math.max(0,(i-e.startTime)/e.duration)),n=s.getZoom(),l=Math.pow(1-o,1.5);s.applyTransform(t);const{x:a,z:r}=e.position,d=3;for(let b=0;b<d;b++){const S=Math.max(0,Math.min(1,o*1.5-b*.15));if(S<=0)continue;const x=l*(1-S)*(1-b*.25),A=.3+S*2,D=Math.max(1,3-S*2)/n,y=t.createRadialGradient(a,r,A*.8,a,r,A*1.2);y.addColorStop(0,this.hexToRgba(B.moveOrder.primary,x)),y.addColorStop(1,this.hexToRgba(B.moveOrder.secondary,x*.5)),t.strokeStyle=this.hexToRgba(B.moveOrder.primary,x*.3),t.lineWidth=D*3,t.beginPath(),t.arc(a,r,A,0,Math.PI*2),t.stroke(),t.strokeStyle=y,t.lineWidth=D,t.beginPath(),t.arc(a,r,A,0,Math.PI*2),t.stroke()}const h=l*.8,m=.25,f=this.animationTime*2;t.save(),t.translate(a,r),t.rotate(f),t.strokeStyle=this.hexToRgba(B.moveOrder.primary,h),t.lineWidth=2/n,t.lineCap="round";const c=m*.3,g=m;t.beginPath(),t.moveTo(0,-c),t.lineTo(0,-g),t.moveTo(0,c),t.lineTo(0,g),t.moveTo(-c,0),t.lineTo(-g,0),t.moveTo(c,0),t.lineTo(g,0),t.stroke(),t.restore();const p=i*.01%1,P=.06+Math.sin(p*Math.PI*2)*.02,w=t.createRadialGradient(a,r,0,a,r,P*2);w.addColorStop(0,this.hexToRgba(B.moveOrder.primary,h)),w.addColorStop(.5,this.hexToRgba(B.moveOrder.secondary,h*.8)),w.addColorStop(1,this.hexToRgba(B.moveOrder.secondary,0)),t.fillStyle=w,t.beginPath(),t.arc(a,r,P*2,0,Math.PI*2),t.fill(),s.restoreTransform(t)}addToolBubble(t,s,e){this.toolBubbles.set(t,{agentId:t,position:{...s},text:e,startTime:performance.now(),duration:4e3})}updateToolBubblePosition(t,s){const e=this.toolBubbles.get(t);e&&(e.position={...s})}removeToolBubble(t){this.toolBubbles.delete(t)}renderToolBubble(t,s,e,i){const o=(i-e.startTime)/e.duration;let n=1;o<.1?n=this.easeOutCubic(o/.1):o>.75&&(n=this.easeInCubic((1-o)/.25));const l=Math.sin(o*Math.PI*4)*.03+o*.15,a=s.worldToScreen(e.position.x,e.position.z-1.2-l),r=Math.max(11,Math.min(14,12*s.getZoom()));t.font=`bold ${r}px "Segoe UI", Arial, sans-serif`;const h=t.measureText(e.text).width,m=10,f=h+m*2,c=r+m*1.5,g=6,p=a.x-f/2,P=a.y-c/2;t.fillStyle=`rgba(0, 0, 0, ${.3*n})`,t.beginPath(),this.roundedRect(t,p+2,P+3,f,c,g),t.fill();const w=t.createLinearGradient(p,P,p,P+c);w.addColorStop(0,this.hexToRgba(B.toolBubble.background[0],n*.95)),w.addColorStop(1,this.hexToRgba(B.toolBubble.background[1],n*.98)),t.fillStyle=w,t.beginPath(),this.roundedRect(t,p,P,f,c,g),t.fill();const b=t.createLinearGradient(p+g,P+1,p+f-g,P+1);b.addColorStop(0,"transparent"),b.addColorStop(.2,`rgba(255, 255, 255, ${n*.15})`),b.addColorStop(.8,`rgba(255, 255, 255, ${n*.15})`),b.addColorStop(1,"transparent"),t.strokeStyle=b,t.lineWidth=1,t.beginPath(),t.moveTo(p+g,P+1),t.lineTo(p+f-g,P+1),t.stroke();const S=t.createLinearGradient(p,P,p,P+c);S.addColorStop(0,this.hexToRgba(B.toolBubble.border,n*.8)),S.addColorStop(1,this.hexToRgba(B.toolBubble.border,n*.5)),t.strokeStyle=S,t.lineWidth=1.5,t.beginPath(),this.roundedRect(t,p,P,f,c,g),t.stroke();const x=8,A=6,D=a.x,y=P+c;t.fillStyle=this.hexToRgba(B.toolBubble.background[1],n*.98),t.beginPath(),t.moveTo(D-x/2,y),t.lineTo(D+x/2,y),t.lineTo(D,y+A),t.closePath(),t.fill(),t.strokeStyle=this.hexToRgba(B.toolBubble.border,n*.6),t.lineWidth=1.5,t.beginPath(),t.moveTo(D-x/2-.5,y),t.lineTo(D,y+A),t.lineTo(D+x/2+.5,y),t.stroke();const T=r*.9;t.font=`${T}px "Segoe UI Emoji", "Apple Color Emoji", serif`,t.fillStyle=this.hexToRgba("#ffcc00",n),t.textAlign="left",t.textBaseline="middle",t.font=`bold ${r}px "Segoe UI", Arial, sans-serif`,t.fillStyle=`rgba(255, 255, 255, ${n})`,t.textAlign="center",t.textBaseline="middle",t.fillText(e.text,a.x,a.y)}renderBossLine(t,s,e,i){s.applyTransform(t);const o=s.getZoom(),n=i.x-e.x,l=i.z-e.z,a=Math.sqrt(n*n+l*l),r=Math.atan2(l,n),d=t.createLinearGradient(e.x,e.z,i.x,i.z);d.addColorStop(0,this.hexToRgba(B.bossLine.primary,.7)),d.addColorStop(.5,this.hexToRgba(B.bossLine.secondary,.5)),d.addColorStop(1,this.hexToRgba(B.bossLine.primary,.7)),t.strokeStyle=B.bossLine.glow,t.lineWidth=6/o,t.lineCap="round",t.beginPath(),t.moveTo(e.x,e.z),t.lineTo(i.x,i.z),t.stroke(),t.strokeStyle=d,t.lineWidth=2.5/o,t.setLineDash([8/o,4/o]),t.lineDashOffset=0,t.beginPath(),t.moveTo(e.x,e.z),t.lineTo(i.x,i.z),t.stroke(),t.setLineDash([]);const h=Math.max(2,Math.floor(a/1.5)),m=.06;for(let p=0;p<=h;p++){const P=p/h,w=e.x+n*P,b=e.z+l*P,S=.35;t.fillStyle=this.hexToRgba(B.bossLine.primary,S),t.beginPath(),t.arc(w,b,m,0,Math.PI*2),t.fill()}const f=.2,c=Math.PI/6,g={x:i.x-Math.cos(r)*.3,z:i.z-Math.sin(r)*.3};t.fillStyle=this.hexToRgba(B.bossLine.primary,.8),t.beginPath(),t.moveTo(g.x,g.z),t.lineTo(g.x-Math.cos(r-c)*f,g.z-Math.sin(r-c)*f),t.lineTo(g.x-Math.cos(r+c)*f,g.z-Math.sin(r+c)*f),t.closePath(),t.fill(),s.restoreTransform(t)}addStatusChangeEffect(t,s){for(let i=0;i<8;i++){const o=i/8*Math.PI*2+Math.random()*.5,n=.5+Math.random()*.8;this.statusParticles.push({position:{...t},velocity:{x:Math.cos(o)*n,z:Math.sin(o)*n-1},color:s,size:.05+Math.random()*.04,startTime:performance.now(),duration:800+Math.random()*400})}}renderStatusParticle(t,s,e,i){const o=(i-e.startTime)/e.duration,n=this.easeOutCubic(1-o),l=e.size*(1-o*.5);s.applyTransform(t);const{x:a,z:r}=e.position,d=t.createRadialGradient(a,r,0,a,r,l*1.5);d.addColorStop(0,this.hexToRgba("#ffffff",n)),d.addColorStop(.2,this.hexToRgba(e.color,n)),d.addColorStop(.6,this.hexToRgba(e.color,n*.4)),d.addColorStop(1,this.hexToRgba(e.color,0)),t.fillStyle=d,t.beginPath(),t.arc(a,r,l*1.5,0,Math.PI*2),t.fill(),s.restoreTransform(t)}addSelectionSparkle(t,s){for(let e=0;e<4;e++){const i=Math.random()*Math.PI*2,o=.3+Math.random()*.2;this.statusParticles.push({position:{x:t.x+Math.cos(i)*o,z:t.z+Math.sin(i)*o},velocity:{x:Math.cos(i)*.3,z:-.5-Math.random()*.3},color:s,size:.04+Math.random()*.03,startTime:performance.now(),duration:500+Math.random()*300})}}roundedRect(t,s,e,i,o,n){t.moveTo(s+n,e),t.lineTo(s+i-n,e),t.arcTo(s+i,e,s+i,e+n,n),t.lineTo(s+i,e+o-n),t.arcTo(s+i,e+o,s+i-n,e+o,n),t.lineTo(s+n,e+o),t.arcTo(s,e+o,s,e+o-n,n),t.lineTo(s,e+n),t.arcTo(s,e,s+n,e,n)}hexToRgba(t,s){const e=Math.round(s*100)/100,i=`${t}|${e}`;let o=O.rgbaCache.get(i);if(o)return o;let n,l,a;if(t.startsWith("rgba")||t.startsWith("rgb")){const d=t.match(/[\d.]+/g);if(d)return n=parseInt(d[0]),l=parseInt(d[1]),a=parseInt(d[2]),o=`rgba(${n}, ${l}, ${a}, ${e})`,O.rgbaCache.size>=O.RGBA_CACHE_MAX&&O.rgbaCache.clear(),O.rgbaCache.set(i,o),o}const r=t.replace("#","");return r.length===3?(n=parseInt(r[0]+r[0],16),l=parseInt(r[1]+r[1],16),a=parseInt(r[2]+r[2],16)):(n=parseInt(r.slice(0,2),16),l=parseInt(r.slice(2,4),16),a=parseInt(r.slice(4,6),16)),o=`rgba(${n}, ${l}, ${a}, ${e})`,O.rgbaCache.size>=O.RGBA_CACHE_MAX&&O.rgbaCache.clear(),O.rgbaCache.set(i,o),o}easeOutCubic(t){return 1-Math.pow(1-t,3)}easeInCubic(t){return t*t*t}clear(){this.moveOrderEffects=[],this.toolBubbles.clear(),this.statusParticles=[]}};u(O,"rgbaCache",new Map),u(O,"RGBA_CACHE_MAX",256);let Tt=O;const U=class U{constructor(t){u(this,"canvas");u(this,"ctx");u(this,"renderer");u(this,"input");u(this,"camera");u(this,"effects");u(this,"staticCanvas");u(this,"staticCtx");u(this,"staticRenderer");u(this,"staticDirty",!0);u(this,"needsRender",!0);u(this,"agents",new Map);u(this,"buildings",new Map);u(this,"areas",new Map);u(this,"selectedAgentIds",new Set);u(this,"selectedBuildingIds",new Set);u(this,"animationFrameId",null);u(this,"lastFrameTime",0);u(this,"lastAnimationTime",0);u(this,"lastRenderTime",0);u(this,"isRunning",!1);u(this,"fpsLimit",0);u(this,"frameInterval",0);u(this,"currentDpr",1);u(this,"movements",new Map);u(this,"callbacks",{});u(this,"indicatorScale",.7);u(this,"showTaskLabels",!0);u(this,"showGrid",!0);u(this,"gridSize",30);u(this,"gridSpacing",2);u(this,"drawingTool",null);u(this,"isDrawing",!1);u(this,"drawStartPos",null);u(this,"drawCurrentPos",null);u(this,"sortedAreasAsc",[]);u(this,"sortedAreasDesc",[]);u(this,"areasSortDirty",!0);u(this,"selectedAreaId",null);u(this,"isResizingArea",!1);u(this,"resizeHandleType",null);u(this,"resizeStartPos",null);u(this,"resizeOriginalArea",null);u(this,"areaDragAgentStartPositions",new Map);u(this,"areaDragBuildingStartPositions",new Map);u(this,"handleResize",()=>{const t=this.canvas.parentElement;if(!t)return;let s=Math.min(window.devicePixelRatio||1,U.MAX_DPR);const e=t.clientWidth,i=t.clientHeight,o=4e6;e*i*s*s>o&&(s=Math.sqrt(o/(e*i))),this.currentDpr=s,this.canvas.width=e*s,this.canvas.height=i*s,this.canvas.style.width=`${e}px`,this.canvas.style.height=`${i}px`,this.staticCanvas.width=e*s,this.staticCanvas.height=i*s,this.ctx.setTransform(1,0,0,1,0,0),this.ctx.scale(s,s),this.staticCtx.setTransform(1,0,0,1,0,0),this.staticCtx.scale(s,s),this.camera.setViewportSize(e,i),this.staticDirty=!0,this.needsRender=!0});u(this,"animate",()=>{if(!this.isRunning)return;this.animationFrameId=requestAnimationFrame(this.animate);const t=performance.now(),s=(t-this.lastFrameTime)/1e3;this.lastFrameTime=t,this.camera.update(s);const e=this.movements.size>0,i=this.effects.hasActiveEffects(),o=this.isDrawing||this.isResizingArea||this.input.getSelectionBox()!==null,n=this.hasWorkingAgents(),l=e||i||o||this.camera.isCurrentlyAnimating(),a=this.hasCameraChanged();if(a&&(this.staticDirty=!0,this.needsRender=!0),(l||n)&&(this.needsRender=!0),!this.needsRender&&this.agents.size===0)return;const r=1e3/U.IDLE_FPS_LIMIT,d=1e3/U.WORKING_FPS_LIMIT;let h;if(l||a?h=this.frameInterval:n?h=this.frameInterval>0?Math.min(this.frameInterval,d):d:h=this.frameInterval>0?Math.min(this.frameInterval,r):r,h>0){if(t-this.lastRenderTime<h)return;this.lastRenderTime=t}Nt.tick();const m=(t-this.lastAnimationTime)/1e3;this.lastAnimationTime=t,this.updateMovements(t),(l||n)&&(this.effects.update(m),this.renderer.update(m),this.staticRenderer.update(m)),this.render(),!l&&!n&&(this.needsRender=!1)});u(this,"lastCamX",NaN);u(this,"lastCamZ",NaN);u(this,"lastCamZoom",NaN);this.canvas=t;const s=t.getContext("2d");if(!s)throw new Error("Failed to get 2D context");this.ctx=s,this.staticCanvas=document.createElement("canvas");const e=this.staticCanvas.getContext("2d");if(!e)throw new Error("Failed to get static 2D context");this.staticCtx=e,this.camera=new le(t.width,t.height),this.renderer=new Rt(s,this.camera),this.staticRenderer=new Rt(e,this.camera),this.effects=new Tt,this.input=new St(t,this.camera,this),this.handleResize(),window.addEventListener("resize",this.handleResize)}start(){this.isRunning||(this.isRunning=!0,this.lastFrameTime=performance.now(),this.lastAnimationTime=this.lastFrameTime,this.animate())}stop(){this.isRunning=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}dispose(){this.stop(),this.camera.saveState(),window.removeEventListener("resize",this.handleResize),this.input.dispose(),this.agents.clear(),this.buildings.clear(),this.areas.clear(),this.invalidateAreaSort(),this.staticCanvas.width=0,this.staticCanvas.height=0}hasCameraChanged(){const t=this.camera.getPosition(),s=this.camera.getZoom(),e=Math.round(t.x*1e3),i=Math.round(t.z*1e3),o=Math.round(s*1e3);return e!==this.lastCamX||i!==this.lastCamZ||o!==this.lastCamZoom?(this.lastCamX=e,this.lastCamZ=i,this.lastCamZoom=o,!0):!1}markStaticDirty(){this.staticDirty=!0,this.needsRender=!0}markDirty(){this.needsRender=!0}invalidateAreaSort(){this.areasSortDirty=!0}getSortedAreasAsc(){return this.areasSortDirty&&(this.sortedAreasAsc=Array.from(this.areas.values()).sort((t,s)=>t.zIndex-s.zIndex),this.sortedAreasDesc=Array.from(this.areas.values()).sort((t,s)=>s.zIndex-t.zIndex),this.areasSortDirty=!1),this.sortedAreasAsc}getSortedAreasDesc(){return this.areasSortDirty&&(this.sortedAreasAsc=Array.from(this.areas.values()).sort((t,s)=>t.zIndex-s.zIndex),this.sortedAreasDesc=Array.from(this.areas.values()).sort((t,s)=>s.zIndex-t.zIndex),this.areasSortDirty=!1),this.sortedAreasDesc}hasWorkingAgents(){for(const t of this.agents.values())if(t.status==="working")return!0;return!1}isPointVisible(t,s,e=0){return this.camera.isVisible(t,s,e)}isAreaVisible(t){const s=this.camera.getVisibleBounds(),e=2;if(t.type==="rectangle"&&"width"in t.size){const i=t.position.x-t.size.width/2,o=t.position.x+t.size.width/2,n=t.position.z-t.size.height/2,l=t.position.z+t.size.height/2;return!(o<s.minX-e||i>s.maxX+e||l<s.minZ-e||n>s.maxZ+e)}if(t.type==="circle"&&"radius"in t.size){const i=t.size.radius;return!(t.position.x+i<s.minX-e||t.position.x-i>s.maxX+e||t.position.z+i<s.minZ-e||t.position.z-i>s.maxZ+e)}return!0}updateMovements(t){const s=[];for(const[e,i]of this.movements){const o=t-i.startTime,n=Math.min(1,o/i.duration),l=1-Math.pow(1-n,3),a=this.agents.get(e);a&&(a.position.x=i.startPos.x+(i.endPos.x-i.startPos.x)*l,a.position.z=i.startPos.z+(i.endPos.z-i.startPos.z)*l),n>=1&&s.push(e)}for(const e of s)this.movements.delete(e)}render(){const{width:t,height:s}=this.canvas,e=this.currentDpr,i=t/e,o=s/e;if(this.staticDirty){this.staticCtx.clearRect(0,0,i,o),this.staticRenderer.drawGround(this.gridSize),this.showGrid&&this.staticRenderer.drawGrid(this.gridSize,this.gridSpacing);for(const a of this.getSortedAreasAsc()){if(!this.isAreaVisible(a))continue;const r=a.id===this.selectedAreaId;this.staticRenderer.drawArea(a,r)}for(const a of this.buildings.values()){if(!this.isPointVisible(a.position.x,a.position.z,2))continue;const r=this.selectedBuildingIds.has(a.id);this.staticRenderer.drawBuilding(a,r)}this.staticDirty=!1}this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.staticCanvas,0,0),this.ctx.restore(),this.renderBossLines(),this.renderer.beginAgentFrame();for(const a of this.agents.values()){if(!this.isPointVisible(a.position.x,a.position.z,2.5))continue;const r=this.selectedAgentIds.has(a.id),d=this.movements.has(a.id);this.renderer.drawAgent(a,r,d,this.indicatorScale,this.showTaskLabels)}this.effects.render(this.ctx,this.camera);const n=this.input.getSelectionBox();n&&this.renderer.drawSelectionBox(n.start,n.end);const l=this.getDrawingPreview();l&&this.renderer.drawAreaPreview(l.start,l.end,l.tool)}renderBossLines(){var s;const t=new Set;for(const e of this.selectedAgentIds){const i=this.agents.get(e);if(i){if(i.isBoss&&i.subordinateIds)for(const o of i.subordinateIds){const n=this.agents.get(o);n&&(this.isPointVisible(i.position.x,i.position.z,2.5)||this.isPointVisible(n.position.x,n.position.z,2.5))&&(t.add(`${i.id}:${n.id}`),this.effects.renderBossLine(this.ctx,this.camera,i.position,n.position))}if(i.bossId){const o=this.agents.get(i.bossId),n=o?`${o.id}:${i.id}`:null,l=!(o!=null&&o.subordinateIds)||o.subordinateIds.includes(i.id);o&&n&&l&&!t.has(n)&&(this.isPointVisible(o.position.x,o.position.z,2.5)||this.isPointVisible(i.position.x,i.position.z,2.5))&&(t.add(n),this.effects.renderBossLine(this.ctx,this.camera,o.position,i.position))}}}for(const e of this.selectedBuildingIds){const i=this.buildings.get(e);if(i&&i.subordinateBuildingIds&&i.subordinateBuildingIds.length>0)for(const o of i.subordinateBuildingIds){const n=this.buildings.get(o);n&&(this.isPointVisible(i.position.x,i.position.z,2)||this.isPointVisible(n.position.x,n.position.z,2))&&this.effects.renderBossLine(this.ctx,this.camera,i.position,n.position)}}for(const e of this.selectedBuildingIds)for(const i of this.buildings.values())if((s=i.subordinateBuildingIds)!=null&&s.includes(e)){for(const o of i.subordinateBuildingIds){const n=this.buildings.get(o);n&&(this.isPointVisible(i.position.x,i.position.z,2)||this.isPointVisible(n.position.x,n.position.z,2))&&this.effects.renderBossLine(this.ctx,this.camera,i.position,n.position)}break}}addAgent(t){const s=xt[t.class],e=(s==null?void 0:s.color)??16777215;this.agents.set(t.id,{id:t.id,position:{x:t.position.x,z:t.position.z},name:t.name,class:t.class,status:t.status,isBoss:t.isBoss===!0||t.class==="boss",color:e,contextRemaining:bt(t).freePercent,lastActivity:t.lastActivity,subordinateIds:t.subordinateIds,bossId:t.bossId,currentTool:t.currentTool,contextUsed:t.contextUsed,contextLimit:t.contextLimit,contextStats:t.contextStats,provider:t.provider}),this.markDirty()}removeAgent(t){this.agents.delete(t),this.movements.delete(t),this.selectedAgentIds.delete(t),this.markDirty()}updateAgent(t,s=!0){const e=this.agents.get(t.id);if(!e){this.addAgent(t);return}const i=xt[t.class],o=(i==null?void 0:i.color)??16777215,n=this.movements.get(t.id),l=.01;let a;if(n){const r=Math.abs(n.endPos.x-t.position.x),d=Math.abs(n.endPos.z-t.position.z);a=r>l||d>l}else{const r=Math.abs(e.position.x-t.position.x),d=Math.abs(e.position.z-t.position.z);a=r>l||d>l}if(a&&s){const d=Math.sqrt(Math.pow(t.position.x-e.position.x,2)+Math.pow(t.position.z-e.position.z,2))/2*1e3;this.movements.set(t.id,{startPos:{x:e.position.x,z:e.position.z},endPos:{x:t.position.x,z:t.position.z},startTime:performance.now(),duration:Math.max(500,Math.min(d,3e3))})}else a&&!s&&!n&&(e.position.x=t.position.x,e.position.z=t.position.z);e.name=t.name,e.class=t.class,e.status=t.status,e.isBoss=t.isBoss===!0||t.class==="boss",e.color=o,e.contextRemaining=bt(t).freePercent,e.lastActivity=t.lastActivity,e.subordinateIds=t.subordinateIds,e.bossId=t.bossId,e.currentTool=t.currentTool,e.contextUsed=t.contextUsed,e.contextLimit=t.contextLimit,e.contextStats=t.contextStats,e.provider=t.provider,e.taskLabel=t.taskLabel,this.markDirty()}syncAgents(t){const s=new Set(t.map(e=>e.id));for(const e of this.agents.keys())(!s.has(e)||z.isAgentInArchivedArea(e))&&this.removeAgent(e);for(const e of t)z.isAgentInArchivedArea(e.id)||this.updateAgent(e,!1)}addBuilding(t){this.buildings.set(t.id,{id:t.id,position:{x:t.position.x,z:t.position.z},name:t.name,style:t.style,status:t.status,color:t.color,scale:t.scale||1,subordinateBuildingIds:t.subordinateBuildingIds,gitChangesCount:t.gitChangesCount}),this.markStaticDirty()}removeBuilding(t){this.buildings.delete(t),this.selectedBuildingIds.delete(t),this.markStaticDirty()}updateBuilding(t){const s=this.buildings.get(t.id);if(!s){this.addBuilding(t);return}s.position.x=t.position.x,s.position.z=t.position.z,s.name=t.name,s.style=t.style,s.status=t.status,s.color=t.color,s.scale=t.scale||1,s.subordinateBuildingIds=t.subordinateBuildingIds,s.gitChangesCount=t.gitChangesCount,this.markStaticDirty()}syncBuildings(){this.markStaticDirty();const t=z.getState(),s=new Set(t.buildings.keys());for(const e of this.buildings.keys())s.has(e)||this.removeBuilding(e);for(const e of t.buildings.values())this.updateBuilding(e)}syncAreas(){var s;const t=z.getState();this.areas.clear(),this.invalidateAreaSort(),this.markStaticDirty();for(const e of t.areas.values()){if(e.archived)continue;const i=e.directories&&e.directories.length>0,o=(s=e.logo)!=null&&s.filename?{url:Ut(jt(`/api/areas/logos/${e.logo.filename}`)),position:e.logo.position,width:e.logo.width,height:e.logo.height,opacity:e.logo.opacity??.8}:void 0;e.type==="rectangle"&&e.width&&e.height?this.areas.set(e.id,{id:e.id,type:"rectangle",position:{x:e.center.x,z:e.center.z},size:{width:e.width,height:e.height},color:e.color,label:e.name,zIndex:e.zIndex??0,directories:[...e.directories],hasDirectories:i,directoryGitCounts:e.directoryGitCounts?[...e.directoryGitCounts]:void 0,logo:o}):e.type==="circle"&&e.radius&&this.areas.set(e.id,{id:e.id,type:"circle",position:{x:e.center.x,z:e.center.z},size:{radius:e.radius},color:e.color,label:e.name,zIndex:e.zIndex??0,directories:[...e.directories],hasDirectories:i,directoryGitCounts:e.directoryGitCounts?[...e.directoryGitCounts]:void 0,logo:o})}}getSelectedAreaId(){return this.selectedAreaId}selectArea(t){this.selectedAreaId=t,z.selectArea(t),this.markStaticDirty()}isAreaSelected(){return this.selectedAreaId!==null}getAreaHandleAtWorldPos(t,s){if(!this.selectedAreaId)return null;const e=this.areas.get(this.selectedAreaId);if(!e)return null;const i=.4,o=this.camera.getZoom(),n=i*(30/Math.max(o,10)),l=t-e.position.x,a=s-e.position.z;if(Math.sqrt(l*l+a*a)<=n)return{areaId:e.id,handleType:"move"};if(e.type==="rectangle"&&"width"in e.size){const{width:r,height:d}=e.size,h=[{type:"nw",x:e.position.x-r/2,z:e.position.z-d/2},{type:"ne",x:e.position.x+r/2,z:e.position.z-d/2},{type:"sw",x:e.position.x-r/2,z:e.position.z+d/2},{type:"se",x:e.position.x+r/2,z:e.position.z+d/2}];for(const f of h){const c=t-f.x,g=s-f.z;if(Math.sqrt(c*c+g*g)<=n)return{areaId:e.id,handleType:f.type}}const m=[{type:"n",x:e.position.x,z:e.position.z-d/2},{type:"s",x:e.position.x,z:e.position.z+d/2},{type:"e",x:e.position.x+r/2,z:e.position.z},{type:"w",x:e.position.x-r/2,z:e.position.z}];for(const f of m){const c=t-f.x,g=s-f.z;if(Math.sqrt(c*c+g*g)<=n)return{areaId:e.id,handleType:f.type}}}else if(e.type==="circle"&&"radius"in e.size){const r=e.position.x+e.size.radius,d=e.position.z,h=t-r,m=s-d;if(Math.sqrt(h*h+m*m)<=n)return{areaId:e.id,handleType:"radius"}}return null}startAreaResize(t,s){if(!this.selectedAreaId)return;const e=this.areas.get(this.selectedAreaId);if(e&&(this.isResizingArea=!0,this.resizeHandleType=t,this.resizeStartPos={...s},this.resizeOriginalArea={...e,size:{...e.size}},this.areaDragAgentStartPositions.clear(),this.areaDragBuildingStartPositions.clear(),t==="move")){const i=z.getState();for(const o of i.agents.values())this.isPointInsideArea(o.position.x,o.position.z,e)&&this.areaDragAgentStartPositions.set(o.id,{...o.position});for(const o of i.buildings.values())this.isPointInsideArea(o.position.x,o.position.z,e)&&this.areaDragBuildingStartPositions.set(o.id,{...o.position})}}updateAreaResize(t){if(!this.isResizingArea||!this.resizeOriginalArea||!this.resizeHandleType||!this.resizeStartPos)return;const s=this.resizeOriginalArea;let e={};if(this.resizeHandleType==="move"){const i=t.x-this.resizeStartPos.x,o=t.z-this.resizeStartPos.z;e={center:{x:s.position.x+i,z:s.position.z+o}};for(const[n,l]of this.areaDragAgentStartPositions)z.moveAgentLocal(n,{x:l.x+i,y:l.y,z:l.z+o});for(const[n,l]of this.areaDragBuildingStartPositions)z.updateBuildingLocal(n,{position:{x:l.x+i,z:l.z+o}})}else if(s.type==="rectangle"&&"width"in s.size){const i=t.x-this.resizeStartPos.x,o=t.z-this.resizeStartPos.z,n=s.size.width,l=s.size.height,a=s.position.x,r=s.position.z,d=c=>{const g=Math.max(.5,n+c);return{width:g,cx:a+(g-n)/2}},h=c=>{const g=Math.max(.5,n-c);return{width:g,cx:a+(n-g)/2}},m=c=>{const g=Math.max(.5,l+c);return{height:g,cz:r+(g-l)/2}},f=c=>{const g=Math.max(.5,l-c);return{height:g,cz:r+(l-g)/2}};switch(this.resizeHandleType){case"se":{const c=d(i),g=m(o);e={width:c.width,height:g.height,center:{x:c.cx,z:g.cz}};break}case"sw":{const c=h(i),g=m(o);e={width:c.width,height:g.height,center:{x:c.cx,z:g.cz}};break}case"ne":{const c=d(i),g=f(o);e={width:c.width,height:g.height,center:{x:c.cx,z:g.cz}};break}case"nw":{const c=h(i),g=f(o);e={width:c.width,height:g.height,center:{x:c.cx,z:g.cz}};break}case"e":{const c=d(i);e={width:c.width,center:{x:c.cx,z:r}};break}case"w":{const c=h(i);e={width:c.width,center:{x:c.cx,z:r}};break}case"s":{const c=m(o);e={height:c.height,center:{x:a,z:c.cz}};break}case"n":{const c=f(o);e={height:c.height,center:{x:a,z:c.cz}};break}}}else if(s.type==="circle"&&this.resizeHandleType==="radius"){const i=t.x-s.position.x,o=t.z-s.position.z;e={radius:Math.max(.5,Math.sqrt(i*i+o*o))}}Object.keys(e).length>0&&(z.updateArea(this.selectedAreaId,e),this.syncAreas())}finishAreaResize(){if(this.resizeHandleType==="move"&&this.resizeOriginalArea&&this.resizeStartPos){const t=z.getState(),s=this.selectedAreaId?t.areas.get(this.selectedAreaId):null;if(s){const e=s.center.x-this.resizeOriginalArea.position.x,i=s.center.z-this.resizeOriginalArea.position.z;if(e!==0||i!==0){for(const[o,n]of this.areaDragAgentStartPositions)z.moveAgent(o,{x:n.x+e,y:n.y,z:n.z+i});for(const[o,n]of this.areaDragBuildingStartPositions)z.moveBuilding(o,{x:n.x+e,z:n.z+i})}}}this.isResizingArea=!1,this.resizeHandleType=null,this.resizeStartPos=null,this.resizeOriginalArea=null,this.areaDragAgentStartPositions.clear(),this.areaDragBuildingStartPositions.clear()}isPointInsideArea(t,s,e){if(e.type==="rectangle"&&"width"in e.size){const i=e.size.width/2,o=e.size.height/2;return t>=e.position.x-i&&t<=e.position.x+i&&s>=e.position.z-o&&s<=e.position.z+o}if(e.type==="circle"&&"radius"in e.size){const i=t-e.position.x,o=s-e.position.z;return i*i+o*o<=e.size.radius*e.size.radius}return!1}isCurrentlyResizingArea(){return this.isResizingArea}setSelectedAgents(t){this.selectedAgentIds=new Set(t),this.markDirty()}setSelectedBuildings(t){this.selectedBuildingIds=new Set(t),this.markStaticDirty()}refreshSelectionVisuals(){const t=z.getState();this.selectedAgentIds=new Set(t.selectedAgentIds),this.selectedBuildingIds=new Set(t.selectedBuildingIds),this.markStaticDirty()}createMoveOrderEffect(t){this.effects.addMoveOrderEffect(t),this.markDirty()}callSubordinates(t){var n;const e=z.getState().agents.get(t);if(!e||!(e.isBoss||e.class==="boss")||!((n=e.subordinateIds)!=null&&n.length))return;const i={x:e.position.x,z:e.position.z},o=this.calculateFormationPositions(i,e.subordinateIds.length);this.effects.addMoveOrderEffect(i),e.subordinateIds.forEach((l,a)=>{const r=o[a];z.moveAgent(l,{x:r.x,y:0,z:r.z});const d=this.agents.get(l);if(d){const m=Math.sqrt(Math.pow(r.x-d.position.x,2)+Math.pow(r.z-d.position.z,2))/2*1e3;this.movements.set(l,{startPos:{x:d.position.x,z:d.position.z},endPos:{x:r.x,z:r.z},startTime:performance.now(),duration:Math.max(500,Math.min(m,3e3))})}})}calculateFormationPositions(t,s){const e=[];if(s===1)return[{x:t.x,z:t.z}];if(s<=6){const i=nt*Math.max(1,s/3);for(let o=0;o<s;o++){const n=o/s*Math.PI*2-Math.PI/2;e.push({x:t.x+Math.cos(n)*i,z:t.z+Math.sin(n)*i})}}else{const i=Math.ceil(Math.sqrt(s)),o=Math.ceil(s/i),n=(i-1)*nt/2,l=(o-1)*nt/2;for(let a=0;a<s;a++){const r=a%i,d=Math.floor(a/i);e.push({x:t.x+r*nt-n,z:t.z+d*nt-l})}}return e}showToolBubble(t,s){const e=this.agents.get(t);e&&(this.effects.addToolBubble(t,e.position,s),this.markDirty())}focusAgent(t,s){const e=this.agents.get(t);e&&this.camera.focusOn(e.position.x,e.position.z,s)}focusBuilding(t,s){const e=this.buildings.get(t);e&&this.camera.focusOn(e.position.x,e.position.z,s)}focusOnContent(){if(this.agents.size===0&&this.buildings.size===0){this.camera.focusOn(0,0,30);return}let t=1/0,s=-1/0,e=1/0,i=-1/0;for(const o of this.agents.values())t=Math.min(t,o.position.x),s=Math.max(s,o.position.x),e=Math.min(e,o.position.z),i=Math.max(i,o.position.z);for(const o of this.buildings.values())t=Math.min(t,o.position.x),s=Math.max(s,o.position.x),e=Math.min(e,o.position.z),i=Math.max(i,o.position.z);this.camera.focusOnBounds(t,s,e,i,3)}getCamera(){return this.camera}setIndicatorScale(t){this.indicatorScale=t,this.needsRender=!0}setTaskLabelsVisible(t){this.showTaskLabels=t,this.needsRender=!0}setGridVisible(t){this.showGrid=t,this.markStaticDirty()}setFpsLimit(t){this.fpsLimit=t,this.frameInterval=t>0?1e3/t:0,console.log(`[Tide 2D] FPS limit set to ${t}, frameInterval: ${this.frameInterval}ms`)}setCallbacks(t){this.callbacks={...this.callbacks,...t}}handleAgentClick(t,s){var e,i;(i=(e=this.callbacks).onAgentClick)==null||i.call(e,t,s)}handleAgentDoubleClick(t){var s,e;(e=(s=this.callbacks).onAgentDoubleClick)==null||e.call(s,t)}handleAgentHover(t,s){var e,i;(i=(e=this.callbacks).onAgentHover)==null||i.call(e,t,s)}handleBuildingClick(t,s){var e,i;(i=(e=this.callbacks).onBuildingClick)==null||i.call(e,t,s)}handleBuildingDoubleClick(t){var s,e;(e=(s=this.callbacks).onBuildingDoubleClick)==null||e.call(s,t)}handleBuildingHover(t){}handleAgentDragMove(t,s){const e=this.agents.get(t);e&&(this.movements.delete(t),e.position.x=s.x,e.position.z=s.z)}handleAgentDragEnd(t,s){z.moveAgent(t,{x:s.x,y:0,z:s.z}),this.createMoveOrderEffect(s)}handleAgentDragCancel(t){const e=z.getState().agents.get(t),i=this.agents.get(t);i&&e&&(i.position.x=e.position.x,i.position.z=e.position.z)}handleBuildingDragStart(t,s){var e,i;(i=(e=this.callbacks).onBuildingDragStart)==null||i.call(e,t,s)}handleBuildingDragMove(t,s){var e,i;(i=(e=this.callbacks).onBuildingDragMove)==null||i.call(e,t,s)}handleBuildingDragEnd(t,s){var e,i;(i=(e=this.callbacks).onBuildingDragEnd)==null||i.call(e,t,s)}handleBuildingDragCancel(t){var s,e;(e=(s=this.callbacks).onBuildingDragCancel)==null||e.call(s,t)}handleContextMenu(t,s,e){var i,o;(o=(i=this.callbacks).onContextMenu)==null||o.call(i,t,s,e)}handleGroundClick(t){var s,e;(e=(s=this.callbacks).onGroundClick)==null||e.call(s,t)}handleAreaFolderClick(t,s){var e,i;s?z.openFileExplorerForAreaFolder(t,s):z.openFileExplorerForArea(t),(i=(e=this.callbacks).onAreaFolderClick)==null||i.call(e,t,s)}handleAreaDoubleClick(t){var s,e;(e=(s=this.callbacks).onAreaDoubleClick)==null||e.call(s,t)}getAreaFolderIconAtScreenPos(t,s){const e=this.camera.screenToWorld(t,s);this.camera.getZoom();for(const i of this.getSortedAreasDesc()){if(!i.hasDirectories)continue;const o=.5,n=o*1.35,l=i.directories||[];let a,r,d=3;if(i.type==="rectangle"&&"width"in i.size)a=i.position.x-i.size.width/2+o*.8,r=i.position.z-i.size.height/2+o*.8,d=Math.max(1,Math.floor((i.size.width-o*1.2)/n));else if(i.type==="circle"&&"radius"in i.size){const m=i.size.radius*.707;a=i.position.x-m+o*.5,r=i.position.z-m+o*.5,d=Math.max(1,Math.floor((i.size.radius*1.414-o)/n))}else continue;const h=o*.7;for(let m=0;m<l.length;m++){const f=Math.floor(m/d),c=m%d,g=a+c*n,p=r+f*n,P=e.x-g,w=e.z-p;if(Math.sqrt(P*P+w*w)<=h)return{areaId:i.id,folderPath:l[m]}}}return null}handleSelectionBox(t,s){var e,i;(i=(e=this.callbacks).onSelectionBox)==null||i.call(e,t,s)}handleMoveCommand(t){var e,i;const s=Array.from(this.selectedAgentIds);(i=(e=this.callbacks).onMoveCommand)==null||i.call(e,s,t)}getAgents(){return this.agents}getBuildings(){return this.buildings}getAgentData(t){return this.agents.get(t)??null}hasActiveMovement(t){return this.movements.has(t)}getBuildingData(t){return this.buildings.get(t)??null}getAgentAtScreenPos(t,s){const e=this.camera.screenToWorld(t,s);return this.getAgentAtWorldPos(e.x,e.z)}getAgentAtWorldPos(t,s){for(const i of this.agents.values()){const o=t-i.position.x,n=s-i.position.z;if(Math.sqrt(o*o+n*n)<=.8)return i}return null}getBuildingAtScreenPos(t,s){const e=this.camera.screenToWorld(t,s);return this.getBuildingAtWorldPos(e.x,e.z)}getBuildingAtWorldPos(t,s){for(const i of this.buildings.values()){const o=t-i.position.x,n=s-i.position.z;if(Math.sqrt(o*o+n*n)<=1.5*i.scale)return i}return null}getAreaAtScreenPos(t,s){const e=this.camera.screenToWorld(t,s);return this.getAreaAtWorldPos(e.x,e.z)}getAreaAtWorldPos(t,s){for(const e of this.getSortedAreasDesc())if(e.type==="rectangle"&&"width"in e.size){const{width:i,height:o}=e.size,n=e.position.x-i/2,l=e.position.x+i/2,a=e.position.z-o/2,r=e.position.z+o/2;if(t>=n&&t<=l&&s>=a&&s<=r)return e}else if(e.type==="circle"&&"radius"in e.size){const{radius:i}=e.size,o=t-e.position.x,n=s-e.position.z;if(Math.sqrt(o*o+n*n)<=i)return e}return null}setDrawingTool(t){this.drawingTool=t,z.setActiveTool(t),(!t||t==="select")&&this.cancelDrawing()}getDrawingTool(){return this.drawingTool}isInDrawingMode(){return this.drawingTool==="rectangle"||this.drawingTool==="circle"}startDrawing(t){this.isInDrawingMode()&&(this.isDrawing=!0,this.drawStartPos={...t},this.drawCurrentPos={...t})}updateDrawing(t){!this.isDrawing||!this.drawStartPos||(this.drawCurrentPos={...t})}finishDrawing(t){if(!this.isDrawing||!this.drawStartPos){this.cancelDrawing();return}this.drawCurrentPos={...t};const s=this.createAreaFromDraw(this.drawStartPos,t);this.cancelDrawing(),s&&z.addArea(s)}cancelDrawing(){this.isDrawing=!1,this.drawStartPos=null,this.drawCurrentPos=null}isCurrentlyDrawing(){return this.isDrawing}getDrawingPreview(){return!this.isDrawing||!this.drawStartPos||!this.drawCurrentPos||!this.drawingTool||this.drawingTool==="select"?null:{start:this.drawStartPos,end:this.drawCurrentPos,tool:this.drawingTool}}createAreaFromDraw(t,s){if(!this.drawingTool||this.drawingTool==="select")return null;const e=`area-${Date.now()}-${Math.random().toString(36).slice(2,9)}`;if(this.drawingTool==="rectangle"){const i=Math.min(t.x,s.x),o=Math.max(t.x,s.x),n=Math.min(t.z,s.z),l=Math.max(t.z,s.z),a=o-i,r=l-n;return a<.5||r<.5?null:{id:e,name:"New Area",type:"rectangle",center:{x:(i+o)/2,z:(n+l)/2},width:a,height:r,color:"#4a9eff",zIndex:z.getNextZIndex(),assignedAgentIds:[],directories:[]}}else if(this.drawingTool==="circle"){const i=s.x-t.x,o=s.z-t.z,n=Math.sqrt(i*i+o*o);return n<.5?null:{id:e,name:"New Area",type:"circle",center:{x:t.x,z:t.z},radius:n,color:"#4a9eff",zIndex:z.getNextZIndex(),assignedAgentIds:[],directories:[]}}return null}};u(U,"IDLE_FPS_LIMIT",8),u(U,"WORKING_FPS_LIMIT",15),u(U,"MAX_DPR",1.25);let Pt=U;function ce(k,t={}){const s=L.useRef(null),e=L.useRef(t);e.current=t,L.useEffect(()=>{const f=k.current;if(!f)return;const c=new Pt(f);s.current=c,typeof window<"u"&&(window.__tideScene2D=c),c.setCallbacks({onAgentClick:(b,S)=>{var x,A;return(A=(x=e.current).onAgentClick)==null?void 0:A.call(x,b,S)},onAgentDoubleClick:b=>{var S,x;return(x=(S=e.current).onAgentDoubleClick)==null?void 0:x.call(S,b)},onAgentHover:(b,S)=>{var x,A;return(A=(x=e.current).onAgentHover)==null?void 0:A.call(x,b,S)},onBuildingClick:(b,S)=>{var x,A;return(A=(x=e.current).onBuildingClick)==null?void 0:A.call(x,b,S)},onBuildingDoubleClick:b=>{var S,x;return(x=(S=e.current).onBuildingDoubleClick)==null?void 0:x.call(S,b)},onBuildingDragStart:(b,S)=>{var x,A;return(A=(x=e.current).onBuildingDragStart)==null?void 0:A.call(x,b,S)},onBuildingDragMove:(b,S)=>{var x,A;return(A=(x=e.current).onBuildingDragMove)==null?void 0:A.call(x,b,S)},onBuildingDragEnd:(b,S)=>{var x,A;return(A=(x=e.current).onBuildingDragEnd)==null?void 0:A.call(x,b,S)},onBuildingDragCancel:b=>{var S,x;return(x=(S=e.current).onBuildingDragCancel)==null?void 0:x.call(S,b)},onContextMenu:(b,S,x)=>{var A,D;return(D=(A=e.current).onContextMenu)==null?void 0:D.call(A,b,S,x)},onGroundClick:b=>{var S,x;return(x=(S=e.current).onGroundClick)==null?void 0:x.call(S,b)},onMoveCommand:(b,S)=>{var x,A;return(A=(x=e.current).onMoveCommand)==null?void 0:A.call(x,b,S)},onAreaDoubleClick:b=>{var S,x;return(x=(S=e.current).onAreaDoubleClick)==null?void 0:x.call(S,b)},onSelectionBox:(b,S)=>{const x=Math.min(b.x,S.x),A=Math.max(b.x,S.x),D=Math.min(b.z,S.z),y=Math.max(b.z,S.z),T=[];for(const M of c.getAgents().values())M.position.x>=x&&M.position.x<=A&&M.position.z>=D&&M.position.z<=y&&T.push(M.id);if(T.length>0){z.selectAgent(T[0]);for(let M=1;M<T.length;M++)z.addToSelection(T[M])}else z.selectAgent(null)}});const g=z.getState();c.syncAreas(),c.syncBuildings(),c.syncAgents(Array.from(g.agents.values())),c.setSelectedAgents(g.selectedAgentIds),c.setSelectedBuildings(g.selectedBuildingIds),c.start();let p=new Map;for(const b of g.agents.values())p.set(b.id,{x:b.position.x,z:b.position.z});let P=g.agents.size>0;const w=z.subscribe(()=>{var S;const b=z.getState();if(!P&&b.agents.size>0){P=!0,c.syncAreas(),c.syncAgents(Array.from(b.agents.values()));for(const x of b.agents.values())p.set(x.id,{x:x.position.x,z:x.position.z})}else{for(const x of b.agents.values()){if(z.isAgentInArchivedArea(x.id)){p.has(x.id)&&(c.removeAgent(x.id),p.delete(x.id));continue}const A=p.get(x.id);!A||A.x!==x.position.x||A.z!==x.position.z?(c.updateAgent(x,!0),p.set(x.id,{x:x.position.x,z:x.position.z})):(S=c.hasActiveMovement)!=null&&S.call(c,x.id)||c.updateAgent(x,!1)}for(const x of p.keys())(!b.agents.has(x)||z.isAgentInArchivedArea(x))&&(c.removeAgent(x),p.delete(x))}c.syncBuildings(),c.syncAreas(),c.setSelectedAgents(b.selectedAgentIds),c.setSelectedBuildings(b.selectedBuildingIds)});return()=>{w(),c.dispose(),s.current=null,typeof window<"u"&&delete window.__tideScene2D}},[k]);const i=L.useCallback(f=>{var c;(c=s.current)==null||c.focusAgent(f)},[]),o=L.useCallback((f,c=!0)=>{var g;(g=s.current)==null||g.updateAgent(f,c)},[]),n=L.useCallback(f=>{var c;(c=s.current)==null||c.createMoveOrderEffect(f)},[]),l=L.useCallback((f,c)=>{var g;(g=s.current)==null||g.showToolBubble(f,c)},[]),a=L.useCallback(f=>{var c;(c=s.current)==null||c.setIndicatorScale(f)},[]),r=L.useCallback(f=>{var c;(c=s.current)==null||c.setTaskLabelsVisible(f)},[]),d=L.useCallback(f=>{var c;(c=s.current)==null||c.setGridVisible(f)},[]),h=L.useCallback(f=>{var c;(c=s.current)==null||c.setDrawingTool(f)},[]),m=L.useCallback(f=>{var c;(c=s.current)==null||c.setFpsLimit(f)},[]);return{scene:s,focusAgent:i,updateAgent:o,createMoveOrderEffect:n,showToolBubble:l,setIndicatorScale:a,setTaskLabelsVisible:r,setGridVisible:d,setDrawingTool:h,setFpsLimit:m}}function pe({onAgentClick:k,onAgentDoubleClick:t,onAgentHover:s,onBuildingClick:e,onBuildingDoubleClick:i,onBuildingDragStart:o,onBuildingDragMove:n,onBuildingDragEnd:l,onBuildingDragCancel:a,onContextMenu:r,onGroundClick:d,onMoveCommand:h,onAreaDoubleClick:m,indicatorScale:f=1,showTaskLabels:c=!0,showGrid:g=!0,fpsLimit:p=0,className:P=""}){const w=L.useRef(null),{scene:b,setIndicatorScale:S,setTaskLabelsVisible:x,setGridVisible:A,setDrawingTool:D,setFpsLimit:y}=ce(w,{onAgentClick:k,onAgentDoubleClick:t,onAgentHover:s,onBuildingClick:e,onBuildingDoubleClick:i,onBuildingDragStart:o,onBuildingDragMove:n,onBuildingDragEnd:l,onBuildingDragCancel:a,onContextMenu:r,onGroundClick:d,onMoveCommand:h,onAreaDoubleClick:m});return L.useEffect(()=>(typeof window<"u"&&b.current&&(window.__tideScene2D_setDrawingTool=D),()=>{typeof window<"u"&&delete window.__tideScene2D_setDrawingTool}),[D,b]),L.useEffect(()=>{S(f)},[f,S]),L.useEffect(()=>{x(c)},[c,x]),L.useEffect(()=>{A(g)},[g,A]),L.useEffect(()=>{y(p)},[p,y]),pt.jsxs("div",{className:`scene-2d-container ${P}`,children:[pt.jsx("canvas",{ref:w,className:"scene-2d-canvas"}),pt.jsx("div",{className:"scene-2d-badge",children:"2D Mode"})]})}export{pe as Scene2DCanvas,pe as default};
|