@zhin.js/console 2.0.4 → 2.0.6
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/CHANGELOG.md +23 -0
- package/browser.tsconfig.json +0 -1
- package/client/src/pages/marketplace.tsx +24 -17
- package/dist/assets/index-C6cpEkIY.js +124 -0
- package/dist/index.html +1 -1
- package/package.json +7 -7
- package/dist/assets/index-BMkFI-uN.js +0 -124
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import*as e from"react";import{Fragment as t,PureComponent as n,StrictMode as r,useCallback as i,useEffect as a,useMemo as o,useRef as s,useState as c}from"react";import{createRoot as l}from"react-dom/client";import{Activity as u,AlertCircle as d,AlertTriangle as f,ArrowLeft as p,ArrowUpDown as m,Bell as h,Bot as g,Box as _,Brain as v,Calendar as y,Check as b,CheckCircle as x,ChevronDown as S,ChevronLeft as C,ChevronRight as w,ChevronUp as T,Circle as E,Clock as D,Code as O,Copy as k,Cpu as ee,Database as te,Download as ne,ExternalLink as A,Eye as j,EyeOff as M,File as N,FileCode as re,FileText as ie,FileWarning as ae,FolderOpen as oe,FormInput as se,GitBranch as ce,Globe as le,Hash as ue,Home as de,Image as fe,Info as pe,Key as me,KeyRound as he,Layers as ge,List as _e,Loader2 as P,Lock as ve,LogOut as ye,MemoryStick as be,Menu as xe,MessageSquare as Se,Moon as Ce,MoreHorizontal as we,Music as Te,Package as F,Pause as Ee,Pencil as De,Play as Oe,Plug as ke,Plus as Ae,RefreshCw as I,RotateCw as je,Save as Me,Search as Ne,Send as Pe,Server as Fe,Settings as Ie,Shield as Le,ShieldCheck as Re,Store as ze,Sun as Be,Table2 as Ve,Terminal as He,Timer as Ue,Trash2 as We,TrendingUp as Ge,User as Ke,UserMinus as qe,UserPlus as Je,Users as Ye,Video as Xe,Wifi as Ze,WifiOff as Qe,Wrench as $e,X as et,XCircle as tt,Zap as nt}from"lucide-react";import{DynamicRouter as rt,Link as it,Outlet as at,addPage as ot,cn as L,persistor as st,pickMediaRawUrl as ct,resolveMediaSrc as lt,selectConfigConnected as ut,setActiveMenu as dt,store as ft,toggleSidebar as pt,useConfig as mt,useConfigYaml as ht,useDatabase as gt,useDispatch as _t,useEnvFiles as vt,useFiles as yt,useSelector as bt,useWebSocket as xt}from"@zhin.js/client";import{Link as St,matchPath as Ct,useLocation as wt,useNavigate as Tt,useParams as Et}from"react-router";import{Fragment as R,jsx as z,jsxs as B}from"react/jsx-runtime";import{cva as Dt}from"class-variance-authority";import{Accordion as Ot,Checkbox as kt,Dialog as At,ScrollArea as jt,Select as Mt,Separator as Nt,Switch as Pt,Tabs as Ft,Tooltip as It}from"radix-ui";var Lt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Rt=Lt(((t,n)=>{n.exports={...e}})),zt=Lt((e=>{var t=Rt();typeof Object.is==`function`&&Object.is,t.useSyncExternalStore,t.useRef,t.useEffect,t.useMemo,t.useDebugValue}));Lt(((e,t)=>{t.exports=zt()}))();function Bt(e){e()}function Vt(){let e=null,t=null;return{clear(){e=null,t=null},notify(){Bt(()=>{let t=e;for(;t;)t.callback(),t=t.next})},get(){let t=[],n=e;for(;n;)t.push(n),n=n.next;return t},subscribe(n){let r=!0,i=t={callback:n,next:null,prev:t};return i.prev?i.prev.next=i:e=i,function(){!r||e===null||(r=!1,i.next?i.next.prev=i.prev:t=i.prev,i.prev?i.prev.next=i.next:e=i.next)}}}}var Ht={notify(){},get:()=>[]};function Ut(e,t){let n,r=Ht,i=0,a=!1;function o(e){u();let t=r.subscribe(e),n=!1;return()=>{n||(n=!0,t(),d())}}function s(){r.notify()}function c(){m.onStateChange&&m.onStateChange()}function l(){return a}function u(){i++,n||(n=t?t.addNestedSub(c):e.subscribe(c),r=Vt())}function d(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=Ht)}function f(){a||(a=!0,u())}function p(){a&&(a=!1,d())}let m={addNestedSub:o,notifyNestedSubs:s,handleChangeWrapper:c,isSubscribed:l,trySubscribe:f,tryUnsubscribe:p,getListeners:()=>r};return m}var Wt=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,Gt=typeof navigator<`u`&&navigator.product===`ReactNative`,Kt=Wt||Gt?e.useLayoutEffect:e.useEffect;Object.prototype;var qt=Symbol.for(`react-redux-context`),Jt=typeof globalThis<`u`?globalThis:{};function Yt(){if(!e.createContext)return{};let t=Jt[qt]??=new Map,n=t.get(e.createContext);return n||(n=e.createContext(null),t.set(e.createContext,n)),n}var Xt=Yt();function Zt(t){let{children:n,context:r,serverState:i,store:a}=t,o=e.useMemo(()=>({store:a,subscription:Ut(a),getServerState:i?()=>i:void 0}),[a,i]),s=e.useMemo(()=>a.getState(),[a]);Kt(()=>{let{subscription:e}=o;return e.onStateChange=e.notifyNestedSubs,e.trySubscribe(),s!==a.getState()&&e.notifyNestedSubs(),()=>{e.tryUnsubscribe(),e.onStateChange=void 0}},[o,s]);let c=r||Xt;return e.createElement(c.Provider,{value:o},n)}var Qt=Zt,$t={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(e){let t=document.documentElement,n=$t[e];t.classList.remove(`light`,`dark`),t.classList.add(e),Object.entries(n).forEach(([e,n])=>{t.style.setProperty(`--${e}`,n)}),localStorage.setItem(`theme`,e)}function tn(){let e=localStorage.getItem(`theme`);return e&&(e===`light`||e===`dark`)?e:window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function nn(){let e=tn();return en(e),e}function rn(){let[e,t]=c(tn);return a(()=>{en(e)},[e]),{theme:e,setTheme:t,toggleTheme:()=>{t(e=>e===`light`?`dark`:`light`)}}}function an(){let{theme:e,toggleTheme:t}=rn();return z(`button`,{onClick:t,className:`p-2 hover:bg-accent rounded-lg transition-colors text-foreground`,title:e===`light`?`切换到暗色模式`:`切换到亮色模式`,children:z(e===`light`?Ce:Be,{className:`w-5 h-5`})})}var on=Dt(`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`}}),V=e.forwardRef(({className:e,variant:t,size:n,...r},i)=>z(`button`,{className:L(on({variant:t,size:n,className:e})),ref:i,...r}));V.displayName=`Button`;var H=e.forwardRef(({className:e,type:t,...n},r)=>z(`input`,{type:t,className:L(`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`,e),ref:r,...n}));H.displayName=`Input`;var sn=e.forwardRef(({className:e,children:t,...n},r)=>B(jt.Root,{ref:r,className:L(`relative overflow-hidden`,e),...n,children:[z(jt.Viewport,{className:`h-full w-full rounded-[inherit]`,children:t}),z(cn,{}),z(jt.Corner,{})]}));sn.displayName=`ScrollArea`;var cn=e.forwardRef(({className:e,orientation:t,...n},r)=>{let i=t??`vertical`;return z(jt.Scrollbar,{ref:r,orientation:i,className:L(`flex touch-none select-none transition-colors`,i===`vertical`&&`h-full w-2.5 border-l border-l-transparent p-[1px]`,i===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent p-[1px]`,e),...n,children:z(jt.Thumb,{className:`relative flex-1 rounded-full bg-border`})})});cn.displayName=`ScrollBar`;var ln=e.forwardRef(({className:e,orientation:t,decorative:n=!0,...r},i)=>{let a=t??`horizontal`;return z(Nt.Root,{ref:i,decorative:n,orientation:a,className:L(`shrink-0 bg-border`,a===`horizontal`?`h-[1px] w-full`:`h-full w-[1px]`,e),...r})});ln.displayName=`Separator`;var un=`zhin_api_token`;function dn(){return localStorage.getItem(un)}function fn(e){localStorage.setItem(un,e)}function pn(){localStorage.removeItem(un)}function mn(){return!!localStorage.getItem(un)}async function hn(e,t){let n=dn(),r=new Headers(t?.headers);n&&r.set(`Authorization`,`Bearer ${n}`);let i=await fetch(e,{...t,headers:r});return i.status===401&&(pn(),window.dispatchEvent(new CustomEvent(`zhin:auth-required`))),i}var gn=[`系统`,`扩展`,`配置与数据`,`其他`];function _n(e){return e.filter(e=>!e.meta?.hideInMenu&&e.key!==`dashboardLayout`)}function vn(e,t){return o(()=>{let n=e.find(e=>e.key===`dashboardLayout`)?.children??[];for(let e of n)if(!(!e.meta?.fullWidth||!e.path)&&Ct({path:e.path,end:!0},t))return!0;return!1},[e,t])}function yn(){let e=_t(),t=wt(),n=Tt(),r=bt(e=>e.ui.sidebarOpen),a=bt(e=>e.ui.activeMenu),s=bt(e=>e.route?.routes||[]),[l,u]=c(``),d=o(()=>{let e=s.find(e=>e.key===`dashboardLayout`);return e?.children?_n(e.children).sort((e,t)=>(e.meta?.order??999)-(t.meta?.order??999)):[]},[s]),f=o(()=>{let e=new Map;for(let t of d){let n=t.meta?.group??`其他`;e.has(n)||e.set(n,[]),e.get(n).push(t)}for(let[,t]of e)t.sort((e,t)=>(e.meta?.order??999)-(t.meta?.order??999));return e},[d]),p=o(()=>d.map(e=>({title:e.title,path:e.path,key:e.key})),[d]),m=o(()=>{let e=l.trim().toLowerCase();return e?p.filter(t=>t.title.toLowerCase().includes(e)||t.path.toLowerCase().includes(e)):p},[l,p]),h=i(t=>{if(t.key!==`Enter`)return;let r=m[0];r?.path&&(n(r.path),e(dt(r.key)),u(``))},[m,n,e]),g=vn(s,t.pathname),_=o(()=>{let e=new Set,t=[];for(let n of gn)f.has(n)&&f.get(n).length&&(t.push(n),e.add(n));for(let n of f.keys())!e.has(n)&&f.get(n).length&&t.push(n);return t},[f]);return B(`div`,{className:`flex h-screen bg-background`,children:[B(`div`,{className:L(`flex flex-col border-r bg-sidebar transition-all duration-300`,r?`w-64`:`w-16`),children:[z(`div`,{className:`p-4 border-b`,children:B(`div`,{className:L(`flex items-center transition-all duration-300`,r?`gap-3`:`justify-center`),children:[z(`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`}),r&&B(`div`,{className:`flex flex-col min-w-0`,children:[z(`span`,{className:`text-base font-semibold truncate`,children:`Zhin.js`}),z(`span`,{className:`text-xs text-muted-foreground`,children:`管理控制台`})]})]})}),z(sn,{className:`flex-1`,children:z(`div`,{className:`p-2 space-y-3`,children:_.map(t=>{let n=f.get(t)??[];return n.length?B(`div`,{className:`space-y-1`,children:[r&&z(`div`,{className:`px-2 pt-1 pb-0.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:t}),n.map((n,i)=>{let o=n.key||`menu-item-${t}-${i}`,s=a===o;return B(it,{to:n.path,onClick:()=>e(dt(o)),className:L(`menu-item`,s&&`active`,!r&&`justify-center px-2`),children:[z(`span`,{className:`shrink-0`,children:n.icon}),r&&z(`span`,{className:`truncate`,children:n.title})]},o)})]},t):null})})})]}),B(`div`,{className:`flex flex-col flex-1 overflow-hidden min-w-0`,children:[B(`header`,{className:`flex items-center justify-between h-14 px-4 border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 shrink-0`,children:[B(`div`,{className:`flex items-center gap-3 min-w-0`,children:[z(V,{variant:`ghost`,size:`icon`,onClick:()=>e(pt()),children:z(xe,{className:`h-5 w-5`})}),B(`div`,{className:`flex flex-col min-w-0`,children:[z(`h2`,{className:`text-sm font-semibold truncate`,children:`控制台`}),z(`span`,{className:`text-xs text-muted-foreground truncate`,children:`跳转菜单 · Enter 打开首条`})]})]}),z(`div`,{className:`hidden md:flex flex-1 max-w-md mx-4`,children:B(`div`,{className:`relative w-full`,children:[z(Ne,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none`}),z(H,{value:l,onChange:e=>u(e.target.value),onKeyDown:h,placeholder:`按名称或路径搜索菜单…`,className:`pl-9 bg-muted/50`,list:`console-nav-search`,autoComplete:`off`}),z(`datalist`,{id:`console-nav-search`,children:p.map(e=>z(`option`,{value:`${e.title} ${e.path}`},e.path))})]})}),B(`div`,{className:`flex items-center gap-1 shrink-0`,children:[z(an,{}),z(V,{variant:`ghost`,size:`icon`,title:`退出登录`,onClick:()=>{pn(),window.dispatchEvent(new CustomEvent(`zhin:auth-required`))},children:z(ye,{className:`h-4 w-4`})})]})]}),z(ln,{className:`md:hidden`}),z(`main`,{className:`flex-1 overflow-auto min-h-0`,children:z(`div`,{className:L(`mx-auto p-6`,g?`max-w-none w-full`:`max-w-7xl`),children:z(at,{})})})]})]})}var U=e.forwardRef(({className:e,...t},n)=>z(`div`,{ref:n,className:L(`rounded-lg border bg-card text-card-foreground shadow-sm`,e),...t}));U.displayName=`Card`;var bn=e.forwardRef(({className:e,...t},n)=>z(`div`,{ref:n,className:L(`flex flex-col space-y-1.5 p-6`,e),...t}));bn.displayName=`CardHeader`;var xn=e.forwardRef(({className:e,...t},n)=>z(`div`,{ref:n,className:L(`text-lg font-semibold leading-none tracking-tight`,e),...t}));xn.displayName=`CardTitle`;var Sn=e.forwardRef(({className:e,...t},n)=>z(`div`,{ref:n,className:L(`text-sm text-muted-foreground`,e),...t}));Sn.displayName=`CardDescription`;var W=e.forwardRef(({className:e,...t},n)=>z(`div`,{ref:n,className:L(`p-6 pt-0`,e),...t}));W.displayName=`CardContent`;var Cn=e.forwardRef(({className:e,...t},n)=>z(`div`,{ref:n,className:L(`flex items-center p-6 pt-0`,e),...t}));Cn.displayName=`CardFooter`;var wn=Dt(`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 G({className:e,variant:t,...n}){return z(`div`,{className:L(wn({variant:t}),e),...n})}var Tn=Dt(`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`}}),K=e.forwardRef(({className:e,variant:t,...n},r)=>z(`div`,{ref:r,role:`alert`,className:L(Tn({variant:t}),e),...n}));K.displayName=`Alert`;var En=e.forwardRef(({className:e,...t},n)=>z(`h5`,{ref:n,className:L(`mb-1 font-medium leading-none tracking-tight`,e),...t}));En.displayName=`AlertTitle`;var q=e.forwardRef(({className:e,...t},n)=>z(`div`,{ref:n,className:L(`text-sm [&_p]:leading-relaxed`,e),...t}));q.displayName=`AlertDescription`;function J({className:e,...t}){return z(`div`,{className:L(`animate-pulse rounded-md bg-primary/10`,e),...t})}var Dn=At.Root;At.Trigger;var On=At.Portal,kn=At.Close,An=e.forwardRef(({className:e,...t},n)=>z(At.Overlay,{ref:n,className:L(`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`,e),...t}));An.displayName=`DialogOverlay`;var jn=e.forwardRef(({className:e,children:t,...n},r)=>B(On,{children:[z(An,{}),B(At.Content,{ref:r,className:L(`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`,e),...n,children:[t,B(At.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:[z(et,{className:`h-4 w-4`}),z(`span`,{className:`sr-only`,children:`Close`})]})]})]}));jn.displayName=`DialogContent`;var Mn=({className:e,...t})=>z(`div`,{className:L(`flex flex-col space-y-1.5 text-center sm:text-left`,e),...t});Mn.displayName=`DialogHeader`;var Nn=({className:e,...t})=>z(`div`,{className:L(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});Nn.displayName=`DialogFooter`;var Pn=e.forwardRef(({className:e,...t},n)=>z(At.Title,{ref:n,className:L(`text-lg font-semibold leading-none tracking-tight`,e),...t}));Pn.displayName=`DialogTitle`;var Fn=e.forwardRef(({className:e,...t},n)=>z(At.Description,{ref:n,className:L(`text-sm text-muted-foreground`,e),...t}));Fn.displayName=`DialogDescription`;function In(){let e=Tt(),[t,n]=c(null),[r,i]=c(null),[o,s]=c(!0),[l,f]=c(null),[p,m]=c(!1),[h,_]=c(!1),{sendRequest:v}=xt();a(()=>{y();let e=setInterval(y,5e3);return()=>clearInterval(e)},[]);let y=async()=>{try{let[e,t]=await Promise.all([hn(`/api/stats`),hn(`/api/system/status`)]);if(!e.ok||!t.ok)throw Error(`API 请求失败`);let r=await e.json(),a=await t.json();r.success&&a.success&&(n(r.data),i(a.data),f(null))}catch(e){f(e.message)}finally{s(!1)}},b=e=>`${Math.floor(e/86400)}天 ${Math.floor(e%86400/3600)}小时 ${Math.floor(e%3600/60)}分钟`,x=e=>`${(e/1024/1024).toFixed(2)} MB`,S=async()=>{_(!0);try{await v({type:`system:restart`})}catch{}setTimeout(()=>{window.location.reload()},3e3)};return o?B(`div`,{className:`space-y-6`,children:[B(`div`,{children:[z(J,{className:`h-8 w-48`}),z(J,{className:`h-4 w-64 mt-2`})]}),z(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4`,children:[...[,,,,]].map((e,t)=>z(J,{className:`h-32`},t))})]}):l?z(`div`,{className:`flex items-center justify-center h-full`,children:B(K,{variant:`destructive`,className:`max-w-md`,children:[z(d,{className:`h-4 w-4`}),B(q,{children:[`加载失败: `,l]})]})}):B(`div`,{className:`space-y-6`,children:[B(`div`,{children:[z(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`系统概览`}),z(`p`,{className:`text-muted-foreground`,children:`实时监控您的机器人框架运行状态`})]}),B(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4`,children:[B(U,{children:[B(bn,{className:`flex flex-row items-center justify-between pb-2`,children:[z(xn,{className:`text-sm font-medium text-muted-foreground`,children:`插件总数`}),z(F,{className:`h-4 w-4 text-muted-foreground`})]}),B(W,{children:[z(`div`,{className:`text-3xl font-bold`,children:t?.plugins.total||0}),B(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[z(G,{variant:`secondary`,className:`mr-1`,children:t?.plugins.active||0}),`个活跃`]})]})]}),B(U,{children:[B(bn,{className:`flex flex-row items-center justify-between pb-2`,children:[z(xn,{className:`text-sm font-medium text-muted-foreground`,children:`机器人`}),z(g,{className:`h-4 w-4 text-muted-foreground`})]}),B(W,{children:[z(`div`,{className:`text-3xl font-bold`,children:t?.bots.total||0}),B(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[z(G,{variant:`success`,className:`mr-1`,children:t?.bots.online||0}),`个在线`]})]})]}),B(U,{children:[B(bn,{className:`flex flex-row items-center justify-between pb-2`,children:[z(xn,{className:`text-sm font-medium text-muted-foreground`,children:`命令数量`}),z(u,{className:`h-4 w-4 text-muted-foreground`})]}),B(W,{children:[z(`div`,{className:`text-3xl font-bold`,children:t?.commands||0}),z(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`可用命令`})]})]}),B(U,{children:[B(bn,{className:`flex flex-row items-center justify-between pb-2`,children:[z(xn,{className:`text-sm font-medium text-muted-foreground`,children:`组件数量`}),z(Ge,{className:`h-4 w-4 text-muted-foreground`})]}),B(W,{children:[z(`div`,{className:`text-3xl font-bold`,children:t?.components||0}),z(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`已注册组件`})]})]})]}),B(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[B(U,{children:[B(bn,{children:[z(xn,{children:`系统信息`}),z(Sn,{children:`服务器运行状态`})]}),B(W,{className:`space-y-3`,children:[B(`div`,{className:`flex justify-between items-center`,children:[B(`div`,{className:`flex items-center gap-2 text-sm`,children:[z(D,{className:`h-4 w-4 text-muted-foreground`}),`运行时间`]}),z(G,{variant:`secondary`,children:r?b(r.uptime):`-`})]}),B(`div`,{className:`flex justify-between items-center`,children:[B(`div`,{className:`flex items-center gap-2 text-sm`,children:[z(ee,{className:`h-4 w-4 text-muted-foreground`}),`平台`]}),z(G,{variant:`secondary`,children:r?.platform||`-`})]}),B(`div`,{className:`flex justify-between items-center`,children:[B(`div`,{className:`flex items-center gap-2 text-sm`,children:[z(u,{className:`h-4 w-4 text-muted-foreground`}),`Node 版本`]}),z(G,{variant:`secondary`,children:r?.nodeVersion||`-`})]})]})]}),B(U,{children:[B(bn,{children:[z(xn,{children:`资源使用`}),z(Sn,{children:`内存使用情况`})]}),B(W,{className:`space-y-3`,children:[B(`div`,{className:`flex justify-between items-center`,children:[B(`div`,{className:`flex items-center gap-2 text-sm`,children:[z(be,{className:`h-4 w-4 text-muted-foreground`}),`堆内存使用`]}),z(G,{variant:`secondary`,children:t?`${t.memory.toFixed(2)} MB`:`-`})]}),B(`div`,{className:`flex justify-between items-center`,children:[B(`div`,{className:`flex items-center gap-2 text-sm`,children:[z(be,{className:`h-4 w-4 text-muted-foreground`}),`总堆内存`]}),z(G,{variant:`secondary`,children:r?x(r.memory.heapTotal):`-`})]}),B(`div`,{className:`flex justify-between items-center`,children:[B(`div`,{className:`flex items-center gap-2 text-sm`,children:[z(be,{className:`h-4 w-4 text-muted-foreground`}),`RSS`]}),z(G,{variant:`secondary`,children:r?x(r.memory.rss):`-`})]})]})]})]}),B(U,{children:[B(bn,{children:[z(xn,{children:`快速操作`}),z(Sn,{children:`常用功能快捷入口`})]}),z(W,{children:B(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[z(V,{variant:`outline`,className:`h-auto p-4 justify-start`,onClick:()=>e(`/plugins`),children:B(`div`,{className:`flex flex-col items-start gap-1`,children:[z(F,{className:`h-5 w-5 mb-1`}),z(`span`,{className:`font-medium`,children:`插件管理`}),z(`span`,{className:`text-xs text-muted-foreground`,children:`查看和管理插件`})]})}),z(V,{variant:`outline`,className:`h-auto p-4 justify-start`,onClick:()=>e(`/bots`),children:B(`div`,{className:`flex flex-col items-start gap-1`,children:[z(g,{className:`h-5 w-5 mb-1`}),z(`span`,{className:`font-medium`,children:`机器人状态`}),z(`span`,{className:`text-xs text-muted-foreground`,children:`监控机器人运行`})]})}),z(V,{variant:`outline`,className:`h-auto p-4 justify-start`,onClick:()=>e(`/logs`),children:B(`div`,{className:`flex flex-col items-start gap-1`,children:[z(ie,{className:`h-5 w-5 mb-1`}),z(`span`,{className:`font-medium`,children:`系统日志`}),z(`span`,{className:`text-xs text-muted-foreground`,children:`查看运行日志`})]})}),z(V,{variant:`outline`,className:`h-auto p-4 justify-start border-orange-200 hover:border-orange-400 hover:bg-orange-50 dark:border-orange-800 dark:hover:border-orange-600 dark:hover:bg-orange-950`,onClick:()=>m(!0),disabled:h,children:B(`div`,{className:`flex flex-col items-start gap-1`,children:[z(je,{className:`h-5 w-5 mb-1 text-orange-500 ${h?`animate-spin`:``}`}),z(`span`,{className:`font-medium`,children:h?`重启中...`:`重启服务`}),z(`span`,{className:`text-xs text-muted-foreground`,children:h?`请稍候,页面将自动刷新`:`重启机器人进程`})]})})]})})]}),z(Dn,{open:p,onOpenChange:m,children:B(jn,{children:[B(Mn,{children:[z(Pn,{children:`确认重启`}),z(Fn,{children:`确定要重启机器人进程吗?所有连接将临时断开,进行中的对话会被中断。进程将在几秒内自动恢复。`})]}),B(Nn,{children:[z(kn,{asChild:!0,children:z(V,{variant:`outline`,children:`取消`})}),z(V,{variant:`destructive`,onClick:()=>{m(!1),S()},children:`确认重启`})]})]})})]})}var Ln={Terminal:He,Box:_,Layers:ge,Clock:D,Brain:v,Wrench:$e,Database:te,Shield:Le,Settings:Ie,Plug:ke,Server:Fe};function Rn(e){return Ln[e]||F}function zn(){let e=Tt(),[t,n]=c([]),[r,i]=c(!0),[o,s]=c(null);a(()=>{l();let e=setInterval(l,1e4);return()=>clearInterval(e)},[]);let l=async()=>{try{let e=await hn(`/api/plugins`);if(!e.ok)throw Error(`API 请求失败`);let t=await e.json();if(t.success)n(t.data),s(null);else throw Error(`数据格式错误`)}catch(e){s(e.message)}finally{i(!1)}};return r?B(`div`,{className:`space-y-4`,children:[z(J,{className:`h-8 w-48`}),z(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:[...[,,,,,,]].map((e,t)=>z(J,{className:`h-40`},t))})]}):o?z(`div`,{className:`flex items-center justify-center h-full`,children:B(K,{variant:`destructive`,className:`max-w-md`,children:[z(d,{className:`h-4 w-4`}),B(q,{children:[`加载失败: `,o]})]})}):B(`div`,{className:`space-y-4`,children:[B(`div`,{children:[z(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`插件管理`}),B(`div`,{className:`flex items-center gap-2 mt-1`,children:[B(`span`,{className:`text-sm text-muted-foreground`,children:[`共 `,t.length,` 个插件`]}),z(G,{variant:`success`,children:t.filter(e=>e.status===`active`).length}),z(`span`,{className:`text-sm text-muted-foreground`,children:`个运行中`})]})]}),z(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:t.map((t,n)=>z(U,{className:`cursor-pointer transition-all hover:shadow-md hover:-translate-y-0.5`,onClick:()=>e(`/plugins/${encodeURIComponent(t.name)}`),children:B(W,{className:`p-4 space-y-3`,children:[B(`div`,{className:`flex justify-between items-center`,children:[B(`div`,{className:`flex items-center gap-2`,children:[z(`div`,{className:`flex items-center justify-center w-8 h-8 rounded-md bg-secondary`,children:z(F,{className:`w-4 h-4`})}),z(`span`,{className:`font-semibold text-sm`,children:t.name})]}),z(G,{variant:t.status===`active`?`success`:`secondary`,children:t.status===`active`?`运行中`:`已停止`})]}),z(`p`,{className:`text-xs text-muted-foreground line-clamp-2`,children:t.description||`暂无描述`}),z(ln,{}),t.features.length>0?z(`div`,{className:`grid gap-1`,style:{gridTemplateColumns:`repeat(${Math.min(t.features.length,4)}, 1fr)`},children:t.features.map(e=>B(`div`,{className:`flex flex-col items-center gap-0.5 rounded-md bg-secondary/50 p-1.5`,children:[z(Rn(e.icon),{className:`w-3 h-3 text-muted-foreground`}),z(`span`,{className:`text-sm font-bold`,children:e.count}),z(`span`,{className:`text-[10px] text-muted-foreground`,children:e.desc})]},e.name))}):z(`p`,{className:`text-xs text-muted-foreground text-center py-1`,children:`无注册功能`})]})},`${t.name}-${n}`))}),t.length===0&&z(U,{className:`mt-6`,children:B(W,{className:`flex flex-col items-center gap-3 py-12`,children:[z(`div`,{className:`flex items-center justify-center w-16 h-16 rounded-full bg-muted`,children:z(F,{className:`w-8 h-8 text-muted-foreground`})}),z(`h3`,{className:`text-lg font-semibold`,children:`暂无插件`}),z(`p`,{className:`text-sm text-muted-foreground`,children:`请先安装并启用插件`})]})})]})}var Bn=e.forwardRef(({className:e,...t},n)=>z(`textarea`,{className:L(`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`,e),ref:n,...t}));Bn.displayName=`Textarea`;var Vn=e.forwardRef(({className:e,...t},n)=>z(Pt.Root,{className:L(`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`,e),...t,ref:n,children:z(Pt.Thumb,{className:L(`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`)})}));Vn.displayName=`Switch`;var Hn=Mt.Root;Mt.Group;var Un=Mt.Value,Wn=e.forwardRef(({className:e,children:t,...n},r)=>B(Mt.Trigger,{ref:r,className:L(`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`,e),...n,children:[t,z(Mt.Icon,{asChild:!0,children:z(S,{className:`h-4 w-4 opacity-50`})})]}));Wn.displayName=`SelectTrigger`;var Gn=e.forwardRef(({className:e,...t},n)=>z(Mt.ScrollUpButton,{ref:n,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:z(T,{className:`h-4 w-4`})}));Gn.displayName=`SelectScrollUpButton`;var Kn=e.forwardRef(({className:e,...t},n)=>z(Mt.ScrollDownButton,{ref:n,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:z(S,{className:`h-4 w-4`})}));Kn.displayName=`SelectScrollDownButton`;var qn=e.forwardRef(({className:e,children:t,position:n,...r},i)=>{let a=n??`popper`;return z(Mt.Portal,{children:B(Mt.Content,{ref:i,className:L(`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`,a===`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`,e),position:a,...r,children:[z(Gn,{}),z(Mt.Viewport,{className:L(`p-1`,a===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),z(Kn,{})]})})});qn.displayName=`SelectContent`;var Jn=e.forwardRef(({className:e,children:t,value:n,...r},i)=>B(Mt.Item,{ref:i,value:n,className:L(`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`,e),...r,children:[z(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:z(Mt.ItemIndicator,{children:z(b,{className:`h-4 w-4`})})}),z(Mt.ItemText,{children:t})]}));Jn.displayName=`SelectItem`;var Yn=e.forwardRef(({className:e,...t},n)=>z(Mt.Separator,{ref:n,className:L(`-mx-1 my-1 h-px bg-muted`,e),...t}));Yn.displayName=`SelectSeparator`;function Xn({field:e,value:t,onChange:n}){return e.enum?B(Hn,{value:t?.toString()||``,onValueChange:n,children:[z(Wn,{children:z(Un,{placeholder:`请选择`})}),z(qn,{children:e.enum.map(e=>z(Jn,{value:e.toString(),children:e.toString()},e))})]}):e.description?.includes(`多行`)||e.key?.includes(`description`)?z(Bn,{value:t||``,onChange:e=>n(e.target.value),placeholder:e.description||`请输入`,rows:3}):z(H,{value:t||``,onChange:e=>n(e.target.value),placeholder:e.description||`请输入`})}function Zn({field:e,value:t,onChange:n}){return z(H,{type:`number`,value:t?.toString()||``,onChange:e=>n(parseFloat(e.target.value)||0),placeholder:e.description||`请输入数字`,min:e.min,max:e.max})}function Qn({value:e,onChange:t}){return B(`div`,{className:`flex items-center gap-3 p-3 rounded-lg bg-muted/50 border`,children:[z(Vn,{checked:e===!0,onCheckedChange:t}),B(`div`,{className:`flex flex-col gap-0.5`,children:[z(`span`,{className:`text-sm font-medium ${e?`text-emerald-600 dark:text-emerald-400`:`text-muted-foreground`}`,children:e?`已启用`:`已禁用`}),z(`span`,{className:`text-xs text-muted-foreground`,children:e?`功能当前处于开启状态`:`功能当前处于关闭状态`})]})]})}function $n({field:e,value:t,onChange:n}){let r=typeof t==`number`?t:e.default||0;return B(`div`,{className:`p-3 rounded-lg bg-muted/50 border space-y-3`,children:[B(`div`,{className:`flex items-center gap-3`,children:[z(`input`,{type:`range`,min:e.min||0,max:e.max||1,step:e.step||.01,value:r,onChange:e=>n(parseFloat(e.target.value)),className:`flex-1 h-2 rounded-lg appearance-none cursor-pointer bg-secondary`}),B(`div`,{className:`flex items-center gap-1`,children:[z(H,{type:`number`,className:`w-20 h-8 text-xs`,value:(r*100).toFixed(0),onChange:e=>n(parseFloat(e.target.value)/100),min:(e.min||0)*100,max:(e.max||1)*100}),z(`span`,{className:`text-xs font-bold text-muted-foreground`,children:`%`})]})]}),B(`div`,{className:`flex items-center justify-between`,children:[z(`span`,{className:`text-xs text-muted-foreground`,children:`当前值`}),B(G,{variant:`secondary`,className:`font-mono`,children:[(r*100).toFixed(1),`%`]})]})]})}function er({field:e,value:t,onChange:n}){let r=t instanceof Date?t.toISOString().split(`T`)[0]:t||``;return B(`div`,{className:`relative`,children:[z(y,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground pointer-events-none`}),z(H,{type:`date`,value:r,onChange:e=>n(new Date(e.target.value)),placeholder:e.description||`选择日期`,className:`pl-9`})]})}function tr({field:e,value:t,onChange:n}){let r=t instanceof RegExp?t.source:typeof t==`string`?t:``;return B(`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:[B(`div`,{className:`flex items-center gap-1`,children:[z(`span`,{className:`text-sm font-bold text-amber-600 dark:text-amber-400`,children:`/`}),z(H,{value:r,className:`font-mono text-sm`,onChange:e=>{try{n(new RegExp(e.target.value))}catch{n(e.target.value)}},placeholder:e.description||`请输入正则表达式`}),z(`span`,{className:`text-sm font-bold text-amber-600 dark:text-amber-400`,children:`/`})]}),B(`p`,{className:`flex items-center gap-1 text-xs text-amber-700 dark:text-amber-300`,children:[z(pe,{className:`w-3 h-3`}),` 输入正则表达式模式 (省略斜杠)`]})]})}function nr({field:e,value:t}){let n=e.default||t;return B(`div`,{className:`flex items-center gap-3 p-3 rounded-lg bg-muted border`,children:[z(ve,{className:`w-4 h-4 text-muted-foreground`}),z(G,{variant:`secondary`,className:`font-mono`,children:String(n)}),z(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:`(常量,不可修改)`})]})}function rr({field:e,value:t,onChange:n}){return B(`div`,{className:`p-3 rounded-lg bg-muted/50 border space-y-2`,children:[B(`p`,{className:`flex items-center gap-1 text-xs font-semibold text-muted-foreground`,children:[z(O,{className:`w-3 h-3`}),` JSON 格式输入`]}),z(Bn,{value:typeof t==`object`?JSON.stringify(t,null,2):String(t||``),onChange:e=>{try{n(JSON.parse(e.target.value))}catch{n(e.target.value)}},placeholder:e.description||`支持任意类型 (JSON 格式)`,rows:4,className:`font-mono text-sm`}),B(`p`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[z(pe,{className:`w-3 h-3`}),` 支持: 字符串、数字、布尔值、对象、数组`]})]})}function ir({fieldName:e,field:t,value:n,onChange:r,onArrayItemChange:i,renderNestedField:a}){let o=Array.isArray(n)?n:[],s=t.inner||t.items;return s&&[`string`,`number`].includes(s.type)?B(`div`,{className:`p-3 rounded-lg bg-muted/50 border space-y-2`,children:[B(`p`,{className:`flex items-center gap-1 text-xs font-semibold text-muted-foreground`,children:[z(_e,{className:`w-3 h-3`}),` 列表输入 (每行一个值)`]}),z(Bn,{value:o.join(`
|
|
2
|
+
`),onChange:e=>{let t=e.target.value.split(`
|
|
3
|
+
`).filter(Boolean);r(s.type===`number`?t.map(e=>parseFloat(e)||0):t)},placeholder:`每行一个值\n${t.description||``}`,rows:4,className:`font-mono text-sm`})]}):B(`div`,{className:`space-y-2`,children:[o.map((t,n)=>z(U,{className:`group`,children:B(`div`,{className:`p-3 space-y-2`,children:[B(`div`,{className:`flex justify-between items-center`,children:[z(G,{variant:`secondary`,className:`font-mono`,children:n+1}),z(V,{variant:`ghost`,size:`sm`,className:`opacity-0 group-hover:opacity-100 transition-opacity text-destructive`,onClick:()=>r(o.filter((e,t)=>t!==n)),children:z(We,{className:`w-3 h-3`})})]}),z(`div`,{className:`pl-2 border-l-2`,children:s&&a(`${e}[${n}]`,s,t,t=>{i?.(e,n,t)})})]})},n)),B(V,{variant:`outline`,size:`sm`,className:`w-full border-dashed`,onClick:()=>r([...o,s?.default||(s?.type===`object`?{}:``)]),children:[z(Ae,{className:`w-4 h-4 mr-1`}),` 添加项`]})]})}function ar({field:e,value:t,onChange:n}){return B(`div`,{className:`p-3 rounded-lg bg-muted/50 border space-y-2`,children:[B(`p`,{className:`flex items-center gap-1 text-xs font-semibold text-muted-foreground`,children:[z(_e,{className:`w-3 h-3`}),` 数组输入 (每行一个值)`]}),z(Bn,{value:Array.isArray(t)?t.join(`
|
|
4
|
+
`):``,onChange:e=>n(e.target.value.split(`
|
|
5
|
+
`).filter(Boolean)),placeholder:`每行一个值\n${e.description||``}`,rows:3,className:`font-mono text-sm`})]})}function or({fieldName:e,field:t,value:n,onArrayItemChange:r,renderNestedField:i}){let a=Array.isArray(n)?n:[];return z(`div`,{className:`space-y-2`,children:(t.list||[]).map((t,n)=>B(`div`,{className:`p-3 rounded-lg bg-muted/50 border space-y-2`,children:[B(G,{variant:`secondary`,className:`font-mono`,children:[`#`,n+1]}),t.description&&z(`p`,{className:`text-xs text-muted-foreground`,children:t.description}),z(`div`,{className:`mt-1`,children:i(`${e}[${n}]`,t,a[n],t=>{r?.(e,n,t)})})]},n))})}function sr({fieldName:e,field:t,renderField:n}){let r=t.dict||t.properties||{};return B(`div`,{className:`rounded-lg border-2 bg-muted/30 overflow-hidden`,children:[B(`div`,{className:`px-4 py-2 bg-muted border-b flex items-center gap-2`,children:[z(F,{className:`w-4 h-4 text-muted-foreground`}),z(`span`,{className:`text-xs font-semibold text-muted-foreground`,children:`对象`})]}),z(`div`,{className:`p-3 space-y-2`,children:Object.entries(r).map(([t,i],a)=>B(`div`,{children:[B(`div`,{className:`p-3 rounded-md bg-background border space-y-1`,children:[B(`div`,{className:`flex items-center gap-1`,children:[z(`span`,{className:`text-sm font-semibold`,children:i.key||t}),i.required&&z(`span`,{className:`text-destructive font-bold`,children:`*`})]}),i.description&&z(`p`,{className:`text-xs text-muted-foreground`,children:i.description}),z(`div`,{className:`mt-1`,children:n(t,i,e)})]}),a<Object.entries(r).length-1&&z(ln,{className:`my-2`})]},t))})]})}function cr({field:e,value:t,onChange:n}){return B(`div`,{className:`p-3 rounded-lg bg-muted/50 border space-y-2`,children:[B(`p`,{className:`flex items-center gap-1 text-xs font-semibold text-muted-foreground`,children:[z(O,{className:`w-3 h-3`}),` 键值对编辑`]}),z(Bn,{value:typeof t==`object`?JSON.stringify(t,null,2):t||`{}`,onChange:e=>{try{n(JSON.parse(e.target.value))}catch{}},placeholder:e.description||`请输入 JSON 格式`,rows:6,className:`font-mono text-sm`}),B(`p`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[z(pe,{className:`w-3 h-3`}),` 键值对格式: `,`{`,`"key": "value"`,`}`]})]})}function lr({field:e,value:t,onChange:n}){let r=e.list||[];if(r.length===0)return z(H,{value:t||``,onChange:e=>n(e.target.value),placeholder:e.description||`请输入值`});let i=r.map(e=>e.default||e.type);return B(`div`,{className:`p-3 rounded-lg bg-muted/50 border space-y-2`,children:[B(`p`,{className:`flex items-center gap-1 text-xs font-semibold text-muted-foreground`,children:[z(ce,{className:`w-3 h-3`}),` 联合类型`]}),B(Hn,{value:t?.toString()||``,onValueChange:n,children:[z(Wn,{children:z(Un,{placeholder:`请选择`})}),z(qn,{children:i.map((e,t)=>z(Jn,{value:String(e),children:String(e)},t))})]})]})}function ur({fieldName:e,field:t,value:n,onChange:r,renderNestedField:i}){let a=t.list||[];return B(`div`,{className:`rounded-lg border-2 bg-muted/30 overflow-hidden`,children:[B(`div`,{className:`px-4 py-2 bg-muted border-b flex items-center gap-2`,children:[z(ge,{className:`w-4 h-4 text-muted-foreground`}),z(`span`,{className:`text-xs font-semibold text-muted-foreground`,children:`交叉类型`})]}),z(`div`,{className:`p-3 space-y-2`,children:a.map((t,a)=>B(`div`,{className:`p-3 rounded-md bg-background border space-y-1`,children:[t.description&&z(`p`,{className:`text-xs text-muted-foreground`,children:t.description}),z(`div`,{className:`mt-1`,children:i(`${e}[${a}]`,t,n,r)})]},a))})]})}function dr(e){let{field:t}=e;switch(t.type){case`string`:return z(Xn,{...e});case`number`:case`integer`:return z(Zn,{...e});case`boolean`:return z(Qn,{...e});case`percent`:return z($n,{...e});case`date`:return z(er,{...e});case`regexp`:return z(tr,{...e});case`const`:return z(nr,{...e});case`any`:return z(rr,{...e});case`list`:return z(ir,{...e});case`array`:return z(ar,{...e});case`tuple`:return z(or,{...e});case`object`:return z(sr,{...e});case`dict`:return z(cr,{...e});case`union`:return z(lr,{...e});case`intersect`:return z(ur,{...e});default:return z(Bn,{value:typeof e.value==`object`?JSON.stringify(e.value,null,2):e.value||``,onChange:t=>{try{e.onChange(JSON.parse(t.target.value))}catch{e.onChange(t.target.value)}},placeholder:t.description||`请输入 JSON 格式`,rows:4,className:`font-mono text-xs`})}}function fr({field:e,value:t,onChange:n}){switch(e.type){case`string`:return z(H,{value:t||``,onChange:e=>n(e.target.value),placeholder:e.description||`请输入`,className:`h-8 text-sm`});case`number`:case`integer`:return z(H,{type:`number`,value:t?.toString()||``,onChange:e=>n(parseFloat(e.target.value)||0),placeholder:e.description||`请输入数字`,min:e.min,max:e.max,className:`h-8 text-sm`});case`boolean`:return B(`div`,{className:`flex items-center gap-2`,children:[z(Vn,{checked:t===!0,onCheckedChange:n}),z(`span`,{className:`text-sm ${t?`text-emerald-600 dark:text-emerald-400`:`text-muted-foreground`}`,children:t?`已启用`:`已禁用`})]});case`object`:{let r=e.dict||e.properties||{};return z(U,{className:`p-2 space-y-2`,children:Object.entries(r).map(([e,r])=>B(`div`,{className:`space-y-1`,children:[z(`span`,{className:`text-xs font-semibold`,children:e}),z(fr,{fieldName:e,field:r,value:t?.[e],onChange:r=>n({...t,[e]:r})})]},e))})}default:return z(Bn,{value:typeof t==`object`?JSON.stringify(t,null,2):t||``,onChange:e=>{try{n(JSON.parse(e.target.value))}catch{n(e.target.value)}},rows:3,className:`font-mono text-xs`})}}var pr=Ot.Root,mr=e.forwardRef(({className:e,value:t,...n},r)=>z(Ot.Item,{ref:r,value:t,className:L(`border-b`,e),...n}));mr.displayName=`AccordionItem`;var hr=e.forwardRef(({className:e,children:t,...n},r)=>z(Ot.Header,{className:`flex`,children:B(Ot.Trigger,{ref:r,className:L(`flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180`,e),...n,children:[t,z(S,{className:`h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200`})]})}));hr.displayName=`AccordionTrigger`;var gr=e.forwardRef(({className:e,children:t,...n},r)=>z(Ot.Content,{ref:r,className:`overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down`,...n,children:z(`div`,{className:L(`pb-4 pt-0`,e),children:t})}));gr.displayName=`AccordionContent`;function _r({pluginName:e,onSuccess:t}){let[n,r]=c({}),[i,o]=c(null),[s,l]=c(void 0),{config:u,schema:p,loading:m,error:h,connected:g,setConfig:_}=mt(e);a(()=>{u&&r(u)},[u]);let[v,y]=c(null),b=async()=>{if(g)try{let e=await _(n);e?.reloaded?o(`配置已保存,插件已重载`):e?.message?(y(e.message),o(null)):o(`配置已保存`),setTimeout(()=>{l(void 0),t?.(),o(null),y(null)},2500)}catch(e){console.error(`保存配置失败:`,e)}},S=(e,t)=>{r(n=>({...n,[e]:t}))},C=(e,t,n)=>{r(r=>({...r,[e]:{...r[e]||{},[t]:n}}))},w=(e,t,n)=>{r(r=>{let i=Array.isArray(r[e])?[...r[e]]:[];return i[t]=n,{...r,[e]:i}})},T=(e,t,r)=>z(dr,{fieldName:e,field:t,value:r?n[r]?.[e]??t.default:n[e]??t.default,onChange:r?t=>C(r,e,t):t=>S(e,t),parentPath:r,onNestedChange:C,onArrayItemChange:w,renderField:T,renderNestedField:(e,t,n,r)=>z(fr,{fieldName:e,field:t,value:n,onChange:r})}),E=p?.object||p?.properties||p?.dict||{};return!p||!E||Object.keys(E).length===0?null:z(U,{className:`mt-4`,children:z(pr,{type:`single`,collapsible:!0,value:s,onValueChange:l,children:B(mr,{value:`config`,className:`border-none`,children:[z(hr,{className:`px-4 hover:no-underline`,children:B(`div`,{className:`flex items-center gap-2`,children:[z(Ie,{className:`w-4 h-4`}),z(`span`,{className:`font-semibold`,children:`插件配置`}),B(G,{variant:`secondary`,children:[Object.keys(E).length,` 项`]})]})}),B(gr,{className:`px-4 pb-4`,children:[i&&B(K,{variant:`success`,className:`mb-3`,children:[z(x,{className:`h-4 w-4`}),z(q,{children:i})]}),v&&!i&&B(K,{className:`mb-3 border-yellow-500/50 text-yellow-700 dark:text-yellow-400`,children:[z(f,{className:`h-4 w-4`}),z(q,{children:v})]}),h&&B(K,{variant:`destructive`,className:`mb-3`,children:[z(d,{className:`h-4 w-4`}),z(q,{children:h})]}),z(`div`,{className:`space-y-3`,children:Object.entries(E).map(([e,t])=>{let n=t;return B(`div`,{className:`p-3 rounded-lg bg-muted/50 border space-y-2`,children:[B(`div`,{className:`flex items-center gap-1`,children:[z(`span`,{className:`text-sm font-semibold`,children:n.key||e}),n.required&&z(`span`,{className:`text-destructive font-bold`,children:`*`})]}),n.description&&z(`p`,{className:`text-xs text-muted-foreground`,children:n.description}),z(`div`,{className:`mt-1`,children:T(n.key||e,n)})]},e)})}),B(`div`,{className:`flex gap-2 justify-end mt-4 pt-3 border-t`,children:[B(V,{variant:`outline`,size:`sm`,onClick:()=>l(void 0),disabled:m,children:[z(et,{className:`w-4 h-4 mr-1`}),` 取消`]}),z(V,{size:`sm`,onClick:b,disabled:m,children:m?B(R,{children:[z(P,{className:`w-4 h-4 mr-1 animate-spin`}),`保存中...`]}):B(R,{children:[z(Me,{className:`w-4 h-4 mr-1`}),`保存配置`]})})]})]})]})})})}var vr={Terminal:He,Box:_,Layers:ge,Clock:D,Brain:v,Wrench:$e,Database:te,Shield:Le,Settings:Ie,Plug:ke,Server:Fe};function yr(e){return vr[e]||F}function br(){let{name:e}=Et(),t=Tt(),[n,r]=c(null),[i,o]=c(!0),[s,l]=c(null);a(()=>{e&&u(e)},[e]);let u=async e=>{try{let t=await hn(`/api/plugins/${encodeURIComponent(e)}`);if(!t.ok)throw Error(`API 请求失败`);let n=await t.json();if(n.success)r(n.data),l(null);else throw Error(`数据格式错误`)}catch(e){l(e.message)}finally{o(!1)}};return i?B(`div`,{className:`space-y-4`,children:[z(J,{className:`h-8 w-24`}),B(`div`,{className:`flex items-center gap-3`,children:[z(J,{className:`h-12 w-12 rounded-xl`}),B(`div`,{children:[z(J,{className:`h-6 w-48`}),z(J,{className:`h-4 w-64 mt-1`})]})]}),z(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 md:grid-cols-6 gap-2`,children:[...[,,,,,,]].map((e,t)=>z(J,{className:`h-20`},t))})]}):s||!n?B(`div`,{children:[B(V,{variant:`ghost`,onClick:()=>t(`/plugins`),className:`mb-4`,children:[z(p,{className:`w-4 h-4 mr-1`}),` 返回`]}),B(K,{variant:`destructive`,children:[z(d,{className:`h-4 w-4`}),B(q,{children:[`加载失败: `,s||`插件不存在`]})]})]}):B(`div`,{className:`space-y-4`,children:[B(V,{variant:`ghost`,size:`sm`,onClick:()=>t(`/plugins`),children:[z(p,{className:`w-4 h-4 mr-1`}),` 返回`]}),B(`div`,{className:`flex items-center gap-3`,children:[z(`div`,{className:`flex items-center justify-center w-12 h-12 rounded-xl bg-secondary`,children:z(F,{className:`w-6 h-6`})}),B(`div`,{children:[B(`div`,{className:`flex items-center gap-2`,children:[z(`h1`,{className:`text-xl font-bold`,children:n.name}),z(G,{variant:n.status===`active`?`success`:`secondary`,children:n.status===`active`?`运行中`:`已停止`})]}),z(`p`,{className:`text-sm text-muted-foreground`,children:n.description||`暂无描述`})]})]}),z(_r,{pluginName:n.name,onSuccess:()=>{}}),z(ln,{}),n.features.length>0&&B(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 md:grid-cols-6 gap-2`,children:[n.features.map(e=>z(U,{children:B(W,{className:`flex flex-col items-center gap-1 p-3`,children:[z(yr(e.icon),{className:`w-4 h-4 text-muted-foreground`}),z(`span`,{className:`text-2xl font-bold`,children:e.count}),z(`span`,{className:`text-xs text-muted-foreground`,children:e.desc})]})},e.name)),n.contexts.length>0&&z(U,{children:B(W,{className:`flex flex-col items-center gap-1 p-3`,children:[z(te,{className:`w-4 h-4 text-muted-foreground`}),z(`span`,{className:`text-2xl font-bold`,children:n.contexts.length}),z(`span`,{className:`text-xs text-muted-foreground`,children:`上下文`})]})})]}),B(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[n.features.map(e=>e.items.length===0?null:B(U,{children:[z(bn,{className:`pb-2`,children:B(`div`,{className:`flex items-center gap-2`,children:[z(yr(e.icon),{className:`w-4 h-4 text-muted-foreground`}),z(xn,{className:`text-base`,children:e.desc}),z(G,{variant:`secondary`,children:e.count})]})}),z(W,{children:z(`div`,{className:`max-h-60 overflow-y-auto pr-1 space-y-2`,children:e.items.map((t,n)=>z(xr,{featureName:e.name,item:t},n))})})]},e.name)),n.contexts.length>0&&B(U,{children:[z(bn,{className:`pb-2`,children:B(`div`,{className:`flex items-center gap-2`,children:[z(te,{className:`w-4 h-4 text-muted-foreground`}),z(xn,{className:`text-base`,children:`上下文`}),z(G,{variant:`secondary`,children:n.contexts.length})]})}),z(W,{children:z(`div`,{className:`max-h-60 overflow-y-auto pr-1 space-y-2`,children:n.contexts.map((e,t)=>z(`div`,{className:`rounded-md bg-muted/50 p-2`,children:z(`code`,{className:`text-sm`,children:e.name})},t))})})]})]})]})}function xr({featureName:e,item:t}){switch(e){case`command`:return B(`div`,{className:`rounded-md bg-muted/50 p-3 space-y-1`,children:[z(`code`,{className:`text-sm font-semibold`,children:t.name}),t.desc?.map((e,t)=>z(`p`,{className:`text-xs text-muted-foreground`,children:e},t)),t.usage&&t.usage.length>0&&B(`div`,{children:[z(`span`,{className:`text-xs font-semibold text-blue-600 dark:text-blue-400`,children:`用法:`}),t.usage.map((e,t)=>z(`code`,{className:`block text-xs bg-muted rounded px-1 py-0.5 mt-0.5`,children:e},t))]}),t.examples&&t.examples.length>0&&B(`div`,{children:[z(`span`,{className:`text-xs font-semibold text-emerald-600 dark:text-emerald-400`,children:`示例:`}),t.examples.map((e,t)=>z(`code`,{className:`block text-xs bg-muted rounded px-1 py-0.5 mt-0.5`,children:e},t))]})]});case`cron`:return B(`div`,{className:`flex justify-between items-center rounded-md bg-muted/50 p-2`,children:[z(`code`,{className:`text-sm`,children:t.expression}),z(G,{variant:t.running?`success`:`secondary`,children:t.running?`运行中`:`已停止`})]});case`tool`:return B(`div`,{className:`rounded-md bg-muted/50 p-3 space-y-1`,children:[z(`code`,{className:`text-sm font-semibold`,children:t.name}),t.desc&&z(`p`,{className:`text-xs text-muted-foreground`,children:t.desc}),t.platforms&&t.platforms.length>0&&z(`div`,{className:`flex gap-1 flex-wrap`,children:t.platforms.map((e,t)=>z(G,{variant:`outline`,className:`text-[10px]`,children:e},t))})]});case`skill`:return B(`div`,{className:`rounded-md bg-muted/50 p-3 space-y-1`,children:[z(`code`,{className:`text-sm font-semibold`,children:t.name}),t.desc&&z(`p`,{className:`text-xs text-muted-foreground`,children:t.desc}),t.toolCount!=null&&B(`span`,{className:`text-xs text-muted-foreground`,children:[`工具: `,t.toolCount]})]});case`config`:return B(`div`,{className:`flex justify-between items-center rounded-md bg-muted/50 p-2`,children:[z(`code`,{className:`text-sm`,children:t.name}),t.defaultValue!==void 0&&B(`span`,{className:`text-xs text-muted-foreground`,children:[`默认: `,JSON.stringify(t.defaultValue)]})]});case`permission`:return z(`div`,{className:`rounded-md bg-muted/50 p-2`,children:z(`code`,{className:`text-sm`,children:t.name})});case`database`:return z(`div`,{className:`rounded-md bg-muted/50 p-2`,children:z(`code`,{className:`text-sm`,children:t.name})});case`adapter`:return B(`div`,{className:`rounded-md bg-muted/50 p-3 space-y-1`,children:[B(`div`,{className:`flex items-center gap-2`,children:[z(ke,{className:`w-3.5 h-3.5 text-muted-foreground`}),z(`code`,{className:`text-sm font-semibold`,children:t.name})]}),B(`div`,{className:`flex gap-3 text-xs text-muted-foreground`,children:[B(`span`,{children:[`Bot: `,t.bots??0]}),B(`span`,{children:[`在线: `,t.online??0]}),t.tools>0&&B(`span`,{children:[`工具: `,t.tools]})]})]});case`service`:return B(`div`,{className:`rounded-md bg-muted/50 p-2 flex items-center gap-2`,children:[z(Fe,{className:`w-3.5 h-3.5 text-muted-foreground`}),z(`code`,{className:`text-sm`,children:t.name}),t.desc&&t.desc!==t.name&&B(`span`,{className:`text-xs text-muted-foreground`,children:[`- `,t.desc]})]});default:return z(`div`,{className:`rounded-md bg-muted/50 p-2`,children:z(`code`,{className:`text-sm`,children:t.name||JSON.stringify(t)})})}}function Sr(){let[e,t]=c([]),[n,r]=c(!0),[o,s]=c(null),l=bt(ut),{sendRequest:f}=xt(),p=i(async()=>{if(!l){r(!1),s(`WebSocket 未连接,请刷新页面`);return}try{t((await f({type:`bot:list`})).bots||[]),s(null)}catch(e){s(e.message)}finally{r(!1)}},[l,f]);return a(()=>{l&&(r(!0),p())},[l,p]),a(()=>{if(!l)return;let e=setInterval(p,8e3);return()=>clearInterval(e)},[l,p]),n&&l?B(`div`,{className:`space-y-6`,children:[z(J,{className:`h-8 w-48`}),z(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4`,children:[...[,,,]].map((e,t)=>z(J,{className:`h-48`},t))})]}):o?z(`div`,{className:`flex items-center justify-center h-full`,children:B(K,{variant:`destructive`,className:`max-w-md`,children:[z(d,{className:`h-4 w-4`}),B(q,{children:[`加载失败: `,o]})]})}):B(`div`,{className:`space-y-6`,children:[B(`div`,{className:`flex items-start justify-between gap-4`,children:[B(`div`,{children:[z(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`机器人管理`}),B(`div`,{className:`flex items-center gap-2 mt-1`,children:[B(`span`,{className:`text-sm text-muted-foreground`,children:[`共 `,e.length,` 个机器人,`]}),z(G,{variant:`success`,children:e.filter(e=>e.connected).length}),z(`span`,{className:`text-sm text-muted-foreground`,children:`个在线`})]}),B(`p`,{className:`text-sm text-muted-foreground mt-2`,children:[`ICQQ 扫码/验证码登录请前往侧栏`,` `,z(St,{to:`/icqq`,className:`text-primary underline-offset-4 hover:underline font-medium`,children:`ICQQ 管理`}),`。`]})]}),B(V,{variant:`outline`,size:`sm`,onClick:()=>{r(!0),p()},disabled:!l||n,children:[z(I,{className:n?`h-4 w-4 animate-spin`:`h-4 w-4`}),`刷新`]})]}),z(ln,{}),z(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4`,children:e.map((e,t)=>z(St,{to:`/bots/${encodeURIComponent(e.adapter)}/${encodeURIComponent(e.name)}`,className:`block transition-opacity hover:opacity-90 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-xl`,children:z(U,{className:`h-full cursor-pointer hover:border-primary/40`,children:B(W,{className:`p-5 space-y-4`,children:[B(`div`,{className:`flex justify-between items-center`,children:[B(`div`,{className:`flex items-center gap-2`,children:[z(`div`,{className:`p-2 rounded-md ${e.connected?`bg-emerald-100 dark:bg-emerald-900/30`:`bg-muted`}`,children:z(g,{className:`w-5 h-5 ${e.connected?`text-emerald-600 dark:text-emerald-400`:`text-muted-foreground`}`})}),z(`span`,{className:`text-lg font-bold`,children:e.name})]}),B(`div`,{className:`flex items-center gap-1`,children:[z(G,{variant:e.connected?`success`:`secondary`,children:e.connected?B(R,{children:[z(Ze,{className:`w-3 h-3 mr-1`}),`在线`]}):B(R,{children:[z(Qe,{className:`w-3 h-3 mr-1`}),`离线`]})}),z(w,{className:`w-4 h-4 text-muted-foreground`})]})]}),B(`div`,{className:`flex items-center gap-2`,children:[z(`span`,{className:`text-sm text-muted-foreground`,children:`适配器:`}),z(G,{variant:`outline`,children:e.adapter})]}),z(ln,{}),B(`div`,{className:`space-y-2`,children:[B(`div`,{className:`flex justify-between items-center p-2 rounded-md bg-muted/50`,children:[B(`div`,{className:`flex items-center gap-2 text-sm`,children:[z(u,{className:`w-4 h-4 ${e.status===`online`?`text-emerald-500`:`text-muted-foreground`}`}),z(`span`,{className:`text-muted-foreground`,children:`运行状态`})]}),z(G,{variant:e.status===`online`?`success`:`secondary`,children:e.status===`online`?`运行中`:`已停止`})]}),B(`div`,{className:`flex justify-between items-center p-2 rounded-md bg-muted/50`,children:[B(`div`,{className:`flex items-center gap-2 text-sm`,children:[z(F,{className:`w-4 h-4 text-muted-foreground`}),z(`span`,{className:`text-muted-foreground`,children:`适配器类型`})]}),z(`span`,{className:`text-sm font-medium`,children:e.adapter})]}),B(`div`,{className:`flex justify-between items-center p-2 rounded-md bg-muted/50`,children:[B(`div`,{className:`flex items-center gap-2 text-sm`,children:[z(nt,{className:`w-4 h-4 text-muted-foreground`}),z(`span`,{className:`text-muted-foreground`,children:`连接状态`})]}),z(`span`,{className:`text-sm font-medium ${e.connected?`text-emerald-600 dark:text-emerald-400`:`text-muted-foreground`}`,children:e.connected?`已连接`:`未连接`})]})]}),B(`div`,{className:`flex flex-wrap items-center justify-center gap-1.5 pt-1`,children:[(e.pendingRequestCount??0)+(e.pendingNoticeCount??0)>0&&B(`span`,{className:`text-xs text-amber-600 dark:text-amber-400 font-medium`,children:[(e.pendingRequestCount??0)+(e.pendingNoticeCount??0),` 条待处理`]}),z(`p`,{className:`text-xs text-primary`,children:`点击进入管理`})]})]})})},`${e.adapter}-${e.name}-${t}`))}),e.length===0&&z(U,{children:B(W,{className:`flex flex-col items-center gap-4 py-12`,children:[z(g,{className:`w-16 h-16 text-muted-foreground/30`}),B(`div`,{className:`text-center`,children:[z(`h3`,{className:`text-lg font-semibold`,children:`暂无机器人`}),z(`p`,{className:`text-sm text-muted-foreground`,children:`请先配置并启动机器人`})]})]})})]})}var Cr=Ft.Root,wr=e.forwardRef(({className:e,...t},n)=>z(Ft.List,{ref:n,className:L(`inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground`,e),...t}));wr.displayName=`TabsList`;var Tr=e.forwardRef(({className:e,value:t,...n},r)=>z(Ft.Trigger,{ref:r,value:t,className:L(`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`,e),...n}));Tr.displayName=`TabsTrigger`;var Er=e.forwardRef(({className:e,value:t,...n},r)=>z(Ft.Content,{ref:r,value:t,className:L(`mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,e),...n}));Er.displayName=`TabsContent`;function Dr({content:e}){return z(R,{children:e.map((e,t)=>{let n=e.data??{};if(e.type===`text`&&n.text!=null)return z(`span`,{children:String(n.text)},t);if(e.type===`at`)return B(`span`,{className:`im-at font-medium`,children:[`@`,String(n.name??n.qq??``)]},t);if(e.type===`face`)return z(`img`,{src:`https://face.viki.moe/apng/${n.id}.png`,alt:``,className:`w-6 h-6 inline-block align-middle mx-0.5`},t);if(e.type===`image`){let e=lt(ct(n),`image`);return e?z(`div`,{className:`my-1.5 block w-full max-w-full`,children:z(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`inline-block max-w-full`,children:z(`img`,{src:e,alt:``,className:L(`max-w-[min(280px,88vw)] max-h-64 rounded-lg border border-border/50 object-contain bg-muted/20`),onError:e=>{e.target.style.display=`none`}})})},t):z(`span`,{className:`text-muted-foreground text-xs`,children:`[图片]`},t)}if(e.type===`video`){let e=lt(ct(n),`video`);return e?z(`div`,{className:`my-1.5 w-full max-w-full`,children:z(`video`,{src:e,controls:!0,playsInline:!0,preload:`metadata`,className:`max-w-[min(320px,92vw)] max-h-72 rounded-lg border border-border/50 bg-black/10`})},t):z(`span`,{className:`text-muted-foreground text-xs`,children:`[视频]`},t)}if(e.type===`audio`||e.type===`record`){let e=lt(ct(n),`audio`);return e?z(`div`,{className:`my-1.5 w-full max-w-[min(320px,100%)]`,children:z(`audio`,{src:e,controls:!0,preload:`metadata`,className:`w-full h-9`})},t):z(`span`,{className:`text-muted-foreground text-xs`,children:`[语音]`},t)}return e.type===`file`?B(`span`,{className:`text-muted-foreground text-xs`,children:[`📎 `,String(n.name??`文件`)]},t):B(`span`,{className:`text-muted-foreground text-xs`,children:[`[`,e.type,`]`]},t)})})}function Or(e){let t=[],n=/\[@([^\]]+)\]|\[face:(\d+)\]|\[image:([^\]]+)\]|\[video:([^\]]+)\]|\[audio:([^\]]+)\]/g,r=0,i;for(;(i=n.exec(e))!==null;){if(i.index>r){let n=e.substring(r,i.index);n&&t.push({type:`text`,data:{text:n}})}i[1]?t.push({type:`at`,data:{qq:i[1],name:i[1]}}):i[2]?t.push({type:`face`,data:{id:parseInt(i[2],10)}}):i[3]?t.push({type:`image`,data:{url:i[3]}}):i[4]?t.push({type:`video`,data:{url:i[4]}}):i[5]&&t.push({type:`audio`,data:{url:i[5]}}),r=n.lastIndex}if(r<e.length){let n=e.substring(r);n&&t.push({type:`text`,data:{text:n}})}return t.length>0?t:[{type:`text`,data:{text:e}}]}function kr(e){return e.length?e.some(e=>e.type===`text`?!!String(e.data?.text??``).trim():!0):!1}function Ar(e){if(Array.isArray(e))return e;if(typeof e==`string`){if(!e.trim())return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return[{type:`text`,data:{text:e}}]}return[]}function jr(){let{adapter:e,botId:t}=Et(),n=e?decodeURIComponent(e):``,r=t?decodeURIComponent(t):``,s=!!(n&&r),{sendRequest:l,connected:u}=xt(),[d,f]=c(null),[p,m]=c(null),[h,g]=c(``),[_,v]=c(!1),[y,b]=c([]),[x,S]=c([]),[C,w]=c([]),[T,E]=c(!1),[D,O]=c(null),[k,ee]=c(new Map),[te,ne]=c(new Map),[A,j]=c(null),[M,N]=c(!1),[re,ie]=c(``),[ae,oe]=c([]),[se,ce]=c(!1),[le,de]=c([]),[fe,pe]=c([]),[me,he]=c([]),[ge,_e]=c(!1),[P,ve]=c(!0),[ye,be]=c(!1),[xe,Ce]=c([]),[we,Te]=c(!1),[F,Ee]=c(0),[De,Oe]=c(!1),[ke,Ae]=c([]),[I,je]=c(!1),[Me,Ne]=c(0),[Pe,Fe]=c(!1),[Ie,Le]=c(`pending`),[Re,ze]=c(`unread`),Be=i(async()=>{if(!(!n||!r||!u))try{f(await l({type:`bot:info`,data:{adapter:n,botId:r}})),m(null)}catch(e){m(e.message)}},[n,r,u,l]);a(()=>{Be();let e=setInterval(Be,8e3);return()=>clearInterval(e)},[Be]);let Ve=i(async()=>{if(!(!n||!r||!u)){E(!0),O(null);try{if(n===`icqq`){let e=await l({type:`bot:friends`,data:{adapter:n,botId:r}}).catch(()=>({friends:[]})),t=await l({type:`bot:groups`,data:{adapter:n,botId:r}}).catch(()=>({groups:[]}));b(e.friends||[]),S(t.groups||[]),w([])}else{b([]),S([]);let e=(await l({type:`bot:channels`,data:{adapter:n,botId:r}}).catch(()=>({}))).channels??[];w(e),e.length||O(`当前适配器暂不支持好友/群/频道列表`)}}catch(e){O(e.message)}finally{E(!1)}}},[n,r,u,l]);a(()=>{u&&Ve()},[u,Ve]);let He=i(async()=>{if(!(!n||!r||!u))try{let{requests:e}=await l({type:`bot:requests`,data:{adapter:n,botId:r}});ee(t=>{let n=new Map(t);for(let t of e||[])n.set(t.id,{...t,canAct:!1});return n})}catch{}},[n,r,u,l]),Ue=i(async e=>{if(!n||!r||A?.type!==`channel`)return;_e(!0);let t=e!=null;try{let i=await l({type:`bot:inboxMessages`,data:{adapter:n,botId:r,channelId:A.id,channelType:A.channelType,limit:50,...e!=null&&{beforeTs:e}}});if(be(!!i.inboxEnabled),!i.inboxEnabled||!i.messages?.length){t||he([]),ve(!1);return}he(t?e=>[...e,...i.messages]:i.messages),ve(i.messages.length>=50)}catch{t||he([]),be(!1),ve(!1)}finally{_e(!1)}},[n,r,A,l]),We=i(async e=>{if(!(!n||!r)){Te(!0);try{let t=e?F:0,i=await l({type:`bot:inboxRequests`,data:{adapter:n,botId:r,limit:30,offset:t}});if(Oe(!!i.inboxEnabled),!i.inboxEnabled||!i.requests?.length){e||Ce([]);return}Ce(e?e=>[...e,...i.requests]:i.requests),Ee(t+(i.requests?.length??0))}catch{e||Ce([]),Oe(!1)}finally{Te(!1)}}},[n,r,F,l]),Ge=i(async e=>{if(!(!n||!r)){je(!0);try{let t=e?Me:0,i=await l({type:`bot:inboxNotices`,data:{adapter:n,botId:r,limit:30,offset:t}});if(Fe(!!i.inboxEnabled),!i.inboxEnabled||!i.notices?.length){e||Ae([]);return}Ae(e?e=>[...e,...i.notices]:i.notices),Ne(t+i.notices.length)}catch{e||Ae([]),Fe(!1)}finally{je(!1)}}},[n,r,Me,l]);a(()=>{He()},[He]),a(()=>{A?.type===`channel`&&(he([]),ve(!0),Ue())},[A?.id,A?.channelType,A?.type,Ue]),a(()=>{let e=e=>{let t=e.detail,i=t.data;if(t.type===`bot:request`)i.adapter===n&&i.botId===r&&ee(e=>{let t=new Map(e);return t.set(i.id,{id:i.id,platformRequestId:String(i.platformRequestId),type:String(i.type),sender:i.sender,comment:String(i.comment??``),channel:i.channel,timestamp:Number(i.timestamp),canAct:i.canAct===!0}),t});else if(t.type===`bot:notice`)i.adapter===n&&i.botId===r&&ne(e=>{let t=new Map(e);return t.set(i.id,{id:i.id,noticeType:String(i.noticeType),channel:i.channel,payload:String(i.payload??`{}`),timestamp:Number(i.timestamp)}),t});else if(t.type===`bot:message`&&i.adapter===n&&i.botId===r){let e=Ar(i.content);de(t=>[...t,{id:`msg-${Date.now()}-${Math.random().toString(36).slice(2)}`,channelId:String(i.channelId??``),channelType:String(i.channelType??`private`),sender:i.sender??{id:``,name:``},content:e,timestamp:Number(i.timestamp??Date.now())}])}};return window.addEventListener(`zhin-console-bot-push`,e),()=>window.removeEventListener(`zhin-console-bot-push`,e)},[n,r]);let qe=o(()=>[...k.values()].sort((e,t)=>t.timestamp-e.timestamp),[k]),Je=o(()=>[...te.values()].sort((e,t)=>t.timestamp-e.timestamp),[te]),Xe=o(()=>{let e=[];return y.forEach(t=>{e.push({id:String(t.user_id),name:t.nickname||t.remark||t.user_id.toString(),channelType:`private`})}),x.forEach(t=>{e.push({id:String(t.group_id),name:t.name||String(t.group_id),channelType:`group`})}),C.forEach(t=>{e.push({id:t.id,name:t.name||t.id,channelType:`channel`})}),e},[y,x,C]),Ze=o(()=>{let e=re.trim().toLowerCase();return e?Xe.filter(t=>t.name.toLowerCase().includes(e)||t.id.toLowerCase().includes(e)):Xe},[Xe,re]),Qe=o(()=>{if(A?.type!==`channel`)return[];let e=me.filter(e=>A.id&&A.channelType).map(e=>{let t=Ar(e.content);return{id:`inbox-${e.id}`,channelId:A.id,channelType:A.channelType,sender:{id:e.sender_id,name:e.sender_name??void 0},content:t,timestamp:e.created_at,outgoing:!1}}),t=le.filter(e=>e.channelId===A.id&&e.channelType===A.channelType).map(e=>({...e,outgoing:!1})),n=fe.filter(e=>e.channelId===A.id&&e.channelType===A.channelType).map(e=>({id:e.id,channelId:e.channelId,channelType:e.channelType,sender:{id:`self`,name:`我`},content:e.segments,timestamp:e.timestamp,outgoing:!0}));return[...e,...t,...n].sort((e,t)=>e.timestamp-t.timestamp)},[A,le,me,fe]),$e=async()=>{if(!(A?.type!==`channel`||A.channelType!==`private`)&&confirm(`确定删除好友 ${A.name}?`))try{await l({type:`bot:deleteFriend`,data:{adapter:n,botId:r,userId:A.id}}),b(e=>e.filter(e=>String(e.user_id)!==A.id)),j(null),Ve()}catch(e){alert(e.message)}},et=async()=>{let e=A?.type===`channel`?A.id:``,t=A?.type===`channel`?A.channelType:`private`,i=Or(h);if(!(!e||!kr(i))){v(!0);try{await l({type:`bot:sendMessage`,data:{adapter:n,botId:r,id:e,type:t,content:i}}),pe(n=>[...n,{id:`local-${Date.now()}-${Math.random().toString(36).slice(2)}`,channelId:e,channelType:t,segments:i,timestamp:Date.now()}]),g(``)}catch(e){alert(e.message)}finally{v(!1)}}},tt=async(e,t)=>{try{await l({type:t?`bot:requestApprove`:`bot:requestReject`,data:{adapter:n,botId:r,requestId:e}});let i=qe.find(t=>t.platformRequestId===e);i&&ee(e=>{let t=new Map(e);return t.delete(i.id),t})}catch(e){alert(e.message)}},nt=async e=>{try{await l({type:`bot:requestConsumed`,data:{id:e}}),ee(t=>{let n=new Map(t);return n.delete(e),n})}catch(e){alert(e.message)}},rt=async e=>{try{await l({type:`bot:noticeConsumed`,data:{id:e}}),ne(t=>{let n=new Map(t);return n.delete(e),n})}catch(e){alert(e.message)}},it=async()=>{if(!(A?.type!==`channel`||A.channelType!==`group`||n!==`icqq`)){ce(!0);try{oe((await l({type:`bot:groupMembers`,data:{adapter:n,botId:r,groupId:A.id}})).members||[])}catch(e){alert(e.message),oe([])}finally{ce(!1)}}};return{valid:s,adapter:n,botId:r,connected:u,info:d,loadErr:p,msgContent:h,setMsgContent:g,sending:_,listLoading:T,listErr:D,selection:A,setSelection:j,showChannelList:M,setShowChannelList:N,listSearch:re,setListSearch:ie,members:ae,membersLoading:se,channelMessages:Qe,inboxMessagesLoading:ge,inboxMessagesHasMore:P,inboxMessagesEnabled:ye,loadInboxMessages:Ue,inboxMessages:me,requestList:qe,noticeList:Je,requestsTab:Ie,setRequestsTab:Le,noticesTab:Re,setNoticesTab:ze,inboxRequests:xe,inboxRequestsLoading:we,inboxRequestsEnabled:De,loadInboxRequests:We,inboxNotices:ke,inboxNoticesLoading:I,inboxNoticesEnabled:Pe,loadInboxNotices:Ge,channels:Xe,filteredChannels:Ze,deleteFriend:$e,handleSend:et,approve:tt,dismissRequest:nt,dismissNotice:rt,loadMembers:it,groupAction:async(e,t,i)=>{if(!(A?.type!==`channel`||A.channelType!==`group`))try{await l({type:e,data:{adapter:n,botId:r,groupId:A.id,userId:String(t),...i}}),await it()}catch(e){alert(e.message)}},loadLists:Ve,loadRequestsFromServer:He,getChannelIcon:e=>{switch(e){case`private`:return z(Ke,{size:16});case`group`:return z(Ye,{size:16});case`channel`:return z(ue,{size:16});default:return z(Se,{size:16})}},showRightPanel:A?.type===`channel`&&A.channelType===`group`&&n===`icqq`}}function Mr(e){let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function Nr(e){return new Date(e).toLocaleDateString(`zh-CN`,{year:`numeric`,month:`long`,day:`numeric`})}function Pr(){let e=jr();if(!e.valid)return z(`div`,{className:`p-4`,children:z(K,{children:z(q,{children:`参数无效`})})});let{adapter:n,botId:r,connected:i,info:a,loadErr:o,msgContent:l,setMsgContent:u,sending:d,listLoading:f,listErr:m,selection:_,setSelection:v,showChannelList:y,setShowChannelList:x,listSearch:S,setListSearch:C,members:w,membersLoading:T,channelMessages:E,inboxMessagesLoading:D,inboxMessagesHasMore:O,inboxMessagesEnabled:k,loadInboxMessages:ee,inboxMessages:te,requestList:ne,noticeList:A,requestsTab:j,setRequestsTab:M,noticesTab:N,setNoticesTab:re,inboxRequests:ie,inboxRequestsLoading:ae,inboxRequestsEnabled:oe,loadInboxRequests:se,inboxNotices:ce,inboxNoticesLoading:le,inboxNoticesEnabled:ue,loadInboxNotices:de,filteredChannels:pe,deleteFriend:me,handleSend:he,approve:ge,dismissRequest:_e,dismissNotice:ve,loadMembers:ye,groupAction:be,loadLists:xe,loadRequestsFromServer:Ce,getChannelIcon:F,showRightPanel:Ee}=e,[De,Oe]=c(null),[ke,Ae]=c(``),I=s(null),je=e=>{u(t=>t?t+(!/\s$/.test(t)&&!/^[\s[,]/.test(e)?` `:``)+e:e)},Me=()=>{let e=ke.trim();!e||!De||(je(De===`image`?`[image:${e}]`:De===`video`?`[video:${e}]`:`[audio:${e}]`),Ae(``),Oe(null))},Ne=e=>{let t=e.target.files?.[0];if(e.target.value=``,!t?.type.startsWith(`image/`))return;let n=new FileReader;n.onload=()=>{let e=String(n.result||``);e&&je(`[image:${e}]`)},n.readAsDataURL(t)},Fe=i&&!d&&kr(Or(l)),Ie=``;return B(`div`,{className:`sandbox-container im-layout`,children:[B(`button`,{type:`button`,className:`mobile-channel-toggle md:hidden`,onClick:()=>x(!y),children:[z(Se,{size:20}),` 会话列表`]}),B(`div`,{className:L(`channel-sidebar`,y&&`show`),children:[z(`div`,{className:`p-3 border-b border-border/60`,children:B(`div`,{className:`flex items-center gap-2`,children:[z(V,{variant:`ghost`,size:`icon`,className:`h-8 w-8 shrink-0`,asChild:!0,children:z(St,{to:`/bots`,children:z(p,{className:`h-4 w-4`})})}),B(`div`,{className:`min-w-0 flex-1`,children:[B(`div`,{className:`flex items-center gap-2`,children:[z(g,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),z(`span`,{className:`font-semibold truncate text-sm`,children:a?.name||r})]}),B(`div`,{className:`flex items-center gap-1.5 mt-0.5 flex-wrap`,children:[z(G,{variant:`outline`,className:`text-[10px] px-1 font-normal`,children:n}),B(`span`,{className:L(`inline-flex items-center gap-0.5 text-[10px] px-1.5 py-0 rounded-full border`,i?`bg-emerald-100 text-emerald-800 border-emerald-200 dark:bg-emerald-900/30 dark:text-emerald-400`:`bg-muted text-muted-foreground`),children:[z(i?Ze:Qe,{size:10}),i?`已连接`:`未连接`]})]})]})]})}),o&&z(`div`,{className:`px-3 py-2`,children:z(`p`,{className:`text-xs text-destructive`,children:o})}),z(`div`,{className:`px-2 pt-2 pb-1`,children:z(H,{value:S,onChange:e=>C(e.target.value),placeholder:`搜索会话…`,className:`h-9 text-sm bg-background/80`})}),B(`div`,{className:`flex-1 overflow-y-auto p-2 space-y-0.5 min-h-0`,children:[f&&z(`div`,{className:`flex items-center justify-center py-6`,children:z(P,{className:`h-5 w-5 animate-spin text-muted-foreground`})}),!f&&m&&z(`p`,{className:`text-xs text-muted-foreground px-2 py-1`,children:m}),pe.length===0&&!f&&!m&&z(`p`,{className:`text-xs text-muted-foreground px-2 py-4 text-center`,children:S.trim()?`无匹配「${S.trim()}」`:`暂无会话`}),pe.map(e=>B(`div`,{role:`button`,tabIndex:0,className:L(`menu-item im-row-compact`,_?.type===`channel`&&_.id===e.id&&`active`),onClick:()=>{v({type:`channel`,id:e.id,name:e.name,channelType:e.channelType}),typeof window<`u`&&window.innerWidth<768&&x(!1)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),v({type:`channel`,id:e.id,name:e.name,channelType:e.channelType}),typeof window<`u`&&window.innerWidth<768&&x(!1))},children:[z(`span`,{className:`shrink-0 opacity-90`,children:F(e.channelType)}),B(`div`,{className:`flex-1 min-w-0 text-left`,children:[z(`div`,{className:`text-sm font-medium truncate leading-tight`,children:e.name}),z(`div`,{className:`text-[11px] text-muted-foreground truncate mt-0.5`,children:e.channelType===`private`?`私聊`:e.channelType===`group`?`群聊`:`频道`})]})]},`${e.channelType}-${e.id}`)),B(`div`,{className:`pt-2 mt-2 border-t border-border/50 space-y-0.5`,children:[B(`div`,{role:`button`,tabIndex:0,className:L(`menu-item im-row-compact`,_?.type===`requests`&&`active`),onClick:()=>{v({type:`requests`}),typeof window<`u`&&window.innerWidth<768&&x(!1)},children:[z(Je,{size:16,className:`shrink-0`}),B(`div`,{className:`flex-1 min-w-0 text-left`,children:[z(`div`,{className:`text-sm font-medium`,children:`请求`}),z(`div`,{className:`text-[11px] text-muted-foreground`,children:`好友/群邀请`})]}),ne.length>0&&z(`span`,{className:`inline-flex items-center justify-center h-5 min-w-5 rounded-full bg-destructive text-destructive-foreground text-[10px] font-medium px-1`,children:ne.length})]}),B(`div`,{role:`button`,tabIndex:0,className:L(`menu-item im-row-compact`,_?.type===`notices`&&`active`),onClick:()=>{v({type:`notices`}),typeof window<`u`&&window.innerWidth<768&&x(!1)},children:[z(h,{size:16,className:`shrink-0`}),B(`div`,{className:`flex-1 min-w-0 text-left`,children:[z(`div`,{className:`text-sm font-medium`,children:`通知`}),z(`div`,{className:`text-[11px] text-muted-foreground`,children:`群管/撤回等`})]}),A.length>0&&z(`span`,{className:`inline-flex items-center justify-center h-5 min-w-5 rounded-full bg-destructive text-destructive-foreground text-[10px] font-medium px-1`,children:A.length})]})]})]}),z(`div`,{className:`p-2 border-t border-border/60`,children:z(V,{variant:`outline`,size:`sm`,className:`w-full border-dashed text-xs h-8`,onClick:()=>void xe(),disabled:f||!i,children:`刷新好友/群`})})]}),y&&z(`div`,{className:`channel-overlay md:hidden`,onClick:()=>x(!1),"aria-hidden":!0}),B(`div`,{className:`im-main-split`,children:[B(`div`,{className:`im-center`,children:[_?.type===`channel`&&B(R,{children:[B(`header`,{className:`im-chat-header px-3 py-2.5 flex items-center justify-between gap-2`,children:[B(`div`,{className:`flex items-center gap-3 min-w-0`,children:[z(`div`,{className:`p-2 rounded-full bg-muted/80 text-muted-foreground shrink-0`,children:F(_.channelType)}),B(`div`,{className:`min-w-0`,children:[z(`h2`,{className:`text-[15px] font-semibold truncate leading-tight`,children:_.name}),B(`p`,{className:`text-[11px] text-muted-foreground truncate mt-0.5`,children:[_.channelType===`private`?`私聊`:_.channelType===`group`?`群聊`:`频道`,` `,`· `,_.id]})]})]}),B(`div`,{className:`flex items-center gap-1 shrink-0`,children:[_.channelType===`private`&&z(V,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-destructive hover:text-destructive`,title:`删除好友`,onClick:()=>void me(),children:z(qe,{className:`h-4 w-4`})}),z(V,{variant:`ghost`,size:`icon`,className:`h-8 w-8 opacity-50`,disabled:!0,title:`更多`,children:z(we,{className:`h-4 w-4`})})]})]}),B(`div`,{className:`flex-1 overflow-y-auto px-3 py-2 min-h-0 flex flex-col`,children:[k&&O&&z(`div`,{className:`flex-shrink-0 py-2 flex justify-center`,children:z(V,{variant:`ghost`,size:`sm`,className:`text-xs`,disabled:D,onClick:()=>{ee(Math.min(...te.map(e=>e.created_at)))},children:D?z(P,{className:`h-4 w-4 animate-spin`}):`加载更早消息`})}),E.length===0&&!D?B(`div`,{className:`flex flex-col items-center justify-center flex-1 gap-2 text-muted-foreground text-sm py-12`,children:[z(Se,{className:`h-10 w-10 opacity-35`}),z(`span`,{children:k?`暂无消息`:`暂无消息,对方发送的消息会显示在此处`})]}):z(`div`,{className:`flex flex-col gap-1 pb-2`,children:E.map(e=>{let n=Mr(e.timestamp),r=n!==Ie;r&&(Ie=n);let i=e.outgoing===!0;return B(t,{children:[r&&z(`div`,{className:`im-date-pill`,children:Nr(e.timestamp)}),z(`div`,{className:L(`flex w-full`,i?`justify-end`:`justify-start`),children:B(`div`,{className:L(i?`im-bubble-out`:`im-bubble-in`),children:[B(`div`,{className:L(`im-meta flex items-center gap-2 text-[10px] mb-0.5`,i?``:`text-muted-foreground`),children:[z(`span`,{className:L(`font-medium`,i?``:`text-foreground/90`),children:i?`我`:e.sender?.name||e.sender?.id||`未知`}),z(`span`,{className:`tabular-nums opacity-80`,children:new Date(e.timestamp).toLocaleTimeString(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})})]}),z(`div`,{className:`text-[14px] leading-snug break-words`,children:z(Dr,{content:e.content})})]})})]},e.id)})})]}),B(`div`,{className:`im-composer p-3 shrink-0 space-y-2`,children:[z(`input`,{ref:I,type:`file`,accept:`image/*`,className:`hidden`,onChange:Ne}),B(`div`,{className:`flex flex-wrap items-center gap-1`,children:[B(V,{type:`button`,variant:`outline`,size:`sm`,className:`h-8 px-2 text-xs`,title:`选择本地图片(插入为 data URL)`,onClick:()=>I.current?.click(),children:[z(fe,{className:`w-3.5 h-3.5 mr-1`}),`图片文件`]}),z(V,{type:`button`,variant:De===`image`?`secondary`:`outline`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:()=>{Oe(e=>e===`image`?null:`image`)},children:`图片链接`}),B(V,{type:`button`,variant:De===`video`?`secondary`:`outline`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:()=>{Oe(e=>e===`video`?null:`video`)},children:[z(Xe,{className:`w-3.5 h-3.5 mr-1`}),`视频`]}),B(V,{type:`button`,variant:De===`audio`?`secondary`:`outline`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:()=>{Oe(e=>e===`audio`?null:`audio`)},children:[z(Te,{className:`w-3.5 h-3.5 mr-1`}),`音频`]})]}),De&&B(`div`,{className:`flex flex-wrap items-end gap-2 rounded-md border border-border/80 bg-muted/20 p-2`,children:[z(H,{value:ke,onChange:e=>Ae(e.target.value),placeholder:De===`image`?`图片 URL 或 base64://…`:De===`video`?`视频直链 URL`:`音频直链 URL`,className:`flex-1 min-w-[12rem] h-9 text-sm`,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),Me())}}),B(V,{type:`button`,size:`sm`,className:`h-9`,onClick:Me,disabled:!ke.trim(),children:[z(b,{className:`w-3.5 h-3.5 mr-1`}),`插入`]})]}),B(`div`,{className:`flex gap-2 items-end`,children:[z(Bn,{placeholder:`文字消息,或使用上方插入图片/音视频… 也可手写 [image:URL]、[video:URL]、[audio:URL]`,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),he())},className:`flex-1 min-h-[44px] max-h-[160px] text-sm resize-y bg-background font-mono text-[13px]`,rows:2}),z(V,{className:`shrink-0 h-10 w-10 p-0 rounded-full`,onClick:()=>void he(),disabled:!Fe,children:d?z(P,{className:`h-4 w-4 animate-spin`}):z(Pe,{className:`h-4 w-4`})})]}),z(`p`,{className:`text-[10px] text-muted-foreground`,children:`Enter 发送 · Shift+Enter 换行 · 发送内容为消息段数组(含多媒体),由适配器实际发送`})]})]}),_?.type===`requests`&&B(`div`,{className:`flex flex-col flex-1 min-h-0 overflow-hidden bg-card m-0 border-0 rounded-none`,children:[B(`header`,{className:`im-chat-header px-4 py-3 flex items-center justify-between`,children:[B(`h2`,{className:`text-base font-semibold flex items-center gap-2`,children:[z(Je,{size:18}),`请求`]}),z(V,{size:`sm`,variant:`outline`,onClick:()=>void Ce(),children:`刷新`})]}),B(Cr,{value:j,onValueChange:e=>{M(e),e===`history`&&ie.length===0&&!ae&&se(!1)},className:`flex flex-col flex-1 min-h-0`,children:[B(wr,{className:`mx-3 mt-2 w-auto justify-start`,children:[z(Tr,{value:`pending`,children:`待处理`}),z(Tr,{value:`history`,children:`历史`})]}),B(Er,{value:`pending`,className:`flex-1 overflow-y-auto p-4 space-y-3 mt-0`,children:[ne.length===0&&B(`div`,{className:`flex flex-col items-center justify-center py-16 gap-2 text-muted-foreground text-sm`,children:[z(Je,{size:40,className:`opacity-25`}),z(`span`,{children:`暂无未处理请求`})]}),ne.map(e=>B(`div`,{className:`border border-border/80 rounded-lg p-3 space-y-2 bg-background/50`,children:[B(`div`,{className:`flex flex-wrap gap-2 text-sm`,children:[z(G,{children:e.type}),B(`span`,{children:[`来自 `,e.sender.name||e.sender.id]}),z(`span`,{className:`text-muted-foreground text-xs`,children:new Date(e.timestamp).toLocaleString()})]}),e.comment&&z(`p`,{className:`text-sm`,children:e.comment}),B(`div`,{className:`flex flex-wrap gap-2`,children:[e.canAct===!0&&B(R,{children:[z(V,{size:`sm`,onClick:()=>void ge(e.platformRequestId,!0),children:`同意`}),z(V,{size:`sm`,variant:`outline`,onClick:()=>void ge(e.platformRequestId,!1),children:`拒绝`})]}),z(V,{size:`sm`,variant:`ghost`,onClick:()=>void _e(e.id),children:`标记已处理`})]})]},e.id))]}),B(Er,{value:`history`,className:`flex-1 overflow-y-auto p-4 space-y-3 mt-0 min-h-0`,children:[!oe&&!ae&&z(`div`,{className:`flex flex-col items-center justify-center py-12 gap-2 text-muted-foreground text-sm`,children:z(`span`,{children:`未启用统一收件箱,无历史记录`})}),ae&&ie.length===0&&z(`div`,{className:`flex justify-center py-8`,children:z(P,{className:`h-6 w-6 animate-spin text-muted-foreground`})}),oe&&ie.length===0&&!ae&&z(`div`,{className:`flex flex-col items-center justify-center py-12 gap-2 text-muted-foreground text-sm`,children:z(`span`,{children:`暂无请求历史`})}),ie.length>0&&B(R,{children:[ie.map(e=>B(`div`,{className:`border border-border/80 rounded-lg p-3 space-y-1 text-sm bg-background/50`,children:[B(`div`,{className:`flex flex-wrap gap-2`,children:[z(G,{variant:`outline`,children:e.type}),z(`span`,{children:e.sender_name||e.sender_id}),z(`span`,{className:`text-muted-foreground text-xs`,children:new Date(e.created_at).toLocaleString()}),e.resolved?z(G,{variant:`secondary`,children:`已处理`}):null]}),e.comment&&z(`p`,{className:`text-muted-foreground text-sm`,children:e.comment})]},e.id)),z(`div`,{className:`flex justify-center pt-2`,children:z(V,{variant:`ghost`,size:`sm`,disabled:ae,onClick:()=>void se(!0),children:ae?z(P,{className:`h-4 w-4 animate-spin`}):`加载更多`})})]})]})]})]}),_?.type===`notices`&&B(`div`,{className:`flex flex-col flex-1 min-h-0 overflow-hidden bg-card m-0 border-0 rounded-none`,children:[z(`header`,{className:`im-chat-header px-4 py-3`,children:B(`h2`,{className:`text-base font-semibold flex items-center gap-2`,children:[z(h,{size:18}),`通知`]})}),B(Cr,{value:N,onValueChange:e=>{re(e),e===`history`&&ce.length===0&&!le&&de(!1)},className:`flex flex-col flex-1 min-h-0`,children:[B(wr,{className:`mx-3 mt-2 w-auto justify-start`,children:[z(Tr,{value:`unread`,children:`未读`}),z(Tr,{value:`history`,children:`历史`})]}),B(Er,{value:`unread`,className:`flex-1 overflow-y-auto p-4 space-y-3 mt-0`,children:[A.length===0&&B(`div`,{className:`flex flex-col items-center justify-center py-16 gap-2 text-muted-foreground text-sm`,children:[z(h,{size:40,className:`opacity-25`}),z(`span`,{children:`暂无未读通知`})]}),A.map(e=>B(`div`,{className:`border border-border/80 rounded-lg p-3 flex justify-between gap-2 bg-background/50`,children:[B(`div`,{className:`min-w-0`,children:[z(G,{className:`mb-1`,children:e.noticeType}),z(`p`,{className:`text-xs text-muted-foreground font-mono truncate max-w-md`,children:e.payload.slice(0,200)}),z(`p`,{className:`text-xs text-muted-foreground mt-1`,children:new Date(e.timestamp).toLocaleString()})]}),z(V,{size:`sm`,variant:`outline`,onClick:()=>void ve(e.id),children:`已读`})]},e.id))]}),B(Er,{value:`history`,className:`flex-1 overflow-y-auto p-4 space-y-3 mt-0 min-h-0`,children:[!ue&&!le&&z(`div`,{className:`flex flex-col items-center justify-center py-12 gap-2 text-muted-foreground text-sm`,children:z(`span`,{children:`未启用统一收件箱,无历史记录`})}),le&&ce.length===0&&z(`div`,{className:`flex justify-center py-8`,children:z(P,{className:`h-6 w-6 animate-spin text-muted-foreground`})}),ue&&ce.length===0&&!le&&z(`div`,{className:`flex flex-col items-center justify-center py-12 gap-2 text-muted-foreground text-sm`,children:z(`span`,{children:`暂无通知历史`})}),ce.length>0&&B(R,{children:[ce.map(e=>B(`div`,{className:`border border-border/80 rounded-lg p-3 space-y-1 text-sm bg-background/50`,children:[B(`div`,{className:`flex flex-wrap gap-2`,children:[z(G,{variant:`outline`,children:e.type}),z(`span`,{className:`text-muted-foreground text-xs`,children:new Date(e.created_at).toLocaleString()})]}),z(`p`,{className:`text-muted-foreground font-mono text-xs truncate max-w-full`,children:String(e.payload??``).slice(0,200)})]},e.id)),z(`div`,{className:`flex justify-center pt-2`,children:z(V,{variant:`ghost`,size:`sm`,disabled:le,onClick:()=>void de(!0),children:le?z(P,{className:`h-4 w-4 animate-spin`}):`加载更多`})})]})]})]})]}),!_&&B(`div`,{className:`flex flex-col items-center justify-center flex-1 gap-3 text-muted-foreground px-6 text-center`,children:[z(Se,{className:`h-14 w-14 opacity-20`}),z(`p`,{className:`text-sm font-medium text-foreground/80`,children:`选择会话或查看请求 / 通知`}),z(`p`,{className:`text-xs max-w-sm`,children:`左侧列表与 Telegram Web 类似:点选好友或群开始聊天;请求与通知在列表下方分组。`})]})]}),Ee&&B(`aside`,{className:L(`im-right-panel im-right-visible`),children:[B(`div`,{className:`p-3 border-b border-border/60`,children:[z(`h3`,{className:`text-sm font-semibold`,children:`群成员与管理`}),z(`p`,{className:`text-[11px] text-muted-foreground mt-0.5`,children:`仅 ICQQ 群聊`})]}),z(`div`,{className:`p-2 border-b border-border/60`,children:B(V,{size:`sm`,variant:`outline`,className:`w-full`,onClick:()=>void ye(),disabled:T,children:[T?z(P,{className:`h-4 w-4 animate-spin mr-1`}):null,`加载成员`]})}),z(`div`,{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-0`,children:w.map((e,t)=>{let n=e.user_id??e.id??t;return B(`div`,{className:`flex flex-col gap-1.5 text-xs p-2 border border-border/70 rounded-md bg-background/60`,children:[B(`div`,{className:`flex flex-wrap items-center gap-1`,children:[z(`span`,{className:`font-medium text-sm`,children:e.nickname??e.name??n}),z(`span`,{className:`text-muted-foreground`,children:n}),(e.role??e.role)!=null&&z(G,{variant:`outline`,className:`text-[10px]`,children:String(e.role??e.role)})]}),B(`div`,{className:`flex flex-wrap gap-1`,children:[z(V,{size:`sm`,variant:`destructive`,className:`h-7 text-[10px] px-2`,onClick:()=>void be(`bot:groupKick`,n),children:`踢`}),z(V,{size:`sm`,variant:`outline`,className:`h-7 text-[10px] px-2`,onClick:()=>void be(`bot:groupMute`,n),children:`禁言`}),z(V,{size:`sm`,variant:`outline`,className:`h-7 text-[10px] px-2`,onClick:()=>void be(`bot:groupAdmin`,n,{enable:!0}),children:`管理`})]})]},`${n}-${t}`)})})]})]})]})}var Fr=e.forwardRef(({className:e,...t},n)=>z(kt.Root,{ref:n,className:L(`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`,e),...t,children:z(kt.Indicator,{className:L(`flex items-center justify-center text-current`),children:z(b,{className:`h-4 w-4`})})}));Fr.displayName=`Checkbox`;function Ir({title:e,description:t,actions:n,className:r}){return B(`div`,{className:L(`flex flex-col gap-1 sm:flex-row sm:items-start sm:justify-between sm:gap-4`,r),children:[B(`div`,{className:`min-w-0 space-y-1`,children:[z(`h1`,{className:`text-2xl font-bold tracking-tight`,children:e}),t?z(`p`,{className:`text-sm text-muted-foreground max-w-2xl`,children:t}):null]}),n?z(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:n}):null]})}function Lr(){let[e,t]=c([]),[n,r]=c(null),[i,l]=c(!0),[u,p]=c(null),[m,h]=c(`all`),[g,_]=c(!0),v=s(null),y=s(0),[b,x]=c(``),S=o(()=>{let t=b.trim().toLowerCase();return t?e.filter(e=>e.message.toLowerCase().includes(t)||e.source.toLowerCase().includes(t)||e.level.toLowerCase().includes(t)):e},[e,b]);a(()=>{C(),w();let e=setInterval(()=>{C(),w()},3e3);return()=>clearInterval(e)},[m]),a(()=>{g&&e.length>y.current&&v.current?.scrollIntoView({behavior:`smooth`}),y.current=e.length},[e.length,g]);let C=async()=>{try{let e=await hn(m===`all`?`/api/logs?limit=100`:`/api/logs?limit=100&level=${m}`);if(!e.ok)throw Error(`API 请求失败`);let n=await e.json();n.success&&Array.isArray(n.data)&&(t(n.data.reverse()),p(null))}catch(e){p(e.message)}finally{l(!1)}},w=async()=>{try{let e=await hn(`/api/logs/stats`);if(!e.ok)return;let t=await e.json();t.success&&r(t.data)}catch(e){console.error(`Failed to fetch stats:`,e)}},T=async(e,t)=>{let n=e?`确定清理 ${e} 天前的日志吗?`:`确定只保留最近 ${t} 条日志吗?`;if(confirm(n))try{let n=await hn(`/api/logs/cleanup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({days:e,maxRecords:t})});if(!n.ok)throw Error(`清理失败`);let r=await n.json();r.success&&(alert(`成功清理 ${r.data.deletedCount} 条日志`),C(),w())}catch(e){alert(e.message)}},D=e=>{switch(e){case`info`:return{border:`border-l-blue-500`,badge:`default`,icon:z(pe,{className:`w-3 h-3`})};case`warn`:return{border:`border-l-amber-500`,badge:`warning`,icon:z(f,{className:`w-3 h-3`})};case`error`:return{border:`border-l-red-500`,badge:`destructive`,icon:z(tt,{className:`w-3 h-3`})};default:return{border:`border-l-gray-500`,badge:`secondary`,icon:z(E,{className:`w-3 h-3`})}}};if(i)return B(`div`,{className:`space-y-4`,children:[z(J,{className:`h-8 w-48`}),z(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3`,children:[...[,,,,]].map((e,t)=>z(J,{className:`h-20`},t))}),z(J,{className:`h-96`})]});let O=async e=>{try{await navigator.clipboard.writeText(e)}catch{}};return B(`div`,{className:`space-y-6`,children:[z(Ir,{title:`系统日志`,description:`实时查看与筛选系统运行日志;支持按级别与关键字过滤。`}),n&&B(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3`,children:[z(U,{children:B(W,{className:`flex flex-col items-center gap-1 p-4`,children:[z(`span`,{className:`text-2xl font-bold`,children:n.total}),z(`span`,{className:`text-xs text-muted-foreground`,children:`总日志数`})]})}),z(U,{children:B(W,{className:`flex flex-col items-center gap-1 p-4`,children:[z(`span`,{className:`text-2xl font-bold text-blue-600 dark:text-blue-400`,children:n.byLevel.info||0}),z(`span`,{className:`text-xs text-muted-foreground`,children:`Info`})]})}),z(U,{children:B(W,{className:`flex flex-col items-center gap-1 p-4`,children:[z(`span`,{className:`text-2xl font-bold text-amber-600 dark:text-amber-400`,children:n.byLevel.warn||0}),z(`span`,{className:`text-xs text-muted-foreground`,children:`Warn`})]})}),z(U,{children:B(W,{className:`flex flex-col items-center gap-1 p-4`,children:[z(`span`,{className:`text-2xl font-bold text-red-600 dark:text-red-400`,children:n.byLevel.error||0}),z(`span`,{className:`text-xs text-muted-foreground`,children:`Error`})]})})]}),z(U,{className:`border-border/80 shadow-sm`,children:B(W,{className:`flex justify-between items-center p-3 flex-wrap gap-3`,children:[B(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[B(`div`,{className:`relative flex-1 min-w-[180px] max-w-xs`,children:[z(Ne,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground pointer-events-none`}),z(`input`,{type:`search`,placeholder:`搜索消息、来源…`,value:b,onChange:e=>x(e.target.value),className:`w-full h-9 pl-9 pr-3 rounded-md border border-input bg-background text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`})]}),B(Hn,{value:m,onValueChange:h,children:[z(Wn,{className:`w-32`,children:z(Un,{placeholder:`所有级别`})}),B(qn,{children:[z(Jn,{value:`all`,children:`所有级别`}),z(Jn,{value:`info`,children:`Info`}),z(Jn,{value:`warn`,children:`Warn`}),z(Jn,{value:`error`,children:`Error`})]})]}),B(`div`,{className:`flex items-center gap-2`,children:[z(Fr,{id:`auto-scroll`,checked:g,onCheckedChange:e=>_(e)}),z(`label`,{htmlFor:`auto-scroll`,className:`text-sm cursor-pointer`,children:`自动滚动`})]})]}),B(`div`,{className:`flex gap-2`,children:[B(V,{variant:`outline`,size:`sm`,onClick:()=>T(7),children:[z(We,{className:`w-3.5 h-3.5 mr-1`}),`清理7天前`]}),B(V,{variant:`outline`,size:`sm`,onClick:()=>T(void 0,5e3),children:[z(We,{className:`w-3.5 h-3.5 mr-1`}),`保留5000条`]}),B(V,{variant:`outline`,size:`sm`,onClick:()=>C(),children:[z(I,{className:`w-3.5 h-3.5 mr-1`}),`刷新`]})]})]})}),z(U,{className:`border-border/80 shadow-sm`,children:z(W,{className:`p-4`,children:B(`div`,{className:`max-h-[min(70vh,720px)] overflow-y-auto rounded-md border border-border/60 bg-muted/20 dark:bg-muted/30 p-2 space-y-1.5`,children:[u?B(K,{variant:`destructive`,children:[z(d,{className:`h-4 w-4`}),B(q,{children:[`加载失败: `,u]})]}):e.length===0?B(`div`,{className:`flex flex-col items-center gap-3 py-12`,children:[z(ie,{className:`w-12 h-12 text-muted-foreground/30`}),z(`span`,{className:`text-sm text-muted-foreground`,children:`暂无日志`})]}):S.length===0?B(`div`,{className:`flex flex-col items-center gap-2 py-10 text-sm text-muted-foreground`,children:[`没有符合「`,b,`」的条目,请调整筛选条件`]}):S.map((e,t)=>{let n=D(e.level),r=`[${e.timestamp}] [${e.level}] ${e.source?e.source+` `:``}${e.message}`;return B(`div`,{className:L(`group relative p-3 rounded-md border border-border/50 bg-card/80 dark:bg-card/60 shadow-sm`,`border-l-[3px]`,n.border),children:[B(`div`,{className:`flex items-center gap-2 mb-1 flex-wrap pr-8`,children:[B(G,{variant:n.badge,className:`gap-1 text-[10px] px-1.5 py-0 font-medium`,children:[n.icon,` `,e.level.toUpperCase()]}),z(`span`,{className:`text-[11px] tabular-nums text-muted-foreground`,children:new Date(e.timestamp).toLocaleString()}),e.source&&z(G,{variant:`outline`,className:`text-[10px] px-1.5 py-0 font-normal`,children:e.source})]}),z(`p`,{className:`text-[13px] leading-relaxed font-mono text-foreground/95 whitespace-pre-wrap break-words pr-2`,children:e.message}),z(V,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute top-2 right-2 h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity`,title:`复制本行`,onClick:()=>void O(r),children:z(k,{className:`w-3.5 h-3.5`})})]},`${e.timestamp}-${t}`)}),z(`div`,{ref:v})]})})})]})}var Rr=Symbol.for(`yaml.alias`),zr=Symbol.for(`yaml.document`),Br=Symbol.for(`yaml.map`),Vr=Symbol.for(`yaml.pair`),Hr=Symbol.for(`yaml.scalar`),Ur=Symbol.for(`yaml.seq`),Wr=Symbol.for(`yaml.node.type`),Gr=e=>!!e&&typeof e==`object`&&e[Wr]===Rr,Kr=e=>!!e&&typeof e==`object`&&e[Wr]===zr,qr=e=>!!e&&typeof e==`object`&&e[Wr]===Br,Y=e=>!!e&&typeof e==`object`&&e[Wr]===Vr,X=e=>!!e&&typeof e==`object`&&e[Wr]===Hr,Jr=e=>!!e&&typeof e==`object`&&e[Wr]===Ur;function Z(e){if(e&&typeof e==`object`)switch(e[Wr]){case Br:case Ur:return!0}return!1}function Q(e){if(e&&typeof e==`object`)switch(e[Wr]){case Rr:case Br:case Hr:case Ur:return!0}return!1}var Yr=e=>(X(e)||Z(e))&&!!e.anchor,Xr=Symbol(`break visit`),Zr=Symbol(`skip children`),Qr=Symbol(`remove node`);function $r(e,t){let n=ri(t);Kr(e)?ei(null,e.contents,n,Object.freeze([e]))===Qr&&(e.contents=null):ei(null,e,n,Object.freeze([]))}$r.BREAK=Xr,$r.SKIP=Zr,$r.REMOVE=Qr;function ei(e,t,n,r){let i=ii(e,t,n,r);if(Q(i)||Y(i))return ai(e,r,i),ei(e,i,n,r);if(typeof i!=`symbol`){if(Z(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=ei(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===Xr)return Xr;else i===Qr&&(t.items.splice(e,1),--e)}}else if(Y(t)){r=Object.freeze(r.concat(t));let e=ei(`key`,t.key,n,r);if(e===Xr)return Xr;e===Qr&&(t.key=null);let i=ei(`value`,t.value,n,r);if(i===Xr)return Xr;i===Qr&&(t.value=null)}}return i}async function ti(e,t){let n=ri(t);Kr(e)?await ni(null,e.contents,n,Object.freeze([e]))===Qr&&(e.contents=null):await ni(null,e,n,Object.freeze([]))}ti.BREAK=Xr,ti.SKIP=Zr,ti.REMOVE=Qr;async function ni(e,t,n,r){let i=await ii(e,t,n,r);if(Q(i)||Y(i))return ai(e,r,i),ni(e,i,n,r);if(typeof i!=`symbol`){if(Z(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=await ni(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===Xr)return Xr;else i===Qr&&(t.items.splice(e,1),--e)}}else if(Y(t)){r=Object.freeze(r.concat(t));let e=await ni(`key`,t.key,n,r);if(e===Xr)return Xr;e===Qr&&(t.key=null);let i=await ni(`value`,t.value,n,r);if(i===Xr)return Xr;i===Qr&&(t.value=null)}}return i}function ri(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function ii(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(qr(t))return n.Map?.(e,t,r);if(Jr(t))return n.Seq?.(e,t,r);if(Y(t))return n.Pair?.(e,t,r);if(X(t))return n.Scalar?.(e,t,r);if(Gr(t))return n.Alias?.(e,t,r)}function ai(e,t,n){let r=t[t.length-1];if(Z(r))r.items[e]=n;else if(Y(r))e===`key`?r.key=n:r.value=n;else if(Kr(r))r.contents=n;else{let e=Gr(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}var oi={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},si=e=>e.replace(/[!,[\]{}]/g,e=>oi[e]),ci=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+si(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&Q(e.contents)){let t={};$r(e.contents,(e,n)=>{Q(n)&&n.tag&&(t[n.tag]=!0)}),r=Object.keys(t)}else r=[];for(let[i,a]of n)i===`!!`&&a===`tag:yaml.org,2002:`||(!e||r.some(e=>e.startsWith(a)))&&t.push(`%TAG ${i} ${a}`);return t.join(`
|
|
6
|
+
`)}};ci.defaultYaml={explicit:!1,version:`1.2`},ci.defaultTags={"!!":`tag:yaml.org,2002:`};function li(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function ui(e){let t=new Set;return $r(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function di(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function fi(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=ui(e);let a=di(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(X(t.node)||Z(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function pi(e,t,n,r){if(r&&typeof r==`object`)if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=pi(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=pi(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=pi(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=pi(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}return e.call(t,n,r)}function mi(e,t,n){if(Array.isArray(e))return e.map((e,t)=>mi(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!Yr(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var hi=class{constructor(e){Object.defineProperty(this,Wr,{value:e})}clone(){let 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(!Kr(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=mi(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?pi(i,{"":o},``,o):o}},gi=class extends hi{constructor(e){super(Rr),this.source=e,Object.defineProperty(this,`tag`,{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],$r(e,{Node:(e,t)=>{(Gr(t)||Yr(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}return r}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,a=this.resolve(r,t);if(!a){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let o=n.get(a);if(o||=(mi(a,null,t),n.get(a)),o?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(o.count+=1,o.aliasCount===0&&(o.aliasCount=_i(r,a,n)),o.count*o.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return o.res}toString(e,t,n){let r=`*${this.source}`;if(e){if(li(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function _i(e,t,n){if(Gr(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(Z(t)){let r=0;for(let i of t.items){let t=_i(e,i,n);t>r&&(r=t)}return r}else if(Y(t)){let r=_i(e,t.key,n),i=_i(e,t.value,n);return Math.max(r,i)}return 1}var vi=e=>!e||typeof e!=`function`&&typeof e!=`object`,$=class extends hi{constructor(e){super(Hr),this.value=e}toJSON(e,t){return t?.keep?this.value:mi(this.value,e,t)}toString(){return String(this.value)}};$.BLOCK_FOLDED=`BLOCK_FOLDED`,$.BLOCK_LITERAL=`BLOCK_LITERAL`,$.PLAIN=`PLAIN`,$.QUOTE_DOUBLE=`QUOTE_DOUBLE`,$.QUOTE_SINGLE=`QUOTE_SINGLE`;var yi=`tag:yaml.org,2002:`;function bi(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function xi(e,t,n){if(Kr(e)&&(e=e.contents),Q(e))return e;if(Y(e)){let t=n.schema[Br].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??=i(e),new gi(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=yi+t.slice(2));let l=bi(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new $(e);return c&&(c.node=t),t}l=e instanceof Map?o[Br]:Symbol.iterator in Object(e)?o[Ur]:o[Br]}a&&(a(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==`function`?l.nodeClass.from(n.schema,e,n):new $(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function Si(e,t,n){let r=n;for(let e=t.length-1;e>=0;--e){let n=t[e];if(typeof n==`number`&&Number.isInteger(n)&&n>=0){let e=[];e[n]=r,r=e}else r=new Map([[n,r]])}return xi(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}var Ci=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done,wi=class extends hi{constructor(e,t){super(e),Object.defineProperty(this,`schema`,{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>Q(t)||Y(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Ci(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(Z(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,Si(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(Z(r))return r.deleteIn(n);throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);return r.length===0?!t&&X(i)?i.value:i:Z(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!Y(t))return!1;let n=t.value;return n==null||e&&X(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return Z(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let e=this.get(n,!0);if(Z(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,Si(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}},Ti=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function Ei(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var Di=(e,t,n)=>e.endsWith(`
|
|
7
|
+
`)?Ei(n,t):n.includes(`
|
|
8
|
+
`)?`
|
|
9
|
+
`+Ei(n,t):(e.endsWith(` `)?``:` `)+n,Oi=`flow`,ki=`block`,Ai=`quoted`;function ji(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=Mi(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===`
|
|
10
|
+
`)n===`block`&&(h=Mi(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
|
|
11
|
+
`&&p!==` `){let t=e[h+1];t&&t!==` `&&t!==`
|
|
12
|
+
`&&t!==` `&&(f=h)}if(h>=d)if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function Mi(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
|
|
13
|
+
`);r=t,i=t+1,a=e[i]}return r}var Ni=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Pi=e=>/^(%|---|\.\.\.)/m.test(e);function Fi(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
|
|
14
|
+
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function Ii(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(Pi(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
|
|
15
|
+
|
|
16
|
+
`;n[e+2]===`\\`&&n[e+3]===`n`&&n[e+4]!==`"`;)o+=`
|
|
17
|
+
`,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:ji(o,a,Ai,Ni(t,!1))}function Li(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
|
|
18
|
+
`)||/[ \t]\n|\n[ \t]/.test(e))return Ii(e,t);let n=t.indent||(Pi(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:ji(r,n,Oi,Ni(t,!1))}function Ri(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=Ii;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?Li:i&&!t?Ii:n?Li:Ii}return r(e,t)}var zi;try{zi=RegExp(`(^|(?<!
|
|
19
|
+
))
|
|
20
|
+
+(?!
|
|
21
|
+
|$)`,`g`)}catch{zi=/\n+(?!\n|$)/g}function Bi({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return Ri(n,r);let l=r.indent||(r.forceBlockIndent||Pi(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===$.BLOCK_FOLDED?!1:t===$.BLOCK_LITERAL?!0:!Fi(n,c,l.length);if(!n)return u?`|
|
|
22
|
+
`:`>
|
|
23
|
+
`;let d,f;for(f=n.length;f>0;--f){let e=n[f-1];if(e!==`
|
|
24
|
+
`&&e!==` `&&e!==` `)break}let p=n.substring(f),m=p.indexOf(`
|
|
25
|
+
`);m===-1?d=`-`:n===p||m!==p.length-1?(d=`+`,a&&a()):d=``,p&&=(n=n.slice(0,-p.length),p[p.length-1]===`
|
|
26
|
+
`&&(p=p.slice(0,-1)),p.replace(zi,`$&${l}`));let h=!1,g,_=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
|
|
27
|
+
`)_=g;else break}let v=n.substring(0,_<g?_+1:g);v&&=(n=n.substring(v.length),v.replace(/\n+/g,`$&${l}`));let y=(h?l?`2`:`1`:``)+d;if(e&&(y+=` `+s(e.replace(/ ?[\r\n]+/g,` `)),i&&i()),!u){let e=n.replace(/\n+/g,`
|
|
28
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`),i=!1,a=Ni(r,!0);o!==`folded`&&t!==$.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=ji(`${v}${e}${p}`,l,ki,a);if(!i)return`>${y}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}\n${l}${v}${n}${p}`}function Vi(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
|
|
29
|
+
`)||u&&/[[\]{},]/.test(a))return Ri(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
|
|
30
|
+
`)?Ri(a,t):Bi(e,t,n,r);if(!s&&!u&&i!==$.PLAIN&&a.includes(`
|
|
31
|
+
`))return Bi(e,t,n,r);if(Pi(a)){if(c===``)return t.forceBlockIndent=!0,Bi(e,t,n,r);if(s&&c===l)return Ri(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return Ri(a,t)}return s?d:ji(d,c,Oi,Ni(t,!1))}function Hi(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==$.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=$.QUOTE_DOUBLE);let c=e=>{switch(e){case $.BLOCK_FOLDED:case $.BLOCK_LITERAL:return i||a?Ri(o.value,t):Bi(o,t,n,r);case $.QUOTE_DOUBLE:return Ii(o.value,t);case $.QUOTE_SINGLE:return Li(o.value,t);case $.PLAIN:return Vi(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function Ui(e,t){let n=Object.assign({blockQuote:!0,commentString:Ti,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},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function Wi(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(X(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(r===null?`null`:typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}function Gi(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(X(e)||Z(e))&&e.anchor;a&&li(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&i.push(r.directives.tagString(o)),i.join(` `)}function Ki(e,t,n,r){if(Y(e))return e.toString(t,n,r);if(Gr(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=Q(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=Wi(t.doc.schema.tags,a);let o=Gi(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):X(a)?Hi(a,t,n,r):a.toString(t,n,r);return o?X(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function qi({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=Q(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(Z(e)||!Q(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||Z(e)||(X(e)?e.type===$.BLOCK_FOLDED||e.type===$.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=Ki(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=Di(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=Di(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=Di(g,n.indent,l(f))));let _,v,y;Q(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&X(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&Jr(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=Ki(t,n,()=>b=!0,()=>h=!0),S=` `;if(f||_||v){if(S=_?`
|
|
32
|
+
`:``,v){let e=l(v);S+=`\n${Ei(e,n.indent)}`}x===``&&!n.inFlow?S===`
|
|
33
|
+
`&&y&&(S=`
|
|
34
|
+
|
|
35
|
+
`):S+=`\n${n.indent}`}else if(!p&&Z(t)){let e=x[0],r=x.indexOf(`
|
|
36
|
+
`),i=r!==-1,a=n.inFlow??t.flow??t.items.length===0;if(i||!a){let t=!1;if(i&&(e===`&`||e===`!`)){let n=x.indexOf(` `);e===`&`&&n!==-1&&n<r&&x[n+1]===`!`&&(n=x.indexOf(` `,n+1)),(n===-1||r<n)&&(t=!0)}t||(S=`\n${n.indent}`)}}else (x===``||x[0]===`
|
|
37
|
+
`)&&(S=``);return g+=S+x,n.inFlow?b&&r&&r():y&&!b?g+=Di(g,n.indent,l(y)):h&&i&&i(),g}function Ji(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}var Yi=`<<`,Xi={identify:e=>e===Yi||typeof e==`symbol`&&e.description===Yi,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new $(Symbol(Yi)),{addToJSMap:Qi}),stringify:()=>Yi},Zi=(e,t)=>(Xi.identify(t)||X(t)&&(!t.type||t.type===$.PLAIN)&&Xi.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===Xi.tag&&e.default);function Qi(e,t,n){if(n=e&&Gr(n)?n.resolve(e.doc):n,Jr(n))for(let r of n.items)$i(e,t,r);else if(Array.isArray(n))for(let r of n)$i(e,t,r);else $i(e,t,n)}function $i(e,t,n){let r=e&&Gr(n)?n.resolve(e.doc):n;if(!qr(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function ea(e,t,{key:n,value:r}){if(Q(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(Zi(e,n))Qi(e,t,r);else{let i=mi(n,``,e);if(t instanceof Map)t.set(i,mi(r,i,e));else if(t instanceof Set)t.add(i);else{let a=ta(n,i,e),o=mi(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function ta(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(Q(e)&&n?.doc){let t=Ui(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),Ji(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function na(e,t,n){return new ra(xi(e,void 0,n),xi(t,void 0,n))}var ra=class e{constructor(e,t=null){Object.defineProperty(this,Wr,{value:Vr}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return Q(n)&&(n=n.clone(t)),Q(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return ea(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?qi(this,e,t,n):JSON.stringify(this)}};function ia(e,t,n){return(t.inFlow??e.flow?oa:aa)(e,t,n)}function aa({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(Q(i))!d&&i.spaceBefore&&f.push(``),sa(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(Y(i)){let e=Q(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),sa(n,f,e.commentBefore,d))}d=!1;let s=Ki(i,u,()=>o=null,()=>d=!0);o&&(s+=Di(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
|
|
38
|
+
`}}return e?(p+=`
|
|
39
|
+
`+Ei(l(e),c),s&&s()):d&&o&&o(),p}function oa({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(Q(i))i.spaceBefore&&d.push(``),sa(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(Y(i)){let e=Q(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),sa(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=Q(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=Ki(i,c,()=>a=null);n<e.length-1&&(o+=`,`),a&&(o+=Di(o,r,s(a))),!l&&(d.length>u||o.includes(`
|
|
40
|
+
`))&&(l=!0),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
|
|
41
|
+
`;return`${e}\n${i}${p}`}else return`${f}${o}${d.join(` `)}${o}${p}`}function sa({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=Ei(t(r),e);n.push(i.trimStart())}}function ca(e,t){let n=X(t)?t.value:t;for(let r of e)if(Y(r)&&(r.key===t||r.key===n||X(r.key)&&r.key.value===n))return r}var la=class extends wi{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(Br,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(na(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=Y(e)?e:!e||typeof e!=`object`||!(`key`in e)?new ra(e,e?.value):new ra(e.key,e.value);let r=ca(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);X(r.value)&&vi(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=ca(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=ca(this.items,e)?.value;return(!t&&X(n)?n.value:n)??void 0}has(e){return!!ca(this.items,e)}set(e,t){this.add(new ra(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)ea(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!Y(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),ia(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}},ua={collection:`map`,default:!0,nodeClass:la,tag:`tag:yaml.org,2002:map`,resolve(e,t){return qr(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>la.from(e,t,n)},da=class extends wi{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(Ur,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=fa(e);return typeof t==`number`?this.items.splice(t,1).length>0:!1}get(e,t){let n=fa(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&X(r)?r.value:r}has(e){let t=fa(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=fa(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];X(r)&&vi(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(mi(e,String(r++),t));return n}toString(e,t,n){return e?ia(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(xi(a,void 0,n))}}return i}};function fa(e){let t=X(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}var pa={collection:`seq`,default:!0,nodeClass:da,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return Jr(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>da.from(e,t,n)},ma={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),Hi(e,t,n,r)}},ha={identify:e=>e==null,createNode:()=>new $(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new $(null),stringify:({source:e},t)=>typeof e==`string`&&ha.test.test(e)?e:t.options.nullStr},ga={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new $(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},n){return e&&ga.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?n.options.trueStr:n.options.falseStr}};function _a({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^\d/.test(a)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-- >0;)a+=`0`}return a}var va={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:_a},ya={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():_a(e)}},ba={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new $(parseFloat(e)),n=e.indexOf(`.`);return n!==-1&&e[e.length-1]===`0`&&(t.minFractionDigits=e.length-n-1),t},stringify:_a},xa=e=>typeof e==`bigint`||Number.isInteger(e),Sa=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function Ca(e,t,n){let{value:r}=e;return xa(r)&&r>=0?n+r.toString(t):_a(e)}var wa={identify:e=>xa(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>Sa(e,2,8,n),stringify:e=>Ca(e,8,`0o`)},Ta={identify:xa,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>Sa(e,0,10,n),stringify:_a},Ea={identify:e=>xa(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>Sa(e,2,16,n),stringify:e=>Ca(e,16,`0x`)},Da=[ua,pa,ma,ha,ga,wa,Ta,Ea,va,ya,ba];function Oa(e){return typeof e==`bigint`||Number.isInteger(e)}var ka=({value:e})=>JSON.stringify(e),Aa=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:ka},{identify:e=>e==null,createNode:()=>new $(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:ka},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:ka},{identify:Oa,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>Oa(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:ka}],ja=[ua,pa].concat(Aa,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}}),Ma={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,t){if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}else return t(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:t,value:n},r,i,a){if(!n)return``;let o=n,s;if(typeof btoa==`function`){let e=``;for(let t=0;t<o.length;++t)e+=String.fromCharCode(o[t]);s=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(t??=$.BLOCK_LITERAL,t!==$.QUOTE_DOUBLE){let e=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),n=Math.ceil(s.length/e),i=Array(n);for(let t=0,r=0;t<n;++t,r+=e)i[t]=s.substr(r,e);s=i.join(t===$.BLOCK_LITERAL?`
|
|
42
|
+
`:` `)}return Hi({comment:e,type:t,value:s},r,i,a)}};function Na(e,t){if(Jr(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!Y(r)){if(qr(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new ra(new $(null));if(r.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${r.commentBefore}\n${e.key.commentBefore}`:r.commentBefore),r.comment){let t=e.value??e.key;t.comment=t.comment?`${r.comment}\n${t.comment}`:r.comment}r=e}e.items[n]=Y(r)?r:new ra(r)}}else t(`Expected a sequence for this tag`);return e}function Pa(e,t,n){let{replacer:r}=n,i=new da(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e))if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`);else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(na(o,s,n))}return i}var Fa={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:Na,createNode:Pa},Ia=class e extends da{constructor(){super(),this.add=la.prototype.add.bind(this),this.delete=la.prototype.delete.bind(this),this.get=la.prototype.get.bind(this),this.has=la.prototype.has.bind(this),this.set=la.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(Y(e)?(r=mi(e.key,``,t),i=mi(e.value,r,t)):r=mi(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=Pa(e,t,n),i=new this;return i.items=r.items,i}};Ia.tag=`tag:yaml.org,2002:omap`;var La={collection:`seq`,identify:e=>e instanceof Map,nodeClass:Ia,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=Na(e,t),r=[];for(let{key:e}of n.items)X(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new Ia,n)},createNode:(e,t,n)=>Ia.from(e,t,n)};function Ra({value:e,source:t},n){return t&&(e?za:Ba).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var za={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new $(!0),stringify:Ra},Ba={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new $(!1),stringify:Ra},Va={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:_a},Ha={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():_a(e)}},Ua={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new $(parseFloat(e.replace(/_/g,``))),n=e.indexOf(`.`);if(n!==-1){let r=e.substring(n+1).replace(/_/g,``);r[r.length-1]===`0`&&(t.minFractionDigits=r.length)}return t},stringify:_a},Wa=e=>typeof e==`bigint`||Number.isInteger(e);function Ga(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function Ka(e,t,n){let{value:r}=e;if(Wa(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return _a(e)}var qa={identify:Wa,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>Ga(e,2,2,n),stringify:e=>Ka(e,2,`0b`)},Ja={identify:Wa,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>Ga(e,1,8,n),stringify:e=>Ka(e,8,`0`)},Ya={identify:Wa,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>Ga(e,0,10,n),stringify:_a},Xa={identify:Wa,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>Ga(e,2,16,n),stringify:e=>Ka(e,16,`0x`)},Za=class e extends la{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=Y(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new ra(e.key,null):new ra(e,null),ca(this.items,t.key)||this.items.push(t)}get(e,t){let n=ca(this.items,e);return!t&&Y(n)?X(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=ca(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new ra(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 Error(`Set items must all have null values`)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof r==`function`&&(e=r.call(t,e,e)),i.items.push(na(e,null,n));return i}};Za.tag=`tag:yaml.org,2002:set`;var Qa={collection:`map`,identify:e=>e instanceof Set,nodeClass:Za,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>Za.from(e,t,n),resolve(e,t){if(qr(e)){if(e.hasAllNullValues(!0))return Object.assign(new Za,e);t(`Set items must all have null values`)}else t(`Expected a mapping for this tag`);return e}};function $a(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function eo(e){let{value:t}=e,n=e=>e;if(typeof t==`bigint`)n=e=>BigInt(e);else if(isNaN(t)||!isFinite(t))return _a(e);let r=``;t<0&&(r=`-`,t*=n(-1));let i=n(60),a=[t%i];return t<60?a.unshift(0):(t=(t-a[0])/i,a.unshift(t%i),t>=60&&(t=(t-a[0])/i,a.unshift(t))),r+a.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}var to={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>$a(e,n),stringify:eo},no={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>$a(e,!1),stringify:eo},ro={identify:e=>e 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(e){let t=e.match(ro.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,n,r,i,a,o,s]=t.map(Number),c=t[7]?Number((t[7]+`00`).substr(1,3)):0,l=Date.UTC(n,r-1,i,a||0,o||0,s||0,c),u=t[8];if(u&&u!==`Z`){let e=$a(u,!1);Math.abs(e)<30&&(e*=60),l-=6e4*e}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``},io=[ua,pa,ma,ha,za,Ba,qa,Ja,Ya,Xa,Va,Ha,Ua,Ma,Xi,La,Fa,Qa,to,no,ro],ao=new Map([[`core`,Da],[`failsafe`,[ua,pa,ma]],[`json`,ja],[`yaml11`,io],[`yaml-1.1`,io]]),oo={binary:Ma,bool:ga,float:ba,floatExp:ya,floatNaN:va,floatTime:no,int:Ta,intHex:Ea,intOct:wa,intTime:to,map:ua,merge:Xi,null:ha,omap:La,pairs:Fa,seq:pa,set:Qa,timestamp:ro},so={"tag:yaml.org,2002:binary":Ma,"tag:yaml.org,2002:merge":Xi,"tag:yaml.org,2002:omap":La,"tag:yaml.org,2002:pairs":Fa,"tag:yaml.org,2002:set":Qa,"tag:yaml.org,2002:timestamp":ro};function co(e,t,n){let r=ao.get(t);if(r&&!e)return n&&!r.includes(Xi)?r.concat(Xi):r.slice();let i=r;if(!i)if(Array.isArray(e))i=[];else{let e=Array.from(ao.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(Xi)),i.reduce((e,t)=>{let n=typeof t==`string`?oo[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(oo).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}var lo=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,uo=class e{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:r,schema:i,sortMapEntries:a,toStringDefaults:o}){this.compat=Array.isArray(e)?co(e,`compat`):e?co(null,e):null,this.name=typeof i==`string`&&i||`core`,this.knownTags=r?so:{},this.tags=co(t,this.name,n),this.toStringOptions=o??null,Object.defineProperty(this,Br,{value:ua}),Object.defineProperty(this,Hr,{value:ma}),Object.defineProperty(this,Ur,{value:pa}),this.sortMapEntries=typeof a==`function`?a:a===!0?lo:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};function fo(e,t){let n=[],r=t.directives===!0;if(t.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(n.push(t),r=!0):e.directives.docStart&&(r=!0)}r&&n.push(`---`);let i=Ui(e,t),{commentString:a}=i.options;if(e.commentBefore){n.length!==1&&n.unshift(``);let t=a(e.commentBefore);n.unshift(Ei(t,``))}let o=!1,s=null;if(e.contents){if(Q(e.contents)){if(e.contents.spaceBefore&&r&&n.push(``),e.contents.commentBefore){let t=a(e.contents.commentBefore);n.push(Ei(t,``))}i.forceBlockIndent=!!e.comment,s=e.contents.comment}let t=s?void 0:()=>o=!0,c=Ki(e.contents,i,()=>s=null,t);s&&(c+=Di(c,``,a(s))),(c[0]===`|`||c[0]===`>`)&&n[n.length-1]===`---`?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(Ki(e.contents,i));if(e.directives?.docEnd)if(e.comment){let t=a(e.comment);t.includes(`
|
|
43
|
+
`)?(n.push(`...`),n.push(Ei(t,``))):n.push(`... ${t}`)}else n.push(`...`);else{let t=e.comment;t&&o&&(t=t.replace(/^\n+/,``)),t&&((!o||s)&&n[n.length-1]!==``&&n.push(``),n.push(Ei(a(t),``)))}return n.join(`
|
|
44
|
+
`)+`
|
|
45
|
+
`}var po=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Wr,{value:zr});let r=null;typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t,t=void 0);let 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:a}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new ci({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[Wr]:{value:zr}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=Q(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){mo(this.contents)&&this.contents.add(e)}addIn(e,t){mo(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=ui(this);e.anchor=!t||n.has(t)?di(t||`a`,n):t}return new gi(e.anchor)}createNode(e,t,n){let r;if(typeof t==`function`)e=t.call({"":e},``,e),r=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),r=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:a,flow:o,keepUndefined:s,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:d,sourceObjects:f}=fi(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=xi(e,l,p);return o&&Z(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new ra(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return mo(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Ci(e)?this.contents==null?!1:(this.contents=null,!0):mo(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Z(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return Ci(e)?!t&&X(this.contents)?this.contents.value:this.contents:Z(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Z(this.contents)?this.contents.has(e):!1}hasIn(e){return Ci(e)?this.contents!==void 0:Z(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=Si(this.schema,[e],t):mo(this.contents)&&this.contents.set(e,t)}setIn(e,t){Ci(e)?this.contents=t:this.contents==null?this.contents=Si(this.schema,Array.from(e),t):mo(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 ci({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 ci({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new uo(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:a}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},s=mi(this.contents,t??``,o);if(typeof i==`function`)for(let{count:e,res:t}of o.anchors.values())i(t,e);return typeof a==`function`?pi(a,{"":s},``,s):s}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return fo(this,e)}};function mo(e){if(Z(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var ho=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},go=class extends ho{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},_o=class extends ho{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}},vo=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
|
|
46
|
+
`),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};function yo(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:(!b||n!==`seq-item-ind`)&&(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}function bo(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
|
|
47
|
+
`))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(bo(t.key)||bo(t.value))return!0}return!1;default:return!0}}function xo(e,t,n){if(t?.type===`flow-collection`){let r=t.end[0];r.indent===e&&(r.source===`]`||r.source===`}`)&&bo(t)&&n(r,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}function So(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==`function`?r:(e,t)=>e===t||X(e)&&X(t)&&e.value===t.value;return t.some(e=>i(e.key,n))}var Co=`All mapping items must start at the same column`;function wo({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new(a?.nodeClass??la)(n.schema);n.atRoot&&=!1;let s=r.offset,c=null;for(let a of r.items){let{start:l,key:u,sep:d,value:f}=a,p=yo(l,{indicator:`explicit-key-ind`,next:u??d?.[0],offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0}),m=!p.found;if(m){if(u&&(u.type===`block-seq`?i(s,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in u&&u.indent!==r.indent&&i(s,`BAD_INDENT`,Co)),!p.anchor&&!p.tag&&!d){c=p.end,p.comment&&(o.comment?o.comment+=`
|
|
48
|
+
`+p.comment:o.comment=p.comment);continue}(p.newlineAfterProp||bo(u))&&i(u??l[l.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else p.found?.indent!==r.indent&&i(s,`BAD_INDENT`,Co);n.atKey=!0;let h=p.end,g=u?e(n,u,p,i):t(n,h,l,null,p,i);n.schema.compat&&xo(r.indent,u,i),n.atKey=!1,So(n,o.items,g)&&i(h,`DUPLICATE_KEY`,`Map keys must be unique`);let _=yo(d??[],{indicator:`map-value-ind`,next:f,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!u||u.type===`block-scalar`});if(s=_.end,_.found){m&&(f?.type===`block-map`&&!_.hasNewline&&i(s,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),n.options.strict&&p.start<_.found.offset-1024&&i(g.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let c=f?e(n,f,_,i):t(n,s,d,null,_,i);n.schema.compat&&xo(r.indent,f,i),s=c.range[2];let l=new ra(g,c);n.options.keepSourceTokens&&(l.srcToken=a),o.items.push(l)}else{m&&i(g.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),_.comment&&(g.comment?g.comment+=`
|
|
49
|
+
`+_.comment:g.comment=_.comment);let e=new ra(g);n.options.keepSourceTokens&&(e.srcToken=a),o.items.push(e)}}return c&&c<s&&i(c,`IMPOSSIBLE`,`Map comment with trailing content`),o.range=[r.offset,s,c??s],o}function To({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new(a?.nodeClass??da)(n.schema);n.atRoot&&=!1,n.atKey&&=!1;let s=r.offset,c=null;for(let{start:a,value:l}of r.items){let u=yo(a,{indicator:`seq-item-ind`,next:l,offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!u.found)if(u.anchor||u.tag||l)l?.type===`block-seq`?i(u.end,`BAD_INDENT`,`All sequence items must start at the same column`):i(s,`MISSING_CHAR`,`Sequence item without - indicator`);else{c=u.end,u.comment&&(o.comment=u.comment);continue}let d=l?e(n,l,u,i):t(n,u.end,a,null,u,i);n.schema.compat&&xo(r.indent,l,i),s=d.range[2],o.items.push(d)}return o.range=[r.offset,s,c??s],o}function Eo(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}var Do=`Block collections are not allowed within flow collections`,Oo=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function ko({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=r.start.source===`{`,s=o?`flow map`:`flow sequence`,c=new(a?.nodeClass??(o?la:da))(n.schema);c.flow=!0;let l=n.atRoot;l&&(n.atRoot=!1),n.atKey&&=!1;let u=r.offset+r.start.source.length;for(let a=0;a<r.items.length;++a){let l=r.items[a],{start:d,key:f,sep:p,value:m}=l,h=yo(d,{flow:s,indicator:`explicit-key-ind`,next:f??p?.[0],offset:u,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!h.found){if(!h.anchor&&!h.tag&&!p&&!m){a===0&&h.comma?i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`):a<r.items.length-1&&i(h.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${s}`),h.comment&&(c.comment?c.comment+=`
|
|
50
|
+
`+h.comment:c.comment=h.comment),u=h.end;continue}!o&&n.options.strict&&bo(f)&&i(f,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(a===0)h.comma&&i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`);else if(h.comma||i(h.start,`MISSING_CHAR`,`Missing , between ${s} items`),h.comment){let e=``;loop:for(let t of d)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let t=c.items[c.items.length-1];Y(t)&&(t=t.value??t.key),t.comment?t.comment+=`
|
|
51
|
+
`+e:t.comment=e,h.comment=h.comment.substring(e.length+1)}}if(!o&&!p&&!h.found){let r=m?e(n,m,h,i):t(n,h.end,p,null,h,i);c.items.push(r),u=r.range[2],Oo(m)&&i(r.range,`BLOCK_IN_FLOW`,Do)}else{n.atKey=!0;let a=h.end,g=f?e(n,f,h,i):t(n,a,d,null,h,i);Oo(f)&&i(g.range,`BLOCK_IN_FLOW`,Do),n.atKey=!1;let _=yo(p??[],{flow:s,indicator:`map-value-ind`,next:m,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(_.found){if(!o&&!h.found&&n.options.strict){if(p)for(let e of p){if(e===_.found)break;if(e.type===`newline`){i(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}h.start<_.found.offset-1024&&i(_.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else m&&(`source`in m&&m.source?.[0]===`:`?i(m,`MISSING_CHAR`,`Missing space after : in ${s}`):i(_.start,`MISSING_CHAR`,`Missing , or : between ${s} items`));let v=m?e(n,m,_,i):_.found?t(n,_.end,p,null,_,i):null;v?Oo(m)&&i(v.range,`BLOCK_IN_FLOW`,Do):_.comment&&(g.comment?g.comment+=`
|
|
52
|
+
`+_.comment:g.comment=_.comment);let y=new ra(g,v);if(n.options.keepSourceTokens&&(y.srcToken=l),o){let e=c;So(n,e.items,g)&&i(a,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(y)}else{let e=new la(n.schema);e.flow=!0,e.items.push(y);let t=(v??g).range;e.range=[g.range[0],t[1],t[2]],c.items.push(e)}u=v?v.range[2]:_.end}}let d=o?`}`:`]`,[f,...p]=r.end,m=u;if(f?.source===d)m=f.offset+f.source.length;else{let e=s[0].toUpperCase()+s.substring(1),t=l?`${e} must end with a ${d}`:`${e} in block collection must be sufficiently indented and end with a ${d}`;i(u,l?`MISSING_CHAR`:`BAD_INDENT`,t),f&&f.source.length!==1&&p.unshift(f)}if(p.length>0){let e=Eo(p,m,n.options.strict,i);e.comment&&(c.comment?c.comment+=`
|
|
53
|
+
`+e.comment:c.comment=e.comment),c.range=[r.offset,m,e.offset]}else c.range=[r.offset,m,m];return c}function Ao(e,t,n,r,i,a){let o=n.type===`block-map`?wo(e,t,n,r,a):n.type===`block-seq`?To(e,t,n,r,a):ko(e,t,n,r,a),s=o.constructor;return i===`!`||i===s.tagName?(o.tag=s.tagName,o):(i&&(o.tag=i),o)}function jo(e,t,n,r,i){let a=r.tag,o=a?t.directives.tagName(a.source,e=>i(a,`TAG_RESOLVE_FAILED`,e)):null;if(n.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=r,n=e&&a?e.offset>a.offset?e:a:e??a;n&&(!t||t.offset<n.offset)&&i(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let s=n.type===`block-map`?`map`:n.type===`block-seq`?`seq`:n.start.source===`{`?`map`:`seq`;if(!a||!o||o===`!`||o===la.tagName&&s===`map`||o===da.tagName&&s===`seq`)return Ao(e,t,n,i,o);let c=t.schema.tags.find(e=>e.tag===o&&e.collection===s);if(!c){let r=t.schema.knownTags[o];if(r?.collection===s)t.schema.tags.push(Object.assign({},r,{default:!1})),c=r;else return r?i(a,`BAD_COLLECTION_TYPE`,`${r.tag} used for ${s} collection, but expects ${r.collection??`scalar`}`,!0):i(a,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${o}`,!0),Ao(e,t,n,i,o)}let l=Ao(e,t,n,i,o,c),u=c.resolve?.(l,e=>i(a,`TAG_RESOLVE_FAILED`,e),t.options)??l,d=Q(u)?u:new $(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}function Mo(e,t,n){let r=t.offset,i=No(t,e.options.strict,n);if(!i)return{value:``,type:null,comment:``,range:[r,r,r]};let a=i.mode===`>`?$.BLOCK_FOLDED:$.BLOCK_LITERAL,o=t.source?Po(t.source):[],s=o.length;for(let e=o.length-1;e>=0;--e){let t=o[e][1];if(t===``||t===`\r`)s=e;else break}if(s===0){let e=i.chomp===`+`&&o.length>0?`
|
|
54
|
+
`.repeat(Math.max(1,o.length-1)):``,n=r+i.length;return t.source&&(n+=t.source.length),{value:e,type:a,comment:i.comment,range:[r,n,n]}}let c=t.indent+i.indent,l=t.offset+i.length,u=0;for(let t=0;t<s;++t){let[r,a]=o[t];if(a===``||a===`\r`)i.indent===0&&r.length>c&&(c=r.length);else{r.length<c&&n(l+r.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),i.indent===0&&(c=r.length),u=t,c===0&&!e.atRoot&&n(l,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}l+=r.length+a.length+1}for(let e=o.length-1;e>=s;--e)o[e][0].length>c&&(s=e+1);let d=``,f=``,p=!1;for(let e=0;e<u;++e)d+=o[e][0].slice(c)+`
|
|
55
|
+
`;for(let e=u;e<s;++e){let[t,r]=o[e];l+=t.length+r.length+1;let s=r[r.length-1]===`\r`;if(s&&(r=r.slice(0,-1)),r&&t.length<c){let e=`Block scalar lines must not be less indented than their ${i.indent?`explicit indentation indicator`:`first line`}`;n(l-r.length-(s?2:1),`BAD_INDENT`,e),t=``}a===$.BLOCK_LITERAL?(d+=f+t.slice(c)+r,f=`
|
|
56
|
+
`):t.length>c||r[0]===` `?(f===` `?f=`
|
|
57
|
+
`:!p&&f===`
|
|
58
|
+
`&&(f=`
|
|
59
|
+
|
|
60
|
+
`),d+=f+t.slice(c)+r,f=`
|
|
61
|
+
`,p=!0):r===``?f===`
|
|
62
|
+
`?d+=`
|
|
63
|
+
`:f=`
|
|
64
|
+
`:(d+=f+r,f=` `,p=!1)}switch(i.chomp){case`-`:break;case`+`:for(let e=s;e<o.length;++e)d+=`
|
|
65
|
+
`+o[e][0].slice(c);d[d.length-1]!==`
|
|
66
|
+
`&&(d+=`
|
|
67
|
+
`);break;default:d+=`
|
|
68
|
+
`}let m=r+i.length+t.source.length;return{value:d,type:a,comment:i.comment,range:[r,m,m]}}function No({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function Po(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}function Fo(e,t,n){let{offset:r,type:i,source:a,end:o}=e,s,c,l=(e,t,i)=>n(r+e,t,i);switch(i){case`scalar`:s=$.PLAIN,c=Io(a,l);break;case`single-quoted-scalar`:s=$.QUOTE_SINGLE,c=Lo(a,l);break;case`double-quoted-scalar`:s=$.QUOTE_DOUBLE,c=zo(a,l);break;default:return n(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${i}`),{value:``,type:null,comment:``,range:[r,r+a.length,r+a.length]}}let u=r+a.length,d=Eo(o,u,t,n);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function Io(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`;break}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),Ro(e)}function Lo(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),Ro(e.slice(1,-1)).replace(/''/g,`'`)}function Ro(e){let t,n;try{t=RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
69
|
+
`,`sy`),n=RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
70
|
+
`,`sy`)}catch{t=/(.*?)[ \t]*\r?\n/sy,n=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=t.exec(e);if(!r)return e;let i=r[1],a=` `,o=t.lastIndex;for(n.lastIndex=o;r=n.exec(e);)r[1]===``?a===`
|
|
71
|
+
`?i+=a:a=`
|
|
72
|
+
`:(i+=a+r[1],a=` `),o=n.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,r=s.exec(e),i+a+(r?.[1]??``)}function zo(e,t){let n=``;for(let r=1;r<e.length-1;++r){let i=e[r];if(!(i===`\r`&&e[r+1]===`
|
|
73
|
+
`))if(i===`
|
|
74
|
+
`){let{fold:t,offset:i}=Bo(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=Vo[i];if(a)n+=a;else if(i===`
|
|
75
|
+
`)for(i=e[r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`\r`&&e[r+1]===`
|
|
76
|
+
`)for(i=e[++r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`x`||i===`u`||i===`U`){let a={x:2,u:4,U:8}[i];n+=Ho(e,r+1,a,t),r+=a}else{let i=e.substr(r-1,2);t(r-1,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),n+=i}}else if(i===` `||i===` `){let t=r,a=e[r+1];for(;a===` `||a===` `;)a=e[++r+1];a!==`
|
|
77
|
+
`&&!(a===`\r`&&e[r+2]===`
|
|
78
|
+
`)&&(n+=r>t?e.slice(t,r+1):i)}else n+=i}return(e[e.length-1]!==`"`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing "quote`),n}function Bo(e,t){let n=``,r=e[t+1];for(;(r===` `||r===` `||r===`
|
|
79
|
+
`||r===`\r`)&&!(r===`\r`&&e[t+2]!==`
|
|
80
|
+
`);)r===`
|
|
81
|
+
`&&(n+=`
|
|
82
|
+
`),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}var Vo={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
|
|
83
|
+
`,r:`\r`,t:` `,v:`\v`,N:`
`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function Ho(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;if(isNaN(a)){let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}return String.fromCodePoint(a)}function Uo(e,t,n,r){let{value:i,type:a,comment:o,range:s}=t.type===`block-scalar`?Mo(e,t,r):Fo(t,e.options.strict,r),c=n?e.directives.tagName(n.source,e=>r(n,`TAG_RESOLVE_FAILED`,e)):null,l;l=e.options.stringKeys&&e.atKey?e.schema[Hr]:c?Wo(e.schema,i,c,n,r):t.type===`scalar`?Go(e,i,t,r):e.schema[Hr];let u;try{let a=l.resolve(i,e=>r(n??t,`TAG_RESOLVE_FAILED`,e),e.options);u=X(a)?a:new $(a)}catch(e){let a=e instanceof Error?e.message:String(e);r(n??t,`TAG_RESOLVE_FAILED`,a),u=new $(i)}return u.range=s,u.source=i,a&&(u.type=a),c&&(u.tag=c),l.format&&(u.format=l.format),o&&(u.comment=o),u}function Wo(e,t,n,r,i){if(n===`!`)return e[Hr];let a=[];for(let t of e.tags)if(!t.collection&&t.tag===n)if(t.default&&t.test)a.push(t);else return t;for(let e of a)if(e.test?.test(t))return e;let o=e.knownTags[n];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(r,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${n}`,n!==`tag:yaml.org,2002:str`),e[Hr])}function Go({atKey:e,directives:t,schema:n},r,i,a){let o=n.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(r))||n[Hr];if(n.compat){let e=n.compat.find(e=>e.default&&e.test?.test(r))??n[Hr];o.tag!==e.tag&&a(i,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${t.tagString(o.tag)} or ${t.tagString(e.tag)}`,!0)}return o}function Ko(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}var qo={composeNode:Jo,composeEmptyNode:Yo};function Jo(e,t,n,r){let i=e.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=n,l,u=!0;switch(t.type){case`alias`:l=Xo(e,t,r),(s||c)&&r(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:l=Uo(e,t,c,r),s&&(l.anchor=s.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:l=jo(qo,e,t,n,r),s&&(l.anchor=s.source.substring(1));break;default:r(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),l=Yo(e,t.offset,void 0,null,n,r),u=!1}return s&&l.anchor===``&&r(s,`BAD_ALIAS`,`Anchor cannot be an empty string`),i&&e.options.stringKeys&&(!X(l)||typeof l.value!=`string`||l.tag&&l.tag!==`tag:yaml.org,2002:str`)&&r(c??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),a&&(l.spaceBefore=!0),o&&(t.type===`scalar`&&t.source===``?l.comment=o:l.commentBefore=o),e.options.keepSourceTokens&&u&&(l.srcToken=t),l}function Yo(e,t,n,r,{spaceBefore:i,comment:a,anchor:o,tag:s,end:c},l){let u=Uo(e,{type:`scalar`,offset:Ko(t,n,r),indent:-1,source:``},s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===``&&l(o,`BAD_ALIAS`,`Anchor cannot be an empty string`)),i&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function Xo({options:e},{offset:t,source:n,end:r},i){let a=new gi(n.substring(1));a.source===``&&i(t,`BAD_ALIAS`,`Alias cannot be an empty string`),a.source.endsWith(`:`)&&i(t+n.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let o=t+n.length,s=Eo(r,o,e.strict,i);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}function Zo(e,t,{offset:n,start:r,value:i,end:a},o){let s=new po(void 0,Object.assign({_directives:t},e)),c={atKey:!1,atRoot:!0,directives:s.directives,options:s.options,schema:s.schema},l=yo(r,{indicator:`doc-start`,next:i??a?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});l.found&&(s.directives.docStart=!0,i&&(i.type===`block-map`||i.type===`block-seq`)&&!l.hasNewline&&o(l.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),s.contents=i?Jo(c,i,l,o):Yo(c,l.end,r,null,l,o);let u=s.contents.range[2],d=Eo(a,u,!1,o);return d.comment&&(s.comment=d.comment),s.range=[n,u,d.offset],s}function Qo(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function $o(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
|
|
84
|
+
|
|
85
|
+
`:`
|
|
86
|
+
`)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var es=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let i=Qo(e);r?this.warnings.push(new _o(i,t,n)):this.errors.push(new go(i,t,n))},this.directives=new ci({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=$o(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(Z(i)&&!i.flow&&i.items.length>0){let e=i.items[0];Y(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`: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:$o(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=Qo(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=Zo(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`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new go(Qo(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new go(Qo(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=Eo(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new go(Qo(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){let e=new po(void 0,Object.assign({_directives:this.directives},this.options));this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),e.range=[0,t,t],this.decorate(e,!1),yield e}}},ts=Symbol(`break visit`),ns=Symbol(`skip children`),rs=Symbol(`remove item`);function is(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),as(Object.freeze([]),e,t)}is.BREAK=ts,is.SKIP=ns,is.REMOVE=rs,is.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},is.parentCollection=(e,t)=>{let n=is.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function as(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=as(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===ts)return ts;else r===rs&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function os(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
|
|
87
|
+
`:case`\r
|
|
88
|
+
`: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(e[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 ss(e){switch(e){case void 0:case` `:case`
|
|
89
|
+
`:case`\r`:case` `:return!0;default:return!1}}var cs=new Set(`0123456789ABCDEFabcdef`),ls=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),us=new Set(`,[]{}`),ds=new Set(` ,[]{}
|
|
90
|
+
\r `),fs=e=>!e||ds.has(e),ps=class{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===`
|
|
91
|
+
`?!0:t===`\r`?this.buffer[e+1]===`
|
|
92
|
+
`:!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`){let t=this.buffer[n+e+1];if(t===`
|
|
93
|
+
`||!t&&!this.atEnd)return e+n+1}return t===`
|
|
94
|
+
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t===`-`||t===`.`){let t=this.buffer.substr(e,3);if((t===`---`||t===`...`)&&ss(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(`
|
|
95
|
+
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]===`\r`&&--e,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]===``&&(yield*this.pushCount(1),e=e.substring(1)),e[0]===`%`){let t=e.length,n=e.indexOf(`#`);for(;n!==-1;){let r=e[n-1];if(r===` `||r===` `){t=n-1;break}else n=e.indexOf(`#`,n+1)}for(;;){let n=e[t-1];if(n===` `||n===` `)--t;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),`stream`}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),`stream`}return yield``,yield*this.parseLineStart()}*parseLineStart(){let 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`);let e=this.peek(3);if((e===`---`||e===`...`)&&ss(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,e===`---`?`doc`:`stream`}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!ss(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext(`block-start`);if((e===`-`||e===`?`||e===`:`)&&ss(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,yield*this.parseBlockStart()}return`doc`}*parseDocument(){yield*this.pushSpaces(!0);let 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(fs),`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);let r=this.getLine();if(r===null)return this.setNext(`flow`);if((n!==-1&&n<this.indentNext&&r[0]!==`#`||n===0&&(r.startsWith(`---`)||r.startsWith(`...`))&&ss(r[3]))&&!(n===this.indentNext-1&&this.flowLevel===1&&(r[0]===`]`||r[0]===`}`)))return this.flowLevel=0,yield``,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,this.flowLevel?`flow`:`doc`;case`*`:return yield*this.pushUntil(fs),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||ss(e)||e===`,`)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),`flow`}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),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 e=0;for(;this.buffer[t-1-e]===`\\`;)e+=1;if(e%2==0)break;t=this.buffer.indexOf(`"`,t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
|
|
96
|
+
`,this.pos);if(r!==-1){for(;r!==-1;){let e=this.continueScalar(r+1);if(e===-1)break;r=n.indexOf(`
|
|
97
|
+
`,e)}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(;;){let 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(e=>ss(e)||e===`#`)}*parseBlockScalar(){let e=this.pos-1,t=0,n;loop:for(let r=this.pos;n=this.buffer[r];++r)switch(n){case` `:t+=1;break;case`
|
|
98
|
+
`:e=r,t=0;break;case`\r`:{let e=this.buffer[r+1];if(!e&&!this.atEnd)return this.setNext(`block-scalar`);if(e===`
|
|
99
|
+
`)break}default:break loop}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{let t=this.continueScalar(e+1);if(t===-1)break;e=this.buffer.indexOf(`
|
|
100
|
+
`,t)}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===`
|
|
101
|
+
`;)n=this.buffer[++r];e=r-1}else if(!this.blockScalarKeep)do{let n=e-1,r=this.buffer[n];r===`\r`&&(r=this.buffer[--n]);let i=n;for(;r===` `;)r=this.buffer[--n];if(r===`
|
|
102
|
+
`&&n>=this.pos&&n+1+t>i)e=n;else break}while(!0);return yield``,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,r;for(;r=this.buffer[++n];)if(r===`:`){let r=this.buffer[n+1];if(ss(r)||e&&us.has(r))break;t=n}else if(ss(r)){let i=this.buffer[n+1];if(r===`\r`&&(i===`
|
|
103
|
+
`?(n+=1,r=`
|
|
104
|
+
`,i=this.buffer[n+1]):t=n),i===`#`||e&&us.has(i))break;if(r===`
|
|
105
|
+
`){let e=this.continueScalar(n+1);if(e===-1)break;n=Math.max(n,e-2)}}else{if(e&&us.has(r))break;t=n}return!r&&!this.atEnd?this.setNext(`plain-scalar`):(yield``,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){let 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(fs))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case`-`:case`?`:case`:`:{let e=this.flowLevel>0,t=this.charAt(1);if(ss(t)||e&&us.has(t))return e?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(;!ss(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(ls.has(t))t=this.buffer[++e];else if(t===`%`&&cs.has(this.buffer[e+1])&&cs.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
|
|
106
|
+
`?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
|
|
107
|
+
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let 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)}},ms=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}};function hs(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function gs(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function _s(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function vs(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function ys(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function bs(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!hs(t.start,`explicit-key-ind`)&&!hs(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,_s(t.value)?t.value.end?Array.prototype.push.apply(t.value.end,t.sep):t.value.end=t.sep:Array.prototype.push.apply(t.start,t.sep),delete t.sep)}var xs=class{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 ps,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let 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}let t=os(e);if(!t){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else 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}}*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(){let 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){let 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{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&bs(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&gs(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.indent<t.indent))&&(e.type===`document`?e.end=n.start:e.items.push({start:n.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`:{let 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`:gs(e.start)===-1?e.start.push(this.sourceToken):(yield*this.pop(),yield*this.step());return;case`anchor`:case`tag`:case`space`:case`comment`:case`newline`:e.start.push(this.sourceToken);return}let 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`){let t=ys(vs(this.peek(2))),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let r={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}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 e=this.source.indexOf(`
|
|
108
|
+
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
109
|
+
`,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let 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)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[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(hs(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=ys(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(hs(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(_s(t.key)&&!hs(t.sep,`newline`)){let e=ys(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken);else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):hs(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`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!hs(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(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let 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)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.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||hs(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.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`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=ys(vs(t));bs(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let 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)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
|
|
110
|
+
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
111
|
+
`,e)+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;let t=ys(vs(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=ys(vs(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.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 Ss(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new ms||null,prettyErrors:t}}function Cs(e,t={}){let{lineCounter:n,prettyErrors:r}=Ss(t),i=new xs(n?.addNewLine),a=new es(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new go(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(vo(e,n)),o.warnings.forEach(vo(e,n))),o}function ws(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=Cs(e,n);if(!i)return null;if(i.warnings.forEach(e=>Ji(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}function Ts(e,t,n){let r=null;if(typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t),typeof n==`string`&&(n=n.length),typeof n==`number`){let e=Math.round(n);n=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=n??t??{};if(!e)return}return Kr(e)&&!r?e.toString(n):new po(e,r,n).toString(n)}function Es({config:e,pluginKeys:t,onSave:n,saving:r}){let i=o(()=>{let n=new Set(t);return n.add(`plugins`),Object.keys(e).filter(e=>!n.has(e))},[e,t]),[s,l]=c({}),[u,d]=c(!1);a(()=>{let t={};for(let n of i)t[n]=e[n];l(t),d(!1)},[e,i]);let f=(e,t)=>{l(n=>({...n,[e]:t})),d(!0)};return i.length===0?z(U,{children:B(W,{className:`flex flex-col items-center gap-3 py-12`,children:[z(`div`,{className:`flex items-center justify-center w-16 h-16 rounded-full bg-muted`,children:z(Ie,{className:`w-8 h-8 text-muted-foreground`})}),z(`h3`,{className:`text-lg font-semibold`,children:`暂无通用配置`}),z(`p`,{className:`text-sm text-muted-foreground`,children:`配置文件中未发现可编辑的通用字段`})]})}):B(`div`,{className:`space-y-4`,children:[z(`div`,{className:`space-y-3`,children:i.map(e=>z(Ds,{fieldKey:e,value:s[e],onChange:t=>f(e,t)},e))}),B(`div`,{className:`flex items-center gap-2 pt-2`,children:[z(V,{size:`sm`,onClick:async()=>{await n(s),d(!1)},disabled:r||!u,children:r?B(R,{children:[z(P,{className:`w-4 h-4 mr-1 animate-spin`}),`保存中...`]}):B(R,{children:[z(Me,{className:`w-4 h-4 mr-1`}),`保存`]})}),u&&B(V,{variant:`outline`,size:`sm`,onClick:()=>{let t={};for(let n of i)t[n]=e[n];l(t),d(!1)},children:[z(et,{className:`w-4 h-4 mr-1`}),`撤销`]}),u&&z(`span`,{className:`text-xs text-muted-foreground`,children:`有未保存的更改`})]})]})}function Ds({fieldKey:e,value:t,onChange:n}){let r=typeof t;if(t==null)return B(`div`,{className:`p-3 rounded-lg bg-muted/50 border space-y-1.5`,children:[B(`div`,{className:`flex items-center gap-1.5`,children:[z(`span`,{className:`text-sm font-medium`,children:e}),z(G,{variant:`outline`,className:`text-[10px] px-1 py-0`,children:`null`})]}),z(H,{value:``,placeholder:`(空值)`,onChange:e=>n(e.target.value||null),className:`h-8 text-sm`})]});if(r===`boolean`)return z(`div`,{className:`p-3 rounded-lg bg-muted/50 border space-y-1.5`,children:B(`div`,{className:`flex items-center justify-between`,children:[B(`div`,{className:`flex items-center gap-1.5`,children:[z(`span`,{className:`text-sm font-medium`,children:e}),z(G,{variant:`outline`,className:`text-[10px] px-1 py-0`,children:`boolean`})]}),z(`button`,{type:`button`,onClick:()=>n(!t),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${t?`bg-primary`:`bg-muted-foreground/30`}`,children:z(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform ${t?`translate-x-4.5`:`translate-x-0.5`}`})})]})});if(r===`number`)return B(`div`,{className:`p-3 rounded-lg bg-muted/50 border space-y-1.5`,children:[B(`div`,{className:`flex items-center gap-1.5`,children:[z(`span`,{className:`text-sm font-medium`,children:e}),z(G,{variant:`outline`,className:`text-[10px] px-1 py-0`,children:`number`})]}),z(H,{type:`number`,value:t,onChange:e=>n(Number(e.target.value)),className:`h-8 text-sm`})]});if(r===`string`){let r=t.includes(`
|
|
112
|
+
`)||t.length>80;return B(`div`,{className:`p-3 rounded-lg bg-muted/50 border space-y-1.5`,children:[B(`div`,{className:`flex items-center gap-1.5`,children:[z(`span`,{className:`text-sm font-medium`,children:e}),z(G,{variant:`outline`,className:`text-[10px] px-1 py-0`,children:`string`})]}),r?z(Bn,{value:t,onChange:e=>n(e.target.value),className:`text-sm font-mono min-h-[80px]`}):z(H,{value:t,onChange:e=>n(e.target.value),className:`h-8 text-sm`})]})}return Array.isArray(t)?B(`div`,{className:`p-3 rounded-lg bg-muted/50 border space-y-1.5`,children:[B(`div`,{className:`flex items-center gap-1.5`,children:[z(`span`,{className:`text-sm font-medium`,children:e}),B(G,{variant:`outline`,className:`text-[10px] px-1 py-0`,children:[`array[`,t.length,`]`]})]}),z(Bn,{value:Ts(t).trim(),onChange:e=>{try{let t=ws(e.target.value);Array.isArray(t)&&n(t)}catch{}},className:`text-sm font-mono min-h-[80px]`})]}):r===`object`?B(`div`,{className:`p-3 rounded-lg bg-muted/50 border space-y-1.5`,children:[B(`div`,{className:`flex items-center gap-1.5`,children:[z(`span`,{className:`text-sm font-medium`,children:e}),z(G,{variant:`outline`,className:`text-[10px] px-1 py-0`,children:`object`})]}),z(Bn,{value:Ts(t).trim(),onChange:e=>{try{let t=ws(e.target.value);t&&typeof t==`object`&&!Array.isArray(t)&&n(t)}catch{}},className:`text-sm font-mono min-h-[100px]`})]}):B(`div`,{className:`p-3 rounded-lg bg-muted/50 border space-y-1.5`,children:[B(`div`,{className:`flex items-center gap-1.5`,children:[z(`span`,{className:`text-sm font-medium`,children:e}),z(G,{variant:`outline`,className:`text-[10px] px-1 py-0`,children:r})]}),z(H,{value:String(t),onChange:e=>n(e.target.value),className:`h-8 text-sm`})]})}function Os(){let{yaml:e,pluginKeys:t,loading:n,error:r,load:s,save:l}=ht(),[u,f]=c(`form`),[p,m]=c(``),[h,g]=c(!1),[_,v]=c(!1),[y,b]=c(null);a(()=>{e&&(m(e),g(!1))},[e]);let S=o(()=>{try{return ws(e)||{}}catch{return{}}},[e]),C=i((e,t)=>{b({type:e,text:t}),setTimeout(()=>b(null),3e3)},[]);return n&&!e?B(`div`,{className:`space-y-4`,children:[z(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`配置管理`}),B(`div`,{className:`flex items-center justify-center py-12`,children:[z(P,{className:`w-6 h-6 animate-spin text-muted-foreground`}),z(`span`,{className:`ml-2 text-sm text-muted-foreground`,children:`加载配置中...`})]})]}):B(`div`,{className:`space-y-4`,children:[B(`div`,{className:`flex items-center justify-between`,children:[B(`div`,{children:[z(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`配置管理`}),z(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`管理 zhin.config.yml 中的通用配置项(不含插件配置)`})]}),z(`div`,{className:`flex items-center gap-2`,children:B(V,{variant:`outline`,size:`sm`,onClick:async()=>{try{await s(),C(`success`,`已刷新`)}catch{C(`error`,`刷新失败`)}},disabled:n,children:[z(I,{className:`w-4 h-4 mr-1 ${n?`animate-spin`:``}`}),`刷新`]})})]}),y&&B(K,{variant:y.type===`error`?`destructive`:`success`,className:`py-2`,children:[y.type===`error`?z(d,{className:`h-4 w-4`}):z(x,{className:`h-4 w-4`}),z(q,{children:y.text})]}),r&&!y&&B(K,{variant:`destructive`,className:`py-2`,children:[z(d,{className:`h-4 w-4`}),z(q,{children:r})]}),B(Cr,{value:u,onValueChange:e=>f(e),children:[B(wr,{children:[B(Tr,{value:`form`,className:`gap-1.5`,children:[z(se,{className:`w-4 h-4`}),`表单模式`]}),B(Tr,{value:`yaml`,className:`gap-1.5`,children:[z(re,{className:`w-4 h-4`}),`YAML 模式`]})]}),z(Er,{value:`form`,children:z(Es,{config:S,pluginKeys:t,onSave:async t=>{v(!0);try{await l(Ts({...ws(e)||{},...t},{lineWidth:0})),C(`success`,`配置已保存,需重启生效`)}catch(e){C(`error`,`保存失败: ${e instanceof Error?e.message:`未知错误`}`)}finally{v(!1)}},saving:_})}),z(Er,{value:`yaml`,children:B(`div`,{className:`space-y-3`,children:[z(`div`,{className:`relative`,children:z(Bn,{value:p,onChange:e=>{m(e.target.value),g(!0)},className:`font-mono text-sm min-h-[400px] resize-y`,placeholder:`# zhin.config.yml`,spellCheck:!1})}),B(`div`,{className:`flex items-center gap-2`,children:[z(V,{size:`sm`,onClick:async()=>{v(!0);try{await l(p),g(!1),C(`success`,`配置已保存,需重启生效`)}catch(e){C(`error`,`保存失败: ${e instanceof Error?e.message:`未知错误`}`)}finally{v(!1)}},disabled:_||!h,children:_?B(R,{children:[z(P,{className:`w-4 h-4 mr-1 animate-spin`}),`保存中...`]}):B(R,{children:[z(Me,{className:`w-4 h-4 mr-1`}),`保存`]})}),h&&B(V,{variant:`outline`,size:`sm`,onClick:()=>{m(e),g(!1)},children:[z(et,{className:`w-4 h-4 mr-1`}),`撤销`]}),h&&z(`span`,{className:`text-xs text-muted-foreground`,children:`有未保存的更改`})]})]})})]})]})}var ks=/^(.*(?:PASSWORD|SECRET|TOKEN|KEY|PRIVATE|CREDENTIAL).*?=\s*)(.+)$/gim;function As(e){return e.replace(ks,(e,t,n)=>{if(n.startsWith("${")||n.trim()===``)return t+n;let r=n.length>4?n.slice(0,2):``;return t+r+`●`.repeat(Math.min(n.length-r.length,20))})}function js({filename:e,getFile:t,saveFile:n,exists:r}){let[o,s]=c(``),[l,u]=c(``),[f,p]=c(!1),[m,h]=c(!1),[g,_]=c(!0),[v,y]=c(null),[b,S]=c(!1),C=i(async()=>{p(!0);try{let n=await t(e);s(n),u(n),S(!0)}catch(e){y({type:`error`,text:`加载失败: ${e instanceof Error?e.message:`未知错误`}`})}finally{p(!1)}},[e,t]);a(()=>{C()},[C]);let w=async()=>{h(!0),y(null);try{await n(e,o),u(o),y({type:`success`,text:`已保存,需重启生效`}),setTimeout(()=>y(null),3e3)}catch(e){y({type:`error`,text:`保存失败: ${e instanceof Error?e.message:`未知错误`}`})}finally{h(!1)}},T=o!==l,E=g&&!T?As(o):o;return f&&!b?B(`div`,{className:`flex items-center justify-center py-8`,children:[z(P,{className:`w-5 h-5 animate-spin text-muted-foreground`}),z(`span`,{className:`ml-2 text-sm text-muted-foreground`,children:`加载中...`})]}):B(`div`,{className:`space-y-3`,children:[!r&&!T&&B(K,{className:`py-2 border-yellow-500/50 text-yellow-700 dark:text-yellow-400`,children:[z(ae,{className:`h-4 w-4`}),z(q,{children:`文件不存在,保存后将自动创建`})]}),v&&B(K,{variant:v.type===`error`?`destructive`:`success`,className:`py-2`,children:[v.type===`error`?z(d,{className:`h-4 w-4`}):z(x,{className:`h-4 w-4`}),z(q,{children:v.text})]}),z(`div`,{className:`relative`,children:z(Bn,{value:E,onChange:e=>{s(e.target.value),_(!1)},onFocus:()=>_(!1),className:`font-mono text-sm min-h-[350px] resize-y`,placeholder:`KEY=VALUE`,spellCheck:!1})}),B(`div`,{className:`flex items-center gap-2`,children:[z(V,{size:`sm`,onClick:w,disabled:m||!T,children:m?B(R,{children:[z(P,{className:`w-4 h-4 mr-1 animate-spin`}),`保存中...`]}):B(R,{children:[z(Me,{className:`w-4 h-4 mr-1`}),`保存`]})}),T&&z(V,{variant:`outline`,size:`sm`,onClick:()=>{s(l),_(!0)},children:`撤销`}),z(V,{variant:`ghost`,size:`sm`,onClick:()=>_(e=>!e),disabled:T,title:g?`显示敏感值`:`隐藏敏感值`,children:z(g?j:M,{className:`w-4 h-4`})}),T&&z(`span`,{className:`text-xs text-muted-foreground`,children:`有未保存的更改`})]})]})}function Ms(){let{files:e,loading:t,error:n,listFiles:r,getFile:i,saveFile:a}=vt(),[o,s]=c(`.env`);return t&&e.length===0?B(`div`,{className:`space-y-6`,children:[z(Ir,{title:`环境变量`,description:`加载文件列表…`}),B(`div`,{className:`flex items-center justify-center py-12 rounded-lg border border-dashed`,children:[z(P,{className:`w-6 h-6 animate-spin text-muted-foreground`}),z(`span`,{className:`ml-2 text-sm text-muted-foreground`,children:`加载中...`})]})]}):B(`div`,{className:`space-y-6`,children:[z(Ir,{title:`环境变量`,description:`管理 .env / .env.* 中的键值;含 PASSWORD、TOKEN、SECRET 等关键字的行可在未编辑时自动遮罩显示。保存后需重启进程生效。`,actions:B(V,{variant:`outline`,size:`sm`,onClick:async()=>{try{await r()}catch{}},disabled:t,children:[z(I,{className:`w-4 h-4 mr-1 ${t?`animate-spin`:``}`}),`刷新`]})}),n&&B(K,{variant:`destructive`,className:`py-2`,children:[z(d,{className:`h-4 w-4`}),z(q,{children:n})]}),B(Cr,{value:o,onValueChange:s,className:`space-y-4`,children:[z(wr,{className:`w-full justify-start flex-wrap h-auto gap-1 bg-muted/40 p-1`,children:[`.env`,`.env.development`,`.env.production`].map(t=>{let n=e.find(e=>e.name===t);return B(Tr,{value:t,className:`gap-1.5 data-[state=active]:shadow-sm`,children:[z(he,{className:`w-3.5 h-3.5`}),t,n&&!n.exists&&z(G,{variant:`outline`,className:`text-[10px] px-1 py-0 ml-1`,children:`新`})]},t)})}),[`.env`,`.env.development`,`.env.production`].map(t=>z(Er,{value:t,className:`mt-0`,children:B(U,{className:`border-border/80 shadow-sm`,children:[B(bn,{className:`pb-2`,children:[z(xn,{className:`text-base font-semibold`,children:t}),B(Sn,{children:[`键值对一行一条,格式 `,z(`code`,{className:`rounded bg-muted px-1 py-0.5 text-xs`,children:`KEY=VALUE`}),`;编辑时始终显示真实内容,保存前请确认环境安全。`]})]}),z(W,{children:z(js,{filename:t,getFile:i,saveFile:a,exists:e.find(e=>e.name===t)?.exists??!1})})]})},t))]})]})}var Ns=`https://cdn.jsdelivr.net.cn/npm/@highlightjs/cdn-assets@11/styles`,Ps={fontFamily:`ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace`,fontSize:`13px`,lineHeight:`20px`,tabSize:2,whiteSpace:`pre`};function Fs(){a(()=>{let e=`hljs-theme-css`,t=document.getElementById(e);t||(t=document.createElement(`link`),t.id=e,t.rel=`stylesheet`,document.head.appendChild(t));let n=()=>{let e=document.documentElement.classList.contains(`dark`);t.href=`${Ns}/${e?`github-dark`:`github`}.min.css`};n();let r=new MutationObserver(n);return r.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>r.disconnect()},[])}function Is(e){switch(e.split(`.`).pop()?.toLowerCase()){case`ts`:case`tsx`:return z(re,{className:`w-4 h-4 text-blue-500`});case`js`:case`jsx`:return z(re,{className:`w-4 h-4 text-yellow-500`});case`json`:return z(N,{className:`w-4 h-4 text-green-500`});case`yml`:case`yaml`:return z(N,{className:`w-4 h-4 text-red-400`});case`md`:return z(N,{className:`w-4 h-4 text-gray-400`});case`env`:return z(N,{className:`w-4 h-4 text-orange-500`});default:return e.startsWith(`.env`)?z(N,{className:`w-4 h-4 text-orange-500`}):z(N,{className:`w-4 h-4 text-muted-foreground`})}}function Ls({node:e,selectedPath:t,onSelect:n,depth:r=0}){let[i,a]=c(r<1),o=e.path===t,s=e.type===`directory`;return B(`div`,{children:[B(`button`,{className:`
|
|
113
|
+
w-full flex items-center gap-1.5 px-2 py-1 text-sm rounded-sm text-left
|
|
114
|
+
hover:bg-accent transition-colors
|
|
115
|
+
${o?`bg-accent text-accent-foreground font-medium`:``}
|
|
116
|
+
`,style:{paddingLeft:`${r*16+8}px`},onClick:()=>{s?a(!i):n(e.path)},children:[s?z(i?S:w,{className:`w-3.5 h-3.5 shrink-0 text-muted-foreground`}):z(`span`,{className:`w-3.5`}),s?z(oe,{className:`w-4 h-4 shrink-0 text-amber-500`}):Is(e.name),z(`span`,{className:`truncate`,children:e.name})]}),s&&i&&e.children&&z(`div`,{children:e.children.map(e=>z(Ls,{node:e,selectedPath:t,onSelect:n,depth:r+1},e.path))})]})}function Rs({value:e,onChange:t,language:n}){let r=s(null),a=s(null),c=o(()=>{if(window.hljs&&n&&window.hljs.getLanguage(n))try{return window.hljs.highlight(e,{language:n}).value}catch{}return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)},[e,n]),l=i(()=>{a.current&&r.current&&(a.current.scrollTop=r.current.scrollTop,a.current.scrollLeft=r.current.scrollLeft)},[]),u=i(n=>{if(n.key===`Tab`){n.preventDefault();let r=n.currentTarget,i=r.selectionStart,a=r.selectionEnd;t(e.substring(0,i)+` `+e.substring(a)),requestAnimationFrame(()=>{r.selectionStart=r.selectionEnd=i+2})}},[e,t]);return B(`div`,{className:`relative h-full w-full overflow-hidden`,children:[z(`pre`,{ref:a,className:`absolute inset-0 m-0 p-4 overflow-auto pointer-events-none`,style:Ps,"aria-hidden":!0,children:z(`code`,{className:n?`hljs language-${n}`:``,dangerouslySetInnerHTML:{__html:c+`
|
|
117
|
+
`},style:{background:`transparent`,padding:0,display:`block`}})}),z(`textarea`,{ref:r,value:e,onChange:e=>t(e.target.value),onScroll:l,onKeyDown:u,wrap:`off`,className:`absolute inset-0 w-full h-full resize-none p-4 bg-transparent outline-none border-0`,style:{...Ps,color:`transparent`,caretColor:`hsl(var(--foreground))`,WebkitTextFillColor:`transparent`},spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`})]})}function zs(e){let t=e.split(`/`).pop()?.toLowerCase()||``;if(t===`.env`||t.startsWith(`.env.`))return`ini`;switch(t.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 Bs({filePath:e,readFile:t,saveFile:n,onClose:r}){let[o,s]=c(``),[l,u]=c(``),[f,p]=c(!0),[m,h]=c(!1),[g,_]=c(null),v=i(async()=>{p(!0),_(null);try{let n=await t(e);s(n),u(n)}catch(e){_({type:`error`,text:`加载失败: ${e instanceof Error?e.message:`未知错误`}`})}finally{p(!1)}},[e,t]);a(()=>{v()},[v]);let y=i(async()=>{h(!0),_(null);try{await n(e,o),u(o),_({type:`success`,text:`已保存`}),setTimeout(()=>_(null),3e3)}catch(e){_({type:`error`,text:`保存失败: ${e instanceof Error?e.message:`未知错误`}`})}finally{h(!1)}},[e,o,n]),b=o!==l;a(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),b&&!m&&y())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[b,m,y]);let S=e.split(`/`).pop()||e;return f?B(`div`,{className:`flex items-center justify-center h-full`,children:[z(P,{className:`w-5 h-5 animate-spin text-muted-foreground`}),z(`span`,{className:`ml-2 text-sm text-muted-foreground`,children:`加载中...`})]}):B(`div`,{className:`flex flex-col h-full`,children:[B(`div`,{className:`flex items-center justify-between px-4 py-2 border-b bg-muted/30`,children:[B(`div`,{className:`flex items-center gap-2`,children:[Is(S),z(`span`,{className:`text-sm font-medium`,children:e}),b&&z(G,{variant:`secondary`,className:`text-[10px] px-1.5 py-0`,children:`未保存`})]}),z(`div`,{className:`flex items-center gap-1`,children:z(V,{size:`sm`,variant:`ghost`,onClick:r,title:`关闭`,children:z(et,{className:`w-4 h-4`})})})]}),g&&B(K,{variant:g.type===`error`?`destructive`:`success`,className:`mx-4 mt-2 py-2`,children:[g.type===`error`?z(d,{className:`h-4 w-4`}):z(x,{className:`h-4 w-4`}),z(q,{children:g.text})]}),z(`div`,{className:`flex-1 min-h-0`,children:z(Rs,{value:o,onChange:s,language:zs(S)})}),B(`div`,{className:`flex items-center gap-2 px-4 py-2 border-t bg-muted/30`,children:[z(V,{size:`sm`,onClick:()=>void y(),disabled:m||!b,children:m?B(R,{children:[z(P,{className:`w-4 h-4 mr-1 animate-spin`}),`保存中...`]}):B(R,{children:[z(Me,{className:`w-4 h-4 mr-1`}),`保存`]})}),b&&z(V,{variant:`outline`,size:`sm`,onClick:()=>s(l),children:`撤销更改`}),B(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:[o.split(`
|
|
118
|
+
`).length,` 行 · Ctrl+S 保存`]})]})]})}function Vs(){Fs();let{tree:e,loading:t,error:n,loadTree:r,readFile:i,saveFile:a}=yt(),[o,s]=c(null);return B(`div`,{className:`space-y-4`,children:[B(`div`,{className:`flex items-center justify-between`,children:[B(`div`,{children:[z(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`文件管理`}),z(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`浏览和编辑工作空间中的配置文件和源代码`})]}),B(V,{variant:`outline`,size:`sm`,onClick:()=>r(),disabled:t,children:[z(I,{className:`w-4 h-4 mr-1 ${t?`animate-spin`:``}`}),`刷新`]})]}),n&&B(K,{variant:`destructive`,className:`py-2`,children:[z(d,{className:`h-4 w-4`}),z(q,{children:n})]}),z(U,{className:`overflow-hidden`,children:z(W,{className:`p-0`,children:B(`div`,{className:`flex`,style:{height:`600px`},children:[B(`div`,{className:`w-64 border-r flex flex-col shrink-0`,children:[z(`div`,{className:`px-3 py-2 border-b bg-muted/30`,children:z(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:`文件浏览器`})}),z(sn,{className:`flex-1`,children:z(`div`,{className:`py-1`,children:t&&e.length===0?z(`div`,{className:`flex items-center justify-center py-8`,children:z(P,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):e.length===0?z(`p`,{className:`text-sm text-muted-foreground text-center py-8`,children:`暂无文件`}):e.map(e=>z(Ls,{node:e,selectedPath:o,onSelect:s},e.path))})})]}),z(`div`,{className:`flex-1 min-w-0`,children:o?z(Bs,{filePath:o,readFile:i,saveFile:a,onClose:()=>s(null)},o):z(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:B(`div`,{className:`text-center`,children:[z(oe,{className:`w-12 h-12 mx-auto mb-3 opacity-30`}),z(`p`,{className:`text-sm`,children:`在左侧选择一个文件开始编辑`}),z(`p`,{className:`text-xs mt-1 opacity-60`,children:`支持 .env、src/、package.json 等关键文件`})]})})})]})})})]})}var Hs={related:`关系型`,document:`文档型`,keyvalue:`键值型`},Us={sqlite:`SQLite`,mysql:`MySQL`,pg:`PostgreSQL`,memory:`Memory`,mongodb:`MongoDB`,redis:`Redis`};function Ws({label:e,value:t,onChange:n}){return B(`div`,{className:`space-y-1`,children:[z(`label`,{className:`text-xs font-medium text-muted-foreground`,children:e}),z(H,{value:t,onChange:e=>n(e.target.value),className:`font-mono text-xs`})]})}function Gs({tableName:e,tableInfo:t,select:n,insert:r,update:s,remove:l}){let[u,f]=c(null),[p,m]=c(!1),[h,g]=c(1),[_,v]=c(null),[y,b]=c(null),[S,T]=c(!1),[E,D]=c({}),O=i(async()=>{m(!0),v(null);try{f(await n(e,h,50))}catch(e){v({type:`error`,text:e.message})}finally{m(!1)}},[e,h,n]);a(()=>{O()},[O]);let k=o(()=>t?.columns?Object.keys(t.columns):u?.rows?.length?Object.keys(u.rows[0]):[],[t,u]),ee=o(()=>{if(!t?.columns)return k[0]||`id`;let e=Object.entries(t.columns).find(([,e])=>e.primary);return e?e[0]:k[0]||`id`},[t,k]),te=async t=>{try{let n={};for(let e of k){let t=E[e];if(!(t===void 0||t===``))try{n[e]=JSON.parse(t)}catch{n[e]=t}}t?await r(e,n):await s(e,n,{[ee]:y[ee]}),v({type:`success`,text:t?`添加成功`:`更新成功`}),b(null),T(!1),D({}),setTimeout(()=>v(null),2e3),await O()}catch(e){v({type:`error`,text:e.message})}},ne=async t=>{if(confirm(`确定要删除这条记录吗?`))try{await l(e,{[ee]:t[ee]}),v({type:`success`,text:`删除成功`}),setTimeout(()=>v(null),2e3),await O()}catch(e){v({type:`error`,text:e.message})}},A=e=>{b(e),T(!1);let t={};for(let n of k)t[n]=typeof e[n]==`object`?JSON.stringify(e[n]):String(e[n]??``);D(t)},j=()=>{b(null),T(!0);let e={};for(let t of k)e[t]=``;D(e)},M=u?Math.ceil(u.total/50):0;return B(`div`,{className:`space-y-3`,children:[_&&B(K,{variant:_.type===`error`?`destructive`:`success`,className:`py-2`,children:[_.type===`error`?z(d,{className:`h-4 w-4`}):z(x,{className:`h-4 w-4`}),z(q,{children:_.text})]}),B(`div`,{className:`flex items-center gap-2`,children:[B(V,{size:`sm`,variant:`outline`,onClick:O,disabled:p,children:[z(I,{className:`w-3.5 h-3.5 mr-1 ${p?`animate-spin`:``}`}),`刷新`]}),B(V,{size:`sm`,onClick:j,children:[z(Ae,{className:`w-3.5 h-3.5 mr-1`}),`添加`]}),B(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:[`共 `,u?.total??0,` 条 · 第 `,h,`/`,M||1,` 页`]})]}),z(`div`,{className:`border rounded-md max-h-[min(70vh,720px)] overflow-auto overscroll-contain scroll-smooth touch-pan-x touch-pan-y bg-card`,role:`region`,"aria-label":`数据表,可左右滑动查看宽表`,children:B(`table`,{className:`text-sm border-collapse min-w-full w-max`,children:[z(`thead`,{className:`sticky top-0 z-10 bg-muted/95 backdrop-blur-sm shadow-sm`,children:B(`tr`,{className:`border-b`,children:[k.map(e=>z(`th`,{className:`px-3 py-2 text-left font-medium text-muted-foreground whitespace-nowrap border-b border-border/80`,children:e},e)),z(`th`,{className:`px-3 py-2 text-right font-medium text-muted-foreground whitespace-nowrap border-b border-border/80 w-24 min-w-[5.5rem]`,children:`操作`})]})}),z(`tbody`,{children:p&&!u?z(`tr`,{children:z(`td`,{colSpan:k.length+1,className:`text-center py-8`,children:z(P,{className:`w-4 h-4 animate-spin inline-block`})})}):u?.rows?.length?u.rows.map((e,t)=>B(`tr`,{className:`border-b border-border/60 hover:bg-muted/30 transition-colors`,children:[k.map(t=>z(`td`,{className:`px-3 py-1.5 font-mono text-xs whitespace-nowrap align-top`,title:typeof e[t]==`object`?JSON.stringify(e[t]):String(e[t]??``),children:typeof e[t]==`object`?JSON.stringify(e[t]):String(e[t]??``)},t)),B(`td`,{className:`px-3 py-1.5 text-right space-x-1 whitespace-nowrap w-24 min-w-[5.5rem]`,children:[z(V,{size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0`,onClick:()=>A(e),children:z(De,{className:`w-3 h-3`})}),z(V,{size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 text-destructive`,onClick:()=>ne(e),children:z(We,{className:`w-3 h-3`})})]})]},t)):z(`tr`,{children:z(`td`,{colSpan:k.length+1,className:`text-center py-8 text-muted-foreground`,children:`暂无数据`})})})]})}),M>1&&B(`div`,{className:`flex items-center justify-center gap-2`,children:[z(V,{size:`sm`,variant:`outline`,disabled:h<=1,onClick:()=>g(e=>e-1),children:z(C,{className:`w-4 h-4`})}),B(`span`,{className:`text-xs text-muted-foreground`,children:[h,` / `,M]}),z(V,{size:`sm`,variant:`outline`,disabled:h>=M,onClick:()=>g(e=>e+1),children:z(w,{className:`w-4 h-4`})})]}),z(Dn,{open:y!==null||S,onOpenChange:e=>{e||(b(null),T(!1))},children:B(jn,{className:`max-w-md max-h-[80vh] overflow-y-auto`,children:[z(Mn,{children:z(Pn,{children:S?`添加记录`:`编辑记录`})}),z(`div`,{className:`space-y-3 py-2`,children:k.map(e=>z(Ws,{label:e,value:E[e]??``,onChange:t=>D(n=>({...n,[e]:t}))},e))}),B(Nn,{children:[z(kn,{asChild:!0,children:z(V,{variant:`outline`,size:`sm`,children:`取消`})}),B(V,{size:`sm`,onClick:()=>te(S),children:[z(Me,{className:`w-3.5 h-3.5 mr-1`}),`保存`]})]})]})})]})}function Ks({tableName:e,select:t,insert:n,update:r,remove:o}){let[s,l]=c(null),[u,f]=c(!1),[p,m]=c(1),[h,g]=c(null),[_,v]=c(null),[y,b]=c(!1),[S,T]=c(``),E=i(async()=>{f(!0),g(null);try{l(await t(e,p,20))}catch(e){g({type:`error`,text:e.message})}finally{f(!1)}},[e,p,t]);a(()=>{E()},[E]);let D=async t=>{try{let i=JSON.parse(S);if(t)await n(e,i);else{let{_id:t,...n}=i;await r(e,n,{_id:_._id})}g({type:`success`,text:t?`添加成功`:`更新成功`}),v(null),b(!1),T(``),setTimeout(()=>g(null),2e3),await E()}catch(e){g({type:`error`,text:e.message})}},O=async t=>{if(confirm(`确定要删除这条文档吗?`))try{await o(e,{_id:t._id}),g({type:`success`,text:`删除成功`}),setTimeout(()=>g(null),2e3),await E()}catch(e){g({type:`error`,text:e.message})}},k=s?Math.ceil(s.total/20):0;return B(`div`,{className:`space-y-3`,children:[h&&B(K,{variant:h.type===`error`?`destructive`:`success`,className:`py-2`,children:[h.type===`error`?z(d,{className:`h-4 w-4`}):z(x,{className:`h-4 w-4`}),z(q,{children:h.text})]}),B(`div`,{className:`flex items-center gap-2`,children:[B(V,{size:`sm`,variant:`outline`,onClick:E,disabled:u,children:[z(I,{className:`w-3.5 h-3.5 mr-1 ${u?`animate-spin`:``}`}),`刷新`]}),B(V,{size:`sm`,onClick:()=>{b(!0),T(`{
|
|
119
|
+
|
|
120
|
+
}`)},children:[z(Ae,{className:`w-3.5 h-3.5 mr-1`}),`添加文档`]}),B(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:[`共 `,s?.total??0,` 条 · 第 `,p,`/`,k||1,` 页`]})]}),z(`div`,{className:`space-y-2`,children:u&&!s?z(`div`,{className:`text-center py-8`,children:z(P,{className:`w-4 h-4 animate-spin inline-block`})}):s?.rows?.length?s.rows.map((e,t)=>z(U,{className:`overflow-hidden`,children:z(W,{className:`p-3`,children:B(`div`,{className:`flex items-start justify-between gap-2`,children:[z(`pre`,{className:`text-xs font-mono flex-1 overflow-x-auto whitespace-pre-wrap break-all`,children:JSON.stringify(e,null,2)}),B(`div`,{className:`flex flex-col gap-1 shrink-0`,children:[z(V,{size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0`,onClick:()=>{v(e),b(!1),T(JSON.stringify(e,null,2))},children:z(De,{className:`w-3 h-3`})}),z(V,{size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 text-destructive`,onClick:()=>O(e),children:z(We,{className:`w-3 h-3`})})]})]})})},e._id||t)):z(`p`,{className:`text-center py-8 text-muted-foreground text-sm`,children:`暂无文档`})}),k>1&&B(`div`,{className:`flex items-center justify-center gap-2`,children:[z(V,{size:`sm`,variant:`outline`,disabled:p<=1,onClick:()=>m(e=>e-1),children:z(C,{className:`w-4 h-4`})}),B(`span`,{className:`text-xs text-muted-foreground`,children:[p,` / `,k]}),z(V,{size:`sm`,variant:`outline`,disabled:p>=k,onClick:()=>m(e=>e+1),children:z(w,{className:`w-4 h-4`})})]}),z(Dn,{open:_!==null||y,onOpenChange:e=>{e||(v(null),b(!1))},children:B(jn,{className:`max-w-lg`,children:[z(Mn,{children:z(Pn,{children:y?`添加文档`:`编辑文档`})}),z(`textarea`,{value:S,onChange:e=>T(e.target.value),className:`w-full h-60 font-mono text-xs p-3 border rounded-md resize-none bg-background`,spellCheck:!1}),B(Nn,{children:[z(kn,{asChild:!0,children:z(V,{variant:`outline`,size:`sm`,children:`取消`})}),B(V,{size:`sm`,onClick:()=>D(y),children:[z(Me,{className:`w-3.5 h-3.5 mr-1`}),`保存`]})]})]})})]})}function qs({tableName:e,kvGet:t,kvSet:n,kvDelete:r,kvEntries:o}){let[s,l]=c([]),[u,f]=c(!1),[p,m]=c(null),[h,g]=c(null),[_,v]=c(!1),[y,b]=c(``),[S,C]=c(``),w=i(async()=>{f(!0),m(null);try{l((await o(e)).entries)}catch(e){m({type:`error`,text:e.message})}finally{f(!1)}},[e,o]);a(()=>{w()},[w]);let T=async t=>{try{let r;try{r=JSON.parse(S)}catch{r=S}await n(e,y,r),m({type:`success`,text:t?`添加成功`:`更新成功`}),g(null),v(!1),b(``),C(``),setTimeout(()=>m(null),2e3),await w()}catch(e){m({type:`error`,text:e.message})}},E=async t=>{if(confirm(`确定要删除键 "${t}" 吗?`))try{await r(e,t),m({type:`success`,text:`删除成功`}),setTimeout(()=>m(null),2e3),await w()}catch(e){m({type:`error`,text:e.message})}};return B(`div`,{className:`space-y-3`,children:[p&&B(K,{variant:p.type===`error`?`destructive`:`success`,className:`py-2`,children:[p.type===`error`?z(d,{className:`h-4 w-4`}):z(x,{className:`h-4 w-4`}),z(q,{children:p.text})]}),B(`div`,{className:`flex items-center gap-2`,children:[B(V,{size:`sm`,variant:`outline`,onClick:w,disabled:u,children:[z(I,{className:`w-3.5 h-3.5 mr-1 ${u?`animate-spin`:``}`}),`刷新`]}),B(V,{size:`sm`,onClick:()=>{v(!0),b(``),C(``)},children:[z(Ae,{className:`w-3.5 h-3.5 mr-1`}),`添加键值`]}),B(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:[`共 `,s.length,` 个键`]})]}),z(`div`,{className:`border rounded-md max-h-[min(60vh,560px)] overflow-auto overscroll-contain touch-pan-x touch-pan-y bg-card`,role:`region`,"aria-label":`键值表,可左右滑动`,children:B(`table`,{className:`text-sm border-collapse min-w-full w-max`,children:[z(`thead`,{className:`sticky top-0 z-10 bg-muted/95 backdrop-blur-sm`,children:B(`tr`,{className:`border-b border-border/80`,children:[z(`th`,{className:`px-3 py-2 text-left font-medium text-muted-foreground whitespace-nowrap min-w-[8rem]`,children:`Key`}),z(`th`,{className:`px-3 py-2 text-left font-medium text-muted-foreground whitespace-nowrap min-w-[12rem]`,children:`Value`}),z(`th`,{className:`px-3 py-2 text-right font-medium text-muted-foreground whitespace-nowrap w-24 min-w-[5.5rem]`,children:`操作`})]})}),z(`tbody`,{children:u&&!s.length?z(`tr`,{children:z(`td`,{colSpan:3,className:`text-center py-8`,children:z(P,{className:`w-4 h-4 animate-spin inline-block`})})}):s.length?s.map(e=>B(`tr`,{className:`border-b border-border/60 hover:bg-muted/30 transition-colors`,children:[B(`td`,{className:`px-3 py-1.5 font-mono text-xs whitespace-nowrap align-top`,children:[z(me,{className:`w-3 h-3 inline-block mr-1 text-muted-foreground shrink-0`}),e.key]}),z(`td`,{className:`px-3 py-1.5 font-mono text-xs whitespace-nowrap align-top`,title:typeof e.value==`object`?JSON.stringify(e.value):String(e.value??``),children:typeof e.value==`object`?JSON.stringify(e.value):String(e.value??``)}),B(`td`,{className:`px-3 py-1.5 text-right space-x-1 whitespace-nowrap`,children:[z(V,{size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0`,onClick:()=>{g(e),v(!1),b(e.key),C(typeof e.value==`object`?JSON.stringify(e.value,null,2):String(e.value??``))},children:z(De,{className:`w-3 h-3`})}),z(V,{size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 text-destructive`,onClick:()=>E(e.key),children:z(We,{className:`w-3 h-3`})})]})]},e.key)):z(`tr`,{children:z(`td`,{colSpan:3,className:`text-center py-8 text-muted-foreground`,children:`暂无数据`})})})]})}),z(Dn,{open:h!==null||_,onOpenChange:e=>{e||(g(null),v(!1))},children:B(jn,{className:`max-w-md`,children:[z(Mn,{children:z(Pn,{children:_?`添加键值`:`编辑键值`})}),B(`div`,{className:`space-y-3 py-2`,children:[B(`div`,{className:`space-y-1`,children:[z(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Key`}),z(H,{value:y,onChange:e=>b(e.target.value),className:`font-mono text-xs`,disabled:!_})]}),B(`div`,{className:`space-y-1`,children:[z(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Value (JSON 或纯文本)`}),z(`textarea`,{value:S,onChange:e=>C(e.target.value),className:`w-full h-32 font-mono text-xs p-3 border rounded-md resize-none bg-background`,spellCheck:!1})]})]}),B(Nn,{children:[z(kn,{asChild:!0,children:z(V,{variant:`outline`,size:`sm`,children:`取消`})}),B(V,{size:`sm`,onClick:()=>T(_),children:[z(Me,{className:`w-3.5 h-3.5 mr-1`}),`保存`]})]})]})})]})}function Js(){let{info:e,tables:t,loading:n,error:r,loadInfo:i,loadTables:a,dropTable:s,select:l,insert:u,update:f,remove:p,kvGet:m,kvSet:h,kvDelete:g,kvEntries:_}=gt(),[v,y]=c(null),b=o(()=>t.find(e=>e.name===v),[t,v]),x=e?.type??`related`;return B(`div`,{className:`space-y-6`,children:[z(Ir,{title:`数据库管理`,description:`浏览和管理 ${Hs[x]} 中的数据;左栏选择对象,右侧查看与编辑。`,actions:B(`div`,{className:`flex items-center gap-2`,children:[e&&B(G,{variant:`secondary`,className:`font-normal`,children:[Us[e.dialect]||e.dialect,` · `,Hs[e.type]]}),B(V,{variant:`outline`,size:`sm`,onClick:()=>{i().catch(()=>{}),a().catch(()=>{})},disabled:n,children:[z(I,{className:`w-4 h-4 mr-1 ${n?`animate-spin`:``}`}),`刷新`]})]})}),r&&B(K,{variant:`destructive`,className:`py-2`,children:[z(d,{className:`h-4 w-4`}),z(q,{children:r})]}),z(U,{className:`overflow-hidden border-border/80 shadow-sm`,children:z(W,{className:`p-0`,children:B(`div`,{className:`flex min-h-[min(520px,calc(100vh-11rem))]`,children:[B(`div`,{className:`w-56 border-r flex flex-col shrink-0`,children:[z(`div`,{className:`px-3 py-2 border-b bg-muted/30`,children:z(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:x===`related`?`数据表`:x===`document`?`集合`:`桶`})}),z(sn,{className:`flex-1`,children:z(`div`,{className:`py-1`,children:n&&!t.length?z(`div`,{className:`flex items-center justify-center py-8`,children:z(P,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):t.length?t.map(e=>B(`button`,{className:`
|
|
121
|
+
group w-full flex items-center gap-2 px-3 py-1.5 text-sm text-left
|
|
122
|
+
hover:bg-accent transition-colors rounded-sm
|
|
123
|
+
${v===e.name?`bg-accent text-accent-foreground font-medium`:``}
|
|
124
|
+
`,onClick:()=>y(e.name),children:[z(x===`keyvalue`?me:Ve,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),z(`span`,{className:`truncate flex-1`,children:e.name}),e.columns&&z(G,{variant:`secondary`,className:`ml-auto text-[10px] px-1 py-0`,children:Object.keys(e.columns).length}),z(V,{size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 opacity-0 group-hover:opacity-100 text-destructive shrink-0`,onClick:t=>{t.stopPropagation();let n=x===`related`?`表`:x===`document`?`集合`:`桶`;confirm(`确定要删除${n} "${e.name}" 吗?此操作不可撤销!`)&&s(e.name).then(()=>{v===e.name&&y(null)}).catch(()=>{})},children:z(We,{className:`w-3 h-3`})})]},e.name)):z(`p`,{className:`text-sm text-muted-foreground text-center py-8`,children:`暂无数据`})})})]}),z(`div`,{className:`flex-1 min-w-0 p-4`,children:v?B(R,{children:[B(`div`,{className:`flex items-center gap-2 mb-4`,children:[z(Ve,{className:`w-5 h-5 text-muted-foreground`}),z(`h2`,{className:`text-lg font-semibold`,children:v}),b?.columns&&B(`div`,{className:`flex gap-1 ml-2 flex-wrap`,children:[Object.entries(b.columns).slice(0,8).map(([e,t])=>B(G,{variant:`outline`,className:`text-[10px] px-1.5 py-0`,children:[e,t.primary?` 🔑`:``,`: `,t.type]},e)),Object.keys(b.columns).length>8&&B(G,{variant:`outline`,className:`text-[10px] px-1.5 py-0`,children:[`+`,Object.keys(b.columns).length-8]})]})]}),x===`keyvalue`?z(qs,{tableName:v,kvGet:m,kvSet:h,kvDelete:g,kvEntries:_},v):x===`document`?z(Ks,{tableName:v,select:l,insert:u,update:f,remove:p},v):z(Gs,{tableName:v,tableInfo:b,select:l,insert:u,update:f,remove:p},v)]}):z(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:B(`div`,{className:`text-center`,children:[z(te,{className:`w-12 h-12 mx-auto mb-3 opacity-30`}),B(`p`,{className:`text-sm`,children:[`在左侧选择`,x===`related`?`一个表`:x===`document`?`一个集合`:`一个桶`,`开始管理`]})]})})})]})})})]})}var Ys={platform:``,botId:``,senderId:``,sceneId:``,scope:``};function Xs(){let[e,t]=c([]),[n,r]=c([]),[o,s]=c([]),[l,u]=c(!0),[f,p]=c(null),[m,h]=c(!1),[g,_]=c(null),[v,y]=c(!1),[x,C]=c({cronExpression:``,prompt:``,label:``,context:{...Ys}}),[w,E]=c(null),[O,te]=c(null),[ne,A]=c(null),j=bt(ut),{sendRequest:M}=xt(),N=i(async()=>{if(!j){u(!1),p(`WebSocket 未连接,请刷新页面`);return}try{let e=await M({type:`cron:list`});t(e.memory||[]),r(e.persistent||[]);try{s((await M({type:`bot:list`})).bots||[])}catch{}p(null)}catch(e){p(e.message)}finally{u(!1)}},[j,M]);a(()=>{j&&(u(!0),N())},[j,N]);let re=async()=>{if(!(!x.cronExpression||!x.prompt)){y(!0);try{let e={};x.context.platform&&(e.platform=x.context.platform),x.context.botId&&(e.botId=x.context.botId),x.context.senderId&&(e.senderId=x.context.senderId),x.context.sceneId&&(e.sceneId=x.context.sceneId),x.context.scope&&(e.scope=x.context.scope);let t=Object.keys(e).length>0;await M({type:`cron:add`,cronExpression:x.cronExpression,prompt:x.prompt,label:x.label,context:t?e:void 0}),h(!1),C({cronExpression:``,prompt:``,label:``,context:{...Ys}}),await N()}catch(e){p(e.message)}finally{y(!1)}}},ie=async()=>{if(g){y(!0);try{await M({type:`cron:remove`,id:g.id}),_(null),await N()}catch(e){p(e.message)}finally{y(!1)}}},ae=async e=>{try{e.enabled?await M({type:`cron:pause`,id:e.id}):await M({type:`cron:resume`,id:e.id}),await N()}catch(e){p(e.message)}};return l&&j?B(`div`,{className:`space-y-6`,children:[z(J,{className:`h-8 w-48`}),z(`div`,{className:`grid grid-cols-1 gap-4`,children:[...[,,,]].map((e,t)=>z(J,{className:`h-32`},t))})]}):f?B(`div`,{className:`space-y-4`,children:[B(K,{variant:`destructive`,children:[z(d,{className:`h-4 w-4`}),z(q,{children:f})]}),B(V,{variant:`outline`,size:`sm`,onClick:()=>{p(null),u(!0),N()},children:[z(I,{className:`w-4 h-4 mr-1`}),` 重试`]})]}):B(`div`,{className:`space-y-6`,children:[B(`div`,{className:`flex items-center justify-between`,children:[B(`div`,{children:[z(`h2`,{className:`text-2xl font-bold tracking-tight`,children:`定时任务`}),z(`p`,{className:`text-muted-foreground text-sm mt-1`,children:`管理持久化定时任务和查看插件注册的内存任务`})]}),B(`div`,{className:`flex items-center gap-2`,children:[B(V,{variant:`outline`,size:`sm`,onClick:()=>{u(!0),N()},children:[z(I,{className:`w-4 h-4 mr-1`}),` 刷新`]}),B(V,{size:`sm`,onClick:()=>h(!0),children:[z(Ae,{className:`w-4 h-4 mr-1`}),` 新建任务`]})]})]}),B(`div`,{children:[B(`div`,{className:`flex items-center gap-2 mb-3`,children:[z(Ue,{className:`w-5 h-5 text-primary`}),z(`h3`,{className:`text-lg font-semibold`,children:`持久化任务`}),z(G,{variant:`secondary`,children:n.length})]}),n.length===0?z(U,{children:B(W,{className:`py-8 text-center text-muted-foreground`,children:[z(D,{className:`w-10 h-10 mx-auto mb-3 opacity-40`}),z(`p`,{children:`暂无持久化定时任务`}),z(`p`,{className:`text-xs mt-1`,children:`点击「新建任务」添加一个定时 AI 任务`})]})}):z(`div`,{className:`grid grid-cols-1 gap-3`,children:n.map(e=>{let t=w===e.id;return z(U,{className:e.enabled?``:`opacity-60`,children:B(W,{className:`py-4`,children:[B(`div`,{className:`flex items-start justify-between gap-4 cursor-pointer`,onClick:()=>E(t?null:e.id),children:[B(`div`,{className:`flex-1 min-w-0`,children:[B(`div`,{className:`flex items-center gap-2 mb-1`,children:[z(t?T:S,{className:`w-4 h-4 shrink-0 text-muted-foreground`}),z(`span`,{className:`font-medium truncate`,children:e.label||e.id}),z(G,{variant:e.enabled?`default`:`outline`,className:`text-xs shrink-0`,children:e.enabled?`运行中`:`已暂停`})]}),B(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground mb-2 ml-6`,children:[z(`code`,{className:`bg-muted px-1.5 py-0.5 rounded`,children:e.cronExpression}),B(`span`,{children:[`创建于 `,new Date(e.createdAt).toLocaleString()]})]}),!t&&z(`p`,{className:`text-sm text-muted-foreground line-clamp-1 ml-6`,children:e.prompt})]}),B(`div`,{className:`flex items-center gap-1 shrink-0`,onClick:e=>e.stopPropagation(),children:[z(V,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,title:e.enabled?`暂停`:`恢复`,onClick:()=>ae(e),children:e.enabled?z(Ee,{className:`w-4 h-4`}):z(Oe,{className:`w-4 h-4`})}),z(V,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-destructive hover:text-destructive`,title:`删除`,onClick:()=>_(e),children:z(We,{className:`w-4 h-4`})})]})]}),t&&B(`div`,{className:`mt-3 ml-6 space-y-3 border-t pt-3`,children:[B(`div`,{children:[B(`div`,{className:`flex items-center justify-between mb-1`,children:[z(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`任务 ID`}),z(V,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,title:`复制 ID`,onClick:()=>{navigator.clipboard.writeText(e.id),A(e.id),setTimeout(()=>A(null),1500)},children:ne===e.id?z(b,{className:`w-3 h-3 text-green-500`}):z(k,{className:`w-3 h-3`})})]}),z(`code`,{className:`text-xs bg-muted px-2 py-1 rounded block`,children:e.id})]}),B(`div`,{children:[z(`span`,{className:`text-xs font-medium text-muted-foreground block mb-1`,children:`Cron 表达式`}),z(`code`,{className:`text-sm bg-muted px-2 py-1 rounded block`,children:e.cronExpression})]}),B(`div`,{children:[z(`span`,{className:`text-xs font-medium text-muted-foreground block mb-1`,children:`Prompt`}),z(`pre`,{className:`text-sm bg-muted px-3 py-2 rounded whitespace-pre-wrap break-words max-h-60 overflow-y-auto`,children:e.prompt})]}),e.context&&Object.values(e.context).some(Boolean)&&B(`div`,{children:[z(`span`,{className:`text-xs font-medium text-muted-foreground block mb-1`,children:`执行上下文`}),B(`div`,{className:`bg-muted px-3 py-2 rounded text-xs space-y-1`,children:[e.context.platform&&B(`p`,{children:[z(`span`,{className:`text-muted-foreground`,children:`平台:`}),` `,e.context.platform]}),e.context.botId&&B(`p`,{children:[z(`span`,{className:`text-muted-foreground`,children:`Bot:`}),` `,e.context.botId]}),e.context.senderId&&B(`p`,{children:[z(`span`,{className:`text-muted-foreground`,children:`发送者:`}),` `,e.context.senderId]}),e.context.sceneId&&B(`p`,{children:[z(`span`,{className:`text-muted-foreground`,children:`场景:`}),` `,e.context.sceneId]}),e.context.scope&&B(`p`,{children:[z(`span`,{className:`text-muted-foreground`,children:`类型:`}),` `,e.context.scope]})]})]}),B(`div`,{className:`flex items-center gap-4 text-xs text-muted-foreground`,children:[B(`span`,{children:[`状态: `,e.enabled?`✅ 运行中`:`⏸️ 已暂停`]}),B(`span`,{children:[`创建于: `,new Date(e.createdAt).toLocaleString()]})]})]})]})},e.id)})})]}),z(ln,{}),B(`div`,{children:[B(`div`,{className:`flex items-center gap-2 mb-3`,children:[z(ee,{className:`w-5 h-5 text-muted-foreground`}),z(`h3`,{className:`text-lg font-semibold`,children:`内存任务(插件注册)`}),z(G,{variant:`outline`,children:e.length})]}),e.length===0?z(U,{children:z(W,{className:`py-6 text-center text-muted-foreground text-sm`,children:`暂无插件注册的内存定时任务`})}):z(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:e.map((e,t)=>{let n=O===t;return z(U,{className:e.running?``:`opacity-60`,children:B(W,{className:`py-3`,children:[B(`div`,{className:`flex items-center justify-between mb-1 cursor-pointer`,onClick:()=>te(n?null:t),children:[B(`div`,{className:`flex items-center gap-2`,children:[z(n?T:S,{className:`w-4 h-4 shrink-0 text-muted-foreground`}),z(`code`,{className:`text-sm bg-muted px-1.5 py-0.5 rounded`,children:e.expression})]}),z(G,{variant:e.running?`default`:`outline`,className:`text-xs`,children:e.running?`运行中`:`已停止`})]}),B(`div`,{className:`text-xs text-muted-foreground space-y-0.5 ml-6`,children:[B(`p`,{children:[`插件: `,e.plugin]}),e.nextExecution&&B(`p`,{children:[`下次执行: `,new Date(e.nextExecution).toLocaleString()]})]}),n&&B(`div`,{className:`mt-3 ml-6 space-y-2 border-t pt-3`,children:[B(`div`,{children:[z(`span`,{className:`text-xs font-medium text-muted-foreground block mb-1`,children:`Cron 表达式`}),z(`code`,{className:`text-sm bg-muted px-2 py-1 rounded block`,children:e.expression})]}),B(`div`,{children:[z(`span`,{className:`text-xs font-medium text-muted-foreground block mb-1`,children:`所属插件`}),z(`code`,{className:`text-sm bg-muted px-2 py-1 rounded block`,children:e.plugin})]}),B(`div`,{className:`flex items-center gap-4 text-xs text-muted-foreground`,children:[B(`span`,{children:[`状态: `,e.running?`✅ 运行中`:`⏹️ 已停止`]}),e.nextExecution&&B(`span`,{children:[`下次执行: `,new Date(e.nextExecution).toLocaleString()]})]})]})]})},t)})})]}),z(Dn,{open:m,onOpenChange:h,children:B(jn,{children:[B(Mn,{children:[z(Pn,{children:`新建定时任务`}),z(Fn,{children:`创建一个持久化定时任务,到点时会将 Prompt 发送给 AI 执行。`})]}),B(`div`,{className:`space-y-4 py-2`,children:[B(`div`,{children:[z(`label`,{className:`text-sm font-medium mb-1.5 block`,children:`标签(可选)`}),z(H,{placeholder:`例如:每日摘要`,value:x.label,onChange:e=>C(t=>({...t,label:e.target.value}))})]}),B(`div`,{children:[z(`label`,{className:`text-sm font-medium mb-1.5 block`,children:`Cron 表达式`}),z(H,{placeholder:`分 时 日 月 周,例如:0 9 * * *`,value:x.cronExpression,onChange:e=>C(t=>({...t,cronExpression:e.target.value}))}),z(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`5 字段格式:分(0-59) 时(0-23) 日(1-31) 月(1-12) 周(0-7)`})]}),B(`div`,{children:[z(`label`,{className:`text-sm font-medium mb-1.5 block`,children:`Prompt`}),z(Bn,{placeholder:`触发时发送给 AI 的指令...`,rows:4,value:x.prompt,onChange:e=>C(t=>({...t,prompt:e.target.value}))})]}),z(ln,{}),B(`div`,{children:[z(`label`,{className:`text-sm font-medium mb-1.5 block`,children:`执行上下文(可选)`}),z(`p`,{className:`text-xs text-muted-foreground mb-3`,children:`指定任务执行时的身份信息,如不填则以 system 身份执行`}),B(`div`,{className:`grid grid-cols-2 gap-3`,children:[B(`div`,{children:[z(`label`,{className:`text-xs text-muted-foreground mb-1 block`,children:`适配器`}),B(`select`,{className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,value:x.context.platform||``,onChange:e=>{let t=e.target.value;C(e=>({...e,context:{...e.context,platform:t,botId:``}}))},children:[z(`option`,{value:``,children:`不指定`}),[...new Set(o.map(e=>e.adapter))].map(e=>z(`option`,{value:e,children:e},e))]})]}),B(`div`,{children:[z(`label`,{className:`text-xs text-muted-foreground mb-1 block`,children:`Bot`}),B(`select`,{className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,value:x.context.botId||``,disabled:!x.context.platform,onChange:e=>C(t=>({...t,context:{...t.context,botId:e.target.value}})),children:[z(`option`,{value:``,children:`不指定`}),o.filter(e=>e.adapter===x.context.platform).map(e=>z(`option`,{value:e.name,children:e.name},e.name))]})]}),B(`div`,{children:[z(`label`,{className:`text-xs text-muted-foreground mb-1 block`,children:`场景类型`}),B(`select`,{className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,value:x.context.scope||``,onChange:e=>C(t=>({...t,context:{...t.context,scope:e.target.value}})),children:[z(`option`,{value:``,children:`不指定`}),z(`option`,{value:`private`,children:`私聊 (private)`}),z(`option`,{value:`group`,children:`群聊 (group)`}),z(`option`,{value:`channel`,children:`频道 (channel)`})]})]}),B(`div`,{children:[z(`label`,{className:`text-xs text-muted-foreground mb-1 block`,children:`发送者 ID`}),z(H,{placeholder:`用户 ID`,value:x.context.senderId||``,onChange:e=>C(t=>({...t,context:{...t.context,senderId:e.target.value}}))})]}),B(`div`,{children:[z(`label`,{className:`text-xs text-muted-foreground mb-1 block`,children:`场景 ID`}),z(H,{placeholder:`群号/频道ID`,value:x.context.sceneId||``,onChange:e=>C(t=>({...t,context:{...t.context,sceneId:e.target.value}}))})]})]})]})]}),B(Nn,{children:[z(kn,{asChild:!0,children:z(V,{variant:`outline`,children:`取消`})}),z(V,{onClick:re,disabled:v||!x.cronExpression||!x.prompt,children:v?`创建中...`:`创建`})]})]})}),z(Dn,{open:!!g,onOpenChange:e=>!e&&_(null),children:B(jn,{children:[B(Mn,{children:[z(Pn,{children:`确认删除`}),B(Fn,{children:[`确定要删除任务「`,g?.label||g?.id,`」吗?此操作不可撤销。`]})]}),B(Nn,{children:[z(kn,{asChild:!0,children:z(V,{variant:`outline`,children:`取消`})}),z(V,{variant:`destructive`,onClick:ie,disabled:v,children:v?`删除中...`:`删除`})]})]})})]})}var Zs=[{value:``,label:`全部`,icon:F},{value:`adapter`,label:`适配器`,icon:le},{value:`service`,label:`服务`,icon:Re},{value:`util`,label:`工具`,icon:F},{value:`game`,label:`游戏`,icon:F},{value:`feature`,label:`特性`,icon:F}];function Qs(e){return e?new Date(e).toLocaleDateString(`zh-CN`):``}function $s(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ec(){let[e,t]=c([]),[n,r]=c(!0),[l,u]=c(null),[f,p]=c(``),[h,g]=c(``),_=s(),[v,y]=c(``),[b,x]=c(!1),[S,C]=c(`name`),[w,T]=c([]),[E,D]=c(!1),[O,k]=c(!1),[ee,te]=c(!1),[j,M]=c(null),N=i(async()=>{r(!0),u(null);try{let e=new URLSearchParams;h&&e.set(`q`,h),v&&e.set(`category`,v),b&&e.set(`official`,`true`),e.set(`limit`,`50`);let n=await fetch(`/pub/marketplace/search?${e}`);if(!n.ok)throw Error(`搜索失败`);let r=await n.json();if(r.success)t(r.data);else throw Error(r.error||`数据格式错误`)}catch(e){u(e.message)}finally{r(!1)}},[h,v,b]);a(()=>(clearTimeout(_.current),_.current=setTimeout(()=>g(f),350),()=>clearTimeout(_.current)),[f]),a(()=>{N()},[N]);let re=i(async()=>{D(!0);try{let e=localStorage.getItem(`zhin_api_token`),t=await fetch(`/api/marketplace/updates`,{headers:e?{Authorization:`Bearer ${e}`}:{}});if(t.ok){let e=await t.json();e.success&&T(e.data)}}catch{}finally{D(!1)}},[]),ie=i(async e=>{k(!0),te(!0),M(null);try{let t=await fetch(`/pub/marketplace/detail/${e}`);if(t.ok){let e=await t.json();e.success&&M(e.data)}}catch{}finally{te(!1)}},[]),ae=o(()=>{let t=[...e];return S===`date`?t.sort((e,t)=>new Date(t.date).getTime()-new Date(e.date).getTime()):t.sort((e,t)=>e.name.localeCompare(t.name)),t},[e,S]);return B(`div`,{className:`space-y-4`,children:[B(`div`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3`,children:[B(`div`,{children:[z(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`插件市场`}),B(`p`,{className:`text-sm text-muted-foreground mt-1`,children:[`探索 Zhin.js 生态中的 `,e.length,` 个插件`]})]}),z(`div`,{className:`flex gap-2`,children:B(V,{variant:`outline`,size:`sm`,onClick:re,disabled:E,children:[z(I,{className:`w-4 h-4 mr-1 ${E?`animate-spin`:``}`}),`检查更新`]})})]}),w.length>0&&B(K,{children:[z(I,{className:`h-4 w-4`}),B(q,{children:[`有 `,w.length,` 个插件可更新:`,w.map(e=>B(G,{variant:`secondary`,className:`ml-1`,children:[e.name,` `,e.current,` → `,e.latest]},e.name))]})]}),B(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[B(`div`,{className:`relative flex-1`,children:[z(Ne,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`}),z(H,{placeholder:`搜索插件名称、描述...`,value:f,onChange:e=>p(e.target.value),className:`pl-9`})]}),B(`div`,{className:`flex gap-2 flex-wrap`,children:[B(V,{variant:b?`default`:`outline`,size:`sm`,onClick:()=>x(!b),children:[z(Re,{className:`w-4 h-4 mr-1`}),`仅官方`]}),B(V,{variant:`outline`,size:`sm`,onClick:()=>C(S===`name`?`date`:`name`),children:[z(m,{className:`w-4 h-4 mr-1`}),S===`name`?`名称`:`更新时间`]})]})]}),z(Cr,{value:v,onValueChange:e=>y(e),children:z(wr,{children:Zs.map(e=>z(Tr,{value:e.value,children:e.label},e.value))})}),l&&B(K,{variant:`destructive`,children:[z(d,{className:`h-4 w-4`}),z(q,{children:l})]}),n&&z(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:[...[,,,,,,]].map((e,t)=>z(J,{className:`h-40`},t))}),!n&&z(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:ae.map(e=>z(U,{className:`cursor-pointer transition-all hover:shadow-md hover:-translate-y-0.5`,onClick:()=>ie(e.name),children:B(W,{className:`p-4 space-y-3`,children:[B(`div`,{className:`flex justify-between items-start`,children:[B(`div`,{className:`flex items-center gap-2 min-w-0`,children:[z(F,{className:`w-4 h-4 shrink-0 text-muted-foreground`}),z(`span`,{className:`font-semibold text-sm truncate`,children:e.name})]}),B(`div`,{className:`flex gap-1 shrink-0`,children:[e.isOfficial&&z(G,{variant:`default`,className:`text-[10px]`,children:`官方`}),B(G,{variant:`secondary`,className:`text-[10px]`,children:[`v`,e.version]})]})]}),z(`p`,{className:`text-xs text-muted-foreground line-clamp-2`,children:e.description||`暂无描述`}),z(ln,{}),B(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[z(`span`,{children:e.author}),z(`span`,{children:Qs(e.date)})]}),e.keywords.length>0&&B(`div`,{className:`flex flex-wrap gap-1`,children:[e.keywords.slice(0,4).map(e=>z(G,{variant:`outline`,className:`text-[10px] px-1.5 py-0`,children:e},e)),e.keywords.length>4&&B(G,{variant:`outline`,className:`text-[10px] px-1.5 py-0`,children:[`+`,e.keywords.length-4]})]})]})},e.name))}),!n&&ae.length===0&&z(U,{children:B(W,{className:`flex flex-col items-center gap-3 py-12`,children:[z(F,{className:`w-12 h-12 text-muted-foreground`}),z(`h3`,{className:`text-lg font-semibold`,children:`未找到插件`}),z(`p`,{className:`text-sm text-muted-foreground`,children:`尝试调整搜索条件或分类筛选`})]})}),z(Dn,{open:O,onOpenChange:k,children:z(jn,{className:`max-w-2xl max-h-[80vh] overflow-y-auto`,children:ee?B(`div`,{className:`space-y-3`,children:[z(J,{className:`h-6 w-48`}),z(J,{className:`h-4 w-full`}),z(J,{className:`h-20 w-full`})]}):j?B(R,{children:[B(Mn,{children:[B(Pn,{className:`flex items-center gap-2`,children:[z(F,{className:`w-5 h-5`}),j.name,B(G,{variant:`secondary`,children:[`v`,j.version]})]}),z(Fn,{children:j.description})]}),B(`div`,{className:`space-y-4`,children:[B(`div`,{className:`grid grid-cols-3 gap-2 text-center`,children:[B(`div`,{className:`rounded-md bg-secondary p-2`,children:[z(`div`,{className:`text-lg font-bold`,children:$s(j.downloads.weekly)}),z(`div`,{className:`text-[10px] text-muted-foreground`,children:`周下载`})]}),B(`div`,{className:`rounded-md bg-secondary p-2`,children:[z(`div`,{className:`text-lg font-bold`,children:$s(j.downloads.monthly)}),z(`div`,{className:`text-[10px] text-muted-foreground`,children:`月下载`})]}),B(`div`,{className:`rounded-md bg-secondary p-2`,children:[z(`div`,{className:`text-lg font-bold`,children:j.versions.length}),z(`div`,{className:`text-[10px] text-muted-foreground`,children:`版本数`})]})]}),z(ln,{}),B(`div`,{className:`space-y-2 text-sm`,children:[j.author&&B(`div`,{className:`flex justify-between`,children:[z(`span`,{className:`text-muted-foreground`,children:`作者`}),z(`span`,{children:j.author})]}),j.license&&B(`div`,{className:`flex justify-between`,children:[z(`span`,{className:`text-muted-foreground`,children:`许可证`}),z(`span`,{children:j.license})]}),j.lastPublish&&B(`div`,{className:`flex justify-between`,children:[z(`span`,{className:`text-muted-foreground`,children:`最后发布`}),z(`span`,{children:Qs(j.lastPublish)})]}),j.engines&&Object.keys(j.engines).length>0&&B(`div`,{className:`flex justify-between`,children:[z(`span`,{className:`text-muted-foreground`,children:`Node.js`}),z(`span`,{children:j.engines.node||`-`})]})]}),j.peerDependencies&&Object.keys(j.peerDependencies).length>0&&B(R,{children:[z(ln,{}),B(`div`,{children:[z(`h4`,{className:`text-sm font-medium mb-2`,children:`对等依赖`}),z(`div`,{className:`flex flex-wrap gap-1`,children:Object.entries(j.peerDependencies).map(([e,t])=>B(G,{variant:`outline`,className:`text-xs`,children:[e,`@`,t]},e))})]})]}),j.readme&&B(R,{children:[z(ln,{}),B(`div`,{children:[z(`h4`,{className:`text-sm font-medium mb-2`,children:`README`}),z(`p`,{className:`text-xs text-muted-foreground whitespace-pre-line leading-relaxed`,children:j.readme})]})]}),z(ln,{}),B(`div`,{children:[z(`h4`,{className:`text-sm font-medium mb-2`,children:`安装命令`}),B(`code`,{className:`block text-xs bg-secondary rounded-md p-2`,children:[`pnpm add `,j.name]})]})]}),B(Nn,{className:`gap-2 flex-wrap`,children:[j.homepage&&z(V,{variant:`outline`,size:`sm`,asChild:!0,children:B(`a`,{href:j.homepage,target:`_blank`,rel:`noopener noreferrer`,children:[z(A,{className:`w-3 h-3 mr-1`}),` 主页`]})}),z(V,{variant:`outline`,size:`sm`,asChild:!0,children:B(`a`,{href:j.npm||`https://www.npmjs.com/package/${j.name}`,target:`_blank`,rel:`noopener noreferrer`,children:[z(ne,{className:`w-3 h-3 mr-1`}),` npm`]})}),z(kn,{asChild:!0,children:z(V,{variant:`secondary`,size:`sm`,children:`关闭`})})]})]}):B(K,{variant:`destructive`,children:[z(d,{className:`h-4 w-4`}),z(q,{children:`加载插件详情失败`})]})})})]})}function tc({onSuccess:e}){let[t,n]=c(``),[r,a]=c(``),[o,s]=c(!1),l=i(async()=>{let n=t.trim();if(!n){a(`请输入 Token`);return}s(!0),a(``);try{let t=await fetch(`/api/system/status`,{headers:{Authorization:`Bearer ${n}`}});t.ok?(fn(n),e()):t.status===401?a(`Token 无效,请检查后重试`):a(`验证失败 (HTTP ${t.status})`)}catch{a(`无法连接到服务器`)}finally{s(!1)}},[t,e]);return z(`div`,{className:`flex items-center justify-center min-h-screen bg-background`,children:B(U,{className:L(`w-full max-w-md mx-4`),children:[B(bn,{className:`text-center space-y-2`,children:[z(`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`}),z(xn,{className:`text-xl`,children:`Zhin.js 控制台`}),z(Sn,{children:`请输入 API Token 以访问管理面板`})]}),z(W,{children:B(`form`,{onSubmit:e=>{e.preventDefault(),l()},className:`space-y-4`,children:[B(`div`,{className:`space-y-2`,children:[z(H,{type:`password`,placeholder:`API Token`,value:t,onChange:e=>{n(e.target.value),r&&a(``)},autoFocus:!0}),r&&z(`p`,{className:`text-sm text-destructive`,children:r})]}),z(V,{type:`submit`,className:`w-full`,disabled:o,children:o?`验证中...`:`登录`}),B(`p`,{className:`text-xs text-center text-muted-foreground`,children:[`Token 位于 `,z(`code`,{className:`text-xs bg-muted px-1 rounded`,children:`.env`}),` 文件的`,` `,z(`code`,{className:`text-xs bg-muted px-1 rounded`,children:`HTTP_TOKEN`}),` 中`]})]})})]})})}function nc(e){return nc=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},nc(e)}function rc(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ic(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ac(e,t,n){return t&&ic(e.prototype,t),n&&ic(e,n),e}function oc(e,t){return t&&(nc(t)===`object`||typeof t==`function`)?t:cc(e)}function sc(e){return sc=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},sc(e)}function cc(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function lc(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&uc(e,t)}function uc(e,t){return uc=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},uc(e,t)}function dc(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var fc=function(e){lc(t,e);function t(){var e,n;rc(this,t);var r=[...arguments];return n=oc(this,(e=sc(t)).call.apply(e,[this].concat(r))),dc(cc(n),`state`,{bootstrapped:!1}),dc(cc(n),`_unsubscribe`,void 0),dc(cc(n),`handlePersistorState`,function(){n.props.persistor.getState().bootstrapped&&(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 ac(t,[{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}}]),t}(n);dc(fc,`defaultProps`,{children:null,loading:null});var pc=It.Provider;It.Root,It.Trigger;var mc=e.forwardRef(({className:e,sideOffset:t=4,...n},r)=>z(It.Portal,{children:z(It.Content,{ref:r,sideOffset:t,className:L(`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`,e),...n})}));mc.displayName=`TooltipContent`,nn();function hc(){let[e,t]=c(mn()),n=i(()=>t(!0),[]);return a(()=>{let e=()=>t(!1);return window.addEventListener(`zhin:auth-required`,e),()=>window.removeEventListener(`zhin:auth-required`,e)},[]),e?z(fc,{loading:null,persistor:st,children:z(Qt,{store:ft,children:z(gc,{})})}):z(tc,{onSuccess:n})}function gc(){xt();let e=bt(e=>e.script?.entries||[]),t=bt(e=>e.script?.loadedScripts||[]),n=bt(e=>e.script?.synced??!1),[r,i]=c(!1);a(()=>{[{key:`dashboardLayout`,path:`/`,title:`Dashboard`,element:z(yn,{}),meta:{order:0},children:[{key:`homePage`,path:`/dashboard`,title:`系统概览`,icon:z(de,{className:`w-4 h-4`}),element:z(In,{}),meta:{group:`系统`,order:0}},{key:`botManagePage`,path:`/bots`,title:`机器人`,icon:z(g,{className:`w-4 h-4`}),element:z(Sr,{}),meta:{group:`系统`,order:1}},{key:`logsPage`,path:`/logs`,title:`系统日志`,icon:z(ie,{className:`w-4 h-4`}),element:z(Lr,{}),meta:{group:`系统`,order:2,fullWidth:!0}},{key:`cronPage`,path:`/cron`,title:`定时任务`,icon:z(D,{className:`w-4 h-4`}),element:z(Xs,{}),meta:{group:`系统`,order:3}},{key:`pluginsPage`,path:`/plugins`,title:`插件管理`,icon:z(F,{className:`w-4 h-4`}),element:z(zn,{}),meta:{group:`扩展`,order:4}},{key:`pluginDetailPage`,title:`插件详情`,path:`/plugins/:name`,element:z(br,{}),meta:{hideInMenu:!0}},{key:`marketplacePage`,path:`/marketplace`,title:`插件市场`,icon:z(ze,{className:`w-4 h-4`}),element:z(ec,{}),meta:{group:`扩展`,order:5}},{key:`configPage`,path:`/config`,title:`配置管理`,icon:z(Ie,{className:`w-4 h-4`}),element:z(Os,{}),meta:{group:`配置与数据`,order:6}},{key:`envManagePage`,path:`/env`,title:`环境变量`,icon:z(he,{className:`w-4 h-4`}),element:z(Ms,{}),meta:{group:`配置与数据`,order:6}},{key:`fileManagePage`,path:`/files`,title:`文件管理`,icon:z(oe,{className:`w-4 h-4`}),element:z(Vs,{}),meta:{group:`配置与数据`,order:7}},{key:`databasePage`,path:`/database`,title:`数据库`,icon:z(te,{className:`w-4 h-4`}),element:z(Js,{}),meta:{group:`配置与数据`,order:8,fullWidth:!0}},{key:`botDetailPage`,path:`/bots/:adapter/:botId`,title:`机器人详情`,element:z(Pr,{}),meta:{hideInMenu:!0,fullWidth:!0}}]}].forEach(e=>{ot(e)}),i(!0)},[]);let o=n&&(e.length===0||e.length===t.length);return!r||!o?z(`div`,{className:`flex items-center justify-center h-screen bg-background`,children:B(`div`,{className:`text-center`,children:[z(`div`,{className:`inline-block animate-spin rounded-full h-8 w-8 border-2 border-muted-foreground border-t-foreground`}),B(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:[`加载中... (`,t.length,`/`,e.length,`)`]})]})}):z(rt,{})}l(document.getElementById(`root`)).render(z(r,{children:z(pc,{children:z(hc,{})})}));
|