@xopcai/xopc 0.0.294 → 0.0.295
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/dist/assets/{auth-C8gJZEsn.js → auth-B_9ZuGDx.js} +2 -1
- package/dist/browser-ext/dist/background.js +1 -1
- package/dist/browser-ext/dist/sidepanel.html +1 -1
- package/dist/browser-ext/dist/sidepanel.js +1 -1
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BDWrNpJe.js → agent-avatar-dicebear-CdaEBfdU.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-ESRFnt6Y.js → agent-defaults-settings-panel-CVunPl7p.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-aTs3RFJB.js → agents-DessO-kK.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-CCS9KbKd.js → app-management-settings-panel-BeucVbqM.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-CuRyhUns.js → appearance-settings-D9QdN7OM.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DAhcVKc4.js → apps-page-CbawVYBT.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-Xj6tLKD2.js → archive-plugin-fRMLP9dL.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CSMv3wDB.js → attachment-load-DVYW2whr.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-4Njbwe26.js → automations-page-iS1Wmdlc.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-CZboHws3.js → automations-workspace-ClZiIDCC.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-ohh8JiqX.js → binary-plugins-Bj3KFtIt.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-ps5gfiDX.js → block-editor-BLs4IKoH.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-DEeymLbJ.js → browser-automations-page-BntIB4a1.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-BkGCUKLR.js → browser-settings-page-BMd_-Dq1.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-Bik37Ina.js → capabilities-settings-panel-Cpb0KBZc.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-B6O7oGmA.js → channels-settings-DoRAjGiN.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-Bx56s8Ju.js → chat-terminal-dock-DH36RVtb.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-model-settings-DdkdFWic.js → computer-model-settings-CH8z1kz0.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-_jWKNIO2.js → computer-settings-page-D8oeOhou.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-h2IMptiJ.js → connectors-page-BpEEyOGa.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-B_w38QJJ.js → date-picker-BEZDMNzZ.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-DG-5rqI3.js → dependency-picker-DC8V8-Zp.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-daUwTaBB.js → desktop-pet-CJloB255.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-wVbuFzeN.js → desktop-pet-settings-B97XYYYn.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-e8NSnXSQ.js → device-pairing-wizard-Cci5K_bT.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DVQCsGO7.js → extension-debug-page-BTrK__r7.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BZd649fz.js → extension-page-DgvpFyGJ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CW_qtR_s.js → extension-settings-page-DjfuFesA.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-zazNZgv6.js → gateway-settings-BsbofCP6.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DuRKe_y9.js → heartbeat-settings-BXxtbvha.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-BzIm3rF9.js → home-page-DErKqiEK.js} +1 -1
- package/dist/gateway/static/root/assets/{index-DTDDJnrO.js → index-CEkw-fGy.js} +8 -8
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DEGJsaAS.js → keyboard-shortcuts-settings-B7E6CgtA.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-ylC0zfxp.js → local-app-workbench-page-CQsTUpog.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-BupSkP0s.js → local-apps-page-C10gURTO.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-CbbEPEH6.js → logs-page-Dg9Ma1sl.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-uzNsZK9S.js → management-settings-Bx1sNion.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-Brz0R-XW.js → media-plugins-BNoJCDvT.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-panel-Dja38ec0.js → note-detail-panel-Bsiuk-2U.js} +3 -3
- package/dist/gateway/static/root/assets/{notes-page-DZV1zODX.js → notes-page-BvAj-wx0.js} +1 -1
- package/dist/gateway/static/root/assets/{page-tabs-B5aqgPVw.js → page-tabs-B604dteb.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-C36n0h3j.js → preview-open-alternatives-Cp8vT7M-.js} +1 -1
- package/dist/gateway/static/root/assets/{proactive-page-Bf3fTLFK.js → proactive-page-afUn4Km7.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-h8R5De4L.js → project-detail-page-D6DLiVAL.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-C4yWYB8l.js → projects-page-Cq9hR-e_.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-C0_N6lUv.js → remote-access-hub-rAPyndf3.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DQrAOOoG.js → runtime-tools-settings-panel-B5EkdFYg.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-CAmYD83K.js → schema-form-BGMXczAd.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-BdzwFjok.js → sessions-page-DwLbo0cX.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-XmB-Qb44.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-nZ0L21U5.js → settings-form-section-Dzhqip3r.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-x7y6VkFZ.js → settings-page-DduNxMxn.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-C65mJ7Xd.js → setup-status-panel-ClmdhFhE.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-B3OpivMd.js → share-preview-page-CpreOM1V.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-vClF3hGb.js → shares-settings-CHkRyFET.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-sAwxVw0W.js → skill-reload-api-DWVyUbv4.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-BqQln5BZ.js → skills-page-ClFiDnDu.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-gVo88ldk.js → skills-page.utils-BR4q22o3.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-DJahgDjR.js → system-settings-panel-BaXq-D5z.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-BXhn4MVL.js → task-detail-page-CJnZCq6v.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-BvxsNjfv.js → tunnel-api-Dl9H37se.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-Bsv3gvqK.js → use-autosave-CTEqUAxS.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-CCVN7AYB.js → user-model-page-DOA5rAgd.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-BHtJeKg9.js → voice-api-key-field-CVCnJKQC.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-4WxTZ3b5.js → work-discovery-overlay-C8pcp5_j.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DdnSUVxc.js → workflow-run-setup-panel-CvayjHzR.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-Dw6PIPAz.js → workflows-page-D7pBtuZt.js} +1 -1
- package/dist/gateway/static/root/index.html +1 -1
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/device-pairing.js +9 -7
- package/dist/packages/gateway-contract/src/sessions.js +1 -0
- package/dist/src/agent/tool-manuals/computer.d.ts +1 -1
- package/dist/src/agent/tool-manuals/computer.js +1 -1
- package/dist/src/agent/tools/computer-use-tool.js +24 -14
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/computer/errors.d.ts +8 -0
- package/dist/src/computer/errors.js +10 -0
- package/dist/src/computer/model-adapter.d.ts +5 -0
- package/dist/src/computer/model-adapter.js +69 -22
- package/dist/src/computer/runtime.d.ts +14 -0
- package/dist/src/computer/runtime.js +4 -3
- package/dist/src/computer/task-state.d.ts +5 -1
- package/dist/src/computer/task-state.js +26 -11
- package/dist/src/gateway/heartbeat/service.js +2 -2
- package/dist/src/gateway/hono/routes/device-push.js +11 -1
- package/dist/src/gateway/hono/routes/notes.js +1 -1
- package/dist/src/gateway/hono/routes/voice.js +1 -1
- package/dist/src/gateway/hono/routes/workflows.js +1 -1
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/notes/types.d.ts +1 -1
- package/dist/src/notifications/device-store.js +1 -1
- package/dist/src/notifications/harmony-push.d.ts +26 -0
- package/dist/src/notifications/harmony-push.js +94 -0
- package/dist/src/notifications/service.d.ts +2 -0
- package/dist/src/notifications/service.js +15 -1
- package/dist/src/notifications/store.d.ts +2 -0
- package/dist/src/notifications/store.js +2 -1
- package/dist/src/notifications/types.d.ts +1 -1
- package/dist/src/storage/sqlite/device-access-repository.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/179_harmonyos_devices.sql +41 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +13 -5
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/package.json +5 -3
- package/dist/gateway/static/root/assets/settings-advanced-gate-BjgGCe3d.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{h as i,t as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as o}from"./check-DUBLcKHA.js";import{t as s}from"./external-link-DjqjBmc3.js";import{t as c}from"./markdown-view-BIg7cei7.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./plus-Q2yW6OE7.js";import{t as d}from"./x-B_N4OPjy.js";import{t as f}from"./cn-JdwAhgNB.js";import{a as p,c as m,i as h,n as g,r as _}from"./locale-store-eliqUnBr.js";import{t as v}from"./messages-NYDOR8-j.js";import{a as y,i as b,o as x,r as S,s as C,t as w}from"./dist-BGTk37IG.js";import{a as T,i as E}from"./vendor-swr-BIWyz7Rc.js";import{t as D}from"./button-CGlRPNzi.js";import{t as O}from"./skeleton-BwbyijEw.js";import{$a as k,$s as ee,Au as A,Ga as j,Hu as te,Ja as M,Qs as ne,Xa as N,Ya as P,bc as F,bu as I,ho as L,qa as R,qc as z,ta as B,vc as re,wc as V}from"./index-DTDDJnrO.js";import{t as H}from"./page-tabs-B5aqgPVw.js";var U=e(t(),1),W=n();function G(e){return e===`builtin`||e===`user`?e:`marketplace`}async function K(e){try{let t=await e.json();if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&typeof t.error.message==`string`)return t.error.message;if(typeof t.message==`string`)return t.message}catch{}return e.statusText||`HTTP ${e.status}`}async function ie(e){let t=await h(_(`/api/marketplace/packages/${encodeURIComponent(e.trim())}`),{cache:`no-store`});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload?.id)throw Error(n.error??`Invalid response`);return n.payload}async function q(e){let t=await h(_(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload?.extensionId)throw Error(n.error??`Invalid response`);return n.payload}async function J(e){let t=await h(_(`/api/extensions/bundled/activation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e.extensionId.trim(),enabled:e.enabled})});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error?.message??`Invalid response`);return n.payload}async function Y(e){let t=await h(_(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e})});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error??`Invalid response`);return n.payload}var X=r();function ae(e,t){let n=e.find(e=>e.id===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var Z={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function Q({className:e}){let t=v(g(e=>e.language)).extensionsPage,n=m(e=>!!e.conversationId),r=R(),{mutate:i}=T(),[a,o]=(0,U.useReducer)(B,Z),{q:s,debounced:c,detailPkg:u,rowBusy:d,actionError:h,restartHint:y}=a,b=n?`marketplace-${c}`:null;(0,U.useEffect)(()=>{let e=window.setTimeout(()=>o({type:`patch`,patch:{debounced:s.trim()}}),300);return()=>window.clearTimeout(e)},[s]);let{data:x,isLoading:S,error:C}=E(b,async()=>p(c.length>0?_(`/api/marketplace?q=${encodeURIComponent(c)}`):_(`/api/marketplace`)),{revalidateOnFocus:!1}),w=(0,U.useCallback)(()=>{i(`gateway-extensions-list`),k()},[i]),D=(0,U.useCallback)(async(e,n)=>{o({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await q({name:e,overwrite:n});w(),r.requiresGatewayRestart&&o({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw o({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceInstallFailed}}),e}finally{o({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceInstallFailed,t.marketplaceRestartHint,w]),A=(0,U.useCallback)(async e=>{o({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await Y(e);w(),n.requiresGatewayRestart&&o({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw o({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceUninstallFailed}}),e}finally{o({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceRestartHint,t.marketplaceUninstallFailed,w]),j=x?.extensions??[];return(0,X.jsxs)(`div`,{className:f(`flex flex-col gap-4`,e),children:[(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(V,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`input`,{type:`search`,value:s,onChange:e=>o({type:`patch`,patch:{q:e.target.value}}),placeholder:t.marketplaceSearchPlaceholder,className:`ui-input h-10 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted`})]}),C?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:C instanceof Error?C.message:t.marketplaceLoadFailed}):null,h?(0,X.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:h}):null,y?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:y}):null,S&&!x?(0,X.jsx)(`ul`,{className:`flex flex-col gap-3`,"aria-label":t.marketplaceLoading,children:[0,1,2].map(e=>(0,X.jsx)(`li`,{className:`rounded-xl bg-surface-panel p-4 shadow-surface`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2.5`,children:[(0,X.jsx)(O,{className:`h-5 w-40`}),(0,X.jsx)(O,{className:`h-4 w-full max-w-xl`}),(0,X.jsx)(O,{className:`h-4 w-2/3 max-w-md`})]}),(0,X.jsx)(O,{className:`h-8 w-20`})]})},e))}):(0,X.jsx)(`ul`,{className:`flex flex-col gap-3`,children:j.length===0?(0,X.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):j.map(e=>{let n=ae(r,e.id),i=d===e.id;return(0,X.jsx)(`li`,{className:`list-none`,children:(0,X.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-label":`${e.name}, ${t.marketplaceDetailTitle}`,onClick:()=>o({type:`patch`,patch:{detailPkg:e.id}}),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),o({type:`patch`,patch:{detailPkg:e.id}}))},className:f(`flex w-full cursor-pointer flex-wrap items-start gap-3 rounded-xl bg-surface-panel p-4 text-left shadow-surface`,`transition-[transform,background-color,box-shadow] duration-150 ease-out`,`hover:bg-surface-hover/40`,`active:scale-[0.992] active:bg-surface-hover/55`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:hover:bg-surface-hover/25 dark:active:bg-surface-hover/35`),children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,X.jsx)(I,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,X.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,X.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.description}):null,(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,X.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e))}),(0,X.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,X.jsx)(z,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]}),(0,X.jsx)(`div`,{role:`group`,className:`flex shrink-0 flex-col items-end gap-2 sm:min-w-[9rem]`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:n===`bundled`?(0,X.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.marketplaceBuiltin}):n===`user`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium text-fg-muted`,children:t.marketplaceInstalled}),(0,X.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&A(e.id).catch(()=>{})},className:f(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-colors active:scale-[0.98] active:bg-surface-hover/80`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[i?(0,X.jsx)(l,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(ee,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,X.jsx)(`button`,{type:`button`,onClick:()=>o({type:`patch`,patch:{detailPkg:e.id}}),className:f(`inline-flex w-full items-center justify-center rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-[transform,background-color] active:scale-[0.98]`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:t.marketplaceReview})})]})},e.id)})}),u?(0,X.jsx)($,{packageName:u,copy:t,extensions:r,onClose:()=>o({type:`patch`,patch:{detailPkg:null}}),onInstall:D,onUninstall:A}):null]})}function $(e){let t=(0,W.c)(102),{packageName:n,copy:r,extensions:i,onClose:o,onInstall:s,onUninstall:u}=e,[p,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(!1),v=m(ue)?`ext-mp-detail-${n}`:null,b;t[0]===n?b=t[1]:(b=async()=>ie(n),t[0]=n,t[1]=b);let T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T={revalidateOnFocus:!1},t[2]=T):T=t[2];let{data:D,error:k,isLoading:A}=E(v,b,T),j;t[3]!==i||t[4]!==n?(j=ae(i,n),t[3]=i,t[4]=n,t[5]=j):j=t[5];let M=j,N=M===`user`,P=D?.manifest?.permissions,F,I,L,R,z,B,V,H,G,K,q;if(t[6]!==r.detailBack||t[7]!==r.detailClose||t[8]!==r.marketplaceAuthor||t[9]!==r.marketplaceCodeRisk||t[10]!==r.marketplaceDependencies||t[11]!==r.marketplaceDetailLoadFailed||t[12]!==r.marketplaceDetailReadmeHeading||t[13]!==r.marketplaceDetailTitle||t[14]!==r.marketplaceDownloads||t[15]!==r.marketplaceIntegrity||t[16]!==r.marketplaceIntegrityVerified||t[17]!==r.marketplaceLifecycleScripts||t[18]!==r.marketplaceLoadFailed||t[19]!==r.marketplaceLoading||t[20]!==r.marketplaceNoReadme||t[21]!==r.marketplacePermissions||t[22]!==r.marketplacePermissionsNone||t[23]!==r.marketplaceRiskConfirm||t[24]!==r.marketplaceRiskTitle||t[25]!==r.marketplaceUnavailableBody||t[26]!==r.marketplaceUnavailableTitle||t[27]!==r.marketplaceVersion||t[28]!==D||t[29]!==k||t[30]!==M||t[31]!==A||t[32]!==o||t[33]!==P||t[34]!==g){let e=P&&typeof P==`object`&&!Array.isArray(P)?Object.entries(P):[],n;t[46]!==r.marketplaceNoReadme||t[47]!==D?(n=D?.readme?.trim()||(D?.description?.trim()?`### ${D.name}\n\n${D.description}`:`*${r.marketplaceNoReadme}*`),t[46]=r.marketplaceNoReadme,t[47]=D,t[48]=n):n=t[48];let i=n;L=w,R=!0,t[49]===o?z=t[50]:(z=e=>!e&&o(),t[49]=o,t[50]=z),I=x,t[51]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,X.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[51]=q):q=t[51],F=S,H=`fixed left-1/2 top-1/2 z-[131] flex h-[min(44rem,calc(100vh-1.5rem))] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,G=le;let a;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(te,{className:`size-5`}),t[52]=a):a=t[52];let s;t[53]!==r.detailBack||t[54]!==o?(s=(0,X.jsx)(`button`,{type:`button`,onClick:o,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailBack,children:a}),t[53]=r.detailBack,t[54]=o,t[55]=s):s=t[55];let l;t[56]===r.marketplaceDetailTitle?l=t[57]:(l=(0,X.jsx)(C,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[56]=r.marketplaceDetailTitle,t[57]=l);let u;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,X.jsx)(d,{className:`size-5`}),t[58]=u):u=t[58];let f;t[59]!==r.detailClose||t[60]!==o?(f=(0,X.jsx)(`button`,{type:`button`,onClick:o,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailClose,children:u}),t[59]=r.detailClose,t[60]=o,t[61]=f):f=t[61],t[62]!==s||t[63]!==l||t[64]!==f?(K=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[s,l,f]}),t[62]=s,t[63]=l,t[64]=f,t[65]=K):K=t[65],B=`min-h-0 flex-1 overflow-y-auto p-5`,V=A&&!D?(0,X.jsxs)(`div`,{className:`space-y-4`,"aria-label":r.marketplaceLoading,children:[(0,X.jsx)(O,{className:`h-6 w-48`}),(0,X.jsx)(O,{className:`h-4 w-28`}),(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsx)(O,{className:`h-12`}),(0,X.jsx)(O,{className:`h-12`})]}),(0,X.jsx)(O,{className:`h-28 w-full`}),(0,X.jsx)(O,{className:`h-36 w-full`})]}):k?(0,X.jsxs)(`div`,{className:`rounded-lg border border-red-300/70 bg-red-50 p-4 text-sm dark:border-red-900 dark:bg-red-950/30`,children:[(0,X.jsx)(`p`,{className:`font-medium text-red-700 dark:text-red-300`,children:r.marketplaceDetailLoadFailed}),(0,X.jsx)(`p`,{className:`mt-1 break-words text-red-600 dark:text-red-400`,children:k instanceof Error?k.message:r.marketplaceLoadFailed})]}):D?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:D.name}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,X.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:D.id})}),(0,X.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceAuthor}),(0,X.jsx)(`dd`,{children:D.author.username})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,X.jsx)(`dd`,{children:D.latestVersion.version})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,X.jsx)(`dd`,{children:D.downloads})]})]}),M===`bundled`?null:(0,X.jsxs)(`section`,{className:`mt-5 space-y-3 rounded-lg border border-edge bg-surface-base p-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[D.installability.available?(0,X.jsx)(re,{className:`mt-0.5 size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):(0,X.jsx)(ne,{className:`mt-0.5 size-5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:D.installability.available?r.marketplaceRiskTitle:r.marketplaceUnavailableTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:D.installability.available?r.marketplaceCodeRisk:D.installability.reason??r.marketplaceUnavailableBody})]})]}),D.installability.available?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`dl`,{className:`grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceIntegrity}),(0,X.jsx)(`dd`,{children:r.marketplaceIntegrityVerified})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDependencies}),(0,X.jsx)(`dd`,{children:D.packageSummary?.dependencyCount??0})]})]}),(0,X.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[(0,X.jsx)(`p`,{className:`font-medium text-fg`,children:r.marketplacePermissions}),e.length>0?(0,X.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(ce)}):(0,X.jsx)(`p`,{className:`mt-1`,children:r.marketplacePermissionsNone})]}),(D.packageSummary?.lifecycleScripts.length??0)>0?(0,X.jsxs)(`p`,{className:`text-xs leading-relaxed text-amber-700 dark:text-amber-300`,children:[r.marketplaceLifecycleScripts,`: `,D.packageSummary?.lifecycleScripts.join(`, `)]}):null,(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:g,onChange:e=>_(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-[var(--color-accent)]`}),(0,X.jsx)(`span`,{children:r.marketplaceRiskConfirm})]})]}):null]}),D.readme?.trim()?(0,X.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:r.marketplaceDetailReadmeHeading}):null,(0,X.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,X.jsx)(c,{content:i})})]}):null,t[6]=r.detailBack,t[7]=r.detailClose,t[8]=r.marketplaceAuthor,t[9]=r.marketplaceCodeRisk,t[10]=r.marketplaceDependencies,t[11]=r.marketplaceDetailLoadFailed,t[12]=r.marketplaceDetailReadmeHeading,t[13]=r.marketplaceDetailTitle,t[14]=r.marketplaceDownloads,t[15]=r.marketplaceIntegrity,t[16]=r.marketplaceIntegrityVerified,t[17]=r.marketplaceLifecycleScripts,t[18]=r.marketplaceLoadFailed,t[19]=r.marketplaceLoading,t[20]=r.marketplaceNoReadme,t[21]=r.marketplacePermissions,t[22]=r.marketplacePermissionsNone,t[23]=r.marketplaceRiskConfirm,t[24]=r.marketplaceRiskTitle,t[25]=r.marketplaceUnavailableBody,t[26]=r.marketplaceUnavailableTitle,t[27]=r.marketplaceVersion,t[28]=D,t[29]=k,t[30]=M,t[31]=A,t[32]=o,t[33]=P,t[34]=g,t[35]=F,t[36]=I,t[37]=L,t[38]=R,t[39]=z,t[40]=B,t[41]=V,t[42]=H,t[43]=G,t[44]=K,t[45]=q}else F=t[35],I=t[36],L=t[37],R=t[38],z=t[39],B=t[40],V=t[41],H=t[42],G=t[43],K=t[44],q=t[45];let J;t[66]!==B||t[67]!==V?(J=(0,X.jsx)(`div`,{className:B,children:V}),t[66]=B,t[67]=V,t[68]=J):J=t[68];let Y;t[69]!==p||t[70]!==r.marketplaceBuiltinGoBuiltin||t[71]!==r.marketplaceBuiltinManageHint||t[72]!==r.marketplaceInstall||t[73]!==r.marketplaceReinstall||t[74]!==r.marketplaceReinstallConfirm||t[75]!==r.marketplaceUninstall||t[76]!==r.marketplaceUninstallConfirm||t[77]!==D||t[78]!==M||t[79]!==o||t[80]!==s||t[81]!==u||t[82]!==n||t[83]!==g||t[84]!==N?(Y=D?(0,X.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:M===`bundled`?(0,X.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,X.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:r.marketplaceBuiltinManageHint}),(0,X.jsx)(a,{to:`/extensions?tab=builtin`,onClick:o,className:`inline-flex w-fit items-center justify-center rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.marketplaceBuiltinGoBuiltin})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,disabled:p||!D.installability.available||!g,onClick:()=>{N&&!window.confirm(r.marketplaceReinstallConfirm)||(h(!0),s(n,N).catch(se).finally(()=>h(!1)))},className:f(`inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`bg-accent text-white shadow-surface hover:bg-accent-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`disabled:pointer-events-none disabled:opacity-50`),children:[p?(0,X.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,N?r.marketplaceReinstall:r.marketplaceInstall]}),N?(0,X.jsxs)(`button`,{type:`button`,disabled:p,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(h(!0),u(n).then(()=>o()).catch(oe).finally(()=>h(!1)))},className:f(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,X.jsx)(ee,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[69]=p,t[70]=r.marketplaceBuiltinGoBuiltin,t[71]=r.marketplaceBuiltinManageHint,t[72]=r.marketplaceInstall,t[73]=r.marketplaceReinstall,t[74]=r.marketplaceReinstallConfirm,t[75]=r.marketplaceUninstall,t[76]=r.marketplaceUninstallConfirm,t[77]=D,t[78]=M,t[79]=o,t[80]=s,t[81]=u,t[82]=n,t[83]=g,t[84]=N,t[85]=Y):Y=t[85];let Z;t[86]!==F||t[87]!==J||t[88]!==Y||t[89]!==H||t[90]!==G||t[91]!==K?(Z=(0,X.jsxs)(F,{className:H,onOpenAutoFocus:G,children:[K,J,Y]}),t[86]=F,t[87]=J,t[88]=Y,t[89]=H,t[90]=G,t[91]=K,t[92]=Z):Z=t[92];let Q;t[93]!==I||t[94]!==Z||t[95]!==q?(Q=(0,X.jsxs)(I,{children:[q,Z]}),t[93]=I,t[94]=Z,t[95]=q,t[96]=Q):Q=t[96];let $;return t[97]!==L||t[98]!==R||t[99]!==z||t[100]!==Q?($=(0,X.jsx)(L,{defaultOpen:R,onOpenChange:z,children:Q}),t[97]=L,t[98]=R,t[99]=z,t[100]=Q,t[101]=$):$=t[101],$}function oe(){}function se(){}function ce(e){let[t,n]=e;return(0,X.jsxs)(`li`,{className:`break-words`,children:[(0,X.jsx)(`code`,{children:t}),`: `,Array.isArray(n)?n.join(`, `):String(n)]},t)}function le(e){return e.preventDefault()}function ue(e){return!!e.conversationId}function de(){let e=g(e=>e.language),t=v(e),n=L(e=>e.setPageHeader),r=L(e=>e.clearPageHeader),o=R(),s=M(),[c,l]=i(),d=G(c.get(`tab`)),f=c.get(`q`)??``,[p,m]=(0,U.useState)(d),[h,_]=(0,U.useState)(f),[y,b]=(0,U.useState)(null),x=c.toString(),S=(0,U.useRef)(x);if(S.current!==x){S.current=x;let e=G(c.get(`tab`)),t=c.get(`q`)??``;m(t=>t===e?t:e),_(e=>e===t?e:t)}(0,U.useEffect)(()=>{l(e=>{let t=new URLSearchParams(e),n=h.trim();return n?t.set(`q`,n):t.delete(`q`),p===`marketplace`?t.delete(`tab`):t.set(`tab`,p),t.toString()===e.toString()?e:t},{replace:!0})},[p,h,l]);let C=(0,U.useMemo)(()=>o.filter(e=>e.source===`bundled`),[o]),w=(0,U.useMemo)(()=>o.filter(e=>e.source!==`bundled`),[o]),T=p===`builtin`?C:w,E=(0,U.useMemo)(()=>{let t=h.trim().toLowerCase(),n=T;return t&&(n=n.filter(e=>(e.name??``).toLowerCase().includes(t)||e.id.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t))),n.toSorted((t,n)=>t.hasUi===n.hasUi?(t.name||t.id).localeCompare(n.name||n.id,e):t.hasUi?-1:1)},[T,h,e]);if((0,U.useEffect)(()=>{b(e=>{if(!e)return e;let t=o.find(t=>t.id===e.id);return t?fe(e)===fe(t)&&e.active===t.active?e:t:null})},[o]),(0,U.useLayoutEffect)(()=>(n({startExtra:null,main:(0,X.jsx)(`div`,{className:`min-w-0`,children:(0,X.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.extensionsPage.title})}),end:(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(D,{asChild:!0,variant:`secondary`,className:`h-9`,children:(0,X.jsxs)(a,{to:`/local-apps`,"aria-label":t.extensionsPage.openLocalApps,title:t.extensionsPage.openLocalApps,children:[(0,X.jsx)(A,{className:`size-4`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:t.extensionsPage.openLocalApps})]})}),(0,X.jsx)(D,{asChild:!0,variant:`primary`,className:`h-9`,children:(0,X.jsxs)(a,{to:`/local-apps/new`,children:[(0,X.jsx)(u,{className:`size-4`}),t.extensionsPage.createLocalApp]})})]})}),()=>r()),[r,t.extensionsPage.createLocalApp,t.extensionsPage.openLocalApps,t.extensionsPage.title,n]),s&&p!==`marketplace`)return(0,X.jsx)(ye,{});let O=p!==`marketplace`&&T.length>0;return(0,X.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,X.jsxs)(`div`,{className:`mx-auto w-full max-w-7xl px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[(0,X.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 border-b border-edge-subtle pb-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,X.jsx)(H,{items:[{id:`marketplace`,label:t.extensionsPage.tabMarketplace},{id:`builtin`,label:t.extensionsPage.tabBuiltin,count:C.length},{id:`user`,label:t.extensionsPage.tabUser,count:w.length}],activeTab:p,onChange:m,ariaLabel:t.extensionsPage.extensionsNavAria,tabIdPrefix:`extensions-tab`,panelIdPrefix:`extensions-panel`,className:`flex-wrap`}),O?(0,X.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,X.jsx)(V,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,X.jsx)(`input`,{type:`search`,value:h,onChange:e=>_(e.target.value),placeholder:t.extensionsPage.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,autoComplete:`off`})]}):null]}),p===`marketplace`?(0,X.jsx)(Q,{}):p===`builtin`&&C.length===0?(0,X.jsx)(xe,{message:t.extensionsPage.emptyBuiltin}):p===`user`&&w.length===0?(0,X.jsx)(xe,{message:t.extensionsPage.emptyUser}):E.length===0?(0,X.jsx)(`p`,{className:`px-3 py-14 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.extensionsPage.noSearchResults}):(0,X.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:E.map(e=>(0,X.jsx)(ge,{extension:e,copy:t.extensionsPage,showSourceBadge:p===`user`,onOpen:()=>b(e)},e.id))})]}),y?(0,X.jsx)(_e,{extension:y,copy:t.extensionsPage,onClose:()=>b(null)},y.id):null]})}function fe(e){return e.activationEligible??e.active}function pe(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function me(e,t){return e.source===`global`?t.badgeSourceGlobal:e.source===`workspace`?t.badgeSourceWorkspace:t.badgeSourceOther}function he(e,t){let n=fe(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function ge(e){let t=(0,W.c)(45),{extension:n,copy:r,showSourceBadge:i,onOpen:a}=e,s;t[0]===n?s=t[1]:(s=fe(n),t[0]=n,t[1]=s);let c=s,l=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=f(`group flex w-full flex-col rounded-xl border border-edge-subtle bg-surface-base p-4 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`dark:hover:bg-surface-hover/25`),t[2]=d):d=t[2];let p=n.name||n.id,m;t[3]===p?m=t[4]:(m=p.charAt(0).toUpperCase(),t[3]=p,t[4]=m);let h;t[5]===m?h=t[6]:(h=(0,X.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-base font-semibold text-accent-fg`,"aria-hidden":!0,children:m}),t[5]=m,t[6]=h);let g;t[7]===n.name?g=t[8]:(g=(0,X.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=g);let _;t[9]===n.version?_=t[10]:(_=n.version?(0,X.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=_);let v;t[11]!==g||t[12]!==_?(v=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[g,_]}),t[11]=g,t[12]=_,t[13]=v):v=t[13];let y;t[14]!==r.statusEnabled||t[15]!==c?(y=c?(0,X.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[(0,X.jsx)(o,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),r.statusEnabled]}):(0,X.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full border-2 border-accent text-accent`,"aria-hidden":!0,children:(0,X.jsx)(u,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=c,t[16]=y):y=t[16];let b;t[17]!==v||t[18]!==y?(b=(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[v,y]}),t[17]=v,t[18]=y,t[19]=b):b=t[19];let x;t[20]!==r.cardNoDescription||t[21]!==n.description?(x=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=x):x=t[22];let S;t[23]===x?S=t[24]:(S=(0,X.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:x}),t[23]=x,t[24]=S);let C=n.hasUi?r.badgeKindUi:r.badgeKindBackend,w;t[25]!==C||t[26]!==l?(w=(0,X.jsx)(`span`,{title:l,className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:C}),t[25]=C,t[26]=l,t[27]=w):w=t[27];let T;t[28]!==r||t[29]!==n||t[30]!==i?(T=n.source===`bundled`?(0,X.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:r.badgeBundled}):i?(0,X.jsx)(`span`,{title:pe(n,r),className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:me(n,r)}):null,t[28]=r,t[29]=n,t[30]=i,t[31]=T):T=t[31];let E;t[32]!==w||t[33]!==T?(E=(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[w,T]}),t[32]=w,t[33]=T,t[34]=E):E=t[34];let D;t[35]!==b||t[36]!==S||t[37]!==E?(D=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,S,E]}),t[35]=b,t[36]=S,t[37]=E,t[38]=D):D=t[38];let O;t[39]!==D||t[40]!==h?(O=(0,X.jsxs)(`div`,{className:`flex gap-3`,children:[h,D]}),t[39]=D,t[40]=h,t[41]=O):O=t[41];let k;return t[42]!==a||t[43]!==O?(k=(0,X.jsx)(`button`,{type:`button`,onClick:a,className:d,children:O}),t[42]=a,t[43]=O,t[44]=k):k=t[44],k}function _e({extension:e,copy:t,onClose:n}){let{mutate:r}=T(),[i,o]=(0,U.useState)(!1),[c,u]=(0,U.useState)(null),[p,m]=(0,U.useState)(!1),h=e.activationEligible===!0,g=(0,U.useCallback)(async()=>{if(e.source===`bundled`){u(null),m(!1),o(!0);try{let{requiresGatewayRestart:t}=await J({extensionId:e.id,enabled:!h});await r(`gateway-extensions-list`),k(),m(t)}catch(e){u(e instanceof Error?e.message:t.builtinToggleFailed)}finally{o(!1)}}},[h,t.builtinToggleFailed,e.id,e.source,r]),_=e.ui?.contributions?.pages??[],v=e.ui?.contributions?.settingsPanels??[],E=e.ui?.contributions?.chatWidgets??[],O=e.ui?.contributions?.sidebarPanels??[],ee=_.find(e=>e.showInNav)??_[0],A=v[0],M=ee?j(e.id,ee):null,ne=A?`/settings/ext/${e.id}/${A.id}`:e.hasConfigSchema||P(e)?`/settings/ext/${e.id}`:null;return(0,X.jsx)(w,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,X.jsxs)(x,{children:[(0,X.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,X.jsxs)(S,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailBack,children:(0,X.jsx)(te,{className:`size-5`})}),(0,X.jsx)(C,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,X.jsxs)(b,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,X.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailClose,children:(0,X.jsx)(d,{className:`size-5`})})]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,X.jsx)(`div`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-accent-soft text-xl font-semibold text-accent-fg`,"aria-hidden":!0,children:(e.name||e.id).charAt(0).toUpperCase()}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,X.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,pe(e,t)]}),e.version?(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,X.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,X.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,X.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:he(e,t)}),e.source===`bundled`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted shadow-surface dark:bg-surface-hover/20`,children:t.builtinConfigHint}),(0,X.jsxs)(`div`,{className:`mt-3 rounded-lg bg-surface-hover/40 p-3 shadow-surface dark:bg-surface-hover/20`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,X.jsx)(D,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void g(),className:`shrink-0 py-1.5 text-xs`,children:i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(l,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):h?t.builtinToggleDisable:t.builtinToggleEnable})]}),c?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:c}):null,p?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null]})]}):(0,X.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted shadow-surface dark:bg-surface-hover/20`,children:t.cliManageHint}),e.hasUi&&(_.length>0||v.length>0||E.length>0)?(0,X.jsxs)(`section`,{className:`mt-8`,children:[(0,X.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,X.jsx)(ve,{template:t.badgePages,count:_.length,hidden:_.length===0}),(0,X.jsx)(ve,{template:t.badgeSettings,count:v.length,hidden:v.length===0}),(0,X.jsx)(ve,{template:t.badgeWidgets,count:E.length,hidden:E.length===0}),(0,X.jsx)(ve,{template:t.badgeSidebar,count:O.length,hidden:O.length===0})]})]}):null,N(e)&&(M||ne)?(0,X.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[M?(0,X.jsxs)(a,{to:M,onClick:n,className:f(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,X.jsx)(s,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,ne?(0,X.jsxs)(a,{to:ne,onClick:n,className:f(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,X.jsx)(F,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,X.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function ve(e){let t=(0,W.c)(6),{template:n,count:r,hidden:i}=e;if(i||r===0)return null;let a;if(t[0]!==r||t[1]!==n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\{\{count\}\}/g,t[3]=e):e=t[3],a=n.replace(e,String(r)),t[0]=r,t[1]=n,t[2]=a}else a=t[2];let o;return t[4]===a?o=t[5]:(o=(0,X.jsx)(`span`,{className:`inline-flex items-center rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:a}),t[4]=a,t[5]=o),o}function ye(){let e=(0,W.c)(5),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,X.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),n=(0,X.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),r=(0,X.jsx)(`div`,{className:`mb-5 h-9 w-full max-w-lg animate-pulse rounded-full bg-surface-hover`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=[`ap0`,`ap1`,`ap2`,`ap3`,`ap4`,`ap5`],e[3]=i):i=e[3];let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,X.jsxs)(`div`,{className:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[t,n,r,(0,X.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:i.map(be)})]})}),e[4]=a):a=e[4],a}function be(e){return(0,X.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge-subtle bg-surface-base shadow-surface`},e)}function xe(e){let t=(0,W.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,X.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-col items-center justify-center rounded-xl border border-edge-subtle bg-surface-base px-4 py-12 text-center shadow-surface`,children:(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{de as ExtensionsPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{h as i,t as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as o}from"./check-DUBLcKHA.js";import{t as s}from"./external-link-DjqjBmc3.js";import{t as c}from"./markdown-view-BIg7cei7.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./plus-Q2yW6OE7.js";import{t as d}from"./x-B_N4OPjy.js";import{t as f}from"./cn-JdwAhgNB.js";import{a as p,c as m,i as h,n as g,r as _}from"./locale-store-eliqUnBr.js";import{t as v}from"./messages-NYDOR8-j.js";import{a as y,i as b,o as x,r as S,s as C,t as w}from"./dist-BGTk37IG.js";import{a as T,i as E}from"./vendor-swr-BIWyz7Rc.js";import{t as D}from"./button-CGlRPNzi.js";import{t as O}from"./skeleton-BwbyijEw.js";import{$a as k,$s as ee,Au as A,Ga as j,Hu as te,Ja as M,Qs as ne,Xa as N,Ya as P,bc as F,bu as I,ho as L,qa as R,qc as z,ta as B,vc as re,wc as V}from"./index-CEkw-fGy.js";import{t as H}from"./page-tabs-B604dteb.js";var U=e(t(),1),W=n();function G(e){return e===`builtin`||e===`user`?e:`marketplace`}async function K(e){try{let t=await e.json();if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&typeof t.error.message==`string`)return t.error.message;if(typeof t.message==`string`)return t.message}catch{}return e.statusText||`HTTP ${e.status}`}async function ie(e){let t=await h(_(`/api/marketplace/packages/${encodeURIComponent(e.trim())}`),{cache:`no-store`});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload?.id)throw Error(n.error??`Invalid response`);return n.payload}async function q(e){let t=await h(_(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload?.extensionId)throw Error(n.error??`Invalid response`);return n.payload}async function J(e){let t=await h(_(`/api/extensions/bundled/activation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e.extensionId.trim(),enabled:e.enabled})});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error?.message??`Invalid response`);return n.payload}async function Y(e){let t=await h(_(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e})});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error??`Invalid response`);return n.payload}var X=r();function ae(e,t){let n=e.find(e=>e.id===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var Z={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function Q({className:e}){let t=v(g(e=>e.language)).extensionsPage,n=m(e=>!!e.conversationId),r=R(),{mutate:i}=T(),[a,o]=(0,U.useReducer)(B,Z),{q:s,debounced:c,detailPkg:u,rowBusy:d,actionError:h,restartHint:y}=a,b=n?`marketplace-${c}`:null;(0,U.useEffect)(()=>{let e=window.setTimeout(()=>o({type:`patch`,patch:{debounced:s.trim()}}),300);return()=>window.clearTimeout(e)},[s]);let{data:x,isLoading:S,error:C}=E(b,async()=>p(c.length>0?_(`/api/marketplace?q=${encodeURIComponent(c)}`):_(`/api/marketplace`)),{revalidateOnFocus:!1}),w=(0,U.useCallback)(()=>{i(`gateway-extensions-list`),k()},[i]),D=(0,U.useCallback)(async(e,n)=>{o({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await q({name:e,overwrite:n});w(),r.requiresGatewayRestart&&o({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw o({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceInstallFailed}}),e}finally{o({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceInstallFailed,t.marketplaceRestartHint,w]),A=(0,U.useCallback)(async e=>{o({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await Y(e);w(),n.requiresGatewayRestart&&o({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw o({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceUninstallFailed}}),e}finally{o({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceRestartHint,t.marketplaceUninstallFailed,w]),j=x?.extensions??[];return(0,X.jsxs)(`div`,{className:f(`flex flex-col gap-4`,e),children:[(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(V,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`input`,{type:`search`,value:s,onChange:e=>o({type:`patch`,patch:{q:e.target.value}}),placeholder:t.marketplaceSearchPlaceholder,className:`ui-input h-10 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted`})]}),C?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:C instanceof Error?C.message:t.marketplaceLoadFailed}):null,h?(0,X.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:h}):null,y?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:y}):null,S&&!x?(0,X.jsx)(`ul`,{className:`flex flex-col gap-3`,"aria-label":t.marketplaceLoading,children:[0,1,2].map(e=>(0,X.jsx)(`li`,{className:`rounded-xl bg-surface-panel p-4 shadow-surface`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2.5`,children:[(0,X.jsx)(O,{className:`h-5 w-40`}),(0,X.jsx)(O,{className:`h-4 w-full max-w-xl`}),(0,X.jsx)(O,{className:`h-4 w-2/3 max-w-md`})]}),(0,X.jsx)(O,{className:`h-8 w-20`})]})},e))}):(0,X.jsx)(`ul`,{className:`flex flex-col gap-3`,children:j.length===0?(0,X.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):j.map(e=>{let n=ae(r,e.id),i=d===e.id;return(0,X.jsx)(`li`,{className:`list-none`,children:(0,X.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-label":`${e.name}, ${t.marketplaceDetailTitle}`,onClick:()=>o({type:`patch`,patch:{detailPkg:e.id}}),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),o({type:`patch`,patch:{detailPkg:e.id}}))},className:f(`flex w-full cursor-pointer flex-wrap items-start gap-3 rounded-xl bg-surface-panel p-4 text-left shadow-surface`,`transition-[transform,background-color,box-shadow] duration-150 ease-out`,`hover:bg-surface-hover/40`,`active:scale-[0.992] active:bg-surface-hover/55`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:hover:bg-surface-hover/25 dark:active:bg-surface-hover/35`),children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,X.jsx)(I,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,X.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,X.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.description}):null,(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,X.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e))}),(0,X.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,X.jsx)(z,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]}),(0,X.jsx)(`div`,{role:`group`,className:`flex shrink-0 flex-col items-end gap-2 sm:min-w-[9rem]`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:n===`bundled`?(0,X.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.marketplaceBuiltin}):n===`user`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium text-fg-muted`,children:t.marketplaceInstalled}),(0,X.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&A(e.id).catch(()=>{})},className:f(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-colors active:scale-[0.98] active:bg-surface-hover/80`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[i?(0,X.jsx)(l,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(ee,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,X.jsx)(`button`,{type:`button`,onClick:()=>o({type:`patch`,patch:{detailPkg:e.id}}),className:f(`inline-flex w-full items-center justify-center rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-[transform,background-color] active:scale-[0.98]`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:t.marketplaceReview})})]})},e.id)})}),u?(0,X.jsx)($,{packageName:u,copy:t,extensions:r,onClose:()=>o({type:`patch`,patch:{detailPkg:null}}),onInstall:D,onUninstall:A}):null]})}function $(e){let t=(0,W.c)(102),{packageName:n,copy:r,extensions:i,onClose:o,onInstall:s,onUninstall:u}=e,[p,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(!1),v=m(ue)?`ext-mp-detail-${n}`:null,b;t[0]===n?b=t[1]:(b=async()=>ie(n),t[0]=n,t[1]=b);let T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T={revalidateOnFocus:!1},t[2]=T):T=t[2];let{data:D,error:k,isLoading:A}=E(v,b,T),j;t[3]!==i||t[4]!==n?(j=ae(i,n),t[3]=i,t[4]=n,t[5]=j):j=t[5];let M=j,N=M===`user`,P=D?.manifest?.permissions,F,I,L,R,z,B,V,H,G,K,q;if(t[6]!==r.detailBack||t[7]!==r.detailClose||t[8]!==r.marketplaceAuthor||t[9]!==r.marketplaceCodeRisk||t[10]!==r.marketplaceDependencies||t[11]!==r.marketplaceDetailLoadFailed||t[12]!==r.marketplaceDetailReadmeHeading||t[13]!==r.marketplaceDetailTitle||t[14]!==r.marketplaceDownloads||t[15]!==r.marketplaceIntegrity||t[16]!==r.marketplaceIntegrityVerified||t[17]!==r.marketplaceLifecycleScripts||t[18]!==r.marketplaceLoadFailed||t[19]!==r.marketplaceLoading||t[20]!==r.marketplaceNoReadme||t[21]!==r.marketplacePermissions||t[22]!==r.marketplacePermissionsNone||t[23]!==r.marketplaceRiskConfirm||t[24]!==r.marketplaceRiskTitle||t[25]!==r.marketplaceUnavailableBody||t[26]!==r.marketplaceUnavailableTitle||t[27]!==r.marketplaceVersion||t[28]!==D||t[29]!==k||t[30]!==M||t[31]!==A||t[32]!==o||t[33]!==P||t[34]!==g){let e=P&&typeof P==`object`&&!Array.isArray(P)?Object.entries(P):[],n;t[46]!==r.marketplaceNoReadme||t[47]!==D?(n=D?.readme?.trim()||(D?.description?.trim()?`### ${D.name}\n\n${D.description}`:`*${r.marketplaceNoReadme}*`),t[46]=r.marketplaceNoReadme,t[47]=D,t[48]=n):n=t[48];let i=n;L=w,R=!0,t[49]===o?z=t[50]:(z=e=>!e&&o(),t[49]=o,t[50]=z),I=x,t[51]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,X.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[51]=q):q=t[51],F=S,H=`fixed left-1/2 top-1/2 z-[131] flex h-[min(44rem,calc(100vh-1.5rem))] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,G=le;let a;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(te,{className:`size-5`}),t[52]=a):a=t[52];let s;t[53]!==r.detailBack||t[54]!==o?(s=(0,X.jsx)(`button`,{type:`button`,onClick:o,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailBack,children:a}),t[53]=r.detailBack,t[54]=o,t[55]=s):s=t[55];let l;t[56]===r.marketplaceDetailTitle?l=t[57]:(l=(0,X.jsx)(C,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[56]=r.marketplaceDetailTitle,t[57]=l);let u;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,X.jsx)(d,{className:`size-5`}),t[58]=u):u=t[58];let f;t[59]!==r.detailClose||t[60]!==o?(f=(0,X.jsx)(`button`,{type:`button`,onClick:o,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailClose,children:u}),t[59]=r.detailClose,t[60]=o,t[61]=f):f=t[61],t[62]!==s||t[63]!==l||t[64]!==f?(K=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[s,l,f]}),t[62]=s,t[63]=l,t[64]=f,t[65]=K):K=t[65],B=`min-h-0 flex-1 overflow-y-auto p-5`,V=A&&!D?(0,X.jsxs)(`div`,{className:`space-y-4`,"aria-label":r.marketplaceLoading,children:[(0,X.jsx)(O,{className:`h-6 w-48`}),(0,X.jsx)(O,{className:`h-4 w-28`}),(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsx)(O,{className:`h-12`}),(0,X.jsx)(O,{className:`h-12`})]}),(0,X.jsx)(O,{className:`h-28 w-full`}),(0,X.jsx)(O,{className:`h-36 w-full`})]}):k?(0,X.jsxs)(`div`,{className:`rounded-lg border border-red-300/70 bg-red-50 p-4 text-sm dark:border-red-900 dark:bg-red-950/30`,children:[(0,X.jsx)(`p`,{className:`font-medium text-red-700 dark:text-red-300`,children:r.marketplaceDetailLoadFailed}),(0,X.jsx)(`p`,{className:`mt-1 break-words text-red-600 dark:text-red-400`,children:k instanceof Error?k.message:r.marketplaceLoadFailed})]}):D?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:D.name}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,X.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:D.id})}),(0,X.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceAuthor}),(0,X.jsx)(`dd`,{children:D.author.username})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,X.jsx)(`dd`,{children:D.latestVersion.version})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,X.jsx)(`dd`,{children:D.downloads})]})]}),M===`bundled`?null:(0,X.jsxs)(`section`,{className:`mt-5 space-y-3 rounded-lg border border-edge bg-surface-base p-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[D.installability.available?(0,X.jsx)(re,{className:`mt-0.5 size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):(0,X.jsx)(ne,{className:`mt-0.5 size-5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:D.installability.available?r.marketplaceRiskTitle:r.marketplaceUnavailableTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:D.installability.available?r.marketplaceCodeRisk:D.installability.reason??r.marketplaceUnavailableBody})]})]}),D.installability.available?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`dl`,{className:`grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceIntegrity}),(0,X.jsx)(`dd`,{children:r.marketplaceIntegrityVerified})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDependencies}),(0,X.jsx)(`dd`,{children:D.packageSummary?.dependencyCount??0})]})]}),(0,X.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[(0,X.jsx)(`p`,{className:`font-medium text-fg`,children:r.marketplacePermissions}),e.length>0?(0,X.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(ce)}):(0,X.jsx)(`p`,{className:`mt-1`,children:r.marketplacePermissionsNone})]}),(D.packageSummary?.lifecycleScripts.length??0)>0?(0,X.jsxs)(`p`,{className:`text-xs leading-relaxed text-amber-700 dark:text-amber-300`,children:[r.marketplaceLifecycleScripts,`: `,D.packageSummary?.lifecycleScripts.join(`, `)]}):null,(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:g,onChange:e=>_(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-[var(--color-accent)]`}),(0,X.jsx)(`span`,{children:r.marketplaceRiskConfirm})]})]}):null]}),D.readme?.trim()?(0,X.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:r.marketplaceDetailReadmeHeading}):null,(0,X.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,X.jsx)(c,{content:i})})]}):null,t[6]=r.detailBack,t[7]=r.detailClose,t[8]=r.marketplaceAuthor,t[9]=r.marketplaceCodeRisk,t[10]=r.marketplaceDependencies,t[11]=r.marketplaceDetailLoadFailed,t[12]=r.marketplaceDetailReadmeHeading,t[13]=r.marketplaceDetailTitle,t[14]=r.marketplaceDownloads,t[15]=r.marketplaceIntegrity,t[16]=r.marketplaceIntegrityVerified,t[17]=r.marketplaceLifecycleScripts,t[18]=r.marketplaceLoadFailed,t[19]=r.marketplaceLoading,t[20]=r.marketplaceNoReadme,t[21]=r.marketplacePermissions,t[22]=r.marketplacePermissionsNone,t[23]=r.marketplaceRiskConfirm,t[24]=r.marketplaceRiskTitle,t[25]=r.marketplaceUnavailableBody,t[26]=r.marketplaceUnavailableTitle,t[27]=r.marketplaceVersion,t[28]=D,t[29]=k,t[30]=M,t[31]=A,t[32]=o,t[33]=P,t[34]=g,t[35]=F,t[36]=I,t[37]=L,t[38]=R,t[39]=z,t[40]=B,t[41]=V,t[42]=H,t[43]=G,t[44]=K,t[45]=q}else F=t[35],I=t[36],L=t[37],R=t[38],z=t[39],B=t[40],V=t[41],H=t[42],G=t[43],K=t[44],q=t[45];let J;t[66]!==B||t[67]!==V?(J=(0,X.jsx)(`div`,{className:B,children:V}),t[66]=B,t[67]=V,t[68]=J):J=t[68];let Y;t[69]!==p||t[70]!==r.marketplaceBuiltinGoBuiltin||t[71]!==r.marketplaceBuiltinManageHint||t[72]!==r.marketplaceInstall||t[73]!==r.marketplaceReinstall||t[74]!==r.marketplaceReinstallConfirm||t[75]!==r.marketplaceUninstall||t[76]!==r.marketplaceUninstallConfirm||t[77]!==D||t[78]!==M||t[79]!==o||t[80]!==s||t[81]!==u||t[82]!==n||t[83]!==g||t[84]!==N?(Y=D?(0,X.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:M===`bundled`?(0,X.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,X.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:r.marketplaceBuiltinManageHint}),(0,X.jsx)(a,{to:`/extensions?tab=builtin`,onClick:o,className:`inline-flex w-fit items-center justify-center rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.marketplaceBuiltinGoBuiltin})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,disabled:p||!D.installability.available||!g,onClick:()=>{N&&!window.confirm(r.marketplaceReinstallConfirm)||(h(!0),s(n,N).catch(se).finally(()=>h(!1)))},className:f(`inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`bg-accent text-white shadow-surface hover:bg-accent-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`disabled:pointer-events-none disabled:opacity-50`),children:[p?(0,X.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,N?r.marketplaceReinstall:r.marketplaceInstall]}),N?(0,X.jsxs)(`button`,{type:`button`,disabled:p,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(h(!0),u(n).then(()=>o()).catch(oe).finally(()=>h(!1)))},className:f(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,X.jsx)(ee,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[69]=p,t[70]=r.marketplaceBuiltinGoBuiltin,t[71]=r.marketplaceBuiltinManageHint,t[72]=r.marketplaceInstall,t[73]=r.marketplaceReinstall,t[74]=r.marketplaceReinstallConfirm,t[75]=r.marketplaceUninstall,t[76]=r.marketplaceUninstallConfirm,t[77]=D,t[78]=M,t[79]=o,t[80]=s,t[81]=u,t[82]=n,t[83]=g,t[84]=N,t[85]=Y):Y=t[85];let Z;t[86]!==F||t[87]!==J||t[88]!==Y||t[89]!==H||t[90]!==G||t[91]!==K?(Z=(0,X.jsxs)(F,{className:H,onOpenAutoFocus:G,children:[K,J,Y]}),t[86]=F,t[87]=J,t[88]=Y,t[89]=H,t[90]=G,t[91]=K,t[92]=Z):Z=t[92];let Q;t[93]!==I||t[94]!==Z||t[95]!==q?(Q=(0,X.jsxs)(I,{children:[q,Z]}),t[93]=I,t[94]=Z,t[95]=q,t[96]=Q):Q=t[96];let $;return t[97]!==L||t[98]!==R||t[99]!==z||t[100]!==Q?($=(0,X.jsx)(L,{defaultOpen:R,onOpenChange:z,children:Q}),t[97]=L,t[98]=R,t[99]=z,t[100]=Q,t[101]=$):$=t[101],$}function oe(){}function se(){}function ce(e){let[t,n]=e;return(0,X.jsxs)(`li`,{className:`break-words`,children:[(0,X.jsx)(`code`,{children:t}),`: `,Array.isArray(n)?n.join(`, `):String(n)]},t)}function le(e){return e.preventDefault()}function ue(e){return!!e.conversationId}function de(){let e=g(e=>e.language),t=v(e),n=L(e=>e.setPageHeader),r=L(e=>e.clearPageHeader),o=R(),s=M(),[c,l]=i(),d=G(c.get(`tab`)),f=c.get(`q`)??``,[p,m]=(0,U.useState)(d),[h,_]=(0,U.useState)(f),[y,b]=(0,U.useState)(null),x=c.toString(),S=(0,U.useRef)(x);if(S.current!==x){S.current=x;let e=G(c.get(`tab`)),t=c.get(`q`)??``;m(t=>t===e?t:e),_(e=>e===t?e:t)}(0,U.useEffect)(()=>{l(e=>{let t=new URLSearchParams(e),n=h.trim();return n?t.set(`q`,n):t.delete(`q`),p===`marketplace`?t.delete(`tab`):t.set(`tab`,p),t.toString()===e.toString()?e:t},{replace:!0})},[p,h,l]);let C=(0,U.useMemo)(()=>o.filter(e=>e.source===`bundled`),[o]),w=(0,U.useMemo)(()=>o.filter(e=>e.source!==`bundled`),[o]),T=p===`builtin`?C:w,E=(0,U.useMemo)(()=>{let t=h.trim().toLowerCase(),n=T;return t&&(n=n.filter(e=>(e.name??``).toLowerCase().includes(t)||e.id.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t))),n.toSorted((t,n)=>t.hasUi===n.hasUi?(t.name||t.id).localeCompare(n.name||n.id,e):t.hasUi?-1:1)},[T,h,e]);if((0,U.useEffect)(()=>{b(e=>{if(!e)return e;let t=o.find(t=>t.id===e.id);return t?fe(e)===fe(t)&&e.active===t.active?e:t:null})},[o]),(0,U.useLayoutEffect)(()=>(n({startExtra:null,main:(0,X.jsx)(`div`,{className:`min-w-0`,children:(0,X.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.extensionsPage.title})}),end:(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(D,{asChild:!0,variant:`secondary`,className:`h-9`,children:(0,X.jsxs)(a,{to:`/local-apps`,"aria-label":t.extensionsPage.openLocalApps,title:t.extensionsPage.openLocalApps,children:[(0,X.jsx)(A,{className:`size-4`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:t.extensionsPage.openLocalApps})]})}),(0,X.jsx)(D,{asChild:!0,variant:`primary`,className:`h-9`,children:(0,X.jsxs)(a,{to:`/local-apps/new`,children:[(0,X.jsx)(u,{className:`size-4`}),t.extensionsPage.createLocalApp]})})]})}),()=>r()),[r,t.extensionsPage.createLocalApp,t.extensionsPage.openLocalApps,t.extensionsPage.title,n]),s&&p!==`marketplace`)return(0,X.jsx)(ye,{});let O=p!==`marketplace`&&T.length>0;return(0,X.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,X.jsxs)(`div`,{className:`mx-auto w-full max-w-7xl px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[(0,X.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 border-b border-edge-subtle pb-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,X.jsx)(H,{items:[{id:`marketplace`,label:t.extensionsPage.tabMarketplace},{id:`builtin`,label:t.extensionsPage.tabBuiltin,count:C.length},{id:`user`,label:t.extensionsPage.tabUser,count:w.length}],activeTab:p,onChange:m,ariaLabel:t.extensionsPage.extensionsNavAria,tabIdPrefix:`extensions-tab`,panelIdPrefix:`extensions-panel`,className:`flex-wrap`}),O?(0,X.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,X.jsx)(V,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,X.jsx)(`input`,{type:`search`,value:h,onChange:e=>_(e.target.value),placeholder:t.extensionsPage.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,autoComplete:`off`})]}):null]}),p===`marketplace`?(0,X.jsx)(Q,{}):p===`builtin`&&C.length===0?(0,X.jsx)(xe,{message:t.extensionsPage.emptyBuiltin}):p===`user`&&w.length===0?(0,X.jsx)(xe,{message:t.extensionsPage.emptyUser}):E.length===0?(0,X.jsx)(`p`,{className:`px-3 py-14 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.extensionsPage.noSearchResults}):(0,X.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:E.map(e=>(0,X.jsx)(ge,{extension:e,copy:t.extensionsPage,showSourceBadge:p===`user`,onOpen:()=>b(e)},e.id))})]}),y?(0,X.jsx)(_e,{extension:y,copy:t.extensionsPage,onClose:()=>b(null)},y.id):null]})}function fe(e){return e.activationEligible??e.active}function pe(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function me(e,t){return e.source===`global`?t.badgeSourceGlobal:e.source===`workspace`?t.badgeSourceWorkspace:t.badgeSourceOther}function he(e,t){let n=fe(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function ge(e){let t=(0,W.c)(45),{extension:n,copy:r,showSourceBadge:i,onOpen:a}=e,s;t[0]===n?s=t[1]:(s=fe(n),t[0]=n,t[1]=s);let c=s,l=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=f(`group flex w-full flex-col rounded-xl border border-edge-subtle bg-surface-base p-4 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`dark:hover:bg-surface-hover/25`),t[2]=d):d=t[2];let p=n.name||n.id,m;t[3]===p?m=t[4]:(m=p.charAt(0).toUpperCase(),t[3]=p,t[4]=m);let h;t[5]===m?h=t[6]:(h=(0,X.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-base font-semibold text-accent-fg`,"aria-hidden":!0,children:m}),t[5]=m,t[6]=h);let g;t[7]===n.name?g=t[8]:(g=(0,X.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=g);let _;t[9]===n.version?_=t[10]:(_=n.version?(0,X.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=_);let v;t[11]!==g||t[12]!==_?(v=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[g,_]}),t[11]=g,t[12]=_,t[13]=v):v=t[13];let y;t[14]!==r.statusEnabled||t[15]!==c?(y=c?(0,X.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[(0,X.jsx)(o,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),r.statusEnabled]}):(0,X.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full border-2 border-accent text-accent`,"aria-hidden":!0,children:(0,X.jsx)(u,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=c,t[16]=y):y=t[16];let b;t[17]!==v||t[18]!==y?(b=(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[v,y]}),t[17]=v,t[18]=y,t[19]=b):b=t[19];let x;t[20]!==r.cardNoDescription||t[21]!==n.description?(x=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=x):x=t[22];let S;t[23]===x?S=t[24]:(S=(0,X.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:x}),t[23]=x,t[24]=S);let C=n.hasUi?r.badgeKindUi:r.badgeKindBackend,w;t[25]!==C||t[26]!==l?(w=(0,X.jsx)(`span`,{title:l,className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:C}),t[25]=C,t[26]=l,t[27]=w):w=t[27];let T;t[28]!==r||t[29]!==n||t[30]!==i?(T=n.source===`bundled`?(0,X.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:r.badgeBundled}):i?(0,X.jsx)(`span`,{title:pe(n,r),className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:me(n,r)}):null,t[28]=r,t[29]=n,t[30]=i,t[31]=T):T=t[31];let E;t[32]!==w||t[33]!==T?(E=(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[w,T]}),t[32]=w,t[33]=T,t[34]=E):E=t[34];let D;t[35]!==b||t[36]!==S||t[37]!==E?(D=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,S,E]}),t[35]=b,t[36]=S,t[37]=E,t[38]=D):D=t[38];let O;t[39]!==D||t[40]!==h?(O=(0,X.jsxs)(`div`,{className:`flex gap-3`,children:[h,D]}),t[39]=D,t[40]=h,t[41]=O):O=t[41];let k;return t[42]!==a||t[43]!==O?(k=(0,X.jsx)(`button`,{type:`button`,onClick:a,className:d,children:O}),t[42]=a,t[43]=O,t[44]=k):k=t[44],k}function _e({extension:e,copy:t,onClose:n}){let{mutate:r}=T(),[i,o]=(0,U.useState)(!1),[c,u]=(0,U.useState)(null),[p,m]=(0,U.useState)(!1),h=e.activationEligible===!0,g=(0,U.useCallback)(async()=>{if(e.source===`bundled`){u(null),m(!1),o(!0);try{let{requiresGatewayRestart:t}=await J({extensionId:e.id,enabled:!h});await r(`gateway-extensions-list`),k(),m(t)}catch(e){u(e instanceof Error?e.message:t.builtinToggleFailed)}finally{o(!1)}}},[h,t.builtinToggleFailed,e.id,e.source,r]),_=e.ui?.contributions?.pages??[],v=e.ui?.contributions?.settingsPanels??[],E=e.ui?.contributions?.chatWidgets??[],O=e.ui?.contributions?.sidebarPanels??[],ee=_.find(e=>e.showInNav)??_[0],A=v[0],M=ee?j(e.id,ee):null,ne=A?`/settings/ext/${e.id}/${A.id}`:e.hasConfigSchema||P(e)?`/settings/ext/${e.id}`:null;return(0,X.jsx)(w,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,X.jsxs)(x,{children:[(0,X.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,X.jsxs)(S,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailBack,children:(0,X.jsx)(te,{className:`size-5`})}),(0,X.jsx)(C,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,X.jsxs)(b,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,X.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailClose,children:(0,X.jsx)(d,{className:`size-5`})})]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,X.jsx)(`div`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-accent-soft text-xl font-semibold text-accent-fg`,"aria-hidden":!0,children:(e.name||e.id).charAt(0).toUpperCase()}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,X.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,pe(e,t)]}),e.version?(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,X.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,X.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,X.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:he(e,t)}),e.source===`bundled`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted shadow-surface dark:bg-surface-hover/20`,children:t.builtinConfigHint}),(0,X.jsxs)(`div`,{className:`mt-3 rounded-lg bg-surface-hover/40 p-3 shadow-surface dark:bg-surface-hover/20`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,X.jsx)(D,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void g(),className:`shrink-0 py-1.5 text-xs`,children:i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(l,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):h?t.builtinToggleDisable:t.builtinToggleEnable})]}),c?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:c}):null,p?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null]})]}):(0,X.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted shadow-surface dark:bg-surface-hover/20`,children:t.cliManageHint}),e.hasUi&&(_.length>0||v.length>0||E.length>0)?(0,X.jsxs)(`section`,{className:`mt-8`,children:[(0,X.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,X.jsx)(ve,{template:t.badgePages,count:_.length,hidden:_.length===0}),(0,X.jsx)(ve,{template:t.badgeSettings,count:v.length,hidden:v.length===0}),(0,X.jsx)(ve,{template:t.badgeWidgets,count:E.length,hidden:E.length===0}),(0,X.jsx)(ve,{template:t.badgeSidebar,count:O.length,hidden:O.length===0})]})]}):null,N(e)&&(M||ne)?(0,X.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[M?(0,X.jsxs)(a,{to:M,onClick:n,className:f(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,X.jsx)(s,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,ne?(0,X.jsxs)(a,{to:ne,onClick:n,className:f(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,X.jsx)(F,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,X.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function ve(e){let t=(0,W.c)(6),{template:n,count:r,hidden:i}=e;if(i||r===0)return null;let a;if(t[0]!==r||t[1]!==n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\{\{count\}\}/g,t[3]=e):e=t[3],a=n.replace(e,String(r)),t[0]=r,t[1]=n,t[2]=a}else a=t[2];let o;return t[4]===a?o=t[5]:(o=(0,X.jsx)(`span`,{className:`inline-flex items-center rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:a}),t[4]=a,t[5]=o),o}function ye(){let e=(0,W.c)(5),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,X.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),n=(0,X.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),r=(0,X.jsx)(`div`,{className:`mb-5 h-9 w-full max-w-lg animate-pulse rounded-full bg-surface-hover`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=[`ap0`,`ap1`,`ap2`,`ap3`,`ap4`,`ap5`],e[3]=i):i=e[3];let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,X.jsxs)(`div`,{className:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[t,n,r,(0,X.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:i.map(be)})]})}),e[4]=a):a=e[4],a}function be(e){return(0,X.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge-subtle bg-surface-base shadow-surface`},e)}function xe(e){let t=(0,W.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,X.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-col items-center justify-center rounded-xl border border-edge-subtle bg-surface-base px-4 py-12 text-center shadow-surface`,children:(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{de as ExtensionsPage};
|
package/dist/gateway/static/root/assets/{archive-plugin-Xj6tLKD2.js → archive-plugin-fRMLP9dL.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./messages-NYDOR8-j.js";import{t as a}from"./jszip.min-DT31yWkU.js";import{t as o}from"./preview-open-alternatives-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./messages-NYDOR8-j.js";import{t as a}from"./jszip.min-DT31yWkU.js";import{t as o}from"./preview-open-alternatives-Cp8vT7M-.js";var s=n(),c=e(a(),1),l=e(t(),1),u=r();function d(e){let t=(0,s.c)(17),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],t[0]=n):n=t[0];let[r,a]=(0,l.useState)(n),[d,m]=(0,l.useState)(null),h,g;if(t[1]===e.binaryBuffer?(h=t[2],g=t[3]):(h=()=>{if(!e.binaryBuffer)return;let t=!1;return c.default.loadAsync(e.binaryBuffer).then(e=>{t||a(Object.values(e.files).slice(0,500).map(p))}).catch(e=>{t||m(e instanceof Error?e.message:String(e))}),()=>{t=!0}},g=[e.binaryBuffer],t[1]=e.binaryBuffer,t[2]=h,t[3]=g),(0,l.useEffect)(h,g),d){let n;t[4]===e.language?n=t[5]:(n=i(e.language),t[4]=e.language,t[5]=n);let r=n,a;t[6]!==r.chat.attachmentPreviewDownloadFull||t[7]!==r.chat.attachmentPreviewOpenElsewhereHint||t[8]!==e.actions.onDownload?(a=(0,u.jsx)(o,{message:r.chat.attachmentPreviewOpenElsewhereHint,downloadLabel:r.chat.attachmentPreviewDownloadFull,onDownload:e.actions.onDownload}),t[6]=r.chat.attachmentPreviewDownloadFull,t[7]=r.chat.attachmentPreviewOpenElsewhereHint,t[8]=e.actions.onDownload,t[9]=a):a=t[9];let s;t[10]===d?s=t[11]:(s=(0,u.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}),t[10]=d,t[11]=s);let c;return t[12]!==a||t[13]!==s?(c=(0,u.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:[a,s]}),t[12]=a,t[13]=s,t[14]=c):c=t[14],c}let _;return t[15]===r?_=t[16]:(_=(0,u.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:(0,u.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-edge bg-surface-panel`,children:r.length===0?(0,u.jsx)(`p`,{className:`p-4 text-sm text-fg-muted`,children:`Loading archive...`}):(0,u.jsx)(`table`,{className:`w-full text-left text-xs`,children:(0,u.jsx)(`tbody`,{children:r.map(f)})})})}),t[15]=r,t[16]=_),_}function f(e){return(0,u.jsxs)(`tr`,{className:`border-b border-edge-subtle last:border-b-0 dark:border-edge`,children:[(0,u.jsx)(`td`,{className:`max-w-0 truncate px-3 py-2 font-mono text-fg`,title:e.name,children:e.dir?`${e.name}/`:e.name}),(0,u.jsx)(`td`,{className:`w-24 px-3 py-2 text-right text-fg-muted`,children:e.dir?``:m(e.size)})]},e.name)}function p(e){return{name:e.name,dir:e.dir,size:e.dir?0:e._data?.uncompressedSize??0}}function m(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}export{d as ArchivePreviewPluginView};
|
package/dist/gateway/static/root/assets/{attachment-load-CSMv3wDB.js → attachment-load-DVYW2whr.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aa as e,oa as t}from"./index-
|
|
1
|
+
import{aa as e,oa as t}from"./index-CEkw-fGy.js";async function n(n,r){let i,a=r||`unnamed`,o=`application/octet-stream`,s=0;if(typeof n==`string`){let e=await fetch(n);if(!e.ok)throw Error(`Failed to fetch file`);if(i=await e.arrayBuffer(),s=i.byteLength,o=e.headers.get(`content-type`)||o,!r){let e=n.split(`/`);a=e[e.length-1]||`document`}}else if(n instanceof File)i=await n.arrayBuffer(),s=n.size,o=n.type||o,a=r||n.name;else if(n instanceof Blob)i=await n.arrayBuffer(),s=n.size,o=n.type||o;else if(n instanceof ArrayBuffer)i=n,s=n.byteLength;else throw Error(`Invalid source type`);let c=new Uint8Array(i),l=``,u=32768;for(let e=0;e<c.length;e+=u){let t=c.slice(e,e+u);l+=String.fromCharCode(...t)}let d=btoa(l),f=`${a}_${Date.now()}_${Math.random()}`;if((o===`application/octet-stream`||/\.(csv|tsv)$/i.test(a))&&(o=e(a)??o),o?.startsWith(`image/`))return{id:f,type:`image`,name:a,mimeType:o,size:s,content:d,preview:d};if(o?.startsWith(`audio/`))return{id:f,type:`voice`,name:a,mimeType:o,size:s,content:d};if(t(a,o??``)){let e=new TextDecoder().decode(i);return{id:f,type:`document`,name:a,mimeType:o?.startsWith(`text/`)?o:`text/plain`,size:s,content:d,extractedText:e}}return{id:f,type:`document`,name:a,mimeType:o,size:s,content:d}}export{n as loadAttachment};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./automations-workspace-
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./automations-workspace-ClZiIDCC.js";var r=e(),i=t();function a(){let e=(0,r.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,i.jsx)(n,{}),e[0]=t):t=e[0],t}export{a as AutomationsPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{h as i,t as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as o,r as s}from"./popover-select-DldSX8GX.js";import{t as c}from"./circle-check-C23XjkUj.js";import{t as l}from"./markdown-view-BIg7cei7.js";import{t as u}from"./git-branch-Dh9uxTot.js";import{t as d}from"./message-circle-Badhj-4D.js";import{t as f}from"./plus-Q2yW6OE7.js";import{t as p}from"./x-B_N4OPjy.js";import{t as m}from"./cn-JdwAhgNB.js";import{n as h}from"./locale-store-eliqUnBr.js";import{t as g}from"./messages-NYDOR8-j.js";import{a as _,n as v,o as y,r as b,s as ee,t as x}from"./dist-BGTk37IG.js";import{i as S}from"./vendor-swr-BIWyz7Rc.js";import{t as C}from"./button-CGlRPNzi.js";import{t as w}from"./skeleton-BwbyijEw.js";import{$l as T,$s as E,Dn as te,En as D,Eu as O,Hs as k,Ia as A,Ku as ne,Lc as j,On as M,Su as N,Uc as P,Vc as re,Xi as F,fn as I,ho as L,jn as ie,kc as ae,kn as oe,l as R,la as se,pc as ce,ul as le,vc as z,wc as ue,wu as B,xu as de,y as fe}from"./index-DTDDJnrO.js";import{a as V,i as H,o as pe,r as U}from"./cron-expression-GDPX4NxC.js";import{a as me,i as he,n as ge,r as W,t as _e}from"./workflow-run-setup-panel-DdnSUVxc.js";import{i as ve,n as ye,r as G,t as be}from"./browser-automation-inputs-Cq4sIJt2.js";var K=e(t(),1),xe=n(),Se=V();function Ce(e,t,n){let r=new Date;return r.setHours(e,t,0,0),r.toLocaleTimeString(n,{hour:`numeric`,minute:`2-digit`})}function q(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 J(e){if(e.length!==2)return!1;let t=[...e].toSorted((e,t)=>e-t);return t[0]===0&&t[1]===6}function Ee(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=H(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=H(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?Ce(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&&J(s))return n.weekendsAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&s.length===1){let e=q(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=>q(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 De(e,t,n,r){let i=e.trim();return i?Ee(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):De(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,browserAutomationId:``,browserAutomationInputs:{},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=W(t,e.workflowInput),c=e.workflowInput.goal.trim()||e.workflowGoal.trim(),l=e.actionMode===`browser_automation`?`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_automation`?{kind:`browser_automation`,automationId:e.browserAutomationId.trim(),inputs:e.browserAutomationInputs}:{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_automation`?600:1800);return{...Ze,...n,name:e.name,description:e.description??``,projectId:e.projectId??``,actionMode:r.kind,agentId:r.kind===`browser_automation`?``:r.agentId??``,instruction:r.kind===`agent`?r.instruction:``,workflowId:r.kind===`workflow`?r.workflowId:``,workflowGoal:r.kind===`workflow`?r.goal??``:``,browserAutomationId:r.kind===`browser_automation`?r.automationId:``,browserAutomationInputs:r.kind===`browser_automation`?r.inputs??{}:{},workflowInput:{goal:r.kind===`workflow`?r.goal??``:``,argValues:i?ge(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_automation`&&r.action.kind===`browser_automation`&&(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}}}function ct(e){return[`reminder`,`brief`,`review`,`followUp`].map(t=>{let n=e.scenarios[t];return{...n,requiresProject:t===`followUp`,form:{...Ze,name:n.name,instruction:t===`reminder`?``:n.instruction,triggerMode:t===`reminder`?`once`:t===`review`?`weekly`:`daily`,time:t===`brief`?`08:30`:t===`review`?`17:00`:`09:00`,weekday:`5`,notificationPolicy:`all`}}})}var Z=r(),lt=`w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg focus-visible:outline-2 focus-visible:outline-accent`;function ut(e){let t=(0,xe.c)(99),{form:n,setForm:r,labels:i,projects:a,projectLocked:c,source:l,requiresProject:u}=e,d;t[0]===r?d=t[1]:(d=e=>r(t=>({...t,...e})),t[0]=r,t[1]=d);let f=d,p;t[2]!==i.experience.source||t[3]!==l?(p=(0,Z.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[i.experience.source,`: `,l]}),t[2]=i.experience.source,t[3]=l,t[4]=p):p=t[4];let m;t[5]===f?m=t[6]:(m=e=>f({name:e.target.value}),t[5]=f,t[6]=m);let h;t[7]!==n.name||t[8]!==m?(h=(0,Z.jsx)(`input`,{className:lt,value:n.name,onChange:m}),t[7]=n.name,t[8]=m,t[9]=h):h=t[9];let g;t[10]!==i.form.name||t[11]!==h?(g=(0,Z.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.form.name,h]}),t[10]=i.form.name,t[11]=h,t[12]=g):g=t[12];let _;t[13]===f?_=t[14]:(_=e=>f({instruction:e.target.value}),t[13]=f,t[14]=_);let v;t[15]!==n.instruction||t[16]!==_?(v=(0,Z.jsx)(`textarea`,{className:lt,rows:5,value:n.instruction,onChange:_}),t[15]=n.instruction,t[16]=_,t[17]=v):v=t[17];let y;t[18]!==i.info.task||t[19]!==v?(y=(0,Z.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.info.task,v]}),t[18]=i.info.task,t[19]=v,t[20]=y):y=t[20];let b;t[21]!==n.projectId||t[22]!==i.form.noProject||t[23]!==i.form.project||t[24]!==c||t[25]!==a||t[26]!==f?(b=!c&&(0,Z.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.form.project,(0,Z.jsxs)(o,{className:lt,value:n.projectId,onChange:e=>f({projectId:e.target.value}),children:[(0,Z.jsx)(s,{value:``,children:i.form.noProject}),a.map(dt)]})]}),t[21]=n.projectId,t[22]=i.form.noProject,t[23]=i.form.project,t[24]=c,t[25]=a,t[26]=f,t[27]=b):b=t[27];let ee;t[28]!==n.projectId||t[29]!==i.experience.projectRequired||t[30]!==u?(ee=u&&!n.projectId?(0,Z.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:i.experience.projectRequired}):null,t[28]=n.projectId,t[29]=i.experience.projectRequired,t[30]=u,t[31]=ee):ee=t[31];let x;t[32]===f?x=t[33]:(x=e=>f({triggerMode:e.target.value}),t[32]=f,t[33]=x);let S;t[34]===i.trigger.once?S=t[35]:(S=(0,Z.jsx)(s,{value:`once`,children:i.trigger.once}),t[34]=i.trigger.once,t[35]=S);let C;t[36]===i.trigger.daily?C=t[37]:(C=(0,Z.jsx)(s,{value:`daily`,children:i.trigger.daily}),t[36]=i.trigger.daily,t[37]=C);let w;t[38]===i.trigger.weekly?w=t[39]:(w=(0,Z.jsx)(s,{value:`weekly`,children:i.trigger.weekly}),t[38]=i.trigger.weekly,t[39]=w);let T;t[40]!==n.triggerMode||t[41]!==x||t[42]!==S||t[43]!==C||t[44]!==w?(T=(0,Z.jsxs)(o,{className:lt,value:n.triggerMode,onChange:x,children:[S,C,w]}),t[40]=n.triggerMode,t[41]=x,t[42]=S,t[43]=C,t[44]=w,t[45]=T):T=t[45];let E;t[46]!==i.form.trigger||t[47]!==T?(E=(0,Z.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.form.trigger,T]}),t[46]=i.form.trigger,t[47]=T,t[48]=E):E=t[48];let te;t[49]!==n.onceAt||t[50]!==n.time||t[51]!==n.triggerMode||t[52]!==i.form.onceAt||t[53]!==i.form.time||t[54]!==f?(te=n.triggerMode===`once`?(0,Z.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.form.onceAt,(0,Z.jsx)(`input`,{type:`datetime-local`,className:lt,value:n.onceAt,onChange:e=>f({onceAt:e.target.value})})]}):(0,Z.jsxs)(`div`,{className:`grid gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`span`,{children:i.form.time}),(0,Z.jsx)(pe,{value:n.time,onChange:e=>f({time:e}),ariaLabel:i.form.time})]}),t[49]=n.onceAt,t[50]=n.time,t[51]=n.triggerMode,t[52]=i.form.onceAt,t[53]=i.form.time,t[54]=f,t[55]=te):te=t[55];let D;t[56]!==n.triggerMode||t[57]!==n.weekday||t[58]!==i.form.day||t[59]!==i.weekdays||t[60]!==f?(D=n.triggerMode===`weekly`&&(0,Z.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.form.day,(0,Z.jsx)(o,{className:lt,value:n.weekday,onChange:e=>f({weekday:e.target.value}),children:[`sunday`,`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`].map((e,t)=>(0,Z.jsx)(s,{value:String(t),children:i.weekdays[e]},e))})]}),t[56]=n.triggerMode,t[57]=n.weekday,t[58]=i.form.day,t[59]=i.weekdays,t[60]=f,t[61]=D):D=t[61];let O;t[62]!==E||t[63]!==te||t[64]!==D?(O=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[E,te,D]}),t[62]=E,t[63]=te,t[64]=D,t[65]=O):O=t[65];let k;t[66]!==n.onceAt||t[67]!==n.triggerMode||t[68]!==i.experience.futureTime?(k=n.triggerMode===`once`&&n.onceAt&&new Date(n.onceAt).getTime()<=Date.now()?(0,Z.jsx)(`p`,{role:`status`,className:`text-sm text-red-700 dark:text-red-300`,children:i.experience.futureTime}):null,t[66]=n.onceAt,t[67]=n.triggerMode,t[68]=i.experience.futureTime,t[69]=k):k=t[69];let A;t[70]===i.experience.scheduleNote?A=t[71]:(A=(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.experience.scheduleNote}),t[70]=i.experience.scheduleNote,t[71]=A);let ne;t[72]===f?ne=t[73]:(ne=e=>f({notificationPolicy:e.target.value}),t[72]=f,t[73]=ne);let j;t[74]===i.draft.notifyAll?j=t[75]:(j=(0,Z.jsx)(s,{value:`all`,children:i.draft.notifyAll}),t[74]=i.draft.notifyAll,t[75]=j);let M;t[76]===i.draft.notifyAttention?M=t[77]:(M=(0,Z.jsx)(s,{value:`attention`,children:i.draft.notifyAttention}),t[76]=i.draft.notifyAttention,t[77]=M);let N;t[78]===i.draft.notifyNone?N=t[79]:(N=(0,Z.jsx)(s,{value:`none`,children:i.draft.notifyNone}),t[78]=i.draft.notifyNone,t[79]=N);let P;t[80]!==n.notificationPolicy||t[81]!==ne||t[82]!==j||t[83]!==M||t[84]!==N?(P=(0,Z.jsxs)(o,{className:lt,value:n.notificationPolicy,onChange:ne,children:[j,M,N]}),t[80]=n.notificationPolicy,t[81]=ne,t[82]=j,t[83]=M,t[84]=N,t[85]=P):P=t[85];let re;t[86]!==i.draft.notifications||t[87]!==P?(re=(0,Z.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.draft.notifications,P]}),t[86]=i.draft.notifications,t[87]=P,t[88]=re):re=t[88];let F;return t[89]!==ee||t[90]!==O||t[91]!==p||t[92]!==k||t[93]!==A||t[94]!==re||t[95]!==g||t[96]!==y||t[97]!==b?(F=(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4`,children:[p,g,y,b,ee,O,k,A,re]}),t[89]=ee,t[90]=O,t[91]=p,t[92]=k,t[93]=A,t[94]=re,t[95]=g,t[96]=y,t[97]=b,t[98]=F):F=t[98],F}function dt(e){return(0,Z.jsx)(s,{value:e.id,children:e.name},e.id)}function ft(e,t){return t.reduce((t,n)=>n.automationId===e&&(!t||n.createdAtMs>t.createdAtMs)?n:t,void 0)}function pt(e,t){let n=ft(e.id,t),r=e.state.lastRunAtMs&&(!n||e.state.lastRunAtMs>n.createdAtMs)?e.state.lastRunStatus:n?.status??e.state.lastRunStatus;return r===`failed`||r===`timeout`}function mt(e,t,n){return e?We(e,n):t.never}function ht(e,t){return e.kind===`workflow`?t.action.workflowWithId.replace(`{id}`,e.workflowId):e.kind===`browser_automation`?`Browser automation: ${e.automationId}`:e.agentId?t.action.agentWithId.replace(`{id}`,e.agentId):t.action.agent}function gt(e){return e.safety?.mode??`auto_apply`}function _t(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 vt(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 yt(e){return e.status===`running`||e.status===`queued`||e.status===`cancelling`}function bt(e){return e.status===`failed`||e.status===`timeout`}function xt(e,t){return e.action.kind===`agent`?e.action.instruction:e.action.kind===`workflow`&&e.action.goal?.trim()||ht(e.action,t)}function St(e){return(e.description?.match(/\[managed-by=([^\]]+)\]/))?.[1]?.trim()||null}function Ct(e){return!!St(e)}function wt(e){return e.description?.replace(/\s*\[managed-by=[^\]]+\]\s*/g,` `).trim()??``}function Tt(e){return yt(e)?0:bt(e)?1:e.status===`succeeded`?2:3}function Et(e){return[...e].sort((e,t)=>{let n=Tt(e)-Tt(t);return n===0?t.createdAtMs-e.createdAtMs:n})}function Dt(){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)(w,{className:`h-4 w-36`}),(0,Z.jsx)(w,{className:`h-3 w-56 max-w-full`})]}),(0,Z.jsx)(w,{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(Ot)})]}),e[1]=n):n=e[1];let r,i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(w,{className:`h-4 w-32`}),i=(0,Z.jsx)(w,{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)(w,{className:`h-12 rounded-lg`}),(0,Z.jsx)(w,{className:`h-12 rounded-lg`}),(0,Z.jsx)(w,{className:`h-12 rounded-lg`})]})]})]})}),e[4]=a):a=e[4],a}function Ot(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)(w,{className:`size-4 rounded-full`}),(0,Z.jsx)(w,{className:`h-4 w-32`}),(0,Z.jsx)(w,{className:`h-5 w-20 rounded-full`})]}),(0,Z.jsx)(w,{className:`mt-3 h-4 w-full`}),(0,Z.jsx)(w,{className:`mt-2 h-4 w-3/5`})]}),(0,Z.jsx)(w,{className:`h-8 w-24 rounded-md`})]})},t)}function kt({projectId:e,embedded:t=!1,title:n,subtitle:r}){let a=h(e=>e.language),c=g(a),l=c.automations,u=c.cron,d=L(e=>e.setPageHeader),w=L(e=>e.clearPageHeader),[E,O]=i(),ne=E.get(`run`)?.trim()??``,j=E.get(`automation`)?.trim()??``,N=E.get(`draft`)?.trim()??``,P=E.get(`action`)?.trim()??``,re=E.get(`projectId`)?.trim()??``,I=e?.trim()||re,ae=!!e?.trim(),ce=E.get(`autogenerate`)===`1`,le=(0,K.useRef)(``),z=E.get(`status`),B=z===`active`||z===`paused`||z===`system`||z===`attention`?z:`all`,V=E.get(`q`)??``,H=e=>O(t=>{let n=new URLSearchParams(t);return e===`all`?n.delete(`status`):n.set(`status`,e),n.delete(`automation`),n}),pe=e=>O(t=>{let n=new URLSearchParams(t);return e?n.set(`q`,e):n.delete(`q`),n.delete(`automation`),n},{replace:!0}),[U,me]=(0,K.useState)(null),[ge,W]=(0,K.useState)(!1),[_e,G]=(0,K.useState)(`blank`),[be,xe]=(0,K.useState)(null),[Se,Ce]=(0,K.useState)(!1),[q,we]=(0,K.useState)(Ze),[Te,J]=(0,K.useState)(null),[Ee,De]=(0,K.useState)(null),[Oe,ke]=(0,K.useState)(!1),[Y,X]=(0,K.useState)(null),[Ae,je]=(0,K.useState)(``),[Me,Ne]=(0,K.useState)(null),[Pe,Fe]=(0,K.useState)(!1),[Ie,Le]=(0,K.useState)(!1),[Re,ze]=(0,K.useState)(I),[Be,Ve]=(0,K.useState)(`new_session`),[He,Ue]=(0,K.useState)(`attention`),[We,Ge]=(0,K.useState)(null),[Ke,qe]=(0,K.useState)(!1),[Ye,Xe]=(0,K.useState)(!1),[Qe,et]=(0,K.useState)(!1),[tt,nt]=(0,K.useState)(null),rt=S([`automations`,I],()=>R.list(I?{projectId:I}:void 0),{refreshInterval:15e3}),it=S([`automation-runs`,I],()=>R.runs(50,void 0,I?{projectId:I}:void 0),{refreshInterval:1e4}),lt=S(Y?[`automation-history`,Y,I]:null,()=>R.runs(50,Y,I?{projectId:I}:void 0),{refreshInterval:1e4}),dt=S(Ee?`automation-run-events:${Ee}`:null,()=>R.runEvents(Ee),{refreshInterval:5e3}),mt=S(`automation-workflow-definitions`,fe),ht=S(`automation-browser-automations`,()=>ve.list()),gt=S(`automation-chat-agents`,se),_t=S(`automation-projects`,()=>A({sortBy:`name`,sortOrder:`asc`,limit:200})),vt=rt.isLoading&&!rt.data||it.isLoading&&!it.data,bt=rt.data?.automations??[],St=(0,K.useMemo)(()=>Et(it.data?.runs??[]),[it.data?.runs]),Tt=(0,K.useMemo)(()=>bt.filter(e=>!Ct(e)),[bt]),Ot=(0,K.useMemo)(()=>bt.filter(Ct),[bt]),kt=(0,K.useMemo)(()=>new Set(Ot.map(e=>e.id)),[Ot]),Mt=(0,K.useMemo)(()=>St.filter(e=>!kt.has(e.automationId)),[St,kt]),Nt=(0,K.useMemo)(()=>St.find(e=>e.id===Ee)??lt.data?.runs.find(e=>e.id===Ee)??null,[St,Ee,lt.data]),Pt=(0,K.useMemo)(()=>bt.find(e=>e.id===Y)??null,[bt,Y]),It=(0,K.useMemo)(()=>bt.find(e=>e.id===be)??null,[bt,be]),Lt=(0,K.useMemo)(()=>[...lt.data?.runs??St].filter(e=>e.automationId===Y).sort((e,t)=>t.createdAtMs-e.createdAtMs),[St,Y,lt.data]),Rt=dt.data?.events??[],zt=(0,K.useMemo)(()=>Mt.filter(e=>!yt(e)&&e.readAtMs==null),[Mt]),Ht=V.trim().toLocaleLowerCase(),Ut=(0,K.useMemo)(()=>(B===`system`?Ot:Tt).filter(e=>B===`attention`&&!pt(e,Mt)||B===`active`&&!e.enabled||B===`paused`&&e.enabled?!1:Ht?[e.name,wt(e),xt(e,l),Je(e.trigger,l,u,a)].some(e=>e.toLocaleLowerCase().includes(Ht)):!0),[u,B,l,a,Ht,Ot,Tt,Mt]),Wt=(0,K.useMemo)(()=>mt.data??[],[mt.data]),Gt=(0,K.useMemo)(()=>(ht.data?.automations??[]).filter(e=>e.enabled),[ht.data]),Kt=gt.data?.items??[],qt=_t.data?.items??[],Jt=(0,K.useMemo)(()=>Wt.find(e=>e.id===q.workflowId.trim())??null,[q.workflowId,Wt]),Zt=(0,K.useMemo)(()=>Gt.find(e=>e.id===q.browserAutomationId.trim())??null,[Gt,q.browserAutomationId]),Qt=q.actionMode===`workflow`&&(!q.workflowId.trim()||Wt.length>0&&!Wt.some(e=>e.id===q.workflowId)),$t=q.actionMode===`workflow`&&Jt?!he(Jt,q.workflowInput,q.workflowInputValid).valid:!1,$=!!q.name.trim()&&(q.triggerMode!==`once`||Number.isFinite(new Date(q.onceAt).getTime())&&(!!It||new Date(q.onceAt).getTime()>Date.now()))&&(![`daily`,`weekly`].includes(q.triggerMode)||/^(?:[01]\d|2[0-3]):[0-5]\d$/.test(q.time))&&(q.triggerMode!==`event`||!!q.eventType.trim()&&at(q.eventPayloadMatch))&&(q.actionMode===`workflow`?!Qt&&!$t:q.actionMode===`browser_automation`?Zt!==null&&ye(Zt,q.browserAutomationInputs):!!q.instruction.trim()),en=(0,K.useMemo)(()=>ct(l),[l]),tn=Tt.filter(e=>pt(e,Mt));(0,K.useEffect)(()=>{if(Ut.length===0){X(null);return}if(j&&Ut.some(e=>e.id===j)){X(j);return}Y&&Ut.some(e=>e.id===Y)||X(Ut[0].id)},[j,Ut,Y]);let nn=(0,K.useCallback)(async()=>{await Promise.all([rt.mutate(),it.mutate(),lt.mutate(),dt.mutate()])},[rt.mutate,dt.mutate,it.mutate,lt.mutate]),rn=(0,K.useCallback)(e=>{if(ae){X(null),De(null);return}O(t=>{let n=new URLSearchParams(t);return e?n.set(`projectId`,e):n.delete(`projectId`),n.delete(`automation`),n.delete(`run`),n}),X(null),De(null)},[ae,O]);(0,K.useEffect)(()=>{ae&&(ze(I),we(e=>e.projectId===I?e:{...e,projectId:I}))},[I,ae]);let an=(0,K.useCallback)(e=>{if(xe(null),Ce(!1),J(null),G(e),W(!0),e===`blank`){we({...Ze,projectId:I});return}je(``),Ne(null),Le(!1),ze(I),Ve(`new_session`),Ue(`attention`)},[I]),on=e=>{me(e),we({...e.form,projectId:I}),xe(null),Ce(!1),J(null),G(`quick`),W(!0)},sn=(0,K.useCallback)(e=>{we(ot(e,Wt)),xe(e.id),Ce(!1),X(null),G(`blank`),W(!0)},[Wt]),cn=(0,K.useCallback)(()=>{Me&&(we({...ot(Me.automation,Wt),projectId:Re,conversationMode:Be,notificationPolicy:He}),xe(null),Ce(!0),G(`blank`))},[Me,Be,He,Re,Wt]),ln=(0,K.useCallback)(async()=>{et(!0),J(null);try{await nn()}catch(e){J(e instanceof Error?e.message:String(e))}finally{et(!1)}},[l.feedback.actionFailed,nn]);(0,K.useEffect)(()=>{let e=bt.find(e=>e.id===j);!e||!Ct(e)||B===`system`||O(e=>{let t=new URLSearchParams(e);return t.set(`status`,`system`),t},{replace:!0})},[j,bt,B,O]),(0,K.useEffect)(()=>{P===`create`&&(an(`blank`),O(e=>{let t=new URLSearchParams(e);return t.delete(`action`),t},{replace:!0}))},[P,an,O]),(0,K.useEffect)(()=>{if(!N)return;let e=`${a}:${ce?`auto`:`seed`}:${N}`;le.current!==e&&(le.current=e,je(N),Ne(null),Le(!1),ze(I),G(`draft`),W(!0),O(e=>{let t=new URLSearchParams(e);return t.delete(`draft`),t.delete(`autogenerate`),t},{replace:!0}),ce&&(J(null),Fe(!0),R.draft({prompt:N,language:a}).then(e=>{Ne(e.draft),Le(!1)}).catch(e=>{J(e instanceof Error?e.message:String(e))}).finally(()=>{Fe(!1)})))},[ce,N,a,I,O]);let un=(0,K.useCallback)(e=>{let t=St.find(t=>t.id===e)??lt.data?.runs.find(t=>t.id===e);if(!t||yt(t)||t.readAtMs!=null)return;let n=Date.now();it.mutate(t=>t&&{...t,runs:t.runs.map(t=>t.id===e?{...t,readAtMs:n}:t)},!1),lt.mutate(t=>t&&{...t,runs:t.runs.map(t=>t.id===e?{...t,readAtMs:n}:t)},!1),R.markRunRead(e).catch(e=>{J(e instanceof Error?e.message:String(e)),it.mutate(),lt.mutate()})},[St,it.mutate,lt.data,lt.mutate]),dn=(0,K.useCallback)(e=>{un(e),De(e),ke(!0),O(t=>{let n=new URLSearchParams(t);return n.set(`run`,e),n},{replace:!0})},[un,O]),fn=(0,K.useCallback)(e=>{X(e);let t=ft(e,St);O(t=>{let n=new URLSearchParams(t);return n.set(`automation`,e),n},{replace:!0}),t&&t.readAtMs==null&&!yt(t)&&un(t.id)},[un,St,O]);(0,K.useEffect)(()=>{ne&&(un(ne),De(ne),ke(!0))},[un,ne]),(0,K.useEffect)(()=>{Ge(null),Xe(!1)},[Ee]);async function pn(){if(J(null),q.triggerMode===`once`&&!It&&new Date(q.onceAt).getTime()<=Date.now()){J(l.experience.futureTime);return}if(!(!$||tt)&&!(_e===`quick`&&U?.requiresProject&&!q.projectId)){if(Se&&Me){nt(`draft:edit`);try{let e=$e(q,Jt),{simulation:t}=await R.simulate(e);Ne({...Me,automation:e,simulation:t}),ze(q.projectId),Ve(q.conversationMode),Ue(q.notificationPolicy),Le(!1),Ce(!1),G(`draft`)}catch(e){J(e instanceof Error?e.message:String(e))}finally{nt(null)}return}if(It){let e=It.id;await mn(`automation:${e}:edit`,()=>R.update(e,st(It,q,Jt)))&&(W(!1),xe(null),X(e));return}nt(`automation:create`);try{let e=$e(q,Jt),{automation:t}=await R.create(e);we(Ze),W(!1),O(e=>{let n=new URLSearchParams(e);return n.delete(`status`),n.delete(`q`),n.delete(`run`),n.set(`automation`,t.id),ae||(t.projectId?n.set(`projectId`,t.projectId):n.delete(`projectId`)),n}),await nn(),X(t.id)}catch(e){J(e instanceof Error?e.message:String(e))}finally{nt(null)}}}async function mn(e,t){J(null),nt(e);try{return await t(),await nn(),!0}catch(e){return J(e instanceof Error?e.message:String(e)),!1}finally{nt(null)}}async function hn(){await mn(`runs:read-all`,()=>R.markAllRunsRead(I||void 0))}async function gn(){let e=Ae.trim();if(e){J(null),Fe(!0);try{Ne((await R.draft({prompt:e,language:a})).draft),Le(!1)}catch(e){J(e instanceof Error?e.message:String(e))}finally{Fe(!1)}}}async function _n(){if(!Me)return;let e=``,t=``;await mn(`draft:publish`,async()=>{let{automation:n}=await R.create({...Me.automation,...Re?{projectId:Re}:{projectId:void 0},conversationMode:Be,notificationPolicy:He});Ne(null),je(``),Le(!1),W(!1),H(`all`),pe(``),e=n.id,t=n.projectId??``})&&e&&(rn(t),X(e))}async function vn(){if(!Me)return;let e=``,t=``,n=``;await mn(`draft:test`,async()=>{let{automation:r}=await R.create({...Me.automation,...Re?{projectId:Re}:{projectId:void 0},conversationMode:Be,notificationPolicy:He,enabled:!1}),{run:i}=await R.runNow(r.id);e=r.id,t=r.projectId??``,n=i.id,Ne(null),je(``),Le(!1),W(!1),H(`all`),pe(``)})&&e&&n&&(rn(t),X(e),dn(n))}async function yn(e){J(null),qe(!0),Ge(null),Xe(!1);try{Ge((await R.repairDraft(e.id,{language:a})).repair)}catch(e){J(e instanceof Error?e.message:String(e))}finally{qe(!1)}}async function bn(e){We&&await mn(`run:${e.id}:repair`,async()=>{await R.update(e.automationId,We.patch),Ge(null),Xe(!1)})}let xn=(0,K.useMemo)(()=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(F,{className:`size-9 shrink-0 p-0`,loading:Qe,label:l.refresh,onClick:ln}),(0,Z.jsxs)(C,{variant:`primary`,onClick:()=>an(`draft`),children:[(0,Z.jsx)(f,{className:`size-4`}),l.new]})]}),[l.new,l.refresh,an,Qe,ln]);return(0,K.useLayoutEffect)(()=>{if(!t)return d({startExtra:null,main:(0,Z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:l.title}),end:xn}),()=>w()},[w,t,xn,l.title,d]),(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`:`mx-auto max-w-[96rem] px-4 py-7 sm:px-6 lg:px-8 lg:py-9`),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)(k,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n||l.title})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:r||l.subtitle})]}),xn]}):null,Te||rt.error||it.error?(0,Z.jsx)(`div`,{role:`alert`,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:Te||l.feedback.actionFailed}):null,!vt&&!rt.error&&Tt.length===0&&B!==`system`?(0,Z.jsxs)(`section`,{className:`rounded-xl border border-edge-subtle bg-surface-base p-6`,children:[(0,Z.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:l.experience.scenes}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.experience.scenesDescription}),(0,Z.jsx)(At,{templates:en,labels:l,onSelect:on}),(0,Z.jsx)(C,{className:`mt-4`,variant:`ghost`,onClick:()=>an(`draft`),children:l.experience.custom})]}):null,!vt&&tn.length>0&&B!==`system`?(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>H(`attention`),className:`flex items-center gap-3 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-3 text-left focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Z.jsx)(de,{className:`size-4 shrink-0 text-red-700 dark:text-red-300`,"aria-hidden":!0}),(0,Z.jsxs)(`span`,{className:`min-w-0 text-sm text-fg`,children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[l.experience.executionIssues,` · `,tn.length]}),(0,Z.jsx)(`span`,{className:`ml-2 text-fg-muted`,children:l.experience.issuesDescription})]})]}):null,vt?(0,Z.jsx)(Dt,{}):Tt.length>0||B===`system`?(0,Z.jsxs)(`section`,{className:`grid min-h-0 items-start gap-4 xl:grid-cols-[minmax(18rem,0.8fr)_minmax(0,1.5fr)]`,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:[ae?null:(0,Z.jsxs)(o,{"aria-label":l.filters.project,className:Q,value:I,onChange:e=>rn(e.target.value),children:[(0,Z.jsx)(s,{value:``,children:l.filters.allProjects}),qt.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`,!ae&&`mt-2`),children:[(0,Z.jsx)(ue,{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:V,onChange:e=>pe(e.target.value),placeholder:l.filters.search,"aria-label":l.filters.search})]}),(0,Z.jsxs)(`nav`,{className:`mt-3 flex flex-wrap items-center gap-1`,"aria-label":l.filters.status,children:[[{id:`all`,label:l.filters.all},{id:`active`,label:l.filters.active},{id:`paused`,label:l.paused},{id:`attention`,label:l.experience.executionIssues}].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`,B===e.id&&`bg-surface-hover text-fg`),onClick:()=>H(e.id),"aria-pressed":B===e.id,children:e.label},e.id)),(0,Z.jsxs)(oe,{children:[(0,Z.jsx)(ie,{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`,B===`system`&&`bg-surface-hover text-fg`),"aria-label":l.system.title,children:(0,Z.jsx)(T,{className:`size-4`})})}),(0,Z.jsx)(M,{children:(0,Z.jsx)(D,{align:`end`,className:`z-70 min-w-40 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:(0,Z.jsxs)(te,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>H(`system`),children:[l.system.title,` `,Ot.length]})})})]})]}),zt.length>0&&B!==`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:[l.filters.unread,` · `,zt.length]}),(0,Z.jsx)(`button`,{type:`button`,className:`font-medium hover:underline`,disabled:tt===`runs:read-all`,onClick:()=>void hn(),children:l.filters.markAllRead})]}):null]}),(0,Z.jsx)(Ft,{automations:Ut,runs:B===`system`?St:Mt,labels:l,cronLabels:u,language:a,selectedAutomationId:Y,onOpenDetails:fn})]}),Pt?(0,Z.jsx)(Vt,{automation:Pt,runs:Lt,runsLoading:lt.isLoading,runsError:lt.error?l.feedback.actionFailed:void 0,labels:l,cronLabels:u,language:a,projects:qt,busyAction:tt,onEdit:sn,onSelectRun:dn,onAction:mn},Pt.id):(0,Z.jsx)(Yt,{icon:(0,Z.jsx)(k,{className:`size-5`}),title:l.empty.filtered})]}):null,!vt&&Tt.length>0?(0,Z.jsx)(`div`,{children:(0,Z.jsxs)(C,{variant:`ghost`,onClick:()=>an(`draft`),children:[(0,Z.jsx)(f,{className:`size-4`,"aria-hidden":!0}),l.experience.discover]})}):null]}),(0,Z.jsx)(x,{open:ge,onOpenChange:e=>{W(e),e||(xe(null),Ce(!1))},children:(0,Z.jsxs)(y,{children:[(0,Z.jsx)(_,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(b,{className:`xopc-dialog-content 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)(ee,{className:`text-base font-semibold text-fg`,children:_e===`draft`?l.draft.title:It?l.editTitle:Se?l.draft.editTitle:l.createTitle}),(0,Z.jsx)(v,{asChild:!0,children:(0,Z.jsx)(C,{variant:`ghost`,"aria-label":l.close,children:(0,Z.jsx)(p,{className:`size-4`})})})]}),Te?(0,Z.jsx)(`p`,{role:`alert`,className:`px-5 py-2 text-sm text-red-700 dark:text-red-300`,children:Te}):null,_e===`draft`?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,Z.jsx)(jt,{labels:l,prompt:Ae,draft:Me,loading:Pe,approved:Ie,publishBusy:tt===`draft:publish`,testBusy:tt===`draft:test`,templates:en,projects:qt,projectId:Re,conversationMode:Be,notificationPolicy:He,onPromptChange:je,onGenerate:gn,onEdit:cn,onPublish:_n,onTest:vn,onProjectChange:ze,onConversationModeChange:Ve,onNotificationPolicyChange:Ue,projectLocked:ae,onApprovedChange:Le,onDiscard:()=>{Ne(null),Le(!1)},onTemplateSelect:e=>{on(e),we({...e.form,projectId:Re})},onOpenAdvanced:()=>{we({...Ze,projectId:Re,conversationMode:Be,notificationPolicy:He}),G(`blank`)}})}):(0,Z.jsxs)(Z.Fragment,{children:[_e===`quick`&&U?(0,Z.jsx)(ut,{form:q,setForm:we,labels:l,projects:qt,projectLocked:ae,source:U.source,requiresProject:U.requiresProject}):(0,Z.jsx)(Xt,{form:q,labels:l,setForm:we,projects:qt,workflowDefinitions:Wt,selectedWorkflow:Jt,workflowsLoading:mt.isLoading,browserAutomations:Gt,selectedBrowserAutomation:Zt,browserAutomationsLoading:ht.isLoading,agentOptions:Kt,agentsLoading:gt.isLoading,language:a,projectLocked:ae}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-edge px-5 py-4`,children:[_e===`quick`?(0,Z.jsx)(C,{variant:`ghost`,onClick:()=>G(`blank`),children:l.draft.advancedCreate}):null,Se?(0,Z.jsx)(C,{variant:`ghost`,onClick:()=>{Ce(!1),G(`draft`)},children:l.cancel}):(0,Z.jsx)(v,{asChild:!0,children:(0,Z.jsx)(C,{variant:`ghost`,children:l.cancel})}),(0,Z.jsx)(C,{variant:`primary`,onClick:pn,disabled:!$||!!tt||_e===`quick`&&!!U?.requiresProject&&!q.projectId,children:tt===`automation:create`||tt===`draft:edit`||It&&tt===`automation:${It.id}:edit`?l.feedback.working:It||Se?l.save:l.experience.createEnabled})]})]})]})]})}),(0,Z.jsx)(x,{open:Oe&&!!Nt,onOpenChange:e=>{ke(e),!e&&O(e=>{let t=new URLSearchParams(e);return t.delete(`run`),t},{replace:!0})},children:(0,Z.jsxs)(y,{children:[(0,Z.jsx)(_,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(b,{className:`xopc-dialog-content 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)(ee,{className:`truncate text-base font-semibold text-fg`,children:Nt?.automationName??l.dashboard.result}),(0,Z.jsx)(v,{asChild:!0,children:(0,Z.jsx)(C,{variant:`ghost`,"aria-label":l.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)(Bt,{className:`rounded-none border-0`,run:Nt,events:Rt,labels:l,cronLabels:u,language:a,loading:dt.isLoading,repairDraft:We,repairLoading:Ke,repairApproved:Ye,busyAction:tt,onRepairApprovedChange:Xe,onSuggestRepair:yn,onApplyRepair:bn})})]})]})})]})}function At(e){let t=(0,xe.c)(9),{templates:n,labels:r,onSelect:i}=e,a;if(t[0]!==r||t[1]!==i||t[2]!==n){let e;t[4]!==r||t[5]!==i?(e=e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded-lg border border-edge-subtle bg-surface-panel p-4 text-left hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Z.jsx)(O,{className:`mb-3 size-4 text-accent-fg`,"aria-hidden":!0}),(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.description}),(0,Z.jsxs)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:[r.experience.source,`: `,e.source]})]},e.name),t[4]=r,t[5]=i,t[6]=e):e=t[6],a=n.map(e),t[0]=r,t[1]=i,t[2]=n,t[3]=a}else a=t[3];let o;return t[7]===a?o=t[8]:(o=(0,Z.jsx)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:a}),t[7]=a,t[8]=o),o}function jt(e){let t=(0,xe.c)(110),{labels:n,prompt:r,draft:i,loading:a,approved:c,publishBusy:l,testBusy:u,templates:d,projects:f,projectId:p,conversationMode:h,notificationPolicy:g,onPromptChange:_,onGenerate:v,onEdit:y,onPublish:b,onTest:ee,onProjectChange:x,onConversationModeChange:S,onNotificationPolicyChange:w,onApprovedChange:T,onDiscard:E,onTemplateSelect:te,onOpenAdvanced:D,projectLocked:O}=e,k=l===void 0?!1:l,A=u===void 0?!1:u,ne=O===void 0?!1:O,M=!!(i&&i.simulation.requiredConfirmations.length>0),N;t[0]!==i||t[1]!==n.draft.advancedCreate||t[2]!==n.draft.suggestions||t[3]!==n.draft.suggestionsDescription||t[4]!==n.experience||t[5]!==D||t[6]!==te||t[7]!==d?(N=i?null:(0,Z.jsxs)(`div`,{className:`mb-5 border-b border-edge-subtle pb-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)(C,{variant:`ghost`,onClick:D,children:n.draft.advancedCreate})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:d.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`focus-visible:ring-2 focus-visible:ring-accent rounded-lg border border-edge-subtle bg-surface-panel p-3 text-left hover:bg-surface-hover`,onClick:()=>te(e),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}),(0,Z.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.experience.source,`: `,e.source]})]},e.name))})]}),t[0]=i,t[1]=n.draft.advancedCreate,t[2]=n.draft.suggestions,t[3]=n.draft.suggestionsDescription,t[4]=n.experience,t[5]=D,t[6]=te,t[7]=d,t[8]=N):N=t[8];let P;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(ce,{className:`size-4 text-accent`}),t[9]=P):P=t[9];let F;t[10]===n.draft.title?F=t[11]:(F=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[P,n.draft.title]}),t[10]=n.draft.title,t[11]=F);let I;t[12]===n.draft.subtitle?I=t[13]:(I=(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:n.draft.subtitle}),t[12]=n.draft.subtitle,t[13]=I);let L;t[14]!==F||t[15]!==I?(L=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[F,I]}),t[14]=F,t[15]=I,t[16]=L):L=t[16];let ie;t[17]!==a||t[18]!==r?(ie=a||!r.trim(),t[17]=a,t[18]=r,t[19]=ie):ie=t[19];let ae;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Z.jsx)(ce,{className:`size-4`}),t[20]=ae):ae=t[20];let oe=a?n.draft.generating:n.draft.generate,R;t[21]!==v||t[22]!==oe||t[23]!==ie?(R=(0,Z.jsxs)(C,{variant:`primary`,onClick:v,disabled:ie,children:[ae,oe]}),t[21]=v,t[22]=oe,t[23]=ie,t[24]=R):R=t[24];let se;t[25]!==R||t[26]!==L?(se=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[L,R]}),t[25]=R,t[26]=L,t[27]=se):se=t[27];let le;t[28]===_?le=t[29]:(le=e=>_(e.target.value),t[28]=_,t[29]=le);let z;t[30]!==n.draft.placeholder||t[31]!==n.draft.title||t[32]!==r||t[33]!==le?(z=(0,Z.jsx)(`textarea`,{"aria-label":n.draft.title,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[30]=n.draft.placeholder,t[31]=n.draft.title,t[32]=r,t[33]=le,t[34]=z):z=t[34];let ue=ne?`sm:grid-cols-2`:`sm:grid-cols-3`,B;t[35]===ue?B=t[36]:(B=m(`mt-3 grid gap-3`,ue),t[35]=ue,t[36]=B);let de;t[37]!==n.draft.noProject||t[38]!==n.draft.project||t[39]!==x||t[40]!==p||t[41]!==ne||t[42]!==f?(de=ne?null:(0,Z.jsx)($,{label:n.draft.project,children:(0,Z.jsxs)(o,{className:Q,value:p,onChange:e=>x(e.target.value),children:[(0,Z.jsx)(s,{value:``,children:n.draft.noProject}),f.map(Mt)]})}),t[37]=n.draft.noProject,t[38]=n.draft.project,t[39]=x,t[40]=p,t[41]=ne,t[42]=f,t[43]=de):de=t[43];let fe;t[44]===S?fe=t[45]:(fe=e=>S(e.target.value),t[44]=S,t[45]=fe);let V;t[46]===n.draft.newConversation?V=t[47]:(V=(0,Z.jsx)(s,{value:`new_session`,children:n.draft.newConversation}),t[46]=n.draft.newConversation,t[47]=V);let H;t[48]===n.draft.continuousConversation?H=t[49]:(H=(0,Z.jsx)(s,{value:`continuous`,children:n.draft.continuousConversation}),t[48]=n.draft.continuousConversation,t[49]=H);let pe;t[50]!==h||t[51]!==fe||t[52]!==V||t[53]!==H?(pe=(0,Z.jsxs)(o,{className:Q,value:h,onChange:fe,children:[V,H]}),t[50]=h,t[51]=fe,t[52]=V,t[53]=H,t[54]=pe):pe=t[54];let U;t[55]!==n.draft.conversation||t[56]!==pe?(U=(0,Z.jsx)($,{label:n.draft.conversation,children:pe}),t[55]=n.draft.conversation,t[56]=pe,t[57]=U):U=t[57];let me;t[58]===w?me=t[59]:(me=e=>w(e.target.value),t[58]=w,t[59]=me);let he;t[60]===n.draft.notifyAttention?he=t[61]:(he=(0,Z.jsx)(s,{value:`attention`,children:n.draft.notifyAttention}),t[60]=n.draft.notifyAttention,t[61]=he);let ge;t[62]===n.draft.notifyAll?ge=t[63]:(ge=(0,Z.jsx)(s,{value:`all`,children:n.draft.notifyAll}),t[62]=n.draft.notifyAll,t[63]=ge);let W;t[64]===n.draft.notifyNone?W=t[65]:(W=(0,Z.jsx)(s,{value:`none`,children:n.draft.notifyNone}),t[64]=n.draft.notifyNone,t[65]=W);let _e;t[66]!==g||t[67]!==me||t[68]!==he||t[69]!==ge||t[70]!==W?(_e=(0,Z.jsxs)(o,{className:Q,value:g,onChange:me,children:[he,ge,W]}),t[66]=g,t[67]=me,t[68]=he,t[69]=ge,t[70]=W,t[71]=_e):_e=t[71];let ve;t[72]!==n.draft.notifications||t[73]!==_e?(ve=(0,Z.jsx)($,{label:n.draft.notifications,children:_e}),t[72]=n.draft.notifications,t[73]=_e,t[74]=ve):ve=t[74];let ye;t[75]!==B||t[76]!==de||t[77]!==U||t[78]!==ve?(ye=(0,Z.jsxs)(`div`,{className:B,children:[de,U,ve]}),t[75]=B,t[76]=de,t[77]=U,t[78]=ve,t[79]=ye):ye=t[79];let G;t[80]!==c||t[81]!==i||t[82]!==n.draft.approval||t[83]!==n.draft.assumptions||t[84]!==n.draft.discard||t[85]!==n.draft.edit||t[86]!==n.draft.publish||t[87]!==n.draft.review||t[88]!==n.draft.risks||t[89]!==n.draft.safety||t[90]!==n.draft.testOnce||t[91]!==n.draft.testing||t[92]!==n.feedback||t[93]!==n.info||t[94]!==n.none||t[95]!==T||t[96]!==E||t[97]!==y||t[98]!==b||t[99]!==ee||t[100]!==k||t[101]!==M||t[102]!==A?(G=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)(Jt,{label:n.info.when,value:i.simulation.triggerSummary}),(0,Z.jsx)(Jt,{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)(Nt,{title:n.draft.safety,items:[...i.simulation.safetyNotes,...i.simulation.requiredConfirmations],empty:n.none}),(0,Z.jsx)(Nt,{title:n.draft.assumptions,items:i.assumptions,empty:n.none}),(0,Z.jsx)(Nt,{title:n.draft.risks,items:i.risks,empty:n.none}),M?(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=>T(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)(C,{variant:`ghost`,onClick:E,children:n.draft.discard}),(0,Z.jsxs)(C,{variant:`secondary`,onClick:y,children:[(0,Z.jsx)(re,{className:`size-4`}),n.draft.edit]}),(0,Z.jsxs)(C,{variant:`secondary`,onClick:ee,disabled:A||k||M&&!c,children:[(0,Z.jsx)(j,{className:`size-4`}),A?n.draft.testing:n.draft.testOnce]}),(0,Z.jsx)(C,{variant:`primary`,onClick:b,disabled:k||M&&!c,children:k?n.feedback.working:n.draft.publish})]})]})]}):null,t[80]=c,t[81]=i,t[82]=n.draft.approval,t[83]=n.draft.assumptions,t[84]=n.draft.discard,t[85]=n.draft.edit,t[86]=n.draft.publish,t[87]=n.draft.review,t[88]=n.draft.risks,t[89]=n.draft.safety,t[90]=n.draft.testOnce,t[91]=n.draft.testing,t[92]=n.feedback,t[93]=n.info,t[94]=n.none,t[95]=T,t[96]=E,t[97]=y,t[98]=b,t[99]=ee,t[100]=k,t[101]=M,t[102]=A,t[103]=G):G=t[103];let be;return t[104]!==se||t[105]!==z||t[106]!==ye||t[107]!==G||t[108]!==N?(be=(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[N,se,z,ye,G]}),t[104]=se,t[105]=z,t[106]=ye,t[107]=G,t[108]=N,t[109]=be):be=t[109],be}function Mt(e){return(0,Z.jsx)(s,{value:e.id,children:e.name},e.id)}function Nt(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(Pt):(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 Pt(e){return(0,Z.jsxs)(`li`,{children:[`- `,e]},e)}function Ft(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)(k,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===i.empty.filtered?n=t[2]:(n=(0,Z.jsx)(Yt,{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(It),n=t.find(yt),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`),style:{contentVisibility:`auto`,containIntrinsicSize:`auto 130px`},"aria-current":s===e.id?`true`:void 0,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`:pt(e,t)?`bg-red-500`:e.enabled?`bg-emerald-500`:`bg-fg-subtle`)}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:e.name}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.enabled?i.enabled:i.paused}),l&&l.readAtMs==null&&!yt(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.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(`line-clamp-2`,l?.error&&`text-red-700 dark:text-red-300`),children:l?l.error||l.summary||i.status[l.status]:e.state.lastError||(e.state.lastRunStatus?i.status[e.state.lastRunStatus]:i.experience.noRuns)}),l?.status?(0,Z.jsx)(`span`,{className:m(`shrink-0 rounded-full px-1.5 py-0.5`,_t(l.status)),children:i.status[l.status]}):null]}),(0,Z.jsxs)(`div`,{className:`mt-2 space-y-1 pl-4 text-xs text-fg-muted`,children:[l?(0,Z.jsxs)(`div`,{children:[i.last,`: `,mt(l.createdAtMs,i,o)]}):null,(0,Z.jsx)(`div`,{children:e.enabled?`${i.next}: ${Ye(e,i,o)}`:i.paused}),(0,Z.jsx)(`div`,{children:Je(e.trigger,i,a,o)})]})]},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 It(e,t){return t.createdAtMs-e.createdAtMs}function Lt(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 Rt(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(`
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{h as i,t as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as o,r as s}from"./popover-select-DldSX8GX.js";import{t as c}from"./circle-check-C23XjkUj.js";import{t as l}from"./markdown-view-BIg7cei7.js";import{t as u}from"./git-branch-Dh9uxTot.js";import{t as d}from"./message-circle-Badhj-4D.js";import{t as f}from"./plus-Q2yW6OE7.js";import{t as p}from"./x-B_N4OPjy.js";import{t as m}from"./cn-JdwAhgNB.js";import{n as h}from"./locale-store-eliqUnBr.js";import{t as g}from"./messages-NYDOR8-j.js";import{a as _,n as v,o as y,r as b,s as ee,t as x}from"./dist-BGTk37IG.js";import{i as S}from"./vendor-swr-BIWyz7Rc.js";import{t as C}from"./button-CGlRPNzi.js";import{t as w}from"./skeleton-BwbyijEw.js";import{$l as T,$s as E,Dn as te,En as D,Eu as O,Hs as k,Ia as A,Ku as ne,Lc as j,On as M,Su as N,Uc as P,Vc as re,Xi as F,fn as I,ho as L,jn as ie,kc as ae,kn as oe,l as R,la as se,pc as ce,ul as le,vc as z,wc as ue,wu as B,xu as de,y as fe}from"./index-CEkw-fGy.js";import{a as V,i as H,o as pe,r as U}from"./cron-expression-GDPX4NxC.js";import{a as me,i as he,n as ge,r as W,t as _e}from"./workflow-run-setup-panel-CvayjHzR.js";import{i as ve,n as ye,r as G,t as be}from"./browser-automation-inputs-Cq4sIJt2.js";var K=e(t(),1),xe=n(),Se=V();function Ce(e,t,n){let r=new Date;return r.setHours(e,t,0,0),r.toLocaleTimeString(n,{hour:`numeric`,minute:`2-digit`})}function q(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 J(e){if(e.length!==2)return!1;let t=[...e].toSorted((e,t)=>e-t);return t[0]===0&&t[1]===6}function Ee(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=H(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=H(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?Ce(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&&J(s))return n.weekendsAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&s.length===1){let e=q(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=>q(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 De(e,t,n,r){let i=e.trim();return i?Ee(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):De(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,browserAutomationId:``,browserAutomationInputs:{},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=W(t,e.workflowInput),c=e.workflowInput.goal.trim()||e.workflowGoal.trim(),l=e.actionMode===`browser_automation`?`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_automation`?{kind:`browser_automation`,automationId:e.browserAutomationId.trim(),inputs:e.browserAutomationInputs}:{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_automation`?600:1800);return{...Ze,...n,name:e.name,description:e.description??``,projectId:e.projectId??``,actionMode:r.kind,agentId:r.kind===`browser_automation`?``:r.agentId??``,instruction:r.kind===`agent`?r.instruction:``,workflowId:r.kind===`workflow`?r.workflowId:``,workflowGoal:r.kind===`workflow`?r.goal??``:``,browserAutomationId:r.kind===`browser_automation`?r.automationId:``,browserAutomationInputs:r.kind===`browser_automation`?r.inputs??{}:{},workflowInput:{goal:r.kind===`workflow`?r.goal??``:``,argValues:i?ge(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_automation`&&r.action.kind===`browser_automation`&&(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}}}function ct(e){return[`reminder`,`brief`,`review`,`followUp`].map(t=>{let n=e.scenarios[t];return{...n,requiresProject:t===`followUp`,form:{...Ze,name:n.name,instruction:t===`reminder`?``:n.instruction,triggerMode:t===`reminder`?`once`:t===`review`?`weekly`:`daily`,time:t===`brief`?`08:30`:t===`review`?`17:00`:`09:00`,weekday:`5`,notificationPolicy:`all`}}})}var Z=r(),lt=`w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg focus-visible:outline-2 focus-visible:outline-accent`;function ut(e){let t=(0,xe.c)(99),{form:n,setForm:r,labels:i,projects:a,projectLocked:c,source:l,requiresProject:u}=e,d;t[0]===r?d=t[1]:(d=e=>r(t=>({...t,...e})),t[0]=r,t[1]=d);let f=d,p;t[2]!==i.experience.source||t[3]!==l?(p=(0,Z.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[i.experience.source,`: `,l]}),t[2]=i.experience.source,t[3]=l,t[4]=p):p=t[4];let m;t[5]===f?m=t[6]:(m=e=>f({name:e.target.value}),t[5]=f,t[6]=m);let h;t[7]!==n.name||t[8]!==m?(h=(0,Z.jsx)(`input`,{className:lt,value:n.name,onChange:m}),t[7]=n.name,t[8]=m,t[9]=h):h=t[9];let g;t[10]!==i.form.name||t[11]!==h?(g=(0,Z.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.form.name,h]}),t[10]=i.form.name,t[11]=h,t[12]=g):g=t[12];let _;t[13]===f?_=t[14]:(_=e=>f({instruction:e.target.value}),t[13]=f,t[14]=_);let v;t[15]!==n.instruction||t[16]!==_?(v=(0,Z.jsx)(`textarea`,{className:lt,rows:5,value:n.instruction,onChange:_}),t[15]=n.instruction,t[16]=_,t[17]=v):v=t[17];let y;t[18]!==i.info.task||t[19]!==v?(y=(0,Z.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.info.task,v]}),t[18]=i.info.task,t[19]=v,t[20]=y):y=t[20];let b;t[21]!==n.projectId||t[22]!==i.form.noProject||t[23]!==i.form.project||t[24]!==c||t[25]!==a||t[26]!==f?(b=!c&&(0,Z.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.form.project,(0,Z.jsxs)(o,{className:lt,value:n.projectId,onChange:e=>f({projectId:e.target.value}),children:[(0,Z.jsx)(s,{value:``,children:i.form.noProject}),a.map(dt)]})]}),t[21]=n.projectId,t[22]=i.form.noProject,t[23]=i.form.project,t[24]=c,t[25]=a,t[26]=f,t[27]=b):b=t[27];let ee;t[28]!==n.projectId||t[29]!==i.experience.projectRequired||t[30]!==u?(ee=u&&!n.projectId?(0,Z.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:i.experience.projectRequired}):null,t[28]=n.projectId,t[29]=i.experience.projectRequired,t[30]=u,t[31]=ee):ee=t[31];let x;t[32]===f?x=t[33]:(x=e=>f({triggerMode:e.target.value}),t[32]=f,t[33]=x);let S;t[34]===i.trigger.once?S=t[35]:(S=(0,Z.jsx)(s,{value:`once`,children:i.trigger.once}),t[34]=i.trigger.once,t[35]=S);let C;t[36]===i.trigger.daily?C=t[37]:(C=(0,Z.jsx)(s,{value:`daily`,children:i.trigger.daily}),t[36]=i.trigger.daily,t[37]=C);let w;t[38]===i.trigger.weekly?w=t[39]:(w=(0,Z.jsx)(s,{value:`weekly`,children:i.trigger.weekly}),t[38]=i.trigger.weekly,t[39]=w);let T;t[40]!==n.triggerMode||t[41]!==x||t[42]!==S||t[43]!==C||t[44]!==w?(T=(0,Z.jsxs)(o,{className:lt,value:n.triggerMode,onChange:x,children:[S,C,w]}),t[40]=n.triggerMode,t[41]=x,t[42]=S,t[43]=C,t[44]=w,t[45]=T):T=t[45];let E;t[46]!==i.form.trigger||t[47]!==T?(E=(0,Z.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.form.trigger,T]}),t[46]=i.form.trigger,t[47]=T,t[48]=E):E=t[48];let te;t[49]!==n.onceAt||t[50]!==n.time||t[51]!==n.triggerMode||t[52]!==i.form.onceAt||t[53]!==i.form.time||t[54]!==f?(te=n.triggerMode===`once`?(0,Z.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.form.onceAt,(0,Z.jsx)(`input`,{type:`datetime-local`,className:lt,value:n.onceAt,onChange:e=>f({onceAt:e.target.value})})]}):(0,Z.jsxs)(`div`,{className:`grid gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`span`,{children:i.form.time}),(0,Z.jsx)(pe,{value:n.time,onChange:e=>f({time:e}),ariaLabel:i.form.time})]}),t[49]=n.onceAt,t[50]=n.time,t[51]=n.triggerMode,t[52]=i.form.onceAt,t[53]=i.form.time,t[54]=f,t[55]=te):te=t[55];let D;t[56]!==n.triggerMode||t[57]!==n.weekday||t[58]!==i.form.day||t[59]!==i.weekdays||t[60]!==f?(D=n.triggerMode===`weekly`&&(0,Z.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.form.day,(0,Z.jsx)(o,{className:lt,value:n.weekday,onChange:e=>f({weekday:e.target.value}),children:[`sunday`,`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`].map((e,t)=>(0,Z.jsx)(s,{value:String(t),children:i.weekdays[e]},e))})]}),t[56]=n.triggerMode,t[57]=n.weekday,t[58]=i.form.day,t[59]=i.weekdays,t[60]=f,t[61]=D):D=t[61];let O;t[62]!==E||t[63]!==te||t[64]!==D?(O=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[E,te,D]}),t[62]=E,t[63]=te,t[64]=D,t[65]=O):O=t[65];let k;t[66]!==n.onceAt||t[67]!==n.triggerMode||t[68]!==i.experience.futureTime?(k=n.triggerMode===`once`&&n.onceAt&&new Date(n.onceAt).getTime()<=Date.now()?(0,Z.jsx)(`p`,{role:`status`,className:`text-sm text-red-700 dark:text-red-300`,children:i.experience.futureTime}):null,t[66]=n.onceAt,t[67]=n.triggerMode,t[68]=i.experience.futureTime,t[69]=k):k=t[69];let A;t[70]===i.experience.scheduleNote?A=t[71]:(A=(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.experience.scheduleNote}),t[70]=i.experience.scheduleNote,t[71]=A);let ne;t[72]===f?ne=t[73]:(ne=e=>f({notificationPolicy:e.target.value}),t[72]=f,t[73]=ne);let j;t[74]===i.draft.notifyAll?j=t[75]:(j=(0,Z.jsx)(s,{value:`all`,children:i.draft.notifyAll}),t[74]=i.draft.notifyAll,t[75]=j);let M;t[76]===i.draft.notifyAttention?M=t[77]:(M=(0,Z.jsx)(s,{value:`attention`,children:i.draft.notifyAttention}),t[76]=i.draft.notifyAttention,t[77]=M);let N;t[78]===i.draft.notifyNone?N=t[79]:(N=(0,Z.jsx)(s,{value:`none`,children:i.draft.notifyNone}),t[78]=i.draft.notifyNone,t[79]=N);let P;t[80]!==n.notificationPolicy||t[81]!==ne||t[82]!==j||t[83]!==M||t[84]!==N?(P=(0,Z.jsxs)(o,{className:lt,value:n.notificationPolicy,onChange:ne,children:[j,M,N]}),t[80]=n.notificationPolicy,t[81]=ne,t[82]=j,t[83]=M,t[84]=N,t[85]=P):P=t[85];let re;t[86]!==i.draft.notifications||t[87]!==P?(re=(0,Z.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.draft.notifications,P]}),t[86]=i.draft.notifications,t[87]=P,t[88]=re):re=t[88];let F;return t[89]!==ee||t[90]!==O||t[91]!==p||t[92]!==k||t[93]!==A||t[94]!==re||t[95]!==g||t[96]!==y||t[97]!==b?(F=(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4`,children:[p,g,y,b,ee,O,k,A,re]}),t[89]=ee,t[90]=O,t[91]=p,t[92]=k,t[93]=A,t[94]=re,t[95]=g,t[96]=y,t[97]=b,t[98]=F):F=t[98],F}function dt(e){return(0,Z.jsx)(s,{value:e.id,children:e.name},e.id)}function ft(e,t){return t.reduce((t,n)=>n.automationId===e&&(!t||n.createdAtMs>t.createdAtMs)?n:t,void 0)}function pt(e,t){let n=ft(e.id,t),r=e.state.lastRunAtMs&&(!n||e.state.lastRunAtMs>n.createdAtMs)?e.state.lastRunStatus:n?.status??e.state.lastRunStatus;return r===`failed`||r===`timeout`}function mt(e,t,n){return e?We(e,n):t.never}function ht(e,t){return e.kind===`workflow`?t.action.workflowWithId.replace(`{id}`,e.workflowId):e.kind===`browser_automation`?`Browser automation: ${e.automationId}`:e.agentId?t.action.agentWithId.replace(`{id}`,e.agentId):t.action.agent}function gt(e){return e.safety?.mode??`auto_apply`}function _t(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 vt(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 yt(e){return e.status===`running`||e.status===`queued`||e.status===`cancelling`}function bt(e){return e.status===`failed`||e.status===`timeout`}function xt(e,t){return e.action.kind===`agent`?e.action.instruction:e.action.kind===`workflow`&&e.action.goal?.trim()||ht(e.action,t)}function St(e){return(e.description?.match(/\[managed-by=([^\]]+)\]/))?.[1]?.trim()||null}function Ct(e){return!!St(e)}function wt(e){return e.description?.replace(/\s*\[managed-by=[^\]]+\]\s*/g,` `).trim()??``}function Tt(e){return yt(e)?0:bt(e)?1:e.status===`succeeded`?2:3}function Et(e){return[...e].sort((e,t)=>{let n=Tt(e)-Tt(t);return n===0?t.createdAtMs-e.createdAtMs:n})}function Dt(){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)(w,{className:`h-4 w-36`}),(0,Z.jsx)(w,{className:`h-3 w-56 max-w-full`})]}),(0,Z.jsx)(w,{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(Ot)})]}),e[1]=n):n=e[1];let r,i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(w,{className:`h-4 w-32`}),i=(0,Z.jsx)(w,{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)(w,{className:`h-12 rounded-lg`}),(0,Z.jsx)(w,{className:`h-12 rounded-lg`}),(0,Z.jsx)(w,{className:`h-12 rounded-lg`})]})]})]})}),e[4]=a):a=e[4],a}function Ot(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)(w,{className:`size-4 rounded-full`}),(0,Z.jsx)(w,{className:`h-4 w-32`}),(0,Z.jsx)(w,{className:`h-5 w-20 rounded-full`})]}),(0,Z.jsx)(w,{className:`mt-3 h-4 w-full`}),(0,Z.jsx)(w,{className:`mt-2 h-4 w-3/5`})]}),(0,Z.jsx)(w,{className:`h-8 w-24 rounded-md`})]})},t)}function kt({projectId:e,embedded:t=!1,title:n,subtitle:r}){let a=h(e=>e.language),c=g(a),l=c.automations,u=c.cron,d=L(e=>e.setPageHeader),w=L(e=>e.clearPageHeader),[E,O]=i(),ne=E.get(`run`)?.trim()??``,j=E.get(`automation`)?.trim()??``,N=E.get(`draft`)?.trim()??``,P=E.get(`action`)?.trim()??``,re=E.get(`projectId`)?.trim()??``,I=e?.trim()||re,ae=!!e?.trim(),ce=E.get(`autogenerate`)===`1`,le=(0,K.useRef)(``),z=E.get(`status`),B=z===`active`||z===`paused`||z===`system`||z===`attention`?z:`all`,V=E.get(`q`)??``,H=e=>O(t=>{let n=new URLSearchParams(t);return e===`all`?n.delete(`status`):n.set(`status`,e),n.delete(`automation`),n}),pe=e=>O(t=>{let n=new URLSearchParams(t);return e?n.set(`q`,e):n.delete(`q`),n.delete(`automation`),n},{replace:!0}),[U,me]=(0,K.useState)(null),[ge,W]=(0,K.useState)(!1),[_e,G]=(0,K.useState)(`blank`),[be,xe]=(0,K.useState)(null),[Se,Ce]=(0,K.useState)(!1),[q,we]=(0,K.useState)(Ze),[Te,J]=(0,K.useState)(null),[Ee,De]=(0,K.useState)(null),[Oe,ke]=(0,K.useState)(!1),[Y,X]=(0,K.useState)(null),[Ae,je]=(0,K.useState)(``),[Me,Ne]=(0,K.useState)(null),[Pe,Fe]=(0,K.useState)(!1),[Ie,Le]=(0,K.useState)(!1),[Re,ze]=(0,K.useState)(I),[Be,Ve]=(0,K.useState)(`new_session`),[He,Ue]=(0,K.useState)(`attention`),[We,Ge]=(0,K.useState)(null),[Ke,qe]=(0,K.useState)(!1),[Ye,Xe]=(0,K.useState)(!1),[Qe,et]=(0,K.useState)(!1),[tt,nt]=(0,K.useState)(null),rt=S([`automations`,I],()=>R.list(I?{projectId:I}:void 0),{refreshInterval:15e3}),it=S([`automation-runs`,I],()=>R.runs(50,void 0,I?{projectId:I}:void 0),{refreshInterval:1e4}),lt=S(Y?[`automation-history`,Y,I]:null,()=>R.runs(50,Y,I?{projectId:I}:void 0),{refreshInterval:1e4}),dt=S(Ee?`automation-run-events:${Ee}`:null,()=>R.runEvents(Ee),{refreshInterval:5e3}),mt=S(`automation-workflow-definitions`,fe),ht=S(`automation-browser-automations`,()=>ve.list()),gt=S(`automation-chat-agents`,se),_t=S(`automation-projects`,()=>A({sortBy:`name`,sortOrder:`asc`,limit:200})),vt=rt.isLoading&&!rt.data||it.isLoading&&!it.data,bt=rt.data?.automations??[],St=(0,K.useMemo)(()=>Et(it.data?.runs??[]),[it.data?.runs]),Tt=(0,K.useMemo)(()=>bt.filter(e=>!Ct(e)),[bt]),Ot=(0,K.useMemo)(()=>bt.filter(Ct),[bt]),kt=(0,K.useMemo)(()=>new Set(Ot.map(e=>e.id)),[Ot]),Mt=(0,K.useMemo)(()=>St.filter(e=>!kt.has(e.automationId)),[St,kt]),Nt=(0,K.useMemo)(()=>St.find(e=>e.id===Ee)??lt.data?.runs.find(e=>e.id===Ee)??null,[St,Ee,lt.data]),Pt=(0,K.useMemo)(()=>bt.find(e=>e.id===Y)??null,[bt,Y]),It=(0,K.useMemo)(()=>bt.find(e=>e.id===be)??null,[bt,be]),Lt=(0,K.useMemo)(()=>[...lt.data?.runs??St].filter(e=>e.automationId===Y).sort((e,t)=>t.createdAtMs-e.createdAtMs),[St,Y,lt.data]),Rt=dt.data?.events??[],zt=(0,K.useMemo)(()=>Mt.filter(e=>!yt(e)&&e.readAtMs==null),[Mt]),Ht=V.trim().toLocaleLowerCase(),Ut=(0,K.useMemo)(()=>(B===`system`?Ot:Tt).filter(e=>B===`attention`&&!pt(e,Mt)||B===`active`&&!e.enabled||B===`paused`&&e.enabled?!1:Ht?[e.name,wt(e),xt(e,l),Je(e.trigger,l,u,a)].some(e=>e.toLocaleLowerCase().includes(Ht)):!0),[u,B,l,a,Ht,Ot,Tt,Mt]),Wt=(0,K.useMemo)(()=>mt.data??[],[mt.data]),Gt=(0,K.useMemo)(()=>(ht.data?.automations??[]).filter(e=>e.enabled),[ht.data]),Kt=gt.data?.items??[],qt=_t.data?.items??[],Jt=(0,K.useMemo)(()=>Wt.find(e=>e.id===q.workflowId.trim())??null,[q.workflowId,Wt]),Zt=(0,K.useMemo)(()=>Gt.find(e=>e.id===q.browserAutomationId.trim())??null,[Gt,q.browserAutomationId]),Qt=q.actionMode===`workflow`&&(!q.workflowId.trim()||Wt.length>0&&!Wt.some(e=>e.id===q.workflowId)),$t=q.actionMode===`workflow`&&Jt?!he(Jt,q.workflowInput,q.workflowInputValid).valid:!1,$=!!q.name.trim()&&(q.triggerMode!==`once`||Number.isFinite(new Date(q.onceAt).getTime())&&(!!It||new Date(q.onceAt).getTime()>Date.now()))&&(![`daily`,`weekly`].includes(q.triggerMode)||/^(?:[01]\d|2[0-3]):[0-5]\d$/.test(q.time))&&(q.triggerMode!==`event`||!!q.eventType.trim()&&at(q.eventPayloadMatch))&&(q.actionMode===`workflow`?!Qt&&!$t:q.actionMode===`browser_automation`?Zt!==null&&ye(Zt,q.browserAutomationInputs):!!q.instruction.trim()),en=(0,K.useMemo)(()=>ct(l),[l]),tn=Tt.filter(e=>pt(e,Mt));(0,K.useEffect)(()=>{if(Ut.length===0){X(null);return}if(j&&Ut.some(e=>e.id===j)){X(j);return}Y&&Ut.some(e=>e.id===Y)||X(Ut[0].id)},[j,Ut,Y]);let nn=(0,K.useCallback)(async()=>{await Promise.all([rt.mutate(),it.mutate(),lt.mutate(),dt.mutate()])},[rt.mutate,dt.mutate,it.mutate,lt.mutate]),rn=(0,K.useCallback)(e=>{if(ae){X(null),De(null);return}O(t=>{let n=new URLSearchParams(t);return e?n.set(`projectId`,e):n.delete(`projectId`),n.delete(`automation`),n.delete(`run`),n}),X(null),De(null)},[ae,O]);(0,K.useEffect)(()=>{ae&&(ze(I),we(e=>e.projectId===I?e:{...e,projectId:I}))},[I,ae]);let an=(0,K.useCallback)(e=>{if(xe(null),Ce(!1),J(null),G(e),W(!0),e===`blank`){we({...Ze,projectId:I});return}je(``),Ne(null),Le(!1),ze(I),Ve(`new_session`),Ue(`attention`)},[I]),on=e=>{me(e),we({...e.form,projectId:I}),xe(null),Ce(!1),J(null),G(`quick`),W(!0)},sn=(0,K.useCallback)(e=>{we(ot(e,Wt)),xe(e.id),Ce(!1),X(null),G(`blank`),W(!0)},[Wt]),cn=(0,K.useCallback)(()=>{Me&&(we({...ot(Me.automation,Wt),projectId:Re,conversationMode:Be,notificationPolicy:He}),xe(null),Ce(!0),G(`blank`))},[Me,Be,He,Re,Wt]),ln=(0,K.useCallback)(async()=>{et(!0),J(null);try{await nn()}catch(e){J(e instanceof Error?e.message:String(e))}finally{et(!1)}},[l.feedback.actionFailed,nn]);(0,K.useEffect)(()=>{let e=bt.find(e=>e.id===j);!e||!Ct(e)||B===`system`||O(e=>{let t=new URLSearchParams(e);return t.set(`status`,`system`),t},{replace:!0})},[j,bt,B,O]),(0,K.useEffect)(()=>{P===`create`&&(an(`blank`),O(e=>{let t=new URLSearchParams(e);return t.delete(`action`),t},{replace:!0}))},[P,an,O]),(0,K.useEffect)(()=>{if(!N)return;let e=`${a}:${ce?`auto`:`seed`}:${N}`;le.current!==e&&(le.current=e,je(N),Ne(null),Le(!1),ze(I),G(`draft`),W(!0),O(e=>{let t=new URLSearchParams(e);return t.delete(`draft`),t.delete(`autogenerate`),t},{replace:!0}),ce&&(J(null),Fe(!0),R.draft({prompt:N,language:a}).then(e=>{Ne(e.draft),Le(!1)}).catch(e=>{J(e instanceof Error?e.message:String(e))}).finally(()=>{Fe(!1)})))},[ce,N,a,I,O]);let un=(0,K.useCallback)(e=>{let t=St.find(t=>t.id===e)??lt.data?.runs.find(t=>t.id===e);if(!t||yt(t)||t.readAtMs!=null)return;let n=Date.now();it.mutate(t=>t&&{...t,runs:t.runs.map(t=>t.id===e?{...t,readAtMs:n}:t)},!1),lt.mutate(t=>t&&{...t,runs:t.runs.map(t=>t.id===e?{...t,readAtMs:n}:t)},!1),R.markRunRead(e).catch(e=>{J(e instanceof Error?e.message:String(e)),it.mutate(),lt.mutate()})},[St,it.mutate,lt.data,lt.mutate]),dn=(0,K.useCallback)(e=>{un(e),De(e),ke(!0),O(t=>{let n=new URLSearchParams(t);return n.set(`run`,e),n},{replace:!0})},[un,O]),fn=(0,K.useCallback)(e=>{X(e);let t=ft(e,St);O(t=>{let n=new URLSearchParams(t);return n.set(`automation`,e),n},{replace:!0}),t&&t.readAtMs==null&&!yt(t)&&un(t.id)},[un,St,O]);(0,K.useEffect)(()=>{ne&&(un(ne),De(ne),ke(!0))},[un,ne]),(0,K.useEffect)(()=>{Ge(null),Xe(!1)},[Ee]);async function pn(){if(J(null),q.triggerMode===`once`&&!It&&new Date(q.onceAt).getTime()<=Date.now()){J(l.experience.futureTime);return}if(!(!$||tt)&&!(_e===`quick`&&U?.requiresProject&&!q.projectId)){if(Se&&Me){nt(`draft:edit`);try{let e=$e(q,Jt),{simulation:t}=await R.simulate(e);Ne({...Me,automation:e,simulation:t}),ze(q.projectId),Ve(q.conversationMode),Ue(q.notificationPolicy),Le(!1),Ce(!1),G(`draft`)}catch(e){J(e instanceof Error?e.message:String(e))}finally{nt(null)}return}if(It){let e=It.id;await mn(`automation:${e}:edit`,()=>R.update(e,st(It,q,Jt)))&&(W(!1),xe(null),X(e));return}nt(`automation:create`);try{let e=$e(q,Jt),{automation:t}=await R.create(e);we(Ze),W(!1),O(e=>{let n=new URLSearchParams(e);return n.delete(`status`),n.delete(`q`),n.delete(`run`),n.set(`automation`,t.id),ae||(t.projectId?n.set(`projectId`,t.projectId):n.delete(`projectId`)),n}),await nn(),X(t.id)}catch(e){J(e instanceof Error?e.message:String(e))}finally{nt(null)}}}async function mn(e,t){J(null),nt(e);try{return await t(),await nn(),!0}catch(e){return J(e instanceof Error?e.message:String(e)),!1}finally{nt(null)}}async function hn(){await mn(`runs:read-all`,()=>R.markAllRunsRead(I||void 0))}async function gn(){let e=Ae.trim();if(e){J(null),Fe(!0);try{Ne((await R.draft({prompt:e,language:a})).draft),Le(!1)}catch(e){J(e instanceof Error?e.message:String(e))}finally{Fe(!1)}}}async function _n(){if(!Me)return;let e=``,t=``;await mn(`draft:publish`,async()=>{let{automation:n}=await R.create({...Me.automation,...Re?{projectId:Re}:{projectId:void 0},conversationMode:Be,notificationPolicy:He});Ne(null),je(``),Le(!1),W(!1),H(`all`),pe(``),e=n.id,t=n.projectId??``})&&e&&(rn(t),X(e))}async function vn(){if(!Me)return;let e=``,t=``,n=``;await mn(`draft:test`,async()=>{let{automation:r}=await R.create({...Me.automation,...Re?{projectId:Re}:{projectId:void 0},conversationMode:Be,notificationPolicy:He,enabled:!1}),{run:i}=await R.runNow(r.id);e=r.id,t=r.projectId??``,n=i.id,Ne(null),je(``),Le(!1),W(!1),H(`all`),pe(``)})&&e&&n&&(rn(t),X(e),dn(n))}async function yn(e){J(null),qe(!0),Ge(null),Xe(!1);try{Ge((await R.repairDraft(e.id,{language:a})).repair)}catch(e){J(e instanceof Error?e.message:String(e))}finally{qe(!1)}}async function bn(e){We&&await mn(`run:${e.id}:repair`,async()=>{await R.update(e.automationId,We.patch),Ge(null),Xe(!1)})}let xn=(0,K.useMemo)(()=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(F,{className:`size-9 shrink-0 p-0`,loading:Qe,label:l.refresh,onClick:ln}),(0,Z.jsxs)(C,{variant:`primary`,onClick:()=>an(`draft`),children:[(0,Z.jsx)(f,{className:`size-4`}),l.new]})]}),[l.new,l.refresh,an,Qe,ln]);return(0,K.useLayoutEffect)(()=>{if(!t)return d({startExtra:null,main:(0,Z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:l.title}),end:xn}),()=>w()},[w,t,xn,l.title,d]),(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`:`mx-auto max-w-[96rem] px-4 py-7 sm:px-6 lg:px-8 lg:py-9`),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)(k,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n||l.title})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:r||l.subtitle})]}),xn]}):null,Te||rt.error||it.error?(0,Z.jsx)(`div`,{role:`alert`,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:Te||l.feedback.actionFailed}):null,!vt&&!rt.error&&Tt.length===0&&B!==`system`?(0,Z.jsxs)(`section`,{className:`rounded-xl border border-edge-subtle bg-surface-base p-6`,children:[(0,Z.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:l.experience.scenes}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.experience.scenesDescription}),(0,Z.jsx)(At,{templates:en,labels:l,onSelect:on}),(0,Z.jsx)(C,{className:`mt-4`,variant:`ghost`,onClick:()=>an(`draft`),children:l.experience.custom})]}):null,!vt&&tn.length>0&&B!==`system`?(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>H(`attention`),className:`flex items-center gap-3 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-3 text-left focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Z.jsx)(de,{className:`size-4 shrink-0 text-red-700 dark:text-red-300`,"aria-hidden":!0}),(0,Z.jsxs)(`span`,{className:`min-w-0 text-sm text-fg`,children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[l.experience.executionIssues,` · `,tn.length]}),(0,Z.jsx)(`span`,{className:`ml-2 text-fg-muted`,children:l.experience.issuesDescription})]})]}):null,vt?(0,Z.jsx)(Dt,{}):Tt.length>0||B===`system`?(0,Z.jsxs)(`section`,{className:`grid min-h-0 items-start gap-4 xl:grid-cols-[minmax(18rem,0.8fr)_minmax(0,1.5fr)]`,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:[ae?null:(0,Z.jsxs)(o,{"aria-label":l.filters.project,className:Q,value:I,onChange:e=>rn(e.target.value),children:[(0,Z.jsx)(s,{value:``,children:l.filters.allProjects}),qt.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`,!ae&&`mt-2`),children:[(0,Z.jsx)(ue,{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:V,onChange:e=>pe(e.target.value),placeholder:l.filters.search,"aria-label":l.filters.search})]}),(0,Z.jsxs)(`nav`,{className:`mt-3 flex flex-wrap items-center gap-1`,"aria-label":l.filters.status,children:[[{id:`all`,label:l.filters.all},{id:`active`,label:l.filters.active},{id:`paused`,label:l.paused},{id:`attention`,label:l.experience.executionIssues}].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`,B===e.id&&`bg-surface-hover text-fg`),onClick:()=>H(e.id),"aria-pressed":B===e.id,children:e.label},e.id)),(0,Z.jsxs)(oe,{children:[(0,Z.jsx)(ie,{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`,B===`system`&&`bg-surface-hover text-fg`),"aria-label":l.system.title,children:(0,Z.jsx)(T,{className:`size-4`})})}),(0,Z.jsx)(M,{children:(0,Z.jsx)(D,{align:`end`,className:`z-70 min-w-40 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:(0,Z.jsxs)(te,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>H(`system`),children:[l.system.title,` `,Ot.length]})})})]})]}),zt.length>0&&B!==`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:[l.filters.unread,` · `,zt.length]}),(0,Z.jsx)(`button`,{type:`button`,className:`font-medium hover:underline`,disabled:tt===`runs:read-all`,onClick:()=>void hn(),children:l.filters.markAllRead})]}):null]}),(0,Z.jsx)(Ft,{automations:Ut,runs:B===`system`?St:Mt,labels:l,cronLabels:u,language:a,selectedAutomationId:Y,onOpenDetails:fn})]}),Pt?(0,Z.jsx)(Vt,{automation:Pt,runs:Lt,runsLoading:lt.isLoading,runsError:lt.error?l.feedback.actionFailed:void 0,labels:l,cronLabels:u,language:a,projects:qt,busyAction:tt,onEdit:sn,onSelectRun:dn,onAction:mn},Pt.id):(0,Z.jsx)(Yt,{icon:(0,Z.jsx)(k,{className:`size-5`}),title:l.empty.filtered})]}):null,!vt&&Tt.length>0?(0,Z.jsx)(`div`,{children:(0,Z.jsxs)(C,{variant:`ghost`,onClick:()=>an(`draft`),children:[(0,Z.jsx)(f,{className:`size-4`,"aria-hidden":!0}),l.experience.discover]})}):null]}),(0,Z.jsx)(x,{open:ge,onOpenChange:e=>{W(e),e||(xe(null),Ce(!1))},children:(0,Z.jsxs)(y,{children:[(0,Z.jsx)(_,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(b,{className:`xopc-dialog-content 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)(ee,{className:`text-base font-semibold text-fg`,children:_e===`draft`?l.draft.title:It?l.editTitle:Se?l.draft.editTitle:l.createTitle}),(0,Z.jsx)(v,{asChild:!0,children:(0,Z.jsx)(C,{variant:`ghost`,"aria-label":l.close,children:(0,Z.jsx)(p,{className:`size-4`})})})]}),Te?(0,Z.jsx)(`p`,{role:`alert`,className:`px-5 py-2 text-sm text-red-700 dark:text-red-300`,children:Te}):null,_e===`draft`?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,Z.jsx)(jt,{labels:l,prompt:Ae,draft:Me,loading:Pe,approved:Ie,publishBusy:tt===`draft:publish`,testBusy:tt===`draft:test`,templates:en,projects:qt,projectId:Re,conversationMode:Be,notificationPolicy:He,onPromptChange:je,onGenerate:gn,onEdit:cn,onPublish:_n,onTest:vn,onProjectChange:ze,onConversationModeChange:Ve,onNotificationPolicyChange:Ue,projectLocked:ae,onApprovedChange:Le,onDiscard:()=>{Ne(null),Le(!1)},onTemplateSelect:e=>{on(e),we({...e.form,projectId:Re})},onOpenAdvanced:()=>{we({...Ze,projectId:Re,conversationMode:Be,notificationPolicy:He}),G(`blank`)}})}):(0,Z.jsxs)(Z.Fragment,{children:[_e===`quick`&&U?(0,Z.jsx)(ut,{form:q,setForm:we,labels:l,projects:qt,projectLocked:ae,source:U.source,requiresProject:U.requiresProject}):(0,Z.jsx)(Xt,{form:q,labels:l,setForm:we,projects:qt,workflowDefinitions:Wt,selectedWorkflow:Jt,workflowsLoading:mt.isLoading,browserAutomations:Gt,selectedBrowserAutomation:Zt,browserAutomationsLoading:ht.isLoading,agentOptions:Kt,agentsLoading:gt.isLoading,language:a,projectLocked:ae}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-edge px-5 py-4`,children:[_e===`quick`?(0,Z.jsx)(C,{variant:`ghost`,onClick:()=>G(`blank`),children:l.draft.advancedCreate}):null,Se?(0,Z.jsx)(C,{variant:`ghost`,onClick:()=>{Ce(!1),G(`draft`)},children:l.cancel}):(0,Z.jsx)(v,{asChild:!0,children:(0,Z.jsx)(C,{variant:`ghost`,children:l.cancel})}),(0,Z.jsx)(C,{variant:`primary`,onClick:pn,disabled:!$||!!tt||_e===`quick`&&!!U?.requiresProject&&!q.projectId,children:tt===`automation:create`||tt===`draft:edit`||It&&tt===`automation:${It.id}:edit`?l.feedback.working:It||Se?l.save:l.experience.createEnabled})]})]})]})]})}),(0,Z.jsx)(x,{open:Oe&&!!Nt,onOpenChange:e=>{ke(e),!e&&O(e=>{let t=new URLSearchParams(e);return t.delete(`run`),t},{replace:!0})},children:(0,Z.jsxs)(y,{children:[(0,Z.jsx)(_,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(b,{className:`xopc-dialog-content 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)(ee,{className:`truncate text-base font-semibold text-fg`,children:Nt?.automationName??l.dashboard.result}),(0,Z.jsx)(v,{asChild:!0,children:(0,Z.jsx)(C,{variant:`ghost`,"aria-label":l.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)(Bt,{className:`rounded-none border-0`,run:Nt,events:Rt,labels:l,cronLabels:u,language:a,loading:dt.isLoading,repairDraft:We,repairLoading:Ke,repairApproved:Ye,busyAction:tt,onRepairApprovedChange:Xe,onSuggestRepair:yn,onApplyRepair:bn})})]})]})})]})}function At(e){let t=(0,xe.c)(9),{templates:n,labels:r,onSelect:i}=e,a;if(t[0]!==r||t[1]!==i||t[2]!==n){let e;t[4]!==r||t[5]!==i?(e=e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded-lg border border-edge-subtle bg-surface-panel p-4 text-left hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Z.jsx)(O,{className:`mb-3 size-4 text-accent-fg`,"aria-hidden":!0}),(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.description}),(0,Z.jsxs)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:[r.experience.source,`: `,e.source]})]},e.name),t[4]=r,t[5]=i,t[6]=e):e=t[6],a=n.map(e),t[0]=r,t[1]=i,t[2]=n,t[3]=a}else a=t[3];let o;return t[7]===a?o=t[8]:(o=(0,Z.jsx)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:a}),t[7]=a,t[8]=o),o}function jt(e){let t=(0,xe.c)(110),{labels:n,prompt:r,draft:i,loading:a,approved:c,publishBusy:l,testBusy:u,templates:d,projects:f,projectId:p,conversationMode:h,notificationPolicy:g,onPromptChange:_,onGenerate:v,onEdit:y,onPublish:b,onTest:ee,onProjectChange:x,onConversationModeChange:S,onNotificationPolicyChange:w,onApprovedChange:T,onDiscard:E,onTemplateSelect:te,onOpenAdvanced:D,projectLocked:O}=e,k=l===void 0?!1:l,A=u===void 0?!1:u,ne=O===void 0?!1:O,M=!!(i&&i.simulation.requiredConfirmations.length>0),N;t[0]!==i||t[1]!==n.draft.advancedCreate||t[2]!==n.draft.suggestions||t[3]!==n.draft.suggestionsDescription||t[4]!==n.experience||t[5]!==D||t[6]!==te||t[7]!==d?(N=i?null:(0,Z.jsxs)(`div`,{className:`mb-5 border-b border-edge-subtle pb-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)(C,{variant:`ghost`,onClick:D,children:n.draft.advancedCreate})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:d.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`focus-visible:ring-2 focus-visible:ring-accent rounded-lg border border-edge-subtle bg-surface-panel p-3 text-left hover:bg-surface-hover`,onClick:()=>te(e),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}),(0,Z.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.experience.source,`: `,e.source]})]},e.name))})]}),t[0]=i,t[1]=n.draft.advancedCreate,t[2]=n.draft.suggestions,t[3]=n.draft.suggestionsDescription,t[4]=n.experience,t[5]=D,t[6]=te,t[7]=d,t[8]=N):N=t[8];let P;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(ce,{className:`size-4 text-accent`}),t[9]=P):P=t[9];let F;t[10]===n.draft.title?F=t[11]:(F=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[P,n.draft.title]}),t[10]=n.draft.title,t[11]=F);let I;t[12]===n.draft.subtitle?I=t[13]:(I=(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:n.draft.subtitle}),t[12]=n.draft.subtitle,t[13]=I);let L;t[14]!==F||t[15]!==I?(L=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[F,I]}),t[14]=F,t[15]=I,t[16]=L):L=t[16];let ie;t[17]!==a||t[18]!==r?(ie=a||!r.trim(),t[17]=a,t[18]=r,t[19]=ie):ie=t[19];let ae;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Z.jsx)(ce,{className:`size-4`}),t[20]=ae):ae=t[20];let oe=a?n.draft.generating:n.draft.generate,R;t[21]!==v||t[22]!==oe||t[23]!==ie?(R=(0,Z.jsxs)(C,{variant:`primary`,onClick:v,disabled:ie,children:[ae,oe]}),t[21]=v,t[22]=oe,t[23]=ie,t[24]=R):R=t[24];let se;t[25]!==R||t[26]!==L?(se=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[L,R]}),t[25]=R,t[26]=L,t[27]=se):se=t[27];let le;t[28]===_?le=t[29]:(le=e=>_(e.target.value),t[28]=_,t[29]=le);let z;t[30]!==n.draft.placeholder||t[31]!==n.draft.title||t[32]!==r||t[33]!==le?(z=(0,Z.jsx)(`textarea`,{"aria-label":n.draft.title,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[30]=n.draft.placeholder,t[31]=n.draft.title,t[32]=r,t[33]=le,t[34]=z):z=t[34];let ue=ne?`sm:grid-cols-2`:`sm:grid-cols-3`,B;t[35]===ue?B=t[36]:(B=m(`mt-3 grid gap-3`,ue),t[35]=ue,t[36]=B);let de;t[37]!==n.draft.noProject||t[38]!==n.draft.project||t[39]!==x||t[40]!==p||t[41]!==ne||t[42]!==f?(de=ne?null:(0,Z.jsx)($,{label:n.draft.project,children:(0,Z.jsxs)(o,{className:Q,value:p,onChange:e=>x(e.target.value),children:[(0,Z.jsx)(s,{value:``,children:n.draft.noProject}),f.map(Mt)]})}),t[37]=n.draft.noProject,t[38]=n.draft.project,t[39]=x,t[40]=p,t[41]=ne,t[42]=f,t[43]=de):de=t[43];let fe;t[44]===S?fe=t[45]:(fe=e=>S(e.target.value),t[44]=S,t[45]=fe);let V;t[46]===n.draft.newConversation?V=t[47]:(V=(0,Z.jsx)(s,{value:`new_session`,children:n.draft.newConversation}),t[46]=n.draft.newConversation,t[47]=V);let H;t[48]===n.draft.continuousConversation?H=t[49]:(H=(0,Z.jsx)(s,{value:`continuous`,children:n.draft.continuousConversation}),t[48]=n.draft.continuousConversation,t[49]=H);let pe;t[50]!==h||t[51]!==fe||t[52]!==V||t[53]!==H?(pe=(0,Z.jsxs)(o,{className:Q,value:h,onChange:fe,children:[V,H]}),t[50]=h,t[51]=fe,t[52]=V,t[53]=H,t[54]=pe):pe=t[54];let U;t[55]!==n.draft.conversation||t[56]!==pe?(U=(0,Z.jsx)($,{label:n.draft.conversation,children:pe}),t[55]=n.draft.conversation,t[56]=pe,t[57]=U):U=t[57];let me;t[58]===w?me=t[59]:(me=e=>w(e.target.value),t[58]=w,t[59]=me);let he;t[60]===n.draft.notifyAttention?he=t[61]:(he=(0,Z.jsx)(s,{value:`attention`,children:n.draft.notifyAttention}),t[60]=n.draft.notifyAttention,t[61]=he);let ge;t[62]===n.draft.notifyAll?ge=t[63]:(ge=(0,Z.jsx)(s,{value:`all`,children:n.draft.notifyAll}),t[62]=n.draft.notifyAll,t[63]=ge);let W;t[64]===n.draft.notifyNone?W=t[65]:(W=(0,Z.jsx)(s,{value:`none`,children:n.draft.notifyNone}),t[64]=n.draft.notifyNone,t[65]=W);let _e;t[66]!==g||t[67]!==me||t[68]!==he||t[69]!==ge||t[70]!==W?(_e=(0,Z.jsxs)(o,{className:Q,value:g,onChange:me,children:[he,ge,W]}),t[66]=g,t[67]=me,t[68]=he,t[69]=ge,t[70]=W,t[71]=_e):_e=t[71];let ve;t[72]!==n.draft.notifications||t[73]!==_e?(ve=(0,Z.jsx)($,{label:n.draft.notifications,children:_e}),t[72]=n.draft.notifications,t[73]=_e,t[74]=ve):ve=t[74];let ye;t[75]!==B||t[76]!==de||t[77]!==U||t[78]!==ve?(ye=(0,Z.jsxs)(`div`,{className:B,children:[de,U,ve]}),t[75]=B,t[76]=de,t[77]=U,t[78]=ve,t[79]=ye):ye=t[79];let G;t[80]!==c||t[81]!==i||t[82]!==n.draft.approval||t[83]!==n.draft.assumptions||t[84]!==n.draft.discard||t[85]!==n.draft.edit||t[86]!==n.draft.publish||t[87]!==n.draft.review||t[88]!==n.draft.risks||t[89]!==n.draft.safety||t[90]!==n.draft.testOnce||t[91]!==n.draft.testing||t[92]!==n.feedback||t[93]!==n.info||t[94]!==n.none||t[95]!==T||t[96]!==E||t[97]!==y||t[98]!==b||t[99]!==ee||t[100]!==k||t[101]!==M||t[102]!==A?(G=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)(Jt,{label:n.info.when,value:i.simulation.triggerSummary}),(0,Z.jsx)(Jt,{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)(Nt,{title:n.draft.safety,items:[...i.simulation.safetyNotes,...i.simulation.requiredConfirmations],empty:n.none}),(0,Z.jsx)(Nt,{title:n.draft.assumptions,items:i.assumptions,empty:n.none}),(0,Z.jsx)(Nt,{title:n.draft.risks,items:i.risks,empty:n.none}),M?(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=>T(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)(C,{variant:`ghost`,onClick:E,children:n.draft.discard}),(0,Z.jsxs)(C,{variant:`secondary`,onClick:y,children:[(0,Z.jsx)(re,{className:`size-4`}),n.draft.edit]}),(0,Z.jsxs)(C,{variant:`secondary`,onClick:ee,disabled:A||k||M&&!c,children:[(0,Z.jsx)(j,{className:`size-4`}),A?n.draft.testing:n.draft.testOnce]}),(0,Z.jsx)(C,{variant:`primary`,onClick:b,disabled:k||M&&!c,children:k?n.feedback.working:n.draft.publish})]})]})]}):null,t[80]=c,t[81]=i,t[82]=n.draft.approval,t[83]=n.draft.assumptions,t[84]=n.draft.discard,t[85]=n.draft.edit,t[86]=n.draft.publish,t[87]=n.draft.review,t[88]=n.draft.risks,t[89]=n.draft.safety,t[90]=n.draft.testOnce,t[91]=n.draft.testing,t[92]=n.feedback,t[93]=n.info,t[94]=n.none,t[95]=T,t[96]=E,t[97]=y,t[98]=b,t[99]=ee,t[100]=k,t[101]=M,t[102]=A,t[103]=G):G=t[103];let be;return t[104]!==se||t[105]!==z||t[106]!==ye||t[107]!==G||t[108]!==N?(be=(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[N,se,z,ye,G]}),t[104]=se,t[105]=z,t[106]=ye,t[107]=G,t[108]=N,t[109]=be):be=t[109],be}function Mt(e){return(0,Z.jsx)(s,{value:e.id,children:e.name},e.id)}function Nt(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(Pt):(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 Pt(e){return(0,Z.jsxs)(`li`,{children:[`- `,e]},e)}function Ft(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)(k,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===i.empty.filtered?n=t[2]:(n=(0,Z.jsx)(Yt,{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(It),n=t.find(yt),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`),style:{contentVisibility:`auto`,containIntrinsicSize:`auto 130px`},"aria-current":s===e.id?`true`:void 0,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`:pt(e,t)?`bg-red-500`:e.enabled?`bg-emerald-500`:`bg-fg-subtle`)}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:e.name}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.enabled?i.enabled:i.paused}),l&&l.readAtMs==null&&!yt(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.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(`line-clamp-2`,l?.error&&`text-red-700 dark:text-red-300`),children:l?l.error||l.summary||i.status[l.status]:e.state.lastError||(e.state.lastRunStatus?i.status[e.state.lastRunStatus]:i.experience.noRuns)}),l?.status?(0,Z.jsx)(`span`,{className:m(`shrink-0 rounded-full px-1.5 py-0.5`,_t(l.status)),children:i.status[l.status]}):null]}),(0,Z.jsxs)(`div`,{className:`mt-2 space-y-1 pl-4 text-xs text-fg-muted`,children:[l?(0,Z.jsxs)(`div`,{children:[i.last,`: `,mt(l.createdAtMs,i,o)]}):null,(0,Z.jsx)(`div`,{children:e.enabled?`${i.next}: ${Ye(e,i,o)}`:i.paused}),(0,Z.jsx)(`div`,{children:Je(e.trigger,i,a,o)})]})]},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 It(e,t){return t.createdAtMs-e.createdAtMs}function Lt(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 Rt(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
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
3
|
`).slice(0,10).join(`
|
|
4
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(zt),"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)(B,{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 zt(e){return!e}function Bt(e){let t=(0,xe.c)(148),{className:n,run:r,events:i,labels:o,cronLabels:s,language:f,loading:p,repairDraft:h,repairLoading:g,repairApproved:_,busyAction:v,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)(ne,{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.conversationId?`/chat/${encodeURIComponent(r.conversationId)}`:r.workflowRunId?`/workflows?run=${encodeURIComponent(r.workflowRunId)}`:null,T=r.conversationId?o.runDetail.openConversation:o.runDetail.openWorkflow,E=r.conversationId?d:u,te=yt(r)?ne:r.status===`succeeded`?c:de,D;t[8]===n?D=t[9]:(D=m(`rounded-lg border border-edge-subtle bg-surface-base shadow-surface`,n),t[8]=n,t[9]=D);let O;t[10]===r.automationName?O=t[11]:(O=(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:r.automationName}),t[10]=r.automationName,t[11]=O);let k;t[12]===r.id?k=t[13]:(k=r.id.slice(0,8),t[12]=r.id,t[13]=k);let A;t[14]===k?A=t[15]:(A=(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:k}),t[14]=k,t[15]=A);let j;t[16]!==O||t[17]!==A?(j=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[O,A]}),t[16]=O,t[17]=A,t[18]=j):j=t[18];let M;t[19]===r.status?M=t[20]:(M=m(`shrink-0 rounded-full px-2 py-0.5 text-xs`,_t(r.status)),t[19]=r.status,t[20]=M);let P=o.status[r.status],re;t[21]!==M||t[22]!==P?(re=(0,Z.jsx)(`span`,{className:M,children:P}),t[21]=M,t[22]=P,t[23]=re):re=t[23];let F;t[24]!==j||t[25]!==re?(F=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[j,re]}),t[24]=j,t[25]=re,t[26]=F):F=t[26];let I;t[27]!==o||t[28]!==f||t[29]!==r.createdAtMs?(I=mt(r.createdAtMs,o,f),t[27]=o,t[28]=f,t[29]=r.createdAtMs,t[30]=I):I=t[30];let L;t[31]===I?L=t[32]:(L=(0,Z.jsx)(`span`,{children:I}),t[31]=I,t[32]=L);let ie;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t[33]=ie):ie=t[33];let ae=o.details.duration,oe;t[34]!==o||t[35]!==r.durationMs?(oe=vt(r.durationMs,o),t[34]=o,t[35]=r.durationMs,t[36]=oe):oe=t[36];let R;t[37]!==o.details.duration||t[38]!==oe?(R=(0,Z.jsxs)(`span`,{children:[ae,` `,oe]}),t[37]=o.details.duration,t[38]=oe,t[39]=R):R=t[39];let se;t[40]!==L||t[41]!==R?(se=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-muted`,children:[L,ie,R]}),t[40]=L,t[41]=R,t[42]=se):se=t[42];let z;t[43]!==o.repair||t[44]!==b||t[45]!==g||t[46]!==r?(z=r.status===`failed`||r.status===`timeout`||r.status===`cancelled`?(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsxs)(C,{variant:`secondary`,onClick:()=>b(r),disabled:g,children:[(0,Z.jsx)(ce,{className:`size-4`}),g?o.repair.generating:o.repair.suggest]})}):null,t[43]=o.repair,t[44]=b,t[45]=g,t[46]=r,t[47]=z):z=t[47];let ue;t[48]!==se||t[49]!==z||t[50]!==F?(ue=(0,Z.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[F,se,z]}),t[48]=se,t[49]=z,t[50]=F,t[51]=ue):ue=t[51];let fe;t[52]===r?fe=t[53]:(fe=yt(r)?`text-blue-500`:bt(r)?`text-red-500`:r.status===`succeeded`?`text-emerald-500`:`text-fg-muted`,t[52]=r,t[53]=fe);let V;t[54]===fe?V=t[55]:(V=m(`size-4`,fe),t[54]=fe,t[55]=V);let H;t[56]!==te||t[57]!==V?(H=(0,Z.jsx)(te,{className:V}),t[56]=te,t[57]=V,t[58]=H):H=t[58];let pe;t[59]!==o.runDetail.resultTitle||t[60]!==H?(pe=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[H,o.runDetail.resultTitle]}),t[59]=o.runDetail.resultTitle,t[60]=H,t[61]=pe):pe=t[61];let U;t[62]!==E||t[63]!==T||t[64]!==S?(U=S?(0,Z.jsx)(C,{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)(E,{className:`size-3.5`}),T,(0,Z.jsx)(N,{className:`size-3.5`})]})}):null,t[62]=E,t[63]=T,t[64]=S,t[65]=U):U=t[65];let me;t[66]!==pe||t[67]!==U?(me=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[pe,U]}),t[66]=pe,t[67]=U,t[68]=me):me=t[68];let he=r.error&&`border-red-500/25 bg-red-500/5`,ge;t[69]===he?ge=t[70]:(ge=m(`mt-3 max-h-80 overflow-y-auto rounded-lg border border-edge/70 bg-surface-muted/25 p-3`,he),t[69]=he,t[70]=ge);let W;t[71]!==o.runDetail.noResult||t[72]!==o.runDetail.resultPending||t[73]!==x||t[74]!==r?(W=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)(l,{content:x,compact:!0,className:`text-sm`}):(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:yt(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]=W):W=t[75];let _e;t[76]!==ge||t[77]!==W?(_e=(0,Z.jsx)(`div`,{className:ge,children:W}),t[76]=ge,t[77]=W,t[78]=_e):_e=t[78];let ve;t[79]!==me||t[80]!==_e?(ve=(0,Z.jsxs)(`section`,{className:`border-b border-edge p-4`,children:[me,_e]}),t[79]=me,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 G;t[84]!==s||t[85]!==o||t[86]!==f||t[87]!==r.manual||t[88]!==r.triggerSnapshot?(G=r.manual?o.trigger.manual:Je(r.triggerSnapshot,o,s,f),t[84]=s,t[85]=o,t[86]=f,t[87]=r.manual,t[88]=r.triggerSnapshot,t[89]=G):G=t[89];let be;t[90]!==o.explain.whyRan||t[91]!==G?(be=(0,Z.jsx)(Kt,{label:o.explain.whyRan,value:G}),t[90]=o.explain.whyRan,t[91]=G,t[92]=be):be=t[92];let K=o.details.started,Se;t[93]!==o||t[94]!==f||t[95]!==r.startedAtMs?(Se=mt(r.startedAtMs,o,f),t[93]=o,t[94]=f,t[95]=r.startedAtMs,t[96]=Se):Se=t[96];let Ce;t[97]!==o.details.started||t[98]!==Se?(Ce=(0,Z.jsx)(Kt,{label:K,value:Se}),t[97]=o.details.started,t[98]=Se,t[99]=Ce):Ce=t[99];let q;t[100]!==o.details.model||t[101]!==r.model?(q=r.model?(0,Z.jsx)(Kt,{label:o.details.model,value:r.model}):null,t[100]=o.details.model,t[101]=r.model,t[102]=q):q=t[102];let we;t[103]!==be||t[104]!==Ce||t[105]!==q?(we=(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs text-fg-muted`,children:[be,Ce,q]}),t[103]=be,t[104]=Ce,t[105]=q,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 J;t[110]!==v||t[111]!==o||t[112]!==ee||t[113]!==y||t[114]!==_||t[115]!==h||t[116]!==r?(J=h?(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:h.explanation}),h.expectedEffect?(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:h.expectedEffect}):null,(0,Z.jsx)(Nt,{title:o.repair.risks,items:h.risks,empty:o.none}),(0,Z.jsx)(Rt,{value:h.patch,labels:o,title:o.details.repairPatch}),h.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:_,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)(C,{variant:`primary`,onClick:()=>ee(r),disabled:v===`run:${r.id}:repair`||h.requiresApproval&&!_,children:v===`run:${r.id}:repair`?o.feedback.working:o.repair.apply})})]}):null,t[110]=v,t[111]=o,t[112]=ee,t[113]=y,t[114]=_,t[115]=h,t[116]=r,t[117]=J):J=t[117];let Ee;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,Z.jsx)(le,{className:`size-4 shrink-0`}),t[118]=Ee):Ee=t[118];let De;t[119]===o.runDetail.technicalEvents?De=t[120]:(De=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-sm font-medium text-fg-muted`,children:[Ee,o.runDetail.technicalEvents]}),t[119]=o.runDetail.technicalEvents,t[120]=De);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)(B,{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]!==De||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:[De,Y]}),t[127]=De,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]!==f||t[135]!==p?(je=(0,Z.jsx)(`div`,{className:`mt-4`,children:p?(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-label":o.loading,children:[(0,Z.jsx)(w,{className:`h-10 w-full`}),(0,Z.jsx)(w,{className:`h-10 w-4/5`}),(0,Z.jsx)(w,{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`,qt(e.type))}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm text-fg`,children:Lt(e,o)}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:[mt(e.createdAtMs,o,f),` · `,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)(B,{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]=f,t[135]=p,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]!==D||t[142]!==ue||t[143]!==ve||t[144]!==Te||t[145]!==J||t[146]!==Me?(Ne=(0,Z.jsxs)(`aside`,{className:D,children:[ue,ve,Te,J,Me]}),t[141]=D,t[142]=ue,t[143]=ve,t[144]=Te,t[145]=J,t[146]=Me,t[147]=Ne):Ne=t[147],Ne}function Vt(e){let t=(0,xe.c)(113),{automation:n,runs:r,runsLoading:i,runsError:a,labels:o,cronLabels:s,language:u,projects:d,busyAction:f,onEdit:p,onSelectRun:h,onAction:g}=e,_=f===`automation:${n.id}:run`,v=f===`automation:${n.id}:toggle`,y=f===`automation:${n.id}:delete`,b;t[0]===n?b=t[1]:(b=Ct(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`,O;t[4]===S?O=t[5]:(O=m(`shrink-0 rounded-full px-2 py-0.5 text-xs`,S),t[4]=S,t[5]=O);let k=n.enabled?o.enabled:o.paused,A;t[6]!==O||t[7]!==k?(A=(0,Z.jsx)(`span`,{className:O,children:k}),t[6]=O,t[7]=k,t[8]=A):A=t[8];let N;t[9]!==x||t[10]!==A?(N=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[x,A]}),t[9]=x,t[10]=A,t[11]=N):N=t[11];let F;t[12]===n?F=t[13]:(F=wt(n)?(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:wt(n)}):null,t[12]=n,t[13]=F);let I;t[14]!==N||t[15]!==F?(I=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[N,F]}),t[14]=N,t[15]=F,t[16]=I):I=t[16];let L;t[17]!==n||t[18]!==f||t[19]!==y||t[20]!==o.dashboard.delete||t[21]!==o.dashboard.deleted||t[22]!==o.dashboard.pause||t[23]!==o.dashboard.resume||t[24]!==o.dashboard.resumed||t[25]!==o.dashboard.runNow||t[26]!==o.details||t[27]!==o.edit||t[28]!==o.experience.deleteConfirm||t[29]!==o.feedback||t[30]!==g||t[31]!==p||t[32]!==ee||t[33]!==_||t[34]!==v?(L=ee?null:(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsxs)(C,{variant:`secondary`,disabled:f!==null,onClick:()=>void g(`automation:${n.id}:toggle`,()=>n.enabled?R.pause(n.id):R.resume(n.id),n.enabled?o.feedback.paused:o.dashboard.resumed),children:[v?(0,Z.jsx)(ae,{className:`size-4 animate-spin`}):n.enabled?(0,Z.jsx)(P,{className:`size-4`}):(0,Z.jsx)(j,{className:`size-4`}),n.enabled?o.dashboard.pause:o.dashboard.resume]}),(0,Z.jsxs)(C,{variant:`primary`,disabled:f!==null,onClick:()=>void g(`automation:${n.id}:run`,()=>R.runNow(n.id),o.feedback.rerunQueued),children:[_?(0,Z.jsx)(ae,{className:`size-4 animate-spin`}):(0,Z.jsx)(j,{className:`size-4`}),o.dashboard.runNow]}),(0,Z.jsxs)(oe,{children:[(0,Z.jsx)(ie,{asChild:!0,children:(0,Z.jsx)(C,{variant:`ghost`,className:`size-9 p-0`,"aria-label":o.details.moreActions,children:(0,Z.jsx)(T,{className:`size-4`})})}),(0,Z.jsx)(M,{children:(0,Z.jsxs)(D,{align:`end`,className:`z-70 min-w-40 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[(0,Z.jsxs)(te,{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:()=>p(n),children:[(0,Z.jsx)(re,{className:`size-4`}),o.edit]}),(0,Z.jsxs)(te,{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:f!==null,onSelect:()=>{window.confirm(o.experience.deleteConfirm)&&g(`automation:${n.id}:delete`,()=>R.remove(n.id),o.dashboard.deleted)},children:[y?(0,Z.jsx)(ae,{className:`size-4 animate-spin`}):(0,Z.jsx)(E,{className:`size-4`}),o.dashboard.delete]})]})})]})]}),t[17]=n,t[18]=f,t[19]=y,t[20]=o.dashboard.delete,t[21]=o.dashboard.deleted,t[22]=o.dashboard.pause,t[23]=o.dashboard.resume,t[24]=o.dashboard.resumed,t[25]=o.dashboard.runNow,t[26]=o.details,t[27]=o.edit,t[28]=o.experience.deleteConfirm,t[29]=o.feedback,t[30]=g,t[31]=p,t[32]=ee,t[33]=_,t[34]=v,t[35]=L):L=t[35];let se;t[36]!==L||t[37]!==I?(se=(0,Z.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[I,L]}),t[36]=L,t[37]=I,t[38]=se):se=t[38];let ce;t[39]===o.dashboard.latestResult?ce=t[40]:(ce=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:o.dashboard.latestResult}),t[39]=o.dashboard.latestResult,t[40]=ce);let le;t[41]!==o.experience.viewResult||t[42]!==h||t[43]!==r[0]?(le=r[0]?(0,Z.jsx)(C,{variant:`secondary`,onClick:()=>h(r[0].id),children:o.experience.viewResult}):null,t[41]=o.experience.viewResult,t[42]=h,t[43]=r[0],t[44]=le):le=t[44];let z;t[45]!==ce||t[46]!==le?(z=(0,Z.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[ce,le]}),t[45]=ce,t[46]=le,t[47]=z):z=t[47];let ue;t[48]!==o||t[49]!==u||t[50]!==r[0]||t[51]!==a||t[52]!==i?(ue=a?(0,Z.jsx)(`p`,{role:`alert`,className:`text-sm text-red-700 dark:text-red-300`,children:a}):i?(0,Z.jsx)(w,{className:`h-28 w-full`}):r[0]?(0,Z.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge-subtle bg-surface-base p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:m(`rounded-full px-2 py-0.5`,_t(r[0].status)),children:o.status[r[0].status]}),mt(r[0].createdAtMs,o,u)]}),(0,Z.jsx)(l,{content:r[0].error||r[0].summary||(yt(r[0])?o.runDetail.resultPending:o.runDetail.noResult),compact:!0})]}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.experience.noRuns}),t[48]=o,t[49]=u,t[50]=r[0],t[51]=a,t[52]=i,t[53]=ue):ue=t[53];let B;t[54]!==n||t[55]!==o||t[56]!==u?(B=n.enabled?`${o.next}: ${Ye(n,o,u)}`:o.paused,t[54]=n,t[55]=o,t[56]=u,t[57]=B):B=t[57];let de;t[58]===B?de=t[59]:(de=(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:B}),t[58]=B,t[59]=de);let fe;t[60]!==z||t[61]!==ue||t[62]!==de?(fe=(0,Z.jsxs)(`section`,{children:[z,ue,de]}),t[60]=z,t[61]=ue,t[62]=de,t[63]=fe):fe=t[63];let V;t[64]===o.dashboard.runHistory?V=t[65]:(V=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:o.dashboard.runHistory}),t[64]=o.dashboard.runHistory,t[65]=V);let H;t[66]===o.dashboard.runHistoryDescription?H=t[67]:(H=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o.dashboard.runHistoryDescription}),t[66]=o.dashboard.runHistoryDescription,t[67]=H);let pe;t[68]!==V||t[69]!==H?(pe=(0,Z.jsxs)(`div`,{children:[V,H]}),t[68]=V,t[69]=H,t[70]=pe):pe=t[70];let U;t[71]===r.length?U=t[72]:(U=(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-base px-2.5 py-1 text-xs text-fg-muted`,children:r.length}),t[71]=r.length,t[72]=U);let me;t[73]!==pe||t[74]!==U?(me=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[pe,U]}),t[73]=pe,t[74]=U,t[75]=me):me=t[75];let he;t[76]!==o||t[77]!==u||t[78]!==h||t[79]!==r||t[80]!==i?(he=i?(0,Z.jsx)(w,{className:`h-24 w-full`}):r.length===0?(0,Z.jsx)(Yt,{className:`min-h-24 py-6`,icon:(0,Z.jsx)(ne,{className:`size-5`}),title:o.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:()=>h(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)(ne,{className:`size-4 shrink-0 text-fg-muted`}),(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:mt(e.createdAtMs,o,u)})]}),(0,Z.jsx)(`span`,{className:m(`shrink-0 rounded-full px-2 py-0.5 text-xs`,_t(e.status)),children:o.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||ht(e.actionSnapshot,o)})]},e.id))}),t[76]=o,t[77]=u,t[78]=h,t[79]=r,t[80]=i,t[81]=he):he=t[81];let ge;t[82]!==me||t[83]!==he?(ge=(0,Z.jsxs)(`section`,{className:`min-w-0`,children:[me,he]}),t[82]=me,t[83]=he,t[84]=ge):ge=t[84];let W;t[85]===o.experience.settings?W=t[86]:(W=(0,Z.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:o.experience.settings}),t[85]=o.experience.settings,t[86]=W);let _e;t[87]!==n||t[88]!==o?(_e=xt(n,o),t[87]=n,t[88]=o,t[89]=_e):_e=t[89];let ve;t[90]===_e?ve=t[91]:(ve=(0,Z.jsx)(l,{content:_e,compact:!0}),t[90]=_e,t[91]=ve);let ye;t[92]!==n||t[93]!==s||t[94]!==o||t[95]!==u||t[96]!==d?(ye=(0,Z.jsx)(Ut,{automation:n,labels:o,cronLabels:s,language:u,projects:d}),t[92]=n,t[93]=s,t[94]=o,t[95]=u,t[96]=d,t[97]=ye):ye=t[97];let G;t[98]!==ve||t[99]!==ye?(G=(0,Z.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[ve,ye]}),t[98]=ve,t[99]=ye,t[100]=G):G=t[100];let be;t[101]!==W||t[102]!==G?(be=(0,Z.jsxs)(`details`,{className:`rounded-lg border border-edge-subtle p-4`,children:[W,G]}),t[101]=W,t[102]=G,t[103]=be):be=t[103];let K;t[104]!==ge||t[105]!==be?(K=(0,Z.jsxs)(`div`,{className:`grid gap-5`,children:[ge,be]}),t[104]=ge,t[105]=be,t[106]=K):K=t[106];let Se;t[107]!==fe||t[108]!==K?(Se=(0,Z.jsxs)(`div`,{className:`grid gap-5 p-5`,children:[fe,K]}),t[107]=fe,t[108]=K,t[109]=Se):Se=t[109];let Ce;return t[110]!==se||t[111]!==Se?(Ce=(0,Z.jsxs)(`article`,{className:`min-w-0 overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel shadow-surface`,children:[se,Se]}),t[110]=se,t[111]=Se,t[112]=Ce):Ce=t[112],Ce}function Ht(e,t){return e===`suggest_only`?t.safety.suggestOnlyDescription:e===`ask_before_apply`?t.safety.askBeforeApplyDescription:t.safety.autoApplyDescription}function Ut(e){let t=(0,xe.c)(146),{automation:n,labels:r,cronLabels:i,language:a,projects:o}=e,s,c,l,f,p,m,h,g,_,v,y;if(t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a){let e=gt(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 d=o,b;t[19]!==n.state.nextRunAtMs||t[20]!==a?(b=n.state.nextRunAtMs?We(n.state.nextRunAtMs,a):void 0,t[19]=n.state.nextRunAtMs,t[20]=a,t[21]=b):b=t[21];let ee=b;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(y=[],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],y.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],y.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],y.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],y.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],y.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],y.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],y.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],y.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],y.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]=y}else y=t[39];_=`h-fit overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,t[70]===r.info.overview?v=t[71]:(v=(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]=v),m=`grid gap-4 p-4`;let x;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(O,{className:`size-4`,"aria-hidden":!0}),t[72]=x):x=t[72];let S=r.info.schedule,C;t[73]!==n.trigger||t[74]!==i||t[75]!==r||t[76]!==a?(C=Je(n.trigger,r,i,a),t[73]=n.trigger,t[74]=i,t[75]=r,t[76]=a,t[77]=C):C=t[77];let w=n.enabled?`${r.info.nextRun}:${d}`:d;t[78]!==r.info.schedule||t[79]!==ee||t[80]!==C||t[81]!==w?(h=(0,Z.jsx)(Gt,{icon:x,label:S,value:C,description:w,descriptionTitle:ee}),t[78]=r.info.schedule,t[79]=ee,t[80]=C,t[81]=w,t[82]=h):h=t[82];let T;t[83]===n.action.kind?T=t[84]:(T=n.action.kind===`workflow`?(0,Z.jsx)(u,{className:`size-4`,"aria-hidden":!0}):n.action.kind===`browser_automation`?(0,Z.jsx)(le,{className:`size-4`,"aria-hidden":!0}):(0,Z.jsx)(k,{className:`size-4`,"aria-hidden":!0}),t[83]=n.action.kind,t[84]=T);let E=r.info.action,te;t[85]!==n.action||t[86]!==r?(te=ht(n.action,r),t[85]=n.action,t[86]=r,t[87]=te):te=t[87],t[88]!==r.info.action||t[89]!==T||t[90]!==te?(g=(0,Z.jsx)(Gt,{icon:T,label:E,value:te}),t[88]=r.info.action,t[89]=T,t[90]=te,t[91]=g):g=t[91],s=Gt,t[92]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(z,{className:`size-4`,"aria-hidden":!0}),t[92]=c):c=t[92],l=r.info.permission,f=r.safety[e],p=Ht(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]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=g,t[12]=_,t[13]=v,t[14]=y}else s=t[4],c=t[5],l=t[6],f=t[7],p=t[8],m=t[9],h=t[10],g=t[11],_=t[12],v=t[13],y=t[14];let b;t[93]!==s||t[94]!==c||t[95]!==l||t[96]!==f||t[97]!==p?(b=(0,Z.jsx)(s,{icon:c,label:l,value:f,description:p}),t[93]=s,t[94]=c,t[95]=l,t[96]=f,t[97]=p,t[98]=b):b=t[98];let ee;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Z.jsx)(u,{className:`size-4`,"aria-hidden":!0}),t[99]=ee):ee=t[99];let x;t[100]!==n.projectId||t[101]!==r.info.noProject||t[102]!==o?(x=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]=x):x=t[103];let S;t[104]!==r.info.project||t[105]!==x?(S=(0,Z.jsx)(Gt,{icon:ee,label:r.info.project,value:x}),t[104]=r.info.project,t[105]=x,t[106]=S):S=t[106];let C;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t[107]=C):C=t[107];let w=n.conversationMode===`continuous`?r.info.continuousConversation:r.info.newConversation,T;t[108]!==r.info.conversation||t[109]!==w?(T=(0,Z.jsx)(Gt,{icon:C,label:r.info.conversation,value:w}),t[108]=r.info.conversation,t[109]=w,t[110]=T):T=t[110];let E;t[111]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(de,{className:`size-4`,"aria-hidden":!0}),t[111]=E):E=t[111];let te=n.notificationPolicy===`all`?r.info.notifyAll:n.notificationPolicy===`none`?r.info.notifyNone:r.info.notifyAttention,D;t[112]!==r.info.notifications||t[113]!==te?(D=(0,Z.jsx)(Gt,{icon:E,label:r.info.notifications,value:te}),t[112]=r.info.notifications,t[113]=te,t[114]=D):D=t[114];let A;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),t[115]=A):A=t[115];let j=r.info.lastRun,M;t[116]!==n||t[117]!==r||t[118]!==a?(M=Xe(n,r,a),t[116]=n,t[117]=r,t[118]=a,t[119]=M):M=t[119];let N=n.state.lastRunStatus===`failed`||n.state.lastRunStatus===`timeout`?`danger`:`default`,P;t[120]!==r.info.lastRun||t[121]!==M||t[122]!==N?(P=(0,Z.jsx)(Gt,{icon:A,label:j,value:M,valueTone:N}),t[120]=r.info.lastRun,t[121]=M,t[122]=N,t[123]=P):P=t[123];let re;t[124]!==n.state.consecutiveFailures||t[125]!==n.state.lastError||t[126]!==r.dashboard?(re=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]=re):re=t[127];let F;t[128]!==r.info.technicalDetails||t[129]!==y?(F=y.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)(B,{className:`size-4 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:y.map(Wt)})]}):null,t[128]=r.info.technicalDetails,t[129]=y,t[130]=F):F=t[130];let I;t[131]!==b||t[132]!==S||t[133]!==T||t[134]!==D||t[135]!==P||t[136]!==re||t[137]!==F||t[138]!==m||t[139]!==h||t[140]!==g?(I=(0,Z.jsxs)(`div`,{className:m,children:[h,g,b,S,T,D,P,re,F]}),t[131]=b,t[132]=S,t[133]=T,t[134]=D,t[135]=P,t[136]=re,t[137]=F,t[138]=m,t[139]=h,t[140]=g,t[141]=I):I=t[141];let L;return t[142]!==I||t[143]!==_||t[144]!==v?(L=(0,Z.jsxs)(`aside`,{className:_,children:[v,I]}),t[142]=I,t[143]=_,t[144]=v,t[145]=L):L=t[145],L}function Wt(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 Gt(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 Kt(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 qt(e){return e.endsWith(`.failed`)?`bg-red-500`:e.endsWith(`.completed`)?`bg-emerald-500`:e.endsWith(`.started`)?`bg-blue-500`:`bg-fg-muted`}function Jt(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 Yt(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 text-fg-muted`,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 Xt(e){let t=(0,xe.c)(274),{form:n,labels:r,setForm:i,projects:a,workflowDefinitions:c,selectedWorkflow:l,workflowsLoading:u,browserAutomations:d,selectedBrowserAutomation:f,browserAutomationsLoading: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(),T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T=[1,2,3],t[2]=T):T=t[2];let E;t[3]!==C||t[4]!==w||t[5]!==v?(E=T.map(e=>Ke(w+C*e,v,w)),t[3]=C,t[4]=w,t[5]=v,t[6]=E):E=t[6];let te=E,D,O;t[7]!==n.actionMode||t[8]!==n.workflowId||t[9]!==i||t[10]!==c?(D=()=>{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}))},O=[n.actionMode,n.workflowId,i,c],t[7]=n.actionMode,t[8]=n.workflowId,t[9]=i,t[10]=c,t[11]=D,t[12]=O):(D=t[11],O=t[12]),(0,K.useEffect)(D,O);let k,A;t[13]!==d||t[14]!==n.actionMode||t[15]!==n.browserAutomationId||t[16]!==i?(k=()=>{if(n.actionMode!==`browser_automation`||n.browserAutomationId.trim())return;let e=d[0];e&&i(t=>({...t,browserAutomationId:e.id,browserAutomationInputs:G(e)}))},A=[d,n.actionMode,n.browserAutomationId,i],t[13]=d,t[14]=n.actionMode,t[15]=n.browserAutomationId,t[16]=i,t[17]=k,t[18]=A):(k=t[17],A=t[18]),(0,K.useEffect)(k,A);let ne;t[19]===S?ne=t[20]:(ne=e=>S({name:e.target.value}),t[19]=S,t[20]=ne);let j;t[21]!==n.name||t[22]!==ne?(j=(0,Z.jsx)(`input`,{className:Q,value:n.name,onChange:ne}),t[21]=n.name,t[22]=ne,t[23]=j):j=t[23];let M;t[24]!==r.form.name||t[25]!==j?(M=(0,Z.jsx)($,{label:r.form.name,children:j}),t[24]=r.form.name,t[25]=j,t[26]=M):M=t[26];let N;t[27]===S?N=t[28]:(N=e=>S({description:e.target.value}),t[27]=S,t[28]=N);let P;t[29]!==n.description||t[30]!==N?(P=(0,Z.jsx)(`input`,{className:Q,value:n.description,onChange:N}),t[29]=n.description,t[30]=N,t[31]=P):P=t[31];let re;t[32]!==r.form.description||t[33]!==P?(re=(0,Z.jsx)($,{label:r.form.description,children:P}),t[32]=r.form.description,t[33]=P,t[34]=re):re=t[34];let F;t[35]!==n.projectId||t[36]!==r.form.noProject||t[37]!==r.form.project||t[38]!==b||t[39]!==a||t[40]!==S?(F=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($t)]})}),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]=F):F=t[41];let L;t[42]===r.form.trigger?L=t[43]:(L=(0,Z.jsx)(en,{title:r.form.trigger}),t[42]=r.form.trigger,t[43]=L);let ie;t[44]===S?ie=t[45]:(ie=e=>S({triggerMode:e.target.value}),t[44]=S,t[45]=ie);let ae;t[46]===r.trigger.manual?ae=t[47]:(ae=(0,Z.jsx)(s,{value:`manual`,children:r.trigger.manual}),t[46]=r.trigger.manual,t[47]=ae);let oe;t[48]===r.trigger.once?oe=t[49]:(oe=(0,Z.jsx)(s,{value:`once`,children:r.trigger.once}),t[48]=r.trigger.once,t[49]=oe);let R;t[50]===r.trigger.daily?R=t[51]:(R=(0,Z.jsx)(s,{value:`daily`,children:r.trigger.daily}),t[50]=r.trigger.daily,t[51]=R);let se;t[52]===r.trigger.weekly?se=t[53]:(se=(0,Z.jsx)(s,{value:`weekly`,children:r.trigger.weekly}),t[52]=r.trigger.weekly,t[53]=se);let ce;t[54]===r.trigger.interval?ce=t[55]:(ce=(0,Z.jsx)(s,{value:`interval`,children:r.trigger.interval}),t[54]=r.trigger.interval,t[55]=ce);let le;t[56]===r.trigger.customCron?le=t[57]:(le=(0,Z.jsx)(s,{value:`cron`,children:r.trigger.customCron}),t[56]=r.trigger.customCron,t[57]=le);let z;t[58]===r.trigger.webhook?z=t[59]:(z=(0,Z.jsx)(s,{value:`webhook`,children:r.trigger.webhook}),t[58]=r.trigger.webhook,t[59]=z);let ue;t[60]===r.trigger.taskBlocked?ue=t[61]:(ue=(0,Z.jsx)(s,{value:`taskBlocked`,children:r.trigger.taskBlocked}),t[60]=r.trigger.taskBlocked,t[61]=ue);let de;t[62]===r.trigger.noteCreated?de=t[63]:(de=(0,Z.jsx)(s,{value:`noteCreated`,children:r.trigger.noteCreated}),t[62]=r.trigger.noteCreated,t[63]=de);let fe;t[64]===r.trigger.workflowFailed?fe=t[65]:(fe=(0,Z.jsx)(s,{value:`workflowFailed`,children:r.trigger.workflowFailed}),t[64]=r.trigger.workflowFailed,t[65]=fe);let V;t[66]===r.trigger.sessionUpdated?V=t[67]:(V=(0,Z.jsx)(s,{value:`sessionUpdated`,children:r.trigger.sessionUpdated}),t[66]=r.trigger.sessionUpdated,t[67]=V);let H;t[68]===r.trigger.customEvent?H=t[69]:(H=(0,Z.jsx)(s,{value:`event`,children:r.trigger.customEvent}),t[68]=r.trigger.customEvent,t[69]=H);let U;t[70]!==n.triggerMode||t[71]!==ie||t[72]!==ae||t[73]!==oe||t[74]!==R||t[75]!==se||t[76]!==ce||t[77]!==le||t[78]!==z||t[79]!==ue||t[80]!==de||t[81]!==fe||t[82]!==V||t[83]!==H?(U=(0,Z.jsxs)(o,{className:Q,value:n.triggerMode,onChange:ie,children:[ae,oe,R,se,ce,le,z,ue,de,fe,V,H]}),t[70]=n.triggerMode,t[71]=ie,t[72]=ae,t[73]=oe,t[74]=R,t[75]=se,t[76]=ce,t[77]=le,t[78]=z,t[79]=ue,t[80]=de,t[81]=fe,t[82]=V,t[83]=H,t[84]=U):U=t[84];let he;t[85]!==n.onceAt||t[86]!==n.triggerMode||t[87]!==r.form.onceAt||t[88]!==S?(he=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]=he):he=t[89];let ge;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?(ge=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)(pe,{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]=ge):ge=t[97];let W=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,`:`,te.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:`{
|