@zhin.js/console 1.0.47 → 1.0.49

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/index.js CHANGED
@@ -1,138 +1,150 @@
1
- import{jsx as a,jsxs as d,Fragment as ie}from"./react-jsx-runtime.js";import*as E from"./react.js";import rr,{useState as T,useEffect as G,useMemo as es,useRef as ir,useCallback as Nt,PureComponent as ar,StrictMode as lr}from"./react.js";import{createRoot as or}from"./react-dom-client.js";import{Moon as cr,Sun as dr,Menu as ur,Search as fr,LogOut as hr,AlertCircle as ae,Package as le,Bot as Ve,Activity as Vt,TrendingUp as mr,Clock as ts,Cpu as pr,MemoryStick as jt,FileText as ss,Server as ns,Plug as rs,Settings as We,Shield as Gs,Database as ht,Wrench as Hs,Brain as Qs,Layers as is,Box as Xs,Terminal as Zs,ChevronDown as as,ChevronUp as gr,Check as en,Code as tn,Info as wt,Lock as yr,Calendar as br,List as sn,Trash2 as qt,Plus as Nr,GitBranch as wr,CheckCircle as ls,AlertTriangle as nn,X as os,Loader2 as be,Save as vt,ArrowLeft as Ls,Wifi as vr,WifiOff as xr,Zap as kr,RefreshCw as cs,Circle as Sr,XCircle as Or,FormInput as Cr,FileCode as Tr,KeyRound as rn,FileWarning as Ar,Eye as Ir,EyeOff as Er,Home as Lr}from"./lucide-react.js";import{cn as I,useDispatch as $r,useSelector as Ce,Link as _r,setActiveMenu as jr,toggleSidebar as Mr,Outlet as Pr,useConfig as Rr,useConfigYaml as Br,useEnvFiles as Dr,persistor as Fr,store as Kr,useWebSocket as Ur,addPage as Vr,DynamicRouter as qr}from"./client.js";import{cva as ds}from"./cva.js";import{ScrollArea as De,Separator as Jr,Switch as $s,Select as J,Accordion as qe,Checkbox as _s,Tabs as xt,Tooltip as Je}from"./radix-ui.js";import{useNavigate as us,useParams as zr}from"./react-router.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&n(l)}).observe(document,{childList:!0,subtree:!0});function t(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(r){if(r.ep)return;r.ep=!0;const i=t(r);fetch(r.href,i)}})();var Mt={exports:{}},Pt={};var js;function Yr(){if(js)return Pt;js=1;var s=rr;function e(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var t=typeof Object.is=="function"?Object.is:e,n=s.useSyncExternalStore,r=s.useRef,i=s.useEffect,l=s.useMemo,o=s.useDebugValue;return Pt.useSyncExternalStoreWithSelector=function(c,u,m,h,f){var g=r(null);if(g.current===null){var b={hasValue:!1,value:null};g.current=b}else b=g.current;g=l(function(){function y(v){if(!k){if(k=!0,O=v,v=h(v),f!==void 0&&b.hasValue){var N=b.value;if(f(N,v))return w=N}return w=v}if(N=w,t(O,v))return N;var C=h(v);return f!==void 0&&f(N,C)?(O=v,N):(O=v,w=C)}var k=!1,O,w,S=m===void 0?null:m;return[function(){return y(u())},S===null?void 0:function(){return y(S())}]},[u,m,h,f]);var p=n(c,g[0],g[1]);return i(function(){b.hasValue=!0,b.value=p},[p]),o(p),p},Pt}var Ms;function Wr(){return Ms||(Ms=1,Mt.exports=Yr()),Mt.exports}Wr();function Gr(s){s()}function Hr(){let s=null,e=null;return{clear(){s=null,e=null},notify(){Gr(()=>{let t=s;for(;t;)t.callback(),t=t.next})},get(){const t=[];let n=s;for(;n;)t.push(n),n=n.next;return t},subscribe(t){let n=!0;const r=e={callback:t,next:null,prev:e};return r.prev?r.prev.next=r:s=r,function(){!n||s===null||(n=!1,r.next?r.next.prev=r.prev:e=r.prev,r.prev?r.prev.next=r.next:s=r.next)}}}}var Ps={notify(){},get:()=>[]};function Qr(s,e){let t,n=Ps,r=0,i=!1;function l(p){m();const y=n.subscribe(p);let k=!1;return()=>{k||(k=!0,y(),h())}}function o(){n.notify()}function c(){b.onStateChange&&b.onStateChange()}function u(){return i}function m(){r++,t||(t=s.subscribe(c),n=Hr())}function h(){r--,t&&r===0&&(t(),t=void 0,n.clear(),n=Ps)}function f(){i||(i=!0,m())}function g(){i&&(i=!1,h())}const b={addNestedSub:l,notifyNestedSubs:o,handleChangeWrapper:c,isSubscribed:u,trySubscribe:f,tryUnsubscribe:g,getListeners:()=>n};return b}var Xr=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Zr=Xr(),ei=()=>typeof navigator<"u"&&navigator.product==="ReactNative",ti=ei(),si=()=>Zr||ti?E.useLayoutEffect:E.useEffect,ni=si(),ri=Symbol.for("react-redux-context"),ii=typeof globalThis<"u"?globalThis:{};function ai(){if(!E.createContext)return{};const s=ii[ri]??=new Map;let e=s.get(E.createContext);return e||(e=E.createContext(null),s.set(E.createContext,e)),e}var li=ai();function oi(s){const{children:e,context:t,serverState:n,store:r}=s,i=E.useMemo(()=>{const c=Qr(r);return{store:r,subscription:c,getServerState:n?()=>n:void 0}},[r,n]),l=E.useMemo(()=>r.getState(),[r]);ni(()=>{const{subscription:c}=i;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),l!==r.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[i,l]);const o=t||li;return E.createElement(o.Provider,{value:i},e)}var ci=oi;const di={light:{background:"0 0% 100%",foreground:"240 10% 3.9%",card:"0 0% 100%","card-foreground":"240 10% 3.9%",popover:"0 0% 100%","popover-foreground":"240 10% 3.9%",primary:"240 5.9% 10%","primary-foreground":"0 0% 98%",secondary:"240 4.8% 95.9%","secondary-foreground":"240 5.9% 10%",muted:"240 4.8% 95.9%","muted-foreground":"240 3.8% 46.1%",accent:"240 4.8% 95.9%","accent-foreground":"240 5.9% 10%",destructive:"0 84.2% 60.2%","destructive-foreground":"0 0% 98%",border:"240 5.9% 90%",input:"240 5.9% 90%",ring:"240 5.9% 10%",radius:"0.5rem","chart-1":"240 5.9% 10%","chart-2":"240 3.8% 46.1%","chart-3":"240 5.9% 90%","chart-4":"240 4.8% 95.9%","chart-5":"0 0% 100%",sidebar:"0 0% 98%","sidebar-foreground":"240 5.3% 26.1%","sidebar-primary":"240 5.9% 10%","sidebar-primary-foreground":"0 0% 98%","sidebar-accent":"240 4.8% 95.9%","sidebar-accent-foreground":"240 5.9% 10%","sidebar-border":"220 13% 91%","sidebar-ring":"240 5.9% 10%"},dark:{background:"240 10% 3.9%",foreground:"0 0% 98%",card:"240 10% 3.9%","card-foreground":"0 0% 98%",popover:"240 10% 3.9%","popover-foreground":"0 0% 98%",primary:"0 0% 98%","primary-foreground":"240 5.9% 10%",secondary:"240 3.7% 15.9%","secondary-foreground":"0 0% 98%",muted:"240 3.7% 15.9%","muted-foreground":"240 5% 64.9%",accent:"240 3.7% 15.9%","accent-foreground":"0 0% 98%",destructive:"0 62.8% 30.6%","destructive-foreground":"0 0% 98%",border:"240 3.7% 15.9%",input:"240 3.7% 15.9%",ring:"240 4.9% 83.9%",radius:"0.5rem","chart-1":"0 0% 98%","chart-2":"240 5% 64.9%","chart-3":"240 3.7% 15.9%","chart-4":"240 10% 3.9%","chart-5":"240 5.9% 10%",sidebar:"240 5.9% 10%","sidebar-foreground":"240 4.8% 95.9%","sidebar-primary":"0 0% 98%","sidebar-primary-foreground":"240 5.9% 10%","sidebar-accent":"240 3.7% 15.9%","sidebar-accent-foreground":"240 4.8% 95.9%","sidebar-border":"240 3.7% 15.9%","sidebar-ring":"240 4.9% 83.9%"}};function an(s){const e=document.documentElement,t=di[s];e.classList.remove("light","dark"),e.classList.add(s),Object.entries(t).forEach(([n,r])=>{e.style.setProperty(`--${n}`,r)}),localStorage.setItem("theme",s)}function ln(){const s=localStorage.getItem("theme");return s&&(s==="light"||s==="dark")?s:window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function ui(){const s=ln();return an(s),s}function fi(){const[s,e]=T(ln);return G(()=>{an(s)},[s]),{theme:s,setTheme:e,toggleTheme:()=>{e(n=>n==="light"?"dark":"light")}}}function hi(){const{theme:s,toggleTheme:e}=fi();return a("button",{onClick:e,className:"p-2 hover:bg-accent rounded-lg transition-colors text-foreground",title:s==="light"?"切换到暗色模式":"切换到亮色模式",children:s==="light"?a(cr,{className:"w-5 h-5"}):a(dr,{className:"w-5 h-5"})})}const mi=ds("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),M=E.forwardRef(({className:s,variant:e,size:t,...n},r)=>a("button",{className:I(mi({variant:e,size:t,className:s})),ref:r,...n}));M.displayName="Button";const V=E.forwardRef(({className:s,type:e,...t},n)=>a("input",{type:e,className:I("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:n,...t}));V.displayName="Input";const on=E.forwardRef(({className:s,children:e,...t},n)=>d(De.Root,{ref:n,className:I("relative overflow-hidden",s),...t,children:[a(De.Viewport,{className:"h-full w-full rounded-[inherit]",children:e}),a(cn,{}),a(De.Corner,{})]}));on.displayName="ScrollArea";const cn=E.forwardRef(({className:s,orientation:e="vertical",...t},n)=>a(De.Scrollbar,{ref:n,orientation:e,className:I("flex touch-none select-none transition-colors",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",s),...t,children:a(De.Thumb,{className:"relative flex-1 rounded-full bg-border"})}));cn.displayName="ScrollBar";const kt="zhin_api_token";function pi(){return localStorage.getItem(kt)}function gi(s){localStorage.setItem(kt,s)}function dn(){localStorage.removeItem(kt)}function yi(){return!!localStorage.getItem(kt)}async function fe(s,e){const t=pi(),n=new Headers(e?.headers);t&&n.set("Authorization",`Bearer ${t}`);const r=await fetch(s,{...e,headers:n});return r.status===401&&(dn(),window.dispatchEvent(new CustomEvent("zhin:auth-required"))),r}function bi(){const s=$r(),e=Ce(i=>i.ui.sidebarOpen),t=Ce(i=>i.ui.activeMenu),n=Ce(i=>i.route.routes),r=es(()=>{const i=n.find(l=>l.key==="dashboard-layout");return!i||!i.children?[]:i.children.filter(l=>!l.meta?.hideInMenu&&l.key!=="dashboard-layout").map((l,o)=>({key:l.key||`menu-item-${o}`,title:l.title,index:l.index,icon:l.icon,href:l.path}))},[n]);return d("div",{className:"flex h-screen bg-background",children:[d("div",{className:I("flex flex-col border-r bg-sidebar transition-all duration-300",e?"w-64":"w-16"),children:[a("div",{className:"p-4 border-b",children:d("div",{className:I("flex items-center transition-all duration-300",e?"gap-3":"justify-center"),children:[a("div",{className:"flex items-center justify-center w-9 h-9 min-w-9 rounded-lg bg-foreground text-background font-bold text-lg",children:"Z"}),e&&d("div",{className:"flex flex-col",children:[a("span",{className:"text-base font-semibold",children:"Zhin.js"}),a("span",{className:"text-xs text-muted-foreground",children:"管理控制台"})]})]})}),a(on,{className:"flex-1",children:a("div",{className:"p-2 space-y-1",children:r.map(i=>{const l=t===i.key;return d(_r,{to:i.href,onClick:()=>s(jr(i.key)),className:I("menu-item",l&&"active",!e&&"justify-center px-2"),children:[a("span",{className:"shrink-0",children:i.icon}),e&&a("span",{className:"truncate",children:i.title})]},i.key)})})})]}),d("div",{className:"flex flex-col flex-1 overflow-hidden",children:[d("header",{className:"flex items-center justify-between h-14 px-4 border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",children:[d("div",{className:"flex items-center gap-3",children:[a(M,{variant:"ghost",size:"icon",onClick:()=>s(Mr()),children:a(ur,{className:"h-5 w-5"})}),d("div",{className:"flex flex-col",children:[a("h2",{className:"text-sm font-semibold",children:"控制台"}),a("span",{className:"text-xs text-muted-foreground",children:"欢迎回来"})]})]}),a("div",{className:"hidden md:flex flex-1 max-w-md mx-6",children:d("div",{className:"relative w-full",children:[a(fr,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a(V,{placeholder:"搜索功能、插件、设置...",className:"pl-9 bg-muted/50"})]})}),d("div",{className:"flex items-center gap-1",children:[a(hi,{}),a(M,{variant:"ghost",size:"icon",title:"退出登录",onClick:()=>{dn(),window.dispatchEvent(new CustomEvent("zhin:auth-required"))},children:a(hr,{className:"h-4 w-4"})})]})]}),a("main",{className:"flex-1 overflow-auto",children:a("div",{className:"max-w-7xl mx-auto p-6",children:a(Pr,{})})})]})]})}const _=E.forwardRef(({className:s,...e},t)=>a("div",{ref:t,className:I("rounded-lg border bg-card text-card-foreground shadow-sm",s),...e}));_.displayName="Card";const se=E.forwardRef(({className:s,...e},t)=>a("div",{ref:t,className:I("flex flex-col space-y-1.5 p-6",s),...e}));se.displayName="CardHeader";const ne=E.forwardRef(({className:s,...e},t)=>a("div",{ref:t,className:I("text-lg font-semibold leading-none tracking-tight",s),...e}));ne.displayName="CardTitle";const Fe=E.forwardRef(({className:s,...e},t)=>a("div",{ref:t,className:I("text-sm text-muted-foreground",s),...e}));Fe.displayName="CardDescription";const P=E.forwardRef(({className:s,...e},t)=>a("div",{ref:t,className:I("p-6 pt-0",s),...e}));P.displayName="CardContent";const Ni=E.forwardRef(({className:s,...e},t)=>a("div",{ref:t,className:I("flex items-center p-6 pt-0",s),...e}));Ni.displayName="CardFooter";const wi=ds("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground shadow",outline:"text-foreground",success:"border-transparent bg-emerald-100 text-emerald-800 dark:bg-emerald-900/30 dark:text-emerald-400",warning:"border-transparent bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400"}},defaultVariants:{variant:"default"}});function L({className:s,variant:e,...t}){return a("div",{className:I(wi({variant:e}),s),...t})}const vi=ds("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",success:"border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-800 dark:bg-emerald-950/50 dark:text-emerald-400 [&>svg]:text-emerald-600 dark:[&>svg]:text-emerald-400",warning:"border-amber-200 bg-amber-50 text-amber-800 dark:border-amber-800 dark:bg-amber-950/50 dark:text-amber-400 [&>svg]:text-amber-600 dark:[&>svg]:text-amber-400"}},defaultVariants:{variant:"default"}}),z=E.forwardRef(({className:s,variant:e,...t},n)=>a("div",{ref:n,role:"alert",className:I(vi({variant:e}),s),...t}));z.displayName="Alert";const xi=E.forwardRef(({className:s,...e},t)=>a("h5",{ref:t,className:I("mb-1 font-medium leading-none tracking-tight",s),...e}));xi.displayName="AlertTitle";const Y=E.forwardRef(({className:s,...e},t)=>a("div",{ref:t,className:I("text-sm [&_p]:leading-relaxed",s),...e}));Y.displayName="AlertDescription";function U({className:s,...e}){return a("div",{className:I("animate-pulse rounded-md bg-primary/10",s),...e})}function ki(){const s=us(),[e,t]=T(null),[n,r]=T(null),[i,l]=T(!0),[o,c]=T(null);G(()=>{u();const f=setInterval(u,5e3);return()=>clearInterval(f)},[]);const u=async()=>{try{const[f,g]=await Promise.all([fe("/api/stats"),fe("/api/system/status")]);if(!f.ok||!g.ok)throw new Error("API 请求失败");const b=await f.json(),p=await g.json();b.success&&p.success&&(t(b.data),r(p.data),c(null))}catch(f){c(f.message)}finally{l(!1)}},m=f=>{const g=Math.floor(f/86400),b=Math.floor(f%86400/3600),p=Math.floor(f%3600/60);return`${g}天 ${b}小时 ${p}分钟`},h=f=>`${(f/1024/1024).toFixed(2)} MB`;return i?d("div",{className:"space-y-6",children:[d("div",{children:[a(U,{className:"h-8 w-48"}),a(U,{className:"h-4 w-64 mt-2"})]}),a("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[...Array(4)].map((f,g)=>a(U,{className:"h-32"},g))})]}):o?a("div",{className:"flex items-center justify-center h-full",children:d(z,{variant:"destructive",className:"max-w-md",children:[a(ae,{className:"h-4 w-4"}),d(Y,{children:["加载失败: ",o]})]})}):d("div",{className:"space-y-6",children:[d("div",{children:[a("h1",{className:"text-2xl font-bold tracking-tight",children:"系统概览"}),a("p",{className:"text-muted-foreground",children:"实时监控您的机器人框架运行状态"})]}),d("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[d(_,{children:[d(se,{className:"flex flex-row items-center justify-between pb-2",children:[a(ne,{className:"text-sm font-medium text-muted-foreground",children:"插件总数"}),a(le,{className:"h-4 w-4 text-muted-foreground"})]}),d(P,{children:[a("div",{className:"text-3xl font-bold",children:e?.plugins.total||0}),d("p",{className:"text-xs text-muted-foreground mt-1",children:[a(L,{variant:"secondary",className:"mr-1",children:e?.plugins.active||0}),"个活跃"]})]})]}),d(_,{children:[d(se,{className:"flex flex-row items-center justify-between pb-2",children:[a(ne,{className:"text-sm font-medium text-muted-foreground",children:"机器人"}),a(Ve,{className:"h-4 w-4 text-muted-foreground"})]}),d(P,{children:[a("div",{className:"text-3xl font-bold",children:e?.bots.total||0}),d("p",{className:"text-xs text-muted-foreground mt-1",children:[a(L,{variant:"success",className:"mr-1",children:e?.bots.online||0}),"个在线"]})]})]}),d(_,{children:[d(se,{className:"flex flex-row items-center justify-between pb-2",children:[a(ne,{className:"text-sm font-medium text-muted-foreground",children:"命令数量"}),a(Vt,{className:"h-4 w-4 text-muted-foreground"})]}),d(P,{children:[a("div",{className:"text-3xl font-bold",children:e?.commands||0}),a("p",{className:"text-xs text-muted-foreground mt-1",children:"可用命令"})]})]}),d(_,{children:[d(se,{className:"flex flex-row items-center justify-between pb-2",children:[a(ne,{className:"text-sm font-medium text-muted-foreground",children:"组件数量"}),a(mr,{className:"h-4 w-4 text-muted-foreground"})]}),d(P,{children:[a("div",{className:"text-3xl font-bold",children:e?.components||0}),a("p",{className:"text-xs text-muted-foreground mt-1",children:"已注册组件"})]})]})]}),d("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[d(_,{children:[d(se,{children:[a(ne,{children:"系统信息"}),a(Fe,{children:"服务器运行状态"})]}),d(P,{className:"space-y-3",children:[d("div",{className:"flex justify-between items-center",children:[d("div",{className:"flex items-center gap-2 text-sm",children:[a(ts,{className:"h-4 w-4 text-muted-foreground"}),"运行时间"]}),a(L,{variant:"secondary",children:n?m(n.uptime):"-"})]}),d("div",{className:"flex justify-between items-center",children:[d("div",{className:"flex items-center gap-2 text-sm",children:[a(pr,{className:"h-4 w-4 text-muted-foreground"}),"平台"]}),a(L,{variant:"secondary",children:n?.platform||"-"})]}),d("div",{className:"flex justify-between items-center",children:[d("div",{className:"flex items-center gap-2 text-sm",children:[a(Vt,{className:"h-4 w-4 text-muted-foreground"}),"Node 版本"]}),a(L,{variant:"secondary",children:n?.nodeVersion||"-"})]})]})]}),d(_,{children:[d(se,{children:[a(ne,{children:"资源使用"}),a(Fe,{children:"内存使用情况"})]}),d(P,{className:"space-y-3",children:[d("div",{className:"flex justify-between items-center",children:[d("div",{className:"flex items-center gap-2 text-sm",children:[a(jt,{className:"h-4 w-4 text-muted-foreground"}),"堆内存使用"]}),a(L,{variant:"secondary",children:e?`${e.memory.toFixed(2)} MB`:"-"})]}),d("div",{className:"flex justify-between items-center",children:[d("div",{className:"flex items-center gap-2 text-sm",children:[a(jt,{className:"h-4 w-4 text-muted-foreground"}),"总堆内存"]}),a(L,{variant:"secondary",children:n?h(n.memory.heapTotal):"-"})]}),d("div",{className:"flex justify-between items-center",children:[d("div",{className:"flex items-center gap-2 text-sm",children:[a(jt,{className:"h-4 w-4 text-muted-foreground"}),"RSS"]}),a(L,{variant:"secondary",children:n?h(n.memory.rss):"-"})]})]})]})]}),d(_,{children:[d(se,{children:[a(ne,{children:"快速操作"}),a(Fe,{children:"常用功能快捷入口"})]}),a(P,{children:d("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[a(M,{variant:"outline",className:"h-auto p-4 justify-start",onClick:()=>s("/plugins"),children:d("div",{className:"flex flex-col items-start gap-1",children:[a(le,{className:"h-5 w-5 mb-1"}),a("span",{className:"font-medium",children:"插件管理"}),a("span",{className:"text-xs text-muted-foreground",children:"查看和管理插件"})]})}),a(M,{variant:"outline",className:"h-auto p-4 justify-start",onClick:()=>s("/bots"),children:d("div",{className:"flex flex-col items-start gap-1",children:[a(Ve,{className:"h-5 w-5 mb-1"}),a("span",{className:"font-medium",children:"机器人状态"}),a("span",{className:"text-xs text-muted-foreground",children:"监控机器人运行"})]})}),a(M,{variant:"outline",className:"h-auto p-4 justify-start",onClick:()=>s("/logs"),children:d("div",{className:"flex flex-col items-start gap-1",children:[a(ss,{className:"h-5 w-5 mb-1"}),a("span",{className:"font-medium",children:"系统日志"}),a("span",{className:"text-xs text-muted-foreground",children:"查看运行日志"})]})})]})})]})]})}const Ie=E.forwardRef(({className:s,orientation:e="horizontal",decorative:t=!0,...n},r)=>a(Jr.Root,{ref:r,decorative:t,orientation:e,className:I("shrink-0 bg-border",e==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...n}));Ie.displayName="Separator";const Si={Terminal:Zs,Box:Xs,Layers:is,Clock:ts,Brain:Qs,Wrench:Hs,Database:ht,Shield:Gs,Settings:We,Plug:rs,Server:ns};function Oi(s){return Si[s]||le}function Ci(){const s=us(),[e,t]=T([]),[n,r]=T(!0),[i,l]=T(null);G(()=>{o();const c=setInterval(o,1e4);return()=>clearInterval(c)},[]);const o=async()=>{try{const c=await fe("/api/plugins");if(!c.ok)throw new Error("API 请求失败");const u=await c.json();if(u.success)t(u.data),l(null);else throw new Error("数据格式错误")}catch(c){l(c.message)}finally{r(!1)}};return n?d("div",{className:"space-y-4",children:[a(U,{className:"h-8 w-48"}),a("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:[...Array(6)].map((c,u)=>a(U,{className:"h-40"},u))})]}):i?a("div",{className:"flex items-center justify-center h-full",children:d(z,{variant:"destructive",className:"max-w-md",children:[a(ae,{className:"h-4 w-4"}),d(Y,{children:["加载失败: ",i]})]})}):d("div",{className:"space-y-4",children:[d("div",{children:[a("h1",{className:"text-2xl font-bold tracking-tight",children:"插件管理"}),d("div",{className:"flex items-center gap-2 mt-1",children:[d("span",{className:"text-sm text-muted-foreground",children:["共 ",e.length," 个插件"]}),a(L,{variant:"success",children:e.filter(c=>c.status==="active").length}),a("span",{className:"text-sm text-muted-foreground",children:"个运行中"})]})]}),a("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:e.map((c,u)=>a(_,{className:"cursor-pointer transition-all hover:shadow-md hover:-translate-y-0.5",onClick:()=>s(`/plugins/${encodeURIComponent(c.name)}`),children:d(P,{className:"p-4 space-y-3",children:[d("div",{className:"flex justify-between items-center",children:[d("div",{className:"flex items-center gap-2",children:[a("div",{className:"flex items-center justify-center w-8 h-8 rounded-md bg-secondary",children:a(le,{className:"w-4 h-4"})}),a("span",{className:"font-semibold text-sm",children:c.name})]}),a(L,{variant:c.status==="active"?"success":"secondary",children:c.status==="active"?"运行中":"已停止"})]}),a("p",{className:"text-xs text-muted-foreground line-clamp-2",children:c.description||"暂无描述"}),a(Ie,{}),c.features.length>0?a("div",{className:"grid gap-1",style:{gridTemplateColumns:`repeat(${Math.min(c.features.length,4)}, 1fr)`},children:c.features.map(m=>{const h=Oi(m.icon);return d("div",{className:"flex flex-col items-center gap-0.5 rounded-md bg-secondary/50 p-1.5",children:[a(h,{className:"w-3 h-3 text-muted-foreground"}),a("span",{className:"text-sm font-bold",children:m.count}),a("span",{className:"text-[10px] text-muted-foreground",children:m.desc})]},m.name)})}):a("p",{className:"text-xs text-muted-foreground text-center py-1",children:"无注册功能"})]})},`${c.name}-${u}`))}),e.length===0&&a(_,{className:"mt-6",children:d(P,{className:"flex flex-col items-center gap-3 py-12",children:[a("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted",children:a(le,{className:"w-8 h-8 text-muted-foreground"})}),a("h3",{className:"text-lg font-semibold",children:"暂无插件"}),a("p",{className:"text-sm text-muted-foreground",children:"请先安装并启用插件"})]})})]})}const W=E.forwardRef(({className:s,...e},t)=>a("textarea",{className:I("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...e}));W.displayName="Textarea";const fs=E.forwardRef(({className:s,...e},t)=>a($s.Root,{className:I("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",s),...e,ref:t,children:a($s.Thumb,{className:I("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));fs.displayName="Switch";const hs=J.Root;J.Group;const ms=J.Value,St=E.forwardRef(({className:s,children:e,...t},n)=>d(J.Trigger,{ref:n,className:I("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",s),...t,children:[e,a(J.Icon,{asChild:!0,children:a(as,{className:"h-4 w-4 opacity-50"})})]}));St.displayName="SelectTrigger";const un=E.forwardRef(({className:s,...e},t)=>a(J.ScrollUpButton,{ref:t,className:I("flex cursor-default items-center justify-center py-1",s),...e,children:a(gr,{className:"h-4 w-4"})}));un.displayName="SelectScrollUpButton";const fn=E.forwardRef(({className:s,...e},t)=>a(J.ScrollDownButton,{ref:t,className:I("flex cursor-default items-center justify-center py-1",s),...e,children:a(as,{className:"h-4 w-4"})}));fn.displayName="SelectScrollDownButton";const Ot=E.forwardRef(({className:s,children:e,position:t="popper",...n},r)=>a(J.Portal,{children:d(J.Content,{ref:r,className:I("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",s),position:t,...n,children:[a(un,{}),a(J.Viewport,{className:I("p-1",t==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:e}),a(fn,{})]})}));Ot.displayName="SelectContent";const pe=E.forwardRef(({className:s,children:e,...t},n)=>d(J.Item,{ref:n,className:I("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...t,children:[a("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:a(J.ItemIndicator,{children:a(en,{className:"h-4 w-4"})})}),a(J.ItemText,{children:e})]}));pe.displayName="SelectItem";const Ti=E.forwardRef(({className:s,...e},t)=>a(J.Separator,{ref:t,className:I("-mx-1 my-1 h-px bg-muted",s),...e}));Ti.displayName="SelectSeparator";function Ai({field:s,value:e,onChange:t}){return s.enum?d(hs,{value:e?.toString()||"",onValueChange:t,children:[a(St,{children:a(ms,{placeholder:"请选择"})}),a(Ot,{children:s.enum.map(n=>a(pe,{value:n.toString(),children:n.toString()},n))})]}):s.description?.includes("多行")||s.key?.includes("description")?a(W,{value:e||"",onChange:n=>t(n.target.value),placeholder:s.description||"请输入",rows:3}):a(V,{value:e||"",onChange:n=>t(n.target.value),placeholder:s.description||"请输入"})}function Ii({field:s,value:e,onChange:t}){return a(V,{type:"number",value:e?.toString()||"",onChange:n=>t(parseFloat(n.target.value)||0),placeholder:s.description||"请输入数字",min:s.min,max:s.max})}function Ei({value:s,onChange:e}){return d("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted/50 border",children:[a(fs,{checked:s===!0,onCheckedChange:e}),d("div",{className:"flex flex-col gap-0.5",children:[a("span",{className:`text-sm font-medium ${s?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"}`,children:s?"已启用":"已禁用"}),a("span",{className:"text-xs text-muted-foreground",children:s?"功能当前处于开启状态":"功能当前处于关闭状态"})]})]})}function Li({field:s,value:e,onChange:t}){const n=typeof e=="number"?e:s.default||0;return d("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-3",children:[d("div",{className:"flex items-center gap-3",children:[a("input",{type:"range",min:s.min||0,max:s.max||1,step:s.step||.01,value:n,onChange:r=>t(parseFloat(r.target.value)),className:"flex-1 h-2 rounded-lg appearance-none cursor-pointer bg-secondary"}),d("div",{className:"flex items-center gap-1",children:[a(V,{type:"number",className:"w-20 h-8 text-xs",value:(n*100).toFixed(0),onChange:r=>t(parseFloat(r.target.value)/100),min:(s.min||0)*100,max:(s.max||1)*100}),a("span",{className:"text-xs font-bold text-muted-foreground",children:"%"})]})]}),d("div",{className:"flex items-center justify-between",children:[a("span",{className:"text-xs text-muted-foreground",children:"当前值"}),d(L,{variant:"secondary",className:"font-mono",children:[(n*100).toFixed(1),"%"]})]})]})}function $i({field:s,value:e,onChange:t}){const n=e instanceof Date?e.toISOString().split("T")[0]:e||"";return d("div",{className:"relative",children:[a(br,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground pointer-events-none"}),a(V,{type:"date",value:n,onChange:r=>t(new Date(r.target.value)),placeholder:s.description||"选择日期",className:"pl-9"})]})}function _i({field:s,value:e,onChange:t}){const n=e instanceof RegExp?e.source:typeof e=="string"?e:"";return d("div",{className:"p-3 rounded-lg bg-amber-50 dark:bg-amber-950/20 border border-amber-200 dark:border-amber-800 space-y-2",children:[d("div",{className:"flex items-center gap-1",children:[a("span",{className:"text-sm font-bold text-amber-600 dark:text-amber-400",children:"/"}),a(V,{value:n,className:"font-mono text-sm",onChange:r=>{try{t(new RegExp(r.target.value))}catch{t(r.target.value)}},placeholder:s.description||"请输入正则表达式"}),a("span",{className:"text-sm font-bold text-amber-600 dark:text-amber-400",children:"/"})]}),d("p",{className:"flex items-center gap-1 text-xs text-amber-700 dark:text-amber-300",children:[a(wt,{className:"w-3 h-3"})," 输入正则表达式模式 (省略斜杠)"]})]})}function ji({field:s,value:e}){const t=s.default||e;return d("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted border",children:[a(yr,{className:"w-4 h-4 text-muted-foreground"}),a(L,{variant:"secondary",className:"font-mono",children:String(t)}),a("span",{className:"text-xs text-muted-foreground ml-auto",children:"(常量,不可修改)"})]})}function Mi({field:s,value:e,onChange:t}){return d("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[d("p",{className:"flex items-center gap-1 text-xs font-semibold text-muted-foreground",children:[a(tn,{className:"w-3 h-3"})," JSON 格式输入"]}),a(W,{value:typeof e=="object"?JSON.stringify(e,null,2):String(e||""),onChange:n=>{try{t(JSON.parse(n.target.value))}catch{t(n.target.value)}},placeholder:s.description||"支持任意类型 (JSON 格式)",rows:4,className:"font-mono text-sm"}),d("p",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[a(wt,{className:"w-3 h-3"})," 支持: 字符串、数字、布尔值、对象、数组"]})]})}function Pi({fieldName:s,field:e,value:t,onChange:n,onArrayItemChange:r,renderNestedField:i}){const l=Array.isArray(t)?t:[],o=e.inner||e.items;return o&&["string","number"].includes(o.type)?d("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[d("p",{className:"flex items-center gap-1 text-xs font-semibold text-muted-foreground",children:[a(sn,{className:"w-3 h-3"})," 列表输入 (每行一个值)"]}),a(W,{value:l.join(`
2
- `),onChange:c=>{const u=c.target.value.split(`
3
- `).filter(Boolean);n(o.type==="number"?u.map(m=>parseFloat(m)||0):u)},placeholder:`每行一个值
4
- ${e.description||""}`,rows:4,className:"font-mono text-sm"})]}):d("div",{className:"space-y-2",children:[l.map((c,u)=>a(_,{className:"group",children:d("div",{className:"p-3 space-y-2",children:[d("div",{className:"flex justify-between items-center",children:[a(L,{variant:"secondary",className:"font-mono",children:u+1}),a(M,{variant:"ghost",size:"sm",className:"opacity-0 group-hover:opacity-100 transition-opacity text-destructive",onClick:()=>n(l.filter((m,h)=>h!==u)),children:a(qt,{className:"w-3 h-3"})})]}),a("div",{className:"pl-2 border-l-2",children:o&&i(`${s}[${u}]`,o,c,m=>{r?.(s,u,m)})})]})},u)),d(M,{variant:"outline",size:"sm",className:"w-full border-dashed",onClick:()=>n([...l,o?.default||(o?.type==="object"?{}:"")]),children:[a(Nr,{className:"w-4 h-4 mr-1"})," 添加项"]})]})}function Ri({field:s,value:e,onChange:t}){return d("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[d("p",{className:"flex items-center gap-1 text-xs font-semibold text-muted-foreground",children:[a(sn,{className:"w-3 h-3"})," 数组输入 (每行一个值)"]}),a(W,{value:Array.isArray(e)?e.join(`
1
+ import{jsx as i,jsxs as o,Fragment as ne}from"./react-jsx-runtime.js";import*as $ from"./react.js";import Ar,{useState as T,useEffect as z,useMemo as Te,useRef as as,useCallback as ue,PureComponent as Er,StrictMode as Ir}from"./react.js";import{createRoot as Lr}from"./react-dom-client.js";import{Moon as $r,Sun as jr,Menu as _r,Search as Pr,LogOut as Mr,AlertCircle as G,Package as fe,Bot as st,Activity as ls,TrendingUp as Dr,Clock as bs,Cpu as Rr,MemoryStick as Qt,FileText as Ns,Server as ws,Plug as xs,Settings as lt,Shield as yn,Database as Fe,Wrench as bn,Brain as Nn,Layers as vs,Box as wn,Terminal as xn,ChevronDown as $t,ChevronUp as Br,Check as vn,Code as kn,Info as jt,Lock as Fr,Calendar as Kr,List as Sn,Trash2 as Oe,Plus as _t,GitBranch as Ur,CheckCircle as Ee,AlertTriangle as Cn,X as ot,Loader2 as te,Save as we,ArrowLeft as Gs,Wifi as Vr,WifiOff as qr,Zap as zr,RefreshCw as xe,Circle as Jr,XCircle as Yr,FormInput as Wr,FileCode as os,KeyRound as Tn,FileWarning as Gr,Eye as Hr,EyeOff as Qr,FolderOpen as ks,ChevronRight as Ss,File as Le,Key as On,Table2 as Hs,Pencil as Cs,ChevronLeft as An,Home as Xr}from"./lucide-react.js";import{cn as E,useDispatch as Zr,useSelector as De,Link as ei,setActiveMenu as ti,toggleSidebar as si,Outlet as ni,useConfig as ri,useConfigYaml as ii,useEnvFiles as ai,useFiles as li,useDatabase as oi,persistor as ci,store as di,useWebSocket as ui,addPage as fi,DynamicRouter as hi}from"./client.js";import{cva as Ts}from"./cva.js";import{ScrollArea as Xe,Separator as mi,Switch as Qs,Select as ee,Accordion as nt,Checkbox as Xs,Tabs as Pt,Dialog as ge,Tooltip as rt}from"./radix-ui.js";import{useNavigate as Os,useParams as pi}from"./react-router.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&n(l)}).observe(document,{childList:!0,subtree:!0});function t(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerPolicy&&(a.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?a.credentials="include":r.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function n(r){if(r.ep)return;r.ep=!0;const a=t(r);fetch(r.href,a)}})();var Xt={exports:{}},Zt={};var Zs;function gi(){if(Zs)return Zt;Zs=1;var s=Ar;function e(d,u){return d===u&&(d!==0||1/d===1/u)||d!==d&&u!==u}var t=typeof Object.is=="function"?Object.is:e,n=s.useSyncExternalStore,r=s.useRef,a=s.useEffect,l=s.useMemo,c=s.useDebugValue;return Zt.useSyncExternalStoreWithSelector=function(d,u,h,m,f){var g=r(null);if(g.current===null){var w={hasValue:!1,value:null};g.current=w}else w=g.current;g=l(function(){function b(S){if(!k){if(k=!0,x=S,S=m(S),f!==void 0&&w.hasValue){var y=w.value;if(f(y,S))return N=y}return N=S}if(y=N,t(x,S))return y;var O=m(S);return f!==void 0&&f(y,O)?(x=S,y):(x=S,N=O)}var k=!1,x,N,C=h===void 0?null:h;return[function(){return b(u())},C===null?void 0:function(){return b(C())}]},[u,h,m,f]);var p=n(d,g[0],g[1]);return a(function(){w.hasValue=!0,w.value=p},[p]),c(p),p},Zt}var en;function yi(){return en||(en=1,Xt.exports=gi()),Xt.exports}yi();function bi(s){s()}function Ni(){let s=null,e=null;return{clear(){s=null,e=null},notify(){bi(()=>{let t=s;for(;t;)t.callback(),t=t.next})},get(){const t=[];let n=s;for(;n;)t.push(n),n=n.next;return t},subscribe(t){let n=!0;const r=e={callback:t,next:null,prev:e};return r.prev?r.prev.next=r:s=r,function(){!n||s===null||(n=!1,r.next?r.next.prev=r.prev:e=r.prev,r.prev?r.prev.next=r.next:s=r.next)}}}}var tn={notify(){},get:()=>[]};function wi(s,e){let t,n=tn,r=0,a=!1;function l(p){h();const b=n.subscribe(p);let k=!1;return()=>{k||(k=!0,b(),m())}}function c(){n.notify()}function d(){w.onStateChange&&w.onStateChange()}function u(){return a}function h(){r++,t||(t=s.subscribe(d),n=Ni())}function m(){r--,t&&r===0&&(t(),t=void 0,n.clear(),n=tn)}function f(){a||(a=!0,h())}function g(){a&&(a=!1,m())}const w={addNestedSub:l,notifyNestedSubs:c,handleChangeWrapper:d,isSubscribed:u,trySubscribe:f,tryUnsubscribe:g,getListeners:()=>n};return w}var xi=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",vi=xi(),ki=()=>typeof navigator<"u"&&navigator.product==="ReactNative",Si=ki(),Ci=()=>vi||Si?$.useLayoutEffect:$.useEffect,Ti=Ci(),Oi=Symbol.for("react-redux-context"),Ai=typeof globalThis<"u"?globalThis:{};function Ei(){if(!$.createContext)return{};const s=Ai[Oi]??=new Map;let e=s.get($.createContext);return e||(e=$.createContext(null),s.set($.createContext,e)),e}var Ii=Ei();function Li(s){const{children:e,context:t,serverState:n,store:r}=s,a=$.useMemo(()=>{const d=wi(r);return{store:r,subscription:d,getServerState:n?()=>n:void 0}},[r,n]),l=$.useMemo(()=>r.getState(),[r]);Ti(()=>{const{subscription:d}=a;return d.onStateChange=d.notifyNestedSubs,d.trySubscribe(),l!==r.getState()&&d.notifyNestedSubs(),()=>{d.tryUnsubscribe(),d.onStateChange=void 0}},[a,l]);const c=t||Ii;return $.createElement(c.Provider,{value:a},e)}var $i=Li;const ji={light:{background:"0 0% 100%",foreground:"240 10% 3.9%",card:"0 0% 100%","card-foreground":"240 10% 3.9%",popover:"0 0% 100%","popover-foreground":"240 10% 3.9%",primary:"240 5.9% 10%","primary-foreground":"0 0% 98%",secondary:"240 4.8% 95.9%","secondary-foreground":"240 5.9% 10%",muted:"240 4.8% 95.9%","muted-foreground":"240 3.8% 46.1%",accent:"240 4.8% 95.9%","accent-foreground":"240 5.9% 10%",destructive:"0 84.2% 60.2%","destructive-foreground":"0 0% 98%",border:"240 5.9% 90%",input:"240 5.9% 90%",ring:"240 5.9% 10%",radius:"0.5rem","chart-1":"240 5.9% 10%","chart-2":"240 3.8% 46.1%","chart-3":"240 5.9% 90%","chart-4":"240 4.8% 95.9%","chart-5":"0 0% 100%",sidebar:"0 0% 98%","sidebar-foreground":"240 5.3% 26.1%","sidebar-primary":"240 5.9% 10%","sidebar-primary-foreground":"0 0% 98%","sidebar-accent":"240 4.8% 95.9%","sidebar-accent-foreground":"240 5.9% 10%","sidebar-border":"220 13% 91%","sidebar-ring":"240 5.9% 10%"},dark:{background:"240 10% 3.9%",foreground:"0 0% 98%",card:"240 10% 3.9%","card-foreground":"0 0% 98%",popover:"240 10% 3.9%","popover-foreground":"0 0% 98%",primary:"0 0% 98%","primary-foreground":"240 5.9% 10%",secondary:"240 3.7% 15.9%","secondary-foreground":"0 0% 98%",muted:"240 3.7% 15.9%","muted-foreground":"240 5% 64.9%",accent:"240 3.7% 15.9%","accent-foreground":"0 0% 98%",destructive:"0 62.8% 30.6%","destructive-foreground":"0 0% 98%",border:"240 3.7% 15.9%",input:"240 3.7% 15.9%",ring:"240 4.9% 83.9%",radius:"0.5rem","chart-1":"0 0% 98%","chart-2":"240 5% 64.9%","chart-3":"240 3.7% 15.9%","chart-4":"240 10% 3.9%","chart-5":"240 5.9% 10%",sidebar:"240 5.9% 10%","sidebar-foreground":"240 4.8% 95.9%","sidebar-primary":"0 0% 98%","sidebar-primary-foreground":"240 5.9% 10%","sidebar-accent":"240 3.7% 15.9%","sidebar-accent-foreground":"240 4.8% 95.9%","sidebar-border":"240 3.7% 15.9%","sidebar-ring":"240 4.9% 83.9%"}};function En(s){const e=document.documentElement,t=ji[s];e.classList.remove("light","dark"),e.classList.add(s),Object.entries(t).forEach(([n,r])=>{e.style.setProperty(`--${n}`,r)}),localStorage.setItem("theme",s)}function In(){const s=localStorage.getItem("theme");return s&&(s==="light"||s==="dark")?s:window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function _i(){const s=In();return En(s),s}function Pi(){const[s,e]=T(In);return z(()=>{En(s)},[s]),{theme:s,setTheme:e,toggleTheme:()=>{e(n=>n==="light"?"dark":"light")}}}function Mi(){const{theme:s,toggleTheme:e}=Pi();return i("button",{onClick:e,className:"p-2 hover:bg-accent rounded-lg transition-colors text-foreground",title:s==="light"?"切换到暗色模式":"切换到亮色模式",children:s==="light"?i($r,{className:"w-5 h-5"}):i(jr,{className:"w-5 h-5"})})}const Di=Ts("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),A=$.forwardRef(({className:s,variant:e,size:t,...n},r)=>i("button",{className:E(Di({variant:e,size:t,className:s})),ref:r,...n}));A.displayName="Button";const Y=$.forwardRef(({className:s,type:e,...t},n)=>i("input",{type:e,className:E("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:n,...t}));Y.displayName="Input";const qe=$.forwardRef(({className:s,children:e,...t},n)=>o(Xe.Root,{ref:n,className:E("relative overflow-hidden",s),...t,children:[i(Xe.Viewport,{className:"h-full w-full rounded-[inherit]",children:e}),i(Ln,{}),i(Xe.Corner,{})]}));qe.displayName="ScrollArea";const Ln=$.forwardRef(({className:s,orientation:e="vertical",...t},n)=>i(Xe.Scrollbar,{ref:n,orientation:e,className:E("flex touch-none select-none transition-colors",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",s),...t,children:i(Xe.Thumb,{className:"relative flex-1 rounded-full bg-border"})}));Ln.displayName="ScrollBar";const Mt="zhin_api_token";function Ri(){return localStorage.getItem(Mt)}function Bi(s){localStorage.setItem(Mt,s)}function $n(){localStorage.removeItem(Mt)}function Fi(){return!!localStorage.getItem(Mt)}async function be(s,e){const t=Ri(),n=new Headers(e?.headers);t&&n.set("Authorization",`Bearer ${t}`);const r=await fetch(s,{...e,headers:n});return r.status===401&&($n(),window.dispatchEvent(new CustomEvent("zhin:auth-required"))),r}function Ki(){const s=Zr(),e=De(a=>a.ui.sidebarOpen),t=De(a=>a.ui.activeMenu),n=De(a=>a.route.routes),r=Te(()=>{const a=n.find(l=>l.key==="dashboard-layout");return!a||!a.children?[]:a.children.filter(l=>!l.meta?.hideInMenu&&l.key!=="dashboard-layout").map((l,c)=>({key:l.key||`menu-item-${c}`,title:l.title,index:l.index,icon:l.icon,href:l.path}))},[n]);return o("div",{className:"flex h-screen bg-background",children:[o("div",{className:E("flex flex-col border-r bg-sidebar transition-all duration-300",e?"w-64":"w-16"),children:[i("div",{className:"p-4 border-b",children:o("div",{className:E("flex items-center transition-all duration-300",e?"gap-3":"justify-center"),children:[i("div",{className:"flex items-center justify-center w-9 h-9 min-w-9 rounded-lg bg-foreground text-background font-bold text-lg",children:"Z"}),e&&o("div",{className:"flex flex-col",children:[i("span",{className:"text-base font-semibold",children:"Zhin.js"}),i("span",{className:"text-xs text-muted-foreground",children:"管理控制台"})]})]})}),i(qe,{className:"flex-1",children:i("div",{className:"p-2 space-y-1",children:r.map(a=>{const l=t===a.key;return o(ei,{to:a.href,onClick:()=>s(ti(a.key)),className:E("menu-item",l&&"active",!e&&"justify-center px-2"),children:[i("span",{className:"shrink-0",children:a.icon}),e&&i("span",{className:"truncate",children:a.title})]},a.key)})})})]}),o("div",{className:"flex flex-col flex-1 overflow-hidden",children:[o("header",{className:"flex items-center justify-between h-14 px-4 border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",children:[o("div",{className:"flex items-center gap-3",children:[i(A,{variant:"ghost",size:"icon",onClick:()=>s(si()),children:i(_r,{className:"h-5 w-5"})}),o("div",{className:"flex flex-col",children:[i("h2",{className:"text-sm font-semibold",children:"控制台"}),i("span",{className:"text-xs text-muted-foreground",children:"欢迎回来"})]})]}),i("div",{className:"hidden md:flex flex-1 max-w-md mx-6",children:o("div",{className:"relative w-full",children:[i(Pr,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),i(Y,{placeholder:"搜索功能、插件、设置...",className:"pl-9 bg-muted/50"})]})}),o("div",{className:"flex items-center gap-1",children:[i(Mi,{}),i(A,{variant:"ghost",size:"icon",title:"退出登录",onClick:()=>{$n(),window.dispatchEvent(new CustomEvent("zhin:auth-required"))},children:i(Mr,{className:"h-4 w-4"})})]})]}),i("main",{className:"flex-1 overflow-auto",children:i("div",{className:"max-w-7xl mx-auto p-6",children:i(ni,{})})})]})]})}const P=$.forwardRef(({className:s,...e},t)=>i("div",{ref:t,className:E("rounded-lg border bg-card text-card-foreground shadow-sm",s),...e}));P.displayName="Card";const oe=$.forwardRef(({className:s,...e},t)=>i("div",{ref:t,className:E("flex flex-col space-y-1.5 p-6",s),...e}));oe.displayName="CardHeader";const ce=$.forwardRef(({className:s,...e},t)=>i("div",{ref:t,className:E("text-lg font-semibold leading-none tracking-tight",s),...e}));ce.displayName="CardTitle";const Ze=$.forwardRef(({className:s,...e},t)=>i("div",{ref:t,className:E("text-sm text-muted-foreground",s),...e}));Ze.displayName="CardDescription";const M=$.forwardRef(({className:s,...e},t)=>i("div",{ref:t,className:E("p-6 pt-0",s),...e}));M.displayName="CardContent";const Ui=$.forwardRef(({className:s,...e},t)=>i("div",{ref:t,className:E("flex items-center p-6 pt-0",s),...e}));Ui.displayName="CardFooter";const Vi=Ts("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground shadow",outline:"text-foreground",success:"border-transparent bg-emerald-100 text-emerald-800 dark:bg-emerald-900/30 dark:text-emerald-400",warning:"border-transparent bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400"}},defaultVariants:{variant:"default"}});function _({className:s,variant:e,...t}){return i("div",{className:E(Vi({variant:e}),s),...t})}const qi=Ts("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",success:"border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-800 dark:bg-emerald-950/50 dark:text-emerald-400 [&>svg]:text-emerald-600 dark:[&>svg]:text-emerald-400",warning:"border-amber-200 bg-amber-50 text-amber-800 dark:border-amber-800 dark:bg-amber-950/50 dark:text-amber-400 [&>svg]:text-amber-600 dark:[&>svg]:text-amber-400"}},defaultVariants:{variant:"default"}}),V=$.forwardRef(({className:s,variant:e,...t},n)=>i("div",{ref:n,role:"alert",className:E(qi({variant:e}),s),...t}));V.displayName="Alert";const zi=$.forwardRef(({className:s,...e},t)=>i("h5",{ref:t,className:E("mb-1 font-medium leading-none tracking-tight",s),...e}));zi.displayName="AlertTitle";const q=$.forwardRef(({className:s,...e},t)=>i("div",{ref:t,className:E("text-sm [&_p]:leading-relaxed",s),...e}));q.displayName="AlertDescription";function X({className:s,...e}){return i("div",{className:E("animate-pulse rounded-md bg-primary/10",s),...e})}function Ji(){const s=Os(),[e,t]=T(null),[n,r]=T(null),[a,l]=T(!0),[c,d]=T(null);z(()=>{u();const f=setInterval(u,5e3);return()=>clearInterval(f)},[]);const u=async()=>{try{const[f,g]=await Promise.all([be("/api/stats"),be("/api/system/status")]);if(!f.ok||!g.ok)throw new Error("API 请求失败");const w=await f.json(),p=await g.json();w.success&&p.success&&(t(w.data),r(p.data),d(null))}catch(f){d(f.message)}finally{l(!1)}},h=f=>{const g=Math.floor(f/86400),w=Math.floor(f%86400/3600),p=Math.floor(f%3600/60);return`${g}天 ${w}小时 ${p}分钟`},m=f=>`${(f/1024/1024).toFixed(2)} MB`;return a?o("div",{className:"space-y-6",children:[o("div",{children:[i(X,{className:"h-8 w-48"}),i(X,{className:"h-4 w-64 mt-2"})]}),i("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[...Array(4)].map((f,g)=>i(X,{className:"h-32"},g))})]}):c?i("div",{className:"flex items-center justify-center h-full",children:o(V,{variant:"destructive",className:"max-w-md",children:[i(G,{className:"h-4 w-4"}),o(q,{children:["加载失败: ",c]})]})}):o("div",{className:"space-y-6",children:[o("div",{children:[i("h1",{className:"text-2xl font-bold tracking-tight",children:"系统概览"}),i("p",{className:"text-muted-foreground",children:"实时监控您的机器人框架运行状态"})]}),o("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[o(P,{children:[o(oe,{className:"flex flex-row items-center justify-between pb-2",children:[i(ce,{className:"text-sm font-medium text-muted-foreground",children:"插件总数"}),i(fe,{className:"h-4 w-4 text-muted-foreground"})]}),o(M,{children:[i("div",{className:"text-3xl font-bold",children:e?.plugins.total||0}),o("p",{className:"text-xs text-muted-foreground mt-1",children:[i(_,{variant:"secondary",className:"mr-1",children:e?.plugins.active||0}),"个活跃"]})]})]}),o(P,{children:[o(oe,{className:"flex flex-row items-center justify-between pb-2",children:[i(ce,{className:"text-sm font-medium text-muted-foreground",children:"机器人"}),i(st,{className:"h-4 w-4 text-muted-foreground"})]}),o(M,{children:[i("div",{className:"text-3xl font-bold",children:e?.bots.total||0}),o("p",{className:"text-xs text-muted-foreground mt-1",children:[i(_,{variant:"success",className:"mr-1",children:e?.bots.online||0}),"个在线"]})]})]}),o(P,{children:[o(oe,{className:"flex flex-row items-center justify-between pb-2",children:[i(ce,{className:"text-sm font-medium text-muted-foreground",children:"命令数量"}),i(ls,{className:"h-4 w-4 text-muted-foreground"})]}),o(M,{children:[i("div",{className:"text-3xl font-bold",children:e?.commands||0}),i("p",{className:"text-xs text-muted-foreground mt-1",children:"可用命令"})]})]}),o(P,{children:[o(oe,{className:"flex flex-row items-center justify-between pb-2",children:[i(ce,{className:"text-sm font-medium text-muted-foreground",children:"组件数量"}),i(Dr,{className:"h-4 w-4 text-muted-foreground"})]}),o(M,{children:[i("div",{className:"text-3xl font-bold",children:e?.components||0}),i("p",{className:"text-xs text-muted-foreground mt-1",children:"已注册组件"})]})]})]}),o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o(P,{children:[o(oe,{children:[i(ce,{children:"系统信息"}),i(Ze,{children:"服务器运行状态"})]}),o(M,{className:"space-y-3",children:[o("div",{className:"flex justify-between items-center",children:[o("div",{className:"flex items-center gap-2 text-sm",children:[i(bs,{className:"h-4 w-4 text-muted-foreground"}),"运行时间"]}),i(_,{variant:"secondary",children:n?h(n.uptime):"-"})]}),o("div",{className:"flex justify-between items-center",children:[o("div",{className:"flex items-center gap-2 text-sm",children:[i(Rr,{className:"h-4 w-4 text-muted-foreground"}),"平台"]}),i(_,{variant:"secondary",children:n?.platform||"-"})]}),o("div",{className:"flex justify-between items-center",children:[o("div",{className:"flex items-center gap-2 text-sm",children:[i(ls,{className:"h-4 w-4 text-muted-foreground"}),"Node 版本"]}),i(_,{variant:"secondary",children:n?.nodeVersion||"-"})]})]})]}),o(P,{children:[o(oe,{children:[i(ce,{children:"资源使用"}),i(Ze,{children:"内存使用情况"})]}),o(M,{className:"space-y-3",children:[o("div",{className:"flex justify-between items-center",children:[o("div",{className:"flex items-center gap-2 text-sm",children:[i(Qt,{className:"h-4 w-4 text-muted-foreground"}),"堆内存使用"]}),i(_,{variant:"secondary",children:e?`${e.memory.toFixed(2)} MB`:"-"})]}),o("div",{className:"flex justify-between items-center",children:[o("div",{className:"flex items-center gap-2 text-sm",children:[i(Qt,{className:"h-4 w-4 text-muted-foreground"}),"总堆内存"]}),i(_,{variant:"secondary",children:n?m(n.memory.heapTotal):"-"})]}),o("div",{className:"flex justify-between items-center",children:[o("div",{className:"flex items-center gap-2 text-sm",children:[i(Qt,{className:"h-4 w-4 text-muted-foreground"}),"RSS"]}),i(_,{variant:"secondary",children:n?m(n.memory.rss):"-"})]})]})]})]}),o(P,{children:[o(oe,{children:[i(ce,{children:"快速操作"}),i(Ze,{children:"常用功能快捷入口"})]}),i(M,{children:o("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[i(A,{variant:"outline",className:"h-auto p-4 justify-start",onClick:()=>s("/plugins"),children:o("div",{className:"flex flex-col items-start gap-1",children:[i(fe,{className:"h-5 w-5 mb-1"}),i("span",{className:"font-medium",children:"插件管理"}),i("span",{className:"text-xs text-muted-foreground",children:"查看和管理插件"})]})}),i(A,{variant:"outline",className:"h-auto p-4 justify-start",onClick:()=>s("/bots"),children:o("div",{className:"flex flex-col items-start gap-1",children:[i(st,{className:"h-5 w-5 mb-1"}),i("span",{className:"font-medium",children:"机器人状态"}),i("span",{className:"text-xs text-muted-foreground",children:"监控机器人运行"})]})}),i(A,{variant:"outline",className:"h-auto p-4 justify-start",onClick:()=>s("/logs"),children:o("div",{className:"flex flex-col items-start gap-1",children:[i(Ns,{className:"h-5 w-5 mb-1"}),i("span",{className:"font-medium",children:"系统日志"}),i("span",{className:"text-xs text-muted-foreground",children:"查看运行日志"})]})})]})})]})]})}const Ke=$.forwardRef(({className:s,orientation:e="horizontal",decorative:t=!0,...n},r)=>i(mi.Root,{ref:r,decorative:t,orientation:e,className:E("shrink-0 bg-border",e==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...n}));Ke.displayName="Separator";const Yi={Terminal:xn,Box:wn,Layers:vs,Clock:bs,Brain:Nn,Wrench:bn,Database:Fe,Shield:yn,Settings:lt,Plug:xs,Server:ws};function Wi(s){return Yi[s]||fe}function Gi(){const s=Os(),[e,t]=T([]),[n,r]=T(!0),[a,l]=T(null);z(()=>{c();const d=setInterval(c,1e4);return()=>clearInterval(d)},[]);const c=async()=>{try{const d=await be("/api/plugins");if(!d.ok)throw new Error("API 请求失败");const u=await d.json();if(u.success)t(u.data),l(null);else throw new Error("数据格式错误")}catch(d){l(d.message)}finally{r(!1)}};return n?o("div",{className:"space-y-4",children:[i(X,{className:"h-8 w-48"}),i("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:[...Array(6)].map((d,u)=>i(X,{className:"h-40"},u))})]}):a?i("div",{className:"flex items-center justify-center h-full",children:o(V,{variant:"destructive",className:"max-w-md",children:[i(G,{className:"h-4 w-4"}),o(q,{children:["加载失败: ",a]})]})}):o("div",{className:"space-y-4",children:[o("div",{children:[i("h1",{className:"text-2xl font-bold tracking-tight",children:"插件管理"}),o("div",{className:"flex items-center gap-2 mt-1",children:[o("span",{className:"text-sm text-muted-foreground",children:["共 ",e.length," 个插件"]}),i(_,{variant:"success",children:e.filter(d=>d.status==="active").length}),i("span",{className:"text-sm text-muted-foreground",children:"个运行中"})]})]}),i("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:e.map((d,u)=>i(P,{className:"cursor-pointer transition-all hover:shadow-md hover:-translate-y-0.5",onClick:()=>s(`/plugins/${encodeURIComponent(d.name)}`),children:o(M,{className:"p-4 space-y-3",children:[o("div",{className:"flex justify-between items-center",children:[o("div",{className:"flex items-center gap-2",children:[i("div",{className:"flex items-center justify-center w-8 h-8 rounded-md bg-secondary",children:i(fe,{className:"w-4 h-4"})}),i("span",{className:"font-semibold text-sm",children:d.name})]}),i(_,{variant:d.status==="active"?"success":"secondary",children:d.status==="active"?"运行中":"已停止"})]}),i("p",{className:"text-xs text-muted-foreground line-clamp-2",children:d.description||"暂无描述"}),i(Ke,{}),d.features.length>0?i("div",{className:"grid gap-1",style:{gridTemplateColumns:`repeat(${Math.min(d.features.length,4)}, 1fr)`},children:d.features.map(h=>{const m=Wi(h.icon);return o("div",{className:"flex flex-col items-center gap-0.5 rounded-md bg-secondary/50 p-1.5",children:[i(m,{className:"w-3 h-3 text-muted-foreground"}),i("span",{className:"text-sm font-bold",children:h.count}),i("span",{className:"text-[10px] text-muted-foreground",children:h.desc})]},h.name)})}):i("p",{className:"text-xs text-muted-foreground text-center py-1",children:"无注册功能"})]})},`${d.name}-${u}`))}),e.length===0&&i(P,{className:"mt-6",children:o(M,{className:"flex flex-col items-center gap-3 py-12",children:[i("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted",children:i(fe,{className:"w-8 h-8 text-muted-foreground"})}),i("h3",{className:"text-lg font-semibold",children:"暂无插件"}),i("p",{className:"text-sm text-muted-foreground",children:"请先安装并启用插件"})]})})]})}const se=$.forwardRef(({className:s,...e},t)=>i("textarea",{className:E("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...e}));se.displayName="Textarea";const As=$.forwardRef(({className:s,...e},t)=>i(Qs.Root,{className:E("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",s),...e,ref:t,children:i(Qs.Thumb,{className:E("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));As.displayName="Switch";const Es=ee.Root;ee.Group;const Is=ee.Value,Dt=$.forwardRef(({className:s,children:e,...t},n)=>o(ee.Trigger,{ref:n,className:E("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",s),...t,children:[e,i(ee.Icon,{asChild:!0,children:i($t,{className:"h-4 w-4 opacity-50"})})]}));Dt.displayName="SelectTrigger";const jn=$.forwardRef(({className:s,...e},t)=>i(ee.ScrollUpButton,{ref:t,className:E("flex cursor-default items-center justify-center py-1",s),...e,children:i(Br,{className:"h-4 w-4"})}));jn.displayName="SelectScrollUpButton";const _n=$.forwardRef(({className:s,...e},t)=>i(ee.ScrollDownButton,{ref:t,className:E("flex cursor-default items-center justify-center py-1",s),...e,children:i($t,{className:"h-4 w-4"})}));_n.displayName="SelectScrollDownButton";const Rt=$.forwardRef(({className:s,children:e,position:t="popper",...n},r)=>i(ee.Portal,{children:o(ee.Content,{ref:r,className:E("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",s),position:t,...n,children:[i(jn,{}),i(ee.Viewport,{className:E("p-1",t==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:e}),i(_n,{})]})}));Rt.displayName="SelectContent";const ke=$.forwardRef(({className:s,children:e,...t},n)=>o(ee.Item,{ref:n,className:E("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...t,children:[i("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:i(ee.ItemIndicator,{children:i(vn,{className:"h-4 w-4"})})}),i(ee.ItemText,{children:e})]}));ke.displayName="SelectItem";const Hi=$.forwardRef(({className:s,...e},t)=>i(ee.Separator,{ref:t,className:E("-mx-1 my-1 h-px bg-muted",s),...e}));Hi.displayName="SelectSeparator";function Qi({field:s,value:e,onChange:t}){return s.enum?o(Es,{value:e?.toString()||"",onValueChange:t,children:[i(Dt,{children:i(Is,{placeholder:"请选择"})}),i(Rt,{children:s.enum.map(n=>i(ke,{value:n.toString(),children:n.toString()},n))})]}):s.description?.includes("多行")||s.key?.includes("description")?i(se,{value:e||"",onChange:n=>t(n.target.value),placeholder:s.description||"请输入",rows:3}):i(Y,{value:e||"",onChange:n=>t(n.target.value),placeholder:s.description||"请输入"})}function Xi({field:s,value:e,onChange:t}){return i(Y,{type:"number",value:e?.toString()||"",onChange:n=>t(parseFloat(n.target.value)||0),placeholder:s.description||"请输入数字",min:s.min,max:s.max})}function Zi({value:s,onChange:e}){return o("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted/50 border",children:[i(As,{checked:s===!0,onCheckedChange:e}),o("div",{className:"flex flex-col gap-0.5",children:[i("span",{className:`text-sm font-medium ${s?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"}`,children:s?"已启用":"已禁用"}),i("span",{className:"text-xs text-muted-foreground",children:s?"功能当前处于开启状态":"功能当前处于关闭状态"})]})]})}function ea({field:s,value:e,onChange:t}){const n=typeof e=="number"?e:s.default||0;return o("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-3",children:[o("div",{className:"flex items-center gap-3",children:[i("input",{type:"range",min:s.min||0,max:s.max||1,step:s.step||.01,value:n,onChange:r=>t(parseFloat(r.target.value)),className:"flex-1 h-2 rounded-lg appearance-none cursor-pointer bg-secondary"}),o("div",{className:"flex items-center gap-1",children:[i(Y,{type:"number",className:"w-20 h-8 text-xs",value:(n*100).toFixed(0),onChange:r=>t(parseFloat(r.target.value)/100),min:(s.min||0)*100,max:(s.max||1)*100}),i("span",{className:"text-xs font-bold text-muted-foreground",children:"%"})]})]}),o("div",{className:"flex items-center justify-between",children:[i("span",{className:"text-xs text-muted-foreground",children:"当前值"}),o(_,{variant:"secondary",className:"font-mono",children:[(n*100).toFixed(1),"%"]})]})]})}function ta({field:s,value:e,onChange:t}){const n=e instanceof Date?e.toISOString().split("T")[0]:e||"";return o("div",{className:"relative",children:[i(Kr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground pointer-events-none"}),i(Y,{type:"date",value:n,onChange:r=>t(new Date(r.target.value)),placeholder:s.description||"选择日期",className:"pl-9"})]})}function sa({field:s,value:e,onChange:t}){const n=e instanceof RegExp?e.source:typeof e=="string"?e:"";return o("div",{className:"p-3 rounded-lg bg-amber-50 dark:bg-amber-950/20 border border-amber-200 dark:border-amber-800 space-y-2",children:[o("div",{className:"flex items-center gap-1",children:[i("span",{className:"text-sm font-bold text-amber-600 dark:text-amber-400",children:"/"}),i(Y,{value:n,className:"font-mono text-sm",onChange:r=>{try{t(new RegExp(r.target.value))}catch{t(r.target.value)}},placeholder:s.description||"请输入正则表达式"}),i("span",{className:"text-sm font-bold text-amber-600 dark:text-amber-400",children:"/"})]}),o("p",{className:"flex items-center gap-1 text-xs text-amber-700 dark:text-amber-300",children:[i(jt,{className:"w-3 h-3"})," 输入正则表达式模式 (省略斜杠)"]})]})}function na({field:s,value:e}){const t=s.default||e;return o("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted border",children:[i(Fr,{className:"w-4 h-4 text-muted-foreground"}),i(_,{variant:"secondary",className:"font-mono",children:String(t)}),i("span",{className:"text-xs text-muted-foreground ml-auto",children:"(常量,不可修改)"})]})}function ra({field:s,value:e,onChange:t}){return o("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[o("p",{className:"flex items-center gap-1 text-xs font-semibold text-muted-foreground",children:[i(kn,{className:"w-3 h-3"})," JSON 格式输入"]}),i(se,{value:typeof e=="object"?JSON.stringify(e,null,2):String(e||""),onChange:n=>{try{t(JSON.parse(n.target.value))}catch{t(n.target.value)}},placeholder:s.description||"支持任意类型 (JSON 格式)",rows:4,className:"font-mono text-sm"}),o("p",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[i(jt,{className:"w-3 h-3"})," 支持: 字符串、数字、布尔值、对象、数组"]})]})}function ia({fieldName:s,field:e,value:t,onChange:n,onArrayItemChange:r,renderNestedField:a}){const l=Array.isArray(t)?t:[],c=e.inner||e.items;return c&&["string","number"].includes(c.type)?o("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[o("p",{className:"flex items-center gap-1 text-xs font-semibold text-muted-foreground",children:[i(Sn,{className:"w-3 h-3"})," 列表输入 (每行一个值)"]}),i(se,{value:l.join(`
2
+ `),onChange:d=>{const u=d.target.value.split(`
3
+ `).filter(Boolean);n(c.type==="number"?u.map(h=>parseFloat(h)||0):u)},placeholder:`每行一个值
4
+ ${e.description||""}`,rows:4,className:"font-mono text-sm"})]}):o("div",{className:"space-y-2",children:[l.map((d,u)=>i(P,{className:"group",children:o("div",{className:"p-3 space-y-2",children:[o("div",{className:"flex justify-between items-center",children:[i(_,{variant:"secondary",className:"font-mono",children:u+1}),i(A,{variant:"ghost",size:"sm",className:"opacity-0 group-hover:opacity-100 transition-opacity text-destructive",onClick:()=>n(l.filter((h,m)=>m!==u)),children:i(Oe,{className:"w-3 h-3"})})]}),i("div",{className:"pl-2 border-l-2",children:c&&a(`${s}[${u}]`,c,d,h=>{r?.(s,u,h)})})]})},u)),o(A,{variant:"outline",size:"sm",className:"w-full border-dashed",onClick:()=>n([...l,c?.default||(c?.type==="object"?{}:"")]),children:[i(_t,{className:"w-4 h-4 mr-1"})," 添加项"]})]})}function aa({field:s,value:e,onChange:t}){return o("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[o("p",{className:"flex items-center gap-1 text-xs font-semibold text-muted-foreground",children:[i(Sn,{className:"w-3 h-3"})," 数组输入 (每行一个值)"]}),i(se,{value:Array.isArray(e)?e.join(`
5
5
  `):"",onChange:n=>t(n.target.value.split(`
6
6
  `).filter(Boolean)),placeholder:`每行一个值
7
- ${s.description||""}`,rows:3,className:"font-mono text-sm"})]})}function Bi({fieldName:s,field:e,value:t,onArrayItemChange:n,renderNestedField:r}){const i=Array.isArray(t)?t:[],l=e.list||[];return a("div",{className:"space-y-2",children:l.map((o,c)=>d("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[d(L,{variant:"secondary",className:"font-mono",children:["#",c+1]}),o.description&&a("p",{className:"text-xs text-muted-foreground",children:o.description}),a("div",{className:"mt-1",children:r(`${s}[${c}]`,o,i[c],u=>{n?.(s,c,u)})})]},c))})}function Di({fieldName:s,field:e,renderField:t}){const n=e.dict||e.properties||{};return d("div",{className:"rounded-lg border-2 bg-muted/30 overflow-hidden",children:[d("div",{className:"px-4 py-2 bg-muted border-b flex items-center gap-2",children:[a(le,{className:"w-4 h-4 text-muted-foreground"}),a("span",{className:"text-xs font-semibold text-muted-foreground",children:"对象"})]}),a("div",{className:"p-3 space-y-2",children:Object.entries(n).map(([r,i],l)=>d("div",{children:[d("div",{className:"p-3 rounded-md bg-background border space-y-1",children:[d("div",{className:"flex items-center gap-1",children:[a("span",{className:"text-sm font-semibold",children:i.key||r}),i.required&&a("span",{className:"text-destructive font-bold",children:"*"})]}),i.description&&a("p",{className:"text-xs text-muted-foreground",children:i.description}),a("div",{className:"mt-1",children:t(r,i,s)})]}),l<Object.entries(n).length-1&&a(Ie,{className:"my-2"})]},r))})]})}function Fi({field:s,value:e,onChange:t}){return d("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[d("p",{className:"flex items-center gap-1 text-xs font-semibold text-muted-foreground",children:[a(tn,{className:"w-3 h-3"})," 键值对编辑"]}),a(W,{value:typeof e=="object"?JSON.stringify(e,null,2):e||"{}",onChange:n=>{try{t(JSON.parse(n.target.value))}catch{}},placeholder:s.description||"请输入 JSON 格式",rows:6,className:"font-mono text-sm"}),d("p",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[a(wt,{className:"w-3 h-3"})," 键值对格式: ","{",'"key": "value"',"}"]})]})}function Ki({field:s,value:e,onChange:t}){const n=s.list||[];if(n.length===0)return a(V,{value:e||"",onChange:i=>t(i.target.value),placeholder:s.description||"请输入值"});const r=n.map(i=>i.default||i.type);return d("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[d("p",{className:"flex items-center gap-1 text-xs font-semibold text-muted-foreground",children:[a(wr,{className:"w-3 h-3"})," 联合类型"]}),d(hs,{value:e?.toString()||"",onValueChange:t,children:[a(St,{children:a(ms,{placeholder:"请选择"})}),a(Ot,{children:r.map((i,l)=>a(pe,{value:String(i),children:String(i)},l))})]})]})}function Ui({fieldName:s,field:e,value:t,onChange:n,renderNestedField:r}){const i=e.list||[];return d("div",{className:"rounded-lg border-2 bg-muted/30 overflow-hidden",children:[d("div",{className:"px-4 py-2 bg-muted border-b flex items-center gap-2",children:[a(is,{className:"w-4 h-4 text-muted-foreground"}),a("span",{className:"text-xs font-semibold text-muted-foreground",children:"交叉类型"})]}),a("div",{className:"p-3 space-y-2",children:i.map((l,o)=>d("div",{className:"p-3 rounded-md bg-background border space-y-1",children:[l.description&&a("p",{className:"text-xs text-muted-foreground",children:l.description}),a("div",{className:"mt-1",children:r(`${s}[${o}]`,l,t,n)})]},o))})]})}function Vi(s){const{field:e}=s;switch(e.type){case"string":return a(Ai,{...s});case"number":case"integer":return a(Ii,{...s});case"boolean":return a(Ei,{...s});case"percent":return a(Li,{...s});case"date":return a($i,{...s});case"regexp":return a(_i,{...s});case"const":return a(ji,{...s});case"any":return a(Mi,{...s});case"list":return a(Pi,{...s});case"array":return a(Ri,{...s});case"tuple":return a(Bi,{...s});case"object":return a(Di,{...s});case"dict":return a(Fi,{...s});case"union":return a(Ki,{...s});case"intersect":return a(Ui,{...s});default:return a(W,{value:typeof s.value=="object"?JSON.stringify(s.value,null,2):s.value||"",onChange:t=>{try{s.onChange(JSON.parse(t.target.value))}catch{s.onChange(t.target.value)}},placeholder:e.description||"请输入 JSON 格式",rows:4,className:"font-mono text-xs"})}}function hn({field:s,value:e,onChange:t}){switch(s.type){case"string":return a(V,{value:e||"",onChange:n=>t(n.target.value),placeholder:s.description||"请输入",className:"h-8 text-sm"});case"number":case"integer":return a(V,{type:"number",value:e?.toString()||"",onChange:n=>t(parseFloat(n.target.value)||0),placeholder:s.description||"请输入数字",min:s.min,max:s.max,className:"h-8 text-sm"});case"boolean":return d("div",{className:"flex items-center gap-2",children:[a(fs,{checked:e===!0,onCheckedChange:t}),a("span",{className:`text-sm ${e?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"}`,children:e?"已启用":"已禁用"})]});case"object":{const n=s.dict||s.properties||{};return a(_,{className:"p-2 space-y-2",children:Object.entries(n).map(([r,i])=>d("div",{className:"space-y-1",children:[a("span",{className:"text-xs font-semibold",children:r}),a(hn,{fieldName:r,field:i,value:e?.[r],onChange:l=>t({...e,[r]:l})})]},r))})}default:return a(W,{value:typeof e=="object"?JSON.stringify(e,null,2):e||"",onChange:n=>{try{t(JSON.parse(n.target.value))}catch{t(n.target.value)}},rows:3,className:"font-mono text-xs"})}}const qi=qe.Root,mn=E.forwardRef(({className:s,...e},t)=>a(qe.Item,{ref:t,className:I("border-b",s),...e}));mn.displayName="AccordionItem";const pn=E.forwardRef(({className:s,children:e,...t},n)=>a(qe.Header,{className:"flex",children:d(qe.Trigger,{ref:n,className:I("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",s),...t,children:[e,a(as,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200"})]})}));pn.displayName="AccordionTrigger";const gn=E.forwardRef(({className:s,children:e,...t},n)=>a(qe.Content,{ref:n,className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...t,children:a("div",{className:I("pb-4 pt-0",s),children:e})}));gn.displayName="AccordionContent";function Ji({pluginName:s,onSuccess:e}){const[t,n]=T({}),[r,i]=T(null),[l,o]=T(void 0),{config:c,schema:u,loading:m,error:h,connected:f,setConfig:g}=Rr(s);G(()=>{c&&n(c)},[c]);const[b,p]=T(null),y=async()=>{if(f)try{const N=await g(t);N?.reloaded?i("配置已保存,插件已重载"):N?.message?(p(N.message),i(null)):i("配置已保存"),setTimeout(()=>{o(void 0),e?.(),i(null),p(null)},2500)}catch(N){console.error("保存配置失败:",N)}},k=(N,C)=>{n(x=>({...x,[N]:C}))},O=(N,C,x)=>{n($=>({...$,[N]:{...$[N]||{},[C]:x}}))},w=(N,C,x)=>{n($=>{const H=Array.isArray($[N])?[...$[N]]:[];return H[C]=x,{...$,[N]:H}})},S=(N,C,x)=>{const $=x?t[x]?.[N]??C.default:t[N]??C.default;return a(Vi,{fieldName:N,field:C,value:$,onChange:x?Q=>O(x,N,Q):Q=>k(N,Q),parentPath:x,onNestedChange:O,onArrayItemChange:w,renderField:S,renderNestedField:(Q,R,tt,nr)=>a(hn,{fieldName:Q,field:R,value:tt,onChange:nr})})},v=u?.object||u?.properties||u?.dict||{};return!u||!v||Object.keys(v).length===0?null:a(_,{className:"mt-4",children:a(qi,{type:"single",collapsible:!0,value:l,onValueChange:o,children:d(mn,{value:"config",className:"border-none",children:[a(pn,{className:"px-4 hover:no-underline",children:d("div",{className:"flex items-center gap-2",children:[a(We,{className:"w-4 h-4"}),a("span",{className:"font-semibold",children:"插件配置"}),d(L,{variant:"secondary",children:[Object.keys(v).length," 项"]})]})}),d(gn,{className:"px-4 pb-4",children:[r&&d(z,{variant:"success",className:"mb-3",children:[a(ls,{className:"h-4 w-4"}),a(Y,{children:r})]}),b&&!r&&d(z,{className:"mb-3 border-yellow-500/50 text-yellow-700 dark:text-yellow-400",children:[a(nn,{className:"h-4 w-4"}),a(Y,{children:b})]}),h&&d(z,{variant:"destructive",className:"mb-3",children:[a(ae,{className:"h-4 w-4"}),a(Y,{children:h})]}),a("div",{className:"space-y-3",children:Object.entries(v).map(([N,C])=>{const x=C;return d("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[d("div",{className:"flex items-center gap-1",children:[a("span",{className:"text-sm font-semibold",children:x.key||N}),x.required&&a("span",{className:"text-destructive font-bold",children:"*"})]}),x.description&&a("p",{className:"text-xs text-muted-foreground",children:x.description}),a("div",{className:"mt-1",children:S(x.key||N,x)})]},N)})}),d("div",{className:"flex gap-2 justify-end mt-4 pt-3 border-t",children:[d(M,{variant:"outline",size:"sm",onClick:()=>o(void 0),disabled:m,children:[a(os,{className:"w-4 h-4 mr-1"})," 取消"]}),a(M,{size:"sm",onClick:y,disabled:m,children:m?d(ie,{children:[a(be,{className:"w-4 h-4 mr-1 animate-spin"}),"保存中..."]}):d(ie,{children:[a(vt,{className:"w-4 h-4 mr-1"}),"保存配置"]})})]})]})]})})})}const zi={Terminal:Zs,Box:Xs,Layers:is,Clock:ts,Brain:Qs,Wrench:Hs,Database:ht,Shield:Gs,Settings:We,Plug:rs,Server:ns};function Rs(s){return zi[s]||le}function Yi(){const{name:s}=zr(),e=us(),[t,n]=T(null),[r,i]=T(!0),[l,o]=T(null);G(()=>{s&&c(s)},[s]);const c=async u=>{try{const m=await fe(`/api/plugins/${encodeURIComponent(u)}`);if(!m.ok)throw new Error("API 请求失败");const h=await m.json();if(h.success)n(h.data),o(null);else throw new Error("数据格式错误")}catch(m){o(m.message)}finally{i(!1)}};return r?d("div",{className:"space-y-4",children:[a(U,{className:"h-8 w-24"}),d("div",{className:"flex items-center gap-3",children:[a(U,{className:"h-12 w-12 rounded-xl"}),d("div",{children:[a(U,{className:"h-6 w-48"}),a(U,{className:"h-4 w-64 mt-1"})]})]}),a("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-6 gap-2",children:[...Array(6)].map((u,m)=>a(U,{className:"h-20"},m))})]}):l||!t?d("div",{children:[d(M,{variant:"ghost",onClick:()=>e("/plugins"),className:"mb-4",children:[a(Ls,{className:"w-4 h-4 mr-1"})," 返回"]}),d(z,{variant:"destructive",children:[a(ae,{className:"h-4 w-4"}),d(Y,{children:["加载失败: ",l||"插件不存在"]})]})]}):d("div",{className:"space-y-4",children:[d(M,{variant:"ghost",size:"sm",onClick:()=>e("/plugins"),children:[a(Ls,{className:"w-4 h-4 mr-1"})," 返回"]}),d("div",{className:"flex items-center gap-3",children:[a("div",{className:"flex items-center justify-center w-12 h-12 rounded-xl bg-secondary",children:a(le,{className:"w-6 h-6"})}),d("div",{children:[d("div",{className:"flex items-center gap-2",children:[a("h1",{className:"text-xl font-bold",children:t.name}),a(L,{variant:t.status==="active"?"success":"secondary",children:t.status==="active"?"运行中":"已停止"})]}),a("p",{className:"text-sm text-muted-foreground",children:t.description||"暂无描述"})]})]}),a(Ji,{pluginName:t.name,onSuccess:()=>{}}),a(Ie,{}),t.features.length>0&&d("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-6 gap-2",children:[t.features.map(u=>{const m=Rs(u.icon);return a(_,{children:d(P,{className:"flex flex-col items-center gap-1 p-3",children:[a(m,{className:"w-4 h-4 text-muted-foreground"}),a("span",{className:"text-2xl font-bold",children:u.count}),a("span",{className:"text-xs text-muted-foreground",children:u.desc})]})},u.name)}),t.contexts.length>0&&a(_,{children:d(P,{className:"flex flex-col items-center gap-1 p-3",children:[a(ht,{className:"w-4 h-4 text-muted-foreground"}),a("span",{className:"text-2xl font-bold",children:t.contexts.length}),a("span",{className:"text-xs text-muted-foreground",children:"上下文"})]})})]}),d("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[t.features.map(u=>{if(u.items.length===0)return null;const m=Rs(u.icon);return d(_,{children:[a(se,{className:"pb-2",children:d("div",{className:"flex items-center gap-2",children:[a(m,{className:"w-4 h-4 text-muted-foreground"}),a(ne,{className:"text-base",children:u.desc}),a(L,{variant:"secondary",children:u.count})]})}),a(P,{children:a("div",{className:"max-h-60 overflow-y-auto pr-1 space-y-2",children:u.items.map((h,f)=>a(Wi,{featureName:u.name,item:h},f))})})]},u.name)}),t.contexts.length>0&&d(_,{children:[a(se,{className:"pb-2",children:d("div",{className:"flex items-center gap-2",children:[a(ht,{className:"w-4 h-4 text-muted-foreground"}),a(ne,{className:"text-base",children:"上下文"}),a(L,{variant:"secondary",children:t.contexts.length})]})}),a(P,{children:a("div",{className:"max-h-60 overflow-y-auto pr-1 space-y-2",children:t.contexts.map((u,m)=>a("div",{className:"rounded-md bg-muted/50 p-2",children:a("code",{className:"text-sm",children:u.name})},m))})})]})]})]})}function Wi({featureName:s,item:e}){switch(s){case"command":return d("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[a("code",{className:"text-sm font-semibold",children:e.name}),e.desc?.map((t,n)=>a("p",{className:"text-xs text-muted-foreground",children:t},n)),e.usage&&e.usage.length>0&&d("div",{children:[a("span",{className:"text-xs font-semibold text-blue-600 dark:text-blue-400",children:"用法:"}),e.usage.map((t,n)=>a("code",{className:"block text-xs bg-muted rounded px-1 py-0.5 mt-0.5",children:t},n))]}),e.examples&&e.examples.length>0&&d("div",{children:[a("span",{className:"text-xs font-semibold text-emerald-600 dark:text-emerald-400",children:"示例:"}),e.examples.map((t,n)=>a("code",{className:"block text-xs bg-muted rounded px-1 py-0.5 mt-0.5",children:t},n))]})]});case"cron":return d("div",{className:"flex justify-between items-center rounded-md bg-muted/50 p-2",children:[a("code",{className:"text-sm",children:e.expression}),a(L,{variant:e.running?"success":"secondary",children:e.running?"运行中":"已停止"})]});case"tool":return d("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[a("code",{className:"text-sm font-semibold",children:e.name}),e.desc&&a("p",{className:"text-xs text-muted-foreground",children:e.desc}),e.platforms&&e.platforms.length>0&&a("div",{className:"flex gap-1 flex-wrap",children:e.platforms.map((t,n)=>a(L,{variant:"outline",className:"text-[10px]",children:t},n))})]});case"skill":return d("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[a("code",{className:"text-sm font-semibold",children:e.name}),e.desc&&a("p",{className:"text-xs text-muted-foreground",children:e.desc}),e.toolCount!=null&&d("span",{className:"text-xs text-muted-foreground",children:["工具: ",e.toolCount]})]});case"config":return d("div",{className:"flex justify-between items-center rounded-md bg-muted/50 p-2",children:[a("code",{className:"text-sm",children:e.name}),e.defaultValue!==void 0&&d("span",{className:"text-xs text-muted-foreground",children:["默认: ",JSON.stringify(e.defaultValue)]})]});case"permission":return a("div",{className:"rounded-md bg-muted/50 p-2",children:a("code",{className:"text-sm",children:e.name})});case"database":return a("div",{className:"rounded-md bg-muted/50 p-2",children:a("code",{className:"text-sm",children:e.name})});case"adapter":return d("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[d("div",{className:"flex items-center gap-2",children:[a(rs,{className:"w-3.5 h-3.5 text-muted-foreground"}),a("code",{className:"text-sm font-semibold",children:e.name})]}),d("div",{className:"flex gap-3 text-xs text-muted-foreground",children:[d("span",{children:["Bot: ",e.bots??0]}),d("span",{children:["在线: ",e.online??0]}),e.tools>0&&d("span",{children:["工具: ",e.tools]})]})]});case"service":return d("div",{className:"rounded-md bg-muted/50 p-2 flex items-center gap-2",children:[a(ns,{className:"w-3.5 h-3.5 text-muted-foreground"}),a("code",{className:"text-sm",children:e.name}),e.desc&&e.desc!==e.name&&d("span",{className:"text-xs text-muted-foreground",children:["- ",e.desc]})]});default:return a("div",{className:"rounded-md bg-muted/50 p-2",children:a("code",{className:"text-sm",children:e.name||JSON.stringify(e)})})}}function Gi(){const[s,e]=T([]),[t,n]=T(!0),[r,i]=T(null);G(()=>{l();const o=setInterval(l,5e3);return()=>clearInterval(o)},[]);const l=async()=>{try{const o=await fe("/api/bots");if(!o.ok)throw new Error("API 请求失败");const c=await o.json();if(c.success)e(c.data),i(null);else throw new Error("数据格式错误")}catch(o){i(o.message)}finally{n(!1)}};return t?d("div",{className:"space-y-6",children:[a(U,{className:"h-8 w-48"}),a("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((o,c)=>a(U,{className:"h-48"},c))})]}):r?a("div",{className:"flex items-center justify-center h-full",children:d(z,{variant:"destructive",className:"max-w-md",children:[a(ae,{className:"h-4 w-4"}),d(Y,{children:["加载失败: ",r]})]})}):d("div",{className:"space-y-6",children:[d("div",{children:[a("h1",{className:"text-2xl font-bold tracking-tight",children:"机器人管理"}),d("div",{className:"flex items-center gap-2 mt-1",children:[d("span",{className:"text-sm text-muted-foreground",children:["共 ",s.length," 个机器人,"]}),a(L,{variant:"success",children:s.filter(o=>o.connected).length}),a("span",{className:"text-sm text-muted-foreground",children:"个在线"})]})]}),a(Ie,{}),a("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:s.map((o,c)=>a(_,{children:d(P,{className:"p-5 space-y-4",children:[d("div",{className:"flex justify-between items-center",children:[d("div",{className:"flex items-center gap-2",children:[a("div",{className:`p-2 rounded-md ${o.connected?"bg-emerald-100 dark:bg-emerald-900/30":"bg-muted"}`,children:a(Ve,{className:`w-5 h-5 ${o.connected?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"}`})}),a("span",{className:"text-lg font-bold",children:o.name})]}),a("div",{className:"relative",children:a(L,{variant:o.connected?"success":"secondary",children:o.connected?d(ie,{children:[a(vr,{className:"w-3 h-3 mr-1"}),"在线"]}):d(ie,{children:[a(xr,{className:"w-3 h-3 mr-1"}),"离线"]})})})]}),d("div",{className:"flex items-center gap-2",children:[a("span",{className:"text-sm text-muted-foreground",children:"适配器:"}),a(L,{variant:"outline",children:o.adapter})]}),a(Ie,{}),d("div",{className:"space-y-2",children:[d("div",{className:"flex justify-between items-center p-2 rounded-md bg-muted/50",children:[d("div",{className:"flex items-center gap-2 text-sm",children:[a(Vt,{className:`w-4 h-4 ${o.status==="online"?"text-emerald-500":"text-muted-foreground"}`}),a("span",{className:"text-muted-foreground",children:"运行状态"})]}),a(L,{variant:o.status==="online"?"success":"secondary",children:o.status==="online"?"运行中":"已停止"})]}),d("div",{className:"flex justify-between items-center p-2 rounded-md bg-muted/50",children:[d("div",{className:"flex items-center gap-2 text-sm",children:[a(le,{className:"w-4 h-4 text-muted-foreground"}),a("span",{className:"text-muted-foreground",children:"适配器类型"})]}),a("span",{className:"text-sm font-medium",children:o.adapter})]}),d("div",{className:"flex justify-between items-center p-2 rounded-md bg-muted/50",children:[d("div",{className:"flex items-center gap-2 text-sm",children:[a(kr,{className:"w-4 h-4 text-muted-foreground"}),a("span",{className:"text-muted-foreground",children:"连接状态"})]}),a("span",{className:`text-sm font-medium ${o.connected?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"}`,children:o.connected?"已连接":"未连接"})]})]})]})},`${o.adapter}-${o.name}-${c}`))}),s.length===0&&a(_,{children:d(P,{className:"flex flex-col items-center gap-4 py-12",children:[a(Ve,{className:"w-16 h-16 text-muted-foreground/30"}),d("div",{className:"text-center",children:[a("h3",{className:"text-lg font-semibold",children:"暂无机器人"}),a("p",{className:"text-sm text-muted-foreground",children:"请先配置并启动机器人"})]})]})})]})}const yn=E.forwardRef(({className:s,...e},t)=>a(_s.Root,{ref:t,className:I("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",s),...e,children:a(_s.Indicator,{className:I("flex items-center justify-center text-current"),children:a(en,{className:"h-4 w-4"})})}));yn.displayName="Checkbox";function Hi(){const[s,e]=T([]),[t,n]=T(null),[r,i]=T(!0),[l,o]=T(null),[c,u]=T("all"),[m,h]=T(!0),f=ir(null),[g,b]=T(0);G(()=>{p(),y();const w=setInterval(()=>{p(),y()},3e3);return()=>clearInterval(w)},[c]),G(()=>{m&&s.length>g&&f.current?.scrollIntoView({behavior:"smooth"}),b(s.length)},[s,m]);const p=async()=>{try{const w=c==="all"?"/api/logs?limit=100":`/api/logs?limit=100&level=${c}`,S=await fe(w);if(!S.ok)throw new Error("API 请求失败");const v=await S.json();v.success&&Array.isArray(v.data)&&(e(v.data.reverse()),o(null))}catch(w){o(w.message)}finally{i(!1)}},y=async()=>{try{const w=await fe("/api/logs/stats");if(!w.ok)return;const S=await w.json();S.success&&n(S.data)}catch(w){console.error("Failed to fetch stats:",w)}},k=async(w,S)=>{const v=w?`确定清理 ${w} 天前的日志吗?`:`确定只保留最近 ${S} 条日志吗?`;if(confirm(v))try{const N=await fe("/api/logs/cleanup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({days:w,maxRecords:S})});if(!N.ok)throw new Error("清理失败");const C=await N.json();C.success&&(alert(`成功清理 ${C.data.deletedCount} 条日志`),p(),y())}catch(N){alert(N.message)}},O=w=>{switch(w){case"info":return{border:"border-l-blue-500",badge:"default",icon:a(wt,{className:"w-3 h-3"})};case"warn":return{border:"border-l-amber-500",badge:"warning",icon:a(nn,{className:"w-3 h-3"})};case"error":return{border:"border-l-red-500",badge:"destructive",icon:a(Or,{className:"w-3 h-3"})};default:return{border:"border-l-gray-500",badge:"secondary",icon:a(Sr,{className:"w-3 h-3"})}}};return r?d("div",{className:"space-y-4",children:[a(U,{className:"h-8 w-48"}),a("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[...Array(4)].map((w,S)=>a(U,{className:"h-20"},S))}),a(U,{className:"h-96"})]}):d("div",{className:"space-y-4",children:[d("div",{children:[a("h1",{className:"text-2xl font-bold tracking-tight",children:"系统日志"}),a("p",{className:"text-sm text-muted-foreground",children:"实时查看系统运行日志"})]}),t&&d("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[a(_,{children:d(P,{className:"flex flex-col items-center gap-1 p-4",children:[a("span",{className:"text-2xl font-bold",children:t.total}),a("span",{className:"text-xs text-muted-foreground",children:"总日志数"})]})}),a(_,{children:d(P,{className:"flex flex-col items-center gap-1 p-4",children:[a("span",{className:"text-2xl font-bold text-blue-600 dark:text-blue-400",children:t.byLevel.info||0}),a("span",{className:"text-xs text-muted-foreground",children:"Info"})]})}),a(_,{children:d(P,{className:"flex flex-col items-center gap-1 p-4",children:[a("span",{className:"text-2xl font-bold text-amber-600 dark:text-amber-400",children:t.byLevel.warn||0}),a("span",{className:"text-xs text-muted-foreground",children:"Warn"})]})}),a(_,{children:d(P,{className:"flex flex-col items-center gap-1 p-4",children:[a("span",{className:"text-2xl font-bold text-red-600 dark:text-red-400",children:t.byLevel.error||0}),a("span",{className:"text-xs text-muted-foreground",children:"Error"})]})})]}),a(_,{children:d(P,{className:"flex justify-between items-center p-3 flex-wrap gap-3",children:[d("div",{className:"flex items-center gap-3 flex-wrap",children:[d(hs,{value:c,onValueChange:u,children:[a(St,{className:"w-32",children:a(ms,{placeholder:"所有级别"})}),d(Ot,{children:[a(pe,{value:"all",children:"所有级别"}),a(pe,{value:"info",children:"Info"}),a(pe,{value:"warn",children:"Warn"}),a(pe,{value:"error",children:"Error"})]})]}),d("div",{className:"flex items-center gap-2",children:[a(yn,{id:"auto-scroll",checked:m,onCheckedChange:w=>h(w)}),a("label",{htmlFor:"auto-scroll",className:"text-sm cursor-pointer",children:"自动滚动"})]})]}),d("div",{className:"flex gap-2",children:[d(M,{variant:"outline",size:"sm",onClick:()=>k(7),children:[a(qt,{className:"w-3.5 h-3.5 mr-1"}),"清理7天前"]}),d(M,{variant:"outline",size:"sm",onClick:()=>k(void 0,5e3),children:[a(qt,{className:"w-3.5 h-3.5 mr-1"}),"保留5000条"]}),d(M,{variant:"outline",size:"sm",onClick:()=>p(),children:[a(cs,{className:"w-3.5 h-3.5 mr-1"}),"刷新"]})]})]})}),a(_,{children:a(P,{className:"p-4",children:d("div",{className:"max-h-[600px] overflow-y-auto rounded-md bg-muted/30 p-2 space-y-1.5",children:[l?d(z,{variant:"destructive",children:[a(ae,{className:"h-4 w-4"}),d(Y,{children:["加载失败: ",l]})]}):s.length===0?d("div",{className:"flex flex-col items-center gap-3 py-12",children:[a(ss,{className:"w-12 h-12 text-muted-foreground/30"}),a("span",{className:"text-sm text-muted-foreground",children:"暂无日志"})]}):s.map((w,S)=>{const v=O(w.level);return d("div",{className:I("p-3 rounded-md bg-background border-l-[3px]",v.border),children:[d("div",{className:"flex items-center gap-2 mb-1",children:[d(L,{variant:v.badge,className:"gap-1 text-[10px] px-1.5 py-0",children:[v.icon," ",w.level.toUpperCase()]}),a("span",{className:"text-[11px] text-muted-foreground",children:new Date(w.timestamp).toLocaleString()}),w.source&&a(L,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:w.source})]}),a("p",{className:"text-sm font-mono whitespace-pre-wrap break-words",children:w.message})]},`${w.timestamp}-${S}`)}),a("div",{ref:f})]})})})]})}const ps=Symbol.for("yaml.alias"),Jt=Symbol.for("yaml.document"),he=Symbol.for("yaml.map"),bn=Symbol.for("yaml.pair"),oe=Symbol.for("yaml.scalar"),$e=Symbol.for("yaml.seq"),ee=Symbol.for("yaml.node.type"),we=s=>!!s&&typeof s=="object"&&s[ee]===ps,Ge=s=>!!s&&typeof s=="object"&&s[ee]===Jt,He=s=>!!s&&typeof s=="object"&&s[ee]===he,F=s=>!!s&&typeof s=="object"&&s[ee]===bn,j=s=>!!s&&typeof s=="object"&&s[ee]===oe,Qe=s=>!!s&&typeof s=="object"&&s[ee]===$e;function B(s){if(s&&typeof s=="object")switch(s[ee]){case he:case $e:return!0}return!1}function D(s){if(s&&typeof s=="object")switch(s[ee]){case ps:case he:case oe:case $e:return!0}return!1}const Nn=s=>(j(s)||B(s))&&!!s.anchor,me=Symbol("break visit"),Qi=Symbol("skip children"),Ke=Symbol("remove node");function _e(s,e){const t=Xi(e);Ge(s)?ke(null,s.contents,t,Object.freeze([s]))===Ke&&(s.contents=null):ke(null,s,t,Object.freeze([]))}_e.BREAK=me;_e.SKIP=Qi;_e.REMOVE=Ke;function ke(s,e,t,n){const r=Zi(s,e,t,n);if(D(r)||F(r))return ea(s,n,r),ke(s,r,t,n);if(typeof r!="symbol"){if(B(e)){n=Object.freeze(n.concat(e));for(let i=0;i<e.items.length;++i){const l=ke(i,e.items[i],t,n);if(typeof l=="number")i=l-1;else{if(l===me)return me;l===Ke&&(e.items.splice(i,1),i-=1)}}}else if(F(e)){n=Object.freeze(n.concat(e));const i=ke("key",e.key,t,n);if(i===me)return me;i===Ke&&(e.key=null);const l=ke("value",e.value,t,n);if(l===me)return me;l===Ke&&(e.value=null)}}return r}function Xi(s){return typeof s=="object"&&(s.Collection||s.Node||s.Value)?Object.assign({Alias:s.Node,Map:s.Node,Scalar:s.Node,Seq:s.Node},s.Value&&{Map:s.Value,Scalar:s.Value,Seq:s.Value},s.Collection&&{Map:s.Collection,Seq:s.Collection},s):s}function Zi(s,e,t,n){if(typeof t=="function")return t(s,e,n);if(He(e))return t.Map?.(s,e,n);if(Qe(e))return t.Seq?.(s,e,n);if(F(e))return t.Pair?.(s,e,n);if(j(e))return t.Scalar?.(s,e,n);if(we(e))return t.Alias?.(s,e,n)}function ea(s,e,t){const n=e[e.length-1];if(B(n))n.items[s]=t;else if(F(n))s==="key"?n.key=t:n.value=t;else if(Ge(n))n.contents=t;else{const r=we(n)?"alias":"scalar";throw new Error(`Cannot replace node with ${r} parent`)}}const ta={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},sa=s=>s.replace(/[!,[\]{}]/g,e=>ta[e]);class K{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},K.defaultYaml,e),this.tags=Object.assign({},K.defaultTags,t)}clone(){const e=new K(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){const e=new K(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:K.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},K.defaultTags);break}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:K.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},K.defaultTags),this.atNextDocument=!1);const n=e.trim().split(/[ \t]+/),r=n.shift();switch(r){case"%TAG":{if(n.length!==2&&(t(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;const[i,l]=n;return this.tags[i]=l,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;const[i]=n;if(i==="1.1"||i==="1.2")return this.yaml.version=i,!0;{const l=/^\d+\.\d+$/.test(i);return t(6,`Unsupported YAML version ${i}`,l),!1}}default:return t(0,`Unknown directive ${r}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){const l=e.slice(2,-1);return l==="!"||l==="!!"?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&t("Verbatim tags must end with a >"),l)}const[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);const i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(l){return t(String(l)),null}return n==="!"?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(const[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+sa(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){const t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags);let r;if(e&&n.length>0&&D(e.contents)){const i={};_e(e.contents,(l,o)=>{D(o)&&o.tag&&(i[o.tag]=!0)}),r=Object.keys(i)}else r=[];for(const[i,l]of n)i==="!!"&&l==="tag:yaml.org,2002:"||(!e||r.some(o=>o.startsWith(l)))&&t.push(`%TAG ${i} ${l}`);return t.join(`
8
- `)}}K.defaultYaml={explicit:!1,version:"1.2"};K.defaultTags={"!!":"tag:yaml.org,2002:"};function wn(s){if(/[\x00-\x19\s,[\]{}]/.test(s)){const t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(s)}`;throw new Error(t)}return!0}function vn(s){const e=new Set;return _e(s,{Value(t,n){n.anchor&&e.add(n.anchor)}}),e}function xn(s,e){for(let t=1;;++t){const n=`${s}${t}`;if(!e.has(n))return n}}function na(s,e){const t=[],n=new Map;let r=null;return{onAnchor:i=>{t.push(i),r??(r=vn(s));const l=xn(e,r);return r.add(l),l},setAnchors:()=>{for(const i of t){const l=n.get(i);if(typeof l=="object"&&l.anchor&&(j(l.node)||B(l.node)))l.node.anchor=l.anchor;else{const o=new Error("Failed to resolve repeated object (this should not happen)");throw o.source=i,o}}},sourceObjects:n}}function Se(s,e,t,n){if(n&&typeof n=="object")if(Array.isArray(n))for(let r=0,i=n.length;r<i;++r){const l=n[r],o=Se(s,n,String(r),l);o===void 0?delete n[r]:o!==l&&(n[r]=o)}else if(n instanceof Map)for(const r of Array.from(n.keys())){const i=n.get(r),l=Se(s,n,r,i);l===void 0?n.delete(r):l!==i&&n.set(r,l)}else if(n instanceof Set)for(const r of Array.from(n)){const i=Se(s,n,r,r);i===void 0?n.delete(r):i!==r&&(n.delete(r),n.add(i))}else for(const[r,i]of Object.entries(n)){const l=Se(s,n,r,i);l===void 0?delete n[r]:l!==i&&(n[r]=l)}return s.call(e,t,n)}function Z(s,e,t){if(Array.isArray(s))return s.map((n,r)=>Z(n,String(r),t));if(s&&typeof s.toJSON=="function"){if(!t||!Nn(s))return s.toJSON(e,t);const n={aliasCount:0,count:1,res:void 0};t.anchors.set(s,n),t.onCreate=i=>{n.res=i,delete t.onCreate};const r=s.toJSON(e,t);return t.onCreate&&t.onCreate(r),r}return typeof s=="bigint"&&!t?.keep?Number(s):s}class gs{constructor(e){Object.defineProperty(this,ee,{value:e})}clone(){const e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!Ge(e))throw new TypeError("A document argument is required");const l={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},o=Z(this,"",l);if(typeof r=="function")for(const{count:c,res:u}of l.anchors.values())r(u,c);return typeof i=="function"?Se(i,{"":o},"",o):o}}class ys extends gs{constructor(e){super(ps),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,t){let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],_e(e,{Node:(i,l)=>{(we(l)||Nn(l))&&n.push(l)}}),t&&(t.aliasResolveCache=n));let r;for(const i of n){if(i===this)break;i.anchor===this.source&&(r=i)}return r}toJSON(e,t){if(!t)return{source:this.source};const{anchors:n,doc:r,maxAliasCount:i}=t,l=this.resolve(r,t);if(!l){const c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let o=n.get(l);if(o||(Z(l,null,t),o=n.get(l)),o?.res===void 0){const c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(i>=0&&(o.count+=1,o.aliasCount===0&&(o.aliasCount=lt(r,l,n)),o.count*o.aliasCount>i)){const c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return o.res}toString(e,t,n){const r=`*${this.source}`;if(e){if(wn(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){const i=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(i)}if(e.implicitKey)return`${r} `}return r}}function lt(s,e,t){if(we(e)){const n=e.resolve(s),r=t&&n&&t.get(n);return r?r.count*r.aliasCount:0}else if(B(e)){let n=0;for(const r of e.items){const i=lt(s,r,t);i>n&&(n=i)}return n}else if(F(e)){const n=lt(s,e.key,t),r=lt(s,e.value,t);return Math.max(n,r)}return 1}const kn=s=>!s||typeof s!="function"&&typeof s!="object";class A extends gs{constructor(e){super(oe),this.value=e}toJSON(e,t){return t?.keep?this.value:Z(this.value,e,t)}toString(){return String(this.value)}}A.BLOCK_FOLDED="BLOCK_FOLDED";A.BLOCK_LITERAL="BLOCK_LITERAL";A.PLAIN="PLAIN";A.QUOTE_DOUBLE="QUOTE_DOUBLE";A.QUOTE_SINGLE="QUOTE_SINGLE";const ra="tag:yaml.org,2002:";function ia(s,e,t){if(e){const n=t.filter(i=>i.tag===e),r=n.find(i=>!i.format)??n[0];if(!r)throw new Error(`Tag ${e} not found`);return r}return t.find(n=>n.identify?.(s)&&!n.format)}function ze(s,e,t){if(Ge(s)&&(s=s.contents),D(s))return s;if(F(s)){const h=t.schema[he].createNode?.(t.schema,null,t);return h.items.push(s),h}(s instanceof String||s instanceof Number||s instanceof Boolean||typeof BigInt<"u"&&s instanceof BigInt)&&(s=s.valueOf());const{aliasDuplicateObjects:n,onAnchor:r,onTagObj:i,schema:l,sourceObjects:o}=t;let c;if(n&&s&&typeof s=="object"){if(c=o.get(s),c)return c.anchor??(c.anchor=r(s)),new ys(c.anchor);c={anchor:null,node:null},o.set(s,c)}e?.startsWith("!!")&&(e=ra+e.slice(2));let u=ia(s,e,l.tags);if(!u){if(s&&typeof s.toJSON=="function"&&(s=s.toJSON()),!s||typeof s!="object"){const h=new A(s);return c&&(c.node=h),h}u=s instanceof Map?l[he]:Symbol.iterator in Object(s)?l[$e]:l[he]}i&&(i(u),delete t.onTagObj);const m=u?.createNode?u.createNode(t.schema,s,t):typeof u?.nodeClass?.from=="function"?u.nodeClass.from(t.schema,s,t):new A(s);return e?m.tag=e:u.default||(m.tag=u.tag),c&&(c.node=m),m}function mt(s,e,t){let n=t;for(let r=e.length-1;r>=0;--r){const i=e[r];if(typeof i=="number"&&Number.isInteger(i)&&i>=0){const l=[];l[i]=n,n=l}else n=new Map([[i,n]])}return ze(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:s,sourceObjects:new Map})}const Re=s=>s==null||typeof s=="object"&&!!s[Symbol.iterator]().next().done;class Sn extends gs{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){const t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(n=>D(n)||F(n)?n.clone(e):n),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Re(e))this.add(t);else{const[n,...r]=e,i=this.get(n,!0);if(B(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,mt(this.schema,r,t));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){const[t,...n]=e;if(n.length===0)return this.delete(t);const r=this.get(t,!0);if(B(r))return r.deleteIn(n);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){const[n,...r]=e,i=this.get(n,!0);return r.length===0?!t&&j(i)?i.value:i:B(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!F(t))return!1;const n=t.value;return n==null||e&&j(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){const[t,...n]=e;if(n.length===0)return this.has(t);const r=this.get(t,!0);return B(r)?r.hasIn(n):!1}setIn(e,t){const[n,...r]=e;if(r.length===0)this.set(n,t);else{const i=this.get(n,!0);if(B(i))i.setIn(r,t);else if(i===void 0&&this.schema)this.set(n,mt(this.schema,r,t));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}}const aa=s=>s.replace(/^(?!$)(?: $)?/gm,"#");function ce(s,e){return/^\n+$/.test(s)?s.substring(1):e?s.replace(/^(?! *$)/gm,e):s}const ge=(s,e,t)=>s.endsWith(`
9
- `)?ce(t,e):t.includes(`
7
+ ${s.description||""}`,rows:3,className:"font-mono text-sm"})]})}function la({fieldName:s,field:e,value:t,onArrayItemChange:n,renderNestedField:r}){const a=Array.isArray(t)?t:[],l=e.list||[];return i("div",{className:"space-y-2",children:l.map((c,d)=>o("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[o(_,{variant:"secondary",className:"font-mono",children:["#",d+1]}),c.description&&i("p",{className:"text-xs text-muted-foreground",children:c.description}),i("div",{className:"mt-1",children:r(`${s}[${d}]`,c,a[d],u=>{n?.(s,d,u)})})]},d))})}function oa({fieldName:s,field:e,renderField:t}){const n=e.dict||e.properties||{};return o("div",{className:"rounded-lg border-2 bg-muted/30 overflow-hidden",children:[o("div",{className:"px-4 py-2 bg-muted border-b flex items-center gap-2",children:[i(fe,{className:"w-4 h-4 text-muted-foreground"}),i("span",{className:"text-xs font-semibold text-muted-foreground",children:"对象"})]}),i("div",{className:"p-3 space-y-2",children:Object.entries(n).map(([r,a],l)=>o("div",{children:[o("div",{className:"p-3 rounded-md bg-background border space-y-1",children:[o("div",{className:"flex items-center gap-1",children:[i("span",{className:"text-sm font-semibold",children:a.key||r}),a.required&&i("span",{className:"text-destructive font-bold",children:"*"})]}),a.description&&i("p",{className:"text-xs text-muted-foreground",children:a.description}),i("div",{className:"mt-1",children:t(r,a,s)})]}),l<Object.entries(n).length-1&&i(Ke,{className:"my-2"})]},r))})]})}function ca({field:s,value:e,onChange:t}){return o("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[o("p",{className:"flex items-center gap-1 text-xs font-semibold text-muted-foreground",children:[i(kn,{className:"w-3 h-3"})," 键值对编辑"]}),i(se,{value:typeof e=="object"?JSON.stringify(e,null,2):e||"{}",onChange:n=>{try{t(JSON.parse(n.target.value))}catch{}},placeholder:s.description||"请输入 JSON 格式",rows:6,className:"font-mono text-sm"}),o("p",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[i(jt,{className:"w-3 h-3"})," 键值对格式: ","{",'"key": "value"',"}"]})]})}function da({field:s,value:e,onChange:t}){const n=s.list||[];if(n.length===0)return i(Y,{value:e||"",onChange:a=>t(a.target.value),placeholder:s.description||"请输入值"});const r=n.map(a=>a.default||a.type);return o("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[o("p",{className:"flex items-center gap-1 text-xs font-semibold text-muted-foreground",children:[i(Ur,{className:"w-3 h-3"})," 联合类型"]}),o(Es,{value:e?.toString()||"",onValueChange:t,children:[i(Dt,{children:i(Is,{placeholder:"请选择"})}),i(Rt,{children:r.map((a,l)=>i(ke,{value:String(a),children:String(a)},l))})]})]})}function ua({fieldName:s,field:e,value:t,onChange:n,renderNestedField:r}){const a=e.list||[];return o("div",{className:"rounded-lg border-2 bg-muted/30 overflow-hidden",children:[o("div",{className:"px-4 py-2 bg-muted border-b flex items-center gap-2",children:[i(vs,{className:"w-4 h-4 text-muted-foreground"}),i("span",{className:"text-xs font-semibold text-muted-foreground",children:"交叉类型"})]}),i("div",{className:"p-3 space-y-2",children:a.map((l,c)=>o("div",{className:"p-3 rounded-md bg-background border space-y-1",children:[l.description&&i("p",{className:"text-xs text-muted-foreground",children:l.description}),i("div",{className:"mt-1",children:r(`${s}[${c}]`,l,t,n)})]},c))})]})}function fa(s){const{field:e}=s;switch(e.type){case"string":return i(Qi,{...s});case"number":case"integer":return i(Xi,{...s});case"boolean":return i(Zi,{...s});case"percent":return i(ea,{...s});case"date":return i(ta,{...s});case"regexp":return i(sa,{...s});case"const":return i(na,{...s});case"any":return i(ra,{...s});case"list":return i(ia,{...s});case"array":return i(aa,{...s});case"tuple":return i(la,{...s});case"object":return i(oa,{...s});case"dict":return i(ca,{...s});case"union":return i(da,{...s});case"intersect":return i(ua,{...s});default:return i(se,{value:typeof s.value=="object"?JSON.stringify(s.value,null,2):s.value||"",onChange:t=>{try{s.onChange(JSON.parse(t.target.value))}catch{s.onChange(t.target.value)}},placeholder:e.description||"请输入 JSON 格式",rows:4,className:"font-mono text-xs"})}}function Pn({field:s,value:e,onChange:t}){switch(s.type){case"string":return i(Y,{value:e||"",onChange:n=>t(n.target.value),placeholder:s.description||"请输入",className:"h-8 text-sm"});case"number":case"integer":return i(Y,{type:"number",value:e?.toString()||"",onChange:n=>t(parseFloat(n.target.value)||0),placeholder:s.description||"请输入数字",min:s.min,max:s.max,className:"h-8 text-sm"});case"boolean":return o("div",{className:"flex items-center gap-2",children:[i(As,{checked:e===!0,onCheckedChange:t}),i("span",{className:`text-sm ${e?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"}`,children:e?"已启用":"已禁用"})]});case"object":{const n=s.dict||s.properties||{};return i(P,{className:"p-2 space-y-2",children:Object.entries(n).map(([r,a])=>o("div",{className:"space-y-1",children:[i("span",{className:"text-xs font-semibold",children:r}),i(Pn,{fieldName:r,field:a,value:e?.[r],onChange:l=>t({...e,[r]:l})})]},r))})}default:return i(se,{value:typeof e=="object"?JSON.stringify(e,null,2):e||"",onChange:n=>{try{t(JSON.parse(n.target.value))}catch{t(n.target.value)}},rows:3,className:"font-mono text-xs"})}}const ha=nt.Root,Mn=$.forwardRef(({className:s,...e},t)=>i(nt.Item,{ref:t,className:E("border-b",s),...e}));Mn.displayName="AccordionItem";const Dn=$.forwardRef(({className:s,children:e,...t},n)=>i(nt.Header,{className:"flex",children:o(nt.Trigger,{ref:n,className:E("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",s),...t,children:[e,i($t,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200"})]})}));Dn.displayName="AccordionTrigger";const Rn=$.forwardRef(({className:s,children:e,...t},n)=>i(nt.Content,{ref:n,className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...t,children:i("div",{className:E("pb-4 pt-0",s),children:e})}));Rn.displayName="AccordionContent";function ma({pluginName:s,onSuccess:e}){const[t,n]=T({}),[r,a]=T(null),[l,c]=T(void 0),{config:d,schema:u,loading:h,error:m,connected:f,setConfig:g}=ri(s);z(()=>{d&&n(d)},[d]);const[w,p]=T(null),b=async()=>{if(f)try{const y=await g(t);y?.reloaded?a("配置已保存,插件已重载"):y?.message?(p(y.message),a(null)):a("配置已保存"),setTimeout(()=>{c(void 0),e?.(),a(null),p(null)},2500)}catch(y){console.error("保存配置失败:",y)}},k=(y,O)=>{n(v=>({...v,[y]:O}))},x=(y,O,v)=>{n(j=>({...j,[y]:{...j[y]||{},[O]:v}}))},N=(y,O,v)=>{n(j=>{const H=Array.isArray(j[y])?[...j[y]]:[];return H[O]=v,{...j,[y]:H}})},C=(y,O,v)=>{const j=v?t[v]?.[y]??O.default:t[y]??O.default;return i(fa,{fieldName:y,field:O,value:j,onChange:v?W=>x(v,y,W):W=>k(y,W),parentPath:v,onNestedChange:x,onArrayItemChange:N,renderField:C,renderNestedField:(W,D,I,B)=>i(Pn,{fieldName:W,field:D,value:I,onChange:B})})},S=u?.object||u?.properties||u?.dict||{};return!u||!S||Object.keys(S).length===0?null:i(P,{className:"mt-4",children:i(ha,{type:"single",collapsible:!0,value:l,onValueChange:c,children:o(Mn,{value:"config",className:"border-none",children:[i(Dn,{className:"px-4 hover:no-underline",children:o("div",{className:"flex items-center gap-2",children:[i(lt,{className:"w-4 h-4"}),i("span",{className:"font-semibold",children:"插件配置"}),o(_,{variant:"secondary",children:[Object.keys(S).length," 项"]})]})}),o(Rn,{className:"px-4 pb-4",children:[r&&o(V,{variant:"success",className:"mb-3",children:[i(Ee,{className:"h-4 w-4"}),i(q,{children:r})]}),w&&!r&&o(V,{className:"mb-3 border-yellow-500/50 text-yellow-700 dark:text-yellow-400",children:[i(Cn,{className:"h-4 w-4"}),i(q,{children:w})]}),m&&o(V,{variant:"destructive",className:"mb-3",children:[i(G,{className:"h-4 w-4"}),i(q,{children:m})]}),i("div",{className:"space-y-3",children:Object.entries(S).map(([y,O])=>{const v=O;return o("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[o("div",{className:"flex items-center gap-1",children:[i("span",{className:"text-sm font-semibold",children:v.key||y}),v.required&&i("span",{className:"text-destructive font-bold",children:"*"})]}),v.description&&i("p",{className:"text-xs text-muted-foreground",children:v.description}),i("div",{className:"mt-1",children:C(v.key||y,v)})]},y)})}),o("div",{className:"flex gap-2 justify-end mt-4 pt-3 border-t",children:[o(A,{variant:"outline",size:"sm",onClick:()=>c(void 0),disabled:h,children:[i(ot,{className:"w-4 h-4 mr-1"})," 取消"]}),i(A,{size:"sm",onClick:b,disabled:h,children:h?o(ne,{children:[i(te,{className:"w-4 h-4 mr-1 animate-spin"}),"保存中..."]}):o(ne,{children:[i(we,{className:"w-4 h-4 mr-1"}),"保存配置"]})})]})]})]})})})}const pa={Terminal:xn,Box:wn,Layers:vs,Clock:bs,Brain:Nn,Wrench:bn,Database:Fe,Shield:yn,Settings:lt,Plug:xs,Server:ws};function sn(s){return pa[s]||fe}function ga(){const{name:s}=pi(),e=Os(),[t,n]=T(null),[r,a]=T(!0),[l,c]=T(null);z(()=>{s&&d(s)},[s]);const d=async u=>{try{const h=await be(`/api/plugins/${encodeURIComponent(u)}`);if(!h.ok)throw new Error("API 请求失败");const m=await h.json();if(m.success)n(m.data),c(null);else throw new Error("数据格式错误")}catch(h){c(h.message)}finally{a(!1)}};return r?o("div",{className:"space-y-4",children:[i(X,{className:"h-8 w-24"}),o("div",{className:"flex items-center gap-3",children:[i(X,{className:"h-12 w-12 rounded-xl"}),o("div",{children:[i(X,{className:"h-6 w-48"}),i(X,{className:"h-4 w-64 mt-1"})]})]}),i("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-6 gap-2",children:[...Array(6)].map((u,h)=>i(X,{className:"h-20"},h))})]}):l||!t?o("div",{children:[o(A,{variant:"ghost",onClick:()=>e("/plugins"),className:"mb-4",children:[i(Gs,{className:"w-4 h-4 mr-1"})," 返回"]}),o(V,{variant:"destructive",children:[i(G,{className:"h-4 w-4"}),o(q,{children:["加载失败: ",l||"插件不存在"]})]})]}):o("div",{className:"space-y-4",children:[o(A,{variant:"ghost",size:"sm",onClick:()=>e("/plugins"),children:[i(Gs,{className:"w-4 h-4 mr-1"})," 返回"]}),o("div",{className:"flex items-center gap-3",children:[i("div",{className:"flex items-center justify-center w-12 h-12 rounded-xl bg-secondary",children:i(fe,{className:"w-6 h-6"})}),o("div",{children:[o("div",{className:"flex items-center gap-2",children:[i("h1",{className:"text-xl font-bold",children:t.name}),i(_,{variant:t.status==="active"?"success":"secondary",children:t.status==="active"?"运行中":"已停止"})]}),i("p",{className:"text-sm text-muted-foreground",children:t.description||"暂无描述"})]})]}),i(ma,{pluginName:t.name,onSuccess:()=>{}}),i(Ke,{}),t.features.length>0&&o("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-6 gap-2",children:[t.features.map(u=>{const h=sn(u.icon);return i(P,{children:o(M,{className:"flex flex-col items-center gap-1 p-3",children:[i(h,{className:"w-4 h-4 text-muted-foreground"}),i("span",{className:"text-2xl font-bold",children:u.count}),i("span",{className:"text-xs text-muted-foreground",children:u.desc})]})},u.name)}),t.contexts.length>0&&i(P,{children:o(M,{className:"flex flex-col items-center gap-1 p-3",children:[i(Fe,{className:"w-4 h-4 text-muted-foreground"}),i("span",{className:"text-2xl font-bold",children:t.contexts.length}),i("span",{className:"text-xs text-muted-foreground",children:"上下文"})]})})]}),o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[t.features.map(u=>{if(u.items.length===0)return null;const h=sn(u.icon);return o(P,{children:[i(oe,{className:"pb-2",children:o("div",{className:"flex items-center gap-2",children:[i(h,{className:"w-4 h-4 text-muted-foreground"}),i(ce,{className:"text-base",children:u.desc}),i(_,{variant:"secondary",children:u.count})]})}),i(M,{children:i("div",{className:"max-h-60 overflow-y-auto pr-1 space-y-2",children:u.items.map((m,f)=>i(ya,{featureName:u.name,item:m},f))})})]},u.name)}),t.contexts.length>0&&o(P,{children:[i(oe,{className:"pb-2",children:o("div",{className:"flex items-center gap-2",children:[i(Fe,{className:"w-4 h-4 text-muted-foreground"}),i(ce,{className:"text-base",children:"上下文"}),i(_,{variant:"secondary",children:t.contexts.length})]})}),i(M,{children:i("div",{className:"max-h-60 overflow-y-auto pr-1 space-y-2",children:t.contexts.map((u,h)=>i("div",{className:"rounded-md bg-muted/50 p-2",children:i("code",{className:"text-sm",children:u.name})},h))})})]})]})]})}function ya({featureName:s,item:e}){switch(s){case"command":return o("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[i("code",{className:"text-sm font-semibold",children:e.name}),e.desc?.map((t,n)=>i("p",{className:"text-xs text-muted-foreground",children:t},n)),e.usage&&e.usage.length>0&&o("div",{children:[i("span",{className:"text-xs font-semibold text-blue-600 dark:text-blue-400",children:"用法:"}),e.usage.map((t,n)=>i("code",{className:"block text-xs bg-muted rounded px-1 py-0.5 mt-0.5",children:t},n))]}),e.examples&&e.examples.length>0&&o("div",{children:[i("span",{className:"text-xs font-semibold text-emerald-600 dark:text-emerald-400",children:"示例:"}),e.examples.map((t,n)=>i("code",{className:"block text-xs bg-muted rounded px-1 py-0.5 mt-0.5",children:t},n))]})]});case"cron":return o("div",{className:"flex justify-between items-center rounded-md bg-muted/50 p-2",children:[i("code",{className:"text-sm",children:e.expression}),i(_,{variant:e.running?"success":"secondary",children:e.running?"运行中":"已停止"})]});case"tool":return o("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[i("code",{className:"text-sm font-semibold",children:e.name}),e.desc&&i("p",{className:"text-xs text-muted-foreground",children:e.desc}),e.platforms&&e.platforms.length>0&&i("div",{className:"flex gap-1 flex-wrap",children:e.platforms.map((t,n)=>i(_,{variant:"outline",className:"text-[10px]",children:t},n))})]});case"skill":return o("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[i("code",{className:"text-sm font-semibold",children:e.name}),e.desc&&i("p",{className:"text-xs text-muted-foreground",children:e.desc}),e.toolCount!=null&&o("span",{className:"text-xs text-muted-foreground",children:["工具: ",e.toolCount]})]});case"config":return o("div",{className:"flex justify-between items-center rounded-md bg-muted/50 p-2",children:[i("code",{className:"text-sm",children:e.name}),e.defaultValue!==void 0&&o("span",{className:"text-xs text-muted-foreground",children:["默认: ",JSON.stringify(e.defaultValue)]})]});case"permission":return i("div",{className:"rounded-md bg-muted/50 p-2",children:i("code",{className:"text-sm",children:e.name})});case"database":return i("div",{className:"rounded-md bg-muted/50 p-2",children:i("code",{className:"text-sm",children:e.name})});case"adapter":return o("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[o("div",{className:"flex items-center gap-2",children:[i(xs,{className:"w-3.5 h-3.5 text-muted-foreground"}),i("code",{className:"text-sm font-semibold",children:e.name})]}),o("div",{className:"flex gap-3 text-xs text-muted-foreground",children:[o("span",{children:["Bot: ",e.bots??0]}),o("span",{children:["在线: ",e.online??0]}),e.tools>0&&o("span",{children:["工具: ",e.tools]})]})]});case"service":return o("div",{className:"rounded-md bg-muted/50 p-2 flex items-center gap-2",children:[i(ws,{className:"w-3.5 h-3.5 text-muted-foreground"}),i("code",{className:"text-sm",children:e.name}),e.desc&&e.desc!==e.name&&o("span",{className:"text-xs text-muted-foreground",children:["- ",e.desc]})]});default:return i("div",{className:"rounded-md bg-muted/50 p-2",children:i("code",{className:"text-sm",children:e.name||JSON.stringify(e)})})}}function ba(){const[s,e]=T([]),[t,n]=T(!0),[r,a]=T(null);z(()=>{l();const c=setInterval(l,5e3);return()=>clearInterval(c)},[]);const l=async()=>{try{const c=await be("/api/bots");if(!c.ok)throw new Error("API 请求失败");const d=await c.json();if(d.success)e(d.data),a(null);else throw new Error("数据格式错误")}catch(c){a(c.message)}finally{n(!1)}};return t?o("div",{className:"space-y-6",children:[i(X,{className:"h-8 w-48"}),i("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((c,d)=>i(X,{className:"h-48"},d))})]}):r?i("div",{className:"flex items-center justify-center h-full",children:o(V,{variant:"destructive",className:"max-w-md",children:[i(G,{className:"h-4 w-4"}),o(q,{children:["加载失败: ",r]})]})}):o("div",{className:"space-y-6",children:[o("div",{children:[i("h1",{className:"text-2xl font-bold tracking-tight",children:"机器人管理"}),o("div",{className:"flex items-center gap-2 mt-1",children:[o("span",{className:"text-sm text-muted-foreground",children:["共 ",s.length," 个机器人,"]}),i(_,{variant:"success",children:s.filter(c=>c.connected).length}),i("span",{className:"text-sm text-muted-foreground",children:"个在线"})]})]}),i(Ke,{}),i("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:s.map((c,d)=>i(P,{children:o(M,{className:"p-5 space-y-4",children:[o("div",{className:"flex justify-between items-center",children:[o("div",{className:"flex items-center gap-2",children:[i("div",{className:`p-2 rounded-md ${c.connected?"bg-emerald-100 dark:bg-emerald-900/30":"bg-muted"}`,children:i(st,{className:`w-5 h-5 ${c.connected?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"}`})}),i("span",{className:"text-lg font-bold",children:c.name})]}),i("div",{className:"relative",children:i(_,{variant:c.connected?"success":"secondary",children:c.connected?o(ne,{children:[i(Vr,{className:"w-3 h-3 mr-1"}),"在线"]}):o(ne,{children:[i(qr,{className:"w-3 h-3 mr-1"}),"离线"]})})})]}),o("div",{className:"flex items-center gap-2",children:[i("span",{className:"text-sm text-muted-foreground",children:"适配器:"}),i(_,{variant:"outline",children:c.adapter})]}),i(Ke,{}),o("div",{className:"space-y-2",children:[o("div",{className:"flex justify-between items-center p-2 rounded-md bg-muted/50",children:[o("div",{className:"flex items-center gap-2 text-sm",children:[i(ls,{className:`w-4 h-4 ${c.status==="online"?"text-emerald-500":"text-muted-foreground"}`}),i("span",{className:"text-muted-foreground",children:"运行状态"})]}),i(_,{variant:c.status==="online"?"success":"secondary",children:c.status==="online"?"运行中":"已停止"})]}),o("div",{className:"flex justify-between items-center p-2 rounded-md bg-muted/50",children:[o("div",{className:"flex items-center gap-2 text-sm",children:[i(fe,{className:"w-4 h-4 text-muted-foreground"}),i("span",{className:"text-muted-foreground",children:"适配器类型"})]}),i("span",{className:"text-sm font-medium",children:c.adapter})]}),o("div",{className:"flex justify-between items-center p-2 rounded-md bg-muted/50",children:[o("div",{className:"flex items-center gap-2 text-sm",children:[i(zr,{className:"w-4 h-4 text-muted-foreground"}),i("span",{className:"text-muted-foreground",children:"连接状态"})]}),i("span",{className:`text-sm font-medium ${c.connected?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"}`,children:c.connected?"已连接":"未连接"})]})]})]})},`${c.adapter}-${c.name}-${d}`))}),s.length===0&&i(P,{children:o(M,{className:"flex flex-col items-center gap-4 py-12",children:[i(st,{className:"w-16 h-16 text-muted-foreground/30"}),o("div",{className:"text-center",children:[i("h3",{className:"text-lg font-semibold",children:"暂无机器人"}),i("p",{className:"text-sm text-muted-foreground",children:"请先配置并启动机器人"})]})]})})]})}const Bn=$.forwardRef(({className:s,...e},t)=>i(Xs.Root,{ref:t,className:E("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",s),...e,children:i(Xs.Indicator,{className:E("flex items-center justify-center text-current"),children:i(vn,{className:"h-4 w-4"})})}));Bn.displayName="Checkbox";function Na(){const[s,e]=T([]),[t,n]=T(null),[r,a]=T(!0),[l,c]=T(null),[d,u]=T("all"),[h,m]=T(!0),f=as(null),[g,w]=T(0);z(()=>{p(),b();const N=setInterval(()=>{p(),b()},3e3);return()=>clearInterval(N)},[d]),z(()=>{h&&s.length>g&&f.current?.scrollIntoView({behavior:"smooth"}),w(s.length)},[s,h]);const p=async()=>{try{const N=d==="all"?"/api/logs?limit=100":`/api/logs?limit=100&level=${d}`,C=await be(N);if(!C.ok)throw new Error("API 请求失败");const S=await C.json();S.success&&Array.isArray(S.data)&&(e(S.data.reverse()),c(null))}catch(N){c(N.message)}finally{a(!1)}},b=async()=>{try{const N=await be("/api/logs/stats");if(!N.ok)return;const C=await N.json();C.success&&n(C.data)}catch(N){console.error("Failed to fetch stats:",N)}},k=async(N,C)=>{const S=N?`确定清理 ${N} 天前的日志吗?`:`确定只保留最近 ${C} 条日志吗?`;if(confirm(S))try{const y=await be("/api/logs/cleanup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({days:N,maxRecords:C})});if(!y.ok)throw new Error("清理失败");const O=await y.json();O.success&&(alert(`成功清理 ${O.data.deletedCount} 条日志`),p(),b())}catch(y){alert(y.message)}},x=N=>{switch(N){case"info":return{border:"border-l-blue-500",badge:"default",icon:i(jt,{className:"w-3 h-3"})};case"warn":return{border:"border-l-amber-500",badge:"warning",icon:i(Cn,{className:"w-3 h-3"})};case"error":return{border:"border-l-red-500",badge:"destructive",icon:i(Yr,{className:"w-3 h-3"})};default:return{border:"border-l-gray-500",badge:"secondary",icon:i(Jr,{className:"w-3 h-3"})}}};return r?o("div",{className:"space-y-4",children:[i(X,{className:"h-8 w-48"}),i("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[...Array(4)].map((N,C)=>i(X,{className:"h-20"},C))}),i(X,{className:"h-96"})]}):o("div",{className:"space-y-4",children:[o("div",{children:[i("h1",{className:"text-2xl font-bold tracking-tight",children:"系统日志"}),i("p",{className:"text-sm text-muted-foreground",children:"实时查看系统运行日志"})]}),t&&o("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[i(P,{children:o(M,{className:"flex flex-col items-center gap-1 p-4",children:[i("span",{className:"text-2xl font-bold",children:t.total}),i("span",{className:"text-xs text-muted-foreground",children:"总日志数"})]})}),i(P,{children:o(M,{className:"flex flex-col items-center gap-1 p-4",children:[i("span",{className:"text-2xl font-bold text-blue-600 dark:text-blue-400",children:t.byLevel.info||0}),i("span",{className:"text-xs text-muted-foreground",children:"Info"})]})}),i(P,{children:o(M,{className:"flex flex-col items-center gap-1 p-4",children:[i("span",{className:"text-2xl font-bold text-amber-600 dark:text-amber-400",children:t.byLevel.warn||0}),i("span",{className:"text-xs text-muted-foreground",children:"Warn"})]})}),i(P,{children:o(M,{className:"flex flex-col items-center gap-1 p-4",children:[i("span",{className:"text-2xl font-bold text-red-600 dark:text-red-400",children:t.byLevel.error||0}),i("span",{className:"text-xs text-muted-foreground",children:"Error"})]})})]}),i(P,{children:o(M,{className:"flex justify-between items-center p-3 flex-wrap gap-3",children:[o("div",{className:"flex items-center gap-3 flex-wrap",children:[o(Es,{value:d,onValueChange:u,children:[i(Dt,{className:"w-32",children:i(Is,{placeholder:"所有级别"})}),o(Rt,{children:[i(ke,{value:"all",children:"所有级别"}),i(ke,{value:"info",children:"Info"}),i(ke,{value:"warn",children:"Warn"}),i(ke,{value:"error",children:"Error"})]})]}),o("div",{className:"flex items-center gap-2",children:[i(Bn,{id:"auto-scroll",checked:h,onCheckedChange:N=>m(N)}),i("label",{htmlFor:"auto-scroll",className:"text-sm cursor-pointer",children:"自动滚动"})]})]}),o("div",{className:"flex gap-2",children:[o(A,{variant:"outline",size:"sm",onClick:()=>k(7),children:[i(Oe,{className:"w-3.5 h-3.5 mr-1"}),"清理7天前"]}),o(A,{variant:"outline",size:"sm",onClick:()=>k(void 0,5e3),children:[i(Oe,{className:"w-3.5 h-3.5 mr-1"}),"保留5000条"]}),o(A,{variant:"outline",size:"sm",onClick:()=>p(),children:[i(xe,{className:"w-3.5 h-3.5 mr-1"}),"刷新"]})]})]})}),i(P,{children:i(M,{className:"p-4",children:o("div",{className:"max-h-[600px] overflow-y-auto rounded-md bg-muted/30 p-2 space-y-1.5",children:[l?o(V,{variant:"destructive",children:[i(G,{className:"h-4 w-4"}),o(q,{children:["加载失败: ",l]})]}):s.length===0?o("div",{className:"flex flex-col items-center gap-3 py-12",children:[i(Ns,{className:"w-12 h-12 text-muted-foreground/30"}),i("span",{className:"text-sm text-muted-foreground",children:"暂无日志"})]}):s.map((N,C)=>{const S=x(N.level);return o("div",{className:E("p-3 rounded-md bg-background border-l-[3px]",S.border),children:[o("div",{className:"flex items-center gap-2 mb-1",children:[o(_,{variant:S.badge,className:"gap-1 text-[10px] px-1.5 py-0",children:[S.icon," ",N.level.toUpperCase()]}),i("span",{className:"text-[11px] text-muted-foreground",children:new Date(N.timestamp).toLocaleString()}),N.source&&i(_,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:N.source})]}),i("p",{className:"text-sm font-mono whitespace-pre-wrap break-words",children:N.message})]},`${N.timestamp}-${C}`)}),i("div",{ref:f})]})})})]})}const Ls=Symbol.for("yaml.alias"),cs=Symbol.for("yaml.document"),Ne=Symbol.for("yaml.map"),Fn=Symbol.for("yaml.pair"),he=Symbol.for("yaml.scalar"),ze=Symbol.for("yaml.seq"),ae=Symbol.for("yaml.node.type"),Ie=s=>!!s&&typeof s=="object"&&s[ae]===Ls,ct=s=>!!s&&typeof s=="object"&&s[ae]===cs,dt=s=>!!s&&typeof s=="object"&&s[ae]===Ne,U=s=>!!s&&typeof s=="object"&&s[ae]===Fn,R=s=>!!s&&typeof s=="object"&&s[ae]===he,ut=s=>!!s&&typeof s=="object"&&s[ae]===ze;function F(s){if(s&&typeof s=="object")switch(s[ae]){case Ne:case ze:return!0}return!1}function K(s){if(s&&typeof s=="object")switch(s[ae]){case Ls:case Ne:case he:case ze:return!0}return!1}const Kn=s=>(R(s)||F(s))&&!!s.anchor,ve=Symbol("break visit"),wa=Symbol("skip children"),et=Symbol("remove node");function Je(s,e){const t=xa(e);ct(s)?_e(null,s.contents,t,Object.freeze([s]))===et&&(s.contents=null):_e(null,s,t,Object.freeze([]))}Je.BREAK=ve;Je.SKIP=wa;Je.REMOVE=et;function _e(s,e,t,n){const r=va(s,e,t,n);if(K(r)||U(r))return ka(s,n,r),_e(s,r,t,n);if(typeof r!="symbol"){if(F(e)){n=Object.freeze(n.concat(e));for(let a=0;a<e.items.length;++a){const l=_e(a,e.items[a],t,n);if(typeof l=="number")a=l-1;else{if(l===ve)return ve;l===et&&(e.items.splice(a,1),a-=1)}}}else if(U(e)){n=Object.freeze(n.concat(e));const a=_e("key",e.key,t,n);if(a===ve)return ve;a===et&&(e.key=null);const l=_e("value",e.value,t,n);if(l===ve)return ve;l===et&&(e.value=null)}}return r}function xa(s){return typeof s=="object"&&(s.Collection||s.Node||s.Value)?Object.assign({Alias:s.Node,Map:s.Node,Scalar:s.Node,Seq:s.Node},s.Value&&{Map:s.Value,Scalar:s.Value,Seq:s.Value},s.Collection&&{Map:s.Collection,Seq:s.Collection},s):s}function va(s,e,t,n){if(typeof t=="function")return t(s,e,n);if(dt(e))return t.Map?.(s,e,n);if(ut(e))return t.Seq?.(s,e,n);if(U(e))return t.Pair?.(s,e,n);if(R(e))return t.Scalar?.(s,e,n);if(Ie(e))return t.Alias?.(s,e,n)}function ka(s,e,t){const n=e[e.length-1];if(F(n))n.items[s]=t;else if(U(n))s==="key"?n.key=t:n.value=t;else if(ct(n))n.contents=t;else{const r=Ie(n)?"alias":"scalar";throw new Error(`Cannot replace node with ${r} parent`)}}const Sa={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Ca=s=>s.replace(/[!,[\]{}]/g,e=>Sa[e]);class Q{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},Q.defaultYaml,e),this.tags=Object.assign({},Q.defaultTags,t)}clone(){const e=new Q(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){const e=new Q(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:Q.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},Q.defaultTags);break}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:Q.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},Q.defaultTags),this.atNextDocument=!1);const n=e.trim().split(/[ \t]+/),r=n.shift();switch(r){case"%TAG":{if(n.length!==2&&(t(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;const[a,l]=n;return this.tags[a]=l,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;const[a]=n;if(a==="1.1"||a==="1.2")return this.yaml.version=a,!0;{const l=/^\d+\.\d+$/.test(a);return t(6,`Unsupported YAML version ${a}`,l),!1}}default:return t(0,`Unknown directive ${r}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){const l=e.slice(2,-1);return l==="!"||l==="!!"?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&t("Verbatim tags must end with a >"),l)}const[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);const a=this.tags[n];if(a)try{return a+decodeURIComponent(r)}catch(l){return t(String(l)),null}return n==="!"?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(const[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+Ca(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){const t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags);let r;if(e&&n.length>0&&K(e.contents)){const a={};Je(e.contents,(l,c)=>{K(c)&&c.tag&&(a[c.tag]=!0)}),r=Object.keys(a)}else r=[];for(const[a,l]of n)a==="!!"&&l==="tag:yaml.org,2002:"||(!e||r.some(c=>c.startsWith(l)))&&t.push(`%TAG ${a} ${l}`);return t.join(`
8
+ `)}}Q.defaultYaml={explicit:!1,version:"1.2"};Q.defaultTags={"!!":"tag:yaml.org,2002:"};function Un(s){if(/[\x00-\x19\s,[\]{}]/.test(s)){const t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(s)}`;throw new Error(t)}return!0}function Vn(s){const e=new Set;return Je(s,{Value(t,n){n.anchor&&e.add(n.anchor)}}),e}function qn(s,e){for(let t=1;;++t){const n=`${s}${t}`;if(!e.has(n))return n}}function Ta(s,e){const t=[],n=new Map;let r=null;return{onAnchor:a=>{t.push(a),r??(r=Vn(s));const l=qn(e,r);return r.add(l),l},setAnchors:()=>{for(const a of t){const l=n.get(a);if(typeof l=="object"&&l.anchor&&(R(l.node)||F(l.node)))l.node.anchor=l.anchor;else{const c=new Error("Failed to resolve repeated object (this should not happen)");throw c.source=a,c}}},sourceObjects:n}}function Pe(s,e,t,n){if(n&&typeof n=="object")if(Array.isArray(n))for(let r=0,a=n.length;r<a;++r){const l=n[r],c=Pe(s,n,String(r),l);c===void 0?delete n[r]:c!==l&&(n[r]=c)}else if(n instanceof Map)for(const r of Array.from(n.keys())){const a=n.get(r),l=Pe(s,n,r,a);l===void 0?n.delete(r):l!==a&&n.set(r,l)}else if(n instanceof Set)for(const r of Array.from(n)){const a=Pe(s,n,r,r);a===void 0?n.delete(r):a!==r&&(n.delete(r),n.add(a))}else for(const[r,a]of Object.entries(n)){const l=Pe(s,n,r,a);l===void 0?delete n[r]:l!==a&&(n[r]=l)}return s.call(e,t,n)}function ie(s,e,t){if(Array.isArray(s))return s.map((n,r)=>ie(n,String(r),t));if(s&&typeof s.toJSON=="function"){if(!t||!Kn(s))return s.toJSON(e,t);const n={aliasCount:0,count:1,res:void 0};t.anchors.set(s,n),t.onCreate=a=>{n.res=a,delete t.onCreate};const r=s.toJSON(e,t);return t.onCreate&&t.onCreate(r),r}return typeof s=="bigint"&&!t?.keep?Number(s):s}class $s{constructor(e){Object.defineProperty(this,ae,{value:e})}clone(){const e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:a}={}){if(!ct(e))throw new TypeError("A document argument is required");const l={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},c=ie(this,"",l);if(typeof r=="function")for(const{count:d,res:u}of l.anchors.values())r(u,d);return typeof a=="function"?Pe(a,{"":c},"",c):c}}class js extends $s{constructor(e){super(Ls),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,t){let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],Je(e,{Node:(a,l)=>{(Ie(l)||Kn(l))&&n.push(l)}}),t&&(t.aliasResolveCache=n));let r;for(const a of n){if(a===this)break;a.anchor===this.source&&(r=a)}return r}toJSON(e,t){if(!t)return{source:this.source};const{anchors:n,doc:r,maxAliasCount:a}=t,l=this.resolve(r,t);if(!l){const d=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(d)}let c=n.get(l);if(c||(ie(l,null,t),c=n.get(l)),c?.res===void 0){const d="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(d)}if(a>=0&&(c.count+=1,c.aliasCount===0&&(c.aliasCount=xt(r,l,n)),c.count*c.aliasCount>a)){const d="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(d)}return c.res}toString(e,t,n){const r=`*${this.source}`;if(e){if(Un(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){const a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(a)}if(e.implicitKey)return`${r} `}return r}}function xt(s,e,t){if(Ie(e)){const n=e.resolve(s),r=t&&n&&t.get(n);return r?r.count*r.aliasCount:0}else if(F(e)){let n=0;for(const r of e.items){const a=xt(s,r,t);a>n&&(n=a)}return n}else if(U(e)){const n=xt(s,e.key,t),r=xt(s,e.value,t);return Math.max(n,r)}return 1}const zn=s=>!s||typeof s!="function"&&typeof s!="object";class L extends $s{constructor(e){super(he),this.value=e}toJSON(e,t){return t?.keep?this.value:ie(this.value,e,t)}toString(){return String(this.value)}}L.BLOCK_FOLDED="BLOCK_FOLDED";L.BLOCK_LITERAL="BLOCK_LITERAL";L.PLAIN="PLAIN";L.QUOTE_DOUBLE="QUOTE_DOUBLE";L.QUOTE_SINGLE="QUOTE_SINGLE";const Oa="tag:yaml.org,2002:";function Aa(s,e,t){if(e){const n=t.filter(a=>a.tag===e),r=n.find(a=>!a.format)??n[0];if(!r)throw new Error(`Tag ${e} not found`);return r}return t.find(n=>n.identify?.(s)&&!n.format)}function it(s,e,t){if(ct(s)&&(s=s.contents),K(s))return s;if(U(s)){const m=t.schema[Ne].createNode?.(t.schema,null,t);return m.items.push(s),m}(s instanceof String||s instanceof Number||s instanceof Boolean||typeof BigInt<"u"&&s instanceof BigInt)&&(s=s.valueOf());const{aliasDuplicateObjects:n,onAnchor:r,onTagObj:a,schema:l,sourceObjects:c}=t;let d;if(n&&s&&typeof s=="object"){if(d=c.get(s),d)return d.anchor??(d.anchor=r(s)),new js(d.anchor);d={anchor:null,node:null},c.set(s,d)}e?.startsWith("!!")&&(e=Oa+e.slice(2));let u=Aa(s,e,l.tags);if(!u){if(s&&typeof s.toJSON=="function"&&(s=s.toJSON()),!s||typeof s!="object"){const m=new L(s);return d&&(d.node=m),m}u=s instanceof Map?l[Ne]:Symbol.iterator in Object(s)?l[ze]:l[Ne]}a&&(a(u),delete t.onTagObj);const h=u?.createNode?u.createNode(t.schema,s,t):typeof u?.nodeClass?.from=="function"?u.nodeClass.from(t.schema,s,t):new L(s);return e?h.tag=e:u.default||(h.tag=u.tag),d&&(d.node=h),h}function Ot(s,e,t){let n=t;for(let r=e.length-1;r>=0;--r){const a=e[r];if(typeof a=="number"&&Number.isInteger(a)&&a>=0){const l=[];l[a]=n,n=l}else n=new Map([[a,n]])}return it(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:s,sourceObjects:new Map})}const He=s=>s==null||typeof s=="object"&&!!s[Symbol.iterator]().next().done;class Jn extends $s{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){const t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(n=>K(n)||U(n)?n.clone(e):n),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(He(e))this.add(t);else{const[n,...r]=e,a=this.get(n,!0);if(F(a))a.addIn(r,t);else if(a===void 0&&this.schema)this.set(n,Ot(this.schema,r,t));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){const[t,...n]=e;if(n.length===0)return this.delete(t);const r=this.get(t,!0);if(F(r))return r.deleteIn(n);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){const[n,...r]=e,a=this.get(n,!0);return r.length===0?!t&&R(a)?a.value:a:F(a)?a.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!U(t))return!1;const n=t.value;return n==null||e&&R(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){const[t,...n]=e;if(n.length===0)return this.has(t);const r=this.get(t,!0);return F(r)?r.hasIn(n):!1}setIn(e,t){const[n,...r]=e;if(r.length===0)this.set(n,t);else{const a=this.get(n,!0);if(F(a))a.setIn(r,t);else if(a===void 0&&this.schema)this.set(n,Ot(this.schema,r,t));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}}const Ea=s=>s.replace(/^(?!$)(?: $)?/gm,"#");function me(s,e){return/^\n+$/.test(s)?s.substring(1):e?s.replace(/^(?! *$)/gm,e):s}const Se=(s,e,t)=>s.endsWith(`
9
+ `)?me(t,e):t.includes(`
10
10
  `)?`
11
- `+ce(t,e):(s.endsWith(" ")?"":" ")+t,On="flow",zt="block",ot="quoted";function Ct(s,e,t="flow",{indentAtStart:n,lineWidth:r=80,minContentWidth:i=20,onFold:l,onOverflow:o}={}){if(!r||r<0)return s;r<i&&(i=0);const c=Math.max(1+i,1+r-e.length);if(s.length<=c)return s;const u=[],m={};let h=r-e.length;typeof n=="number"&&(n>r-Math.max(2,i)?u.push(0):h=r-n);let f,g,b=!1,p=-1,y=-1,k=-1;t===zt&&(p=Bs(s,p,e.length),p!==-1&&(h=p+c));for(let w;w=s[p+=1];){if(t===ot&&w==="\\"){switch(y=p,s[p+1]){case"x":p+=3;break;case"u":p+=5;break;case"U":p+=9;break;default:p+=1}k=p}if(w===`
12
- `)t===zt&&(p=Bs(s,p,e.length)),h=p+e.length+c,f=void 0;else{if(w===" "&&g&&g!==" "&&g!==`
13
- `&&g!==" "){const S=s[p+1];S&&S!==" "&&S!==`
14
- `&&S!==" "&&(f=p)}if(p>=h)if(f)u.push(f),h=f+c,f=void 0;else if(t===ot){for(;g===" "||g===" ";)g=w,w=s[p+=1],b=!0;const S=p>k+1?p-2:y-1;if(m[S])return s;u.push(S),m[S]=!0,h=S+c,f=void 0}else b=!0}g=w}if(b&&o&&o(),u.length===0)return s;l&&l();let O=s.slice(0,u[0]);for(let w=0;w<u.length;++w){const S=u[w],v=u[w+1]||s.length;S===0?O=`
15
- ${e}${s.slice(0,v)}`:(t===ot&&m[S]&&(O+=`${s[S]}\\`),O+=`
16
- ${e}${s.slice(S+1,v)}`)}return O}function Bs(s,e,t){let n=e,r=e+1,i=s[r];for(;i===" "||i===" ";)if(e<r+t)i=s[++e];else{do i=s[++e];while(i&&i!==`
17
- `);n=e,r=e+1,i=s[r]}return n}const Tt=(s,e)=>({indentAtStart:e?s.indent.length:s.indentAtStart,lineWidth:s.options.lineWidth,minContentWidth:s.options.minContentWidth}),At=s=>/^(%|---|\.\.\.)/m.test(s);function la(s,e,t){if(!e||e<0)return!1;const n=e-t,r=s.length;if(r<=n)return!1;for(let i=0,l=0;i<r;++i)if(s[i]===`
18
- `){if(i-l>n)return!0;if(l=i+1,r-l<=n)return!1}return!0}function Ue(s,e){const t=JSON.stringify(s);if(e.options.doubleQuotedAsJSON)return t;const{implicitKey:n}=e,r=e.options.doubleQuotedMinMultiLineLength,i=e.indent||(At(s)?" ":"");let l="",o=0;for(let c=0,u=t[c];u;u=t[++c])if(u===" "&&t[c+1]==="\\"&&t[c+2]==="n"&&(l+=t.slice(o,c)+"\\ ",c+=1,o=c,u="\\"),u==="\\")switch(t[c+1]){case"u":{l+=t.slice(o,c);const m=t.substr(c+2,4);switch(m){case"0000":l+="\\0";break;case"0007":l+="\\a";break;case"000b":l+="\\v";break;case"001b":l+="\\e";break;case"0085":l+="\\N";break;case"00a0":l+="\\_";break;case"2028":l+="\\L";break;case"2029":l+="\\P";break;default:m.substr(0,2)==="00"?l+="\\x"+m.substr(2):l+=t.substr(c,6)}c+=5,o=c+1}break;case"n":if(n||t[c+2]==='"'||t.length<r)c+=1;else{for(l+=t.slice(o,c)+`
11
+ `+me(t,e):(s.endsWith(" ")?"":" ")+t,Yn="flow",ds="block",vt="quoted";function Bt(s,e,t="flow",{indentAtStart:n,lineWidth:r=80,minContentWidth:a=20,onFold:l,onOverflow:c}={}){if(!r||r<0)return s;r<a&&(a=0);const d=Math.max(1+a,1+r-e.length);if(s.length<=d)return s;const u=[],h={};let m=r-e.length;typeof n=="number"&&(n>r-Math.max(2,a)?u.push(0):m=r-n);let f,g,w=!1,p=-1,b=-1,k=-1;t===ds&&(p=nn(s,p,e.length),p!==-1&&(m=p+d));for(let N;N=s[p+=1];){if(t===vt&&N==="\\"){switch(b=p,s[p+1]){case"x":p+=3;break;case"u":p+=5;break;case"U":p+=9;break;default:p+=1}k=p}if(N===`
12
+ `)t===ds&&(p=nn(s,p,e.length)),m=p+e.length+d,f=void 0;else{if(N===" "&&g&&g!==" "&&g!==`
13
+ `&&g!==" "){const C=s[p+1];C&&C!==" "&&C!==`
14
+ `&&C!==" "&&(f=p)}if(p>=m)if(f)u.push(f),m=f+d,f=void 0;else if(t===vt){for(;g===" "||g===" ";)g=N,N=s[p+=1],w=!0;const C=p>k+1?p-2:b-1;if(h[C])return s;u.push(C),h[C]=!0,m=C+d,f=void 0}else w=!0}g=N}if(w&&c&&c(),u.length===0)return s;l&&l();let x=s.slice(0,u[0]);for(let N=0;N<u.length;++N){const C=u[N],S=u[N+1]||s.length;C===0?x=`
15
+ ${e}${s.slice(0,S)}`:(t===vt&&h[C]&&(x+=`${s[C]}\\`),x+=`
16
+ ${e}${s.slice(C+1,S)}`)}return x}function nn(s,e,t){let n=e,r=e+1,a=s[r];for(;a===" "||a===" ";)if(e<r+t)a=s[++e];else{do a=s[++e];while(a&&a!==`
17
+ `);n=e,r=e+1,a=s[r]}return n}const Ft=(s,e)=>({indentAtStart:e?s.indent.length:s.indentAtStart,lineWidth:s.options.lineWidth,minContentWidth:s.options.minContentWidth}),Kt=s=>/^(%|---|\.\.\.)/m.test(s);function Ia(s,e,t){if(!e||e<0)return!1;const n=e-t,r=s.length;if(r<=n)return!1;for(let a=0,l=0;a<r;++a)if(s[a]===`
18
+ `){if(a-l>n)return!0;if(l=a+1,r-l<=n)return!1}return!0}function tt(s,e){const t=JSON.stringify(s);if(e.options.doubleQuotedAsJSON)return t;const{implicitKey:n}=e,r=e.options.doubleQuotedMinMultiLineLength,a=e.indent||(Kt(s)?" ":"");let l="",c=0;for(let d=0,u=t[d];u;u=t[++d])if(u===" "&&t[d+1]==="\\"&&t[d+2]==="n"&&(l+=t.slice(c,d)+"\\ ",d+=1,c=d,u="\\"),u==="\\")switch(t[d+1]){case"u":{l+=t.slice(c,d);const h=t.substr(d+2,4);switch(h){case"0000":l+="\\0";break;case"0007":l+="\\a";break;case"000b":l+="\\v";break;case"001b":l+="\\e";break;case"0085":l+="\\N";break;case"00a0":l+="\\_";break;case"2028":l+="\\L";break;case"2029":l+="\\P";break;default:h.substr(0,2)==="00"?l+="\\x"+h.substr(2):l+=t.substr(d,6)}d+=5,c=d+1}break;case"n":if(n||t[d+2]==='"'||t.length<r)d+=1;else{for(l+=t.slice(c,d)+`
19
19
 
20
- `;t[c+2]==="\\"&&t[c+3]==="n"&&t[c+4]!=='"';)l+=`
21
- `,c+=2;l+=i,t[c+2]===" "&&(l+="\\"),c+=1,o=c+1}break;default:c+=1}return l=o?l+t.slice(o):t,n?l:Ct(l,i,ot,Tt(e,!1))}function Yt(s,e){if(e.options.singleQuote===!1||e.implicitKey&&s.includes(`
22
- `)||/[ \t]\n|\n[ \t]/.test(s))return Ue(s,e);const t=e.indent||(At(s)?" ":""),n="'"+s.replace(/'/g,"''").replace(/\n+/g,`$&
23
- ${t}`)+"'";return e.implicitKey?n:Ct(n,t,On,Tt(e,!1))}function Oe(s,e){const{singleQuote:t}=e.options;let n;if(t===!1)n=Ue;else{const r=s.includes('"'),i=s.includes("'");r&&!i?n=Yt:i&&!r?n=Ue:n=t?Yt:Ue}return n(s,e)}let Wt;try{Wt=new RegExp(`(^|(?<!
20
+ `;t[d+2]==="\\"&&t[d+3]==="n"&&t[d+4]!=='"';)l+=`
21
+ `,d+=2;l+=a,t[d+2]===" "&&(l+="\\"),d+=1,c=d+1}break;default:d+=1}return l=c?l+t.slice(c):t,n?l:Bt(l,a,vt,Ft(e,!1))}function us(s,e){if(e.options.singleQuote===!1||e.implicitKey&&s.includes(`
22
+ `)||/[ \t]\n|\n[ \t]/.test(s))return tt(s,e);const t=e.indent||(Kt(s)?" ":""),n="'"+s.replace(/'/g,"''").replace(/\n+/g,`$&
23
+ ${t}`)+"'";return e.implicitKey?n:Bt(n,t,Yn,Ft(e,!1))}function Me(s,e){const{singleQuote:t}=e.options;let n;if(t===!1)n=tt;else{const r=s.includes('"'),a=s.includes("'");r&&!a?n=us:a&&!r?n=tt:n=t?us:tt}return n(s,e)}let fs;try{fs=new RegExp(`(^|(?<!
24
24
  ))
25
25
  +(?!
26
- |$)`,"g")}catch{Wt=/\n+(?!\n|$)/g}function ct({comment:s,type:e,value:t},n,r,i){const{blockQuote:l,commentString:o,lineWidth:c}=n.options;if(!l||/\n[\t ]+$/.test(t))return Oe(t,n);const u=n.indent||(n.forceBlockIndent||At(t)?" ":""),m=l==="literal"?!0:l==="folded"||e===A.BLOCK_FOLDED?!1:e===A.BLOCK_LITERAL?!0:!la(t,c,u.length);if(!t)return m?`|
26
+ |$)`,"g")}catch{fs=/\n+(?!\n|$)/g}function kt({comment:s,type:e,value:t},n,r,a){const{blockQuote:l,commentString:c,lineWidth:d}=n.options;if(!l||/\n[\t ]+$/.test(t))return Me(t,n);const u=n.indent||(n.forceBlockIndent||Kt(t)?" ":""),h=l==="literal"?!0:l==="folded"||e===L.BLOCK_FOLDED?!1:e===L.BLOCK_LITERAL?!0:!Ia(t,d,u.length);if(!t)return h?`|
27
27
  `:`>
28
- `;let h,f;for(f=t.length;f>0;--f){const v=t[f-1];if(v!==`
29
- `&&v!==" "&&v!==" ")break}let g=t.substring(f);const b=g.indexOf(`
30
- `);b===-1?h="-":t===g||b!==g.length-1?(h="+",i&&i()):h="",g&&(t=t.slice(0,-g.length),g[g.length-1]===`
31
- `&&(g=g.slice(0,-1)),g=g.replace(Wt,`$&${u}`));let p=!1,y,k=-1;for(y=0;y<t.length;++y){const v=t[y];if(v===" ")p=!0;else if(v===`
32
- `)k=y;else break}let O=t.substring(0,k<y?k+1:y);O&&(t=t.substring(O.length),O=O.replace(/\n+/g,`$&${u}`));let S=(p?u?"2":"1":"")+h;if(s&&(S+=" "+o(s.replace(/ ?[\r\n]+/g," ")),r&&r()),!m){const v=t.replace(/\n+/g,`
33
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${u}`);let N=!1;const C=Tt(n,!0);l!=="folded"&&e!==A.BLOCK_FOLDED&&(C.onOverflow=()=>{N=!0});const x=Ct(`${O}${v}${g}`,u,zt,C);if(!N)return`>${S}
34
- ${u}${x}`}return t=t.replace(/\n+/g,`$&${u}`),`|${S}
35
- ${u}${O}${t}${g}`}function oa(s,e,t,n){const{type:r,value:i}=s,{actualString:l,implicitKey:o,indent:c,indentStep:u,inFlow:m}=e;if(o&&i.includes(`
36
- `)||m&&/[[\]{},]/.test(i))return Oe(i,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return o||m||!i.includes(`
37
- `)?Oe(i,e):ct(s,e,t,n);if(!o&&!m&&r!==A.PLAIN&&i.includes(`
38
- `))return ct(s,e,t,n);if(At(i)){if(c==="")return e.forceBlockIndent=!0,ct(s,e,t,n);if(o&&c===u)return Oe(i,e)}const h=i.replace(/\n+/g,`$&
39
- ${c}`);if(l){const f=p=>p.default&&p.tag!=="tag:yaml.org,2002:str"&&p.test?.test(h),{compat:g,tags:b}=e.doc.schema;if(b.some(f)||g?.some(f))return Oe(i,e)}return o?h:Ct(h,c,On,Tt(e,!1))}function bs(s,e,t,n){const{implicitKey:r,inFlow:i}=e,l=typeof s.value=="string"?s:Object.assign({},s,{value:String(s.value)});let{type:o}=s;o!==A.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(l.value)&&(o=A.QUOTE_DOUBLE);const c=m=>{switch(m){case A.BLOCK_FOLDED:case A.BLOCK_LITERAL:return r||i?Oe(l.value,e):ct(l,e,t,n);case A.QUOTE_DOUBLE:return Ue(l.value,e);case A.QUOTE_SINGLE:return Yt(l.value,e);case A.PLAIN:return oa(l,e,t,n);default:return null}};let u=c(o);if(u===null){const{defaultKeyType:m,defaultStringType:h}=e.options,f=r&&m||h;if(u=c(f),u===null)throw new Error(`Unsupported default string type ${f}`)}return u}function Cn(s,e){const t=Object.assign({blockQuote:!0,commentString:aa,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},s.schema.toStringOptions,e);let n;switch(t.collectionStyle){case"block":n=!1;break;case"flow":n=!0;break;default:n=null}return{anchors:new Set,doc:s,flowCollectionPadding:t.flowCollectionPadding?" ":"",indent:"",indentStep:typeof t.indent=="number"?" ".repeat(t.indent):" ",inFlow:n,options:t}}function ca(s,e){if(e.tag){const r=s.filter(i=>i.tag===e.tag);if(r.length>0)return r.find(i=>i.format===e.format)??r[0]}let t,n;if(j(e)){n=e.value;let r=s.filter(i=>i.identify?.(n));if(r.length>1){const i=r.filter(l=>l.test);i.length>0&&(r=i)}t=r.find(i=>i.format===e.format)??r.find(i=>!i.format)}else n=e,t=s.find(r=>r.nodeClass&&n instanceof r.nodeClass);if(!t){const r=n?.constructor?.name??(n===null?"null":typeof n);throw new Error(`Tag not resolved for ${r} value`)}return t}function da(s,e,{anchors:t,doc:n}){if(!n.directives)return"";const r=[],i=(j(s)||B(s))&&s.anchor;i&&wn(i)&&(t.add(i),r.push(`&${i}`));const l=s.tag??(e.default?null:e.tag);return l&&r.push(n.directives.tagString(l)),r.join(" ")}function Ee(s,e,t,n){if(F(s))return s.toString(e,t,n);if(we(s)){if(e.doc.directives)return s.toString(e);if(e.resolvedAliases?.has(s))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(s):e.resolvedAliases=new Set([s]),s=s.resolve(e.doc)}let r;const i=D(s)?s:e.doc.createNode(s,{onTagObj:c=>r=c});r??(r=ca(e.doc.schema.tags,i));const l=da(i,r,e);l.length>0&&(e.indentAtStart=(e.indentAtStart??0)+l.length+1);const o=typeof r.stringify=="function"?r.stringify(i,e,t,n):j(i)?bs(i,e,t,n):i.toString(e,t,n);return l?j(i)||o[0]==="{"||o[0]==="["?`${l} ${o}`:`${l}
40
- ${e.indent}${o}`:o}function ua({key:s,value:e},t,n,r){const{allNullValues:i,doc:l,indent:o,indentStep:c,options:{commentString:u,indentSeq:m,simpleKeys:h}}=t;let f=D(s)&&s.comment||null;if(h){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(B(s)||!D(s)&&typeof s=="object"){const C="With simple keys, collection cannot be used as a key value";throw new Error(C)}}let g=!h&&(!s||f&&e==null&&!t.inFlow||B(s)||(j(s)?s.type===A.BLOCK_FOLDED||s.type===A.BLOCK_LITERAL:typeof s=="object"));t=Object.assign({},t,{allNullValues:!1,implicitKey:!g&&(h||!i),indent:o+c});let b=!1,p=!1,y=Ee(s,t,()=>b=!0,()=>p=!0);if(!g&&!t.inFlow&&y.length>1024){if(h)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");g=!0}if(t.inFlow){if(i||e==null)return b&&n&&n(),y===""?"?":g?`? ${y}`:y}else if(i&&!h||e==null&&g)return y=`? ${y}`,f&&!b?y+=ge(y,t.indent,u(f)):p&&r&&r(),y;b&&(f=null),g?(f&&(y+=ge(y,t.indent,u(f))),y=`? ${y}
41
- ${o}:`):(y=`${y}:`,f&&(y+=ge(y,t.indent,u(f))));let k,O,w;D(e)?(k=!!e.spaceBefore,O=e.commentBefore,w=e.comment):(k=!1,O=null,w=null,e&&typeof e=="object"&&(e=l.createNode(e))),t.implicitKey=!1,!g&&!f&&j(e)&&(t.indentAtStart=y.length+1),p=!1,!m&&c.length>=2&&!t.inFlow&&!g&&Qe(e)&&!e.flow&&!e.tag&&!e.anchor&&(t.indent=t.indent.substring(2));let S=!1;const v=Ee(e,t,()=>S=!0,()=>p=!0);let N=" ";if(f||k||O){if(N=k?`
42
- `:"",O){const C=u(O);N+=`
43
- ${ce(C,t.indent)}`}v===""&&!t.inFlow?N===`
44
- `&&w&&(N=`
28
+ `;let m,f;for(f=t.length;f>0;--f){const S=t[f-1];if(S!==`
29
+ `&&S!==" "&&S!==" ")break}let g=t.substring(f);const w=g.indexOf(`
30
+ `);w===-1?m="-":t===g||w!==g.length-1?(m="+",a&&a()):m="",g&&(t=t.slice(0,-g.length),g[g.length-1]===`
31
+ `&&(g=g.slice(0,-1)),g=g.replace(fs,`$&${u}`));let p=!1,b,k=-1;for(b=0;b<t.length;++b){const S=t[b];if(S===" ")p=!0;else if(S===`
32
+ `)k=b;else break}let x=t.substring(0,k<b?k+1:b);x&&(t=t.substring(x.length),x=x.replace(/\n+/g,`$&${u}`));let C=(p?u?"2":"1":"")+m;if(s&&(C+=" "+c(s.replace(/ ?[\r\n]+/g," ")),r&&r()),!h){const S=t.replace(/\n+/g,`
33
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${u}`);let y=!1;const O=Ft(n,!0);l!=="folded"&&e!==L.BLOCK_FOLDED&&(O.onOverflow=()=>{y=!0});const v=Bt(`${x}${S}${g}`,u,ds,O);if(!y)return`>${C}
34
+ ${u}${v}`}return t=t.replace(/\n+/g,`$&${u}`),`|${C}
35
+ ${u}${x}${t}${g}`}function La(s,e,t,n){const{type:r,value:a}=s,{actualString:l,implicitKey:c,indent:d,indentStep:u,inFlow:h}=e;if(c&&a.includes(`
36
+ `)||h&&/[[\]{},]/.test(a))return Me(a,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return c||h||!a.includes(`
37
+ `)?Me(a,e):kt(s,e,t,n);if(!c&&!h&&r!==L.PLAIN&&a.includes(`
38
+ `))return kt(s,e,t,n);if(Kt(a)){if(d==="")return e.forceBlockIndent=!0,kt(s,e,t,n);if(c&&d===u)return Me(a,e)}const m=a.replace(/\n+/g,`$&
39
+ ${d}`);if(l){const f=p=>p.default&&p.tag!=="tag:yaml.org,2002:str"&&p.test?.test(m),{compat:g,tags:w}=e.doc.schema;if(w.some(f)||g?.some(f))return Me(a,e)}return c?m:Bt(m,d,Yn,Ft(e,!1))}function _s(s,e,t,n){const{implicitKey:r,inFlow:a}=e,l=typeof s.value=="string"?s:Object.assign({},s,{value:String(s.value)});let{type:c}=s;c!==L.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(l.value)&&(c=L.QUOTE_DOUBLE);const d=h=>{switch(h){case L.BLOCK_FOLDED:case L.BLOCK_LITERAL:return r||a?Me(l.value,e):kt(l,e,t,n);case L.QUOTE_DOUBLE:return tt(l.value,e);case L.QUOTE_SINGLE:return us(l.value,e);case L.PLAIN:return La(l,e,t,n);default:return null}};let u=d(c);if(u===null){const{defaultKeyType:h,defaultStringType:m}=e.options,f=r&&h||m;if(u=d(f),u===null)throw new Error(`Unsupported default string type ${f}`)}return u}function Wn(s,e){const t=Object.assign({blockQuote:!0,commentString:Ea,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},s.schema.toStringOptions,e);let n;switch(t.collectionStyle){case"block":n=!1;break;case"flow":n=!0;break;default:n=null}return{anchors:new Set,doc:s,flowCollectionPadding:t.flowCollectionPadding?" ":"",indent:"",indentStep:typeof t.indent=="number"?" ".repeat(t.indent):" ",inFlow:n,options:t}}function $a(s,e){if(e.tag){const r=s.filter(a=>a.tag===e.tag);if(r.length>0)return r.find(a=>a.format===e.format)??r[0]}let t,n;if(R(e)){n=e.value;let r=s.filter(a=>a.identify?.(n));if(r.length>1){const a=r.filter(l=>l.test);a.length>0&&(r=a)}t=r.find(a=>a.format===e.format)??r.find(a=>!a.format)}else n=e,t=s.find(r=>r.nodeClass&&n instanceof r.nodeClass);if(!t){const r=n?.constructor?.name??(n===null?"null":typeof n);throw new Error(`Tag not resolved for ${r} value`)}return t}function ja(s,e,{anchors:t,doc:n}){if(!n.directives)return"";const r=[],a=(R(s)||F(s))&&s.anchor;a&&Un(a)&&(t.add(a),r.push(`&${a}`));const l=s.tag??(e.default?null:e.tag);return l&&r.push(n.directives.tagString(l)),r.join(" ")}function Ue(s,e,t,n){if(U(s))return s.toString(e,t,n);if(Ie(s)){if(e.doc.directives)return s.toString(e);if(e.resolvedAliases?.has(s))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(s):e.resolvedAliases=new Set([s]),s=s.resolve(e.doc)}let r;const a=K(s)?s:e.doc.createNode(s,{onTagObj:d=>r=d});r??(r=$a(e.doc.schema.tags,a));const l=ja(a,r,e);l.length>0&&(e.indentAtStart=(e.indentAtStart??0)+l.length+1);const c=typeof r.stringify=="function"?r.stringify(a,e,t,n):R(a)?_s(a,e,t,n):a.toString(e,t,n);return l?R(a)||c[0]==="{"||c[0]==="["?`${l} ${c}`:`${l}
40
+ ${e.indent}${c}`:c}function _a({key:s,value:e},t,n,r){const{allNullValues:a,doc:l,indent:c,indentStep:d,options:{commentString:u,indentSeq:h,simpleKeys:m}}=t;let f=K(s)&&s.comment||null;if(m){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(F(s)||!K(s)&&typeof s=="object"){const O="With simple keys, collection cannot be used as a key value";throw new Error(O)}}let g=!m&&(!s||f&&e==null&&!t.inFlow||F(s)||(R(s)?s.type===L.BLOCK_FOLDED||s.type===L.BLOCK_LITERAL:typeof s=="object"));t=Object.assign({},t,{allNullValues:!1,implicitKey:!g&&(m||!a),indent:c+d});let w=!1,p=!1,b=Ue(s,t,()=>w=!0,()=>p=!0);if(!g&&!t.inFlow&&b.length>1024){if(m)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");g=!0}if(t.inFlow){if(a||e==null)return w&&n&&n(),b===""?"?":g?`? ${b}`:b}else if(a&&!m||e==null&&g)return b=`? ${b}`,f&&!w?b+=Se(b,t.indent,u(f)):p&&r&&r(),b;w&&(f=null),g?(f&&(b+=Se(b,t.indent,u(f))),b=`? ${b}
41
+ ${c}:`):(b=`${b}:`,f&&(b+=Se(b,t.indent,u(f))));let k,x,N;K(e)?(k=!!e.spaceBefore,x=e.commentBefore,N=e.comment):(k=!1,x=null,N=null,e&&typeof e=="object"&&(e=l.createNode(e))),t.implicitKey=!1,!g&&!f&&R(e)&&(t.indentAtStart=b.length+1),p=!1,!h&&d.length>=2&&!t.inFlow&&!g&&ut(e)&&!e.flow&&!e.tag&&!e.anchor&&(t.indent=t.indent.substring(2));let C=!1;const S=Ue(e,t,()=>C=!0,()=>p=!0);let y=" ";if(f||k||x){if(y=k?`
42
+ `:"",x){const O=u(x);y+=`
43
+ ${me(O,t.indent)}`}S===""&&!t.inFlow?y===`
44
+ `&&N&&(y=`
45
45
 
46
- `):N+=`
47
- ${t.indent}`}else if(!g&&B(e)){const C=v[0],x=v.indexOf(`
48
- `),$=x!==-1,H=t.inFlow??e.flow??e.items.length===0;if($||!H){let Q=!1;if($&&(C==="&"||C==="!")){let R=v.indexOf(" ");C==="&"&&R!==-1&&R<x&&v[R+1]==="!"&&(R=v.indexOf(" ",R+1)),(R===-1||x<R)&&(Q=!0)}Q||(N=`
49
- ${t.indent}`)}}else(v===""||v[0]===`
50
- `)&&(N="");return y+=N+v,t.inFlow?S&&n&&n():w&&!S?y+=ge(y,t.indent,u(w)):p&&r&&r(),y}function Tn(s,e){(s==="debug"||s==="warn")&&console.warn(e)}const st="<<",de={identify:s=>s===st||typeof s=="symbol"&&s.description===st,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new A(Symbol(st)),{addToJSMap:An}),stringify:()=>st},fa=(s,e)=>(de.identify(e)||j(e)&&(!e.type||e.type===A.PLAIN)&&de.identify(e.value))&&s?.doc.schema.tags.some(t=>t.tag===de.tag&&t.default);function An(s,e,t){if(t=s&&we(t)?t.resolve(s.doc):t,Qe(t))for(const n of t.items)Rt(s,e,n);else if(Array.isArray(t))for(const n of t)Rt(s,e,n);else Rt(s,e,t)}function Rt(s,e,t){const n=s&&we(t)?t.resolve(s.doc):t;if(!He(n))throw new Error("Merge sources must be maps or map aliases");const r=n.toJSON(null,s,Map);for(const[i,l]of r)e instanceof Map?e.has(i)||e.set(i,l):e instanceof Set?e.add(i):Object.prototype.hasOwnProperty.call(e,i)||Object.defineProperty(e,i,{value:l,writable:!0,enumerable:!0,configurable:!0});return e}function In(s,e,{key:t,value:n}){if(D(t)&&t.addToJSMap)t.addToJSMap(s,e,n);else if(fa(s,t))An(s,e,n);else{const r=Z(t,"",s);if(e instanceof Map)e.set(r,Z(n,r,s));else if(e instanceof Set)e.add(r);else{const i=ha(t,r,s),l=Z(n,i,s);i in e?Object.defineProperty(e,i,{value:l,writable:!0,enumerable:!0,configurable:!0}):e[i]=l}}return e}function ha(s,e,t){if(e===null)return"";if(typeof e!="object")return String(e);if(D(s)&&t?.doc){const n=Cn(t.doc,{});n.anchors=new Set;for(const i of t.anchors.keys())n.anchors.add(i.anchor);n.inFlow=!0,n.inStringifyKey=!0;const r=s.toString(n);if(!t.mapKeyWarned){let i=JSON.stringify(r);i.length>40&&(i=i.substring(0,36)+'..."'),Tn(t.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${i}. Set mapAsMap: true to use object keys.`),t.mapKeyWarned=!0}return r}return JSON.stringify(e)}function Ns(s,e,t){const n=ze(s,void 0,t),r=ze(e,void 0,t);return new q(n,r)}class q{constructor(e,t=null){Object.defineProperty(this,ee,{value:bn}),this.key=e,this.value=t}clone(e){let{key:t,value:n}=this;return D(t)&&(t=t.clone(e)),D(n)&&(n=n.clone(e)),new q(t,n)}toJSON(e,t){const n=t?.mapAsMap?new Map:{};return In(t,n,this)}toString(e,t,n){return e?.doc?ua(this,e,t,n):JSON.stringify(this)}}function En(s,e,t){return(e.inFlow??s.flow?pa:ma)(s,e,t)}function ma({comment:s,items:e},t,{blockItemPrefix:n,flowChars:r,itemIndent:i,onChompKeep:l,onComment:o}){const{indent:c,options:{commentString:u}}=t,m=Object.assign({},t,{indent:i,type:null});let h=!1;const f=[];for(let b=0;b<e.length;++b){const p=e[b];let y=null;if(D(p))!h&&p.spaceBefore&&f.push(""),pt(t,f,p.commentBefore,h),p.comment&&(y=p.comment);else if(F(p)){const O=D(p.key)?p.key:null;O&&(!h&&O.spaceBefore&&f.push(""),pt(t,f,O.commentBefore,h))}h=!1;let k=Ee(p,m,()=>y=null,()=>h=!0);y&&(k+=ge(k,i,u(y))),h&&y&&(h=!1),f.push(n+k)}let g;if(f.length===0)g=r.start+r.end;else{g=f[0];for(let b=1;b<f.length;++b){const p=f[b];g+=p?`
51
- ${c}${p}`:`
46
+ `):y+=`
47
+ ${t.indent}`}else if(!g&&F(e)){const O=S[0],v=S.indexOf(`
48
+ `),j=v!==-1,H=t.inFlow??e.flow??e.items.length===0;if(j||!H){let W=!1;if(j&&(O==="&"||O==="!")){let D=S.indexOf(" ");O==="&"&&D!==-1&&D<v&&S[D+1]==="!"&&(D=S.indexOf(" ",D+1)),(D===-1||v<D)&&(W=!0)}W||(y=`
49
+ ${t.indent}`)}}else(S===""||S[0]===`
50
+ `)&&(y="");return b+=y+S,t.inFlow?C&&n&&n():N&&!C?b+=Se(b,t.indent,u(N)):p&&r&&r(),b}function Gn(s,e){(s==="debug"||s==="warn")&&console.warn(e)}const gt="<<",pe={identify:s=>s===gt||typeof s=="symbol"&&s.description===gt,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new L(Symbol(gt)),{addToJSMap:Hn}),stringify:()=>gt},Pa=(s,e)=>(pe.identify(e)||R(e)&&(!e.type||e.type===L.PLAIN)&&pe.identify(e.value))&&s?.doc.schema.tags.some(t=>t.tag===pe.tag&&t.default);function Hn(s,e,t){if(t=s&&Ie(t)?t.resolve(s.doc):t,ut(t))for(const n of t.items)es(s,e,n);else if(Array.isArray(t))for(const n of t)es(s,e,n);else es(s,e,t)}function es(s,e,t){const n=s&&Ie(t)?t.resolve(s.doc):t;if(!dt(n))throw new Error("Merge sources must be maps or map aliases");const r=n.toJSON(null,s,Map);for(const[a,l]of r)e instanceof Map?e.has(a)||e.set(a,l):e instanceof Set?e.add(a):Object.prototype.hasOwnProperty.call(e,a)||Object.defineProperty(e,a,{value:l,writable:!0,enumerable:!0,configurable:!0});return e}function Qn(s,e,{key:t,value:n}){if(K(t)&&t.addToJSMap)t.addToJSMap(s,e,n);else if(Pa(s,t))Hn(s,e,n);else{const r=ie(t,"",s);if(e instanceof Map)e.set(r,ie(n,r,s));else if(e instanceof Set)e.add(r);else{const a=Ma(t,r,s),l=ie(n,a,s);a in e?Object.defineProperty(e,a,{value:l,writable:!0,enumerable:!0,configurable:!0}):e[a]=l}}return e}function Ma(s,e,t){if(e===null)return"";if(typeof e!="object")return String(e);if(K(s)&&t?.doc){const n=Wn(t.doc,{});n.anchors=new Set;for(const a of t.anchors.keys())n.anchors.add(a.anchor);n.inFlow=!0,n.inStringifyKey=!0;const r=s.toString(n);if(!t.mapKeyWarned){let a=JSON.stringify(r);a.length>40&&(a=a.substring(0,36)+'..."'),Gn(t.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${a}. Set mapAsMap: true to use object keys.`),t.mapKeyWarned=!0}return r}return JSON.stringify(e)}function Ps(s,e,t){const n=it(s,void 0,t),r=it(e,void 0,t);return new Z(n,r)}class Z{constructor(e,t=null){Object.defineProperty(this,ae,{value:Fn}),this.key=e,this.value=t}clone(e){let{key:t,value:n}=this;return K(t)&&(t=t.clone(e)),K(n)&&(n=n.clone(e)),new Z(t,n)}toJSON(e,t){const n=t?.mapAsMap?new Map:{};return Qn(t,n,this)}toString(e,t,n){return e?.doc?_a(this,e,t,n):JSON.stringify(this)}}function Xn(s,e,t){return(e.inFlow??s.flow?Ra:Da)(s,e,t)}function Da({comment:s,items:e},t,{blockItemPrefix:n,flowChars:r,itemIndent:a,onChompKeep:l,onComment:c}){const{indent:d,options:{commentString:u}}=t,h=Object.assign({},t,{indent:a,type:null});let m=!1;const f=[];for(let w=0;w<e.length;++w){const p=e[w];let b=null;if(K(p))!m&&p.spaceBefore&&f.push(""),At(t,f,p.commentBefore,m),p.comment&&(b=p.comment);else if(U(p)){const x=K(p.key)?p.key:null;x&&(!m&&x.spaceBefore&&f.push(""),At(t,f,x.commentBefore,m))}m=!1;let k=Ue(p,h,()=>b=null,()=>m=!0);b&&(k+=Se(k,a,u(b))),m&&b&&(m=!1),f.push(n+k)}let g;if(f.length===0)g=r.start+r.end;else{g=f[0];for(let w=1;w<f.length;++w){const p=f[w];g+=p?`
51
+ ${d}${p}`:`
52
52
  `}}return s?(g+=`
53
- `+ce(u(s),c),o&&o()):h&&l&&l(),g}function pa({items:s},e,{flowChars:t,itemIndent:n}){const{indent:r,indentStep:i,flowCollectionPadding:l,options:{commentString:o}}=e;n+=i;const c=Object.assign({},e,{indent:n,inFlow:!0,type:null});let u=!1,m=0;const h=[];for(let b=0;b<s.length;++b){const p=s[b];let y=null;if(D(p))p.spaceBefore&&h.push(""),pt(e,h,p.commentBefore,!1),p.comment&&(y=p.comment);else if(F(p)){const O=D(p.key)?p.key:null;O&&(O.spaceBefore&&h.push(""),pt(e,h,O.commentBefore,!1),O.comment&&(u=!0));const w=D(p.value)?p.value:null;w?(w.comment&&(y=w.comment),w.commentBefore&&(u=!0)):p.value==null&&O?.comment&&(y=O.comment)}y&&(u=!0);let k=Ee(p,c,()=>y=null);b<s.length-1&&(k+=","),y&&(k+=ge(k,n,o(y))),!u&&(h.length>m||k.includes(`
54
- `))&&(u=!0),h.push(k),m=h.length}const{start:f,end:g}=t;if(h.length===0)return f+g;if(!u){const b=h.reduce((p,y)=>p+y.length+2,2);u=e.options.lineWidth>0&&b>e.options.lineWidth}if(u){let b=f;for(const p of h)b+=p?`
55
- ${i}${r}${p}`:`
56
- `;return`${b}
57
- ${r}${g}`}else return`${f}${l}${h.join(" ")}${l}${g}`}function pt({indent:s,options:{commentString:e}},t,n,r){if(n&&r&&(n=n.replace(/^\n+/,"")),n){const i=ce(e(n),s);t.push(i.trimStart())}}function ye(s,e){const t=j(e)?e.value:e;for(const n of s)if(F(n)&&(n.key===e||n.key===t||j(n.key)&&n.key.value===t))return n}class X extends Sn{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(he,e),this.items=[]}static from(e,t,n){const{keepUndefined:r,replacer:i}=n,l=new this(e),o=(c,u)=>{if(typeof i=="function")u=i.call(t,c,u);else if(Array.isArray(i)&&!i.includes(c))return;(u!==void 0||r)&&l.items.push(Ns(c,u,n))};if(t instanceof Map)for(const[c,u]of t)o(c,u);else if(t&&typeof t=="object")for(const c of Object.keys(t))o(c,t[c]);return typeof e.sortMapEntries=="function"&&l.items.sort(e.sortMapEntries),l}add(e,t){let n;F(e)?n=e:!e||typeof e!="object"||!("key"in e)?n=new q(e,e?.value):n=new q(e.key,e.value);const r=ye(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw new Error(`Key ${n.key} already set`);j(r.value)&&kn(n.value)?r.value.value=n.value:r.value=n.value}else if(i){const l=this.items.findIndex(o=>i(n,o)<0);l===-1?this.items.push(n):this.items.splice(l,0,n)}else this.items.push(n)}delete(e){const t=ye(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){const r=ye(this.items,e)?.value;return(!t&&j(r)?r.value:r)??void 0}has(e){return!!ye(this.items,e)}set(e,t){this.add(new q(e,t),!0)}toJSON(e,t,n){const r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(const i of this.items)In(t,r,i);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(const r of this.items)if(!F(r))throw new Error(`Map items must all be pairs; found ${JSON.stringify(r)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),En(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:n,onComment:t})}}const je={collection:"map",default:!0,nodeClass:X,tag:"tag:yaml.org,2002:map",resolve(s,e){return He(s)||e("Expected a mapping for this tag"),s},createNode:(s,e,t)=>X.from(s,e,t)};class Ne extends Sn{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super($e,e),this.items=[]}add(e){this.items.push(e)}delete(e){const t=nt(e);return typeof t!="number"?!1:this.items.splice(t,1).length>0}get(e,t){const n=nt(e);if(typeof n!="number")return;const r=this.items[n];return!t&&j(r)?r.value:r}has(e){const t=nt(e);return typeof t=="number"&&t<this.items.length}set(e,t){const n=nt(e);if(typeof n!="number")throw new Error(`Expected a valid index, not ${e}.`);const r=this.items[n];j(r)&&kn(t)?r.value=t:this.items[n]=t}toJSON(e,t){const n=[];t?.onCreate&&t.onCreate(n);let r=0;for(const i of this.items)n.push(Z(i,String(r++),t));return n}toString(e,t,n){return e?En(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){const{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let l=0;for(let o of t){if(typeof r=="function"){const c=t instanceof Set?o:String(l++);o=r.call(t,c,o)}i.items.push(ze(o,void 0,n))}}return i}}function nt(s){let e=j(s)?s.value:s;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}const Me={collection:"seq",default:!0,nodeClass:Ne,tag:"tag:yaml.org,2002:seq",resolve(s,e){return Qe(s)||e("Expected a sequence for this tag"),s},createNode:(s,e,t)=>Ne.from(s,e,t)},It={identify:s=>typeof s=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:s=>s,stringify(s,e,t,n){return e=Object.assign({actualString:!0},e),bs(s,e,t,n)}},Et={identify:s=>s==null,createNode:()=>new A(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new A(null),stringify:({source:s},e)=>typeof s=="string"&&Et.test.test(s)?s:e.options.nullStr},ws={identify:s=>typeof s=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:s=>new A(s[0]==="t"||s[0]==="T"),stringify({source:s,value:e},t){if(s&&ws.test.test(s)){const n=s[0]==="t"||s[0]==="T";if(e===n)return s}return e?t.options.trueStr:t.options.falseStr}};function re({format:s,minFractionDigits:e,tag:t,value:n}){if(typeof n=="bigint")return String(n);const r=typeof n=="number"?n:Number(n);if(!isFinite(r))return isNaN(r)?".nan":r<0?"-.inf":".inf";let i=Object.is(n,-0)?"-0":JSON.stringify(n);if(!s&&e&&(!t||t==="tag:yaml.org,2002:float")&&/^\d/.test(i)){let l=i.indexOf(".");l<0&&(l=i.length,i+=".");let o=e-(i.length-l-1);for(;o-- >0;)i+="0"}return i}const Ln={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:s=>s.slice(-3).toLowerCase()==="nan"?NaN:s[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:re},$n={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:s=>parseFloat(s),stringify(s){const e=Number(s.value);return isFinite(e)?e.toExponential():re(s)}},_n={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(s){const e=new A(parseFloat(s)),t=s.indexOf(".");return t!==-1&&s[s.length-1]==="0"&&(e.minFractionDigits=s.length-t-1),e},stringify:re},Lt=s=>typeof s=="bigint"||Number.isInteger(s),vs=(s,e,t,{intAsBigInt:n})=>n?BigInt(s):parseInt(s.substring(e),t);function jn(s,e,t){const{value:n}=s;return Lt(n)&&n>=0?t+n.toString(e):re(s)}const Mn={identify:s=>Lt(s)&&s>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(s,e,t)=>vs(s,2,8,t),stringify:s=>jn(s,8,"0o")},Pn={identify:Lt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(s,e,t)=>vs(s,0,10,t),stringify:re},Rn={identify:s=>Lt(s)&&s>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(s,e,t)=>vs(s,2,16,t),stringify:s=>jn(s,16,"0x")},ga=[je,Me,It,Et,ws,Mn,Pn,Rn,Ln,$n,_n];function Ds(s){return typeof s=="bigint"||Number.isInteger(s)}const rt=({value:s})=>JSON.stringify(s),ya=[{identify:s=>typeof s=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:s=>s,stringify:rt},{identify:s=>s==null,createNode:()=>new A(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:rt},{identify:s=>typeof s=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:s=>s==="true",stringify:rt},{identify:Ds,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(s,e,{intAsBigInt:t})=>t?BigInt(s):parseInt(s,10),stringify:({value:s})=>Ds(s)?s.toString():JSON.stringify(s)},{identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:s=>parseFloat(s),stringify:rt}],ba={default:!0,tag:"",test:/^/,resolve(s,e){return e(`Unresolved plain scalar ${JSON.stringify(s)}`),s}},Na=[je,Me].concat(ya,ba),xs={identify:s=>s instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(s,e){if(typeof atob=="function"){const t=atob(s.replace(/[\n\r]/g,"")),n=new Uint8Array(t.length);for(let r=0;r<t.length;++r)n[r]=t.charCodeAt(r);return n}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),s},stringify({comment:s,type:e,value:t},n,r,i){if(!t)return"";const l=t;let o;if(typeof btoa=="function"){let c="";for(let u=0;u<l.length;++u)c+=String.fromCharCode(l[u]);o=btoa(c)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=A.BLOCK_LITERAL),e!==A.QUOTE_DOUBLE){const c=Math.max(n.options.lineWidth-n.indent.length,n.options.minContentWidth),u=Math.ceil(o.length/c),m=new Array(u);for(let h=0,f=0;h<u;++h,f+=c)m[h]=o.substr(f,c);o=m.join(e===A.BLOCK_LITERAL?`
58
- `:" ")}return bs({comment:s,type:e,value:o},n,r,i)}};function Bn(s,e){if(Qe(s))for(let t=0;t<s.items.length;++t){let n=s.items[t];if(!F(n)){if(He(n)){n.items.length>1&&e("Each pair must have its own sequence indicator");const r=n.items[0]||new q(new A(null));if(n.commentBefore&&(r.key.commentBefore=r.key.commentBefore?`${n.commentBefore}
59
- ${r.key.commentBefore}`:n.commentBefore),n.comment){const i=r.value??r.key;i.comment=i.comment?`${n.comment}
60
- ${i.comment}`:n.comment}n=r}s.items[t]=F(n)?n:new q(n)}}else e("Expected a sequence for this tag");return s}function Dn(s,e,t){const{replacer:n}=t,r=new Ne(s);r.tag="tag:yaml.org,2002:pairs";let i=0;if(e&&Symbol.iterator in Object(e))for(let l of e){typeof n=="function"&&(l=n.call(e,String(i++),l));let o,c;if(Array.isArray(l))if(l.length===2)o=l[0],c=l[1];else throw new TypeError(`Expected [key, value] tuple: ${l}`);else if(l&&l instanceof Object){const u=Object.keys(l);if(u.length===1)o=u[0],c=l[o];else throw new TypeError(`Expected tuple with one key, not ${u.length} keys`)}else o=l;r.items.push(Ns(o,c,t))}return r}const ks={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Bn,createNode:Dn};class Te extends Ne{constructor(){super(),this.add=X.prototype.add.bind(this),this.delete=X.prototype.delete.bind(this),this.get=X.prototype.get.bind(this),this.has=X.prototype.has.bind(this),this.set=X.prototype.set.bind(this),this.tag=Te.tag}toJSON(e,t){if(!t)return super.toJSON(e);const n=new Map;t?.onCreate&&t.onCreate(n);for(const r of this.items){let i,l;if(F(r)?(i=Z(r.key,"",t),l=Z(r.value,i,t)):i=Z(r,"",t),n.has(i))throw new Error("Ordered maps must not include duplicate keys");n.set(i,l)}return n}static from(e,t,n){const r=Dn(e,t,n),i=new this;return i.items=r.items,i}}Te.tag="tag:yaml.org,2002:omap";const Ss={collection:"seq",identify:s=>s instanceof Map,nodeClass:Te,default:!1,tag:"tag:yaml.org,2002:omap",resolve(s,e){const t=Bn(s,e),n=[];for(const{key:r}of t.items)j(r)&&(n.includes(r.value)?e(`Ordered maps must not include duplicate keys: ${r.value}`):n.push(r.value));return Object.assign(new Te,t)},createNode:(s,e,t)=>Te.from(s,e,t)};function Fn({value:s,source:e},t){return e&&(s?Kn:Un).test.test(e)?e:s?t.options.trueStr:t.options.falseStr}const Kn={identify:s=>s===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new A(!0),stringify:Fn},Un={identify:s=>s===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new A(!1),stringify:Fn},wa={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:s=>s.slice(-3).toLowerCase()==="nan"?NaN:s[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:re},va={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:s=>parseFloat(s.replace(/_/g,"")),stringify(s){const e=Number(s.value);return isFinite(e)?e.toExponential():re(s)}},xa={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(s){const e=new A(parseFloat(s.replace(/_/g,""))),t=s.indexOf(".");if(t!==-1){const n=s.substring(t+1).replace(/_/g,"");n[n.length-1]==="0"&&(e.minFractionDigits=n.length)}return e},stringify:re},Xe=s=>typeof s=="bigint"||Number.isInteger(s);function $t(s,e,t,{intAsBigInt:n}){const r=s[0];if((r==="-"||r==="+")&&(e+=1),s=s.substring(e).replace(/_/g,""),n){switch(t){case 2:s=`0b${s}`;break;case 8:s=`0o${s}`;break;case 16:s=`0x${s}`;break}const l=BigInt(s);return r==="-"?BigInt(-1)*l:l}const i=parseInt(s,t);return r==="-"?-1*i:i}function Os(s,e,t){const{value:n}=s;if(Xe(n)){const r=n.toString(e);return n<0?"-"+t+r.substr(1):t+r}return re(s)}const ka={identify:Xe,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(s,e,t)=>$t(s,2,2,t),stringify:s=>Os(s,2,"0b")},Sa={identify:Xe,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(s,e,t)=>$t(s,1,8,t),stringify:s=>Os(s,8,"0")},Oa={identify:Xe,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(s,e,t)=>$t(s,0,10,t),stringify:re},Ca={identify:Xe,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(s,e,t)=>$t(s,2,16,t),stringify:s=>Os(s,16,"0x")};class Ae extends X{constructor(e){super(e),this.tag=Ae.tag}add(e){let t;F(e)?t=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?t=new q(e.key,null):t=new q(e,null),ye(this.items,t.key)||this.items.push(t)}get(e,t){const n=ye(this.items,e);return!t&&F(n)?j(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);const n=ye(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new q(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw new Error("Set items must all have null values")}static from(e,t,n){const{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let l of t)typeof r=="function"&&(l=r.call(t,l,l)),i.items.push(Ns(l,null,n));return i}}Ae.tag="tag:yaml.org,2002:set";const Cs={collection:"map",identify:s=>s instanceof Set,nodeClass:Ae,default:!1,tag:"tag:yaml.org,2002:set",createNode:(s,e,t)=>Ae.from(s,e,t),resolve(s,e){if(He(s)){if(s.hasAllNullValues(!0))return Object.assign(new Ae,s);e("Set items must all have null values")}else e("Expected a mapping for this tag");return s}};function Ts(s,e){const t=s[0],n=t==="-"||t==="+"?s.substring(1):s,r=l=>e?BigInt(l):Number(l),i=n.replace(/_/g,"").split(":").reduce((l,o)=>l*r(60)+r(o),r(0));return t==="-"?r(-1)*i:i}function Vn(s){let{value:e}=s,t=l=>l;if(typeof e=="bigint")t=l=>BigInt(l);else if(isNaN(e)||!isFinite(e))return re(s);let n="";e<0&&(n="-",e*=t(-1));const r=t(60),i=[e%r];return e<60?i.unshift(0):(e=(e-i[0])/r,i.unshift(e%r),e>=60&&(e=(e-i[0])/r,i.unshift(e))),n+i.map(l=>String(l).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}const qn={identify:s=>typeof s=="bigint"||Number.isInteger(s),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(s,e,{intAsBigInt:t})=>Ts(s,t),stringify:Vn},Jn={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:s=>Ts(s,!1),stringify:Vn},_t={identify:s=>s instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(s){const e=s.match(_t.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");const[,t,n,r,i,l,o]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0;let u=Date.UTC(t,n-1,r,i||0,l||0,o||0,c);const m=e[8];if(m&&m!=="Z"){let h=Ts(m,!1);Math.abs(h)<30&&(h*=60),u-=6e4*h}return new Date(u)},stringify:({value:s})=>s?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""},Fs=[je,Me,It,Et,Kn,Un,ka,Sa,Oa,Ca,wa,va,xa,xs,de,Ss,ks,Cs,qn,Jn,_t],Ks=new Map([["core",ga],["failsafe",[je,Me,It]],["json",Na],["yaml11",Fs],["yaml-1.1",Fs]]),Us={binary:xs,bool:ws,float:_n,floatExp:$n,floatNaN:Ln,floatTime:Jn,int:Pn,intHex:Rn,intOct:Mn,intTime:qn,map:je,merge:de,null:Et,omap:Ss,pairs:ks,seq:Me,set:Cs,timestamp:_t},Ta={"tag:yaml.org,2002:binary":xs,"tag:yaml.org,2002:merge":de,"tag:yaml.org,2002:omap":Ss,"tag:yaml.org,2002:pairs":ks,"tag:yaml.org,2002:set":Cs,"tag:yaml.org,2002:timestamp":_t};function Bt(s,e,t){const n=Ks.get(e);if(n&&!s)return t&&!n.includes(de)?n.concat(de):n.slice();let r=n;if(!r)if(Array.isArray(s))r=[];else{const i=Array.from(Ks.keys()).filter(l=>l!=="yaml11").map(l=>JSON.stringify(l)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${i} or define customTags array`)}if(Array.isArray(s))for(const i of s)r=r.concat(i);else typeof s=="function"&&(r=s(r.slice()));return t&&(r=r.concat(de)),r.reduce((i,l)=>{const o=typeof l=="string"?Us[l]:l;if(!o){const c=JSON.stringify(l),u=Object.keys(Us).map(m=>JSON.stringify(m)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${u}`)}return i.includes(o)||i.push(o),i},[])}const Aa=(s,e)=>s.key<e.key?-1:s.key>e.key?1:0;class As{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:r,schema:i,sortMapEntries:l,toStringDefaults:o}){this.compat=Array.isArray(e)?Bt(e,"compat"):e?Bt(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=r?Ta:{},this.tags=Bt(t,this.name,n),this.toStringOptions=o??null,Object.defineProperty(this,he,{value:je}),Object.defineProperty(this,oe,{value:It}),Object.defineProperty(this,$e,{value:Me}),this.sortMapEntries=typeof l=="function"?l:l===!0?Aa:null}clone(){const e=Object.create(As.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}function Ia(s,e){const t=[];let n=e.directives===!0;if(e.directives!==!1&&s.directives){const c=s.directives.toString(s);c?(t.push(c),n=!0):s.directives.docStart&&(n=!0)}n&&t.push("---");const r=Cn(s,e),{commentString:i}=r.options;if(s.commentBefore){t.length!==1&&t.unshift("");const c=i(s.commentBefore);t.unshift(ce(c,""))}let l=!1,o=null;if(s.contents){if(D(s.contents)){if(s.contents.spaceBefore&&n&&t.push(""),s.contents.commentBefore){const m=i(s.contents.commentBefore);t.push(ce(m,""))}r.forceBlockIndent=!!s.comment,o=s.contents.comment}const c=o?void 0:()=>l=!0;let u=Ee(s.contents,r,()=>o=null,c);o&&(u+=ge(u,"",i(o))),(u[0]==="|"||u[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${u}`:t.push(u)}else t.push(Ee(s.contents,r));if(s.directives?.docEnd)if(s.comment){const c=i(s.comment);c.includes(`
61
- `)?(t.push("..."),t.push(ce(c,""))):t.push(`... ${c}`)}else t.push("...");else{let c=s.comment;c&&l&&(c=c.replace(/^\n+/,"")),c&&((!l||o)&&t[t.length-1]!==""&&t.push(""),t.push(ce(i(c),"")))}return t.join(`
53
+ `+me(u(s),d),c&&c()):m&&l&&l(),g}function Ra({items:s},e,{flowChars:t,itemIndent:n}){const{indent:r,indentStep:a,flowCollectionPadding:l,options:{commentString:c}}=e;n+=a;const d=Object.assign({},e,{indent:n,inFlow:!0,type:null});let u=!1,h=0;const m=[];for(let w=0;w<s.length;++w){const p=s[w];let b=null;if(K(p))p.spaceBefore&&m.push(""),At(e,m,p.commentBefore,!1),p.comment&&(b=p.comment);else if(U(p)){const x=K(p.key)?p.key:null;x&&(x.spaceBefore&&m.push(""),At(e,m,x.commentBefore,!1),x.comment&&(u=!0));const N=K(p.value)?p.value:null;N?(N.comment&&(b=N.comment),N.commentBefore&&(u=!0)):p.value==null&&x?.comment&&(b=x.comment)}b&&(u=!0);let k=Ue(p,d,()=>b=null);w<s.length-1&&(k+=","),b&&(k+=Se(k,n,c(b))),!u&&(m.length>h||k.includes(`
54
+ `))&&(u=!0),m.push(k),h=m.length}const{start:f,end:g}=t;if(m.length===0)return f+g;if(!u){const w=m.reduce((p,b)=>p+b.length+2,2);u=e.options.lineWidth>0&&w>e.options.lineWidth}if(u){let w=f;for(const p of m)w+=p?`
55
+ ${a}${r}${p}`:`
56
+ `;return`${w}
57
+ ${r}${g}`}else return`${f}${l}${m.join(" ")}${l}${g}`}function At({indent:s,options:{commentString:e}},t,n,r){if(n&&r&&(n=n.replace(/^\n+/,"")),n){const a=me(e(n),s);t.push(a.trimStart())}}function Ce(s,e){const t=R(e)?e.value:e;for(const n of s)if(U(n)&&(n.key===e||n.key===t||R(n.key)&&n.key.value===t))return n}class re extends Jn{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Ne,e),this.items=[]}static from(e,t,n){const{keepUndefined:r,replacer:a}=n,l=new this(e),c=(d,u)=>{if(typeof a=="function")u=a.call(t,d,u);else if(Array.isArray(a)&&!a.includes(d))return;(u!==void 0||r)&&l.items.push(Ps(d,u,n))};if(t instanceof Map)for(const[d,u]of t)c(d,u);else if(t&&typeof t=="object")for(const d of Object.keys(t))c(d,t[d]);return typeof e.sortMapEntries=="function"&&l.items.sort(e.sortMapEntries),l}add(e,t){let n;U(e)?n=e:!e||typeof e!="object"||!("key"in e)?n=new Z(e,e?.value):n=new Z(e.key,e.value);const r=Ce(this.items,n.key),a=this.schema?.sortMapEntries;if(r){if(!t)throw new Error(`Key ${n.key} already set`);R(r.value)&&zn(n.value)?r.value.value=n.value:r.value=n.value}else if(a){const l=this.items.findIndex(c=>a(n,c)<0);l===-1?this.items.push(n):this.items.splice(l,0,n)}else this.items.push(n)}delete(e){const t=Ce(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){const r=Ce(this.items,e)?.value;return(!t&&R(r)?r.value:r)??void 0}has(e){return!!Ce(this.items,e)}set(e,t){this.add(new Z(e,t),!0)}toJSON(e,t,n){const r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(const a of this.items)Qn(t,r,a);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(const r of this.items)if(!U(r))throw new Error(`Map items must all be pairs; found ${JSON.stringify(r)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Xn(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:n,onComment:t})}}const Ye={collection:"map",default:!0,nodeClass:re,tag:"tag:yaml.org,2002:map",resolve(s,e){return dt(s)||e("Expected a mapping for this tag"),s},createNode:(s,e,t)=>re.from(s,e,t)};class Ae extends Jn{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(ze,e),this.items=[]}add(e){this.items.push(e)}delete(e){const t=yt(e);return typeof t!="number"?!1:this.items.splice(t,1).length>0}get(e,t){const n=yt(e);if(typeof n!="number")return;const r=this.items[n];return!t&&R(r)?r.value:r}has(e){const t=yt(e);return typeof t=="number"&&t<this.items.length}set(e,t){const n=yt(e);if(typeof n!="number")throw new Error(`Expected a valid index, not ${e}.`);const r=this.items[n];R(r)&&zn(t)?r.value=t:this.items[n]=t}toJSON(e,t){const n=[];t?.onCreate&&t.onCreate(n);let r=0;for(const a of this.items)n.push(ie(a,String(r++),t));return n}toString(e,t,n){return e?Xn(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){const{replacer:r}=n,a=new this(e);if(t&&Symbol.iterator in Object(t)){let l=0;for(let c of t){if(typeof r=="function"){const d=t instanceof Set?c:String(l++);c=r.call(t,d,c)}a.items.push(it(c,void 0,n))}}return a}}function yt(s){let e=R(s)?s.value:s;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}const We={collection:"seq",default:!0,nodeClass:Ae,tag:"tag:yaml.org,2002:seq",resolve(s,e){return ut(s)||e("Expected a sequence for this tag"),s},createNode:(s,e,t)=>Ae.from(s,e,t)},Ut={identify:s=>typeof s=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:s=>s,stringify(s,e,t,n){return e=Object.assign({actualString:!0},e),_s(s,e,t,n)}},Vt={identify:s=>s==null,createNode:()=>new L(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new L(null),stringify:({source:s},e)=>typeof s=="string"&&Vt.test.test(s)?s:e.options.nullStr},Ms={identify:s=>typeof s=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:s=>new L(s[0]==="t"||s[0]==="T"),stringify({source:s,value:e},t){if(s&&Ms.test.test(s)){const n=s[0]==="t"||s[0]==="T";if(e===n)return s}return e?t.options.trueStr:t.options.falseStr}};function de({format:s,minFractionDigits:e,tag:t,value:n}){if(typeof n=="bigint")return String(n);const r=typeof n=="number"?n:Number(n);if(!isFinite(r))return isNaN(r)?".nan":r<0?"-.inf":".inf";let a=Object.is(n,-0)?"-0":JSON.stringify(n);if(!s&&e&&(!t||t==="tag:yaml.org,2002:float")&&/^\d/.test(a)){let l=a.indexOf(".");l<0&&(l=a.length,a+=".");let c=e-(a.length-l-1);for(;c-- >0;)a+="0"}return a}const Zn={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:s=>s.slice(-3).toLowerCase()==="nan"?NaN:s[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:de},er={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:s=>parseFloat(s),stringify(s){const e=Number(s.value);return isFinite(e)?e.toExponential():de(s)}},tr={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(s){const e=new L(parseFloat(s)),t=s.indexOf(".");return t!==-1&&s[s.length-1]==="0"&&(e.minFractionDigits=s.length-t-1),e},stringify:de},qt=s=>typeof s=="bigint"||Number.isInteger(s),Ds=(s,e,t,{intAsBigInt:n})=>n?BigInt(s):parseInt(s.substring(e),t);function sr(s,e,t){const{value:n}=s;return qt(n)&&n>=0?t+n.toString(e):de(s)}const nr={identify:s=>qt(s)&&s>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(s,e,t)=>Ds(s,2,8,t),stringify:s=>sr(s,8,"0o")},rr={identify:qt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(s,e,t)=>Ds(s,0,10,t),stringify:de},ir={identify:s=>qt(s)&&s>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(s,e,t)=>Ds(s,2,16,t),stringify:s=>sr(s,16,"0x")},Ba=[Ye,We,Ut,Vt,Ms,nr,rr,ir,Zn,er,tr];function rn(s){return typeof s=="bigint"||Number.isInteger(s)}const bt=({value:s})=>JSON.stringify(s),Fa=[{identify:s=>typeof s=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:s=>s,stringify:bt},{identify:s=>s==null,createNode:()=>new L(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:bt},{identify:s=>typeof s=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:s=>s==="true",stringify:bt},{identify:rn,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(s,e,{intAsBigInt:t})=>t?BigInt(s):parseInt(s,10),stringify:({value:s})=>rn(s)?s.toString():JSON.stringify(s)},{identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:s=>parseFloat(s),stringify:bt}],Ka={default:!0,tag:"",test:/^/,resolve(s,e){return e(`Unresolved plain scalar ${JSON.stringify(s)}`),s}},Ua=[Ye,We].concat(Fa,Ka),Rs={identify:s=>s instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(s,e){if(typeof atob=="function"){const t=atob(s.replace(/[\n\r]/g,"")),n=new Uint8Array(t.length);for(let r=0;r<t.length;++r)n[r]=t.charCodeAt(r);return n}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),s},stringify({comment:s,type:e,value:t},n,r,a){if(!t)return"";const l=t;let c;if(typeof btoa=="function"){let d="";for(let u=0;u<l.length;++u)d+=String.fromCharCode(l[u]);c=btoa(d)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=L.BLOCK_LITERAL),e!==L.QUOTE_DOUBLE){const d=Math.max(n.options.lineWidth-n.indent.length,n.options.minContentWidth),u=Math.ceil(c.length/d),h=new Array(u);for(let m=0,f=0;m<u;++m,f+=d)h[m]=c.substr(f,d);c=h.join(e===L.BLOCK_LITERAL?`
58
+ `:" ")}return _s({comment:s,type:e,value:c},n,r,a)}};function ar(s,e){if(ut(s))for(let t=0;t<s.items.length;++t){let n=s.items[t];if(!U(n)){if(dt(n)){n.items.length>1&&e("Each pair must have its own sequence indicator");const r=n.items[0]||new Z(new L(null));if(n.commentBefore&&(r.key.commentBefore=r.key.commentBefore?`${n.commentBefore}
59
+ ${r.key.commentBefore}`:n.commentBefore),n.comment){const a=r.value??r.key;a.comment=a.comment?`${n.comment}
60
+ ${a.comment}`:n.comment}n=r}s.items[t]=U(n)?n:new Z(n)}}else e("Expected a sequence for this tag");return s}function lr(s,e,t){const{replacer:n}=t,r=new Ae(s);r.tag="tag:yaml.org,2002:pairs";let a=0;if(e&&Symbol.iterator in Object(e))for(let l of e){typeof n=="function"&&(l=n.call(e,String(a++),l));let c,d;if(Array.isArray(l))if(l.length===2)c=l[0],d=l[1];else throw new TypeError(`Expected [key, value] tuple: ${l}`);else if(l&&l instanceof Object){const u=Object.keys(l);if(u.length===1)c=u[0],d=l[c];else throw new TypeError(`Expected tuple with one key, not ${u.length} keys`)}else c=l;r.items.push(Ps(c,d,t))}return r}const Bs={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:ar,createNode:lr};class Re extends Ae{constructor(){super(),this.add=re.prototype.add.bind(this),this.delete=re.prototype.delete.bind(this),this.get=re.prototype.get.bind(this),this.has=re.prototype.has.bind(this),this.set=re.prototype.set.bind(this),this.tag=Re.tag}toJSON(e,t){if(!t)return super.toJSON(e);const n=new Map;t?.onCreate&&t.onCreate(n);for(const r of this.items){let a,l;if(U(r)?(a=ie(r.key,"",t),l=ie(r.value,a,t)):a=ie(r,"",t),n.has(a))throw new Error("Ordered maps must not include duplicate keys");n.set(a,l)}return n}static from(e,t,n){const r=lr(e,t,n),a=new this;return a.items=r.items,a}}Re.tag="tag:yaml.org,2002:omap";const Fs={collection:"seq",identify:s=>s instanceof Map,nodeClass:Re,default:!1,tag:"tag:yaml.org,2002:omap",resolve(s,e){const t=ar(s,e),n=[];for(const{key:r}of t.items)R(r)&&(n.includes(r.value)?e(`Ordered maps must not include duplicate keys: ${r.value}`):n.push(r.value));return Object.assign(new Re,t)},createNode:(s,e,t)=>Re.from(s,e,t)};function or({value:s,source:e},t){return e&&(s?cr:dr).test.test(e)?e:s?t.options.trueStr:t.options.falseStr}const cr={identify:s=>s===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new L(!0),stringify:or},dr={identify:s=>s===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new L(!1),stringify:or},Va={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:s=>s.slice(-3).toLowerCase()==="nan"?NaN:s[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:de},qa={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:s=>parseFloat(s.replace(/_/g,"")),stringify(s){const e=Number(s.value);return isFinite(e)?e.toExponential():de(s)}},za={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(s){const e=new L(parseFloat(s.replace(/_/g,""))),t=s.indexOf(".");if(t!==-1){const n=s.substring(t+1).replace(/_/g,"");n[n.length-1]==="0"&&(e.minFractionDigits=n.length)}return e},stringify:de},ft=s=>typeof s=="bigint"||Number.isInteger(s);function zt(s,e,t,{intAsBigInt:n}){const r=s[0];if((r==="-"||r==="+")&&(e+=1),s=s.substring(e).replace(/_/g,""),n){switch(t){case 2:s=`0b${s}`;break;case 8:s=`0o${s}`;break;case 16:s=`0x${s}`;break}const l=BigInt(s);return r==="-"?BigInt(-1)*l:l}const a=parseInt(s,t);return r==="-"?-1*a:a}function Ks(s,e,t){const{value:n}=s;if(ft(n)){const r=n.toString(e);return n<0?"-"+t+r.substr(1):t+r}return de(s)}const Ja={identify:ft,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(s,e,t)=>zt(s,2,2,t),stringify:s=>Ks(s,2,"0b")},Ya={identify:ft,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(s,e,t)=>zt(s,1,8,t),stringify:s=>Ks(s,8,"0")},Wa={identify:ft,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(s,e,t)=>zt(s,0,10,t),stringify:de},Ga={identify:ft,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(s,e,t)=>zt(s,2,16,t),stringify:s=>Ks(s,16,"0x")};class Be extends re{constructor(e){super(e),this.tag=Be.tag}add(e){let t;U(e)?t=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?t=new Z(e.key,null):t=new Z(e,null),Ce(this.items,t.key)||this.items.push(t)}get(e,t){const n=Ce(this.items,e);return!t&&U(n)?R(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);const n=Ce(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new Z(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw new Error("Set items must all have null values")}static from(e,t,n){const{replacer:r}=n,a=new this(e);if(t&&Symbol.iterator in Object(t))for(let l of t)typeof r=="function"&&(l=r.call(t,l,l)),a.items.push(Ps(l,null,n));return a}}Be.tag="tag:yaml.org,2002:set";const Us={collection:"map",identify:s=>s instanceof Set,nodeClass:Be,default:!1,tag:"tag:yaml.org,2002:set",createNode:(s,e,t)=>Be.from(s,e,t),resolve(s,e){if(dt(s)){if(s.hasAllNullValues(!0))return Object.assign(new Be,s);e("Set items must all have null values")}else e("Expected a mapping for this tag");return s}};function Vs(s,e){const t=s[0],n=t==="-"||t==="+"?s.substring(1):s,r=l=>e?BigInt(l):Number(l),a=n.replace(/_/g,"").split(":").reduce((l,c)=>l*r(60)+r(c),r(0));return t==="-"?r(-1)*a:a}function ur(s){let{value:e}=s,t=l=>l;if(typeof e=="bigint")t=l=>BigInt(l);else if(isNaN(e)||!isFinite(e))return de(s);let n="";e<0&&(n="-",e*=t(-1));const r=t(60),a=[e%r];return e<60?a.unshift(0):(e=(e-a[0])/r,a.unshift(e%r),e>=60&&(e=(e-a[0])/r,a.unshift(e))),n+a.map(l=>String(l).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}const fr={identify:s=>typeof s=="bigint"||Number.isInteger(s),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(s,e,{intAsBigInt:t})=>Vs(s,t),stringify:ur},hr={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:s=>Vs(s,!1),stringify:ur},Jt={identify:s=>s instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(s){const e=s.match(Jt.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");const[,t,n,r,a,l,c]=e.map(Number),d=e[7]?Number((e[7]+"00").substr(1,3)):0;let u=Date.UTC(t,n-1,r,a||0,l||0,c||0,d);const h=e[8];if(h&&h!=="Z"){let m=Vs(h,!1);Math.abs(m)<30&&(m*=60),u-=6e4*m}return new Date(u)},stringify:({value:s})=>s?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""},an=[Ye,We,Ut,Vt,cr,dr,Ja,Ya,Wa,Ga,Va,qa,za,Rs,pe,Fs,Bs,Us,fr,hr,Jt],ln=new Map([["core",Ba],["failsafe",[Ye,We,Ut]],["json",Ua],["yaml11",an],["yaml-1.1",an]]),on={binary:Rs,bool:Ms,float:tr,floatExp:er,floatNaN:Zn,floatTime:hr,int:rr,intHex:ir,intOct:nr,intTime:fr,map:Ye,merge:pe,null:Vt,omap:Fs,pairs:Bs,seq:We,set:Us,timestamp:Jt},Ha={"tag:yaml.org,2002:binary":Rs,"tag:yaml.org,2002:merge":pe,"tag:yaml.org,2002:omap":Fs,"tag:yaml.org,2002:pairs":Bs,"tag:yaml.org,2002:set":Us,"tag:yaml.org,2002:timestamp":Jt};function ts(s,e,t){const n=ln.get(e);if(n&&!s)return t&&!n.includes(pe)?n.concat(pe):n.slice();let r=n;if(!r)if(Array.isArray(s))r=[];else{const a=Array.from(ln.keys()).filter(l=>l!=="yaml11").map(l=>JSON.stringify(l)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${a} or define customTags array`)}if(Array.isArray(s))for(const a of s)r=r.concat(a);else typeof s=="function"&&(r=s(r.slice()));return t&&(r=r.concat(pe)),r.reduce((a,l)=>{const c=typeof l=="string"?on[l]:l;if(!c){const d=JSON.stringify(l),u=Object.keys(on).map(h=>JSON.stringify(h)).join(", ");throw new Error(`Unknown custom tag ${d}; use one of ${u}`)}return a.includes(c)||a.push(c),a},[])}const Qa=(s,e)=>s.key<e.key?-1:s.key>e.key?1:0;class qs{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:r,schema:a,sortMapEntries:l,toStringDefaults:c}){this.compat=Array.isArray(e)?ts(e,"compat"):e?ts(null,e):null,this.name=typeof a=="string"&&a||"core",this.knownTags=r?Ha:{},this.tags=ts(t,this.name,n),this.toStringOptions=c??null,Object.defineProperty(this,Ne,{value:Ye}),Object.defineProperty(this,he,{value:Ut}),Object.defineProperty(this,ze,{value:We}),this.sortMapEntries=typeof l=="function"?l:l===!0?Qa:null}clone(){const e=Object.create(qs.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}function Xa(s,e){const t=[];let n=e.directives===!0;if(e.directives!==!1&&s.directives){const d=s.directives.toString(s);d?(t.push(d),n=!0):s.directives.docStart&&(n=!0)}n&&t.push("---");const r=Wn(s,e),{commentString:a}=r.options;if(s.commentBefore){t.length!==1&&t.unshift("");const d=a(s.commentBefore);t.unshift(me(d,""))}let l=!1,c=null;if(s.contents){if(K(s.contents)){if(s.contents.spaceBefore&&n&&t.push(""),s.contents.commentBefore){const h=a(s.contents.commentBefore);t.push(me(h,""))}r.forceBlockIndent=!!s.comment,c=s.contents.comment}const d=c?void 0:()=>l=!0;let u=Ue(s.contents,r,()=>c=null,d);c&&(u+=Se(u,"",a(c))),(u[0]==="|"||u[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${u}`:t.push(u)}else t.push(Ue(s.contents,r));if(s.directives?.docEnd)if(s.comment){const d=a(s.comment);d.includes(`
61
+ `)?(t.push("..."),t.push(me(d,""))):t.push(`... ${d}`)}else t.push("...");else{let d=s.comment;d&&l&&(d=d.replace(/^\n+/,"")),d&&((!l||c)&&t[t.length-1]!==""&&t.push(""),t.push(me(a(d),"")))}return t.join(`
62
62
  `)+`
63
- `}class Ze{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,ee,{value:Jt});let r=null;typeof t=="function"||Array.isArray(t)?r=t:n===void 0&&t&&(n=t,t=void 0);const i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},n);this.options=i;let{version:l}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(l=this.directives.yaml.version)):this.directives=new K({version:l}),this.setSchema(l,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){const e=Object.create(Ze.prototype,{[ee]:{value:Jt}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=D(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){ve(this.contents)&&this.contents.add(e)}addIn(e,t){ve(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){const n=vn(this);e.anchor=!t||n.has(t)?xn(t||"a",n):t}return new ys(e.anchor)}createNode(e,t,n){let r;if(typeof t=="function")e=t.call({"":e},"",e),r=t;else if(Array.isArray(t)){const y=O=>typeof O=="number"||O instanceof String||O instanceof Number,k=t.filter(y).map(String);k.length>0&&(t=t.concat(k)),r=t}else n===void 0&&t&&(n=t,t=void 0);const{aliasDuplicateObjects:i,anchorPrefix:l,flow:o,keepUndefined:c,onTagObj:u,tag:m}=n??{},{onAnchor:h,setAnchors:f,sourceObjects:g}=na(this,l||"a"),b={aliasDuplicateObjects:i??!0,keepUndefined:c??!1,onAnchor:h,onTagObj:u,replacer:r,schema:this.schema,sourceObjects:g},p=ze(e,m,b);return o&&B(p)&&(p.flow=!0),f(),p}createPair(e,t,n={}){const r=this.createNode(e,null,n),i=this.createNode(t,null,n);return new q(r,i)}delete(e){return ve(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Re(e)?this.contents==null?!1:(this.contents=null,!0):ve(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return B(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return Re(e)?!t&&j(this.contents)?this.contents.value:this.contents:B(this.contents)?this.contents.getIn(e,t):void 0}has(e){return B(this.contents)?this.contents.has(e):!1}hasIn(e){return Re(e)?this.contents!==void 0:B(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=mt(this.schema,[e],t):ve(this.contents)&&this.contents.set(e,t)}setIn(e,t){Re(e)?this.contents=t:this.contents==null?this.contents=mt(this.schema,Array.from(e),t):ve(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e=="number"&&(e=String(e));let n;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new K({version:"1.1"}),n={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new K({version:e}),n={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,n=null;break;default:{const r=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${r}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new As(Object.assign(n,t));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:l}={}){const o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},c=Z(this.contents,t??"",o);if(typeof i=="function")for(const{count:u,res:m}of o.anchors.values())i(m,u);return typeof l=="function"?Se(l,{"":c},"",c):c}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){const t=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${t}`)}return Ia(this,e)}}function ve(s){if(B(s))return!0;throw new Error("Expected a YAML collection as document contents")}class zn extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}}class Be extends zn{constructor(e,t,n){super("YAMLParseError",e,t,n)}}class Ea extends zn{constructor(e,t,n){super("YAMLWarning",e,t,n)}}const Vs=(s,e)=>t=>{if(t.pos[0]===-1)return;t.linePos=t.pos.map(o=>e.linePos(o));const{line:n,col:r}=t.linePos[0];t.message+=` at line ${n}, column ${r}`;let i=r-1,l=s.substring(e.lineStarts[n-1],e.lineStarts[n]).replace(/[\n\r]+$/,"");if(i>=60&&l.length>80){const o=Math.min(i-39,l.length-79);l="…"+l.substring(o),i-=o-1}if(l.length>80&&(l=l.substring(0,79)+"…"),n>1&&/^ *$/.test(l.substring(0,i))){let o=s.substring(e.lineStarts[n-2],e.lineStarts[n-1]);o.length>80&&(o=o.substring(0,79)+`…
64
- `),l=o+l}if(/[^ ]/.test(l)){let o=1;const c=t.linePos[1];c?.line===n&&c.col>r&&(o=Math.max(1,Math.min(c.col-r,80-i)));const u=" ".repeat(i)+"^".repeat(o);t.message+=`:
63
+ `}class ht{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,ae,{value:cs});let r=null;typeof t=="function"||Array.isArray(t)?r=t:n===void 0&&t&&(n=t,t=void 0);const a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},n);this.options=a;let{version:l}=a;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(l=this.directives.yaml.version)):this.directives=new Q({version:l}),this.setSchema(l,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){const e=Object.create(ht.prototype,{[ae]:{value:cs}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=K(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){$e(this.contents)&&this.contents.add(e)}addIn(e,t){$e(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){const n=Vn(this);e.anchor=!t||n.has(t)?qn(t||"a",n):t}return new js(e.anchor)}createNode(e,t,n){let r;if(typeof t=="function")e=t.call({"":e},"",e),r=t;else if(Array.isArray(t)){const b=x=>typeof x=="number"||x instanceof String||x instanceof Number,k=t.filter(b).map(String);k.length>0&&(t=t.concat(k)),r=t}else n===void 0&&t&&(n=t,t=void 0);const{aliasDuplicateObjects:a,anchorPrefix:l,flow:c,keepUndefined:d,onTagObj:u,tag:h}=n??{},{onAnchor:m,setAnchors:f,sourceObjects:g}=Ta(this,l||"a"),w={aliasDuplicateObjects:a??!0,keepUndefined:d??!1,onAnchor:m,onTagObj:u,replacer:r,schema:this.schema,sourceObjects:g},p=it(e,h,w);return c&&F(p)&&(p.flow=!0),f(),p}createPair(e,t,n={}){const r=this.createNode(e,null,n),a=this.createNode(t,null,n);return new Z(r,a)}delete(e){return $e(this.contents)?this.contents.delete(e):!1}deleteIn(e){return He(e)?this.contents==null?!1:(this.contents=null,!0):$e(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return F(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return He(e)?!t&&R(this.contents)?this.contents.value:this.contents:F(this.contents)?this.contents.getIn(e,t):void 0}has(e){return F(this.contents)?this.contents.has(e):!1}hasIn(e){return He(e)?this.contents!==void 0:F(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=Ot(this.schema,[e],t):$e(this.contents)&&this.contents.set(e,t)}setIn(e,t){He(e)?this.contents=t:this.contents==null?this.contents=Ot(this.schema,Array.from(e),t):$e(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e=="number"&&(e=String(e));let n;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Q({version:"1.1"}),n={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new Q({version:e}),n={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,n=null;break;default:{const r=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${r}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new qs(Object.assign(n,t));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:a,reviver:l}={}){const c={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},d=ie(this.contents,t??"",c);if(typeof a=="function")for(const{count:u,res:h}of c.anchors.values())a(h,u);return typeof l=="function"?Pe(l,{"":d},"",d):d}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){const t=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${t}`)}return Xa(this,e)}}function $e(s){if(F(s))return!0;throw new Error("Expected a YAML collection as document contents")}class mr extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}}class Qe extends mr{constructor(e,t,n){super("YAMLParseError",e,t,n)}}class Za extends mr{constructor(e,t,n){super("YAMLWarning",e,t,n)}}const cn=(s,e)=>t=>{if(t.pos[0]===-1)return;t.linePos=t.pos.map(c=>e.linePos(c));const{line:n,col:r}=t.linePos[0];t.message+=` at line ${n}, column ${r}`;let a=r-1,l=s.substring(e.lineStarts[n-1],e.lineStarts[n]).replace(/[\n\r]+$/,"");if(a>=60&&l.length>80){const c=Math.min(a-39,l.length-79);l="…"+l.substring(c),a-=c-1}if(l.length>80&&(l=l.substring(0,79)+"…"),n>1&&/^ *$/.test(l.substring(0,a))){let c=s.substring(e.lineStarts[n-2],e.lineStarts[n-1]);c.length>80&&(c=c.substring(0,79)+`…
64
+ `),l=c+l}if(/[^ ]/.test(l)){let c=1;const d=t.linePos[1];d?.line===n&&d.col>r&&(c=Math.max(1,Math.min(d.col-r,80-a)));const u=" ".repeat(a)+"^".repeat(c);t.message+=`:
65
65
 
66
66
  ${l}
67
67
  ${u}
68
- `}};function Le(s,{flow:e,indicator:t,next:n,offset:r,onError:i,parentIndent:l,startOnNewline:o}){let c=!1,u=o,m=o,h="",f="",g=!1,b=!1,p=null,y=null,k=null,O=null,w=null,S=null,v=null;for(const x of s)switch(b&&(x.type!=="space"&&x.type!=="newline"&&x.type!=="comma"&&i(x.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),b=!1),p&&(u&&x.type!=="comment"&&x.type!=="newline"&&i(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),p=null),x.type){case"space":!e&&(t!=="doc-start"||n?.type!=="flow-collection")&&x.source.includes(" ")&&(p=x),m=!0;break;case"comment":{m||i(x,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const $=x.source.substring(1)||" ";h?h+=f+$:h=$,f="",u=!1;break}case"newline":u?h?h+=x.source:(!S||t!=="seq-item-ind")&&(c=!0):f+=x.source,u=!0,g=!0,(y||k)&&(O=x),m=!0;break;case"anchor":y&&i(x,"MULTIPLE_ANCHORS","A node can have at most one anchor"),x.source.endsWith(":")&&i(x.offset+x.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),y=x,v??(v=x.offset),u=!1,m=!1,b=!0;break;case"tag":{k&&i(x,"MULTIPLE_TAGS","A node can have at most one tag"),k=x,v??(v=x.offset),u=!1,m=!1,b=!0;break}case t:(y||k)&&i(x,"BAD_PROP_ORDER",`Anchors and tags must be after the ${x.source} indicator`),S&&i(x,"UNEXPECTED_TOKEN",`Unexpected ${x.source} in ${e??"collection"}`),S=x,u=t==="seq-item-ind"||t==="explicit-key-ind",m=!1;break;case"comma":if(e){w&&i(x,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),w=x,u=!1,m=!1;break}default:i(x,"UNEXPECTED_TOKEN",`Unexpected ${x.type} token`),u=!1,m=!1}const N=s[s.length-1],C=N?N.offset+N.source.length:r;return b&&n&&n.type!=="space"&&n.type!=="newline"&&n.type!=="comma"&&(n.type!=="scalar"||n.source!=="")&&i(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),p&&(u&&p.indent<=l||n?.type==="block-map"||n?.type==="block-seq")&&i(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:w,found:S,spaceBefore:c,comment:h,hasNewline:g,anchor:y,tag:k,newlineAfterProp:O,end:C,start:v??C}}function Ye(s){if(!s)return null;switch(s.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(s.source.includes(`
69
- `))return!0;if(s.end){for(const e of s.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(const e of s.items){for(const t of e.start)if(t.type==="newline")return!0;if(e.sep){for(const t of e.sep)if(t.type==="newline")return!0}if(Ye(e.key)||Ye(e.value))return!0}return!1;default:return!0}}function Gt(s,e,t){if(e?.type==="flow-collection"){const n=e.end[0];n.indent===s&&(n.source==="]"||n.source==="}")&&Ye(e)&&t(n,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function Yn(s,e,t){const{uniqueKeys:n}=s.options;if(n===!1)return!1;const r=typeof n=="function"?n:(i,l)=>i===l||j(i)&&j(l)&&i.value===l.value;return e.some(i=>r(i.key,t))}const qs="All mapping items must start at the same column";function La({composeNode:s,composeEmptyNode:e},t,n,r,i){const l=i?.nodeClass??X,o=new l(t.schema);t.atRoot&&(t.atRoot=!1);let c=n.offset,u=null;for(const m of n.items){const{start:h,key:f,sep:g,value:b}=m,p=Le(h,{indicator:"explicit-key-ind",next:f??g?.[0],offset:c,onError:r,parentIndent:n.indent,startOnNewline:!0}),y=!p.found;if(y){if(f&&(f.type==="block-seq"?r(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==n.indent&&r(c,"BAD_INDENT",qs)),!p.anchor&&!p.tag&&!g){u=p.end,p.comment&&(o.comment?o.comment+=`
70
- `+p.comment:o.comment=p.comment);continue}(p.newlineAfterProp||Ye(f))&&r(f??h[h.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else p.found?.indent!==n.indent&&r(c,"BAD_INDENT",qs);t.atKey=!0;const k=p.end,O=f?s(t,f,p,r):e(t,k,h,null,p,r);t.schema.compat&&Gt(n.indent,f,r),t.atKey=!1,Yn(t,o.items,O)&&r(k,"DUPLICATE_KEY","Map keys must be unique");const w=Le(g??[],{indicator:"map-value-ind",next:b,offset:O.range[2],onError:r,parentIndent:n.indent,startOnNewline:!f||f.type==="block-scalar"});if(c=w.end,w.found){y&&(b?.type==="block-map"&&!w.hasNewline&&r(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),t.options.strict&&p.start<w.found.offset-1024&&r(O.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));const S=b?s(t,b,w,r):e(t,c,g,null,w,r);t.schema.compat&&Gt(n.indent,b,r),c=S.range[2];const v=new q(O,S);t.options.keepSourceTokens&&(v.srcToken=m),o.items.push(v)}else{y&&r(O.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),w.comment&&(O.comment?O.comment+=`
71
- `+w.comment:O.comment=w.comment);const S=new q(O);t.options.keepSourceTokens&&(S.srcToken=m),o.items.push(S)}}return u&&u<c&&r(u,"IMPOSSIBLE","Map comment with trailing content"),o.range=[n.offset,c,u??c],o}function $a({composeNode:s,composeEmptyNode:e},t,n,r,i){const l=i?.nodeClass??Ne,o=new l(t.schema);t.atRoot&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let c=n.offset,u=null;for(const{start:m,value:h}of n.items){const f=Le(m,{indicator:"seq-item-ind",next:h,offset:c,onError:r,parentIndent:n.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||h)h?.type==="block-seq"?r(f.end,"BAD_INDENT","All sequence items must start at the same column"):r(c,"MISSING_CHAR","Sequence item without - indicator");else{u=f.end,f.comment&&(o.comment=f.comment);continue}const g=h?s(t,h,f,r):e(t,f.end,m,null,f,r);t.schema.compat&&Gt(n.indent,h,r),c=g.range[2],o.items.push(g)}return o.range=[n.offset,c,u??c],o}function et(s,e,t,n){let r="";if(s){let i=!1,l="";for(const o of s){const{source:c,type:u}=o;switch(u){case"space":i=!0;break;case"comment":{t&&!i&&n(o,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const m=c.substring(1)||" ";r?r+=l+m:r=m,l="";break}case"newline":r&&(l+=c),i=!0;break;default:n(o,"UNEXPECTED_TOKEN",`Unexpected ${u} at node end`)}e+=c.length}}return{comment:r,offset:e}}const Dt="Block collections are not allowed within flow collections",Ft=s=>s&&(s.type==="block-map"||s.type==="block-seq");function _a({composeNode:s,composeEmptyNode:e},t,n,r,i){const l=n.start.source==="{",o=l?"flow map":"flow sequence",c=i?.nodeClass??(l?X:Ne),u=new c(t.schema);u.flow=!0;const m=t.atRoot;m&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let h=n.offset+n.start.source.length;for(let y=0;y<n.items.length;++y){const k=n.items[y],{start:O,key:w,sep:S,value:v}=k,N=Le(O,{flow:o,indicator:"explicit-key-ind",next:w??S?.[0],offset:h,onError:r,parentIndent:n.indent,startOnNewline:!1});if(!N.found){if(!N.anchor&&!N.tag&&!S&&!v){y===0&&N.comma?r(N.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${o}`):y<n.items.length-1&&r(N.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${o}`),N.comment&&(u.comment?u.comment+=`
72
- `+N.comment:u.comment=N.comment),h=N.end;continue}!l&&t.options.strict&&Ye(w)&&r(w,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(y===0)N.comma&&r(N.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${o}`);else if(N.comma||r(N.start,"MISSING_CHAR",`Missing , between ${o} items`),N.comment){let C="";e:for(const x of O)switch(x.type){case"comma":case"space":break;case"comment":C=x.source.substring(1);break e;default:break e}if(C){let x=u.items[u.items.length-1];F(x)&&(x=x.value??x.key),x.comment?x.comment+=`
73
- `+C:x.comment=C,N.comment=N.comment.substring(C.length+1)}}if(!l&&!S&&!N.found){const C=v?s(t,v,N,r):e(t,N.end,S,null,N,r);u.items.push(C),h=C.range[2],Ft(v)&&r(C.range,"BLOCK_IN_FLOW",Dt)}else{t.atKey=!0;const C=N.end,x=w?s(t,w,N,r):e(t,C,O,null,N,r);Ft(w)&&r(x.range,"BLOCK_IN_FLOW",Dt),t.atKey=!1;const $=Le(S??[],{flow:o,indicator:"map-value-ind",next:v,offset:x.range[2],onError:r,parentIndent:n.indent,startOnNewline:!1});if($.found){if(!l&&!N.found&&t.options.strict){if(S)for(const R of S){if(R===$.found)break;if(R.type==="newline"){r(R,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}N.start<$.found.offset-1024&&r($.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else v&&("source"in v&&v.source?.[0]===":"?r(v,"MISSING_CHAR",`Missing space after : in ${o}`):r($.start,"MISSING_CHAR",`Missing , or : between ${o} items`));const H=v?s(t,v,$,r):$.found?e(t,$.end,S,null,$,r):null;H?Ft(v)&&r(H.range,"BLOCK_IN_FLOW",Dt):$.comment&&(x.comment?x.comment+=`
74
- `+$.comment:x.comment=$.comment);const Q=new q(x,H);if(t.options.keepSourceTokens&&(Q.srcToken=k),l){const R=u;Yn(t,R.items,x)&&r(C,"DUPLICATE_KEY","Map keys must be unique"),R.items.push(Q)}else{const R=new X(t.schema);R.flow=!0,R.items.push(Q);const tt=(H??x).range;R.range=[x.range[0],tt[1],tt[2]],u.items.push(R)}h=H?H.range[2]:$.end}}const f=l?"}":"]",[g,...b]=n.end;let p=h;if(g?.source===f)p=g.offset+g.source.length;else{const y=o[0].toUpperCase()+o.substring(1),k=m?`${y} must end with a ${f}`:`${y} in block collection must be sufficiently indented and end with a ${f}`;r(h,m?"MISSING_CHAR":"BAD_INDENT",k),g&&g.source.length!==1&&b.unshift(g)}if(b.length>0){const y=et(b,p,t.options.strict,r);y.comment&&(u.comment?u.comment+=`
75
- `+y.comment:u.comment=y.comment),u.range=[n.offset,p,y.offset]}else u.range=[n.offset,p,p];return u}function Kt(s,e,t,n,r,i){const l=t.type==="block-map"?La(s,e,t,n,i):t.type==="block-seq"?$a(s,e,t,n,i):_a(s,e,t,n,i),o=l.constructor;return r==="!"||r===o.tagName?(l.tag=o.tagName,l):(r&&(l.tag=r),l)}function ja(s,e,t,n,r){const i=n.tag,l=i?e.directives.tagName(i.source,f=>r(i,"TAG_RESOLVE_FAILED",f)):null;if(t.type==="block-seq"){const{anchor:f,newlineAfterProp:g}=n,b=f&&i?f.offset>i.offset?f:i:f??i;b&&(!g||g.offset<b.offset)&&r(b,"MISSING_CHAR","Missing newline after block sequence props")}const o=t.type==="block-map"?"map":t.type==="block-seq"?"seq":t.start.source==="{"?"map":"seq";if(!i||!l||l==="!"||l===X.tagName&&o==="map"||l===Ne.tagName&&o==="seq")return Kt(s,e,t,r,l);let c=e.schema.tags.find(f=>f.tag===l&&f.collection===o);if(!c){const f=e.schema.knownTags[l];if(f?.collection===o)e.schema.tags.push(Object.assign({},f,{default:!1})),c=f;else return f?r(i,"BAD_COLLECTION_TYPE",`${f.tag} used for ${o} collection, but expects ${f.collection??"scalar"}`,!0):r(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${l}`,!0),Kt(s,e,t,r,l)}const u=Kt(s,e,t,r,l,c),m=c.resolve?.(u,f=>r(i,"TAG_RESOLVE_FAILED",f),e.options)??u,h=D(m)?m:new A(m);return h.range=u.range,h.tag=l,c?.format&&(h.format=c.format),h}function Ma(s,e,t){const n=e.offset,r=Pa(e,s.options.strict,t);if(!r)return{value:"",type:null,comment:"",range:[n,n,n]};const i=r.mode===">"?A.BLOCK_FOLDED:A.BLOCK_LITERAL,l=e.source?Ra(e.source):[];let o=l.length;for(let p=l.length-1;p>=0;--p){const y=l[p][1];if(y===""||y==="\r")o=p;else break}if(o===0){const p=r.chomp==="+"&&l.length>0?`
76
- `.repeat(Math.max(1,l.length-1)):"";let y=n+r.length;return e.source&&(y+=e.source.length),{value:p,type:i,comment:r.comment,range:[n,y,y]}}let c=e.indent+r.indent,u=e.offset+r.length,m=0;for(let p=0;p<o;++p){const[y,k]=l[p];if(k===""||k==="\r")r.indent===0&&y.length>c&&(c=y.length);else{y.length<c&&t(u+y.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),r.indent===0&&(c=y.length),m=p,c===0&&!s.atRoot&&t(u,"BAD_INDENT","Block scalar values in collections must be indented");break}u+=y.length+k.length+1}for(let p=l.length-1;p>=o;--p)l[p][0].length>c&&(o=p+1);let h="",f="",g=!1;for(let p=0;p<m;++p)h+=l[p][0].slice(c)+`
77
- `;for(let p=m;p<o;++p){let[y,k]=l[p];u+=y.length+k.length+1;const O=k[k.length-1]==="\r";if(O&&(k=k.slice(0,-1)),k&&y.length<c){const S=`Block scalar lines must not be less indented than their ${r.indent?"explicit indentation indicator":"first line"}`;t(u-k.length-(O?2:1),"BAD_INDENT",S),y=""}i===A.BLOCK_LITERAL?(h+=f+y.slice(c)+k,f=`
78
- `):y.length>c||k[0]===" "?(f===" "?f=`
68
+ `}};function Ve(s,{flow:e,indicator:t,next:n,offset:r,onError:a,parentIndent:l,startOnNewline:c}){let d=!1,u=c,h=c,m="",f="",g=!1,w=!1,p=null,b=null,k=null,x=null,N=null,C=null,S=null;for(const v of s)switch(w&&(v.type!=="space"&&v.type!=="newline"&&v.type!=="comma"&&a(v.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),w=!1),p&&(u&&v.type!=="comment"&&v.type!=="newline"&&a(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),p=null),v.type){case"space":!e&&(t!=="doc-start"||n?.type!=="flow-collection")&&v.source.includes(" ")&&(p=v),h=!0;break;case"comment":{h||a(v,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const j=v.source.substring(1)||" ";m?m+=f+j:m=j,f="",u=!1;break}case"newline":u?m?m+=v.source:(!C||t!=="seq-item-ind")&&(d=!0):f+=v.source,u=!0,g=!0,(b||k)&&(x=v),h=!0;break;case"anchor":b&&a(v,"MULTIPLE_ANCHORS","A node can have at most one anchor"),v.source.endsWith(":")&&a(v.offset+v.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),b=v,S??(S=v.offset),u=!1,h=!1,w=!0;break;case"tag":{k&&a(v,"MULTIPLE_TAGS","A node can have at most one tag"),k=v,S??(S=v.offset),u=!1,h=!1,w=!0;break}case t:(b||k)&&a(v,"BAD_PROP_ORDER",`Anchors and tags must be after the ${v.source} indicator`),C&&a(v,"UNEXPECTED_TOKEN",`Unexpected ${v.source} in ${e??"collection"}`),C=v,u=t==="seq-item-ind"||t==="explicit-key-ind",h=!1;break;case"comma":if(e){N&&a(v,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),N=v,u=!1,h=!1;break}default:a(v,"UNEXPECTED_TOKEN",`Unexpected ${v.type} token`),u=!1,h=!1}const y=s[s.length-1],O=y?y.offset+y.source.length:r;return w&&n&&n.type!=="space"&&n.type!=="newline"&&n.type!=="comma"&&(n.type!=="scalar"||n.source!=="")&&a(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),p&&(u&&p.indent<=l||n?.type==="block-map"||n?.type==="block-seq")&&a(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:N,found:C,spaceBefore:d,comment:m,hasNewline:g,anchor:b,tag:k,newlineAfterProp:x,end:O,start:S??O}}function at(s){if(!s)return null;switch(s.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(s.source.includes(`
69
+ `))return!0;if(s.end){for(const e of s.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(const e of s.items){for(const t of e.start)if(t.type==="newline")return!0;if(e.sep){for(const t of e.sep)if(t.type==="newline")return!0}if(at(e.key)||at(e.value))return!0}return!1;default:return!0}}function hs(s,e,t){if(e?.type==="flow-collection"){const n=e.end[0];n.indent===s&&(n.source==="]"||n.source==="}")&&at(e)&&t(n,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function pr(s,e,t){const{uniqueKeys:n}=s.options;if(n===!1)return!1;const r=typeof n=="function"?n:(a,l)=>a===l||R(a)&&R(l)&&a.value===l.value;return e.some(a=>r(a.key,t))}const dn="All mapping items must start at the same column";function el({composeNode:s,composeEmptyNode:e},t,n,r,a){const l=a?.nodeClass??re,c=new l(t.schema);t.atRoot&&(t.atRoot=!1);let d=n.offset,u=null;for(const h of n.items){const{start:m,key:f,sep:g,value:w}=h,p=Ve(m,{indicator:"explicit-key-ind",next:f??g?.[0],offset:d,onError:r,parentIndent:n.indent,startOnNewline:!0}),b=!p.found;if(b){if(f&&(f.type==="block-seq"?r(d,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==n.indent&&r(d,"BAD_INDENT",dn)),!p.anchor&&!p.tag&&!g){u=p.end,p.comment&&(c.comment?c.comment+=`
70
+ `+p.comment:c.comment=p.comment);continue}(p.newlineAfterProp||at(f))&&r(f??m[m.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else p.found?.indent!==n.indent&&r(d,"BAD_INDENT",dn);t.atKey=!0;const k=p.end,x=f?s(t,f,p,r):e(t,k,m,null,p,r);t.schema.compat&&hs(n.indent,f,r),t.atKey=!1,pr(t,c.items,x)&&r(k,"DUPLICATE_KEY","Map keys must be unique");const N=Ve(g??[],{indicator:"map-value-ind",next:w,offset:x.range[2],onError:r,parentIndent:n.indent,startOnNewline:!f||f.type==="block-scalar"});if(d=N.end,N.found){b&&(w?.type==="block-map"&&!N.hasNewline&&r(d,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),t.options.strict&&p.start<N.found.offset-1024&&r(x.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));const C=w?s(t,w,N,r):e(t,d,g,null,N,r);t.schema.compat&&hs(n.indent,w,r),d=C.range[2];const S=new Z(x,C);t.options.keepSourceTokens&&(S.srcToken=h),c.items.push(S)}else{b&&r(x.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),N.comment&&(x.comment?x.comment+=`
71
+ `+N.comment:x.comment=N.comment);const C=new Z(x);t.options.keepSourceTokens&&(C.srcToken=h),c.items.push(C)}}return u&&u<d&&r(u,"IMPOSSIBLE","Map comment with trailing content"),c.range=[n.offset,d,u??d],c}function tl({composeNode:s,composeEmptyNode:e},t,n,r,a){const l=a?.nodeClass??Ae,c=new l(t.schema);t.atRoot&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let d=n.offset,u=null;for(const{start:h,value:m}of n.items){const f=Ve(h,{indicator:"seq-item-ind",next:m,offset:d,onError:r,parentIndent:n.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||m)m?.type==="block-seq"?r(f.end,"BAD_INDENT","All sequence items must start at the same column"):r(d,"MISSING_CHAR","Sequence item without - indicator");else{u=f.end,f.comment&&(c.comment=f.comment);continue}const g=m?s(t,m,f,r):e(t,f.end,h,null,f,r);t.schema.compat&&hs(n.indent,m,r),d=g.range[2],c.items.push(g)}return c.range=[n.offset,d,u??d],c}function mt(s,e,t,n){let r="";if(s){let a=!1,l="";for(const c of s){const{source:d,type:u}=c;switch(u){case"space":a=!0;break;case"comment":{t&&!a&&n(c,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const h=d.substring(1)||" ";r?r+=l+h:r=h,l="";break}case"newline":r&&(l+=d),a=!0;break;default:n(c,"UNEXPECTED_TOKEN",`Unexpected ${u} at node end`)}e+=d.length}}return{comment:r,offset:e}}const ss="Block collections are not allowed within flow collections",ns=s=>s&&(s.type==="block-map"||s.type==="block-seq");function sl({composeNode:s,composeEmptyNode:e},t,n,r,a){const l=n.start.source==="{",c=l?"flow map":"flow sequence",d=a?.nodeClass??(l?re:Ae),u=new d(t.schema);u.flow=!0;const h=t.atRoot;h&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let m=n.offset+n.start.source.length;for(let b=0;b<n.items.length;++b){const k=n.items[b],{start:x,key:N,sep:C,value:S}=k,y=Ve(x,{flow:c,indicator:"explicit-key-ind",next:N??C?.[0],offset:m,onError:r,parentIndent:n.indent,startOnNewline:!1});if(!y.found){if(!y.anchor&&!y.tag&&!C&&!S){b===0&&y.comma?r(y.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${c}`):b<n.items.length-1&&r(y.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${c}`),y.comment&&(u.comment?u.comment+=`
72
+ `+y.comment:u.comment=y.comment),m=y.end;continue}!l&&t.options.strict&&at(N)&&r(N,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(b===0)y.comma&&r(y.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${c}`);else if(y.comma||r(y.start,"MISSING_CHAR",`Missing , between ${c} items`),y.comment){let O="";e:for(const v of x)switch(v.type){case"comma":case"space":break;case"comment":O=v.source.substring(1);break e;default:break e}if(O){let v=u.items[u.items.length-1];U(v)&&(v=v.value??v.key),v.comment?v.comment+=`
73
+ `+O:v.comment=O,y.comment=y.comment.substring(O.length+1)}}if(!l&&!C&&!y.found){const O=S?s(t,S,y,r):e(t,y.end,C,null,y,r);u.items.push(O),m=O.range[2],ns(S)&&r(O.range,"BLOCK_IN_FLOW",ss)}else{t.atKey=!0;const O=y.end,v=N?s(t,N,y,r):e(t,O,x,null,y,r);ns(N)&&r(v.range,"BLOCK_IN_FLOW",ss),t.atKey=!1;const j=Ve(C??[],{flow:c,indicator:"map-value-ind",next:S,offset:v.range[2],onError:r,parentIndent:n.indent,startOnNewline:!1});if(j.found){if(!l&&!y.found&&t.options.strict){if(C)for(const D of C){if(D===j.found)break;if(D.type==="newline"){r(D,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}y.start<j.found.offset-1024&&r(j.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else S&&("source"in S&&S.source?.[0]===":"?r(S,"MISSING_CHAR",`Missing space after : in ${c}`):r(j.start,"MISSING_CHAR",`Missing , or : between ${c} items`));const H=S?s(t,S,j,r):j.found?e(t,j.end,C,null,j,r):null;H?ns(S)&&r(H.range,"BLOCK_IN_FLOW",ss):j.comment&&(v.comment?v.comment+=`
74
+ `+j.comment:v.comment=j.comment);const W=new Z(v,H);if(t.options.keepSourceTokens&&(W.srcToken=k),l){const D=u;pr(t,D.items,v)&&r(O,"DUPLICATE_KEY","Map keys must be unique"),D.items.push(W)}else{const D=new re(t.schema);D.flow=!0,D.items.push(W);const I=(H??v).range;D.range=[v.range[0],I[1],I[2]],u.items.push(D)}m=H?H.range[2]:j.end}}const f=l?"}":"]",[g,...w]=n.end;let p=m;if(g?.source===f)p=g.offset+g.source.length;else{const b=c[0].toUpperCase()+c.substring(1),k=h?`${b} must end with a ${f}`:`${b} in block collection must be sufficiently indented and end with a ${f}`;r(m,h?"MISSING_CHAR":"BAD_INDENT",k),g&&g.source.length!==1&&w.unshift(g)}if(w.length>0){const b=mt(w,p,t.options.strict,r);b.comment&&(u.comment?u.comment+=`
75
+ `+b.comment:u.comment=b.comment),u.range=[n.offset,p,b.offset]}else u.range=[n.offset,p,p];return u}function rs(s,e,t,n,r,a){const l=t.type==="block-map"?el(s,e,t,n,a):t.type==="block-seq"?tl(s,e,t,n,a):sl(s,e,t,n,a),c=l.constructor;return r==="!"||r===c.tagName?(l.tag=c.tagName,l):(r&&(l.tag=r),l)}function nl(s,e,t,n,r){const a=n.tag,l=a?e.directives.tagName(a.source,f=>r(a,"TAG_RESOLVE_FAILED",f)):null;if(t.type==="block-seq"){const{anchor:f,newlineAfterProp:g}=n,w=f&&a?f.offset>a.offset?f:a:f??a;w&&(!g||g.offset<w.offset)&&r(w,"MISSING_CHAR","Missing newline after block sequence props")}const c=t.type==="block-map"?"map":t.type==="block-seq"?"seq":t.start.source==="{"?"map":"seq";if(!a||!l||l==="!"||l===re.tagName&&c==="map"||l===Ae.tagName&&c==="seq")return rs(s,e,t,r,l);let d=e.schema.tags.find(f=>f.tag===l&&f.collection===c);if(!d){const f=e.schema.knownTags[l];if(f?.collection===c)e.schema.tags.push(Object.assign({},f,{default:!1})),d=f;else return f?r(a,"BAD_COLLECTION_TYPE",`${f.tag} used for ${c} collection, but expects ${f.collection??"scalar"}`,!0):r(a,"TAG_RESOLVE_FAILED",`Unresolved tag: ${l}`,!0),rs(s,e,t,r,l)}const u=rs(s,e,t,r,l,d),h=d.resolve?.(u,f=>r(a,"TAG_RESOLVE_FAILED",f),e.options)??u,m=K(h)?h:new L(h);return m.range=u.range,m.tag=l,d?.format&&(m.format=d.format),m}function rl(s,e,t){const n=e.offset,r=il(e,s.options.strict,t);if(!r)return{value:"",type:null,comment:"",range:[n,n,n]};const a=r.mode===">"?L.BLOCK_FOLDED:L.BLOCK_LITERAL,l=e.source?al(e.source):[];let c=l.length;for(let p=l.length-1;p>=0;--p){const b=l[p][1];if(b===""||b==="\r")c=p;else break}if(c===0){const p=r.chomp==="+"&&l.length>0?`
76
+ `.repeat(Math.max(1,l.length-1)):"";let b=n+r.length;return e.source&&(b+=e.source.length),{value:p,type:a,comment:r.comment,range:[n,b,b]}}let d=e.indent+r.indent,u=e.offset+r.length,h=0;for(let p=0;p<c;++p){const[b,k]=l[p];if(k===""||k==="\r")r.indent===0&&b.length>d&&(d=b.length);else{b.length<d&&t(u+b.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),r.indent===0&&(d=b.length),h=p,d===0&&!s.atRoot&&t(u,"BAD_INDENT","Block scalar values in collections must be indented");break}u+=b.length+k.length+1}for(let p=l.length-1;p>=c;--p)l[p][0].length>d&&(c=p+1);let m="",f="",g=!1;for(let p=0;p<h;++p)m+=l[p][0].slice(d)+`
77
+ `;for(let p=h;p<c;++p){let[b,k]=l[p];u+=b.length+k.length+1;const x=k[k.length-1]==="\r";if(x&&(k=k.slice(0,-1)),k&&b.length<d){const C=`Block scalar lines must not be less indented than their ${r.indent?"explicit indentation indicator":"first line"}`;t(u-k.length-(x?2:1),"BAD_INDENT",C),b=""}a===L.BLOCK_LITERAL?(m+=f+b.slice(d)+k,f=`
78
+ `):b.length>d||k[0]===" "?(f===" "?f=`
79
79
  `:!g&&f===`
80
80
  `&&(f=`
81
81
 
82
- `),h+=f+y.slice(c)+k,f=`
82
+ `),m+=f+b.slice(d)+k,f=`
83
83
  `,g=!0):k===""?f===`
84
- `?h+=`
84
+ `?m+=`
85
85
  `:f=`
86
- `:(h+=f+k,f=" ",g=!1)}switch(r.chomp){case"-":break;case"+":for(let p=o;p<l.length;++p)h+=`
87
- `+l[p][0].slice(c);h[h.length-1]!==`
88
- `&&(h+=`
89
- `);break;default:h+=`
90
- `}const b=n+r.length+e.source.length;return{value:h,type:i,comment:r.comment,range:[n,b,b]}}function Pa({offset:s,props:e},t,n){if(e[0].type!=="block-scalar-header")return n(e[0],"IMPOSSIBLE","Block scalar header not found"),null;const{source:r}=e[0],i=r[0];let l=0,o="",c=-1;for(let f=1;f<r.length;++f){const g=r[f];if(!o&&(g==="-"||g==="+"))o=g;else{const b=Number(g);!l&&b?l=b:c===-1&&(c=s+f)}}c!==-1&&n(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${r}`);let u=!1,m="",h=r.length;for(let f=1;f<e.length;++f){const g=e[f];switch(g.type){case"space":u=!0;case"newline":h+=g.source.length;break;case"comment":t&&!u&&n(g,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),h+=g.source.length,m=g.source.substring(1);break;case"error":n(g,"UNEXPECTED_TOKEN",g.message),h+=g.source.length;break;default:{const b=`Unexpected token in block scalar header: ${g.type}`;n(g,"UNEXPECTED_TOKEN",b);const p=g.source;p&&typeof p=="string"&&(h+=p.length)}}}return{mode:i,indent:l,chomp:o,comment:m,length:h}}function Ra(s){const e=s.split(/\n( *)/),t=e[0],n=t.match(/^( *)/),i=[n?.[1]?[n[1],t.slice(n[1].length)]:["",t]];for(let l=1;l<e.length;l+=2)i.push([e[l],e[l+1]]);return i}function Ba(s,e,t){const{offset:n,type:r,source:i,end:l}=s;let o,c;const u=(f,g,b)=>t(n+f,g,b);switch(r){case"scalar":o=A.PLAIN,c=Da(i,u);break;case"single-quoted-scalar":o=A.QUOTE_SINGLE,c=Fa(i,u);break;case"double-quoted-scalar":o=A.QUOTE_DOUBLE,c=Ka(i,u);break;default:return t(s,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${r}`),{value:"",type:null,comment:"",range:[n,n+i.length,n+i.length]}}const m=n+i.length,h=et(l,m,e,t);return{value:c,type:o,comment:h.comment,range:[n,m,h.offset]}}function Da(s,e){let t="";switch(s[0]){case" ":t="a tab character";break;case",":t="flow indicator character ,";break;case"%":t="directive indicator character %";break;case"|":case">":{t=`block scalar indicator ${s[0]}`;break}case"@":case"`":{t=`reserved character ${s[0]}`;break}}return t&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${t}`),Wn(s)}function Fa(s,e){return(s[s.length-1]!=="'"||s.length===1)&&e(s.length,"MISSING_CHAR","Missing closing 'quote"),Wn(s.slice(1,-1)).replace(/''/g,"'")}function Wn(s){let e,t;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
86
+ `:(m+=f+k,f=" ",g=!1)}switch(r.chomp){case"-":break;case"+":for(let p=c;p<l.length;++p)m+=`
87
+ `+l[p][0].slice(d);m[m.length-1]!==`
88
+ `&&(m+=`
89
+ `);break;default:m+=`
90
+ `}const w=n+r.length+e.source.length;return{value:m,type:a,comment:r.comment,range:[n,w,w]}}function il({offset:s,props:e},t,n){if(e[0].type!=="block-scalar-header")return n(e[0],"IMPOSSIBLE","Block scalar header not found"),null;const{source:r}=e[0],a=r[0];let l=0,c="",d=-1;for(let f=1;f<r.length;++f){const g=r[f];if(!c&&(g==="-"||g==="+"))c=g;else{const w=Number(g);!l&&w?l=w:d===-1&&(d=s+f)}}d!==-1&&n(d,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${r}`);let u=!1,h="",m=r.length;for(let f=1;f<e.length;++f){const g=e[f];switch(g.type){case"space":u=!0;case"newline":m+=g.source.length;break;case"comment":t&&!u&&n(g,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),m+=g.source.length,h=g.source.substring(1);break;case"error":n(g,"UNEXPECTED_TOKEN",g.message),m+=g.source.length;break;default:{const w=`Unexpected token in block scalar header: ${g.type}`;n(g,"UNEXPECTED_TOKEN",w);const p=g.source;p&&typeof p=="string"&&(m+=p.length)}}}return{mode:a,indent:l,chomp:c,comment:h,length:m}}function al(s){const e=s.split(/\n( *)/),t=e[0],n=t.match(/^( *)/),a=[n?.[1]?[n[1],t.slice(n[1].length)]:["",t]];for(let l=1;l<e.length;l+=2)a.push([e[l],e[l+1]]);return a}function ll(s,e,t){const{offset:n,type:r,source:a,end:l}=s;let c,d;const u=(f,g,w)=>t(n+f,g,w);switch(r){case"scalar":c=L.PLAIN,d=ol(a,u);break;case"single-quoted-scalar":c=L.QUOTE_SINGLE,d=cl(a,u);break;case"double-quoted-scalar":c=L.QUOTE_DOUBLE,d=dl(a,u);break;default:return t(s,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${r}`),{value:"",type:null,comment:"",range:[n,n+a.length,n+a.length]}}const h=n+a.length,m=mt(l,h,e,t);return{value:d,type:c,comment:m.comment,range:[n,h,m.offset]}}function ol(s,e){let t="";switch(s[0]){case" ":t="a tab character";break;case",":t="flow indicator character ,";break;case"%":t="directive indicator character %";break;case"|":case">":{t=`block scalar indicator ${s[0]}`;break}case"@":case"`":{t=`reserved character ${s[0]}`;break}}return t&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${t}`),gr(s)}function cl(s,e){return(s[s.length-1]!=="'"||s.length===1)&&e(s.length,"MISSING_CHAR","Missing closing 'quote"),gr(s.slice(1,-1)).replace(/''/g,"'")}function gr(s){let e,t;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
91
91
  `,"sy"),t=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
92
- `,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,t=/[ \t]*(.*?)[ \t]*\r?\n/sy}let n=e.exec(s);if(!n)return s;let r=n[1],i=" ",l=e.lastIndex;for(t.lastIndex=l;n=t.exec(s);)n[1]===""?i===`
93
- `?r+=i:i=`
94
- `:(r+=i+n[1],i=" "),l=t.lastIndex;const o=/[ \t]*(.*)/sy;return o.lastIndex=l,n=o.exec(s),r+i+(n?.[1]??"")}function Ka(s,e){let t="";for(let n=1;n<s.length-1;++n){const r=s[n];if(!(r==="\r"&&s[n+1]===`
92
+ `,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,t=/[ \t]*(.*?)[ \t]*\r?\n/sy}let n=e.exec(s);if(!n)return s;let r=n[1],a=" ",l=e.lastIndex;for(t.lastIndex=l;n=t.exec(s);)n[1]===""?a===`
93
+ `?r+=a:a=`
94
+ `:(r+=a+n[1],a=" "),l=t.lastIndex;const c=/[ \t]*(.*)/sy;return c.lastIndex=l,n=c.exec(s),r+a+(n?.[1]??"")}function dl(s,e){let t="";for(let n=1;n<s.length-1;++n){const r=s[n];if(!(r==="\r"&&s[n+1]===`
95
95
  `))if(r===`
96
- `){const{fold:i,offset:l}=Ua(s,n);t+=i,n=l}else if(r==="\\"){let i=s[++n];const l=Va[i];if(l)t+=l;else if(i===`
97
- `)for(i=s[n+1];i===" "||i===" ";)i=s[++n+1];else if(i==="\r"&&s[n+1]===`
98
- `)for(i=s[++n+1];i===" "||i===" ";)i=s[++n+1];else if(i==="x"||i==="u"||i==="U"){const o={x:2,u:4,U:8}[i];t+=qa(s,n+1,o,e),n+=o}else{const o=s.substr(n-1,2);e(n-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${o}`),t+=o}}else if(r===" "||r===" "){const i=n;let l=s[n+1];for(;l===" "||l===" ";)l=s[++n+1];l!==`
96
+ `){const{fold:a,offset:l}=ul(s,n);t+=a,n=l}else if(r==="\\"){let a=s[++n];const l=fl[a];if(l)t+=l;else if(a===`
97
+ `)for(a=s[n+1];a===" "||a===" ";)a=s[++n+1];else if(a==="\r"&&s[n+1]===`
98
+ `)for(a=s[++n+1];a===" "||a===" ";)a=s[++n+1];else if(a==="x"||a==="u"||a==="U"){const c={x:2,u:4,U:8}[a];t+=hl(s,n+1,c,e),n+=c}else{const c=s.substr(n-1,2);e(n-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${c}`),t+=c}}else if(r===" "||r===" "){const a=n;let l=s[n+1];for(;l===" "||l===" ";)l=s[++n+1];l!==`
99
99
  `&&!(l==="\r"&&s[n+2]===`
100
- `)&&(t+=n>i?s.slice(i,n+1):r)}else t+=r}return(s[s.length-1]!=='"'||s.length===1)&&e(s.length,"MISSING_CHAR",'Missing closing "quote'),t}function Ua(s,e){let t="",n=s[e+1];for(;(n===" "||n===" "||n===`
100
+ `)&&(t+=n>a?s.slice(a,n+1):r)}else t+=r}return(s[s.length-1]!=='"'||s.length===1)&&e(s.length,"MISSING_CHAR",'Missing closing "quote'),t}function ul(s,e){let t="",n=s[e+1];for(;(n===" "||n===" "||n===`
101
101
  `||n==="\r")&&!(n==="\r"&&s[e+2]!==`
102
102
  `);)n===`
103
103
  `&&(t+=`
104
- `),e+=1,n=s[e+1];return t||(t=" "),{fold:t,offset:e}}const Va={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
105
- `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function qa(s,e,t,n){const r=s.substr(e,t),l=r.length===t&&/^[0-9a-fA-F]+$/.test(r)?parseInt(r,16):NaN;if(isNaN(l)){const o=s.substr(e-2,t+2);return n(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${o}`),o}return String.fromCodePoint(l)}function Gn(s,e,t,n){const{value:r,type:i,comment:l,range:o}=e.type==="block-scalar"?Ma(s,e,n):Ba(e,s.options.strict,n),c=t?s.directives.tagName(t.source,h=>n(t,"TAG_RESOLVE_FAILED",h)):null;let u;s.options.stringKeys&&s.atKey?u=s.schema[oe]:c?u=Ja(s.schema,r,c,t,n):e.type==="scalar"?u=za(s,r,e,n):u=s.schema[oe];let m;try{const h=u.resolve(r,f=>n(t??e,"TAG_RESOLVE_FAILED",f),s.options);m=j(h)?h:new A(h)}catch(h){const f=h instanceof Error?h.message:String(h);n(t??e,"TAG_RESOLVE_FAILED",f),m=new A(r)}return m.range=o,m.source=r,i&&(m.type=i),c&&(m.tag=c),u.format&&(m.format=u.format),l&&(m.comment=l),m}function Ja(s,e,t,n,r){if(t==="!")return s[oe];const i=[];for(const o of s.tags)if(!o.collection&&o.tag===t)if(o.default&&o.test)i.push(o);else return o;for(const o of i)if(o.test?.test(e))return o;const l=s.knownTags[t];return l&&!l.collection?(s.tags.push(Object.assign({},l,{default:!1,test:void 0})),l):(r(n,"TAG_RESOLVE_FAILED",`Unresolved tag: ${t}`,t!=="tag:yaml.org,2002:str"),s[oe])}function za({atKey:s,directives:e,schema:t},n,r,i){const l=t.tags.find(o=>(o.default===!0||s&&o.default==="key")&&o.test?.test(n))||t[oe];if(t.compat){const o=t.compat.find(c=>c.default&&c.test?.test(n))??t[oe];if(l.tag!==o.tag){const c=e.tagString(l.tag),u=e.tagString(o.tag),m=`Value may be parsed as either ${c} or ${u}`;i(r,"TAG_RESOLVE_FAILED",m,!0)}}return l}function Ya(s,e,t){if(e){t??(t=e.length);for(let n=t-1;n>=0;--n){let r=e[n];switch(r.type){case"space":case"comment":case"newline":s-=r.source.length;continue}for(r=e[++n];r?.type==="space";)s+=r.source.length,r=e[++n];break}}return s}const Wa={composeNode:Hn,composeEmptyNode:Is};function Hn(s,e,t,n){const r=s.atKey,{spaceBefore:i,comment:l,anchor:o,tag:c}=t;let u,m=!0;switch(e.type){case"alias":u=Ga(s,e,n),(o||c)&&n(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":u=Gn(s,e,c,n),o&&(u.anchor=o.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":u=ja(Wa,s,e,t,n),o&&(u.anchor=o.source.substring(1));break;default:{const h=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;n(e,"UNEXPECTED_TOKEN",h),u=Is(s,e.offset,void 0,null,t,n),m=!1}}return o&&u.anchor===""&&n(o,"BAD_ALIAS","Anchor cannot be an empty string"),r&&s.options.stringKeys&&(!j(u)||typeof u.value!="string"||u.tag&&u.tag!=="tag:yaml.org,2002:str")&&n(c??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),i&&(u.spaceBefore=!0),l&&(e.type==="scalar"&&e.source===""?u.comment=l:u.commentBefore=l),s.options.keepSourceTokens&&m&&(u.srcToken=e),u}function Is(s,e,t,n,{spaceBefore:r,comment:i,anchor:l,tag:o,end:c},u){const m={type:"scalar",offset:Ya(e,t,n),indent:-1,source:""},h=Gn(s,m,o,u);return l&&(h.anchor=l.source.substring(1),h.anchor===""&&u(l,"BAD_ALIAS","Anchor cannot be an empty string")),r&&(h.spaceBefore=!0),i&&(h.comment=i,h.range[2]=c),h}function Ga({options:s},{offset:e,source:t,end:n},r){const i=new ys(t.substring(1));i.source===""&&r(e,"BAD_ALIAS","Alias cannot be an empty string"),i.source.endsWith(":")&&r(e+t.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);const l=e+t.length,o=et(n,l,s.strict,r);return i.range=[e,l,o.offset],o.comment&&(i.comment=o.comment),i}function Ha(s,e,{offset:t,start:n,value:r,end:i},l){const o=Object.assign({_directives:e},s),c=new Ze(void 0,o),u={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},m=Le(n,{indicator:"doc-start",next:r??i?.[0],offset:t,onError:l,parentIndent:0,startOnNewline:!0});m.found&&(c.directives.docStart=!0,r&&(r.type==="block-map"||r.type==="block-seq")&&!m.hasNewline&&l(m.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=r?Hn(u,r,m,l):Is(u,m.end,n,null,m,l);const h=c.contents.range[2],f=et(i,h,!1,l);return f.comment&&(c.comment=f.comment),c.range=[t,h,f.offset],c}function Pe(s){if(typeof s=="number")return[s,s+1];if(Array.isArray(s))return s.length===2?s:[s[0],s[1]];const{offset:e,source:t}=s;return[e,e+(typeof t=="string"?t.length:1)]}function Js(s){let e="",t=!1,n=!1;for(let r=0;r<s.length;++r){const i=s[r];switch(i[0]){case"#":e+=(e===""?"":n?`
104
+ `),e+=1,n=s[e+1];return t||(t=" "),{fold:t,offset:e}}const fl={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
105
+ `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function hl(s,e,t,n){const r=s.substr(e,t),l=r.length===t&&/^[0-9a-fA-F]+$/.test(r)?parseInt(r,16):NaN;if(isNaN(l)){const c=s.substr(e-2,t+2);return n(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${c}`),c}return String.fromCodePoint(l)}function yr(s,e,t,n){const{value:r,type:a,comment:l,range:c}=e.type==="block-scalar"?rl(s,e,n):ll(e,s.options.strict,n),d=t?s.directives.tagName(t.source,m=>n(t,"TAG_RESOLVE_FAILED",m)):null;let u;s.options.stringKeys&&s.atKey?u=s.schema[he]:d?u=ml(s.schema,r,d,t,n):e.type==="scalar"?u=pl(s,r,e,n):u=s.schema[he];let h;try{const m=u.resolve(r,f=>n(t??e,"TAG_RESOLVE_FAILED",f),s.options);h=R(m)?m:new L(m)}catch(m){const f=m instanceof Error?m.message:String(m);n(t??e,"TAG_RESOLVE_FAILED",f),h=new L(r)}return h.range=c,h.source=r,a&&(h.type=a),d&&(h.tag=d),u.format&&(h.format=u.format),l&&(h.comment=l),h}function ml(s,e,t,n,r){if(t==="!")return s[he];const a=[];for(const c of s.tags)if(!c.collection&&c.tag===t)if(c.default&&c.test)a.push(c);else return c;for(const c of a)if(c.test?.test(e))return c;const l=s.knownTags[t];return l&&!l.collection?(s.tags.push(Object.assign({},l,{default:!1,test:void 0})),l):(r(n,"TAG_RESOLVE_FAILED",`Unresolved tag: ${t}`,t!=="tag:yaml.org,2002:str"),s[he])}function pl({atKey:s,directives:e,schema:t},n,r,a){const l=t.tags.find(c=>(c.default===!0||s&&c.default==="key")&&c.test?.test(n))||t[he];if(t.compat){const c=t.compat.find(d=>d.default&&d.test?.test(n))??t[he];if(l.tag!==c.tag){const d=e.tagString(l.tag),u=e.tagString(c.tag),h=`Value may be parsed as either ${d} or ${u}`;a(r,"TAG_RESOLVE_FAILED",h,!0)}}return l}function gl(s,e,t){if(e){t??(t=e.length);for(let n=t-1;n>=0;--n){let r=e[n];switch(r.type){case"space":case"comment":case"newline":s-=r.source.length;continue}for(r=e[++n];r?.type==="space";)s+=r.source.length,r=e[++n];break}}return s}const yl={composeNode:br,composeEmptyNode:zs};function br(s,e,t,n){const r=s.atKey,{spaceBefore:a,comment:l,anchor:c,tag:d}=t;let u,h=!0;switch(e.type){case"alias":u=bl(s,e,n),(c||d)&&n(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":u=yr(s,e,d,n),c&&(u.anchor=c.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":u=nl(yl,s,e,t,n),c&&(u.anchor=c.source.substring(1));break;default:{const m=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;n(e,"UNEXPECTED_TOKEN",m),u=zs(s,e.offset,void 0,null,t,n),h=!1}}return c&&u.anchor===""&&n(c,"BAD_ALIAS","Anchor cannot be an empty string"),r&&s.options.stringKeys&&(!R(u)||typeof u.value!="string"||u.tag&&u.tag!=="tag:yaml.org,2002:str")&&n(d??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),a&&(u.spaceBefore=!0),l&&(e.type==="scalar"&&e.source===""?u.comment=l:u.commentBefore=l),s.options.keepSourceTokens&&h&&(u.srcToken=e),u}function zs(s,e,t,n,{spaceBefore:r,comment:a,anchor:l,tag:c,end:d},u){const h={type:"scalar",offset:gl(e,t,n),indent:-1,source:""},m=yr(s,h,c,u);return l&&(m.anchor=l.source.substring(1),m.anchor===""&&u(l,"BAD_ALIAS","Anchor cannot be an empty string")),r&&(m.spaceBefore=!0),a&&(m.comment=a,m.range[2]=d),m}function bl({options:s},{offset:e,source:t,end:n},r){const a=new js(t.substring(1));a.source===""&&r(e,"BAD_ALIAS","Alias cannot be an empty string"),a.source.endsWith(":")&&r(e+t.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);const l=e+t.length,c=mt(n,l,s.strict,r);return a.range=[e,l,c.offset],c.comment&&(a.comment=c.comment),a}function Nl(s,e,{offset:t,start:n,value:r,end:a},l){const c=Object.assign({_directives:e},s),d=new ht(void 0,c),u={atKey:!1,atRoot:!0,directives:d.directives,options:d.options,schema:d.schema},h=Ve(n,{indicator:"doc-start",next:r??a?.[0],offset:t,onError:l,parentIndent:0,startOnNewline:!0});h.found&&(d.directives.docStart=!0,r&&(r.type==="block-map"||r.type==="block-seq")&&!h.hasNewline&&l(h.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),d.contents=r?br(u,r,h,l):zs(u,h.end,n,null,h,l);const m=d.contents.range[2],f=mt(a,m,!1,l);return f.comment&&(d.comment=f.comment),d.range=[t,m,f.offset],d}function Ge(s){if(typeof s=="number")return[s,s+1];if(Array.isArray(s))return s.length===2?s:[s[0],s[1]];const{offset:e,source:t}=s;return[e,e+(typeof t=="string"?t.length:1)]}function un(s){let e="",t=!1,n=!1;for(let r=0;r<s.length;++r){const a=s[r];switch(a[0]){case"#":e+=(e===""?"":n?`
106
106
 
107
107
  `:`
108
- `)+(i.substring(1)||" "),t=!0,n=!1;break;case"%":s[r+1]?.[0]!=="#"&&(r+=1),t=!1;break;default:t||(n=!0),t=!1}}return{comment:e,afterEmptyLine:n}}class Qa{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,n,r,i)=>{const l=Pe(t);i?this.warnings.push(new Ea(l,n,r)):this.errors.push(new Be(l,n,r))},this.directives=new K({version:e.version||"1.2"}),this.options=e}decorate(e,t){const{comment:n,afterEmptyLine:r}=Js(this.prelude);if(n){const i=e.contents;if(t)e.comment=e.comment?`${e.comment}
109
- ${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(B(i)&&!i.flow&&i.items.length>0){let l=i.items[0];F(l)&&(l=l.key);const o=l.commentBefore;l.commentBefore=o?`${n}
110
- ${o}`:n}else{const l=i.commentBefore;i.commentBefore=l?`${n}
111
- ${l}`:n}}t?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Js(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(const r of e)yield*this.next(r);yield*this.end(t,n)}*next(e){switch(e.type){case"directive":this.directives.add(e.source,(t,n,r)=>{const i=Pe(e);i[0]+=t,this.onError(i,"BAD_DIRECTIVE",n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{const t=Ha(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{const t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new Be(Pe(e),"UNEXPECTED_TOKEN",t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case"doc-end":{if(!this.doc){const n="Unexpected doc-end without preceding document";this.errors.push(new Be(Pe(e),"UNEXPECTED_TOKEN",n));break}this.doc.directives.docEnd=!0;const t=et(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){const n=this.doc.comment;this.doc.comment=n?`${n}
112
- ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new Be(Pe(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){const n=Object.assign({_directives:this.directives},this.options),r=new Ze(void 0,n);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),r.range=[0,t,t],this.decorate(r,!1),yield r}}}const Qn="\uFEFF",Xn="",Zn="",Ht="";function Xa(s){switch(s){case Qn:return"byte-order-mark";case Xn:return"doc-mode";case Zn:return"flow-error-end";case Ht:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
108
+ `)+(a.substring(1)||" "),t=!0,n=!1;break;case"%":s[r+1]?.[0]!=="#"&&(r+=1),t=!1;break;default:t||(n=!0),t=!1}}return{comment:e,afterEmptyLine:n}}class wl{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,n,r,a)=>{const l=Ge(t);a?this.warnings.push(new Za(l,n,r)):this.errors.push(new Qe(l,n,r))},this.directives=new Q({version:e.version||"1.2"}),this.options=e}decorate(e,t){const{comment:n,afterEmptyLine:r}=un(this.prelude);if(n){const a=e.contents;if(t)e.comment=e.comment?`${e.comment}
109
+ ${n}`:n;else if(r||e.directives.docStart||!a)e.commentBefore=n;else if(F(a)&&!a.flow&&a.items.length>0){let l=a.items[0];U(l)&&(l=l.key);const c=l.commentBefore;l.commentBefore=c?`${n}
110
+ ${c}`:n}else{const l=a.commentBefore;a.commentBefore=l?`${n}
111
+ ${l}`:n}}t?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:un(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(const r of e)yield*this.next(r);yield*this.end(t,n)}*next(e){switch(e.type){case"directive":this.directives.add(e.source,(t,n,r)=>{const a=Ge(e);a[0]+=t,this.onError(a,"BAD_DIRECTIVE",n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{const t=Nl(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{const t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new Qe(Ge(e),"UNEXPECTED_TOKEN",t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case"doc-end":{if(!this.doc){const n="Unexpected doc-end without preceding document";this.errors.push(new Qe(Ge(e),"UNEXPECTED_TOKEN",n));break}this.doc.directives.docEnd=!0;const t=mt(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){const n=this.doc.comment;this.doc.comment=n?`${n}
112
+ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new Qe(Ge(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){const n=Object.assign({_directives:this.directives},this.options),r=new ht(void 0,n);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),r.range=[0,t,t],this.decorate(r,!1),yield r}}}const Nr="\uFEFF",wr="",xr="",ms="";function xl(s){switch(s){case Nr:return"byte-order-mark";case wr:return"doc-mode";case xr:return"flow-error-end";case ms:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
113
113
  `:case`\r
114
- `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(s[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}function te(s){switch(s){case void 0:case" ":case`
115
- `:case"\r":case" ":return!0;default:return!1}}const zs=new Set("0123456789ABCDEFabcdef"),Za=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),it=new Set(",[]{}"),el=new Set(` ,[]{}
116
- \r `),Ut=s=>!s||el.has(s);class tl{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??"stream";for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===" "||t===" ";)t=this.buffer[++e];return!t||t==="#"||t===`
114
+ `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(s[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}function le(s){switch(s){case void 0:case" ":case`
115
+ `:case"\r":case" ":return!0;default:return!1}}const fn=new Set("0123456789ABCDEFabcdef"),vl=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Nt=new Set(",[]{}"),kl=new Set(` ,[]{}
116
+ \r `),is=s=>!s||kl.has(s);class Sl{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??"stream";for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===" "||t===" ";)t=this.buffer[++e];return!t||t==="#"||t===`
117
117
  `?!0:t==="\r"?this.buffer[e+1]===`
118
118
  `:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;for(;t===" ";)t=this.buffer[++n+e];if(t==="\r"){const r=this.buffer[n+e+1];if(r===`
119
119
  `||!r&&!this.atEnd)return e+n+1}return t===`
120
- `||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t==="-"||t==="."){const n=this.buffer.substr(e,3);if((n==="---"||n==="...")&&te(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
121
- `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===Qn&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let t=e.length,n=e.indexOf("#");for(;n!==-1;){const i=e[n-1];if(i===" "||i===" "){t=n-1;break}else n=e.indexOf("#",n+1)}for(;;){const i=e[t-1];if(i===" "||i===" ")t-=1;else break}const r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),"stream"}if(this.atLineEnd()){const t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield Xn,yield*this.parseLineStart()}*parseLineStart(){const e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");const t=this.peek(3);if((t==="---"||t==="...")&&te(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,t==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!te(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){const[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&te(t)){const n=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=n,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);const e=this.getLine();if(e===null)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(Ut),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);const r=this.getLine();if(r===null)return this.setNext("flow");if((n!==-1&&n<this.indentNext&&r[0]!=="#"||n===0&&(r.startsWith("---")||r.startsWith("..."))&&te(r[3]))&&!(n===this.indentNext-1&&this.flowLevel===1&&(r[0]==="]"||r[0]==="}")))return this.flowLevel=0,yield Zn,yield*this.parseLineStart();let i=0;for(;r[i]===",";)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),r[i]){case void 0:return"flow";case"#":return yield*this.pushCount(r.length-i),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Ut),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{const l=this.charAt(1);if(this.flowKey||te(l)||l===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){const e=this.charAt(0);let t=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;t!==-1&&this.buffer[t+1]==="'";)t=this.buffer.indexOf("'",t+2);else for(;t!==-1;){let i=0;for(;this.buffer[t-1-i]==="\\";)i+=1;if(i%2===0)break;t=this.buffer.indexOf('"',t+1)}const n=this.buffer.substring(0,t);let r=n.indexOf(`
122
- `,this.pos);if(r!==-1){for(;r!==-1;){const i=this.continueScalar(r+1);if(i===-1)break;r=n.indexOf(`
123
- `,i)}r!==-1&&(t=r-(n[r-1]==="\r"?2:1))}if(t===-1){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){const t=this.buffer[++e];if(t==="+")this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if(t!=="-")break}return yield*this.pushUntil(t=>te(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,n;e:for(let i=this.pos;n=this.buffer[i];++i)switch(n){case" ":t+=1;break;case`
124
- `:e=i,t=0;break;case"\r":{const l=this.buffer[i+1];if(!l&&!this.atEnd)return this.setNext("block-scalar");if(l===`
125
- `)break}default:break e}if(!n&&!this.atEnd)return this.setNext("block-scalar");if(t>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=t:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{const i=this.continueScalar(e+1);if(i===-1)break;e=this.buffer.indexOf(`
126
- `,i)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let r=e+1;for(n=this.buffer[r];n===" ";)n=this.buffer[++r];if(n===" "){for(;n===" "||n===" "||n==="\r"||n===`
127
- `;)n=this.buffer[++r];e=r-1}else if(!this.blockScalarKeep)do{let i=e-1,l=this.buffer[i];l==="\r"&&(l=this.buffer[--i]);const o=i;for(;l===" ";)l=this.buffer[--i];if(l===`
128
- `&&i>=this.pos&&i+1+t>o)e=i;else break}while(!0);return yield Ht,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){const e=this.flowLevel>0;let t=this.pos-1,n=this.pos-1,r;for(;r=this.buffer[++n];)if(r===":"){const i=this.buffer[n+1];if(te(i)||e&&it.has(i))break;t=n}else if(te(r)){let i=this.buffer[n+1];if(r==="\r"&&(i===`
120
+ `||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t==="-"||t==="."){const n=this.buffer.substr(e,3);if((n==="---"||n==="...")&&le(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
121
+ `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===Nr&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let t=e.length,n=e.indexOf("#");for(;n!==-1;){const a=e[n-1];if(a===" "||a===" "){t=n-1;break}else n=e.indexOf("#",n+1)}for(;;){const a=e[t-1];if(a===" "||a===" ")t-=1;else break}const r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),"stream"}if(this.atLineEnd()){const t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield wr,yield*this.parseLineStart()}*parseLineStart(){const e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");const t=this.peek(3);if((t==="---"||t==="...")&&le(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,t==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!le(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){const[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&le(t)){const n=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=n,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);const e=this.getLine();if(e===null)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(is),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);const r=this.getLine();if(r===null)return this.setNext("flow");if((n!==-1&&n<this.indentNext&&r[0]!=="#"||n===0&&(r.startsWith("---")||r.startsWith("..."))&&le(r[3]))&&!(n===this.indentNext-1&&this.flowLevel===1&&(r[0]==="]"||r[0]==="}")))return this.flowLevel=0,yield xr,yield*this.parseLineStart();let a=0;for(;r[a]===",";)a+=yield*this.pushCount(1),a+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(a+=yield*this.pushIndicators(),r[a]){case void 0:return"flow";case"#":return yield*this.pushCount(r.length-a),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(is),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{const l=this.charAt(1);if(this.flowKey||le(l)||l===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){const e=this.charAt(0);let t=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;t!==-1&&this.buffer[t+1]==="'";)t=this.buffer.indexOf("'",t+2);else for(;t!==-1;){let a=0;for(;this.buffer[t-1-a]==="\\";)a+=1;if(a%2===0)break;t=this.buffer.indexOf('"',t+1)}const n=this.buffer.substring(0,t);let r=n.indexOf(`
122
+ `,this.pos);if(r!==-1){for(;r!==-1;){const a=this.continueScalar(r+1);if(a===-1)break;r=n.indexOf(`
123
+ `,a)}r!==-1&&(t=r-(n[r-1]==="\r"?2:1))}if(t===-1){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){const t=this.buffer[++e];if(t==="+")this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if(t!=="-")break}return yield*this.pushUntil(t=>le(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,n;e:for(let a=this.pos;n=this.buffer[a];++a)switch(n){case" ":t+=1;break;case`
124
+ `:e=a,t=0;break;case"\r":{const l=this.buffer[a+1];if(!l&&!this.atEnd)return this.setNext("block-scalar");if(l===`
125
+ `)break}default:break e}if(!n&&!this.atEnd)return this.setNext("block-scalar");if(t>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=t:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{const a=this.continueScalar(e+1);if(a===-1)break;e=this.buffer.indexOf(`
126
+ `,a)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let r=e+1;for(n=this.buffer[r];n===" ";)n=this.buffer[++r];if(n===" "){for(;n===" "||n===" "||n==="\r"||n===`
127
+ `;)n=this.buffer[++r];e=r-1}else if(!this.blockScalarKeep)do{let a=e-1,l=this.buffer[a];l==="\r"&&(l=this.buffer[--a]);const c=a;for(;l===" ";)l=this.buffer[--a];if(l===`
128
+ `&&a>=this.pos&&a+1+t>c)e=a;else break}while(!0);return yield ms,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){const e=this.flowLevel>0;let t=this.pos-1,n=this.pos-1,r;for(;r=this.buffer[++n];)if(r===":"){const a=this.buffer[n+1];if(le(a)||e&&Nt.has(a))break;t=n}else if(le(r)){let a=this.buffer[n+1];if(r==="\r"&&(a===`
129
129
  `?(n+=1,r=`
130
- `,i=this.buffer[n+1]):t=n),i==="#"||e&&it.has(i))break;if(r===`
131
- `){const l=this.continueScalar(n+1);if(l===-1)break;n=Math.max(n,l-2)}}else{if(e&&it.has(r))break;t=n}return!r&&!this.atEnd?this.setNext("plain-scalar"):(yield Ht,yield*this.pushToIndex(t+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){const n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(Ut))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{const e=this.flowLevel>0,t=this.charAt(1);if(te(t)||e&&it.has(t))return e?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,t=this.buffer[e];for(;!te(t)&&t!==">";)t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];for(;t;)if(Za.has(t))t=this.buffer[++e];else if(t==="%"&&zs.has(this.buffer[e+1])&&zs.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){const e=this.buffer[this.pos];return e===`
130
+ `,a=this.buffer[n+1]):t=n),a==="#"||e&&Nt.has(a))break;if(r===`
131
+ `){const l=this.continueScalar(n+1);if(l===-1)break;n=Math.max(n,l-2)}}else{if(e&&Nt.has(r))break;t=n}return!r&&!this.atEnd?this.setNext("plain-scalar"):(yield ms,yield*this.pushToIndex(t+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){const n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(is))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{const e=this.flowLevel>0,t=this.charAt(1);if(le(t)||e&&Nt.has(t))return e?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,t=this.buffer[e];for(;!le(t)&&t!==">";)t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];for(;t;)if(vl.has(t))t=this.buffer[++e];else if(t==="%"&&fn.has(this.buffer[e+1])&&fn.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){const e=this.buffer[this.pos];return e===`
132
132
  `?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
133
- `?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===" "||e&&n===" ");const r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}class sl{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){const i=t+n>>1;this.lineStarts[i]<e?t=i+1:n=i}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};const r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}}function ue(s,e){for(let t=0;t<s.length;++t)if(s[t].type===e)return!0;return!1}function Ys(s){for(let e=0;e<s.length;++e)switch(s[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function er(s){switch(s?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function at(s){switch(s.type){case"document":return s.start;case"block-map":{const e=s.items[s.items.length-1];return e.sep??e.start}case"block-seq":return s.items[s.items.length-1].start;default:return[]}}function xe(s){if(s.length===0)return[];let e=s.length;e:for(;--e>=0;)switch(s[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;s[++e]?.type==="space";);return s.splice(e,s.length)}function Ws(s){if(s.start.type==="flow-seq-start")for(const e of s.items)e.sep&&!e.value&&!ue(e.start,"explicit-key-ind")&&!ue(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,er(e.value)?e.value.end?Array.prototype.push.apply(e.value.end,e.sep):e.value.end=e.sep:Array.prototype.push.apply(e.start,e.sep),delete e.sep)}class nl{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new tl,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(const n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}const t=Xa(e);if(t)if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{const n=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:n,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){const e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){const t=e??this.stack.pop();if(!t)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{const n=this.peek(1);switch(t.type==="block-scalar"?t.indent="indent"in n?n.indent:0:t.type==="flow-collection"&&n.type==="document"&&(t.indent=0),t.type==="flow-collection"&&Ws(t),n.type){case"document":n.value=t;break;case"block-scalar":n.props.push(t);break;case"block-map":{const r=n.items[n.items.length-1];if(r.value){n.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(r.sep)r.value=t;else{Object.assign(r,{key:t,sep:[]}),this.onKeyLine=!r.explicitKey;return}break}case"block-seq":{const r=n.items[n.items.length-1];r.value?n.items.push({start:[],value:t}):r.value=t;break}case"flow-collection":{const r=n.items[n.items.length-1];!r||r.value?n.items.push({start:[],key:t,sep:[]}):r.sep?r.value=t:Object.assign(r,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((n.type==="document"||n.type==="block-map"||n.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){const r=t.items[t.items.length-1];r&&!r.sep&&!r.value&&r.start.length>0&&Ys(r.start)===-1&&(t.indent===0||r.start.every(i=>i.type!=="comment"||i.indent<t.indent))&&(n.type==="document"?n.end=r.start:n.items.push({start:r.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{const e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{Ys(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}const t=this.startBlockValue(e);t?this.stack.push(t):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){const t=at(this.peek(2)),n=xe(t);let r;e.end?(r=e.end,r.push(this.sourceToken),delete e.end):r=[this.sourceToken];const i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let t=this.source.indexOf(`
133
+ `?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===" "||e&&n===" ");const r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}class Cl{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){const a=t+n>>1;this.lineStarts[a]<e?t=a+1:n=a}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};const r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}}function ye(s,e){for(let t=0;t<s.length;++t)if(s[t].type===e)return!0;return!1}function hn(s){for(let e=0;e<s.length;++e)switch(s[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function vr(s){switch(s?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function wt(s){switch(s.type){case"document":return s.start;case"block-map":{const e=s.items[s.items.length-1];return e.sep??e.start}case"block-seq":return s.items[s.items.length-1].start;default:return[]}}function je(s){if(s.length===0)return[];let e=s.length;e:for(;--e>=0;)switch(s[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;s[++e]?.type==="space";);return s.splice(e,s.length)}function mn(s){if(s.start.type==="flow-seq-start")for(const e of s.items)e.sep&&!e.value&&!ye(e.start,"explicit-key-ind")&&!ye(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,vr(e.value)?e.value.end?Array.prototype.push.apply(e.value.end,e.sep):e.value.end=e.sep:Array.prototype.push.apply(e.start,e.sep),delete e.sep)}class Tl{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Sl,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(const n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}const t=xl(e);if(t)if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{const n=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:n,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){const e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){const t=e??this.stack.pop();if(!t)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{const n=this.peek(1);switch(t.type==="block-scalar"?t.indent="indent"in n?n.indent:0:t.type==="flow-collection"&&n.type==="document"&&(t.indent=0),t.type==="flow-collection"&&mn(t),n.type){case"document":n.value=t;break;case"block-scalar":n.props.push(t);break;case"block-map":{const r=n.items[n.items.length-1];if(r.value){n.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(r.sep)r.value=t;else{Object.assign(r,{key:t,sep:[]}),this.onKeyLine=!r.explicitKey;return}break}case"block-seq":{const r=n.items[n.items.length-1];r.value?n.items.push({start:[],value:t}):r.value=t;break}case"flow-collection":{const r=n.items[n.items.length-1];!r||r.value?n.items.push({start:[],key:t,sep:[]}):r.sep?r.value=t:Object.assign(r,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((n.type==="document"||n.type==="block-map"||n.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){const r=t.items[t.items.length-1];r&&!r.sep&&!r.value&&r.start.length>0&&hn(r.start)===-1&&(t.indent===0||r.start.every(a=>a.type!=="comment"||a.indent<t.indent))&&(n.type==="document"?n.end=r.start:n.items.push({start:r.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{const e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{hn(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}const t=this.startBlockValue(e);t?this.stack.push(t):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){const t=wt(this.peek(2)),n=je(t);let r;e.end?(r=e.end,r.push(this.sourceToken),delete e.end):r=[this.sourceToken];const a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let t=this.source.indexOf(`
134
134
  `)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
135
- `,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){const t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){const n="end"in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){const r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){Array.prototype.push.apply(r,t.start),r.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){const n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind";let i=[];if(r&&t.sep&&!t.value){const l=[];for(let o=0;o<t.sep.length;++o){const c=t.sep[o];switch(c.type){case"newline":l.push(o);break;case"space":break;case"comment":c.indent>e.indent&&(l.length=0);break;default:l.length=0}}l.length>=2&&(i=t.sep.splice(l[1]))}switch(this.type){case"anchor":case"tag":r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"explicit-key-ind":!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(t.explicitKey)if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(ue(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(er(t.key)&&!ue(t.sep,"newline")){const l=xe(t.start),o=t.key,c=t.sep;c.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:l,key:o,sep:c}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken);else if(ue(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{const l=xe(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:l,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):ue(t.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const l=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:l,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(l):(Object.assign(t,{key:l,sep:[]}),this.onKeyLine=!0);return}default:{const l=this.startBlockValue(e);if(l){if(l.type==="block-seq"){if(!t.explicitKey&&t.sep&&!ue(t.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(l);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){const t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){const n="end"in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){const r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){Array.prototype.push.apply(r,t.start),r.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;t.value||ue(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){const n=this.startBlockValue(e);if(n){this.stack.push(n);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){const t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let n;do yield*this.pop(),n=this.peek(1);while(n?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case"map-value-ind":!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const r=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:r,sep:[]}):t.sep?this.stack.push(r):Object.assign(t,{key:r,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}const n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{const n=this.peek(2);if(n.type==="block-map"&&(this.type==="map-value-ind"&&n.indent===e.indent||this.type==="newline"&&!n.items[n.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&n.type!=="flow-collection"){const r=at(n),i=xe(r);Ws(e);const l=e.end.splice(1,e.end.length);l.push(this.sourceToken);const o={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:l}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
135
+ `,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){const t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){const n="end"in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){const r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){Array.prototype.push.apply(r,t.start),r.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){const n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind";let a=[];if(r&&t.sep&&!t.value){const l=[];for(let c=0;c<t.sep.length;++c){const d=t.sep[c];switch(d.type){case"newline":l.push(c);break;case"space":break;case"comment":d.indent>e.indent&&(l.length=0);break;default:l.length=0}}l.length>=2&&(a=t.sep.splice(l[1]))}switch(this.type){case"anchor":case"tag":r||t.value?(a.push(this.sourceToken),e.items.push({start:a}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"explicit-key-ind":!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(a.push(this.sourceToken),e.items.push({start:a,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(t.explicitKey)if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(ye(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(vr(t.key)&&!ye(t.sep,"newline")){const l=je(t.start),c=t.key,d=t.sep;d.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:l,key:c,sep:d}]})}else a.length>0?t.sep=t.sep.concat(a,this.sourceToken):t.sep.push(this.sourceToken);else if(ye(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{const l=je(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:l,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||r?e.items.push({start:a,key:null,sep:[this.sourceToken]}):ye(t.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const l=this.flowScalar(this.type);r||t.value?(e.items.push({start:a,key:l,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(l):(Object.assign(t,{key:l,sep:[]}),this.onKeyLine=!0);return}default:{const l=this.startBlockValue(e);if(l){if(l.type==="block-seq"){if(!t.explicitKey&&t.sep&&!ye(t.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else n&&e.items.push({start:a});this.stack.push(l);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){const t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){const n="end"in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){const r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){Array.prototype.push.apply(r,t.start),r.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;t.value||ye(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){const n=this.startBlockValue(e);if(n){this.stack.push(n);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){const t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let n;do yield*this.pop(),n=this.peek(1);while(n?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case"map-value-ind":!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const r=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:r,sep:[]}):t.sep?this.stack.push(r):Object.assign(t,{key:r,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}const n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{const n=this.peek(2);if(n.type==="block-map"&&(this.type==="map-value-ind"&&n.indent===e.indent||this.type==="newline"&&!n.items[n.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&n.type!=="flow-collection"){const r=wt(n),a=je(r);mn(e);const l=e.end.splice(1,e.end.length);l.push(this.sourceToken);const c={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:a,key:e,sep:l}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=c}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
136
136
  `)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
137
- `,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const t=at(e),n=xe(t);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;const t=at(e),n=xe(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!=="comment"||this.indent<=t?!1:e.every(n=>n.type==="newline"||n.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}function rl(s){const e=s.prettyErrors!==!1;return{lineCounter:s.lineCounter||e&&new sl||null,prettyErrors:e}}function il(s,e={}){const{lineCounter:t,prettyErrors:n}=rl(e),r=new nl(t?.addNewLine),i=new Qa(e);let l=null;for(const o of i.compose(r.parse(s),!0,s.length))if(!l)l=o;else if(l.options.logLevel!=="silent"){l.errors.push(new Be(o.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return n&&t&&(l.errors.forEach(Vs(s,t)),l.warnings.forEach(Vs(s,t))),l}function gt(s,e,t){let n;const r=il(s,t);if(!r)return null;if(r.warnings.forEach(i=>Tn(r.options.logLevel,i)),r.errors.length>0){if(r.options.logLevel!=="silent")throw r.errors[0];r.errors=[]}return r.toJS(Object.assign({reviver:n},t))}function Qt(s,e,t){let n=null;if(typeof e=="function"||Array.isArray(e)?n=e:t===void 0&&e&&(t=e),typeof t=="string"&&(t=t.length),typeof t=="number"){const r=Math.round(t);t=r<1?void 0:r>8?{indent:8}:{indent:r}}if(s===void 0){const{keepUndefined:r}=t??e??{};if(!r)return}return Ge(s)&&!n?s.toString(t):new Ze(s,n,t).toString(t)}const tr=xt.Root,Es=E.forwardRef(({className:s,...e},t)=>a(xt.List,{ref:t,className:I("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...e}));Es.displayName="TabsList";const yt=E.forwardRef(({className:s,...e},t)=>a(xt.Trigger,{ref:t,className:I("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",s),...e}));yt.displayName="TabsTrigger";const bt=E.forwardRef(({className:s,...e},t)=>a(xt.Content,{ref:t,className:I("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...e}));bt.displayName="TabsContent";function al({config:s,pluginKeys:e,onSave:t,saving:n}){const r=es(()=>{const f=new Set(e);return f.add("plugins"),Object.keys(s).filter(g=>!f.has(g))},[s,e]),[i,l]=T({}),[o,c]=T(!1);G(()=>{const f={};for(const g of r)f[g]=s[g];l(f),c(!1)},[s,r]);const u=(f,g)=>{l(b=>({...b,[f]:g})),c(!0)},m=async()=>{await t(i),c(!1)},h=()=>{const f={};for(const g of r)f[g]=s[g];l(f),c(!1)};return r.length===0?a(_,{children:d(P,{className:"flex flex-col items-center gap-3 py-12",children:[a("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted",children:a(We,{className:"w-8 h-8 text-muted-foreground"})}),a("h3",{className:"text-lg font-semibold",children:"暂无通用配置"}),a("p",{className:"text-sm text-muted-foreground",children:"配置文件中未发现可编辑的通用字段"})]})}):d("div",{className:"space-y-4",children:[a("div",{className:"space-y-3",children:r.map(f=>a(ll,{fieldKey:f,value:i[f],onChange:g=>u(f,g)},f))}),d("div",{className:"flex items-center gap-2 pt-2",children:[a(M,{size:"sm",onClick:m,disabled:n||!o,children:n?d(ie,{children:[a(be,{className:"w-4 h-4 mr-1 animate-spin"}),"保存中..."]}):d(ie,{children:[a(vt,{className:"w-4 h-4 mr-1"}),"保存"]})}),o&&d(M,{variant:"outline",size:"sm",onClick:h,children:[a(os,{className:"w-4 h-4 mr-1"}),"撤销"]}),o&&a("span",{className:"text-xs text-muted-foreground",children:"有未保存的更改"})]})]})}function ll({fieldKey:s,value:e,onChange:t}){const n=typeof e;if(e==null)return d("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-1.5",children:[d("div",{className:"flex items-center gap-1.5",children:[a("span",{className:"text-sm font-medium",children:s}),a(L,{variant:"outline",className:"text-[10px] px-1 py-0",children:"null"})]}),a(V,{value:"",placeholder:"(空值)",onChange:r=>t(r.target.value||null),className:"h-8 text-sm"})]});if(n==="boolean")return a("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-1.5",children:d("div",{className:"flex items-center justify-between",children:[d("div",{className:"flex items-center gap-1.5",children:[a("span",{className:"text-sm font-medium",children:s}),a(L,{variant:"outline",className:"text-[10px] px-1 py-0",children:"boolean"})]}),a("button",{type:"button",onClick:()=>t(!e),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${e?"bg-primary":"bg-muted-foreground/30"}`,children:a("span",{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform ${e?"translate-x-4.5":"translate-x-0.5"}`})})]})});if(n==="number")return d("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-1.5",children:[d("div",{className:"flex items-center gap-1.5",children:[a("span",{className:"text-sm font-medium",children:s}),a(L,{variant:"outline",className:"text-[10px] px-1 py-0",children:"number"})]}),a(V,{type:"number",value:e,onChange:r=>t(Number(r.target.value)),className:"h-8 text-sm"})]});if(n==="string"){const r=e.includes(`
138
- `)||e.length>80;return d("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-1.5",children:[d("div",{className:"flex items-center gap-1.5",children:[a("span",{className:"text-sm font-medium",children:s}),a(L,{variant:"outline",className:"text-[10px] px-1 py-0",children:"string"})]}),r?a(W,{value:e,onChange:i=>t(i.target.value),className:"text-sm font-mono min-h-[80px]"}):a(V,{value:e,onChange:i=>t(i.target.value),className:"h-8 text-sm"})]})}return Array.isArray(e)?d("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-1.5",children:[d("div",{className:"flex items-center gap-1.5",children:[a("span",{className:"text-sm font-medium",children:s}),d(L,{variant:"outline",className:"text-[10px] px-1 py-0",children:["array[",e.length,"]"]})]}),a(W,{value:Qt(e).trim(),onChange:r=>{try{const i=gt(r.target.value);Array.isArray(i)&&t(i)}catch{}},className:"text-sm font-mono min-h-[80px]"})]}):n==="object"?d("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-1.5",children:[d("div",{className:"flex items-center gap-1.5",children:[a("span",{className:"text-sm font-medium",children:s}),a(L,{variant:"outline",className:"text-[10px] px-1 py-0",children:"object"})]}),a(W,{value:Qt(e).trim(),onChange:r=>{try{const i=gt(r.target.value);i&&typeof i=="object"&&!Array.isArray(i)&&t(i)}catch{}},className:"text-sm font-mono min-h-[100px]"})]}):d("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-1.5",children:[d("div",{className:"flex items-center gap-1.5",children:[a("span",{className:"text-sm font-medium",children:s}),a(L,{variant:"outline",className:"text-[10px] px-1 py-0",children:n})]}),a(V,{value:String(e),onChange:r=>t(r.target.value),className:"h-8 text-sm"})]})}function ol(){const{yaml:s,pluginKeys:e,loading:t,error:n,load:r,save:i}=Br(),[l,o]=T("form"),[c,u]=T(""),[m,h]=T(!1),[f,g]=T(!1),[b,p]=T(null);G(()=>{s&&(u(s),h(!1))},[s]);const y=es(()=>{try{return gt(s)||{}}catch{return{}}},[s]),k=Nt((v,N)=>{p({type:v,text:N}),setTimeout(()=>p(null),3e3)},[]),O=async()=>{g(!0);try{await i(c),h(!1),k("success","配置已保存,需重启生效")}catch(v){k("error",`保存失败: ${v instanceof Error?v.message:"未知错误"}`)}finally{g(!1)}},w=async v=>{g(!0);try{const C={...gt(s)||{},...v},x=Qt(C,{lineWidth:0});await i(x),k("success","配置已保存,需重启生效")}catch(N){k("error",`保存失败: ${N instanceof Error?N.message:"未知错误"}`)}finally{g(!1)}},S=async()=>{try{await r(),k("success","已刷新")}catch{k("error","刷新失败")}};return t&&!s?d("div",{className:"space-y-4",children:[a("h1",{className:"text-2xl font-bold tracking-tight",children:"配置管理"}),d("div",{className:"flex items-center justify-center py-12",children:[a(be,{className:"w-6 h-6 animate-spin text-muted-foreground"}),a("span",{className:"ml-2 text-sm text-muted-foreground",children:"加载配置中..."})]})]}):d("div",{className:"space-y-4",children:[d("div",{className:"flex items-center justify-between",children:[d("div",{children:[a("h1",{className:"text-2xl font-bold tracking-tight",children:"配置管理"}),a("p",{className:"text-sm text-muted-foreground mt-1",children:"管理 zhin.config.yml 中的通用配置项(不含插件配置)"})]}),a("div",{className:"flex items-center gap-2",children:d(M,{variant:"outline",size:"sm",onClick:S,disabled:t,children:[a(cs,{className:`w-4 h-4 mr-1 ${t?"animate-spin":""}`}),"刷新"]})})]}),b&&d(z,{variant:b.type==="error"?"destructive":"success",className:"py-2",children:[b.type==="error"?a(ae,{className:"h-4 w-4"}):a(ls,{className:"h-4 w-4"}),a(Y,{children:b.text})]}),n&&!b&&d(z,{variant:"destructive",className:"py-2",children:[a(ae,{className:"h-4 w-4"}),a(Y,{children:n})]}),d(tr,{value:l,onValueChange:v=>o(v),children:[d(Es,{children:[d(yt,{value:"form",className:"gap-1.5",children:[a(Cr,{className:"w-4 h-4"}),"表单模式"]}),d(yt,{value:"yaml",className:"gap-1.5",children:[a(Tr,{className:"w-4 h-4"}),"YAML 模式"]})]}),a(bt,{value:"form",children:a(al,{config:y,pluginKeys:e,onSave:w,saving:f})}),a(bt,{value:"yaml",children:d("div",{className:"space-y-3",children:[a("div",{className:"relative",children:a(W,{value:c,onChange:v=>{u(v.target.value),h(!0)},className:"font-mono text-sm min-h-[400px] resize-y",placeholder:"# zhin.config.yml",spellCheck:!1})}),d("div",{className:"flex items-center gap-2",children:[a(M,{size:"sm",onClick:O,disabled:f||!m,children:f?d(ie,{children:[a(be,{className:"w-4 h-4 mr-1 animate-spin"}),"保存中..."]}):d(ie,{children:[a(vt,{className:"w-4 h-4 mr-1"}),"保存"]})}),m&&d(M,{variant:"outline",size:"sm",onClick:()=>{u(s),h(!1)},children:[a(os,{className:"w-4 h-4 mr-1"}),"撤销"]}),m&&a("span",{className:"text-xs text-muted-foreground",children:"有未保存的更改"})]})]})})]})]})}const cl=/^(.*(?:PASSWORD|SECRET|TOKEN|KEY|PRIVATE|CREDENTIAL).*?=\s*)(.+)$/gim;function dl(s){return s.replace(cl,(e,t,n)=>{if(n.startsWith("${")||n.trim()==="")return t+n;const r=n.length>4?n.slice(0,2):"";return t+r+"●".repeat(Math.min(n.length-r.length,20))})}function ul({filename:s,getFile:e,saveFile:t,exists:n}){const[r,i]=T(""),[l,o]=T(""),[c,u]=T(!1),[m,h]=T(!1),[f,g]=T(!0),[b,p]=T(null),[y,k]=T(!1),O=Nt(async()=>{u(!0);try{const N=await e(s);i(N),o(N),k(!0)}catch(N){p({type:"error",text:`加载失败: ${N instanceof Error?N.message:"未知错误"}`})}finally{u(!1)}},[s,e]);G(()=>{O()},[O]);const w=async()=>{h(!0),p(null);try{await t(s,r),o(r),p({type:"success",text:"已保存,需重启生效"}),setTimeout(()=>p(null),3e3)}catch(N){p({type:"error",text:`保存失败: ${N instanceof Error?N.message:"未知错误"}`})}finally{h(!1)}},S=r!==l,v=f&&!S?dl(r):r;return c&&!y?d("div",{className:"flex items-center justify-center py-8",children:[a(be,{className:"w-5 h-5 animate-spin text-muted-foreground"}),a("span",{className:"ml-2 text-sm text-muted-foreground",children:"加载中..."})]}):d("div",{className:"space-y-3",children:[!n&&!S&&d(z,{className:"py-2 border-yellow-500/50 text-yellow-700 dark:text-yellow-400",children:[a(Ar,{className:"h-4 w-4"}),a(Y,{children:"文件不存在,保存后将自动创建"})]}),b&&d(z,{variant:b.type==="error"?"destructive":"success",className:"py-2",children:[b.type==="error"?a(ae,{className:"h-4 w-4"}):a(ls,{className:"h-4 w-4"}),a(Y,{children:b.text})]}),a("div",{className:"relative",children:a(W,{value:v,onChange:N=>{i(N.target.value),g(!1)},onFocus:()=>g(!1),className:"font-mono text-sm min-h-[350px] resize-y",placeholder:"KEY=VALUE",spellCheck:!1})}),d("div",{className:"flex items-center gap-2",children:[a(M,{size:"sm",onClick:w,disabled:m||!S,children:m?d(ie,{children:[a(be,{className:"w-4 h-4 mr-1 animate-spin"}),"保存中..."]}):d(ie,{children:[a(vt,{className:"w-4 h-4 mr-1"}),"保存"]})}),S&&a(M,{variant:"outline",size:"sm",onClick:()=>{i(l),g(!0)},children:"撤销"}),a(M,{variant:"ghost",size:"sm",onClick:()=>g(N=>!N),disabled:S,title:f?"显示敏感值":"隐藏敏感值",children:f?a(Ir,{className:"w-4 h-4"}):a(Er,{className:"w-4 h-4"})}),S&&a("span",{className:"text-xs text-muted-foreground",children:"有未保存的更改"})]})]})}function fl(){const{files:s,loading:e,error:t,listFiles:n,getFile:r,saveFile:i}=Dr(),[l,o]=T(".env"),c=async()=>{try{await n()}catch{}};return e&&s.length===0?d("div",{className:"space-y-4",children:[a("h1",{className:"text-2xl font-bold tracking-tight",children:"环境变量"}),d("div",{className:"flex items-center justify-center py-12",children:[a(be,{className:"w-6 h-6 animate-spin text-muted-foreground"}),a("span",{className:"ml-2 text-sm text-muted-foreground",children:"加载中..."})]})]}):d("div",{className:"space-y-4",children:[d("div",{className:"flex items-center justify-between",children:[d("div",{children:[a("h1",{className:"text-2xl font-bold tracking-tight",children:"环境变量"}),a("p",{className:"text-sm text-muted-foreground mt-1",children:"管理 .env 文件中的环境变量,修改后需重启生效"})]}),d(M,{variant:"outline",size:"sm",onClick:c,disabled:e,children:[a(cs,{className:`w-4 h-4 mr-1 ${e?"animate-spin":""}`}),"刷新"]})]}),t&&d(z,{variant:"destructive",className:"py-2",children:[a(ae,{className:"h-4 w-4"}),a(Y,{children:t})]}),d(tr,{value:l,onValueChange:o,children:[a(Es,{children:[".env",".env.development",".env.production"].map(u=>{const m=s.find(h=>h.name===u);return d(yt,{value:u,className:"gap-1.5",children:[a(rn,{className:"w-3.5 h-3.5"}),u,m&&!m.exists&&a(L,{variant:"outline",className:"text-[10px] px-1 py-0 ml-1",children:"新"})]},u)})}),[".env",".env.development",".env.production"].map(u=>a(bt,{value:u,children:a(ul,{filename:u,getFile:r,saveFile:i,exists:s.find(m=>m.name===u)?.exists??!1})},u))]})]})}function hl({onSuccess:s}){const[e,t]=T(""),[n,r]=T(""),[i,l]=T(!1),o=Nt(async()=>{const c=e.trim();if(!c){r("请输入 Token");return}l(!0),r("");try{const u=await fetch("/api/system/status",{headers:{Authorization:`Bearer ${c}`}});u.ok?(gi(c),s()):u.status===401?r("Token 无效,请检查后重试"):r(`验证失败 (HTTP ${u.status})`)}catch{r("无法连接到服务器")}finally{l(!1)}},[e,s]);return a("div",{className:"flex items-center justify-center min-h-screen bg-background",children:d(_,{className:I("w-full max-w-md mx-4"),children:[d(se,{className:"text-center space-y-2",children:[a("div",{className:"flex items-center justify-center mx-auto w-12 h-12 rounded-xl bg-foreground text-background font-bold text-xl",children:"Z"}),a(ne,{className:"text-xl",children:"Zhin.js 控制台"}),a(Fe,{children:"请输入 API Token 以访问管理面板"})]}),a(P,{children:d("form",{onSubmit:c=>{c.preventDefault(),o()},className:"space-y-4",children:[d("div",{className:"space-y-2",children:[a(V,{type:"password",placeholder:"API Token",value:e,onChange:c=>{t(c.target.value),n&&r("")},autoFocus:!0}),n&&a("p",{className:"text-sm text-destructive",children:n})]}),a(M,{type:"submit",className:"w-full",disabled:i,children:i?"验证中...":"登录"}),d("p",{className:"text-xs text-center text-muted-foreground",children:["Token 位于 ",a("code",{className:"text-xs bg-muted px-1 rounded",children:".env"})," 文件的"," ",a("code",{className:"text-xs bg-muted px-1 rounded",children:"HTTP_TOKEN"})," 中"]})]})})]})})}function dt(s){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?dt=function(t){return typeof t}:dt=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},dt(s)}function ml(s,e){if(!(s instanceof e))throw new TypeError("Cannot call a class as a function")}function pl(s,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(s,n.key,n)}}function gl(s,e,t){return e&&pl(s.prototype,e),s}function yl(s,e){return e&&(dt(e)==="object"||typeof e=="function")?e:ut(s)}function Xt(s){return Xt=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Xt(s)}function ut(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function bl(s,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(e&&e.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),e&&Zt(s,e)}function Zt(s,e){return Zt=Object.setPrototypeOf||function(n,r){return n.__proto__=r,n},Zt(s,e)}function ft(s,e,t){return e in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}var sr=(function(s){bl(e,s);function e(){var t,n;ml(this,e);for(var r=arguments.length,i=new Array(r),l=0;l<r;l++)i[l]=arguments[l];return n=yl(this,(t=Xt(e)).call.apply(t,[this].concat(i))),ft(ut(n),"state",{bootstrapped:!1}),ft(ut(n),"_unsubscribe",void 0),ft(ut(n),"handlePersistorState",function(){var o=n.props.persistor,c=o.getState(),u=c.bootstrapped;u&&(n.props.onBeforeLift?Promise.resolve(n.props.onBeforeLift()).finally(function(){return n.setState({bootstrapped:!0})}):n.setState({bootstrapped:!0}),n._unsubscribe&&n._unsubscribe())}),n}return gl(e,[{key:"componentDidMount",value:function(){this._unsubscribe=this.props.persistor.subscribe(this.handlePersistorState),this.handlePersistorState()}},{key:"componentWillUnmount",value:function(){this._unsubscribe&&this._unsubscribe()}},{key:"render",value:function(){return typeof this.props.children=="function"?this.props.children(this.state.bootstrapped):this.state.bootstrapped?this.props.children:this.props.loading}}]),e})(ar);ft(sr,"defaultProps",{children:null,loading:null});const Nl=Je.Provider;Je.Root;Je.Trigger;const wl=E.forwardRef(({className:s,sideOffset:e=4,...t},n)=>a(Je.Portal,{children:a(Je.Content,{ref:n,sideOffset:e,className:I("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...t})}));wl.displayName="TooltipContent";ui();function vl(){const[s,e]=T(yi()),t=Nt(()=>e(!0),[]);return G(()=>{const n=()=>e(!1);return window.addEventListener("zhin:auth-required",n),()=>window.removeEventListener("zhin:auth-required",n)},[]),s?a(sr,{loading:null,persistor:Fr,children:a(ci,{store:Kr,children:a(xl,{})})}):a(hl,{onSuccess:t})}function xl(){Ur();const s=Ce(l=>l.script.entries),e=Ce(l=>l.script.loadedScripts),t=Ce(l=>l.script.synced),[n,r]=T(!1);G(()=>{[{key:"dashboard-layout",path:"/",title:"Dashboard",element:a(bi,{}),meta:{order:0},children:[{key:"dashboard-home",path:"/dashboard",title:"系统概览",icon:a(Lr,{className:"w-4 h-4"}),element:a(ki,{})},{key:"dashboard-plugins",path:"/plugins",title:"插件管理",icon:a(le,{className:"w-4 h-4"}),element:a(Ci,{}),meta:{order:2}},{key:"dashboard-plugin-detail",title:"插件详情",path:"/plugins/:name",element:a(Yi,{}),meta:{hideInMenu:!0}},{key:"dashboard-config",path:"/config",title:"配置管理",icon:a(We,{className:"w-4 h-4"}),element:a(ol,{}),meta:{order:3}},{key:"dashboard-env",path:"/env",title:"环境变量",icon:a(rn,{className:"w-4 h-4"}),element:a(fl,{}),meta:{order:4}},{key:"dashboard-bots",path:"/bots",title:"机器人",icon:a(Ve,{className:"w-4 h-4"}),element:a(Gi,{}),meta:{order:5}},{key:"dashboard-logs",path:"/logs",title:"系统日志",icon:a(ss,{className:"w-4 h-4"}),element:a(Hi,{}),meta:{order:6}}]}].forEach(o=>{Vr(o)}),r(!0)},[]);const i=t&&(s.length===0||s.length===e.length);return!n||!i?a("div",{className:"flex items-center justify-center h-screen bg-background",children:d("div",{className:"text-center",children:[a("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-2 border-muted-foreground border-t-foreground"}),d("p",{className:"mt-3 text-sm text-muted-foreground",children:["加载中... (",e.length,"/",s.length,")"]})]})}):a(qr,{})}or(document.getElementById("root")).render(a(lr,{children:a(Nl,{children:a(vl,{})})}));
137
+ `,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const t=wt(e),n=je(t);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;const t=wt(e),n=je(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!=="comment"||this.indent<=t?!1:e.every(n=>n.type==="newline"||n.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}function Ol(s){const e=s.prettyErrors!==!1;return{lineCounter:s.lineCounter||e&&new Cl||null,prettyErrors:e}}function Al(s,e={}){const{lineCounter:t,prettyErrors:n}=Ol(e),r=new Tl(t?.addNewLine),a=new wl(e);let l=null;for(const c of a.compose(r.parse(s),!0,s.length))if(!l)l=c;else if(l.options.logLevel!=="silent"){l.errors.push(new Qe(c.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return n&&t&&(l.errors.forEach(cn(s,t)),l.warnings.forEach(cn(s,t))),l}function Et(s,e,t){let n;const r=Al(s,t);if(!r)return null;if(r.warnings.forEach(a=>Gn(r.options.logLevel,a)),r.errors.length>0){if(r.options.logLevel!=="silent")throw r.errors[0];r.errors=[]}return r.toJS(Object.assign({reviver:n},t))}function ps(s,e,t){let n=null;if(typeof e=="function"||Array.isArray(e)?n=e:t===void 0&&e&&(t=e),typeof t=="string"&&(t=t.length),typeof t=="number"){const r=Math.round(t);t=r<1?void 0:r>8?{indent:8}:{indent:r}}if(s===void 0){const{keepUndefined:r}=t??e??{};if(!r)return}return ct(s)&&!n?s.toString(t):new ht(s,n,t).toString(t)}const kr=Pt.Root,Js=$.forwardRef(({className:s,...e},t)=>i(Pt.List,{ref:t,className:E("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...e}));Js.displayName="TabsList";const It=$.forwardRef(({className:s,...e},t)=>i(Pt.Trigger,{ref:t,className:E("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",s),...e}));It.displayName="TabsTrigger";const Lt=$.forwardRef(({className:s,...e},t)=>i(Pt.Content,{ref:t,className:E("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...e}));Lt.displayName="TabsContent";function El({config:s,pluginKeys:e,onSave:t,saving:n}){const r=Te(()=>{const f=new Set(e);return f.add("plugins"),Object.keys(s).filter(g=>!f.has(g))},[s,e]),[a,l]=T({}),[c,d]=T(!1);z(()=>{const f={};for(const g of r)f[g]=s[g];l(f),d(!1)},[s,r]);const u=(f,g)=>{l(w=>({...w,[f]:g})),d(!0)},h=async()=>{await t(a),d(!1)},m=()=>{const f={};for(const g of r)f[g]=s[g];l(f),d(!1)};return r.length===0?i(P,{children:o(M,{className:"flex flex-col items-center gap-3 py-12",children:[i("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted",children:i(lt,{className:"w-8 h-8 text-muted-foreground"})}),i("h3",{className:"text-lg font-semibold",children:"暂无通用配置"}),i("p",{className:"text-sm text-muted-foreground",children:"配置文件中未发现可编辑的通用字段"})]})}):o("div",{className:"space-y-4",children:[i("div",{className:"space-y-3",children:r.map(f=>i(Il,{fieldKey:f,value:a[f],onChange:g=>u(f,g)},f))}),o("div",{className:"flex items-center gap-2 pt-2",children:[i(A,{size:"sm",onClick:h,disabled:n||!c,children:n?o(ne,{children:[i(te,{className:"w-4 h-4 mr-1 animate-spin"}),"保存中..."]}):o(ne,{children:[i(we,{className:"w-4 h-4 mr-1"}),"保存"]})}),c&&o(A,{variant:"outline",size:"sm",onClick:m,children:[i(ot,{className:"w-4 h-4 mr-1"}),"撤销"]}),c&&i("span",{className:"text-xs text-muted-foreground",children:"有未保存的更改"})]})]})}function Il({fieldKey:s,value:e,onChange:t}){const n=typeof e;if(e==null)return o("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-1.5",children:[o("div",{className:"flex items-center gap-1.5",children:[i("span",{className:"text-sm font-medium",children:s}),i(_,{variant:"outline",className:"text-[10px] px-1 py-0",children:"null"})]}),i(Y,{value:"",placeholder:"(空值)",onChange:r=>t(r.target.value||null),className:"h-8 text-sm"})]});if(n==="boolean")return i("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-1.5",children:o("div",{className:"flex items-center justify-between",children:[o("div",{className:"flex items-center gap-1.5",children:[i("span",{className:"text-sm font-medium",children:s}),i(_,{variant:"outline",className:"text-[10px] px-1 py-0",children:"boolean"})]}),i("button",{type:"button",onClick:()=>t(!e),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${e?"bg-primary":"bg-muted-foreground/30"}`,children:i("span",{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform ${e?"translate-x-4.5":"translate-x-0.5"}`})})]})});if(n==="number")return o("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-1.5",children:[o("div",{className:"flex items-center gap-1.5",children:[i("span",{className:"text-sm font-medium",children:s}),i(_,{variant:"outline",className:"text-[10px] px-1 py-0",children:"number"})]}),i(Y,{type:"number",value:e,onChange:r=>t(Number(r.target.value)),className:"h-8 text-sm"})]});if(n==="string"){const r=e.includes(`
138
+ `)||e.length>80;return o("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-1.5",children:[o("div",{className:"flex items-center gap-1.5",children:[i("span",{className:"text-sm font-medium",children:s}),i(_,{variant:"outline",className:"text-[10px] px-1 py-0",children:"string"})]}),r?i(se,{value:e,onChange:a=>t(a.target.value),className:"text-sm font-mono min-h-[80px]"}):i(Y,{value:e,onChange:a=>t(a.target.value),className:"h-8 text-sm"})]})}return Array.isArray(e)?o("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-1.5",children:[o("div",{className:"flex items-center gap-1.5",children:[i("span",{className:"text-sm font-medium",children:s}),o(_,{variant:"outline",className:"text-[10px] px-1 py-0",children:["array[",e.length,"]"]})]}),i(se,{value:ps(e).trim(),onChange:r=>{try{const a=Et(r.target.value);Array.isArray(a)&&t(a)}catch{}},className:"text-sm font-mono min-h-[80px]"})]}):n==="object"?o("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-1.5",children:[o("div",{className:"flex items-center gap-1.5",children:[i("span",{className:"text-sm font-medium",children:s}),i(_,{variant:"outline",className:"text-[10px] px-1 py-0",children:"object"})]}),i(se,{value:ps(e).trim(),onChange:r=>{try{const a=Et(r.target.value);a&&typeof a=="object"&&!Array.isArray(a)&&t(a)}catch{}},className:"text-sm font-mono min-h-[100px]"})]}):o("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-1.5",children:[o("div",{className:"flex items-center gap-1.5",children:[i("span",{className:"text-sm font-medium",children:s}),i(_,{variant:"outline",className:"text-[10px] px-1 py-0",children:n})]}),i(Y,{value:String(e),onChange:r=>t(r.target.value),className:"h-8 text-sm"})]})}function Ll(){const{yaml:s,pluginKeys:e,loading:t,error:n,load:r,save:a}=ii(),[l,c]=T("form"),[d,u]=T(""),[h,m]=T(!1),[f,g]=T(!1),[w,p]=T(null);z(()=>{s&&(u(s),m(!1))},[s]);const b=Te(()=>{try{return Et(s)||{}}catch{return{}}},[s]),k=ue((S,y)=>{p({type:S,text:y}),setTimeout(()=>p(null),3e3)},[]),x=async()=>{g(!0);try{await a(d),m(!1),k("success","配置已保存,需重启生效")}catch(S){k("error",`保存失败: ${S instanceof Error?S.message:"未知错误"}`)}finally{g(!1)}},N=async S=>{g(!0);try{const O={...Et(s)||{},...S},v=ps(O,{lineWidth:0});await a(v),k("success","配置已保存,需重启生效")}catch(y){k("error",`保存失败: ${y instanceof Error?y.message:"未知错误"}`)}finally{g(!1)}},C=async()=>{try{await r(),k("success","已刷新")}catch{k("error","刷新失败")}};return t&&!s?o("div",{className:"space-y-4",children:[i("h1",{className:"text-2xl font-bold tracking-tight",children:"配置管理"}),o("div",{className:"flex items-center justify-center py-12",children:[i(te,{className:"w-6 h-6 animate-spin text-muted-foreground"}),i("span",{className:"ml-2 text-sm text-muted-foreground",children:"加载配置中..."})]})]}):o("div",{className:"space-y-4",children:[o("div",{className:"flex items-center justify-between",children:[o("div",{children:[i("h1",{className:"text-2xl font-bold tracking-tight",children:"配置管理"}),i("p",{className:"text-sm text-muted-foreground mt-1",children:"管理 zhin.config.yml 中的通用配置项(不含插件配置)"})]}),i("div",{className:"flex items-center gap-2",children:o(A,{variant:"outline",size:"sm",onClick:C,disabled:t,children:[i(xe,{className:`w-4 h-4 mr-1 ${t?"animate-spin":""}`}),"刷新"]})})]}),w&&o(V,{variant:w.type==="error"?"destructive":"success",className:"py-2",children:[w.type==="error"?i(G,{className:"h-4 w-4"}):i(Ee,{className:"h-4 w-4"}),i(q,{children:w.text})]}),n&&!w&&o(V,{variant:"destructive",className:"py-2",children:[i(G,{className:"h-4 w-4"}),i(q,{children:n})]}),o(kr,{value:l,onValueChange:S=>c(S),children:[o(Js,{children:[o(It,{value:"form",className:"gap-1.5",children:[i(Wr,{className:"w-4 h-4"}),"表单模式"]}),o(It,{value:"yaml",className:"gap-1.5",children:[i(os,{className:"w-4 h-4"}),"YAML 模式"]})]}),i(Lt,{value:"form",children:i(El,{config:b,pluginKeys:e,onSave:N,saving:f})}),i(Lt,{value:"yaml",children:o("div",{className:"space-y-3",children:[i("div",{className:"relative",children:i(se,{value:d,onChange:S=>{u(S.target.value),m(!0)},className:"font-mono text-sm min-h-[400px] resize-y",placeholder:"# zhin.config.yml",spellCheck:!1})}),o("div",{className:"flex items-center gap-2",children:[i(A,{size:"sm",onClick:x,disabled:f||!h,children:f?o(ne,{children:[i(te,{className:"w-4 h-4 mr-1 animate-spin"}),"保存中..."]}):o(ne,{children:[i(we,{className:"w-4 h-4 mr-1"}),"保存"]})}),h&&o(A,{variant:"outline",size:"sm",onClick:()=>{u(s),m(!1)},children:[i(ot,{className:"w-4 h-4 mr-1"}),"撤销"]}),h&&i("span",{className:"text-xs text-muted-foreground",children:"有未保存的更改"})]})]})})]})]})}const $l=/^(.*(?:PASSWORD|SECRET|TOKEN|KEY|PRIVATE|CREDENTIAL).*?=\s*)(.+)$/gim;function jl(s){return s.replace($l,(e,t,n)=>{if(n.startsWith("${")||n.trim()==="")return t+n;const r=n.length>4?n.slice(0,2):"";return t+r+"●".repeat(Math.min(n.length-r.length,20))})}function _l({filename:s,getFile:e,saveFile:t,exists:n}){const[r,a]=T(""),[l,c]=T(""),[d,u]=T(!1),[h,m]=T(!1),[f,g]=T(!0),[w,p]=T(null),[b,k]=T(!1),x=ue(async()=>{u(!0);try{const y=await e(s);a(y),c(y),k(!0)}catch(y){p({type:"error",text:`加载失败: ${y instanceof Error?y.message:"未知错误"}`})}finally{u(!1)}},[s,e]);z(()=>{x()},[x]);const N=async()=>{m(!0),p(null);try{await t(s,r),c(r),p({type:"success",text:"已保存,需重启生效"}),setTimeout(()=>p(null),3e3)}catch(y){p({type:"error",text:`保存失败: ${y instanceof Error?y.message:"未知错误"}`})}finally{m(!1)}},C=r!==l,S=f&&!C?jl(r):r;return d&&!b?o("div",{className:"flex items-center justify-center py-8",children:[i(te,{className:"w-5 h-5 animate-spin text-muted-foreground"}),i("span",{className:"ml-2 text-sm text-muted-foreground",children:"加载中..."})]}):o("div",{className:"space-y-3",children:[!n&&!C&&o(V,{className:"py-2 border-yellow-500/50 text-yellow-700 dark:text-yellow-400",children:[i(Gr,{className:"h-4 w-4"}),i(q,{children:"文件不存在,保存后将自动创建"})]}),w&&o(V,{variant:w.type==="error"?"destructive":"success",className:"py-2",children:[w.type==="error"?i(G,{className:"h-4 w-4"}):i(Ee,{className:"h-4 w-4"}),i(q,{children:w.text})]}),i("div",{className:"relative",children:i(se,{value:S,onChange:y=>{a(y.target.value),g(!1)},onFocus:()=>g(!1),className:"font-mono text-sm min-h-[350px] resize-y",placeholder:"KEY=VALUE",spellCheck:!1})}),o("div",{className:"flex items-center gap-2",children:[i(A,{size:"sm",onClick:N,disabled:h||!C,children:h?o(ne,{children:[i(te,{className:"w-4 h-4 mr-1 animate-spin"}),"保存中..."]}):o(ne,{children:[i(we,{className:"w-4 h-4 mr-1"}),"保存"]})}),C&&i(A,{variant:"outline",size:"sm",onClick:()=>{a(l),g(!0)},children:"撤销"}),i(A,{variant:"ghost",size:"sm",onClick:()=>g(y=>!y),disabled:C,title:f?"显示敏感值":"隐藏敏感值",children:f?i(Hr,{className:"w-4 h-4"}):i(Qr,{className:"w-4 h-4"})}),C&&i("span",{className:"text-xs text-muted-foreground",children:"有未保存的更改"})]})]})}function Pl(){const{files:s,loading:e,error:t,listFiles:n,getFile:r,saveFile:a}=ai(),[l,c]=T(".env"),d=async()=>{try{await n()}catch{}};return e&&s.length===0?o("div",{className:"space-y-4",children:[i("h1",{className:"text-2xl font-bold tracking-tight",children:"环境变量"}),o("div",{className:"flex items-center justify-center py-12",children:[i(te,{className:"w-6 h-6 animate-spin text-muted-foreground"}),i("span",{className:"ml-2 text-sm text-muted-foreground",children:"加载中..."})]})]}):o("div",{className:"space-y-4",children:[o("div",{className:"flex items-center justify-between",children:[o("div",{children:[i("h1",{className:"text-2xl font-bold tracking-tight",children:"环境变量"}),i("p",{className:"text-sm text-muted-foreground mt-1",children:"管理 .env 文件中的环境变量,修改后需重启生效"})]}),o(A,{variant:"outline",size:"sm",onClick:d,disabled:e,children:[i(xe,{className:`w-4 h-4 mr-1 ${e?"animate-spin":""}`}),"刷新"]})]}),t&&o(V,{variant:"destructive",className:"py-2",children:[i(G,{className:"h-4 w-4"}),i(q,{children:t})]}),o(kr,{value:l,onValueChange:c,children:[i(Js,{children:[".env",".env.development",".env.production"].map(u=>{const h=s.find(m=>m.name===u);return o(It,{value:u,className:"gap-1.5",children:[i(Tn,{className:"w-3.5 h-3.5"}),u,h&&!h.exists&&i(_,{variant:"outline",className:"text-[10px] px-1 py-0 ml-1",children:"新"})]},u)})}),[".env",".env.development",".env.production"].map(u=>i(Lt,{value:u,children:i(_l,{filename:u,getFile:r,saveFile:a,exists:s.find(h=>h.name===u)?.exists??!1})},u))]})]})}function Sr(s){switch(s.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return i(os,{className:"w-4 h-4 text-blue-500"});case"js":case"jsx":return i(os,{className:"w-4 h-4 text-yellow-500"});case"json":return i(Le,{className:"w-4 h-4 text-green-500"});case"yml":case"yaml":return i(Le,{className:"w-4 h-4 text-red-400"});case"md":return i(Le,{className:"w-4 h-4 text-gray-400"});case"env":return i(Le,{className:"w-4 h-4 text-orange-500"});default:return s.startsWith(".env")?i(Le,{className:"w-4 h-4 text-orange-500"}):i(Le,{className:"w-4 h-4 text-muted-foreground"})}}const Ml="https://cdn.jsdelivr.net.cn/npm/@highlightjs/cdn-assets@11/styles";function Dl(s){const e=s.split("/").pop()?.toLowerCase()||"";if(e===".env"||e.startsWith(".env."))return"ini";switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":return"javascript";case"css":return"css";case"scss":return"scss";case"less":return"less";case"json":return"json";case"yml":case"yaml":return"yaml";case"md":return"markdown";case"xml":case"html":return"xml";case"sh":case"bash":return"bash";default:return null}}function Rl(){z(()=>{const s="hljs-theme-css";let e=document.getElementById(s);e||(e=document.createElement("link"),e.id=s,e.rel="stylesheet",document.head.appendChild(e));const t=()=>{const r=document.documentElement.classList.contains("dark");e.href=`${Ml}/${r?"github-dark":"github"}.min.css`};t();const n=new MutationObserver(t);return n.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>n.disconnect()},[])}const pn={fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace',fontSize:"13px",lineHeight:"20px",tabSize:2,whiteSpace:"pre"};function Bl({value:s,onChange:e,language:t}){const n=as(null),r=as(null),a=Te(()=>{if(window.hljs&&t&&window.hljs.getLanguage(t))try{return window.hljs.highlight(s,{language:t}).value}catch{}return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},[s,t]),l=ue(()=>{r.current&&n.current&&(r.current.scrollTop=n.current.scrollTop,r.current.scrollLeft=n.current.scrollLeft)},[]),c=ue(d=>{if(d.key==="Tab"){d.preventDefault();const u=d.currentTarget,h=u.selectionStart,m=u.selectionEnd,f=s.substring(0,h)+" "+s.substring(m);e(f),requestAnimationFrame(()=>{u.selectionStart=u.selectionEnd=h+2})}},[s,e]);return o("div",{className:"relative h-full w-full overflow-hidden",children:[i("pre",{ref:r,className:"absolute inset-0 m-0 p-4 overflow-auto pointer-events-none",style:pn,"aria-hidden":!0,children:i("code",{className:t?`hljs language-${t}`:"",dangerouslySetInnerHTML:{__html:a+`
139
+ `},style:{background:"transparent",padding:0,display:"block"}})}),i("textarea",{ref:n,value:s,onChange:d=>e(d.target.value),onScroll:l,onKeyDown:c,wrap:"off",className:"absolute inset-0 w-full h-full resize-none p-4 bg-transparent outline-none border-0",style:{...pn,color:"transparent",caretColor:"hsl(var(--foreground))",WebkitTextFillColor:"transparent"},spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"})]})}function Cr({node:s,selectedPath:e,onSelect:t,depth:n=0}){const[r,a]=T(n<1),l=s.path===e,c=s.type==="directory";return o("div",{children:[o("button",{className:`
140
+ w-full flex items-center gap-1.5 px-2 py-1 text-sm rounded-sm text-left
141
+ hover:bg-accent transition-colors
142
+ ${l?"bg-accent text-accent-foreground font-medium":""}
143
+ `,style:{paddingLeft:`${n*16+8}px`},onClick:()=>{c?a(!r):t(s.path)},children:[c?r?i($t,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}):i(Ss,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}):i("span",{className:"w-3.5"}),c?i(ks,{className:"w-4 h-4 shrink-0 text-amber-500"}):Sr(s.name),i("span",{className:"truncate",children:s.name})]}),c&&r&&s.children&&i("div",{children:s.children.map(d=>i(Cr,{node:d,selectedPath:e,onSelect:t,depth:n+1},d.path))})]})}function Fl({filePath:s,readFile:e,saveFile:t,onClose:n}){const[r,a]=T(""),[l,c]=T(""),[d,u]=T(!0),[h,m]=T(!1),[f,g]=T(null),w=ue(async()=>{u(!0),g(null);try{const x=await e(s);a(x),c(x)}catch(x){g({type:"error",text:`加载失败: ${x instanceof Error?x.message:"未知错误"}`})}finally{u(!1)}},[s,e]);z(()=>{w()},[w]);const p=async()=>{m(!0),g(null);try{await t(s,r),c(r),g({type:"success",text:"已保存"}),setTimeout(()=>g(null),3e3)}catch(x){g({type:"error",text:`保存失败: ${x instanceof Error?x.message:"未知错误"}`})}finally{m(!1)}};z(()=>{const x=N=>{(N.metaKey||N.ctrlKey)&&N.key==="s"&&(N.preventDefault(),b&&!h&&p())};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)});const b=r!==l,k=s.split("/").pop()||s;return d?o("div",{className:"flex items-center justify-center h-full",children:[i(te,{className:"w-5 h-5 animate-spin text-muted-foreground"}),i("span",{className:"ml-2 text-sm text-muted-foreground",children:"加载中..."})]}):o("div",{className:"flex flex-col h-full",children:[o("div",{className:"flex items-center justify-between px-4 py-2 border-b bg-muted/30",children:[o("div",{className:"flex items-center gap-2",children:[Sr(k),i("span",{className:"text-sm font-medium",children:s}),b&&i(_,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"未保存"})]}),i("div",{className:"flex items-center gap-1",children:i(A,{size:"sm",variant:"ghost",onClick:n,title:"关闭",children:i(ot,{className:"w-4 h-4"})})})]}),f&&o(V,{variant:f.type==="error"?"destructive":"success",className:"mx-4 mt-2 py-2",children:[f.type==="error"?i(G,{className:"h-4 w-4"}):i(Ee,{className:"h-4 w-4"}),i(q,{children:f.text})]}),i("div",{className:"flex-1 min-h-0",children:i(Bl,{value:r,onChange:a,language:Dl(k)})}),o("div",{className:"flex items-center gap-2 px-4 py-2 border-t bg-muted/30",children:[i(A,{size:"sm",onClick:p,disabled:h||!b,children:h?o(ne,{children:[i(te,{className:"w-4 h-4 mr-1 animate-spin"}),"保存中..."]}):o(ne,{children:[i(we,{className:"w-4 h-4 mr-1"}),"保存"]})}),b&&i(A,{variant:"outline",size:"sm",onClick:()=>a(l),children:"撤销更改"}),o("span",{className:"text-xs text-muted-foreground ml-auto",children:[r.split(`
144
+ `).length," 行 · Ctrl+S 保存"]})]})]})}function Kl(){Rl();const{tree:s,loading:e,error:t,loadTree:n,readFile:r,saveFile:a}=li(),[l,c]=T(null);return o("div",{className:"space-y-4",children:[o("div",{className:"flex items-center justify-between",children:[o("div",{children:[i("h1",{className:"text-2xl font-bold tracking-tight",children:"文件管理"}),i("p",{className:"text-sm text-muted-foreground mt-1",children:"浏览和编辑工作空间中的配置文件和源代码"})]}),o(A,{variant:"outline",size:"sm",onClick:()=>n(),disabled:e,children:[i(xe,{className:`w-4 h-4 mr-1 ${e?"animate-spin":""}`}),"刷新"]})]}),t&&o(V,{variant:"destructive",className:"py-2",children:[i(G,{className:"h-4 w-4"}),i(q,{children:t})]}),i(P,{className:"overflow-hidden",children:i(M,{className:"p-0",children:o("div",{className:"flex",style:{height:"600px"},children:[o("div",{className:"w-64 border-r flex flex-col shrink-0",children:[i("div",{className:"px-3 py-2 border-b bg-muted/30",children:i("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"文件浏览器"})}),i(qe,{className:"flex-1",children:i("div",{className:"py-1",children:e&&s.length===0?i("div",{className:"flex items-center justify-center py-8",children:i(te,{className:"w-4 h-4 animate-spin text-muted-foreground"})}):s.length===0?i("p",{className:"text-sm text-muted-foreground text-center py-8",children:"暂无文件"}):s.map(d=>i(Cr,{node:d,selectedPath:l,onSelect:c},d.path))})})]}),i("div",{className:"flex-1 min-w-0",children:l?i(Fl,{filePath:l,readFile:r,saveFile:a,onClose:()=>c(null)},l):i("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:o("div",{className:"text-center",children:[i(ks,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),i("p",{className:"text-sm",children:"在左侧选择一个文件开始编辑"}),i("p",{className:"text-xs mt-1 opacity-60",children:"支持 .env、src/、package.json 等关键文件"})]})})})]})})})]})}const Ys=ge.Root;ge.Trigger;const Ul=ge.Portal,Ws=ge.Close,Tr=$.forwardRef(({className:s,...e},t)=>i(ge.Overlay,{ref:t,className:E("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...e}));Tr.displayName="DialogOverlay";const Yt=$.forwardRef(({className:s,children:e,...t},n)=>o(Ul,{children:[i(Tr,{}),o(ge.Content,{ref:n,className:E("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...t,children:[e,o(ge.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[i(ot,{className:"h-4 w-4"}),i("span",{className:"sr-only",children:"Close"})]})]})]}));Yt.displayName="DialogContent";const Wt=({className:s,...e})=>i("div",{className:E("flex flex-col space-y-1.5 text-center sm:text-left",s),...e});Wt.displayName="DialogHeader";const Gt=({className:s,...e})=>i("div",{className:E("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...e});Gt.displayName="DialogFooter";const Ht=$.forwardRef(({className:s,...e},t)=>i(ge.Title,{ref:t,className:E("text-lg font-semibold leading-none tracking-tight",s),...e}));Ht.displayName="DialogTitle";const Vl=$.forwardRef(({className:s,...e},t)=>i(ge.Description,{ref:t,className:E("text-sm text-muted-foreground",s),...e}));Vl.displayName="DialogDescription";function ql({label:s,value:e,onChange:t}){return o("div",{className:"space-y-1",children:[i("label",{className:"text-xs font-medium text-muted-foreground",children:s}),i(Y,{value:e,onChange:n=>t(n.target.value),className:"font-mono text-xs"})]})}function zl({tableName:s,tableInfo:e,select:t,insert:n,update:r,remove:a}){const[l,c]=T(null),[d,u]=T(!1),[h,m]=T(1),[f,g]=T(null),[w,p]=T(null),[b,k]=T(!1),[x,N]=T({}),C=50,S=ue(async()=>{u(!0),g(null);try{const I=await t(s,h,C);c(I)}catch(I){g({type:"error",text:I.message})}finally{u(!1)}},[s,h,t]);z(()=>{S()},[S]);const y=Te(()=>e?.columns?Object.keys(e.columns):l?.rows?.length?Object.keys(l.rows[0]):[],[e,l]),O=Te(()=>{if(!e?.columns)return y[0]||"id";const I=Object.entries(e.columns).find(([,B])=>B.primary);return I?I[0]:y[0]||"id"},[e,y]),v=async I=>{try{const B={};for(const J of y){const pt=x[J];if(!(pt===void 0||pt===""))try{B[J]=JSON.parse(pt)}catch{B[J]=pt}}if(I)await n(s,B);else{const J={[O]:w[O]};await r(s,B,J)}g({type:"success",text:I?"添加成功":"更新成功"}),p(null),k(!1),N({}),setTimeout(()=>g(null),2e3),await S()}catch(B){g({type:"error",text:B.message})}},j=async I=>{if(confirm("确定要删除这条记录吗?"))try{await a(s,{[O]:I[O]}),g({type:"success",text:"删除成功"}),setTimeout(()=>g(null),2e3),await S()}catch(B){g({type:"error",text:B.message})}},H=I=>{p(I),k(!1);const B={};for(const J of y)B[J]=typeof I[J]=="object"?JSON.stringify(I[J]):String(I[J]??"");N(B)},W=()=>{p(null),k(!0);const I={};for(const B of y)I[B]="";N(I)},D=l?Math.ceil(l.total/C):0;return o("div",{className:"space-y-3",children:[f&&o(V,{variant:f.type==="error"?"destructive":"success",className:"py-2",children:[f.type==="error"?i(G,{className:"h-4 w-4"}):i(Ee,{className:"h-4 w-4"}),i(q,{children:f.text})]}),o("div",{className:"flex items-center gap-2",children:[o(A,{size:"sm",variant:"outline",onClick:S,disabled:d,children:[i(xe,{className:`w-3.5 h-3.5 mr-1 ${d?"animate-spin":""}`}),"刷新"]}),o(A,{size:"sm",onClick:W,children:[i(_t,{className:"w-3.5 h-3.5 mr-1"}),"添加"]}),o("span",{className:"text-xs text-muted-foreground ml-auto",children:["共 ",l?.total??0," 条 · 第 ",h,"/",D||1," 页"]})]}),i(qe,{className:"border rounded-md",children:i("div",{className:"overflow-x-auto",children:o("table",{className:"w-full text-sm",children:[i("thead",{children:o("tr",{className:"border-b bg-muted/50",children:[y.map(I=>i("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground whitespace-nowrap",children:I},I)),i("th",{className:"px-3 py-2 text-right font-medium text-muted-foreground w-20",children:"操作"})]})}),i("tbody",{children:d&&!l?i("tr",{children:i("td",{colSpan:y.length+1,className:"text-center py-8",children:i(te,{className:"w-4 h-4 animate-spin inline-block"})})}):l?.rows?.length?l.rows.map((I,B)=>o("tr",{className:"border-b hover:bg-muted/30 transition-colors",children:[y.map(J=>i("td",{className:"px-3 py-1.5 font-mono text-xs max-w-[300px] truncate",children:typeof I[J]=="object"?JSON.stringify(I[J]):String(I[J]??"")},J)),o("td",{className:"px-3 py-1.5 text-right space-x-1 whitespace-nowrap",children:[i(A,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>H(I),children:i(Cs,{className:"w-3 h-3"})}),i(A,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-destructive",onClick:()=>j(I),children:i(Oe,{className:"w-3 h-3"})})]})]},B)):i("tr",{children:i("td",{colSpan:y.length+1,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})})})]})})}),D>1&&o("div",{className:"flex items-center justify-center gap-2",children:[i(A,{size:"sm",variant:"outline",disabled:h<=1,onClick:()=>m(I=>I-1),children:i(An,{className:"w-4 h-4"})}),o("span",{className:"text-xs text-muted-foreground",children:[h," / ",D]}),i(A,{size:"sm",variant:"outline",disabled:h>=D,onClick:()=>m(I=>I+1),children:i(Ss,{className:"w-4 h-4"})})]}),i(Ys,{open:w!==null||b,onOpenChange:I=>{I||(p(null),k(!1))},children:o(Yt,{className:"max-w-md max-h-[80vh] overflow-y-auto",children:[i(Wt,{children:i(Ht,{children:b?"添加记录":"编辑记录"})}),i("div",{className:"space-y-3 py-2",children:y.map(I=>i(ql,{label:I,value:x[I]??"",onChange:B=>N(J=>({...J,[I]:B}))},I))}),o(Gt,{children:[i(Ws,{asChild:!0,children:i(A,{variant:"outline",size:"sm",children:"取消"})}),o(A,{size:"sm",onClick:()=>v(b),children:[i(we,{className:"w-3.5 h-3.5 mr-1"}),"保存"]})]})]})})]})}function Jl({tableName:s,select:e,insert:t,update:n,remove:r}){const[a,l]=T(null),[c,d]=T(!1),[u,h]=T(1),[m,f]=T(null),[g,w]=T(null),[p,b]=T(!1),[k,x]=T(""),N=20,C=ue(async()=>{d(!0),f(null);try{const v=await e(s,u,N);l(v)}catch(v){f({type:"error",text:v.message})}finally{d(!1)}},[s,u,e]);z(()=>{C()},[C]);const S=async v=>{try{const j=JSON.parse(k);if(v)await t(s,j);else{const{_id:H,...W}=j;await n(s,W,{_id:g._id})}f({type:"success",text:v?"添加成功":"更新成功"}),w(null),b(!1),x(""),setTimeout(()=>f(null),2e3),await C()}catch(j){f({type:"error",text:j.message})}},y=async v=>{if(confirm("确定要删除这条文档吗?"))try{await r(s,{_id:v._id}),f({type:"success",text:"删除成功"}),setTimeout(()=>f(null),2e3),await C()}catch(j){f({type:"error",text:j.message})}},O=a?Math.ceil(a.total/N):0;return o("div",{className:"space-y-3",children:[m&&o(V,{variant:m.type==="error"?"destructive":"success",className:"py-2",children:[m.type==="error"?i(G,{className:"h-4 w-4"}):i(Ee,{className:"h-4 w-4"}),i(q,{children:m.text})]}),o("div",{className:"flex items-center gap-2",children:[o(A,{size:"sm",variant:"outline",onClick:C,disabled:c,children:[i(xe,{className:`w-3.5 h-3.5 mr-1 ${c?"animate-spin":""}`}),"刷新"]}),o(A,{size:"sm",onClick:()=>{b(!0),x(`{
145
+
146
+ }`)},children:[i(_t,{className:"w-3.5 h-3.5 mr-1"}),"添加文档"]}),o("span",{className:"text-xs text-muted-foreground ml-auto",children:["共 ",a?.total??0," 条 · 第 ",u,"/",O||1," 页"]})]}),i("div",{className:"space-y-2",children:c&&!a?i("div",{className:"text-center py-8",children:i(te,{className:"w-4 h-4 animate-spin inline-block"})}):a?.rows?.length?a.rows.map((v,j)=>i(P,{className:"overflow-hidden",children:i(M,{className:"p-3",children:o("div",{className:"flex items-start justify-between gap-2",children:[i("pre",{className:"text-xs font-mono flex-1 overflow-x-auto whitespace-pre-wrap break-all",children:JSON.stringify(v,null,2)}),o("div",{className:"flex flex-col gap-1 shrink-0",children:[i(A,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{w(v),b(!1),x(JSON.stringify(v,null,2))},children:i(Cs,{className:"w-3 h-3"})}),i(A,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-destructive",onClick:()=>y(v),children:i(Oe,{className:"w-3 h-3"})})]})]})})},v._id||j)):i("p",{className:"text-center py-8 text-muted-foreground text-sm",children:"暂无文档"})}),O>1&&o("div",{className:"flex items-center justify-center gap-2",children:[i(A,{size:"sm",variant:"outline",disabled:u<=1,onClick:()=>h(v=>v-1),children:i(An,{className:"w-4 h-4"})}),o("span",{className:"text-xs text-muted-foreground",children:[u," / ",O]}),i(A,{size:"sm",variant:"outline",disabled:u>=O,onClick:()=>h(v=>v+1),children:i(Ss,{className:"w-4 h-4"})})]}),i(Ys,{open:g!==null||p,onOpenChange:v=>{v||(w(null),b(!1))},children:o(Yt,{className:"max-w-lg",children:[i(Wt,{children:i(Ht,{children:p?"添加文档":"编辑文档"})}),i("textarea",{value:k,onChange:v=>x(v.target.value),className:"w-full h-60 font-mono text-xs p-3 border rounded-md resize-none bg-background",spellCheck:!1}),o(Gt,{children:[i(Ws,{asChild:!0,children:i(A,{variant:"outline",size:"sm",children:"取消"})}),o(A,{size:"sm",onClick:()=>S(p),children:[i(we,{className:"w-3.5 h-3.5 mr-1"}),"保存"]})]})]})})]})}function Yl({tableName:s,kvGet:e,kvSet:t,kvDelete:n,kvEntries:r}){const[a,l]=T([]),[c,d]=T(!1),[u,h]=T(null),[m,f]=T(null),[g,w]=T(!1),[p,b]=T(""),[k,x]=T(""),N=ue(async()=>{d(!0),h(null);try{const y=await r(s);l(y.entries)}catch(y){h({type:"error",text:y.message})}finally{d(!1)}},[s,r]);z(()=>{N()},[N]);const C=async y=>{try{let O;try{O=JSON.parse(k)}catch{O=k}await t(s,p,O),h({type:"success",text:y?"添加成功":"更新成功"}),f(null),w(!1),b(""),x(""),setTimeout(()=>h(null),2e3),await N()}catch(O){h({type:"error",text:O.message})}},S=async y=>{if(confirm(`确定要删除键 "${y}" 吗?`))try{await n(s,y),h({type:"success",text:"删除成功"}),setTimeout(()=>h(null),2e3),await N()}catch(O){h({type:"error",text:O.message})}};return o("div",{className:"space-y-3",children:[u&&o(V,{variant:u.type==="error"?"destructive":"success",className:"py-2",children:[u.type==="error"?i(G,{className:"h-4 w-4"}):i(Ee,{className:"h-4 w-4"}),i(q,{children:u.text})]}),o("div",{className:"flex items-center gap-2",children:[o(A,{size:"sm",variant:"outline",onClick:N,disabled:c,children:[i(xe,{className:`w-3.5 h-3.5 mr-1 ${c?"animate-spin":""}`}),"刷新"]}),o(A,{size:"sm",onClick:()=>{w(!0),b(""),x("")},children:[i(_t,{className:"w-3.5 h-3.5 mr-1"}),"添加键值"]}),o("span",{className:"text-xs text-muted-foreground ml-auto",children:["共 ",a.length," 个键"]})]}),i(qe,{className:"border rounded-md",children:o("table",{className:"w-full text-sm",children:[i("thead",{children:o("tr",{className:"border-b bg-muted/50",children:[i("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground w-1/3",children:"Key"}),i("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Value"}),i("th",{className:"px-3 py-2 text-right font-medium text-muted-foreground w-20",children:"操作"})]})}),i("tbody",{children:c&&!a.length?i("tr",{children:i("td",{colSpan:3,className:"text-center py-8",children:i(te,{className:"w-4 h-4 animate-spin inline-block"})})}):a.length?a.map(y=>o("tr",{className:"border-b hover:bg-muted/30 transition-colors",children:[o("td",{className:"px-3 py-1.5 font-mono text-xs",children:[i(On,{className:"w-3 h-3 inline-block mr-1 text-muted-foreground"}),y.key]}),i("td",{className:"px-3 py-1.5 font-mono text-xs max-w-[400px] truncate",children:typeof y.value=="object"?JSON.stringify(y.value):String(y.value??"")}),o("td",{className:"px-3 py-1.5 text-right space-x-1 whitespace-nowrap",children:[i(A,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{f(y),w(!1),b(y.key),x(typeof y.value=="object"?JSON.stringify(y.value,null,2):String(y.value??""))},children:i(Cs,{className:"w-3 h-3"})}),i(A,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-destructive",onClick:()=>S(y.key),children:i(Oe,{className:"w-3 h-3"})})]})]},y.key)):i("tr",{children:i("td",{colSpan:3,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})})})]})}),i(Ys,{open:m!==null||g,onOpenChange:y=>{y||(f(null),w(!1))},children:o(Yt,{className:"max-w-md",children:[i(Wt,{children:i(Ht,{children:g?"添加键值":"编辑键值"})}),o("div",{className:"space-y-3 py-2",children:[o("div",{className:"space-y-1",children:[i("label",{className:"text-xs font-medium text-muted-foreground",children:"Key"}),i(Y,{value:p,onChange:y=>b(y.target.value),className:"font-mono text-xs",disabled:!g})]}),o("div",{className:"space-y-1",children:[i("label",{className:"text-xs font-medium text-muted-foreground",children:"Value (JSON 或纯文本)"}),i("textarea",{value:k,onChange:y=>x(y.target.value),className:"w-full h-32 font-mono text-xs p-3 border rounded-md resize-none bg-background",spellCheck:!1})]})]}),o(Gt,{children:[i(Ws,{asChild:!0,children:i(A,{variant:"outline",size:"sm",children:"取消"})}),o(A,{size:"sm",onClick:()=>C(g),children:[i(we,{className:"w-3.5 h-3.5 mr-1"}),"保存"]})]})]})})]})}const gn={related:"关系型",document:"文档型",keyvalue:"键值型"},Wl={sqlite:"SQLite",mysql:"MySQL",pg:"PostgreSQL",memory:"Memory",mongodb:"MongoDB",redis:"Redis"};function Gl(){const{info:s,tables:e,loading:t,error:n,loadInfo:r,loadTables:a,dropTable:l,select:c,insert:d,update:u,remove:h,kvGet:m,kvSet:f,kvDelete:g,kvEntries:w}=oi(),[p,b]=T(null),k=Te(()=>e.find(N=>N.name===p),[e,p]),x=s?.type??"related";return o("div",{className:"space-y-4",children:[o("div",{className:"flex items-center justify-between",children:[o("div",{children:[i("h1",{className:"text-2xl font-bold tracking-tight",children:"数据库管理"}),o("p",{className:"text-sm text-muted-foreground mt-1",children:["浏览和管理",gn[x],"数据库中的数据"]})]}),o("div",{className:"flex items-center gap-2",children:[s&&o(_,{variant:"secondary",children:[Wl[s.dialect]||s.dialect," · ",gn[s.type]]}),o(A,{variant:"outline",size:"sm",onClick:()=>{r().catch(()=>{}),a().catch(()=>{})},disabled:t,children:[i(xe,{className:`w-4 h-4 mr-1 ${t?"animate-spin":""}`}),"刷新"]})]})]}),n&&o(V,{variant:"destructive",className:"py-2",children:[i(G,{className:"h-4 w-4"}),i(q,{children:n})]}),i(P,{className:"overflow-hidden",children:i(M,{className:"p-0",children:o("div",{className:"flex",style:{minHeight:"500px"},children:[o("div",{className:"w-56 border-r flex flex-col shrink-0",children:[i("div",{className:"px-3 py-2 border-b bg-muted/30",children:i("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:x==="related"?"数据表":x==="document"?"集合":"桶"})}),i(qe,{className:"flex-1",children:i("div",{className:"py-1",children:t&&!e.length?i("div",{className:"flex items-center justify-center py-8",children:i(te,{className:"w-4 h-4 animate-spin text-muted-foreground"})}):e.length?e.map(N=>o("button",{className:`
147
+ group w-full flex items-center gap-2 px-3 py-1.5 text-sm text-left
148
+ hover:bg-accent transition-colors rounded-sm
149
+ ${p===N.name?"bg-accent text-accent-foreground font-medium":""}
150
+ `,onClick:()=>b(N.name),children:[x==="keyvalue"?i(On,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}):i(Hs,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),i("span",{className:"truncate flex-1",children:N.name}),N.columns&&i(_,{variant:"secondary",className:"ml-auto text-[10px] px-1 py-0",children:Object.keys(N.columns).length}),i(A,{size:"sm",variant:"ghost",className:"h-5 w-5 p-0 opacity-0 group-hover:opacity-100 text-destructive shrink-0",onClick:C=>{C.stopPropagation(),confirm(`确定要删除${x==="related"?"表":x==="document"?"集合":"桶"} "${N.name}" 吗?此操作不可撤销!`)&&l(N.name).then(()=>{p===N.name&&b(null)}).catch(()=>{})},children:i(Oe,{className:"w-3 h-3"})})]},N.name)):i("p",{className:"text-sm text-muted-foreground text-center py-8",children:"暂无数据"})})})]}),i("div",{className:"flex-1 min-w-0 p-4",children:p?o(ne,{children:[o("div",{className:"flex items-center gap-2 mb-4",children:[i(Hs,{className:"w-5 h-5 text-muted-foreground"}),i("h2",{className:"text-lg font-semibold",children:p}),k?.columns&&o("div",{className:"flex gap-1 ml-2 flex-wrap",children:[Object.entries(k.columns).slice(0,8).map(([N,C])=>o(_,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:[N,C.primary?" 🔑":"",": ",C.type]},N)),Object.keys(k.columns).length>8&&o(_,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:["+",Object.keys(k.columns).length-8]})]})]}),x==="keyvalue"?i(Yl,{tableName:p,kvGet:m,kvSet:f,kvDelete:g,kvEntries:w},p):x==="document"?i(Jl,{tableName:p,select:c,insert:d,update:u,remove:h},p):i(zl,{tableName:p,tableInfo:k,select:c,insert:d,update:u,remove:h},p)]}):i("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:o("div",{className:"text-center",children:[i(Fe,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),o("p",{className:"text-sm",children:["在左侧选择",x==="related"?"一个表":x==="document"?"一个集合":"一个桶","开始管理"]})]})})})]})})})]})}function Hl({onSuccess:s}){const[e,t]=T(""),[n,r]=T(""),[a,l]=T(!1),c=ue(async()=>{const d=e.trim();if(!d){r("请输入 Token");return}l(!0),r("");try{const u=await fetch("/api/system/status",{headers:{Authorization:`Bearer ${d}`}});u.ok?(Bi(d),s()):u.status===401?r("Token 无效,请检查后重试"):r(`验证失败 (HTTP ${u.status})`)}catch{r("无法连接到服务器")}finally{l(!1)}},[e,s]);return i("div",{className:"flex items-center justify-center min-h-screen bg-background",children:o(P,{className:E("w-full max-w-md mx-4"),children:[o(oe,{className:"text-center space-y-2",children:[i("div",{className:"flex items-center justify-center mx-auto w-12 h-12 rounded-xl bg-foreground text-background font-bold text-xl",children:"Z"}),i(ce,{className:"text-xl",children:"Zhin.js 控制台"}),i(Ze,{children:"请输入 API Token 以访问管理面板"})]}),i(M,{children:o("form",{onSubmit:d=>{d.preventDefault(),c()},className:"space-y-4",children:[o("div",{className:"space-y-2",children:[i(Y,{type:"password",placeholder:"API Token",value:e,onChange:d=>{t(d.target.value),n&&r("")},autoFocus:!0}),n&&i("p",{className:"text-sm text-destructive",children:n})]}),i(A,{type:"submit",className:"w-full",disabled:a,children:a?"验证中...":"登录"}),o("p",{className:"text-xs text-center text-muted-foreground",children:["Token 位于 ",i("code",{className:"text-xs bg-muted px-1 rounded",children:".env"})," 文件的"," ",i("code",{className:"text-xs bg-muted px-1 rounded",children:"HTTP_TOKEN"})," 中"]})]})})]})})}function St(s){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?St=function(t){return typeof t}:St=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},St(s)}function Ql(s,e){if(!(s instanceof e))throw new TypeError("Cannot call a class as a function")}function Xl(s,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(s,n.key,n)}}function Zl(s,e,t){return e&&Xl(s.prototype,e),s}function eo(s,e){return e&&(St(e)==="object"||typeof e=="function")?e:Ct(s)}function gs(s){return gs=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},gs(s)}function Ct(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function to(s,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(e&&e.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),e&&ys(s,e)}function ys(s,e){return ys=Object.setPrototypeOf||function(n,r){return n.__proto__=r,n},ys(s,e)}function Tt(s,e,t){return e in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}var Or=(function(s){to(e,s);function e(){var t,n;Ql(this,e);for(var r=arguments.length,a=new Array(r),l=0;l<r;l++)a[l]=arguments[l];return n=eo(this,(t=gs(e)).call.apply(t,[this].concat(a))),Tt(Ct(n),"state",{bootstrapped:!1}),Tt(Ct(n),"_unsubscribe",void 0),Tt(Ct(n),"handlePersistorState",function(){var c=n.props.persistor,d=c.getState(),u=d.bootstrapped;u&&(n.props.onBeforeLift?Promise.resolve(n.props.onBeforeLift()).finally(function(){return n.setState({bootstrapped:!0})}):n.setState({bootstrapped:!0}),n._unsubscribe&&n._unsubscribe())}),n}return Zl(e,[{key:"componentDidMount",value:function(){this._unsubscribe=this.props.persistor.subscribe(this.handlePersistorState),this.handlePersistorState()}},{key:"componentWillUnmount",value:function(){this._unsubscribe&&this._unsubscribe()}},{key:"render",value:function(){return typeof this.props.children=="function"?this.props.children(this.state.bootstrapped):this.state.bootstrapped?this.props.children:this.props.loading}}]),e})(Er);Tt(Or,"defaultProps",{children:null,loading:null});const so=rt.Provider;rt.Root;rt.Trigger;const no=$.forwardRef(({className:s,sideOffset:e=4,...t},n)=>i(rt.Portal,{children:i(rt.Content,{ref:n,sideOffset:e,className:E("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...t})}));no.displayName="TooltipContent";_i();function ro(){const[s,e]=T(Fi()),t=ue(()=>e(!0),[]);return z(()=>{const n=()=>e(!1);return window.addEventListener("zhin:auth-required",n),()=>window.removeEventListener("zhin:auth-required",n)},[]),s?i(Or,{loading:null,persistor:ci,children:i($i,{store:di,children:i(io,{})})}):i(Hl,{onSuccess:t})}function io(){ui();const s=De(l=>l.script.entries),e=De(l=>l.script.loadedScripts),t=De(l=>l.script.synced),[n,r]=T(!1);z(()=>{[{key:"dashboard-layout",path:"/",title:"Dashboard",element:i(Ki,{}),meta:{order:0},children:[{key:"homePage",path:"/dashboard",title:"系统概览",icon:i(Xr,{className:"w-4 h-4"}),element:i(Ji,{})},{key:"pluginsPage",path:"/plugins",title:"插件管理",icon:i(fe,{className:"w-4 h-4"}),element:i(Gi,{}),meta:{order:2}},{key:"pluginDetailPage",title:"插件详情",path:"/plugins/:name",element:i(ga,{}),meta:{hideInMenu:!0}},{key:"configPage",path:"/config",title:"配置管理",icon:i(lt,{className:"w-4 h-4"}),element:i(Ll,{}),meta:{order:3}},{key:"envManagePage",path:"/env",title:"环境变量",icon:i(Tn,{className:"w-4 h-4"}),element:i(Pl,{}),meta:{order:4}},{key:"fileManagePage",path:"/files",title:"文件管理",icon:i(ks,{className:"w-4 h-4"}),element:i(Kl,{}),meta:{order:5}},{key:"databasePage",path:"/database",title:"数据库",icon:i(Fe,{className:"w-4 h-4"}),element:i(Gl,{}),meta:{order:6}},{key:"botManagePage",path:"/bots",title:"机器人",icon:i(st,{className:"w-4 h-4"}),element:i(ba,{}),meta:{order:7}},{key:"logsPage ",path:"/logs",title:"系统日志",icon:i(Ns,{className:"w-4 h-4"}),element:i(Na,{}),meta:{order:8}}]}].forEach(c=>{fi(c)}),r(!0)},[]);const a=t&&(s.length===0||s.length===e.length);return!n||!a?i("div",{className:"flex items-center justify-center h-screen bg-background",children:o("div",{className:"text-center",children:[i("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-2 border-muted-foreground border-t-foreground"}),o("p",{className:"mt-3 text-sm text-muted-foreground",children:["加载中... (",e.length,"/",s.length,")"]})]})}):i(hi,{})}Lr(document.getElementById("root")).render(i(Ir,{children:i(so,{children:i(ro,{})})}));