@xopcai/xopc 0.0.243 → 0.0.244
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DDH4HgP7.js → agent-avatar-dicebear-BhXGsupm.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-BDCfJZhh.js → agent-defaults-settings-panel-Blzn2H6t.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-B0ZWgf-U.js → agents-Cmp-z8Y_.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-Blfwszzn.js → app-management-settings-panel-CezjAP1K.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-C3V7Na75.js → appearance-settings-C-CfS05x.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-BiEks0-F.js → apps-page-7Y13_bqZ.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-BS-S4LJ9.js → attachment-load-DI4CoIga.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-C7Y3L30D.js → automations-page-D04Xceck.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-A3zPkPuo.js → automations-workspace-wEO1OWk0.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-BM9B5kcm.js → binary-plugins-BJQe8TRu.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-BbnpkYP9.js → block-editor-BSzGjJC6.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-Dk4FQ7fY.js → browser-settings-page-DjAZ_LF2.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-B9qGL-it.js → browser-workflows-page-CwbxA3B7.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-settings-panel--tR_El9e.js → capabilities-settings-panel-jt9bqUMK.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-D347vl_J.js → channels-settings-Cz_TWY3a.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-DABPvwBT.js → chat-terminal-dock-D3gj2D3U.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-B-tvJkRJ.js → connectors-page-Shs5vbzx.js} +1 -1
- package/dist/gateway/static/root/assets/{cron-expression-D3bsKbNd.js → cron-expression-DgWHw0jX.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-BsGM6Yty.js → date-picker-CKg-RPbs.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-Dj3g6YXZ.js → dependency-picker-CVYkw-NN.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-C1QT0Sur.js → desktop-pet-Bf46oXTY.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-r6kAOnfY.js → desktop-pet-settings-BJO_klc7.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DOkf7nh9.js → extension-debug-page-T2PmFFOW.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-Cq2IA4Ho.js → extension-page-2wAE2RCe.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DQn4qjDZ.js → extension-settings-page-Y9ZiCJ21.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-DM3poL22.js → gateway-config-api-DaYY1Gkn.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-DPgH1hnh.js → gateway-settings-eO3IzW_J.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-Bk80-E3b.js → heartbeat-settings-BAgrkyHc.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-DKo5JiMR.js → home-page-GTjKH7LK.js} +1 -1
- package/dist/gateway/static/root/assets/{index-B0WJL9N1.js → index-DUz0O54y.js} +8 -8
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BEwvd8ZU.js → keyboard-shortcuts-settings-CWGqL6o5.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page--eJ5rmNj.js → local-app-workbench-page-DKJ-rks0.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-CgkY9E-r.js → local-apps-page-Bfidv29d.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-Z49Td0J9.js → logs-page-DwAHrPbF.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-Dv8NSJKt.js → management-settings-BG7j1I9f.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-Cm0RBB-t.js → markdown-split-AnmmpLs6.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-Bcr5sU1f.js → media-plugins-CGS-05cE.js} +1 -1
- package/dist/gateway/static/root/assets/{mobile-pairing-wizard-kKDiXofY.js → mobile-pairing-wizard-DoKK5GfV.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-CgsaRaGi.js → notes-page-Lr8rsFAR.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-workbench-C1DEE09k.js → notes-workbench-ISWnKLxO.js} +2 -2
- package/dist/gateway/static/root/assets/{project-detail-page-isRapnp5.js → project-detail-page-BZqr4yam.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-zvsjg0mi.js → projects-page-Dau8733A.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-C9TGZ9Hc.js → remote-access-hub-DdChlvGP.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-2zm9edMA.js → runtime-tools-settings-panel-CmZTNv1W.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-54A5gzkN.js → schema-form-XlVPyiVQ.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-BP8RyiUn.js → sessions-page-C3kADsd4.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CSYy6SUa.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-DzDhoyxv.js → settings-page-DblUeM3V.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-uDicHU1w.js → setup-status-panel-bDfRfSnq.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-lOmLCWFS.js → share-preview-page-DBMWFMN-.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-T4Yvouvv.js → shares-settings-Bu6lIStj.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-DVb7nrXz.js → skill-reload-api-BNMc4l04.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-CnyNH3To.js → skills-page-CSOseeQe.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-CgDtf2qs.js → skills-page.utils-CniRGhkJ.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-C8yWfwtR.js → system-settings-panel-D0GqNpKy.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-Tzfjlbf3.js → task-detail-page-BRCq-nR7.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-Bvg679no.js → tunnel-api-BtjS2nrM.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-D88VGoyG.js → use-autosave-TwuAycG8.js} +1 -1
- package/dist/gateway/static/root/assets/{user-context-page-RijPtyfO.js → user-context-page-CbqPu8xZ.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-CBHLsMcc.js → voice-api-key-field-CzwG5plu.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-GGe2TQ98.js → work-discovery-overlay-DS15FzQA.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-C0layUE9.js → workflow-run-setup-panel-C_boCemi.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-DQXIzBAc.js → workflows-page-CaI2ruyy.js} +1 -1
- package/dist/gateway/static/root/index.html +1 -1
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +4 -4
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/embedded/model-runtime.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -1
- package/dist/src/agent/image/tool-model-config.js +1 -1
- package/dist/src/agent/ipc/inbox.js +1 -1
- package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +1 -1
- package/dist/src/agent/service.js +2 -2
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/tasks/task-judge-service.js +3 -3
- package/dist/src/ai-assist/text-assist.js +1 -1
- package/dist/src/auth/credentials.js +2 -2
- package/dist/src/auth/profiles/store.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +2 -2
- package/dist/src/automations/draft/automation-draft-service.js +1 -1
- package/dist/src/browser/providers/browser-ext-install.js +1 -1
- package/dist/src/cli/commands/agent.js +2 -2
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/models.js +2 -2
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/cli/commands/profile.js +1 -1
- package/dist/src/cli/commands/tunnel.js +1 -1
- package/dist/src/cli/commands/update.js +1 -1
- package/dist/src/cli/extension-cli-register.js +1 -1
- package/dist/src/config/index.js +5 -5
- package/dist/src/config/loader.js +1 -1
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/extensions/lockfile.js +1 -1
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/connectors.js +23 -23
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/sessions.js +1 -1
- package/dist/src/gateway/run-loop.js +1 -1
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service.js +6 -6
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/providers/register-runtime-providers.js +1 -1
- package/dist/src/share/hosted-session-share.js +1 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/settings-advanced-gate-D4EMxWAZ.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{p as i,t as a}from"./chunk-KS7C4IRE-BaASWQor.js";import{a as o,i as s,o as c,r as l,s as u,t as d}from"./dist-CpzYSoz7.js";import{t as f}from"./check-DUBLcKHA.js";import{t as p}from"./external-link-DjqjBmc3.js";import{t as m}from"./markdown-view-PPCLt7fu.js";import{t as h}from"./loader-circle-CifKLtgG.js";import{t as g}from"./plus-Q2yW6OE7.js";import{t as _}from"./search-DA7gz22f.js";import{t as v}from"./x-B_N4OPjy.js";import{t as y}from"./messages-CTSgFlE4.js";import{a as b,i as x,n as S,r as C,s as w}from"./locale-store-CMZljTJx.js";import{t as T}from"./cn-JdwAhgNB.js";import{a as E,i as D}from"./vendor-swr-BIWyz7Rc.js";import{t as O}from"./button-CtTvuElV.js";import{t as k}from"./skeleton-BwbyijEw.js";import{Es as ee,Gs as A,Js as j,Li as M,Ml as N,Qi as P,Ts as te,Wl as F,Xi as I,Yi as L,Zi as R,eu as ne,gc as z,oa as B,qi as V,ta as H}from"./index-B0WJL9N1.js";import{t as U}from"./page-tabs-BaEQMYm_.js";var W=e(t(),1),G=n();function K(e){return e===`builtin`||e===`user`?e:`marketplace`}async function q(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 re(e){let t=await x(C(`/api/marketplace/packages/${encodeURIComponent(e.trim())}`),{cache:`no-store`});if(!t.ok)throw Error(await q(t));let n=await t.json();if(!n.ok||!n.payload?.id)throw Error(n.error??`Invalid response`);return n.payload}async function J(e){let t=await x(C(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await q(t));let n=await t.json();if(!n.ok||!n.payload?.extensionId)throw Error(n.error??`Invalid response`);return n.payload}async function Y(e){let t=await x(C(`/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 q(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error?.message??`Invalid response`);return n.payload}async function X(e){let t=await x(C(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e})});if(!t.ok)throw Error(await q(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error??`Invalid response`);return n.payload}var Z=r();function ie(e,t){let n=e.find(e=>e.id===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var Q={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function $({className:e}){let t=y(S(e=>e.language)).extensionsPage,n=w(e=>!!e.token),r=L(),{mutate:i}=E(),[a,o]=(0,W.useReducer)(M,Q),{q:s,debounced:c,detailPkg:l,rowBusy:u,actionError:d,restartHint:f}=a,p=n?`marketplace-${c}`:null;(0,W.useEffect)(()=>{let e=window.setTimeout(()=>o({type:`patch`,patch:{debounced:s.trim()}}),300);return()=>window.clearTimeout(e)},[s]);let{data:m,isLoading:g,error:v}=D(p,async()=>b(c.length>0?C(`/api/marketplace?q=${encodeURIComponent(c)}`):C(`/api/marketplace`)),{revalidateOnFocus:!1}),x=(0,W.useCallback)(()=>{i(`gateway-extensions-list`),H()},[i]),O=(0,W.useCallback)(async(e,n)=>{o({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await J({name:e,overwrite:n});x(),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,x]),A=(0,W.useCallback)(async e=>{o({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await X(e);x(),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,x]),j=m?.extensions??[];return(0,Z.jsxs)(`div`,{className:T(`flex flex-col gap-4`,e),children:[(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(_,{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,Z.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`})]}),v?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:v instanceof Error?v.message:t.marketplaceLoadFailed}):null,d?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}):null,f?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f}):null,g&&!m?(0,Z.jsx)(`ul`,{className:`flex flex-col gap-3`,"aria-label":t.marketplaceLoading,children:[0,1,2].map(e=>(0,Z.jsx)(`li`,{className:`rounded-xl bg-surface-panel p-4 shadow-surface`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2.5`,children:[(0,Z.jsx)(k,{className:`h-5 w-40`}),(0,Z.jsx)(k,{className:`h-4 w-full max-w-xl`}),(0,Z.jsx)(k,{className:`h-4 w-2/3 max-w-md`})]}),(0,Z.jsx)(k,{className:`h-8 w-20`})]})},e))}):(0,Z.jsx)(`ul`,{className:`flex flex-col gap-3`,children:j.length===0?(0,Z.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):j.map(e=>{let n=ie(r,e.id),i=u===e.id;return(0,Z.jsx)(`li`,{className:`list-none`,children:(0,Z.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:T(`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,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,Z.jsx)(N,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,Z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.description}):null,(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,Z.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,Z.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,Z.jsx)(z,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]}),(0,Z.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,Z.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,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-medium text-fg-muted`,children:t.marketplaceInstalled}),(0,Z.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&A(e.id).catch(()=>{})},className:T(`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,Z.jsx)(h,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(ee,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,Z.jsx)(`button`,{type:`button`,onClick:()=>o({type:`patch`,patch:{detailPkg:e.id}}),className:T(`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)})}),l?(0,Z.jsx)(ae,{packageName:l,copy:t,extensions:r,onClose:()=>o({type:`patch`,patch:{detailPkg:null}}),onInstall:O,onUninstall:A}):null]})}function ae(e){let t=(0,G.c)(102),{packageName:n,copy:r,extensions:i,onClose:s,onInstall:f,onUninstall:p}=e,[g,_]=(0,W.useState)(!1),[y,b]=(0,W.useState)(!1),x=w(ue)?`ext-mp-detail-${n}`:null,S;t[0]===n?S=t[1]:(S=async()=>re(n),t[0]=n,t[1]=S);let C;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(C={revalidateOnFocus:!1},t[2]=C):C=t[2];let{data:E,error:O,isLoading:j}=D(x,S,C),M;t[3]!==i||t[4]!==n?(M=ie(i,n),t[3]=i,t[4]=n,t[5]=M):M=t[5];let N=M,P=N===`user`,F=E?.manifest?.permissions,I,L,R,z,B,V,H,U,K,q,J;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]!==E||t[29]!==O||t[30]!==N||t[31]!==j||t[32]!==s||t[33]!==F||t[34]!==y){let e=F&&typeof F==`object`&&!Array.isArray(F)?Object.entries(F):[],n;t[46]!==r.marketplaceNoReadme||t[47]!==E?(n=E?.readme?.trim()||(E?.description?.trim()?`### ${E.name}\n\n${E.description}`:`*${r.marketplaceNoReadme}*`),t[46]=r.marketplaceNoReadme,t[47]=E,t[48]=n):n=t[48];let i=n;R=d,z=!0,t[49]===s?B=t[50]:(B=e=>!e&&s(),t[49]=s,t[50]=B),L=c,t[51]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,Z.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[51]=J):J=t[51],I=l,U=`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`,K=le;let a;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(ne,{className:`size-5`}),t[52]=a):a=t[52];let f;t[53]!==r.detailBack||t[54]!==s?(f=(0,Z.jsx)(`button`,{type:`button`,onClick:s,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]=s,t[55]=f):f=t[55];let p;t[56]===r.marketplaceDetailTitle?p=t[57]:(p=(0,Z.jsx)(u,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[56]=r.marketplaceDetailTitle,t[57]=p);let h;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(v,{className:`size-5`}),t[58]=h):h=t[58];let g;t[59]!==r.detailClose||t[60]!==s?(g=(0,Z.jsx)(`button`,{type:`button`,onClick:s,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:h}),t[59]=r.detailClose,t[60]=s,t[61]=g):g=t[61],t[62]!==f||t[63]!==p||t[64]!==g?(q=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[f,p,g]}),t[62]=f,t[63]=p,t[64]=g,t[65]=q):q=t[65],V=`min-h-0 flex-1 overflow-y-auto p-5`,H=j&&!E?(0,Z.jsxs)(`div`,{className:`space-y-4`,"aria-label":r.marketplaceLoading,children:[(0,Z.jsx)(k,{className:`h-6 w-48`}),(0,Z.jsx)(k,{className:`h-4 w-28`}),(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsx)(k,{className:`h-12`}),(0,Z.jsx)(k,{className:`h-12`})]}),(0,Z.jsx)(k,{className:`h-28 w-full`}),(0,Z.jsx)(k,{className:`h-36 w-full`})]}):O?(0,Z.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,Z.jsx)(`p`,{className:`font-medium text-red-700 dark:text-red-300`,children:r.marketplaceDetailLoadFailed}),(0,Z.jsx)(`p`,{className:`mt-1 break-words text-red-600 dark:text-red-400`,children:O instanceof Error?O.message:r.marketplaceLoadFailed})]}):E?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:E.name}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,Z.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:E.id})}),(0,Z.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceAuthor}),(0,Z.jsx)(`dd`,{children:E.author.username})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,Z.jsx)(`dd`,{children:E.latestVersion.version})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,Z.jsx)(`dd`,{children:E.downloads})]})]}),N===`bundled`?null:(0,Z.jsxs)(`section`,{className:`mt-5 space-y-3 rounded-lg border border-edge bg-surface-base p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[E.installability.available?(0,Z.jsx)(A,{className:`mt-0.5 size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):(0,Z.jsx)(te,{className:`mt-0.5 size-5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:E.installability.available?r.marketplaceRiskTitle:r.marketplaceUnavailableTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:E.installability.available?r.marketplaceCodeRisk:E.installability.reason??r.marketplaceUnavailableBody})]})]}),E.installability.available?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`dl`,{className:`grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceIntegrity}),(0,Z.jsx)(`dd`,{children:r.marketplaceIntegrityVerified})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDependencies}),(0,Z.jsx)(`dd`,{children:E.packageSummary?.dependencyCount??0})]})]}),(0,Z.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-fg`,children:r.marketplacePermissions}),e.length>0?(0,Z.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(ce)}):(0,Z.jsx)(`p`,{className:`mt-1`,children:r.marketplacePermissionsNone})]}),(E.packageSummary?.lifecycleScripts.length??0)>0?(0,Z.jsxs)(`p`,{className:`text-xs leading-relaxed text-amber-700 dark:text-amber-300`,children:[r.marketplaceLifecycleScripts,`: `,E.packageSummary?.lifecycleScripts.join(`, `)]}):null,(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-[var(--color-accent)]`}),(0,Z.jsx)(`span`,{children:r.marketplaceRiskConfirm})]})]}):null]}),E.readme?.trim()?(0,Z.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:r.marketplaceDetailReadmeHeading}):null,(0,Z.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,Z.jsx)(m,{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]=E,t[29]=O,t[30]=N,t[31]=j,t[32]=s,t[33]=F,t[34]=y,t[35]=I,t[36]=L,t[37]=R,t[38]=z,t[39]=B,t[40]=V,t[41]=H,t[42]=U,t[43]=K,t[44]=q,t[45]=J}else I=t[35],L=t[36],R=t[37],z=t[38],B=t[39],V=t[40],H=t[41],U=t[42],K=t[43],q=t[44],J=t[45];let Y;t[66]!==V||t[67]!==H?(Y=(0,Z.jsx)(`div`,{className:V,children:H}),t[66]=V,t[67]=H,t[68]=Y):Y=t[68];let X;t[69]!==g||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]!==E||t[78]!==N||t[79]!==s||t[80]!==f||t[81]!==p||t[82]!==n||t[83]!==y||t[84]!==P?(X=E?(0,Z.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:N===`bundled`?(0,Z.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:r.marketplaceBuiltinManageHint}),(0,Z.jsx)(a,{to:`/extensions?tab=builtin`,onClick:s,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,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,disabled:g||!E.installability.available||!y,onClick:()=>{P&&!window.confirm(r.marketplaceReinstallConfirm)||(_(!0),f(n,P).catch(se).finally(()=>_(!1)))},className:T(`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:[g?(0,Z.jsx)(h,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,P?r.marketplaceReinstall:r.marketplaceInstall]}),P?(0,Z.jsxs)(`button`,{type:`button`,disabled:g,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(_(!0),p(n).then(()=>s()).catch(oe).finally(()=>_(!1)))},className:T(`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,Z.jsx)(ee,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[69]=g,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]=E,t[78]=N,t[79]=s,t[80]=f,t[81]=p,t[82]=n,t[83]=y,t[84]=P,t[85]=X):X=t[85];let Q;t[86]!==I||t[87]!==Y||t[88]!==X||t[89]!==U||t[90]!==K||t[91]!==q?(Q=(0,Z.jsxs)(I,{className:U,onOpenAutoFocus:K,children:[q,Y,X]}),t[86]=I,t[87]=Y,t[88]=X,t[89]=U,t[90]=K,t[91]=q,t[92]=Q):Q=t[92];let $;t[93]!==L||t[94]!==Q||t[95]!==J?($=(0,Z.jsxs)(L,{children:[J,Q]}),t[93]=L,t[94]=Q,t[95]=J,t[96]=$):$=t[96];let ae;return t[97]!==R||t[98]!==z||t[99]!==B||t[100]!==$?(ae=(0,Z.jsx)(R,{defaultOpen:z,onOpenChange:B,children:$}),t[97]=R,t[98]=z,t[99]=B,t[100]=$,t[101]=ae):ae=t[101],ae}function oe(){}function se(){}function ce(e){let[t,n]=e;return(0,Z.jsxs)(`li`,{className:`break-words`,children:[(0,Z.jsx)(`code`,{children:t}),`: `,Array.isArray(n)?n.join(`, `):String(n)]},t)}function le(e){return e.preventDefault()}function ue(e){return!!e.token}function de(){let e=S(e=>e.language),t=y(e),n=B(e=>e.setPageHeader),r=B(e=>e.clearPageHeader),o=L(),s=I(),[c,l]=i(),u=K(c.get(`tab`)),d=c.get(`q`)??``,[f,p]=(0,W.useState)(u),[m,h]=(0,W.useState)(d),[v,b]=(0,W.useState)(null),x=c.toString(),C=(0,W.useRef)(x);if(C.current!==x){C.current=x;let e=K(c.get(`tab`)),t=c.get(`q`)??``;p(t=>t===e?t:e),h(e=>e===t?e:t)}(0,W.useEffect)(()=>{l(e=>{let t=new URLSearchParams(e),n=m.trim();return n?t.set(`q`,n):t.delete(`q`),f===`marketplace`?t.delete(`tab`):t.set(`tab`,f),t.toString()===e.toString()?e:t},{replace:!0})},[f,m,l]);let w=(0,W.useMemo)(()=>o.filter(e=>e.source===`bundled`),[o]),T=(0,W.useMemo)(()=>o.filter(e=>e.source!==`bundled`),[o]),E=f===`builtin`?w:T,D=(0,W.useMemo)(()=>{let t=m.trim().toLowerCase(),n=E;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)},[E,m,e]);if((0,W.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,W.useLayoutEffect)(()=>(n({startExtra:null,main:(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.extensionsPage.title})}),end:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(O,{asChild:!0,variant:`secondary`,className:`h-9`,children:(0,Z.jsxs)(a,{to:`/local-apps`,"aria-label":t.extensionsPage.openLocalApps,title:t.extensionsPage.openLocalApps,children:[(0,Z.jsx)(F,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`hidden sm:inline`,children:t.extensionsPage.openLocalApps})]})}),(0,Z.jsx)(O,{asChild:!0,variant:`primary`,className:`h-9`,children:(0,Z.jsxs)(a,{to:`/local-apps/new`,children:[(0,Z.jsx)(g,{className:`size-4`}),t.extensionsPage.createLocalApp]})})]})}),()=>r()),[r,t.extensionsPage.createLocalApp,t.extensionsPage.openLocalApps,t.extensionsPage.title,n]),s&&f!==`marketplace`)return(0,Z.jsx)(ye,{});let k=f!==`marketplace`&&E.length>0;return(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,Z.jsxs)(`div`,{className:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[(0,Z.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-base p-3 shadow-surface sm:flex-row sm:items-center sm:justify-between`,children:[(0,Z.jsx)(U,{items:[{id:`marketplace`,label:t.extensionsPage.tabMarketplace},{id:`builtin`,label:t.extensionsPage.tabBuiltin,count:w.length},{id:`user`,label:t.extensionsPage.tabUser,count:T.length}],activeTab:f,onChange:p,ariaLabel:t.extensionsPage.extensionsNavAria,tabIdPrefix:`extensions-tab`,panelIdPrefix:`extensions-panel`,className:`flex-wrap`}),k?(0,Z.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,Z.jsx)(_,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:m,onChange:e=>h(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]}),f===`marketplace`?(0,Z.jsx)($,{}):f===`builtin`&&w.length===0?(0,Z.jsx)(xe,{message:t.extensionsPage.emptyBuiltin}):f===`user`&&T.length===0?(0,Z.jsx)(xe,{message:t.extensionsPage.emptyUser}):D.length===0?(0,Z.jsx)(`p`,{className:`rounded-xl border border-edge-subtle bg-surface-base px-3 py-8 text-center text-sm text-fg-muted shadow-surface sm:px-5 xl:px-6`,children:t.extensionsPage.noSearchResults}):(0,Z.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:D.map(e=>(0,Z.jsx)(ge,{extension:e,copy:t.extensionsPage,showSourceBadge:f===`user`,onOpen:()=>b(e)},e.id))})]}),v?(0,Z.jsx)(_e,{extension:v,copy:t.extensionsPage,onClose:()=>b(null)},v.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,G.c)(45),{extension:n,copy:r,showSourceBadge:i,onOpen:a}=e,o;t[0]===n?o=t[1]:(o=fe(n),t[0]=n,t[1]=o);let s=o,c=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=T(`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]=l):l=t[2];let u=n.name||n.id,d;t[3]===u?d=t[4]:(d=u.charAt(0).toUpperCase(),t[3]=u,t[4]=d);let p;t[5]===d?p=t[6]:(p=(0,Z.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:d}),t[5]=d,t[6]=p);let m;t[7]===n.name?m=t[8]:(m=(0,Z.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=m);let h;t[9]===n.version?h=t[10]:(h=n.version?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=h);let _;t[11]!==m||t[12]!==h?(_=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),t[11]=m,t[12]=h,t[13]=_):_=t[13];let v;t[14]!==r.statusEnabled||t[15]!==s?(v=s?(0,Z.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,Z.jsx)(f,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),r.statusEnabled]}):(0,Z.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,Z.jsx)(g,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=s,t[16]=v):v=t[16];let y;t[17]!==_||t[18]!==v?(y=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[_,v]}),t[17]=_,t[18]=v,t[19]=y):y=t[19];let b;t[20]!==r.cardNoDescription||t[21]!==n.description?(b=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=b):b=t[22];let x;t[23]===b?x=t[24]:(x=(0,Z.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:b}),t[23]=b,t[24]=x);let S=n.hasUi?r.badgeKindUi:r.badgeKindBackend,C;t[25]!==S||t[26]!==c?(C=(0,Z.jsx)(`span`,{title:c,className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:S}),t[25]=S,t[26]=c,t[27]=C):C=t[27];let w;t[28]!==r||t[29]!==n||t[30]!==i?(w=n.source===`bundled`?(0,Z.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,Z.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]=w):w=t[31];let E;t[32]!==C||t[33]!==w?(E=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[C,w]}),t[32]=C,t[33]=w,t[34]=E):E=t[34];let D;t[35]!==y||t[36]!==x||t[37]!==E?(D=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[y,x,E]}),t[35]=y,t[36]=x,t[37]=E,t[38]=D):D=t[38];let O;t[39]!==D||t[40]!==p?(O=(0,Z.jsxs)(`div`,{className:`flex gap-3`,children:[p,D]}),t[39]=D,t[40]=p,t[41]=O):O=t[41];let k;return t[42]!==a||t[43]!==O?(k=(0,Z.jsx)(`button`,{type:`button`,onClick:a,className:l,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}=E(),[i,f]=(0,W.useState)(!1),[m,g]=(0,W.useState)(null),[_,y]=(0,W.useState)(!1),b=e.activationEligible===!0,x=(0,W.useCallback)(async()=>{if(e.source===`bundled`){g(null),y(!1),f(!0);try{let{requiresGatewayRestart:t}=await Y({extensionId:e.id,enabled:!b});await r(`gateway-extensions-list`),H(),y(t)}catch(e){g(e instanceof Error?e.message:t.builtinToggleFailed)}finally{f(!1)}}},[b,t.builtinToggleFailed,e.id,e.source,r]),S=e.ui?.contributions?.pages??[],C=e.ui?.contributions?.settingsPanels??[],w=e.ui?.contributions?.chatWidgets??[],D=e.ui?.contributions?.sidebarPanels??[],k=S.find(e=>e.showInNav)??S[0],ee=C[0],A=k?V(e.id,k):null,M=ee?`/settings/ext/${e.id}/${ee.id}`:e.hasConfigSchema||R(e)?`/settings/ext/${e.id}`:null;return(0,Z.jsx)(d,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,Z.jsxs)(c,{children:[(0,Z.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,Z.jsxs)(l,{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,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,Z.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,Z.jsx)(ne,{className:`size-5`})}),(0,Z.jsx)(u,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,Z.jsxs)(s,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,Z.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,Z.jsx)(v,{className:`size-5`})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,Z.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,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,Z.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,pe(e,t)]}),e.version?(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,Z.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:he(e,t)}),e.source===`bundled`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.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,Z.jsxs)(`div`,{className:`mt-3 rounded-lg bg-surface-hover/40 p-3 shadow-surface dark:bg-surface-hover/20`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,Z.jsx)(O,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void x(),className:`shrink-0 py-1.5 text-xs`,children:i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(h,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):b?t.builtinToggleDisable:t.builtinToggleEnable})]}),m?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:m}):null,_?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null]})]}):(0,Z.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&&(S.length>0||C.length>0||w.length>0)?(0,Z.jsxs)(`section`,{className:`mt-8`,children:[(0,Z.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,Z.jsx)(ve,{template:t.badgePages,count:S.length,hidden:S.length===0}),(0,Z.jsx)(ve,{template:t.badgeSettings,count:C.length,hidden:C.length===0}),(0,Z.jsx)(ve,{template:t.badgeWidgets,count:w.length,hidden:w.length===0}),(0,Z.jsx)(ve,{template:t.badgeSidebar,count:D.length,hidden:D.length===0})]})]}):null,P(e)&&(A||M)?(0,Z.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[A?(0,Z.jsxs)(a,{to:A,onClick:n,className:T(`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,Z.jsx)(p,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,M?(0,Z.jsxs)(a,{to:M,onClick:n,className:T(`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,Z.jsx)(j,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,Z.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function ve(e){let t=(0,G.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,Z.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,G.c)(5),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),n=(0,Z.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),r=(0,Z.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,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,Z.jsxs)(`div`,{className:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[t,n,r,(0,Z.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,Z.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,G.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.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,Z.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{p as i,t as a}from"./chunk-KS7C4IRE-BaASWQor.js";import{a as o,i as s,o as c,r as l,s as u,t as d}from"./dist-CpzYSoz7.js";import{t as f}from"./check-DUBLcKHA.js";import{t as p}from"./external-link-DjqjBmc3.js";import{t as m}from"./markdown-view-PPCLt7fu.js";import{t as h}from"./loader-circle-CifKLtgG.js";import{t as g}from"./plus-Q2yW6OE7.js";import{t as _}from"./search-DA7gz22f.js";import{t as v}from"./x-B_N4OPjy.js";import{t as y}from"./messages-CTSgFlE4.js";import{a as b,i as x,n as S,r as C,s as w}from"./locale-store-CMZljTJx.js";import{t as T}from"./cn-JdwAhgNB.js";import{a as E,i as D}from"./vendor-swr-BIWyz7Rc.js";import{t as O}from"./button-CtTvuElV.js";import{t as k}from"./skeleton-BwbyijEw.js";import{Es as ee,Gs as A,Js as j,Li as M,Ml as N,Qi as P,Ts as te,Wl as F,Xi as I,Yi as L,Zi as R,eu as ne,gc as z,oa as B,qi as V,ta as H}from"./index-DUz0O54y.js";import{t as U}from"./page-tabs-BaEQMYm_.js";var W=e(t(),1),G=n();function K(e){return e===`builtin`||e===`user`?e:`marketplace`}async function q(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 re(e){let t=await x(C(`/api/marketplace/packages/${encodeURIComponent(e.trim())}`),{cache:`no-store`});if(!t.ok)throw Error(await q(t));let n=await t.json();if(!n.ok||!n.payload?.id)throw Error(n.error??`Invalid response`);return n.payload}async function J(e){let t=await x(C(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await q(t));let n=await t.json();if(!n.ok||!n.payload?.extensionId)throw Error(n.error??`Invalid response`);return n.payload}async function Y(e){let t=await x(C(`/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 q(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error?.message??`Invalid response`);return n.payload}async function X(e){let t=await x(C(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e})});if(!t.ok)throw Error(await q(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error??`Invalid response`);return n.payload}var Z=r();function ie(e,t){let n=e.find(e=>e.id===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var Q={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function $({className:e}){let t=y(S(e=>e.language)).extensionsPage,n=w(e=>!!e.token),r=L(),{mutate:i}=E(),[a,o]=(0,W.useReducer)(M,Q),{q:s,debounced:c,detailPkg:l,rowBusy:u,actionError:d,restartHint:f}=a,p=n?`marketplace-${c}`:null;(0,W.useEffect)(()=>{let e=window.setTimeout(()=>o({type:`patch`,patch:{debounced:s.trim()}}),300);return()=>window.clearTimeout(e)},[s]);let{data:m,isLoading:g,error:v}=D(p,async()=>b(c.length>0?C(`/api/marketplace?q=${encodeURIComponent(c)}`):C(`/api/marketplace`)),{revalidateOnFocus:!1}),x=(0,W.useCallback)(()=>{i(`gateway-extensions-list`),H()},[i]),O=(0,W.useCallback)(async(e,n)=>{o({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await J({name:e,overwrite:n});x(),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,x]),A=(0,W.useCallback)(async e=>{o({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await X(e);x(),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,x]),j=m?.extensions??[];return(0,Z.jsxs)(`div`,{className:T(`flex flex-col gap-4`,e),children:[(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(_,{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,Z.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`})]}),v?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:v instanceof Error?v.message:t.marketplaceLoadFailed}):null,d?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}):null,f?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f}):null,g&&!m?(0,Z.jsx)(`ul`,{className:`flex flex-col gap-3`,"aria-label":t.marketplaceLoading,children:[0,1,2].map(e=>(0,Z.jsx)(`li`,{className:`rounded-xl bg-surface-panel p-4 shadow-surface`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2.5`,children:[(0,Z.jsx)(k,{className:`h-5 w-40`}),(0,Z.jsx)(k,{className:`h-4 w-full max-w-xl`}),(0,Z.jsx)(k,{className:`h-4 w-2/3 max-w-md`})]}),(0,Z.jsx)(k,{className:`h-8 w-20`})]})},e))}):(0,Z.jsx)(`ul`,{className:`flex flex-col gap-3`,children:j.length===0?(0,Z.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):j.map(e=>{let n=ie(r,e.id),i=u===e.id;return(0,Z.jsx)(`li`,{className:`list-none`,children:(0,Z.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:T(`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,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,Z.jsx)(N,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,Z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.description}):null,(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,Z.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,Z.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,Z.jsx)(z,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]}),(0,Z.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,Z.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,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-medium text-fg-muted`,children:t.marketplaceInstalled}),(0,Z.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&A(e.id).catch(()=>{})},className:T(`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,Z.jsx)(h,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(ee,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,Z.jsx)(`button`,{type:`button`,onClick:()=>o({type:`patch`,patch:{detailPkg:e.id}}),className:T(`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)})}),l?(0,Z.jsx)(ae,{packageName:l,copy:t,extensions:r,onClose:()=>o({type:`patch`,patch:{detailPkg:null}}),onInstall:O,onUninstall:A}):null]})}function ae(e){let t=(0,G.c)(102),{packageName:n,copy:r,extensions:i,onClose:s,onInstall:f,onUninstall:p}=e,[g,_]=(0,W.useState)(!1),[y,b]=(0,W.useState)(!1),x=w(ue)?`ext-mp-detail-${n}`:null,S;t[0]===n?S=t[1]:(S=async()=>re(n),t[0]=n,t[1]=S);let C;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(C={revalidateOnFocus:!1},t[2]=C):C=t[2];let{data:E,error:O,isLoading:j}=D(x,S,C),M;t[3]!==i||t[4]!==n?(M=ie(i,n),t[3]=i,t[4]=n,t[5]=M):M=t[5];let N=M,P=N===`user`,F=E?.manifest?.permissions,I,L,R,z,B,V,H,U,K,q,J;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]!==E||t[29]!==O||t[30]!==N||t[31]!==j||t[32]!==s||t[33]!==F||t[34]!==y){let e=F&&typeof F==`object`&&!Array.isArray(F)?Object.entries(F):[],n;t[46]!==r.marketplaceNoReadme||t[47]!==E?(n=E?.readme?.trim()||(E?.description?.trim()?`### ${E.name}\n\n${E.description}`:`*${r.marketplaceNoReadme}*`),t[46]=r.marketplaceNoReadme,t[47]=E,t[48]=n):n=t[48];let i=n;R=d,z=!0,t[49]===s?B=t[50]:(B=e=>!e&&s(),t[49]=s,t[50]=B),L=c,t[51]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,Z.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[51]=J):J=t[51],I=l,U=`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`,K=le;let a;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(ne,{className:`size-5`}),t[52]=a):a=t[52];let f;t[53]!==r.detailBack||t[54]!==s?(f=(0,Z.jsx)(`button`,{type:`button`,onClick:s,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]=s,t[55]=f):f=t[55];let p;t[56]===r.marketplaceDetailTitle?p=t[57]:(p=(0,Z.jsx)(u,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[56]=r.marketplaceDetailTitle,t[57]=p);let h;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(v,{className:`size-5`}),t[58]=h):h=t[58];let g;t[59]!==r.detailClose||t[60]!==s?(g=(0,Z.jsx)(`button`,{type:`button`,onClick:s,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:h}),t[59]=r.detailClose,t[60]=s,t[61]=g):g=t[61],t[62]!==f||t[63]!==p||t[64]!==g?(q=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[f,p,g]}),t[62]=f,t[63]=p,t[64]=g,t[65]=q):q=t[65],V=`min-h-0 flex-1 overflow-y-auto p-5`,H=j&&!E?(0,Z.jsxs)(`div`,{className:`space-y-4`,"aria-label":r.marketplaceLoading,children:[(0,Z.jsx)(k,{className:`h-6 w-48`}),(0,Z.jsx)(k,{className:`h-4 w-28`}),(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsx)(k,{className:`h-12`}),(0,Z.jsx)(k,{className:`h-12`})]}),(0,Z.jsx)(k,{className:`h-28 w-full`}),(0,Z.jsx)(k,{className:`h-36 w-full`})]}):O?(0,Z.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,Z.jsx)(`p`,{className:`font-medium text-red-700 dark:text-red-300`,children:r.marketplaceDetailLoadFailed}),(0,Z.jsx)(`p`,{className:`mt-1 break-words text-red-600 dark:text-red-400`,children:O instanceof Error?O.message:r.marketplaceLoadFailed})]}):E?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:E.name}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,Z.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:E.id})}),(0,Z.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceAuthor}),(0,Z.jsx)(`dd`,{children:E.author.username})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,Z.jsx)(`dd`,{children:E.latestVersion.version})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,Z.jsx)(`dd`,{children:E.downloads})]})]}),N===`bundled`?null:(0,Z.jsxs)(`section`,{className:`mt-5 space-y-3 rounded-lg border border-edge bg-surface-base p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[E.installability.available?(0,Z.jsx)(A,{className:`mt-0.5 size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):(0,Z.jsx)(te,{className:`mt-0.5 size-5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:E.installability.available?r.marketplaceRiskTitle:r.marketplaceUnavailableTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:E.installability.available?r.marketplaceCodeRisk:E.installability.reason??r.marketplaceUnavailableBody})]})]}),E.installability.available?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`dl`,{className:`grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceIntegrity}),(0,Z.jsx)(`dd`,{children:r.marketplaceIntegrityVerified})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDependencies}),(0,Z.jsx)(`dd`,{children:E.packageSummary?.dependencyCount??0})]})]}),(0,Z.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-fg`,children:r.marketplacePermissions}),e.length>0?(0,Z.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(ce)}):(0,Z.jsx)(`p`,{className:`mt-1`,children:r.marketplacePermissionsNone})]}),(E.packageSummary?.lifecycleScripts.length??0)>0?(0,Z.jsxs)(`p`,{className:`text-xs leading-relaxed text-amber-700 dark:text-amber-300`,children:[r.marketplaceLifecycleScripts,`: `,E.packageSummary?.lifecycleScripts.join(`, `)]}):null,(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-[var(--color-accent)]`}),(0,Z.jsx)(`span`,{children:r.marketplaceRiskConfirm})]})]}):null]}),E.readme?.trim()?(0,Z.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:r.marketplaceDetailReadmeHeading}):null,(0,Z.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,Z.jsx)(m,{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]=E,t[29]=O,t[30]=N,t[31]=j,t[32]=s,t[33]=F,t[34]=y,t[35]=I,t[36]=L,t[37]=R,t[38]=z,t[39]=B,t[40]=V,t[41]=H,t[42]=U,t[43]=K,t[44]=q,t[45]=J}else I=t[35],L=t[36],R=t[37],z=t[38],B=t[39],V=t[40],H=t[41],U=t[42],K=t[43],q=t[44],J=t[45];let Y;t[66]!==V||t[67]!==H?(Y=(0,Z.jsx)(`div`,{className:V,children:H}),t[66]=V,t[67]=H,t[68]=Y):Y=t[68];let X;t[69]!==g||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]!==E||t[78]!==N||t[79]!==s||t[80]!==f||t[81]!==p||t[82]!==n||t[83]!==y||t[84]!==P?(X=E?(0,Z.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:N===`bundled`?(0,Z.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:r.marketplaceBuiltinManageHint}),(0,Z.jsx)(a,{to:`/extensions?tab=builtin`,onClick:s,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,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,disabled:g||!E.installability.available||!y,onClick:()=>{P&&!window.confirm(r.marketplaceReinstallConfirm)||(_(!0),f(n,P).catch(se).finally(()=>_(!1)))},className:T(`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:[g?(0,Z.jsx)(h,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,P?r.marketplaceReinstall:r.marketplaceInstall]}),P?(0,Z.jsxs)(`button`,{type:`button`,disabled:g,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(_(!0),p(n).then(()=>s()).catch(oe).finally(()=>_(!1)))},className:T(`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,Z.jsx)(ee,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[69]=g,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]=E,t[78]=N,t[79]=s,t[80]=f,t[81]=p,t[82]=n,t[83]=y,t[84]=P,t[85]=X):X=t[85];let Q;t[86]!==I||t[87]!==Y||t[88]!==X||t[89]!==U||t[90]!==K||t[91]!==q?(Q=(0,Z.jsxs)(I,{className:U,onOpenAutoFocus:K,children:[q,Y,X]}),t[86]=I,t[87]=Y,t[88]=X,t[89]=U,t[90]=K,t[91]=q,t[92]=Q):Q=t[92];let $;t[93]!==L||t[94]!==Q||t[95]!==J?($=(0,Z.jsxs)(L,{children:[J,Q]}),t[93]=L,t[94]=Q,t[95]=J,t[96]=$):$=t[96];let ae;return t[97]!==R||t[98]!==z||t[99]!==B||t[100]!==$?(ae=(0,Z.jsx)(R,{defaultOpen:z,onOpenChange:B,children:$}),t[97]=R,t[98]=z,t[99]=B,t[100]=$,t[101]=ae):ae=t[101],ae}function oe(){}function se(){}function ce(e){let[t,n]=e;return(0,Z.jsxs)(`li`,{className:`break-words`,children:[(0,Z.jsx)(`code`,{children:t}),`: `,Array.isArray(n)?n.join(`, `):String(n)]},t)}function le(e){return e.preventDefault()}function ue(e){return!!e.token}function de(){let e=S(e=>e.language),t=y(e),n=B(e=>e.setPageHeader),r=B(e=>e.clearPageHeader),o=L(),s=I(),[c,l]=i(),u=K(c.get(`tab`)),d=c.get(`q`)??``,[f,p]=(0,W.useState)(u),[m,h]=(0,W.useState)(d),[v,b]=(0,W.useState)(null),x=c.toString(),C=(0,W.useRef)(x);if(C.current!==x){C.current=x;let e=K(c.get(`tab`)),t=c.get(`q`)??``;p(t=>t===e?t:e),h(e=>e===t?e:t)}(0,W.useEffect)(()=>{l(e=>{let t=new URLSearchParams(e),n=m.trim();return n?t.set(`q`,n):t.delete(`q`),f===`marketplace`?t.delete(`tab`):t.set(`tab`,f),t.toString()===e.toString()?e:t},{replace:!0})},[f,m,l]);let w=(0,W.useMemo)(()=>o.filter(e=>e.source===`bundled`),[o]),T=(0,W.useMemo)(()=>o.filter(e=>e.source!==`bundled`),[o]),E=f===`builtin`?w:T,D=(0,W.useMemo)(()=>{let t=m.trim().toLowerCase(),n=E;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)},[E,m,e]);if((0,W.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,W.useLayoutEffect)(()=>(n({startExtra:null,main:(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.extensionsPage.title})}),end:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(O,{asChild:!0,variant:`secondary`,className:`h-9`,children:(0,Z.jsxs)(a,{to:`/local-apps`,"aria-label":t.extensionsPage.openLocalApps,title:t.extensionsPage.openLocalApps,children:[(0,Z.jsx)(F,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`hidden sm:inline`,children:t.extensionsPage.openLocalApps})]})}),(0,Z.jsx)(O,{asChild:!0,variant:`primary`,className:`h-9`,children:(0,Z.jsxs)(a,{to:`/local-apps/new`,children:[(0,Z.jsx)(g,{className:`size-4`}),t.extensionsPage.createLocalApp]})})]})}),()=>r()),[r,t.extensionsPage.createLocalApp,t.extensionsPage.openLocalApps,t.extensionsPage.title,n]),s&&f!==`marketplace`)return(0,Z.jsx)(ye,{});let k=f!==`marketplace`&&E.length>0;return(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,Z.jsxs)(`div`,{className:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[(0,Z.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-base p-3 shadow-surface sm:flex-row sm:items-center sm:justify-between`,children:[(0,Z.jsx)(U,{items:[{id:`marketplace`,label:t.extensionsPage.tabMarketplace},{id:`builtin`,label:t.extensionsPage.tabBuiltin,count:w.length},{id:`user`,label:t.extensionsPage.tabUser,count:T.length}],activeTab:f,onChange:p,ariaLabel:t.extensionsPage.extensionsNavAria,tabIdPrefix:`extensions-tab`,panelIdPrefix:`extensions-panel`,className:`flex-wrap`}),k?(0,Z.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,Z.jsx)(_,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:m,onChange:e=>h(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]}),f===`marketplace`?(0,Z.jsx)($,{}):f===`builtin`&&w.length===0?(0,Z.jsx)(xe,{message:t.extensionsPage.emptyBuiltin}):f===`user`&&T.length===0?(0,Z.jsx)(xe,{message:t.extensionsPage.emptyUser}):D.length===0?(0,Z.jsx)(`p`,{className:`rounded-xl border border-edge-subtle bg-surface-base px-3 py-8 text-center text-sm text-fg-muted shadow-surface sm:px-5 xl:px-6`,children:t.extensionsPage.noSearchResults}):(0,Z.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:D.map(e=>(0,Z.jsx)(ge,{extension:e,copy:t.extensionsPage,showSourceBadge:f===`user`,onOpen:()=>b(e)},e.id))})]}),v?(0,Z.jsx)(_e,{extension:v,copy:t.extensionsPage,onClose:()=>b(null)},v.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,G.c)(45),{extension:n,copy:r,showSourceBadge:i,onOpen:a}=e,o;t[0]===n?o=t[1]:(o=fe(n),t[0]=n,t[1]=o);let s=o,c=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=T(`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]=l):l=t[2];let u=n.name||n.id,d;t[3]===u?d=t[4]:(d=u.charAt(0).toUpperCase(),t[3]=u,t[4]=d);let p;t[5]===d?p=t[6]:(p=(0,Z.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:d}),t[5]=d,t[6]=p);let m;t[7]===n.name?m=t[8]:(m=(0,Z.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=m);let h;t[9]===n.version?h=t[10]:(h=n.version?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=h);let _;t[11]!==m||t[12]!==h?(_=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),t[11]=m,t[12]=h,t[13]=_):_=t[13];let v;t[14]!==r.statusEnabled||t[15]!==s?(v=s?(0,Z.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,Z.jsx)(f,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),r.statusEnabled]}):(0,Z.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,Z.jsx)(g,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=s,t[16]=v):v=t[16];let y;t[17]!==_||t[18]!==v?(y=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[_,v]}),t[17]=_,t[18]=v,t[19]=y):y=t[19];let b;t[20]!==r.cardNoDescription||t[21]!==n.description?(b=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=b):b=t[22];let x;t[23]===b?x=t[24]:(x=(0,Z.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:b}),t[23]=b,t[24]=x);let S=n.hasUi?r.badgeKindUi:r.badgeKindBackend,C;t[25]!==S||t[26]!==c?(C=(0,Z.jsx)(`span`,{title:c,className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:S}),t[25]=S,t[26]=c,t[27]=C):C=t[27];let w;t[28]!==r||t[29]!==n||t[30]!==i?(w=n.source===`bundled`?(0,Z.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,Z.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]=w):w=t[31];let E;t[32]!==C||t[33]!==w?(E=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[C,w]}),t[32]=C,t[33]=w,t[34]=E):E=t[34];let D;t[35]!==y||t[36]!==x||t[37]!==E?(D=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[y,x,E]}),t[35]=y,t[36]=x,t[37]=E,t[38]=D):D=t[38];let O;t[39]!==D||t[40]!==p?(O=(0,Z.jsxs)(`div`,{className:`flex gap-3`,children:[p,D]}),t[39]=D,t[40]=p,t[41]=O):O=t[41];let k;return t[42]!==a||t[43]!==O?(k=(0,Z.jsx)(`button`,{type:`button`,onClick:a,className:l,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}=E(),[i,f]=(0,W.useState)(!1),[m,g]=(0,W.useState)(null),[_,y]=(0,W.useState)(!1),b=e.activationEligible===!0,x=(0,W.useCallback)(async()=>{if(e.source===`bundled`){g(null),y(!1),f(!0);try{let{requiresGatewayRestart:t}=await Y({extensionId:e.id,enabled:!b});await r(`gateway-extensions-list`),H(),y(t)}catch(e){g(e instanceof Error?e.message:t.builtinToggleFailed)}finally{f(!1)}}},[b,t.builtinToggleFailed,e.id,e.source,r]),S=e.ui?.contributions?.pages??[],C=e.ui?.contributions?.settingsPanels??[],w=e.ui?.contributions?.chatWidgets??[],D=e.ui?.contributions?.sidebarPanels??[],k=S.find(e=>e.showInNav)??S[0],ee=C[0],A=k?V(e.id,k):null,M=ee?`/settings/ext/${e.id}/${ee.id}`:e.hasConfigSchema||R(e)?`/settings/ext/${e.id}`:null;return(0,Z.jsx)(d,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,Z.jsxs)(c,{children:[(0,Z.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,Z.jsxs)(l,{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,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,Z.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,Z.jsx)(ne,{className:`size-5`})}),(0,Z.jsx)(u,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,Z.jsxs)(s,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,Z.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,Z.jsx)(v,{className:`size-5`})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,Z.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,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,Z.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,pe(e,t)]}),e.version?(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,Z.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:he(e,t)}),e.source===`bundled`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.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,Z.jsxs)(`div`,{className:`mt-3 rounded-lg bg-surface-hover/40 p-3 shadow-surface dark:bg-surface-hover/20`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,Z.jsx)(O,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void x(),className:`shrink-0 py-1.5 text-xs`,children:i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(h,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):b?t.builtinToggleDisable:t.builtinToggleEnable})]}),m?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:m}):null,_?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null]})]}):(0,Z.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&&(S.length>0||C.length>0||w.length>0)?(0,Z.jsxs)(`section`,{className:`mt-8`,children:[(0,Z.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,Z.jsx)(ve,{template:t.badgePages,count:S.length,hidden:S.length===0}),(0,Z.jsx)(ve,{template:t.badgeSettings,count:C.length,hidden:C.length===0}),(0,Z.jsx)(ve,{template:t.badgeWidgets,count:w.length,hidden:w.length===0}),(0,Z.jsx)(ve,{template:t.badgeSidebar,count:D.length,hidden:D.length===0})]})]}):null,P(e)&&(A||M)?(0,Z.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[A?(0,Z.jsxs)(a,{to:A,onClick:n,className:T(`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,Z.jsx)(p,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,M?(0,Z.jsxs)(a,{to:M,onClick:n,className:T(`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,Z.jsx)(j,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,Z.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function ve(e){let t=(0,G.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,Z.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,G.c)(5),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),n=(0,Z.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),r=(0,Z.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,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,Z.jsxs)(`div`,{className:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[t,n,r,(0,Z.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,Z.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,G.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.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,Z.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/{attachment-load-BS-S4LJ9.js → attachment-load-DI4CoIga.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-process-heavy-B2_kr5EA.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-zJ_50EbN.js","assets/excel-worksheet-utils-EyvwNT4X.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{t as e}from"./preload-helper-zJ_50EbN.js";import{Hi as t}from"./index-
|
|
2
|
+
import{t as e}from"./preload-helper-zJ_50EbN.js";import{Hi as t}from"./index-DUz0O54y.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/pdf`||a.toLowerCase().endsWith(`.pdf`)){let{processPdf:t}=await e(async()=>{let{processPdf:e}=await import(`./attachment-process-heavy-B2_kr5EA.js`);return{processPdf:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n,preview:r}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:`application/pdf`,size:s,content:d,extractedText:n,preview:r}}if(o===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||a.toLowerCase().endsWith(`.docx`)){let{processDocx:t}=await e(async()=>{let{processDocx:e}=await import(`./attachment-process-heavy-B2_kr5EA.js`);return{processDocx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,size:s,content:d,extractedText:n}}if(o===`application/vnd.openxmlformats-officedocument.presentationml.presentation`||a.toLowerCase().endsWith(`.pptx`)){let{processPptx:t}=await e(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-B2_kr5EA.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:`application/vnd.openxmlformats-officedocument.presentationml.presentation`,size:s,content:d,extractedText:n}}if([`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`application/vnd.ms-excel`].includes(o)||a.toLowerCase().endsWith(`.xlsx`)||a.toLowerCase().endsWith(`.xls`)){let{processExcel:t}=await e(async()=>{let{processExcel:e}=await import(`./attachment-process-heavy-B2_kr5EA.js`);return{processExcel:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:o&&o.startsWith(`application/vnd`)?o:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,size:s,content:d,extractedText:n}}if(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}}throw Error(`Unsupported file type: ${o}`)}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-wEO1OWk0.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{p as i,t as a}from"./chunk-KS7C4IRE-BaASWQor.js";import{a as o,n as s,o as c,r as l,s as u,t as d}from"./dist-CpzYSoz7.js";import{n as f,r as p}from"./popover-select-C-Hj-nXR.js";import{t as ee}from"./circle-check-C23XjkUj.js";import{t as m}from"./ellipsis-0k4rZLoy.js";import{t as h}from"./markdown-view-PPCLt7fu.js";import{t as g}from"./pencil-DmIY3Oa-.js";import{t as _}from"./plus-Q2yW6OE7.js";import{t as te}from"./search-DA7gz22f.js";import{t as v}from"./x-B_N4OPjy.js";import{t as y}from"./messages-CTSgFlE4.js";import{n as b}from"./locale-store-CMZljTJx.js";import{t as x}from"./cn-JdwAhgNB.js";import{i as S}from"./vendor-swr-BIWyz7Rc.js";import{t as C}from"./button-CtTvuElV.js";import{t as w}from"./skeleton-BwbyijEw.js";import{Bl as ne,Bs as T,Es as E,Fl as re,Gi as D,Gs as ie,Ll as ae,Nl as oe,Ti as O,Wt as k,an as se,cc as A,ec as j,fs as M,in as N,iu as ce,kc as le,l as P,ln as ue,ni as F,oa as I,on as de,pc as L,sn as fe,tl as R,v as z,wc as pe}from"./index-B0WJL9N1.js";import{a as B,i as V,o as H,r as U}from"./cron-expression-D3bsKbNd.js";import{a as W,i as me,n as he,r as ge,t as _e}from"./workflow-run-setup-panel-C0layUE9.js";import{i as ve,n as ye,r as be,t as G}from"./browser-workflow-inputs-CRnkgZHI.js";var K=e(t(),1),xe=n(),Se=B();function q(e,t,n){let r=new Date;return r.setHours(e,t,0,0),r.toLocaleTimeString(n,{hour:`numeric`,minute:`2-digit`})}function Ce(e,t){let n=e===7?0:e;return new Date(Date.UTC(2023,0,1)+n*864e5).toLocaleDateString(t,{weekday:`short`,timeZone:`UTC`})}function we(e,t){return e.length<=1?e[0]??``:t.startsWith(`zh`)?e.join(`、`):e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(`, `)}, and ${e.at(-1)}`}function Te(e){return e.length===5&&e.every((e,t)=>e===t+1)}function Ee(e){if(e.length!==2)return!1;let t=[...e].toSorted((e,t)=>e-t);return t[0]===0&&t[1]===6}function De(e,t,n,r){try{let i=Se.CronExpressionParser.parse(e,{...r?.timezone?{tz:r.timezone}:{}}).fields,a=U(i.minute.values),o=U(i.hour.values),s=U(i.dayOfWeek.values),c=U(i.dayOfMonth.values);if(a.length===60&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard)return n.everyMinute;if(!i.minute.isWildcard&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard&&a.length>1){let e=V(a);if(e!=null&&e>0)return n.everyNMinutes.replace(`{{n}}`,String(e))}if(!i.minute.isWildcard&&a.length===1&&!i.hour.isWildcard&&o.length>1&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard){let e=V(o);if(e!=null&&e>0)return n.everyNHours.replace(`{{n}}`,String(e))}if(!i.minute.isWildcard&&a.length===1&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard&&o.length===24)return n.hourly;let l=!i.minute.isWildcard&&a.length===1&&!i.hour.isWildcard&&o.length===1?q(o[0],a[0],t):``;if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard)return n.dailyAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&Te(s))return n.weekdaysAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&Ee(s))return n.weekendsAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&s.length===1){let e=Ce(s[0],t);return n.weeklyOn.replace(`{{day}}`,e).replace(`{{time}}`,l)}if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&s.length>1){let e=we(s.map(e=>Ce(e,t)),t);return n.daysAt.replace(`{{days}}`,e).replace(`{{time}}`,l)}return l&&!i.dayOfMonth.isWildcard&&c.length===1&&i.month.isWildcard&&i.dayOfWeek.isWildcard?n.monthlyAt.replace(`{{day}}`,String(c[0])).replace(`{{time}}`,l):n.customSchedule}catch{return null}}function J(e,t,n,r){let i=e.trim();return i?De(i,t,n,r)||Oe(r?.nextRun,t)||n.customSchedule:Oe(r?.nextRun,t)||`—`}function Oe(e,t){if(!e)return``;let n=new Date(e);return Number.isNaN(n.getTime())?``:n.toLocaleString(t,{weekday:`short`,hour:`numeric`,minute:`2-digit`})}var ke=1e3,Y=60*ke,X=60*Y,Ae=24*X,je=7*Ae,Me=new Intl.ListFormat(`en-US`,{type:`conjunction`}),Ne=Object.fromEntries([`second`,`minute`,`hour`,`day`,`week`].map(e=>[e,new Intl.NumberFormat(`en-US`,{style:`unit`,unit:e,unitDisplay:`long`})])),Pe={en:new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),zh:new Intl.DateTimeFormat(`zh-CN`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})},Fe={en:new Intl.DateTimeFormat(`en-US`,{hour:`2-digit`,minute:`2-digit`}),zh:new Intl.DateTimeFormat(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})},Ie={minute:Y,hour:X,day:Ae,week:je};function Le(e){return e===`zh`?`zh-CN`:`en-US`}function Re(e,t,n){return n===`zh`?`${e} ${t===`week`?`周`:t===`day`?`天`:t===`hour`?`小时`:t===`minute`?`分钟`:`秒`}`:Ne[String(t)].format(e)}function ze(e,t){return t===`zh`?e.join(` `):Me.format(e)}function Be(e,t){let n=typeof e==`number`?e:Number.parseFloat(e);return Math.max(Y,Math.round((Number.isFinite(n)&&n>0?n:1)*Ie[t]))}function Ve(e,t,n){let r=typeof e==`number`?e:Number.parseFloat(e),i=Number.isFinite(r)&&r>0?r:1;return String(Number.parseFloat((i*Ie[t]/Ie[n]).toFixed(6)))}function He(e,t){let n=Math.max(ke,Math.round(e)),r=n===Ae?[{unit:`hour`,ms:X}]:n>=je&&n%je===0?[{unit:`week`,ms:je}]:n>=Ae?[{unit:`day`,ms:Ae},{unit:`hour`,ms:X},{unit:`minute`,ms:Y},{unit:`second`,ms:ke}]:n>=X?[{unit:`hour`,ms:X},{unit:`minute`,ms:Y},{unit:`second`,ms:ke}]:n>=Y?[{unit:`minute`,ms:Y},{unit:`second`,ms:ke}]:[{unit:`second`,ms:ke}],i=n,a=[];for(let{unit:e,ms:n}of r){let r=Math.floor(i/n);r<=0||(a.push(Re(r,e,t)),i%=n)}return ze(a,t)}function Ue(e,t){let n=He(e,t);return t===`zh`?`每 ${n}运行一次`:`Runs every ${n}`}function We(e,t){return Pe[t].format(new Date(e))}function Ge(e){return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())}function Ke(e,t,n=Date.now()){let r=new Date(e),i=Math.round((Ge(r)-Ge(new Date(n)))/Ae),a=Fe[t].format(r);return i===0?t===`zh`?`今天 ${a}`:`today at ${a}`:i===1?t===`zh`?`明天 ${a}`:`tomorrow at ${a}`:i===-1?t===`zh`?`昨天 ${a}`:`yesterday at ${a}`:We(e,t)}function qe(e,t){return e.eventType===`task.attention_required.v2`&&e.payloadMatch?.reason===`blocked`?t.trigger.taskBlockedWhen:e.eventType===`note.created`?t.trigger.noteCreatedWhen:e.eventType===`workflow.run.completed`&&e.payloadMatch?.status===`failed`?t.trigger.workflowFailedWhen:e.eventType===`session.transcript.updated`?t.trigger.sessionUpdatedWhen:t.trigger.eventWithType.replace(`{type}`,e.eventType)}function Je(e,t,n,r){if(e.kind===`manual`)return t.trigger.manualWhen;if(e.kind===`webhook`)return t.trigger.webhookWhen;if(e.kind===`event`)return qe(e,t);let i=e.schedule;return i.kind===`once`?t.trigger.onceAt.replace(`{time}`,Ke(Date.parse(i.at),r)):i.kind===`interval`?Ue(i.everyMs,r):J(i.expr,Le(r),n.scheduleBadge,{timezone:i.tz})}function Ye(e,t,n,r=Date.now()){return e.enabled?e.state.nextRunAtMs?Ke(e.state.nextRunAtMs,n,r):e.trigger.kind===`manual`?t.info.noAutomaticTrigger:e.trigger.kind===`event`||e.trigger.kind===`webhook`?t.info.waitingForTrigger:t.info.noUpcomingRun:t.info.pausedNoAutomaticRuns}function Xe(e,t,n,r=Date.now()){if(!e.state.lastRunAtMs)return t.info.notRunYet;let i=Ke(e.state.lastRunAtMs,n,r),a=e.state.lastRunStatus;return a?`${i} · ${t.status[a]}`:i}var Ze={name:``,description:``,projectId:``,triggerMode:`daily`,time:`09:00`,weekday:`1`,intervalValue:`1`,intervalUnit:`hour`,cronExpr:`0 9 * * *`,webhookSecretId:``,onceAt:``,eventType:``,eventSource:``,eventPayloadMatch:``,actionMode:`agent`,agentId:``,instruction:``,workflowId:``,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0,browserWorkflowId:``,browserWorkflowInputs:{},safetyMode:`suggest_only`,timeoutSeconds:`1800`,conversationMode:`new_session`,notificationPolicy:`attention`,completionWebhookUrl:``,disableAfterFailures:`3`},Qe=[{value:`15`,unit:`minute`},{value:`30`,unit:`minute`},{value:`1`,unit:`hour`},{value:`6`,unit:`hour`},{value:`24`,unit:`hour`}];function $e(e,t){let[n,r]=e.time.split(`:`),i=Number.parseInt(n||`9`,10),a=Number.parseInt(r||`0`,10),o;if(e.triggerMode===`manual`)o={kind:`manual`};else if(e.triggerMode===`once`)o={kind:`schedule`,schedule:{kind:`once`,at:new Date(e.onceAt).toISOString()}};else if(e.triggerMode===`webhook`)o={kind:`webhook`,...e.webhookSecretId.trim()?{secretId:e.webhookSecretId.trim()}:{}};else if(e.triggerMode===`taskBlocked`)o={kind:`event`,eventType:`task.attention_required.v2`,source:`tasks`,payloadMatch:{reason:`blocked`}};else if(e.triggerMode===`noteCreated`)o={kind:`event`,eventType:`note.created`,source:`notes`};else if(e.triggerMode===`workflowFailed`)o={kind:`event`,eventType:`workflow.run.completed`,source:`workflows`,payloadMatch:{status:`failed`}};else if(e.triggerMode===`sessionUpdated`)o={kind:`event`,eventType:`session.transcript.updated`,source:`sessions`};else if(e.triggerMode===`event`){let t=e.eventPayloadMatch.trim()?JSON.parse(e.eventPayloadMatch):void 0;o={kind:`event`,eventType:e.eventType.trim(),...e.eventSource.trim()?{source:e.eventSource.trim()}:{},...t?{payloadMatch:t}:{}}}else o=e.triggerMode===`interval`?{kind:`schedule`,schedule:{kind:`interval`,everyMs:Be(e.intervalValue,e.intervalUnit)}}:e.triggerMode===`weekly`?{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * ${e.weekday}`}}:e.triggerMode===`cron`?{kind:`schedule`,schedule:{kind:`cron`,expr:e.cronExpr.trim()}}:{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * *`}};let s=ge(t,e.workflowInput),c=e.workflowInput.goal.trim()||e.workflowGoal.trim(),l=e.actionMode===`browser_recipe`?`auto_apply`:e.safetyMode,u;return u=e.actionMode===`workflow`?{kind:`workflow`,workflowId:e.workflowId.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{},...s===void 0?{}:{input:s},...c?{goal:c}:{},...e.workflowInput.concurrency.trim()?{concurrency:Math.max(1,Number.parseInt(e.workflowInput.concurrency,10)||1)}:{},...e.workflowInput.maxSubagents.trim()?{maxSubagents:Math.max(1,Number.parseInt(e.workflowInput.maxSubagents,10)||1)}:{}}:e.actionMode===`browser_recipe`?{kind:`browser_recipe`,recipeId:e.browserWorkflowId.trim(),args:e.browserWorkflowInputs}:{kind:`agent`,instruction:e.instruction.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{}},{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},...e.projectId.trim()?{projectId:e.projectId.trim()}:{},trigger:o,action:u,safety:{mode:l},conversationMode:e.conversationMode,notificationPolicy:e.notificationPolicy,...l===`auto_apply`&&e.completionWebhookUrl.trim()?{completionWebhookUrl:e.completionWebhookUrl.trim()}:{},reliability:{executionTimeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||1800),disableAfterConsecutiveFailures:Math.max(1,Number.parseInt(e.disableAfterFailures,10)||3)}}}function et(e){let t=e.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+\*$/);if(t)return{triggerMode:`daily`,time:`${t[2].padStart(2,`0`)}:${t[1].padStart(2,`0`)}`,weekday:`1`,cronExpr:e};let n=e.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+([0-6])$/);return n?{triggerMode:`weekly`,time:`${n[2].padStart(2,`0`)}:${n[1].padStart(2,`0`)}`,weekday:n[3],cronExpr:e}:{triggerMode:`cron`,time:Ze.time,weekday:Ze.weekday,cronExpr:e}}function tt(e){let t=[[`week`,10080*6e4],[`day`,1440*6e4],[`hour`,60*6e4],[`minute`,6e4]],[n,r]=t.find(([,t])=>e>=t&&e%t===0)??t.at(-1);return{intervalValue:String(e/r),intervalUnit:n}}function nt(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=t.getTimezoneOffset()*6e4;return new Date(t.getTime()-n).toISOString().slice(0,16)}function rt(e){let t=e.payloadMatch;return e.eventType===`task.attention_required.v2`&&e.source===`tasks`&&t?.reason===`blocked`?{triggerMode:`taskBlocked`}:e.eventType===`note.created`&&e.source===`notes`&&!t?{triggerMode:`noteCreated`}:e.eventType===`workflow.run.completed`&&e.source===`workflows`&&t?.status===`failed`?{triggerMode:`workflowFailed`}:e.eventType===`session.transcript.updated`&&e.source===`sessions`&&!t?{triggerMode:`sessionUpdated`}:{triggerMode:`event`,eventType:e.eventType,eventSource:e.source??``,eventPayloadMatch:t?JSON.stringify(t,null,2):``}}function it(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function at(e){if(!e.trim())return!0;try{let t=JSON.parse(e);return!!t&&typeof t==`object`&&!Array.isArray(t)&&Object.values(t).every(e=>e===null||[`string`,`number`,`boolean`].includes(typeof e))}catch{return!1}}function ot(e,t=[]){let n={triggerMode:`manual`};if(e.trigger.kind===`webhook`)n={triggerMode:`webhook`,webhookSecretId:e.trigger.secretId??``};else if(e.trigger.kind===`event`)n=rt(e.trigger);else if(e.trigger.kind===`schedule`){let t=e.trigger.schedule;t.kind===`cron`&&(n=et(t.expr)),t.kind===`interval`&&(n={triggerMode:`interval`,...tt(t.everyMs)}),t.kind===`once`&&(n={triggerMode:`once`,onceAt:nt(t.at)})}let r=e.action,i=r.kind===`workflow`?t.find(e=>e.id===r.workflowId)??null:null,a=r.kind===`workflow`?it(r.input):{},o=e.reliability?.executionTimeoutSeconds??r.timeoutSeconds??e.reliability?.timeoutSeconds??(r.kind===`browser_recipe`?600:1800);return{...Ze,...n,name:e.name,description:e.description??``,projectId:e.projectId??``,actionMode:r.kind,agentId:r.kind===`browser_recipe`?``:r.agentId??``,instruction:r.kind===`agent`?r.instruction:``,workflowId:r.kind===`workflow`?r.workflowId:``,workflowGoal:r.kind===`workflow`?r.goal??``:``,browserWorkflowId:r.kind===`browser_recipe`?r.recipeId:``,browserWorkflowInputs:r.kind===`browser_recipe`?r.args??{}:{},workflowInput:{goal:r.kind===`workflow`?r.goal??``:``,argValues:i?he(i.name,a):{},schemaInput:a,concurrency:r.kind===`workflow`&&r.concurrency?String(r.concurrency):``,maxSubagents:r.kind===`workflow`&&r.maxSubagents?String(r.maxSubagents):``},workflowInputValid:!0,safetyMode:e.safety?.mode??`auto_apply`,timeoutSeconds:String(o),conversationMode:e.conversationMode??`new_session`,notificationPolicy:e.notificationPolicy??`attention`,completionWebhookUrl:e.completionWebhookUrl??``,disableAfterFailures:String(e.reliability?.disableAfterConsecutiveFailures??3)}}function st(e,t,n){let r=$e(t,n),i=e.trigger.kind===`schedule`&&r.trigger.kind===`schedule`&&e.trigger.schedule.kind===r.trigger.schedule.kind?{...r.trigger,schedule:{...e.trigger.schedule,...r.trigger.schedule}}:r.trigger,a=r.action;return e.action.kind===`agent`&&r.action.kind===`agent`?a={...e.action,...r.action,agentId:r.action.agentId}:e.action.kind===`workflow`&&r.action.kind===`workflow`?a={...e.action,...r.action,agentId:r.action.agentId,input:r.action.input,goal:r.action.goal,concurrency:r.action.concurrency,maxSubagents:r.action.maxSubagents}:e.action.kind===`browser_recipe`&&r.action.kind===`browser_recipe`&&(a={...e.action,...r.action}),{...r,description:t.description.trim(),projectId:t.projectId.trim(),completionWebhookUrl:t.completionWebhookUrl.trim(),trigger:i,action:a,reliability:{...e.reliability,...r.reliability}}}var Z=r();function ct(e,t,n){return e?We(e,n):t.never}function lt(e,t){return e.kind===`workflow`?t.action.workflowWithId.replace(`{id}`,e.workflowId):e.kind===`browser_recipe`?`Browser automation: ${e.recipeId}`:e.agentId?t.action.agentWithId.replace(`{id}`,e.agentId):t.action.agent}function ut(e){return e.safety?.mode??`auto_apply`}function dt(e){return e===`succeeded`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`running`||e===`queued`||e===`cancelling`?`bg-blue-500/10 text-blue-700 dark:text-blue-300`:`bg-surface-hover text-fg-muted`}function ft(e,t){if(e==null)return t.never;if(e<1e3)return`${e}ms`;let n=Math.round(e/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`}function pt(e){return e.status===`running`||e.status===`queued`||e.status===`cancelling`}function mt(e){return e.status===`failed`||e.status===`timeout`||e.status===`cancelled`}function ht(e,t){if((e.state.consecutiveFailures??0)>0)return!0;let n=t.reduce((t,n)=>n.automationId===e.id&&(!t||n.createdAtMs>t.createdAtMs)?n:t,void 0);return n?mt(n):!1}function gt(e,t){return e.action.kind===`agent`?e.action.instruction:e.action.kind===`workflow`&&e.action.goal?.trim()||lt(e.action,t)}function _t(e){return(e.description?.match(/\[managed-by=([^\]]+)\]/))?.[1]?.trim()||null}function vt(e){return!!_t(e)}function yt(e){return e.description?.replace(/\s*\[managed-by=[^\]]+\]\s*/g,` `).trim()??``}function bt(e){return pt(e)?0:mt(e)?1:e.status===`succeeded`?2:3}function xt(e){return[...e].sort((e,t)=>{let n=bt(e)-bt(t);return n===0?t.createdAtMs-e.createdAtMs:n})}function St(){let e=(0,xe.c)(5),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,Z.jsx)(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(Ct)})]}),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 Ct(e,t){return(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(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 wt({projectId:e,embedded:t=!1,title:n,subtitle:r}){let a=b(e=>e.language),ee=y(a),h=ee.automations,g=ee.cron,w=I(e=>e.setPageHeader),ne=I(e=>e.clearPageHeader),[T,E]=i(),re=T.get(`run`)?.trim()??``,ie=T.get(`automation`)?.trim()??``,ae=T.get(`draft`)?.trim()??``,oe=T.get(`action`)?.trim()??``,k=T.get(`projectId`)?.trim()??``,A=e?.trim()||k,j=!!e?.trim(),ce=T.get(`autogenerate`)===`1`,le=(0,K.useRef)(``),[L,R]=(0,K.useState)(`all`),[pe,B]=(0,K.useState)(``),[V,H]=(0,K.useState)(!1),[U,W]=(0,K.useState)(`blank`),[he,ge]=(0,K.useState)(null),[_e,be]=(0,K.useState)(!1),[G,xe]=(0,K.useState)(Ze),[Se,q]=(0,K.useState)(null),[Ce,we]=(0,K.useState)(null),[Te,Ee]=(0,K.useState)(!1),[De,J]=(0,K.useState)(null),[Oe,ke]=(0,K.useState)(``),[Y,X]=(0,K.useState)(null),[Ae,je]=(0,K.useState)(!1),[Me,Ne]=(0,K.useState)(!1),[Pe,Fe]=(0,K.useState)(A),[Ie,Le]=(0,K.useState)(`new_session`),[Re,ze]=(0,K.useState)(`attention`),[Be,Ve]=(0,K.useState)(null),[He,Ue]=(0,K.useState)(!1),[We,Ge]=(0,K.useState)(!1),[Ke,qe]=(0,K.useState)(!1),[Ye,Xe]=(0,K.useState)(null),Qe=S([`automations`,A],()=>P.list(A?{projectId:A}:void 0),{refreshInterval:15e3}),et=S([`automation-runs`,A],()=>P.runs(50,void 0,A?{projectId:A}:void 0),{refreshInterval:1e4}),tt=S(Ce?`automation-run-events:${Ce}`:null,()=>P.runEvents(Ce),{refreshInterval:5e3}),nt=S(`automation-workflow-definitions`,z),rt=S(`automation-browser-workflows`,()=>ve.list()),it=S(`automation-chat-agents`,D),ct=S(`automation-projects`,()=>O({sortBy:`name`,sortOrder:`asc`,limit:200})),lt=Qe.isLoading&&!Qe.data||et.isLoading&&!et.data,ut=Qe.data?.automations??[],dt=(0,K.useMemo)(()=>xt(et.data?.runs??[]),[et.data?.runs]),ft=(0,K.useMemo)(()=>ut.filter(e=>!vt(e)),[ut]),mt=(0,K.useMemo)(()=>ut.filter(vt),[ut]),ht=(0,K.useMemo)(()=>new Set(mt.map(e=>e.id)),[mt]),_t=(0,K.useMemo)(()=>dt.filter(e=>!ht.has(e.automationId)),[dt,ht]),bt=(0,K.useMemo)(()=>dt.find(e=>e.id===Ce)??null,[dt,Ce]),Ct=(0,K.useMemo)(()=>ut.find(e=>e.id===De)??null,[ut,De]),wt=(0,K.useMemo)(()=>ut.find(e=>e.id===he)??null,[ut,he]),Et=(0,K.useMemo)(()=>dt.filter(e=>e.automationId===De).sort((e,t)=>t.createdAtMs-e.createdAtMs),[dt,De]),Dt=tt.data?.events??[],Ot=(0,K.useMemo)(()=>_t.filter(e=>!pt(e)&&e.readAtMs==null),[_t]),At=pe.trim().toLocaleLowerCase(),jt=(0,K.useMemo)(()=>(L===`system`?mt:ft).filter(e=>L===`active`&&!e.enabled||L===`paused`&&e.enabled?!1:At?[e.name,yt(e),gt(e,h),Je(e.trigger,h,g,a)].some(e=>e.toLocaleLowerCase().includes(At)):!0),[g,L,h,a,At,mt,ft,_t]),Mt=(0,K.useMemo)(()=>nt.data??[],[nt.data]),Nt=(0,K.useMemo)(()=>(rt.data?.workflows??[]).filter(e=>e.enabled),[rt.data]),It=it.data?.items??[],Lt=ct.data?.items??[],Rt=(0,K.useMemo)(()=>Mt.find(e=>e.id===G.workflowId.trim())??null,[G.workflowId,Mt]),zt=(0,K.useMemo)(()=>Nt.find(e=>e.id===G.browserWorkflowId.trim())??null,[Nt,G.browserWorkflowId]),Bt=G.actionMode===`workflow`&&(!G.workflowId.trim()||Mt.length>0&&!Mt.some(e=>e.id===G.workflowId)),Vt=G.actionMode===`workflow`&&Rt?!me(Rt,G.workflowInput,G.workflowInputValid).valid:!1,Ht=!!G.name.trim()&&(G.triggerMode!==`once`||Number.isFinite(new Date(G.onceAt).getTime()))&&(G.triggerMode!==`event`||!!G.eventType.trim()&&at(G.eventPayloadMatch))&&(G.actionMode===`workflow`?!Bt&&!Vt:G.actionMode===`browser_recipe`?zt!==null&&ye(zt,G.browserWorkflowInputs):!!G.instruction.trim()),Gt=(0,K.useMemo)(()=>[{name:h.templates.dailyAgent.name,description:h.templates.dailyAgent.description,form:{...Ze,name:h.templates.dailyAgent.name,instruction:h.templates.dailyAgent.instruction,triggerMode:`daily`}},{name:h.templates.morningWorkflow.name,description:h.templates.morningWorkflow.description,form:{...Ze,name:h.templates.morningWorkflow.formName,actionMode:`workflow`,workflowId:Mt[0]?.id??``}},{name:h.templates.webhookAgent.name,description:h.templates.webhookAgent.description,form:{...Ze,name:h.templates.webhookAgent.formName,triggerMode:`webhook`}},{name:h.templates.blockedTask.name,description:h.templates.blockedTask.description,form:{...Ze,name:h.templates.blockedTask.formName,triggerMode:`taskBlocked`,instruction:h.templates.blockedTask.instruction}},{name:h.templates.noteCreated.name,description:h.templates.noteCreated.description,form:{...Ze,name:h.templates.noteCreated.formName,triggerMode:`noteCreated`,instruction:h.templates.noteCreated.instruction}}],[h,Mt]);(0,K.useEffect)(()=>{if(jt.length===0){J(null);return}De&&jt.some(e=>e.id===De)||J(jt[0].id)},[jt,De]);let Kt=(0,K.useCallback)(async()=>{await Promise.all([Qe.mutate(),et.mutate(),tt.mutate()])},[Qe.mutate,tt.mutate,et.mutate]),qt=(0,K.useCallback)(e=>{if(j){J(null),we(null);return}E(t=>{let n=new URLSearchParams(t);return e?n.set(`projectId`,e):n.delete(`projectId`),n.delete(`automation`),n.delete(`run`),n}),J(null),we(null)},[j,E]);(0,K.useEffect)(()=>{j&&(Fe(A),xe(e=>e.projectId===A?e:{...e,projectId:A}))},[A,j]);let $=(0,K.useCallback)(e=>{if(ge(null),be(!1),W(e),H(!0),e===`blank`){xe({...Ze,projectId:A});return}ke(``),X(null),Ne(!1),Fe(A),Le(`new_session`),ze(`attention`)},[A]),Jt=(0,K.useCallback)(e=>{xe(ot(e,Mt)),ge(e.id),be(!1),J(null),W(`blank`),H(!0)},[Mt]),Yt=(0,K.useCallback)(()=>{Y&&(xe({...ot(Y.automation,Mt),projectId:Pe,conversationMode:Ie,notificationPolicy:Re}),ge(null),be(!0),W(`blank`))},[Y,Ie,Re,Pe,Mt]),Xt=(0,K.useCallback)(async()=>{qe(!0),q(null);try{await Kt()}catch(e){q(e instanceof Error?e.message:String(e))}finally{qe(!1)}},[h.feedback.actionFailed,Kt]);(0,K.useEffect)(()=>{if(!ie)return;let e=ut.find(e=>e.id===ie);e&&(R(vt(e)?`system`:`all`),J(e.id),E(e=>{let t=new URLSearchParams(e);return t.delete(`automation`),t},{replace:!0}))},[ie,ut,E]),(0,K.useEffect)(()=>{oe===`create`&&($(`blank`),E(e=>{let t=new URLSearchParams(e);return t.delete(`action`),t},{replace:!0}))},[oe,$,E]),(0,K.useEffect)(()=>{if(!ae)return;let e=`${a}:${ce?`auto`:`seed`}:${ae}`;le.current!==e&&(le.current=e,ke(ae),X(null),Ne(!1),Fe(A),W(`draft`),H(!0),E(e=>{let t=new URLSearchParams(e);return t.delete(`draft`),t.delete(`autogenerate`),t},{replace:!0}),ce&&(q(null),je(!0),P.draft({prompt:ae,language:a}).then(e=>{X(e.draft),Ne(!1)}).catch(e=>{q(e instanceof Error?e.message:String(e))}).finally(()=>{je(!1)})))},[ce,ae,a,A,E]);let Zt=(0,K.useCallback)(e=>{let t=dt.find(t=>t.id===e);if(!t||pt(t)||t.readAtMs!=null)return;let n=Date.now();et.mutate(t=>t&&{...t,runs:t.runs.map(t=>t.id===e?{...t,readAtMs:n}:t)},!1),P.markRunRead(e).catch(e=>{q(e instanceof Error?e.message:String(e)),et.mutate()})},[dt,et.mutate]),Qt=(0,K.useCallback)(e=>{Zt(e),we(e),Ee(!0),E(t=>{let n=new URLSearchParams(t);return n.set(`run`,e),n},{replace:!0})},[Zt,E]),$t=(0,K.useCallback)(e=>{J(e);let t=dt.find(t=>t.automationId===e);t&&t.readAtMs==null&&!pt(t)&&Zt(t.id)},[Zt,dt]);(0,K.useEffect)(()=>{re&&(Zt(re),we(re),Ee(!0))},[Zt,re]),(0,K.useEffect)(()=>{Ve(null),Ge(!1)},[Ce]);async function en(){if(q(null),Ht){if(_e&&Y){Xe(`draft:edit`);try{let e=$e(G,Rt),{simulation:t}=await P.simulate(e);X({...Y,automation:e,simulation:t}),Fe(G.projectId),Le(G.conversationMode),ze(G.notificationPolicy),Ne(!1),be(!1),W(`draft`)}catch(e){q(e instanceof Error?e.message:String(e))}finally{Xe(null)}return}if(wt){let e=wt.id;await tn(`automation:${e}:edit`,()=>P.update(e,st(wt,G,Rt)))&&(H(!1),ge(null),J(e));return}try{let e=$e(G,Rt),{automation:t}=await P.create(e);xe(Ze),H(!1),R(`all`),B(``),qt(t.projectId??``),await Kt(),J(t.id)}catch(e){q(e instanceof Error?e.message:String(e))}}}async function tn(e,t){q(null),Xe(e);try{return await t(),await Kt(),!0}catch(e){return q(e instanceof Error?e.message:String(e)),!1}finally{Xe(null)}}async function nn(){await tn(`runs:read-all`,()=>P.markAllRunsRead(A||void 0))}async function rn(){let e=Oe.trim();if(e){q(null),je(!0);try{X((await P.draft({prompt:e,language:a})).draft),Ne(!1)}catch(e){q(e instanceof Error?e.message:String(e))}finally{je(!1)}}}async function an(){if(!Y)return;let e=``,t=``;await tn(`draft:publish`,async()=>{let{automation:n}=await P.create({...Y.automation,...Pe?{projectId:Pe}:{projectId:void 0},conversationMode:Ie,notificationPolicy:Re});X(null),ke(``),Ne(!1),H(!1),R(`all`),B(``),e=n.id,t=n.projectId??``})&&e&&(qt(t),J(e))}async function on(){if(!Y)return;let e=``,t=``,n=``;await tn(`draft:test`,async()=>{let{automation:r}=await P.create({...Y.automation,...Pe?{projectId:Pe}:{projectId:void 0},conversationMode:Ie,notificationPolicy:Re,enabled:!1}),{run:i}=await P.runNow(r.id);e=r.id,t=r.projectId??``,n=i.id,X(null),ke(``),Ne(!1),H(!1),R(`all`),B(``)})&&e&&n&&(qt(t),J(e),Qt(n))}async function sn(e){q(null),Ue(!0),Ve(null),Ge(!1);try{Ve((await P.repairDraft(e.id,{language:a})).repair)}catch(e){q(e instanceof Error?e.message:String(e))}finally{Ue(!1)}}async function cn(e){Be&&await tn(`run:${e.id}:repair`,async()=>{await P.update(e.automationId,Be.patch),Ve(null),Ge(!1)})}let ln=(0,K.useMemo)(()=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(F,{className:`size-9 shrink-0 p-0`,loading:Ke,label:h.refresh,onClick:Xt}),(0,Z.jsxs)(C,{variant:`primary`,onClick:()=>$(`draft`),children:[(0,Z.jsx)(_,{className:`size-4`}),h.new]})]}),[h.new,h.refresh,$,Ke,Xt]);return(0,K.useLayoutEffect)(()=>{if(!t)return w({startExtra:null,main:(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:h.title}),(0,Z.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:h.subtitle})]}),end:ln}),()=>ne()},[ne,t,ln,h.subtitle,h.title,w]),(0,Z.jsxs)(`div`,{className:x(`flex min-h-0 min-w-0 flex-1 flex-col`,t?`bg-transparent`:`bg-surface-panel`),children:[(0,Z.jsxs)(`div`,{className:x(`flex w-full flex-col gap-4`,t?`py-1`:`px-3 py-5 sm:px-5 xl:px-6`),children:[t?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 rounded-xl border border-edge-subtle bg-surface-base px-4 py-3 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(M,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n||h.title})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:r||h.subtitle})]}),ln]}):null,Se?(0,Z.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:Se}):null,lt?(0,Z.jsx)(St,{}):(0,Z.jsxs)(`section`,{className:`grid min-h-0 items-start gap-4 xl:grid-cols-[20rem_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`aside`,{className:`overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`border-b border-edge-subtle p-3`,children:[j?null:(0,Z.jsxs)(f,{"aria-label":h.filters.project,className:Q,value:A,onChange:e=>qt(e.target.value),children:[(0,Z.jsx)(p,{value:``,children:h.filters.allProjects}),Lt.map(e=>(0,Z.jsx)(p,{value:e.id,children:e.name},e.id))]}),(0,Z.jsxs)(`label`,{className:x(`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`,!j&&`mt-2`),children:[(0,Z.jsx)(te,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-subtle`,value:pe,onChange:e=>B(e.target.value),placeholder:h.filters.search})]}),(0,Z.jsxs)(`nav`,{className:`mt-3 flex items-center gap-1`,"aria-label":h.filters.status,children:[[{id:`all`,label:h.filters.all},{id:`active`,label:h.filters.active},{id:`paused`,label:h.paused}].map(e=>(0,Z.jsx)(`button`,{type:`button`,className:x(`rounded-md px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,L===e.id&&`bg-surface-hover text-fg`),onClick:()=>R(e.id),children:e.label},e.id)),(0,Z.jsxs)(fe,{children:[(0,Z.jsx)(ue,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:x(`ml-auto rounded-md p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,L===`system`&&`bg-surface-hover text-fg`),"aria-label":h.system.title,children:(0,Z.jsx)(m,{className:`size-4`})})}),(0,Z.jsx)(de,{children:(0,Z.jsx)(N,{align:`end`,className:`z-70 min-w-40 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:(0,Z.jsxs)(se,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>R(`system`),children:[h.system.title,` `,mt.length]})})})]})]}),Ot.length>0&&L!==`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:[h.filters.unread,` · `,Ot.length]}),(0,Z.jsx)(`button`,{type:`button`,className:`font-medium hover:underline`,disabled:Ye===`runs:read-all`,onClick:()=>void nn(),children:h.filters.markAllRead})]}):null]}),(0,Z.jsx)(kt,{automations:jt,runs:L===`system`?dt:_t,labels:h,cronLabels:g,language:a,selectedAutomationId:De,onOpenDetails:$t})]}),Ct?(0,Z.jsx)(Ft,{automation:Ct,runs:Et,labels:h,cronLabels:g,language:a,projects:Lt,busyAction:Ye,onEdit:Jt,onSelectRun:Qt,onAction:tn}):(0,Z.jsx)(Ut,{icon:(0,Z.jsx)(M,{className:`size-5`}),title:h.empty.filtered})]})]}),(0,Z.jsx)(d,{open:V,onOpenChange:e=>{H(e),e||(ge(null),be(!1))},children:(0,Z.jsxs)(c,{children:[(0,Z.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(l,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(760px,calc(100vh-2rem))] w-[min(100%-2rem,48rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,Z.jsx)(u,{className:`text-base font-semibold text-fg`,children:U===`draft`?h.draft.title:wt?h.editTitle:_e?h.draft.editTitle:h.createTitle}),(0,Z.jsx)(s,{asChild:!0,children:(0,Z.jsx)(C,{variant:`ghost`,"aria-label":h.close,children:(0,Z.jsx)(v,{className:`size-4`})})})]}),U===`draft`?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,Z.jsx)(Tt,{labels:h,prompt:Oe,draft:Y,loading:Ae,approved:Me,publishBusy:Ye===`draft:publish`,testBusy:Ye===`draft:test`,templates:Gt,projects:Lt,projectId:Pe,conversationMode:Ie,notificationPolicy:Re,onPromptChange:ke,onGenerate:rn,onEdit:Yt,onPublish:an,onTest:on,onProjectChange:Fe,onConversationModeChange:Le,onNotificationPolicyChange:ze,projectLocked:j,onApprovedChange:Ne,onDiscard:()=>{X(null),Ne(!1)},onTemplateSelect:e=>{xe({...e,projectId:Pe}),W(`blank`)},onOpenAdvanced:()=>{xe({...Ze,projectId:Pe,conversationMode:Ie,notificationPolicy:Re}),W(`blank`)}})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Wt,{form:G,labels:h,setForm:xe,projects:Lt,workflowDefinitions:Mt,selectedWorkflow:Rt,workflowsLoading:nt.isLoading,browserWorkflows:Nt,selectedBrowserWorkflow:zt,browserWorkflowsLoading:rt.isLoading,agentOptions:It,agentsLoading:it.isLoading,language:a,projectLocked:j}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[_e?(0,Z.jsx)(C,{variant:`ghost`,onClick:()=>{be(!1),W(`draft`)},children:h.cancel}):(0,Z.jsx)(s,{asChild:!0,children:(0,Z.jsx)(C,{variant:`ghost`,children:h.cancel})}),(0,Z.jsx)(C,{variant:`primary`,onClick:en,disabled:!Ht||Ye===`draft:edit`||!!(wt&&Ye),children:Ye===`draft:edit`||wt&&Ye===`automation:${wt.id}:edit`?h.feedback.working:wt||_e?h.save:h.create})]})]})]})]})}),(0,Z.jsx)(d,{open:Te&&!!bt,onOpenChange:e=>{Ee(e),!e&&E(e=>{let t=new URLSearchParams(e);return t.delete(`run`),t},{replace:!0})},children:(0,Z.jsxs)(c,{children:[(0,Z.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(l,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(85vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,Z.jsx)(u,{className:`truncate text-base font-semibold text-fg`,children:bt?.automationName??h.dashboard.result}),(0,Z.jsx)(s,{asChild:!0,children:(0,Z.jsx)(C,{variant:`ghost`,"aria-label":h.close,children:(0,Z.jsx)(v,{className:`size-4`})})})]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Z.jsx)(Pt,{className:`rounded-none border-0`,run:bt,events:Dt,labels:h,cronLabels:g,language:a,loading:tt.isLoading,repairDraft:Be,repairLoading:He,repairApproved:We,busyAction:Ye,onRepairApprovedChange:Ge,onSuggestRepair:sn,onApplyRepair:cn})})]})]})})]})}function Tt(e){let t=(0,xe.c)(108),{labels:n,prompt:r,draft:i,loading:a,approved:o,publishBusy:s,testBusy:c,templates:l,projects:u,projectId:d,conversationMode:ee,notificationPolicy:m,onPromptChange:h,onGenerate:_,onEdit:te,onPublish:v,onTest:y,onProjectChange:b,onConversationModeChange:S,onNotificationPolicyChange:w,onApprovedChange:ne,onDiscard:E,onTemplateSelect:re,onOpenAdvanced:D,projectLocked:ie}=e,ae=s===void 0?!1:s,oe=c===void 0?!1:c,O=ie===void 0?!1:ie,k=!!(i&&i.simulation.requiredConfirmations.length>0),se;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Z.jsx)(T,{className:`size-4 text-accent`}),t[0]=se):se=t[0];let j;t[1]===n.draft.title?j=t[2]:(j=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[se,n.draft.title]}),t[1]=n.draft.title,t[2]=j);let M;t[3]===n.draft.subtitle?M=t[4]:(M=(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:n.draft.subtitle}),t[3]=n.draft.subtitle,t[4]=M);let N;t[5]!==j||t[6]!==M?(N=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[j,M]}),t[5]=j,t[6]=M,t[7]=N):N=t[7];let ce;t[8]!==a||t[9]!==r?(ce=a||!r.trim(),t[8]=a,t[9]=r,t[10]=ce):ce=t[10];let le;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,Z.jsx)(T,{className:`size-4`}),t[11]=le):le=t[11];let P=a?n.draft.generating:n.draft.generate,ue;t[12]!==_||t[13]!==P||t[14]!==ce?(ue=(0,Z.jsxs)(C,{variant:`primary`,onClick:_,disabled:ce,children:[le,P]}),t[12]=_,t[13]=P,t[14]=ce,t[15]=ue):ue=t[15];let F;t[16]!==ue||t[17]!==N?(F=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[N,ue]}),t[16]=ue,t[17]=N,t[18]=F):F=t[18];let I;t[19]===h?I=t[20]:(I=e=>h(e.target.value),t[19]=h,t[20]=I);let de;t[21]!==n.draft.placeholder||t[22]!==r||t[23]!==I?(de=(0,Z.jsx)(`textarea`,{className:`mt-4 min-h-20 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,value:r,onChange:I,placeholder:n.draft.placeholder}),t[21]=n.draft.placeholder,t[22]=r,t[23]=I,t[24]=de):de=t[24];let L=O?`sm:grid-cols-2`:`sm:grid-cols-3`,fe;t[25]===L?fe=t[26]:(fe=x(`mt-3 grid gap-3`,L),t[25]=L,t[26]=fe);let R;t[27]!==n.draft.noProject||t[28]!==n.draft.project||t[29]!==b||t[30]!==d||t[31]!==O||t[32]!==u?(R=O?null:(0,Z.jsx)($,{label:n.draft.project,children:(0,Z.jsxs)(f,{className:Q,value:d,onChange:e=>b(e.target.value),children:[(0,Z.jsx)(p,{value:``,children:n.draft.noProject}),u.map(Et)]})}),t[27]=n.draft.noProject,t[28]=n.draft.project,t[29]=b,t[30]=d,t[31]=O,t[32]=u,t[33]=R):R=t[33];let z;t[34]===S?z=t[35]:(z=e=>S(e.target.value),t[34]=S,t[35]=z);let pe;t[36]===n.draft.newConversation?pe=t[37]:(pe=(0,Z.jsx)(p,{value:`new_session`,children:n.draft.newConversation}),t[36]=n.draft.newConversation,t[37]=pe);let B;t[38]===n.draft.continuousConversation?B=t[39]:(B=(0,Z.jsx)(p,{value:`continuous`,children:n.draft.continuousConversation}),t[38]=n.draft.continuousConversation,t[39]=B);let V;t[40]!==ee||t[41]!==z||t[42]!==pe||t[43]!==B?(V=(0,Z.jsxs)(f,{className:Q,value:ee,onChange:z,children:[pe,B]}),t[40]=ee,t[41]=z,t[42]=pe,t[43]=B,t[44]=V):V=t[44];let H;t[45]!==n.draft.conversation||t[46]!==V?(H=(0,Z.jsx)($,{label:n.draft.conversation,children:V}),t[45]=n.draft.conversation,t[46]=V,t[47]=H):H=t[47];let U;t[48]===w?U=t[49]:(U=e=>w(e.target.value),t[48]=w,t[49]=U);let W;t[50]===n.draft.notifyAttention?W=t[51]:(W=(0,Z.jsx)(p,{value:`attention`,children:n.draft.notifyAttention}),t[50]=n.draft.notifyAttention,t[51]=W);let me;t[52]===n.draft.notifyAll?me=t[53]:(me=(0,Z.jsx)(p,{value:`all`,children:n.draft.notifyAll}),t[52]=n.draft.notifyAll,t[53]=me);let he;t[54]===n.draft.notifyNone?he=t[55]:(he=(0,Z.jsx)(p,{value:`none`,children:n.draft.notifyNone}),t[54]=n.draft.notifyNone,t[55]=he);let ge;t[56]!==m||t[57]!==U||t[58]!==W||t[59]!==me||t[60]!==he?(ge=(0,Z.jsxs)(f,{className:Q,value:m,onChange:U,children:[W,me,he]}),t[56]=m,t[57]=U,t[58]=W,t[59]=me,t[60]=he,t[61]=ge):ge=t[61];let _e;t[62]!==n.draft.notifications||t[63]!==ge?(_e=(0,Z.jsx)($,{label:n.draft.notifications,children:ge}),t[62]=n.draft.notifications,t[63]=ge,t[64]=_e):_e=t[64];let ve;t[65]!==fe||t[66]!==R||t[67]!==H||t[68]!==_e?(ve=(0,Z.jsxs)(`div`,{className:fe,children:[R,H,_e]}),t[65]=fe,t[66]=R,t[67]=H,t[68]=_e,t[69]=ve):ve=t[69];let ye;t[70]!==i||t[71]!==n.draft.advancedCreate||t[72]!==n.draft.suggestions||t[73]!==n.draft.suggestionsDescription||t[74]!==D||t[75]!==re||t[76]!==l?(ye=i?null:(0,Z.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.draft.suggestions}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:n.draft.suggestionsDescription})]}),(0,Z.jsx)(C,{variant:`ghost`,onClick:D,children:n.draft.advancedCreate})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:l.slice(0,4).map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-lg border border-edge-subtle bg-surface-panel p-3 text-left hover:bg-surface-hover`,onClick:()=>re(e.form),children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,Z.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:e.description})]},e.name))})]}),t[70]=i,t[71]=n.draft.advancedCreate,t[72]=n.draft.suggestions,t[73]=n.draft.suggestionsDescription,t[74]=D,t[75]=re,t[76]=l,t[77]=ye):ye=t[77];let be;t[78]!==o||t[79]!==i||t[80]!==n.draft.approval||t[81]!==n.draft.assumptions||t[82]!==n.draft.discard||t[83]!==n.draft.edit||t[84]!==n.draft.publish||t[85]!==n.draft.review||t[86]!==n.draft.risks||t[87]!==n.draft.safety||t[88]!==n.draft.testOnce||t[89]!==n.draft.testing||t[90]!==n.feedback||t[91]!==n.info||t[92]!==n.none||t[93]!==ne||t[94]!==E||t[95]!==te||t[96]!==v||t[97]!==y||t[98]!==ae||t[99]!==k||t[100]!==oe?(be=i?(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg bg-surface-base p-4 lg:grid-cols-[1fr_1fr]`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:i.automation.name}),i.automation.description?(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:i.automation.description}):null,(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,Z.jsx)(Ht,{label:n.info.when,value:i.simulation.triggerSummary}),(0,Z.jsx)(Ht,{label:n.info.run,value:i.simulation.actionSummary})]})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:n.draft.review}),(0,Z.jsx)(Dt,{title:n.draft.safety,items:[...i.simulation.safetyNotes,...i.simulation.requiredConfirmations],empty:n.none}),(0,Z.jsx)(Dt,{title:n.draft.assumptions,items:i.assumptions,empty:n.none}),(0,Z.jsx)(Dt,{title:n.draft.risks,items:i.risks,empty:n.none}),k?(0,Z.jsxs)(`label`,{className:`mt-4 flex items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:o,onChange:e=>ne(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:te,children:[(0,Z.jsx)(g,{className:`size-4`}),n.draft.edit]}),(0,Z.jsxs)(C,{variant:`secondary`,onClick:y,disabled:oe||ae||k&&!o,children:[(0,Z.jsx)(A,{className:`size-4`}),oe?n.draft.testing:n.draft.testOnce]}),(0,Z.jsx)(C,{variant:`primary`,onClick:v,disabled:ae||k&&!o,children:ae?n.feedback.working:n.draft.publish})]})]})]}):null,t[78]=o,t[79]=i,t[80]=n.draft.approval,t[81]=n.draft.assumptions,t[82]=n.draft.discard,t[83]=n.draft.edit,t[84]=n.draft.publish,t[85]=n.draft.review,t[86]=n.draft.risks,t[87]=n.draft.safety,t[88]=n.draft.testOnce,t[89]=n.draft.testing,t[90]=n.feedback,t[91]=n.info,t[92]=n.none,t[93]=ne,t[94]=E,t[95]=te,t[96]=v,t[97]=y,t[98]=ae,t[99]=k,t[100]=oe,t[101]=be):be=t[101];let G;return t[102]!==F||t[103]!==de||t[104]!==ve||t[105]!==ye||t[106]!==be?(G=(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[F,de,ve,ye,be]}),t[102]=F,t[103]=de,t[104]=ve,t[105]=ye,t[106]=be,t[107]=G):G=t[107],G}function Et(e){return(0,Z.jsx)(p,{value:e.id,children:e.name},e.id)}function Dt(e){let t=(0,xe.c)(10),{title:n,items:r,empty:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o;t[2]!==i||t[3]!==r?(o=r.length>0?r.map(Ot):(0,Z.jsx)(`li`,{className:`text-fg-muted`,children:i}),t[2]=i,t[3]=r,t[4]=o):o=t[4];let s;t[5]===o?s=t[6]:(s=(0,Z.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm text-fg`,children:o}),t[5]=o,t[6]=s);let c;return t[7]!==a||t[8]!==s?(c=(0,Z.jsxs)(`div`,{className:`mt-3`,children:[a,s]}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function Ot(e){return(0,Z.jsxs)(`li`,{children:[`- `,e]},e)}function kt(e){let t=(0,xe.c)(20),{automations:n,runs:r,labels:i,cronLabels:a,language:o,selectedAutomationId:s,onOpenDetails:c}=e;if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(M,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===i.empty.filtered?n=t[2]:(n=(0,Z.jsx)(Ut,{className:`rounded-none border-0 shadow-none`,icon:e,title:i.empty.filtered}),t[1]=i.empty.filtered,t[2]=n),n}let l;if(t[3]!==n||t[4]!==a||t[5]!==i||t[6]!==o||t[7]!==c||t[8]!==r||t[9]!==s){let e;t[11]!==a||t[12]!==i||t[13]!==o||t[14]!==c||t[15]!==r||t[16]!==s?(e=e=>{let t=r.filter(t=>t.automationId===e.id).sort(At),n=t.find(pt),l=t[0];return(0,Z.jsxs)(`button`,{type:`button`,className:x(`block w-full p-3 text-left outline-none hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,s===e.id&&`bg-surface-hover`),onClick:()=>c(e.id),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:x(`size-2 shrink-0 rounded-full`,n?`bg-blue-500`:ht(e,t)?`bg-red-500`:e.enabled?`bg-emerald-500`:`bg-fg-subtle`)}),(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),l&&l.readAtMs==null&&!pt(l)?(0,Z.jsx)(`span`,{className:`ml-auto size-2 shrink-0 rounded-full bg-blue-500`,children:(0,Z.jsx)(`span`,{className:`sr-only`,children:i.filters.unread})}):null]}),(0,Z.jsx)(`div`,{className:`mt-1 truncate pl-4 text-xs text-fg-muted`,children:Je(e.trigger,i,a,o)}),(0,Z.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center justify-between gap-2 pl-4 text-xs text-fg-subtle`,children:[(0,Z.jsx)(`span`,{className:x(`truncate`,l?.error&&`text-red-700 dark:text-red-300`),children:l?l.error||l.summary||i.status[l.status]:e.enabled?`${i.next}: ${ct(e.state.nextRunAtMs,i,o)}`:i.paused}),l?.status?(0,Z.jsx)(`span`,{className:x(`shrink-0 rounded-full px-1.5 py-0.5`,dt(l.status)),children:i.status[l.status]}):null]})]},e.id)},t[11]=a,t[12]=i,t[13]=o,t[14]=c,t[15]=r,t[16]=s,t[17]=e):e=t[17],l=n.map(e),t[3]=n,t[4]=a,t[5]=i,t[6]=o,t[7]=c,t[8]=r,t[9]=s,t[10]=l}else l=t[10];let u;return t[18]===l?u=t[19]:(u=(0,Z.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:l}),t[18]=l,t[19]=u),u}function At(e,t){return t.createdAtMs-e.createdAtMs}function jt(e,t){let n=t.events,r=e.data&&typeof e.data==`object`?e.data:{},i=typeof r.actionKind==`string`?r.actionKind:null,a=typeof r.status==`string`&&r.status in t.status?t.status[r.status]:null;switch(e.type){case`run.queued`:return e.message.toLowerCase().includes(`manual`)?n.manualQueued:e.message.toLowerCase().includes(`scheduled`)?n.scheduledQueued:n.eventQueued;case`run.started`:return n.runStarted;case`action.started`:return i?n.actionStarted.replace(`{kind}`,i):n.actionStartedFallback;case`action.completed`:return i?n.actionCompleted.replace(`{kind}`,i):n.actionCompletedFallback;case`action.failed`:return i?n.actionFailed.replace(`{kind}`,i):n.actionFailedFallback;case`completion_hook.started`:return n.completionHookStarted;case`completion_hook.completed`:return n.completionHookCompleted;case`completion_hook.failed`:return n.completionHookFailed;case`run.completed`:return a?n.runCompleted.replace(`{status}`,a):n.runCompletedFallback;default:return e.message}}function Mt(e){let t=(0,xe.c)(17),{value:n,labels:r,title:i,defaultExpanded:a}=e,[o,s]=(0,K.useState)(a===void 0?!1:a),c;t[0]===n?c=t[1]:(c=JSON.stringify(n,null,2),t[0]=n,t[1]=c);let l=c,u;t[2]===l?u=t[3]:(u=l.split(`
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{p as i,t as a}from"./chunk-KS7C4IRE-BaASWQor.js";import{a as o,n as s,o as c,r as l,s as u,t as d}from"./dist-CpzYSoz7.js";import{n as f,r as p}from"./popover-select-C-Hj-nXR.js";import{t as ee}from"./circle-check-C23XjkUj.js";import{t as m}from"./ellipsis-0k4rZLoy.js";import{t as h}from"./markdown-view-PPCLt7fu.js";import{t as g}from"./pencil-DmIY3Oa-.js";import{t as _}from"./plus-Q2yW6OE7.js";import{t as te}from"./search-DA7gz22f.js";import{t as v}from"./x-B_N4OPjy.js";import{t as y}from"./messages-CTSgFlE4.js";import{n as b}from"./locale-store-CMZljTJx.js";import{t as x}from"./cn-JdwAhgNB.js";import{i as S}from"./vendor-swr-BIWyz7Rc.js";import{t as C}from"./button-CtTvuElV.js";import{t as w}from"./skeleton-BwbyijEw.js";import{Bl as ne,Bs as T,Es as E,Fl as re,Gi as D,Gs as ie,Ll as ae,Nl as oe,Ti as O,Wt as k,an as se,cc as A,ec as j,fs as M,in as N,iu as ce,kc as le,l as P,ln as ue,ni as F,oa as I,on as de,pc as L,sn as fe,tl as R,v as z,wc as pe}from"./index-DUz0O54y.js";import{a as B,i as V,o as H,r as U}from"./cron-expression-DgWHw0jX.js";import{a as W,i as me,n as he,r as ge,t as _e}from"./workflow-run-setup-panel-C_boCemi.js";import{i as ve,n as ye,r as be,t as G}from"./browser-workflow-inputs-CRnkgZHI.js";var K=e(t(),1),xe=n(),Se=B();function q(e,t,n){let r=new Date;return r.setHours(e,t,0,0),r.toLocaleTimeString(n,{hour:`numeric`,minute:`2-digit`})}function Ce(e,t){let n=e===7?0:e;return new Date(Date.UTC(2023,0,1)+n*864e5).toLocaleDateString(t,{weekday:`short`,timeZone:`UTC`})}function we(e,t){return e.length<=1?e[0]??``:t.startsWith(`zh`)?e.join(`、`):e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(`, `)}, and ${e.at(-1)}`}function Te(e){return e.length===5&&e.every((e,t)=>e===t+1)}function Ee(e){if(e.length!==2)return!1;let t=[...e].toSorted((e,t)=>e-t);return t[0]===0&&t[1]===6}function De(e,t,n,r){try{let i=Se.CronExpressionParser.parse(e,{...r?.timezone?{tz:r.timezone}:{}}).fields,a=U(i.minute.values),o=U(i.hour.values),s=U(i.dayOfWeek.values),c=U(i.dayOfMonth.values);if(a.length===60&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard)return n.everyMinute;if(!i.minute.isWildcard&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard&&a.length>1){let e=V(a);if(e!=null&&e>0)return n.everyNMinutes.replace(`{{n}}`,String(e))}if(!i.minute.isWildcard&&a.length===1&&!i.hour.isWildcard&&o.length>1&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard){let e=V(o);if(e!=null&&e>0)return n.everyNHours.replace(`{{n}}`,String(e))}if(!i.minute.isWildcard&&a.length===1&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard&&o.length===24)return n.hourly;let l=!i.minute.isWildcard&&a.length===1&&!i.hour.isWildcard&&o.length===1?q(o[0],a[0],t):``;if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard)return n.dailyAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&Te(s))return n.weekdaysAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&Ee(s))return n.weekendsAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&s.length===1){let e=Ce(s[0],t);return n.weeklyOn.replace(`{{day}}`,e).replace(`{{time}}`,l)}if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&s.length>1){let e=we(s.map(e=>Ce(e,t)),t);return n.daysAt.replace(`{{days}}`,e).replace(`{{time}}`,l)}return l&&!i.dayOfMonth.isWildcard&&c.length===1&&i.month.isWildcard&&i.dayOfWeek.isWildcard?n.monthlyAt.replace(`{{day}}`,String(c[0])).replace(`{{time}}`,l):n.customSchedule}catch{return null}}function J(e,t,n,r){let i=e.trim();return i?De(i,t,n,r)||Oe(r?.nextRun,t)||n.customSchedule:Oe(r?.nextRun,t)||`—`}function Oe(e,t){if(!e)return``;let n=new Date(e);return Number.isNaN(n.getTime())?``:n.toLocaleString(t,{weekday:`short`,hour:`numeric`,minute:`2-digit`})}var ke=1e3,Y=60*ke,X=60*Y,Ae=24*X,je=7*Ae,Me=new Intl.ListFormat(`en-US`,{type:`conjunction`}),Ne=Object.fromEntries([`second`,`minute`,`hour`,`day`,`week`].map(e=>[e,new Intl.NumberFormat(`en-US`,{style:`unit`,unit:e,unitDisplay:`long`})])),Pe={en:new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),zh:new Intl.DateTimeFormat(`zh-CN`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})},Fe={en:new Intl.DateTimeFormat(`en-US`,{hour:`2-digit`,minute:`2-digit`}),zh:new Intl.DateTimeFormat(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})},Ie={minute:Y,hour:X,day:Ae,week:je};function Le(e){return e===`zh`?`zh-CN`:`en-US`}function Re(e,t,n){return n===`zh`?`${e} ${t===`week`?`周`:t===`day`?`天`:t===`hour`?`小时`:t===`minute`?`分钟`:`秒`}`:Ne[String(t)].format(e)}function ze(e,t){return t===`zh`?e.join(` `):Me.format(e)}function Be(e,t){let n=typeof e==`number`?e:Number.parseFloat(e);return Math.max(Y,Math.round((Number.isFinite(n)&&n>0?n:1)*Ie[t]))}function Ve(e,t,n){let r=typeof e==`number`?e:Number.parseFloat(e),i=Number.isFinite(r)&&r>0?r:1;return String(Number.parseFloat((i*Ie[t]/Ie[n]).toFixed(6)))}function He(e,t){let n=Math.max(ke,Math.round(e)),r=n===Ae?[{unit:`hour`,ms:X}]:n>=je&&n%je===0?[{unit:`week`,ms:je}]:n>=Ae?[{unit:`day`,ms:Ae},{unit:`hour`,ms:X},{unit:`minute`,ms:Y},{unit:`second`,ms:ke}]:n>=X?[{unit:`hour`,ms:X},{unit:`minute`,ms:Y},{unit:`second`,ms:ke}]:n>=Y?[{unit:`minute`,ms:Y},{unit:`second`,ms:ke}]:[{unit:`second`,ms:ke}],i=n,a=[];for(let{unit:e,ms:n}of r){let r=Math.floor(i/n);r<=0||(a.push(Re(r,e,t)),i%=n)}return ze(a,t)}function Ue(e,t){let n=He(e,t);return t===`zh`?`每 ${n}运行一次`:`Runs every ${n}`}function We(e,t){return Pe[t].format(new Date(e))}function Ge(e){return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())}function Ke(e,t,n=Date.now()){let r=new Date(e),i=Math.round((Ge(r)-Ge(new Date(n)))/Ae),a=Fe[t].format(r);return i===0?t===`zh`?`今天 ${a}`:`today at ${a}`:i===1?t===`zh`?`明天 ${a}`:`tomorrow at ${a}`:i===-1?t===`zh`?`昨天 ${a}`:`yesterday at ${a}`:We(e,t)}function qe(e,t){return e.eventType===`task.attention_required.v2`&&e.payloadMatch?.reason===`blocked`?t.trigger.taskBlockedWhen:e.eventType===`note.created`?t.trigger.noteCreatedWhen:e.eventType===`workflow.run.completed`&&e.payloadMatch?.status===`failed`?t.trigger.workflowFailedWhen:e.eventType===`session.transcript.updated`?t.trigger.sessionUpdatedWhen:t.trigger.eventWithType.replace(`{type}`,e.eventType)}function Je(e,t,n,r){if(e.kind===`manual`)return t.trigger.manualWhen;if(e.kind===`webhook`)return t.trigger.webhookWhen;if(e.kind===`event`)return qe(e,t);let i=e.schedule;return i.kind===`once`?t.trigger.onceAt.replace(`{time}`,Ke(Date.parse(i.at),r)):i.kind===`interval`?Ue(i.everyMs,r):J(i.expr,Le(r),n.scheduleBadge,{timezone:i.tz})}function Ye(e,t,n,r=Date.now()){return e.enabled?e.state.nextRunAtMs?Ke(e.state.nextRunAtMs,n,r):e.trigger.kind===`manual`?t.info.noAutomaticTrigger:e.trigger.kind===`event`||e.trigger.kind===`webhook`?t.info.waitingForTrigger:t.info.noUpcomingRun:t.info.pausedNoAutomaticRuns}function Xe(e,t,n,r=Date.now()){if(!e.state.lastRunAtMs)return t.info.notRunYet;let i=Ke(e.state.lastRunAtMs,n,r),a=e.state.lastRunStatus;return a?`${i} · ${t.status[a]}`:i}var Ze={name:``,description:``,projectId:``,triggerMode:`daily`,time:`09:00`,weekday:`1`,intervalValue:`1`,intervalUnit:`hour`,cronExpr:`0 9 * * *`,webhookSecretId:``,onceAt:``,eventType:``,eventSource:``,eventPayloadMatch:``,actionMode:`agent`,agentId:``,instruction:``,workflowId:``,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0,browserWorkflowId:``,browserWorkflowInputs:{},safetyMode:`suggest_only`,timeoutSeconds:`1800`,conversationMode:`new_session`,notificationPolicy:`attention`,completionWebhookUrl:``,disableAfterFailures:`3`},Qe=[{value:`15`,unit:`minute`},{value:`30`,unit:`minute`},{value:`1`,unit:`hour`},{value:`6`,unit:`hour`},{value:`24`,unit:`hour`}];function $e(e,t){let[n,r]=e.time.split(`:`),i=Number.parseInt(n||`9`,10),a=Number.parseInt(r||`0`,10),o;if(e.triggerMode===`manual`)o={kind:`manual`};else if(e.triggerMode===`once`)o={kind:`schedule`,schedule:{kind:`once`,at:new Date(e.onceAt).toISOString()}};else if(e.triggerMode===`webhook`)o={kind:`webhook`,...e.webhookSecretId.trim()?{secretId:e.webhookSecretId.trim()}:{}};else if(e.triggerMode===`taskBlocked`)o={kind:`event`,eventType:`task.attention_required.v2`,source:`tasks`,payloadMatch:{reason:`blocked`}};else if(e.triggerMode===`noteCreated`)o={kind:`event`,eventType:`note.created`,source:`notes`};else if(e.triggerMode===`workflowFailed`)o={kind:`event`,eventType:`workflow.run.completed`,source:`workflows`,payloadMatch:{status:`failed`}};else if(e.triggerMode===`sessionUpdated`)o={kind:`event`,eventType:`session.transcript.updated`,source:`sessions`};else if(e.triggerMode===`event`){let t=e.eventPayloadMatch.trim()?JSON.parse(e.eventPayloadMatch):void 0;o={kind:`event`,eventType:e.eventType.trim(),...e.eventSource.trim()?{source:e.eventSource.trim()}:{},...t?{payloadMatch:t}:{}}}else o=e.triggerMode===`interval`?{kind:`schedule`,schedule:{kind:`interval`,everyMs:Be(e.intervalValue,e.intervalUnit)}}:e.triggerMode===`weekly`?{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * ${e.weekday}`}}:e.triggerMode===`cron`?{kind:`schedule`,schedule:{kind:`cron`,expr:e.cronExpr.trim()}}:{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * *`}};let s=ge(t,e.workflowInput),c=e.workflowInput.goal.trim()||e.workflowGoal.trim(),l=e.actionMode===`browser_recipe`?`auto_apply`:e.safetyMode,u;return u=e.actionMode===`workflow`?{kind:`workflow`,workflowId:e.workflowId.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{},...s===void 0?{}:{input:s},...c?{goal:c}:{},...e.workflowInput.concurrency.trim()?{concurrency:Math.max(1,Number.parseInt(e.workflowInput.concurrency,10)||1)}:{},...e.workflowInput.maxSubagents.trim()?{maxSubagents:Math.max(1,Number.parseInt(e.workflowInput.maxSubagents,10)||1)}:{}}:e.actionMode===`browser_recipe`?{kind:`browser_recipe`,recipeId:e.browserWorkflowId.trim(),args:e.browserWorkflowInputs}:{kind:`agent`,instruction:e.instruction.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{}},{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},...e.projectId.trim()?{projectId:e.projectId.trim()}:{},trigger:o,action:u,safety:{mode:l},conversationMode:e.conversationMode,notificationPolicy:e.notificationPolicy,...l===`auto_apply`&&e.completionWebhookUrl.trim()?{completionWebhookUrl:e.completionWebhookUrl.trim()}:{},reliability:{executionTimeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||1800),disableAfterConsecutiveFailures:Math.max(1,Number.parseInt(e.disableAfterFailures,10)||3)}}}function et(e){let t=e.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+\*$/);if(t)return{triggerMode:`daily`,time:`${t[2].padStart(2,`0`)}:${t[1].padStart(2,`0`)}`,weekday:`1`,cronExpr:e};let n=e.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+([0-6])$/);return n?{triggerMode:`weekly`,time:`${n[2].padStart(2,`0`)}:${n[1].padStart(2,`0`)}`,weekday:n[3],cronExpr:e}:{triggerMode:`cron`,time:Ze.time,weekday:Ze.weekday,cronExpr:e}}function tt(e){let t=[[`week`,10080*6e4],[`day`,1440*6e4],[`hour`,60*6e4],[`minute`,6e4]],[n,r]=t.find(([,t])=>e>=t&&e%t===0)??t.at(-1);return{intervalValue:String(e/r),intervalUnit:n}}function nt(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=t.getTimezoneOffset()*6e4;return new Date(t.getTime()-n).toISOString().slice(0,16)}function rt(e){let t=e.payloadMatch;return e.eventType===`task.attention_required.v2`&&e.source===`tasks`&&t?.reason===`blocked`?{triggerMode:`taskBlocked`}:e.eventType===`note.created`&&e.source===`notes`&&!t?{triggerMode:`noteCreated`}:e.eventType===`workflow.run.completed`&&e.source===`workflows`&&t?.status===`failed`?{triggerMode:`workflowFailed`}:e.eventType===`session.transcript.updated`&&e.source===`sessions`&&!t?{triggerMode:`sessionUpdated`}:{triggerMode:`event`,eventType:e.eventType,eventSource:e.source??``,eventPayloadMatch:t?JSON.stringify(t,null,2):``}}function it(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function at(e){if(!e.trim())return!0;try{let t=JSON.parse(e);return!!t&&typeof t==`object`&&!Array.isArray(t)&&Object.values(t).every(e=>e===null||[`string`,`number`,`boolean`].includes(typeof e))}catch{return!1}}function ot(e,t=[]){let n={triggerMode:`manual`};if(e.trigger.kind===`webhook`)n={triggerMode:`webhook`,webhookSecretId:e.trigger.secretId??``};else if(e.trigger.kind===`event`)n=rt(e.trigger);else if(e.trigger.kind===`schedule`){let t=e.trigger.schedule;t.kind===`cron`&&(n=et(t.expr)),t.kind===`interval`&&(n={triggerMode:`interval`,...tt(t.everyMs)}),t.kind===`once`&&(n={triggerMode:`once`,onceAt:nt(t.at)})}let r=e.action,i=r.kind===`workflow`?t.find(e=>e.id===r.workflowId)??null:null,a=r.kind===`workflow`?it(r.input):{},o=e.reliability?.executionTimeoutSeconds??r.timeoutSeconds??e.reliability?.timeoutSeconds??(r.kind===`browser_recipe`?600:1800);return{...Ze,...n,name:e.name,description:e.description??``,projectId:e.projectId??``,actionMode:r.kind,agentId:r.kind===`browser_recipe`?``:r.agentId??``,instruction:r.kind===`agent`?r.instruction:``,workflowId:r.kind===`workflow`?r.workflowId:``,workflowGoal:r.kind===`workflow`?r.goal??``:``,browserWorkflowId:r.kind===`browser_recipe`?r.recipeId:``,browserWorkflowInputs:r.kind===`browser_recipe`?r.args??{}:{},workflowInput:{goal:r.kind===`workflow`?r.goal??``:``,argValues:i?he(i.name,a):{},schemaInput:a,concurrency:r.kind===`workflow`&&r.concurrency?String(r.concurrency):``,maxSubagents:r.kind===`workflow`&&r.maxSubagents?String(r.maxSubagents):``},workflowInputValid:!0,safetyMode:e.safety?.mode??`auto_apply`,timeoutSeconds:String(o),conversationMode:e.conversationMode??`new_session`,notificationPolicy:e.notificationPolicy??`attention`,completionWebhookUrl:e.completionWebhookUrl??``,disableAfterFailures:String(e.reliability?.disableAfterConsecutiveFailures??3)}}function st(e,t,n){let r=$e(t,n),i=e.trigger.kind===`schedule`&&r.trigger.kind===`schedule`&&e.trigger.schedule.kind===r.trigger.schedule.kind?{...r.trigger,schedule:{...e.trigger.schedule,...r.trigger.schedule}}:r.trigger,a=r.action;return e.action.kind===`agent`&&r.action.kind===`agent`?a={...e.action,...r.action,agentId:r.action.agentId}:e.action.kind===`workflow`&&r.action.kind===`workflow`?a={...e.action,...r.action,agentId:r.action.agentId,input:r.action.input,goal:r.action.goal,concurrency:r.action.concurrency,maxSubagents:r.action.maxSubagents}:e.action.kind===`browser_recipe`&&r.action.kind===`browser_recipe`&&(a={...e.action,...r.action}),{...r,description:t.description.trim(),projectId:t.projectId.trim(),completionWebhookUrl:t.completionWebhookUrl.trim(),trigger:i,action:a,reliability:{...e.reliability,...r.reliability}}}var Z=r();function ct(e,t,n){return e?We(e,n):t.never}function lt(e,t){return e.kind===`workflow`?t.action.workflowWithId.replace(`{id}`,e.workflowId):e.kind===`browser_recipe`?`Browser automation: ${e.recipeId}`:e.agentId?t.action.agentWithId.replace(`{id}`,e.agentId):t.action.agent}function ut(e){return e.safety?.mode??`auto_apply`}function dt(e){return e===`succeeded`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`running`||e===`queued`||e===`cancelling`?`bg-blue-500/10 text-blue-700 dark:text-blue-300`:`bg-surface-hover text-fg-muted`}function ft(e,t){if(e==null)return t.never;if(e<1e3)return`${e}ms`;let n=Math.round(e/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`}function pt(e){return e.status===`running`||e.status===`queued`||e.status===`cancelling`}function mt(e){return e.status===`failed`||e.status===`timeout`||e.status===`cancelled`}function ht(e,t){if((e.state.consecutiveFailures??0)>0)return!0;let n=t.reduce((t,n)=>n.automationId===e.id&&(!t||n.createdAtMs>t.createdAtMs)?n:t,void 0);return n?mt(n):!1}function gt(e,t){return e.action.kind===`agent`?e.action.instruction:e.action.kind===`workflow`&&e.action.goal?.trim()||lt(e.action,t)}function _t(e){return(e.description?.match(/\[managed-by=([^\]]+)\]/))?.[1]?.trim()||null}function vt(e){return!!_t(e)}function yt(e){return e.description?.replace(/\s*\[managed-by=[^\]]+\]\s*/g,` `).trim()??``}function bt(e){return pt(e)?0:mt(e)?1:e.status===`succeeded`?2:3}function xt(e){return[...e].sort((e,t)=>{let n=bt(e)-bt(t);return n===0?t.createdAtMs-e.createdAtMs:n})}function St(){let e=(0,xe.c)(5),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,Z.jsx)(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(Ct)})]}),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 Ct(e,t){return(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(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 wt({projectId:e,embedded:t=!1,title:n,subtitle:r}){let a=b(e=>e.language),ee=y(a),h=ee.automations,g=ee.cron,w=I(e=>e.setPageHeader),ne=I(e=>e.clearPageHeader),[T,E]=i(),re=T.get(`run`)?.trim()??``,ie=T.get(`automation`)?.trim()??``,ae=T.get(`draft`)?.trim()??``,oe=T.get(`action`)?.trim()??``,k=T.get(`projectId`)?.trim()??``,A=e?.trim()||k,j=!!e?.trim(),ce=T.get(`autogenerate`)===`1`,le=(0,K.useRef)(``),[L,R]=(0,K.useState)(`all`),[pe,B]=(0,K.useState)(``),[V,H]=(0,K.useState)(!1),[U,W]=(0,K.useState)(`blank`),[he,ge]=(0,K.useState)(null),[_e,be]=(0,K.useState)(!1),[G,xe]=(0,K.useState)(Ze),[Se,q]=(0,K.useState)(null),[Ce,we]=(0,K.useState)(null),[Te,Ee]=(0,K.useState)(!1),[De,J]=(0,K.useState)(null),[Oe,ke]=(0,K.useState)(``),[Y,X]=(0,K.useState)(null),[Ae,je]=(0,K.useState)(!1),[Me,Ne]=(0,K.useState)(!1),[Pe,Fe]=(0,K.useState)(A),[Ie,Le]=(0,K.useState)(`new_session`),[Re,ze]=(0,K.useState)(`attention`),[Be,Ve]=(0,K.useState)(null),[He,Ue]=(0,K.useState)(!1),[We,Ge]=(0,K.useState)(!1),[Ke,qe]=(0,K.useState)(!1),[Ye,Xe]=(0,K.useState)(null),Qe=S([`automations`,A],()=>P.list(A?{projectId:A}:void 0),{refreshInterval:15e3}),et=S([`automation-runs`,A],()=>P.runs(50,void 0,A?{projectId:A}:void 0),{refreshInterval:1e4}),tt=S(Ce?`automation-run-events:${Ce}`:null,()=>P.runEvents(Ce),{refreshInterval:5e3}),nt=S(`automation-workflow-definitions`,z),rt=S(`automation-browser-workflows`,()=>ve.list()),it=S(`automation-chat-agents`,D),ct=S(`automation-projects`,()=>O({sortBy:`name`,sortOrder:`asc`,limit:200})),lt=Qe.isLoading&&!Qe.data||et.isLoading&&!et.data,ut=Qe.data?.automations??[],dt=(0,K.useMemo)(()=>xt(et.data?.runs??[]),[et.data?.runs]),ft=(0,K.useMemo)(()=>ut.filter(e=>!vt(e)),[ut]),mt=(0,K.useMemo)(()=>ut.filter(vt),[ut]),ht=(0,K.useMemo)(()=>new Set(mt.map(e=>e.id)),[mt]),_t=(0,K.useMemo)(()=>dt.filter(e=>!ht.has(e.automationId)),[dt,ht]),bt=(0,K.useMemo)(()=>dt.find(e=>e.id===Ce)??null,[dt,Ce]),Ct=(0,K.useMemo)(()=>ut.find(e=>e.id===De)??null,[ut,De]),wt=(0,K.useMemo)(()=>ut.find(e=>e.id===he)??null,[ut,he]),Et=(0,K.useMemo)(()=>dt.filter(e=>e.automationId===De).sort((e,t)=>t.createdAtMs-e.createdAtMs),[dt,De]),Dt=tt.data?.events??[],Ot=(0,K.useMemo)(()=>_t.filter(e=>!pt(e)&&e.readAtMs==null),[_t]),At=pe.trim().toLocaleLowerCase(),jt=(0,K.useMemo)(()=>(L===`system`?mt:ft).filter(e=>L===`active`&&!e.enabled||L===`paused`&&e.enabled?!1:At?[e.name,yt(e),gt(e,h),Je(e.trigger,h,g,a)].some(e=>e.toLocaleLowerCase().includes(At)):!0),[g,L,h,a,At,mt,ft,_t]),Mt=(0,K.useMemo)(()=>nt.data??[],[nt.data]),Nt=(0,K.useMemo)(()=>(rt.data?.workflows??[]).filter(e=>e.enabled),[rt.data]),It=it.data?.items??[],Lt=ct.data?.items??[],Rt=(0,K.useMemo)(()=>Mt.find(e=>e.id===G.workflowId.trim())??null,[G.workflowId,Mt]),zt=(0,K.useMemo)(()=>Nt.find(e=>e.id===G.browserWorkflowId.trim())??null,[Nt,G.browserWorkflowId]),Bt=G.actionMode===`workflow`&&(!G.workflowId.trim()||Mt.length>0&&!Mt.some(e=>e.id===G.workflowId)),Vt=G.actionMode===`workflow`&&Rt?!me(Rt,G.workflowInput,G.workflowInputValid).valid:!1,Ht=!!G.name.trim()&&(G.triggerMode!==`once`||Number.isFinite(new Date(G.onceAt).getTime()))&&(G.triggerMode!==`event`||!!G.eventType.trim()&&at(G.eventPayloadMatch))&&(G.actionMode===`workflow`?!Bt&&!Vt:G.actionMode===`browser_recipe`?zt!==null&&ye(zt,G.browserWorkflowInputs):!!G.instruction.trim()),Gt=(0,K.useMemo)(()=>[{name:h.templates.dailyAgent.name,description:h.templates.dailyAgent.description,form:{...Ze,name:h.templates.dailyAgent.name,instruction:h.templates.dailyAgent.instruction,triggerMode:`daily`}},{name:h.templates.morningWorkflow.name,description:h.templates.morningWorkflow.description,form:{...Ze,name:h.templates.morningWorkflow.formName,actionMode:`workflow`,workflowId:Mt[0]?.id??``}},{name:h.templates.webhookAgent.name,description:h.templates.webhookAgent.description,form:{...Ze,name:h.templates.webhookAgent.formName,triggerMode:`webhook`}},{name:h.templates.blockedTask.name,description:h.templates.blockedTask.description,form:{...Ze,name:h.templates.blockedTask.formName,triggerMode:`taskBlocked`,instruction:h.templates.blockedTask.instruction}},{name:h.templates.noteCreated.name,description:h.templates.noteCreated.description,form:{...Ze,name:h.templates.noteCreated.formName,triggerMode:`noteCreated`,instruction:h.templates.noteCreated.instruction}}],[h,Mt]);(0,K.useEffect)(()=>{if(jt.length===0){J(null);return}De&&jt.some(e=>e.id===De)||J(jt[0].id)},[jt,De]);let Kt=(0,K.useCallback)(async()=>{await Promise.all([Qe.mutate(),et.mutate(),tt.mutate()])},[Qe.mutate,tt.mutate,et.mutate]),qt=(0,K.useCallback)(e=>{if(j){J(null),we(null);return}E(t=>{let n=new URLSearchParams(t);return e?n.set(`projectId`,e):n.delete(`projectId`),n.delete(`automation`),n.delete(`run`),n}),J(null),we(null)},[j,E]);(0,K.useEffect)(()=>{j&&(Fe(A),xe(e=>e.projectId===A?e:{...e,projectId:A}))},[A,j]);let $=(0,K.useCallback)(e=>{if(ge(null),be(!1),W(e),H(!0),e===`blank`){xe({...Ze,projectId:A});return}ke(``),X(null),Ne(!1),Fe(A),Le(`new_session`),ze(`attention`)},[A]),Jt=(0,K.useCallback)(e=>{xe(ot(e,Mt)),ge(e.id),be(!1),J(null),W(`blank`),H(!0)},[Mt]),Yt=(0,K.useCallback)(()=>{Y&&(xe({...ot(Y.automation,Mt),projectId:Pe,conversationMode:Ie,notificationPolicy:Re}),ge(null),be(!0),W(`blank`))},[Y,Ie,Re,Pe,Mt]),Xt=(0,K.useCallback)(async()=>{qe(!0),q(null);try{await Kt()}catch(e){q(e instanceof Error?e.message:String(e))}finally{qe(!1)}},[h.feedback.actionFailed,Kt]);(0,K.useEffect)(()=>{if(!ie)return;let e=ut.find(e=>e.id===ie);e&&(R(vt(e)?`system`:`all`),J(e.id),E(e=>{let t=new URLSearchParams(e);return t.delete(`automation`),t},{replace:!0}))},[ie,ut,E]),(0,K.useEffect)(()=>{oe===`create`&&($(`blank`),E(e=>{let t=new URLSearchParams(e);return t.delete(`action`),t},{replace:!0}))},[oe,$,E]),(0,K.useEffect)(()=>{if(!ae)return;let e=`${a}:${ce?`auto`:`seed`}:${ae}`;le.current!==e&&(le.current=e,ke(ae),X(null),Ne(!1),Fe(A),W(`draft`),H(!0),E(e=>{let t=new URLSearchParams(e);return t.delete(`draft`),t.delete(`autogenerate`),t},{replace:!0}),ce&&(q(null),je(!0),P.draft({prompt:ae,language:a}).then(e=>{X(e.draft),Ne(!1)}).catch(e=>{q(e instanceof Error?e.message:String(e))}).finally(()=>{je(!1)})))},[ce,ae,a,A,E]);let Zt=(0,K.useCallback)(e=>{let t=dt.find(t=>t.id===e);if(!t||pt(t)||t.readAtMs!=null)return;let n=Date.now();et.mutate(t=>t&&{...t,runs:t.runs.map(t=>t.id===e?{...t,readAtMs:n}:t)},!1),P.markRunRead(e).catch(e=>{q(e instanceof Error?e.message:String(e)),et.mutate()})},[dt,et.mutate]),Qt=(0,K.useCallback)(e=>{Zt(e),we(e),Ee(!0),E(t=>{let n=new URLSearchParams(t);return n.set(`run`,e),n},{replace:!0})},[Zt,E]),$t=(0,K.useCallback)(e=>{J(e);let t=dt.find(t=>t.automationId===e);t&&t.readAtMs==null&&!pt(t)&&Zt(t.id)},[Zt,dt]);(0,K.useEffect)(()=>{re&&(Zt(re),we(re),Ee(!0))},[Zt,re]),(0,K.useEffect)(()=>{Ve(null),Ge(!1)},[Ce]);async function en(){if(q(null),Ht){if(_e&&Y){Xe(`draft:edit`);try{let e=$e(G,Rt),{simulation:t}=await P.simulate(e);X({...Y,automation:e,simulation:t}),Fe(G.projectId),Le(G.conversationMode),ze(G.notificationPolicy),Ne(!1),be(!1),W(`draft`)}catch(e){q(e instanceof Error?e.message:String(e))}finally{Xe(null)}return}if(wt){let e=wt.id;await tn(`automation:${e}:edit`,()=>P.update(e,st(wt,G,Rt)))&&(H(!1),ge(null),J(e));return}try{let e=$e(G,Rt),{automation:t}=await P.create(e);xe(Ze),H(!1),R(`all`),B(``),qt(t.projectId??``),await Kt(),J(t.id)}catch(e){q(e instanceof Error?e.message:String(e))}}}async function tn(e,t){q(null),Xe(e);try{return await t(),await Kt(),!0}catch(e){return q(e instanceof Error?e.message:String(e)),!1}finally{Xe(null)}}async function nn(){await tn(`runs:read-all`,()=>P.markAllRunsRead(A||void 0))}async function rn(){let e=Oe.trim();if(e){q(null),je(!0);try{X((await P.draft({prompt:e,language:a})).draft),Ne(!1)}catch(e){q(e instanceof Error?e.message:String(e))}finally{je(!1)}}}async function an(){if(!Y)return;let e=``,t=``;await tn(`draft:publish`,async()=>{let{automation:n}=await P.create({...Y.automation,...Pe?{projectId:Pe}:{projectId:void 0},conversationMode:Ie,notificationPolicy:Re});X(null),ke(``),Ne(!1),H(!1),R(`all`),B(``),e=n.id,t=n.projectId??``})&&e&&(qt(t),J(e))}async function on(){if(!Y)return;let e=``,t=``,n=``;await tn(`draft:test`,async()=>{let{automation:r}=await P.create({...Y.automation,...Pe?{projectId:Pe}:{projectId:void 0},conversationMode:Ie,notificationPolicy:Re,enabled:!1}),{run:i}=await P.runNow(r.id);e=r.id,t=r.projectId??``,n=i.id,X(null),ke(``),Ne(!1),H(!1),R(`all`),B(``)})&&e&&n&&(qt(t),J(e),Qt(n))}async function sn(e){q(null),Ue(!0),Ve(null),Ge(!1);try{Ve((await P.repairDraft(e.id,{language:a})).repair)}catch(e){q(e instanceof Error?e.message:String(e))}finally{Ue(!1)}}async function cn(e){Be&&await tn(`run:${e.id}:repair`,async()=>{await P.update(e.automationId,Be.patch),Ve(null),Ge(!1)})}let ln=(0,K.useMemo)(()=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(F,{className:`size-9 shrink-0 p-0`,loading:Ke,label:h.refresh,onClick:Xt}),(0,Z.jsxs)(C,{variant:`primary`,onClick:()=>$(`draft`),children:[(0,Z.jsx)(_,{className:`size-4`}),h.new]})]}),[h.new,h.refresh,$,Ke,Xt]);return(0,K.useLayoutEffect)(()=>{if(!t)return w({startExtra:null,main:(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:h.title}),(0,Z.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:h.subtitle})]}),end:ln}),()=>ne()},[ne,t,ln,h.subtitle,h.title,w]),(0,Z.jsxs)(`div`,{className:x(`flex min-h-0 min-w-0 flex-1 flex-col`,t?`bg-transparent`:`bg-surface-panel`),children:[(0,Z.jsxs)(`div`,{className:x(`flex w-full flex-col gap-4`,t?`py-1`:`px-3 py-5 sm:px-5 xl:px-6`),children:[t?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 rounded-xl border border-edge-subtle bg-surface-base px-4 py-3 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(M,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n||h.title})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:r||h.subtitle})]}),ln]}):null,Se?(0,Z.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:Se}):null,lt?(0,Z.jsx)(St,{}):(0,Z.jsxs)(`section`,{className:`grid min-h-0 items-start gap-4 xl:grid-cols-[20rem_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`aside`,{className:`overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`border-b border-edge-subtle p-3`,children:[j?null:(0,Z.jsxs)(f,{"aria-label":h.filters.project,className:Q,value:A,onChange:e=>qt(e.target.value),children:[(0,Z.jsx)(p,{value:``,children:h.filters.allProjects}),Lt.map(e=>(0,Z.jsx)(p,{value:e.id,children:e.name},e.id))]}),(0,Z.jsxs)(`label`,{className:x(`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`,!j&&`mt-2`),children:[(0,Z.jsx)(te,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-subtle`,value:pe,onChange:e=>B(e.target.value),placeholder:h.filters.search})]}),(0,Z.jsxs)(`nav`,{className:`mt-3 flex items-center gap-1`,"aria-label":h.filters.status,children:[[{id:`all`,label:h.filters.all},{id:`active`,label:h.filters.active},{id:`paused`,label:h.paused}].map(e=>(0,Z.jsx)(`button`,{type:`button`,className:x(`rounded-md px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,L===e.id&&`bg-surface-hover text-fg`),onClick:()=>R(e.id),children:e.label},e.id)),(0,Z.jsxs)(fe,{children:[(0,Z.jsx)(ue,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:x(`ml-auto rounded-md p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,L===`system`&&`bg-surface-hover text-fg`),"aria-label":h.system.title,children:(0,Z.jsx)(m,{className:`size-4`})})}),(0,Z.jsx)(de,{children:(0,Z.jsx)(N,{align:`end`,className:`z-70 min-w-40 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:(0,Z.jsxs)(se,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>R(`system`),children:[h.system.title,` `,mt.length]})})})]})]}),Ot.length>0&&L!==`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:[h.filters.unread,` · `,Ot.length]}),(0,Z.jsx)(`button`,{type:`button`,className:`font-medium hover:underline`,disabled:Ye===`runs:read-all`,onClick:()=>void nn(),children:h.filters.markAllRead})]}):null]}),(0,Z.jsx)(kt,{automations:jt,runs:L===`system`?dt:_t,labels:h,cronLabels:g,language:a,selectedAutomationId:De,onOpenDetails:$t})]}),Ct?(0,Z.jsx)(Ft,{automation:Ct,runs:Et,labels:h,cronLabels:g,language:a,projects:Lt,busyAction:Ye,onEdit:Jt,onSelectRun:Qt,onAction:tn}):(0,Z.jsx)(Ut,{icon:(0,Z.jsx)(M,{className:`size-5`}),title:h.empty.filtered})]})]}),(0,Z.jsx)(d,{open:V,onOpenChange:e=>{H(e),e||(ge(null),be(!1))},children:(0,Z.jsxs)(c,{children:[(0,Z.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(l,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(760px,calc(100vh-2rem))] w-[min(100%-2rem,48rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,Z.jsx)(u,{className:`text-base font-semibold text-fg`,children:U===`draft`?h.draft.title:wt?h.editTitle:_e?h.draft.editTitle:h.createTitle}),(0,Z.jsx)(s,{asChild:!0,children:(0,Z.jsx)(C,{variant:`ghost`,"aria-label":h.close,children:(0,Z.jsx)(v,{className:`size-4`})})})]}),U===`draft`?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,Z.jsx)(Tt,{labels:h,prompt:Oe,draft:Y,loading:Ae,approved:Me,publishBusy:Ye===`draft:publish`,testBusy:Ye===`draft:test`,templates:Gt,projects:Lt,projectId:Pe,conversationMode:Ie,notificationPolicy:Re,onPromptChange:ke,onGenerate:rn,onEdit:Yt,onPublish:an,onTest:on,onProjectChange:Fe,onConversationModeChange:Le,onNotificationPolicyChange:ze,projectLocked:j,onApprovedChange:Ne,onDiscard:()=>{X(null),Ne(!1)},onTemplateSelect:e=>{xe({...e,projectId:Pe}),W(`blank`)},onOpenAdvanced:()=>{xe({...Ze,projectId:Pe,conversationMode:Ie,notificationPolicy:Re}),W(`blank`)}})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Wt,{form:G,labels:h,setForm:xe,projects:Lt,workflowDefinitions:Mt,selectedWorkflow:Rt,workflowsLoading:nt.isLoading,browserWorkflows:Nt,selectedBrowserWorkflow:zt,browserWorkflowsLoading:rt.isLoading,agentOptions:It,agentsLoading:it.isLoading,language:a,projectLocked:j}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[_e?(0,Z.jsx)(C,{variant:`ghost`,onClick:()=>{be(!1),W(`draft`)},children:h.cancel}):(0,Z.jsx)(s,{asChild:!0,children:(0,Z.jsx)(C,{variant:`ghost`,children:h.cancel})}),(0,Z.jsx)(C,{variant:`primary`,onClick:en,disabled:!Ht||Ye===`draft:edit`||!!(wt&&Ye),children:Ye===`draft:edit`||wt&&Ye===`automation:${wt.id}:edit`?h.feedback.working:wt||_e?h.save:h.create})]})]})]})]})}),(0,Z.jsx)(d,{open:Te&&!!bt,onOpenChange:e=>{Ee(e),!e&&E(e=>{let t=new URLSearchParams(e);return t.delete(`run`),t},{replace:!0})},children:(0,Z.jsxs)(c,{children:[(0,Z.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(l,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(85vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,Z.jsx)(u,{className:`truncate text-base font-semibold text-fg`,children:bt?.automationName??h.dashboard.result}),(0,Z.jsx)(s,{asChild:!0,children:(0,Z.jsx)(C,{variant:`ghost`,"aria-label":h.close,children:(0,Z.jsx)(v,{className:`size-4`})})})]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Z.jsx)(Pt,{className:`rounded-none border-0`,run:bt,events:Dt,labels:h,cronLabels:g,language:a,loading:tt.isLoading,repairDraft:Be,repairLoading:He,repairApproved:We,busyAction:Ye,onRepairApprovedChange:Ge,onSuggestRepair:sn,onApplyRepair:cn})})]})]})})]})}function Tt(e){let t=(0,xe.c)(108),{labels:n,prompt:r,draft:i,loading:a,approved:o,publishBusy:s,testBusy:c,templates:l,projects:u,projectId:d,conversationMode:ee,notificationPolicy:m,onPromptChange:h,onGenerate:_,onEdit:te,onPublish:v,onTest:y,onProjectChange:b,onConversationModeChange:S,onNotificationPolicyChange:w,onApprovedChange:ne,onDiscard:E,onTemplateSelect:re,onOpenAdvanced:D,projectLocked:ie}=e,ae=s===void 0?!1:s,oe=c===void 0?!1:c,O=ie===void 0?!1:ie,k=!!(i&&i.simulation.requiredConfirmations.length>0),se;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Z.jsx)(T,{className:`size-4 text-accent`}),t[0]=se):se=t[0];let j;t[1]===n.draft.title?j=t[2]:(j=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[se,n.draft.title]}),t[1]=n.draft.title,t[2]=j);let M;t[3]===n.draft.subtitle?M=t[4]:(M=(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:n.draft.subtitle}),t[3]=n.draft.subtitle,t[4]=M);let N;t[5]!==j||t[6]!==M?(N=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[j,M]}),t[5]=j,t[6]=M,t[7]=N):N=t[7];let ce;t[8]!==a||t[9]!==r?(ce=a||!r.trim(),t[8]=a,t[9]=r,t[10]=ce):ce=t[10];let le;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,Z.jsx)(T,{className:`size-4`}),t[11]=le):le=t[11];let P=a?n.draft.generating:n.draft.generate,ue;t[12]!==_||t[13]!==P||t[14]!==ce?(ue=(0,Z.jsxs)(C,{variant:`primary`,onClick:_,disabled:ce,children:[le,P]}),t[12]=_,t[13]=P,t[14]=ce,t[15]=ue):ue=t[15];let F;t[16]!==ue||t[17]!==N?(F=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[N,ue]}),t[16]=ue,t[17]=N,t[18]=F):F=t[18];let I;t[19]===h?I=t[20]:(I=e=>h(e.target.value),t[19]=h,t[20]=I);let de;t[21]!==n.draft.placeholder||t[22]!==r||t[23]!==I?(de=(0,Z.jsx)(`textarea`,{className:`mt-4 min-h-20 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,value:r,onChange:I,placeholder:n.draft.placeholder}),t[21]=n.draft.placeholder,t[22]=r,t[23]=I,t[24]=de):de=t[24];let L=O?`sm:grid-cols-2`:`sm:grid-cols-3`,fe;t[25]===L?fe=t[26]:(fe=x(`mt-3 grid gap-3`,L),t[25]=L,t[26]=fe);let R;t[27]!==n.draft.noProject||t[28]!==n.draft.project||t[29]!==b||t[30]!==d||t[31]!==O||t[32]!==u?(R=O?null:(0,Z.jsx)($,{label:n.draft.project,children:(0,Z.jsxs)(f,{className:Q,value:d,onChange:e=>b(e.target.value),children:[(0,Z.jsx)(p,{value:``,children:n.draft.noProject}),u.map(Et)]})}),t[27]=n.draft.noProject,t[28]=n.draft.project,t[29]=b,t[30]=d,t[31]=O,t[32]=u,t[33]=R):R=t[33];let z;t[34]===S?z=t[35]:(z=e=>S(e.target.value),t[34]=S,t[35]=z);let pe;t[36]===n.draft.newConversation?pe=t[37]:(pe=(0,Z.jsx)(p,{value:`new_session`,children:n.draft.newConversation}),t[36]=n.draft.newConversation,t[37]=pe);let B;t[38]===n.draft.continuousConversation?B=t[39]:(B=(0,Z.jsx)(p,{value:`continuous`,children:n.draft.continuousConversation}),t[38]=n.draft.continuousConversation,t[39]=B);let V;t[40]!==ee||t[41]!==z||t[42]!==pe||t[43]!==B?(V=(0,Z.jsxs)(f,{className:Q,value:ee,onChange:z,children:[pe,B]}),t[40]=ee,t[41]=z,t[42]=pe,t[43]=B,t[44]=V):V=t[44];let H;t[45]!==n.draft.conversation||t[46]!==V?(H=(0,Z.jsx)($,{label:n.draft.conversation,children:V}),t[45]=n.draft.conversation,t[46]=V,t[47]=H):H=t[47];let U;t[48]===w?U=t[49]:(U=e=>w(e.target.value),t[48]=w,t[49]=U);let W;t[50]===n.draft.notifyAttention?W=t[51]:(W=(0,Z.jsx)(p,{value:`attention`,children:n.draft.notifyAttention}),t[50]=n.draft.notifyAttention,t[51]=W);let me;t[52]===n.draft.notifyAll?me=t[53]:(me=(0,Z.jsx)(p,{value:`all`,children:n.draft.notifyAll}),t[52]=n.draft.notifyAll,t[53]=me);let he;t[54]===n.draft.notifyNone?he=t[55]:(he=(0,Z.jsx)(p,{value:`none`,children:n.draft.notifyNone}),t[54]=n.draft.notifyNone,t[55]=he);let ge;t[56]!==m||t[57]!==U||t[58]!==W||t[59]!==me||t[60]!==he?(ge=(0,Z.jsxs)(f,{className:Q,value:m,onChange:U,children:[W,me,he]}),t[56]=m,t[57]=U,t[58]=W,t[59]=me,t[60]=he,t[61]=ge):ge=t[61];let _e;t[62]!==n.draft.notifications||t[63]!==ge?(_e=(0,Z.jsx)($,{label:n.draft.notifications,children:ge}),t[62]=n.draft.notifications,t[63]=ge,t[64]=_e):_e=t[64];let ve;t[65]!==fe||t[66]!==R||t[67]!==H||t[68]!==_e?(ve=(0,Z.jsxs)(`div`,{className:fe,children:[R,H,_e]}),t[65]=fe,t[66]=R,t[67]=H,t[68]=_e,t[69]=ve):ve=t[69];let ye;t[70]!==i||t[71]!==n.draft.advancedCreate||t[72]!==n.draft.suggestions||t[73]!==n.draft.suggestionsDescription||t[74]!==D||t[75]!==re||t[76]!==l?(ye=i?null:(0,Z.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.draft.suggestions}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:n.draft.suggestionsDescription})]}),(0,Z.jsx)(C,{variant:`ghost`,onClick:D,children:n.draft.advancedCreate})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:l.slice(0,4).map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-lg border border-edge-subtle bg-surface-panel p-3 text-left hover:bg-surface-hover`,onClick:()=>re(e.form),children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,Z.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:e.description})]},e.name))})]}),t[70]=i,t[71]=n.draft.advancedCreate,t[72]=n.draft.suggestions,t[73]=n.draft.suggestionsDescription,t[74]=D,t[75]=re,t[76]=l,t[77]=ye):ye=t[77];let be;t[78]!==o||t[79]!==i||t[80]!==n.draft.approval||t[81]!==n.draft.assumptions||t[82]!==n.draft.discard||t[83]!==n.draft.edit||t[84]!==n.draft.publish||t[85]!==n.draft.review||t[86]!==n.draft.risks||t[87]!==n.draft.safety||t[88]!==n.draft.testOnce||t[89]!==n.draft.testing||t[90]!==n.feedback||t[91]!==n.info||t[92]!==n.none||t[93]!==ne||t[94]!==E||t[95]!==te||t[96]!==v||t[97]!==y||t[98]!==ae||t[99]!==k||t[100]!==oe?(be=i?(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg bg-surface-base p-4 lg:grid-cols-[1fr_1fr]`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:i.automation.name}),i.automation.description?(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:i.automation.description}):null,(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,Z.jsx)(Ht,{label:n.info.when,value:i.simulation.triggerSummary}),(0,Z.jsx)(Ht,{label:n.info.run,value:i.simulation.actionSummary})]})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:n.draft.review}),(0,Z.jsx)(Dt,{title:n.draft.safety,items:[...i.simulation.safetyNotes,...i.simulation.requiredConfirmations],empty:n.none}),(0,Z.jsx)(Dt,{title:n.draft.assumptions,items:i.assumptions,empty:n.none}),(0,Z.jsx)(Dt,{title:n.draft.risks,items:i.risks,empty:n.none}),k?(0,Z.jsxs)(`label`,{className:`mt-4 flex items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:o,onChange:e=>ne(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:te,children:[(0,Z.jsx)(g,{className:`size-4`}),n.draft.edit]}),(0,Z.jsxs)(C,{variant:`secondary`,onClick:y,disabled:oe||ae||k&&!o,children:[(0,Z.jsx)(A,{className:`size-4`}),oe?n.draft.testing:n.draft.testOnce]}),(0,Z.jsx)(C,{variant:`primary`,onClick:v,disabled:ae||k&&!o,children:ae?n.feedback.working:n.draft.publish})]})]})]}):null,t[78]=o,t[79]=i,t[80]=n.draft.approval,t[81]=n.draft.assumptions,t[82]=n.draft.discard,t[83]=n.draft.edit,t[84]=n.draft.publish,t[85]=n.draft.review,t[86]=n.draft.risks,t[87]=n.draft.safety,t[88]=n.draft.testOnce,t[89]=n.draft.testing,t[90]=n.feedback,t[91]=n.info,t[92]=n.none,t[93]=ne,t[94]=E,t[95]=te,t[96]=v,t[97]=y,t[98]=ae,t[99]=k,t[100]=oe,t[101]=be):be=t[101];let G;return t[102]!==F||t[103]!==de||t[104]!==ve||t[105]!==ye||t[106]!==be?(G=(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[F,de,ve,ye,be]}),t[102]=F,t[103]=de,t[104]=ve,t[105]=ye,t[106]=be,t[107]=G):G=t[107],G}function Et(e){return(0,Z.jsx)(p,{value:e.id,children:e.name},e.id)}function Dt(e){let t=(0,xe.c)(10),{title:n,items:r,empty:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o;t[2]!==i||t[3]!==r?(o=r.length>0?r.map(Ot):(0,Z.jsx)(`li`,{className:`text-fg-muted`,children:i}),t[2]=i,t[3]=r,t[4]=o):o=t[4];let s;t[5]===o?s=t[6]:(s=(0,Z.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm text-fg`,children:o}),t[5]=o,t[6]=s);let c;return t[7]!==a||t[8]!==s?(c=(0,Z.jsxs)(`div`,{className:`mt-3`,children:[a,s]}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function Ot(e){return(0,Z.jsxs)(`li`,{children:[`- `,e]},e)}function kt(e){let t=(0,xe.c)(20),{automations:n,runs:r,labels:i,cronLabels:a,language:o,selectedAutomationId:s,onOpenDetails:c}=e;if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(M,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===i.empty.filtered?n=t[2]:(n=(0,Z.jsx)(Ut,{className:`rounded-none border-0 shadow-none`,icon:e,title:i.empty.filtered}),t[1]=i.empty.filtered,t[2]=n),n}let l;if(t[3]!==n||t[4]!==a||t[5]!==i||t[6]!==o||t[7]!==c||t[8]!==r||t[9]!==s){let e;t[11]!==a||t[12]!==i||t[13]!==o||t[14]!==c||t[15]!==r||t[16]!==s?(e=e=>{let t=r.filter(t=>t.automationId===e.id).sort(At),n=t.find(pt),l=t[0];return(0,Z.jsxs)(`button`,{type:`button`,className:x(`block w-full p-3 text-left outline-none hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,s===e.id&&`bg-surface-hover`),onClick:()=>c(e.id),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:x(`size-2 shrink-0 rounded-full`,n?`bg-blue-500`:ht(e,t)?`bg-red-500`:e.enabled?`bg-emerald-500`:`bg-fg-subtle`)}),(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),l&&l.readAtMs==null&&!pt(l)?(0,Z.jsx)(`span`,{className:`ml-auto size-2 shrink-0 rounded-full bg-blue-500`,children:(0,Z.jsx)(`span`,{className:`sr-only`,children:i.filters.unread})}):null]}),(0,Z.jsx)(`div`,{className:`mt-1 truncate pl-4 text-xs text-fg-muted`,children:Je(e.trigger,i,a,o)}),(0,Z.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center justify-between gap-2 pl-4 text-xs text-fg-subtle`,children:[(0,Z.jsx)(`span`,{className:x(`truncate`,l?.error&&`text-red-700 dark:text-red-300`),children:l?l.error||l.summary||i.status[l.status]:e.enabled?`${i.next}: ${ct(e.state.nextRunAtMs,i,o)}`:i.paused}),l?.status?(0,Z.jsx)(`span`,{className:x(`shrink-0 rounded-full px-1.5 py-0.5`,dt(l.status)),children:i.status[l.status]}):null]})]},e.id)},t[11]=a,t[12]=i,t[13]=o,t[14]=c,t[15]=r,t[16]=s,t[17]=e):e=t[17],l=n.map(e),t[3]=n,t[4]=a,t[5]=i,t[6]=o,t[7]=c,t[8]=r,t[9]=s,t[10]=l}else l=t[10];let u;return t[18]===l?u=t[19]:(u=(0,Z.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:l}),t[18]=l,t[19]=u),u}function At(e,t){return t.createdAtMs-e.createdAtMs}function jt(e,t){let n=t.events,r=e.data&&typeof e.data==`object`?e.data:{},i=typeof r.actionKind==`string`?r.actionKind:null,a=typeof r.status==`string`&&r.status in t.status?t.status[r.status]:null;switch(e.type){case`run.queued`:return e.message.toLowerCase().includes(`manual`)?n.manualQueued:e.message.toLowerCase().includes(`scheduled`)?n.scheduledQueued:n.eventQueued;case`run.started`:return n.runStarted;case`action.started`:return i?n.actionStarted.replace(`{kind}`,i):n.actionStartedFallback;case`action.completed`:return i?n.actionCompleted.replace(`{kind}`,i):n.actionCompletedFallback;case`action.failed`:return i?n.actionFailed.replace(`{kind}`,i):n.actionFailedFallback;case`completion_hook.started`:return n.completionHookStarted;case`completion_hook.completed`:return n.completionHookCompleted;case`completion_hook.failed`:return n.completionHookFailed;case`run.completed`:return a?n.runCompleted.replace(`{status}`,a):n.runCompletedFallback;default:return e.message}}function Mt(e){let t=(0,xe.c)(17),{value:n,labels:r,title:i,defaultExpanded:a}=e,[o,s]=(0,K.useState)(a===void 0?!1:a),c;t[0]===n?c=t[1]:(c=JSON.stringify(n,null,2),t[0]=n,t[1]=c);let l=c,u;t[2]===l?u=t[3]:(u=l.split(`
|
|
2
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 ee=p,m;t[7]!==o||t[8]!==f||t[9]!==r||t[10]!==i?(m=f?(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-2.5 py-2 text-left text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>s(Nt),"aria-expanded":o,children:[(0,Z.jsx)(`span`,{children:i}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-accent-fg`,children:[o?r.details.hideDetails:r.details.showDetails,(0,Z.jsx)(ae,{className:x(`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]=m):m=t[11];let h=o||!f?l:ee,g;t[12]===h?g=t[13]:(g=(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-all px-2.5 pb-2 text-xs leading-relaxed text-fg-muted`,children:h}),t[12]=h,t[13]=g);let _;return t[14]!==m||t[15]!==g?(_=(0,Z.jsxs)(`div`,{className:`mt-2 rounded-md border border-edge/70 bg-surface-muted/35`,children:[m,g]}),t[14]=m,t[15]=g,t[16]=_):_=t[16],_}function Nt(e){return!e}function Pt(e){let t=(0,xe.c)(148),{className:n,run:r,events:i,labels:o,cronLabels:s,language:c,loading:l,repairDraft:u,repairLoading:d,repairApproved:f,busyAction:p,onRepairApprovedChange:m,onSuggestRepair:g,onApplyRepair:_}=e;if(!r){let e;t[0]===n?e=t[1]:(e=x(`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)(ce,{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 te=r.error||r.summary,v=r.sessionKey?`/chat/${encodeURIComponent(r.sessionKey)}`:r.workflowRunId?`/workflows?run=${encodeURIComponent(r.workflowRunId)}`:null,y=r.sessionKey?o.runDetail.openConversation:o.runDetail.openWorkflow,b=r.sessionKey?pe:R,S=pt(r)?ce:mt(r)?oe:ee,ne;t[8]===n?ne=t[9]:(ne=x(`rounded-lg border border-edge-subtle bg-surface-base shadow-surface`,n),t[8]=n,t[9]=ne);let E;t[10]===r.automationName?E=t[11]:(E=(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:r.automationName}),t[10]=r.automationName,t[11]=E);let D;t[12]===r.id?D=t[13]:(D=r.id.slice(0,8),t[12]=r.id,t[13]=D);let ie;t[14]===D?ie=t[15]:(ie=(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:D}),t[14]=D,t[15]=ie);let O;t[16]!==E||t[17]!==ie?(O=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[E,ie]}),t[16]=E,t[17]=ie,t[18]=O):O=t[18];let k;t[19]===r.status?k=t[20]:(k=x(`shrink-0 rounded-full px-2 py-0.5 text-xs`,dt(r.status)),t[19]=r.status,t[20]=k);let se=o.status[r.status],A;t[21]!==k||t[22]!==se?(A=(0,Z.jsx)(`span`,{className:k,children:se}),t[21]=k,t[22]=se,t[23]=A):A=t[23];let j;t[24]!==O||t[25]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[O,A]}),t[24]=O,t[25]=A,t[26]=j):j=t[26];let M;t[27]!==o||t[28]!==c||t[29]!==r.createdAtMs?(M=ct(r.createdAtMs,o,c),t[27]=o,t[28]=c,t[29]=r.createdAtMs,t[30]=M):M=t[30];let N;t[31]===M?N=t[32]:(N=(0,Z.jsx)(`span`,{children:M}),t[31]=M,t[32]=N);let P;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t[33]=P):P=t[33];let ue=o.details.duration,F;t[34]!==o||t[35]!==r.durationMs?(F=ft(r.durationMs,o),t[34]=o,t[35]=r.durationMs,t[36]=F):F=t[36];let I;t[37]!==o.details.duration||t[38]!==F?(I=(0,Z.jsxs)(`span`,{children:[ue,` `,F]}),t[37]=o.details.duration,t[38]=F,t[39]=I):I=t[39];let de;t[40]!==N||t[41]!==I?(de=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-muted`,children:[N,P,I]}),t[40]=N,t[41]=I,t[42]=de):de=t[42];let L;t[43]!==o.repair||t[44]!==g||t[45]!==d||t[46]!==r?(L=r.status===`failed`||r.status===`timeout`||r.status===`cancelled`?(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsxs)(C,{variant:`secondary`,onClick:()=>g(r),disabled:d,children:[(0,Z.jsx)(T,{className:`size-4`}),d?o.repair.generating:o.repair.suggest]})}):null,t[43]=o.repair,t[44]=g,t[45]=d,t[46]=r,t[47]=L):L=t[47];let fe;t[48]!==de||t[49]!==L||t[50]!==j?(fe=(0,Z.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[j,de,L]}),t[48]=de,t[49]=L,t[50]=j,t[51]=fe):fe=t[51];let z;t[52]===r?z=t[53]:(z=pt(r)?`text-blue-500`:mt(r)?`text-red-500`:`text-emerald-500`,t[52]=r,t[53]=z);let B;t[54]===z?B=t[55]:(B=x(`size-4`,z),t[54]=z,t[55]=B);let V;t[56]!==S||t[57]!==B?(V=(0,Z.jsx)(S,{className:B}),t[56]=S,t[57]=B,t[58]=V):V=t[58];let H;t[59]!==o.runDetail.resultTitle||t[60]!==V?(H=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[V,o.runDetail.resultTitle]}),t[59]=o.runDetail.resultTitle,t[60]=V,t[61]=H):H=t[61];let U;t[62]!==b||t[63]!==y||t[64]!==v?(U=v?(0,Z.jsx)(C,{asChild:!0,variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,children:(0,Z.jsxs)(a,{to:v,children:[(0,Z.jsx)(b,{className:`size-3.5`}),y,(0,Z.jsx)(re,{className:`size-3.5`})]})}):null,t[62]=b,t[63]=y,t[64]=v,t[65]=U):U=t[65];let W;t[66]!==H||t[67]!==U?(W=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[H,U]}),t[66]=H,t[67]=U,t[68]=W):W=t[68];let me=r.error&&`border-red-500/25 bg-red-500/5`,he;t[69]===me?he=t[70]:(he=x(`mt-3 max-h-80 overflow-y-auto rounded-lg border border-edge/70 bg-surface-muted/25 p-3`,me),t[69]=me,t[70]=he);let ge;t[71]!==o.runDetail.noResult||t[72]!==o.runDetail.resultPending||t[73]!==te||t[74]!==r?(ge=te?r.error?(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-red-700 dark:text-red-300`,children:te}):(0,Z.jsx)(h,{content:te,compact:!0,className:`text-sm`}):(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:pt(r)?o.runDetail.resultPending:o.runDetail.noResult}),t[71]=o.runDetail.noResult,t[72]=o.runDetail.resultPending,t[73]=te,t[74]=r,t[75]=ge):ge=t[75];let _e;t[76]!==he||t[77]!==ge?(_e=(0,Z.jsx)(`div`,{className:he,children:ge}),t[76]=he,t[77]=ge,t[78]=_e):_e=t[78];let ve;t[79]!==W||t[80]!==_e?(ve=(0,Z.jsxs)(`section`,{className:`border-b border-edge p-4`,children:[W,_e]}),t[79]=W,t[80]=_e,t[81]=ve):ve=t[81];let ye;t[82]===o.runDetail.runInfo?ye=t[83]:(ye=(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:o.runDetail.runInfo}),t[82]=o.runDetail.runInfo,t[83]=ye);let be;t[84]!==s||t[85]!==o||t[86]!==c||t[87]!==r.manual||t[88]!==r.triggerSnapshot?(be=r.manual?o.trigger.manual:Je(r.triggerSnapshot,o,s,c),t[84]=s,t[85]=o,t[86]=c,t[87]=r.manual,t[88]=r.triggerSnapshot,t[89]=be):be=t[89];let G;t[90]!==o.explain.whyRan||t[91]!==be?(G=(0,Z.jsx)(Bt,{label:o.explain.whyRan,value:be}),t[90]=o.explain.whyRan,t[91]=be,t[92]=G):G=t[92];let K=o.details.started,Se;t[93]!==o||t[94]!==c||t[95]!==r.startedAtMs?(Se=ct(r.startedAtMs,o,c),t[93]=o,t[94]=c,t[95]=r.startedAtMs,t[96]=Se):Se=t[96];let q;t[97]!==o.details.started||t[98]!==Se?(q=(0,Z.jsx)(Bt,{label:K,value:Se}),t[97]=o.details.started,t[98]=Se,t[99]=q):q=t[99];let Ce;t[100]!==o.details.model||t[101]!==r.model?(Ce=r.model?(0,Z.jsx)(Bt,{label:o.details.model,value:r.model}):null,t[100]=o.details.model,t[101]=r.model,t[102]=Ce):Ce=t[102];let we;t[103]!==G||t[104]!==q||t[105]!==Ce?(we=(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs text-fg-muted`,children:[G,q,Ce]}),t[103]=G,t[104]=q,t[105]=Ce,t[106]=we):we=t[106];let Te;t[107]!==ye||t[108]!==we?(Te=(0,Z.jsxs)(`section`,{className:`border-b border-edge p-4`,children:[ye,we]}),t[107]=ye,t[108]=we,t[109]=Te):Te=t[109];let Ee;t[110]!==p||t[111]!==o||t[112]!==_||t[113]!==m||t[114]!==f||t[115]!==u||t[116]!==r?(Ee=u?(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:u.explanation}),u.expectedEffect?(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:u.expectedEffect}):null,(0,Z.jsx)(Dt,{title:o.repair.risks,items:u.risks,empty:o.none}),(0,Z.jsx)(Mt,{value:u.patch,labels:o,title:o.details.repairPatch}),u.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:f,onChange:e=>m(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:()=>_(r),disabled:p===`run:${r.id}:repair`||u.requiresApproval&&!f,children:p===`run:${r.id}:repair`?o.feedback.working:o.repair.apply})})]}):null,t[110]=p,t[111]=o,t[112]=_,t[113]=m,t[114]=f,t[115]=u,t[116]=r,t[117]=Ee):Ee=t[117];let De;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,Z.jsx)(le,{className:`size-4 shrink-0`}),t[118]=De):De=t[118];let J;t[119]===o.runDetail.technicalEvents?J=t[120]:(J=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-sm font-medium text-fg-muted`,children:[De,o.runDetail.technicalEvents]}),t[119]=o.runDetail.technicalEvents,t[120]=J);let Oe;t[121]!==i.length||t[122]!==o.runDetail.eventCount?(Oe=o.runDetail.eventCount.replace(`{count}`,String(i.length)),t[121]=i.length,t[122]=o.runDetail.eventCount,t[123]=Oe):Oe=t[123];let ke;t[124]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,Z.jsx)(ae,{className:`size-4 transition-transform group-open:rotate-180`}),t[124]=ke):ke=t[124];let Y;t[125]===Oe?Y=t[126]:(Y=(0,Z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[Oe,ke]}),t[125]=Oe,t[126]=Y);let X;t[127]!==J||t[128]!==Y?(X=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 rounded-md outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,children:[J,Y]}),t[127]=J,t[128]=Y,t[129]=X):X=t[129];let Ae;t[130]===o.runDetail.technicalEventsDescription?Ae=t[131]:(Ae=(0,Z.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:o.runDetail.technicalEventsDescription}),t[130]=o.runDetail.technicalEventsDescription,t[131]=Ae);let je;t[132]!==i||t[133]!==o||t[134]!==c||t[135]!==l?(je=(0,Z.jsx)(`div`,{className:`mt-4`,children:l?(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:x(`mt-1 size-2 rounded-full`,Vt(e.type))}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm text-fg`,children:jt(e,o)}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:[ct(e.createdAtMs,o,c),` · `,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)(ae,{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]=c,t[135]=l,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]!==ne||t[142]!==fe||t[143]!==ve||t[144]!==Te||t[145]!==Ee||t[146]!==Me?(Ne=(0,Z.jsxs)(`aside`,{className:ne,children:[fe,ve,Te,Ee,Me]}),t[141]=ne,t[142]=fe,t[143]=ve,t[144]=Te,t[145]=Ee,t[146]=Me,t[147]=Ne):Ne=t[147],Ne}function Ft(e){let t=(0,xe.c)(83),{automation:n,runs:r,labels:i,cronLabels:a,language:o,projects:s,busyAction:c,onEdit:l,onSelectRun:u,onAction:d}=e,f=c===`automation:${n.id}:run`,p=c===`automation:${n.id}:toggle`,_=c===`automation:${n.id}:delete`,te;t[0]===n?te=t[1]:(te=vt(n),t[0]=n,t[1]=te);let v=te,y;t[2]===n.name?y=t[3]:(y=(0,Z.jsx)(`h2`,{className:`truncate text-lg font-semibold text-fg`,children:n.name}),t[2]=n.name,t[3]=y);let b=n.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`,S;t[4]===b?S=t[5]:(S=x(`shrink-0 rounded-full px-2 py-0.5 text-xs`,b),t[4]=b,t[5]=S);let w=n.enabled?i.enabled:i.paused,ne;t[6]!==S||t[7]!==w?(ne=(0,Z.jsx)(`span`,{className:S,children:w}),t[6]=S,t[7]=w,t[8]=ne):ne=t[8];let T;t[9]!==y||t[10]!==ne?(T=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[y,ne]}),t[9]=y,t[10]=ne,t[11]=T):T=t[11];let re;t[12]===n?re=t[13]:(re=yt(n)?(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:yt(n)}):null,t[12]=n,t[13]=re);let D;t[14]!==T||t[15]!==re?(D=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[T,re]}),t[14]=T,t[15]=re,t[16]=D):D=t[16];let ie;t[17]!==n||t[18]!==c||t[19]!==_||t[20]!==i.dashboard.delete||t[21]!==i.dashboard.deleted||t[22]!==i.dashboard.pause||t[23]!==i.dashboard.resume||t[24]!==i.dashboard.resumed||t[25]!==i.dashboard.runNow||t[26]!==i.details||t[27]!==i.edit||t[28]!==i.feedback||t[29]!==d||t[30]!==l||t[31]!==v||t[32]!==f||t[33]!==p?(ie=v?null:(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsxs)(C,{variant:`secondary`,disabled:c!==null,onClick:()=>void d(`automation:${n.id}:toggle`,()=>n.enabled?P.pause(n.id):P.resume(n.id),n.enabled?i.feedback.paused:i.dashboard.resumed),children:[p?(0,Z.jsx)(j,{className:`size-4 animate-spin`}):n.enabled?(0,Z.jsx)(L,{className:`size-4`}):(0,Z.jsx)(A,{className:`size-4`}),n.enabled?i.dashboard.pause:i.dashboard.resume]}),(0,Z.jsxs)(C,{variant:`primary`,disabled:c!==null,onClick:()=>void d(`automation:${n.id}:run`,()=>P.runNow(n.id),i.feedback.rerunQueued),children:[f?(0,Z.jsx)(j,{className:`size-4 animate-spin`}):(0,Z.jsx)(A,{className:`size-4`}),i.dashboard.runNow]}),(0,Z.jsxs)(fe,{children:[(0,Z.jsx)(ue,{asChild:!0,children:(0,Z.jsx)(C,{variant:`ghost`,className:`size-9 p-0`,"aria-label":i.details.moreActions,children:(0,Z.jsx)(m,{className:`size-4`})})}),(0,Z.jsx)(de,{children:(0,Z.jsxs)(N,{align:`end`,className:`z-70 min-w-40 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[(0,Z.jsxs)(se,{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:()=>l(n),children:[(0,Z.jsx)(g,{className:`size-4`}),i.edit]}),(0,Z.jsxs)(se,{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:c!==null,onSelect:()=>void d(`automation:${n.id}:delete`,()=>P.remove(n.id),i.dashboard.deleted),children:[_?(0,Z.jsx)(j,{className:`size-4 animate-spin`}):(0,Z.jsx)(E,{className:`size-4`}),i.dashboard.delete]})]})})]})]}),t[17]=n,t[18]=c,t[19]=_,t[20]=i.dashboard.delete,t[21]=i.dashboard.deleted,t[22]=i.dashboard.pause,t[23]=i.dashboard.resume,t[24]=i.dashboard.resumed,t[25]=i.dashboard.runNow,t[26]=i.details,t[27]=i.edit,t[28]=i.feedback,t[29]=d,t[30]=l,t[31]=v,t[32]=f,t[33]=p,t[34]=ie):ie=t[34];let ae;t[35]!==ie||t[36]!==D?(ae=(0,Z.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[D,ie]}),t[35]=ie,t[36]=D,t[37]=ae):ae=t[37];let oe;t[38]===i.info.task?oe=t[39]:(oe=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.info.task}),t[38]=i.info.task,t[39]=oe);let O;t[40]!==n||t[41]!==i?(O=gt(n,i),t[40]=n,t[41]=i,t[42]=O):O=t[42];let k;t[43]===O?k=t[44]:(k=(0,Z.jsx)(`div`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base p-4`,children:(0,Z.jsx)(h,{content:O,compact:!0})}),t[43]=O,t[44]=k);let M;t[45]!==oe||t[46]!==k?(M=(0,Z.jsxs)(`section`,{children:[oe,k]}),t[45]=oe,t[46]=k,t[47]=M):M=t[47];let le;t[48]!==n||t[49]!==a||t[50]!==i||t[51]!==o||t[52]!==s?(le=(0,Z.jsx)(Lt,{automation:n,labels:i,cronLabels:a,language:o,projects:s}),t[48]=n,t[49]=a,t[50]=i,t[51]=o,t[52]=s,t[53]=le):le=t[53];let F;t[54]===i.dashboard.runHistory?F=t[55]:(F=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.dashboard.runHistory}),t[54]=i.dashboard.runHistory,t[55]=F);let I;t[56]===i.dashboard.runHistoryDescription?I=t[57]:(I=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.dashboard.runHistoryDescription}),t[56]=i.dashboard.runHistoryDescription,t[57]=I);let R;t[58]!==F||t[59]!==I?(R=(0,Z.jsxs)(`div`,{children:[F,I]}),t[58]=F,t[59]=I,t[60]=R):R=t[60];let z;t[61]===r.length?z=t[62]:(z=(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-base px-2.5 py-1 text-xs text-fg-muted`,children:r.length}),t[61]=r.length,t[62]=z);let pe;t[63]!==R||t[64]!==z?(pe=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[R,z]}),t[63]=R,t[64]=z,t[65]=pe):pe=t[65];let B;t[66]!==i||t[67]!==o||t[68]!==u||t[69]!==r?(B=r.length===0?(0,Z.jsx)(Ut,{icon:(0,Z.jsx)(ce,{className:`size-5`}),title:i.empty.runs}):(0,Z.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:r.slice(0,8).map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`block w-full p-3 text-left hover:bg-surface-hover`,onClick:()=>u(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)(ee,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-300`}):(0,Z.jsx)(ce,{className:`size-4 shrink-0 text-fg-muted`}),(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:ct(e.createdAtMs,i,o)})]}),(0,Z.jsx)(`span`,{className:x(`shrink-0 rounded-full px-2 py-0.5 text-xs`,dt(e.status)),children:i.status[e.status]})]}),(0,Z.jsx)(`p`,{className:x(`mt-1 line-clamp-2 pl-6 text-sm text-fg-muted`,e.error&&`text-red-700 dark:text-red-300`),children:e.error||e.summary||lt(e.actionSnapshot,i)})]},e.id))}),t[66]=i,t[67]=o,t[68]=u,t[69]=r,t[70]=B):B=t[70];let V;t[71]!==pe||t[72]!==B?(V=(0,Z.jsxs)(`section`,{className:`min-w-0`,children:[pe,B]}),t[71]=pe,t[72]=B,t[73]=V):V=t[73];let H;t[74]!==le||t[75]!==V?(H=(0,Z.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[20rem_minmax(0,1fr)]`,children:[le,V]}),t[74]=le,t[75]=V,t[76]=H):H=t[76];let U;t[77]!==M||t[78]!==H?(U=(0,Z.jsxs)(`div`,{className:`grid gap-5 p-5`,children:[M,H]}),t[77]=M,t[78]=H,t[79]=U):U=t[79];let W;return t[80]!==ae||t[81]!==U?(W=(0,Z.jsxs)(`article`,{className:`min-w-0 overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel shadow-surface`,children:[ae,U]}),t[80]=ae,t[81]=U,t[82]=W):W=t[82],W}function It(e,t){return e===`suggest_only`?t.safety.suggestOnlyDescription:e===`ask_before_apply`?t.safety.askBeforeApplyDescription:t.safety.autoApplyDescription}function Lt(e){let t=(0,xe.c)(146),{automation:n,labels:r,cronLabels:i,language:a,projects:o}=e,s,c,l,u,d,f,p,ee,m,h,g;if(t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a){let e=ut(n),o;t[15]!==n||t[16]!==r||t[17]!==a?(o=Ye(n,r,a),t[15]=n,t[16]=r,t[17]=a,t[18]=o):o=t[18];let _=o,te;t[19]!==n.state.nextRunAtMs||t[20]!==a?(te=n.state.nextRunAtMs?We(n.state.nextRunAtMs,a):void 0,t[19]=n.state.nextRunAtMs,t[20]=a,t[21]=te):te=t[21];let v=te;if(t[22]!==n.trigger.eventType||t[23]!==n.trigger.kind||t[24]!==n.trigger.schedule||t[25]!==n.trigger.secretId||t[26]!==n.trigger.source||t[27]!==r.info.anchor||t[28]!==r.info.calendarSchedule||t[29]!==r.info.eventSource||t[30]!==r.info.eventType||t[31]!==r.info.expression||t[32]!==r.info.fixedInterval||t[33]!==r.info.oneTimeSchedule||t[34]!==r.info.rawInterval||t[35]!==r.info.scheduleType||t[36]!==r.info.timezone||t[37]!==r.info.webhookSecret||t[38]!==a){if(g=[],n.trigger.kind===`schedule`){let e=n.trigger.schedule,i=e.kind===`interval`?r.info.fixedInterval:e.kind===`cron`?r.info.calendarSchedule:r.info.oneTimeSchedule,o;if(t[40]!==r.info.scheduleType||t[41]!==i?(o={label:r.info.scheduleType,value:i},t[40]=r.info.scheduleType,t[41]=i,t[42]=o):o=t[42],g.push(o),e.kind===`interval`){let n=`${e.everyMs} ms`,i;if(t[43]!==r.info.rawInterval||t[44]!==n?(i={label:r.info.rawInterval,value:n},t[43]=r.info.rawInterval,t[44]=n,t[45]=i):i=t[45],g.push(i),e.anchorMs){let n=r.info.anchor,i;t[46]!==a||t[47]!==e.anchorMs?(i=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],g.push(o)}}else if(e.kind===`cron`){let n;if(t[52]!==r.info.expression||t[53]!==e.expr?(n={label:r.info.expression,value:e.expr},t[52]=r.info.expression,t[53]=e.expr,t[54]=n):n=t[54],g.push(n),e.tz){let n;t[55]!==r.info.timezone||t[56]!==e.tz?(n={label:r.info.timezone,value:e.tz},t[55]=r.info.timezone,t[56]=e.tz,t[57]=n):n=t[57],g.push(n)}}else{let n;t[58]!==r.info.oneTimeSchedule||t[59]!==e.at?(n={label:r.info.oneTimeSchedule,value:e.at},t[58]=r.info.oneTimeSchedule,t[59]=e.at,t[60]=n):n=t[60],g.push(n)}}else if(n.trigger.kind===`event`){let e;if(t[61]!==n.trigger.eventType||t[62]!==r.info.eventType?(e={label:r.info.eventType,value:n.trigger.eventType},t[61]=n.trigger.eventType,t[62]=r.info.eventType,t[63]=e):e=t[63],g.push(e),n.trigger.source){let e;t[64]!==n.trigger.source||t[65]!==r.info.eventSource?(e={label:r.info.eventSource,value:n.trigger.source},t[64]=n.trigger.source,t[65]=r.info.eventSource,t[66]=e):e=t[66],g.push(e)}}else if(n.trigger.kind===`webhook`&&n.trigger.secretId){let e;t[67]!==n.trigger.secretId||t[68]!==r.info.webhookSecret?(e={label:r.info.webhookSecret,value:n.trigger.secretId},t[67]=n.trigger.secretId,t[68]=r.info.webhookSecret,t[69]=e):e=t[69],g.push(e)}t[22]=n.trigger.eventType,t[23]=n.trigger.kind,t[24]=n.trigger.schedule,t[25]=n.trigger.secretId,t[26]=n.trigger.source,t[27]=r.info.anchor,t[28]=r.info.calendarSchedule,t[29]=r.info.eventSource,t[30]=r.info.eventType,t[31]=r.info.expression,t[32]=r.info.fixedInterval,t[33]=r.info.oneTimeSchedule,t[34]=r.info.rawInterval,t[35]=r.info.scheduleType,t[36]=r.info.timezone,t[37]=r.info.webhookSecret,t[38]=a,t[39]=g}else g=t[39];m=`h-fit overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,t[70]===r.info.overview?h=t[71]:(h=(0,Z.jsx)(`div`,{className:`border-b border-edge-subtle px-4 py-3`,children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.info.overview})}),t[70]=r.info.overview,t[71]=h),f=`grid gap-4 p-4`;let y;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),t[72]=y):y=t[72];let b=r.info.schedule,x;t[73]!==n.trigger||t[74]!==i||t[75]!==r||t[76]!==a?(x=Je(n.trigger,r,i,a),t[73]=n.trigger,t[74]=i,t[75]=r,t[76]=a,t[77]=x):x=t[77];let S=n.enabled?`${r.info.nextRun}:${_}`:_;t[78]!==r.info.schedule||t[79]!==v||t[80]!==x||t[81]!==S?(p=(0,Z.jsx)(zt,{icon:y,label:b,value:x,description:S,descriptionTitle:v}),t[78]=r.info.schedule,t[79]=v,t[80]=x,t[81]=S,t[82]=p):p=t[82];let C;t[83]===n.action.kind?C=t[84]:(C=n.action.kind===`workflow`?(0,Z.jsx)(R,{className:`size-4`,"aria-hidden":!0}):n.action.kind===`browser_recipe`?(0,Z.jsx)(le,{className:`size-4`,"aria-hidden":!0}):(0,Z.jsx)(M,{className:`size-4`,"aria-hidden":!0}),t[83]=n.action.kind,t[84]=C);let w=r.info.action,T;t[85]!==n.action||t[86]!==r?(T=lt(n.action,r),t[85]=n.action,t[86]=r,t[87]=T):T=t[87],t[88]!==r.info.action||t[89]!==C||t[90]!==T?(ee=(0,Z.jsx)(zt,{icon:C,label:w,value:T}),t[88]=r.info.action,t[89]=C,t[90]=T,t[91]=ee):ee=t[91],s=zt,t[92]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(ie,{className:`size-4`,"aria-hidden":!0}),t[92]=c):c=t[92],l=r.info.permission,u=r.safety[e],d=It(e,r),t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=ee,t[12]=m,t[13]=h,t[14]=g}else s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],ee=t[11],m=t[12],h=t[13],g=t[14];let _;t[93]!==s||t[94]!==c||t[95]!==l||t[96]!==u||t[97]!==d?(_=(0,Z.jsx)(s,{icon:c,label:l,value:u,description:d}),t[93]=s,t[94]=c,t[95]=l,t[96]=u,t[97]=d,t[98]=_):_=t[98];let te;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Z.jsx)(R,{className:`size-4`,"aria-hidden":!0}),t[99]=te):te=t[99];let v;t[100]!==n.projectId||t[101]!==r.info.noProject||t[102]!==o?(v=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]=v):v=t[103];let y;t[104]!==r.info.project||t[105]!==v?(y=(0,Z.jsx)(zt,{icon:te,label:r.info.project,value:v}),t[104]=r.info.project,t[105]=v,t[106]=y):y=t[106];let b;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(pe,{className:`size-4`,"aria-hidden":!0}),t[107]=b):b=t[107];let x=n.conversationMode===`continuous`?r.info.continuousConversation:r.info.newConversation,S;t[108]!==r.info.conversation||t[109]!==x?(S=(0,Z.jsx)(zt,{icon:b,label:r.info.conversation,value:x}),t[108]=r.info.conversation,t[109]=x,t[110]=S):S=t[110];let C;t[111]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(oe,{className:`size-4`,"aria-hidden":!0}),t[111]=C):C=t[111];let w=n.notificationPolicy===`all`?r.info.notifyAll:n.notificationPolicy===`none`?r.info.notifyNone:r.info.notifyAttention,T;t[112]!==r.info.notifications||t[113]!==w?(T=(0,Z.jsx)(zt,{icon:C,label:r.info.notifications,value:w}),t[112]=r.info.notifications,t[113]=w,t[114]=T):T=t[114];let E;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(ce,{className:`size-4`,"aria-hidden":!0}),t[115]=E):E=t[115];let re=r.info.lastRun,D;t[116]!==n||t[117]!==r||t[118]!==a?(D=Xe(n,r,a),t[116]=n,t[117]=r,t[118]=a,t[119]=D):D=t[119];let O=n.state.lastRunStatus===`failed`||n.state.lastRunStatus===`timeout`?`danger`:`default`,k;t[120]!==r.info.lastRun||t[121]!==D||t[122]!==O?(k=(0,Z.jsx)(zt,{icon:E,label:re,value:D,valueTone:O}),t[120]=r.info.lastRun,t[121]=D,t[122]=O,t[123]=k):k=t[123];let se;t[124]!==n.state.consecutiveFailures||t[125]!==n.state.lastError||t[126]!==r.dashboard?(se=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]=se):se=t[127];let A;t[128]!==r.info.technicalDetails||t[129]!==g?(A=g.length>0?(0,Z.jsxs)(`details`,{className:`group border-t border-edge-subtle pt-3`,children:[(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 text-sm text-fg-muted outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Z.jsx)(`span`,{children:r.info.technicalDetails}),(0,Z.jsx)(ae,{className:`size-4 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:g.map(Rt)})]}):null,t[128]=r.info.technicalDetails,t[129]=g,t[130]=A):A=t[130];let j;t[131]!==_||t[132]!==y||t[133]!==S||t[134]!==T||t[135]!==k||t[136]!==se||t[137]!==A||t[138]!==f||t[139]!==p||t[140]!==ee?(j=(0,Z.jsxs)(`div`,{className:f,children:[p,ee,_,y,S,T,k,se,A]}),t[131]=_,t[132]=y,t[133]=S,t[134]=T,t[135]=k,t[136]=se,t[137]=A,t[138]=f,t[139]=p,t[140]=ee,t[141]=j):j=t[141];let N;return t[142]!==j||t[143]!==m||t[144]!==h?(N=(0,Z.jsxs)(`aside`,{className:m,children:[h,j]}),t[142]=j,t[143]=m,t[144]=h,t[145]=N):N=t[145],N}function Rt(e){return(0,Z.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.label}),(0,Z.jsx)(`span`,{className:`break-all font-mono text-xs text-fg-muted`,children:e.value})]},`${e.label}:${e.value}`)}function zt(e){let t=(0,xe.c)(19),{icon:n,label:r,value:i,description:a,descriptionTitle:o,valueTone:s}=e,c=s===void 0?`default`:s,l;t[0]===n?l=t[1]:(l=(0,Z.jsx)(`span`,{className:`mt-0.5 text-fg-subtle`,children:n}),t[0]=n,t[1]=l);let u;t[2]===r?u=t[3]:(u=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r}),t[2]=r,t[3]=u);let d=c===`danger`?`text-red-700 dark:text-red-300`:`text-fg`,f;t[4]===d?f=t[5]:(f=x(`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 ee;t[9]!==a||t[10]!==o?(ee=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]=ee):ee=t[11];let m;t[12]!==u||t[13]!==p||t[14]!==ee?(m=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[u,p,ee]}),t[12]=u,t[13]=p,t[14]=ee,t[15]=m):m=t[15];let h;return t[16]!==l||t[17]!==m?(h=(0,Z.jsxs)(`div`,{className:`grid grid-cols-[1.25rem_1fr] gap-2.5`,children:[l,m]}),t[16]=l,t[17]=m,t[18]=h):h=t[18],h}function Bt(e){let t=(0,xe.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`span`,{children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Z.jsxs)(`div`,{className:`grid grid-cols-[5rem_1fr] gap-2`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Vt(e){return e.endsWith(`.failed`)?`bg-red-500`:e.endsWith(`.completed`)?`bg-emerald-500`:e.endsWith(`.started`)?`bg-blue-500`:`bg-fg-muted`}function Ht(e){let t=(0,xe.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`div`,{className:`text-xs font-medium uppercase text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Z.jsx)(`div`,{className:`mt-1 truncate text-sm text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Ut(e){let t=(0,xe.c)(8),{className:n,icon:r,title:i}=e,a;t[0]===n?a=t[1]:(a=x(`flex min-h-48 flex-col items-center justify-center rounded-lg border border-edge-subtle bg-surface-base text-fg-muted shadow-surface`,n),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=(0,Z.jsx)(`div`,{className:`mt-2 text-sm`,children:i}),t[2]=i,t[3]=o);let s;return t[4]!==r||t[5]!==a||t[6]!==o?(s=(0,Z.jsxs)(`div`,{className:a,children:[r,o]}),t[4]=r,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Wt(e){let t=(0,xe.c)(274),{form:n,labels:r,setForm:i,projects:a,workflowDefinitions:o,selectedWorkflow:s,workflowsLoading:c,browserWorkflows:l,selectedBrowserWorkflow:u,browserWorkflowsLoading:d,agentOptions:ee,agentsLoading:m,language:h,projectLocked:g}=e,_=g===void 0?!1:g,te=y(h).agentsSettings,v;t[0]===i?v=t[1]:(v=e=>i(t=>({...t,...e})),t[0]=i,t[1]=v);let b=v,S=Be(n.intervalValue,n.intervalUnit),C=Date.now(),w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=[1,2,3],t[2]=w):w=t[2];let ne;t[3]!==S||t[4]!==C||t[5]!==h?(ne=w.map(e=>Ke(C+S*e,h,C)),t[3]=S,t[4]=C,t[5]=h,t[6]=ne):ne=t[6];let T=ne,E,re;t[7]!==n.actionMode||t[8]!==n.workflowId||t[9]!==i||t[10]!==o?(E=()=>{if(n.actionMode!==`workflow`||n.workflowId.trim())return;let e=o[0]?.id;e&&i(t=>({...t,workflowId:e,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}))},re=[n.actionMode,n.workflowId,i,o],t[7]=n.actionMode,t[8]=n.workflowId,t[9]=i,t[10]=o,t[11]=E,t[12]=re):(E=t[11],re=t[12]),(0,K.useEffect)(E,re);let D,ie;t[13]!==l||t[14]!==n.actionMode||t[15]!==n.browserWorkflowId||t[16]!==i?(D=()=>{if(n.actionMode!==`browser_recipe`||n.browserWorkflowId.trim())return;let e=l[0];e&&i(t=>({...t,browserWorkflowId:e.id,browserWorkflowInputs:be(e)}))},ie=[l,n.actionMode,n.browserWorkflowId,i],t[13]=l,t[14]=n.actionMode,t[15]=n.browserWorkflowId,t[16]=i,t[17]=D,t[18]=ie):(D=t[17],ie=t[18]),(0,K.useEffect)(D,ie);let oe;t[19]===b?oe=t[20]:(oe=e=>b({name:e.target.value}),t[19]=b,t[20]=oe);let O;t[21]!==n.name||t[22]!==oe?(O=(0,Z.jsx)(`input`,{className:Q,value:n.name,onChange:oe}),t[21]=n.name,t[22]=oe,t[23]=O):O=t[23];let se;t[24]!==r.form.name||t[25]!==O?(se=(0,Z.jsx)($,{label:r.form.name,children:O}),t[24]=r.form.name,t[25]=O,t[26]=se):se=t[26];let A;t[27]===b?A=t[28]:(A=e=>b({description:e.target.value}),t[27]=b,t[28]=A);let j;t[29]!==n.description||t[30]!==A?(j=(0,Z.jsx)(`input`,{className:Q,value:n.description,onChange:A}),t[29]=n.description,t[30]=A,t[31]=j):j=t[31];let M;t[32]!==r.form.description||t[33]!==j?(M=(0,Z.jsx)($,{label:r.form.description,children:j}),t[32]=r.form.description,t[33]=j,t[34]=M):M=t[34];let N;t[35]!==n.projectId||t[36]!==r.form.noProject||t[37]!==r.form.project||t[38]!==_||t[39]!==a||t[40]!==b?(N=_?null:(0,Z.jsx)($,{label:r.form.project,children:(0,Z.jsxs)(f,{className:Q,value:n.projectId,onChange:e=>b({projectId:e.target.value}),children:[(0,Z.jsx)(p,{value:``,children:r.form.noProject}),a.map(qt)]})}),t[35]=n.projectId,t[36]=r.form.noProject,t[37]=r.form.project,t[38]=_,t[39]=a,t[40]=b,t[41]=N):N=t[41];let ce;t[42]===r.form.trigger?ce=t[43]:(ce=(0,Z.jsx)(Jt,{title:r.form.trigger}),t[42]=r.form.trigger,t[43]=ce);let le;t[44]===b?le=t[45]:(le=e=>b({triggerMode:e.target.value}),t[44]=b,t[45]=le);let P;t[46]===r.trigger.manual?P=t[47]:(P=(0,Z.jsx)(p,{value:`manual`,children:r.trigger.manual}),t[46]=r.trigger.manual,t[47]=P);let ue;t[48]===r.trigger.once?ue=t[49]:(ue=(0,Z.jsx)(p,{value:`once`,children:r.trigger.once}),t[48]=r.trigger.once,t[49]=ue);let F;t[50]===r.trigger.daily?F=t[51]:(F=(0,Z.jsx)(p,{value:`daily`,children:r.trigger.daily}),t[50]=r.trigger.daily,t[51]=F);let I;t[52]===r.trigger.weekly?I=t[53]:(I=(0,Z.jsx)(p,{value:`weekly`,children:r.trigger.weekly}),t[52]=r.trigger.weekly,t[53]=I);let de;t[54]===r.trigger.interval?de=t[55]:(de=(0,Z.jsx)(p,{value:`interval`,children:r.trigger.interval}),t[54]=r.trigger.interval,t[55]=de);let L;t[56]===r.trigger.customCron?L=t[57]:(L=(0,Z.jsx)(p,{value:`cron`,children:r.trigger.customCron}),t[56]=r.trigger.customCron,t[57]=L);let fe;t[58]===r.trigger.webhook?fe=t[59]:(fe=(0,Z.jsx)(p,{value:`webhook`,children:r.trigger.webhook}),t[58]=r.trigger.webhook,t[59]=fe);let R;t[60]===r.trigger.taskBlocked?R=t[61]:(R=(0,Z.jsx)(p,{value:`taskBlocked`,children:r.trigger.taskBlocked}),t[60]=r.trigger.taskBlocked,t[61]=R);let z;t[62]===r.trigger.noteCreated?z=t[63]:(z=(0,Z.jsx)(p,{value:`noteCreated`,children:r.trigger.noteCreated}),t[62]=r.trigger.noteCreated,t[63]=z);let pe;t[64]===r.trigger.workflowFailed?pe=t[65]:(pe=(0,Z.jsx)(p,{value:`workflowFailed`,children:r.trigger.workflowFailed}),t[64]=r.trigger.workflowFailed,t[65]=pe);let B;t[66]===r.trigger.sessionUpdated?B=t[67]:(B=(0,Z.jsx)(p,{value:`sessionUpdated`,children:r.trigger.sessionUpdated}),t[66]=r.trigger.sessionUpdated,t[67]=B);let V;t[68]===r.trigger.customEvent?V=t[69]:(V=(0,Z.jsx)(p,{value:`event`,children:r.trigger.customEvent}),t[68]=r.trigger.customEvent,t[69]=V);let U;t[70]!==n.triggerMode||t[71]!==le||t[72]!==P||t[73]!==ue||t[74]!==F||t[75]!==I||t[76]!==de||t[77]!==L||t[78]!==fe||t[79]!==R||t[80]!==z||t[81]!==pe||t[82]!==B||t[83]!==V?(U=(0,Z.jsxs)(f,{className:Q,value:n.triggerMode,onChange:le,children:[P,ue,F,I,de,L,fe,R,z,pe,B,V]}),t[70]=n.triggerMode,t[71]=le,t[72]=P,t[73]=ue,t[74]=F,t[75]=I,t[76]=de,t[77]=L,t[78]=fe,t[79]=R,t[80]=z,t[81]=pe,t[82]=B,t[83]=V,t[84]=U):U=t[84];let me;t[85]!==n.onceAt||t[86]!==n.triggerMode||t[87]!==r.form.onceAt||t[88]!==b?(me=n.triggerMode===`once`?(0,Z.jsx)($,{label:r.form.onceAt,children:(0,Z.jsx)(`input`,{className:Q,type:`datetime-local`,value:n.onceAt,onChange:e=>b({onceAt:e.target.value})})}):null,t[85]=n.onceAt,t[86]=n.triggerMode,t[87]=r.form.onceAt,t[88]=b,t[89]=me):me=t[89];let he;t[90]!==n.time||t[91]!==n.triggerMode||t[92]!==n.weekday||t[93]!==r.form.day||t[94]!==r.form.time||t[95]!==r.weekdays||t[96]!==b?(he=n.triggerMode===`daily`||n.triggerMode===`weekly`?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsx)($,{label:r.form.time,children:(0,Z.jsx)(H,{value:n.time,onChange:e=>b({time:e}),ariaLabel:r.form.time})}),n.triggerMode===`weekly`?(0,Z.jsx)($,{label:r.form.day,children:(0,Z.jsxs)(f,{className:Q,value:n.weekday,onChange:e=>b({weekday:e.target.value}),children:[(0,Z.jsx)(p,{value:`1`,children:r.weekdays.monday}),(0,Z.jsx)(p,{value:`2`,children:r.weekdays.tuesday}),(0,Z.jsx)(p,{value:`3`,children:r.weekdays.wednesday}),(0,Z.jsx)(p,{value:`4`,children:r.weekdays.thursday}),(0,Z.jsx)(p,{value:`5`,children:r.weekdays.friday}),(0,Z.jsx)(p,{value:`6`,children:r.weekdays.saturday}),(0,Z.jsx)(p,{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]=b,t[97]=he):he=t[97];let ge=n.triggerMode===`interval`?(0,Z.jsxs)(`div`,{className:`grid gap-3 rounded-lg border border-edge-subtle bg-surface-base p-3`,children:[(0,Z.jsx)($,{label:r.form.intervalEvery,children:(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,1fr)_10rem]`,children:[(0,Z.jsx)(`input`,{className:Q,type:`number`,min:6e4/Be(1,n.intervalUnit),step:`any`,inputMode:`decimal`,value:n.intervalValue,onChange:e=>b({intervalValue:e.target.value})}),(0,Z.jsxs)(f,{className:Q,value:n.intervalUnit,onChange:e=>{let t=e.target.value;b({intervalValue:Ve(n.intervalValue,n.intervalUnit,t),intervalUnit:t})},children:[(0,Z.jsx)(p,{value:`minute`,children:r.form.intervalUnits.minute}),(0,Z.jsx)(p,{value:`hour`,children:r.form.intervalUnits.hour}),(0,Z.jsx)(p,{value:`day`,children:r.form.intervalUnits.day}),(0,Z.jsx)(p,{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===S;return(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":n,className:x(`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:()=>b({intervalValue:e.value,intervalUnit:e.unit}),children:He(t,h)},`${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(S,h)}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:[r.form.nextThreeRuns,`:`,T.join(h===`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]!==b?(ve=n.triggerMode===`cron`?(0,Z.jsx)($,{label:r.form.expression,children:(0,Z.jsx)(`input`,{className:Q,value:n.cronExpr,onChange:e=>b({cronExpr:e.target.value})})}):null,t[98]=n.cronExpr,t[99]=n.triggerMode,t[100]=r.form.expression,t[101]=b,t[102]=ve):ve=t[102];let ye;t[103]!==n.triggerMode||t[104]!==n.webhookSecretId||t[105]!==r.form.secretId||t[106]!==b?(ye=n.triggerMode===`webhook`?(0,Z.jsx)($,{label:r.form.secretId,children:(0,Z.jsx)(`input`,{className:Q,value:n.webhookSecretId,onChange:e=>b({webhookSecretId:e.target.value})})}):null,t[103]=n.triggerMode,t[104]=n.webhookSecretId,t[105]=r.form.secretId,t[106]=b,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]!==b?(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=>b({eventType:e.target.value})})}),(0,Z.jsx)($,{label:r.form.eventSource,children:(0,Z.jsx)(`input`,{className:Q,value:n.eventSource,onChange:e=>b({eventSource:e.target.value})})})]}),(0,Z.jsxs)($,{label:r.form.eventPayloadMatch,children:[(0,Z.jsx)(`textarea`,{className:x(Q,`min-h-24 resize-y font-mono text-xs`),value:n.eventPayloadMatch,onChange:e=>b({eventPayloadMatch:e.target.value}),placeholder:`{
|
package/dist/gateway/static/root/assets/{binary-plugins-BM9B5kcm.js → binary-plugins-BJQe8TRu.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-preview-renderer-BDTD8YUe.js","assets/preload-helper-zJ_50EbN.js","assets/excel-worksheet-utils-EyvwNT4X.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
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"./preload-helper-zJ_50EbN.js";import{t as a}from"./messages-CTSgFlE4.js";import{Bi as o,Vi as s}from"./index-B0WJL9N1.js";import{t as c}from"./preview-open-alternatives-CsNVTKC0.js";import{t as l}from"./use-blob-object-url-D4BFuzZB.js";var u=e(t(),1),d=n();function f(e){let t=e.trim(),n=t.match(/^<pptx\s+filename="([^"]*)">\s*/),r=t;n&&(r=t.slice(n[0].length),r=r.replace(/\s*<\/pptx>\s*$/u,``).trim());let i=[],a=/<slide number="(\d+)">([\s\S]*?)<\/slide>/gu,o;for(;(o=a.exec(r))!==null;){let e=Number.parseInt(o[1],10),t=o[2].trim();i.push({slideNumber:e,text:t})}let s=[],c=/<!--([\s\S]*?)-->/gu,l;for(;(l=c.exec(r))!==null;)s.push(l[1].trim());return i.length===0?{ok:!1,raw:e}:{ok:!0,slides:i,notes:s}}var p=r();function m(e){let t=(0,d.c)(13),{text:n,slideLabel:r,emptySlideLabel:i}=e,a;t[0]===n?a=t[1]:(a=f(n),t[0]=n,t[1]=a);let o=a;if(!o.ok){let e;return t[2]===o.raw?e=t[3]:(e=(0,p.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg`,children:o.raw}),t[2]=o.raw,t[3]=e),e}let s;if(t[4]!==i||t[5]!==o.notes||t[6]!==o.slides||t[7]!==r){let e=[];if(o.notes.length>0){let n;t[9]===o.notes?n=t[10]:(n=o.notes.map(h),t[9]=o.notes,t[10]=n);let r;t[11]===n?r=t[12]:(r=(0,p.jsx)(`div`,{className:`mb-2 border-b border-edge-subtle pb-2 dark:border-edge`,role:`status`,children:n},`notes`),t[11]=n,t[12]=r),e.push(r)}for(let t of o.slides)e.push((0,p.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel p-3 dark:border-edge`,children:[(0,p.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-fg`,children:r(t.slideNumber)}),(0,p.jsx)(`div`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-fg`,children:t.text.length>0?t.text:i})]},t.slideNumber));s=(0,p.jsx)(`div`,{className:`flex flex-col gap-3`,children:e}),t[4]=i,t[5]=o.notes,t[6]=o.slides,t[7]=r,t[8]=s}else s=t[8];return s}function h(e){return(0,p.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e},e)}function g(e,t){return t===`pdf`?a(e).chat.attachmentPreviewPdfRendering:e===`zh`?t===`excel`?`正在加载电子表格…`:`正在加载文档…`:t===`excel`?`Loading spreadsheet...`:`Loading document...`}function _(e,t){e.innerHTML=``;let n=document.createElement(`p`);n.className=`p-4 text-sm text-fg-muted`,n.textContent=t,e.appendChild(n)}function v({language:e,buffer:t,kind:n,fileKey:r,containerEl:o,onPdfPageCount:s}){let c=(0,u.useRef)(null),[l,d]=(0,u.useState)(null),[f,p]=(0,u.useState)(!1);return(0,u.useLayoutEffect)(()=>{if(c.current?.(),c.current=null,d(null),p(!1),!t||!n||!o||!r)return;let l=!1;return _(o,g(e,n)),(async()=>{try{let r=await i(()=>import(`./attachment-preview-renderer-BDTD8YUe.js`),__vite__mapDeps([0,1,2]));if(l)return;let u=a(e).chat;if(n===`pdf`){let{cleanup:e}=await r.renderPdfInContainer(o,t,{loadingText:u.attachmentPreviewPdfRendering,loadMoreHint:u.attachmentPreviewPdfLoadMore,onPageCount:s});c.current=e}else if(n===`excel`){let{cleanup:e,truncated:n}=await r.renderExcelInContainer(o,t,{truncationNotice:u.attachmentPreviewExcelTruncated.replaceAll(`{rows}`,`500`).replaceAll(`{cols}`,`64`)});c.current=e,l||p(n)}else if(n===`docx`){let{cleanup:e}=await r.renderDocxInContainer(o,t);c.current=e}}catch(e){l||d(e instanceof Error?e.message:String(e))}})(),()=>{l=!0,c.current?.(),c.current=null}},[t,n,o,r,e,s]),{error:l,excelTruncated:f}}function y(e){let t=(0,d.c)(12),{props:n,message:r}=e,i;t[0]===n.language?i=t[1]:(i=a(n.language),t[0]=n.language,t[1]=i);let o=i,s=n.descriptor.context===`workspace`,l=!!n.actions.onOpenWithSystemApp&&(n.actions.canOpenWithSystemApp??!0)&&s,u=s?o.workspace.openSystemApp:void 0,f=s?o.workspace.chooseApp:void 0,m;return t[2]!==o.chat.attachmentPreviewDownloadFull||t[3]!==r||t[4]!==n.actions.canChooseOpenWithApp||t[5]!==n.actions.onChooseOpenWithApp||t[6]!==n.actions.onDownload||t[7]!==n.actions.onOpenWithSystemApp||t[8]!==l||t[9]!==u||t[10]!==f?(m=(0,p.jsx)(c,{message:r,downloadLabel:o.chat.attachmentPreviewDownloadFull,onDownload:n.actions.onDownload,openSystemLabel:u,onOpenWithSystemApp:n.actions.onOpenWithSystemApp,canOpenWithSystemApp:l,chooseAppLabel:f,onChooseOpenWithApp:n.actions.onChooseOpenWithApp,canChooseOpenWithApp:n.actions.canChooseOpenWithApp}),t[2]=o.chat.attachmentPreviewDownloadFull,t[3]=r,t[4]=n.actions.canChooseOpenWithApp,t[5]=n.actions.onChooseOpenWithApp,t[6]=n.actions.onDownload,t[7]=n.actions.onOpenWithSystemApp,t[8]=l,t[9]=u,t[10]=f,t[11]=m):m=t[11],m}function b(e){let t=a(e.language);return e.descriptor.context===`workspace`?t.workspace.openElsewhereHint:t.chat.attachmentPreviewOpenElsewhereHint}function x(e){let t=(0,d.c)(24),n;bb0:{if(!e.binaryBuffer){n=null;break bb0}let r;if(t[0]!==e.binaryBuffer||t[1]!==e.descriptor.fileName||t[2]!==e.descriptor.mimeType){let n=s(e.descriptor.fileName)??e.descriptor.mimeType??`image/png`;r=new Blob([e.binaryBuffer],{type:n}),t[0]=e.binaryBuffer,t[1]=e.descriptor.fileName,t[2]=e.descriptor.mimeType,t[3]=r}else r=t[3];n=r}let r=l(n),i;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(i={x:0,y:0},t[4]=i):i=t[4];let[a,o]=(0,u.useState)(i),c=(0,u.useRef)(null),f=(0,u.useRef)(null),m=e.controls?.zoom??1,h=e.controls?.rotation??0,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{o({x:0,y:0})},t[5]=g):g=t[5];let _;if(t[6]!==e.descriptor.id||t[7]!==h?(_=[e.descriptor.id,h],t[6]=e.descriptor.id,t[7]=h,t[8]=_):_=t[8],(0,u.useEffect)(g,_),!r)return null;let v;t[9]!==a.x||t[10]!==a.y?(v=e=>{e.button===0&&(c.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,ox:a.x,oy:a.y},e.currentTarget.setPointerCapture(e.pointerId))},t[9]=a.x,t[10]=a.y,t[11]=v):v=t[11];let y,b,x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{let t=c.current;!t||t.pointerId!==e.pointerId||o({x:t.ox+e.clientX-t.x,y:t.oy+e.clientY-t.y})},b=e=>{c.current?.pointerId===e.pointerId&&(c.current=null)},x=e=>{c.current?.pointerId===e.pointerId&&(c.current=null)},t[12]=y,t[13]=b,t[14]=x):(y=t[12],b=t[13],x=t[14]);let S=`translate(${a.x}px, ${a.y}px) scale(${m}) rotate(${h}deg)`,C=m>1?`grab`:`default`,w;t[15]!==S||t[16]!==C?(w={transform:S,cursor:C},t[15]=S,t[16]=C,t[17]=w):w=t[17];let T;t[18]!==r||t[19]!==w?(T=(0,p.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`max-h-full max-w-full select-none object-contain transition-transform duration-100`,style:w}),t[18]=r,t[19]=w,t[20]=T):T=t[20];let E;return t[21]!==T||t[22]!==v?(E=(0,p.jsx)(`div`,{ref:f,className:`flex min-h-0 flex-1 touch-none items-center justify-center overflow-hidden bg-surface-base px-3 py-4 dark:bg-surface-hover/20`,onPointerDown:v,onPointerMove:y,onPointerUp:b,onPointerCancel:x,children:T}),t[21]=T,t[22]=v,t[23]=E):E=t[23],E}function S(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`pdf`}),t[0]=e,t[1]=n),n}function C(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`docx`}),t[0]=e,t[1]=n),n}function w(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`excel`}),t[0]=e,t[1]=n),n}function T(e){let t=(0,d.c)(31),n=(0,u.useRef)(null),[r,i]=(0,u.useState)(null),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=e=>{n.current=e,i(e)},t[0]=o):o=t[0];let s=o,c=e.kind===`pdf`?e.controls?.setPageCount:void 0,l;t[1]!==r||t[2]!==e.binaryBuffer||t[3]!==e.descriptor.id||t[4]!==e.kind||t[5]!==e.language||t[6]!==c?(l={language:e.language,buffer:e.binaryBuffer,kind:e.kind,fileKey:e.descriptor.id,containerEl:r,onPdfPageCount:c},t[1]=r,t[2]=e.binaryBuffer,t[3]=e.descriptor.id,t[4]=e.kind,t[5]=e.language,t[6]=c,t[7]=l):l=t[7];let{error:f,excelTruncated:m}=v(l),h=a(e.language),g=e.kind===`pdf`?e.controls?.zoom??1:1,_=e.kind===`pdf`?e.controls?.rotation??0:0,x=e.kind===`pdf`?e.controls?.page??1:1,S,C;t[8]!==e.kind||t[9]!==_||t[10]!==g?(S=()=>{e.kind!==`pdf`||!n.current||(n.current.style.setProperty(`--xopc-preview-pdf-zoom`,String(g)),n.current.style.setProperty(`--xopc-preview-pdf-rotation`,`${_}deg`),n.current.querySelectorAll(`[data-pdf-page]`).forEach(e=>{let t=e.dataset.pdfBaseHeight??(e.offsetHeight>0?String(e.offsetHeight):void 0);t&&(e.dataset.pdfBaseHeight=t,e.style.height=`${Number(t)*g}px`),e.style.transformOrigin=`top center`,e.style.transform=`scale(${g}) rotate(${_}deg)`,e.style.marginBottom=g===1?``:`${Math.max(16,24*g)}px`}))},C=[e.kind,_,g],t[8]=e.kind,t[9]=_,t[10]=g,t[11]=S,t[12]=C):(S=t[11],C=t[12]),(0,u.useEffect)(S,C);let w,T;if(t[13]!==x||t[14]!==e.kind?(w=()=>{e.kind!==`pdf`||!n.current||n.current.querySelector(`[data-pdf-page="${x}"]`)?.scrollIntoView({block:`start`})},T=[x,e.kind],t[13]=x,t[14]=e.kind,t[15]=w,t[16]=T):(w=t[15],T=t[16]),(0,u.useEffect)(w,T),f){let n;t[17]===e?n=t[18]:(n=b(e),t[17]=e,t[18]=n);let r;t[19]!==e||t[20]!==n?(r=(0,p.jsx)(y,{props:e,message:n}),t[19]=e,t[20]=n,t[21]=r):r=t[21];let i;t[22]===f?i=t[23]:(i=(0,p.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:f}),t[22]=f,t[23]=i);let a;return t[24]!==r||t[25]!==i?(a=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:[r,i]}),t[24]=r,t[25]=i,t[26]=a):a=t[26],a}if(e.kind===`excel`){let n=m?(0,p.jsx)(y,{props:e,message:h.chat.attachmentPreviewExcelTruncated.replaceAll(`{rows}`,`500`).replaceAll(`{cols}`,`64`)}):null,r;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,p.jsx)(`div`,{ref:s,className:`docx-preview-host min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`}),t[27]=r):r=t[27];let i;return t[28]===n?i=t[29]:(i=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:[n,r]}),t[28]=n,t[29]=i),i}let E;return t[30]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,p.jsx)(`div`,{ref:s,className:`docx-preview-host min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`}),t[30]=E):E=t[30],E}function E(e){let t=(0,d.c)(23),n;t[0]===e.language?n=t[1]:(n=a(e.language),t[0]=e.language,t[1]=n);let r=n,i=e.extractedText||r.chat.attachmentPreviewNoText,s=!!e.extractedTextTruncated||i.length>3e5,c;t[2]===i?c=t[3]:(c=i.length>3e5?i.slice(0,o):i,t[2]=i,t[3]=c);let l=c,u;t[4]!==r.chat.attachmentPreviewOpenElsewhereTruncated||t[5]!==e||t[6]!==s?(u=s?(0,p.jsx)(y,{props:e,message:r.chat.attachmentPreviewOpenElsewhereTruncated}):null,t[4]=r.chat.attachmentPreviewOpenElsewhereTruncated,t[5]=e,t[6]=s,t[7]=u):u=t[7];let f;t[8]!==r.chat.attachmentPreviewPptxTruncated||t[9]!==s?(f=s?(0,p.jsx)(`p`,{className:`mb-2 border-b border-edge-subtle pb-2 text-xs text-fg-muted dark:border-edge`,children:r.chat.attachmentPreviewPptxTruncated}):null,t[8]=r.chat.attachmentPreviewPptxTruncated,t[9]=s,t[10]=f):f=t[10];let h;t[11]===r.chat.attachmentPreviewPptxSlide?h=t[12]:(h=e=>r.chat.attachmentPreviewPptxSlide.replaceAll(`{n}`,String(e)),t[11]=r.chat.attachmentPreviewPptxSlide,t[12]=h);let g;t[13]!==r.chat.attachmentPreviewPptxEmptySlide||t[14]!==h||t[15]!==l?(g=(0,p.jsx)(m,{text:l,slideLabel:h,emptySlideLabel:r.chat.attachmentPreviewPptxEmptySlide}),t[13]=r.chat.attachmentPreviewPptxEmptySlide,t[14]=h,t[15]=l,t[16]=g):g=t[16];let _;t[17]!==f||t[18]!==g?(_=(0,p.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:[f,g]}),t[17]=f,t[18]=g,t[19]=_):_=t[19];let v;return t[20]!==u||t[21]!==_?(v=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:[u,_]}),t[20]=u,t[21]=_,t[22]=v):v=t[22],v}export{C as DocxPreviewPluginView,x as InteractiveImagePreview,S as PdfPreviewPluginView,E as PptxPreviewPluginView,w as SpreadsheetPreviewPluginView};
|
|
2
|
+
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"./preload-helper-zJ_50EbN.js";import{t as a}from"./messages-CTSgFlE4.js";import{Bi as o,Vi as s}from"./index-DUz0O54y.js";import{t as c}from"./preview-open-alternatives-CsNVTKC0.js";import{t as l}from"./use-blob-object-url-D4BFuzZB.js";var u=e(t(),1),d=n();function f(e){let t=e.trim(),n=t.match(/^<pptx\s+filename="([^"]*)">\s*/),r=t;n&&(r=t.slice(n[0].length),r=r.replace(/\s*<\/pptx>\s*$/u,``).trim());let i=[],a=/<slide number="(\d+)">([\s\S]*?)<\/slide>/gu,o;for(;(o=a.exec(r))!==null;){let e=Number.parseInt(o[1],10),t=o[2].trim();i.push({slideNumber:e,text:t})}let s=[],c=/<!--([\s\S]*?)-->/gu,l;for(;(l=c.exec(r))!==null;)s.push(l[1].trim());return i.length===0?{ok:!1,raw:e}:{ok:!0,slides:i,notes:s}}var p=r();function m(e){let t=(0,d.c)(13),{text:n,slideLabel:r,emptySlideLabel:i}=e,a;t[0]===n?a=t[1]:(a=f(n),t[0]=n,t[1]=a);let o=a;if(!o.ok){let e;return t[2]===o.raw?e=t[3]:(e=(0,p.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg`,children:o.raw}),t[2]=o.raw,t[3]=e),e}let s;if(t[4]!==i||t[5]!==o.notes||t[6]!==o.slides||t[7]!==r){let e=[];if(o.notes.length>0){let n;t[9]===o.notes?n=t[10]:(n=o.notes.map(h),t[9]=o.notes,t[10]=n);let r;t[11]===n?r=t[12]:(r=(0,p.jsx)(`div`,{className:`mb-2 border-b border-edge-subtle pb-2 dark:border-edge`,role:`status`,children:n},`notes`),t[11]=n,t[12]=r),e.push(r)}for(let t of o.slides)e.push((0,p.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel p-3 dark:border-edge`,children:[(0,p.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-fg`,children:r(t.slideNumber)}),(0,p.jsx)(`div`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-fg`,children:t.text.length>0?t.text:i})]},t.slideNumber));s=(0,p.jsx)(`div`,{className:`flex flex-col gap-3`,children:e}),t[4]=i,t[5]=o.notes,t[6]=o.slides,t[7]=r,t[8]=s}else s=t[8];return s}function h(e){return(0,p.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e},e)}function g(e,t){return t===`pdf`?a(e).chat.attachmentPreviewPdfRendering:e===`zh`?t===`excel`?`正在加载电子表格…`:`正在加载文档…`:t===`excel`?`Loading spreadsheet...`:`Loading document...`}function _(e,t){e.innerHTML=``;let n=document.createElement(`p`);n.className=`p-4 text-sm text-fg-muted`,n.textContent=t,e.appendChild(n)}function v({language:e,buffer:t,kind:n,fileKey:r,containerEl:o,onPdfPageCount:s}){let c=(0,u.useRef)(null),[l,d]=(0,u.useState)(null),[f,p]=(0,u.useState)(!1);return(0,u.useLayoutEffect)(()=>{if(c.current?.(),c.current=null,d(null),p(!1),!t||!n||!o||!r)return;let l=!1;return _(o,g(e,n)),(async()=>{try{let r=await i(()=>import(`./attachment-preview-renderer-BDTD8YUe.js`),__vite__mapDeps([0,1,2]));if(l)return;let u=a(e).chat;if(n===`pdf`){let{cleanup:e}=await r.renderPdfInContainer(o,t,{loadingText:u.attachmentPreviewPdfRendering,loadMoreHint:u.attachmentPreviewPdfLoadMore,onPageCount:s});c.current=e}else if(n===`excel`){let{cleanup:e,truncated:n}=await r.renderExcelInContainer(o,t,{truncationNotice:u.attachmentPreviewExcelTruncated.replaceAll(`{rows}`,`500`).replaceAll(`{cols}`,`64`)});c.current=e,l||p(n)}else if(n===`docx`){let{cleanup:e}=await r.renderDocxInContainer(o,t);c.current=e}}catch(e){l||d(e instanceof Error?e.message:String(e))}})(),()=>{l=!0,c.current?.(),c.current=null}},[t,n,o,r,e,s]),{error:l,excelTruncated:f}}function y(e){let t=(0,d.c)(12),{props:n,message:r}=e,i;t[0]===n.language?i=t[1]:(i=a(n.language),t[0]=n.language,t[1]=i);let o=i,s=n.descriptor.context===`workspace`,l=!!n.actions.onOpenWithSystemApp&&(n.actions.canOpenWithSystemApp??!0)&&s,u=s?o.workspace.openSystemApp:void 0,f=s?o.workspace.chooseApp:void 0,m;return t[2]!==o.chat.attachmentPreviewDownloadFull||t[3]!==r||t[4]!==n.actions.canChooseOpenWithApp||t[5]!==n.actions.onChooseOpenWithApp||t[6]!==n.actions.onDownload||t[7]!==n.actions.onOpenWithSystemApp||t[8]!==l||t[9]!==u||t[10]!==f?(m=(0,p.jsx)(c,{message:r,downloadLabel:o.chat.attachmentPreviewDownloadFull,onDownload:n.actions.onDownload,openSystemLabel:u,onOpenWithSystemApp:n.actions.onOpenWithSystemApp,canOpenWithSystemApp:l,chooseAppLabel:f,onChooseOpenWithApp:n.actions.onChooseOpenWithApp,canChooseOpenWithApp:n.actions.canChooseOpenWithApp}),t[2]=o.chat.attachmentPreviewDownloadFull,t[3]=r,t[4]=n.actions.canChooseOpenWithApp,t[5]=n.actions.onChooseOpenWithApp,t[6]=n.actions.onDownload,t[7]=n.actions.onOpenWithSystemApp,t[8]=l,t[9]=u,t[10]=f,t[11]=m):m=t[11],m}function b(e){let t=a(e.language);return e.descriptor.context===`workspace`?t.workspace.openElsewhereHint:t.chat.attachmentPreviewOpenElsewhereHint}function x(e){let t=(0,d.c)(24),n;bb0:{if(!e.binaryBuffer){n=null;break bb0}let r;if(t[0]!==e.binaryBuffer||t[1]!==e.descriptor.fileName||t[2]!==e.descriptor.mimeType){let n=s(e.descriptor.fileName)??e.descriptor.mimeType??`image/png`;r=new Blob([e.binaryBuffer],{type:n}),t[0]=e.binaryBuffer,t[1]=e.descriptor.fileName,t[2]=e.descriptor.mimeType,t[3]=r}else r=t[3];n=r}let r=l(n),i;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(i={x:0,y:0},t[4]=i):i=t[4];let[a,o]=(0,u.useState)(i),c=(0,u.useRef)(null),f=(0,u.useRef)(null),m=e.controls?.zoom??1,h=e.controls?.rotation??0,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{o({x:0,y:0})},t[5]=g):g=t[5];let _;if(t[6]!==e.descriptor.id||t[7]!==h?(_=[e.descriptor.id,h],t[6]=e.descriptor.id,t[7]=h,t[8]=_):_=t[8],(0,u.useEffect)(g,_),!r)return null;let v;t[9]!==a.x||t[10]!==a.y?(v=e=>{e.button===0&&(c.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,ox:a.x,oy:a.y},e.currentTarget.setPointerCapture(e.pointerId))},t[9]=a.x,t[10]=a.y,t[11]=v):v=t[11];let y,b,x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{let t=c.current;!t||t.pointerId!==e.pointerId||o({x:t.ox+e.clientX-t.x,y:t.oy+e.clientY-t.y})},b=e=>{c.current?.pointerId===e.pointerId&&(c.current=null)},x=e=>{c.current?.pointerId===e.pointerId&&(c.current=null)},t[12]=y,t[13]=b,t[14]=x):(y=t[12],b=t[13],x=t[14]);let S=`translate(${a.x}px, ${a.y}px) scale(${m}) rotate(${h}deg)`,C=m>1?`grab`:`default`,w;t[15]!==S||t[16]!==C?(w={transform:S,cursor:C},t[15]=S,t[16]=C,t[17]=w):w=t[17];let T;t[18]!==r||t[19]!==w?(T=(0,p.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`max-h-full max-w-full select-none object-contain transition-transform duration-100`,style:w}),t[18]=r,t[19]=w,t[20]=T):T=t[20];let E;return t[21]!==T||t[22]!==v?(E=(0,p.jsx)(`div`,{ref:f,className:`flex min-h-0 flex-1 touch-none items-center justify-center overflow-hidden bg-surface-base px-3 py-4 dark:bg-surface-hover/20`,onPointerDown:v,onPointerMove:y,onPointerUp:b,onPointerCancel:x,children:T}),t[21]=T,t[22]=v,t[23]=E):E=t[23],E}function S(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`pdf`}),t[0]=e,t[1]=n),n}function C(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`docx`}),t[0]=e,t[1]=n),n}function w(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`excel`}),t[0]=e,t[1]=n),n}function T(e){let t=(0,d.c)(31),n=(0,u.useRef)(null),[r,i]=(0,u.useState)(null),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=e=>{n.current=e,i(e)},t[0]=o):o=t[0];let s=o,c=e.kind===`pdf`?e.controls?.setPageCount:void 0,l;t[1]!==r||t[2]!==e.binaryBuffer||t[3]!==e.descriptor.id||t[4]!==e.kind||t[5]!==e.language||t[6]!==c?(l={language:e.language,buffer:e.binaryBuffer,kind:e.kind,fileKey:e.descriptor.id,containerEl:r,onPdfPageCount:c},t[1]=r,t[2]=e.binaryBuffer,t[3]=e.descriptor.id,t[4]=e.kind,t[5]=e.language,t[6]=c,t[7]=l):l=t[7];let{error:f,excelTruncated:m}=v(l),h=a(e.language),g=e.kind===`pdf`?e.controls?.zoom??1:1,_=e.kind===`pdf`?e.controls?.rotation??0:0,x=e.kind===`pdf`?e.controls?.page??1:1,S,C;t[8]!==e.kind||t[9]!==_||t[10]!==g?(S=()=>{e.kind!==`pdf`||!n.current||(n.current.style.setProperty(`--xopc-preview-pdf-zoom`,String(g)),n.current.style.setProperty(`--xopc-preview-pdf-rotation`,`${_}deg`),n.current.querySelectorAll(`[data-pdf-page]`).forEach(e=>{let t=e.dataset.pdfBaseHeight??(e.offsetHeight>0?String(e.offsetHeight):void 0);t&&(e.dataset.pdfBaseHeight=t,e.style.height=`${Number(t)*g}px`),e.style.transformOrigin=`top center`,e.style.transform=`scale(${g}) rotate(${_}deg)`,e.style.marginBottom=g===1?``:`${Math.max(16,24*g)}px`}))},C=[e.kind,_,g],t[8]=e.kind,t[9]=_,t[10]=g,t[11]=S,t[12]=C):(S=t[11],C=t[12]),(0,u.useEffect)(S,C);let w,T;if(t[13]!==x||t[14]!==e.kind?(w=()=>{e.kind!==`pdf`||!n.current||n.current.querySelector(`[data-pdf-page="${x}"]`)?.scrollIntoView({block:`start`})},T=[x,e.kind],t[13]=x,t[14]=e.kind,t[15]=w,t[16]=T):(w=t[15],T=t[16]),(0,u.useEffect)(w,T),f){let n;t[17]===e?n=t[18]:(n=b(e),t[17]=e,t[18]=n);let r;t[19]!==e||t[20]!==n?(r=(0,p.jsx)(y,{props:e,message:n}),t[19]=e,t[20]=n,t[21]=r):r=t[21];let i;t[22]===f?i=t[23]:(i=(0,p.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:f}),t[22]=f,t[23]=i);let a;return t[24]!==r||t[25]!==i?(a=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:[r,i]}),t[24]=r,t[25]=i,t[26]=a):a=t[26],a}if(e.kind===`excel`){let n=m?(0,p.jsx)(y,{props:e,message:h.chat.attachmentPreviewExcelTruncated.replaceAll(`{rows}`,`500`).replaceAll(`{cols}`,`64`)}):null,r;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,p.jsx)(`div`,{ref:s,className:`docx-preview-host min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`}),t[27]=r):r=t[27];let i;return t[28]===n?i=t[29]:(i=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:[n,r]}),t[28]=n,t[29]=i),i}let E;return t[30]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,p.jsx)(`div`,{ref:s,className:`docx-preview-host min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`}),t[30]=E):E=t[30],E}function E(e){let t=(0,d.c)(23),n;t[0]===e.language?n=t[1]:(n=a(e.language),t[0]=e.language,t[1]=n);let r=n,i=e.extractedText||r.chat.attachmentPreviewNoText,s=!!e.extractedTextTruncated||i.length>3e5,c;t[2]===i?c=t[3]:(c=i.length>3e5?i.slice(0,o):i,t[2]=i,t[3]=c);let l=c,u;t[4]!==r.chat.attachmentPreviewOpenElsewhereTruncated||t[5]!==e||t[6]!==s?(u=s?(0,p.jsx)(y,{props:e,message:r.chat.attachmentPreviewOpenElsewhereTruncated}):null,t[4]=r.chat.attachmentPreviewOpenElsewhereTruncated,t[5]=e,t[6]=s,t[7]=u):u=t[7];let f;t[8]!==r.chat.attachmentPreviewPptxTruncated||t[9]!==s?(f=s?(0,p.jsx)(`p`,{className:`mb-2 border-b border-edge-subtle pb-2 text-xs text-fg-muted dark:border-edge`,children:r.chat.attachmentPreviewPptxTruncated}):null,t[8]=r.chat.attachmentPreviewPptxTruncated,t[9]=s,t[10]=f):f=t[10];let h;t[11]===r.chat.attachmentPreviewPptxSlide?h=t[12]:(h=e=>r.chat.attachmentPreviewPptxSlide.replaceAll(`{n}`,String(e)),t[11]=r.chat.attachmentPreviewPptxSlide,t[12]=h);let g;t[13]!==r.chat.attachmentPreviewPptxEmptySlide||t[14]!==h||t[15]!==l?(g=(0,p.jsx)(m,{text:l,slideLabel:h,emptySlideLabel:r.chat.attachmentPreviewPptxEmptySlide}),t[13]=r.chat.attachmentPreviewPptxEmptySlide,t[14]=h,t[15]=l,t[16]=g):g=t[16];let _;t[17]!==f||t[18]!==g?(_=(0,p.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:[f,g]}),t[17]=f,t[18]=g,t[19]=_):_=t[19];let v;return t[20]!==u||t[21]!==_?(v=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:[u,_]}),t[20]=u,t[21]=_,t[22]=v):v=t[22],v}export{C as DocxPreviewPluginView,x as InteractiveImagePreview,S as PdfPreviewPluginView,E as PptxPreviewPluginView,w as SpreadsheetPreviewPluginView};
|