@xopcai/xopc 0.0.240 → 0.0.241
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-DLfkwJzZ.js → activity-store-CLnbVm9G.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DNqb8LGQ.js → agent-avatar-dicebear-DuBewmbW.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DbdgX6AA.js +1 -0
- package/dist/gateway/static/root/assets/agents-BX3uRVm4.js +1 -0
- package/dist/gateway/static/root/assets/{api-IUm57Zse.js → api-DjBZe303.js} +1 -1
- package/dist/gateway/static/root/assets/app-chrome-BeB4KgOf.js +1 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-4-eqCZG_.js → app-management-settings-panel-D8evZyFQ.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-Dus5TPxo.js → appearance-settings-B-iul0RG.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-CoZd_cZu.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-Bha1jUhj.js → archive-plugin-BOx0EJZs.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CX2u191M.js → attachment-load-Cfk1lwBo.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-BizspokZ.js → automations-page-BTSGvaeS.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-C8RRKT-a.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-CSn8R1EL.js → binary-plugins-ChZyZK45.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-D5MN7UPI.js → block-editor-DCH9b2Ht.js} +46 -46
- package/dist/gateway/static/root/assets/browser-settings-page-D1GPwIfx.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-CeG3fWhC.js → browser-workflow-inputs-jvfcgFG-.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-oqmPd1KI.js → browser-workflows-page-DrHW7XNi.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-CrXB1Q-l.js +7 -0
- package/dist/gateway/static/root/assets/channels-settings-DWMSYaNZ.js +1 -0
- package/dist/gateway/static/root/assets/{channels-status-swr-CwUSKmeY.js → channels-status-swr-CC9MFway.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-C0m-ie_q.js → chat-terminal-dock-DeeZrVbV.js} +2 -2
- package/dist/gateway/static/root/assets/connectors-page-DXTl1fNB.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-DJOvtnKf.js → cron-expression-CiqQOeQ3.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-B06ZCEsb.js → date-picker-CGAMGPfU.js} +1 -1
- package/dist/gateway/static/root/assets/dependency-picker-CxWeUTsc.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-INH03b4z.js → desktop-pet-C3QmYO75.js} +1 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-CAADkWYy.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-BcEHXLQ2.js → extension-debug-page-FQXjDJ8P.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CWefEHKN.js → extension-page-BJE1D5Ji.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CjBTLU5X.js → extension-settings-page-5Ik2tNry.js} +1 -1
- package/dist/gateway/static/root/assets/folder-open-CyzJ19I9.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-api-4GYzRHAt.js → gateway-config-api-cTj71t2a.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-DfMY-MLf.js → gateway-config-swr-Bxe_R-JH.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-C8MQeYbR.js → gateway-settings-KXBUjNcx.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-S6aB0hVI.js → gateway-startup-retry-DJG-I0wW.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-C8cVzIcs.js +1 -0
- package/dist/gateway/static/root/assets/home-page-NdWtBda5.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-DOX5uq-R.js → image-generation-api-Dc_ojQuj.js} +1 -1
- package/dist/gateway/static/root/assets/index-7i2P3312.js +70 -0
- package/dist/gateway/static/root/assets/index-DTo3IcbW.css +2 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-xvS2czSF.js → keyboard-shortcuts-settings-pOKl7blR.js} +1 -1
- package/dist/gateway/static/root/assets/link-2-D_ZKYUW7.js +1 -0
- package/dist/gateway/static/root/assets/local-app-workbench-page-C_j_od5f.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-BAYQxS0S.js → local-apps-page-Bi6wwKgm.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-XDFAPNNu.js → locale-store-C5wr3_pc.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-D6PDZEVP.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-DYmKy_2v.js → management-settings-DGlVizWi.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-Cr32dNv1.js → markdown-split-CXP5zBx_.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-v-O3cOpk.js → markdown-view-D6LxlDxr.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-KPSjs3vW.js → media-plugins-BsENGLr2.js} +1 -1
- package/dist/gateway/static/root/assets/message-square-plus-XP0tGdlV.js +1 -0
- package/dist/gateway/static/root/assets/messages-_tYhRAHD.js +3 -0
- package/dist/gateway/static/root/assets/minimize-2-DtOGrlpo.js +1 -0
- package/dist/gateway/static/root/assets/{mobile-pairing-wizard-pWsC7jcc.js → mobile-pairing-wizard-DcEz7qcX.js} +1 -1
- package/dist/gateway/static/root/assets/models-hub-cache-Y7GUjxHx.js +1 -0
- package/dist/gateway/static/root/assets/{notes-page-DBBnJrFf.js → notes-page-D2EqpDyo.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-Bu0a83Oj.js +4 -0
- package/dist/gateway/static/root/assets/{oauth-api-B_pcOUfT.js → oauth-api-C5NVcsKE.js} +1 -1
- package/dist/gateway/static/root/assets/pencil-DmIY3Oa-.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-B8cjLdm4.js → product-open-page-DMhf1rdz.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-DDHi0Y4Q.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-CVMFKpmu.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-DeVvBsl4.js → registry-api-FXdFaoWM.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-B74aErBY.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DFTHpNg6.js → runtime-tools-settings-panel-Bv-akndY.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-CW7qifxi.js → schema-form-BUzdHWx6.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-D2wmGNZE.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-CYCCUMEt.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-OMPX3Svb.js → settings-form-section-DjWzRk4z.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-CDKXJ12S.js → settings-page-C0OBLqpu.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-NpLQkFCh.js +1 -0
- package/dist/gateway/static/root/assets/share-preview-page-BtbPYaYC.js +2 -0
- package/dist/gateway/static/root/assets/shares-settings-rf8f1OGq.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-BkvclZ_o.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-DAAlmTSh.js → skills-page-CYk8pN97.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-CiMRNDFM.js → skills-page.utils-DGjnz-NG.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-Bq7niN-G.js → system-settings-panel-DmCRSvtd.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-6a2RdDl2.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-5-XHH7F0.js → theme-store-DUko1ZnE.js} +1 -1
- package/dist/gateway/static/root/assets/tunnel-api-Chfiba_x.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-CkwILwYg.js → use-autosave-W_P8Kiv4.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-SeOHP6XO.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-BG-kpmoU.js → voice-api-key-field-BZD0j1jc.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-Bk_bVeGX.js → voice-config-api-BO6A8V3Z.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-BOH2utuu.js → work-discovery-overlay-BfwEoOGL.js} +1 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-X7Z5_lRX.js +3 -0
- package/dist/gateway/static/root/assets/workflows-page-BklMzkg8.js +5 -0
- package/dist/gateway/static/root/index.html +18 -13
- package/dist/package.js +1 -1
- package/dist/src/gateway/hono/routes/media.js +5 -14
- package/dist/src/gateway/hono/routes/shares.js +36 -8
- package/dist/src/gateway/hono/routes/voice.js +1 -1
- package/dist/src/gateway/media-access.d.ts +6 -0
- package/dist/src/gateway/media-access.js +19 -0
- package/dist/src/share/share-store.js +3 -2
- package/dist/src/share/share-types.d.ts +2 -0
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CDZBY8QF.js +0 -1
- package/dist/gateway/static/root/assets/agents-BpWZKFrQ.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-DPacUrzS.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-CudEcxwk.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-wKhgAIwg.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-Dj_x6HTl.js +0 -7
- package/dist/gateway/static/root/assets/channels-settings-BpsJRsjG.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-B-Gdzfob.js +0 -2
- package/dist/gateway/static/root/assets/dependency-picker-BU8dmVCo.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-CzAGt3M_.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-C_8vY0Eu.js +0 -1
- package/dist/gateway/static/root/assets/home-page-D1SM6UXd.js +0 -1
- package/dist/gateway/static/root/assets/index-BN4XPtJY.js +0 -70
- package/dist/gateway/static/root/assets/index-CCBexxKW.css +0 -2
- package/dist/gateway/static/root/assets/local-app-workbench-page-DAh4_rTj.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-COS-Yb-N.js +0 -2
- package/dist/gateway/static/root/assets/messages-B1HDp_j8.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-cache-Bngs8o1m.js +0 -1
- package/dist/gateway/static/root/assets/notes-api-BMhFpRmW.js +0 -1
- package/dist/gateway/static/root/assets/notes-workbench-CSAzL8Tf.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-DHIJpssV.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-BDoAwszu.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-DPi4SQVV.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-VNrtwwV5.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CUcTHMDp.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-Dnvfemeb.js +0 -1
- package/dist/gateway/static/root/assets/share-preview-page-BoSIu0WX.js +0 -2
- package/dist/gateway/static/root/assets/shares-settings-C87QeRxC.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-rY5ujr0j.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-JtztFp2Y.js +0 -1
- package/dist/gateway/static/root/assets/tunnel-api-eBX1eb2v.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-CMH2GOGL.js +0 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-B92rr2yf.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-DXvdYJff.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{p as i,t as a}from"./chunk-KS7C4IRE-BaASWQor.js";import{n as o,r as s}from"./popover-select-DrILF6mR.js";import{t as c}from"./circle-check-C23XjkUj.js";import{t as l}from"./ellipsis-0k4rZLoy.js";import{t as u}from"./markdown-view-v-O3cOpk.js";import{t as d}from"./plus-Q2yW6OE7.js";import{t as f}from"./search-DA7gz22f.js";import{t as p}from"./x-B_N4OPjy.js";import{t as m}from"./cn-JdwAhgNB.js";import{t as h}from"./button-CSEbl4zT.js";import{t as g}from"./messages-B1HDp_j8.js";import{n as _}from"./locale-store-XDFAPNNu.js";import{t as v}from"./skeleton-BwbyijEw.js";import{a as y,n as b,o as ee,r as x,s as S,t as C}from"./dist-BPoKqzeH.js";import{i as w}from"./vendor-swr-BIWyz7Rc.js";import{$c as te,Cs as ne,Do as re,Ds as ie,Ji as T,Js as E,Ti as ae,Un as D,Us as oe,Vo as O,ar as se,bc as ce,cr as k,hs as A,ir as j,ja as M,ks as N,l as P,ma as F,ol as I,or as le,os as L,rl as ue,rr as de,tl as R,ts as fe,v as z,wl as pe}from"./index-BN4XPtJY.js";import{a as B,i as V,o as H,r as U}from"./cron-expression-DJOvtnKf.js";import{a as W,i as me,n as he,r as ge,t as _e}from"./workflow-run-setup-panel-B92rr2yf.js";import{i as ve,n as ye,r as be,t as G}from"./browser-workflow-inputs-CeG3fWhC.js";var K=e(t(),1),xe=n(),Se=B();function q(e,t,n){let r=new Date;return r.setHours(e,t,0,0),r.toLocaleTimeString(n,{hour:`numeric`,minute:`2-digit`})}function Ce(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 we(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 Te(e){return e.length===5&&e.every((e,t)=>e===t+1)}function Ee(e){if(e.length!==2)return!1;let t=[...e].toSorted((e,t)=>e-t);return t[0]===0&&t[1]===6}function De(e,t,n,r){try{let i=Se.CronExpressionParser.parse(e,{...r?.timezone?{tz:r.timezone}:{}}).fields,a=U(i.minute.values),o=U(i.hour.values),s=U(i.dayOfWeek.values),c=U(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=V(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=V(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?q(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&&Te(s))return n.weekdaysAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&Ee(s))return n.weekendsAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&s.length===1){let e=Ce(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=we(s.map(e=>Ce(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 J(e,t,n,r){let i=e.trim();return i?De(i,t,n,r)||Oe(r?.nextRun,t)||n.customSchedule:Oe(r?.nextRun,t)||`—`}function Oe(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 ke=1e3,Y=60*ke,X=60*Y,Ae=24*X,je=7*Ae,Me=new Intl.ListFormat(`en-US`,{type:`conjunction`}),Ne=Object.fromEntries([`second`,`minute`,`hour`,`day`,`week`].map(e=>[e,new Intl.NumberFormat(`en-US`,{style:`unit`,unit:e,unitDisplay:`long`})])),Pe={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`})},Fe={en:new Intl.DateTimeFormat(`en-US`,{hour:`2-digit`,minute:`2-digit`}),zh:new Intl.DateTimeFormat(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})},Ie={minute:Y,hour:X,day:Ae,week:je};function Le(e){return e===`zh`?`zh-CN`:`en-US`}function Re(e,t,n){return n===`zh`?`${e} ${t===`week`?`周`:t===`day`?`天`:t===`hour`?`小时`:t===`minute`?`分钟`:`秒`}`:Ne[String(t)].format(e)}function ze(e,t){return t===`zh`?e.join(` `):Me.format(e)}function Be(e,t){let n=typeof e==`number`?e:Number.parseFloat(e);return Math.max(Y,Math.round((Number.isFinite(n)&&n>0?n:1)*Ie[t]))}function Ve(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*Ie[t]/Ie[n]).toFixed(6)))}function He(e,t){let n=Math.max(ke,Math.round(e)),r=n===Ae?[{unit:`hour`,ms:X}]:n>=je&&n%je===0?[{unit:`week`,ms:je}]:n>=Ae?[{unit:`day`,ms:Ae},{unit:`hour`,ms:X},{unit:`minute`,ms:Y},{unit:`second`,ms:ke}]:n>=X?[{unit:`hour`,ms:X},{unit:`minute`,ms:Y},{unit:`second`,ms:ke}]:n>=Y?[{unit:`minute`,ms:Y},{unit:`second`,ms:ke}]:[{unit:`second`,ms:ke}],i=n,a=[];for(let{unit:e,ms:n}of r){let r=Math.floor(i/n);r<=0||(a.push(Re(r,e,t)),i%=n)}return ze(a,t)}function Ue(e,t){let n=He(e,t);return t===`zh`?`每 ${n}运行一次`:`Runs every ${n}`}function We(e,t){return Pe[t].format(new Date(e))}function Ge(e){return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())}function Ke(e,t,n=Date.now()){let r=new Date(e),i=Math.round((Ge(r)-Ge(new Date(n)))/Ae),a=Fe[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}`:We(e,t)}function qe(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 Je(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 qe(e,t);let i=e.schedule;return i.kind===`once`?t.trigger.onceAt.replace(`{time}`,Ke(Date.parse(i.at),r)):i.kind===`interval`?Ue(i.everyMs,r):J(i.expr,Le(r),n.scheduleBadge,{timezone:i.tz})}function Ye(e,t,n,r=Date.now()){return e.enabled?e.state.nextRunAtMs?Ke(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 Xe(e,t,n,r=Date.now()){if(!e.state.lastRunAtMs)return t.info.notRunYet;let i=Ke(e.state.lastRunAtMs,n,r),a=e.state.lastRunStatus;return a?`${i} · ${t.status[a]}`:i}var Ze={name:``,description:``,projectId:``,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`,conversationMode:`new_session`,notificationPolicy:`attention`,completionWebhookUrl:``,disableAfterFailures:`3`},Qe=[{value:`15`,unit:`minute`},{value:`30`,unit:`minute`},{value:`1`,unit:`hour`},{value:`6`,unit:`hour`},{value:`24`,unit:`hour`}];function $e(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:Be(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=ge(t,e.workflowInput),c=e.workflowInput.goal.trim()||e.workflowGoal.trim(),l=e.actionMode===`browser_recipe`?`auto_apply`:e.safetyMode,u;return u=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()}:{},...e.projectId.trim()?{projectId:e.projectId.trim()}:{},trigger:o,action:u,safety:{mode:l},conversationMode:e.conversationMode,notificationPolicy:e.notificationPolicy,...l===`auto_apply`&&e.completionWebhookUrl.trim()?{completionWebhookUrl:e.completionWebhookUrl.trim()}:{},reliability:{executionTimeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||1800),disableAfterConsecutiveFailures:Math.max(1,Number.parseInt(e.disableAfterFailures,10)||3)}}}function et(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:Ze.time,weekday:Ze.weekday,cronExpr:e}}function tt(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 nt(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 rt(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 it(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function at(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 ot(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=rt(e.trigger);else if(e.trigger.kind===`schedule`){let t=e.trigger.schedule;t.kind===`cron`&&(n=et(t.expr)),t.kind===`interval`&&(n={triggerMode:`interval`,...tt(t.everyMs)}),t.kind===`once`&&(n={triggerMode:`once`,onceAt:nt(t.at)})}let r=e.action,i=r.kind===`workflow`?t.find(e=>e.id===r.workflowId)??null:null,a=r.kind===`workflow`?it(r.input):{},o=e.reliability?.executionTimeoutSeconds??r.timeoutSeconds??e.reliability?.timeoutSeconds??(r.kind===`browser_recipe`?600:1800);return{...Ze,...n,name:e.name,description:e.description??``,projectId:e.projectId??``,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?he(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(o),conversationMode:e.conversationMode??`new_session`,notificationPolicy:e.notificationPolicy??`attention`,completionWebhookUrl:e.completionWebhookUrl??``,disableAfterFailures:String(e.reliability?.disableAfterConsecutiveFailures??3)}}function st(e,t,n){let r=$e(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(),projectId:t.projectId.trim(),completionWebhookUrl:t.completionWebhookUrl.trim(),trigger:i,action:a,reliability:{...e.reliability,...r.reliability}}}var Z=r();function ct(e,t,n){return e?We(e,n):t.never}function lt(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 ut(e){return e.safety?.mode??`auto_apply`}function dt(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 ft(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 pt(e){return e.status===`running`||e.status===`queued`||e.status===`cancelling`}function mt(e){return e.status===`failed`||e.status===`timeout`||e.status===`cancelled`}function ht(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?mt(n):!1}function gt(e,t){return e.action.kind===`agent`?e.action.instruction:e.action.kind===`workflow`&&e.action.goal?.trim()||lt(e.action,t)}function _t(e){return(e.description?.match(/\[managed-by=([^\]]+)\]/))?.[1]?.trim()||null}function vt(e){return!!_t(e)}function yt(e){return e.description?.replace(/\s*\[managed-by=[^\]]+\]\s*/g,` `).trim()??``}function bt(e){return pt(e)?0:mt(e)?1:e.status===`succeeded`?2:3}function xt(e){return[...e].sort((e,t)=>{let n=bt(e)-bt(t);return n===0?t.createdAtMs-e.createdAtMs:n})}function St(){let e=(0,xe.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)(v,{className:`h-4 w-36`}),(0,Z.jsx)(v,{className:`h-3 w-56 max-w-full`})]}),(0,Z.jsx)(v,{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(Ct)})]}),e[1]=n):n=e[1];let r,i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(v,{className:`h-4 w-32`}),i=(0,Z.jsx)(v,{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)(v,{className:`h-12 rounded-lg`}),(0,Z.jsx)(v,{className:`h-12 rounded-lg`}),(0,Z.jsx)(v,{className:`h-12 rounded-lg`})]})]})]})}),e[4]=a):a=e[4],a}function Ct(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)(v,{className:`size-4 rounded-full`}),(0,Z.jsx)(v,{className:`h-4 w-32`}),(0,Z.jsx)(v,{className:`h-5 w-20 rounded-full`})]}),(0,Z.jsx)(v,{className:`mt-3 h-4 w-full`}),(0,Z.jsx)(v,{className:`mt-2 h-4 w-3/5`})]}),(0,Z.jsx)(v,{className:`h-8 w-24 rounded-md`})]})},t)}function wt({projectId:e,embedded:t=!1,title:n,subtitle:r}){let a=_(e=>e.language),c=g(a),u=c.automations,v=c.cron,te=M(e=>e.setPageHeader),ne=M(e=>e.clearPageHeader),[ie,E]=i(),D=ie.get(`run`)?.trim()??``,oe=ie.get(`automation`)?.trim()??``,O=ie.get(`draft`)?.trim()??``,ce=ie.get(`action`)?.trim()??``,A=ie.get(`projectId`)?.trim()??``,N=e?.trim()||A,I=!!e?.trim(),L=ie.get(`autogenerate`)===`1`,ue=(0,K.useRef)(``),[R,fe]=(0,K.useState)(`all`),[pe,B]=(0,K.useState)(``),[V,H]=(0,K.useState)(!1),[U,W]=(0,K.useState)(`blank`),[he,ge]=(0,K.useState)(null),[_e,be]=(0,K.useState)(!1),[G,xe]=(0,K.useState)(Ze),[Se,q]=(0,K.useState)(null),[Ce,we]=(0,K.useState)(null),[Te,Ee]=(0,K.useState)(!1),[De,J]=(0,K.useState)(null),[Oe,ke]=(0,K.useState)(``),[Y,X]=(0,K.useState)(null),[Ae,je]=(0,K.useState)(!1),[Me,Ne]=(0,K.useState)(!1),[Pe,Fe]=(0,K.useState)(N),[Ie,Le]=(0,K.useState)(`new_session`),[Re,ze]=(0,K.useState)(`attention`),[Be,Ve]=(0,K.useState)(null),[He,Ue]=(0,K.useState)(!1),[We,Ge]=(0,K.useState)(!1),[Ke,qe]=(0,K.useState)(!1),[Ye,Xe]=(0,K.useState)(null),Qe=w([`automations`,N],()=>P.list(N?{projectId:N}:void 0),{refreshInterval:15e3}),et=w([`automation-runs`,N],()=>P.runs(50,void 0,N?{projectId:N}:void 0),{refreshInterval:1e4}),tt=w(Ce?`automation-run-events:${Ce}`:null,()=>P.runEvents(Ce),{refreshInterval:5e3}),nt=w(`automation-workflow-definitions`,z),rt=w(`automation-browser-workflows`,()=>ve.list()),it=w(`automation-chat-agents`,F),ct=w(`automation-projects`,()=>T({sortBy:`name`,sortOrder:`asc`,limit:200})),lt=Qe.isLoading&&!Qe.data||et.isLoading&&!et.data,ut=Qe.data?.automations??[],dt=(0,K.useMemo)(()=>xt(et.data?.runs??[]),[et.data?.runs]),ft=(0,K.useMemo)(()=>ut.filter(e=>!vt(e)),[ut]),mt=(0,K.useMemo)(()=>ut.filter(vt),[ut]),ht=(0,K.useMemo)(()=>new Set(mt.map(e=>e.id)),[mt]),_t=(0,K.useMemo)(()=>dt.filter(e=>!ht.has(e.automationId)),[dt,ht]),bt=(0,K.useMemo)(()=>dt.find(e=>e.id===Ce)??null,[dt,Ce]),Ct=(0,K.useMemo)(()=>ut.find(e=>e.id===De)??null,[ut,De]),wt=(0,K.useMemo)(()=>ut.find(e=>e.id===he)??null,[ut,he]),Et=(0,K.useMemo)(()=>dt.filter(e=>e.automationId===De).sort((e,t)=>t.createdAtMs-e.createdAtMs),[dt,De]),Dt=tt.data?.events??[],Ot=(0,K.useMemo)(()=>_t.filter(e=>!pt(e)&&e.readAtMs==null),[_t]),At=pe.trim().toLocaleLowerCase(),jt=(0,K.useMemo)(()=>(R===`system`?mt:ft).filter(e=>R===`active`&&!e.enabled||R===`paused`&&e.enabled?!1:At?[e.name,yt(e),gt(e,u),Je(e.trigger,u,v,a)].some(e=>e.toLocaleLowerCase().includes(At)):!0),[v,R,u,a,At,mt,ft,_t]),Mt=(0,K.useMemo)(()=>nt.data??[],[nt.data]),Nt=(0,K.useMemo)(()=>(rt.data?.workflows??[]).filter(e=>e.enabled),[rt.data]),It=it.data?.items??[],Lt=ct.data?.items??[],Rt=(0,K.useMemo)(()=>Mt.find(e=>e.id===G.workflowId.trim())??null,[G.workflowId,Mt]),zt=(0,K.useMemo)(()=>Nt.find(e=>e.id===G.browserWorkflowId.trim())??null,[Nt,G.browserWorkflowId]),Bt=G.actionMode===`workflow`&&(!G.workflowId.trim()||Mt.length>0&&!Mt.some(e=>e.id===G.workflowId)),Vt=G.actionMode===`workflow`&&Rt?!me(Rt,G.workflowInput,G.workflowInputValid).valid:!1,Ht=!!G.name.trim()&&(G.triggerMode!==`once`||Number.isFinite(new Date(G.onceAt).getTime()))&&(G.triggerMode!==`event`||!!G.eventType.trim()&&at(G.eventPayloadMatch))&&(G.actionMode===`workflow`?!Bt&&!Vt:G.actionMode===`browser_recipe`?zt!==null&&ye(zt,G.browserWorkflowInputs):!!G.instruction.trim()),Gt=(0,K.useMemo)(()=>[{name:u.templates.dailyAgent.name,description:u.templates.dailyAgent.description,form:{...Ze,name:u.templates.dailyAgent.name,instruction:u.templates.dailyAgent.instruction,triggerMode:`daily`}},{name:u.templates.morningWorkflow.name,description:u.templates.morningWorkflow.description,form:{...Ze,name:u.templates.morningWorkflow.formName,actionMode:`workflow`,workflowId:Mt[0]?.id??``}},{name:u.templates.webhookAgent.name,description:u.templates.webhookAgent.description,form:{...Ze,name:u.templates.webhookAgent.formName,triggerMode:`webhook`}},{name:u.templates.blockedTask.name,description:u.templates.blockedTask.description,form:{...Ze,name:u.templates.blockedTask.formName,triggerMode:`taskBlocked`,instruction:u.templates.blockedTask.instruction}},{name:u.templates.noteCreated.name,description:u.templates.noteCreated.description,form:{...Ze,name:u.templates.noteCreated.formName,triggerMode:`noteCreated`,instruction:u.templates.noteCreated.instruction}}],[u,Mt]);(0,K.useEffect)(()=>{if(jt.length===0){J(null);return}De&&jt.some(e=>e.id===De)||J(jt[0].id)},[jt,De]);let Kt=(0,K.useCallback)(async()=>{await Promise.all([Qe.mutate(),et.mutate(),tt.mutate()])},[Qe.mutate,tt.mutate,et.mutate]),qt=(0,K.useCallback)(e=>{if(I){J(null),we(null);return}E(t=>{let n=new URLSearchParams(t);return e?n.set(`projectId`,e):n.delete(`projectId`),n.delete(`automation`),n.delete(`run`),n}),J(null),we(null)},[I,E]);(0,K.useEffect)(()=>{I&&(Fe(N),xe(e=>e.projectId===N?e:{...e,projectId:N}))},[N,I]);let $=(0,K.useCallback)(e=>{if(ge(null),be(!1),W(e),H(!0),e===`blank`){xe({...Ze,projectId:N});return}ke(``),X(null),Ne(!1),Fe(N),Le(`new_session`),ze(`attention`)},[N]),Jt=(0,K.useCallback)(e=>{xe(ot(e,Mt)),ge(e.id),be(!1),J(null),W(`blank`),H(!0)},[Mt]),Yt=(0,K.useCallback)(()=>{Y&&(xe({...ot(Y.automation,Mt),projectId:Pe,conversationMode:Ie,notificationPolicy:Re}),ge(null),be(!0),W(`blank`))},[Y,Ie,Re,Pe,Mt]),Xt=(0,K.useCallback)(async()=>{qe(!0),q(null);try{await Kt()}catch(e){q(e instanceof Error?e.message:String(e))}finally{qe(!1)}},[u.feedback.actionFailed,Kt]);(0,K.useEffect)(()=>{if(!oe)return;let e=ut.find(e=>e.id===oe);e&&(fe(vt(e)?`system`:`all`),J(e.id),E(e=>{let t=new URLSearchParams(e);return t.delete(`automation`),t},{replace:!0}))},[oe,ut,E]),(0,K.useEffect)(()=>{ce===`create`&&($(`blank`),E(e=>{let t=new URLSearchParams(e);return t.delete(`action`),t},{replace:!0}))},[ce,$,E]),(0,K.useEffect)(()=>{if(!O)return;let e=`${a}:${L?`auto`:`seed`}:${O}`;ue.current!==e&&(ue.current=e,ke(O),X(null),Ne(!1),Fe(N),W(`draft`),H(!0),E(e=>{let t=new URLSearchParams(e);return t.delete(`draft`),t.delete(`autogenerate`),t},{replace:!0}),L&&(q(null),je(!0),P.draft({prompt:O,language:a}).then(e=>{X(e.draft),Ne(!1)}).catch(e=>{q(e instanceof Error?e.message:String(e))}).finally(()=>{je(!1)})))},[L,O,a,N,E]);let Zt=(0,K.useCallback)(e=>{let t=dt.find(t=>t.id===e);if(!t||pt(t)||t.readAtMs!=null)return;let n=Date.now();et.mutate(t=>t&&{...t,runs:t.runs.map(t=>t.id===e?{...t,readAtMs:n}:t)},!1),P.markRunRead(e).catch(e=>{q(e instanceof Error?e.message:String(e)),et.mutate()})},[dt,et.mutate]),Qt=(0,K.useCallback)(e=>{Zt(e),we(e),Ee(!0),E(t=>{let n=new URLSearchParams(t);return n.set(`run`,e),n},{replace:!0})},[Zt,E]),$t=(0,K.useCallback)(e=>{J(e);let t=dt.find(t=>t.automationId===e);t&&t.readAtMs==null&&!pt(t)&&Zt(t.id)},[Zt,dt]);(0,K.useEffect)(()=>{D&&(Zt(D),we(D),Ee(!0))},[Zt,D]),(0,K.useEffect)(()=>{Ve(null),Ge(!1)},[Ce]);async function en(){if(q(null),Ht){if(_e&&Y){Xe(`draft:edit`);try{let e=$e(G,Rt),{simulation:t}=await P.simulate(e);X({...Y,automation:e,simulation:t}),Fe(G.projectId),Le(G.conversationMode),ze(G.notificationPolicy),Ne(!1),be(!1),W(`draft`)}catch(e){q(e instanceof Error?e.message:String(e))}finally{Xe(null)}return}if(wt){let e=wt.id;await tn(`automation:${e}:edit`,()=>P.update(e,st(wt,G,Rt)))&&(H(!1),ge(null),J(e));return}try{let e=$e(G,Rt),{automation:t}=await P.create(e);xe(Ze),H(!1),fe(`all`),B(``),qt(t.projectId??``),await Kt(),J(t.id)}catch(e){q(e instanceof Error?e.message:String(e))}}}async function tn(e,t){q(null),Xe(e);try{return await t(),await Kt(),!0}catch(e){return q(e instanceof Error?e.message:String(e)),!1}finally{Xe(null)}}async function nn(){await tn(`runs:read-all`,()=>P.markAllRunsRead(N||void 0))}async function rn(){let e=Oe.trim();if(e){q(null),je(!0);try{X((await P.draft({prompt:e,language:a})).draft),Ne(!1)}catch(e){q(e instanceof Error?e.message:String(e))}finally{je(!1)}}}async function an(){if(!Y)return;let e=``,t=``;await tn(`draft:publish`,async()=>{let{automation:n}=await P.create({...Y.automation,...Pe?{projectId:Pe}:{projectId:void 0},conversationMode:Ie,notificationPolicy:Re});X(null),ke(``),Ne(!1),H(!1),fe(`all`),B(``),e=n.id,t=n.projectId??``})&&e&&(qt(t),J(e))}async function on(){if(!Y)return;let e=``,t=``,n=``;await tn(`draft:test`,async()=>{let{automation:r}=await P.create({...Y.automation,...Pe?{projectId:Pe}:{projectId:void 0},conversationMode:Ie,notificationPolicy:Re,enabled:!1}),{run:i}=await P.runNow(r.id);e=r.id,t=r.projectId??``,n=i.id,X(null),ke(``),Ne(!1),H(!1),fe(`all`),B(``)})&&e&&n&&(qt(t),J(e),Qt(n))}async function sn(e){q(null),Ue(!0),Ve(null),Ge(!1);try{Ve((await P.repairDraft(e.id,{language:a})).repair)}catch(e){q(e instanceof Error?e.message:String(e))}finally{Ue(!1)}}async function cn(e){Be&&await tn(`run:${e.id}:repair`,async()=>{await P.update(e.automationId,Be.patch),Ve(null),Ge(!1)})}let ln=(0,K.useMemo)(()=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(ae,{className:`size-9 shrink-0 p-0`,loading:Ke,label:u.refresh,onClick:Xt}),(0,Z.jsxs)(h,{variant:`primary`,onClick:()=>$(`draft`),children:[(0,Z.jsx)(d,{className:`size-4`}),u.new]})]}),[u.new,u.refresh,$,Ke,Xt]);return(0,K.useLayoutEffect)(()=>{if(!t)return te({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:u.title}),(0,Z.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:u.subtitle})]}),end:ln}),()=>ne()},[ne,t,ln,u.subtitle,u.title,te]),(0,Z.jsxs)(`div`,{className:m(`flex min-h-0 min-w-0 flex-1 flex-col`,t?`bg-transparent`:`bg-surface-panel`),children:[(0,Z.jsxs)(`div`,{className:m(`flex w-full flex-col gap-4`,t?`py-1`:`px-3 py-5 sm:px-5 xl:px-6`),children:[t?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 rounded-xl border border-edge-subtle bg-surface-base px-4 py-3 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(re,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n||u.title})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:r||u.subtitle})]}),ln]}):null,Se?(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:Se}):null,lt?(0,Z.jsx)(St,{}):(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:[I?null:(0,Z.jsxs)(o,{"aria-label":u.filters.project,className:Q,value:N,onChange:e=>qt(e.target.value),children:[(0,Z.jsx)(s,{value:``,children:u.filters.allProjects}),Lt.map(e=>(0,Z.jsx)(s,{value:e.id,children:e.name},e.id))]}),(0,Z.jsxs)(`label`,{className:m(`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`,!I&&`mt-2`),children:[(0,Z.jsx)(f,{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:pe,onChange:e=>B(e.target.value),placeholder:u.filters.search})]}),(0,Z.jsxs)(`nav`,{className:`mt-3 flex items-center gap-1`,"aria-label":u.filters.status,children:[[{id:`all`,label:u.filters.all},{id:`active`,label:u.filters.active},{id:`paused`,label:u.paused}].map(e=>(0,Z.jsx)(`button`,{type:`button`,className:m(`rounded-md px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,R===e.id&&`bg-surface-hover text-fg`),onClick:()=>fe(e.id),children:e.label},e.id)),(0,Z.jsxs)(le,{children:[(0,Z.jsx)(k,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:m(`ml-auto rounded-md p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,R===`system`&&`bg-surface-hover text-fg`),"aria-label":u.system.title,children:(0,Z.jsx)(l,{className:`size-4`})})}),(0,Z.jsx)(se,{children:(0,Z.jsx)(de,{align:`end`,className:`z-70 min-w-40 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:(0,Z.jsxs)(j,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>fe(`system`),children:[u.system.title,` `,mt.length]})})})]})]}),Ot.length>0&&R!==`system`?(0,Z.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2 rounded-md bg-accent/8 px-2.5 py-1.5 text-xs text-accent-fg`,children:[(0,Z.jsxs)(`span`,{children:[u.filters.unread,` · `,Ot.length]}),(0,Z.jsx)(`button`,{type:`button`,className:`font-medium hover:underline`,disabled:Ye===`runs:read-all`,onClick:()=>void nn(),children:u.filters.markAllRead})]}):null]}),(0,Z.jsx)(kt,{automations:jt,runs:R===`system`?dt:_t,labels:u,cronLabels:v,language:a,selectedAutomationId:De,onOpenDetails:$t})]}),Ct?(0,Z.jsx)(Ft,{automation:Ct,runs:Et,labels:u,cronLabels:v,language:a,projects:Lt,busyAction:Ye,onEdit:Jt,onSelectRun:Qt,onAction:tn}):(0,Z.jsx)(Ut,{icon:(0,Z.jsx)(re,{className:`size-5`}),title:u.empty.filtered})]})]}),(0,Z.jsx)(C,{open:V,onOpenChange:e=>{H(e),e||(ge(null),be(!1))},children:(0,Z.jsxs)(ee,{children:[(0,Z.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(x,{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)(S,{className:`text-base font-semibold text-fg`,children:U===`draft`?u.draft.title:wt?u.editTitle:_e?u.draft.editTitle:u.createTitle}),(0,Z.jsx)(b,{asChild:!0,children:(0,Z.jsx)(h,{variant:`ghost`,"aria-label":u.close,children:(0,Z.jsx)(p,{className:`size-4`})})})]}),U===`draft`?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,Z.jsx)(Tt,{labels:u,prompt:Oe,draft:Y,loading:Ae,approved:Me,publishBusy:Ye===`draft:publish`,testBusy:Ye===`draft:test`,templates:Gt,projects:Lt,projectId:Pe,conversationMode:Ie,notificationPolicy:Re,onPromptChange:ke,onGenerate:rn,onEdit:Yt,onPublish:an,onTest:on,onProjectChange:Fe,onConversationModeChange:Le,onNotificationPolicyChange:ze,projectLocked:I,onApprovedChange:Ne,onDiscard:()=>{X(null),Ne(!1)},onTemplateSelect:e=>{xe({...e,projectId:Pe}),W(`blank`)},onOpenAdvanced:()=>{xe({...Ze,projectId:Pe,conversationMode:Ie,notificationPolicy:Re}),W(`blank`)}})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Wt,{form:G,labels:u,setForm:xe,projects:Lt,workflowDefinitions:Mt,selectedWorkflow:Rt,workflowsLoading:nt.isLoading,browserWorkflows:Nt,selectedBrowserWorkflow:zt,browserWorkflowsLoading:rt.isLoading,agentOptions:It,agentsLoading:it.isLoading,language:a,projectLocked:I}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[_e?(0,Z.jsx)(h,{variant:`ghost`,onClick:()=>{be(!1),W(`draft`)},children:u.cancel}):(0,Z.jsx)(b,{asChild:!0,children:(0,Z.jsx)(h,{variant:`ghost`,children:u.cancel})}),(0,Z.jsx)(h,{variant:`primary`,onClick:en,disabled:!Ht||Ye===`draft:edit`||!!(wt&&Ye),children:Ye===`draft:edit`||wt&&Ye===`automation:${wt.id}:edit`?u.feedback.working:wt||_e?u.save:u.create})]})]})]})]})}),(0,Z.jsx)(C,{open:Te&&!!bt,onOpenChange:e=>{Ee(e),!e&&E(e=>{let t=new URLSearchParams(e);return t.delete(`run`),t},{replace:!0})},children:(0,Z.jsxs)(ee,{children:[(0,Z.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(x,{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)(S,{className:`truncate text-base font-semibold text-fg`,children:bt?.automationName??u.dashboard.result}),(0,Z.jsx)(b,{asChild:!0,children:(0,Z.jsx)(h,{variant:`ghost`,"aria-label":u.close,children:(0,Z.jsx)(p,{className:`size-4`})})})]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Z.jsx)(Pt,{className:`rounded-none border-0`,run:bt,events:Dt,labels:u,cronLabels:v,language:a,loading:tt.isLoading,repairDraft:Be,repairLoading:He,repairApproved:We,busyAction:Ye,onRepairApprovedChange:Ge,onSuggestRepair:sn,onApplyRepair:cn})})]})]})})]})}function Tt(e){let t=(0,xe.c)(108),{labels:n,prompt:r,draft:i,loading:a,approved:c,publishBusy:l,testBusy:u,templates:d,projects:f,projectId:p,conversationMode:g,notificationPolicy:_,onPromptChange:v,onGenerate:y,onEdit:b,onPublish:ee,onTest:x,onProjectChange:S,onConversationModeChange:C,onNotificationPolicyChange:w,onApprovedChange:te,onDiscard:re,onTemplateSelect:T,onOpenAdvanced:E,projectLocked:ae}=e,D=l===void 0?!1:l,oe=u===void 0?!1:u,O=ae===void 0?!1:ae,se=!!(i&&i.simulation.requiredConfirmations.length>0),ce;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Z.jsx)(fe,{className:`size-4 text-accent`}),t[0]=ce):ce=t[0];let k;t[1]===n.draft.title?k=t[2]:(k=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[ce,n.draft.title]}),t[1]=n.draft.title,t[2]=k);let A;t[3]===n.draft.subtitle?A=t[4]:(A=(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:n.draft.subtitle}),t[3]=n.draft.subtitle,t[4]=A);let j;t[5]!==k||t[6]!==A?(j=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[k,A]}),t[5]=k,t[6]=A,t[7]=j):j=t[7];let M;t[8]!==a||t[9]!==r?(M=a||!r.trim(),t[8]=a,t[9]=r,t[10]=M):M=t[10];let N;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(fe,{className:`size-4`}),t[11]=N):N=t[11];let P=a?n.draft.generating:n.draft.generate,F;t[12]!==y||t[13]!==P||t[14]!==M?(F=(0,Z.jsxs)(h,{variant:`primary`,onClick:y,disabled:M,children:[N,P]}),t[12]=y,t[13]=P,t[14]=M,t[15]=F):F=t[15];let I;t[16]!==F||t[17]!==j?(I=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[j,F]}),t[16]=F,t[17]=j,t[18]=I):I=t[18];let le;t[19]===v?le=t[20]:(le=e=>v(e.target.value),t[19]=v,t[20]=le);let L;t[21]!==n.draft.placeholder||t[22]!==r||t[23]!==le?(L=(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:le,placeholder:n.draft.placeholder}),t[21]=n.draft.placeholder,t[22]=r,t[23]=le,t[24]=L):L=t[24];let ue=O?`sm:grid-cols-2`:`sm:grid-cols-3`,de;t[25]===ue?de=t[26]:(de=m(`mt-3 grid gap-3`,ue),t[25]=ue,t[26]=de);let R;t[27]!==n.draft.noProject||t[28]!==n.draft.project||t[29]!==S||t[30]!==p||t[31]!==O||t[32]!==f?(R=O?null:(0,Z.jsx)($,{label:n.draft.project,children:(0,Z.jsxs)(o,{className:Q,value:p,onChange:e=>S(e.target.value),children:[(0,Z.jsx)(s,{value:``,children:n.draft.noProject}),f.map(Et)]})}),t[27]=n.draft.noProject,t[28]=n.draft.project,t[29]=S,t[30]=p,t[31]=O,t[32]=f,t[33]=R):R=t[33];let z;t[34]===C?z=t[35]:(z=e=>C(e.target.value),t[34]=C,t[35]=z);let pe;t[36]===n.draft.newConversation?pe=t[37]:(pe=(0,Z.jsx)(s,{value:`new_session`,children:n.draft.newConversation}),t[36]=n.draft.newConversation,t[37]=pe);let B;t[38]===n.draft.continuousConversation?B=t[39]:(B=(0,Z.jsx)(s,{value:`continuous`,children:n.draft.continuousConversation}),t[38]=n.draft.continuousConversation,t[39]=B);let V;t[40]!==g||t[41]!==z||t[42]!==pe||t[43]!==B?(V=(0,Z.jsxs)(o,{className:Q,value:g,onChange:z,children:[pe,B]}),t[40]=g,t[41]=z,t[42]=pe,t[43]=B,t[44]=V):V=t[44];let H;t[45]!==n.draft.conversation||t[46]!==V?(H=(0,Z.jsx)($,{label:n.draft.conversation,children:V}),t[45]=n.draft.conversation,t[46]=V,t[47]=H):H=t[47];let U;t[48]===w?U=t[49]:(U=e=>w(e.target.value),t[48]=w,t[49]=U);let W;t[50]===n.draft.notifyAttention?W=t[51]:(W=(0,Z.jsx)(s,{value:`attention`,children:n.draft.notifyAttention}),t[50]=n.draft.notifyAttention,t[51]=W);let me;t[52]===n.draft.notifyAll?me=t[53]:(me=(0,Z.jsx)(s,{value:`all`,children:n.draft.notifyAll}),t[52]=n.draft.notifyAll,t[53]=me);let he;t[54]===n.draft.notifyNone?he=t[55]:(he=(0,Z.jsx)(s,{value:`none`,children:n.draft.notifyNone}),t[54]=n.draft.notifyNone,t[55]=he);let ge;t[56]!==_||t[57]!==U||t[58]!==W||t[59]!==me||t[60]!==he?(ge=(0,Z.jsxs)(o,{className:Q,value:_,onChange:U,children:[W,me,he]}),t[56]=_,t[57]=U,t[58]=W,t[59]=me,t[60]=he,t[61]=ge):ge=t[61];let _e;t[62]!==n.draft.notifications||t[63]!==ge?(_e=(0,Z.jsx)($,{label:n.draft.notifications,children:ge}),t[62]=n.draft.notifications,t[63]=ge,t[64]=_e):_e=t[64];let ve;t[65]!==de||t[66]!==R||t[67]!==H||t[68]!==_e?(ve=(0,Z.jsxs)(`div`,{className:de,children:[R,H,_e]}),t[65]=de,t[66]=R,t[67]=H,t[68]=_e,t[69]=ve):ve=t[69];let ye;t[70]!==i||t[71]!==n.draft.advancedCreate||t[72]!==n.draft.suggestions||t[73]!==n.draft.suggestionsDescription||t[74]!==E||t[75]!==T||t[76]!==d?(ye=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)(h,{variant:`ghost`,onClick:E,children:n.draft.advancedCreate})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:d.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:()=>T(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[70]=i,t[71]=n.draft.advancedCreate,t[72]=n.draft.suggestions,t[73]=n.draft.suggestionsDescription,t[74]=E,t[75]=T,t[76]=d,t[77]=ye):ye=t[77];let be;t[78]!==c||t[79]!==i||t[80]!==n.draft.approval||t[81]!==n.draft.assumptions||t[82]!==n.draft.discard||t[83]!==n.draft.edit||t[84]!==n.draft.publish||t[85]!==n.draft.review||t[86]!==n.draft.risks||t[87]!==n.draft.safety||t[88]!==n.draft.testOnce||t[89]!==n.draft.testing||t[90]!==n.feedback||t[91]!==n.info||t[92]!==n.none||t[93]!==te||t[94]!==re||t[95]!==b||t[96]!==ee||t[97]!==x||t[98]!==D||t[99]!==se||t[100]!==oe?(be=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)(Ht,{label:n.info.when,value:i.simulation.triggerSummary}),(0,Z.jsx)(Ht,{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)(Dt,{title:n.draft.safety,items:[...i.simulation.safetyNotes,...i.simulation.requiredConfirmations],empty:n.none}),(0,Z.jsx)(Dt,{title:n.draft.assumptions,items:i.assumptions,empty:n.none}),(0,Z.jsx)(Dt,{title:n.draft.risks,items:i.risks,empty:n.none}),se?(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:c,onChange:e=>te(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)(h,{variant:`ghost`,onClick:re,children:n.draft.discard}),(0,Z.jsxs)(h,{variant:`secondary`,onClick:b,children:[(0,Z.jsx)(ie,{className:`size-4`}),n.draft.edit]}),(0,Z.jsxs)(h,{variant:`secondary`,onClick:x,disabled:oe||D||se&&!c,children:[(0,Z.jsx)(ne,{className:`size-4`}),oe?n.draft.testing:n.draft.testOnce]}),(0,Z.jsx)(h,{variant:`primary`,onClick:ee,disabled:D||se&&!c,children:D?n.feedback.working:n.draft.publish})]})]})]}):null,t[78]=c,t[79]=i,t[80]=n.draft.approval,t[81]=n.draft.assumptions,t[82]=n.draft.discard,t[83]=n.draft.edit,t[84]=n.draft.publish,t[85]=n.draft.review,t[86]=n.draft.risks,t[87]=n.draft.safety,t[88]=n.draft.testOnce,t[89]=n.draft.testing,t[90]=n.feedback,t[91]=n.info,t[92]=n.none,t[93]=te,t[94]=re,t[95]=b,t[96]=ee,t[97]=x,t[98]=D,t[99]=se,t[100]=oe,t[101]=be):be=t[101];let G;return t[102]!==I||t[103]!==L||t[104]!==ve||t[105]!==ye||t[106]!==be?(G=(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[I,L,ve,ye,be]}),t[102]=I,t[103]=L,t[104]=ve,t[105]=ye,t[106]=be,t[107]=G):G=t[107],G}function Et(e){return(0,Z.jsx)(s,{value:e.id,children:e.name},e.id)}function Dt(e){let t=(0,xe.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(Ot):(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 Ot(e){return(0,Z.jsxs)(`li`,{children:[`- `,e]},e)}function kt(e){let t=(0,xe.c)(20),{automations:n,runs:r,labels:i,cronLabels:a,language:o,selectedAutomationId:s,onOpenDetails:c}=e;if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(re,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===i.empty.filtered?n=t[2]:(n=(0,Z.jsx)(Ut,{className:`rounded-none border-0 shadow-none`,icon:e,title:i.empty.filtered}),t[1]=i.empty.filtered,t[2]=n),n}let l;if(t[3]!==n||t[4]!==a||t[5]!==i||t[6]!==o||t[7]!==c||t[8]!==r||t[9]!==s){let e;t[11]!==a||t[12]!==i||t[13]!==o||t[14]!==c||t[15]!==r||t[16]!==s?(e=e=>{let t=r.filter(t=>t.automationId===e.id).sort(At),n=t.find(pt),l=t[0];return(0,Z.jsxs)(`button`,{type:`button`,className:m(`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:()=>c(e.id),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:m(`size-2 shrink-0 rounded-full`,n?`bg-blue-500`:ht(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}),l&&l.readAtMs==null&&!pt(l)?(0,Z.jsx)(`span`,{className:`ml-auto size-2 shrink-0 rounded-full bg-blue-500`,children:(0,Z.jsx)(`span`,{className:`sr-only`,children:i.filters.unread})}):null]}),(0,Z.jsx)(`div`,{className:`mt-1 truncate pl-4 text-xs text-fg-muted`,children:Je(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:m(`truncate`,l?.error&&`text-red-700 dark:text-red-300`),children:l?l.error||l.summary||i.status[l.status]:e.enabled?`${i.next}: ${ct(e.state.nextRunAtMs,i,o)}`:i.paused}),l?.status?(0,Z.jsx)(`span`,{className:m(`shrink-0 rounded-full px-1.5 py-0.5`,dt(l.status)),children:i.status[l.status]}):null]})]},e.id)},t[11]=a,t[12]=i,t[13]=o,t[14]=c,t[15]=r,t[16]=s,t[17]=e):e=t[17],l=n.map(e),t[3]=n,t[4]=a,t[5]=i,t[6]=o,t[7]=c,t[8]=r,t[9]=s,t[10]=l}else l=t[10];let u;return t[18]===l?u=t[19]:(u=(0,Z.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:l}),t[18]=l,t[19]=u),u}function At(e,t){return t.createdAtMs-e.createdAtMs}function jt(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`completion_hook.started`:return n.completionHookStarted;case`completion_hook.completed`:return n.completionHookCompleted;case`completion_hook.failed`:return n.completionHookFailed;case`run.completed`:return a?n.runCompleted.replace(`{status}`,a):n.runCompletedFallback;default:return e.message}}function Mt(e){let t=(0,xe.c)(17),{value:n,labels:r,title:i,defaultExpanded:a}=e,[o,s]=(0,K.useState)(a===void 0?!1:a),c;t[0]===n?c=t[1]:(c=JSON.stringify(n,null,2),t[0]=n,t[1]=c);let l=c,u;t[2]===l?u=t[3]:(u=l.split(`
|
|
2
|
-
`),t[2]=l,t[3]=u);let d=u.length,f=l.length>720||d>18,p;t[4]!==f||t[5]!==l?(p=f?`${l.split(`
|
|
3
|
-
`).slice(0,10).join(`
|
|
4
|
-
`).trimEnd()}...`:l,t[4]=f,t[5]=l,t[6]=p):p=t[6];let h=p,g;t[7]!==o||t[8]!==f||t[9]!==r||t[10]!==i?(g=f?(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(Nt),"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)(ue,{className:m(`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]=f,t[9]=r,t[10]=i,t[11]=g):g=t[11];let _=o||!f?l: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 y;return t[14]!==g||t[15]!==v?(y=(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]=y):y=t[16],y}function Nt(e){return!e}function Pt(e){let t=(0,xe.c)(148),{className:n,run:r,events:i,labels:o,cronLabels:s,language:l,loading:d,repairDraft:f,repairLoading:p,repairApproved:g,busyAction:_,onRepairApprovedChange:y,onSuggestRepair:b,onApplyRepair:ee}=e;if(!r){let e;t[0]===n?e=t[1]:(e=m(`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)(pe,{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 x=r.error||r.summary,S=r.sessionKey?`/chat/${encodeURIComponent(r.sessionKey)}`:r.workflowRunId?`/workflows?run=${encodeURIComponent(r.workflowRunId)}`:null,C=r.sessionKey?o.runDetail.openConversation:o.runDetail.openWorkflow,w=r.sessionKey?oe:ce,ne=pt(r)?pe:mt(r)?te:c,re;t[8]===n?re=t[9]:(re=m(`rounded-lg border border-edge-subtle bg-surface-base shadow-surface`,n),t[8]=n,t[9]=re);let ie;t[10]===r.automationName?ie=t[11]:(ie=(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:r.automationName}),t[10]=r.automationName,t[11]=ie);let T;t[12]===r.id?T=t[13]:(T=r.id.slice(0,8),t[12]=r.id,t[13]=T);let ae;t[14]===T?ae=t[15]:(ae=(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:T}),t[14]=T,t[15]=ae);let D;t[16]!==ie||t[17]!==ae?(D=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[ie,ae]}),t[16]=ie,t[17]=ae,t[18]=D):D=t[18];let O;t[19]===r.status?O=t[20]:(O=m(`shrink-0 rounded-full px-2 py-0.5 text-xs`,dt(r.status)),t[19]=r.status,t[20]=O);let se=o.status[r.status],k;t[21]!==O||t[22]!==se?(k=(0,Z.jsx)(`span`,{className:O,children:se}),t[21]=O,t[22]=se,t[23]=k):k=t[23];let A;t[24]!==D||t[25]!==k?(A=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[D,k]}),t[24]=D,t[25]=k,t[26]=A):A=t[26];let j;t[27]!==o||t[28]!==l||t[29]!==r.createdAtMs?(j=ct(r.createdAtMs,o,l),t[27]=o,t[28]=l,t[29]=r.createdAtMs,t[30]=j):j=t[30];let M;t[31]===j?M=t[32]:(M=(0,Z.jsx)(`span`,{children:j}),t[31]=j,t[32]=M);let N;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t[33]=N):N=t[33];let P=o.details.duration,F;t[34]!==o||t[35]!==r.durationMs?(F=ft(r.durationMs,o),t[34]=o,t[35]=r.durationMs,t[36]=F):F=t[36];let I;t[37]!==o.details.duration||t[38]!==F?(I=(0,Z.jsxs)(`span`,{children:[P,` `,F]}),t[37]=o.details.duration,t[38]=F,t[39]=I):I=t[39];let le;t[40]!==M||t[41]!==I?(le=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-muted`,children:[M,N,I]}),t[40]=M,t[41]=I,t[42]=le):le=t[42];let L;t[43]!==o.repair||t[44]!==b||t[45]!==p||t[46]!==r?(L=r.status===`failed`||r.status===`timeout`||r.status===`cancelled`?(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsxs)(h,{variant:`secondary`,onClick:()=>b(r),disabled:p,children:[(0,Z.jsx)(fe,{className:`size-4`}),p?o.repair.generating:o.repair.suggest]})}):null,t[43]=o.repair,t[44]=b,t[45]=p,t[46]=r,t[47]=L):L=t[47];let de;t[48]!==le||t[49]!==L||t[50]!==A?(de=(0,Z.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[A,le,L]}),t[48]=le,t[49]=L,t[50]=A,t[51]=de):de=t[51];let z;t[52]===r?z=t[53]:(z=pt(r)?`text-blue-500`:mt(r)?`text-red-500`:`text-emerald-500`,t[52]=r,t[53]=z);let B;t[54]===z?B=t[55]:(B=m(`size-4`,z),t[54]=z,t[55]=B);let V;t[56]!==ne||t[57]!==B?(V=(0,Z.jsx)(ne,{className:B}),t[56]=ne,t[57]=B,t[58]=V):V=t[58];let H;t[59]!==o.runDetail.resultTitle||t[60]!==V?(H=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[V,o.runDetail.resultTitle]}),t[59]=o.runDetail.resultTitle,t[60]=V,t[61]=H):H=t[61];let U;t[62]!==w||t[63]!==C||t[64]!==S?(U=S?(0,Z.jsx)(h,{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)(w,{className:`size-3.5`}),C,(0,Z.jsx)(R,{className:`size-3.5`})]})}):null,t[62]=w,t[63]=C,t[64]=S,t[65]=U):U=t[65];let W;t[66]!==H||t[67]!==U?(W=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[H,U]}),t[66]=H,t[67]=U,t[68]=W):W=t[68];let me=r.error&&`border-red-500/25 bg-red-500/5`,he;t[69]===me?he=t[70]:(he=m(`mt-3 max-h-80 overflow-y-auto rounded-lg border border-edge/70 bg-surface-muted/25 p-3`,me),t[69]=me,t[70]=he);let ge;t[71]!==o.runDetail.noResult||t[72]!==o.runDetail.resultPending||t[73]!==x||t[74]!==r?(ge=x?r.error?(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-red-700 dark:text-red-300`,children:x}):(0,Z.jsx)(u,{content:x,compact:!0,className:`text-sm`}):(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:pt(r)?o.runDetail.resultPending:o.runDetail.noResult}),t[71]=o.runDetail.noResult,t[72]=o.runDetail.resultPending,t[73]=x,t[74]=r,t[75]=ge):ge=t[75];let _e;t[76]!==he||t[77]!==ge?(_e=(0,Z.jsx)(`div`,{className:he,children:ge}),t[76]=he,t[77]=ge,t[78]=_e):_e=t[78];let ve;t[79]!==W||t[80]!==_e?(ve=(0,Z.jsxs)(`section`,{className:`border-b border-edge p-4`,children:[W,_e]}),t[79]=W,t[80]=_e,t[81]=ve):ve=t[81];let ye;t[82]===o.runDetail.runInfo?ye=t[83]:(ye=(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:o.runDetail.runInfo}),t[82]=o.runDetail.runInfo,t[83]=ye);let be;t[84]!==s||t[85]!==o||t[86]!==l||t[87]!==r.manual||t[88]!==r.triggerSnapshot?(be=r.manual?o.trigger.manual:Je(r.triggerSnapshot,o,s,l),t[84]=s,t[85]=o,t[86]=l,t[87]=r.manual,t[88]=r.triggerSnapshot,t[89]=be):be=t[89];let G;t[90]!==o.explain.whyRan||t[91]!==be?(G=(0,Z.jsx)(Bt,{label:o.explain.whyRan,value:be}),t[90]=o.explain.whyRan,t[91]=be,t[92]=G):G=t[92];let K=o.details.started,Se;t[93]!==o||t[94]!==l||t[95]!==r.startedAtMs?(Se=ct(r.startedAtMs,o,l),t[93]=o,t[94]=l,t[95]=r.startedAtMs,t[96]=Se):Se=t[96];let q;t[97]!==o.details.started||t[98]!==Se?(q=(0,Z.jsx)(Bt,{label:K,value:Se}),t[97]=o.details.started,t[98]=Se,t[99]=q):q=t[99];let Ce;t[100]!==o.details.model||t[101]!==r.model?(Ce=r.model?(0,Z.jsx)(Bt,{label:o.details.model,value:r.model}):null,t[100]=o.details.model,t[101]=r.model,t[102]=Ce):Ce=t[102];let we;t[103]!==G||t[104]!==q||t[105]!==Ce?(we=(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs text-fg-muted`,children:[G,q,Ce]}),t[103]=G,t[104]=q,t[105]=Ce,t[106]=we):we=t[106];let Te;t[107]!==ye||t[108]!==we?(Te=(0,Z.jsxs)(`section`,{className:`border-b border-edge p-4`,children:[ye,we]}),t[107]=ye,t[108]=we,t[109]=Te):Te=t[109];let Ee;t[110]!==_||t[111]!==o||t[112]!==ee||t[113]!==y||t[114]!==g||t[115]!==f||t[116]!==r?(Ee=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)(Dt,{title:o.repair.risks,items:f.risks,empty:o.none}),(0,Z.jsx)(Mt,{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:g,onChange:e=>y(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)(h,{variant:`primary`,onClick:()=>ee(r),disabled:_===`run:${r.id}:repair`||f.requiresApproval&&!g,children:_===`run:${r.id}:repair`?o.feedback.working:o.repair.apply})})]}):null,t[110]=_,t[111]=o,t[112]=ee,t[113]=y,t[114]=g,t[115]=f,t[116]=r,t[117]=Ee):Ee=t[117];let De;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,Z.jsx)(E,{className:`size-4 shrink-0`}),t[118]=De):De=t[118];let J;t[119]===o.runDetail.technicalEvents?J=t[120]:(J=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-sm font-medium text-fg-muted`,children:[De,o.runDetail.technicalEvents]}),t[119]=o.runDetail.technicalEvents,t[120]=J);let Oe;t[121]!==i.length||t[122]!==o.runDetail.eventCount?(Oe=o.runDetail.eventCount.replace(`{count}`,String(i.length)),t[121]=i.length,t[122]=o.runDetail.eventCount,t[123]=Oe):Oe=t[123];let ke;t[124]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,Z.jsx)(ue,{className:`size-4 transition-transform group-open:rotate-180`}),t[124]=ke):ke=t[124];let Y;t[125]===Oe?Y=t[126]:(Y=(0,Z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[Oe,ke]}),t[125]=Oe,t[126]=Y);let X;t[127]!==J||t[128]!==Y?(X=(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:[J,Y]}),t[127]=J,t[128]=Y,t[129]=X):X=t[129];let Ae;t[130]===o.runDetail.technicalEventsDescription?Ae=t[131]:(Ae=(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]=Ae);let je;t[132]!==i||t[133]!==o||t[134]!==l||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)(v,{className:`h-10 w-full`}),(0,Z.jsx)(v,{className:`h-10 w-4/5`}),(0,Z.jsx)(v,{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:m(`mt-1 size-2 rounded-full`,Vt(e.type))}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm text-fg`,children:jt(e,o)}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:[ct(e.createdAtMs,o,l),` · `,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)(ue,{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]=l,t[135]=d,t[136]=je):je=t[136];let Me;t[137]!==X||t[138]!==Ae||t[139]!==je?(Me=(0,Z.jsxs)(`details`,{className:`group px-4 py-3`,children:[X,Ae,je]}),t[137]=X,t[138]=Ae,t[139]=je,t[140]=Me):Me=t[140];let Ne;return t[141]!==re||t[142]!==de||t[143]!==ve||t[144]!==Te||t[145]!==Ee||t[146]!==Me?(Ne=(0,Z.jsxs)(`aside`,{className:re,children:[de,ve,Te,Ee,Me]}),t[141]=re,t[142]=de,t[143]=ve,t[144]=Te,t[145]=Ee,t[146]=Me,t[147]=Ne):Ne=t[147],Ne}function Ft(e){let t=(0,xe.c)(83),{automation:n,runs:r,labels:i,cronLabels:a,language:o,projects:s,busyAction:d,onEdit:f,onSelectRun:p,onAction:g}=e,_=d===`automation:${n.id}:run`,v=d===`automation:${n.id}:toggle`,y=d===`automation:${n.id}:delete`,b;t[0]===n?b=t[1]:(b=vt(n),t[0]=n,t[1]=b);let ee=b,x;t[2]===n.name?x=t[3]:(x=(0,Z.jsx)(`h2`,{className:`truncate text-lg font-semibold text-fg`,children:n.name}),t[2]=n.name,t[3]=x);let S=n.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`,C;t[4]===S?C=t[5]:(C=m(`shrink-0 rounded-full px-2 py-0.5 text-xs`,S),t[4]=S,t[5]=C);let w=n.enabled?i.enabled:i.paused,te;t[6]!==C||t[7]!==w?(te=(0,Z.jsx)(`span`,{className:C,children:w}),t[6]=C,t[7]=w,t[8]=te):te=t[8];let re;t[9]!==x||t[10]!==te?(re=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[x,te]}),t[9]=x,t[10]=te,t[11]=re):re=t[11];let T;t[12]===n?T=t[13]:(T=yt(n)?(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:yt(n)}):null,t[12]=n,t[13]=T);let E;t[14]!==re||t[15]!==T?(E=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[re,T]}),t[14]=re,t[15]=T,t[16]=E):E=t[16];let ae;t[17]!==n||t[18]!==d||t[19]!==y||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]!==g||t[30]!==f||t[31]!==ee||t[32]!==_||t[33]!==v?(ae=ee?null:(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsxs)(h,{variant:`secondary`,disabled:d!==null,onClick:()=>void g(`automation:${n.id}:toggle`,()=>n.enabled?P.pause(n.id):P.resume(n.id),n.enabled?i.feedback.paused:i.dashboard.resumed),children:[v?(0,Z.jsx)(A,{className:`size-4 animate-spin`}):n.enabled?(0,Z.jsx)(N,{className:`size-4`}):(0,Z.jsx)(ne,{className:`size-4`}),n.enabled?i.dashboard.pause:i.dashboard.resume]}),(0,Z.jsxs)(h,{variant:`primary`,disabled:d!==null,onClick:()=>void g(`automation:${n.id}:run`,()=>P.runNow(n.id),i.feedback.rerunQueued),children:[_?(0,Z.jsx)(A,{className:`size-4 animate-spin`}):(0,Z.jsx)(ne,{className:`size-4`}),i.dashboard.runNow]}),(0,Z.jsxs)(le,{children:[(0,Z.jsx)(k,{asChild:!0,children:(0,Z.jsx)(h,{variant:`ghost`,className:`size-9 p-0`,"aria-label":i.details.moreActions,children:(0,Z.jsx)(l,{className:`size-4`})})}),(0,Z.jsx)(se,{children:(0,Z.jsxs)(de,{align:`end`,className:`z-70 min-w-40 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[(0,Z.jsxs)(j,{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:()=>f(n),children:[(0,Z.jsx)(ie,{className:`size-4`}),i.edit]}),(0,Z.jsxs)(j,{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:d!==null,onSelect:()=>void g(`automation:${n.id}:delete`,()=>P.remove(n.id),i.dashboard.deleted),children:[y?(0,Z.jsx)(A,{className:`size-4 animate-spin`}):(0,Z.jsx)(O,{className:`size-4`}),i.dashboard.delete]})]})})]})]}),t[17]=n,t[18]=d,t[19]=y,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]=g,t[30]=f,t[31]=ee,t[32]=_,t[33]=v,t[34]=ae):ae=t[34];let D;t[35]!==ae||t[36]!==E?(D=(0,Z.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[E,ae]}),t[35]=ae,t[36]=E,t[37]=D):D=t[37];let oe;t[38]===i.info.task?oe=t[39]:(oe=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.info.task}),t[38]=i.info.task,t[39]=oe);let ce;t[40]!==n||t[41]!==i?(ce=gt(n,i),t[40]=n,t[41]=i,t[42]=ce):ce=t[42];let M;t[43]===ce?M=t[44]:(M=(0,Z.jsx)(`div`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base p-4`,children:(0,Z.jsx)(u,{content:ce,compact:!0})}),t[43]=ce,t[44]=M);let F;t[45]!==oe||t[46]!==M?(F=(0,Z.jsxs)(`section`,{children:[oe,M]}),t[45]=oe,t[46]=M,t[47]=F):F=t[47];let I;t[48]!==n||t[49]!==a||t[50]!==i||t[51]!==o||t[52]!==s?(I=(0,Z.jsx)(Lt,{automation:n,labels:i,cronLabels:a,language:o,projects:s}),t[48]=n,t[49]=a,t[50]=i,t[51]=o,t[52]=s,t[53]=I):I=t[53];let L;t[54]===i.dashboard.runHistory?L=t[55]:(L=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.dashboard.runHistory}),t[54]=i.dashboard.runHistory,t[55]=L);let ue;t[56]===i.dashboard.runHistoryDescription?ue=t[57]:(ue=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.dashboard.runHistoryDescription}),t[56]=i.dashboard.runHistoryDescription,t[57]=ue);let R;t[58]!==L||t[59]!==ue?(R=(0,Z.jsxs)(`div`,{children:[L,ue]}),t[58]=L,t[59]=ue,t[60]=R):R=t[60];let fe;t[61]===r.length?fe=t[62]:(fe=(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-base px-2.5 py-1 text-xs text-fg-muted`,children:r.length}),t[61]=r.length,t[62]=fe);let z;t[63]!==R||t[64]!==fe?(z=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[R,fe]}),t[63]=R,t[64]=fe,t[65]=z):z=t[65];let B;t[66]!==i||t[67]!==o||t[68]!==p||t[69]!==r?(B=r.length===0?(0,Z.jsx)(Ut,{icon:(0,Z.jsx)(pe,{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:()=>p(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)(c,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-300`}):(0,Z.jsx)(pe,{className:`size-4 shrink-0 text-fg-muted`}),(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:ct(e.createdAtMs,i,o)})]}),(0,Z.jsx)(`span`,{className:m(`shrink-0 rounded-full px-2 py-0.5 text-xs`,dt(e.status)),children:i.status[e.status]})]}),(0,Z.jsx)(`p`,{className:m(`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||lt(e.actionSnapshot,i)})]},e.id))}),t[66]=i,t[67]=o,t[68]=p,t[69]=r,t[70]=B):B=t[70];let V;t[71]!==z||t[72]!==B?(V=(0,Z.jsxs)(`section`,{className:`min-w-0`,children:[z,B]}),t[71]=z,t[72]=B,t[73]=V):V=t[73];let H;t[74]!==I||t[75]!==V?(H=(0,Z.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[20rem_minmax(0,1fr)]`,children:[I,V]}),t[74]=I,t[75]=V,t[76]=H):H=t[76];let U;t[77]!==F||t[78]!==H?(U=(0,Z.jsxs)(`div`,{className:`grid gap-5 p-5`,children:[F,H]}),t[77]=F,t[78]=H,t[79]=U):U=t[79];let W;return t[80]!==D||t[81]!==U?(W=(0,Z.jsxs)(`article`,{className:`min-w-0 overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel shadow-surface`,children:[D,U]}),t[80]=D,t[81]=U,t[82]=W):W=t[82],W}function It(e,t){return e===`suggest_only`?t.safety.suggestOnlyDescription:e===`ask_before_apply`?t.safety.askBeforeApplyDescription:t.safety.autoApplyDescription}function Lt(e){let t=(0,xe.c)(146),{automation:n,labels:r,cronLabels:i,language:a,projects:o}=e,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=ut(n),o;t[15]!==n||t[16]!==r||t[17]!==a?(o=Ye(n,r,a),t[15]=n,t[16]=r,t[17]=a,t[18]=o):o=t[18];let v=o,y;t[19]!==n.state.nextRunAtMs||t[20]!==a?(y=n.state.nextRunAtMs?We(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(_=[],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],_.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],_.push(i),e.anchorMs){let n=r.info.anchor,i;t[46]!==a||t[47]!==e.anchorMs?(i=We(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],_.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],_.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],_.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],_.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],_.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],_.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],_.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]=_}else _=t[39];h=`h-fit overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,t[70]===r.info.overview?g=t[71]:(g=(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]=g),f=`grid gap-4 p-4`;let ee;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Z.jsx)(I,{className:`size-4`,"aria-hidden":!0}),t[72]=ee):ee=t[72];let x=r.info.schedule,S;t[73]!==n.trigger||t[74]!==i||t[75]!==r||t[76]!==a?(S=Je(n.trigger,r,i,a),t[73]=n.trigger,t[74]=i,t[75]=r,t[76]=a,t[77]=S):S=t[77];let C=n.enabled?`${r.info.nextRun}:${v}`:v;t[78]!==r.info.schedule||t[79]!==b||t[80]!==S||t[81]!==C?(p=(0,Z.jsx)(zt,{icon:ee,label:x,value:S,description:C,descriptionTitle:b}),t[78]=r.info.schedule,t[79]=b,t[80]=S,t[81]=C,t[82]=p):p=t[82];let w;t[83]===n.action.kind?w=t[84]:(w=n.action.kind===`workflow`?(0,Z.jsx)(ce,{className:`size-4`,"aria-hidden":!0}):n.action.kind===`browser_recipe`?(0,Z.jsx)(E,{className:`size-4`,"aria-hidden":!0}):(0,Z.jsx)(re,{className:`size-4`,"aria-hidden":!0}),t[83]=n.action.kind,t[84]=w);let te=r.info.action,ne;t[85]!==n.action||t[86]!==r?(ne=lt(n.action,r),t[85]=n.action,t[86]=r,t[87]=ne):ne=t[87],t[88]!==r.info.action||t[89]!==w||t[90]!==ne?(m=(0,Z.jsx)(zt,{icon:w,label:te,value:ne}),t[88]=r.info.action,t[89]=w,t[90]=ne,t[91]=m):m=t[91],s=zt,t[92]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(L,{className:`size-4`,"aria-hidden":!0}),t[92]=c):c=t[92],l=r.info.permission,u=r.safety[e],d=It(e,r),t[0]=n,t[1]=i,t[2]=r,t[3]=a,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]=_}else s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13],_=t[14];let v;t[93]!==s||t[94]!==c||t[95]!==l||t[96]!==u||t[97]!==d?(v=(0,Z.jsx)(s,{icon:c,label:l,value:u,description:d}),t[93]=s,t[94]=c,t[95]=l,t[96]=u,t[97]=d,t[98]=v):v=t[98];let y;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(ce,{className:`size-4`,"aria-hidden":!0}),t[99]=y):y=t[99];let b;t[100]!==n.projectId||t[101]!==r.info.noProject||t[102]!==o?(b=o.find(e=>e.id===n.projectId)?.name??r.info.noProject,t[100]=n.projectId,t[101]=r.info.noProject,t[102]=o,t[103]=b):b=t[103];let ee;t[104]!==r.info.project||t[105]!==b?(ee=(0,Z.jsx)(zt,{icon:y,label:r.info.project,value:b}),t[104]=r.info.project,t[105]=b,t[106]=ee):ee=t[106];let x;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(oe,{className:`size-4`,"aria-hidden":!0}),t[107]=x):x=t[107];let S=n.conversationMode===`continuous`?r.info.continuousConversation:r.info.newConversation,C;t[108]!==r.info.conversation||t[109]!==S?(C=(0,Z.jsx)(zt,{icon:x,label:r.info.conversation,value:S}),t[108]=r.info.conversation,t[109]=S,t[110]=C):C=t[110];let w;t[111]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[111]=w):w=t[111];let ne=n.notificationPolicy===`all`?r.info.notifyAll:n.notificationPolicy===`none`?r.info.notifyNone:r.info.notifyAttention,ie;t[112]!==r.info.notifications||t[113]!==ne?(ie=(0,Z.jsx)(zt,{icon:w,label:r.info.notifications,value:ne}),t[112]=r.info.notifications,t[113]=ne,t[114]=ie):ie=t[114];let T;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(pe,{className:`size-4`,"aria-hidden":!0}),t[115]=T):T=t[115];let ae=r.info.lastRun,D;t[116]!==n||t[117]!==r||t[118]!==a?(D=Xe(n,r,a),t[116]=n,t[117]=r,t[118]=a,t[119]=D):D=t[119];let O=n.state.lastRunStatus===`failed`||n.state.lastRunStatus===`timeout`?`danger`:`default`,se;t[120]!==r.info.lastRun||t[121]!==D||t[122]!==O?(se=(0,Z.jsx)(zt,{icon:T,label:ae,value:D,valueTone:O}),t[120]=r.info.lastRun,t[121]=D,t[122]=O,t[123]=se):se=t[123];let k;t[124]!==n.state.consecutiveFailures||t[125]!==n.state.lastError||t[126]!==r.dashboard?(k=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[124]=n.state.consecutiveFailures,t[125]=n.state.lastError,t[126]=r.dashboard,t[127]=k):k=t[127];let A;t[128]!==r.info.technicalDetails||t[129]!==_?(A=_.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)(ue,{className:`size-4 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:_.map(Rt)})]}):null,t[128]=r.info.technicalDetails,t[129]=_,t[130]=A):A=t[130];let j;t[131]!==v||t[132]!==ee||t[133]!==C||t[134]!==ie||t[135]!==se||t[136]!==k||t[137]!==A||t[138]!==f||t[139]!==p||t[140]!==m?(j=(0,Z.jsxs)(`div`,{className:f,children:[p,m,v,ee,C,ie,se,k,A]}),t[131]=v,t[132]=ee,t[133]=C,t[134]=ie,t[135]=se,t[136]=k,t[137]=A,t[138]=f,t[139]=p,t[140]=m,t[141]=j):j=t[141];let M;return t[142]!==j||t[143]!==h||t[144]!==g?(M=(0,Z.jsxs)(`aside`,{className:h,children:[g,j]}),t[142]=j,t[143]=h,t[144]=g,t[145]=M):M=t[145],M}function Rt(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 zt(e){let t=(0,xe.c)(19),{icon:n,label:r,value:i,description:a,descriptionTitle:o,valueTone:s}=e,c=s===void 0?`default`:s,l;t[0]===n?l=t[1]:(l=(0,Z.jsx)(`span`,{className:`mt-0.5 text-fg-subtle`,children:n}),t[0]=n,t[1]=l);let u;t[2]===r?u=t[3]:(u=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r}),t[2]=r,t[3]=u);let d=c===`danger`?`text-red-700 dark:text-red-300`:`text-fg`,f;t[4]===d?f=t[5]:(f=m(`mt-1 text-sm font-medium leading-5`,d),t[4]=d,t[5]=f);let p;t[6]!==f||t[7]!==i?(p=(0,Z.jsx)(`div`,{className:f,children:i}),t[6]=f,t[7]=i,t[8]=p):p=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]!==u||t[13]!==p||t[14]!==h?(g=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[u,p,h]}),t[12]=u,t[13]=p,t[14]=h,t[15]=g):g=t[15];let _;return t[16]!==l||t[17]!==g?(_=(0,Z.jsxs)(`div`,{className:`grid grid-cols-[1.25rem_1fr] gap-2.5`,children:[l,g]}),t[16]=l,t[17]=g,t[18]=_):_=t[18],_}function Bt(e){let t=(0,xe.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 Vt(e){return e.endsWith(`.failed`)?`bg-red-500`:e.endsWith(`.completed`)?`bg-emerald-500`:e.endsWith(`.started`)?`bg-blue-500`:`bg-fg-muted`}function Ht(e){let t=(0,xe.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 Ut(e){let t=(0,xe.c)(8),{className:n,icon:r,title:i}=e,a;t[0]===n?a=t[1]:(a=m(`flex min-h-48 flex-col items-center justify-center rounded-lg border border-edge-subtle bg-surface-base text-fg-muted shadow-surface`,n),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=(0,Z.jsx)(`div`,{className:`mt-2 text-sm`,children:i}),t[2]=i,t[3]=o);let s;return t[4]!==r||t[5]!==a||t[6]!==o?(s=(0,Z.jsxs)(`div`,{className:a,children:[r,o]}),t[4]=r,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Wt(e){let t=(0,xe.c)(274),{form:n,labels:r,setForm:i,projects:a,workflowDefinitions:c,selectedWorkflow:l,workflowsLoading:u,browserWorkflows:d,selectedBrowserWorkflow:f,browserWorkflowsLoading:p,agentOptions:h,agentsLoading:_,language:v,projectLocked:y}=e,b=y===void 0?!1:y,ee=g(v).agentsSettings,x;t[0]===i?x=t[1]:(x=e=>i(t=>({...t,...e})),t[0]=i,t[1]=x);let S=x,C=Be(n.intervalValue,n.intervalUnit),w=Date.now(),te;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(te=[1,2,3],t[2]=te):te=t[2];let ne;t[3]!==C||t[4]!==w||t[5]!==v?(ne=te.map(e=>Ke(w+C*e,v,w)),t[3]=C,t[4]=w,t[5]=v,t[6]=ne):ne=t[6];let re=ne,ie,T;t[7]!==n.actionMode||t[8]!==n.workflowId||t[9]!==i||t[10]!==c?(ie=()=>{if(n.actionMode!==`workflow`||n.workflowId.trim())return;let e=c[0]?.id;e&&i(t=>({...t,workflowId:e,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}))},T=[n.actionMode,n.workflowId,i,c],t[7]=n.actionMode,t[8]=n.workflowId,t[9]=i,t[10]=c,t[11]=ie,t[12]=T):(ie=t[11],T=t[12]),(0,K.useEffect)(ie,T);let E,ae;t[13]!==d||t[14]!==n.actionMode||t[15]!==n.browserWorkflowId||t[16]!==i?(E=()=>{if(n.actionMode!==`browser_recipe`||n.browserWorkflowId.trim())return;let e=d[0];e&&i(t=>({...t,browserWorkflowId:e.id,browserWorkflowInputs:be(e)}))},ae=[d,n.actionMode,n.browserWorkflowId,i],t[13]=d,t[14]=n.actionMode,t[15]=n.browserWorkflowId,t[16]=i,t[17]=E,t[18]=ae):(E=t[17],ae=t[18]),(0,K.useEffect)(E,ae);let oe;t[19]===S?oe=t[20]:(oe=e=>S({name:e.target.value}),t[19]=S,t[20]=oe);let O;t[21]!==n.name||t[22]!==oe?(O=(0,Z.jsx)(`input`,{className:Q,value:n.name,onChange:oe}),t[21]=n.name,t[22]=oe,t[23]=O):O=t[23];let se;t[24]!==r.form.name||t[25]!==O?(se=(0,Z.jsx)($,{label:r.form.name,children:O}),t[24]=r.form.name,t[25]=O,t[26]=se):se=t[26];let ce;t[27]===S?ce=t[28]:(ce=e=>S({description:e.target.value}),t[27]=S,t[28]=ce);let k;t[29]!==n.description||t[30]!==ce?(k=(0,Z.jsx)(`input`,{className:Q,value:n.description,onChange:ce}),t[29]=n.description,t[30]=ce,t[31]=k):k=t[31];let A;t[32]!==r.form.description||t[33]!==k?(A=(0,Z.jsx)($,{label:r.form.description,children:k}),t[32]=r.form.description,t[33]=k,t[34]=A):A=t[34];let j;t[35]!==n.projectId||t[36]!==r.form.noProject||t[37]!==r.form.project||t[38]!==b||t[39]!==a||t[40]!==S?(j=b?null:(0,Z.jsx)($,{label:r.form.project,children:(0,Z.jsxs)(o,{className:Q,value:n.projectId,onChange:e=>S({projectId:e.target.value}),children:[(0,Z.jsx)(s,{value:``,children:r.form.noProject}),a.map(qt)]})}),t[35]=n.projectId,t[36]=r.form.noProject,t[37]=r.form.project,t[38]=b,t[39]=a,t[40]=S,t[41]=j):j=t[41];let M;t[42]===r.form.trigger?M=t[43]:(M=(0,Z.jsx)(Jt,{title:r.form.trigger}),t[42]=r.form.trigger,t[43]=M);let N;t[44]===S?N=t[45]:(N=e=>S({triggerMode:e.target.value}),t[44]=S,t[45]=N);let P;t[46]===r.trigger.manual?P=t[47]:(P=(0,Z.jsx)(s,{value:`manual`,children:r.trigger.manual}),t[46]=r.trigger.manual,t[47]=P);let F;t[48]===r.trigger.once?F=t[49]:(F=(0,Z.jsx)(s,{value:`once`,children:r.trigger.once}),t[48]=r.trigger.once,t[49]=F);let I;t[50]===r.trigger.daily?I=t[51]:(I=(0,Z.jsx)(s,{value:`daily`,children:r.trigger.daily}),t[50]=r.trigger.daily,t[51]=I);let le;t[52]===r.trigger.weekly?le=t[53]:(le=(0,Z.jsx)(s,{value:`weekly`,children:r.trigger.weekly}),t[52]=r.trigger.weekly,t[53]=le);let L;t[54]===r.trigger.interval?L=t[55]:(L=(0,Z.jsx)(s,{value:`interval`,children:r.trigger.interval}),t[54]=r.trigger.interval,t[55]=L);let de;t[56]===r.trigger.customCron?de=t[57]:(de=(0,Z.jsx)(s,{value:`cron`,children:r.trigger.customCron}),t[56]=r.trigger.customCron,t[57]=de);let R;t[58]===r.trigger.webhook?R=t[59]:(R=(0,Z.jsx)(s,{value:`webhook`,children:r.trigger.webhook}),t[58]=r.trigger.webhook,t[59]=R);let fe;t[60]===r.trigger.taskBlocked?fe=t[61]:(fe=(0,Z.jsx)(s,{value:`taskBlocked`,children:r.trigger.taskBlocked}),t[60]=r.trigger.taskBlocked,t[61]=fe);let z;t[62]===r.trigger.noteCreated?z=t[63]:(z=(0,Z.jsx)(s,{value:`noteCreated`,children:r.trigger.noteCreated}),t[62]=r.trigger.noteCreated,t[63]=z);let pe;t[64]===r.trigger.workflowFailed?pe=t[65]:(pe=(0,Z.jsx)(s,{value:`workflowFailed`,children:r.trigger.workflowFailed}),t[64]=r.trigger.workflowFailed,t[65]=pe);let B;t[66]===r.trigger.sessionUpdated?B=t[67]:(B=(0,Z.jsx)(s,{value:`sessionUpdated`,children:r.trigger.sessionUpdated}),t[66]=r.trigger.sessionUpdated,t[67]=B);let V;t[68]===r.trigger.customEvent?V=t[69]:(V=(0,Z.jsx)(s,{value:`event`,children:r.trigger.customEvent}),t[68]=r.trigger.customEvent,t[69]=V);let U;t[70]!==n.triggerMode||t[71]!==N||t[72]!==P||t[73]!==F||t[74]!==I||t[75]!==le||t[76]!==L||t[77]!==de||t[78]!==R||t[79]!==fe||t[80]!==z||t[81]!==pe||t[82]!==B||t[83]!==V?(U=(0,Z.jsxs)(o,{className:Q,value:n.triggerMode,onChange:N,children:[P,F,I,le,L,de,R,fe,z,pe,B,V]}),t[70]=n.triggerMode,t[71]=N,t[72]=P,t[73]=F,t[74]=I,t[75]=le,t[76]=L,t[77]=de,t[78]=R,t[79]=fe,t[80]=z,t[81]=pe,t[82]=B,t[83]=V,t[84]=U):U=t[84];let me;t[85]!==n.onceAt||t[86]!==n.triggerMode||t[87]!==r.form.onceAt||t[88]!==S?(me=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[85]=n.onceAt,t[86]=n.triggerMode,t[87]=r.form.onceAt,t[88]=S,t[89]=me):me=t[89];let he;t[90]!==n.time||t[91]!==n.triggerMode||t[92]!==n.weekday||t[93]!==r.form.day||t[94]!==r.form.time||t[95]!==r.weekdays||t[96]!==S?(he=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)(H,{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[90]=n.time,t[91]=n.triggerMode,t[92]=n.weekday,t[93]=r.form.day,t[94]=r.form.time,t[95]=r.weekdays,t[96]=S,t[97]=he):he=t[97];let ge=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/Be(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:Ve(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:Qe.map(e=>{let t=Be(e.value,e.unit),n=t===C;return(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":n,className:m(`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:He(t,v)},`${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:Ue(C,v)}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:[r.form.nextThreeRuns,`:`,re.join(v===`zh`?`、`:`, `)]}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:r.form.fixedIntervalHint})]})]}):null,ve;t[98]!==n.cronExpr||t[99]!==n.triggerMode||t[100]!==r.form.expression||t[101]!==S?(ve=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[98]=n.cronExpr,t[99]=n.triggerMode,t[100]=r.form.expression,t[101]=S,t[102]=ve):ve=t[102];let ye;t[103]!==n.triggerMode||t[104]!==n.webhookSecretId||t[105]!==r.form.secretId||t[106]!==S?(ye=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[103]=n.triggerMode,t[104]=n.webhookSecretId,t[105]=r.form.secretId,t[106]=S,t[107]=ye):ye=t[107];let Se;t[108]!==n.eventPayloadMatch||t[109]!==n.eventSource||t[110]!==n.eventType||t[111]!==n.triggerMode||t[112]!==r.form.eventPayloadMatch||t[113]!==r.form.eventSource||t[114]!==r.form.eventType||t[115]!==r.form.invalidJsonObject||t[116]!==S?(Se=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:m(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
|
-
}`}),at(n.eventPayloadMatch)?null:(0,Z.jsx)(`span`,{className:`text-xs text-red-700 dark:text-red-300`,children:r.form.invalidJsonObject})]})]}):null,t[108]=n.eventPayloadMatch,t[109]=n.eventSource,t[110]=n.eventType,t[111]=n.triggerMode,t[112]=r.form.eventPayloadMatch,t[113]=r.form.eventSource,t[114]=r.form.eventType,t[115]=r.form.invalidJsonObject,t[116]=S,t[117]=Se):Se=t[117];let q;t[118]===r.form.action?q=t[119]:(q=(0,Z.jsx)(Jt,{title:r.form.action}),t[118]=r.form.action,t[119]=q);let Ce;t[120]!==n.timeoutSeconds||t[121]!==n.workflowId||t[122]!==S||t[123]!==c?(Ce=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()&&c[0]?{workflowId:c[0].id,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}:{}})},t[120]=n.timeoutSeconds,t[121]=n.workflowId,t[122]=S,t[123]=c,t[124]=Ce):Ce=t[124];let we;t[125]===r.action.runAgent?we=t[126]:(we=(0,Z.jsx)(s,{value:`agent`,children:r.action.runAgent}),t[125]=r.action.runAgent,t[126]=we);let Te;t[127]===r.action.runWorkflow?Te=t[128]:(Te=(0,Z.jsx)(s,{value:`workflow`,children:r.action.runWorkflow}),t[127]=r.action.runWorkflow,t[128]=Te);let Ee=v===`zh`?`浏览器自动化`:`Browser automation`,De;t[129]===Ee?De=t[130]:(De=(0,Z.jsx)(s,{value:`browser_recipe`,children:Ee}),t[129]=Ee,t[130]=De);let J;t[131]!==n.actionMode||t[132]!==Ce||t[133]!==we||t[134]!==Te||t[135]!==De?(J=(0,Z.jsxs)(o,{className:Q,value:n.actionMode,onChange:Ce,children:[we,Te,De]}),t[131]=n.actionMode,t[132]=Ce,t[133]=we,t[134]=Te,t[135]=De,t[136]=J):J=t[136];let Oe=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:_?r.form.loadingAgents:r.form.defaultAgent}),h.map(e=>(0,Z.jsx)(s,{value:e.id,children:D(e,ee)},e.id))]})}),ke;t[137]!==d||t[138]!==p||t[139]!==n.actionMode||t[140]!==n.agentId||t[141]!==n.browserWorkflowId||t[142]!==n.browserWorkflowInputs||t[143]!==n.description||t[144]!==n.instruction||t[145]!==n.name||t[146]!==n.triggerMode||t[147]!==n.workflowId||t[148]!==n.workflowInput||t[149]!==r.form.instruction||t[150]!==r.form.loadingWorkflows||t[151]!==r.form.noWorkflows||t[152]!==r.form.triggeredRun||t[153]!==r.form.workflow||t[154]!==v||t[155]!==f||t[156]!==l||t[157]!==S||t[158]!==c||t[159]!==u?(ke=n.actionMode===`agent`?(0,Z.jsxs)($,{label:r.form.instruction,children:[(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(W,{value:n.instruction,onApply:e=>S({instruction:e}),fieldId:`automation.instruction`,fieldLabel:r.form.instruction,scenario:`automation.instruction`,locale:v,context:{automationName:n.name,automationDescription:n.description,triggerMode:n.triggerMode,agentId:n.agentId},showLabel:!1})}),(0,Z.jsx)(`textarea`,{className:m(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:u||c.length===0,children:[u?(0,Z.jsx)(s,{value:``,children:r.form.loadingWorkflows}):null,!u&&c.length===0?(0,Z.jsx)(s,{value:``,children:r.form.noWorkflows}):null,c.map(Kt)]})}),l?(0,Z.jsx)(_e,{definition:l,language:v,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:v===`zh`?`浏览器自动化`:`Browser automation`,children:(0,Z.jsxs)(o,{className:Q,value:n.browserWorkflowId,onChange:e=>{let t=d.find(t=>t.id===e.target.value);S({browserWorkflowId:e.target.value,browserWorkflowInputs:t?be(t):{}})},disabled:p||d.length===0,children:[d.length===0?(0,Z.jsx)(s,{value:``,children:v===`zh`?`没有已启用的浏览器自动化`:`No enabled browser automations`}):null,d.map(Gt)]})}),f&&Object.keys(f.inputs).length>0?(0,Z.jsx)($,{label:v===`zh`?`运行时填写`:`Run inputs`,children:(0,Z.jsx)(G,{workflow:f,values:n.browserWorkflowInputs,language:v,onChange:e=>S({browserWorkflowInputs:e})})}):null]}),t[137]=d,t[138]=p,t[139]=n.actionMode,t[140]=n.agentId,t[141]=n.browserWorkflowId,t[142]=n.browserWorkflowInputs,t[143]=n.description,t[144]=n.instruction,t[145]=n.name,t[146]=n.triggerMode,t[147]=n.workflowId,t[148]=n.workflowInput,t[149]=r.form.instruction,t[150]=r.form.loadingWorkflows,t[151]=r.form.noWorkflows,t[152]=r.form.triggeredRun,t[153]=r.form.workflow,t[154]=v,t[155]=f,t[156]=l,t[157]=S,t[158]=c,t[159]=u,t[160]=ke):ke=t[160];let Y;t[161]===r.form.advancedDescription?Y=t[162]:(Y=(0,Z.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:r.form.advancedDescription}),t[161]=r.form.advancedDescription,t[162]=Y);let X;t[163]!==r.form.advanced||t[164]!==Y?(X=(0,Z.jsxs)(`span`,{children:[r.form.advanced,Y]}),t[163]=r.form.advanced,t[164]=Y,t[165]=X):X=t[165];let Ae;t[166]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=(0,Z.jsx)(ue,{className:`size-4 transition-transform group-open:rotate-180`}),t[166]=Ae):Ae=t[166];let je;t[167]===X?je=t[168]:(je=(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:[X,Ae]}),t[167]=X,t[168]=je);let Me;t[169]!==n.actionMode||t[170]!==n.safetyMode||t[171]!==r.form.safety||t[172]!==r.safety||t[173]!==S?(Me=n.actionMode===`browser_recipe`?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Jt,{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})},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[169]=n.actionMode,t[170]=n.safetyMode,t[171]=r.form.safety,t[172]=r.safety,t[173]=S,t[174]=Me):Me=t[174];let Ne;t[175]===r.form.results?Ne=t[176]:(Ne=(0,Z.jsx)(Jt,{title:r.form.results}),t[175]=r.form.results,t[176]=Ne);let Pe;t[177]===S?Pe=t[178]:(Pe=e=>S({conversationMode:e.target.value}),t[177]=S,t[178]=Pe);let Fe;t[179]===r.form.newConversation?Fe=t[180]:(Fe=(0,Z.jsx)(s,{value:`new_session`,children:r.form.newConversation}),t[179]=r.form.newConversation,t[180]=Fe);let Ie;t[181]===r.form.continuousConversation?Ie=t[182]:(Ie=(0,Z.jsx)(s,{value:`continuous`,children:r.form.continuousConversation}),t[181]=r.form.continuousConversation,t[182]=Ie);let Le;t[183]!==n.conversationMode||t[184]!==Pe||t[185]!==Fe||t[186]!==Ie?(Le=(0,Z.jsxs)(o,{className:Q,value:n.conversationMode,onChange:Pe,children:[Fe,Ie]}),t[183]=n.conversationMode,t[184]=Pe,t[185]=Fe,t[186]=Ie,t[187]=Le):Le=t[187];let Re;t[188]!==r.form.conversation||t[189]!==Le?(Re=(0,Z.jsx)($,{label:r.form.conversation,children:Le}),t[188]=r.form.conversation,t[189]=Le,t[190]=Re):Re=t[190];let ze;t[191]===S?ze=t[192]:(ze=e=>S({notificationPolicy:e.target.value}),t[191]=S,t[192]=ze);let We;t[193]===r.form.notifyAttention?We=t[194]:(We=(0,Z.jsx)(s,{value:`attention`,children:r.form.notifyAttention}),t[193]=r.form.notifyAttention,t[194]=We);let Ge;t[195]===r.form.notifyAll?Ge=t[196]:(Ge=(0,Z.jsx)(s,{value:`all`,children:r.form.notifyAll}),t[195]=r.form.notifyAll,t[196]=Ge);let qe;t[197]===r.form.notifyNone?qe=t[198]:(qe=(0,Z.jsx)(s,{value:`none`,children:r.form.notifyNone}),t[197]=r.form.notifyNone,t[198]=qe);let Je;t[199]!==n.notificationPolicy||t[200]!==ze||t[201]!==We||t[202]!==Ge||t[203]!==qe?(Je=(0,Z.jsxs)(o,{className:Q,value:n.notificationPolicy,onChange:ze,children:[We,Ge,qe]}),t[199]=n.notificationPolicy,t[200]=ze,t[201]=We,t[202]=Ge,t[203]=qe,t[204]=Je):Je=t[204];let Ye;t[205]!==r.form.notifications||t[206]!==Je?(Ye=(0,Z.jsx)($,{label:r.form.notifications,children:Je}),t[205]=r.form.notifications,t[206]=Je,t[207]=Ye):Ye=t[207];let Xe;t[208]!==n.completionWebhookUrl||t[209]!==n.safetyMode||t[210]!==r.form.completionWebhook||t[211]!==S?(Xe=n.safetyMode===`auto_apply`?(0,Z.jsx)($,{label:r.form.completionWebhook,children:(0,Z.jsx)(`input`,{className:Q,value:n.completionWebhookUrl,onChange:e=>S({completionWebhookUrl:e.target.value})})}):null,t[208]=n.completionWebhookUrl,t[209]=n.safetyMode,t[210]=r.form.completionWebhook,t[211]=S,t[212]=Xe):Xe=t[212];let Ze;t[213]===r.form.reliability?Ze=t[214]:(Ze=(0,Z.jsx)(Jt,{title:r.form.reliability}),t[213]=r.form.reliability,t[214]=Ze);let $e;t[215]===S?$e=t[216]:($e=e=>S({timeoutSeconds:e.target.value}),t[215]=S,t[216]=$e);let et;t[217]!==n.timeoutSeconds||t[218]!==$e?(et=(0,Z.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.timeoutSeconds,onChange:$e}),t[217]=n.timeoutSeconds,t[218]=$e,t[219]=et):et=t[219];let tt;t[220]!==r.form.timeoutSeconds||t[221]!==et?(tt=(0,Z.jsx)($,{label:r.form.timeoutSeconds,children:et}),t[220]=r.form.timeoutSeconds,t[221]=et,t[222]=tt):tt=t[222];let nt;t[223]===S?nt=t[224]:(nt=e=>S({disableAfterFailures:e.target.value}),t[223]=S,t[224]=nt);let rt;t[225]!==n.disableAfterFailures||t[226]!==nt?(rt=(0,Z.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.disableAfterFailures,onChange:nt}),t[225]=n.disableAfterFailures,t[226]=nt,t[227]=rt):rt=t[227];let it;t[228]!==r.form.disableAfterFailures||t[229]!==rt?(it=(0,Z.jsx)($,{label:r.form.disableAfterFailures,children:rt}),t[228]=r.form.disableAfterFailures,t[229]=rt,t[230]=it):it=t[230];let ot;t[231]!==tt||t[232]!==it?(ot=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[tt,it]}),t[231]=tt,t[232]=it,t[233]=ot):ot=t[233];let st;t[234]===r.form.effectivePolicy?st=t[235]:(st=(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.form.effectivePolicy}),t[234]=r.form.effectivePolicy,t[235]=st);let ct=n.timeoutSeconds||`—`,lt;t[236]!==r.form.executionDeadline||t[237]!==ct?(lt=(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[r.form.executionDeadline,`: `,ct,`s`]}),t[236]=r.form.executionDeadline,t[237]=ct,t[238]=lt):lt=t[238];let ut;t[239]===r.form.downstreamTimeoutHint?ut=t[240]:(ut=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-fg-subtle`,children:r.form.downstreamTimeoutHint}),t[239]=r.form.downstreamTimeoutHint,t[240]=ut);let dt;t[241]!==st||t[242]!==lt||t[243]!==ut?(dt=(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-muted/40 px-3 py-2.5`,children:[st,lt,ut]}),t[241]=st,t[242]=lt,t[243]=ut,t[244]=dt):dt=t[244];let ft;t[245]!==Me||t[246]!==Ne||t[247]!==Re||t[248]!==Ye||t[249]!==Xe||t[250]!==Ze||t[251]!==ot||t[252]!==dt?(ft=(0,Z.jsxs)(`div`,{className:`grid gap-4 border-t border-edge-subtle p-4`,children:[Me,Ne,Re,Ye,Xe,Ze,ot,dt]}),t[245]=Me,t[246]=Ne,t[247]=Re,t[248]=Ye,t[249]=Xe,t[250]=Ze,t[251]=ot,t[252]=dt,t[253]=ft):ft=t[253];let pt;t[254]!==je||t[255]!==ft?(pt=(0,Z.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base`,children:[je,ft]}),t[254]=je,t[255]=ft,t[256]=pt):pt=t[256];let mt;return t[257]!==se||t[258]!==A||t[259]!==j||t[260]!==M||t[261]!==U||t[262]!==me||t[263]!==he||t[264]!==ge||t[265]!==ve||t[266]!==ye||t[267]!==Se||t[268]!==q||t[269]!==J||t[270]!==Oe||t[271]!==ke||t[272]!==pt?(mt=(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:[se,A,j,M,U,me,he,ge,ve,ye,Se,q,J,Oe,ke,pt]})}),t[257]=se,t[258]=A,t[259]=j,t[260]=M,t[261]=U,t[262]=me,t[263]=he,t[264]=ge,t[265]=ve,t[266]=ye,t[267]=Se,t[268]=q,t[269]=J,t[270]=Oe,t[271]=ke,t[272]=pt,t[273]=mt):mt=t[273],mt}function Gt(e){return(0,Z.jsx)(s,{value:e.id,children:e.name},e.id)}function Kt(e){return(0,Z.jsx)(s,{value:e.id,children:e.title||e.name},e.id)}function qt(e){return(0,Z.jsx)(s,{value:e.id,children: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,xe.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 Jt(e){let t=(0,xe.c)(3),{title:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(ce,{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{wt as t};
|
|
@@ -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{p as i}from"./chunk-KS7C4IRE-BaASWQor.js";import{n as a,r as o}from"./popover-select-DrILF6mR.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./cloud-C4-yfnnk.js";import{t as l}from"./download-Dk-ZjtO6.js";import{t as u}from"./external-link-DjqjBmc3.js";import{t as d}from"./globe-DSSGFWFn.js";import{t as f}from"./loader-circle-CifKLtgG.js";import{t as p}from"./cn-JdwAhgNB.js";import{t as m}from"./button-CSEbl4zT.js";import{a as h,o as g,s as _}from"./form-field-width-DJw_jULe.js";import{t as v}from"./copy-to-clipboard-HOJ79TWv.js";import{t as y}from"./messages-B1HDp_j8.js";import{a as b,i as x,n as S,r as C,s as w}from"./locale-store-XDFAPNNu.js";import{n as T,r as E}from"./gateway-config-swr-DfMY-MLf.js";import{Bo as D,Co as O,Cs as k,Ei as A,Fc as j,Gc as M,Jc as N,Lo as P,Ls as F,Ss as I,To as L,Wc as R,Zn as z,Zo as B,_o as V,aa as H,hs as ee,ia as U,ko as W,oa as G,os as K,rs as te,ss as ne,tl as re,ws as ie,ys as ae}from"./index-BN4XPtJY.js";import{n as oe,r as se,t as ce}from"./settings-page-layout-BRQNel6r.js";import{n as le}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as ue,t as q}from"./settings-form-section-OMPX3Svb.js";import{n as de,t as fe}from"./use-autosave-CkwILwYg.js";import{t as pe}from"./page-tabs-BaEQMYm_.js";import{t as me}from"./settings-advanced-gate-CUcTHMDp.js";import{a as he,c as ge,d as _e,u as ve}from"./gateway-config-api-4GYzRHAt.js";import{t as ye}from"./tab-completion-input-D64VNmiA.js";var J=e(t(),1),Y=n(),X=r();function Z(e){let t=(0,Y.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,X.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,X.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,X.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 Q(){return p(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,_,`dark:border-edge`)}function be(){return p(g,h)}function xe(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 Se(e){let t=(0,Y.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,X.jsx)(`label`,{htmlFor:`browser-backend-select`,className:`text-sm font-medium text-fg`,children:s.browserPickerTitle}),t[8]=s.browserPickerTitle,t[9]=l);let u;t[10]===s.browserPickerSubtitle?u=t[11]:(u=(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:s.browserPickerSubtitle}),t[10]=s.browserPickerSubtitle,t[11]=u);let d;t[12]!==l||t[13]!==u?(d=(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[l,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(f=p(be(),`min-w-0 flex-1 sm:max-w-md`),t[15]=f):f=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(Ce),t[18]=o,t[19]=g);let _;t[20]!==s.browserPickerTitle||t[21]!==m||t[22]!==g||t[23]!==n?(_=(0,X.jsx)(a,{id:`browser-backend-select`,className:f,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,X.jsxs)(`button`,{type:`button`,className:p(`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,X.jsx)(`span`,{children:s.browserGoToConfigure}),(0,X.jsx)(re,{className:`size-4 shrink-0`,"aria-hidden":!0})]}):null,y;t[25]!==v||t[26]!==_?(y=(0,X.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,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,y,e?(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.statusLabel?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-medium text-fg-muted`,"aria-label":e.statusLabel,children:[(0,X.jsx)(`span`,{className:p(`inline-block size-1.5 rounded-full`,xe(e.status)),"aria-hidden":!0}),e.statusLabel]}):null}),(0,X.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 Ce(e){return(0,X.jsx)(o,{value:e.value,children:e.name},e.value)}function we(e){return`browser-focus-${e}`}function Te(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 Ee(e){let t=(0,Y.c)(95),{a:n,form:r,update:i}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=we(`runtime`),t[0]=s):s=t[0];let c;t[1]===n.browserBehaviorShow?c=t[2]:(c=(0,X.jsx)(ue,{icon:te,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,X.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,X.jsx)(`span`,{children:n.browserHeadlessOn}),t[8]=n.browserHeadlessOn,t[9]=d);let f;t[10]!==u||t[11]!==d?(f=(0,X.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,X.jsx)(Z,{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=be(),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,X.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,X.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,X.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,X.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,X.jsx)(Z,{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=Q(),t[36]=T):T=t[36];let E=r.browserDialogTimeout??``,D;t[37]===i?D=t[38]:(D=e=>i({browserDialogTimeout:Number.parseInt(e,10)}),t[37]=i,t[38]=D);let O;t[39]===i?O=t[40]:(O=e=>{let t=e.target.value;i({browserDialogTimeout:t===``?void 0:Number.parseInt(t,10)})},t[39]=i,t[40]=O);let k;t[41]!==E||t[42]!==D||t[43]!==O?(k=(0,X.jsx)(ye,{type:`number`,className:T,min:1,value:E,suggestion:`300`,onAcceptSuggestion:D,placeholder:`300`,onChange:O}),t[41]=E,t[42]=D,t[43]=O,t[44]=k):k=t[44];let A;t[45]!==n.desc.browserDialogTimeout||t[46]!==n.label.browserDialogTimeout||t[47]!==k?(A=(0,X.jsx)(Z,{label:C,description:w,children:k}),t[45]=n.desc.browserDialogTimeout,t[46]=n.label.browserDialogTimeout,t[47]=k,t[48]=A):A=t[48];let j;t[49]!==S||t[50]!==A||t[51]!==p?(j=(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[p,S,A]}),t[49]=S,t[50]=A,t[51]=p,t[52]=j):j=t[52];let M;t[53]!==c||t[54]!==j?(M=(0,X.jsx)(`div`,{id:s,className:`scroll-mt-24`,children:(0,X.jsxs)(q,{children:[c,j]})}),t[53]=c,t[54]=j,t[55]=M):M=t[55];let N;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(N=we(`security`),t[56]=N):N=t[56];let P;t[57]===n.browserSecurityShow?P=t[58]:(P=(0,X.jsx)(ue,{icon:ne,title:n.browserSecurityShow}),t[57]=n.browserSecurityShow,t[58]=P);let F;t[59]===i?F=t[60]:(F=e=>i({browserAllowPrivateUrls:e.target.checked}),t[59]=i,t[60]=F);let I;t[61]!==r.browserAllowPrivateUrls||t[62]!==F?(I=(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserAllowPrivateUrls,onChange:F}),t[61]=r.browserAllowPrivateUrls,t[62]=F,t[63]=I):I=t[63];let L;t[64]===n.browserAllowPrivateOn?L=t[65]:(L=(0,X.jsx)(`span`,{children:n.browserAllowPrivateOn}),t[64]=n.browserAllowPrivateOn,t[65]=L);let R;t[66]!==I||t[67]!==L?(R=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[I,L]}),t[66]=I,t[67]=L,t[68]=R):R=t[68];let z;t[69]!==n.desc.browserAllowPrivateUrls||t[70]!==n.label.browserAllowPrivateUrls||t[71]!==R?(z=(0,X.jsx)(Z,{label:n.label.browserAllowPrivateUrls,description:n.desc.browserAllowPrivateUrls,children:R}),t[69]=n.desc.browserAllowPrivateUrls,t[70]=n.label.browserAllowPrivateUrls,t[71]=R,t[72]=z):z=t[72];let B=n.label.browserCommandTimeout,V=n.desc.browserCommandTimeout,H;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(H=Q(),t[73]=H):H=t[73];let ee=r.browserCommandTimeout??``,U;t[74]===i?U=t[75]:(U=e=>i({browserCommandTimeout:Number.parseInt(e,10)}),t[74]=i,t[75]=U);let W;t[76]===i?W=t[77]:(W=e=>{let t=e.target.value;i({browserCommandTimeout:t===``?void 0:Number.parseInt(t,10)})},t[76]=i,t[77]=W);let G;t[78]!==ee||t[79]!==U||t[80]!==W?(G=(0,X.jsx)(ye,{type:`number`,className:H,min:5,value:ee,suggestion:`30`,onAcceptSuggestion:U,placeholder:`30`,onChange:W}),t[78]=ee,t[79]=U,t[80]=W,t[81]=G):G=t[81];let K;t[82]!==n.desc.browserCommandTimeout||t[83]!==n.label.browserCommandTimeout||t[84]!==G?(K=(0,X.jsx)(Z,{label:B,description:V,children:G}),t[82]=n.desc.browserCommandTimeout,t[83]=n.label.browserCommandTimeout,t[84]=G,t[85]=K):K=t[85];let re;t[86]!==z||t[87]!==K?(re=(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[z,K]}),t[86]=z,t[87]=K,t[88]=re):re=t[88];let ie;t[89]!==P||t[90]!==re?(ie=(0,X.jsx)(`div`,{id:N,className:`scroll-mt-24`,children:(0,X.jsxs)(q,{className:`border border-amber-500/20`,children:[P,re]})}),t[89]=P,t[90]=re,t[91]=ie):ie=t[91];let ae;return t[92]!==M||t[93]!==ie?(ae=(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[M,ie]}),t[92]=M,t[93]=ie,t[94]=ae):ae=t[94],ae}function De(e){let t=(0,Y.c)(9),{language:n,label:r,className:i}=e,a;t[0]===n?a=t[1]:(a=V(n),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=p(`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 s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,X.jsx)(u,{className:`size-3 shrink-0`,"aria-hidden":!0}),t[4]=s):s=t[4];let c;return t[5]!==r||t[6]!==a||t[7]!==o?(c=(0,X.jsxs)(`a`,{href:a,target:`_blank`,rel:`noreferrer`,className:o,children:[r,s]}),t[5]=r,t[6]=a,t[7]=o,t[8]=c):c=t[8],c}function Oe(e){let t=(0,Y.c)(27),{title:n,description:r,recommended:i,recommendedLabel:a,icon:o,onSelect:s,selectLabel:c}=e,l=`${n} — ${c}`,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=p(`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]=u):u=t[0];let d;t[1]===o?d=t[2]:(d=(0,X.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,X.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=o,t[2]=d);let f;t[3]===n?f=t[4]:(f=(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=f);let m;t[5]!==i||t[6]!==a?(m=i&&a?(0,X.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]!==f||t[9]!==m?(h=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f,m]}),t[8]=f,t[9]=m,t[10]=h):h=t[10];let g;t[11]===r?g=t[12]:(g=(0,X.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,X.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,X.jsx)(re,{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]!==d||t[18]!==_?(y=(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[d,_,v]}),t[17]=d,t[18]=_,t[19]=y):y=t[19];let b;t[20]===c?b=t[21]:(b=(0,X.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,X.jsxs)(`button`,{type:`button`,onClick:s,"aria-label":l,className:u,children:[y,b]}),t[22]=s,t[23]=l,t[24]=y,t[25]=b,t[26]=x):x=t[26],x}function ke(e){let t=(0,Y.c)(25),{m:n,onStart:r}=e,i=z(Ae),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:ae,title:n.browserSetupExtTitle,description:n.browserSetupExtDesc,recommended:!0},{id:`cloakbrowser`,icon:K,title:n.browserBackendCloakBrowser,description:n.browserModeCloakTagline},{id:`local`,icon:F,title:n.browserSetupLocalTitle,description:n.browserSetupLocalDesc},{id:`cloud`,icon:c,title:n.browserSetupCloudTitle,description:n.browserSetupCloudDesc}].filter(e=>ve(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,X.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.browserSetupTitle}),t[10]=n.browserSetupTitle,t[11]=s);let l;t[12]===n.browserSetupSubtitle?l=t[13]:(l=(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.browserSetupSubtitle}),t[12]=n.browserSetupSubtitle,t[13]=l);let u;t[14]!==s||t[15]!==l?(u=(0,X.jsxs)(`div`,{children:[s,l]}),t[14]=s,t[15]=l,t[16]=u):u=t[16];let d;t[17]!==n.browserSetupRecommended||t[18]!==n.browserSetupSelect||t[19]!==o||t[20]!==r?(d=(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.map(e=>(0,X.jsx)(Oe,{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]=d):d=t[21];let f;return t[22]!==u||t[23]!==d?(f=(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-base p-4`,children:[u,d]}),t[22]=u,t[23]=d,t[24]=f):f=t[24],f}function Ae(e){return e.mode}function je(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 Me(e,t){if(e)return{ready:t.browserStatusReady,not_installed:t.browserStatusNotInstalled,checking:t.browserStatusChecking,unknown:t.browserStatusUnknown,error:t.browserStatusError}[e]}function Ne(e){if(e.kind!==`idle`)return e.kind===`loading`?`checking`:e.kind===`error`?`error`:e.data.connected?`ready`:(e.data.running,`not_installed`)}function Pe(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 Fe=[`overview`,`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Ie=[`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Le={connection:`overview`,extension:`extension`,local:`local`,cloak:`cloakbrowser`,cdp:`cdp`,cloud:`cloud`,runtime:`overview`,security:`overview`};function Re(e){let t=(e??``).trim();return t===`behavior`?`overview`:Fe.includes(t)?t:`overview`}function ze(e){return Ie.includes(e)}function Be(e){let t=(0,Y.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,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[p?(0,X.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,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:f}),i?(0,X.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,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[a?(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsx)(Ve,{kind:a,detail:o,m:u})}):(0,X.jsx)(`span`,{}),s?(0,X.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,X.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,X.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,X.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,X.jsx)(n,{className:`size-4`,strokeWidth:1.75})}),t[18]=n,t[19]=_);let v;t[20]===r?v=t[21]:(v=(0,X.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,X.jsx)(Ve,{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,X.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,X.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,X.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,X.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,X.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,X.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,X.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 Ve(e){let t=(0,Y.c)(27),{kind:n,detail:r,m:i}=e,a,o,c,l;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:u}={ready:{icon:s,color:`text-green-600 dark:text-green-400`,label:i.browserStatusReady},not_installed:{icon:D,color:`text-amber-600 dark:text-amber-400`,label:i.browserStatusNotInstalled},checking:{icon:f,color:`text-fg-muted`,label:i.browserStatusChecking},unknown:{icon:N,color:`text-fg-muted`,label:i.browserStatusUnknown},error:{icon:M,color:`text-red-600 dark:text-red-400`,label:i.browserStatusError}}[n];a=e,o=u,l=`inline-flex min-w-0 flex-col items-start gap-1`,c=p(`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]=c,t[9]=l}else a=t[6],o=t[7],c=t[8],l=t[9];let u=n===`checking`&&`animate-spin`,d;t[10]===u?d=t[11]:(d=p(`size-3.5 shrink-0`,u),t[10]=u,t[11]=d);let m;t[12]!==a||t[13]!==d?(m=(0,X.jsx)(a,{className:d}),t[12]=a,t[13]=d,t[14]=m):m=t[14];let h;t[15]===o?h=t[16]:(h=(0,X.jsx)(`span`,{children:o}),t[15]=o,t[16]=h);let g;t[17]!==c||t[18]!==m||t[19]!==h?(g=(0,X.jsxs)(`span`,{className:c,children:[m,h]}),t[17]=c,t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;t[21]===r?_=t[22]:(_=r?(0,X.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg-subtle`,children:r}):null,t[21]=r,t[22]=_);let v;return t[23]!==l||t[24]!==g||t[25]!==_?(v=(0,X.jsxs)(`span`,{className:l,children:[g,_]}),t[23]=l,t[24]=g,t[25]=_,t[26]=v):v=t[26],v}function He(e){let t=(0,Y.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=p(`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,X.jsx)(`div`,{className:a,children:r}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}var Ue={instances:[],launchStatus:`idle`,launchMessage:null,testStatus:`idle`,testMessage:null,executablePath:``};function We({m:e,cdpUrl:t,onCdpUrlChange:n,launch:r,stop:i,listInstances:a,ping:o,embedded:s=!1}){let[c,l]=(0,J.useReducer)(G,Ue),{instances:u,launchStatus:d,launchMessage:p,testStatus:m,testMessage:h,executablePath:g}=c,_=(0,J.useCallback)(async()=>{try{l({type:`patch`,patch:{instances:await a()}})}catch{}},[a]);(0,J.useEffect)(()=>{_();let e=setInterval(()=>void _(),8e3);return()=>clearInterval(e)},[_]);let v=(0,J.useCallback)(async()=>{if(d!==`pending`){l({type:`patch`,patch:{launchStatus:`pending`,launchMessage:null}});try{let t=await r(g.trim()||void 0);l({type:`patch`,patch:{launchStatus:`ok`,launchMessage:e.browserCdpLaunchedAtPort.replace(`{{port}}`,String(t.port))}}),n(t.wsEndpoint),await _()}catch(e){l({type:`patch`,patch:{launchStatus:`error`,launchMessage:e instanceof Error?e.message:String(e)}})}}},[g,r,d,e.browserCdpLaunchedAtPort,n,_]),y=(0,J.useCallback)(async e=>{await i(e),await _()},[_,i]),b=(0,J.useCallback)(async()=>{if(t.trim()){l({type:`patch`,patch:{testStatus:`pending`,testMessage:null}});try{let n=await o(t.trim());n.reachable?l({type:`patch`,patch:{testStatus:`ok`,testMessage:e.browserCdpReachable.replace(`{{browser}}`,n.browser??`—`)}}):l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,n.error??`—`)}})}catch(t){l({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,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(Be,{icon:k,title:e.browserCdpLaunchLocal,description:e.browserCdpLaunchLocalDesc,m:e,embedded:s,sectionTitle:s?e.browserCdpLaunchLocal:void 0,primaryAction:(0,X.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:d===`pending`,onClick:()=>void v(),children:[d===`pending`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(k,{className:`size-3.5`}),d===`pending`?e.browserCdpLaunching:e.browserCdpLaunchLocal]}),children:[p?(0,X.jsx)(He,{kind:d===`error`?`error`:`success`,message:p}):null,(0,X.jsx)(Z,{label:e.browserCdpChromePath,description:e.browserCdpChromePathDesc,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:g,placeholder:`/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,onChange:e=>l({type:`patch`,patch:{executablePath:e.target.value}}),autoComplete:`off`})}),u.length>0?(0,X.jsx)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base p-3 shadow-surface`,children:u.map(t=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,X.jsxs)(`span`,{className:`font-mono text-fg`,children:[`port `,t.port,` · pid `,t.pid]}),(0,X.jsx)(`span`,{className:`truncate text-fg-subtle`,children:t.wsEndpoint})]}),(0,X.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,X.jsx)(B,{className:`size-3`}),e.browserCdpStopLocal]})]},t.port))}):null]}),(0,X.jsxs)(Be,{icon:W,title:e.label.browserCdpUrl,description:e.desc.browserCdpUrl,m:e,embedded:s,sectionTitle:s?e.label.browserCdpUrl:void 0,primaryAction:(0,X.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,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(I,{className:`size-3.5`}),m===`pending`?e.browserCdpTesting:e.browserCdpTestConnection]}),children:[(0,X.jsx)(`input`,{type:`text`,className:Q(),value:t,placeholder:`ws://127.0.0.1:9222`,onChange:e=>n(e.target.value),autoComplete:`off`}),(0,X.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCdpLoopbackOnly}),h?(0,X.jsx)(He,{kind:m===`error`?`error`:`success`,message:h}):null]})]})}function Ge(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 Ke(e){let t=(0,Y.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=Ge(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,X.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,X.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,X.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,X.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,X.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,X.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-raised`,children:d==null?(0,X.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-accent/70`}):(0,X.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,X.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(qe)}):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,X.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,X.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 qe(e){return(0,X.jsx)(`div`,{className:`truncate`,children:e},e)}var Je={confirmOpen:!1,installStatus:`idle`,installMessage:null,openStatus:`idle`,openMessage:null,runtime:null};function Ye({m:e,doctor:t,refetch:n,applyDoctor:r,installStream:i,fetchRuntimeStatus:c,launchCloak:u,form:d,onChange:p,embedded:m=!1}){let[h,g]=(0,J.useReducer)(G,Je),{confirmOpen:_,installStatus:v,installMessage:y,openStatus:b,openMessage:x,runtime:S}=h,{progress:C,running:w,cancelling:T,run:E,reset:D,cancel:O}=i,j=t.kind===`ok`?t.data:null,M=j?.installed===!0,N=v===`installing`||w,P=(0,J.useCallback)(async()=>{if(M)try{g({type:`patch`,patch:{runtime:await c()}})}catch{}},[c,M]);(0,J.useEffect)(()=>{if(!M){g({type:`patch`,patch:{runtime:null}});return}P();let e=setInterval(()=>void P(),8e3);return()=>clearInterval(e)},[M,P]);let F=(0,J.useCallback)(async()=>{g({type:`patch`,patch:{confirmOpen:!1,installStatus:`installing`,installMessage:null}}),D();let t=await E({body:{cacheDir:d.cacheDir.trim()||void 0,binaryPath:d.binaryPath.trim()||void 0},fallbackError:e.browserCloakInstallFailed});if(!t.ok){if(t.error===`busy`){g({type:`patch`,patch:{installStatus:`installing`}});return}if(t.error===`cancelled`){g({type:`patch`,patch:{installStatus:`idle`,installMessage:null}}),D();return}g({type:`patch`,patch:{installStatus:`failed`,installMessage:t.errorMessage??e.browserCloakInstallFailed}});return}t.payload&&r?.(t.payload),g({type:`patch`,patch:{installStatus:`installed`,installMessage:t.payload?.binaryPath?`${e.browserCloakInstalled}: ${t.payload.binaryPath}`:e.browserCloakInstalled}}),await n({cacheDir:d.cacheDir,binaryPath:d.binaryPath}),await P()},[r,d.binaryPath,d.cacheDir,e.browserCloakInstallFailed,e.browserCloakInstalled,n,P,D,E]),I=(0,J.useCallback)(async()=>{if(b!==`pending`){g({type:`patch`,patch:{openStatus:`pending`,openMessage:null}});try{let t=await u();g({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){g({type:`patch`,patch:{openStatus:`error`,openMessage:e instanceof Error?e.message:String(e)}})}}},[u,e.browserCloakOpenLaunched,e.browserCloakOpenReused,b]),L=t.kind===`loading`?`checking`:t.kind===`error`?`error`:M?`ready`:`not_installed`,R=M&&j?.version?`v${j.version} (${j.platform})`:void 0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Be,{icon:K,title:e.browserCloakGuideTitle,description:e.browserCloakGuideDesc,status:L,statusDetail:R,m:e,embedded:m,primaryAction:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[M?(0,X.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:b===`pending`,onClick:()=>void I(),children:[b===`pending`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(k,{className:`size-3.5`}),b===`pending`?e.browserCloakOpening:e.browserCloakOpen]}):null,(0,X.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:N,onClick:()=>g({type:`patch`,patch:{confirmOpen:!0}}),children:[N?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):M?(0,X.jsx)(ee,{className:`size-3.5`}):v===`installed`?(0,X.jsx)(s,{className:`size-3.5 text-green-500`}):(0,X.jsx)(l,{className:`size-3.5`}),N?e.browserCloakInstalling:M?e.browserReinstall:e.browserCloakDownload]})]}),children:[w?(0,X.jsx)(Ke,{m:e,progress:C,cancelling:T,onCancel:()=>void O()}):null,y?(0,X.jsx)(He,{kind:v===`failed`?`error`:`success`,message:y}):null,x?(0,X.jsx)(He,{kind:b===`error`?`error`:`success`,message:x}):null,M&&S?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base p-3 shadow-surface`,children:[(0,X.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:S.running?e.browserCloakRuntimeRunning.replace(`{{port}}`,String(S.port)):e.browserCloakRuntimeOff})}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`span`,{className:`text-fg-subtle`,children:e.browserCloakProfileLabel}),(0,X.jsx)(`span`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:S.userDataDir})]}),(0,X.jsx)(`p`,{className:`text-[11px] leading-relaxed text-fg-subtle`,children:e.browserCloakProfileAgentHint}),S.temporaryProfile?(0,X.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserCloakTemporaryProfileHint}):null]}):null,(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,X.jsx)(Z,{label:e.label.browserCloakKeepOpen,description:e.desc.browserCloakKeepOpen,children:(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:d.keepOpen,onChange:e=>p({keepOpen:e.target.checked})}),(0,X.jsx)(`span`,{children:e.browserCloakKeepOpenOn})]})}),(0,X.jsx)(Z,{label:e.label.browserCloakTemporaryProfile,description:e.desc.browserCloakTemporaryProfile,children:(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:d.temporaryProfile,onChange:e=>p({temporaryProfile:e.target.checked})}),(0,X.jsx)(`span`,{children:e.browserCloakTemporaryProfileOn})]})}),(0,X.jsx)(Z,{label:e.label.browserHumanize,description:e.desc.browserHumanize,children:(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:d.humanize,onChange:e=>p({humanize:e.target.checked})}),(0,X.jsx)(`span`,{children:e.browserHumanizeOn})]})}),(0,X.jsx)(Z,{label:e.label.browserHumanPreset,description:e.desc.browserHumanPreset,children:(0,X.jsxs)(a,{className:be(),value:d.humanPreset,onChange:e=>p({humanPreset:e.target.value}),children:[(0,X.jsx)(o,{value:`careful`,children:e.browserHumanPresetCareful}),(0,X.jsx)(o,{value:`default`,children:e.browserHumanPresetDefault})]})})]})]}),(0,X.jsxs)(q,{className:`mt-4`,children:[(0,X.jsx)(ue,{icon:K,title:e.browserCloakAdvancedShow}),(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,X.jsxs)(Z,{label:e.label.browserCloakCacheDir,description:e.desc.browserCloakCacheDir,children:[(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.cacheDir,placeholder:`~/.xopc/bin/cloakbrowser`,onChange:e=>p({cacheDir:e.target.value}),autoComplete:`off`}),(0,X.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCacheDirHomeOnly})]}),(0,X.jsxs)(Z,{label:e.label.browserCloakBinaryPath,description:e.desc.browserCloakBinaryPath,children:[(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.binaryPath,placeholder:`~/.xopc/bin/cloakbrowser/chromium-v.../Chromium.app/Contents/MacOS/Chromium`,onChange:e=>p({binaryPath:e.target.value}),autoComplete:`off`}),d.binaryPath.trim()?(0,X.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserBinaryPathWarning}):null]}),(0,X.jsx)(Z,{label:e.label.browserCloakTimezone,description:e.desc.browserCloakTimezone,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.timezone,placeholder:`America/New_York`,onChange:e=>p({timezone:e.target.value}),autoComplete:`off`})}),(0,X.jsx)(Z,{label:e.label.browserCloakLocale,description:e.desc.browserCloakLocale,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.locale,placeholder:`en-US`,onChange:e=>p({locale:e.target.value}),autoComplete:`off`})}),(0,X.jsx)(Z,{label:e.label.browserCloakWebrtcIp,description:e.desc.browserCloakWebrtcIp,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.webrtcIp,placeholder:`203.0.113.10`,onChange:e=>p({webrtcIp:e.target.value}),autoComplete:`off`})}),(0,X.jsx)(Z,{label:e.label.browserCloakFingerprintPlatform,description:e.desc.browserCloakFingerprintPlatform,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.fingerprintPlatform,placeholder:`macos`,onChange:e=>p({fingerprintPlatform:e.target.value}),autoComplete:`off`})}),(0,X.jsx)(`div`,{className:`sm:col-span-2`,children:(0,X.jsx)(Z,{label:e.label.browserCloakExtraArgs,description:e.desc.browserCloakExtraArgs,children:(0,X.jsx)(`textarea`,{className:Xe(),value:d.extraArgs,placeholder:`--disable-dev-shm-usage`,rows:3,onChange:e=>p({extraArgs:e.target.value})})})})]})]}),(0,X.jsx)(A,{open:_,title:e.browserConfirmDownloadTitle,description:Ze(e,j),confirmLabel:e.browserConfirmDownloadConfirm,cancelLabel:e.browserConfirmDownloadCancel,onConfirm:()=>void F(),onCancel:()=>g({type:`patch`,patch:{confirmOpen:!1}})})]})}function Xe(){return`${Q()} min-h-[4.5rem] resize-y font-mono text-xs`}function Ze(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 Qe({m:e,form:t,onChange:n,testCloud:r,embedded:i=!1}){let[s,l]=(0,J.useState)(`idle`),[u,d]=(0,J.useState)(null),p=t.provider===`local`?`browserbase`:t.provider,m=y(S(e=>e.language)).providersSettings,h=O({show:m.show,hide:m.hide,copy:m.copy,copied:m.copied}),g=(0,J.useCallback)(()=>he().then(e=>e.apiKey??null),[]),_=(0,J.useCallback)(async()=>{l(`pending`),d(null);try{let n=await r(p,t.apiKey);n.reachable?(l(`ok`),d(e.browserCloudTestOk)):(l(`error`),d(e.browserCloudTestFailed.replace(`{{error}}`,n.error??`—`)))}catch(t){l(`error`),d(e.browserCloudTestFailed.replace(`{{error}}`,t instanceof Error?t.message:String(t)))}},[t.apiKey,e.browserCloudTestFailed,e.browserCloudTestOk,p,r]);return(0,X.jsxs)(Be,{icon:c,title:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,m:e,embedded:i,primaryAction:(0,X.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 _(),children:[s===`pending`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(I,{className:`size-3.5`}),e.browserCloudTestConnection]}),children:[(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,X.jsx)(Z,{label:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,children:(0,X.jsxs)(a,{className:be(),value:p,onChange:e=>n({provider:e.target.value}),children:[(0,X.jsx)(o,{value:`browserbase`,children:e.browserCloudProviderBrowserbase}),(0,X.jsx)(o,{value:`browser-use`,children:e.browserCloudProviderBrowserUse})]})}),(0,X.jsx)(Z,{label:e.label.browserCloudApiKey,description:e.desc.browserCloudApiKey,children:(0,X.jsx)(L,{value:t.apiKey,onChange:e=>n({apiKey:e}),placeholder:p===`browserbase`?`BROWSERBASE_API_KEY`:`BROWSER_USE_API_KEY`,labels:h,reveal:g,loadFailedLabel:`Failed to load key`})}),p===`browserbase`?(0,X.jsx)(Z,{label:e.label.browserCloudProjectId,description:e.desc.browserCloudProjectId,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:t.projectId,placeholder:`BROWSERBASE_PROJECT_ID`,onChange:e=>n({projectId:e.target.value}),autoComplete:`off`})}):null,(0,X.jsx)(Z,{label:e.label.browserCloudRegion,description:e.desc.browserCloudRegion,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:t.region,placeholder:`us-west-2`,onChange:e=>n({region:e.target.value}),autoComplete:`off`})})]}),u?(0,X.jsx)(He,{kind:s===`error`?`error`:`success`,message:u}):null]})}function $e(e){let t=(0,Y.c)(48),{m:n,installed:r,extensionDir:i,connected:a,busy:o,onOpenChrome:c,onCopyPath:l,onRevealFolder:u,pathBusy:d,folderBusy:f}=e,m;t[0]!==r||t[1]!==n.browserExtensionInstallStep1?(m={id:`install`,label:n.browserExtensionInstallStep1,done:r},t[0]=r,t[1]=n.browserExtensionInstallStep1,t[2]=m):m=t[2];let h=!!i&&a,g;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]!==l||t[12]!==c||t[13]!==u||t[14]!==d?(g=i?(0,X.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-raised px-2.5 py-2 shadow-surface`,children:[(0,X.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.browserExtensionInstallStep2FolderLabel}),(0,X.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-fg`,children:i}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-3`,children:[(0,X.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:o,onClick:c,children:n.browserExtensionOpenChrome}),(0,X.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:d?n.browserExtensionInstalling:n.browserExtensionCopyPath}),(0,X.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:o,onClick:u,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]=l,t[12]=c,t[13]=u,t[14]=d,t[15]=g):g=t[15];let _;t[16]!==n.browserExtensionInstallStep2||t[17]!==h||t[18]!==g?(_={id:`load`,label:n.browserExtensionInstallStep2,done:h,detail:g},t[16]=n.browserExtensionInstallStep2,t[17]=h,t[18]=g,t[19]=_):_=t[19];let v;t[20]!==a||t[21]!==n.browserExtensionInstallStep3?(v={id:`connect`,label:n.browserExtensionInstallStep3,done:a},t[20]=a,t[21]=n.browserExtensionInstallStep3,t[22]=v):v=t[22];let y;t[23]!==m||t[24]!==_||t[25]!==v?(y=[m,_,v],t[23]=m,t[24]=_,t[25]=v,t[26]=y):y=t[26];let b=y,x;t[27]===b?x=t[28]:(x=b.filter(et),t[27]=b,t[28]=x);let S=x.length,C=n.browserExtensionInstallGuideTitle,w;t[29]===n.browserExtensionInstallGuideTitle?w=t[30]:(w=(0,X.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:n.browserExtensionInstallGuideTitle}),t[29]=n.browserExtensionInstallGuideTitle,t[30]=w);let T;t[31]!==S||t[32]!==n.browserExtensionChecklistProgress||t[33]!==b.length?(T=n.browserExtensionChecklistProgress.replace(`{{done}}`,String(S)).replace(`{{total}}`,String(b.length)),t[31]=S,t[32]=n.browserExtensionChecklistProgress,t[33]=b.length,t[34]=T):T=t[34];let E;t[35]===T?E=t[36]:(E=(0,X.jsx)(`span`,{className:`ml-auto text-xs font-normal text-fg-muted`,children:T}),t[35]=T,t[36]=E);let D;t[37]!==E||t[38]!==w?(D=(0,X.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[w,E]}),t[37]=E,t[38]=w,t[39]=D):D=t[39];let O;t[40]!==n.browserExtensionChecklistDone||t[41]!==n.browserExtensionChecklistPending||t[42]!==b?(O=(0,X.jsx)(`ol`,{className:`flex flex-col gap-3`,children:b.map((e,t)=>(0,X.jsxs)(`li`,{className:`flex gap-2.5`,children:[(0,X.jsx)(`span`,{className:`mt-0.5 shrink-0`,"aria-hidden":!0,children:e.done?(0,X.jsx)(s,{className:`size-4 text-emerald-500`,strokeWidth:2}):(0,X.jsx)(R,{className:`size-4 text-fg-subtle`,strokeWidth:1.75})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`p`,{className:p(`text-[11px] leading-relaxed`,e.done?`text-fg-muted line-through decoration-fg-subtle/60`:`text-fg`),children:[(0,X.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]=b,t[43]=O):O=t[43];let k;return t[44]!==n.browserExtensionInstallGuideTitle||t[45]!==D||t[46]!==O?(k=(0,X.jsxs)(`div`,{"aria-label":C,className:`rounded-xl bg-surface-base p-3`,children:[D,O]}),t[44]=n.browserExtensionInstallGuideTitle,t[45]=D,t[46]=O,t[47]=k):k=t[47],k}function et(e){return e.done}var tt=19820,nt=3e4;function rt({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,J.useState)(null),[_,y]=(0,J.useState)(null),[b,x]=(0,J.useState)(null),S=p.port??tt,C=p.host||`127.0.0.1`,w=`ws://${C}:${S}/browser-ext`,T=t.kind===`ok`&&t.data.running,E=t.kind===`ok`&&t.data.connected,D=t.kind===`ok`&&t.data.bridgeHeld===!0,O=t.kind===`ok`&&t.data.portConflict===!0,A=T||D,j=n.kind===`ok`?n.data:t.kind===`ok`?t.data.artifacts:void 0,M=j?.installed===!0,N=j?.extensionDir,F=j?.needsChromeReload===!0,L=t.kind===`ok`?E?{icon:ie,color:`text-green-500`,label:e.browserExtensionConnected}:T?{icon:I,color:`text-amber-500`,label:e.browserExtensionWaiting}:{icon:P,color:`text-fg-muted`,label:e.browserExtensionServerOff}:{icon:P,color:`text-fg-muted`,label:`…`},R=L.icon,z=(0,J.useCallback)(async()=>{if(!h){g(`start`),y(null);try{await i({host:C,port:S})}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,C,S,i]),V=(0,J.useCallback)(async()=>{if(!h){g(`stop`),y(null);try{await a()}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,a]),H=(0,J.useCallback)(async()=>{if(!h){g(`disconnect`),y(null);try{await o()}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,o]),ee=(0,J.useCallback)(async()=>{if(!h){g(`install`),y(null),x(null);try{let t=await s({force:M});t?.extensionDir?x(`${e.browserExtensionInstalled}: ${t.extensionDir}`):x(e.browserExtensionInstalled),await c()}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,s,M,e.browserExtensionInstalled,c]),U=(0,J.useCallback)(async()=>{if(!h){g(`open`),y(null);try{await u()}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,u]),W=(0,J.useCallback)(async()=>{if(!(!N||h)){g(`path`),y(null),x(null);try{await v(N)?x(e.browserExtensionPathCopied):x(e.browserExtensionPathCopyFailed)}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,N,e.browserExtensionPathCopied,e.browserExtensionPathCopyFailed]),G=(0,J.useCallback)(async()=>{if(!(!N||h)){g(`folder`),y(null),x(null);try{await d(),x(e.browserExtensionFolderOpened)}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,N,e.browserExtensionFolderOpened,d]),K=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.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===`install`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(l,{className:`size-3.5`}),h===`install`?e.browserExtensionInstalling:e.browserExtensionInstall]}),A?(0,X.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 V(),children:[h===`stop`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(B,{className:`size-3.5`}),e.browserExtensionStopBridge]}):(0,X.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 z(),children:[h===`start`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(k,{className:`size-3.5`}),h===`start`?e.browserExtensionStarting:e.browserExtensionStartBridge]}),E?(0,X.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 H(),children:[h===`disconnect`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(P,{className:`size-3.5`}),e.browserExtensionDisconnect]}):null]});return(0,X.jsx)(Be,{icon:ae,title:e.browserBackendExtension,description:e.browserExtensionDownloadHint,m:e,embedded:m,primaryAction:K,advancedTitle:e.browserAdvancedShow,advanced:(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,X.jsx)(Z,{label:e.label.browserExtensionPort,description:e.desc.browserExtensionPort,children:(0,X.jsx)(ye,{type:`number`,className:Q(),min:1024,max:65535,value:p.port??``,suggestion:String(tt),onAcceptSuggestion:e=>r({port:Number.parseInt(e,10)}),placeholder:String(tt),onChange:e=>{let t=e.target.value;r({port:t===``?void 0:Number.parseInt(t,10)})}})}),(0,X.jsx)(Z,{label:e.label.browserExtensionHost,description:e.desc.browserExtensionHost,children:(0,X.jsx)(ye,{type:`text`,className:Q(),value:p.host,suggestion:`127.0.0.1`,onAcceptSuggestion:e=>r({host:e}),placeholder:`127.0.0.1`,onChange:e=>r({host:e.target.value}),autoComplete:`off`})}),(0,X.jsx)(Z,{label:e.label.browserExtensionConnectionTimeout,description:e.desc.browserExtensionConnectionTimeout,children:(0,X.jsx)(ye,{type:`number`,className:Q(),min:1,step:1,value:p.connectionTimeoutMs==null?``:Math.round(p.connectionTimeoutMs/1e3),placeholder:String(nt/1e3),suggestion:String(nt/1e3),onAcceptSuggestion:e=>r({connectionTimeoutMs:Number.parseInt(e,10)*1e3}),onChange:e=>{let t=e.target.value;r({connectionTimeoutMs:t===``?void 0:Math.max(1,Number.parseInt(t,10))*1e3})}})})]}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,X.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:w}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs ${L.color}`,children:[(0,X.jsx)(R,{className:`size-3.5`}),(0,X.jsx)(`span`,{children:L.label})]})]}),(0,X.jsx)($e,{m:e,installed:M,extensionDir:N,connected:E,busy:h!==null,pathBusy:h===`path`,folderBusy:h===`folder`,onOpenChrome:()=>void U(),onCopyPath:()=>void W(),onRevealFolder:()=>void G()}),F?(0,X.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,X.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(S))}):null,b?(0,X.jsx)(He,{kind:`success`,message:b}):null,_?(0,X.jsx)(He,{kind:`error`,message:_}):null]})})}function it(e){let t=(0,Y.c)(41),{m:n,doctor:r,refetch:i,applyDoctor:a,installStream:o,embedded:c}=e,u=c===void 0?!1:c,[d,p]=(0,J.useState)(`idle`),[m,h]=(0,J.useState)(null),{progress:g,running:_,cancelling:v,run:y,reset:b,cancel:x}=o,S;t[0]!==a||t[1]!==n.browserPlaywrightInstallFailed||t[2]!==n.browserPlaywrightInstalled||t[3]!==i||t[4]!==b||t[5]!==y?(S=async()=>{p(`installing`),h(null),b();let e=await y({fallbackError:n.browserPlaywrightInstallFailed});if(!e.ok){if(e.error===`busy`){p(`installing`);return}if(e.error===`cancelled`){p(`idle`),h(null),b();return}p(`failed`),h(e.errorMessage??n.browserPlaywrightInstallFailed);return}e.payload&&a?.(e.payload),p(`installed`),h(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]=b,t[5]=y,t[6]=S):S=t[6];let C=S,w=r.kind===`loading`?`checking`:r.kind===`error`?`error`:r.kind===`ok`?r.data.installed?`ready`:`not_installed`:`unknown`,T=r.kind===`ok`&&r.data.installed&&r.data.executablePath?r.data.executablePath:void 0,E=r.kind===`ok`&&r.data.installed,D=d===`installing`||_,O;t[7]===C?O=t[8]:(O=()=>void C(),t[7]=C,t[8]=O);let k;t[9]!==E||t[10]!==D||t[11]!==d?(k=D?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):E?(0,X.jsx)(ee,{className:`size-3.5`}):d===`installed`?(0,X.jsx)(s,{className:`size-3.5 text-green-500`}):(0,X.jsx)(l,{className:`size-3.5`}),t[9]=E,t[10]=D,t[11]=d,t[12]=k):k=t[12];let A=D?n.browserPlaywrightInstalling:E?n.browserReinstall:n.browserPlaywrightInstall,j;t[13]!==D||t[14]!==O||t[15]!==k||t[16]!==A?(j=(0,X.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:D,onClick:O,children:[k,A]}),t[13]=D,t[14]=O,t[15]=k,t[16]=A,t[17]=j):j=t[17];let M;t[18]===n.browserPlaywrightManualInstall?M=t[19]:(M=(0,X.jsx)(`p`,{className:`text-fg-muted`,children:n.browserPlaywrightManualInstall}),t[18]=n.browserPlaywrightManualInstall,t[19]=M);let N;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,X.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]=N):N=t[20];let P;t[21]===M?P=t[22]:(P=(0,X.jsxs)(`div`,{className:`text-xs`,children:[M,N]}),t[21]=M,t[22]=P);let I;t[23]!==x||t[24]!==v||t[25]!==n||t[26]!==g||t[27]!==_?(I=_?(0,X.jsx)(Ke,{m:n,progress:g,showLogs:!0,cancelling:v,onCancel:()=>void x()}):null,t[23]=x,t[24]=v,t[25]=n,t[26]=g,t[27]=_,t[28]=I):I=t[28];let L;t[29]!==m||t[30]!==d?(L=m?(0,X.jsx)(He,{kind:d===`failed`?`error`:`success`,message:m}):null,t[29]=m,t[30]=d,t[31]=L):L=t[31];let R;return t[32]!==u||t[33]!==n||t[34]!==T||t[35]!==w||t[36]!==I||t[37]!==L||t[38]!==j||t[39]!==P?(R=(0,X.jsxs)(Be,{icon:F,title:n.browserPlaywrightGuideTitle,description:n.browserPlaywrightGuideDesc,status:w,statusDetail:T,m:n,embedded:u,primaryAction:j,children:[P,I,L]}),t[32]=u,t[33]=n,t[34]=T,t[35]=w,t[36]=I,t[37]=L,t[38]=j,t[39]=P,t[40]=R):R=t[40],R}async function at(e){let t=await x(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 x(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 ot={playwright:{kind:`idle`},cloak:{kind:`idle`},extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};function st(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 ct(e){let[t,n]=(0,J.useReducer)(st,ot),{playwright:r,cloak:i,extension:a,extensionArtifacts:o}=t,s=(0,J.useCallback)(async()=>{n({type:`playwright`,state:{kind:`loading`}});try{n({type:`playwright`,state:{kind:`ok`,data:await at(C(`/api/browser/playwright/doctor`))}})}catch(e){n({type:`playwright`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[]),c=(0,J.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 at(C(`/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,J.useCallback)(e=>{n({type:`playwright`,state:{kind:`ok`,data:e}})},[]),u=(0,J.useCallback)(e=>{n({type:`cloak`,state:{kind:`ok`,data:e}})},[]),d=(0,J.useCallback)(async()=>at(C(`/api/browser/cloakbrowser/status`)),[]),f=(0,J.useCallback)(async()=>$(C(`/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:g,extensionPort:_}=e,v=(0,J.useCallback)(async()=>{let e=new URLSearchParams({probe:`1`});g&&e.set(`host`,g),_!==void 0&&e.set(`port`,String(_)),n({type:`extension-start-probe`});try{let t=await x(C(`/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)}})}},[g,_]),y=(0,J.useCallback)(async()=>{n({type:`extension-artifacts-start-probe`});try{let e=await at(C(`/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}},[]),b=(0,J.useCallback)(async e=>{let t=(await $(C(`/api/browser/extension/install`),{force:e?.force??!1})).doctor;return n({type:`extension-artifacts`,state:{kind:`ok`,data:t}}),await v(),t},[v]),S=(0,J.useCallback)(async()=>{await $(C(`/api/browser/extension/open`),{action:`chrome`})},[]),w=(0,J.useCallback)(async()=>{await $(C(`/api/browser/extension/open`),{action:`folder`})},[]);(0,J.useEffect)(()=>{if(!m){n({type:`playwright-idle`});return}s()},[m,s]),(0,J.useEffect)(()=>{if(!h){n({type:`cloak-idle`});return}c()},[h,c]);let T=(0,J.useRef)(p);T.current!==p&&(T.current=p,p||n({type:`extension-idle`})),(0,J.useEffect)(()=>{if(!p)return;v(),y();let e=setInterval(()=>void v(),5e3);return()=>clearInterval(e)},[p,v,y]);let E=(0,J.useCallback)(async e=>{await $(C(`/api/browser/extension/start`),{host:e?.host??g,port:e?.port??_}),await v()},[g,_,v]),D=(0,J.useCallback)(async()=>{await $(C(`/api/browser/extension/stop`),{}),await v()},[v]),O=(0,J.useCallback)(async()=>{await $(C(`/api/browser/extension/disconnect`),{}),await v()},[v]),k=(0,J.useRef)(null);return(0,J.useEffect)(()=>{if(!p||e.activeBackend!==`extension`){k.current=null;return}if(a.kind!==`ok`||a.data.running||a.data.bridgeHeld)return;let t=`${g}:${_??19820}`;k.current!==t&&(k.current=t,E({host:g,port:_}).catch(()=>{k.current=null}))},[p,a,g,_,e.activeBackend,E]),{playwright:r,cloak:i,extension:a,extensionArtifacts:o,refetchPlaywright:s,applyPlaywrightDoctor:l,refetchCloak:c,applyCloakDoctor:u,fetchCloakRuntimeStatus:d,launchCloak:f,refetchExtension:v,refetchExtensionArtifacts:y,installExtensionArtifacts:b,openExtensionChrome:S,revealExtensionFolder:w,pingCdp:(0,J.useCallback)(async e=>$(C(`/api/browser/cdp/ping`),{cdpUrl:e}),[]),testCloud:(0,J.useCallback)(async(e,t)=>$(C(`/api/browser/cloud/test-connection`),{provider:e,apiKey:t}),[]),launchCdp:(0,J.useCallback)(async e=>$(C(`/api/browser/cdp/launch`),{executablePath:e}),[]),stopCdp:(0,J.useCallback)(async e=>{await $(C(`/api/browser/cdp/stop`),{port:e})},[]),listCdpInstances:(0,J.useCallback)(async()=>(await at(C(`/api/browser/cdp/instances`))).instances,[]),startExtensionBridge:E,stopExtensionBridge:D,disconnectExtension:O}}var lt=`
|
|
3
|
-
|
|
4
|
-
`,ut=/\r\n/g,dt={playwright:`/api/browser/playwright/install/stream`,cloakbrowser:`/api/browser/cloakbrowser/install/stream`},ft={playwright:`/api/browser/playwright/install/cancel`,cloakbrowser:`/api/browser/cloakbrowser/install/cancel`},pt=8;function mt(){return{phase:null,message:null,percent:null,lines:[]}}function ht(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>pt?r.slice(-8):r}return n}async function gt(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(ut,`
|
|
6
|
-
`);let l=a.split(lt);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 _t(e){let[t,n]=(0,J.useState)(mt),[r,i]=(0,J.useState)(!1),[a,o]=(0,J.useState)(!1),s=(0,J.useRef)(!1),c=(0,J.useRef)(null),l=(0,J.useCallback)(()=>{s.current||n(mt())},[]),u=(0,J.useCallback)(async()=>{if(s.current){o(!0);try{await x(C(ft[e]),{method:`POST`}).catch(()=>{}),c.current?.abort()}finally{o(!1)}}},[e]);return{progress:t,running:r,cancelling:a,run:(0,J.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(mt());try{let i=await x(C(dt[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 gt(i.body,e=>{n(t=>ht(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 vt(e){let t=(0,Y.c)(150),{a:n,form:r,update:i,activeTab:a,setActiveTab:o}=e,s=S(bt),l=z(yt),u=_t(`playwright`),f=_t(`cloakbrowser`),m=r.browserEnabled&&(a===`overview`||a===`extension`),h=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]!==m||t[8]!==h?(_={cacheDir:r.browserCloakCacheDir,binaryPath:r.browserCloakBinaryPath,browserEnabled:r.browserEnabled,activeBackend:r.browserBackend,probeExtension:m,probeLocal:h,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]=m,t[8]=h,t[9]=_):_=t[9];let v=ct(_),y;t[10]===v.playwright?y=t[11]:(y=je(v.playwright),t[10]=v.playwright,t[11]=y);let b=y,x;t[12]===v.cloak?x=t[13]:(x=je(v.cloak),t[12]=v.cloak,t[13]=x);let C=x,w;t[14]===v.extension?w=t[15]:(w=Ne(v.extension),t[14]=v.extension,t[15]=w);let T=w,E;t[16]!==n||t[17]!==v.extension?(E=Pe(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]!==C||t[21]!==T||t[22]!==D||t[23]!==b||t[24]!==l?(O=[{value:`extension`,icon:ae,name:n.browserBackendExtension,tagline:n.browserModeExtTagline,status:T,statusLabel:D},{value:`local`,icon:F,name:n.browserBackendLocal,tagline:n.browserModeLocalTagline,status:b,statusLabel:Me(b,n)},{value:`cloakbrowser`,icon:K,name:n.browserBackendCloakBrowser,tagline:n.browserModeCloakTagline,status:C,statusLabel:Me(C,n)},{value:`cdp`,icon:W,name:n.browserBackendCdp,tagline:n.browserModeCdpTagline},{value:`cloud`,icon:c,name:n.browserBackendCloud,tagline:n.browserModeCloudTagline}].filter(e=>ve(e.value,l)),t[19]=n,t[20]=C,t[21]=T,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=p(`flex flex-col gap-5 transition-opacity`,M),t[29]=M,t[30]=N);let P=!r.browserEnabled,I;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?(I=a===`extension`?(0,X.jsx)(q,{children:(0,X.jsx)(rt,{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]=I):I=t[46];let L;t[47]!==n||t[48]!==a||t[49]!==v.applyPlaywrightDoctor||t[50]!==v.playwright||t[51]!==v.refetchPlaywright||t[52]!==u?(L=a===`local`?(0,X.jsx)(q,{children:(0,X.jsx)(it,{embedded:!0,m:n,doctor:v.playwright,refetch:v.refetchPlaywright,applyDoctor:v.applyPlaywrightDoctor,installStream:u})}):null,t[47]=n,t[48]=a,t[49]=v.applyPlaywrightDoctor,t[50]=v.playwright,t[51]=v.refetchPlaywright,t[52]=u,t[53]=L):L=t[53];let R;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?(R=a===`cloakbrowser`?(0,X.jsx)(q,{children:(0,X.jsx)(Ye,{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]=R):R=t[74];let B;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?(B=a===`cdp`?(0,X.jsx)(q,{children:(0,X.jsx)(We,{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]=B):B=t[83];let V;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?(V=a===`cloud`?(0,X.jsx)(q,{children:(0,X.jsx)(Qe,{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]=V):V=t[92];let H;t[93]!==I||t[94]!==L||t[95]!==R||t[96]!==B||t[97]!==V||t[98]!==N||t[99]!==P?(H=(0,X.jsxs)(`div`,{className:N,"aria-hidden":P,children:[I,L,R,B,V]}),t[93]=I,t[94]=L,t[95]=R,t[96]=B,t[97]=V,t[98]=N,t[99]=P,t[100]=H):H=t[100];let ee=H;if(a===`overview`){let e;t[101]!==n||t[102]!==r.browserEnabled||t[103]!==j?(e=r.browserEnabled?null:(0,X.jsx)(ke,{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,X.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,X.jsx)(d,{className:`size-4`,strokeWidth:1.75})}),t[105]=a):a=t[105];let c;t[106]===i?c=t[107]:(c=e=>i({browserEnabled:e.target.checked}),t[106]=i,t[107]=c);let l;t[108]!==r.browserEnabled||t[109]!==c?(l=(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserEnabled,onChange:c}),t[108]=r.browserEnabled,t[109]=c,t[110]=l):l=t[110];let u;t[111]===n.browserEnabledOn?u=t[112]:(u=(0,X.jsx)(`span`,{children:n.browserEnabledOn}),t[111]=n.browserEnabledOn,t[112]=u);let f;t[113]!==l||t[114]!==u?(f=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[l,u]}),t[113]=l,t[114]=u,t[115]=f):f=t[115];let m;t[116]!==n.desc.browserEnabled||t[117]!==n.label.browserEnabled||t[118]!==f?(m=(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[a,(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsx)(Z,{label:n.label.browserEnabled,description:n.desc.browserEnabled,children:f})})]}),t[116]=n.desc.browserEnabled,t[117]=n.label.browserEnabled,t[118]=f,t[119]=m):m=t[119];let h;t[120]!==n.browserDocsLink||t[121]!==s?(h=(0,X.jsx)(De,{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,X.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,X.jsx)(`div`,{id:we(`connection`),className:p(`scroll-mt-24 transition-opacity`,!r.browserEnabled&&`pointer-events-none opacity-40`),children:(0,X.jsx)(Se,{m:n,value:r.browserBackend,onChange:e=>i({browserBackend:e}),onOpenConfig:o,options:k})}):(0,X.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,X.jsx)(q,{children:(0,X.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=p(`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,X.jsx)(Ee,{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,X.jsx)(me,{children:(0,X.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,X.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 ze(a)?ee:null}function yt(e){return e.mode}function bt(e){return e.language}function xt(e){let t=(0,Y.c)(40),{sectionId:n,intro:r,vm:i,children:a,tabbed:o}=e,s=o===void 0?!1:o,c=S(St),l;t[0]===c?l=t[1]:(l=y(c),t[0]=c,t[1]=l);let u=l,d=u.agentSettings,f=u.settingsSections[n]??n;if(!i.hasToken){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(j,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),t[2]=e):e=t[2];let n;t[3]===f?n=t[4]:(n=(0,X.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:f}),t[3]=f,t[4]=n);let r;t[5]===d.needToken?r=t[6]:(r=(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:d.needToken}),t[5]=d.needToken,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,X.jsx)(se,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:(0,X.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[e,(0,X.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,X.jsx)(se,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,X.jsx)(le,{sections:1})}),t[10]=e):e=t[10],e}if(!i.form){let e=i.error??i.fetchError??d.loadError,n;t[11]===e?n=t[12]:(n=(0,X.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,X.jsx)(m,{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,X.jsxs)(se,{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 p=s?void 0:r,h;t[21]===d.sectionDesc?h=t[22]:(h=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:d.sectionDesc}),t[21]=d.sectionDesc,t[22]=h);let g;t[23]!==i.autosaveStatus||t[24]!==i.error?(g=(0,X.jsx)(de,{status:i.autosaveStatus,error:i.error}),t[23]=i.autosaveStatus,t[24]=i.error,t[25]=g):g=t[25];let _;t[26]!==f||t[27]!==p||t[28]!==h||t[29]!==g?(_=(0,X.jsx)(oe,{title:f,subtitle:p,meta:h,actions:g}),t[26]=f,t[27]=p,t[28]=h,t[29]=g,t[30]=_):_=t[30];let v;t[31]===i.error?v=t[32]:(v=i.error?(0,X.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]=v);let b;t[33]===a?b=t[34]:(b=(0,X.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:a}),t[33]=a,t[34]=b);let x;return t[35]!==_||t[36]!==v||t[37]!==b||t[38]!==i.onBlurCapture?(x=(0,X.jsxs)(se,{gap:`gap-6`,onBlurCapture:i.onBlurCapture,children:[_,v,b]}),t[35]=_,t[36]=v,t[37]=b,t[38]=i.onBlurCapture,t[39]=x):x=t[39],x}function St(e){return e.language}var Ct={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};function wt(e){return e===!0||e===`true`||e===1}function Tt(e){let t=(e&&typeof e==`object`&&!Array.isArray(e)?e:{}).browser;if(!t||typeof t!=`object`||Array.isArray(t))return{...Ct};let n=t,r=n.cloud&&typeof n.cloud==`object`&&!Array.isArray(n.cloud)?n.cloud:{},i=n.extension&&typeof n.extension==`object`&&!Array.isArray(n.extension)?n.extension:{},a=n.cloakbrowser&&typeof n.cloakbrowser==`object`&&!Array.isArray(n.cloakbrowser)?n.cloakbrowser:{},o=n.backend,s=n.cloudProvider,c=n.dialogPolicy;return{browserEnabled:wt(n.enabled),browserHeadless:wt(n.headless),browserAllowPrivateUrls:wt(n.allowPrivateUrls),browserCommandTimeout:typeof n.commandTimeout==`number`&&n.commandTimeout>=5?Math.floor(n.commandTimeout):void 0,browserBackend:o===`local`||o===`cdp`||o===`cloud`||o===`extension`||o===`cloakbrowser`?o:`extension`,browserCloudProvider:s===`browserbase`||s===`browser-use`?s:`local`,browserCloudApiKey:typeof r.apiKey==`string`?r.apiKey:``,browserCloudProjectId:typeof r.projectId==`string`?r.projectId:``,browserCloudRegion:typeof r.region==`string`?r.region:``,browserCdpUrl:typeof n.cdpUrl==`string`?n.cdpUrl:``,browserExtensionPort:typeof i.port==`number`&&i.port>=1024&&i.port<=65535?Math.floor(i.port):void 0,browserExtensionHost:typeof i.host==`string`&&i.host?i.host:`127.0.0.1`,browserExtensionConnectionTimeout:typeof i.connectionTimeout==`number`&&i.connectionTimeout>=1e3?Math.floor(i.connectionTimeout):void 0,browserCloakKeepOpen:a.keepOpen!==!1,browserCloakTemporaryProfile:a.temporaryProfile===!0,browserCloakCacheDir:typeof a.cacheDir==`string`?a.cacheDir:``,browserCloakBinaryPath:typeof a.binaryPath==`string`?a.binaryPath:``,browserCloakTimezone:typeof a.timezone==`string`?a.timezone:``,browserCloakLocale:typeof a.locale==`string`?a.locale:``,browserCloakWebrtcIp:typeof a.webrtcIp==`string`?a.webrtcIp:``,browserCloakFingerprintPlatform:typeof a.fingerprintPlatform==`string`?a.fingerprintPlatform:``,browserCloakExtraArgs:Array.isArray(a.extraArgs)?a.extraArgs.filter(e=>typeof e==`string`&&e.trim().length>0).join(`
|
|
7
|
-
`):``,browserHumanize:n.humanize!==!1,browserHumanPreset:n.humanPreset==="default"?`default`:`careful`,browserDialogPolicy:c===`must_respond`||c===`auto_accept`?c:`auto_dismiss`,browserDialogTimeout:typeof n.dialogTimeoutSeconds==`number`&&n.dialogTimeoutSeconds>=1?Math.floor(n.dialogTimeoutSeconds):void 0}}function Et(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 Dt(e){await b(C(`/api/config`),{method:`PATCH`,body:JSON.stringify({browser:Et(e)})}),T()}var Ot=U();function kt(e){let t=!!w(e=>e.token),[n,r]=(0,J.useReducer)(Ot,{form:null,baseline:null}),i=n.form,a=n.baseline,o=(0,J.useRef)(!1),s=(0,J.useRef)(i);s.current=i;let c=(0,J.useRef)(null),{data:l,error:u,isLoading:d,mutate:f}=E(t);H({enabled:t,parsed:(0,J.useMemo)(()=>l?.payload?.config===void 0?null:Tt(l.payload.config),[l]),dirty:o.current,trackedParsedRef:c,dispatch:r,onResetDirty:()=>{o.current=!1}});let p=!!(t&&d&&l===void 0&&!u),m=u instanceof Error?u.message:u?String(u):null,h=(0,J.useMemo)(()=>!i||!a?!1:JSON.stringify(i)!==JSON.stringify(a),[i,a]),g=(0,J.useCallback)(e=>{o.current=!0,r({type:`patch`,patch:e})},[]),_=fe({value:i,dirty:h,onSave:(0,J.useCallback)(async t=>{try{await Dt(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:m,form:i,update:g,autosaveStatus:_.status,error:_.error,onBlurCapture:_.onBlurCapture,mutate:f}}function At(e,t){return e.browserTabs[t]}function jt(){let e=(0,Y.c)(42),t=S(Nt),n;e[0]===t?n=e[1]:(n=y(t),e[0]=t,e[1]=n);let r=n,a=r.agentSettings,o=r.chat,s=z(Mt),c=kt(a),[l,u]=i(),d;e[2]===s?d=e[3]:(d=_e(Fe,s),e[2]=s,e[3]=d);let f=d,p;e[4]===l?p=e[5]:(p=Te(l.get(`focus`)),e[4]=l,e[5]=p);let m=p,h;e[6]!==m||e[7]!==l?(h=m?Le[m]??Re(l.get(`tab`)):Re(l.get(`tab`)),e[6]=m,e[7]=l,e[8]=h):h=e[8];let g=h,_;bb0:{if(!c.form){_=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],_=t}let v=_,b;e[14]===u?b=e[15]:(b=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]=b);let x=b;ge(g,x);let C,w;e[16]!==m||e[17]!==l||e[18]!==u?(C=()=>{if(!m)return;let e=Le[m]??Re(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=m===`runtime`||m===`security`?we(m):null;if(!t)return;let n=window.setTimeout(()=>{document.getElementById(t)?.scrollIntoView({behavior:`smooth`,block:`start`})},80);return()=>window.clearTimeout(n)},w=[m,l,u],e[16]=m,e[17]=l,e[18]=u,e[19]=C,e[20]=w):(C=e[19],w=e[20]),(0,J.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:At(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]!==g||e[27]!==a.browserTabsAria||e[28]!==x||e[29]!==E?(D=(0,X.jsx)(pe,{items:E,activeTab:g,onChange:x,ariaLabel:a.browserTabsAria,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`}),e[26]=g,e[27]=a.browserTabsAria,e[28]=x,e[29]=E,e[30]=D):D=e[30];let O;e[31]!==g||e[32]!==v||e[33]!==x?(O=v?(0,X.jsx)(vt,{...v,activeTab:g,setActiveTab:x}):null,e[31]=g,e[32]=v,e[33]=x,e[34]=O):O=e[34];let k;e[35]!==g||e[36]!==O?(k=(0,X.jsx)(ce,{id:g,activeTab:g,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`,showHeading:!1,framed:!1,children:O}),e[35]=g,e[36]=O,e[37]=k):k=e[37];let A;return e[38]!==k||e[39]!==D||e[40]!==c?(A=(0,X.jsxs)(xt,{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 Mt(e){return e.mode}function Nt(e){return e.language}export{jt as AgentBrowserSettingsPage};
|