opencami 1.4.0 → 1.5.1

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.
Files changed (112) hide show
  1. package/README.md +60 -0
  2. package/dist/client/assets/CSPContext-BBLAL_m_.js +1 -0
  3. package/dist/client/assets/DirectionContext-DXnZc0zz.js +1 -0
  4. package/dist/client/assets/_sessionKey-BidmO1-D.js +100 -0
  5. package/dist/client/assets/agents-CtZs_u1j.js +2 -0
  6. package/dist/client/assets/agents-screen-Basce5qo.js +1 -0
  7. package/dist/client/assets/bots-C_dWjy3z.js +2 -0
  8. package/dist/client/assets/bots-screen-n_xhYOEE.js +1 -0
  9. package/dist/client/assets/button-BaHefIXU.js +1 -0
  10. package/dist/client/assets/c-BIGW1oBm.js +1 -0
  11. package/dist/client/assets/{connect-D3baVDFL.js → connect-DHr3hhUR.js} +1 -1
  12. package/dist/client/assets/core-BrHBc0Zp.js +12 -0
  13. package/dist/client/assets/cpp-B-lmv-kZ.js +1 -0
  14. package/dist/client/assets/csharp-K5feNrxe.js +1 -0
  15. package/dist/client/assets/css-DPfMkruS.js +1 -0
  16. package/dist/client/assets/diff-D97Zzqfu.js +1 -0
  17. package/dist/client/assets/dockerfile-BcOcwvcX.js +1 -0
  18. package/dist/client/assets/engine-javascript-PwbX1GN8.js +141 -0
  19. package/dist/client/assets/file-explorer-screen-8t6M4Xco.js +1 -0
  20. package/dist/client/assets/files-BdlpK3Cy.js +2 -0
  21. package/dist/client/assets/go-Dn2_MT6a.js +1 -0
  22. package/dist/client/assets/graphql-ChdNCCLP.js +1 -0
  23. package/dist/client/assets/html-GMplVEZG.js +1 -0
  24. package/dist/client/assets/index-B2iG4EM1.js +3 -0
  25. package/dist/client/assets/{index-ByIsZcHh.js → index-GTR-Xzl2.js} +1 -1
  26. package/dist/client/assets/index-T4TOjvD0.js +1 -0
  27. package/dist/client/assets/java-CylS5w8V.js +1 -0
  28. package/dist/client/assets/javascript-wDzz0qaB.js +1 -0
  29. package/dist/client/assets/json-Cp-IABpG.js +1 -0
  30. package/dist/client/assets/jsx-g9-lgVsj.js +1 -0
  31. package/dist/client/assets/keyboard-shortcuts-dialog-CcKSlK52.js +1 -0
  32. package/dist/client/assets/kotlin-BdnUsdx6.js +1 -0
  33. package/dist/client/assets/{main-CkIF0soY.js → main-mIHr_ble.js} +129 -17
  34. package/dist/client/assets/markdown-Cvjx9yec.js +1 -0
  35. package/dist/client/assets/{opencami-logo-CIxSO1oo.js → opencami-logo-CRIdKbbZ.js} +1 -1
  36. package/dist/client/assets/php-CDn_0X-4.js +1 -0
  37. package/dist/client/assets/python-B6aJPvgy.js +1 -0
  38. package/dist/client/assets/react-Cfq4ot0g.js +1 -0
  39. package/dist/client/assets/regexp-CDVJQ6XC.js +1 -0
  40. package/dist/client/assets/ruby-FDmvQDUv.js +1 -0
  41. package/dist/client/assets/rust-B1yitclQ.js +1 -0
  42. package/dist/client/assets/search-dialog-D19x_xaG.js +1 -0
  43. package/dist/client/assets/session-export-dialog-DRlJwhMa.js +1 -0
  44. package/dist/client/assets/settings-dialog-BA5FjiyP.js +1 -0
  45. package/dist/client/assets/shell-DfDnw5Jg.js +1 -0
  46. package/dist/client/assets/skills-lmNPZksG.js +2 -0
  47. package/dist/client/assets/skills-panel-Cv-N_MDk.js +5 -0
  48. package/dist/client/assets/sql-BLtJtn59.js +1 -0
  49. package/dist/client/assets/styles-JgjN_ZCd.css +1 -0
  50. package/dist/client/assets/swift-Dg5xB15N.js +1 -0
  51. package/dist/client/assets/switch-Bh9tVOYh.js +1 -0
  52. package/dist/client/assets/tabs-BfaEc9zS.js +1 -0
  53. package/dist/client/assets/toml-vGWfd6FD.js +1 -0
  54. package/dist/client/assets/tooltip-w9D-e_R-.js +1 -0
  55. package/dist/client/assets/tsx-COt5Ahok.js +1 -0
  56. package/dist/client/assets/typescript-BPQ3VLAy.js +1 -0
  57. package/dist/client/assets/use-file-explorer-state-CLaDuI9X.js +12 -0
  58. package/dist/client/assets/useButton-DsMdJPGn.js +1 -0
  59. package/dist/client/assets/useCompositeItem-CaYygSfB.js +1 -0
  60. package/dist/client/assets/{useControlled-Y306krcC.js → useControlled-wOKVgKF4.js} +1 -1
  61. package/dist/client/assets/{useMutation-0WgW4xQJ.js → useMutation-fJnleJAb.js} +1 -1
  62. package/dist/client/assets/visuallyHidden-CqGRL_Oq.js +9 -0
  63. package/dist/client/assets/vitesse-dark-D0r3Knsf.js +1 -0
  64. package/dist/client/assets/vitesse-light-CVO1_9PV.js +1 -0
  65. package/dist/client/assets/xml-sdJ4AIDG.js +1 -0
  66. package/dist/client/assets/yaml-Buea-lGh.js +1 -0
  67. package/dist/server/assets/{_sessionKey-BhFH4uWY.js → _sessionKey-B5UHBd2U.js} +190 -54
  68. package/dist/server/assets/_tanstack-start-manifest_v-D11xMFUx.js +4 -0
  69. package/dist/server/assets/{agents-Dz_i76VW.js → agents-CmQ4vvXm.js} +1 -1
  70. package/dist/server/assets/{agents-screen-CqQPJndp.js → agents-screen-bmrIyFbk.js} +43 -35
  71. package/dist/server/assets/{bots-6ryCIgKh.js → bots-Byt6jv0a.js} +1 -1
  72. package/dist/server/assets/bots-screen-C2TGFv42.js +474 -0
  73. package/dist/server/assets/{button-DtQ3rV1m.js → button-CwY2OHFj.js} +2 -2
  74. package/dist/server/assets/{connect-B8jpGQGK.js → connect-CbgijWz4.js} +2 -35
  75. package/dist/server/assets/{file-explorer-screen-DCfS_Ajx.js → file-explorer-screen-CVlFiAFu.js} +36 -36
  76. package/dist/server/assets/{files-D2GIrPF4.js → files-BIEcSPGp.js} +1 -1
  77. package/dist/server/assets/{index-B2JHn34C.js → index--_jH_0mX.js} +2 -1
  78. package/dist/server/assets/{index-BNSsDaLb.js → index-Dl2BOKP7.js} +116 -82
  79. package/dist/server/assets/{keyboard-shortcuts-dialog-CqIm8aYF.js → keyboard-shortcuts-dialog-CsNP85q8.js} +2 -2
  80. package/dist/server/assets/{router-Dme7USeO.js → router-DJA7GtMo.js} +356 -64
  81. package/dist/server/assets/{search-dialog-DG0D9KRN.js → search-dialog-C2a3OYm_.js} +64 -83
  82. package/dist/server/assets/{session-export-dialog-DLPZVlQV.js → session-export-dialog-CwclV0Aj.js} +2 -2
  83. package/dist/server/assets/{settings-dialog-BaGT4e5l.js → settings-dialog-CHVzrou9.js} +390 -128
  84. package/dist/server/assets/skills-Cy8xclXY.js +11 -0
  85. package/dist/server/assets/skills-panel-BnRNb7u9.js +762 -0
  86. package/dist/server/assets/{switch-DnX0MjGS.js → switch-BbkUeVDV.js} +1 -1
  87. package/dist/server/assets/tabs-DDFZob0m.js +67 -0
  88. package/dist/server/assets/{tooltip-gbV6rEVv.js → tooltip-DgsSPocE.js} +1 -1
  89. package/dist/server/assets/{use-file-explorer-state-DfAKF2gZ.js → use-file-explorer-state-Il1LlBAe.js} +1 -1
  90. package/dist/server/server.js +2 -2
  91. package/package.json +7 -2
  92. package/dist/client/assets/_sessionKey-DB95zj1L.js +0 -97
  93. package/dist/client/assets/agents-LFrWe-HX.js +0 -2
  94. package/dist/client/assets/agents-screen-CEBBk1yO.js +0 -1
  95. package/dist/client/assets/bots-CxDwf_WK.js +0 -2
  96. package/dist/client/assets/bots-screen-D6qma1wK.js +0 -1
  97. package/dist/client/assets/button-Il3CHIzX.js +0 -1
  98. package/dist/client/assets/file-explorer-screen-rtV6n-5_.js +0 -1
  99. package/dist/client/assets/files-DMemuq9D.js +0 -2
  100. package/dist/client/assets/index-CVV4XiZo.js +0 -153
  101. package/dist/client/assets/keyboard-shortcuts-dialog-DXC0YHoy.js +0 -1
  102. package/dist/client/assets/react-BhVdgA5r.js +0 -1
  103. package/dist/client/assets/search-dialog-I1jJplIh.js +0 -1
  104. package/dist/client/assets/session-export-dialog-CH5unryw.js +0 -1
  105. package/dist/client/assets/settings-dialog-B8v-GVJ8.js +0 -1
  106. package/dist/client/assets/styles-BaTVzdPa.css +0 -1
  107. package/dist/client/assets/switch-sQnv1YsK.js +0 -1
  108. package/dist/client/assets/tooltip-j_viC_EE.js +0 -1
  109. package/dist/client/assets/use-file-explorer-state-BUH-u7Jv.js +0 -12
  110. package/dist/client/assets/useButton-9VAzplAB.js +0 -9
  111. package/dist/server/assets/_tanstack-start-manifest_v-BaIrL1VQ.js +0 -4
  112. package/dist/server/assets/bots-screen-DS_ZF9Ec.js +0 -417
@@ -0,0 +1,100 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/settings-dialog-BA5FjiyP.js","assets/main-mIHr_ble.js","assets/button-BaHefIXU.js","assets/use-file-explorer-state-CLaDuI9X.js","assets/useButton-DsMdJPGn.js","assets/tooltip-w9D-e_R-.js","assets/DirectionContext-DXnZc0zz.js","assets/visuallyHidden-CqGRL_Oq.js","assets/useCompositeItem-CaYygSfB.js","assets/react-Cfq4ot0g.js","assets/switch-Bh9tVOYh.js","assets/useControlled-wOKVgKF4.js","assets/tabs-BfaEc9zS.js","assets/CSPContext-BBLAL_m_.js","assets/index-B2iG4EM1.js","assets/useMutation-fJnleJAb.js","assets/opencami-logo-CRIdKbbZ.js","assets/index-T4TOjvD0.js","assets/session-export-dialog-DRlJwhMa.js","assets/keyboard-shortcuts-dialog-CcKSlK52.js","assets/search-dialog-D19x_xaG.js"])))=>i.map(i=>d[i]);
2
+ import{j as h,r as m,L as St,u as qt,_ as Hn,z as Zs,d as Yr,f as xl,a as yl,A as bl}from"./main-mIHr_ble.js";import{m as Fe,A as ut,u as Tn}from"./visuallyHidden-CqGRL_Oq.js";import{a7 as wl,a8 as kl,a9 as _i,y as eo,i as Sl,E as Ve,A as vl,h as jn,T as pt,a as dt,b as mt,c as gt,s as kt,d as Cl,g as Oi}from"./tooltip-w9D-e_R-.js";import{B as Ce,C as El,c as q,ab as Gr,af as Tt,E as Tl,H as ne,J as to,V as Un,ai as jl,aj as Al,ak as Il,a as no,al as Rl,n as Nl,am as Ll,L as Qr,b as Vt,I as Ml,an as Dl,a2 as zl,ao as Pl,s as ro,u as _l,l as io,K as Ol,N as Fl,X as Jr,x as $l,h as Bl,ap as so,aq as Hl,W as Zr,p as oo,ar as rr,as as Fi,at as Ul,S as ql,au as Wl,av as Kl}from"./button-BaHefIXU.js";import{D as ao,a as lo,b as co,c as Vl,d as uo,h as Xl,i as Yl,j as Gl,k as Ql,l as Jl,m as Zl,n as ec,o as tc,p as nc,q as fo,M as qn,e as Wn,f as Kn,g as vt,u as ir}from"./use-file-explorer-state-CLaDuI9X.js";import{d as ho,a as Ct,g as po,m as rc,u as et,f as ic,n as sc}from"./useButton-DsMdJPGn.js";import{u as oc}from"./useControlled-wOKVgKF4.js";import{g as ac,e as lc,u as mo,v as cc}from"./DirectionContext-DXnZc0zz.js";import{u as uc}from"./CSPContext-BBLAL_m_.js";import{u as go}from"./useMutation-fJnleJAb.js";import{O as fc,a as hc}from"./opencami-logo-CRIdKbbZ.js";import{r as pc,C as ei,u as dc,p as xo}from"./index-B2iG4EM1.js";import{s as ti,h as mc,w as gc,f as xc,a as yc,b as bc,c as $i}from"./index-T4TOjvD0.js";import{c as yo}from"./react-Cfq4ot0g.js";function Nr(e){if(!e)return"main";const t=e.trim();if(t.length===0)return"main";const n=t.split(":"),i=(n[n.length-1]??"").trim();return i.length>0?i:t}function tt(e){return(Array.isArray(e.content)?e.content:[]).map(n=>n.type==="text"?String(n.text??""):"").join("").trim()}function Rt(e){return(Array.isArray(e.content)?e.content:[]).filter(n=>n.type==="toolCall")}function wc(e){if(typeof e=="number"&&Number.isFinite(e))return e<1e12?e*1e3:e;if(typeof e=="string"){const t=Date.parse(e);if(!Number.isNaN(t))return t}return null}function Lr(e){const t=[e.createdAt,e.created_at,e.timestamp,e.time,e.ts];for(const n of t){const r=wc(n);if(r)return r}return Date.now()}const kc=["agent:main:main","main"];function Mr(e){return kc.includes(e)}const Sc=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function vc(e){if(e.includes(":subagent:")||e.startsWith("agent:codex:")||e.includes(":openai:"))return"subagent";if(e.startsWith("isolated:")||e.includes(":cron:"))return"cron";if(e.startsWith("agent:")&&!e.startsWith("agent:main:"))return"other";if(e.startsWith("agent:main:")){const t=e.slice(11);return Sc.test(t)?"webchat":"chat"}return"other"}function Cc(e){return Array.isArray(e)?e.map(t=>{const n=typeof t.key=="string"&&t.key.trim().length>0?t.key.trim():Nr(t.friendlyId??t.key),r=typeof t.friendlyId=="string"&&t.friendlyId.trim().length>0?t.friendlyId.trim():Nr(n),i=vc(n),s=t,o=typeof s.totalTokens=="number"?s.totalTokens:void 0,a=typeof s.contextTokens=="number"?s.contextTokens:void 0,l=typeof s.status=="string"?s.status:void 0;return{key:n,friendlyId:r,title:typeof t.title=="string"?t.title:void 0,derivedTitle:typeof t.derivedTitle=="string"?t.derivedTitle:void 0,label:typeof t.label=="string"?t.label:void 0,updatedAt:typeof t.updatedAt=="number"?t.updatedAt:void 0,lastMessage:t.lastMessage??null,kind:i,status:l,totalTokens:o,contextTokens:a}}):[]}async function lt(e){try{const t=await e.json();return t?.error?String(t.error):t?.message?String(t.message):JSON.stringify(t)}catch{try{return await e.text()}catch{return e.statusText||"Request failed"}}}const Ec="Missing gateway auth. Set CLAWDBOT_GATEWAY_TOKEN (recommended) or CLAWDBOT_GATEWAY_PASSWORD in the server environment.";function Bi(e){return e.includes(Ec)}function Hi(e,t){const n=crypto.randomUUID(),r=`opt-${n}`,i=Date.now(),s=[];if(t&&t.length>0)for(const a of t)a.type==="image"&&a.base64&&s.push({type:"image",source:{type:"base64",media_type:a.file.type,data:a.base64}});return e.trim()?s.push({type:"text",text:e}):t&&t.length>0&&s.push({type:"text",text:""}),{clientId:n,optimisticId:r,optimisticMessage:{role:"user",content:s,__optimisticId:r,clientId:n,status:"sending",timestamp:i}}}const ke={sessions:["chat","sessions"],history:function(t,n){return["chat","history",t,n]}};async function Tc(){const e=await fetch("/api/sessions");if(!e.ok)throw new Error(await lt(e));const t=await e.json();return Cc(t.sessions)}async function jc(e){const t=new URLSearchParams({limit:"200"});e.sessionKey&&t.set("sessionKey",e.sessionKey),e.friendlyId&&t.set("friendlyId",e.friendlyId);const n=await fetch(`/api/history?${t.toString()}`);if(!n.ok)throw new Error(await lt(n));return await n.json()}async function Ac(){const e=new AbortController,t=window.setTimeout(()=>e.abort(),2500);try{const n=await fetch("/api/ping",{signal:e.signal});if(!n.ok)throw new Error(await lt(n));return await n.json()}catch(n){throw n instanceof DOMException&&n.name==="AbortError"?new Error("Gateway check timed out"):n}finally{window.clearTimeout(t)}}function ni(e,t,n,r){const i=ke.history(t,n);e.setQueryData(i,function(o){const a=o,l=Array.isArray(a?.messages)?a.messages:[],c=r(l);return{sessionKey:a?.sessionKey??n,sessionId:a?.sessionId,messages:c}})}function sr(e,t,n,r){ni(e,t,n,function(s){return[...s,r]})}function Ic(e,t,n,r,i){const s=`opt-${r}`;ni(e,t,n,function(a){return a.map(l=>l.clientId===r||l.__optimisticId===r||l.__optimisticId===s?i(l):l)})}function Rc(e,t,n,r,i){ni(e,t,n,function(o){return o.filter(a=>!(a.clientId===r||a.__optimisticId===r||i&&a.__optimisticId===i))})}function Dr(e,t,n){const r=ke.history(t,n);e.setQueryData(r,{sessionKey:n,messages:[]})}function Nc(e,t,n,r,i){const s=ke.history(t,n),o=ke.history(r,i),a=e.getQueryData(s);if(!a)return;const l=Array.isArray(a.messages)?a.messages:[];e.setQueryData(o,{sessionKey:i,sessionId:a.sessionId,messages:l}),e.removeQueries({queryKey:s,exact:!0})}function Lc(e,t,n,r){e.setQueryData(ke.sessions,function(s){return Array.isArray(s)?s.map(o=>o.key!==t&&o.friendlyId!==n?o:{...o,lastMessage:r}):s})}function Mc(e,t,n){e.setQueryData(ke.sessions,function(i){return Array.isArray(i)?i.filter(s=>s.key!==t&&s.friendlyId!==n):i}),e.removeQueries({queryKey:["chat","history",n],exact:!1}),t&&t!==n&&e.removeQueries({queryKey:["chat","history",t],exact:!1})}async function Dc(e,t,n,r){e.setQueryData(ke.sessions,function(s){return Array.isArray(s)?s.map(o=>o.key===t||o.friendlyId===n?{...o,label:r}:o):s});try{const i=await fetch("/api/sessions",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionKey:t,friendlyId:n,label:r})});if(!i.ok){const s=await lt(i);console.error("[updateSessionLabel] Failed to persist:",s)}}catch(i){console.error("[updateSessionLabel] Network error:",i)}}function bo(e){return!e.content||!Array.isArray(e.content)?"":e.content.filter(t=>t.type==="text").map(t=>t.text||"").join(`
3
+ `)}function zc(e,t,n){const r=[];r.push(`# Conversation: ${e}`),r.push(`Date: ${n.toLocaleString()}`),r.push("");for(const i of t){const s=i.role||"unknown",o=bo(i);if(o){const a=s==="user"?"User":"Assistant";r.push(`## ${a}`),r.push(""),r.push(o),r.push("")}}return r.join(`
4
+ `)}function Pc(e,t,n){const r={title:e,exportDate:n.toISOString(),messages:t.map(i=>({role:i.role,content:i.content,timestamp:i.timestamp}))};return JSON.stringify(r,null,2)}function _c(e,t,n){const r=[];r.push(`Conversation: ${e}`),r.push(`Date: ${n.toLocaleString()}`),r.push("─".repeat(60)),r.push("");for(const i of t){const s=i.role||"unknown",o=bo(i);if(o){const a=s==="user"?"User":"Assistant";r.push(`${a}:`),r.push(o),r.push("")}}return r.join(`
5
+ `)}function Oc(e,t,n){const r=new Date;let i,s,o;switch(n){case"markdown":i=zc(e,t,r),s=`${or(e)}.md`,o="text/markdown";break;case"json":i=Pc(e,t,r),s=`${or(e)}.json`,o="application/json";break;case"txt":i=_c(e,t,r),s=`${or(e)}.txt`,o="text/plain";break;default:throw new Error(`Unsupported format: ${n}`)}Fc(i,s,o)}function or(e){return e.replace(/[^a-z0-9-_\s]/gi,"").replace(/\s+/g,"-").toLowerCase().slice(0,50)||"conversation"}function Fc(e,t,n){const r=new Blob([e],{type:n}),i=URL.createObjectURL(r),s=document.createElement("a");s.href=i,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(i)}function $c({open:e,onOpenChange:t,sessionTitle:n,onSave:r,onCancel:i}){return h.jsx(ao,{open:e,onOpenChange:t,children:h.jsx(lo,{children:h.jsxs("div",{className:"p-4",children:[h.jsx(co,{className:"mb-1",children:"Rename"}),h.jsx(Vl,{className:"mb-4",children:"Enter a new name for this session."}),h.jsx("input",{type:"text",defaultValue:n,onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),r(s.currentTarget.value))},className:"w-full rounded-lg border border-primary-200 bg-primary-50 px-3 py-2 text-sm text-primary-900 outline-none focus:border-primary-400",placeholder:"Session name",autoFocus:!0}),h.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[h.jsx(uo,{onClick:i,children:"Cancel"}),h.jsx(Ce,{onClick:s=>{const o=s.currentTarget.parentElement?.previousElementSibling;r(o.value)},children:"Save"})]})]})})})}function Bc(e){const{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:s,actionsRef:o,handle:a,triggerId:l,defaultTriggerId:c=null}=e,u=Xl(),f=!!u,p=El(()=>a?.store??new Yl({open:n??r,activeTriggerId:l!==void 0?l:c,modal:!0,disablePointerDismissal:!0,nested:f,role:"alertdialog"})).current;p.useControlledProp("open",n,r),p.useControlledProp("activeTriggerId",l,c),p.useSyncedValue("nested",f),p.useContextCallback("onOpenChange",i),p.useContextCallback("onOpenChangeComplete",s);const d=p.useState("payload");Gl({store:p,actionsRef:o,parentContext:u?.store.context});const g=m.useMemo(()=>({store:p}),[p]);return h.jsx(Ql.Provider,{value:g,children:typeof t=="function"?t({payload:d}):t})}function Hc({children:e,...t}){return h.jsx(Bc,{...t,children:e})}function Uc({className:e,children:t}){return h.jsxs(Jl,{children:[h.jsx(Zl,{className:"fixed inset-0 bg-primary-950/20 transition-all duration-150 data-[state=open]:opacity-100 data-[state=closed]:opacity-0"}),h.jsx(ec,{className:q("fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2","w-[min(400px,92vw)] rounded-xl border border-primary-200 bg-primary-50 p-0 shadow-xl","transition-all duration-150","data-[state=open]:opacity-100 data-[state=closed]:opacity-0","data-[state=open]:scale-100 data-[state=closed]:scale-95",e),children:t})]})}function qc({className:e,...t}){return h.jsx(tc,{className:q("text-lg font-medium text-primary-900",e),...t})}function Wc({className:e,...t}){return h.jsx(nc,{className:q("text-sm text-primary-600",e),...t})}function Kc({className:e,...t}){return h.jsx(fo,{render:h.jsx(Ce,{variant:"outline",className:q(e)}),...t})}function Vc({className:e,...t}){return h.jsx(fo,{render:h.jsx(Ce,{variant:"destructive",className:q(e)}),...t})}function Xc({open:e,onOpenChange:t,sessionTitle:n,onConfirm:r,onCancel:i}){return h.jsx(Hc,{open:e,onOpenChange:t,children:h.jsx(Uc,{children:h.jsxs("div",{className:"p-4",children:[h.jsx(qc,{className:"mb-1",children:"Delete Session"}),h.jsxs(Wc,{className:"mb-4",children:['Are you sure you want to delete "',n,'"? This action cannot be undone.']}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(Kc,{onClick:i,children:"Cancel"}),h.jsx(Vc,{onClick:r,children:"Delete"})]})]})})})}function Yc(e){const{open:t,defaultOpen:n,onOpenChange:r,disabled:i}=e,s=t!==void 0,[o,a]=oc({controlled:t,default:n,name:"Collapsible",state:"open"}),{mounted:l,setMounted:c,transitionStatus:u}=wl(o,!0,!0),[f,p]=m.useState(o),[{height:d,width:g},y]=m.useState({height:void 0,width:void 0}),k=ho(),[w,S]=m.useState(),E=w??k,[N,M]=m.useState(!1),[v,F]=m.useState(!1),U=m.useRef(null),D=m.useRef(null),C=m.useRef(null),z=m.useRef(null),j=kl(z,!1),_=Ct(R=>{const T=!o,B=po(rc,R.nativeEvent);if(r(T,B),B.isCanceled)return;const I=z.current;D.current==="css-animation"&&I!=null&&I.style.removeProperty("animation-name"),!N&&!v&&(D.current!=null&&D.current!=="css-animation"&&!l&&T&&c(!0),D.current==="css-animation"&&(!f&&T&&p(!0),!l&&T&&c(!0))),a(T),D.current==="none"&&l&&!T&&c(!1)});return et(()=>{s&&D.current==="none"&&!v&&!o&&c(!1)},[s,v,o,t,c]),m.useMemo(()=>({abortControllerRef:U,animationTypeRef:D,disabled:i,handleTrigger:_,height:d,mounted:l,open:o,panelId:E,panelRef:z,runOnceAnimationsFinish:j,setDimensions:y,setHiddenUntilFound:M,setKeepMounted:F,setMounted:c,setOpen:a,setPanelIdState:S,setVisible:p,transitionDimensionRef:C,transitionStatus:u,visible:f,width:g}),[U,D,i,_,d,l,o,E,z,j,y,M,F,c,a,p,C,u,f,g])}const wo=m.createContext(void 0);function ko(){const e=m.useContext(wo);if(e===void 0)throw new Error(Gr(15));return e}let nn=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=_i.startingStyle]="startingStyle",e[e.endingStyle=_i.endingStyle]="endingStyle",e})({}),Gc=(function(e){return e.panelOpen="data-panel-open",e})({});const Qc={[nn.open]:""},Jc={[nn.closed]:""},Zc={open(e){return e?{[Gc.panelOpen]:""}:null}},eu={open(e){return e?Qc:Jc}},So={...eu,...eo},tu=m.forwardRef(function(t,n){const{render:r,className:i,defaultOpen:s=!1,disabled:o=!1,onOpenChange:a,open:l,...c}=t,u=Ct(a),f=Yc({open:l,defaultOpen:s,onOpenChange:u,disabled:o}),p=m.useMemo(()=>({open:f.open,disabled:f.disabled,transitionStatus:f.transitionStatus}),[f.open,f.disabled,f.transitionStatus]),d=m.useMemo(()=>({...f,onOpenChange:u,state:p}),[f,u,p]),g=Tt("div",t,{state:p,ref:n,props:c,stateAttributesMapping:So});return h.jsx(wo.Provider,{value:d,children:g})}),nu={...Zc,...eo},ru=m.forwardRef(function(t,n){const{panelId:r,open:i,handleTrigger:s,state:o,disabled:a}=ko(),{className:l,disabled:c=a,id:u,render:f,nativeButton:p=!0,...d}=t,{getButtonProps:g,buttonRef:y}=ic({disabled:c,focusableWhenDisabled:!0,native:p}),k=m.useMemo(()=>({"aria-controls":i?r:void 0,"aria-expanded":i,onClick:s}),[r,i,s]);return Tt("button",t,{state:o,ref:[n,y],props:[k,d,g],stateAttributesMapping:nu})});let iu=(function(e){return e.disabled="data-disabled",e.orientation="data-orientation",e})({});function su(e){const{abortControllerRef:t,animationTypeRef:n,externalRef:r,height:i,hiddenUntilFound:s,keepMounted:o,id:a,mounted:l,onOpenChange:c,open:u,panelRef:f,runOnceAnimationsFinish:p,setDimensions:d,setMounted:g,setOpen:y,setVisible:k,transitionDimensionRef:w,visible:S,width:E}=e,N=m.useRef(!1),M=m.useRef(null),v=m.useRef(u),F=m.useRef(u),U=Sl(),D=m.useMemo(()=>n.current==="css-animation"?!S:!u&&!l,[u,l,S,n]),C=Ct(j=>{if(!j)return;if(n.current==null||w.current==null){const T=getComputedStyle(j),B=T.animationName!=="none"&&T.animationName!=="",I=T.transitionDuration!=="0s"&&T.transitionDuration!=="";B&&I||(T.animationName==="none"&&T.transitionDuration!=="0s"?n.current="css-transition":T.animationName!=="none"&&T.transitionDuration==="0s"?n.current="css-animation":n.current="none"),j.getAttribute(iu.orientation)==="horizontal"||T.transitionProperty.indexOf("width")>-1?w.current="width":w.current="height"}if(n.current!=="css-transition")return;(i===void 0||E===void 0)&&(d({height:j.scrollHeight,width:j.scrollWidth}),F.current&&j.style.setProperty("transition-duration","0s"));let _=-1,R=-1;return _=Ve.request(()=>{F.current=!1,R=Ve.request(()=>{setTimeout(()=>{j.style.removeProperty("transition-duration")})})}),()=>{Ve.cancel(_),Ve.cancel(R)}}),z=Tl(r,f,C);return et(()=>{if(n.current!=="css-transition")return;const j=f.current;if(!j)return;let _=-1;if(t.current!=null&&(t.current.abort(),t.current=null),u){const R={"justify-content":j.style.justifyContent,"align-items":j.style.alignItems,"align-content":j.style.alignContent,"justify-items":j.style.justifyItems};Object.keys(R).forEach(T=>{j.style.setProperty(T,"initial","important")}),!F.current&&!o&&j.setAttribute(nn.startingStyle,""),d({height:j.scrollHeight,width:j.scrollWidth}),_=Ve.request(()=>{Object.entries(R).forEach(([T,B])=>{B===""?j.style.removeProperty(T):j.style.setProperty(T,B)})})}else{if(j.scrollHeight===0&&j.scrollWidth===0)return;d({height:j.scrollHeight,width:j.scrollWidth});const R=new AbortController;t.current=R;const T=R.signal;let B=null;const I=nn.endingStyle;return B=new MutationObserver(H=>{H.some(x=>x.type==="attributes"&&x.attributeName===I)&&(B?.disconnect(),B=null,p(()=>{d({height:0,width:0}),j.style.removeProperty("content-visibility"),g(!1),t.current===R&&(t.current=null)},T))}),B.observe(j,{attributes:!0,attributeFilter:[I]}),()=>{B?.disconnect(),U.cancel(),t.current===R&&(R.abort(),t.current=null)}}return()=>{Ve.cancel(_)}},[t,n,U,s,o,l,u,f,p,d,g]),et(()=>{if(n.current!=="css-animation")return;const j=f.current;j&&(M.current=j.style.animationName||M.current,j.style.setProperty("animation-name","none"),d({height:j.scrollHeight,width:j.scrollWidth}),!v.current&&!N.current&&j.style.removeProperty("animation-name"),u?(t.current!=null&&(t.current.abort(),t.current=null),g(!0),k(!0)):(t.current=new AbortController,p(()=>{g(!1),k(!1),t.current=null},t.current.signal)))},[t,n,u,f,p,d,g,k,S]),ac(()=>{const j=Ve.request(()=>{v.current=!1});return()=>Ve.cancel(j)}),et(()=>{if(!s)return;const j=f.current;if(!j)return;let _=-1,R=-1;return u&&N.current&&(j.style.transitionDuration="0s",d({height:j.scrollHeight,width:j.scrollWidth}),_=Ve.request(()=>{N.current=!1,R=Ve.request(()=>{setTimeout(()=>{j.style.removeProperty("transition-duration")})})})),()=>{Ve.cancel(_),Ve.cancel(R)}},[s,u,f,d]),et(()=>{const j=f.current;j&&s&&D&&(j.setAttribute("hidden","until-found"),n.current==="css-transition"&&j.setAttribute(nn.startingStyle,""))},[s,D,n,f]),m.useEffect(function(){const _=f.current;if(!_)return;function R(T){N.current=!0,y(!0),c(!0,po(sc,T))}return _.addEventListener("beforematch",R),()=>{_.removeEventListener("beforematch",R)}},[c,f,y]),m.useMemo(()=>({props:{hidden:D,id:a,ref:z}}),[D,a,z])}let Ui=(function(e){return e.collapsiblePanelHeight="--collapsible-panel-height",e.collapsiblePanelWidth="--collapsible-panel-width",e})({});const ou=m.forwardRef(function(t,n){const{className:r,hiddenUntilFound:i,keepMounted:s,render:o,id:a,...l}=t,{abortControllerRef:c,animationTypeRef:u,height:f,mounted:p,onOpenChange:d,open:g,panelId:y,panelRef:k,runOnceAnimationsFinish:w,setDimensions:S,setHiddenUntilFound:E,setKeepMounted:N,setMounted:M,setPanelIdState:v,setOpen:F,setVisible:U,state:D,transitionDimensionRef:C,visible:z,width:j,transitionStatus:_}=ko(),R=i??!1,T=s??!1;et(()=>{if(a)return v(a),()=>{v(void 0)}},[a,v]),et(()=>{E(R)},[E,R]),et(()=>{N(T)},[N,T]);const{props:B}=su({abortControllerRef:c,animationTypeRef:u,externalRef:n,height:f,hiddenUntilFound:R,id:y,keepMounted:T,mounted:p,onOpenChange:d,open:g,panelRef:k,runOnceAnimationsFinish:w,setDimensions:S,setMounted:M,setOpen:F,setVisible:U,transitionDimensionRef:C,visible:z,width:j});vl({open:g&&_==="idle",ref:k,onComplete(){g&&S({height:void 0,width:void 0})}});const I=m.useMemo(()=>({...D,transitionStatus:_}),[D,_]),H=Tt("div",t,{state:I,ref:[n,k],props:[B,{style:{[Ui.collapsiblePanelHeight]:f===void 0?"auto":`${f}px`,[Ui.collapsiblePanelWidth]:j===void 0?"auto":`${j}px`}},l],stateAttributesMapping:So});return T||R||!T&&p?H:null});function An(e){return h.jsx(tu,{...e})}function In({className:e,...t}){return h.jsx(ru,{className:q("group inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-left text-xs font-medium text-primary-500 transition-colors hover:bg-primary-100 hover:text-primary-700 data-panel-open:text-primary-700",e),...t})}function Rn({className:e,contentClassName:t,children:n,...r}){return h.jsx(ou,{className:q('flex h-(--collapsible-panel-height) flex-col overflow-hidden text-sm transition-all duration-150 ease-out data-ending-style:h-0 data-starting-style:h-0 [&[hidden]:not([hidden="until-found"])]:hidden',e),...r,children:h.jsx("div",{className:q("pt-1",t),children:n})})}const vo=m.createContext(void 0);function Vn(){const e=m.useContext(vo);if(e===void 0)throw new Error(Gr(53));return e}let Nn=(function(e){return e.scrollAreaCornerHeight="--scroll-area-corner-height",e.scrollAreaCornerWidth="--scroll-area-corner-width",e})({});const dn=500,qi=16;function Ye(e,t,n){if(!e)return 0;const r=getComputedStyle(e),i=n==="x"?"Inline":"Block";return n==="x"&&t==="margin"?parseFloat(r[`${t}InlineStart`])*2:parseFloat(r[`${t}${i}Start`])+parseFloat(r[`${t}${i}End`])}let au=(function(e){return e.orientation="data-orientation",e.hovering="data-hovering",e.scrolling="data-scrolling",e.hasOverflowX="data-has-overflow-x",e.hasOverflowY="data-has-overflow-y",e.overflowXStart="data-overflow-x-start",e.overflowXEnd="data-overflow-x-end",e.overflowYStart="data-overflow-y-start",e.overflowYEnd="data-overflow-y-end",e})({});const mn="base-ui-disable-scrollbar",Co={className:mn,getElement(e){return h.jsx("style",{nonce:e,href:mn,precedence:"base-ui:low",children:`.${mn}{scrollbar-width:none}.${mn}::-webkit-scrollbar{display:none}`})}};let _t=(function(e){return e.hasOverflowX="data-has-overflow-x",e.hasOverflowY="data-has-overflow-y",e.overflowXStart="data-overflow-x-start",e.overflowXEnd="data-overflow-x-end",e.overflowYStart="data-overflow-y-start",e.overflowYEnd="data-overflow-y-end",e})({});const ri={hasOverflowX:e=>e?{[_t.hasOverflowX]:""}:null,hasOverflowY:e=>e?{[_t.hasOverflowY]:""}:null,overflowXStart:e=>e?{[_t.overflowXStart]:""}:null,overflowXEnd:e=>e?{[_t.overflowXEnd]:""}:null,overflowYStart:e=>e?{[_t.overflowYStart]:""}:null,overflowYEnd:e=>e?{[_t.overflowYEnd]:""}:null,cornerHidden:()=>null},lu={x:0,y:0},Wi={width:0,height:0},cu={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},uu={x:!1,y:!1,corner:!1},fu=m.forwardRef(function(t,n){const{render:r,className:i,overflowEdgeThreshold:s,...o}=t,a=hu(s),l=ho(),c=jn(),u=jn(),{nonce:f,disableStyleElements:p}=uc(),[d,g]=m.useState(!1),[y,k]=m.useState(!1),[w,S]=m.useState(!1),[E,N]=m.useState(!1),[M,v]=m.useState(Wi),[F,U]=m.useState(Wi),[D,C]=m.useState(cu),[z,j]=m.useState(uu),_=m.useRef(null),R=m.useRef(null),T=m.useRef(null),B=m.useRef(null),I=m.useRef(null),H=m.useRef(null),L=m.useRef(null),x=m.useRef(!1),K=m.useRef(0),V=m.useRef(0),b=m.useRef(0),J=m.useRef(0),Z=m.useRef("vertical"),Y=m.useRef(lu),ae=Ct($=>{const re=$.x-Y.current.x,ge=$.y-Y.current.y;Y.current=$,ge!==0&&(S(!0),c.start(dn,()=>{S(!1)})),re!==0&&(k(!0),u.start(dn,()=>{k(!1)}))}),se=Ct($=>{$.button===0&&(x.current=!0,K.current=$.clientY,V.current=$.clientX,Z.current=$.currentTarget.getAttribute(au.orientation),R.current&&(b.current=R.current.scrollTop,J.current=R.current.scrollLeft),I.current&&Z.current==="vertical"&&I.current.setPointerCapture($.pointerId),H.current&&Z.current==="horizontal"&&H.current.setPointerCapture($.pointerId))}),ee=Ct($=>{if(!x.current)return;const re=$.clientY-K.current,ge=$.clientX-V.current;if(R.current){const ie=R.current.scrollHeight,ye=R.current.clientHeight,Ae=R.current.scrollWidth,Ge=R.current.clientWidth;if(I.current&&T.current&&Z.current==="vertical"){const Ie=Ye(T.current,"padding","y"),Ne=Ye(I.current,"margin","y"),A=I.current.offsetHeight,O=T.current.offsetHeight-A-Ie-Ne,G=re/O;R.current.scrollTop=b.current+G*(ie-ye),$.preventDefault(),S(!0),c.start(dn,()=>{S(!1)})}if(H.current&&B.current&&Z.current==="horizontal"){const Ie=Ye(B.current,"padding","x"),Ne=Ye(H.current,"margin","x"),A=H.current.offsetWidth,O=B.current.offsetWidth-A-Ie-Ne,G=ge/O;R.current.scrollLeft=J.current+G*(Ae-Ge),$.preventDefault(),k(!0),u.start(dn,()=>{k(!1)})}}}),le=Ct($=>{x.current=!1,I.current&&Z.current==="vertical"&&I.current.releasePointerCapture($.pointerId),H.current&&Z.current==="horizontal"&&H.current.releasePointerCapture($.pointerId)});function me($){N($.pointerType==="touch")}function Se($){if(me($),$.pointerType!=="touch"){const re=lc(_.current,$.target);g(re)}}const we=m.useMemo(()=>({hasOverflowX:!z.x,hasOverflowY:!z.y,overflowXStart:D.xStart,overflowXEnd:D.xEnd,overflowYStart:D.yStart,overflowYEnd:D.yEnd,cornerHidden:z.corner}),[z.x,z.y,z.corner,D]),xe={role:"presentation",onPointerEnter:Se,onPointerMove:Se,onPointerDown:me,onPointerLeave(){g(!1)},style:{position:"relative",[Nn.scrollAreaCornerHeight]:`${M.height}px`,[Nn.scrollAreaCornerWidth]:`${M.width}px`}},Ee=Tt("div",t,{state:we,ref:[n,_],props:[xe,o],stateAttributesMapping:ri}),W=m.useMemo(()=>({handlePointerDown:se,handlePointerMove:ee,handlePointerUp:le,handleScroll:ae,cornerSize:M,setCornerSize:v,thumbSize:F,setThumbSize:U,touchModality:E,cornerRef:L,scrollingX:y,setScrollingX:k,scrollingY:w,setScrollingY:S,hovering:d,setHovering:g,viewportRef:R,rootRef:_,scrollbarYRef:T,scrollbarXRef:B,thumbYRef:I,thumbXRef:H,rootId:l,hiddenState:z,setHiddenState:j,overflowEdges:D,setOverflowEdges:C,viewportState:we,overflowEdgeThreshold:a}),[se,ee,le,ae,M,F,E,y,k,w,S,d,g,l,z,D,we,a]);return h.jsxs(vo.Provider,{value:W,children:[!p&&Co.getElement(f),Ee]})});function hu(e){if(typeof e=="number"){const t=Math.max(0,e);return{xStart:t,xEnd:t,yStart:t,yEnd:t}}return{xStart:Math.max(0,e?.xStart||0),xEnd:Math.max(0,e?.xEnd||0),yStart:Math.max(0,e?.yStart||0),yEnd:Math.max(0,e?.yEnd||0)}}const pu=m.createContext(void 0);function ft(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}function du(e,t){if(typeof IntersectionObserver>"u")return()=>{};const n=new IntersectionObserver(r=>{r.forEach(i=>{i.intersectionRatio>0&&(t(),n.disconnect())})});return n.observe(e),()=>{n.disconnect()}}let Et=(function(e){return e.scrollAreaOverflowXStart="--scroll-area-overflow-x-start",e.scrollAreaOverflowXEnd="--scroll-area-overflow-x-end",e.scrollAreaOverflowYStart="--scroll-area-overflow-y-start",e.scrollAreaOverflowYEnd="--scroll-area-overflow-y-end",e})({}),Ki=!1;function mu(){Ki||cc||(typeof CSS<"u"&&"registerProperty"in CSS&&[Et.scrollAreaOverflowXStart,Et.scrollAreaOverflowXEnd,Et.scrollAreaOverflowYStart,Et.scrollAreaOverflowYEnd].forEach(e=>{try{CSS.registerProperty({name:e,syntax:"<length>",inherits:!1,initialValue:"0px"})}catch{}}),Ki=!0)}const gu=m.forwardRef(function(t,n){const{render:r,className:i,...s}=t,{viewportRef:o,scrollbarYRef:a,scrollbarXRef:l,thumbYRef:c,thumbXRef:u,cornerRef:f,cornerSize:p,setCornerSize:d,setThumbSize:g,rootId:y,setHiddenState:k,hiddenState:w,handleScroll:S,setHovering:E,setOverflowEdges:N,overflowEdges:M,overflowEdgeThreshold:v}=Vn(),F=mo(),U=m.useRef(!0),D=jn(),C=jn(),z=Ct(()=>{const I=o.current,H=a.current,L=l.current,x=c.current,K=u.current,V=f.current;if(!I)return;const b=I.scrollHeight,J=I.scrollWidth,Z=I.clientHeight,Y=I.clientWidth,ae=I.scrollTop,se=I.scrollLeft;if(b===0||J===0)return;const ee=Z>=b,le=Y>=J,me=Y/J,Se=Z/b,we=Math.max(0,J-Y),xe=Math.max(0,b-Z);let Ee=0,W=0;le||(F==="rtl"?Ee=ft(-se,0,we):Ee=ft(se,0,we),W=we-Ee);const $=ee?0:ft(ae,0,xe),re=ee?0:xe-$,ge=le?0:Y,ie=ee?0:Z;let ye=0,Ae=0;!le&&!ee&&(ye=H?.offsetWidth||0,Ae=L?.offsetHeight||0);const Ge=p.width===0&&p.height===0,Ie=Ge?ye:0,Ne=Ge?Ae:0,A=Ye(L,"padding","x"),O=Ye(H,"padding","y"),G=Ye(K,"margin","x"),te=Ye(x,"margin","y"),ce=ge-A-G,Re=ie-O-te,Ue=L?Math.min(L.offsetWidth-Ie,ce):ce,Oe=H?Math.min(H.offsetHeight-Ne,Re):Re,qe=Math.max(qi,Ue*me),Qe=Math.max(qi,Oe*Se);if(g(he=>he.height===Qe&&he.width===qe?he:{width:qe,height:Qe}),H&&x){const he=H.offsetHeight-Qe-O-te,Ke=b-Z,zt=Ke===0?0:ae/Ke,st=Math.min(he,Math.max(0,zt*he));x.style.transform=`translate3d(0,${st}px,0)`}if(L&&K){const he=L.offsetWidth-qe-A-G,Ke=J-Y,zt=Ke===0?0:se/Ke,st=F==="rtl"?ft(zt*he,-he,0):ft(zt*he,0,he);K.style.transform=`translate3d(${st}px,0,0)`}const je=ft(Ee,0,we),We=ft(W,0,we),ze=ft($,0,xe),rt=ft(re,0,xe),tr=[[Et.scrollAreaOverflowXStart,je],[Et.scrollAreaOverflowXEnd,We],[Et.scrollAreaOverflowYStart,ze],[Et.scrollAreaOverflowYEnd,rt]];for(const[he,Ke]of tr)I.style.setProperty(he,`${Ke}px`);V&&(le||ee?d({width:0,height:0}):!le&&!ee&&d({width:ye,height:Ae})),k(he=>{const Ke=ee||le;return he.y===ee&&he.x===le&&he.corner===Ke?he:{y:ee,x:le,corner:Ke}});const it={xStart:!le&&je>v.xStart,xEnd:!le&&We>v.xEnd,yStart:!ee&&ze>v.yStart,yEnd:!ee&&rt>v.yEnd};N(he=>he.xStart===it.xStart&&he.xEnd===it.xEnd&&he.yStart===it.yStart&&he.yEnd===it.yEnd?he:it)});et(()=>{if(!o.current)return;mu();let I=!1;return du(o.current,()=>{if(!I){I=!0;return}z()})},[z,o]),et(()=>{queueMicrotask(z)},[z,w,F]),et(()=>{o.current?.matches(":hover")&&E(!0)},[o,E]),m.useEffect(()=>{const I=o.current;if(typeof ResizeObserver>"u"||!I)return;let H=!1;const L=new ResizeObserver(()=>{if(!H){H=!0;return}z()});return L.observe(I),C.start(0,()=>{const x=I.getAnimations({subtree:!0});x.length!==0&&Promise.all(x.map(K=>K.finished)).then(z).catch(()=>{})}),()=>{L.disconnect(),C.clear()}},[z,o,C]);function j(){U.current=!1}const _={role:"presentation",...y&&{"data-id":`${y}-viewport`},...(!w.x||!w.y)&&{tabIndex:0},className:Co.className,style:{overflow:"scroll"},onScroll(){o.current&&(z(),U.current||S({x:o.current.scrollLeft,y:o.current.scrollTop}),D.start(100,()=>{U.current=!0}))},onWheel:j,onTouchMove:j,onPointerMove:j,onPointerEnter:j,onKeyDown:j},R=m.useMemo(()=>({hasOverflowX:!w.x,hasOverflowY:!w.y,overflowXStart:M.xStart,overflowXEnd:M.xEnd,overflowYStart:M.yStart,overflowYEnd:M.yEnd,cornerHidden:w.corner}),[w.x,w.y,w.corner,M]),T=Tt("div",t,{ref:[n,o],state:R,props:[_,s],stateAttributesMapping:ri}),B=m.useMemo(()=>({computeThumbPosition:z}),[z]);return h.jsx(pu.Provider,{value:B,children:T})}),Eo=m.createContext(void 0);function xu(){const e=m.useContext(Eo);if(e===void 0)throw new Error(Gr(54));return e}let Ln=(function(e){return e.scrollAreaThumbHeight="--scroll-area-thumb-height",e.scrollAreaThumbWidth="--scroll-area-thumb-width",e})({});const yu=m.forwardRef(function(t,n){const{render:r,className:i,orientation:s="vertical",keepMounted:o=!1,...a}=t,{hovering:l,scrollingX:c,scrollingY:u,hiddenState:f,overflowEdges:p,scrollbarYRef:d,scrollbarXRef:g,viewportRef:y,thumbYRef:k,thumbXRef:w,handlePointerDown:S,handlePointerUp:E,rootId:N,thumbSize:M}=Vn(),v=m.useMemo(()=>({hovering:l,scrolling:{horizontal:c,vertical:u}[s],orientation:s,hasOverflowX:!f.x,hasOverflowY:!f.y,overflowXStart:p.xStart,overflowXEnd:p.xEnd,overflowYStart:p.yStart,overflowYEnd:p.yEnd,cornerHidden:f.corner}),[l,c,u,s,f,p]),F=mo();m.useEffect(()=>{const _=y.current,R=s==="vertical"?d.current:g.current;if(!R)return;function T(B){if(!(!_||!R||B.ctrlKey)){if(B.preventDefault(),s==="vertical"){if(_.scrollTop===0&&B.deltaY<0)return}else if(_.scrollLeft===0&&B.deltaX<0)return;if(s==="vertical"){if(_.scrollTop===_.scrollHeight-_.clientHeight&&B.deltaY>0)return}else if(_.scrollLeft===_.scrollWidth-_.clientWidth&&B.deltaX>0)return;s==="vertical"?_.scrollTop+=B.deltaY:_.scrollLeft+=B.deltaX}}return R.addEventListener("wheel",T,{passive:!1}),()=>{R.removeEventListener("wheel",T)}},[s,g,d,y]);const U={...N&&{"data-id":`${N}-scrollbar`},onPointerDown(_){if(_.button===0&&_.currentTarget===_.target&&y.current){if(k.current&&d.current&&s==="vertical"){const R=Ye(k.current,"margin","y"),T=Ye(d.current,"padding","y"),B=k.current.offsetHeight,I=d.current.getBoundingClientRect(),H=_.clientY-I.top-B/2-T+R/2,L=y.current.scrollHeight,x=y.current.clientHeight,K=d.current.offsetHeight-B-T-R,b=H/K*(L-x);y.current.scrollTop=b}if(w.current&&g.current&&s==="horizontal"){const R=Ye(w.current,"margin","x"),T=Ye(g.current,"padding","x"),B=w.current.offsetWidth,I=g.current.getBoundingClientRect(),H=_.clientX-I.left-B/2-T+R/2,L=y.current.scrollWidth,x=y.current.clientWidth,K=g.current.offsetWidth-B-T-R,V=H/K;let b;F==="rtl"?(b=(1-V)*(L-x),y.current.scrollLeft<=0&&(b=-b)):b=V*(L-x),y.current.scrollLeft=b}S(_)}},onPointerUp:E,style:{position:"absolute",touchAction:"none",WebkitUserSelect:"none",userSelect:"none",...s==="vertical"&&{top:0,bottom:`var(${Nn.scrollAreaCornerHeight})`,insetInlineEnd:0,[Ln.scrollAreaThumbHeight]:`${M.height}px`},...s==="horizontal"&&{insetInlineStart:0,insetInlineEnd:`var(${Nn.scrollAreaCornerWidth})`,bottom:0,[Ln.scrollAreaThumbWidth]:`${M.width}px`}}},D=Tt("div",t,{ref:[n,s==="vertical"?d:g],state:v,props:[U,a],stateAttributesMapping:ri}),C=m.useMemo(()=>({orientation:s}),[s]),z=s==="vertical"?f.y:f.x;return o||!z?h.jsx(Eo.Provider,{value:C,children:D}):null}),bu=m.forwardRef(function(t,n){const{render:r,className:i,...s}=t,{thumbYRef:o,thumbXRef:a,handlePointerDown:l,handlePointerMove:c,handlePointerUp:u,setScrollingX:f,setScrollingY:p}=Vn(),{orientation:d}=xu(),g=m.useMemo(()=>({orientation:d}),[d]);return Tt("div",t,{ref:[n,d==="vertical"?o:a],state:g,props:[{onPointerDown:l,onPointerMove:c,onPointerUp(k){d==="vertical"&&p(!1),d==="horizontal"&&f(!1),u(k)},style:{...d==="vertical"&&{height:`var(${Ln.scrollAreaThumbHeight})`},...d==="horizontal"&&{width:`var(${Ln.scrollAreaThumbWidth})`}}},s]})}),wu=m.forwardRef(function(t,n){const{render:r,className:i,...s}=t,{cornerRef:o,cornerSize:a,hiddenState:l}=Vn(),c=Tt("div",t,{ref:[n,o],props:[{style:{position:"absolute",bottom:0,insetInlineEnd:0,width:a.width,height:a.height}},s]});return l.corner?null:c});function To({className:e,...t}){return h.jsx(fu,{className:q("group/scroll-area relative outline-none focus-visible:outline-none",e),...t})}function jo({className:e,...t}){return h.jsx(gu,{className:q("h-full w-full outline-none focus-visible:outline-none",e),...t})}function Ao({className:e,...t}){return h.jsx(yu,{className:q("flex w-2 touch-none select-none p-0.5 outline-none focus-visible:outline-none","opacity-0 transition-opacity duration-150","data-hovering:opacity-100 data-scrolling:opacity-100 group-hover/scroll-area:opacity-100",e),...t})}function Io({className:e,...t}){return h.jsx(bu,{className:q("flex-1 rounded-full bg-primary-500 outline-none focus-visible:outline-none",e),...t})}function ku({className:e,...t}){return h.jsx(wu,{className:q("bg-primary-100 outline-none focus-visible:outline-none",e),...t})}function Su(e){return e==="subagent"?Rl:e==="cron"?Nl:Ll}function vu(e){return!e||!Array.isArray(e.content)?"":e.content.map(n=>n.type==="text"?String(n.text??""):"").join(" ").replace(/\s+/g," ").trim()}function Cu(e){if(typeof e=="number"&&Number.isFinite(e))return e<1e12?e*1e3:e;if(typeof e=="string"){const t=Date.parse(e);if(!Number.isNaN(t))return t}return null}function Eu(e){if(!e)return null;const t=[e.createdAt,e.created_at,e.timestamp,e.time,e.ts];for(const n of t){const r=Cu(n);if(r)return r}return null}function Tu(e){const t=e-Date.now(),n=Math.abs(t),r=[["minute",6e4],["hour",36e5],["day",864e5]];let i="minute",s=6e4;n>=r[2][1]?[i,s]=r[2]:n>=r[1][1]&&([i,s]=r[1]);const o=Math.round(t/s);return new Intl.RelativeTimeFormat("en",{numeric:"auto"}).format(o,i)}function ju(e){const t=String(e??"").toLowerCase().trim();return t?t==="error"||t==="failed"?"error":t==="completed"||t==="ended"||t==="done"?"success":null:null}function Au({session:e,active:t,isGenerating:n=!1,isPinned:r,selectionMode:i=!1,selected:s=!1,onToggleSelect:o,onSelect:a,onTogglePin:l,onRename:c,onDelete:u,onExport:f}){const p=e.label||e.title||e.derivedTitle||e.friendlyId,d=Su(e.kind),g=e.kind==="subagent"&&(e.lastMessage?.role==="assistant"||e.lastMessage?.role==="toolResult")?vu(e.lastMessage):"",y=g.length>50?`${g.slice(0,50).trimEnd()}…`:g,k=e.kind==="subagent"?ju(e.status):null,w=e.kind==="cron"?Eu(e.lastMessage):null;return h.jsxs(St,{to:"/chat/$sessionKey",params:{sessionKey:e.friendlyId},onClick:S=>{if(i){S.preventDefault(),S.stopPropagation(),o?.(e);return}a?.()},className:q("group inline-flex items-center justify-between","w-full text-left pl-1.5 pr-0.5 min-h-8 py-1 rounded-lg transition-colors duration-0","select-none",t?"bg-[var(--opencami-accent-light)] text-[var(--opencami-accent)]":"bg-transparent text-primary-950 [&:hover:not(:has(button:hover))]:bg-primary-200"),children:[h.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[i?h.jsx("span",{"aria-hidden":"true",className:q("inline-flex items-center justify-center size-4 shrink-0 rounded border transition-colors",s?"bg-primary-700 border-primary-700 text-white":"border-primary-300 bg-surface"),children:s?h.jsx("svg",{viewBox:"0 0 12 12",className:"size-3",fill:"none",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{d:"M2.5 6l2.5 2.5 4.5-5"})}):null}):null,h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[h.jsx(ne,{icon:d,size:12,strokeWidth:1.75,className:"text-primary-500/70 shrink-0"}),h.jsxs("div",{className:"min-w-0 truncate text-sm font-[450]",title:p,children:[r?h.jsx("span",{className:"mr-1 text-xs text-primary-700","aria-hidden":"true",children:"📌"}):null,p]}),e.kind==="subagent"?n?h.jsx("span",{"aria-label":"Session active",className:"size-1.5 rounded-full bg-green-500 shrink-0"}):k==="success"?h.jsx(ne,{icon:to,size:12,strokeWidth:1.8,className:"text-green-600/80 shrink-0"}):k==="error"?h.jsx(ne,{icon:Un,size:12,strokeWidth:1.8,className:"text-red-600/80 shrink-0"}):null:null]}),y?h.jsx("div",{className:"text-[11px] text-primary-600/80 line-clamp-1 mt-0.5 pl-[18px]",children:y}):null,e.kind==="cron"&&w?h.jsx("div",{className:"text-[10px] text-primary-500/75 line-clamp-1 mt-0.5 pl-[18px] font-mono",children:Tu(w)}):null]})]}),i?null:h.jsxs(qn,{children:[h.jsx(Wn,{type:"button",onClick:S=>{S.preventDefault(),S.stopPropagation()},className:q("ml-2 inline-flex size-7 items-center justify-center rounded-md text-primary-700","opacity-0 transition-opacity group-hover:opacity-100 hover:bg-primary-200","aria-expanded:opacity-100 aria-expanded:bg-primary-200"),children:h.jsx(ne,{icon:jl,size:20,strokeWidth:1.5})}),h.jsxs(Kn,{side:"bottom",align:"end",children:[h.jsxs(vt,{onClick:S=>{S.preventDefault(),S.stopPropagation(),l(e)},className:"gap-2",children:[h.jsx("span",{className:"text-xs","aria-hidden":"true",children:"📌"})," ",r?"Unpin Session":"Pin Session"]}),h.jsxs(vt,{onClick:S=>{S.preventDefault(),S.stopPropagation(),c(e)},className:"gap-2",children:[h.jsx(ne,{icon:Al,size:20,strokeWidth:1.5})," ","Rename"]}),h.jsxs(vt,{onClick:S=>{S.preventDefault(),S.stopPropagation(),f(e)},className:"gap-2",children:[h.jsx(ne,{icon:Il,size:20,strokeWidth:1.5})," ","Export"]}),Mr(e.key)?null:h.jsxs(vt,{onClick:S=>{S.preventDefault(),S.stopPropagation(),u(e)},className:"text-red-700 gap-2 hover:bg-red-50/80 data-highlighted:bg-red-50/80",children:[h.jsx(ne,{icon:no,size:20,strokeWidth:1.5})," ","Delete"]})]})]})]})}function Iu(e,t){return e.active!==t.active||e.isGenerating!==t.isGenerating||e.isPinned!==t.isPinned||e.selectionMode!==t.selectionMode||e.selected!==t.selected||e.onToggleSelect!==t.onToggleSelect||e.onSelect!==t.onSelect||e.onTogglePin!==t.onTogglePin||e.onRename!==t.onRename||e.onDelete!==t.onDelete||e.onExport!==t.onExport?!1:e.session===t.session?!0:e.session.key===t.session.key&&e.session.friendlyId===t.session.friendlyId&&e.session.label===t.session.label&&e.session.title===t.session.title&&e.session.derivedTitle===t.session.derivedTitle&&e.session.updatedAt===t.session.updatedAt&&e.session.kind===t.session.kind&&e.session.status===t.session.status&&e.session.lastMessage===t.session.lastMessage}const ar=m.memo(Au,Iu),Ro="opencami-pinned-sessions",No="opencami-sidebar-folders",bt={webchat:!1,subagent:!1,cron:!1,other:!1};async function Ru(e){const t=new URLSearchParams;e&&t.set("sessionKey",e);const n=await fetch(`/api/sessions?${t.toString()}`,{method:"DELETE"});if(!n.ok)throw new Error(await lt(n))}async function Nu(e,t,n){const r=[];let i=0;const s=Array.from({length:Math.min(t,e.length)},async function(){for(;i<e.length;){const a=i;i+=1;try{await n(e[a])}catch(l){r.push(l)}}});return await Promise.all(s),r}function Lu(){if(typeof window>"u")return[];try{const e=localStorage.getItem(Ro);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}function Mu(e){if(!(typeof window>"u"))try{const t=Array.from(new Set(e));localStorage.setItem(Ro,JSON.stringify(t))}catch{}}function Du(){if(typeof window>"u")return{...bt};try{const e=localStorage.getItem(No);if(!e)return{...bt};const t=JSON.parse(e);return!t||typeof t!="object"?{...bt}:{webchat:typeof t.webchat=="boolean"?t.webchat:bt.webchat,subagent:typeof t.subagent=="boolean"?t.subagent:bt.subagent,cron:typeof t.cron=="boolean"?t.cron:bt.cron,other:typeof t.other=="boolean"?t.other:bt.other}}catch{return{...bt}}}function zu(e){if(!(typeof window>"u"))try{localStorage.setItem(No,JSON.stringify(e))}catch{}}function Sn(e,t,n){return n&&e.key?e.key===n:e.friendlyId===t}function Pu(e){if(!e)return!1;const t=e.toLowerCase();return t.includes("running")||t.includes("active")||t.includes("stream")||t.includes("generat")}function lr(e,t,n,r){return Sn(e,t,n)&&r?!0:Pu(e.status)}const _u=m.memo(function({sessions:t,activeFriendlyId:n,activeSessionKey:r,isStreaming:i=!1,defaultOpen:s=!0,onSelect:o,onRename:a,onDelete:l,onExport:c}){const u=m.useDeferredValue(t),f=qt(),[p,d]=m.useState(()=>Lu()),[g,y]=m.useState(()=>Du()),[k,w]=m.useState(!1),[S,E]=m.useState(()=>new Set),N=m.useMemo(()=>new Set(p),[p]),M=u.filter(L=>N.has(L.key)),v=u.filter(L=>!N.has(L.key)),F=M.length>0&&v.length>0,U=m.useMemo(()=>{const L={chat:[],webchat:[],subagent:[],cron:[],other:[]};for(const x of v){const K=x.kind??"other";L[K].push(x)}return L},[v]),D=m.useMemo(()=>u.filter(L=>S.has(L.key)),[S,u]),C=D.length,z=m.useCallback(()=>{w(L=>(L&&E(new Set),!L))},[]),j=m.useCallback(L=>{Mr(L.key)||E(x=>{const K=new Set(x);return K.has(L.key)?K.delete(L.key):K.add(L.key),K})},[]),_=m.useCallback(()=>{E(new Set(u.filter(L=>!Mr(L.key)).map(L=>L.key)))},[u]),R=m.useCallback(()=>{w(!1),E(new Set)},[]),T=m.useCallback(async()=>{if(D.length===0||!window.confirm(`Delete ${D.length} sessions? This will archive them.`))return;const x=[];await Nu(D,10,async K=>{try{await Ru(K.key)}catch(V){throw x.push(K.label||K.title||K.derivedTitle||K.friendlyId),V}}),x.length>0&&(console.error("[sidebar] Bulk delete failed for some sessions",x),window.alert(`Could not delete ${x.length} session${x.length!==1?"s":""}:
6
+
7
+ ${x.join(`
8
+ `)}`)),w(!1),E(new Set),f.invalidateQueries({queryKey:ke.sessions})},[f,D]),B=m.useCallback(L=>{d(x=>{const V=x.includes(L.key)?x.filter(b=>b!==L.key):[...x,L.key];return Mu(V),V})},[]),I=m.useCallback((L,x)=>{y(K=>{const V={...K,[L]:x};return zu(V),V})},[]);function H(L,x,K){return K.length===0?null:h.jsxs(An,{className:"flex flex-col",open:g[L],onOpenChange:V=>I(L,V),children:[h.jsxs(In,{className:q("w-full justify-between border-l-2 border-primary-200/70 px-2 py-1 text-[11px] font-medium text-primary-500/80 text-balance"),children:[h.jsx("span",{className:"truncate",children:x}),h.jsx("span",{className:q("rounded-full bg-primary-100 px-1.5 py-0.5 text-[10px] font-medium text-primary-700 tabular-nums"),children:K.length})]}),h.jsx(Rn,{contentClassName:"flex flex-col gap-px",children:K.map(V=>h.jsx(ar,{session:V,active:Sn(V,n,r),isGenerating:lr(V,n,r,i),isPinned:!1,selectionMode:k,selected:S.has(V.key),onToggleSelect:j,onSelect:o,onTogglePin:B,onRename:a,onDelete:l,onExport:c},V.key))})]})}return h.jsxs(An,{className:"flex h-full flex-col flex-1 min-h-0 w-full",defaultOpen:s,children:[h.jsxs("div",{className:"flex items-center justify-between pr-2 shrink-0",children:[h.jsxs(In,{className:"w-fit pl-1.5 text-balance",children:["Sessions",h.jsx("span",{className:"opacity-0 transition-opacity duration-150 group-hover:opacity-100",children:h.jsx(ne,{icon:Qr,className:"size-3 transition-transform duration-150 group-data-panel-open:rotate-90"})})]}),h.jsx("button",{type:"button",onClick:z,className:q("text-[11px] font-medium px-1.5 py-0.5 rounded-md transition-colors",k?"text-primary-900 bg-primary-200":"text-primary-500 hover:text-primary-700 hover:bg-primary-100"),children:k?"Done":"Select"})]}),h.jsx(Rn,{className:"w-full flex-1 min-h-0 h-auto data-starting-style:h-0 data-ending-style:h-0",contentClassName:"flex flex-1 min-h-0 flex-col overflow-y-auto",children:h.jsxs(To,{className:"flex-1 min-h-0",children:[h.jsx(jo,{className:"min-h-0",children:h.jsxs("div",{className:"flex flex-col gap-2 pl-2 pr-2",children:[M.length>0?h.jsx("div",{className:"flex flex-col gap-px",children:M.map(L=>h.jsx(ar,{session:L,active:Sn(L,n,r),isGenerating:lr(L,n,r,i),isPinned:!0,selectionMode:k,selected:S.has(L.key),onToggleSelect:j,onSelect:o,onTogglePin:B,onRename:a,onDelete:l,onExport:c},L.key))}):null,F?h.jsx("div",{className:"my-1 border-t border-primary-200/80"}):null,U.chat.length>0?h.jsxs("div",{className:"flex flex-col gap-px",children:[h.jsx("div",{className:q("border-l-2 border-primary-200/70 px-2 py-1 text-[11px] font-medium text-primary-500/80 text-balance"),children:"💬 Chats"}),h.jsx("div",{className:"flex flex-col gap-px",children:U.chat.map(L=>h.jsx(ar,{session:L,active:Sn(L,n,r),isGenerating:lr(L,n,r,i),isPinned:!1,selectionMode:k,selected:S.has(L.key),onToggleSelect:j,onSelect:o,onTogglePin:B,onRename:a,onDelete:l,onExport:c},L.key))})]}):null,H("webchat","🦎 OpenCami",U.webchat),H("subagent","🤖 Sub-agents",U.subagent),H("cron","⏰ Cron / Isolated",U.cron),H("other","📁 Other",U.other)]})}),h.jsx(Ao,{orientation:"vertical",children:h.jsx(Io,{})})]})}),k?h.jsxs("div",{className:"shrink-0 border-t border-primary-200 bg-surface px-2 py-2 flex flex-col gap-1.5",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("span",{className:"text-xs text-primary-600 font-medium",children:[C," selected"]}),h.jsx("button",{type:"button",onClick:_,className:"text-[11px] font-medium text-primary-600 hover:text-primary-800",children:"Select all"})]}),h.jsxs("div",{className:"flex gap-1.5",children:[h.jsxs("button",{type:"button",onClick:T,disabled:C===0,className:q("flex-1 inline-flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium transition-colors",C>0?"bg-red-100 text-red-700 hover:bg-red-200":"bg-primary-100 text-primary-400 cursor-not-allowed"),children:[h.jsx(ne,{icon:no,size:14,strokeWidth:1.5}),"Delete"]}),h.jsx("button",{type:"button",onClick:R,className:"flex-1 inline-flex items-center justify-center rounded-md px-2 py-1.5 text-xs font-medium bg-primary-100 text-primary-700 hover:bg-primary-200 transition-colors",children:"Cancel"})]})]}):null]})},Ou);function Ou(e,t){if(e.activeFriendlyId!==t.activeFriendlyId||e.activeSessionKey!==t.activeSessionKey||e.isStreaming!==t.isStreaming||e.defaultOpen!==t.defaultOpen||e.onSelect!==t.onSelect||e.onRename!==t.onRename||e.onDelete!==t.onDelete||e.onExport!==t.onExport)return!1;if(e.sessions===t.sessions)return!0;if(e.sessions.length!==t.sessions.length)return!1;for(let n=0;n<e.sessions.length;n+=1){const r=e.sessions[n],i=t.sessions[n];if(r.key!==i.key||r.friendlyId!==i.friendlyId||r.label!==i.label||r.title!==i.title||r.derivedTitle!==i.derivedTitle||r.updatedAt!==i.updatedAt||r.kind!==i.kind||r.status!==i.status||r.lastMessage!==i.lastMessage)return!1}return!0}function Fu(){const[e,t]=m.useState(!1),[n,r]=m.useState(!1),[i,s]=m.useState(null),[o,a]=m.useState(null),l=m.useCallback(async()=>{if(t(!0),s(null),!(n||o)){r(!0);try{const d=await fetch("/api/paths");if(!d.ok)throw new Error(await lt(d));const g=await d.json();a({agentId:String(g.agentId??"main"),stateDir:String(g.stateDir??""),sessionsDir:String(g.sessionsDir??""),storePath:String(g.storePath??"")})}catch(d){s(d instanceof Error?d.message:String(d))}finally{r(!1)}}},[o,n]),c=m.useCallback(()=>{l()},[l]),u=m.useCallback(()=>{t(!1)},[]),f=m.useCallback(()=>{if(o?.sessionsDir)try{navigator.clipboard.writeText(o.sessionsDir)}catch{}},[o]),p=m.useCallback(()=>{if(o?.storePath)try{navigator.clipboard.writeText(o.storePath)}catch{}},[o]);return{settingsOpen:e,setSettingsOpen:t,pathsLoading:n,pathsError:i,paths:o,handleOpenSettings:c,closeSettings:u,copySessionsDir:f,copyStorePath:p}}let Be=null,ii=!1,vn=null;function $u(e){Be=e}function cr(){return Be!==null}function Xt(e){ii=e}function ur(){return ii}function Mn(){Be=null,ii=!1}function Bu(e,t){if(Be){if(e&&Be.sessionKey===e){Mn();return}t&&Be.friendlyId===t&&Mn()}}function Hu(e){vn={friendlyId:e,at:Date.now()}}function Lo(e,t=15e3){return!(!vn||vn.friendlyId!==e||Date.now()-vn.at>t)}function Uu(e,t){if(!Be)return null;if(e&&Be.sessionKey===e){const n=Be;return Be=null,n}if(t&&Be.friendlyId===t){const n=Be;return Be=null,n}return null}const qu=8e3,It=new Map;function Wu(e){e&&It.set(e,{id:e,expiresAt:Date.now()+qu})}function Ku(e){e&&It.delete(e)}function Vu(e){if(It.size===0)return e;const t=Date.now();let n=!1;const r=e.filter(i=>{const s=It.get(i.key),o=It.get(i.friendlyId);return s&&s.expiresAt<=t||o&&o.expiresAt<=t?(s&&s.expiresAt<=t&&It.delete(i.key),o&&o.expiresAt<=t&&It.delete(i.friendlyId),!0):s||o?(n=!0,!1):!0});return n?r:e}function Xu(){const e=qt(),[t,n]=m.useState(!1),[r,i]=m.useState(null),s=go({mutationFn:async function(l){const c=new URLSearchParams;l.sessionKey&&c.set("sessionKey",l.sessionKey),l.friendlyId&&c.set("friendlyId",l.friendlyId);const u=await fetch(`/api/sessions?${c.toString()}`,{method:"DELETE"});if(!u.ok)throw new Error(await lt(u));return l},onMutate:async function(l){i(null),Wu(l.sessionKey||l.friendlyId),Bu(l.sessionKey,l.friendlyId),await e.cancelQueries({queryKey:ke.sessions});const c=e.getQueryData(ke.sessions);return Mc(e,l.sessionKey,l.friendlyId),l.isActive&&(l.sessionKey||l.friendlyId)&&Dr(e,l.friendlyId||l.sessionKey,l.sessionKey||l.friendlyId),{previousSessions:c,isActive:l.isActive}},onError:function(l,c,u){u?.previousSessions&&e.setQueryData(ke.sessions,u.previousSessions),Ku(c.sessionKey||c.friendlyId),i(l instanceof Error?l.message:String(l))},onSuccess:function(l){l.isActive&&Mn(),e.invalidateQueries({queryKey:ke.sessions})},onSettled:function(){n(!1)}});return{deleteSession:m.useCallback(async(a,l,c)=>{!a&&!l||(n(!0),await s.mutateAsync({sessionKey:a,friendlyId:l,isActive:c}))},[s]),deleting:t,error:r}}function Yu(){const e=qt(),[t,n]=m.useState(!1),[r,i]=m.useState(null),s=go({mutationFn:async function(l){const c=await fetch("/api/sessions",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({sessionKey:l.sessionKey,label:l.newTitle})});if(!c.ok)throw new Error(await lt(c));return l},onMutate:async function(l){i(null),await e.cancelQueries({queryKey:ke.sessions});const c=e.getQueryData(ke.sessions);return e.setQueryData(ke.sessions,function(f){return Array.isArray(f)?f.map(p=>p.key!==l.sessionKey?p:{...p,label:l.newTitle,title:l.newTitle}):f}),{previousSessions:c}},onError:function(l,c,u){u?.previousSessions&&e.setQueryData(ke.sessions,u.previousSessions),i(l instanceof Error?l.message:String(l))},onSuccess:function(){e.invalidateQueries({queryKey:ke.sessions})},onSettled:function(){n(!1)}});return{renameSession:m.useCallback(async(a,l)=>{!a||!l.trim()||(n(!0),await s.mutateAsync({sessionKey:a,newTitle:l.trim()}))},[s]),renaming:t,error:r}}const Gu=m.lazy(()=>Hn(()=>import("./settings-dialog-BA5FjiyP.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])).then(e=>({default:e.SettingsDialog}))),Qu=m.lazy(()=>Hn(()=>import("./session-export-dialog-DRlJwhMa.js"),__vite__mapDeps([18,1,3,2,4,5,6,7,8,9])).then(e=>({default:e.SessionExportDialog})));function Ju({sessions:e,activeFriendlyId:t,activeSessionKey:n,isStreaming:r=!1,creatingSession:i,onCreateSession:s,isCollapsed:o,onToggleCollapse:a,onSelectSession:l,onActiveSessionDelete:c,onOpenSearch:u}){const{settingsOpen:f,setSettingsOpen:p,pathsLoading:d,pathsError:g,paths:y,handleOpenSettings:k,closeSettings:w,copySessionsDir:S,copyStorePath:E}=Fu(),{deleteSession:N}=Xu(),{renameSession:M}=Yu(),v={duration:.15,ease:o?"easeIn":"easeOut"},[F,U]=m.useState(!1),[D,C]=m.useState(null),[z,j]=m.useState(""),[_,R]=m.useState(!1),[T,B]=m.useState(null),[I,H]=m.useState(null),[L,x]=m.useState(""),[K,V]=m.useState(!1),[b,J]=m.useState(null),[Z,Y]=m.useState(null),[ae,se]=m.useState(""),ee=qt();function le($){C($.key),j($.label||$.title||$.derivedTitle||""),U(!0)}function me($){D&&M(D,$),U(!1),C(null)}function Se($){B($.key),H($.friendlyId),x($.label||$.title||$.derivedTitle||$.friendlyId),R(!0)}function we(){if(T&&I){const $=I===t;$&&c&&c(),N(T,I,$)}R(!1),B(null),H(null)}function xe($){J($.key),Y($.friendlyId),se($.label||$.title||$.derivedTitle||$.friendlyId),V(!0)}function Ee($){if(b&&Z){const re=ke.history(Z,b),ge=ee.getQueryData(re);ge?.messages&&Oc(ae,ge.messages,$)}V(!1),J(null),Y(null)}const W={className:"border-r border-primary-200 h-full overflow-hidden bg-primary-100 flex flex-col"};return h.jsxs(Fe.aside,{initial:!1,animate:{width:o?48:"var(--opencami-sidebar-width)"},transition:v,className:W.className,children:[h.jsxs(Fe.div,{layout:!0,transition:{layout:v},className:q("flex items-center h-12 px-2 justify-between"),children:[h.jsx(ut,{initial:!1,children:o?null:h.jsx(Fe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:v,children:h.jsxs(St,{to:"/new",className:q(Vt({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start"),children:[h.jsx(fc,{className:"size-5"}),h.jsx(hc,{})]})})}),h.jsx(pt,{children:h.jsxs(dt,{children:[h.jsx(mt,{onClick:a,render:h.jsx(Ce,{size:"icon-sm",variant:"ghost",children:h.jsx(ne,{icon:Ml,size:20,strokeWidth:1.5})})}),h.jsx(gt,{side:"right",children:o?"Open Sidebar":"Close Sidebar"})]})})]}),h.jsxs("div",{className:"px-2 mb-4 flex flex-col gap-1",children:[h.jsxs(Fe.div,{layout:!0,transition:{layout:v},className:"w-full space-y-2",children:[h.jsxs(Ce,{disabled:i,variant:"ghost",size:"sm",onClick:s,onMouseUp:l,className:"w-full pl-1.5 justify-start",children:[h.jsx(ne,{icon:Dl,size:20,strokeWidth:1.5,className:"min-w-5"}),h.jsx(ut,{initial:!1,mode:"wait",children:!o&&h.jsx(Fe.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:v,className:"overflow-hidden whitespace-nowrap",children:"New Session"})})]}),h.jsx(pt,{children:h.jsxs(dt,{children:[h.jsx(mt,{asChild:!0,children:h.jsxs(St,{to:"/files",className:q(Vt({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start"),onClick:l,children:[h.jsx(ne,{icon:zl,size:20,strokeWidth:1.5,className:"min-w-5"}),h.jsx(ut,{initial:!1,mode:"wait",children:!o&&h.jsx(Fe.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:v,className:"overflow-hidden whitespace-nowrap",children:"Files"})})]})}),o&&h.jsx(gt,{side:"right",children:"Files"})]})}),(()=>{try{return localStorage.getItem("opencami-skills-browser")==="true"}catch{return!1}})()&&h.jsx(pt,{children:h.jsxs(dt,{children:[h.jsx(mt,{asChild:!0,children:h.jsxs(St,{to:"/skills",className:q(Vt({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start"),onClick:l,children:[h.jsx(ne,{icon:Pl,size:20,strokeWidth:1.5,className:"min-w-5"}),h.jsx(ut,{initial:!1,mode:"wait",children:!o&&h.jsx(Fe.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:v,className:"overflow-hidden whitespace-nowrap",children:"Skills"})})]})}),o&&h.jsx(gt,{side:"right",children:"Skills"})]})}),(()=>{try{return localStorage.getItem("opencami-agent-manager")==="true"}catch{return!1}})()&&h.jsx(pt,{children:h.jsxs(dt,{children:[h.jsx(mt,{asChild:!0,children:h.jsxs(St,{to:"/agents",className:q(Vt({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start"),onClick:l,children:[h.jsx(ne,{icon:ro,size:20,strokeWidth:1.5,className:"min-w-5"}),h.jsx(ut,{initial:!1,mode:"wait",children:!o&&h.jsx(Fe.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:v,className:"overflow-hidden whitespace-nowrap",children:"Agents"})})]})}),o&&h.jsx(gt,{side:"right",children:"Agents"})]})}),(()=>{try{return localStorage.getItem("opencami-cron-manager")==="true"}catch{return!1}})()&&h.jsx(pt,{children:h.jsxs(dt,{children:[h.jsx(mt,{asChild:!0,children:h.jsxs(St,{to:"/bots",className:q(Vt({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start"),onClick:l,children:[h.jsx(ne,{icon:_l,size:20,strokeWidth:1.5,className:"min-w-5"}),h.jsx(ut,{initial:!1,mode:"wait",children:!o&&h.jsx(Fe.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:v,className:"overflow-hidden whitespace-nowrap",children:"Cron Jobs"})})]})}),o&&h.jsx(gt,{side:"right",children:"Cron Jobs"})]})})]}),h.jsx(Fe.div,{layout:!0,transition:{layout:v},className:"w-full",children:h.jsxs(Ce,{variant:"ghost",size:"sm",onClick:u,className:"w-full pl-1.5 justify-start",children:[h.jsx(ne,{icon:io,size:20,strokeWidth:1.5,className:"min-w-5"}),h.jsx(ut,{initial:!1,mode:"wait",children:!o&&h.jsx(Fe.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:v,className:"overflow-hidden whitespace-nowrap",children:"Search"})})]})})]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:h.jsx(ut,{initial:!1,children:!o&&h.jsx(Fe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:v,className:"pt-0 flex flex-col w-full min-h-0 h-full",children:h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx(_u,{sessions:e,activeFriendlyId:t,activeSessionKey:n,isStreaming:r,onSelect:l,onRename:le,onDelete:Se,onExport:xe})})},"content")})}),h.jsx("div",{className:"px-2 py-3 border-t border-primary-200 bg-primary-100",children:h.jsx(Fe.div,{layout:!0,transition:{layout:v},className:"w-full",children:h.jsxs(Ce,{variant:"ghost",size:"sm",onClick:k,title:o?"Settings":void 0,className:"w-full justify-start pl-1.5",children:[h.jsx(ne,{icon:Ol,size:20,strokeWidth:1.5,className:"min-w-5"}),h.jsx(ut,{initial:!1,mode:"wait",children:!o&&h.jsx(Fe.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:v,className:"overflow-hidden whitespace-nowrap",children:"Settings"})})]})})}),f&&h.jsx(m.Suspense,{fallback:null,children:h.jsx(Gu,{open:f,onOpenChange:p,pathsLoading:d,pathsError:g,paths:y,onClose:w,onCopySessionsDir:S,onCopyStorePath:E})}),h.jsx($c,{open:F,onOpenChange:U,sessionTitle:z,onSave:me,onCancel:()=>U(!1)}),h.jsx(Xc,{open:_,onOpenChange:R,sessionTitle:L,onConfirm:we,onCancel:()=>R(!1)}),K&&h.jsx(m.Suspense,{fallback:null,children:h.jsx(Qu,{open:K,onOpenChange:V,sessionTitle:ae,onExport:Ee,onCancel:()=>V(!1)})})]})}function Zu(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const r=e[n],i=t[n];if(r.key!==i.key||r.friendlyId!==i.friendlyId||r.label!==i.label||r.title!==i.title||r.derivedTitle!==i.derivedTitle||r.updatedAt!==i.updatedAt||r.kind!==i.kind||r.status!==i.status||r.lastMessage!==i.lastMessage)return!1}return!0}function ef(e,t){return!(e.activeFriendlyId!==t.activeFriendlyId||e.activeSessionKey!==t.activeSessionKey||e.isStreaming!==t.isStreaming||e.creatingSession!==t.creatingSession||e.isCollapsed!==t.isCollapsed||!Zu(e.sessions,t.sessions))}const tf=m.memo(Ju,ef);function Vi(e){if(e<=0)return"0";if(e>=1e6){const t=e/1e6,n=t.toFixed(1);return n.endsWith(".0")?`${Math.round(t)}M`:`${n}M`}if(e>=1e5)return`${Math.round(e/1e3)}K`;if(e>=1e4)return`${Math.round(e/1e3)}K`;if(e>=1e3){const t=e/1e3,n=t.toFixed(1);return n.endsWith(".0")?`${Math.round(t)}K`:`${n}K`}return String(Math.round(e))}function Xi(e){return e>=90?{bar:"bg-red-500",text:"text-red-600 dark:text-red-400"}:e>=70?{bar:"bg-yellow-500",text:"text-yellow-600 dark:text-yellow-400"}:{bar:"bg-emerald-500",text:"text-emerald-600 dark:text-emerald-400"}}function nf({totalTokens:e,contextTokens:t,className:n}){const{percentage:r,usedStr:i,maxStr:s,colors:o,hasData:a,isNearlyFull:l}=m.useMemo(()=>{if(typeof t!="number"||t<=0)return{percentage:0,usedStr:"",maxStr:"",colors:Xi(0),hasData:!1,isNearlyFull:!1};const f=typeof e=="number"&&e>0?e:0,p=Math.min(100,Math.round(f/t*100));return{percentage:p,usedStr:Vi(f),maxStr:Vi(t),colors:Xi(p),hasData:!0,isNearlyFull:p>=95}},[e,t]);if(!a)return null;const c=typeof e=="number"&&e>0?e.toLocaleString():"0",u=typeof t=="number"?t.toLocaleString():"0";return h.jsxs("div",{className:q("group relative flex items-center gap-1.5",n),title:`Context: ${c} / ${u} tokens (${r}%)`,children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("div",{className:"w-12 h-1.5 rounded-full bg-primary-200 dark:bg-primary-700 overflow-hidden shrink-0 group-hover:h-2 transition-all",children:h.jsx("div",{className:q("h-full rounded-full transition-all duration-500 ease-out",o.bar,l&&"animate-pulse"),style:{width:`${r}%`}})}),h.jsx("span",{className:q("text-[10px] leading-none font-medium tabular-nums whitespace-nowrap",l?o.text:"text-primary-500 dark:text-primary-400"),children:i})]}),h.jsx("div",{className:q("absolute right-0 top-full mt-1 z-50","pointer-events-none opacity-0 scale-95","group-hover:pointer-events-auto group-hover:opacity-100 group-hover:scale-100","transition-all duration-150 origin-top-right"),children:h.jsxs("div",{className:q("rounded-md border border-primary-200 dark:border-primary-700","bg-surface shadow-lg px-3 py-2","text-xs whitespace-nowrap"),children:[h.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[h.jsx("span",{className:"text-primary-500 dark:text-primary-400",children:"Context window"}),h.jsxs("span",{className:q("font-semibold",o.text),children:[r,"%"]})]}),h.jsxs("div",{className:"flex items-center gap-1.5 text-primary-700 dark:text-primary-300",children:[h.jsx("span",{className:"font-medium",children:i}),h.jsx("span",{className:"text-primary-400",children:"/"}),h.jsx("span",{children:s}),h.jsx("span",{className:"text-primary-400",children:"tokens"})]}),h.jsx("div",{className:"w-full h-1.5 rounded-full bg-primary-200 dark:bg-primary-700 overflow-hidden mt-1.5",children:h.jsx("div",{className:q("h-full rounded-full transition-all duration-500 ease-out",o.bar),style:{width:`${r}%`}})}),l&&h.jsx("div",{className:"mt-1.5 text-[10px] text-red-500 dark:text-red-400 font-medium",children:"⚠ Context nearly full — consider /compact"})]})})]})}const rf=m.memo(nf);function sf({activeTitle:e,wrapperRef:t,showSidebarButton:n=!1,onOpenSidebar:r,totalTokens:i,contextTokens:s}){return h.jsxs("div",{ref:t,"data-tauri-drag-region":!0,className:"border-b border-primary-200 px-4 h-12 flex min-w-0 items-center overflow-x-hidden bg-surface tauri-drag-header",children:[n?h.jsx(Ce,{size:"icon-sm",variant:"ghost",onClick:r,className:"mr-2 text-primary-800 hover:bg-primary-100",style:{WebkitAppRegion:"no-drag"},"aria-label":"Open sidebar",children:h.jsx(ne,{icon:Fl,size:18,strokeWidth:1.6})}):null,h.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:h.jsx("div",{className:"truncate text-sm font-medium",children:e})}),h.jsx(rf,{totalTokens:i,contextTokens:s,className:"ml-3 hidden sm:flex"})]})}const of=m.memo(sf);function af(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function lf(e){const t=new Date(e);return af(t,new Date)?new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit"}).format(t):new Intl.DateTimeFormat("en-GB",{day:"2-digit",month:"short"}).format(t)}function cf(e){return new Intl.DateTimeFormat("en-GB",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date(e))}function uf({timestamp:e}){const t=lf(e),n=cf(e);return h.jsx(pt,{children:h.jsxs(dt,{children:[h.jsx(mt,{className:"inline-flex items-center text-xs text-primary-600",children:t}),h.jsx(gt,{side:"top",children:n})]})})}function ff({text:e,align:t,timestamp:n,forceVisible:r=!1}){const[i,s]=m.useState(!1),[o,a]=m.useState("idle"),l=m.useRef(null),c=m.useRef(null),u=m.useRef(null),[f,p]=m.useState(()=>{if(typeof window>"u")return!0;try{const w=localStorage.getItem("opencami-tts-enabled");return w===null?!0:w==="true"}catch{return!0}});m.useEffect(()=>{function w(S){S.key==="opencami-tts-enabled"&&p(S.newValue===null?!0:S.newValue==="true")}return window.addEventListener("storage",w),()=>window.removeEventListener("storage",w)},[]),m.useEffect(()=>()=>{u.current?.abort(),l.current&&(l.current.pause(),l.current=null),c.current&&(URL.revokeObjectURL(c.current),c.current=null)},[]);const d=async()=>{try{await navigator.clipboard.writeText(e),s(!0),window.setTimeout(()=>s(!1),1400)}catch{s(!1)}},g=async()=>{if(o==="playing"){u.current?.abort(),l.current&&(l.current.pause(),l.current=null),c.current&&(URL.revokeObjectURL(c.current),c.current=null),a("idle");return}u.current?.abort();const w=new AbortController;u.current=w,a("loading");try{const S=await fetch("/api/tts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:e}),signal:w.signal});if(!S.ok)throw new Error("TTS failed");const E=await S.blob(),N=URL.createObjectURL(E);c.current=N;const M=new Audio(N);l.current=M,M.onended=()=>{a("idle"),c.current&&(URL.revokeObjectURL(c.current),c.current=null),l.current=null},M.onerror=()=>{a("idle"),c.current&&(URL.revokeObjectURL(c.current),c.current=null),l.current=null},await M.play(),a("playing")}catch(S){if(S instanceof Error&&S.name==="AbortError"){a("idle");return}a("idle"),c.current&&(URL.revokeObjectURL(c.current),c.current=null),l.current=null}},y=t==="end"?"justify-end":"justify-start",k=t==="start"&&f&&e.trim().length>0;return h.jsxs("div",{className:q("flex items-center gap-2 text-xs text-primary-600 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 duration-100 ease-out",r?"opacity-100":"opacity-0",y),children:[h.jsx(pt,{children:h.jsxs(dt,{children:[h.jsx(mt,{type:"button",onClick:()=>{d().catch(()=>{})},className:"inline-flex items-center justify-center rounded border border-transparent bg-transparent p-1 text-primary-700 hover:text-primary-900 hover:bg-primary-100",children:h.jsx(ne,{icon:i?Jr:$l,size:16,strokeWidth:1.6})}),h.jsx(gt,{side:"top",children:"Copy"})]})}),k&&h.jsx(pt,{children:h.jsxs(dt,{children:[h.jsx(mt,{type:"button",onClick:()=>{g().catch(()=>{})},disabled:o==="loading",className:q("inline-flex items-center justify-center rounded border border-transparent bg-transparent p-1 text-primary-700 hover:text-primary-900 hover:bg-primary-100",o==="loading"&&"opacity-60 cursor-wait"),children:h.jsx(ne,{icon:o==="loading"?Bl:o==="playing"?so:Hl,size:16,strokeWidth:1.6,className:q(o==="loading"&&"animate-spin")})}),h.jsx(gt,{side:"top",children:o==="loading"?"Generating speech…":o==="playing"?"Stop":"Listen"})]})}),h.jsx(uf,{timestamp:n})]})}function si(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Dt=si();function Mo(e){Dt=e}var rn={exec:()=>null};function fe(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(_e.caret,"$1"),n=n.replace(i,o),r},getRegex:()=>new RegExp(n,t)};return r}var hf=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),_e={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},pf=/^(?:[ \t]*(?:\n|$))+/,df=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,mf=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,un=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,gf=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,oi=/(?:[*+-]|\d{1,9}[.)])/,Do=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,zo=fe(Do).replace(/bull/g,oi).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),xf=fe(Do).replace(/bull/g,oi).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),ai=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,yf=/^[^\n]+/,li=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,bf=fe(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",li).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),wf=fe(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,oi).getRegex(),Xn="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|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ci=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,kf=fe("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",ci).replace("tag",Xn).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Po=fe(ai).replace("hr",un).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Xn).getRegex(),Sf=fe(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Po).getRegex(),ui={blockquote:Sf,code:df,def:bf,fences:mf,heading:gf,hr:un,html:kf,lheading:zo,list:wf,newline:pf,paragraph:Po,table:rn,text:yf},Yi=fe("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",un).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Xn).getRegex(),vf={...ui,lheading:xf,table:Yi,paragraph:fe(ai).replace("hr",un).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Yi).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Xn).getRegex()},Cf={...ui,html:fe(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ci).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:rn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:fe(ai).replace("hr",un).replace("heading",` *#{1,6} *[^
9
+ ]`).replace("lheading",zo).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Ef=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Tf=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,_o=/^( {2,}|\\)\n(?!\s*$)/,jf=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Yn=/[\p{P}\p{S}]/u,fi=/[\s\p{P}\p{S}]/u,Oo=/[^\s\p{P}\p{S}]/u,Af=fe(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,fi).getRegex(),Fo=/(?!~)[\p{P}\p{S}]/u,If=/(?!~)[\s\p{P}\p{S}]/u,Rf=/(?:[^\s\p{P}\p{S}]|~)/u,Nf=fe(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",hf?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),$o=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Lf=fe($o,"u").replace(/punct/g,Yn).getRegex(),Mf=fe($o,"u").replace(/punct/g,Fo).getRegex(),Bo="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Df=fe(Bo,"gu").replace(/notPunctSpace/g,Oo).replace(/punctSpace/g,fi).replace(/punct/g,Yn).getRegex(),zf=fe(Bo,"gu").replace(/notPunctSpace/g,Rf).replace(/punctSpace/g,If).replace(/punct/g,Fo).getRegex(),Pf=fe("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Oo).replace(/punctSpace/g,fi).replace(/punct/g,Yn).getRegex(),_f=fe(/\\(punct)/,"gu").replace(/punct/g,Yn).getRegex(),Of=fe(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Ff=fe(ci).replace("(?:-->|$)","-->").getRegex(),$f=fe("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Ff).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Dn=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Bf=fe(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Dn).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ho=fe(/^!?\[(label)\]\[(ref)\]/).replace("label",Dn).replace("ref",li).getRegex(),Uo=fe(/^!?\[(ref)\](?:\[\])?/).replace("ref",li).getRegex(),Hf=fe("reflink|nolink(?!\\()","g").replace("reflink",Ho).replace("nolink",Uo).getRegex(),Gi=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,hi={_backpedal:rn,anyPunctuation:_f,autolink:Of,blockSkip:Nf,br:_o,code:Tf,del:rn,emStrongLDelim:Lf,emStrongRDelimAst:Df,emStrongRDelimUnd:Pf,escape:Ef,link:Bf,nolink:Uo,punctuation:Af,reflink:Ho,reflinkSearch:Hf,tag:$f,text:jf,url:rn},Uf={...hi,link:fe(/^!?\[(label)\]\((.*?)\)/).replace("label",Dn).getRegex(),reflink:fe(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Dn).getRegex()},zr={...hi,emStrongRDelimAst:zf,emStrongLDelim:Mf,url:fe(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Gi).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:fe(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Gi).getRegex()},qf={...zr,br:fe(_o).replace("{2,}","*").getRegex(),text:fe(zr.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},gn={normal:ui,gfm:vf,pedantic:Cf},Yt={normal:hi,gfm:zr,breaks:qf,pedantic:Uf},Wf={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Qi=e=>Wf[e];function ht(e,t){if(t){if(_e.escapeTest.test(e))return e.replace(_e.escapeReplace,Qi)}else if(_e.escapeTestNoEncode.test(e))return e.replace(_e.escapeReplaceNoEncode,Qi);return e}function Ji(e){try{e=encodeURI(e).replace(_e.percentDecode,"%")}catch{return null}return e}function Zi(e,t){let n=e.replace(_e.findPipe,(s,o,a)=>{let l=!1,c=o;for(;--c>=0&&a[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(_e.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(_e.slashPipe,"|");return r}function Gt(e,t,n){let r=e.length;if(r===0)return"";let i=0;for(;i<r&&e.charAt(r-i-1)===t;)i++;return e.slice(0,r-i)}function Kf(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function es(e,t,n,r,i){let s=t.href,o=t.title||null,a=e[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:s,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,l}function Vf(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
10
+ `).map(s=>{let o=s.match(n.other.beginningSpace);if(o===null)return s;let[a]=o;return a.length>=i.length?s.slice(i.length):s}).join(`
11
+ `)}var zn=class{options;rules;lexer;constructor(e){this.options=e||Dt}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Gt(n,`
12
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=Vf(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=Gt(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Gt(t[0],`
13
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Gt(t[0],`
14
+ `).split(`
15
+ `),r="",i="",s=[];for(;n.length>0;){let o=!1,a=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))a.push(n[l]),o=!0;else if(!o)a.push(n[l]);else break;n=n.slice(l);let c=a.join(`
16
+ `),u=c.replace(this.rules.other.blockquoteSetextReplace,`
17
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
18
+ ${c}`:c,i=i?`${i}
19
+ ${u}`:u;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,s,!0),this.lexer.state.top=f,n.length===0)break;let p=s.at(-1);if(p?.type==="code")break;if(p?.type==="blockquote"){let d=p,g=d.raw+`
20
+ `+n.join(`
21
+ `),y=this.blockquote(g);s[s.length-1]=y,r=r.substring(0,r.length-d.raw.length)+y.raw,i=i.substring(0,i.length-d.text.length)+y.text;break}else if(p?.type==="list"){let d=p,g=d.raw+`
22
+ `+n.join(`
23
+ `),y=this.list(g);s[s.length-1]=y,r=r.substring(0,r.length-p.raw.length)+y.raw,i=i.substring(0,i.length-d.raw.length)+y.raw,n=g.substring(s.at(-1).raw.length).split(`
24
+ `);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let s=this.rules.other.listItemRegex(n),o=!1;for(;e;){let l=!1,c="",u="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let f=t[2].split(`
25
+ `,1)[0].replace(this.rules.other.listReplaceTabs,y=>" ".repeat(3*y.length)),p=e.split(`
26
+ `,1)[0],d=!f.trim(),g=0;if(this.options.pedantic?(g=2,u=f.trimStart()):d?g=t[1].length+1:(g=t[2].search(this.rules.other.nonSpaceChar),g=g>4?1:g,u=f.slice(g),g+=t[1].length),d&&this.rules.other.blankLine.test(p)&&(c+=p+`
27
+ `,e=e.substring(p.length+1),l=!0),!l){let y=this.rules.other.nextBulletRegex(g),k=this.rules.other.hrRegex(g),w=this.rules.other.fencesBeginRegex(g),S=this.rules.other.headingBeginRegex(g),E=this.rules.other.htmlBeginRegex(g);for(;e;){let N=e.split(`
28
+ `,1)[0],M;if(p=N,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),M=p):M=p.replace(this.rules.other.tabCharGlobal," "),w.test(p)||S.test(p)||E.test(p)||y.test(p)||k.test(p))break;if(M.search(this.rules.other.nonSpaceChar)>=g||!p.trim())u+=`
29
+ `+M.slice(g);else{if(d||f.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||w.test(f)||S.test(f)||k.test(f))break;u+=`
30
+ `+p}!d&&!p.trim()&&(d=!0),c+=N+`
31
+ `,e=e.substring(N.length+1),f=M.slice(g)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(o=!0)),i.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),i.raw+=c}let a=i.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let l of i.items){if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),l.task){if(l.text=l.text.replace(this.rules.other.listReplaceTask,""),l.tokens[0]?.type==="text"||l.tokens[0]?.type==="paragraph"){l.tokens[0].raw=l.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),l.tokens[0].text=l.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let u=this.lexer.inlineQueue.length-1;u>=0;u--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[u].src)){this.lexer.inlineQueue[u].src=this.lexer.inlineQueue[u].src.replace(this.rules.other.listReplaceTask,"");break}}let c=this.rules.other.listTaskCheckbox.exec(l.raw);if(c){let u={type:"checkbox",raw:c[0]+" ",checked:c[0]!=="[ ]"};l.checked=u.checked,i.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=u.raw+l.tokens[0].raw,l.tokens[0].text=u.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(u)):l.tokens.unshift({type:"paragraph",raw:u.raw,text:u.raw,tokens:[u]}):l.tokens.unshift(u)}}if(!i.loose){let c=l.tokens.filter(f=>f.type==="space"),u=c.length>0&&c.some(f=>this.rules.other.anyLine.test(f.raw));i.loose=u}}if(i.loose)for(let l of i.items){l.loose=!0;for(let c of l.tokens)c.type==="text"&&(c.type="paragraph")}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:r,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Zi(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
32
+ `):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let o of r)this.rules.other.tableAlignRight.test(o)?s.align.push("right"):this.rules.other.tableAlignCenter.test(o)?s.align.push("center"):this.rules.other.tableAlignLeft.test(o)?s.align.push("left"):s.align.push(null);for(let o=0;o<n.length;o++)s.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:s.align[o]});for(let o of i)s.rows.push(Zi(o,s.header.length).map((a,l)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:s.align[l]})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
33
+ `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let s=Gt(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{let s=Kf(t[2],"()");if(s===-2)return;if(s>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let r=t[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3])}else i=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),es(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[r.toLowerCase()];if(!i){let s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return es(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,s,o,a=i,l=0,c=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+i);(r=c.exec(t))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(o=[...s].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&i%3&&!((i+o)%3)){l+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+l);let u=[...r[0]][0].length,f=e.slice(0,i+r.index+u+o);if(Math.min(i,o)%2){let d=f.slice(1,-1);return{type:"em",raw:f,text:d,tokens:this.lexer.inlineTokens(d)}}let p=f.slice(2,-2);return{type:"strong",raw:f,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,r;if(t[2]==="@")n=t[0],r="mailto:"+n;else{let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0]}return{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},Je=class Pr{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Dt,this.options.tokenizer=this.options.tokenizer||new zn,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:_e,block:gn.normal,inline:Yt.normal};this.options.pedantic?(n.block=gn.pedantic,n.inline=Yt.pedantic):this.options.gfm&&(n.block=gn.gfm,this.options.breaks?n.inline=Yt.breaks:n.inline=Yt.gfm),this.tokenizer.rules=n}static get rules(){return{block:gn,inline:Yt}}static lex(t,n){return new Pr(n).lex(t)}static lexInline(t,n){return new Pr(n).inlineTokens(t)}lex(t){t=t.replace(_e.carriageReturn,`
34
+ `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],r=!1){for(this.options.pedantic&&(t=t.replace(_e.tabCharGlobal," ").replace(_e.spaceLine,""));t;){let i;if(this.options.extensions?.block?.some(o=>(i=o.call({lexer:this},t,n))?(t=t.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.space(t)){t=t.substring(i.raw.length);let o=n.at(-1);i.raw.length===1&&o!==void 0?o.raw+=`
35
+ `:n.push(i);continue}if(i=this.tokenizer.code(t)){t=t.substring(i.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
36
+ `)?"":`
37
+ `)+i.raw,o.text+=`
38
+ `+i.text,this.inlineQueue.at(-1).src=o.text):n.push(i);continue}if(i=this.tokenizer.fences(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.heading(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.hr(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.blockquote(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.list(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.html(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.def(t)){t=t.substring(i.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
39
+ `)?"":`
40
+ `)+i.raw,o.text+=`
41
+ `+i.raw,this.inlineQueue.at(-1).src=o.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},n.push(i));continue}if(i=this.tokenizer.table(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.lheading(t)){t=t.substring(i.raw.length),n.push(i);continue}let s=t;if(this.options.extensions?.startBlock){let o=1/0,a=t.slice(1),l;this.options.extensions.startBlock.forEach(c=>{l=c.call({lexer:this},a),typeof l=="number"&&l>=0&&(o=Math.min(o,l))}),o<1/0&&o>=0&&(s=t.substring(0,o+1))}if(this.state.top&&(i=this.tokenizer.paragraph(s))){let o=n.at(-1);r&&o?.type==="paragraph"?(o.raw+=(o.raw.endsWith(`
42
+ `)?"":`
43
+ `)+i.raw,o.text+=`
44
+ `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(i),r=s.length!==t.length,t=t.substring(i.raw.length);continue}if(i=this.tokenizer.text(t)){t=t.substring(i.raw.length);let o=n.at(-1);o?.type==="text"?(o.raw+=(o.raw.endsWith(`
45
+ `)?"":`
46
+ `)+i.raw,o.text+=`
47
+ `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(i);continue}if(t){let o="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r=t,i=null;if(this.tokens.links){let l=Object.keys(this.tokens.links);if(l.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)l.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)s=i[2]?i[2].length:0,r=r.slice(0,i.index+s)+"["+"a".repeat(i[0].length-s-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let o=!1,a="";for(;t;){o||(a=""),o=!1;let l;if(this.options.extensions?.inline?.some(u=>(l=u.call({lexer:this},t,n))?(t=t.substring(l.raw.length),n.push(l),!0):!1))continue;if(l=this.tokenizer.escape(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.tag(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.link(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(l.raw.length);let u=n.at(-1);l.type==="text"&&u?.type==="text"?(u.raw+=l.raw,u.text+=l.text):n.push(l);continue}if(l=this.tokenizer.emStrong(t,r,a)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.codespan(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.br(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.del(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.autolink(t)){t=t.substring(l.raw.length),n.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(t))){t=t.substring(l.raw.length),n.push(l);continue}let c=t;if(this.options.extensions?.startInline){let u=1/0,f=t.slice(1),p;this.options.extensions.startInline.forEach(d=>{p=d.call({lexer:this},f),typeof p=="number"&&p>=0&&(u=Math.min(u,p))}),u<1/0&&u>=0&&(c=t.substring(0,u+1))}if(l=this.tokenizer.inlineText(c)){t=t.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(a=l.raw.slice(-1)),o=!0;let u=n.at(-1);u?.type==="text"?(u.raw+=l.raw,u.text+=l.text):n.push(l);continue}if(t){let u="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return n}},Pn=class{options;parser;constructor(e){this.options=e||Dt}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(_e.notSpaceStart)?.[0],i=e.replace(_e.endingNewline,"")+`
48
+ `;return r?'<pre><code class="language-'+ht(r)+'">'+(n?i:ht(i,!0))+`</code></pre>
49
+ `:"<pre><code>"+(n?i:ht(i,!0))+`</code></pre>
50
+ `}blockquote({tokens:e}){return`<blockquote>
51
+ ${this.parser.parse(e)}</blockquote>
52
+ `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
53
+ `}hr(e){return`<hr>
54
+ `}list(e){let t=e.ordered,n=e.start,r="";for(let o=0;o<e.items.length;o++){let a=e.items[o];r+=this.listitem(a)}let i=t?"ol":"ul",s=t&&n!==1?' start="'+n+'"':"";return"<"+i+s+`>
55
+ `+r+"</"+i+`>
56
+ `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
57
+ `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
58
+ `}table(e){let t="",n="";for(let i=0;i<e.header.length;i++)n+=this.tablecell(e.header[i]);t+=this.tablerow({text:n});let r="";for(let i=0;i<e.rows.length;i++){let s=e.rows[i];n="";for(let o=0;o<s.length;o++)n+=this.tablecell(s[o]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
59
+ <thead>
60
+ `+t+`</thead>
61
+ `+r+`</table>
62
+ `}tablerow({text:e}){return`<tr>
63
+ ${e}</tr>
64
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
65
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${ht(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Ji(e);if(i===null)return r;e=i;let s='<a href="'+e+'"';return t&&(s+=' title="'+ht(t)+'"'),s+=">"+r+"</a>",s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Ji(e);if(i===null)return ht(n);e=i;let s=`<img src="${e}" alt="${n}"`;return t&&(s+=` title="${ht(t)}"`),s+=">",s}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:ht(e.text)}},pi=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Ze=class _r{options;renderer;textRenderer;constructor(t){this.options=t||Dt,this.options.renderer=this.options.renderer||new Pn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new pi}static parse(t,n){return new _r(n).parse(t)}static parseInline(t,n){return new _r(n).parseInline(t)}parse(t){let n="";for(let r=0;r<t.length;r++){let i=t[r];if(this.options.extensions?.renderers?.[i.type]){let o=i,a=this.options.extensions.renderers[o.type].call({parser:this},o);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){n+=a||"";continue}}let s=i;switch(s.type){case"space":{n+=this.renderer.space(s);break}case"hr":{n+=this.renderer.hr(s);break}case"heading":{n+=this.renderer.heading(s);break}case"code":{n+=this.renderer.code(s);break}case"table":{n+=this.renderer.table(s);break}case"blockquote":{n+=this.renderer.blockquote(s);break}case"list":{n+=this.renderer.list(s);break}case"checkbox":{n+=this.renderer.checkbox(s);break}case"html":{n+=this.renderer.html(s);break}case"def":{n+=this.renderer.def(s);break}case"paragraph":{n+=this.renderer.paragraph(s);break}case"text":{n+=this.renderer.text(s);break}default:{let o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(t,n=this.renderer){let r="";for(let i=0;i<t.length;i++){let s=t[i];if(this.options.extensions?.renderers?.[s.type]){let a=this.options.extensions.renderers[s.type].call({parser:this},s);if(a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){r+=a||"";continue}}let o=s;switch(o.type){case"escape":{r+=n.text(o);break}case"html":{r+=n.html(o);break}case"link":{r+=n.link(o);break}case"image":{r+=n.image(o);break}case"checkbox":{r+=n.checkbox(o);break}case"strong":{r+=n.strong(o);break}case"em":{r+=n.em(o);break}case"codespan":{r+=n.codespan(o);break}case"br":{r+=n.br(o);break}case"del":{r+=n.del(o);break}case"text":{r+=n.text(o);break}default:{let a='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return r}},tn=class{options;block;constructor(e){this.options=e||Dt}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Je.lex:Je.lexInline}provideParser(){return this.block?Ze.parse:Ze.parseInline}},Xf=class{defaults=si();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ze;Renderer=Pn;TextRenderer=pi;Lexer=Je;Tokenizer=zn;Hooks=tn;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{let i=r;for(let s of i.header)n=n.concat(this.walkTokens(s.tokens,t));for(let s of i.rows)for(let o of s)n=n.concat(this.walkTokens(o.tokens,t));break}case"list":{let i=r;n=n.concat(this.walkTokens(i.items,t));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(s=>{let o=i[s].flat(1/0);n=n.concat(this.walkTokens(o,t))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=t.renderers[i.name];s?t.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=s.apply(this,o)),a}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[i.level];s?s.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),r.extensions=t),n.renderer){let i=this.defaults.renderer||new Pn(this.defaults);for(let s in n.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=n.renderer[o],l=i[o];i[o]=(...c)=>{let u=a.apply(i,c);return u===!1&&(u=l.apply(i,c)),u||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new zn(this.defaults);for(let s in n.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=n.tokenizer[o],l=i[o];i[o]=(...c)=>{let u=a.apply(i,c);return u===!1&&(u=l.apply(i,c)),u}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new tn;for(let s in n.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=n.hooks[o],l=i[o];tn.passThroughHooks.has(s)?i[o]=c=>{if(this.defaults.async&&tn.passThroughHooksRespectAsync.has(s))return(async()=>{let f=await a.call(i,c);return l.call(i,f)})();let u=a.call(i,c);return l.call(i,u)}:i[o]=(...c)=>{if(this.defaults.async)return(async()=>{let f=await a.apply(i,c);return f===!1&&(f=await l.apply(i,c)),f})();let u=a.apply(i,c);return u===!1&&(u=l.apply(i,c)),u}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Je.lex(e,t??this.defaults)}parser(e,t){return Ze.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(t):t,a=await(i.hooks?await i.hooks.provideLexer():e?Je.lex:Je.lexInline)(o,i),l=i.hooks?await i.hooks.processAllTokens(a):a;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let c=await(i.hooks?await i.hooks.provideParser():e?Ze.parse:Ze.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(c):c})().catch(s);try{i.hooks&&(t=i.hooks.preprocess(t));let o=(i.hooks?i.hooks.provideLexer():e?Je.lex:Je.lexInline)(t,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():e?Ze.parse:Ze.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(e,t){return n=>{if(n.message+=`
66
+ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+ht(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},Lt=new Xf;function pe(e,t){return Lt.parse(e,t)}pe.options=pe.setOptions=function(e){return Lt.setOptions(e),pe.defaults=Lt.defaults,Mo(pe.defaults),pe};pe.getDefaults=si;pe.defaults=Dt;pe.use=function(...e){return Lt.use(...e),pe.defaults=Lt.defaults,Mo(pe.defaults),pe};pe.walkTokens=function(e,t){return Lt.walkTokens(e,t)};pe.parseInline=Lt.parseInline;pe.Parser=Ze;pe.parser=Ze.parse;pe.Renderer=Pn;pe.TextRenderer=pi;pe.Lexer=Je;pe.lexer=Je.lex;pe.Tokenizer=zn;pe.Hooks=tn;pe.parse=pe;pe.options;pe.setOptions;pe.use;pe.walkTokens;pe.parseInline;Ze.parse;Je.lex;const Yf=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Gf=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Qf={};function ts(e,t){return(Qf.jsx?Gf:Yf).test(e)}const Jf={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"};var Ot={},fr,ns;function Zf(){if(ns)return fr;ns=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,a=/^\s+|\s+$/g,l=`
67
+ `,c="/",u="*",f="",p="comment",d="declaration";function g(k,w){if(typeof k!="string")throw new TypeError("First argument must be a string");if(!k)return[];w=w||{};var S=1,E=1;function N(R){var T=R.match(t);T&&(S+=T.length);var B=R.lastIndexOf(l);E=~B?R.length-B:E+R.length}function M(){var R={line:S,column:E};return function(T){return T.position=new v(R),D(),T}}function v(R){this.start=R,this.end={line:S,column:E},this.source=w.source}v.prototype.content=k;function F(R){var T=new Error(w.source+":"+S+":"+E+": "+R);if(T.reason=R,T.filename=w.source,T.line=S,T.column=E,T.source=k,!w.silent)throw T}function U(R){var T=R.exec(k);if(T){var B=T[0];return N(B),k=k.slice(B.length),T}}function D(){U(n)}function C(R){var T;for(R=R||[];T=z();)T!==!1&&R.push(T);return R}function z(){var R=M();if(!(c!=k.charAt(0)||u!=k.charAt(1))){for(var T=2;f!=k.charAt(T)&&(u!=k.charAt(T)||c!=k.charAt(T+1));)++T;if(T+=2,f===k.charAt(T-1))return F("End of comment missing");var B=k.slice(2,T-2);return E+=2,N(B),k=k.slice(T),E+=2,R({type:p,comment:B})}}function j(){var R=M(),T=U(r);if(T){if(z(),!U(i))return F("property missing ':'");var B=U(s),I=R({type:d,property:y(T[0].replace(e,f)),value:B?y(B[0].replace(e,f)):f});return U(o),I}}function _(){var R=[];C(R);for(var T;T=j();)T!==!1&&(R.push(T),C(R));return R}return D(),_()}function y(k){return k?k.replace(a,f):f}return fr=g,fr}var rs;function eh(){if(rs)return Ot;rs=1;var e=Ot&&Ot.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.default=n;const t=e(Zf());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const o=(0,t.default)(r),a=typeof i=="function";return o.forEach(l=>{if(l.type!=="declaration")return;const{property:c,value:u}=l;a?i(c,u,l):u&&(s=s||{},s[c]=u)}),s}return Ot}var Qt={},is;function th(){if(is)return Qt;is=1,Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(c){return!c||n.test(c)||e.test(c)},o=function(c,u){return u.toUpperCase()},a=function(c,u){return"".concat(u,"-")},l=function(c,u){return u===void 0&&(u={}),s(c)?c:(c=c.toLowerCase(),u.reactCompat?c=c.replace(i,a):c=c.replace(r,a),c.replace(t,o))};return Qt.camelCase=l,Qt}var Jt,ss;function nh(){if(ss)return Jt;ss=1;var e=Jt&&Jt.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(eh()),n=th();function r(i,s){var o={};return!i||typeof i!="string"||(0,t.default)(i,function(a,l){a&&l&&(o[(0,n.camelCase)(a,s)]=l)}),o}return r.default=r,Jt=r,Jt}var rh=nh();const ih=Zs(rh),qo=Wo("end"),di=Wo("start");function Wo(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 sh(e){const t=di(e),n=qo(e);if(t&&n)return{start:t,end:n}}function sn(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?os(e.position):"start"in e||"end"in e?os(e):"line"in e||"column"in e?Or(e):""}function Or(e){return as(e&&e.line)+":"+as(e&&e.column)}function os(e){return Or(e&&e.start)+"-"+Or(e&&e.end)}function as(e){return e&&typeof e=="number"?e:1}class De extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!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&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=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=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=sn(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=o&&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}}De.prototype.file="";De.prototype.name="";De.prototype.reason="";De.prototype.message="";De.prototype.stack="";De.prototype.column=void 0;De.prototype.line=void 0;De.prototype.ancestors=void 0;De.prototype.cause=void 0;De.prototype.fatal=void 0;De.prototype.place=void 0;De.prototype.ruleId=void 0;De.prototype.source=void 0;const mi={}.hasOwnProperty,oh=new Map,ah=/[A-Z]/g,lh=new Set(["table","tbody","thead","tfoot","tr"]),ch=new Set(["td","th"]),Ko="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function uh(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=yh(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=xh(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"?ti:mc,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=Vo(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function Vo(e,t,n){if(t.type==="element")return fh(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return hh(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return dh(e,t,n);if(t.type==="mdxjsEsm")return ph(e,t);if(t.type==="root")return mh(e,t,n);if(t.type==="text")return gh(e,t)}function fh(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=ti,e.schema=i),e.ancestors.push(t);const s=Yo(e,t.tagName,!1),o=bh(e,t);let a=xi(e,t);return lh.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!gc(l):!0})),Xo(e,o,s,t),gi(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function hh(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}ln(e,t.position)}function ph(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ln(e,t.position)}function dh(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=ti,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:Yo(e,t.name,!0),o=wh(e,t),a=xi(e,t);return Xo(e,o,s,t),gi(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function mh(e,t,n){const r={};return gi(r,xi(e,t)),e.create(t,e.Fragment,r,n)}function gh(e,t){return t.value}function Xo(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 xh(e,t,n){return r;function r(i,s,o,a){const c=Array.isArray(o.children)?n:t;return a?c(s,o,a):c(s,o)}}function yh(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=di(r);return t(i,s,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function bh(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&mi.call(t.properties,i)){const s=kh(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&ch.has(t.tagName)?r=a:n[o]=a}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function wh(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];s.type;const o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else ln(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 a=r.value.data.estree.body[0];a.type,s=e.evaluater.evaluateExpression(a.expression)}else ln(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function xi(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:oh;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const c=i.get(l)||0;o=l+"-"+c,i.set(l,c+1)}}const a=Vo(e,s,o);a!==void 0&&n.push(a)}return n}function kh(e,t,n){const r=xc(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?yc(n):bc(n)),r.property==="style"){let i=typeof n=="object"?n:Sh(e,String(n));return e.stylePropertyNameCase==="css"&&(i=vh(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Jf[r.property]||r.property:r.attribute,n]}}function Sh(e,t){try{return ih(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new De("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=Ko+"#cannot-parse-style-attribute",i}}function Yo(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const a=ts(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}else r=ts(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return mi.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);ln(e)}function ln(e,t){const n=new De("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=Ko+"#cannot-handle-mdx-estrees-without-createevaluater",n}function vh(e){const t={};let n;for(n in e)mi.call(e,n)&&(t[Ch(n)]=e[n]);return t}function Ch(e){let t=e.replace(ah,Eh);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Eh(e){return"-"+e.toLowerCase()}const hr={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"]},Th={};function yi(e,t){const n=Th,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Go(e,r,i)}function Go(e,t,n){if(jh(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 ls(e.children,t,n)}return Array.isArray(e)?ls(e,t,n):""}function ls(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=Go(e[i],t,n);return r.join("")}function jh(e){return!!(e&&typeof e=="object")}const cs=document.createElement("i");function bi(e){const t="&"+e+";";cs.innerHTML=t;const n=cs.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function He(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function Xe(e,t){return e.length>0?(He(e,e.length,0,t),e):t}const us={}.hasOwnProperty;function Qo(e){const t={};let n=-1;for(;++n<e.length;)Ah(t,e[n]);return t}function Ah(e,t){let n;for(n in t){const i=(us.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){us.call(i,o)||(i[o]=[]);const a=s[o];Ih(i[o],Array.isArray(a)?a:a?[a]:[])}}}function Ih(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);He(e,0,0,r)}function Jo(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 nt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Pe=jt(/[A-Za-z]/),Me=jt(/[\dA-Za-z]/),Rh=jt(/[#-'*+\--9=?A-Z^-~]/);function _n(e){return e!==null&&(e<32||e===127)}const Fr=jt(/\d/),Nh=jt(/[\dA-Fa-f]/),Lh=jt(/[!-/:-@[-`{-~]/);function Q(e){return e!==null&&e<-2}function de(e){return e!==null&&(e<0||e===32)}function oe(e){return e===-2||e===-1||e===32}const Gn=jt(new RegExp("\\p{P}|\\p{S}","u")),Mt=jt(/\s/);function jt(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Wt(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&Me(e.charCodeAt(n+1))&&Me(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function ue(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return oe(l)?(e.enter(n),a(l)):t(l)}function a(l){return oe(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const Mh={tokenize:Dh};function Dh(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),ue(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),s(a)}function s(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return Q(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const zh={tokenize:Ph},fs={tokenize:_h};function Ph(e){const t=this,n=[];let r=0,i,s,o;return a;function a(E){if(r<n.length){const N=n[r];return t.containerState=N[1],e.attempt(N[0].continuation,l,c)(E)}return c(E)}function l(E){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&S();const N=t.events.length;let M=N,v;for(;M--;)if(t.events[M][0]==="exit"&&t.events[M][1].type==="chunkFlow"){v=t.events[M][1].end;break}w(r);let F=N;for(;F<t.events.length;)t.events[F][1].end={...v},F++;return He(t.events,M+1,0,t.events.slice(N)),t.events.length=F,c(E)}return a(E)}function c(E){if(r===n.length){if(!i)return p(E);if(i.currentConstruct&&i.currentConstruct.concrete)return g(E);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(fs,u,f)(E)}function u(E){return i&&S(),w(r),p(E)}function f(E){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,g(E)}function p(E){return t.containerState={},e.attempt(fs,d,g)(E)}function d(E){return r++,n.push([t.currentConstruct,t.containerState]),p(E)}function g(E){if(E===null){i&&S(),w(0),e.consume(E);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),y(E)}function y(E){if(E===null){k(e.exit("chunkFlow"),!0),w(0),e.consume(E);return}return Q(E)?(e.consume(E),k(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(E),y)}function k(E,N){const M=t.sliceStream(E);if(N&&M.push(null),E.previous=s,s&&(s.next=E),s=E,i.defineSkip(E.start),i.write(M),t.parser.lazy[E.start.line]){let v=i.events.length;for(;v--;)if(i.events[v][1].start.offset<o&&(!i.events[v][1].end||i.events[v][1].end.offset>o))return;const F=t.events.length;let U=F,D,C;for(;U--;)if(t.events[U][0]==="exit"&&t.events[U][1].type==="chunkFlow"){if(D){C=t.events[U][1].end;break}D=!0}for(w(r),v=F;v<t.events.length;)t.events[v][1].end={...C},v++;He(t.events,U+1,0,t.events.slice(F)),t.events.length=v}}function w(E){let N=n.length;for(;N-- >E;){const M=n[N];t.containerState=M[1],M[0].exit.call(t,e)}n.length=E}function S(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function _h(e,t,n){return ue(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ut(e){if(e===null||de(e)||Mt(e))return 1;if(Gn(e))return 2}function Qn(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 $r={name:"attention",resolveAll:Oh,tokenize:Fh};function Oh(e,t){let n=-1,r,i,s,o,a,l,c,u;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;l=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 f={...e[r][1].end},p={...e[n][1].start};hs(f,-l),hs(p,l),o={type:l>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=Xe(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=Xe(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),c=Xe(c,Qn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=Xe(c,[["exit",s,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,c=Xe(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):u=0,He(e,r-1,n-r+3,c),n=r+c.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Fh(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Ut(r);let s;return o;function o(l){return s=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===s)return e.consume(l),a;const c=e.exit("attentionSequence"),u=Ut(l),f=!u||u===2&&i||n.includes(l),p=!i||i===2&&u||n.includes(r);return c._open=!!(s===42?f:f&&(i||!p)),c._close=!!(s===42?p:p&&(u||!f)),t(l)}}function hs(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const $h={name:"autolink",tokenize:Bh};function Bh(e,t,n){let r=0;return i;function i(d){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(d){return Pe(d)?(e.consume(d),o):d===64?n(d):c(d)}function o(d){return d===43||d===45||d===46||Me(d)?(r=1,a(d)):c(d)}function a(d){return d===58?(e.consume(d),r=0,l):(d===43||d===45||d===46||Me(d))&&r++<32?(e.consume(d),a):(r=0,c(d))}function l(d){return d===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.exit("autolink"),t):d===null||d===32||d===60||_n(d)?n(d):(e.consume(d),l)}function c(d){return d===64?(e.consume(d),u):Rh(d)?(e.consume(d),c):n(d)}function u(d){return Me(d)?f(d):n(d)}function f(d){return d===46?(e.consume(d),r=0,u):d===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.exit("autolink"),t):p(d)}function p(d){if((d===45||Me(d))&&r++<63){const g=d===45?p:f;return e.consume(d),g}return n(d)}}const fn={partial:!0,tokenize:Hh};function Hh(e,t,n){return r;function r(s){return oe(s)?ue(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||Q(s)?t(s):n(s)}}const Zo={continuation:{tokenize:qh},exit:Wh,name:"blockQuote",tokenize:Uh};function Uh(e,t,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return oe(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function qh(e,t,n){const r=this;return i;function i(o){return oe(o)?ue(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(Zo,t,n)(o)}}function Wh(e){e.exit("blockQuote")}const ea={name:"characterEscape",tokenize:Kh};function Kh(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 Lh(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const ta={name:"characterReference",tokenize:Vh};function Vh(e,t,n){const r=this;let i=0,s,o;return a;function a(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),l}function l(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),s=31,o=Me,u(f))}function c(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=Nh,u):(e.enter("characterReferenceValue"),s=7,o=Fr,u(f))}function u(f){if(f===59&&i){const p=e.exit("characterReferenceValue");return o===Me&&!bi(r.sliceSerialize(p))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(f)&&i++<s?(e.consume(f),u):n(f)}}const ps={partial:!0,tokenize:Yh},ds={concrete:!0,name:"codeFenced",tokenize:Xh};function Xh(e,t,n){const r=this,i={partial:!0,tokenize:M};let s=0,o=0,a;return l;function l(v){return c(v)}function c(v){const F=r.events[r.events.length-1];return s=F&&F[1].type==="linePrefix"?F[2].sliceSerialize(F[1],!0).length:0,a=v,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(v)}function u(v){return v===a?(o++,e.consume(v),u):o<3?n(v):(e.exit("codeFencedFenceSequence"),oe(v)?ue(e,f,"whitespace")(v):f(v))}function f(v){return v===null||Q(v)?(e.exit("codeFencedFence"),r.interrupt?t(v):e.check(ps,y,N)(v)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(v))}function p(v){return v===null||Q(v)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(v)):oe(v)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ue(e,d,"whitespace")(v)):v===96&&v===a?n(v):(e.consume(v),p)}function d(v){return v===null||Q(v)?f(v):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(v))}function g(v){return v===null||Q(v)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(v)):v===96&&v===a?n(v):(e.consume(v),g)}function y(v){return e.attempt(i,N,k)(v)}function k(v){return e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),w}function w(v){return s>0&&oe(v)?ue(e,S,"linePrefix",s+1)(v):S(v)}function S(v){return v===null||Q(v)?e.check(ps,y,N)(v):(e.enter("codeFlowValue"),E(v))}function E(v){return v===null||Q(v)?(e.exit("codeFlowValue"),S(v)):(e.consume(v),E)}function N(v){return e.exit("codeFenced"),t(v)}function M(v,F,U){let D=0;return C;function C(T){return v.enter("lineEnding"),v.consume(T),v.exit("lineEnding"),z}function z(T){return v.enter("codeFencedFence"),oe(T)?ue(v,j,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):j(T)}function j(T){return T===a?(v.enter("codeFencedFenceSequence"),_(T)):U(T)}function _(T){return T===a?(D++,v.consume(T),_):D>=o?(v.exit("codeFencedFenceSequence"),oe(T)?ue(v,R,"whitespace")(T):R(T)):U(T)}function R(T){return T===null||Q(T)?(v.exit("codeFencedFence"),F(T)):U(T)}}}function Yh(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const pr={name:"codeIndented",tokenize:Qh},Gh={partial:!0,tokenize:Jh};function Qh(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),ue(e,s,"linePrefix",5)(c)}function s(c){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?o(c):n(c)}function o(c){return c===null?l(c):Q(c)?e.attempt(Gh,o,l)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||Q(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function l(c){return e.exit("codeIndented"),t(c)}}function Jh(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):Q(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):ue(e,s,"linePrefix",5)(o)}function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):Q(o)?i(o):n(o)}}const Zh={name:"codeText",previous:tp,resolve:ep,tokenize:np};function ep(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 tp(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function np(e,t,n){let r=0,i,s;return o;function o(f){return e.enter("codeText"),e.enter("codeTextSequence"),a(f)}function a(f){return f===96?(e.consume(f),r++,a):(e.exit("codeTextSequence"),l(f))}function l(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),l):f===96?(s=e.enter("codeTextSequence"),i=0,u(f)):Q(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),l):(e.enter("codeTextData"),c(f))}function c(f){return f===null||f===32||f===96||Q(f)?(e.exit("codeTextData"),l(f)):(e.consume(f),c)}function u(f){return f===96?(e.consume(f),i++,u):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(s.type="codeTextData",c(f))}}class rp{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&&Zt(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),Zt(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Zt(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);Zt(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Zt(this.left,n.reverse())}}}function Zt(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 na(e){const t={};let n=-1,r,i,s,o,a,l,c;const u=new rp(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type==="chunkFlow"&&u.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,ip(u,n)),n=t[n],c=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=u.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(u.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...u.get(i)[1].start},a=u.slice(i,n),a.unshift(r),u.splice(i,n-i+1,a))}}return He(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function ip(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],c={};let u,f,p=-1,d=n,g=0,y=0;const k=[y];for(;d;){for(;e.get(++i)[1]!==d;);s.push(i),d._tokenizer||(u=r.sliceStream(d),d.next||u.push(null),f&&o.defineSkip(d.start),d._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),d._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),f=d,d=d.next}for(d=n;++p<a.length;)a[p][0]==="exit"&&a[p-1][0]==="enter"&&a[p][1].type===a[p-1][1].type&&a[p][1].start.line!==a[p][1].end.line&&(y=p+1,k.push(y),d._tokenizer=void 0,d.previous=void 0,d=d.next);for(o.events=[],d?(d._tokenizer=void 0,d.previous=void 0):k.pop(),p=k.length;p--;){const w=a.slice(k[p],k[p+1]),S=s.pop();l.push([S,S+w.length-1]),e.splice(S,2,w)}for(l.reverse(),p=-1;++p<l.length;)c[g+l[p][0]]=g+l[p][1],g+=l[p][1]-l[p][0]-1;return c}const sp={resolve:ap,tokenize:lp},op={partial:!0,tokenize:cp};function ap(e){return na(e),e}function lp(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):Q(a)?e.check(op,o,s)(a):(e.consume(a),i)}function s(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function o(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function cp(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),ue(e,s,"linePrefix")}function s(o){if(o===null||Q(o))return n(o);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function ra(e,t,n,r,i,s,o,a,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return f;function f(w){return w===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(w),e.exit(s),p):w===null||w===32||w===41||_n(w)?n(w):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),y(w))}function p(w){return w===62?(e.enter(s),e.consume(w),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),d(w))}function d(w){return w===62?(e.exit("chunkString"),e.exit(a),p(w)):w===null||w===60||Q(w)?n(w):(e.consume(w),w===92?g:d)}function g(w){return w===60||w===62||w===92?(e.consume(w),d):d(w)}function y(w){return!u&&(w===null||w===41||de(w))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(w)):u<c&&w===40?(e.consume(w),u++,y):w===41?(e.consume(w),u--,y):w===null||w===32||w===40||_n(w)?n(w):(e.consume(w),w===92?k:y)}function k(w){return w===40||w===41||w===92?(e.consume(w),y):y(w)}}function ia(e,t,n,r,i,s){const o=this;let a=0,l;return c;function c(d){return e.enter(r),e.enter(i),e.consume(d),e.exit(i),e.enter(s),u}function u(d){return a>999||d===null||d===91||d===93&&!l||d===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(d):d===93?(e.exit(s),e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):Q(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),u):(e.enter("chunkString",{contentType:"string"}),f(d))}function f(d){return d===null||d===91||d===93||Q(d)||a++>999?(e.exit("chunkString"),u(d)):(e.consume(d),l||(l=!oe(d)),d===92?p:f)}function p(d){return d===91||d===92||d===93?(e.consume(d),a++,f):f(d)}}function sa(e,t,n,r,i,s){let o;return a;function a(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),o=p===40?41:p,l):n(p)}function l(p){return p===o?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(s),c(p))}function c(p){return p===o?(e.exit(s),l(o)):p===null?n(p):Q(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),ue(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(p))}function u(p){return p===o||p===null||Q(p)?(e.exit("chunkString"),c(p)):(e.consume(p),p===92?f:u)}function f(p){return p===o||p===92?(e.consume(p),u):u(p)}}function on(e,t){let n;return r;function r(i){return Q(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):oe(i)?ue(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const up={name:"definition",tokenize:hp},fp={partial:!0,tokenize:pp};function hp(e,t,n){const r=this;let i;return s;function s(d){return e.enter("definition"),o(d)}function o(d){return ia.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(d)}function a(d){return i=nt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),d===58?(e.enter("definitionMarker"),e.consume(d),e.exit("definitionMarker"),l):n(d)}function l(d){return de(d)?on(e,c)(d):c(d)}function c(d){return ra(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(d)}function u(d){return e.attempt(fp,f,f)(d)}function f(d){return oe(d)?ue(e,p,"whitespace")(d):p(d)}function p(d){return d===null||Q(d)?(e.exit("definition"),r.parser.defined.push(i),t(d)):n(d)}}function pp(e,t,n){return r;function r(a){return de(a)?on(e,i)(a):n(a)}function i(a){return sa(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return oe(a)?ue(e,o,"whitespace")(a):o(a)}function o(a){return a===null||Q(a)?t(a):n(a)}}const dp={name:"hardBreakEscape",tokenize:mp};function mp(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return Q(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const gp={name:"headingAtx",resolve:xp,tokenize:yp};function xp(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"},He(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function yp(e,t,n){let r=0;return i;function i(u){return e.enter("atxHeading"),s(u)}function s(u){return e.enter("atxHeadingSequence"),o(u)}function o(u){return u===35&&r++<6?(e.consume(u),o):u===null||de(u)?(e.exit("atxHeadingSequence"),a(u)):n(u)}function a(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||Q(u)?(e.exit("atxHeading"),t(u)):oe(u)?ue(e,a,"whitespace")(u):(e.enter("atxHeadingText"),c(u))}function l(u){return u===35?(e.consume(u),l):(e.exit("atxHeadingSequence"),a(u))}function c(u){return u===null||u===35||de(u)?(e.exit("atxHeadingText"),a(u)):(e.consume(u),c)}}const bp=["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"],ms=["pre","script","style","textarea"],wp={concrete:!0,name:"htmlFlow",resolveTo:vp,tokenize:Cp},kp={partial:!0,tokenize:Tp},Sp={partial:!0,tokenize:Ep};function vp(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 Cp(e,t,n){const r=this;let i,s,o,a,l;return c;function c(b){return u(b)}function u(b){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(b),f}function f(b){return b===33?(e.consume(b),p):b===47?(e.consume(b),s=!0,y):b===63?(e.consume(b),i=3,r.interrupt?t:x):Pe(b)?(e.consume(b),o=String.fromCharCode(b),k):n(b)}function p(b){return b===45?(e.consume(b),i=2,d):b===91?(e.consume(b),i=5,a=0,g):Pe(b)?(e.consume(b),i=4,r.interrupt?t:x):n(b)}function d(b){return b===45?(e.consume(b),r.interrupt?t:x):n(b)}function g(b){const J="CDATA[";return b===J.charCodeAt(a++)?(e.consume(b),a===J.length?r.interrupt?t:j:g):n(b)}function y(b){return Pe(b)?(e.consume(b),o=String.fromCharCode(b),k):n(b)}function k(b){if(b===null||b===47||b===62||de(b)){const J=b===47,Z=o.toLowerCase();return!J&&!s&&ms.includes(Z)?(i=1,r.interrupt?t(b):j(b)):bp.includes(o.toLowerCase())?(i=6,J?(e.consume(b),w):r.interrupt?t(b):j(b)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(b):s?S(b):E(b))}return b===45||Me(b)?(e.consume(b),o+=String.fromCharCode(b),k):n(b)}function w(b){return b===62?(e.consume(b),r.interrupt?t:j):n(b)}function S(b){return oe(b)?(e.consume(b),S):C(b)}function E(b){return b===47?(e.consume(b),C):b===58||b===95||Pe(b)?(e.consume(b),N):oe(b)?(e.consume(b),E):C(b)}function N(b){return b===45||b===46||b===58||b===95||Me(b)?(e.consume(b),N):M(b)}function M(b){return b===61?(e.consume(b),v):oe(b)?(e.consume(b),M):E(b)}function v(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(e.consume(b),l=b,F):oe(b)?(e.consume(b),v):U(b)}function F(b){return b===l?(e.consume(b),l=null,D):b===null||Q(b)?n(b):(e.consume(b),F)}function U(b){return b===null||b===34||b===39||b===47||b===60||b===61||b===62||b===96||de(b)?M(b):(e.consume(b),U)}function D(b){return b===47||b===62||oe(b)?E(b):n(b)}function C(b){return b===62?(e.consume(b),z):n(b)}function z(b){return b===null||Q(b)?j(b):oe(b)?(e.consume(b),z):n(b)}function j(b){return b===45&&i===2?(e.consume(b),B):b===60&&i===1?(e.consume(b),I):b===62&&i===4?(e.consume(b),K):b===63&&i===3?(e.consume(b),x):b===93&&i===5?(e.consume(b),L):Q(b)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(kp,V,_)(b)):b===null||Q(b)?(e.exit("htmlFlowData"),_(b)):(e.consume(b),j)}function _(b){return e.check(Sp,R,V)(b)}function R(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),T}function T(b){return b===null||Q(b)?_(b):(e.enter("htmlFlowData"),j(b))}function B(b){return b===45?(e.consume(b),x):j(b)}function I(b){return b===47?(e.consume(b),o="",H):j(b)}function H(b){if(b===62){const J=o.toLowerCase();return ms.includes(J)?(e.consume(b),K):j(b)}return Pe(b)&&o.length<8?(e.consume(b),o+=String.fromCharCode(b),H):j(b)}function L(b){return b===93?(e.consume(b),x):j(b)}function x(b){return b===62?(e.consume(b),K):b===45&&i===2?(e.consume(b),x):j(b)}function K(b){return b===null||Q(b)?(e.exit("htmlFlowData"),V(b)):(e.consume(b),K)}function V(b){return e.exit("htmlFlow"),t(b)}}function Ep(e,t,n){const r=this;return i;function i(o){return Q(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function Tp(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(fn,t,n)}}const jp={name:"htmlText",tokenize:Ap};function Ap(e,t,n){const r=this;let i,s,o;return a;function a(x){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(x),l}function l(x){return x===33?(e.consume(x),c):x===47?(e.consume(x),M):x===63?(e.consume(x),E):Pe(x)?(e.consume(x),U):n(x)}function c(x){return x===45?(e.consume(x),u):x===91?(e.consume(x),s=0,g):Pe(x)?(e.consume(x),S):n(x)}function u(x){return x===45?(e.consume(x),d):n(x)}function f(x){return x===null?n(x):x===45?(e.consume(x),p):Q(x)?(o=f,I(x)):(e.consume(x),f)}function p(x){return x===45?(e.consume(x),d):f(x)}function d(x){return x===62?B(x):x===45?p(x):f(x)}function g(x){const K="CDATA[";return x===K.charCodeAt(s++)?(e.consume(x),s===K.length?y:g):n(x)}function y(x){return x===null?n(x):x===93?(e.consume(x),k):Q(x)?(o=y,I(x)):(e.consume(x),y)}function k(x){return x===93?(e.consume(x),w):y(x)}function w(x){return x===62?B(x):x===93?(e.consume(x),w):y(x)}function S(x){return x===null||x===62?B(x):Q(x)?(o=S,I(x)):(e.consume(x),S)}function E(x){return x===null?n(x):x===63?(e.consume(x),N):Q(x)?(o=E,I(x)):(e.consume(x),E)}function N(x){return x===62?B(x):E(x)}function M(x){return Pe(x)?(e.consume(x),v):n(x)}function v(x){return x===45||Me(x)?(e.consume(x),v):F(x)}function F(x){return Q(x)?(o=F,I(x)):oe(x)?(e.consume(x),F):B(x)}function U(x){return x===45||Me(x)?(e.consume(x),U):x===47||x===62||de(x)?D(x):n(x)}function D(x){return x===47?(e.consume(x),B):x===58||x===95||Pe(x)?(e.consume(x),C):Q(x)?(o=D,I(x)):oe(x)?(e.consume(x),D):B(x)}function C(x){return x===45||x===46||x===58||x===95||Me(x)?(e.consume(x),C):z(x)}function z(x){return x===61?(e.consume(x),j):Q(x)?(o=z,I(x)):oe(x)?(e.consume(x),z):D(x)}function j(x){return x===null||x===60||x===61||x===62||x===96?n(x):x===34||x===39?(e.consume(x),i=x,_):Q(x)?(o=j,I(x)):oe(x)?(e.consume(x),j):(e.consume(x),R)}function _(x){return x===i?(e.consume(x),i=void 0,T):x===null?n(x):Q(x)?(o=_,I(x)):(e.consume(x),_)}function R(x){return x===null||x===34||x===39||x===60||x===61||x===96?n(x):x===47||x===62||de(x)?D(x):(e.consume(x),R)}function T(x){return x===47||x===62||de(x)?D(x):n(x)}function B(x){return x===62?(e.consume(x),e.exit("htmlTextData"),e.exit("htmlText"),t):n(x)}function I(x){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),H}function H(x){return oe(x)?ue(e,L,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(x):L(x)}function L(x){return e.enter("htmlTextData"),o(x)}}const wi={name:"labelEnd",resolveAll:Lp,resolveTo:Mp,tokenize:Dp},Ip={tokenize:zp},Rp={tokenize:Pp},Np={tokenize:_p};function Lp(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&&He(e,0,e.length,n),e}function Mp(e,t){let n=e.length,r=0,i,s,o,a;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(o){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"&&(o=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},u={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",c,t]],a=Xe(a,e.slice(s+1,s+r+3)),a=Xe(a,[["enter",u,t]]),a=Xe(a,Qn(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=Xe(a,[["exit",u,t],e[o-2],e[o-1],["exit",c,t]]),a=Xe(a,e.slice(o+1)),a=Xe(a,[["exit",l,t]]),He(e,s,e.length,a),e}function Dp(e,t,n){const r=this;let i=r.events.length,s,o;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 a;function a(p){return s?s._inactive?f(p):(o=r.parser.defined.includes(nt(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),l):n(p)}function l(p){return p===40?e.attempt(Ip,u,o?u:f)(p):p===91?e.attempt(Rp,u,o?c:f)(p):o?u(p):f(p)}function c(p){return e.attempt(Np,u,f)(p)}function u(p){return t(p)}function f(p){return s._balanced=!0,n(p)}}function zp(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),i}function i(f){return de(f)?on(e,s)(f):s(f)}function s(f){return f===41?u(f):ra(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function o(f){return de(f)?on(e,l)(f):u(f)}function a(f){return n(f)}function l(f){return f===34||f===39||f===40?sa(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):u(f)}function c(f){return de(f)?on(e,u)(f):u(f)}function u(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function Pp(e,t,n){const r=this;return i;function i(a){return ia.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(nt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function _p(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 Op={name:"labelStartImage",resolveAll:wi.resolveAll,tokenize:Fp};function Fp(e,t,n){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),s}function s(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const $p={name:"labelStartLink",resolveAll:wi.resolveAll,tokenize:Bp};function Bp(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const dr={name:"lineEnding",tokenize:Hp};function Hp(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),ue(e,t,"linePrefix")}}const Cn={name:"thematicBreak",tokenize:Up};function Up(e,t,n){let r=0,i;return s;function s(c){return e.enter("thematicBreak"),o(c)}function o(c){return i=c,a(c)}function a(c){return c===i?(e.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||Q(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),oe(c)?ue(e,a,"whitespace")(c):a(c))}}const $e={continuation:{tokenize:Vp},exit:Yp,name:"list",tokenize:Kp},qp={partial:!0,tokenize:Gp},Wp={partial:!0,tokenize:Xp};function Kp(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,o=0;return a;function a(d){const g=r.containerState.type||(d===42||d===43||d===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||d===r.containerState.marker:Fr(d)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),d===42||d===45?e.check(Cn,n,c)(d):c(d);if(!r.interrupt||d===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(d)}return n(d)}function l(d){return Fr(d)&&++o<10?(e.consume(d),l):(!r.interrupt||o<2)&&(r.containerState.marker?d===r.containerState.marker:d===41||d===46)?(e.exit("listItemValue"),c(d)):n(d)}function c(d){return e.enter("listItemMarker"),e.consume(d),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||d,e.check(fn,r.interrupt?n:u,e.attempt(qp,p,f))}function u(d){return r.containerState.initialBlankLine=!0,s++,p(d)}function f(d){return oe(d)?(e.enter("listItemPrefixWhitespace"),e.consume(d),e.exit("listItemPrefixWhitespace"),p):n(d)}function p(d){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(d)}}function Vp(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(fn,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ue(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!oe(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Wp,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,ue(e,e.attempt($e,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function Xp(e,t,n){const r=this;return ue(e,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function Yp(e){e.exit(this.containerState.type)}function Gp(e,t,n){const r=this;return ue(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!oe(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const gs={name:"setextUnderline",resolveTo:Qp,tokenize:Jp};function Qp(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 o={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",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function Jp(e,t,n){const r=this;let i;return s;function s(c){let u=r.events.length,f;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){f=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),i=c,o(c)):n(c)}function o(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===i?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),oe(c)?ue(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||Q(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const Zp={tokenize:ed};function ed(e){const t=this,n=e.attempt(fn,r,e.attempt(this.parser.constructs.flowInitial,i,ue(e,e.attempt(this.parser.constructs.flow,i,e.attempt(sp,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 td={resolveAll:aa()},nd=oa("string"),rd=oa("text");function oa(e){return{resolveAll:aa(e==="text"?id:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,o,a);return o;function o(u){return c(u)?s(u):a(u)}function a(u){if(u===null){n.consume(u);return}return n.enter("data"),n.consume(u),l}function l(u){return c(u)?(n.exit("data"),s(u)):(n.consume(u),l)}function c(u){if(u===null)return!0;const f=i[u];let p=-1;if(f)for(;++p<f.length;){const d=f[p];if(!d.previous||d.previous.call(r,r.previous))return!0}return!1}}}function aa(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 id(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,o=-1,a=0,l;for(;s--;){const c=i[s];if(typeof c=="string"){for(o=c.length;c.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(c===-2)l=!0,a++;else if(c!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const c={type:n===e.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}const sd={42:$e,43:$e,45:$e,48:$e,49:$e,50:$e,51:$e,52:$e,53:$e,54:$e,55:$e,56:$e,57:$e,62:Zo},od={91:up},ad={[-2]:pr,[-1]:pr,32:pr},ld={35:gp,42:Cn,45:[gs,Cn],60:wp,61:gs,95:Cn,96:ds,126:ds},cd={38:ta,92:ea},ud={[-5]:dr,[-4]:dr,[-3]:dr,33:Op,38:ta,42:$r,60:[$h,jp],91:$p,92:[dp,ea],93:wi,95:$r,96:Zh},fd={null:[$r,td]},hd={null:[42,95]},pd={null:[]},dd=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:hd,contentInitial:od,disable:pd,document:sd,flow:ld,flowInitial:ad,insideSpan:fd,string:cd,text:ud},Symbol.toStringTag,{value:"Module"}));function md(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 o=[],a=[];const l={attempt:F(M),check:F(v),consume:S,enter:E,exit:N,interrupt:F(v,{interrupt:!0})},c={code:null,containerState:{},defineSkip:y,events:[],now:g,parser:e,previous:null,sliceSerialize:p,sliceStream:d,write:f};let u=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function f(z){return o=Xe(o,z),k(),o[o.length-1]!==null?[]:(U(t,0),c.events=Qn(s,c.events,c),c.events)}function p(z,j){return xd(d(z),j)}function d(z){return gd(o,z)}function g(){const{_bufferIndex:z,_index:j,line:_,column:R,offset:T}=r;return{_bufferIndex:z,_index:j,line:_,column:R,offset:T}}function y(z){i[z.line]=z.column,C()}function k(){let z;for(;r._index<o.length;){const j=o[r._index];if(typeof j=="string")for(z=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===z&&r._bufferIndex<j.length;)w(j.charCodeAt(r._bufferIndex));else w(j)}}function w(z){u=u(z)}function S(z){Q(z)?(r.line++,r.column=1,r.offset+=z===-3?2:1,C()):z!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=z}function E(z,j){const _=j||{};return _.type=z,_.start=g(),c.events.push(["enter",_,c]),a.push(_),_}function N(z){const j=a.pop();return j.end=g(),c.events.push(["exit",j,c]),j}function M(z,j){U(z,j.from)}function v(z,j){j.restore()}function F(z,j){return _;function _(R,T,B){let I,H,L,x;return Array.isArray(R)?V(R):"tokenize"in R?V([R]):K(R);function K(Y){return ae;function ae(se){const ee=se!==null&&Y[se],le=se!==null&&Y.null,me=[...Array.isArray(ee)?ee:ee?[ee]:[],...Array.isArray(le)?le:le?[le]:[]];return V(me)(se)}}function V(Y){return I=Y,H=0,Y.length===0?B:b(Y[H])}function b(Y){return ae;function ae(se){return x=D(),L=Y,Y.partial||(c.currentConstruct=Y),Y.name&&c.parser.constructs.disable.null.includes(Y.name)?Z():Y.tokenize.call(j?Object.assign(Object.create(c),j):c,l,J,Z)(se)}}function J(Y){return z(L,x),T}function Z(Y){return x.restore(),++H<I.length?b(I[H]):B}}}function U(z,j){z.resolveAll&&!s.includes(z)&&s.push(z),z.resolve&&He(c.events,j,c.events.length-j,z.resolve(c.events.slice(j),c)),z.resolveTo&&(c.events=z.resolveTo(c.events,c))}function D(){const z=g(),j=c.previous,_=c.currentConstruct,R=c.events.length,T=Array.from(a);return{from:R,restore:B};function B(){r=z,c.previous=j,c.currentConstruct=_,c.events.length=R,a=T,C()}}function C(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function gd(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,s)];else{if(o=e.slice(n,i),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function xd(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
68
+ `;break}case-3:{o=`\r
69
+ `;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function yd(e){const r={constructs:Qo([dd,...(e||{}).extensions||[]]),content:i(Mh),defined:[],document:i(zh),flow:i(Zp),lazy:{},string:i(nd),text:i(rd)};return r;function i(s){return o;function o(a){return md(r,s,a)}}}function bd(e){for(;!na(e););return e}const xs=/[\0\t\n\r]/g;function wd(){let e=1,t="",n=!0,r;return i;function i(s,o,a){const l=[];let c,u,f,p,d;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),f=0,t="",n&&(s.charCodeAt(0)===65279&&f++,n=void 0);f<s.length;){if(xs.lastIndex=f,c=xs.exec(s),p=c&&c.index!==void 0?c.index:s.length,d=s.charCodeAt(p),!c){t=s.slice(f);break}if(d===10&&f===p&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),f<p&&(l.push(s.slice(f,p)),e+=p-f),d){case 0:{l.push(65533),e++;break}case 9:{for(u=Math.ceil(e/4)*4,l.push(-2);e++<u;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}f=p+1}return a&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const kd=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Sd(e){return e.replace(kd,vd)}function vd(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return Jo(n.slice(s?2:1),s?16:10)}return bi(n)||e}const la={}.hasOwnProperty;function Cd(e,t,n){return typeof t!="string"&&(n=t,t=void 0),Ed(n)(bd(yd(n).document().write(wd()(e,t,!0))))}function Ed(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(ge),autolinkProtocol:D,autolinkEmail:D,atxHeading:s(Ee),blockQuote:s(le),characterEscape:D,characterReference:D,codeFenced:s(me),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(me,o),codeText:s(Se,o),codeTextData:D,data:D,codeFlowValue:D,definition:s(we),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(xe),hardBreakEscape:s(W),hardBreakTrailing:s(W),htmlFlow:s($,o),htmlFlowData:D,htmlText:s($,o),htmlTextData:D,image:s(re),label:o,link:s(ge),listItem:s(ye),listItemValue:p,listOrdered:s(ie,f),listUnordered:s(ie),paragraph:s(Ae),reference:b,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Ee),strong:s(Ge),thematicBreak:s(Ne)},exit:{atxHeading:l(),atxHeadingSequence:M,autolink:l(),autolinkEmail:ee,autolinkProtocol:se,blockQuote:l(),characterEscapeValue:C,characterReferenceMarkerHexadecimal:Z,characterReferenceMarkerNumeric:Z,characterReferenceValue:Y,characterReference:ae,codeFenced:l(k),codeFencedFence:y,codeFencedFenceInfo:d,codeFencedFenceMeta:g,codeFlowValue:C,codeIndented:l(w),codeText:l(T),codeTextData:C,data:C,definition:l(),definitionDestinationString:N,definitionLabelString:S,definitionTitleString:E,emphasis:l(),hardBreakEscape:l(j),hardBreakTrailing:l(j),htmlFlow:l(_),htmlFlowData:C,htmlText:l(R),htmlTextData:C,image:l(I),label:L,labelText:H,lineEnding:z,link:l(B),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:J,resourceDestinationString:x,resourceTitleString:K,resource:V,setextHeading:l(U),setextHeadingLineSequence:F,setextHeadingText:v,strong:l(),thematicBreak:l()}};ca(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(A){let O={type:"root",children:[]};const G={stack:[O],tokenStack:[],config:t,enter:a,exit:c,buffer:o,resume:u,data:n},te=[];let ce=-1;for(;++ce<A.length;)if(A[ce][1].type==="listOrdered"||A[ce][1].type==="listUnordered")if(A[ce][0]==="enter")te.push(ce);else{const Re=te.pop();ce=i(A,Re,ce)}for(ce=-1;++ce<A.length;){const Re=t[A[ce][0]];la.call(Re,A[ce][1].type)&&Re[A[ce][1].type].call(Object.assign({sliceSerialize:A[ce][2].sliceSerialize},G),A[ce][1])}if(G.tokenStack.length>0){const Re=G.tokenStack[G.tokenStack.length-1];(Re[1]||ys).call(G,void 0,Re[0])}for(O.position={start:wt(A.length>0?A[0][1].start:{line:1,column:1,offset:0}),end:wt(A.length>0?A[A.length-2][1].end:{line:1,column:1,offset:0})},ce=-1;++ce<t.transforms.length;)O=t.transforms[ce](O)||O;return O}function i(A,O,G){let te=O-1,ce=-1,Re=!1,Ue,Oe,qe,Qe;for(;++te<=G;){const je=A[te];switch(je[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{je[0]==="enter"?ce++:ce--,Qe=void 0;break}case"lineEndingBlank":{je[0]==="enter"&&(Ue&&!Qe&&!ce&&!qe&&(qe=te),Qe=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Qe=void 0}if(!ce&&je[0]==="enter"&&je[1].type==="listItemPrefix"||ce===-1&&je[0]==="exit"&&(je[1].type==="listUnordered"||je[1].type==="listOrdered")){if(Ue){let We=te;for(Oe=void 0;We--;){const ze=A[We];if(ze[1].type==="lineEnding"||ze[1].type==="lineEndingBlank"){if(ze[0]==="exit")continue;Oe&&(A[Oe][1].type="lineEndingBlank",Re=!0),ze[1].type="lineEnding",Oe=We}else if(!(ze[1].type==="linePrefix"||ze[1].type==="blockQuotePrefix"||ze[1].type==="blockQuotePrefixWhitespace"||ze[1].type==="blockQuoteMarker"||ze[1].type==="listItemIndent"))break}qe&&(!Oe||qe<Oe)&&(Ue._spread=!0),Ue.end=Object.assign({},Oe?A[Oe][1].start:je[1].end),A.splice(Oe||te,0,["exit",Ue,je[2]]),te++,G++}if(je[1].type==="listItemPrefix"){const We={type:"listItem",_spread:!1,start:Object.assign({},je[1].start),end:void 0};Ue=We,A.splice(te,0,["enter",We,je[2]]),te++,G++,qe=void 0,Qe=!0}}}return A[O][1]._spread=Re,G}function s(A,O){return G;function G(te){a.call(this,A(te),te),O&&O.call(this,te)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(A,O,G){this.stack[this.stack.length-1].children.push(A),this.stack.push(A),this.tokenStack.push([O,G||void 0]),A.position={start:wt(O.start),end:void 0}}function l(A){return O;function O(G){A&&A.call(this,G),c.call(this,G)}}function c(A,O){const G=this.stack.pop(),te=this.tokenStack.pop();if(te)te[0].type!==A.type&&(O?O.call(this,A,te[0]):(te[1]||ys).call(this,A,te[0]));else throw new Error("Cannot close `"+A.type+"` ("+sn({start:A.start,end:A.end})+"): it’s not open");G.position.end=wt(A.end)}function u(){return yi(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(A){if(this.data.expectingFirstListItemValue){const O=this.stack[this.stack.length-2];O.start=Number.parseInt(this.sliceSerialize(A),10),this.data.expectingFirstListItemValue=void 0}}function d(){const A=this.resume(),O=this.stack[this.stack.length-1];O.lang=A}function g(){const A=this.resume(),O=this.stack[this.stack.length-1];O.meta=A}function y(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function k(){const A=this.resume(),O=this.stack[this.stack.length-1];O.value=A.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function w(){const A=this.resume(),O=this.stack[this.stack.length-1];O.value=A.replace(/(\r?\n|\r)$/g,"")}function S(A){const O=this.resume(),G=this.stack[this.stack.length-1];G.label=O,G.identifier=nt(this.sliceSerialize(A)).toLowerCase()}function E(){const A=this.resume(),O=this.stack[this.stack.length-1];O.title=A}function N(){const A=this.resume(),O=this.stack[this.stack.length-1];O.url=A}function M(A){const O=this.stack[this.stack.length-1];if(!O.depth){const G=this.sliceSerialize(A).length;O.depth=G}}function v(){this.data.setextHeadingSlurpLineEnding=!0}function F(A){const O=this.stack[this.stack.length-1];O.depth=this.sliceSerialize(A).codePointAt(0)===61?1:2}function U(){this.data.setextHeadingSlurpLineEnding=void 0}function D(A){const G=this.stack[this.stack.length-1].children;let te=G[G.length-1];(!te||te.type!=="text")&&(te=Ie(),te.position={start:wt(A.start),end:void 0},G.push(te)),this.stack.push(te)}function C(A){const O=this.stack.pop();O.value+=this.sliceSerialize(A),O.position.end=wt(A.end)}function z(A){const O=this.stack[this.stack.length-1];if(this.data.atHardBreak){const G=O.children[O.children.length-1];G.position.end=wt(A.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(O.type)&&(D.call(this,A),C.call(this,A))}function j(){this.data.atHardBreak=!0}function _(){const A=this.resume(),O=this.stack[this.stack.length-1];O.value=A}function R(){const A=this.resume(),O=this.stack[this.stack.length-1];O.value=A}function T(){const A=this.resume(),O=this.stack[this.stack.length-1];O.value=A}function B(){const A=this.stack[this.stack.length-1];if(this.data.inReference){const O=this.data.referenceType||"shortcut";A.type+="Reference",A.referenceType=O,delete A.url,delete A.title}else delete A.identifier,delete A.label;this.data.referenceType=void 0}function I(){const A=this.stack[this.stack.length-1];if(this.data.inReference){const O=this.data.referenceType||"shortcut";A.type+="Reference",A.referenceType=O,delete A.url,delete A.title}else delete A.identifier,delete A.label;this.data.referenceType=void 0}function H(A){const O=this.sliceSerialize(A),G=this.stack[this.stack.length-2];G.label=Sd(O),G.identifier=nt(O).toLowerCase()}function L(){const A=this.stack[this.stack.length-1],O=this.resume(),G=this.stack[this.stack.length-1];if(this.data.inReference=!0,G.type==="link"){const te=A.children;G.children=te}else G.alt=O}function x(){const A=this.resume(),O=this.stack[this.stack.length-1];O.url=A}function K(){const A=this.resume(),O=this.stack[this.stack.length-1];O.title=A}function V(){this.data.inReference=void 0}function b(){this.data.referenceType="collapsed"}function J(A){const O=this.resume(),G=this.stack[this.stack.length-1];G.label=O,G.identifier=nt(this.sliceSerialize(A)).toLowerCase(),this.data.referenceType="full"}function Z(A){this.data.characterReferenceType=A.type}function Y(A){const O=this.sliceSerialize(A),G=this.data.characterReferenceType;let te;G?(te=Jo(O,G==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):te=bi(O);const ce=this.stack[this.stack.length-1];ce.value+=te}function ae(A){const O=this.stack.pop();O.position.end=wt(A.end)}function se(A){C.call(this,A);const O=this.stack[this.stack.length-1];O.url=this.sliceSerialize(A)}function ee(A){C.call(this,A);const O=this.stack[this.stack.length-1];O.url="mailto:"+this.sliceSerialize(A)}function le(){return{type:"blockquote",children:[]}}function me(){return{type:"code",lang:null,meta:null,value:""}}function Se(){return{type:"inlineCode",value:""}}function we(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function xe(){return{type:"emphasis",children:[]}}function Ee(){return{type:"heading",depth:0,children:[]}}function W(){return{type:"break"}}function $(){return{type:"html",value:""}}function re(){return{type:"image",title:null,url:"",alt:null}}function ge(){return{type:"link",title:null,url:"",children:[]}}function ie(A){return{type:"list",ordered:A.type==="listOrdered",start:null,spread:A._spread,children:[]}}function ye(A){return{type:"listItem",spread:A._spread,checked:null,children:[]}}function Ae(){return{type:"paragraph",children:[]}}function Ge(){return{type:"strong",children:[]}}function Ie(){return{type:"text",value:""}}function Ne(){return{type:"thematicBreak"}}}function wt(e){return{line:e.line,column:e.column,offset:e.offset}}function ca(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?ca(e,r):Td(e,r)}}function Td(e,t){let n;for(n in t)if(la.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 ys(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+sn({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+sn({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+sn({start:t.start,end:t.end})+") is still open")}function jd(e){const t=this;t.parser=n;function n(r){return Cd(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Ad(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 Id(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
70
+ `}]}function Rd(e,t){const n=t.value?t.value+`
71
+ `:"",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 Nd(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Ld(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Md(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=Wt(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let o,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=s+1,a+=1,e.footnoteCounts.set(r,a);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)}function Dd(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 zd(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function ua(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 o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function Pd(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ua(e,t);const i={src:Wt(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 _d(e,t){const n={src:Wt(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 Od(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 Fd(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ua(e,t);const i={href:Wt(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 $d(e,t){const n={href:Wt(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 Bd(e,t,n){const r=e.all(t),i=n?Hd(n):fa(t),s={},o=[];if(typeof t.checked=="boolean"){const u=r[0];let f;u&&u.type==="element"&&u.tagName==="p"?f=u:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const u=r[a];(i||a!==0||u.type!=="element"||u.tagName!=="p")&&o.push({type:"text",value:`
72
+ `}),u.type==="element"&&u.tagName==="p"&&!i?o.push(...u.children):o.push(u)}const l=r[r.length-1];l&&(i||l.type!=="element"||l.tagName!=="p")&&o.push({type:"text",value:`
73
+ `});const c={type:"element",tagName:"li",properties:s,children:o};return e.patch(t,c),e.applyData(t,c)}function Hd(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=fa(n[r])}return t}function fa(e){const t=e.spread;return t??e.children.length>1}function Ud(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 o=r[i];if(o.type==="element"&&o.tagName==="li"&&o.properties&&Array.isArray(o.properties.className)&&o.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 qd(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Wd(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function Kd(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Vd(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const o={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],o),i.push(o)}if(n.length>0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=di(t.children[1]),l=qo(t.children[t.children.length-1]);a&&l&&(o.position={start:a,end:l}),i.push(o)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function Xd(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,a=o?o.length:t.children.length;let l=-1;const c=[];for(;++l<a;){const f=t.children[l],p={},d=o?o[l]:void 0;d&&(p.align=d);let g={type:"element",tagName:s,properties:p,children:[]};f&&(g.children=e.all(f),e.patch(f,g),g=e.applyData(f,g)),c.push(g)}const u={type:"element",tagName:"tr",properties:{},children:e.wrap(c,!0)};return e.patch(t,u),e.applyData(t,u)}function Yd(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const bs=9,ws=32;function Gd(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(ks(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(ks(t.slice(i),i>0,!1)),s.join("")}function ks(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===bs||s===ws;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===bs||s===ws;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function Qd(e,t){const n={type:"text",value:Gd(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Jd(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const Zd={blockquote:Ad,break:Id,code:Rd,delete:Nd,emphasis:Ld,footnoteReference:Md,heading:Dd,html:zd,imageReference:Pd,image:_d,inlineCode:Od,linkReference:Fd,link:$d,listItem:Bd,list:Ud,paragraph:qd,root:Wd,strong:Kd,table:Vd,tableCell:Yd,tableRow:Xd,text:Qd,thematicBreak:Jd,toml:xn,yaml:xn,definition:xn,footnoteDefinition:xn};function xn(){}const ha=-1,Jn=0,an=1,On=2,ki=3,Si=4,vi=5,Ci=6,pa=7,da=8,Ss=typeof self=="object"?self:globalThis,em=(e,t)=>{const n=(i,s)=>(e.set(s,i),i),r=i=>{if(e.has(i))return e.get(i);const[s,o]=t[i];switch(s){case Jn:case ha:return n(o,i);case an:{const a=n([],i);for(const l of o)a.push(r(l));return a}case On:{const a=n({},i);for(const[l,c]of o)a[r(l)]=r(c);return a}case ki:return n(new Date(o),i);case Si:{const{source:a,flags:l}=o;return n(new RegExp(a,l),i)}case vi:{const a=n(new Map,i);for(const[l,c]of o)a.set(r(l),r(c));return a}case Ci:{const a=n(new Set,i);for(const l of o)a.add(r(l));return a}case pa:{const{name:a,message:l}=o;return n(new Ss[a](l),i)}case da:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:a}=new Uint8Array(o);return n(new DataView(a),o)}}return n(new Ss[s](o),i)};return r},vs=e=>em(new Map,e)(0),Ft="",{toString:tm}={},{keys:nm}=Object,en=e=>{const t=typeof e;if(t!=="object"||!e)return[Jn,t];const n=tm.call(e).slice(8,-1);switch(n){case"Array":return[an,Ft];case"Object":return[On,Ft];case"Date":return[ki,Ft];case"RegExp":return[Si,Ft];case"Map":return[vi,Ft];case"Set":return[Ci,Ft];case"DataView":return[an,n]}return n.includes("Array")?[an,n]:n.includes("Error")?[pa,n]:[On,n]},yn=([e,t])=>e===Jn&&(t==="function"||t==="symbol"),rm=(e,t,n,r)=>{const i=(o,a)=>{const l=r.push(o)-1;return n.set(a,l),l},s=o=>{if(n.has(o))return n.get(o);let[a,l]=en(o);switch(a){case Jn:{let u=o;switch(l){case"bigint":a=da,u=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);u=null;break;case"undefined":return i([ha],o)}return i([a,u],o)}case an:{if(l){let p=o;return l==="DataView"?p=new Uint8Array(o.buffer):l==="ArrayBuffer"&&(p=new Uint8Array(o)),i([l,[...p]],o)}const u=[],f=i([a,u],o);for(const p of o)u.push(s(p));return f}case On:{if(l)switch(l){case"BigInt":return i([l,o.toString()],o);case"Boolean":case"Number":case"String":return i([l,o.valueOf()],o)}if(t&&"toJSON"in o)return s(o.toJSON());const u=[],f=i([a,u],o);for(const p of nm(o))(e||!yn(en(o[p])))&&u.push([s(p),s(o[p])]);return f}case ki:return i([a,o.toISOString()],o);case Si:{const{source:u,flags:f}=o;return i([a,{source:u,flags:f}],o)}case vi:{const u=[],f=i([a,u],o);for(const[p,d]of o)(e||!(yn(en(p))||yn(en(d))))&&u.push([s(p),s(d)]);return f}case Ci:{const u=[],f=i([a,u],o);for(const p of o)(e||!yn(en(p)))&&u.push(s(p));return f}}const{message:c}=o;return i([a,{name:l,message:c}],o)};return s},Cs=(e,{json:t,lossy:n}={})=>{const r=[];return rm(!(t||n),!!t,new Map,r)(e),r},Fn=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?vs(Cs(e,t)):structuredClone(e):(e,t)=>vs(Cs(e,t));function im(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 sm(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function om(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||im,r=e.options.footnoteBackLabel||sm,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let l=-1;for(;++l<e.footnoteOrder.length;){const c=e.footnoteById.get(e.footnoteOrder[l]);if(!c)continue;const u=e.all(c),f=String(c.identifier).toUpperCase(),p=Wt(f.toLowerCase());let d=0;const g=[],y=e.footnoteCounts.get(f);for(;y!==void 0&&++d<=y;){g.length>0&&g.push({type:"text",value:" "});let S=typeof n=="string"?n:n(l,d);typeof S=="string"&&(S={type:"text",value:S}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,d),className:["data-footnote-backref"]},children:Array.isArray(S)?S:[S]})}const k=u[u.length-1];if(k&&k.type==="element"&&k.tagName==="p"){const S=k.children[k.children.length-1];S&&S.type==="text"?S.value+=" ":k.children.push({type:"text",value:" "}),k.children.push(...g)}else u.push(...g);const w={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(u,!0)};e.patch(c,w),a.push(w)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...Fn(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
74
+ `},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:`
75
+ `}]}}const Zn=(function(e){if(e==null)return um;if(typeof e=="function")return er(e);if(typeof e=="object")return Array.isArray(e)?am(e):lm(e);if(typeof e=="string")return cm(e);throw new Error("Expected function, string, or object as test")});function am(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Zn(e[n]);return er(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function lm(e){const t=e;return er(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function cm(e){return er(t);function t(n){return n&&n.type===e}}function er(e){return t;function t(n,r,i){return!!(fm(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function um(){return!0}function fm(e){return e!==null&&typeof e=="object"&&"type"in e}const ma=[],hm=!0,Br=!1,pm="skip";function ga(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=Zn(i),o=r?-1:1;a(e,void 0,[])();function a(l,c,u){const f=l&&typeof l=="object"?l:{};if(typeof f.type=="string"){const d=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(l.type+(d?"<"+d+">":""))+")"})}return p;function p(){let d=ma,g,y,k;if((!t||s(l,c,u[u.length-1]||void 0))&&(d=dm(n(l,u)),d[0]===Br))return d;if("children"in l&&l.children){const w=l;if(w.children&&d[0]!==pm)for(y=(r?w.children.length:-1)+o,k=u.concat(w);y>-1&&y<w.children.length;){const S=w.children[y];if(g=a(S,y,k)(),g[0]===Br)return g;y=typeof g[1]=="number"?g[1]:y+o}}return d}}}function dm(e){return Array.isArray(e)?e:typeof e=="number"?[hm,e]:e==null?ma:[e]}function Ei(e,t,n,r){let i,s,o;typeof t=="function"&&typeof n!="function"?(s=void 0,o=t,i=n):(s=t,o=n,i=r),ga(e,s,a,i);function a(l,c){const u=c[c.length-1],f=u?u.children.indexOf(l):void 0;return o(l,f,u)}}const Hr={}.hasOwnProperty,mm={};function gm(e,t){const n=t||mm,r=new Map,i=new Map,s=new Map,o={...Zd,...n.handlers},a={all:c,applyData:ym,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:o,one:l,options:n,patch:xm,wrap:wm};return Ei(e,function(u){if(u.type==="definition"||u.type==="footnoteDefinition"){const f=u.type==="definition"?r:i,p=String(u.identifier).toUpperCase();f.has(p)||f.set(p,u)}}),a;function l(u,f){const p=u.type,d=a.handlers[p];if(Hr.call(a.handlers,p)&&d)return d(a,u,f);if(a.options.passThrough&&a.options.passThrough.includes(p)){if("children"in u){const{children:y,...k}=u,w=Fn(k);return w.children=a.all(u),w}return Fn(u)}return(a.options.unknownHandler||bm)(a,u,f)}function c(u){const f=[];if("children"in u){const p=u.children;let d=-1;for(;++d<p.length;){const g=a.one(p[d],u);if(g){if(d&&p[d-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=Es(g.value)),!Array.isArray(g)&&g.type==="element")){const y=g.children[0];y&&y.type==="text"&&(y.value=Es(y.value))}Array.isArray(g)?f.push(...g):f.push(g)}}}return f}}function xm(e,t){e.position&&(t.position=sh(e))}function ym(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 o="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:o}}n.type==="element"&&s&&Object.assign(n.properties,Fn(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function bm(e,t){const n=t.data||{},r="value"in t&&!(Hr.call(n,"hProperties")||Hr.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 wm(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
76
+ `});++r<e.length;)r&&n.push({type:"text",value:`
77
+ `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
78
+ `}),n}function Es(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Ts(e,t){const n=gm(e,t),r=n.one(e,void 0),i=om(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&s.children.push({type:"text",value:`
79
+ `},i),s}function km(e,t){return e&&"run"in e?async function(n,r){const i=Ts(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Ts(n,{file:r,...e||t})}}function js(e){if(e)throw e}var mr,As;function Sm(){if(As)return mr;As=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(c){return typeof Array.isArray=="function"?Array.isArray(c):t.call(c)==="[object Array]"},s=function(c){if(!c||t.call(c)!=="[object Object]")return!1;var u=e.call(c,"constructor"),f=c.constructor&&c.constructor.prototype&&e.call(c.constructor.prototype,"isPrototypeOf");if(c.constructor&&!u&&!f)return!1;var p;for(p in c);return typeof p>"u"||e.call(c,p)},o=function(c,u){n&&u.name==="__proto__"?n(c,u.name,{enumerable:!0,configurable:!0,value:u.newValue,writable:!0}):c[u.name]=u.newValue},a=function(c,u){if(u==="__proto__")if(e.call(c,u)){if(r)return r(c,u).value}else return;return c[u]};return mr=function l(){var c,u,f,p,d,g,y=arguments[0],k=1,w=arguments.length,S=!1;for(typeof y=="boolean"&&(S=y,y=arguments[1]||{},k=2),(y==null||typeof y!="object"&&typeof y!="function")&&(y={});k<w;++k)if(c=arguments[k],c!=null)for(u in c)f=a(y,u),p=a(c,u),y!==p&&(S&&p&&(s(p)||(d=i(p)))?(d?(d=!1,g=f&&i(f)?f:[]):g=f&&s(f)?f:{},o(y,{name:u,newValue:l(S,g,p)})):typeof p<"u"&&o(y,{name:u,newValue:p}));return y},mr}var vm=Sm();const gr=Zs(vm);function Ur(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 Cm(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);a(null,...i);function a(l,...c){const u=e[++s];let f=-1;if(l){o(l);return}for(;++f<i.length;)(c[f]===null||c[f]===void 0)&&(c[f]=i[f]);i=c,u?Em(u,a)(...c):o(null,...c)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function Em(e,t){let n;return r;function r(...o){const a=e.length>o.length;let l;a&&o.push(i);try{l=e.apply(this,o)}catch(c){const u=c;if(a&&n)throw u;return i(u)}a||(l&&l.then&&typeof l.then=="function"?l.then(s,i):l instanceof Error?i(l):s(l))}function i(o,...a){n||(n=!0,t(o,...a))}function s(o){i(null,o)}}const at={basename:Tm,dirname:jm,extname:Am,join:Im,sep:"/"};function Tm(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');hn(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 o=-1,a=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else o<0&&(s=!0,o=i+1),a>-1&&(e.codePointAt(i)===t.codePointAt(a--)?a<0&&(r=i):(a=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function jm(e){if(hn(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 Am(e){hn(e);let t=e.length,n=-1,r=0,i=-1,s=0,o;for(;t--;){const a=e.codePointAt(t);if(a===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),a===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 Im(...e){let t=-1,n;for(;++t<e.length;)hn(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":Rm(n)}function Rm(e){hn(e);const t=e.codePointAt(0)===47;let n=Nm(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function Nm(e,t){let n="",r=0,i=-1,s=0,o=-1,a,l;for(;++o<=e.length;){if(o<e.length)a=e.codePointAt(o);else{if(a===47)break;a=47}if(a===47){if(!(i===o-1||s===1))if(i!==o-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(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",r=0):(n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/")),i=o,s=0;continue}}else if(n.length>0){n="",r=0,i=o,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,s=0}else a===46&&s>-1?s++:s=-1}return n}function hn(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Lm={cwd:Mm};function Mm(){return"/"}function qr(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function Dm(e){if(typeof e=="string")e=new URL(e);else if(!qr(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 zm(e)}function zm(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 xr=["history","path","basename","stem","extname","dirname"];class xa{constructor(t){let n;t?qr(t)?n={path:t}:typeof t=="string"||Pm(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":Lm.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<xr.length;){const s=xr[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)xr.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?at.basename(this.path):void 0}set basename(t){br(t,"basename"),yr(t,"basename"),this.path=at.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?at.dirname(this.path):void 0}set dirname(t){Is(this.basename,"dirname"),this.path=at.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?at.extname(this.path):void 0}set extname(t){if(yr(t,"extname"),Is(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=at.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){qr(t)&&(t=Dm(t)),br(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?at.basename(this.path,this.extname):void 0}set stem(t){br(t,"stem"),yr(t,"stem"),this.path=at.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 De(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 yr(e,t){if(e&&e.includes(at.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+at.sep+"`")}function br(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Is(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function Pm(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const _m=(function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s}),Om={}.hasOwnProperty;class Ti extends _m{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=Cm()}copy(){const t=new Ti;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(gr(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Sr("data",this.frozen),this.namespace[t]=n,this):Om.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Sr("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=bn(t),r=this.parser||this.Parser;return wr("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),wr("process",this.parser||this.Parser),kr("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,o){const a=bn(t),l=r.parse(a);r.run(l,a,function(u,f,p){if(u||!f||!p)return c(u);const d=f,g=r.stringify(d,p);Bm(g)?p.value=g:p.result=g,c(u,p)});function c(u,f){u||!f?o(u):s?s(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),wr("processSync",this.parser||this.Parser),kr("processSync",this.compiler||this.Compiler),this.process(t,i),Ns("processSync","process",n),r;function i(s,o){n=!0,js(s),r=o}}run(t,n,r){Rs(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(o,a){const l=bn(n);i.run(t,l,c);function c(u,f,p){const d=f||t;u?a(u):o?o(d):r(void 0,d,p)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),Ns("runSync","run",r),i;function s(o,a){js(o),i=a,r=!0}}stringify(t,n){this.freeze();const r=bn(n),i=this.compiler||this.Compiler;return kr("stringify",i),Rs(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(Sr("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?a(t):o(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(c){if(typeof c=="function")l(c,[]);else if(typeof c=="object")if(Array.isArray(c)){const[u,...f]=c;l(u,f)}else o(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function o(c){if(!("plugins"in c)&&!("settings"in c))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");a(c.plugins),c.settings&&(i.settings=gr(!0,i.settings,c.settings))}function a(c){let u=-1;if(c!=null)if(Array.isArray(c))for(;++u<c.length;){const f=c[u];s(f)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,u){let f=-1,p=-1;for(;++f<r.length;)if(r[f][0]===c){p=f;break}if(p===-1)r.push([c,...u]);else if(u.length>0){let[d,...g]=u;const y=r[p][1];Ur(y)&&Ur(d)&&(d=gr(!0,y,d)),r[p]=[c,d,...g]}}}}const Fm=new Ti().freeze();function wr(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function kr(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Sr(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 Rs(e){if(!Ur(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Ns(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function bn(e){return $m(e)?e:new xa(e)}function $m(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Bm(e){return typeof e=="string"||Hm(e)}function Hm(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Um="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Ls=[],Ms={allowDangerousHtml:!0},qm=/^(https?|ircs?|mailto|xmpp)$/i,Wm=[{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:"className",id:"remove-classname"},{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 Km(e){const t=Vm(e),n=Xm(e);return Ym(t.runSync(t.parse(n),n),e)}function Vm(e){const t=e.rehypePlugins||Ls,n=e.remarkPlugins||Ls,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Ms}:Ms;return Fm().use(jd).use(n).use(km,r).use(t)}function Xm(e){const t=e.children||"",n=new xa;return typeof t=="string"&&(n.value=t),n}function Ym(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,o=t.skipHtml,a=t.unwrapDisallowed,l=t.urlTransform||Gm;for(const u of Wm)Object.hasOwn(t,u.from)&&(""+u.from+(u.to?"use `"+u.to+"` instead":"remove it")+Um+u.id,void 0);return Ei(e,c),uh(e,{Fragment:h.Fragment,components:i,ignoreInvalidStyle:!0,jsx:h.jsx,jsxs:h.jsxs,passKeys:!0,passNode:!0});function c(u,f,p){if(u.type==="raw"&&p&&typeof f=="number")return o?p.children.splice(f,1):p.children[f]={type:"text",value:u.value},f;if(u.type==="element"){let d;for(d in hr)if(Object.hasOwn(hr,d)&&Object.hasOwn(u.properties,d)){const g=u.properties[d],y=hr[d];(y===null||y.includes(u.tagName))&&(u.properties[d]=l(String(g||""),d,u))}}if(u.type==="element"){let d=n?!n.includes(u.tagName):s?s.includes(u.tagName):!1;if(!d&&r&&typeof f=="number"&&(d=!r(u,f,p)),d&&p&&typeof f=="number")return a&&u.children?p.children.splice(f,1,...u.children):p.children.splice(f,1),f}}}function Gm(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||qm.test(e.slice(0,t))?e:""}function Qm(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function ya(e,t,n){const i=Zn((n||{}).ignore||[]),s=Jm(t);let o=-1;for(;++o<s.length;)ga(e,"text",a);function a(c,u){let f=-1,p;for(;++f<u.length;){const d=u[f],g=p?p.children:void 0;if(i(d,g?g.indexOf(d):void 0,p))return;p=d}if(p)return l(c,u)}function l(c,u){const f=u[u.length-1],p=s[o][0],d=s[o][1];let g=0;const k=f.children.indexOf(c);let w=!1,S=[];p.lastIndex=0;let E=p.exec(c.value);for(;E;){const N=E.index,M={index:E.index,input:E.input,stack:[...u,c]};let v=d(...E,M);if(typeof v=="string"&&(v=v.length>0?{type:"text",value:v}:void 0),v===!1?p.lastIndex=N+1:(g!==N&&S.push({type:"text",value:c.value.slice(g,N)}),Array.isArray(v)?S.push(...v):v&&S.push(v),g=N+E[0].length,w=!0),!p.global)break;E=p.exec(c.value)}return w?(g<c.value.length&&S.push({type:"text",value:c.value.slice(g)}),f.children.splice(k,1,...S)):S=[c],k+S.length}}function Jm(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([Zm(i[0]),eg(i[1])])}return t}function Zm(e){return typeof e=="string"?new RegExp(Qm(e),"g"):e}function eg(e){return typeof e=="function"?e:function(){return e}}function tg(e){ya(e,[/\r?\n|\r/g,ng])}function ng(){return{type:"break"}}function rg(){return function(e){tg(e)}}const vr="phrasing",Cr=["autolink","link","image","label"];function ig(){return{transforms:[fg],enter:{literalAutolink:og,literalAutolinkEmail:Er,literalAutolinkHttp:Er,literalAutolinkWww:Er},exit:{literalAutolink:ug,literalAutolinkEmail:cg,literalAutolinkHttp:ag,literalAutolinkWww:lg}}}function sg(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:vr,notInConstruct:Cr},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:vr,notInConstruct:Cr},{character:":",before:"[ps]",after:"\\/",inConstruct:vr,notInConstruct:Cr}]}}function og(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Er(e){this.config.enter.autolinkProtocol.call(this,e)}function ag(e){this.config.exit.autolinkProtocol.call(this,e)}function lg(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function cg(e){this.config.exit.autolinkEmail.call(this,e)}function ug(e){this.exit(e)}function fg(e){ya(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,hg],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),pg]],{ignore:["link","linkReference"]})}function hg(e,t,n,r,i){let s="";if(!ba(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!dg(n)))return!1;const o=mg(n+r);if(!o[0])return!1;const a={type:"link",title:null,url:s+t+o[0],children:[{type:"text",value:t+o[0]}]};return o[1]?[a,{type:"text",value:o[1]}]:a}function pg(e,t,n,r){return!ba(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function dg(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 mg(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=$i(e,"(");let s=$i(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 ba(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Mt(n)||Gn(n))&&(!t||n!==47)}wa.peek=Cg;function gg(){this.buffer()}function xg(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function yg(){this.buffer()}function bg(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function wg(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=nt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function kg(e){this.exit(e)}function Sg(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=nt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function vg(e){this.exit(e)}function Cg(){return"["}function wa(e,t,n,r){const i=n.createTracker(r);let s=i.move("[^");const o=n.enter("footnoteReference"),a=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),a(),o(),s+=i.move("]"),s}function Eg(){return{enter:{gfmFootnoteCallString:gg,gfmFootnoteCall:xg,gfmFootnoteDefinitionLabelString:yg,gfmFootnoteDefinition:bg},exit:{gfmFootnoteCallString:wg,gfmFootnoteCall:kg,gfmFootnoteDefinitionLabelString:Sg,gfmFootnoteDefinition:vg}}}function Tg(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:wa},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,o){const a=s.createTracker(o);let l=a.move("[^");const c=s.enter("footnoteDefinition"),u=s.enter("label");return l+=a.move(s.safe(s.associationId(r),{before:l,after:"]"})),u(),l+=a.move("]:"),r.children&&r.children.length>0&&(a.shift(4),l+=a.move((t?`
80
+ `:" ")+s.indentLines(s.containerFlow(r,a.current()),t?ka:jg))),c(),l}}function jg(e,t,n){return t===0?e:ka(e,t,n)}function ka(e,t,n){return(n?"":" ")+e}const Ag=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Sa.peek=Mg;function Ig(){return{canContainEols:["delete"],enter:{strikethrough:Ng},exit:{strikethrough:Lg}}}function Rg(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Ag}],handlers:{delete:Sa}}}function Ng(e){this.enter({type:"delete",children:[]},e)}function Lg(e){this.exit(e)}function Sa(e,t,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let o=i.move("~~");return o+=n.containerPhrasing(e,{...i.current(),before:o,after:"~"}),o+=i.move("~~"),s(),o}function Mg(){return"~"}function Dg(e){return e.length}function zg(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||Dg,s=[],o=[],a=[],l=[];let c=0,u=-1;for(;++u<e.length;){const y=[],k=[];let w=-1;for(e[u].length>c&&(c=e[u].length);++w<e[u].length;){const S=Pg(e[u][w]);if(n.alignDelimiters!==!1){const E=i(S);k[w]=E,(l[w]===void 0||E>l[w])&&(l[w]=E)}y.push(S)}o[u]=y,a[u]=k}let f=-1;if(typeof r=="object"&&"length"in r)for(;++f<c;)s[f]=Ds(r[f]);else{const y=Ds(r);for(;++f<c;)s[f]=y}f=-1;const p=[],d=[];for(;++f<c;){const y=s[f];let k="",w="";y===99?(k=":",w=":"):y===108?k=":":y===114&&(w=":");let S=n.alignDelimiters===!1?1:Math.max(1,l[f]-k.length-w.length);const E=k+"-".repeat(S)+w;n.alignDelimiters!==!1&&(S=k.length+S+w.length,S>l[f]&&(l[f]=S),d[f]=S),p[f]=E}o.splice(1,0,p),a.splice(1,0,d),u=-1;const g=[];for(;++u<o.length;){const y=o[u],k=a[u];f=-1;const w=[];for(;++f<c;){const S=y[f]||"";let E="",N="";if(n.alignDelimiters!==!1){const M=l[f]-(k[f]||0),v=s[f];v===114?E=" ".repeat(M):v===99?M%2?(E=" ".repeat(M/2+.5),N=" ".repeat(M/2-.5)):(E=" ".repeat(M/2),N=E):N=" ".repeat(M)}n.delimiterStart!==!1&&!f&&w.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&S==="")&&(n.delimiterStart!==!1||f)&&w.push(" "),n.alignDelimiters!==!1&&w.push(E),w.push(S),n.alignDelimiters!==!1&&w.push(N),n.padding!==!1&&w.push(" "),(n.delimiterEnd!==!1||f!==c-1)&&w.push("|")}g.push(n.delimiterEnd===!1?w.join("").replace(/ +$/,""):w.join(""))}return g.join(`
81
+ `)}function Pg(e){return e==null?"":String(e)}function Ds(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 _g(e,t,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const o=n.indentLines(n.containerFlow(e,s.current()),Og);return i(),o}function Og(e,t,n){return">"+(n?"":" ")+e}function Fg(e,t){return zs(e,t.inConstruct,!0)&&!zs(e,t.notInConstruct,!1)}function zs(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 Ps(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
82
+ `&&Fg(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
83
+ `}function $g(e,t){const n=String(e);let r=n.indexOf(t),i=r,s=0,o=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>o&&(o=s):s=1,i=r+t.length,r=n.indexOf(t,i);return o}function Bg(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 Hg(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 Ug(e,t,n,r){const i=Hg(n),s=e.value||"",o=i==="`"?"GraveAccent":"Tilde";if(Bg(e,n)){const f=n.enter("codeIndented"),p=n.indentLines(s,qg);return f(),p}const a=n.createTracker(r),l=i.repeat(Math.max($g(s,i)+1,3)),c=n.enter("codeFenced");let u=a.move(l);if(e.lang){const f=n.enter(`codeFencedLang${o}`);u+=a.move(n.safe(e.lang,{before:u,after:" ",encode:["`"],...a.current()})),f()}if(e.lang&&e.meta){const f=n.enter(`codeFencedMeta${o}`);u+=a.move(" "),u+=a.move(n.safe(e.meta,{before:u,after:`
84
+ `,encode:["`"],...a.current()})),f()}return u+=a.move(`
85
+ `),s&&(u+=a.move(s+`
86
+ `)),u+=a.move(l),c(),u}function qg(e,t,n){return(n?"":" ")+e}function ji(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 Wg(e,t,n,r){const i=ji(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("definition");let a=n.enter("label");const l=n.createTracker(r);let c=l.move("[");return c+=l.move(n.safe(n.associationId(e),{before:c,after:"]",...l.current()})),c+=l.move("]: "),a(),!e.url||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":`
87
+ `,...l.current()}))),a(),e.title&&(a=n.enter(`title${s}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),a()),o(),c}function Kg(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 cn(e){return"&#x"+e.toString(16).toUpperCase()+";"}function $n(e,t,n){const r=Ut(e),i=Ut(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}}va.peek=Vg;function va(e,t,n,r){const i=Kg(n),s=n.enter("emphasis"),o=n.createTracker(r),a=o.move(i);let l=o.move(n.containerPhrasing(e,{after:i,before:a,...o.current()}));const c=l.charCodeAt(0),u=$n(r.before.charCodeAt(r.before.length-1),c,i);u.inside&&(l=cn(c)+l.slice(1));const f=l.charCodeAt(l.length-1),p=$n(r.after.charCodeAt(0),f,i);p.inside&&(l=l.slice(0,-1)+cn(f));const d=o.move(i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:u.outside},a+l+d}function Vg(e,t,n){return n.options.emphasis||"*"}function Xg(e,t){let n=!1;return Ei(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Br}),!!((!e.depth||e.depth<3)&&yi(e)&&(t.options.setext||n))}function Yg(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(Xg(e,n)){const u=n.enter("headingSetext"),f=n.enter("phrasing"),p=n.containerPhrasing(e,{...s.current(),before:`
88
+ `,after:`
89
+ `});return f(),u(),p+`
90
+ `+(i===1?"=":"-").repeat(p.length-(Math.max(p.lastIndexOf("\r"),p.lastIndexOf(`
91
+ `))+1))}const o="#".repeat(i),a=n.enter("headingAtx"),l=n.enter("phrasing");s.move(o+" ");let c=n.containerPhrasing(e,{before:"# ",after:`
92
+ `,...s.current()});return/^[\t ]/.test(c)&&(c=cn(c.charCodeAt(0))+c.slice(1)),c=c?o+" "+c:o,n.options.closeAtx&&(c+=" "+o),l(),a(),c}Ca.peek=Gg;function Ca(e){return e.value||""}function Gg(){return"<"}Ea.peek=Qg;function Ea(e,t,n,r){const i=ji(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("image");let a=n.enter("label");const l=n.createTracker(r);let c=l.move("![");return c+=l.move(n.safe(e.alt,{before:c,after:"]",...l.current()})),c+=l.move("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),a(),e.title&&(a=n.enter(`title${s}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),a()),c+=l.move(")"),o(),c}function Qg(){return"!"}Ta.peek=Jg;function Ta(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("![");const c=n.safe(e.alt,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),o();const u=n.stack;n.stack=[],o=n.enter("reference");const f=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=u,s(),i==="full"||!c||c!==f?l+=a.move(f+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function Jg(){return"!"}ja.peek=Zg;function ja(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 o=n.unsafe[s],a=n.compilePattern(o);let l;if(o.atBreak)for(;l=a.exec(r);){let c=l.index;r.charCodeAt(c)===10&&r.charCodeAt(c-1)===13&&c--,r=r.slice(0,c)+" "+r.slice(l.index+1)}}return i+r+i}function Zg(){return"`"}function Aa(e,t){const n=yi(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))}Ia.peek=ex;function Ia(e,t,n,r){const i=ji(n),s=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let a,l;if(Aa(e,n)){const u=n.stack;n.stack=[],a=n.enter("autolink");let f=o.move("<");return f+=o.move(n.containerPhrasing(e,{before:f,after:">",...o.current()})),f+=o.move(">"),a(),n.stack=u,f}a=n.enter("link"),l=n.enter("label");let c=o.move("[");return c+=o.move(n.containerPhrasing(e,{before:c,after:"](",...o.current()})),c+=o.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=o.move("<"),c+=o.move(n.safe(e.url,{before:c,after:">",...o.current()})),c+=o.move(">")):(l=n.enter("destinationRaw"),c+=o.move(n.safe(e.url,{before:c,after:e.title?" ":")",...o.current()}))),l(),e.title&&(l=n.enter(`title${s}`),c+=o.move(" "+i),c+=o.move(n.safe(e.title,{before:c,after:i,...o.current()})),c+=o.move(i),l()),c+=o.move(")"),a(),c}function ex(e,t,n){return Aa(e,n)?"<":"["}Ra.peek=tx;function Ra(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("[");const c=n.containerPhrasing(e,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),o();const u=n.stack;n.stack=[],o=n.enter("reference");const f=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=u,s(),i==="full"||!c||c!==f?l+=a.move(f+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function tx(){return"["}function Ai(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 nx(e){const t=Ai(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 rx(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 Na(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 ix(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let o=e.ordered?rx(n):Ai(n);const a=e.ordered?o==="."?")":".":nx(n);let l=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){const u=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&u&&(!u.children||!u.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&&(l=!0),Na(n)===o&&u){let f=-1;for(;++f<e.children.length;){const p=e.children[f];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(o=a),n.bulletCurrent=o;const c=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=s,i(),c}function sx(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 ox(e,t,n,r){const i=sx(n);let s=n.bulletCurrent||Ai(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 o=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);const a=n.createTracker(r);a.move(s+" ".repeat(o-s.length)),a.shift(o);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,a.current()),u);return l(),c;function u(f,p,d){return p?(d?"":" ".repeat(o))+f:(d?s:s+" ".repeat(o-s.length))+f}}function ax(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),o=n.containerPhrasing(e,r);return s(),i(),o}const lx=Zn(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function cx(e,t,n,r){return(e.children.some(function(o){return lx(o)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function ux(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}La.peek=fx;function La(e,t,n,r){const i=ux(n),s=n.enter("strong"),o=n.createTracker(r),a=o.move(i+i);let l=o.move(n.containerPhrasing(e,{after:i,before:a,...o.current()}));const c=l.charCodeAt(0),u=$n(r.before.charCodeAt(r.before.length-1),c,i);u.inside&&(l=cn(c)+l.slice(1));const f=l.charCodeAt(l.length-1),p=$n(r.after.charCodeAt(0),f,i);p.inside&&(l=l.slice(0,-1)+cn(f));const d=o.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:u.outside},a+l+d}function fx(e,t,n){return n.options.strong||"*"}function hx(e,t,n,r){return n.safe(e.value,r)}function px(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 dx(e,t,n){const r=(Na(n)+(n.options.ruleSpaces?" ":"")).repeat(px(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Ma={blockquote:_g,break:Ps,code:Ug,definition:Wg,emphasis:va,hardBreak:Ps,heading:Yg,html:Ca,image:Ea,imageReference:Ta,inlineCode:ja,link:Ia,linkReference:Ra,list:ix,listItem:ox,paragraph:ax,root:cx,strong:La,text:hx,thematicBreak:dx};function mx(){return{enter:{table:gx,tableData:_s,tableHeader:_s,tableRow:yx},exit:{codeText:bx,table:xx,tableData:Tr,tableHeader:Tr,tableRow:Tr}}}function gx(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 xx(e){this.exit(e),this.data.inTable=void 0}function yx(e){this.enter({type:"tableRow",children:[]},e)}function Tr(e){this.exit(e)}function _s(e){this.enter({type:"tableCell",children:[]},e)}function bx(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,wx));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function wx(e,t){return t==="|"?t:e}function kx(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
93
+ `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:o,tableCell:l,tableRow:a}};function o(d,g,y,k){return c(u(d,y,k),d.align)}function a(d,g,y,k){const w=f(d,y,k),S=c([w]);return S.slice(0,S.indexOf(`
94
+ `))}function l(d,g,y,k){const w=y.enter("tableCell"),S=y.enter("phrasing"),E=y.containerPhrasing(d,{...k,before:s,after:s});return S(),w(),E}function c(d,g){return zg(d,{align:g,alignDelimiters:r,padding:n,stringLength:i})}function u(d,g,y){const k=d.children;let w=-1;const S=[],E=g.enter("table");for(;++w<k.length;)S[w]=f(k[w],g,y);return E(),S}function f(d,g,y){const k=d.children;let w=-1;const S=[],E=g.enter("tableRow");for(;++w<k.length;)S[w]=l(k[w],d,g,y);return E(),S}function p(d,g,y){let k=Ma.inlineCode(d,g,y);return y.stack.includes("tableCell")&&(k=k.replace(/\|/g,"\\$&")),k}}function Sx(){return{exit:{taskListCheckValueChecked:Os,taskListCheckValueUnchecked:Os,paragraph:Cx}}}function vx(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Ex}}}function Os(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function Cx(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];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===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 Ex(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let l=Ma.listItem(e,t,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(u){return u+o}}function Tx(){return[ig(),Eg(),Ig(),mx(),Sx()]}function jx(e){return{extensions:[sg(),Tg(e),Rg(),kx(e),vx()]}}const Ax={tokenize:Dx,partial:!0},Da={tokenize:zx,partial:!0},za={tokenize:Px,partial:!0},Pa={tokenize:_x,partial:!0},Ix={tokenize:Ox,partial:!0},_a={name:"wwwAutolink",tokenize:Lx,previous:Fa},Oa={name:"protocolAutolink",tokenize:Mx,previous:$a},xt={name:"emailAutolink",tokenize:Nx,previous:Ba},ct={};function Rx(){return{text:ct}}let At=48;for(;At<123;)ct[At]=xt,At++,At===58?At=65:At===91&&(At=97);ct[43]=xt;ct[45]=xt;ct[46]=xt;ct[95]=xt;ct[72]=[xt,Oa];ct[104]=[xt,Oa];ct[87]=[xt,_a];ct[119]=[xt,_a];function Nx(e,t,n){const r=this;let i,s;return o;function o(f){return!Wr(f)||!Ba.call(r,r.previous)||Ii(r.events)?n(f):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(f))}function a(f){return Wr(f)?(e.consume(f),a):f===64?(e.consume(f),l):n(f)}function l(f){return f===46?e.check(Ix,u,c)(f):f===45||f===95||Me(f)?(s=!0,e.consume(f),l):u(f)}function c(f){return e.consume(f),i=!0,l}function u(f){return s&&i&&Pe(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(f)):n(f)}}function Lx(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!Fa.call(r,r.previous)||Ii(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(Ax,e.attempt(Da,e.attempt(za,s),n),n)(o))}function s(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function Mx(e,t,n){const r=this;let i="",s=!1;return o;function o(f){return(f===72||f===104)&&$a.call(r,r.previous)&&!Ii(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(f),e.consume(f),a):n(f)}function a(f){if(Pe(f)&&i.length<5)return i+=String.fromCodePoint(f),e.consume(f),a;if(f===58){const p=i.toLowerCase();if(p==="http"||p==="https")return e.consume(f),l}return n(f)}function l(f){return f===47?(e.consume(f),s?c:(s=!0,l)):n(f)}function c(f){return f===null||_n(f)||de(f)||Mt(f)||Gn(f)?n(f):e.attempt(Da,e.attempt(za,u),n)(f)}function u(f){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(f)}}function Dx(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),s):n(o)}function s(o){return o===null?n(o):t(o)}}function zx(e,t,n){let r,i,s;return o;function o(c){return c===46||c===95?e.check(Pa,l,a)(c):c===null||de(c)||Mt(c)||c!==45&&Gn(c)?l(c):(s=!0,e.consume(c),o)}function a(c){return c===95?r=!0:(i=r,r=void 0),e.consume(c),o}function l(c){return i||r||!s?n(c):t(c)}}function Px(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Pa,t,s)(o):o===null||de(o)||Mt(o)?t(o):(e.consume(o),i)}function s(o){return o===41&&r++,e.consume(o),i}}function _x(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),s):a===93?(e.consume(a),i):a===60||a===null||de(a)||Mt(a)?t(a):n(a)}function i(a){return a===null||a===40||a===91||de(a)||Mt(a)?t(a):r(a)}function s(a){return Pe(a)?o(a):n(a)}function o(a){return a===59?(e.consume(a),r):Pe(a)?(e.consume(a),o):n(a)}}function Ox(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return Me(s)?n(s):t(s)}}function Fa(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||de(e)}function $a(e){return!Pe(e)}function Ba(e){return!(e===47||Wr(e))}function Wr(e){return e===43||e===45||e===46||e===95||Me(e)}function Ii(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 Fx={tokenize:Vx,partial:!0};function $x(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:qx,continuation:{tokenize:Wx},exit:Kx}},text:{91:{name:"gfmFootnoteCall",tokenize:Ux},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Bx,resolveTo:Hx}}}}function Bx(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const c=nt(r.sliceSerialize({start:o.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function Hx(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)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[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",o,t],["exit",o,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function Ux(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(f){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),l}function l(f){return f!==94?n(f):(e.enter("gfmFootnoteCallMarker"),e.consume(f),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(f){if(s>999||f===93&&!o||f===null||f===91||de(f))return n(f);if(f===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(nt(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(f)}return de(f)||(o=!0),s++,e.consume(f),f===92?u:c}function u(f){return f===91||f===92||f===93?(e.consume(f),s++,c):c(f)}}function qx(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;return l;function l(g){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(g){return g===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",u):n(g)}function u(g){if(o>999||g===93&&!a||g===null||g===91||de(g))return n(g);if(g===93){e.exit("chunkString");const y=e.exit("gfmFootnoteDefinitionLabelString");return s=nt(r.sliceSerialize(y)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return de(g)||(a=!0),o++,e.consume(g),g===92?f:u}function f(g){return g===91||g===92||g===93?(e.consume(g),o++,u):u(g)}function p(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),i.includes(s)||i.push(s),ue(e,d,"gfmFootnoteDefinitionWhitespace")):n(g)}function d(g){return t(g)}}function Wx(e,t,n){return e.check(fn,t,e.attempt(Fx,t,n))}function Kx(e){e.exit("gfmFootnoteDefinition")}function Vx(e,t,n){const r=this;return ue(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(s):n(s)}}function Xx(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(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},f={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},p=[["enter",u,a],["enter",o[c][1],a],["exit",o[c][1],a],["enter",f,a]],d=a.parser.constructs.insideSpan.null;d&&He(p,p.length,0,Qn(d,o.slice(c+1,l),a)),He(p,p.length,0,[["exit",f,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",u,a]]),He(o,c-1,l-c+3,p),l=c+p.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){const c=this.previous,u=this.events;let f=0;return p;function p(g){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(g):(o.enter("strikethroughSequenceTemporary"),d(g))}function d(g){const y=Ut(c);if(g===126)return f>1?l(g):(o.consume(g),f++,d);if(f<2&&!n)return l(g);const k=o.exit("strikethroughSequenceTemporary"),w=Ut(g);return k._open=!w||w===2&&!!y,k._close=!y||y===2&&!!w,a(g)}}}class Yx{constructor(){this.map=[]}add(t,n,r){Gx(this,t,n,r)}consume(t){if(this.map.sort(function(s,o){return s[0]-o[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 Gx(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 Qx(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 Jx(){return{flow:{null:{name:"table",tokenize:Zx,resolveAll:ey}}}}function Zx(e,t,n){const r=this;let i=0,s=0,o;return a;function a(C){let z=r.events.length-1;for(;z>-1;){const R=r.events[z][1].type;if(R==="lineEnding"||R==="linePrefix")z--;else break}const j=z>-1?r.events[z][1].type:null,_=j==="tableHead"||j==="tableRow"?v:l;return _===v&&r.parser.lazy[r.now().line]?n(C):_(C)}function l(C){return e.enter("tableHead"),e.enter("tableRow"),c(C)}function c(C){return C===124||(o=!0,s+=1),u(C)}function u(C){return C===null?n(C):Q(C)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),d):n(C):oe(C)?ue(e,u,"whitespace")(C):(s+=1,o&&(o=!1,i+=1),C===124?(e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),o=!0,u):(e.enter("data"),f(C)))}function f(C){return C===null||C===124||de(C)?(e.exit("data"),u(C)):(e.consume(C),C===92?p:f)}function p(C){return C===92||C===124?(e.consume(C),f):f(C)}function d(C){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(C):(e.enter("tableDelimiterRow"),o=!1,oe(C)?ue(e,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):g(C))}function g(C){return C===45||C===58?k(C):C===124?(o=!0,e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),y):M(C)}function y(C){return oe(C)?ue(e,k,"whitespace")(C):k(C)}function k(C){return C===58?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(C),e.exit("tableDelimiterMarker"),w):C===45?(s+=1,w(C)):C===null||Q(C)?N(C):M(C)}function w(C){return C===45?(e.enter("tableDelimiterFiller"),S(C)):M(C)}function S(C){return C===45?(e.consume(C),S):C===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(C),e.exit("tableDelimiterMarker"),E):(e.exit("tableDelimiterFiller"),E(C))}function E(C){return oe(C)?ue(e,N,"whitespace")(C):N(C)}function N(C){return C===124?g(C):C===null||Q(C)?!o||i!==s?M(C):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(C)):M(C)}function M(C){return n(C)}function v(C){return e.enter("tableRow"),F(C)}function F(C){return C===124?(e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),F):C===null||Q(C)?(e.exit("tableRow"),t(C)):oe(C)?ue(e,F,"whitespace")(C):(e.enter("data"),U(C))}function U(C){return C===null||C===124||de(C)?(e.exit("data"),F(C)):(e.consume(C),C===92?D:U)}function D(C){return C===92||C===124?(e.consume(C),U):U(C)}}function ey(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,c,u,f;const p=new Yx;for(;++n<e.length;){const d=e[n],g=d[1];d[0]==="enter"?g.type==="tableHead"?(a=!1,l!==0&&(Fs(p,t,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.add(n,0,[["enter",c,t]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,f=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,u={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.add(n,0,[["enter",u,t]])),i=g.type==="tableDelimiterRow"?2:u?3:1):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],f=wn(p,t,s,i,void 0,f),s=[0,0,0,0]),o[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],f=wn(p,t,s,i,void 0,f)),s=o,o=[s[1],n,0,0])):g.type==="tableHead"?(a=!0,l=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],f=wn(p,t,s,i,n,f)):o[1]!==0&&(f=wn(p,t,o,i,n,f)),i=0):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&Fs(p,t,l,c,u),p.consume(t.events),n=-1;++n<t.events.length;){const d=t.events[n];d[0]==="enter"&&d[1].type==="table"&&(d[1]._align=Qx(t.events,n))}return e}function wn(e,t,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},Bt(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=Bt(t.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const c=Bt(t.events,n[2]),u=Bt(t.events,n[3]),f={type:a,start:Object.assign({},c),end:Object.assign({},u)};if(e.add(n[2],0,[["enter",f,t]]),r!==2){const p=t.events[n[2]],d=t.events[n[3]];if(p[1].end=Object.assign({},d[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,y=n[3]-n[2]-1;e.add(g,y,[])}}e.add(n[3]+1,0,[["exit",f,t]])}return i!==void 0&&(s.end=Object.assign({},Bt(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function Fs(e,t,n,r,i){const s=[],o=Bt(t.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,t])),r.end=Object.assign({},o),s.push(["exit",r,t]),e.add(n+1,0,s)}function Bt(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const ty={name:"tasklistCheck",tokenize:ry};function ny(){return{text:{91:ty}}}function ry(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return de(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(l)}function a(l){return Q(l)?t(l):oe(l)?e.check({tokenize:iy},t,n)(l):n(l)}}function iy(e,t,n){return ue(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function sy(e){return Qo([Rx(),$x(),Xx(e),Jx(),ny()])}const oy={};function ay(e){const t=this,n=e||oy,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(sy(n)),s.push(Tx()),o.push(jx(n))}const ly=["md","txt","json","yaml","yml","toml","py","js","ts","tsx","jsx","css","scss","html","xml","sh","bash","go","rs","rb","php","java","kt","swift","c","cpp","h","hpp","sql","graphql","dockerfile","env","conf","cfg","ini","log","csv"],cy=ly.join("|"),uy="(?:~\\/[A-Za-z0-9._\\-\\/]*[A-Za-z0-9._\\-\\/]|\\/(?:[\\w.\\-]+\\/)*[\\w.\\-]+\\/?)",fy="(?:[A-Za-z0-9._\\-]+(?:\\/[A-Za-z0-9._\\-]+)+\\/?)",hy=`(?:[A-Za-z0-9_-][A-Za-z0-9._-]*[A-Za-z0-9_-]\\.(?:${cy})|dockerfile)`,Bn=new RegExp(`(^|[\\s"'(,;:])(${uy}|${fy}|${hy})(?=$|[\\s"'),;:!?])`,"gi");function py(e){if(!e)return{path:e??"",trailing:""};const t=e.match(/^(.*?)([),.;:!?]+)?$/);return t?{path:t[1]||e,trailing:t[2]||""}:{path:e,trailing:""}}function dy(e){if(!e)return!1;Bn.lastIndex=0;const t=Bn.exec(e);if(!t)return!1;const n=t[1]||"",r=t[2]||"",i=t.index+n.length,s=i+r.length;return i===0&&s===e.length}function my(e){if(!e)return[{type:"text",value:e}];const t=[];let n=0;Bn.lastIndex=0;let r;for(;(r=Bn.exec(e))!==null;){const i=r[1]||"",s=r[2]||"",o=r[0],a=r.index,l=a,c=a+i.length;l>n&&t.push({type:"text",value:e.slice(n,l)}),i&&t.push({type:"text",value:i});const{path:u,trailing:f}=py(s);u.length>1?(t.push({type:"path",value:u}),f&&t.push({type:"text",value:f})):t.push({type:"text",value:o}),n=c+s.length}return n<e.length&&t.push({type:"text",value:e.slice(n)}),t.length>0?t:[{type:"text",value:e}]}function gy(e){return`openclaw-file://${encodeURIComponent(e)}`}function Ha(e){if(!e?.startsWith("openclaw-file://"))return null;try{return decodeURIComponent(e.slice(16))}catch{return null}}function xy(){return e=>{function t(n,r){if(n){if(n.type==="text"&&r&&r.type!=="link"&&r.type!=="inlineCode"&&r.type!=="code"){const i=my(String(n.value||""));if(!i.some(l=>l.type==="path"))return;const o=i.map(l=>l.type==="text"?{type:"text",value:l.value}:{type:"link",url:gy(l.value),children:[{type:"text",value:l.value}]}),a=r.children.indexOf(n);a>=0&&r.children.splice(a,1,...o);return}if(Array.isArray(n.children))for(const i of[...n.children])t(i,n)}}t(e,null)}}const yy={py:"python",ts:"typescript",js:"javascript",jsx:"jsx",tsx:"tsx",json:"json",md:"markdown",yml:"yaml",yaml:"yaml",sh:"bash",bash:"bash",zsh:"bash",html:"html",css:"css",sql:"sql",xml:"xml",toml:"toml",rs:"rust",go:"go",java:"java",c:"c",cpp:"cpp",cs:"csharp",php:"php",rb:"ruby",graphql:"graphql",diff:"diff",patch:"diff",env:"text"};function by(e){if(!e)return"text";const n=(e.split("/").pop()||"").toLowerCase();if(n==="dockerfile")return"dockerfile";if(n==="makefile")return"text";const r=n.split("."),i=r.length>1&&r.pop()||"",s=yy[i]||i||"text";return pc(s)}const wy=100*1024;function Ua(e){return e?e.includes("/")?e:`/${e}`:"/"}function jr(e){let t=Ua(e);const n=["/root/clawd/","/root/"];for(const r of n)if(t.startsWith(r)){t="/"+t.slice(r.length);break}return t.startsWith("/")?t:`/${t}`}function ky(e){const n=e.replace(/\/+$/,"").split("/").pop()||"";return!n||n.startsWith(".")?!1:n.includes(".")}function Sy(e){return e?e.endsWith("/")||!ky(e):!1}function vy(e,t){const n=String(e||"").toUpperCase(),r=String(t||"").toLowerCase();return n.includes("DIRECTORY")||r.includes("is a directory")||r.includes("directory")}function Cy(e){return pe.lexer(e).map(n=>n.raw)}function qa(e){if(!e)return"text";const t=e.match(/language-([\w-]+)/);return t?t[1]:"text"}function Wa(e){const t=e?.trim();return t&&t.split(/\s+/)[0]||void 0}const Ey={code:function({className:t,children:n,node:r}){if(!t?.includes("language-"))return h.jsx("code",{className:"rounded bg-primary-100 px-1.5 py-1 text-sm font-mono text-primary-900 border border-primary-200",children:n});const s=qa(t),o=Wa(r?.data?.meta);return h.jsx(ei,{content:String(n??""),language:s,filename:o,className:"w-full"})},pre:function({children:t}){return h.jsx(h.Fragment,{children:t})},h1:function({children:t}){return h.jsx("h1",{className:"text-xl font-medium text-primary-950",children:t})},h2:function({children:t}){return h.jsx("h2",{className:"text-lg font-medium text-primary-900",children:t})},h3:function({children:t}){return h.jsx("h3",{className:"font-medium text-primary-900",children:t})},p:function({children:t}){return h.jsx("p",{className:"text-primary-950 text-pretty leading-relaxed",children:t})},ul:function({children:t}){return h.jsx("ul",{className:"ml-4 list-disc text-primary-950 marker:text-primary-400",children:t})},ol:function({children:t}){return h.jsx("ol",{className:"ml-4 list-decimal text-primary-950 marker:text-primary-500",children:t})},li:function({children:t}){return h.jsx("li",{className:"leading-relaxed",children:t})},blockquote:function({children:t}){return h.jsx("blockquote",{className:"border-l-2 border-primary-300 pl-4 text-primary-900 italic",children:t})},strong:function({children:t}){return h.jsx("strong",{className:"font-medium text-primary-950",children:t})},em:function({children:t}){return h.jsx("em",{className:"italic text-primary-950",children:t})},hr:function(){return h.jsx("hr",{className:"my-3 border-primary-200"})},table:function({children:t}){return h.jsx("div",{className:"overflow-x-auto",children:h.jsx("table",{className:"w-full border-collapse text-sm",children:t})})},thead:function({children:t}){return h.jsx("thead",{className:"border-b border-primary-200 bg-primary-50",children:t})},tbody:function({children:t}){return h.jsx("tbody",{className:"divide-y divide-primary-100",children:t})},tr:function({children:t}){return h.jsx("tr",{className:"transition-colors hover:bg-primary-50/50",children:t})},th:function({children:t}){return h.jsx("th",{className:"px-3 py-2 text-left font-medium text-primary-950",children:t})},td:function({children:t}){return h.jsx("td",{className:"px-3 py-2 text-primary-950",children:t})}};function Ty(e){return{...Ey,a:function({children:n,href:r}){const i=Ha(r);return i?h.jsx("button",{type:"button",onClick:()=>e(i),className:"font-mono text-[var(--opencami-accent)] underline decoration-[var(--opencami-accent-light)] underline-offset-4 hover:opacity-90 cursor-pointer",children:n}):h.jsx("a",{href:r,onClick:s=>{r?.startsWith("openclaw-file://")&&s.preventDefault()},className:"text-[var(--opencami-accent)] underline decoration-[var(--opencami-accent-light)] underline-offset-4 transition-opacity hover:opacity-90",target:"_blank",rel:"noopener noreferrer",children:n})},code:function({children:n,className:r,node:i}){if(r?.includes("language-")){const o=qa(r),a=Wa(i?.data?.meta);return h.jsx(ei,{content:String(n??""),language:o,filename:a,className:"w-full"})}const s=typeof n=="string"?n:Array.isArray(n)?n.filter(o=>typeof o=="string").join(""):String(n??"");return s&&dy(s)?h.jsx("button",{type:"button",onClick:()=>e(s),className:"font-mono text-sm bg-primary-100 rounded px-1.5 py-0.5 text-primary-900 underline decoration-primary-300 underline-offset-4 hover:decoration-primary-600 cursor-pointer",children:n}):h.jsx("code",{className:"font-mono text-sm bg-primary-100 rounded px-1.5 py-0.5 text-primary-900",children:n})}}}const Ka=m.memo(function({content:t,components:n}){return h.jsx(Km,{remarkPlugins:[ay,rg,xy],components:n,children:t})},function(t,n){return t.content===n.content});Ka.displayName="MemoizedMarkdownBlock";function jy(e,t){return t==="NOT_FOUND"||e===404?"File not found":t==="UNSUPPORTED_TYPE"?"Binary file":t==="FILE_TOO_LARGE"||e===413?"File too large":"Failed to load file preview"}function Ay({children:e,id:t,className:n,components:r}){const i=m.useId(),s=t??i,o=m.useMemo(()=>Cy(e),[e]),[a,l]=m.useState({status:"idle"}),c=Yr(),u=m.useCallback(y=>{const k=jr(y);ir.getState().navigateTo(k),l({status:"idle"}),c({to:"/files"})},[c]),f=m.useCallback(y=>{const k=Ua(y);if(Sy(k)){u(k);return}l({status:"loading",path:k})},[u]),p=m.useMemo(()=>Ty(f),[f]),d=m.useMemo(()=>({...p,...r||{}}),[p,r]);m.useEffect(()=>{if(a.status!=="loading")return;const y=a.path,k=new AbortController;return fetch(`/api/files/read?path=${encodeURIComponent(y)}`,{signal:k.signal}).then(async w=>{const S=await w.json().catch(()=>({}));if(!w.ok){if(vy(S.code,S.message)){u(y);return}const M=jy(w.status,S.code);l({status:"error",path:y,message:M});return}if(Number(S.size??0)>wy){l({status:"error",path:y,message:"File too large"});return}const N=String(S.content??"");l({status:"success",path:y,content:N,language:by(y)})}).catch(()=>{k.signal.aborted||l({status:"error",path:y,message:"Failed to load file preview"})}),()=>k.abort()},[a,u]);const g=a.status!=="idle";return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:q("flex min-w-0 max-w-full flex-col gap-2 overflow-x-hidden",n),onClickCapture:y=>{const w=y.target?.closest?.('a[href^="openclaw-file://"]');if(!w)return;const S=Ha(w.getAttribute("href")??void 0);S&&(y.preventDefault(),y.stopPropagation(),f(S))},children:o.map((y,k)=>h.jsx(Ka,{content:y,components:d},`${s}-block-${k}`))}),h.jsx(ao,{open:g,onOpenChange:y=>{y||l({status:"idle"})},children:h.jsxs(lo,{className:"w-[min(1000px,95vw)] max-h-[88vh] overflow-hidden p-0",children:[h.jsxs("div",{className:"border-b border-primary-200 px-4 py-3 flex items-start justify-between gap-3",children:[h.jsxs("div",{className:"min-w-0",children:[h.jsx(co,{className:"text-base",children:"File Preview"}),a.status!=="idle"&&h.jsx("p",{className:"text-xs text-primary-600 font-mono truncate",children:a.path})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[a.status!=="idle"&&h.jsx(Ce,{variant:"ghost",size:"sm",asChild:!0,children:h.jsx(St,{to:"/files",onClick:()=>{const y=a.status!=="idle"?jr(a.path):"";if(y){const k=y.includes("/")&&y.slice(0,y.lastIndexOf("/"))||"/";ir.getState().navigateTo(k)}l({status:"idle"})},children:"Open in Explorer"})}),a.status!=="idle"&&h.jsx(Ce,{variant:"ghost",size:"sm",asChild:!0,children:h.jsx(St,{to:"/files",onClick:()=>{const y=a.status!=="idle"?jr(a.path):"";y&&ir.getState().openInEditor(y),l({status:"idle"})},children:"Open in Editor"})}),h.jsx(uo,{children:"Close"})]})]}),h.jsxs("div",{className:"p-4 overflow-auto max-h-[calc(88vh-72px)]",children:[a.status==="loading"&&h.jsx("p",{className:"text-sm text-primary-600",children:"Loading preview…"}),a.status==="error"&&h.jsx("p",{className:"text-sm text-red-600",children:a.message}),a.status==="success"&&h.jsx(ei,{content:a.content,language:a.language,className:"w-full"})]})]})})]})}const Va=m.memo(Ay);Va.displayName="Markdown";function Xa({children:e,className:t,...n}){return h.jsx("div",{className:q("flex gap-3 w-full",t),...n,children:e})}function Iy({children:e,markdown:t=!1,className:n,...r}){const i=q("rounded-[12px] break-words whitespace-normal min-w-0 max-w-full overflow-x-hidden",n);return t?h.jsx(Va,{className:i,...r,children:e}):h.jsx("div",{className:i,...r,children:e})}function Ry(){const[e,t]=m.useState(()=>typeof window<"u"?window.innerWidth<768:!1);return m.useEffect(()=>{if(typeof window>"u")return;const n=window.matchMedia("(max-width: 767px)"),r=i=>t(i.matches);return n.addEventListener("change",r),t(n.matches),()=>n.removeEventListener("change",r)},[]),e}function Ny({content:e}){const t=Ry();return h.jsx("div",{className:"inline-flex flex-col",children:h.jsxs(An,{defaultOpen:!t,children:[h.jsxs(In,{render:h.jsx(Ce,{variant:"ghost",className:"h-auto gap-1.5 px-1.5 py-0.5 -mx-2"}),children:[h.jsx("span",{className:"text-sm font-medium text-primary-900",children:"Thinking"}),h.jsx(ne,{icon:Zr,size:14,strokeWidth:1.5,className:"text-primary-900 transition-transform duration-150 group-data-panel-open:rotate-180"})]}),h.jsx(Rn,{children:h.jsx("div",{className:"pt-1 mb-3",children:h.jsx("p",{className:"text-sm text-primary-700 whitespace-pre-wrap",children:e})})})]})})}function Ly({toolPart:e,defaultOpen:t=!1}){const{state:n,input:r,output:i,toolCallId:s}=e,o=(c,u=3200)=>{const f=c===void 0?"undefined":c;let p;if(typeof f=="string")try{p=JSON.stringify(JSON.parse(f),null,2)}catch{p=f}else p=JSON.stringify(f,null,2);return p.length<=u?p:`${p.slice(0,u).trimEnd()}
95
+ …[truncated]`},a=n==="output-error"?Un:n==="output-available"?to:oo,l=n==="output-error"?"text-red-600/80":n==="output-available"?"text-green-600/80":"text-primary-500/80";return h.jsx("div",{className:"inline-flex flex-col w-full",children:h.jsxs(An,{defaultOpen:t,children:[h.jsxs(In,{render:h.jsx(Ce,{variant:"ghost",className:"h-auto w-full justify-start gap-1.5 rounded-md px-1.5 py-1"}),children:[h.jsx(ne,{icon:a,size:12,strokeWidth:1.7,className:l}),h.jsx("span",{className:"text-sm font-medium text-primary-900",children:e.type}),h.jsx(ne,{icon:Zr,size:14,strokeWidth:1.5,className:"ml-auto text-primary-700/80 transition-transform duration-150 group-data-panel-open:rotate-180"})]}),h.jsx(Rn,{className:"mt-1",children:h.jsxs("div",{className:"space-y-2 rounded-md border border-primary-200 bg-primary-100/70 p-2",children:[h.jsxs("div",{className:"rounded border border-primary-200 bg-primary-50 px-2 py-1.5",children:[h.jsx("div",{className:"text-[11px] font-medium text-primary-600",children:"Tool"}),h.jsx("div",{className:"font-mono text-xs text-primary-800 break-all",children:e.type})]}),r&&Object.keys(r).length>0&&h.jsxs("div",{className:"rounded border border-primary-200 bg-primary-50 px-2 py-1.5",children:[h.jsx("h4",{className:"mb-1 text-[11px] font-medium text-primary-600",children:"Input"}),h.jsx("pre",{className:"max-h-44 overflow-auto whitespace-pre-wrap break-all font-mono text-xs leading-relaxed text-primary-800",children:o(r)})]}),i!=null&&h.jsxs("div",{className:"rounded border border-primary-200 bg-primary-50 px-2 py-1.5",children:[h.jsx("h4",{className:"mb-1 text-[11px] font-medium text-primary-600",children:"Output"}),h.jsx("pre",{className:"max-h-44 overflow-auto whitespace-pre-wrap break-all font-mono text-xs leading-relaxed text-primary-800",children:o(i)})]}),n==="output-error"&&e.errorText&&h.jsxs("div",{className:"rounded border border-red-200 bg-red-50 px-2 py-1.5",children:[h.jsx("h4",{className:"mb-1 text-[11px] font-medium text-red-600",children:"Error"}),h.jsx("div",{className:"text-xs text-red-700",children:e.errorText})]}),s&&h.jsxs("div",{className:"text-[11px] text-primary-500/80 font-mono tabular-nums",children:["ID: ",s.slice(0,16),"..."]})]})})]})})}function $s(e){try{return new URL(e).hostname.replace("www.","")}catch{return e}}function Bs({domain:e}){return h.jsx("div",{className:"flex items-center justify-center w-5 h-5 rounded-full bg-white dark:bg-zinc-800 border border-cyan-500/20 overflow-hidden",title:e,children:h.jsx("img",{src:`https://www.google.com/s2/favicons?domain=${e}&sz=32`,alt:"",className:"w-4 h-4 object-contain",loading:"lazy",onError:t=>{const n=t.target;n.style.display="none";const r=n.parentElement;r&&(r.textContent=e.charAt(0).toUpperCase(),r.classList.add("text-[10px]","font-medium","text-cyan-400"))}})})}function My({sources:e}){const[t,n]=m.useState(!1);if(!e.length)return null;const r=[...new Set(e.map(i=>$s(i.url)))];return h.jsxs("div",{className:"mt-2 w-full",children:[h.jsxs("button",{onClick:()=>n(!t),className:q("inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs","bg-cyan-500/10 hover:bg-cyan-500/20 border border-cyan-500/30","text-cyan-300 transition-colors"),children:[h.jsx(ne,{icon:io,size:14}),h.jsx("span",{className:"font-medium",children:"Sources"}),h.jsx("span",{className:"px-1.5 py-0.5 rounded-full bg-cyan-500/20 text-cyan-400 font-semibold",children:e.length}),h.jsxs("div",{className:"flex items-center gap-0.5 ml-1",children:[r.slice(0,3).map(i=>h.jsx(Bs,{domain:i},i)),r.length>3&&h.jsxs("span",{className:"text-cyan-500/70 text-[10px] ml-0.5",children:["+",r.length-3]})]}),h.jsx(ne,{icon:Qr,size:12,className:q("transition-transform",t&&"rotate-90")})]}),t&&h.jsx("div",{className:"mt-2 rounded-lg border border-cyan-500/20 bg-cyan-500/5 max-h-80 overflow-y-auto",children:e.map((i,s)=>{const o=$s(i.url);return h.jsxs("a",{href:i.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-start gap-2 p-2.5 border-b border-cyan-500/10 last:border-b-0 hover:bg-cyan-500/5 transition-colors",children:[h.jsx(Bs,{domain:o}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"text-sm font-medium text-primary-900 hover:underline line-clamp-1",children:i.title||o}),h.jsx("div",{className:"text-xs text-muted-foreground",children:o}),i.snippet&&h.jsx("p",{className:"text-xs text-muted-foreground/80 line-clamp-2 mt-0.5",children:i.snippet})]})]},`${i.url}-${s}`)})})]})}function Dy(e,t){const n=t!==void 0,r=t?.isError??!1;let i;n?r?i="output-error":i="output-available":i="input-available";let s;r&&t?.content?.[0]?.type==="text"&&(s=t.content[0].text||"Unknown error");const o=t?.content?.map(l=>l.type==="text"?String(l.text??""):"").join("").trim(),a=t?.details??(o&&o.length>0?o:void 0);return{type:e.name||"unknown",state:i,input:e.arguments,output:a,toolCallId:e.id,errorText:s}}function Hs(e){return Rt(e).map(n=>{const r=n.id??"",i=n.name??"",s=n.partialJson??"",o=n.arguments?JSON.stringify(n.arguments):"";return`${r}|${i}|${s}|${o}`}).join("||")}function zy(e){if(!e)return"missing";const n=(Array.isArray(e.content)?e.content:[]).map(i=>i.type==="text"?String(i.text??""):"").join("").trim(),r=e.details?JSON.stringify(e.details):"";return`${e.toolCallId??""}|${e.toolName??""}|${e.isError?"1":"0"}|${n}|${r}`}function Us(e,t){if(!t)return"";const n=Rt(e);return n.length===0?"":n.map(r=>r.id?zy(t.get(r.id)):"missing").join("||")}function Py(e){if(typeof e=="number"&&Number.isFinite(e))return e<1e12?e*1e3:e;if(typeof e=="string"){const t=Date.parse(e);if(!Number.isNaN(t))return t}return null}function qs(e){const t=[e.createdAt,e.created_at,e.timestamp,e.time,e.ts];for(const n of t){const r=Py(n);if(r)return r}return null}function Kr(e){const n=(Array.isArray(e.content)?e.content:[]).find(r=>r.type==="thinking");return n&&"thinking"in n?String(n.thinking??""):null}function _y(e){const t=Array.isArray(e.content)?e.content:[],n=[];for(const r of t)r.type==="image"&&"source"in r&&typeof r.source?.data=="string"&&n.push(r);return n}function Oy({message:e,toolResultsByCallId:t,forceActionsVisible:n=!1,isStreaming:r=!1,isLastAssistant:i=!1,aggregatedSearchSources:s,wrapperRef:o,wrapperClassName:a,wrapperScrollMarginTop:l,messageDomId:c,highlighted:u=!1}){const{settings:f}=dc(),p=e.role||"assistant",d=tt(e),g=Kr(e),y=_y(e),k=p==="user",w=Lr(e),S=p==="assistant"?Rt(e):[],E=S.length>0,N=i&&!r&&f.showSearchSources&&s?s:[];return h.jsxs("div",{ref:o,id:c,"data-message-id":c,style:{contentVisibility:"auto",containIntrinsicSize:"auto 120px",...typeof l=="number"?{scrollMarginTop:`${l}px`}:void 0},className:q("opencami-message-item group mx-auto flex w-full max-w-[var(--opencami-chat-width)] flex-col gap-1 py-[var(--opencami-msg-padding-y)]",a,u&&"opencami-message-highlight",k?"items-end":"items-start"),children:[g&&f.showReasoningBlocks&&h.jsx("div",{className:"w-full max-w-[var(--opencami-chat-width)]",children:h.jsx(Ny,{content:g})}),y.length>0&&h.jsx("div",{className:q("flex flex-wrap gap-2 mb-2",k?"justify-end":"justify-start"),children:y.map((M,v)=>h.jsx("img",{src:`data:${M.source.media_type};base64,${M.source.data}`,alt:`Attachment ${v+1}`,loading:"lazy",decoding:"async",className:"max-w-[300px] max-h-[300px] rounded-lg object-cover"},v))}),h.jsx(Xa,{className:q("min-w-0 max-w-full",k?"flex-row-reverse":""),children:h.jsx(Iy,{markdown:!k,className:q("text-primary-900 opencami-text-size min-w-0 max-w-full",k?"opencami-message-user bg-primary-100 px-4 py-[var(--opencami-user-bubble-py)] max-w-[85%]":"opencami-message-assistant bg-transparent w-full",!k&&r&&"stream-fade-in"),children:d})}),E&&f.showToolMessages&&h.jsx("div",{className:"mt-2 flex w-full min-w-0 max-w-[var(--opencami-chat-width)] flex-col gap-3 overflow-x-hidden",children:S.map(M=>{const v=M.id?t?.get(M.id):void 0,F=Dy(M,v);return h.jsx(Ly,{toolPart:F,defaultOpen:!1},M.id||M.name)})}),N.length>0&&h.jsx("div",{className:"w-full max-w-[var(--opencami-chat-width)]",children:h.jsx(My,{sources:N})}),!E&&h.jsx(ff,{text:d,timestamp:w,align:k?"end":"start",forceVisible:n})]})}function Fy(e,t){return!(e.forceActionsVisible!==t.forceActionsVisible||e.isStreaming!==t.isStreaming||e.isLastAssistant!==t.isLastAssistant||e.aggregatedSearchSources!==t.aggregatedSearchSources||e.wrapperClassName!==t.wrapperClassName||e.wrapperRef!==t.wrapperRef||e.wrapperScrollMarginTop!==t.wrapperScrollMarginTop||e.messageDomId!==t.messageDomId||e.highlighted!==t.highlighted||(e.message.role||"assistant")!==(t.message.role||"assistant")||tt(e.message)!==tt(t.message)||Kr(e.message)!==Kr(t.message)||Hs(e.message)!==Hs(t.message)||Us(e.message,e.toolResultsByCallId)!==Us(t.message,t.toolResultsByCallId)||qs(e.message)!==qs(t.message))}const Ar=m.memo(Oy,Fy),$y=[/```[\s\S]*?```/g,/`[^`]+`/g,/\b(function|const|let|var|class|import|export|return|async|await)\b/g];function By(e){const t=[],n=e.match(/"([^"]+)"|'([^']+)'/g);n&&t.push(...n.map(s=>s.replace(/['"]/g,"")));const r=e.match(/\b[A-Z][a-z]+(?:\s+[A-Z][a-z]+)*\b/g);r&&t.push(...r.filter(s=>!["I","The","A","An","This"].includes(s)));const i=e.match(/`([^`]+)`/g);return i&&t.push(...i.map(s=>s.replace(/`/g,""))),[...new Set(t)].slice(0,5)}function Hy(e){return $y.some(t=>t.test(e))}function Uy(e){return/^[\s]*[-*•\d]+[.)\s]/m.test(e)||/\b(first|second|third|1\.|2\.|3\.)/i.test(e)}function qy(e){return/\b(alternatively|another|other option|could also|you might|consider)\b/i.test(e)}function Wy(e){return/\b(because|since|due to|reason|why|how|what|when|where)\b/i.test(e)}function Ky(e){return/\b(however|but|note|warning|caution|careful|important|keep in mind|be aware)\b/i.test(e)}function Vy(e){const t=[],n=By(e);if(Hy(e)&&(t.push({text:"Can you explain this code step by step?",type:"clarify"}),t.push({text:"How would I modify this for my use case?",type:"actionable"})),Uy(e)&&(t.push({text:"Can you elaborate on the first point?",type:"expand"}),t.push({text:"Which of these is most important to start with?",type:"actionable"})),qy(e)&&(t.push({text:"What are the pros and cons of each approach?",type:"alternative"}),t.push({text:"Which option would you recommend and why?",type:"clarify"})),Wy(e)&&t.length<3&&t.push({text:"Can you give me a practical example?",type:"example"}),Ky(e)&&t.length<3&&t.push({text:"What potential issues should I watch out for?",type:"clarify"}),n.length>0&&t.length<3){const s=n[0];t.push({text:`Tell me more about ${s}`,type:"expand"})}const r=[{text:"Can you give me a concrete example?",type:"example"},{text:"What would be the next steps?",type:"actionable"},{text:"How does this work in practice?",type:"expand"},{text:"Are there any common mistakes to avoid?",type:"clarify"},{text:"Can you simplify this explanation?",type:"clarify"}],i=new Set(t.map(s=>s.type));for(const s of r){if(t.length>=3)break;i.has(s.type)||(t.push(s),i.add(s.type))}for(const s of r){if(t.length>=3)break;t.some(o=>o.text===s.text)||t.push(s)}return t.slice(0,3)}function Ws(e){return Vy(e).map(t=>t.text)}const Xy={openai:{baseUrl:"https://api.openai.com/v1",model:"gpt-4.1-nano"},openrouter:{baseUrl:"https://openrouter.ai/api/v1",model:"openai/gpt-oss-120b"},ollama:{baseUrl:"http://localhost:11434/v1",model:"llama3.2"},custom:{baseUrl:"",model:""}},En={useLlmTitles:!0,useLlmFollowUps:!0,llmProvider:"openai",llmBaseUrl:"",llmModel:"",llmApiKey:""};function Ya(e){return Xy[e]}function Yy(e){return e.llmBaseUrl.trim()?e.llmBaseUrl.trim():Ya(e.llmProvider).baseUrl}function Gy(e){return e.llmModel.trim()?e.llmModel.trim():Ya(e.llmProvider).model}function Ks(e,t){return e.llmProvider==="ollama"?!0:e.llmProvider==="custom"?!!e.llmApiKey.trim()||e.llmBaseUrl.trim()&&e.llmModel.trim():t||!!e.llmApiKey.trim()}function Qy(e){if(!e||typeof e!="object")return{settings:En};const{settings:t}=e;if(!t)return{settings:En};const{openaiApiKey:n,...r}=t,i=r.llmApiKey??n??"";return{settings:{...En,...r,llmApiKey:i}}}const Nt=yo()(xo(e=>({settings:{...En},updateSettings:t=>e(n=>({settings:{...n.settings,...t}})),clearApiKey:()=>e(t=>({settings:{...t.settings,llmApiKey:""}}))}),{name:"llm-settings",version:2,migrate:e=>Qy(e)}));function E0(){const e=Nt(o=>o.settings),t=Nt(o=>o.updateSettings),n=Nt(o=>o.clearApiKey),[r,i]=m.useState({hasEnvKey:!1,hasOpenRouterKey:!1,hasUserKey:!!e.llmApiKey,isAvailable:Ks(e,!1),isLoading:!0,error:null});m.useEffect(()=>{let o=!1;async function a(){try{const l=await fetch("/api/llm-features");if(!l.ok)throw new Error("Failed to check LLM status");const c=await l.json();if(o)return;const u=!!e.llmApiKey,f=e.llmProvider==="openrouter"?!!c.hasOpenRouterKey:c.hasEnvKey;i({hasEnvKey:c.hasEnvKey,hasOpenRouterKey:!!c.hasOpenRouterKey,hasUserKey:u,isAvailable:Ks(e,f),isLoading:!1,error:null})}catch(l){if(o)return;i(c=>({...c,isLoading:!1,error:l instanceof Error?l.message:"Failed to check status"}))}}return a(),()=>{o=!0}},[e.llmApiKey,e.llmProvider,e.llmBaseUrl,e.llmModel]);const s=m.useCallback(async o=>{try{const a=Ga({...e,llmApiKey:o}),c=await(await fetch("/api/llm-features",{method:"POST",headers:{"Content-Type":"application/json",...a},body:JSON.stringify({action:"test"})})).json();return c.ok?{valid:c.valid??!1,error:c.error}:{valid:!1,error:c.error||"Test failed"}}catch(a){return{valid:!1,error:a instanceof Error?a.message:"Network error"}}},[e]);return{settings:e,updateSettings:t,clearApiKey:n,status:r,testApiKey:s}}function Ga(e){const t=e.llmApiKey,n=Yy(e),r=Gy(e);return t?{"X-OpenAI-API-Key":t,...n?{"X-LLM-Base-URL":n}:{},...r?{"X-LLM-Model":r}:{}}:{...n?{"X-LLM-Base-URL":n}:{},...r?{"X-LLM-Model":r}:{}}}function Qa(){const e=Nt.getState().settings;return Ga(e)}async function Jy(e,t){const n={"Content-Type":"application/json",...Qa()},r=await fetch("/api/llm-features",{method:"POST",headers:n,body:JSON.stringify({action:"followups",conversationContext:e}),signal:t});if(!r.ok)throw new Error(`API error: ${r.status}`);const i=await r.json();return i.ok&&Array.isArray(i.suggestions)&&i.suggestions.length>0?i.suggestions:[]}function Zy(e,t,n){const r=Nt(E=>E.settings),i=r.useLlmFollowUps,{minResponseLength:s=50,timeoutMs:o=8e3,heuristicsOnly:a}=n??{},l=a??!i,[c,u]=m.useState([]),[f,p]=m.useState(!1),[d,g]=m.useState(null),[y,k]=m.useState(null),w=m.useRef(""),S=m.useRef(null);return m.useEffect(()=>{if(!e||e.trim().length<s){u([]),k(null),p(!1),g(null);return}const E=e.slice(0,200)+e.length;if(E===w.current)return;if(w.current=E,S.current&&S.current.abort(),l){const F=Ws(e);u(F),k("heuristic"),p(!1),g(null);return}const N=new AbortController;S.current=N,p(!0),g(null);const M=Ws(e);u(M),k("heuristic");const v=t?`Context: ${t}
96
+
97
+ Assistant's response:
98
+ ${e.slice(0,2e3)}`:`Assistant's response:
99
+ ${e.slice(0,2e3)}`;return Jy(v,N.signal).then(F=>{N.signal.aborted||(F.length>0&&(u(F),k("llm")),p(!1))}).catch(F=>{N.signal.aborted||(g(F instanceof Error?F.message:String(F)),p(!1))}),()=>{}},[e,t,s,o,l,r.llmApiKey,r.llmBaseUrl,r.llmModel,r.llmProvider]),{suggestions:c,isLoading:f,error:d,source:y}}function eb({responseText:e,contextSummary:t,onSuggestionClick:n,disabled:r=!1,className:i}){const{suggestions:s,isLoading:o,source:a}=Zy(e,t,{minResponseLength:50,timeoutMs:8e3});return s.length===0&&!o?null:h.jsxs("div",{className:q("flex flex-col gap-2 mt-3",i),children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-primary-500",children:[h.jsx("span",{className:"text-primary-400",children:"✨"}),h.jsx("span",{children:o?h.jsxs("span",{className:"flex items-center gap-1",children:["Thinking of follow-ups",h.jsx(ne,{icon:oo,size:12,strokeWidth:2,className:"animate-spin text-primary-400"})]}):a==="llm"?"AI suggestions":"Follow-up suggestions"})]}),h.jsx("div",{className:"flex flex-wrap gap-2",children:s.map((l,c)=>h.jsxs("button",{type:"button",disabled:r,onClick:()=>n(l),className:q("group inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full","text-sm text-primary-700 bg-primary-50 border border-primary-200","hover:bg-primary-100 hover:border-primary-300 hover:text-primary-900","focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus:ring-offset-1","transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-primary-50 disabled:hover:border-primary-200",o&&"opacity-75"),children:[h.jsx("span",{children:l}),h.jsx(ne,{icon:Qr,size:14,strokeWidth:2,className:"text-primary-400 group-hover:text-primary-600 group-hover:translate-x-0.5 transition-all duration-150"})]},`${c}-${l.slice(0,20)}`))})]})}const Vs=m.memo(eb);function tb({className:e,variant:t="outline",scrollRef:n,...r}){const[i,s]=m.useState(!0),[o,a]=m.useState(!1),l=m.useRef(0),c=m.useCallback(()=>{const u=n.current;if(!u)return;const f=Math.abs(u.scrollHeight-u.scrollTop-u.clientHeight)<100;s(f)},[n]);return m.useLayoutEffect(()=>{const u=n.current;if(!u)return;const f=()=>{l.current=u.scrollTop,c()},p=new MutationObserver(()=>{u&&(u.scrollTop!==l.current&&(l.current=u.scrollTop),c())});return c(),u.addEventListener("scroll",f),p.observe(u,{childList:!0,subtree:!0}),()=>{u.removeEventListener("scroll",f),p.disconnect()}},[c,n]),m.useLayoutEffect(()=>{if(i){a(!1);return}const u=window.setTimeout(()=>{a(!0)},200);return()=>window.clearTimeout(u)},[i]),h.jsx(Ce,{variant:"secondary",size:"icon-sm",className:q("pointer-events-auto rounded-full shadow-md","transition-all duration-100 ease-in-out",!i&&o?"translate-y-0 scale-100 opacity-100":"pointer-events-none translate-y-4 scale-98 opacity-0",e),onClick:()=>{const u=n.current;u&&(u.scrollTop=u.scrollHeight,s(!0))},...r,children:h.jsx(ne,{icon:Zr,size:18,strokeWidth:1.8})})}function nb({className:e,viewportRef:t,scrollRef:n,viewportProps:r}){return h.jsxs(To,{className:q("relative flex flex-1 min-h-0 flex-col",e),children:[h.jsx(jo,{className:"relative will-change-transform overflow-x-hidden",ref:t,...r}),h.jsx("div",{className:"relative mx-auto w-full min-w-0 max-w-full px-5 sm:max-w-[768px]",children:h.jsx("div",{className:"pointer-events-none absolute bottom-10 right-10 z-50",children:h.jsx(tb,{scrollRef:n})})}),h.jsx(Ao,{orientation:"vertical",children:h.jsx(Io,{})}),h.jsx(ku,{})]})}function rb(e,t){if(e===t)return!0;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n)if(e[i]!==t[i])return!1;return!0}function ib(e,t){return!(e.className!==t.className||e.viewportRef!==t.viewportRef||e.scrollRef!==t.scrollRef||!rb(e.viewportProps,t.viewportProps))}const sb=m.memo(nb,ib);function ob({viewportNode:e,children:t}){return e?xl.createPortal(h.jsx("div",{className:"relative flex w-full min-w-0 max-w-full flex-col overflow-x-hidden",children:t}),e):null}function ab({children:e,className:t,onUserScroll:n,...r}){const i=m.useRef(null),[s,o]=m.useState(null),a=m.useCallback(function(c){i.current=c,o(c)},[]);return m.useLayoutEffect(()=>{const l=i.current;if(!l)return;const c=()=>{n?.(l.scrollTop)};return l.addEventListener("scroll",c),()=>l.removeEventListener("scroll",c)},[n]),h.jsxs(h.Fragment,{children:[h.jsx(sb,{className:t,viewportRef:a,scrollRef:i,viewportProps:r}),h.jsx(ob,{viewportNode:s,children:e})]})}const lb=m.memo(ab);function cb({children:e,className:t,...n}){return h.jsx("div",{className:q("flex w-full min-w-0 max-w-full flex-col min-h-full overflow-x-hidden",t),...n,children:h.jsx("div",{className:"mx-auto w-full min-w-0 max-w-full px-2 md:px-5 sm:max-w-[768px] flex flex-col flex-1 min-h-full overflow-x-hidden",children:h.jsx("div",{className:"flex min-w-0 max-w-full flex-col space-y-3 md:space-y-6",children:e})})})}function ub({...e}){return h.jsx("div",{className:"h-px w-full shrink-0 scroll-mt-4 pt-6","aria-hidden":"true",...e})}function fb({as:e="span",className:t,duration:n=4,spread:r=20,children:i,...s}){const o=Math.min(Math.max(r,5),45),a=e;return h.jsx(a,{className:q("bg-size-[200%_auto] bg-clip-text font-medium text-transparent","animate-[shimmer_4s_infinite_linear]",t),style:{backgroundImage:`linear-gradient(to right, var(--color-primary-600) ${50-o}%, var(--color-primary-950) 50%, var(--color-primary-600) ${50+o}%)`,animationDuration:`${n}s`},...s,children:i})}function hb({className:e}){return h.jsxs("div",{className:q("flex items-center gap-2",e),children:[h.jsxs("div",{className:"relative flex h-1.5 w-1.5",children:[h.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-primary-400 opacity-75"}),h.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-size-[200%_auto] animate-[shimmer_2s_infinite_linear]",style:{backgroundImage:"linear-gradient(to right, var(--color-primary-600) 0%, var(--color-primary-950) 50%, var(--color-primary-600) 100%)"}})]}),h.jsx(fb,{className:"text-sm",duration:2,children:"Generating..."})]})}function pb({messages:e,loading:t,empty:n,emptyState:r,notice:i,noticePosition:s="start",waitingForResponse:o,isStreaming:a=!1,sessionKey:l,pinToTop:c,pinGroupMinHeight:u,headerHeight:f,contentStyle:p,onFollowUpClick:d,jumpToMessageId:g}){const y=m.useRef(null),k=m.useRef(null),w=m.useRef(!1),S=m.useRef(c),E=m.useRef(void 0),[N,M]=m.useState(null),v=m.useMemo(()=>e.filter(I=>I.role!=="toolResult"),[e]),F=m.useMemo(()=>{const I=new Map;for(const H of e){if(H.role!=="toolResult")continue;const L=H.toolCallId;typeof L=="string"&&L.trim().length>0&&I.set(L,H)}return I},[e]),U=m.useMemo(()=>{const I=K=>K?K.replace(/SECURITY NOTICE:[\s\S]*?<<<EXTERNAL_UNTRUSTED_CONTENT>>>/g,"").replace(/<<<\/?EXTERNAL_UNTRUSTED_CONTENT>>>/g,"").replace(/<<<\/?END_EXTERNAL_UNTRUSTED_CONTENT>>>/g,"").replace(/Source: Web (?:Search|Fetch)\n---/g,"").replace(/\n{2,}/g,`
100
+ `).trim():"",H=(K,V,b)=>{try{const J=JSON.parse(K),Z=Array.isArray(J)?J:J?.results??J?.web?.results??[];if(!Array.isArray(Z))return!1;let Y=!1;for(const ae of Z)ae?.url&&ae?.title&&!b.has(ae.url)&&(b.add(ae.url),V.push({title:I(ae.title),url:ae.url,snippet:I(ae.description||ae.snippet||ae.content||"")}),Y=!0);return Y}catch{return!1}},L=[],x=new Set;for(const K of v){if(K.role!=="assistant")continue;const V=Rt(K);for(const b of V){if(!b.id)continue;const J=b.name==="web_search",Z=b.name==="web_fetch",Y=b.name==="exec";if(!J&&!Z&&!Y)continue;const ae=F.get(b.id);if(!ae)continue;const se=ae.content?.map(ee=>ee.type==="text"?String(ee.text??""):"").join("").trim();if(se){if(J||Y){if(Y&&(!se.includes('"results"')||!se.includes('"url"')))continue;let ee=se;const le=se.indexOf("{");le>0&&(ee=se.slice(le));const me=ee.lastIndexOf("}");me>0&&(ee=ee.slice(0,me+1)),H(ee,L,x)}else if(Z){const ee=b.arguments?.url;if(ee&&!x.has(ee)){x.add(ee);let le;try{le=new URL(ee).hostname}catch{le=ee}L.push({title:le,url:ee})}}}}}return L},[v,F]),D=v.map((I,H)=>({message:I,index:H})).filter(({message:I})=>I.role!=="user").map(({index:I})=>I).pop(),C=v.map((I,H)=>({message:I,index:H})).filter(({message:I})=>I.role==="user").map(({index:I})=>I).pop(),z=o&&(typeof C!="number"||typeof D!="number"||D<C),j=typeof C=="number"?C:-1,_=c&&j>=0,R=typeof D=="number"?v[D]:void 0,T=R?tt(R):"",B=!o&&!a&&T.length>0&&d!==void 0&&(typeof C!="number"||typeof D!="number"||D>C);return m.useLayoutEffect(()=>{if(!t){if(c){const I=!S.current||E.current!==C;S.current=!0,E.current=C,I&&k.current&&(w.current=!0,k.current.scrollIntoView({behavior:"auto",block:"start"}),window.setTimeout(()=>{w.current=!1},0));return}S.current=!1,E.current=C,y.current&&(w.current=!0,y.current.scrollIntoView({behavior:"auto",block:"end"}),window.setTimeout(()=>{w.current=!1},0))}},[t,v.length,l,c,C]),m.useEffect(()=>{if(!g||t)return;const I=document.getElementById(`message-${g}`);if(!I)return;I.scrollIntoView({behavior:"smooth",block:"center"}),M(g);const H=window.setTimeout(()=>{M(L=>L===g?null:L)},1800);return()=>window.clearTimeout(H)},[g,t,v]),h.jsx(lb,{className:"flex-1 min-h-0 -mb-4",children:h.jsxs(cb,{className:"pt-6",style:p,children:[i&&s==="start"?i:null,n&&!i?r??h.jsx("div",{"aria-hidden":!0}):_?h.jsxs(h.Fragment,{children:[v.slice(0,j).map((I,H)=>{const L=typeof I.id=="string"?I.id:void 0,x=L||H,K=typeof D=="number"&&H===D,V=typeof D=="number"&&H===D,b=I.role==="assistant"&&Rt(I).length>0;return h.jsx(Ar,{message:I,toolResultsByCallId:b?F:void 0,forceActionsVisible:K,isStreaming:V&&a,isLastAssistant:V,aggregatedSearchSources:V?U:void 0,messageDomId:L?`message-${L}`:void 0,highlighted:N===L},x)}),h.jsxs("div",{className:"flex flex-col gap-[var(--opencami-msg-gap)]",style:{minHeight:`${Math.max(0,u)}px`},children:[v.slice(j).map((I,H)=>{const L=j+H,x=typeof I.id=="string"?I.id:void 0,K=x||L,V=typeof D=="number"&&L===D,b=typeof D=="number"&&L===D,J=L===C?k:void 0,Z=L===C?"scroll-mt-0":void 0,Y=L===C?f:void 0,ae=I.role==="assistant"&&Rt(I).length>0;return h.jsx(Ar,{message:I,toolResultsByCallId:ae?F:void 0,forceActionsVisible:V,isStreaming:b&&a,isLastAssistant:b,aggregatedSearchSources:b?U:void 0,wrapperRef:J,wrapperClassName:Z,wrapperScrollMarginTop:Y,messageDomId:x?`message-${x}`:void 0,highlighted:N===x},K)}),z?h.jsx("div",{className:"py-2",children:h.jsx(hb,{})}):null,B&&d?h.jsx(Vs,{responseText:T,onSuggestionClick:d,disabled:o}):null]})]}):h.jsxs(h.Fragment,{children:[v.map((I,H)=>{const L=typeof I.id=="string"?I.id:void 0,x=L||H,K=typeof D=="number"&&H===D,V=typeof D=="number"&&H===D,b=I.role==="assistant"&&Rt(I).length>0;return h.jsx(Ar,{message:I,toolResultsByCallId:b?F:void 0,forceActionsVisible:K,isStreaming:V&&a,isLastAssistant:V,aggregatedSearchSources:V?U:void 0,messageDomId:L?`message-${L}`:void 0,highlighted:N===L},x)}),B&&d?h.jsx(Vs,{responseText:T,onSuggestionClick:d,disabled:o}):null]}),i&&s==="end"?i:null,h.jsx(ub,{ref:y})]})})}function db(e,t){return e.messages===t.messages&&e.loading===t.loading&&e.empty===t.empty&&e.emptyState===t.emptyState&&e.notice===t.notice&&e.noticePosition===t.noticePosition&&e.waitingForResponse===t.waitingForResponse&&e.isStreaming===t.isStreaming&&e.sessionKey===t.sessionKey&&e.pinToTop===t.pinToTop&&e.pinGroupMinHeight===t.pinGroupMinHeight&&e.headerHeight===t.headerHeight&&e.contentStyle===t.contentStyle&&e.onFollowUpClick===t.onFollowUpClick&&e.jumpToMessageId===t.jumpToMessageId}const mb=m.memo(pb,db),Ja=m.createContext({isLoading:!1,value:"",setValue:()=>{},maxHeight:240,onSubmit:void 0,disabled:!1,textareaRef:yl.createRef()});let Ht=null,Xs=!1;function gb(){Xs||typeof window>"u"||(Xs=!0,window.addEventListener("keydown",e=>{if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.altKey)return;const t=e.target;if(!t)return;const n=t.tagName.toLowerCase();if(n==="input"||n==="textarea"||n==="select"||t.isContentEditable)return;const r=e.key.length===1,i=e.key==="Backspace";!r&&!i||!Ht||Ht.disabled||Ht.focus()}))}function Za(){return m.useContext(Ja)}function xb({className:e,isLoading:t=!1,maxHeight:n=240,value:r,onValueChange:i,onSubmit:s,children:o,disabled:a=!1,onClick:l,...c}){const[u,f]=m.useState(r||""),p=m.useRef(null);gb();function d(y){f(y),i?.(y)}function g(y){a||p.current?.focus(),l?.(y)}return h.jsx(pt,{children:h.jsx(Ja.Provider,{value:{isLoading:t,value:r??u,setValue:i??d,maxHeight:n,onSubmit:s,disabled:a,textareaRef:p},children:h.jsx("div",{onClick:g,className:q("bg-surface cursor-text rounded-[22px] outline outline-ink/10 shadow-[0px_12px_32px_0px_rgba(0,0,0,0.05)] py-3 gap-3 flex flex-col",a&&"cursor-not-allowed opacity-60",e),...c,children:o})})})}function yb({className:e,onKeyDown:t,disableAutosize:n=!1,inputRef:r,...i}){const{value:s,setValue:o,maxHeight:a,onSubmit:l,disabled:c,textareaRef:u}=Za();function f(y){!y||n||(y.style.height="auto",typeof a=="number"?y.style.height=`${Math.min(y.scrollHeight,a)}px`:y.style.height=`min(${y.scrollHeight}px, ${a})`)}function p(y){u.current=y,typeof r=="function"?r(y):r&&"current"in r&&(r.current=y),y?Ht=y:Ht===y&&(Ht=null),f(y)}m.useLayoutEffect(()=>{if(!u.current||n)return;const y=u.current;y.style.height="auto",typeof a=="number"?y.style.height=`${Math.min(y.scrollHeight,a)}px`:y.style.height=`min(${y.scrollHeight}px, ${a})`},[s,a,n]);function d(y){f(y.target),o(y.target.value)}function g(y){y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),l?.()),t?.(y)}return h.jsx("textarea",{ref:p,value:s,onChange:d,onKeyDown:g,className:q("text-primary-950 opencami-text-size min-h-[28px] w-full resize-none border-none bg-transparent shadow-none outline-none focus-visible:ring-0 pl-4 pr-1 placeholder:text-primary-500",e),rows:1,readOnly:c,"aria-disabled":c,...i})}function bb({children:e,className:t,...n}){return h.jsx("div",{className:q("flex items-center gap-2",t),...n,children:e})}function Ys({tooltip:e,children:t,className:n,side:r="top",...i}){const{disabled:s}=Za();return h.jsxs(dt,{...i,children:[h.jsx(mt,{disabled:s,onClick:o=>o.stopPropagation(),children:t}),h.jsx(gt,{side:r,className:n,children:e})]})}const el="opencami-selected-model";function wb(){if(typeof window>"u")return null;try{return localStorage.getItem(el)}catch{return null}}function kb(e){if(!(typeof window>"u"))try{localStorage.setItem(el,e)}catch{}}function Sb({className:e,onModelChange:t}){const[n,r]=m.useState([]),[i,s]=m.useState(""),[o,a]=m.useState(!0),[l,c]=m.useState(null),u=m.useRef(null);m.useEffect(()=>{let y=!0;async function k(){u.current?.abort();const w=new AbortController;u.current=w;try{a(!0),c(null);const S=await fetch("/api/models",{signal:w.signal});if(!S.ok)throw new Error("Failed to fetch models");const E=await S.json();if(!y)return;if(E.ok&&E.models.length>0){r(E.models);const N=wb(),M=N&&E.models.some(v=>v.id===N)?N:E.defaultModel;s(M),t?.(M)}else throw new Error("No models available")}catch(S){if(S instanceof Error&&S.name==="AbortError"||!y)return;console.error("[model-selector] Error fetching models:",S),c(S instanceof Error?S.message:"Failed to load models"),r([{id:"default",name:"Default Model"}]),s("default")}finally{y&&a(!1)}}return k(),()=>{y=!1,u.current?.abort()}},[t]);function f(y){s(y),kb(y),t?.(y)}if(o)return h.jsxs("div",{className:q("flex items-center gap-2 text-xs text-primary-500",e),children:[h.jsx(ne,{icon:rr,size:14}),h.jsx("span",{children:"Loading..."})]});if(l||n.length===0)return null;const p=n.find(y=>y.id===i),d=p?.name||"Select Model",g=(()=>{if(!p?.name)return d;const k=p.name.replace(/\s*\([^)]*\)\s*$/,"").trim(),w=k.split(/\s+/);return w.length>3?w.slice(0,3).join(" "):k})();return n.length===1?h.jsxs("div",{className:q("flex items-center gap-2 text-xs text-primary-500",e),children:[h.jsx(ne,{icon:rr,size:14}),h.jsx("span",{className:"font-[450] md:hidden",children:g}),h.jsx("span",{className:"font-[450] hidden md:inline",children:d})]}):h.jsxs(qn,{children:[h.jsxs(Wn,{className:q("inline-flex h-7 items-center gap-2 rounded-md px-2 text-xs font-[450] text-primary-600 hover:text-primary-900 hover:bg-primary-100",e),children:[h.jsx(ne,{icon:rr,size:14}),h.jsx("span",{className:"md:hidden",children:g}),h.jsx("span",{className:"hidden md:inline",children:d})]}),h.jsx(Kn,{side:"top",align:"start",children:n.map(y=>h.jsxs(vt,{onClick:()=>f(y.id),className:"justify-between min-w-[180px]",children:[h.jsx("span",{children:y.name}),i===y.id&&h.jsx(ne,{icon:Jr,size:14,className:"text-primary-600"})]},y.id))})]})}const tl="opencami-personas-enabled",Vr="opencami-active-persona";function vb(){if(typeof window>"u")return!0;try{const e=localStorage.getItem(tl);return e===null?!0:e==="true"}catch{return!0}}function Cb(){if(typeof window>"u")return null;try{const e=localStorage.getItem(Vr);return e?JSON.parse(e):null}catch{return null}}function Gs(e){if(!(typeof window>"u"))try{e?localStorage.setItem(Vr,JSON.stringify(e)):localStorage.removeItem(Vr)}catch{}}const Eb={core:"Core",creative:"Creative",curator:"Curator",learning:"Learning",lifestyle:"Lifestyle",professional:"Professional"};function Tb({className:e,onSelect:t}){const[n,r]=m.useState({}),[i,s]=m.useState(null),[o,a]=m.useState(!0),[l,c]=m.useState(!1),[u,f]=m.useState(vb),p=m.useRef(null);m.useEffect(()=>{const k=w=>{w.key===tl&&f(w.newValue===null?!0:w.newValue==="true")};return window.addEventListener("storage",k),()=>window.removeEventListener("storage",k)},[]),m.useEffect(()=>{let k=!0;async function w(){p.current?.abort();const S=new AbortController;p.current=S;try{a(!0);const E=await fetch("/api/personas",{signal:S.signal});if(!E.ok){c(!1);return}const N=await E.json();if(!k)return;N.ok&&N.available?(r(N.personas),c(!0),s(Cb())):c(!1)}catch(E){if(E instanceof Error&&E.name==="AbortError"||!k)return;c(!1)}finally{k&&a(!1)}}return w(),()=>{k=!1,p.current?.abort()}},[]);const d=m.useCallback(k=>{s(k),Gs(k),t(`/persona ${k.id}`)},[t]),g=m.useCallback(()=>{s(null),Gs(null),t("/persona exit")},[t]);if(o||!l||!u)return null;const y=Object.entries(n);return y.length===0?null:h.jsxs(qn,{children:[h.jsxs(Wn,{className:q("inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-[450] text-primary-600 hover:text-primary-900 hover:bg-primary-100",e),children:[h.jsx("span",{className:"text-sm","aria-hidden":"true",children:"🎭"}),i?h.jsxs("span",{className:"flex items-center gap-1",children:[h.jsx("span",{children:i.emoji}),h.jsx("span",{children:i.name})]}):h.jsx("span",{children:"Persona"})]}),h.jsxs(Kn,{side:"top",align:"start",className:"w-[300px] max-h-[360px] overflow-y-auto",children:[i&&h.jsxs(h.Fragment,{children:[h.jsxs(vt,{onClick:g,className:"text-red-600 hover:bg-red-50",children:[h.jsx("span",{className:"text-sm",children:"✕"}),h.jsx("span",{children:"Exit Persona"}),h.jsxs("span",{className:"ml-auto text-[10px] text-primary-400",children:[i.emoji," ",i.name]})]}),h.jsx("div",{className:"my-1 h-px bg-primary-200"})]}),y.map(([k,w])=>h.jsxs("div",{children:[h.jsx("div",{className:"px-2 pb-0.5 pt-2 text-[10px] font-semibold uppercase tracking-wider text-primary-400",children:Eb[k]??k}),w.map(S=>h.jsxs(vt,{onClick:()=>d(S),className:"justify-between",children:[h.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[h.jsx("span",{className:"text-sm flex-shrink-0",children:S.emoji}),h.jsx("span",{className:"truncate",children:S.name})]}),h.jsx("span",{className:"text-[11px] text-primary-400 truncate ml-2 max-w-[140px]",children:S.description})]},S.id))]},k))]})]})}const jb=[{command:"/new",description:"Start a new conversation",usage:"/new"},{command:"/reset",description:"Reset conversation context",usage:"/reset"},{command:"/abort",description:"Abort current generation",usage:"/abort"},{command:"/status",description:"Show session status card",usage:"/status"},{command:"/usage",description:"Show token usage",usage:"/usage [off|tokens|full]"},{command:"/models",description:"List available models",usage:"/models"},{command:"/agents",description:"List available agents",usage:"/agents"},{command:"/sessions",description:"List active sessions",usage:"/sessions"},{command:"/model",description:"Switch model for this session",usage:"/model <alias>"},{command:"/reasoning",description:"Toggle reasoning mode",usage:"/reasoning [on|off|stream]"},{command:"/think",description:"Set thinking budget",usage:"/think [off|minimal|low|medium|high]"},{command:"/verbose",description:"Toggle verbose output",usage:"/verbose [on|full|off]"},{command:"/tts",description:"Text-to-speech controls",usage:"/tts [status|off|always]"},{command:"/settings",description:"Show current settings",usage:"/settings"},{command:"/help",description:"Show help",usage:"/help"}];function Ab({className:e,onCommandSelect:t}){const[n,r]=m.useState(!1);function i(s){t?.(s),r(!1)}return h.jsxs(h.Fragment,{children:[h.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>r(!0),className:q("h-7 w-7 p-0",e),title:"Show commands (Ctrl+/)",children:h.jsx(ne,{icon:Fi,size:16,className:"text-primary-500"})}),n&&h.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:h.jsxs("div",{className:"bg-white dark:bg-neutral-900 border border-primary-200 dark:border-neutral-700 rounded-xl shadow-2xl w-full max-w-lg max-h-[80vh] overflow-hidden",children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-primary-200 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-800",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(ne,{icon:Fi,size:18,className:"text-primary-600 dark:text-primary-400"}),h.jsx("h2",{className:"font-semibold text-primary-900 dark:text-white",children:"Slash Commands"})]}),h.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>r(!1),className:"h-7 w-7 p-0",children:h.jsx(ne,{icon:Un,size:16})})]}),h.jsxs("div",{className:"overflow-y-auto max-h-[60vh] p-2 bg-white dark:bg-neutral-900",children:[h.jsx("div",{className:"text-xs text-primary-500 dark:text-neutral-400 px-2 py-1 mb-2",children:"Type these commands in the chat input"}),jb.map(s=>h.jsxs("button",{onClick:()=>i(s.command),className:"w-full flex items-start gap-3 px-3 py-2 rounded-lg hover:bg-primary-100 dark:hover:bg-neutral-800 transition-colors text-left",children:[h.jsx("code",{className:"text-sm font-mono font-medium text-primary-700 dark:text-primary-300 bg-primary-100 dark:bg-neutral-800 px-1.5 py-0.5 rounded min-w-[80px]",children:s.command}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"text-sm text-primary-900 dark:text-neutral-100",children:s.description}),s.usage&&s.usage!==s.command&&h.jsx("div",{className:"text-xs text-primary-500 dark:text-neutral-500 font-mono mt-0.5",children:s.usage})]})]},s.command))]}),h.jsx("div",{className:"px-4 py-2 border-t border-primary-200 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-800",children:h.jsxs("div",{className:"text-xs text-primary-500 dark:text-neutral-400",children:["Press ",h.jsx("kbd",{className:"px-1 py-0.5 bg-primary-200 dark:bg-neutral-700 rounded text-primary-700 dark:text-neutral-300",children:"Esc"})," to close"]})})]})})]})}const Ib=10*1024*1024,$t=1280,Rb=.75,Nb=300*1024,Lb=["image/png","image/jpeg","image/gif","image/webp"],Mb=".png,.jpg,.jpeg,.gif,.webp";function Db(){if(typeof document>"u")return!1;try{const e=document.createElement("canvas");return!!(e.getContext&&e.getContext("2d"))}catch{return!1}}async function zb(e){if(!Db())throw new Error("Image compression not available in this browser");return new Promise((t,n)=>{const r=new Image,i=URL.createObjectURL(e),s=()=>{URL.revokeObjectURL(i)};r.onload=()=>{try{let o=r.width,a=r.height;(o>$t||a>$t)&&(o>a?(a=Math.round(a*$t/o),o=$t):(o=Math.round(o*$t/a),a=$t));const l=document.createElement("canvas");l.width=o,l.height=a;const c=l.getContext("2d");if(!c){s(),n(new Error("Failed to get canvas context"));return}c.drawImage(r,0,0,o,a);const u=e.type==="image/png"?"image/png":"image/jpeg";let f=Rb,p=l.toDataURL(u,f);if(u==="image/jpeg"){const g=Nb*1.37;for(;p.length>g&&f>.3;)f-=.1,p=l.toDataURL(u,f)}const d=p.split(",")[1];if(!d){s(),n(new Error("Failed to encode image"));return}s(),t(d)}catch(o){s(),n(o instanceof Error?o:new Error("Image compression failed"))}},r.onerror=()=>{s(),n(new Error("Failed to load image"))},r.src=i})}function nl(e){return Lb.includes(e.type)}async function rl(e){const t=crypto.randomUUID();if(!nl(e))return{id:t,file:e,preview:null,type:"image",base64:null,error:"Unsupported file type. Please use PNG, JPG, GIF, or WebP images."};if(e.size>Ib)return{id:t,file:e,preview:null,type:"image",base64:null,error:"Image is too large. Maximum size is 10MB."};try{const n=await zb(e),r=URL.createObjectURL(e);return{id:t,file:e,preview:r,type:"image",base64:n}}catch(n){return{id:t,file:e,preview:null,type:"image",base64:null,error:n instanceof Error?n.message:"Failed to process image"}}}function Pb({onFileSelect:e,disabled:t=!1,className:n}){const r=m.useRef(null),i=m.useCallback(()=>{r.current?.click()},[]),s=m.useCallback(async o=>{const a=o.target.files?.[0];if(!a)return;o.target.value="";const l=await rl(a);e(l)},[e]);return h.jsxs(h.Fragment,{children:[h.jsx("input",{ref:r,type:"file",accept:Mb,onChange:s,className:"hidden","aria-hidden":"true"}),h.jsx(Ce,{variant:"ghost",size:"icon-sm",onClick:i,disabled:t,className:n,"aria-label":"Attach image",type:"button",children:h.jsx(ne,{icon:Ul,size:18,strokeWidth:1.8})})]})}function _b(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ob(e){const t=e.split(".");return t.length>1&&t.pop()?.toUpperCase()||""}function Fb({attachment:e,onRemove:t,className:n}){m.useEffect(()=>()=>{e.preview&&URL.revokeObjectURL(e.preview)},[e.preview]);const r=!!e.error;return h.jsxs("div",{className:q("relative flex items-center gap-3 rounded-xl border p-2 pr-3",r?"border-red-300 bg-red-50":"border-primary-200 bg-primary-50",n),children:[h.jsx("div",{className:"relative shrink-0",children:e.type==="image"&&e.preview?h.jsx("img",{src:e.preview,alt:e.file.name,className:"h-12 w-12 rounded-lg object-cover"}):h.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-lg bg-primary-100",children:h.jsx(ne,{icon:ql,size:24,className:"text-primary-500"})})}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("p",{className:"truncate text-sm font-medium text-primary-900",children:e.file.name}),r?h.jsx("p",{className:"text-xs text-red-600",children:e.error}):h.jsxs("p",{className:"text-xs text-primary-500",children:[Ob(e.file.name)," •"," ",_b(e.file.size)]})]}),h.jsx(Ce,{variant:"ghost",size:"icon-sm",onClick:()=>t(e.id),className:"h-6 w-6 shrink-0 rounded-full hover:bg-primary-200","aria-label":"Remove attachment",type:"button",children:h.jsx(ne,{icon:Un,size:14})})]})}function $b({attachments:e,onRemove:t,className:n}){return e.length===0?null:h.jsx("div",{className:q("flex flex-col gap-2 px-4",n),children:e.map(r=>h.jsx(Fb,{attachment:r,onRemove:t},r.id))})}function Bb({commands:e,selectedIndex:t,onSelect:n,className:r}){return e.length===0?null:h.jsx("div",{className:q("absolute left-2 right-2 md:left-5 md:right-5 bottom-full mb-2 z-20 rounded-xl border border-white/10 bg-neutral-900/95 shadow-2xl backdrop-blur-sm overflow-hidden",r),role:"listbox","aria-label":"Slash commands",children:h.jsx("div",{className:"max-h-56 overflow-y-auto p-1",children:e.map((i,s)=>{const o=s===t;return h.jsx("button",{type:"button",role:"option","aria-selected":o,onMouseDown:a=>{a.preventDefault(),n(i)},className:q("w-full rounded-md px-3 py-2 text-left transition-colors",o?"bg-neutral-800":"hover:bg-neutral-800/80"),children:h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("code",{className:"min-w-[90px] font-mono text-xs text-primary-300",children:i.command}),h.jsx("span",{className:"text-xs text-neutral-300",children:i.description})]})},i.command)})})})}const Hb=m.memo(Bb),Xr=yo()(xo(e=>({level:"low",setLevel:t=>e({level:t})}),{name:"thinking-level"}));function Ub(){const e=Xr(n=>n.level),t=Xr(n=>n.setLevel);return{level:e,setLevel:t}}const Ir=[{value:"off",label:"Off",description:"No reasoning",shortLabel:"Off"},{value:"low",label:"Low",description:"Think",shortLabel:"Low"},{value:"medium",label:"Medium",description:"Think harder",shortLabel:"Medium"},{value:"high",label:"High",description:"Ultrathink",shortLabel:"High"}];function qb({className:e}){const{level:t,setLevel:n}=Ub(),r=Ir.find(i=>i.value===t)??Ir[1];return h.jsxs(qn,{children:[h.jsxs(Wn,{className:q("inline-flex h-7 items-center gap-2 rounded-md px-2 text-xs font-[450] text-primary-600 hover:text-primary-900 hover:bg-primary-100",e),children:[h.jsx(ne,{icon:ro,size:20,strokeWidth:1.5,className:q(t==="off"?"text-primary-400":"text-primary-700")}),h.jsx("span",{className:"text-pretty",children:r.shortLabel})]}),h.jsx(Kn,{side:"top",align:"start",className:"min-w-[190px]",children:Ir.map(i=>h.jsxs(vt,{onClick:()=>n(i.value),className:"justify-between",children:[h.jsxs("span",{className:"flex flex-col text-pretty",children:[h.jsx("span",{className:"text-sm text-primary-900",children:i.label}),h.jsx("span",{className:"text-xs text-primary-500",children:i.description})]}),t===i.value&&h.jsx(ne,{icon:Jr,size:20,strokeWidth:1.5,className:"text-primary-600"})]},i.value))})]})}const Qs=[{command:"/haiku",description:"Switch to Claude Haiku 4.5"},{command:"/sonnet",description:"Switch to Claude Sonnet 4.5"},{command:"/opus",description:"Switch to Claude Opus 4.5"},{command:"/opus46",description:"Switch to Claude Opus 4.6"},{command:"/codex",description:"Switch to GPT 5.3 Codex"},{command:"/glm",description:"Switch to GLM 4.7"},{command:"/kimi",description:"Switch to Kimi K2.5"},{command:"/minimax",description:"Switch to MiniMax M2.1"},{command:"/grok",description:"Switch to Grok 4.1 Fast"},{command:"/model",description:"Show model picker or switch model"},{command:"/new",description:"New chat (optional: /new model)"},{command:"/reset",description:"Reset session"},{command:"/stop",description:"Stop current generation"},{command:"/compact",description:"Compact conversation context"},{command:"/help",description:"Show available commands"},{command:"/commands",description:"List all commands"},{command:"/status",description:"Show session status & usage"},{command:"/whoami",description:"Show your sender ID"},{command:"/context",description:"Show context window details"},{command:"/usage",description:"Toggle usage footer (off/tokens/full/cost)"},{command:"/think",description:"Set thinking level (off/low/medium/high)"},{command:"/reasoning",description:"Toggle reasoning (on/off/stream)"},{command:"/verbose",description:"Toggle verbose mode (on/full/off)"},{command:"/elevated",description:"Toggle elevated permissions (on/off/ask)"},{command:"/exec",description:"Configure exec settings"},{command:"/queue",description:"Show/configure message queue"},{command:"/tts",description:"Text-to-speech (off/always/tagged/status)"},{command:"/subagents",description:"List/stop/log sub-agent runs"},{command:"/followups",description:"Show follow-up suggestions"},{command:"/skill",description:"Run a skill by name"},{command:"/allowlist",description:"List/add/remove allowlist entries"},{command:"/approve",description:"Resolve exec approval (allow/deny)"},{command:"/config",description:"Show/get/set config (owner-only)"},{command:"/debug",description:"Runtime overrides (owner-only)"},{command:"/send",description:"Toggle message sending (on/off)"},{command:"/restart",description:"Restart gateway"},{command:"/activation",description:"Set activation mode (mention/always)"},{command:"/dock-telegram",description:"Switch replies to Telegram"},{command:"/dock-discord",description:"Switch replies to Discord"},{command:"/bash",description:"Run host shell command"}];function Wb({onSubmit:e,isLoading:t,disabled:n,wrapperRef:r,inputRef:i}){const[s,o]=m.useState(""),[a,l]=m.useState(""),[c,u]=m.useState([]),[f,p]=m.useState(0),[d,g]=m.useState(!1),[y,k]=m.useState(!1),[w,S]=m.useState(!1),[E,N]=m.useState(0),[M,v]=m.useState(!1),F=m.useRef(null),U=m.useRef([]),D=m.useRef(null),C=m.useRef(null),z=m.useRef(null),j=m.useRef(null),_=m.useMemo(()=>/^\/\S*$/.test(s)&&!d,[s,d]),R=m.useMemo(()=>_?s.slice(1).toLowerCase():"",[_,s]),T=m.useMemo(()=>_?R?Qs.filter(W=>W.command.slice(1).toLowerCase().startsWith(R)):Qs:[],[_,R]),B=m.useCallback(W=>{j.current=W,i&&(typeof i=="function"?i(W):i.current=W)},[i]),I=m.useCallback(()=>{typeof window>"u"||window.requestAnimationFrame(()=>{j.current?.focus()})},[]),H=m.useCallback(()=>{o(""),u([]),p(0),g(!1),I()},[I]),L=m.useCallback(W=>{u($=>[...$,W])},[]),x=m.useCallback(W=>{u($=>$.filter(re=>re.id!==W))},[]),K=m.useCallback(W=>{Array.from(W.dataTransfer.types).includes("Files")&&(W.preventDefault(),W.dataTransfer.dropEffect="copy",k(!0))},[]),V=m.useCallback(W=>{W.preventDefault();const $=W.relatedTarget;$&&W.currentTarget.contains($)||k(!1)},[]),b=m.useCallback(async W=>{W.preventDefault(),k(!1);const $=Array.from(W.dataTransfer.files??[]);if($.length===0)return;const re=$.filter(ie=>nl(ie));if(re.length===0)return;const ge=await Promise.all(re.map(ie=>rl(ie)));u(ie=>[...ie,...ge]),I()},[I]),J=m.useCallback(W=>{o(W),p(0),g(!1),I()},[I]),Z=m.useCallback(W=>{o(W),p(0),g(!1)},[]),Y=m.useCallback(W=>{o(`${W.command} `),p(0),g(!1),I()},[I]),ae=m.useCallback(()=>{if(n)return;if(_&&T.length>0){const re=Math.min(f,T.length-1);Y(T[re]);return}const W=s.trim(),$=c.filter(re=>!re.error&&re.base64);W.length===0&&$.length===0||(e(W,{reset:H,setValue:J,model:a||void 0,attachments:$}),I())},[n,_,T,f,Y,s,c,e,H,J,a,I]),se=m.useCallback(W=>{e(W,{reset:H,setValue:J,model:a||void 0,attachments:[]}),I()},[I,e,H,J,a]),ee=m.useCallback(W=>{if(_){if(W.key==="Escape"){W.preventDefault(),g(!0),p(0);return}if(T.length!==0){if(W.key==="ArrowDown"){W.preventDefault(),p($=>($+1)%T.length);return}if(W.key==="ArrowUp"){W.preventDefault(),p($=>($-1+T.length)%T.length);return}if(W.key==="Tab"){W.preventDefault();const $=Math.min(f,T.length-1);Y(T[$])}}}},[_,T,f,Y]);m.useEffect(()=>()=>{C.current?.abort(),D.current&&clearInterval(D.current),F.current&&F.current.state!=="inactive"&&F.current.stop(),z.current&&z.current.abort()},[]);const le=m.useCallback(()=>{if(typeof window>"u")return"auto";try{return localStorage.getItem("opencami-stt-provider")||"auto"}catch{return"auto"}},[]),me=m.useCallback(()=>{F.current&&F.current.state!=="inactive"&&F.current.stop(),z.current&&z.current.stop(),D.current&&(clearInterval(D.current),D.current=null),S(!1),N(0)},[]),Se=m.useCallback(async()=>{const W=le();if(W==="browser"){const $=window.SpeechRecognition||window.webkitSpeechRecognition;if(!$){alert("Web Speech API is not supported in this browser.");return}const re=new $;re.continuous=!0,re.interimResults=!1,re.lang=navigator.language||"en-US",z.current=re,S(!0),N(0),D.current=setInterval(()=>{N(ie=>ie>=119?(me(),0):ie+1)},1e3);let ge="";re.onresult=ie=>{for(let ye=ie.resultIndex;ye<ie.results.length;ye++)ie.results[ye].isFinal&&(ge+=ie.results[ye][0].transcript)},re.onend=()=>{S(!1),N(0),D.current&&clearInterval(D.current),ge.trim()&&(o(ie=>ie+(ie?" ":"")+ge.trim()),I())},re.onerror=()=>{S(!1),N(0),D.current&&clearInterval(D.current)},re.start();return}try{const $=await navigator.mediaDevices.getUserMedia({audio:!0}),re=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",ge=new MediaRecorder($,{mimeType:re});F.current=ge,U.current=[],ge.ondataavailable=ie=>{ie.data.size>0&&U.current.push(ie.data)},ge.onstop=async()=>{$.getTracks().forEach(ye=>ye.stop());const ie=new Blob(U.current,{type:re});if(ie.size!==0){v(!0);try{const ye=new FormData;ye.append("audio",ie,`recording.${re==="audio/webm"?"webm":"mp4"}`),W!=="auto"&&ye.append("provider",W),C.current?.abort();const Ae=new AbortController;C.current=Ae;const Ie=await(await fetch("/api/stt",{method:"POST",body:ye,signal:Ae.signal})).json();Ie.ok&&Ie.text?(o(Ne=>Ne+(Ne?" ":"")+Ie.text),I()):Ie.ok||(console.warn("STT failed:",Ie.error),alert(Ie.error||"Speech-to-text failed. Try the Browser provider in Settings."))}catch(ye){if(ye instanceof Error&&ye.name==="AbortError")return;console.warn("STT request failed:",ye),alert("Could not reach speech-to-text service.")}finally{v(!1)}}},S(!0),N(0),D.current=setInterval(()=>{N(ie=>ie>=119?(me(),0):ie+1)},1e3),ge.start()}catch($){const re=$ instanceof Error?$.message:String($);if(re.includes("NotAllowedError")||re.includes("Permission"))try{(await navigator.permissions.query({name:"microphone"})).state==="denied"?alert("Microphone access is blocked. Please enable it in your browser/app settings."):alert("Microphone permission was not granted. Please try again and allow access when prompted.")}catch{alert("Could not access microphone. Please check your browser settings and allow microphone access for this site.")}else alert("Could not access microphone: "+re)}},[le,me,I]),we=m.useCallback(()=>{w?me():Se()},[w,me,Se]),xe=c.filter(W=>!W.error&&W.base64),Ee=n||s.trim().length===0&&xe.length===0;return h.jsxs("div",{className:"mx-auto w-full max-w-[var(--opencami-chat-width)] px-2 md:px-5 relative pb-1 md:pb-3",ref:r,onDragOver:K,onDragLeave:V,onDrop:b,children:[y&&h.jsx("div",{className:"pointer-events-none absolute inset-2 z-20 flex items-center justify-center rounded-2xl border-2 border-dashed border-primary-400 bg-primary-50/90 text-sm font-medium text-primary-700",children:"Drop image here"}),h.jsxs(xb,{value:s,onValueChange:Z,onSubmit:ae,isLoading:t,disabled:n,children:[h.jsx($b,{attachments:c,onRemove:x}),_&&T.length>0&&h.jsx(Hb,{commands:T,selectedIndex:Math.min(f,T.length-1),onSelect:Y}),h.jsx(yb,{placeholder:"Type a message…",inputRef:B,onKeyDown:ee}),h.jsxs(bb,{className:"justify-between px-3",children:[h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(Sb,{onModelChange:l}),h.jsx(qb,{}),h.jsx(Tb,{onSelect:se}),h.jsx(Ab,{onCommandSelect:W=>Z(W+" ")})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(Pb,{onFileSelect:L,disabled:n}),h.jsx(Ys,{tooltip:w?"Stop recording":"Voice input",children:h.jsx(Ce,{onClick:we,disabled:n||M,size:"icon-sm",variant:w?"destructive":"ghost",className:`rounded-full ${w?"animate-pulse":""}`,"aria-label":w?"Stop recording":"Voice input",children:M?h.jsx("span",{className:"size-4 animate-spin rounded-full border-2 border-current border-t-transparent"}):w?h.jsxs("span",{className:"flex items-center gap-1",children:[h.jsx("span",{className:"size-2 rounded-full bg-red-500"}),h.jsxs("span",{className:"text-xs tabular-nums",children:[Math.floor(E/60),":",String(E%60).padStart(2,"0")]}),h.jsx(ne,{icon:so,size:14,strokeWidth:2})]}):h.jsx(ne,{icon:Wl,size:18,strokeWidth:2})})}),h.jsx(Ys,{tooltip:"Send message",children:h.jsx(Ce,{onClick:ae,disabled:Ee,size:"icon-sm",className:"rounded-full","aria-label":"Send message",children:h.jsx(ne,{icon:Kl,size:18,strokeWidth:2})})})]})]})]})]})}const Kb=m.memo(Wb);function Vb({title:e,description:t,detail:n,actionLabel:r,onAction:i,className:s}){return h.jsx("div",{className:q("w-full max-w-[var(--opencami-chat-width)]",s),children:h.jsx(Xa,{children:h.jsxs("div",{className:"w-full rounded-xl border border-primary-200 bg-primary-50 p-4 text-primary-900",children:[h.jsx("div",{className:"text-balance font-medium",children:e}),h.jsx("div",{className:"mt-2 text-pretty text-primary-700",children:t}),n?h.jsx("div",{className:"mt-2 text-xs text-primary-600",children:n}):null,r&&i?h.jsx("div",{className:"mt-3",children:h.jsx(Ce,{size:"sm",variant:"outline",onClick:i,children:r})}):null]})})})}function Xb({state:e,error:t,onRetry:n,className:r}){const i=e==="checking",s=i?"Checking gateway connection...":"OpenClaw gateway is unreachable",o=i?"This dashboard needs access to the OpenClaw gateway configured by your server environment variables.":"";return h.jsx(Vb,{title:s,description:i?o:h.jsxs(h.Fragment,{children:["We could not reach the gateway from the dashboard server. Start the gateway and confirm your server environment has"," ",h.jsx("span",{className:"font-mono",children:"CLAWDBOT_GATEWAY_URL"})," plus"," ",h.jsx("span",{className:"font-mono",children:"CLAWDBOT_GATEWAY_TOKEN"})," (or"," ",h.jsx("span",{className:"font-mono",children:"CLAWDBOT_GATEWAY_PASSWORD"}),")."]}),detail:i?null:t,actionLabel:i?void 0:"Retry",onAction:i?void 0:n,className:r})}function Yb(){const e=m.useRef(null),t=m.useRef(null),n=m.useRef(null),[r,i]=m.useState(0),[s,o]=m.useState(0);return m.useLayoutEffect(()=>{const a=e.current,l=t.current,c=n.current;if(!c)return;const u=()=>{const p=a?.offsetHeight??0,d=l?.offsetHeight??0,g=c.clientHeight;c.style.setProperty("--chat-header-height",`${Math.max(0,p)}px`),c.style.setProperty("--chat-composer-height",`${Math.max(0,d)}px`),o(p),i(Math.max(0,g-p-d))};u();const f=new ResizeObserver(()=>u());return a&&f.observe(a),l&&f.observe(l),()=>f.disconnect()},[]),{headerRef:e,composerRef:t,mainRef:n,pinGroupMinHeight:r,headerHeight:s}}function Gb({activeFriendlyId:e,activeSessionKey:t,forcedSessionKey:n,isNewChat:r,isRedirecting:i,activeExists:s,sessionsReady:o,queryClient:a}){const l=n||t||e,c=ke.history(e,l),u=Tn({queryKey:c,queryFn:async function(){const S=a.getQueryData(c),E=Array.isArray(S?.messages)?S.messages.filter(v=>v.status==="sending"||v.__optimisticId?!0:!!v.clientId):[],N=await jc({sessionKey:l,friendlyId:e});if(!E.length)return N;const M=Qb(N.messages,E);return{...N,messages:M}},enabled:!r&&!!e&&!i&&(!o||s),placeholderData:function(){return a.getQueryData(c)},gcTime:1e3*60*10}),f=m.useRef(""),p=m.useRef([]),d=m.useMemo(()=>{const w=Array.isArray(u.data?.messages)?u.data.messages:[],S=w[w.length-1],E=S&&typeof S.id=="string"?S.id:"",N=`${w.length}:${S?.role??""}:${E}:${tt(S??{content:[]}).slice(-32)}`;return N===f.current?p.current:(f.current=N,p.current=w,w)},[u.data?.messages]),g=u.error instanceof Error?u.error.message:null,y=m.useMemo(()=>{if(n)return n;const w=u.data?.sessionKey;return typeof w=="string"&&w.trim().length>0?w.trim():t},[t,n,u.data?.sessionKey]);return{historyQuery:u,historyMessages:d,displayMessages:d,historyError:g,resolvedSessionKey:y,activeCanonicalKey:r?"new":y||e,sessionKeyForHistory:l}}function Qb(e,t){if(!t.length)return e;const n=[...e];for(const r of t)e.some(s=>{if(r.clientId&&s.clientId&&r.clientId===s.clientId||r.__optimisticId&&s.__optimisticId&&r.__optimisticId===s.__optimisticId)return!0;if(r.role&&s.role&&r.role!==s.role)return!1;const o=tt(r);if(!o||o!==tt(s))return!1;const a=Lr(r),l=Lr(s);return Math.abs(a-l)<=1e4})||n.push(r);return n}function Jb(e){const[t,n]=m.useState(!1);return m.useLayoutEffect(()=>{const r=window.matchMedia("(max-width: 768px)"),i=()=>n(r.matches);return i(),r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[]),m.useLayoutEffect(()=>{t&&kt(e,function(i){return{...i,isSidebarCollapsed:!0}})},[t,e]),{isMobile:t}}function Zb({activeFriendlyId:e,isNewChat:t,forcedSessionKey:n}){const r=Tn({queryKey:ke.sessions,queryFn:Tc,refetchInterval:3e4}),i=m.useMemo(()=>{const f=r.data??[];return Vu(f)},[r.data]),s=m.useMemo(()=>i.find(f=>f.friendlyId===e),[i,e]),o=m.useMemo(()=>t||n||Lo(e)?!0:i.some(f=>f.friendlyId===e),[e,n,t,i]),a=s?.key??"",l=m.useMemo(()=>s?s.label||s.title||s.derivedTitle||s.friendlyId:e,[e,s]),c=r.error instanceof Error?r.error.message:null,u=m.useMemo(()=>({totalTokens:s?.totalTokens,contextTokens:s?.contextTokens}),[s?.totalTokens,s?.contextTokens]);return{sessionsQuery:r,sessions:i,activeSession:s,activeExists:o,activeSessionKey:a,activeTitle:l,activeTokens:u,sessionsError:c}}function e0(){const e=Nt(c=>c.settings),[t,n]=m.useState(!1),[r,i]=m.useState(null),[s,o]=m.useState(null),a=m.useRef(null);return{generateTitle:m.useCallback(async c=>{a.current&&a.current.abort();const u=new AbortController;a.current=u,n(!0);try{const f={"Content-Type":"application/json",...Qa()},p=await fetch("/api/llm-features",{method:"POST",headers:f,body:JSON.stringify({action:"title",message:c}),signal:u.signal});if(!p.ok)throw new Error(`API error: ${p.status}`);const d=await p.json();if(u.signal.aborted)throw new Error("Aborted");const g=d.title||c.slice(0,50),y=g.length>64?g.slice(0,61)+"...":g,k=d.source||"heuristic";return i(y),o(k),{title:y,source:k,error:d.error}}catch(f){if(f instanceof Error&&f.name==="AbortError")throw f;const p=t0(c);return i(p),o("heuristic"),{title:p,source:"heuristic",error:f instanceof Error?f.message:"Unknown error"}}finally{n(!1),a.current===u&&(a.current=null)}},[e.llmApiKey,e.llmBaseUrl,e.llmModel,e.llmProvider]),isGenerating:t,lastTitle:r,lastSource:s}}function t0(e){let t=e.replace(/```[\s\S]*?```/g," ");t=t.replace(/`[^`]+`/g," "),t=t.replace(/https?:\/\/[^\s]+/g," "),t=t.replace(/[^\w\s.,!?'-]/g," "),t=t.replace(/\s+/g," ").trim();let i=t.split(/\s+/).filter(s=>{if(s.length<=2){const o=s.toUpperCase();return["AI","ML","UI","UX","API","CSS","JS"].includes(o)}return!0}).slice(0,6).join(" ");return i=i.replace(/[.,!?]+$/,""),i.length>60&&(i=i.slice(0,57)+"..."),i||e.slice(0,50)}function n0(){return Nt(e=>e.settings.useLlmTitles)}const Rr={active:!1,text:"",tools:[],sessionKey:null};function r0(e){const[t,n]=m.useState(Rr),r=m.useRef(null),i=m.useRef(e.onDone),s=m.useRef(e.onError);i.current=e.onDone,s.current=e.onError;const o=m.useCallback(l=>{if(r.current&&(r.current.close(),r.current=null),l?.preserveState){n(c=>({...c,active:!1}));return}n(Rr)},[]),a=m.useCallback(l=>{r.current&&(r.current.close(),r.current=null),n({active:!0,text:"",tools:[],sessionKey:l});const c=new EventSource(`/api/stream?sessionKey=${encodeURIComponent(l)}`);r.current=c,c.addEventListener("delta",u=>{try{const f=JSON.parse(u.data);n(p=>({...p,text:p.text+f.text}))}catch{}}),c.addEventListener("tool",u=>{try{const f=JSON.parse(u.data);n(p=>{const d=p.tools.findIndex(y=>y.id===f.id),g=[...p.tools];return d>=0?g[d]={name:f.name,status:f.status,id:f.id}:g.push({name:f.name,status:f.status,id:f.id}),{...p,tools:g}})}catch{}}),c.addEventListener("done",u=>{try{const f=JSON.parse(u.data);c.close(),r.current=null,n(p=>({...p,active:!1})),i.current(f.sessionKey)}catch{}}),c.onerror=()=>{c.readyState===EventSource.CLOSED&&(c.close(),r.current=null,n(Rr),s.current?.("Stream connection lost"))}},[]);return{streaming:t,startStream:a,stopStream:o}}function i0(e){const t=m.useCallback(n=>{const r=n.target,i=r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable;if(n.key==="Escape"){e.onEscape?.();return}if(n.key==="?"&&!i&&!n.metaKey&&!n.ctrlKey){n.preventDefault(),e.onShowHelp?.();return}if(i)return;const o=navigator.platform.toUpperCase().indexOf("MAC")>=0?n.metaKey:n.ctrlKey;if(o&&n.key==="k"&&!n.shiftKey){n.preventDefault(),e.onNewChat?.();return}if(o&&n.key==="/"){n.preventDefault(),e.onFocusInput?.();return}if(o&&n.shiftKey&&n.key==="C"){n.preventDefault(),e.onCopyLastResponse?.();return}if(o&&n.key==="f"&&!n.shiftKey){n.preventDefault(),e.onSearch?.();return}if(o&&n.shiftKey&&n.key==="F"){n.preventDefault(),e.onSearchGlobal?.();return}},[e]);m.useEffect(()=>(window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}),[t])}function Js(e){const{threshold:t=50,edgeWidth:n,onMove:r,onSwipe:i,onCancel:s,direction:o,enabled:a=!0}=e,l=m.useRef({startX:0,startY:0,tracking:!1,directionLocked:!1}),c=m.useCallback(p=>{if(!a)return;const d=p.touches[0];d&&(n!==void 0&&d.clientX>n||(l.current={startX:d.clientX,startY:d.clientY,tracking:!0,directionLocked:!1}))},[a,n]),u=m.useCallback(p=>{const d=l.current;if(!d.tracking)return;const g=p.touches[0];if(!g)return;const y=g.clientX-d.startX,k=g.clientY-d.startY,w=Math.abs(y),S=Math.abs(k);if(!d.directionLocked){if(w<5&&S<5)return;if(S>w){d.tracking=!1,s?.();return}d.directionLocked=!0}o==="left"&&y>0||o==="right"&&y<0||(p.preventDefault(),r?.(y))},[o,r,s]),f=m.useCallback(p=>{const d=l.current;if(!d.tracking)return;d.tracking=!1;const g=p.changedTouches[0];if(!g){s?.();return}const y=g.clientX-d.startX,k=Math.abs(y);if(!d.directionLocked||k<t){s?.();return}const w=y>0?"right":"left";if(o&&w!==o){s?.();return}i(w)},[o,s,i,t]);return{onTouchStart:c,onTouchMove:u,onTouchEnd:f}}const s0=m.lazy(()=>Hn(()=>import("./keyboard-shortcuts-dialog-CcKSlK52.js"),__vite__mapDeps([19,1,3,2,4,5,6,7,8,9])).then(e=>({default:e.KeyboardShortcutsDialog}))),o0=m.lazy(()=>Hn(()=>import("./search-dialog-D19x_xaG.js"),__vite__mapDeps([20,1,2,3,4,5,6,7,8,9,11,13,15,16,14,17])).then(e=>({default:e.SearchDialog}))),kn="opencami-search-jump-target";function a0({activeFriendlyId:e,isNewChat:t=!1,onSessionResolved:n,forcedSessionKey:r}){const i=Yr(),s=qt(),[o,a]=m.useState(!1),[l,c]=m.useState(!1),[u,f]=m.useState(null),[p,d]=m.useState(!1),{headerRef:g,composerRef:y,mainRef:k,pinGroupMinHeight:w,headerHeight:S}=Yb(),[E,N]=m.useState(()=>cr()||ur()),[M,v]=m.useState(()=>cr()||ur()),[F,U]=m.useState(!1),[D,C]=m.useState(!1),[z,j]=m.useState("global"),[_,R]=m.useState(null),[T,B]=m.useState(!1),I=Xr(P=>P.level),H=m.useRef(null),L=m.useRef(null),x=m.useRef(null),K=m.useRef(""),V=m.useRef(()=>{}),b=m.useRef(!1),{isMobile:J}=Jb(s),{sessionsQuery:Z,sessions:Y,activeExists:ae,activeSessionKey:se,activeTitle:ee,activeTokens:le,sessionsError:me}=Zb({activeFriendlyId:e,isNewChat:t,forcedSessionKey:r}),{historyQuery:Se,historyMessages:we,displayMessages:xe,historyError:Ee,resolvedSessionKey:W,activeCanonicalKey:$,sessionKeyForHistory:re}=Gb({activeFriendlyId:e,activeSessionKey:se,forcedSessionKey:r,isNewChat:t,isRedirecting:p,activeExists:ae,sessionsReady:Z.isSuccess,queryClient:s}),ge=Tn({queryKey:Cl,queryFn:function(){return Oi(s)},initialData:function(){return Oi(s)},staleTime:1/0}),ie=Tn({queryKey:["gateway","status"],queryFn:Ac,retry:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:"always"}),ye=m.useRef(Date.now()),Ae=ie.error instanceof Error?ie.error.message:ie.data&&!ie.data.ok?ie.data.error||"Gateway unavailable":null,Ge=Ae??me??Ee,Ie=m.useCallback(()=>{ie.refetch()},[ie]),Ne=ge.data?.isSidebarCollapsed??!1,A=Js({enabled:J&&Ne,edgeWidth:40,threshold:50,direction:"right",onSwipe:()=>{kt(s,P=>({...P,isSidebarCollapsed:!1}))}}),O=Js({enabled:J&&!Ne,threshold:50,direction:"left",onSwipe:()=>{kt(s,P=>({...P,isSidebarCollapsed:!0}))}}),G=m.useCallback(()=>{f(null),d(!0),i({to:"/new",replace:!0})},[i]),te=m.useCallback(()=>{L.current&&(window.clearInterval(L.current),L.current=null),x.current&&(window.clearTimeout(x.current),x.current=null)},[]),ce=m.useCallback(()=>{te(),Xt(!1),N(!1),B(!1)},[te]),Re=n0(),{generateTitle:Ue}=e0(),Oe=m.useRef(new Set),qe=150,Qe=600,je=m.useCallback(()=>{!e||t||(L.current&&window.clearInterval(L.current),B(!0),L.current=window.setInterval(()=>{V.current()},qe))},[e,t]),We=m.useRef(()=>{}),ze=m.useRef(()=>{}),{streaming:rt,startStream:tr,stopStream:it}=r0({onDone:P=>We.current(P),onError:P=>ze.current(P)});We.current=m.useCallback(async P=>{await Se.refetch(),it({preserveState:!0}),ce(),s.invalidateQueries({queryKey:ke.sessions})},[Se,s,it,ce]),ze.current=m.useCallback(P=>{console.warn("[stream] SSE error, falling back to polling")},[]);const he=m.useMemo(()=>{if(!rt.text)return null;const P=[];for(const X of rt.tools)P.push({type:"toolCall",name:X.name,id:X.id});return P.push({type:"text",text:rt.text}),{role:"assistant",content:P,id:"__streaming__",__streaming:!0,timestamp:Date.now()}},[rt.text,rt.tools]),Ke=m.useMemo(()=>{if(!he)return xe;const P=[...xe].map((be,Te)=>({message:be,index:Te})).filter(({message:be})=>be.role==="assistant").map(({index:be})=>be).pop(),X=[...xe].map((be,Te)=>({message:be,index:Te})).filter(({message:be})=>be.role==="user").map(({index:be})=>be).pop();if(typeof P=="number"&&(typeof X!="number"||P>X)&&typeof P=="number"){const be=xe[P];if(tt(be).length>=rt.text.length)return xe;const ot=[...xe];return ot[P]=he,ot}return[...xe,he]},[xe,he,rt.text]),zt=m.useMemo(()=>({}),[]);V.current=function(){Se.refetch()},m.useEffect(()=>{if(p){u&&f(null);return}if(st){u&&f(null);return}if(Z.isSuccess&&!ae){u&&f(null);return}const P=me??Ee??Ae;if(!P){u?.startsWith("Failed to load")&&f(null);return}Bi(P)&&i({to:"/connect",replace:!0});const X=me?`Failed to load sessions. ${me}`:Ee?`Failed to load history. ${Ee}`:Ae?`Gateway unavailable. ${Ae}`:null;X&&f(X)},[u,Ae,Ee,p,i,me]);const st=!t&&!r&&!Lo(e)&&Z.isSuccess&&Y.length>0&&!Y.some(P=>P.friendlyId===e)&&!Se.isFetching&&!Se.isSuccess;m.useEffect(()=>{if(p){if(t){d(!1);return}!st&&Z.isSuccess&&d(!1)}},[t,p,Z.isSuccess,st]),m.useEffect(()=>{t||Z.isSuccess&&Y.length!==0&&st&&(Mn(),Dr(s,e,re),i({to:"/new",replace:!0}))},[e,Se.isFetching,Se.isSuccess,t,i,s,re,Y,Z.isSuccess,st]);const Ri=st||p,pn=m.useRef("fast");m.useEffect(()=>{const P=we[we.length-1];if(!P||P.role!=="assistant")return;const X=`${we.length}:${tt(P).slice(-64)}`;X!==K.current&&(K.current=X,pn.current!=="fast"&&L.current&&(window.clearInterval(L.current),L.current=window.setInterval(()=>{V.current()},qe),pn.current="fast"),x.current&&window.clearTimeout(x.current),x.current=window.setTimeout(()=>{L.current&&(window.clearInterval(L.current),L.current=window.setInterval(()=>{V.current()},Qe),pn.current="slow"),x.current=window.setTimeout(()=>{ce(),pn.current="fast"},3e3)},1500))},[we,ce]),m.useEffect(()=>{if(!Re||t||p)return;const P=r||W||se;if(!P||Oe.current.has(P))return;const X=we.filter(Te=>Te.role==="user"),ve=we.filter(Te=>Te.role==="assistant");if(X.length===0||ve.length===0||X.length!==1)return;const be=tt(X[0]);!be||be.length<5||(Oe.current.add(P),(async()=>{try{const Te=await Ue(be);Te.title&&await Dc(s,P,e,Te.title)}catch(Te){console.error("[smart-title] Error generating title:",Te)}})())},[Re,t,p,r,W,se,e,we,Ue,s]),m.useEffect(()=>{if(t||e){if(te(),it(),K.current="",B(!1),b.current){b.current=!1;return}if(cr()||ur()){N(!0),v(!0);return}N(!1),v(!1)}},[e,t,te,it]),m.useEffect(()=>{if(!(typeof window>"u"))try{const P=sessionStorage.getItem(kn);if(!P){R(null);return}const X=JSON.parse(P);if(typeof X.at=="number"&&Date.now()-X.at>300*1e3){sessionStorage.removeItem(kn),R(null);return}if(X.friendlyId===e&&typeof X.messageId=="string"&&X.messageId.length>0){R(X.messageId),sessionStorage.removeItem(kn);return}R(null)}catch{R(null)}},[e]),m.useLayoutEffect(()=>{if(t)return;const P=Uu(r||W||se,e);if(!P)return;b.current=!0;const X=ke.history(P.friendlyId,P.sessionKey),ve=s.getQueryData(X);(Array.isArray(ve?.messages)?ve.messages:[]).some(ot=>!!(P.optimisticMessage.clientId&&(ot.clientId===P.optimisticMessage.clientId||ot.__optimisticId===P.optimisticMessage.clientId)||P.optimisticMessage.__optimisticId&&ot.__optimisticId===P.optimisticMessage.__optimisticId))||sr(s,P.friendlyId,P.sessionKey,P.optimisticMessage),N(!0),v(!0),nr(P.sessionKey,P.friendlyId,P.message,!0,P.attachments)},[e,se,r,t,s,W]);function nr(P,X,ve,be=!1,Te,ot){let Pt="";if(!be){const{clientId:Le,optimisticMessage:Kt}=Hi(ve,Te);Pt=Le,sr(s,X,P,Kt),Lc(s,P,X,Kt)}Xt(!0),a(!0),f(null),N(!0),v(!0);const yt=Te?.map(Le=>({mimeType:Le.file.type,content:Le.base64}));tr(P),je(),fetch("/api/send",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({sessionKey:P,friendlyId:X,message:ve,thinking:I,idempotencyKey:crypto.randomUUID(),attachments:yt,model:ot||void 0})}).then(async Le=>{if(!Le.ok)throw new Error(await lt(Le))}).catch(Le=>{const Kt=Le instanceof Error?Le.message:String(Le);if(Bi(Kt)){i({to:"/connect",replace:!0});return}Pt&&Ic(s,X,P,Pt,function(gl){return{...gl,status:"error"}}),f(`Failed to send message. ${Kt}`),Xt(!1),N(!1),v(!1)}).finally(()=>{a(!1)})}const Ni=m.useCallback(async()=>{c(!0);try{const P=await fetch("/api/sessions",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({})});if(!P.ok)throw new Error(await lt(P));const X=await P.json(),ve=typeof X.sessionKey=="string"?X.sessionKey:"",be=typeof X.friendlyId=="string"&&X.friendlyId.trim().length>0?X.friendlyId.trim():Nr(ve);if(!ve||!be)throw new Error("Invalid session response");return s.invalidateQueries({queryKey:ke.sessions}),{sessionKey:ve,friendlyId:be}}finally{c(!1)}},[s]),il=m.useCallback((P,X)=>{const ve=X.attachments;if(P.length===0&&(!ve||ve.length===0))return;if(X.reset(),t){const{clientId:Te,optimisticId:ot,optimisticMessage:Pt}=Hi(P,ve);sr(s,"new","new",Pt),Xt(!0),a(!0),N(!0),v(!0),Ni().then(({sessionKey:yt,friendlyId:Le})=>{if(Hu(Le),$u({sessionKey:yt,friendlyId:Le,message:P,optimisticMessage:Pt,attachments:ve}),n){n({sessionKey:yt,friendlyId:Le});return}i({to:"/chat/$sessionKey",params:{sessionKey:Le},replace:!0})}).catch(yt=>{Rc(s,"new","new",Te,ot),X.setValue(P),f(`Failed to create session. ${yt instanceof Error?yt.message:String(yt)}`),Xt(!1),N(!1),v(!1),a(!1)});return}nr(r||W||se,e,P,!1,ve,X.model)},[e,se,Ni,r,t,i,n,s,W]),Li=m.useCallback(()=>{N(!1),v(!1),Dr(s,"new","new"),i({to:"/new"}),J&&kt(s,function(X){return{...X,isSidebarCollapsed:!0}})},[J,i,s]),sl=m.useCallback(()=>{kt(s,function(X){return{...X,isSidebarCollapsed:!X.isSidebarCollapsed}})},[s]),ol=m.useCallback(()=>{J&&kt(s,function(X){return{...X,isSidebarCollapsed:!0}})},[J,s]),al=m.useCallback(()=>{kt(s,function(X){return{...X,isSidebarCollapsed:!1}})},[s]),ll=m.useCallback(P=>{if(t||!P.trim())return;const X=r||W||se;X&&nr(X,e,P.trim())},[e,se,r,t,W]),cl=m.useCallback(()=>{H.current?.focus()},[]),ul=m.useCallback(()=>{if(F){U(!1);return}document.activeElement instanceof HTMLElement&&document.activeElement.blur()},[F]),fl=m.useCallback(()=>{const P=[...xe].reverse().find(ve=>ve.role==="assistant");if(!P)return;const X=tt(P);X&&navigator.clipboard.writeText(X).catch(()=>{})},[xe]),hl=m.useCallback(()=>{U(!0)},[]),pl=m.useCallback(()=>{j(t?"global":"current"),C(!0)},[t]),Mi=m.useCallback(()=>{j("global"),C(!0)},[]);i0({onNewChat:Li,onFocusInput:cl,onEscape:ul,onCopyLastResponse:fl,onShowHelp:hl,onSearch:pl,onSearchGlobal:Mi});const Di=Se.isLoading&&!Se.data||p,zi=!!Ae&&ie.errorUpdatedAt>ye.current,dl=!Di&&xe.length===0,ml=m.useMemo(()=>!zi||!Ge?null:h.jsx(Xb,{state:"error",error:Ge,onRetry:Ie}),[Ge,Ie,zi]),Pi=h.jsx(tf,{sessions:Y,activeFriendlyId:e,activeSessionKey:re,creatingSession:l,onCreateSession:Li,isCollapsed:J?!1:Ne,onToggleCollapse:sl,onSelectSession:ol,onActiveSessionDelete:G,onOpenSearch:Mi});return h.jsxs("div",{className:"h-screen bg-surface text-primary-900",children:[h.jsxs("div",{className:q("h-full overflow-hidden",J?"relative":"grid grid-cols-[auto_minmax(0,1fr)]"),children:[Ri?null:J?h.jsxs(h.Fragment,{children:[!Ne&&h.jsx("div",{className:"fixed inset-0 z-40 bg-black/40 transition-opacity duration-200",onClick:()=>kt(s,P=>({...P,isSidebarCollapsed:!0})),...O}),h.jsx("div",{className:q("fixed inset-y-0 left-0 z-50 w-[var(--opencami-sidebar-width)] transition-transform duration-150 safe-area-top",Ne?"-translate-x-full":"translate-x-0"),...O,children:Pi})]}):Pi,h.jsxs("main",{className:"flex flex-col h-full min-h-0 min-w-0 overflow-x-hidden",ref:k,...A,children:[h.jsx(of,{activeTitle:ee,wrapperRef:g,showSidebarButton:J,onOpenSidebar:al,totalTokens:le.totalTokens,contextTokens:le.contextTokens}),Ri?null:h.jsxs(h.Fragment,{children:[h.jsx(mb,{messages:Ke,loading:Di,empty:dl,notice:ml,noticePosition:"end",waitingForResponse:E,isStreaming:T,sessionKey:$,pinToTop:M,pinGroupMinHeight:w,headerHeight:S,contentStyle:zt,onFollowUpClick:ll,jumpToMessageId:_}),h.jsx(Kb,{onSubmit:il,isLoading:o,disabled:o,wrapperRef:y,inputRef:H})]})]})]}),F&&h.jsx(m.Suspense,{fallback:null,children:h.jsx(s0,{open:F,onOpenChange:U})}),D&&h.jsx(m.Suspense,{fallback:null,children:h.jsx(o0,{open:D,onOpenChange:C,sessions:Y,currentFriendlyId:e,currentSessionKey:se,mode:z,onJumpToMessage:P=>{if(C(!1),!!P.friendlyId){if(P.messageId&&P.friendlyId===e){R(P.messageId);return}if(P.messageId&&typeof window<"u")try{sessionStorage.setItem(kn,JSON.stringify({friendlyId:P.friendlyId,messageId:P.messageId,at:Date.now()}))}catch{}i({to:"/chat/$sessionKey",params:{sessionKey:P.friendlyId}})}}})})]})}function l0(){const e=qt(),t=Yr(),[n,r]=m.useState(null),i=bl.useParams(),s=typeof i.sessionKey=="string"?i.sessionKey:"main",o=s==="new",a=n?.friendlyId===s?n.sessionKey:void 0,l=m.useCallback(function(u){Nc(e,"new","new",u.friendlyId,u.sessionKey),r({friendlyId:u.friendlyId,sessionKey:u.sessionKey}),t({to:"/chat/$sessionKey",params:{sessionKey:u.friendlyId},replace:!0})},[t,e]);return h.jsx(a0,{activeFriendlyId:s,isNewChat:o,forcedSessionKey:a,onSessionResolved:o?l:void 0})}const T0=Object.freeze(Object.defineProperty({__proto__:null,component:l0},Symbol.toStringTag,{value:"Module"}));export{T0 as $,ke as c,Ya as g,E0 as u};