agent-canvas 0.1.8 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,63 +1,63 @@
1
- import{useState as v1}from"react";import{jsxDEV as u}from"react/jsx-dev-runtime";function Z1({title:B,children:y}){let[N,J]=v1(!1);return u("div",{className:"relative mb-8 p-4 group/section","data-md":"section","data-md-title":B,children:[u("div",{className:"relative mb-2",children:[u("button",{onClick:()=>J(!N),className:`absolute -left-8 top-1/2 -translate-y-1/2 text-text-tertiary opacity-0 group-hover/section:opacity-50 hover:!opacity-100 transition-all duration-150 p-0.5 ${N?"-rotate-90":""}`,children:u("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",children:u("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),u("h2",{className:"font-heading text-section text-text-primary",style:{fontWeight:400},children:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this),u("div",{className:N?"mt-6 hidden":"mt-6",children:y},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as c}from"react/jsx-dev-runtime";var w1={todo:"bg-border-hover",done:"bg-accent-green",blocked:"bg-accent-red","in-progress":"bg-accent-blue"},k1={todo:"Todo",done:"Done",blocked:"Blocked","in-progress":"In progress"},A1={info:"bg-accent-blue-muted text-accent-blue",success:"bg-accent-green-muted text-accent-green",warning:"bg-accent-amber-muted text-accent-amber",danger:"bg-accent-red-muted text-accent-red",neutral:"bg-border-subtle text-text-tertiary"};function gy({id:B,label:y,status:N,badge:J,badgeVariant:$="neutral",children:Q}){return c("div",{className:"group/task relative -mx-4 px-4 py-3 rounded-md transition-colors duration-150 hover:bg-bg-input","data-task-id":B,"data-md":"item","data-md-label":y,...N?{"data-md-status":N}:{},...J?{"data-md-badge":J}:{},children:c("div",{className:"flex items-start gap-3",children:[N&&c("span",{className:`w-2 h-2 rounded-full mt-[7px] flex-shrink-0 ${w1[N]}`},void 0,!1,void 0,this),c("div",{className:"flex-1 min-w-0",children:[c("div",{className:"flex items-baseline gap-2",children:[c("span",{className:"font-body text-task-label font-semibold text-text-primary",children:y},void 0,!1,void 0,this),N&&c("span",{className:"font-body text-tiny uppercase tracking-wider text-text-tertiary opacity-0 group-hover/task:opacity-100 transition-opacity duration-150",children:k1[N]},void 0,!1,void 0,this),J&&c("span",{className:`font-body text-tiny font-medium px-1.5 py-px rounded-full ${A1[$]}`,children:J},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q&&c("div",{className:"text-body text-text-secondary mt-1 leading-relaxed",children:Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function z1(B){return c(gy,{...B},void 0,!1,void 0,this)}import{useEffect as _1,useRef as O1}from"react";import{jsxDEV as Yy}from"react/jsx-dev-runtime";function C1({language:B,children:y}){let N=typeof y==="string"?y:String(y??""),J=O1(null);return _1(()=>{let $=J.current,Q=window.hljs;if(!$||!Q)return;$.removeAttribute("data-highlighted"),$.className=B?`language-${B}`:"",$.textContent=N,Q.highlightElement($)},[N,B]),Yy("div",{className:"relative mt-3 group/code","data-md":"codeblock","data-md-language":B||"",children:[B&&Yy("span",{className:"absolute top-2 right-3 text-tiny text-text-tertiary opacity-0 group-hover/code:opacity-60 transition-opacity duration-150 z-10 font-mono",children:B},void 0,!1,void 0,this),Yy("pre",{className:"bg-bg-code rounded-md p-4 overflow-x-auto text-code font-mono leading-relaxed",children:Yy("code",{ref:J,className:B?`language-${B}`:"",children:N},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as Gy}from"react/jsx-dev-runtime";var I1={info:{bg:"bg-accent-blue-muted",icon:"i",iconColor:"text-accent-blue"},warning:{bg:"bg-accent-amber-muted",icon:"!",iconColor:"text-accent-amber"},danger:{bg:"bg-accent-red-muted",icon:"✕",iconColor:"text-accent-red"},tip:{bg:"bg-accent-green-muted",icon:"✓",iconColor:"text-accent-green"}};function R1({type:B="info",children:y}){let N=I1[B];return Gy("div",{className:`${N.bg} relative rounded-lg px-5 py-4 mt-3 flex gap-3 items-start`,"data-md":"callout","data-md-type":B,children:[Gy("span",{className:`${N.iconColor} opacity-70 text-base leading-relaxed flex-shrink-0 mt-px`,children:N.icon},void 0,!1,void 0,this),Gy("div",{className:"text-body text-text-secondary leading-relaxed",children:y},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as g1}from"react/jsx-dev-runtime";function S1({children:B}){return g1("div",{className:"relative bg-bg-elevated rounded-lg px-5 py-4 mt-3 text-body text-text-secondary italic leading-relaxed","data-md":"note",children:B},void 0,!1,void 0,this)}import{jsxDEV as p}from"react/jsx-dev-runtime";function h1({headers:B,rows:y}){return p("div",{className:"overflow-x-auto mt-3","data-md":"table",children:p("table",{className:"w-full text-body",children:[p("thead",{children:p("tr",{className:"border-b border-border-subtle",children:B.map((N,J)=>p("th",{className:"text-left px-4 py-2.5 text-meta font-medium uppercase tracking-wider text-text-tertiary font-body",children:N},J,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),p("tbody",{children:y.map((N,J)=>p("tr",{className:`relative border-b border-border-subtle last:border-b-0 transition-colors hover:bg-bg-surface/50 ${J%2===1?"bg-bg-surface/30":""}`,children:N.map(($,Q)=>p("td",{className:"px-4 py-2.5 text-text-secondary font-body",children:$},Q,!1,void 0,this))},J,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as l}from"react/jsx-dev-runtime";function D1({items:B}){return l("ul",{className:"space-y-1 mt-3","data-md":"checklist",children:B.map((y,N)=>l("li",{"data-md":"checklist-item","data-md-label":y.label,className:"relative flex items-start gap-2.5 py-1",children:[l("span",{className:`w-4 h-4 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5 transition-all ${y.checked?"bg-accent-green":"border-[1.5px] border-border-hover"}`,children:y.checked&&l("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:l("path",{d:"M2.5 5L4.5 7L7.5 3",style:{stroke:"var(--color-text-inverse)"},strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),l("span",{className:`text-body font-body ${y.checked?"text-text-tertiary line-through decoration-border-hover":"text-text-secondary"}`,children:y.label},void 0,!1,void 0,this)]},N,!0,void 0,this))},void 0,!1,void 0,this)}import{jsxDEV as c1}from"react/jsx-dev-runtime";var j1={high:"text-accent-red bg-accent-red-muted",medium:"text-accent-amber bg-accent-amber-muted",low:"text-text-tertiary bg-border-subtle"};function V1({level:B}){return c1("span",{className:`inline text-tiny font-medium font-body ml-2 px-1.5 py-0.5 rounded ${j1[B]}`,"data-md":"priority","data-md-level":B,children:B},void 0,!1,void 0,this)}import{useEffect as hy,useState as Wy,useContext as Dy,useRef as x1}from"react";import{SessionContext as d1,ActiveViewCtx as p1}from"#canvas/runtime";import{jsxDEV as E}from"react/jsx-dev-runtime";var E1={ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",py:"python",rs:"rust",go:"go",rb:"ruby",java:"java",json:"json",yaml:"yaml",yml:"yaml",md:"markdown",css:"css",html:"html",sh:"bash",bash:"bash",toml:"toml",sql:"sql",xml:"xml",c:"c",cpp:"cpp",h:"c"};function u1({path:B,lines:y,__content:N}){let J=Dy(d1),{setActiveView:$}=Dy(p1),[Q,Y]=Wy(N??null),[f,W]=Wy(()=>{let L=B.split(".").pop()||"";return E1[L]||"text"}),[K,X]=Wy(null),[b,P]=Wy(!N),U=x1(null);if(hy(()=>{if(N!==void 0)return;P(!0),X(null),fetch(`/api/file?session=${J}&path=${encodeURIComponent(B)}`).then((L)=>L.json()).then((L)=>{if(L.error)X(L.error);else{let q=L.content;if(y)q=q.split(`
1
+ import{useState as V0}from"react";import{jsxDEV as J1}from"react/jsx-dev-runtime";function x0({title:J,children:y}){let[Q,Y]=V0(!1);return J1("div",{className:"relative mb-8 p-4 group/section","data-md":"section","data-md-title":J,children:[J1("div",{className:"relative mb-2",children:[J1("button",{onClick:()=>Y(!Q),className:`absolute -left-8 top-1/2 -translate-y-1/2 text-text-tertiary opacity-0 group-hover/section:opacity-50 hover:!opacity-100 transition-all duration-150 p-0.5 ${Q?"-rotate-90":""}`,children:J1("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",children:J1("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),J1("h2",{className:"font-heading text-section text-text-primary",style:{fontWeight:400},children:J},void 0,!1,void 0,this)]},void 0,!0,void 0,this),J1("div",{className:Q?"mt-6 hidden":"mt-6",children:y},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as i}from"react/jsx-dev-runtime";var D0={todo:"bg-border-hover",done:"bg-accent-green",blocked:"bg-accent-red","in-progress":"bg-accent-blue"},p0={todo:"Todo",done:"Done",blocked:"Blocked","in-progress":"In progress"},c0={info:"bg-accent-blue-muted text-accent-blue",success:"bg-accent-green-muted text-accent-green",warning:"bg-accent-amber-muted text-accent-amber",danger:"bg-accent-red-muted text-accent-red",neutral:"bg-border-subtle text-text-tertiary"};function s1({id:J,label:y,status:Q,badge:Y,badgeVariant:$="neutral",children:B}){return i("div",{className:"group/task relative -mx-4 px-4 py-3 rounded-md transition-colors duration-150 hover:bg-bg-input","data-task-id":J,"data-md":"item","data-md-label":y,...Q?{"data-md-status":Q}:{},...Y?{"data-md-badge":Y}:{},children:i("div",{className:"flex items-start gap-3",children:[Q&&i("span",{className:`w-2 h-2 rounded-full mt-[7px] flex-shrink-0 ${D0[Q]}`},void 0,!1,void 0,this),i("div",{className:"flex-1 min-w-0",children:[i("div",{className:"flex items-baseline gap-2",children:[i("span",{className:"font-body text-task-label font-semibold text-text-primary",children:y},void 0,!1,void 0,this),Q&&i("span",{className:"font-body text-tiny uppercase tracking-wider text-text-tertiary opacity-0 group-hover/task:opacity-100 transition-opacity duration-150",children:p0[Q]},void 0,!1,void 0,this),Y&&i("span",{className:`font-body text-tiny font-medium px-1.5 py-px rounded-full ${c0[$]}`,children:Y},void 0,!1,void 0,this)]},void 0,!0,void 0,this),B&&i("div",{className:"text-body text-text-secondary mt-1 leading-relaxed",children:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function E0(J){return i(s1,{...J},void 0,!1,void 0,this)}import{useEffect as d0,useRef as u0}from"react";import{jsxDEV as _1}from"react/jsx-dev-runtime";function r0({language:J,children:y}){let Q=typeof y==="string"?y:String(y??""),Y=u0(null);return d0(()=>{let $=Y.current,B=window.hljs;if(!$||!B)return;$.removeAttribute("data-highlighted"),$.className=J?`language-${J}`:"",$.textContent=Q,B.highlightElement($)},[Q,J]),_1("div",{className:"relative mt-3 group/code","data-md":"codeblock","data-md-language":J||"",children:[J&&_1("span",{className:"absolute top-2 right-3 text-tiny text-text-tertiary opacity-0 group-hover/code:opacity-60 transition-opacity duration-150 z-10 font-mono",children:J},void 0,!1,void 0,this),_1("pre",{className:"bg-bg-code rounded-md p-4 overflow-x-auto text-code font-mono leading-relaxed",children:_1("code",{ref:Y,className:J?`language-${J}`:"",children:Q},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as g1}from"react/jsx-dev-runtime";var i0={info:{bg:"bg-accent-blue-muted",icon:"i",iconColor:"text-accent-blue"},warning:{bg:"bg-accent-amber-muted",icon:"!",iconColor:"text-accent-amber"},danger:{bg:"bg-accent-red-muted",icon:"✕",iconColor:"text-accent-red"},tip:{bg:"bg-accent-green-muted",icon:"✓",iconColor:"text-accent-green"}};function l0({type:J="info",children:y}){let Q=i0[J];return g1("div",{className:`${Q.bg} relative rounded-lg px-5 py-4 mt-3 flex gap-3 items-start`,"data-md":"callout","data-md-type":J,children:[g1("span",{className:`${Q.iconColor} opacity-70 text-base leading-relaxed flex-shrink-0 mt-px`,children:Q.icon},void 0,!1,void 0,this),g1("div",{className:"text-body text-text-secondary leading-relaxed",children:y},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as o0}from"react/jsx-dev-runtime";function a0({children:J}){return o0("div",{className:"relative bg-bg-elevated rounded-lg px-5 py-4 mt-3 text-body text-text-secondary italic leading-relaxed","data-md":"note",children:J},void 0,!1,void 0,this)}import{jsxDEV as e}from"react/jsx-dev-runtime";function s0({headers:J,rows:y}){return e("div",{className:"overflow-x-auto mt-3","data-md":"table",children:e("table",{className:"w-full text-body",children:[e("thead",{children:e("tr",{className:"border-b border-border-subtle",children:J.map((Q,Y)=>e("th",{className:"text-left px-4 py-2.5 text-meta font-medium uppercase tracking-wider text-text-tertiary font-body",children:Q},Y,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),e("tbody",{children:y.map((Q,Y)=>e("tr",{className:`relative border-b border-border-subtle last:border-b-0 transition-colors hover:bg-bg-surface/50 ${Y%2===1?"bg-bg-surface/30":""}`,children:Q.map(($,B)=>e("td",{className:"px-4 py-2.5 text-text-secondary font-body",children:$},B,!1,void 0,this))},Y,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as X1}from"react/jsx-dev-runtime";function n0({items:J}){return X1("ul",{className:"space-y-1 mt-3","data-md":"checklist",children:J.map((y,Q)=>X1("li",{"data-md":"checklist-item","data-md-label":y.label,className:"relative flex items-start gap-2.5 py-1",children:[X1("span",{className:`w-4 h-4 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5 transition-all ${y.checked?"bg-accent-green":"border-[1.5px] border-border-hover"}`,children:y.checked&&X1("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:X1("path",{d:"M2.5 5L4.5 7L7.5 3",style:{stroke:"var(--color-text-inverse)"},strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),X1("span",{className:`text-body font-body ${y.checked?"text-text-tertiary line-through decoration-border-hover":"text-text-secondary"}`,children:y.label},void 0,!1,void 0,this)]},Q,!0,void 0,this))},void 0,!1,void 0,this)}import{jsxDEV as yy}from"react/jsx-dev-runtime";var t0={high:"text-accent-red bg-accent-red-muted",medium:"text-accent-amber bg-accent-amber-muted",low:"text-text-tertiary bg-border-subtle"};function e0({level:J}){return yy("span",{className:`inline text-tiny font-medium font-body ml-2 px-1.5 py-0.5 rounded ${t0[J]}`,"data-md":"priority","data-md-level":J,children:J},void 0,!1,void 0,this)}import{useEffect as n1,useState as w1,useContext as t1,useRef as $y}from"react";import{SessionContext as Jy,ActiveViewCtx as Qy}from"#canvas/runtime";import{jsxDEV as y1}from"react/jsx-dev-runtime";var Yy={ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",py:"python",rs:"rust",go:"go",rb:"ruby",java:"java",json:"json",yaml:"yaml",yml:"yaml",md:"markdown",css:"css",html:"html",sh:"bash",bash:"bash",toml:"toml",sql:"sql",xml:"xml",c:"c",cpp:"cpp",h:"c"};function By({path:J,lines:y,__content:Q}){let Y=t1(Jy),{setActiveView:$}=t1(Qy),[B,W]=w1(Q??null),[K,X]=w1(()=>{let q=J.split(".").pop()||"";return Yy[q]||"text"}),[L,N]=w1(null),[G,H]=w1(!Q),b=$y(null);if(n1(()=>{if(Q!==void 0)return;H(!0),N(null),fetch(`/api/file?session=${Y}&path=${encodeURIComponent(J)}`).then((q)=>q.json()).then((q)=>{if(q.error)N(q.error);else{let T=q.content;if(y)T=T.split(`
2
2
  `).slice(y[0]-1,y[1]).join(`
3
- `);Y(q),W(L.language||"text")}}).catch(()=>X("Failed to fetch file")).finally(()=>P(!1))},[J,B,y?.[0],y?.[1],N]),hy(()=>{let L=U.current,q=window.hljs;if(!L||!q||!Q)return;L.removeAttribute("data-highlighted"),L.className=f?`language-${f}`:"",L.textContent=Q,q.highlightElement(L)},[Q,f]),b)return E("div",{className:"text-text-tertiary text-body mt-3 bg-bg-code rounded-md p-4",children:["Loading ",B,"..."]},void 0,!0,void 0,this);if(K)return E("div",{className:"text-accent-red text-body mt-3 bg-accent-red-muted rounded-md p-4",children:[B,": ",K]},void 0,!0,void 0,this);return E("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden","data-md":"filepreview","data-md-path":B,...y?{"data-md-lines":`${y[0]}-${y[1]}`}:{},children:[E("div",{className:"px-4 py-2 flex items-center justify-between",children:[E("button",{className:"font-mono text-meta text-text-tertiary hover:text-text-secondary hover:underline cursor-pointer text-left",onClick:()=>$({type:"file",path:B}),title:`Open ${B}`,children:B},void 0,!1,void 0,this),y&&E("span",{className:"font-mono text-meta text-text-tertiary opacity-60",children:["L",y[0],"–",y[1]]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),E("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono !bg-transparent",style:{background:"transparent"},children:E("code",{ref:U,className:f?`language-${f}`:"",children:Q},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as vy,useRef as t,useState as o,useCallback as x}from"react";import a1 from"react-dom";import{useAnnotations as l1}from"#canvas/runtime";import{useEffect as my,useRef as My,useState as Ty,useCallback as Vy,useMemo as cy}from"react";import{createPortal as r1}from"react-dom";function jy(B,y){let $=y||document.body,Q=B.getBoundingClientRect(),Y=$.getBoundingClientRect(),f=$===document.body?window.scrollY:$.scrollTop,W=Q.bottom-Y.top+f+8,K=Math.max(0,Math.min(Q.left-Y.left,Y.width-280-12));return $.style.position="relative",{style:{position:"absolute",top:`${W}px`,left:`${K}px`},parent:$}}import{jsxDEV as h}from"react/jsx-dev-runtime";function i1({anchorEl:B,scrollContainer:y,onClose:N,ignoreSelector:J,zIndex:$="50",padding:Q="12px",width:Y="280px",children:f}){let W=My(null),K=My(N);K.current=N;let{style:X,parent:b}=jy(B,y);return my(()=>{let P=setTimeout(()=>{let U=(L)=>{if(W.current&&!W.current.contains(L.target)){if(J&&L.target.closest?.(J))return;K.current(),document.removeEventListener("mousedown",U)}};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},0);return()=>clearTimeout(P)},[J]),r1(h("div",{ref:W,style:{...X,zIndex:$,width:Y,background:"var(--color-bg-elevated)",border:"1px solid var(--color-border-hover)",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",padding:Q,fontFamily:"'Inter', sans-serif"},children:f},void 0,!1,void 0,this),b)}var dy=[{label:"Clarity",items:["Unclear","Why?","Needs example","Missing context"]},{label:"Scope",items:["Overkill","Out of scope","Important","Risky"]},{label:"Action",items:["Simplify","Rethink","Expand on this","Skip this"]}],xy=dy.flatMap((B)=>B.items);function py({anchorEl:B,scrollContainer:y,snippet:N,truncateAt:J=100,header:$,onAdd:Q,onCancel:Y}){let[f,W]=Ty(""),[K,X]=Ty(null),[b,P]=Ty(!1),U=My(null);my(()=>{U.current?.focus()},[]);let L=Vy(()=>{if(f.trim())Q(f.trim());else Y()},[f,Q,Y]),q=f.trim().length>0?xy.filter((H)=>H.toLowerCase().startsWith(f.trim().toLowerCase())):xy,G=b?[]:q.length===1&&q[0].toLowerCase()===f.trim().toLowerCase()?[]:q,Z=new Set(G),A=dy.map((H)=>({label:H.label,items:H.items.filter((T)=>Z.has(T))})).filter((H)=>H.items.length>0),w=A.map((H)=>H.items),C=w.flat(),I=cy(()=>{if(K===null)return 0;let H=0;for(let T=0;T<w.length;T++){if(K<H+w[T].length)return T;H+=w[T].length}return 0},[K,w]),z=cy(()=>{if(K===null)return 0;let H=0;for(let T=0;T<I;T++)H+=w[T].length;return K-H},[K,I,w]),g=(H,T)=>{let _=0;for(let S=0;S<H;S++)_+=w[S].length;return _+T};my(()=>{X(null),P(!1)},[f]);let D=Vy((H)=>{W(H)},[]),O=N.length>J?N.slice(0,J)+"...":N;return h(i1,{anchorEl:B,scrollContainer:y,onClose:Y,width:"420px",children:[$??h("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontStyle:"italic",marginBottom:"8px",lineHeight:"1.4",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:["“",O,"”"]},void 0,!0,void 0,this),h("textarea",{ref:U,value:f,onChange:(H)=>W(H.target.value),onKeyDown:(H)=>{if(C.length>0&&(H.key==="ArrowDown"||H.key==="ArrowUp"||H.key==="ArrowLeft"||H.key==="ArrowRight")){if(H.preventDefault(),K===null){X(0);return}if(H.key==="ArrowDown"){let T=Math.min(z+1,w[I].length-1);X(g(I,T))}else if(H.key==="ArrowUp"){let T=Math.max(z-1,0);X(g(I,T))}else if(H.key==="ArrowRight"){let T=Math.min(I+1,w.length-1),_=Math.min(z,w[T].length-1);X(g(T,_))}else if(H.key==="ArrowLeft"){let T=Math.max(I-1,0),_=Math.min(z,w[T].length-1);X(g(T,_))}return}if(K!==null&&C.length>0){if(H.key==="Tab"){H.preventDefault(),D(C[K]);return}if(H.key==="Enter"&&!H.shiftKey){H.preventDefault(),Q(C[K]);return}}if(H.key==="Enter"&&!H.shiftKey){H.preventDefault(),L();return}if(H.key==="Escape")if(C.length>0&&!b)P(!0);else Y()},style:{width:"100%",minHeight:"60px",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",resize:"vertical",outline:"none"},placeholder:"Add your note..."},void 0,!1,void 0,this),h("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px",marginTop:"8px"},children:[h("button",{onClick:Y,style:{fontSize:"11px",color:"var(--color-text-tertiary)",background:"none",border:"none",cursor:"pointer",padding:"4px 12px",fontFamily:"'Inter', sans-serif"},children:"Cancel"},void 0,!1,void 0,this),h("button",{onClick:L,style:{fontSize:"11px",fontWeight:500,padding:"4px 12px",borderRadius:"6px",background:"var(--color-highlight-bg)",color:"var(--color-text-primary)",border:"1px solid var(--color-highlight-border)",cursor:"pointer",fontFamily:"'Inter', sans-serif"},children:"Add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),C.length>0&&h("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:A.map((H)=>h("div",{style:{flex:1},children:[h("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--color-text-disabled)",textTransform:"uppercase",letterSpacing:"0.05em",padding:"2px 6px",marginBottom:"2px",fontFamily:"'Inter', sans-serif"},children:H.label},void 0,!1,void 0,this),H.items.map((T)=>{let _=C.indexOf(T);return h("div",{onMouseDown:(S)=>{S.preventDefault(),S.stopPropagation(),D(T)},onMouseEnter:()=>X(_),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:_===K?"var(--color-text-primary)":"var(--color-text-secondary)",background:_===K?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[h("span",{style:{fontWeight:500},children:T.slice(0,f.trim().length)},void 0,!1,void 0,this),T.slice(f.trim().length)]},T,!0,void 0,this)})]},H.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as F,Fragment as iy}from"react/jsx-dev-runtime";var s=0.2,fy=0.25,Ky=4;function uy({zoom:B,onZoomIn:y,onZoomOut:N,onZoomReset:J,onFullscreen:$}){return F("div",{className:"flex items-center gap-0.5 bg-bg-surface border border-border-subtle rounded-md px-1 py-0.5",style:{fontSize:"12px"},children:[F("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:N,title:"Zoom out",disabled:B<=fy,children:F("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:F("line",{x1:"5",y1:"12",x2:"19",y2:"12"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),F("button",{className:"px-1.5 h-7 rounded hover:bg-bg-elevated text-text-tertiary hover:text-text-primary transition-colors tabular-nums",onClick:J,title:"Reset zoom",children:[Math.round(B*100),"%"]},void 0,!0,void 0,this),F("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:y,title:"Zoom in",disabled:B>=Ky,children:F("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[F("line",{x1:"12",y1:"5",x2:"12",y2:"19"},void 0,!1,void 0,this),F("line",{x1:"5",y1:"12",x2:"19",y2:"12"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),$&&F(iy,{children:[F("div",{className:"w-px h-4 bg-border-subtle mx-0.5"},void 0,!1,void 0,this),F("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:$,title:"Fullscreen",children:F("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[F("polyline",{points:"15 3 21 3 21 9"},void 0,!1,void 0,this),F("polyline",{points:"9 21 3 21 3 15"},void 0,!1,void 0,this),F("line",{x1:"21",y1:"3",x2:"14",y2:"10"},void 0,!1,void 0,this),F("line",{x1:"3",y1:"21",x2:"10",y2:"14"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function ry(B=1){let[y,N]=o(B),J=x(()=>N((Y)=>Math.min(Ky,+(Y+s).toFixed(2))),[]),$=x(()=>N((Y)=>Math.max(fy,+(Y-s).toFixed(2))),[]),Q=x(()=>N(1),[]);return{zoom:y,zoomIn:J,zoomOut:$,zoomReset:Q,setZoom:N}}function o1({svgHtml:B,source:y,onClose:N}){let J=t(null),{zoom:$,zoomIn:Q,zoomOut:Y,zoomReset:f,setZoom:W}=ry(1),[K,X]=o({x:0,y:0}),b=t(null);vy(()=>{let Z=(A)=>{if(A.key==="Escape")N()};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[N]);let P=x((Z)=>{Z.preventDefault();let A=Z.deltaY>0?-s:s;W((w)=>Math.max(fy,Math.min(Ky,+(w+A).toFixed(2))))},[W]),U=x((Z)=>{if(Z.button!==0)return;b.current={startX:Z.clientX,startY:Z.clientY,panX:K.x,panY:K.y},Z.preventDefault()},[K]),L=x((Z)=>{if(!b.current)return;X({x:b.current.panX+(Z.clientX-b.current.startX),y:b.current.panY+(Z.clientY-b.current.startY)})},[]),q=x(()=>{b.current=null},[]),G=x(()=>{f(),X({x:0,y:0})},[f]);return a1.createPortal(F("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"var(--color-bg-base)",display:"flex",flexDirection:"column"},onMouseMove:L,onMouseUp:q,onMouseLeave:q,children:[F("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border-subtle",style:{flexShrink:0,background:"var(--color-bg-surface)"},children:[F("span",{className:"text-body text-text-secondary",style:{fontSize:"13px"},children:"Mermaid Diagram"},void 0,!1,void 0,this),F("div",{className:"flex items-center gap-2",children:[F(uy,{zoom:$,onZoomIn:Q,onZoomOut:Y,onZoomReset:G},void 0,!1,void 0,this),F("button",{className:"flex items-center justify-center w-8 h-8 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:N,title:"Close (Esc)",children:F("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[F("line",{x1:"18",y1:"6",x2:"6",y2:"18"},void 0,!1,void 0,this),F("line",{x1:"6",y1:"6",x2:"18",y2:"18"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),F("div",{style:{flex:1,overflow:"hidden",cursor:b.current?"grabbing":"grab"},onWheel:P,onMouseDown:U,children:F("div",{ref:J,style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",transform:`translate(${K.x}px, ${K.y}px) scale(${$})`,transformOrigin:"center center",transition:b.current?"none":"transform 0.1s ease-out"},dangerouslySetInnerHTML:{__html:B}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),document.body)}function s1({children:B}){let y=t(null),[N,J]=o(null),[$,Q]=o(!1),[Y,f]=o(""),W=typeof B==="string"?B:String(B??""),{annotations:K,addAnnotationWithId:X,activeAnnotationId:b,setActiveAnnotationId:P}=l1(),[U,L]=o(null),{zoom:q,zoomIn:G,zoomOut:Z,zoomReset:A,setZoom:w}=ry(1),C=t(K);C.current=K;let I=x((O,H,T)=>{let _=`[Diagram ${T.toLowerCase()}] ${H}`,S=C.current.find((Fy)=>Fy.snippet===_);if(S)P(S.id);else L({anchorEl:O,snippet:H,prefix:T})},[P]),z=t(I);z.current=I,vy(()=>{let O=!1,H=async()=>{try{let _=window.mermaid;if(!_){J("Mermaid library not loaded");return}let S=document.documentElement.dataset.theme==="light"?"default":"dark";_.initialize({startOnLoad:!1,theme:S});let Fy=`mermaid-${Math.random().toString(36).slice(2)}`,{svg:Sy}=await _.render(Fy,W.trim());if(!O&&y.current)y.current.innerHTML=Sy,f(Sy),n1(y.current,(T1,m1,M1)=>z.current(T1,m1,M1)),Ey(y.current,C.current);J(null)}catch(_){if(!O)J(_.message||"Invalid diagram")}};H();let T=new MutationObserver((_)=>{for(let S of _)if(S.attributeName==="data-theme")H()});return T.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{O=!0,T.disconnect()}},[W]),vy(()=>{if(y.current)Ey(y.current,K,b)},[K,b]);let g=x((O)=>{if(!O.ctrlKey&&!O.metaKey)return;O.preventDefault();let H=O.deltaY>0?-s:s;w((T)=>Math.max(fy,Math.min(Ky,+(T+H).toFixed(2))))},[w]);if(N)return F("div",{className:"bg-accent-red-muted rounded-md p-4 mt-3 text-body text-accent-red",children:["Mermaid error: ",N,F("pre",{className:"mt-2 text-tiny text-text-tertiary whitespace-pre-wrap",children:W},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let D=y.current?.closest("#plan-scroll-container");return F(iy,{children:[F("div",{className:"mt-3 mermaid-container","data-md":"mermaid","data-md-source":W.trim(),children:[F("div",{className:"flex justify-end mb-1",children:F(uy,{zoom:q,onZoomIn:G,onZoomOut:Z,onZoomReset:A,onFullscreen:()=>Q(!0)},void 0,!1,void 0,this)},void 0,!1,void 0,this),F("div",{style:{overflow:"auto",maxHeight:"70vh"},onWheel:g,children:F("div",{ref:y,className:"flex justify-center",style:{transform:`scale(${q})`,transformOrigin:"top center",transition:"transform 0.1s ease-out",minHeight:q<1?void 0:void 0}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U&&F(py,{anchorEl:U.anchorEl,scrollContainer:D,snippet:U.snippet,header:F("div",{style:{fontSize:"12px",color:"var(--color-text-tertiary)",marginBottom:"8px",lineHeight:"1.4",display:"flex",alignItems:"center",gap:"6px"},children:[F("span",{style:{width:"8px",height:"8px",borderRadius:"50%",background:"var(--color-accent-amber)",flexShrink:0}},void 0,!1,void 0,this),U.snippet]},void 0,!0,void 0,this),onAdd:(O)=>{let H=`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;X(H,`[Diagram ${U.prefix.toLowerCase()}] ${U.snippet}`,O),L(null)},onCancel:()=>L(null)},void 0,!1,void 0,this),$&&Y&&F(o1,{svgHtml:Y,source:W,onClose:()=>Q(!1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function n1(B,y){let N=(J,$,Q)=>{J.style.cursor="pointer",J.addEventListener("mouseenter",()=>{J.style.filter="brightness(1.2)"}),J.addEventListener("mouseleave",()=>{J.style.filter=""}),J.addEventListener("click",(Y)=>{Y.stopPropagation(),Y.preventDefault(),y(J,$(),Q)})};for(let J of B.querySelectorAll(".node"))N(J,()=>{return(J.querySelector(".nodeLabel")||J.querySelector("foreignObject span")||J.querySelector("text"))?.textContent?.trim()||"Node"},"Node");for(let J of B.querySelectorAll(".edgePath")){let $=J,Q=$.querySelector("path");if(Q){Q.style.strokeWidth=Math.max(parseFloat(Q.style.strokeWidth||"1"),8)+"px",Q.style.strokeOpacity="0";let f=Q.cloneNode(!0);f.style.strokeWidth="",f.style.strokeOpacity="",$.insertBefore(f,Q)}let Y=$.id||"";N($,()=>{let f=B.querySelectorAll(".edgeLabel");for(let W of f)if(W.id&&Y&&W.id.replace("label","").includes(Y.replace("L-","").replace("edge",""))){let K=W.textContent?.trim();if(K)return K}return"Connection"},"Edge")}for(let J of B.querySelectorAll(".edgeLabel")){let $=J.textContent?.trim();if(!$)continue;N(J,()=>$,"Edge")}for(let J of B.querySelectorAll(".actor")){let $=J.closest("g")?.querySelector("text")||J.parentElement?.querySelector("text");if(!$)continue;let Q=J.closest("g");if(!Q||Q.hasAttribute("data-clickable"))continue;Q.setAttribute("data-clickable","true"),N(Q,()=>$.textContent?.trim()||"Participant","Node")}for(let J of B.querySelectorAll(".messageText")){let $=J.textContent?.trim();if(!$)continue;N(J,()=>$,"Edge")}for(let J of B.querySelectorAll(".entityBox")){let $=J.closest("g");if(!$||$.hasAttribute("data-clickable"))continue;let Q=$.querySelector(".entityLabel");if(!Q)continue;$.setAttribute("data-clickable","true"),N($,()=>Q.textContent?.trim()||"Entity","Node")}for(let J of B.querySelectorAll(".relationshipLabel")){let $=J.textContent?.trim();if(!$)continue;let Y=J.closest("g")||J;if(Y.hasAttribute("data-clickable"))continue;Y.setAttribute("data-clickable","true"),N(Y,()=>$,"Edge")}for(let J of B.querySelectorAll(".classGroup")){let $=J;if($.hasAttribute("data-clickable"))continue;let Q=$.querySelector(".classTitle, .classTitleText, text");if(!Q)continue;$.setAttribute("data-clickable","true"),N($,()=>Q.textContent?.trim()||"Class","Node")}for(let J of B.querySelectorAll(".statediagram-state")){let $=J;if($.hasAttribute("data-clickable"))continue;let Q=$.querySelector(".state-title, text");if(!Q)continue;$.setAttribute("data-clickable","true"),N($,()=>Q.textContent?.trim()||"State","Node")}for(let J of B.querySelectorAll(".mindmap-node")){let $=J;if($.hasAttribute("data-clickable"))continue;let Q=$.querySelector(".mindmap-node-label, text");if(!Q)continue;$.setAttribute("data-clickable","true"),N($,()=>Q.textContent?.trim()||"Node","Node")}}function Ey(B,y,N){let J=new Map;for(let Q of y){let Y=Q.snippet.match(/^\[Diagram (?:node|edge)\] (.+)$/);if(Y)J.set(Y[1],Q.id)}for(let Q of B.querySelectorAll("[data-annotated]"))Q.style.outline="",Q.style.outlineOffset="",Q.style.borderRadius="",Q.removeAttribute("data-annotated");if(J.size===0)return;for(let Q of B.querySelectorAll(".node")){let f=(Q.querySelector(".nodeLabel")||Q.querySelector("foreignObject span")||Q.querySelector("text"))?.textContent?.trim();if(!f||!J.has(f))continue;let W=J.get(f),K=Q;K.setAttribute("data-annotated",W);let X=W===N;K.style.outline=X?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",K.style.outlineOffset="2px",K.style.borderRadius="4px"}for(let Q of B.querySelectorAll(".edgeLabel")){let Y=Q.textContent?.trim();if(!Y||!J.has(Y))continue;let f=J.get(Y),W=Q;W.setAttribute("data-annotated",f);let K=f===N;W.style.outline=K?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",W.style.outlineOffset="2px",W.style.borderRadius="4px"}for(let Q of B.querySelectorAll(".actor")){let Y=Q.closest("g");if(!Y)continue;let W=Y.querySelector("text")?.textContent?.trim();if(!W||!J.has(W))continue;if(Y.hasAttribute("data-annotated"))continue;let K=J.get(W);Y.setAttribute("data-annotated",K);let X=K===N,b=Y.querySelector("rect");if(b)b.style.outline=X?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",b.style.outlineOffset="2px",b.style.borderRadius="4px"}for(let Q of B.querySelectorAll(".messageText")){let Y=Q.textContent?.trim();if(!Y||!J.has(Y))continue;let f=J.get(Y),W=Q;W.setAttribute("data-annotated",f);let K=f===N;W.style.outline=K?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",W.style.outlineOffset="2px",W.style.borderRadius="4px"}let $=(Q,Y,f)=>{for(let W of B.querySelectorAll(Q)){let K=f(W);if(!K||K.hasAttribute("data-annotated"))continue;let b=K.querySelector(Y)?.textContent?.trim();if(!b||!J.has(b))continue;let P=J.get(b);K.setAttribute("data-annotated",P);let U=P===N,L=K.querySelector("rect, circle, ellipse, polygon")||K;L.style.outline=U?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",L.style.outlineOffset="2px",L.style.borderRadius="4px"}};$(".entityBox",".entityLabel",(Q)=>Q.closest("g"));for(let Q of B.querySelectorAll(".relationshipLabel")){let f=Q.closest("g")||Q;if(f.hasAttribute("data-annotated"))continue;let W=Q.textContent?.trim();if(!W||!J.has(W))continue;let K=J.get(W);f.setAttribute("data-annotated",K);let X=K===N;f.style.outline=X?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",f.style.outlineOffset="2px",f.style.borderRadius="4px"}$(".classGroup",".classTitle, .classTitleText, text",(Q)=>Q),$(".statediagram-state",".state-title, text",(Q)=>Q),$(".mindmap-node",".mindmap-node-label, text",(Q)=>Q)}import{jsxDEV as e}from"react/jsx-dev-runtime";function t1({before:B,after:y,language:N}){let J=B.split(`
3
+ `);W(T),X(q.language||"text")}}).catch(()=>N("Failed to fetch file")).finally(()=>H(!1))},[Y,J,y?.[0],y?.[1],Q]),n1(()=>{let q=b.current,T=window.hljs;if(!q||!T||!B)return;q.removeAttribute("data-highlighted"),q.className=K?`language-${K}`:"",q.textContent=B,T.highlightElement(q)},[B,K]),G)return y1("div",{className:"text-text-tertiary text-body mt-3 bg-bg-code rounded-md p-4",children:["Loading ",J,"..."]},void 0,!0,void 0,this);if(L)return y1("div",{className:"text-accent-red text-body mt-3 bg-accent-red-muted rounded-md p-4",children:[J,": ",L]},void 0,!0,void 0,this);return y1("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden","data-md":"filepreview","data-md-path":J,...y?{"data-md-lines":`${y[0]}-${y[1]}`}:{},children:[y1("div",{className:"px-4 py-2 flex items-center justify-between",children:[y1("button",{className:"font-mono text-meta text-text-tertiary hover:text-text-secondary hover:underline cursor-pointer text-left",onClick:()=>$({type:"file",path:J}),title:`Open ${J}`,children:J},void 0,!1,void 0,this),y&&y1("span",{className:"font-mono text-meta text-text-tertiary opacity-60",children:["L",y[0],"–",y[1]]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),y1("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono !bg-transparent",style:{background:"transparent"},children:y1("code",{ref:b,className:K?`language-${K}`:"",children:B},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as D1,useRef as U1,useState as K1,useCallback as l}from"react";import Hy from"react-dom";import{useAnnotations as Py}from"#canvas/runtime";import{useEffect as Y0,useRef as A1,useState as G1,useCallback as M1,useMemo as J0,useContext as Ky}from"react";import{createPortal as Ly}from"react-dom";function e1(J,y){let $=y||document.body,B=J.getBoundingClientRect(),W=$.getBoundingClientRect(),K=$===document.body?window.scrollY:$.scrollTop,X=B.bottom-W.top+K+8,L=Math.max(0,Math.min(B.left-W.left,W.width-280-12));return $.style.position="relative",{style:{position:"absolute",top:`${X}px`,left:`${L}px`},parent:$}}import{useState as j1,useRef as V1,useCallback as n,useEffect as y0}from"react";function Q1(J,y){J.style.height="auto",J.style.height=(y?Math.max(y,J.scrollHeight):J.scrollHeight)+"px"}import{jsxDEV as g}from"react/jsx-dev-runtime";function Wy(J){return`/api/uploads/${J.split("/").pop()}`}async function Xy(J,y){let Q=new FormData;Q.append("image",y);try{return(await(await fetch(`/api/session/${J}/upload`,{method:"POST",body:Q})).json()).path||null}catch{return null}}function $0({note:J,onNoteChange:y,images:Q,onAddImage:Y,onRemoveImage:$,sessionId:B,placeholder:W="Add your note...",autoFocus:K=!1,autoResize:X=!1,readOnly:L=!1,onKeyDown:N,onTextareaClick:G,textareaRef:H,textareaClassName:b,textareaStyle:q,minHeight:T,attachButton:P="always",openFilePickerRef:v}){let[A,O]=j1(!1),[c,V]=j1(!1),[k,D]=j1(!1),S=V1(0),f=V1(null),h=V1(null),I=n(()=>h.current?.click(),[]);y0(()=>{if(v)v.current=I},[v,I]);let p=n((U)=>{if(f.current=U,H)H.current=U;if(U&&X)Q1(U,T)},[H,X,T]);y0(()=>{if(K&&f.current){let U=f.current;if(U.focus(),U.value)U.setSelectionRange(U.value.length,U.value.length)}},[K]);let x=n(async(U)=>{if(!U.type.startsWith("image/"))return;V(!0);try{let Z=await Xy(B,U);if(Z)Y(Z)}finally{V(!1)}},[B,Y]),t=n((U)=>{let Z=U.clipboardData.items;for(let C of Z)if(C.type.startsWith("image/")){U.preventDefault();let s=C.getAsFile();if(s)x(s);return}},[x]),m=n((U)=>{if(U.preventDefault(),S.current++,S.current===1)O(!0)},[]),E=n((U)=>{U.preventDefault()},[]),d=n((U)=>{if(U.preventDefault(),S.current--,S.current===0)O(!1)},[]),o=n((U)=>{U.preventDefault(),S.current=0,O(!1);for(let Z of U.dataTransfer.files)if(Z.type.startsWith("image/"))x(Z)},[x]),$1=n((U)=>{if(y(U.target.value),X)U.target.style.height="auto",U.target.style.height=(T?Math.max(T,U.target.scrollHeight):U.target.scrollHeight)+"px"},[y,X,T]),q1="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",h1={width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",outline:"none",...X?{resize:"none",overflow:"hidden"}:{resize:"vertical"}},v1=!L&&(P==="always"||P==="on-focus"&&k);return g("div",{style:{position:"relative"},onDragEnter:L?void 0:m,onDragOver:L?void 0:E,onDragLeave:L?void 0:d,onDrop:L?void 0:o,children:[g("textarea",{ref:p,value:J,onChange:L?void 0:$1,onPaste:L?void 0:t,onKeyDown:N,onClick:G,onFocus:()=>D(!0),onBlur:()=>{setTimeout(()=>D(!1),150)},readOnly:L,placeholder:W,className:b??q1,style:q??h1,rows:X?1:void 0},void 0,!1,void 0,this),!L&&g("input",{ref:h,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:(U)=>{let Z=U.target.files;if(Z)for(let C of Z)x(C);U.target.value=""}},void 0,!1,void 0,this),(Q.length>0||v1)&&g("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[Q.map((U)=>g("div",{style:{position:"relative",width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:[g("img",{src:Wy(U),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!L&&g("button",{onClick:(Z)=>{Z.stopPropagation(),$(U)},style:{position:"absolute",top:"2px",right:"2px",width:"16px",height:"16px",borderRadius:"50%",background:"rgba(0,0,0,0.6)",color:"white",border:"none",cursor:"pointer",fontSize:"11px",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0},title:"Remove image",children:"×"},void 0,!1,void 0,this)]},U,!0,void 0,this)),v1&&g(x1,{onClick:I},void 0,!1,void 0,this)]},void 0,!0,void 0,this),c&&g("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),A&&g("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-highlight-bg)",opacity:0.9,border:"2px dashed var(--color-highlight-border)",borderRadius:"6px",zIndex:10,pointerEvents:"none",fontSize:"12px",fontFamily:"'Inter', sans-serif",color:"var(--color-text-secondary)"},children:"Drop image"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function x1({onClick:J,size:y=16}){return g("button",{onClick:(Q)=>{Q.stopPropagation(),J()},style:{width:`${y*2}px`,height:`${y*2}px`,borderRadius:"6px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-tertiary)",flexShrink:0,transition:"color 0.15s"},title:"Attach image",onMouseEnter:(Q)=>{Q.currentTarget.style.color="var(--color-text-secondary)"},onMouseLeave:(Q)=>{Q.currentTarget.style.color="var(--color-text-tertiary)"},children:g("svg",{width:y,height:y,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[g("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},void 0,!1,void 0,this),g("circle",{cx:"8.5",cy:"8.5",r:"1.5"},void 0,!1,void 0,this),g("polyline",{points:"21 15 16 10 5 21"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{SessionContext as Ny}from"#canvas/runtime";import{jsxDEV as R,Fragment as Uy}from"react/jsx-dev-runtime";function qy({anchorEl:J,scrollContainer:y,onClose:Q,ignoreSelector:Y,zIndex:$="50",padding:B="12px",width:W="280px",children:K}){let X=A1(null),L=A1(Q);L.current=Q;let{style:N,parent:G}=e1(J,y);return Y0(()=>{let H=setTimeout(()=>{let b=(q)=>{if(X.current&&!X.current.contains(q.target)){if(Y&&q.target.closest?.(Y))return;L.current(),document.removeEventListener("mousedown",b)}};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},0);return()=>clearTimeout(H)},[Y]),Ly(R("div",{ref:X,style:{...N,zIndex:$,width:W,background:"var(--color-bg-elevated)",border:"1px solid var(--color-border-hover)",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",padding:B,fontFamily:"'Inter', sans-serif"},children:K},void 0,!1,void 0,this),G)}var B0=[{label:"Clarity",items:["Unclear","Why?","Needs example","Missing context"]},{label:"Scope",items:["Overkill","Out of scope","Important","Risky"]},{label:"Action",items:["Simplify","Rethink","Expand on this","Skip this"]}],Q0=B0.flatMap((J)=>J.items);function Gy({anchorEl:J,scrollContainer:y,snippet:Q,truncateAt:Y=100,header:$,initialNote:B="",initialImages:W,onConfirm:K,onCancel:X,onDelete:L}){let N=Ky(Ny),G=B!==""||!!L,[H,b]=G1(B),[q,T]=G1(W||[]),[P,v]=G1(null),[A,O]=G1(G),[c,V]=G1(!1),k=A1(null),D=A1(null),S=M1(()=>{if(H.trim()||q.length>0)K(H.trim(),q);else if(G&&L)L();else X()},[H,q,K,X,G,L]),f=M1(()=>{if(G){if(!H.trim()&&q.length===0&&L){L(),X();return}K(H,q);return}X()},[H,q,G,K,X,L]),h=!G,I=H.trim().length>0?Q0.filter((U)=>U.toLowerCase().startsWith(H.trim().toLowerCase())):Q0,p=!h||A?[]:I.length===1&&I[0].toLowerCase()===H.trim().toLowerCase()?[]:I,x=new Set(p),t=B0.map((U)=>({label:U.label,items:U.items.filter((Z)=>x.has(Z))})).filter((U)=>U.items.length>0),m=t.map((U)=>U.items),E=m.flat(),d=J0(()=>{if(P===null)return 0;let U=0;for(let Z=0;Z<m.length;Z++){if(P<U+m[Z].length)return Z;U+=m[Z].length}return 0},[P,m]),o=J0(()=>{if(P===null)return 0;let U=0;for(let Z=0;Z<d;Z++)U+=m[Z].length;return P-U},[P,d,m]),$1=(U,Z)=>{let C=0;for(let s=0;s<U;s++)C+=m[s].length;return C+Z};Y0(()=>{v(null),O(G)},[H]);let q1=M1((U)=>{b(U)},[]),h1=Q.length>Y?Q.slice(0,Y)+"...":Q,v1=M1((U)=>{if(E.length>0&&(U.key==="ArrowDown"||U.key==="ArrowUp"||U.key==="ArrowLeft"||U.key==="ArrowRight")){if(U.preventDefault(),P===null){v(0);return}if(U.key==="ArrowDown"){let Z=Math.min(o+1,m[d].length-1);v($1(d,Z))}else if(U.key==="ArrowUp"){let Z=Math.max(o-1,0);v($1(d,Z))}else if(U.key==="ArrowRight"){let Z=Math.min(d+1,m.length-1),C=Math.min(o,m[Z].length-1);v($1(Z,C))}else if(U.key==="ArrowLeft"){let Z=Math.max(d-1,0),C=Math.min(o,m[Z].length-1);v($1(Z,C))}return}if(P!==null&&E.length>0){if(U.key==="Tab"){U.preventDefault(),q1(E[P]);return}if(U.key==="Enter"&&!U.shiftKey){U.preventDefault(),K(E[P],q);return}}if(U.key==="Enter"&&!U.shiftKey){U.preventDefault(),S();return}if(U.key==="Escape")if(E.length>0&&!A)O(!0);else if(G)f();else X()},[E,P,o,d,m,$1,q1,K,q,S,A,G,f,X]);return R(qy,{anchorEl:J,scrollContainer:y,onClose:G?f:X,ignoreSelector:G?"[data-annotation-id]":void 0,zIndex:G?"60":"50",padding:G?"10px 12px":"12px",width:"420px",children:[!G&&($??R("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontStyle:"italic",marginBottom:"8px",lineHeight:"1.4",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:["“",h1,"”"]},void 0,!0,void 0,this)),R($0,{note:H,onNoteChange:b,images:q,onAddImage:(U)=>T((Z)=>[...Z,U]),onRemoveImage:(U)=>T((Z)=>Z.filter((C)=>C!==U)),sessionId:N,autoFocus:!0,autoResize:G,textareaRef:k,onKeyDown:v1,attachButton:"none",openFilePickerRef:D,textareaStyle:G?{width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",resize:"none",outline:"none",overflow:"hidden"}:{width:"100%",minHeight:"60px",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",resize:"vertical",outline:"none"},placeholder:"Add your note..."},void 0,!1,void 0,this),R("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:G?"6px":"8px"},children:[R(x1,{onClick:()=>D.current?.(),size:14},void 0,!1,void 0,this),R("div",{style:{flex:1}},void 0,!1,void 0,this),G?R("button",{onClick:()=>{if(L)L();X()},onMouseEnter:()=>V(!0),onMouseLeave:()=>V(!1),style:{fontSize:"11px",color:c?"var(--color-accent-red)":"var(--color-text-tertiary)",background:"none",border:"none",cursor:"pointer",padding:"2px 0",fontFamily:"'Inter', sans-serif"},children:"Delete"},void 0,!1,void 0,this):R(Uy,{children:[R("button",{onClick:X,style:{fontSize:"11px",color:"var(--color-text-tertiary)",background:"none",border:"none",cursor:"pointer",padding:"4px 12px",fontFamily:"'Inter', sans-serif"},children:"Cancel"},void 0,!1,void 0,this),R("button",{onClick:S,style:{fontSize:"11px",fontWeight:500,padding:"4px 12px",borderRadius:"6px",background:"var(--color-highlight-bg)",color:"var(--color-text-primary)",border:"1px solid var(--color-highlight-border)",cursor:"pointer",fontFamily:"'Inter', sans-serif"},children:"Add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),E.length>0&&R("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:t.map((U)=>R("div",{style:{flex:1},children:[R("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--color-text-disabled)",textTransform:"uppercase",letterSpacing:"0.05em",padding:"2px 6px",marginBottom:"2px",fontFamily:"'Inter', sans-serif"},children:U.label},void 0,!1,void 0,this),U.items.map((Z)=>{let C=E.indexOf(Z);return R("div",{onMouseDown:(s)=>{s.preventDefault(),s.stopPropagation(),q1(Z)},onMouseEnter:()=>v(C),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:C===P?"var(--color-text-primary)":"var(--color-text-secondary)",background:C===P?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[R("span",{style:{fontWeight:500},children:Z.slice(0,H.trim().length)},void 0,!1,void 0,this),Z.slice(H.trim().length)]},Z,!0,void 0,this)})]},U.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function W0({anchorEl:J,scrollContainer:y,snippet:Q,truncateAt:Y,header:$,onAdd:B,onCancel:W}){return R(Gy,{anchorEl:J,scrollContainer:y,snippet:Q,truncateAt:Y,header:$,onConfirm:(K,X)=>B(K,X),onCancel:W},void 0,!1,void 0,this)}import{jsxDEV as F,Fragment as N0}from"react/jsx-dev-runtime";var L1=0.2,f1=0.25,z1=4;function K0({zoom:J,onZoomIn:y,onZoomOut:Q,onZoomReset:Y,onFullscreen:$}){return F("div",{className:"flex items-center gap-0.5 bg-bg-surface border border-border-subtle rounded-md px-1 py-0.5",style:{fontSize:"12px"},children:[F("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:Q,title:"Zoom out",disabled:J<=f1,children:F("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:F("line",{x1:"5",y1:"12",x2:"19",y2:"12"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),F("button",{className:"px-1.5 h-7 rounded hover:bg-bg-elevated text-text-tertiary hover:text-text-primary transition-colors tabular-nums",onClick:Y,title:"Reset zoom",children:[Math.round(J*100),"%"]},void 0,!0,void 0,this),F("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:y,title:"Zoom in",disabled:J>=z1,children:F("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[F("line",{x1:"12",y1:"5",x2:"12",y2:"19"},void 0,!1,void 0,this),F("line",{x1:"5",y1:"12",x2:"19",y2:"12"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),$&&F(N0,{children:[F("div",{className:"w-px h-4 bg-border-subtle mx-0.5"},void 0,!1,void 0,this),F("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:$,title:"Fullscreen",children:F("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[F("polyline",{points:"15 3 21 3 21 9"},void 0,!1,void 0,this),F("polyline",{points:"9 21 3 21 3 15"},void 0,!1,void 0,this),F("line",{x1:"21",y1:"3",x2:"14",y2:"10"},void 0,!1,void 0,this),F("line",{x1:"3",y1:"21",x2:"10",y2:"14"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function L0(J=1){let[y,Q]=K1(J),Y=l(()=>Q((W)=>Math.min(z1,+(W+L1).toFixed(2))),[]),$=l(()=>Q((W)=>Math.max(f1,+(W-L1).toFixed(2))),[]),B=l(()=>Q(1),[]);return{zoom:y,zoomIn:Y,zoomOut:$,zoomReset:B,setZoom:Q}}function by({svgHtml:J,source:y,onClose:Q}){let Y=U1(null),{zoom:$,zoomIn:B,zoomOut:W,zoomReset:K,setZoom:X}=L0(1),[L,N]=K1({x:0,y:0}),G=U1(null);D1(()=>{let v=(A)=>{if(A.key==="Escape")Q()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[Q]);let H=l((v)=>{v.preventDefault();let A=v.deltaY>0?-L1:L1;X((O)=>Math.max(f1,Math.min(z1,+(O+A).toFixed(2))))},[X]),b=l((v)=>{if(v.button!==0)return;G.current={startX:v.clientX,startY:v.clientY,panX:L.x,panY:L.y},v.preventDefault()},[L]),q=l((v)=>{if(!G.current)return;N({x:G.current.panX+(v.clientX-G.current.startX),y:G.current.panY+(v.clientY-G.current.startY)})},[]),T=l(()=>{G.current=null},[]),P=l(()=>{K(),N({x:0,y:0})},[K]);return Hy.createPortal(F("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"var(--color-bg-base)",display:"flex",flexDirection:"column"},onMouseMove:q,onMouseUp:T,onMouseLeave:T,children:[F("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border-subtle",style:{flexShrink:0,background:"var(--color-bg-surface)"},children:[F("span",{className:"text-body text-text-secondary",style:{fontSize:"13px"},children:"Mermaid Diagram"},void 0,!1,void 0,this),F("div",{className:"flex items-center gap-2",children:[F(K0,{zoom:$,onZoomIn:B,onZoomOut:W,onZoomReset:P},void 0,!1,void 0,this),F("button",{className:"flex items-center justify-center w-8 h-8 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:Q,title:"Close (Esc)",children:F("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[F("line",{x1:"18",y1:"6",x2:"6",y2:"18"},void 0,!1,void 0,this),F("line",{x1:"6",y1:"6",x2:"18",y2:"18"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),F("div",{style:{flex:1,overflow:"hidden",cursor:G.current?"grabbing":"grab"},onWheel:H,onMouseDown:b,children:F("div",{ref:Y,style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",transform:`translate(${L.x}px, ${L.y}px) scale(${$})`,transformOrigin:"center center",transition:G.current?"none":"transform 0.1s ease-out"},dangerouslySetInnerHTML:{__html:J}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),document.body)}function Ty({children:J}){let y=U1(null),[Q,Y]=K1(null),[$,B]=K1(!1),[W,K]=K1(""),X=typeof J==="string"?J:String(J??""),{annotations:L,addAnnotationWithId:N,activeAnnotationId:G,setActiveAnnotationId:H}=Py(),[b,q]=K1(null),{zoom:T,zoomIn:P,zoomOut:v,zoomReset:A,setZoom:O}=L0(1),c=U1(L);c.current=L;let V=l((f,h,I)=>{let p=`[Diagram ${I.toLowerCase()}] ${h}`,x=c.current.find((t)=>t.snippet===p);if(x)H(x.id);else q({anchorEl:f,snippet:h,prefix:I})},[H]),k=U1(V);k.current=V,D1(()=>{let f=!1,h=async()=>{try{let p=window.mermaid;if(!p){Y("Mermaid library not loaded");return}let x=document.documentElement.dataset.theme==="light"?"default":"dark";p.initialize({startOnLoad:!1,theme:x});let t=`mermaid-${Math.random().toString(36).slice(2)}`,{svg:m}=await p.render(t,X.trim());if(!f&&y.current)y.current.innerHTML=m,K(m),Zy(y.current,(E,d,o)=>k.current(E,d,o)),X0(y.current,c.current);Y(null)}catch(p){if(!f)Y(p.message||"Invalid diagram")}};h();let I=new MutationObserver((p)=>{for(let x of p)if(x.attributeName==="data-theme")h()});return I.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{f=!0,I.disconnect()}},[X]),D1(()=>{if(y.current)X0(y.current,L,G)},[L,G]);let D=l((f)=>{if(!f.ctrlKey&&!f.metaKey)return;f.preventDefault();let h=f.deltaY>0?-L1:L1;O((I)=>Math.max(f1,Math.min(z1,+(I+h).toFixed(2))))},[O]);if(Q)return F("div",{className:"bg-accent-red-muted rounded-md p-4 mt-3 text-body text-accent-red",children:["Mermaid error: ",Q,F("pre",{className:"mt-2 text-tiny text-text-tertiary whitespace-pre-wrap",children:X},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let S=y.current?.closest("#plan-scroll-container");return F(N0,{children:[F("div",{className:"mt-3 mermaid-container","data-md":"mermaid","data-md-source":X.trim(),children:[F("div",{className:"flex justify-end mb-1",children:F(K0,{zoom:T,onZoomIn:P,onZoomOut:v,onZoomReset:A,onFullscreen:()=>B(!0)},void 0,!1,void 0,this)},void 0,!1,void 0,this),F("div",{style:{overflow:"auto",maxHeight:"70vh"},onWheel:D,children:F("div",{ref:y,className:"flex justify-center",style:{transform:`scale(${T})`,transformOrigin:"top center",transition:"transform 0.1s ease-out",minHeight:T<1?void 0:void 0}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b&&F(W0,{anchorEl:b.anchorEl,scrollContainer:S,snippet:b.snippet,header:F("div",{style:{fontSize:"12px",color:"var(--color-text-tertiary)",marginBottom:"8px",lineHeight:"1.4",display:"flex",alignItems:"center",gap:"6px"},children:[F("span",{style:{width:"8px",height:"8px",borderRadius:"50%",background:"var(--color-accent-amber)",flexShrink:0}},void 0,!1,void 0,this),b.snippet]},void 0,!0,void 0,this),onAdd:(f,h)=>{let I=`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;N(I,`[Diagram ${b.prefix.toLowerCase()}] ${b.snippet}`,f,void 0,void 0,h),q(null)},onCancel:()=>q(null)},void 0,!1,void 0,this),$&&W&&F(by,{svgHtml:W,source:X,onClose:()=>B(!1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Zy(J,y){let Q=(Y,$,B)=>{Y.style.cursor="pointer",Y.addEventListener("mouseenter",()=>{Y.style.filter="brightness(1.2)"}),Y.addEventListener("mouseleave",()=>{Y.style.filter=""}),Y.addEventListener("click",(W)=>{W.stopPropagation(),W.preventDefault(),y(Y,$(),B)})};for(let Y of J.querySelectorAll(".node"))Q(Y,()=>{return(Y.querySelector(".nodeLabel")||Y.querySelector("foreignObject span")||Y.querySelector("text"))?.textContent?.trim()||"Node"},"Node");for(let Y of J.querySelectorAll(".edgePath")){let $=Y,B=$.querySelector("path");if(B){B.style.strokeWidth=Math.max(parseFloat(B.style.strokeWidth||"1"),8)+"px",B.style.strokeOpacity="0";let K=B.cloneNode(!0);K.style.strokeWidth="",K.style.strokeOpacity="",$.insertBefore(K,B)}let W=$.id||"";Q($,()=>{let K=J.querySelectorAll(".edgeLabel");for(let X of K)if(X.id&&W&&X.id.replace("label","").includes(W.replace("L-","").replace("edge",""))){let L=X.textContent?.trim();if(L)return L}return"Connection"},"Edge")}for(let Y of J.querySelectorAll(".edgeLabel")){let $=Y.textContent?.trim();if(!$)continue;Q(Y,()=>$,"Edge")}for(let Y of J.querySelectorAll(".actor")){let $=Y.closest("g")?.querySelector("text")||Y.parentElement?.querySelector("text");if(!$)continue;let B=Y.closest("g");if(!B||B.hasAttribute("data-clickable"))continue;B.setAttribute("data-clickable","true"),Q(B,()=>$.textContent?.trim()||"Participant","Node")}for(let Y of J.querySelectorAll(".messageText")){let $=Y.textContent?.trim();if(!$)continue;Q(Y,()=>$,"Edge")}for(let Y of J.querySelectorAll(".entityBox")){let $=Y.closest("g");if(!$||$.hasAttribute("data-clickable"))continue;let B=$.querySelector(".entityLabel");if(!B)continue;$.setAttribute("data-clickable","true"),Q($,()=>B.textContent?.trim()||"Entity","Node")}for(let Y of J.querySelectorAll(".relationshipLabel")){let $=Y.textContent?.trim();if(!$)continue;let W=Y.closest("g")||Y;if(W.hasAttribute("data-clickable"))continue;W.setAttribute("data-clickable","true"),Q(W,()=>$,"Edge")}for(let Y of J.querySelectorAll(".classGroup")){let $=Y;if($.hasAttribute("data-clickable"))continue;let B=$.querySelector(".classTitle, .classTitleText, text");if(!B)continue;$.setAttribute("data-clickable","true"),Q($,()=>B.textContent?.trim()||"Class","Node")}for(let Y of J.querySelectorAll(".statediagram-state")){let $=Y;if($.hasAttribute("data-clickable"))continue;let B=$.querySelector(".state-title, text");if(!B)continue;$.setAttribute("data-clickable","true"),Q($,()=>B.textContent?.trim()||"State","Node")}for(let Y of J.querySelectorAll(".mindmap-node")){let $=Y;if($.hasAttribute("data-clickable"))continue;let B=$.querySelector(".mindmap-node-label, text");if(!B)continue;$.setAttribute("data-clickable","true"),Q($,()=>B.textContent?.trim()||"Node","Node")}}function X0(J,y,Q){let Y=new Map;for(let B of y){let W=B.snippet.match(/^\[Diagram (?:node|edge)\] (.+)$/);if(W)Y.set(W[1],B.id)}for(let B of J.querySelectorAll("[data-annotated]"))B.style.outline="",B.style.outlineOffset="",B.style.borderRadius="",B.removeAttribute("data-annotated");if(Y.size===0)return;for(let B of J.querySelectorAll(".node")){let K=(B.querySelector(".nodeLabel")||B.querySelector("foreignObject span")||B.querySelector("text"))?.textContent?.trim();if(!K||!Y.has(K))continue;let X=Y.get(K),L=B;L.setAttribute("data-annotated",X);let N=X===Q;L.style.outline=N?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",L.style.outlineOffset="2px",L.style.borderRadius="4px"}for(let B of J.querySelectorAll(".edgeLabel")){let W=B.textContent?.trim();if(!W||!Y.has(W))continue;let K=Y.get(W),X=B;X.setAttribute("data-annotated",K);let L=K===Q;X.style.outline=L?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",X.style.outlineOffset="2px",X.style.borderRadius="4px"}for(let B of J.querySelectorAll(".actor")){let W=B.closest("g");if(!W)continue;let X=W.querySelector("text")?.textContent?.trim();if(!X||!Y.has(X))continue;if(W.hasAttribute("data-annotated"))continue;let L=Y.get(X);W.setAttribute("data-annotated",L);let N=L===Q,G=W.querySelector("rect");if(G)G.style.outline=N?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",G.style.outlineOffset="2px",G.style.borderRadius="4px"}for(let B of J.querySelectorAll(".messageText")){let W=B.textContent?.trim();if(!W||!Y.has(W))continue;let K=Y.get(W),X=B;X.setAttribute("data-annotated",K);let L=K===Q;X.style.outline=L?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",X.style.outlineOffset="2px",X.style.borderRadius="4px"}let $=(B,W,K)=>{for(let X of J.querySelectorAll(B)){let L=K(X);if(!L||L.hasAttribute("data-annotated"))continue;let G=L.querySelector(W)?.textContent?.trim();if(!G||!Y.has(G))continue;let H=Y.get(G);L.setAttribute("data-annotated",H);let b=H===Q,q=L.querySelector("rect, circle, ellipse, polygon")||L;q.style.outline=b?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",q.style.outlineOffset="2px",q.style.borderRadius="4px"}};$(".entityBox",".entityLabel",(B)=>B.closest("g"));for(let B of J.querySelectorAll(".relationshipLabel")){let K=B.closest("g")||B;if(K.hasAttribute("data-annotated"))continue;let X=B.textContent?.trim();if(!X||!Y.has(X))continue;let L=Y.get(X);K.setAttribute("data-annotated",L);let N=L===Q;K.style.outline=N?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",K.style.outlineOffset="2px",K.style.borderRadius="4px"}$(".classGroup",".classTitle, .classTitleText, text",(B)=>B),$(".statediagram-state",".state-title, text",(B)=>B),$(".mindmap-node",".mindmap-node-label, text",(B)=>B)}import{jsxDEV as H1}from"react/jsx-dev-runtime";function Fy({before:J,after:y,language:Q}){let Y=J.split(`
4
4
  `),$=y.split(`
5
- `),Q=e1(J,$),Y=[],f=0,W=0,K=0;while(f<J.length||W<$.length)if(K<Q.length&&f<J.length&&W<$.length&&J[f]===Q[K]&&$[W]===Q[K])Y.push({type:"same",line:J[f]}),f++,W++,K++;else if(f<J.length&&(K>=Q.length||J[f]!==Q[K]))Y.push({type:"removed",line:J[f]}),f++;else if(W<$.length)Y.push({type:"added",line:$[W]}),W++;return e("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden group/diff","data-md":"diff","data-md-language":N||"",children:[N&&e("div",{className:"px-4 py-2 text-meta font-mono text-text-tertiary opacity-0 group-hover/diff:opacity-60 transition-opacity",children:["diff (",N,")"]},void 0,!0,void 0,this),e("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono",children:Y.map((X,b)=>e("div",{className:X.type==="removed"?"bg-accent-red-muted text-accent-red":X.type==="added"?"bg-accent-green-muted text-accent-green":"text-text-tertiary",children:[e("span",{className:"select-none w-6 inline-block text-center opacity-60",children:X.type==="removed"?"-":X.type==="added"?"+":" "},void 0,!1,void 0,this),X.line]},b,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function e1(B,y){let N=B.length,J=y.length,$=Array.from({length:N+1},()=>Array(J+1).fill(0));for(let W=1;W<=N;W++)for(let K=1;K<=J;K++)$[W][K]=B[W-1]===y[K-1]?$[W-1][K-1]+1:Math.max($[W-1][K],$[W][K-1]);let Q=[],Y=N,f=J;while(Y>0&&f>0)if(B[Y-1]===y[f-1])Q.unshift(B[Y-1]),Y--,f--;else if($[Y-1][f]>$[Y][f-1])Y--;else f--;return Q}import{useEffect as Xy,useRef as ly,useState as oy}from"react";import{useAnnotations as sy}from"#canvas/runtime";function yy(B,y){B.style.height="auto",B.style.height=(y?Math.max(y,B.scrollHeight):B.scrollHeight)+"px"}import{jsxDEV as ay}from"react/jsx-dev-runtime";function n({note:B,onChange:y}){return ay("div",{className:"mt-1.5",children:ay("textarea",{value:B,onChange:(N)=>y(N.target.value),className:"w-full bg-transparent text-[12px] font-body text-text-primary resize-none focus:outline-none border-none placeholder:text-text-disabled transition-colors min-h-[20px] p-0 leading-relaxed",placeholder:"Add a note...",rows:1,onInput:(N)=>yy(N.target),ref:(N)=>{if(N)yy(N)}},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as k}from"react/jsx-dev-runtime";function y0({id:B,label:y,options:N,required:J}){let{responses:$,setResponse:Q}=sy(),Y=$.get(B),f=Y?.value,W=Y?.note||"",[K,X]=oy(!1),b=ly(null);Xy(()=>{if(!$.has(B))Q(B,{id:B,type:"radio",label:y,value:null,options:N,required:J})},[B]);let P=(L)=>{Q(B,{...Y,value:L})};Xy(()=>{let L=b.current;if(!L)return;let q=(G)=>{let A=G.target.closest("[data-md-label]")?.getAttribute("data-md-label");if(A&&N.includes(A))P(A)};return L.addEventListener("kb-select",q),()=>L.removeEventListener("kb-select",q)});let U=Y?.required&&!f;return k("div",{ref:b,"data-md":"choice","data-md-label":y,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[k("div",{className:"flex items-baseline gap-2 mb-2",children:[k("span",{className:"text-[13px] font-body font-medium text-text-primary",children:y},void 0,!1,void 0,this),J&&k("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),k("div",{className:"space-y-1",children:N.map((L)=>k("label",{"data-md":"choice-option","data-md-label":L,onClick:()=>P(L),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${f===L?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[k("span",{className:`w-4 h-4 rounded-full border-[1.5px] flex items-center justify-center flex-shrink-0 transition-all ${f===L?"border-accent-amber bg-accent-amber":"border-border-strong"}`,children:f===L&&k("span",{className:"w-1.5 h-1.5 rounded-full bg-text-inverse"},void 0,!1,void 0,this)},void 0,!1,void 0,this),k("span",{className:"text-[13px] font-body text-text-secondary",children:L},void 0,!1,void 0,this)]},L,!0,void 0,this))},void 0,!1,void 0,this),k(n,{show:K,note:W,onToggle:()=>X(!K),onChange:(L)=>Q(B,{...Y,note:L})},void 0,!1,void 0,this),U&&k("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select an option."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function $0({id:B,label:y,options:N,required:J}){let{responses:$,setResponse:Q}=sy(),Y=$.get(B),f=Y?.value||[],W=Y?.note||"",[K,X]=oy(!1),b=ly(null);Xy(()=>{if(!$.has(B))Q(B,{id:B,type:"checkbox",label:y,value:[],options:N,required:J})},[B]);let P=(L)=>{let q=f.includes(L)?f.filter((G)=>G!==L):[...f,L];Q(B,{...Y,value:q})};Xy(()=>{let L=b.current;if(!L)return;let q=(G)=>{let A=G.target.closest("[data-md-label]")?.getAttribute("data-md-label");if(A&&N.includes(A))P(A)};return L.addEventListener("kb-select",q),()=>L.removeEventListener("kb-select",q)});let U=Y?.required&&f.length===0;return k("div",{ref:b,"data-md":"multichoice","data-md-label":y,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[k("div",{className:"flex items-baseline gap-2 mb-2",children:[k("span",{className:"text-[13px] font-body font-medium text-text-primary",children:y},void 0,!1,void 0,this),J&&k("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),k("div",{className:"space-y-1",children:N.map((L)=>{let q=f.includes(L);return k("label",{"data-md":"multichoice-option","data-md-label":L,onClick:()=>P(L),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${q?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[k("span",{className:`w-4 h-4 rounded flex items-center justify-center flex-shrink-0 transition-all ${q?"bg-accent-amber":"border-[1.5px] border-border-strong"}`,children:q&&k("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:k("path",{d:"M2.5 5L4.5 7L7.5 3",style:{stroke:"var(--color-text-inverse)"},strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),k("span",{className:"text-[13px] font-body text-text-secondary",children:L},void 0,!1,void 0,this)]},L,!0,void 0,this)})},void 0,!1,void 0,this),k(n,{show:K,note:W,onToggle:()=>X(!K),onChange:(L)=>Q(B,{...Y,note:L})},void 0,!1,void 0,this),U&&k("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select at least one option."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as ny,useRef as B0,useState as ty}from"react";import{useAnnotations as ey}from"#canvas/runtime";import{jsxDEV as v}from"react/jsx-dev-runtime";function N0({id:B,label:y,placeholder:N,multiline:J,required:$}){let{responses:Q,setResponse:Y}=ey(),f=Q.get(B),W=f?.value??"",K=f?.note||"",[X,b]=ty(!1),P=B0(null);ny(()=>{if(!Q.has(B))Y(B,{id:B,type:"text",label:y,value:"",required:$})},[B]);let U=(G)=>{Y(B,{...f,value:G})},L=(G)=>yy(G,J?60:32),q=f?.required&&!W.trim();return v("div",{"data-md":"userinput","data-md-label":y,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[v("div",{className:"flex items-baseline gap-2 mb-2",children:[v("span",{className:"text-[13px] font-body font-medium text-text-primary",children:y},void 0,!1,void 0,this),$&&v("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),v("textarea",{ref:P,value:W,onChange:(G)=>{U(G.target.value),L(G.target)},placeholder:N||"Type your response...",rows:J?3:1,className:"w-full bg-bg-input text-[13px] font-body text-text-primary rounded-lg px-3 py-2 resize-none focus:outline-none border border-border-subtle focus:border-border-hover placeholder:text-text-tertiary transition-colors",onInput:(G)=>L(G.target),onFocus:(G)=>L(G.target)},void 0,!1,void 0,this),v(n,{show:X,note:K,onToggle:()=>b(!X),onChange:(G)=>Y(B,{...f,note:G})},void 0,!1,void 0,this),q&&v("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"This field is required."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function J0({id:B,label:y,min:N=1,max:J=10,step:$=1,required:Q,minLabel:Y,maxLabel:f}){let{responses:W,setResponse:K}=ey(),X=W.get(B),b=X?.value,P=X?.note||"",[U,L]=ty(!1);ny(()=>{if(!W.has(B))K(B,{id:B,type:"range",label:y,value:null,required:Q})},[B]);let q=(z)=>{K(B,{...X,value:z})},G=b!==null&&b!==void 0,Z=G?b:Math.round((N+J)/2),A=(Z-N)/(J-N)*100,w=Math.round((J-N)/$),C=w<=20,I=X?.required&&!G;return v("div",{"data-md":"rangeinput","data-md-label":y,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[v("div",{className:"flex items-baseline justify-between mb-1",children:[v("div",{className:"flex items-baseline gap-2",children:[v("span",{className:"text-[13px] font-body font-medium text-text-primary",children:y},void 0,!1,void 0,this),Q&&v("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),v("span",{className:"flex items-center gap-1.5",children:[v("span",{className:`text-[13px] font-mono ${G?"text-accent-amber":"text-text-disabled"}`,children:G?b:"—"},void 0,!1,void 0,this),G&&v("button",{onClick:()=>K(B,{...X,value:null}),className:"text-text-disabled hover:text-text-tertiary transition-colors text-[10px] leading-none",title:"Clear",children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),v("div",{className:"relative h-6 flex items-center",children:[v("div",{className:"absolute left-0 right-0 h-1.5 rounded-full bg-border-medium",children:G&&v("div",{className:"h-full rounded-full bg-accent-amber transition-all duration-150",style:{width:`${A}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this),C&&Array.from({length:w+1},(z,g)=>{let D=N+g*$,O=(D-N)/(J-N)*100,H=G&&D<=b;return v("div",{className:`absolute rounded-full pointer-events-none transition-all duration-150 ${G&&D===b?"w-2.5 h-2.5 bg-accent-amber":H?"w-1.5 h-1.5 bg-accent-amber":"w-1.5 h-1.5 bg-border-hover"}`,style:{left:`${O}%`,transform:"translate(-50%, -50%)",top:"50%"}},g,!1,void 0,this)}),G?v("div",{className:"absolute h-5 w-5 rounded-full bg-accent-amber shadow-md pointer-events-none transition-all duration-150",style:{left:`calc(${A}% - 10px)`,borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this):v("div",{className:"absolute h-4 w-4 rounded-full bg-border-hover pointer-events-none opacity-50",style:{left:"calc(50% - 8px)",borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this),v("input",{type:"range",min:N,max:J,step:$,value:Z,onChange:(z)=>q(Number(z.target.value)),className:"absolute inset-0 w-full opacity-0 cursor-pointer"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),C&&w<=10?v("div",{className:"flex justify-between -mt-0.5 px-0",children:Array.from({length:w+1},(z,g)=>{let D=N+g*$;return v("span",{className:`text-[10px] font-mono transition-colors ${G&&D===b?"text-accent-amber font-medium":"text-text-disabled"}`,style:{minWidth:"1ch",textAlign:"center"},children:D},g,!1,void 0,this)})},void 0,!1,void 0,this):v("div",{className:"flex justify-between -mt-0.5",children:[v("span",{className:"text-[11px] text-text-tertiary font-body",children:Y||N},void 0,!1,void 0,this),v("span",{className:"text-[11px] text-text-tertiary font-body",children:f||J},void 0,!1,void 0,this)]},void 0,!0,void 0,this),v(n,{show:U,note:P,onToggle:()=>L(!U),onChange:(z)=>K(B,{...X,note:z})},void 0,!1,void 0,this),I&&v("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select a value."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useContext as Q0,useState as Y0}from"react";import{SessionContext as W0}from"#canvas/runtime";import{jsxDEV as $y}from"react/jsx-dev-runtime";function f0({src:B,alt:y,caption:N,width:J,height:$}){let Q=Q0(W0),[Y,f]=Y0(!1),W=`/api/image?session=${encodeURIComponent(Q)}&path=${encodeURIComponent(B)}`;if(Y)return $y("div",{className:"mt-3 text-accent-red text-body bg-accent-red-muted rounded-md p-4",children:[B,": Failed to load image"]},void 0,!0,void 0,this);return $y("figure",{className:"mt-3 relative","data-md":"image","data-md-src":B,children:[$y("div",{className:"rounded-md overflow-hidden border border-border-subtle bg-bg-code inline-block",children:$y("img",{src:W,alt:y||B,onError:()=>f(!0),className:"block max-w-full h-auto",...J?{width:J}:{},...$?{height:$}:{}},void 0,!1,void 0,this)},void 0,!1,void 0,this),N&&$y("figcaption",{className:"mt-1.5 text-meta text-text-tertiary font-body",children:N},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useMemo as t0}from"react";function wy(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var a=wy();function Y1(B){a=B}var r={exec:()=>null};function m(B,y=""){let N=typeof B=="string"?B:B.source,J={replace:($,Q)=>{let Y=typeof Q=="string"?Q:Q.source;return Y=Y.replace(R.caret,"$1"),N=N.replace($,Y),J},getRegex:()=>new RegExp(N,y)};return J}var K0=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),R={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,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,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:(B)=>new RegExp(`^( {0,3}${B})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:(B)=>new RegExp(`^ {0,${Math.min(3,B-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:(B)=>new RegExp(`^ {0,${Math.min(3,B-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:(B)=>new RegExp(`^ {0,${Math.min(3,B-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:(B)=>new RegExp(`^ {0,${Math.min(3,B-1)}}#`),htmlBeginRegex:(B)=>new RegExp(`^ {0,${Math.min(3,B-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:(B)=>new RegExp(`^ {0,${Math.min(3,B-1)}}>`)},X0=/^(?:[ \t]*(?:\n|$))+/,L0=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,b0=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Qy=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,P0=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ky=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,W1=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,f1=m(W1).replace(/bull/g,ky).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(),H0=m(W1).replace(/bull/g,ky).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(),Ay=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,U0=/^[^\n]+/,zy=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,q0=m(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",zy).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),F0=m(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ky).getRegex(),Uy="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",_y=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,G0=m("^ {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[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",_y).replace("tag",Uy).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),K1=m(Ay).replace("hr",Qy).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[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Uy).getRegex(),T0=m(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",K1).getRegex(),Oy={blockquote:T0,code:L0,def:q0,fences:b0,heading:P0,hr:Qy,html:G0,lheading:f1,list:F0,newline:X0,paragraph:K1,table:r,text:U0},y1=m("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Qy).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Uy).getRegex(),m0={...Oy,lheading:H0,table:y1,paragraph:m(Ay).replace("hr",Qy).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",y1).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Uy).getRegex()},M0={...Oy,html:m(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",_y).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:r,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:m(Ay).replace("hr",Qy).replace("heading",` *#{1,6} *[^
6
- ]`).replace("lheading",f1).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},v0=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Z0=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,X1=/^( {2,}|\\)\n(?!\s*$)/,w0=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,qy=/[\p{P}\p{S}]/u,Cy=/[\s\p{P}\p{S}]/u,L1=/[^\s\p{P}\p{S}]/u,k0=m(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Cy).getRegex(),b1=/(?!~)[\p{P}\p{S}]/u,A0=/(?!~)[\s\p{P}\p{S}]/u,z0=/(?:[^\s\p{P}\p{S}]|~)/u,P1=/(?![*_])[\p{P}\p{S}]/u,_0=/(?![*_])[\s\p{P}\p{S}]/u,O0=/(?:[^\s\p{P}\p{S}]|[*_])/u,C0=m(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",K0?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),H1=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,I0=m(H1,"u").replace(/punct/g,qy).getRegex(),R0=m(H1,"u").replace(/punct/g,b1).getRegex(),U1="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",S0=m(U1,"gu").replace(/notPunctSpace/g,L1).replace(/punctSpace/g,Cy).replace(/punct/g,qy).getRegex(),g0=m(U1,"gu").replace(/notPunctSpace/g,z0).replace(/punctSpace/g,A0).replace(/punct/g,b1).getRegex(),h0=m("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,L1).replace(/punctSpace/g,Cy).replace(/punct/g,qy).getRegex(),D0=m(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,P1).getRegex(),j0="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",V0=m(j0,"gu").replace(/notPunctSpace/g,O0).replace(/punctSpace/g,_0).replace(/punct/g,P1).getRegex(),c0=m(/\\(punct)/,"gu").replace(/punct/g,qy).getRegex(),x0=m(/^<(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(),d0=m(_y).replace("(?:-->|$)","-->").getRegex(),p0=m("^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",d0).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),by=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,E0=m(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",by).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),q1=m(/^!?\[(label)\]\[(ref)\]/).replace("label",by).replace("ref",zy).getRegex(),F1=m(/^!?\[(ref)\](?:\[\])?/).replace("ref",zy).getRegex(),u0=m("reflink|nolink(?!\\()","g").replace("reflink",q1).replace("nolink",F1).getRegex(),$1=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Iy={_backpedal:r,anyPunctuation:c0,autolink:x0,blockSkip:C0,br:X1,code:Z0,del:r,delLDelim:r,delRDelim:r,emStrongLDelim:I0,emStrongRDelimAst:S0,emStrongRDelimUnd:h0,escape:v0,link:E0,nolink:F1,punctuation:k0,reflink:q1,reflinkSearch:u0,tag:p0,text:w0,url:r},r0={...Iy,link:m(/^!?\[(label)\]\((.*?)\)/).replace("label",by).getRegex(),reflink:m(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",by).getRegex()},Zy={...Iy,emStrongRDelimAst:g0,emStrongLDelim:R0,delLDelim:D0,delRDelim:V0,url:m(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",$1).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:m(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",$1).getRegex()},i0={...Zy,br:m(X1).replace("{2,}","*").getRegex(),text:m(Zy.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ly={normal:Oy,gfm:m0,pedantic:M0},By={normal:Iy,gfm:Zy,breaks:i0,pedantic:r0},a0={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},B1=(B)=>a0[B];function d(B,y){if(y){if(R.escapeTest.test(B))return B.replace(R.escapeReplace,B1)}else if(R.escapeTestNoEncode.test(B))return B.replace(R.escapeReplaceNoEncode,B1);return B}function N1(B){try{B=encodeURI(B).replace(R.percentDecode,"%")}catch{return null}return B}function J1(B,y){let N=B.replace(R.findPipe,(Q,Y,f)=>{let W=!1,K=Y;for(;--K>=0&&f[K]==="\\";)W=!W;return W?"|":" |"}),J=N.split(R.splitPipe),$=0;if(J[0].trim()||J.shift(),J.length>0&&!J.at(-1)?.trim()&&J.pop(),y)if(J.length>y)J.splice(y);else for(;J.length<y;)J.push("");for(;$<J.length;$++)J[$]=J[$].trim().replace(R.slashPipe,"|");return J}function Ny(B,y,N){let J=B.length;if(J===0)return"";let $=0;for(;$<J;){let Q=B.charAt(J-$-1);if(Q===y&&!N)$++;else if(Q!==y&&N)$++;else break}return B.slice(0,J-$)}function l0(B,y){if(B.indexOf(y[1])===-1)return-1;let N=0;for(let J=0;J<B.length;J++)if(B[J]==="\\")J++;else if(B[J]===y[0])N++;else if(B[J]===y[1]&&(N--,N<0))return J;return N>0?-2:-1}function o0(B,y=0){let N=y,J="";for(let $ of B)if($==="\t"){let Q=4-N%4;J+=" ".repeat(Q),N+=Q}else J+=$,N++;return J}function Q1(B,y,N,J,$){let Q=y.href,Y=y.title||null,f=B[1].replace($.other.outputLinkReplace,"$1");J.state.inLink=!0;let W={type:B[0].charAt(0)==="!"?"image":"link",raw:N,href:Q,title:Y,text:f,tokens:J.inlineTokens(f)};return J.state.inLink=!1,W}function s0(B,y,N){let J=B.match(N.other.indentCodeCompensation);if(J===null)return y;let $=J[1];return y.split(`
7
- `).map((Q)=>{let Y=Q.match(N.other.beginningSpace);if(Y===null)return Q;let[f]=Y;return f.length>=$.length?Q.slice($.length):Q}).join(`
8
- `)}var Py=class{options;rules;lexer;constructor(B){this.options=B||a}space(B){let y=this.rules.block.newline.exec(B);if(y&&y[0].length>0)return{type:"space",raw:y[0]}}code(B){let y=this.rules.block.code.exec(B);if(y){let N=y[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:y[0],codeBlockStyle:"indented",text:this.options.pedantic?N:Ny(N,`
9
- `)}}}fences(B){let y=this.rules.block.fences.exec(B);if(y){let N=y[0],J=s0(N,y[3]||"",this.rules);return{type:"code",raw:N,lang:y[2]?y[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):y[2],text:J}}}heading(B){let y=this.rules.block.heading.exec(B);if(y){let N=y[2].trim();if(this.rules.other.endingHash.test(N)){let J=Ny(N,"#");(this.options.pedantic||!J||this.rules.other.endingSpaceChar.test(J))&&(N=J.trim())}return{type:"heading",raw:y[0],depth:y[1].length,text:N,tokens:this.lexer.inline(N)}}}hr(B){let y=this.rules.block.hr.exec(B);if(y)return{type:"hr",raw:Ny(y[0],`
10
- `)}}blockquote(B){let y=this.rules.block.blockquote.exec(B);if(y){let N=Ny(y[0],`
5
+ `),B=vy(Y,$),W=[],K=0,X=0,L=0;while(K<Y.length||X<$.length)if(L<B.length&&K<Y.length&&X<$.length&&Y[K]===B[L]&&$[X]===B[L])W.push({type:"same",line:Y[K]}),K++,X++,L++;else if(K<Y.length&&(L>=B.length||Y[K]!==B[L]))W.push({type:"removed",line:Y[K]}),K++;else if(X<$.length)W.push({type:"added",line:$[X]}),X++;return H1("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden group/diff","data-md":"diff","data-md-language":Q||"",children:[Q&&H1("div",{className:"px-4 py-2 text-meta font-mono text-text-tertiary opacity-0 group-hover/diff:opacity-60 transition-opacity",children:["diff (",Q,")"]},void 0,!0,void 0,this),H1("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono",children:W.map((N,G)=>H1("div",{className:N.type==="removed"?"bg-accent-red-muted text-accent-red":N.type==="added"?"bg-accent-green-muted text-accent-green":"text-text-tertiary",children:[H1("span",{className:"select-none w-6 inline-block text-center opacity-60",children:N.type==="removed"?"-":N.type==="added"?"+":" "},void 0,!1,void 0,this),N.line]},G,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function vy(J,y){let Q=J.length,Y=y.length,$=Array.from({length:Q+1},()=>Array(Y+1).fill(0));for(let X=1;X<=Q;X++)for(let L=1;L<=Y;L++)$[X][L]=J[X-1]===y[L-1]?$[X-1][L-1]+1:Math.max($[X-1][L],$[X][L-1]);let B=[],W=Q,K=Y;while(W>0&&K>0)if(J[W-1]===y[K-1])B.unshift(J[W-1]),W--,K--;else if($[W-1][K]>$[W][K-1])W--;else K--;return B}import{useEffect as k1,useRef as G0,useState as U0}from"react";import{useAnnotations as H0}from"#canvas/runtime";import{jsxDEV as q0}from"react/jsx-dev-runtime";function N1({note:J,onChange:y}){return q0("div",{className:"mt-1.5",children:q0("textarea",{value:J,onChange:(Q)=>y(Q.target.value),className:"w-full bg-transparent text-[12px] font-body text-text-primary resize-none focus:outline-none border-none placeholder:text-text-disabled transition-colors min-h-[20px] p-0 leading-relaxed",placeholder:"Add a note...",rows:1,onInput:(Q)=>Q1(Q.target),ref:(Q)=>{if(Q)Q1(Q)}},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as z}from"react/jsx-dev-runtime";function _y({id:J,label:y,options:Q,required:Y}){let{responses:$,setResponse:B}=H0(),W=$.get(J),K=W?.value,X=W?.note||"",[L,N]=U0(!1),G=G0(null);k1(()=>{if(!$.has(J))B(J,{id:J,type:"radio",label:y,value:null,options:Q,required:Y})},[J]);let H=(q)=>{B(J,{...W,value:q})};k1(()=>{let q=G.current;if(!q)return;let T=(P)=>{let A=P.target.closest("[data-md-label]")?.getAttribute("data-md-label");if(A&&Q.includes(A))H(A)};return q.addEventListener("kb-select",T),()=>q.removeEventListener("kb-select",T)});let b=W?.required&&!K;return z("div",{ref:G,"data-md":"choice","data-md-label":y,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[z("div",{className:"flex items-baseline gap-2 mb-2",children:[z("span",{className:"text-[13px] font-body font-medium text-text-primary",children:y},void 0,!1,void 0,this),Y&&z("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z("div",{className:"space-y-1",children:Q.map((q)=>z("label",{"data-md":"choice-option","data-md-label":q,onClick:()=>H(q),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${K===q?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[z("span",{className:`w-4 h-4 rounded-full border-[1.5px] flex items-center justify-center flex-shrink-0 transition-all ${K===q?"border-accent-amber bg-accent-amber":"border-border-strong"}`,children:K===q&&z("span",{className:"w-1.5 h-1.5 rounded-full bg-text-inverse"},void 0,!1,void 0,this)},void 0,!1,void 0,this),z("span",{className:"text-[13px] font-body text-text-secondary",children:q},void 0,!1,void 0,this)]},q,!0,void 0,this))},void 0,!1,void 0,this),z(N1,{show:L,note:X,onToggle:()=>N(!L),onChange:(q)=>B(J,{...W,note:q})},void 0,!1,void 0,this),b&&z("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select an option."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function wy({id:J,label:y,options:Q,required:Y}){let{responses:$,setResponse:B}=H0(),W=$.get(J),K=W?.value||[],X=W?.note||"",[L,N]=U0(!1),G=G0(null);k1(()=>{if(!$.has(J))B(J,{id:J,type:"checkbox",label:y,value:[],options:Q,required:Y})},[J]);let H=(q)=>{let T=K.includes(q)?K.filter((P)=>P!==q):[...K,q];B(J,{...W,value:T})};k1(()=>{let q=G.current;if(!q)return;let T=(P)=>{let A=P.target.closest("[data-md-label]")?.getAttribute("data-md-label");if(A&&Q.includes(A))H(A)};return q.addEventListener("kb-select",T),()=>q.removeEventListener("kb-select",T)});let b=W?.required&&K.length===0;return z("div",{ref:G,"data-md":"multichoice","data-md-label":y,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[z("div",{className:"flex items-baseline gap-2 mb-2",children:[z("span",{className:"text-[13px] font-body font-medium text-text-primary",children:y},void 0,!1,void 0,this),Y&&z("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z("div",{className:"space-y-1",children:Q.map((q)=>{let T=K.includes(q);return z("label",{"data-md":"multichoice-option","data-md-label":q,onClick:()=>H(q),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${T?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[z("span",{className:`w-4 h-4 rounded flex items-center justify-center flex-shrink-0 transition-all ${T?"bg-accent-amber":"border-[1.5px] border-border-strong"}`,children:T&&z("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:z("path",{d:"M2.5 5L4.5 7L7.5 3",style:{stroke:"var(--color-text-inverse)"},strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),z("span",{className:"text-[13px] font-body text-text-secondary",children:q},void 0,!1,void 0,this)]},q,!0,void 0,this)})},void 0,!1,void 0,this),z(N1,{show:L,note:X,onToggle:()=>N(!L),onChange:(q)=>B(J,{...W,note:q})},void 0,!1,void 0,this),b&&z("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select at least one option."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as P0,useRef as My,useState as b0}from"react";import{useAnnotations as T0}from"#canvas/runtime";import{jsxDEV as M}from"react/jsx-dev-runtime";function Ay({id:J,label:y,placeholder:Q,multiline:Y,required:$}){let{responses:B,setResponse:W}=T0(),K=B.get(J),X=K?.value??"",L=K?.note||"",[N,G]=b0(!1),H=My(null);P0(()=>{if(!B.has(J))W(J,{id:J,type:"text",label:y,value:"",required:$})},[J]);let b=(P)=>{W(J,{...K,value:P})},q=(P)=>Q1(P,Y?60:32),T=K?.required&&!X.trim();return M("div",{"data-md":"userinput","data-md-label":y,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[M("div",{className:"flex items-baseline gap-2 mb-2",children:[M("span",{className:"text-[13px] font-body font-medium text-text-primary",children:y},void 0,!1,void 0,this),$&&M("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),M("textarea",{ref:H,value:X,onChange:(P)=>{b(P.target.value),q(P.target)},placeholder:Q||"Type your response...",rows:Y?3:1,className:"w-full bg-bg-input text-[13px] font-body text-text-primary rounded-lg px-3 py-2 resize-none focus:outline-none border border-border-subtle focus:border-border-hover placeholder:text-text-tertiary transition-colors",onInput:(P)=>q(P.target),onFocus:(P)=>q(P.target)},void 0,!1,void 0,this),M(N1,{show:N,note:L,onToggle:()=>G(!N),onChange:(P)=>W(J,{...K,note:P})},void 0,!1,void 0,this),T&&M("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"This field is required."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function fy({id:J,label:y,min:Q=1,max:Y=10,step:$=1,required:B,minLabel:W,maxLabel:K}){let{responses:X,setResponse:L}=T0(),N=X.get(J),G=N?.value,H=N?.note||"",[b,q]=b0(!1);P0(()=>{if(!X.has(J))L(J,{id:J,type:"range",label:y,value:null,required:B})},[J]);let T=(k)=>{L(J,{...N,value:k})},P=G!==null&&G!==void 0,v=P?G:Math.round((Q+Y)/2),A=(v-Q)/(Y-Q)*100,O=Math.round((Y-Q)/$),c=O<=20,V=N?.required&&!P;return M("div",{"data-md":"rangeinput","data-md-label":y,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[M("div",{className:"flex items-baseline justify-between mb-1",children:[M("div",{className:"flex items-baseline gap-2",children:[M("span",{className:"text-[13px] font-body font-medium text-text-primary",children:y},void 0,!1,void 0,this),B&&M("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),M("span",{className:"flex items-center gap-1.5",children:[M("span",{className:`text-[13px] font-mono ${P?"text-accent-amber":"text-text-disabled"}`,children:P?G:"—"},void 0,!1,void 0,this),P&&M("button",{onClick:()=>L(J,{...N,value:null}),className:"text-text-disabled hover:text-text-tertiary transition-colors text-[10px] leading-none",title:"Clear",children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),M("div",{className:"relative h-6 flex items-center",children:[M("div",{className:"absolute left-0 right-0 h-1.5 rounded-full bg-border-medium",children:P&&M("div",{className:"h-full rounded-full bg-accent-amber transition-all duration-150",style:{width:`${A}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this),c&&Array.from({length:O+1},(k,D)=>{let S=Q+D*$,f=(S-Q)/(Y-Q)*100,h=P&&S<=G;return M("div",{className:`absolute rounded-full pointer-events-none transition-all duration-150 ${P&&S===G?"w-2.5 h-2.5 bg-accent-amber":h?"w-1.5 h-1.5 bg-accent-amber":"w-1.5 h-1.5 bg-border-hover"}`,style:{left:`${f}%`,transform:"translate(-50%, -50%)",top:"50%"}},D,!1,void 0,this)}),P?M("div",{className:"absolute h-5 w-5 rounded-full bg-accent-amber shadow-md pointer-events-none transition-all duration-150",style:{left:`calc(${A}% - 10px)`,borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this):M("div",{className:"absolute h-4 w-4 rounded-full bg-border-hover pointer-events-none opacity-50",style:{left:"calc(50% - 8px)",borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this),M("input",{type:"range",min:Q,max:Y,step:$,value:v,onChange:(k)=>T(Number(k.target.value)),className:"absolute inset-0 w-full opacity-0 cursor-pointer"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),c&&O<=10?M("div",{className:"flex justify-between -mt-0.5 px-0",children:Array.from({length:O+1},(k,D)=>{let S=Q+D*$;return M("span",{className:`text-[10px] font-mono transition-colors ${P&&S===G?"text-accent-amber font-medium":"text-text-disabled"}`,style:{minWidth:"1ch",textAlign:"center"},children:S},D,!1,void 0,this)})},void 0,!1,void 0,this):M("div",{className:"flex justify-between -mt-0.5",children:[M("span",{className:"text-[11px] text-text-tertiary font-body",children:W||Q},void 0,!1,void 0,this),M("span",{className:"text-[11px] text-text-tertiary font-body",children:K||Y},void 0,!1,void 0,this)]},void 0,!0,void 0,this),M(N1,{show:b,note:H,onToggle:()=>q(!b),onChange:(k)=>L(J,{...N,note:k})},void 0,!1,void 0,this),V&&M("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select a value."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useContext as zy,useState as ky}from"react";import{SessionContext as Oy}from"#canvas/runtime";import{jsxDEV as P1}from"react/jsx-dev-runtime";function Sy({src:J,alt:y,caption:Q,width:Y,height:$}){let B=zy(Oy),[W,K]=ky(!1),X=`/api/image?session=${encodeURIComponent(B)}&path=${encodeURIComponent(J)}`;if(W)return P1("div",{className:"mt-3 text-accent-red text-body bg-accent-red-muted rounded-md p-4",children:[J,": Failed to load image"]},void 0,!0,void 0,this);return P1("figure",{className:"mt-3 relative","data-md":"image","data-md-src":J,children:[P1("div",{className:"rounded-md overflow-hidden border border-border-subtle bg-bg-code inline-block",children:P1("img",{src:X,alt:y||J,onError:()=>K(!0),className:"block max-w-full h-auto",...Y?{width:Y}:{},...$?{height:$}:{}},void 0,!1,void 0,this)},void 0,!1,void 0,this),Q&&P1("figcaption",{className:"mt-1.5 text-meta text-text-tertiary font-body",children:Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useMemo as F5}from"react";function c1(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var W1=c1();function A0(J){W1=J}var Y1={exec:()=>null};function _(J,y=""){let Q=typeof J=="string"?J:J.source,Y={replace:($,B)=>{let W=typeof B=="string"?B:B.source;return W=W.replace(j.caret,"$1"),Q=Q.replace($,W),Y},getRegex:()=>new RegExp(Q,y)};return Y}var Iy=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),j={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,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,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:(J)=>new RegExp(`^( {0,3}${J})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:(J)=>new RegExp(`^ {0,${Math.min(3,J-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:(J)=>new RegExp(`^ {0,${Math.min(3,J-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:(J)=>new RegExp(`^ {0,${Math.min(3,J-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:(J)=>new RegExp(`^ {0,${Math.min(3,J-1)}}#`),htmlBeginRegex:(J)=>new RegExp(`^ {0,${Math.min(3,J-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:(J)=>new RegExp(`^ {0,${Math.min(3,J-1)}}>`)},my=/^(?:[ \t]*(?:\n|$))+/,Cy=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Ry=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,F1=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,hy=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,E1=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,f0=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,z0=_(f0).replace(/bull/g,E1).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(),gy=_(f0).replace(/bull/g,E1).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(),d1=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,jy=/^[^\n]+/,u1=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Vy=_(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",u1).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),xy=_(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,E1).getRegex(),C1="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",r1=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Dy=_("^ {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[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",r1).replace("tag",C1).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),k0=_(d1).replace("hr",F1).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[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",C1).getRegex(),py=_(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",k0).getRegex(),i1={blockquote:py,code:Cy,def:Vy,fences:Ry,heading:hy,hr:F1,html:Dy,lheading:z0,list:xy,newline:my,paragraph:k0,table:Y1,text:jy},Z0=_("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",F1).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",C1).getRegex(),cy={...i1,lheading:gy,table:Z0,paragraph:_(d1).replace("hr",F1).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Z0).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",C1).getRegex()},Ey={...i1,html:_(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",r1).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:Y1,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:_(d1).replace("hr",F1).replace("heading",` *#{1,6} *[^
6
+ ]`).replace("lheading",z0).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},dy=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,uy=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,O0=/^( {2,}|\\)\n(?!\s*$)/,ry=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,R1=/[\p{P}\p{S}]/u,l1=/[\s\p{P}\p{S}]/u,S0=/[^\s\p{P}\p{S}]/u,iy=_(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,l1).getRegex(),I0=/(?!~)[\p{P}\p{S}]/u,ly=/(?!~)[\s\p{P}\p{S}]/u,ay=/(?:[^\s\p{P}\p{S}]|~)/u,m0=/(?![*_])[\p{P}\p{S}]/u,oy=/(?![*_])[\s\p{P}\p{S}]/u,sy=/(?:[^\s\p{P}\p{S}]|[*_])/u,ny=_(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Iy?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),C0=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ty=_(C0,"u").replace(/punct/g,R1).getRegex(),ey=_(C0,"u").replace(/punct/g,I0).getRegex(),R0="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",y5=_(R0,"gu").replace(/notPunctSpace/g,S0).replace(/punctSpace/g,l1).replace(/punct/g,R1).getRegex(),$5=_(R0,"gu").replace(/notPunctSpace/g,ay).replace(/punctSpace/g,ly).replace(/punct/g,I0).getRegex(),J5=_("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,S0).replace(/punctSpace/g,l1).replace(/punct/g,R1).getRegex(),Q5=_(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,m0).getRegex(),Y5="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",B5=_(Y5,"gu").replace(/notPunctSpace/g,sy).replace(/punctSpace/g,oy).replace(/punct/g,m0).getRegex(),W5=_(/\\(punct)/,"gu").replace(/punct/g,R1).getRegex(),X5=_(/^<(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(),K5=_(r1).replace("(?:-->|$)","-->").getRegex(),L5=_("^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",K5).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),S1=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,N5=_(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",S1).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),h0=_(/^!?\[(label)\]\[(ref)\]/).replace("label",S1).replace("ref",u1).getRegex(),g0=_(/^!?\[(ref)\](?:\[\])?/).replace("ref",u1).getRegex(),q5=_("reflink|nolink(?!\\()","g").replace("reflink",h0).replace("nolink",g0).getRegex(),F0=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,a1={_backpedal:Y1,anyPunctuation:W5,autolink:X5,blockSkip:ny,br:O0,code:uy,del:Y1,delLDelim:Y1,delRDelim:Y1,emStrongLDelim:ty,emStrongRDelimAst:y5,emStrongRDelimUnd:J5,escape:dy,link:N5,nolink:g0,punctuation:iy,reflink:h0,reflinkSearch:q5,tag:L5,text:ry,url:Y1},G5={...a1,link:_(/^!?\[(label)\]\((.*?)\)/).replace("label",S1).getRegex(),reflink:_(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",S1).getRegex()},p1={...a1,emStrongRDelimAst:$5,emStrongLDelim:ey,delLDelim:Q5,delRDelim:B5,url:_(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",F0).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:_(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",F0).getRegex()},U5={...p1,br:_(O0).replace("{2,}","*").getRegex(),text:_(p1.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},O1={normal:i1,gfm:cy,pedantic:Ey},b1={normal:a1,gfm:p1,breaks:U5,pedantic:G5},H5={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},v0=(J)=>H5[J];function a(J,y){if(y){if(j.escapeTest.test(J))return J.replace(j.escapeReplace,v0)}else if(j.escapeTestNoEncode.test(J))return J.replace(j.escapeReplaceNoEncode,v0);return J}function _0(J){try{J=encodeURI(J).replace(j.percentDecode,"%")}catch{return null}return J}function w0(J,y){let Q=J.replace(j.findPipe,(B,W,K)=>{let X=!1,L=W;for(;--L>=0&&K[L]==="\\";)X=!X;return X?"|":" |"}),Y=Q.split(j.splitPipe),$=0;if(Y[0].trim()||Y.shift(),Y.length>0&&!Y.at(-1)?.trim()&&Y.pop(),y)if(Y.length>y)Y.splice(y);else for(;Y.length<y;)Y.push("");for(;$<Y.length;$++)Y[$]=Y[$].trim().replace(j.slashPipe,"|");return Y}function T1(J,y,Q){let Y=J.length;if(Y===0)return"";let $=0;for(;$<Y;){let B=J.charAt(Y-$-1);if(B===y&&!Q)$++;else if(B!==y&&Q)$++;else break}return J.slice(0,Y-$)}function P5(J,y){if(J.indexOf(y[1])===-1)return-1;let Q=0;for(let Y=0;Y<J.length;Y++)if(J[Y]==="\\")Y++;else if(J[Y]===y[0])Q++;else if(J[Y]===y[1]&&(Q--,Q<0))return Y;return Q>0?-2:-1}function b5(J,y=0){let Q=y,Y="";for(let $ of J)if($==="\t"){let B=4-Q%4;Y+=" ".repeat(B),Q+=B}else Y+=$,Q++;return Y}function M0(J,y,Q,Y,$){let B=y.href,W=y.title||null,K=J[1].replace($.other.outputLinkReplace,"$1");Y.state.inLink=!0;let X={type:J[0].charAt(0)==="!"?"image":"link",raw:Q,href:B,title:W,text:K,tokens:Y.inlineTokens(K)};return Y.state.inLink=!1,X}function T5(J,y,Q){let Y=J.match(Q.other.indentCodeCompensation);if(Y===null)return y;let $=Y[1];return y.split(`
7
+ `).map((B)=>{let W=B.match(Q.other.beginningSpace);if(W===null)return B;let[K]=W;return K.length>=$.length?B.slice($.length):B}).join(`
8
+ `)}var I1=class{options;rules;lexer;constructor(J){this.options=J||W1}space(J){let y=this.rules.block.newline.exec(J);if(y&&y[0].length>0)return{type:"space",raw:y[0]}}code(J){let y=this.rules.block.code.exec(J);if(y){let Q=y[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:y[0],codeBlockStyle:"indented",text:this.options.pedantic?Q:T1(Q,`
9
+ `)}}}fences(J){let y=this.rules.block.fences.exec(J);if(y){let Q=y[0],Y=T5(Q,y[3]||"",this.rules);return{type:"code",raw:Q,lang:y[2]?y[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):y[2],text:Y}}}heading(J){let y=this.rules.block.heading.exec(J);if(y){let Q=y[2].trim();if(this.rules.other.endingHash.test(Q)){let Y=T1(Q,"#");(this.options.pedantic||!Y||this.rules.other.endingSpaceChar.test(Y))&&(Q=Y.trim())}return{type:"heading",raw:y[0],depth:y[1].length,text:Q,tokens:this.lexer.inline(Q)}}}hr(J){let y=this.rules.block.hr.exec(J);if(y)return{type:"hr",raw:T1(y[0],`
10
+ `)}}blockquote(J){let y=this.rules.block.blockquote.exec(J);if(y){let Q=T1(y[0],`
11
11
  `).split(`
12
- `),J="",$="",Q=[];for(;N.length>0;){let Y=!1,f=[],W;for(W=0;W<N.length;W++)if(this.rules.other.blockquoteStart.test(N[W]))f.push(N[W]),Y=!0;else if(!Y)f.push(N[W]);else break;N=N.slice(W);let K=f.join(`
13
- `),X=K.replace(this.rules.other.blockquoteSetextReplace,`
14
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");J=J?`${J}
15
- ${K}`:K,$=$?`${$}
16
- ${X}`:X;let b=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(X,Q,!0),this.lexer.state.top=b,N.length===0)break;let P=Q.at(-1);if(P?.type==="code")break;if(P?.type==="blockquote"){let U=P,L=U.raw+`
17
- `+N.join(`
18
- `),q=this.blockquote(L);Q[Q.length-1]=q,J=J.substring(0,J.length-U.raw.length)+q.raw,$=$.substring(0,$.length-U.text.length)+q.text;break}else if(P?.type==="list"){let U=P,L=U.raw+`
19
- `+N.join(`
20
- `),q=this.list(L);Q[Q.length-1]=q,J=J.substring(0,J.length-P.raw.length)+q.raw,$=$.substring(0,$.length-U.raw.length)+q.raw,N=L.substring(Q.at(-1).raw.length).split(`
21
- `);continue}}return{type:"blockquote",raw:J,tokens:Q,text:$}}}list(B){let y=this.rules.block.list.exec(B);if(y){let N=y[1].trim(),J=N.length>1,$={type:"list",raw:"",ordered:J,start:J?+N.slice(0,-1):"",loose:!1,items:[]};N=J?`\\d{1,9}\\${N.slice(-1)}`:`\\${N}`,this.options.pedantic&&(N=J?N:"[*+-]");let Q=this.rules.other.listItemRegex(N),Y=!1;for(;B;){let W=!1,K="",X="";if(!(y=Q.exec(B))||this.rules.block.hr.test(B))break;K=y[0],B=B.substring(K.length);let b=o0(y[2].split(`
22
- `,1)[0],y[1].length),P=B.split(`
23
- `,1)[0],U=!b.trim(),L=0;if(this.options.pedantic?(L=2,X=b.trimStart()):U?L=y[1].length+1:(L=b.search(this.rules.other.nonSpaceChar),L=L>4?1:L,X=b.slice(L),L+=y[1].length),U&&this.rules.other.blankLine.test(P)&&(K+=P+`
24
- `,B=B.substring(P.length+1),W=!0),!W){let q=this.rules.other.nextBulletRegex(L),G=this.rules.other.hrRegex(L),Z=this.rules.other.fencesBeginRegex(L),A=this.rules.other.headingBeginRegex(L),w=this.rules.other.htmlBeginRegex(L),C=this.rules.other.blockquoteBeginRegex(L);for(;B;){let I=B.split(`
25
- `,1)[0],z;if(P=I,this.options.pedantic?(P=P.replace(this.rules.other.listReplaceNesting," "),z=P):z=P.replace(this.rules.other.tabCharGlobal," "),Z.test(P)||A.test(P)||w.test(P)||C.test(P)||q.test(P)||G.test(P))break;if(z.search(this.rules.other.nonSpaceChar)>=L||!P.trim())X+=`
26
- `+z.slice(L);else{if(U||b.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||Z.test(b)||A.test(b)||G.test(b))break;X+=`
27
- `+P}U=!P.trim(),K+=I+`
28
- `,B=B.substring(I.length+1),b=z.slice(L)}}$.loose||(Y?$.loose=!0:this.rules.other.doubleBlankLine.test(K)&&(Y=!0)),$.items.push({type:"list_item",raw:K,task:!!this.options.gfm&&this.rules.other.listIsTask.test(X),loose:!1,text:X,tokens:[]}),$.raw+=K}let f=$.items.at(-1);if(f)f.raw=f.raw.trimEnd(),f.text=f.text.trimEnd();else return;$.raw=$.raw.trimEnd();for(let W of $.items){if(this.lexer.state.top=!1,W.tokens=this.lexer.blockTokens(W.text,[]),W.task){if(W.text=W.text.replace(this.rules.other.listReplaceTask,""),W.tokens[0]?.type==="text"||W.tokens[0]?.type==="paragraph"){W.tokens[0].raw=W.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),W.tokens[0].text=W.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let X=this.lexer.inlineQueue.length-1;X>=0;X--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[X].src)){this.lexer.inlineQueue[X].src=this.lexer.inlineQueue[X].src.replace(this.rules.other.listReplaceTask,"");break}}let K=this.rules.other.listTaskCheckbox.exec(W.raw);if(K){let X={type:"checkbox",raw:K[0]+" ",checked:K[0]!=="[ ]"};W.checked=X.checked,$.loose?W.tokens[0]&&["paragraph","text"].includes(W.tokens[0].type)&&"tokens"in W.tokens[0]&&W.tokens[0].tokens?(W.tokens[0].raw=X.raw+W.tokens[0].raw,W.tokens[0].text=X.raw+W.tokens[0].text,W.tokens[0].tokens.unshift(X)):W.tokens.unshift({type:"paragraph",raw:X.raw,text:X.raw,tokens:[X]}):W.tokens.unshift(X)}}if(!$.loose){let K=W.tokens.filter((b)=>b.type==="space"),X=K.length>0&&K.some((b)=>this.rules.other.anyLine.test(b.raw));$.loose=X}}if($.loose)for(let W of $.items){W.loose=!0;for(let K of W.tokens)K.type==="text"&&(K.type="paragraph")}return $}}html(B){let y=this.rules.block.html.exec(B);if(y)return{type:"html",block:!0,raw:y[0],pre:y[1]==="pre"||y[1]==="script"||y[1]==="style",text:y[0]}}def(B){let y=this.rules.block.def.exec(B);if(y){let N=y[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),J=y[2]?y[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",$=y[3]?y[3].substring(1,y[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):y[3];return{type:"def",tag:N,raw:y[0],href:J,title:$}}}table(B){let y=this.rules.block.table.exec(B);if(!y||!this.rules.other.tableDelimiter.test(y[2]))return;let N=J1(y[1]),J=y[2].replace(this.rules.other.tableAlignChars,"").split("|"),$=y[3]?.trim()?y[3].replace(this.rules.other.tableRowBlankLine,"").split(`
29
- `):[],Q={type:"table",raw:y[0],header:[],align:[],rows:[]};if(N.length===J.length){for(let Y of J)this.rules.other.tableAlignRight.test(Y)?Q.align.push("right"):this.rules.other.tableAlignCenter.test(Y)?Q.align.push("center"):this.rules.other.tableAlignLeft.test(Y)?Q.align.push("left"):Q.align.push(null);for(let Y=0;Y<N.length;Y++)Q.header.push({text:N[Y],tokens:this.lexer.inline(N[Y]),header:!0,align:Q.align[Y]});for(let Y of $)Q.rows.push(J1(Y,Q.header.length).map((f,W)=>({text:f,tokens:this.lexer.inline(f),header:!1,align:Q.align[W]})));return Q}}lheading(B){let y=this.rules.block.lheading.exec(B);if(y)return{type:"heading",raw:y[0],depth:y[2].charAt(0)==="="?1:2,text:y[1],tokens:this.lexer.inline(y[1])}}paragraph(B){let y=this.rules.block.paragraph.exec(B);if(y){let N=y[1].charAt(y[1].length-1)===`
30
- `?y[1].slice(0,-1):y[1];return{type:"paragraph",raw:y[0],text:N,tokens:this.lexer.inline(N)}}}text(B){let y=this.rules.block.text.exec(B);if(y)return{type:"text",raw:y[0],text:y[0],tokens:this.lexer.inline(y[0])}}escape(B){let y=this.rules.inline.escape.exec(B);if(y)return{type:"escape",raw:y[0],text:y[1]}}tag(B){let y=this.rules.inline.tag.exec(B);if(y)return!this.lexer.state.inLink&&this.rules.other.startATag.test(y[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(y[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(y[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(y[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:y[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:y[0]}}link(B){let y=this.rules.inline.link.exec(B);if(y){let N=y[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(N)){if(!this.rules.other.endAngleBracket.test(N))return;let Q=Ny(N.slice(0,-1),"\\");if((N.length-Q.length)%2===0)return}else{let Q=l0(y[2],"()");if(Q===-2)return;if(Q>-1){let Y=(y[0].indexOf("!")===0?5:4)+y[1].length+Q;y[2]=y[2].substring(0,Q),y[0]=y[0].substring(0,Y).trim(),y[3]=""}}let J=y[2],$="";if(this.options.pedantic){let Q=this.rules.other.pedanticHrefTitle.exec(J);Q&&(J=Q[1],$=Q[3])}else $=y[3]?y[3].slice(1,-1):"";return J=J.trim(),this.rules.other.startAngleBracket.test(J)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(N)?J=J.slice(1):J=J.slice(1,-1)),Q1(y,{href:J&&J.replace(this.rules.inline.anyPunctuation,"$1"),title:$&&$.replace(this.rules.inline.anyPunctuation,"$1")},y[0],this.lexer,this.rules)}}reflink(B,y){let N;if((N=this.rules.inline.reflink.exec(B))||(N=this.rules.inline.nolink.exec(B))){let J=(N[2]||N[1]).replace(this.rules.other.multipleSpaceGlobal," "),$=y[J.toLowerCase()];if(!$){let Q=N[0].charAt(0);return{type:"text",raw:Q,text:Q}}return Q1(N,$,N[0],this.lexer,this.rules)}}emStrong(B,y,N=""){let J=this.rules.inline.emStrongLDelim.exec(B);if(!J||J[3]&&N.match(this.rules.other.unicodeAlphaNumeric))return;if(!(J[1]||J[2])||!N||this.rules.inline.punctuation.exec(N)){let $=[...J[0]].length-1,Q,Y,f=$,W=0,K=J[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(K.lastIndex=0,y=y.slice(-1*B.length+$);(J=K.exec(y))!=null;){if(Q=J[1]||J[2]||J[3]||J[4]||J[5]||J[6],!Q)continue;if(Y=[...Q].length,J[3]||J[4]){f+=Y;continue}else if((J[5]||J[6])&&$%3&&!(($+Y)%3)){W+=Y;continue}if(f-=Y,f>0)continue;Y=Math.min(Y,Y+f+W);let X=[...J[0]][0].length,b=B.slice(0,$+J.index+X+Y);if(Math.min($,Y)%2){let U=b.slice(1,-1);return{type:"em",raw:b,text:U,tokens:this.lexer.inlineTokens(U)}}let P=b.slice(2,-2);return{type:"strong",raw:b,text:P,tokens:this.lexer.inlineTokens(P)}}}}codespan(B){let y=this.rules.inline.code.exec(B);if(y){let N=y[2].replace(this.rules.other.newLineCharGlobal," "),J=this.rules.other.nonSpaceChar.test(N),$=this.rules.other.startingSpaceChar.test(N)&&this.rules.other.endingSpaceChar.test(N);return J&&$&&(N=N.substring(1,N.length-1)),{type:"codespan",raw:y[0],text:N}}}br(B){let y=this.rules.inline.br.exec(B);if(y)return{type:"br",raw:y[0]}}del(B,y,N=""){let J=this.rules.inline.delLDelim.exec(B);if(!J)return;if(!J[1]||!N||this.rules.inline.punctuation.exec(N)){let $=[...J[0]].length-1,Q,Y,f=$,W=this.rules.inline.delRDelim;for(W.lastIndex=0,y=y.slice(-1*B.length+$);(J=W.exec(y))!=null;){if(Q=J[1]||J[2]||J[3]||J[4]||J[5]||J[6],!Q||(Y=[...Q].length,Y!==$))continue;if(J[3]||J[4]){f+=Y;continue}if(f-=Y,f>0)continue;Y=Math.min(Y,Y+f);let K=[...J[0]][0].length,X=B.slice(0,$+J.index+K+Y),b=X.slice($,-$);return{type:"del",raw:X,text:b,tokens:this.lexer.inlineTokens(b)}}}}autolink(B){let y=this.rules.inline.autolink.exec(B);if(y){let N,J;return y[2]==="@"?(N=y[1],J="mailto:"+N):(N=y[1],J=N),{type:"link",raw:y[0],text:N,href:J,tokens:[{type:"text",raw:N,text:N}]}}}url(B){let y;if(y=this.rules.inline.url.exec(B)){let N,J;if(y[2]==="@")N=y[0],J="mailto:"+N;else{let $;do $=y[0],y[0]=this.rules.inline._backpedal.exec(y[0])?.[0]??"";while($!==y[0]);N=y[0],y[1]==="www."?J="http://"+y[0]:J=y[0]}return{type:"link",raw:y[0],text:N,href:J,tokens:[{type:"text",raw:N,text:N}]}}}inlineText(B){let y=this.rules.inline.text.exec(B);if(y){let N=this.lexer.state.inRawBlock;return{type:"text",raw:y[0],text:y[0],escaped:N}}}},j=class B{tokens;options;state;inlineQueue;tokenizer;constructor(y){this.tokens=[],this.tokens.links=Object.create(null),this.options=y||a,this.options.tokenizer=this.options.tokenizer||new Py,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:R,block:Ly.normal,inline:By.normal};this.options.pedantic?(N.block=Ly.pedantic,N.inline=By.pedantic):this.options.gfm&&(N.block=Ly.gfm,this.options.breaks?N.inline=By.breaks:N.inline=By.gfm),this.tokenizer.rules=N}static get rules(){return{block:Ly,inline:By}}static lex(y,N){return new B(N).lex(y)}static lexInline(y,N){return new B(N).inlineTokens(y)}lex(y){y=y.replace(R.carriageReturn,`
31
- `),this.blockTokens(y,this.tokens);for(let N=0;N<this.inlineQueue.length;N++){let J=this.inlineQueue[N];this.inlineTokens(J.src,J.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(y,N=[],J=!1){for(this.options.pedantic&&(y=y.replace(R.tabCharGlobal," ").replace(R.spaceLine,""));y;){let $;if(this.options.extensions?.block?.some((Y)=>($=Y.call({lexer:this},y,N))?(y=y.substring($.raw.length),N.push($),!0):!1))continue;if($=this.tokenizer.space(y)){y=y.substring($.raw.length);let Y=N.at(-1);$.raw.length===1&&Y!==void 0?Y.raw+=`
32
- `:N.push($);continue}if($=this.tokenizer.code(y)){y=y.substring($.raw.length);let Y=N.at(-1);Y?.type==="paragraph"||Y?.type==="text"?(Y.raw+=(Y.raw.endsWith(`
12
+ `),Y="",$="",B=[];for(;Q.length>0;){let W=!1,K=[],X;for(X=0;X<Q.length;X++)if(this.rules.other.blockquoteStart.test(Q[X]))K.push(Q[X]),W=!0;else if(!W)K.push(Q[X]);else break;Q=Q.slice(X);let L=K.join(`
13
+ `),N=L.replace(this.rules.other.blockquoteSetextReplace,`
14
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");Y=Y?`${Y}
15
+ ${L}`:L,$=$?`${$}
16
+ ${N}`:N;let G=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(N,B,!0),this.lexer.state.top=G,Q.length===0)break;let H=B.at(-1);if(H?.type==="code")break;if(H?.type==="blockquote"){let b=H,q=b.raw+`
17
+ `+Q.join(`
18
+ `),T=this.blockquote(q);B[B.length-1]=T,Y=Y.substring(0,Y.length-b.raw.length)+T.raw,$=$.substring(0,$.length-b.text.length)+T.text;break}else if(H?.type==="list"){let b=H,q=b.raw+`
19
+ `+Q.join(`
20
+ `),T=this.list(q);B[B.length-1]=T,Y=Y.substring(0,Y.length-H.raw.length)+T.raw,$=$.substring(0,$.length-b.raw.length)+T.raw,Q=q.substring(B.at(-1).raw.length).split(`
21
+ `);continue}}return{type:"blockquote",raw:Y,tokens:B,text:$}}}list(J){let y=this.rules.block.list.exec(J);if(y){let Q=y[1].trim(),Y=Q.length>1,$={type:"list",raw:"",ordered:Y,start:Y?+Q.slice(0,-1):"",loose:!1,items:[]};Q=Y?`\\d{1,9}\\${Q.slice(-1)}`:`\\${Q}`,this.options.pedantic&&(Q=Y?Q:"[*+-]");let B=this.rules.other.listItemRegex(Q),W=!1;for(;J;){let X=!1,L="",N="";if(!(y=B.exec(J))||this.rules.block.hr.test(J))break;L=y[0],J=J.substring(L.length);let G=b5(y[2].split(`
22
+ `,1)[0],y[1].length),H=J.split(`
23
+ `,1)[0],b=!G.trim(),q=0;if(this.options.pedantic?(q=2,N=G.trimStart()):b?q=y[1].length+1:(q=G.search(this.rules.other.nonSpaceChar),q=q>4?1:q,N=G.slice(q),q+=y[1].length),b&&this.rules.other.blankLine.test(H)&&(L+=H+`
24
+ `,J=J.substring(H.length+1),X=!0),!X){let T=this.rules.other.nextBulletRegex(q),P=this.rules.other.hrRegex(q),v=this.rules.other.fencesBeginRegex(q),A=this.rules.other.headingBeginRegex(q),O=this.rules.other.htmlBeginRegex(q),c=this.rules.other.blockquoteBeginRegex(q);for(;J;){let V=J.split(`
25
+ `,1)[0],k;if(H=V,this.options.pedantic?(H=H.replace(this.rules.other.listReplaceNesting," "),k=H):k=H.replace(this.rules.other.tabCharGlobal," "),v.test(H)||A.test(H)||O.test(H)||c.test(H)||T.test(H)||P.test(H))break;if(k.search(this.rules.other.nonSpaceChar)>=q||!H.trim())N+=`
26
+ `+k.slice(q);else{if(b||G.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||v.test(G)||A.test(G)||P.test(G))break;N+=`
27
+ `+H}b=!H.trim(),L+=V+`
28
+ `,J=J.substring(V.length+1),G=k.slice(q)}}$.loose||(W?$.loose=!0:this.rules.other.doubleBlankLine.test(L)&&(W=!0)),$.items.push({type:"list_item",raw:L,task:!!this.options.gfm&&this.rules.other.listIsTask.test(N),loose:!1,text:N,tokens:[]}),$.raw+=L}let K=$.items.at(-1);if(K)K.raw=K.raw.trimEnd(),K.text=K.text.trimEnd();else return;$.raw=$.raw.trimEnd();for(let X of $.items){if(this.lexer.state.top=!1,X.tokens=this.lexer.blockTokens(X.text,[]),X.task){if(X.text=X.text.replace(this.rules.other.listReplaceTask,""),X.tokens[0]?.type==="text"||X.tokens[0]?.type==="paragraph"){X.tokens[0].raw=X.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),X.tokens[0].text=X.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let N=this.lexer.inlineQueue.length-1;N>=0;N--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[N].src)){this.lexer.inlineQueue[N].src=this.lexer.inlineQueue[N].src.replace(this.rules.other.listReplaceTask,"");break}}let L=this.rules.other.listTaskCheckbox.exec(X.raw);if(L){let N={type:"checkbox",raw:L[0]+" ",checked:L[0]!=="[ ]"};X.checked=N.checked,$.loose?X.tokens[0]&&["paragraph","text"].includes(X.tokens[0].type)&&"tokens"in X.tokens[0]&&X.tokens[0].tokens?(X.tokens[0].raw=N.raw+X.tokens[0].raw,X.tokens[0].text=N.raw+X.tokens[0].text,X.tokens[0].tokens.unshift(N)):X.tokens.unshift({type:"paragraph",raw:N.raw,text:N.raw,tokens:[N]}):X.tokens.unshift(N)}}if(!$.loose){let L=X.tokens.filter((G)=>G.type==="space"),N=L.length>0&&L.some((G)=>this.rules.other.anyLine.test(G.raw));$.loose=N}}if($.loose)for(let X of $.items){X.loose=!0;for(let L of X.tokens)L.type==="text"&&(L.type="paragraph")}return $}}html(J){let y=this.rules.block.html.exec(J);if(y)return{type:"html",block:!0,raw:y[0],pre:y[1]==="pre"||y[1]==="script"||y[1]==="style",text:y[0]}}def(J){let y=this.rules.block.def.exec(J);if(y){let Q=y[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),Y=y[2]?y[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",$=y[3]?y[3].substring(1,y[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):y[3];return{type:"def",tag:Q,raw:y[0],href:Y,title:$}}}table(J){let y=this.rules.block.table.exec(J);if(!y||!this.rules.other.tableDelimiter.test(y[2]))return;let Q=w0(y[1]),Y=y[2].replace(this.rules.other.tableAlignChars,"").split("|"),$=y[3]?.trim()?y[3].replace(this.rules.other.tableRowBlankLine,"").split(`
29
+ `):[],B={type:"table",raw:y[0],header:[],align:[],rows:[]};if(Q.length===Y.length){for(let W of Y)this.rules.other.tableAlignRight.test(W)?B.align.push("right"):this.rules.other.tableAlignCenter.test(W)?B.align.push("center"):this.rules.other.tableAlignLeft.test(W)?B.align.push("left"):B.align.push(null);for(let W=0;W<Q.length;W++)B.header.push({text:Q[W],tokens:this.lexer.inline(Q[W]),header:!0,align:B.align[W]});for(let W of $)B.rows.push(w0(W,B.header.length).map((K,X)=>({text:K,tokens:this.lexer.inline(K),header:!1,align:B.align[X]})));return B}}lheading(J){let y=this.rules.block.lheading.exec(J);if(y)return{type:"heading",raw:y[0],depth:y[2].charAt(0)==="="?1:2,text:y[1],tokens:this.lexer.inline(y[1])}}paragraph(J){let y=this.rules.block.paragraph.exec(J);if(y){let Q=y[1].charAt(y[1].length-1)===`
30
+ `?y[1].slice(0,-1):y[1];return{type:"paragraph",raw:y[0],text:Q,tokens:this.lexer.inline(Q)}}}text(J){let y=this.rules.block.text.exec(J);if(y)return{type:"text",raw:y[0],text:y[0],tokens:this.lexer.inline(y[0])}}escape(J){let y=this.rules.inline.escape.exec(J);if(y)return{type:"escape",raw:y[0],text:y[1]}}tag(J){let y=this.rules.inline.tag.exec(J);if(y)return!this.lexer.state.inLink&&this.rules.other.startATag.test(y[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(y[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(y[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(y[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:y[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:y[0]}}link(J){let y=this.rules.inline.link.exec(J);if(y){let Q=y[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(Q)){if(!this.rules.other.endAngleBracket.test(Q))return;let B=T1(Q.slice(0,-1),"\\");if((Q.length-B.length)%2===0)return}else{let B=P5(y[2],"()");if(B===-2)return;if(B>-1){let W=(y[0].indexOf("!")===0?5:4)+y[1].length+B;y[2]=y[2].substring(0,B),y[0]=y[0].substring(0,W).trim(),y[3]=""}}let Y=y[2],$="";if(this.options.pedantic){let B=this.rules.other.pedanticHrefTitle.exec(Y);B&&(Y=B[1],$=B[3])}else $=y[3]?y[3].slice(1,-1):"";return Y=Y.trim(),this.rules.other.startAngleBracket.test(Y)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(Q)?Y=Y.slice(1):Y=Y.slice(1,-1)),M0(y,{href:Y&&Y.replace(this.rules.inline.anyPunctuation,"$1"),title:$&&$.replace(this.rules.inline.anyPunctuation,"$1")},y[0],this.lexer,this.rules)}}reflink(J,y){let Q;if((Q=this.rules.inline.reflink.exec(J))||(Q=this.rules.inline.nolink.exec(J))){let Y=(Q[2]||Q[1]).replace(this.rules.other.multipleSpaceGlobal," "),$=y[Y.toLowerCase()];if(!$){let B=Q[0].charAt(0);return{type:"text",raw:B,text:B}}return M0(Q,$,Q[0],this.lexer,this.rules)}}emStrong(J,y,Q=""){let Y=this.rules.inline.emStrongLDelim.exec(J);if(!Y||Y[3]&&Q.match(this.rules.other.unicodeAlphaNumeric))return;if(!(Y[1]||Y[2])||!Q||this.rules.inline.punctuation.exec(Q)){let $=[...Y[0]].length-1,B,W,K=$,X=0,L=Y[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(L.lastIndex=0,y=y.slice(-1*J.length+$);(Y=L.exec(y))!=null;){if(B=Y[1]||Y[2]||Y[3]||Y[4]||Y[5]||Y[6],!B)continue;if(W=[...B].length,Y[3]||Y[4]){K+=W;continue}else if((Y[5]||Y[6])&&$%3&&!(($+W)%3)){X+=W;continue}if(K-=W,K>0)continue;W=Math.min(W,W+K+X);let N=[...Y[0]][0].length,G=J.slice(0,$+Y.index+N+W);if(Math.min($,W)%2){let b=G.slice(1,-1);return{type:"em",raw:G,text:b,tokens:this.lexer.inlineTokens(b)}}let H=G.slice(2,-2);return{type:"strong",raw:G,text:H,tokens:this.lexer.inlineTokens(H)}}}}codespan(J){let y=this.rules.inline.code.exec(J);if(y){let Q=y[2].replace(this.rules.other.newLineCharGlobal," "),Y=this.rules.other.nonSpaceChar.test(Q),$=this.rules.other.startingSpaceChar.test(Q)&&this.rules.other.endingSpaceChar.test(Q);return Y&&$&&(Q=Q.substring(1,Q.length-1)),{type:"codespan",raw:y[0],text:Q}}}br(J){let y=this.rules.inline.br.exec(J);if(y)return{type:"br",raw:y[0]}}del(J,y,Q=""){let Y=this.rules.inline.delLDelim.exec(J);if(!Y)return;if(!Y[1]||!Q||this.rules.inline.punctuation.exec(Q)){let $=[...Y[0]].length-1,B,W,K=$,X=this.rules.inline.delRDelim;for(X.lastIndex=0,y=y.slice(-1*J.length+$);(Y=X.exec(y))!=null;){if(B=Y[1]||Y[2]||Y[3]||Y[4]||Y[5]||Y[6],!B||(W=[...B].length,W!==$))continue;if(Y[3]||Y[4]){K+=W;continue}if(K-=W,K>0)continue;W=Math.min(W,W+K);let L=[...Y[0]][0].length,N=J.slice(0,$+Y.index+L+W),G=N.slice($,-$);return{type:"del",raw:N,text:G,tokens:this.lexer.inlineTokens(G)}}}}autolink(J){let y=this.rules.inline.autolink.exec(J);if(y){let Q,Y;return y[2]==="@"?(Q=y[1],Y="mailto:"+Q):(Q=y[1],Y=Q),{type:"link",raw:y[0],text:Q,href:Y,tokens:[{type:"text",raw:Q,text:Q}]}}}url(J){let y;if(y=this.rules.inline.url.exec(J)){let Q,Y;if(y[2]==="@")Q=y[0],Y="mailto:"+Q;else{let $;do $=y[0],y[0]=this.rules.inline._backpedal.exec(y[0])?.[0]??"";while($!==y[0]);Q=y[0],y[1]==="www."?Y="http://"+y[0]:Y=y[0]}return{type:"link",raw:y[0],text:Q,href:Y,tokens:[{type:"text",raw:Q,text:Q}]}}}inlineText(J){let y=this.rules.inline.text.exec(J);if(y){let Q=this.lexer.state.inRawBlock;return{type:"text",raw:y[0],text:y[0],escaped:Q}}}},u=class J{tokens;options;state;inlineQueue;tokenizer;constructor(y){this.tokens=[],this.tokens.links=Object.create(null),this.options=y||W1,this.options.tokenizer=this.options.tokenizer||new I1,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 Q={other:j,block:O1.normal,inline:b1.normal};this.options.pedantic?(Q.block=O1.pedantic,Q.inline=b1.pedantic):this.options.gfm&&(Q.block=O1.gfm,this.options.breaks?Q.inline=b1.breaks:Q.inline=b1.gfm),this.tokenizer.rules=Q}static get rules(){return{block:O1,inline:b1}}static lex(y,Q){return new J(Q).lex(y)}static lexInline(y,Q){return new J(Q).inlineTokens(y)}lex(y){y=y.replace(j.carriageReturn,`
31
+ `),this.blockTokens(y,this.tokens);for(let Q=0;Q<this.inlineQueue.length;Q++){let Y=this.inlineQueue[Q];this.inlineTokens(Y.src,Y.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(y,Q=[],Y=!1){for(this.options.pedantic&&(y=y.replace(j.tabCharGlobal," ").replace(j.spaceLine,""));y;){let $;if(this.options.extensions?.block?.some((W)=>($=W.call({lexer:this},y,Q))?(y=y.substring($.raw.length),Q.push($),!0):!1))continue;if($=this.tokenizer.space(y)){y=y.substring($.raw.length);let W=Q.at(-1);$.raw.length===1&&W!==void 0?W.raw+=`
32
+ `:Q.push($);continue}if($=this.tokenizer.code(y)){y=y.substring($.raw.length);let W=Q.at(-1);W?.type==="paragraph"||W?.type==="text"?(W.raw+=(W.raw.endsWith(`
33
33
  `)?"":`
34
- `)+$.raw,Y.text+=`
35
- `+$.text,this.inlineQueue.at(-1).src=Y.text):N.push($);continue}if($=this.tokenizer.fences(y)){y=y.substring($.raw.length),N.push($);continue}if($=this.tokenizer.heading(y)){y=y.substring($.raw.length),N.push($);continue}if($=this.tokenizer.hr(y)){y=y.substring($.raw.length),N.push($);continue}if($=this.tokenizer.blockquote(y)){y=y.substring($.raw.length),N.push($);continue}if($=this.tokenizer.list(y)){y=y.substring($.raw.length),N.push($);continue}if($=this.tokenizer.html(y)){y=y.substring($.raw.length),N.push($);continue}if($=this.tokenizer.def(y)){y=y.substring($.raw.length);let Y=N.at(-1);Y?.type==="paragraph"||Y?.type==="text"?(Y.raw+=(Y.raw.endsWith(`
34
+ `)+$.raw,W.text+=`
35
+ `+$.text,this.inlineQueue.at(-1).src=W.text):Q.push($);continue}if($=this.tokenizer.fences(y)){y=y.substring($.raw.length),Q.push($);continue}if($=this.tokenizer.heading(y)){y=y.substring($.raw.length),Q.push($);continue}if($=this.tokenizer.hr(y)){y=y.substring($.raw.length),Q.push($);continue}if($=this.tokenizer.blockquote(y)){y=y.substring($.raw.length),Q.push($);continue}if($=this.tokenizer.list(y)){y=y.substring($.raw.length),Q.push($);continue}if($=this.tokenizer.html(y)){y=y.substring($.raw.length),Q.push($);continue}if($=this.tokenizer.def(y)){y=y.substring($.raw.length);let W=Q.at(-1);W?.type==="paragraph"||W?.type==="text"?(W.raw+=(W.raw.endsWith(`
36
36
  `)?"":`
37
- `)+$.raw,Y.text+=`
38
- `+$.raw,this.inlineQueue.at(-1).src=Y.text):this.tokens.links[$.tag]||(this.tokens.links[$.tag]={href:$.href,title:$.title},N.push($));continue}if($=this.tokenizer.table(y)){y=y.substring($.raw.length),N.push($);continue}if($=this.tokenizer.lheading(y)){y=y.substring($.raw.length),N.push($);continue}let Q=y;if(this.options.extensions?.startBlock){let Y=1/0,f=y.slice(1),W;this.options.extensions.startBlock.forEach((K)=>{W=K.call({lexer:this},f),typeof W=="number"&&W>=0&&(Y=Math.min(Y,W))}),Y<1/0&&Y>=0&&(Q=y.substring(0,Y+1))}if(this.state.top&&($=this.tokenizer.paragraph(Q))){let Y=N.at(-1);J&&Y?.type==="paragraph"?(Y.raw+=(Y.raw.endsWith(`
37
+ `)+$.raw,W.text+=`
38
+ `+$.raw,this.inlineQueue.at(-1).src=W.text):this.tokens.links[$.tag]||(this.tokens.links[$.tag]={href:$.href,title:$.title},Q.push($));continue}if($=this.tokenizer.table(y)){y=y.substring($.raw.length),Q.push($);continue}if($=this.tokenizer.lheading(y)){y=y.substring($.raw.length),Q.push($);continue}let B=y;if(this.options.extensions?.startBlock){let W=1/0,K=y.slice(1),X;this.options.extensions.startBlock.forEach((L)=>{X=L.call({lexer:this},K),typeof X=="number"&&X>=0&&(W=Math.min(W,X))}),W<1/0&&W>=0&&(B=y.substring(0,W+1))}if(this.state.top&&($=this.tokenizer.paragraph(B))){let W=Q.at(-1);Y&&W?.type==="paragraph"?(W.raw+=(W.raw.endsWith(`
39
39
  `)?"":`
40
- `)+$.raw,Y.text+=`
41
- `+$.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=Y.text):N.push($),J=Q.length!==y.length,y=y.substring($.raw.length);continue}if($=this.tokenizer.text(y)){y=y.substring($.raw.length);let Y=N.at(-1);Y?.type==="text"?(Y.raw+=(Y.raw.endsWith(`
40
+ `)+$.raw,W.text+=`
41
+ `+$.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=W.text):Q.push($),Y=B.length!==y.length,y=y.substring($.raw.length);continue}if($=this.tokenizer.text(y)){y=y.substring($.raw.length);let W=Q.at(-1);W?.type==="text"?(W.raw+=(W.raw.endsWith(`
42
42
  `)?"":`
43
- `)+$.raw,Y.text+=`
44
- `+$.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=Y.text):N.push($);continue}if(y){let Y="Infinite loop on byte: "+y.charCodeAt(0);if(this.options.silent){console.error(Y);break}else throw Error(Y)}}return this.state.top=!0,N}inline(y,N=[]){return this.inlineQueue.push({src:y,tokens:N}),N}inlineTokens(y,N=[]){let J=y,$=null;if(this.tokens.links){let W=Object.keys(this.tokens.links);if(W.length>0)for(;($=this.tokenizer.rules.inline.reflinkSearch.exec(J))!=null;)W.includes($[0].slice($[0].lastIndexOf("[")+1,-1))&&(J=J.slice(0,$.index)+"["+"a".repeat($[0].length-2)+"]"+J.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;($=this.tokenizer.rules.inline.anyPunctuation.exec(J))!=null;)J=J.slice(0,$.index)+"++"+J.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let Q;for(;($=this.tokenizer.rules.inline.blockSkip.exec(J))!=null;)Q=$[2]?$[2].length:0,J=J.slice(0,$.index+Q)+"["+"a".repeat($[0].length-Q-2)+"]"+J.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);J=this.options.hooks?.emStrongMask?.call({lexer:this},J)??J;let Y=!1,f="";for(;y;){Y||(f=""),Y=!1;let W;if(this.options.extensions?.inline?.some((X)=>(W=X.call({lexer:this},y,N))?(y=y.substring(W.raw.length),N.push(W),!0):!1))continue;if(W=this.tokenizer.escape(y)){y=y.substring(W.raw.length),N.push(W);continue}if(W=this.tokenizer.tag(y)){y=y.substring(W.raw.length),N.push(W);continue}if(W=this.tokenizer.link(y)){y=y.substring(W.raw.length),N.push(W);continue}if(W=this.tokenizer.reflink(y,this.tokens.links)){y=y.substring(W.raw.length);let X=N.at(-1);W.type==="text"&&X?.type==="text"?(X.raw+=W.raw,X.text+=W.text):N.push(W);continue}if(W=this.tokenizer.emStrong(y,J,f)){y=y.substring(W.raw.length),N.push(W);continue}if(W=this.tokenizer.codespan(y)){y=y.substring(W.raw.length),N.push(W);continue}if(W=this.tokenizer.br(y)){y=y.substring(W.raw.length),N.push(W);continue}if(W=this.tokenizer.del(y,J,f)){y=y.substring(W.raw.length),N.push(W);continue}if(W=this.tokenizer.autolink(y)){y=y.substring(W.raw.length),N.push(W);continue}if(!this.state.inLink&&(W=this.tokenizer.url(y))){y=y.substring(W.raw.length),N.push(W);continue}let K=y;if(this.options.extensions?.startInline){let X=1/0,b=y.slice(1),P;this.options.extensions.startInline.forEach((U)=>{P=U.call({lexer:this},b),typeof P=="number"&&P>=0&&(X=Math.min(X,P))}),X<1/0&&X>=0&&(K=y.substring(0,X+1))}if(W=this.tokenizer.inlineText(K)){y=y.substring(W.raw.length),W.raw.slice(-1)!=="_"&&(f=W.raw.slice(-1)),Y=!0;let X=N.at(-1);X?.type==="text"?(X.raw+=W.raw,X.text+=W.text):N.push(W);continue}if(y){let X="Infinite loop on byte: "+y.charCodeAt(0);if(this.options.silent){console.error(X);break}else throw Error(X)}}return N}},Hy=class{options;parser;constructor(B){this.options=B||a}space(B){return""}code({text:B,lang:y,escaped:N}){let J=(y||"").match(R.notSpaceStart)?.[0],$=B.replace(R.endingNewline,"")+`
45
- `;return J?'<pre><code class="language-'+d(J)+'">'+(N?$:d($,!0))+`</code></pre>
46
- `:"<pre><code>"+(N?$:d($,!0))+`</code></pre>
47
- `}blockquote({tokens:B}){return`<blockquote>
48
- ${this.parser.parse(B)}</blockquote>
49
- `}html({text:B}){return B}def(B){return""}heading({tokens:B,depth:y}){return`<h${y}>${this.parser.parseInline(B)}</h${y}>
50
- `}hr(B){return`<hr>
51
- `}list(B){let{ordered:y,start:N}=B,J="";for(let Y=0;Y<B.items.length;Y++){let f=B.items[Y];J+=this.listitem(f)}let $=y?"ol":"ul",Q=y&&N!==1?' start="'+N+'"':"";return"<"+$+Q+`>
52
- `+J+"</"+$+`>
53
- `}listitem(B){return`<li>${this.parser.parse(B.tokens)}</li>
54
- `}checkbox({checked:B}){return"<input "+(B?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:B}){return`<p>${this.parser.parseInline(B)}</p>
55
- `}table(B){let y="",N="";for(let $=0;$<B.header.length;$++)N+=this.tablecell(B.header[$]);y+=this.tablerow({text:N});let J="";for(let $=0;$<B.rows.length;$++){let Q=B.rows[$];N="";for(let Y=0;Y<Q.length;Y++)N+=this.tablecell(Q[Y]);J+=this.tablerow({text:N})}return J&&(J=`<tbody>${J}</tbody>`),`<table>
43
+ `)+$.raw,W.text+=`
44
+ `+$.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=W.text):Q.push($);continue}if(y){let W="Infinite loop on byte: "+y.charCodeAt(0);if(this.options.silent){console.error(W);break}else throw Error(W)}}return this.state.top=!0,Q}inline(y,Q=[]){return this.inlineQueue.push({src:y,tokens:Q}),Q}inlineTokens(y,Q=[]){let Y=y,$=null;if(this.tokens.links){let X=Object.keys(this.tokens.links);if(X.length>0)for(;($=this.tokenizer.rules.inline.reflinkSearch.exec(Y))!=null;)X.includes($[0].slice($[0].lastIndexOf("[")+1,-1))&&(Y=Y.slice(0,$.index)+"["+"a".repeat($[0].length-2)+"]"+Y.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;($=this.tokenizer.rules.inline.anyPunctuation.exec(Y))!=null;)Y=Y.slice(0,$.index)+"++"+Y.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let B;for(;($=this.tokenizer.rules.inline.blockSkip.exec(Y))!=null;)B=$[2]?$[2].length:0,Y=Y.slice(0,$.index+B)+"["+"a".repeat($[0].length-B-2)+"]"+Y.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);Y=this.options.hooks?.emStrongMask?.call({lexer:this},Y)??Y;let W=!1,K="";for(;y;){W||(K=""),W=!1;let X;if(this.options.extensions?.inline?.some((N)=>(X=N.call({lexer:this},y,Q))?(y=y.substring(X.raw.length),Q.push(X),!0):!1))continue;if(X=this.tokenizer.escape(y)){y=y.substring(X.raw.length),Q.push(X);continue}if(X=this.tokenizer.tag(y)){y=y.substring(X.raw.length),Q.push(X);continue}if(X=this.tokenizer.link(y)){y=y.substring(X.raw.length),Q.push(X);continue}if(X=this.tokenizer.reflink(y,this.tokens.links)){y=y.substring(X.raw.length);let N=Q.at(-1);X.type==="text"&&N?.type==="text"?(N.raw+=X.raw,N.text+=X.text):Q.push(X);continue}if(X=this.tokenizer.emStrong(y,Y,K)){y=y.substring(X.raw.length),Q.push(X);continue}if(X=this.tokenizer.codespan(y)){y=y.substring(X.raw.length),Q.push(X);continue}if(X=this.tokenizer.br(y)){y=y.substring(X.raw.length),Q.push(X);continue}if(X=this.tokenizer.del(y,Y,K)){y=y.substring(X.raw.length),Q.push(X);continue}if(X=this.tokenizer.autolink(y)){y=y.substring(X.raw.length),Q.push(X);continue}if(!this.state.inLink&&(X=this.tokenizer.url(y))){y=y.substring(X.raw.length),Q.push(X);continue}let L=y;if(this.options.extensions?.startInline){let N=1/0,G=y.slice(1),H;this.options.extensions.startInline.forEach((b)=>{H=b.call({lexer:this},G),typeof H=="number"&&H>=0&&(N=Math.min(N,H))}),N<1/0&&N>=0&&(L=y.substring(0,N+1))}if(X=this.tokenizer.inlineText(L)){y=y.substring(X.raw.length),X.raw.slice(-1)!=="_"&&(K=X.raw.slice(-1)),W=!0;let N=Q.at(-1);N?.type==="text"?(N.raw+=X.raw,N.text+=X.text):Q.push(X);continue}if(y){let N="Infinite loop on byte: "+y.charCodeAt(0);if(this.options.silent){console.error(N);break}else throw Error(N)}}return Q}},m1=class{options;parser;constructor(J){this.options=J||W1}space(J){return""}code({text:J,lang:y,escaped:Q}){let Y=(y||"").match(j.notSpaceStart)?.[0],$=J.replace(j.endingNewline,"")+`
45
+ `;return Y?'<pre><code class="language-'+a(Y)+'">'+(Q?$:a($,!0))+`</code></pre>
46
+ `:"<pre><code>"+(Q?$:a($,!0))+`</code></pre>
47
+ `}blockquote({tokens:J}){return`<blockquote>
48
+ ${this.parser.parse(J)}</blockquote>
49
+ `}html({text:J}){return J}def(J){return""}heading({tokens:J,depth:y}){return`<h${y}>${this.parser.parseInline(J)}</h${y}>
50
+ `}hr(J){return`<hr>
51
+ `}list(J){let{ordered:y,start:Q}=J,Y="";for(let W=0;W<J.items.length;W++){let K=J.items[W];Y+=this.listitem(K)}let $=y?"ol":"ul",B=y&&Q!==1?' start="'+Q+'"':"";return"<"+$+B+`>
52
+ `+Y+"</"+$+`>
53
+ `}listitem(J){return`<li>${this.parser.parse(J.tokens)}</li>
54
+ `}checkbox({checked:J}){return"<input "+(J?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:J}){return`<p>${this.parser.parseInline(J)}</p>
55
+ `}table(J){let y="",Q="";for(let $=0;$<J.header.length;$++)Q+=this.tablecell(J.header[$]);y+=this.tablerow({text:Q});let Y="";for(let $=0;$<J.rows.length;$++){let B=J.rows[$];Q="";for(let W=0;W<B.length;W++)Q+=this.tablecell(B[W]);Y+=this.tablerow({text:Q})}return Y&&(Y=`<tbody>${Y}</tbody>`),`<table>
56
56
  <thead>
57
57
  `+y+`</thead>
58
- `+J+`</table>
59
- `}tablerow({text:B}){return`<tr>
60
- ${B}</tr>
61
- `}tablecell(B){let y=this.parser.parseInline(B.tokens),N=B.header?"th":"td";return(B.align?`<${N} align="${B.align}">`:`<${N}>`)+y+`</${N}>
62
- `}strong({tokens:B}){return`<strong>${this.parser.parseInline(B)}</strong>`}em({tokens:B}){return`<em>${this.parser.parseInline(B)}</em>`}codespan({text:B}){return`<code>${d(B,!0)}</code>`}br(B){return"<br>"}del({tokens:B}){return`<del>${this.parser.parseInline(B)}</del>`}link({href:B,title:y,tokens:N}){let J=this.parser.parseInline(N),$=N1(B);if($===null)return J;B=$;let Q='<a href="'+B+'"';return y&&(Q+=' title="'+d(y)+'"'),Q+=">"+J+"</a>",Q}image({href:B,title:y,text:N,tokens:J}){J&&(N=this.parser.parseInline(J,this.parser.textRenderer));let $=N1(B);if($===null)return d(N);B=$;let Q=`<img src="${B}" alt="${d(N)}"`;return y&&(Q+=` title="${d(y)}"`),Q+=">",Q}text(B){return"tokens"in B&&B.tokens?this.parser.parseInline(B.tokens):("escaped"in B)&&B.escaped?B.text:d(B.text)}},Ry=class{strong({text:B}){return B}em({text:B}){return B}codespan({text:B}){return B}del({text:B}){return B}html({text:B}){return B}text({text:B}){return B}link({text:B}){return""+B}image({text:B}){return""+B}br(){return""}checkbox({raw:B}){return B}},V=class B{options;renderer;textRenderer;constructor(y){this.options=y||a,this.options.renderer=this.options.renderer||new Hy,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ry}static parse(y,N){return new B(N).parse(y)}static parseInline(y,N){return new B(N).parseInline(y)}parse(y){let N="";for(let J=0;J<y.length;J++){let $=y[J];if(this.options.extensions?.renderers?.[$.type]){let Y=$,f=this.options.extensions.renderers[Y.type].call({parser:this},Y);if(f!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(Y.type)){N+=f||"";continue}}let Q=$;switch(Q.type){case"space":{N+=this.renderer.space(Q);break}case"hr":{N+=this.renderer.hr(Q);break}case"heading":{N+=this.renderer.heading(Q);break}case"code":{N+=this.renderer.code(Q);break}case"table":{N+=this.renderer.table(Q);break}case"blockquote":{N+=this.renderer.blockquote(Q);break}case"list":{N+=this.renderer.list(Q);break}case"checkbox":{N+=this.renderer.checkbox(Q);break}case"html":{N+=this.renderer.html(Q);break}case"def":{N+=this.renderer.def(Q);break}case"paragraph":{N+=this.renderer.paragraph(Q);break}case"text":{N+=this.renderer.text(Q);break}default:{let Y='Token with "'+Q.type+'" type was not found.';if(this.options.silent)return console.error(Y),"";throw Error(Y)}}}return N}parseInline(y,N=this.renderer){let J="";for(let $=0;$<y.length;$++){let Q=y[$];if(this.options.extensions?.renderers?.[Q.type]){let f=this.options.extensions.renderers[Q.type].call({parser:this},Q);if(f!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(Q.type)){J+=f||"";continue}}let Y=Q;switch(Y.type){case"escape":{J+=N.text(Y);break}case"html":{J+=N.html(Y);break}case"link":{J+=N.link(Y);break}case"image":{J+=N.image(Y);break}case"checkbox":{J+=N.checkbox(Y);break}case"strong":{J+=N.strong(Y);break}case"em":{J+=N.em(Y);break}case"codespan":{J+=N.codespan(Y);break}case"br":{J+=N.br(Y);break}case"del":{J+=N.del(Y);break}case"text":{J+=N.text(Y);break}default:{let f='Token with "'+Y.type+'" type was not found.';if(this.options.silent)return console.error(f),"";throw Error(f)}}}return J}},Jy=class{options;block;constructor(B){this.options=B||a}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(B){return B}postprocess(B){return B}processAllTokens(B){return B}emStrongMask(B){return B}provideLexer(){return this.block?j.lex:j.lexInline}provideParser(){return this.block?V.parse:V.parseInline}},n0=class{defaults=wy();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=V;Renderer=Hy;TextRenderer=Ry;Lexer=j;Tokenizer=Py;Hooks=Jy;constructor(...B){this.use(...B)}walkTokens(B,y){let N=[];for(let J of B)switch(N=N.concat(y.call(this,J)),J.type){case"table":{let $=J;for(let Q of $.header)N=N.concat(this.walkTokens(Q.tokens,y));for(let Q of $.rows)for(let Y of Q)N=N.concat(this.walkTokens(Y.tokens,y));break}case"list":{let $=J;N=N.concat(this.walkTokens($.items,y));break}default:{let $=J;this.defaults.extensions?.childTokens?.[$.type]?this.defaults.extensions.childTokens[$.type].forEach((Q)=>{let Y=$[Q].flat(1/0);N=N.concat(this.walkTokens(Y,y))}):$.tokens&&(N=N.concat(this.walkTokens($.tokens,y)))}}return N}use(...B){let y=this.defaults.extensions||{renderers:{},childTokens:{}};return B.forEach((N)=>{let J={...N};if(J.async=this.defaults.async||J.async||!1,N.extensions&&(N.extensions.forEach(($)=>{if(!$.name)throw Error("extension name required");if("renderer"in $){let Q=y.renderers[$.name];Q?y.renderers[$.name]=function(...Y){let f=$.renderer.apply(this,Y);return f===!1&&(f=Q.apply(this,Y)),f}:y.renderers[$.name]=$.renderer}if("tokenizer"in $){if(!$.level||$.level!=="block"&&$.level!=="inline")throw Error("extension level must be 'block' or 'inline'");let Q=y[$.level];Q?Q.unshift($.tokenizer):y[$.level]=[$.tokenizer],$.start&&($.level==="block"?y.startBlock?y.startBlock.push($.start):y.startBlock=[$.start]:$.level==="inline"&&(y.startInline?y.startInline.push($.start):y.startInline=[$.start]))}"childTokens"in $&&$.childTokens&&(y.childTokens[$.name]=$.childTokens)}),J.extensions=y),N.renderer){let $=this.defaults.renderer||new Hy(this.defaults);for(let Q in N.renderer){if(!(Q in $))throw Error(`renderer '${Q}' does not exist`);if(["options","parser"].includes(Q))continue;let Y=Q,f=N.renderer[Y],W=$[Y];$[Y]=(...K)=>{let X=f.apply($,K);return X===!1&&(X=W.apply($,K)),X||""}}J.renderer=$}if(N.tokenizer){let $=this.defaults.tokenizer||new Py(this.defaults);for(let Q in N.tokenizer){if(!(Q in $))throw Error(`tokenizer '${Q}' does not exist`);if(["options","rules","lexer"].includes(Q))continue;let Y=Q,f=N.tokenizer[Y],W=$[Y];$[Y]=(...K)=>{let X=f.apply($,K);return X===!1&&(X=W.apply($,K)),X}}J.tokenizer=$}if(N.hooks){let $=this.defaults.hooks||new Jy;for(let Q in N.hooks){if(!(Q in $))throw Error(`hook '${Q}' does not exist`);if(["options","block"].includes(Q))continue;let Y=Q,f=N.hooks[Y],W=$[Y];Jy.passThroughHooks.has(Q)?$[Y]=(K)=>{if(this.defaults.async&&Jy.passThroughHooksRespectAsync.has(Q))return(async()=>{let b=await f.call($,K);return W.call($,b)})();let X=f.call($,K);return W.call($,X)}:$[Y]=(...K)=>{if(this.defaults.async)return(async()=>{let b=await f.apply($,K);return b===!1&&(b=await W.apply($,K)),b})();let X=f.apply($,K);return X===!1&&(X=W.apply($,K)),X}}J.hooks=$}if(N.walkTokens){let $=this.defaults.walkTokens,Q=N.walkTokens;J.walkTokens=function(Y){let f=[];return f.push(Q.call(this,Y)),$&&(f=f.concat($.call(this,Y))),f}}this.defaults={...this.defaults,...J}}),this}setOptions(B){return this.defaults={...this.defaults,...B},this}lexer(B,y){return j.lex(B,y??this.defaults)}parser(B,y){return V.parse(B,y??this.defaults)}parseMarkdown(B){return(y,N)=>{let J={...N},$={...this.defaults,...J},Q=this.onError(!!$.silent,!!$.async);if(this.defaults.async===!0&&J.async===!1)return Q(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 y>"u"||y===null)return Q(Error("marked(): input parameter is undefined or null"));if(typeof y!="string")return Q(Error("marked(): input parameter is of type "+Object.prototype.toString.call(y)+", string expected"));if($.hooks&&($.hooks.options=$,$.hooks.block=B),$.async)return(async()=>{let Y=$.hooks?await $.hooks.preprocess(y):y,f=await($.hooks?await $.hooks.provideLexer():B?j.lex:j.lexInline)(Y,$),W=$.hooks?await $.hooks.processAllTokens(f):f;$.walkTokens&&await Promise.all(this.walkTokens(W,$.walkTokens));let K=await($.hooks?await $.hooks.provideParser():B?V.parse:V.parseInline)(W,$);return $.hooks?await $.hooks.postprocess(K):K})().catch(Q);try{$.hooks&&(y=$.hooks.preprocess(y));let Y=($.hooks?$.hooks.provideLexer():B?j.lex:j.lexInline)(y,$);$.hooks&&(Y=$.hooks.processAllTokens(Y)),$.walkTokens&&this.walkTokens(Y,$.walkTokens);let f=($.hooks?$.hooks.provideParser():B?V.parse:V.parseInline)(Y,$);return $.hooks&&(f=$.hooks.postprocess(f)),f}catch(Y){return Q(Y)}}}onError(B,y){return(N)=>{if(N.message+=`
63
- Please report this to https://github.com/markedjs/marked.`,B){let J="<p>An error occurred:</p><pre>"+d(N.message+"",!0)+"</pre>";return y?Promise.resolve(J):J}if(y)return Promise.reject(N);throw N}}},i=new n0;function M(B,y){return i.parse(B,y)}M.options=M.setOptions=function(B){return i.setOptions(B),M.defaults=i.defaults,Y1(M.defaults),M};M.getDefaults=wy;M.defaults=a;M.use=function(...B){return i.use(...B),M.defaults=i.defaults,Y1(M.defaults),M};M.walkTokens=function(B,y){return i.walkTokens(B,y)};M.parseInline=i.parseInline;M.Parser=V;M.parser=V.parse;M.Renderer=Hy;M.TextRenderer=Ry;M.Lexer=j;M.lexer=j.lex;M.Tokenizer=Py;M.Hooks=Jy;M.parse=M;var{options:X2,setOptions:L2,use:b2,walkTokens:P2,parseInline:H2}=M;var U2=V.parse,q2=j.lex;import{jsxDEV as G1}from"react/jsx-dev-runtime";M.setOptions({gfm:!0,breaks:!1});function e0({children:B,file:y,__content:N}){let J=N??(typeof B==="string"?B:String(B??"")),$=t0(()=>{if(!J)return"";return M.parse(J,{async:!1})},[J]);if(!J)return G1("div",{className:"text-text-tertiary text-tiny mt-3",children:y?`Could not load: ${y}`:"No markdown content"},void 0,!1,void 0,this);return G1("div",{className:"mt-3 prose-canvas","data-md":"markdown",...y?{"data-md-file":y}:{},"data-md-source":J,dangerouslySetInnerHTML:{__html:$}},void 0,!1,void 0,this)}import{useFeedback as r2}from"#canvas/runtime";export{r2 as useFeedback,N0 as UserInput,z1 as Task,h1 as Table,Z1 as Section,J0 as RangeInput,V1 as Priority,S1 as Note,$0 as MultiChoice,s1 as Mermaid,e0 as Markdown,gy as Item,f0 as ImageView,u1 as FilePreview,t1 as Diff,C1 as CodeBlock,y0 as Choice,D1 as Checklist,R1 as Callout};
58
+ `+Y+`</table>
59
+ `}tablerow({text:J}){return`<tr>
60
+ ${J}</tr>
61
+ `}tablecell(J){let y=this.parser.parseInline(J.tokens),Q=J.header?"th":"td";return(J.align?`<${Q} align="${J.align}">`:`<${Q}>`)+y+`</${Q}>
62
+ `}strong({tokens:J}){return`<strong>${this.parser.parseInline(J)}</strong>`}em({tokens:J}){return`<em>${this.parser.parseInline(J)}</em>`}codespan({text:J}){return`<code>${a(J,!0)}</code>`}br(J){return"<br>"}del({tokens:J}){return`<del>${this.parser.parseInline(J)}</del>`}link({href:J,title:y,tokens:Q}){let Y=this.parser.parseInline(Q),$=_0(J);if($===null)return Y;J=$;let B='<a href="'+J+'"';return y&&(B+=' title="'+a(y)+'"'),B+=">"+Y+"</a>",B}image({href:J,title:y,text:Q,tokens:Y}){Y&&(Q=this.parser.parseInline(Y,this.parser.textRenderer));let $=_0(J);if($===null)return a(Q);J=$;let B=`<img src="${J}" alt="${a(Q)}"`;return y&&(B+=` title="${a(y)}"`),B+=">",B}text(J){return"tokens"in J&&J.tokens?this.parser.parseInline(J.tokens):("escaped"in J)&&J.escaped?J.text:a(J.text)}},o1=class{strong({text:J}){return J}em({text:J}){return J}codespan({text:J}){return J}del({text:J}){return J}html({text:J}){return J}text({text:J}){return J}link({text:J}){return""+J}image({text:J}){return""+J}br(){return""}checkbox({raw:J}){return J}},r=class J{options;renderer;textRenderer;constructor(y){this.options=y||W1,this.options.renderer=this.options.renderer||new m1,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new o1}static parse(y,Q){return new J(Q).parse(y)}static parseInline(y,Q){return new J(Q).parseInline(y)}parse(y){let Q="";for(let Y=0;Y<y.length;Y++){let $=y[Y];if(this.options.extensions?.renderers?.[$.type]){let W=$,K=this.options.extensions.renderers[W.type].call({parser:this},W);if(K!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(W.type)){Q+=K||"";continue}}let B=$;switch(B.type){case"space":{Q+=this.renderer.space(B);break}case"hr":{Q+=this.renderer.hr(B);break}case"heading":{Q+=this.renderer.heading(B);break}case"code":{Q+=this.renderer.code(B);break}case"table":{Q+=this.renderer.table(B);break}case"blockquote":{Q+=this.renderer.blockquote(B);break}case"list":{Q+=this.renderer.list(B);break}case"checkbox":{Q+=this.renderer.checkbox(B);break}case"html":{Q+=this.renderer.html(B);break}case"def":{Q+=this.renderer.def(B);break}case"paragraph":{Q+=this.renderer.paragraph(B);break}case"text":{Q+=this.renderer.text(B);break}default:{let W='Token with "'+B.type+'" type was not found.';if(this.options.silent)return console.error(W),"";throw Error(W)}}}return Q}parseInline(y,Q=this.renderer){let Y="";for(let $=0;$<y.length;$++){let B=y[$];if(this.options.extensions?.renderers?.[B.type]){let K=this.options.extensions.renderers[B.type].call({parser:this},B);if(K!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(B.type)){Y+=K||"";continue}}let W=B;switch(W.type){case"escape":{Y+=Q.text(W);break}case"html":{Y+=Q.html(W);break}case"link":{Y+=Q.link(W);break}case"image":{Y+=Q.image(W);break}case"checkbox":{Y+=Q.checkbox(W);break}case"strong":{Y+=Q.strong(W);break}case"em":{Y+=Q.em(W);break}case"codespan":{Y+=Q.codespan(W);break}case"br":{Y+=Q.br(W);break}case"del":{Y+=Q.del(W);break}case"text":{Y+=Q.text(W);break}default:{let K='Token with "'+W.type+'" type was not found.';if(this.options.silent)return console.error(K),"";throw Error(K)}}}return Y}},Z1=class{options;block;constructor(J){this.options=J||W1}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(J){return J}postprocess(J){return J}processAllTokens(J){return J}emStrongMask(J){return J}provideLexer(){return this.block?u.lex:u.lexInline}provideParser(){return this.block?r.parse:r.parseInline}},Z5=class{defaults=c1();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=r;Renderer=m1;TextRenderer=o1;Lexer=u;Tokenizer=I1;Hooks=Z1;constructor(...J){this.use(...J)}walkTokens(J,y){let Q=[];for(let Y of J)switch(Q=Q.concat(y.call(this,Y)),Y.type){case"table":{let $=Y;for(let B of $.header)Q=Q.concat(this.walkTokens(B.tokens,y));for(let B of $.rows)for(let W of B)Q=Q.concat(this.walkTokens(W.tokens,y));break}case"list":{let $=Y;Q=Q.concat(this.walkTokens($.items,y));break}default:{let $=Y;this.defaults.extensions?.childTokens?.[$.type]?this.defaults.extensions.childTokens[$.type].forEach((B)=>{let W=$[B].flat(1/0);Q=Q.concat(this.walkTokens(W,y))}):$.tokens&&(Q=Q.concat(this.walkTokens($.tokens,y)))}}return Q}use(...J){let y=this.defaults.extensions||{renderers:{},childTokens:{}};return J.forEach((Q)=>{let Y={...Q};if(Y.async=this.defaults.async||Y.async||!1,Q.extensions&&(Q.extensions.forEach(($)=>{if(!$.name)throw Error("extension name required");if("renderer"in $){let B=y.renderers[$.name];B?y.renderers[$.name]=function(...W){let K=$.renderer.apply(this,W);return K===!1&&(K=B.apply(this,W)),K}:y.renderers[$.name]=$.renderer}if("tokenizer"in $){if(!$.level||$.level!=="block"&&$.level!=="inline")throw Error("extension level must be 'block' or 'inline'");let B=y[$.level];B?B.unshift($.tokenizer):y[$.level]=[$.tokenizer],$.start&&($.level==="block"?y.startBlock?y.startBlock.push($.start):y.startBlock=[$.start]:$.level==="inline"&&(y.startInline?y.startInline.push($.start):y.startInline=[$.start]))}"childTokens"in $&&$.childTokens&&(y.childTokens[$.name]=$.childTokens)}),Y.extensions=y),Q.renderer){let $=this.defaults.renderer||new m1(this.defaults);for(let B in Q.renderer){if(!(B in $))throw Error(`renderer '${B}' does not exist`);if(["options","parser"].includes(B))continue;let W=B,K=Q.renderer[W],X=$[W];$[W]=(...L)=>{let N=K.apply($,L);return N===!1&&(N=X.apply($,L)),N||""}}Y.renderer=$}if(Q.tokenizer){let $=this.defaults.tokenizer||new I1(this.defaults);for(let B in Q.tokenizer){if(!(B in $))throw Error(`tokenizer '${B}' does not exist`);if(["options","rules","lexer"].includes(B))continue;let W=B,K=Q.tokenizer[W],X=$[W];$[W]=(...L)=>{let N=K.apply($,L);return N===!1&&(N=X.apply($,L)),N}}Y.tokenizer=$}if(Q.hooks){let $=this.defaults.hooks||new Z1;for(let B in Q.hooks){if(!(B in $))throw Error(`hook '${B}' does not exist`);if(["options","block"].includes(B))continue;let W=B,K=Q.hooks[W],X=$[W];Z1.passThroughHooks.has(B)?$[W]=(L)=>{if(this.defaults.async&&Z1.passThroughHooksRespectAsync.has(B))return(async()=>{let G=await K.call($,L);return X.call($,G)})();let N=K.call($,L);return X.call($,N)}:$[W]=(...L)=>{if(this.defaults.async)return(async()=>{let G=await K.apply($,L);return G===!1&&(G=await X.apply($,L)),G})();let N=K.apply($,L);return N===!1&&(N=X.apply($,L)),N}}Y.hooks=$}if(Q.walkTokens){let $=this.defaults.walkTokens,B=Q.walkTokens;Y.walkTokens=function(W){let K=[];return K.push(B.call(this,W)),$&&(K=K.concat($.call(this,W))),K}}this.defaults={...this.defaults,...Y}}),this}setOptions(J){return this.defaults={...this.defaults,...J},this}lexer(J,y){return u.lex(J,y??this.defaults)}parser(J,y){return r.parse(J,y??this.defaults)}parseMarkdown(J){return(y,Q)=>{let Y={...Q},$={...this.defaults,...Y},B=this.onError(!!$.silent,!!$.async);if(this.defaults.async===!0&&Y.async===!1)return B(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 y>"u"||y===null)return B(Error("marked(): input parameter is undefined or null"));if(typeof y!="string")return B(Error("marked(): input parameter is of type "+Object.prototype.toString.call(y)+", string expected"));if($.hooks&&($.hooks.options=$,$.hooks.block=J),$.async)return(async()=>{let W=$.hooks?await $.hooks.preprocess(y):y,K=await($.hooks?await $.hooks.provideLexer():J?u.lex:u.lexInline)(W,$),X=$.hooks?await $.hooks.processAllTokens(K):K;$.walkTokens&&await Promise.all(this.walkTokens(X,$.walkTokens));let L=await($.hooks?await $.hooks.provideParser():J?r.parse:r.parseInline)(X,$);return $.hooks?await $.hooks.postprocess(L):L})().catch(B);try{$.hooks&&(y=$.hooks.preprocess(y));let W=($.hooks?$.hooks.provideLexer():J?u.lex:u.lexInline)(y,$);$.hooks&&(W=$.hooks.processAllTokens(W)),$.walkTokens&&this.walkTokens(W,$.walkTokens);let K=($.hooks?$.hooks.provideParser():J?r.parse:r.parseInline)(W,$);return $.hooks&&(K=$.hooks.postprocess(K)),K}catch(W){return B(W)}}}onError(J,y){return(Q)=>{if(Q.message+=`
63
+ Please report this to https://github.com/markedjs/marked.`,J){let Y="<p>An error occurred:</p><pre>"+a(Q.message+"",!0)+"</pre>";return y?Promise.resolve(Y):Y}if(y)return Promise.reject(Q);throw Q}}},B1=new Z5;function w(J,y){return B1.parse(J,y)}w.options=w.setOptions=function(J){return B1.setOptions(J),w.defaults=B1.defaults,A0(w.defaults),w};w.getDefaults=c1;w.defaults=W1;w.use=function(...J){return B1.use(...J),w.defaults=B1.defaults,A0(w.defaults),w};w.walkTokens=function(J,y){return B1.walkTokens(J,y)};w.parseInline=B1.parseInline;w.Parser=r;w.parser=r.parse;w.Renderer=m1;w.TextRenderer=o1;w.Lexer=u;w.lexer=u.lex;w.Tokenizer=I1;w.Hooks=Z1;w.parse=w;var{options:x2,setOptions:D2,use:p2,walkTokens:c2,parseInline:E2}=w;var d2=r.parse,u2=u.lex;import{jsxDEV as j0}from"react/jsx-dev-runtime";w.setOptions({gfm:!0,breaks:!1});function v5({children:J,file:y,__content:Q}){let Y=Q??(typeof J==="string"?J:String(J??"")),$=F5(()=>{if(!Y)return"";return w.parse(Y,{async:!1})},[Y]);if(!Y)return j0("div",{className:"text-text-tertiary text-tiny mt-3",children:y?`Could not load: ${y}`:"No markdown content"},void 0,!1,void 0,this);return j0("div",{className:"mt-3 prose-canvas","data-md":"markdown",...y?{"data-md-file":y}:{},"data-md-source":Y,dangerouslySetInnerHTML:{__html:$}},void 0,!1,void 0,this)}import{useFeedback as F4}from"#canvas/runtime";export{F4 as useFeedback,Ay as UserInput,E0 as Task,s0 as Table,x0 as Section,fy as RangeInput,e0 as Priority,a0 as Note,wy as MultiChoice,Ty as Mermaid,v5 as Markdown,s1 as Item,Sy as ImageView,By as FilePreview,Fy as Diff,r0 as CodeBlock,_y as Choice,n0 as Checklist,l0 as Callout};