linkshell-cli 0.5.40 → 0.5.42

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.
@@ -1,36 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPanel-C3hvv9KU.js","assets/vendor-react-M7xG3qiw.js","assets/vendor-xterm-D15THcI4.js","assets/vendor-highlight-NXWAAyIv.js","assets/UsageDashboard-D9Xlpl3d.js","assets/PortPreview-6-Cj-cKd.js","assets/FileBrowser-Daeji5i-.js"])))=>i.map(i=>d[i]);
2
- import{r as v,j as l,g as ro,a as pc,c as mc}from"./vendor-react-M7xG3qiw.js";import{o as at,u as gc,g as xc,c as yc}from"./vendor-highlight-NXWAAyIv.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();const io="linkshell_gateway_url",bc="http://localhost:8787";function kc(){var e;return typeof window<"u"&&((e=window.location)!=null&&e.origin)?window.location.origin.replace(/\/+$/,""):bc}function so(){let e=kc();try{const t=localStorage.getItem(io);t&&(e=t)}catch{}return{httpUrl:e}}function ao(e){try{localStorage.setItem(io,e.replace(/\/+$/,""))}catch{}}const oo="linkshell_device_token";let Ht=null;function ci(){return typeof(crypto==null?void 0:crypto.randomUUID)=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function Yn(){if(Ht)return Ht;try{Ht=localStorage.getItem(oo)}catch{Ht=null}return Ht}function vc(){const e=Yn();if(e)return e;const t=ci();return Di(t),t}function Di(e){Ht=e;try{localStorage.setItem(oo,e)}catch{}}const Ns="linkshell_device_id";let fn=null;function wc(){if(fn)return fn;try{let e=localStorage.getItem(Ns);e||(e=ci(),localStorage.setItem(Ns,e)),fn=e}catch{fn=ci()}return fn}const lo="linkshell_theme",Xn=new Set;let ur=Sc();function Sc(){try{const e=localStorage.getItem(lo);if(e==="light"||e==="dark"||e==="system")return e}catch{}return"dark"}function _c(){return typeof window<"u"&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!0}function jc(e=ur){return e==="system"?_c()?"dark":"light":e}function ui(){typeof document>"u"||document.documentElement.setAttribute("data-theme",jc())}function Is(){return ur}function zi(e){ur=e;try{localStorage.setItem(lo,e)}catch{}ui();for(const t of Xn)t()}function Cc(e){return Xn.add(e),()=>Xn.delete(e)}function Nc(){var e;if(ui(),typeof window<"u"&&window.matchMedia){const t=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>{if(ur==="system"){ui();for(const r of Xn)r()}};(e=t.addEventListener)==null||e.call(t,"change",n)}}const co=1,uo="linkshell_view",dr="linkshell_conv_",fr="linkshell_timeline_",hr="linkshell_known_sessions";function pr(e){try{const t=localStorage.getItem(e);if(!t)return null;const n=JSON.parse(t);return n&&n.version===co&&n.data!==void 0?n.data:null}catch{return null}}function on(e,t){try{const n={version:co,data:t};localStorage.setItem(e,JSON.stringify(n))}catch{}}function Ic(){return pr(uo)??{name:"list"}}function Ts(e){on(uo,e)}function jt(){return pr(hr)??[]}function di(e){if(e.length===0)return jt();const t=new Set(e.map(i=>i.id)),n=new Map;for(const i of jt())n.set(i.id,t.has(i.id)?i:{...i,hasHost:!1});for(const i of e)n.set(i.id,{...n.get(i.id),...i});const r=[...n.values()].sort((i,s)=>(s.lastActivity??0)-(i.lastActivity??0)).slice(0,50);return on(hr,r),r}function Tc(){const e=jt().map(t=>({...t,hasHost:!1}));return on(hr,e),e}function Ac(e){const t=jt().filter(n=>n.id!==e);return on(hr,t),fo(e),t}function fo(e){try{for(const t of ho(e))localStorage.removeItem(Jn+t.id);localStorage.removeItem(dr+e),localStorage.removeItem(fr+e)}catch{}}function Ec(){try{const e=new Set(jt().map(n=>n.id)),t=new Set;for(let n=0;n<localStorage.length;n++){const r=localStorage.key(n);if(!r)continue;const i=[dr,fr].find(a=>r.startsWith(a));if(!i)continue;const s=r.slice(i.length);e.has(s)||t.add(s)}for(const n of t)fo(n)}catch{}}function ho(e){return pr(dr+e)??[]}function As(e,t){on(dr+e,t)}const Jn="linkshell_draft_";function Pc(e){try{return localStorage.getItem(Jn+e)??""}catch{return""}}function Mc(e,t){try{t?localStorage.setItem(Jn+e,t):localStorage.removeItem(Jn+e)}catch{}}function Rc(e){return pr(fr+e)??{}}function Es(e,t){const n={};for(const[r,i]of t){const s=i.filter(a=>{var o;return((o=a.metadata)==null?void 0:o.optimistic)!==!0}).slice(-200);n[r]=s}on(fr+e,n)}Ec();function Lc(){try{const e=new URLSearchParams(window.location.search),t=e.get("embed")==="1",n=e.get("theme");return{embed:t,sessionId:e.get("session"),gateway:e.get("gateway"),token:e.get("token"),theme:n==="dark"||n==="light"?n:null}}catch{return{embed:!1,sessionId:null,gateway:null,token:null,theme:null}}}function Dc(e){return!e.embed||!e.sessionId||!e.token||!e.gateway?null:(ao(e.gateway),Di(e.token),e.theme&&zi(e.theme),di([{id:e.sessionId,state:"active",hasHost:!0,clientCount:1,provider:null,machineId:null,hostname:null,platform:null,projectName:null,cwd:null,lastActivity:Date.now()}]),{name:"console",sessionId:e.sessionId})}function po(){try{const e=window.ReactNativeWebView;e==null||e.postMessage(JSON.stringify({type:"requestClose"}))}catch{}}const zc="linkshell_embed";function Oi(){try{return new URLSearchParams(window.location.search).get("embed")==="1"?!0:localStorage.getItem(zc)==="1"}catch{return!1}}class Oc extends v.Component{constructor(){super(...arguments),this.state={error:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t){console.error("[ErrorBoundary]",t)}render(){return this.state.error?l.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4 px-6",children:[l.jsx("div",{className:"text-lg font-medium text-content-primary",children:"页面出错了"}),l.jsx("div",{className:"max-w-md break-all text-center font-mono text-xs text-content-muted",children:this.state.error.message}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{type:"button",className:"codex-btn-primary",onClick:()=>window.location.reload(),children:"重新加载"}),Oi()&&l.jsx("button",{type:"button",className:"codex-btn-outline",onClick:()=>po(),children:"关闭"})]})]}):this.props.children}}const Tn="https://mkbeusztkzffnzjdwmqk.supabase.co",An="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1rYmV1c3p0a3pmZm56amR3bXFrIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjU5Nzc0NzgsImV4cCI6MjA4MTU1MzQ3OH0.2wlT6q6687Z5rpEYsdp01IQpNNl_XWv0IAfBgwPyDP0",Fi="linkshell_session",mo=1;function $i(e){const t={version:mo,session:e};localStorage.setItem(Fi,JSON.stringify(t))}function mr(){try{const e=localStorage.getItem(Fi);if(!e)return null;const t=JSON.parse(e);return t&&t.version===mo&&t.session?t.session:null}catch{return null}}function go(){localStorage.removeItem(Fi)}const fi=new Set;function Fc(e){return fi.add(e),()=>{fi.delete(e)}}function $c(){for(const e of fi)try{e()}catch{}}function Bc(e){return(e==null?void 0:e.plan)==="pro"}async function Bi(e,t,n="free"){try{const r=await fetch(`${Tn}/rest/v1/profiles?id=eq.${t}&select=plan,plan_expires_at&limit=1`,{headers:{Authorization:`Bearer ${e}`,apikey:An}});if(r.ok){const i=await r.json();if(i.length>0){const s=i[0];if(s.plan==="pro"&&s.plan_expires_at&&new Date(s.plan_expires_at)>new Date)return"pro"}return"free"}return n}catch{return n}}async function qc(e,t){try{const n=await fetch(`${Tn}/auth/v1/token?grant_type=password`,{method:"POST",headers:{"Content-Type":"application/json",apikey:An},body:JSON.stringify({email:e,password:t})}),r=await n.json();if(!n.ok)return{session:null,error:r.error_description||"登录失败"};const i=await Bi(r.access_token,r.user.id),s={accessToken:r.access_token,refreshToken:r.refresh_token,expiresAt:Date.now()+(r.expires_in??3600)*1e3,user:{id:r.user.id,email:r.user.email},plan:i};return $i(s),{session:s,error:null}}catch(n){return{session:null,error:n.message||"网络错误"}}}async function Vc(e,t){try{const n=await fetch(`${Tn}/auth/v1/signup`,{method:"POST",headers:{"Content-Type":"application/json",apikey:An},body:JSON.stringify({email:e,password:t})}),r=await n.json();if(!n.ok)return{session:null,error:r.error_description||r.msg||"注册失败"};if(!r.access_token)return{session:null,error:null};const i=await Bi(r.access_token,r.user.id),s={accessToken:r.access_token,refreshToken:r.refresh_token,expiresAt:Date.now()+(r.expires_in??3600)*1e3,user:{id:r.user.id,email:r.user.email},plan:i};return $i(s),{session:s,error:null}}catch(n){return{session:null,error:n.message||"网络错误"}}}async function Uc(){const e=mr();if(e)try{await fetch(`${Tn}/auth/v1/logout`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,apikey:An}})}catch{}go()}let hn=null;async function Hc(){if(hn)return hn;hn=(async()=>{const e=mr();if(!(e!=null&&e.refreshToken))return null;try{const t=await fetch(`${Tn}/auth/v1/token?grant_type=refresh_token`,{method:"POST",headers:{"Content-Type":"application/json",apikey:An},body:JSON.stringify({refresh_token:e.refreshToken})});if(!t.ok)return t.status>=400&&t.status<500&&(go(),$c()),null;const n=await t.json(),r=await Bi(n.access_token,n.user.id,e.plan),i={accessToken:n.access_token,refreshToken:n.refresh_token,expiresAt:Date.now()+(n.expires_in??3600)*1e3,user:{id:n.user.id,email:n.user.email},plan:r};return $i(i),i}catch{return null}})();try{return await hn}finally{hn=null}}async function xo(){const e=mr();return e?e.expiresAt-Date.now()<6e4?Hc():e:null}function we({size:e=16,children:t,...n}){return l.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n,children:t})}const zr=e=>l.jsxs(we,{...e,children:[l.jsx("path",{d:"m4 17 6-6-6-6"}),l.jsx("path",{d:"M12 19h8"})]}),Pt=e=>l.jsx(we,{...e,children:l.jsx("path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"})}),Sn=e=>l.jsxs(we,{...e,children:[l.jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),l.jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"})]}),Wc=e=>l.jsxs(we,{...e,children:[l.jsx("rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}),l.jsx("path",{d:"M8 21h8M12 17v4"})]}),yo=e=>l.jsx(we,{...e,children:l.jsx("rect",{width:"14",height:"14",x:"5",y:"5",rx:"2"})}),dt=e=>l.jsx(we,{...e,children:l.jsx("path",{d:"M18 6 6 18M6 6l12 12"})}),Zc=e=>l.jsx(we,{...e,children:l.jsx("path",{d:"M4 6h16M4 12h16M4 18h16"})}),nt=e=>l.jsx(we,{...e,children:l.jsx("path",{d:"m9 18 6-6-6-6"})}),Ps=e=>l.jsx(we,{...e,children:l.jsx("path",{d:"m15 18-6-6 6-6"})}),xt=e=>l.jsx(we,{...e,children:l.jsx("path",{d:"m6 9 6 6 6-6"})}),bo=e=>l.jsx(we,{...e,children:l.jsx("path",{d:"m5 12 7-7 7 7M12 19V5"})}),ko=e=>l.jsxs(we,{...e,children:[l.jsx("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),l.jsx("path",{d:"M21 3v5h-5M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),l.jsx("path",{d:"M8 16H3v5"})]}),_n=e=>l.jsx(we,{...e,children:l.jsx("path",{d:"M5 12h14M12 5v14"})}),qi=e=>l.jsx(we,{...e,children:l.jsx("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),Rt=e=>l.jsx(we,{...e,children:l.jsx("path",{d:"M20 6 9 17l-5-5"})}),Qc=e=>l.jsxs(we,{...e,children:[l.jsx("circle",{cx:"12",cy:"12",r:"4"}),l.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41"})]}),Kc=e=>l.jsx(we,{...e,children:l.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})}),Yc=e=>l.jsxs(we,{...e,children:[l.jsx("rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}),l.jsx("path",{d:"M8 21h8M12 17v4"})]}),vo=e=>l.jsx(we,{...e,children:l.jsx("path",{d:"M12 22v-5M9 8V2M15 8V2M18 8v3a6 6 0 0 1-12 0V8Z"})}),Vi=e=>l.jsxs(we,{...e,children:[l.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),l.jsx("circle",{cx:"9",cy:"7",r:"4"}),l.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75"})]}),Xc=e=>l.jsxs(we,{...e,children:[l.jsx("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),l.jsx("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]}),Yt=e=>l.jsxs(we,{...e,children:[l.jsx("path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),l.jsx("path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"})]}),wo=e=>l.jsxs(we,{...e,children:[l.jsx("rect",{width:"20",height:"5",x:"2",y:"3",rx:"1"}),l.jsx("path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"}),l.jsx("path",{d:"M10 12h4"})]}),Jc=e=>l.jsxs(we,{...e,children:[l.jsx("path",{d:"M3 6h18"}),l.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),l.jsx("path",{d:"M10 11v6M14 11v6"})]}),Mt=e=>l.jsxs(we,{...e,children:[l.jsx("circle",{cx:"11",cy:"11",r:"8"}),l.jsx("path",{d:"m21 21-4.3-4.3"})]}),So=e=>l.jsxs(we,{...e,children:[l.jsx("circle",{cx:"12",cy:"12",r:"1"}),l.jsx("circle",{cx:"19",cy:"12",r:"1"}),l.jsx("circle",{cx:"5",cy:"12",r:"1"})]}),Or=e=>l.jsx(we,{...e,children:l.jsx("path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3"})}),ev=e=>l.jsxs(we,{...e,children:[l.jsx("path",{d:"M15 3h6v6"}),l.jsx("path",{d:"M10 14 21 3"}),l.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"})]}),Gc=e=>l.jsxs(we,{...e,children:[l.jsx("circle",{cx:"12",cy:"18",r:"3"}),l.jsx("circle",{cx:"6",cy:"6",r:"3"}),l.jsx("circle",{cx:"18",cy:"6",r:"3"}),l.jsx("path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9"}),l.jsx("path",{d:"M12 12v3"})]}),Zn=e=>l.jsxs(we,{...e,children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20M2 12h20"})]}),tv=e=>l.jsxs(we,{...e,children:[l.jsx("rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2"}),l.jsx("path",{d:"M12 18h.01"})]}),nv=e=>l.jsx(we,{...e,children:l.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})});function Ui({size:e=28,className:t}){return l.jsx("img",{src:"/logos/linkshell.png",alt:"LinkShell",width:e,height:e,className:`rounded-lg object-contain ${t??""}`,style:{width:e,height:e}})}function Xt({provider:e,size:t=14,className:n}){const r=e==="codex"?"/logos/codex.png":e==="claude"?"/logos/claude.png":e==="gemini"?"/logos/gemini.png":e==="copilot"?"/logos/copilot.png":null;return r?l.jsx("img",{src:r,alt:e,width:t,height:t,className:`shrink-0 rounded-sm object-contain ${n??""}`,style:{width:t,height:t}}):l.jsx(qi,{size:t,className:n??"text-content-faint"})}function eu({onLogin:e,onCancel:t}){const[n,r]=v.useState(""),[i,s]=v.useState(""),[a,o]=v.useState(null),[c,u]=v.useState(!1),[f,d]=v.useState(null),p=async m=>{m.preventDefault(),u(!0),o(null);const b=await qc(n,i);u(!1),b.error?o(b.error):b.session&&e(b.session)},h=async()=>{u(!0),o(null),d(null);const m=await Vc(n,i);u(!1),m.error?o(m.error):m.session?e(m.session):d("请查收邮件以确认账户。")};return l.jsx("div",{className:"flex min-h-screen items-center justify-center px-4",children:l.jsxs("div",{className:"w-full max-w-sm space-y-6",children:[l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"mx-auto mb-3 flex items-center justify-center",children:l.jsx(Ui,{size:56})}),l.jsx("h1",{className:"font-mono text-xl font-bold text-content-primary",children:"LinkShell"}),l.jsx("p",{className:"mt-1 text-sm text-content-muted",children:"登录以连接你的 agent 会话"})]}),l.jsxs("form",{onSubmit:p,className:"space-y-3",children:[l.jsx("input",{type:"email",placeholder:"邮箱",value:n,onChange:m=>r(m.target.value),required:!0,className:"codex-input",autoComplete:"email"}),l.jsx("input",{type:"password",placeholder:"密码",value:i,onChange:m=>s(m.target.value),required:!0,minLength:6,className:"codex-input",autoComplete:"current-password"}),a&&l.jsx("p",{className:"text-sm text-danger",children:a}),f&&l.jsx("p",{className:"text-sm text-success",children:f}),l.jsx("button",{type:"submit",disabled:c,className:"codex-btn-primary w-full",children:c?"…":"登录"}),l.jsx("button",{type:"button",onClick:h,disabled:c||!n||!i,className:"codex-btn-outline w-full",children:"创建账户"}),t&&l.jsx("button",{type:"button",onClick:t,className:"codex-btn-ghost w-full",children:"暂不登录,用配对码连接"})]}),l.jsx("p",{className:"text-center text-2xs text-content-faint",children:"登录可选 · Pro 账户登录后免扫码直接看到自己的会话"})]})})}function gr(e){return e.httpUrl.replace(/\/+$/,"")}function _o(e){return e.wsUrl?e.wsUrl.replace(/\/+$/,""):gr(e).replace(/^http/,"ws")}function tu(e){const t={},n=e.jwt??e.deviceToken;return n&&(t.Authorization=`Bearer ${n}`),t}function nu(e,t){if(!t.deviceToken)return e;const n=new URL(e);return n.searchParams.set("token",t.deviceToken),n.toString()}async function ru(e,t){const n=await fetch(`${gr(e)}/pairings/claim`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pairingCode:t,deviceToken:Yn()??void 0})});if(!n.ok){const i=await n.json().catch(()=>null);throw new Error((i==null?void 0:i.error)||`配对失败 (HTTP ${n.status})`)}const r=await n.json();return r.deviceToken&&Di(r.deviceToken),r}async function iu(e,t){const n=await fetch(nu(`${gr(e)}/sessions`,t),{headers:tu(t)});return n.ok?(await n.json()).sessions??[]:[]}async function su(e,t){if(!t)return[];const n=await fetch(`${gr(e)}/sessions/mine`,{headers:{Authorization:`Bearer ${t}`}});return n.ok?(await n.json()).sessions??[]:[]}function au(e,t){const n=new URL(`${_o(e)}/ws`);return n.searchParams.set("sessionId",t.sessionId),n.searchParams.set("role","client"),n.searchParams.set("deviceId",t.deviceId),t.deviceToken&&n.searchParams.set("token",t.deviceToken),t.jwt&&n.searchParams.set("auth_token",t.jwt),n.toString()}function ou(e,t){const n=new URL(`${_o(e)}/ws`);return n.searchParams.set("role","watcher"),t.deviceToken&&n.searchParams.set("token",t.deviceToken),t.jwt&&n.searchParams.set("auth_token",t.jwt),n.toString()}var ve;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},e.getValidEnumValues=i=>{const s=e.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return e.objectValues(a)},e.objectValues=i=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},e.find=(i,s)=>{for(const a of i)if(s(a))return a},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(ve||(ve={}));var Ms;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Ms||(Ms={}));const H=ve.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),_t=e=>{switch(typeof e){case"undefined":return H.undefined;case"string":return H.string;case"number":return Number.isNaN(e)?H.nan:H.number;case"boolean":return H.boolean;case"function":return H.function;case"bigint":return H.bigint;case"symbol":return H.symbol;case"object":return Array.isArray(e)?H.array:e===null?H.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?H.promise:typeof Map<"u"&&e instanceof Map?H.map:typeof Set<"u"&&e instanceof Set?H.set:typeof Date<"u"&&e instanceof Date?H.date:H.object;default:return H.unknown}},D=ve.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class ht extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let o=r,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(n(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return i(this),r}static assert(t){if(!(t instanceof ht))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ve.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const i of this.issues)if(i.path.length>0){const s=i.path[0];n[s]=n[s]||[],n[s].push(t(i))}else r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}ht.create=e=>new ht(e);const hi=(e,t)=>{let n;switch(e.code){case D.invalid_type:e.received===H.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case D.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,ve.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:n=`Unrecognized key(s) in object: ${ve.joinValues(e.keys,", ")}`;break;case D.invalid_union:n="Invalid input";break;case D.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${ve.joinValues(e.options)}`;break;case D.invalid_enum_value:n=`Invalid enum value. Expected ${ve.joinValues(e.options)}, received '${e.received}'`;break;case D.invalid_arguments:n="Invalid function arguments";break;case D.invalid_return_type:n="Invalid function return type";break;case D.invalid_date:n="Invalid date";break;case D.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:ve.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case D.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case D.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case D.custom:n="Invalid input";break;case D.invalid_intersection_types:n="Intersection results could not be merged";break;case D.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case D.not_finite:n="Number must be finite";break;default:n=t.defaultError,ve.assertNever(e)}return{message:n}};let lu=hi;function cu(){return lu}const uu=e=>{const{data:t,path:n,errorMaps:r,issueData:i}=e,s=[...n,...i.path||[]],a={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let o="";const c=r.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:t,defaultError:o}).message;return{...i,path:s,message:o}};function B(e,t){const n=cu(),r=uu({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===hi?void 0:hi].filter(i=>!!i)});e.common.issues.push(r)}class Ue{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const i of n){if(i.status==="aborted")return re;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const i of n){const s=await i.key,a=await i.value;r.push({key:s,value:a})}return Ue.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const i of n){const{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return re;s.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(r[s.value]=a.value)}return{status:t.value,value:r}}}const re=Object.freeze({status:"aborted"}),bn=e=>({status:"dirty",value:e}),rt=e=>({status:"valid",value:e}),Rs=e=>e.status==="aborted",Ls=e=>e.status==="dirty",en=e=>e.status==="valid",Gn=e=>typeof Promise<"u"&&e instanceof Promise;var W;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(W||(W={}));class pt{constructor(t,n,r,i){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ds=(e,t)=>{if(en(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new ht(e.common.issues);return this._error=n,this._error}}};function ce(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(a,o)=>{const{message:c}=e;return a.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??r??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:c??n??o.defaultError}},description:i}}class ye{get description(){return this._def.description}_getType(t){return _t(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:_t(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Ue,ctx:{common:t.parent.common,data:t.data,parsedType:_t(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(Gn(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:_t(t)},i=this._parseSync({data:t,path:r.path,parent:r});return Ds(r,i)}"~validate"(t){var r,i;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:_t(t)};if(!this["~standard"].async)try{const s=this._parseSync({data:t,path:[],parent:n});return en(s)?{value:s.value}:{issues:n.common.issues}}catch(s){(i=(r=s==null?void 0:s.message)==null?void 0:r.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(s=>en(s)?{value:s.value}:{issues:n.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:_t(t)},i=this._parse({data:t,path:r.path,parent:r}),s=await(Gn(i)?i:Promise.resolve(i));return Ds(r,s)}refine(t,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,s)=>{const a=t(i),o=()=>s.addIssue({code:D.custom,...r(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(t,n){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(t){return new rn({schema:this,typeName:te.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Ct.create(this,this._def)}nullable(){return sn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ft.create(this)}promise(){return ir.create(this,this._def)}or(t){return tr.create([this,t],this._def)}and(t){return nr.create(this,t,this._def)}transform(t){return new rn({...ce(this._def),schema:this,typeName:te.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new yi({...ce(this._def),innerType:this,defaultValue:n,typeName:te.ZodDefault})}brand(){return new Mu({typeName:te.ZodBranded,type:this,...ce(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new bi({...ce(this._def),innerType:this,catchValue:n,typeName:te.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return Hi.create(this,t)}readonly(){return ki.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const du=/^c[^\s-]{8,}$/i,fu=/^[0-9a-z]+$/,hu=/^[0-9A-HJKMNP-TV-Z]{26}$/i,pu=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,mu=/^[a-z0-9_-]{21}$/i,gu=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,xu=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,yu=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,bu="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Fr;const ku=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,vu=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,wu=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Su=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,_u=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ju=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,jo="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Cu=new RegExp(`^${jo}$`);function Co(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function Nu(e){return new RegExp(`^${Co(e)}$`)}function Iu(e){let t=`${jo}T${Co(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function Tu(e,t){return!!((t==="v4"||!t)&&ku.test(e)||(t==="v6"||!t)&&wu.test(e))}function Au(e,t){if(!gu.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function Eu(e,t){return!!((t==="v4"||!t)&&vu.test(e)||(t==="v6"||!t)&&Su.test(e))}class gt extends ye{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==H.string){const s=this._getOrReturnCtx(t);return B(s,{code:D.invalid_type,expected:H.string,received:s.parsedType}),re}const r=new Ue;let i;for(const s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),B(i,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),B(i,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){const a=t.data.length>s.value,o=t.data.length<s.value;(a||o)&&(i=this._getOrReturnCtx(t,i),a?B(i,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&B(i,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")yu.test(t.data)||(i=this._getOrReturnCtx(t,i),B(i,{validation:"email",code:D.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Fr||(Fr=new RegExp(bu,"u")),Fr.test(t.data)||(i=this._getOrReturnCtx(t,i),B(i,{validation:"emoji",code:D.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")pu.test(t.data)||(i=this._getOrReturnCtx(t,i),B(i,{validation:"uuid",code:D.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")mu.test(t.data)||(i=this._getOrReturnCtx(t,i),B(i,{validation:"nanoid",code:D.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")du.test(t.data)||(i=this._getOrReturnCtx(t,i),B(i,{validation:"cuid",code:D.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")fu.test(t.data)||(i=this._getOrReturnCtx(t,i),B(i,{validation:"cuid2",code:D.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")hu.test(t.data)||(i=this._getOrReturnCtx(t,i),B(i,{validation:"ulid",code:D.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),B(i,{validation:"url",code:D.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),B(i,{validation:"regex",code:D.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),B(i,{code:D.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),B(i,{code:D.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),B(i,{code:D.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?Iu(s).test(t.data)||(i=this._getOrReturnCtx(t,i),B(i,{code:D.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?Cu.test(t.data)||(i=this._getOrReturnCtx(t,i),B(i,{code:D.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?Nu(s).test(t.data)||(i=this._getOrReturnCtx(t,i),B(i,{code:D.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?xu.test(t.data)||(i=this._getOrReturnCtx(t,i),B(i,{validation:"duration",code:D.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?Tu(t.data,s.version)||(i=this._getOrReturnCtx(t,i),B(i,{validation:"ip",code:D.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?Au(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),B(i,{validation:"jwt",code:D.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?Eu(t.data,s.version)||(i=this._getOrReturnCtx(t,i),B(i,{validation:"cidr",code:D.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?_u.test(t.data)||(i=this._getOrReturnCtx(t,i),B(i,{validation:"base64",code:D.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?ju.test(t.data)||(i=this._getOrReturnCtx(t,i),B(i,{validation:"base64url",code:D.invalid_string,message:s.message}),r.dirty()):ve.assertNever(s);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:D.invalid_string,...W.errToObj(r)})}_addCheck(t){return new gt({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...W.errToObj(t)})}url(t){return this._addCheck({kind:"url",...W.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...W.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...W.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...W.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...W.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...W.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...W.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...W.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...W.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...W.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...W.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...W.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...W.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...W.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...W.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...W.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...W.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...W.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...W.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...W.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...W.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...W.errToObj(n)})}nonempty(t){return this.min(1,W.errToObj(t))}trim(){return new gt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new gt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new gt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}gt.create=e=>new gt({checks:[],typeName:te.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...ce(e)});function Pu(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r,s=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return s%a/10**i}class tn extends ye{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==H.number){const s=this._getOrReturnCtx(t);return B(s,{code:D.invalid_type,expected:H.number,received:s.parsedType}),re}let r;const i=new Ue;for(const s of this._def.checks)s.kind==="int"?ve.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),B(r,{code:D.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),B(r,{code:D.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),B(r,{code:D.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?Pu(t.data,s.value)!==0&&(r=this._getOrReturnCtx(t,r),B(r,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),B(r,{code:D.not_finite,message:s.message}),i.dirty()):ve.assertNever(s);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,W.toString(n))}gt(t,n){return this.setLimit("min",t,!1,W.toString(n))}lte(t,n){return this.setLimit("max",t,!0,W.toString(n))}lt(t,n){return this.setLimit("max",t,!1,W.toString(n))}setLimit(t,n,r,i){return new tn({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:W.toString(i)}]})}_addCheck(t){return new tn({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:W.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:W.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:W.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:W.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:W.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:W.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:W.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:W.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:W.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&ve.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}tn.create=e=>new tn({checks:[],typeName:te.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...ce(e)});class jn extends ye{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==H.bigint)return this._getInvalidInput(t);let r;const i=new Ue;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),B(r,{code:D.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),B(r,{code:D.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),B(r,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):ve.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return B(n,{code:D.invalid_type,expected:H.bigint,received:n.parsedType}),re}gte(t,n){return this.setLimit("min",t,!0,W.toString(n))}gt(t,n){return this.setLimit("min",t,!1,W.toString(n))}lte(t,n){return this.setLimit("max",t,!0,W.toString(n))}lt(t,n){return this.setLimit("max",t,!1,W.toString(n))}setLimit(t,n,r,i){return new jn({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:W.toString(i)}]})}_addCheck(t){return new jn({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:W.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:W.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:W.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:W.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:W.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}jn.create=e=>new jn({checks:[],typeName:te.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...ce(e)});class pi extends ye{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==H.boolean){const r=this._getOrReturnCtx(t);return B(r,{code:D.invalid_type,expected:H.boolean,received:r.parsedType}),re}return rt(t.data)}}pi.create=e=>new pi({typeName:te.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...ce(e)});class er extends ye{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==H.date){const s=this._getOrReturnCtx(t);return B(s,{code:D.invalid_type,expected:H.date,received:s.parsedType}),re}if(Number.isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return B(s,{code:D.invalid_date}),re}const r=new Ue;let i;for(const s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),B(i,{code:D.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),B(i,{code:D.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):ve.assertNever(s);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new er({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:W.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:W.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}er.create=e=>new er({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:te.ZodDate,...ce(e)});class zs extends ye{_parse(t){if(this._getType(t)!==H.symbol){const r=this._getOrReturnCtx(t);return B(r,{code:D.invalid_type,expected:H.symbol,received:r.parsedType}),re}return rt(t.data)}}zs.create=e=>new zs({typeName:te.ZodSymbol,...ce(e)});class Os extends ye{_parse(t){if(this._getType(t)!==H.undefined){const r=this._getOrReturnCtx(t);return B(r,{code:D.invalid_type,expected:H.undefined,received:r.parsedType}),re}return rt(t.data)}}Os.create=e=>new Os({typeName:te.ZodUndefined,...ce(e)});class Fs extends ye{_parse(t){if(this._getType(t)!==H.null){const r=this._getOrReturnCtx(t);return B(r,{code:D.invalid_type,expected:H.null,received:r.parsedType}),re}return rt(t.data)}}Fs.create=e=>new Fs({typeName:te.ZodNull,...ce(e)});class $s extends ye{constructor(){super(...arguments),this._any=!0}_parse(t){return rt(t.data)}}$s.create=e=>new $s({typeName:te.ZodAny,...ce(e)});class mi extends ye{constructor(){super(...arguments),this._unknown=!0}_parse(t){return rt(t.data)}}mi.create=e=>new mi({typeName:te.ZodUnknown,...ce(e)});class Nt extends ye{_parse(t){const n=this._getOrReturnCtx(t);return B(n,{code:D.invalid_type,expected:H.never,received:n.parsedType}),re}}Nt.create=e=>new Nt({typeName:te.ZodNever,...ce(e)});class Bs extends ye{_parse(t){if(this._getType(t)!==H.undefined){const r=this._getOrReturnCtx(t);return B(r,{code:D.invalid_type,expected:H.void,received:r.parsedType}),re}return rt(t.data)}}Bs.create=e=>new Bs({typeName:te.ZodVoid,...ce(e)});class ft extends ye{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==H.array)return B(n,{code:D.invalid_type,expected:H.array,received:n.parsedType}),re;if(i.exactLength!==null){const a=n.data.length>i.exactLength.value,o=n.data.length<i.exactLength.value;(a||o)&&(B(n,{code:a?D.too_big:D.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(B(n,{code:D.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(B(n,{code:D.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,o)=>i.type._parseAsync(new pt(n,a,n.path,o)))).then(a=>Ue.mergeArray(r,a));const s=[...n.data].map((a,o)=>i.type._parseSync(new pt(n,a,n.path,o)));return Ue.mergeArray(r,s)}get element(){return this._def.type}min(t,n){return new ft({...this._def,minLength:{value:t,message:W.toString(n)}})}max(t,n){return new ft({...this._def,maxLength:{value:t,message:W.toString(n)}})}length(t,n){return new ft({...this._def,exactLength:{value:t,message:W.toString(n)}})}nonempty(t){return this.min(1,t)}}ft.create=(e,t)=>new ft({type:e,minLength:null,maxLength:null,exactLength:null,typeName:te.ZodArray,...ce(t)});function Wt(e){if(e instanceof Re){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Ct.create(Wt(r))}return new Re({...e._def,shape:()=>t})}else return e instanceof ft?new ft({...e._def,type:Wt(e.element)}):e instanceof Ct?Ct.create(Wt(e.unwrap())):e instanceof sn?sn.create(Wt(e.unwrap())):e instanceof Lt?Lt.create(e.items.map(t=>Wt(t))):e}class Re extends ye{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=ve.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==H.object){const u=this._getOrReturnCtx(t);return B(u,{code:D.invalid_type,expected:H.object,received:u.parsedType}),re}const{status:r,ctx:i}=this._processInputParams(t),{shape:s,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Nt&&this._def.unknownKeys==="strip"))for(const u in i.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const f=s[u],d=i.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new pt(i,d,i.path,u)),alwaysSet:u in i.data})}if(this._def.catchall instanceof Nt){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:i.data[f]}});else if(u==="strict")o.length>0&&(B(i,{code:D.unrecognized_keys,keys:o}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of o){const d=i.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new pt(i,d,i.path,f)),alwaysSet:f in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of c){const d=await f.key,p=await f.value;u.push({key:d,value:p,alwaysSet:f.alwaysSet})}return u}).then(u=>Ue.mergeObjectSync(r,u)):Ue.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(t){return W.errToObj,new Re({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var s,a;const i=((a=(s=this._def).errorMap)==null?void 0:a.call(s,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:W.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new Re({...this._def,unknownKeys:"strip"})}passthrough(){return new Re({...this._def,unknownKeys:"passthrough"})}extend(t){return new Re({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Re({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:te.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Re({...this._def,catchall:t})}pick(t){const n={};for(const r of ve.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new Re({...this._def,shape:()=>n})}omit(t){const n={};for(const r of ve.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new Re({...this._def,shape:()=>n})}deepPartial(){return Wt(this)}partial(t){const n={};for(const r of ve.objectKeys(this.shape)){const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}return new Re({...this._def,shape:()=>n})}required(t){const n={};for(const r of ve.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Ct;)s=s._def.innerType;n[r]=s}return new Re({...this._def,shape:()=>n})}keyof(){return No(ve.objectKeys(this.shape))}}Re.create=(e,t)=>new Re({shape:()=>e,unknownKeys:"strip",catchall:Nt.create(),typeName:te.ZodObject,...ce(t)});Re.strictCreate=(e,t)=>new Re({shape:()=>e,unknownKeys:"strict",catchall:Nt.create(),typeName:te.ZodObject,...ce(t)});Re.lazycreate=(e,t)=>new Re({shape:e,unknownKeys:"strip",catchall:Nt.create(),typeName:te.ZodObject,...ce(t)});class tr extends ye{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function i(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return n.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(o=>new ht(o.ctx.common.issues));return B(n,{code:D.invalid_union,unionErrors:a}),re}if(n.common.async)return Promise.all(r.map(async s=>{const a={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(i);{let s;const a=[];for(const c of r){const u={...n,common:{...n.common,issues:[]},parent:null},f=c._parseSync({data:n.data,path:n.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!s&&(s={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(c=>new ht(c));return B(n,{code:D.invalid_union,unionErrors:o}),re}}get options(){return this._def.options}}tr.create=(e,t)=>new tr({options:e,typeName:te.ZodUnion,...ce(t)});function gi(e,t){const n=_t(e),r=_t(t);if(e===t)return{valid:!0,data:e};if(n===H.object&&r===H.object){const i=ve.objectKeys(t),s=ve.objectKeys(e).filter(o=>i.indexOf(o)!==-1),a={...e,...t};for(const o of s){const c=gi(e[o],t[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(n===H.array&&r===H.array){if(e.length!==t.length)return{valid:!1};const i=[];for(let s=0;s<e.length;s++){const a=e[s],o=t[s],c=gi(a,o);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return n===H.date&&r===H.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class nr extends ye{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(s,a)=>{if(Rs(s)||Rs(a))return re;const o=gi(s.value,a.value);return o.valid?((Ls(s)||Ls(a))&&n.dirty(),{status:n.value,value:o.data}):(B(r,{code:D.invalid_intersection_types}),re)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}nr.create=(e,t,n)=>new nr({left:e,right:t,typeName:te.ZodIntersection,...ce(n)});class Lt extends ye{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==H.array)return B(r,{code:D.invalid_type,expected:H.array,received:r.parsedType}),re;if(r.data.length<this._def.items.length)return B(r,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),re;!this._def.rest&&r.data.length>this._def.items.length&&(B(r,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const s=[...r.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new pt(r,a,r.path,o)):null}).filter(a=>!!a);return r.common.async?Promise.all(s).then(a=>Ue.mergeArray(n,a)):Ue.mergeArray(n,s)}get items(){return this._def.items}rest(t){return new Lt({...this._def,rest:t})}}Lt.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Lt({items:e,typeName:te.ZodTuple,rest:null,...ce(t)})};class rr extends ye{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==H.object)return B(r,{code:D.invalid_type,expected:H.object,received:r.parsedType}),re;const i=[],s=this._def.keyType,a=this._def.valueType;for(const o in r.data)i.push({key:s._parse(new pt(r,o,r.path,o)),value:a._parse(new pt(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?Ue.mergeObjectAsync(n,i):Ue.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof ye?new rr({keyType:t,valueType:n,typeName:te.ZodRecord,...ce(r)}):new rr({keyType:gt.create(),valueType:t,typeName:te.ZodRecord,...ce(n)})}}class qs extends ye{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==H.map)return B(r,{code:D.invalid_type,expected:H.map,received:r.parsedType}),re;const i=this._def.keyType,s=this._def.valueType,a=[...r.data.entries()].map(([o,c],u)=>({key:i._parse(new pt(r,o,r.path,[u,"key"])),value:s._parse(new pt(r,c,r.path,[u,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return re;(u.status==="dirty"||f.status==="dirty")&&n.dirty(),o.set(u.value,f.value)}return{status:n.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return re;(u.status==="dirty"||f.status==="dirty")&&n.dirty(),o.set(u.value,f.value)}return{status:n.value,value:o}}}}qs.create=(e,t,n)=>new qs({valueType:t,keyType:e,typeName:te.ZodMap,...ce(n)});class Cn extends ye{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==H.set)return B(r,{code:D.invalid_type,expected:H.set,received:r.parsedType}),re;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(B(r,{code:D.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(B(r,{code:D.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const s=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return re;f.status==="dirty"&&n.dirty(),u.add(f.value)}return{status:n.value,value:u}}const o=[...r.data.values()].map((c,u)=>s._parse(new pt(r,c,r.path,u)));return r.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(t,n){return new Cn({...this._def,minSize:{value:t,message:W.toString(n)}})}max(t,n){return new Cn({...this._def,maxSize:{value:t,message:W.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Cn.create=(e,t)=>new Cn({valueType:e,minSize:null,maxSize:null,typeName:te.ZodSet,...ce(t)});class Vs extends ye{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Vs.create=(e,t)=>new Vs({getter:e,typeName:te.ZodLazy,...ce(t)});class xi extends ye{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return B(n,{received:n.data,code:D.invalid_literal,expected:this._def.value}),re}return{status:"valid",value:t.data}}get value(){return this._def.value}}xi.create=(e,t)=>new xi({value:e,typeName:te.ZodLiteral,...ce(t)});function No(e,t){return new nn({values:e,typeName:te.ZodEnum,...ce(t)})}class nn extends ye{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return B(n,{expected:ve.joinValues(r),received:n.parsedType,code:D.invalid_type}),re}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return B(n,{received:n.data,code:D.invalid_enum_value,options:r}),re}return rt(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return nn.create(t,{...this._def,...n})}exclude(t,n=this._def){return nn.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}nn.create=No;class Us extends ye{_parse(t){const n=ve.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==H.string&&r.parsedType!==H.number){const i=ve.objectValues(n);return B(r,{expected:ve.joinValues(i),received:r.parsedType,code:D.invalid_type}),re}if(this._cache||(this._cache=new Set(ve.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const i=ve.objectValues(n);return B(r,{received:r.data,code:D.invalid_enum_value,options:i}),re}return rt(t.data)}get enum(){return this._def.values}}Us.create=(e,t)=>new Us({values:e,typeName:te.ZodNativeEnum,...ce(t)});class ir extends ye{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==H.promise&&n.common.async===!1)return B(n,{code:D.invalid_type,expected:H.promise,received:n.parsedType}),re;const r=n.parsedType===H.promise?n.data:Promise.resolve(n.data);return rt(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}ir.create=(e,t)=>new ir({type:e,typeName:te.ZodPromise,...ce(t)});class rn extends ye{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===te.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:a=>{B(r,a),a.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const a=i.transform(r.data,s);if(r.common.async)return Promise.resolve(a).then(async o=>{if(n.value==="aborted")return re;const c=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return c.status==="aborted"?re:c.status==="dirty"||n.value==="dirty"?bn(c.value):c});{if(n.value==="aborted")return re;const o=this._def.schema._parseSync({data:a,path:r.path,parent:r});return o.status==="aborted"?re:o.status==="dirty"||n.value==="dirty"?bn(o.value):o}}if(i.type==="refinement"){const a=o=>{const c=i.refinement(o,s);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?re:(o.status==="dirty"&&n.dirty(),a(o.value),{status:n.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?re:(o.status==="dirty"&&n.dirty(),a(o.value).then(()=>({status:n.value,value:o.value}))))}if(i.type==="transform")if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!en(a))return re;const o=i.transform(a.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>en(a)?Promise.resolve(i.transform(a.value,s)).then(o=>({status:n.value,value:o})):re);ve.assertNever(i)}}rn.create=(e,t,n)=>new rn({schema:e,typeName:te.ZodEffects,effect:t,...ce(n)});rn.createWithPreprocess=(e,t,n)=>new rn({schema:t,effect:{type:"preprocess",transform:e},typeName:te.ZodEffects,...ce(n)});class Ct extends ye{_parse(t){return this._getType(t)===H.undefined?rt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Ct.create=(e,t)=>new Ct({innerType:e,typeName:te.ZodOptional,...ce(t)});class sn extends ye{_parse(t){return this._getType(t)===H.null?rt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}sn.create=(e,t)=>new sn({innerType:e,typeName:te.ZodNullable,...ce(t)});class yi extends ye{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===H.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}yi.create=(e,t)=>new yi({innerType:e,typeName:te.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ce(t)});class bi extends ye{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Gn(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ht(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ht(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}bi.create=(e,t)=>new bi({innerType:e,typeName:te.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ce(t)});class Hs extends ye{_parse(t){if(this._getType(t)!==H.nan){const r=this._getOrReturnCtx(t);return B(r,{code:D.invalid_type,expected:H.nan,received:r.parsedType}),re}return{status:"valid",value:t.data}}}Hs.create=e=>new Hs({typeName:te.ZodNaN,...ce(e)});class Mu extends ye{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class Hi extends ye{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?re:s.status==="dirty"?(n.dirty(),bn(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?re:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,n){return new Hi({in:t,out:n,typeName:te.ZodPipeline})}}class ki extends ye{_parse(t){const n=this._def.innerType._parse(t),r=i=>(en(i)&&(i.value=Object.freeze(i.value)),i);return Gn(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}ki.create=(e,t)=>new ki({innerType:e,typeName:te.ZodReadonly,...ce(t)});var te;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(te||(te={}));const g=gt.create,V=tn.create,he=pi.create,xr=mi.create;Nt.create;const pe=ft.create,T=Re.create;tr.create;nr.create;Lt.create;const yt=rr.create,Io=xi.create,ue=nn.create;ir.create;Ct.create;sn.create;const Ru=1,To=1048576,Lu=4194304,Du=8388608,Ao=8388608,zu=1048576,Ou=8388608,Fu=8192,$u=16,Bu=ue(["host","client"]);ue(["pending_pairing","connecting","active","reconnecting","idle","terminated"]);const Wi=ue(["claude","codex","gemini","copilot","custom"]);ue(["session_not_found","pairing_expired","pairing_not_found","control_conflict","session_terminated","ack_out_of_range","invalid_message","unauthorized"]);const qu=T({id:g().min(1),type:g().min(1),sessionId:g().min(1),terminalId:g().min(1).optional(),deviceId:g().min(1).optional(),timestamp:g().datetime(),traceId:g().min(1).optional(),seq:V().int().nonnegative().optional(),ack:V().int().nonnegative().optional(),payload:xr()}),Vu=T({stream:ue(["stdout","stderr"]),data:g().max(To),encoding:Io("utf8").default("utf8"),isReplay:he().default(!1),isFinal:he().default(!1)}),Uu=T({data:g().max(To)}),Hu=T({cols:V().int().positive(),rows:V().int().positive()}),Wu=T({role:Bu,clientName:g().min(1),provider:Wi.optional(),protocolVersion:V().int().optional(),machineId:g().min(1).optional(),hostname:g().optional(),platform:g().optional(),cwd:g().optional(),projectName:g().optional()}),Zu=T({exitCode:V().int().nullable(),signal:V().int().nullable().optional()}),Qu=T({seq:V().int().nonnegative()}),Ku=T({lastAckedSeq:V().int().min(-1).optional().default(-1),lastAckedSeqByTerminal:yt(V().int().min(-1)).optional().default({}),machineId:g().min(1).optional()}),Yu=T({ts:V()}),Xu=T({pairingCode:g().regex(/^\d{6}$/),sessionId:g().min(1),expiresAt:g().datetime()}),Ju=T({pairingCode:g().regex(/^\d{6}$/)}),Gu=T({sessionId:g().min(1)}),ed=T({deviceId:g().min(1)}),td=T({deviceId:g().min(1)}),nd=T({deviceId:g().min(1),reason:g().min(1)}),rd=T({deviceId:g().min(1)}),id=T({reason:g().optional()}),sd=T({}),ad=T({fps:V().int().min(1).max(30).default(5),quality:V().int().min(10).max(100).default(60),scale:V().min(.1).max(1).default(.5)}),od=T({}),ld=T({data:g().max(Lu),width:V().int(),height:V().int(),frameId:V().int(),chunkIndex:V().int().default(0),chunkTotal:V().int().default(1)}),cd=T({active:he(),mode:ue(["webrtc","fallback","off"]).default("off"),error:g().optional()}),ud=T({sdp:g()}),dd=T({sdp:g()}),fd=T({candidate:g(),sdpMid:g().nullable().optional(),sdpMLineIndex:V().nullable().optional()}),hd=T({cwd:g().min(1),provider:Wi.optional(),forceNew:he().optional()}),pd=T({terminalId:g().min(1),cwd:g(),projectName:g(),provider:g(),status:ue(["running","exited"])}),md=T({terminals:pe(pd)}),gd=T({terminalId:g().min(1),cwd:g(),projectName:g(),provider:g().optional()}),xd=T({terminalId:g().min(1)}),yd=T({path:g().min(1)}),bd=T({path:g().min(1),includeFiles:he().optional().default(!1),requestId:g().min(1).optional()}),kd=T({name:g(),path:g(),isDirectory:he(),size:V().int().nonnegative().optional(),modifiedAt:g().datetime().optional()}),vd=T({path:g(),entries:pe(kd),error:g().optional(),requestId:g().min(1).optional()}),wd=T({path:g().min(1),maxBytes:V().int().positive().max(1e6).optional().default(256e3),requestId:g().min(1).optional()}),Sd=T({path:g(),content:g().default(""),encoding:Io("utf8").default("utf8"),size:V().int().nonnegative().optional(),truncated:he().default(!1),error:g().optional(),requestId:g().min(1).optional()}),_d=T({phase:ue(["thinking","tool_use","outputting","waiting","idle","error"]),provider:Wi.optional(),seq:V().optional(),toolName:g().optional(),toolInput:g().optional(),permissionRequest:g().optional(),summary:g().optional(),topPermission:T({requestId:g(),toolName:g(),toolInput:g(),permissionRequest:g(),timestamp:V()}).optional(),permissionResolution:T({requestId:g(),outcome:ue(["allow","deny","cancelled"]),source:g().optional(),delivered:he()}).optional(),pendingPermissionCount:V().optional(),machineId:g().min(1).optional()}),jd=T({data:g().max(Du),filename:g().min(1).refine(e=>!e.includes("..")&&!e.startsWith("/"),"invalid filename")}),Cd=T({requestId:g().min(1),decision:ue(["allow","deny"])}),Nd=T({requestId:g().min(1),decision:ue(["allow","deny"]),resolved:he(),delivered:he(),source:g().optional(),message:g().optional()}),Id=T({code:g().min(1),message:g().min(1)}),Td=T({requestId:g().min(1),method:g().min(1).max($u),url:g().max(Fu),headers:yt(g()),body:g().max(Ao).nullable(),port:V().int().min(1).max(65535)}),Ad=T({requestId:g().min(1),statusCode:V().int(),headers:yt(g()),body:g().max(Ao),isFinal:he()}),Ed=T({requestId:g().min(1),data:g().max(zu),isBinary:he()}),Pd=T({requestId:g().min(1),code:V().int().optional(),reason:g().optional()}),Md=T({count:V().int().min(1).max(500).default(100)}),Rd=T({entries:pe(g()),shell:g().optional()}),It=g().min(1),ln=ue(["none","minimal","low","medium","high","xhigh"]),cn=ue(["read_only","workspace_write","full_access"]),yr=ue(["default","plan"]),br=T({type:ue(["text","image"]),text:g().optional(),data:g().max(Ou).optional(),mimeType:g().optional()}),Eo=T({id:g().min(1),role:ue(["user","assistant","system"]),content:g(),createdAt:V(),isStreaming:he().optional()}),kr=T({id:g().min(1),name:g().min(1),input:g().optional(),output:g().optional(),createdAt:V().optional(),status:ue(["pending","running","completed","failed"]).default("pending")}),En=T({requestId:g().min(1),toolName:g().optional(),toolInput:g().optional(),context:g().optional(),options:pe(T({id:g().min(1),label:g().min(1),kind:ue(["allow","deny","other"]).default("other")})).default([])}),Ld=T({id:g().min(1),label:g().min(1)}),Dd=T({id:g().min(1),name:g().min(1),title:g().min(1),description:g().optional(),provider:It.optional(),source:ue(["built_in","custom","project","user","linkshell"]).default("built_in"),category:g().optional(),argsMode:ue(["none","optional","required","raw"]).default("optional"),requiresIdle:he().optional(),destructive:he().optional(),disabledReason:g().optional(),executionKind:ue(["prompt","native","local_ui"]).default("prompt")}),zd=T({id:g().min(1),title:g().min(1),description:g().optional()}),Od=ue(["pending","connecting","connected","failed","needs_auth","disabled"]),Fd=T({name:g().min(1),status:Od,error:g().optional(),toolCount:V().int().optional()}),$d=T({id:It,label:g().min(1),enabled:he(),reason:g().optional(),supportsImages:he().optional(),supportsPermission:he().optional(),supportsPlan:he().optional(),supportsCancel:he().optional(),models:pe(Ld).optional(),defaultModel:g().min(1).optional(),reasoningEfforts:pe(ln).optional(),permissionModes:pe(cn).optional(),commands:pe(Dd).optional(),modes:pe(zd).optional(),currentMode:g().optional(),features:yt(he()).optional(),mcpServers:pe(Fd).optional()}),Zi=T({enabled:he(),provider:It.optional(),machineId:g().min(1).optional(),providers:pe($d).optional(),protocolVersion:V().int().optional(),error:g().optional(),supportsSessionList:he().default(!1),supportsSessionLoad:he().default(!1),supportsImages:he().default(!1),supportsAudio:he().default(!1),supportsPermission:he().default(!1),supportsPlan:he().default(!1),supportsCancel:he().default(!1)}),Bd=T({}),qd=T({cwd:g().optional(),provider:It.optional(),mcpServers:yt(xr()).optional()}),Vd=T({agentSessionId:g().min(1),cwd:g().optional()}),Ud=T({}),Hd=T({agentSessionId:g().optional(),clientMessageId:g().min(1),contentBlocks:pe(br).min(1),model:g().min(1).optional(),reasoningEffort:ln.optional(),permissionMode:cn.optional()}),Wd=T({agentSessionId:g().optional()}),Zd=T({agentSessionId:g().optional(),kind:ue(["message","message_delta","tool_call","tool_result","plan","status","error"]),message:Eo.optional(),delta:g().optional(),toolCall:kr.optional(),plan:pe(T({id:g().min(1),text:g().min(1),status:ue(["pending","in_progress","completed"])})).optional(),status:ue(["idle","running","waiting_permission","error"]).optional(),error:g().optional()}),Qd=En.extend({agentSessionId:g().optional()}),Kd=T({agentSessionId:g().optional(),requestId:g().min(1),outcome:ue(["allow","deny","cancelled"]),optionId:g().optional()}),Yd=T({agentSessionId:g().optional(),capabilities:Zi.optional(),messages:pe(Eo).default([]),toolCalls:pe(kr).default([]),pendingPermissions:pe(En).default([]),status:ue(["unavailable","idle","running","waiting_permission","error"]).default("unavailable"),error:g().optional()}),vr=ue(["unavailable","idle","running","waiting_permission","error"]),Po=ue(["chat","thinking","tool_activity","command_execution","file_change","subagent_action","plan","user_input_prompt","review","context_compaction"]),Xd=T({path:g().min(1),kind:g().optional(),added:V().int().nonnegative().optional(),removed:V().int().nonnegative().optional()}),Mo=T({entries:pe(Xd).default([]),diff:g().optional(),summary:g().optional(),changeSetId:g().optional(),status:ue(["pending","running","completed","failed"]).optional()}),Ro=T({command:g().optional(),cwd:g().optional(),output:g().optional(),exitCode:V().int().nullable().optional(),status:ue(["pending","running","completed","failed"]).optional()}),Jd=T({id:g().min(1),label:g().min(1),description:g().optional()}),Gd=T({id:g().min(1),header:g().optional(),question:g().min(1),isOther:he().optional(),isSecret:he().optional(),selectionLimit:V().int().positive().optional(),options:pe(Jd).optional()}),Lo=T({requestId:g().min(1),questions:pe(Gd).default([])}),ef=T({threadId:g().min(1),agentId:g().optional(),nickname:g().optional(),role:g().optional(),model:g().optional(),prompt:g().optional()}),tf=T({threadId:g().min(1),status:g().min(1),message:g().optional()}),Do=T({tool:g().min(1),status:g().min(1),prompt:g().optional(),model:g().optional(),receiverThreadIds:pe(g().min(1)).default([]),receiverAgents:pe(ef).default([]),agentStates:yt(tf).default({})}),Pn=T({id:g().min(1),conversationId:g().min(1),type:ue(["message","tool_call","plan","permission","status","error"]),kind:Po.optional(),turnId:g().optional(),itemId:g().optional(),role:ue(["user","assistant","system"]).optional(),content:pe(br).optional(),text:g().optional(),toolCall:kr.optional(),commandExecution:Ro.optional(),fileChange:Mo.optional(),subagent:Do.optional(),structuredInput:Lo.optional(),plan:pe(T({id:g().min(1),text:g().min(1),status:ue(["pending","in_progress","completed"])})).optional(),permission:En.optional(),status:vr.optional(),error:g().optional(),metadata:yt(xr()).optional(),createdAt:V(),updatedAt:V().optional(),isStreaming:he().optional()}),zo=T({inputTokens:V().optional(),outputTokens:V().optional(),cacheReadTokens:V().optional(),totalTokens:V().optional(),contextWindow:V().optional(),totalCostUsd:V().optional(),updatedAt:V().optional()}),wr=T({id:g().min(1),agentSessionId:g().optional(),provider:It.default("codex"),cwd:g(),workspaceRoots:pe(g()).optional(),group:g().optional(),title:g().optional(),model:g().optional(),reasoningEffort:ln.optional(),permissionMode:cn.optional(),collaborationMode:yr.optional(),control:ue(["owned","attached"]).default("owned"),status:vr.default("idle"),archived:he().default(!1),lastMessagePreview:g().optional(),lastActivityAt:V(),createdAt:V(),usage:zo.optional()}),nf=T({}),rf=Zi.extend({workspaceProtocolVersion:V().int().default(2)}),sf=T({conversationId:g().optional(),agentSessionId:g().optional(),cwd:g().optional(),provider:It.optional(),model:g().optional(),reasoningEffort:ln.optional(),permissionMode:cn.optional(),collaborationMode:yr.optional(),title:g().optional(),forkFromConversationId:g().optional(),forkFromTurnId:g().optional()}),af=T({conversation:wr,snapshot:pe(Pn).default([]),requestedConversationId:g().min(1).optional()}),of=T({includeArchived:he().optional().default(!1)}),lf=T({conversations:pe(wr)}),cf=T({conversationId:g().min(1),clientMessageId:g().min(1),contentBlocks:pe(br).min(1),delivery:ue(["auto","new_turn","steer"]).optional().default("auto"),targetTurnId:g().min(1).optional(),model:g().min(1).optional(),reasoningEffort:ln.optional(),permissionMode:cn.optional(),collaborationMode:yr.optional()}),uf=T({conversationId:g().min(1),commandId:g().min(1),rawText:g().optional(),args:g().optional(),clientMessageId:g().min(1)}),df=T({conversationId:g().min(1)}),ff=T({conversationId:g().min(1),requestId:g().min(1),outcome:ue(["allow","deny","cancelled"]),optionId:g().optional()}),hf=T({conversationId:g().min(1),requestId:g().min(1),answers:yt(pe(g()))}),pf=T({conversationId:g().optional()}),mf=T({conversations:pe(wr).default([]),activeConversationId:g().optional(),items:pe(Pn).default([]),machineId:g().min(1).optional()}),gf=T({conversationId:g().min(1),conversation:wr.optional(),item:Pn.optional(),patch:T({itemId:g().min(1),kind:Po.optional(),role:ue(["user","assistant","system"]).optional(),content:pe(br).optional(),text:g().optional(),textDelta:g().optional(),status:vr.optional(),toolCall:kr.optional(),commandExecution:Ro.optional(),fileChange:Mo.optional(),subagent:Do.optional(),structuredInput:Lo.optional(),plan:pe(T({id:g().min(1),text:g().min(1),status:ue(["pending","in_progress","completed"])})).optional(),permission:En.optional(),error:g().optional(),metadata:yt(xr()).optional(),updatedAt:V().optional(),isStreaming:he().optional()}).optional()}),xf=En.extend({conversationId:g().min(1),item:Pn.optional()}),yf=T({conversationId:g().optional(),kind:ue(["model_changed","effort_changed","permission_changed","native_unsupported","info","warning"]),title:g().min(1),detail:g().optional(),durationMs:V().int().positive().optional()}),bf=T({conversationId:g().min(1),cursor:g().optional(),limit:V().int().positive().max(200).optional().default(50)}),kf=T({conversationId:g().min(1),items:pe(Pn).default([]),nextCursor:g().optional(),hasMore:he().default(!1)}),Oo=T({inputTokens:V().default(0),outputTokens:V().default(0),cacheReadTokens:V().default(0),cacheWriteTokens:V().default(0),totalTokens:V().default(0),calls:V().default(0)}),$n=Oo.extend({key:g()}),vf=T({}),wf=T({totals:Oo,sessions:V().default(0),peakDayTokens:V().default(0),longestTaskMs:V().default(0),currentStreakDays:V().default(0),longestStreakDays:V().default(0),byDay:pe($n).default([]),byHourWeekday:pe(T({weekday:V(),hour:V(),tokens:V()})).default([]),byTool:pe($n).default([]),byModel:pe($n).default([]),byProject:pe($n).default([]),generatedAt:V()}),Sf=T({conversationId:g().min(1),title:g().optional(),archived:he().optional(),model:g().optional(),reasoningEffort:ln.optional(),permissionMode:cn.optional(),collaborationMode:yr.optional()}),_f=T({hasHost:he(),agentStatus:vr.optional().nullable(),agentProvider:g().optional().nullable(),agentConversationId:g().optional().nullable(),agentTitle:g().optional().nullable(),agentDetail:g().optional().nullable(),agentLastActivity:V().optional().nullable(),lastActivity:V().optional(),agentUsage:zo.optional().nullable()}),jf=T({conversationId:g().min(1)}),Cf=T({conversationId:g().min(1)}),Nf=T({provider:It.optional(),serverName:g().min(1)}),If=T({provider:It.optional(),serverName:g().min(1),authorizationUrl:g().min(1).optional(),error:g().optional()}),Ws={"session.connect":Wu,"session.ack":Qu,"session.resume":Ku,"session.heartbeat":Yu,"session.error":Id,"terminal.output":Vu,"terminal.input":Uu,"terminal.resize":Hu,"terminal.exit":Zu,"pairing.created":Xu,"pairing.claim":Ju,"pairing.claimed":Gu,"control.claim":ed,"control.grant":td,"control.reject":nd,"control.release":rd,"session.host_disconnected":id,"session.host_reconnected":sd,"session.presence":_f,"screen.start":ad,"screen.stop":od,"screen.frame":ld,"screen.status":cd,"screen.offer":ud,"screen.answer":dd,"screen.ice":fd,"file.upload":jd,"terminal.spawn":hd,"terminal.spawned":gd,"terminal.list":md,"terminal.browse":bd,"terminal.browse.result":vd,"terminal.file.read":wd,"terminal.file.read.result":Sd,"terminal.kill":xd,"terminal.mkdir":yd,"terminal.status":_d,"permission.decision":Cd,"permission.decision.result":Nd,"tunnel.request":Td,"tunnel.response":Ad,"tunnel.ws.data":Ed,"tunnel.ws.close":Pd,"terminal.history.request":Md,"terminal.history.response":Rd,"agent.initialize":Bd,"agent.capabilities":Zi,"agent.session.new":qd,"agent.session.load":Vd,"agent.session.list":Ud,"agent.prompt":Hd,"agent.cancel":Wd,"agent.update":Zd,"agent.permission.request":Qd,"agent.permission.response":Kd,"agent.snapshot":Yd,"agent.v2.capabilities.request":nf,"agent.v2.capabilities":rf,"agent.v2.conversation.open":sf,"agent.v2.conversation.opened":af,"agent.v2.conversation.list":of,"agent.v2.conversation.list.result":lf,"agent.v2.conversation.update":Sf,"agent.v2.conversation.delete":jf,"agent.v2.conversation.deleted":Cf,"agent.v2.prompt":cf,"agent.v2.command.execute":uf,"agent.v2.cancel":df,"agent.v2.permission.respond":ff,"agent.v2.permission.request":xf,"agent.v2.structured_input.respond":hf,"agent.v2.snapshot.request":pf,"agent.v2.snapshot":mf,"agent.v2.event":gf,"agent.v2.notice":yf,"agent.v2.history.request":bf,"agent.v2.history.result":kf,"agent.v2.usage.request":vf,"agent.v2.usage.report":wf,"agent.v2.mcp.login":Nf,"agent.v2.mcp.login.result":If},Tf=["agent.v2.capabilities","agent.v2.conversation.opened","agent.v2.conversation.list.result","agent.v2.event","agent.v2.snapshot","agent.v2.permission.request","agent.v2.notice","agent.v2.history.result","agent.v2.conversation.deleted","agent.v2.usage.report","agent.v2.mcp.login.result"],Af=["agent.v2.conversation.open","agent.v2.conversation.update","agent.v2.conversation.delete","agent.v2.prompt","agent.v2.command.execute","agent.v2.cancel","agent.v2.permission.respond","agent.v2.structured_input.respond","agent.v2.mcp.login"],Ef=["agent.v2.capabilities.request","agent.v2.conversation.list","agent.v2.snapshot.request","agent.v2.history.request","agent.v2.usage.request"],Pf=new Set(Tf),Mf=new Set(Af),Rf=new Set(Ef);function Lf(e){return Pf.has(e)?"host_to_client":Mf.has(e)?"client_write":Rf.has(e)?"client_read":null}function Df(e){return Lf(e)==="host_to_client"}function zf(){var e;return typeof((e=globalThis.crypto)==null?void 0:e.randomUUID)=="function"?globalThis.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=Math.random()*16|0;return(t==="x"?n:n&3|8).toString(16)})}function pn(e){return{id:e.id??zf(),type:e.type,sessionId:e.sessionId,terminalId:e.terminalId,deviceId:e.deviceId,timestamp:new Date().toISOString(),traceId:e.traceId,seq:e.seq,ack:e.ack,payload:e.payload}}function Fo(e){return qu.parse(JSON.parse(e))}function Of(e){return JSON.stringify(e)}function qe(e,t){if(!Object.prototype.hasOwnProperty.call(Ws,e))throw new ht([{code:D.custom,path:["type"],message:`Unknown protocol message type: ${String(e)}`}]);return Ws[e].parse(t)}function Ff(e){if(!e.deviceToken&&!e.jwt)return e.onState("poll"),()=>{};let t=!1,n=null,r,i=0;const s=()=>{if(t)return;e.onState(i===0?"connecting":"poll");const a=ou(e.config,{deviceToken:e.deviceToken,jwt:e.jwt}),o=new WebSocket(a);n=o,o.onopen=()=>{i=0,e.onState("live")},o.onmessage=c=>{if(typeof c.data=="string")try{const u=Fo(c.data);if(u.type!=="session.presence")return;const f=u.payload;e.onPresence(u.sessionId,{hasHost:f.hasHost,agentStatus:f.agentStatus??null,agentProvider:f.agentProvider??null,agentConversationId:f.agentConversationId??null,agentTitle:f.agentTitle??null,agentDetail:f.agentDetail??null,agentLastActivity:f.agentLastActivity??null,lastActivity:f.lastActivity??Date.now(),agentUsage:f.agentUsage??null})}catch{}},o.onclose=()=>{if(t)return;e.onState("poll");const c=Math.min(15e3,1e3*2**Math.min(i,4));i+=1,r=window.setTimeout(s,c)},o.onerror=()=>{o.close()}};return s(),()=>{t=!0,r&&window.clearTimeout(r),n==null||n.close()}}function Zs(e){return e.agentStatus==="waiting_permission"?0:e.agentStatus==="running"?1:e.agentStatus==="error"?2:e.hasHost?10:20}function $f(e){var n;const t=(n=e.agentTitle)==null?void 0:n.trim();return t||e.projectName||e.hostname||e.id.slice(0,8)}function Bf(e){if(!e)return null;const t=e.replace(/\/+$/,"").split("/");return t[t.length-1]||e}function qf(e){if(!e||e<=0)return null;const t=Date.now()-e;return t<45e3?"刚刚":t<36e5?`${Math.max(1,Math.round(t/6e4))} 分钟前`:t<864e5?`${Math.max(1,Math.round(t/36e5))} 小时前`:`${Math.max(1,Math.round(t/864e5))} 天前`}function Vf(e,t){var r,i,s,a;return e.hasHost?e.agentStatus==="waiting_permission"?{text:((r=e.agentDetail)==null?void 0:r.trim())||"等你授权才能继续",tone:"warning"}:e.agentStatus==="error"?{text:((i=e.agentDetail)==null?void 0:i.trim())||"刚刚异常",tone:"danger"}:e.agentStatus==="running"&&((s=e.agentDetail)!=null&&s.trim())&&e.agentDetail.trim()!==((a=e.agentTitle)==null?void 0:a.trim())?{text:e.agentDetail.trim(),tone:"muted"}:{text:[t!=null&&t.showHost&&e.hostname?e.hostname:null,Bf(e.cwd),qf(e.agentLastActivity??e.lastActivity)].filter(Boolean).join(" · ")||"在线",tone:"muted"}:{text:"主机离线",tone:"muted"}}function $o(e){switch(e){case"waiting_permission":return{text:"等你授权",className:"border-warning/40 bg-warning/10 text-warning",pulsing:!0};case"running":return{text:"运行中",className:"border-success/30 bg-success/10 text-success",pulsing:!0};case"error":return{text:"异常",className:"border-danger/30 bg-danger/10 text-danger"};default:return null}}function Uf(e){const t=(e||"").toLowerCase();if(/bash|shell|command/.test(t))return"允许运行这条命令?";if(/write|edit|multiedit/.test(t))return"允许改这个文件?";if(/(^|_)read(_|$)|readfile|read_file/.test(t))return"允许读取这个文件?";if(/webfetch|web_search|websearch|fetch/.test(t))return"允许访问网络?";const n=e==null?void 0:e.split(/ · |__/).pop();return n?`允许使用 ${n}?`:"需要你的授权才能继续"}function Hf({session:e,onLogin:t,onLogout:n,onOpenSession:r}){const[i,s]=v.useState(so()),[a,o]=v.useState(i.httpUrl),[c,u]=v.useState(!1),[f,d]=v.useState(()=>jt()),p=P=>Math.max(P.lastActivity??0,P.agentLastActivity??0),h=f.filter(P=>P.hasHost).sort((P,x)=>{const z=Zs(P)-Zs(x);return z!==0?z:p(x)-p(P)}),m=f.filter(P=>!P.hasHost).sort((P,x)=>p(x)-p(P)),b=new Set(f.map(P=>P.hostname).filter(Boolean)).size>1,[w,k]=v.useState(!1),[A,I]=v.useState(!0),[Z,Q]=v.useState(""),[j,Y]=v.useState(!1),[X,G]=v.useState(null),[_,F]=v.useState(!1),[$,ae]=v.useState("poll"),q=v.useCallback(async P=>{P!=null&&P.silent||I(!0);try{const[x,z]=await Promise.allSettled([su(i,(e==null?void 0:e.accessToken)??null),iu(i,{deviceToken:Yn(),jwt:(e==null?void 0:e.accessToken)??null})]),me=x.status==="fulfilled"?x.value:[],y=z.status==="fulfilled"?z.value:[],Ee=x.status==="rejected"&&z.status==="rejected",Ie=new Map;for(const Le of[...me,...y])Ie.set(Le.id,Le);const Ne=[...Ie.values()];d(Ee?jt():Ne.length>0?di(Ne):Tc())}catch{d(jt())}finally{I(!1)}},[i,e==null?void 0:e.accessToken]);v.useEffect(()=>{q()},[q]),v.useEffect(()=>Ff({config:i,deviceToken:Yn(),jwt:(e==null?void 0:e.accessToken)??null,onState:ae,onPresence:(P,x)=>{d(z=>z.find(y=>y.id===P)?z.map(y=>y.id===P?{...y,...x,lastActivity:x.lastActivity??y.lastActivity}:y):(q({silent:!0}),z))}}),[i,e==null?void 0:e.accessToken,q]),v.useEffect(()=>{const P=$==="live"?3e4:8e3,x=window.setInterval(()=>{document.visibilityState==="visible"&&q({silent:!0})},P);return()=>window.clearInterval(x)},[q,$]);const O=async()=>{const P=Z.trim();if(!/^\d{6}$/.test(P)){G("请输入 6 位配对码");return}Y(!0),G(null);try{const{sessionId:x}=await ru(i,P);di([{id:x,state:"active",hasHost:!0,clientCount:1,provider:null,machineId:null,hostname:null,platform:null,projectName:null,cwd:null,lastActivity:Date.now()}]),Q(""),F(!1),q(),r(x)}catch(x){G(x.message||"配对失败")}finally{Y(!1)}},J=P=>{d(Ac(P))},de=()=>{const P=a.trim().replace(/\/+$/,"");if(P===i.httpUrl){u(!1);return}let x=!1;try{const z=new URL(P);x=z.protocol==="http:"||z.protocol==="https:"}catch{x=!1}if(!x){u(!0);return}u(!1),o(P),ao(P),s({httpUrl:P})},Ce=P=>{const x=Vf(P,{showHost:b}),z=$o(P.agentStatus),me=P.agentStatus==="waiting_permission"?"bg-warning":P.agentStatus==="running"?"bg-accent":P.agentStatus==="error"?"bg-danger":null,y=x.tone==="warning"?"text-warning":x.tone==="danger"?"text-danger":"text-content-muted",Ee=l.jsxs("div",{className:"min-w-0",children:[l.jsxs("p",{className:"flex items-center gap-2 text-[15px] font-medium text-content-primary",children:[l.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${P.hasHost?P.agentStatus==="running"||P.agentStatus==="waiting_permission"?"bg-accent animate-pulse-dot":"bg-success":"bg-content-faint"}`}),l.jsx("span",{className:"truncate",children:$f(P)}),P.agentProvider&&l.jsx(Xt,{provider:P.agentProvider,size:12}),z&&l.jsxs("span",{className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border px-2 py-0.5 text-2xs font-medium ${z.className}`,children:[z.pulsing&&l.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-pulse-dot"}),z.text]})]}),l.jsx("p",{className:`mt-1 truncate text-2xs ${y}`,children:x.text})]});return l.jsxs("div",{className:`codex-card group relative flex items-center justify-between overflow-hidden p-4 transition-colors ${P.hasHost?"hover:bg-surface-overlay":"opacity-70"} ${P.agentStatus==="running"?"border-accent/25":P.agentStatus==="waiting_permission"?"border-warning/30":P.agentStatus==="error"?"border-danger/25":""}`,children:[me&&l.jsx("span",{"aria-hidden":!0,className:`absolute inset-y-0 left-0 w-0.5 ${me}`}),P.hasHost?l.jsx("button",{onClick:()=>r(P.id),className:"flex flex-1 cursor-pointer items-center justify-between text-left",children:Ee}):l.jsx("div",{className:"flex flex-1 items-center justify-between text-left",children:Ee}),l.jsxs("div",{className:"flex items-center gap-2 pl-3",children:[l.jsx("button",{onClick:()=>J(P.id),className:"cursor-pointer rounded-lg p-1.5 text-content-faint opacity-0 transition-colors hover:text-danger group-hover:opacity-100",title:"从列表移除","aria-label":"移除会话",children:l.jsx(dt,{size:14})}),P.hasHost&&l.jsx(nt,{size:16,className:"text-content-faint"})]})]},P.id)};return l.jsxs("div",{className:"min-h-screen bg-canvas",children:[l.jsxs("header",{className:"glass-bar sticky top-0 z-10 flex min-h-14 items-center justify-between gap-3 border-b border-border px-4 sm:px-6",style:{paddingTop:"env(safe-area-inset-top)"},children:[l.jsxs("div",{className:"flex shrink-0 items-center gap-2.5",children:[l.jsx(Ui,{size:26}),l.jsx("h1",{className:"font-mono text-[15px] font-semibold text-content-primary",children:"LinkShell"})]}),l.jsxs("div",{className:"flex min-w-0 items-center gap-2 sm:gap-3",children:[Bc(e)&&l.jsx("span",{className:"shrink-0 rounded-full border border-accent/30 bg-accent/10 px-2.5 py-0.5 text-2xs font-semibold tracking-wide text-accent",children:"PRO"}),e?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"hidden min-w-0 truncate text-[13px] text-content-muted sm:inline",children:e.user.email}),l.jsx("button",{onClick:async()=>{await Uc(),n()},className:"codex-btn-ghost shrink-0 whitespace-nowrap text-2xs",children:"退出"})]}):l.jsx("button",{onClick:t,className:"codex-btn-outline shrink-0 whitespace-nowrap text-2xs",children:"登录"})]})]}),l.jsx("main",{className:"mx-auto max-w-[46rem] animate-fade-in px-4 py-6 sm:px-6 sm:py-10",children:l.jsxs("section",{className:"space-y-5",children:[l.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[l.jsxs("h2",{className:"flex flex-wrap items-center gap-2 text-[15px] font-semibold text-content-primary",children:["我的会话 ",l.jsxs("span",{className:"font-normal text-content-muted",children:["(",h.length,")"]}),l.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-2xs font-medium ${$==="live"?"border-success/30 bg-success/10 text-success":"border-border bg-surface-overlay text-content-muted"}`,children:[$==="live"&&l.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-pulse-dot"}),$==="live"?"实时":$==="connecting"?"连接中":"轮询"]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("button",{onClick:()=>void q(),className:"codex-btn-ghost text-2xs",children:[l.jsx(ko,{size:13})," 刷新"]}),l.jsxs("button",{onClick:()=>F(P=>!P),className:"codex-btn-primary text-2xs",children:[l.jsx(_n,{size:13})," 添加连接"]})]})]}),_&&l.jsxs("section",{className:"codex-card animate-slide-in p-5",children:[l.jsx("label",{className:"mb-1.5 block text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"网关地址"}),l.jsxs("div",{className:"mb-4",children:[l.jsx("input",{value:a,onChange:P=>{o(P.target.value),u(!1)},onBlur:de,onKeyDown:P=>P.key==="Enter"&&de(),className:`codex-input font-mono text-2xs ${c?"border-danger/60":""}`,placeholder:"https://gateway.itool.tech"}),c&&l.jsx("p",{className:"mt-1.5 text-2xs text-danger",children:"请输入有效的 http(s) 地址"})]}),l.jsx("label",{className:"mb-1.5 block text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"配对码(在主机运行 linkshell 获取)"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{value:Z,onChange:P=>Q(P.target.value.replace(/\D/g,"").slice(0,6)),placeholder:"123456",inputMode:"numeric",autoFocus:!0,className:"codex-input flex-1 font-mono tracking-widest",onKeyDown:P=>P.key==="Enter"&&O()}),l.jsx("button",{onClick:O,disabled:j,className:"codex-btn-primary",children:j?"…":"连接"})]}),X&&l.jsx("p",{className:"mt-3 text-[13px] text-danger",children:X})]}),h.length===0&&m.length===0?l.jsx("div",{className:"codex-card flex flex-col items-center gap-3 px-6 py-20 text-center",children:A?l.jsx("p",{className:"text-[15px] leading-7 text-content-muted",children:"加载中…"}):l.jsxs("p",{className:"max-w-sm text-[15px] leading-7 text-content-muted",children:["还没有会话。在主机运行"," ",l.jsx("code",{className:"font-mono text-accent",children:"linkshell"}),",然后点「添加连接」输入配对码。"]})}):l.jsxs("div",{className:"space-y-3",children:[h.map(P=>Ce(P)),m.length>0&&l.jsxs("div",{className:"space-y-3 pt-2",children:[l.jsxs("button",{onClick:()=>k(P=>!P),className:"flex w-full cursor-pointer items-center gap-1.5 text-2xs font-semibold uppercase tracking-wider text-content-faint transition-colors hover:text-content-muted",children:[l.jsx(nt,{size:12,className:`transition-transform ${w?"rotate-90":""}`}),"离线 (",m.length,")"]}),w&&m.map(P=>Ce(P))]})]})]})})]})}const Bo={cancel:!1,list:!1,permission:!1,plan:!1,fork:!1,images:!1,model:!1,effort:!1,permissionMode:!1};function Wf(e,t){var n;if((n=e==null?void 0:e.providers)!=null&&n.length){if(t){const r=e.providers.find(i=>i.id===t);if(r)return r}return e.providers.find(r=>r.enabled)??e.providers[0]}}function wt(e,t){var r;const n=(r=e==null?void 0:e.features)==null?void 0:r[t];return typeof n=="boolean"?n:void 0}function Qi(e){return(e==null?void 0:e.control)!=="attached"}function vi(e,t){var i;if(!e)return{...Bo};const n=Wf(e,t),r=(n==null?void 0:n.supportsPermission)??wt(n,"permissions")??e.supportsPermission??!1;return{cancel:(n==null?void 0:n.supportsCancel)??wt(n,"cancel")??e.supportsCancel??!1,list:wt(n,"sessionList")??e.supportsSessionList??!1,permission:r,plan:(n==null?void 0:n.supportsPlan)??wt(n,"plan")??e.supportsPlan??!1,fork:wt(n,"sessionFork")??!1,images:(n==null?void 0:n.supportsImages)??wt(n,"images")??e.supportsImages??!1,model:wt(n,"setModel")??!1,effort:wt(n,"reasoningEffort")??!1,permissionMode:r&&(((i=n==null?void 0:n.permissionModes)==null?void 0:i.length)??0)>0}}function Zt(e,t){const n=vi(e,t==null?void 0:t.provider);return Qi(t)?n:{...Bo,list:n.list}}const Zf=15e3,Qf=1e3,Kf=3e4,Yf=20;class Xf{constructor(t){this.options=t,this.status="idle",this.deviceId=wc(),this.controllerId=null,this.epoch=0,this.reconnectAttempts=0,this.manualClose=!1,this.lastAckedSeqByTerminal=new Map,this.terminalBuffers=new Map,this.listeners=new Set}get sessionId(){return this.options.sessionId}get currentStatus(){return this.status}get isController(){return this.controllerId===this.deviceId}onEvent(t){return this.listeners.add(t),()=>this.listeners.delete(t)}emit(t){for(const n of this.listeners)n(t)}setStatus(t){this.status!==t&&(this.status=t,this.emit({type:"status",status:t}))}connect(){this.manualClose=!1,this.openSocket(!1)}openSocket(t){var r,i;if(this.manualClose)return;const n=++this.epoch;this.setStatus(t?"reconnecting":"connecting"),Promise.resolve(((i=(r=this.options).getJwt)==null?void 0:i.call(r))??null).then(s=>{n!==this.epoch||this.manualClose||this.openSocketWithJwt(n,t,s)})}openSocketWithJwt(t,n,r){const i=au(this.options.config,{sessionId:this.options.sessionId,deviceId:this.deviceId,deviceToken:vc(),jwt:r});let s;try{s=new WebSocket(i)}catch{this.scheduleReconnect(t);return}this.socket=s,s.onopen=()=>{if(t!==this.epoch){try{s.close()}catch{}return}this.reconnectAttempts=0,this.setStatus("connected"),this.startHeartbeat(),this.claimControl(),n&&this.sendResume()},s.onmessage=a=>{t===this.epoch&&this.handleMessage(typeof a.data=="string"?a.data:String(a.data))},s.onerror=()=>{this.epoch},s.onclose=()=>{if(t===this.epoch){if(this.stopHeartbeat(),this.manualClose){this.setStatus("disconnected");return}this.scheduleReconnect(t)}}}scheduleReconnect(t){if(this.manualClose||t!==this.epoch)return;const n=Math.min(this.reconnectAttempts++,Yf),i=Math.min(Qf*2**n,Kf)*(.5+Math.random()*.5);this.setStatus("reconnecting"),this.reconnectTimer=setTimeout(()=>this.openSocket(!0),i)}startHeartbeat(){this.stopHeartbeat(),this.heartbeatTimer=setInterval(()=>{this.sendRaw(pn({type:"session.heartbeat",sessionId:this.options.sessionId,payload:{ts:Date.now()}}))},Zf)}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0)}sendResume(){this.sendRaw(pn({type:"session.resume",sessionId:this.options.sessionId,payload:{lastAckedSeq:-1,lastAckedSeqByTerminal:Object.fromEntries(this.lastAckedSeqByTerminal)}}))}handleMessage(t){var i;let n;try{n=Fo(t)}catch{return}const r=n.type;if(r==="terminal.output"){try{const s=qe("terminal.output",n.payload),a=n.terminalId??"default";if(n.seq!==void 0){const u=this.lastAckedSeqByTerminal.get(a)??-1;n.seq>u&&(this.lastAckedSeqByTerminal.set(a,n.seq),this.sendRaw(pn({type:"session.ack",sessionId:this.options.sessionId,terminalId:a,payload:{seq:n.seq}})))}this.emit({type:"terminal.output",terminalId:a,data:s.data,seq:n.seq,isReplay:s.isReplay});let c=(this.terminalBuffers.get(a)??"")+s.data;c.length>262144&&(c=c.slice(c.length-131072)),this.terminalBuffers.set(a,c)}catch{}return}if(r==="terminal.reset"){const s=n.terminalId??"default";this.terminalBuffers.delete(s),this.lastAckedSeqByTerminal.delete(s),this.emit({type:"terminal.reset",terminalId:s});return}if(r==="control.grant"){const s=((i=n.payload)==null?void 0:i.deviceId)??null;this.controllerId=s,this.emit({type:"control",controllerId:s});return}if(r==="control.release"){this.controllerId=null,this.emit({type:"control",controllerId:null});return}if(r==="session.error"){const s=n.payload;this.emit({type:"session.error",code:s.code??"error",message:s.message??""});return}if(r==="session.host_disconnected"){this.setStatus("host_disconnected");return}if(r==="session.host_reconnected"){this.setStatus("connected");return}if(r==="terminal.list"||r==="terminal.spawned"){this.emit({type:"terminal.list",envelope:n});return}if(Df(r)){this.emit({type:"agent",envelope:n});return}this.emit({type:"envelope",envelope:n})}sendRaw(t){return!this.socket||this.socket.readyState!==WebSocket.OPEN?!1:(this.socket.send(Of(t)),!0)}send(t,n,r){return this.sendRaw(pn({type:t,sessionId:this.options.sessionId,deviceId:this.deviceId,terminalId:r,payload:n}))}claimControl(){this.sendRaw(pn({type:"control.claim",sessionId:this.options.sessionId,deviceId:this.deviceId,payload:{deviceId:this.deviceId}}))}sendInput(t,n){this.send("terminal.input",{data:n},t)}sendResize(t,n,r){this.send("terminal.resize",{cols:n,rows:r},t)}requestTerminalList(){this.send("terminal.list",{terminals:[]})}terminalBuffer(t){return this.terminalBuffers.get(t)??""}spawnTerminal(t){this.send("terminal.spawn",{cwd:t,forceNew:!0})}killTerminal(t){this.send("terminal.kill",{terminalId:t},t),this.terminalBuffers.delete(t)}sendAgent(t,n){return this.send(t,n)}protocolVersion(){return Ru}disconnect(){if(this.manualClose=!0,this.epoch++,this.stopHeartbeat(),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0),this.socket){try{this.socket.close(1e3,"client disconnect")}catch{}this.socket=void 0}this.setStatus("disconnected")}}const Qs=200;function Qt(e,t){var i,s;if(t.length===0)return e;const n=new Map;for(const a of e)n.set(a.id,a);for(const a of t){const o=n.get(a.id);if(!(((i=o==null?void 0:o.metadata)==null?void 0:i.queuedDiscarded)===!0&&((s=a.metadata)==null?void 0:s.queuedDiscarded)!==!0)){if(o!=null&&o.metadata&&(o.metadata.queuedSent||o.metadata.queuedDiscarded||o.metadata.delivery)){const c=a.metadata??{};n.set(a.id,{...a,metadata:{...c,queuedSent:c.queuedSent??o.metadata.queuedSent,queuedDiscarded:c.queuedDiscarded??o.metadata.queuedDiscarded,delivery:c.delivery??o.metadata.delivery}});continue}n.set(a.id,a)}}const r=[...n.values()].sort((a,o)=>a.createdAt-o.createdAt);return r.length>Qs?r.slice(r.length-Qs):r}function Jf(e,t,n){if(t.item){const r={...t.item,metadata:{...t.item.metadata??{}}};return Qt(e,[r])}if(t.patch){const r=t.patch;let i=!1;const s=e.map(a=>a.id!==r.itemId&&a.itemId!==r.itemId?a:(i=!0,{...a,kind:r.kind??a.kind,role:r.role??a.role,content:r.content??a.content,text:r.textDelta?`${r.text??a.text??""}${r.textDelta}`:r.text??a.text,status:r.status??a.status,toolCall:r.toolCall?{...a.toolCall??{},...r.toolCall}:a.toolCall,commandExecution:r.commandExecution?{...a.commandExecution??{},...r.commandExecution}:a.commandExecution,fileChange:r.fileChange?{...a.fileChange??{},...r.fileChange}:a.fileChange,subagent:r.subagent?{...a.subagent??{},...r.subagent}:a.subagent,structuredInput:r.structuredInput??a.structuredInput,plan:r.plan??a.plan,permission:r.permission?{...a.permission??{},...r.permission}:a.permission,error:r.error??a.error,metadata:r.metadata?{...a.metadata??{},...r.metadata}:a.metadata,updatedAt:r.updatedAt??Date.now(),isStreaming:r.isStreaming??a.isStreaming}));return i?s:(n==null||n(r.itemId),e)}return e}function wi(e){return e.map(t=>({...t,metadata:{...t.metadata??{}}}))}function Gf(e){const t=new Map;for(const n of wi(e)){const r=t.get(n.conversationId)??[];r.push(n),t.set(n.conversationId,r)}return t}function $r(e,t){const n=new Map;for(const r of e)n.set(r.id,r);for(const r of t){const i=n.get(r.id);if(!i){n.set(r.id,r);continue}n.set(r.id,{...i,...r,status:r.status,lastActivityAt:Math.max(i.lastActivityAt??0,r.lastActivityAt??0)})}return[...n.values()].sort((r,i)=>i.lastActivityAt-r.lastActivityAt)}function eh(e){var t,n,r;if(e.text)return e.text.slice(0,120).replace(/\s+/g," ").trim();if((t=e.toolCall)!=null&&t.name)return`🔧 ${e.toolCall.name}`;if((n=e.commandExecution)!=null&&n.command)return`$ ${e.commandExecution.command}`;if((r=e.fileChange)!=null&&r.summary)return e.fileChange.summary;if(e.error)return`⚠ ${e.error}`}function ct(e){const t=Math.random().toString(36).slice(2,10);return`${e}-${Date.now().toString(36)}-${t}`}function Ks(e,t){return`${e??"unknown"}:${t}`}function th(e){return/auth|unauthorized|token|subscription|version|protocol/i.test(e)}function nh(e){switch(e){case"thinking":case"tool_use":case"outputting":return"running";case"waiting":return"waiting_permission";case"idle":return"idle";case"error":return"error";default:return null}}class rh{constructor(t,n,r){this.listeners=new Set,this.pendingBrowse=new Map,this.pendingRead=new Map,this.openInFlight=new Set,this.openedThisSession=new Set,this.autoFlushing=new Set,this.reqCounter=0,this.outbox=[],this.snapshotRecoveryTimers=new Map,this.status="idle",this.isController=!1,this.externalAgentStatus=null,this.externalAgentTitle=null,this.externalAgentProvider=null,this.externalAgentConversationId=null,this.conversations=[],this.timelines=new Map,this.capabilities=null,this.activeConversationId=null,this.lastError=null,this.history=new Map,this.notices=[],this.usage=null,this.mcpAuthLinks={},this.lastProviderSig="",this.subscribe=s=>(this.listeners.add(s),()=>this.listeners.delete(s)),this.getSnapshot=()=>this.snapshot,this.sessionId=n,this.bridge=new Xf({config:t,sessionId:n,getJwt:r}),this.conversations=ho(n);const i=Rc(n);this.timelines=new Map(Object.entries(i)),this.snapshot=this.buildSnapshot(),this.unsub=this.bridge.onEvent(s=>this.handleBridgeEvent(s))}buildSnapshot(){return{status:this.status,isController:this.isController,externalAgentStatus:this.externalAgentStatus,externalAgentTitle:this.externalAgentTitle,externalAgentProvider:this.externalAgentProvider,externalAgentConversationId:this.externalAgentConversationId,conversations:this.conversations,timelines:this.timelines,capabilities:this.capabilities,activeConversationId:this.activeConversationId,lastError:this.lastError,history:this.history,notices:this.notices,usage:this.usage,mcpAuthLinks:this.mcpAuthLinks}}notify(){this.snapshot=this.buildSnapshot();for(const t of this.listeners)t();this.schedulePersist()}schedulePersist(){this.persistTimer||(this.persistTimer=setTimeout(()=>{this.persistTimer=void 0,As(this.sessionId,this.conversations),Es(this.sessionId,this.timelines)},800))}flushPersist(){this.persistTimer&&(clearTimeout(this.persistTimer),this.persistTimer=void 0),As(this.sessionId,this.conversations),Es(this.sessionId,this.timelines)}connect(){this.bridge.connect()}destroy(){this.flushPersist(),this.errorClearTimer&&clearTimeout(this.errorClearTimer);for(const t of this.snapshotRecoveryTimers.values())clearTimeout(t);this.snapshotRecoveryTimers.clear(),this.unsub(),this.bridge.disconnect(),this.listeners.clear()}get client(){return this.bridge}handleBridgeEvent(t){var n;switch(t.type){case"status":this.status=t.status,t.status==="connected"&&((n=this.lastError)!=null&&n.sticky||(this.lastError=null),this.requestCapabilities(),this.requestSnapshot(),this.flushOutbox()),this.notify();break;case"control":this.isController=this.bridge.isController,this.notify();break;case"session.error":{const r=th(t.code);this.lastError={code:t.code,message:t.message,sticky:r},this.notify(),this.errorClearTimer&&(clearTimeout(this.errorClearTimer),this.errorClearTimer=void 0),r||(this.errorClearTimer=setTimeout(()=>{this.lastError=null,this.errorClearTimer=void 0,this.notify()},6e3));break}case"agent":this.handleAgentEnvelope(t.envelope);break;case"envelope":this.handleOtherEnvelope(t.envelope);break}}handleOtherEnvelope(t){const n=t.type;if(n==="terminal.status"){try{const r=qe("terminal.status",t.payload);this.externalAgentStatus=nh(r.phase),this.externalAgentProvider=r.provider??null,this.externalAgentTitle=r.toolName?`外部终端 · ${r.toolName}`:r.summary?`外部终端 · ${r.summary}`:"外部终端",this.externalAgentConversationId=r.conversationId??null,this.notify()}catch{}return}if(n==="terminal.browse.result"){try{const r=qe("terminal.browse.result",t.payload);if(r.requestId){const i=this.pendingBrowse.get(r.requestId);i&&(this.pendingBrowse.delete(r.requestId),i(r))}}catch{}return}if(n==="terminal.file.read.result"){try{const r=qe("terminal.file.read.result",t.payload);if(r.requestId){const i=this.pendingRead.get(r.requestId);i&&(this.pendingRead.delete(r.requestId),i(r))}}catch{}return}}setTimeline(t,n){const r=new Map(this.timelines);r.set(t,n),this.timelines=r}handleAgentEnvelope(t){var r;const n=t.type;try{if(n==="agent.v2.capabilities"){this.capabilities=qe("agent.v2.capabilities",t.payload);const i=(this.capabilities.providers??[]).filter(s=>s.enabled).map(s=>s.id).sort().join(",");i&&i!==this.lastProviderSig&&(this.lastProviderSig=i,this.requestSnapshot()),vi(this.capabilities).list&&this.requestConversationList(),this.pruneConnectedMcpAuthLinks(),this.notify();return}if(n==="agent.v2.snapshot"){const i=qe("agent.v2.snapshot",t.payload);this.conversations=$r(this.conversations,i.conversations),i.activeConversationId&&(this.activeConversationId=i.activeConversationId);const s=Gf(i.items),a=new Map(this.timelines);for(const[o,c]of s)a.set(o,Qt(a.get(o)??[],c));this.timelines=a,this.notify();return}if(n==="agent.v2.conversation.opened"){const i=qe("agent.v2.conversation.opened",t.payload);this.conversations=$r(this.conversations,[i.conversation]),this.activeConversationId=i.conversation.id,this.setTimeline(i.conversation.id,Qt(this.timelines.get(i.conversation.id)??[],wi(i.snapshot)));const s=a=>{const o=this.history.get(a);this.history.set(a,{loading:!1,hasMore:(o==null?void 0:o.hasMore)??!0,cursor:o==null?void 0:o.cursor,syncing:!1}),this.openedThisSession.add(a)};s(i.conversation.id),i.requestedConversationId&&i.requestedConversationId!==i.conversation.id&&s(i.requestedConversationId),this.openInFlight.delete(i.conversation.id),i.requestedConversationId&&this.openInFlight.delete(i.requestedConversationId),this.notify();return}if(n==="agent.v2.history.result"){const i=qe("agent.v2.history.result",t.payload);this.setTimeline(i.conversationId,Qt(this.timelines.get(i.conversationId)??[],wi(i.items))),this.history.set(i.conversationId,{loading:!1,hasMore:i.hasMore,cursor:i.nextCursor}),this.notify();return}if(n==="agent.v2.conversation.list.result"){const i=qe("agent.v2.conversation.list.result",t.payload);this.conversations=$r(this.conversations,i.conversations),this.notify();return}if(n==="agent.v2.conversation.deleted"){const i=qe("agent.v2.conversation.deleted",t.payload);this.removeConversationLocal(i.conversationId),this.notify();return}if(n==="agent.v2.mcp.login.result"){const i=qe("agent.v2.mcp.login.result",t.payload),s=Ks(i.provider,i.serverName);if(i.error){const a={...this.mcpAuthLinks};delete a[s],this.mcpAuthLinks=a,this.pushNotice({kind:"warning",title:`MCP ${i.serverName} 授权失败`,detail:i.error});return}if(i.authorizationUrl){this.mcpAuthLinks={...this.mcpAuthLinks,[s]:i.authorizationUrl},this.notify();try{window.open(i.authorizationUrl,"_blank","noopener,noreferrer")||this.pushNotice({kind:"info",title:"请打开授权页",detail:"浏览器拦截了弹窗,请在 MCP 面板里点击「打开授权页」。"})}catch{this.pushNotice({kind:"info",title:"请打开授权页",detail:"无法自动打开授权页,请在 MCP 面板里手动打开。"})}return}this.notify();return}if(n==="agent.v2.event"){const i=qe("agent.v2.event",t.payload);if(i.conversation){const o=i.conversation,c=this.conversations.some(u=>u.id===o.id);this.conversations=(c?this.conversations.map(u=>u.id===o.id?o:u):[o,...this.conversations]).sort((u,f)=>f.lastActivityAt-u.lastActivityAt)}else(r=i.patch)!=null&&r.status&&this.updateConversationStatus(i.conversationId,i.patch.status,i.patch.updatedAt??Date.now());const s=this.timelines.get(i.conversationId)??[],a=Jf(s,i,()=>this.scheduleSnapshotRecovery(i.conversationId));if(a!==s){this.setTimeline(i.conversationId,a);const o=a[a.length-1];o&&this.touchConversation(i.conversationId,o)}this.notify(),this.maybeFlushQueue(i.conversationId);return}if(n==="agent.v2.permission.request"){const i=qe("agent.v2.permission.request",t.payload);if(this.updateConversationStatus(i.conversationId,"waiting_permission",Date.now()),i.item){const s={...i.item,metadata:{...i.item.metadata??{},permissionLive:!0}};this.setTimeline(i.conversationId,Qt(this.timelines.get(i.conversationId)??[],[s])),this.notify()}return}if(n==="agent.v2.notice"){const i=qe("agent.v2.notice",t.payload),s=ct("notice");this.notices=[...this.notices,{id:s,kind:i.kind,title:i.title,detail:i.detail}].slice(-4),this.notify();const a=i.durationMs&&i.durationMs>0?i.durationMs:4e3;setTimeout(()=>this.dismissNotice(s),a);return}if(n==="agent.v2.usage.report"){this.usage=qe("agent.v2.usage.report",t.payload),this.notify();return}}catch{}}touchConversation(t,n){const r=eh(n);this.conversations=this.conversations.map(i=>i.id===t?{...i,lastMessagePreview:r??i.lastMessagePreview,lastActivityAt:n.updatedAt??n.createdAt??i.lastActivityAt}:i)}updateConversationStatus(t,n,r){this.conversations=this.conversations.map(i=>i.id===t?{...i,status:n,lastActivityAt:Math.max(i.lastActivityAt,r)}:i).sort((i,s)=>s.lastActivityAt-i.lastActivityAt)}sendReliable(t,n){const r=this.bridge.sendAgent(t,n);return r||this.outbox.push({type:t,payload:n,queuedAt:Date.now()}),r}flushOutbox(){if(this.outbox.length===0)return;const t=this.outbox;this.outbox=[];const n=Date.now();let r=0;for(let i=0;i<t.length;i++){const s=t[i];if(n-s.queuedAt>6e4){r+=1;continue}if(!this.sendReliable(s.type,s.payload)){this.outbox.push(...t.slice(i+1));break}}if(r>0){const i=ct("notice");this.notices=[...this.notices,{id:i,kind:"warning",title:"发送失败",detail:`${r} 条消息因连接中断超过 60 秒未能送达,已丢弃`}].slice(-4),this.notify(),setTimeout(()=>this.dismissNotice(i),6e3)}}scheduleSnapshotRecovery(t){this.snapshotRecoveryTimers.has(t)||this.snapshotRecoveryTimers.set(t,setTimeout(()=>{this.snapshotRecoveryTimers.delete(t),this.requestSnapshot(t)},1e3))}pushNotice(t){const n=ct("notice");this.notices=[...this.notices,{id:n,kind:t.kind,title:t.title,detail:t.detail}].slice(-4),this.notify(),setTimeout(()=>this.dismissNotice(n),t.durationMs&&t.durationMs>0?t.durationMs:5e3)}pruneConnectedMcpAuthLinks(){var i;const t=this.mcpAuthLinks;if(Object.keys(t).length===0)return;const r={...t};for(const s of((i=this.capabilities)==null?void 0:i.providers)??[])for(const a of s.mcpServers??[])a.status==="connected"&&delete r[Ks(s.id,a.name)];this.mcpAuthLinks=r}dismissNotice(t){const n=this.notices.filter(r=>r.id!==t);n.length!==this.notices.length&&(this.notices=n,this.notify())}dismissError(){this.errorClearTimer&&(clearTimeout(this.errorClearTimer),this.errorClearTimer=void 0),this.lastError&&(this.lastError=null,this.notify())}setActiveConversation(t){this.activeConversationId=t,this.notify(),t&&this.ensureHistoryLoaded(t)}ensureHistoryLoaded(t){if(this.openInFlight.has(t))return;const r=(this.timelines.get(t)??[]).some(a=>{var o;return((o=a.metadata)==null?void 0:o.optimistic)!==!0});if(r&&this.openedThisSession.has(t)){const a=this.conversations.find(o=>o.id===t);if((a==null?void 0:a.status)!=="running"&&(a==null?void 0:a.status)!=="waiting_permission")return}const i=this.conversations.find(a=>a.id===t);if(!i)return;this.openInFlight.add(t);const s=this.history.get(t);r?this.history.set(t,{loading:(s==null?void 0:s.loading)??!1,hasMore:(s==null?void 0:s.hasMore)??!0,cursor:s==null?void 0:s.cursor,syncing:!0}):this.history.set(t,{loading:!0,hasMore:(s==null?void 0:s.hasMore)??!0,cursor:s==null?void 0:s.cursor}),this.notify(),setTimeout(()=>{if(!this.openInFlight.delete(t))return;const a=this.history.get(t);if(a&&(a.loading||a.syncing)){this.history.set(t,{loading:!1,hasMore:a.hasMore,cursor:a.cursor,syncing:!1});const o=ct("notice");this.notices=[...this.notices,{id:o,kind:"warning",title:"加载对话记录超时"}].slice(-4),setTimeout(()=>this.dismissNotice(o),6e3),this.notify()}},4e3),this.bridge.sendAgent("agent.v2.conversation.open",{conversationId:t,agentSessionId:i.agentSessionId,provider:i.provider,cwd:i.cwd,model:i.model,reasoningEffort:i.reasoningEffort,permissionMode:i.permissionMode,collaborationMode:i.collaborationMode,title:i.title})}requestCapabilities(){this.bridge.sendAgent("agent.v2.capabilities.request",{})}requestSnapshot(t){this.bridge.sendAgent("agent.v2.snapshot.request",t?{conversationId:t}:{})}requestConversationList(t=!1){vi(this.capabilities).list&&this.bridge.sendAgent("agent.v2.conversation.list",{includeArchived:t})}requestUsage(){this.bridge.sendAgent("agent.v2.usage.request",{})}loadOlderHistory(t){const n=this.history.get(t);n&&(n.loading||!n.hasMore)||(this.history.set(t,{loading:!0,hasMore:(n==null?void 0:n.hasMore)??!0,cursor:n==null?void 0:n.cursor}),this.notify(),this.bridge.sendAgent("agent.v2.history.request",{conversationId:t,cursor:n==null?void 0:n.cursor,limit:50}))}openConversation(t){const n=t.conversationId??ct("agent");return this.bridge.sendAgent("agent.v2.conversation.open",{conversationId:n,provider:t.provider,cwd:t.cwd,model:t.model,reasoningEffort:t.reasoningEffort,permissionMode:t.permissionMode,collaborationMode:t.collaborationMode,title:t.title}),n}forkConversation(t,n){const r=this.conversations.find(s=>s.id===t);if(!r||!Zt(this.capabilities,r).fork)return;const i=ct("agent");return this.bridge.sendAgent("agent.v2.conversation.open",{conversationId:i,provider:r.provider,cwd:r.cwd,forkFromConversationId:t,forkFromTurnId:n}),i}sendPrompt(t){let n=[];t.text.trim()&&n.push({type:"text",text:t.text});for(const u of t.images??[])n.push({type:"image",data:u.data,mimeType:u.mimeType});if(n.length===0)return;const r=this.conversations.find(u=>u.id===t.conversationId);if(!Qi(r)||(Zt(this.capabilities,r).images||(n=n.filter(u=>u.type!=="image")),n.length===0))return;const a=(r==null?void 0:r.status)==="running"||(r==null?void 0:r.status)==="waiting_permission"?"queued":"auto",o=ct("msg"),c={id:o,conversationId:t.conversationId,type:"message",kind:"chat",role:"user",content:n,text:t.text,createdAt:Date.now(),metadata:{optimistic:!0,delivery:a,clientMessageId:o}};this.setTimeline(t.conversationId,Qt(this.timelines.get(t.conversationId)??[],[c])),this.conversations=this.conversations.map(u=>u.id===t.conversationId?{...u,model:t.model??u.model,reasoningEffort:t.reasoningEffort??u.reasoningEffort,permissionMode:t.permissionMode??u.permissionMode,collaborationMode:t.collaborationMode??u.collaborationMode,status:a==="auto"?"running":u.status,lastActivityAt:Date.now()}:u),this.notify(),a!=="queued"&&this.sendReliable("agent.v2.prompt",{conversationId:t.conversationId,clientMessageId:o,contentBlocks:n,delivery:"auto",model:t.model,reasoningEffort:t.reasoningEffort,permissionMode:t.permissionMode,collaborationMode:t.collaborationMode})}sendQueuedFollowUp(t,n,r){var u,f,d;const s=(this.timelines.get(t)??[]).find(p=>p.id===n);if(!s||((u=s.metadata)==null?void 0:u.queuedSent)===!0||((f=s.metadata)==null?void 0:f.queuedDiscarded)===!0)return;const a=this.conversations.find(p=>p.id===t),o=s.content??(s.text?[{type:"text",text:s.text}]:[]);if(o.length===0)return;this.bridge.sendAgent("agent.v2.prompt",{conversationId:t,clientMessageId:((d=s.metadata)==null?void 0:d.clientMessageId)??ct("msg"),contentBlocks:o,delivery:r,model:a==null?void 0:a.model,reasoningEffort:a==null?void 0:a.reasoningEffort,permissionMode:a==null?void 0:a.permissionMode,collaborationMode:a==null?void 0:a.collaborationMode})&&(this.patchItem(t,n,{queuedSent:!0}),this.notify())}discardQueuedFollowUp(t,n){this.patchItem(t,n,{queuedDiscarded:!0,queuedSent:!0}),this.notify()}patchItem(t,n,r){const i=this.timelines.get(t);i&&this.setTimeline(t,i.map(s=>s.id===n?{...s,metadata:{...s.metadata??{},...r},updatedAt:Date.now()}:s))}maybeFlushQueue(t){const n=this.conversations.find(s=>s.id===t);if(!n||n.status==="running"||n.status==="waiting_permission")return;const i=(this.timelines.get(t)??[]).find(s=>{var a,o,c;return((a=s.metadata)==null?void 0:a.delivery)==="queued"&&((o=s.metadata)==null?void 0:o.queuedSent)!==!0&&((c=s.metadata)==null?void 0:c.queuedDiscarded)!==!0});!i||this.autoFlushing.has(i.id)||(this.autoFlushing.add(i.id),this.sendQueuedFollowUp(t,i.id,"new_turn"),setTimeout(()=>this.autoFlushing.delete(i.id),1500))}cancel(t){const n=this.conversations.find(r=>r.id===t);Zt(this.capabilities,n).cancel&&this.sendReliable("agent.v2.cancel",{conversationId:t})}respondPermission(t,n,r,i){const s=this.conversations.find(a=>a.id===t);Zt(this.capabilities,s).permission&&(this.patchItemByPredicate(t,a=>{var o;return((o=a.permission)==null?void 0:o.requestId)===n},{permissionPending:!0,pendingOutcome:r,optionId:i}),this.notify(),this.sendReliable("agent.v2.permission.respond",{conversationId:t,requestId:n,outcome:r,optionId:i}))}respondStructuredInput(t,n,r){this.patchItemByPredicate(t,i=>{var s;return((s=i.structuredInput)==null?void 0:s.requestId)===n},{inputSubmitting:!0,answers:r}),this.notify(),this.sendReliable("agent.v2.structured_input.respond",{conversationId:t,requestId:n,answers:r})}patchItemByPredicate(t,n,r){const i=this.timelines.get(t);if(!i)return;let s=!1;this.setTimeline(t,i.map(a=>s||!n(a)?a:(s=!0,{...a,metadata:{...a.metadata??{},...r},updatedAt:Date.now()})))}executeCommand(t,n,r){this.bridge.sendAgent("agent.v2.command.execute",{conversationId:t,commandId:n,args:r,clientMessageId:ct("cmd")})}updateConversationSettings(t,n){const r=this.conversations.find(a=>a.id===t),i=Zt(this.capabilities,r),s={...n};i.model||delete s.model,i.effort||delete s.reasoningEffort,i.permissionMode||delete s.permissionMode,i.plan||delete s.collaborationMode,Object.keys(s).length!==0&&(this.conversations=this.conversations.map(a=>a.id===t?{...a,...s}:a),this.notify(),this.bridge.sendAgent("agent.v2.conversation.update",{conversationId:t,...s}))}renameConversation(t,n){const r=n.trim(),i=r===""?void 0:r;this.conversations=this.conversations.map(s=>s.id===t?{...s,title:i}:s),this.notify(),this.bridge.sendAgent("agent.v2.conversation.update",{conversationId:t,title:r})}setConversationArchived(t,n){this.conversations=this.conversations.map(r=>r.id===t?{...r,archived:n}:r),this.notify(),this.bridge.sendAgent("agent.v2.conversation.update",{conversationId:t,archived:n})}deleteConversation(t){this.removeConversationLocal(t),this.notify(),this.bridge.sendAgent("agent.v2.conversation.delete",{conversationId:t})}startMcpLogin(t,n){this.bridge.sendAgent("agent.v2.mcp.login",{...t?{provider:t}:{},serverName:n})}removeConversationLocal(t){if(this.conversations=this.conversations.filter(n=>n.id!==t),this.timelines.has(t)){const n=new Map(this.timelines);n.delete(t),this.timelines=n}this.history.delete(t),this.openInFlight.delete(t),this.activeConversationId===t&&(this.activeConversationId=null)}nextRequestId(t){return this.reqCounter+=1,`${t}-${this.reqCounter}-${ct("r")}`}browse(t,n=!0){const r=this.nextRequestId("browse");return new Promise((i,s)=>{const a=setTimeout(()=>{this.pendingBrowse.delete(r),s(new Error("browse timeout"))},1e4);this.pendingBrowse.set(r,o=>{clearTimeout(a),i(o)}),this.bridge.send("terminal.browse",{path:t,includeFiles:n,requestId:r})})}readFile(t,n=256e3){const r=this.nextRequestId("read");return new Promise((i,s)=>{const a=setTimeout(()=>{this.pendingRead.delete(r),s(new Error("read timeout"))},1e4);this.pendingRead.set(r,o=>{clearTimeout(a),i(o)}),this.bridge.send("terminal.file.read",{path:t,maxBytes:n,requestId:r})})}}function ih(e,t){const n=`${e.httpUrl}|${t}`,r=v.useRef(null),i=v.useMemo(()=>{var o;if(r.current&&r.current.key===n)return r.current.store;(o=r.current)==null||o.store.destroy();const a=new rh(e,t,async()=>{const c=await xo();return(c==null?void 0:c.accessToken)??null});return r.current={key:n,store:a},a},[n]);v.useEffect(()=>(i.connect(),()=>{i.destroy(),r.current=null}),[i]);const s=v.useSyncExternalStore(i.subscribe,i.getSnapshot);return{store:i,snapshot:s}}const qo=()=>typeof window<"u"&&"Notification"in window;function sh(){qo()&&Notification.permission==="default"&&Notification.requestPermission().catch(()=>{})}const ah="● LinkShell";function oh(){return document.hidden||!document.hasFocus()}function lh(e){const t=v.useRef(new Map),n=v.useRef(null);v.useEffect(()=>{const r=()=>{n.current!=null&&!document.hidden&&(document.title=n.current,n.current=null)};return window.addEventListener("focus",r),document.addEventListener("visibilitychange",r),()=>{window.removeEventListener("focus",r),document.removeEventListener("visibilitychange",r)}},[]),v.useEffect(()=>{const r=t.current,i=new Map;for(const s of e){if(i.set(s.id,s.status),r.get(s.id)!=="running"||s.status==="running")continue;const o=s.status==="idle",c=s.status==="waiting_permission";if(!o&&!c||!oh())continue;const u=o?"任务完成":"等待授权",f=s.title&&s.title.trim()||s.lastMessagePreview&&s.lastMessagePreview.trim().slice(0,60)||`对话 ${s.id.slice(-6)}`;if(n.current==null&&(n.current=document.title),document.title=ah,qo()&&Notification.permission==="granted")try{const d=new Notification(u,{body:f,tag:`linkshell-turn-${s.id}`});d.onclick=()=>{window.focus(),d.close()}}catch{}}t.current=i},[e])}function ch(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const uh=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,dh=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,fh={};function Ys(e,t){return(fh.jsx?dh:uh).test(e)}const hh=/[ \t\n\f\r]/g;function ph(e){return typeof e=="object"?e.type==="text"?Xs(e.value):!1:Xs(e)}function Xs(e){return e.replace(hh,"")===""}class Mn{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Mn.prototype.normal={};Mn.prototype.property={};Mn.prototype.space=void 0;function Vo(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Mn(n,r,t)}function Si(e){return e.toLowerCase()}class Qe{constructor(t,n){this.attribute=n,this.property=t}}Qe.prototype.attribute="";Qe.prototype.booleanish=!1;Qe.prototype.boolean=!1;Qe.prototype.commaOrSpaceSeparated=!1;Qe.prototype.commaSeparated=!1;Qe.prototype.defined=!1;Qe.prototype.mustUseProperty=!1;Qe.prototype.number=!1;Qe.prototype.overloadedBoolean=!1;Qe.prototype.property="";Qe.prototype.spaceSeparated=!1;Qe.prototype.space=void 0;let mh=0;const oe=zt(),Me=zt(),_i=zt(),L=zt(),Ae=zt(),Jt=zt(),Xe=zt();function zt(){return 2**++mh}const ji=Object.freeze(Object.defineProperty({__proto__:null,boolean:oe,booleanish:Me,commaOrSpaceSeparated:Xe,commaSeparated:Jt,number:L,overloadedBoolean:_i,spaceSeparated:Ae},Symbol.toStringTag,{value:"Module"})),Br=Object.keys(ji);class Ki extends Qe{constructor(t,n,r,i){let s=-1;if(super(t,n),Js(this,"space",i),typeof r=="number")for(;++s<Br.length;){const a=Br[s];Js(this,Br[s],(r&ji[a])===ji[a])}}}Ki.prototype.defined=!0;function Js(e,t,n){n&&(e[t]=n)}function un(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Ki(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Si(r)]=r,n[Si(s.attribute)]=r}return new Mn(t,n,e.space)}const Uo=un({properties:{ariaActiveDescendant:null,ariaAtomic:Me,ariaAutoComplete:null,ariaBusy:Me,ariaChecked:Me,ariaColCount:L,ariaColIndex:L,ariaColSpan:L,ariaControls:Ae,ariaCurrent:null,ariaDescribedBy:Ae,ariaDetails:null,ariaDisabled:Me,ariaDropEffect:Ae,ariaErrorMessage:null,ariaExpanded:Me,ariaFlowTo:Ae,ariaGrabbed:Me,ariaHasPopup:null,ariaHidden:Me,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ae,ariaLevel:L,ariaLive:null,ariaModal:Me,ariaMultiLine:Me,ariaMultiSelectable:Me,ariaOrientation:null,ariaOwns:Ae,ariaPlaceholder:null,ariaPosInSet:L,ariaPressed:Me,ariaReadOnly:Me,ariaRelevant:null,ariaRequired:Me,ariaRoleDescription:Ae,ariaRowCount:L,ariaRowIndex:L,ariaRowSpan:L,ariaSelected:Me,ariaSetSize:L,ariaSort:null,ariaValueMax:L,ariaValueMin:L,ariaValueNow:L,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Ho(e,t){return t in e?e[t]:t}function Wo(e,t){return Ho(e,t.toLowerCase())}const gh=un({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Jt,acceptCharset:Ae,accessKey:Ae,action:null,allow:null,allowFullScreen:oe,allowPaymentRequest:oe,allowUserMedia:oe,alt:null,as:null,async:oe,autoCapitalize:null,autoComplete:Ae,autoFocus:oe,autoPlay:oe,blocking:Ae,capture:null,charSet:null,checked:oe,cite:null,className:Ae,cols:L,colSpan:null,content:null,contentEditable:Me,controls:oe,controlsList:Ae,coords:L|Jt,crossOrigin:null,data:null,dateTime:null,decoding:null,default:oe,defer:oe,dir:null,dirName:null,disabled:oe,download:_i,draggable:Me,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:oe,formTarget:null,headers:Ae,height:L,hidden:_i,high:L,href:null,hrefLang:null,htmlFor:Ae,httpEquiv:Ae,id:null,imageSizes:null,imageSrcSet:null,inert:oe,inputMode:null,integrity:null,is:null,isMap:oe,itemId:null,itemProp:Ae,itemRef:Ae,itemScope:oe,itemType:Ae,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:oe,low:L,manifest:null,max:null,maxLength:L,media:null,method:null,min:null,minLength:L,multiple:oe,muted:oe,name:null,nonce:null,noModule:oe,noValidate:oe,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:oe,optimum:L,pattern:null,ping:Ae,placeholder:null,playsInline:oe,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:oe,referrerPolicy:null,rel:Ae,required:oe,reversed:oe,rows:L,rowSpan:L,sandbox:Ae,scope:null,scoped:oe,seamless:oe,selected:oe,shadowRootClonable:oe,shadowRootDelegatesFocus:oe,shadowRootMode:null,shape:null,size:L,sizes:null,slot:null,span:L,spellCheck:Me,src:null,srcDoc:null,srcLang:null,srcSet:null,start:L,step:null,style:null,tabIndex:L,target:null,title:null,translate:null,type:null,typeMustMatch:oe,useMap:null,value:Me,width:L,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ae,axis:null,background:null,bgColor:null,border:L,borderColor:null,bottomMargin:L,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:oe,declare:oe,event:null,face:null,frame:null,frameBorder:null,hSpace:L,leftMargin:L,link:null,longDesc:null,lowSrc:null,marginHeight:L,marginWidth:L,noResize:oe,noHref:oe,noShade:oe,noWrap:oe,object:null,profile:null,prompt:null,rev:null,rightMargin:L,rules:null,scheme:null,scrolling:Me,standby:null,summary:null,text:null,topMargin:L,valueType:null,version:null,vAlign:null,vLink:null,vSpace:L,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:oe,disableRemotePlayback:oe,prefix:null,property:null,results:L,security:null,unselectable:null},space:"html",transform:Wo}),xh=un({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Xe,accentHeight:L,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:L,amplitude:L,arabicForm:null,ascent:L,attributeName:null,attributeType:null,azimuth:L,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:L,by:null,calcMode:null,capHeight:L,className:Ae,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:L,diffuseConstant:L,direction:null,display:null,dur:null,divisor:L,dominantBaseline:null,download:oe,dx:null,dy:null,edgeMode:null,editable:null,elevation:L,enableBackground:null,end:null,event:null,exponent:L,externalResourcesRequired:null,fill:null,fillOpacity:L,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Jt,g2:Jt,glyphName:Jt,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:L,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:L,horizOriginX:L,horizOriginY:L,id:null,ideographic:L,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:L,k:L,k1:L,k2:L,k3:L,k4:L,kernelMatrix:Xe,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:L,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:L,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:L,overlineThickness:L,paintOrder:null,panose1:null,path:null,pathLength:L,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ae,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:L,pointsAtY:L,pointsAtZ:L,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Xe,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Xe,rev:Xe,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Xe,requiredFeatures:Xe,requiredFonts:Xe,requiredFormats:Xe,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:L,specularExponent:L,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:L,strikethroughThickness:L,string:null,stroke:null,strokeDashArray:Xe,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:L,strokeOpacity:L,strokeWidth:null,style:null,surfaceScale:L,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Xe,tabIndex:L,tableValues:null,target:null,targetX:L,targetY:L,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Xe,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:L,underlineThickness:L,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:L,values:null,vAlphabetic:L,vMathematical:L,vectorEffect:null,vHanging:L,vIdeographic:L,version:null,vertAdvY:L,vertOriginX:L,vertOriginY:L,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:L,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Ho}),Zo=un({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Qo=un({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Wo}),Ko=un({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),yh={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},bh=/[A-Z]/g,Gs=/-[a-z]/g,kh=/^data[-\w.:]+$/i;function vh(e,t){const n=Si(t);let r=t,i=Qe;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&kh.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(Gs,Sh);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!Gs.test(s)){let a=s.replace(bh,wh);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=Ki}return new i(r,t)}function wh(e){return"-"+e.toLowerCase()}function Sh(e){return e.charAt(1).toUpperCase()}const _h=Vo([Uo,gh,Zo,Qo,Ko],"html"),Yi=Vo([Uo,xh,Zo,Qo,Ko],"svg");function jh(e){return e.join(" ").trim()}var Vt={},qr,ea;function Ch(){if(ea)return qr;ea=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,o=/^\s+|\s+$/g,c=`
3
- `,u="/",f="*",d="",p="comment",h="declaration";function m(w,k){if(typeof w!="string")throw new TypeError("First argument must be a string");if(!w)return[];k=k||{};var A=1,I=1;function Z(q){var O=q.match(t);O&&(A+=O.length);var J=q.lastIndexOf(c);I=~J?q.length-J:I+q.length}function Q(){var q={line:A,column:I};return function(O){return O.position=new j(q),G(),O}}function j(q){this.start=q,this.end={line:A,column:I},this.source=k.source}j.prototype.content=w;function Y(q){var O=new Error(k.source+":"+A+":"+I+": "+q);if(O.reason=q,O.filename=k.source,O.line=A,O.column=I,O.source=w,!k.silent)throw O}function X(q){var O=q.exec(w);if(O){var J=O[0];return Z(J),w=w.slice(J.length),O}}function G(){X(n)}function _(q){var O;for(q=q||[];O=F();)O!==!1&&q.push(O);return q}function F(){var q=Q();if(!(u!=w.charAt(0)||f!=w.charAt(1))){for(var O=2;d!=w.charAt(O)&&(f!=w.charAt(O)||u!=w.charAt(O+1));)++O;if(O+=2,d===w.charAt(O-1))return Y("End of comment missing");var J=w.slice(2,O-2);return I+=2,Z(J),w=w.slice(O),I+=2,q({type:p,comment:J})}}function $(){var q=Q(),O=X(r);if(O){if(F(),!X(i))return Y("property missing ':'");var J=X(s),de=q({type:h,property:b(O[0].replace(e,d)),value:J?b(J[0].replace(e,d)):d});return X(a),de}}function ae(){var q=[];_(q);for(var O;O=$();)O!==!1&&(q.push(O),_(q));return q}return G(),ae()}function b(w){return w?w.replace(o,d):d}return qr=m,qr}var ta;function Nh(){if(ta)return Vt;ta=1;var e=Vt&&Vt.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Vt,"__esModule",{value:!0}),Vt.default=n;const t=e(Ch());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const a=(0,t.default)(r),o=typeof i=="function";return a.forEach(c=>{if(c.type!=="declaration")return;const{property:u,value:f}=c;o?i(u,f,c):f&&(s=s||{},s[u]=f)}),s}return Vt}var mn={},na;function Ih(){if(na)return mn;na=1,Object.defineProperty(mn,"__esModule",{value:!0}),mn.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(u){return!u||n.test(u)||e.test(u)},a=function(u,f){return f.toUpperCase()},o=function(u,f){return"".concat(f,"-")},c=function(u,f){return f===void 0&&(f={}),s(u)?u:(u=u.toLowerCase(),f.reactCompat?u=u.replace(i,o):u=u.replace(r,o),u.replace(t,a))};return mn.camelCase=c,mn}var gn,ra;function Th(){if(ra)return gn;ra=1;var e=gn&&gn.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Nh()),n=Ih();function r(i,s){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(o,c){o&&c&&(a[(0,n.camelCase)(o,s)]=c)}),a}return r.default=r,gn=r,gn}var Ah=Th();const Eh=ro(Ah),Yo=Xo("end"),Xi=Xo("start");function Xo(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Ph(e){const t=Xi(e),n=Yo(e);if(t&&n)return{start:t,end:n}}function kn(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?ia(e.position):"start"in e||"end"in e?ia(e):"line"in e||"column"in e?Ci(e):""}function Ci(e){return sa(e&&e.line)+":"+sa(e&&e.column)}function ia(e){return Ci(e&&e.start)+"-"+Ci(e&&e.end)}function sa(e){return e&&typeof e=="number"?e:1}class ze extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},a=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(a=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?s.ruleId=r:(s.source=r.slice(0,c),s.ruleId=r.slice(c+1))}if(!s.place&&s.ancestors&&s.ancestors){const c=s.ancestors[s.ancestors.length-1];c&&(s.place=c.position)}const o=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=o?o.line:void 0,this.name=kn(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ze.prototype.file="";ze.prototype.name="";ze.prototype.reason="";ze.prototype.message="";ze.prototype.stack="";ze.prototype.column=void 0;ze.prototype.line=void 0;ze.prototype.ancestors=void 0;ze.prototype.cause=void 0;ze.prototype.fatal=void 0;ze.prototype.place=void 0;ze.prototype.ruleId=void 0;ze.prototype.source=void 0;const Ji={}.hasOwnProperty,Mh=new Map,Rh=/[A-Z]/g,Lh=new Set(["table","tbody","thead","tfoot","tr"]),Dh=new Set(["td","th"]),Jo="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function zh(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Hh(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Uh(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Yi:_h,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=Go(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function Go(e,t,n){if(t.type==="element")return Oh(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Fh(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Bh(e,t,n);if(t.type==="mdxjsEsm")return $h(e,t);if(t.type==="root")return qh(e,t,n);if(t.type==="text")return Vh(e,t)}function Oh(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Yi,e.schema=i),e.ancestors.push(t);const s=tl(e,t.tagName,!1),a=Wh(e,t);let o=es(e,t);return Lh.has(t.tagName)&&(o=o.filter(function(c){return typeof c=="string"?!ph(c):!0})),el(e,a,s,t),Gi(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function Fh(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return at(r.type==="ExpressionStatement"),e.evaluater.evaluateExpression(r.expression)}Nn(e,t.position)}function $h(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Nn(e,t.position)}function Bh(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Yi,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:tl(e,t.name,!0),a=Zh(e,t),o=es(e,t);return el(e,a,s,t),Gi(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function qh(e,t,n){const r={};return Gi(r,es(e,t)),e.create(t,e.Fragment,r,n)}function Vh(e,t){return t.value}function el(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Gi(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Uh(e,t,n){return r;function r(i,s,a,o){const u=Array.isArray(a.children)?n:t;return o?u(s,a,o):u(s,a)}}function Hh(e,t){return n;function n(r,i,s,a){const o=Array.isArray(s.children),c=Xi(r);return t(i,s,a,o,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function Wh(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Ji.call(t.properties,i)){const s=Qh(e,i,t.properties[i]);if(s){const[a,o]=s;e.tableCellAlignToStyle&&a==="align"&&typeof o=="string"&&Dh.has(t.tagName)?r=o:n[a]=o}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Zh(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];at(s.type==="ExpressionStatement");const a=s.expression;at(a.type==="ObjectExpression");const o=a.properties[0];at(o.type==="SpreadElement"),Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else Nn(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const o=r.value.data.estree.body[0];at(o.type==="ExpressionStatement"),s=e.evaluater.evaluateExpression(o.expression)}else Nn(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function es(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:Mh;for(;++r<t.children.length;){const s=t.children[r];let a;if(e.passKeys){const c=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(c){const u=i.get(c)||0;a=c+"-"+u,i.set(c,u+1)}}const o=Go(e,s,a);o!==void 0&&n.push(o)}return n}function Qh(e,t,n){const r=vh(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?ch(n):jh(n)),r.property==="style"){let i=typeof n=="object"?n:Kh(e,String(n));return e.stylePropertyNameCase==="css"&&(i=Yh(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?yh[r.property]||r.property:r.attribute,n]}}function Kh(e,t){try{return Eh(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new ze("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=Jo+"#cannot-parse-style-attribute",i}}function tl(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,a;for(;++s<i.length;){const o=Ys(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};a=a?{type:"MemberExpression",object:a,property:o,computed:!!(s&&o.type==="Literal"),optional:!1}:o}r=a}else r=Ys(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Ji.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Nn(e)}function Nn(e,t){const n=new ze("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Jo+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Yh(e){const t={};let n;for(n in e)Ji.call(e,n)&&(t[Xh(n)]=e[n]);return t}function Xh(e){let t=e.replace(Rh,Jh);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Jh(e){return"-"+e.toLowerCase()}const Vr={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},Gh={};function ts(e,t){const n=Gh,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return nl(e,r,i)}function nl(e,t,n){if(ep(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return aa(e.children,t,n)}return Array.isArray(e)?aa(e,t,n):""}function aa(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=nl(e[i],t,n);return r.join("")}function ep(e){return!!(e&&typeof e=="object")}const oa=document.createElement("i");function ns(e){const t="&"+e+";";oa.innerHTML=t;const n=oa.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Je(e,t,n,r){const i=e.length;let s=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);s<r.length;)a=r.slice(s,s+1e4),a.unshift(t,0),e.splice(...a),s+=1e4,t+=1e4}function tt(e,t){return e.length>0?(Je(e,e.length,0,t),e):t}const la={}.hasOwnProperty;function rl(e){const t={};let n=-1;for(;++n<e.length;)tp(t,e[n]);return t}function tp(e,t){let n;for(n in t){const i=(la.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let a;if(s)for(a in s){la.call(i,a)||(i[a]=[]);const o=s[a];np(i[a],Array.isArray(o)?o:o?[o]:[])}}}function np(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Je(e,0,0,r)}function il(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function ot(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ve=Tt(/[A-Za-z]/),De=Tt(/[\dA-Za-z]/),rp=Tt(/[#-'*+\--9=?A-Z^-~]/);function sr(e){return e!==null&&(e<32||e===127)}const Ni=Tt(/\d/),ip=Tt(/[\dA-Fa-f]/),sp=Tt(/[!-/:-@[-`{-~]/);function K(e){return e!==null&&e<-2}function Te(e){return e!==null&&(e<0||e===32)}function ge(e){return e===-2||e===-1||e===32}const Sr=Tt(new RegExp("\\p{P}|\\p{S}","u")),Dt=Tt(/\s/);function Tt(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function dn(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let a="";if(s===37&&De(e.charCodeAt(n+1))&&De(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(a=String.fromCharCode(s));else if(s>55295&&s<57344){const o=e.charCodeAt(n+1);s<56320&&o>56319&&o<57344?(a=String.fromCharCode(s,o),i=1):a="�"}else a=String.fromCharCode(s);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function be(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(c){return ge(c)?(e.enter(n),o(c)):t(c)}function o(c){return ge(c)&&s++<i?(e.consume(c),o):(e.exit(n),t(c))}}const ap={tokenize:op};function op(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),be(e,t,"linePrefix")}function i(o){return e.enter("paragraph"),s(o)}function s(o){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,a(o)}function a(o){if(o===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(o);return}return K(o)?(e.consume(o),e.exit("chunkText"),s):(e.consume(o),a)}}const lp={tokenize:cp},ca={tokenize:up};function cp(e){const t=this,n=[];let r=0,i,s,a;return o;function o(I){if(r<n.length){const Z=n[r];return t.containerState=Z[1],e.attempt(Z[0].continuation,c,u)(I)}return u(I)}function c(I){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&A();const Z=t.events.length;let Q=Z,j;for(;Q--;)if(t.events[Q][0]==="exit"&&t.events[Q][1].type==="chunkFlow"){j=t.events[Q][1].end;break}k(r);let Y=Z;for(;Y<t.events.length;)t.events[Y][1].end={...j},Y++;return Je(t.events,Q+1,0,t.events.slice(Z)),t.events.length=Y,u(I)}return o(I)}function u(I){if(r===n.length){if(!i)return p(I);if(i.currentConstruct&&i.currentConstruct.concrete)return m(I);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(ca,f,d)(I)}function f(I){return i&&A(),k(r),p(I)}function d(I){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,m(I)}function p(I){return t.containerState={},e.attempt(ca,h,m)(I)}function h(I){return r++,n.push([t.currentConstruct,t.containerState]),p(I)}function m(I){if(I===null){i&&A(),k(0),e.consume(I);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),b(I)}function b(I){if(I===null){w(e.exit("chunkFlow"),!0),k(0),e.consume(I);return}return K(I)?(e.consume(I),w(e.exit("chunkFlow")),r=0,t.interrupt=void 0,o):(e.consume(I),b)}function w(I,Z){const Q=t.sliceStream(I);if(Z&&Q.push(null),I.previous=s,s&&(s.next=I),s=I,i.defineSkip(I.start),i.write(Q),t.parser.lazy[I.start.line]){let j=i.events.length;for(;j--;)if(i.events[j][1].start.offset<a&&(!i.events[j][1].end||i.events[j][1].end.offset>a))return;const Y=t.events.length;let X=Y,G,_;for(;X--;)if(t.events[X][0]==="exit"&&t.events[X][1].type==="chunkFlow"){if(G){_=t.events[X][1].end;break}G=!0}for(k(r),j=Y;j<t.events.length;)t.events[j][1].end={..._},j++;Je(t.events,X+1,0,t.events.slice(Y)),t.events.length=j}}function k(I){let Z=n.length;for(;Z-- >I;){const Q=n[Z];t.containerState=Q[1],Q[0].exit.call(t,e)}n.length=I}function A(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function up(e,t,n){return be(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function an(e){if(e===null||Te(e)||Dt(e))return 1;if(Sr(e))return 2}function _r(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const Ii={name:"attention",resolveAll:dp,tokenize:fp};function dp(e,t){let n=-1,r,i,s,a,o,c,u,f;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const d={...e[r][1].end},p={...e[n][1].start};ua(d,-c),ua(p,c),a={type:c>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},o={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},s={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?"strong":"emphasis",start:{...a.start},end:{...o.end}},e[r][1].end={...a.start},e[n][1].start={...o.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=tt(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=tt(u,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",s,t]]),u=tt(u,_r(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=tt(u,[["exit",s,t],["enter",o,t],["exit",o,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,u=tt(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,Je(e,r-1,n-r+3,u),n=r+u.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function fp(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=an(r);let s;return a;function a(c){return s=c,e.enter("attentionSequence"),o(c)}function o(c){if(c===s)return e.consume(c),o;const u=e.exit("attentionSequence"),f=an(c),d=!f||f===2&&i||n.includes(c),p=!i||i===2&&f||n.includes(r);return u._open=!!(s===42?d:d&&(i||!p)),u._close=!!(s===42?p:p&&(f||!d)),t(c)}}function ua(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const hp={name:"autolink",tokenize:pp};function pp(e,t,n){let r=0;return i;function i(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(h){return Ve(h)?(e.consume(h),a):h===64?n(h):u(h)}function a(h){return h===43||h===45||h===46||De(h)?(r=1,o(h)):u(h)}function o(h){return h===58?(e.consume(h),r=0,c):(h===43||h===45||h===46||De(h))&&r++<32?(e.consume(h),o):(r=0,u(h))}function c(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||sr(h)?n(h):(e.consume(h),c)}function u(h){return h===64?(e.consume(h),f):rp(h)?(e.consume(h),u):n(h)}function f(h){return De(h)?d(h):n(h)}function d(h){return h===46?(e.consume(h),r=0,f):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):p(h)}function p(h){if((h===45||De(h))&&r++<63){const m=h===45?p:d;return e.consume(h),m}return n(h)}}const Rn={partial:!0,tokenize:mp};function mp(e,t,n){return r;function r(s){return ge(s)?be(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||K(s)?t(s):n(s)}}const sl={continuation:{tokenize:xp},exit:yp,name:"blockQuote",tokenize:gp};function gp(e,t,n){const r=this;return i;function i(a){if(a===62){const o=r.containerState;return o.open||(e.enter("blockQuote",{_container:!0}),o.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),s}return n(a)}function s(a){return ge(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function xp(e,t,n){const r=this;return i;function i(a){return ge(a)?be(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):s(a)}function s(a){return e.attempt(sl,t,n)(a)}}function yp(e){e.exit("blockQuote")}const al={name:"characterEscape",tokenize:bp};function bp(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return sp(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const ol={name:"characterReference",tokenize:kp};function kp(e,t,n){const r=this;let i=0,s,a;return o;function o(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),c}function c(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),s=31,a=De,f(d))}function u(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,a=ip,f):(e.enter("characterReferenceValue"),s=7,a=Ni,f(d))}function f(d){if(d===59&&i){const p=e.exit("characterReferenceValue");return a===De&&!ns(r.sliceSerialize(p))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(d)&&i++<s?(e.consume(d),f):n(d)}}const da={partial:!0,tokenize:wp},fa={concrete:!0,name:"codeFenced",tokenize:vp};function vp(e,t,n){const r=this,i={partial:!0,tokenize:Q};let s=0,a=0,o;return c;function c(j){return u(j)}function u(j){const Y=r.events[r.events.length-1];return s=Y&&Y[1].type==="linePrefix"?Y[2].sliceSerialize(Y[1],!0).length:0,o=j,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(j)}function f(j){return j===o?(a++,e.consume(j),f):a<3?n(j):(e.exit("codeFencedFenceSequence"),ge(j)?be(e,d,"whitespace")(j):d(j))}function d(j){return j===null||K(j)?(e.exit("codeFencedFence"),r.interrupt?t(j):e.check(da,b,Z)(j)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(j))}function p(j){return j===null||K(j)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(j)):ge(j)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),be(e,h,"whitespace")(j)):j===96&&j===o?n(j):(e.consume(j),p)}function h(j){return j===null||K(j)?d(j):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(j))}function m(j){return j===null||K(j)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(j)):j===96&&j===o?n(j):(e.consume(j),m)}function b(j){return e.attempt(i,Z,w)(j)}function w(j){return e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),k}function k(j){return s>0&&ge(j)?be(e,A,"linePrefix",s+1)(j):A(j)}function A(j){return j===null||K(j)?e.check(da,b,Z)(j):(e.enter("codeFlowValue"),I(j))}function I(j){return j===null||K(j)?(e.exit("codeFlowValue"),A(j)):(e.consume(j),I)}function Z(j){return e.exit("codeFenced"),t(j)}function Q(j,Y,X){let G=0;return _;function _(O){return j.enter("lineEnding"),j.consume(O),j.exit("lineEnding"),F}function F(O){return j.enter("codeFencedFence"),ge(O)?be(j,$,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):$(O)}function $(O){return O===o?(j.enter("codeFencedFenceSequence"),ae(O)):X(O)}function ae(O){return O===o?(G++,j.consume(O),ae):G>=a?(j.exit("codeFencedFenceSequence"),ge(O)?be(j,q,"whitespace")(O):q(O)):X(O)}function q(O){return O===null||K(O)?(j.exit("codeFencedFence"),Y(O)):X(O)}}}function wp(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const Ur={name:"codeIndented",tokenize:_p},Sp={partial:!0,tokenize:jp};function _p(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),be(e,s,"linePrefix",5)(u)}function s(u){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?c(u):K(u)?e.attempt(Sp,a,c)(u):(e.enter("codeFlowValue"),o(u))}function o(u){return u===null||K(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),o)}function c(u){return e.exit("codeIndented"),t(u)}}function jp(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):K(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):be(e,s,"linePrefix",5)(a)}function s(a){const o=r.events[r.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):K(a)?i(a):n(a)}}const Cp={name:"codeText",previous:Ip,resolve:Np,tokenize:Tp};function Np(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Ip(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Tp(e,t,n){let r=0,i,s;return a;function a(d){return e.enter("codeText"),e.enter("codeTextSequence"),o(d)}function o(d){return d===96?(e.consume(d),r++,o):(e.exit("codeTextSequence"),c(d))}function c(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),c):d===96?(s=e.enter("codeTextSequence"),i=0,f(d)):K(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):(e.enter("codeTextData"),u(d))}function u(d){return d===null||d===32||d===96||K(d)?(e.exit("codeTextData"),c(d)):(e.consume(d),u)}function f(d){return d===96?(e.consume(d),i++,f):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(s.type="codeTextData",u(d))}}class Ap{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&xn(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),xn(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),xn(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);xn(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);xn(this.left,n.reverse())}}}function xn(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function ll(e){const t={};let n=-1,r,i,s,a,o,c,u;const f=new Ap(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,s=0,s<c.length&&c[s][1].type==="lineEndingBlank"&&(s+=2),s<c.length&&c[s][1].type==="content"))for(;++s<c.length&&c[s][1].type!=="content";)c[s][1].type==="chunkText"&&(c[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,Ep(f,n)),n=t[n],u=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(a=f.get(s),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(f.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=s);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(r[1].end={...f.get(i)[1].start},o=f.slice(i,n),o.unshift(r),f.splice(i,n-i+1,o))}}return Je(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!u}function Ep(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const o=a.events,c=[],u={};let f,d,p=-1,h=n,m=0,b=0;const w=[b];for(;h;){for(;e.get(++i)[1]!==h;);s.push(i),h._tokenizer||(f=r.sliceStream(h),h.next||f.push(null),d&&a.defineSkip(h.start),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(f),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),d=h,h=h.next}for(h=n;++p<o.length;)o[p][0]==="exit"&&o[p-1][0]==="enter"&&o[p][1].type===o[p-1][1].type&&o[p][1].start.line!==o[p][1].end.line&&(b=p+1,w.push(b),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(a.events=[],h?(h._tokenizer=void 0,h.previous=void 0):w.pop(),p=w.length;p--;){const k=o.slice(w[p],w[p+1]),A=s.pop();c.push([A,A+k.length-1]),e.splice(A,2,k)}for(c.reverse(),p=-1;++p<c.length;)u[m+c[p][0]]=m+c[p][1],m+=c[p][1]-c[p][0]-1;return u}const Pp={resolve:Rp,tokenize:Lp},Mp={partial:!0,tokenize:Dp};function Rp(e){return ll(e),e}function Lp(e,t){let n;return r;function r(o){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(o)}function i(o){return o===null?s(o):K(o)?e.check(Mp,a,s)(o):(e.consume(o),i)}function s(o){return e.exit("chunkContent"),e.exit("content"),t(o)}function a(o){return e.consume(o),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function Dp(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),be(e,s,"linePrefix")}function s(a){if(a===null||K(a))return n(a);const o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function cl(e,t,n,r,i,s,a,o,c){const u=c||Number.POSITIVE_INFINITY;let f=0;return d;function d(k){return k===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(k),e.exit(s),p):k===null||k===32||k===41||sr(k)?n(k):(e.enter(r),e.enter(a),e.enter(o),e.enter("chunkString",{contentType:"string"}),b(k))}function p(k){return k===62?(e.enter(s),e.consume(k),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),h(k))}function h(k){return k===62?(e.exit("chunkString"),e.exit(o),p(k)):k===null||k===60||K(k)?n(k):(e.consume(k),k===92?m:h)}function m(k){return k===60||k===62||k===92?(e.consume(k),h):h(k)}function b(k){return!f&&(k===null||k===41||Te(k))?(e.exit("chunkString"),e.exit(o),e.exit(a),e.exit(r),t(k)):f<u&&k===40?(e.consume(k),f++,b):k===41?(e.consume(k),f--,b):k===null||k===32||k===40||sr(k)?n(k):(e.consume(k),k===92?w:b)}function w(k){return k===40||k===41||k===92?(e.consume(k),b):b(k)}}function ul(e,t,n,r,i,s){const a=this;let o=0,c;return u;function u(h){return e.enter(r),e.enter(i),e.consume(h),e.exit(i),e.enter(s),f}function f(h){return o>999||h===null||h===91||h===93&&!c||h===94&&!o&&"_hiddenFootnoteSupport"in a.parser.constructs?n(h):h===93?(e.exit(s),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):K(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===null||h===91||h===93||K(h)||o++>999?(e.exit("chunkString"),f(h)):(e.consume(h),c||(c=!ge(h)),h===92?p:d)}function p(h){return h===91||h===92||h===93?(e.consume(h),o++,d):d(h)}}function dl(e,t,n,r,i,s){let a;return o;function o(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),a=p===40?41:p,c):n(p)}function c(p){return p===a?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(s),u(p))}function u(p){return p===a?(e.exit(s),c(a)):p===null?n(p):K(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),be(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===a||p===null||K(p)?(e.exit("chunkString"),u(p)):(e.consume(p),p===92?d:f)}function d(p){return p===a||p===92?(e.consume(p),f):f(p)}}function vn(e,t){let n;return r;function r(i){return K(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):ge(i)?be(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const zp={name:"definition",tokenize:Fp},Op={partial:!0,tokenize:$p};function Fp(e,t,n){const r=this;let i;return s;function s(h){return e.enter("definition"),a(h)}function a(h){return ul.call(r,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function o(h){return i=ot(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),c):n(h)}function c(h){return Te(h)?vn(e,u)(h):u(h)}function u(h){return cl(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function f(h){return e.attempt(Op,d,d)(h)}function d(h){return ge(h)?be(e,p,"whitespace")(h):p(h)}function p(h){return h===null||K(h)?(e.exit("definition"),r.parser.defined.push(i),t(h)):n(h)}}function $p(e,t,n){return r;function r(o){return Te(o)?vn(e,i)(o):n(o)}function i(o){return dl(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function s(o){return ge(o)?be(e,a,"whitespace")(o):a(o)}function a(o){return o===null||K(o)?t(o):n(o)}}const Bp={name:"hardBreakEscape",tokenize:qp};function qp(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return K(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const Vp={name:"headingAtx",resolve:Up,tokenize:Hp};function Up(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Je(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function Hp(e,t,n){let r=0;return i;function i(f){return e.enter("atxHeading"),s(f)}function s(f){return e.enter("atxHeadingSequence"),a(f)}function a(f){return f===35&&r++<6?(e.consume(f),a):f===null||Te(f)?(e.exit("atxHeadingSequence"),o(f)):n(f)}function o(f){return f===35?(e.enter("atxHeadingSequence"),c(f)):f===null||K(f)?(e.exit("atxHeading"),t(f)):ge(f)?be(e,o,"whitespace")(f):(e.enter("atxHeadingText"),u(f))}function c(f){return f===35?(e.consume(f),c):(e.exit("atxHeadingSequence"),o(f))}function u(f){return f===null||f===35||Te(f)?(e.exit("atxHeadingText"),o(f)):(e.consume(f),u)}}const Wp=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],ha=["pre","script","style","textarea"],Zp={concrete:!0,name:"htmlFlow",resolveTo:Yp,tokenize:Xp},Qp={partial:!0,tokenize:Gp},Kp={partial:!0,tokenize:Jp};function Yp(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Xp(e,t,n){const r=this;let i,s,a,o,c;return u;function u(y){return f(y)}function f(y){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(y),d}function d(y){return y===33?(e.consume(y),p):y===47?(e.consume(y),s=!0,b):y===63?(e.consume(y),i=3,r.interrupt?t:x):Ve(y)?(e.consume(y),a=String.fromCharCode(y),w):n(y)}function p(y){return y===45?(e.consume(y),i=2,h):y===91?(e.consume(y),i=5,o=0,m):Ve(y)?(e.consume(y),i=4,r.interrupt?t:x):n(y)}function h(y){return y===45?(e.consume(y),r.interrupt?t:x):n(y)}function m(y){const Ee="CDATA[";return y===Ee.charCodeAt(o++)?(e.consume(y),o===Ee.length?r.interrupt?t:$:m):n(y)}function b(y){return Ve(y)?(e.consume(y),a=String.fromCharCode(y),w):n(y)}function w(y){if(y===null||y===47||y===62||Te(y)){const Ee=y===47,Ie=a.toLowerCase();return!Ee&&!s&&ha.includes(Ie)?(i=1,r.interrupt?t(y):$(y)):Wp.includes(a.toLowerCase())?(i=6,Ee?(e.consume(y),k):r.interrupt?t(y):$(y)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(y):s?A(y):I(y))}return y===45||De(y)?(e.consume(y),a+=String.fromCharCode(y),w):n(y)}function k(y){return y===62?(e.consume(y),r.interrupt?t:$):n(y)}function A(y){return ge(y)?(e.consume(y),A):_(y)}function I(y){return y===47?(e.consume(y),_):y===58||y===95||Ve(y)?(e.consume(y),Z):ge(y)?(e.consume(y),I):_(y)}function Z(y){return y===45||y===46||y===58||y===95||De(y)?(e.consume(y),Z):Q(y)}function Q(y){return y===61?(e.consume(y),j):ge(y)?(e.consume(y),Q):I(y)}function j(y){return y===null||y===60||y===61||y===62||y===96?n(y):y===34||y===39?(e.consume(y),c=y,Y):ge(y)?(e.consume(y),j):X(y)}function Y(y){return y===c?(e.consume(y),c=null,G):y===null||K(y)?n(y):(e.consume(y),Y)}function X(y){return y===null||y===34||y===39||y===47||y===60||y===61||y===62||y===96||Te(y)?Q(y):(e.consume(y),X)}function G(y){return y===47||y===62||ge(y)?I(y):n(y)}function _(y){return y===62?(e.consume(y),F):n(y)}function F(y){return y===null||K(y)?$(y):ge(y)?(e.consume(y),F):n(y)}function $(y){return y===45&&i===2?(e.consume(y),J):y===60&&i===1?(e.consume(y),de):y===62&&i===4?(e.consume(y),z):y===63&&i===3?(e.consume(y),x):y===93&&i===5?(e.consume(y),P):K(y)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Qp,me,ae)(y)):y===null||K(y)?(e.exit("htmlFlowData"),ae(y)):(e.consume(y),$)}function ae(y){return e.check(Kp,q,me)(y)}function q(y){return e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),O}function O(y){return y===null||K(y)?ae(y):(e.enter("htmlFlowData"),$(y))}function J(y){return y===45?(e.consume(y),x):$(y)}function de(y){return y===47?(e.consume(y),a="",Ce):$(y)}function Ce(y){if(y===62){const Ee=a.toLowerCase();return ha.includes(Ee)?(e.consume(y),z):$(y)}return Ve(y)&&a.length<8?(e.consume(y),a+=String.fromCharCode(y),Ce):$(y)}function P(y){return y===93?(e.consume(y),x):$(y)}function x(y){return y===62?(e.consume(y),z):y===45&&i===2?(e.consume(y),x):$(y)}function z(y){return y===null||K(y)?(e.exit("htmlFlowData"),me(y)):(e.consume(y),z)}function me(y){return e.exit("htmlFlow"),t(y)}}function Jp(e,t,n){const r=this;return i;function i(a){return K(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):n(a)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function Gp(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Rn,t,n)}}const em={name:"htmlText",tokenize:tm};function tm(e,t,n){const r=this;let i,s,a;return o;function o(x){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(x),c}function c(x){return x===33?(e.consume(x),u):x===47?(e.consume(x),Q):x===63?(e.consume(x),I):Ve(x)?(e.consume(x),X):n(x)}function u(x){return x===45?(e.consume(x),f):x===91?(e.consume(x),s=0,m):Ve(x)?(e.consume(x),A):n(x)}function f(x){return x===45?(e.consume(x),h):n(x)}function d(x){return x===null?n(x):x===45?(e.consume(x),p):K(x)?(a=d,de(x)):(e.consume(x),d)}function p(x){return x===45?(e.consume(x),h):d(x)}function h(x){return x===62?J(x):x===45?p(x):d(x)}function m(x){const z="CDATA[";return x===z.charCodeAt(s++)?(e.consume(x),s===z.length?b:m):n(x)}function b(x){return x===null?n(x):x===93?(e.consume(x),w):K(x)?(a=b,de(x)):(e.consume(x),b)}function w(x){return x===93?(e.consume(x),k):b(x)}function k(x){return x===62?J(x):x===93?(e.consume(x),k):b(x)}function A(x){return x===null||x===62?J(x):K(x)?(a=A,de(x)):(e.consume(x),A)}function I(x){return x===null?n(x):x===63?(e.consume(x),Z):K(x)?(a=I,de(x)):(e.consume(x),I)}function Z(x){return x===62?J(x):I(x)}function Q(x){return Ve(x)?(e.consume(x),j):n(x)}function j(x){return x===45||De(x)?(e.consume(x),j):Y(x)}function Y(x){return K(x)?(a=Y,de(x)):ge(x)?(e.consume(x),Y):J(x)}function X(x){return x===45||De(x)?(e.consume(x),X):x===47||x===62||Te(x)?G(x):n(x)}function G(x){return x===47?(e.consume(x),J):x===58||x===95||Ve(x)?(e.consume(x),_):K(x)?(a=G,de(x)):ge(x)?(e.consume(x),G):J(x)}function _(x){return x===45||x===46||x===58||x===95||De(x)?(e.consume(x),_):F(x)}function F(x){return x===61?(e.consume(x),$):K(x)?(a=F,de(x)):ge(x)?(e.consume(x),F):G(x)}function $(x){return x===null||x===60||x===61||x===62||x===96?n(x):x===34||x===39?(e.consume(x),i=x,ae):K(x)?(a=$,de(x)):ge(x)?(e.consume(x),$):(e.consume(x),q)}function ae(x){return x===i?(e.consume(x),i=void 0,O):x===null?n(x):K(x)?(a=ae,de(x)):(e.consume(x),ae)}function q(x){return x===null||x===34||x===39||x===60||x===61||x===96?n(x):x===47||x===62||Te(x)?G(x):(e.consume(x),q)}function O(x){return x===47||x===62||Te(x)?G(x):n(x)}function J(x){return x===62?(e.consume(x),e.exit("htmlTextData"),e.exit("htmlText"),t):n(x)}function de(x){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),Ce}function Ce(x){return ge(x)?be(e,P,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(x):P(x)}function P(x){return e.enter("htmlTextData"),a(x)}}const rs={name:"labelEnd",resolveAll:sm,resolveTo:am,tokenize:om},nm={tokenize:lm},rm={tokenize:cm},im={tokenize:um};function sm(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&Je(e,0,e.length,n),e}function am(e,t){let n=e.length,r=0,i,s,a,o;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=n);const c={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[s][1].start},end:{...e[a][1].end}},f={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[a-2][1].start}};return o=[["enter",c,t],["enter",u,t]],o=tt(o,e.slice(s+1,s+r+3)),o=tt(o,[["enter",f,t]]),o=tt(o,_r(t.parser.constructs.insideSpan.null,e.slice(s+r+4,a-3),t)),o=tt(o,[["exit",f,t],e[a-2],e[a-1],["exit",u,t]]),o=tt(o,e.slice(a+1)),o=tt(o,[["exit",c,t]]),Je(e,s,e.length,o),e}function om(e,t,n){const r=this;let i=r.events.length,s,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return o;function o(p){return s?s._inactive?d(p):(a=r.parser.defined.includes(ot(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),c):n(p)}function c(p){return p===40?e.attempt(nm,f,a?f:d)(p):p===91?e.attempt(rm,f,a?u:d)(p):a?f(p):d(p)}function u(p){return e.attempt(im,f,d)(p)}function f(p){return t(p)}function d(p){return s._balanced=!0,n(p)}}function lm(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),i}function i(d){return Te(d)?vn(e,s)(d):s(d)}function s(d){return d===41?f(d):cl(e,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function a(d){return Te(d)?vn(e,c)(d):f(d)}function o(d){return n(d)}function c(d){return d===34||d===39||d===40?dl(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):f(d)}function u(d){return Te(d)?vn(e,f)(d):f(d)}function f(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function cm(e,t,n){const r=this;return i;function i(o){return ul.call(r,e,s,a,"reference","referenceMarker","referenceString")(o)}function s(o){return r.parser.defined.includes(ot(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function a(o){return n(o)}}function um(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const dm={name:"labelStartImage",resolveAll:rs.resolveAll,tokenize:fm};function fm(e,t,n){const r=this;return i;function i(o){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(o),e.exit("labelImageMarker"),s}function s(o){return o===91?(e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelImage"),a):n(o)}function a(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const hm={name:"labelStartLink",resolveAll:rs.resolveAll,tokenize:pm};function pm(e,t,n){const r=this;return i;function i(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),s}function s(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const Hr={name:"lineEnding",tokenize:mm};function mm(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),be(e,t,"linePrefix")}}const Qn={name:"thematicBreak",tokenize:gm};function gm(e,t,n){let r=0,i;return s;function s(u){return e.enter("thematicBreak"),a(u)}function a(u){return i=u,o(u)}function o(u){return u===i?(e.enter("thematicBreakSequence"),c(u)):r>=3&&(u===null||K(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===i?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),ge(u)?be(e,o,"whitespace")(u):o(u))}}const Ze={continuation:{tokenize:km},exit:wm,name:"list",tokenize:bm},xm={partial:!0,tokenize:Sm},ym={partial:!0,tokenize:vm};function bm(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return o;function o(h){const m=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:Ni(h)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(Qn,n,u)(h):u(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(h)}return n(h)}function c(h){return Ni(h)&&++a<10?(e.consume(h),c):(!r.interrupt||a<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),u(h)):n(h)}function u(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(Rn,r.interrupt?n:f,e.attempt(xm,p,d))}function f(h){return r.containerState.initialBlankLine=!0,s++,p(h)}function d(h){return ge(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),p):n(h)}function p(h){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function km(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Rn,i,s);function i(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,be(e,t,"listItemIndent",r.containerState.size+1)(o)}function s(o){return r.containerState.furtherBlankLines||!ge(o)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(o)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(ym,t,a)(o))}function a(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,be(e,e.attempt(Ze,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function vm(e,t,n){const r=this;return be(e,i,"listItemIndent",r.containerState.size+1);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(s):n(s)}}function wm(e){e.exit(this.containerState.type)}function Sm(e,t,n){const r=this;return be(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const a=r.events[r.events.length-1];return!ge(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const pa={name:"setextUnderline",resolveTo:_m,tokenize:jm};function _m(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",a,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function jm(e,t,n){const r=this;let i;return s;function s(u){let f=r.events.length,d;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){d=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),i=u,a(u)):n(u)}function a(u){return e.enter("setextHeadingLineSequence"),o(u)}function o(u){return u===i?(e.consume(u),o):(e.exit("setextHeadingLineSequence"),ge(u)?be(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||K(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const Cm={tokenize:Nm};function Nm(e){const t=this,n=e.attempt(Rn,r,e.attempt(this.parser.constructs.flowInitial,i,be(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Pp,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Im={resolveAll:hl()},Tm=fl("string"),Am=fl("text");function fl(e){return{resolveAll:hl(e==="text"?Em:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,a,o);return a;function a(f){return u(f)?s(f):o(f)}function o(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),c}function c(f){return u(f)?(n.exit("data"),s(f)):(n.consume(f),c)}function u(f){if(f===null)return!0;const d=i[f];let p=-1;if(d)for(;++p<d.length;){const h=d[p];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function hl(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function Em(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,a=-1,o=0,c;for(;s--;){const u=i[s];if(typeof u=="string"){for(a=u.length;u.charCodeAt(a-1)===32;)o++,a--;if(a)break;a=-1}else if(u===-2)c=!0,o++;else if(u!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(o=0),o){const u={type:n===e.length||c||o<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?a:r.start._bufferIndex+a,_index:r.start._index+s,line:r.end.line,column:r.end.column-o,offset:r.end.offset-o},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const Pm={42:Ze,43:Ze,45:Ze,48:Ze,49:Ze,50:Ze,51:Ze,52:Ze,53:Ze,54:Ze,55:Ze,56:Ze,57:Ze,62:sl},Mm={91:zp},Rm={[-2]:Ur,[-1]:Ur,32:Ur},Lm={35:Vp,42:Qn,45:[pa,Qn],60:Zp,61:pa,95:Qn,96:fa,126:fa},Dm={38:ol,92:al},zm={[-5]:Hr,[-4]:Hr,[-3]:Hr,33:dm,38:ol,42:Ii,60:[hp,em],91:hm,92:[Bp,al],93:rs,95:Ii,96:Cp},Om={null:[Ii,Im]},Fm={null:[42,95]},$m={null:[]},Bm=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Fm,contentInitial:Mm,disable:$m,document:Pm,flow:Lm,flowInitial:Rm,insideSpan:Om,string:Dm,text:zm},Symbol.toStringTag,{value:"Module"}));function qm(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let a=[],o=[];const c={attempt:Y(Q),check:Y(j),consume:A,enter:I,exit:Z,interrupt:Y(j,{interrupt:!0})},u={code:null,containerState:{},defineSkip:b,events:[],now:m,parser:e,previous:null,sliceSerialize:p,sliceStream:h,write:d};let f=t.tokenize.call(u,c);return t.resolveAll&&s.push(t),u;function d(F){return a=tt(a,F),w(),a[a.length-1]!==null?[]:(X(t,0),u.events=_r(s,u.events,u),u.events)}function p(F,$){return Um(h(F),$)}function h(F){return Vm(a,F)}function m(){const{_bufferIndex:F,_index:$,line:ae,column:q,offset:O}=r;return{_bufferIndex:F,_index:$,line:ae,column:q,offset:O}}function b(F){i[F.line]=F.column,_()}function w(){let F;for(;r._index<a.length;){const $=a[r._index];if(typeof $=="string")for(F=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===F&&r._bufferIndex<$.length;)k($.charCodeAt(r._bufferIndex));else k($)}}function k(F){f=f(F)}function A(F){K(F)?(r.line++,r.column=1,r.offset+=F===-3?2:1,_()):F!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=F}function I(F,$){const ae=$||{};return ae.type=F,ae.start=m(),u.events.push(["enter",ae,u]),o.push(ae),ae}function Z(F){const $=o.pop();return $.end=m(),u.events.push(["exit",$,u]),$}function Q(F,$){X(F,$.from)}function j(F,$){$.restore()}function Y(F,$){return ae;function ae(q,O,J){let de,Ce,P,x;return Array.isArray(q)?me(q):"tokenize"in q?me([q]):z(q);function z(Ne){return Le;function Le(le){const Ke=le!==null&&Ne[le],Oe=le!==null&&Ne.null,Ye=[...Array.isArray(Ke)?Ke:Ke?[Ke]:[],...Array.isArray(Oe)?Oe:Oe?[Oe]:[]];return me(Ye)(le)}}function me(Ne){return de=Ne,Ce=0,Ne.length===0?J:y(Ne[Ce])}function y(Ne){return Le;function Le(le){return x=G(),P=Ne,Ne.partial||(u.currentConstruct=Ne),Ne.name&&u.parser.constructs.disable.null.includes(Ne.name)?Ie():Ne.tokenize.call($?Object.assign(Object.create(u),$):u,c,Ee,Ie)(le)}}function Ee(Ne){return F(P,x),O}function Ie(Ne){return x.restore(),++Ce<de.length?y(de[Ce]):J}}}function X(F,$){F.resolveAll&&!s.includes(F)&&s.push(F),F.resolve&&Je(u.events,$,u.events.length-$,F.resolve(u.events.slice($),u)),F.resolveTo&&(u.events=F.resolveTo(u.events,u))}function G(){const F=m(),$=u.previous,ae=u.currentConstruct,q=u.events.length,O=Array.from(o);return{from:q,restore:J};function J(){r=F,u.previous=$,u.currentConstruct=ae,u.events.length=q,o=O,_()}}function _(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Vm(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let a;if(n===i)a=[e[n].slice(r,s)];else{if(a=e.slice(n,i),r>-1){const o=a[0];typeof o=="string"?a[0]=o.slice(r):a.shift()}s>0&&a.push(e[i].slice(0,s))}return a}function Um(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let a;if(typeof s=="string")a=s;else switch(s){case-5:{a="\r";break}case-4:{a=`
4
- `;break}case-3:{a=`\r
5
- `;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&i)continue;a=" ";break}default:a=String.fromCharCode(s)}i=s===-2,r.push(a)}return r.join("")}function Hm(e){const r={constructs:rl([Bm,...(e||{}).extensions||[]]),content:i(ap),defined:[],document:i(lp),flow:i(Cm),lazy:{},string:i(Tm),text:i(Am)};return r;function i(s){return a;function a(o){return qm(r,s,o)}}}function Wm(e){for(;!ll(e););return e}const ma=/[\0\t\n\r]/g;function Zm(){let e=1,t="",n=!0,r;return i;function i(s,a,o){const c=[];let u,f,d,p,h;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(a||void 0).decode(s)),d=0,t="",n&&(s.charCodeAt(0)===65279&&d++,n=void 0);d<s.length;){if(ma.lastIndex=d,u=ma.exec(s),p=u&&u.index!==void 0?u.index:s.length,h=s.charCodeAt(p),!u){t=s.slice(d);break}if(h===10&&d===p&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),d<p&&(c.push(s.slice(d,p)),e+=p-d),h){case 0:{c.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,c.push(-2);e++<f;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}d=p+1}return o&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const Qm=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Km(e){return e.replace(Qm,Ym)}function Ym(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return il(n.slice(s?2:1),s?16:10)}return ns(n)||e}const pl={}.hasOwnProperty;function Xm(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),Jm(n)(Wm(Hm(n).document().write(Zm()(e,t,!0))))}function Jm(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(se),autolinkProtocol:G,autolinkEmail:G,atxHeading:s(ke),blockQuote:s(Oe),characterEscape:G,characterReference:G,codeFenced:s(Ye),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:s(Ye,a),codeText:s(C,a),codeTextData:G,data:G,codeFlowValue:G,definition:s(U),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:s(ie),hardBreakEscape:s(Se),hardBreakTrailing:s(Se),htmlFlow:s(Fe,a),htmlFlowData:G,htmlText:s(Fe,a),htmlTextData:G,image:s(Ft),label:a,link:s(se),listItem:s(M),listItemValue:p,listOrdered:s(He,d),listUnordered:s(He),paragraph:s($t),reference:y,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:s(ke),strong:s(Ge),thematicBreak:s(Bt)},exit:{atxHeading:c(),atxHeadingSequence:Q,autolink:c(),autolinkEmail:Ke,autolinkProtocol:le,blockQuote:c(),characterEscapeValue:_,characterReferenceMarkerHexadecimal:Ie,characterReferenceMarkerNumeric:Ie,characterReferenceValue:Ne,characterReference:Le,codeFenced:c(w),codeFencedFence:b,codeFencedFenceInfo:h,codeFencedFenceMeta:m,codeFlowValue:_,codeIndented:c(k),codeText:c(O),codeTextData:_,data:_,definition:c(),definitionDestinationString:Z,definitionLabelString:A,definitionTitleString:I,emphasis:c(),hardBreakEscape:c($),hardBreakTrailing:c($),htmlFlow:c(ae),htmlFlowData:_,htmlText:c(q),htmlTextData:_,image:c(de),label:P,labelText:Ce,lineEnding:F,link:c(J),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:Ee,resourceDestinationString:x,resourceTitleString:z,resource:me,setextHeading:c(X),setextHeadingLineSequence:Y,setextHeadingText:j,strong:c(),thematicBreak:c()}};ml(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(N){let R={type:"root",children:[]};const ee={stack:[R],tokenStack:[],config:t,enter:o,exit:u,buffer:a,resume:f,data:n},fe=[];let _e=-1;for(;++_e<N.length;)if(N[_e][1].type==="listOrdered"||N[_e][1].type==="listUnordered")if(N[_e][0]==="enter")fe.push(_e);else{const We=fe.pop();_e=i(N,We,_e)}for(_e=-1;++_e<N.length;){const We=t[N[_e][0]];pl.call(We,N[_e][1].type)&&We[N[_e][1].type].call(Object.assign({sliceSerialize:N[_e][2].sliceSerialize},ee),N[_e][1])}if(ee.tokenStack.length>0){const We=ee.tokenStack[ee.tokenStack.length-1];(We[1]||ga).call(ee,void 0,We[0])}for(R.position={start:St(N.length>0?N[0][1].start:{line:1,column:1,offset:0}),end:St(N.length>0?N[N.length-2][1].end:{line:1,column:1,offset:0})},_e=-1;++_e<t.transforms.length;)R=t.transforms[_e](R)||R;return R}function i(N,R,ee){let fe=R-1,_e=-1,We=!1,lt,it,vt,At;for(;++fe<=ee;){const $e=N[fe];switch($e[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{$e[0]==="enter"?_e++:_e--,At=void 0;break}case"lineEndingBlank":{$e[0]==="enter"&&(lt&&!At&&!_e&&!vt&&(vt=fe),At=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:At=void 0}if(!_e&&$e[0]==="enter"&&$e[1].type==="listItemPrefix"||_e===-1&&$e[0]==="exit"&&($e[1].type==="listUnordered"||$e[1].type==="listOrdered")){if(lt){let et=fe;for(it=void 0;et--;){const Be=N[et];if(Be[1].type==="lineEnding"||Be[1].type==="lineEndingBlank"){if(Be[0]==="exit")continue;it&&(N[it][1].type="lineEndingBlank",We=!0),Be[1].type="lineEnding",it=et}else if(!(Be[1].type==="linePrefix"||Be[1].type==="blockQuotePrefix"||Be[1].type==="blockQuotePrefixWhitespace"||Be[1].type==="blockQuoteMarker"||Be[1].type==="listItemIndent"))break}vt&&(!it||vt<it)&&(lt._spread=!0),lt.end=Object.assign({},it?N[it][1].start:$e[1].end),N.splice(it||fe,0,["exit",lt,$e[2]]),fe++,ee++}if($e[1].type==="listItemPrefix"){const et={type:"listItem",_spread:!1,start:Object.assign({},$e[1].start),end:void 0};lt=et,N.splice(fe,0,["enter",et,$e[2]]),fe++,ee++,vt=void 0,At=!0}}}return N[R][1]._spread=We,ee}function s(N,R){return ee;function ee(fe){o.call(this,N(fe),fe),R&&R.call(this,fe)}}function a(){this.stack.push({type:"fragment",children:[]})}function o(N,R,ee){this.stack[this.stack.length-1].children.push(N),this.stack.push(N),this.tokenStack.push([R,ee||void 0]),N.position={start:St(R.start),end:void 0}}function c(N){return R;function R(ee){N&&N.call(this,ee),u.call(this,ee)}}function u(N,R){const ee=this.stack.pop(),fe=this.tokenStack.pop();if(fe)fe[0].type!==N.type&&(R?R.call(this,N,fe[0]):(fe[1]||ga).call(this,N,fe[0]));else throw new Error("Cannot close `"+N.type+"` ("+kn({start:N.start,end:N.end})+"): it’s not open");ee.position.end=St(N.end)}function f(){return ts(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function p(N){if(this.data.expectingFirstListItemValue){const R=this.stack[this.stack.length-2];R.start=Number.parseInt(this.sliceSerialize(N),10),this.data.expectingFirstListItemValue=void 0}}function h(){const N=this.resume(),R=this.stack[this.stack.length-1];R.lang=N}function m(){const N=this.resume(),R=this.stack[this.stack.length-1];R.meta=N}function b(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const N=this.resume(),R=this.stack[this.stack.length-1];R.value=N.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function k(){const N=this.resume(),R=this.stack[this.stack.length-1];R.value=N.replace(/(\r?\n|\r)$/g,"")}function A(N){const R=this.resume(),ee=this.stack[this.stack.length-1];ee.label=R,ee.identifier=ot(this.sliceSerialize(N)).toLowerCase()}function I(){const N=this.resume(),R=this.stack[this.stack.length-1];R.title=N}function Z(){const N=this.resume(),R=this.stack[this.stack.length-1];R.url=N}function Q(N){const R=this.stack[this.stack.length-1];if(!R.depth){const ee=this.sliceSerialize(N).length;R.depth=ee}}function j(){this.data.setextHeadingSlurpLineEnding=!0}function Y(N){const R=this.stack[this.stack.length-1];R.depth=this.sliceSerialize(N).codePointAt(0)===61?1:2}function X(){this.data.setextHeadingSlurpLineEnding=void 0}function G(N){const ee=this.stack[this.stack.length-1].children;let fe=ee[ee.length-1];(!fe||fe.type!=="text")&&(fe=kt(),fe.position={start:St(N.start),end:void 0},ee.push(fe)),this.stack.push(fe)}function _(N){const R=this.stack.pop();R.value+=this.sliceSerialize(N),R.position.end=St(N.end)}function F(N){const R=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ee=R.children[R.children.length-1];ee.position.end=St(N.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(R.type)&&(G.call(this,N),_.call(this,N))}function $(){this.data.atHardBreak=!0}function ae(){const N=this.resume(),R=this.stack[this.stack.length-1];R.value=N}function q(){const N=this.resume(),R=this.stack[this.stack.length-1];R.value=N}function O(){const N=this.resume(),R=this.stack[this.stack.length-1];R.value=N}function J(){const N=this.stack[this.stack.length-1];if(this.data.inReference){const R=this.data.referenceType||"shortcut";N.type+="Reference",N.referenceType=R,delete N.url,delete N.title}else delete N.identifier,delete N.label;this.data.referenceType=void 0}function de(){const N=this.stack[this.stack.length-1];if(this.data.inReference){const R=this.data.referenceType||"shortcut";N.type+="Reference",N.referenceType=R,delete N.url,delete N.title}else delete N.identifier,delete N.label;this.data.referenceType=void 0}function Ce(N){const R=this.sliceSerialize(N),ee=this.stack[this.stack.length-2];ee.label=Km(R),ee.identifier=ot(R).toLowerCase()}function P(){const N=this.stack[this.stack.length-1],R=this.resume(),ee=this.stack[this.stack.length-1];if(this.data.inReference=!0,ee.type==="link"){const fe=N.children;ee.children=fe}else ee.alt=R}function x(){const N=this.resume(),R=this.stack[this.stack.length-1];R.url=N}function z(){const N=this.resume(),R=this.stack[this.stack.length-1];R.title=N}function me(){this.data.inReference=void 0}function y(){this.data.referenceType="collapsed"}function Ee(N){const R=this.resume(),ee=this.stack[this.stack.length-1];ee.label=R,ee.identifier=ot(this.sliceSerialize(N)).toLowerCase(),this.data.referenceType="full"}function Ie(N){this.data.characterReferenceType=N.type}function Ne(N){const R=this.sliceSerialize(N),ee=this.data.characterReferenceType;let fe;ee?(fe=il(R,ee==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):fe=ns(R);const _e=this.stack[this.stack.length-1];_e.value+=fe}function Le(N){const R=this.stack.pop();R.position.end=St(N.end)}function le(N){_.call(this,N);const R=this.stack[this.stack.length-1];R.url=this.sliceSerialize(N)}function Ke(N){_.call(this,N);const R=this.stack[this.stack.length-1];R.url="mailto:"+this.sliceSerialize(N)}function Oe(){return{type:"blockquote",children:[]}}function Ye(){return{type:"code",lang:null,meta:null,value:""}}function C(){return{type:"inlineCode",value:""}}function U(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ie(){return{type:"emphasis",children:[]}}function ke(){return{type:"heading",depth:0,children:[]}}function Se(){return{type:"break"}}function Fe(){return{type:"html",value:""}}function Ft(){return{type:"image",title:null,url:"",alt:null}}function se(){return{type:"link",title:null,url:"",children:[]}}function He(N){return{type:"list",ordered:N.type==="listOrdered",start:null,spread:N._spread,children:[]}}function M(N){return{type:"listItem",spread:N._spread,checked:null,children:[]}}function $t(){return{type:"paragraph",children:[]}}function Ge(){return{type:"strong",children:[]}}function kt(){return{type:"text",value:""}}function Bt(){return{type:"thematicBreak"}}}function St(e){return{line:e.line,column:e.column,offset:e.offset}}function ml(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?ml(e,r):Gm(e,r)}}function Gm(e,t){let n;for(n in t)if(pl.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function ga(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+kn({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+kn({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+kn({start:t.start,end:t.end})+") is still open")}function eg(e){const t=this;t.parser=n;function n(r){return Xm(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function tg(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function ng(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
6
- `}]}function rg(e,t){const n=t.value?t.value+`
7
- `:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function ig(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function sg(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ag(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=dn(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let a,o=e.footnoteCounts.get(r);o===void 0?(o=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=s+1,o+=1,e.footnoteCounts.set(r,o);const c={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(o>1?"-"+o:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,c);const u={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,u),e.applyData(t,u)}function og(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function lg(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function gl(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const a=i[i.length-1];return a&&a.type==="text"?a.value+=r:i.push({type:"text",value:r}),i}function cg(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return gl(e,t);const i={src:dn(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function ug(e,t){const n={src:dn(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function dg(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function fg(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return gl(e,t);const i={href:dn(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function hg(e,t){const n={href:dn(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function pg(e,t,n){const r=e.all(t),i=n?mg(n):xl(t),s={},a=[];if(typeof t.checked=="boolean"){const f=r[0];let d;f&&f.type==="element"&&f.tagName==="p"?d=f:(d={type:"element",tagName:"p",properties:{},children:[]},r.unshift(d)),d.children.length>0&&d.children.unshift({type:"text",value:" "}),d.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let o=-1;for(;++o<r.length;){const f=r[o];(i||o!==0||f.type!=="element"||f.tagName!=="p")&&a.push({type:"text",value:`
8
- `}),f.type==="element"&&f.tagName==="p"&&!i?a.push(...f.children):a.push(f)}const c=r[r.length-1];c&&(i||c.type!=="element"||c.tagName!=="p")&&a.push({type:"text",value:`
9
- `});const u={type:"element",tagName:"li",properties:s,children:a};return e.patch(t,u),e.applyData(t,u)}function mg(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=xl(n[r])}return t}function xl(e){const t=e.spread;return t??e.children.length>1}function gg(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const a=r[i];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)}function xg(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function yg(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function bg(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function kg(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),i.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},o=Xi(t.children[1]),c=Yo(t.children[t.children.length-1]);o&&c&&(a.position={start:o,end:c}),i.push(a)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function vg(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,o=a?a.length:t.children.length;let c=-1;const u=[];for(;++c<o;){const d=t.children[c],p={},h=a?a[c]:void 0;h&&(p.align=h);let m={type:"element",tagName:s,properties:p,children:[]};d&&(m.children=e.all(d),e.patch(d,m),m=e.applyData(d,m)),u.push(m)}const f={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,f),e.applyData(t,f)}function wg(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const xa=9,ya=32;function Sg(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(ba(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(ba(t.slice(i),i>0,!1)),s.join("")}function ba(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===xa||s===ya;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===xa||s===ya;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function _g(e,t){const n={type:"text",value:Sg(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function jg(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const Cg={blockquote:tg,break:ng,code:rg,delete:ig,emphasis:sg,footnoteReference:ag,heading:og,html:lg,imageReference:cg,image:ug,inlineCode:dg,linkReference:fg,link:hg,listItem:pg,list:gg,paragraph:xg,root:yg,strong:bg,table:kg,tableCell:wg,tableRow:vg,text:_g,thematicBreak:jg,toml:Bn,yaml:Bn,definition:Bn,footnoteDefinition:Bn};function Bn(){}const yl=-1,jr=0,wn=1,ar=2,is=3,ss=4,as=5,os=6,bl=7,kl=8,ka=typeof self=="object"?self:globalThis,Ng=(e,t)=>{const n=(i,s)=>(e.set(s,i),i),r=i=>{if(e.has(i))return e.get(i);const[s,a]=t[i];switch(s){case jr:case yl:return n(a,i);case wn:{const o=n([],i);for(const c of a)o.push(r(c));return o}case ar:{const o=n({},i);for(const[c,u]of a)o[r(c)]=r(u);return o}case is:return n(new Date(a),i);case ss:{const{source:o,flags:c}=a;return n(new RegExp(o,c),i)}case as:{const o=n(new Map,i);for(const[c,u]of a)o.set(r(c),r(u));return o}case os:{const o=n(new Set,i);for(const c of a)o.add(r(c));return o}case bl:{const{name:o,message:c}=a;return n(new ka[o](c),i)}case kl:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:o}=new Uint8Array(a);return n(new DataView(o),a)}}return n(new ka[s](a),i)};return r},va=e=>Ng(new Map,e)(0),Ut="",{toString:Ig}={},{keys:Tg}=Object,yn=e=>{const t=typeof e;if(t!=="object"||!e)return[jr,t];const n=Ig.call(e).slice(8,-1);switch(n){case"Array":return[wn,Ut];case"Object":return[ar,Ut];case"Date":return[is,Ut];case"RegExp":return[ss,Ut];case"Map":return[as,Ut];case"Set":return[os,Ut];case"DataView":return[wn,n]}return n.includes("Array")?[wn,n]:n.includes("Error")?[bl,n]:[ar,n]},qn=([e,t])=>e===jr&&(t==="function"||t==="symbol"),Ag=(e,t,n,r)=>{const i=(a,o)=>{const c=r.push(a)-1;return n.set(o,c),c},s=a=>{if(n.has(a))return n.get(a);let[o,c]=yn(a);switch(o){case jr:{let f=a;switch(c){case"bigint":o=kl,f=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);f=null;break;case"undefined":return i([yl],a)}return i([o,f],a)}case wn:{if(c){let p=a;return c==="DataView"?p=new Uint8Array(a.buffer):c==="ArrayBuffer"&&(p=new Uint8Array(a)),i([c,[...p]],a)}const f=[],d=i([o,f],a);for(const p of a)f.push(s(p));return d}case ar:{if(c)switch(c){case"BigInt":return i([c,a.toString()],a);case"Boolean":case"Number":case"String":return i([c,a.valueOf()],a)}if(t&&"toJSON"in a)return s(a.toJSON());const f=[],d=i([o,f],a);for(const p of Tg(a))(e||!qn(yn(a[p])))&&f.push([s(p),s(a[p])]);return d}case is:return i([o,a.toISOString()],a);case ss:{const{source:f,flags:d}=a;return i([o,{source:f,flags:d}],a)}case as:{const f=[],d=i([o,f],a);for(const[p,h]of a)(e||!(qn(yn(p))||qn(yn(h))))&&f.push([s(p),s(h)]);return d}case os:{const f=[],d=i([o,f],a);for(const p of a)(e||!qn(yn(p)))&&f.push(s(p));return d}}const{message:u}=a;return i([o,{name:c,message:u}],a)};return s},wa=(e,{json:t,lossy:n}={})=>{const r=[];return Ag(!(t||n),!!t,new Map,r)(e),r},or=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?va(wa(e,t)):structuredClone(e):(e,t)=>va(wa(e,t));function Eg(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function Pg(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function Mg(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Eg,r=e.options.footnoteBackLabel||Pg,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},o=[];let c=-1;for(;++c<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[c]);if(!u)continue;const f=e.all(u),d=String(u.identifier).toUpperCase(),p=dn(d.toLowerCase());let h=0;const m=[],b=e.footnoteCounts.get(d);for(;b!==void 0&&++h<=b;){m.length>0&&m.push({type:"text",value:" "});let A=typeof n=="string"?n:n(c,h);typeof A=="string"&&(A={type:"text",value:A}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,h),className:["data-footnote-backref"]},children:Array.isArray(A)?A:[A]})}const w=f[f.length-1];if(w&&w.type==="element"&&w.tagName==="p"){const A=w.children[w.children.length-1];A&&A.type==="text"?A.value+=" ":w.children.push({type:"text",value:" "}),w.children.push(...m)}else f.push(...m);const k={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(f,!0)};e.patch(u,k),o.push(k)}if(o.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...or(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
10
- `},{type:"element",tagName:"ol",properties:{},children:e.wrap(o,!0)},{type:"text",value:`
11
- `}]}}const Ln=(function(e){if(e==null)return zg;if(typeof e=="function")return Cr(e);if(typeof e=="object")return Array.isArray(e)?Rg(e):Lg(e);if(typeof e=="string")return Dg(e);throw new Error("Expected function, string, or object as test")});function Rg(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Ln(e[n]);return Cr(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function Lg(e){const t=e;return Cr(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function Dg(e){return Cr(t);function t(n){return n&&n.type===e}}function Cr(e){return t;function t(n,r,i){return!!(Og(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function zg(){return!0}function Og(e){return e!==null&&typeof e=="object"&&"type"in e}const vl=[],Fg=!0,Ti=!1,$g="skip";function wl(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=Ln(i),a=r?-1:1;o(e,void 0,[])();function o(c,u,f){const d=c&&typeof c=="object"?c:{};if(typeof d.type=="string"){const h=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(c.type+(h?"<"+h+">":""))+")"})}return p;function p(){let h=vl,m,b,w;if((!t||s(c,u,f[f.length-1]||void 0))&&(h=Bg(n(c,f)),h[0]===Ti))return h;if("children"in c&&c.children){const k=c;if(k.children&&h[0]!==$g)for(b=(r?k.children.length:-1)+a,w=f.concat(k);b>-1&&b<k.children.length;){const A=k.children[b];if(m=o(A,b,w)(),m[0]===Ti)return m;b=typeof m[1]=="number"?m[1]:b+a}}return h}}}function Bg(e){return Array.isArray(e)?e:typeof e=="number"?[Fg,e]:e==null?vl:[e]}function Nr(e,t,n,r){let i,s,a;typeof t=="function"&&typeof n!="function"?(s=void 0,a=t,i=n):(s=t,a=n,i=r),wl(e,s,o,i);function o(c,u){const f=u[u.length-1],d=f?f.children.indexOf(c):void 0;return a(c,d,f)}}const Ai={}.hasOwnProperty,qg={};function Vg(e,t){const n=t||qg,r=new Map,i=new Map,s=new Map,a={...Cg,...n.handlers},o={all:u,applyData:Hg,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:a,one:c,options:n,patch:Ug,wrap:Zg};return Nr(e,function(f){if(f.type==="definition"||f.type==="footnoteDefinition"){const d=f.type==="definition"?r:i,p=String(f.identifier).toUpperCase();d.has(p)||d.set(p,f)}}),o;function c(f,d){const p=f.type,h=o.handlers[p];if(Ai.call(o.handlers,p)&&h)return h(o,f,d);if(o.options.passThrough&&o.options.passThrough.includes(p)){if("children"in f){const{children:b,...w}=f,k=or(w);return k.children=o.all(f),k}return or(f)}return(o.options.unknownHandler||Wg)(o,f,d)}function u(f){const d=[];if("children"in f){const p=f.children;let h=-1;for(;++h<p.length;){const m=o.one(p[h],f);if(m){if(h&&p[h-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=Sa(m.value)),!Array.isArray(m)&&m.type==="element")){const b=m.children[0];b&&b.type==="text"&&(b.value=Sa(b.value))}Array.isArray(m)?d.push(...m):d.push(m)}}}return d}}function Ug(e,t){e.position&&(t.position=Ph(e))}function Hg(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,s=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&s&&Object.assign(n.properties,or(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function Wg(e,t){const n=t.data||{},r="value"in t&&!(Ai.call(n,"hProperties")||Ai.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Zg(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
12
- `});++r<e.length;)r&&n.push({type:"text",value:`
13
- `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
14
- `}),n}function Sa(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function _a(e,t){const n=Vg(e,t),r=n.one(e,void 0),i=Mg(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&s.children.push({type:"text",value:`
15
- `},i),s}function Qg(e,t){return e&&"run"in e?async function(n,r){const i=_a(n,{file:r,...t});await e.run(i,r)}:function(n,r){return _a(n,{file:r,...e||t})}}function ja(e){if(e)throw e}var Wr,Ca;function Kg(){if(Ca)return Wr;Ca=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):t.call(u)==="[object Array]"},s=function(u){if(!u||t.call(u)!=="[object Object]")return!1;var f=e.call(u,"constructor"),d=u.constructor&&u.constructor.prototype&&e.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!f&&!d)return!1;var p;for(p in u);return typeof p>"u"||e.call(u,p)},a=function(u,f){n&&f.name==="__proto__"?n(u,f.name,{enumerable:!0,configurable:!0,value:f.newValue,writable:!0}):u[f.name]=f.newValue},o=function(u,f){if(f==="__proto__")if(e.call(u,f)){if(r)return r(u,f).value}else return;return u[f]};return Wr=function c(){var u,f,d,p,h,m,b=arguments[0],w=1,k=arguments.length,A=!1;for(typeof b=="boolean"&&(A=b,b=arguments[1]||{},w=2),(b==null||typeof b!="object"&&typeof b!="function")&&(b={});w<k;++w)if(u=arguments[w],u!=null)for(f in u)d=o(b,f),p=o(u,f),b!==p&&(A&&p&&(s(p)||(h=i(p)))?(h?(h=!1,m=d&&i(d)?d:[]):m=d&&s(d)?d:{},a(b,{name:f,newValue:c(A,m,p)})):typeof p<"u"&&a(b,{name:f,newValue:p}));return b},Wr}var Yg=Kg();const Zr=ro(Yg);function Ei(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Xg(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);o(null,...i);function o(c,...u){const f=e[++s];let d=-1;if(c){a(c);return}for(;++d<i.length;)(u[d]===null||u[d]===void 0)&&(u[d]=i[d]);i=u,f?Jg(f,o)(...u):a(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function Jg(e,t){let n;return r;function r(...a){const o=e.length>a.length;let c;o&&a.push(i);try{c=e.apply(this,a)}catch(u){const f=u;if(o&&n)throw f;return i(f)}o||(c&&c.then&&typeof c.then=="function"?c.then(s,i):c instanceof Error?i(c):s(c))}function i(a,...o){n||(n=!0,t(a,...o))}function s(a){i(null,a)}}const ut={basename:Gg,dirname:ex,extname:tx,join:nx,sep:"/"};function Gg(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Dn(e);let n=0,r=-1,i=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,o=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else a<0&&(s=!0,a=i+1),o>-1&&(e.codePointAt(i)===t.codePointAt(o--)?o<0&&(r=i):(o=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function ex(e){if(Dn(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function tx(e){Dn(e);let t=e.length,n=-1,r=0,i=-1,s=0,a;for(;t--;){const o=e.codePointAt(t);if(o===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),o===46?i<0?i=t:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||n<0||s===0||s===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function nx(...e){let t=-1,n;for(;++t<e.length;)Dn(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":rx(n)}function rx(e){Dn(e);const t=e.codePointAt(0)===47;let n=ix(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function ix(e,t){let n="",r=0,i=-1,s=0,a=-1,o,c;for(;++a<=e.length;){if(a<e.length)o=e.codePointAt(a);else{if(o===47)break;o=47}if(o===47){if(!(i===a-1||s===1))if(i!==a-1&&s===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/")),i=a,s=0;continue}}else if(n.length>0){n="",r=0,i=a,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,a):n=e.slice(i+1,a),r=a-i-1;i=a,s=0}else o===46&&s>-1?s++:s=-1}return n}function Dn(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const sx={cwd:ax};function ax(){return"/"}function Pi(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function ox(e){if(typeof e=="string")e=new URL(e);else if(!Pi(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return lx(e)}function lx(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const Qr=["history","path","basename","stem","extname","dirname"];class Sl{constructor(t){let n;t?Pi(t)?n={path:t}:typeof t=="string"||cx(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":sx.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Qr.length;){const s=Qr[r];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s])}let i;for(i in n)Qr.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?ut.basename(this.path):void 0}set basename(t){Yr(t,"basename"),Kr(t,"basename"),this.path=ut.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?ut.dirname(this.path):void 0}set dirname(t){Na(this.basename,"dirname"),this.path=ut.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?ut.extname(this.path):void 0}set extname(t){if(Kr(t,"extname"),Na(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=ut.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Pi(t)&&(t=ox(t)),Yr(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?ut.basename(this.path,this.extname):void 0}set stem(t){Yr(t,"stem"),Kr(t,"stem"),this.path=ut.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new ze(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Kr(e,t){if(e&&e.includes(ut.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+ut.sep+"`")}function Yr(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Na(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function cx(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const ux=(function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s}),dx={}.hasOwnProperty;class ls extends ux{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Xg()}copy(){const t=new ls;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Zr(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Gr("data",this.frozen),this.namespace[t]=n,this):dx.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Gr("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Vn(t),r=this.parser||this.Parser;return Xr("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Xr("process",this.parser||this.Parser),Jr("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,a){const o=Vn(t),c=r.parse(o);r.run(c,o,function(f,d,p){if(f||!d||!p)return u(f);const h=d,m=r.stringify(h,p);px(m)?p.value=m:p.result=m,u(f,p)});function u(f,d){f||!d?a(f):s?s(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),Xr("processSync",this.parser||this.Parser),Jr("processSync",this.compiler||this.Compiler),this.process(t,i),Ta("processSync","process",n),r;function i(s,a){n=!0,ja(s),r=a}}run(t,n,r){Ia(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?s(void 0,r):new Promise(s);function s(a,o){const c=Vn(n);i.run(t,c,u);function u(f,d,p){const h=d||t;f?o(f):a?a(h):r(void 0,h,p)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),Ta("runSync","run",r),i;function s(a,o){ja(a),i=o,r=!0}}stringify(t,n){this.freeze();const r=Vn(n),i=this.compiler||this.Compiler;return Jr("stringify",i),Ia(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(Gr("use",this.frozen),t!=null)if(typeof t=="function")c(t,n);else if(typeof t=="object")Array.isArray(t)?o(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(u){if(typeof u=="function")c(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[f,...d]=u;c(f,d)}else a(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function a(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(u.plugins),u.settings&&(i.settings=Zr(!0,i.settings,u.settings))}function o(u){let f=-1;if(u!=null)if(Array.isArray(u))for(;++f<u.length;){const d=u[f];s(d)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function c(u,f){let d=-1,p=-1;for(;++d<r.length;)if(r[d][0]===u){p=d;break}if(p===-1)r.push([u,...f]);else if(f.length>0){let[h,...m]=f;const b=r[p][1];Ei(b)&&Ei(h)&&(h=Zr(!0,b,h)),r[p]=[u,h,...m]}}}}const fx=new ls().freeze();function Xr(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Jr(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Gr(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Ia(e){if(!Ei(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Ta(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Vn(e){return hx(e)?e:new Sl(e)}function hx(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function px(e){return typeof e=="string"||mx(e)}function mx(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const gx="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Aa=[],Ea={allowDangerousHtml:!0},xx=/^(https?|ircs?|mailto|xmpp)$/i,yx=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function bx(e){const t=kx(e),n=vx(e);return wx(t.runSync(t.parse(n),n),e)}function kx(e){const t=e.rehypePlugins||Aa,n=e.remarkPlugins||Aa,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Ea}:Ea;return fx().use(eg).use(n).use(Qg,r).use(t)}function vx(e){const t=e.children||"",n=new Sl;return typeof t=="string"&&(n.value=t),n}function wx(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,a=t.skipHtml,o=t.unwrapDisallowed,c=t.urlTransform||Sx;for(const f of yx)Object.hasOwn(t,f.from)&&gc("Unexpected `"+f.from+"` prop, "+(f.to?"use `"+f.to+"` instead":"remove it")+" (see <"+gx+"#"+f.id+"> for more info)");return t.className&&(e={type:"element",tagName:"div",properties:{className:t.className},children:e.type==="root"?e.children:[e]}),Nr(e,u),zh(e,{Fragment:l.Fragment,components:i,ignoreInvalidStyle:!0,jsx:l.jsx,jsxs:l.jsxs,passKeys:!0,passNode:!0});function u(f,d,p){if(f.type==="raw"&&p&&typeof d=="number")return a?p.children.splice(d,1):p.children[d]={type:"text",value:f.value},d;if(f.type==="element"){let h;for(h in Vr)if(Object.hasOwn(Vr,h)&&Object.hasOwn(f.properties,h)){const m=f.properties[h],b=Vr[h];(b===null||b.includes(f.tagName))&&(f.properties[h]=c(String(m||""),h,f))}}if(f.type==="element"){let h=n?!n.includes(f.tagName):s?s.includes(f.tagName):!1;if(!h&&r&&typeof d=="number"&&(h=!r(f,d,p)),h&&p&&typeof d=="number")return o&&f.children?p.children.splice(d,1,...f.children):p.children.splice(d,1),d}}}function Sx(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||xx.test(e.slice(0,t))?e:""}function Pa(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function _x(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function jx(e,t,n){const i=Ln((n||{}).ignore||[]),s=Cx(t);let a=-1;for(;++a<s.length;)wl(e,"text",o);function o(u,f){let d=-1,p;for(;++d<f.length;){const h=f[d],m=p?p.children:void 0;if(i(h,m?m.indexOf(h):void 0,p))return;p=h}if(p)return c(u,f)}function c(u,f){const d=f[f.length-1],p=s[a][0],h=s[a][1];let m=0;const w=d.children.indexOf(u);let k=!1,A=[];p.lastIndex=0;let I=p.exec(u.value);for(;I;){const Z=I.index,Q={index:I.index,input:I.input,stack:[...f,u]};let j=h(...I,Q);if(typeof j=="string"&&(j=j.length>0?{type:"text",value:j}:void 0),j===!1?p.lastIndex=Z+1:(m!==Z&&A.push({type:"text",value:u.value.slice(m,Z)}),Array.isArray(j)?A.push(...j):j&&A.push(j),m=Z+I[0].length,k=!0),!p.global)break;I=p.exec(u.value)}return k?(m<u.value.length&&A.push({type:"text",value:u.value.slice(m)}),d.children.splice(w,1,...A)):A=[u],w+A.length}}function Cx(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const i=n[r];t.push([Nx(i[0]),Ix(i[1])])}return t}function Nx(e){return typeof e=="string"?new RegExp(_x(e),"g"):e}function Ix(e){return typeof e=="function"?e:function(){return e}}const ei="phrasing",ti=["autolink","link","image","label"];function Tx(){return{transforms:[Dx],enter:{literalAutolink:Ex,literalAutolinkEmail:ni,literalAutolinkHttp:ni,literalAutolinkWww:ni},exit:{literalAutolink:Lx,literalAutolinkEmail:Rx,literalAutolinkHttp:Px,literalAutolinkWww:Mx}}}function Ax(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ei,notInConstruct:ti},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ei,notInConstruct:ti},{character:":",before:"[ps]",after:"\\/",inConstruct:ei,notInConstruct:ti}]}}function Ex(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function ni(e){this.config.enter.autolinkProtocol.call(this,e)}function Px(e){this.config.exit.autolinkProtocol.call(this,e)}function Mx(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];at(t.type==="link"),t.url="http://"+this.sliceSerialize(e)}function Rx(e){this.config.exit.autolinkEmail.call(this,e)}function Lx(e){this.exit(e)}function Dx(e){jx(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,zx],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),Ox]],{ignore:["link","linkReference"]})}function zx(e,t,n,r,i){let s="";if(!_l(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!Fx(n)))return!1;const a=$x(n+r);if(!a[0])return!1;const o={type:"link",title:null,url:s+t+a[0],children:[{type:"text",value:t+a[0]}]};return a[1]?[o,{type:"text",value:a[1]}]:o}function Ox(e,t,n,r){return!_l(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Fx(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function $x(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const i=Pa(e,"(");let s=Pa(e,")");for(;r!==-1&&i>s;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),s++;return[e,n]}function _l(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Dt(n)||Sr(n))&&(!t||n!==47)}jl.peek=Kx;function Bx(){this.buffer()}function qx(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Vx(){this.buffer()}function Ux(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Hx(e){const t=this.resume(),n=this.stack[this.stack.length-1];at(n.type==="footnoteReference"),n.identifier=ot(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Wx(e){this.exit(e)}function Zx(e){const t=this.resume(),n=this.stack[this.stack.length-1];at(n.type==="footnoteDefinition"),n.identifier=ot(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Qx(e){this.exit(e)}function Kx(){return"["}function jl(e,t,n,r){const i=n.createTracker(r);let s=i.move("[^");const a=n.enter("footnoteReference"),o=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),o(),a(),s+=i.move("]"),s}function Yx(){return{enter:{gfmFootnoteCallString:Bx,gfmFootnoteCall:qx,gfmFootnoteDefinitionLabelString:Vx,gfmFootnoteDefinition:Ux},exit:{gfmFootnoteCallString:Hx,gfmFootnoteCall:Wx,gfmFootnoteDefinitionLabelString:Zx,gfmFootnoteDefinition:Qx}}}function Xx(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:jl},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,a){const o=s.createTracker(a);let c=o.move("[^");const u=s.enter("footnoteDefinition"),f=s.enter("label");return c+=o.move(s.safe(s.associationId(r),{before:c,after:"]"})),f(),c+=o.move("]:"),r.children&&r.children.length>0&&(o.shift(4),c+=o.move((t?`
16
- `:" ")+s.indentLines(s.containerFlow(r,o.current()),t?Cl:Jx))),u(),c}}function Jx(e,t,n){return t===0?e:Cl(e,t,n)}function Cl(e,t,n){return(n?"":" ")+e}const Gx=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Nl.peek=iy;function ey(){return{canContainEols:["delete"],enter:{strikethrough:ny},exit:{strikethrough:ry}}}function ty(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Gx}],handlers:{delete:Nl}}}function ny(e){this.enter({type:"delete",children:[]},e)}function ry(e){this.exit(e)}function Nl(e,t,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let a=i.move("~~");return a+=n.containerPhrasing(e,{...i.current(),before:a,after:"~"}),a+=i.move("~~"),s(),a}function iy(){return"~"}function sy(e){return e.length}function ay(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||sy,s=[],a=[],o=[],c=[];let u=0,f=-1;for(;++f<e.length;){const b=[],w=[];let k=-1;for(e[f].length>u&&(u=e[f].length);++k<e[f].length;){const A=oy(e[f][k]);if(n.alignDelimiters!==!1){const I=i(A);w[k]=I,(c[k]===void 0||I>c[k])&&(c[k]=I)}b.push(A)}a[f]=b,o[f]=w}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<u;)s[d]=Ma(r[d]);else{const b=Ma(r);for(;++d<u;)s[d]=b}d=-1;const p=[],h=[];for(;++d<u;){const b=s[d];let w="",k="";b===99?(w=":",k=":"):b===108?w=":":b===114&&(k=":");let A=n.alignDelimiters===!1?1:Math.max(1,c[d]-w.length-k.length);const I=w+"-".repeat(A)+k;n.alignDelimiters!==!1&&(A=w.length+A+k.length,A>c[d]&&(c[d]=A),h[d]=A),p[d]=I}a.splice(1,0,p),o.splice(1,0,h),f=-1;const m=[];for(;++f<a.length;){const b=a[f],w=o[f];d=-1;const k=[];for(;++d<u;){const A=b[d]||"";let I="",Z="";if(n.alignDelimiters!==!1){const Q=c[d]-(w[d]||0),j=s[d];j===114?I=" ".repeat(Q):j===99?Q%2?(I=" ".repeat(Q/2+.5),Z=" ".repeat(Q/2-.5)):(I=" ".repeat(Q/2),Z=I):Z=" ".repeat(Q)}n.delimiterStart!==!1&&!d&&k.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&A==="")&&(n.delimiterStart!==!1||d)&&k.push(" "),n.alignDelimiters!==!1&&k.push(I),k.push(A),n.alignDelimiters!==!1&&k.push(Z),n.padding!==!1&&k.push(" "),(n.delimiterEnd!==!1||d!==u-1)&&k.push("|")}m.push(n.delimiterEnd===!1?k.join("").replace(/ +$/,""):k.join(""))}return m.join(`
17
- `)}function oy(e){return e==null?"":String(e)}function Ma(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function ly(e,t,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const a=n.indentLines(n.containerFlow(e,s.current()),cy);return i(),a}function cy(e,t,n){return">"+(n?"":" ")+e}function uy(e,t){return Ra(e,t.inConstruct,!0)&&!Ra(e,t.notInConstruct,!1)}function Ra(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function La(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
18
- `&&uy(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
19
- `}function dy(e,t){const n=String(e);let r=n.indexOf(t),i=r,s=0,a=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>a&&(a=s):s=1,i=r+t.length,r=n.indexOf(t,i);return a}function fy(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function hy(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function py(e,t,n,r){const i=hy(n),s=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(fy(e,n)){const d=n.enter("codeIndented"),p=n.indentLines(s,my);return d(),p}const o=n.createTracker(r),c=i.repeat(Math.max(dy(s,i)+1,3)),u=n.enter("codeFenced");let f=o.move(c);if(e.lang){const d=n.enter(`codeFencedLang${a}`);f+=o.move(n.safe(e.lang,{before:f,after:" ",encode:["`"],...o.current()})),d()}if(e.lang&&e.meta){const d=n.enter(`codeFencedMeta${a}`);f+=o.move(" "),f+=o.move(n.safe(e.meta,{before:f,after:`
20
- `,encode:["`"],...o.current()})),d()}return f+=o.move(`
21
- `),s&&(f+=o.move(s+`
22
- `)),f+=o.move(c),u(),f}function my(e,t,n){return(n?"":" ")+e}function cs(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function gy(e,t,n,r){const i=cs(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("definition");let o=n.enter("label");const c=n.createTracker(r);let u=c.move("[");return u+=c.move(n.safe(n.associationId(e),{before:u,after:"]",...c.current()})),u+=c.move("]: "),o(),!e.url||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(n.safe(e.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(o=n.enter("destinationRaw"),u+=c.move(n.safe(e.url,{before:u,after:e.title?" ":`
23
- `,...c.current()}))),o(),e.title&&(o=n.enter(`title${s}`),u+=c.move(" "+i),u+=c.move(n.safe(e.title,{before:u,after:i,...c.current()})),u+=c.move(i),o()),a(),u}function xy(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function In(e){return"&#x"+e.toString(16).toUpperCase()+";"}function lr(e,t,n){const r=an(e),i=an(t);return r===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Il.peek=yy;function Il(e,t,n,r){const i=xy(n),s=n.enter("emphasis"),a=n.createTracker(r),o=a.move(i);let c=a.move(n.containerPhrasing(e,{after:i,before:o,...a.current()}));const u=c.charCodeAt(0),f=lr(r.before.charCodeAt(r.before.length-1),u,i);f.inside&&(c=In(u)+c.slice(1));const d=c.charCodeAt(c.length-1),p=lr(r.after.charCodeAt(0),d,i);p.inside&&(c=c.slice(0,-1)+In(d));const h=a.move(i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:f.outside},o+c+h}function yy(e,t,n){return n.options.emphasis||"*"}function by(e,t){let n=!1;return Nr(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Ti}),!!((!e.depth||e.depth<3)&&ts(e)&&(t.options.setext||n))}function ky(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(by(e,n)){const f=n.enter("headingSetext"),d=n.enter("phrasing"),p=n.containerPhrasing(e,{...s.current(),before:`
24
- `,after:`
25
- `});return d(),f(),p+`
26
- `+(i===1?"=":"-").repeat(p.length-(Math.max(p.lastIndexOf("\r"),p.lastIndexOf(`
27
- `))+1))}const a="#".repeat(i),o=n.enter("headingAtx"),c=n.enter("phrasing");s.move(a+" ");let u=n.containerPhrasing(e,{before:"# ",after:`
28
- `,...s.current()});return/^[\t ]/.test(u)&&(u=In(u.charCodeAt(0))+u.slice(1)),u=u?a+" "+u:a,n.options.closeAtx&&(u+=" "+a),c(),o(),u}Tl.peek=vy;function Tl(e){return e.value||""}function vy(){return"<"}Al.peek=wy;function Al(e,t,n,r){const i=cs(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("image");let o=n.enter("label");const c=n.createTracker(r);let u=c.move("![");return u+=c.move(n.safe(e.alt,{before:u,after:"]",...c.current()})),u+=c.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(n.safe(e.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(o=n.enter("destinationRaw"),u+=c.move(n.safe(e.url,{before:u,after:e.title?" ":")",...c.current()}))),o(),e.title&&(o=n.enter(`title${s}`),u+=c.move(" "+i),u+=c.move(n.safe(e.title,{before:u,after:i,...c.current()})),u+=c.move(i),o()),u+=c.move(")"),a(),u}function wy(){return"!"}El.peek=Sy;function El(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let a=n.enter("label");const o=n.createTracker(r);let c=o.move("![");const u=n.safe(e.alt,{before:c,after:"]",...o.current()});c+=o.move(u+"]["),a();const f=n.stack;n.stack=[],a=n.enter("reference");const d=n.safe(n.associationId(e),{before:c,after:"]",...o.current()});return a(),n.stack=f,s(),i==="full"||!u||u!==d?c+=o.move(d+"]"):i==="shortcut"?c=c.slice(0,-1):c+=o.move("]"),c}function Sy(){return"!"}Pl.peek=_y;function Pl(e,t,n){let r=e.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const a=n.unsafe[s],o=n.compilePattern(a);let c;if(a.atBreak)for(;c=o.exec(r);){let u=c.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(c.index+1)}}return i+r+i}function _y(){return"`"}function Ml(e,t){const n=ts(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Rl.peek=jy;function Rl(e,t,n,r){const i=cs(n),s=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let o,c;if(Ml(e,n)){const f=n.stack;n.stack=[],o=n.enter("autolink");let d=a.move("<");return d+=a.move(n.containerPhrasing(e,{before:d,after:">",...a.current()})),d+=a.move(">"),o(),n.stack=f,d}o=n.enter("link"),c=n.enter("label");let u=a.move("[");return u+=a.move(n.containerPhrasing(e,{before:u,after:"](",...a.current()})),u+=a.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),u+=a.move("<"),u+=a.move(n.safe(e.url,{before:u,after:">",...a.current()})),u+=a.move(">")):(c=n.enter("destinationRaw"),u+=a.move(n.safe(e.url,{before:u,after:e.title?" ":")",...a.current()}))),c(),e.title&&(c=n.enter(`title${s}`),u+=a.move(" "+i),u+=a.move(n.safe(e.title,{before:u,after:i,...a.current()})),u+=a.move(i),c()),u+=a.move(")"),o(),u}function jy(e,t,n){return Ml(e,n)?"<":"["}Ll.peek=Cy;function Ll(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let a=n.enter("label");const o=n.createTracker(r);let c=o.move("[");const u=n.containerPhrasing(e,{before:c,after:"]",...o.current()});c+=o.move(u+"]["),a();const f=n.stack;n.stack=[],a=n.enter("reference");const d=n.safe(n.associationId(e),{before:c,after:"]",...o.current()});return a(),n.stack=f,s(),i==="full"||!u||u!==d?c+=o.move(d+"]"):i==="shortcut"?c=c.slice(0,-1):c+=o.move("]"),c}function Cy(){return"["}function us(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Ny(e){const t=us(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Iy(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Dl(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Ty(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let a=e.ordered?Iy(n):us(n);const o=e.ordered?a==="."?")":".":Ny(n);let c=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const f=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&f&&(!f.children||!f.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),Dl(n)===a&&f){let d=-1;for(;++d<e.children.length;){const p=e.children[d];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){c=!0;break}}}}c&&(a=o),n.bulletCurrent=a;const u=n.containerFlow(e,r);return n.bulletLastUsed=a,n.bulletCurrent=s,i(),u}function Ay(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Ey(e,t,n,r){const i=Ay(n);let s=n.bulletCurrent||us(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let a=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const o=n.createTracker(r);o.move(s+" ".repeat(a-s.length)),o.shift(a);const c=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,o.current()),f);return c(),u;function f(d,p,h){return p?(h?"":" ".repeat(a))+d:(h?s:s+" ".repeat(a-s.length))+d}}function Py(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),a=n.containerPhrasing(e,r);return s(),i(),a}const My=Ln(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Ry(e,t,n,r){return(e.children.some(function(a){return My(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function Ly(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}zl.peek=Dy;function zl(e,t,n,r){const i=Ly(n),s=n.enter("strong"),a=n.createTracker(r),o=a.move(i+i);let c=a.move(n.containerPhrasing(e,{after:i,before:o,...a.current()}));const u=c.charCodeAt(0),f=lr(r.before.charCodeAt(r.before.length-1),u,i);f.inside&&(c=In(u)+c.slice(1));const d=c.charCodeAt(c.length-1),p=lr(r.after.charCodeAt(0),d,i);p.inside&&(c=c.slice(0,-1)+In(d));const h=a.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:f.outside},o+c+h}function Dy(e,t,n){return n.options.strong||"*"}function zy(e,t,n,r){return n.safe(e.value,r)}function Oy(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Fy(e,t,n){const r=(Dl(n)+(n.options.ruleSpaces?" ":"")).repeat(Oy(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Ol={blockquote:ly,break:La,code:py,definition:gy,emphasis:Il,hardBreak:La,heading:ky,html:Tl,image:Al,imageReference:El,inlineCode:Pl,link:Rl,linkReference:Ll,list:Ty,listItem:Ey,paragraph:Py,root:Ry,strong:zl,text:zy,thematicBreak:Fy};function $y(){return{enter:{table:By,tableData:Da,tableHeader:Da,tableRow:Vy},exit:{codeText:Uy,table:qy,tableData:ri,tableHeader:ri,tableRow:ri}}}function By(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function qy(e){this.exit(e),this.data.inTable=void 0}function Vy(e){this.enter({type:"tableRow",children:[]},e)}function ri(e){this.exit(e)}function Da(e){this.enter({type:"tableCell",children:[]},e)}function Uy(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Hy));const n=this.stack[this.stack.length-1];at(n.type==="inlineCode"),n.value=t,this.exit(e)}function Hy(e,t){return t==="|"?t:e}function Wy(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
29
- `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:a,tableCell:c,tableRow:o}};function a(h,m,b,w){return u(f(h,b,w),h.align)}function o(h,m,b,w){const k=d(h,b,w),A=u([k]);return A.slice(0,A.indexOf(`
30
- `))}function c(h,m,b,w){const k=b.enter("tableCell"),A=b.enter("phrasing"),I=b.containerPhrasing(h,{...w,before:s,after:s});return A(),k(),I}function u(h,m){return ay(h,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function f(h,m,b){const w=h.children;let k=-1;const A=[],I=m.enter("table");for(;++k<w.length;)A[k]=d(w[k],m,b);return I(),A}function d(h,m,b){const w=h.children;let k=-1;const A=[],I=m.enter("tableRow");for(;++k<w.length;)A[k]=c(w[k],h,m,b);return I(),A}function p(h,m,b){let w=Ol.inlineCode(h,m,b);return b.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function Zy(){return{exit:{taskListCheckValueChecked:za,taskListCheckValueUnchecked:za,paragraph:Ky}}}function Qy(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Yy}}}function za(e){const t=this.stack[this.stack.length-2];at(t.type==="listItem"),t.checked=e.type==="taskListCheckValueChecked"}function Ky(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];at(n.type==="paragraph");const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,a;for(;++s<i.length;){const o=i[s];if(o.type==="paragraph"){a=o;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function Yy(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",o=n.createTracker(r);s&&o.move(a);let c=Ol.listItem(e,t,n,{...r,...o.current()});return s&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),c;function u(f){return f+a}}function Xy(){return[Tx(),Yx(),ey(),$y(),Zy()]}function Jy(e){return{extensions:[Ax(),Xx(e),ty(),Wy(e),Qy()]}}const Gy={tokenize:sb,partial:!0},Fl={tokenize:ab,partial:!0},$l={tokenize:ob,partial:!0},Bl={tokenize:lb,partial:!0},eb={tokenize:cb,partial:!0},ql={name:"wwwAutolink",tokenize:rb,previous:Ul},Vl={name:"protocolAutolink",tokenize:ib,previous:Hl},bt={name:"emailAutolink",tokenize:nb,previous:Wl},mt={};function tb(){return{text:mt}}let Et=48;for(;Et<123;)mt[Et]=bt,Et++,Et===58?Et=65:Et===91&&(Et=97);mt[43]=bt;mt[45]=bt;mt[46]=bt;mt[95]=bt;mt[72]=[bt,Vl];mt[104]=[bt,Vl];mt[87]=[bt,ql];mt[119]=[bt,ql];function nb(e,t,n){const r=this;let i,s;return a;function a(d){return!Mi(d)||!Wl.call(r,r.previous)||ds(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),o(d))}function o(d){return Mi(d)?(e.consume(d),o):d===64?(e.consume(d),c):n(d)}function c(d){return d===46?e.check(eb,f,u)(d):d===45||d===95||De(d)?(s=!0,e.consume(d),c):f(d)}function u(d){return e.consume(d),i=!0,c}function f(d){return s&&i&&Ve(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function rb(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!Ul.call(r,r.previous)||ds(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(Gy,e.attempt(Fl,e.attempt($l,s),n),n)(a))}function s(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function ib(e,t,n){const r=this;let i="",s=!1;return a;function a(d){return(d===72||d===104)&&Hl.call(r,r.previous)&&!ds(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),e.consume(d),o):n(d)}function o(d){if(Ve(d)&&i.length<5)return i+=String.fromCodePoint(d),e.consume(d),o;if(d===58){const p=i.toLowerCase();if(p==="http"||p==="https")return e.consume(d),c}return n(d)}function c(d){return d===47?(e.consume(d),s?u:(s=!0,c)):n(d)}function u(d){return d===null||sr(d)||Te(d)||Dt(d)||Sr(d)?n(d):e.attempt(Fl,e.attempt($l,f),n)(d)}function f(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function sb(e,t,n){let r=0;return i;function i(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),i):a===46&&r===3?(e.consume(a),s):n(a)}function s(a){return a===null?n(a):t(a)}}function ab(e,t,n){let r,i,s;return a;function a(u){return u===46||u===95?e.check(Bl,c,o)(u):u===null||Te(u)||Dt(u)||u!==45&&Sr(u)?c(u):(s=!0,e.consume(u),a)}function o(u){return u===95?r=!0:(i=r,r=void 0),e.consume(u),a}function c(u){return i||r||!s?n(u):t(u)}}function ob(e,t){let n=0,r=0;return i;function i(a){return a===40?(n++,e.consume(a),i):a===41&&r<n?s(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(Bl,t,s)(a):a===null||Te(a)||Dt(a)?t(a):(e.consume(a),i)}function s(a){return a===41&&r++,e.consume(a),i}}function lb(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),s):o===93?(e.consume(o),i):o===60||o===null||Te(o)||Dt(o)?t(o):n(o)}function i(o){return o===null||o===40||o===91||Te(o)||Dt(o)?t(o):r(o)}function s(o){return Ve(o)?a(o):n(o)}function a(o){return o===59?(e.consume(o),r):Ve(o)?(e.consume(o),a):n(o)}}function cb(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return De(s)?n(s):t(s)}}function Ul(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Te(e)}function Hl(e){return!Ve(e)}function Wl(e){return!(e===47||Mi(e))}function Mi(e){return e===43||e===45||e===46||e===95||De(e)}function ds(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const ub={tokenize:yb,partial:!0};function db(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:mb,continuation:{tokenize:gb},exit:xb}},text:{91:{name:"gfmFootnoteCall",tokenize:pb},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:fb,resolveTo:hb}}}}function fb(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;i--;){const c=r.events[i][1];if(c.type==="labelImage"){a=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return o;function o(c){if(!a||!a._balanced)return n(c);const u=ot(r.sliceSerialize({start:a.end,end:r.now()}));return u.codePointAt(0)!==94||!s.includes(u.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function hb(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},o=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",a,t],["exit",a,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...o),e}function pb(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,a;return o;function o(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),c}function c(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(d){if(s>999||d===93&&!a||d===null||d===91||Te(d))return n(d);if(d===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(ot(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return Te(d)||(a=!0),s++,e.consume(d),d===92?f:u}function f(d){return d===91||d===92||d===93?(e.consume(d),s++,u):u(d)}}function mb(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,a=0,o;return c;function c(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",f):n(m)}function f(m){if(a>999||m===93&&!o||m===null||m===91||Te(m))return n(m);if(m===93){e.exit("chunkString");const b=e.exit("gfmFootnoteDefinitionLabelString");return s=ot(r.sliceSerialize(b)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return Te(m)||(o=!0),a++,e.consume(m),m===92?d:f}function d(m){return m===91||m===92||m===93?(e.consume(m),a++,f):f(m)}function p(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),be(e,h,"gfmFootnoteDefinitionWhitespace")):n(m)}function h(m){return t(m)}}function gb(e,t,n){return e.check(Rn,t,e.attempt(ub,t,n))}function xb(e){e.exit("gfmFootnoteDefinition")}function yb(e,t,n){const r=this;return be(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(s):n(s)}}function bb(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(a,o){let c=-1;for(;++c<a.length;)if(a[c][0]==="enter"&&a[c][1].type==="strikethroughSequenceTemporary"&&a[c][1]._close){let u=c;for(;u--;)if(a[u][0]==="exit"&&a[u][1].type==="strikethroughSequenceTemporary"&&a[u][1]._open&&a[c][1].end.offset-a[c][1].start.offset===a[u][1].end.offset-a[u][1].start.offset){a[c][1].type="strikethroughSequence",a[u][1].type="strikethroughSequence";const f={type:"strikethrough",start:Object.assign({},a[u][1].start),end:Object.assign({},a[c][1].end)},d={type:"strikethroughText",start:Object.assign({},a[u][1].end),end:Object.assign({},a[c][1].start)},p=[["enter",f,o],["enter",a[u][1],o],["exit",a[u][1],o],["enter",d,o]],h=o.parser.constructs.insideSpan.null;h&&Je(p,p.length,0,_r(h,a.slice(u+1,c),o)),Je(p,p.length,0,[["exit",d,o],["enter",a[c][1],o],["exit",a[c][1],o],["exit",f,o]]),Je(a,u-1,c-u+3,p),c=u+p.length-2;break}}for(c=-1;++c<a.length;)a[c][1].type==="strikethroughSequenceTemporary"&&(a[c][1].type="data");return a}function s(a,o,c){const u=this.previous,f=this.events;let d=0;return p;function p(m){return u===126&&f[f.length-1][1].type!=="characterEscape"?c(m):(a.enter("strikethroughSequenceTemporary"),h(m))}function h(m){const b=an(u);if(m===126)return d>1?c(m):(a.consume(m),d++,h);if(d<2&&!n)return c(m);const w=a.exit("strikethroughSequenceTemporary"),k=an(m);return w._open=!k||k===2&&!!b,w._close=!b||b===2&&!!k,o(m)}}}class kb{constructor(){this.map=[]}add(t,n,r){vb(this,t,n,r)}consume(t){if(this.map.sort(function(s,a){return s[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function vb(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function wb(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function Sb(){return{flow:{null:{name:"table",tokenize:_b,resolveAll:jb}}}}function _b(e,t,n){const r=this;let i=0,s=0,a;return o;function o(_){let F=r.events.length-1;for(;F>-1;){const q=r.events[F][1].type;if(q==="lineEnding"||q==="linePrefix")F--;else break}const $=F>-1?r.events[F][1].type:null,ae=$==="tableHead"||$==="tableRow"?j:c;return ae===j&&r.parser.lazy[r.now().line]?n(_):ae(_)}function c(_){return e.enter("tableHead"),e.enter("tableRow"),u(_)}function u(_){return _===124||(a=!0,s+=1),f(_)}function f(_){return _===null?n(_):K(_)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),h):n(_):ge(_)?be(e,f,"whitespace")(_):(s+=1,a&&(a=!1,i+=1),_===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),a=!0,f):(e.enter("data"),d(_)))}function d(_){return _===null||_===124||Te(_)?(e.exit("data"),f(_)):(e.consume(_),_===92?p:d)}function p(_){return _===92||_===124?(e.consume(_),d):d(_)}function h(_){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(_):(e.enter("tableDelimiterRow"),a=!1,ge(_)?be(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):m(_))}function m(_){return _===45||_===58?w(_):_===124?(a=!0,e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),b):Q(_)}function b(_){return ge(_)?be(e,w,"whitespace")(_):w(_)}function w(_){return _===58?(s+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),k):_===45?(s+=1,k(_)):_===null||K(_)?Z(_):Q(_)}function k(_){return _===45?(e.enter("tableDelimiterFiller"),A(_)):Q(_)}function A(_){return _===45?(e.consume(_),A):_===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),I):(e.exit("tableDelimiterFiller"),I(_))}function I(_){return ge(_)?be(e,Z,"whitespace")(_):Z(_)}function Z(_){return _===124?m(_):_===null||K(_)?!a||i!==s?Q(_):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(_)):Q(_)}function Q(_){return n(_)}function j(_){return e.enter("tableRow"),Y(_)}function Y(_){return _===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),Y):_===null||K(_)?(e.exit("tableRow"),t(_)):ge(_)?be(e,Y,"whitespace")(_):(e.enter("data"),X(_))}function X(_){return _===null||_===124||Te(_)?(e.exit("data"),Y(_)):(e.consume(_),_===92?G:X)}function G(_){return _===92||_===124?(e.consume(_),X):X(_)}}function jb(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],a=[0,0,0,0],o=!1,c=0,u,f,d;const p=new kb;for(;++n<e.length;){const h=e[n],m=h[1];h[0]==="enter"?m.type==="tableHead"?(o=!1,c!==0&&(Oa(p,t,c,u,f),f=void 0,c=0),u={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",u,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,d=void 0,s=[0,0,0,0],a=[0,n+1,0,0],o&&(o=!1,f={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",f,t]])),i=m.type==="tableDelimiterRow"?2:f?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(s[1]!==0&&(a[0]=a[1],d=Un(p,t,s,i,void 0,d),s=[0,0,0,0]),a[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(a[0]=a[1],d=Un(p,t,s,i,void 0,d)),s=a,a=[s[1],n,0,0])):m.type==="tableHead"?(o=!0,c=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(c=n,s[1]!==0?(a[0]=a[1],d=Un(p,t,s,i,n,d)):a[1]!==0&&(d=Un(p,t,a,i,n,d)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(a[3]=n)}for(c!==0&&Oa(p,t,c,u,f),p.consume(t.events),n=-1;++n<t.events.length;){const h=t.events[n];h[0]==="enter"&&h[1].type==="table"&&(h[1]._align=wb(t.events,n))}return e}function Un(e,t,n,r,i,s){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",o="tableContent";n[0]!==0&&(s.end=Object.assign({},Kt(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const c=Kt(t.events,n[1]);if(s={type:a,start:Object.assign({},c),end:Object.assign({},c)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const u=Kt(t.events,n[2]),f=Kt(t.events,n[3]),d={type:o,start:Object.assign({},u),end:Object.assign({},f)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const p=t.events[n[2]],h=t.events[n[3]];if(p[1].end=Object.assign({},h[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,b=n[3]-n[2]-1;e.add(m,b,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return i!==void 0&&(s.end=Object.assign({},Kt(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function Oa(e,t,n,r,i){const s=[],a=Kt(t.events,n);i&&(i.end=Object.assign({},a),s.push(["exit",i,t])),r.end=Object.assign({},a),s.push(["exit",r,t]),e.add(n+1,0,s)}function Kt(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const Cb={name:"tasklistCheck",tokenize:Ib};function Nb(){return{text:{91:Cb}}}function Ib(e,t,n){const r=this;return i;function i(c){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),s)}function s(c){return Te(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),a):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),a):n(c)}function a(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),o):n(c)}function o(c){return K(c)?t(c):ge(c)?e.check({tokenize:Tb},t,n)(c):n(c)}}function Tb(e,t,n){return be(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function Ab(e){return rl([tb(),db(),bb(e),Sb(),Nb()])}const Eb={};function Pb(e){const t=this,n=e||Eb,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Ab(n)),s.push(Xy()),a.push(Jy(n))}const Fa=(function(e,t,n){const r=Ln(n);if(!e||!e.type||!e.children)throw new Error("Expected parent node");if(typeof t=="number"){if(t<0||t===Number.POSITIVE_INFINITY)throw new Error("Expected positive finite number as index")}else if(t=e.children.indexOf(t),t<0)throw new Error("Expected child node or index");for(;++t<e.children.length;)if(r(e.children[t],t,e))return e.children[t]}),Ot=(function(e){if(e==null)return Lb;if(typeof e=="string")return Rb(e);if(typeof e=="object")return Mb(e);if(typeof e=="function")return fs(e);throw new Error("Expected function, string, or array as `test`")});function Mb(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Ot(e[n]);return fs(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function Rb(e){return fs(t);function t(n){return n.tagName===e}}function fs(e){return t;function t(n,r,i){return!!(Db(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function Lb(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function Db(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}const $a=/\n/g,Ba=/[\t ]+/g,Ri=Ot("br"),qa=Ot(Ub),zb=Ot("p"),Va=Ot("tr"),Ob=Ot(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",Vb,Hb]),Zl=Ot(["address","article","aside","blockquote","body","caption","center","dd","dialog","dir","dl","dt","div","figure","figcaption","footer","form,","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","legend","li","listing","main","menu","nav","ol","p","plaintext","pre","section","ul","xmp"]);function Fb(e,t){const n=t||{},r="children"in e?e.children:[],i=Zl(e),s=Yl(e,{whitespace:n.whitespace||"normal"}),a=[];(e.type==="text"||e.type==="comment")&&a.push(...Kl(e,{breakBefore:!0,breakAfter:!0}));let o=-1;for(;++o<r.length;)a.push(...Ql(r[o],e,{whitespace:s,breakBefore:o?void 0:i,breakAfter:o<r.length-1?Ri(r[o+1]):i}));const c=[];let u;for(o=-1;++o<a.length;){const f=a[o];typeof f=="number"?u!==void 0&&f>u&&(u=f):f&&(u!==void 0&&u>-1&&c.push(`
31
- `.repeat(u)||" "),u=-1,c.push(f))}return c.join("")}function Ql(e,t,n){return e.type==="element"?$b(e,t,n):e.type==="text"?n.whitespace==="normal"?Kl(e,n):Bb(e):[]}function $b(e,t,n){const r=Yl(e,n),i=e.children||[];let s=-1,a=[];if(Ob(e))return a;let o,c;for(Ri(e)||Va(e)&&Fa(t,e,Va)?c=`
32
- `:zb(e)?(o=2,c=2):Zl(e)&&(o=1,c=1);++s<i.length;)a=a.concat(Ql(i[s],e,{whitespace:r,breakBefore:s?void 0:o,breakAfter:s<i.length-1?Ri(i[s+1]):c}));return qa(e)&&Fa(t,e,qa)&&a.push(" "),o&&a.unshift(o),c&&a.push(c),a}function Kl(e,t){const n=String(e.value),r=[],i=[];let s=0;for(;s<=n.length;){$a.lastIndex=s;const c=$a.exec(n),u=c&&"index"in c?c.index:n.length;r.push(qb(n.slice(s,u).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,""),s===0?t.breakBefore:!0,u===n.length?t.breakAfter:!0)),s=u+1}let a=-1,o;for(;++a<r.length;)r[a].charCodeAt(r[a].length-1)===8203||a<r.length-1&&r[a+1].charCodeAt(0)===8203?(i.push(r[a]),o=void 0):r[a]?(typeof o=="number"&&i.push(o),i.push(r[a]),o=0):(a===0||a===r.length-1)&&i.push(0);return i}function Bb(e){return[String(e.value)]}function qb(e,t,n){const r=[];let i=0,s;for(;i<e.length;){Ba.lastIndex=i;const a=Ba.exec(e);s=a?a.index:e.length,!i&&!s&&a&&!t&&r.push(""),i!==s&&r.push(e.slice(i,s)),i=a?s+a[0].length:s}return i!==s&&!n&&r.push(""),r.join(" ")}function Yl(e,t){if(e.type==="element"){const n=e.properties||{};switch(e.tagName){case"listing":case"plaintext":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return n.wrap?"pre-wrap":"pre";case"td":case"th":return n.noWrap?"nowrap":t.whitespace;case"textarea":return"pre-wrap"}}return t.whitespace}function Vb(e){return!!(e.properties||{}).hidden}function Ub(e){return e.tagName==="td"||e.tagName==="th"}function Hb(e){return e.tagName==="dialog"&&!(e.properties||{}).open}const Wb={};function Ua(e){const t=e||Wb,n=t.aliases,r=t.detect||!1,i=t.languages||xc,s=t.plainText,a=t.prefix,o=t.subset;let c="hljs";const u=yc(i);if(n&&u.registerAlias(n),a){const f=a.indexOf("-");c=f===-1?a:a.slice(0,f)}return function(f,d){Nr(f,"element",function(p,h,m){if(p.tagName!=="code"||!m||m.type!=="element"||m.tagName!=="pre")return;const b=Zb(p);if(b===!1||!b&&!r||b&&s&&s.includes(b))return;Array.isArray(p.properties.className)||(p.properties.className=[]),p.properties.className.includes(c)||p.properties.className.unshift(c);const w=Fb(p,{whitespace:"pre"});let k;try{k=b?u.highlight(b,w,{prefix:a}):u.highlightAuto(w,{prefix:a,subset:o})}catch(A){const I=A;if(b&&/Unknown language/.test(I.message)){d.message("Cannot highlight as `"+b+"`, it’s not registered",{ancestors:[m,p],cause:I,place:p.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw I}!b&&k.data&&k.data.language&&p.properties.className.push("language-"+k.data.language),k.children.length>0&&(p.children=k.children)})}}function Zb(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let r;for(;++n<t.length;){const i=String(t[n]);if(i==="no-highlight"||i==="nohighlight")return!1;!r&&i.slice(0,5)==="lang-"&&(r=i.slice(5)),!r&&i.slice(0,9)==="language-"&&(r=i.slice(9))}return r}function Xl(e){const t=e.split(`
33
- `),n=[];for(const r of t)r.startsWith("@@")?n.push({kind:"hunk",text:r}):r.startsWith("diff ")||r.startsWith("index ")||r.startsWith("--- ")||r.startsWith("+++ ")?n.push({kind:"meta",text:r}):r.startsWith("+")?n.push({kind:"add",text:r.slice(1)}):r.startsWith("-")?n.push({kind:"remove",text:r.slice(1)}):n.push({kind:"context",text:r.startsWith(" ")?r.slice(1):r});return n}function Jl(e){let t=0,n=0;for(const r of e)r.kind==="add"?t++:r.kind==="remove"&&n++;return{added:t,removed:n}}function Li(e){var t;return e==null||e===!1||e===!0?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Li).join(""):typeof e=="object"&&"props"in e?Li((t=e.props)==null?void 0:t.children):""}function Ir({text:e,className:t,label:n="复制"}){const[r,i]=v.useState(!1),s=async a=>{a.stopPropagation();try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)}catch{}};return l.jsx("button",{onClick:s,title:r?"已复制":n,"aria-label":n,className:t??"flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-border bg-surface text-content-muted transition-colors hover:text-content-primary",children:r?l.jsx(Rt,{size:13,className:"text-success"}):l.jsx(Xc,{size:13})})}function Qb(e){const t=e.toLowerCase(),n=r=>{if(!r||!Array.isArray(r.children)||r.type==="element"&&(r.tagName==="code"||r.tagName==="pre"))return;const i=[];for(const s of r.children)if(s.type==="text"&&typeof s.value=="string"){const a=s.value,o=a.toLowerCase();let c=o.indexOf(t);if(c===-1){i.push(s);continue}let u=0;for(;c!==-1;)c>u&&i.push({type:"text",value:a.slice(u,c)}),i.push({type:"element",tagName:"mark",properties:{},children:[{type:"text",value:a.slice(c,c+t.length)}]}),u=c+t.length,c=o.indexOf(t,u);u<a.length&&i.push({type:"text",value:a.slice(u)})}else n(s),i.push(s);r.children=i};return()=>r=>{t&&n(r)}}const Gl=v.memo(function({text:t,highlight:n}){return l.jsx("div",{className:"prose-codex break-words text-[15px] leading-7 text-content-primary",children:l.jsx(bx,{remarkPlugins:[Pb],rehypePlugins:n?[[Ua,{detect:!0,ignoreMissing:!0}],Qb(n)]:[[Ua,{detect:!0,ignoreMissing:!0}]],components:{mark({children:r}){return l.jsx("mark",{className:"rounded bg-warning/30 px-0.5 text-content-primary",children:r})},pre({children:r}){return l.jsx(l.Fragment,{children:r})},code({className:r,children:i,...s}){if(/language-|hljs/.test(r??"")){const o=Li(i);return l.jsxs("div",{className:"group/code relative my-3",children:[l.jsx("pre",{className:"max-w-full overflow-x-auto rounded-lg border border-border bg-surface-raised p-3 font-mono text-[13px] leading-relaxed",children:l.jsx("code",{className:r,...s,children:i})}),l.jsx(Ir,{text:o,className:"absolute right-2 top-2 flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-border bg-surface text-content-muted opacity-0 transition-opacity hover:text-content-primary group-hover/code:opacity-100"})]})}return l.jsx("code",{className:"break-all rounded bg-surface-overlay px-1.5 py-0.5 font-mono text-[13px] text-accent",...s,children:i})},a({children:r,...i}){return l.jsx("a",{className:"text-accent underline underline-offset-2",target:"_blank",rel:"noreferrer",...i,children:r})},p({children:r}){return l.jsx("p",{className:"my-2",children:r})},ul({children:r}){return l.jsx("ul",{className:"my-2 list-disc space-y-1 pl-5",children:r})},ol({children:r}){return l.jsx("ol",{className:"my-2 list-decimal space-y-1 pl-5",children:r})}},children:t})})});function ec({item:e,onOpen:t}){const n=e.fileChange,r=n.diff?Xl(n.diff):[],i=Jl(r),s=n.entries.length>0?n.entries.map(u=>u.path):[],a=s[0]||n.summary||"文件变更",o=s.length>1?` +${s.length-1}`:"",c=!!(n.diff&&t);return l.jsxs("button",{onClick:()=>c&&(t==null?void 0:t(e)),className:`flex w-full items-center gap-2 rounded-xl border border-border bg-surface px-3.5 py-2.5 text-left transition-colors ${c?"cursor-pointer hover:border-border-strong hover:bg-surface-overlay":"cursor-default"}`,children:[l.jsx(Sn,{size:14,className:"shrink-0 text-content-faint"}),l.jsxs("span",{className:"truncate font-mono text-[13px] text-content-primary",title:s.join(", ")||a,children:[a,o&&l.jsx("span",{className:"text-content-muted",children:o})]}),l.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2 font-mono text-[13px]",children:[i.added>0&&l.jsxs("span",{className:"text-diff-addText",children:["+",i.added]}),i.removed>0&&l.jsxs("span",{className:"text-diff-removeText",children:["−",i.removed]}),c&&l.jsx(nt,{size:13,className:"text-content-faint"})]})]})}function Kb(e){const t=/@@\s*-(\d+)(?:,\d+)?\s*\+(\d+)(?:,\d+)?\s*@@/.exec(e);return t?[Number(t[1]),Number(t[2])]:null}function Yb({item:e}){const t=e.fileChange,n=t!=null&&t.diff?Xl(t.diff):[],r=Jl(n),i=(t==null?void 0:t.entries.map(o=>o.path).join(", "))||(t==null?void 0:t.summary)||"文件变更";let s=0,a=0;return l.jsxs("div",{className:"flex h-full flex-col bg-surface",children:[l.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3.5 py-2.5",children:[l.jsx(Sn,{size:13,className:"shrink-0 text-content-faint"}),l.jsx("span",{className:"truncate font-mono text-[13px] text-content-secondary",title:i,children:i}),l.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2 font-mono text-[13px]",children:[r.added>0&&l.jsxs("span",{className:"text-diff-addText",children:["+",r.added]}),r.removed>0&&l.jsxs("span",{className:"text-diff-removeText",children:["−",r.removed]})]}),(t==null?void 0:t.diff)&&l.jsx(Ir,{text:t.diff,label:"复制差异"})]}),l.jsx("div",{className:"min-h-0 flex-1 overflow-auto font-mono text-[13px] leading-[1.6]",children:n.length===0?l.jsx("p",{className:"px-3 py-2 text-content-muted",children:(t==null?void 0:t.summary)||"无差异内容"}):n.map((o,c)=>{if(o.kind==="hunk"){const h=Kb(o.text);return h&&(s=h[0],a=h[1]),l.jsxs("div",{className:"flex bg-surface-raised/60 text-accent-dim",children:[l.jsx("span",{className:"w-14 shrink-0 border-r border-border"}),l.jsx("span",{className:"px-3 py-0.5",children:o.text})]},c)}if(o.kind==="meta")return null;const u=o.kind==="add",f=o.kind==="remove",d=u?"":String(s),p=f?"":String(a);return u||(s+=1),f||(a+=1),l.jsxs("div",{className:`flex ${u?"bg-diff-add":f?"bg-diff-remove":""}`,children:[l.jsxs("span",{className:"flex w-14 shrink-0 select-none justify-end gap-1.5 border-r border-border px-1.5 py-0.5 text-[10px] text-content-faint",children:[l.jsx("span",{className:"w-5 text-right",children:d}),l.jsx("span",{className:"w-5 text-right",children:p})]}),l.jsxs("span",{className:`flex-1 whitespace-pre px-3 py-0.5 ${u?"text-diff-addText":f?"text-diff-removeText":"text-content-secondary"}`,children:[l.jsx("span",{className:"mr-2 select-none opacity-60",children:u?"+":f?"−":" "}),o.text||" "]})]},c)})})]})}function Gt({oldText:e,newText:t}){const n=e?e.split(`
34
- `):[],r=t?t.split(`
35
- `):[];if(n.length===0&&r.length===0)return null;const i=(s,a,o)=>l.jsx("div",{className:`flex ${a?"bg-diff-add":"bg-diff-remove"}`,children:l.jsxs("span",{className:`flex-1 whitespace-pre px-3 py-0.5 ${a?"text-diff-addText":"text-diff-removeText"}`,children:[l.jsx("span",{className:"mr-2 select-none opacity-60",children:a?"+":"−"}),s||" "]})},o);return l.jsxs("div",{className:"max-h-72 overflow-auto rounded-lg border border-border bg-surface-raised font-mono text-[13px] leading-[1.6]",children:[n.map((s,a)=>i(s,!1,`r${a}`)),r.map((s,a)=>i(s,!0,`a${a}`))]})}function ii(e){if(!e)return;const t=e.split("/").filter(Boolean);return t.length>2?t.slice(-2).join("/"):e}function cr(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.old_string=="string"||typeof t.new_string=="string"}function Xb(e){if(!Array.isArray(e))return null;const t=[];for(const n of e){if(!n||typeof n!="object")return null;const r=n;if(typeof r.content!="string"||typeof r.status!="string")return null;t.push({content:r.content,status:r.status,activeForm:typeof r.activeForm=="string"?r.activeForm:void 0})}return t}function Jb({todos:e}){return l.jsx("ul",{className:"space-y-1.5",children:e.map((t,n)=>l.jsxs("li",{className:"flex items-start gap-2 text-sm leading-6",children:[l.jsx("span",{className:"mt-1 shrink-0",children:t.status==="completed"?l.jsx(Rt,{size:12,className:"text-success"}):t.status==="in_progress"?l.jsx("span",{className:"block h-2.5 w-2.5 animate-pulse-dot rounded-full bg-accent"}):l.jsx("span",{className:"block h-2.5 w-2.5 rounded-full border border-content-faint"})}),l.jsx("span",{className:`min-w-0 flex-1 ${t.status==="completed"?"text-content-muted line-through":t.status==="in_progress"?"font-semibold text-content-primary":"text-content-secondary"}`,children:t.status==="in_progress"&&t.activeForm?t.activeForm:t.content})]},n))})}function Gb(e,t=120){const n=e.replace(/\s+/g," ").trim();return n.length>t?n.slice(0,t-1)+"…":n}function ek(e,t){let n={};if(t)try{const s=JSON.parse(t);s&&typeof s=="object"&&(n=s)}catch{}const r=s=>typeof n[s]=="string"?n[s]:void 0;switch(e.split(/ · |__/).pop()??e){case"WebSearch":return{Icon:Mt,label:"网络搜索",summary:r("query")};case"WebFetch":return{Icon:Zn,label:"获取网页",summary:r("url")};case"Grep":{const s=r("pattern"),a=r("path");return{Icon:Mt,label:"搜索代码",summary:a?`${s??""} · ${a}`:s}}case"Glob":return{Icon:Mt,label:"查找文件",summary:r("pattern")};case"Read":return{Icon:Sn,label:"读取文件",summary:r("file_path")??r("path")};case"LS":case"List":return{Icon:Pt,label:"列出目录",summary:r("path")};case"Task":return{Icon:Vi,label:"子任务",summary:r("description")??r("prompt")};case"Edit":{const s=r("file_path"),a=cr(n)?l.jsx(Gt,{oldText:n.old_string,newText:n.new_string}):void 0;return{Icon:Yt,label:"编辑文件",summary:ii(s),body:a}}case"MultiEdit":{const s=r("file_path"),a=Array.isArray(n.edits)?n.edits.filter(cr):[],o=a.length>0?l.jsx("div",{className:"space-y-2",children:a.map((c,u)=>l.jsx(Gt,{oldText:c.old_string,newText:c.new_string},u))}):void 0;return{Icon:Yt,label:"编辑文件",summary:ii(s),body:o}}case"Write":{const s=r("file_path"),a=r("content"),o=a!=null?l.jsx(Gt,{newText:a}):void 0;return{Icon:Yt,label:"写入文件",summary:ii(s),body:o}}case"TodoWrite":{const s=Xb(n.todos);if(!s)return{Icon:Rt,label:"更新任务列表"};const a=s.filter(o=>o.status==="completed").length;return{Icon:Rt,label:"更新任务列表",summary:`${a}/${s.length}`,body:l.jsx(Jb,{todos:s})}}case"NotebookEdit":return{Icon:Yt,label:"编辑 Notebook",summary:r("notebook_path")};default:return{Icon:qi,label:e}}}function tk({status:e}){const t=e==="completed"?"bg-success":e==="failed"?"bg-danger":e==="running"?"bg-accent animate-pulse-dot":"bg-content-faint";return l.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${t}`})}function tc({item:e}){const t=e.toolCall,n=e.commandExecution,r=(n==null?void 0:n.status)??(t==null?void 0:t.status),i=!!(n!=null&&n.output||t!=null&&t.input||t!=null&&t.output),[s,a]=v.useState(r==="running"||r==="failed"),o=!n&&t?ek(t.name,t.input):null,c=(o==null?void 0:o.Icon)??qi;return l.jsxs("div",{className:"overflow-hidden rounded-xl border border-border bg-surface",children:[l.jsxs("button",{onClick:()=>i&&a(u=>!u),className:`flex w-full items-center gap-2 px-3.5 py-2.5 text-left transition-colors ${i?"cursor-pointer hover:bg-surface-overlay":"cursor-default"} ${n?"border-b border-border bg-surface-raised":""}`,children:[i?s?l.jsx(xt,{size:12,className:"shrink-0 text-content-faint"}):l.jsx(nt,{size:12,className:"shrink-0 text-content-faint"}):l.jsx("span",{className:"w-3 shrink-0"}),l.jsx(tk,{status:r}),n?l.jsx("span",{className:"truncate font-mono text-[13px] text-content-secondary",children:`$ ${n.command??"命令"}`}):l.jsxs(l.Fragment,{children:[l.jsx(c,{size:12,className:"shrink-0 text-content-faint"}),l.jsx("span",{className:"shrink-0 text-[13px] font-medium text-content-secondary",children:(o==null?void 0:o.label)??(t==null?void 0:t.name)??"工具调用"}),(o==null?void 0:o.summary)&&l.jsx("span",{className:"truncate font-mono text-[13px] text-content-faint",children:Gb(o.summary)})]}),n&&typeof n.exitCode=="number"&&l.jsxs("span",{className:`ml-auto shrink-0 font-mono text-[13px] ${n.exitCode===0?"text-success":"text-danger"}`,children:["exit ",n.exitCode]})]}),s&&i&&l.jsxs("div",{className:n?"":"px-3.5 pb-3 pt-2",children:[(n==null?void 0:n.output)&&l.jsxs("div",{className:"group/out relative",children:[l.jsx("pre",{className:"max-h-72 overflow-auto px-3.5 py-2.5 font-mono text-[13px] leading-relaxed text-content-secondary",children:n.output}),l.jsx(Ir,{text:n.output,className:"absolute right-2 top-2 flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-border bg-surface text-content-muted opacity-0 transition-opacity hover:text-content-primary group-hover/out:opacity-100"})]}),o!=null&&o.body?o.body:(t==null?void 0:t.input)&&l.jsx("pre",{className:"max-h-40 overflow-auto rounded-lg bg-surface-raised px-3 py-2 font-mono text-[13px] text-content-faint",children:t.input}),(t==null?void 0:t.output)&&l.jsx("pre",{className:"mt-2 max-h-60 overflow-auto rounded-lg bg-surface-raised px-3 py-2 font-mono text-[13px] text-content-secondary",children:t.output})]})]})}function nk(e,t){if(!e||!t)return null;let n;try{const i=JSON.parse(t);if(!i||typeof i!="object")return null;n=i}catch{return null}const r=(e.split(/ · |__/).pop()??e).toLowerCase();if(r==="edit")return cr(n)?l.jsx(Gt,{oldText:n.old_string,newText:n.new_string}):typeof n.path=="string"?l.jsx("pre",{className:"max-h-32 overflow-auto rounded-lg bg-surface-raised px-3 py-2 font-mono text-[13px] text-content-secondary",children:n.path}):null;if(r==="multiedit"){const i=Array.isArray(n.edits)?n.edits.filter(cr):[];return i.length>0?l.jsx("div",{className:"space-y-2",children:i.map((s,a)=>l.jsx(Gt,{oldText:s.old_string,newText:s.new_string},a))}):null}return r==="write"?typeof n.content=="string"?l.jsx(Gt,{newText:n.content}):null:r==="bash"||r==="shell"||r==="command"||r==="commandexecution"?typeof n.command!="string"?null:l.jsxs("div",{children:[l.jsx("pre",{className:"max-h-32 overflow-auto rounded-lg bg-surface-raised px-3 py-2 font-mono text-[13px] text-content-secondary",children:`$ ${n.command}`}),typeof n.cwd=="string"&&n.cwd&&l.jsx("p",{className:"mt-1.5 font-mono text-xs text-content-faint",children:n.cwd}),typeof n.description=="string"&&n.description&&l.jsx("p",{className:"mt-1.5 text-xs text-content-muted",children:n.description})]}):null}function rk(e){if(!e)return!1;const t=e.tagName;return t==="TEXTAREA"||t==="INPUT"||t==="SELECT"?!0:e.isContentEditable===!0}function ik({item:e,onRespond:t}){var p;const[n,r]=v.useState(!1),i=e.permission,s=n||((p=e.metadata)==null?void 0:p.permissionPending)===!0,a=[...i&&i.options.length>0?i.options:[{id:"allow",label:"允许一次",kind:"allow"},{id:"deny",label:"拒绝",kind:"deny"}]].sort((h,m)=>h.kind===m.kind?0:h.kind==="allow"?-1:1),o=(h,m)=>{!i||s||(r(!0),t(i.requestId,h,m))},c=a.find(h=>h.kind==="allow"),u=c==null?void 0:c.id;if(v.useEffect(()=>{if(!i||s||!u)return;const h=m=>{m.key!=="Enter"||m.metaKey||m.ctrlKey||m.altKey||m.shiftKey||m.isComposing||rk(document.activeElement)||(m.preventDefault(),o("allow",u))};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[s,u,i==null?void 0:i.requestId]),!i)return null;const f=nk(i.toolName,i.toolInput),d=a.filter(h=>h.kind==="allow").length;return l.jsxs("div",{className:"rounded-xl border border-warning/40 bg-surface p-4",children:[l.jsx("p",{className:"text-sm font-medium text-content-primary",children:Uf(i.toolName)}),i.context&&l.jsx("p",{className:"mt-1.5 text-sm text-content-secondary",children:i.context}),f?l.jsx("div",{className:"mt-2",children:f}):i.toolInput&&l.jsx("pre",{className:"mt-2 max-h-32 overflow-auto rounded-lg bg-surface-raised px-3 py-2 font-mono text-[13px] text-content-faint",children:i.toolInput}),l.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:a.map(h=>{const m=h.kind==="allow"?a.filter(w=>w.kind==="allow").findIndex(w=>w.id===h.id):-1,b=h.kind==="allow"?m===0||d===1?"codex-btn-primary min-h-11 px-4 text-sm":"codex-btn-outline min-h-11 px-4 text-sm":"codex-btn-ghost min-h-11 px-4 text-sm";return l.jsx("button",{disabled:s,onClick:()=>o(h.kind==="allow"?"allow":"deny",h.id),className:b,children:h.label},h.id)})}),s&&l.jsx("p",{className:"mt-2 text-xs text-content-muted",children:"已发送…"})]})}function sk({item:e}){var t;return(t=e.plan)!=null&&t.length?l.jsxs("div",{className:"rounded-xl border border-border bg-surface p-4",children:[l.jsx("p",{className:"mb-2 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"计划"}),l.jsx("ul",{className:"space-y-1.5",children:e.plan.map(n=>l.jsxs("li",{className:"flex items-start gap-2 text-sm leading-6",children:[l.jsx("span",{className:"mt-1 shrink-0",children:n.status==="completed"?l.jsx(Rt,{size:12,className:"text-success"}):n.status==="in_progress"?l.jsx("span",{className:"block h-2.5 w-2.5 animate-pulse-dot rounded-full bg-accent"}):l.jsx("span",{className:"block h-2.5 w-2.5 rounded-full border border-content-faint"})}),l.jsx("div",{className:`min-w-0 flex-1 ${n.status==="completed"?"text-content-muted line-through":"text-content-secondary"}`,children:l.jsx(Gl,{text:n.text})})]},n.id))})]}):null}function ak({item:e,onSubmit:t}){var d,p,h;const n=e.structuredInput,[r,i]=v.useState({});if(!n)return null;const s=((d=e.metadata)==null?void 0:d.inputSubmitting)===!0,a=((p=e.metadata)==null?void 0:p.inputSubmitted)===!0,o=typeof((h=e.metadata)==null?void 0:h.inputError)=="string"?e.metadata.inputError:void 0,c=(m,b,w)=>{i(k=>{const A=k[m]??[];if(A.includes(b))return{...k,[m]:A.filter(Z=>Z!==b)};if(!w||w<=1)return{...k,[m]:[b]};const I=[...A,b];return{...k,[m]:I.slice(-w)}})},u=(m,b)=>{i(w=>({...w,[m]:b?[b]:[]}))},f=n.questions.every(m=>{var b;return(((b=r[m.id])==null?void 0:b.length)??0)>0});return l.jsxs("div",{className:"rounded-xl border border-accent-dim/40 bg-surface p-4",children:[l.jsx("p",{className:"text-sm font-medium text-accent",children:"需要你的输入"}),l.jsx("div",{className:"mt-3 space-y-4",children:n.questions.map(m=>l.jsxs("div",{children:[m.header&&l.jsx("p",{className:"text-2xs font-semibold uppercase tracking-wider text-content-faint",children:m.header}),l.jsx("p",{className:"mb-2 text-sm text-content-secondary",children:m.question}),m.options&&m.options.length>0&&m.selectionLimit&&m.selectionLimit>1&&l.jsxs("p",{className:"mb-2 text-2xs text-content-faint",children:["可多选",m.selectionLimit<m.options.length?`(最多 ${m.selectionLimit} 项)`:""]}),m.options&&m.options.length>0?l.jsx("div",{className:"flex flex-wrap gap-2",children:m.options.map(b=>{const w=(r[m.id]??[]).includes(b.id);return l.jsx("button",{disabled:a||s,onClick:()=>c(m.id,b.id,m.selectionLimit),title:b.description,className:w?"codex-btn-primary text-xs":"codex-btn-outline text-xs",children:b.label},b.id)})}):l.jsx("input",{type:m.isSecret?"password":"text",disabled:a||s,onChange:b=>u(m.id,b.target.value),className:"codex-input text-sm",placeholder:"输入答案…"})]},m.id))}),o&&l.jsx("p",{className:"mt-3 text-xs text-danger",children:o}),l.jsx("div",{className:"mt-3",children:a?l.jsx("span",{className:"text-xs text-content-muted",children:"已提交"}):l.jsx("button",{disabled:!f||s,onClick:()=>t(n.requestId,r),className:"codex-btn-primary text-xs",children:s?"提交中…":"提交"})})]})}function hs(){return l.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-2xs text-accent",children:[l.jsx("span",{className:"h-1 w-1 animate-pulse-dot rounded-full bg-accent"}),"正在生成"]})}function nc({item:e}){const[t,n]=v.useState(!!e.isStreaming);return l.jsxs("div",{className:"rounded-xl border border-border bg-surface px-3.5 py-2.5",children:[l.jsxs("button",{onClick:()=>n(r=>!r),className:"flex w-full cursor-pointer items-center gap-1.5 text-left text-xs text-content-muted transition-colors hover:text-content-secondary",children:[t?l.jsx(xt,{size:11,className:"shrink-0 text-content-faint"}):l.jsx(nt,{size:11,className:"shrink-0 text-content-faint"}),l.jsx("span",{children:"思考过程"}),e.isStreaming&&l.jsx(hs,{})]}),t&&e.text&&l.jsx("p",{className:"mt-2 whitespace-pre-wrap break-words pl-4 text-sm italic leading-relaxed text-content-muted",children:e.text})]})}function Ha({item:e,label:t}){const[n,r]=v.useState(!1),i=e.text!=null&&e.text.trim()!=="";return l.jsxs("div",{className:"flex items-center gap-2 py-0.5 text-2xs text-content-faint",children:[l.jsx("span",{className:"h-px flex-1 bg-border"}),l.jsxs("button",{onClick:()=>i&&r(s=>!s),className:`flex shrink-0 items-center gap-1 rounded-full border border-border bg-surface px-2.5 py-1 ${i?"cursor-pointer transition-colors hover:text-content-secondary":"cursor-default"}`,title:i?n?"收起":"展开":void 0,children:[l.jsx("span",{className:"font-medium",children:t}),e.isStreaming&&l.jsx(hs,{}),i&&(n?l.jsx(xt,{size:10}):l.jsx(nt,{size:10}))]}),l.jsx("span",{className:"h-px flex-1 bg-border"}),n&&i&&l.jsx("p",{className:"basis-full whitespace-pre-wrap break-words pt-1.5 text-xs italic leading-relaxed text-content-muted",children:e.text})]})}function ok(e){const t=Math.max(1,e.receiverThreadIds.length,e.receiverAgents.length),n=(e.tool||"").toLowerCase();return n.includes("spawn")?`启动 ${t} 个子 Agent`:n.includes("wait")?`等待 ${t} 个子 Agent`:n.includes("resume")?`恢复 ${t} 个子 Agent`:n.includes("close")?`关闭 ${t} 个子 Agent`:n.includes("sendinput")||n.includes("send_input")?`更新 ${t} 个子 Agent`:t===1?"子 Agent 活动":`${t} 个子 Agent 活动`}function lk(e){const t=(e||"").toLowerCase().replace(/[\s_-]/g,"");return t==="completed"||t==="done"||t==="success"?"完成":t==="failed"||t==="error"?"失败":t==="stopped"||t==="cancelled"?"已停止":t==="queued"||t==="pending"?"排队中":t==="running"||t==="inprogress"?"运行中":e||"未知"}function rc({item:e,onOpenAgent:t}){const n=e.subagent,[r,i]=v.useState(!0),s=[...new Set(n.receiverThreadIds.length>0?n.receiverThreadIds:n.receiverAgents.map(a=>a.threadId))];return l.jsxs("div",{className:"rounded-xl border border-border bg-surface p-3.5",children:[l.jsxs("button",{onClick:()=>i(a=>!a),className:"flex w-full cursor-pointer items-center gap-2 text-left",children:[l.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md bg-accent/10 text-accent",children:l.jsx(Vi,{size:13})}),l.jsx("span",{className:"flex-1 truncate text-sm font-medium text-content-primary",children:ok(n)}),e.isStreaming&&l.jsx("span",{className:"h-1.5 w-1.5 animate-pulse-dot rounded-full bg-accent"}),r?l.jsx(xt,{size:13,className:"shrink-0 text-content-faint"}):l.jsx(nt,{size:13,className:"shrink-0 text-content-faint"})]}),n.prompt&&l.jsx("p",{className:`mt-2 text-xs leading-relaxed text-content-muted ${r?"":"line-clamp-1"}`,children:n.prompt}),r&&s.length>0&&l.jsx("div",{className:"mt-2.5 space-y-0.5",children:s.map(a=>{const o=n.receiverAgents.find(p=>p.threadId===a),c=n.agentStates[a],u=lk((c==null?void 0:c.status)??n.status),f=o!=null&&o.nickname&&(o!=null&&o.role)?`${o.nickname} [${o.role}]`:(o==null?void 0:o.nickname)||(o==null?void 0:o.role)||(a.length>14?`Agent ${a.slice(-8)}`:a||"Agent"),d=u==="失败"?"bg-danger":u==="完成"?"bg-success":"bg-accent";return l.jsxs("button",{onClick:()=>t==null?void 0:t({threadId:a,name:f,role:o==null?void 0:o.role,model:o==null?void 0:o.model,prompt:(o==null?void 0:o.prompt)??n.prompt,status:u,message:c==null?void 0:c.message,tool:n.tool}),className:"flex w-full cursor-pointer items-center gap-2 rounded-lg px-1.5 py-1 text-left transition-colors hover:bg-surface-overlay",children:[l.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${d}`}),l.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-content-secondary",children:f}),(o==null?void 0:o.model)&&l.jsx("span",{className:"shrink-0 font-mono text-2xs text-content-faint",children:o.model}),l.jsx("span",{className:"shrink-0 text-2xs font-medium text-content-muted",children:u}),l.jsx(nt,{size:12,className:"shrink-0 text-content-faint"})]},a)})})]})}function ck({detail:e}){const t=e.status==="失败"?"bg-danger":e.status==="完成"?"bg-success":"bg-accent";return l.jsxs("div",{className:"flex h-full flex-col overflow-y-auto bg-surface",children:[l.jsxs("div",{className:"border-b border-border px-4 py-4",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-accent/10 text-accent",children:l.jsx(Vi,{size:15})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"truncate text-sm font-semibold text-content-primary",children:e.name}),l.jsx("p",{className:"truncate font-mono text-2xs text-content-faint",children:e.threadId})]}),l.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 text-xs text-content-secondary",children:[l.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${t}`}),e.status]})]}),l.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.role&&l.jsx("span",{className:"codex-chip",children:e.role}),e.model&&l.jsx("span",{className:"codex-chip",children:e.model}),e.tool&&l.jsx("span",{className:"codex-chip",children:e.tool})]})]}),l.jsxs("div",{className:"space-y-4 px-4 py-4",children:[e.prompt&&l.jsxs("section",{children:[l.jsx("p",{className:"mb-1.5 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"委派指令"}),l.jsx("div",{className:"rounded-xl border border-border bg-surface-raised p-3 text-[13px] leading-relaxed text-content-secondary whitespace-pre-wrap",children:e.prompt})]}),e.message&&l.jsxs("section",{children:[l.jsx("p",{className:"mb-1.5 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"状态消息"}),l.jsx("div",{className:"rounded-xl border border-border bg-surface-raised p-3 text-[13px] leading-relaxed text-content-secondary whitespace-pre-wrap",children:e.message})]}),l.jsx("p",{className:"pt-2 text-2xs leading-relaxed text-content-faint",children:"子 Agent 由主 Agent 内部派生,其完整对话记录不经网关透出,因此此处仅展示主 Agent 报告的状态信息。"})]})]})}const uk=new Set(["tool_activity","command_execution","file_change","subagent_action","thinking"]);function dk(e){return!!(e.kind&&uk.has(e.kind)||e.fileChange||e.commandExecution||e.toolCall||e.subagent||e.type==="tool_call")}function Hn(e){var t,n,r;return e.role==="user"&&((t=e.metadata)==null?void 0:t.delivery)==="queued"&&((n=e.metadata)==null?void 0:n.queuedSent)!==!0&&((r=e.metadata)==null?void 0:r.queuedDiscarded)!==!0}function fk({items:e,canSteer:t,onSend:n,onSteer:r,onDiscard:i}){return e.length===0?null:l.jsx("div",{className:"mb-2 flex flex-col gap-1.5",children:e.map(s=>l.jsxs("div",{className:"group flex animate-slide-in items-center gap-2 rounded-xl border border-border bg-surface-raised px-3.5 py-2.5 shadow-sm",children:[l.jsx("span",{className:"shrink-0 rounded-full bg-surface-overlay px-2 py-0.5 text-2xs font-medium text-content-muted",children:"已排队"}),l.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-content-secondary",children:s.text}),l.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[l.jsx("button",{onClick:()=>n(s.id),className:"cursor-pointer rounded-md px-2 py-1 text-2xs text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"立即发送",children:"立即发送"}),t&&l.jsx("button",{onClick:()=>r(s.id),className:"cursor-pointer rounded-md px-2 py-1 text-2xs text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"引导当前轮",children:"引导"}),l.jsx("button",{onClick:()=>i(s.id),className:"cursor-pointer rounded-md p-1 text-content-faint transition-colors hover:text-danger",title:"丢弃","aria-label":"丢弃排队消息",children:l.jsx(dt,{size:14})})]})]},s.id))})}function Wa(e,t,n){return e.kind==="thinking"?l.jsx(nc,{item:e}):e.kind==="subagent_action"||e.subagent?l.jsx(rc,{item:e,onOpenAgent:n}):e.kind==="file_change"||e.fileChange?l.jsx(ec,{item:e,onOpen:t}):l.jsx(tc,{item:e})}function hk(e){let t=1/0,n=0;for(const c of e){typeof c.createdAt=="number"&&(t=Math.min(t,c.createdAt));const u=typeof c.updatedAt=="number"?c.updatedAt:c.createdAt;typeof u=="number"&&(n=Math.max(n,u))}if(!Number.isFinite(t)||n<=t)return;const r=n-t;if(r<1e3)return;const i=Math.round(r/1e3);if(i<60)return`${(r/1e3).toFixed(1)}s`;const s=Math.floor(i/60),a=i%60;return s<60?`${s}m ${String(a).padStart(2,"0")}s`:`${Math.floor(s/60)}h ${String(s%60).padStart(2,"0")}m ${String(a).padStart(2,"0")}s`}function pk({items:e,live:t,onOpenDiff:n,onOpenAgent:r}){const[i,s]=v.useState(!1);if(t)return l.jsx("div",{className:"space-y-2",children:e.map(m=>l.jsx("div",{children:Wa(m,n,r)},m.id))});const a=e.filter(m=>m.kind==="file_change"||m.fileChange).length,o=e.filter(m=>m.kind==="command_execution"||m.commandExecution).length,c=e.filter(m=>(m.toolCall||m.type==="tool_call")&&!m.subagent).length,u=e.filter(m=>m.kind==="subagent_action"||m.subagent).length,f=e.filter(m=>m.kind==="thinking").length,d=[];a&&d.push(`编辑 ${a} 个文件`),o&&d.push(`运行 ${o} 条命令`),c&&d.push(`调用 ${c} 个工具`),u&&d.push(`${u} 次子 Agent`),!a&&!o&&!c&&!u&&f&&d.push("思考");const p=d.join(" · ")||`${e.length} 项活动`,h=hk(e);return i?l.jsxs("div",{className:"rounded-xl border border-border bg-surface p-2",children:[l.jsxs("button",{onClick:()=>s(!1),className:"mb-2 flex w-full cursor-pointer items-center gap-1.5 px-1.5 text-left text-xs text-content-muted transition-colors hover:text-content-secondary",children:[l.jsx(xt,{size:12,className:"shrink-0 text-content-faint"}),l.jsx("span",{children:p}),h&&l.jsxs("span",{className:"text-content-faint",children:["· ",h]})]}),l.jsx("div",{className:"space-y-2",children:e.map(m=>l.jsx("div",{children:Wa(m,n,r)},m.id))})]}):l.jsxs("button",{onClick:()=>s(!0),className:"flex w-full cursor-pointer items-center gap-1.5 rounded-full border border-border bg-surface px-3.5 py-2 text-left text-xs text-content-muted transition-colors hover:border-border-strong hover:text-content-secondary",children:[l.jsx(nt,{size:12,className:"shrink-0 text-content-faint"}),l.jsx("span",{children:p}),h&&l.jsxs("span",{className:"text-content-faint",children:["· ",h]}),l.jsx("span",{className:"ml-auto text-content-faint",children:"展开"})]})}const Za=v.memo(function({item:t,canSteer:n,onPermission:r,onStructuredInput:i,onSendQueued:s,onSteerQueued:a,onDiscardQueued:o,onOpenDiff:c,onOpenAgent:u,onEditMessage:f,onFork:d,highlightQuery:p}){var w;if(t.kind==="user_input_prompt"||t.structuredInput)return l.jsx(ak,{item:t,onSubmit:i});if(t.kind==="subagent_action"||t.subagent)return l.jsx(rc,{item:t,onOpenAgent:u});if(t.kind==="file_change"||t.fileChange)return l.jsx(ec,{item:t,onOpen:c});if(t.kind==="command_execution"||t.commandExecution||t.type==="tool_call"||t.toolCall)return l.jsx(tc,{item:t});if(t.type==="permission"||t.permission)return l.jsx(ik,{item:t,onRespond:r});if(t.type==="plan"||t.plan)return l.jsx(sk,{item:t});if(t.type==="error"||t.error)return l.jsxs("div",{className:"flex items-start gap-2 rounded-xl border border-danger/40 bg-surface px-3.5 py-2.5 text-sm text-danger",children:[l.jsx("span",{className:"mt-1.5 block h-1.5 w-1.5 shrink-0 rounded-full bg-danger"}),l.jsx("span",{children:t.error??"发生错误"})]});if(t.kind==="thinking")return l.jsx(nc,{item:t});if(t.kind==="context_compaction")return l.jsx(Ha,{item:t,label:"上下文压缩"});if(t.kind==="review")return l.jsx(Ha,{item:t,label:"审查"});const h=t.role==="user",m=((w=t.metadata)==null?void 0:w.queuedDiscarded)===!0,b=t.text!=null&&t.text!=="";return l.jsxs("div",{className:h?"group flex flex-col items-end":"group min-w-0",children:[l.jsxs("div",{className:h?`max-w-[85%] break-words rounded-2xl px-4 py-2.5 text-[15px] leading-7 ${m?"bg-surface-raised text-content-secondary line-through opacity-50":"bg-surface-raised text-content-primary"}`:"w-full min-w-0",children:[Array.isArray(t.content)&&t.content.some(k=>k.type==="image")&&l.jsx("div",{className:"mb-1.5 flex flex-wrap gap-2",children:t.content.filter(k=>k.type==="image"&&k.data).map((k,A)=>l.jsx("img",{src:k.data,alt:"附件",className:"max-h-48 rounded-lg border border-border object-contain"},A))}),b&&l.jsx(Gl,{text:t.text,highlight:p}),t.isStreaming&&l.jsx(hs,{})]}),m&&l.jsx("span",{className:"mt-1 text-2xs text-content-faint",children:"已丢弃"}),b&&!t.isStreaming&&!m&&l.jsxs("div",{className:`mt-1 flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 ${h?"justify-end":""}`,children:[h&&f&&l.jsx("button",{onClick:()=>f(t.text),title:"编辑并重新发送","aria-label":"编辑并重新发送",className:"flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-border bg-surface text-content-muted transition-colors hover:text-content-primary",children:l.jsx(Yt,{size:13})}),d&&l.jsx("button",{onClick:()=>d(t.itemId??t.id),title:"从此处分叉出新会话","aria-label":"从此处分叉",className:"flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-border bg-surface text-content-muted transition-colors hover:text-content-primary",children:l.jsx(Gc,{size:13})}),l.jsx(Ir,{text:t.text})]})]})},(e,t)=>e.item===t.item&&e.canSteer===t.canSteer&&e.onPermission===t.onPermission&&e.onStructuredInput===t.onStructuredInput&&e.onSendQueued===t.onSendQueued&&e.onSteerQueued===t.onSteerQueued&&e.onDiscardQueued===t.onDiscardQueued&&e.onOpenDiff===t.onOpenDiff&&e.onOpenAgent===t.onOpenAgent&&e.onEditMessage===t.onEditMessage&&e.onFork===t.onFork&&e.highlightQuery===t.highlightQuery);function zn({open:e,anchorRef:t,placement:n="bottom-end",onClose:r,children:i,className:s,minWidth:a=176}){const o=v.useRef(null),[c,u]=v.useState({}),f=v.useCallback(()=>{const d=t.current;if(!d)return;const p=d.getBoundingClientRect(),h=6,m={position:"fixed",zIndex:80,maxWidth:"calc(100vw - 16px)",minWidth:a},b=n.startsWith("top"),w=n.endsWith("end");b?m.bottom=Math.max(8,window.innerHeight-p.top+h):m.top=Math.min(window.innerHeight-8,p.bottom+h),w?m.right=Math.max(8,window.innerWidth-p.right):m.left=Math.max(8,Math.min(p.left,window.innerWidth-a-8)),u(m)},[t,n,a]);return v.useLayoutEffect(()=>{e&&f()},[e,f]),v.useEffect(()=>{if(!e)return;const d=b=>{var k,A;const w=b.target;(k=t.current)!=null&&k.contains(w)||(A=o.current)!=null&&A.contains(w)||r()},p=b=>{b.key==="Escape"&&r()},h=()=>f(),m=window.setTimeout(()=>document.addEventListener("pointerdown",d),0);return window.addEventListener("keydown",p),window.addEventListener("resize",h),window.addEventListener("scroll",h,!0),()=>{window.clearTimeout(m),document.removeEventListener("pointerdown",d),window.removeEventListener("keydown",p),window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0)}},[e,r,f]),!e||typeof document>"u"?null:pc.createPortal(l.jsx("div",{ref:o,style:c,className:s,role:"menu",children:i}),document.body)}function mk(e){const[t,n]=v.useState(()=>typeof window<"u"&&"matchMedia"in window?window.matchMedia(e).matches:!1);return v.useEffect(()=>{if(typeof window>"u"||!("matchMedia"in window))return;const r=window.matchMedia(e),i=()=>n(r.matches);return i(),r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[e]),t}function ic(){return mk("(max-width: 767px)")}function gk({disabled:e,running:t,supportsImages:n,commands:r=[],conversationId:i,lastUserText:s,cwd:a,onBrowse:o,seedText:c,controls:u,onSend:f,onCancel:d,onExecuteCommand:p}){const[h,m]=v.useState(""),[b,w]=v.useState([]),[k,A]=v.useState(0),[I,Z]=v.useState(!1),[Q,j]=v.useState([]),[Y,X]=v.useState([]),[G,_]=v.useState(null),F=v.useRef(null),$=v.useRef(null),ae=v.useRef(null),q=ic();v.useEffect(()=>{if(!i)return;const C=Pc(i);m(C),j([]),requestAnimationFrame(()=>z())},[i]),v.useEffect(()=>{!c||c.nonce===0||(m(c.text),requestAnimationFrame(()=>{const C=F.current;C&&(C.focus(),C.setSelectionRange(C.value.length,C.value.length),z())}))},[c==null?void 0:c.nonce]);const O=v.useMemo(()=>{const C=/^\/(\S*)$/.exec(h);if(!C||r.length===0)return null;const U=C[1].toLowerCase(),ke=r.map(Se=>{const Fe=Se.name.toLowerCase(),Ft=Se.title.toLowerCase();return U?Fe.startsWith(U)||Ft.startsWith(`/${U}`)?{c:Se,rank:0}:Fe.includes(U)||Ft.includes(U)?{c:Se,rank:1}:null:{c:Se,rank:2}}).filter(Se=>Se!==null).sort((Se,Fe)=>Se.rank-Fe.rank).slice(0,8).map(Se=>Se.c);return ke.length>0?ke:null},[h,r]),J=v.useMemo(()=>{if(!o)return null;const C=/(?:^|\s)@(\S*)$/.exec(h);if(!C)return null;const U=C[1],ie=U.lastIndexOf("/"),ke=ie>=0?U.slice(0,ie):"",Se=ie>=0?U.slice(ie+1):U;return{token:`@${U}`,query:U,dir:ke,filter:Se}},[h,o]),de=v.useMemo(()=>{if(!J)return null;const C=(a||".").replace(/\/+$/,"")||"/";return J.dir?`${C}/${J.dir}`:C},[J,a]);v.useEffect(()=>{if(!de||!o||de===G)return;let C=!1;return o(de).then(U=>{C||(X(U.error?[]:U.entries),_(de))}).catch(()=>{C||X([])}),()=>{C=!0}},[de,G,o]);const Ce=v.useMemo(()=>{if(!J||G!==de)return null;const C=J.filter.toLowerCase(),U=Y.filter(ie=>ie.name.toLowerCase().includes(C)).sort((ie,ke)=>ie.isDirectory!==ke.isDirectory?ie.isDirectory?-1:1:ie.name.localeCompare(ke.name)).slice(0,50);return U.length>0?U:null},[J,Y,G,de]),P=O?{kind:"slash",items:O}:Ce?{kind:"mention",items:Ce}:null,x=()=>{F.current&&(F.current.style.height="auto")},z=()=>{const C=F.current;C&&(C.style.height="auto",C.style.height=`${Math.min(C.scrollHeight,200)}px`)},me=C=>{m(C),A(0),i&&Mc(i,C),z()},y=C=>{var U;C.argsMode==="none"?(p==null||p(C.id),me(""),x()):(me(`/${C.name} `),(U=F.current)==null||U.focus())},Ee=C=>{var Se;if(!J)return;const U=(a||".").replace(/\/+$/,""),ie=U&&C.path.startsWith(U)?C.path.slice(U.length).replace(/^\/+/,""):C.name,ke=h.slice(0,h.length-J.token.length);C.isDirectory?me(`${ke}@${ie}/`):(me(ke),j(Fe=>Fe.includes(ie)?Fe:[...Fe,ie])),(Se=F.current)==null||Se.focus()},Ie=()=>{if(e)return;const C=h.trim(),U=/^\/(\S+)\s*(.*)$/s.exec(C);if(U&&p){const Se=r.find(Fe=>Fe.name.toLowerCase()===U[1].toLowerCase());if(Se){p(Se.id,U[2]||void 0),me(""),j([]),x();return}}const ke=[Q.map(Se=>`@${Se}`).join(" "),C].filter(Boolean).join(" ");!ke&&b.length===0||(f(ke,b),me(""),w([]),j([]),x())},Ne=C=>{if(P){const U=P.items.length;if(C.key==="ArrowDown"){C.preventDefault(),A(ke=>Math.min(ke+1,U-1));return}if(C.key==="ArrowUp"){C.preventDefault(),A(ke=>Math.max(ke-1,0));return}const ie=()=>{const ke=Math.min(k,U-1);P.kind==="slash"?y(P.items[ke]):Ee(P.items[ke])};if(C.key==="Tab"){C.preventDefault(),ie();return}if(C.key==="Enter"&&!C.metaKey&&!C.ctrlKey&&!C.shiftKey&&P.kind==="mention"){C.preventDefault(),ie();return}if(C.key==="Enter"&&(C.metaKey||C.ctrlKey)){C.preventDefault(),ie();return}if(C.key==="Escape"){C.preventDefault(),P.kind==="slash"?me(""):J&&me(h.slice(0,h.length-J.token.length));return}}if(C.key==="ArrowUp"&&!P&&h===""&&s){C.preventDefault(),me(s),requestAnimationFrame(()=>{const U=F.current;U&&U.setSelectionRange(U.value.length,U.value.length)});return}C.key==="Enter"&&(C.metaKey||C.ctrlKey)&&(C.preventDefault(),Ie())},Le=C=>{for(const U of C){if(!U.type.startsWith("image/"))continue;const ie=new FileReader;ie.onload=()=>{const ke=String(ie.result);w(Se=>[...Se,{data:ke,mimeType:U.type||"image/png",name:U.name||"粘贴图片"}])},ie.readAsDataURL(U)}},le=C=>{Le(Array.from(C.target.files??[])),C.target.value=""},Ke=C=>{if(!n)return;const U=Array.from(C.clipboardData.items).filter(ie=>ie.kind==="file"&&ie.type.startsWith("image/")).map(ie=>ie.getAsFile()).filter(ie=>ie!=null);U.length>0&&(C.preventDefault(),Le(U))},Oe=C=>{if(Z(!1),!n)return;const U=Array.from(C.dataTransfer.files).filter(ie=>ie.type.startsWith("image/"));U.length>0&&(C.preventDefault(),Le(U))},Ye=C=>{n&&Array.from(C.dataTransfer.items).some(U=>U.kind==="file")&&(C.preventDefault(),Z(!0))};return l.jsxs("div",{ref:ae,className:"relative",children:[P&&l.jsx(zn,{open:!0,anchorRef:ae,placement:"top-start",onClose:()=>{},className:"codex-card-raised max-h-72 overflow-y-auto p-1",minWidth:280,children:P.kind==="slash"?P.items.map((C,U)=>{const ie=C.description&&C.description!==C.title?C.description:void 0,ke=C.argsMode==="required"?"需要参数":C.argsMode==="optional"?"可选参数":void 0;return l.jsxs("button",{onMouseEnter:()=>A(U),onClick:()=>y(C),className:`flex w-full cursor-pointer flex-col rounded-lg px-2.5 py-1.5 text-left transition-colors ${U===k?"bg-surface-overlay":"hover:bg-surface-overlay"}`,children:[l.jsxs("span",{className:"flex w-full items-center",children:[l.jsxs("span",{className:"font-mono text-xs text-accent",children:["/",C.name]}),l.jsx("span",{className:"ml-2 flex-1 truncate text-xs text-content-muted",children:C.title}),ke&&l.jsx("span",{className:"ml-2 shrink-0 rounded bg-surface px-1.5 py-0.5 text-[10px] text-content-faint",children:ke}),C.destructive&&l.jsx("span",{className:"ml-2 h-1.5 w-1.5 shrink-0 rounded-full bg-danger",title:"破坏性操作"})]}),ie&&l.jsx("span",{className:"mt-0.5 truncate text-[11px] text-content-faint",children:ie})]},C.id)}):P.items.map((C,U)=>l.jsxs("button",{onMouseEnter:()=>A(U),onClick:()=>Ee(C),className:`flex w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-left transition-colors ${U===k?"bg-surface-overlay":"hover:bg-surface-overlay"}`,children:[C.isDirectory?l.jsx(Pt,{size:13,className:"shrink-0 text-content-faint"}):l.jsx(Sn,{size:13,className:"shrink-0 text-content-faint"}),l.jsx("span",{className:"truncate font-mono text-xs text-content-secondary",children:C.name}),C.isDirectory&&l.jsx("span",{className:"text-content-faint",children:"/"})]},C.path))}),b.length>0&&l.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:b.map((C,U)=>l.jsxs("div",{className:"group relative",children:[l.jsx("img",{src:C.data,alt:C.name,className:"h-14 w-14 rounded-lg border border-border object-cover"}),l.jsx("button",{onClick:()=>w(ie=>ie.filter((ke,Se)=>Se!==U)),className:"absolute -right-1.5 -top-1.5 flex h-4 w-4 cursor-pointer items-center justify-center rounded-full bg-danger text-white","aria-label":"移除图片",children:l.jsx(dt,{size:10})})]},U))}),Q.length>0&&l.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:Q.map(C=>l.jsxs("span",{className:"flex items-center gap-1 rounded-lg border border-border bg-surface-overlay py-1 pl-2 pr-1 font-mono text-xs text-content-secondary",children:[l.jsx(Sn,{size:12,className:"shrink-0 text-content-faint"}),l.jsx("span",{className:"max-w-[200px] truncate",title:C,children:C}),l.jsx("button",{onClick:()=>j(U=>U.filter(ie=>ie!==C)),className:"flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded text-content-faint transition-colors hover:text-danger","aria-label":`移除 ${C}`,children:l.jsx(dt,{size:11})})]},C))}),l.jsxs("div",{onDrop:Oe,onDragOver:Ye,onDragLeave:()=>Z(!1),className:`codex-card-raised flex flex-col gap-1 px-3 pt-2.5 pb-2 transition-colors focus-within:border-border-strong ${I?"border-border-strong":""}`,children:[n&&l.jsx("input",{ref:$,type:"file",accept:"image/*",multiple:!0,onChange:le,className:"hidden"}),l.jsx("textarea",{ref:F,value:h,rows:1,disabled:e,placeholder:q?r.length>0?"发送指令,或输入 / 调用命令…":"向 agent 发送指令…":r.length>0?"发送指令,/ 调用命令,@ 引用文件 (⌘/Ctrl+Enter 发送)":"向 agent 发送指令,@ 引用文件 (⌘/Ctrl+Enter 发送,Enter 换行)",onChange:C=>me(C.target.value),onKeyDown:Ne,onPaste:Ke,className:"min-w-0 resize-none bg-transparent px-0 py-1 text-base leading-6 text-content-primary placeholder-content-muted outline-none md:text-[15px]"}),l.jsxs("div",{className:"flex items-center gap-1",children:[n&&l.jsx("button",{onClick:()=>{var C;return(C=$.current)==null?void 0:C.click()},disabled:e,className:"flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-full text-content-muted transition-colors hover:bg-surface-overlay hover:text-content-primary disabled:opacity-40",title:"附加图片","aria-label":"附加图片",children:l.jsx(_n,{size:17})}),l.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:u}),t&&d?l.jsx("button",{onClick:d,className:"flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full bg-surface-overlay text-content-secondary transition-colors hover:bg-surface-raised hover:text-content-primary","aria-label":"停止",title:"停止",children:l.jsx(yo,{size:14})}):l.jsx("button",{onClick:Ie,disabled:e||!h.trim()&&b.length===0&&Q.length===0,className:"flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full bg-accent-dim text-white transition-colors hover:bg-accent disabled:cursor-default disabled:bg-surface-overlay disabled:text-content-faint","aria-label":"发送",title:"发送",children:l.jsx(bo,{size:16})})]})]})]})}const xk="modulepreload",yk=function(e){return"/"+e},Qa={},Tr=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let a=function(u){return Promise.all(u.map(f=>Promise.resolve(f).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),c=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));i=a(n.map(u=>{if(u=yk(u),u in Qa)return;Qa[u]=!0;const f=u.endsWith(".css"),d=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${d}`))return;const p=document.createElement("link");if(p.rel=f?"stylesheet":xk,f||(p.as="script"),p.crossOrigin="",p.href=u,c&&p.setAttribute("nonce",c),document.head.appendChild(p),f)return new Promise((h,m)=>{p.addEventListener("load",h),p.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${u}`)))})}))}function s(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return i.then(a=>{for(const o of a||[])o.status==="rejected"&&s(o.reason);return t().catch(s)})},bk=v.lazy(()=>Tr(()=>import("./TerminalPanel-C3hvv9KU.js"),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.TerminalPanel}))),kk=v.lazy(()=>Tr(()=>import("./UsageDashboard-D9Xlpl3d.js"),__vite__mapDeps([4,1,3])).then(e=>({default:e.UsageDashboard}))),vk=v.lazy(()=>Tr(()=>import("./PortPreview-6-Cj-cKd.js"),__vite__mapDeps([5,1,3])).then(e=>({default:e.PortPreview}))),wk=v.lazy(()=>Tr(()=>import("./FileBrowser-Daeji5i-.js"),__vite__mapDeps([6,1,3])).then(e=>({default:e.FileBrowser})));function Sk(){return l.jsx("div",{className:"flex h-full w-full items-center justify-center",children:l.jsx("span",{className:"h-5 w-5 animate-spin rounded-full border-2 border-content-faint border-t-accent"})})}function Ar(e){return function(n){return l.jsx(v.Suspense,{fallback:l.jsx(Sk,{}),children:l.jsx(e,{...n})})}}const Ka=Ar(bk),_k=Ar(kk),jk=Ar(vk),Ck=Ar(wk);function ps(e){if(!e||e==="—")return"(未知目录)";const t=e.replace(/\/+$/,"").split("/");return t[t.length-1]||e}function sc(e){return e!=null&&e.length?e.filter(t=>t&&!t.includes("/.codex/visualizations/")):[]}function Nk(e){const t=e.map(ps);return t.length===0?"工作区":t.length===1?t[0]:t.length===2?`${t[0]} + ${t[1]}`:`${t[0]} + ${t.length-1} 个项目`}function Ik(e){if(e.provider==="codex"){const n=sc(e.workspaceRoots);if(n.length>1)return{key:`ws:${[...n].sort().join(`
36
- `)}`,label:Nk(n),kind:"workspace"}}if(e.provider==="claude"&&e.group)return{key:`group:${e.group}`,label:e.group,kind:"group"};const t=e.cwd||"—";return{key:`cwd:${t}`,label:ps(t),kind:"folder"}}function Tk(e){const t=new Map;for(const r of e){const i=Ik(r);let s=t.get(r.provider);s||(s=new Map,t.set(r.provider,s));let a=s.get(i.key);a||(a={provider:r.provider,key:i.key,label:i.label,kind:i.kind,conversations:[]},s.set(i.key,a)),a.conversations.push(r)}const n=r=>r.conversations.reduce((i,s)=>Math.max(i,s.lastActivityAt),0);return[...t.entries()].map(([r,i])=>({provider:r,buckets:[...i.values()].map(s=>({...s,conversations:[...s.conversations].sort((a,o)=>o.lastActivityAt-a.lastActivityAt)})).sort((s,a)=>n(a)-n(s))})).sort((r,i)=>r.provider.localeCompare(i.provider))}function Ak(e){var n,r;if(e.kind==="workspace")return sc((n=e.conversations[0])==null?void 0:n.workspaceRoots)[0];const t=(r=e.conversations[0])==null?void 0:r.cwd;return t&&t!=="—"?t:void 0}function Ek({open:e,confirmDelete:t,archived:n,onToggle:r,onClose:i,onRename:s,onArchive:a,onDelete:o}){const c=v.useRef(null);return l.jsxs(l.Fragment,{children:[l.jsx("button",{ref:c,onClick:u=>{u.stopPropagation(),r()},className:`absolute right-1.5 top-1.5 cursor-pointer rounded-md p-1 text-content-faint transition-colors hover:bg-surface-overlay hover:text-content-primary ${e?"opacity-100":"opacity-0 group-hover:opacity-100"}`,title:"更多操作","aria-label":"更多操作",children:l.jsx(So,{size:14})}),l.jsxs(zn,{open:e,anchorRef:c,placement:"bottom-end",onClose:i,className:"overflow-hidden rounded-lg border border-border bg-surface py-1 shadow-xl",minWidth:160,children:[l.jsxs("button",{onClick:s,className:"flex w-full cursor-pointer items-center gap-2 px-3 py-2.5 text-left text-2xs text-content-secondary transition-colors hover:bg-surface-overlay",children:[l.jsx(Yt,{size:13})," 改名"]}),l.jsxs("button",{onClick:a,className:"flex w-full cursor-pointer items-center gap-2 px-3 py-2.5 text-left text-2xs text-content-secondary transition-colors hover:bg-surface-overlay",children:[l.jsx(wo,{size:13})," ",n?"取消归档":"归档"]}),l.jsxs("button",{onClick:o,className:"flex w-full cursor-pointer items-center gap-2 px-3 py-2.5 text-left text-2xs text-danger transition-colors hover:bg-danger/10",children:[l.jsx(Jc,{size:13})," ",t?"确认从列表移除?":"从列表移除"]})]})]})}function Ya(e,t){return e.status==="waiting_permission"?0:e.status==="running"?1:e.status==="error"?2:e.id===t?3:4}function Pk(e){return(t,n)=>{const r=Ya(t,e)-Ya(n,e);return r!==0?r:n.lastActivityAt-t.lastActivityAt}}function Mk(e){return e.status==="waiting_permission"||e.status==="running"||e.status==="error"}function Xa(e){switch(e){case"claude":return"Claude";case"codex":return"Codex";case"gemini":return"Gemini";case"copilot":return"Copilot";case"opencode":return"OpenCode";case"cursor":return"Cursor";case"grok":return"Grok";case"kimi":return"Kimi";default:return e}}function si({status:e}){const t=e==="unavailable"?{text:"不可用",className:"border-border bg-surface-overlay text-content-faint"}:$o(e);return t?l.jsxs("span",{className:`inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${t.className}`,children:[t.pulsing&&l.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-pulse-dot"}),t.text]}):null}function Ja({deviceLabel:e,conversations:t,capabilities:n,activeConversationId:r,externalAgentStatus:i,externalAgentTitle:s,externalAgentProvider:a,store:o,onSelect:c,onNewConversation:u,onOpenExternalTerminal:f}){const p=((n==null?void 0:n.providers)??[]).filter(z=>z.enabled),[h,m]=v.useState(!1),b=v.useMemo(()=>t.filter(z=>z.archived).length,[t]),w=v.useCallback(z=>!(z.archived&&!h||z.model==="<synthetic>"),[h]),k=v.useMemo(()=>t.filter(w),[t,w]),A=v.useMemo(()=>k.filter(Mk).sort(Pk(r)),[k,r]),I=i==="running"||i==="waiting_permission"||i==="error",Z=I||A.length>0,Q=v.useMemo(()=>Tk(k),[k]),[j,Y]=v.useState(new Set),X=z=>Y(me=>{const y=new Set(me);return y.has(z)?y.delete(z):y.add(z),y}),[G,_]=v.useState(null),[F,$]=v.useState(null),[ae,q]=v.useState(null),[O,J]=v.useState(""),de=v.useRef(!1),Ce=()=>{_(null),$(null)},P=z=>{Ce(),q(z.id),J(z.title&&z.title.trim()||"")},x=z=>{o.renameConversation(z.id,O),q(null)};return l.jsxs("div",{className:"flex h-full flex-col",children:[l.jsxs("div",{className:"flex items-center gap-2.5 border-b border-border px-3 py-3",children:[l.jsx(Wc,{size:14,className:"shrink-0 text-content-faint"}),l.jsx("span",{className:"truncate font-mono text-[13px] font-semibold text-content-secondary",children:e})]}),l.jsxs("div",{className:"space-y-2 border-b border-border px-3 py-3",children:[l.jsx("p",{className:"text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"新建对话"}),p.length===0?l.jsx("span",{className:"text-2xs text-content-faint",children:"等待能力…"}):l.jsx("div",{className:"flex flex-wrap gap-2",children:p.map(z=>l.jsxs("button",{onClick:()=>u(z.id),className:"codex-btn-outline text-2xs","aria-label":`新建 ${z.label} 对话`,children:[l.jsx(Xt,{provider:z.id,size:13})," ",z.label]},z.id))})]}),Z&&l.jsxs("div",{className:"border-b border-border px-3 py-3",children:[l.jsx("p",{className:"mb-2 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"活跃会话"}),l.jsxs("div",{className:"space-y-1",children:[I&&i&&l.jsxs("button",{onClick:f,className:"flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-2 text-left transition-colors duration-150 hover:bg-surface-overlay",title:"打开终端面板",children:[l.jsx(Xt,{provider:a??"custom",size:14}),l.jsxs("span",{className:"min-w-0 flex-1",children:[l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"truncate text-[13px] font-medium text-content-primary",children:s??"外部终端"}),l.jsx(si,{status:i})]}),l.jsx("span",{className:"mt-0.5 block truncate font-mono text-2xs text-content-muted",children:e})]})]},"active:external-terminal"),A.map(z=>{const me=z.title&&z.title.trim()||z.lastMessagePreview&&z.lastMessagePreview.trim().slice(0,40)||`对话 ${z.id.slice(-6)}`;return l.jsxs("button",{onClick:()=>c(z.id),className:`flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-2 text-left transition-colors duration-150 hover:bg-surface-overlay ${z.id===r?"tree-row-active":""}`,title:z.cwd,children:[l.jsx(Xt,{provider:z.provider,size:14}),l.jsxs("span",{className:"min-w-0 flex-1",children:[l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"truncate text-[13px] font-medium text-content-primary",children:me}),l.jsx(si,{status:z.status})]}),l.jsx("span",{className:"mt-0.5 block truncate font-mono text-2xs text-content-muted",children:ps(z.cwd)})]})]},`active:${z.id}`)})]})]}),l.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 py-3",children:Q.length===0?l.jsx("p",{className:"px-3 py-2 text-2xs text-content-faint",children:h||b===0?"还没有对话":"没有未归档的对话"}):Q.map(z=>{const me=`prov:${z.provider}`,y=j.has(me),Ee=z.buckets.reduce((Ie,Ne)=>Ie+Ne.conversations.length,0);return l.jsxs("div",{className:"py-1",children:[l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsxs("button",{onClick:()=>X(me),className:"tree-row flex-1",children:[y?l.jsx(nt,{size:12,className:"shrink-0 text-content-faint"}):l.jsx(xt,{size:12,className:"shrink-0 text-content-faint"}),l.jsx(Xt,{provider:z.provider,size:13}),l.jsx("span",{className:"text-[13px] font-medium text-content-secondary",children:Xa(z.provider)}),l.jsxs("span",{className:"text-2xs text-content-faint",children:["(",Ee,")"]})]}),l.jsx("button",{onClick:()=>u(z.provider),className:"cursor-pointer rounded-lg p-1.5 text-content-faint transition-colors hover:bg-surface-overlay hover:text-accent",title:`新建 ${Xa(z.provider)} 对话`,"aria-label":"新建对话",children:l.jsx(_n,{size:13})})]}),!y&&z.buckets.map(Ie=>{const Ne=`bucket:${z.provider}:${Ie.key}`,Le=j.has(Ne);return l.jsxs("div",{className:"pl-3",children:[l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsxs("button",{onClick:()=>X(Ne),className:"tree-row flex-1",title:Ie.kind==="workspace"?"多项目工作区":Ie.label,children:[Le?l.jsx(nt,{size:12,className:"shrink-0 text-content-faint"}):l.jsx(xt,{size:12,className:"shrink-0 text-content-faint"}),l.jsx(Pt,{size:13,className:"shrink-0 text-content-faint"}),l.jsx("span",{className:"truncate text-2xs font-semibold uppercase tracking-wider text-content-faint",children:Ie.label}),Ie.kind==="workspace"&&l.jsx("span",{className:"shrink-0 rounded bg-surface-overlay px-1 text-[10px] text-content-faint",children:"工作区"})]}),Ie.kind!=="workspace"&&l.jsx("button",{onClick:()=>u(z.provider,Ak(Ie)),className:"cursor-pointer rounded-lg p-1.5 text-content-faint transition-colors hover:bg-surface-overlay hover:text-accent",title:"在此分组新建对话","aria-label":"新建对话",children:l.jsx(_n,{size:13})})]}),!Le&&Ie.conversations.map(le=>{const Ke=le.title&&le.title.trim()||le.lastMessagePreview&&le.lastMessagePreview.trim().slice(0,40)||`对话 ${le.id.slice(-6)}`,Oe=ae===le.id,Ye=G===le.id;return l.jsxs("div",{className:"group relative",children:[Oe?l.jsx("input",{autoFocus:!0,value:O,onChange:C=>J(C.target.value),onKeyDown:C=>{C.key==="Enter"?(C.preventDefault(),C.currentTarget.blur()):C.key==="Escape"&&(de.current=!0,C.currentTarget.blur())},onBlur:()=>{if(de.current){de.current=!1,q(null);return}x(le)},placeholder:"对话名称",className:"block w-full rounded-lg border border-accent bg-surface py-2 pl-7 pr-3 text-[13px] text-content-primary outline-none"}):l.jsxs("button",{onClick:()=>c(le.id),className:`block w-full cursor-pointer rounded-lg py-2 pl-7 pr-9 text-left transition-colors duration-150 hover:bg-surface-overlay ${le.id===r?"tree-row-active":""}`,children:[l.jsxs("p",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"truncate text-[13px] text-content-primary",children:Ke}),l.jsx(si,{status:le.status}),le.archived&&l.jsx("span",{className:"shrink-0 rounded bg-surface-overlay px-1 text-2xs text-content-faint",children:"已归档"})]}),le.lastMessagePreview&&le.lastMessagePreview.trim()!==Ke&&l.jsx("p",{className:"mt-0.5 truncate text-2xs text-content-muted",children:le.lastMessagePreview})]}),!Oe&&l.jsx(Ek,{open:Ye,confirmDelete:F===le.id,archived:!!le.archived,onToggle:()=>{$(null),_(Ye?null:le.id)},onClose:Ce,onRename:()=>P(le),onArchive:()=>{o.setConversationArchived(le.id,!le.archived),Ce()},onDelete:()=>{F===le.id?(o.deleteConversation(le.id),Ce()):$(le.id)}})]},le.id)})]},Ie.key)})]},z.provider)})}),b>0&&l.jsxs("button",{onClick:()=>m(z=>!z),className:"flex items-center gap-2 border-t border-border px-3 py-2.5 text-left text-2xs text-content-faint transition-colors hover:bg-surface-overlay hover:text-content-secondary",children:[l.jsx(wo,{size:13,className:"shrink-0"}),h?"隐藏已归档":`显示已归档 (${b})`]})]})}const Rk={none:"无",minimal:"极简",low:"低",medium:"中",high:"高",xhigh:"极高"},Lk={read_only:"只读",workspace_write:"工作区写",full_access:"完全访问"};function ai({icon:e,value:t,options:n,render:r,onChange:i,title:s,placeholder:a}){const[o,c]=v.useState(!1),u=v.useRef(null);if(n.length===0)return null;const f=t!==void 0&&n.includes(t),d=f?r(t):a??r(n[0]);return l.jsxs("div",{className:"relative shrink-0",children:[l.jsxs("button",{ref:u,type:"button",onClick:()=>c(p=>!p),title:s,className:"flex cursor-pointer items-center gap-1 rounded-full px-2 py-1 text-2xs font-medium text-content-secondary transition-colors hover:bg-surface-overlay hover:text-content-primary",children:[e,l.jsx("span",{className:"max-w-[7rem] truncate",children:d}),l.jsx(xt,{size:11,className:"text-content-faint"})]}),l.jsx(zn,{open:o,anchorRef:u,placement:"top-start",onClose:()=>c(!1),className:"codex-card-raised overflow-hidden p-1 animate-fade-in",minWidth:128,children:n.map(p=>l.jsxs("button",{type:"button",onClick:()=>{i(p),c(!1)},className:`flex w-full cursor-pointer items-center justify-between gap-3 rounded-lg px-2.5 py-2.5 text-left text-xs transition-colors hover:bg-surface-overlay ${f&&p===t?"text-content-primary":"text-content-secondary"}`,children:[l.jsx("span",{className:"truncate",children:r(p)}),f&&p===t&&l.jsx(Rt,{size:13,className:"shrink-0 text-accent"})]},p))})]})}function Dk({conversation:e,capability:t,flags:n,onChange:r}){var f;const s=((t==null?void 0:t.models)??[]).filter(d=>d.id!=="default"),a=n.effort?(t==null?void 0:t.reasoningEfforts)??[]:[],o=n.permissionMode?(t==null?void 0:t.permissionModes)??[]:[],c=n.plan,u=e.collaborationMode==="plan";return l.jsxs(l.Fragment,{children:[n.model&&s.length>0&&l.jsx(ai,{title:"模型",value:e.model??(t==null?void 0:t.defaultModel)??((f=s[0])==null?void 0:f.id),options:s.map(d=>d.id),render:d=>{var p;return((p=s.find(h=>h.id===d))==null?void 0:p.label)??d},onChange:d=>r({model:d})}),l.jsx(ai,{title:"推理强度",value:e.reasoningEffort,options:a,render:d=>Rk[d]??d,onChange:d=>r({reasoningEffort:d}),placeholder:"默认"}),l.jsx(ai,{title:"权限",value:e.permissionMode,options:o,render:d=>Lk[d]??d,onChange:d=>r({permissionMode:d}),placeholder:"默认"}),c&&l.jsxs("button",{type:"button",onClick:()=>r({collaborationMode:u?"default":"plan"}),className:`inline-flex shrink-0 cursor-pointer items-center gap-1 rounded-full px-2 py-1 text-2xs font-medium transition-colors ${u?"bg-accent-dim text-white":"text-content-secondary hover:bg-surface-overlay hover:text-content-primary"}`,title:"计划模式",children:[u&&l.jsx(Rt,{size:11}),"计划"]})]})}function zk({store:e,initialPath:t,providerLabel:n,onCancel:r,onConfirm:i}){const[s,a]=v.useState(t||"."),[o,c]=v.useState([]),[u,f]=v.useState(!1),[d,p]=v.useState(null),h=v.useCallback(async b=>{f(!0),p(null);try{const w=await e.browse(b,!1);w.error?p(w.error):(a(w.path),c(w.entries.filter(k=>k.isDirectory).sort((k,A)=>k.name.localeCompare(A.name))))}catch(w){p(w.message||"无法读取目录")}finally{f(!1)}},[e]);v.useEffect(()=>{h(t||".")},[h,t]);const m=s.replace(/\/+$/,"").split("/").slice(0,-1).join("/")||"/";return l.jsx("div",{className:"fixed inset-0 z-50 flex items-end justify-center bg-black/60 sm:items-center sm:p-4",onClick:r,children:l.jsxs("div",{className:"codex-card flex max-h-[85dvh] w-full max-w-lg flex-col overflow-hidden rounded-t-2xl sm:rounded-xl",onClick:b=>b.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[l.jsxs("h3",{className:"text-sm font-semibold",children:["选择工作目录 · ",n]}),l.jsx("button",{onClick:r,className:"codex-btn-ghost px-2 py-1.5","aria-label":"取消",children:l.jsx(dt,{size:15})})]}),l.jsxs("div",{className:"flex items-center gap-1 border-b border-border px-3 py-2",children:[l.jsx("button",{onClick:()=>h(m),disabled:u,className:"cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"上级目录","aria-label":"上级目录",children:l.jsx(bo,{size:14})}),l.jsx("input",{value:s,onChange:b=>a(b.target.value),onKeyDown:b=>b.key==="Enter"&&h(s),className:"flex-1 bg-transparent font-mono text-2xs text-content-primary outline-none"}),l.jsx("button",{onClick:()=>h(s),disabled:u,className:"cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"刷新","aria-label":"刷新",children:l.jsx(ko,{size:14})})]}),d&&l.jsx("p",{className:"px-4 py-2 text-2xs text-danger",children:d}),l.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:u?l.jsx("p",{className:"px-4 py-3 text-2xs text-content-muted",children:"加载中…"}):o.length===0?l.jsx("p",{className:"px-4 py-3 text-2xs text-content-faint",children:"(无子目录)"}):o.map(b=>l.jsxs("button",{onClick:()=>h(b.path),className:"flex w-full cursor-pointer items-center gap-2 px-4 py-1.5 text-left transition-colors hover:bg-surface-overlay",children:[l.jsx(Pt,{size:13,className:"shrink-0 text-content-faint"}),l.jsx("span",{className:"truncate font-mono text-2xs text-content-primary",children:b.name})]},b.path))}),l.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] sm:pb-3",children:[l.jsxs("span",{className:"truncate font-mono text-2xs text-content-muted",title:s,children:["将在此创建:",s]}),l.jsx("button",{onClick:()=>i(s),disabled:u,className:"codex-btn-primary text-2xs",children:"在此新建"})]})]})})}const oi=["light","dark","system"],Ga={light:"浅色",dark:"深色",system:"跟随系统"};function eo(){const e=v.useSyncExternalStore(Cc,Is,Is),t=()=>zi(oi[(oi.indexOf(e)+1)%oi.length]),n=e==="light"?Qc:e==="dark"?Kc:Yc;return l.jsx("button",{onClick:t,className:"codex-btn-ghost px-2 py-1.5",title:`主题:${Ga[e]}(点击切换)`,"aria-label":`主题:${Ga[e]}`,children:l.jsx(n,{size:15})})}function Ok(e,t){if(!e)return 0;const n=e.toLowerCase(),r=t.toLowerCase();let i=0,s=0,a=-1;for(let o=0;o<n.length;o++){const c=n[o],u=r.indexOf(c,i);if(u===-1)return null;a>=0?s+=u-a-1:s+=u,a=u,i=u+1}return s}function Fk({open:e,onClose:t,actions:n,placeholder:r="搜索命令、对话…"}){const[i,s]=v.useState(""),[a,o]=v.useState(0),c=v.useRef(null);v.useEffect(()=>{e&&(s(""),o(0),requestAnimationFrame(()=>{var m;return(m=c.current)==null?void 0:m.focus()}))},[e]);const u=v.useMemo(()=>n.map(b=>({a:b,score:Ok(i,`${b.label} ${b.hint??""} ${b.keywords??""}`)})).filter(b=>b.score!==null).sort((b,w)=>b.score-w.score).map(b=>b.a),[n,i]);if(v.useEffect(()=>{o(m=>Math.min(m,Math.max(0,u.length-1)))},[u.length]),!e)return null;const f=m=>{const b=u[m];b&&(t(),b.run())},d=m=>{m.key==="ArrowDown"?(m.preventDefault(),o(b=>Math.min(b+1,u.length-1))):m.key==="ArrowUp"?(m.preventDefault(),o(b=>Math.max(b-1,0))):m.key==="Enter"?(m.preventDefault(),f(a)):m.key==="Escape"&&(m.preventDefault(),t())};let p=-1;const h=new Map;for(const m of u){const b=m.group??"",w=h.get(b)??[];w.push(m),h.set(b,w)}return l.jsx("div",{className:"fixed inset-0 z-[60] flex items-start justify-center bg-canvas/60 px-3 pt-[8vh] backdrop-blur-sm animate-fade-in sm:px-4 sm:pt-[12vh]",onClick:t,children:l.jsxs("div",{className:"codex-card-raised w-full max-w-xl overflow-hidden",onClick:m=>m.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3.5 py-3",children:[l.jsx(Mt,{size:16,className:"shrink-0 text-content-faint"}),l.jsx("input",{ref:c,value:i,onChange:m=>s(m.target.value),onKeyDown:d,placeholder:r,className:"min-w-0 flex-1 bg-transparent text-[15px] text-content-primary placeholder-content-muted outline-none"}),l.jsx("kbd",{className:"hidden shrink-0 rounded border border-border px-1.5 py-0.5 font-mono text-2xs text-content-faint sm:inline",children:"esc"})]}),l.jsx("div",{className:"max-h-[50vh] overflow-y-auto p-1.5",children:u.length===0?l.jsx("p",{className:"px-3 py-6 text-center text-sm text-content-muted",children:"没有匹配项"}):[...h.entries()].map(([m,b])=>l.jsxs("div",{className:"mb-1",children:[m&&l.jsx("p",{className:"px-2.5 pb-1 pt-2 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:m}),b.map(w=>{p+=1;const k=p;return l.jsxs("button",{onMouseEnter:()=>o(k),onClick:()=>f(k),className:`flex w-full cursor-pointer items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors ${k===a?"bg-surface-overlay":"hover:bg-surface-overlay"}`,children:[w.icon&&l.jsx("span",{className:"shrink-0 text-content-muted",children:w.icon}),l.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-content-primary",children:w.label}),w.hint&&l.jsx("span",{className:"shrink-0 text-2xs text-content-faint",children:w.hint})]},w.id)})]},m||"_"))})]})})}const to={pending:"等待中",connecting:"连接中",connected:"已连接",failed:"连接失败",needs_auth:"需要授权",disabled:"已禁用"},$k={pending:"bg-content-faint",connecting:"bg-warning",connected:"bg-success",failed:"bg-danger",needs_auth:"bg-warning",disabled:"bg-content-faint"};function Bk(e){return e.some(t=>t.status==="failed")?"bg-danger":e.some(t=>t.status==="pending"||t.status==="connecting"||t.status==="needs_auth")?"bg-warning":e.every(t=>t.status==="disabled")?"bg-content-faint":"bg-success"}function qk(e,t){return`${e??"unknown"}:${t}`}function no({mcpServers:e,provider:t,authLinks:n,onLogin:r}){const[i,s]=v.useState(!1),a=v.useRef(null);if(!e||e.length===0)return null;const o=e.filter(c=>c.status==="connected").length;return l.jsxs("div",{className:"relative",children:[l.jsxs("button",{ref:a,type:"button",onClick:()=>s(c=>!c),title:`MCP 服务器(${o}/${e.length} 已连接)`,"aria-label":"MCP 服务器状态",className:`flex cursor-pointer items-center gap-1 rounded-md p-1.5 transition-colors ${i?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,children:[l.jsx(vo,{size:16}),l.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${Bk(e)}`})]}),l.jsxs(zn,{open:i,anchorRef:a,placement:"bottom-end",onClose:()=>s(!1),className:"codex-card-raised overflow-hidden p-1 animate-fade-in",minWidth:208,children:[l.jsx("div",{className:"px-2 py-1 text-2xs font-medium uppercase tracking-wide text-content-faint",children:"MCP 服务器"}),e.map(c=>{const u=n==null?void 0:n[qk(t,c.name)];return l.jsxs("div",{className:"flex items-center gap-2 rounded px-2 py-1.5 text-xs",title:c.error??to[c.status],children:[l.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${$k[c.status]}`}),l.jsx("span",{className:"min-w-0 flex-1 truncate text-content-primary",children:c.name}),typeof c.toolCount=="number"&&c.status==="connected"&&l.jsxs("span",{className:"text-2xs text-content-faint",children:[c.toolCount," 个工具"]}),c.status==="needs_auth"&&r&&l.jsx("button",{type:"button",onClick:()=>r(t,c.name),className:"cursor-pointer rounded px-1.5 py-0.5 text-2xs text-accent hover:bg-accent/10",children:"授权"}),u&&l.jsx("a",{href:u,target:"_blank",rel:"noreferrer",className:"text-2xs text-accent hover:underline",children:"打开授权页"}),c.status!=="needs_auth"&&l.jsx("span",{className:"text-2xs text-content-muted",children:to[c.status]})]},c.name)})]})]})}function Vk(e){return e==="connected"?{text:"已连接",color:"text-success"}:e==="connecting"||e==="reconnecting"||e==="claiming"?{text:"连接中",color:"text-warning"}:e==="host_disconnected"?{text:"主机离线",color:"text-warning"}:e.startsWith("error")?{text:"错误",color:"text-danger"}:{text:"未连接",color:"text-content-muted"}}function Uk({children:e}){const[t,n]=v.useState(!1),r=v.useRef(null);return l.jsxs("div",{className:"relative",children:[l.jsx("button",{ref:r,type:"button",onClick:()=>n(i=>!i),className:`cursor-pointer rounded-md p-1.5 transition-colors ${t?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,title:"更多","aria-label":"更多","aria-expanded":t,children:l.jsx(So,{size:16})}),l.jsx(zn,{open:t,anchorRef:r,placement:"bottom-end",onClose:()=>n(!1),className:"codex-card-raised overflow-hidden p-1 animate-fade-in",minWidth:176,children:e(()=>n(!1))})]})}function Wn({icon:e,label:t,active:n,onClick:r}){return l.jsxs("button",{type:"button",onClick:r,className:`flex w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 py-2.5 text-left text-xs transition-colors ${n?"bg-accent-dim/20 text-content-primary":"text-content-secondary hover:bg-surface-overlay hover:text-content-primary"}`,children:[e,t]})}function li(e){switch(e){case"running":return{text:"运行中",className:"border-success/30 bg-success/10 text-success",pulsing:!0};case"waiting_permission":return{text:"等待授权",className:"border-warning/40 bg-warning/10 text-warning",pulsing:!0};case"error":return{text:"异常",className:"border-danger/30 bg-danger/10 text-danger"};case"idle":return{text:"空闲",className:"border-border bg-surface-overlay text-content-muted"};case"unavailable":return{text:"不可用",className:"border-border bg-surface-overlay text-content-faint"};default:return null}}function Kn(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Hk(e){if(!e)return null;const t=e.inputTokens!=null||e.cacheReadTokens!=null?(e.inputTokens??0)+(e.cacheReadTokens??0):null,n=[];let r="";if(t!=null&&e.contextWindow&&e.contextWindow>0){const i=Math.min(100,Math.round(t/e.contextWindow*100));n.push(`${i}%`),r=`上下文 ${Kn(t)} / ${Kn(e.contextWindow)} tokens`}else{const i=e.totalTokens??t??e.outputTokens??null;i!=null&&(n.push(Kn(i)),r=`${i.toLocaleString()} tokens`)}return typeof e.totalCostUsd=="number"&&e.totalCostUsd>0&&(n.push(`$${e.totalCostUsd.toFixed(e.totalCostUsd<1?3:2)}`),r=r?`${r} · $${e.totalCostUsd.toFixed(4)}`:`$${e.totalCostUsd.toFixed(4)}`),n.length===0?null:{text:n.join(" · "),title:r}}function Wk(e){const t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h ${String(r).padStart(2,"0")}m ${String(i).padStart(2,"0")}s`:r>0?`${r}m ${String(i).padStart(2,"0")}s`:`${i}s`}function Zk(e){const[t,n]=v.useState(0),r=v.useRef(null);return v.useEffect(()=>{if(!e){r.current=null,n(0);return}r.current=Date.now(),n(0);const i=setInterval(()=>{r.current!=null&&n(Math.floor((Date.now()-r.current)/1e3))},1e3);return()=>clearInterval(i)},[e]),t}function Qk(e,t,n){const[r,i]=v.useState(()=>({render:e,className:e?t:""})),s=v.useRef(e);v.useEffect(()=>{e&&!s.current?i({render:!0,className:t}):!e&&s.current&&i({render:!0,className:n}),s.current=e},[e,t,n]);const a=v.useCallback(()=>{s.current||i({render:!1,className:""})},[]);return{render:r.render,className:r.className,onAnimationEnd:a}}function Kk(e,t){var i,s,a,o,c,u,f,d;const n=t.toLowerCase();return[e.text,(i=e.commandExecution)==null?void 0:i.command,(s=e.commandExecution)==null?void 0:s.output,(a=e.toolCall)==null?void 0:a.name,(o=e.toolCall)==null?void 0:o.input,(c=e.toolCall)==null?void 0:c.output,(u=e.fileChange)==null?void 0:u.summary,...((d=(f=e.fileChange)==null?void 0:f.entries)==null?void 0:d.map(p=>p.path))??[],e.error].some(p=>typeof p=="string"&&p.toLowerCase().includes(n))}function Yk({sessionId:e,session:t,onBack:n}){var _s,js,Cs;const r=v.useMemo(()=>so(),[]),i=v.useMemo(()=>Oi(),[]),{store:s,snapshot:a}=ih(r,e),o=ic(),[c,u]=v.useState("none"),[f,d]=v.useState(!1),[p,h]=v.useState(!1),[m,b]=v.useState(()=>{const S=Number(localStorage.getItem("linkshell_terminal_h"));return S>=120&&S<=600?S:320}),w=v.useRef(!1),k=v.useRef(m);k.current=m;const A=v.useRef(f);A.current=f;const I=v.useCallback(()=>{A.current?h(!0):d(!0)},[]),Z=v.useCallback(()=>{h(!1),d(!0)},[]),[Q,j]=v.useState(!1),[Y,X]=v.useState(null),[G,_]=v.useState(null),[F,$]=v.useState(!1),[ae,q]=v.useState(null),[O,J]=v.useState({text:"",nonce:0}),[de,Ce]=v.useState(!1),[P,x]=v.useState(""),[z,me]=v.useState(!1),y=v.useRef(null),[Ee,Ie]=v.useState(()=>{const S=Number(localStorage.getItem("linkshell_sidebar_w"));return S>=180&&S<=520?S:256}),[Ne,Le]=v.useState(()=>localStorage.getItem("linkshell_sidebar_collapsed")==="1"),[le,Ke]=v.useState(()=>{const S=Number(localStorage.getItem("linkshell_rightpanel_w"));return S>=320&&S<=1100?S:560}),Oe=v.useRef(!1),Ye=v.useRef(!1),C=v.useRef(null),U=()=>{Le(S=>(localStorage.setItem("linkshell_sidebar_collapsed",S?"0":"1"),!S))},ie=S=>{S.preventDefault(),Oe.current=!0;const E=xe=>{if(!Oe.current)return;const je=Math.min(520,Math.max(180,xe.clientX));Ie(je)},ne=()=>{Oe.current=!1,localStorage.setItem("linkshell_sidebar_w",String(ke.current)),window.removeEventListener("pointermove",E),window.removeEventListener("pointerup",ne)};window.addEventListener("pointermove",E),window.addEventListener("pointerup",ne)},ke=v.useRef(Ee);ke.current=Ee;const Se=v.useRef(le);Se.current=le;const Fe=S=>{S.preventDefault(),Ye.current=!0;const E=xe=>{if(!Ye.current)return;const je=Math.min(1100,Math.max(320,window.innerWidth-xe.clientX));Ke(je)},ne=()=>{Ye.current=!1,localStorage.setItem("linkshell_rightpanel_w",String(Se.current)),window.removeEventListener("pointermove",E),window.removeEventListener("pointerup",ne)};window.addEventListener("pointermove",E),window.addEventListener("pointerup",ne)},Ft=S=>{S.preventDefault(),w.current=!0;const E=S.clientY,ne=k.current,xe=st=>{if(!w.current)return;const Pe=Math.min(600,Math.max(120,ne+(E-st.clientY)));b(Pe)},je=()=>{w.current=!1,localStorage.setItem("linkshell_terminal_h",String(k.current)),window.removeEventListener("pointermove",xe),window.removeEventListener("pointerup",je)};window.addEventListener("pointermove",xe),window.addEventListener("pointerup",je)},se=a.activeConversationId,He=se?a.timelines.get(se)??[]:[],M=a.conversations.find(S=>S.id===se),$t=((_s=a.capabilities)==null?void 0:_s.providers)??[],Ge=M?$t.find(S=>S.id===M.provider):void 0,kt=Zt(a.capabilities,M),Bt=Qi(M),N=(M==null?void 0:M.status)==="running",R=se?a.history.get(se):void 0;lh(a.conversations);const ee=v.useRef(!1);ee.current=N;const fe=v.useRef(s);fe.current=s;const _e=v.useRef(null);_e.current=se??null;const We=v.useRef(!1);We.current=z||F||Q||ae!=null||Y!=null||G!=null;const lt=v.useRef(!1);lt.current=de;const it=v.useMemo(()=>{for(let S=He.length-1;S>=0;S--){const E=He[S];if(E.role==="user"&&E.text)return E.text}},[He]),vt=S=>{J(E=>({text:S,nonce:E.nonce+1}))},At=v.useMemo(()=>{if((M==null?void 0:M.collaborationMode)!=="plan"||N||(M==null?void 0:M.status)==="waiting_permission")return!1;const S=[...He].reverse().find(E=>!Hn(E));return S!=null&&S.role!=="user"},[M==null?void 0:M.collaborationMode,M==null?void 0:M.status,N,He]),$e=()=>{se&&s.sendPrompt({conversationId:se,text:"请按上面的计划开始执行。",collaborationMode:"default",model:M==null?void 0:M.model,reasoningEffort:M==null?void 0:M.reasoningEffort,permissionMode:M==null?void 0:M.permissionMode})};v.useEffect(()=>{const S=E=>{const ne=E.metaKey||E.ctrlKey;ne&&E.shiftKey&&E.key.toLowerCase()==="p"?(E.preventDefault(),me(xe=>!xe)):ne&&!E.shiftKey&&E.key.toLowerCase()==="k"?(E.preventDefault(),me(xe=>!xe)):ne&&!E.shiftKey&&E.key.toLowerCase()==="j"?(E.preventDefault(),I()):ne&&!E.shiftKey&&E.key.toLowerCase()==="f"?(E.preventDefault(),Ce(!0),requestAnimationFrame(()=>{var xe;return(xe=y.current)==null?void 0:xe.focus()})):E.key==="Escape"&&(lt.current?Ce(!1):ee.current&&_e.current&&!We.current&&fe.current.cancel(_e.current))};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[]),v.useEffect(()=>{Ce(!1),x("")},[se]);const et=v.useRef(0),Be=v.useRef(!0),ms=v.useRef(null),[ac,Er]=v.useState(!0),[oc,On]=v.useState(!1),lc=()=>{const S=C.current;if(!S)return;const E=S.scrollHeight-S.scrollTop-S.clientHeight<80;Be.current=E,Er(E),E&&On(!1),S.scrollTop<60&&se&&(R!=null&&R.hasMore)&&!R.loading&&(et.current=S.scrollHeight,s.loadOlderHistory(se))},cc=v.useCallback(()=>{const S=C.current;S&&(Be.current=!0,Er(!0),On(!1),S.scrollTop=S.scrollHeight)},[]);v.useEffect(()=>{const S=ms.current,E=C.current;if(!S||!E)return;let ne=S.getBoundingClientRect().height;const xe=new ResizeObserver(()=>{const je=S.getBoundingClientRect().height,st=je>ne;ne=je,Be.current?E.scrollTop=E.scrollHeight:st&&!et.current&&On(!0)});return xe.observe(S),()=>xe.disconnect()},[se]);const gs=v.useRef(void 0);v.useLayoutEffect(()=>{const S=C.current;if(S){if(gs.current!==se){gs.current=se,Be.current=!0,Er(!0),On(!1),S.scrollTop=S.scrollHeight;return}et.current>0?(S.scrollTop=S.scrollHeight-et.current,et.current=0):Be.current&&(S.scrollTop=S.scrollHeight)}},[He.length,se]);const Pr=(S,E)=>{E?xs(S,E):q(S)},xs=(S,E)=>{const ne=$t.find(je=>je.id===S),xe=s.openConversation({provider:S,cwd:E,model:ne==null?void 0:ne.defaultModel});s.setActiveConversation(xe),q(null)},uc=(S,E)=>{se&&(sh(),s.sendPrompt({conversationId:se,text:S,images:E.map(ne=>({data:ne.data,mimeType:ne.mimeType})),model:M==null?void 0:M.model,reasoningEffort:M==null?void 0:M.reasoningEffort,permissionMode:M==null?void 0:M.permissionMode,collaborationMode:M==null?void 0:M.collaborationMode}))},ys=Vk(a.status),Mr=(M==null?void 0:M.status)==="running"||(M==null?void 0:M.status)==="waiting_permission"||(M==null?void 0:M.status)==="error",qt=!Mr&&(a.externalAgentStatus==="running"||a.externalAgentStatus==="waiting_permission"||a.externalAgentStatus==="error"),Fn=li(Mr?M==null?void 0:M.status:qt?a.externalAgentStatus??void 0:M==null?void 0:M.status),Rr=Mr?M==null?void 0:M.provider:qt?a.externalAgentTitle??"外部终端":M==null?void 0:M.provider,bs=qt?a.externalAgentStatus==="running":(M==null?void 0:M.status)==="running",dc=Zk(bs),Lr=qt?null:Hk(M==null?void 0:M.usage),ks=`CLI 设备 · ${e.slice(0,8)}`,vs=M==null?void 0:M.cwd,ws=v.useCallback(()=>{s.client.spawnTerminal(vs||".")},[s,vs]),Ss=$t.filter(S=>S.enabled),fc=v.useMemo(()=>{const S=[];for(const E of Ss)S.push({id:`new-${E.id}`,label:`新建 ${E.label} 对话`,group:"新建",keywords:`new conversation ${E.id}`,icon:l.jsx(_n,{size:15}),run:()=>Pr(E.id)});for(const E of a.conversations.filter(ne=>!ne.archived)){const ne=E.title&&E.title.trim()||E.lastMessagePreview&&E.lastMessagePreview.trim().slice(0,40)||`对话 ${E.id.slice(-6)}`;S.push({id:`conv-${E.id}`,label:ne,group:"对话",hint:E.cwd?E.cwd.split("/").slice(-1)[0]:void 0,keywords:`${E.provider} ${E.cwd??""}`,icon:l.jsx(Xt,{provider:E.provider,size:15}),run:()=>s.setActiveConversation(E.id)})}return se&&N&&kt.cancel&&S.push({id:"cancel",label:"停止当前回合",group:"操作",keywords:"cancel stop interrupt",icon:l.jsx(yo,{size:15}),run:()=>s.cancel(se)}),se&&S.push({id:"search",label:"在对话中搜索",group:"操作",hint:"⌘F",keywords:"search find filter",icon:l.jsx(Mt,{size:15}),run:()=>{Ce(!0),requestAnimationFrame(()=>{var E;return(E=y.current)==null?void 0:E.focus()})}}),S.push({id:"panel-terminal",label:"切换终端",group:"操作",hint:"⌘J",keywords:"terminal shell",icon:l.jsx(zr,{size:15}),run:I},{id:"panel-files",label:"打开文件浏览器",group:"操作",keywords:"files browse",icon:l.jsx(Pt,{size:15}),run:()=>u(E=>E==="files"?"none":"files")},{id:"panel-preview",label:"打开端口预览",group:"操作",keywords:"preview port browser localhost tunnel",icon:l.jsx(Zn,{size:15}),run:()=>u(E=>E==="preview"?"none":"preview")}),S},[Ss,a.conversations,se,N,kt.cancel]);return l.jsxs("div",{className:"flex h-[100dvh] flex-col overflow-hidden",children:[l.jsxs("header",{className:"flex items-center justify-between gap-2 overflow-visible border-b border-border px-3 py-1.5 md:px-4 md:py-2",style:{paddingTop:"max(0.375rem, env(safe-area-inset-top))"},children:[l.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[o&&l.jsx("button",{onClick:()=>j(!0),className:"codex-btn-ghost shrink-0 px-2 py-1.5","aria-label":"打开会话列表",children:l.jsx(Zc,{size:17})}),l.jsx("button",{onClick:n,className:"codex-btn-ghost shrink-0 px-2 py-1.5 text-2xs","aria-label":"返回会话列表",children:o?l.jsx(Ps,{size:17}):"← 会话"}),l.jsxs("span",{className:`flex shrink-0 items-center gap-1 text-2xs ${ys.color}`,children:[l.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),!o&&ys.text]}),Fn&&!(o&&!qt&&(M==null?void 0:M.status)==="idle")&&l.jsxs("span",{className:`inline-flex min-w-0 items-center gap-1 rounded-full border px-2 py-0.5 text-2xs font-medium ${Fn.className}`,title:qt?"外部终端状态":"当前对话状态",children:[Fn.pulsing&&l.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-current animate-pulse-dot"}),!o&&Rr&&l.jsx("span",{className:"min-w-0 truncate",children:Rr}),l.jsxs("span",{className:"shrink-0",children:[!o&&Rr?"· ":"",Fn.text]}),bs&&l.jsx("span",{className:"shrink-0 font-mono tabular-nums opacity-70",children:Wk(dc)})]}),Lr&&!o&&l.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full border border-border bg-surface-overlay px-2 py-0.5 font-mono text-2xs tabular-nums text-content-muted",title:Lr.title,children:Lr.text}),((js=a.usage)==null?void 0:js.totals)&&!o&&l.jsxs("span",{className:"inline-flex shrink-0 items-center gap-0.5 rounded-full border border-border bg-surface-overlay px-2 py-0.5 font-mono text-2xs tabular-nums text-content-muted",title:"全机用量",children:[l.jsx(Or,{size:12}),Kn(a.usage.totals.totalTokens)]}),a.lastError&&l.jsx("button",{onClick:()=>s.dismissError(),className:"min-w-0 truncate rounded-full border border-danger/30 bg-danger/10 px-2 py-0.5 text-2xs text-danger",title:`${a.lastError.message}(点击关闭)`,children:a.lastError.code})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[l.jsx("button",{onClick:()=>{se&&(Ce(!0),requestAnimationFrame(()=>{var S;return(S=y.current)==null?void 0:S.focus()}))},disabled:!se,className:"codex-btn-ghost px-2 py-1.5 disabled:opacity-40",title:"在对话中搜索 (⌘/Ctrl+F)","aria-label":"在对话中搜索",children:l.jsx(Mt,{size:16})}),o?l.jsxs(l.Fragment,{children:[l.jsx(no,{mcpServers:Ge==null?void 0:Ge.mcpServers,provider:M==null?void 0:M.provider,authLinks:a.mcpAuthLinks,onLogin:(S,E)=>s.startMcpLogin(S,E)}),l.jsx(Uk,{children:S=>l.jsxs(l.Fragment,{children:[!i&&l.jsxs("div",{className:"flex items-center justify-between rounded-lg px-2.5 py-1.5",children:[l.jsx("span",{className:"text-xs text-content-secondary",children:"主题"}),l.jsx(eo,{})]}),l.jsx(Wn,{icon:l.jsx(Pt,{size:15}),label:"文件",active:c==="files",onClick:()=>{u(E=>E==="files"?"none":"files"),S()}}),l.jsx(Wn,{icon:l.jsx(zr,{size:15}),label:"终端",active:f,onClick:()=>{I(),S()}}),l.jsx(Wn,{icon:l.jsx(Zn,{size:15}),label:"端口预览",active:c==="preview",onClick:()=>{u(E=>E==="preview"?"none":"preview"),S()}}),l.jsx(Wn,{icon:l.jsx(Or,{size:15}),label:"用量统计",active:F,onClick:()=>{s.requestUsage(),$(!0),S()}})]})})]}):l.jsxs(l.Fragment,{children:[!i&&l.jsx(eo,{}),l.jsx("button",{onClick:()=>u(S=>S==="preview"?"none":"preview"),className:`cursor-pointer rounded-md p-1.5 transition-colors ${c==="preview"?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,title:"端口预览","aria-label":"端口预览",children:l.jsx(Zn,{size:16})}),l.jsx("button",{onClick:()=>u(S=>S==="files"?"none":"files"),className:`cursor-pointer rounded-md p-1.5 transition-colors ${c==="files"?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,title:"文件","aria-label":"文件",children:l.jsx(Pt,{size:16})}),l.jsx("button",{onClick:I,className:`cursor-pointer rounded-md p-1.5 transition-colors ${f?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,title:"终端 (⌘J)","aria-label":"终端",children:l.jsx(zr,{size:16})}),l.jsx("button",{onClick:()=>{s.requestUsage(),$(!0)},className:`cursor-pointer rounded-md p-1.5 transition-colors ${F?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,title:"用量统计","aria-label":"用量统计",children:l.jsx(Or,{size:16})}),l.jsx(no,{mcpServers:Ge==null?void 0:Ge.mcpServers,provider:M==null?void 0:M.provider,authLinks:a.mcpAuthLinks,onLogin:(S,E)=>s.startMcpLogin(S,E)})]})]})]}),l.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[a.status==="host_disconnected"&&l.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center bg-canvas/80 backdrop-blur-sm",children:l.jsxs("div",{className:"codex-card-raised mx-4 flex max-w-sm flex-col items-center gap-3 px-6 py-8 text-center animate-fade-in",children:[l.jsx("span",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-warning/15 text-warning",children:l.jsx(vo,{size:24})}),l.jsx("h2",{className:"text-base font-semibold text-content-primary",children:"主机已离线"}),l.jsxs("p",{className:"text-sm leading-relaxed text-content-muted",children:["与该会话的主机连接已断开。请确认主机上的"," ",l.jsx("code",{className:"font-mono text-accent",children:"linkshell"})," 仍在运行。正在自动尝试重新连接…"]}),l.jsx("button",{onClick:n,className:"codex-btn-outline mt-1 text-2xs",children:"返回会话列表"})]})}),o?Q&&l.jsxs("div",{className:"absolute inset-0 z-30 flex animate-fade-in",children:[l.jsxs("aside",{className:"flex w-[82%] max-w-xs flex-col border-r border-border bg-surface shadow-2xl animate-drawer-in",children:[l.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[l.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"会话"}),l.jsx("button",{type:"button",onClick:()=>j(!1),className:"codex-btn-ghost px-2 py-1","aria-label":"关闭会话列表",children:l.jsx(dt,{size:15})})]}),l.jsx("div",{className:"min-h-0 flex-1",children:l.jsx(Ja,{deviceLabel:ks,conversations:a.conversations,capabilities:a.capabilities,activeConversationId:se,externalAgentStatus:a.externalAgentStatus,externalAgentTitle:a.externalAgentTitle,externalAgentProvider:a.externalAgentProvider,store:s,onSelect:S=>{s.setActiveConversation(S),j(!1)},onNewConversation:(S,E)=>{j(!1),Pr(S,E)},onOpenExternalTerminal:()=>{var E;const S=a.externalAgentConversationId||((E=a.conversations.find(ne=>ne.status==="running"||ne.status==="waiting_permission"))==null?void 0:E.id);S?(s.setActiveConversation(S),j(!1)):(j(!1),Z())}})})]}),l.jsx("button",{className:"flex-1 bg-canvas/60 backdrop-blur-sm",onClick:()=>j(!1),"aria-label":"关闭"})]}):Ne?l.jsx("div",{className:"flex w-9 shrink-0 flex-col items-center border-r border-border bg-surface py-2",children:l.jsx("button",{onClick:U,className:"cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-content-primary",title:"展开侧边栏","aria-label":"展开侧边栏",children:l.jsx(nt,{size:16})})}):l.jsxs("aside",{className:"relative flex shrink-0 flex-col border-r border-border bg-surface",style:{width:Ee},children:[l.jsxs("div",{className:"flex items-center justify-between border-b border-border px-2 py-1",children:[l.jsx("span",{className:"pl-1 text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"会话"}),l.jsx("button",{onClick:U,className:"cursor-pointer rounded-md p-1 text-content-muted transition-colors hover:bg-surface-overlay hover:text-content-primary",title:"收起侧边栏","aria-label":"收起侧边栏",children:l.jsx(Ps,{size:15})})]}),l.jsx("div",{className:"min-h-0 flex-1",children:l.jsx(Ja,{deviceLabel:ks,conversations:a.conversations,capabilities:a.capabilities,activeConversationId:se,externalAgentStatus:a.externalAgentStatus,externalAgentTitle:a.externalAgentTitle,externalAgentProvider:a.externalAgentProvider,store:s,onSelect:S=>s.setActiveConversation(S),onNewConversation:Pr,onOpenExternalTerminal:()=>{var E;const S=a.externalAgentConversationId||((E=a.conversations.find(ne=>ne.status==="running"||ne.status==="waiting_permission"))==null?void 0:E.id);S?s.setActiveConversation(S):Z()}})}),l.jsx("div",{onPointerDown:ie,className:"absolute right-0 top-0 h-full w-1 cursor-col-resize bg-transparent transition-colors hover:bg-accent-dim/50",title:"拖动调整宽度"})]}),l.jsx("main",{className:"flex min-w-0 flex-1 flex-col",children:!se||!M?l.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[l.jsx(Ui,{size:44,className:"opacity-40"}),l.jsx("p",{className:"text-[15px] leading-7 text-content-muted",children:o?"点击左上角菜单选择对话,或新建一个开始":"从左侧选择一个对话,或新建一个开始"})]}):l.jsxs(l.Fragment,{children:[de&&l.jsxs("div",{className:"flex items-center gap-2 border-b border-border bg-surface px-4 py-2",children:[l.jsx(Mt,{size:15,className:"shrink-0 text-content-faint"}),l.jsx("input",{ref:y,value:P,onChange:S=>x(S.target.value),onKeyDown:S=>S.key==="Escape"&&(Ce(!1),x("")),placeholder:"在此对话中搜索…",className:"min-w-0 flex-1 bg-transparent text-sm text-content-primary placeholder-content-muted outline-none"}),l.jsx("button",{onClick:()=>{Ce(!1),x("")},className:"codex-btn-ghost px-2 py-1","aria-label":"关闭搜索",children:l.jsx(dt,{size:14})})]}),l.jsx("div",{ref:C,onScroll:lc,className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-3 py-5 md:px-4 md:py-8",children:l.jsxs("div",{ref:ms,className:"mx-auto flex w-full min-w-0 max-w-3xl flex-col gap-6",children:[(R==null?void 0:R.loading)&&l.jsx("p",{className:"text-center text-2xs text-content-muted",children:"加载更早的消息…"}),(R==null?void 0:R.syncing)&&He.length>0&&l.jsx("div",{className:"flex justify-center",children:l.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-border bg-surface-overlay px-2 py-0.5 text-2xs text-content-muted",children:[l.jsx("span",{className:"h-2.5 w-2.5 animate-spin rounded-full border border-content-faint border-t-accent"}),"正在同步…"]})}),de&&P.trim()?(()=>{const S=P.trim(),E=He.filter(ne=>!Hn(ne)&&Kk(ne,S));return E.length===0?l.jsxs("p",{className:"py-12 text-center text-sm text-content-muted",children:["没有匹配「",S,"」的消息"]}):l.jsxs(l.Fragment,{children:[l.jsxs("p",{className:"text-center text-2xs text-content-faint",children:[E.length," 条匹配"]}),E.map(ne=>l.jsx("div",{className:"min-w-0 animate-fade-in",children:l.jsx(Za,{item:ne,canSteer:!1,onPermission:(xe,je,st)=>s.respondPermission(se,xe,je,st),onStructuredInput:(xe,je)=>s.respondStructuredInput(se,xe,je),onOpenDiff:xe=>{X(xe),u("none")},onOpenAgent:xe=>{_(xe),X(null),u("none")},onEditMessage:vt,highlightQuery:S})},ne.id))]})})():(()=>{const S=[];let E=[];const ne=()=>{E.length&&(S.push({k:"group",key:`grp-${E[0].id}`,items:E}),E=[])};for(const je of He)Hn(je)||(dk(je)?E.push(je):(ne(),S.push({k:"item",item:je})));ne();let xe=-1;return S.forEach((je,st)=>{je.k==="group"&&(xe=st)}),S.map((je,st)=>je.k==="item"?l.jsx("div",{className:"min-w-0 animate-fade-in",children:l.jsx(Za,{item:je.item,canSteer:Bt&&M.provider==="codex"&&N,onPermission:(Pe,Dr,hc)=>s.respondPermission(se,Pe,Dr,hc),onStructuredInput:(Pe,Dr)=>s.respondStructuredInput(se,Pe,Dr),onSendQueued:Pe=>s.sendQueuedFollowUp(se,Pe,"new_turn"),onSteerQueued:Pe=>s.sendQueuedFollowUp(se,Pe,"steer"),onDiscardQueued:Pe=>s.discardQueuedFollowUp(se,Pe),onOpenDiff:Pe=>{X(Pe),u("none")},onOpenAgent:Pe=>{_(Pe),X(null),u("none")},onEditMessage:vt,onFork:kt.fork?Pe=>s.forkConversation(se,Pe):void 0})},je.item.id):l.jsx("div",{className:"min-w-0 animate-fade-in",children:l.jsx(pk,{items:je.items,live:N&&st===xe,onOpenDiff:Pe=>{X(Pe),u("none")},onOpenAgent:Pe=>{_(Pe),X(null),u("none")}})},je.key))})(),He.length===0&&(R!=null&&R.loading?l.jsxs("div",{className:"flex flex-col items-center gap-2 py-16 text-content-muted",children:[l.jsx("span",{className:"h-5 w-5 animate-spin rounded-full border-2 border-content-faint border-t-accent"}),l.jsx("p",{className:"text-sm",children:"加载对话记录…"})]}):Bt?l.jsx("p",{className:"py-12 text-center text-sm text-content-muted",children:"发送第一条指令…"}):l.jsx("p",{className:"py-12 text-center text-sm text-content-muted",children:"这场会话在本机终端里。Web 只旁观同一份记录;没有可导入的 transcript 时这里是空的。"}))]})}),!ac&&l.jsx("div",{className:"pointer-events-none relative z-10 h-0",children:l.jsxs("button",{onClick:cc,className:"codex-card-raised pointer-events-auto absolute bottom-2 right-3 flex cursor-pointer items-center gap-1.5 rounded-full px-3 py-1.5 text-2xs text-content-secondary transition-colors animate-fade-in hover:text-content-primary md:right-4","aria-label":"回到底部",title:"回到底部",children:[oc&&l.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-accent"}),l.jsx(xt,{size:14}),"回到底部"]})}),l.jsxs("div",{className:"mx-auto w-full min-w-0 max-w-3xl px-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] md:px-4 md:pb-4",children:[!Bt&&l.jsxs("div",{className:"mb-2 rounded-xl border border-border bg-surface px-3.5 py-2.5 text-sm text-content-secondary",children:["只读旁观 · 这场会话在本机 ",M.provider==="codex"?"Codex":"终端"," 里运行。停止和插话请在那边操作;Web 只同步同一份记录。"]}),At&&l.jsxs("div",{className:"mb-2 flex items-center gap-3 rounded-xl border border-accent-dim/40 bg-surface px-3.5 py-2.5 animate-slide-in",children:[l.jsx("span",{className:"min-w-0 flex-1 text-sm text-content-secondary",children:"计划已就绪。执行它,或在下方继续补充。"}),l.jsx("button",{onClick:$e,className:"codex-btn-primary shrink-0 text-xs",children:"执行计划"})]}),l.jsx(fk,{items:He.filter(Hn),canSteer:M.provider==="codex"&&N,onSend:S=>s.sendQueuedFollowUp(se,S,"new_turn"),onSteer:S=>s.sendQueuedFollowUp(se,S,"steer"),onDiscard:S=>s.discardQueuedFollowUp(se,S)}),l.jsx(gk,{disabled:a.status!=="connected"||!Bt,running:N,supportsImages:kt.images,commands:Ge==null?void 0:Ge.commands,conversationId:se,lastUserText:it,cwd:M.cwd,onBrowse:S=>s.browse(S,!0),seedText:O,controls:l.jsx(Dk,{conversation:M,capability:Ge,flags:kt,onChange:S=>s.updateConversationSettings(se,S)}),onSend:uc,onCancel:kt.cancel?()=>s.cancel(se):void 0,onExecuteCommand:(S,E)=>s.executeCommand(se,S,E)})]}),!o&&(f||p)&&l.jsxs("div",{className:`relative shrink-0 overflow-hidden border-t border-border bg-surface ${p?"animate-panel-out-down":"animate-panel-in-up"}`,style:{height:m},onAnimationEnd:()=>{p&&(h(!1),d(!1))},children:[l.jsx("div",{onPointerDown:Ft,className:"absolute left-0 right-0 top-0 z-10 h-1 cursor-row-resize bg-transparent transition-colors hover:bg-accent-dim/50",title:"拖动调整终端高度"}),l.jsx(Ka,{bridge:s.client,onNewTerminal:ws})]})]})}),(()=>{let S=null;G?S=l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[l.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"子 Agent"}),l.jsx("button",{onClick:()=>_(null),className:"codex-btn-ghost px-2 py-1.5","aria-label":"关闭",children:l.jsx(dt,{size:15})})]}),l.jsx("div",{className:"min-h-0 flex-1",children:l.jsx(ck,{detail:G})})]}):Y?S=l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[l.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"文件差异"}),l.jsx("button",{onClick:()=>X(null),className:"codex-btn-ghost px-2 py-1.5","aria-label":"关闭差异",children:l.jsx(dt,{size:15})})]}),l.jsx("div",{className:"min-h-0 flex-1",children:l.jsx(Yb,{item:Y})})]}):c==="files"?S=l.jsx(Ck,{store:s,initialPath:(M==null?void 0:M.cwd)||".",onClose:()=>u("none")}):c==="preview"&&(S=l.jsx(jk,{gatewayUrl:r.httpUrl,sessionId:e,initialAuthToken:(t==null?void 0:t.accessToken)??null,isMobile:o,onClose:()=>u("none"),onAnnotate:st=>{J(Pe=>({text:st,nonce:Pe.nonce+1})),o&&u("none")}}));const E=v.useRef(null);S!==null&&(E.current=S);const ne=S!==null,xe=Qk(ne,"animate-panel-in-right","animate-panel-out-right");if(!xe.render&&!ne)return null;const je=ne?S:E.current;return o?l.jsx("aside",{className:`absolute inset-0 z-30 flex flex-col bg-canvas ${xe.className||"animate-fade-in"}`,onAnimationEnd:xe.onAnimationEnd,children:je}):l.jsxs("aside",{className:`relative flex shrink-0 flex-col border-l border-border ${xe.className}`,style:{width:le},onAnimationEnd:xe.onAnimationEnd,children:[l.jsx("div",{onPointerDown:Fe,className:"absolute left-0 top-0 z-10 h-full w-1 cursor-col-resize bg-transparent transition-colors hover:bg-accent-dim/50",title:"拖动调整宽度"}),je]})})(),o&&(f||p)&&l.jsxs("aside",{className:`absolute inset-0 z-30 flex flex-col bg-canvas ${p?"animate-panel-out-right":"animate-fade-in"}`,onAnimationEnd:()=>{p&&(h(!1),d(!1))},children:[l.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[l.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"终端"}),l.jsx("button",{type:"button",onClick:I,className:"codex-btn-ghost px-2 py-1.5","aria-label":"关闭终端",children:l.jsx(dt,{size:15})})]}),l.jsx("div",{className:"min-h-0 flex-1",children:l.jsx(Ka,{bridge:s.client,onNewTerminal:ws})})]}),a.notices.length>0&&l.jsx("div",{className:`pointer-events-none z-40 flex flex-col gap-2 ${o?"absolute left-3 right-3 top-2":"fixed right-4 top-16 w-80"}`,children:a.notices.map(S=>l.jsxs("button",{onClick:()=>s.dismissNotice(S.id),className:`codex-card-raised pointer-events-auto animate-fade-in cursor-pointer px-3 py-2 text-left ${S.kind==="warning"?"border-warning/40":""}`,children:[l.jsxs("p",{className:"flex items-center gap-1.5 text-xs font-medium text-content-primary",children:[l.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${S.kind==="warning"?"bg-warning":"bg-accent"}`}),S.title]}),S.detail&&l.jsx("p",{className:"mt-0.5 pl-3 text-2xs text-content-muted",children:S.detail})]},S.id))})]}),ae&&l.jsx(zk,{store:s,initialPath:(M==null?void 0:M.cwd)||".",providerLabel:((Cs=$t.find(S=>S.id===ae))==null?void 0:Cs.label)??ae,onCancel:()=>q(null),onConfirm:S=>xs(ae,S)}),l.jsx(Fk,{open:z,onClose:()=>me(!1),actions:fc}),F&&l.jsx(_k,{report:a.usage,onClose:()=>$(!1)})]})}Nc();function Xk(){const[e,t]=v.useState(null),[n,r]=v.useState(!1),[i,s]=v.useState(!1),a=v.useMemo(()=>Dc(Lc()),[]),o=v.useMemo(()=>Oi(),[]),[c,u]=v.useState(()=>a??Ic()),f=d=>{u(d),Ts(d)};return v.useEffect(()=>{const d=mr();d&&t(d),r(!0),d&&xo().then(p=>{p&&t(p)})},[]),v.useEffect(()=>{var d;o&&((d=document.querySelector('meta[name="viewport"]'))==null||d.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"))},[o]),v.useEffect(()=>{if(!o)return;const d=window;return d.__linkshellSetTheme=p=>{(p==="dark"||p==="light")&&zi(p)},()=>{delete d.__linkshellSetTheme}},[o]),v.useEffect(()=>Fc(()=>{t(null),s(!1),u(d=>d.name==="list"?d:{name:"list"}),Ts({name:"list"})}),[]),n?i?l.jsx(eu,{onLogin:d=>{t(d),s(!1)},onCancel:()=>s(!1)}):c.name==="console"?l.jsx(Yk,{sessionId:c.sessionId,session:e,onBack:o?po:()=>f({name:"list"})}):l.jsx(Hf,{session:e,onLogin:()=>s(!0),onLogout:()=>{t(null),f({name:"list"})},onOpenSession:d=>f({name:"console",sessionId:d})}):null}mc.createRoot(document.getElementById("root")).render(l.jsx(Oc,{children:l.jsx(Xk,{})}));export{zr as I,dt as a,_n as b,nv as c,Yc as d,vc as e,tv as f,xo as g,ko as h,ev as i,Zn as j,Pt as k,bo as l,Sn as m};