tide-commander 1.166.0 → 1.167.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.
- package/CHANGELOG.md +15 -0
- package/dist/assets/{BossLogsModal-CsMSjCZp.js → BossLogsModal-CLmSG1H0.js} +1 -1
- package/dist/assets/BossSpawnModal-DZlB8KRy.js +1 -0
- package/dist/assets/ControlsModal-B1-STBnD.js +1 -0
- package/dist/assets/DockerLogsModal-CWnhsG_r.js +2 -0
- package/dist/assets/{EmbeddedEditor-n2QnK4hA.js → EmbeddedEditor-5po-iz0Q.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-DhKifdH0.js → GmailOAuthSetup-BB10r44e.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-D14lS0lT.js → GoogleOAuthSetup-CW_Ib5kq.js} +1 -1
- package/dist/assets/{IframeModal-c2Go5TIq.js → IframeModal-CPt5x5fr.js} +1 -1
- package/dist/assets/IntegrationsPanel-CO-5iHtn.js +2 -0
- package/dist/assets/{LogViewerModal-onBz0hK3.js → LogViewerModal-DicJq6l-.js} +1 -1
- package/dist/assets/{MonitoringModal-D58Oka-L.js → MonitoringModal-B3nwcYZn.js} +1 -1
- package/dist/assets/{PM2LogsModal-DtEHMB6v.js → PM2LogsModal-Viw6fBjN.js} +2 -2
- package/dist/assets/RestoreArchivedAreaModal-BVH9wxhk.js +1 -0
- package/dist/assets/Scene2DCanvas-D6TCimYq.js +1 -0
- package/dist/assets/SceneManager-BdJs75zx.js +104 -0
- package/dist/assets/{SkillsPanel-aK_Vhyhx.js → SkillsPanel-D1WonIBN.js} +1 -1
- package/dist/assets/{SlackMultiInstanceSetup-CR9tuDCR.js → SlackMultiInstanceSetup-DSTZ5Hry.js} +1 -1
- package/dist/assets/SpawnModal-DUpIkQ08.js +1 -0
- package/dist/assets/StatisticsModal-BoDgM_8E.js +1 -0
- package/dist/assets/SubordinateAssignmentModal-LysAkNGy.js +1 -0
- package/dist/assets/{TriggerManagerPanel-CtDALyfM.js → TriggerManagerPanel-BHxmBRvy.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-CEYKw625.js → WorkflowEditorPanel-BHayKmMV.js} +1 -1
- package/dist/assets/abnfDiagram-VRR7QNED-DBZ5EpAj.js +1 -0
- package/dist/assets/arc-UCe2q9lp.js +1 -0
- package/dist/assets/architectureDiagram-ZJ3FMSHR-D5zOdUA8.js +36 -0
- package/dist/assets/{area-logos-HooY4aHb.js → area-logos-4nlUPBxf.js} +1 -1
- package/dist/assets/blockDiagram-677ZJIJ3-7S-qZlh0.js +132 -0
- package/dist/assets/c4Diagram-LMCZKHZV-CgLv5SCO.js +10 -0
- package/dist/assets/channel-C59jtig-.js +1 -0
- package/dist/assets/chunk-2Q5K7J3B-J08qsAGr.js +1 -0
- package/dist/assets/chunk-32BRIVSS-Xy5D5wu7.js +1 -0
- package/dist/assets/chunk-5VM5RSS4-DqhmRB6E.js +15 -0
- package/dist/assets/chunk-EX3LRPZG-QE89_WgA.js +231 -0
- package/dist/assets/chunk-JWPE2WC7-YSc_ua_g.js +1 -0
- package/dist/assets/chunk-MOJQB5TN-CcH7NM7I.js +88 -0
- package/dist/assets/chunk-RYQCIY6F-CndQTJJ1.js +1 -0
- package/dist/assets/chunk-V7JOEXUC-Dauixo5p.js +206 -0
- package/dist/assets/chunk-VR4S4FIN-BBU6oFw0.js +1 -0
- package/dist/assets/chunk-XXDRQBXY-DXMolb4D.js +1 -0
- package/dist/assets/classDiagram-OUVF2IWQ-DHvVmqF9.js +1 -0
- package/dist/assets/classDiagram-v2-EOCWNBFH-DHvVmqF9.js +1 -0
- package/dist/assets/cose-bilkent-JH36ORCC-Dd9IB924.js +1 -0
- package/dist/assets/cynefin-VYW2F7L2-BQxwdSSb.js +178 -0
- package/dist/assets/cynefinDiagram-TSTJHNR4-BLnxgd0m.js +62 -0
- package/dist/assets/cytoscape.esm-DTSO7Bv0.js +331 -0
- package/dist/assets/dagre-VKFMJZFB-BZ7fXVWR.js +4 -0
- package/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/dist/assets/diagram-FQU43EPY-BFQ1xjHE.js +3 -0
- package/dist/assets/diagram-G47NLZAW-sXsGErM6.js +24 -0
- package/dist/assets/diagram-NH7WQ7WH-D6SPifDp.js +24 -0
- package/dist/assets/diagram-OA4YK3LP-Mu16f_2g.js +30 -0
- package/dist/assets/diagram-WEI45ONY-3BTJg43I.js +41 -0
- package/dist/assets/ebnfDiagram-CCIWWBDH-BGl2hs1X.js +1 -0
- package/dist/assets/erDiagram-Q63AITRT-D03B1rgc.js +85 -0
- package/dist/assets/flowDiagram-23GEKE2U-BCaZJGGE.js +156 -0
- package/dist/assets/ganttDiagram-NO4QXBWP-DrTSQR9G.js +292 -0
- package/dist/assets/gitGraphDiagram-IHSO6WYX-BvrZLcji.js +106 -0
- package/dist/assets/graph-C9eacEi8.js +1 -0
- package/dist/assets/index-B7l8Nsf8.js +1 -0
- package/dist/assets/index-BK7LL53p.js +1 -0
- package/dist/assets/index-CJ6x10Zs.js +2 -0
- package/dist/assets/index-D6btqUwj.js +2 -0
- package/dist/assets/{index-BSPc0AE-.js → index-DAXUzeVz.js} +6 -6
- package/dist/assets/{index-BxPFO5EJ.js → index-DcD9tVKJ.js} +3 -3
- package/dist/assets/{index-DdCk239w.js → index-Dzup44Dy.js} +6 -6
- package/dist/assets/index-JEgWBCoB.js +1 -0
- package/dist/assets/index-J_xWyk3Q.js +1 -0
- package/dist/assets/infoDiagram-FWYZ7A6U-Bw9k-wkS.js +2 -0
- package/dist/assets/init-Gi6I4Gst.js +1 -0
- package/dist/assets/ishikawaDiagram-FXEZZL3T-C2oVKtw0.js +70 -0
- package/dist/assets/journeyDiagram-5HDEW3XC-pRpwSEa5.js +139 -0
- package/dist/assets/kanban-definition-HUTT4EX6-CYq_poR1.js +89 -0
- package/dist/assets/katex-C5jXJg4s.js +257 -0
- package/dist/assets/layout-DEXfKzaS.js +1 -0
- package/dist/assets/linear-DLT2RlFJ.js +1 -0
- package/dist/assets/{main-D6IBl2Xu.js → main-06kmV-SQ.js} +125 -125
- package/dist/assets/map-Czzmt4hB.js +1 -0
- package/dist/assets/mermaid.core-DmOBz9SE.js +314 -0
- package/dist/assets/mindmap-definition-LN4V7U3C-DzucjpI_.js +96 -0
- package/dist/assets/ordinal-Cboi1Yqb.js +1 -0
- package/dist/assets/pegDiagram-2B236MQR-CIf_bLf4.js +1 -0
- package/dist/assets/pieDiagram-ENE6RG2P-Dh9HXeSf.js +39 -0
- package/dist/assets/quadrantDiagram-ABIIQ3AL-B5hZRZ5w.js +7 -0
- package/dist/assets/railroadDiagram-RFXS5EU6-B1oWAO1u.js +1 -0
- package/dist/assets/requirementDiagram-TGXJPOKE-Cg7bjm4O.js +84 -0
- package/dist/assets/sankeyDiagram-HTMAVEWB-TLCrcbtk.js +40 -0
- package/dist/assets/sequenceDiagram-DBY2YBRQ-BD3b_psw.js +162 -0
- package/dist/assets/sizeCapture-X5ZJPWSS-D26nx1uQ.js +1 -0
- package/dist/assets/stateDiagram-2N3HPSRC-CIwRQUnK.js +1 -0
- package/dist/assets/stateDiagram-v2-6OUMAXLB-C5qcZ4o1.js +1 -0
- package/dist/assets/swimlanes-5IMT3BWC-DYbes851.js +2 -0
- package/dist/assets/swimlanesDiagram-G3AALYLV-Ke-NRRIa.js +8 -0
- package/dist/assets/timeline-definition-FHXFAJF6-Fr9U6JU6.js +120 -0
- package/dist/assets/{vendor-three-Chj50gSY.js → vendor-three-3OKhI9bz.js} +1 -1
- package/dist/assets/vennDiagram-L72KCM5P-Cns-KLq7.js +34 -0
- package/dist/assets/wardleyDiagram-EHGQE667-DHA7rD9Z.js +78 -0
- package/dist/assets/{web-BVrXaF9j.js → web-B7c8sthS.js} +1 -1
- package/dist/assets/{web-B6Lyhp8u.js → web-C05qFIA-.js} +1 -1
- package/dist/assets/{web-DQi4Jy_X.js → web-Dja1kfLs.js} +1 -1
- package/dist/assets/xychartDiagram-FW5EYKEG-DCnL05Wq.js +7 -0
- package/dist/build-info.json +1 -1
- package/dist/index.html +2 -2
- package/dist/src/packages/server/claude/runner/watchdog.js +27 -0
- package/dist/src/packages/server/codex/app-server/codex-app-server-runner.js +34 -4
- package/dist/src/packages/server/data/builtin-skills/index.js +2 -0
- package/dist/src/packages/server/data/builtin-skills/mermaid-diagrams.js +76 -0
- package/dist/src/packages/server/opencode/server/opencode-server-process.js +102 -7
- package/dist/src/packages/server/opencode/server/opencode-server-runner.js +13 -0
- package/dist/src/packages/server/services/agent-service.js +7 -0
- package/dist/src/packages/server/services/runtime-events.js +1 -0
- package/package.json +2 -1
- package/dist/assets/BossSpawnModal-Z6ZZuraP.js +0 -1
- package/dist/assets/ControlsModal-UAWrBPnS.js +0 -1
- package/dist/assets/DockerLogsModal-Dvk09sbP.js +0 -2
- package/dist/assets/IntegrationsPanel-CkZyLCWN.js +0 -2
- package/dist/assets/RestoreArchivedAreaModal-BKgjpTYA.js +0 -1
- package/dist/assets/Scene2DCanvas-BSe1eM97.js +0 -1
- package/dist/assets/SceneManager-Bv_J6Asr.js +0 -104
- package/dist/assets/SpawnModal-BGoN5C1p.js +0 -1
- package/dist/assets/StatisticsModal-BY9pHl-m.js +0 -1
- package/dist/assets/SubordinateAssignmentModal-2bO3Y-zS.js +0 -1
- package/dist/assets/index-BTaesMkc.js +0 -1
- package/dist/assets/index-CCZsNuvk.js +0 -1
- package/dist/assets/index-CUfnGcms.js +0 -2
- package/dist/assets/index-CwjljR04.js +0 -1
- package/dist/assets/index-DPJj90PK.js +0 -2
- package/dist/assets/index-I8PSiTLl.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.167.0] - 2026-07-17
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **Mermaid diagrams in chat** - agent responses containing a ` ```mermaid ` fenced block now render as a diagram inline. The chat shows a clean static preview; clicking it opens a modal with an interactive viewport — zoom (buttons or ctrl/⌘-scroll toward the cursor) and drag-to-pan — so large diagrams stay explorable without cluttering the thread. Streaming-safe: shows a stable "Rendering diagram…" placeholder (with collapsible source) until the syntax settles, and falls back to raw source if invalid.
|
|
9
|
+
- **Mermaid skill (default)** - a new built-in "Mermaid Diagrams" skill, enabled for every agent, that teaches agents when and how to emit Mermaid (flowcharts, sequence, ER, state, gantt, class) so they reach for a diagram instead of prose when a visual lands faster.
|
|
10
|
+
- **Error detail on the status badge** - hovering an agent whose status is "error" now shows the underlying runtime error message as a tooltip; it clears automatically once the agent recovers.
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- **Duplicate first message (OpenCode/Codex)** - the opening prompt of a new OpenCode or Codex session is persisted wrapped in the instruction block; the UI unwraps it for display, so it appeared twice (a live row next to its history twin). The live row is now deduplicated against the wrapping twin, while two legitimately-identical sends are preserved.
|
|
14
|
+
- **"Send now" on Codex app-server** - interrupting a Codex app-server turn silently failed (the request was missing the required turn id). The runner now tracks the active turn id, so "Send now"/stop actually interrupts the running turn.
|
|
15
|
+
- **Duplicated prompt on OpenCode** - a transient network hiccup could resend an OpenCode prompt that had already landed, so agents saw the same message twice. POSTs are no longer auto-retried on transport errors (only idempotent GETs retry once).
|
|
16
|
+
- **Long OpenCode turns falsely erroring** - turns running longer than ~5 minutes could trip a request timeout and wrongly flag the agent as errored. The message send now uses a dedicated no-timeout connection that waits harmlessly for turn end.
|
|
17
|
+
- **OpenCode agent going silent after a failed send** - a failed send left the runner stuck "processing" so every later message queued forever and never arrived; the turn state now resets and the queue drains on recovery.
|
|
18
|
+
- **Stuck mid-turn CLI recovery** - a tmux-mode CLI that hangs mid-turn (e.g. Grok deadlocking on resume of a killed session) — alive but emitting nothing and stuck "working" forever — is now detected by the watchdog, killed, and respawned through the capped restart policy so it ends in a clear error instead of hanging indefinitely.
|
|
19
|
+
|
|
5
20
|
## [1.166.0] - 2026-07-17
|
|
6
21
|
|
|
7
22
|
### Added
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as M,
|
|
1
|
+
import{u as M,e as N,f as v,r as m,s as u,j as r}from"./main-06kmV-SQ.js";import{L as B}from"./LogViewerModal-DicJq6l-.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-3OKhI9bz.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as Be,x as Oe,k as Re,i as Fe,r as t,m as re,S as G,y as R,d as Te,s as S,C as W,A as de,z as C,j as s,n as y,M as Pe,F as ze,I as F,P as K,o as A,p as T,t as H,w as Ue}from"./main-06kmV-SQ.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-3OKhI9bz.js";function ue(u){const w=C.filter(E=>!u.has(`Boss ${E}`));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:E,onSpawnEnd:P,spawnPosition:me,spawnAreaId:g}){const{t:n}=Be(["terminal","common"]),J=Oe(),c=Re(),$=Fe(),[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(""),O=t.useRef(null),q=t.useRef(!1),ne=t.useRef(!1),b=t.useMemo(()=>$.filter(e=>e.enabled),[$]),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?$.filter(l=>e.defaultSkillIds.includes(l.id)):[]},[c,d,$]),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(R).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 Te(`/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=R.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),O.current&&(O.current.focus(),O.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),E(),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()},Ee=()=>{V(!1),p(""),B(new Set),P(),w()},$e=()=>{V(!1),_(!0),P()};t.useEffect(()=>(window.__bossSpawnModalSuccess=Ee,window.__bossSpawnModalError=$e,()=>{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=R.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:O,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(F,{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(F,{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(T).map(e=>s.jsxs("button",{className:`spawn-select-btn ${ee===e?"selected":""}`,onClick:()=>fe(e),title:T[e].description,children:[s.jsx("span",{children:T[e].icon}),s.jsx("span",{children:T[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(F,{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=R[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(F,{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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as K,L as Q,x as J,N as W,Q as ee,r as u,R as se,g as te,T as D,U as z,V as ae,j as e,W as ne,X as re,s as g,Y as R,Z as V}from"./main-06kmV-SQ.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-3OKhI9bz.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"]},oe={camera:"terminal:controls.cameraControls",interaction:"terminal:controls.interaction"};function pe({isOpen:s,onClose:r}){const{t:a}=K(["terminal","common"]),l=Q(),o=J(),h=W(),N=ee(),[x,C]=u.useState("keyboard"),[b,v]=u.useState(""),[p,j]=u.useState("all"),[m,f]=u.useState(!1),[c,d]=u.useState(null),[k,w]=u.useState(null),Y=se.useRef(null),{handleMouseDown:X,handleClick:Z}=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&&c){const A=S=>S===" "||S==="Space"?"Space":S.length===1?S.toLowerCase():S,L=A(t.key),B=A(c.key);if(!(B.length===1&&/^[a-zA-Z]$/.test(L)?`Key${L.toUpperCase()}`==`Key${B.toUpperCase()}`:L===B))return!1;const M=t.modifiers,T=c.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(o.values()).map(t=>t).filter(t=>t.shortcut&&t.shortcut.trim().length>0).filter(t=>{const n=z(t.shortcut).toLowerCase();if(m&&c){const y={key:c.key,code:c.key.length===1&&/^[a-zA-Z]$/.test(c.key)?`Key${c.key.toUpperCase()}`:c.key.length===1&&/^[0-9]$/.test(c.key)?`Digit${c.key}`:c.key==="Space"?"Space":c.key,ctrlKey:!!c.modifiers.ctrl,altKey:!!c.modifiers.alt,shiftKey:!!c.modifiers.shift,metaKey:!!c.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),{}),I=(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:Z,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"})]}),c?e.jsxs("span",{className:"find-by-shortcut-display",children:[D({key:c.key,modifiers:c.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=>I(i.id,y)})]},i.id))})]},t)}),F.length===0&&E.length===0&&e.jsx("div",{className:"shortcuts-empty",children:m?c?e.jsx("p",{children:a("terminal:controls.noShortcutBoundTo",{keys:D({key:c.key,modifiers:c.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(oe[t])})}),e.jsx("div",{className:"shortcuts-grid",children:n.map(i=>e.jsx(ce,{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 ce({binding:s}){const{t:r}=K(["terminal"]),a=W(),[l,o]=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(),o(!1),N(null))},f=()=>{h&&R(a.bindings,h,s.id).length===0&&g.updateMouseBinding(s.id,{button:h.button,modifiers:h.modifiers}),o(!1),N(null)},c=setTimeout(()=>{document.addEventListener("mousedown",j,!0),document.addEventListener("keydown",m,!0),document.addEventListener("click",f,!0)},100);return()=>{clearTimeout(c),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:()=>o(!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,o)=>{g.updateCameraSensitivity({[l]:o})},[]);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((o,h)=>{g.updateTrackpadConfig({[o]:h})},[]),l=u.useCallback((o,h)=>{g.updateTrackpadConfig({sensitivity:{[o]: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:o=>a("enabled",o.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:o=>a("pinchToZoom",o.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:o=>a("twoFingerPan",o.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:o=>a("shiftTwoFingerOrbit",o.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:o=>l("zoom",parseFloat(o.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:o=>l("pan",parseFloat(o.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:o=>l("orbit",parseFloat(o.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{u as f,a as u,b as S,r as n,s as o,j as x}from"./main-06kmV-SQ.js";import{L as k}from"./LogViewerModal-DicJq6l-.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-3OKhI9bz.js";function I({building:e,isOpen:t,onClose:i,onMinimize:m}){var a;const{t:c}=f(["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
|
+
`).map((s,p)=>({text:s,lineNumber:p+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{I as DockerLogsModal};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as ot,j as Tt}from"./main-
|
|
1
|
+
import{r as ot,j as Tt}from"./main-06kmV-SQ.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-3OKhI9bz.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-D6IBl2Xu.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,c as S,d as y,j as e,I as B}from"./main-06kmV-SQ.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-3OKhI9bz.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,
|
|
1
|
+
import{r,c as E,d as y,j as e}from"./main-06kmV-SQ.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-3OKhI9bz.js";function F({integration:o,onSave:k,onCancel:x}){const[g,G]=r.useState(o.values.GOOGLE_CLIENT_ID||""),[f,O]=r.useState(""),[m,A]=r.useState(o.values.GOOGLE_REDIRECT_BASE_URL||""),[N,z]=r.useState(null),[a,S]=r.useState(null),[l,h]=r.useState(!1),[C,s]=r.useState(null),[L,w]=r.useState(!1),I=o.values.GOOGLE_CLIENT_ID==="********"&&o.values.GOOGLE_CLIENT_SECRET==="********",[b,p]=r.useState(o.status.needsReauth?"expired":o.status.connected?"connected":"credentials"),n=r.useRef(null),j=r.useCallback(async(t=!1)=>{try{const d={gmail:"/api/email/status","google-calendar":"/api/calendar/status","google-drive":"/api/drive/status"}[o.id]||"/api/calendar/status",u=await E(y(t?`${d}?probe=1`:d));if(u.ok){const c=await u.json();S(c),c.needsReauth?p("expired"):c.authenticated&&p("connected"),(c.authenticated||c.needsReauth)&&n.current&&(clearInterval(n.current),n.current=null)}}catch(i){console.error("Failed to fetch Google auth status:",i)}},[o.id]);r.useEffect(()=>(j(!0),()=>{n.current&&clearInterval(n.current)}),[j]);const v=async()=>{const i={gmail:"/api/email/auth/url","google-calendar":"/api/calendar/auth/url","google-drive":"/api/drive/auth/url"}[o.id]||"/api/calendar/auth/url",d=await E(y(i));if(!d.ok){const c=await d.json().catch(()=>({}));throw new Error(c.error||`HTTP ${d.status}`)}const u=await d.json();if(!u.url)throw new Error("OAuth URL is empty");z(u.url),s(null),p("authorize"),n.current&&clearInterval(n.current),n.current=setInterval(j,3e3)},R=async()=>{h(!0),s(null);try{await v()}catch(t){s(t instanceof Error?t.message:"Failed to get OAuth URL")}finally{h(!1)}},_=async()=>{if(!g.trim()){s("Client ID is required");return}h(!0),s(null);try{const t={GOOGLE_REDIRECT_BASE_URL:m.trim()};g.trim()&&g.trim()!=="********"&&(t.GOOGLE_CLIENT_ID=g.trim()),f.trim()&&(t.GOOGLE_CLIENT_SECRET=f.trim()),console.log("Saving Google OAuth config...",t),await k(t),console.log("Config saved successfully"),await v()}catch(t){const i=t instanceof Error?t.message:"Failed to get OAuth URL";console.error("Error in handleSaveCredentials:",i,t),s(i)}finally{h(!1)}};return e.jsxs("div",{className:"google-oauth-setup",children:[C&&e.jsx("div",{className:"google-oauth-error",children:C}),b==="credentials"&&e.jsxs("div",{className:"google-oauth-section",children:[e.jsx("h4",{className:"google-oauth-section-title",children:"Google OAuth Credentials"}),I&&!L?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:x,children:"Cancel"}),e.jsx("button",{type:"button",className:"integration-btn secondary",onClick:()=>w(!0),disabled:l,children:"Edit credentials"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:R,disabled:l,children:l?"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 t=o.id==="gmail"?"/api/email/auth/callback":o.id==="google-drive"?"/api/drive/auth/callback":"/api/calendar/auth/callback",i=m.trim();return i?`${i.replace(/\/$/,"")}${t}`:y(t)})()})]}),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:g,placeholder:"xxxx.apps.googleusercontent.com",onChange:t=>G(t.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:f,placeholder:o.values.GOOGLE_CLIENT_SECRET?"(saved)":"Enter client secret",onChange:t=>O(t.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:m,placeholder:"http://localhost:6200",onChange:t=>A(t.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:x,children:"Cancel"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:_,disabled:l||!g.trim(),children:l?"Saving...":"Save & Authorize"})]})]})]}),b==="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."}),N&&e.jsx("a",{href:N,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:()=>{n.current&&(clearInterval(n.current),n.current=null),p("credentials")},children:"Back"})})]}),b==="expired"&&e.jsxs("div",{className:"google-oauth-section",children:[e.jsx("h4",{className:"google-oauth-section-title",children:"Google Authorization Expired"}),e.jsxs("div",{className:"google-oauth-expired-banner",children:[e.jsxs("div",{className:"google-oauth-expired-title",children:[e.jsx("span",{children:"⚠"}),e.jsx("span",{children:(a==null?void 0:a.tokenState)==="invalid_client"?"OAuth credentials rejected":"Token expired — reconnect required"})]}),e.jsx("div",{className:"google-oauth-expired-body",children:(a==null?void 0:a.tokenState)==="invalid_client"?e.jsx(e.Fragment,{children:"Google rejected the Client ID / Client Secret. Confirm the OAuth client still exists in the Google Cloud Console, then re-enter the credentials."}):e.jsxs(e.Fragment,{children:["Google rejected the stored refresh token, so Gmail, Calendar, and Drive can no longer act on your account — they all share this one token. This normally happens when access is revoked, the account password changed, or the OAuth consent screen is still in ",e.jsx("strong",{children:"Testing"})," mode (Google expires those refresh tokens after 7 days — publish the app to stop it recurring)."]})}),(a==null?void 0:a.error)&&e.jsx("div",{className:"google-oauth-expired-detail",children:a.error})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:x,children:"Close"}),e.jsx("button",{type:"button",className:"integration-btn secondary",onClick:()=>{w(!0),p("credentials")},disabled:l,children:"Edit credentials"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:async()=>{h(!0),s(null);try{await v()}catch(t){s(t instanceof Error?t.message:"Failed to get OAuth URL")}finally{h(!1)}},disabled:l,children:l?"Loading...":"Reconnect Google"})]})]}),b==="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"}),(a==null?void 0:a.emailAddress)&&e.jsx("span",{className:"google-oauth-email",children:a.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 k({}),x()},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-
|
|
1
|
+
import{u as K,r as a,j as e}from"./main-06kmV-SQ.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-3OKhI9bz.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GmailOAuthSetup-BB10r44e.js","assets/main-06kmV-SQ.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-3OKhI9bz.js","assets/main-BzGnAbiA.css","assets/GoogleOAuthSetup-CW_Ib5kq.js","assets/SlackMultiInstanceSetup-DSTZ5Hry.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as d,c as R,d as w,j as e,R as P,$ as T}from"./main-06kmV-SQ.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-3OKhI9bz.js";const z={"gmail-oauth":d.lazy(()=>T(()=>import("./GmailOAuthSetup-BB10r44e.js"),__vite__mapDeps([0,1,2,3,4])).then(n=>({default:n.GmailOAuthSetup}))),"google-oauth":d.lazy(()=>T(()=>import("./GoogleOAuthSetup-CW_Ib5kq.js"),__vite__mapDeps([5,1,2,3,4])).then(n=>({default:n.GoogleOAuthSetup}))),"slack-multi-instance":d.lazy(()=>T(()=>import("./SlackMultiInstanceSetup-DSTZ5Hry.js"),__vite__mapDeps([6,1,2,3,4])).then(n=>({default:n.SlackMultiInstanceSetup})))},A={gmail:"✉️",slack:"💬",jira:"📋","google-calendar":"📅","google-drive":"📁",docx:"📄"},B={gmail:"Send and receive emails through Gmail. Supports OAuth 2.0 authentication for secure access to your inbox.",slack:"Connect to Slack workspaces. Send messages, receive notifications, and integrate with channels.",jira:"Manage Jira issues and projects. Create tickets, track progress, and handle service desk requests.","google-calendar":"Access Google Calendar events. Create, update, and monitor calendar entries.","google-drive":"Read, create, and edit files in Google Drive. Search and manage folders.",docx:"Generate and manipulate DOCX documents. Create reports, templates, and formatted documents."},E={gmail:["Google Cloud Console project","OAuth 2.0 credentials (Client ID & Secret)","Gmail API enabled"],slack:["Bot token (xoxb-) with App-Level Token for real-time Socket Mode, OR User token (xoxp-) for polling mode (~30-60s lag, no Slack app config needed)","For Socket Mode: enable Socket Mode + Event Subscriptions; subscribe to bot events message.channels, message.groups, message.im","Required scopes: channels:history, channels:read, chat:write, groups:history, groups:read, im:history, im:read, users:read","Polling mode (xoxp-) mirrors all channels/groups/DMs the user is a member of — supports xoxp- user tokens that cannot use Socket Mode"],jira:["Jira Cloud instance URL","API Token (from Atlassian account)","Account email address"],"google-calendar":["Google Cloud Console project","OAuth 2.0 credentials","Calendar API enabled"],"google-drive":["Google Cloud Console project","OAuth 2.0 credentials (Client ID & Secret)","Google Drive API enabled"],docx:["No external credentials required","Templates directory (optional)"]},s={overlay:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4,backdropFilter:"blur(4px)",animation:"fadeIn 0.15s ease-out"},modal:{background:"var(--surface-0, #1e1e2e)",borderRadius:12,border:"1px solid var(--border, #313244)",width:"90vw",maxWidth:720,maxHeight:"85vh",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.5)",animation:"slideUp 0.2s ease-out"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--border, #313244)",background:"var(--surface-1, #181825)"},headerTitle:{fontSize:16,fontWeight:600,color:"var(--text-primary, #cdd6f4)",display:"flex",alignItems:"center",gap:8},closeBtn:{background:"none",border:"none",color:"var(--text-secondary, #a6adc8)",fontSize:20,cursor:"pointer",padding:"4px 8px",borderRadius:6,lineHeight:1},tabs:{display:"flex",borderBottom:"1px solid var(--border, #313244)",background:"var(--surface-1, #181825)",overflowX:"auto",scrollbarWidth:"none"},tab:n=>({padding:"10px 16px",background:"none",border:"none",borderBottom:n?"2px solid var(--accent, #89b4fa)":"2px solid transparent",color:n?"var(--accent, #89b4fa)":"var(--text-secondary, #a6adc8)",fontSize:13,fontWeight:n?600:400,cursor:"pointer",display:"flex",alignItems:"center",gap:6,whiteSpace:"nowrap",transition:"color 0.15s, border-color 0.15s",flexShrink:0}),tabStatus:(n,u)=>({width:6,height:6,borderRadius:"50%",background:u?"#f38ba8":n?"#a6e3a1":"#fab387",flexShrink:0}),body:{flex:1,overflow:"auto",padding:20},integrationHeader:{display:"flex",alignItems:"flex-start",gap:12,marginBottom:16},iconCircle:{width:44,height:44,borderRadius:10,background:"var(--surface-1, #181825)",border:"1px solid var(--border, #313244)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:22,flexShrink:0},integrationMeta:{flex:1},integrationName:{fontSize:15,fontWeight:600,color:"var(--text-primary, #cdd6f4)",marginBottom:4,display:"flex",alignItems:"center",gap:8},description:{fontSize:13,color:"var(--text-secondary, #a6adc8)",lineHeight:1.5},statusBadge:(n,u)=>({display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",borderRadius:10,fontSize:11,fontWeight:600,background:u?"rgba(243, 139, 168, 0.15)":n?"rgba(166, 227, 161, 0.15)":"rgba(250, 179, 135, 0.15)",color:u?"#f38ba8":n?"#a6e3a1":"#fab387"}),section:{marginTop:16,padding:12,borderRadius:8,background:"var(--surface-1, #181825)",border:"1px solid var(--border, #313244)"},sectionTitle:{fontSize:12,fontWeight:600,color:"var(--text-secondary, #a6adc8)",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:8},requirementList:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:4},requirementItem:{fontSize:12,color:"var(--text-secondary, #a6adc8)",display:"flex",alignItems:"center",gap:6},formSection:{marginTop:16},formSectionTitle:{fontSize:12,fontWeight:600,color:"var(--text-secondary, #a6adc8)",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:12}};function O({integration:n,onSave:u,onCancel:x}){const[p,I]=d.useState({...n.values}),[b,h]=d.useState({}),[f,C]=d.useState(!1),[m,v]=d.useState(!1);d.useEffect(()=>{I({...n.values}),h({}),v(!1)},[n.id]);const y=(r,l)=>{I(o=>({...o,[r]:l})),h(o=>{const i={...o};return delete i[r],i}),v(!1)},k=async r=>{r.preventDefault();const l={};for(const o of n.schema)if(o.required&&!p[o.key]&&p[o.key]!==0&&p[o.key]!==!1&&(l[o.key]=`${o.label} is required`),o.validate){const i=o.validate(p[o.key]);i&&(l[o.key]=i)}if(Object.keys(l).length>0){h(l);return}C(!0);try{await u(p),v(!0),setTimeout(()=>v(!1),3e3)}catch(o){h({_form:String(o)})}finally{C(!1)}},S=new Map;for(const r of n.schema){const l=r.group||"";S.has(l)||S.set(l,[]),S.get(l).push(r)}const a={display:"flex",flexDirection:"column",gap:4,marginBottom:12},t={fontSize:13,fontWeight:500,color:"var(--text-primary, #cdd6f4)"},c={padding:"8px 10px",borderRadius:6,border:"1px solid var(--border, #313244)",background:"var(--surface-0, #1e1e2e)",color:"var(--text-primary, #cdd6f4)",fontSize:13,outline:"none",width:"100%",boxSizing:"border-box"},g={fontSize:11,color:"var(--text-secondary, #a6adc8)"},j={fontSize:11,color:"#f38ba8"},_=r=>{var o;const l=p[r.key]??r.defaultValue??"";switch(r.type){case"boolean":return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:"var(--text-primary, #cdd6f4)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!l,onChange:i=>y(r.key,i.target.checked)}),r.label]});case"select":return e.jsxs("select",{style:c,value:String(l),onChange:i=>y(r.key,i.target.value),children:[e.jsx("option",{value:"",children:r.placeholder||"Select..."}),(o=r.options)==null?void 0:o.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))]});case"textarea":return e.jsx("textarea",{style:{...c,resize:"vertical",minHeight:80},value:String(l),placeholder:r.placeholder,onChange:i=>y(r.key,i.target.value),rows:4});case"number":return e.jsx("input",{type:"number",style:c,value:l===""?"":Number(l),placeholder:r.placeholder,onChange:i=>y(r.key,i.target.value===""?"":Number(i.target.value))});case"password":return e.jsx("input",{type:"password",style:c,value:String(l),placeholder:r.placeholder,onChange:i=>y(r.key,i.target.value),autoComplete:"off"});default:return e.jsx("input",{type:r.type,style:c,value:String(l),placeholder:r.placeholder,onChange:i=>y(r.key,i.target.value)})}};return e.jsxs("form",{onSubmit:k,children:[b._form&&e.jsx("div",{style:{...j,marginBottom:12,padding:"8px 10px",borderRadius:6,background:"rgba(243, 139, 168, 0.1)"},children:b._form}),Array.from(S.entries()).map(([r,l])=>e.jsxs("div",{children:[r&&e.jsx("div",{style:{...s.sectionTitle,marginTop:16,marginBottom:8},children:r}),l.map(o=>e.jsxs("div",{style:a,children:[o.type!=="boolean"&&e.jsxs("label",{style:t,children:[o.label,o.required&&e.jsx("span",{style:{color:"#f38ba8",marginLeft:2},children:"*"})]}),_(o),o.description&&e.jsx("span",{style:g,children:o.description}),b[o.key]&&e.jsx("span",{style:j,children:b[o.key]})]},o.key))]},r||"_default")),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:16,paddingTop:12,borderTop:"1px solid var(--border, #313244)"},children:[e.jsx("button",{type:"button",onClick:x,style:{padding:"8px 16px",borderRadius:6,border:"1px solid var(--border, #313244)",background:"none",color:"var(--text-secondary, #a6adc8)",fontSize:13,cursor:"pointer"},children:"Cancel"}),e.jsx("button",{type:"submit",disabled:f,style:{padding:"8px 16px",borderRadius:6,border:"none",background:m?"#a6e3a1":"var(--accent, #89b4fa)",color:"#1e1e2e",fontSize:13,fontWeight:600,cursor:f?"wait":"pointer",opacity:f?.7:1},children:f?"Saving...":m?"Saved":"Save Configuration"})]})]})}function M({isOpen:n,onClose:u,initialTab:x}){const[p,I]=d.useState([]),[b,h]=d.useState(x||null),[f,C]=d.useState(!0),[m,v]=d.useState(null),y=d.useRef(x||null),k=d.useCallback(async()=>{try{const t=await R(w("/api/integrations"));if(!t.ok)throw new Error(`HTTP ${t.status}`);const c=await t.json();I(c),v(null),h(g=>{const j=g||x||(c.length>0?c[0].id:null);return y.current=j,j})}catch(t){v(`Failed to load integrations: ${t}`)}finally{C(!1)}},[x]);d.useEffect(()=>{n&&(C(!0),k(),x&&h(x))},[n,x]);const S=d.useCallback(async(t,c)=>{const g=await R(w(`/api/integrations/${t}/config`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!g.ok){const j=await g.json().catch(()=>({}));throw new Error(j.error||`HTTP ${g.status}`)}await k()},[k]);if(!n)return null;const a=p.find(t=>t.id===b);return e.jsx("div",{style:s.overlay,onClick:u,children:e.jsxs("div",{style:s.modal,onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{style:s.header,children:[e.jsxs("div",{style:s.headerTitle,children:[e.jsx("span",{children:"🔌"}),e.jsx("span",{children:"Integrations"})]}),e.jsx("button",{style:s.closeBtn,onClick:u,title:"Close",children:"×"})]}),f&&e.jsx("div",{style:{padding:40,textAlign:"center",color:"var(--text-secondary, #a6adc8)"},children:"Loading integrations..."}),m&&e.jsxs("div",{style:{padding:20,textAlign:"center"},children:[e.jsx("div",{style:{color:"#f38ba8",marginBottom:8},children:m}),e.jsx("button",{onClick:k,style:{padding:"6px 12px",borderRadius:6,border:"1px solid var(--border, #313244)",background:"none",color:"var(--text-primary, #cdd6f4)",cursor:"pointer",fontSize:13},children:"Retry"})]}),!f&&!m&&p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:s.tabs,children:p.map(t=>e.jsxs("button",{style:s.tab(b===t.id),onClick:()=>h(t.id),children:[e.jsx("span",{children:A[t.id]||"🔌"}),e.jsx("span",{children:t.name}),e.jsx("span",{style:s.tabStatus(t.status.connected,!!t.status.error)})]},t.id))}),e.jsx("div",{style:s.body,children:a&&e.jsxs("div",{children:[e.jsxs("div",{style:s.integrationHeader,children:[e.jsx("div",{style:s.iconCircle,children:A[a.id]||"🔌"}),e.jsxs("div",{style:s.integrationMeta,children:[e.jsxs("div",{style:s.integrationName,children:[a.name,e.jsx("span",{style:s.statusBadge(a.status.connected,!!a.status.error),children:a.status.needsReauth?"⚠ Token Expired — Reconnect":a.status.error?"✗ Error":a.status.connected?"✓ Connected":"⚠ Not Configured"}),a.id==="slack"&&(()=>{var g;const t=((g=a.values)==null?void 0:g.currentMode)||"none";if(t==="none")return null;const c=t==="polling"?"Polling":"Socket";return e.jsx("span",{style:{marginLeft:8,padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:500,background:"rgba(137, 180, 250, 0.15)",color:"#89b4fa",border:"1px solid rgba(137, 180, 250, 0.3)"},title:t==="polling"?"Web API polling (xoxp- user token)":"Real-time Socket Mode (xoxb- bot token)",children:c})})()]}),e.jsx("div",{style:s.description,children:B[a.id]||a.description})]})]}),a.status.error&&e.jsxs("div",{style:{...s.section,borderColor:"rgba(243, 139, 168, 0.3)",background:"rgba(243, 139, 168, 0.05)"},children:[e.jsx("div",{style:{...s.sectionTitle,color:"#f38ba8"},children:"Error"}),e.jsx("div",{style:{fontSize:12,color:"#f38ba8"},children:a.status.error})]}),E[a.id]&&e.jsxs("div",{style:s.section,children:[e.jsx("div",{style:s.sectionTitle,children:"Requirements"}),e.jsx("ul",{style:s.requirementList,children:E[a.id].map((t,c)=>e.jsxs("li",{style:s.requirementItem,children:[e.jsx("span",{style:{color:"var(--accent, #89b4fa)"},children:"•"}),t]},c))})]}),e.jsxs("div",{style:s.formSection,children:[e.jsx("div",{style:s.formSectionTitle,children:"Configuration"}),a.customComponent&&z[a.customComponent]?e.jsx(d.Suspense,{fallback:e.jsx("div",{style:{color:"var(--text-secondary)",fontSize:13},children:"Loading..."}),children:P.createElement(z[a.customComponent],{key:a.id,integration:a,onSave:t=>S(a.id,t),onCancel:u})}):e.jsx(O,{integration:a,onSave:t=>S(a.id,t),onCancel:u})]})]})})]}),!f&&!m&&p.length===0&&e.jsx("div",{style:{padding:40,textAlign:"center",color:"var(--text-secondary, #a6adc8)"},children:"No integrations available."})]})})}export{M as IntegrationsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as me,r as l,
|
|
1
|
+
import{u as me,r as l,g as ge,j as e,I as xe,h as fe}from"./main-06kmV-SQ.js";function je({isOpen:E,onClose:L,onMinimize:P,title:B,icon:U,lines:c,isStreaming:F,onClear:J,emptyMessage:V,streamingIndicatorLabel:X,headerInfo:Y,isLoading:W,extraToolbar:Z,extraFooter:O,modalClassName:ee}){const{t:a}=me(["terminal","common"]),[u,$]=l.useState(""),[h,w]=l.useState(!1),[f,S]=l.useState(!1),[M,I]=l.useState(""),[k,p]=l.useState(!0),[R,te]=l.useState(!0),[se,Q]=l.useState(null),[r,le]=l.useState([]),[m,j]=l.useState(0),[v,ne]=l.useState(!1),[T,re]=l.useState(5),[_,C]=l.useState(null),[y,ae]=l.useState(!0),o=l.useRef(null),D=l.useRef(null),A=l.useRef(null),H=l.useRef(!1),q=l.useRef(0),K=l.useMemo(()=>c.map(t=>t.text),[c]),b=l.useMemo(()=>{if(!u)return C(null),null;try{const t=v?u:u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=new RegExp(t,"gi");return C(null),s}catch(t){return C(t.message),null}},[u,v]),N=l.useMemo(()=>{if(!b)return[];const t=[];for(let s=0;s<K.length;s++)b.test(K[s])&&t.push(s),b.lastIndex=0;return t},[K,b]);l.useEffect(()=>{le(N),m>=N.length&&j(Math.max(0,N.length-1))},[N]);const oe=l.useMemo(()=>{const t=c.map((i,x)=>({entry:i,originalIndex:x}));if(!u||!b||y)return t;if(N.length===0)return[];const s=new Set;for(const i of N){const x=Math.max(0,i-T),de=Math.min(c.length-1,i+T);for(let G=x;G<=de;G++)s.add(G)}const n=Array.from(s).sort((i,x)=>i-x),d=[];for(let i=0;i<n.length;i++){const x=n[i];i>0&&x-n[i-1]>1&&d.push({entry:{text:"",lineNumber:-1},originalIndex:-1,isSeparator:!0}),d.push({entry:c[x],originalIndex:x})}return d},[c,u,b,N,T,y]);l.useEffect(()=>{k&&o.current&&c.length>q.current&&(H.current=!0,requestAnimationFrame(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight),setTimeout(()=>{H.current=!1},50)})),q.current=c.length},[c.length,k]),l.useEffect(()=>{h&&D.current&&D.current.focus()},[h]),l.useEffect(()=>{f&&A.current&&A.current.focus()},[f]);const g=l.useCallback(t=>{if(!o.current)return;const n=t*18;o.current.scrollTop=n-100,Q(t),setTimeout(()=>Q(null),2e3)},[]);l.useEffect(()=>{if(!E)return;const t=s=>{if(s.key==="Escape"){s.preventDefault(),s.stopPropagation(),s.stopImmediatePropagation(),h?w(!1):f?S(!1):L();return}if(s.key==="/"&&!h&&!f&&(s.preventDefault(),w(!0)),s.key==="g"&&s.ctrlKey&&(s.preventDefault(),S(!0)),s.key==="End"&&s.ctrlKey&&o.current&&(o.current.scrollTop=o.current.scrollHeight),s.key==="Home"&&s.ctrlKey&&o.current&&(o.current.scrollTop=0),(s.key==="F3"||s.key==="Enter"&&h)&&r.length>0)if(s.preventDefault(),s.shiftKey){const n=(m-1+r.length)%r.length;j(n),g(r[n])}else{const n=(m+1)%r.length;j(n),g(r[n])}if(!h&&!f&&r.length>0){if(s.key==="n"&&!s.ctrlKey){s.preventDefault();const n=(m+1)%r.length;j(n),g(r[n])}else if(s.key==="N"){s.preventDefault();const n=(m-1+r.length)%r.length;j(n),g(r[n])}}!h&&!f&&o.current&&(s.key==="j"?(s.preventDefault(),o.current.scrollTop+=60,p(!1)):s.key==="k"?(s.preventDefault(),o.current.scrollTop-=60,p(!1)):s.key==="G"&&!s.ctrlKey?(s.preventDefault(),o.current.scrollTop=o.current.scrollHeight,p(!0)):s.key==="g"&&!s.ctrlKey&&(s.preventDefault(),o.current.scrollTop=0,p(!1)))};return window.addEventListener("keydown",t,{capture:!0}),()=>window.removeEventListener("keydown",t,{capture:!0})},[E,h,f,r,m,L,g]);const z=l.useCallback(()=>{const t=parseInt(M,10);!isNaN(t)&&t>0&&t<=c.length&&(g(t-1),p(!1)),S(!1),I("")},[M,c.length,g]),ce=l.useCallback(()=>{if(H.current||!o.current)return;const{scrollTop:t,scrollHeight:s,clientHeight:n}=o.current,d=s-t-n<50;!d&&k&&p(!1),d&&!k&&p(!0)},[k]),ie=l.useCallback(t=>{if(!u||!b)return t;const s=v?u:u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");try{const n=new RegExp(`(${s})`,"gi");return t.replace(n,'<mark class="search-highlight">$1</mark>')}catch{return t}},[u,b,v]),{handleMouseDown:ue,handleClick:he}=ge(L);return E?e.jsx("div",{className:"pm2-logs-modal-overlay",onMouseDown:ue,onClick:he,children:e.jsxs("div",{className:`pm2-logs-modal ${ee||""}`,children:[e.jsxs("div",{className:"pm2-logs-modal-header",children:[e.jsxs("div",{className:"header-left",children:[e.jsx("span",{className:"modal-icon",children:U}),e.jsx("span",{className:"modal-title",title:B,children:B}),F&&e.jsxs("span",{className:"streaming-indicator",title:"Live streaming",children:[e.jsx("span",{className:"pulse"}),X||a("terminal:logs.live")]}),Y]}),e.jsxs("div",{className:"header-right",children:[e.jsx("span",{className:"line-count",children:a("terminal:logs.lines",{count:c.length})}),P&&e.jsx("button",{className:"modal-close",onClick:P,title:"Minimize — dock below the terminal input",children:e.jsx(xe,{name:"arrow-down",size:14})}),e.jsx("button",{className:"modal-close",onClick:L,title:a("terminal:logs.closeEsc"),children:"×"})]})]}),e.jsxs("div",{className:"pm2-logs-modal-toolbar",children:[e.jsxs("div",{className:"toolbar-left",children:[e.jsxs("button",{className:`toolbar-btn ${h?"active":""}`,onClick:()=>w(!h),title:a("terminal:logs.searchShortcut"),children:["🔍 ",a("terminal:logs.search")]}),e.jsxs("button",{className:"toolbar-btn",onClick:()=>S(!0),title:a("terminal:logs.goToLineShortcut"),children:["⏬ ",a("terminal:logs.goToLine")]}),Z,e.jsxs("button",{className:`toolbar-btn ${R?"active":""}`,onClick:()=>te(!R),title:a("terminal:logs.toggleWrap"),children:["↩ ",a("terminal:logs.wrap")]}),e.jsxs("button",{className:`toolbar-btn ${k?"active":""}`,onClick:()=>p(!k),title:a("terminal:logs.autoScrollToBottom"),children:["↓ ",a("terminal:logs.auto")]})]}),e.jsx("div",{className:"toolbar-right",children:e.jsxs("button",{className:"toolbar-btn danger",onClick:J,title:a("terminal:logs.clear"),children:["🗑 ",a("terminal:logs.clear")]})})]}),h&&e.jsxs("div",{className:"pm2-logs-search-bar",children:[e.jsx("input",{ref:D,type:"text",placeholder:a(v?"terminal:logs.regexPlaceholder":"terminal:logs.searchPlaceholder"),value:u,onChange:t=>{$(t.target.value),j(0)},onKeyDown:t=>{t.key==="Escape"&&(w(!1),$(""),C(null))}}),e.jsx("button",{className:`toolbar-btn small ${v?"active":""}`,onClick:()=>ne(!v),title:"Toggle regex mode",children:".*"}),e.jsx("button",{className:`toolbar-btn small ${y?"active":""}`,onClick:()=>ae(!y),title:y?"Show all lines (highlight matches)":"Show only context around matches",children:y?"All":"Ctx"}),e.jsxs("div",{className:`context-control ${y?"hidden":""}`,title:"Lines of context around matches",children:[e.jsx("label",{children:"±"}),e.jsx("input",{type:"number",min:"0",max:"100",value:T,onChange:t=>re(Math.max(0,parseInt(t.target.value)||0)),className:"context-input"})]}),e.jsx("button",{className:"toolbar-btn small",onClick:()=>{if(r.length===0)return;const t=(m-1+r.length)%r.length;j(t),g(r[t])},disabled:r.length===0,title:"Previous match (Shift+F3)",children:"▲"}),e.jsx("button",{className:"toolbar-btn small",onClick:()=>{if(r.length===0)return;const t=(m+1)%r.length;j(t),g(r[t])},disabled:r.length===0,title:"Next match (F3)",children:"▼"}),u&&e.jsx("span",{className:"match-count",children:_?e.jsx("span",{className:"regex-error",title:_,children:a("terminal:logs.invalidRegex")}):r.length>0?`${m+1}/${r.length}`:a("terminal:logs.noMatches")}),e.jsx("button",{className:"search-close",onClick:()=>{w(!1),$(""),C(null)},children:"×"})]}),f&&e.jsxs("div",{className:"pm2-logs-goto-line",children:[e.jsxs("label",{children:[a("terminal:logs.goToLineLabel"),":"]}),e.jsx("input",{ref:A,type:"number",min:"1",max:c.length,placeholder:`1-${c.length}`,value:M,onChange:t=>I(t.target.value),onKeyDown:t=>{t.key==="Enter"?z():t.key==="Escape"&&(S(!1),I(""))}}),e.jsx("button",{onClick:z,children:a("terminal:logs.go")}),e.jsx("button",{onClick:()=>S(!1),children:a("common:buttons.cancel")})]}),e.jsx("div",{ref:o,className:`pm2-logs-content ${R?"wrap":"nowrap"}`,onScroll:ce,children:c.length===0?e.jsx("div",{className:"logs-empty",children:W||F?e.jsxs("div",{className:"logs-loading",children:[e.jsx("span",{className:"logs-loading-spinner","aria-hidden":"true"}),e.jsx("span",{children:V||a(W?"terminal:logs.loadingLogs":"terminal:logs.waitingForLogs")})]}):e.jsx("span",{children:V||a("terminal:logs.noLogs")})}):e.jsx("div",{className:"logs-lines",children:oe.map((t,s)=>{if("isSeparator"in t&&t.isSeparator)return e.jsxs("div",{className:"log-separator",children:[e.jsx("span",{className:"separator-line"}),e.jsx("span",{className:"separator-label",children:"…"}),e.jsx("span",{className:"separator-line"})]},`sep-${s}`);const{entry:n,originalIndex:d}=t,i=u&&N.includes(d);return e.jsxs("div",{className:`log-line ${se===d?"highlighted":""} ${r[m]===d?"current-match":""} ${i?"match-line":""} ${n.isError?"error-line":""}`,children:[e.jsx("span",{className:"line-number",children:n.lineNumber}),n.sourceLabel&&e.jsxs("span",{className:"boss-log-source",style:{color:n.sourceColor},children:["[",n.sourceLabel,"]"]}),e.jsx("span",{className:"line-content",dangerouslySetInnerHTML:{__html:ie(fe(n.text))}})]},d)})})}),e.jsxs("div",{className:"pm2-logs-modal-footer",children:[e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"j"}),"/",e.jsx("kbd",{children:"k"})," Scroll"]}),e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"g"}),"/",e.jsx("kbd",{children:"G"})," Top/Bottom"]}),e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"/"})," Search"]}),e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"n"}),"/",e.jsx("kbd",{children:"N"})," Next/Prev match"]}),e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"Ctrl+G"})," Go to line"]}),e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"Esc"})," Close"]}),O]})]})}):null}export{je as L};
|