tide-commander 1.155.0 → 1.157.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +23 -1
  2. package/dist/assets/{BossLogsModal-OFobifVq.js → BossLogsModal-DDSE0x_p.js} +1 -1
  3. package/dist/assets/{BossSpawnModal-Dho-x6rm.js → BossSpawnModal-D5N-Lxn1.js} +1 -1
  4. package/dist/assets/{ControlsModal-DJBDhvNO.js → ControlsModal-DJZUWiyu.js} +1 -1
  5. package/dist/assets/{DockerLogsModal-C9TRTcsO.js → DockerLogsModal-DC2UXd0z.js} +1 -1
  6. package/dist/assets/{EmbeddedEditor-GDE_Khwz.js → EmbeddedEditor-Dhtz_k0F.js} +1 -1
  7. package/dist/assets/{GmailOAuthSetup-D9m5zMWC.js → GmailOAuthSetup-D-FwEI0M.js} +1 -1
  8. package/dist/assets/{GoogleOAuthSetup-BxkN7LjY.js → GoogleOAuthSetup-BNGK9RSM.js} +1 -1
  9. package/dist/assets/{IframeModal-Do_I_wI7.js → IframeModal-nPZKErA3.js} +1 -1
  10. package/dist/assets/{IntegrationsPanel-jRrwC2-G.js → IntegrationsPanel-CulfxUP-.js} +2 -2
  11. package/dist/assets/{LogViewerModal-BtcUe5i2.js → LogViewerModal-CRyAs-oh.js} +1 -1
  12. package/dist/assets/{MonitoringModal-BTmSXrzv.js → MonitoringModal-Dopg2wVf.js} +1 -1
  13. package/dist/assets/{PM2LogsModal-CUf7NGHz.js → PM2LogsModal-BU7EDdEi.js} +1 -1
  14. package/dist/assets/{RestoreArchivedAreaModal-B72UKeRP.js → RestoreArchivedAreaModal-EH9xwyUB.js} +1 -1
  15. package/dist/assets/{Scene2DCanvas-BCfxX7JU.js → Scene2DCanvas-B3l1gohF.js} +1 -1
  16. package/dist/assets/{SceneManager-BQubdlgd.js → SceneManager-a-l_xGUx.js} +1 -1
  17. package/dist/assets/{SkillsPanel-3qreMiJs.js → SkillsPanel-Bhyi4Fml.js} +1 -1
  18. package/dist/assets/{SlackMultiInstanceSetup-BSCT5nAB.js → SlackMultiInstanceSetup-Cm7Ml8KO.js} +1 -1
  19. package/dist/assets/{SpawnModal-DaWjnugM.js → SpawnModal-Db3zLyWg.js} +1 -1
  20. package/dist/assets/{StatisticsModal-DCjCAU2o.js → StatisticsModal-BJE6QCYm.js} +1 -1
  21. package/dist/assets/{SubordinateAssignmentModal-9iPXraIi.js → SubordinateAssignmentModal-BxakVxLF.js} +1 -1
  22. package/dist/assets/{TriggerManagerPanel-B4dCLEi_.js → TriggerManagerPanel-BXAJeXW0.js} +1 -1
  23. package/dist/assets/{WorkflowEditorPanel-BaYXKfYH.js → WorkflowEditorPanel-DnwQCDzh.js} +1 -1
  24. package/dist/assets/{area-logos-CgVT13bp.js → area-logos-BHK56r6D.js} +1 -1
  25. package/dist/assets/index-BIxFr4P2.css +1 -0
  26. package/dist/assets/{index-DiZy3nuB.js → index-C1Gs2JMb.js} +1 -1
  27. package/dist/assets/{index-CetQ5OX1.js → index-Cjw_IU-U.js} +1 -1
  28. package/dist/assets/{index-D8dlRudN.js → index-CuXL7VR9.js} +3 -3
  29. package/dist/assets/{index-C3jAbuv2.js → index-CyccEWP-.js} +1 -1
  30. package/dist/assets/{index-0y0WY2XK.js → index-D01KXErP.js} +1 -1
  31. package/dist/assets/{index-DNjdlOwh.js → index-DFuirzEO.js} +1 -1
  32. package/dist/assets/index-DOvmFreL.js +2 -0
  33. package/dist/assets/{index-C-tbJxGb.js → index-DWJwZ_Wh.js} +1 -1
  34. package/dist/assets/{index-C7t_6aP3.js → index-DiCRRwAA.js} +2 -2
  35. package/dist/assets/main-BPB42oyq.css +1 -0
  36. package/dist/assets/main-D8A4ans-.js +292 -0
  37. package/dist/assets/{web-EBdZk56y.js → web-B_cvh4cx.js} +1 -1
  38. package/dist/assets/{web-Dj2DYQG1.js → web-Cn4UiVDm.js} +1 -1
  39. package/dist/assets/{web-PXjd4vZ8.js → web-DTrqfZ3J.js} +1 -1
  40. package/dist/build-info.json +1 -1
  41. package/dist/index.html +2 -2
  42. package/dist/src/packages/server/opencode/server/opencode-server-event-adapter.js +31 -1
  43. package/dist/src/packages/server/routes/system.js +6 -0
  44. package/dist/src/packages/server/services/system-prompt-service.js +6 -6
  45. package/dist/src/packages/server/services/web-bundle-builder.js +146 -0
  46. package/package.json +1 -1
  47. package/dist/assets/index-BPjQZacc.css +0 -1
  48. package/dist/assets/index-C3Yb-3TP.js +0 -2
  49. package/dist/assets/main-BHBs2E1L.css +0 -1
  50. package/dist/assets/main-DDwa0x9e.js +0 -289
package/CHANGELOG.md CHANGED
@@ -2,10 +2,32 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.157.0] - 2026-07-12
6
+
7
+ ### Added
8
+ - **Codex activity cards** - Codex `exec` orchestration steps now render as familiar Read/Edit/Grep/Glob/Bash/WebSearch-style activity cards (matching icon + one-line summary) in both the live terminal and history, instead of opaque `exec` blobs. Each card expands to reveal the full command and its result, and clicking an edit or read card opens the file's diff or jumps straight to the referenced lines in the file viewer.
9
+ - **Auto-rebuilt UI bundle (dev checkouts)** - a self-hosted/git-checkout server now rebuilds its served web bundle in the background whenever the UI source is newer than the last build, so phones pull the fresh interface over OTA without a manual release build. A new `dev` flag lets those same-version bundle updates reach phones still running APK-bundled assets.
10
+
11
+ ### Changed
12
+ - **Compact Flat mode mobile header** - reduced the Flat chat header's mobile-only padding and avatar footprint while preserving the Android safe-area inset, leaving more vertical room for conversation content on phones.
13
+ - **Useful Flat map on mobile** - replaced the squeezed desktop-spatial grid with a readable two-column area browser: cards retain their broad map order without empty cells, area names/logos/counts stay visible, the sticky header keeps the safe-area-aware view switcher and live summary in reach, and an expanded area spans the full width with touch-sized agent, folder, and building controls.
14
+ - **Streaming agent modes back to opt-in** - the Codex app-server and OpenCode `serve` word-by-word streaming modes are experimental again and default OFF until further hardened (reversing the 1.155.0 default-on rollout); enable either per preference in Settings.
15
+
16
+ ### Fixed
17
+ - **OpenCode streaming glitches** - in OpenCode streaming (`serve`) mode, the agent no longer echoes your own prompt back as an assistant message, and reasoning-model thinking no longer renders twice (once as a streamed text row and once as a thinking row).
18
+
19
+ ## [1.156.0] - 2026-07-12
20
+
21
+ ### Added
22
+ - **Mobile chat actions sheet** - on phones, the chat header's action cluster (search, git changes, buildings, debug, clear/collapse context, clear subordinates, remove agent) now lives in a thumb-reachable bottom sheet opened by a new "Actions" button in the bottom nav, instead of being crammed into the top-right corner. The sheet slides up above the bottom nav, closes on Escape / Android-back / backdrop tap, and desktop keeps its inline header cluster unchanged.
23
+
5
24
  ## [1.155.0] - 2026-07-12
6
25
 
7
26
  ### Added
8
- - **OpenCode streaming (serve) mode** - a new experimental Settings toggle ("OpenCode Streaming / serve") runs OpenCode agents through a persistent `opencode serve` (SSE) process so replies type out word-by-word instead of landing as one block. The server runs detached and survives commander restarts (in-flight turns keep running and auto-reconnect), reuses the existing OpenCode event parser, and a per-launch router picks run-vs-serve; the toggle applies to new turns with no server restart needed. This mirrors the Codex app-server streaming mode.
27
+ - **OpenCode streaming (serve) mode** - OpenCode agents can run through a persistent `opencode serve` (SSE) process so replies type out word-by-word instead of landing as one block. The server runs detached and survives commander restarts (in-flight turns keep running and auto-reconnect), reuses the existing OpenCode event parser, and a per-launch router picks run-vs-serve; changing the Settings toggle applies to new turns with no server restart needed. Mirrors the Codex app-server streaming mode.
28
+
29
+ ### Changed
30
+ - **Streaming is on by default for Codex and OpenCode** - the Codex app-server and OpenCode serve streaming modes are now enabled by default (both toggles default on) instead of being opt-in experimental toggles, so Codex and OpenCode replies stream word-by-word out of the box with restart survival. Turn either off in Settings if you prefer whole-message delivery.
9
31
 
10
32
  ## [1.154.0] - 2026-07-12
11
33
 
@@ -1 +1 @@
1
- import{u as M,l as N,m as v,r as m,s as u,j as r}from"./main-DDwa0x9e.js";import{L as B}from"./LogViewerModal-BtcUe5i2.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function C(s){const n=["#3498db","#2ecc71","#9b59b6","#e67e22","#1abc9c","#e74c3c","#f1c40f","#00bcd4"];let a=0;for(let o=0;o<s.length;o++)a=s.charCodeAt(o)+((a<<5)-a);return n[Math.abs(a)%n.length]}function w({building:s,isOpen:n,onClose:a}){const{t:o}=M(["terminal","common"]),b=N(),f=v(),l=b.get(s.id)||[],[i,d]=m.useState(null),c=s.subordinateBuildingIds||[],g=c.map(e=>f.get(e)).filter(e=>e!==void 0);m.useEffect(()=>(n&&c.length>0&&u.startBossLogStreaming(s.id),()=>{s.id&&u.stopBossLogStreaming(s.id)}),[n,s.id,c.length]);const h=m.useMemo(()=>{const e=new Set;return l.forEach(t=>e.add(t.subordinateName)),Array.from(e)},[l]),p=m.useMemo(()=>(i?l.filter(t=>t.subordinateName===i):l).map((t,j)=>({text:t.chunk,lineNumber:j+1,sourceLabel:t.subordinateName,sourceColor:C(t.subordinateName),isError:t.isError})),[l,i]),x=g.some(e=>{var t;return(t=e.pm2)==null?void 0:t.enabled}),L=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:o("terminal:logs.allSources")}),h.map(e=>r.jsx("option",{value:e,children:e},e))]}):void 0,S=i?r.jsxs("div",{className:"shortcut",style:{marginLeft:"auto"},children:[r.jsxs("span",{children:[o("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(B,{isOpen:n,onClose:a,title:`${s.name} - ${o("terminal:logs.bossLogs")}`,icon:"👑",lines:p,isStreaming:c.length>0,streamingIndicatorLabel:`${g.length} ${o("terminal:logs.units")}`,onClear:()=>u.clearBossStreamingLogs(s.id),emptyMessage:x?l.length===0?o("terminal:logs.waitingForLogs"):o("terminal:logs.noMatchingLogs"):o("terminal:logs.noPM2Subordinates"),extraToolbar:L,extraFooter:S,modalClassName:"boss-logs-modal"})}export{w as BossLogsModal};
1
+ import{u as M,l as N,m as v,r as m,s as u,j as r}from"./main-D8A4ans-.js";import{L as B}from"./LogViewerModal-CRyAs-oh.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function C(s){const n=["#3498db","#2ecc71","#9b59b6","#e67e22","#1abc9c","#e74c3c","#f1c40f","#00bcd4"];let a=0;for(let o=0;o<s.length;o++)a=s.charCodeAt(o)+((a<<5)-a);return n[Math.abs(a)%n.length]}function w({building:s,isOpen:n,onClose:a}){const{t:o}=M(["terminal","common"]),b=N(),f=v(),l=b.get(s.id)||[],[i,d]=m.useState(null),c=s.subordinateBuildingIds||[],g=c.map(e=>f.get(e)).filter(e=>e!==void 0);m.useEffect(()=>(n&&c.length>0&&u.startBossLogStreaming(s.id),()=>{s.id&&u.stopBossLogStreaming(s.id)}),[n,s.id,c.length]);const h=m.useMemo(()=>{const e=new Set;return l.forEach(t=>e.add(t.subordinateName)),Array.from(e)},[l]),p=m.useMemo(()=>(i?l.filter(t=>t.subordinateName===i):l).map((t,j)=>({text:t.chunk,lineNumber:j+1,sourceLabel:t.subordinateName,sourceColor:C(t.subordinateName),isError:t.isError})),[l,i]),x=g.some(e=>{var t;return(t=e.pm2)==null?void 0:t.enabled}),L=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:o("terminal:logs.allSources")}),h.map(e=>r.jsx("option",{value:e,children:e},e))]}):void 0,S=i?r.jsxs("div",{className:"shortcut",style:{marginLeft:"auto"},children:[r.jsxs("span",{children:[o("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(B,{isOpen:n,onClose:a,title:`${s.name} - ${o("terminal:logs.bossLogs")}`,icon:"👑",lines:p,isStreaming:c.length>0,streamingIndicatorLabel:`${g.length} ${o("terminal:logs.units")}`,onClear:()=>u.clearBossStreamingLogs(s.id),emptyMessage:x?l.length===0?o("terminal:logs.waitingForLogs"):o("terminal:logs.noMatchingLogs"):o("terminal:logs.noPM2Subordinates"),extraToolbar:L,extraFooter:S,modalClassName:"boss-logs-modal"})}export{w as BossLogsModal};
@@ -1 +1 @@
1
- import{u as Be,aC as Re,b6 as Oe,b5 as Te,r as t,_ as re,S as G,bj as O,k as Fe,s as S,ba as W,A as de,bk as C,j as s,a9 as y,bb as Pe,bd as ze,I as T,be as K,aT as A,aR as F,bh as H,$ as Ue}from"./main-DDwa0x9e.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function ue(u){const w=C.filter($=>!u.has(`Boss ${$}`));return w.length===0?`Boss ${C[Math.floor(Math.random()*C.length)]}-${Date.now()%1e3}`:`Boss ${w[Math.floor(Math.random()*w.length)]}`}function Ke({isOpen:u,onClose:w,onSpawnStart:$,onSpawnEnd:P,spawnPosition:me,spawnAreaId:g}){const{t:n}=Be(["terminal","common"]),J=Re(),c=Oe(),E=Te(),[m,p]=t.useState(""),[L,z]=t.useState(()=>re(G.LAST_CWD)),[d,I]=t.useState("boss"),[X,V]=t.useState(!1),[pe,_]=t.useState(!1),[Y,he]=t.useState(!0),[Q,we]=t.useState("bypass"),[o,D]=t.useState("claude"),[f,N]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[Z,xe]=t.useState("claude-opus-4-8[1m]"),[ee,fe]=t.useState("gpt-5.6-luna"),[k,B]=t.useState(new Set),[se,U]=t.useState(new Set),[h,be]=t.useState(""),[v,je]=t.useState(""),[ae,ge]=t.useState(""),R=t.useRef(null),q=t.useRef(!1),ne=t.useRef(!1),b=t.useMemo(()=>E.filter(e=>e.enabled),[E]),le=t.useMemo(()=>{if(!v.trim())return b;const e=v.toLowerCase();return b.filter(a=>a.name.toLowerCase().includes(e)||a.description.toLowerCase().includes(e)||a.slug.toLowerCase().includes(e))},[b,v]),Ne=t.useMemo(()=>{var a;const e=c.find(l=>l.id===d);return(a=e==null?void 0:e.defaultSkillIds)!=null&&a.length?E.filter(l=>e.defaultSkillIds.includes(l.id)):[]},[c,d,E]),ve=["full-notifications","streaming-exec","task-label","report-task-to-boss","agent-tracking","agent-memory","send-message-to-agent"];t.useEffect(()=>{if(u&&!ne.current){if(b.length>0){const l=b.filter(i=>ve.includes(i.slug)).map(i=>i.id);l.length>0&&U(new Set(l))}if(re(G.DEFAULT_AGENT_CLASS)==="random"){const i=[...Object.keys(O).filter(j=>j!=="boss"),...c.map(j=>j.id)];i.length>0&&I(i[Math.floor(Math.random()*i.length)])}}ne.current=u},[u,b,c]);const Se=t.useCallback(e=>{U(a=>{const l=new Set(a);return l.has(e)?l.delete(e):l.add(e),l})},[]),r=t.useMemo(()=>c.find(e=>e.id===d),[c,d]),Ce=t.useMemo(()=>{if(r!=null&&r.model)return r.model},[r]),ke=t.useMemo(()=>{if(r!=null&&r.customModelPath)return Fe(`/api/custom-models/${r.id}`)},[r]),Me=r==null?void 0:r.modelScale,ye=t.useMemo(()=>r?"scout":d==="boss"?"architect":d,[d,r]);t.useEffect(()=>{if(!u||!g)return;const e=S.getState().areas.get(g);if(e!=null&&e.directories&&e.directories.length>0){z(e.directories[0]);return}const a=Array.from(S.getState().agents.values()).filter(x=>{var M;return((M=S.getAreaForAgent(x.id))==null?void 0:M.id)===g&&x.cwd});if(a.length===0)return;const l=new Map;for(const x of a)l.set(x.cwd,(l.get(x.cwd)||0)+1);let i="",j=0;for(const[x,M]of l)M>j&&(i=x,j=M);i&&z(i)},[u,g]);const te=t.useMemo(()=>Array.from(J.values()).filter(e=>!e.isBoss&&e.class!=="boss"&&!e.bossId),[J]),ie=t.useMemo(()=>{if(!h.trim())return c;const e=h.toLowerCase();return c.filter(a=>a.name.toLowerCase().includes(e)||a.description.toLowerCase().includes(e)||a.id.toLowerCase().includes(e))},[c,h]),ce=t.useMemo(()=>{if(!h.trim())return W;const e=h.toLowerCase();return W.filter(a=>{const l=de[a.id];return l?a.name.toLowerCase().includes(e)||a.id.toLowerCase().includes(e)||l.description.toLowerCase().includes(e):!1})},[h]),oe=t.useMemo(()=>{if(!h.trim())return!0;const e=h.toLowerCase(),a=O.boss;return"boss".includes(e)||a.description.toLowerCase().includes(e)},[h]);t.useEffect(()=>{if(u&&!q.current){q.current=!0;const e=new Set(Array.from(S.getState().agents.values()).map(l=>l.name)),a=c.find(l=>l.id===d);if(a){const l=C.filter(i=>!e.has(`${a.name} ${i}`));if(l.length===0){const i=C[Math.floor(Math.random()*C.length)];p(`${a.name} ${i}-${Date.now()%1e3}`)}else p(`${a.name} ${l[Math.floor(Math.random()*l.length)]}`)}else p(ue(e));B(new Set),R.current&&(R.current.focus(),R.current.select())}else u||(q.current=!1)},[u]),t.useEffect(()=>{if(!u)return;const e=c.find(a=>a.id===d);if(e)if(m.startsWith("Boss ")){const a=m.substring(5);p(`${e.name} ${a}`)}else{const a=c.find(l=>m.startsWith(l.name+" "));if(a){const l=m.substring(a.name.length+1);p(`${e.name} ${l}`)}else p(`${e.name} ${m}`)}else{const a=c.find(l=>m.startsWith(l.name+" "));if(a){const l=m.substring(a.name.length+1);p(`Boss ${l}`)}else m.startsWith("Boss ")||p(`Boss ${m}`)}},[d]);const Ae=()=>{if(_(!1),!L.trim()){_(!0);return}if(!m.trim()){const l=new Set(Array.from(S.getState().agents.values()).map(i=>i.name));p(ue(l));return}Ue(G.LAST_CWD,L),$(),window.__spawnModalAreaContext=g?{areaId:g}:null;const e=ae.trim()||void 0,a=Array.from(se);S.spawnBossAgent(m.trim(),d,L.trim(),me||void 0,Array.from(k),o==="claude"?Y:!1,Q,o,o==="codex"?f:void 0,o==="codex"?ee:void 0,o==="claude"?Z:void 0,e,a),p(""),B(new Set),U(new Set),P(),w()},$e=()=>{V(!1),p(""),B(new Set),P(),w()},Ee=()=>{V(!1),_(!0),P()};t.useEffect(()=>(window.__bossSpawnModalSuccess=$e,window.__bossSpawnModalError=Ee,()=>{delete window.__bossSpawnModalSuccess,delete window.__bossSpawnModalError}),[m]);const Le=e=>{e.target===e.currentTarget&&w()},Ie=e=>{e.key==="Escape"&&w()},_e=e=>{const a=new Set(k);a.has(e)?a.delete(e):a.add(e),B(a)};if(!u)return null;const De=O.boss;return s.jsx("div",{className:`modal-overlay ${u?"visible":""}`,onClick:Le,onKeyDown:Ie,children:s.jsxs("div",{className:"modal boss-spawn-modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx(y,{classId:"boss",size:22,className:"boss-header-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(Pe,{agentClass:ye,modelFile:Ce,customModelUrl:ke,modelScale:Me,width:100,height:120})}),s.jsxs("div",{className:"spawn-class-section",children:[s.jsx("div",{className:"spawn-class-label",children:n("terminal:spawn.bossClass")}),c.length+W.length+1>6&&s.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:n("terminal:spawn.filterClasses"),value:h,onChange:e=>be(e.target.value)}),s.jsxs("div",{className:"class-selector-inline",children:[ie.map(e=>s.jsxs("button",{className:`class-chip ${d===e.id?"selected":""}`,onClick:()=>I(e.id),title:e.description,children:[s.jsx(y,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)),oe&&s.jsxs("button",{className:`class-chip ${d==="boss"?"selected":""}`,onClick:()=>I("boss"),title:De.description,children:[s.jsx(y,{classId:"boss",size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:n("terminal:spawn.bossClassName")})]}),ce.map(e=>{const a=de[e.id];return a?s.jsxs("button",{className:`class-chip ${d===e.id?"selected":""}`,onClick:()=>I(e.id),title:a.description,children:[s.jsx(y,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id):null}),h&&ie.length===0&&!oe&&ce.length===0&&s.jsx("div",{className:"class-search-empty",children:n("terminal:spawn.noClassesMatch",{query:h})})]})]})]}),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:R,type:"text",className:"spawn-input",placeholder:n("terminal:spawn.bossNamePlaceholder"),value:m,onChange:e=>p(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(ze,{value:L,onChange:e=>{z(e),_(!1)},placeholder:n("terminal:spawn.workingDirPlaceholder"),className:"spawn-input",hasError:pe,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 ${o==="claude"?"selected":""}`,onClick:()=>D("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 ${o==="codex"?"selected":""}`,onClick:()=>D("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("button",{className:`spawn-select-btn spawn-select-btn--opencode ${o==="opencode"?"selected":""}`,onClick:()=>D("opencode"),title:"Use OpenCode CLI (multi-provider)",children:[s.jsx("span",{children:s.jsx(T,{name:"status-pending",size:14,weight:"fill",color:"#4ade80"})}),s.jsx("span",{children:"OpenCode"})]}),s.jsxs("button",{className:`spawn-select-btn spawn-select-btn--grok ${o==="grok"?"selected":""}`,onClick:()=>D("grok"),title:"Use Grok CLI (headless)",children:[s.jsx("img",{src:"/assets/grok.png",alt:"Grok",className:"spawn-provider-icon"}),s.jsx("span",{children:"Grok"})]})]})]}),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(K).map(e=>s.jsxs("button",{className:`spawn-select-btn ${Q===e?"selected":""}`,onClick:()=>we(e),title:K[e].description,children:[s.jsx("span",{children:s.jsx(T,{name:e==="bypass"?"bolt":"lock",size:14})}),s.jsx("span",{children:K[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")}),o==="claude"?s.jsx("div",{className:"spawn-select-row spawn-select-row--wrap",children:Object.keys(A).filter(e=>!A[e].deprecated).map(e=>s.jsxs("button",{className:`spawn-select-btn ${Z===e?"selected":""}`,onClick:()=>xe(e),title:A[e].description,children:[s.jsx("span",{children:A[e].icon}),s.jsx("span",{children:A[e].label})]},e))}):o==="codex"?s.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(F).map(e=>s.jsxs("button",{className:`spawn-select-btn ${ee===e?"selected":""}`,onClick:()=>fe(e),title:F[e].description,children:[s.jsx("span",{children:F[e].icon}),s.jsx("span",{children:F[e].label})]},e))}):o==="opencode"?s.jsx("input",{type:"text",className:"spawn-input",defaultValue:"minimax/MiniMax-M1-80k",placeholder:"provider/model (e.g., minimax/MiniMax-M1-80k)"}):o==="grok"?s.jsx("div",{className:"spawn-inline-hint",children:"grok-4.5"}):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:Y,onChange:e=>he(e.target.checked),disabled:o!=="claude"}),s.jsx("span",{children:n("terminal:spawn.chromeBrowser")})]})})]})]}),o==="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}))}),s.jsxs("select",{className:"spawn-input",value:f.reasoningEffort||"",onChange:e=>N(a=>({...a,reasoningEffort:e.target.value||void 0})),children:[s.jsx("option",{value:"",children:n("terminal:spawn.codex.reasoningEffortDefault")}),Object.keys(H).map(e=>s.jsxs("option",{value:e,children:[H[e].icon," ",n("terminal:spawn.codex.reasoningEffort"),": ",H[e].label]},e))]})]})]})}),b.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"),")"]})]}),b.length>6&&s.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:n("terminal:spawn.filterSkills"),value:v,onChange:e=>je(e.target.value)}),s.jsxs("div",{className:"spawn-skills-inline",children:[le.map(e=>{const a=se.has(e.id);return Ne.some(i=>i.id===e.id)?null:s.jsxs("button",{className:`spawn-skill-chip ${a?"selected":""}`,onClick:()=>Se(e.id),title:e.description,children:[a&&s.jsx("span",{className:"spawn-skill-check",children:s.jsx(T,{name:"check",size:12})}),s.jsx("span",{children:e.name}),e.builtin&&s.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},e.id)}),v&&le.length===0&&s.jsx("div",{className:"skill-search-empty",children:n("terminal:spawn.noSkillsMatch",{query:v})})]})]}),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:ae,onChange:e=>ge(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:te.length===0?s.jsx("div",{className:"subordinates-empty",children:n("terminal:spawn.noAvailableAgents")}):te.map(e=>{const a=k.has(e.id),l=O[e.class],i=c.find(x=>x.id===e.class),j=l||i||{color:"#888888"};return s.jsxs("button",{className:`subordinate-chip ${a?"selected":""}`,onClick:()=>_e(e.id),children:[a&&s.jsx("span",{className:"subordinate-check",children:s.jsx(T,{name:"check",size:12})}),s.jsx("span",{className:"subordinate-chip-icon",style:{color:j.color},children:s.jsx(y,{classId:e.class,size:16})}),s.jsx("span",{className:"subordinate-chip-name",children:e.name})]},e.id)})}),k.size>0&&s.jsxs("div",{className:"subordinates-count",children:[k.size," ",n("common:labels.selected").toLowerCase()]})]})]})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:w,children:n("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-boss",onClick:Ae,disabled:X,children:n(X?"common:buttons.deploying":"common:buttons2.deployBoss")})]})]})})}export{Ke as BossSpawnModal};
1
+ import{u as Be,aC as Re,b6 as Oe,b5 as Te,r as t,_ as re,S as G,bj as O,k as Fe,s as S,ba as W,A as de,bk as C,j as s,a9 as y,bb as Pe,bd as ze,I as T,be as K,aT as A,aR as F,bh as H,$ as Ue}from"./main-D8A4ans-.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function ue(u){const w=C.filter($=>!u.has(`Boss ${$}`));return w.length===0?`Boss ${C[Math.floor(Math.random()*C.length)]}-${Date.now()%1e3}`:`Boss ${w[Math.floor(Math.random()*w.length)]}`}function Ke({isOpen:u,onClose:w,onSpawnStart:$,onSpawnEnd:P,spawnPosition:me,spawnAreaId:g}){const{t:n}=Be(["terminal","common"]),J=Re(),c=Oe(),E=Te(),[m,p]=t.useState(""),[L,z]=t.useState(()=>re(G.LAST_CWD)),[d,I]=t.useState("boss"),[X,V]=t.useState(!1),[pe,_]=t.useState(!1),[Y,he]=t.useState(!0),[Q,we]=t.useState("bypass"),[o,D]=t.useState("claude"),[f,N]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[Z,xe]=t.useState("claude-opus-4-8[1m]"),[ee,fe]=t.useState("gpt-5.6-luna"),[k,B]=t.useState(new Set),[se,U]=t.useState(new Set),[h,be]=t.useState(""),[v,je]=t.useState(""),[ae,ge]=t.useState(""),R=t.useRef(null),q=t.useRef(!1),ne=t.useRef(!1),b=t.useMemo(()=>E.filter(e=>e.enabled),[E]),le=t.useMemo(()=>{if(!v.trim())return b;const e=v.toLowerCase();return b.filter(a=>a.name.toLowerCase().includes(e)||a.description.toLowerCase().includes(e)||a.slug.toLowerCase().includes(e))},[b,v]),Ne=t.useMemo(()=>{var a;const e=c.find(l=>l.id===d);return(a=e==null?void 0:e.defaultSkillIds)!=null&&a.length?E.filter(l=>e.defaultSkillIds.includes(l.id)):[]},[c,d,E]),ve=["full-notifications","streaming-exec","task-label","report-task-to-boss","agent-tracking","agent-memory","send-message-to-agent"];t.useEffect(()=>{if(u&&!ne.current){if(b.length>0){const l=b.filter(i=>ve.includes(i.slug)).map(i=>i.id);l.length>0&&U(new Set(l))}if(re(G.DEFAULT_AGENT_CLASS)==="random"){const i=[...Object.keys(O).filter(j=>j!=="boss"),...c.map(j=>j.id)];i.length>0&&I(i[Math.floor(Math.random()*i.length)])}}ne.current=u},[u,b,c]);const Se=t.useCallback(e=>{U(a=>{const l=new Set(a);return l.has(e)?l.delete(e):l.add(e),l})},[]),r=t.useMemo(()=>c.find(e=>e.id===d),[c,d]),Ce=t.useMemo(()=>{if(r!=null&&r.model)return r.model},[r]),ke=t.useMemo(()=>{if(r!=null&&r.customModelPath)return Fe(`/api/custom-models/${r.id}`)},[r]),Me=r==null?void 0:r.modelScale,ye=t.useMemo(()=>r?"scout":d==="boss"?"architect":d,[d,r]);t.useEffect(()=>{if(!u||!g)return;const e=S.getState().areas.get(g);if(e!=null&&e.directories&&e.directories.length>0){z(e.directories[0]);return}const a=Array.from(S.getState().agents.values()).filter(x=>{var M;return((M=S.getAreaForAgent(x.id))==null?void 0:M.id)===g&&x.cwd});if(a.length===0)return;const l=new Map;for(const x of a)l.set(x.cwd,(l.get(x.cwd)||0)+1);let i="",j=0;for(const[x,M]of l)M>j&&(i=x,j=M);i&&z(i)},[u,g]);const te=t.useMemo(()=>Array.from(J.values()).filter(e=>!e.isBoss&&e.class!=="boss"&&!e.bossId),[J]),ie=t.useMemo(()=>{if(!h.trim())return c;const e=h.toLowerCase();return c.filter(a=>a.name.toLowerCase().includes(e)||a.description.toLowerCase().includes(e)||a.id.toLowerCase().includes(e))},[c,h]),ce=t.useMemo(()=>{if(!h.trim())return W;const e=h.toLowerCase();return W.filter(a=>{const l=de[a.id];return l?a.name.toLowerCase().includes(e)||a.id.toLowerCase().includes(e)||l.description.toLowerCase().includes(e):!1})},[h]),oe=t.useMemo(()=>{if(!h.trim())return!0;const e=h.toLowerCase(),a=O.boss;return"boss".includes(e)||a.description.toLowerCase().includes(e)},[h]);t.useEffect(()=>{if(u&&!q.current){q.current=!0;const e=new Set(Array.from(S.getState().agents.values()).map(l=>l.name)),a=c.find(l=>l.id===d);if(a){const l=C.filter(i=>!e.has(`${a.name} ${i}`));if(l.length===0){const i=C[Math.floor(Math.random()*C.length)];p(`${a.name} ${i}-${Date.now()%1e3}`)}else p(`${a.name} ${l[Math.floor(Math.random()*l.length)]}`)}else p(ue(e));B(new Set),R.current&&(R.current.focus(),R.current.select())}else u||(q.current=!1)},[u]),t.useEffect(()=>{if(!u)return;const e=c.find(a=>a.id===d);if(e)if(m.startsWith("Boss ")){const a=m.substring(5);p(`${e.name} ${a}`)}else{const a=c.find(l=>m.startsWith(l.name+" "));if(a){const l=m.substring(a.name.length+1);p(`${e.name} ${l}`)}else p(`${e.name} ${m}`)}else{const a=c.find(l=>m.startsWith(l.name+" "));if(a){const l=m.substring(a.name.length+1);p(`Boss ${l}`)}else m.startsWith("Boss ")||p(`Boss ${m}`)}},[d]);const Ae=()=>{if(_(!1),!L.trim()){_(!0);return}if(!m.trim()){const l=new Set(Array.from(S.getState().agents.values()).map(i=>i.name));p(ue(l));return}Ue(G.LAST_CWD,L),$(),window.__spawnModalAreaContext=g?{areaId:g}:null;const e=ae.trim()||void 0,a=Array.from(se);S.spawnBossAgent(m.trim(),d,L.trim(),me||void 0,Array.from(k),o==="claude"?Y:!1,Q,o,o==="codex"?f:void 0,o==="codex"?ee:void 0,o==="claude"?Z:void 0,e,a),p(""),B(new Set),U(new Set),P(),w()},$e=()=>{V(!1),p(""),B(new Set),P(),w()},Ee=()=>{V(!1),_(!0),P()};t.useEffect(()=>(window.__bossSpawnModalSuccess=$e,window.__bossSpawnModalError=Ee,()=>{delete window.__bossSpawnModalSuccess,delete window.__bossSpawnModalError}),[m]);const Le=e=>{e.target===e.currentTarget&&w()},Ie=e=>{e.key==="Escape"&&w()},_e=e=>{const a=new Set(k);a.has(e)?a.delete(e):a.add(e),B(a)};if(!u)return null;const De=O.boss;return s.jsx("div",{className:`modal-overlay ${u?"visible":""}`,onClick:Le,onKeyDown:Ie,children:s.jsxs("div",{className:"modal boss-spawn-modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx(y,{classId:"boss",size:22,className:"boss-header-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(Pe,{agentClass:ye,modelFile:Ce,customModelUrl:ke,modelScale:Me,width:100,height:120})}),s.jsxs("div",{className:"spawn-class-section",children:[s.jsx("div",{className:"spawn-class-label",children:n("terminal:spawn.bossClass")}),c.length+W.length+1>6&&s.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:n("terminal:spawn.filterClasses"),value:h,onChange:e=>be(e.target.value)}),s.jsxs("div",{className:"class-selector-inline",children:[ie.map(e=>s.jsxs("button",{className:`class-chip ${d===e.id?"selected":""}`,onClick:()=>I(e.id),title:e.description,children:[s.jsx(y,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)),oe&&s.jsxs("button",{className:`class-chip ${d==="boss"?"selected":""}`,onClick:()=>I("boss"),title:De.description,children:[s.jsx(y,{classId:"boss",size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:n("terminal:spawn.bossClassName")})]}),ce.map(e=>{const a=de[e.id];return a?s.jsxs("button",{className:`class-chip ${d===e.id?"selected":""}`,onClick:()=>I(e.id),title:a.description,children:[s.jsx(y,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id):null}),h&&ie.length===0&&!oe&&ce.length===0&&s.jsx("div",{className:"class-search-empty",children:n("terminal:spawn.noClassesMatch",{query:h})})]})]})]}),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:R,type:"text",className:"spawn-input",placeholder:n("terminal:spawn.bossNamePlaceholder"),value:m,onChange:e=>p(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(ze,{value:L,onChange:e=>{z(e),_(!1)},placeholder:n("terminal:spawn.workingDirPlaceholder"),className:"spawn-input",hasError:pe,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 ${o==="claude"?"selected":""}`,onClick:()=>D("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 ${o==="codex"?"selected":""}`,onClick:()=>D("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("button",{className:`spawn-select-btn spawn-select-btn--opencode ${o==="opencode"?"selected":""}`,onClick:()=>D("opencode"),title:"Use OpenCode CLI (multi-provider)",children:[s.jsx("span",{children:s.jsx(T,{name:"status-pending",size:14,weight:"fill",color:"#4ade80"})}),s.jsx("span",{children:"OpenCode"})]}),s.jsxs("button",{className:`spawn-select-btn spawn-select-btn--grok ${o==="grok"?"selected":""}`,onClick:()=>D("grok"),title:"Use Grok CLI (headless)",children:[s.jsx("img",{src:"/assets/grok.png",alt:"Grok",className:"spawn-provider-icon"}),s.jsx("span",{children:"Grok"})]})]})]}),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(K).map(e=>s.jsxs("button",{className:`spawn-select-btn ${Q===e?"selected":""}`,onClick:()=>we(e),title:K[e].description,children:[s.jsx("span",{children:s.jsx(T,{name:e==="bypass"?"bolt":"lock",size:14})}),s.jsx("span",{children:K[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")}),o==="claude"?s.jsx("div",{className:"spawn-select-row spawn-select-row--wrap",children:Object.keys(A).filter(e=>!A[e].deprecated).map(e=>s.jsxs("button",{className:`spawn-select-btn ${Z===e?"selected":""}`,onClick:()=>xe(e),title:A[e].description,children:[s.jsx("span",{children:A[e].icon}),s.jsx("span",{children:A[e].label})]},e))}):o==="codex"?s.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(F).map(e=>s.jsxs("button",{className:`spawn-select-btn ${ee===e?"selected":""}`,onClick:()=>fe(e),title:F[e].description,children:[s.jsx("span",{children:F[e].icon}),s.jsx("span",{children:F[e].label})]},e))}):o==="opencode"?s.jsx("input",{type:"text",className:"spawn-input",defaultValue:"minimax/MiniMax-M1-80k",placeholder:"provider/model (e.g., minimax/MiniMax-M1-80k)"}):o==="grok"?s.jsx("div",{className:"spawn-inline-hint",children:"grok-4.5"}):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:Y,onChange:e=>he(e.target.checked),disabled:o!=="claude"}),s.jsx("span",{children:n("terminal:spawn.chromeBrowser")})]})})]})]}),o==="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}))}),s.jsxs("select",{className:"spawn-input",value:f.reasoningEffort||"",onChange:e=>N(a=>({...a,reasoningEffort:e.target.value||void 0})),children:[s.jsx("option",{value:"",children:n("terminal:spawn.codex.reasoningEffortDefault")}),Object.keys(H).map(e=>s.jsxs("option",{value:e,children:[H[e].icon," ",n("terminal:spawn.codex.reasoningEffort"),": ",H[e].label]},e))]})]})]})}),b.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"),")"]})]}),b.length>6&&s.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:n("terminal:spawn.filterSkills"),value:v,onChange:e=>je(e.target.value)}),s.jsxs("div",{className:"spawn-skills-inline",children:[le.map(e=>{const a=se.has(e.id);return Ne.some(i=>i.id===e.id)?null:s.jsxs("button",{className:`spawn-skill-chip ${a?"selected":""}`,onClick:()=>Se(e.id),title:e.description,children:[a&&s.jsx("span",{className:"spawn-skill-check",children:s.jsx(T,{name:"check",size:12})}),s.jsx("span",{children:e.name}),e.builtin&&s.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},e.id)}),v&&le.length===0&&s.jsx("div",{className:"skill-search-empty",children:n("terminal:spawn.noSkillsMatch",{query:v})})]})]}),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:ae,onChange:e=>ge(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:te.length===0?s.jsx("div",{className:"subordinates-empty",children:n("terminal:spawn.noAvailableAgents")}):te.map(e=>{const a=k.has(e.id),l=O[e.class],i=c.find(x=>x.id===e.class),j=l||i||{color:"#888888"};return s.jsxs("button",{className:`subordinate-chip ${a?"selected":""}`,onClick:()=>_e(e.id),children:[a&&s.jsx("span",{className:"subordinate-check",children:s.jsx(T,{name:"check",size:12})}),s.jsx("span",{className:"subordinate-chip-icon",style:{color:j.color},children:s.jsx(y,{classId:e.class,size:16})}),s.jsx("span",{className:"subordinate-chip-name",children:e.name})]},e.id)})}),k.size>0&&s.jsxs("div",{className:"subordinates-count",children:[k.size," ",n("common:labels.selected").toLowerCase()]})]})]})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:w,children:n("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-boss",onClick:Ae,disabled:X,children:n(X?"common:buttons.deploying":"common:buttons2.deployBoss")})]})]})})}export{Ke as BossSpawnModal};
@@ -1 +1 @@
1
- import{u as K,cR as Q,aC as J,cS as W,cT as ee,r as u,aq as se,n as te,cG as D,cU as z,cV as ae,j as e,cW as ne,C as re,s as g,cX as R,cY as V}from"./main-DDwa0x9e.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const G={global:"terminal:controls.contextGlobal",commander:"terminal:controls.contextCommander",toolbox:"terminal:controls.contextToolbox"},le={global:"terminal:controls.contextGlobalDesc",commander:"terminal:controls.contextCommanderDesc",toolbox:"terminal:controls.contextToolboxDesc"},U={camera:["camera-pan","camera-orbit","camera-rotate","camera-zoom","camera-tilt"],interaction:["primary-action","selection-box","context-menu","move-command"]},ce={camera:"terminal:controls.cameraControls",interaction:"terminal:controls.interaction"};function pe({isOpen:s,onClose:r}){const{t:a}=K(["terminal","common"]),l=Q(),c=J(),h=W(),N=ee(),[x,C]=u.useState("keyboard"),[b,v]=u.useState(""),[p,j]=u.useState("all"),[m,f]=u.useState(!1),[o,d]=u.useState(null),[k,w]=u.useState(null),Y=se.useRef(null),{handleMouseDown:X,handleClick:I}=te(r);if(u.useEffect(()=>{if(!s||m)return;const t=n=>{n.key==="Escape"&&(n.preventDefault(),n.stopPropagation(),r())};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[s,r,m]),u.useEffect(()=>{s||(v(""),f(!1),d(null))},[s]),u.useEffect(()=>{if(!s||!m)return;const t=n=>{if(n.key==="Escape"){n.preventDefault(),n.stopPropagation(),f(!1),d(null);return}if(["Control","Alt","Shift","Meta"].includes(n.key))return;n.preventDefault(),n.stopPropagation();let i=n.key;n.code.startsWith("Key")&&n.code.length===4?i=n.code.charAt(3).toLowerCase():n.code.startsWith("Digit")&&n.code.length===6?i=n.code.charAt(5):n.code==="Space"&&(i="Space"),d({key:i,modifiers:{ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey,meta:n.metaKey}})};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[s,m]),!s)return null;const F=l.filter(t=>{const n=a(`terminal:controls.shortcuts.${t.id}.name`,{defaultValue:t.name}),i=a(`terminal:controls.shortcuts.${t.id}.description`,{defaultValue:t.description});if(m&&o){const A=S=>S===" "||S==="Space"?"Space":S.length===1?S.toLowerCase():S,B=A(t.key),L=A(o.key);if(!(L.length===1&&/^[a-zA-Z]$/.test(B)?`Key${B.toUpperCase()}`==`Key${L.toUpperCase()}`:B===L))return!1;const M=t.modifiers,T=o.modifiers;return(M.ctrl||!1)===(T.ctrl||!1)&&(M.alt||!1)===(T.alt||!1)&&(M.shift||!1)===(T.shift||!1)&&(M.meta||!1)===(T.meta||!1)}if(!b)return!0;const y=b.toLowerCase();return n.toLowerCase().includes(y)||i.toLowerCase().includes(y)||D(t).toLowerCase().includes(y)}),E=Array.from(c.values()).map(t=>t).filter(t=>t.shortcut&&t.shortcut.trim().length>0).filter(t=>{const n=z(t.shortcut).toLowerCase();if(m&&o){const y={key:o.key,code:o.key.length===1&&/^[a-zA-Z]$/.test(o.key)?`Key${o.key.toUpperCase()}`:o.key.length===1&&/^[0-9]$/.test(o.key)?`Digit${o.key}`:o.key==="Space"?"Space":o.key,ctrlKey:!!o.modifiers.ctrl,altKey:!!o.modifiers.alt,shiftKey:!!o.modifiers.shift,metaKey:!!o.modifiers.meta};return ae(y,t.shortcut)}if(!b)return!0;const i=b.toLowerCase();return t.name.toLowerCase().includes(i)||n.toLowerCase().includes(i)}),P=F.reduce((t,n)=>(t[n.context]||(t[n.context]=[]),t[n.context].push(n),t),{}),Z=(t,n)=>{g.updateShortcut(t,n)},$=()=>{w(x)},_=()=>{k==="keyboard"?g.resetShortcuts():(k==="mouse"||k==="trackpad")&&g.resetMouseControls()},q=k==="keyboard"?"terminal:controls.confirmResetKeyboard":k==="mouse"?"terminal:controls.confirmResetMouse":"terminal:controls.confirmResetTrackpad",O=["global","commander","toolbox"],H=h.bindings.reduce((t,n)=>(U.camera.includes(n.action)?t.camera.push(n):U.interaction.includes(n.action)&&t.interaction.push(n),t),{camera:[],interaction:[]});return e.jsxs("div",{className:"shortcuts-modal-overlay",onMouseDown:X,onClick:I,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:a("terminal:controls.title")})]}),e.jsx("button",{className:"shortcuts-modal-close",onClick:r,children:"×"})]}),e.jsxs("div",{className:"controls-main-tabs",children:[e.jsxs("button",{className:`controls-main-tab ${x==="keyboard"?"active":""}`,onClick:()=>C("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"})]}),a("terminal:controls.keyboard")]}),e.jsxs("button",{className:`controls-main-tab ${x==="mouse"?"active":""}`,onClick:()=>C("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"})]}),a("terminal:controls.mouse")]}),e.jsxs("button",{className:`controls-main-tab ${x==="trackpad"?"active":""}`,onClick:()=>C("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"})]}),a("terminal:controls.trackpad")]})]}),x==="keyboard"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shortcuts-modal-toolbar",children:[m?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"})]}),o?e.jsxs("span",{className:"find-by-shortcut-display",children:[D({key:o.key,modifiers:o.modifiers}),e.jsx("button",{className:"shortcuts-search-clear",onClick:()=>d(null),children:"×"})]}):e.jsx("span",{className:"find-by-shortcut-prompt",children:a("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:Y,type:"text",placeholder:a("terminal:controls.searchShortcuts"),value:b,onChange:t=>v(t.target.value),autoFocus:!0}),b&&e.jsx("button",{className:"shortcuts-search-clear",onClick:()=>v(""),children:"×"})]}),e.jsx("button",{className:`shortcuts-find-by-key-btn ${m?"active":""}`,onClick:()=>{f(!m),d(null),v("")},title:a(m?"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:$,children:a("common:buttons.reset")})]}),e.jsxs("div",{className:"shortcuts-context-tabs",children:[e.jsxs("button",{className:`shortcuts-context-tab ${p==="all"?"active":""}`,onClick:()=>j("all"),children:[a("common:labels.all"),e.jsx("span",{className:"shortcuts-context-tab-count",children:F.length})]}),O.map(t=>{var i;const n=((i=P[t])==null?void 0:i.length)||0;return e.jsxs("button",{className:`shortcuts-context-tab ${p===t?"active":""}`,onClick:()=>j(t),children:[a(G[t]),e.jsx("span",{className:"shortcuts-context-tab-count",children:n})]},t)})]}),e.jsxs("div",{className:"shortcuts-modal-content",children:[O.map(t=>{const n=P[t]||[];return n.length===0||p!=="all"&&p!==t?null:e.jsxs("div",{className:"shortcuts-context-group",children:[p==="all"&&e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:a(G[t])}),e.jsx("span",{className:"shortcuts-context-description",children:a(le[t])})]}),e.jsx("div",{className:"shortcuts-grid",children:n.map(i=>e.jsxs("div",{className:"shortcut-item",children:[e.jsxs("div",{className:"shortcut-item-info",children:[e.jsx("span",{className:"shortcut-item-name",children:a(`terminal:controls.shortcuts.${i.id}.name`,{defaultValue:i.name})}),e.jsx("span",{className:"shortcut-item-description",children:a(`terminal:controls.shortcuts.${i.id}.description`,{defaultValue:i.description})})]}),e.jsx(ne,{shortcut:i,onUpdate:y=>Z(i.id,y)})]},i.id))})]},t)}),F.length===0&&E.length===0&&e.jsx("div",{className:"shortcuts-empty",children:m?o?e.jsx("p",{children:a("terminal:controls.noShortcutBoundTo",{keys:D({key:o.key,modifiers:o.modifiers})})}):e.jsx("p",{children:a("terminal:controls.pressKeyCombinationToFind")}):e.jsx("p",{children:a("terminal:controls.noShortcutsFound",{query:b})})}),E.length>0&&(p==="all"||p==="global")&&e.jsxs("div",{className:"shortcuts-context-group",children:[p==="all"&&e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:"Agent Terminal Shortcuts"}),e.jsx("span",{className:"shortcuts-context-description",children:"Per-agent global shortcuts that open the guake terminal"})]}),e.jsx("div",{className:"shortcuts-grid",children:E.map(t=>e.jsxs("div",{className:"shortcut-item",children:[e.jsxs("div",{className:"shortcut-item-info",children:[e.jsx("span",{className:"shortcut-item-name",children:t.name}),e.jsx("span",{className:"shortcut-item-description",children:"Open terminal for this agent"})]}),e.jsx("div",{className:"key-capture-container",children:e.jsx("button",{className:"key-capture-input disabled",disabled:!0,children:e.jsx("span",{className:"key-capture-value",children:z(t.shortcut)})})})]},t.id))})]})]})]}),x==="mouse"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shortcuts-modal-toolbar",children:[e.jsx("span",{className:"mouse-controls-subtitle",children:a("terminal:controls.cameraAndInteraction")}),e.jsx("button",{className:"shortcuts-reset-all-btn",onClick:$,children:a("common:buttons.reset")})]}),e.jsxs("div",{className:"shortcuts-modal-content mouse-controls-content",children:[e.jsx("div",{className:"mouse-controls-bindings",children:Object.entries(H).map(([t,n])=>e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsx("div",{className:"shortcuts-context-header",children:e.jsx("span",{className:"shortcuts-context-label",children:a(ce[t])})}),e.jsx("div",{className:"shortcuts-grid",children:n.map(i=>e.jsx(oe,{binding:i},i.id))})]},t))}),e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:a("terminal:controls.sensitivity")}),e.jsx("span",{className:"shortcuts-context-description",children:a("terminal:controls.adjustCameraSpeed")})]}),e.jsx(ie,{sensitivity:h.sensitivity})]})]})]}),x==="trackpad"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shortcuts-modal-toolbar",children:[e.jsx("span",{className:"mouse-controls-subtitle",children:a("terminal:controls.trackpadGestureSettings")}),e.jsx("button",{className:"shortcuts-reset-all-btn",onClick:$,children:a("common:buttons.reset")})]}),e.jsx("div",{className:"shortcuts-modal-content trackpad-controls-content",children:e.jsx(de,{config:N})})]}),e.jsx("div",{className:"shortcuts-modal-footer",children:e.jsx("span",{className:"shortcuts-modal-hint",children:a(x==="keyboard"?m?"terminal:controls.hintFindByShortcut":"terminal:controls.hintKeyboard":x==="mouse"?"terminal:controls.hintMouse":"terminal:controls.hintTrackpad")})})]}),e.jsx(re,{isOpen:k!==null,title:a("common:buttons.resetToDefaults"),message:a(q),confirmLabel:a("common:buttons.reset"),cancelLabel:a("common:buttons.cancel"),variant:"danger",onConfirm:_,onClose:()=>w(null)})]})}function oe({binding:s}){const{t:r}=K(["terminal"]),a=W(),[l,c]=u.useState(!1),[h,N]=u.useState(null);u.useEffect(()=>{if(!l)return;const j=d=>{d.preventDefault(),d.stopPropagation();const w={0:"left",1:"middle",2:"right",3:"back",4:"forward"}[d.button];w&&N({button:w,modifiers:{ctrl:d.ctrlKey,alt:d.altKey,shift:d.shiftKey,meta:d.metaKey}})},m=d=>{d.key==="Escape"&&(d.preventDefault(),d.stopPropagation(),c(!1),N(null))},f=()=>{h&&R(a.bindings,h,s.id).length===0&&g.updateMouseBinding(s.id,{button:h.button,modifiers:h.modifiers}),c(!1),N(null)},o=setTimeout(()=>{document.addEventListener("mousedown",j,!0),document.addEventListener("keydown",m,!0),document.addEventListener("click",f,!0)},100);return()=>{clearTimeout(o),document.removeEventListener("mousedown",j,!0),document.removeEventListener("keydown",m,!0),document.removeEventListener("click",f,!0)}},[l,h,s.id,a.bindings]);const x=h?R(a.bindings,h,s.id):[],C=r(`terminal:controls.mouseBindings.${s.id}.name`,{defaultValue:s.name}),b=r(`terminal:controls.mouseBindings.${s.id}.description`,{defaultValue:s.description}),v=j=>r(`terminal:controls.mouseButtons.${j}`,{defaultValue:j}),p=h?V({...s,...h},v):V(s,v);return e.jsxs("div",{className:`shortcut-item ${s.enabled?"":"disabled"}`,children:[e.jsxs("div",{className:"shortcut-item-info",children:[e.jsx("span",{className:"shortcut-item-name",children:C}),e.jsx("span",{className:"shortcut-item-description",children:b})]}),e.jsxs("div",{className:"key-capture-container",children:[e.jsx("button",{className:`key-capture-input ${l?"capturing":""} ${x.length>0?"conflict":""}`,onClick:()=>c(!0),children:l?h?e.jsx("span",{className:"key-capture-value",style:{color:"#f1fa8c"},children:p}):e.jsx("span",{style:{color:"#6272a4",fontStyle:"italic"},children:r("terminal:controls.clickToCapture")}):e.jsx("span",{className:"key-capture-value",children:p})}),x.length>0&&e.jsxs("span",{className:"key-capture-conflict",children:[r("terminal:controls.conflicts"),": ",x.map(j=>r(`terminal:controls.mouseBindings.${j.id}.name`,{defaultValue:j.name})).join(", ")]})]})]})}function ie({sensitivity:s}){const{t:r}=K(["terminal"]),a=u.useCallback((l,c)=>{g.updateCameraSensitivity({[l]:c})},[]);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:r("terminal:controls.panSpeed")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.panSpeed,onChange:l=>a("panSpeed",parseFloat(l.target.value))}),e.jsxs("span",{className:"sensitivity-slider-value",children:[s.panSpeed.toFixed(1),"x"]})]}),e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:r("terminal:controls.orbitSpeed")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.orbitSpeed,onChange:l=>a("orbitSpeed",parseFloat(l.target.value))}),e.jsxs("span",{className:"sensitivity-slider-value",children:[s.orbitSpeed.toFixed(1),"x"]})]}),e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:r("terminal:controls.zoomSpeed")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.zoomSpeed,onChange:l=>a("zoomSpeed",parseFloat(l.target.value))}),e.jsxs("span",{className:"sensitivity-slider-value",children:[s.zoomSpeed.toFixed(1),"x"]})]}),e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:r("terminal:controls.smoothing")}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:s.smoothing,onChange:l=>a("smoothing",parseFloat(l.target.value))}),e.jsx("span",{className:"sensitivity-slider-value",children:s.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:s.invertPanX,onChange:l=>a("invertPanX",l.target.checked)}),e.jsx("span",{children:r("terminal:controls.invertPanX")})]}),e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:s.invertPanY,onChange:l=>a("invertPanY",l.target.checked)}),e.jsx("span",{children:r("terminal:controls.invertPanY")})]}),e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:s.invertOrbitX,onChange:l=>a("invertOrbitX",l.target.checked)}),e.jsx("span",{children:r("terminal:controls.invertOrbitX")})]}),e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:s.invertOrbitY,onChange:l=>a("invertOrbitY",l.target.checked)}),e.jsx("span",{children:r("terminal:controls.invertOrbitY")})]})]})]})}function de({config:s}){const{t:r}=K(["terminal"]),a=u.useCallback((c,h)=>{g.updateTrackpadConfig({[c]:h})},[]),l=u.useCallback((c,h)=>{g.updateTrackpadConfig({sensitivity:{[c]: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:r("terminal:controls.trackpadGestures")}),e.jsx("span",{className:"shortcuts-context-description",children:r("terminal:controls.enableTrackpadSupport")})]}),e.jsx("div",{className:"trackpad-toggle-row",children:e.jsxs("label",{className:"trackpad-toggle",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:c=>a("enabled",c.target.checked)}),e.jsx("span",{className:"trackpad-toggle-label",children:r("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:r("terminal:controls.gestureControls")}),e.jsx("span",{className:"shortcuts-context-description",children:r("terminal:controls.enableDisableGestures")})]}),e.jsxs("div",{className:"trackpad-gestures-grid",children:[e.jsxs("label",{className:`trackpad-gesture-item ${s.enabled?"":"disabled"}`,children:[e.jsx("input",{type:"checkbox",checked:s.pinchToZoom,onChange:c=>a("pinchToZoom",c.target.checked),disabled:!s.enabled}),e.jsxs("div",{className:"trackpad-gesture-info",children:[e.jsx("span",{className:"trackpad-gesture-name",children:r("terminal:controls.pinchToZoom")}),e.jsx("span",{className:"trackpad-gesture-desc",children:r("terminal:controls.pinchToZoomDesc")})]})]}),e.jsxs("label",{className:`trackpad-gesture-item ${s.enabled?"":"disabled"}`,children:[e.jsx("input",{type:"checkbox",checked:s.twoFingerPan,onChange:c=>a("twoFingerPan",c.target.checked),disabled:!s.enabled}),e.jsxs("div",{className:"trackpad-gesture-info",children:[e.jsx("span",{className:"trackpad-gesture-name",children:r("terminal:controls.twoFingerPan")}),e.jsx("span",{className:"trackpad-gesture-desc",children:r("terminal:controls.twoFingerPanDesc")})]})]}),e.jsxs("label",{className:`trackpad-gesture-item ${s.enabled?"":"disabled"}`,children:[e.jsx("input",{type:"checkbox",checked:s.shiftTwoFingerOrbit,onChange:c=>a("shiftTwoFingerOrbit",c.target.checked),disabled:!s.enabled}),e.jsxs("div",{className:"trackpad-gesture-info",children:[e.jsx("span",{className:"trackpad-gesture-name",children:r("terminal:controls.shiftTwoFingerOrbit")}),e.jsx("span",{className:"trackpad-gesture-desc",children:r("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:r("terminal:controls.sensitivity")}),e.jsx("span",{className:"shortcuts-context-description",children:r("terminal:controls.adjustGestureSensitivity")})]}),e.jsxs("div",{className:"trackpad-sensitivity-sliders",children:[e.jsxs("div",{className:`trackpad-slider-row ${!s.enabled||!s.pinchToZoom?"disabled":""}`,children:[e.jsx("label",{children:r("terminal:controls.zoom")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.sensitivity.zoom,onChange:c=>l("zoom",parseFloat(c.target.value)),disabled:!s.enabled||!s.pinchToZoom}),e.jsxs("span",{className:"trackpad-slider-value",children:[s.sensitivity.zoom.toFixed(1),"x"]})]}),e.jsxs("div",{className:`trackpad-slider-row ${!s.enabled||!s.twoFingerPan?"disabled":""}`,children:[e.jsx("label",{children:r("terminal:controls.pan")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.sensitivity.pan,onChange:c=>l("pan",parseFloat(c.target.value)),disabled:!s.enabled||!s.twoFingerPan}),e.jsxs("span",{className:"trackpad-slider-value",children:[s.sensitivity.pan.toFixed(1),"x"]})]}),e.jsxs("div",{className:`trackpad-slider-row ${!s.enabled||!s.shiftTwoFingerOrbit?"disabled":""}`,children:[e.jsx("label",{children:r("terminal:controls.orbit")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.sensitivity.orbit,onChange:c=>l("orbit",parseFloat(c.target.value)),disabled:!s.enabled||!s.shiftTwoFingerOrbit}),e.jsxs("span",{className:"trackpad-slider-value",children:[s.sensitivity.orbit.toFixed(1),"x"]})]})]})]})]})}export{pe as ControlsModal};
1
+ import{u as K,cR as Q,aC as J,cS as W,cT as ee,r as u,aq as se,n as te,cG as D,cU as z,cV as ae,j as e,cW as ne,C as re,s as g,cX as R,cY as V}from"./main-D8A4ans-.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const G={global:"terminal:controls.contextGlobal",commander:"terminal:controls.contextCommander",toolbox:"terminal:controls.contextToolbox"},le={global:"terminal:controls.contextGlobalDesc",commander:"terminal:controls.contextCommanderDesc",toolbox:"terminal:controls.contextToolboxDesc"},U={camera:["camera-pan","camera-orbit","camera-rotate","camera-zoom","camera-tilt"],interaction:["primary-action","selection-box","context-menu","move-command"]},ce={camera:"terminal:controls.cameraControls",interaction:"terminal:controls.interaction"};function pe({isOpen:s,onClose:r}){const{t:a}=K(["terminal","common"]),l=Q(),c=J(),h=W(),N=ee(),[x,C]=u.useState("keyboard"),[b,v]=u.useState(""),[p,j]=u.useState("all"),[m,f]=u.useState(!1),[o,d]=u.useState(null),[k,w]=u.useState(null),Y=se.useRef(null),{handleMouseDown:X,handleClick:I}=te(r);if(u.useEffect(()=>{if(!s||m)return;const t=n=>{n.key==="Escape"&&(n.preventDefault(),n.stopPropagation(),r())};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[s,r,m]),u.useEffect(()=>{s||(v(""),f(!1),d(null))},[s]),u.useEffect(()=>{if(!s||!m)return;const t=n=>{if(n.key==="Escape"){n.preventDefault(),n.stopPropagation(),f(!1),d(null);return}if(["Control","Alt","Shift","Meta"].includes(n.key))return;n.preventDefault(),n.stopPropagation();let i=n.key;n.code.startsWith("Key")&&n.code.length===4?i=n.code.charAt(3).toLowerCase():n.code.startsWith("Digit")&&n.code.length===6?i=n.code.charAt(5):n.code==="Space"&&(i="Space"),d({key:i,modifiers:{ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey,meta:n.metaKey}})};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[s,m]),!s)return null;const F=l.filter(t=>{const n=a(`terminal:controls.shortcuts.${t.id}.name`,{defaultValue:t.name}),i=a(`terminal:controls.shortcuts.${t.id}.description`,{defaultValue:t.description});if(m&&o){const A=S=>S===" "||S==="Space"?"Space":S.length===1?S.toLowerCase():S,B=A(t.key),L=A(o.key);if(!(L.length===1&&/^[a-zA-Z]$/.test(B)?`Key${B.toUpperCase()}`==`Key${L.toUpperCase()}`:B===L))return!1;const M=t.modifiers,T=o.modifiers;return(M.ctrl||!1)===(T.ctrl||!1)&&(M.alt||!1)===(T.alt||!1)&&(M.shift||!1)===(T.shift||!1)&&(M.meta||!1)===(T.meta||!1)}if(!b)return!0;const y=b.toLowerCase();return n.toLowerCase().includes(y)||i.toLowerCase().includes(y)||D(t).toLowerCase().includes(y)}),E=Array.from(c.values()).map(t=>t).filter(t=>t.shortcut&&t.shortcut.trim().length>0).filter(t=>{const n=z(t.shortcut).toLowerCase();if(m&&o){const y={key:o.key,code:o.key.length===1&&/^[a-zA-Z]$/.test(o.key)?`Key${o.key.toUpperCase()}`:o.key.length===1&&/^[0-9]$/.test(o.key)?`Digit${o.key}`:o.key==="Space"?"Space":o.key,ctrlKey:!!o.modifiers.ctrl,altKey:!!o.modifiers.alt,shiftKey:!!o.modifiers.shift,metaKey:!!o.modifiers.meta};return ae(y,t.shortcut)}if(!b)return!0;const i=b.toLowerCase();return t.name.toLowerCase().includes(i)||n.toLowerCase().includes(i)}),P=F.reduce((t,n)=>(t[n.context]||(t[n.context]=[]),t[n.context].push(n),t),{}),Z=(t,n)=>{g.updateShortcut(t,n)},$=()=>{w(x)},_=()=>{k==="keyboard"?g.resetShortcuts():(k==="mouse"||k==="trackpad")&&g.resetMouseControls()},q=k==="keyboard"?"terminal:controls.confirmResetKeyboard":k==="mouse"?"terminal:controls.confirmResetMouse":"terminal:controls.confirmResetTrackpad",O=["global","commander","toolbox"],H=h.bindings.reduce((t,n)=>(U.camera.includes(n.action)?t.camera.push(n):U.interaction.includes(n.action)&&t.interaction.push(n),t),{camera:[],interaction:[]});return e.jsxs("div",{className:"shortcuts-modal-overlay",onMouseDown:X,onClick:I,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:a("terminal:controls.title")})]}),e.jsx("button",{className:"shortcuts-modal-close",onClick:r,children:"×"})]}),e.jsxs("div",{className:"controls-main-tabs",children:[e.jsxs("button",{className:`controls-main-tab ${x==="keyboard"?"active":""}`,onClick:()=>C("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"})]}),a("terminal:controls.keyboard")]}),e.jsxs("button",{className:`controls-main-tab ${x==="mouse"?"active":""}`,onClick:()=>C("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"})]}),a("terminal:controls.mouse")]}),e.jsxs("button",{className:`controls-main-tab ${x==="trackpad"?"active":""}`,onClick:()=>C("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"})]}),a("terminal:controls.trackpad")]})]}),x==="keyboard"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shortcuts-modal-toolbar",children:[m?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"})]}),o?e.jsxs("span",{className:"find-by-shortcut-display",children:[D({key:o.key,modifiers:o.modifiers}),e.jsx("button",{className:"shortcuts-search-clear",onClick:()=>d(null),children:"×"})]}):e.jsx("span",{className:"find-by-shortcut-prompt",children:a("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:Y,type:"text",placeholder:a("terminal:controls.searchShortcuts"),value:b,onChange:t=>v(t.target.value),autoFocus:!0}),b&&e.jsx("button",{className:"shortcuts-search-clear",onClick:()=>v(""),children:"×"})]}),e.jsx("button",{className:`shortcuts-find-by-key-btn ${m?"active":""}`,onClick:()=>{f(!m),d(null),v("")},title:a(m?"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:$,children:a("common:buttons.reset")})]}),e.jsxs("div",{className:"shortcuts-context-tabs",children:[e.jsxs("button",{className:`shortcuts-context-tab ${p==="all"?"active":""}`,onClick:()=>j("all"),children:[a("common:labels.all"),e.jsx("span",{className:"shortcuts-context-tab-count",children:F.length})]}),O.map(t=>{var i;const n=((i=P[t])==null?void 0:i.length)||0;return e.jsxs("button",{className:`shortcuts-context-tab ${p===t?"active":""}`,onClick:()=>j(t),children:[a(G[t]),e.jsx("span",{className:"shortcuts-context-tab-count",children:n})]},t)})]}),e.jsxs("div",{className:"shortcuts-modal-content",children:[O.map(t=>{const n=P[t]||[];return n.length===0||p!=="all"&&p!==t?null:e.jsxs("div",{className:"shortcuts-context-group",children:[p==="all"&&e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:a(G[t])}),e.jsx("span",{className:"shortcuts-context-description",children:a(le[t])})]}),e.jsx("div",{className:"shortcuts-grid",children:n.map(i=>e.jsxs("div",{className:"shortcut-item",children:[e.jsxs("div",{className:"shortcut-item-info",children:[e.jsx("span",{className:"shortcut-item-name",children:a(`terminal:controls.shortcuts.${i.id}.name`,{defaultValue:i.name})}),e.jsx("span",{className:"shortcut-item-description",children:a(`terminal:controls.shortcuts.${i.id}.description`,{defaultValue:i.description})})]}),e.jsx(ne,{shortcut:i,onUpdate:y=>Z(i.id,y)})]},i.id))})]},t)}),F.length===0&&E.length===0&&e.jsx("div",{className:"shortcuts-empty",children:m?o?e.jsx("p",{children:a("terminal:controls.noShortcutBoundTo",{keys:D({key:o.key,modifiers:o.modifiers})})}):e.jsx("p",{children:a("terminal:controls.pressKeyCombinationToFind")}):e.jsx("p",{children:a("terminal:controls.noShortcutsFound",{query:b})})}),E.length>0&&(p==="all"||p==="global")&&e.jsxs("div",{className:"shortcuts-context-group",children:[p==="all"&&e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:"Agent Terminal Shortcuts"}),e.jsx("span",{className:"shortcuts-context-description",children:"Per-agent global shortcuts that open the guake terminal"})]}),e.jsx("div",{className:"shortcuts-grid",children:E.map(t=>e.jsxs("div",{className:"shortcut-item",children:[e.jsxs("div",{className:"shortcut-item-info",children:[e.jsx("span",{className:"shortcut-item-name",children:t.name}),e.jsx("span",{className:"shortcut-item-description",children:"Open terminal for this agent"})]}),e.jsx("div",{className:"key-capture-container",children:e.jsx("button",{className:"key-capture-input disabled",disabled:!0,children:e.jsx("span",{className:"key-capture-value",children:z(t.shortcut)})})})]},t.id))})]})]})]}),x==="mouse"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shortcuts-modal-toolbar",children:[e.jsx("span",{className:"mouse-controls-subtitle",children:a("terminal:controls.cameraAndInteraction")}),e.jsx("button",{className:"shortcuts-reset-all-btn",onClick:$,children:a("common:buttons.reset")})]}),e.jsxs("div",{className:"shortcuts-modal-content mouse-controls-content",children:[e.jsx("div",{className:"mouse-controls-bindings",children:Object.entries(H).map(([t,n])=>e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsx("div",{className:"shortcuts-context-header",children:e.jsx("span",{className:"shortcuts-context-label",children:a(ce[t])})}),e.jsx("div",{className:"shortcuts-grid",children:n.map(i=>e.jsx(oe,{binding:i},i.id))})]},t))}),e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:a("terminal:controls.sensitivity")}),e.jsx("span",{className:"shortcuts-context-description",children:a("terminal:controls.adjustCameraSpeed")})]}),e.jsx(ie,{sensitivity:h.sensitivity})]})]})]}),x==="trackpad"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shortcuts-modal-toolbar",children:[e.jsx("span",{className:"mouse-controls-subtitle",children:a("terminal:controls.trackpadGestureSettings")}),e.jsx("button",{className:"shortcuts-reset-all-btn",onClick:$,children:a("common:buttons.reset")})]}),e.jsx("div",{className:"shortcuts-modal-content trackpad-controls-content",children:e.jsx(de,{config:N})})]}),e.jsx("div",{className:"shortcuts-modal-footer",children:e.jsx("span",{className:"shortcuts-modal-hint",children:a(x==="keyboard"?m?"terminal:controls.hintFindByShortcut":"terminal:controls.hintKeyboard":x==="mouse"?"terminal:controls.hintMouse":"terminal:controls.hintTrackpad")})})]}),e.jsx(re,{isOpen:k!==null,title:a("common:buttons.resetToDefaults"),message:a(q),confirmLabel:a("common:buttons.reset"),cancelLabel:a("common:buttons.cancel"),variant:"danger",onConfirm:_,onClose:()=>w(null)})]})}function oe({binding:s}){const{t:r}=K(["terminal"]),a=W(),[l,c]=u.useState(!1),[h,N]=u.useState(null);u.useEffect(()=>{if(!l)return;const j=d=>{d.preventDefault(),d.stopPropagation();const w={0:"left",1:"middle",2:"right",3:"back",4:"forward"}[d.button];w&&N({button:w,modifiers:{ctrl:d.ctrlKey,alt:d.altKey,shift:d.shiftKey,meta:d.metaKey}})},m=d=>{d.key==="Escape"&&(d.preventDefault(),d.stopPropagation(),c(!1),N(null))},f=()=>{h&&R(a.bindings,h,s.id).length===0&&g.updateMouseBinding(s.id,{button:h.button,modifiers:h.modifiers}),c(!1),N(null)},o=setTimeout(()=>{document.addEventListener("mousedown",j,!0),document.addEventListener("keydown",m,!0),document.addEventListener("click",f,!0)},100);return()=>{clearTimeout(o),document.removeEventListener("mousedown",j,!0),document.removeEventListener("keydown",m,!0),document.removeEventListener("click",f,!0)}},[l,h,s.id,a.bindings]);const x=h?R(a.bindings,h,s.id):[],C=r(`terminal:controls.mouseBindings.${s.id}.name`,{defaultValue:s.name}),b=r(`terminal:controls.mouseBindings.${s.id}.description`,{defaultValue:s.description}),v=j=>r(`terminal:controls.mouseButtons.${j}`,{defaultValue:j}),p=h?V({...s,...h},v):V(s,v);return e.jsxs("div",{className:`shortcut-item ${s.enabled?"":"disabled"}`,children:[e.jsxs("div",{className:"shortcut-item-info",children:[e.jsx("span",{className:"shortcut-item-name",children:C}),e.jsx("span",{className:"shortcut-item-description",children:b})]}),e.jsxs("div",{className:"key-capture-container",children:[e.jsx("button",{className:`key-capture-input ${l?"capturing":""} ${x.length>0?"conflict":""}`,onClick:()=>c(!0),children:l?h?e.jsx("span",{className:"key-capture-value",style:{color:"#f1fa8c"},children:p}):e.jsx("span",{style:{color:"#6272a4",fontStyle:"italic"},children:r("terminal:controls.clickToCapture")}):e.jsx("span",{className:"key-capture-value",children:p})}),x.length>0&&e.jsxs("span",{className:"key-capture-conflict",children:[r("terminal:controls.conflicts"),": ",x.map(j=>r(`terminal:controls.mouseBindings.${j.id}.name`,{defaultValue:j.name})).join(", ")]})]})]})}function ie({sensitivity:s}){const{t:r}=K(["terminal"]),a=u.useCallback((l,c)=>{g.updateCameraSensitivity({[l]:c})},[]);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:r("terminal:controls.panSpeed")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.panSpeed,onChange:l=>a("panSpeed",parseFloat(l.target.value))}),e.jsxs("span",{className:"sensitivity-slider-value",children:[s.panSpeed.toFixed(1),"x"]})]}),e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:r("terminal:controls.orbitSpeed")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.orbitSpeed,onChange:l=>a("orbitSpeed",parseFloat(l.target.value))}),e.jsxs("span",{className:"sensitivity-slider-value",children:[s.orbitSpeed.toFixed(1),"x"]})]}),e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:r("terminal:controls.zoomSpeed")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.zoomSpeed,onChange:l=>a("zoomSpeed",parseFloat(l.target.value))}),e.jsxs("span",{className:"sensitivity-slider-value",children:[s.zoomSpeed.toFixed(1),"x"]})]}),e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:r("terminal:controls.smoothing")}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:s.smoothing,onChange:l=>a("smoothing",parseFloat(l.target.value))}),e.jsx("span",{className:"sensitivity-slider-value",children:s.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:s.invertPanX,onChange:l=>a("invertPanX",l.target.checked)}),e.jsx("span",{children:r("terminal:controls.invertPanX")})]}),e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:s.invertPanY,onChange:l=>a("invertPanY",l.target.checked)}),e.jsx("span",{children:r("terminal:controls.invertPanY")})]}),e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:s.invertOrbitX,onChange:l=>a("invertOrbitX",l.target.checked)}),e.jsx("span",{children:r("terminal:controls.invertOrbitX")})]}),e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:s.invertOrbitY,onChange:l=>a("invertOrbitY",l.target.checked)}),e.jsx("span",{children:r("terminal:controls.invertOrbitY")})]})]})]})}function de({config:s}){const{t:r}=K(["terminal"]),a=u.useCallback((c,h)=>{g.updateTrackpadConfig({[c]:h})},[]),l=u.useCallback((c,h)=>{g.updateTrackpadConfig({sensitivity:{[c]: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:r("terminal:controls.trackpadGestures")}),e.jsx("span",{className:"shortcuts-context-description",children:r("terminal:controls.enableTrackpadSupport")})]}),e.jsx("div",{className:"trackpad-toggle-row",children:e.jsxs("label",{className:"trackpad-toggle",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:c=>a("enabled",c.target.checked)}),e.jsx("span",{className:"trackpad-toggle-label",children:r("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:r("terminal:controls.gestureControls")}),e.jsx("span",{className:"shortcuts-context-description",children:r("terminal:controls.enableDisableGestures")})]}),e.jsxs("div",{className:"trackpad-gestures-grid",children:[e.jsxs("label",{className:`trackpad-gesture-item ${s.enabled?"":"disabled"}`,children:[e.jsx("input",{type:"checkbox",checked:s.pinchToZoom,onChange:c=>a("pinchToZoom",c.target.checked),disabled:!s.enabled}),e.jsxs("div",{className:"trackpad-gesture-info",children:[e.jsx("span",{className:"trackpad-gesture-name",children:r("terminal:controls.pinchToZoom")}),e.jsx("span",{className:"trackpad-gesture-desc",children:r("terminal:controls.pinchToZoomDesc")})]})]}),e.jsxs("label",{className:`trackpad-gesture-item ${s.enabled?"":"disabled"}`,children:[e.jsx("input",{type:"checkbox",checked:s.twoFingerPan,onChange:c=>a("twoFingerPan",c.target.checked),disabled:!s.enabled}),e.jsxs("div",{className:"trackpad-gesture-info",children:[e.jsx("span",{className:"trackpad-gesture-name",children:r("terminal:controls.twoFingerPan")}),e.jsx("span",{className:"trackpad-gesture-desc",children:r("terminal:controls.twoFingerPanDesc")})]})]}),e.jsxs("label",{className:`trackpad-gesture-item ${s.enabled?"":"disabled"}`,children:[e.jsx("input",{type:"checkbox",checked:s.shiftTwoFingerOrbit,onChange:c=>a("shiftTwoFingerOrbit",c.target.checked),disabled:!s.enabled}),e.jsxs("div",{className:"trackpad-gesture-info",children:[e.jsx("span",{className:"trackpad-gesture-name",children:r("terminal:controls.shiftTwoFingerOrbit")}),e.jsx("span",{className:"trackpad-gesture-desc",children:r("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:r("terminal:controls.sensitivity")}),e.jsx("span",{className:"shortcuts-context-description",children:r("terminal:controls.adjustGestureSensitivity")})]}),e.jsxs("div",{className:"trackpad-sensitivity-sliders",children:[e.jsxs("div",{className:`trackpad-slider-row ${!s.enabled||!s.pinchToZoom?"disabled":""}`,children:[e.jsx("label",{children:r("terminal:controls.zoom")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.sensitivity.zoom,onChange:c=>l("zoom",parseFloat(c.target.value)),disabled:!s.enabled||!s.pinchToZoom}),e.jsxs("span",{className:"trackpad-slider-value",children:[s.sensitivity.zoom.toFixed(1),"x"]})]}),e.jsxs("div",{className:`trackpad-slider-row ${!s.enabled||!s.twoFingerPan?"disabled":""}`,children:[e.jsx("label",{children:r("terminal:controls.pan")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.sensitivity.pan,onChange:c=>l("pan",parseFloat(c.target.value)),disabled:!s.enabled||!s.twoFingerPan}),e.jsxs("span",{className:"trackpad-slider-value",children:[s.sensitivity.pan.toFixed(1),"x"]})]}),e.jsxs("div",{className:`trackpad-slider-row ${!s.enabled||!s.shiftTwoFingerOrbit?"disabled":""}`,children:[e.jsx("label",{children:r("terminal:controls.orbit")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.sensitivity.orbit,onChange:c=>l("orbit",parseFloat(c.target.value)),disabled:!s.enabled||!s.shiftTwoFingerOrbit}),e.jsxs("span",{className:"trackpad-slider-value",children:[s.sensitivity.orbit.toFixed(1),"x"]})]})]})]})]})}export{pe as ControlsModal};
@@ -1,2 +1,2 @@
1
- import{u as p,f as u,h as S,r as n,s as o,j as x}from"./main-DDwa0x9e.js";import{L as k}from"./LogViewerModal-BtcUe5i2.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function h({building:e,isOpen:t,onClose:i,onMinimize:m}){var a;const{t:c}=p(["terminal"]),g=u(),d=S(),r=g.get(e.id)||"",l=d.has(e.id);n.useEffect(()=>{var s;return t&&((s=e.docker)!=null&&s.enabled)&&o.startLogStreaming(e.id,200),()=>{e.id&&o.stopLogStreaming(e.id)}},[t,e.id,(a=e.docker)==null?void 0:a.enabled]);const L=n.useMemo(()=>r.split(`
1
+ import{u as p,f as u,h as S,r as n,s as o,j as x}from"./main-D8A4ans-.js";import{L as k}from"./LogViewerModal-CRyAs-oh.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function h({building:e,isOpen:t,onClose:i,onMinimize:m}){var a;const{t:c}=p(["terminal"]),g=u(),d=S(),r=g.get(e.id)||"",l=d.has(e.id);n.useEffect(()=>{var s;return t&&((s=e.docker)!=null&&s.enabled)&&o.startLogStreaming(e.id,200),()=>{e.id&&o.stopLogStreaming(e.id)}},[t,e.id,(a=e.docker)==null?void 0:a.enabled]);const L=n.useMemo(()=>r.split(`
2
2
  `).map((s,f)=>({text:s,lineNumber:f+1})),[r]);return x.jsx(k,{isOpen:t,onClose:i,onMinimize:m,title:`${e.name} - ${c("terminal:logs.dockerLogs")}`,icon:"🐳",lines:L,isStreaming:l,onClear:()=>o.clearStreamingLogs(e.id)})}export{h as DockerLogsModal};
@@ -1,4 +1,4 @@
1
- import{r as ot,j as Tt}from"./main-DDwa0x9e.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";let Hs=[],PQ=[];(()=>{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?PQ:Hs).push(O=O+t[e])})();function wX(t){if(t<768)return!1;for(let e=0,O=Hs.length;;){let i=e+O>>1;if(t<Hs[i])O=i;else if(t>=PQ[i])e=i+1;else return!0;if(e==O)return!1}}function ef(t){return t>=127462&&t<=127487}const tf=8205;function TX(t,e,O=!0,i=!0){return(O?SQ:xX)(t,e,i)}function SQ(t,e,O){if(e==t.length)return e;e&&XQ(t.charCodeAt(e))&&bQ(t.charCodeAt(e-1))&&e--;let i=zo(t,e);for(e+=Of(i);e<t.length;){let n=zo(t,e);if(i==tf||n==tf||O&&wX(n))e+=Of(n),i=n;else if(ef(n)){let r=0,a=e-2;for(;a>=0&&ef(zo(t,a));)r++,a-=2;if(r%2==0)break;e+=2}else break}return e}function xX(t,e,O){for(;e>0;){let i=SQ(t,e-2,O);if(i<e)return i;e--}return 0}function zo(t,e){let O=t.charCodeAt(e);if(!bQ(O)||e+1==t.length)return O;let i=t.charCodeAt(e+1);return XQ(i)?(O-55296<<10)+(i-56320)+65536:O}function XQ(t){return t>=56320&&t<57344}function bQ(t){return t>=55296&&t<56320}function Of(t){return t<65536?1:2}class Oe{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]=zi(this,e,O);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(O,this.length,n,1),qt.from(n,this.length-(O-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,O=this.length){[e,O]=zi(this,e,O);let i=[];return this.decompose(e,O,i,0),qt.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),n=new mn(this),r=new mn(e);for(let a=O,o=O;;){if(n.next(a),r.next(a),a=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(o+=n.value.length,n.done||o>=i)return!0}}iter(e=1){return new mn(this,e)}iterRange(e,O=this.length){return new yQ(this,e,O)}iterLines(e,O){let i;if(e==null)i=this.iter();else{O==null&&(O=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,O==this.lines+1?this.length:O<=1?0:this.line(O-1).to))}return new kQ(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]?Oe.empty:e.length<=32?new ge(e):qt.from(ge.split(e,[]))}}class ge extends Oe{constructor(e,O=vX(e)){super(),this.text=e,this.length=O}get lines(){return this.text.length}get children(){return null}lineInner(e,O,i,n){for(let r=0;;r++){let a=this.text[r],o=n+a.length;if((O?i:o)>=e)return new _X(n,o,i,a);n=o+1,i++}}decompose(e,O,i,n){let r=e<=0&&O>=this.length?this:new ge(nf(this.text,e,O),Math.min(O,this.length)-Math.max(0,e));if(n&1){let a=i.pop(),o=Nr(r.text,a.text.slice(),0,r.length);if(o.length<=32)i.push(new ge(o,a.length+r.length));else{let s=o.length>>1;i.push(new ge(o.slice(0,s)),new ge(o.slice(s)))}}else i.push(r)}replace(e,O,i){if(!(i instanceof ge))return super.replace(e,O,i);[e,O]=zi(this,e,O);let n=Nr(this.text,Nr(i.text,nf(this.text,0,e)),O),r=this.length+i.length-(O-e);return n.length<=32?new ge(n,r):qt.from(ge.split(n,[]),r)}sliceString(e,O=this.length,i=`
1
+ import{r as ot,j as Tt}from"./main-D8A4ans-.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";let Hs=[],PQ=[];(()=>{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?PQ:Hs).push(O=O+t[e])})();function wX(t){if(t<768)return!1;for(let e=0,O=Hs.length;;){let i=e+O>>1;if(t<Hs[i])O=i;else if(t>=PQ[i])e=i+1;else return!0;if(e==O)return!1}}function ef(t){return t>=127462&&t<=127487}const tf=8205;function TX(t,e,O=!0,i=!0){return(O?SQ:xX)(t,e,i)}function SQ(t,e,O){if(e==t.length)return e;e&&XQ(t.charCodeAt(e))&&bQ(t.charCodeAt(e-1))&&e--;let i=zo(t,e);for(e+=Of(i);e<t.length;){let n=zo(t,e);if(i==tf||n==tf||O&&wX(n))e+=Of(n),i=n;else if(ef(n)){let r=0,a=e-2;for(;a>=0&&ef(zo(t,a));)r++,a-=2;if(r%2==0)break;e+=2}else break}return e}function xX(t,e,O){for(;e>0;){let i=SQ(t,e-2,O);if(i<e)return i;e--}return 0}function zo(t,e){let O=t.charCodeAt(e);if(!bQ(O)||e+1==t.length)return O;let i=t.charCodeAt(e+1);return XQ(i)?(O-55296<<10)+(i-56320)+65536:O}function XQ(t){return t>=56320&&t<57344}function bQ(t){return t>=55296&&t<56320}function Of(t){return t<65536?1:2}class Oe{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]=zi(this,e,O);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(O,this.length,n,1),qt.from(n,this.length-(O-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,O=this.length){[e,O]=zi(this,e,O);let i=[];return this.decompose(e,O,i,0),qt.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),n=new mn(this),r=new mn(e);for(let a=O,o=O;;){if(n.next(a),r.next(a),a=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(o+=n.value.length,n.done||o>=i)return!0}}iter(e=1){return new mn(this,e)}iterRange(e,O=this.length){return new yQ(this,e,O)}iterLines(e,O){let i;if(e==null)i=this.iter();else{O==null&&(O=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,O==this.lines+1?this.length:O<=1?0:this.line(O-1).to))}return new kQ(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]?Oe.empty:e.length<=32?new ge(e):qt.from(ge.split(e,[]))}}class ge extends Oe{constructor(e,O=vX(e)){super(),this.text=e,this.length=O}get lines(){return this.text.length}get children(){return null}lineInner(e,O,i,n){for(let r=0;;r++){let a=this.text[r],o=n+a.length;if((O?i:o)>=e)return new _X(n,o,i,a);n=o+1,i++}}decompose(e,O,i,n){let r=e<=0&&O>=this.length?this:new ge(nf(this.text,e,O),Math.min(O,this.length)-Math.max(0,e));if(n&1){let a=i.pop(),o=Nr(r.text,a.text.slice(),0,r.length);if(o.length<=32)i.push(new ge(o,a.length+r.length));else{let s=o.length>>1;i.push(new ge(o.slice(0,s)),new ge(o.slice(s)))}}else i.push(r)}replace(e,O,i){if(!(i instanceof ge))return super.replace(e,O,i);[e,O]=zi(this,e,O);let n=Nr(this.text,Nr(i.text,nf(this.text,0,e)),O),r=this.length+i.length-(O-e);return n.length<=32?new ge(n,r):qt.from(ge.split(n,[]),r)}sliceString(e,O=this.length,i=`
2
2
  `){[e,O]=zi(this,e,O);let n="";for(let r=0,a=0;r<=O&&a<this.text.length;a++){let o=this.text[a],s=r+o.length;r>e&&a&&(n+=i),e<s&&O>r&&(n+=o.slice(Math.max(0,e-r),O-r)),r=s+1}return n}flatten(e){for(let O of this.text)e.push(O)}scanIdentical(){return 0}static split(e,O){let i=[],n=-1;for(let r of e)i.push(r),n+=r.length+1,i.length==32&&(O.push(new ge(i,n)),i=[],n=-1);return n>-1&&O.push(new ge(i,n)),O}}class qt extends Oe{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,n){for(let r=0;;r++){let a=this.children[r],o=n+a.length,s=i+a.lines-1;if((O?s:o)>=e)return a.lineInner(e,O,i,n);n=o+1,i=s+1}}decompose(e,O,i,n){for(let r=0,a=0;a<=O&&r<this.children.length;r++){let o=this.children[r],s=a+o.length;if(e<=s&&O>=a){let l=n&((a<=e?1:0)|(s>=O?2:0));a>=e&&s<=O&&!l?i.push(o):o.decompose(e-a,O-a,i,l)}a=s+1}}replace(e,O,i){if([e,O]=zi(this,e,O),i.lines<this.lines)for(let n=0,r=0;n<this.children.length;n++){let a=this.children[n],o=r+a.length;if(e>=r&&O<=o){let s=a.replace(e-r,O-r,i),l=this.lines-a.lines+s.lines;if(s.lines<l>>4&&s.lines>l>>6){let c=this.children.slice();return c[n]=s,new qt(c,this.length-(O-e)+i.length)}return super.replace(r,o,s)}r=o+1}return super.replace(e,O,i)}sliceString(e,O=this.length,i=`
3
3
  `){[e,O]=zi(this,e,O);let n="";for(let r=0,a=0;r<this.children.length&&a<=O;r++){let o=this.children[r],s=a+o.length;a>e&&r&&(n+=i),e<s&&O>a&&(n+=o.sliceString(e-a,O-a,i)),a=s+1}return n}flatten(e){for(let O of this.children)O.flatten(e)}scanIdentical(e,O){if(!(e instanceof qt))return 0;let i=0,[n,r,a,o]=O>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=O,r+=O){if(n==a||r==o)return i;let s=this.children[n],l=e.children[r];if(s!=l)return i+s.scanIdentical(l,O);i+=s.length+1}}static from(e,O=e.reduce((i,n)=>i+n.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let $ of e)$.flatten(d);return new ge(d,O)}let n=Math.max(32,i>>5),r=n<<1,a=n>>1,o=[],s=0,l=-1,c=[];function u(d){let $;if(d.lines>r&&d instanceof qt)for(let Q of d.children)u(Q);else d.lines>a&&(s>a||!s)?(f(),o.push(d)):d instanceof ge&&s&&($=c[c.length-1])instanceof ge&&d.lines+$.lines<=32?(s+=d.lines,l+=d.length+1,c[c.length-1]=new ge($.text.concat(d.text),$.length+1+d.length)):(s+d.lines>n&&f(),s+=d.lines,l+=d.length+1,c.push(d))}function f(){s!=0&&(o.push(c.length==1?c[0]:qt.from(c,l)),l=-1,s=c.length=0)}for(let d of e)u(d);return f(),o.length==1?o[0]:new qt(o,O)}}Oe.empty=new ge([""],0);function vX(t){let e=-1;for(let O of t)e+=O.length+1;return e}function Nr(t,e,O=0,i=1e9){for(let n=0,r=0,a=!0;r<t.length&&n<=i;r++){let o=t[r],s=n+o.length;s>=O&&(s>i&&(o=o.slice(0,i-n)),n<O&&(o=o.slice(O-n)),a?(e[e.length-1]+=o,a=!1):e.push(o)),n=s+1}return e}function nf(t,e,O){return Nr(t,[""],e,O)}class mn{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 ge?e.text.length:e.children.length)<<1]}nextInner(e,O){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],a=r>>1,o=n instanceof ge?n.text.length:n.children.length;if(a==(O>0?o: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((r&1)==(O>0?0:1)){if(this.offsets[i]+=O,e==0)return this.lineBreak=!0,this.value=`
4
4
  `,this;e--}else if(n instanceof ge){let s=n.text[a+(O<0?-1:0)];if(this.offsets[i]+=O,s.length>Math.max(0,e))return this.value=e==0?s:O>0?s.slice(e):s.slice(0,s.length-e),this;e-=s.length}else{let s=n.children[a+(O<0?-1:0)];e>s.length?(e-=s.length,this.offsets[i]+=O):(O<0&&this.offsets[i]--,this.nodes.push(s),this.offsets.push(O>0?1:(s instanceof ge?s.text.length:s.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class yQ{constructor(e,O,i){this.value="",this.done=!1,this.cursor=new mn(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:n}=this.cursor.next(e);return this.pos+=(n.length+e)*O,this.value=n.length<=i?n:O<0?n.slice(n.length-i):n.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 kQ{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:O,lineBreak:i,value:n}=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=n,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Oe.prototype[Symbol.iterator]=function(){return this.iter()},mn.prototype[Symbol.iterator]=yQ.prototype[Symbol.iterator]=kQ.prototype[Symbol.iterator]=function(){return this});let _X=class{constructor(e,O,i,n){this.from=e,this.to=O,this.number=i,this.text=n}get length(){return this.to-this.from}};function zi(t,e,O){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,O))]}function we(t,e,O=!0,i=!0){return TX(t,e,O,i)}function YX(t){return t>=56320&&t<57344}function RX(t){return t>=55296&&t<56320}function ci(t,e){let O=t.charCodeAt(e);if(!RX(O)||e+1==t.length)return O;let i=t.charCodeAt(e+1);return YX(i)?(O-55296<<10)+(i-56320)+65536:O}function wQ(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function er(t){return t<65536?1:2}const Ks=/\r\n?|\n/;var ze=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(ze||(ze={}));class Gt{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,n=0;O<this.sections.length;){let r=this.sections[O++],a=this.sections[O++];a<0?(e(i,n,r),n+=r):n+=a,i+=r}}iterChangedRanges(e,O=!1){Js(this,e,O)}get invertedDesc(){let e=[];for(let O=0;O<this.sections.length;){let i=this.sections[O++],n=this.sections[O++];n<0?e.push(i,n):e.push(n,i)}return new Gt(e)}composeDesc(e){return this.empty?e:e.empty?this:TQ(this,e)}mapDesc(e,O=!1){return e.empty?this:el(this,e,O)}mapPos(e,O=-1,i=ze.Simple){let n=0,r=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],l=n+o;if(s<0){if(l>e)return r+(e-n);r+=o}else{if(i!=ze.Simple&&l>=e&&(i==ze.TrackDel&&n<e&&l>e||i==ze.TrackBefore&&n<e||i==ze.TrackAfter&&l>e))return null;if(l>e||l==e&&O<0&&!o)return e==n||O<0?r:r+s;r+=s}n=l}if(e>n)throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);return r}touchesRange(e,O=e){for(let i=0,n=0;i<this.sections.length&&n<=O;){let r=this.sections[i++],a=this.sections[i++],o=n+r;if(a>=0&&n<=O&&o>=e)return n<e&&o>O?"cover":!0;n=o}return!1}toString(){let e="";for(let O=0;O<this.sections.length;){let i=this.sections[O++],n=this.sections[O++];e+=(e?" ":"")+i+(n>=0?":"+n:"")}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 Gt(e)}static create(e){return new Gt(e)}}class Xe extends Gt{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 Js(this,(O,i,n,r,a)=>e=e.replace(n,n+(i-O),a),!1),e}mapDesc(e,O=!1){return el(this,e,O,!0)}invert(e){let O=this.sections.slice(),i=[];for(let n=0,r=0;n<O.length;n+=2){let a=O[n],o=O[n+1];if(o>=0){O[n]=o,O[n+1]=a;let s=n>>1;for(;i.length<s;)i.push(Oe.empty);i.push(a?e.slice(r,r+a):Oe.empty)}r+=a}return new Xe(O,i)}compose(e){return this.empty?e:e.empty?this:TQ(this,e,!0)}map(e,O=!1){return e.empty?this:el(this,e,O,!0)}iterChanges(e,O=!1){Js(this,e,O)}get desc(){return Gt.create(this.sections)}filter(e){let O=[],i=[],n=[],r=new Yn(this);e:for(let a=0,o=0;;){let s=a==e.length?1e9:e[a++];for(;o<s||o==s&&r.len==0;){if(r.done)break e;let c=Math.min(r.len,s-o);Re(n,c,-1);let u=r.ins==-1?-1:r.off==0?r.ins:0;Re(O,c,u),u>0&&PO(i,O,r.text),r.forward(c),o+=c}let l=e[a++];for(;o<l;){if(r.done)break e;let c=Math.min(r.len,l-o);Re(O,c,-1),Re(n,c,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(c),o+=c}}return{changes:new Xe(O,i),filtered:Gt.create(n)}}toJSON(){let e=[];for(let O=0;O<this.sections.length;O+=2){let i=this.sections[O],n=this.sections[O+1];n<0?e.push(i):n==0?e.push([i]):e.push([i].concat(this.inserted[O>>1].toJSON()))}return e}static of(e,O,i){let n=[],r=[],a=0,o=null;function s(c=!1){if(!c&&!n.length)return;a<O&&Re(n,O-a,-1);let u=new Xe(n,r);o=o?o.compose(u.map(o)):u,n=[],r=[],a=0}function l(c){if(Array.isArray(c))for(let u of c)l(u);else if(c instanceof Xe){if(c.length!=O)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${O})`);s(),o=o?o.compose(c.map(o)):c}else{let{from:u,to:f=u,insert:d}=c;if(u>f||u<0||f>O)throw new RangeError(`Invalid change range ${u} to ${f} (in doc of length ${O})`);let $=d?typeof d=="string"?Oe.of(d.split(i||Ks)):d:Oe.empty,Q=$.length;if(u==f&&Q==0)return;u<a&&s(),u>a&&Re(n,u-a,-1),Re(n,f-u,Q),PO(r,n,$),a=f}}return l(e),s(!o),o}static empty(e){return new Xe(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let O=[],i=[];for(let n=0;n<e.length;n++){let r=e[n];if(typeof r=="number")O.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((a,o)=>o&&typeof a!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)O.push(r[0],0);else{for(;i.length<n;)i.push(Oe.empty);i[n]=Oe.of(r.slice(1)),O.push(r[0],i[n].length)}}}return new Xe(O,i)}static createSet(e,O){return new Xe(e,O)}}function Re(t,e,O,i=!1){if(e==0&&O<=0)return;let n=t.length-2;n>=0&&O<=0&&O==t[n+1]?t[n]+=e:n>=0&&e==0&&t[n]==0?t[n+1]+=O:i?(t[n]+=e,t[n+1]+=O):t.push(e,O)}function PO(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(Oe.empty);t.push(O)}}function Js(t,e,O){let i=t.inserted;for(let n=0,r=0,a=0;a<t.sections.length;){let o=t.sections[a++],s=t.sections[a++];if(s<0)n+=o,r+=o;else{let l=n,c=r,u=Oe.empty;for(;l+=o,c+=s,s&&i&&(u=u.append(i[a-2>>1])),!(O||a==t.sections.length||t.sections[a+1]<0);)o=t.sections[a++],s=t.sections[a++];e(n,l,r,c,u),n=l,r=c}}}function el(t,e,O,i=!1){let n=[],r=i?[]:null,a=new Yn(t),o=new Yn(e);for(let s=-1;;){if(a.done&&o.len||o.done&&a.len)throw new Error("Mismatched change set lengths");if(a.ins==-1&&o.ins==-1){let l=Math.min(a.len,o.len);Re(n,l,-1),a.forward(l),o.forward(l)}else if(o.ins>=0&&(a.ins<0||s==a.i||a.off==0&&(o.len<a.len||o.len==a.len&&!O))){let l=o.len;for(Re(n,o.ins,-1);l;){let c=Math.min(a.len,l);a.ins>=0&&s<a.i&&a.len<=c&&(Re(n,0,a.ins),r&&PO(r,n,a.text),s=a.i),a.forward(c),l-=c}o.next()}else if(a.ins>=0){let l=0,c=a.len;for(;c;)if(o.ins==-1){let u=Math.min(c,o.len);l+=u,c-=u,o.forward(u)}else if(o.ins==0&&o.len<c)c-=o.len,o.next();else break;Re(n,l,s<a.i?a.ins:0),r&&s<a.i&&PO(r,n,a.text),s=a.i,a.forward(a.len-c)}else{if(a.done&&o.done)return r?Xe.createSet(n,r):Gt.create(n);throw new Error("Mismatched change set lengths")}}}function TQ(t,e,O=!1){let i=[],n=O?[]:null,r=new Yn(t),a=new Yn(e);for(let o=!1;;){if(r.done&&a.done)return n?Xe.createSet(i,n):Gt.create(i);if(r.ins==0)Re(i,r.len,0,o),r.next();else if(a.len==0&&!a.done)Re(i,0,a.ins,o),n&&PO(n,i,a.text),a.next();else{if(r.done||a.done)throw new Error("Mismatched change set lengths");{let s=Math.min(r.len2,a.len),l=i.length;if(r.ins==-1){let c=a.ins==-1?-1:a.off?0:a.ins;Re(i,s,c,o),n&&c&&PO(n,i,a.text)}else a.ins==-1?(Re(i,r.off?0:r.len,s,o),n&&PO(n,i,r.textBit(s))):(Re(i,r.off?0:r.len,a.off?0:a.ins,o),n&&!a.off&&PO(n,i,a.text));o=(r.ins>s||a.ins>=0&&a.len>s)&&(o||i.length>l),r.forward2(s),a.forward(s)}}}}class Yn{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?Oe.empty:e[O]}textBit(e){let{inserted:O}=this.set,i=this.i-2>>1;return i>=O.length&&!e?Oe.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 DO{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,n;return this.empty?i=n=e.mapPos(this.from,O):(i=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new DO(i,n,this.flags)}extend(e,O=e,i=0){if(e<=this.anchor&&O>=this.anchor)return y.range(e,O,void 0,void 0,i);let n=Math.abs(e-this.anchor)>Math.abs(O-this.anchor)?e:O;return y.range(this.anchor,n,void 0,void 0,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 y.range(e.anchor,e.head)}static create(e,O,i){return new DO(e,O,i)}}class y{constructor(e,O){this.ranges=e,this.mainIndex=O}map(e,O=-1){return e.empty?this:y.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 y([this.main],0)}addRange(e,O=!0){return y.create([e].concat(this.ranges),O?0:this.mainIndex+1)}replaceRange(e,O=this.mainIndex){let i=this.ranges.slice();return i[O]=e,y.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 y(e.ranges.map(O=>DO.fromJSON(O)),e.main)}static single(e,O=e){return new y([y.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,n=0;n<e.length;n++){let r=e[n];if(r.empty?r.from<=i:r.from<i)return y.normalized(e.slice(),O);i=r.to}return new y(e,O)}static cursor(e,O=0,i,n){return DO.create(e,e,(O==0?0:O<0?8:16)|(i==null?7:Math.min(6,i))|(n??16777215)<<6)}static range(e,O,i,n,r){let a=(i??16777215)<<6|(n==null?7:Math.min(6,n));return!r&&e!=O&&(r=O<e?1:-1),O<e?DO.create(O,e,48|a):DO.create(e,O,(r?r<0?8:16:0)|a)}static normalized(e,O=0){let i=e[O];e.sort((n,r)=>n.from-r.from),O=e.indexOf(i);for(let n=1;n<e.length;n++){let r=e[n],a=e[n-1];if(r.empty?r.from<=a.to:r.from<a.to){let o=a.from,s=Math.max(r.to,a.to);n<=O&&O--,e.splice(--n,2,r.anchor>r.head?y.range(s,o):y.range(o,s))}}return new y(e,O)}}function xQ(t,e){for(let O of t.ranges)if(O.to>e)throw new RangeError("Selection points outside of document")}let vc=0;class E{constructor(e,O,i,n,r){this.combine=e,this.compareInput=O,this.compare=i,this.isStatic=n,this.id=vc++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new E(e.combine||(O=>O),e.compareInput||((O,i)=>O===i),e.compare||(e.combine?(O,i)=>O===i:_c),!!e.static,e.enables)}of(e){return new Br([],this,0,e)}compute(e,O){if(this.isStatic)throw new Error("Can't compute a static facet");return new Br(e,this,1,O)}computeN(e,O){if(this.isStatic)throw new Error("Can't compute a static facet");return new Br(e,this,2,O)}from(e,O){return O||(O=i=>i),this.compute([e],i=>O(i.field(e)))}}function _c(t,e){return t==e||t.length==e.length&&t.every((O,i)=>O===e[i])}class Br{constructor(e,O,i,n){this.dependencies=e,this.facet=O,this.type=i,this.value=n,this.id=vc++}dynamicSlot(e){var O;let i=this.value,n=this.facet.compareInput,r=this.id,a=e[r]>>1,o=this.type==2,s=!1,l=!1,c=[];for(let u of this.dependencies)u=="doc"?s=!0:u=="selection"?l=!0:(((O=e[u.id])!==null&&O!==void 0?O:1)&1)==0&&c.push(e[u.id]);return{create(u){return u.values[a]=i(u),1},update(u,f){if(s&&f.docChanged||l&&(f.docChanged||f.selection)||tl(u,c)){let d=i(u);if(o?!rf(d,u.values[a],n):!n(d,u.values[a]))return u.values[a]=d,1}return 0},reconfigure:(u,f)=>{let d,$=f.config.address[r];if($!=null){let Q=fa(f,$);if(this.dependencies.every(p=>p instanceof E?f.facet(p)===u.facet(p):p instanceof rt?f.field(p,!1)==u.field(p,!1):!0)||(o?rf(d=i(u),Q,n):n(d=i(u),Q)))return u.values[a]=Q,0}else d=i(u);return u.values[a]=d,1}}}}function rf(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 tl(t,e){let O=!1;for(let i of e)Pn(t,i)&1&&(O=!0);return O}function ZX(t,e,O){let i=O.map(s=>t[s.id]),n=O.map(s=>s.type),r=i.filter(s=>!(s&1)),a=t[e.id]>>1;function o(s){let l=[];for(let c=0;c<i.length;c++){let u=fa(s,i[c]);if(n[c]==2)for(let f of u)l.push(f);else l.push(u)}return e.combine(l)}return{create(s){for(let l of i)Pn(s,l);return s.values[a]=o(s),1},update(s,l){if(!tl(s,r))return 0;let c=o(s);return e.compare(c,s.values[a])?0:(s.values[a]=c,1)},reconfigure(s,l){let c=tl(s,i),u=l.config.facets[e.id],f=l.facet(e);if(u&&!c&&_c(O,u))return s.values[a]=f,0;let d=o(s);return e.compare(d,f)?(s.values[a]=f,0):(s.values[a]=d,1)}}}const Qr=E.define({static:!0});class rt{constructor(e,O,i,n,r){this.id=e,this.createF=O,this.updateF=i,this.compareF=n,this.spec=r,this.provides=void 0}static define(e){let O=new rt(vc++,e.create,e.update,e.compare||((i,n)=>i===n),e);return e.provide&&(O.provides=e.provide(O)),O}create(e){let O=e.facet(Qr).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,n)=>{let r=i.values[O],a=this.updateF(r,n);return this.compareF(r,a)?0:(i.values[O]=a,1)},reconfigure:(i,n)=>{let r=i.facet(Qr),a=n.facet(Qr),o;return(o=r.find(s=>s.field==this))&&o!=a.find(s=>s.field==this)?(i.values[O]=o.create(i),1):n.config.address[this.id]!=null?(i.values[O]=n.field(this),0):(i.values[O]=this.create(i),1)}}}init(e){return[this,Qr.of({field:this,create:e})]}get extension(){return this}}const GO={lowest:4,low:3,default:2,high:1,highest:0};function Ji(t){return e=>new vQ(e,t)}const ui={highest:Ji(GO.highest),high:Ji(GO.high),default:Ji(GO.default),low:Ji(GO.low),lowest:Ji(GO.lowest)};class vQ{constructor(e,O){this.inner=e,this.prec=O}}class Fa{of(e){return new Ol(this,e)}reconfigure(e){return Fa.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Ol{constructor(e,O){this.compartment=e,this.inner=O}}class ua{constructor(e,O,i,n,r,a){for(this.base=e,this.compartments=O,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.facets=a,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 n=[],r=Object.create(null),a=new Map;for(let f of zX(e,O,a))f instanceof rt?n.push(f):(r[f.facet.id]||(r[f.facet.id]=[])).push(f);let o=Object.create(null),s=[],l=[];for(let f of n)o[f.id]=l.length<<1,l.push(d=>f.slot(d));let c=i==null?void 0:i.config.facets;for(let f in r){let d=r[f],$=d[0].facet,Q=c&&c[f]||[];if(d.every(p=>p.type==0))if(o[$.id]=s.length<<1|1,_c(Q,d))s.push(i.facet($));else{let p=$.combine(d.map(m=>m.value));s.push(i&&$.compare(p,i.facet($))?i.facet($):p)}else{for(let p of d)p.type==0?(o[p.id]=s.length<<1|1,s.push(p.value)):(o[p.id]=l.length<<1,l.push(m=>p.dynamicSlot(m)));o[$.id]=l.length<<1,l.push(p=>ZX(p,$,d))}}let u=l.map(f=>f(o));return new ua(e,a,u,o,s,r)}}function zX(t,e,O){let i=[[],[],[],[],[]],n=new Map;function r(a,o){let s=n.get(a);if(s!=null){if(s<=o)return;let l=i[s].indexOf(a);l>-1&&i[s].splice(l,1),a instanceof Ol&&O.delete(a.compartment)}if(n.set(a,o),Array.isArray(a))for(let l of a)r(l,o);else if(a instanceof Ol){if(O.has(a.compartment))throw new RangeError("Duplicate use of compartment in extensions");let l=e.get(a.compartment)||a.inner;O.set(a.compartment,l),r(l,o)}else if(a instanceof vQ)r(a.inner,a.prec);else if(a instanceof rt)i[o].push(a),a.provides&&r(a.provides,o);else if(a instanceof Br)i[o].push(a),a.facet.extensions&&r(a.facet.extensions,GO.default);else{let l=a.extension;if(!l)throw new Error(`Unrecognized extension value in extension set (${a}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(l,o)}}return r(t,GO.default),i.reduce((a,o)=>a.concat(o))}function Pn(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 n=t.computeSlot(t,t.config.dynamicSlots[O]);return t.status[O]=2|n}function fa(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const _Q=E.define(),il=E.define({combine:t=>t.some(e=>e),static:!0}),YQ=E.define({combine:t=>t.length?t[0]:void 0,static:!0}),RQ=E.define(),ZQ=E.define(),zQ=E.define(),qQ=E.define({combine:t=>t.length?t[0]:!1});class uO{constructor(e,O){this.type=e,this.value=O}static define(){return new qX}}class qX{of(e){return new uO(this,e)}}class UX{constructor(e){this.map=e}of(e){return new ie(this,e)}}class ie{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 ie(this.type,O)}is(e){return this.type==e}static define(e={}){return new UX(e.map||(O=>O))}static mapEffects(e,O){if(!e.length)return e;let i=[];for(let n of e){let r=n.map(O);r&&i.push(r)}return i}}ie.reconfigure=ie.define();ie.appendConfig=ie.define();class Pe{constructor(e,O,i,n,r,a){this.startState=e,this.changes=O,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=a,this._doc=null,this._state=null,i&&xQ(i,O.newLength),r.some(o=>o.type==Pe.time)||(this.annotations=r.concat(Pe.time.of(Date.now())))}static create(e,O,i,n,r,a){return new Pe(e,O,i,n,r,a)}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(Pe.userEvent);return!!(O&&(O==e||O.length>e.length&&O.slice(0,e.length)==e&&O[e.length]=="."))}}Pe.time=uO.define();Pe.userEvent=uO.define();Pe.addToHistory=uO.define();Pe.remote=uO.define();function VX(t,e){let O=[];for(let i=0,n=0;;){let r,a;if(i<t.length&&(n==e.length||e[n]>=t[i]))r=t[i++],a=t[i++];else if(n<e.length)r=e[n++],a=e[n++];else return O;!O.length||O[O.length-1]<r?O.push(r,a):O[O.length-1]<a&&(O[O.length-1]=a)}}function UQ(t,e,O){var i;let n,r,a;return O?(n=e.changes,r=Xe.empty(e.changes.length),a=t.changes.compose(e.changes)):(n=e.changes.map(t.changes),r=t.changes.mapDesc(e.changes,!0),a=t.changes.compose(n)),{changes:a,selection:e.selection?e.selection.map(r):(i=t.selection)===null||i===void 0?void 0:i.map(n),effects:ie.mapEffects(t.effects,n).concat(ie.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function nl(t,e,O){let i=e.selection,n=Ti(e.annotations);return e.userEvent&&(n=n.concat(Pe.userEvent.of(e.userEvent))),{changes:e.changes instanceof Xe?e.changes:Xe.of(e.changes||[],O,t.facet(YQ)),selection:i&&(i instanceof y?i:y.single(i.anchor,i.head)),effects:Ti(e.effects),annotations:n,scrollIntoView:!!e.scrollIntoView}}function VQ(t,e,O){let i=nl(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(O=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(O=!1);let a=!!e[r].sequential;i=UQ(i,nl(t,e[r],a?i.changes.newLength:t.doc.length),a)}let n=Pe.create(t,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return jX(O?WX(n):n)}function WX(t){let e=t.startState,O=!0;for(let n of e.facet(RQ)){let r=n(t);if(r===!1){O=!1;break}Array.isArray(r)&&(O=O===!0?r:VX(O,r))}if(O!==!0){let n,r;if(O===!1)r=t.changes.invertedDesc,n=Xe.empty(e.doc.length);else{let a=t.changes.filter(O);n=a.changes,r=a.filtered.mapDesc(a.changes).invertedDesc}t=Pe.create(e,n,t.selection&&t.selection.map(r),ie.mapEffects(t.effects,r),t.annotations,t.scrollIntoView)}let i=e.facet(ZQ);for(let n=i.length-1;n>=0;n--){let r=i[n](t);r instanceof Pe?t=r:Array.isArray(r)&&r.length==1&&r[0]instanceof Pe?t=r[0]:t=VQ(e,Ti(r),!1)}return t}function jX(t){let e=t.startState,O=e.facet(zQ),i=t;for(let n=O.length-1;n>=0;n--){let r=O[n](t);r&&Object.keys(r).length&&(i=UQ(i,nl(e,r,t.changes.newLength),!0))}return i==t?t:Pe.create(e,t.changes,t.selection,i.effects,i.annotations,i.scrollIntoView)}const EX=[];function Ti(t){return t==null?EX:Array.isArray(t)?t:[t]}var de=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(de||(de={}));const CX=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let rl;try{rl=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function GX(t){if(rl)return rl.test(t);for(let e=0;e<t.length;e++){let O=t[e];if(/\w/.test(O)||O>"€"&&(O.toUpperCase()!=O.toLowerCase()||CX.test(O)))return!0}return!1}function AX(t){return e=>{if(!/\S/.test(e))return de.Space;if(GX(e))return de.Word;for(let O=0;O<t.length;O++)if(e.indexOf(t[O])>-1)return de.Word;return de.Other}}class re{constructor(e,O,i,n,r,a){this.config=e,this.doc=O,this.selection=i,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=r,a&&(a._state=this);for(let o=0;o<this.config.dynamicSlots.length;o++)Pn(this,o<<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 Pn(this,i),fa(this,i)}update(...e){return VQ(this,e,!0)}applyTransaction(e){let O=this.config,{base:i,compartments:n}=O;for(let o of e.effects)o.is(Fa.reconfigure)?(O&&(n=new Map,O.compartments.forEach((s,l)=>n.set(l,s)),O=null),n.set(o.value.compartment,o.value.extension)):o.is(ie.reconfigure)?(O=null,i=o.value):o.is(ie.appendConfig)&&(O=null,i=Ti(i).concat(o.value));let r;O?r=e.startState.values.slice():(O=ua.resolve(i,n,this),r=new re(O,this.doc,this.selection,O.dynamicSlots.map(()=>null),(s,l)=>l.reconfigure(s,this),null).values);let a=e.startState.facet(il)?e.newSelection:e.newSelection.asSingle();new re(O,e.newDoc,a,r,(o,s)=>s.update(o,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:y.cursor(O.from+e.length)}))}changeByRange(e){let O=this.selection,i=e(O.ranges[0]),n=this.changes(i.changes),r=[i.range],a=Ti(i.effects);for(let o=1;o<O.ranges.length;o++){let s=e(O.ranges[o]),l=this.changes(s.changes),c=l.map(n);for(let f=0;f<o;f++)r[f]=r[f].map(c);let u=n.mapDesc(l,!0);r.push(s.range.map(u)),n=n.compose(c),a=ie.mapEffects(a,c).concat(ie.mapEffects(Ti(s.effects),u))}return{changes:n,selection:y.create(r,O.mainIndex),effects:a}}changes(e=[]){return e instanceof Xe?e:Xe.of(e,this.doc.length,this.facet(re.lineSeparator))}toText(e){return Oe.of(e.split(this.facet(re.lineSeparator)||Ks))}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:(Pn(this,O),fa(this,O))}toJSON(e){let O={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let n=e[i];n instanceof rt&&this.config.address[n.id]!=null&&(O[i]=n.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 n=[];if(i){for(let r in i)if(Object.prototype.hasOwnProperty.call(e,r)){let a=i[r],o=e[r];n.push(a.init(s=>a.spec.fromJSON(o,s)))}}return re.create({doc:e.doc,selection:y.fromJSON(e.selection),extensions:O.extensions?n.concat([O.extensions]):n})}static create(e={}){let O=ua.resolve(e.extensions||[],new Map),i=e.doc instanceof Oe?e.doc:Oe.of((e.doc||"").split(O.staticFacet(re.lineSeparator)||Ks)),n=e.selection?e.selection instanceof y?e.selection:y.single(e.selection.anchor,e.selection.head):y.single(0);return xQ(n,i.length),O.staticFacet(il)||(n=n.asSingle()),new re(O,i,n,O.dynamicSlots.map(()=>null),(r,a)=>a.create(r),null)}get tabSize(){return this.facet(re.tabSize)}get lineBreak(){return this.facet(re.lineSeparator)||`
@@ -1,4 +1,4 @@
1
- import{r as t,i as S,k as y,j as e,I as B}from"./main-DDwa0x9e.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function oe({integration:o,onSave:f,onCancel:z}){const[r,I]=t.useState(o.values.authMethod||"oauth2"),[g,L]=t.useState(o.values.clientId||""),[v,q]=t.useState(""),[w,K]=t.useState(o.values.redirectBaseUrl||""),[m,$]=t.useState(""),[j,Y]=t.useState(o.values.impersonateEmail||""),[p,E]=t.useState(String(o.values.pollingIntervalMs??3e4)),[x,O]=t.useState(o.values.defaultApprovalKeywords||"approved,aprobado,autorizado,yes,ok"),[M,G]=t.useState(null),[n,T]=t.useState(null),[c,d]=t.useState(!1),[P,i]=t.useState(null),[U,F]=t.useState(!1),[H,J]=t.useState(!1),[N,W]=t.useState(!1),[b,h]=t.useState(o.status.connected?"connected":"credentials"),k=r==="oauth2"&&o.values.clientId==="********"&&o.values.clientSecret==="********",s=t.useRef(null),_=t.useRef(o.status.connected),u=t.useCallback(async()=>{try{const a=await S(y("/api/email/status"));if(a.ok){const l=await a.json();T(l),l.authenticated&&(h("connected"),s.current&&(clearInterval(s.current),s.current=null))}}catch(a){console.error("Failed to fetch Gmail status:",a)}},[]);t.useEffect(()=>{const a=o.status.connected,l=_.current;a&&!l&&b!=="connected"?h("connected"):!a&&l&&b==="connected"&&h("credentials"),_.current=a},[o.status.connected]),t.useEffect(()=>(u(),()=>{s.current&&clearInterval(s.current)}),[u]);const R=async()=>{const a=await S(y("/api/email/auth/url"));if(!a.ok){const A=await a.json().catch(()=>({}));throw new Error(A.error||`HTTP ${a.status}`)}const l=await a.json();if(!l.url)throw new Error("OAuth URL is empty");G(l.url),i(null),h("authorize"),s.current&&clearInterval(s.current),s.current=setInterval(u,3e3)},X=async()=>{d(!0),i(null);try{await R()}catch(a){i(a instanceof Error?a.message:"Failed to get OAuth URL")}finally{d(!1)}},Q=async()=>{if(!g.trim()){i("Client ID is required");return}d(!0),i(null);try{const a={authMethod:"oauth2",redirectBaseUrl:w.trim(),pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:x};g.trim()&&g.trim()!=="********"&&(a.clientId=g.trim()),v.trim()&&v.trim()!=="********"&&(a.clientSecret=v.trim()),await f(a),await R()}catch(a){const l=a instanceof Error?a.message:"Failed to get OAuth URL";i(l)}finally{d(!1)}},V=async()=>{if(!m.trim()){i("Service Account JSON is required");return}if(!j.trim()){i("Impersonate Email is required");return}try{const a=JSON.parse(m.trim());if(!a.client_email||!a.private_key){i("Service Account JSON must contain client_email and private_key");return}}catch{i("Invalid JSON in Service Account field");return}d(!0),i(null);try{await f({authMethod:"service_account",serviceAccountJson:m.trim(),impersonateEmail:j.trim(),pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:x}),await new Promise(a=>setTimeout(a,1e3)),await u()}catch(a){const l=a instanceof Error?a.message:"Failed to save service account";i(l)}finally{d(!1)}},Z=async()=>{F(!0),i(null);try{await f({pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:x})}catch(a){i(a instanceof Error?a.message:"Failed to save settings")}finally{F(!1)}},ee=async()=>{const a=!(n!=null&&n.pollingActive);J(!0),i(null);try{const l=a?"/api/email/polling/start":"/api/email/polling/stop",A=a?{intervalMs:parseInt(p)||3e4}:{},C=await S(y(l),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)});if(!C.ok){const te=await C.json().catch(()=>({}));throw new Error(te.error||`HTTP ${C.status}`)}await u()}catch(l){i(l instanceof Error?l.message:"Failed to toggle polling")}finally{J(!1)}},ae=async()=>{d(!0),i(null);try{await f({refreshToken:"",serviceAccountJson:"",impersonateEmail:""}),T(null),G(null),h("credentials"),await u()}catch(a){i(a instanceof Error?a.message:"Failed to disconnect")}finally{d(!1)}},D=!!o.values.serviceAccountJson;return e.jsxs("div",{className:"gmail-oauth-setup",children:[P&&e.jsx("div",{className:"gmail-oauth-error",children:P}),b==="credentials"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsxs("div",{className:"gmail-oauth-field",style:{marginBottom:24},children:[e.jsx("label",{className:"integration-field-label",children:"Authentication Method"}),e.jsxs("div",{className:"gmail-auth-method-selector",children:[e.jsxs("button",{type:"button",className:`gmail-auth-method-btn ${r==="oauth2"?"active":""}`,onClick:()=>{I("oauth2"),i(null)},children:[e.jsx("span",{className:"gmail-auth-method-icon",children:e.jsx(B,{name:"key",size:14})}),e.jsx("span",{className:"gmail-auth-method-label",children:"OAuth 2.0"}),e.jsx("span",{className:"gmail-auth-method-desc",children:"Browser login flow"})]}),e.jsxs("button",{type:"button",className:`gmail-auth-method-btn ${r==="service_account"?"active":""}`,onClick:()=>{I("service_account"),i(null)},children:[e.jsx("span",{className:"gmail-auth-method-icon",children:e.jsx(B,{name:"robot",size:14})}),e.jsx("span",{className:"gmail-auth-method-label",children:"Service Account"}),e.jsx("span",{className:"gmail-auth-method-desc",children:"Domain-wide delegation"})]})]})]}),r==="oauth2"&&k&&!N&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Google OAuth Credentials"}),e.jsxs("div",{className:"gmail-oauth-shared-banner",children:[e.jsxs("div",{className:"gmail-oauth-shared-title",children:[e.jsx("span",{children:"✓"}),e.jsx("span",{children:"Credentials already configured"})]}),e.jsx("div",{className:"gmail-oauth-shared-body",children:"Existing Google OAuth credentials (Client ID and Secret) are saved in your secrets store — they're shared between Gmail, Calendar, and Drive. You may still need to re-authorize once so the refresh token grants Gmail access."})]})]}),r==="oauth2"&&(!k||N)&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Google OAuth Credentials"}),e.jsxs("p",{className:"gmail-oauth-help",children:["Create OAuth2 credentials in the"," ",e.jsx("a",{href:"https://console.cloud.google.com/apis/credentials",target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-link",children:"Google Cloud Console"}),". Enable the Gmail API and (optionally) the Calendar API. Set the redirect URI to:"," ",e.jsx("code",{className:"gmail-oauth-code",children:w.trim()?`${w.trim().replace(/\/$/,"")}/api/email/auth/callback`:y("/api/email/auth/callback")})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client ID ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"text",className:"integration-field-input",value:g,placeholder:"xxxx.apps.googleusercontent.com",onChange:a=>L(a.target.value)})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client Secret ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"password",className:"integration-field-input",value:v,placeholder:o.values.clientSecret?"(saved)":"Enter client secret",onChange:a=>q(a.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"OAuth Redirect Base URL"}),e.jsx("input",{type:"text",className:"integration-field-input",value:w,placeholder:"http://localhost:6200",onChange:a=>K(a.target.value),autoComplete:"off"}),e.jsxs("span",{className:"integration-field-description",children:["Override the base URL used to build the OAuth redirect (e.g. ",e.jsx("code",{children:"http://commander.local:10003"}),"). Leave empty to use the server's local address. Google does not accept raw IPs — use a domain (you can map one in ",e.jsx("code",{children:"/etc/hosts"}),")."]})]})]}),r==="service_account"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Service Account Credentials"}),e.jsxs("p",{className:"gmail-oauth-help",children:["Use a Google service account with"," ",e.jsx("a",{href:"https://admin.google.com/ac/owl/domainwidedelegation",target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-link",children:"domain-wide delegation"})," ","enabled. The service account must be authorized for Gmail scopes in Google Workspace Admin."]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["Service Account JSON ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:m,placeholder:D?"(saved — paste new JSON to replace)":"Paste the full service account JSON key file contents",onChange:a=>$(a.target.value),rows:6,spellCheck:!1}),e.jsx("span",{className:"integration-field-description",children:"The JSON key file downloaded from Google Cloud Console containing client_email and private_key."})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["Impersonate Email ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"email",className:"integration-field-input",value:j,placeholder:"user@yourdomain.com",onChange:a=>Y(a.target.value)}),e.jsx("span",{className:"integration-field-description",children:"The email address to impersonate via domain-wide delegation. Must be a user in your Google Workspace domain."})]})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Polling Interval (ms)"}),e.jsx("input",{type:"number",className:"integration-field-input",value:p,onChange:a=>E(a.target.value)}),e.jsx("span",{className:"integration-field-description",children:"How often to check for new emails. Default: 30000 (30s)."})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Approval Keywords"}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:x,onChange:a=>O(a.target.value),rows:2}),e.jsx("span",{className:"integration-field-description",children:"Comma-separated keywords that indicate email approval."})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:z,children:"Cancel"}),r==="oauth2"&&k&&!N?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"integration-btn secondary",onClick:()=>W(!0),disabled:c,children:"Edit credentials"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:X,disabled:c,children:c?"Loading...":"Authorize with existing credentials"})]}):r==="oauth2"?e.jsx("button",{type:"button",className:"integration-btn save",onClick:Q,disabled:c||!g.trim(),children:c?"Saving...":"Save & Authorize"}):e.jsx("button",{type:"button",className:"integration-btn save",onClick:V,disabled:c||!j.trim()||!m.trim()&&!D,children:c?"Connecting...":"Save & Connect"})]})]}),b==="authorize"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Authorize Gmail Access"}),e.jsx("p",{className:"gmail-oauth-help",children:"Click the link below to authorize Tide Commander to access your Gmail account. After granting access, you will be redirected back and the connection will be established automatically."}),M&&e.jsx("a",{href:M,target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-authorize-btn",children:"Authorize with Google"}),e.jsxs("div",{className:"gmail-oauth-waiting",children:[e.jsx("span",{className:"gmail-oauth-spinner"}),e.jsx("span",{children:"Waiting for authorization to complete..."})]}),e.jsx("div",{className:"integration-form-actions",children:e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:()=>{s.current&&(clearInterval(s.current),s.current=null),h("credentials")},children:"Back"})})]}),b==="connected"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Gmail Connected"}),e.jsxs("div",{className:"gmail-oauth-connected-info",children:[e.jsx("span",{className:"gmail-oauth-connected-badge",children:"Connected"}),(n==null?void 0:n.emailAddress)&&e.jsx("span",{className:"gmail-oauth-email",children:n.emailAddress}),e.jsx("span",{className:"gmail-oauth-auth-type",children:r==="service_account"?"Service Account":"OAuth 2.0"})]}),e.jsxs("div",{className:"gmail-polling-toggle-row",children:[e.jsxs("div",{className:"gmail-polling-toggle-info",children:[e.jsx("div",{className:"gmail-polling-toggle-label",children:"Automatic Polling"}),e.jsx("div",{className:"gmail-polling-toggle-status",children:n!=null&&n.pollingActive?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"gmail-polling-dot active"}),"Active",n.lastChecked&&e.jsxs("span",{className:"gmail-polling-last",children:["— last checked ",new Date(n.lastChecked).toLocaleTimeString()]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"gmail-polling-dot paused"}),"Paused — new emails will not be ingested"]})})]}),e.jsx("button",{type:"button",role:"switch","aria-checked":!!(n!=null&&n.pollingActive),"aria-label":"Toggle automatic polling",className:`gmail-polling-switch ${n!=null&&n.pollingActive?"on":"off"}`,onClick:ee,disabled:H,children:e.jsx("span",{className:"gmail-polling-switch-thumb"})})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Polling Interval (ms)"}),e.jsx("input",{type:"number",className:"integration-field-input",value:p,onChange:a=>E(a.target.value)})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Approval Keywords"}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:x,onChange:a=>O(a.target.value),rows:2})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:z,children:"Close"}),e.jsx("button",{type:"button",className:"integration-btn",style:{backgroundColor:"#f38ba8",color:"#1e1e2e"},onClick:ae,disabled:c,children:c?"Disconnecting...":"Disconnect"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:Z,disabled:U,children:U?"Saving...":"Save Settings"})]})]}),e.jsx("style",{children:`
1
+ import{r as t,i as S,k as y,j as e,I as B}from"./main-D8A4ans-.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function oe({integration:o,onSave:f,onCancel:z}){const[r,I]=t.useState(o.values.authMethod||"oauth2"),[g,L]=t.useState(o.values.clientId||""),[v,q]=t.useState(""),[w,K]=t.useState(o.values.redirectBaseUrl||""),[m,$]=t.useState(""),[j,Y]=t.useState(o.values.impersonateEmail||""),[p,E]=t.useState(String(o.values.pollingIntervalMs??3e4)),[x,O]=t.useState(o.values.defaultApprovalKeywords||"approved,aprobado,autorizado,yes,ok"),[M,G]=t.useState(null),[n,T]=t.useState(null),[c,d]=t.useState(!1),[P,i]=t.useState(null),[U,F]=t.useState(!1),[H,J]=t.useState(!1),[N,W]=t.useState(!1),[b,h]=t.useState(o.status.connected?"connected":"credentials"),k=r==="oauth2"&&o.values.clientId==="********"&&o.values.clientSecret==="********",s=t.useRef(null),_=t.useRef(o.status.connected),u=t.useCallback(async()=>{try{const a=await S(y("/api/email/status"));if(a.ok){const l=await a.json();T(l),l.authenticated&&(h("connected"),s.current&&(clearInterval(s.current),s.current=null))}}catch(a){console.error("Failed to fetch Gmail status:",a)}},[]);t.useEffect(()=>{const a=o.status.connected,l=_.current;a&&!l&&b!=="connected"?h("connected"):!a&&l&&b==="connected"&&h("credentials"),_.current=a},[o.status.connected]),t.useEffect(()=>(u(),()=>{s.current&&clearInterval(s.current)}),[u]);const R=async()=>{const a=await S(y("/api/email/auth/url"));if(!a.ok){const A=await a.json().catch(()=>({}));throw new Error(A.error||`HTTP ${a.status}`)}const l=await a.json();if(!l.url)throw new Error("OAuth URL is empty");G(l.url),i(null),h("authorize"),s.current&&clearInterval(s.current),s.current=setInterval(u,3e3)},X=async()=>{d(!0),i(null);try{await R()}catch(a){i(a instanceof Error?a.message:"Failed to get OAuth URL")}finally{d(!1)}},Q=async()=>{if(!g.trim()){i("Client ID is required");return}d(!0),i(null);try{const a={authMethod:"oauth2",redirectBaseUrl:w.trim(),pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:x};g.trim()&&g.trim()!=="********"&&(a.clientId=g.trim()),v.trim()&&v.trim()!=="********"&&(a.clientSecret=v.trim()),await f(a),await R()}catch(a){const l=a instanceof Error?a.message:"Failed to get OAuth URL";i(l)}finally{d(!1)}},V=async()=>{if(!m.trim()){i("Service Account JSON is required");return}if(!j.trim()){i("Impersonate Email is required");return}try{const a=JSON.parse(m.trim());if(!a.client_email||!a.private_key){i("Service Account JSON must contain client_email and private_key");return}}catch{i("Invalid JSON in Service Account field");return}d(!0),i(null);try{await f({authMethod:"service_account",serviceAccountJson:m.trim(),impersonateEmail:j.trim(),pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:x}),await new Promise(a=>setTimeout(a,1e3)),await u()}catch(a){const l=a instanceof Error?a.message:"Failed to save service account";i(l)}finally{d(!1)}},Z=async()=>{F(!0),i(null);try{await f({pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:x})}catch(a){i(a instanceof Error?a.message:"Failed to save settings")}finally{F(!1)}},ee=async()=>{const a=!(n!=null&&n.pollingActive);J(!0),i(null);try{const l=a?"/api/email/polling/start":"/api/email/polling/stop",A=a?{intervalMs:parseInt(p)||3e4}:{},C=await S(y(l),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)});if(!C.ok){const te=await C.json().catch(()=>({}));throw new Error(te.error||`HTTP ${C.status}`)}await u()}catch(l){i(l instanceof Error?l.message:"Failed to toggle polling")}finally{J(!1)}},ae=async()=>{d(!0),i(null);try{await f({refreshToken:"",serviceAccountJson:"",impersonateEmail:""}),T(null),G(null),h("credentials"),await u()}catch(a){i(a instanceof Error?a.message:"Failed to disconnect")}finally{d(!1)}},D=!!o.values.serviceAccountJson;return e.jsxs("div",{className:"gmail-oauth-setup",children:[P&&e.jsx("div",{className:"gmail-oauth-error",children:P}),b==="credentials"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsxs("div",{className:"gmail-oauth-field",style:{marginBottom:24},children:[e.jsx("label",{className:"integration-field-label",children:"Authentication Method"}),e.jsxs("div",{className:"gmail-auth-method-selector",children:[e.jsxs("button",{type:"button",className:`gmail-auth-method-btn ${r==="oauth2"?"active":""}`,onClick:()=>{I("oauth2"),i(null)},children:[e.jsx("span",{className:"gmail-auth-method-icon",children:e.jsx(B,{name:"key",size:14})}),e.jsx("span",{className:"gmail-auth-method-label",children:"OAuth 2.0"}),e.jsx("span",{className:"gmail-auth-method-desc",children:"Browser login flow"})]}),e.jsxs("button",{type:"button",className:`gmail-auth-method-btn ${r==="service_account"?"active":""}`,onClick:()=>{I("service_account"),i(null)},children:[e.jsx("span",{className:"gmail-auth-method-icon",children:e.jsx(B,{name:"robot",size:14})}),e.jsx("span",{className:"gmail-auth-method-label",children:"Service Account"}),e.jsx("span",{className:"gmail-auth-method-desc",children:"Domain-wide delegation"})]})]})]}),r==="oauth2"&&k&&!N&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Google OAuth Credentials"}),e.jsxs("div",{className:"gmail-oauth-shared-banner",children:[e.jsxs("div",{className:"gmail-oauth-shared-title",children:[e.jsx("span",{children:"✓"}),e.jsx("span",{children:"Credentials already configured"})]}),e.jsx("div",{className:"gmail-oauth-shared-body",children:"Existing Google OAuth credentials (Client ID and Secret) are saved in your secrets store — they're shared between Gmail, Calendar, and Drive. You may still need to re-authorize once so the refresh token grants Gmail access."})]})]}),r==="oauth2"&&(!k||N)&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Google OAuth Credentials"}),e.jsxs("p",{className:"gmail-oauth-help",children:["Create OAuth2 credentials in the"," ",e.jsx("a",{href:"https://console.cloud.google.com/apis/credentials",target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-link",children:"Google Cloud Console"}),". Enable the Gmail API and (optionally) the Calendar API. Set the redirect URI to:"," ",e.jsx("code",{className:"gmail-oauth-code",children:w.trim()?`${w.trim().replace(/\/$/,"")}/api/email/auth/callback`:y("/api/email/auth/callback")})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client ID ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"text",className:"integration-field-input",value:g,placeholder:"xxxx.apps.googleusercontent.com",onChange:a=>L(a.target.value)})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client Secret ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"password",className:"integration-field-input",value:v,placeholder:o.values.clientSecret?"(saved)":"Enter client secret",onChange:a=>q(a.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"OAuth Redirect Base URL"}),e.jsx("input",{type:"text",className:"integration-field-input",value:w,placeholder:"http://localhost:6200",onChange:a=>K(a.target.value),autoComplete:"off"}),e.jsxs("span",{className:"integration-field-description",children:["Override the base URL used to build the OAuth redirect (e.g. ",e.jsx("code",{children:"http://commander.local:10003"}),"). Leave empty to use the server's local address. Google does not accept raw IPs — use a domain (you can map one in ",e.jsx("code",{children:"/etc/hosts"}),")."]})]})]}),r==="service_account"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Service Account Credentials"}),e.jsxs("p",{className:"gmail-oauth-help",children:["Use a Google service account with"," ",e.jsx("a",{href:"https://admin.google.com/ac/owl/domainwidedelegation",target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-link",children:"domain-wide delegation"})," ","enabled. The service account must be authorized for Gmail scopes in Google Workspace Admin."]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["Service Account JSON ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:m,placeholder:D?"(saved — paste new JSON to replace)":"Paste the full service account JSON key file contents",onChange:a=>$(a.target.value),rows:6,spellCheck:!1}),e.jsx("span",{className:"integration-field-description",children:"The JSON key file downloaded from Google Cloud Console containing client_email and private_key."})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["Impersonate Email ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"email",className:"integration-field-input",value:j,placeholder:"user@yourdomain.com",onChange:a=>Y(a.target.value)}),e.jsx("span",{className:"integration-field-description",children:"The email address to impersonate via domain-wide delegation. Must be a user in your Google Workspace domain."})]})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Polling Interval (ms)"}),e.jsx("input",{type:"number",className:"integration-field-input",value:p,onChange:a=>E(a.target.value)}),e.jsx("span",{className:"integration-field-description",children:"How often to check for new emails. Default: 30000 (30s)."})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Approval Keywords"}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:x,onChange:a=>O(a.target.value),rows:2}),e.jsx("span",{className:"integration-field-description",children:"Comma-separated keywords that indicate email approval."})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:z,children:"Cancel"}),r==="oauth2"&&k&&!N?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"integration-btn secondary",onClick:()=>W(!0),disabled:c,children:"Edit credentials"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:X,disabled:c,children:c?"Loading...":"Authorize with existing credentials"})]}):r==="oauth2"?e.jsx("button",{type:"button",className:"integration-btn save",onClick:Q,disabled:c||!g.trim(),children:c?"Saving...":"Save & Authorize"}):e.jsx("button",{type:"button",className:"integration-btn save",onClick:V,disabled:c||!j.trim()||!m.trim()&&!D,children:c?"Connecting...":"Save & Connect"})]})]}),b==="authorize"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Authorize Gmail Access"}),e.jsx("p",{className:"gmail-oauth-help",children:"Click the link below to authorize Tide Commander to access your Gmail account. After granting access, you will be redirected back and the connection will be established automatically."}),M&&e.jsx("a",{href:M,target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-authorize-btn",children:"Authorize with Google"}),e.jsxs("div",{className:"gmail-oauth-waiting",children:[e.jsx("span",{className:"gmail-oauth-spinner"}),e.jsx("span",{children:"Waiting for authorization to complete..."})]}),e.jsx("div",{className:"integration-form-actions",children:e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:()=>{s.current&&(clearInterval(s.current),s.current=null),h("credentials")},children:"Back"})})]}),b==="connected"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Gmail Connected"}),e.jsxs("div",{className:"gmail-oauth-connected-info",children:[e.jsx("span",{className:"gmail-oauth-connected-badge",children:"Connected"}),(n==null?void 0:n.emailAddress)&&e.jsx("span",{className:"gmail-oauth-email",children:n.emailAddress}),e.jsx("span",{className:"gmail-oauth-auth-type",children:r==="service_account"?"Service Account":"OAuth 2.0"})]}),e.jsxs("div",{className:"gmail-polling-toggle-row",children:[e.jsxs("div",{className:"gmail-polling-toggle-info",children:[e.jsx("div",{className:"gmail-polling-toggle-label",children:"Automatic Polling"}),e.jsx("div",{className:"gmail-polling-toggle-status",children:n!=null&&n.pollingActive?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"gmail-polling-dot active"}),"Active",n.lastChecked&&e.jsxs("span",{className:"gmail-polling-last",children:["— last checked ",new Date(n.lastChecked).toLocaleTimeString()]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"gmail-polling-dot paused"}),"Paused — new emails will not be ingested"]})})]}),e.jsx("button",{type:"button",role:"switch","aria-checked":!!(n!=null&&n.pollingActive),"aria-label":"Toggle automatic polling",className:`gmail-polling-switch ${n!=null&&n.pollingActive?"on":"off"}`,onClick:ee,disabled:H,children:e.jsx("span",{className:"gmail-polling-switch-thumb"})})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Polling Interval (ms)"}),e.jsx("input",{type:"number",className:"integration-field-input",value:p,onChange:a=>E(a.target.value)})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Approval Keywords"}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:x,onChange:a=>O(a.target.value),rows:2})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:z,children:"Close"}),e.jsx("button",{type:"button",className:"integration-btn",style:{backgroundColor:"#f38ba8",color:"#1e1e2e"},onClick:ae,disabled:c,children:c?"Disconnecting...":"Disconnect"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:Z,disabled:U,children:U?"Saving...":"Save Settings"})]})]}),e.jsx("style",{children:`
2
2
  .gmail-oauth-setup {
3
3
  padding: 0;
4
4
  }
@@ -1,4 +1,4 @@
1
- import{r as t,i as w,k as v,j as e}from"./main-DDwa0x9e.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function B({integration:o,onSave:j,onCancel:h}){const[l,C]=t.useState(o.values.GOOGLE_CLIENT_ID||""),[p,E]=t.useState(""),[b,S]=t.useState(o.values.GOOGLE_REDIRECT_BASE_URL||""),[y,G]=t.useState(null),[g,O]=t.useState(null),[c,u]=t.useState(!1),[N,s]=t.useState(null),[A,z]=t.useState(!1),I=o.values.GOOGLE_CLIENT_ID==="********"&&o.values.GOOGLE_CLIENT_SECRET==="********",[x,f]=t.useState(o.status.connected?"connected":"credentials"),r=t.useRef(null),m=t.useCallback(async()=>{try{const n={gmail:"/api/email/status","google-calendar":"/api/calendar/status","google-drive":"/api/drive/status"}[o.id]||"/api/calendar/status",i=await w(v(n));if(i.ok){const d=await i.json();O(d),d.authenticated&&(f("connected"),r.current&&(clearInterval(r.current),r.current=null))}}catch(a){console.error("Failed to fetch Google auth status:",a)}},[o.id]);t.useEffect(()=>(m(),()=>{r.current&&clearInterval(r.current)}),[m]);const k=async()=>{const n={gmail:"/api/email/auth/url","google-calendar":"/api/calendar/auth/url","google-drive":"/api/drive/auth/url"}[o.id]||"/api/calendar/auth/url",i=await w(v(n));if(!i.ok){const _=await i.json().catch(()=>({}));throw new Error(_.error||`HTTP ${i.status}`)}const d=await i.json();if(!d.url)throw new Error("OAuth URL is empty");G(d.url),s(null),f("authorize"),r.current&&clearInterval(r.current),r.current=setInterval(m,3e3)},L=async()=>{u(!0),s(null);try{await k()}catch(a){s(a instanceof Error?a.message:"Failed to get OAuth URL")}finally{u(!1)}},R=async()=>{if(!l.trim()){s("Client ID is required");return}u(!0),s(null);try{const a={GOOGLE_REDIRECT_BASE_URL:b.trim()};l.trim()&&l.trim()!=="********"&&(a.GOOGLE_CLIENT_ID=l.trim()),p.trim()&&(a.GOOGLE_CLIENT_SECRET=p.trim()),console.log("Saving Google OAuth config...",a),await j(a),console.log("Config saved successfully"),await k()}catch(a){const n=a instanceof Error?a.message:"Failed to get OAuth URL";console.error("Error in handleSaveCredentials:",n,a),s(n)}finally{u(!1)}};return e.jsxs("div",{className:"google-oauth-setup",children:[N&&e.jsx("div",{className:"google-oauth-error",children:N}),x==="credentials"&&e.jsxs("div",{className:"google-oauth-section",children:[e.jsx("h4",{className:"google-oauth-section-title",children:"Google OAuth Credentials"}),I&&!A?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"google-oauth-shared-banner",children:[e.jsxs("div",{className:"google-oauth-shared-title",children:[e.jsx("span",{children:"✓"}),e.jsx("span",{children:"Credentials already configured"})]}),e.jsx("div",{className:"google-oauth-shared-body",children:"Existing Google OAuth credentials (Client ID and Secret) are saved in your secrets store — they're shared between Gmail, Calendar, and Drive. You may still need to re-authorize once so the refresh token grants access to this service."})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:h,children:"Cancel"}),e.jsx("button",{type:"button",className:"integration-btn secondary",onClick:()=>z(!0),disabled:c,children:"Edit credentials"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:L,disabled:c,children:c?"Loading...":"Authorize with existing credentials"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"google-oauth-help",children:["Create OAuth2 credentials in the"," ",e.jsx("a",{href:"https://console.cloud.google.com/apis/credentials",target:"_blank",rel:"noopener noreferrer",className:"google-oauth-link",children:"Google Cloud Console"}),". Enable the relevant API (Gmail, Calendar, or Drive). Set the redirect URI to:"," ",e.jsx("code",{className:"google-oauth-code",children:(()=>{const a=o.id==="gmail"?"/api/email/auth/callback":o.id==="google-drive"?"/api/drive/auth/callback":"/api/calendar/auth/callback",n=b.trim();return n?`${n.replace(/\/$/,"")}${a}`:v(a)})()})]}),e.jsxs("div",{className:"google-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client ID ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"text",className:"integration-field-input",value:l,placeholder:"xxxx.apps.googleusercontent.com",onChange:a=>C(a.target.value)})]}),e.jsxs("div",{className:"google-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client Secret ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"password",className:"integration-field-input",value:p,placeholder:o.values.GOOGLE_CLIENT_SECRET?"(saved)":"Enter client secret",onChange:a=>E(a.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"google-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"OAuth Redirect Base URL"}),e.jsx("input",{type:"text",className:"integration-field-input",value:b,placeholder:"http://localhost:6200",onChange:a=>S(a.target.value),autoComplete:"off"}),e.jsxs("span",{className:"integration-field-description",style:{display:"block",marginTop:7,color:"#7f849c",fontSize:12},children:["Override the base URL used to build the OAuth redirect (e.g. ",e.jsx("code",{children:"http://commander.local:10003"}),"). Shared across Gmail, Calendar, and Drive. Leave empty to use the server's local address. Google does not accept raw IPs — use a domain (you can map one in ",e.jsx("code",{children:"/etc/hosts"}),")."]})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:h,children:"Cancel"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:R,disabled:c||!l.trim(),children:c?"Saving...":"Save & Authorize"})]})]})]}),x==="authorize"&&e.jsxs("div",{className:"google-oauth-section",children:[e.jsx("h4",{className:"google-oauth-section-title",children:"Authorize Google Access"}),e.jsx("p",{className:"google-oauth-help",children:"Click the link below to authorize Tide Commander to access your Google account. After granting access, you will be redirected back and the connection will be established automatically."}),y&&e.jsx("a",{href:y,target:"_blank",rel:"noopener noreferrer",className:"google-oauth-authorize-btn",children:"Authorize with Google"}),e.jsxs("div",{className:"google-oauth-waiting",children:[e.jsx("span",{className:"google-oauth-spinner"}),e.jsx("span",{children:"Waiting for authorization to complete..."})]}),e.jsx("div",{className:"integration-form-actions",children:e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:()=>{r.current&&(clearInterval(r.current),r.current=null),f("credentials")},children:"Back"})})]}),x==="connected"&&e.jsxs("div",{className:"google-oauth-section",children:[e.jsx("h4",{className:"google-oauth-section-title",children:"Google Connected"}),e.jsxs("div",{className:"google-oauth-connected-info",children:[e.jsx("span",{className:"google-oauth-connected-badge",children:"Connected"}),(g==null?void 0:g.emailAddress)&&e.jsx("span",{className:"google-oauth-email",children:g.emailAddress})]}),e.jsx("p",{className:"google-oauth-help",children:"Your Google account has been successfully connected."}),e.jsx("div",{className:"integration-form-actions",children:e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:async()=>{await j({}),h()},children:"Close"})})]}),e.jsx("style",{children:`
1
+ import{r as t,i as w,k as v,j as e}from"./main-D8A4ans-.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function B({integration:o,onSave:j,onCancel:h}){const[l,C]=t.useState(o.values.GOOGLE_CLIENT_ID||""),[p,E]=t.useState(""),[b,S]=t.useState(o.values.GOOGLE_REDIRECT_BASE_URL||""),[y,G]=t.useState(null),[g,O]=t.useState(null),[c,u]=t.useState(!1),[N,s]=t.useState(null),[A,z]=t.useState(!1),I=o.values.GOOGLE_CLIENT_ID==="********"&&o.values.GOOGLE_CLIENT_SECRET==="********",[x,f]=t.useState(o.status.connected?"connected":"credentials"),r=t.useRef(null),m=t.useCallback(async()=>{try{const n={gmail:"/api/email/status","google-calendar":"/api/calendar/status","google-drive":"/api/drive/status"}[o.id]||"/api/calendar/status",i=await w(v(n));if(i.ok){const d=await i.json();O(d),d.authenticated&&(f("connected"),r.current&&(clearInterval(r.current),r.current=null))}}catch(a){console.error("Failed to fetch Google auth status:",a)}},[o.id]);t.useEffect(()=>(m(),()=>{r.current&&clearInterval(r.current)}),[m]);const k=async()=>{const n={gmail:"/api/email/auth/url","google-calendar":"/api/calendar/auth/url","google-drive":"/api/drive/auth/url"}[o.id]||"/api/calendar/auth/url",i=await w(v(n));if(!i.ok){const _=await i.json().catch(()=>({}));throw new Error(_.error||`HTTP ${i.status}`)}const d=await i.json();if(!d.url)throw new Error("OAuth URL is empty");G(d.url),s(null),f("authorize"),r.current&&clearInterval(r.current),r.current=setInterval(m,3e3)},L=async()=>{u(!0),s(null);try{await k()}catch(a){s(a instanceof Error?a.message:"Failed to get OAuth URL")}finally{u(!1)}},R=async()=>{if(!l.trim()){s("Client ID is required");return}u(!0),s(null);try{const a={GOOGLE_REDIRECT_BASE_URL:b.trim()};l.trim()&&l.trim()!=="********"&&(a.GOOGLE_CLIENT_ID=l.trim()),p.trim()&&(a.GOOGLE_CLIENT_SECRET=p.trim()),console.log("Saving Google OAuth config...",a),await j(a),console.log("Config saved successfully"),await k()}catch(a){const n=a instanceof Error?a.message:"Failed to get OAuth URL";console.error("Error in handleSaveCredentials:",n,a),s(n)}finally{u(!1)}};return e.jsxs("div",{className:"google-oauth-setup",children:[N&&e.jsx("div",{className:"google-oauth-error",children:N}),x==="credentials"&&e.jsxs("div",{className:"google-oauth-section",children:[e.jsx("h4",{className:"google-oauth-section-title",children:"Google OAuth Credentials"}),I&&!A?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"google-oauth-shared-banner",children:[e.jsxs("div",{className:"google-oauth-shared-title",children:[e.jsx("span",{children:"✓"}),e.jsx("span",{children:"Credentials already configured"})]}),e.jsx("div",{className:"google-oauth-shared-body",children:"Existing Google OAuth credentials (Client ID and Secret) are saved in your secrets store — they're shared between Gmail, Calendar, and Drive. You may still need to re-authorize once so the refresh token grants access to this service."})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:h,children:"Cancel"}),e.jsx("button",{type:"button",className:"integration-btn secondary",onClick:()=>z(!0),disabled:c,children:"Edit credentials"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:L,disabled:c,children:c?"Loading...":"Authorize with existing credentials"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"google-oauth-help",children:["Create OAuth2 credentials in the"," ",e.jsx("a",{href:"https://console.cloud.google.com/apis/credentials",target:"_blank",rel:"noopener noreferrer",className:"google-oauth-link",children:"Google Cloud Console"}),". Enable the relevant API (Gmail, Calendar, or Drive). Set the redirect URI to:"," ",e.jsx("code",{className:"google-oauth-code",children:(()=>{const a=o.id==="gmail"?"/api/email/auth/callback":o.id==="google-drive"?"/api/drive/auth/callback":"/api/calendar/auth/callback",n=b.trim();return n?`${n.replace(/\/$/,"")}${a}`:v(a)})()})]}),e.jsxs("div",{className:"google-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client ID ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"text",className:"integration-field-input",value:l,placeholder:"xxxx.apps.googleusercontent.com",onChange:a=>C(a.target.value)})]}),e.jsxs("div",{className:"google-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client Secret ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"password",className:"integration-field-input",value:p,placeholder:o.values.GOOGLE_CLIENT_SECRET?"(saved)":"Enter client secret",onChange:a=>E(a.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"google-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"OAuth Redirect Base URL"}),e.jsx("input",{type:"text",className:"integration-field-input",value:b,placeholder:"http://localhost:6200",onChange:a=>S(a.target.value),autoComplete:"off"}),e.jsxs("span",{className:"integration-field-description",style:{display:"block",marginTop:7,color:"#7f849c",fontSize:12},children:["Override the base URL used to build the OAuth redirect (e.g. ",e.jsx("code",{children:"http://commander.local:10003"}),"). Shared across Gmail, Calendar, and Drive. Leave empty to use the server's local address. Google does not accept raw IPs — use a domain (you can map one in ",e.jsx("code",{children:"/etc/hosts"}),")."]})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:h,children:"Cancel"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:R,disabled:c||!l.trim(),children:c?"Saving...":"Save & Authorize"})]})]})]}),x==="authorize"&&e.jsxs("div",{className:"google-oauth-section",children:[e.jsx("h4",{className:"google-oauth-section-title",children:"Authorize Google Access"}),e.jsx("p",{className:"google-oauth-help",children:"Click the link below to authorize Tide Commander to access your Google account. After granting access, you will be redirected back and the connection will be established automatically."}),y&&e.jsx("a",{href:y,target:"_blank",rel:"noopener noreferrer",className:"google-oauth-authorize-btn",children:"Authorize with Google"}),e.jsxs("div",{className:"google-oauth-waiting",children:[e.jsx("span",{className:"google-oauth-spinner"}),e.jsx("span",{children:"Waiting for authorization to complete..."})]}),e.jsx("div",{className:"integration-form-actions",children:e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:()=>{r.current&&(clearInterval(r.current),r.current=null),f("credentials")},children:"Back"})})]}),x==="connected"&&e.jsxs("div",{className:"google-oauth-section",children:[e.jsx("h4",{className:"google-oauth-section-title",children:"Google Connected"}),e.jsxs("div",{className:"google-oauth-connected-info",children:[e.jsx("span",{className:"google-oauth-connected-badge",children:"Connected"}),(g==null?void 0:g.emailAddress)&&e.jsx("span",{className:"google-oauth-email",children:g.emailAddress})]}),e.jsx("p",{className:"google-oauth-help",children:"Your Google account has been successfully connected."}),e.jsx("div",{className:"integration-form-actions",children:e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:async()=>{await j({}),h()},children:"Close"})})]}),e.jsx("style",{children:`
2
2
  .google-oauth-setup {
3
3
  padding: 0;
4
4
  }
@@ -1 +1 @@
1
- import{u as K,r as a,j as e}from"./main-DDwa0x9e.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function se({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{se as IframeModal,se as default};
1
+ import{u as K,r as a,j as e}from"./main-D8A4ans-.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function se({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{se as IframeModal,se as default};