@xopcai/xopc 0.0.201 → 0.0.203

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 (164) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-DOhnAQOQ.js → activity-store-SZAay-ze.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-D8Cw0Mve.js → agent-avatar-dicebear-DPLJtxoS.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-DyjRuuRa.js +68 -0
  6. package/dist/gateway/static/root/assets/{api-E9Bk-Idp.js → api-C1cSt2ru.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-BubrReXg.js → app-management-settings-panel-B3PCMqor.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-BY5Az2p4.js → appearance-settings-txSx3REK.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-BEhBaooZ.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-BY8843mB.js → archive-plugin-B2VVc17j.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-DG45KScf.js → attachment-load-Crk7x8qR.js} +1 -1
  12. package/dist/gateway/static/root/assets/automations-page-BUC6FL6O.js +6 -0
  13. package/dist/gateway/static/root/assets/{binary-plugins-DGIF2ZAv.js → binary-plugins-CLlJsq5D.js} +1 -1
  14. package/dist/gateway/static/root/assets/{block-editor-C1Qktr1g.js → block-editor-cJ5lVNAG.js} +46 -46
  15. package/dist/gateway/static/root/assets/browser-settings-page-Bq2m4VpX.js +8 -0
  16. package/dist/gateway/static/root/assets/{browser-workflow-inputs-D_jnndyz.js → browser-workflow-inputs-WRiFG88u.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-workflows-page-DyIRvPaq.js → browser-workflows-page-BHLdVoOC.js} +2 -2
  18. package/dist/gateway/static/root/assets/capabilities-settings-panel-BiQbVvYU.js +7 -0
  19. package/dist/gateway/static/root/assets/{capability-presets-api--tz0mGLY.js → capability-presets-api-DmElfgC9.js} +1 -1
  20. package/dist/gateway/static/root/assets/capability-presets-settings-panel-CYlZQpLY.js +3 -0
  21. package/dist/gateway/static/root/assets/{channel-recipient-api-CkOKF9nc.js → channel-recipient-api-BUEOtPft.js} +1 -1
  22. package/dist/gateway/static/root/assets/channels-settings-DlDiCMhO.js +1 -0
  23. package/dist/gateway/static/root/assets/channels-status-swr-Dm_-934M.js +1 -0
  24. package/dist/gateway/static/root/assets/{connectors-api-FBOe9SWC.js → connectors-api-BCdn44_o.js} +1 -1
  25. package/dist/gateway/static/root/assets/connectors-page-Ce-eaPHw.js +2 -0
  26. package/dist/gateway/static/root/assets/cron-expression-D2hF3t68.js +2 -0
  27. package/dist/gateway/static/root/assets/{date-picker-Dtn7e6TW.js → date-picker-Dvjoq2mB.js} +1 -1
  28. package/dist/gateway/static/root/assets/dependency-picker-zv1OIhk3.js +1 -0
  29. package/dist/gateway/static/root/assets/desktop-pet-DJZhKLTb.js +1 -0
  30. package/dist/gateway/static/root/assets/{desktop-pet-settings-FDmaty3P.js → desktop-pet-settings-B3ubM-eY.js} +1 -1
  31. package/dist/gateway/static/root/assets/{directory-picker-path-field-X2e8xn8j.js → directory-picker-path-field-BZEJIWOT.js} +1 -1
  32. package/dist/gateway/static/root/assets/download-Dk-ZjtO6.js +1 -0
  33. package/dist/gateway/static/root/assets/{extension-debug-page-Dx4MBfga.js → extension-debug-page-Bvq3E1A1.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-page-Bf_FEDhM.js → extension-page-CuCJjWNm.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-settings-page-CrOgZxkf.js → extension-settings-page-CpTk_ajr.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-config-api-CZ4r-7qT.js → gateway-config-api-C2yM6qj7.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-config-swr-Cv2ywpdb.js → gateway-config-swr-CN-JHMAh.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-settings-DpWmVi0w.js → gateway-settings-COwi--2Q.js} +1 -1
  39. package/dist/gateway/static/root/assets/{gateway-startup-retry-undf-k5g.js → gateway-startup-retry-Dq1RyCjz.js} +1 -1
  40. package/dist/gateway/static/root/assets/{heartbeat-settings-DSQZhSvT.js → heartbeat-settings-Dc6H4VGF.js} +1 -1
  41. package/dist/gateway/static/root/assets/home-page-BB3RGxwm.js +3 -0
  42. package/dist/gateway/static/root/assets/index-CPTLS-Zn.js +85 -0
  43. package/dist/gateway/static/root/assets/index-Dm-cvIpl.css +2 -0
  44. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Bc3Quw42.js → keyboard-shortcuts-settings-cue30Z5p.js} +1 -1
  45. package/dist/gateway/static/root/assets/local-app-workbench-page-DfO6FOB9.js +2 -0
  46. package/dist/gateway/static/root/assets/local-apps-page-DKQSCsa0.js +1 -0
  47. package/dist/gateway/static/root/assets/{locale-store-CnamlR07.js → locale-store-81Gv0wwo.js} +1 -1
  48. package/dist/gateway/static/root/assets/logs-page-DODbODyl.js +2 -0
  49. package/dist/gateway/static/root/assets/{management-settings-CJmcaVje.js → management-settings--4H26QR-.js} +1 -1
  50. package/dist/gateway/static/root/assets/{markdown-split-AcuFp0TH.js → markdown-split-BTvpyjAi.js} +1 -1
  51. package/dist/gateway/static/root/assets/markdown-view-B12xeflb.css +1 -0
  52. package/dist/gateway/static/root/assets/markdown-view-B4iBrVWK.js +69 -0
  53. package/dist/gateway/static/root/assets/{media-plugins-BvFgsiJL.js → media-plugins-DrejWl8t.js} +1 -1
  54. package/dist/gateway/static/root/assets/messages-ELK_1h2D.js +3 -0
  55. package/dist/gateway/static/root/assets/{notes-page-IW7IQ9nJ.js → notes-page-DfSzeQKd.js} +1 -1
  56. package/dist/gateway/static/root/assets/notes-workbench-DxL4GhwV.js +4 -0
  57. package/dist/gateway/static/root/assets/plus-Q2yW6OE7.js +1 -0
  58. package/dist/gateway/static/root/assets/preview-open-alternatives-yjh1_7K3.js +1 -0
  59. package/dist/gateway/static/root/assets/{product-open-page-CWEzLykF.js → product-open-page-DopWBJLa.js} +1 -1
  60. package/dist/gateway/static/root/assets/project-detail-page-Bl3LJHZB.js +1 -0
  61. package/dist/gateway/static/root/assets/projects-page-DStOErTC.js +1 -0
  62. package/dist/gateway/static/root/assets/remote-access-hub-C_hh9ztK.js +1 -0
  63. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DAohEZrX.js → runtime-tools-settings-panel-_dHhbYV2.js} +2 -2
  64. package/dist/gateway/static/root/assets/{schema-form-C_OBW8A5.js → schema-form-DZhORvJZ.js} +1 -1
  65. package/dist/gateway/static/root/assets/sessions-page-DDY21KYw.js +1 -0
  66. package/dist/gateway/static/root/assets/settings-advanced-gate-BJrHIcw8.js +1 -0
  67. package/dist/gateway/static/root/assets/{settings-form-section-C7w2WS-A.js → settings-form-section-Du5eAgFS.js} +1 -1
  68. package/dist/gateway/static/root/assets/{settings-loading-skeleton-zwibve4m.js → settings-loading-skeleton-DWS27sv1.js} +1 -1
  69. package/dist/gateway/static/root/assets/{settings-page-B9W03dSW.js → settings-page-DPD0MwoN.js} +1 -1
  70. package/dist/gateway/static/root/assets/setup-status-panel-CnXN4LH_.js +1 -0
  71. package/dist/gateway/static/root/assets/share-preview-page-D6HmH2ga.js +2 -0
  72. package/dist/gateway/static/root/assets/shares-settings-U3lvtO3Y.js +1 -0
  73. package/dist/gateway/static/root/assets/skill-reload-api-B6GiZgZU.js +1 -0
  74. package/dist/gateway/static/root/assets/skills-page-XVO7d3fh.js +2 -0
  75. package/dist/gateway/static/root/assets/{skills-page.utils-D9QT5cxj.js → skills-page.utils-DwxIpWrI.js} +1 -1
  76. package/dist/gateway/static/root/assets/{system-settings-panel-c1HVtv1Y.js → system-settings-panel-BmKbxR8_.js} +1 -1
  77. package/dist/gateway/static/root/assets/task-detail-page-DA6ItYrc.js +1 -0
  78. package/dist/gateway/static/root/assets/{theme-store-BDyUTObE.js → theme-store-hOF81tUQ.js} +1 -1
  79. package/dist/gateway/static/root/assets/{use-autosave-D6UkH_Ga.js → use-autosave-GJfDpf66.js} +1 -1
  80. package/dist/gateway/static/root/assets/user-context-page-CQ1QrRE6.js +1 -0
  81. package/dist/gateway/static/root/assets/{voice-api-key-field-BOxkKbGh.js → voice-api-key-field-B0zve9EE.js} +1 -1
  82. package/dist/gateway/static/root/assets/work-discovery-overlay-DrIbHnBz.js +1 -0
  83. package/dist/gateway/static/root/assets/work-discovery-page-CQW8pPec.js +1 -0
  84. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-ZA3bP65I.js → workflow-run-setup-panel-D-_zQxim.js} +2 -2
  85. package/dist/gateway/static/root/assets/workflows-page-O21l_f5c.js +5 -0
  86. package/dist/gateway/static/root/assets/{working-directory-picker-modal-BcyiDXU3.js → working-directory-picker-modal-5xYx48tV.js} +1 -1
  87. package/dist/gateway/static/root/assets/x-B_N4OPjy.js +1 -0
  88. package/dist/gateway/static/root/index.html +19 -14
  89. package/dist/package.js +1 -1
  90. package/dist/src/agent/agent-manager.js +2 -1
  91. package/dist/src/agent/embedded/run-for-session.js +3 -2
  92. package/dist/src/agent/embedded/run-turn.js +29 -16
  93. package/dist/src/agent/embedded/types.d.ts +2 -2
  94. package/dist/src/agent/embedded/xopc-stream-bridge.d.ts +2 -1
  95. package/dist/src/agent/embedded/xopc-stream-bridge.js +2 -2
  96. package/dist/src/agent/memory/context-budget.d.ts +6 -1
  97. package/dist/src/agent/memory/context-budget.js +94 -2
  98. package/dist/src/agent/prompt/cache-boundary.d.ts +2 -0
  99. package/dist/src/agent/prompt/cache-boundary.js +10 -1
  100. package/dist/src/agent/prompt/sections/project-context.d.ts +1 -4
  101. package/dist/src/agent/prompt/sections/project-context.js +6 -13
  102. package/dist/src/agent/prompt/service-prompt-builder.js +2 -1
  103. package/dist/src/agent/prompt/system-prompt.d.ts +1 -3
  104. package/dist/src/agent/prompt/system-prompt.js +6 -15
  105. package/dist/src/agent/tools/cache-stability.d.ts +3 -0
  106. package/dist/src/agent/tools/cache-stability.js +19 -0
  107. package/dist/src/agent/tools/factory.js +2 -1
  108. package/dist/src/agent-manifest/schema.d.ts +40 -20
  109. package/dist/src/agent-manifest/schema.js +4 -5
  110. package/dist/src/config/schema.d.ts +40 -20
  111. package/dist/src/extensions/types/providers.d.ts +0 -2
  112. package/dist/src/gateway/hono/lib/config-payload.d.ts +4 -1
  113. package/dist/src/gateway/hono/oauth-async.d.ts +1 -0
  114. package/dist/src/gateway/hono/oauth-async.js +14 -2
  115. package/dist/src/providers/extension-stream-bridge.js +0 -2
  116. package/dist/src/providers/google-managed-prompt-cache.d.ts +14 -0
  117. package/dist/src/providers/google-managed-prompt-cache.js +125 -0
  118. package/dist/src/providers/prompt-cache-fingerprint.d.ts +4 -0
  119. package/dist/src/providers/prompt-cache-fingerprint.js +44 -0
  120. package/dist/src/providers/prompt-cache-lifecycle.d.ts +9 -0
  121. package/dist/src/providers/prompt-cache-lifecycle.js +31 -0
  122. package/dist/src/providers/prompt-cache-observability.d.ts +20 -0
  123. package/dist/src/providers/prompt-cache-observability.js +44 -0
  124. package/dist/src/providers/prompt-cache-payload.d.ts +10 -3
  125. package/dist/src/providers/prompt-cache-payload.js +204 -31
  126. package/dist/src/providers/prompt-cache-plan.d.ts +15 -0
  127. package/dist/src/providers/prompt-cache-plan.js +29 -0
  128. package/package.json +3 -3
  129. package/dist/gateway/static/root/assets/agents-ANavi648.js +0 -68
  130. package/dist/gateway/static/root/assets/apps-page-CFh9MBxc.js +0 -1
  131. package/dist/gateway/static/root/assets/automations-page-751CeNI3.js +0 -6
  132. package/dist/gateway/static/root/assets/browser-settings-page-CGAWs-TT.js +0 -8
  133. package/dist/gateway/static/root/assets/capabilities-settings-panel-CghUK68J.js +0 -7
  134. package/dist/gateway/static/root/assets/capability-presets-settings-panel-XsTfkvUn.js +0 -3
  135. package/dist/gateway/static/root/assets/channels-settings-DkoAZZMe.js +0 -1
  136. package/dist/gateway/static/root/assets/channels-status-swr-DNDvMWpl.js +0 -1
  137. package/dist/gateway/static/root/assets/connectors-page-e4vekkAu.js +0 -2
  138. package/dist/gateway/static/root/assets/cron-expression-Q4QaYjpI.js +0 -2
  139. package/dist/gateway/static/root/assets/dependency-picker-Br6nPaM6.js +0 -1
  140. package/dist/gateway/static/root/assets/desktop-pet-DzTM6aH8.js +0 -1
  141. package/dist/gateway/static/root/assets/home-page-L0uHiu0T.js +0 -3
  142. package/dist/gateway/static/root/assets/index-Bp8I_eX4.css +0 -1
  143. package/dist/gateway/static/root/assets/index-DRrjYYzZ.js +0 -152
  144. package/dist/gateway/static/root/assets/local-app-workbench-page-Copi3sdP.js +0 -2
  145. package/dist/gateway/static/root/assets/local-apps-page-CP9X_vtz.js +0 -1
  146. package/dist/gateway/static/root/assets/logs-page-DMKq6e29.js +0 -2
  147. package/dist/gateway/static/root/assets/messages-D7kOD_o_.js +0 -3
  148. package/dist/gateway/static/root/assets/notes-workbench-Zb8U0anO.js +0 -4
  149. package/dist/gateway/static/root/assets/preview-open-alternatives-C-b34dgQ.js +0 -1
  150. package/dist/gateway/static/root/assets/project-detail-page-BuIbLnan.js +0 -1
  151. package/dist/gateway/static/root/assets/projects-page-BwUfRqNV.js +0 -1
  152. package/dist/gateway/static/root/assets/remote-access-hub-BTaXxcEi.js +0 -1
  153. package/dist/gateway/static/root/assets/sessions-page-BnHoTCD3.js +0 -1
  154. package/dist/gateway/static/root/assets/settings-advanced-gate-BTB_fxjt.js +0 -1
  155. package/dist/gateway/static/root/assets/setup-status-panel-C8Hec2Af.js +0 -1
  156. package/dist/gateway/static/root/assets/share-preview-page-6e3ks2be.js +0 -2
  157. package/dist/gateway/static/root/assets/shares-settings-Bwc5HfLI.js +0 -1
  158. package/dist/gateway/static/root/assets/skill-reload-api-D7kunhqy.js +0 -1
  159. package/dist/gateway/static/root/assets/skills-page-WgkaNzpc.js +0 -2
  160. package/dist/gateway/static/root/assets/task-detail-page-CjP-6WVU.js +0 -1
  161. package/dist/gateway/static/root/assets/user-context-page-D8ZhPDNF.js +0 -1
  162. package/dist/gateway/static/root/assets/work-discovery-overlay-Dd19yK9t.js +0 -1
  163. package/dist/gateway/static/root/assets/work-discovery-page-DUkdJl1e.js +0 -1
  164. package/dist/gateway/static/root/assets/workflows-page-C2b5W5bw.js +0 -5
@@ -1,6 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,t as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{n as o,r as s}from"./popover-select-BzdnTy3h.js";import{t as c}from"./cn-JdwAhgNB.js";import{t as l}from"./button-CSEbl4zT.js";import{t as u}from"./messages-D7kOD_o_.js";import{n as d}from"./locale-store-CnamlR07.js";import{a as f,n as p,o as m,r as h,s as g,t as _}from"./dist-BPoKqzeH.js";import{i as v}from"./vendor-swr-BIWyz7Rc.js";import{Al as y,An as b,Dl as x,Ds as S,Hc as C,Jo as w,Ks as ee,Ls as T,Ma as E,Ml as D,Na as O,Ns as k,Ol as A,Ql as te,Qs as j,Ri as ne,Ss as re,Tl as ie,Wa as M,Ws as ae,Xs as oe,Yo as N,dr as P,fc as se,fr as F,gr as ce,hc as le,ls as ue,mr as de,nl as I,pr as L,u as R,v as fe,wi as pe}from"./index-DRrjYYzZ.js";import{a as z,i as B,o as me,r as V}from"./cron-expression-Q4QaYjpI.js";import{a as he,i as ge,n as _e,r as H,t as ve}from"./workflow-run-setup-panel-ZA3bP65I.js";import{i as ye,n as be,r as xe,t as Se}from"./browser-workflow-inputs-D_jnndyz.js";var U=e(t(),1),W=n(),Ce=z();function we(e,t,n){let r=new Date;return r.setHours(e,t,0,0),r.toLocaleTimeString(n,{hour:`numeric`,minute:`2-digit`})}function Te(e,t){let n=e===7?0:e;return new Date(Date.UTC(2023,0,1)+n*864e5).toLocaleDateString(t,{weekday:`short`,timeZone:`UTC`})}function G(e,t){return e.length<=1?e[0]??``:t.startsWith(`zh`)?e.join(`、`):e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(`, `)}, and ${e.at(-1)}`}function Ee(e){return e.length===5&&e.every((e,t)=>e===t+1)}function De(e){if(e.length!==2)return!1;let t=[...e].toSorted((e,t)=>e-t);return t[0]===0&&t[1]===6}function Oe(e,t,n,r){try{let i=Ce.CronExpressionParser.parse(e,{...r?.timezone?{tz:r.timezone}:{}}).fields,a=V(i.minute.values),o=V(i.hour.values),s=V(i.dayOfWeek.values),c=V(i.dayOfMonth.values);if(a.length===60&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard)return n.everyMinute;if(!i.minute.isWildcard&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard&&a.length>1){let e=B(a);if(e!=null&&e>0)return n.everyNMinutes.replace(`{{n}}`,String(e))}if(!i.minute.isWildcard&&a.length===1&&!i.hour.isWildcard&&o.length>1&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard){let e=B(o);if(e!=null&&e>0)return n.everyNHours.replace(`{{n}}`,String(e))}if(!i.minute.isWildcard&&a.length===1&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard&&o.length===24)return n.hourly;let l=!i.minute.isWildcard&&a.length===1&&!i.hour.isWildcard&&o.length===1?we(o[0],a[0],t):``;if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard)return n.dailyAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&Ee(s))return n.weekdaysAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&De(s))return n.weekendsAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&s.length===1){let e=Te(s[0],t);return n.weeklyOn.replace(`{{day}}`,e).replace(`{{time}}`,l)}if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&s.length>1){let e=G(s.map(e=>Te(e,t)),t);return n.daysAt.replace(`{{days}}`,e).replace(`{{time}}`,l)}return l&&!i.dayOfMonth.isWildcard&&c.length===1&&i.month.isWildcard&&i.dayOfWeek.isWildcard?n.monthlyAt.replace(`{{day}}`,String(c[0])).replace(`{{time}}`,l):n.customSchedule}catch{return null}}function ke(e,t,n,r){let i=e.trim();return i?Oe(i,t,n,r)||Ae(r?.nextRun,t)||n.customSchedule:Ae(r?.nextRun,t)||`—`}function Ae(e,t){if(!e)return``;let n=new Date(e);return Number.isNaN(n.getTime())?``:n.toLocaleString(t,{weekday:`short`,hour:`numeric`,minute:`2-digit`})}var K=1e3,q=60*K,J=60*q,Y=24*J,X=7*Y,je=new Intl.ListFormat(`en-US`,{type:`conjunction`}),Me=Object.fromEntries([`second`,`minute`,`hour`,`day`,`week`].map(e=>[e,new Intl.NumberFormat(`en-US`,{style:`unit`,unit:e,unitDisplay:`long`})])),Ne={en:new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),zh:new Intl.DateTimeFormat(`zh-CN`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})},Pe={en:new Intl.DateTimeFormat(`en-US`,{hour:`2-digit`,minute:`2-digit`}),zh:new Intl.DateTimeFormat(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})},Fe={minute:q,hour:J,day:Y,week:X};function Ie(e){return e===`zh`?`zh-CN`:`en-US`}function Le(e,t,n){return n===`zh`?`${e} ${t===`week`?`周`:t===`day`?`天`:t===`hour`?`小时`:t===`minute`?`分钟`:`秒`}`:Me[String(t)].format(e)}function Re(e,t){return t===`zh`?e.join(` `):je.format(e)}function ze(e,t){let n=typeof e==`number`?e:Number.parseFloat(e);return Math.max(q,Math.round((Number.isFinite(n)&&n>0?n:1)*Fe[t]))}function Be(e,t,n){let r=typeof e==`number`?e:Number.parseFloat(e),i=Number.isFinite(r)&&r>0?r:1;return String(Number.parseFloat((i*Fe[t]/Fe[n]).toFixed(6)))}function Ve(e,t){let n=Math.max(K,Math.round(e)),r=n===Y?[{unit:`hour`,ms:J}]:n>=X&&n%X===0?[{unit:`week`,ms:X}]:n>=Y?[{unit:`day`,ms:Y},{unit:`hour`,ms:J},{unit:`minute`,ms:q},{unit:`second`,ms:K}]:n>=J?[{unit:`hour`,ms:J},{unit:`minute`,ms:q},{unit:`second`,ms:K}]:n>=q?[{unit:`minute`,ms:q},{unit:`second`,ms:K}]:[{unit:`second`,ms:K}],i=n,a=[];for(let{unit:e,ms:n}of r){let r=Math.floor(i/n);r<=0||(a.push(Le(r,e,t)),i%=n)}return Re(a,t)}function He(e,t){let n=Ve(e,t);return t===`zh`?`每 ${n}运行一次`:`Runs every ${n}`}function Ue(e,t){return Ne[t].format(new Date(e))}function We(e){return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())}function Ge(e,t,n=Date.now()){let r=new Date(e),i=Math.round((We(r)-We(new Date(n)))/Y),a=Pe[t].format(r);return i===0?t===`zh`?`今天 ${a}`:`today at ${a}`:i===1?t===`zh`?`明天 ${a}`:`tomorrow at ${a}`:i===-1?t===`zh`?`昨天 ${a}`:`yesterday at ${a}`:Ue(e,t)}function Ke(e,t){return e.eventType===`task.attention_required.v2`&&e.payloadMatch?.reason===`blocked`?t.trigger.taskBlockedWhen:e.eventType===`note.created`?t.trigger.noteCreatedWhen:e.eventType===`workflow.run.completed`&&e.payloadMatch?.status===`failed`?t.trigger.workflowFailedWhen:e.eventType===`session.transcript.updated`?t.trigger.sessionUpdatedWhen:t.trigger.eventWithType.replace(`{type}`,e.eventType)}function qe(e,t,n,r){if(e.kind===`manual`)return t.trigger.manualWhen;if(e.kind===`webhook`)return t.trigger.webhookWhen;if(e.kind===`event`)return Ke(e,t);let i=e.schedule;return i.kind===`once`?t.trigger.onceAt.replace(`{time}`,Ge(Date.parse(i.at),r)):i.kind===`interval`?He(i.everyMs,r):ke(i.expr,Ie(r),n.scheduleBadge,{timezone:i.tz})}function Je(e,t,n,r=Date.now()){return e.enabled?e.state.nextRunAtMs?Ge(e.state.nextRunAtMs,n,r):e.trigger.kind===`manual`?t.info.noAutomaticTrigger:e.trigger.kind===`event`||e.trigger.kind===`webhook`?t.info.waitingForTrigger:t.info.noUpcomingRun:t.info.pausedNoAutomaticRuns}function Ye(e,t,n,r=Date.now()){if(!e.state.lastRunAtMs)return t.info.notRunYet;let i=Ge(e.state.lastRunAtMs,n,r),a=e.state.lastRunStatus;return a?`${i} · ${t.status[a]}`:i}var Xe={name:``,description:``,triggerMode:`daily`,time:`09:00`,weekday:`1`,intervalValue:`1`,intervalUnit:`hour`,cronExpr:`0 9 * * *`,webhookSecretId:``,onceAt:``,eventType:``,eventSource:``,eventPayloadMatch:``,actionMode:`agent`,agentId:``,instruction:``,workflowId:``,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0,browserWorkflowId:``,browserWorkflowInputs:{},safetyMode:`suggest_only`,timeoutSeconds:`1800`,afterRunMode:`none`,webhookUrl:``,disableAfterFailures:`3`},Ze=[{value:`15`,unit:`minute`},{value:`30`,unit:`minute`},{value:`1`,unit:`hour`},{value:`6`,unit:`hour`},{value:`24`,unit:`hour`}];function Qe(e,t){let[n,r]=e.time.split(`:`),i=Number.parseInt(n||`9`,10),a=Number.parseInt(r||`0`,10),o;if(e.triggerMode===`manual`)o={kind:`manual`};else if(e.triggerMode===`once`)o={kind:`schedule`,schedule:{kind:`once`,at:new Date(e.onceAt).toISOString()}};else if(e.triggerMode===`webhook`)o={kind:`webhook`,...e.webhookSecretId.trim()?{secretId:e.webhookSecretId.trim()}:{}};else if(e.triggerMode===`taskBlocked`)o={kind:`event`,eventType:`task.attention_required.v2`,source:`tasks`,payloadMatch:{reason:`blocked`}};else if(e.triggerMode===`noteCreated`)o={kind:`event`,eventType:`note.created`,source:`notes`};else if(e.triggerMode===`workflowFailed`)o={kind:`event`,eventType:`workflow.run.completed`,source:`workflows`,payloadMatch:{status:`failed`}};else if(e.triggerMode===`sessionUpdated`)o={kind:`event`,eventType:`session.transcript.updated`,source:`sessions`};else if(e.triggerMode===`event`){let t=e.eventPayloadMatch.trim()?JSON.parse(e.eventPayloadMatch):void 0;o={kind:`event`,eventType:e.eventType.trim(),...e.eventSource.trim()?{source:e.eventSource.trim()}:{},...t?{payloadMatch:t}:{}}}else o=e.triggerMode===`interval`?{kind:`schedule`,schedule:{kind:`interval`,everyMs:ze(e.intervalValue,e.intervalUnit)}}:e.triggerMode===`weekly`?{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * ${e.weekday}`}}:e.triggerMode===`cron`?{kind:`schedule`,schedule:{kind:`cron`,expr:e.cronExpr.trim()}}:{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * *`}};let s=H(t,e.workflowInput),c=e.workflowInput.goal.trim()||e.workflowGoal.trim(),l=e.actionMode===`browser_recipe`?`auto_apply`:e.safetyMode,u=l===`auto_apply`?e.afterRunMode:`none`,d;return d=e.actionMode===`workflow`?{kind:`workflow`,workflowId:e.workflowId.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{},...s===void 0?{}:{input:s},...c?{goal:c}:{},...e.workflowInput.concurrency.trim()?{concurrency:Math.max(1,Number.parseInt(e.workflowInput.concurrency,10)||1)}:{},...e.workflowInput.maxSubagents.trim()?{maxSubagents:Math.max(1,Number.parseInt(e.workflowInput.maxSubagents,10)||1)}:{}}:e.actionMode===`browser_recipe`?{kind:`browser_recipe`,recipeId:e.browserWorkflowId.trim(),args:e.browserWorkflowInputs}:{kind:`agent`,instruction:e.instruction.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{}},{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},trigger:o,action:d,safety:{mode:l},afterRun:u===`webhook`?{kind:`webhook`,url:e.webhookUrl.trim()}:{kind:u},reliability:{executionTimeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||1800),disableAfterConsecutiveFailures:Math.max(1,Number.parseInt(e.disableAfterFailures,10)||3)}}}function $e(e){let t=e.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+\*$/);if(t)return{triggerMode:`daily`,time:`${t[2].padStart(2,`0`)}:${t[1].padStart(2,`0`)}`,weekday:`1`,cronExpr:e};let n=e.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+([0-6])$/);return n?{triggerMode:`weekly`,time:`${n[2].padStart(2,`0`)}:${n[1].padStart(2,`0`)}`,weekday:n[3],cronExpr:e}:{triggerMode:`cron`,time:Xe.time,weekday:Xe.weekday,cronExpr:e}}function et(e){let t=[[`week`,10080*6e4],[`day`,1440*6e4],[`hour`,60*6e4],[`minute`,6e4]],[n,r]=t.find(([,t])=>e>=t&&e%t===0)??t.at(-1);return{intervalValue:String(e/r),intervalUnit:n}}function tt(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=t.getTimezoneOffset()*6e4;return new Date(t.getTime()-n).toISOString().slice(0,16)}function nt(e){let t=e.payloadMatch;return e.eventType===`task.attention_required.v2`&&e.source===`tasks`&&t?.reason===`blocked`?{triggerMode:`taskBlocked`}:e.eventType===`note.created`&&e.source===`notes`&&!t?{triggerMode:`noteCreated`}:e.eventType===`workflow.run.completed`&&e.source===`workflows`&&t?.status===`failed`?{triggerMode:`workflowFailed`}:e.eventType===`session.transcript.updated`&&e.source===`sessions`&&!t?{triggerMode:`sessionUpdated`}:{triggerMode:`event`,eventType:e.eventType,eventSource:e.source??``,eventPayloadMatch:t?JSON.stringify(t,null,2):``}}function rt(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function it(e){if(!e.trim())return!0;try{let t=JSON.parse(e);return!!t&&typeof t==`object`&&!Array.isArray(t)&&Object.values(t).every(e=>e===null||[`string`,`number`,`boolean`].includes(typeof e))}catch{return!1}}function at(e,t=[]){let n={triggerMode:`manual`};if(e.trigger.kind===`webhook`)n={triggerMode:`webhook`,webhookSecretId:e.trigger.secretId??``};else if(e.trigger.kind===`event`)n=nt(e.trigger);else if(e.trigger.kind===`schedule`){let t=e.trigger.schedule;t.kind===`cron`&&(n=$e(t.expr)),t.kind===`interval`&&(n={triggerMode:`interval`,...et(t.everyMs)}),t.kind===`once`&&(n={triggerMode:`once`,onceAt:tt(t.at)})}let r=e.action,i=r.kind===`workflow`?t.find(e=>e.id===r.workflowId)??null:null,a=r.kind===`workflow`?rt(r.input):{},o=e.afterRun??{kind:`none`},s=e.reliability?.executionTimeoutSeconds??r.timeoutSeconds??e.reliability?.timeoutSeconds??(r.kind===`browser_recipe`?600:1800);return{...Xe,...n,name:e.name,description:e.description??``,actionMode:r.kind,agentId:r.kind===`browser_recipe`?``:r.agentId??``,instruction:r.kind===`agent`?r.instruction:``,workflowId:r.kind===`workflow`?r.workflowId:``,workflowGoal:r.kind===`workflow`?r.goal??``:``,browserWorkflowId:r.kind===`browser_recipe`?r.recipeId:``,browserWorkflowInputs:r.kind===`browser_recipe`?r.args??{}:{},workflowInput:{goal:r.kind===`workflow`?r.goal??``:``,argValues:i?_e(i.name,a):{},schemaInput:a,concurrency:r.kind===`workflow`&&r.concurrency?String(r.concurrency):``,maxSubagents:r.kind===`workflow`&&r.maxSubagents?String(r.maxSubagents):``},workflowInputValid:!0,safetyMode:e.safety?.mode??`auto_apply`,timeoutSeconds:String(s),afterRunMode:o.kind,webhookUrl:o.kind===`webhook`?o.url:``,disableAfterFailures:String(e.reliability?.disableAfterConsecutiveFailures??3)}}function ot(e,t,n){let r=Qe(t,n),i=e.trigger.kind===`schedule`&&r.trigger.kind===`schedule`&&e.trigger.schedule.kind===r.trigger.schedule.kind?{...r.trigger,schedule:{...e.trigger.schedule,...r.trigger.schedule}}:r.trigger,a=r.action;return e.action.kind===`agent`&&r.action.kind===`agent`?a={...e.action,...r.action,agentId:r.action.agentId}:e.action.kind===`workflow`&&r.action.kind===`workflow`?a={...e.action,...r.action,agentId:r.action.agentId,input:r.action.input,goal:r.action.goal,concurrency:r.action.concurrency,maxSubagents:r.action.maxSubagents}:e.action.kind===`browser_recipe`&&r.action.kind===`browser_recipe`&&(a={...e.action,...r.action}),{...r,description:t.description.trim(),trigger:i,action:a,reliability:{...e.reliability,...r.reliability}}}var Z=r();function st(e,t,n){return e?Ue(e,n):t.never}function ct(e,t){return e.kind===`workflow`?t.action.workflowWithId.replace(`{id}`,e.workflowId):e.kind===`browser_recipe`?`Browser automation: ${e.recipeId}`:e.agentId?t.action.agentWithId.replace(`{id}`,e.agentId):t.action.agent}function lt(e){return e.safety?.mode??`auto_apply`}function ut(e){return e===`succeeded`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`running`||e===`queued`||e===`cancelling`?`bg-blue-500/10 text-blue-700 dark:text-blue-300`:`bg-surface-hover text-fg-muted`}function dt(e,t){if(e==null)return t.never;if(e<1e3)return`${e}ms`;let n=Math.round(e/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`}function ft(e){return e.status===`running`||e.status===`queued`||e.status===`cancelling`}function pt(e){return e.status===`failed`||e.status===`timeout`||e.status===`cancelled`}function mt(e,t){if((e.state.consecutiveFailures??0)>0)return!0;let n=t.reduce((t,n)=>n.automationId===e.id&&(!t||n.createdAtMs>t.createdAtMs)?n:t,void 0);return n?pt(n):!1}function ht(e,t){return e.action.kind===`agent`?e.action.instruction:e.action.kind===`workflow`&&e.action.goal?.trim()||ct(e.action,t)}function gt(e){return(e.description?.match(/\[managed-by=([^\]]+)\]/))?.[1]?.trim()||null}function _t(e){return!!gt(e)}function vt(e){return e.description?.replace(/\s*\[managed-by=[^\]]+\]\s*/g,` `).trim()??``}function yt(e){return ft(e)?0:pt(e)?1:e.status===`succeeded`?2:3}function bt(e){return[...e].sort((e,t)=>{let n=yt(e)-yt(t);return n===0?t.createdAtMs-e.createdAtMs:n})}function xt(){let e=(0,W.c)(5),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,Z.jsx)(O,{className:`h-4 w-36`}),(0,Z.jsx)(O,{className:`h-3 w-56 max-w-full`})]}),(0,Z.jsx)(O,{className:`h-7 w-20 rounded-full`})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsxs)(`section`,{className:`rounded-xl bg-surface-panel p-4 shadow-surface`,children:[t,(0,Z.jsx)(`div`,{className:`mt-4 grid gap-2`,children:Array.from({length:6}).map(St)})]}),e[1]=n):n=e[1];let r,i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(O,{className:`h-4 w-32`}),i=(0,Z.jsx)(O,{className:`mt-4 h-24 rounded-lg`}),e[2]=r,e[3]=i):(r=e[2],i=e[3]);let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:(0,Z.jsxs)(`div`,{className:`grid gap-3 xl:grid-cols-[minmax(0,1fr)_26rem]`,children:[n,(0,Z.jsxs)(`section`,{className:`hidden rounded-xl bg-surface-panel p-4 shadow-surface xl:block`,children:[r,i,(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-2`,children:[(0,Z.jsx)(O,{className:`h-12 rounded-lg`}),(0,Z.jsx)(O,{className:`h-12 rounded-lg`}),(0,Z.jsx)(O,{className:`h-12 rounded-lg`})]})]})]})}),e[4]=a):a=e[4],a}function St(e,t){return(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(O,{className:`size-4 rounded-full`}),(0,Z.jsx)(O,{className:`h-4 w-32`}),(0,Z.jsx)(O,{className:`h-5 w-20 rounded-full`})]}),(0,Z.jsx)(O,{className:`mt-3 h-4 w-full`}),(0,Z.jsx)(O,{className:`mt-2 h-4 w-3/5`})]}),(0,Z.jsx)(O,{className:`h-8 w-24 rounded-md`})]})},t)}function Ct(){let e=d(e=>e.language),t=u(e),n=t.automations,r=t.cron,a=M(e=>e.setPageHeader),o=M(e=>e.clearPageHeader),[s,y]=i(),b=s.get(`run`)?.trim()??``,x=s.get(`view`)===`runs`,S=s.get(`automation`)?.trim()??``,C=s.get(`draft`)?.trim()??``,ee=s.get(`action`)?.trim()??``,T=s.get(`projectId`)?.trim()??``,D=s.get(`autogenerate`)===`1`,O=(0,U.useRef)(``),[A,j]=(0,U.useState)(`all`),[re,ie]=(0,U.useState)(``),[oe,P]=(0,U.useState)(!1),[se,F]=(0,U.useState)(`blank`),[ce,le]=(0,U.useState)(null),[ue,de]=(0,U.useState)(!1),[I,L]=(0,U.useState)(Xe),[pe,z]=(0,U.useState)(null),[B,me]=(0,U.useState)(null),[V,he]=(0,U.useState)(!1),[_e,H]=(0,U.useState)(null),[ve,xe]=(0,U.useState)(``),[Se,W]=(0,U.useState)(null),[Ce,we]=(0,U.useState)(!1),[Te,G]=(0,U.useState)(!1),[Ee,De]=(0,U.useState)(null),[Oe,ke]=(0,U.useState)(!1),[Ae,K]=(0,U.useState)(!1),[q,J]=(0,U.useState)(!1),[Y,X]=(0,U.useState)(null),je=v([`automations`,T],()=>R.list(T?{projectId:T}:void 0),{refreshInterval:15e3}),Me=v([`automation-runs`,T],()=>R.runs(50,void 0,T?{projectId:T}:void 0),{refreshInterval:1e4}),Ne=v(B?`automation-run-events:${B}`:null,()=>R.runEvents(B),{refreshInterval:5e3}),Pe=v(`automation-workflow-definitions`,fe),Fe=v(`automation-browser-workflows`,()=>ye.list()),Ie=v(`automation-chat-agents`,E),Le=je.isLoading&&!je.data||Me.isLoading&&!Me.data,Re=je.data?.automations??[],ze=(0,U.useMemo)(()=>bt(Me.data?.runs??[]),[Me.data?.runs]),Be=(0,U.useMemo)(()=>Re.filter(e=>!_t(e)),[Re]),Ve=(0,U.useMemo)(()=>Re.filter(_t),[Re]),He=(0,U.useMemo)(()=>new Set(Ve.map(e=>e.id)),[Ve]),Ue=(0,U.useMemo)(()=>ze.filter(e=>!He.has(e.automationId)),[ze,He]),We=(0,U.useMemo)(()=>ze.find(e=>e.id===B)??null,[ze,B]),Ge=(0,U.useMemo)(()=>Re.find(e=>e.id===_e)??null,[Re,_e]),Ke=(0,U.useMemo)(()=>Re.find(e=>e.id===ce)??null,[Re,ce]),Je=(0,U.useMemo)(()=>ze.filter(e=>e.automationId===_e).sort((e,t)=>t.createdAtMs-e.createdAtMs),[ze,_e]),Ye=Ne.data?.events??[],Ze=(0,U.useMemo)(()=>Be.filter(e=>mt(e,Ue)).length,[Be,Ue]),$e=re.trim().toLocaleLowerCase(),et=(0,U.useMemo)(()=>(A===`system`?Ve:Be).filter(t=>A===`active`&&!t.enabled||A===`paused`&&t.enabled||A===`attention`&&!mt(t,Ue)?!1:$e?[t.name,vt(t),ht(t,n),qe(t.trigger,n,r,e)].some(e=>e.toLocaleLowerCase().includes($e)):!0),[r,A,n,e,$e,Ve,Be,Ue]),tt=(0,U.useMemo)(()=>Pe.data??[],[Pe.data]),nt=(0,U.useMemo)(()=>(Fe.data?.workflows??[]).filter(e=>e.enabled),[Fe.data]),rt=Ie.data?.items??[],st=(0,U.useMemo)(()=>tt.find(e=>e.id===I.workflowId.trim())??null,[I.workflowId,tt]),ct=(0,U.useMemo)(()=>nt.find(e=>e.id===I.browserWorkflowId.trim())??null,[nt,I.browserWorkflowId]),lt=I.actionMode===`workflow`&&(!I.workflowId.trim()||tt.length>0&&!tt.some(e=>e.id===I.workflowId)),ut=I.actionMode===`workflow`&&st?!ge(st,I.workflowInput,I.workflowInputValid).valid:!1,dt=!!I.name.trim()&&(I.triggerMode!==`once`||Number.isFinite(new Date(I.onceAt).getTime()))&&(I.triggerMode!==`event`||!!I.eventType.trim()&&it(I.eventPayloadMatch))&&(I.actionMode===`workflow`?!lt&&!ut:I.actionMode===`browser_recipe`?ct!==null&&be(ct,I.browserWorkflowInputs):!!I.instruction.trim())&&(I.afterRunMode!==`webhook`||!!I.webhookUrl.trim()),ft=(0,U.useMemo)(()=>[{name:n.templates.dailyAgent.name,description:n.templates.dailyAgent.description,form:{...Xe,name:n.templates.dailyAgent.name,instruction:n.templates.dailyAgent.instruction,triggerMode:`daily`}},{name:n.templates.morningWorkflow.name,description:n.templates.morningWorkflow.description,form:{...Xe,name:n.templates.morningWorkflow.formName,actionMode:`workflow`,workflowId:tt[0]?.id??``}},{name:n.templates.webhookAgent.name,description:n.templates.webhookAgent.description,form:{...Xe,name:n.templates.webhookAgent.formName,triggerMode:`webhook`}},{name:n.templates.blockedTask.name,description:n.templates.blockedTask.description,form:{...Xe,name:n.templates.blockedTask.formName,triggerMode:`taskBlocked`,instruction:n.templates.blockedTask.instruction}},{name:n.templates.noteCreated.name,description:n.templates.noteCreated.description,form:{...Xe,name:n.templates.noteCreated.formName,triggerMode:`noteCreated`,instruction:n.templates.noteCreated.instruction}}],[n,tt]);(0,U.useEffect)(()=>{if(et.length===0){H(null);return}_e&&et.some(e=>e.id===_e)||H(et[0].id)},[et,_e]);let pt=(0,U.useCallback)(async()=>{await Promise.all([je.mutate(),Me.mutate(),Ne.mutate()])},[je.mutate,Ne.mutate,Me.mutate]),gt=(0,U.useCallback)(e=>{if(le(null),de(!1),F(e),P(!0),e===`blank`){L(Xe);return}xe(``),W(null),G(!1)},[]),yt=(0,U.useCallback)(e=>{L(at(e,tt)),le(e.id),de(!1),H(null),F(`blank`),P(!0)},[tt]),St=(0,U.useCallback)(()=>{Se&&(L(at(Se.automation,tt)),le(null),de(!0),F(`blank`))},[Se,tt]),Ct=(0,U.useCallback)(async()=>{J(!0),z(null);try{await pt()}catch(e){z(e instanceof Error?e.message:String(e))}finally{J(!1)}},[n.feedback.actionFailed,pt]);(0,U.useEffect)(()=>{b&&(me(b),he(!0))},[b]),(0,U.useEffect)(()=>{if(!S)return;let e=Re.find(e=>e.id===S);e&&(j(_t(e)?`system`:`all`),H(e.id),y(e=>{let t=new URLSearchParams(e);return t.delete(`automation`),t},{replace:!0}))},[S,Re,y]),(0,U.useEffect)(()=>{ee===`create`&&(gt(`blank`),y(e=>{let t=new URLSearchParams(e);return t.delete(`action`),t},{replace:!0}))},[ee,gt,y]),(0,U.useEffect)(()=>{if(!C)return;let t=`${e}:${D?`auto`:`seed`}:${C}`;O.current!==t&&(O.current=t,xe(C),W(null),G(!1),F(`draft`),P(!0),y(e=>{let t=new URLSearchParams(e);return t.delete(`draft`),t.delete(`autogenerate`),t},{replace:!0}),D&&(z(null),we(!0),R.draft({prompt:C,language:e}).then(e=>{W(e.draft),G(!1)}).catch(e=>{z(e instanceof Error?e.message:String(e))}).finally(()=>{we(!1)})))},[D,C,e,y]);let Tt=(0,U.useCallback)(e=>{me(e),he(!0),y(t=>{let n=new URLSearchParams(t);return n.set(`run`,e),n},{replace:!0})},[y]);(0,U.useEffect)(()=>{De(null),K(!1)},[B]);async function Et(){if(z(null),dt){if(ue&&Se){X(`draft:edit`);try{let e=Qe(I,st),{simulation:t}=await R.simulate(e);W({...Se,automation:e,simulation:t}),G(!1),de(!1),F(`draft`)}catch(e){z(e instanceof Error?e.message:String(e))}finally{X(null)}return}if(Ke){let e=Ke.id;await Ot(`automation:${e}:edit`,()=>R.update(e,ot(Ke,I,st)))&&(P(!1),le(null),H(e));return}try{let{automation:e}=await R.create({...Qe(I,st),...T?{projectId:T}:{}});L(Xe),P(!1),j(`all`),ie(``),await pt(),H(e.id)}catch(e){z(e instanceof Error?e.message:String(e))}}}async function Ot(e,t){z(null),X(e);try{return await t(),await pt(),!0}catch(e){return z(e instanceof Error?e.message:String(e)),!1}finally{X(null)}}async function At(){let t=ve.trim();if(t){z(null),we(!0);try{W((await R.draft({prompt:t,language:e})).draft),G(!1)}catch(e){z(e instanceof Error?e.message:String(e))}finally{we(!1)}}}async function jt(){if(!Se)return;let e=``;await Ot(`draft:publish`,async()=>{let{automation:t}=await R.create({...Se.automation,...T?{projectId:T}:{}});W(null),xe(``),G(!1),P(!1),j(`all`),ie(``),e=t.id})&&e&&H(e)}async function Mt(t){z(null),ke(!0),De(null),K(!1);try{De((await R.repairDraft(t.id,{language:e})).repair)}catch(e){z(e instanceof Error?e.message:String(e))}finally{ke(!1)}}async function Ft(e){Ee&&await Ot(`run:${e.id}:repair`,async()=>{await R.update(e.automationId,Ee.patch),De(null),K(!1)})}let It=(0,U.useMemo)(()=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(ne,{className:`size-9 shrink-0 p-0`,loading:q,label:n.refresh,onClick:Ct}),(0,Z.jsxs)(l,{variant:`secondary`,onClick:()=>y(e=>{let t=new URLSearchParams(e);return x?t.delete(`view`):t.set(`view`,`runs`),t}),children:[(0,Z.jsx)(te,{className:`size-4`}),x?n.dashboard.backToAutomations:n.dashboard.allRuns]}),(0,Z.jsxs)(l,{variant:`primary`,onClick:()=>gt(`draft`),children:[(0,Z.jsx)(ae,{className:`size-4`}),n.new]})]}),[n.dashboard.allRuns,n.dashboard.backToAutomations,n.new,n.refresh,gt,q,Ct,x,y]);return(0,U.useLayoutEffect)(()=>(a({startExtra:null,main:(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,Z.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.subtitle})]}),end:It}),()=>o()),[o,It,n.subtitle,n.title,a]),(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-4 px-3 py-5 sm:px-5 xl:px-6`,children:[pe?(0,Z.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:pe}):null,Le?(0,Z.jsx)(xt,{}):x?(0,Z.jsx)(kt,{runs:ze,labels:n,cronLabels:r,language:e,busyAction:Y,onSelectRun:Tt,onAction:Ot}):(0,Z.jsxs)(`section`,{className:`grid min-h-0 items-start gap-4 xl:grid-cols-[20rem_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`aside`,{className:`overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`border-b border-edge-subtle p-3`,children:[(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg-muted focus-within:border-accent`,children:[(0,Z.jsx)(k,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-subtle`,value:re,onChange:e=>ie(e.target.value),placeholder:n.filters.search})]}),(0,Z.jsx)(`nav`,{className:`mt-3 flex flex-wrap gap-1`,"aria-label":n.filters.status,children:[{id:`all`,label:n.filters.all},{id:`active`,label:n.filters.active},{id:`paused`,label:n.paused},{id:`attention`,label:n.dashboard.needsAttention,count:Ze},{id:`system`,label:n.system.title,count:Ve.length}].map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:c(`rounded-md px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,A===e.id&&`bg-surface-hover text-fg`),onClick:()=>j(e.id),children:[e.label,e.count?` ${e.count}`:``]},e.id))})]}),(0,Z.jsx)(Dt,{automations:et,runs:A===`system`?ze:Ue,labels:n,cronLabels:r,language:e,selectedAutomationId:_e,onOpenDetails:H})]}),Ge?(0,Z.jsx)(Pt,{automation:Ge,runs:Je,labels:n,cronLabels:r,language:e,busyAction:Y,onEdit:yt,onSelectRun:Tt,onAction:Ot}):(0,Z.jsx)(Ht,{icon:(0,Z.jsx)(w,{className:`size-5`}),title:n.empty.filtered})]})]}),(0,Z.jsx)(_,{open:oe,onOpenChange:e=>{P(e),e||(le(null),de(!1))},children:(0,Z.jsxs)(m,{children:[(0,Z.jsx)(f,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(h,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(760px,calc(100vh-2rem))] w-[min(100%-2rem,48rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,Z.jsx)(g,{className:`text-base font-semibold text-fg`,children:se===`draft`?n.draft.title:Ke?n.editTitle:ue?n.draft.editTitle:n.createTitle}),(0,Z.jsx)(p,{asChild:!0,children:(0,Z.jsx)(l,{variant:`ghost`,"aria-label":n.close,children:(0,Z.jsx)(N,{className:`size-4`})})})]}),se===`draft`?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,Z.jsx)(wt,{labels:n,prompt:ve,draft:Se,loading:Ce,approved:Te,publishBusy:Y===`draft:publish`,templates:ft,onPromptChange:xe,onGenerate:At,onEdit:St,onPublish:jt,onApprovedChange:G,onDiscard:()=>{W(null),G(!1)},onTemplateSelect:e=>{L(e),F(`blank`)},onOpenAdvanced:()=>{L(Xe),F(`blank`)}})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ut,{form:I,labels:n,setForm:L,workflowDefinitions:tt,selectedWorkflow:st,workflowsLoading:Pe.isLoading,browserWorkflows:nt,selectedBrowserWorkflow:ct,browserWorkflowsLoading:Fe.isLoading,agentOptions:rt,agentsLoading:Ie.isLoading,language:e}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[ue?(0,Z.jsx)(l,{variant:`ghost`,onClick:()=>{de(!1),F(`draft`)},children:n.cancel}):(0,Z.jsx)(p,{asChild:!0,children:(0,Z.jsx)(l,{variant:`ghost`,children:n.cancel})}),(0,Z.jsx)(l,{variant:`primary`,onClick:Et,disabled:!dt||Y===`draft:edit`||!!(Ke&&Y),children:Y===`draft:edit`||Ke&&Y===`automation:${Ke.id}:edit`?n.feedback.working:Ke||ue?n.save:n.create})]})]})]})]})}),(0,Z.jsx)(_,{open:V&&!!We,onOpenChange:e=>{he(e),!e&&y(e=>{let t=new URLSearchParams(e);return t.delete(`run`),t},{replace:!0})},children:(0,Z.jsxs)(m,{children:[(0,Z.jsx)(f,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(h,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(85vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,Z.jsx)(g,{className:`truncate text-base font-semibold text-fg`,children:We?.automationName??n.dashboard.result}),(0,Z.jsx)(p,{asChild:!0,children:(0,Z.jsx)(l,{variant:`ghost`,"aria-label":n.close,children:(0,Z.jsx)(N,{className:`size-4`})})})]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Z.jsx)(Nt,{className:`rounded-none border-0`,run:We,events:Ye,labels:n,cronLabels:r,language:e,loading:Ne.isLoading,repairDraft:Ee,repairLoading:Oe,repairApproved:Ae,busyAction:Y,onRepairApprovedChange:K,onSuggestRepair:Mt,onApplyRepair:Ft})})]})]})})]})}function wt(e){let t=(0,W.c)(58),{labels:n,prompt:r,draft:i,loading:a,approved:o,publishBusy:s,templates:c,onPromptChange:u,onGenerate:d,onEdit:f,onPublish:p,onApprovedChange:m,onDiscard:h,onTemplateSelect:g,onOpenAdvanced:_}=e,v=s===void 0?!1:s,y=!!(i&&i.simulation.requiredConfirmations.length>0),b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(re,{className:`size-4 text-accent`}),t[0]=b):b=t[0];let x;t[1]===n.draft.title?x=t[2]:(x=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[b,n.draft.title]}),t[1]=n.draft.title,t[2]=x);let S;t[3]===n.draft.subtitle?S=t[4]:(S=(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:n.draft.subtitle}),t[3]=n.draft.subtitle,t[4]=S);let C;t[5]!==x||t[6]!==S?(C=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[x,S]}),t[5]=x,t[6]=S,t[7]=C):C=t[7];let w;t[8]!==a||t[9]!==r?(w=a||!r.trim(),t[8]=a,t[9]=r,t[10]=w):w=t[10];let ee;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Z.jsx)(re,{className:`size-4`}),t[11]=ee):ee=t[11];let T=a?n.draft.generating:n.draft.generate,E;t[12]!==d||t[13]!==w||t[14]!==T?(E=(0,Z.jsxs)(l,{variant:`primary`,onClick:d,disabled:w,children:[ee,T]}),t[12]=d,t[13]=w,t[14]=T,t[15]=E):E=t[15];let D;t[16]!==C||t[17]!==E?(D=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[C,E]}),t[16]=C,t[17]=E,t[18]=D):D=t[18];let O;t[19]===u?O=t[20]:(O=e=>u(e.target.value),t[19]=u,t[20]=O);let k;t[21]!==n.draft.placeholder||t[22]!==r||t[23]!==O?(k=(0,Z.jsx)(`textarea`,{className:`mt-4 min-h-20 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,value:r,onChange:O,placeholder:n.draft.placeholder}),t[21]=n.draft.placeholder,t[22]=r,t[23]=O,t[24]=k):k=t[24];let A;t[25]!==i||t[26]!==n.draft.advancedCreate||t[27]!==n.draft.suggestions||t[28]!==n.draft.suggestionsDescription||t[29]!==_||t[30]!==g||t[31]!==c?(A=i?null:(0,Z.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.draft.suggestions}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:n.draft.suggestionsDescription})]}),(0,Z.jsx)(l,{variant:`ghost`,onClick:_,children:n.draft.advancedCreate})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:c.slice(0,4).map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-lg border border-edge-subtle bg-surface-panel p-3 text-left hover:bg-surface-hover`,onClick:()=>g(e.form),children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,Z.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:e.description})]},e.name))})]}),t[25]=i,t[26]=n.draft.advancedCreate,t[27]=n.draft.suggestions,t[28]=n.draft.suggestionsDescription,t[29]=_,t[30]=g,t[31]=c,t[32]=A):A=t[32];let te;t[33]!==o||t[34]!==i||t[35]!==n.draft.approval||t[36]!==n.draft.assumptions||t[37]!==n.draft.discard||t[38]!==n.draft.edit||t[39]!==n.draft.publish||t[40]!==n.draft.review||t[41]!==n.draft.risks||t[42]!==n.draft.safety||t[43]!==n.feedback||t[44]!==n.info||t[45]!==n.none||t[46]!==m||t[47]!==h||t[48]!==f||t[49]!==p||t[50]!==v||t[51]!==y?(te=i?(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg bg-surface-base p-4 lg:grid-cols-[1fr_1fr]`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:i.automation.name}),i.automation.description?(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:i.automation.description}):null,(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,Z.jsx)(Vt,{label:n.info.when,value:i.simulation.triggerSummary}),(0,Z.jsx)(Vt,{label:n.info.run,value:i.simulation.actionSummary})]})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:n.draft.review}),(0,Z.jsx)(Tt,{title:n.draft.safety,items:[...i.simulation.safetyNotes,...i.simulation.requiredConfirmations],empty:n.none}),(0,Z.jsx)(Tt,{title:n.draft.assumptions,items:i.assumptions,empty:n.none}),(0,Z.jsx)(Tt,{title:n.draft.risks,items:i.risks,empty:n.none}),y?(0,Z.jsxs)(`label`,{className:`mt-4 flex items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:o,onChange:e=>m(e.target.checked)}),(0,Z.jsx)(`span`,{children:n.draft.approval})]}):null,(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(l,{variant:`ghost`,onClick:h,children:n.draft.discard}),(0,Z.jsxs)(l,{variant:`secondary`,onClick:f,children:[(0,Z.jsx)(oe,{className:`size-4`}),n.draft.edit]}),(0,Z.jsx)(l,{variant:`primary`,onClick:p,disabled:v||y&&!o,children:v?n.feedback.working:n.draft.publish})]})]})]}):null,t[33]=o,t[34]=i,t[35]=n.draft.approval,t[36]=n.draft.assumptions,t[37]=n.draft.discard,t[38]=n.draft.edit,t[39]=n.draft.publish,t[40]=n.draft.review,t[41]=n.draft.risks,t[42]=n.draft.safety,t[43]=n.feedback,t[44]=n.info,t[45]=n.none,t[46]=m,t[47]=h,t[48]=f,t[49]=p,t[50]=v,t[51]=y,t[52]=te):te=t[52];let j;return t[53]!==D||t[54]!==k||t[55]!==A||t[56]!==te?(j=(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[D,k,A,te]}),t[53]=D,t[54]=k,t[55]=A,t[56]=te,t[57]=j):j=t[57],j}function Tt(e){let t=(0,W.c)(10),{title:n,items:r,empty:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o;t[2]!==i||t[3]!==r?(o=r.length>0?r.map(Et):(0,Z.jsx)(`li`,{className:`text-fg-muted`,children:i}),t[2]=i,t[3]=r,t[4]=o):o=t[4];let s;t[5]===o?s=t[6]:(s=(0,Z.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm text-fg`,children:o}),t[5]=o,t[6]=s);let c;return t[7]!==a||t[8]!==s?(c=(0,Z.jsxs)(`div`,{className:`mt-3`,children:[a,s]}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function Et(e){return(0,Z.jsxs)(`li`,{children:[`- `,e]},e)}function Dt(e){let t=(0,W.c)(20),{automations:n,runs:r,labels:i,cronLabels:a,language:o,selectedAutomationId:s,onOpenDetails:l}=e;if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(w,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===i.empty.filtered?n=t[2]:(n=(0,Z.jsx)(Ht,{icon:e,title:i.empty.filtered}),t[1]=i.empty.filtered,t[2]=n),n}let u;if(t[3]!==n||t[4]!==a||t[5]!==i||t[6]!==o||t[7]!==l||t[8]!==r||t[9]!==s){let e;t[11]!==a||t[12]!==i||t[13]!==o||t[14]!==l||t[15]!==r||t[16]!==s?(e=e=>{let t=r.filter(t=>t.automationId===e.id).sort(Ot),n=t.find(ft),u=t[0];return(0,Z.jsxs)(`button`,{type:`button`,className:c(`block w-full p-3 text-left outline-none hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,s===e.id&&`bg-surface-hover`),onClick:()=>l(e.id),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:c(`size-2 shrink-0 rounded-full`,n?`bg-blue-500`:mt(e,t)?`bg-red-500`:e.enabled?`bg-emerald-500`:`bg-fg-subtle`)}),(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.name})]}),(0,Z.jsx)(`div`,{className:`mt-1 truncate pl-4 text-xs text-fg-muted`,children:qe(e.trigger,i,a,o)}),(0,Z.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center justify-between gap-2 pl-4 text-xs text-fg-subtle`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:e.enabled?`${i.next}: ${st(e.state.nextRunAtMs,i,o)}`:i.paused}),u?.status?(0,Z.jsx)(`span`,{className:c(`shrink-0 rounded-full px-1.5 py-0.5`,ut(u.status)),children:i.status[u.status]}):null]})]},e.id)},t[11]=a,t[12]=i,t[13]=o,t[14]=l,t[15]=r,t[16]=s,t[17]=e):e=t[17],u=n.map(e),t[3]=n,t[4]=a,t[5]=i,t[6]=o,t[7]=l,t[8]=r,t[9]=s,t[10]=u}else u=t[10];let d;return t[18]===u?d=t[19]:(d=(0,Z.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:u}),t[18]=u,t[19]=d),d}function Ot(e,t){return t.createdAtMs-e.createdAtMs}function kt(e){let t=(0,W.c)(23),{runs:n,labels:r,cronLabels:i,language:a,busyAction:o,onSelectRun:s,onAction:u}=e,d;t[0]===r.dashboard.allRuns?d=t[1]:(d=(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.dashboard.allRuns}),t[0]=r.dashboard.allRuns,t[1]=d);let f;t[2]===r.dashboard.runCenterDescription?f=t[3]:(f=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.dashboard.runCenterDescription}),t[2]=r.dashboard.runCenterDescription,t[3]=f);let p;t[4]!==d||t[5]!==f?(p=(0,Z.jsxs)(`div`,{children:[d,f]}),t[4]=d,t[5]=f,t[6]=p):p=t[6];let m;t[7]===n.length?m=t[8]:(m=(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:n.length}),t[7]=n.length,t[8]=m);let h;t[9]!==p||t[10]!==m?(h=(0,Z.jsxs)(`header`,{className:`flex items-start justify-between gap-3 border-b border-edge-subtle px-4 py-3`,children:[p,m]}),t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==o||t[13]!==i||t[14]!==r||t[15]!==a||t[16]!==u||t[17]!==s||t[18]!==n?(g=n.length===0?(0,Z.jsx)(Ht,{icon:(0,Z.jsx)(te,{className:`size-5`}),title:r.empty.runs}):(0,Z.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:n.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 px-4 py-3 hover:bg-surface-hover`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left outline-none`,onClick:()=>s(e.id),children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.automationName}),(0,Z.jsx)(`span`,{className:c(`rounded-full px-2 py-0.5 text-xs`,ut(e.status)),children:r.status[e.status]}),(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:st(e.createdAtMs,r,a)})]}),(0,Z.jsx)(`p`,{className:c(`mt-1 line-clamp-2 text-sm text-fg-muted`,e.error&&`text-red-700 dark:text-red-300`),children:e.error||e.summary||(ft(e)?r.runDetail.resultPending:r.runDetail.noResult)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:e.manual?r.trigger.manual:qe(e.triggerSnapshot,r,i,a)})]}),ft(e)?(0,Z.jsx)(l,{variant:`ghost`,disabled:o!==null,onClick:()=>void u(`run:${e.id}:cancel`,()=>R.cancelRun(e.id),r.dashboard.cancelled),children:o===`run:${e.id}:cancel`?r.feedback.working:r.cancel}):null]},e.id))}),t[12]=o,t[13]=i,t[14]=r,t[15]=a,t[16]=u,t[17]=s,t[18]=n,t[19]=g):g=t[19];let _;return t[20]!==h||t[21]!==g?(_=(0,Z.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,children:[h,g]}),t[20]=h,t[21]=g,t[22]=_):_=t[22],_}function At(e,t){let n=t.events,r=e.data&&typeof e.data==`object`?e.data:{},i=typeof r.actionKind==`string`?r.actionKind:null,a=typeof r.status==`string`&&r.status in t.status?t.status[r.status]:null;switch(e.type){case`run.queued`:return e.message.toLowerCase().includes(`manual`)?n.manualQueued:e.message.toLowerCase().includes(`scheduled`)?n.scheduledQueued:n.eventQueued;case`run.started`:return n.runStarted;case`action.started`:return i?n.actionStarted.replace(`{kind}`,i):n.actionStartedFallback;case`action.completed`:return i?n.actionCompleted.replace(`{kind}`,i):n.actionCompletedFallback;case`action.failed`:return i?n.actionFailed.replace(`{kind}`,i):n.actionFailedFallback;case`after_run.started`:return n.afterRunStarted;case`after_run.completed`:return n.afterRunCompleted;case`after_run.failed`:return n.afterRunFailed;case`run.completed`:return a?n.runCompleted.replace(`{status}`,a):n.runCompletedFallback;default:return e.message}}function jt(e){let t=(0,W.c)(17),{value:n,labels:r,title:i,defaultExpanded:a}=e,[o,s]=(0,U.useState)(a===void 0?!1:a),l;t[0]===n?l=t[1]:(l=JSON.stringify(n,null,2),t[0]=n,t[1]=l);let u=l,d;t[2]===u?d=t[3]:(d=u.split(`
2
- `),t[2]=u,t[3]=d);let f=d.length,p=u.length>720||f>18,m;t[4]!==p||t[5]!==u?(m=p?`${u.split(`
3
- `).slice(0,10).join(`
4
- `).trimEnd()}...`:u,t[4]=p,t[5]=u,t[6]=m):m=t[6];let h=m,g;t[7]!==o||t[8]!==p||t[9]!==r||t[10]!==i?(g=p?(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-2.5 py-2 text-left text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>s(Mt),"aria-expanded":o,children:[(0,Z.jsx)(`span`,{children:i}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-accent-fg`,children:[o?r.details.hideDetails:r.details.showDetails,(0,Z.jsx)(y,{className:c(`size-3.5 transition-transform`,o&&`rotate-180`),"aria-hidden":!0})]})]}):(0,Z.jsx)(`div`,{className:`px-2.5 py-2 text-xs font-medium text-fg-muted`,children:i}),t[7]=o,t[8]=p,t[9]=r,t[10]=i,t[11]=g):g=t[11];let _=o||!p?u:h,v;t[12]===_?v=t[13]:(v=(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-all px-2.5 pb-2 text-xs leading-relaxed text-fg-muted`,children:_}),t[12]=_,t[13]=v);let b;return t[14]!==g||t[15]!==v?(b=(0,Z.jsxs)(`div`,{className:`mt-2 rounded-md border border-edge/70 bg-surface-muted/35`,children:[g,v]}),t[14]=g,t[15]=v,t[16]=b):b=t[16],b}function Mt(e){return!e}function Nt(e){let t=(0,W.c)(148),{className:n,run:r,events:i,labels:o,cronLabels:s,language:u,loading:d,repairDraft:f,repairLoading:p,repairApproved:m,busyAction:h,onRepairApprovedChange:g,onSuggestRepair:_,onApplyRepair:v}=e;if(!r){let e;t[0]===n?e=t[1]:(e=c(`flex min-h-64 flex-col justify-center rounded-lg border border-edge-subtle bg-surface-base px-4 text-center text-sm text-fg-muted shadow-surface`,n),t[0]=n,t[1]=e);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(te,{className:`mx-auto size-5`}),t[2]=r):r=t[2];let i;t[3]===o.selectRun?i=t[4]:(i=(0,Z.jsx)(`div`,{className:`mt-2`,children:o.selectRun}),t[3]=o.selectRun,t[4]=i);let a;return t[5]!==e||t[6]!==i?(a=(0,Z.jsxs)(`aside`,{className:e,children:[r,i]}),t[5]=e,t[6]=i,t[7]=a):a=t[7],a}let b=r.error||r.summary,S=r.sessionKey?`/chat/${encodeURIComponent(r.sessionKey)}`:r.workflowRunId?`/workflows?run=${encodeURIComponent(r.workflowRunId)}`:null,w=r.sessionKey?o.runDetail.openConversation:o.runDetail.openWorkflow,ee=r.sessionKey?se:C,T=ft(r)?te:pt(r)?x:ie,E;t[8]===n?E=t[9]:(E=c(`rounded-lg border border-edge-subtle bg-surface-base shadow-surface`,n),t[8]=n,t[9]=E);let D;t[10]===r.automationName?D=t[11]:(D=(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:r.automationName}),t[10]=r.automationName,t[11]=D);let k;t[12]===r.id?k=t[13]:(k=r.id.slice(0,8),t[12]=r.id,t[13]=k);let j;t[14]===k?j=t[15]:(j=(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:k}),t[14]=k,t[15]=j);let ne;t[16]!==D||t[17]!==j?(ne=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[D,j]}),t[16]=D,t[17]=j,t[18]=ne):ne=t[18];let M;t[19]===r.status?M=t[20]:(M=c(`shrink-0 rounded-full px-2 py-0.5 text-xs`,ut(r.status)),t[19]=r.status,t[20]=M);let ae=o.status[r.status],oe;t[21]!==M||t[22]!==ae?(oe=(0,Z.jsx)(`span`,{className:M,children:ae}),t[21]=M,t[22]=ae,t[23]=oe):oe=t[23];let N;t[24]!==ne||t[25]!==oe?(N=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[ne,oe]}),t[24]=ne,t[25]=oe,t[26]=N):N=t[26];let P;t[27]!==o||t[28]!==u||t[29]!==r.createdAtMs?(P=st(r.createdAtMs,o,u),t[27]=o,t[28]=u,t[29]=r.createdAtMs,t[30]=P):P=t[30];let F;t[31]===P?F=t[32]:(F=(0,Z.jsx)(`span`,{children:P}),t[31]=P,t[32]=F);let ce;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t[33]=ce):ce=t[33];let ue=o.details.duration,de;t[34]!==o||t[35]!==r.durationMs?(de=dt(r.durationMs,o),t[34]=o,t[35]=r.durationMs,t[36]=de):de=t[36];let I;t[37]!==o.details.duration||t[38]!==de?(I=(0,Z.jsxs)(`span`,{children:[ue,` `,de]}),t[37]=o.details.duration,t[38]=de,t[39]=I):I=t[39];let L;t[40]!==F||t[41]!==I?(L=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-muted`,children:[F,ce,I]}),t[40]=F,t[41]=I,t[42]=L):L=t[42];let R;t[43]!==o.repair||t[44]!==_||t[45]!==p||t[46]!==r?(R=r.status===`failed`||r.status===`timeout`||r.status===`cancelled`?(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsxs)(l,{variant:`secondary`,onClick:()=>_(r),disabled:p,children:[(0,Z.jsx)(re,{className:`size-4`}),p?o.repair.generating:o.repair.suggest]})}):null,t[43]=o.repair,t[44]=_,t[45]=p,t[46]=r,t[47]=R):R=t[47];let fe;t[48]!==L||t[49]!==R||t[50]!==N?(fe=(0,Z.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[N,L,R]}),t[48]=L,t[49]=R,t[50]=N,t[51]=fe):fe=t[51];let z;t[52]===r?z=t[53]:(z=ft(r)?`text-blue-500`:pt(r)?`text-red-500`:`text-emerald-500`,t[52]=r,t[53]=z);let B;t[54]===z?B=t[55]:(B=c(`size-4`,z),t[54]=z,t[55]=B);let me;t[56]!==T||t[57]!==B?(me=(0,Z.jsx)(T,{className:B}),t[56]=T,t[57]=B,t[58]=me):me=t[58];let V;t[59]!==o.runDetail.resultTitle||t[60]!==me?(V=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[me,o.runDetail.resultTitle]}),t[59]=o.runDetail.resultTitle,t[60]=me,t[61]=V):V=t[61];let he;t[62]!==ee||t[63]!==w||t[64]!==S?(he=S?(0,Z.jsx)(l,{asChild:!0,variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,children:(0,Z.jsxs)(a,{to:S,children:[(0,Z.jsx)(ee,{className:`size-3.5`}),w,(0,Z.jsx)(A,{className:`size-3.5`})]})}):null,t[62]=ee,t[63]=w,t[64]=S,t[65]=he):he=t[65];let ge;t[66]!==V||t[67]!==he?(ge=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[V,he]}),t[66]=V,t[67]=he,t[68]=ge):ge=t[68];let _e=r.error&&`border-red-500/25 bg-red-500/5`,H;t[69]===_e?H=t[70]:(H=c(`mt-3 max-h-80 overflow-y-auto rounded-lg border border-edge/70 bg-surface-muted/25 p-3`,_e),t[69]=_e,t[70]=H);let ve;t[71]!==o.runDetail.noResult||t[72]!==o.runDetail.resultPending||t[73]!==b||t[74]!==r?(ve=b?r.error?(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-red-700 dark:text-red-300`,children:b}):(0,Z.jsx)(pe,{content:b,compact:!0,className:`text-sm`,openHttpLinksInNewTab:!0}):(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:ft(r)?o.runDetail.resultPending:o.runDetail.noResult}),t[71]=o.runDetail.noResult,t[72]=o.runDetail.resultPending,t[73]=b,t[74]=r,t[75]=ve):ve=t[75];let ye;t[76]!==H||t[77]!==ve?(ye=(0,Z.jsx)(`div`,{className:H,children:ve}),t[76]=H,t[77]=ve,t[78]=ye):ye=t[78];let be;t[79]!==ge||t[80]!==ye?(be=(0,Z.jsxs)(`section`,{className:`border-b border-edge p-4`,children:[ge,ye]}),t[79]=ge,t[80]=ye,t[81]=be):be=t[81];let xe;t[82]===o.runDetail.runInfo?xe=t[83]:(xe=(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:o.runDetail.runInfo}),t[82]=o.runDetail.runInfo,t[83]=xe);let Se;t[84]!==s||t[85]!==o||t[86]!==u||t[87]!==r.manual||t[88]!==r.triggerSnapshot?(Se=r.manual?o.trigger.manual:qe(r.triggerSnapshot,o,s,u),t[84]=s,t[85]=o,t[86]=u,t[87]=r.manual,t[88]=r.triggerSnapshot,t[89]=Se):Se=t[89];let U;t[90]!==o.explain.whyRan||t[91]!==Se?(U=(0,Z.jsx)(zt,{label:o.explain.whyRan,value:Se}),t[90]=o.explain.whyRan,t[91]=Se,t[92]=U):U=t[92];let Ce=o.details.started,we;t[93]!==o||t[94]!==u||t[95]!==r.startedAtMs?(we=st(r.startedAtMs,o,u),t[93]=o,t[94]=u,t[95]=r.startedAtMs,t[96]=we):we=t[96];let Te;t[97]!==o.details.started||t[98]!==we?(Te=(0,Z.jsx)(zt,{label:Ce,value:we}),t[97]=o.details.started,t[98]=we,t[99]=Te):Te=t[99];let G;t[100]!==o.details.model||t[101]!==r.model?(G=r.model?(0,Z.jsx)(zt,{label:o.details.model,value:r.model}):null,t[100]=o.details.model,t[101]=r.model,t[102]=G):G=t[102];let Ee;t[103]!==U||t[104]!==Te||t[105]!==G?(Ee=(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs text-fg-muted`,children:[U,Te,G]}),t[103]=U,t[104]=Te,t[105]=G,t[106]=Ee):Ee=t[106];let De;t[107]!==xe||t[108]!==Ee?(De=(0,Z.jsxs)(`section`,{className:`border-b border-edge p-4`,children:[xe,Ee]}),t[107]=xe,t[108]=Ee,t[109]=De):De=t[109];let Oe;t[110]!==h||t[111]!==o||t[112]!==v||t[113]!==g||t[114]!==m||t[115]!==f||t[116]!==r?(Oe=f?(0,Z.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:o.repair.title}),(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:f.explanation}),f.expectedEffect?(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:f.expectedEffect}):null,(0,Z.jsx)(Tt,{title:o.repair.risks,items:f.risks,empty:o.none}),(0,Z.jsx)(jt,{value:f.patch,labels:o,title:o.details.repairPatch}),f.requiresApproval?(0,Z.jsxs)(`label`,{className:`mt-3 flex items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:m,onChange:e=>g(e.target.checked)}),(0,Z.jsx)(`span`,{children:o.repair.approval})]}):null,(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsx)(l,{variant:`primary`,onClick:()=>v(r),disabled:h===`run:${r.id}:repair`||f.requiresApproval&&!m,children:h===`run:${r.id}:repair`?o.feedback.working:o.repair.apply})})]}):null,t[110]=h,t[111]=o,t[112]=v,t[113]=g,t[114]=m,t[115]=f,t[116]=r,t[117]=Oe):Oe=t[117];let ke;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,Z.jsx)(le,{className:`size-4 shrink-0`}),t[118]=ke):ke=t[118];let Ae;t[119]===o.runDetail.technicalEvents?Ae=t[120]:(Ae=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-sm font-medium text-fg-muted`,children:[ke,o.runDetail.technicalEvents]}),t[119]=o.runDetail.technicalEvents,t[120]=Ae);let K;t[121]!==i.length||t[122]!==o.runDetail.eventCount?(K=o.runDetail.eventCount.replace(`{count}`,String(i.length)),t[121]=i.length,t[122]=o.runDetail.eventCount,t[123]=K):K=t[123];let q;t[124]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,Z.jsx)(y,{className:`size-4 transition-transform group-open:rotate-180`}),t[124]=q):q=t[124];let J;t[125]===K?J=t[126]:(J=(0,Z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[K,q]}),t[125]=K,t[126]=J);let Y;t[127]!==Ae||t[128]!==J?(Y=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 rounded-md outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,children:[Ae,J]}),t[127]=Ae,t[128]=J,t[129]=Y):Y=t[129];let X;t[130]===o.runDetail.technicalEventsDescription?X=t[131]:(X=(0,Z.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:o.runDetail.technicalEventsDescription}),t[130]=o.runDetail.technicalEventsDescription,t[131]=X);let je;t[132]!==i||t[133]!==o||t[134]!==u||t[135]!==d?(je=(0,Z.jsx)(`div`,{className:`mt-4`,children:d?(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-label":o.loading,children:[(0,Z.jsx)(O,{className:`h-10 w-full`}),(0,Z.jsx)(O,{className:`h-10 w-4/5`}),(0,Z.jsx)(O,{className:`h-10 w-11/12`})]}):i.length===0?(0,Z.jsx)(`div`,{className:`text-sm text-fg-muted`,children:o.empty.events}):(0,Z.jsx)(`ol`,{className:`space-y-3`,children:i.map(e=>(0,Z.jsxs)(`li`,{className:`grid grid-cols-[0.75rem_1fr] gap-3`,children:[(0,Z.jsx)(`span`,{className:c(`mt-1 size-2 rounded-full`,Bt(e.type))}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm text-fg`,children:At(e,o)}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:[st(e.createdAtMs,o,u),` · `,e.type]}),e.data&&typeof e.data==`object`?(0,Z.jsxs)(`details`,{className:`group/event mt-2 rounded-md border border-edge/70 bg-surface-muted/35`,children:[(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 px-2.5 py-2 text-xs font-medium text-fg-muted outline-none hover:text-fg`,children:[o.details.eventData,(0,Z.jsx)(y,{className:`size-3.5 transition-transform group-open/event:rotate-180`})]}),(0,Z.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre-wrap break-all border-t border-edge/70 px-2.5 py-2 text-xs leading-relaxed text-fg-muted`,children:JSON.stringify(e.data,null,2)})]}):null]})]},e.id))})}),t[132]=i,t[133]=o,t[134]=u,t[135]=d,t[136]=je):je=t[136];let Me;t[137]!==Y||t[138]!==X||t[139]!==je?(Me=(0,Z.jsxs)(`details`,{className:`group px-4 py-3`,children:[Y,X,je]}),t[137]=Y,t[138]=X,t[139]=je,t[140]=Me):Me=t[140];let Ne;return t[141]!==E||t[142]!==fe||t[143]!==be||t[144]!==De||t[145]!==Oe||t[146]!==Me?(Ne=(0,Z.jsxs)(`aside`,{className:E,children:[fe,be,De,Oe,Me]}),t[141]=E,t[142]=fe,t[143]=be,t[144]=De,t[145]=Oe,t[146]=Me,t[147]=Ne):Ne=t[147],Ne}function Pt(e){let t=(0,W.c)(82),{automation:n,runs:r,labels:i,cronLabels:a,language:o,busyAction:s,onEdit:u,onSelectRun:d,onAction:f}=e,p=s===`automation:${n.id}:run`,m=s===`automation:${n.id}:toggle`,h=s===`automation:${n.id}:delete`,g;t[0]===n?g=t[1]:(g=_t(n),t[0]=n,t[1]=g);let _=g,v;t[2]===n.name?v=t[3]:(v=(0,Z.jsx)(`h2`,{className:`truncate text-lg font-semibold text-fg`,children:n.name}),t[2]=n.name,t[3]=v);let y=n.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`,b;t[4]===y?b=t[5]:(b=c(`shrink-0 rounded-full px-2 py-0.5 text-xs`,y),t[4]=y,t[5]=b);let x=n.enabled?i.enabled:i.paused,S;t[6]!==b||t[7]!==x?(S=(0,Z.jsx)(`span`,{className:b,children:x}),t[6]=b,t[7]=x,t[8]=S):S=t[8];let C;t[9]!==v||t[10]!==S?(C=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[v,S]}),t[9]=v,t[10]=S,t[11]=C):C=t[11];let w;t[12]===n?w=t[13]:(w=vt(n)?(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:vt(n)}):null,t[12]=n,t[13]=w);let E;t[14]!==C||t[15]!==w?(E=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[C,w]}),t[14]=C,t[15]=w,t[16]=E):E=t[16];let D;t[17]!==n||t[18]!==s||t[19]!==h||t[20]!==i.dashboard.delete||t[21]!==i.dashboard.deleted||t[22]!==i.dashboard.pause||t[23]!==i.dashboard.resume||t[24]!==i.dashboard.resumed||t[25]!==i.dashboard.runNow||t[26]!==i.details||t[27]!==i.edit||t[28]!==i.feedback||t[29]!==f||t[30]!==u||t[31]!==_||t[32]!==p||t[33]!==m?(D=_?null:(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsxs)(l,{variant:`secondary`,disabled:s!==null,onClick:()=>void f(`automation:${n.id}:toggle`,()=>n.enabled?R.pause(n.id):R.resume(n.id),n.enabled?i.feedback.paused:i.dashboard.resumed),children:[m?(0,Z.jsx)(T,{className:`size-4 animate-spin`}):n.enabled?(0,Z.jsx)(j,{className:`size-4`}):(0,Z.jsx)(ee,{className:`size-4`}),n.enabled?i.dashboard.pause:i.dashboard.resume]}),(0,Z.jsxs)(l,{variant:`primary`,disabled:s!==null,onClick:()=>void f(`automation:${n.id}:run`,()=>R.runNow(n.id),i.feedback.rerunQueued),children:[p?(0,Z.jsx)(T,{className:`size-4 animate-spin`}):(0,Z.jsx)(ee,{className:`size-4`}),i.dashboard.runNow]}),(0,Z.jsxs)(de,{children:[(0,Z.jsx)(ce,{asChild:!0,children:(0,Z.jsx)(l,{variant:`ghost`,className:`size-9 p-0`,"aria-label":i.details.moreActions,children:(0,Z.jsx)(I,{className:`size-4`})})}),(0,Z.jsx)(L,{children:(0,Z.jsxs)(P,{align:`end`,className:`z-70 min-w-40 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[(0,Z.jsxs)(F,{className:`flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>u(n),children:[(0,Z.jsx)(oe,{className:`size-4`}),i.edit]}),(0,Z.jsxs)(F,{className:`flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm text-red-700 outline-none hover:bg-red-500/10 dark:text-red-300`,disabled:s!==null,onSelect:()=>void f(`automation:${n.id}:delete`,()=>R.remove(n.id),i.dashboard.deleted),children:[h?(0,Z.jsx)(T,{className:`size-4 animate-spin`}):(0,Z.jsx)(ue,{className:`size-4`}),i.dashboard.delete]})]})})]})]}),t[17]=n,t[18]=s,t[19]=h,t[20]=i.dashboard.delete,t[21]=i.dashboard.deleted,t[22]=i.dashboard.pause,t[23]=i.dashboard.resume,t[24]=i.dashboard.resumed,t[25]=i.dashboard.runNow,t[26]=i.details,t[27]=i.edit,t[28]=i.feedback,t[29]=f,t[30]=u,t[31]=_,t[32]=p,t[33]=m,t[34]=D):D=t[34];let O;t[35]!==D||t[36]!==E?(O=(0,Z.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[E,D]}),t[35]=D,t[36]=E,t[37]=O):O=t[37];let k;t[38]===i.info.task?k=t[39]:(k=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.info.task}),t[38]=i.info.task,t[39]=k);let A;t[40]!==n||t[41]!==i?(A=ht(n,i),t[40]=n,t[41]=i,t[42]=A):A=t[42];let ne;t[43]===A?ne=t[44]:(ne=(0,Z.jsx)(`div`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base p-4`,children:(0,Z.jsx)(pe,{content:A,compact:!0,openHttpLinksInNewTab:!0})}),t[43]=A,t[44]=ne);let re;t[45]!==k||t[46]!==ne?(re=(0,Z.jsxs)(`section`,{children:[k,ne]}),t[45]=k,t[46]=ne,t[47]=re):re=t[47];let M;t[48]!==n||t[49]!==a||t[50]!==i||t[51]!==o?(M=(0,Z.jsx)(It,{automation:n,labels:i,cronLabels:a,language:o}),t[48]=n,t[49]=a,t[50]=i,t[51]=o,t[52]=M):M=t[52];let ae;t[53]===i.dashboard.runHistory?ae=t[54]:(ae=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.dashboard.runHistory}),t[53]=i.dashboard.runHistory,t[54]=ae);let N;t[55]===i.dashboard.runHistoryDescription?N=t[56]:(N=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.dashboard.runHistoryDescription}),t[55]=i.dashboard.runHistoryDescription,t[56]=N);let se;t[57]!==ae||t[58]!==N?(se=(0,Z.jsxs)(`div`,{children:[ae,N]}),t[57]=ae,t[58]=N,t[59]=se):se=t[59];let le;t[60]===r.length?le=t[61]:(le=(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-base px-2.5 py-1 text-xs text-fg-muted`,children:r.length}),t[60]=r.length,t[61]=le);let fe;t[62]!==se||t[63]!==le?(fe=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[se,le]}),t[62]=se,t[63]=le,t[64]=fe):fe=t[64];let z;t[65]!==i||t[66]!==o||t[67]!==d||t[68]!==r?(z=r.length===0?(0,Z.jsx)(Ht,{icon:(0,Z.jsx)(te,{className:`size-5`}),title:i.empty.runs}):(0,Z.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:r.slice(0,8).map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`block w-full p-3 text-left hover:bg-surface-hover`,onClick:()=>d(e.id),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e.status===`succeeded`?(0,Z.jsx)(ie,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-300`}):(0,Z.jsx)(te,{className:`size-4 shrink-0 text-fg-muted`}),(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:st(e.createdAtMs,i,o)})]}),(0,Z.jsx)(`span`,{className:c(`shrink-0 rounded-full px-2 py-0.5 text-xs`,ut(e.status)),children:i.status[e.status]})]}),(0,Z.jsx)(`p`,{className:c(`mt-1 line-clamp-2 pl-6 text-sm text-fg-muted`,e.error&&`text-red-700 dark:text-red-300`),children:e.error||e.summary||ct(e.actionSnapshot,i)})]},e.id))}),t[65]=i,t[66]=o,t[67]=d,t[68]=r,t[69]=z):z=t[69];let B;t[70]!==fe||t[71]!==z?(B=(0,Z.jsxs)(`section`,{className:`min-w-0`,children:[fe,z]}),t[70]=fe,t[71]=z,t[72]=B):B=t[72];let me;t[73]!==M||t[74]!==B?(me=(0,Z.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[20rem_minmax(0,1fr)]`,children:[M,B]}),t[73]=M,t[74]=B,t[75]=me):me=t[75];let V;t[76]!==re||t[77]!==me?(V=(0,Z.jsxs)(`div`,{className:`grid gap-5 p-5`,children:[re,me]}),t[76]=re,t[77]=me,t[78]=V):V=t[78];let he;return t[79]!==O||t[80]!==V?(he=(0,Z.jsxs)(`article`,{className:`min-w-0 overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel shadow-surface`,children:[O,V]}),t[79]=O,t[80]=V,t[81]=he):he=t[81],he}function Ft(e,t){return e===`suggest_only`?t.safety.suggestOnlyDescription:e===`ask_before_apply`?t.safety.askBeforeApplyDescription:t.safety.autoApplyDescription}function It(e){let t=(0,W.c)(127),{automation:n,labels:r,cronLabels:i,language:a}=e,o,s,c,l,u,d,f,p,m,h,g;if(t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a){let e=lt(n),_;t[15]!==n||t[16]!==r||t[17]!==a?(_=Je(n,r,a),t[15]=n,t[16]=r,t[17]=a,t[18]=_):_=t[18];let v=_,y;t[19]!==n.state.nextRunAtMs||t[20]!==a?(y=n.state.nextRunAtMs?Ue(n.state.nextRunAtMs,a):void 0,t[19]=n.state.nextRunAtMs,t[20]=a,t[21]=y):y=t[21];let b=y;if(t[22]!==n.trigger.eventType||t[23]!==n.trigger.kind||t[24]!==n.trigger.schedule||t[25]!==n.trigger.secretId||t[26]!==n.trigger.source||t[27]!==r.info.anchor||t[28]!==r.info.calendarSchedule||t[29]!==r.info.eventSource||t[30]!==r.info.eventType||t[31]!==r.info.expression||t[32]!==r.info.fixedInterval||t[33]!==r.info.oneTimeSchedule||t[34]!==r.info.rawInterval||t[35]!==r.info.scheduleType||t[36]!==r.info.timezone||t[37]!==r.info.webhookSecret||t[38]!==a){if(g=[],n.trigger.kind===`schedule`){let e=n.trigger.schedule,i=e.kind===`interval`?r.info.fixedInterval:e.kind===`cron`?r.info.calendarSchedule:r.info.oneTimeSchedule,o;if(t[40]!==r.info.scheduleType||t[41]!==i?(o={label:r.info.scheduleType,value:i},t[40]=r.info.scheduleType,t[41]=i,t[42]=o):o=t[42],g.push(o),e.kind===`interval`){let n=`${e.everyMs} ms`,i;if(t[43]!==r.info.rawInterval||t[44]!==n?(i={label:r.info.rawInterval,value:n},t[43]=r.info.rawInterval,t[44]=n,t[45]=i):i=t[45],g.push(i),e.anchorMs){let n=r.info.anchor,i;t[46]!==a||t[47]!==e.anchorMs?(i=Ue(e.anchorMs,a),t[46]=a,t[47]=e.anchorMs,t[48]=i):i=t[48];let o;t[49]!==r.info.anchor||t[50]!==i?(o={label:n,value:i},t[49]=r.info.anchor,t[50]=i,t[51]=o):o=t[51],g.push(o)}}else if(e.kind===`cron`){let n;if(t[52]!==r.info.expression||t[53]!==e.expr?(n={label:r.info.expression,value:e.expr},t[52]=r.info.expression,t[53]=e.expr,t[54]=n):n=t[54],g.push(n),e.tz){let n;t[55]!==r.info.timezone||t[56]!==e.tz?(n={label:r.info.timezone,value:e.tz},t[55]=r.info.timezone,t[56]=e.tz,t[57]=n):n=t[57],g.push(n)}}else{let n;t[58]!==r.info.oneTimeSchedule||t[59]!==e.at?(n={label:r.info.oneTimeSchedule,value:e.at},t[58]=r.info.oneTimeSchedule,t[59]=e.at,t[60]=n):n=t[60],g.push(n)}}else if(n.trigger.kind===`event`){let e;if(t[61]!==n.trigger.eventType||t[62]!==r.info.eventType?(e={label:r.info.eventType,value:n.trigger.eventType},t[61]=n.trigger.eventType,t[62]=r.info.eventType,t[63]=e):e=t[63],g.push(e),n.trigger.source){let e;t[64]!==n.trigger.source||t[65]!==r.info.eventSource?(e={label:r.info.eventSource,value:n.trigger.source},t[64]=n.trigger.source,t[65]=r.info.eventSource,t[66]=e):e=t[66],g.push(e)}}else if(n.trigger.kind===`webhook`&&n.trigger.secretId){let e;t[67]!==n.trigger.secretId||t[68]!==r.info.webhookSecret?(e={label:r.info.webhookSecret,value:n.trigger.secretId},t[67]=n.trigger.secretId,t[68]=r.info.webhookSecret,t[69]=e):e=t[69],g.push(e)}t[22]=n.trigger.eventType,t[23]=n.trigger.kind,t[24]=n.trigger.schedule,t[25]=n.trigger.secretId,t[26]=n.trigger.source,t[27]=r.info.anchor,t[28]=r.info.calendarSchedule,t[29]=r.info.eventSource,t[30]=r.info.eventType,t[31]=r.info.expression,t[32]=r.info.fixedInterval,t[33]=r.info.oneTimeSchedule,t[34]=r.info.rawInterval,t[35]=r.info.scheduleType,t[36]=r.info.timezone,t[37]=r.info.webhookSecret,t[38]=a,t[39]=g}else g=t[39];m=`h-fit overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,t[70]===r.info.overview?h=t[71]:(h=(0,Z.jsx)(`div`,{className:`border-b border-edge-subtle px-4 py-3`,children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.info.overview})}),t[70]=r.info.overview,t[71]=h),d=`grid gap-4 p-4`;let x;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(D,{className:`size-4`,"aria-hidden":!0}),t[72]=x):x=t[72];let ee=r.info.schedule,T;t[73]!==n.trigger||t[74]!==i||t[75]!==r||t[76]!==a?(T=qe(n.trigger,r,i,a),t[73]=n.trigger,t[74]=i,t[75]=r,t[76]=a,t[77]=T):T=t[77];let E=n.enabled?`${r.info.nextRun}:${v}`:v;t[78]!==r.info.schedule||t[79]!==b||t[80]!==T||t[81]!==E?(f=(0,Z.jsx)(Rt,{icon:x,label:ee,value:T,description:E,descriptionTitle:b}),t[78]=r.info.schedule,t[79]=b,t[80]=T,t[81]=E,t[82]=f):f=t[82];let O;t[83]===n.action.kind?O=t[84]:(O=n.action.kind===`workflow`?(0,Z.jsx)(C,{className:`size-4`,"aria-hidden":!0}):n.action.kind===`browser_recipe`?(0,Z.jsx)(le,{className:`size-4`,"aria-hidden":!0}):(0,Z.jsx)(w,{className:`size-4`,"aria-hidden":!0}),t[83]=n.action.kind,t[84]=O);let k=r.info.action,A;t[85]!==n.action||t[86]!==r?(A=ct(n.action,r),t[85]=n.action,t[86]=r,t[87]=A):A=t[87],t[88]!==r.info.action||t[89]!==O||t[90]!==A?(p=(0,Z.jsx)(Rt,{icon:O,label:k,value:A}),t[88]=r.info.action,t[89]=O,t[90]=A,t[91]=p):p=t[91],o=Rt,t[92]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(S,{className:`size-4`,"aria-hidden":!0}),t[92]=s):s=t[92],c=r.info.permission,l=r.safety[e],u=Ft(e,r),t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g}else o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14];let _;t[93]!==o||t[94]!==s||t[95]!==c||t[96]!==l||t[97]!==u?(_=(0,Z.jsx)(o,{icon:s,label:c,value:l,description:u}),t[93]=o,t[94]=s,t[95]=c,t[96]=l,t[97]=u,t[98]=_):_=t[98];let v;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[99]=v):v=t[99];let b=r.info.lastRun,x;t[100]!==n||t[101]!==r||t[102]!==a?(x=Ye(n,r,a),t[100]=n,t[101]=r,t[102]=a,t[103]=x):x=t[103];let ee=n.state.lastRunStatus===`failed`||n.state.lastRunStatus===`timeout`?`danger`:`default`,T;t[104]!==r.info.lastRun||t[105]!==x||t[106]!==ee?(T=(0,Z.jsx)(Rt,{icon:v,label:b,value:x,valueTone:ee}),t[104]=r.info.lastRun,t[105]=x,t[106]=ee,t[107]=T):T=t[107];let E;t[108]!==n.state.consecutiveFailures||t[109]!==n.state.lastError||t[110]!==r.dashboard?(E=n.state.consecutiveFailures?(0,Z.jsxs)(`div`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:[r.dashboard.failures,`:`,n.state.consecutiveFailures,n.state.lastError?(0,Z.jsx)(`p`,{className:`mt-1 break-words text-xs`,children:n.state.lastError}):null]}):n.state.lastError?(0,Z.jsx)(`p`,{className:`break-words text-sm text-red-700 dark:text-red-300`,children:n.state.lastError}):null,t[108]=n.state.consecutiveFailures,t[109]=n.state.lastError,t[110]=r.dashboard,t[111]=E):E=t[111];let O;t[112]!==r.info.technicalDetails||t[113]!==g?(O=g.length>0?(0,Z.jsxs)(`details`,{className:`group border-t border-edge-subtle pt-3`,children:[(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 text-sm text-fg-muted outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Z.jsx)(`span`,{children:r.info.technicalDetails}),(0,Z.jsx)(y,{className:`size-4 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:g.map(Lt)})]}):null,t[112]=r.info.technicalDetails,t[113]=g,t[114]=O):O=t[114];let k;t[115]!==_||t[116]!==T||t[117]!==E||t[118]!==O||t[119]!==d||t[120]!==f||t[121]!==p?(k=(0,Z.jsxs)(`div`,{className:d,children:[f,p,_,T,E,O]}),t[115]=_,t[116]=T,t[117]=E,t[118]=O,t[119]=d,t[120]=f,t[121]=p,t[122]=k):k=t[122];let A;return t[123]!==k||t[124]!==m||t[125]!==h?(A=(0,Z.jsxs)(`aside`,{className:m,children:[h,k]}),t[123]=k,t[124]=m,t[125]=h,t[126]=A):A=t[126],A}function Lt(e){return(0,Z.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.label}),(0,Z.jsx)(`span`,{className:`break-all font-mono text-xs text-fg-muted`,children:e.value})]},`${e.label}:${e.value}`)}function Rt(e){let t=(0,W.c)(19),{icon:n,label:r,value:i,description:a,descriptionTitle:o,valueTone:s}=e,l=s===void 0?`default`:s,u;t[0]===n?u=t[1]:(u=(0,Z.jsx)(`span`,{className:`mt-0.5 text-fg-subtle`,children:n}),t[0]=n,t[1]=u);let d;t[2]===r?d=t[3]:(d=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r}),t[2]=r,t[3]=d);let f=l===`danger`?`text-red-700 dark:text-red-300`:`text-fg`,p;t[4]===f?p=t[5]:(p=c(`mt-1 text-sm font-medium leading-5`,f),t[4]=f,t[5]=p);let m;t[6]!==p||t[7]!==i?(m=(0,Z.jsx)(`div`,{className:p,children:i}),t[6]=p,t[7]=i,t[8]=m):m=t[8];let h;t[9]!==a||t[10]!==o?(h=a?(0,Z.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,title:o,children:a}):null,t[9]=a,t[10]=o,t[11]=h):h=t[11];let g;t[12]!==d||t[13]!==m||t[14]!==h?(g=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[d,m,h]}),t[12]=d,t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;return t[16]!==u||t[17]!==g?(_=(0,Z.jsxs)(`div`,{className:`grid grid-cols-[1.25rem_1fr] gap-2.5`,children:[u,g]}),t[16]=u,t[17]=g,t[18]=_):_=t[18],_}function zt(e){let t=(0,W.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`span`,{children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Z.jsxs)(`div`,{className:`grid grid-cols-[5rem_1fr] gap-2`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Bt(e){return e.endsWith(`.failed`)?`bg-red-500`:e.endsWith(`.completed`)?`bg-emerald-500`:e.endsWith(`.started`)?`bg-blue-500`:`bg-fg-muted`}function Vt(e){let t=(0,W.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`div`,{className:`text-xs font-medium uppercase text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Z.jsx)(`div`,{className:`mt-1 truncate text-sm text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Ht(e){let t=(0,W.c)(5),{icon:n,title:r}=e,i;t[0]===r?i=t[1]:(i=(0,Z.jsx)(`div`,{className:`mt-2 text-sm`,children:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,Z.jsxs)(`div`,{className:`flex min-h-48 flex-col items-center justify-center rounded-lg border border-edge-subtle bg-surface-base text-fg-muted shadow-surface`,children:[n,i]}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function Ut(e){let t=(0,W.c)(250),{form:n,labels:r,setForm:i,workflowDefinitions:a,selectedWorkflow:l,workflowsLoading:d,browserWorkflows:f,selectedBrowserWorkflow:p,browserWorkflowsLoading:m,agentOptions:h,agentsLoading:g,language:_}=e,v=u(_).agentsSettings,x;t[0]===i?x=t[1]:(x=e=>i(t=>({...t,...e})),t[0]=i,t[1]=x);let S=x,C=ze(n.intervalValue,n.intervalUnit),w=Date.now(),ee;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(ee=[1,2,3],t[2]=ee):ee=t[2];let T;t[3]!==C||t[4]!==w||t[5]!==_?(T=ee.map(e=>Ge(w+C*e,_,w)),t[3]=C,t[4]=w,t[5]=_,t[6]=T):T=t[6];let E=T,D,O;t[7]!==n.actionMode||t[8]!==n.workflowId||t[9]!==i||t[10]!==a?(D=()=>{if(n.actionMode!==`workflow`||n.workflowId.trim())return;let e=a[0]?.id;e&&i(t=>({...t,workflowId:e,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}))},O=[n.actionMode,n.workflowId,i,a],t[7]=n.actionMode,t[8]=n.workflowId,t[9]=i,t[10]=a,t[11]=D,t[12]=O):(D=t[11],O=t[12]),(0,U.useEffect)(D,O);let k,A;t[13]!==f||t[14]!==n.actionMode||t[15]!==n.browserWorkflowId||t[16]!==i?(k=()=>{if(n.actionMode!==`browser_recipe`||n.browserWorkflowId.trim())return;let e=f[0];e&&i(t=>({...t,browserWorkflowId:e.id,browserWorkflowInputs:xe(e)}))},A=[f,n.actionMode,n.browserWorkflowId,i],t[13]=f,t[14]=n.actionMode,t[15]=n.browserWorkflowId,t[16]=i,t[17]=k,t[18]=A):(k=t[17],A=t[18]),(0,U.useEffect)(k,A);let te;t[19]===S?te=t[20]:(te=e=>S({name:e.target.value}),t[19]=S,t[20]=te);let j;t[21]!==n.name||t[22]!==te?(j=(0,Z.jsx)(`input`,{className:Q,value:n.name,onChange:te}),t[21]=n.name,t[22]=te,t[23]=j):j=t[23];let ne;t[24]!==r.form.name||t[25]!==j?(ne=(0,Z.jsx)($,{label:r.form.name,children:j}),t[24]=r.form.name,t[25]=j,t[26]=ne):ne=t[26];let re;t[27]===S?re=t[28]:(re=e=>S({description:e.target.value}),t[27]=S,t[28]=re);let ie;t[29]!==n.description||t[30]!==re?(ie=(0,Z.jsx)(`input`,{className:Q,value:n.description,onChange:re}),t[29]=n.description,t[30]=re,t[31]=ie):ie=t[31];let M;t[32]!==r.form.description||t[33]!==ie?(M=(0,Z.jsx)($,{label:r.form.description,children:ie}),t[32]=r.form.description,t[33]=ie,t[34]=M):M=t[34];let ae;t[35]===r.form.trigger?ae=t[36]:(ae=(0,Z.jsx)(Kt,{title:r.form.trigger}),t[35]=r.form.trigger,t[36]=ae);let oe;t[37]===S?oe=t[38]:(oe=e=>S({triggerMode:e.target.value}),t[37]=S,t[38]=oe);let N;t[39]===r.trigger.manual?N=t[40]:(N=(0,Z.jsx)(s,{value:`manual`,children:r.trigger.manual}),t[39]=r.trigger.manual,t[40]=N);let P;t[41]===r.trigger.once?P=t[42]:(P=(0,Z.jsx)(s,{value:`once`,children:r.trigger.once}),t[41]=r.trigger.once,t[42]=P);let se;t[43]===r.trigger.daily?se=t[44]:(se=(0,Z.jsx)(s,{value:`daily`,children:r.trigger.daily}),t[43]=r.trigger.daily,t[44]=se);let F;t[45]===r.trigger.weekly?F=t[46]:(F=(0,Z.jsx)(s,{value:`weekly`,children:r.trigger.weekly}),t[45]=r.trigger.weekly,t[46]=F);let ce;t[47]===r.trigger.interval?ce=t[48]:(ce=(0,Z.jsx)(s,{value:`interval`,children:r.trigger.interval}),t[47]=r.trigger.interval,t[48]=ce);let le;t[49]===r.trigger.customCron?le=t[50]:(le=(0,Z.jsx)(s,{value:`cron`,children:r.trigger.customCron}),t[49]=r.trigger.customCron,t[50]=le);let ue;t[51]===r.trigger.webhook?ue=t[52]:(ue=(0,Z.jsx)(s,{value:`webhook`,children:r.trigger.webhook}),t[51]=r.trigger.webhook,t[52]=ue);let de;t[53]===r.trigger.taskBlocked?de=t[54]:(de=(0,Z.jsx)(s,{value:`taskBlocked`,children:r.trigger.taskBlocked}),t[53]=r.trigger.taskBlocked,t[54]=de);let I;t[55]===r.trigger.noteCreated?I=t[56]:(I=(0,Z.jsx)(s,{value:`noteCreated`,children:r.trigger.noteCreated}),t[55]=r.trigger.noteCreated,t[56]=I);let L;t[57]===r.trigger.workflowFailed?L=t[58]:(L=(0,Z.jsx)(s,{value:`workflowFailed`,children:r.trigger.workflowFailed}),t[57]=r.trigger.workflowFailed,t[58]=L);let R;t[59]===r.trigger.sessionUpdated?R=t[60]:(R=(0,Z.jsx)(s,{value:`sessionUpdated`,children:r.trigger.sessionUpdated}),t[59]=r.trigger.sessionUpdated,t[60]=R);let fe;t[61]===r.trigger.customEvent?fe=t[62]:(fe=(0,Z.jsx)(s,{value:`event`,children:r.trigger.customEvent}),t[61]=r.trigger.customEvent,t[62]=fe);let pe;t[63]!==n.triggerMode||t[64]!==oe||t[65]!==N||t[66]!==P||t[67]!==se||t[68]!==F||t[69]!==ce||t[70]!==le||t[71]!==ue||t[72]!==de||t[73]!==I||t[74]!==L||t[75]!==R||t[76]!==fe?(pe=(0,Z.jsxs)(o,{className:Q,value:n.triggerMode,onChange:oe,children:[N,P,se,F,ce,le,ue,de,I,L,R,fe]}),t[63]=n.triggerMode,t[64]=oe,t[65]=N,t[66]=P,t[67]=se,t[68]=F,t[69]=ce,t[70]=le,t[71]=ue,t[72]=de,t[73]=I,t[74]=L,t[75]=R,t[76]=fe,t[77]=pe):pe=t[77];let z;t[78]!==n.onceAt||t[79]!==n.triggerMode||t[80]!==r.form.onceAt||t[81]!==S?(z=n.triggerMode===`once`?(0,Z.jsx)($,{label:r.form.onceAt,children:(0,Z.jsx)(`input`,{className:Q,type:`datetime-local`,value:n.onceAt,onChange:e=>S({onceAt:e.target.value})})}):null,t[78]=n.onceAt,t[79]=n.triggerMode,t[80]=r.form.onceAt,t[81]=S,t[82]=z):z=t[82];let B;t[83]!==n.time||t[84]!==n.triggerMode||t[85]!==n.weekday||t[86]!==r.form.day||t[87]!==r.form.time||t[88]!==r.weekdays||t[89]!==S?(B=n.triggerMode===`daily`||n.triggerMode===`weekly`?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsx)($,{label:r.form.time,children:(0,Z.jsx)(me,{value:n.time,onChange:e=>S({time:e}),ariaLabel:r.form.time})}),n.triggerMode===`weekly`?(0,Z.jsx)($,{label:r.form.day,children:(0,Z.jsxs)(o,{className:Q,value:n.weekday,onChange:e=>S({weekday:e.target.value}),children:[(0,Z.jsx)(s,{value:`1`,children:r.weekdays.monday}),(0,Z.jsx)(s,{value:`2`,children:r.weekdays.tuesday}),(0,Z.jsx)(s,{value:`3`,children:r.weekdays.wednesday}),(0,Z.jsx)(s,{value:`4`,children:r.weekdays.thursday}),(0,Z.jsx)(s,{value:`5`,children:r.weekdays.friday}),(0,Z.jsx)(s,{value:`6`,children:r.weekdays.saturday}),(0,Z.jsx)(s,{value:`0`,children:r.weekdays.sunday})]})}):null]}):null,t[83]=n.time,t[84]=n.triggerMode,t[85]=n.weekday,t[86]=r.form.day,t[87]=r.form.time,t[88]=r.weekdays,t[89]=S,t[90]=B):B=t[90];let V=n.triggerMode===`interval`?(0,Z.jsxs)(`div`,{className:`grid gap-3 rounded-lg border border-edge-subtle bg-surface-base p-3`,children:[(0,Z.jsx)($,{label:r.form.intervalEvery,children:(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,1fr)_10rem]`,children:[(0,Z.jsx)(`input`,{className:Q,type:`number`,min:6e4/ze(1,n.intervalUnit),step:`any`,inputMode:`decimal`,value:n.intervalValue,onChange:e=>S({intervalValue:e.target.value})}),(0,Z.jsxs)(o,{className:Q,value:n.intervalUnit,onChange:e=>{let t=e.target.value;S({intervalValue:Be(n.intervalValue,n.intervalUnit,t),intervalUnit:t})},children:[(0,Z.jsx)(s,{value:`minute`,children:r.form.intervalUnits.minute}),(0,Z.jsx)(s,{value:`hour`,children:r.form.intervalUnits.hour}),(0,Z.jsx)(s,{value:`day`,children:r.form.intervalUnits.day}),(0,Z.jsx)(s,{value:`week`,children:r.form.intervalUnits.week})]})]})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.form.commonIntervals}),(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:Ze.map(e=>{let t=ze(e.value,e.unit),n=t===C;return(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":n,className:c(`rounded-full border px-2.5 py-1 text-xs transition-colors`,n?`border-accent bg-accent/10 text-accent`:`border-edge-subtle text-fg-muted hover:border-edge hover:bg-surface-hover hover:text-fg`),onClick:()=>S({intervalValue:e.value,intervalUnit:e.unit}),children:Ve(t,_)},`${e.value}:${e.unit}`)})})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2.5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:He(C,_)}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:[r.form.nextThreeRuns,`:`,E.join(_===`zh`?`、`:`, `)]}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:r.form.fixedIntervalHint})]})]}):null,ge;t[91]!==n.cronExpr||t[92]!==n.triggerMode||t[93]!==r.form.expression||t[94]!==S?(ge=n.triggerMode===`cron`?(0,Z.jsx)($,{label:r.form.expression,children:(0,Z.jsx)(`input`,{className:Q,value:n.cronExpr,onChange:e=>S({cronExpr:e.target.value})})}):null,t[91]=n.cronExpr,t[92]=n.triggerMode,t[93]=r.form.expression,t[94]=S,t[95]=ge):ge=t[95];let _e;t[96]!==n.triggerMode||t[97]!==n.webhookSecretId||t[98]!==r.form.secretId||t[99]!==S?(_e=n.triggerMode===`webhook`?(0,Z.jsx)($,{label:r.form.secretId,children:(0,Z.jsx)(`input`,{className:Q,value:n.webhookSecretId,onChange:e=>S({webhookSecretId:e.target.value})})}):null,t[96]=n.triggerMode,t[97]=n.webhookSecretId,t[98]=r.form.secretId,t[99]=S,t[100]=_e):_e=t[100];let H;t[101]!==n.eventPayloadMatch||t[102]!==n.eventSource||t[103]!==n.eventType||t[104]!==n.triggerMode||t[105]!==r.form.eventPayloadMatch||t[106]!==r.form.eventSource||t[107]!==r.form.eventType||t[108]!==r.form.invalidJsonObject||t[109]!==S?(H=n.triggerMode===`event`?(0,Z.jsxs)(`div`,{className:`grid gap-3 rounded-lg border border-edge-subtle bg-surface-base p-3`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsx)($,{label:r.form.eventType,children:(0,Z.jsx)(`input`,{className:Q,value:n.eventType,onChange:e=>S({eventType:e.target.value})})}),(0,Z.jsx)($,{label:r.form.eventSource,children:(0,Z.jsx)(`input`,{className:Q,value:n.eventSource,onChange:e=>S({eventSource:e.target.value})})})]}),(0,Z.jsxs)($,{label:r.form.eventPayloadMatch,children:[(0,Z.jsx)(`textarea`,{className:c(Q,`min-h-24 resize-y font-mono text-xs`),value:n.eventPayloadMatch,onChange:e=>S({eventPayloadMatch:e.target.value}),placeholder:`{
5
- "status": "blocked"
6
- }`}),it(n.eventPayloadMatch)?null:(0,Z.jsx)(`span`,{className:`text-xs text-red-700 dark:text-red-300`,children:r.form.invalidJsonObject})]})]}):null,t[101]=n.eventPayloadMatch,t[102]=n.eventSource,t[103]=n.eventType,t[104]=n.triggerMode,t[105]=r.form.eventPayloadMatch,t[106]=r.form.eventSource,t[107]=r.form.eventType,t[108]=r.form.invalidJsonObject,t[109]=S,t[110]=H):H=t[110];let ye;t[111]===r.form.action?ye=t[112]:(ye=(0,Z.jsx)(Kt,{title:r.form.action}),t[111]=r.form.action,t[112]=ye);let be;t[113]!==n.timeoutSeconds||t[114]!==n.workflowId||t[115]!==S||t[116]!==a?(be=e=>{let t=e.target.value,r=Number.parseInt(n.timeoutSeconds,10);S({actionMode:t,...r===600||r===1800?{timeoutSeconds:t===`browser_recipe`?`600`:`1800`}:{},...t===`browser_recipe`?{safetyMode:`auto_apply`}:{},...t===`workflow`&&!n.workflowId.trim()&&a[0]?{workflowId:a[0].id,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}:{}})},t[113]=n.timeoutSeconds,t[114]=n.workflowId,t[115]=S,t[116]=a,t[117]=be):be=t[117];let Ce;t[118]===r.action.runAgent?Ce=t[119]:(Ce=(0,Z.jsx)(s,{value:`agent`,children:r.action.runAgent}),t[118]=r.action.runAgent,t[119]=Ce);let we;t[120]===r.action.runWorkflow?we=t[121]:(we=(0,Z.jsx)(s,{value:`workflow`,children:r.action.runWorkflow}),t[120]=r.action.runWorkflow,t[121]=we);let Te=_===`zh`?`浏览器自动化`:`Browser automation`,G;t[122]===Te?G=t[123]:(G=(0,Z.jsx)(s,{value:`browser_recipe`,children:Te}),t[122]=Te,t[123]=G);let Ee;t[124]!==n.actionMode||t[125]!==be||t[126]!==Ce||t[127]!==we||t[128]!==G?(Ee=(0,Z.jsxs)(o,{className:Q,value:n.actionMode,onChange:be,children:[Ce,we,G]}),t[124]=n.actionMode,t[125]=be,t[126]=Ce,t[127]=we,t[128]=G,t[129]=Ee):Ee=t[129];let De=n.actionMode===`browser_recipe`?null:(0,Z.jsx)($,{label:r.form.agent,children:(0,Z.jsxs)(o,{className:Q,value:n.agentId,onChange:e=>S({agentId:e.target.value}),children:[(0,Z.jsx)(s,{value:``,children:g?r.form.loadingAgents:r.form.defaultAgent}),h.map(e=>(0,Z.jsx)(s,{value:e.id,children:b(e,v)},e.id))]})}),Oe;t[130]!==f||t[131]!==m||t[132]!==n.actionMode||t[133]!==n.agentId||t[134]!==n.browserWorkflowId||t[135]!==n.browserWorkflowInputs||t[136]!==n.description||t[137]!==n.instruction||t[138]!==n.name||t[139]!==n.triggerMode||t[140]!==n.workflowId||t[141]!==n.workflowInput||t[142]!==r.form.instruction||t[143]!==r.form.loadingWorkflows||t[144]!==r.form.noWorkflows||t[145]!==r.form.triggeredRun||t[146]!==r.form.workflow||t[147]!==_||t[148]!==p||t[149]!==l||t[150]!==S||t[151]!==a||t[152]!==d?(Oe=n.actionMode===`agent`?(0,Z.jsxs)($,{label:r.form.instruction,children:[(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(he,{value:n.instruction,onApply:e=>S({instruction:e}),fieldId:`automation.instruction`,fieldLabel:r.form.instruction,scenario:`automation.instruction`,locale:_,context:{automationName:n.name,automationDescription:n.description,triggerMode:n.triggerMode,agentId:n.agentId},showLabel:!1})}),(0,Z.jsx)(`textarea`,{className:c(Q,`min-h-32 resize-y`),value:n.instruction,onChange:e=>S({instruction:e.target.value})})]}):n.actionMode===`workflow`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:r.form.workflow,children:(0,Z.jsxs)(o,{className:Q,value:n.workflowId,onChange:e=>S({workflowId:e.target.value,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}),disabled:d||a.length===0,children:[d?(0,Z.jsx)(s,{value:``,children:r.form.loadingWorkflows}):null,!d&&a.length===0?(0,Z.jsx)(s,{value:``,children:r.form.noWorkflows}):null,a.map(Gt)]})}),l?(0,Z.jsx)(ve,{definition:l,language:_,value:n.workflowInput,onChange:e=>S({workflowInput:e,workflowGoal:e.goal,workflowInputValid:!0}),mode:`automation`,badgeLabel:r.form.triggeredRun,onValidityChange:e=>S({workflowInputValid:e.valid}),aiAssist:{inputScenario:`automation.workflowInput`,goalScenario:`automation.workflowGoal`,context:{automationName:n.name,automationDescription:n.description,triggerMode:n.triggerMode,workflowId:l.id,workflowTitle:l.title,workflowDescription:l.description}},inputClassName:`rounded-lg`}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:_===`zh`?`浏览器自动化`:`Browser automation`,children:(0,Z.jsxs)(o,{className:Q,value:n.browserWorkflowId,onChange:e=>{let t=f.find(t=>t.id===e.target.value);S({browserWorkflowId:e.target.value,browserWorkflowInputs:t?xe(t):{}})},disabled:m||f.length===0,children:[f.length===0?(0,Z.jsx)(s,{value:``,children:_===`zh`?`没有已启用的浏览器自动化`:`No enabled browser automations`}):null,f.map(Wt)]})}),p&&Object.keys(p.inputs).length>0?(0,Z.jsx)($,{label:_===`zh`?`运行时填写`:`Run inputs`,children:(0,Z.jsx)(Se,{workflow:p,values:n.browserWorkflowInputs,language:_,onChange:e=>S({browserWorkflowInputs:e})})}):null]}),t[130]=f,t[131]=m,t[132]=n.actionMode,t[133]=n.agentId,t[134]=n.browserWorkflowId,t[135]=n.browserWorkflowInputs,t[136]=n.description,t[137]=n.instruction,t[138]=n.name,t[139]=n.triggerMode,t[140]=n.workflowId,t[141]=n.workflowInput,t[142]=r.form.instruction,t[143]=r.form.loadingWorkflows,t[144]=r.form.noWorkflows,t[145]=r.form.triggeredRun,t[146]=r.form.workflow,t[147]=_,t[148]=p,t[149]=l,t[150]=S,t[151]=a,t[152]=d,t[153]=Oe):Oe=t[153];let ke;t[154]===r.form.advancedDescription?ke=t[155]:(ke=(0,Z.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:r.form.advancedDescription}),t[154]=r.form.advancedDescription,t[155]=ke);let Ae;t[156]!==r.form.advanced||t[157]!==ke?(Ae=(0,Z.jsxs)(`span`,{children:[r.form.advanced,ke]}),t[156]=r.form.advanced,t[157]=ke,t[158]=Ae):Ae=t[158];let K;t[159]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,Z.jsx)(y,{className:`size-4 transition-transform group-open:rotate-180`}),t[159]=K):K=t[159];let q;t[160]===Ae?q=t[161]:(q=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-3 text-sm font-semibold text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[Ae,K]}),t[160]=Ae,t[161]=q);let J;t[162]!==n.actionMode||t[163]!==n.afterRunMode||t[164]!==n.safetyMode||t[165]!==r.form.safety||t[166]!==r.safety||t[167]!==S?(J=n.actionMode===`browser_recipe`?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Kt,{title:r.form.safety}),(0,Z.jsxs)($,{label:r.form.safety,children:[(0,Z.jsxs)(o,{className:Q,value:n.safetyMode,onChange:e=>{let t=e.target.value;S({safetyMode:t,...t!==`auto_apply`&&n.afterRunMode===`webhook`?{afterRunMode:`none`,webhookUrl:``}:{}})},children:[(0,Z.jsx)(s,{value:`suggest_only`,children:r.safety.suggest_only}),(0,Z.jsx)(s,{value:`ask_before_apply`,children:r.safety.ask_before_apply}),(0,Z.jsx)(s,{value:`auto_apply`,children:r.safety.auto_apply})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.safetyMode===`suggest_only`?r.safety.suggestOnlyDescription:n.safetyMode===`ask_before_apply`?r.safety.askBeforeApplyDescription:r.safety.autoApplyDescription})]})]}),t[162]=n.actionMode,t[163]=n.afterRunMode,t[164]=n.safetyMode,t[165]=r.form.safety,t[166]=r.safety,t[167]=S,t[168]=J):J=t[168];let Y;t[169]===r.form.afterRun?Y=t[170]:(Y=(0,Z.jsx)(Kt,{title:r.form.afterRun}),t[169]=r.form.afterRun,t[170]=Y);let X;t[171]===S?X=t[172]:(X=e=>S({afterRunMode:e.target.value}),t[171]=S,t[172]=X);let je;t[173]===r.afterRun.none?je=t[174]:(je=(0,Z.jsx)(s,{value:`none`,children:r.afterRun.none}),t[173]=r.afterRun.none,t[174]=je);let Me;t[175]===r.afterRun.saveToSession?Me=t[176]:(Me=(0,Z.jsx)(s,{value:`saveToSession`,children:r.afterRun.saveToSession}),t[175]=r.afterRun.saveToSession,t[176]=Me);let Ne=n.safetyMode!==`auto_apply`,Pe;t[177]!==r.afterRun.webhook||t[178]!==Ne?(Pe=(0,Z.jsx)(s,{value:`webhook`,disabled:Ne,children:r.afterRun.webhook}),t[177]=r.afterRun.webhook,t[178]=Ne,t[179]=Pe):Pe=t[179];let Fe;t[180]!==n.afterRunMode||t[181]!==X||t[182]!==je||t[183]!==Me||t[184]!==Pe?(Fe=(0,Z.jsxs)(o,{className:Q,value:n.afterRunMode,onChange:X,children:[je,Me,Pe]}),t[180]=n.afterRunMode,t[181]=X,t[182]=je,t[183]=Me,t[184]=Pe,t[185]=Fe):Fe=t[185];let Ie;t[186]!==n.afterRunMode||t[187]!==n.webhookUrl||t[188]!==r.form.webhookUrl||t[189]!==S?(Ie=n.afterRunMode===`webhook`?(0,Z.jsx)($,{label:r.form.webhookUrl,children:(0,Z.jsx)(`input`,{className:Q,value:n.webhookUrl,onChange:e=>S({webhookUrl:e.target.value})})}):null,t[186]=n.afterRunMode,t[187]=n.webhookUrl,t[188]=r.form.webhookUrl,t[189]=S,t[190]=Ie):Ie=t[190];let Le;t[191]===r.form.reliability?Le=t[192]:(Le=(0,Z.jsx)(Kt,{title:r.form.reliability}),t[191]=r.form.reliability,t[192]=Le);let Re;t[193]===S?Re=t[194]:(Re=e=>S({timeoutSeconds:e.target.value}),t[193]=S,t[194]=Re);let Ue;t[195]!==n.timeoutSeconds||t[196]!==Re?(Ue=(0,Z.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.timeoutSeconds,onChange:Re}),t[195]=n.timeoutSeconds,t[196]=Re,t[197]=Ue):Ue=t[197];let We;t[198]!==r.form.timeoutSeconds||t[199]!==Ue?(We=(0,Z.jsx)($,{label:r.form.timeoutSeconds,children:Ue}),t[198]=r.form.timeoutSeconds,t[199]=Ue,t[200]=We):We=t[200];let Ke;t[201]===S?Ke=t[202]:(Ke=e=>S({disableAfterFailures:e.target.value}),t[201]=S,t[202]=Ke);let qe;t[203]!==n.disableAfterFailures||t[204]!==Ke?(qe=(0,Z.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.disableAfterFailures,onChange:Ke}),t[203]=n.disableAfterFailures,t[204]=Ke,t[205]=qe):qe=t[205];let Je;t[206]!==r.form.disableAfterFailures||t[207]!==qe?(Je=(0,Z.jsx)($,{label:r.form.disableAfterFailures,children:qe}),t[206]=r.form.disableAfterFailures,t[207]=qe,t[208]=Je):Je=t[208];let Ye;t[209]!==We||t[210]!==Je?(Ye=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[We,Je]}),t[209]=We,t[210]=Je,t[211]=Ye):Ye=t[211];let Xe;t[212]===r.form.effectivePolicy?Xe=t[213]:(Xe=(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.form.effectivePolicy}),t[212]=r.form.effectivePolicy,t[213]=Xe);let Qe=n.timeoutSeconds||`—`,$e;t[214]!==r.form.executionDeadline||t[215]!==Qe?($e=(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[r.form.executionDeadline,`: `,Qe,`s`]}),t[214]=r.form.executionDeadline,t[215]=Qe,t[216]=$e):$e=t[216];let et;t[217]===r.form.downstreamTimeoutHint?et=t[218]:(et=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-fg-subtle`,children:r.form.downstreamTimeoutHint}),t[217]=r.form.downstreamTimeoutHint,t[218]=et);let tt;t[219]!==Xe||t[220]!==$e||t[221]!==et?(tt=(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-muted/40 px-3 py-2.5`,children:[Xe,$e,et]}),t[219]=Xe,t[220]=$e,t[221]=et,t[222]=tt):tt=t[222];let nt;t[223]!==J||t[224]!==Y||t[225]!==Fe||t[226]!==Ie||t[227]!==Le||t[228]!==Ye||t[229]!==tt?(nt=(0,Z.jsxs)(`div`,{className:`grid gap-4 border-t border-edge-subtle p-4`,children:[J,Y,Fe,Ie,Le,Ye,tt]}),t[223]=J,t[224]=Y,t[225]=Fe,t[226]=Ie,t[227]=Le,t[228]=Ye,t[229]=tt,t[230]=nt):nt=t[230];let rt;t[231]!==q||t[232]!==nt?(rt=(0,Z.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base`,children:[q,nt]}),t[231]=q,t[232]=nt,t[233]=rt):rt=t[233];let at;return t[234]!==ne||t[235]!==M||t[236]!==ae||t[237]!==pe||t[238]!==z||t[239]!==B||t[240]!==V||t[241]!==ge||t[242]!==_e||t[243]!==H||t[244]!==ye||t[245]!==Ee||t[246]!==De||t[247]!==Oe||t[248]!==rt?(at=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[ne,M,ae,pe,z,B,V,ge,_e,H,ye,Ee,De,Oe,rt]})}),t[234]=ne,t[235]=M,t[236]=ae,t[237]=pe,t[238]=z,t[239]=B,t[240]=V,t[241]=ge,t[242]=_e,t[243]=H,t[244]=ye,t[245]=Ee,t[246]=De,t[247]=Oe,t[248]=rt,t[249]=at):at=t[249],at}function Wt(e){return(0,Z.jsx)(s,{value:e.id,children:e.name},e.id)}function Gt(e){return(0,Z.jsx)(s,{value:e.id,children:e.title||e.name},e.id)}var Q=`w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`;function $(e){let t=(0,W.c)(5),{label:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,Z.jsxs)(`div`,{className:`grid gap-1.5`,children:[i,r]}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function Kt(e){let t=(0,W.c)(3),{title:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(C,{className:`size-4 text-fg-muted`}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 pt-2 text-sm font-semibold text-fg`,children:[r,n]}),t[1]=n,t[2]=i),i}export{Ct as AutomationsPage};
@@ -1,8 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{n as a,r as o}from"./popover-select-BzdnTy3h.js";import{t as s}from"./external-link-DjqjBmc3.js";import{t as c}from"./globe-DSSGFWFn.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./cn-JdwAhgNB.js";import{t as d}from"./button-CSEbl4zT.js";import{t as f}from"./copy-to-clipboard-HOJ79TWv.js";import{t as p}from"./messages-D7kOD_o_.js";import{l as m,n as h,o as g,r as _,s as v}from"./locale-store-CnamlR07.js";import{n as y,r as b}from"./gateway-config-swr-Cv2ywpdb.js";import{n as x,r as S,t as C}from"./settings-form-draft-Dy10ldo8.js";import{Cr as w,Ds as T,Go as E,Gs as D,Io as O,Ks as k,Ls as A,Ol as j,Os as M,Tl as N,Uo as P,Vs as F,Zo as I,_l as L,ac as R,al as z,cs as B,fl as ee,os as V,qn as te,qs as H,sl as U,vl as W,ws as ne,xl as G,ys as K}from"./index-DRrjYYzZ.js";import{n as re,r as ie,t as ae}from"./settings-page-layout-BRQNel6r.js";import{n as oe}from"./settings-loading-skeleton-zwibve4m.js";import{n as se,t as ce}from"./use-autosave-D6UkH_Ga.js";import{t as le}from"./settings-advanced-gate-BTB_fxjt.js";import{n as ue,t as q}from"./settings-form-section-C7w2WS-A.js";import{t as de}from"./page-tabs-BaEQMYm_.js";import{c as fe,r as pe,s as J}from"./typed-models-lib-q5-Vfqd8.js";import{a as me,c as he,d as ge,u as _e}from"./gateway-config-api-CZ4r-7qT.js";var Y=e(t(),1),X=n(),Z=r();function Q(e){let t=(0,X.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function ve(e){switch(e){case`ready`:return`bg-emerald-500`;case`not_installed`:case`checking`:return`bg-amber-500`;case`error`:return`bg-red-500`;default:return`bg-fg-subtle/60`}}function ye(e){let t=(0,X.c)(28),{value:n,onChange:r,onOpenConfig:i,options:o,m:s}=e,c;if(t[0]!==s.browserGoToConfigure||t[1]!==s.browserPickerSubtitle||t[2]!==s.browserPickerTitle||t[3]!==r||t[4]!==i||t[5]!==o||t[6]!==n){let e=o.find(e=>e.value===n)??o[0],l;t[8]===s.browserPickerTitle?l=t[9]:(l=(0,Z.jsx)(`label`,{htmlFor:`browser-backend-select`,className:`text-sm font-medium text-fg`,children:s.browserPickerTitle}),t[8]=s.browserPickerTitle,t[9]=l);let d;t[10]===s.browserPickerSubtitle?d=t[11]:(d=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:s.browserPickerSubtitle}),t[10]=s.browserPickerSubtitle,t[11]=d);let f;t[12]!==l||t[13]!==d?(f=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[l,d]}),t[12]=l,t[13]=d,t[14]=f):f=t[14];let p;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(p=u(fe(),`min-w-0 flex-1 sm:max-w-md`),t[15]=p):p=t[15];let m;t[16]===r?m=t[17]:(m=e=>r(e.target.value),t[16]=r,t[17]=m);let h=s.browserPickerTitle,g;t[18]===o?g=t[19]:(g=o.map(be),t[18]=o,t[19]=g);let _;t[20]!==s.browserPickerTitle||t[21]!==m||t[22]!==g||t[23]!==n?(_=(0,Z.jsx)(a,{id:`browser-backend-select`,className:p,value:n,onChange:m,"aria-label":h,children:g}),t[20]=s.browserPickerTitle,t[21]=m,t[22]=g,t[23]=n,t[24]=_):_=t[24];let v=i?(0,Z.jsxs)(`button`,{type:`button`,className:u(`inline-flex shrink-0 items-center justify-center gap-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-accent`,`transition-colors hover:border-edge-strong hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),onClick:()=>i(n),"aria-label":`${e?.name??n} — ${s.browserGoToConfigure}`,children:[(0,Z.jsx)(`span`,{children:s.browserGoToConfigure}),(0,Z.jsx)(j,{className:`size-4 shrink-0`,"aria-hidden":!0})]}):null,y;t[25]!==v||t[26]!==_?(y=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-2`,children:[_,v]}),t[25]=v,t[26]=_,t[27]=y):y=t[27],c=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f,y,e?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.statusLabel?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-medium text-fg-muted`,"aria-label":e.statusLabel,children:[(0,Z.jsx)(`span`,{className:u(`inline-block size-1.5 rounded-full`,ve(e.status)),"aria-hidden":!0}),e.statusLabel]}):null}),(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.tagline})]}):null]}),t[0]=s.browserGoToConfigure,t[1]=s.browserPickerSubtitle,t[2]=s.browserPickerTitle,t[3]=r,t[4]=i,t[5]=o,t[6]=n,t[7]=c}else c=t[7];return c}function be(e){return(0,Z.jsx)(o,{value:e.value,children:e.name},e.value)}function xe(e){return`browser-focus-${e}`}function Se(e){switch(e){case`connection`:case`extension`:case`local`:case`cloak`:case`cdp`:case`cloud`:case`runtime`:case`security`:return e;default:return null}}function Ce(e){let t=(0,X.c)(89),{a:n,form:r,update:i}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=xe(`runtime`),t[0]=s):s=t[0];let c;t[1]===n.browserBehaviorShow?c=t[2]:(c=(0,Z.jsx)(ue,{icon:ne,title:n.browserBehaviorShow}),t[1]=n.browserBehaviorShow,t[2]=c);let l;t[3]===i?l=t[4]:(l=e=>i({browserHeadless:e.target.checked}),t[3]=i,t[4]=l);let u;t[5]!==r.browserHeadless||t[6]!==l?(u=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserHeadless,onChange:l}),t[5]=r.browserHeadless,t[6]=l,t[7]=u):u=t[7];let d;t[8]===n.browserHeadlessOn?d=t[9]:(d=(0,Z.jsx)(`span`,{children:n.browserHeadlessOn}),t[8]=n.browserHeadlessOn,t[9]=d);let f;t[10]!==u||t[11]!==d?(f=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[u,d]}),t[10]=u,t[11]=d,t[12]=f):f=t[12];let p;t[13]!==n.desc.browserHeadless||t[14]!==n.label.browserHeadless||t[15]!==f?(p=(0,Z.jsx)(Q,{label:n.label.browserHeadless,description:n.desc.browserHeadless,children:f}),t[13]=n.desc.browserHeadless,t[14]=n.label.browserHeadless,t[15]=f,t[16]=p):p=t[16];let m=n.label.browserDialogPolicy,h=n.desc.browserDialogPolicy,g;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(g=fe(),t[17]=g):g=t[17];let _;t[18]===i?_=t[19]:(_=e=>i({browserDialogPolicy:e.target.value}),t[18]=i,t[19]=_);let v;t[20]===n.browserDialogPolicyMustRespond?v=t[21]:(v=(0,Z.jsx)(o,{value:`must_respond`,children:n.browserDialogPolicyMustRespond}),t[20]=n.browserDialogPolicyMustRespond,t[21]=v);let y;t[22]===n.browserDialogPolicyAutoDismiss?y=t[23]:(y=(0,Z.jsx)(o,{value:`auto_dismiss`,children:n.browserDialogPolicyAutoDismiss}),t[22]=n.browserDialogPolicyAutoDismiss,t[23]=y);let b;t[24]===n.browserDialogPolicyAutoAccept?b=t[25]:(b=(0,Z.jsx)(o,{value:`auto_accept`,children:n.browserDialogPolicyAutoAccept}),t[24]=n.browserDialogPolicyAutoAccept,t[25]=b);let x;t[26]!==r.browserDialogPolicy||t[27]!==_||t[28]!==v||t[29]!==y||t[30]!==b?(x=(0,Z.jsxs)(a,{className:g,value:r.browserDialogPolicy,onChange:_,children:[v,y,b]}),t[26]=r.browserDialogPolicy,t[27]=_,t[28]=v,t[29]=y,t[30]=b,t[31]=x):x=t[31];let S;t[32]!==n.desc.browserDialogPolicy||t[33]!==n.label.browserDialogPolicy||t[34]!==x?(S=(0,Z.jsx)(Q,{label:m,description:h,children:x}),t[32]=n.desc.browserDialogPolicy,t[33]=n.label.browserDialogPolicy,t[34]=x,t[35]=S):S=t[35];let C=n.label.browserDialogTimeout,w=n.desc.browserDialogTimeout,T;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(T=J(),t[36]=T):T=t[36];let E=r.browserDialogTimeout??``,D;t[37]===i?D=t[38]:(D=e=>{let t=e.target.value;i({browserDialogTimeout:t===``?void 0:Number.parseInt(t,10)})},t[37]=i,t[38]=D);let O;t[39]!==E||t[40]!==D?(O=(0,Z.jsx)(`input`,{type:`number`,className:T,min:1,value:E,placeholder:`300`,onChange:D}),t[39]=E,t[40]=D,t[41]=O):O=t[41];let k;t[42]!==n.desc.browserDialogTimeout||t[43]!==n.label.browserDialogTimeout||t[44]!==O?(k=(0,Z.jsx)(Q,{label:C,description:w,children:O}),t[42]=n.desc.browserDialogTimeout,t[43]=n.label.browserDialogTimeout,t[44]=O,t[45]=k):k=t[45];let A;t[46]!==S||t[47]!==k||t[48]!==p?(A=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[p,S,k]}),t[46]=S,t[47]=k,t[48]=p,t[49]=A):A=t[49];let j;t[50]!==c||t[51]!==A?(j=(0,Z.jsx)(`div`,{id:s,className:`scroll-mt-24`,children:(0,Z.jsxs)(q,{children:[c,A]})}),t[50]=c,t[51]=A,t[52]=j):j=t[52];let N;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(N=xe(`security`),t[53]=N):N=t[53];let P;t[54]===n.browserSecurityShow?P=t[55]:(P=(0,Z.jsx)(ue,{icon:M,title:n.browserSecurityShow}),t[54]=n.browserSecurityShow,t[55]=P);let F;t[56]===i?F=t[57]:(F=e=>i({browserAllowPrivateUrls:e.target.checked}),t[56]=i,t[57]=F);let I;t[58]!==r.browserAllowPrivateUrls||t[59]!==F?(I=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserAllowPrivateUrls,onChange:F}),t[58]=r.browserAllowPrivateUrls,t[59]=F,t[60]=I):I=t[60];let L;t[61]===n.browserAllowPrivateOn?L=t[62]:(L=(0,Z.jsx)(`span`,{children:n.browserAllowPrivateOn}),t[61]=n.browserAllowPrivateOn,t[62]=L);let R;t[63]!==I||t[64]!==L?(R=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[I,L]}),t[63]=I,t[64]=L,t[65]=R):R=t[65];let z;t[66]!==n.desc.browserAllowPrivateUrls||t[67]!==n.label.browserAllowPrivateUrls||t[68]!==R?(z=(0,Z.jsx)(Q,{label:n.label.browserAllowPrivateUrls,description:n.desc.browserAllowPrivateUrls,children:R}),t[66]=n.desc.browserAllowPrivateUrls,t[67]=n.label.browserAllowPrivateUrls,t[68]=R,t[69]=z):z=t[69];let B=n.label.browserCommandTimeout,ee=n.desc.browserCommandTimeout,V;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(V=J(),t[70]=V):V=t[70];let te=r.browserCommandTimeout??``,H;t[71]===i?H=t[72]:(H=e=>{let t=e.target.value;i({browserCommandTimeout:t===``?void 0:Number.parseInt(t,10)})},t[71]=i,t[72]=H);let U;t[73]!==te||t[74]!==H?(U=(0,Z.jsx)(`input`,{type:`number`,className:V,min:5,value:te,placeholder:`30`,onChange:H}),t[73]=te,t[74]=H,t[75]=U):U=t[75];let W;t[76]!==n.desc.browserCommandTimeout||t[77]!==n.label.browserCommandTimeout||t[78]!==U?(W=(0,Z.jsx)(Q,{label:B,description:ee,children:U}),t[76]=n.desc.browserCommandTimeout,t[77]=n.label.browserCommandTimeout,t[78]=U,t[79]=W):W=t[79];let G;t[80]!==z||t[81]!==W?(G=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[z,W]}),t[80]=z,t[81]=W,t[82]=G):G=t[82];let K;t[83]!==P||t[84]!==G?(K=(0,Z.jsx)(`div`,{id:N,className:`scroll-mt-24`,children:(0,Z.jsxs)(q,{className:`border border-amber-500/20`,children:[P,G]})}),t[83]=P,t[84]=G,t[85]=K):K=t[85];let re;return t[86]!==j||t[87]!==K?(re=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[j,K]}),t[86]=j,t[87]=K,t[88]=re):re=t[88],re}function we(e){let t=(0,X.c)(9),{language:n,label:r,className:i}=e,a;t[0]===n?a=t[1]:(a=O(n),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=u(`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,i),t[2]=i,t[3]=o);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(s,{className:`size-3 shrink-0`,"aria-hidden":!0}),t[4]=c):c=t[4];let l;return t[5]!==r||t[6]!==a||t[7]!==o?(l=(0,Z.jsxs)(`a`,{href:a,target:`_blank`,rel:`noreferrer`,className:o,children:[r,c]}),t[5]=r,t[6]=a,t[7]=o,t[8]=l):l=t[8],l}function Te(e){let t=(0,X.c)(27),{title:n,description:r,recommended:i,recommendedLabel:a,icon:o,onSelect:s,selectLabel:c}=e,l=`${n} — ${c}`,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=u(`group flex w-full flex-col rounded-xl bg-surface-panel/80 p-3 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=d):d=t[0];let f;t[1]===o?f=t[2]:(f=(0,Z.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,Z.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=o,t[2]=f);let p;t[3]===n?p=t[4]:(p=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=p);let m;t[5]!==i||t[6]!==a?(m=i&&a?(0,Z.jsx)(`span`,{className:`rounded-full bg-accent/15 px-2 py-0.5 text-[10px] font-medium text-accent`,children:a}):null,t[5]=i,t[6]=a,t[7]=m):m=t[7];let h;t[8]!==p||t[9]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[p,m]}),t[8]=p,t[9]=m,t[10]=h):h=t[10];let g;t[11]===r?g=t[12]:(g=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(j,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=v):v=t[16];let y;t[17]!==f||t[18]!==_?(y=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[f,_,v]}),t[17]=f,t[18]=_,t[19]=y):y=t[19];let b;t[20]===c?b=t[21]:(b=(0,Z.jsx)(`span`,{className:`mt-2 text-[11px] font-medium text-accent`,children:c}),t[20]=c,t[21]=b);let x;return t[22]!==s||t[23]!==l||t[24]!==y||t[25]!==b?(x=(0,Z.jsxs)(`button`,{type:`button`,onClick:s,"aria-label":l,className:d,children:[y,b]}),t[22]=s,t[23]=l,t[24]=y,t[25]=b,t[26]=x):x=t[26],x}function Ee(e){let t=(0,X.c)(25),{m:n,onStart:r}=e,i=te(De),a;t[0]!==n.browserBackendCloakBrowser||t[1]!==n.browserModeCloakTagline||t[2]!==n.browserSetupCloudDesc||t[3]!==n.browserSetupCloudTitle||t[4]!==n.browserSetupExtDesc||t[5]!==n.browserSetupExtTitle||t[6]!==n.browserSetupLocalDesc||t[7]!==n.browserSetupLocalTitle||t[8]!==i?(a=[{id:`extension`,icon:F,title:n.browserSetupExtTitle,description:n.browserSetupExtDesc,recommended:!0},{id:`cloakbrowser`,icon:T,title:n.browserBackendCloakBrowser,description:n.browserModeCloakTagline},{id:`local`,icon:R,title:n.browserSetupLocalTitle,description:n.browserSetupLocalDesc},{id:`cloud`,icon:ee,title:n.browserSetupCloudTitle,description:n.browserSetupCloudDesc}].filter(e=>_e(e.id,i)),t[0]=n.browserBackendCloakBrowser,t[1]=n.browserModeCloakTagline,t[2]=n.browserSetupCloudDesc,t[3]=n.browserSetupCloudTitle,t[4]=n.browserSetupExtDesc,t[5]=n.browserSetupExtTitle,t[6]=n.browserSetupLocalDesc,t[7]=n.browserSetupLocalTitle,t[8]=i,t[9]=a):a=t[9];let o=a,s;t[10]===n.browserSetupTitle?s=t[11]:(s=(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.browserSetupTitle}),t[10]=n.browserSetupTitle,t[11]=s);let c;t[12]===n.browserSetupSubtitle?c=t[13]:(c=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.browserSetupSubtitle}),t[12]=n.browserSetupSubtitle,t[13]=c);let l;t[14]!==s||t[15]!==c?(l=(0,Z.jsxs)(`div`,{children:[s,c]}),t[14]=s,t[15]=c,t[16]=l):l=t[16];let u;t[17]!==n.browserSetupRecommended||t[18]!==n.browserSetupSelect||t[19]!==o||t[20]!==r?(u=(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.map(e=>(0,Z.jsx)(Te,{icon:e.icon,title:e.title,description:e.description,recommended:e.recommended,recommendedLabel:n.browserSetupRecommended,selectLabel:n.browserSetupSelect,onSelect:()=>r(e.id)},e.id))}),t[17]=n.browserSetupRecommended,t[18]=n.browserSetupSelect,t[19]=o,t[20]=r,t[21]=u):u=t[21];let d;return t[22]!==l||t[23]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-base p-4`,children:[l,u]}),t[22]=l,t[23]=u,t[24]=d):d=t[24],d}function De(e){return e.mode}function Oe(e){if(e.kind===`loading`)return`checking`;if(e.kind===`error`)return`error`;if(e.kind===`ok`)return e.data.installed?`ready`:`not_installed`}function ke(e,t){if(e)return{ready:t.browserStatusReady,not_installed:t.browserStatusNotInstalled,checking:t.browserStatusChecking,unknown:t.browserStatusUnknown,error:t.browserStatusError}[e]}function Ae(e){if(e.kind!==`idle`)return e.kind===`loading`?`checking`:e.kind===`error`?`error`:e.data.connected?`ready`:(e.data.running,`not_installed`)}function je(e,t){if(e.kind!==`idle`)return e.kind===`loading`?t.browserStatusChecking:e.kind===`error`?t.browserStatusError:e.data.connected?t.browserExtensionConnected:e.data.running?t.browserExtensionWaiting:t.browserExtensionServerOff}var Me=[`overview`,`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Ne=[`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Pe={connection:`overview`,extension:`extension`,local:`local`,cloak:`cloakbrowser`,cdp:`cdp`,cloud:`cloud`,runtime:`overview`,security:`overview`};function Fe(e){let t=(e??``).trim();return t===`behavior`?`overview`:Me.includes(t)?t:`overview`}function Ie(e){return Ne.includes(e)}function Le(e){let t=(0,X.c)(46),{icon:n,title:r,description:i,status:a,statusDetail:o,primaryAction:s,children:c,advanced:l,m:u,embedded:d,sectionTitle:f,advancedTitle:p}=e,m=d===void 0?!1:d,h;t[0]!==l||t[1]!==p?(h=l?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[p?(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:p}):null,l]}):null,t[0]=l,t[1]=p,t[2]=h):h=t[2];let g=h;if(m){let e;t[3]!==i||t[4]!==f?(e=f?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:f}),i?(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}):null]}):null,t[3]=i,t[4]=f,t[5]=e):e=t[5];let n;t[6]!==u||t[7]!==s||t[8]!==a||t[9]!==o?(n=a||s?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[a?(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(Re,{kind:a,detail:o,m:u})}):(0,Z.jsx)(`span`,{}),s?(0,Z.jsx)(`div`,{className:`shrink-0`,children:s}):null]}):null,t[6]=u,t[7]=s,t[8]=a,t[9]=o,t[10]=n):n=t[10];let r;t[11]===c?r=t[12]:(r=c?(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[11]=c,t[12]=r);let l;return t[13]!==g||t[14]!==e||t[15]!==n||t[16]!==r?(l=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e,n,r,g]}),t[13]=g,t[14]=e,t[15]=n,t[16]=r,t[17]=l):l=t[17],l}let _;t[18]===n?_=t[19]:(_=(0,Z.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75})}),t[18]=n,t[19]=_);let v;t[20]===r?v=t[21]:(v=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r}),t[20]=r,t[21]=v);let y;t[22]!==u||t[23]!==a||t[24]!==o?(y=a?(0,Z.jsx)(Re,{kind:a,detail:o,m:u}):null,t[22]=u,t[23]=a,t[24]=o,t[25]=y):y=t[25];let b;t[26]!==v||t[27]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28];let x;t[29]===i?x=t[30]:(x=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}),t[29]=i,t[30]=x);let S;t[31]!==b||t[32]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[b,x]}),t[31]=b,t[32]=x,t[33]=S):S=t[33];let C;t[34]===s?C=t[35]:(C=s?(0,Z.jsx)(`div`,{className:`shrink-0`,children:s}):null,t[34]=s,t[35]=C);let w;t[36]!==_||t[37]!==S||t[38]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[_,S,C]}),t[36]=_,t[37]=S,t[38]=C,t[39]=w):w=t[39];let T;t[40]===c?T=t[41]:(T=c?(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[40]=c,t[41]=T);let E;return t[42]!==g||t[43]!==w||t[44]!==T?(E=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[w,T,g]}),t[42]=g,t[43]=w,t[44]=T,t[45]=E):E=t[45],E}function Re(e){let t=(0,X.c)(27),{kind:n,detail:r,m:i}=e,a,o,s,c;if(t[0]!==n||t[1]!==i.browserStatusChecking||t[2]!==i.browserStatusError||t[3]!==i.browserStatusNotInstalled||t[4]!==i.browserStatusReady||t[5]!==i.browserStatusUnknown){let{icon:e,color:r,label:d}={ready:{icon:N,color:`text-green-600 dark:text-green-400`,label:i.browserStatusReady},not_installed:{icon:B,color:`text-amber-600 dark:text-amber-400`,label:i.browserStatusNotInstalled},checking:{icon:l,color:`text-fg-muted`,label:i.browserStatusChecking},unknown:{icon:G,color:`text-fg-muted`,label:i.browserStatusUnknown},error:{icon:W,color:`text-red-600 dark:text-red-400`,label:i.browserStatusError}}[n];a=e,o=d,c=`inline-flex min-w-0 flex-col items-start gap-1`,s=u(`inline-flex shrink-0 items-center gap-1 whitespace-nowrap text-xs font-medium`,r),t[0]=n,t[1]=i.browserStatusChecking,t[2]=i.browserStatusError,t[3]=i.browserStatusNotInstalled,t[4]=i.browserStatusReady,t[5]=i.browserStatusUnknown,t[6]=a,t[7]=o,t[8]=s,t[9]=c}else a=t[6],o=t[7],s=t[8],c=t[9];let d=n===`checking`&&`animate-spin`,f;t[10]===d?f=t[11]:(f=u(`size-3.5 shrink-0`,d),t[10]=d,t[11]=f);let p;t[12]!==a||t[13]!==f?(p=(0,Z.jsx)(a,{className:f}),t[12]=a,t[13]=f,t[14]=p):p=t[14];let m;t[15]===o?m=t[16]:(m=(0,Z.jsx)(`span`,{children:o}),t[15]=o,t[16]=m);let h;t[17]!==s||t[18]!==p||t[19]!==m?(h=(0,Z.jsxs)(`span`,{className:s,children:[p,m]}),t[17]=s,t[18]=p,t[19]=m,t[20]=h):h=t[20];let g;t[21]===r?g=t[22]:(g=r?(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg-subtle`,children:r}):null,t[21]=r,t[22]=g);let _;return t[23]!==c||t[24]!==h||t[25]!==g?(_=(0,Z.jsxs)(`span`,{className:c,children:[h,g]}),t[23]=c,t[24]=h,t[25]=g,t[26]=_):_=t[26],_}function ze(e){let t=(0,X.c)(5),{kind:n,message:r}=e,i=n===`success`?`border-green-500/30 bg-green-500/10 text-green-700 dark:text-green-300`:`border-red-500/30 bg-red-500/10 text-red-600 dark:text-red-300`,a;t[0]===i?a=t[1]:(a=u(`rounded-lg border px-3 py-2 text-xs leading-relaxed`,i),t[0]=i,t[1]=a);let o;return t[2]!==r||t[3]!==a?(o=(0,Z.jsx)(`div`,{className:a,children:r}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}var Be={instances:[],launchStatus:`idle`,launchMessage:null,testStatus:`idle`,testMessage:null,executablePath:``};function Ve({m:e,cdpUrl:t,onCdpUrlChange:n,launch:r,stop:i,listInstances:a,ping:o,embedded:s=!1}){let[c,u]=(0,Y.useReducer)(S,Be),{instances:d,launchStatus:f,launchMessage:p,testStatus:m,testMessage:h,executablePath:g}=c,_=(0,Y.useCallback)(async()=>{try{u({type:`patch`,patch:{instances:await a()}})}catch{}},[a]);(0,Y.useEffect)(()=>{_();let e=setInterval(()=>void _(),8e3);return()=>clearInterval(e)},[_]);let v=(0,Y.useCallback)(async()=>{if(f!==`pending`){u({type:`patch`,patch:{launchStatus:`pending`,launchMessage:null}});try{let t=await r(g.trim()||void 0);u({type:`patch`,patch:{launchStatus:`ok`,launchMessage:e.browserCdpLaunchedAtPort.replace(`{{port}}`,String(t.port))}}),n(t.wsEndpoint),await _()}catch(e){u({type:`patch`,patch:{launchStatus:`error`,launchMessage:e instanceof Error?e.message:String(e)}})}}},[g,r,f,e.browserCdpLaunchedAtPort,n,_]),y=(0,Y.useCallback)(async e=>{await i(e),await _()},[_,i]),b=(0,Y.useCallback)(async()=>{if(t.trim()){u({type:`patch`,patch:{testStatus:`pending`,testMessage:null}});try{let n=await o(t.trim());n.reachable?u({type:`patch`,patch:{testStatus:`ok`,testMessage:e.browserCdpReachable.replace(`{{browser}}`,n.browser??`—`)}}):u({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,n.error??`—`)}})}catch(t){u({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,t instanceof Error?t.message:String(t))}})}}},[t,e.browserCdpReachable,e.browserCdpUnreachable,o]);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(Le,{icon:k,title:e.browserCdpLaunchLocal,description:e.browserCdpLaunchLocalDesc,m:e,embedded:s,sectionTitle:s?e.browserCdpLaunchLocal:void 0,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:f===`pending`,onClick:()=>void v(),children:[f===`pending`?(0,Z.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(k,{className:`size-3.5`}),f===`pending`?e.browserCdpLaunching:e.browserCdpLaunchLocal]}),children:[p?(0,Z.jsx)(ze,{kind:f===`error`?`error`:`success`,message:p}):null,(0,Z.jsx)(Q,{label:e.browserCdpChromePath,description:e.browserCdpChromePathDesc,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:g,placeholder:`/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,onChange:e=>u({type:`patch`,patch:{executablePath:e.target.value}}),autoComplete:`off`})}),d.length>0?(0,Z.jsx)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base p-3 shadow-surface`,children:d.map(t=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsxs)(`span`,{className:`font-mono text-fg`,children:[`port `,t.port,` · pid `,t.pid]}),(0,Z.jsx)(`span`,{className:`truncate text-fg-subtle`,children:t.wsEndpoint})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs font-medium text-fg hover:bg-surface-raised`,onClick:()=>void y(t.port),children:[(0,Z.jsx)(K,{className:`size-3`}),e.browserCdpStopLocal]})]},t.port))}):null]}),(0,Z.jsxs)(Le,{icon:I,title:e.label.browserCdpUrl,description:e.desc.browserCdpUrl,m:e,embedded:s,sectionTitle:s?e.label.browserCdpUrl:void 0,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:!t.trim()||m===`pending`,onClick:()=>void b(),children:[m===`pending`?(0,Z.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(D,{className:`size-3.5`}),m===`pending`?e.browserCdpTesting:e.browserCdpTestConnection]}),children:[(0,Z.jsx)(`input`,{type:`text`,className:J(),value:t,placeholder:`ws://127.0.0.1:9222`,onChange:e=>n(e.target.value),autoComplete:`off`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCdpLoopbackOnly}),h?(0,Z.jsx)(ze,{kind:m===`error`?`error`:`success`,message:h}):null]})]})}function He(e,t){let n=t.phase;if(!n)return e.browserInstallPhaseStarting;if(n===`downloading`)return t.percent==null?e.browserInstallPhaseDownloading:e.browserInstallPhaseDownloadingPercent.replace(`{{percent}}`,String(t.percent));switch(n){case`starting`:return e.browserInstallPhaseStarting;case`verifying`:return e.browserInstallPhaseVerifying;case`extracting`:return e.browserInstallPhaseExtracting;case`running`:return t.message??e.browserInstallPhaseRunning;case`ready`:return e.browserInstallPhaseReady;default:return t.message??e.browserInstallPhaseRunning}}function Ue(e){let t=(0,X.c)(32),{m:n,progress:r,showLogs:i,onCancel:a,cancelling:o}=e,s=i===void 0?!1:i,c=o===void 0?!1:o;if(!r.phase)return null;let l;t[0]!==n||t[1]!==r?(l=He(n,r),t[0]=n,t[1]=r,t[2]=l):l=t[2];let u=l,d=r.percent==null?(r.phase===`extracting`||r.phase===`verifying`||r.phase===`running`||r.phase,null):Math.min(100,Math.max(0,r.percent)),f;t[3]===u?f=t[4]:(f=(0,Z.jsx)(`span`,{className:`text-fg`,children:u}),t[3]=u,t[4]=f);let p;t[5]===d?p=t[6]:(p=d==null?null:(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[d,`%`]}),t[5]=d,t[6]=p);let m;t[7]!==c||t[8]!==n||t[9]!==a?(m=a?(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md border border-edge px-2 py-0.5 text-[11px] font-medium text-fg-muted hover:bg-surface-raised hover:text-fg disabled:cursor-not-allowed disabled:opacity-60`,disabled:c,onClick:()=>void a(),children:c?n.browserInstallCancelling:n.browserInstallCancel}):null,t[7]=c,t[8]=n,t[9]=a,t[10]=m):m=t[10];let h;t[11]!==p||t[12]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p,m]}),t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;t[14]!==f||t[15]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-fg-muted`,children:[f,h]}),t[14]=f,t[15]=h,t[16]=g):g=t[16];let _;t[17]===d?_=t[18]:(_=(0,Z.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-raised`,children:d==null?(0,Z.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-accent/70`}):(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-300 ease-out`,style:{width:`${d}%`}})}),t[17]=d,t[18]=_);let v;t[19]!==r.lines||t[20]!==s?(v=s&&r.lines.length>0?(0,Z.jsx)(`div`,{className:`max-h-28 overflow-y-auto rounded-md bg-surface-panel px-2 py-1.5 font-mono text-[10px] leading-relaxed text-fg-muted shadow-surface`,children:r.lines.map(We)}):null,t[19]=r.lines,t[20]=s,t[21]=v):v=t[21];let y;t[22]!==r.message||t[23]!==r.percent||t[24]!==r.phase||t[25]!==s?(y=!s&&r.phase===`downloading`&&r.message&&r.percent==null?(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:r.message}):null,t[22]=r.message,t[23]=r.percent,t[24]=r.phase,t[25]=s,t[26]=y):y=t[26];let b;return t[27]!==v||t[28]!==y||t[29]!==g||t[30]!==_?(b=(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-lg bg-surface-base px-3 py-2.5 shadow-surface`,children:[g,_,v,y]}),t[27]=v,t[28]=y,t[29]=g,t[30]=_,t[31]=b):b=t[31],b}function We(e){return(0,Z.jsx)(`div`,{className:`truncate`,children:e},e)}var Ge={confirmOpen:!1,installStatus:`idle`,installMessage:null,openStatus:`idle`,openMessage:null,runtime:null};function Ke({m:e,doctor:t,refetch:n,applyDoctor:r,installStream:i,fetchRuntimeStatus:s,launchCloak:c,form:u,onChange:d,embedded:f=!1}){let[p,m]=(0,Y.useReducer)(S,Ge),{confirmOpen:h,installStatus:g,installMessage:_,openStatus:v,openMessage:y,runtime:b}=p,{progress:x,running:C,cancelling:E,run:D,reset:O,cancel:j}=i,M=t.kind===`ok`?t.data:null,P=M?.installed===!0,F=g===`installing`||C,I=(0,Y.useCallback)(async()=>{if(P)try{m({type:`patch`,patch:{runtime:await s()}})}catch{}},[s,P]);(0,Y.useEffect)(()=>{if(!P){m({type:`patch`,patch:{runtime:null}});return}I();let e=setInterval(()=>void I(),8e3);return()=>clearInterval(e)},[P,I]);let L=(0,Y.useCallback)(async()=>{m({type:`patch`,patch:{confirmOpen:!1,installStatus:`installing`,installMessage:null}}),O();let t=await D({body:{cacheDir:u.cacheDir.trim()||void 0,binaryPath:u.binaryPath.trim()||void 0},fallbackError:e.browserCloakInstallFailed});if(!t.ok){if(t.error===`busy`){m({type:`patch`,patch:{installStatus:`installing`}});return}if(t.error===`cancelled`){m({type:`patch`,patch:{installStatus:`idle`,installMessage:null}}),O();return}m({type:`patch`,patch:{installStatus:`failed`,installMessage:t.errorMessage??e.browserCloakInstallFailed}});return}t.payload&&r?.(t.payload),m({type:`patch`,patch:{installStatus:`installed`,installMessage:t.payload?.binaryPath?`${e.browserCloakInstalled}: ${t.payload.binaryPath}`:e.browserCloakInstalled}}),await n({cacheDir:u.cacheDir,binaryPath:u.binaryPath}),await I()},[r,u.binaryPath,u.cacheDir,e.browserCloakInstallFailed,e.browserCloakInstalled,n,I,O,D]),R=(0,Y.useCallback)(async()=>{if(v!==`pending`){m({type:`patch`,patch:{openStatus:`pending`,openMessage:null}});try{let t=await c();m({type:`patch`,patch:{openStatus:`ok`,openMessage:t.reused?e.browserCloakOpenReused.replace(`{{port}}`,String(t.port)):e.browserCloakOpenLaunched.replace(`{{port}}`,String(t.port)),runtime:t}})}catch(e){m({type:`patch`,patch:{openStatus:`error`,openMessage:e instanceof Error?e.message:String(e)}})}}},[c,e.browserCloakOpenLaunched,e.browserCloakOpenReused,v]),B=t.kind===`loading`?`checking`:t.kind===`error`?`error`:P?`ready`:`not_installed`,ee=P&&M?.version?`v${M.version} (${M.platform})`:void 0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Le,{icon:T,title:e.browserCloakGuideTitle,description:e.browserCloakGuideDesc,status:B,statusDetail:ee,m:e,embedded:f,primaryAction:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[P?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:v===`pending`,onClick:()=>void R(),children:[v===`pending`?(0,Z.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(k,{className:`size-3.5`}),v===`pending`?e.browserCloakOpening:e.browserCloakOpen]}):null,(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:F,onClick:()=>m({type:`patch`,patch:{confirmOpen:!0}}),children:[F?(0,Z.jsx)(l,{className:`size-3.5 animate-spin`}):P?(0,Z.jsx)(A,{className:`size-3.5`}):g===`installed`?(0,Z.jsx)(N,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(z,{className:`size-3.5`}),F?e.browserCloakInstalling:P?e.browserReinstall:e.browserCloakDownload]})]}),children:[C?(0,Z.jsx)(Ue,{m:e,progress:x,cancelling:E,onCancel:()=>void j()}):null,_?(0,Z.jsx)(ze,{kind:g===`failed`?`error`:`success`,message:_}):null,y?(0,Z.jsx)(ze,{kind:v===`error`?`error`:`success`,message:y}):null,P&&b?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base p-3 shadow-surface`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:b.running?e.browserCloakRuntimeRunning.replace(`{{port}}`,String(b.port)):e.browserCloakRuntimeOff})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:e.browserCloakProfileLabel}),(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:b.userDataDir})]}),(0,Z.jsx)(`p`,{className:`text-[11px] leading-relaxed text-fg-subtle`,children:e.browserCloakProfileAgentHint}),b.temporaryProfile?(0,Z.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserCloakTemporaryProfileHint}):null]}):null,(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{label:e.label.browserCloakKeepOpen,description:e.desc.browserCloakKeepOpen,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:u.keepOpen,onChange:e=>d({keepOpen:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserCloakKeepOpenOn})]})}),(0,Z.jsx)(Q,{label:e.label.browserCloakTemporaryProfile,description:e.desc.browserCloakTemporaryProfile,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:u.temporaryProfile,onChange:e=>d({temporaryProfile:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserCloakTemporaryProfileOn})]})}),(0,Z.jsx)(Q,{label:e.label.browserHumanize,description:e.desc.browserHumanize,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:u.humanize,onChange:e=>d({humanize:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserHumanizeOn})]})}),(0,Z.jsx)(Q,{label:e.label.browserHumanPreset,description:e.desc.browserHumanPreset,children:(0,Z.jsxs)(a,{className:fe(),value:u.humanPreset,onChange:e=>d({humanPreset:e.target.value}),children:[(0,Z.jsx)(o,{value:`careful`,children:e.browserHumanPresetCareful}),(0,Z.jsx)(o,{value:`default`,children:e.browserHumanPresetDefault})]})})]})]}),(0,Z.jsxs)(q,{className:`mt-4`,children:[(0,Z.jsx)(ue,{icon:T,title:e.browserCloakAdvancedShow}),(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsxs)(Q,{label:e.label.browserCloakCacheDir,description:e.desc.browserCloakCacheDir,children:[(0,Z.jsx)(`input`,{type:`text`,className:J(),value:u.cacheDir,placeholder:`~/.xopc/bin/cloakbrowser`,onChange:e=>d({cacheDir:e.target.value}),autoComplete:`off`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCacheDirHomeOnly})]}),(0,Z.jsxs)(Q,{label:e.label.browserCloakBinaryPath,description:e.desc.browserCloakBinaryPath,children:[(0,Z.jsx)(`input`,{type:`text`,className:J(),value:u.binaryPath,placeholder:`~/.xopc/bin/cloakbrowser/chromium-v.../Chromium.app/Contents/MacOS/Chromium`,onChange:e=>d({binaryPath:e.target.value}),autoComplete:`off`}),u.binaryPath.trim()?(0,Z.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserBinaryPathWarning}):null]}),(0,Z.jsx)(Q,{label:e.label.browserCloakTimezone,description:e.desc.browserCloakTimezone,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:u.timezone,placeholder:`America/New_York`,onChange:e=>d({timezone:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserCloakLocale,description:e.desc.browserCloakLocale,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:u.locale,placeholder:`en-US`,onChange:e=>d({locale:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserCloakWebrtcIp,description:e.desc.browserCloakWebrtcIp,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:u.webrtcIp,placeholder:`203.0.113.10`,onChange:e=>d({webrtcIp:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserCloakFingerprintPlatform,description:e.desc.browserCloakFingerprintPlatform,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:u.fingerprintPlatform,placeholder:`macos`,onChange:e=>d({fingerprintPlatform:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(`div`,{className:`sm:col-span-2`,children:(0,Z.jsx)(Q,{label:e.label.browserCloakExtraArgs,description:e.desc.browserCloakExtraArgs,children:(0,Z.jsx)(`textarea`,{className:qe(),value:u.extraArgs,placeholder:`--disable-dev-shm-usage`,rows:3,onChange:e=>d({extraArgs:e.target.value})})})})]})]}),(0,Z.jsx)(w,{open:h,title:e.browserConfirmDownloadTitle,description:Je(e,M),confirmLabel:e.browserConfirmDownloadConfirm,cancelLabel:e.browserConfirmDownloadCancel,onConfirm:()=>void L(),onCancel:()=>m({type:`patch`,patch:{confirmOpen:!1}})})]})}function qe(){return`${J()} min-h-[4.5rem] resize-y font-mono text-xs`}function Je(e,t){if(!t)return e.browserConfirmDownloadBody;let n=[e.browserConfirmDownloadBody.replace(`{{version}}`,t.version??`—`).replace(`{{platform}}`,t.platform).replace(`{{url}}`,t.downloadUrl||`—`)];return t.expectedSha256?n.push(`SHA-256: ${t.expectedSha256.slice(0,16)}…`):n.push(e.browserCloakSha256Skipped),n.join(`
2
- `)}function Ye({m:e,form:t,onChange:n,testCloud:r,embedded:i=!1}){let[s,c]=(0,Y.useState)(`idle`),[u,d]=(0,Y.useState)(null),f=t.provider===`local`?`browserbase`:t.provider,m=p(h(e=>e.language)).providersSettings,g=P({show:m.show,hide:m.hide,copy:m.copy,copied:m.copied}),_=(0,Y.useCallback)(()=>me().then(e=>e.apiKey??null),[]),v=(0,Y.useCallback)(async()=>{c(`pending`),d(null);try{let n=await r(f,t.apiKey);n.reachable?(c(`ok`),d(e.browserCloudTestOk)):(c(`error`),d(e.browserCloudTestFailed.replace(`{{error}}`,n.error??`—`)))}catch(t){c(`error`),d(e.browserCloudTestFailed.replace(`{{error}}`,t instanceof Error?t.message:String(t)))}},[t.apiKey,e.browserCloudTestFailed,e.browserCloudTestOk,f,r]);return(0,Z.jsxs)(Le,{icon:ee,title:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,m:e,embedded:i,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:s===`pending`,onClick:()=>void v(),children:[s===`pending`?(0,Z.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(D,{className:`size-3.5`}),e.browserCloudTestConnection]}),children:[(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{label:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,children:(0,Z.jsxs)(a,{className:fe(),value:f,onChange:e=>n({provider:e.target.value}),children:[(0,Z.jsx)(o,{value:`browserbase`,children:e.browserCloudProviderBrowserbase}),(0,Z.jsx)(o,{value:`browser-use`,children:e.browserCloudProviderBrowserUse})]})}),(0,Z.jsx)(Q,{label:e.label.browserCloudApiKey,description:e.desc.browserCloudApiKey,children:(0,Z.jsx)(E,{value:t.apiKey,onChange:e=>n({apiKey:e}),placeholder:f===`browserbase`?`BROWSERBASE_API_KEY`:`BROWSER_USE_API_KEY`,labels:g,reveal:_,loadFailedLabel:`Failed to load key`})}),f===`browserbase`?(0,Z.jsx)(Q,{label:e.label.browserCloudProjectId,description:e.desc.browserCloudProjectId,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:t.projectId,placeholder:`BROWSERBASE_PROJECT_ID`,onChange:e=>n({projectId:e.target.value}),autoComplete:`off`})}):null,(0,Z.jsx)(Q,{label:e.label.browserCloudRegion,description:e.desc.browserCloudRegion,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:t.region,placeholder:`us-west-2`,onChange:e=>n({region:e.target.value}),autoComplete:`off`})})]}),u?(0,Z.jsx)(ze,{kind:s===`error`?`error`:`success`,message:u}):null]})}function Xe(e){let t=(0,X.c)(48),{m:n,installed:r,extensionDir:i,connected:a,busy:o,onOpenChrome:s,onCopyPath:c,onRevealFolder:l,pathBusy:d,folderBusy:f}=e,p;t[0]!==r||t[1]!==n.browserExtensionInstallStep1?(p={id:`install`,label:n.browserExtensionInstallStep1,done:r},t[0]=r,t[1]=n.browserExtensionInstallStep1,t[2]=p):p=t[2];let m=!!i&&a,h;t[3]!==o||t[4]!==i||t[5]!==f||t[6]!==n.browserExtensionCopyPath||t[7]!==n.browserExtensionInstallStep2FolderLabel||t[8]!==n.browserExtensionInstalling||t[9]!==n.browserExtensionOpenChrome||t[10]!==n.browserExtensionRevealFolder||t[11]!==c||t[12]!==s||t[13]!==l||t[14]!==d?(h=i?(0,Z.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-raised px-2.5 py-2 shadow-surface`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.browserExtensionInstallStep2FolderLabel}),(0,Z.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-fg`,children:i}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-3`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:o,onClick:s,children:n.browserExtensionOpenChrome}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:o,onClick:c,title:i,children:d?n.browserExtensionInstalling:n.browserExtensionCopyPath}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:o,onClick:l,title:i,children:f?n.browserExtensionInstalling:n.browserExtensionRevealFolder})]})]}):null,t[3]=o,t[4]=i,t[5]=f,t[6]=n.browserExtensionCopyPath,t[7]=n.browserExtensionInstallStep2FolderLabel,t[8]=n.browserExtensionInstalling,t[9]=n.browserExtensionOpenChrome,t[10]=n.browserExtensionRevealFolder,t[11]=c,t[12]=s,t[13]=l,t[14]=d,t[15]=h):h=t[15];let g;t[16]!==n.browserExtensionInstallStep2||t[17]!==m||t[18]!==h?(g={id:`load`,label:n.browserExtensionInstallStep2,done:m,detail:h},t[16]=n.browserExtensionInstallStep2,t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;t[20]!==a||t[21]!==n.browserExtensionInstallStep3?(_={id:`connect`,label:n.browserExtensionInstallStep3,done:a},t[20]=a,t[21]=n.browserExtensionInstallStep3,t[22]=_):_=t[22];let v;t[23]!==p||t[24]!==g||t[25]!==_?(v=[p,g,_],t[23]=p,t[24]=g,t[25]=_,t[26]=v):v=t[26];let y=v,b;t[27]===y?b=t[28]:(b=y.filter(Ze),t[27]=y,t[28]=b);let x=b.length,S=n.browserExtensionInstallGuideTitle,C;t[29]===n.browserExtensionInstallGuideTitle?C=t[30]:(C=(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:n.browserExtensionInstallGuideTitle}),t[29]=n.browserExtensionInstallGuideTitle,t[30]=C);let w;t[31]!==x||t[32]!==n.browserExtensionChecklistProgress||t[33]!==y.length?(w=n.browserExtensionChecklistProgress.replace(`{{done}}`,String(x)).replace(`{{total}}`,String(y.length)),t[31]=x,t[32]=n.browserExtensionChecklistProgress,t[33]=y.length,t[34]=w):w=t[34];let T;t[35]===w?T=t[36]:(T=(0,Z.jsx)(`span`,{className:`ml-auto text-xs font-normal text-fg-muted`,children:w}),t[35]=w,t[36]=T);let E;t[37]!==T||t[38]!==C?(E=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[C,T]}),t[37]=T,t[38]=C,t[39]=E):E=t[39];let D;t[40]!==n.browserExtensionChecklistDone||t[41]!==n.browserExtensionChecklistPending||t[42]!==y?(D=(0,Z.jsx)(`ol`,{className:`flex flex-col gap-3`,children:y.map((e,t)=>(0,Z.jsxs)(`li`,{className:`flex gap-2.5`,children:[(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,"aria-hidden":!0,children:e.done?(0,Z.jsx)(N,{className:`size-4 text-emerald-500`,strokeWidth:2}):(0,Z.jsx)(L,{className:`size-4 text-fg-subtle`,strokeWidth:1.75})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`p`,{className:u(`text-[11px] leading-relaxed`,e.done?`text-fg-muted line-through decoration-fg-subtle/60`:`text-fg`),children:[(0,Z.jsxs)(`span`,{className:`sr-only`,children:[e.done?n.browserExtensionChecklistDone:n.browserExtensionChecklistPending,` `]}),t+1,`. `,e.label]}),e.detail]})]},e.id))}),t[40]=n.browserExtensionChecklistDone,t[41]=n.browserExtensionChecklistPending,t[42]=y,t[43]=D):D=t[43];let O;return t[44]!==n.browserExtensionInstallGuideTitle||t[45]!==E||t[46]!==D?(O=(0,Z.jsxs)(`div`,{"aria-label":S,className:`rounded-xl bg-surface-base p-3`,children:[E,D]}),t[44]=n.browserExtensionInstallGuideTitle,t[45]=E,t[46]=D,t[47]=O):O=t[47],O}function Ze(e){return e.done}var Qe=19820,$e=3e4;function et({m:e,probe:t,artifacts:n,onChange:r,startBridge:i,stopBridge:a,disconnectExtension:o,installArtifacts:s,refetchArtifacts:c,openExtensionChrome:u,revealExtensionFolder:d,form:p,embedded:m=!1}){let[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(null),x=p.port??Qe,S=p.host||`127.0.0.1`,C=`ws://${S}:${x}/browser-ext`,w=t.kind===`ok`&&t.data.running,T=t.kind===`ok`&&t.data.connected,E=t.kind===`ok`&&t.data.bridgeHeld===!0,O=t.kind===`ok`&&t.data.portConflict===!0,A=w||E,j=n.kind===`ok`?n.data:t.kind===`ok`?t.data.artifacts:void 0,M=j?.installed===!0,N=j?.extensionDir,P=j?.needsChromeReload===!0,I=t.kind===`ok`?T?{icon:H,color:`text-green-500`,label:e.browserExtensionConnected}:w?{icon:D,color:`text-amber-500`,label:e.browserExtensionWaiting}:{icon:V,color:`text-fg-muted`,label:e.browserExtensionServerOff}:{icon:V,color:`text-fg-muted`,label:`…`},L=I.icon,R=(0,Y.useCallback)(async()=>{if(!h){g(`start`),v(null);try{await i({host:S,port:x})}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,S,x,i]),B=(0,Y.useCallback)(async()=>{if(!h){g(`stop`),v(null);try{await a()}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,a]),ee=(0,Y.useCallback)(async()=>{if(!h){g(`disconnect`),v(null);try{await o()}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,o]),te=(0,Y.useCallback)(async()=>{if(!h){g(`install`),v(null),b(null);try{let t=await s({force:M});t?.extensionDir?b(`${e.browserExtensionInstalled}: ${t.extensionDir}`):b(e.browserExtensionInstalled),await c()}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,s,M,e.browserExtensionInstalled,c]),U=(0,Y.useCallback)(async()=>{if(!h){g(`open`),v(null);try{await u()}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,u]),W=(0,Y.useCallback)(async()=>{if(!(!N||h)){g(`path`),v(null),b(null);try{await f(N)?b(e.browserExtensionPathCopied):b(e.browserExtensionPathCopyFailed)}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,N,e.browserExtensionPathCopied,e.browserExtensionPathCopyFailed]),ne=(0,Y.useCallback)(async()=>{if(!(!N||h)){g(`folder`),v(null),b(null);try{await d(),b(e.browserExtensionFolderOpened)}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,N,e.browserExtensionFolderOpened,d]),G=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:h!==null,onClick:()=>void te(),children:[h===`install`?(0,Z.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(z,{className:`size-3.5`}),h===`install`?e.browserExtensionInstalling:e.browserExtensionInstall]}),A?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:h!==null,onClick:()=>void B(),children:[h===`stop`?(0,Z.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(K,{className:`size-3.5`}),e.browserExtensionStopBridge]}):(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:h!==null,onClick:()=>void R(),children:[h===`start`?(0,Z.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(k,{className:`size-3.5`}),h===`start`?e.browserExtensionStarting:e.browserExtensionStartBridge]}),T?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:h!==null,onClick:()=>void ee(),children:[h===`disconnect`?(0,Z.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(V,{className:`size-3.5`}),e.browserExtensionDisconnect]}):null]});return(0,Z.jsx)(Le,{icon:F,title:e.browserBackendExtension,description:e.browserExtensionDownloadHint,m:e,embedded:m,primaryAction:G,advancedTitle:e.browserAdvancedShow,advanced:(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{label:e.label.browserExtensionPort,description:e.desc.browserExtensionPort,children:(0,Z.jsx)(`input`,{type:`number`,className:J(),min:1024,max:65535,value:p.port??``,placeholder:String(Qe),onChange:e=>{let t=e.target.value;r({port:t===``?void 0:Number.parseInt(t,10)})}})}),(0,Z.jsx)(Q,{label:e.label.browserExtensionHost,description:e.desc.browserExtensionHost,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:p.host,placeholder:`127.0.0.1`,onChange:e=>r({host:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserExtensionConnectionTimeout,description:e.desc.browserExtensionConnectionTimeout,children:(0,Z.jsx)(`input`,{type:`number`,className:J(),min:1,step:1,value:p.connectionTimeoutMs==null?``:Math.round(p.connectionTimeoutMs/1e3),placeholder:String($e/1e3),onChange:e=>{let t=e.target.value;r({connectionTimeoutMs:t===``?void 0:Math.max(1,Number.parseInt(t,10))*1e3})}})})]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:C}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs ${I.color}`,children:[(0,Z.jsx)(L,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:I.label})]})]}),(0,Z.jsx)(Xe,{m:e,installed:M,extensionDir:N,connected:T,busy:h!==null,pathBusy:h===`path`,folderBusy:h===`folder`,onOpenChrome:()=>void U(),onCopyPath:()=>void W(),onRevealFolder:()=>void ne()}),P?(0,Z.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:e.browserExtensionNeedsChromeReload}):null,O?(0,Z.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:e.browserExtensionPortConflict.replace(`{{port}}`,String(x))}):null,y?(0,Z.jsx)(ze,{kind:`success`,message:y}):null,_?(0,Z.jsx)(ze,{kind:`error`,message:_}):null]})})}function tt(e){let t=(0,X.c)(41),{m:n,doctor:r,refetch:i,applyDoctor:a,installStream:o,embedded:s}=e,c=s===void 0?!1:s,[u,d]=(0,Y.useState)(`idle`),[f,p]=(0,Y.useState)(null),{progress:m,running:h,cancelling:g,run:_,reset:v,cancel:y}=o,b;t[0]!==a||t[1]!==n.browserPlaywrightInstallFailed||t[2]!==n.browserPlaywrightInstalled||t[3]!==i||t[4]!==v||t[5]!==_?(b=async()=>{d(`installing`),p(null),v();let e=await _({fallbackError:n.browserPlaywrightInstallFailed});if(!e.ok){if(e.error===`busy`){d(`installing`);return}if(e.error===`cancelled`){d(`idle`),p(null),v();return}d(`failed`),p(e.errorMessage??n.browserPlaywrightInstallFailed);return}e.payload&&a?.(e.payload),d(`installed`),p(e.payload?.executablePath?`${n.browserPlaywrightInstalled}: ${e.payload.executablePath}`:n.browserPlaywrightInstalled),await i()},t[0]=a,t[1]=n.browserPlaywrightInstallFailed,t[2]=n.browserPlaywrightInstalled,t[3]=i,t[4]=v,t[5]=_,t[6]=b):b=t[6];let x=b,S=r.kind===`loading`?`checking`:r.kind===`error`?`error`:r.kind===`ok`?r.data.installed?`ready`:`not_installed`:`unknown`,C=r.kind===`ok`&&r.data.installed&&r.data.executablePath?r.data.executablePath:void 0,w=r.kind===`ok`&&r.data.installed,T=u===`installing`||h,E;t[7]===x?E=t[8]:(E=()=>void x(),t[7]=x,t[8]=E);let D;t[9]!==w||t[10]!==T||t[11]!==u?(D=T?(0,Z.jsx)(l,{className:`size-3.5 animate-spin`}):w?(0,Z.jsx)(A,{className:`size-3.5`}):u===`installed`?(0,Z.jsx)(N,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(z,{className:`size-3.5`}),t[9]=w,t[10]=T,t[11]=u,t[12]=D):D=t[12];let O=T?n.browserPlaywrightInstalling:w?n.browserReinstall:n.browserPlaywrightInstall,k;t[13]!==T||t[14]!==E||t[15]!==D||t[16]!==O?(k=(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:T,onClick:E,children:[D,O]}),t[13]=T,t[14]=E,t[15]=D,t[16]=O,t[17]=k):k=t[17];let j;t[18]===n.browserPlaywrightManualInstall?j=t[19]:(j=(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:n.browserPlaywrightManualInstall}),t[18]=n.browserPlaywrightManualInstall,t[19]=j);let M;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(`code`,{className:`mt-2 block w-fit rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg`,children:`node node_modules/playwright-core/cli.js install chromium`}),t[20]=M):M=t[20];let P;t[21]===j?P=t[22]:(P=(0,Z.jsxs)(`div`,{className:`text-xs`,children:[j,M]}),t[21]=j,t[22]=P);let F;t[23]!==y||t[24]!==g||t[25]!==n||t[26]!==m||t[27]!==h?(F=h?(0,Z.jsx)(Ue,{m:n,progress:m,showLogs:!0,cancelling:g,onCancel:()=>void y()}):null,t[23]=y,t[24]=g,t[25]=n,t[26]=m,t[27]=h,t[28]=F):F=t[28];let I;t[29]!==f||t[30]!==u?(I=f?(0,Z.jsx)(ze,{kind:u===`failed`?`error`:`success`,message:f}):null,t[29]=f,t[30]=u,t[31]=I):I=t[31];let L;return t[32]!==c||t[33]!==n||t[34]!==C||t[35]!==S||t[36]!==F||t[37]!==I||t[38]!==k||t[39]!==P?(L=(0,Z.jsxs)(Le,{icon:R,title:n.browserPlaywrightGuideTitle,description:n.browserPlaywrightGuideDesc,status:S,statusDetail:C,m:n,embedded:c,primaryAction:k,children:[P,F,I]}),t[32]=c,t[33]=n,t[34]=C,t[35]=S,t[36]=F,t[37]=I,t[38]=k,t[39]=P,t[40]=L):L=t[40],L}async function nt(e){let t=await g(e),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1){let e=typeof n.error==`string`?n.error:n.error?.message;throw Error(e||`Request failed: ${t.status}`)}if(n.payload===void 0)throw Error(`Empty payload`);return n.payload}async function $(e,t){let n=await g(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})}),r=await n.json().catch(()=>({}));if(!n.ok||r.ok===!1){let e=typeof r.error==`string`?r.error:r.error?.message;throw Error(e||`Request failed: ${n.status}`)}if(r.payload===void 0)throw Error(`Empty payload`);return r.payload}var rt={playwright:{kind:`idle`},cloak:{kind:`idle`},extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};function it(e,t){switch(t.type){case`playwright`:return{...e,playwright:t.state};case`cloak`:return{...e,cloak:t.state};case`extension`:return{...e,extension:t.state};case`extension-artifacts`:return{...e,extensionArtifacts:t.state};case`playwright-idle`:return{...e,playwright:{kind:`idle`}};case`cloak-idle`:return{...e,cloak:{kind:`idle`}};case`extension-idle`:return{...e,extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};case`extension-start-probe`:return{...e,extension:e.extension.kind===`ok`?e.extension:{kind:`loading`}};case`extension-artifacts-start-probe`:return{...e,extensionArtifacts:e.extensionArtifacts.kind===`ok`?e.extensionArtifacts:{kind:`loading`}}}}function at(e){let[t,n]=(0,Y.useReducer)(it,rt),{playwright:r,cloak:i,extension:a,extensionArtifacts:o}=t,s=(0,Y.useCallback)(async()=>{n({type:`playwright`,state:{kind:`loading`}});try{n({type:`playwright`,state:{kind:`ok`,data:await nt(_(`/api/browser/playwright/doctor`))}})}catch(e){n({type:`playwright`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[]),c=(0,Y.useCallback)(async t=>{n({type:`cloak`,state:{kind:`loading`}});let r=(t?.cacheDir??e.cacheDir??``).trim(),i=(t?.binaryPath??e.binaryPath??``).trim(),a=new URLSearchParams;r&&a.set(`cacheDir`,r),i&&a.set(`binaryPath`,i);try{let e=await nt(_(`/api/browser/cloakbrowser/doctor${a.size?`?${a}`:``}`));return n({type:`cloak`,state:{kind:`ok`,data:e}}),e}catch(e){return n({type:`cloak`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}}),null}},[e.binaryPath,e.cacheDir]),l=(0,Y.useCallback)(e=>{n({type:`playwright`,state:{kind:`ok`,data:e}})},[]),u=(0,Y.useCallback)(e=>{n({type:`cloak`,state:{kind:`ok`,data:e}})},[]),d=(0,Y.useCallback)(async()=>nt(_(`/api/browser/cloakbrowser/status`)),[]),f=(0,Y.useCallback)(async()=>$(_(`/api/browser/cloakbrowser/launch`),{}),[]),p=e.browserEnabled===!0&&e.probeExtension===!0,m=e.browserEnabled===!0&&e.probeLocal===!0,h=e.browserEnabled===!0&&e.probeCloak===!0,{extensionHost:v,extensionPort:y}=e,b=(0,Y.useCallback)(async()=>{let e=new URLSearchParams({probe:`1`});v&&e.set(`host`,v),y!==void 0&&e.set(`port`,String(y)),n({type:`extension-start-probe`});try{let t=await g(_(`/api/browser/extension-status?${e}`),{signal:AbortSignal.timeout(3e3)}),r=await t.json().catch(()=>({}));if(!t.ok){n({type:`extension`,state:{kind:`error`,message:`HTTP ${t.status}`}});return}n({type:`extension`,state:{kind:`ok`,data:{running:r.running===!0,connected:r.connected===!0,backend:r.backend,artifacts:r.artifacts,bridgeHeld:r.bridgeHeld===!0,refCount:typeof r.refCount==`number`?r.refCount:void 0,manualBridge:r.manualBridge===!0,portConflict:r.portConflict===!0}}})}catch(e){n({type:`extension`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[v,y]),x=(0,Y.useCallback)(async()=>{n({type:`extension-artifacts-start-probe`});try{let e=await nt(_(`/api/browser/extension/doctor`));return n({type:`extension-artifacts`,state:{kind:`ok`,data:e}}),e}catch(e){return n({type:`extension-artifacts`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}}),null}},[]),S=(0,Y.useCallback)(async e=>{let t=(await $(_(`/api/browser/extension/install`),{force:e?.force??!1})).doctor;return n({type:`extension-artifacts`,state:{kind:`ok`,data:t}}),await b(),t},[b]),C=(0,Y.useCallback)(async()=>{await $(_(`/api/browser/extension/open`),{action:`chrome`})},[]),w=(0,Y.useCallback)(async()=>{await $(_(`/api/browser/extension/open`),{action:`folder`})},[]);(0,Y.useEffect)(()=>{if(!m){n({type:`playwright-idle`});return}s()},[m,s]),(0,Y.useEffect)(()=>{if(!h){n({type:`cloak-idle`});return}c()},[h,c]);let T=(0,Y.useRef)(p);T.current!==p&&(T.current=p,p||n({type:`extension-idle`})),(0,Y.useEffect)(()=>{if(!p)return;b(),x();let e=setInterval(()=>void b(),5e3);return()=>clearInterval(e)},[p,b,x]);let E=(0,Y.useCallback)(async e=>{await $(_(`/api/browser/extension/start`),{host:e?.host??v,port:e?.port??y}),await b()},[v,y,b]),D=(0,Y.useCallback)(async()=>{await $(_(`/api/browser/extension/stop`),{}),await b()},[b]),O=(0,Y.useCallback)(async()=>{await $(_(`/api/browser/extension/disconnect`),{}),await b()},[b]),k=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{if(!p||e.activeBackend!==`extension`){k.current=null;return}if(a.kind!==`ok`||a.data.running||a.data.bridgeHeld)return;let t=`${v}:${y??19820}`;k.current!==t&&(k.current=t,E({host:v,port:y}).catch(()=>{k.current=null}))},[p,a,v,y,e.activeBackend,E]),{playwright:r,cloak:i,extension:a,extensionArtifacts:o,refetchPlaywright:s,applyPlaywrightDoctor:l,refetchCloak:c,applyCloakDoctor:u,fetchCloakRuntimeStatus:d,launchCloak:f,refetchExtension:b,refetchExtensionArtifacts:x,installExtensionArtifacts:S,openExtensionChrome:C,revealExtensionFolder:w,pingCdp:(0,Y.useCallback)(async e=>$(_(`/api/browser/cdp/ping`),{cdpUrl:e}),[]),testCloud:(0,Y.useCallback)(async(e,t)=>$(_(`/api/browser/cloud/test-connection`),{provider:e,apiKey:t}),[]),launchCdp:(0,Y.useCallback)(async e=>$(_(`/api/browser/cdp/launch`),{executablePath:e}),[]),stopCdp:(0,Y.useCallback)(async e=>{await $(_(`/api/browser/cdp/stop`),{port:e})},[]),listCdpInstances:(0,Y.useCallback)(async()=>(await nt(_(`/api/browser/cdp/instances`))).instances,[]),startExtensionBridge:E,stopExtensionBridge:D,disconnectExtension:O}}var ot=`
3
-
4
- `,st=/\r\n/g,ct={playwright:`/api/browser/playwright/install/stream`,cloakbrowser:`/api/browser/cloakbrowser/install/stream`},lt={playwright:`/api/browser/playwright/install/cancel`,cloakbrowser:`/api/browser/cloakbrowser/install/cancel`},ut=8;function dt(){return{phase:null,message:null,percent:null,lines:[]}}function ft(e,t){let n={phase:t.phase,message:t.message??t.line??e.message,percent:t.percent??e.percent,lines:e.lines};if(t.line){let r=[...e.lines,t.line];n.lines=r.length>ut?r.slice(-8):r}return n}async function pt(e,t,n){let r=e.getReader(),i=new TextDecoder,a=``,o=null,s=e=>{let n=``,r=``;for(let t of e.split(`
5
- `)){let e=t.replace(/\r$/,``);e.startsWith(`event:`)?n=e.slice(6).trim():e.startsWith(`data:`)&&(r+=e.slice(5).trimStart())}if(r){if(n===`progress`){try{let e=JSON.parse(r);e&&typeof e==`object`&&typeof e.phase==`string`&&t(e)}catch{}return}if(n===`result`)try{let e=JSON.parse(r);o=e.ok?{ok:!0,payload:e.payload}:{ok:!1,error:String(e.error??`unknown`),message:typeof e.message==`string`?e.message:void 0,status:e.error===`busy`?409:e.error===`cancelled`?499:500}}catch{o={ok:!1,error:`parse`,status:0}}}};try{let e=async()=>{if(o!==null)return o;if(n?.aborted)return await r.cancel().catch(()=>{}),{ok:!1,error:`cancelled`,status:499};let{done:t,value:c}=await r.read();if(t)return o??{ok:!1,error:`no-result`,status:0};a+=i.decode(c,{stream:!0}),a=a.replace(st,`
6
- `);let l=a.split(ot);a=l.pop()??``;for(let e of l)e.length&&s(e);return e()},t=await e();if(t)return t}catch(e){if(n?.aborted||e instanceof DOMException&&e.name===`AbortError`)return{ok:!1,error:`cancelled`,status:499};throw e}finally{r.releaseLock()}return o||(n?.aborted?{ok:!1,error:`cancelled`,status:499}:{ok:!1,error:`no-result`,status:0})}function mt(e){let[t,n]=(0,Y.useState)(dt),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(!1),s=(0,Y.useRef)(!1),c=(0,Y.useRef)(null),l=(0,Y.useCallback)(()=>{s.current||n(dt())},[]),u=(0,Y.useCallback)(async()=>{if(s.current){o(!0);try{await g(_(lt[e]),{method:`POST`}).catch(()=>{}),c.current?.abort()}finally{o(!1)}}},[e]);return{progress:t,running:r,cancelling:a,run:(0,Y.useCallback)(async t=>{if(s.current)return{ok:!1,error:`busy`,status:409,errorMessage:`An install for this browser type is already in progress.`};let r=new AbortController;c.current=r,s.current=!0,i(!0),n(dt());try{let i=await g(_(ct[e]),{method:`POST`,headers:{Accept:`text/event-stream`,...t.body===void 0?{}:{"Content-Type":`application/json`}},body:t.body===void 0?void 0:JSON.stringify(t.body),signal:r.signal});if(!i.ok||!i.body){let e=await i.text().catch(()=>``),t=`HTTP ${i.status}`;try{let n=JSON.parse(e);typeof n.message==`string`?t=n.message:typeof n.error==`string`&&(t=n.error)}catch{e&&(t=e.slice(0,500))}return{ok:!1,error:i.status===409?`busy`:`http`,status:i.status,errorMessage:t}}let a=await pt(i.body,e=>{n(t=>ft(t,e))},r.signal);return a.ok?a:a.error===`cancelled`?{...a,errorMessage:void 0}:{...a,errorMessage:a.message??(a.error===`busy`?`An install for this browser type is already in progress.`:t.fallbackError)}}catch(e){return r.signal.aborted||e instanceof DOMException&&e.name===`AbortError`?{ok:!1,error:`cancelled`,status:499}:{ok:!1,error:`network`,errorMessage:e instanceof Error?e.message:t.fallbackError}}finally{c.current===r&&(c.current=null),s.current=!1,i(!1),o(!1)}},[e]),reset:l,cancel:u}}function ht(e){let t=(0,X.c)(150),{a:n,form:r,update:i,activeTab:a,setActiveTab:o}=e,s=h(_t),l=te(gt),d=mt(`playwright`),f=mt(`cloakbrowser`),p=r.browserEnabled&&(a===`overview`||a===`extension`),m=r.browserEnabled&&(a===`overview`||a===`local`),g=r.browserEnabled&&(a===`overview`||a===`cloakbrowser`),_;t[0]!==r.browserBackend||t[1]!==r.browserCloakBinaryPath||t[2]!==r.browserCloakCacheDir||t[3]!==r.browserEnabled||t[4]!==r.browserExtensionHost||t[5]!==r.browserExtensionPort||t[6]!==g||t[7]!==p||t[8]!==m?(_={cacheDir:r.browserCloakCacheDir,binaryPath:r.browserCloakBinaryPath,browserEnabled:r.browserEnabled,activeBackend:r.browserBackend,probeExtension:p,probeLocal:m,probeCloak:g,extensionHost:r.browserExtensionHost,extensionPort:r.browserExtensionPort},t[0]=r.browserBackend,t[1]=r.browserCloakBinaryPath,t[2]=r.browserCloakCacheDir,t[3]=r.browserEnabled,t[4]=r.browserExtensionHost,t[5]=r.browserExtensionPort,t[6]=g,t[7]=p,t[8]=m,t[9]=_):_=t[9];let v=at(_),y;t[10]===v.playwright?y=t[11]:(y=Oe(v.playwright),t[10]=v.playwright,t[11]=y);let b=y,x;t[12]===v.cloak?x=t[13]:(x=Oe(v.cloak),t[12]=v.cloak,t[13]=x);let S=x,C;t[14]===v.extension?C=t[15]:(C=Ae(v.extension),t[14]=v.extension,t[15]=C);let w=C,E;t[16]!==n||t[17]!==v.extension?(E=je(v.extension,n),t[16]=n,t[17]=v.extension,t[18]=E):E=t[18];let D=E,O;t[19]!==n||t[20]!==S||t[21]!==w||t[22]!==D||t[23]!==b||t[24]!==l?(O=[{value:`extension`,icon:F,name:n.browserBackendExtension,tagline:n.browserModeExtTagline,status:w,statusLabel:D},{value:`local`,icon:R,name:n.browserBackendLocal,tagline:n.browserModeLocalTagline,status:b,statusLabel:ke(b,n)},{value:`cloakbrowser`,icon:T,name:n.browserBackendCloakBrowser,tagline:n.browserModeCloakTagline,status:S,statusLabel:ke(S,n)},{value:`cdp`,icon:I,name:n.browserBackendCdp,tagline:n.browserModeCdpTagline},{value:`cloud`,icon:ee,name:n.browserBackendCloud,tagline:n.browserModeCloudTagline}].filter(e=>_e(e.value,l)),t[19]=n,t[20]=S,t[21]=w,t[22]=D,t[23]=b,t[24]=l,t[25]=O):O=t[25];let k=O,A;t[26]!==o||t[27]!==i?(A=e=>{i({browserEnabled:!0,browserBackend:e}),o(e)},t[26]=o,t[27]=i,t[28]=A):A=t[28];let j=A,M=!r.browserEnabled&&`pointer-events-none opacity-40`,N;t[29]===M?N=t[30]:(N=u(`flex flex-col gap-5 transition-opacity`,M),t[29]=M,t[30]=N);let P=!r.browserEnabled,L;t[31]!==n||t[32]!==a||t[33]!==v.disconnectExtension||t[34]!==v.extension||t[35]!==v.extensionArtifacts||t[36]!==v.installExtensionArtifacts||t[37]!==v.openExtensionChrome||t[38]!==v.refetchExtensionArtifacts||t[39]!==v.revealExtensionFolder||t[40]!==v.startExtensionBridge||t[41]!==v.stopExtensionBridge||t[42]!==r.browserExtensionConnectionTimeout||t[43]!==r.browserExtensionHost||t[44]!==r.browserExtensionPort||t[45]!==i?(L=a===`extension`?(0,Z.jsx)(q,{children:(0,Z.jsx)(et,{embedded:!0,m:n,probe:v.extension,artifacts:v.extensionArtifacts,form:{port:r.browserExtensionPort,host:r.browserExtensionHost,connectionTimeoutMs:r.browserExtensionConnectionTimeout},onChange:e=>i({...e.port===void 0?{}:{browserExtensionPort:e.port},...e.host===void 0?{}:{browserExtensionHost:e.host},...e.connectionTimeoutMs===void 0?{}:{browserExtensionConnectionTimeout:e.connectionTimeoutMs}}),startBridge:v.startExtensionBridge,stopBridge:v.stopExtensionBridge,disconnectExtension:v.disconnectExtension,installArtifacts:v.installExtensionArtifacts,refetchArtifacts:v.refetchExtensionArtifacts,openExtensionChrome:v.openExtensionChrome,revealExtensionFolder:v.revealExtensionFolder})}):null,t[31]=n,t[32]=a,t[33]=v.disconnectExtension,t[34]=v.extension,t[35]=v.extensionArtifacts,t[36]=v.installExtensionArtifacts,t[37]=v.openExtensionChrome,t[38]=v.refetchExtensionArtifacts,t[39]=v.revealExtensionFolder,t[40]=v.startExtensionBridge,t[41]=v.stopExtensionBridge,t[42]=r.browserExtensionConnectionTimeout,t[43]=r.browserExtensionHost,t[44]=r.browserExtensionPort,t[45]=i,t[46]=L):L=t[46];let z;t[47]!==n||t[48]!==a||t[49]!==v.applyPlaywrightDoctor||t[50]!==v.playwright||t[51]!==v.refetchPlaywright||t[52]!==d?(z=a===`local`?(0,Z.jsx)(q,{children:(0,Z.jsx)(tt,{embedded:!0,m:n,doctor:v.playwright,refetch:v.refetchPlaywright,applyDoctor:v.applyPlaywrightDoctor,installStream:d})}):null,t[47]=n,t[48]=a,t[49]=v.applyPlaywrightDoctor,t[50]=v.playwright,t[51]=v.refetchPlaywright,t[52]=d,t[53]=z):z=t[53];let B;t[54]!==n||t[55]!==a||t[56]!==f||t[57]!==v.applyCloakDoctor||t[58]!==v.cloak||t[59]!==v.fetchCloakRuntimeStatus||t[60]!==v.launchCloak||t[61]!==v.refetchCloak||t[62]!==r.browserCloakBinaryPath||t[63]!==r.browserCloakCacheDir||t[64]!==r.browserCloakExtraArgs||t[65]!==r.browserCloakFingerprintPlatform||t[66]!==r.browserCloakKeepOpen||t[67]!==r.browserCloakLocale||t[68]!==r.browserCloakTemporaryProfile||t[69]!==r.browserCloakTimezone||t[70]!==r.browserCloakWebrtcIp||t[71]!==r.browserHumanPreset||t[72]!==r.browserHumanize||t[73]!==i?(B=a===`cloakbrowser`?(0,Z.jsx)(q,{children:(0,Z.jsx)(Ke,{embedded:!0,m:n,doctor:v.cloak,refetch:v.refetchCloak,applyDoctor:v.applyCloakDoctor,installStream:f,fetchRuntimeStatus:v.fetchCloakRuntimeStatus,launchCloak:v.launchCloak,form:{cacheDir:r.browserCloakCacheDir,binaryPath:r.browserCloakBinaryPath,keepOpen:r.browserCloakKeepOpen,temporaryProfile:r.browserCloakTemporaryProfile,humanize:r.browserHumanize,humanPreset:r.browserHumanPreset,timezone:r.browserCloakTimezone,locale:r.browserCloakLocale,webrtcIp:r.browserCloakWebrtcIp,fingerprintPlatform:r.browserCloakFingerprintPlatform,extraArgs:r.browserCloakExtraArgs},onChange:e=>i({...e.cacheDir===void 0?{}:{browserCloakCacheDir:e.cacheDir},...e.binaryPath===void 0?{}:{browserCloakBinaryPath:e.binaryPath},...e.keepOpen===void 0?{}:{browserCloakKeepOpen:e.keepOpen},...e.temporaryProfile===void 0?{}:{browserCloakTemporaryProfile:e.temporaryProfile},...e.humanize===void 0?{}:{browserHumanize:e.humanize},...e.humanPreset===void 0?{}:{browserHumanPreset:e.humanPreset},...e.timezone===void 0?{}:{browserCloakTimezone:e.timezone},...e.locale===void 0?{}:{browserCloakLocale:e.locale},...e.webrtcIp===void 0?{}:{browserCloakWebrtcIp:e.webrtcIp},...e.fingerprintPlatform===void 0?{}:{browserCloakFingerprintPlatform:e.fingerprintPlatform},...e.extraArgs===void 0?{}:{browserCloakExtraArgs:e.extraArgs}})})}):null,t[54]=n,t[55]=a,t[56]=f,t[57]=v.applyCloakDoctor,t[58]=v.cloak,t[59]=v.fetchCloakRuntimeStatus,t[60]=v.launchCloak,t[61]=v.refetchCloak,t[62]=r.browserCloakBinaryPath,t[63]=r.browserCloakCacheDir,t[64]=r.browserCloakExtraArgs,t[65]=r.browserCloakFingerprintPlatform,t[66]=r.browserCloakKeepOpen,t[67]=r.browserCloakLocale,t[68]=r.browserCloakTemporaryProfile,t[69]=r.browserCloakTimezone,t[70]=r.browserCloakWebrtcIp,t[71]=r.browserHumanPreset,t[72]=r.browserHumanize,t[73]=i,t[74]=B):B=t[74];let V;t[75]!==n||t[76]!==a||t[77]!==v.launchCdp||t[78]!==v.listCdpInstances||t[79]!==v.pingCdp||t[80]!==v.stopCdp||t[81]!==r.browserCdpUrl||t[82]!==i?(V=a===`cdp`?(0,Z.jsx)(q,{children:(0,Z.jsx)(Ve,{embedded:!0,m:n,cdpUrl:r.browserCdpUrl,onCdpUrlChange:e=>i({browserCdpUrl:e}),launch:v.launchCdp,stop:v.stopCdp,listInstances:v.listCdpInstances,ping:v.pingCdp})}):null,t[75]=n,t[76]=a,t[77]=v.launchCdp,t[78]=v.listCdpInstances,t[79]=v.pingCdp,t[80]=v.stopCdp,t[81]=r.browserCdpUrl,t[82]=i,t[83]=V):V=t[83];let H;t[84]!==n||t[85]!==a||t[86]!==v.testCloud||t[87]!==r.browserCloudApiKey||t[88]!==r.browserCloudProjectId||t[89]!==r.browserCloudProvider||t[90]!==r.browserCloudRegion||t[91]!==i?(H=a===`cloud`?(0,Z.jsx)(q,{children:(0,Z.jsx)(Ye,{embedded:!0,m:n,form:{provider:r.browserCloudProvider,apiKey:r.browserCloudApiKey,projectId:r.browserCloudProjectId,region:r.browserCloudRegion},onChange:e=>i({...e.provider===void 0?{}:{browserCloudProvider:e.provider},...e.apiKey===void 0?{}:{browserCloudApiKey:e.apiKey},...e.projectId===void 0?{}:{browserCloudProjectId:e.projectId},...e.region===void 0?{}:{browserCloudRegion:e.region}}),testCloud:v.testCloud})}):null,t[84]=n,t[85]=a,t[86]=v.testCloud,t[87]=r.browserCloudApiKey,t[88]=r.browserCloudProjectId,t[89]=r.browserCloudProvider,t[90]=r.browserCloudRegion,t[91]=i,t[92]=H):H=t[92];let U;t[93]!==L||t[94]!==z||t[95]!==B||t[96]!==V||t[97]!==H||t[98]!==N||t[99]!==P?(U=(0,Z.jsxs)(`div`,{className:N,"aria-hidden":P,children:[L,z,B,V,H]}),t[93]=L,t[94]=z,t[95]=B,t[96]=V,t[97]=H,t[98]=N,t[99]=P,t[100]=U):U=t[100];let W=U;if(a===`overview`){let e;t[101]!==n||t[102]!==r.browserEnabled||t[103]!==j?(e=r.browserEnabled?null:(0,Z.jsx)(Ee,{m:n,onStart:j}),t[101]=n,t[102]=r.browserEnabled,t[103]=j,t[104]=e):e=t[104];let a;t[105]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,"aria-hidden":!0,children:(0,Z.jsx)(c,{className:`size-4`,strokeWidth:1.75})}),t[105]=a):a=t[105];let l;t[106]===i?l=t[107]:(l=e=>i({browserEnabled:e.target.checked}),t[106]=i,t[107]=l);let d;t[108]!==r.browserEnabled||t[109]!==l?(d=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserEnabled,onChange:l}),t[108]=r.browserEnabled,t[109]=l,t[110]=d):d=t[110];let f;t[111]===n.browserEnabledOn?f=t[112]:(f=(0,Z.jsx)(`span`,{children:n.browserEnabledOn}),t[111]=n.browserEnabledOn,t[112]=f);let p;t[113]!==d||t[114]!==f?(p=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[d,f]}),t[113]=d,t[114]=f,t[115]=p):p=t[115];let m;t[116]!==n.desc.browserEnabled||t[117]!==n.label.browserEnabled||t[118]!==p?(m=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[a,(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(Q,{label:n.label.browserEnabled,description:n.desc.browserEnabled,children:p})})]}),t[116]=n.desc.browserEnabled,t[117]=n.label.browserEnabled,t[118]=p,t[119]=m):m=t[119];let h;t[120]!==n.browserDocsLink||t[121]!==s?(h=(0,Z.jsx)(we,{language:s,label:n.browserDocsLink,className:`shrink-0 pt-1`}),t[120]=n.browserDocsLink,t[121]=s,t[122]=h):h=t[122];let g;t[123]!==m||t[124]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[m,h]}),t[123]=m,t[124]=h,t[125]=g):g=t[125];let _;t[126]!==n||t[127]!==r.browserBackend||t[128]!==r.browserEnabled||t[129]!==k||t[130]!==o||t[131]!==i?(_=r.browserEnabled?(0,Z.jsx)(`div`,{id:xe(`connection`),className:u(`scroll-mt-24 transition-opacity`,!r.browserEnabled&&`pointer-events-none opacity-40`),children:(0,Z.jsx)(ye,{m:n,value:r.browserBackend,onChange:e=>i({browserBackend:e}),onOpenConfig:o,options:k})}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.browserDisabledHint}),t[126]=n,t[127]=r.browserBackend,t[128]=r.browserEnabled,t[129]=k,t[130]=o,t[131]=i,t[132]=_):_=t[132];let v;t[133]!==g||t[134]!==_?(v=(0,Z.jsx)(q,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[g,_]})}),t[133]=g,t[134]=_,t[135]=v):v=t[135];let y=!r.browserEnabled&&`pointer-events-none opacity-40`,b;t[136]===y?b=t[137]:(b=u(`transition-opacity`,y),t[136]=y,t[137]=b);let x=!r.browserEnabled,S;t[138]!==n||t[139]!==r||t[140]!==i?(S=(0,Z.jsx)(Ce,{a:n,form:r,update:i}),t[138]=n,t[139]=r,t[140]=i,t[141]=S):S=t[141];let C;t[142]!==b||t[143]!==x||t[144]!==S?(C=(0,Z.jsx)(le,{children:(0,Z.jsx)(`div`,{className:b,"aria-hidden":x,children:S})}),t[142]=b,t[143]=x,t[144]=S,t[145]=C):C=t[145];let w;return t[146]!==e||t[147]!==v||t[148]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[e,v,C]}),t[146]=e,t[147]=v,t[148]=C,t[149]=w):w=t[149],w}return Ie(a)?W:null}function gt(e){return e.mode}function _t(e){return e.language}function vt(e){let t=(0,X.c)(40),{sectionId:n,intro:r,vm:i,children:a,tabbed:o}=e,s=o===void 0?!1:o,c=h(yt),l;t[0]===c?l=t[1]:(l=p(c),t[0]=c,t[1]=l);let u=l,f=u.agentSettings,m=u.settingsSections[n]??n;if(!i.hasToken){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(U,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),t[2]=e):e=t[2];let n;t[3]===m?n=t[4]:(n=(0,Z.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:m}),t[3]=m,t[4]=n);let r;t[5]===f.needToken?r=t[6]:(r=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:f.needToken}),t[5]=f.needToken,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,Z.jsx)(ie,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[e,(0,Z.jsxs)(`div`,{children:[n,r]})]})}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}if(i.loading){let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ie,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,Z.jsx)(oe,{sections:1})}),t[10]=e):e=t[10],e}if(!i.form){let e=i.error??i.fetchError??f.loadError,n;t[11]===e?n=t[12]:(n=(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[11]=e,t[12]=n);let r;t[13]===i?r=t[14]:(r=()=>void i.mutate(),t[13]=i,t[14]=r);let a;t[15]!==u.logs.refresh||t[16]!==r?(a=(0,Z.jsx)(d,{type:`button`,variant:`secondary`,onClick:r,children:u.logs.refresh}),t[15]=u.logs.refresh,t[16]=r,t[17]=a):a=t[17];let o;return t[18]!==n||t[19]!==a?(o=(0,Z.jsxs)(ie,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:[n,a]}),t[18]=n,t[19]=a,t[20]=o):o=t[20],o}let g=s?void 0:r,_;t[21]===f.sectionDesc?_=t[22]:(_=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:f.sectionDesc}),t[21]=f.sectionDesc,t[22]=_);let v;t[23]!==i.autosaveStatus||t[24]!==i.error?(v=(0,Z.jsx)(se,{status:i.autosaveStatus,error:i.error}),t[23]=i.autosaveStatus,t[24]=i.error,t[25]=v):v=t[25];let y;t[26]!==m||t[27]!==g||t[28]!==_||t[29]!==v?(y=(0,Z.jsx)(re,{title:m,subtitle:g,meta:_,actions:v}),t[26]=m,t[27]=g,t[28]=_,t[29]=v,t[30]=y):y=t[30];let b;t[31]===i.error?b=t[32]:(b=i.error?(0,Z.jsx)(`div`,{className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/50 dark:text-red-400`,role:`alert`,children:i.error}):null,t[31]=i.error,t[32]=b);let x;t[33]===a?x=t[34]:(x=(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:a}),t[33]=a,t[34]=x);let S;return t[35]!==y||t[36]!==b||t[37]!==x||t[38]!==i.onBlurCapture?(S=(0,Z.jsxs)(ie,{gap:`gap-6`,onBlurCapture:i.onBlurCapture,children:[y,b,x]}),t[35]=y,t[36]=b,t[37]=x,t[38]=i.onBlurCapture,t[39]=S):S=t[39],S}function yt(e){return e.language}var bt={summaryModel:``},xt={model:``,maxLength:void 0};function St(e){if(!e)return``;if(typeof e==`string`)return e;if(typeof e==`object`&&!Array.isArray(e)){let t=e.primary;return typeof t==`string`?t:``}return``}function Ct(e){if(typeof e!=`object`||!e||!(`fallbacks`in e))return[];let t=e.fallbacks;return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim().length>0):[]}function wt(e){return e===!0||e===`true`||e===1}function Tt(e){let t=e;if(!t||typeof t!=`object`||Array.isArray(t))return{browserEnabled:!0,browserHeadless:!1,browserAllowPrivateUrls:!1,browserCommandTimeout:void 0,browserBackend:`extension`,browserCloudProvider:`local`,browserCloudApiKey:``,browserCloudProjectId:``,browserCloudRegion:``,browserCdpUrl:``,browserExtensionPort:void 0,browserExtensionHost:`127.0.0.1`,browserExtensionConnectionTimeout:void 0,browserCloakKeepOpen:!0,browserCloakTemporaryProfile:!1,browserCloakCacheDir:``,browserCloakBinaryPath:``,browserCloakTimezone:``,browserCloakLocale:``,browserCloakWebrtcIp:``,browserCloakFingerprintPlatform:``,browserCloakExtraArgs:``,browserHumanize:!0,browserHumanPreset:`careful`,browserDialogPolicy:`auto_dismiss`,browserDialogTimeout:void 0};let n=t,r=wt(n.enabled),i=n.headless,a=i===!0||i===`true`||i===1,o=wt(n.allowPrivateUrls),s=typeof n.commandTimeout==`number`&&Number.isFinite(n.commandTimeout)&&n.commandTimeout>=5?Math.floor(n.commandTimeout):void 0,c=n.backend,l=c===`local`||c===`cdp`||c===`cloud`||c===`extension`||c===`cloakbrowser`?c:`extension`,u=n.cloudProvider,d=u===`browserbase`||u===`browser-use`?u:`local`,f=typeof n.cloud==`object`&&n.cloud&&!Array.isArray(n.cloud)?n.cloud:{},p=typeof f.apiKey==`string`?f.apiKey:``,m=typeof f.projectId==`string`?f.projectId:``,h=typeof f.region==`string`?f.region:``,g=typeof n.cdpUrl==`string`?n.cdpUrl:``,_=typeof n.extension==`object`&&n.extension&&!Array.isArray(n.extension)?n.extension:{},v=typeof _.port==`number`&&Number.isFinite(_.port)&&_.port>=1024&&_.port<=65535?Math.floor(_.port):void 0,y=typeof _.host==`string`&&_.host?_.host:`127.0.0.1`,b=typeof _.connectionTimeout==`number`&&Number.isFinite(_.connectionTimeout)&&_.connectionTimeout>=1e3?Math.floor(_.connectionTimeout):void 0,x=typeof n.cloakbrowser==`object`&&n.cloakbrowser&&!Array.isArray(n.cloakbrowser)?n.cloakbrowser:{},S=n.humanPreset==="default"?`default`:`careful`,C=n.dialogPolicy,w=C===`must_respond`||C===`auto_accept`?C:`auto_dismiss`,T=typeof n.dialogTimeoutSeconds==`number`&&Number.isFinite(n.dialogTimeoutSeconds)&&n.dialogTimeoutSeconds>=1?Math.floor(n.dialogTimeoutSeconds):void 0;return{browserEnabled:r,browserHeadless:a,browserAllowPrivateUrls:o,browserCommandTimeout:s,browserBackend:l,browserCloudProvider:d,browserCloudApiKey:p,browserCloudProjectId:m,browserCloudRegion:h,browserCdpUrl:g,browserExtensionPort:v,browserExtensionHost:y,browserExtensionConnectionTimeout:b,browserCloakKeepOpen:x.keepOpen!==!1,browserCloakTemporaryProfile:x.temporaryProfile===!0,browserCloakCacheDir:typeof x.cacheDir==`string`?x.cacheDir:``,browserCloakBinaryPath:typeof x.binaryPath==`string`?x.binaryPath:``,browserCloakTimezone:typeof x.timezone==`string`?x.timezone:``,browserCloakLocale:typeof x.locale==`string`?x.locale:``,browserCloakWebrtcIp:typeof x.webrtcIp==`string`?x.webrtcIp:``,browserCloakFingerprintPlatform:typeof x.fingerprintPlatform==`string`?x.fingerprintPlatform:``,browserCloakExtraArgs:Array.isArray(x.extraArgs)?x.extraArgs.filter(e=>typeof e==`string`&&e.trim().length>0).join(`
7
- `):``,browserHumanize:n.humanize!==!1,browserHumanPreset:S,browserDialogPolicy:w,browserDialogTimeout:T}}function Et(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...bt};let t=e;return{summaryModel:typeof t.summaryModel==`string`?t.summaryModel:``}}function Dt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...xt};let t=e;return{model:typeof t.model==`string`?t.model:``,maxLength:typeof t.maxLength==`number`&&t.maxLength>0?t.maxLength:void 0}}function Ot(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return{enabled:t};let n=e;return{enabled:typeof n.enabled==`boolean`?n.enabled:t}}function kt(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function At(e){if(e==null)return``;if(typeof e==`string`){let t=e.trim();if(!t)return``;try{let e=JSON.parse(t);if(typeof e==`object`&&e&&!Array.isArray(e))return JSON.stringify(e,null,2)}catch{return t}return``}if(typeof e==`object`&&!Array.isArray(e))try{return JSON.stringify(e,null,2)}catch{return``}return``}function jt(e){let t=e.imageGenerationModelTimeoutMs;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return Math.floor(t);let n=e.imageGenerationModel;if(n&&typeof n==`object`&&!Array.isArray(n)){let e=n.timeoutMs;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return Math.floor(e)}return null}function Mt(e){if(e.imageGenerationModelAutoProviderFallback===!0)return!0;let t=e.imageGenerationModel;return t&&typeof t==`object`&&!Array.isArray(t)?t.autoProviderFallback===!0:!1}function Nt(e){let t={},n=t.models&&typeof t.models==`object`&&!Array.isArray(t.models)?t.models:{},r=n.chat,i=t.modelFallbacks,a=Array.isArray(i)&&i.every(e=>typeof e==`string`)?i:Ct(r),o=t.imageModelFallbacks,s=Array.isArray(o)&&o.every(e=>typeof e==`string`)?o:Ct(t.imageModel),c=t.imageGenerationModelFallbacks,l=Array.isArray(c)&&c.every(e=>typeof e==`string`)?c:Ct(t.imageGenerationModel),u=Tt((e&&typeof e==`object`&&!Array.isArray(e)?e:{}).browser),d=typeof t.maxTaskDurationMs==`number`&&Number.isFinite(t.maxTaskDurationMs)?t.maxTaskDurationMs:void 0,f=d===void 0?void 0:Math.round(d/6e4);return{model:St(r),modelFallbacks:a,imageModel:St(t.imageModel),imageModelFallbacks:s,imageGenerationModel:St(t.imageGenerationModel),imageGenerationModelFallbacks:l,imageGenerationModelTimeoutMs:jt(t),imageGenerationModelAutoProviderFallback:Mt(t),mediaMaxMb:typeof t.mediaMaxMb==`number`&&!Number.isNaN(t.mediaMaxMb)?t.mediaMaxMb:void 0,maxTokens:typeof t.maxTokens==`number`?t.maxTokens:8192,temperature:typeof t.temperature==`number`?t.temperature:.7,maxToolIterations:typeof t.maxToolIterations==`number`?t.maxToolIterations:20,maxTaskDurationMinutes:f,maxRequestsPerTurn:typeof t.maxRequestsPerTurn==`number`?t.maxRequestsPerTurn:50,maxToolFailuresPerTurn:typeof t.maxToolFailuresPerTurn==`number`?t.maxToolFailuresPerTurn:3,workspace:typeof t.workspace==`string`?t.workspace:`~/.xopc/workspace`,...u,thinkingDefault:typeof t.thinkingDefault==`string`?t.thinkingDefault:`medium`,reasoningDefault:typeof t.reasoningDefault==`string`?t.reasoningDefault:`stream`,verboseDefault:typeof t.verboseDefault==`string`?t.verboseDefault:`full`,sessionSearch:Et(t.sessionSearch),webExtract:Dt(t.webExtract),delegate:Ot(t.delegate,!1),executeCode:Ot(t.executeCode,!1),skillsAllowlist:kt(t.skills),toolsDisable:(()=>{let e=t.tools;if(!e||typeof e!=`object`||Array.isArray(e))return[];let n=e.disable;return kt(n)})(),typedModels:pe(n),paramsJson:At(t.params)}}function Pt(e){return{enabled:e.browserEnabled,headless:e.browserHeadless,allowPrivateUrls:e.browserAllowPrivateUrls,...e.browserCommandTimeout===void 0?{}:{commandTimeout:e.browserCommandTimeout},backend:e.browserBackend,...e.browserCloudProvider===`local`?{}:{cloudProvider:e.browserCloudProvider},...e.browserBackend===`cloud`?{cloud:{...e.browserCloudApiKey.trim()?{apiKey:e.browserCloudApiKey.trim()}:{},...e.browserCloudProjectId.trim()?{projectId:e.browserCloudProjectId.trim()}:{},...e.browserCloudRegion.trim()?{region:e.browserCloudRegion.trim()}:{}}}:{},...e.browserCdpUrl.trim()?{cdpUrl:e.browserCdpUrl.trim()}:{},...e.browserBackend===`extension`?{extension:{...e.browserExtensionPort===void 0?{}:{port:e.browserExtensionPort},...e.browserExtensionHost.trim()?{host:e.browserExtensionHost.trim()}:{},...e.browserExtensionConnectionTimeout===void 0?{}:{connectionTimeout:e.browserExtensionConnectionTimeout}}}:{},...e.browserBackend===`cloakbrowser`?{cloakbrowser:{keepOpen:e.browserCloakKeepOpen,temporaryProfile:e.browserCloakTemporaryProfile,...e.browserCloakCacheDir.trim()?{cacheDir:e.browserCloakCacheDir.trim()}:{},...e.browserCloakBinaryPath.trim()?{binaryPath:e.browserCloakBinaryPath.trim()}:{},...e.browserCloakTimezone.trim()?{timezone:e.browserCloakTimezone.trim()}:{},...e.browserCloakLocale.trim()?{locale:e.browserCloakLocale.trim()}:{},...e.browserCloakWebrtcIp.trim()?{webrtcIp:e.browserCloakWebrtcIp.trim()}:{},...e.browserCloakFingerprintPlatform.trim()?{fingerprintPlatform:e.browserCloakFingerprintPlatform.trim()}:{},...(()=>{let t=e.browserCloakExtraArgs.split(`
8
- `).map(e=>e.trim()).filter(Boolean);return t.length>0?{extraArgs:t}:{}})()},humanize:e.browserHumanize,humanPreset:e.browserHumanPreset}:{},...e.browserDialogPolicy===`auto_dismiss`?{}:{dialogPolicy:e.browserDialogPolicy},...e.browserDialogTimeout===void 0?{}:{dialogTimeoutSeconds:e.browserDialogTimeout}}}async function Ft(e){await v(_(`/api/config`),{method:`PATCH`,body:JSON.stringify({browser:Pt(e)})}),y()}var It=C();function Lt(e){let t=!!m(e=>e.token),[n,r]=(0,Y.useReducer)(It,{form:null,baseline:null}),i=n.form,a=n.baseline,o=(0,Y.useRef)(!1),s=(0,Y.useRef)(i);s.current=i;let c=(0,Y.useRef)(null),{data:l,error:u,isLoading:d,mutate:f}=b(t);x({enabled:t,parsed:(0,Y.useMemo)(()=>l?.payload?.config===void 0?null:Nt(l.payload.config),[l]),dirty:o.current,trackedParsedRef:c,dispatch:r,onResetDirty:()=>{o.current=!1}});let p=!!(t&&d&&l===void 0&&!u),h=u instanceof Error?u.message:u?String(u):null,g=(0,Y.useMemo)(()=>!i||!a?!1:JSON.stringify(i)!==JSON.stringify(a),[i,a]),_=(0,Y.useCallback)(e=>{o.current=!0,r({type:`patch`,patch:e})},[]),v=ce({value:i,dirty:g,onSave:(0,Y.useCallback)(async t=>{try{await Ft(t),r({type:`saved`,value:t}),o.current=!!(s.current&&JSON.stringify(s.current)!==JSON.stringify(t))}catch(t){throw Error(t instanceof Error?t.message:e.saveError)}},[e.saveError])});return{hasToken:t,loading:p,fetchError:h,form:i,update:_,autosaveStatus:v.status,error:v.error,onBlurCapture:v.onBlurCapture,mutate:f}}function Rt(e,t){return e.browserTabs[t]}function zt(){let e=(0,X.c)(42),t=h(Vt),n;e[0]===t?n=e[1]:(n=p(t),e[0]=t,e[1]=n);let r=n,a=r.agentSettings,o=r.chat,s=te(Bt),c=Lt(a),[l,u]=i(),d;e[2]===s?d=e[3]:(d=ge(Me,s),e[2]=s,e[3]=d);let f=d,m;e[4]===l?m=e[5]:(m=Se(l.get(`focus`)),e[4]=l,e[5]=m);let g=m,_;e[6]!==g||e[7]!==l?(_=g?Pe[g]??Fe(l.get(`tab`)):Fe(l.get(`tab`)),e[6]=g,e[7]=l,e[8]=_):_=e[8];let v=_,y;bb0:{if(!c.form){y=null;break bb0}let t;e[9]!==a||e[10]!==o||e[11]!==c.form||e[12]!==c.update?(t={form:c.form,update:c.update,a,chat:o},e[9]=a,e[10]=o,e[11]=c.form,e[12]=c.update,e[13]=t):t=e[13],y=t}let b=y,x;e[14]===u?x=e[15]:(x=e=>{u(t=>{let n=new URLSearchParams(t);return n.delete(`focus`),e===`overview`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[14]=u,e[15]=x);let S=x;he(v,S);let C,w;e[16]!==g||e[17]!==l||e[18]!==u?(C=()=>{if(!g)return;let e=Pe[g]??Fe(l.get(`tab`));u(t=>{let n=new URLSearchParams(t);return n.delete(`focus`),e===`overview`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0});let t=g===`runtime`||g===`security`?xe(g):null;if(!t)return;let n=window.setTimeout(()=>{document.getElementById(t)?.scrollIntoView({behavior:`smooth`,block:`start`})},80);return()=>window.clearTimeout(n)},w=[g,l,u],e[16]=g,e[17]=l,e[18]=u,e[19]=C,e[20]=w):(C=e[19],w=e[20]),(0,Y.useEffect)(C,w);let T;if(e[21]!==a||e[22]!==f){let t;e[24]===a?t=e[25]:(t=e=>({id:e,label:Rt(a,e)}),e[24]=a,e[25]=t),T=f.map(t),e[21]=a,e[22]=f,e[23]=T}else T=e[23];let E=T,D;e[26]!==v||e[27]!==a.browserTabsAria||e[28]!==S||e[29]!==E?(D=(0,Z.jsx)(de,{items:E,activeTab:v,onChange:S,ariaLabel:a.browserTabsAria,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`}),e[26]=v,e[27]=a.browserTabsAria,e[28]=S,e[29]=E,e[30]=D):D=e[30];let O;e[31]!==v||e[32]!==b||e[33]!==S?(O=b?(0,Z.jsx)(ht,{...b,activeTab:v,setActiveTab:S}):null,e[31]=v,e[32]=b,e[33]=S,e[34]=O):O=e[34];let k;e[35]!==v||e[36]!==O?(k=(0,Z.jsx)(ae,{id:v,activeTab:v,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`,showHeading:!1,framed:!1,children:O}),e[35]=v,e[36]=O,e[37]=k):k=e[37];let A;return e[38]!==k||e[39]!==D||e[40]!==c?(A=(0,Z.jsxs)(vt,{sectionId:`agent-browser`,intro:``,vm:c,tabbed:!0,children:[D,k]}),e[38]=k,e[39]=D,e[40]=c,e[41]=A):A=e[41],A}function Bt(e){return e.mode}function Vt(e){return e.language}export{zt as AgentBrowserSettingsPage};