import{j as t,P as Z,L as $,C as Lt,D as P,a as B,b as O,c as A,d as I,e as V,B as p,F as tt,a5 as et,O as _t,R as ot,E as zt,f as $t,r as i}from"./index-CwVkcMR-.js";import{I as D}from"./input-B5ad6Rfz.js";import{S as st,a as at,b as ct,c as nt,d as z}from"./select-CGtvCG8I.js";import{T as Pt,a as Bt,b as J,c as K}from"./tabs-Bd_3HnQp.js";import{C as rt}from"./checkbox-CbtT7pld.js";import{t as l}from"./index-Dxvx0mlR.js";import{s as j,t as Ot}from"./automation-CscX6ZsM.js";import{B as N}from"./badge-DgJ0w7jf.js";import{C as At}from"./circle-x-DBoylLde.js";import{L as b}from"./label-mg-tHjNc.js";import{T as It}from"./textarea-BZOXMpxW.js";import{S as it}from"./square-pen-C8Ol72WC.js";import{C as pt,b as Vt,c as Rt,d as qt,a as lt}from"./card-C5qBu7CR.js";import{P as Ht}from"./play-_cqG4jyc.js";import{C as Qt}from"./copy-CKzeWvtb.js";import{T as mt}from"./trash-2-BPpnm3Sz.js";import{S as Ut}from"./search-1PdnG-g5.js";import{P as Xt}from"./plus-CaJ-dB4A.js";import"./index-CBIZnJrN.js";import"./chevron-up-DM77dvsL.js";function Gt(o){return{id:o.id,name:o.name,code:o.code||"",description:o.description||"",type:o.type||"shell",content:o.content||"",timeout:o.timeout||300,version:o.version||1,run_count:o.run_count||0,created_at:o.created_at,updated_at:o.updated_at}}const w=[{value:"shell",label:"Shell",sample:`#!/bin/bash # 系统巡检脚本 echo "===== 系统信息 =====" uname -a echo "" echo "===== 磁盘使用 =====" df -h echo "" echo "===== 内存使用 =====" free -h `},{value:"python",label:"Python",sample:`#!/usr/bin/env python3 # 主机信息采集 import platform, socket print("主机名:", socket.gethostname()) print("系统:", platform.platform()) print("Python:", platform.python_version()) `}],W={shell:"border-green-500/30 text-green-500 bg-green-500/10",bash:"border-green-500/30 text-green-500 bg-green-500/10",python:"border-blue-500/30 text-blue-500 bg-blue-500/10",powershell:"border-cyan-500/30 text-cyan-500 bg-cyan-500/10",yaml:"border-purple-500/30 text-purple-500 bg-purple-500/10"},dt=o=>t.jsx(N,{"code-path":"src/components/automation/script-helpers.tsx:66:3",variant:"outline",className:W[o]||W.shell,children:(o||"shell").toUpperCase()}),Y=()=>`sc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`;function xt(o){switch(o){case"pending":return t.jsxs(N,{"code-path":"src/components/automation/script-helpers.tsx:78:14",variant:"outline",className:"gap-1",children:[t.jsx(Lt,{"code-path":"src/components/automation/script-helpers.tsx:78:57",className:"w-3 h-3"}),"等待中"]});case"running":return t.jsxs(N,{"code-path":"src/components/automation/script-helpers.tsx:80:14",variant:"default",className:"bg-blue-500 gap-1",children:[t.jsx($,{"code-path":"src/components/automation/script-helpers.tsx:80:69",className:"w-3 h-3 animate-spin"}),"执行中"]});case"success":return t.jsxs(N,{"code-path":"src/components/automation/script-helpers.tsx:82:14",variant:"default",className:"bg-green-600 gap-1",children:[t.jsx(Z,{"code-path":"src/components/automation/script-helpers.tsx:82:70",className:"w-3 h-3"}),"成功"]});case"failed":return t.jsxs(N,{"code-path":"src/components/automation/script-helpers.tsx:84:14",variant:"destructive",className:"gap-1",children:[t.jsx(At,{"code-path":"src/components/automation/script-helpers.tsx:84:61",className:"w-3 h-3"}),"失败"]});default:return t.jsx(N,{"code-path":"src/components/automation/script-helpers.tsx:86:14",variant:"secondary",children:o||"未知"})}}const Jt=o=>{if(!o)return"-";const a=new Date(o);return Number.isNaN(a.getTime())?"-":a.toLocaleString("zh-CN",{hour12:!1})},Kt=({open:o,onOpenChange:a,editingId:s,editingCode:n,formData:m,setFormData:x,onTypeChange:f,onSave:C})=>t.jsx(P,{"code-path":"src/components/automation/ScriptFormDialog.tsx:38:5",open:o,onOpenChange:a,children:t.jsxs(B,{"code-path":"src/components/automation/ScriptFormDialog.tsx:39:7",className:"max-w-4xl max-h-[90vh]",children:[t.jsxs(O,{"code-path":"src/components/automation/ScriptFormDialog.tsx:40:9",children:[t.jsx(A,{"code-path":"src/components/automation/ScriptFormDialog.tsx:41:11",children:s!==null?"编辑脚本":"新建脚本"}),t.jsx(I,{"code-path":"src/components/automation/ScriptFormDialog.tsx:42:11",children:"编写运维脚本,支持 Shell / Python / PowerShell"})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:44:9",className:"space-y-4 overflow-y-auto max-h-[60vh] pr-1",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:45:11",className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:46:13",children:[t.jsx(b,{"code-path":"src/components/automation/ScriptFormDialog.tsx:47:15",children:"名称"}),t.jsx(D,{"code-path":"src/components/automation/ScriptFormDialog.tsx:48:15",value:m.name,onChange:r=>x({...m,name:r.target.value}),placeholder:"如:系统巡检脚本"})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:54:13",children:[t.jsx(b,{"code-path":"src/components/automation/ScriptFormDialog.tsx:55:15",children:"类型"}),t.jsxs(st,{"code-path":"src/components/automation/ScriptFormDialog.tsx:56:15",value:m.type,onValueChange:f,children:[t.jsx(at,{"code-path":"src/components/automation/ScriptFormDialog.tsx:57:17",children:t.jsx(ct,{"code-path":"src/components/automation/ScriptFormDialog.tsx:57:32"})}),t.jsx(nt,{"code-path":"src/components/automation/ScriptFormDialog.tsx:58:17",children:w.map(r=>t.jsx(z,{"code-path":"src/components/automation/ScriptFormDialog.tsx:60:21",value:r.value,children:r.label},r.value))})]})]})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:66:11",children:[t.jsx(b,{"code-path":"src/components/automation/ScriptFormDialog.tsx:67:13",children:"描述"}),t.jsx(D,{"code-path":"src/components/automation/ScriptFormDialog.tsx:68:13",value:m.description,onChange:r=>x({...m,description:r.target.value}),placeholder:"脚本用途说明"})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:74:11",className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:75:13",children:[t.jsx(b,{"code-path":"src/components/automation/ScriptFormDialog.tsx:76:15",children:"超时(秒)"}),t.jsx(D,{"code-path":"src/components/automation/ScriptFormDialog.tsx:77:15",type:"number",value:m.timeout,onChange:r=>x({...m,timeout:Number(r.target.value)}),placeholder:"300"})]}),s!==null&&t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:85:15",children:[t.jsx(b,{"code-path":"src/components/automation/ScriptFormDialog.tsx:86:17",children:"编码"}),t.jsx(D,{"code-path":"src/components/automation/ScriptFormDialog.tsx:87:17",value:n,disabled:!0,className:"font-mono text-xs"})]})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:91:11",children:[t.jsx(b,{"code-path":"src/components/automation/ScriptFormDialog.tsx:92:13",children:"脚本内容"}),t.jsx(It,{"code-path":"src/components/automation/ScriptFormDialog.tsx:93:13",value:m.content,onChange:r=>x({...m,content:r.target.value}),className:"min-h-[360px] font-mono text-sm",placeholder:"在此编写脚本内容..."})]})]}),t.jsxs(V,{"code-path":"src/components/automation/ScriptFormDialog.tsx:101:9",children:[t.jsx(p,{"code-path":"src/components/automation/ScriptFormDialog.tsx:102:11",variant:"outline",onClick:()=>a(!1),children:"取消"}),t.jsxs(p,{"code-path":"src/components/automation/ScriptFormDialog.tsx:103:11",onClick:C,children:[t.jsx(Z,{"code-path":"src/components/automation/ScriptFormDialog.tsx:104:13",className:"w-4 h-4 mr-2"}),s!==null?"保存":"创建"]})]})]})}),Wt=({open:o,onOpenChange:a,script:s,onEdit:n})=>t.jsx(P,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:20:5",open:o,onOpenChange:a,children:t.jsxs(B,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:21:7",className:"max-w-4xl max-h-[90vh]",children:[t.jsxs(O,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:22:9",children:[t.jsxs(A,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:23:11",className:"flex items-center gap-2",children:[t.jsx(tt,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:24:13",className:"w-5 h-5 text-purple-500"}),s?.name,s&&dt(s.type)]}),t.jsx(I,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:28:11",children:s?.description})]}),t.jsx(et,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:30:9",className:"h-[500px] w-full rounded-md border bg-black",children:t.jsx("pre",{"code-path":"src/components/automation/ScriptDetailDialog.tsx:31:11",className:"p-4 font-mono text-sm text-green-400 whitespace-pre-wrap",children:s?.content||"(空)"})}),t.jsxs(V,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:35:9",children:[t.jsx(p,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:36:11",variant:"outline",onClick:()=>a(!1),children:"关闭"}),s&&t.jsxs(p,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:38:13",onClick:()=>n(s),children:[t.jsx(it,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:39:15",className:"w-4 h-4 mr-2"}),"编辑"]})]})]})}),Yt=({open:o,onOpenChange:a,exec:s})=>t.jsx(P,{"code-path":"src/components/automation/ScriptLogsDialog.tsx:18:5",open:o,onOpenChange:a,children:t.jsxs(B,{"code-path":"src/components/automation/ScriptLogsDialog.tsx:19:7",className:"max-w-4xl max-h-[90vh]",children:[t.jsxs(O,{"code-path":"src/components/automation/ScriptLogsDialog.tsx:20:9",children:[t.jsx(A,{"code-path":"src/components/automation/ScriptLogsDialog.tsx:21:11",children:"执行日志"}),t.jsxs(I,{"code-path":"src/components/automation/ScriptLogsDialog.tsx:22:11",children:[s?.task_name," · ",xt(s?.status||"")]})]}),t.jsx(et,{"code-path":"src/components/automation/ScriptLogsDialog.tsx:26:9",className:"h-[480px] w-full rounded-md border bg-black",children:t.jsx("pre",{"code-path":"src/components/automation/ScriptLogsDialog.tsx:27:11",className:"p-4 font-mono text-sm text-green-400 whitespace-pre-wrap",children:s?.output||"暂无日志输出..."})}),t.jsx(V,{"code-path":"src/components/automation/ScriptLogsDialog.tsx:31:9",children:t.jsx(p,{"code-path":"src/components/automation/ScriptLogsDialog.tsx:32:11",variant:"outline",onClick:()=>a(!1),children:"关闭"})})]})});function Zt({script:o,selected:a,executing:s,onToggleSelect:n,onView:m,onExecute:x,onEdit:f,onClone:C,onDelete:r}){return t.jsxs(pt,{"code-path":"src/components/automation/ScriptCard.tsx:26:5",className:"hover:shadow-md transition-shadow",children:[t.jsxs(Vt,{"code-path":"src/components/automation/ScriptCard.tsx:27:7",className:"pb-3",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptCard.tsx:28:9",className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptCard.tsx:29:11",className:"flex items-center gap-2 min-w-0",children:[t.jsx(rt,{"code-path":"src/components/automation/ScriptCard.tsx:30:13",checked:a,onCheckedChange:n,className:"border-[var(--dg-border)]"}),t.jsx(tt,{"code-path":"src/components/automation/ScriptCard.tsx:35:13",className:"w-5 h-5 text-purple-500 shrink-0"}),t.jsx(Rt,{"code-path":"src/components/automation/ScriptCard.tsx:36:13",className:"text-base truncate",children:o.name})]}),dt(o.type)]}),t.jsx(qt,{"code-path":"src/components/automation/ScriptCard.tsx:40:9",className:"line-clamp-2",children:o.description||"暂无描述"})]}),t.jsxs(lt,{"code-path":"src/components/automation/ScriptCard.tsx:42:7",className:"pt-0",children:[t.jsx("div",{"code-path":"src/components/automation/ScriptCard.tsx:43:9",className:"bg-muted/40 rounded-md p-2 mb-3 font-mono text-xs text-muted-foreground overflow-hidden",children:t.jsx("pre",{"code-path":"src/components/automation/ScriptCard.tsx:44:11",className:"whitespace-pre-wrap line-clamp-3",children:o.content})}),t.jsxs("div",{"code-path":"src/components/automation/ScriptCard.tsx:46:9",className:"flex items-center justify-between text-xs text-muted-foreground mb-3",children:[t.jsxs("span",{"code-path":"src/components/automation/ScriptCard.tsx:47:11",children:["执行 ",o.run_count," 次 · v",o.version]}),t.jsxs("span",{"code-path":"src/components/automation/ScriptCard.tsx:48:11",children:["超时 ",o.timeout,"s"]})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptCard.tsx:50:9",className:"flex items-center gap-1",children:[t.jsx(p,{"code-path":"src/components/automation/ScriptCard.tsx:51:11",variant:"ghost",size:"sm",title:"查看内容",onClick:m,children:t.jsx(_t,{"code-path":"src/components/automation/ScriptCard.tsx:52:13",className:"w-4 h-4"})}),t.jsx(p,{"code-path":"src/components/automation/ScriptCard.tsx:54:11",variant:"ghost",size:"sm",title:"执行",disabled:s,onClick:x,children:s?t.jsx($,{"code-path":"src/components/automation/ScriptCard.tsx:56:17",className:"w-4 h-4 animate-spin text-blue-600"}):t.jsx(Ht,{"code-path":"src/components/automation/ScriptCard.tsx:57:17",className:"w-4 h-4 text-green-600"})}),t.jsx(p,{"code-path":"src/components/automation/ScriptCard.tsx:59:11",variant:"ghost",size:"sm",title:"编辑",onClick:f,children:t.jsx(it,{"code-path":"src/components/automation/ScriptCard.tsx:60:13",className:"w-4 h-4"})}),t.jsx(p,{"code-path":"src/components/automation/ScriptCard.tsx:62:11",variant:"ghost",size:"sm",title:"复制",onClick:C,children:t.jsx(Qt,{"code-path":"src/components/automation/ScriptCard.tsx:63:13",className:"w-4 h-4"})}),t.jsx(p,{"code-path":"src/components/automation/ScriptCard.tsx:65:11",variant:"ghost",size:"sm",title:"删除",onClick:r,children:t.jsx(mt,{"code-path":"src/components/automation/ScriptCard.tsx:66:13",className:"w-4 h-4 text-red-600"})})]})]})]})}function te({executions:o,onRefresh:a,onViewLogs:s}){return t.jsxs("div",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:16:5",className:"space-y-4",children:[t.jsx("div",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:17:7",className:"flex justify-end",children:t.jsxs(p,{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:18:9",variant:"outline",onClick:a,children:[t.jsx(ot,{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:19:11",className:"w-4 h-4 mr-2"}),"刷新"]})}),t.jsx(pt,{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:23:7",children:t.jsx(lt,{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:24:9",className:"p-0",children:t.jsx("div",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:25:11",className:"overflow-x-auto",children:t.jsxs("table",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:26:13",className:"w-full",children:[t.jsx("thead",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:27:15",className:"bg-muted/50",children:t.jsxs("tr",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:28:17",children:[t.jsx("th",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:29:19",className:"px-4 py-3 text-left text-sm font-medium",children:"#"}),t.jsx("th",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:30:19",className:"px-4 py-3 text-left text-sm font-medium",children:"脚本"}),t.jsx("th",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:31:19",className:"px-4 py-3 text-left text-sm font-medium",children:"状态"}),t.jsx("th",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:32:19",className:"px-4 py-3 text-left text-sm font-medium",children:"开始时间"}),t.jsx("th",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:33:19",className:"px-4 py-3 text-left text-sm font-medium",children:"耗时"}),t.jsx("th",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:34:19",className:"px-4 py-3 text-left text-sm font-medium",children:"操作"})]})}),t.jsx("tbody",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:37:15",className:"divide-y",children:o.length===0?t.jsx("tr",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:39:19",children:t.jsx("td",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:40:21",colSpan:6,className:"px-4 py-8 text-center text-muted-foreground",children:"暂无执行记录"})}):o.map(n=>t.jsxs("tr",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:46:21",className:"hover:bg-muted/50",children:[t.jsx("td",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:47:23",className:"px-4 py-3 text-sm text-muted-foreground",children:n.id}),t.jsx("td",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:48:23",className:"px-4 py-3 text-sm",children:n.task_name}),t.jsx("td",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:49:23",className:"px-4 py-3",children:xt(n.status)}),t.jsx("td",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:50:23",className:"px-4 py-3 text-sm text-muted-foreground",children:Jt(n.started_at)}),t.jsx("td",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:51:23",className:"px-4 py-3 text-sm",children:n.duration?`${(n.duration/1e3).toFixed(1)}s`:"-"}),t.jsx("td",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:54:23",className:"px-4 py-3",children:t.jsx(p,{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:55:25",variant:"ghost",size:"sm",title:"查看日志",onClick:()=>s(n),children:t.jsx(zt,{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:56:27",className:"w-4 h-4"})})})]},n.id))})]})})})})]})}function be(){const o=$t(),[a,s]=i.useState([]),[n,m]=i.useState([]),[x,f]=i.useState(!1),[C,r]=i.useState(!1),[R,ht]=i.useState(""),[k,ut]=i.useState("all"),[gt,St]=i.useState("scripts"),[h,T]=i.useState([]),[jt,E]=i.useState(!1),[ft,L]=i.useState(!1),[vt,q]=i.useState(!1),[y,H]=i.useState(null),[Q,U]=i.useState(null),[bt,Nt]=i.useState(null),[u,M]=i.useState({name:"",description:"",content:"",type:"shell",timeout:300}),S=async()=>{f(!0);try{const c=(await j.getScripts({page_size:100}))?.list||[];s(c.map(Gt))}catch{l.error("获取脚本列表失败")}finally{f(!1)}},F=async()=>{try{const c=(await Ot.getExecutions({task_type:"script",page_size:50}))?.list||[];m(c)}catch{}};i.useEffect(()=>{S(),F()},[]);const Ct=()=>{H(null),M({name:"",description:"",content:w[0].sample,type:"shell",timeout:300}),E(!0)},X=e=>{H(e.id),U(e),M({name:e.name,description:e.description,content:e.content,type:e.type,timeout:e.timeout}),E(!0),L(!1)},yt=e=>{M(c=>{const g=w.some(_=>_.sample===c.content)||c.content==="",d=w.find(_=>_.value===e);return{...c,type:e,content:y===null&&g&&d?d.sample:c.content}})},Dt=async()=>{if(!u.name.trim()||!u.content.trim()){l.error("请填写名称和脚本内容");return}const e={name:u.name.trim(),code:Y(),description:u.description,type:u.type,content:u.content,timeout:Number(u.timeout)||300};try{y!==null?(await j.updateScript(y,e),l.success("脚本更新成功")):(await j.createScript(e),l.success("脚本创建成功")),E(!1),S()}catch{l.error(y!==null?"更新失败":"创建失败")}},wt=async e=>{try{await j.createScript({name:`${e.name} (副本)`,code:Y(),description:e.description,type:e.type,content:e.content,timeout:e.timeout}),l.success("复制成功"),S()}catch{l.error("复制失败")}},Tt=async e=>{if(await o({title:"删除脚本",description:`确定删除「${e.name}」吗?此操作不可恢复。`,confirmText:"删除",variant:"destructive"}))try{await j.deleteScript(e.id),l.success("删除成功"),S()}catch{l.error("删除失败")}},Et=async e=>{if(await o({title:"执行脚本",description:`将在 AIOps 主机上本地执行「${e.name}」(${e.type})。`,confirmText:"开始执行"})){r(!0);try{const g=await j.executeScript(e.id),d=g?.data??g;d?.status==="success"?l.success(`执行成功,耗时 ${d.duration??0}ms`):l.error(`执行失败,耗时 ${d?.duration??0}ms`,{description:(d?.output||"").slice(0,120)}),S(),F()}catch{l.error("执行请求失败")}finally{r(!1)}}},v=a.filter(e=>{const c=R.toLowerCase(),g=e.name.toLowerCase().includes(c)||e.description.toLowerCase().includes(c)||e.code.toLowerCase().includes(c),d=k==="all"||e.type===k;return g&&d}),Mt=e=>{T(c=>c.includes(e)?c.filter(g=>g!==e):[...c,e])},G=v.length>0&&h.length===v.length,Ft=()=>{T(G?[]:v.map(e=>e.id))},kt=async()=>{if(!(h.length===0||!await o({title:"批量删除脚本",description:`确定删除选中的 ${h.length} 个脚本吗?此操作不可恢复。`,confirmText:"批量删除",variant:"destructive"})))try{await j.batchDelete(h),l.success(`已删除 ${h.length} 个脚本`),T([]),S()}catch{l.error("批量删除失败")}};return t.jsxs("div",{"code-path":"src/components/automation/ScriptManager.tsx:252:5",className:"space-y-6",children:[t.jsxs(Pt,{"code-path":"src/components/automation/ScriptManager.tsx:254:7",value:gt,onValueChange:e=>{St(e),e==="jobs"&&F()},children:[t.jsxs(Bt,{"code-path":"src/components/automation/ScriptManager.tsx:255:9",className:"grid w-full grid-cols-2 lg:w-[360px]",children:[t.jsx(J,{"code-path":"src/components/automation/ScriptManager.tsx:256:11",value:"scripts",children:"脚本库"}),t.jsx(J,{"code-path":"src/components/automation/ScriptManager.tsx:257:11",value:"jobs",children:"执行记录"})]}),t.jsxs(K,{"code-path":"src/components/automation/ScriptManager.tsx:261:9",value:"scripts",className:"space-y-4",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptManager.tsx:262:11",className:"flex flex-wrap items-center justify-between gap-4",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptManager.tsx:263:13",className:"flex items-center gap-2 flex-1 min-w-[300px]",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptManager.tsx:264:15",className:"relative flex-1",children:[t.jsx(Ut,{"code-path":"src/components/automation/ScriptManager.tsx:265:17",className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),t.jsx(D,{"code-path":"src/components/automation/ScriptManager.tsx:266:17",placeholder:"搜索名称、编码、描述...",value:R,onChange:e=>ht(e.target.value),className:"pl-10"})]}),t.jsxs(st,{"code-path":"src/components/automation/ScriptManager.tsx:273:15",value:k,onValueChange:ut,children:[t.jsx(at,{"code-path":"src/components/automation/ScriptManager.tsx:274:17",className:"w-[140px]",children:t.jsx(ct,{"code-path":"src/components/automation/ScriptManager.tsx:275:19",placeholder:"类型"})}),t.jsxs(nt,{"code-path":"src/components/automation/ScriptManager.tsx:277:17",children:[t.jsx(z,{"code-path":"src/components/automation/ScriptManager.tsx:278:19",value:"all",children:"全部类型"}),w.map(e=>t.jsx(z,{"code-path":"src/components/automation/ScriptManager.tsx:280:21",value:e.value,children:e.label},e.value))]})]})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptManager.tsx:285:13",className:"flex items-center gap-2",children:[t.jsxs(p,{"code-path":"src/components/automation/ScriptManager.tsx:286:15",variant:"outline",onClick:S,children:[t.jsx(ot,{"code-path":"src/components/automation/ScriptManager.tsx:287:17",className:"w-4 h-4 mr-2"}),"刷新"]}),t.jsxs(p,{"code-path":"src/components/automation/ScriptManager.tsx:290:15",onClick:Ct,children:[t.jsx(Xt,{"code-path":"src/components/automation/ScriptManager.tsx:291:17",className:"w-4 h-4 mr-2"}),"新建脚本"]})]})]}),h.length>0&&t.jsxs("div",{"code-path":"src/components/automation/ScriptManager.tsx:299:13",className:"flex items-center justify-between gap-4 px-4 py-2.5 rounded-lg border border-[var(--dg-border)] bg-[var(--dg-bg-secondary)]",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptManager.tsx:300:15",className:"flex items-center gap-3",children:[t.jsx(rt,{"code-path":"src/components/automation/ScriptManager.tsx:301:17",checked:G,onCheckedChange:Ft,className:"border-[var(--dg-border)]"}),t.jsxs("span",{"code-path":"src/components/automation/ScriptManager.tsx:306:17",className:"text-sm text-[var(--dg-text-secondary)]",children:["已选择 ",h.length," 项 / 共 ",v.length," 项"]})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptManager.tsx:310:15",className:"flex items-center gap-2",children:[t.jsx(p,{"code-path":"src/components/automation/ScriptManager.tsx:311:17",variant:"outline",size:"sm",onClick:()=>T([]),children:"取消选择"}),t.jsxs(p,{"code-path":"src/components/automation/ScriptManager.tsx:314:17",variant:"outline",size:"sm",className:"border-red-500/30 text-red-400 hover:bg-red-500/10",onClick:kt,children:[t.jsx(mt,{"code-path":"src/components/automation/ScriptManager.tsx:320:19",className:"w-4 h-4 mr-2"}),"批量删除"]})]})]}),t.jsx("div",{"code-path":"src/components/automation/ScriptManager.tsx:328:11",className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:x?t.jsxs("div",{"code-path":"src/components/automation/ScriptManager.tsx:330:15",className:"col-span-full text-center py-8 text-muted-foreground",children:[t.jsx($,{"code-path":"src/components/automation/ScriptManager.tsx:331:17",className:"w-5 h-5 animate-spin inline mr-2"}),"加载中..."]}):v.length===0?t.jsx("div",{"code-path":"src/components/automation/ScriptManager.tsx:335:15",className:"col-span-full text-center py-8 text-muted-foreground",children:a.length===0?"暂无脚本,点击「新建脚本」创建第一个":"未匹配到符合条件的脚本"}):v.map(e=>t.jsx(Zt,{"code-path":"src/components/automation/ScriptManager.tsx:340:17",script:e,selected:h.includes(e.id),executing:C,onToggleSelect:()=>Mt(e.id),onView:()=>{U(e),L(!0)},onExecute:()=>Et(e),onEdit:()=>X(e),onClone:()=>wt(e),onDelete:()=>Tt(e)},e.id))})]}),t.jsx(K,{"code-path":"src/components/automation/ScriptManager.tsx:358:9",value:"jobs",children:t.jsx(te,{"code-path":"src/components/automation/ScriptManager.tsx:359:11",executions:n,onRefresh:F,onViewLogs:e=>{Nt(e),q(!0)}})})]}),t.jsx(Kt,{"code-path":"src/components/automation/ScriptManager.tsx:368:7",open:jt,onOpenChange:E,editingId:y,editingCode:Q?.code||"",formData:u,setFormData:M,onTypeChange:yt,onSave:Dt}),t.jsx(Wt,{"code-path":"src/components/automation/ScriptManager.tsx:380:7",open:ft,onOpenChange:L,script:Q,onEdit:X}),t.jsx(Yt,{"code-path":"src/components/automation/ScriptManager.tsx:388:7",open:vt,onOpenChange:q,exec:bt})]})}export{be as ScriptManager};