tide-commander 1.97.0 → 1.99.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/assets/{BossLogsModal-CT25hD17.js → BossLogsModal-CDel834o.js} +1 -1
  2. package/dist/assets/{BossSpawnModal-9rS7AFkZ.js → BossSpawnModal-BB9wL5VV.js} +1 -1
  3. package/dist/assets/{ControlsModal-D-mymoM7.js → ControlsModal-D5RE5MvT.js} +1 -1
  4. package/dist/assets/{DockerLogsModal-Ae-ZCeeP.js → DockerLogsModal-B27P1JpZ.js} +1 -1
  5. package/dist/assets/{EmbeddedEditor-DLOOpM0K.js → EmbeddedEditor-DP1jqsT_.js} +1 -1
  6. package/dist/assets/{GmailOAuthSetup-C9NLhWLo.js → GmailOAuthSetup-DvuL5G8Q.js} +1 -1
  7. package/dist/assets/{GoogleOAuthSetup-1kzgrPV6.js → GoogleOAuthSetup-CG6bSCjv.js} +1 -1
  8. package/dist/assets/{IframeModal-DKS0IFsr.js → IframeModal-ClnUGmJV.js} +1 -1
  9. package/dist/assets/{IntegrationsPanel-CBvKOeud.js → IntegrationsPanel-0vdfxZRq.js} +2 -2
  10. package/dist/assets/{LogViewerModal-Dlt8JfVg.js → LogViewerModal-DLQlrZ4O.js} +1 -1
  11. package/dist/assets/{MonitoringModal-BM1IEZv6.js → MonitoringModal-DiC9TNCy.js} +1 -1
  12. package/dist/assets/{PM2LogsModal-B1-HUHWZ.js → PM2LogsModal-BgPrnaP5.js} +1 -1
  13. package/dist/assets/{RestoreArchivedAreaModal-DXmYo7fp.js → RestoreArchivedAreaModal-CIN1OrOW.js} +1 -1
  14. package/dist/assets/{Scene2DCanvas-CuUxSaPb.js → Scene2DCanvas-Bap6brvv.js} +1 -1
  15. package/dist/assets/{SceneManager-UD3IHY20.js → SceneManager-CidCW0PR.js} +1 -1
  16. package/dist/assets/{SkillsPanel-DjRBVrO2.js → SkillsPanel-DHQTPaP2.js} +1 -1
  17. package/dist/assets/{SlackMultiInstanceSetup-Csp81Dqn.js → SlackMultiInstanceSetup-CQK4D89W.js} +1 -1
  18. package/dist/assets/{SpawnModal-dg0mH3d9.js → SpawnModal-Cx_k3HHC.js} +1 -1
  19. package/dist/assets/{SubordinateAssignmentModal-CeBPRNNX.js → SubordinateAssignmentModal-C1DOv51H.js} +1 -1
  20. package/dist/assets/TriggerManagerPanel-jP5RBK2L.js +9 -0
  21. package/dist/assets/{WorkflowEditorPanel-IIsptZgp.js → WorkflowEditorPanel-Dh6mZ8M4.js} +1 -1
  22. package/dist/assets/{index-h-IcmGfB.js → index-B-ttQFx4.js} +2 -2
  23. package/dist/assets/index-BXnThzaG.js +11 -0
  24. package/dist/assets/index-CK8NcQSU.css +1 -0
  25. package/dist/assets/{index-CNDUxsGy.js → index-CYwFXTQZ.js} +1 -1
  26. package/dist/assets/{index-sDgBtEgH.js → index-Cwlm-Pqi.js} +3 -3
  27. package/dist/assets/index-D96LXKm4.js +1 -0
  28. package/dist/assets/{index-BGh9tRSy.js → index-DP5sMNS9.js} +1 -1
  29. package/dist/assets/{index-CsyPNc8u.js → index-DfEbuBH8.js} +1 -1
  30. package/dist/assets/{index-DEI-vrXk.js → index-DsKaX6TJ.js} +1 -1
  31. package/dist/assets/{index-CIqkVLo1.js → index-enJvXAbe.js} +1 -1
  32. package/dist/assets/main-B7wf_xU_.js +214 -0
  33. package/dist/assets/main-DLzFxLC1.css +1 -0
  34. package/dist/assets/{web-BmPSJLwQ.js → web-BHmmnvF7.js} +1 -1
  35. package/dist/assets/{web-Dggt4D4N.js → web-IGuhG0xr.js} +1 -1
  36. package/dist/assets/{web-BgPjNMBK.js → web-SOehUGgT.js} +1 -1
  37. package/dist/index.html +2 -2
  38. package/dist/locales/en/config.json +60 -1
  39. package/dist/locales/en/terminal.json +10 -0
  40. package/dist/src/packages/server/claude/backend.js +42 -0
  41. package/dist/src/packages/server/claude/permission-prompt-server.mjs +188 -0
  42. package/dist/src/packages/server/claude/runner/process-lifecycle.js +3 -0
  43. package/dist/src/packages/server/claude/runner/stdout-pipeline.js +8 -0
  44. package/dist/src/packages/server/claude/runner/tmux-helper.js +14 -0
  45. package/dist/src/packages/server/data/event-queries.js +143 -1
  46. package/dist/src/packages/server/data/migrations/007_whatsapp_messages.sql +48 -0
  47. package/dist/src/packages/server/index.js +1 -0
  48. package/dist/src/packages/server/integrations/gmail/gmail-client.js +139 -24
  49. package/dist/src/packages/server/integrations/gmail/gmail-routes.js +162 -0
  50. package/dist/src/packages/server/integrations/whatsapp/whatsapp-routes.js +81 -0
  51. package/dist/src/packages/server/integrations/whatsapp/whatsapp-trigger-handler.js +29 -0
  52. package/dist/src/packages/server/routes/agent-prompt.js +57 -0
  53. package/dist/src/packages/server/routes/index.js +8 -1
  54. package/dist/src/packages/server/routes/skills.js +193 -0
  55. package/dist/src/packages/server/routes/system.js +156 -0
  56. package/dist/src/packages/server/routes/trigger-routes.js +74 -17
  57. package/dist/src/packages/server/routes/webhook-signatures.js +20 -7
  58. package/dist/src/packages/server/services/agent-prompt-service.js +100 -0
  59. package/dist/src/packages/server/services/index.js +1 -0
  60. package/dist/src/packages/server/services/self-update-service.js +191 -0
  61. package/dist/src/packages/server/websocket/handler.js +2 -1
  62. package/dist/src/packages/server/websocket/listeners/agent-prompt-listeners.js +13 -0
  63. package/dist/src/packages/server/websocket/listeners/index.js +2 -0
  64. package/dist/src/packages/shared/whatsapp-types.js +1 -0
  65. package/package.json +2 -2
  66. package/dist/assets/TriggerManagerPanel-D1QPpFhP.js +0 -9
  67. package/dist/assets/index-BdGz_GAe.css +0 -1
  68. package/dist/assets/index-CR9w26tq.js +0 -1
  69. package/dist/assets/index-vJkimYqD.js +0 -1
  70. package/dist/assets/main-BV_IuaBg.css +0 -1
  71. package/dist/assets/main-klWBzHh0.js +0 -214
@@ -0,0 +1,11 @@
1
+ import{r as l,aT as Re,aU as Ye,j as e,I as $,u as Y,aV as ts,a2 as ns,f as Ve,s as E,aW as hs,k as is,l as me,aX as X,aY as ms,aM as gs,aZ as fs,C as ge,a_ as J,aJ as we,a$ as xs,b0 as bs,b1 as js,b2 as ws,b3 as Ce,b4 as os,b5 as ys,b6 as Be,b7 as vs,b8 as Ns,b9 as ks,ba as Cs,bb as Ss,bc as Ts,bd as As,aF as _s,J as Es,S as ke,be as Is,bf as Ps,aH as $s,bg as Ue,K as Pe,aQ as Ls,bh as ze,bi as Ds}from"./main-B7wf_xU_.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ke="deivid11/tide-commander",Fs=`https://api.github.com/repos/${Ke}/releases/latest`,Os=`https://api.github.com/repos/${Ke}/releases?per_page=3`,Rs=3600*1e3,Je="app_update_dismissed_version",Ze="1.99.0";function Us(){var x,b;const[s,t]=l.useState({isChecking:!1,updateAvailable:!1,updateInfo:null,recentReleases:[],error:null,currentVersion:Ze}),a=((b=(x=Re)==null?void 0:x.getPlatform)==null?void 0:b.call(x))==="android"||!1,o=p=>p.replace(/^v/,"").split(".").map(m=>parseInt(m,10)||0),r=(p,f)=>{const m=o(p),y=o(f),j=Math.max(m.length,y.length);for(let h=0;h<j;h++){const _=m[h]||0,D=y[h]||0;if(_>D)return 1;if(_<D)return-1}return 0},d=async p=>{var m,y;if(Re&&Ye&&((y=(m=Re).isNativePlatform)==null?void 0:y.call(m))===!0){const j=await Ye.get({url:p,headers:{Accept:"application/vnd.github.v3+json"}});return{data:j.data,status:j.status}}else{const j=await fetch(p,{headers:{Accept:"application/vnd.github.v3+json"}});return j.ok?{data:await j.json(),status:j.status}:{data:null,status:j.status}}},c=l.useCallback(async(p=!1)=>{t(f=>({...f,isChecking:!0,error:null}));try{const[f,m]=await Promise.all([d(Fs),d(Os)]);if(f.status!==200)throw new Error(`GitHub API error: ${f.status}`);const y=f.data,j=y.tag_name;let h=[];m.status===200&&m.data&&(h=m.data.map(A=>({version:A.tag_name,name:A.name,publishedAt:A.published_at,releaseUrl:A.html_url})));const _=localStorage.getItem(Je);if(!p&&_===j)return t(A=>({...A,isChecking:!1,updateAvailable:!1,recentReleases:h})),null;if(!(r(j,Ze)>0))return t(A=>({...A,isChecking:!1,updateAvailable:!1,recentReleases:h})),null;const P=y.assets.find(A=>A.name.endsWith(".apk")&&A.content_type==="application/vnd.android.package-archive"),C={version:j,name:y.name,changelog:y.body,releaseUrl:y.html_url,apkUrl:(P==null?void 0:P.browser_download_url)||null,apkSize:(P==null?void 0:P.size)||null,publishedAt:y.published_at};return t(A=>({...A,isChecking:!1,updateAvailable:!0,updateInfo:C,recentReleases:h})),C}catch(f){const m=f instanceof Error?f.message:"Failed to check for updates";return t(y=>({...y,isChecking:!1,error:m})),null}},[]),n=l.useCallback(async()=>{var p,f,m;if(!((p=s.updateInfo)!=null&&p.apkUrl)){(f=s.updateInfo)!=null&&f.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}if(!a){(m=s.updateInfo)!=null&&m.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}try{window.open(s.updateInfo.apkUrl,"_system"),t(y=>({...y,error:null}))}catch(y){const j=y instanceof Error?y.message:"Failed to open download";t(h=>({...h,error:j}))}},[s.updateInfo,a]),u=l.useCallback(()=>{s.updateInfo&&localStorage.setItem(Je,s.updateInfo.version),t(p=>({...p,updateAvailable:!1,updateInfo:null}))},[s.updateInfo]),w=l.useCallback(()=>{var p;(p=s.updateInfo)!=null&&p.releaseUrl?window.open(s.updateInfo.releaseUrl,"_blank"):window.open(`https://github.com/${Ke}/releases`,"_blank")},[s.updateInfo]);return l.useEffect(()=>{if(!a)return;const p=setTimeout(()=>{c()},5e3),f=setInterval(()=>{c()},Rs);return()=>{clearTimeout(p),clearInterval(f)}},[a,c]),{...s,isAndroid:a,checkForUpdate:c,downloadAndInstall:n,dismissUpdate:u,openReleasePage:w}}const ls="tide-toolbox-collapse";function zs(s,t){try{const a=localStorage.getItem(`${ls}-${s}`);if(a!==null)return a==="true"}catch{}return t}function Ms(s,t){try{localStorage.setItem(`${ls}-${s}`,String(t))}catch{}}function W({title:s,storageKey:t,defaultOpen:a=!1,forceOpen:o=!1,children:r,headerExtra:d}){const[c,n]=l.useState(()=>t?zs(t,a):a),u=()=>{const x=!c;n(x),t&&Ms(t,x)},w=o||c;return e.jsxs("div",{className:`collapsible-section ${w?"open":"collapsed"}`,children:[e.jsxs("button",{className:"collapsible-header",onClick:u,children:[e.jsx("span",{className:"collapsible-title",children:s}),e.jsxs("span",{className:"collapsible-header-right",children:[d,e.jsx("span",{className:"collapsible-arrow",children:e.jsx($,{name:w?"caret-down":"caret-right",size:10})})]})]}),w&&e.jsx("div",{className:"collapsible-content",children:r})]})}function Bs({area:s,isSelected:t,onClick:a,onDelete:o}){const{t:r}=Y(["config","common"]),d=s.assignedAgentIds.length,c=s.type==="rectangle"?r("config:areas.rect"):r("config:areas.circle");return e.jsxs("div",{className:`area-item ${t?"selected":""}`,onClick:a,children:[e.jsx("div",{className:"area-color-dot",style:{backgroundColor:s.color}}),e.jsxs("div",{className:"area-info",children:[e.jsx("div",{className:"area-name",children:s.name}),e.jsxs("div",{className:"area-meta",children:[c," ",d>0&&`• ${d} ${d>1?r("common:labels.agents").toLowerCase():r("common:labels.agent").toLowerCase()}`]})]}),e.jsx("button",{className:"area-delete-btn",onClick:o,title:r("config:areas.deleteArea"),children:"×"})]})}function Vs({building:s,isSelected:t,onClick:a,onEdit:o}){var n;const{t:r}=Y(["config"]),d=((n=s.pm2Status)==null?void 0:n.ports)||[],c=(u,w)=>{u.stopPropagation(),window.open(`http://${window.location.hostname}:${w}`,"_blank")};return e.jsxs("div",{className:`building-item ${t?"selected":""}`,onClick:a,children:[e.jsx("div",{className:"building-status-dot",style:{backgroundColor:ts[s.status]},title:s.status}),e.jsx("div",{className:"building-icon",children:e.jsx($,{name:ns(s.type),size:16})}),e.jsxs("div",{className:"building-info",children:[e.jsx("div",{className:"building-name",children:s.name}),e.jsxs("div",{className:"building-meta",children:[s.type,d.length>0&&e.jsx("span",{className:"building-ports",children:d.map(u=>e.jsxs("a",{href:`http://${window.location.hostname}:${u}`,className:"building-port-link",onClick:w=>c(w,u),title:`Open :${u}`,children:[":",u]},u))})]})]}),e.jsx("button",{className:"building-edit-btn",onClick:u=>{u.stopPropagation(),o()},title:r("config:buildings.editBuilding"),children:e.jsx($,{name:"gear",size:14})})]})}function Ks({building:s,onClose:t,onOpenModal:a}){var w,x,b,p,f,m,y,j;const{t:o}=Y(["config","common"]),{buildingLogs:r}=Ve(),d=E.getBuildingLogs(s.id),c=hs[s.style||"server-rack"],n=h=>{E.sendBuildingCommand(s.id,h)},u=h=>{window.open(h,"_blank")};return e.jsxs("div",{className:"building-editor",children:[e.jsxs("div",{className:"building-editor-header",children:[e.jsxs("div",{className:"building-editor-title-row",children:[e.jsx("span",{className:"building-editor-icon",children:e.jsx($,{name:ns(s.type),size:18})}),e.jsx("span",{className:"building-editor-title",children:s.name}),e.jsx("span",{className:"building-editor-status",style:{backgroundColor:ts[s.status]},children:s.status})]}),e.jsx("button",{className:"building-editor-close",onClick:t,children:"×"})]}),e.jsx("div",{className:"building-editor-section",children:e.jsxs("div",{className:"building-editor-info-grid",children:[e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("common:labels.type")}),e.jsx("span",{className:"building-editor-info-value",children:s.type})]}),e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.style")}),e.jsx("span",{className:"building-editor-info-value",children:c.label})]}),s.cwd&&e.jsxs("div",{className:"building-editor-info-item building-editor-info-wide",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.directory")}),e.jsx("span",{className:"building-editor-info-value building-editor-cwd",title:s.cwd,children:s.cwd.split("/").pop()||s.cwd})]})]})}),s.type==="server"&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.actions")}),e.jsxs("div",{className:"building-editor-actions",children:[e.jsxs("button",{className:"building-editor-action-btn start",onClick:()=>n("start"),disabled:!((w=s.commands)!=null&&w.start)||s.status==="running",title:((x=s.commands)==null?void 0:x.start)||o("config:buildings.noStartCommand"),children:[e.jsx($,{name:"play",size:12})," ",o("common:buttons.start")]}),e.jsxs("button",{className:"building-editor-action-btn stop",onClick:()=>n("stop"),disabled:!((b=s.commands)!=null&&b.stop)||s.status==="stopped",title:((p=s.commands)==null?void 0:p.stop)||o("config:buildings.noStopCommand"),children:[e.jsx($,{name:"stop",size:12,weight:"fill"})," ",o("common:buttons.stop")]}),e.jsxs("button",{className:"building-editor-action-btn restart",onClick:()=>n("restart"),disabled:!((f=s.commands)!=null&&f.restart),title:((m=s.commands)==null?void 0:m.restart)||o("config:buildings.noRestartCommand"),children:[e.jsx($,{name:"refresh",size:12})," ",o("common:buttons.retry")]}),e.jsxs("button",{className:"building-editor-action-btn health",onClick:()=>n("healthCheck"),disabled:!((y=s.commands)!=null&&y.healthCheck),title:((j=s.commands)==null?void 0:j.healthCheck)||o("config:buildings.noHealthCheck"),children:[e.jsx($,{name:"heart",size:12})," Health"]})]})]}),s.urls&&s.urls.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.links")}),e.jsx("div",{className:"building-editor-links",children:s.urls.map((h,_)=>e.jsxs("button",{className:"building-editor-link",onClick:()=>u(h.url),title:h.url,children:[e.jsx($,{name:"link",size:12})," ",h.label||h.url]},_))})]}),d.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsxs("div",{className:"building-editor-section-title",children:[o("config:buildings.recentLogs"),e.jsx("button",{className:"building-editor-clear-logs",onClick:()=>E.clearBuildingLogs(s.id),title:o("common:buttons.clear"),children:o("common:buttons.clear")})]}),e.jsx("div",{className:"building-editor-logs",children:d.slice(-5).map((h,_)=>e.jsx("div",{className:"building-editor-log-entry",children:h},_))})]}),e.jsx("div",{className:"building-editor-footer",children:e.jsxs("button",{className:"building-editor-edit-btn",onClick:a,children:[e.jsx($,{name:"gear",size:12})," ",o("config:buildings.fullSettings")]})})]})}async function Hs(s,t){const a=X(),o=await fetch(me(`/api/areas/${s}/logo`),{method:"POST",headers:{"Content-Type":t.type||"image/png","X-Filename":encodeURIComponent(t.name),...a?{Authorization:`Bearer ${a}`}:{}},body:t});if(!o.ok){const r=await o.json().catch(()=>({error:o.statusText}));throw new Error(r.error||`Upload failed: ${o.statusText}`)}return o.json()}async function Ws(s){const t=X(),a=await fetch(me(`/api/areas/${s}/logo`),{method:"DELETE",headers:{...t?{Authorization:`Bearer ${t}`}:{}}});if(!a.ok)throw new Error(`Failed to delete logo: ${a.statusText}`)}function qs(s){return is(me(`/api/areas/logos/${s}`))}const Gs=[{key:"center",labelKey:"posCenter"},{key:"top-left",labelKey:"posTopLeft"},{key:"top-right",labelKey:"posTopRight"},{key:"bottom-left",labelKey:"posBottomLeft"},{key:"bottom-right",labelKey:"posBottomRight"}];function Ys({area:s,onClose:t,onOpenFolder:a}){var ce;const{t:o}=Y(["config","common"]),[r,d]=l.useState(s.name),[c,n]=l.useState(s.prompt||""),[u,w]=l.useState(!1),[x,b]=l.useState(""),[p,f]=l.useState(!1),m=l.useRef(null);l.useEffect(()=>{d(s.name)},[s.id,s.name]),l.useEffect(()=>{n(s.prompt||"")},[s.id,s.prompt]);const y=k=>{const O=k.target.value;d(O),E.updateArea(s.id,{name:O})},j=k=>{E.updateArea(s.id,{color:k})},h=k=>{const O=k.target.value;n(O),E.updateArea(s.id,{prompt:O})},_=()=>{x.trim()&&(E.addDirectoryToArea(s.id,x.trim()),b(""),w(!1))},D=(k,O)=>{O.stopPropagation(),E.removeDirectoryFromArea(s.id,k)},P=()=>{E.bringAreaToFront(s.id)},C=()=>{E.sendAreaToBack(s.id)},A=l.useCallback(()=>{let k=2,O=2;s.type==="rectangle"&&s.width&&s.height?(k=s.width,O=s.height):s.type==="circle"&&s.radius&&(k=s.radius*1.414,O=s.radius*1.414);const B=Math.min(k,O)*.4;return{width:Math.round(B*10)/10,height:Math.round(B*10)/10}},[s.type,s.width,s.height,s.radius]),V=async k=>{var B;const O=(B=k.target.files)==null?void 0:B[0];if(O){f(!0);try{const v=await Hs(s.id,O),F=A();E.updateArea(s.id,{logo:{filename:v.filename,position:"center",width:F.width,height:F.height,keepAspectRatio:!0,opacity:.8}})}catch(v){console.error("Failed to upload logo:",v)}finally{f(!1),m.current&&(m.current.value="")}}},M=async()=>{try{await Ws(s.id),E.updateArea(s.id,{logo:void 0})}catch(k){console.error("Failed to remove logo:",k)}},K=k=>{s.logo&&E.updateArea(s.id,{logo:{...s.logo,position:k}})},N=k=>{if(!s.logo)return;const O=parseFloat(k.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.width>0){const B=s.logo.height/s.logo.width;E.updateArea(s.id,{logo:{...s.logo,width:O,height:Math.round(O*B*10)/10}})}else E.updateArea(s.id,{logo:{...s.logo,width:O}})},S=k=>{if(!s.logo)return;const O=parseFloat(k.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.height>0){const B=s.logo.width/s.logo.height;E.updateArea(s.id,{logo:{...s.logo,height:O,width:Math.round(O*B*10)/10}})}else E.updateArea(s.id,{logo:{...s.logo,height:O}})},H=()=>{s.logo&&E.updateArea(s.id,{logo:{...s.logo,keepAspectRatio:!s.logo.keepAspectRatio}})},Z=k=>{s.logo&&E.updateArea(s.id,{logo:{...s.logo,opacity:parseFloat(k.target.value)}})};return e.jsxs("div",{className:"area-editor",children:[e.jsxs("div",{className:"area-editor-header",children:[e.jsx("span",{className:"area-editor-title",children:o("config:areas.editArea")}),e.jsx("button",{className:"area-editor-close",onClick:t,children:"×"})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("common:labels.name")}),e.jsx("input",{type:"text",className:"area-editor-input",value:r,onChange:y,placeholder:o("config:areas.areaName")})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.color")}),e.jsx("div",{className:"color-picker-row",children:ms.map(k=>e.jsx("div",{className:`color-swatch ${s.color===k?"selected":""}`,style:{backgroundColor:k},onClick:()=>j(k)},k))})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.layer")}),e.jsxs("div",{className:"area-layer-buttons",children:[e.jsxs("button",{className:"area-layer-btn",onClick:P,title:o("config:areas.bringToFront"),children:[e.jsx($,{name:"arrow-up",size:12})," ",o("config:areas.front")]}),e.jsxs("button",{className:"area-layer-btn",onClick:C,title:o("config:areas.sendToBack"),children:[e.jsx($,{name:"arrow-down",size:12})," ",o("config:areas.back")]})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.logo")}),e.jsxs("div",{className:"area-logo-section",children:[(ce=s.logo)!=null&&ce.filename?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"area-logo-preview",children:[e.jsx("img",{src:qs(s.logo.filename),alt:"Logo",className:"area-logo-thumbnail"}),e.jsx("button",{className:"area-logo-remove-btn",onClick:M,children:o("config:areas.removeLogo")}),e.jsx("button",{className:"area-logo-replace-btn",onClick:()=>{var k;return(k=m.current)==null?void 0:k.click()},disabled:p,children:p?"...":e.jsx($,{name:"refresh",size:12})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoPosition")}),e.jsx("div",{className:"area-logo-position-row",children:Gs.map(({key:k,labelKey:O})=>{var B;return e.jsx("button",{className:`area-logo-pos-btn ${((B=s.logo)==null?void 0:B.position)===k?"active":""}`,onClick:()=>K(k),children:o(`config:areas.${O}`)},k)})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoSize")}),e.jsxs("div",{className:"area-logo-size-row",children:[e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoWidth")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.width,onChange:N,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoHeight")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.height,onChange:S,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-aspect-label",title:o("config:areas.keepAspectRatio"),children:[e.jsx("input",{type:"checkbox",checked:s.logo.keepAspectRatio,onChange:H}),o("config:areas.keepAspectRatio")]})]})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoOpacity")}),e.jsxs("div",{className:"area-logo-opacity-row",children:[e.jsx("input",{type:"range",min:0,max:1,step:.05,value:s.logo.opacity??.8,onChange:Z,className:"area-logo-opacity-slider"}),e.jsxs("span",{className:"area-logo-opacity-value",children:[Math.round((s.logo.opacity??.8)*100),"%"]})]})]})]}):e.jsx("button",{className:"area-logo-upload-btn",onClick:()=>{var k;return(k=m.current)==null?void 0:k.click()},disabled:p,children:p?"...":o("config:areas.uploadLogo")}),e.jsx("input",{ref:m,type:"file",accept:"image/*",style:{display:"none"},onChange:V})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.folders",{count:s.directories.length})}),e.jsxs("div",{className:"area-folders-list",children:[s.directories.map(k=>e.jsxs("div",{className:"area-folder-item",title:k,children:[e.jsx("span",{className:"area-folder-icon clickable",onClick:()=>a==null?void 0:a(s.id),title:o("config:areas.openFolder"),children:e.jsx($,{name:"folder",size:14})}),e.jsx("span",{className:"area-folder-path",children:k.split("/").pop()||k}),e.jsx("button",{className:"area-folder-remove",onClick:O=>D(k,O),title:o("config:areas.removeFolder"),children:"×"})]},k)),u?e.jsxs("div",{className:"area-add-folder-inline",children:[e.jsx(gs,{value:x,onChange:b,onSubmit:_,placeholder:o("config:areas.folderPlaceholder"),className:"area-add-folder-input",directoriesOnly:!0,autoFocus:!0}),e.jsx("button",{className:"area-add-folder-confirm",onClick:_,children:"+"})]}):e.jsx("button",{className:"area-add-folder-btn",onClick:()=>w(!0),children:o("config:areas.addFolder")})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.prompt","Prompt")}),e.jsx("textarea",{className:"area-editor-input",value:c,onChange:h,placeholder:o("config:areas.promptPlaceholder","System prompt for agents in this area..."),rows:4,style:{resize:"vertical",fontFamily:"monospace",fontSize:12}}),e.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4},children:o("config:areas.promptHint","This prompt is injected into agents assigned to this area. Takes effect on next context refresh.")})]}),s.assignedAgentIds.length>0&&e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.assignedAgents",{count:s.assignedAgentIds.length})}),e.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:o("config:areas.rightClickUnassign")})]})]})}function Js(){const{t:s}=Y(["config","common"]),t=fs(),[a,o]=l.useState(!1),[r,d]=l.useState(null),[c,n]=l.useState({name:"",key:"",value:"",description:""}),[u,w]=l.useState(null),x=()=>{o(!0),d(null),n({name:"",key:"",value:"",description:""})},b=h=>{d(h.id),o(!1),n({name:h.name,key:h.key,value:h.value,description:h.description||""})},p=()=>{o(!1),d(null),n({name:"",key:"",value:"",description:""})},f=()=>{!c.name.trim()||!c.key.trim()||(r?E.updateSecret(r,{name:c.name.trim(),key:c.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:c.value,description:c.description.trim()||void 0}):E.createSecret({name:c.name.trim(),key:c.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:c.value,description:c.description.trim()||void 0}),p())},m=h=>{w(h)},y=()=>{u&&(E.deleteSecret(u),r===u&&p())},j=h=>{navigator.clipboard.writeText(`{{${h}}}`)};return e.jsxs("div",{className:"secrets-section",children:[e.jsx("div",{className:"secrets-description",children:s("config:secrets.description",{placeholder:"{{KEY}}"})}),e.jsx("div",{className:"secrets-list",children:t.length===0&&!a?e.jsx("div",{className:"secrets-empty",children:s("config:secrets.noSecrets")}):t.map(h=>e.jsxs("div",{className:`secret-item ${r===h.id?"editing":""}`,children:[e.jsxs("div",{className:"secret-item-header",children:[e.jsxs("div",{className:"secret-item-info",children:[e.jsx("span",{className:"secret-item-name",children:h.name}),e.jsx("code",{className:"secret-item-key",onClick:()=>j(h.key),title:s("config:secrets.copyPlaceholder"),children:`{{${h.key}}}`})]}),e.jsxs("div",{className:"secret-item-actions",children:[e.jsx("button",{className:"secret-item-btn edit",onClick:()=>b(h),title:s("common:buttons.edit"),children:e.jsx($,{name:"edit",size:12})}),e.jsx("button",{className:"secret-item-btn delete",onClick:()=>m(h.id),title:s("common:buttons.delete"),children:"×"})]})]}),h.description&&e.jsx("div",{className:"secret-item-description",children:h.description})]},h.id))}),(a||r)&&e.jsxs("div",{className:"secret-form",children:[e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.name")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.namePlaceholder"),value:c.name,onChange:h=>n({...c,name:h.target.value}),autoFocus:!0})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:"Key"}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.keyPlaceholder"),value:c.key,onChange:h=>n({...c,key:h.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")})}),e.jsx("span",{className:"secret-form-hint",children:s("config:secrets.usedAs",{placeholder:`{{${c.key||"KEY"}}}`})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("config:secrets.secretValue")}),e.jsx("input",{type:"password",className:"secret-form-input",placeholder:s("config:secrets.valuePlaceholder"),value:c.value,onChange:h=>n({...c,value:h.target.value})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.description")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.descriptionPlaceholder"),value:c.description,onChange:h=>n({...c,description:h.target.value})})]}),e.jsxs("div",{className:"secret-form-actions",children:[e.jsx("button",{className:"secret-form-btn cancel",onClick:p,children:s("common:buttons.cancel")}),e.jsx("button",{className:"secret-form-btn save",onClick:f,disabled:!c.name.trim()||!c.key.trim(),children:s(r?"config:secrets.update":"common:buttons.add")})]})]}),!a&&!r&&e.jsx("button",{className:"secrets-add-btn",onClick:x,children:s("config:secrets.addSecret")}),e.jsx(ge,{isOpen:u!==null,title:s("common:buttons.delete"),message:s("config:secrets.deleteConfirm"),confirmLabel:s("common:buttons.delete"),cancelLabel:s("common:buttons.cancel"),variant:"danger",onConfirm:y,onClose:()=>w(null)})]})}async function Zs(){const s=X(),t=await fetch(`${J()}/api/agents/system-settings/prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!t.ok)throw new Error(`Failed to fetch system prompt: ${t.statusText}`);return(await t.json()).prompt||""}async function Xs(s){const t=X(),a=await fetch(`${J()}/api/agents/system-settings/prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({prompt:s})});if(!a.ok)throw new Error(`Failed to update system prompt: ${a.statusText}`)}async function Qs(){const s=X(),t=await fetch(`${J()}/api/agents/system-settings/prompt`,{method:"DELETE",headers:{Authorization:`Bearer ${s}`}});if(!t.ok)throw new Error(`Failed to clear system prompt: ${t.statusText}`)}async function ea(){const s=X(),t=await fetch(`${J()}/api/agents/system-settings/echo-prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!t.ok)throw new Error(`Failed to fetch echo prompt setting: ${t.statusText}`);return(await t.json()).enabled||!1}async function sa(s){const t=X(),a=await fetch(`${J()}/api/agents/system-settings/echo-prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({enabled:s})});if(!a.ok)throw new Error(`Failed to update echo prompt setting: ${a.statusText}`)}async function aa(){const s=X(),t=await fetch(`${J()}/api/agents/system-settings/codex-binary`,{headers:{Authorization:`Bearer ${s}`}});if(!t.ok)throw new Error(`Failed to fetch codex binary path: ${t.statusText}`);return(await t.json()).path||""}async function ta(s){const t=X(),a=await fetch(`${J()}/api/agents/system-settings/codex-binary`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({path:s})});if(!a.ok)throw new Error(`Failed to update codex binary path: ${a.statusText}`)}async function na(){const s=X(),t=await fetch(`${J()}/api/agents/system-settings/tmux-mode`,{headers:{Authorization:`Bearer ${s}`}});if(!t.ok)throw new Error(`Failed to fetch tmux mode setting: ${t.statusText}`);return(await t.json()).enabled||!1}async function ia(s){const t=X(),a=await fetch(`${J()}/api/agents/system-settings/tmux-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({enabled:s})});if(!a.ok)throw new Error(`Failed to update tmux mode setting: ${a.statusText}`)}async function oa(){const s=X(),t=await fetch(`${J()}/api/agents/system-settings/backup`,{headers:{Authorization:`Bearer ${s}`}});if(!t.ok)throw new Error(`Failed to fetch backup status: ${t.statusText}`);return t.json()}async function la(s){const t=X(),a=await fetch(`${J()}/api/agents/system-settings/backup`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({enabled:s})});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.error||`Failed to update backup setting: ${a.statusText}`)}return a.json()}function ca({checked:s,onChange:t,disabled:a}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,disabled:a,onChange:o=>t(o.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function ra(){const{t:s}=Y(["config","common"]),[t,a]=l.useState([]),[o,r]=l.useState(new Set),[d,c]=l.useState(new Set),[n,u]=l.useState(!1),[w,x]=l.useState(!1),[b,p]=l.useState(null),[f,m]=l.useState(null),[y,j]=l.useState(null),[h,_]=l.useState(null),[D,P]=l.useState(!1),[C,A]=l.useState(null);l.useEffect(()=>{we(me("/api/config/categories")).then(v=>v.json()).then(v=>{const F=Array.isArray(v)?v:[];a(F),r(new Set(F.map(R=>R.id)))}).catch(v=>console.error("Failed to fetch config categories:",v))},[]),l.useEffect(()=>{oa().then(_).catch(v=>{console.error("Failed to fetch backup status:",v),A(v.message||"Failed to fetch backup status")})},[]);const V=async v=>{if(!D){P(!0),A(null);try{const F=await la(v);_(F)}catch(F){A(F.message||"Failed to update backup setting")}finally{P(!1)}}},M=v=>{r(F=>{const R=new Set(F);return R.has(v)?R.delete(v):R.add(v),R})},K=v=>{c(F=>{const R=new Set(F);return R.has(v)?R.delete(v):R.add(v),R})},N=()=>r(new Set(t.map(v=>v.id))),S=()=>r(new Set),H=()=>{f&&c(new Set(f.categories.map(v=>v.id)))},Z=()=>c(new Set),ce=async()=>{var v;if(o.size!==0){u(!0),j(null);try{const F=Array.from(o).join(","),R=await we(me(`/api/config/export?categories=${F}`));if(!R.ok)throw new Error("Export failed");const Q=await R.blob(),ae=window.URL.createObjectURL(Q),ee=document.createElement("a");ee.href=ae;const T=R.headers.get("Content-Disposition"),q=((v=T==null?void 0:T.match(/filename="(.+)"/))==null?void 0:v[1])||"tide-commander-config.zip";ee.download=q,document.body.appendChild(ee),ee.click(),document.body.removeChild(ee),window.URL.revokeObjectURL(ae),j({type:"success",text:s("config:data.exportSuccess")})}catch(F){j({type:"error",text:F.message||"Export failed"})}finally{u(!1)}}},k=async v=>{var R;const F=(R=v.target.files)==null?void 0:R[0];if(F){p(F),j(null),m(null),c(new Set);try{const Q=await we(me("/api/config/preview"),{method:"POST",headers:{"Content-Type":"application/zip"},body:await F.arrayBuffer()});if(!Q.ok){const T=await Q.json();throw new Error(T.error||"Failed to preview config file")}const ae=await Q.json(),ee=Array.isArray(ae.categories)?ae.categories:[];m({...ae,categories:ee}),c(new Set(ee.map(T=>T.id)))}catch(Q){j({type:"error",text:Q.message||"Failed to read config file"}),p(null)}}},O=async()=>{if(!(!b||d.size===0)){x(!0),j(null);try{const v=Array.from(d).join(","),F=await we(me(`/api/config/import?categories=${v}`),{method:"POST",headers:{"Content-Type":"application/zip"},body:await b.arrayBuffer()}),R=await F.json();if(!F.ok)throw new Error(R.error||"Import failed");j({type:"success",text:R.message||s("config:data.importSuccess")}),p(null),m(null),c(new Set)}catch(v){j({type:"error",text:v.message||"Import failed"})}finally{x(!1)}}},B=()=>{p(null),m(null),c(new Set),j(null)};return e.jsxs("div",{className:"data-section",children:[y&&e.jsx("div",{className:`data-message data-message-${y.type}`,children:y.text}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:"Hourly Backups"}),e.jsx(ca,{checked:!!(h!=null&&h.enabled),disabled:D||!h,onChange:V})]}),e.jsxs("div",{className:"data-backup-info",children:[h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:["Saves a compressed snapshot of your data every hour to"," ",e.jsx("code",{children:h.backupDir}),". Identical snapshots are skipped. Keeps the 8 newest plus one from each of the 2 most recent prior days."]}),!h.scriptExists&&e.jsxs("div",{style:{marginTop:6,color:"var(--dracula-red, #ff5555)"},children:["Backup script not found at ",e.jsx("code",{children:h.scriptPath})]}),h.lastRunAt&&e.jsxs("div",{style:{marginTop:6},children:["Last run: ",new Date(h.lastRunAt).toLocaleString(),h.lastRunOk===!0&&" — ok",h.lastRunOk===!1&&h.lastRunError&&e.jsxs("span",{style:{color:"var(--dracula-red, #ff5555)"},children:[" — ",h.lastRunError]})]})]}):e.jsx("div",{children:"Loading backup status…"}),C&&e.jsx("div",{className:"data-message data-message-error",style:{marginTop:6},children:C})]})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:s("config:data.exportData")}),e.jsxs("div",{className:"data-select-controls",children:[e.jsx("button",{className:"data-select-btn",onClick:N,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:S,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:t.map(v=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:o.has(v.id),onChange:()=>M(v.id)}),e.jsx("span",{className:"data-category-name",children:v.name})]},v.id))}),e.jsx("button",{className:"data-action-btn export",onClick:ce,disabled:n||o.size===0,children:n?s("config:data.exporting"):s("config:data.exportCount",{count:o.size})})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsx("div",{className:"data-subsection-header",children:e.jsx("span",{className:"data-subsection-title",children:s("config:data.importData")})}),b?f?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"data-import-info",children:[e.jsx("div",{className:"data-import-file",children:b.name}),e.jsxs("div",{className:"data-import-date",children:[s("config:data.exported"),": ",new Date(f.exportedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-subtitle",children:s("config:data.selectToImport")}),e.jsxs("div",{className:"data-select-controls",children:[e.jsx("button",{className:"data-select-btn",onClick:H,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:Z,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:f.categories.map(v=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:d.has(v.id),onChange:()=>K(v.id)}),e.jsx("span",{className:"data-category-name",children:v.name}),v.fileCount&&e.jsxs("span",{className:"data-category-count",children:["(",v.fileCount," ",s("config:data.files"),")"]})]},v.id))}),e.jsxs("div",{className:"data-import-actions",children:[e.jsx("button",{className:"data-action-btn cancel",onClick:B,children:s("common:buttons.cancel")}),e.jsx("button",{className:"data-action-btn import",onClick:O,disabled:w||d.size===0,children:w?s("config:data.importing"):s("config:data.importCount",{count:d.size})})]})]}):e.jsx("div",{className:"data-loading",children:s("config:data.readingFile")}):e.jsxs("label",{className:"data-file-input",children:[e.jsx("input",{type:"file",accept:".zip",onChange:k,style:{display:"none"}}),e.jsx("span",{className:"data-file-input-label",children:s("config:data.selectFile")})]})]})]})}async function da(){const s=await we(`${J()}/api/system/install-info`);if(!s.ok)throw new Error(`Failed to fetch install info: ${s.statusText}`);return s.json()}function ua(s,t){const a=new AbortController;return(async()=>{try{const o=await fetch(is(`${J()}/api/system/self-update`),{method:"POST",signal:a.signal,headers:{Accept:"text/event-stream"}});if(!o.ok||!o.body){const n=await o.text().catch(()=>"");let u=null;try{u=JSON.parse(n)}catch{}const w=u&&typeof u=="object"&&"error"in u&&typeof u.error=="string"?u.error:`Self-update failed: ${o.status} ${o.statusText}`;s({type:"error",message:w}),t(new Error(w));return}const r=o.body.getReader(),d=new TextDecoder("utf-8");let c="";for(;;){const{value:n,done:u}=await r.read();if(u)break;c+=d.decode(n,{stream:!0});let w=c.indexOf(`
2
+
3
+ `);for(;w!==-1;){const x=c.slice(0,w);c=c.slice(w+2);const b=x.split(`
4
+ `);let p="message",f="";for(const m of b)m.startsWith(":")||(m.startsWith("event:")?p=m.slice(6).trim():m.startsWith("data:")&&(f+=(f?`
5
+ `:"")+m.slice(5).trim()));if(f)try{const m=JSON.parse(f);s({type:p,...m})}catch{}w=c.indexOf(`
6
+
7
+ `)}}t()}catch(o){if(o.name==="AbortError"){t();return}t(o)}})(),()=>a.abort()}function pa(){const[s,t]=l.useState(()=>xs()),a=o=>{t(o);const r=js(o);ws(r)};return e.jsx("div",{className:"theme-selector",children:e.jsx("div",{className:"theme-selector-grid",children:bs.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 ha(){const{t:s}=Y(["config"]),[t,a]=l.useState(null),[o,r]=l.useState("idle"),[d,c]=l.useState(""),[n,u]=l.useState(null),[w,x]=l.useState(null),b=l.useRef(null),p=l.useRef(null),f=l.useCallback(async()=>{try{const _=await da();a(_)}catch{a(null)}},[]);l.useEffect(()=>{f()},[f]),l.useEffect(()=>{p.current&&(p.current.scrollTop=p.current.scrollHeight)},[d]);const m=l.useCallback(()=>{r("confirm")},[]),y=l.useCallback(()=>{r("idle")},[]),j=l.useCallback(()=>{r("running"),c(""),u(null),x(null);const _=ua(D=>{switch(D.type){case"start":c(P=>P+`${D.message}
8
+ `);break;case"stdout":c(P=>P+D.chunk);break;case"stderr":c(P=>P+D.chunk);break;case"error":u(D.message),D.suggestedManualCommand&&c(P=>P+`
9
+
10
+ Suggested manual command: ${D.suggestedManualCommand}
11
+ `);break;case"done":D.success?(x(D.newVersion),r("success")):r("failed");break}},D=>{D&&u(P=>P??D.message),r(P=>P==="running"?n?"failed":"success":P)});b.current=_},[n]),h=l.useCallback(()=>{var _;(_=b.current)==null||_.call(b),b.current=null,r("idle"),f()},[f]);return t?t.isGlobalInstall?t.autoUpdateSupported?!t.updateAvailable&&o==="idle"?null:e.jsxs("div",{className:"about-autoupdate",children:[e.jsx("div",{className:"about-autoupdate-title",children:s("config:about.autoUpdateTitle")}),o==="idle"&&t.updateAvailable&&e.jsxs("div",{className:"about-autoupdate-row",children:[e.jsxs("span",{className:"about-autoupdate-versions",children:[e.jsx("span",{className:"about-autoupdate-current",children:t.currentVersion}),e.jsx("span",{className:"about-autoupdate-arrow",children:"→"}),e.jsx("span",{className:"about-autoupdate-latest",children:t.latestVersion})]}),e.jsx("button",{className:"about-update-btn download",onClick:m,children:s("config:about.autoUpdateButton")})]}),o==="confirm"&&e.jsxs("div",{className:"about-autoupdate-confirm",children:[e.jsx("div",{className:"about-autoupdate-confirm-title",children:s("config:about.autoUpdateConfirmTitle")}),e.jsx("div",{className:"about-autoupdate-confirm-body",children:s("config:about.autoUpdateConfirmBody")}),e.jsxs("div",{className:"about-autoupdate-confirm-actions",children:[e.jsx("button",{className:"about-update-btn changelog",onClick:y,children:s("config:about.autoUpdateCancel")}),e.jsx("button",{className:"about-update-btn download",onClick:j,children:s("config:about.autoUpdateConfirm")})]})]}),(o==="running"||o==="success"||o==="failed")&&e.jsxs("div",{className:"about-autoupdate-stream",children:[e.jsxs("div",{className:"about-autoupdate-stream-title",children:[o==="running"&&s("config:about.autoUpdateRunning"),o==="success"&&s("config:about.autoUpdateSuccess"),o==="failed"&&s("config:about.autoUpdateFailed")]}),e.jsx("pre",{ref:p,className:"about-autoupdate-output",children:d||"..."}),o==="success"&&e.jsxs("div",{className:"about-autoupdate-success-hint",children:[w&&e.jsxs("div",{className:"about-autoupdate-newversion",children:["v",w]}),e.jsx("div",{children:s("config:about.autoUpdateRestartHint")})]}),o==="failed"&&n&&e.jsx("div",{className:"about-update-error",children:n}),(o==="success"||o==="failed")&&e.jsx("div",{className:"about-autoupdate-stream-actions",children:e.jsx("button",{className:"about-update-btn changelog",onClick:h,children:s("config:about.autoUpdateClose")})})]})]}):e.jsxs("div",{className:"about-autoupdate",children:[e.jsx("div",{className:"about-autoupdate-title",children:s("config:about.autoUpdateTitle")}),e.jsx("div",{className:"about-autoupdate-devnote",children:s("config:about.autoUpdatePackageManagerNotice",{pm:t.packageManager})}),t.suggestedManualCommand&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"about-autoupdate-manualhint",children:s("config:about.autoUpdateManualCommand")}),e.jsx("pre",{className:"about-autoupdate-manualcmd",children:t.suggestedManualCommand})]})]}):e.jsxs("div",{className:"about-autoupdate",children:[e.jsx("div",{className:"about-autoupdate-title",children:s("config:about.autoUpdateTitle")}),e.jsx("div",{className:"about-autoupdate-devnote",children:s("config:about.autoUpdateDevMode")})]}):null}function ma(){const{t:s}=Y(["config"]),{updateAvailable:t,updateInfo:a,recentReleases:o,isChecking:r,error:d,currentVersion:c,isAndroid:n,checkForUpdate:u,downloadAndInstall:w,openReleasePage:x}=Us(),b=f=>f?`${(f/(1024*1024)).toFixed(1)} MB`:"",p=f=>new Date(f).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($,{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:c}),t&&a?e.jsx("span",{className:"about-version-update-badge",onClick:x,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.jsx(ha,{}),e.jsxs("div",{className:"about-update",children:[t&&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"),": ",b(a.apkSize)]}),d&&e.jsx("div",{className:"about-update-error",children:d}),e.jsxs("div",{className:"about-update-actions",children:[e.jsx("button",{className:"about-update-btn changelog",onClick:x,children:s("config:about.changelog")}),n&&a.apkUrl?e.jsx("button",{className:"about-update-btn download",onClick:w,children:s("config:about.downloadAPK")}):e.jsx("button",{className:"about-update-btn download",onClick:x,children:s("config:about.viewRelease")})]})]}):e.jsxs("div",{className:"about-update-check",children:[e.jsx("span",{className:"about-update-status",children:s(r?"config:about.checkingUpdates":"config:about.upToDate")}),e.jsx("button",{className:"about-update-btn check",onClick:()=>u(!0),disabled:r,children:r?"...":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(f=>e.jsxs("a",{href:f.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:`about-release-item ${f.version===`v${c}`||f.version===c?"current":""}`,children:[e.jsx("span",{className:"about-release-version",children:f.version}),e.jsx("span",{className:"about-release-date",children:p(f.publishedAt)})]},f.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($,{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 ga={gmail:"✉️",slack:"💬",jira:"📋","google-calendar":"📅",docx:"📄",whatsapp:"📱"};function fa({onOpenModal:s}){const[t,a]=l.useState([]),[o,r]=l.useState(!0),d=l.useCallback(async()=>{try{const c=await we(me("/api/integrations"));if(!c.ok)return;const n=await c.json();a(n)}catch{}finally{r(!1)}},[]);return l.useEffect(()=>{d()},[d]),o?e.jsx("div",{style:{color:"var(--text-secondary, #a6adc8)",fontSize:12,padding:"4px 0"},children:"Loading..."}):t.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:2},children:[t.map(c=>{const n=ga[c.id]||"🔌",u=!!c.status.error,w=c.status.connected,x=u?"#f38ba8":w?"#a6e3a1":"#fab387",b=u?"Error":w?"Connected":"Setup Required",p=u?"✗":w?"✓":"⚠";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"3px 8px",borderRadius:4,background:"var(--surface-1, #181825)",border:"1px solid var(--border, #313244)",fontSize:12,minHeight:26},children:[e.jsx("span",{style:{fontSize:13,flexShrink:0},children:n}),e.jsx("span",{style:{flex:1,minWidth:0,color:"var(--text-primary, #cdd6f4)",fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:c.name}),e.jsx("span",{style:{color:x,fontSize:10,fontWeight:500,whiteSpace:"nowrap"},title:b,children:p}),e.jsx("button",{onClick:()=>s(c.id),title:`Configure ${c.name}`,style:{background:"none",border:"none",cursor:"pointer",padding:"1px 3px",fontSize:12,color:"var(--text-secondary, #a6adc8)",borderRadius:3,flexShrink:0,lineHeight:1},onMouseEnter:f=>{f.target.style.color="var(--text-primary, #cdd6f4)"},onMouseLeave:f=>{f.target.style.color="var(--text-secondary, #a6adc8)"},children:"⚙️"})]},c.id)}),e.jsx("button",{onClick:()=>s(),style:{background:"none",border:"1px dashed var(--border, #313244)",borderRadius:4,padding:"3px 8px",cursor:"pointer",color:"var(--text-secondary, #a6adc8)",fontSize:11,textAlign:"center",marginTop:2},onMouseEnter:c=>{c.target.style.borderColor="var(--accent, #89b4fa)",c.target.style.color="var(--accent, #89b4fa)"},onMouseLeave:c=>{c.target.style.borderColor="var(--border, #313244)",c.target.style.color="var(--text-secondary, #a6adc8)"},children:"Manage All Integrations"})]})}function xa({isOpen:s,onClose:t}){const{t:a}=Y(["config"]),[o,r]=l.useState(""),[d,c]=l.useState(""),[n,u]=l.useState(!0),[w,x]=l.useState(null),[b,p]=l.useState(null),[f,m]=l.useState(!1),[y,j]=l.useState(!1),[h,_]=l.useState(!1);l.useEffect(()=>{s&&D()},[s]);const D=async()=>{try{u(!0),x(null),p(null);const S=await Zs();r(S),c(S),m(!1)}catch(S){x(S instanceof Error?S.message:"Failed to load system prompt")}finally{u(!1)}},P=S=>{const H=S.target.value;r(H),m(H!==d),x(null),p(null)},C=async()=>{try{x(null),p(null),await Xs(o),c(o),m(!1),p(a("config:systemPrompt.saved"))}catch(S){x(S instanceof Error?S.message:"Failed to save system prompt")}},A=()=>{j(!0)},V=async()=>{try{x(null),p(null),await Qs(),r(""),c(""),m(!1),p(a("config:systemPrompt.cleared"))}catch(S){x(S instanceof Error?S.message:"Failed to clear system prompt")}},M=()=>{r(d),m(!1),x(null),p(null)},K=()=>{if(f){_(!0);return}t()},N=S=>{S.key==="Escape"&&(S.preventDefault(),K())};return s?e.jsxs(Ce,{children:[e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:K,children:e.jsxs("div",{className:"system-prompt-modal",onClick:S=>S.stopPropagation(),onKeyDown:N,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:a("config:systemPrompt.title")}),e.jsx("button",{className:"modal-close",onClick:K,"aria-label":"Close",children:e.jsx($,{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")}),w&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:e.jsx($,{name:"warn",size:14})}),w]}),b&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx($,{name:"check",size:14})}),b]}),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:P,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:A,disabled:!o||n,children:a("config:systemPrompt.clear")})}),e.jsxs("div",{className:"footer-buttons-right",children:[e.jsx("button",{className:"btn btn-secondary",onClick:K,children:"Close"}),e.jsx("button",{className:"btn btn-secondary",onClick:M,disabled:!f||n,children:a("config:systemPrompt.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:C,disabled:!f||n,children:a("config:systemPrompt.save")})]})]})]})}),e.jsx(ge,{isOpen:y,title:a("config:systemPrompt.clear"),message:a("config:systemPrompt.confirmClear"),confirmLabel:a("config:systemPrompt.clear"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{V()},onClose:()=>j(!1)}),e.jsx(ge,{isOpen:h,title:"Unsaved Changes",message:"You have unsaved changes. Close anyway?",confirmLabel:"Close anyway",cancelLabel:"Keep editing",variant:"danger",onConfirm:t,onClose:()=>_(!1)})]}):null}const Xe={enabled:!1,baseUrl:"",defaultSessionId:"",webhookVerifyToken:"",showIncomingToasts:!0},ba=2500,ja=12e4;function Qe(s){return{enabled:s.enabled??!1,baseUrl:s.baseUrl??"",defaultSessionId:s.defaultSessionId??"",webhookVerifyToken:s.webhookVerifyToken??"",showIncomingToasts:s.showIncomingToasts??!0}}function wa(s,t){return s.enabled===t.enabled&&s.baseUrl===t.baseUrl&&s.defaultSessionId===t.defaultSessionId&&s.webhookVerifyToken===t.webhookVerifyToken&&s.showIncomingToasts===t.showIncomingToasts}function ya({isOpen:s,onClose:t}){const{t:a}=Y(["config"]),[o,r]=l.useState(Xe),[d,c]=l.useState(Xe),[n,u]=l.useState(!1),[w,x]=l.useState([]),[b,p]=l.useState(!0),[f,m]=l.useState(null),[y,j]=l.useState(null),[h,_]=l.useState(""),[D,P]=l.useState(!1),[C,A]=l.useState(""),[V,M]=l.useState(null),[K,N]=l.useState(null),[S,H]=l.useState(null),Z=l.useRef(null),ce=l.useRef(0),[k,O]=l.useState(""),[B,v]=l.useState(""),[F,R]=l.useState(null),[Q,ae]=l.useState(!1),[ee,T]=l.useState(!1),[q,ne]=l.useState(!1),[re,te]=l.useState(!1),[pe,ye]=l.useState(null),ve=!wa(o,d),ie=l.useCallback(()=>{Z.current&&(clearTimeout(Z.current),Z.current=null)},[]),L=l.useCallback(async()=>{try{p(!0),m(null),j(null);const[g,z]=await Promise.all([os(),ys()]),oe=Qe(g);if(r(oe),c(oe),u(!!z.configured),z.configured)try{const fe=await Be();x(Array.isArray(fe)?fe:[])}catch{x([])}else x([])}catch(g){m(g instanceof Error?g.message:a("config:whatsapp.errors.loadFailed"))}finally{p(!1)}},[a]),he=l.useCallback(async()=>{try{const g=await Be();x(Array.isArray(g)?g:[])}catch{}},[]);l.useEffect(()=>(s?L():(ie(),M(null),N(null),H(null),_(""),P(!1),R(null)),()=>{ie()}),[s,L,ie]);const se=(g,z)=>{r(oe=>({...oe,[g]:z})),m(null),j(null)},Le=async()=>{try{m(null),j(null);const g=await Ss({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 z=Qe(g);r(z),c(z),j(a("config:whatsapp.saved"))}catch(g){m(g instanceof Error?g.message:a("config:whatsapp.errors.saveFailed"))}},Se=()=>{r(d),m(null),j(null)},be=()=>{if(ve){T(!0);return}t()},De=g=>{g.key==="Escape"&&(g.preventDefault(),be())},Te=async()=>{const g=h.trim();if(g)try{m(null),j(null),await Ns(g),_(""),P(!1),u(!0),j(a("config:whatsapp.apiKeySaved"))}catch(z){m(z instanceof Error?z.message:a("config:whatsapp.errors.apiKeySaveFailed"))}},Fe=()=>{ne(!0)},Ae=async()=>{try{m(null),j(null),await Ts(),u(!1),j(a("config:whatsapp.apiKeyCleared"))}catch(g){m(g instanceof Error?g.message:a("config:whatsapp.errors.apiKeyClearFailed"))}},_e=l.useCallback(async g=>{if(Date.now()>ce.current){H(a("config:whatsapp.pairingTimeout")),M(null),N(null),ie(),he();return}try{const z=await vs(g);if(z.status&&["connected","paired","open","ready"].includes(z.status.toLowerCase())){H(a("config:whatsapp.pairingSuccess")),M(null),N(null),ie(),he();return}const fe=z.qrUrl??z.qr??null;fe&&N(fe)}catch(z){H(z instanceof Error?z.message:a("config:whatsapp.errors.qrFetchFailed"))}Z.current=setTimeout(()=>{_e(g)},ba)},[he,ie,a]),Ee=async()=>{const g=C.trim();if(g)try{m(null),j(null),H(null),N(null),ie(),await ks(g),A(""),M(g),ce.current=Date.now()+ja,_e(g),he()}catch(z){m(z instanceof Error?z.message:a("config:whatsapp.errors.sessionCreateFailed"))}},Ne=()=>{ie(),M(null),N(null),H(null)},Oe=g=>{ye(g),te(!0)},Ie=async()=>{if(pe)try{m(null),j(null),await As(pe),V===pe&&Ne(),he(),j(a("config:whatsapp.sessionDeleted"))}catch(g){m(g instanceof Error?g.message:a("config:whatsapp.errors.sessionDeleteFailed"))}finally{ye(null)}},ue=async()=>{const g=k.trim(),z=B.trim();if(!(!g||!z))try{ae(!0),R(null);const oe=o.defaultSessionId.trim()||void 0;await Cs(g,z,oe),R({kind:"success",text:a("config:whatsapp.testSent")})}catch(oe){R({kind:"error",text:oe instanceof Error?oe.message:a("config:whatsapp.errors.testSendFailed")})}finally{ae(!1)}};return s?e.jsxs(Ce,{children:[e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:be,children:e.jsxs("div",{className:"whatsapp-config-modal",onClick:g=>g.stopPropagation(),onKeyDown:De,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:a("config:whatsapp.title")}),e.jsx("button",{className:"modal-close",onClick:be,"aria-label":"Close",children:e.jsx($,{name:"close",size:16})})]}),e.jsx("div",{className:"modal-body",children:b?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")}),f&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:e.jsx($,{name:"warn",size:14})}),f]}),y&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx($,{name:"check",size:14})}),y]}),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:g=>se("enabled",g.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:g=>se("showIncomingToasts",g.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:g=>se("baseUrl",g.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:g=>se("defaultSessionId",g.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:g=>se("webhookVerifyToken",g.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($,{name:"check",size:12})," ",a("config:whatsapp.configured")]}):e.jsxs("span",{className:"wa-status wa-status-warn",children:[e.jsx($,{name:"warn",size:12})," ",a("config:whatsapp.notConfigured")]})}),e.jsxs("div",{className:"wa-field wa-field-inline",children:[e.jsx("input",{type:D?"text":"password",className:"wa-input",placeholder:a("config:whatsapp.apiKeyPlaceholder"),value:h,onChange:g=>_(g.target.value)}),e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>P(g=>!g),title:a(D?"config:whatsapp.hideKey":"config:whatsapp.showKey"),children:e.jsx($,{name:D?"eye-closed":"eye",size:14})}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:Te,disabled:!h.trim(),children:a("config:whatsapp.saveKey")}),e.jsx("button",{type:"button",className:"btn btn-danger",onClick:Fe,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(w)||w.length===0?e.jsx("div",{className:"wa-empty",children:a("config:whatsapp.noSessions")}):w.map(g=>e.jsxs("div",{className:"wa-session-row",children:[e.jsxs("div",{className:"wa-session-info",children:[e.jsx("span",{className:"wa-session-id",children:g.id}),e.jsx("span",{className:`wa-session-status status-${(g.status??"unknown").toLowerCase()}`,children:g.status||"—"}),g.pairedNumber&&e.jsx("span",{className:"wa-session-paired",children:g.pairedNumber})]}),e.jsx("button",{type:"button",className:"btn btn-danger btn-sm",onClick:()=>Oe(g.id),children:a("config:whatsapp.deleteSession")})]},g.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:C,onChange:g=>A(g.target.value),onKeyDown:g=>{g.key==="Enter"&&Ee()}}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:Ee,disabled:!C.trim()||V!==null,children:a("config:whatsapp.addSession")})]}),V&&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:V})}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Ne,children:a("config:whatsapp.cancelPairing")})]}),K?e.jsx("div",{className:"wa-qr-image",children:e.jsx("img",{src:K,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")})]})]}),S&&!V&&e.jsx("div",{className:"wa-pairing-message",children:S})]}),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:k,onChange:g=>O(g.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:B,onChange:g=>v(g.target.value)})]}),e.jsx("div",{className:"wa-field-inline wa-field-end",children:e.jsx("button",{type:"button",className:"btn btn-primary",onClick:ue,disabled:!k.trim()||!B.trim()||Q,children:a(Q?"config:whatsapp.sending":"config:whatsapp.sendTest")})}),F&&e.jsxs("div",{className:`alert ${F.kind==="success"?"alert-success":"alert-error"}`,children:[e.jsx("span",{className:"alert-icon",children:e.jsx($,{name:F.kind==="success"?"check":"warn",size:14})}),F.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:be,children:a("config:whatsapp.close")}),e.jsx("button",{className:"btn btn-secondary",onClick:Se,disabled:!ve||b,children:a("config:whatsapp.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:Le,disabled:!ve||b,children:a("config:whatsapp.save")})]})]})]})}),e.jsx(ge,{isOpen:ee,title:a("config:whatsapp.unsavedTitle"),message:a("config:whatsapp.unsavedMessage"),confirmLabel:a("config:whatsapp.closeAnyway"),cancelLabel:a("config:whatsapp.keepEditing"),variant:"danger",onConfirm:()=>{T(!1),t()},onClose:()=>T(!1)}),e.jsx(ge,{isOpen:q,title:a("config:whatsapp.clearKey"),message:a("config:whatsapp.confirmClearKey"),confirmLabel:a("config:whatsapp.clearKey"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{Ae()},onClose:()=>ne(!1)}),e.jsx(ge,{isOpen:re,title:a("config:whatsapp.deleteSession"),message:a("config:whatsapp.confirmDeleteSession",{id:pe??""}),confirmLabel:a("config:whatsapp.deleteSession"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{Ie()},onClose:()=>{te(!1),ye(null)}})]}):null}const cs=["messages","statusChanges","taskComplete","errors","planReady","agentSpawned","agentStopped"];function He(s=!1){const t=X(),a={};return t&&(a.Authorization=`Bearer ${t}`),s&&(a["Content-Type"]="application/json"),a}async function We(s,t){try{const a=await s.json();if(a&&typeof a.error=="string")return a.error;if(a&&typeof a.message=="string")return a.message}catch{}return`${t}: ${s.statusText}`}async function va(){const s=await fetch(`${J()}/api/whatsapp/notification-config`,{headers:He()});if(!s.ok)throw new Error(await We(s,"Failed to fetch WhatsApp notification config"));return s.json()}async function Na(s){const t=await fetch(`${J()}/api/whatsapp/notification-config`,{method:"PATCH",headers:He(!0),body:JSON.stringify(s)});if(!t.ok)throw new Error(await We(t,"Failed to update WhatsApp notification config"));return t.json()}async function ka(){const s=await fetch(`${J()}/api/whatsapp/notification-config`,{method:"DELETE",headers:He()});if(!s.ok)throw new Error(await We(s,"Failed to reset WhatsApp notification config"));return s.json()}const $e={messages:!0,statusChanges:!0,taskComplete:!0,errors:!0,planReady:!0,agentSpawned:!0,agentStopped:!0},es={filter:{...$e},recipient:""};function Ca(s,t){if(s.recipient!==t.recipient)return!1;for(const a of cs)if(s.filter[a]!==t.filter[a])return!1;return!0}function Sa({isOpen:s,onClose:t}){const{t:a}=Y(["config"]),[o,r]=l.useState(es),[d,c]=l.useState(es),[n,u]=l.useState(!0),[w,x]=l.useState(null),[b,p]=l.useState(null),[f,m]=l.useState(!1),[y,j]=l.useState(!1),h=!Ca(o,d),_=l.useCallback(async()=>{try{u(!0),x(null),p(null);const N=await va(),S={filter:{...$e,...N.filter},recipient:N.recipient??""};r(S),c(S)}catch(N){x(N instanceof Error?N.message:a("config:whatsappNotifications.errors.loadFailed"))}finally{u(!1)}},[a]);l.useEffect(()=>{s&&_()},[s,_]);const D=(N,S)=>{r(H=>({...H,filter:{...H.filter,[N]:S}})),x(null),p(null)},P=N=>{r(S=>({...S,recipient:N})),x(null),p(null)},C=async()=>{try{x(null),p(null);const N=await Na({filter:o.filter,recipient:o.recipient.trim()}),S={filter:{...$e,...N.filter},recipient:N.recipient??""};r(S),c(S),p(a("config:whatsappNotifications.saved"))}catch(N){x(N instanceof Error?N.message:a("config:whatsappNotifications.errors.saveFailed"))}},A=()=>{r(d),x(null),p(null)},V=async()=>{try{x(null),p(null);const N=await ka(),S={filter:{...$e,...N.filter},recipient:N.recipient??""};r(S),c(S),p(a("config:whatsappNotifications.resetDone"))}catch(N){x(N instanceof Error?N.message:a("config:whatsappNotifications.errors.resetFailed"))}},M=()=>{if(h){m(!0);return}t()},K=N=>{N.key==="Escape"&&(N.preventDefault(),M())};return s?e.jsxs(Ce,{children:[e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:M,children:e.jsxs("div",{className:"whatsapp-notifications-modal",onClick:N=>N.stopPropagation(),onKeyDown:K,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:a("config:whatsappNotifications.title")}),e.jsx("button",{className:"modal-close",onClick:M,"aria-label":"Close",children:e.jsx($,{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:a("config:whatsappNotifications.loading")})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"modal-description",children:a("config:whatsappNotifications.description")}),w&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:e.jsx($,{name:"warn",size:14})}),w]}),b&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx($,{name:"check",size:14})}),b]}),e.jsxs("section",{className:"wan-section",children:[e.jsx("h3",{className:"wan-section-title",children:a("config:whatsappNotifications.sections.recipient")}),e.jsxs("div",{className:"wan-field",children:[e.jsx("label",{htmlFor:"wan-recipient",className:"wan-label",children:a("config:whatsappNotifications.recipientLabel")}),e.jsx("input",{id:"wan-recipient",type:"text",className:"wan-input",placeholder:a("config:whatsappNotifications.recipientPlaceholder"),value:o.recipient,onChange:N=>P(N.target.value)}),e.jsx("span",{className:"wan-hint",children:a("config:whatsappNotifications.recipientHint")})]})]}),e.jsxs("section",{className:"wan-section",children:[e.jsx("h3",{className:"wan-section-title",children:a("config:whatsappNotifications.sections.events")}),e.jsx("p",{className:"wan-section-hint",children:a("config:whatsappNotifications.eventsHint")}),cs.map(N=>e.jsxs("div",{className:"wan-toggle-row",children:[e.jsxs("div",{className:"wan-toggle-info",children:[e.jsx("span",{className:"wan-toggle-title",children:a(`config:whatsappNotifications.events.${N}.title`)}),e.jsx("span",{className:"wan-toggle-help",children:a(`config:whatsappNotifications.events.${N}.help`)})]}),e.jsxs("label",{className:"wan-toggle",children:[e.jsx("input",{type:"checkbox",checked:o.filter[N],onChange:S=>D(N,S.target.checked)}),e.jsx("span",{className:"wan-toggle-track",children:e.jsx("span",{className:"wan-toggle-thumb"})})]})]},N))]})]})}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("div",{className:"footer-buttons-left",children:e.jsx("button",{className:"btn btn-danger",onClick:()=>j(!0),disabled:n,children:a("config:whatsappNotifications.resetToDefaults")})}),e.jsxs("div",{className:"footer-buttons-right",children:[e.jsx("button",{className:"btn btn-secondary",onClick:M,children:a("config:whatsappNotifications.close")}),e.jsx("button",{className:"btn btn-secondary",onClick:A,disabled:!h||n,children:a("config:whatsappNotifications.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:C,disabled:!h||n,children:a("config:whatsappNotifications.save")})]})]})]})}),e.jsx(ge,{isOpen:f,title:a("config:whatsappNotifications.unsavedTitle"),message:a("config:whatsappNotifications.unsavedMessage"),confirmLabel:a("config:whatsappNotifications.closeAnyway"),cancelLabel:a("config:whatsappNotifications.keepEditing"),variant:"danger",onConfirm:()=>{m(!1),t()},onClose:()=>m(!1)}),e.jsx(ge,{isOpen:y,title:a("config:whatsappNotifications.resetToDefaults"),message:a("config:whatsappNotifications.confirmReset"),confirmLabel:a("config:whatsappNotifications.resetToDefaults"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{V(),j(!1)},onClose:()=>j(!1)})]}):null}function rs(s){const t=s.replace(/@.*$/,"");return/^\d{10,15}$/.test(t)?t.startsWith("521")&&t.length===13?`+52 1 ${t.slice(3,5)} ${t.slice(5,9)} ${t.slice(9)}`:t.startsWith("52")&&t.length===12?`+52 ${t.slice(2,4)} ${t.slice(4,8)} ${t.slice(8)}`:t.startsWith("1")&&t.length===11?`+1 ${t.slice(1,4)} ${t.slice(4,7)} ${t.slice(7)}`:`+${t}`:s}function Ta(s,t=Date.now()){const a=s*1e3,o=t-a;if(o<0)return ss(a);const r=Math.floor(o/6e4);if(r<1)return"now";if(r<60)return`${r}m`;const d=Math.floor(r/60);if(d<24)return`${d}h`;const c=Math.floor(d/24);return c===1?"yesterday":c<7?`${c}d`:ss(a)}function ss(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Aa(s){const t=s*1e3;return new Date(t).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1})}function ds(s){switch(s){case"image":return"📷";case"audio":return"🎤";case"video":return"📹";case"document":return"📎";case"location":return"📍";case"contact":return"👤";case"sticker":return"🌟";case"reaction":return"👍";case"unknown":return"❓";case"text":default:return null}}function _a(s,t){return s.length<=t?s:s.slice(0,Math.max(0,t-1)).trimEnd()+"…"}function Ea({chats:s,selectedChatId:t,loading:a,error:o,onSelect:r,onRefresh:d,now:c}){const{t:n}=Y(["config","common"]);return e.jsxs("div",{className:"whatsapp-history-chatlist",children:[e.jsxs("div",{className:"whatsapp-history-chatlist__header",children:[e.jsx("span",{className:"whatsapp-history-chatlist__title",children:n("config:whatsappHistory.chats")}),e.jsx("button",{type:"button",className:"whatsapp-history-chatlist__refresh",onClick:d,disabled:a,"aria-label":n("config:whatsappHistory.refresh"),title:n("config:whatsappHistory.refresh"),children:"⟳"})]}),o&&e.jsx("div",{className:"whatsapp-history-chatlist__error",children:o}),a&&s.length===0&&e.jsxs("div",{className:"whatsapp-history-chatlist__loading",children:[e.jsx("span",{className:"spinner"}),e.jsx("span",{children:n("config:whatsappHistory.loadingChats")})]}),!a&&!o&&s.length===0&&e.jsx("div",{className:"whatsapp-history-chatlist__empty",children:n("config:whatsappHistory.emptyChats")}),e.jsx("ul",{className:"whatsapp-history-chatlist__items",children:s.map(u=>{const w=ds(u.lastMessageType),x=u.lastMessagePreview||`[${u.lastMessageType}]`,b=u.chatId===t;return e.jsx("li",{className:`whatsapp-history-chatlist__item ${b?"is-selected":""}`,children:e.jsxs("button",{type:"button",className:"whatsapp-history-chatlist__button",onClick:()=>r(u.chatId),children:[e.jsxs("div",{className:"whatsapp-history-chatlist__row",children:[e.jsx("span",{className:"whatsapp-history-chatlist__name",children:rs(u.chatId)}),e.jsx("span",{className:"whatsapp-history-chatlist__time",children:Ta(u.lastTimestamp,c)})]}),e.jsxs("div",{className:"whatsapp-history-chatlist__row whatsapp-history-chatlist__row--secondary",children:[e.jsxs("span",{className:"whatsapp-history-chatlist__preview",children:[u.lastDirection==="outbound"&&e.jsx("span",{className:"whatsapp-history-chatlist__direction",children:"↗ "}),w&&e.jsxs("span",{className:"whatsapp-history-chatlist__preview-icon",children:[w," "]}),_a(x,40)]}),u.unreadCount>0&&e.jsx("span",{className:"whatsapp-history-chatlist__unread",children:u.unreadCount})]})]})},u.chatId)})})]})}function Ia({message:s}){const t=s.direction==="outbound"?"outbound":"inbound",a=ds(s.messageType),o=(s.body??"").trim(),r=o.length>0,d=r?null:`[${s.messageType}]`;return e.jsx("div",{className:`whatsapp-history-bubble whatsapp-history-bubble--${t}`,children:e.jsxs("div",{className:"whatsapp-history-bubble__inner",children:[a&&e.jsx("span",{className:"whatsapp-history-bubble__type-icon",title:s.messageType,children:a}),r?e.jsx("span",{className:"whatsapp-history-bubble__body",children:o}):e.jsx("span",{className:"whatsapp-history-bubble__placeholder",children:d}),s.audioTranscription&&e.jsxs("span",{className:"whatsapp-history-bubble__transcription",children:["“",s.audioTranscription,"”"]}),s.mediaPath&&e.jsx("a",{className:"whatsapp-history-bubble__media-link",href:s.mediaPath,target:"_blank",rel:"noopener noreferrer",children:s.mediaFilename||"open media"}),e.jsx("span",{className:"whatsapp-history-bubble__time",children:Aa(s.timestamp)})]})})}const Pa=["all","inbound","outbound"],$a=["all","text","image","audio","video","document","sticker","location","contact","reaction","unknown"];function La({direction:s,type:t,onDirectionChange:a,onTypeChange:o,disabled:r}){const{t:d}=Y(["config"]);return e.jsxs("div",{className:"whatsapp-history-filters",children:[e.jsxs("label",{className:"whatsapp-history-filters__field",children:[e.jsx("span",{children:d("config:whatsappHistory.direction")}),e.jsx("select",{value:s,onChange:c=>a(c.target.value),disabled:r,children:Pa.map(c=>e.jsx("option",{value:c,children:d(`config:whatsappHistory.directionValues.${c}`)},c))})]}),e.jsxs("label",{className:"whatsapp-history-filters__field",children:[e.jsx("span",{children:d("config:whatsappHistory.type")}),e.jsx("select",{value:t,onChange:c=>o(c.target.value),disabled:r,children:$a.map(c=>e.jsx("option",{value:c,children:d(`config:whatsappHistory.typeValues.${c}`)},c))})]})]})}function Da({chatId:s,messages:t,loading:a,loadingMore:o,error:r,hasMore:d,direction:c,type:n,onDirectionChange:u,onTypeChange:w,onLoadMore:x}){const{t:b}=Y(["config"]),p=l.useRef(null),f=l.useRef(null);return l.useEffect(()=>{p.current&&f.current!==s&&(f.current=s,p.current.scrollTop=p.current.scrollHeight)},[s,t.length]),s?e.jsxs("div",{className:"whatsapp-history-messages",children:[e.jsxs("div",{className:"whatsapp-history-messages__header",children:[e.jsx("div",{className:"whatsapp-history-messages__title",children:rs(s)}),e.jsx(La,{direction:c,type:n,onDirectionChange:u,onTypeChange:w,disabled:a})]}),e.jsxs("div",{className:"whatsapp-history-messages__scroll",ref:p,children:[d&&e.jsx("div",{className:"whatsapp-history-messages__load-more-row",children:e.jsx("button",{type:"button",className:"whatsapp-history-messages__load-more",onClick:x,disabled:o||a,children:b(o?"config:whatsappHistory.loadingOlder":"config:whatsappHistory.loadOlder")})}),r&&e.jsx("div",{className:"whatsapp-history-messages__error",children:r}),a&&t.length===0&&e.jsxs("div",{className:"whatsapp-history-messages__loading",children:[e.jsx("span",{className:"spinner"}),e.jsx("span",{children:b("config:whatsappHistory.loadingMessages")})]}),!a&&!r&&t.length===0&&e.jsx("div",{className:"whatsapp-history-messages__empty",children:b("config:whatsappHistory.emptyMessages")}),t.map(m=>e.jsx(Ia,{message:m},Fa(m)))]})]}):e.jsx("div",{className:"whatsapp-history-messages whatsapp-history-messages--empty",children:e.jsx("div",{className:"whatsapp-history-messages__placeholder",children:b("config:whatsappHistory.selectChat")})})}function Fa(s){return typeof s.id=="number"?`id:${s.id}`:s.messageId?`mid:${s.messageId}`:`t:${s.timestamp}:${s.fromJid}:${(s.body??"").slice(0,16)}`}function us(){const s=X(),t={};return s&&(t.Authorization=`Bearer ${s}`),t}async function ps(s,t){try{const a=await s.json();if(a&&typeof a.error=="string")return a.error;if(a&&typeof a.message=="string")return a.message}catch{}return`${t}: ${s.statusText}`}async function Oa(s){const t=`${J()}/api/whatsapp/chats/${encodeURIComponent(s)}`,a=await fetch(t,{headers:us()});if(!a.ok)throw new Error(await ps(a,"Failed to fetch WhatsApp chats"));return a.json()}async function as(s,t,a={}){const o=new URLSearchParams;a.cursor&&o.set("cursor",a.cursor),typeof a.limit=="number"&&o.set("limit",String(a.limit)),a.direction&&o.set("direction",a.direction),a.type&&o.set("type",a.type);const r=o.toString(),d=`${J()}/api/whatsapp/chats/${encodeURIComponent(s)}/${encodeURIComponent(t)}/messages${r?`?${r}`:""}`,c=await fetch(d,{headers:us()});if(!c.ok)throw new Error(await ps(c,"Failed to fetch WhatsApp messages"));return c.json()}const Ra=50;function Ua({isOpen:s,onClose:t}){const{t:a}=Y(["config"]),[o,r]=l.useState([]),[d,c]=l.useState(null),[n,u]=l.useState(null),[w,x]=l.useState([]),[b,p]=l.useState(!1),[f,m]=l.useState(null),[y,j]=l.useState(null),[h,_]=l.useState([]),[D,P]=l.useState(!1),[C,A]=l.useState(!1),[V,M]=l.useState(null),[K,N]=l.useState(null),[S,H]=l.useState("all"),[Z,ce]=l.useState("all"),[k,O]=l.useState(()=>Date.now()),B=l.useRef(0);l.useEffect(()=>{if(!s)return;const T=window.setInterval(()=>O(Date.now()),6e4);return()=>window.clearInterval(T)},[s]),l.useEffect(()=>{if(!s)return;let T=!1;return(async()=>{var q;try{u(null);const[ne,re]=await Promise.all([Be().catch(()=>[]),os().catch(()=>null)]);if(T)return;r(ne);const te=(re==null?void 0:re.defaultSessionId)||((q=ne[0])==null?void 0:q.id)||null;c(pe=>pe??te)}catch(ne){if(T)return;u(ne instanceof Error?ne.message:String(ne))}})(),()=>{T=!0}},[s]);const v=l.useCallback(async T=>{p(!0),m(null);try{const q=await Oa(T);x(q.chats)}catch(q){m(q instanceof Error?q.message:String(q))}finally{p(!1)}},[]);l.useEffect(()=>{!s||!d||(j(null),_([]),N(null),v(d))},[s,d,v]);const F=l.useMemo(()=>{const T={limit:Ra};return S!=="all"&&(T.direction=S),Z!=="all"&&(T.type=Z),T},[S,Z]),R=l.useCallback(async(T,q,ne)=>{const re=++B.current;P(!0),M(null),_([]),N(null);try{const te=await as(T,q,ne);if(re!==B.current)return;_([...te.messages].reverse()),N(te.nextCursor)}catch(te){if(re!==B.current)return;M(te instanceof Error?te.message:String(te))}finally{re===B.current&&P(!1)}},[]);l.useEffect(()=>{!s||!d||!y||R(d,y,F)},[s,d,y,F,R]);const Q=l.useCallback(async()=>{if(!(!d||!y||!K)){A(!0),M(null);try{const T=await as(d,y,{...F,cursor:K});_(q=>[...[...T.messages].reverse(),...q]),N(T.nextCursor)}catch(T){M(T instanceof Error?T.message:String(T))}finally{A(!1)}}},[d,y,K,F]),ae=l.useCallback(()=>{d&&v(d)},[d,v]),ee=l.useCallback(T=>{T.key==="Escape"&&(T.preventDefault(),t())},[t]);return s?e.jsx(Ce,{children:e.jsx("div",{className:"modal-overlay visible",onClick:t,children:e.jsxs("div",{className:"whatsapp-history-modal",onClick:T=>T.stopPropagation(),onKeyDown:ee,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:a("config:whatsappHistory.title")}),e.jsx("div",{className:"whatsapp-history-modal__session",children:e.jsxs("label",{children:[e.jsx("span",{children:a("config:whatsappHistory.session")}),e.jsxs("select",{value:d??"",onChange:T=>c(T.target.value||null),disabled:o.length===0,children:[o.length===0&&e.jsx("option",{value:"",children:a("config:whatsappHistory.noSessions")}),o.map(T=>e.jsxs("option",{value:T.id,children:[T.id,T.pairedNumber?` (${T.pairedNumber})`:""]},T.id))]})]})}),e.jsx("button",{className:"modal-close",onClick:t,"aria-label":"Close",children:e.jsx($,{name:"close",size:16})})]}),n&&e.jsx("div",{className:"whatsapp-history-modal__alert",children:n}),e.jsxs("div",{className:"whatsapp-history-modal__body",children:[e.jsx(Ea,{chats:w,selectedChatId:y,loading:b,error:f,onSelect:j,onRefresh:ae,now:k}),e.jsx(Da,{chatId:y,messages:h,loading:D,loadingMore:C,error:V,hasMore:K!==null,direction:S,type:Z,onDirectionChange:H,onTypeChange:ce,onLoadMore:Q})]})]})})}):null}function za({isOpen:s,onClose:t,onOpenConfig:a,onOpenNotifications:o,onOpenHistory:r}){const{t:d}=Y(["config"]);if(l.useEffect(()=>{if(!s)return;const n=u=>{u.key==="Escape"&&(u.preventDefault(),t())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[s,t]),!s)return null;const c=n=>{t(),n()};return e.jsx(Ce,{children:e.jsx("div",{className:"modal-overlay visible",onClick:t,children:e.jsxs("div",{className:"whatsapp-hub-modal",onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("h2",{children:[e.jsx("span",{className:"whatsapp-hub-modal__icon",children:"📱"}),d("config:whatsappHub.title",{defaultValue:"WhatsApp"})]}),e.jsx("button",{className:"modal-close",onClick:t,"aria-label":"Close",children:e.jsx($,{name:"close",size:16})})]}),e.jsxs("div",{className:"modal-body",children:[e.jsx("p",{className:"whatsapp-hub-modal__intro",children:d("config:whatsappHub.intro",{defaultValue:"Pick what you want to manage for the WhatsApp integration."})}),e.jsxs("div",{className:"whatsapp-hub-modal__options",children:[e.jsxs("button",{type:"button",className:"whatsapp-hub-modal__option",onClick:()=>c(a),children:[e.jsx("span",{className:"whatsapp-hub-modal__option-icon",children:e.jsx($,{name:"gear",size:18})}),e.jsxs("span",{className:"whatsapp-hub-modal__option-text",children:[e.jsx("span",{className:"whatsapp-hub-modal__option-title",children:d("config:whatsappHub.config",{defaultValue:"Integration config"})}),e.jsx("span",{className:"whatsapp-hub-modal__option-desc",children:d("config:whatsappHub.configDesc",{defaultValue:"Server URL, API key, sessions and pairing."})})]})]}),e.jsxs("button",{type:"button",className:"whatsapp-hub-modal__option",onClick:()=>c(o),children:[e.jsx("span",{className:"whatsapp-hub-modal__option-icon",children:e.jsx($,{name:"bell",size:18})}),e.jsxs("span",{className:"whatsapp-hub-modal__option-text",children:[e.jsx("span",{className:"whatsapp-hub-modal__option-title",children:d("config:whatsappHub.notifications",{defaultValue:"Notifications"})}),e.jsx("span",{className:"whatsapp-hub-modal__option-desc",children:d("config:whatsappHub.notificationsDesc",{defaultValue:"Which agent events get forwarded and to whom."})})]})]}),e.jsxs("button",{type:"button",className:"whatsapp-hub-modal__option",onClick:()=>c(r),children:[e.jsx("span",{className:"whatsapp-hub-modal__option-icon",children:e.jsx($,{name:"hourglass",size:18})}),e.jsxs("span",{className:"whatsapp-hub-modal__option-text",children:[e.jsx("span",{className:"whatsapp-hub-modal__option-title",children:d("config:whatsappHub.history",{defaultValue:"History"})}),e.jsx("span",{className:"whatsapp-hub-modal__option-desc",children:d("config:whatsappHub.historyDesc",{defaultValue:"Browse persisted chats and messages."})})]})]})]})]})]})})})}const Ma=[{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:"🌙"}],Ba=[{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:"🔴"}],Va=[{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:"👎"}],Ka=[{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:"💜"}],Ha=[{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"}],Wa=[{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"}],qa={showTrees:"trees",showBushes:"bushes",showHouse:"house",showLamps:"lamps",showGrass:"grass",showClouds:"clouds"},Ga={none:"grass","pokemon-stadium":"pokemon"},Ya={"emote-yes":"yes","emote-no":"no"},Ja={"":"auto","#4a90d9":"dayBlue","#0a1a2a":"night","#ff6b35":"sunset","#1a0a2e":"purple","#2d5a27":"matrix","#8b0000":"blood","#000000":"void"};function le({checked:s,onChange:t}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,onChange:a=>t(a.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function je({options:s,value:t,onChange:a,iconOnly:o=!1}){return e.jsx("div",{className:"chip-selector",children:s.map(r=>e.jsxs("button",{className:`chip ${t===r.value?"active":""}`,onClick:()=>a(r.value),title:r.label,children:[e.jsx("span",{className:"chip-icon",children:r.icon}),!o&&e.jsx("span",{className:"chip-label",children:r.label})]},r.value))})}function I({text:s,query:t}){if(!t.trim())return e.jsx(e.Fragment,{children:s});const a=s.toLowerCase(),o=t.toLowerCase(),r=a.indexOf(o);if(r===-1)return e.jsx(e.Fragment,{children:s});const d=s.slice(0,r),c=s.slice(r,r+t.length),n=s.slice(r+t.length);return e.jsxs(e.Fragment,{children:[d,e.jsx("mark",{className:"search-highlight",children:c}),n]})}const Za=[{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:"data",title:"Data",keywords:["export","import","backup","restore","save","load","json"]},{id:"integrations",title:"Integrations",keywords:["integrations","integraciones","plugins","gmail","slack","jira","calendar","docx","email","whatsapp","notifications","notification","baileys","history","historial","chat","messages","inbox","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"]}],Me=[{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 Xa({config:s,onChange:t,searchQuery:a="",onOpenIntegrationsModal:o,onOpenMonitoringModal:r,onOpenWorkflowEditor:d,onOpenTriggerManager:c}){var qe;const{t:n}=Y(["config","common"]),u=Ve(),w=_s(),[x,b]=l.useState(()=>Es(ke.DEFAULT_AGENT_CLASS)||"scout"),[p,f]=l.useState(u.settings.historyLimit),[m,y]=l.useState(()=>Is()),[j,h]=l.useState(!1),[_,D]=l.useState(""),[P,C]=l.useState(()=>X()),[A,V]=l.useState(!1),[M,K]=l.useState(!1),[N,S]=l.useState(""),[H,Z]=l.useState(!1),[ce,k]=l.useState(!1),[O,B]=l.useState(!1),[v,F]=l.useState(!1),[R,Q]=l.useState(!1),[ae,ee]=l.useState(""),[T,q]=l.useState(!1);l.useEffect(()=>{aa().then(ee).catch(()=>{})},[]),l.useEffect(()=>{ea().then(i=>{i!==u.settings.experimentalEchoPrompt&&E.updateSettings({experimentalEchoPrompt:i})}).catch(()=>{})},[]),l.useEffect(()=>{na().then(i=>{i!==u.settings.tmuxMode&&E.updateSettings({tmuxMode:i})}).catch(()=>{})},[]),l.useEffect(()=>Ps(i=>{y(i),h(!1)}),[]);const ne=Ma.map(i=>({...i,label:n(`config:time.${i.value}`)})),re=Ba.map(i=>({...i,label:n(`config:floor.${Ga[i.value]||i.value}`)})),te=Va.map(i=>({...i,label:n(`config:animation.${Ya[i.value]||i.value}`)})),pe=Ka.map(i=>({...i,label:n(`config:colorMode.${i.value}`)})),ye=Ha.map(i=>({...i,label:n(`config:terrain.${qa[i.key]}`)})),ve=Wa.map(i=>({...i,label:n(`config:sky.${Ja[i.value??""]}`)})),ie=a.trim()?Za.filter(i=>{const U=a.toLowerCase();return i.title.toLowerCase().includes(U)||i.keywords.some(de=>de.toLowerCase().includes(U))}).map(i=>i.id):null,L=i=>ie?ie.includes(i):!0,he=L("integrations"),se=u.settings.customAgentNames||[],Le=se.length>0?se:$s,Se=()=>{const i=N.trim();i&&!se.includes(i)&&(E.updateSettings({customAgentNames:[...se,i]}),S(""))},be=i=>{E.updateSettings({customAgentNames:se.filter(U=>U!==i)})},De=()=>{E.updateSettings({customAgentNames:[]})},Te=()=>{const i=_.trim();if(i){if(m.includes(i)){D("");return}y([...m,i]),h(!0),D("")}},Fe=i=>{y(m.filter((U,de)=>de!==i)),h(!0)},Ae=(i,U)=>{const de=i+U;if(de<0||de>=m.length)return;const xe=m.slice();[xe[i],xe[de]]=[xe[de],xe[i]],y(xe),h(!0)},_e=()=>{Ds(m),h(!1),ze()},Ee=i=>{C(i),V(!0)},Ne=()=>{Pe(ke.AUTH_TOKEN,P),V(!1),ze()},Oe=i=>{ee(i),q(!0)},Ie=()=>{ta(ae).catch(()=>{}),q(!1)},ue=i=>{t({...s,terrain:{...s.terrain,...i}})},g=i=>{t({...s,modelStyle:{...s.modelStyle,...i}})},z=i=>{t({...s,animations:{...s.animations,...i}})},oe=i=>{f(i),E.updateSettings({historyLimit:i})},fe=i=>{const U=s.terrain[i];typeof U=="boolean"&&ue({[i]:!U})},G=a.trim().length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"config-section",children:[ie&&ie.length===0&&e.jsx("div",{className:"config-no-results",children:n("config:noResults",{query:a})}),L("general")&&e.jsxs(W,{title:n("config:sections.general"),storageKey:"general",defaultOpen:!0,forceOpen:G&&L("general"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(I,{text:n("config:general.history"),query:a})}),e.jsx("input",{type:"number",className:"config-input config-input-sm",value:p,onChange:i=>oe(parseInt(i.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(I,{text:n("config:general.hideCosts"),query:a})}),e.jsx(le,{checked:u.settings.hideCost,onChange:i=>E.updateSettings({hideCost:i})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(I,{text:n("config:general.grid"),query:a})}),e.jsx(le,{checked:s.gridVisible,onChange:i=>t({...s,gridVisible:i})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(I,{text:n("config:general.showFPS"),query:a})}),e.jsx(le,{checked:u.settings.showFPS,onChange:i=>E.updateSettings({showFPS:i})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(I,{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:i=>t({...s,fpsLimit:parseInt(i.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(I,{text:n("config:general.powerSaving"),query:a})," ",e.jsx($,{name:"bolt",size:12})]}),e.jsx(le,{checked:u.settings.powerSaving,onChange:i=>E.updateSettings({powerSaving:i})})]}),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(I,{text:n("config:general.tmuxMode"),query:a})}),e.jsx(le,{checked:u.settings.tmuxMode,onChange:async i=>{E.updateSettings({tmuxMode:i});try{await ia(i)}catch(U){console.error("Failed to sync tmux mode setting to server:",U)}}})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(I,{text:n("config:general.vibrationIntensity"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"5",step:"1",value:u.settings.vibrationIntensity,onChange:i=>E.updateSettings({vibrationIntensity:parseInt(i.target.value)})}),e.jsx("span",{className:"config-value",children:u.settings.vibrationIntensity===0?n("config:vibrationValues.off"):u.settings.vibrationIntensity===1?n("config:vibrationValues.ultraLight"):u.settings.vibrationIntensity===2?n("config:vibrationValues.veryLight"):u.settings.vibrationIntensity===3?n("config:vibrationValues.light"):u.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(I,{text:n("config:general.externalEditor"),query:a})}),e.jsx("input",{type:"text",className:"config-input",placeholder:n("config:general.externalEditorPlaceholder"),value:u.settings.externalEditorCommand||"",onChange:i=>E.updateSettings({externalEditorCommand:i.target.value})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(I,{text:n("config:general.tabTitle"),query:a})}),e.jsx("input",{type:"text",className:"config-input",placeholder:n("config:general.tabTitlePlaceholder"),value:u.settings.tabTitle||"",onChange:i=>E.updateSettings({tabTitle:i.target.value})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(I,{text:n("config:general.language"),query:a})}),e.jsx(je,{options:Me,value:localStorage.getItem("tide-commander-language-mode")==="manual"?((qe=Me.find(i=>i.value!=="auto"&&Ue.language.startsWith(i.value.split("-")[0])))==null?void 0:qe.value)||"en":"auto",onChange:i=>{var U;if(i==="auto"){localStorage.setItem("tide-commander-language-mode","auto");const de=navigator.language,xe=((U=Me.find(Ge=>Ge.value!=="auto"&&de.startsWith(Ge.value.split("-")[0])))==null?void 0:U.value)||"en";Ue.changeLanguage(xe)}else localStorage.setItem("tide-commander-language-mode","manual"),Ue.changeLanguage(i)}})]})]}),L("agentNames")&&e.jsx(W,{title:n("config:sections.agentNames"),storageKey:"agentNames",defaultOpen:!1,forceOpen:G&&L("agentNames"),children:e.jsxs("div",{className:"agent-names-section",children:[e.jsx("span",{className:"config-hint",children:se.length>0?n("config:agentNames.customConfigured",{count:se.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:N,onChange:i=>S(i.target.value),onKeyDown:i=>{i.key==="Enter"&&Se()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:Se,disabled:!N.trim(),title:n("config:agentNames.addName"),children:"+"})]}),e.jsx("div",{className:"agent-names-list",children:Le.map((i,U)=>e.jsxs("div",{className:"agent-name-chip",children:[e.jsx("span",{className:"agent-name-text",children:i}),se.length>0&&e.jsx("button",{className:"agent-name-remove",onClick:()=>be(i),title:n("common:buttons.remove"),children:"x"})]},`${i}-${U}`))}),se.length>0&&e.jsx("button",{className:"config-btn config-btn-link",onClick:De,children:n("common:buttons.resetToDefaults")})]})}),L("defaultClass")&&e.jsx(W,{title:"Default Spawn Class",storageKey:"defaultClass",defaultOpen:!1,forceOpen:G&&L("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${x==="random"?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{b("random"),Pe(ke.DEFAULT_AGENT_CLASS,"random")},children:e.jsx("span",{className:"agent-name-text",children:"🎲 Random"})}),Object.entries(Ls).map(([i,U])=>e.jsx("div",{className:`agent-name-chip${x===i?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{b(i),Pe(ke.DEFAULT_AGENT_CLASS,i)},children:e.jsxs("span",{className:"agent-name-text",children:[U.icon," ",i.charAt(0).toUpperCase()+i.slice(1)]})},i)),w.map(i=>e.jsx("div",{className:`agent-name-chip${x===i.id?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{b(i.id),Pe(ke.DEFAULT_AGENT_CLASS,i.id)},children:e.jsxs("span",{className:"agent-name-text",children:[i.icon," ",i.name]})},i.id))]})]})}),L("appearance")&&e.jsx(W,{title:n("config:sections.appearance"),storageKey:"appearance",defaultOpen:!1,forceOpen:G&&L("appearance"),children:e.jsx(pa,{})}),L("connection")&&e.jsxs(W,{title:n("config:sections.connection"),storageKey:"connection",defaultOpen:!1,forceOpen:G&&L("connection"),children:[e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(I,{text:n("config:connection.backendUrl"),query:a})}),e.jsx("div",{className:"backend-urls-list",children:m.map((i,U)=>e.jsxs("div",{className:"backend-url-row",children:[e.jsx("span",{className:"backend-url-priority",title:n("config:connection.priorityLabel",{defaultValue:"Priority"}),children:U+1}),e.jsx("span",{className:"backend-url-text",title:i,children:i}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>Ae(U,-1),disabled:U===0,title:n("config:connection.moveUp",{defaultValue:"Move up"}),children:"↑"}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>Ae(U,1),disabled:U===m.length-1,title:n("config:connection.moveDown",{defaultValue:"Move down"}),children:"↓"}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>Fe(U),title:n("common:buttons.remove"),children:"x"})]},`${i}-${U}`))}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:_,onChange:i=>D(i.target.value),placeholder:n("config:connection.addUrlPlaceholder",{defaultValue:"http://host:port"}),onKeyDown:i=>{i.key==="Enter"&&Te()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:Te,disabled:!_.trim(),title:n("config:connection.addUrl",{defaultValue:"Add URL"}),children:"+"}),j&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:_e,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(I,{text:n("config:connection.authToken"),query:a})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:M?"text":"password",className:"config-input config-input-full",value:P,onChange:i=>Ee(i.target.value),placeholder:n("config:connection.tokenPlaceholder"),onKeyDown:i=>{i.key==="Enter"&&A&&Ne()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>K(!M),title:n(M?"config:connection.hideToken":"config:connection.showToken"),children:e.jsx($,{name:M?"eye-closed":"eye",size:14})}),A&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:Ne,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(I,{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:ae,onChange:i=>Oe(i.target.value),placeholder:n("config:connection.codexBinaryPathPlaceholder"),onKeyDown:i=>{i.key==="Enter"&&T&&Ie()}}),T&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:Ie,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(I,{text:n("common:buttons.reconnect"),query:a})}),e.jsx("button",{className:"config-btn",onClick:()=>ze(),title:"Force reconnect to server",children:n("common:buttons.reconnect")})]})]}),L("scene")&&e.jsxs(W,{title:n("config:sections.scene"),storageKey:"scene",defaultOpen:!1,forceOpen:G&&L("scene"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(I,{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:i=>t({...s,characterScale:parseFloat(i.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(I,{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:i=>t({...s,scale2d:parseFloat(i.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(I,{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:i=>t({...s,scale3d:parseFloat(i.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(I,{text:n("config:scene.show2DTaskLabels",{defaultValue:"Show 2D task labels"}),query:a})}),e.jsx(le,{checked:s.show2DTaskLabels,onChange:i=>t({...s,show2DTaskLabels:i})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(I,{text:n("config:scene.time"),query:a})}),e.jsx(je,{options:ne,value:s.timeMode,onChange:i=>t({...s,timeMode:i}),iconOnly:!0})]})]}),L("terrain")&&e.jsxs(W,{title:n("config:sections.terrain"),storageKey:"terrain",defaultOpen:!1,forceOpen:G&&L("terrain"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(I,{text:n("config:terrainSettings.simpleMode",{defaultValue:"Simple Mode"}),query:a})}),e.jsx(le,{checked:s.terrain.simpleMode??!1,onChange:i=>ue({simpleMode:i})})]}),e.jsx("div",{className:"terrain-icons",style:{opacity:s.terrain.simpleMode?.4:1,pointerEvents:s.terrain.simpleMode?"none":"auto"},children:ye.map(i=>e.jsx("button",{className:`terrain-icon-btn ${s.terrain[i.key]?"active":""}`,onClick:()=>fe(i.key),title:i.label,children:i.icon},i.key))}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(I,{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:i=>ue({fogDensity:parseFloat(i.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(I,{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:i=>ue({brightness:parseFloat(i.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(I,{text:n("config:terrainSettings.floor"),query:a})}),e.jsx(je,{options:re,value:s.terrain.floorStyle,onChange:i=>ue({floorStyle:i}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(I,{text:n("config:terrainSettings.sky"),query:a})}),e.jsx("div",{className:"sky-color-selector",children:ve.map(i=>e.jsx("button",{className:`sky-color-btn ${s.terrain.skyColor===i.value?"active":""}`,onClick:()=>ue({skyColor:i.value}),title:i.label,style:{background:i.color}},i.value??"auto"))})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(I,{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:i=>ue({battlefieldSize:parseInt(i.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.battlefieldSize})]})]}),L("modelStyle")&&e.jsxs(W,{title:n("config:sections.modelStyle"),storageKey:"modelStyle",defaultOpen:!1,forceOpen:G&&L("modelStyle"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(I,{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:i=>g({saturation:parseFloat(i.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(I,{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:i=>g({roughness:parseFloat(i.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(I,{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:i=>g({metalness:parseFloat(i.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(I,{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:i=>g({emissiveBoost:parseFloat(i.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(I,{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:i=>g({envMapIntensity:parseFloat(i.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(I,{text:n("config:modelStyleSettings.wireframe"),query:a})}),e.jsx(le,{checked:s.modelStyle.wireframe,onChange:i=>g({wireframe:i})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(I,{text:n("config:modelStyleSettings.colorMode"),query:a})}),e.jsx(je,{options:pe,value:s.modelStyle.colorMode,onChange:i=>g({colorMode:i}),iconOnly:!0})]})]}),L("animations")&&e.jsxs(W,{title:n("config:sections.animations"),storageKey:"animations",defaultOpen:!1,forceOpen:G&&L("animations"),children:[e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(I,{text:n("config:animationSettings.idle"),query:a})}),e.jsx(je,{options:te,value:s.animations.idleAnimation,onChange:i=>z({idleAnimation:i}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(I,{text:n("config:animationSettings.working"),query:a})}),e.jsx(je,{options:te,value:s.animations.workingAnimation,onChange:i=>z({workingAnimation:i}),iconOnly:!0})]})]}),L("secrets")&&e.jsx(W,{title:n("config:sections.secrets"),storageKey:"secrets",defaultOpen:!1,forceOpen:G&&L("secrets"),children:e.jsx(Js,{})}),L("systemPrompt")&&e.jsx(W,{title:n("config:sections.systemPrompt"),storageKey:"systemPrompt",defaultOpen:!1,forceOpen:G&&L("systemPrompt"),children:e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(I,{text:n("config:systemPrompt.title"),query:a})}),e.jsx("button",{className:"config-button",onClick:()=>Z(!0),children:n("config:systemPrompt.editPrompt")})]})}),L("data")&&e.jsx(W,{title:n("config:sections.data"),storageKey:"data",defaultOpen:!1,forceOpen:G&&L("data"),children:e.jsx(ra,{})}),he&&e.jsx(W,{title:n("config:sections.integrations"),storageKey:"integrations",defaultOpen:!1,forceOpen:G&&he,children:e.jsx(fa,{onOpenModal:i=>{i==="whatsapp"?Q(!0):o==null||o(i)}})}),L("workflows")&&e.jsxs(W,{title:"Workflows",storageKey:"workflows",defaultOpen:!1,forceOpen:G&&L("workflows"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(I,{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:()=>d==null?void 0:d(),children:"Open Workflow Editor"})})]}),L("triggers")&&e.jsxs(W,{title:"Triggers",storageKey:"triggers",defaultOpen:!1,forceOpen:G&&L("triggers"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(I,{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:()=>c==null?void 0:c(),children:"Open Trigger Manager"})})]}),L("monitoring")&&e.jsxs(W,{title:"Monitoring",storageKey:"monitoring",defaultOpen:!1,forceOpen:G&&L("monitoring"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(I,{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:()=>r==null?void 0:r(),children:"Open Monitoring & Logs"})})]}),L("experimental")&&e.jsxs(W,{title:n("config:sections.experimental"),storageKey:"experimental",defaultOpen:!1,forceOpen:G&&L("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(I,{text:n("config:experimental.2dView"),query:a})," ",e.jsx($,{name:"map",size:12})]}),e.jsx(le,{checked:u.settings.experimental2DView,onChange:i=>E.updateSettings({experimental2DView:i})})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Voice assistant for hands-free agent control",children:[e.jsx(I,{text:n("config:experimental.voiceAssistant"),query:a})," ",e.jsx($,{name:"microphone",size:12})]}),e.jsx(le,{checked:u.settings.experimentalVoiceAssistant,onChange:i=>E.updateSettings({experimentalVoiceAssistant:i})})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Text-to-speech for reading agent responses",children:[e.jsx(I,{text:n("config:experimental.tts"),query:a})," ",e.jsx($,{name:"speaker-on",size:12})]}),e.jsx(le,{checked:u.settings.experimentalTTS,onChange:i=>E.updateSettings({experimentalTTS:i})})]}),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(I,{text:n("config:experimental.echoPrompt"),query:a})}),e.jsx(le,{checked:u.settings.experimentalEchoPrompt,onChange:async i=>{E.updateSettings({experimentalEchoPrompt:i});try{await sa(i)}catch(U){console.error("Failed to sync echo prompt setting to server:",U)}}})]}),e.jsx("span",{className:"config-hint",children:n("config:experimental.hint")})]}),L("about")&&e.jsx(W,{title:n("config:sections.about"),storageKey:"about",defaultOpen:!1,forceOpen:G&&L("about"),children:e.jsx(ma,{})})]}),e.jsx(xa,{isOpen:H,onClose:()=>Z(!1)}),e.jsx(ya,{isOpen:ce,onClose:()=>k(!1)}),e.jsx(Sa,{isOpen:O,onClose:()=>B(!1)}),e.jsx(Ua,{isOpen:v,onClose:()=>F(!1)}),e.jsx(za,{isOpen:R,onClose:()=>Q(!1),onOpenConfig:()=>k(!0),onOpenNotifications:()=>B(!0),onOpenHistory:()=>F(!0)})]})}function at({onConfigChange:s,onToolChange:t,config:a,isOpen:o,onClose:r,onOpenBuildingModal:d,onOpenAreaExplorer:c,onOpenIntegrationsModal:n,onOpenMonitoringModal:u,onOpenWorkflowEditor:w,onOpenTriggerManager:x}){const{t:b}=Y(["config","common"]),p=Ve(),f=Array.from(p.areas.values()),m=Array.from(p.buildings.values()),[y,j]=l.useState(""),h=l.useRef(null);if(l.useEffect(()=>{const C=A=>{A.key==="Escape"&&o&&r()};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[o,r]),l.useEffect(()=>{if(o&&h.current){if(typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches)return;const A=setTimeout(()=>{var V;(V=h.current)==null||V.focus()},50);return()=>clearTimeout(A)}},[o]),!o)return null;const _=C=>{const A=p.activeTool===C?null:C;t(A)},D=C=>{E.selectArea(p.selectedAreaId===C?null:C),t("select")},P=(C,A)=>{C.stopPropagation(),E.deleteArea(A)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"toolbox-backdrop",onClick:r}),e.jsxs("aside",{className:"toolbox",children:[e.jsxs("div",{className:"toolbox-header",children:[e.jsx("span",{children:b("config:title")}),e.jsx("button",{className:"toolbox-close-btn",onClick:r,title:b("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:h,type:"text",placeholder:b("config:searchPlaceholder"),value:y,onChange:C=>j(C.target.value),className:"toolbox-search-input"}),y&&e.jsx("button",{className:"toolbox-search-clear",onClick:()=>j(""),children:"×"})]}),e.jsxs("div",{className:"toolbox-content",children:[e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsxs(W,{title:b("config:areas.title",{count:f.length}),storageKey:"areas",children:[e.jsxs("div",{className:"tool-buttons",children:[e.jsx("button",{className:`tool-btn ${p.activeTool==="select"?"active":""}`,onClick:()=>_("select"),title:b("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 ${p.activeTool==="rectangle"?"active":""}`,onClick:()=>_("rectangle"),title:b("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 ${p.activeTool==="circle"?"active":""}`,onClick:()=>_("circle"),title:b("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:f.length===0?e.jsx("div",{className:"areas-empty",children:b("config:areas.drawToCreate")}):f.map(C=>e.jsx(Bs,{area:C,isSelected:p.selectedAreaId===C.id,onClick:()=>D(C.id),onDelete:A=>P(A,C.id)},C.id))})]})}),p.selectedAreaId&&e.jsx(Ys,{area:p.areas.get(p.selectedAreaId),onClose:()=>E.selectArea(null),onOpenFolder:c}),e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsx(W,{title:b("config:buildings.title",{count:m.length}),storageKey:"buildings",headerExtra:e.jsx("button",{className:"add-building-btn",onClick:C=>{C.stopPropagation(),d==null||d()},title:b("config:buildings.addBuilding"),children:"+"}),children:e.jsx("div",{className:"buildings-list",children:m.length===0?e.jsx("div",{className:"buildings-empty",children:b("config:buildings.clickToAdd")}):m.map(C=>e.jsx(Vs,{building:C,isSelected:p.selectedBuildingIds.has(C.id),onClick:()=>{E.selectBuilding(p.selectedBuildingIds.has(C.id)?null:C.id)},onEdit:()=>d==null?void 0:d(C.id)},C.id))})})}),p.selectedBuildingIds.size===1&&(()=>{const C=Array.from(p.selectedBuildingIds)[0],A=p.buildings.get(C);return A?e.jsx(Ks,{building:A,onClose:()=>E.selectBuilding(null),onOpenModal:()=>d==null?void 0:d(C)}):null})(),e.jsx(Xa,{config:a,onChange:s,searchQuery:y,onOpenIntegrationsModal:n,onOpenMonitoringModal:u,onOpenWorkflowEditor:w,onOpenTriggerManager:x})]})]})]})}export{at as Toolbox};
@@ -0,0 +1 @@
1
+ .system-prompt-modal{width:720px;max-width:95vw;max-height:85vh;display:flex;flex-direction:column;padding:0;background:#14141e;border:1px solid #2a2a3a;border-radius:12px;overflow:hidden}.system-prompt-modal .modal-header{padding:14px 20px;margin-bottom:0;border-bottom:1px solid #2a2a3a;font-size:16px;font-weight:600;display:flex;justify-content:space-between;align-items:center;gap:12px}.system-prompt-modal .modal-header h2{margin:0;font-size:16px}.system-prompt-modal .modal-footer{padding:12px 20px;border-top:1px solid #2a2a3a;display:flex;justify-content:space-between;align-items:center;gap:12px}.modal-close{background:transparent;border:none;color:#8a8a98;font-size:24px;line-height:1;cursor:pointer;padding:4px 8px;border-radius:4px;transition:all .15s;flex-shrink:0}.modal-close:hover{background:#d45a5a26;color:#d45a5a}.modal-body{flex:1;overflow-y:auto;padding:20px;min-height:0;display:flex;flex-direction:column;gap:12px}.modal-description{margin:0;font-size:12px;color:#8a8a98;line-height:1.5}.loading-state{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:48px 24px}.loading-state .spinner{width:32px;height:32px;border:3px solid rgba(42,42,58,.5);border-top-color:#5a8fd4;border-radius:50%;animation:spin .8s linear infinite}.loading-state p{color:#8a8a98;margin:0;font-size:13px}@keyframes spin{to{transform:rotate(360deg)}}.alert{padding:10px 12px;border-radius:4px;display:flex;gap:8px;align-items:flex-start;font-size:12px;line-height:1.4}.alert .alert-icon{flex-shrink:0;font-size:14px}.alert.alert-error{background:#d45a5a1a;border:1px solid rgba(212,90,90,.25);color:#d45a5a}.alert.alert-success{background:#5cb88a1a;border:1px solid rgba(92,184,138,.25);color:#5cb88a}.editor-wrapper{display:flex;flex-direction:column;gap:6px;flex:1}.editor-header{display:flex;justify-content:space-between;align-items:center;gap:8px}.editor-label{font-size:11px;font-weight:600;color:#8a8a98;text-transform:uppercase;letter-spacing:.3px}.char-count{font-size:10px;color:#606070;flex-shrink:0}.prompt-editor{padding:10px 12px;border:1px solid #2a2a3a;border-radius:4px;background:#1c1c28;color:#d0d0d8;font-family:JetBrains Mono,SF Mono,Fira Code,Consolas,monospace;font-size:12px;line-height:1.6;resize:vertical;min-height:14rem;flex:1;max-height:28rem;outline:none;transition:all .15s}.prompt-editor:focus{border-color:#5a8fd4;background:#1c1c28cc}.prompt-editor::placeholder{color:#606070;white-space:pre-line}.editor-hint{font-size:10px;color:#606070;font-style:italic;padding:0 2px}.footer-buttons-left{display:flex;gap:6px}.footer-buttons-right{display:flex;gap:6px;margin-left:auto}.btn{padding:8px 14px;border:1px solid #2a2a3a;border-radius:4px;font-size:12px;font-weight:500;cursor:pointer;transition:all .15s;white-space:nowrap;background:#1c1c28;color:#d0d0d8}.whatsapp-config-modal{width:900px;max-width:95vw;max-height:85vh;display:flex;flex-direction:column;padding:0;background:#14141e;border:1px solid #2a2a3a;border-radius:12px;overflow:hidden}.whatsapp-config-modal .modal-header{padding:14px 20px;margin-bottom:0;border-bottom:1px solid #2a2a3a;font-size:16px;font-weight:600;display:flex;justify-content:space-between;align-items:center;gap:12px}.whatsapp-config-modal .modal-header h2{margin:0;font-size:16px}.whatsapp-config-modal .modal-footer{padding:12px 20px;border-top:1px solid #2a2a3a;display:flex;justify-content:space-between;align-items:center;gap:12px}.whatsapp-config-modal .modal-body{flex:1;overflow-y:auto;padding:20px;min-height:0;display:flex;flex-direction:column;gap:16px}.whatsapp-config-modal .modal-description{margin:0;font-size:12px;color:#8a8a98;line-height:1.5}.whatsapp-config-modal .loading-state{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:48px 24px}.whatsapp-config-modal .loading-state .spinner{width:32px;height:32px;border:3px solid rgba(42,42,58,.5);border-top-color:#5a8fd4;border-radius:50%;animation:wa-spin .8s linear infinite}.whatsapp-config-modal .loading-state p{color:#8a8a98;margin:0;font-size:13px}.whatsapp-config-modal .alert{padding:10px 12px;border-radius:4px;display:flex;gap:8px;align-items:flex-start;font-size:12px;line-height:1.4}.whatsapp-config-modal .alert .alert-icon{flex-shrink:0;font-size:14px}.whatsapp-config-modal .alert.alert-error{background:#d45a5a1a;border:1px solid rgba(212,90,90,.25);color:#d45a5a}.whatsapp-config-modal .alert.alert-success{background:#5cb88a1a;border:1px solid rgba(92,184,138,.25);color:#5cb88a}.whatsapp-config-modal .footer-buttons-left{display:flex;gap:6px}.whatsapp-config-modal .footer-buttons-right{display:flex;gap:6px;margin-left:auto}@keyframes wa-spin{to{transform:rotate(360deg)}}.wa-section{display:flex;flex-direction:column;gap:10px;padding:14px 14px 16px;border:1px solid #2a2a3a;border-radius:8px;background:#1c1c2873}.wa-section-title{margin:0 0 4px;font-size:12px;font-weight:600;color:#8a8a98;text-transform:uppercase;letter-spacing:.5px}.wa-field{display:flex;flex-direction:column;gap:4px}.wa-field.wa-field-row{flex-direction:row;align-items:center;justify-content:space-between}.wa-field.wa-field-inline{flex-direction:row;align-items:center;gap:8px;flex-wrap:wrap}.wa-field.wa-field-inline .wa-input{flex:1 1 220px;min-width:160px}.wa-field.wa-field-end{justify-content:flex-end}.wa-label{font-size:11px;font-weight:600;color:#8a8a98;text-transform:uppercase;letter-spacing:.3px}.wa-hint{font-size:10px;color:#606070;font-style:italic}.wa-input,.wa-textarea{padding:8px 10px;border:1px solid #2a2a3a;border-radius:4px;background:#1c1c28;color:#d0d0d8;font-family:JetBrains Mono,SF Mono,Fira Code,Consolas,monospace;font-size:12px;line-height:1.5;outline:none;transition:all .15s;width:100%;box-sizing:border-box}.wa-input:focus,.wa-textarea:focus{border-color:#5a8fd4;background:#1c1c28cc}.wa-input::placeholder,.wa-textarea::placeholder{color:#606070}.wa-textarea{resize:vertical;min-height:6rem;max-height:14rem}.wa-toggle{position:relative;display:inline-flex;align-items:center;cursor:pointer;flex-shrink:0}.wa-toggle input{position:absolute;opacity:0;pointer-events:none}.wa-toggle .wa-toggle-track{width:32px;height:18px;background:#1c1c28;border:1px solid #2a2a3a;border-radius:9px;transition:background .15s,border-color .15s;position:relative;display:inline-block}.wa-toggle .wa-toggle-thumb{position:absolute;top:1px;left:1px;width:14px;height:14px;background:#8a8a98;border-radius:50%;transition:transform .15s,background .15s}.wa-toggle input:checked+.wa-toggle-track{background:#5a8fd459;border-color:#5a8fd4}.wa-toggle input:checked+.wa-toggle-track .wa-toggle-thumb{transform:translate(14px);background:#5a8fd4}.wa-key-status{display:flex;align-items:center;gap:8px}.wa-status{display:inline-flex;align-items:center;gap:4px;padding:3px 8px;border-radius:4px;font-size:11px;font-weight:500}.wa-status.wa-status-ok{background:#5cb88a1f;color:#5cb88a;border:1px solid rgba(92,184,138,.3)}.wa-status.wa-status-warn{background:#d4a05a1f;color:#d4a05a;border:1px solid rgba(212,160,90,.3)}.wa-sessions-list{display:flex;flex-direction:column;gap:6px}.wa-empty{font-size:12px;color:#606070;font-style:italic;padding:8px 0}.wa-session-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:8px 10px;border:1px solid #2a2a3a;border-radius:4px;background:#1c1c28}.wa-session-info{display:flex;align-items:center;gap:10px;flex-wrap:wrap;min-width:0}.wa-session-id{font-family:JetBrains Mono,SF Mono,Fira Code,Consolas,monospace;font-size:12px;color:#d0d0d8;font-weight:500}.wa-session-status{font-size:11px;padding:2px 6px;border-radius:4px;background:#60607026;color:#8a8a98;text-transform:uppercase;letter-spacing:.3px}.wa-session-status.status-connected,.wa-session-status.status-paired,.wa-session-status.status-open,.wa-session-status.status-ready{background:#5cb88a26;color:#5cb88a}.wa-session-status.status-pairing,.wa-session-status.status-connecting,.wa-session-status.status-qr{background:#5a8fd426;color:#5a8fd4}.wa-session-status.status-error,.wa-session-status.status-disconnected,.wa-session-status.status-failed{background:#d45a5a26;color:#d45a5a}.wa-session-paired{font-size:11px;color:#606070}.wa-qr-panel{margin-top:8px;padding:12px;border:1px dashed #2a2a3a;border-radius:6px;background:#0d0d1480;display:flex;flex-direction:column;gap:10px}.wa-qr-header{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px;color:#8a8a98}.wa-qr-image{display:flex;justify-content:center;padding:12px;background:#fff;border-radius:4px}.wa-qr-image img{width:240px;height:240px;image-rendering:pixelated}.wa-qr-loading{display:flex;flex-direction:column;align-items:center;gap:8px;padding:24px}.wa-qr-loading .spinner{width:24px;height:24px;border:3px solid rgba(42,42,58,.5);border-top-color:#5a8fd4;border-radius:50%;animation:wa-spin .8s linear infinite}.wa-qr-loading p{margin:0;font-size:12px;color:#8a8a98}.wa-pairing-message{font-size:12px;color:#8a8a98;font-style:italic}.btn{padding:8px 14px;border:1px solid #2a2a3a;border-radius:4px;font-size:12px;font-weight:500;cursor:pointer;transition:all .15s;white-space:nowrap;background:#1c1c28;color:#d0d0d8;display:inline-flex;align-items:center;gap:6px}.btn:disabled{opacity:.5;cursor:not-allowed}.btn:active:not(:disabled){transform:scale(.98)}.btn:hover:not(:disabled){border-color:#8a8a98;background:#1c1c28cc}.btn.btn-sm{padding:5px 10px;font-size:11px}.btn.btn-primary{background:#5a8fd4;color:#fff;border-color:#5a8fd4}.btn.btn-primary:hover:not(:disabled){background:#5a8fd4e6;box-shadow:0 0 0 2px #5a8fd433}.btn.btn-secondary{background:#1c1c28;color:#d0d0d8;border-color:#2a2a3a}.btn.btn-secondary:hover:not(:disabled){border-color:#8a8a98;background:#1c1c28cc}.btn.btn-danger{background:#d45a5a26;color:#d45a5a;border-color:#d45a5a4d}.btn.btn-danger:hover:not(:disabled){background:#d45a5a40;border-color:#d45a5a80}.whatsapp-notifications-modal{width:720px;max-width:95vw;max-height:85vh;display:flex;flex-direction:column;padding:0;background:#14141e;border:1px solid #2a2a3a;border-radius:12px;overflow:hidden}.whatsapp-notifications-modal .modal-header{padding:14px 20px;border-bottom:1px solid #2a2a3a;font-size:16px;font-weight:600;display:flex;justify-content:space-between;align-items:center;gap:12px}.whatsapp-notifications-modal .modal-header h2{margin:0;font-size:16px}.whatsapp-notifications-modal .modal-footer{padding:12px 20px;border-top:1px solid #2a2a3a;display:flex;justify-content:space-between;align-items:center;gap:12px}.whatsapp-notifications-modal .modal-footer .footer-buttons-right{display:flex;gap:8px}.whatsapp-notifications-modal .modal-body{flex:1;overflow-y:auto;padding:20px;min-height:0;display:flex;flex-direction:column;gap:16px}.whatsapp-notifications-modal .modal-description{margin:0;font-size:12px;color:#8a8a98;line-height:1.5}.whatsapp-notifications-modal .loading-state{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:48px 24px}.whatsapp-notifications-modal .loading-state .spinner{width:32px;height:32px;border:3px solid rgba(42,42,58,.5);border-top-color:#5a8fd4;border-radius:50%;animation:wan-spin .8s linear infinite}.whatsapp-notifications-modal .loading-state p{color:#8a8a98;margin:0;font-size:13px}.whatsapp-notifications-modal .alert{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:6px;font-size:12px}.whatsapp-notifications-modal .alert.alert-error{background:#dc26261a;color:#f87171;border:1px solid rgba(220,38,38,.3)}.whatsapp-notifications-modal .alert.alert-success{background:#22c55e1a;color:#4ade80;border:1px solid rgba(34,197,94,.3)}.whatsapp-notifications-modal .wan-section{display:flex;flex-direction:column;gap:10px;padding:12px;border:1px solid #2a2a3a;border-radius:8px;background:#0d0d14}.whatsapp-notifications-modal .wan-section-title{margin:0;font-size:13px;font-weight:600;color:#d0d0d8}.whatsapp-notifications-modal .wan-section-hint{margin:0;font-size:11px;color:#8a8a98;line-height:1.4}.whatsapp-notifications-modal .wan-field{display:flex;flex-direction:column;gap:4px}.whatsapp-notifications-modal .wan-label{font-size:12px;font-weight:500;color:#8a8a98}.whatsapp-notifications-modal .wan-input{padding:8px 10px;background:#14141e;color:#d0d0d8;border:1px solid #2a2a3a;border-radius:6px;font-size:13px}.whatsapp-notifications-modal .wan-input:focus{outline:none;border-color:#5a8fd4}.whatsapp-notifications-modal .wan-hint{font-size:11px;color:#8a8a98}.whatsapp-notifications-modal .wan-toggle-row{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:8px 0;border-bottom:1px solid rgba(42,42,58,.5)}.whatsapp-notifications-modal .wan-toggle-row:last-child{border-bottom:none}.whatsapp-notifications-modal .wan-toggle-info{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}.whatsapp-notifications-modal .wan-toggle-title{font-size:13px;color:#d0d0d8;font-weight:500}.whatsapp-notifications-modal .wan-toggle-help{font-size:11px;color:#8a8a98;line-height:1.4}.whatsapp-notifications-modal .wan-toggle{position:relative;display:inline-block;width:36px;height:20px;flex-shrink:0;cursor:pointer}.whatsapp-notifications-modal .wan-toggle input{opacity:0;width:0;height:0}.whatsapp-notifications-modal .wan-toggle input:checked+.wan-toggle-track{background:#5a8fd4}.whatsapp-notifications-modal .wan-toggle input:checked+.wan-toggle-track .wan-toggle-thumb{transform:translate(16px)}.whatsapp-notifications-modal .wan-toggle-track{position:absolute;top:0;right:0;bottom:0;left:0;background:#2a2a3a99;border-radius:999px;transition:background .15s ease}.whatsapp-notifications-modal .wan-toggle-thumb{position:absolute;top:2px;left:2px;width:16px;height:16px;background:#fff;border-radius:50%;transition:transform .15s ease}@media(max-width:600px){.whatsapp-notifications-modal{width:100%;max-width:100vw}.whatsapp-notifications-modal .modal-footer{flex-direction:column;align-items:stretch}.whatsapp-notifications-modal .modal-footer .footer-buttons-left,.whatsapp-notifications-modal .modal-footer .footer-buttons-right{width:100%;justify-content:stretch}.whatsapp-notifications-modal .modal-footer .footer-buttons-left .btn,.whatsapp-notifications-modal .modal-footer .footer-buttons-right .btn{flex:1}}@keyframes wan-spin{to{transform:rotate(360deg)}}.whatsapp-history-modal{position:relative;display:flex;flex-direction:column;width:min(1200px,96vw);height:min(820px,92vh);background:#0d0d14;border:1px solid #2a2a3a;border-radius:6px;box-shadow:0 16px 48px #0006;overflow:hidden}.whatsapp-history-modal .modal-header{display:flex;align-items:center;gap:16px;padding:12px 16px;border-bottom:1px solid #2a2a3a;background:#14141e}.whatsapp-history-modal .modal-header h2{margin:0;font-size:14px;font-weight:600;color:#d0d0d8;flex-shrink:0}.whatsapp-history-modal .modal-header .modal-close{margin-left:auto;background:transparent;border:none;color:#606070;cursor:pointer;padding:4px;border-radius:4px}.whatsapp-history-modal .modal-header .modal-close:hover{background:#d0d0d814;color:#d0d0d8}.whatsapp-history-modal__session{display:flex;align-items:center;gap:8px}.whatsapp-history-modal__session label{display:flex;align-items:center;gap:6px;font-size:11px;color:#606070}.whatsapp-history-modal__session label select{background:#1c1c28;border:1px solid #2a2a3a;color:#d0d0d8;font-size:11px;padding:4px 6px;border-radius:4px;min-width:140px}.whatsapp-history-modal__alert{padding:8px 16px;background:#d45a5a1f;color:#d45a5a;border-bottom:1px solid rgba(212,90,90,.3);font-size:12px}.whatsapp-history-modal__body{flex:1;display:grid;grid-template-columns:320px 1fr;min-height:0;background:#0d0d14}.whatsapp-history-chatlist{display:flex;flex-direction:column;min-height:0;border-right:1px solid #2a2a3a;background:#14141e}.whatsapp-history-chatlist__header{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;border-bottom:1px solid #2a2a3a}.whatsapp-history-chatlist__title{font-size:11px;font-weight:600;letter-spacing:.05em;text-transform:uppercase;color:#606070}.whatsapp-history-chatlist__refresh{background:transparent;border:1px solid #2a2a3a;color:#606070;border-radius:4px;padding:2px 8px;cursor:pointer;font-size:12px}.whatsapp-history-chatlist__refresh:hover:not(:disabled){background:#d0d0d80f;color:#d0d0d8}.whatsapp-history-chatlist__refresh:disabled{opacity:.5;cursor:not-allowed}.whatsapp-history-chatlist__error{padding:8px 12px;color:#d45a5a;font-size:12px;background:#d45a5a14}.whatsapp-history-chatlist__loading,.whatsapp-history-chatlist__empty{display:flex;align-items:center;gap:8px;padding:16px 12px;color:#606070;font-size:12px}.whatsapp-history-chatlist__items{list-style:none;margin:0;padding:0;overflow-y:auto;flex:1}.whatsapp-history-chatlist__item{border-bottom:1px solid rgba(42,42,58,.4)}.whatsapp-history-chatlist__item.is-selected .whatsapp-history-chatlist__button{background:#5ab8c81a;border-left:3px solid #5ab8c8}.whatsapp-history-chatlist__button{width:100%;text-align:left;background:transparent;border:none;border-left:3px solid transparent;padding:10px 12px;cursor:pointer;color:#d0d0d8;display:flex;flex-direction:column;gap:3px}.whatsapp-history-chatlist__button:hover{background:#d0d0d80a}.whatsapp-history-chatlist__row{display:flex;align-items:center;justify-content:space-between;gap:8px}.whatsapp-history-chatlist__row--secondary{font-size:11px;color:#606070}.whatsapp-history-chatlist__name{font-size:12px;font-weight:500;color:#d0d0d8;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whatsapp-history-chatlist__time{font-size:10px;color:#606070;flex-shrink:0}.whatsapp-history-chatlist__preview{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whatsapp-history-chatlist__direction{color:#606070}.whatsapp-history-chatlist__preview-icon{margin-right:2px}.whatsapp-history-chatlist__unread{background:#5cb88a;color:#0d0d14;border-radius:10px;padding:1px 6px;font-size:10px;font-weight:600;flex-shrink:0}.whatsapp-history-messages{display:flex;flex-direction:column;min-height:0;background:#0d0d14}.whatsapp-history-messages--empty{align-items:center;justify-content:center}.whatsapp-history-messages__header{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 16px;border-bottom:1px solid #2a2a3a;background:#14141e}.whatsapp-history-messages__title{font-size:13px;font-weight:600;color:#d0d0d8;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whatsapp-history-messages__scroll{flex:1;overflow-y:auto;padding:14px 16px 18px;display:flex;flex-direction:column;gap:6px;background:#0d0d14}.whatsapp-history-messages__load-more-row{display:flex;justify-content:center;margin:6px 0 10px}.whatsapp-history-messages__load-more{background:#1c1c28;border:1px solid #2a2a3a;color:#8a8a98;border-radius:4px;padding:4px 12px;font-size:11px;cursor:pointer}.whatsapp-history-messages__load-more:hover:not(:disabled){background:#d0d0d80f;color:#d0d0d8}.whatsapp-history-messages__load-more:disabled{opacity:.6;cursor:not-allowed}.whatsapp-history-messages__error{color:#d45a5a;background:#d45a5a14;padding:8px 12px;border-radius:4px;font-size:12px;align-self:center}.whatsapp-history-messages__loading,.whatsapp-history-messages__empty,.whatsapp-history-messages__placeholder{display:flex;align-items:center;justify-content:center;gap:8px;color:#606070;font-size:12px;padding:30px 16px}.whatsapp-history-messages__placeholder{font-size:13px}.whatsapp-history-filters{display:flex;gap:10px;flex-shrink:0}.whatsapp-history-filters__field{display:flex;align-items:center;gap:6px;font-size:11px;color:#606070}.whatsapp-history-filters__field select{background:#1c1c28;border:1px solid #2a2a3a;color:#d0d0d8;font-size:11px;padding:3px 6px;border-radius:4px}.whatsapp-history-filters__field select:disabled{opacity:.6}.whatsapp-history-bubble{display:flex;width:100%}.whatsapp-history-bubble--inbound{justify-content:flex-start}.whatsapp-history-bubble--outbound{justify-content:flex-end}.whatsapp-history-bubble__inner{display:inline-flex;flex-direction:column;gap:2px;max-width:70%;padding:7px 11px 5px;border-radius:10px;font-size:13px;line-height:1.45;word-break:break-word;box-shadow:0 1px 1px #0003}.whatsapp-history-bubble--inbound .whatsapp-history-bubble__inner{background:#ffffff0f;color:#d0d0d8;border-top-left-radius:2px}.whatsapp-history-bubble--outbound .whatsapp-history-bubble__inner{background:#25d3662e;color:#d0d0d8;border-top-right-radius:2px}.whatsapp-history-bubble__type-icon{font-size:12px;color:#606070;margin-right:4px}.whatsapp-history-bubble__body{white-space:pre-wrap}.whatsapp-history-bubble__placeholder{font-style:italic;color:#606070}.whatsapp-history-bubble__transcription{font-size:11px;color:#606070;font-style:italic}.whatsapp-history-bubble__media-link{font-size:11px;color:#5ab8c8;text-decoration:underline}.whatsapp-history-bubble__media-link:hover{opacity:.85}.whatsapp-history-bubble__time{align-self:flex-end;font-size:10px;color:#606070;margin-top:2px}:root{--bg-primary: #0d0d14;--bg-secondary: #14141e;--bg-tertiary: #1c1c28;--border-color: #2a2a3a;--text-primary: #d0d0d8;--text-secondary: #8a8a98;--text-muted: #606070;--accent-blue: #5a8fd4;--accent-green: #5cb88a;--accent-orange: #d4a05a;--accent-red: #d45a5a;--accent-purple: #8a6fbf;--accent-cyan: #5ab8c8;--accent-claude: #a06848;--accent-claude-light: #c8896a;--accent-pink: #5a8fd4;--accent-yellow: #d0d0d8;--font-size-base: 14px;--line-height-base: 1.5;--msg-user-bg: color-mix(in srgb, #5ab8c8 8%, transparent);--msg-user-border: #5ab8c8;--msg-user-text: #d0d0d8;--msg-assistant-bg: color-mix(in srgb, #5cb88a 8%, transparent);--msg-assistant-border: #5cb88a;--msg-assistant-text: #d0d0d8;--tool-use-bg: color-mix(in srgb, #d4a05a 8%, transparent);--tool-use-border: #d4a05a;--tool-use-text: #d4a05a;--tool-use-name: #d4a05a;--tool-result-bg: color-mix(in srgb, #8a6fbf 6%, transparent);--tool-result-border: #8a6fbf;--tool-result-text: #5cb88a;--context-bar-bg: #1c1c28;--context-bar-fill: #8a6fbf;--output-line-bg: transparent;--task-label-color: #5ab8c8}.whatsapp-hub-modal{position:relative;width:min(520px,92vw);background:#0d0d14;border:1px solid #2a2a3a;border-radius:6px;box-shadow:0 16px 48px #0006;overflow:hidden}.whatsapp-hub-modal .modal-header{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;border-bottom:1px solid #2a2a3a;background:#14141e}.whatsapp-hub-modal .modal-header h2{margin:0;font-size:14px;font-weight:600;color:#d0d0d8;display:inline-flex;align-items:center;gap:8px}.whatsapp-hub-modal .modal-header .modal-close{background:transparent;border:none;color:#606070;cursor:pointer;padding:4px;border-radius:4px}.whatsapp-hub-modal .modal-header .modal-close:hover{background:#d0d0d814;color:#d0d0d8}.whatsapp-hub-modal__icon{font-size:18px;line-height:1}.whatsapp-hub-modal .modal-body{padding:14px 16px 16px;display:flex;flex-direction:column;gap:12px}.whatsapp-hub-modal__intro{margin:0;color:#8a8a98;font-size:12px;line-height:1.45}.whatsapp-hub-modal__options{display:flex;flex-direction:column;gap:6px}.whatsapp-hub-modal__option{display:flex;align-items:flex-start;gap:12px;padding:10px 12px;background:#14141e;border:1px solid #2a2a3a;border-radius:4px;color:#d0d0d8;cursor:pointer;text-align:left;transition:background .12s ease,border-color .12s ease}.whatsapp-hub-modal__option:hover{background:#d0d0d80d;border-color:#5ab8c8}.whatsapp-hub-modal__option:focus-visible{outline:1px solid #5ab8c8;outline-offset:2px}.whatsapp-hub-modal__option-icon{flex-shrink:0;width:28px;height:28px;border-radius:6px;background:#5ab8c81f;color:#5ab8c8;display:inline-flex;align-items:center;justify-content:center}.whatsapp-hub-modal__option-text{display:flex;flex-direction:column;gap:2px;min-width:0}.whatsapp-hub-modal__option-title{font-size:13px;font-weight:600;color:#d0d0d8}.whatsapp-hub-modal__option-desc{font-size:11px;color:#606070;line-height:1.4}
@@ -1,4 +1,4 @@
1
- import{bg as ta,u as B,j as e,aL as j,bj as Ms,bk as Fs,aM as Ue,s as D,bl as $s,r as d,D as Z,I as F,a2 as Us,aV as Ve,f as na,bm as la,J as ia,S as oa,h as ra,bn as Ks,aW as He}from"./main-klWBzHh0.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const ca=[{value:"",labelKey:"terminal:building.colorDefault"},{value:"#2a2a3a",labelKey:"terminal:building.colorDarkGray"},{value:"#3a2a2a",labelKey:"terminal:building.colorDarkRed"},{value:"#2a3a2a",labelKey:"terminal:building.colorDarkGreen"},{value:"#2a2a4a",labelKey:"terminal:building.colorDarkBlue"},{value:"#3a3a2a",labelKey:"terminal:building.colorDarkYellow"},{value:"#3a2a3a",labelKey:"terminal:building.colorDarkPurple"},{value:"#2a3a3a",labelKey:"terminal:building.colorDarkCyan"},{value:"#4a3a3a",labelKey:"terminal:building.colorWarmBrown"},{value:"#3a4a4a",labelKey:"terminal:building.colorCoolSteel"}];function ma(o){return ta.t(o)}function qe(o){if(o===0)return"0 B";const p=1024,u=["B","KB","MB","GB"],x=Math.floor(Math.log(o)/Math.log(p));return parseFloat((o/Math.pow(p,x)).toFixed(1))+" "+u[x]}function da(o){const u=Date.now()-o,x=Math.floor(u/(1e3*60*60)),n=Math.floor(u%(1e3*60*60)/(1e3*60));return x>0?`${x}h ${n}m`:`${n}m`}const Hs={30:"#1a1a1a",31:"#e74c3c",32:"#2ecc71",33:"#f39c12",34:"#3498db",35:"#9b59b6",36:"#00bcd4",37:"#ecf0f1",90:"#7f8c8d",91:"#ff6b6b",92:"#4ade80",93:"#fbbf24",94:"#60a5fa",95:"#c084fc",96:"#22d3ee",97:"#ffffff"};function Vs(o){const p=[],u=/\x1B\[([0-9;]*)m/g;let x=0,n=null,y;for(;(y=u.exec(o))!==null;){if(y.index>x){const g=o.slice(x,y.index);n?p.push(e.jsx("span",{style:{color:n},children:g},p.length)):p.push(g)}const C=y[1].split(";").map(Number);for(const g of C)g===0||g===39?n=null:Hs[g]&&(n=Hs[g]);x=u.lastIndex}if(x<o.length){const C=o.slice(x);n?p.push(e.jsx("span",{style:{color:n},children:C},p.length)):p.push(C)}return p.length>0?p:[o]}function ua({buildingName:o,onClose:p,onConfirm:u}){const{t:x}=B(["terminal","common"]);return e.jsx("div",{className:"modal-overlay visible",onClick:p,children:e.jsxs("div",{className:"modal confirm-modal",onClick:n=>n.stopPropagation(),children:[e.jsx("div",{className:"modal-header",children:x("terminal:building.deleteBuilding")}),e.jsxs("div",{className:"modal-body confirm-modal-body",children:[e.jsx("p",{children:x("terminal:building.deleteConfirm",{name:o})}),e.jsx("p",{className:"confirm-modal-note",children:x("terminal:building.deleteNote")})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:p,children:x("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-danger",onClick:u,autoFocus:!0,children:x("common:buttons.delete")})]})]})})}function pa({usePM2:o,setUsePM2:p}){const{t:u}=B(["terminal"]);return e.jsxs("div",{className:"form-section pm2-toggle-section",children:[e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",className:"toggle-input",checked:o,onChange:x=>p(x.target.checked)}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})}),e.jsxs("span",{className:"toggle-label",children:[e.jsx("span",{className:"pm2-badge",children:"PM2"}),u("terminal:building.usePM2")]})]}),e.jsx("div",{className:"form-hint",children:u("terminal:building.pm2Hint")})]})}function ha({usePM2:o,pm2Script:p,setPm2Script:u,pm2Args:x,setPm2Args:n,pm2Interpreter:y,setPm2Interpreter:C,pm2InterpreterArgs:g,setPm2InterpreterArgs:v,pm2Env:s,setPm2Env:h,isEditMode:a,building:t,handleCommand:r}){var N;const{t:i}=B(["terminal","common"]);return o?e.jsxs("div",{className:"form-section pm2-config-section",children:[e.jsx("label",{className:"form-label",children:i("terminal:building.pm2Configuration")}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Script"),e.jsx(j,{text:i("terminal:building.helpPm2Script"),title:i("terminal:building.pm2Script"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:p,onChange:b=>u(b.target.value),placeholder:"npm, java, python, ./app.js",required:o})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Arguments"),e.jsx(j,{text:i("terminal:building.helpPm2Arguments"),title:i("terminal:building.pm2Arguments"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:x,onChange:b=>n(b.target.value),placeholder:"run dev, -jar app.jar, app.py"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Interpreter"),e.jsx(j,{text:i("terminal:building.helpPm2Interpreter"),title:i("terminal:building.pm2Interpreter"),position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:y,onChange:b=>C(b.target.value),children:Object.keys(Ms).map(b=>e.jsx("option",{value:b,children:Ms[b].label},b))})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2InterpArgs"),e.jsx(j,{text:i("terminal:building.helpPm2InterpArgs"),title:i("terminal:building.pm2InterpArgs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:b=>v(b.target.value),placeholder:"-jar (for Java)"})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Environment"),e.jsx(j,{text:i("terminal:building.helpPm2Environment"),title:i("terminal:building.pm2Environment"),position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:s,onChange:b=>h(b.target.value),placeholder:`KEY=value
1
+ import{bg as ta,u as B,j as e,aL as j,bj as Ms,bk as Fs,aM as Ue,s as D,bl as $s,r as d,D as Z,I as F,a2 as Us,aV as Ve,f as na,bm as la,J as ia,S as oa,h as ra,bn as Ks,aW as He}from"./main-B7wf_xU_.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const ca=[{value:"",labelKey:"terminal:building.colorDefault"},{value:"#2a2a3a",labelKey:"terminal:building.colorDarkGray"},{value:"#3a2a2a",labelKey:"terminal:building.colorDarkRed"},{value:"#2a3a2a",labelKey:"terminal:building.colorDarkGreen"},{value:"#2a2a4a",labelKey:"terminal:building.colorDarkBlue"},{value:"#3a3a2a",labelKey:"terminal:building.colorDarkYellow"},{value:"#3a2a3a",labelKey:"terminal:building.colorDarkPurple"},{value:"#2a3a3a",labelKey:"terminal:building.colorDarkCyan"},{value:"#4a3a3a",labelKey:"terminal:building.colorWarmBrown"},{value:"#3a4a4a",labelKey:"terminal:building.colorCoolSteel"}];function ma(o){return ta.t(o)}function qe(o){if(o===0)return"0 B";const p=1024,u=["B","KB","MB","GB"],x=Math.floor(Math.log(o)/Math.log(p));return parseFloat((o/Math.pow(p,x)).toFixed(1))+" "+u[x]}function da(o){const u=Date.now()-o,x=Math.floor(u/(1e3*60*60)),n=Math.floor(u%(1e3*60*60)/(1e3*60));return x>0?`${x}h ${n}m`:`${n}m`}const Hs={30:"#1a1a1a",31:"#e74c3c",32:"#2ecc71",33:"#f39c12",34:"#3498db",35:"#9b59b6",36:"#00bcd4",37:"#ecf0f1",90:"#7f8c8d",91:"#ff6b6b",92:"#4ade80",93:"#fbbf24",94:"#60a5fa",95:"#c084fc",96:"#22d3ee",97:"#ffffff"};function Vs(o){const p=[],u=/\x1B\[([0-9;]*)m/g;let x=0,n=null,y;for(;(y=u.exec(o))!==null;){if(y.index>x){const g=o.slice(x,y.index);n?p.push(e.jsx("span",{style:{color:n},children:g},p.length)):p.push(g)}const C=y[1].split(";").map(Number);for(const g of C)g===0||g===39?n=null:Hs[g]&&(n=Hs[g]);x=u.lastIndex}if(x<o.length){const C=o.slice(x);n?p.push(e.jsx("span",{style:{color:n},children:C},p.length)):p.push(C)}return p.length>0?p:[o]}function ua({buildingName:o,onClose:p,onConfirm:u}){const{t:x}=B(["terminal","common"]);return e.jsx("div",{className:"modal-overlay visible",onClick:p,children:e.jsxs("div",{className:"modal confirm-modal",onClick:n=>n.stopPropagation(),children:[e.jsx("div",{className:"modal-header",children:x("terminal:building.deleteBuilding")}),e.jsxs("div",{className:"modal-body confirm-modal-body",children:[e.jsx("p",{children:x("terminal:building.deleteConfirm",{name:o})}),e.jsx("p",{className:"confirm-modal-note",children:x("terminal:building.deleteNote")})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:p,children:x("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-danger",onClick:u,autoFocus:!0,children:x("common:buttons.delete")})]})]})})}function pa({usePM2:o,setUsePM2:p}){const{t:u}=B(["terminal"]);return e.jsxs("div",{className:"form-section pm2-toggle-section",children:[e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",className:"toggle-input",checked:o,onChange:x=>p(x.target.checked)}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})}),e.jsxs("span",{className:"toggle-label",children:[e.jsx("span",{className:"pm2-badge",children:"PM2"}),u("terminal:building.usePM2")]})]}),e.jsx("div",{className:"form-hint",children:u("terminal:building.pm2Hint")})]})}function ha({usePM2:o,pm2Script:p,setPm2Script:u,pm2Args:x,setPm2Args:n,pm2Interpreter:y,setPm2Interpreter:C,pm2InterpreterArgs:g,setPm2InterpreterArgs:v,pm2Env:s,setPm2Env:h,isEditMode:a,building:t,handleCommand:r}){var N;const{t:i}=B(["terminal","common"]);return o?e.jsxs("div",{className:"form-section pm2-config-section",children:[e.jsx("label",{className:"form-label",children:i("terminal:building.pm2Configuration")}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Script"),e.jsx(j,{text:i("terminal:building.helpPm2Script"),title:i("terminal:building.pm2Script"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:p,onChange:b=>u(b.target.value),placeholder:"npm, java, python, ./app.js",required:o})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Arguments"),e.jsx(j,{text:i("terminal:building.helpPm2Arguments"),title:i("terminal:building.pm2Arguments"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:x,onChange:b=>n(b.target.value),placeholder:"run dev, -jar app.jar, app.py"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Interpreter"),e.jsx(j,{text:i("terminal:building.helpPm2Interpreter"),title:i("terminal:building.pm2Interpreter"),position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:y,onChange:b=>C(b.target.value),children:Object.keys(Ms).map(b=>e.jsx("option",{value:b,children:Ms[b].label},b))})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2InterpArgs"),e.jsx(j,{text:i("terminal:building.helpPm2InterpArgs"),title:i("terminal:building.pm2InterpArgs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:b=>v(b.target.value),placeholder:"-jar (for Java)"})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Environment"),e.jsx(j,{text:i("terminal:building.helpPm2Environment"),title:i("terminal:building.pm2Environment"),position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:s,onChange:b=>h(b.target.value),placeholder:`KEY=value
2
2
  SERVER_PORT=7201
3
3
  NODE_ENV=production`,rows:3})]}),e.jsx("div",{className:"pm2-examples",children:e.jsxs("details",{children:[e.jsx("summary",{children:i("terminal:building.pm2Examples")}),e.jsxs("div",{className:"pm2-examples-content",children:[e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Node.js:"})," Script: ",e.jsx("code",{children:"npm"}),", Args: ",e.jsx("code",{children:"run dev"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Symfony:"})," Script: ",e.jsx("code",{children:"symfony"}),", Args: ",e.jsx("code",{children:"serve --no-daemon"}),", Interpreter: ",e.jsx("code",{children:"None"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Java JAR:"})," Script: ",e.jsx("code",{children:"app.jar"}),", Interpreter: ",e.jsx("code",{children:"Java"}),", Interp. Args: ",e.jsx("code",{children:"-jar"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Python:"})," Script: ",e.jsx("code",{children:"app.py"}),", Interpreter: ",e.jsx("code",{children:"Python 3"})]})]})]})}),a&&(t==null?void 0:t.pm2Status)&&e.jsx("div",{className:"pm2-status-display",children:e.jsxs("div",{className:"pm2-status-row",children:[e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"PID"}),e.jsx("span",{className:"pm2-metric-value",children:t.pm2Status.pid||"-"})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"CPU"}),e.jsxs("span",{className:"pm2-metric-value",children:[((N=t.pm2Status.cpu)==null?void 0:N.toFixed(1))||"0","%"]})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"MEM"}),e.jsx("span",{className:"pm2-metric-value",children:qe(t.pm2Status.memory||0)})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"Restarts"}),e.jsx("span",{className:"pm2-metric-value",children:t.pm2Status.restarts||0})]}),t.pm2Status.uptime&&e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"Uptime"}),e.jsx("span",{className:"pm2-metric-value",children:da(t.pm2Status.uptime)})]})]})}),a&&e.jsxs("div",{className:"pm2-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>r("start"),children:i("common:buttons.start")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>r("stop"),children:i("common:buttons.stop")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>r("restart"),children:i("terminal:buildingAction.restart")}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>r("logs"),children:i("terminal:logs.title")})]})]}):null}function xa({dockerMode:o,setDockerMode:p,dockerImage:u,setDockerImage:x,dockerContainerName:n,setDockerContainerName:y,dockerCommand:C,setDockerCommand:g,dockerPorts:v,setDockerPorts:s,dockerVolumes:h,setDockerVolumes:a,dockerNetwork:t,setDockerNetwork:r,dockerRestart:i,setDockerRestart:N,dockerPull:b,setDockerPull:L,dockerEnv:T,setDockerEnv:A,dockerComposePath:$,setDockerComposePath:R,dockerComposeProject:K,setDockerComposeProject:I,dockerComposeServices:H,setDockerComposeServices:O,selectedExistingContainer:c,setSelectedExistingContainer:E,dockerContainersList:V,isEditMode:q,building:k,handleCommand:_}){const{t:M}=B(["config","common"]);return e.jsxs("div",{className:"form-section docker-config-section",children:[e.jsx("label",{className:"form-label",children:M("config:buildings.dockerConfig")}),e.jsxs("div",{className:"docker-mode-selector",children:[e.jsxs("label",{className:`docker-mode-option ${o==="container"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"container",checked:o==="container",onChange:()=>p("container")}),e.jsx("span",{className:"docker-mode-icon",children:"📦"}),e.jsx("span",{className:"docker-mode-label",children:"Container"}),e.jsx("span",{className:"docker-mode-desc",children:"Create a new container"})]}),e.jsxs("label",{className:`docker-mode-option ${o==="compose"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"compose",checked:o==="compose",onChange:()=>p("compose")}),e.jsx("span",{className:"docker-mode-icon",children:"🛠"}),e.jsx("span",{className:"docker-mode-label",children:"Compose"}),e.jsx("span",{className:"docker-mode-desc",children:"Manage multiple services"})]}),e.jsxs("label",{className:`docker-mode-option ${o==="existing"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"existing",checked:o==="existing",onChange:()=>p("existing")}),e.jsx("span",{className:"docker-mode-icon",children:"🔎"}),e.jsx("span",{className:"docker-mode-label",children:"Existing"}),e.jsx("span",{className:"docker-mode-desc",children:"Adopt existing container"})]})]}),o==="container"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Image:",e.jsx(j,{text:"Docker image to run, e.g., nginx:latest, redis:alpine, my-app:v1",title:"Image",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:u,onChange:l=>x(l.target.value),placeholder:"nginx:latest",required:!0})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Container Name:",e.jsx(j,{text:"Custom name for the container. If empty, auto-generated based on building name.",title:"Container Name",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:n,onChange:l=>y(l.target.value),placeholder:"Auto-generated (tc-{name}-{id})"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Command:",e.jsx(j,{text:"Override the default container command. Leave empty to use image's CMD.",title:"Command Override",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:C,onChange:l=>g(l.target.value),placeholder:"Optional command override"})]}),e.jsxs("div",{className:"form-section docker-ports-section",children:[e.jsxs("label",{className:"form-label",children:["Port Mappings",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>s([...v,""]),children:"+ Add"})]}),v.map((l,S)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:l,onChange:U=>{const z=[...v];z[S]=U.target.value,s(z)},placeholder:"8080:80 or 3000"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>s(v.filter((U,z)=>z!==S)),children:"x"})]},S)),v.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host:container (e.g., 8080:80) or same port (e.g., 3000)"})]}),e.jsxs("div",{className:"form-section docker-volumes-section",children:[e.jsxs("label",{className:"form-label",children:["Volume Mounts",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>a([...h,""]),children:"+ Add"})]}),h.map((l,S)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:l,onChange:U=>{const z=[...h];z[S]=U.target.value,a(z)},placeholder:"./data:/app/data or /host/path:/container/path"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>a(h.filter((U,z)=>z!==S)),children:"x"})]},S)),h.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host_path:container_path (relative paths resolved from working directory)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Network:",e.jsx(j,{text:"Docker network to connect to. Leave empty for default bridge network.",title:"Network",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:t,onChange:l=>r(l.target.value),placeholder:"bridge (default)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Restart Policy:",e.jsx(j,{text:"When should Docker restart the container automatically?",title:"Restart Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:i,onChange:l=>N(l.target.value),children:Object.keys(Fs).map(l=>e.jsx("option",{value:l,children:Fs[l].label},l))})]})]}),o==="compose"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Compose File:",e.jsx(j,{text:"Path to docker-compose.yml file, relative to working directory.",title:"Compose File",position:"top",size:"sm"})]}),e.jsx(Ue,{value:$,onChange:R,placeholder:"docker-compose.yml",className:"form-input",directoriesOnly:!1})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Project Name:",e.jsx(j,{text:"Override the compose project name. Leave empty for auto-generated name.",title:"Project Name",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:K,onChange:l=>I(l.target.value),placeholder:"Auto-generated"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Services:",e.jsx(j,{text:"Specific services to manage (comma-separated). Leave empty for all services.",title:"Services",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:H,onChange:l=>O(l.target.value),placeholder:"All services (or: api, db, redis)"})]})]}),o==="existing"&&e.jsxs("div",{className:"docker-existing-section",children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Select Container:",e.jsx(j,{text:"Choose an existing Docker container to monitor and control. The container will not be deleted when removing the building.",title:"Existing Container",position:"top",size:"sm"})]}),e.jsxs("div",{className:"docker-existing-select-wrapper",children:[e.jsxs("select",{className:"form-input form-select",value:c,onChange:l=>E(l.target.value),required:o==="existing",children:[e.jsx("option",{value:"",children:"Select a container..."}),V.map(l=>e.jsxs("option",{value:l.name,children:[l.name," (",l.image,") - ",l.state]},l.id))]}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>D.requestDockerContainersList(),title:"Refresh container list",children:"↻"})]})]}),V.length===0&&e.jsx("div",{className:"form-hint docker-existing-hint",children:"No containers found. Make sure Docker is running and you have containers available."}),c&&e.jsx("div",{className:"docker-existing-info",children:(()=>{const l=V.find(S=>S.name===c);return l?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Image:"}),e.jsx("span",{className:"docker-existing-info-value",children:l.image})]}),e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Status:"}),e.jsx("span",{className:`docker-existing-info-value docker-status-${l.status}`,children:l.state})]}),e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"ID:"}),e.jsx("span",{className:"docker-existing-info-value",children:l.id.slice(0,12)})]}),l.ports.length>0&&e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Ports:"}),e.jsx("span",{className:"docker-existing-info-value",children:l.ports.map(S=>`${S.host}:${S.container}/${S.protocol}`).join(", ")})]})]}):null})()}),e.jsx("div",{className:"form-hint",children:"Note: Existing containers will not be deleted when you remove this building."})]}),o!=="existing"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Pull Policy:",e.jsx(j,{text:"When to pull images: always, only if missing, or never.",title:"Pull Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:b,onChange:l=>L(l.target.value),children:Object.keys($s).map(l=>e.jsx("option",{value:l,children:$s[l].label},l))})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:["Environment:",e.jsx(j,{text:"Environment variables in KEY=value format, one per line.",title:"Environment Variables",position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:T,onChange:l=>A(l.target.value),placeholder:`KEY=value
4
4
  DATABASE_URL=postgres://...