tide-commander 1.82.0 → 1.83.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/dist/assets/{BossLogsModal-c_-m-65A.js → BossLogsModal-Bgg8MqNZ.js} +1 -1
- package/dist/assets/{BossSpawnModal-xoclsIKS.js → BossSpawnModal-SQNEPxH1.js} +1 -1
- package/dist/assets/{ControlsModal-DvbJLRQI.js → ControlsModal-ImEPi76l.js} +1 -1
- package/dist/assets/{DockerLogsModal-BEwlDjvB.js → DockerLogsModal-Cs3jjehG.js} +1 -1
- package/dist/assets/{EmbeddedEditor-Ce0A9MPZ.js → EmbeddedEditor-Cg3lq_Cv.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-CxPmSlXq.js → GmailOAuthSetup-1Gh5-yZt.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-C5XDtkWo.js → GoogleOAuthSetup-DmXPQyOR.js} +1 -1
- package/dist/assets/{IframeModal-B30rL5T9.js → IframeModal-BEItm7bf.js} +1 -1
- package/dist/assets/{IntegrationsPanel-DOiXFhKJ.js → IntegrationsPanel-epI8eaV_.js} +2 -2
- package/dist/assets/{LogViewerModal-BDDX94V7.js → LogViewerModal-B4ryb52t.js} +1 -1
- package/dist/assets/{MonitoringModal-Bb-ofaiK.js → MonitoringModal-CzUjqD5Y.js} +1 -1
- package/dist/assets/{PM2LogsModal-BbwXHEqR.js → PM2LogsModal-Ex9G2Mly.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-DDndv4rZ.js → RestoreArchivedAreaModal-DIsamY35.js} +1 -1
- package/dist/assets/{Scene2DCanvas-D0mV81Bm.js → Scene2DCanvas-B5VdT-R2.js} +1 -1
- package/dist/assets/{SceneManager-BT7vcVki.js → SceneManager-CgkTa3Uf.js} +1 -1
- package/dist/assets/{SkillsPanel-Db_tfT8F.js → SkillsPanel-DXxAlZbz.js} +1 -1
- package/dist/assets/{SpawnModal-BgBB9Nre.js → SpawnModal-_1Af5rTQ.js} +1 -1
- package/dist/assets/{SubordinateAssignmentModal-CsNUXzAa.js → SubordinateAssignmentModal-CZ1p4KxH.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-DLjvwFj_.js → TriggerManagerPanel-DnOvAQq6.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-CtWq2X20.js → WorkflowEditorPanel-Dr896thl.js} +1 -1
- package/dist/assets/{index-CeGEneIm.js → index-C70mj1bd.js} +1 -1
- package/dist/assets/{index-dz45uNT2.js → index-CgPa_6TH.js} +1 -1
- package/dist/assets/{index-BKRYCHvF.js → index-CkhtIUBY.js} +1 -1
- package/dist/assets/{index-DjcUPqW1.js → index-CoUtzDXD.js} +1 -1
- package/dist/assets/{index-BWFXqJh3.js → index-DCHHa29_.js} +1 -1
- package/dist/assets/{index-Bx7MluX4.js → index-DVqDWfDB.js} +2 -2
- package/dist/assets/{index-Blb2sMy-.js → index-DvRrAd9Y.js} +1 -1
- package/dist/assets/{index-kLrB6kGv.js → index-OYmdvKdM.js} +3 -3
- package/dist/assets/{index-B-kiGa62.js → index-ave_XgRW.js} +1 -1
- package/dist/assets/{main-C0wLbrjb.js → main-CHfGSVnw.js} +94 -93
- package/dist/assets/main-DmmvYoEs.css +1 -0
- package/dist/assets/{web-CQeInubf.js → web-D1aYcbd6.js} +1 -1
- package/dist/assets/{web-Dpd6fLBM.js → web-rv0WAVTk.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/src/packages/server/claude/runner/internal-events.js +6 -3
- package/dist/src/packages/server/claude/runner/tmux-helper.js +10 -0
- package/dist/src/packages/server/claude/runner/watchdog.js +14 -0
- package/dist/src/packages/server/claude/runner.js +35 -13
- package/dist/src/packages/server/claude/session-loader.js +240 -0
- package/dist/src/packages/server/routes/agents.js +4 -0
- package/dist/src/packages/server/routes/index.js +2 -0
- package/dist/src/packages/server/routes/sessions.js +93 -0
- package/dist/src/packages/server/services/runtime-command-execution.js +13 -0
- package/dist/src/packages/server/services/runtime-service.js +7 -0
- package/dist/src/packages/server/utils/index.js +1 -0
- package/dist/src/packages/server/utils/log-context.js +10 -0
- package/dist/src/packages/server/utils/logger.js +6 -1
- package/dist/src/packages/server/websocket/handlers/agent-handler.js +17 -5
- package/package.json +1 -1
- package/dist/assets/main-DrNeyjdE.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,aP as Pe,aQ as ze,j as e,I as L,u as se,aR as Ve,_ as qe,f as De,s as k,aS as Ge,k as He,l as re,aT as W,aU as Ye,aI as Je,aV as Ze,C as fe,aW as ae,aF as Ne,aX as Xe,aY as Qe,aZ as es,a_ as ss,a$ as Me,b0 as as,b1 as ts,b2 as _e,b3 as ns,b4 as os,b5 as is,b6 as ls,b7 as cs,b8 as rs,b9 as ds,aB as ms,E as us,S as ye,ba as ps,bb as gs,aD as hs,bc as Le,G as Ae,aM as fs,bd as Fe,be as xs}from"./main-C0wLbrjb.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const $e="deivid11/tide-commander",bs=`https://api.github.com/repos/${$e}/releases/latest`,js=`https://api.github.com/repos/${$e}/releases?per_page=3`,vs=3600*1e3,Ue="app_update_dismissed_version",Re="1.82.0";function ys(){var y,S;const[s,i]=c.useState({isChecking:!1,updateAvailable:!1,updateInfo:null,recentReleases:[],error:null,currentVersion:Re}),a=((S=(y=Pe)==null?void 0:y.getPlatform)==null?void 0:S.call(y))==="android"||!1,o=u=>u.replace(/^v/,"").split(".").map(p=>parseInt(p,10)||0),m=(u,h)=>{const p=o(u),N=o(h),x=Math.max(p.length,N.length);for(let r=0;r<x;r++){const F=p[r]||0,R=N[r]||0;if(F>R)return 1;if(F<R)return-1}return 0},f=async u=>{var p,N;if(Pe&&ze&&((N=(p=Pe).isNativePlatform)==null?void 0:N.call(p))===!0){const x=await ze.get({url:u,headers:{Accept:"application/vnd.github.v3+json"}});return{data:x.data,status:x.status}}else{const x=await fetch(u,{headers:{Accept:"application/vnd.github.v3+json"}});return x.ok?{data:await x.json(),status:x.status}:{data:null,status:x.status}}},d=c.useCallback(async(u=!1)=>{i(h=>({...h,isChecking:!0,error:null}));try{const[h,p]=await Promise.all([f(bs),f(js)]);if(h.status!==200)throw new Error(`GitHub API error: ${h.status}`);const N=h.data,x=N.tag_name;let r=[];p.status===200&&p.data&&(r=p.data.map(C=>({version:C.tag_name,name:C.name,publishedAt:C.published_at,releaseUrl:C.html_url})));const F=localStorage.getItem(Ue);if(!u&&F===x)return i(C=>({...C,isChecking:!1,updateAvailable:!1,recentReleases:r})),null;if(!(m(x,Re)>0))return i(C=>({...C,isChecking:!1,updateAvailable:!1,recentReleases:r})),null;const $=N.assets.find(C=>C.name.endsWith(".apk")&&C.content_type==="application/vnd.android.package-archive"),v={version:x,name:N.name,changelog:N.body,releaseUrl:N.html_url,apkUrl:($==null?void 0:$.browser_download_url)||null,apkSize:($==null?void 0:$.size)||null,publishedAt:N.published_at};return i(C=>({...C,isChecking:!1,updateAvailable:!0,updateInfo:v,recentReleases:r})),v}catch(h){const p=h instanceof Error?h.message:"Failed to check for updates";return i(N=>({...N,isChecking:!1,error:p})),null}},[]),n=c.useCallback(async()=>{var u,h,p;if(!((u=s.updateInfo)!=null&&u.apkUrl)){(h=s.updateInfo)!=null&&h.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}if(!a){(p=s.updateInfo)!=null&&p.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}try{window.open(s.updateInfo.apkUrl,"_system"),i(N=>({...N,error:null}))}catch(N){const x=N instanceof Error?N.message:"Failed to open download";i(r=>({...r,error:x}))}},[s.updateInfo,a]),g=c.useCallback(()=>{s.updateInfo&&localStorage.setItem(Ue,s.updateInfo.version),i(u=>({...u,updateAvailable:!1,updateInfo:null}))},[s.updateInfo]),T=c.useCallback(()=>{var u;(u=s.updateInfo)!=null&&u.releaseUrl?window.open(s.updateInfo.releaseUrl,"_blank"):window.open(`https://github.com/${$e}/releases`,"_blank")},[s.updateInfo]);return c.useEffect(()=>{if(!a)return;const u=setTimeout(()=>{d()},5e3),h=setInterval(()=>{d()},vs);return()=>{clearTimeout(u),clearInterval(h)}},[a,d]),{...s,isAndroid:a,checkForUpdate:d,downloadAndInstall:n,dismissUpdate:g,openReleasePage:T}}const We="tide-toolbox-collapse";function Ns(s,i){try{const a=localStorage.getItem(`${We}-${s}`);if(a!==null)return a==="true"}catch{}return i}function ws(s,i){try{localStorage.setItem(`${We}-${s}`,String(i))}catch{}}function U({title:s,storageKey:i,defaultOpen:a=!1,forceOpen:o=!1,children:m,headerExtra:f}){const[d,n]=c.useState(()=>i?Ns(i,a):a),g=()=>{const y=!d;n(y),i&&ws(i,y)},T=o||d;return e.jsxs("div",{className:`collapsible-section ${T?"open":"collapsed"}`,children:[e.jsxs("button",{className:"collapsible-header",onClick:g,children:[e.jsx("span",{className:"collapsible-title",children:s}),e.jsxs("span",{className:"collapsible-header-right",children:[f,e.jsx("span",{className:"collapsible-arrow",children:e.jsx(L,{name:T?"caret-down":"caret-right",size:10})})]})]}),T&&e.jsx("div",{className:"collapsible-content",children:m})]})}function ks({area:s,isSelected:i,onClick:a,onDelete:o}){const{t:m}=se(["config","common"]),f=s.assignedAgentIds.length,d=s.type==="rectangle"?m("config:areas.rect"):m("config:areas.circle");return e.jsxs("div",{className:`area-item ${i?"selected":""}`,onClick:a,children:[e.jsx("div",{className:"area-color-dot",style:{backgroundColor:s.color}}),e.jsxs("div",{className:"area-info",children:[e.jsx("div",{className:"area-name",children:s.name}),e.jsxs("div",{className:"area-meta",children:[d," ",f>0&&`• ${f} ${f>1?m("common:labels.agents").toLowerCase():m("common:labels.agent").toLowerCase()}`]})]}),e.jsx("button",{className:"area-delete-btn",onClick:o,title:m("config:areas.deleteArea"),children:"×"})]})}function Ss({building:s,isSelected:i,onClick:a,onEdit:o}){var n;const{t:m}=se(["config"]),f=((n=s.pm2Status)==null?void 0:n.ports)||[],d=(g,T)=>{g.stopPropagation(),window.open(`http://${window.location.hostname}:${T}`,"_blank")};return e.jsxs("div",{className:`building-item ${i?"selected":""}`,onClick:a,children:[e.jsx("div",{className:"building-status-dot",style:{backgroundColor:Ve[s.status]},title:s.status}),e.jsx("div",{className:"building-icon",children:e.jsx(L,{name:qe(s.type),size:16})}),e.jsxs("div",{className:"building-info",children:[e.jsx("div",{className:"building-name",children:s.name}),e.jsxs("div",{className:"building-meta",children:[s.type,f.length>0&&e.jsx("span",{className:"building-ports",children:f.map(g=>e.jsxs("a",{href:`http://${window.location.hostname}:${g}`,className:"building-port-link",onClick:T=>d(T,g),title:`Open :${g}`,children:[":",g]},g))})]})]}),e.jsx("button",{className:"building-edit-btn",onClick:g=>{g.stopPropagation(),o()},title:m("config:buildings.editBuilding"),children:e.jsx(L,{name:"gear",size:14})})]})}function Cs({building:s,onClose:i,onOpenModal:a}){var T,y,S,u,h,p,N,x;const{t:o}=se(["config","common"]),{buildingLogs:m}=De(),f=k.getBuildingLogs(s.id),d=Ge[s.style||"server-rack"],n=r=>{k.sendBuildingCommand(s.id,r)},g=r=>{window.open(r,"_blank")};return e.jsxs("div",{className:"building-editor",children:[e.jsxs("div",{className:"building-editor-header",children:[e.jsxs("div",{className:"building-editor-title-row",children:[e.jsx("span",{className:"building-editor-icon",children:e.jsx(L,{name:qe(s.type),size:18})}),e.jsx("span",{className:"building-editor-title",children:s.name}),e.jsx("span",{className:"building-editor-status",style:{backgroundColor:Ve[s.status]},children:s.status})]}),e.jsx("button",{className:"building-editor-close",onClick:i,children:"×"})]}),e.jsx("div",{className:"building-editor-section",children:e.jsxs("div",{className:"building-editor-info-grid",children:[e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("common:labels.type")}),e.jsx("span",{className:"building-editor-info-value",children:s.type})]}),e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.style")}),e.jsx("span",{className:"building-editor-info-value",children:d.label})]}),s.cwd&&e.jsxs("div",{className:"building-editor-info-item building-editor-info-wide",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.directory")}),e.jsx("span",{className:"building-editor-info-value building-editor-cwd",title:s.cwd,children:s.cwd.split("/").pop()||s.cwd})]})]})}),s.type==="server"&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.actions")}),e.jsxs("div",{className:"building-editor-actions",children:[e.jsxs("button",{className:"building-editor-action-btn start",onClick:()=>n("start"),disabled:!((T=s.commands)!=null&&T.start)||s.status==="running",title:((y=s.commands)==null?void 0:y.start)||o("config:buildings.noStartCommand"),children:[e.jsx(L,{name:"play",size:12})," ",o("common:buttons.start")]}),e.jsxs("button",{className:"building-editor-action-btn stop",onClick:()=>n("stop"),disabled:!((S=s.commands)!=null&&S.stop)||s.status==="stopped",title:((u=s.commands)==null?void 0:u.stop)||o("config:buildings.noStopCommand"),children:[e.jsx(L,{name:"stop",size:12,weight:"fill"})," ",o("common:buttons.stop")]}),e.jsxs("button",{className:"building-editor-action-btn restart",onClick:()=>n("restart"),disabled:!((h=s.commands)!=null&&h.restart),title:((p=s.commands)==null?void 0:p.restart)||o("config:buildings.noRestartCommand"),children:[e.jsx(L,{name:"refresh",size:12})," ",o("common:buttons.retry")]}),e.jsxs("button",{className:"building-editor-action-btn health",onClick:()=>n("healthCheck"),disabled:!((N=s.commands)!=null&&N.healthCheck),title:((x=s.commands)==null?void 0:x.healthCheck)||o("config:buildings.noHealthCheck"),children:[e.jsx(L,{name:"heart",size:12})," Health"]})]})]}),s.urls&&s.urls.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.links")}),e.jsx("div",{className:"building-editor-links",children:s.urls.map((r,F)=>e.jsxs("button",{className:"building-editor-link",onClick:()=>g(r.url),title:r.url,children:[e.jsx(L,{name:"link",size:12})," ",r.label||r.url]},F))})]}),f.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsxs("div",{className:"building-editor-section-title",children:[o("config:buildings.recentLogs"),e.jsx("button",{className:"building-editor-clear-logs",onClick:()=>k.clearBuildingLogs(s.id),title:o("common:buttons.clear"),children:o("common:buttons.clear")})]}),e.jsx("div",{className:"building-editor-logs",children:f.slice(-5).map((r,F)=>e.jsx("div",{className:"building-editor-log-entry",children:r},F))})]}),e.jsx("div",{className:"building-editor-footer",children:e.jsxs("button",{className:"building-editor-edit-btn",onClick:a,children:[e.jsx(L,{name:"gear",size:12})," ",o("config:buildings.fullSettings")]})})]})}async function As(s,i){const a=W(),o=await fetch(re(`/api/areas/${s}/logo`),{method:"POST",headers:{"Content-Type":i.type||"image/png","X-Filename":encodeURIComponent(i.name),...a?{Authorization:`Bearer ${a}`}:{}},body:i});if(!o.ok){const m=await o.json().catch(()=>({error:o.statusText}));throw new Error(m.error||`Upload failed: ${o.statusText}`)}return o.json()}async function Ts(s){const i=W(),a=await fetch(re(`/api/areas/${s}/logo`),{method:"DELETE",headers:{...i?{Authorization:`Bearer ${i}`}:{}}});if(!a.ok)throw new Error(`Failed to delete logo: ${a.statusText}`)}function Is(s){return He(re(`/api/areas/logos/${s}`))}const Es=[{key:"center",labelKey:"posCenter"},{key:"top-left",labelKey:"posTopLeft"},{key:"top-right",labelKey:"posTopRight"},{key:"bottom-left",labelKey:"posBottomLeft"},{key:"bottom-right",labelKey:"posBottomRight"}];function Ps({area:s,onClose:i,onOpenFolder:a}){var ne;const{t:o}=se(["config","common"]),[m,f]=c.useState(s.name),[d,n]=c.useState(s.prompt||""),[g,T]=c.useState(!1),[y,S]=c.useState(""),[u,h]=c.useState(!1),p=c.useRef(null);c.useEffect(()=>{f(s.name)},[s.id,s.name]),c.useEffect(()=>{n(s.prompt||"")},[s.id,s.prompt]);const N=b=>{const E=b.target.value;f(E),k.updateArea(s.id,{name:E})},x=b=>{k.updateArea(s.id,{color:b})},r=b=>{const E=b.target.value;n(E),k.updateArea(s.id,{prompt:E})},F=()=>{y.trim()&&(k.addDirectoryToArea(s.id,y.trim()),S(""),T(!1))},R=(b,E)=>{E.stopPropagation(),k.removeDirectoryFromArea(s.id,b)},$=()=>{k.bringAreaToFront(s.id)},v=()=>{k.sendAreaToBack(s.id)},C=c.useCallback(()=>{let b=2,E=2;s.type==="rectangle"&&s.width&&s.height?(b=s.width,E=s.height):s.type==="circle"&&s.radius&&(b=s.radius*1.414,E=s.radius*1.414);const z=Math.min(b,E)*.4;return{width:Math.round(z*10)/10,height:Math.round(z*10)/10}},[s.type,s.width,s.height,s.radius]),M=async b=>{var z;const E=(z=b.target.files)==null?void 0:z[0];if(E){h(!0);try{const j=await As(s.id,E),P=C();k.updateArea(s.id,{logo:{filename:j.filename,position:"center",width:P.width,height:P.height,keepAspectRatio:!0,opacity:.8}})}catch(j){console.error("Failed to upload logo:",j)}finally{h(!1),p.current&&(p.current.value="")}}},K=async()=>{try{await Ts(s.id),k.updateArea(s.id,{logo:void 0})}catch(b){console.error("Failed to remove logo:",b)}},G=b=>{s.logo&&k.updateArea(s.id,{logo:{...s.logo,position:b}})},V=b=>{if(!s.logo)return;const E=parseFloat(b.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.width>0){const z=s.logo.height/s.logo.width;k.updateArea(s.id,{logo:{...s.logo,width:E,height:Math.round(E*z*10)/10}})}else k.updateArea(s.id,{logo:{...s.logo,width:E}})},O=b=>{if(!s.logo)return;const E=parseFloat(b.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.height>0){const z=s.logo.width/s.logo.height;k.updateArea(s.id,{logo:{...s.logo,height:E,width:Math.round(E*z*10)/10}})}else k.updateArea(s.id,{logo:{...s.logo,height:E}})},q=()=>{s.logo&&k.updateArea(s.id,{logo:{...s.logo,keepAspectRatio:!s.logo.keepAspectRatio}})},ee=b=>{s.logo&&k.updateArea(s.id,{logo:{...s.logo,opacity:parseFloat(b.target.value)}})};return e.jsxs("div",{className:"area-editor",children:[e.jsxs("div",{className:"area-editor-header",children:[e.jsx("span",{className:"area-editor-title",children:o("config:areas.editArea")}),e.jsx("button",{className:"area-editor-close",onClick:i,children:"×"})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("common:labels.name")}),e.jsx("input",{type:"text",className:"area-editor-input",value:m,onChange:N,placeholder:o("config:areas.areaName")})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.color")}),e.jsx("div",{className:"color-picker-row",children:Ye.map(b=>e.jsx("div",{className:`color-swatch ${s.color===b?"selected":""}`,style:{backgroundColor:b},onClick:()=>x(b)},b))})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.layer")}),e.jsxs("div",{className:"area-layer-buttons",children:[e.jsxs("button",{className:"area-layer-btn",onClick:$,title:o("config:areas.bringToFront"),children:[e.jsx(L,{name:"arrow-up",size:12})," ",o("config:areas.front")]}),e.jsxs("button",{className:"area-layer-btn",onClick:v,title:o("config:areas.sendToBack"),children:[e.jsx(L,{name:"arrow-down",size:12})," ",o("config:areas.back")]})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.logo")}),e.jsxs("div",{className:"area-logo-section",children:[(ne=s.logo)!=null&&ne.filename?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"area-logo-preview",children:[e.jsx("img",{src:Is(s.logo.filename),alt:"Logo",className:"area-logo-thumbnail"}),e.jsx("button",{className:"area-logo-remove-btn",onClick:K,children:o("config:areas.removeLogo")}),e.jsx("button",{className:"area-logo-replace-btn",onClick:()=>{var b;return(b=p.current)==null?void 0:b.click()},disabled:u,children:u?"...":e.jsx(L,{name:"refresh",size:12})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoPosition")}),e.jsx("div",{className:"area-logo-position-row",children:Es.map(({key:b,labelKey:E})=>{var z;return e.jsx("button",{className:`area-logo-pos-btn ${((z=s.logo)==null?void 0:z.position)===b?"active":""}`,onClick:()=>G(b),children:o(`config:areas.${E}`)},b)})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoSize")}),e.jsxs("div",{className:"area-logo-size-row",children:[e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoWidth")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.width,onChange:V,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoHeight")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.height,onChange:O,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-aspect-label",title:o("config:areas.keepAspectRatio"),children:[e.jsx("input",{type:"checkbox",checked:s.logo.keepAspectRatio,onChange:q}),o("config:areas.keepAspectRatio")]})]})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoOpacity")}),e.jsxs("div",{className:"area-logo-opacity-row",children:[e.jsx("input",{type:"range",min:0,max:1,step:.05,value:s.logo.opacity??.8,onChange:ee,className:"area-logo-opacity-slider"}),e.jsxs("span",{className:"area-logo-opacity-value",children:[Math.round((s.logo.opacity??.8)*100),"%"]})]})]})]}):e.jsx("button",{className:"area-logo-upload-btn",onClick:()=>{var b;return(b=p.current)==null?void 0:b.click()},disabled:u,children:u?"...":o("config:areas.uploadLogo")}),e.jsx("input",{ref:p,type:"file",accept:"image/*",style:{display:"none"},onChange:M})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.folders",{count:s.directories.length})}),e.jsxs("div",{className:"area-folders-list",children:[s.directories.map(b=>e.jsxs("div",{className:"area-folder-item",title:b,children:[e.jsx("span",{className:"area-folder-icon clickable",onClick:()=>a==null?void 0:a(s.id),title:o("config:areas.openFolder"),children:e.jsx(L,{name:"folder",size:14})}),e.jsx("span",{className:"area-folder-path",children:b.split("/").pop()||b}),e.jsx("button",{className:"area-folder-remove",onClick:E=>R(b,E),title:o("config:areas.removeFolder"),children:"×"})]},b)),g?e.jsxs("div",{className:"area-add-folder-inline",children:[e.jsx(Je,{value:y,onChange:S,onSubmit:F,placeholder:o("config:areas.folderPlaceholder"),className:"area-add-folder-input",directoriesOnly:!0,autoFocus:!0}),e.jsx("button",{className:"area-add-folder-confirm",onClick:F,children:"+"})]}):e.jsx("button",{className:"area-add-folder-btn",onClick:()=>T(!0),children:o("config:areas.addFolder")})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.prompt","Prompt")}),e.jsx("textarea",{className:"area-editor-input",value:d,onChange:r,placeholder:o("config:areas.promptPlaceholder","System prompt for agents in this area..."),rows:4,style:{resize:"vertical",fontFamily:"monospace",fontSize:12}}),e.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4},children:o("config:areas.promptHint","This prompt is injected into agents assigned to this area. Takes effect on next context refresh.")})]}),s.assignedAgentIds.length>0&&e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.assignedAgents",{count:s.assignedAgentIds.length})}),e.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:o("config:areas.rightClickUnassign")})]})]})}function Ls(){const{t:s}=se(["config","common"]),i=Ze(),[a,o]=c.useState(!1),[m,f]=c.useState(null),[d,n]=c.useState({name:"",key:"",value:"",description:""}),[g,T]=c.useState(null),y=()=>{o(!0),f(null),n({name:"",key:"",value:"",description:""})},S=r=>{f(r.id),o(!1),n({name:r.name,key:r.key,value:r.value,description:r.description||""})},u=()=>{o(!1),f(null),n({name:"",key:"",value:"",description:""})},h=()=>{!d.name.trim()||!d.key.trim()||(m?k.updateSecret(m,{name:d.name.trim(),key:d.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:d.value,description:d.description.trim()||void 0}):k.createSecret({name:d.name.trim(),key:d.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:d.value,description:d.description.trim()||void 0}),u())},p=r=>{T(r)},N=()=>{g&&(k.deleteSecret(g),m===g&&u())},x=r=>{navigator.clipboard.writeText(`{{${r}}}`)};return e.jsxs("div",{className:"secrets-section",children:[e.jsx("div",{className:"secrets-description",children:s("config:secrets.description",{placeholder:"{{KEY}}"})}),e.jsx("div",{className:"secrets-list",children:i.length===0&&!a?e.jsx("div",{className:"secrets-empty",children:s("config:secrets.noSecrets")}):i.map(r=>e.jsxs("div",{className:`secret-item ${m===r.id?"editing":""}`,children:[e.jsxs("div",{className:"secret-item-header",children:[e.jsxs("div",{className:"secret-item-info",children:[e.jsx("span",{className:"secret-item-name",children:r.name}),e.jsx("code",{className:"secret-item-key",onClick:()=>x(r.key),title:s("config:secrets.copyPlaceholder"),children:`{{${r.key}}}`})]}),e.jsxs("div",{className:"secret-item-actions",children:[e.jsx("button",{className:"secret-item-btn edit",onClick:()=>S(r),title:s("common:buttons.edit"),children:e.jsx(L,{name:"edit",size:12})}),e.jsx("button",{className:"secret-item-btn delete",onClick:()=>p(r.id),title:s("common:buttons.delete"),children:"×"})]})]}),r.description&&e.jsx("div",{className:"secret-item-description",children:r.description})]},r.id))}),(a||m)&&e.jsxs("div",{className:"secret-form",children:[e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.name")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.namePlaceholder"),value:d.name,onChange:r=>n({...d,name:r.target.value}),autoFocus:!0})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:"Key"}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.keyPlaceholder"),value:d.key,onChange:r=>n({...d,key:r.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")})}),e.jsx("span",{className:"secret-form-hint",children:s("config:secrets.usedAs",{placeholder:`{{${d.key||"KEY"}}}`})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("config:secrets.secretValue")}),e.jsx("input",{type:"password",className:"secret-form-input",placeholder:s("config:secrets.valuePlaceholder"),value:d.value,onChange:r=>n({...d,value:r.target.value})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.description")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.descriptionPlaceholder"),value:d.description,onChange:r=>n({...d,description:r.target.value})})]}),e.jsxs("div",{className:"secret-form-actions",children:[e.jsx("button",{className:"secret-form-btn cancel",onClick:u,children:s("common:buttons.cancel")}),e.jsx("button",{className:"secret-form-btn save",onClick:h,disabled:!d.name.trim()||!d.key.trim(),children:s(m?"config:secrets.update":"common:buttons.add")})]})]}),!a&&!m&&e.jsx("button",{className:"secrets-add-btn",onClick:y,children:s("config:secrets.addSecret")}),e.jsx(fe,{isOpen:g!==null,title:s("common:buttons.delete"),message:s("config:secrets.deleteConfirm"),confirmLabel:s("common:buttons.delete"),cancelLabel:s("common:buttons.cancel"),variant:"danger",onConfirm:N,onClose:()=>T(null)})]})}async function Fs(){const s=W(),i=await fetch(`${ae()}/api/agents/system-settings/prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch system prompt: ${i.statusText}`);return(await i.json()).prompt||""}async function Os(s){const i=W(),a=await fetch(`${ae()}/api/agents/system-settings/prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({prompt:s})});if(!a.ok)throw new Error(`Failed to update system prompt: ${a.statusText}`)}async function Ds(){const s=W(),i=await fetch(`${ae()}/api/agents/system-settings/prompt`,{method:"DELETE",headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to clear system prompt: ${i.statusText}`)}async function $s(){const s=W(),i=await fetch(`${ae()}/api/agents/system-settings/echo-prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch echo prompt setting: ${i.statusText}`);return(await i.json()).enabled||!1}async function zs(s){const i=W(),a=await fetch(`${ae()}/api/agents/system-settings/echo-prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!a.ok)throw new Error(`Failed to update echo prompt setting: ${a.statusText}`)}async function _s(){const s=W(),i=await fetch(`${ae()}/api/agents/system-settings/codex-binary`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch codex binary path: ${i.statusText}`);return(await i.json()).path||""}async function Us(s){const i=W(),a=await fetch(`${ae()}/api/agents/system-settings/codex-binary`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({path:s})});if(!a.ok)throw new Error(`Failed to update codex binary path: ${a.statusText}`)}async function Rs(){const s=W(),i=await fetch(`${ae()}/api/agents/system-settings/tmux-mode`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch tmux mode setting: ${i.statusText}`);return(await i.json()).enabled||!1}async function Bs(s){const i=W(),a=await fetch(`${ae()}/api/agents/system-settings/tmux-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!a.ok)throw new Error(`Failed to update tmux mode setting: ${a.statusText}`)}async function Ks(){const s=W(),i=await fetch(`${ae()}/api/agents/system-settings/backup`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch backup status: ${i.statusText}`);return i.json()}async function Vs(s){const i=W(),a=await fetch(`${ae()}/api/agents/system-settings/backup`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.error||`Failed to update backup setting: ${a.statusText}`)}return a.json()}function qs({checked:s,onChange:i,disabled:a}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,disabled:a,onChange:o=>i(o.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function Ms(){const{t:s}=se(["config","common"]),[i,a]=c.useState([]),[o,m]=c.useState(new Set),[f,d]=c.useState(new Set),[n,g]=c.useState(!1),[T,y]=c.useState(!1),[S,u]=c.useState(null),[h,p]=c.useState(null),[N,x]=c.useState(null),[r,F]=c.useState(null),[R,$]=c.useState(!1),[v,C]=c.useState(null);c.useEffect(()=>{Ne(re("/api/config/categories")).then(j=>j.json()).then(j=>{const P=Array.isArray(j)?j:[];a(P),m(new Set(P.map(D=>D.id)))}).catch(j=>console.error("Failed to fetch config categories:",j))},[]),c.useEffect(()=>{Ks().then(F).catch(j=>{console.error("Failed to fetch backup status:",j),C(j.message||"Failed to fetch backup status")})},[]);const M=async j=>{if(!R){$(!0),C(null);try{const P=await Vs(j);F(P)}catch(P){C(P.message||"Failed to update backup setting")}finally{$(!1)}}},K=j=>{m(P=>{const D=new Set(P);return D.has(j)?D.delete(j):D.add(j),D})},G=j=>{d(P=>{const D=new Set(P);return D.has(j)?D.delete(j):D.add(j),D})},V=()=>m(new Set(i.map(j=>j.id))),O=()=>m(new Set),q=()=>{h&&d(new Set(h.categories.map(j=>j.id)))},ee=()=>d(new Set),ne=async()=>{var j;if(o.size!==0){g(!0),x(null);try{const P=Array.from(o).join(","),D=await Ne(re(`/api/config/export?categories=${P}`));if(!D.ok)throw new Error("Export failed");const Y=await D.blob(),J=window.URL.createObjectURL(Y),Z=document.createElement("a");Z.href=J;const H=D.headers.get("Content-Disposition"),xe=((j=H==null?void 0:H.match(/filename="(.+)"/))==null?void 0:j[1])||"tide-commander-config.zip";Z.download=xe,document.body.appendChild(Z),Z.click(),document.body.removeChild(Z),window.URL.revokeObjectURL(J),x({type:"success",text:s("config:data.exportSuccess")})}catch(P){x({type:"error",text:P.message||"Export failed"})}finally{g(!1)}}},b=async j=>{var D;const P=(D=j.target.files)==null?void 0:D[0];if(P){u(P),x(null),p(null),d(new Set);try{const Y=await Ne(re("/api/config/preview"),{method:"POST",headers:{"Content-Type":"application/zip"},body:await P.arrayBuffer()});if(!Y.ok){const H=await Y.json();throw new Error(H.error||"Failed to preview config file")}const J=await Y.json(),Z=Array.isArray(J.categories)?J.categories:[];p({...J,categories:Z}),d(new Set(Z.map(H=>H.id)))}catch(Y){x({type:"error",text:Y.message||"Failed to read config file"}),u(null)}}},E=async()=>{if(!(!S||f.size===0)){y(!0),x(null);try{const j=Array.from(f).join(","),P=await Ne(re(`/api/config/import?categories=${j}`),{method:"POST",headers:{"Content-Type":"application/zip"},body:await S.arrayBuffer()}),D=await P.json();if(!P.ok)throw new Error(D.error||"Import failed");x({type:"success",text:D.message||s("config:data.importSuccess")}),u(null),p(null),d(new Set)}catch(j){x({type:"error",text:j.message||"Import failed"})}finally{y(!1)}}},z=()=>{u(null),p(null),d(new Set),x(null)};return e.jsxs("div",{className:"data-section",children:[N&&e.jsx("div",{className:`data-message data-message-${N.type}`,children:N.text}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:"Hourly Backups"}),e.jsx(qs,{checked:!!(r!=null&&r.enabled),disabled:R||!r,onChange:M})]}),e.jsxs("div",{className:"data-backup-info",children:[r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:["Saves a compressed snapshot of your data every hour to"," ",e.jsx("code",{children:r.backupDir}),". Identical snapshots are skipped. Keeps the 8 newest plus one from each of the 2 most recent prior days."]}),!r.scriptExists&&e.jsxs("div",{style:{marginTop:6,color:"var(--dracula-red, #ff5555)"},children:["Backup script not found at ",e.jsx("code",{children:r.scriptPath})]}),r.lastRunAt&&e.jsxs("div",{style:{marginTop:6},children:["Last run: ",new Date(r.lastRunAt).toLocaleString(),r.lastRunOk===!0&&" — ok",r.lastRunOk===!1&&r.lastRunError&&e.jsxs("span",{style:{color:"var(--dracula-red, #ff5555)"},children:[" — ",r.lastRunError]})]})]}):e.jsx("div",{children:"Loading backup status…"}),v&&e.jsx("div",{className:"data-message data-message-error",style:{marginTop:6},children:v})]})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:s("config:data.exportData")}),e.jsxs("div",{className:"data-select-controls",children:[e.jsx("button",{className:"data-select-btn",onClick:V,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:O,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:i.map(j=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:o.has(j.id),onChange:()=>K(j.id)}),e.jsx("span",{className:"data-category-name",children:j.name})]},j.id))}),e.jsx("button",{className:"data-action-btn export",onClick:ne,disabled:n||o.size===0,children:n?s("config:data.exporting"):s("config:data.exportCount",{count:o.size})})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsx("div",{className:"data-subsection-header",children:e.jsx("span",{className:"data-subsection-title",children:s("config:data.importData")})}),S?h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"data-import-info",children:[e.jsx("div",{className:"data-import-file",children:S.name}),e.jsxs("div",{className:"data-import-date",children:[s("config:data.exported"),": ",new Date(h.exportedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-subtitle",children:s("config:data.selectToImport")}),e.jsxs("div",{className:"data-select-controls",children:[e.jsx("button",{className:"data-select-btn",onClick:q,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:ee,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:h.categories.map(j=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:f.has(j.id),onChange:()=>G(j.id)}),e.jsx("span",{className:"data-category-name",children:j.name}),j.fileCount&&e.jsxs("span",{className:"data-category-count",children:["(",j.fileCount," ",s("config:data.files"),")"]})]},j.id))}),e.jsxs("div",{className:"data-import-actions",children:[e.jsx("button",{className:"data-action-btn cancel",onClick:z,children:s("common:buttons.cancel")}),e.jsx("button",{className:"data-action-btn import",onClick:E,disabled:T||f.size===0,children:T?s("config:data.importing"):s("config:data.importCount",{count:f.size})})]})]}):e.jsx("div",{className:"data-loading",children:s("config:data.readingFile")}):e.jsxs("label",{className:"data-file-input",children:[e.jsx("input",{type:"file",accept:".zip",onChange:b,style:{display:"none"}}),e.jsx("span",{className:"data-file-input-label",children:s("config:data.selectFile")})]})]})]})}function Ws(){const[s,i]=c.useState(()=>Xe()),a=o=>{i(o);const m=es(o);ss(m)};return e.jsx("div",{className:"theme-selector",children:e.jsx("div",{className:"theme-selector-grid",children:Qe.map(o=>e.jsxs("button",{className:`theme-option ${s===o.id?"active":""}`,onClick:()=>a(o.id),title:o.description,children:[e.jsx("div",{className:"theme-preview",children:e.jsxs("div",{className:"theme-preview-bg",style:{backgroundColor:o.colors.bgPrimary},children:[e.jsx("div",{className:"theme-preview-accent",style:{backgroundColor:o.colors.accentBlue}}),e.jsx("div",{className:"theme-preview-claude",style:{backgroundColor:o.colors.accentClaude}})]})}),e.jsx("span",{className:"theme-name",children:o.name})]},o.id))})})}function Gs(){const{t:s}=se(["config"]),{updateAvailable:i,updateInfo:a,recentReleases:o,isChecking:m,error:f,currentVersion:d,isAndroid:n,checkForUpdate:g,downloadAndInstall:T,openReleasePage:y}=ys(),S=h=>h?`${(h/(1024*1024)).toFixed(1)} MB`:"",u=h=>new Date(h).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"});return e.jsxs("div",{className:"about-section",children:[e.jsxs("div",{className:"about-logo",children:[e.jsx("span",{className:"about-logo-icon",children:e.jsx(L,{name:"waves",size:24})}),e.jsx("span",{className:"about-logo-text",children:"Tide Commander"})]}),e.jsxs("div",{className:"about-version",children:[e.jsx("span",{className:"about-version-label",children:s("config:about.version")}),e.jsxs("div",{className:"about-version-info",children:[e.jsx("span",{className:"about-version-value",children:d}),i&&a?e.jsx("span",{className:"about-version-update-badge",onClick:y,title:`Update available: ${a.version}`,children:a.version}):e.jsxs("a",{href:"https://github.com/deivid11/tide-commander/releases",target:"_blank",rel:"noopener noreferrer",className:"about-version-status",children:["(",s("config:about.updated"),")"]})]})]}),e.jsxs("div",{className:"about-update",children:[i&&a?e.jsxs("div",{className:"about-update-available",children:[e.jsxs("div",{className:"about-update-header",children:[e.jsx("span",{className:"about-update-badge",children:s("config:about.updateAvailable")}),e.jsx("span",{className:"about-update-version",children:a.version})]}),a.apkSize&&e.jsxs("div",{className:"about-update-size",children:[s("config:about.sizeLabel"),": ",S(a.apkSize)]}),f&&e.jsx("div",{className:"about-update-error",children:f}),e.jsxs("div",{className:"about-update-actions",children:[e.jsx("button",{className:"about-update-btn changelog",onClick:y,children:s("config:about.changelog")}),n&&a.apkUrl?e.jsx("button",{className:"about-update-btn download",onClick:T,children:s("config:about.downloadAPK")}):e.jsx("button",{className:"about-update-btn download",onClick:y,children:s("config:about.viewRelease")})]})]}):e.jsxs("div",{className:"about-update-check",children:[e.jsx("span",{className:"about-update-status",children:s(m?"config:about.checkingUpdates":"config:about.upToDate")}),e.jsx("button",{className:"about-update-btn check",onClick:()=>g(!0),disabled:m,children:m?"...":s("config:about.check")})]}),o.length>0&&e.jsxs("div",{className:"about-releases",children:[e.jsx("div",{className:"about-releases-title",children:s("config:about.recentReleases")}),e.jsx("div",{className:"about-releases-list",children:o.map(h=>e.jsxs("a",{href:h.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:`about-release-item ${h.version===`v${d}`||h.version===d?"current":""}`,children:[e.jsx("span",{className:"about-release-version",children:h.version}),e.jsx("span",{className:"about-release-date",children:u(h.publishedAt)})]},h.version))})]})]}),e.jsx("div",{className:"about-description",children:s("config:about.tagline")}),e.jsxs("div",{className:"about-principles",children:[e.jsx("div",{className:"about-principles-title",children:s("config:about.corePrinciples")}),e.jsxs("ul",{className:"about-principles-list",children:[e.jsx("li",{children:s("config:about.principle1")}),e.jsx("li",{children:s("config:about.principle2")}),e.jsx("li",{children:s("config:about.principle3")}),e.jsx("li",{children:s("config:about.principle4")})]})]}),e.jsx("div",{className:"about-links",children:e.jsxs("a",{href:"https://github.com/deivid11/tide-commander",target:"_blank",rel:"noopener noreferrer",className:"about-link",children:[e.jsx("span",{className:"about-link-icon",children:e.jsx(L,{name:"package",size:14})}),e.jsx("span",{children:s("config:about.repository")})]})}),e.jsxs("div",{className:"about-credits",children:[e.jsx("div",{className:"about-credits-title",children:s("config:about.specialThanks")}),e.jsxs("div",{className:"about-credit-item",children:[e.jsx("a",{href:"https://kenney.nl",target:"_blank",rel:"noopener noreferrer",className:"about-credit-link",children:"Kenney.nl"}),e.jsx("span",{className:"about-credit-desc",children:s("config:about.kenneyCredit")})]}),e.jsxs("div",{className:"about-credit-item",children:[e.jsx("a",{href:"https://claude.ai/code",target:"_blank",rel:"noopener noreferrer",className:"about-credit-link",children:"Claude Code"}),e.jsx("span",{className:"about-credit-desc",children:s("config:about.claudeCodeCredit")})]})]})]})}const Hs={gmail:"✉️",slack:"💬",jira:"📋","google-calendar":"📅",docx:"📄"};function Ys({onOpenModal:s}){const[i,a]=c.useState([]),[o,m]=c.useState(!0),f=c.useCallback(async()=>{try{const d=await Ne(re("/api/integrations"));if(!d.ok)return;const n=await d.json();a(n)}catch{}finally{m(!1)}},[]);return c.useEffect(()=>{f()},[f]),o?e.jsx("div",{style:{color:"var(--text-secondary, #a6adc8)",fontSize:12,padding:"4px 0"},children:"Loading..."}):i.length===0?e.jsx("div",{style:{color:"var(--text-secondary, #a6adc8)",fontSize:12,padding:"4px 0"},children:"No integrations available."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[i.map(d=>{const n=Hs[d.id]||"🔌",g=!!d.status.error,T=d.status.connected,y=g?"#f38ba8":T?"#a6e3a1":"#fab387",S=g?"Error":T?"Connected":"Setup Required",u=g?"✗":T?"✓":"⚠";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:6,background:"var(--surface-1, #181825)",border:"1px solid var(--border, #313244)",fontSize:13},children:[e.jsx("span",{style:{fontSize:15,flexShrink:0},children:n}),e.jsx("span",{style:{flex:1,color:"var(--text-primary, #cdd6f4)",fontWeight:500},children:d.name}),e.jsxs("span",{style:{color:y,fontSize:11,fontWeight:500,whiteSpace:"nowrap"},children:[u," ",S]}),e.jsx("button",{onClick:()=>s(d.id),title:`Configure ${d.name}`,style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",fontSize:14,color:"var(--text-secondary, #a6adc8)",borderRadius:4,flexShrink:0},onMouseEnter:h=>{h.target.style.color="var(--text-primary, #cdd6f4)"},onMouseLeave:h=>{h.target.style.color="var(--text-secondary, #a6adc8)"},children:"⚙️"})]},d.id)}),e.jsx("button",{onClick:()=>s(),style:{background:"none",border:"1px dashed var(--border, #313244)",borderRadius:6,padding:"6px 8px",cursor:"pointer",color:"var(--text-secondary, #a6adc8)",fontSize:12,textAlign:"center",marginTop:2},onMouseEnter:d=>{d.target.style.borderColor="var(--accent, #89b4fa)",d.target.style.color="var(--accent, #89b4fa)"},onMouseLeave:d=>{d.target.style.borderColor="var(--border, #313244)",d.target.style.color="var(--text-secondary, #a6adc8)"},children:"Manage All Integrations"})]})}function Js({isOpen:s,onClose:i}){const{t:a}=se(["config"]),[o,m]=c.useState(""),[f,d]=c.useState(""),[n,g]=c.useState(!0),[T,y]=c.useState(null),[S,u]=c.useState(null),[h,p]=c.useState(!1),[N,x]=c.useState(!1),[r,F]=c.useState(!1);c.useEffect(()=>{s&&R()},[s]);const R=async()=>{try{g(!0),y(null),u(null);const O=await Fs();m(O),d(O),p(!1)}catch(O){y(O instanceof Error?O.message:"Failed to load system prompt")}finally{g(!1)}},$=O=>{const q=O.target.value;m(q),p(q!==f),y(null),u(null)},v=async()=>{try{y(null),u(null),await Os(o),d(o),p(!1),u(a("config:systemPrompt.saved"))}catch(O){y(O instanceof Error?O.message:"Failed to save system prompt")}},C=()=>{x(!0)},M=async()=>{try{y(null),u(null),await Ds(),m(""),d(""),p(!1),u(a("config:systemPrompt.cleared"))}catch(O){y(O instanceof Error?O.message:"Failed to clear system prompt")}},K=()=>{m(f),p(!1),y(null),u(null)},G=()=>{if(h){F(!0);return}i()},V=O=>{O.key==="Escape"&&(O.preventDefault(),G())};return s?e.jsxs(Me,{children:[e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:G,children:e.jsxs("div",{className:"system-prompt-modal",onClick:O=>O.stopPropagation(),onKeyDown:V,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:a("config:systemPrompt.title")}),e.jsx("button",{className:"modal-close",onClick:G,"aria-label":"Close",children:e.jsx(L,{name:"close",size:16})})]}),e.jsx("div",{className:"modal-body",children:n?e.jsxs("div",{className:"loading-state",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:"Loading system prompt..."})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"modal-description",children:a("config:systemPrompt.description")}),T&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:"warn",size:14})}),T]}),S&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:"check",size:14})}),S]}),e.jsxs("div",{className:"editor-wrapper",children:[e.jsxs("div",{className:"editor-header",children:[e.jsx("label",{htmlFor:"prompt-input",className:"editor-label",children:a("config:systemPrompt.editPrompt")}),e.jsxs("span",{className:"char-count",children:[o.length," ",a("config:systemPrompt.characters")]})]}),e.jsx("textarea",{id:"prompt-input",className:"prompt-editor",value:o,onChange:$,placeholder:a("config:systemPrompt.placeholder"),rows:18,autoFocus:!0}),e.jsx("div",{className:"editor-hint",children:a("config:systemPrompt.hint")})]})]})}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("div",{className:"footer-buttons-left",children:e.jsx("button",{className:"btn btn-danger",onClick:C,disabled:!o||n,children:a("config:systemPrompt.clear")})}),e.jsxs("div",{className:"footer-buttons-right",children:[e.jsx("button",{className:"btn btn-secondary",onClick:G,children:"Close"}),e.jsx("button",{className:"btn btn-secondary",onClick:K,disabled:!h||n,children:a("config:systemPrompt.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:v,disabled:!h||n,children:a("config:systemPrompt.save")})]})]})]})}),e.jsx(fe,{isOpen:N,title:a("config:systemPrompt.clear"),message:a("config:systemPrompt.confirmClear"),confirmLabel:a("config:systemPrompt.clear"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{M()},onClose:()=>x(!1)}),e.jsx(fe,{isOpen:r,title:"Unsaved Changes",message:"You have unsaved changes. Close anyway?",confirmLabel:"Close anyway",cancelLabel:"Keep editing",variant:"danger",onConfirm:i,onClose:()=>F(!1)})]}):null}const Be={enabled:!1,baseUrl:"",defaultSessionId:"",webhookVerifyToken:"",showIncomingToasts:!0},Zs=2500,Xs=12e4;function Ke(s){return{enabled:s.enabled??!1,baseUrl:s.baseUrl??"",defaultSessionId:s.defaultSessionId??"",webhookVerifyToken:s.webhookVerifyToken??"",showIncomingToasts:s.showIncomingToasts??!0}}function Qs(s,i){return s.enabled===i.enabled&&s.baseUrl===i.baseUrl&&s.defaultSessionId===i.defaultSessionId&&s.webhookVerifyToken===i.webhookVerifyToken&&s.showIncomingToasts===i.showIncomingToasts}function ea({isOpen:s,onClose:i}){const{t:a}=se(["config"]),[o,m]=c.useState(Be),[f,d]=c.useState(Be),[n,g]=c.useState(!1),[T,y]=c.useState([]),[S,u]=c.useState(!0),[h,p]=c.useState(null),[N,x]=c.useState(null),[r,F]=c.useState(""),[R,$]=c.useState(!1),[v,C]=c.useState(""),[M,K]=c.useState(null),[G,V]=c.useState(null),[O,q]=c.useState(null),ee=c.useRef(null),ne=c.useRef(0),[b,E]=c.useState(""),[z,j]=c.useState(""),[P,D]=c.useState(null),[Y,J]=c.useState(!1),[Z,H]=c.useState(!1),[xe,de]=c.useState(!1),[A,X]=c.useState(!1),[pe,ge]=c.useState(null),be=!Qs(o,f),te=c.useCallback(()=>{ee.current&&(clearTimeout(ee.current),ee.current=null)},[]),je=c.useCallback(async()=>{try{u(!0),p(null),x(null);const[l,I]=await Promise.all([as(),ts()]),B=Ke(l);if(m(B),d(B),g(!!I.configured),I.configured)try{const ce=await _e();y(Array.isArray(ce)?ce:[])}catch{y([])}else y([])}catch(l){p(l instanceof Error?l.message:a("config:whatsapp.errors.loadFailed"))}finally{u(!1)}},[a]),me=c.useCallback(async()=>{try{const l=await _e();y(Array.isArray(l)?l:[])}catch{}},[]);c.useEffect(()=>(s?je():(te(),K(null),V(null),q(null),F(""),$(!1),D(null)),()=>{te()}),[s,je,te]);const le=(l,I)=>{m(B=>({...B,[l]:I})),p(null),x(null)},Te=async()=>{try{p(null),x(null);const l=await cs({enabled:o.enabled,baseUrl:o.baseUrl.trim(),defaultSessionId:o.defaultSessionId.trim(),webhookVerifyToken:o.webhookVerifyToken,showIncomingToasts:o.showIncomingToasts});window.dispatchEvent(new CustomEvent("tide:whatsapp-config-updated"));const I=Ke(l);m(I),d(I),x(a("config:whatsapp.saved"))}catch(l){p(l instanceof Error?l.message:a("config:whatsapp.errors.saveFailed"))}},Ie=()=>{m(f),p(null),x(null)},ue=()=>{if(be){H(!0);return}i()},Ee=l=>{l.key==="Escape"&&(l.preventDefault(),ue())},we=async()=>{const l=r.trim();if(l)try{p(null),x(null),await os(l),F(""),$(!1),g(!0),x(a("config:whatsapp.apiKeySaved"))}catch(I){p(I instanceof Error?I.message:a("config:whatsapp.errors.apiKeySaveFailed"))}},oe=()=>{de(!0)},ie=async()=>{try{p(null),x(null),await rs(),g(!1),x(a("config:whatsapp.apiKeyCleared"))}catch(l){p(l instanceof Error?l.message:a("config:whatsapp.errors.apiKeyClearFailed"))}},ve=c.useCallback(async l=>{if(Date.now()>ne.current){q(a("config:whatsapp.pairingTimeout")),K(null),V(null),te(),me();return}try{const I=await ns(l);if(I.status&&["connected","paired","open","ready"].includes(I.status.toLowerCase())){q(a("config:whatsapp.pairingSuccess")),K(null),V(null),te(),me();return}const ce=I.qrUrl??I.qr??null;ce&&V(ce)}catch(I){q(I instanceof Error?I.message:a("config:whatsapp.errors.qrFetchFailed"))}ee.current=setTimeout(()=>{ve(l)},Zs)},[me,te,a]),ke=async()=>{const l=v.trim();if(l)try{p(null),x(null),q(null),V(null),te(),await is(l),C(""),K(l),ne.current=Date.now()+Xs,ve(l),me()}catch(I){p(I instanceof Error?I.message:a("config:whatsapp.errors.sessionCreateFailed"))}},Se=()=>{te(),K(null),V(null),q(null)},_=l=>{ge(l),X(!0)},Ce=async()=>{if(pe)try{p(null),x(null),await ds(pe),M===pe&&Se(),me(),x(a("config:whatsapp.sessionDeleted"))}catch(l){p(l instanceof Error?l.message:a("config:whatsapp.errors.sessionDeleteFailed"))}finally{ge(null)}},t=async()=>{const l=b.trim(),I=z.trim();if(!(!l||!I))try{J(!0),D(null);const B=o.defaultSessionId.trim()||void 0;await ls(l,I,B),D({kind:"success",text:a("config:whatsapp.testSent")})}catch(B){D({kind:"error",text:B instanceof Error?B.message:a("config:whatsapp.errors.testSendFailed")})}finally{J(!1)}};return s?e.jsxs(Me,{children:[e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:ue,children:e.jsxs("div",{className:"whatsapp-config-modal",onClick:l=>l.stopPropagation(),onKeyDown:Ee,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:a("config:whatsapp.title")}),e.jsx("button",{className:"modal-close",onClick:ue,"aria-label":"Close",children:e.jsx(L,{name:"close",size:16})})]}),e.jsx("div",{className:"modal-body",children:S?e.jsxs("div",{className:"loading-state",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:a("config:whatsapp.loading")})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"modal-description",children:a("config:whatsapp.description")}),h&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:"warn",size:14})}),h]}),N&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:"check",size:14})}),N]}),e.jsxs("section",{className:"wa-section",children:[e.jsx("h3",{className:"wa-section-title",children:a("config:whatsapp.sections.general")}),e.jsxs("div",{className:"wa-field wa-field-row",children:[e.jsx("label",{htmlFor:"wa-enabled",className:"wa-label",children:a("config:whatsapp.enabled")}),e.jsxs("label",{className:"wa-toggle",children:[e.jsx("input",{id:"wa-enabled",type:"checkbox",checked:o.enabled,onChange:l=>le("enabled",l.target.checked)}),e.jsx("span",{className:"wa-toggle-track",children:e.jsx("span",{className:"wa-toggle-thumb"})})]})]}),e.jsxs("div",{className:"wa-field wa-field-row",children:[e.jsx("label",{htmlFor:"wa-show-toasts",className:"wa-label",children:a("config:whatsapp.showIncomingToasts")}),e.jsxs("label",{className:"wa-toggle",children:[e.jsx("input",{id:"wa-show-toasts",type:"checkbox",checked:o.showIncomingToasts,onChange:l=>le("showIncomingToasts",l.target.checked)}),e.jsx("span",{className:"wa-toggle-track",children:e.jsx("span",{className:"wa-toggle-thumb"})})]})]}),e.jsx("span",{className:"wa-hint",children:a("config:whatsapp.showIncomingToastsHelp")}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-base-url",className:"wa-label",children:a("config:whatsapp.baseUrl")}),e.jsx("input",{id:"wa-base-url",type:"text",className:"wa-input",placeholder:"http://localhost:3007",value:o.baseUrl,onChange:l=>le("baseUrl",l.target.value)})]}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-default-session",className:"wa-label",children:a("config:whatsapp.defaultSessionId")}),e.jsx("input",{id:"wa-default-session",type:"text",className:"wa-input",placeholder:a("config:whatsapp.defaultSessionIdPlaceholder"),value:o.defaultSessionId,onChange:l=>le("defaultSessionId",l.target.value)})]}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-webhook-token",className:"wa-label",children:a("config:whatsapp.webhookVerifyToken")}),e.jsx("input",{id:"wa-webhook-token",type:"text",className:"wa-input",placeholder:a("config:whatsapp.webhookVerifyTokenPlaceholder"),value:o.webhookVerifyToken,onChange:l=>le("webhookVerifyToken",l.target.value)})]})]}),e.jsxs("section",{className:"wa-section",children:[e.jsx("h3",{className:"wa-section-title",children:a("config:whatsapp.sections.apiKey")}),e.jsx("div",{className:"wa-key-status",children:n?e.jsxs("span",{className:"wa-status wa-status-ok",children:[e.jsx(L,{name:"check",size:12})," ",a("config:whatsapp.configured")]}):e.jsxs("span",{className:"wa-status wa-status-warn",children:[e.jsx(L,{name:"warn",size:12})," ",a("config:whatsapp.notConfigured")]})}),e.jsxs("div",{className:"wa-field wa-field-inline",children:[e.jsx("input",{type:R?"text":"password",className:"wa-input",placeholder:a("config:whatsapp.apiKeyPlaceholder"),value:r,onChange:l=>F(l.target.value)}),e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>$(l=>!l),title:a(R?"config:whatsapp.hideKey":"config:whatsapp.showKey"),children:e.jsx(L,{name:R?"eye-closed":"eye",size:14})}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:we,disabled:!r.trim(),children:a("config:whatsapp.saveKey")}),e.jsx("button",{type:"button",className:"btn btn-danger",onClick:oe,disabled:!n,children:a("config:whatsapp.clearKey")})]}),e.jsx("span",{className:"wa-hint",children:a("config:whatsapp.apiKeyHint")})]}),e.jsxs("section",{className:"wa-section",children:[e.jsx("h3",{className:"wa-section-title",children:a("config:whatsapp.sections.sessions")}),e.jsx("div",{className:"wa-sessions-list",children:!Array.isArray(T)||T.length===0?e.jsx("div",{className:"wa-empty",children:a("config:whatsapp.noSessions")}):T.map(l=>e.jsxs("div",{className:"wa-session-row",children:[e.jsxs("div",{className:"wa-session-info",children:[e.jsx("span",{className:"wa-session-id",children:l.id}),e.jsx("span",{className:`wa-session-status status-${(l.status??"unknown").toLowerCase()}`,children:l.status||"—"}),l.pairedNumber&&e.jsx("span",{className:"wa-session-paired",children:l.pairedNumber})]}),e.jsx("button",{type:"button",className:"btn btn-danger btn-sm",onClick:()=>_(l.id),children:a("config:whatsapp.deleteSession")})]},l.id))}),e.jsxs("div",{className:"wa-field wa-field-inline",children:[e.jsx("input",{type:"text",className:"wa-input",placeholder:a("config:whatsapp.addSessionPlaceholder"),value:v,onChange:l=>C(l.target.value),onKeyDown:l=>{l.key==="Enter"&&ke()}}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:ke,disabled:!v.trim()||M!==null,children:a("config:whatsapp.addSession")})]}),M&&e.jsxs("div",{className:"wa-qr-panel",children:[e.jsxs("div",{className:"wa-qr-header",children:[e.jsx("span",{children:a("config:whatsapp.qrPrompt",{id:M})}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Se,children:a("config:whatsapp.cancelPairing")})]}),G?e.jsx("div",{className:"wa-qr-image",children:e.jsx("img",{src:G,alt:"WhatsApp pairing QR code"})}):e.jsxs("div",{className:"wa-qr-loading",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:a("config:whatsapp.waitingForQr")})]})]}),O&&!M&&e.jsx("div",{className:"wa-pairing-message",children:O})]}),e.jsxs("section",{className:"wa-section",children:[e.jsx("h3",{className:"wa-section-title",children:a("config:whatsapp.sections.testMessage")}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-test-to",className:"wa-label",children:a("config:whatsapp.testTo")}),e.jsx("input",{id:"wa-test-to",type:"text",className:"wa-input",placeholder:a("config:whatsapp.testToPlaceholder"),value:b,onChange:l=>E(l.target.value)})]}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-test-message",className:"wa-label",children:a("config:whatsapp.testMessageBody")}),e.jsx("textarea",{id:"wa-test-message",className:"wa-textarea",rows:4,placeholder:a("config:whatsapp.testMessageBodyPlaceholder"),value:z,onChange:l=>j(l.target.value)})]}),e.jsx("div",{className:"wa-field-inline wa-field-end",children:e.jsx("button",{type:"button",className:"btn btn-primary",onClick:t,disabled:!b.trim()||!z.trim()||Y,children:a(Y?"config:whatsapp.sending":"config:whatsapp.sendTest")})}),P&&e.jsxs("div",{className:`alert ${P.kind==="success"?"alert-success":"alert-error"}`,children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:P.kind==="success"?"check":"warn",size:14})}),P.text]})]})]})}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("div",{className:"footer-buttons-left"}),e.jsxs("div",{className:"footer-buttons-right",children:[e.jsx("button",{className:"btn btn-secondary",onClick:ue,children:a("config:whatsapp.close")}),e.jsx("button",{className:"btn btn-secondary",onClick:Ie,disabled:!be||S,children:a("config:whatsapp.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:Te,disabled:!be||S,children:a("config:whatsapp.save")})]})]})]})}),e.jsx(fe,{isOpen:Z,title:a("config:whatsapp.unsavedTitle"),message:a("config:whatsapp.unsavedMessage"),confirmLabel:a("config:whatsapp.closeAnyway"),cancelLabel:a("config:whatsapp.keepEditing"),variant:"danger",onConfirm:()=>{H(!1),i()},onClose:()=>H(!1)}),e.jsx(fe,{isOpen:xe,title:a("config:whatsapp.clearKey"),message:a("config:whatsapp.confirmClearKey"),confirmLabel:a("config:whatsapp.clearKey"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{ie()},onClose:()=>de(!1)}),e.jsx(fe,{isOpen:A,title:a("config:whatsapp.deleteSession"),message:a("config:whatsapp.confirmDeleteSession",{id:pe??""}),confirmLabel:a("config:whatsapp.deleteSession"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{Ce()},onClose:()=>{X(!1),ge(null)}})]}):null}const sa=[{value:"auto",label:"Auto",icon:"🕐"},{value:"dawn",label:"Dawn",icon:"🌅"},{value:"day",label:"Day",icon:"☀️"},{value:"dusk",label:"Dusk",icon:"🌇"},{value:"night",label:"Night",icon:"🌙"}],aa=[{value:"none",label:"Grass",icon:"🌱"},{value:"concrete",label:"Concrete",icon:"🏗️"},{value:"galactic",label:"Galactic",icon:"🌌"},{value:"metal",label:"Metal",icon:"⚙️"},{value:"hex",label:"Hex",icon:"⬡"},{value:"circuit",label:"Circuit",icon:"🔌"},{value:"pokemon-stadium",label:"Pokemon",icon:"🔴"}],ta=[{value:"static",label:"Static",icon:"🧍"},{value:"idle",label:"Idle",icon:"🚶"},{value:"walk",label:"Walk",icon:"🚶♂️"},{value:"sprint",label:"Sprint",icon:"🏃"},{value:"jump",label:"Jump",icon:"⬆️"},{value:"fall",label:"Fall",icon:"⬇️"},{value:"crouch",label:"Crouch",icon:"🧎"},{value:"sit",label:"Sit",icon:"🪑"},{value:"die",label:"Die",icon:"💀"},{value:"emote-yes",label:"Yes",icon:"👍"},{value:"emote-no",label:"No",icon:"👎"}],na=[{value:"normal",label:"Normal",icon:"🎨"},{value:"bw",label:"B&W",icon:"⬛"},{value:"sepia",label:"Sepia",icon:"🟤"},{value:"cool",label:"Cool",icon:"❄️"},{value:"warm",label:"Warm",icon:"🔥"},{value:"neon",label:"Neon",icon:"💜"}],oa=[{key:"showTrees",icon:"🌳",label:"Trees"},{key:"showBushes",icon:"🌿",label:"Bushes"},{key:"showHouse",icon:"🏠",label:"House"},{key:"showLamps",icon:"💡",label:"Lamps"},{key:"showGrass",icon:"🟩",label:"Grass"},{key:"showClouds",icon:"☁️",label:"Clouds"}],ia=[{value:null,label:"Auto",color:"linear-gradient(135deg, #4a90d9 0%, #0a1a2a 100%)"},{value:"#4a90d9",label:"Day Blue",color:"#4a90d9"},{value:"#0a1a2a",label:"Night",color:"#0a1a2a"},{value:"#ff6b35",label:"Sunset",color:"#ff6b35"},{value:"#1a0a2e",label:"Purple",color:"#1a0a2e"},{value:"#2d5a27",label:"Matrix",color:"#2d5a27"},{value:"#8b0000",label:"Blood",color:"#8b0000"},{value:"#000000",label:"Void",color:"#000000"}],la={showTrees:"trees",showBushes:"bushes",showHouse:"house",showLamps:"lamps",showGrass:"grass",showClouds:"clouds"},ca={none:"grass","pokemon-stadium":"pokemon"},ra={"emote-yes":"yes","emote-no":"no"},da={"":"auto","#4a90d9":"dayBlue","#0a1a2a":"night","#ff6b35":"sunset","#1a0a2e":"purple","#2d5a27":"matrix","#8b0000":"blood","#000000":"void"};function Q({checked:s,onChange:i}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,onChange:a=>i(a.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function he({options:s,value:i,onChange:a,iconOnly:o=!1}){return e.jsx("div",{className:"chip-selector",children:s.map(m=>e.jsxs("button",{className:`chip ${i===m.value?"active":""}`,onClick:()=>a(m.value),title:m.label,children:[e.jsx("span",{className:"chip-icon",children:m.icon}),!o&&e.jsx("span",{className:"chip-label",children:m.label})]},m.value))})}function w({text:s,query:i}){if(!i.trim())return e.jsx(e.Fragment,{children:s});const a=s.toLowerCase(),o=i.toLowerCase(),m=a.indexOf(o);if(m===-1)return e.jsx(e.Fragment,{children:s});const f=s.slice(0,m),d=s.slice(m,m+i.length),n=s.slice(m+i.length);return e.jsxs(e.Fragment,{children:[f,e.jsx("mark",{className:"search-highlight",children:d}),n]})}const ma=[{id:"general",title:"General",keywords:["history","hide costs","grid","fps","power saving","performance","limit","editor","external editor","language","idioma","语言","vibration","haptic","intensity","tab title","tmux","process persistence"]},{id:"agentNames",title:"Agent Names",keywords:["agent","names","custom","characters","rename"]},{id:"defaultClass",title:"Default Spawn Class",keywords:["default","class","spawn","agent","scout","builder","random"]},{id:"appearance",title:"Appearance",keywords:["theme","appearance","color","dark","light","style","look"]},{id:"connection",title:"Connection",keywords:["backend","url","auth","token","reconnect","server","api","connect","codex","opencode","binary","path"]},{id:"scene",title:"Scene",keywords:["character","size","indicator","scale","time","dawn","day","dusk","night","auto"]},{id:"terrain",title:"Terrain",keywords:["trees","bushes","house","lamps","grass","clouds","fog","brightness","floor","sky","color","environment","battlefield","size","grid","simple","minimal","dark","clean"]},{id:"modelStyle",title:"Agent Model Style",keywords:["saturation","roughness","metalness","glow","emissive","reflections","wireframe","color mode","material","shader"]},{id:"animations",title:"Animations",keywords:["idle","working","animation","walk","run","sprint","jump","sit","crouch"]},{id:"secrets",title:"Secrets",keywords:["secrets","api","key","password","credentials","env","environment"]},{id:"systemPrompt",title:"System Prompt",keywords:["system","prompt","global","instructions","ai","agent","rules","guidelines"]},{id:"whatsapp",title:"WhatsApp Integration",keywords:["whatsapp","message","sms","integration","notification","baileys"]},{id:"data",title:"Data",keywords:["export","import","backup","restore","save","load","json"]},{id:"integrations",title:"Integrations",keywords:["integrations","plugins","gmail","slack","jira","calendar","docx","email","config","setup"]},{id:"workflows",title:"Workflows",keywords:["workflow","automation","state machine","editor","actions","transitions","pipeline"]},{id:"triggers",title:"Triggers",keywords:["trigger","event","webhook","cron","slack","email","jira","matching","fire"]},{id:"monitoring",title:"Monitoring",keywords:["monitoring","logs","triggers","events","history","workflow","traces","audit","timeline"]},{id:"experimental",title:"Experimental",keywords:["experimental","2d","view","voice","assistant","speech","tts","text to speech","echo","prompt","duplicate"]},{id:"about",title:"About",keywords:["about","version","update","credits","github","releases"]}],Oe=[{value:"auto",label:"Auto",icon:"🌐"},{value:"en",label:"English",icon:"🇺🇸"},{value:"zh-CN",label:"中文",icon:"🇨🇳"},{value:"es",label:"Español",icon:"🇪🇸"},{value:"hi",label:"हिन्दी",icon:"🇮🇳"},{value:"pt",label:"Português",icon:"🇧🇷"},{value:"ru",label:"Русский",icon:"🇷🇺"},{value:"ja",label:"日本語",icon:"🇯🇵"},{value:"de",label:"Deutsch",icon:"🇩🇪"},{value:"fr",label:"Français",icon:"🇫🇷"},{value:"it",label:"Italiano",icon:"🇮🇹"}];function ua({config:s,onChange:i,searchQuery:a="",onOpenIntegrationsModal:o,onOpenMonitoringModal:m,onOpenWorkflowEditor:f,onOpenTriggerManager:d}){var Ce;const{t:n}=se(["config","common"]),g=De(),T=ms(),[y,S]=c.useState(()=>us(ye.DEFAULT_AGENT_CLASS)||"scout"),[u,h]=c.useState(g.settings.historyLimit),[p,N]=c.useState(()=>ps()),[x,r]=c.useState(!1),[F,R]=c.useState(""),[$,v]=c.useState(()=>W()),[C,M]=c.useState(!1),[K,G]=c.useState(!1),[V,O]=c.useState(""),[q,ee]=c.useState(!1),[ne,b]=c.useState(!1),[E,z]=c.useState(""),[j,P]=c.useState(!1);c.useEffect(()=>{_s().then(z).catch(()=>{})},[]),c.useEffect(()=>{$s().then(t=>{t!==g.settings.experimentalEchoPrompt&&k.updateSettings({experimentalEchoPrompt:t})}).catch(()=>{})},[]),c.useEffect(()=>{Rs().then(t=>{t!==g.settings.tmuxMode&&k.updateSettings({tmuxMode:t})}).catch(()=>{})},[]),c.useEffect(()=>gs(t=>{N(t),r(!1)}),[]);const D=sa.map(t=>({...t,label:n(`config:time.${t.value}`)})),Y=aa.map(t=>({...t,label:n(`config:floor.${ca[t.value]||t.value}`)})),J=ta.map(t=>({...t,label:n(`config:animation.${ra[t.value]||t.value}`)})),Z=na.map(t=>({...t,label:n(`config:colorMode.${t.value}`)})),H=oa.map(t=>({...t,label:n(`config:terrain.${la[t.key]}`)})),xe=ia.map(t=>({...t,label:n(`config:sky.${da[t.value??""]}`)})),de=a.trim()?ma.filter(t=>{const l=a.toLowerCase();return t.title.toLowerCase().includes(l)||t.keywords.some(I=>I.toLowerCase().includes(l))}).map(t=>t.id):null,A=t=>de?de.includes(t):!0,X=g.settings.customAgentNames||[],pe=X.length>0?X:hs,ge=()=>{const t=V.trim();t&&!X.includes(t)&&(k.updateSettings({customAgentNames:[...X,t]}),O(""))},be=t=>{k.updateSettings({customAgentNames:X.filter(l=>l!==t)})},te=()=>{k.updateSettings({customAgentNames:[]})},je=()=>{const t=F.trim();if(t){if(p.includes(t)){R("");return}N([...p,t]),r(!0),R("")}},me=t=>{N(p.filter((l,I)=>I!==t)),r(!0)},le=(t,l)=>{const I=t+l;if(I<0||I>=p.length)return;const B=p.slice();[B[t],B[I]]=[B[I],B[t]],N(B),r(!0)},Te=()=>{xs(p),r(!1),Fe()},Ie=t=>{v(t),M(!0)},ue=()=>{Ae(ye.AUTH_TOKEN,$),M(!1),Fe()},Ee=t=>{z(t),P(!0)},we=()=>{Us(E).catch(()=>{}),P(!1)},oe=t=>{i({...s,terrain:{...s.terrain,...t}})},ie=t=>{i({...s,modelStyle:{...s.modelStyle,...t}})},ve=t=>{i({...s,animations:{...s.animations,...t}})},ke=t=>{h(t),k.updateSettings({historyLimit:t})},Se=t=>{const l=s.terrain[t];typeof l=="boolean"&&oe({[t]:!l})},_=a.trim().length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"config-section",children:[de&&de.length===0&&e.jsx("div",{className:"config-no-results",children:n("config:noResults",{query:a})}),A("general")&&e.jsxs(U,{title:n("config:sections.general"),storageKey:"general",defaultOpen:!0,forceOpen:_&&A("general"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.history"),query:a})}),e.jsx("input",{type:"number",className:"config-input config-input-sm",value:u,onChange:t=>ke(parseInt(t.target.value)||100),min:50,max:2e3,step:50})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.hideCosts"),query:a})}),e.jsx(Q,{checked:g.settings.hideCost,onChange:t=>k.updateSettings({hideCost:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.grid"),query:a})}),e.jsx(Q,{checked:s.gridVisible,onChange:t=>i({...s,gridVisible:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.showFPS"),query:a})}),e.jsx(Q,{checked:g.settings.showFPS,onChange:t=>k.updateSettings({showFPS:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.fpsLimit"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"120",step:"10",value:s.fpsLimit,onChange:t=>i({...s,fpsLimit:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.fpsLimit===0?"∞":s.fpsLimit})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Experimental: Reduce FPS when idle to save power",children:[e.jsx(w,{text:n("config:general.powerSaving"),query:a})," ",e.jsx(L,{name:"bolt",size:12})]}),e.jsx(Q,{checked:g.settings.powerSaving,onChange:t=>k.updateSettings({powerSaving:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",title:"Wrap agent processes in tmux sessions so they survive server restarts (requires tmux installed)",children:e.jsx(w,{text:n("config:general.tmuxMode"),query:a})}),e.jsx(Q,{checked:g.settings.tmuxMode,onChange:async t=>{k.updateSettings({tmuxMode:t});try{await Bs(t)}catch(l){console.error("Failed to sync tmux mode setting to server:",l)}}})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.vibrationIntensity"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"5",step:"1",value:g.settings.vibrationIntensity,onChange:t=>k.updateSettings({vibrationIntensity:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:g.settings.vibrationIntensity===0?n("config:vibrationValues.off"):g.settings.vibrationIntensity===1?n("config:vibrationValues.ultraLight"):g.settings.vibrationIntensity===2?n("config:vibrationValues.veryLight"):g.settings.vibrationIntensity===3?n("config:vibrationValues.light"):g.settings.vibrationIntensity===4?n("config:vibrationValues.medium"):n("config:vibrationValues.heavy")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.externalEditor"),query:a})}),e.jsx("input",{type:"text",className:"config-input",placeholder:n("config:general.externalEditorPlaceholder"),value:g.settings.externalEditorCommand||"",onChange:t=>k.updateSettings({externalEditorCommand:t.target.value})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.tabTitle"),query:a})}),e.jsx("input",{type:"text",className:"config-input",placeholder:n("config:general.tabTitlePlaceholder"),value:g.settings.tabTitle||"",onChange:t=>k.updateSettings({tabTitle:t.target.value})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.language"),query:a})}),e.jsx(he,{options:Oe,value:localStorage.getItem("tide-commander-language-mode")==="manual"?((Ce=Oe.find(t=>t.value!=="auto"&&Le.language.startsWith(t.value.split("-")[0])))==null?void 0:Ce.value)||"en":"auto",onChange:t=>{var l;if(t==="auto"){localStorage.setItem("tide-commander-language-mode","auto");const I=navigator.language,B=((l=Oe.find(ce=>ce.value!=="auto"&&I.startsWith(ce.value.split("-")[0])))==null?void 0:l.value)||"en";Le.changeLanguage(B)}else localStorage.setItem("tide-commander-language-mode","manual"),Le.changeLanguage(t)}})]})]}),A("agentNames")&&e.jsx(U,{title:n("config:sections.agentNames"),storageKey:"agentNames",defaultOpen:!1,forceOpen:_&&A("agentNames"),children:e.jsxs("div",{className:"agent-names-section",children:[e.jsx("span",{className:"config-hint",children:X.length>0?n("config:agentNames.customConfigured",{count:X.length}):n("config:agentNames.usingDefaults")}),e.jsxs("div",{className:"agent-names-input-row",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",placeholder:n("config:agentNames.addPlaceholder"),value:V,onChange:t=>O(t.target.value),onKeyDown:t=>{t.key==="Enter"&&ge()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:ge,disabled:!V.trim(),title:n("config:agentNames.addName"),children:"+"})]}),e.jsx("div",{className:"agent-names-list",children:pe.map((t,l)=>e.jsxs("div",{className:"agent-name-chip",children:[e.jsx("span",{className:"agent-name-text",children:t}),X.length>0&&e.jsx("button",{className:"agent-name-remove",onClick:()=>be(t),title:n("common:buttons.remove"),children:"x"})]},`${t}-${l}`))}),X.length>0&&e.jsx("button",{className:"config-btn config-btn-link",onClick:te,children:n("common:buttons.resetToDefaults")})]})}),A("defaultClass")&&e.jsx(U,{title:"Default Spawn Class",storageKey:"defaultClass",defaultOpen:!1,forceOpen:_&&A("defaultClass"),children:e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-hint",children:'Class pre-selected when the spawn modal opens. "Random" picks a different class each time.'}),e.jsxs("div",{className:"agent-names-list",style:{flexWrap:"wrap",gap:"6px",marginTop:"8px"},children:[e.jsx("div",{className:`agent-name-chip${y==="random"?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{S("random"),Ae(ye.DEFAULT_AGENT_CLASS,"random")},children:e.jsx("span",{className:"agent-name-text",children:"🎲 Random"})}),Object.entries(fs).map(([t,l])=>e.jsx("div",{className:`agent-name-chip${y===t?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{S(t),Ae(ye.DEFAULT_AGENT_CLASS,t)},children:e.jsxs("span",{className:"agent-name-text",children:[l.icon," ",t.charAt(0).toUpperCase()+t.slice(1)]})},t)),T.map(t=>e.jsx("div",{className:`agent-name-chip${y===t.id?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{S(t.id),Ae(ye.DEFAULT_AGENT_CLASS,t.id)},children:e.jsxs("span",{className:"agent-name-text",children:[t.icon," ",t.name]})},t.id))]})]})}),A("appearance")&&e.jsx(U,{title:n("config:sections.appearance"),storageKey:"appearance",defaultOpen:!1,forceOpen:_&&A("appearance"),children:e.jsx(Ws,{})}),A("connection")&&e.jsxs(U,{title:n("config:sections.connection"),storageKey:"connection",defaultOpen:!1,forceOpen:_&&A("connection"),children:[e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:connection.backendUrl"),query:a})}),e.jsx("div",{className:"backend-urls-list",children:p.map((t,l)=>e.jsxs("div",{className:"backend-url-row",children:[e.jsx("span",{className:"backend-url-priority",title:n("config:connection.priorityLabel",{defaultValue:"Priority"}),children:l+1}),e.jsx("span",{className:"backend-url-text",title:t,children:t}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>le(l,-1),disabled:l===0,title:n("config:connection.moveUp",{defaultValue:"Move up"}),children:"↑"}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>le(l,1),disabled:l===p.length-1,title:n("config:connection.moveDown",{defaultValue:"Move down"}),children:"↓"}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>me(l),title:n("common:buttons.remove"),children:"x"})]},`${t}-${l}`))}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:F,onChange:t=>R(t.target.value),placeholder:n("config:connection.addUrlPlaceholder",{defaultValue:"http://host:port"}),onKeyDown:t=>{t.key==="Enter"&&je()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:je,disabled:!F.trim(),title:n("config:connection.addUrl",{defaultValue:"Add URL"}),children:"+"}),x&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:Te,title:n("config:connection.saveAndReconnect"),children:n("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:n("config:connection.urlsHint",{defaultValue:"Tried in order on connect; the first reachable host wins. Leave empty for auto-detect."})})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:connection.authToken"),query:a})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:K?"text":"password",className:"config-input config-input-full",value:$,onChange:t=>Ie(t.target.value),placeholder:n("config:connection.tokenPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&C&&ue()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>G(!K),title:n(K?"config:connection.hideToken":"config:connection.showToken"),children:e.jsx(L,{name:K?"eye-closed":"eye",size:14})}),C&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:ue,title:n("config:connection.saveAndReconnect"),children:n("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:n("config:connection.tokenRequired")})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:connection.codexBinaryPath"),query:a})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:E,onChange:t=>Ee(t.target.value),placeholder:n("config:connection.codexBinaryPathPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&j&&we()}}),j&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:we,children:n("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:n("config:connection.codexBinaryPathHint")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("common:buttons.reconnect"),query:a})}),e.jsx("button",{className:"config-btn",onClick:()=>Fe(),title:"Force reconnect to server",children:n("common:buttons.reconnect")})]})]}),A("scene")&&e.jsxs(U,{title:n("config:sections.scene"),storageKey:"scene",defaultOpen:!1,forceOpen:_&&A("scene"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:scene.characterSize"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"3.0",step:"0.1",value:s.characterScale,onChange:t=>i({...s,characterScale:parseFloat(t.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.characterScale.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:scene.scale2d",{defaultValue:"2D Scale"}),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"2.0",step:"0.1",value:s.scale2d,onChange:t=>i({...s,scale2d:parseFloat(t.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.scale2d.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:scene.scale3d",{defaultValue:"3D Scale"}),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"2.0",step:"0.1",value:s.scale3d,onChange:t=>i({...s,scale3d:parseFloat(t.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.scale3d.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:scene.show2DTaskLabels",{defaultValue:"Show 2D task labels"}),query:a})}),e.jsx(Q,{checked:s.show2DTaskLabels,onChange:t=>i({...s,show2DTaskLabels:t})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:scene.time"),query:a})}),e.jsx(he,{options:D,value:s.timeMode,onChange:t=>i({...s,timeMode:t}),iconOnly:!0})]})]}),A("terrain")&&e.jsxs(U,{title:n("config:sections.terrain"),storageKey:"terrain",defaultOpen:!1,forceOpen:_&&A("terrain"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:terrainSettings.simpleMode",{defaultValue:"Simple Mode"}),query:a})}),e.jsx(Q,{checked:s.terrain.simpleMode??!1,onChange:t=>oe({simpleMode:t})})]}),e.jsx("div",{className:"terrain-icons",style:{opacity:s.terrain.simpleMode?.4:1,pointerEvents:s.terrain.simpleMode?"none":"auto"},children:H.map(t=>e.jsx("button",{className:`terrain-icon-btn ${s.terrain[t.key]?"active":""}`,onClick:()=>Se(t.key),title:t.label,children:t.icon},t.key))}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:terrainSettings.fog"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.terrain.fogDensity,onChange:t=>oe({fogDensity:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.fogDensity===0?n("config:fogValues.off"):s.terrain.fogDensity<=1?n("config:fogValues.low"):n("config:fogValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:terrainSettings.brightness"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.2",max:"2",step:"0.1",value:s.terrain.brightness,onChange:t=>oe({brightness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.brightness<=.5?n("config:brightnessValues.dark"):s.terrain.brightness<=1.2?n("config:brightnessValues.normal"):n("config:brightnessValues.bright")})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:terrainSettings.floor"),query:a})}),e.jsx(he,{options:Y,value:s.terrain.floorStyle,onChange:t=>oe({floorStyle:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:terrainSettings.sky"),query:a})}),e.jsx("div",{className:"sky-color-selector",children:xe.map(t=>e.jsx("button",{className:`sky-color-btn ${s.terrain.skyColor===t.value?"active":""}`,onClick:()=>oe({skyColor:t.value}),title:t.label,style:{background:t.color}},t.value??"auto"))})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:terrainSettings.battlefieldSize"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"30",max:"200",step:"10",value:s.terrain.battlefieldSize,onChange:t=>oe({battlefieldSize:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.battlefieldSize})]})]}),A("modelStyle")&&e.jsxs(U,{title:n("config:sections.modelStyle"),storageKey:"modelStyle",defaultOpen:!1,forceOpen:_&&A("modelStyle"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:modelStyleSettings.saturation"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.modelStyle.saturation,onChange:t=>ie({saturation:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.saturation<=.3?n("config:saturationValues.gray"):s.modelStyle.saturation<=1.2?n("config:saturationValues.normal"):n("config:saturationValues.vivid")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:modelStyleSettings.roughness"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.roughness,onChange:t=>ie({roughness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.roughness<0?n("config:roughnessValues.auto"):s.modelStyle.roughness<=.3?n("config:roughnessValues.glossy"):s.modelStyle.roughness<=.7?n("config:roughnessValues.normal"):n("config:roughnessValues.matte")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:modelStyleSettings.metalness"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.metalness,onChange:t=>ie({metalness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.metalness<0?n("config:metalnessValues.auto"):s.modelStyle.metalness<=.3?n("config:metalnessValues.plastic"):s.modelStyle.metalness<=.7?n("config:metalnessValues.mixed"):n("config:metalnessValues.metal")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:modelStyleSettings.glow"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"1",step:"0.05",value:s.modelStyle.emissiveBoost,onChange:t=>ie({emissiveBoost:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.emissiveBoost<=.1?n("config:glowValues.off"):s.modelStyle.emissiveBoost<=.4?n("config:glowValues.low"):s.modelStyle.emissiveBoost<=.7?n("config:glowValues.med"):n("config:glowValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:modelStyleSettings.reflections"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"2",step:"0.1",value:s.modelStyle.envMapIntensity,onChange:t=>ie({envMapIntensity:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.envMapIntensity<0?n("config:reflectionValues.auto"):s.modelStyle.envMapIntensity<=.3?n("config:reflectionValues.low"):s.modelStyle.envMapIntensity<=1?n("config:reflectionValues.normal"):n("config:reflectionValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:modelStyleSettings.wireframe"),query:a})}),e.jsx(Q,{checked:s.modelStyle.wireframe,onChange:t=>ie({wireframe:t})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:modelStyleSettings.colorMode"),query:a})}),e.jsx(he,{options:Z,value:s.modelStyle.colorMode,onChange:t=>ie({colorMode:t}),iconOnly:!0})]})]}),A("animations")&&e.jsxs(U,{title:n("config:sections.animations"),storageKey:"animations",defaultOpen:!1,forceOpen:_&&A("animations"),children:[e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:animationSettings.idle"),query:a})}),e.jsx(he,{options:J,value:s.animations.idleAnimation,onChange:t=>ve({idleAnimation:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:animationSettings.working"),query:a})}),e.jsx(he,{options:J,value:s.animations.workingAnimation,onChange:t=>ve({workingAnimation:t}),iconOnly:!0})]})]}),A("secrets")&&e.jsx(U,{title:n("config:sections.secrets"),storageKey:"secrets",defaultOpen:!1,forceOpen:_&&A("secrets"),children:e.jsx(Ls,{})}),A("systemPrompt")&&e.jsx(U,{title:n("config:sections.systemPrompt"),storageKey:"systemPrompt",defaultOpen:!1,forceOpen:_&&A("systemPrompt"),children:e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:systemPrompt.title"),query:a})}),e.jsx("button",{className:"config-button",onClick:()=>ee(!0),children:n("config:systemPrompt.editPrompt")})]})}),A("whatsapp")&&e.jsx(U,{title:n("config:sections.whatsapp"),storageKey:"whatsapp",defaultOpen:!1,forceOpen:_&&A("whatsapp"),children:e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:whatsapp.title"),query:a})}),e.jsx("button",{className:"config-button",onClick:()=>b(!0),children:n("config:whatsapp.editConfig")})]})}),A("data")&&e.jsx(U,{title:n("config:sections.data"),storageKey:"data",defaultOpen:!1,forceOpen:_&&A("data"),children:e.jsx(Ms,{})}),A("integrations")&&e.jsx(U,{title:"Integrations",storageKey:"integrations",defaultOpen:!1,forceOpen:_&&A("integrations"),children:e.jsx(Ys,{onOpenModal:t=>o==null?void 0:o(t)})}),A("workflows")&&e.jsxs(U,{title:"Workflows",storageKey:"workflows",defaultOpen:!1,forceOpen:_&&A("workflows"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(w,{text:"Create and manage automated workflow pipelines with visual state machine editor",query:a})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>f==null?void 0:f(),children:"Open Workflow Editor"})})]}),A("triggers")&&e.jsxs(U,{title:"Triggers",storageKey:"triggers",defaultOpen:!1,forceOpen:_&&A("triggers"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(w,{text:"Create and manage event-driven triggers that fire agents with templates",query:a})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>d==null?void 0:d(),children:"Open Trigger Manager"})})]}),A("monitoring")&&e.jsxs(U,{title:"Monitoring",storageKey:"monitoring",defaultOpen:!1,forceOpen:_&&A("monitoring"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(w,{text:"View event logs, trigger history, workflow traces, and system stats",query:a})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>m==null?void 0:m(),children:"Open Monitoring & Logs"})})]}),A("experimental")&&e.jsxs(U,{title:n("config:sections.experimental"),storageKey:"experimental",defaultOpen:!1,forceOpen:_&&A("experimental"),children:[e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Lightweight 2D top-down view for better performance",children:[e.jsx(w,{text:n("config:experimental.2dView"),query:a})," ",e.jsx(L,{name:"map",size:12})]}),e.jsx(Q,{checked:g.settings.experimental2DView,onChange:t=>k.updateSettings({experimental2DView:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Voice assistant for hands-free agent control",children:[e.jsx(w,{text:n("config:experimental.voiceAssistant"),query:a})," ",e.jsx(L,{name:"microphone",size:12})]}),e.jsx(Q,{checked:g.settings.experimentalVoiceAssistant,onChange:t=>k.updateSettings({experimentalVoiceAssistant:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Text-to-speech for reading agent responses",children:[e.jsx(w,{text:n("config:experimental.tts"),query:a})," ",e.jsx(L,{name:"speaker-on",size:12})]}),e.jsx(Q,{checked:g.settings.experimentalTTS,onChange:t=>k.updateSettings({experimentalTTS:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",title:"Duplicate system prompt for improved LLM attention coverage. Increases input token usage.",children:e.jsx(w,{text:n("config:experimental.echoPrompt"),query:a})}),e.jsx(Q,{checked:g.settings.experimentalEchoPrompt,onChange:async t=>{k.updateSettings({experimentalEchoPrompt:t});try{await zs(t)}catch(l){console.error("Failed to sync echo prompt setting to server:",l)}}})]}),e.jsx("span",{className:"config-hint",children:n("config:experimental.hint")})]}),A("about")&&e.jsx(U,{title:n("config:sections.about"),storageKey:"about",defaultOpen:!1,forceOpen:_&&A("about"),children:e.jsx(Gs,{})})]}),e.jsx(Js,{isOpen:q,onClose:()=>ee(!1)}),e.jsx(ea,{isOpen:ne,onClose:()=>b(!1)})]})}function fa({onConfigChange:s,onToolChange:i,config:a,isOpen:o,onClose:m,onOpenBuildingModal:f,onOpenAreaExplorer:d,onOpenIntegrationsModal:n,onOpenMonitoringModal:g,onOpenWorkflowEditor:T,onOpenTriggerManager:y}){const{t:S}=se(["config","common"]),u=De(),h=Array.from(u.areas.values()),p=Array.from(u.buildings.values()),[N,x]=c.useState(""),r=c.useRef(null);if(c.useEffect(()=>{const v=C=>{C.key==="Escape"&&o&&m()};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[o,m]),c.useEffect(()=>{if(o&&r.current){const v=setTimeout(()=>{var C;(C=r.current)==null||C.focus()},50);return()=>clearTimeout(v)}},[o]),!o)return null;const F=v=>{const C=u.activeTool===v?null:v;i(C)},R=v=>{k.selectArea(u.selectedAreaId===v?null:v),i("select")},$=(v,C)=>{v.stopPropagation(),k.deleteArea(C)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"toolbox-backdrop",onClick:m}),e.jsxs("aside",{className:"toolbox",children:[e.jsxs("div",{className:"toolbox-header",children:[e.jsx("span",{children:S("config:title")}),e.jsx("button",{className:"toolbox-close-btn",onClick:m,title:S("common:buttons.close"),children:"×"})]}),e.jsxs("div",{className:"toolbox-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:r,type:"text",placeholder:S("config:searchPlaceholder"),value:N,onChange:v=>x(v.target.value),className:"toolbox-search-input"}),N&&e.jsx("button",{className:"toolbox-search-clear",onClick:()=>x(""),children:"×"})]}),e.jsxs("div",{className:"toolbox-content",children:[e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsxs(U,{title:S("config:areas.title",{count:h.length}),storageKey:"areas",children:[e.jsxs("div",{className:"tool-buttons",children:[e.jsx("button",{className:`tool-btn ${u.activeTool==="select"?"active":""}`,onClick:()=>F("select"),title:S("config:tools.select"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z"})})})}),e.jsx("button",{className:`tool-btn ${u.activeTool==="rectangle"?"active":""}`,onClick:()=>F("rectangle"),title:S("config:tools.rectangle"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"})})})}),e.jsx("button",{className:`tool-btn ${u.activeTool==="circle"?"active":""}`,onClick:()=>F("circle"),title:S("config:tools.circle"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("circle",{cx:"12",cy:"12",r:"9"})})})})]}),e.jsx("div",{className:"areas-list",children:h.length===0?e.jsx("div",{className:"areas-empty",children:S("config:areas.drawToCreate")}):h.map(v=>e.jsx(ks,{area:v,isSelected:u.selectedAreaId===v.id,onClick:()=>R(v.id),onDelete:C=>$(C,v.id)},v.id))})]})}),u.selectedAreaId&&e.jsx(Ps,{area:u.areas.get(u.selectedAreaId),onClose:()=>k.selectArea(null),onOpenFolder:d}),e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsx(U,{title:S("config:buildings.title",{count:p.length}),storageKey:"buildings",headerExtra:e.jsx("button",{className:"add-building-btn",onClick:v=>{v.stopPropagation(),f==null||f()},title:S("config:buildings.addBuilding"),children:"+"}),children:e.jsx("div",{className:"buildings-list",children:p.length===0?e.jsx("div",{className:"buildings-empty",children:S("config:buildings.clickToAdd")}):p.map(v=>e.jsx(Ss,{building:v,isSelected:u.selectedBuildingIds.has(v.id),onClick:()=>{k.selectBuilding(u.selectedBuildingIds.has(v.id)?null:v.id)},onEdit:()=>f==null?void 0:f(v.id)},v.id))})})}),u.selectedBuildingIds.size===1&&(()=>{const v=Array.from(u.selectedBuildingIds)[0],C=u.buildings.get(v);return C?e.jsx(Cs,{building:C,onClose:()=>k.selectBuilding(null),onOpenModal:()=>f==null?void 0:f(v)}):null})(),e.jsx(ua,{config:a,onChange:s,searchQuery:N,onOpenIntegrationsModal:n,onOpenMonitoringModal:g,onOpenWorkflowEditor:T,onOpenTriggerManager:y})]})]})]})}export{fa as Toolbox};
|
|
1
|
+
import{r as c,aP as Pe,aQ as ze,j as e,I as L,u as se,aR as Ve,_ as qe,f as De,s as k,aS as Ge,k as He,l as re,aT as W,aU as Ye,aI as Je,aV as Ze,C as fe,aW as ae,aF as Ne,aX as Xe,aY as Qe,aZ as es,a_ as ss,a$ as Me,b0 as as,b1 as ts,b2 as _e,b3 as ns,b4 as os,b5 as is,b6 as ls,b7 as cs,b8 as rs,b9 as ds,aB as ms,E as us,S as ye,ba as ps,bb as gs,aD as hs,bc as Le,G as Ae,aM as fs,bd as Fe,be as xs}from"./main-CHfGSVnw.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const $e="deivid11/tide-commander",bs=`https://api.github.com/repos/${$e}/releases/latest`,js=`https://api.github.com/repos/${$e}/releases?per_page=3`,vs=3600*1e3,Ue="app_update_dismissed_version",Re="1.83.0";function ys(){var y,S;const[s,i]=c.useState({isChecking:!1,updateAvailable:!1,updateInfo:null,recentReleases:[],error:null,currentVersion:Re}),a=((S=(y=Pe)==null?void 0:y.getPlatform)==null?void 0:S.call(y))==="android"||!1,o=u=>u.replace(/^v/,"").split(".").map(p=>parseInt(p,10)||0),m=(u,h)=>{const p=o(u),N=o(h),x=Math.max(p.length,N.length);for(let r=0;r<x;r++){const F=p[r]||0,R=N[r]||0;if(F>R)return 1;if(F<R)return-1}return 0},f=async u=>{var p,N;if(Pe&&ze&&((N=(p=Pe).isNativePlatform)==null?void 0:N.call(p))===!0){const x=await ze.get({url:u,headers:{Accept:"application/vnd.github.v3+json"}});return{data:x.data,status:x.status}}else{const x=await fetch(u,{headers:{Accept:"application/vnd.github.v3+json"}});return x.ok?{data:await x.json(),status:x.status}:{data:null,status:x.status}}},d=c.useCallback(async(u=!1)=>{i(h=>({...h,isChecking:!0,error:null}));try{const[h,p]=await Promise.all([f(bs),f(js)]);if(h.status!==200)throw new Error(`GitHub API error: ${h.status}`);const N=h.data,x=N.tag_name;let r=[];p.status===200&&p.data&&(r=p.data.map(C=>({version:C.tag_name,name:C.name,publishedAt:C.published_at,releaseUrl:C.html_url})));const F=localStorage.getItem(Ue);if(!u&&F===x)return i(C=>({...C,isChecking:!1,updateAvailable:!1,recentReleases:r})),null;if(!(m(x,Re)>0))return i(C=>({...C,isChecking:!1,updateAvailable:!1,recentReleases:r})),null;const $=N.assets.find(C=>C.name.endsWith(".apk")&&C.content_type==="application/vnd.android.package-archive"),v={version:x,name:N.name,changelog:N.body,releaseUrl:N.html_url,apkUrl:($==null?void 0:$.browser_download_url)||null,apkSize:($==null?void 0:$.size)||null,publishedAt:N.published_at};return i(C=>({...C,isChecking:!1,updateAvailable:!0,updateInfo:v,recentReleases:r})),v}catch(h){const p=h instanceof Error?h.message:"Failed to check for updates";return i(N=>({...N,isChecking:!1,error:p})),null}},[]),n=c.useCallback(async()=>{var u,h,p;if(!((u=s.updateInfo)!=null&&u.apkUrl)){(h=s.updateInfo)!=null&&h.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}if(!a){(p=s.updateInfo)!=null&&p.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}try{window.open(s.updateInfo.apkUrl,"_system"),i(N=>({...N,error:null}))}catch(N){const x=N instanceof Error?N.message:"Failed to open download";i(r=>({...r,error:x}))}},[s.updateInfo,a]),g=c.useCallback(()=>{s.updateInfo&&localStorage.setItem(Ue,s.updateInfo.version),i(u=>({...u,updateAvailable:!1,updateInfo:null}))},[s.updateInfo]),T=c.useCallback(()=>{var u;(u=s.updateInfo)!=null&&u.releaseUrl?window.open(s.updateInfo.releaseUrl,"_blank"):window.open(`https://github.com/${$e}/releases`,"_blank")},[s.updateInfo]);return c.useEffect(()=>{if(!a)return;const u=setTimeout(()=>{d()},5e3),h=setInterval(()=>{d()},vs);return()=>{clearTimeout(u),clearInterval(h)}},[a,d]),{...s,isAndroid:a,checkForUpdate:d,downloadAndInstall:n,dismissUpdate:g,openReleasePage:T}}const We="tide-toolbox-collapse";function Ns(s,i){try{const a=localStorage.getItem(`${We}-${s}`);if(a!==null)return a==="true"}catch{}return i}function ws(s,i){try{localStorage.setItem(`${We}-${s}`,String(i))}catch{}}function U({title:s,storageKey:i,defaultOpen:a=!1,forceOpen:o=!1,children:m,headerExtra:f}){const[d,n]=c.useState(()=>i?Ns(i,a):a),g=()=>{const y=!d;n(y),i&&ws(i,y)},T=o||d;return e.jsxs("div",{className:`collapsible-section ${T?"open":"collapsed"}`,children:[e.jsxs("button",{className:"collapsible-header",onClick:g,children:[e.jsx("span",{className:"collapsible-title",children:s}),e.jsxs("span",{className:"collapsible-header-right",children:[f,e.jsx("span",{className:"collapsible-arrow",children:e.jsx(L,{name:T?"caret-down":"caret-right",size:10})})]})]}),T&&e.jsx("div",{className:"collapsible-content",children:m})]})}function ks({area:s,isSelected:i,onClick:a,onDelete:o}){const{t:m}=se(["config","common"]),f=s.assignedAgentIds.length,d=s.type==="rectangle"?m("config:areas.rect"):m("config:areas.circle");return e.jsxs("div",{className:`area-item ${i?"selected":""}`,onClick:a,children:[e.jsx("div",{className:"area-color-dot",style:{backgroundColor:s.color}}),e.jsxs("div",{className:"area-info",children:[e.jsx("div",{className:"area-name",children:s.name}),e.jsxs("div",{className:"area-meta",children:[d," ",f>0&&`• ${f} ${f>1?m("common:labels.agents").toLowerCase():m("common:labels.agent").toLowerCase()}`]})]}),e.jsx("button",{className:"area-delete-btn",onClick:o,title:m("config:areas.deleteArea"),children:"×"})]})}function Ss({building:s,isSelected:i,onClick:a,onEdit:o}){var n;const{t:m}=se(["config"]),f=((n=s.pm2Status)==null?void 0:n.ports)||[],d=(g,T)=>{g.stopPropagation(),window.open(`http://${window.location.hostname}:${T}`,"_blank")};return e.jsxs("div",{className:`building-item ${i?"selected":""}`,onClick:a,children:[e.jsx("div",{className:"building-status-dot",style:{backgroundColor:Ve[s.status]},title:s.status}),e.jsx("div",{className:"building-icon",children:e.jsx(L,{name:qe(s.type),size:16})}),e.jsxs("div",{className:"building-info",children:[e.jsx("div",{className:"building-name",children:s.name}),e.jsxs("div",{className:"building-meta",children:[s.type,f.length>0&&e.jsx("span",{className:"building-ports",children:f.map(g=>e.jsxs("a",{href:`http://${window.location.hostname}:${g}`,className:"building-port-link",onClick:T=>d(T,g),title:`Open :${g}`,children:[":",g]},g))})]})]}),e.jsx("button",{className:"building-edit-btn",onClick:g=>{g.stopPropagation(),o()},title:m("config:buildings.editBuilding"),children:e.jsx(L,{name:"gear",size:14})})]})}function Cs({building:s,onClose:i,onOpenModal:a}){var T,y,S,u,h,p,N,x;const{t:o}=se(["config","common"]),{buildingLogs:m}=De(),f=k.getBuildingLogs(s.id),d=Ge[s.style||"server-rack"],n=r=>{k.sendBuildingCommand(s.id,r)},g=r=>{window.open(r,"_blank")};return e.jsxs("div",{className:"building-editor",children:[e.jsxs("div",{className:"building-editor-header",children:[e.jsxs("div",{className:"building-editor-title-row",children:[e.jsx("span",{className:"building-editor-icon",children:e.jsx(L,{name:qe(s.type),size:18})}),e.jsx("span",{className:"building-editor-title",children:s.name}),e.jsx("span",{className:"building-editor-status",style:{backgroundColor:Ve[s.status]},children:s.status})]}),e.jsx("button",{className:"building-editor-close",onClick:i,children:"×"})]}),e.jsx("div",{className:"building-editor-section",children:e.jsxs("div",{className:"building-editor-info-grid",children:[e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("common:labels.type")}),e.jsx("span",{className:"building-editor-info-value",children:s.type})]}),e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.style")}),e.jsx("span",{className:"building-editor-info-value",children:d.label})]}),s.cwd&&e.jsxs("div",{className:"building-editor-info-item building-editor-info-wide",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.directory")}),e.jsx("span",{className:"building-editor-info-value building-editor-cwd",title:s.cwd,children:s.cwd.split("/").pop()||s.cwd})]})]})}),s.type==="server"&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.actions")}),e.jsxs("div",{className:"building-editor-actions",children:[e.jsxs("button",{className:"building-editor-action-btn start",onClick:()=>n("start"),disabled:!((T=s.commands)!=null&&T.start)||s.status==="running",title:((y=s.commands)==null?void 0:y.start)||o("config:buildings.noStartCommand"),children:[e.jsx(L,{name:"play",size:12})," ",o("common:buttons.start")]}),e.jsxs("button",{className:"building-editor-action-btn stop",onClick:()=>n("stop"),disabled:!((S=s.commands)!=null&&S.stop)||s.status==="stopped",title:((u=s.commands)==null?void 0:u.stop)||o("config:buildings.noStopCommand"),children:[e.jsx(L,{name:"stop",size:12,weight:"fill"})," ",o("common:buttons.stop")]}),e.jsxs("button",{className:"building-editor-action-btn restart",onClick:()=>n("restart"),disabled:!((h=s.commands)!=null&&h.restart),title:((p=s.commands)==null?void 0:p.restart)||o("config:buildings.noRestartCommand"),children:[e.jsx(L,{name:"refresh",size:12})," ",o("common:buttons.retry")]}),e.jsxs("button",{className:"building-editor-action-btn health",onClick:()=>n("healthCheck"),disabled:!((N=s.commands)!=null&&N.healthCheck),title:((x=s.commands)==null?void 0:x.healthCheck)||o("config:buildings.noHealthCheck"),children:[e.jsx(L,{name:"heart",size:12})," Health"]})]})]}),s.urls&&s.urls.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.links")}),e.jsx("div",{className:"building-editor-links",children:s.urls.map((r,F)=>e.jsxs("button",{className:"building-editor-link",onClick:()=>g(r.url),title:r.url,children:[e.jsx(L,{name:"link",size:12})," ",r.label||r.url]},F))})]}),f.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsxs("div",{className:"building-editor-section-title",children:[o("config:buildings.recentLogs"),e.jsx("button",{className:"building-editor-clear-logs",onClick:()=>k.clearBuildingLogs(s.id),title:o("common:buttons.clear"),children:o("common:buttons.clear")})]}),e.jsx("div",{className:"building-editor-logs",children:f.slice(-5).map((r,F)=>e.jsx("div",{className:"building-editor-log-entry",children:r},F))})]}),e.jsx("div",{className:"building-editor-footer",children:e.jsxs("button",{className:"building-editor-edit-btn",onClick:a,children:[e.jsx(L,{name:"gear",size:12})," ",o("config:buildings.fullSettings")]})})]})}async function As(s,i){const a=W(),o=await fetch(re(`/api/areas/${s}/logo`),{method:"POST",headers:{"Content-Type":i.type||"image/png","X-Filename":encodeURIComponent(i.name),...a?{Authorization:`Bearer ${a}`}:{}},body:i});if(!o.ok){const m=await o.json().catch(()=>({error:o.statusText}));throw new Error(m.error||`Upload failed: ${o.statusText}`)}return o.json()}async function Ts(s){const i=W(),a=await fetch(re(`/api/areas/${s}/logo`),{method:"DELETE",headers:{...i?{Authorization:`Bearer ${i}`}:{}}});if(!a.ok)throw new Error(`Failed to delete logo: ${a.statusText}`)}function Is(s){return He(re(`/api/areas/logos/${s}`))}const Es=[{key:"center",labelKey:"posCenter"},{key:"top-left",labelKey:"posTopLeft"},{key:"top-right",labelKey:"posTopRight"},{key:"bottom-left",labelKey:"posBottomLeft"},{key:"bottom-right",labelKey:"posBottomRight"}];function Ps({area:s,onClose:i,onOpenFolder:a}){var ne;const{t:o}=se(["config","common"]),[m,f]=c.useState(s.name),[d,n]=c.useState(s.prompt||""),[g,T]=c.useState(!1),[y,S]=c.useState(""),[u,h]=c.useState(!1),p=c.useRef(null);c.useEffect(()=>{f(s.name)},[s.id,s.name]),c.useEffect(()=>{n(s.prompt||"")},[s.id,s.prompt]);const N=b=>{const E=b.target.value;f(E),k.updateArea(s.id,{name:E})},x=b=>{k.updateArea(s.id,{color:b})},r=b=>{const E=b.target.value;n(E),k.updateArea(s.id,{prompt:E})},F=()=>{y.trim()&&(k.addDirectoryToArea(s.id,y.trim()),S(""),T(!1))},R=(b,E)=>{E.stopPropagation(),k.removeDirectoryFromArea(s.id,b)},$=()=>{k.bringAreaToFront(s.id)},v=()=>{k.sendAreaToBack(s.id)},C=c.useCallback(()=>{let b=2,E=2;s.type==="rectangle"&&s.width&&s.height?(b=s.width,E=s.height):s.type==="circle"&&s.radius&&(b=s.radius*1.414,E=s.radius*1.414);const z=Math.min(b,E)*.4;return{width:Math.round(z*10)/10,height:Math.round(z*10)/10}},[s.type,s.width,s.height,s.radius]),M=async b=>{var z;const E=(z=b.target.files)==null?void 0:z[0];if(E){h(!0);try{const j=await As(s.id,E),P=C();k.updateArea(s.id,{logo:{filename:j.filename,position:"center",width:P.width,height:P.height,keepAspectRatio:!0,opacity:.8}})}catch(j){console.error("Failed to upload logo:",j)}finally{h(!1),p.current&&(p.current.value="")}}},K=async()=>{try{await Ts(s.id),k.updateArea(s.id,{logo:void 0})}catch(b){console.error("Failed to remove logo:",b)}},G=b=>{s.logo&&k.updateArea(s.id,{logo:{...s.logo,position:b}})},V=b=>{if(!s.logo)return;const E=parseFloat(b.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.width>0){const z=s.logo.height/s.logo.width;k.updateArea(s.id,{logo:{...s.logo,width:E,height:Math.round(E*z*10)/10}})}else k.updateArea(s.id,{logo:{...s.logo,width:E}})},O=b=>{if(!s.logo)return;const E=parseFloat(b.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.height>0){const z=s.logo.width/s.logo.height;k.updateArea(s.id,{logo:{...s.logo,height:E,width:Math.round(E*z*10)/10}})}else k.updateArea(s.id,{logo:{...s.logo,height:E}})},q=()=>{s.logo&&k.updateArea(s.id,{logo:{...s.logo,keepAspectRatio:!s.logo.keepAspectRatio}})},ee=b=>{s.logo&&k.updateArea(s.id,{logo:{...s.logo,opacity:parseFloat(b.target.value)}})};return e.jsxs("div",{className:"area-editor",children:[e.jsxs("div",{className:"area-editor-header",children:[e.jsx("span",{className:"area-editor-title",children:o("config:areas.editArea")}),e.jsx("button",{className:"area-editor-close",onClick:i,children:"×"})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("common:labels.name")}),e.jsx("input",{type:"text",className:"area-editor-input",value:m,onChange:N,placeholder:o("config:areas.areaName")})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.color")}),e.jsx("div",{className:"color-picker-row",children:Ye.map(b=>e.jsx("div",{className:`color-swatch ${s.color===b?"selected":""}`,style:{backgroundColor:b},onClick:()=>x(b)},b))})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.layer")}),e.jsxs("div",{className:"area-layer-buttons",children:[e.jsxs("button",{className:"area-layer-btn",onClick:$,title:o("config:areas.bringToFront"),children:[e.jsx(L,{name:"arrow-up",size:12})," ",o("config:areas.front")]}),e.jsxs("button",{className:"area-layer-btn",onClick:v,title:o("config:areas.sendToBack"),children:[e.jsx(L,{name:"arrow-down",size:12})," ",o("config:areas.back")]})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.logo")}),e.jsxs("div",{className:"area-logo-section",children:[(ne=s.logo)!=null&&ne.filename?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"area-logo-preview",children:[e.jsx("img",{src:Is(s.logo.filename),alt:"Logo",className:"area-logo-thumbnail"}),e.jsx("button",{className:"area-logo-remove-btn",onClick:K,children:o("config:areas.removeLogo")}),e.jsx("button",{className:"area-logo-replace-btn",onClick:()=>{var b;return(b=p.current)==null?void 0:b.click()},disabled:u,children:u?"...":e.jsx(L,{name:"refresh",size:12})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoPosition")}),e.jsx("div",{className:"area-logo-position-row",children:Es.map(({key:b,labelKey:E})=>{var z;return e.jsx("button",{className:`area-logo-pos-btn ${((z=s.logo)==null?void 0:z.position)===b?"active":""}`,onClick:()=>G(b),children:o(`config:areas.${E}`)},b)})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoSize")}),e.jsxs("div",{className:"area-logo-size-row",children:[e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoWidth")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.width,onChange:V,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoHeight")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.height,onChange:O,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-aspect-label",title:o("config:areas.keepAspectRatio"),children:[e.jsx("input",{type:"checkbox",checked:s.logo.keepAspectRatio,onChange:q}),o("config:areas.keepAspectRatio")]})]})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoOpacity")}),e.jsxs("div",{className:"area-logo-opacity-row",children:[e.jsx("input",{type:"range",min:0,max:1,step:.05,value:s.logo.opacity??.8,onChange:ee,className:"area-logo-opacity-slider"}),e.jsxs("span",{className:"area-logo-opacity-value",children:[Math.round((s.logo.opacity??.8)*100),"%"]})]})]})]}):e.jsx("button",{className:"area-logo-upload-btn",onClick:()=>{var b;return(b=p.current)==null?void 0:b.click()},disabled:u,children:u?"...":o("config:areas.uploadLogo")}),e.jsx("input",{ref:p,type:"file",accept:"image/*",style:{display:"none"},onChange:M})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.folders",{count:s.directories.length})}),e.jsxs("div",{className:"area-folders-list",children:[s.directories.map(b=>e.jsxs("div",{className:"area-folder-item",title:b,children:[e.jsx("span",{className:"area-folder-icon clickable",onClick:()=>a==null?void 0:a(s.id),title:o("config:areas.openFolder"),children:e.jsx(L,{name:"folder",size:14})}),e.jsx("span",{className:"area-folder-path",children:b.split("/").pop()||b}),e.jsx("button",{className:"area-folder-remove",onClick:E=>R(b,E),title:o("config:areas.removeFolder"),children:"×"})]},b)),g?e.jsxs("div",{className:"area-add-folder-inline",children:[e.jsx(Je,{value:y,onChange:S,onSubmit:F,placeholder:o("config:areas.folderPlaceholder"),className:"area-add-folder-input",directoriesOnly:!0,autoFocus:!0}),e.jsx("button",{className:"area-add-folder-confirm",onClick:F,children:"+"})]}):e.jsx("button",{className:"area-add-folder-btn",onClick:()=>T(!0),children:o("config:areas.addFolder")})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.prompt","Prompt")}),e.jsx("textarea",{className:"area-editor-input",value:d,onChange:r,placeholder:o("config:areas.promptPlaceholder","System prompt for agents in this area..."),rows:4,style:{resize:"vertical",fontFamily:"monospace",fontSize:12}}),e.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4},children:o("config:areas.promptHint","This prompt is injected into agents assigned to this area. Takes effect on next context refresh.")})]}),s.assignedAgentIds.length>0&&e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.assignedAgents",{count:s.assignedAgentIds.length})}),e.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:o("config:areas.rightClickUnassign")})]})]})}function Ls(){const{t:s}=se(["config","common"]),i=Ze(),[a,o]=c.useState(!1),[m,f]=c.useState(null),[d,n]=c.useState({name:"",key:"",value:"",description:""}),[g,T]=c.useState(null),y=()=>{o(!0),f(null),n({name:"",key:"",value:"",description:""})},S=r=>{f(r.id),o(!1),n({name:r.name,key:r.key,value:r.value,description:r.description||""})},u=()=>{o(!1),f(null),n({name:"",key:"",value:"",description:""})},h=()=>{!d.name.trim()||!d.key.trim()||(m?k.updateSecret(m,{name:d.name.trim(),key:d.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:d.value,description:d.description.trim()||void 0}):k.createSecret({name:d.name.trim(),key:d.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:d.value,description:d.description.trim()||void 0}),u())},p=r=>{T(r)},N=()=>{g&&(k.deleteSecret(g),m===g&&u())},x=r=>{navigator.clipboard.writeText(`{{${r}}}`)};return e.jsxs("div",{className:"secrets-section",children:[e.jsx("div",{className:"secrets-description",children:s("config:secrets.description",{placeholder:"{{KEY}}"})}),e.jsx("div",{className:"secrets-list",children:i.length===0&&!a?e.jsx("div",{className:"secrets-empty",children:s("config:secrets.noSecrets")}):i.map(r=>e.jsxs("div",{className:`secret-item ${m===r.id?"editing":""}`,children:[e.jsxs("div",{className:"secret-item-header",children:[e.jsxs("div",{className:"secret-item-info",children:[e.jsx("span",{className:"secret-item-name",children:r.name}),e.jsx("code",{className:"secret-item-key",onClick:()=>x(r.key),title:s("config:secrets.copyPlaceholder"),children:`{{${r.key}}}`})]}),e.jsxs("div",{className:"secret-item-actions",children:[e.jsx("button",{className:"secret-item-btn edit",onClick:()=>S(r),title:s("common:buttons.edit"),children:e.jsx(L,{name:"edit",size:12})}),e.jsx("button",{className:"secret-item-btn delete",onClick:()=>p(r.id),title:s("common:buttons.delete"),children:"×"})]})]}),r.description&&e.jsx("div",{className:"secret-item-description",children:r.description})]},r.id))}),(a||m)&&e.jsxs("div",{className:"secret-form",children:[e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.name")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.namePlaceholder"),value:d.name,onChange:r=>n({...d,name:r.target.value}),autoFocus:!0})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:"Key"}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.keyPlaceholder"),value:d.key,onChange:r=>n({...d,key:r.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")})}),e.jsx("span",{className:"secret-form-hint",children:s("config:secrets.usedAs",{placeholder:`{{${d.key||"KEY"}}}`})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("config:secrets.secretValue")}),e.jsx("input",{type:"password",className:"secret-form-input",placeholder:s("config:secrets.valuePlaceholder"),value:d.value,onChange:r=>n({...d,value:r.target.value})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.description")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.descriptionPlaceholder"),value:d.description,onChange:r=>n({...d,description:r.target.value})})]}),e.jsxs("div",{className:"secret-form-actions",children:[e.jsx("button",{className:"secret-form-btn cancel",onClick:u,children:s("common:buttons.cancel")}),e.jsx("button",{className:"secret-form-btn save",onClick:h,disabled:!d.name.trim()||!d.key.trim(),children:s(m?"config:secrets.update":"common:buttons.add")})]})]}),!a&&!m&&e.jsx("button",{className:"secrets-add-btn",onClick:y,children:s("config:secrets.addSecret")}),e.jsx(fe,{isOpen:g!==null,title:s("common:buttons.delete"),message:s("config:secrets.deleteConfirm"),confirmLabel:s("common:buttons.delete"),cancelLabel:s("common:buttons.cancel"),variant:"danger",onConfirm:N,onClose:()=>T(null)})]})}async function Fs(){const s=W(),i=await fetch(`${ae()}/api/agents/system-settings/prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch system prompt: ${i.statusText}`);return(await i.json()).prompt||""}async function Os(s){const i=W(),a=await fetch(`${ae()}/api/agents/system-settings/prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({prompt:s})});if(!a.ok)throw new Error(`Failed to update system prompt: ${a.statusText}`)}async function Ds(){const s=W(),i=await fetch(`${ae()}/api/agents/system-settings/prompt`,{method:"DELETE",headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to clear system prompt: ${i.statusText}`)}async function $s(){const s=W(),i=await fetch(`${ae()}/api/agents/system-settings/echo-prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch echo prompt setting: ${i.statusText}`);return(await i.json()).enabled||!1}async function zs(s){const i=W(),a=await fetch(`${ae()}/api/agents/system-settings/echo-prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!a.ok)throw new Error(`Failed to update echo prompt setting: ${a.statusText}`)}async function _s(){const s=W(),i=await fetch(`${ae()}/api/agents/system-settings/codex-binary`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch codex binary path: ${i.statusText}`);return(await i.json()).path||""}async function Us(s){const i=W(),a=await fetch(`${ae()}/api/agents/system-settings/codex-binary`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({path:s})});if(!a.ok)throw new Error(`Failed to update codex binary path: ${a.statusText}`)}async function Rs(){const s=W(),i=await fetch(`${ae()}/api/agents/system-settings/tmux-mode`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch tmux mode setting: ${i.statusText}`);return(await i.json()).enabled||!1}async function Bs(s){const i=W(),a=await fetch(`${ae()}/api/agents/system-settings/tmux-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!a.ok)throw new Error(`Failed to update tmux mode setting: ${a.statusText}`)}async function Ks(){const s=W(),i=await fetch(`${ae()}/api/agents/system-settings/backup`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch backup status: ${i.statusText}`);return i.json()}async function Vs(s){const i=W(),a=await fetch(`${ae()}/api/agents/system-settings/backup`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.error||`Failed to update backup setting: ${a.statusText}`)}return a.json()}function qs({checked:s,onChange:i,disabled:a}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,disabled:a,onChange:o=>i(o.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function Ms(){const{t:s}=se(["config","common"]),[i,a]=c.useState([]),[o,m]=c.useState(new Set),[f,d]=c.useState(new Set),[n,g]=c.useState(!1),[T,y]=c.useState(!1),[S,u]=c.useState(null),[h,p]=c.useState(null),[N,x]=c.useState(null),[r,F]=c.useState(null),[R,$]=c.useState(!1),[v,C]=c.useState(null);c.useEffect(()=>{Ne(re("/api/config/categories")).then(j=>j.json()).then(j=>{const P=Array.isArray(j)?j:[];a(P),m(new Set(P.map(D=>D.id)))}).catch(j=>console.error("Failed to fetch config categories:",j))},[]),c.useEffect(()=>{Ks().then(F).catch(j=>{console.error("Failed to fetch backup status:",j),C(j.message||"Failed to fetch backup status")})},[]);const M=async j=>{if(!R){$(!0),C(null);try{const P=await Vs(j);F(P)}catch(P){C(P.message||"Failed to update backup setting")}finally{$(!1)}}},K=j=>{m(P=>{const D=new Set(P);return D.has(j)?D.delete(j):D.add(j),D})},G=j=>{d(P=>{const D=new Set(P);return D.has(j)?D.delete(j):D.add(j),D})},V=()=>m(new Set(i.map(j=>j.id))),O=()=>m(new Set),q=()=>{h&&d(new Set(h.categories.map(j=>j.id)))},ee=()=>d(new Set),ne=async()=>{var j;if(o.size!==0){g(!0),x(null);try{const P=Array.from(o).join(","),D=await Ne(re(`/api/config/export?categories=${P}`));if(!D.ok)throw new Error("Export failed");const Y=await D.blob(),J=window.URL.createObjectURL(Y),Z=document.createElement("a");Z.href=J;const H=D.headers.get("Content-Disposition"),xe=((j=H==null?void 0:H.match(/filename="(.+)"/))==null?void 0:j[1])||"tide-commander-config.zip";Z.download=xe,document.body.appendChild(Z),Z.click(),document.body.removeChild(Z),window.URL.revokeObjectURL(J),x({type:"success",text:s("config:data.exportSuccess")})}catch(P){x({type:"error",text:P.message||"Export failed"})}finally{g(!1)}}},b=async j=>{var D;const P=(D=j.target.files)==null?void 0:D[0];if(P){u(P),x(null),p(null),d(new Set);try{const Y=await Ne(re("/api/config/preview"),{method:"POST",headers:{"Content-Type":"application/zip"},body:await P.arrayBuffer()});if(!Y.ok){const H=await Y.json();throw new Error(H.error||"Failed to preview config file")}const J=await Y.json(),Z=Array.isArray(J.categories)?J.categories:[];p({...J,categories:Z}),d(new Set(Z.map(H=>H.id)))}catch(Y){x({type:"error",text:Y.message||"Failed to read config file"}),u(null)}}},E=async()=>{if(!(!S||f.size===0)){y(!0),x(null);try{const j=Array.from(f).join(","),P=await Ne(re(`/api/config/import?categories=${j}`),{method:"POST",headers:{"Content-Type":"application/zip"},body:await S.arrayBuffer()}),D=await P.json();if(!P.ok)throw new Error(D.error||"Import failed");x({type:"success",text:D.message||s("config:data.importSuccess")}),u(null),p(null),d(new Set)}catch(j){x({type:"error",text:j.message||"Import failed"})}finally{y(!1)}}},z=()=>{u(null),p(null),d(new Set),x(null)};return e.jsxs("div",{className:"data-section",children:[N&&e.jsx("div",{className:`data-message data-message-${N.type}`,children:N.text}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:"Hourly Backups"}),e.jsx(qs,{checked:!!(r!=null&&r.enabled),disabled:R||!r,onChange:M})]}),e.jsxs("div",{className:"data-backup-info",children:[r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:["Saves a compressed snapshot of your data every hour to"," ",e.jsx("code",{children:r.backupDir}),". Identical snapshots are skipped. Keeps the 8 newest plus one from each of the 2 most recent prior days."]}),!r.scriptExists&&e.jsxs("div",{style:{marginTop:6,color:"var(--dracula-red, #ff5555)"},children:["Backup script not found at ",e.jsx("code",{children:r.scriptPath})]}),r.lastRunAt&&e.jsxs("div",{style:{marginTop:6},children:["Last run: ",new Date(r.lastRunAt).toLocaleString(),r.lastRunOk===!0&&" — ok",r.lastRunOk===!1&&r.lastRunError&&e.jsxs("span",{style:{color:"var(--dracula-red, #ff5555)"},children:[" — ",r.lastRunError]})]})]}):e.jsx("div",{children:"Loading backup status…"}),v&&e.jsx("div",{className:"data-message data-message-error",style:{marginTop:6},children:v})]})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:s("config:data.exportData")}),e.jsxs("div",{className:"data-select-controls",children:[e.jsx("button",{className:"data-select-btn",onClick:V,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:O,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:i.map(j=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:o.has(j.id),onChange:()=>K(j.id)}),e.jsx("span",{className:"data-category-name",children:j.name})]},j.id))}),e.jsx("button",{className:"data-action-btn export",onClick:ne,disabled:n||o.size===0,children:n?s("config:data.exporting"):s("config:data.exportCount",{count:o.size})})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsx("div",{className:"data-subsection-header",children:e.jsx("span",{className:"data-subsection-title",children:s("config:data.importData")})}),S?h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"data-import-info",children:[e.jsx("div",{className:"data-import-file",children:S.name}),e.jsxs("div",{className:"data-import-date",children:[s("config:data.exported"),": ",new Date(h.exportedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-subtitle",children:s("config:data.selectToImport")}),e.jsxs("div",{className:"data-select-controls",children:[e.jsx("button",{className:"data-select-btn",onClick:q,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:ee,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:h.categories.map(j=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:f.has(j.id),onChange:()=>G(j.id)}),e.jsx("span",{className:"data-category-name",children:j.name}),j.fileCount&&e.jsxs("span",{className:"data-category-count",children:["(",j.fileCount," ",s("config:data.files"),")"]})]},j.id))}),e.jsxs("div",{className:"data-import-actions",children:[e.jsx("button",{className:"data-action-btn cancel",onClick:z,children:s("common:buttons.cancel")}),e.jsx("button",{className:"data-action-btn import",onClick:E,disabled:T||f.size===0,children:T?s("config:data.importing"):s("config:data.importCount",{count:f.size})})]})]}):e.jsx("div",{className:"data-loading",children:s("config:data.readingFile")}):e.jsxs("label",{className:"data-file-input",children:[e.jsx("input",{type:"file",accept:".zip",onChange:b,style:{display:"none"}}),e.jsx("span",{className:"data-file-input-label",children:s("config:data.selectFile")})]})]})]})}function Ws(){const[s,i]=c.useState(()=>Xe()),a=o=>{i(o);const m=es(o);ss(m)};return e.jsx("div",{className:"theme-selector",children:e.jsx("div",{className:"theme-selector-grid",children:Qe.map(o=>e.jsxs("button",{className:`theme-option ${s===o.id?"active":""}`,onClick:()=>a(o.id),title:o.description,children:[e.jsx("div",{className:"theme-preview",children:e.jsxs("div",{className:"theme-preview-bg",style:{backgroundColor:o.colors.bgPrimary},children:[e.jsx("div",{className:"theme-preview-accent",style:{backgroundColor:o.colors.accentBlue}}),e.jsx("div",{className:"theme-preview-claude",style:{backgroundColor:o.colors.accentClaude}})]})}),e.jsx("span",{className:"theme-name",children:o.name})]},o.id))})})}function Gs(){const{t:s}=se(["config"]),{updateAvailable:i,updateInfo:a,recentReleases:o,isChecking:m,error:f,currentVersion:d,isAndroid:n,checkForUpdate:g,downloadAndInstall:T,openReleasePage:y}=ys(),S=h=>h?`${(h/(1024*1024)).toFixed(1)} MB`:"",u=h=>new Date(h).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"});return e.jsxs("div",{className:"about-section",children:[e.jsxs("div",{className:"about-logo",children:[e.jsx("span",{className:"about-logo-icon",children:e.jsx(L,{name:"waves",size:24})}),e.jsx("span",{className:"about-logo-text",children:"Tide Commander"})]}),e.jsxs("div",{className:"about-version",children:[e.jsx("span",{className:"about-version-label",children:s("config:about.version")}),e.jsxs("div",{className:"about-version-info",children:[e.jsx("span",{className:"about-version-value",children:d}),i&&a?e.jsx("span",{className:"about-version-update-badge",onClick:y,title:`Update available: ${a.version}`,children:a.version}):e.jsxs("a",{href:"https://github.com/deivid11/tide-commander/releases",target:"_blank",rel:"noopener noreferrer",className:"about-version-status",children:["(",s("config:about.updated"),")"]})]})]}),e.jsxs("div",{className:"about-update",children:[i&&a?e.jsxs("div",{className:"about-update-available",children:[e.jsxs("div",{className:"about-update-header",children:[e.jsx("span",{className:"about-update-badge",children:s("config:about.updateAvailable")}),e.jsx("span",{className:"about-update-version",children:a.version})]}),a.apkSize&&e.jsxs("div",{className:"about-update-size",children:[s("config:about.sizeLabel"),": ",S(a.apkSize)]}),f&&e.jsx("div",{className:"about-update-error",children:f}),e.jsxs("div",{className:"about-update-actions",children:[e.jsx("button",{className:"about-update-btn changelog",onClick:y,children:s("config:about.changelog")}),n&&a.apkUrl?e.jsx("button",{className:"about-update-btn download",onClick:T,children:s("config:about.downloadAPK")}):e.jsx("button",{className:"about-update-btn download",onClick:y,children:s("config:about.viewRelease")})]})]}):e.jsxs("div",{className:"about-update-check",children:[e.jsx("span",{className:"about-update-status",children:s(m?"config:about.checkingUpdates":"config:about.upToDate")}),e.jsx("button",{className:"about-update-btn check",onClick:()=>g(!0),disabled:m,children:m?"...":s("config:about.check")})]}),o.length>0&&e.jsxs("div",{className:"about-releases",children:[e.jsx("div",{className:"about-releases-title",children:s("config:about.recentReleases")}),e.jsx("div",{className:"about-releases-list",children:o.map(h=>e.jsxs("a",{href:h.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:`about-release-item ${h.version===`v${d}`||h.version===d?"current":""}`,children:[e.jsx("span",{className:"about-release-version",children:h.version}),e.jsx("span",{className:"about-release-date",children:u(h.publishedAt)})]},h.version))})]})]}),e.jsx("div",{className:"about-description",children:s("config:about.tagline")}),e.jsxs("div",{className:"about-principles",children:[e.jsx("div",{className:"about-principles-title",children:s("config:about.corePrinciples")}),e.jsxs("ul",{className:"about-principles-list",children:[e.jsx("li",{children:s("config:about.principle1")}),e.jsx("li",{children:s("config:about.principle2")}),e.jsx("li",{children:s("config:about.principle3")}),e.jsx("li",{children:s("config:about.principle4")})]})]}),e.jsx("div",{className:"about-links",children:e.jsxs("a",{href:"https://github.com/deivid11/tide-commander",target:"_blank",rel:"noopener noreferrer",className:"about-link",children:[e.jsx("span",{className:"about-link-icon",children:e.jsx(L,{name:"package",size:14})}),e.jsx("span",{children:s("config:about.repository")})]})}),e.jsxs("div",{className:"about-credits",children:[e.jsx("div",{className:"about-credits-title",children:s("config:about.specialThanks")}),e.jsxs("div",{className:"about-credit-item",children:[e.jsx("a",{href:"https://kenney.nl",target:"_blank",rel:"noopener noreferrer",className:"about-credit-link",children:"Kenney.nl"}),e.jsx("span",{className:"about-credit-desc",children:s("config:about.kenneyCredit")})]}),e.jsxs("div",{className:"about-credit-item",children:[e.jsx("a",{href:"https://claude.ai/code",target:"_blank",rel:"noopener noreferrer",className:"about-credit-link",children:"Claude Code"}),e.jsx("span",{className:"about-credit-desc",children:s("config:about.claudeCodeCredit")})]})]})]})}const Hs={gmail:"✉️",slack:"💬",jira:"📋","google-calendar":"📅",docx:"📄"};function Ys({onOpenModal:s}){const[i,a]=c.useState([]),[o,m]=c.useState(!0),f=c.useCallback(async()=>{try{const d=await Ne(re("/api/integrations"));if(!d.ok)return;const n=await d.json();a(n)}catch{}finally{m(!1)}},[]);return c.useEffect(()=>{f()},[f]),o?e.jsx("div",{style:{color:"var(--text-secondary, #a6adc8)",fontSize:12,padding:"4px 0"},children:"Loading..."}):i.length===0?e.jsx("div",{style:{color:"var(--text-secondary, #a6adc8)",fontSize:12,padding:"4px 0"},children:"No integrations available."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[i.map(d=>{const n=Hs[d.id]||"🔌",g=!!d.status.error,T=d.status.connected,y=g?"#f38ba8":T?"#a6e3a1":"#fab387",S=g?"Error":T?"Connected":"Setup Required",u=g?"✗":T?"✓":"⚠";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:6,background:"var(--surface-1, #181825)",border:"1px solid var(--border, #313244)",fontSize:13},children:[e.jsx("span",{style:{fontSize:15,flexShrink:0},children:n}),e.jsx("span",{style:{flex:1,color:"var(--text-primary, #cdd6f4)",fontWeight:500},children:d.name}),e.jsxs("span",{style:{color:y,fontSize:11,fontWeight:500,whiteSpace:"nowrap"},children:[u," ",S]}),e.jsx("button",{onClick:()=>s(d.id),title:`Configure ${d.name}`,style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",fontSize:14,color:"var(--text-secondary, #a6adc8)",borderRadius:4,flexShrink:0},onMouseEnter:h=>{h.target.style.color="var(--text-primary, #cdd6f4)"},onMouseLeave:h=>{h.target.style.color="var(--text-secondary, #a6adc8)"},children:"⚙️"})]},d.id)}),e.jsx("button",{onClick:()=>s(),style:{background:"none",border:"1px dashed var(--border, #313244)",borderRadius:6,padding:"6px 8px",cursor:"pointer",color:"var(--text-secondary, #a6adc8)",fontSize:12,textAlign:"center",marginTop:2},onMouseEnter:d=>{d.target.style.borderColor="var(--accent, #89b4fa)",d.target.style.color="var(--accent, #89b4fa)"},onMouseLeave:d=>{d.target.style.borderColor="var(--border, #313244)",d.target.style.color="var(--text-secondary, #a6adc8)"},children:"Manage All Integrations"})]})}function Js({isOpen:s,onClose:i}){const{t:a}=se(["config"]),[o,m]=c.useState(""),[f,d]=c.useState(""),[n,g]=c.useState(!0),[T,y]=c.useState(null),[S,u]=c.useState(null),[h,p]=c.useState(!1),[N,x]=c.useState(!1),[r,F]=c.useState(!1);c.useEffect(()=>{s&&R()},[s]);const R=async()=>{try{g(!0),y(null),u(null);const O=await Fs();m(O),d(O),p(!1)}catch(O){y(O instanceof Error?O.message:"Failed to load system prompt")}finally{g(!1)}},$=O=>{const q=O.target.value;m(q),p(q!==f),y(null),u(null)},v=async()=>{try{y(null),u(null),await Os(o),d(o),p(!1),u(a("config:systemPrompt.saved"))}catch(O){y(O instanceof Error?O.message:"Failed to save system prompt")}},C=()=>{x(!0)},M=async()=>{try{y(null),u(null),await Ds(),m(""),d(""),p(!1),u(a("config:systemPrompt.cleared"))}catch(O){y(O instanceof Error?O.message:"Failed to clear system prompt")}},K=()=>{m(f),p(!1),y(null),u(null)},G=()=>{if(h){F(!0);return}i()},V=O=>{O.key==="Escape"&&(O.preventDefault(),G())};return s?e.jsxs(Me,{children:[e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:G,children:e.jsxs("div",{className:"system-prompt-modal",onClick:O=>O.stopPropagation(),onKeyDown:V,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:a("config:systemPrompt.title")}),e.jsx("button",{className:"modal-close",onClick:G,"aria-label":"Close",children:e.jsx(L,{name:"close",size:16})})]}),e.jsx("div",{className:"modal-body",children:n?e.jsxs("div",{className:"loading-state",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:"Loading system prompt..."})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"modal-description",children:a("config:systemPrompt.description")}),T&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:"warn",size:14})}),T]}),S&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:"check",size:14})}),S]}),e.jsxs("div",{className:"editor-wrapper",children:[e.jsxs("div",{className:"editor-header",children:[e.jsx("label",{htmlFor:"prompt-input",className:"editor-label",children:a("config:systemPrompt.editPrompt")}),e.jsxs("span",{className:"char-count",children:[o.length," ",a("config:systemPrompt.characters")]})]}),e.jsx("textarea",{id:"prompt-input",className:"prompt-editor",value:o,onChange:$,placeholder:a("config:systemPrompt.placeholder"),rows:18,autoFocus:!0}),e.jsx("div",{className:"editor-hint",children:a("config:systemPrompt.hint")})]})]})}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("div",{className:"footer-buttons-left",children:e.jsx("button",{className:"btn btn-danger",onClick:C,disabled:!o||n,children:a("config:systemPrompt.clear")})}),e.jsxs("div",{className:"footer-buttons-right",children:[e.jsx("button",{className:"btn btn-secondary",onClick:G,children:"Close"}),e.jsx("button",{className:"btn btn-secondary",onClick:K,disabled:!h||n,children:a("config:systemPrompt.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:v,disabled:!h||n,children:a("config:systemPrompt.save")})]})]})]})}),e.jsx(fe,{isOpen:N,title:a("config:systemPrompt.clear"),message:a("config:systemPrompt.confirmClear"),confirmLabel:a("config:systemPrompt.clear"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{M()},onClose:()=>x(!1)}),e.jsx(fe,{isOpen:r,title:"Unsaved Changes",message:"You have unsaved changes. Close anyway?",confirmLabel:"Close anyway",cancelLabel:"Keep editing",variant:"danger",onConfirm:i,onClose:()=>F(!1)})]}):null}const Be={enabled:!1,baseUrl:"",defaultSessionId:"",webhookVerifyToken:"",showIncomingToasts:!0},Zs=2500,Xs=12e4;function Ke(s){return{enabled:s.enabled??!1,baseUrl:s.baseUrl??"",defaultSessionId:s.defaultSessionId??"",webhookVerifyToken:s.webhookVerifyToken??"",showIncomingToasts:s.showIncomingToasts??!0}}function Qs(s,i){return s.enabled===i.enabled&&s.baseUrl===i.baseUrl&&s.defaultSessionId===i.defaultSessionId&&s.webhookVerifyToken===i.webhookVerifyToken&&s.showIncomingToasts===i.showIncomingToasts}function ea({isOpen:s,onClose:i}){const{t:a}=se(["config"]),[o,m]=c.useState(Be),[f,d]=c.useState(Be),[n,g]=c.useState(!1),[T,y]=c.useState([]),[S,u]=c.useState(!0),[h,p]=c.useState(null),[N,x]=c.useState(null),[r,F]=c.useState(""),[R,$]=c.useState(!1),[v,C]=c.useState(""),[M,K]=c.useState(null),[G,V]=c.useState(null),[O,q]=c.useState(null),ee=c.useRef(null),ne=c.useRef(0),[b,E]=c.useState(""),[z,j]=c.useState(""),[P,D]=c.useState(null),[Y,J]=c.useState(!1),[Z,H]=c.useState(!1),[xe,de]=c.useState(!1),[A,X]=c.useState(!1),[pe,ge]=c.useState(null),be=!Qs(o,f),te=c.useCallback(()=>{ee.current&&(clearTimeout(ee.current),ee.current=null)},[]),je=c.useCallback(async()=>{try{u(!0),p(null),x(null);const[l,I]=await Promise.all([as(),ts()]),B=Ke(l);if(m(B),d(B),g(!!I.configured),I.configured)try{const ce=await _e();y(Array.isArray(ce)?ce:[])}catch{y([])}else y([])}catch(l){p(l instanceof Error?l.message:a("config:whatsapp.errors.loadFailed"))}finally{u(!1)}},[a]),me=c.useCallback(async()=>{try{const l=await _e();y(Array.isArray(l)?l:[])}catch{}},[]);c.useEffect(()=>(s?je():(te(),K(null),V(null),q(null),F(""),$(!1),D(null)),()=>{te()}),[s,je,te]);const le=(l,I)=>{m(B=>({...B,[l]:I})),p(null),x(null)},Te=async()=>{try{p(null),x(null);const l=await cs({enabled:o.enabled,baseUrl:o.baseUrl.trim(),defaultSessionId:o.defaultSessionId.trim(),webhookVerifyToken:o.webhookVerifyToken,showIncomingToasts:o.showIncomingToasts});window.dispatchEvent(new CustomEvent("tide:whatsapp-config-updated"));const I=Ke(l);m(I),d(I),x(a("config:whatsapp.saved"))}catch(l){p(l instanceof Error?l.message:a("config:whatsapp.errors.saveFailed"))}},Ie=()=>{m(f),p(null),x(null)},ue=()=>{if(be){H(!0);return}i()},Ee=l=>{l.key==="Escape"&&(l.preventDefault(),ue())},we=async()=>{const l=r.trim();if(l)try{p(null),x(null),await os(l),F(""),$(!1),g(!0),x(a("config:whatsapp.apiKeySaved"))}catch(I){p(I instanceof Error?I.message:a("config:whatsapp.errors.apiKeySaveFailed"))}},oe=()=>{de(!0)},ie=async()=>{try{p(null),x(null),await rs(),g(!1),x(a("config:whatsapp.apiKeyCleared"))}catch(l){p(l instanceof Error?l.message:a("config:whatsapp.errors.apiKeyClearFailed"))}},ve=c.useCallback(async l=>{if(Date.now()>ne.current){q(a("config:whatsapp.pairingTimeout")),K(null),V(null),te(),me();return}try{const I=await ns(l);if(I.status&&["connected","paired","open","ready"].includes(I.status.toLowerCase())){q(a("config:whatsapp.pairingSuccess")),K(null),V(null),te(),me();return}const ce=I.qrUrl??I.qr??null;ce&&V(ce)}catch(I){q(I instanceof Error?I.message:a("config:whatsapp.errors.qrFetchFailed"))}ee.current=setTimeout(()=>{ve(l)},Zs)},[me,te,a]),ke=async()=>{const l=v.trim();if(l)try{p(null),x(null),q(null),V(null),te(),await is(l),C(""),K(l),ne.current=Date.now()+Xs,ve(l),me()}catch(I){p(I instanceof Error?I.message:a("config:whatsapp.errors.sessionCreateFailed"))}},Se=()=>{te(),K(null),V(null),q(null)},_=l=>{ge(l),X(!0)},Ce=async()=>{if(pe)try{p(null),x(null),await ds(pe),M===pe&&Se(),me(),x(a("config:whatsapp.sessionDeleted"))}catch(l){p(l instanceof Error?l.message:a("config:whatsapp.errors.sessionDeleteFailed"))}finally{ge(null)}},t=async()=>{const l=b.trim(),I=z.trim();if(!(!l||!I))try{J(!0),D(null);const B=o.defaultSessionId.trim()||void 0;await ls(l,I,B),D({kind:"success",text:a("config:whatsapp.testSent")})}catch(B){D({kind:"error",text:B instanceof Error?B.message:a("config:whatsapp.errors.testSendFailed")})}finally{J(!1)}};return s?e.jsxs(Me,{children:[e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:ue,children:e.jsxs("div",{className:"whatsapp-config-modal",onClick:l=>l.stopPropagation(),onKeyDown:Ee,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:a("config:whatsapp.title")}),e.jsx("button",{className:"modal-close",onClick:ue,"aria-label":"Close",children:e.jsx(L,{name:"close",size:16})})]}),e.jsx("div",{className:"modal-body",children:S?e.jsxs("div",{className:"loading-state",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:a("config:whatsapp.loading")})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"modal-description",children:a("config:whatsapp.description")}),h&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:"warn",size:14})}),h]}),N&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:"check",size:14})}),N]}),e.jsxs("section",{className:"wa-section",children:[e.jsx("h3",{className:"wa-section-title",children:a("config:whatsapp.sections.general")}),e.jsxs("div",{className:"wa-field wa-field-row",children:[e.jsx("label",{htmlFor:"wa-enabled",className:"wa-label",children:a("config:whatsapp.enabled")}),e.jsxs("label",{className:"wa-toggle",children:[e.jsx("input",{id:"wa-enabled",type:"checkbox",checked:o.enabled,onChange:l=>le("enabled",l.target.checked)}),e.jsx("span",{className:"wa-toggle-track",children:e.jsx("span",{className:"wa-toggle-thumb"})})]})]}),e.jsxs("div",{className:"wa-field wa-field-row",children:[e.jsx("label",{htmlFor:"wa-show-toasts",className:"wa-label",children:a("config:whatsapp.showIncomingToasts")}),e.jsxs("label",{className:"wa-toggle",children:[e.jsx("input",{id:"wa-show-toasts",type:"checkbox",checked:o.showIncomingToasts,onChange:l=>le("showIncomingToasts",l.target.checked)}),e.jsx("span",{className:"wa-toggle-track",children:e.jsx("span",{className:"wa-toggle-thumb"})})]})]}),e.jsx("span",{className:"wa-hint",children:a("config:whatsapp.showIncomingToastsHelp")}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-base-url",className:"wa-label",children:a("config:whatsapp.baseUrl")}),e.jsx("input",{id:"wa-base-url",type:"text",className:"wa-input",placeholder:"http://localhost:3007",value:o.baseUrl,onChange:l=>le("baseUrl",l.target.value)})]}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-default-session",className:"wa-label",children:a("config:whatsapp.defaultSessionId")}),e.jsx("input",{id:"wa-default-session",type:"text",className:"wa-input",placeholder:a("config:whatsapp.defaultSessionIdPlaceholder"),value:o.defaultSessionId,onChange:l=>le("defaultSessionId",l.target.value)})]}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-webhook-token",className:"wa-label",children:a("config:whatsapp.webhookVerifyToken")}),e.jsx("input",{id:"wa-webhook-token",type:"text",className:"wa-input",placeholder:a("config:whatsapp.webhookVerifyTokenPlaceholder"),value:o.webhookVerifyToken,onChange:l=>le("webhookVerifyToken",l.target.value)})]})]}),e.jsxs("section",{className:"wa-section",children:[e.jsx("h3",{className:"wa-section-title",children:a("config:whatsapp.sections.apiKey")}),e.jsx("div",{className:"wa-key-status",children:n?e.jsxs("span",{className:"wa-status wa-status-ok",children:[e.jsx(L,{name:"check",size:12})," ",a("config:whatsapp.configured")]}):e.jsxs("span",{className:"wa-status wa-status-warn",children:[e.jsx(L,{name:"warn",size:12})," ",a("config:whatsapp.notConfigured")]})}),e.jsxs("div",{className:"wa-field wa-field-inline",children:[e.jsx("input",{type:R?"text":"password",className:"wa-input",placeholder:a("config:whatsapp.apiKeyPlaceholder"),value:r,onChange:l=>F(l.target.value)}),e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>$(l=>!l),title:a(R?"config:whatsapp.hideKey":"config:whatsapp.showKey"),children:e.jsx(L,{name:R?"eye-closed":"eye",size:14})}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:we,disabled:!r.trim(),children:a("config:whatsapp.saveKey")}),e.jsx("button",{type:"button",className:"btn btn-danger",onClick:oe,disabled:!n,children:a("config:whatsapp.clearKey")})]}),e.jsx("span",{className:"wa-hint",children:a("config:whatsapp.apiKeyHint")})]}),e.jsxs("section",{className:"wa-section",children:[e.jsx("h3",{className:"wa-section-title",children:a("config:whatsapp.sections.sessions")}),e.jsx("div",{className:"wa-sessions-list",children:!Array.isArray(T)||T.length===0?e.jsx("div",{className:"wa-empty",children:a("config:whatsapp.noSessions")}):T.map(l=>e.jsxs("div",{className:"wa-session-row",children:[e.jsxs("div",{className:"wa-session-info",children:[e.jsx("span",{className:"wa-session-id",children:l.id}),e.jsx("span",{className:`wa-session-status status-${(l.status??"unknown").toLowerCase()}`,children:l.status||"—"}),l.pairedNumber&&e.jsx("span",{className:"wa-session-paired",children:l.pairedNumber})]}),e.jsx("button",{type:"button",className:"btn btn-danger btn-sm",onClick:()=>_(l.id),children:a("config:whatsapp.deleteSession")})]},l.id))}),e.jsxs("div",{className:"wa-field wa-field-inline",children:[e.jsx("input",{type:"text",className:"wa-input",placeholder:a("config:whatsapp.addSessionPlaceholder"),value:v,onChange:l=>C(l.target.value),onKeyDown:l=>{l.key==="Enter"&&ke()}}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:ke,disabled:!v.trim()||M!==null,children:a("config:whatsapp.addSession")})]}),M&&e.jsxs("div",{className:"wa-qr-panel",children:[e.jsxs("div",{className:"wa-qr-header",children:[e.jsx("span",{children:a("config:whatsapp.qrPrompt",{id:M})}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Se,children:a("config:whatsapp.cancelPairing")})]}),G?e.jsx("div",{className:"wa-qr-image",children:e.jsx("img",{src:G,alt:"WhatsApp pairing QR code"})}):e.jsxs("div",{className:"wa-qr-loading",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:a("config:whatsapp.waitingForQr")})]})]}),O&&!M&&e.jsx("div",{className:"wa-pairing-message",children:O})]}),e.jsxs("section",{className:"wa-section",children:[e.jsx("h3",{className:"wa-section-title",children:a("config:whatsapp.sections.testMessage")}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-test-to",className:"wa-label",children:a("config:whatsapp.testTo")}),e.jsx("input",{id:"wa-test-to",type:"text",className:"wa-input",placeholder:a("config:whatsapp.testToPlaceholder"),value:b,onChange:l=>E(l.target.value)})]}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-test-message",className:"wa-label",children:a("config:whatsapp.testMessageBody")}),e.jsx("textarea",{id:"wa-test-message",className:"wa-textarea",rows:4,placeholder:a("config:whatsapp.testMessageBodyPlaceholder"),value:z,onChange:l=>j(l.target.value)})]}),e.jsx("div",{className:"wa-field-inline wa-field-end",children:e.jsx("button",{type:"button",className:"btn btn-primary",onClick:t,disabled:!b.trim()||!z.trim()||Y,children:a(Y?"config:whatsapp.sending":"config:whatsapp.sendTest")})}),P&&e.jsxs("div",{className:`alert ${P.kind==="success"?"alert-success":"alert-error"}`,children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:P.kind==="success"?"check":"warn",size:14})}),P.text]})]})]})}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("div",{className:"footer-buttons-left"}),e.jsxs("div",{className:"footer-buttons-right",children:[e.jsx("button",{className:"btn btn-secondary",onClick:ue,children:a("config:whatsapp.close")}),e.jsx("button",{className:"btn btn-secondary",onClick:Ie,disabled:!be||S,children:a("config:whatsapp.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:Te,disabled:!be||S,children:a("config:whatsapp.save")})]})]})]})}),e.jsx(fe,{isOpen:Z,title:a("config:whatsapp.unsavedTitle"),message:a("config:whatsapp.unsavedMessage"),confirmLabel:a("config:whatsapp.closeAnyway"),cancelLabel:a("config:whatsapp.keepEditing"),variant:"danger",onConfirm:()=>{H(!1),i()},onClose:()=>H(!1)}),e.jsx(fe,{isOpen:xe,title:a("config:whatsapp.clearKey"),message:a("config:whatsapp.confirmClearKey"),confirmLabel:a("config:whatsapp.clearKey"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{ie()},onClose:()=>de(!1)}),e.jsx(fe,{isOpen:A,title:a("config:whatsapp.deleteSession"),message:a("config:whatsapp.confirmDeleteSession",{id:pe??""}),confirmLabel:a("config:whatsapp.deleteSession"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{Ce()},onClose:()=>{X(!1),ge(null)}})]}):null}const sa=[{value:"auto",label:"Auto",icon:"🕐"},{value:"dawn",label:"Dawn",icon:"🌅"},{value:"day",label:"Day",icon:"☀️"},{value:"dusk",label:"Dusk",icon:"🌇"},{value:"night",label:"Night",icon:"🌙"}],aa=[{value:"none",label:"Grass",icon:"🌱"},{value:"concrete",label:"Concrete",icon:"🏗️"},{value:"galactic",label:"Galactic",icon:"🌌"},{value:"metal",label:"Metal",icon:"⚙️"},{value:"hex",label:"Hex",icon:"⬡"},{value:"circuit",label:"Circuit",icon:"🔌"},{value:"pokemon-stadium",label:"Pokemon",icon:"🔴"}],ta=[{value:"static",label:"Static",icon:"🧍"},{value:"idle",label:"Idle",icon:"🚶"},{value:"walk",label:"Walk",icon:"🚶♂️"},{value:"sprint",label:"Sprint",icon:"🏃"},{value:"jump",label:"Jump",icon:"⬆️"},{value:"fall",label:"Fall",icon:"⬇️"},{value:"crouch",label:"Crouch",icon:"🧎"},{value:"sit",label:"Sit",icon:"🪑"},{value:"die",label:"Die",icon:"💀"},{value:"emote-yes",label:"Yes",icon:"👍"},{value:"emote-no",label:"No",icon:"👎"}],na=[{value:"normal",label:"Normal",icon:"🎨"},{value:"bw",label:"B&W",icon:"⬛"},{value:"sepia",label:"Sepia",icon:"🟤"},{value:"cool",label:"Cool",icon:"❄️"},{value:"warm",label:"Warm",icon:"🔥"},{value:"neon",label:"Neon",icon:"💜"}],oa=[{key:"showTrees",icon:"🌳",label:"Trees"},{key:"showBushes",icon:"🌿",label:"Bushes"},{key:"showHouse",icon:"🏠",label:"House"},{key:"showLamps",icon:"💡",label:"Lamps"},{key:"showGrass",icon:"🟩",label:"Grass"},{key:"showClouds",icon:"☁️",label:"Clouds"}],ia=[{value:null,label:"Auto",color:"linear-gradient(135deg, #4a90d9 0%, #0a1a2a 100%)"},{value:"#4a90d9",label:"Day Blue",color:"#4a90d9"},{value:"#0a1a2a",label:"Night",color:"#0a1a2a"},{value:"#ff6b35",label:"Sunset",color:"#ff6b35"},{value:"#1a0a2e",label:"Purple",color:"#1a0a2e"},{value:"#2d5a27",label:"Matrix",color:"#2d5a27"},{value:"#8b0000",label:"Blood",color:"#8b0000"},{value:"#000000",label:"Void",color:"#000000"}],la={showTrees:"trees",showBushes:"bushes",showHouse:"house",showLamps:"lamps",showGrass:"grass",showClouds:"clouds"},ca={none:"grass","pokemon-stadium":"pokemon"},ra={"emote-yes":"yes","emote-no":"no"},da={"":"auto","#4a90d9":"dayBlue","#0a1a2a":"night","#ff6b35":"sunset","#1a0a2e":"purple","#2d5a27":"matrix","#8b0000":"blood","#000000":"void"};function Q({checked:s,onChange:i}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,onChange:a=>i(a.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function he({options:s,value:i,onChange:a,iconOnly:o=!1}){return e.jsx("div",{className:"chip-selector",children:s.map(m=>e.jsxs("button",{className:`chip ${i===m.value?"active":""}`,onClick:()=>a(m.value),title:m.label,children:[e.jsx("span",{className:"chip-icon",children:m.icon}),!o&&e.jsx("span",{className:"chip-label",children:m.label})]},m.value))})}function w({text:s,query:i}){if(!i.trim())return e.jsx(e.Fragment,{children:s});const a=s.toLowerCase(),o=i.toLowerCase(),m=a.indexOf(o);if(m===-1)return e.jsx(e.Fragment,{children:s});const f=s.slice(0,m),d=s.slice(m,m+i.length),n=s.slice(m+i.length);return e.jsxs(e.Fragment,{children:[f,e.jsx("mark",{className:"search-highlight",children:d}),n]})}const ma=[{id:"general",title:"General",keywords:["history","hide costs","grid","fps","power saving","performance","limit","editor","external editor","language","idioma","语言","vibration","haptic","intensity","tab title","tmux","process persistence"]},{id:"agentNames",title:"Agent Names",keywords:["agent","names","custom","characters","rename"]},{id:"defaultClass",title:"Default Spawn Class",keywords:["default","class","spawn","agent","scout","builder","random"]},{id:"appearance",title:"Appearance",keywords:["theme","appearance","color","dark","light","style","look"]},{id:"connection",title:"Connection",keywords:["backend","url","auth","token","reconnect","server","api","connect","codex","opencode","binary","path"]},{id:"scene",title:"Scene",keywords:["character","size","indicator","scale","time","dawn","day","dusk","night","auto"]},{id:"terrain",title:"Terrain",keywords:["trees","bushes","house","lamps","grass","clouds","fog","brightness","floor","sky","color","environment","battlefield","size","grid","simple","minimal","dark","clean"]},{id:"modelStyle",title:"Agent Model Style",keywords:["saturation","roughness","metalness","glow","emissive","reflections","wireframe","color mode","material","shader"]},{id:"animations",title:"Animations",keywords:["idle","working","animation","walk","run","sprint","jump","sit","crouch"]},{id:"secrets",title:"Secrets",keywords:["secrets","api","key","password","credentials","env","environment"]},{id:"systemPrompt",title:"System Prompt",keywords:["system","prompt","global","instructions","ai","agent","rules","guidelines"]},{id:"whatsapp",title:"WhatsApp Integration",keywords:["whatsapp","message","sms","integration","notification","baileys"]},{id:"data",title:"Data",keywords:["export","import","backup","restore","save","load","json"]},{id:"integrations",title:"Integrations",keywords:["integrations","plugins","gmail","slack","jira","calendar","docx","email","config","setup"]},{id:"workflows",title:"Workflows",keywords:["workflow","automation","state machine","editor","actions","transitions","pipeline"]},{id:"triggers",title:"Triggers",keywords:["trigger","event","webhook","cron","slack","email","jira","matching","fire"]},{id:"monitoring",title:"Monitoring",keywords:["monitoring","logs","triggers","events","history","workflow","traces","audit","timeline"]},{id:"experimental",title:"Experimental",keywords:["experimental","2d","view","voice","assistant","speech","tts","text to speech","echo","prompt","duplicate"]},{id:"about",title:"About",keywords:["about","version","update","credits","github","releases"]}],Oe=[{value:"auto",label:"Auto",icon:"🌐"},{value:"en",label:"English",icon:"🇺🇸"},{value:"zh-CN",label:"中文",icon:"🇨🇳"},{value:"es",label:"Español",icon:"🇪🇸"},{value:"hi",label:"हिन्दी",icon:"🇮🇳"},{value:"pt",label:"Português",icon:"🇧🇷"},{value:"ru",label:"Русский",icon:"🇷🇺"},{value:"ja",label:"日本語",icon:"🇯🇵"},{value:"de",label:"Deutsch",icon:"🇩🇪"},{value:"fr",label:"Français",icon:"🇫🇷"},{value:"it",label:"Italiano",icon:"🇮🇹"}];function ua({config:s,onChange:i,searchQuery:a="",onOpenIntegrationsModal:o,onOpenMonitoringModal:m,onOpenWorkflowEditor:f,onOpenTriggerManager:d}){var Ce;const{t:n}=se(["config","common"]),g=De(),T=ms(),[y,S]=c.useState(()=>us(ye.DEFAULT_AGENT_CLASS)||"scout"),[u,h]=c.useState(g.settings.historyLimit),[p,N]=c.useState(()=>ps()),[x,r]=c.useState(!1),[F,R]=c.useState(""),[$,v]=c.useState(()=>W()),[C,M]=c.useState(!1),[K,G]=c.useState(!1),[V,O]=c.useState(""),[q,ee]=c.useState(!1),[ne,b]=c.useState(!1),[E,z]=c.useState(""),[j,P]=c.useState(!1);c.useEffect(()=>{_s().then(z).catch(()=>{})},[]),c.useEffect(()=>{$s().then(t=>{t!==g.settings.experimentalEchoPrompt&&k.updateSettings({experimentalEchoPrompt:t})}).catch(()=>{})},[]),c.useEffect(()=>{Rs().then(t=>{t!==g.settings.tmuxMode&&k.updateSettings({tmuxMode:t})}).catch(()=>{})},[]),c.useEffect(()=>gs(t=>{N(t),r(!1)}),[]);const D=sa.map(t=>({...t,label:n(`config:time.${t.value}`)})),Y=aa.map(t=>({...t,label:n(`config:floor.${ca[t.value]||t.value}`)})),J=ta.map(t=>({...t,label:n(`config:animation.${ra[t.value]||t.value}`)})),Z=na.map(t=>({...t,label:n(`config:colorMode.${t.value}`)})),H=oa.map(t=>({...t,label:n(`config:terrain.${la[t.key]}`)})),xe=ia.map(t=>({...t,label:n(`config:sky.${da[t.value??""]}`)})),de=a.trim()?ma.filter(t=>{const l=a.toLowerCase();return t.title.toLowerCase().includes(l)||t.keywords.some(I=>I.toLowerCase().includes(l))}).map(t=>t.id):null,A=t=>de?de.includes(t):!0,X=g.settings.customAgentNames||[],pe=X.length>0?X:hs,ge=()=>{const t=V.trim();t&&!X.includes(t)&&(k.updateSettings({customAgentNames:[...X,t]}),O(""))},be=t=>{k.updateSettings({customAgentNames:X.filter(l=>l!==t)})},te=()=>{k.updateSettings({customAgentNames:[]})},je=()=>{const t=F.trim();if(t){if(p.includes(t)){R("");return}N([...p,t]),r(!0),R("")}},me=t=>{N(p.filter((l,I)=>I!==t)),r(!0)},le=(t,l)=>{const I=t+l;if(I<0||I>=p.length)return;const B=p.slice();[B[t],B[I]]=[B[I],B[t]],N(B),r(!0)},Te=()=>{xs(p),r(!1),Fe()},Ie=t=>{v(t),M(!0)},ue=()=>{Ae(ye.AUTH_TOKEN,$),M(!1),Fe()},Ee=t=>{z(t),P(!0)},we=()=>{Us(E).catch(()=>{}),P(!1)},oe=t=>{i({...s,terrain:{...s.terrain,...t}})},ie=t=>{i({...s,modelStyle:{...s.modelStyle,...t}})},ve=t=>{i({...s,animations:{...s.animations,...t}})},ke=t=>{h(t),k.updateSettings({historyLimit:t})},Se=t=>{const l=s.terrain[t];typeof l=="boolean"&&oe({[t]:!l})},_=a.trim().length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"config-section",children:[de&&de.length===0&&e.jsx("div",{className:"config-no-results",children:n("config:noResults",{query:a})}),A("general")&&e.jsxs(U,{title:n("config:sections.general"),storageKey:"general",defaultOpen:!0,forceOpen:_&&A("general"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.history"),query:a})}),e.jsx("input",{type:"number",className:"config-input config-input-sm",value:u,onChange:t=>ke(parseInt(t.target.value)||100),min:50,max:2e3,step:50})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.hideCosts"),query:a})}),e.jsx(Q,{checked:g.settings.hideCost,onChange:t=>k.updateSettings({hideCost:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.grid"),query:a})}),e.jsx(Q,{checked:s.gridVisible,onChange:t=>i({...s,gridVisible:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.showFPS"),query:a})}),e.jsx(Q,{checked:g.settings.showFPS,onChange:t=>k.updateSettings({showFPS:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.fpsLimit"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"120",step:"10",value:s.fpsLimit,onChange:t=>i({...s,fpsLimit:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.fpsLimit===0?"∞":s.fpsLimit})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Experimental: Reduce FPS when idle to save power",children:[e.jsx(w,{text:n("config:general.powerSaving"),query:a})," ",e.jsx(L,{name:"bolt",size:12})]}),e.jsx(Q,{checked:g.settings.powerSaving,onChange:t=>k.updateSettings({powerSaving:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",title:"Wrap agent processes in tmux sessions so they survive server restarts (requires tmux installed)",children:e.jsx(w,{text:n("config:general.tmuxMode"),query:a})}),e.jsx(Q,{checked:g.settings.tmuxMode,onChange:async t=>{k.updateSettings({tmuxMode:t});try{await Bs(t)}catch(l){console.error("Failed to sync tmux mode setting to server:",l)}}})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.vibrationIntensity"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"5",step:"1",value:g.settings.vibrationIntensity,onChange:t=>k.updateSettings({vibrationIntensity:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:g.settings.vibrationIntensity===0?n("config:vibrationValues.off"):g.settings.vibrationIntensity===1?n("config:vibrationValues.ultraLight"):g.settings.vibrationIntensity===2?n("config:vibrationValues.veryLight"):g.settings.vibrationIntensity===3?n("config:vibrationValues.light"):g.settings.vibrationIntensity===4?n("config:vibrationValues.medium"):n("config:vibrationValues.heavy")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.externalEditor"),query:a})}),e.jsx("input",{type:"text",className:"config-input",placeholder:n("config:general.externalEditorPlaceholder"),value:g.settings.externalEditorCommand||"",onChange:t=>k.updateSettings({externalEditorCommand:t.target.value})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.tabTitle"),query:a})}),e.jsx("input",{type:"text",className:"config-input",placeholder:n("config:general.tabTitlePlaceholder"),value:g.settings.tabTitle||"",onChange:t=>k.updateSettings({tabTitle:t.target.value})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.language"),query:a})}),e.jsx(he,{options:Oe,value:localStorage.getItem("tide-commander-language-mode")==="manual"?((Ce=Oe.find(t=>t.value!=="auto"&&Le.language.startsWith(t.value.split("-")[0])))==null?void 0:Ce.value)||"en":"auto",onChange:t=>{var l;if(t==="auto"){localStorage.setItem("tide-commander-language-mode","auto");const I=navigator.language,B=((l=Oe.find(ce=>ce.value!=="auto"&&I.startsWith(ce.value.split("-")[0])))==null?void 0:l.value)||"en";Le.changeLanguage(B)}else localStorage.setItem("tide-commander-language-mode","manual"),Le.changeLanguage(t)}})]})]}),A("agentNames")&&e.jsx(U,{title:n("config:sections.agentNames"),storageKey:"agentNames",defaultOpen:!1,forceOpen:_&&A("agentNames"),children:e.jsxs("div",{className:"agent-names-section",children:[e.jsx("span",{className:"config-hint",children:X.length>0?n("config:agentNames.customConfigured",{count:X.length}):n("config:agentNames.usingDefaults")}),e.jsxs("div",{className:"agent-names-input-row",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",placeholder:n("config:agentNames.addPlaceholder"),value:V,onChange:t=>O(t.target.value),onKeyDown:t=>{t.key==="Enter"&&ge()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:ge,disabled:!V.trim(),title:n("config:agentNames.addName"),children:"+"})]}),e.jsx("div",{className:"agent-names-list",children:pe.map((t,l)=>e.jsxs("div",{className:"agent-name-chip",children:[e.jsx("span",{className:"agent-name-text",children:t}),X.length>0&&e.jsx("button",{className:"agent-name-remove",onClick:()=>be(t),title:n("common:buttons.remove"),children:"x"})]},`${t}-${l}`))}),X.length>0&&e.jsx("button",{className:"config-btn config-btn-link",onClick:te,children:n("common:buttons.resetToDefaults")})]})}),A("defaultClass")&&e.jsx(U,{title:"Default Spawn Class",storageKey:"defaultClass",defaultOpen:!1,forceOpen:_&&A("defaultClass"),children:e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-hint",children:'Class pre-selected when the spawn modal opens. "Random" picks a different class each time.'}),e.jsxs("div",{className:"agent-names-list",style:{flexWrap:"wrap",gap:"6px",marginTop:"8px"},children:[e.jsx("div",{className:`agent-name-chip${y==="random"?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{S("random"),Ae(ye.DEFAULT_AGENT_CLASS,"random")},children:e.jsx("span",{className:"agent-name-text",children:"🎲 Random"})}),Object.entries(fs).map(([t,l])=>e.jsx("div",{className:`agent-name-chip${y===t?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{S(t),Ae(ye.DEFAULT_AGENT_CLASS,t)},children:e.jsxs("span",{className:"agent-name-text",children:[l.icon," ",t.charAt(0).toUpperCase()+t.slice(1)]})},t)),T.map(t=>e.jsx("div",{className:`agent-name-chip${y===t.id?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{S(t.id),Ae(ye.DEFAULT_AGENT_CLASS,t.id)},children:e.jsxs("span",{className:"agent-name-text",children:[t.icon," ",t.name]})},t.id))]})]})}),A("appearance")&&e.jsx(U,{title:n("config:sections.appearance"),storageKey:"appearance",defaultOpen:!1,forceOpen:_&&A("appearance"),children:e.jsx(Ws,{})}),A("connection")&&e.jsxs(U,{title:n("config:sections.connection"),storageKey:"connection",defaultOpen:!1,forceOpen:_&&A("connection"),children:[e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:connection.backendUrl"),query:a})}),e.jsx("div",{className:"backend-urls-list",children:p.map((t,l)=>e.jsxs("div",{className:"backend-url-row",children:[e.jsx("span",{className:"backend-url-priority",title:n("config:connection.priorityLabel",{defaultValue:"Priority"}),children:l+1}),e.jsx("span",{className:"backend-url-text",title:t,children:t}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>le(l,-1),disabled:l===0,title:n("config:connection.moveUp",{defaultValue:"Move up"}),children:"↑"}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>le(l,1),disabled:l===p.length-1,title:n("config:connection.moveDown",{defaultValue:"Move down"}),children:"↓"}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>me(l),title:n("common:buttons.remove"),children:"x"})]},`${t}-${l}`))}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:F,onChange:t=>R(t.target.value),placeholder:n("config:connection.addUrlPlaceholder",{defaultValue:"http://host:port"}),onKeyDown:t=>{t.key==="Enter"&&je()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:je,disabled:!F.trim(),title:n("config:connection.addUrl",{defaultValue:"Add URL"}),children:"+"}),x&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:Te,title:n("config:connection.saveAndReconnect"),children:n("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:n("config:connection.urlsHint",{defaultValue:"Tried in order on connect; the first reachable host wins. Leave empty for auto-detect."})})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:connection.authToken"),query:a})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:K?"text":"password",className:"config-input config-input-full",value:$,onChange:t=>Ie(t.target.value),placeholder:n("config:connection.tokenPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&C&&ue()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>G(!K),title:n(K?"config:connection.hideToken":"config:connection.showToken"),children:e.jsx(L,{name:K?"eye-closed":"eye",size:14})}),C&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:ue,title:n("config:connection.saveAndReconnect"),children:n("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:n("config:connection.tokenRequired")})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:connection.codexBinaryPath"),query:a})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:E,onChange:t=>Ee(t.target.value),placeholder:n("config:connection.codexBinaryPathPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&j&&we()}}),j&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:we,children:n("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:n("config:connection.codexBinaryPathHint")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("common:buttons.reconnect"),query:a})}),e.jsx("button",{className:"config-btn",onClick:()=>Fe(),title:"Force reconnect to server",children:n("common:buttons.reconnect")})]})]}),A("scene")&&e.jsxs(U,{title:n("config:sections.scene"),storageKey:"scene",defaultOpen:!1,forceOpen:_&&A("scene"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:scene.characterSize"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"3.0",step:"0.1",value:s.characterScale,onChange:t=>i({...s,characterScale:parseFloat(t.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.characterScale.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:scene.scale2d",{defaultValue:"2D Scale"}),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"2.0",step:"0.1",value:s.scale2d,onChange:t=>i({...s,scale2d:parseFloat(t.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.scale2d.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:scene.scale3d",{defaultValue:"3D Scale"}),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"2.0",step:"0.1",value:s.scale3d,onChange:t=>i({...s,scale3d:parseFloat(t.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.scale3d.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:scene.show2DTaskLabels",{defaultValue:"Show 2D task labels"}),query:a})}),e.jsx(Q,{checked:s.show2DTaskLabels,onChange:t=>i({...s,show2DTaskLabels:t})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:scene.time"),query:a})}),e.jsx(he,{options:D,value:s.timeMode,onChange:t=>i({...s,timeMode:t}),iconOnly:!0})]})]}),A("terrain")&&e.jsxs(U,{title:n("config:sections.terrain"),storageKey:"terrain",defaultOpen:!1,forceOpen:_&&A("terrain"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:terrainSettings.simpleMode",{defaultValue:"Simple Mode"}),query:a})}),e.jsx(Q,{checked:s.terrain.simpleMode??!1,onChange:t=>oe({simpleMode:t})})]}),e.jsx("div",{className:"terrain-icons",style:{opacity:s.terrain.simpleMode?.4:1,pointerEvents:s.terrain.simpleMode?"none":"auto"},children:H.map(t=>e.jsx("button",{className:`terrain-icon-btn ${s.terrain[t.key]?"active":""}`,onClick:()=>Se(t.key),title:t.label,children:t.icon},t.key))}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:terrainSettings.fog"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.terrain.fogDensity,onChange:t=>oe({fogDensity:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.fogDensity===0?n("config:fogValues.off"):s.terrain.fogDensity<=1?n("config:fogValues.low"):n("config:fogValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:terrainSettings.brightness"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.2",max:"2",step:"0.1",value:s.terrain.brightness,onChange:t=>oe({brightness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.brightness<=.5?n("config:brightnessValues.dark"):s.terrain.brightness<=1.2?n("config:brightnessValues.normal"):n("config:brightnessValues.bright")})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:terrainSettings.floor"),query:a})}),e.jsx(he,{options:Y,value:s.terrain.floorStyle,onChange:t=>oe({floorStyle:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:terrainSettings.sky"),query:a})}),e.jsx("div",{className:"sky-color-selector",children:xe.map(t=>e.jsx("button",{className:`sky-color-btn ${s.terrain.skyColor===t.value?"active":""}`,onClick:()=>oe({skyColor:t.value}),title:t.label,style:{background:t.color}},t.value??"auto"))})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:terrainSettings.battlefieldSize"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"30",max:"200",step:"10",value:s.terrain.battlefieldSize,onChange:t=>oe({battlefieldSize:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.battlefieldSize})]})]}),A("modelStyle")&&e.jsxs(U,{title:n("config:sections.modelStyle"),storageKey:"modelStyle",defaultOpen:!1,forceOpen:_&&A("modelStyle"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:modelStyleSettings.saturation"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.modelStyle.saturation,onChange:t=>ie({saturation:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.saturation<=.3?n("config:saturationValues.gray"):s.modelStyle.saturation<=1.2?n("config:saturationValues.normal"):n("config:saturationValues.vivid")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:modelStyleSettings.roughness"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.roughness,onChange:t=>ie({roughness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.roughness<0?n("config:roughnessValues.auto"):s.modelStyle.roughness<=.3?n("config:roughnessValues.glossy"):s.modelStyle.roughness<=.7?n("config:roughnessValues.normal"):n("config:roughnessValues.matte")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:modelStyleSettings.metalness"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.metalness,onChange:t=>ie({metalness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.metalness<0?n("config:metalnessValues.auto"):s.modelStyle.metalness<=.3?n("config:metalnessValues.plastic"):s.modelStyle.metalness<=.7?n("config:metalnessValues.mixed"):n("config:metalnessValues.metal")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:modelStyleSettings.glow"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"1",step:"0.05",value:s.modelStyle.emissiveBoost,onChange:t=>ie({emissiveBoost:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.emissiveBoost<=.1?n("config:glowValues.off"):s.modelStyle.emissiveBoost<=.4?n("config:glowValues.low"):s.modelStyle.emissiveBoost<=.7?n("config:glowValues.med"):n("config:glowValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:modelStyleSettings.reflections"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"2",step:"0.1",value:s.modelStyle.envMapIntensity,onChange:t=>ie({envMapIntensity:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.envMapIntensity<0?n("config:reflectionValues.auto"):s.modelStyle.envMapIntensity<=.3?n("config:reflectionValues.low"):s.modelStyle.envMapIntensity<=1?n("config:reflectionValues.normal"):n("config:reflectionValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:modelStyleSettings.wireframe"),query:a})}),e.jsx(Q,{checked:s.modelStyle.wireframe,onChange:t=>ie({wireframe:t})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:modelStyleSettings.colorMode"),query:a})}),e.jsx(he,{options:Z,value:s.modelStyle.colorMode,onChange:t=>ie({colorMode:t}),iconOnly:!0})]})]}),A("animations")&&e.jsxs(U,{title:n("config:sections.animations"),storageKey:"animations",defaultOpen:!1,forceOpen:_&&A("animations"),children:[e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:animationSettings.idle"),query:a})}),e.jsx(he,{options:J,value:s.animations.idleAnimation,onChange:t=>ve({idleAnimation:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:animationSettings.working"),query:a})}),e.jsx(he,{options:J,value:s.animations.workingAnimation,onChange:t=>ve({workingAnimation:t}),iconOnly:!0})]})]}),A("secrets")&&e.jsx(U,{title:n("config:sections.secrets"),storageKey:"secrets",defaultOpen:!1,forceOpen:_&&A("secrets"),children:e.jsx(Ls,{})}),A("systemPrompt")&&e.jsx(U,{title:n("config:sections.systemPrompt"),storageKey:"systemPrompt",defaultOpen:!1,forceOpen:_&&A("systemPrompt"),children:e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:systemPrompt.title"),query:a})}),e.jsx("button",{className:"config-button",onClick:()=>ee(!0),children:n("config:systemPrompt.editPrompt")})]})}),A("whatsapp")&&e.jsx(U,{title:n("config:sections.whatsapp"),storageKey:"whatsapp",defaultOpen:!1,forceOpen:_&&A("whatsapp"),children:e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:whatsapp.title"),query:a})}),e.jsx("button",{className:"config-button",onClick:()=>b(!0),children:n("config:whatsapp.editConfig")})]})}),A("data")&&e.jsx(U,{title:n("config:sections.data"),storageKey:"data",defaultOpen:!1,forceOpen:_&&A("data"),children:e.jsx(Ms,{})}),A("integrations")&&e.jsx(U,{title:"Integrations",storageKey:"integrations",defaultOpen:!1,forceOpen:_&&A("integrations"),children:e.jsx(Ys,{onOpenModal:t=>o==null?void 0:o(t)})}),A("workflows")&&e.jsxs(U,{title:"Workflows",storageKey:"workflows",defaultOpen:!1,forceOpen:_&&A("workflows"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(w,{text:"Create and manage automated workflow pipelines with visual state machine editor",query:a})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>f==null?void 0:f(),children:"Open Workflow Editor"})})]}),A("triggers")&&e.jsxs(U,{title:"Triggers",storageKey:"triggers",defaultOpen:!1,forceOpen:_&&A("triggers"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(w,{text:"Create and manage event-driven triggers that fire agents with templates",query:a})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>d==null?void 0:d(),children:"Open Trigger Manager"})})]}),A("monitoring")&&e.jsxs(U,{title:"Monitoring",storageKey:"monitoring",defaultOpen:!1,forceOpen:_&&A("monitoring"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(w,{text:"View event logs, trigger history, workflow traces, and system stats",query:a})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>m==null?void 0:m(),children:"Open Monitoring & Logs"})})]}),A("experimental")&&e.jsxs(U,{title:n("config:sections.experimental"),storageKey:"experimental",defaultOpen:!1,forceOpen:_&&A("experimental"),children:[e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Lightweight 2D top-down view for better performance",children:[e.jsx(w,{text:n("config:experimental.2dView"),query:a})," ",e.jsx(L,{name:"map",size:12})]}),e.jsx(Q,{checked:g.settings.experimental2DView,onChange:t=>k.updateSettings({experimental2DView:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Voice assistant for hands-free agent control",children:[e.jsx(w,{text:n("config:experimental.voiceAssistant"),query:a})," ",e.jsx(L,{name:"microphone",size:12})]}),e.jsx(Q,{checked:g.settings.experimentalVoiceAssistant,onChange:t=>k.updateSettings({experimentalVoiceAssistant:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Text-to-speech for reading agent responses",children:[e.jsx(w,{text:n("config:experimental.tts"),query:a})," ",e.jsx(L,{name:"speaker-on",size:12})]}),e.jsx(Q,{checked:g.settings.experimentalTTS,onChange:t=>k.updateSettings({experimentalTTS:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",title:"Duplicate system prompt for improved LLM attention coverage. Increases input token usage.",children:e.jsx(w,{text:n("config:experimental.echoPrompt"),query:a})}),e.jsx(Q,{checked:g.settings.experimentalEchoPrompt,onChange:async t=>{k.updateSettings({experimentalEchoPrompt:t});try{await zs(t)}catch(l){console.error("Failed to sync echo prompt setting to server:",l)}}})]}),e.jsx("span",{className:"config-hint",children:n("config:experimental.hint")})]}),A("about")&&e.jsx(U,{title:n("config:sections.about"),storageKey:"about",defaultOpen:!1,forceOpen:_&&A("about"),children:e.jsx(Gs,{})})]}),e.jsx(Js,{isOpen:q,onClose:()=>ee(!1)}),e.jsx(ea,{isOpen:ne,onClose:()=>b(!1)})]})}function fa({onConfigChange:s,onToolChange:i,config:a,isOpen:o,onClose:m,onOpenBuildingModal:f,onOpenAreaExplorer:d,onOpenIntegrationsModal:n,onOpenMonitoringModal:g,onOpenWorkflowEditor:T,onOpenTriggerManager:y}){const{t:S}=se(["config","common"]),u=De(),h=Array.from(u.areas.values()),p=Array.from(u.buildings.values()),[N,x]=c.useState(""),r=c.useRef(null);if(c.useEffect(()=>{const v=C=>{C.key==="Escape"&&o&&m()};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[o,m]),c.useEffect(()=>{if(o&&r.current){const v=setTimeout(()=>{var C;(C=r.current)==null||C.focus()},50);return()=>clearTimeout(v)}},[o]),!o)return null;const F=v=>{const C=u.activeTool===v?null:v;i(C)},R=v=>{k.selectArea(u.selectedAreaId===v?null:v),i("select")},$=(v,C)=>{v.stopPropagation(),k.deleteArea(C)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"toolbox-backdrop",onClick:m}),e.jsxs("aside",{className:"toolbox",children:[e.jsxs("div",{className:"toolbox-header",children:[e.jsx("span",{children:S("config:title")}),e.jsx("button",{className:"toolbox-close-btn",onClick:m,title:S("common:buttons.close"),children:"×"})]}),e.jsxs("div",{className:"toolbox-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:r,type:"text",placeholder:S("config:searchPlaceholder"),value:N,onChange:v=>x(v.target.value),className:"toolbox-search-input"}),N&&e.jsx("button",{className:"toolbox-search-clear",onClick:()=>x(""),children:"×"})]}),e.jsxs("div",{className:"toolbox-content",children:[e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsxs(U,{title:S("config:areas.title",{count:h.length}),storageKey:"areas",children:[e.jsxs("div",{className:"tool-buttons",children:[e.jsx("button",{className:`tool-btn ${u.activeTool==="select"?"active":""}`,onClick:()=>F("select"),title:S("config:tools.select"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z"})})})}),e.jsx("button",{className:`tool-btn ${u.activeTool==="rectangle"?"active":""}`,onClick:()=>F("rectangle"),title:S("config:tools.rectangle"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"})})})}),e.jsx("button",{className:`tool-btn ${u.activeTool==="circle"?"active":""}`,onClick:()=>F("circle"),title:S("config:tools.circle"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("circle",{cx:"12",cy:"12",r:"9"})})})})]}),e.jsx("div",{className:"areas-list",children:h.length===0?e.jsx("div",{className:"areas-empty",children:S("config:areas.drawToCreate")}):h.map(v=>e.jsx(ks,{area:v,isSelected:u.selectedAreaId===v.id,onClick:()=>R(v.id),onDelete:C=>$(C,v.id)},v.id))})]})}),u.selectedAreaId&&e.jsx(Ps,{area:u.areas.get(u.selectedAreaId),onClose:()=>k.selectArea(null),onOpenFolder:d}),e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsx(U,{title:S("config:buildings.title",{count:p.length}),storageKey:"buildings",headerExtra:e.jsx("button",{className:"add-building-btn",onClick:v=>{v.stopPropagation(),f==null||f()},title:S("config:buildings.addBuilding"),children:"+"}),children:e.jsx("div",{className:"buildings-list",children:p.length===0?e.jsx("div",{className:"buildings-empty",children:S("config:buildings.clickToAdd")}):p.map(v=>e.jsx(Ss,{building:v,isSelected:u.selectedBuildingIds.has(v.id),onClick:()=>{k.selectBuilding(u.selectedBuildingIds.has(v.id)?null:v.id)},onEdit:()=>f==null?void 0:f(v.id)},v.id))})})}),u.selectedBuildingIds.size===1&&(()=>{const v=Array.from(u.selectedBuildingIds)[0],C=u.buildings.get(v);return C?e.jsx(Cs,{building:C,onClose:()=>k.selectBuilding(null),onOpenModal:()=>f==null?void 0:f(v)}):null})(),e.jsx(ua,{config:a,onChange:s,searchQuery:N,onOpenIntegrationsModal:n,onOpenMonitoringModal:g,onOpenWorkflowEditor:T,onOpenTriggerManager:y})]})]})]})}export{fa as Toolbox};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-
|
|
2
|
-
import{c5 as e,by as o}from"./main-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-D1aYcbd6.js","assets/main-CHfGSVnw.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-DmmvYoEs.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c5 as e,by as o}from"./main-CHfGSVnw.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";var i;(function(r){r.Heavy="HEAVY",r.Medium="MEDIUM",r.Light="LIGHT"})(i||(i={}));var t;(function(r){r.Success="SUCCESS",r.Warning="WARNING",r.Error="ERROR"})(t||(t={}));const c=e("Haptics",{web:()=>o(()=>import("./web-D1aYcbd6.js"),__vite__mapDeps([0,1,2,3,4])).then(r=>new r.HapticsWeb)});export{c as Haptics,i as ImpactStyle,t as NotificationType};
|