agent-canvas 0.1.26 → 0.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +25 -0
- package/.github/workflows/deploy-worker-prod.yml +20 -0
- package/.github/workflows/deploy-worker-stage.yml +22 -0
- package/.github/workflows/deploy-worker.yml +73 -0
- package/bin/lib/instructions/overview.md +1 -0
- package/bun.lock +193 -0
- package/daemon/build.ts +22 -0
- package/daemon/client/AnnotationEditor.tsx +12 -2
- package/daemon/client/AnnotationProvider.tsx +20 -6
- package/daemon/client/AnnotationSidebar.tsx +72 -35
- package/daemon/client/App.tsx +219 -10
- package/daemon/client/FileBrowser.tsx +16 -0
- package/daemon/client/FileViewer.tsx +18 -0
- package/daemon/client/PlanRenderer.tsx +3 -2
- package/daemon/client/ReviewerIdentityDialog.tsx +95 -0
- package/daemon/client/SessionSwitcher.tsx +5 -0
- package/daemon/client/ShareDialog.tsx +230 -0
- package/daemon/client/clientApi.ts +142 -0
- package/daemon/client/runtime.ts +22 -0
- package/daemon/dist/client.css +1 -1
- package/daemon/dist/client.js +74 -74
- package/daemon/dist/components.js +50 -50
- package/daemon/src/handlers/api.ts +63 -0
- package/daemon/src/remote-feedback.test.ts +179 -0
- package/daemon/src/remote-feedback.ts +128 -0
- package/daemon/src/server.ts +5 -0
- package/daemon/src/session.ts +139 -6
- package/daemon/src/share.test.ts +221 -0
- package/daemon/src/share.ts +187 -0
- package/daemon/src/websocket.ts +15 -2
- package/package.json +5 -1
- package/workers/canvas-share/README.md +159 -0
- package/workers/canvas-share/oblaka.ts +56 -0
- package/workers/canvas-share/package.json +25 -0
- package/workers/canvas-share/public/assets/.gitkeep +0 -0
- package/workers/canvas-share/public/assets/client.css +2 -0
- package/workers/canvas-share/public/assets/client.js +91 -0
- package/workers/canvas-share/public/assets/components.js +63 -0
- package/workers/canvas-share/public/assets/jsx-runtime.js +3 -0
- package/workers/canvas-share/public/assets/preact-compat.js +1 -0
- package/workers/canvas-share/public/assets/runtime.js +1 -0
- package/workers/canvas-share/public/index.html +385 -0
- package/workers/canvas-share/public/screenshot-dark.png +0 -0
- package/workers/canvas-share/public/screenshot-light.png +0 -0
- package/workers/canvas-share/src/index.test.ts +165 -0
- package/workers/canvas-share/src/index.ts +510 -0
- package/workers/canvas-share/src/types.ts +97 -0
- package/workers/canvas-share/src/util.ts +156 -0
- package/workers/canvas-share/src/validation.ts +117 -0
- package/workers/canvas-share/tsconfig.json +16 -0
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import{useState as
|
|
1
|
+
import{useState as x0}from"react";import{jsxDEV as Q1}from"react/jsx-dev-runtime";function D0({title:J,children:y}){let[Q,B]=x0(!1);return Q1("div",{className:"relative mb-8 p-4 group/section","data-md":"section","data-md-title":J,children:[Q1("div",{className:"relative mb-2",children:[Q1("button",{onClick:()=>B(!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:Q1("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",children:Q1("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),Q1("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),Q1("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 o}from"react/jsx-dev-runtime";var c0={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"},E0={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 t1({id:J,label:y,status:Q,badge:B,badgeVariant:$="neutral",children:Y}){return o("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}:{},...B?{"data-md-badge":B}:{},children:o("div",{className:"flex items-start gap-3",children:[Q&&o("span",{className:`w-2 h-2 rounded-full mt-[7px] flex-shrink-0 ${c0[Q]}`},void 0,!1,void 0,this),o("div",{className:"flex-1 min-w-0",children:[o("div",{className:"flex items-baseline gap-2",children:[o("span",{className:"font-body text-task-label font-semibold text-text-primary",children:y},void 0,!1,void 0,this),Q&&o("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),B&&o("span",{className:`font-body text-tiny font-medium px-1.5 py-px rounded-full ${E0[$]}`,children:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Y&&o("div",{className:"text-body text-text-secondary mt-1 leading-relaxed",children:Y},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 d0(J){return o(t1,{...J},void 0,!1,void 0,this)}import{useEffect as u0,useRef as r0}from"react";import{jsxDEV as A1}from"react/jsx-dev-runtime";function i0({language:J,children:y}){let Q=typeof y==="string"?y:String(y??""),B=r0(null);return u0(()=>{let $=B.current,Y=window.hljs;if(!$||!Y)return;$.removeAttribute("data-highlighted"),$.className=J?`language-${J}`:"",$.textContent=Q,Y.highlightElement($)},[Q,J]),A1("div",{className:"relative mt-3 group/code","data-md":"codeblock","data-md-language":J||"",children:[J&&A1("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),A1("pre",{className:"bg-bg-code rounded-md p-4 overflow-x-auto text-code font-mono leading-relaxed",children:A1("code",{ref:B,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 V1}from"react/jsx-dev-runtime";var l0={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 a0({type:J="info",children:y}){let Q=l0[J];return V1("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:[V1("span",{className:`${Q.iconColor} opacity-70 text-base leading-relaxed flex-shrink-0 mt-px`,children:Q.icon},void 0,!1,void 0,this),V1("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 s0}from"react/jsx-dev-runtime";function o0({children:J}){return s0("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 $1}from"react/jsx-dev-runtime";function n0({headers:J,rows:y}){return $1("div",{className:"overflow-x-auto mt-3","data-md":"table",children:$1("table",{className:"w-full text-body",children:[$1("thead",{children:$1("tr",{className:"border-b border-border-subtle",children:J.map((Q,B)=>$1("th",{className:"text-left px-4 py-2.5 text-meta font-medium uppercase tracking-wider text-text-tertiary font-body",children:Q},B,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),$1("tbody",{children:y.map((Q,B)=>$1("tr",{className:`relative border-b border-border-subtle last:border-b-0 transition-colors hover:bg-bg-surface/50 ${B%2===1?"bg-bg-surface/30":""}`,children:Q.map(($,Y)=>$1("td",{className:"px-4 py-2.5 text-text-secondary font-body",children:$},Y,!1,void 0,this))},B,!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 q1}from"react/jsx-dev-runtime";function t0({items:J}){return q1("ul",{className:"space-y-1 mt-3","data-md":"checklist",children:J.map((y,Q)=>q1("li",{"data-md":"checklist-item","data-md-label":y.label,className:"relative flex items-start gap-2.5 py-1",children:[q1("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&&q1("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:q1("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),q1("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 $5}from"react/jsx-dev-runtime";var e0={high:"text-accent-red bg-accent-red-muted",medium:"text-accent-amber bg-accent-amber-muted",low:"text-text-tertiary bg-border-subtle"};function y5({level:J}){return $5("span",{className:`inline text-tiny font-medium font-body ml-2 px-1.5 py-0.5 rounded ${e0[J]}`,"data-md":"priority","data-md-level":J,children:J},void 0,!1,void 0,this)}import{useEffect as e1,useState as v1,useContext as y0,useRef as J5}from"react";import{SessionContext as Q5,ActiveViewCtx as B5}from"#canvas/runtime";import{jsxDEV as J1}from"react/jsx-dev-runtime";var Y5={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 W5({path:J,lines:y,__content:Q}){let B=y0(Q5),{setActiveView:$}=y0(B5),[Y,W]=v1(Q??null),[L,X]=v1(()=>{let q=J.split(".").pop()||"";return Y5[q]||"text"}),[K,N]=v1(null),[G,U]=v1(!Q),T=J5(null);if(e1(()=>{if(Q!==void 0)return;U(!0),N(null),fetch(`/api/file?session=${B}&path=${encodeURIComponent(J)}`).then((q)=>q.json()).then((q)=>{if(q.error)N(q.error);else{let b=q.content;if(y)b=b.split(`
|
|
2
2
|
`).slice(y[0]-1,y[1]).join(`
|
|
3
|
-
`);W(b),X(q.language||"text")}}).catch(()=>N("Failed to fetch file")).finally(()=>U(!1))},[Y,Q,y?.[0],y?.[1],J]),t1(()=>{let q=T.current,b=window.hljs;if(!q||!b||!B)return;q.removeAttribute("data-highlighted"),q.className=K?`language-${K}`:"",q.textContent=B,b.highlightElement(q)},[B,K]),G)return J1("div",{className:"text-text-tertiary text-body mt-3 bg-bg-code rounded-md p-4",children:["Loading ",Q,"..."]},void 0,!0,void 0,this);if(L)return J1("div",{className:"text-accent-red text-body mt-3 bg-accent-red-muted rounded-md p-4",children:[Q,": ",L]},void 0,!0,void 0,this);return J1("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden","data-md":"filepreview","data-md-path":Q,...y?{"data-md-lines":`${y[0]}-${y[1]}`}:{},children:[J1("div",{className:"px-4 py-2 flex items-center justify-between",children:[J1("button",{className:"font-mono text-meta text-text-tertiary hover:text-text-secondary hover:underline cursor-pointer text-left",onClick:()=>$({type:"file",path:Q}),title:`Open ${Q}`,children:Q},void 0,!1,void 0,this),y&&J1("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),J1("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono !bg-transparent",style:{background:"transparent"},children:J1("code",{ref:T,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 c1,useRef as H1,useState as G1,useCallback as s}from"react";import Hy from"react-dom";import{useAnnotations as by,useCanvasFile as Ty}from"#canvas/runtime";import{useEffect as Ky,useRef as A1,useState as q1,useCallback as M1,useMemo as J0,useContext as Ly}from"react";import{createPortal as Ny}from"react-dom";function y0(Q,y){let $=y||document.body,B=Q.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 V1,useRef as x1,useCallback as y1,useEffect as By}from"react";function Y1(Q,y){Q.style.height="auto",Q.style.height=(y?Math.max(y,Q.scrollHeight):Q.scrollHeight)+"px"}import{jsxDEV as j}from"react/jsx-dev-runtime";function Wy(Q){return`/api/uploads/${Q.split("/").pop()}`}async function Xy(Q,y){let J=new FormData;J.append("image",y);try{return(await(await fetch(`/api/session/${Q}/upload`,{method:"POST",body:J})).json()).path||null}catch{return null}}function $0({note:Q,onNoteChange:y,images:J,onAddImage:Y,onRemoveImage:$,sessionId:B,placeholder:W="Add your note...",autoFocus:K=!1,autoResize:X=!1,readOnly:L=!1,onKeyDown:N,onTextareaClick:G,textareaRef:U,textareaClassName:T,textareaStyle:q,minHeight:b,attachButton:P="always",openFilePickerRef:_}){let[A,m]=V1(!1),[r,g]=V1(!1),[z,x]=V1(!1),I=x1(0),E=x1(null),O=x1(null),R=y1(()=>O.current?.click(),[]);if(_)_.current=R;let c=y1((Z)=>{if(E.current=Z,U)U.current=Z;if(Z&&X)Y1(Z,b)},[U,X,b]);By(()=>{if(K&&E.current){let Z=E.current;if(Z.focus(),Z.value)Z.setSelectionRange(Z.value.length,Z.value.length)}},[K]);let C=y1(async(Z)=>{if(!Z.type.startsWith("image/"))return;g(!0);try{let D=await Xy(B,Z);if(D)Y(D)}finally{g(!1)}},[B,Y]),i=y1((Z)=>{let D=Z.clipboardData.items;for(let H of D)if(H.type.startsWith("image/")){Z.preventDefault();let f=H.getAsFile();if(f)C(f);return}},[C]),S=y1((Z)=>{if(Z.preventDefault(),I.current++,I.current===1)m(!0)},[]),p=y1((Z)=>{Z.preventDefault()},[]),d=y1((Z)=>{if(Z.preventDefault(),I.current--,I.current===0)m(!1)},[]),t=y1((Z)=>{Z.preventDefault(),I.current=0,m(!1);for(let D of Z.dataTransfer.files)if(D.type.startsWith("image/"))C(D)},[C]),e=y1((Z)=>{if(y(Z.target.value),X)Z.target.style.height="auto",Z.target.style.height=(b?Math.max(b,Z.target.scrollHeight):Z.target.scrollHeight)+"px"},[y,X,b]),h1="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",g1={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"}},K1=!L&&(P==="always"||P==="on-focus"&&z);return j("div",{style:{position:"relative"},onDragEnter:L?void 0:S,onDragOver:L?void 0:p,onDragLeave:L?void 0:d,onDrop:L?void 0:t,children:[j("textarea",{ref:c,value:Q,onChange:L?void 0:e,onPaste:L?void 0:i,onKeyDown:N,onClick:G,onFocus:()=>x(!0),onBlur:()=>{setTimeout(()=>x(!1),150)},readOnly:L,placeholder:W,className:T??h1,style:q??g1,rows:X?1:void 0},void 0,!1,void 0,this),!L&&j("input",{ref:O,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:(Z)=>{let D=Z.target.files;if(D)for(let H of D)C(H);Z.target.value=""}},void 0,!1,void 0,this),(J.length>0||K1)&&j("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[J.map((Z)=>j("div",{style:{position:"relative",width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:[j("img",{src:Wy(Z),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!L&&j("button",{onClick:(D)=>{D.stopPropagation(),$(Z)},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)]},Z,!0,void 0,this)),K1&&j(D1,{onClick:R},void 0,!1,void 0,this)]},void 0,!0,void 0,this),r&&j("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),A&&j("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 D1({onClick:Q,size:y=16}){return j("button",{onClick:(J)=>{J.stopPropagation(),Q()},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:(J)=>{J.currentTarget.style.color="var(--color-text-secondary)"},onMouseLeave:(J)=>{J.currentTarget.style.color="var(--color-text-tertiary)"},children:j("svg",{width:y,height:y,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[j("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},void 0,!1,void 0,this),j("circle",{cx:"8.5",cy:"8.5",r:"1.5"},void 0,!1,void 0,this),j("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 qy}from"#canvas/runtime";import{jsxDEV as h,Fragment as Py}from"react/jsx-dev-runtime";function Gy({anchorEl:Q,scrollContainer:y,onClose:J,ignoreSelector:Y,zIndex:$="50",padding:B="12px",width:W="280px",children:K}){let X=A1(null),L=A1(J);L.current=J;let{style:N,parent:G}=y0(Q,y);return Ky(()=>{let U=setTimeout(()=>{let T=(q)=>{if(X.current&&!X.current.contains(q.target)){if(Y&&q.target.closest?.(Y))return;L.current(),document.removeEventListener("mousedown",T)}};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},0);return()=>clearTimeout(U)},[Y]),Ny(h("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 Y0=[{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=Y0.flatMap((Q)=>Q.items);function Uy({anchorEl:Q,scrollContainer:y,snippet:J,truncateAt:Y=100,header:$,initialNote:B="",initialImages:W,onConfirm:K,onCancel:X,onDelete:L}){let N=Ly(qy),G=B!==""||!!L,[U,T]=q1(B),[q,b]=q1(W||[]),[P,_]=q1(null),[A,m]=q1(G),[r,g]=q1(!1),z=A1(null),x=A1(null),I=M1(()=>{if(U.trim()||q.length>0)K(U.trim(),q);else if(G&&L)L();else X()},[U,q,K,X,G,L]),E=M1(()=>{if(G){if(!U.trim()&&q.length===0&&L){L(),X();return}K(U,q);return}X()},[U,q,G,K,X,L]),O=!G,R=U.trim().length>0?Q0.filter((H)=>H.toLowerCase().startsWith(U.trim().toLowerCase())):Q0,c=!O||A?[]:R.length===1&&R[0].toLowerCase()===U.trim().toLowerCase()?[]:R,C=new Set(c),i=Y0.map((H)=>({label:H.label,items:H.items.filter((f)=>C.has(f))})).filter((H)=>H.items.length>0),S=i.map((H)=>H.items),p=S.flat(),d=J0(()=>{if(P===null)return 0;let H=0;for(let f=0;f<S.length;f++){if(P<H+S[f].length)return f;H+=S[f].length}return 0},[P,S]),t=J0(()=>{if(P===null)return 0;let H=0;for(let f=0;f<d;f++)H+=S[f].length;return P-H},[P,d,S]),e=(H,f)=>{let u=0;for(let L1=0;L1<H;L1++)u+=S[L1].length;return u+f},[h1,g1]=q1(U);if(U!==h1)g1(U),_(null),m(G);let K1=M1((H)=>{T(H)},[]),Z=J.length>Y?J.slice(0,Y)+"...":J,D=M1((H)=>{if(p.length>0&&(H.key==="ArrowDown"||H.key==="ArrowUp"||H.key==="ArrowLeft"||H.key==="ArrowRight")){if(H.preventDefault(),P===null){_(0);return}if(H.key==="ArrowDown"){let f=Math.min(t+1,S[d].length-1);_(e(d,f))}else if(H.key==="ArrowUp"){let f=Math.max(t-1,0);_(e(d,f))}else if(H.key==="ArrowRight"){let f=Math.min(d+1,S.length-1),u=Math.min(t,S[f].length-1);_(e(f,u))}else if(H.key==="ArrowLeft"){let f=Math.max(d-1,0),u=Math.min(t,S[f].length-1);_(e(f,u))}return}if(P!==null&&p.length>0){if(H.key==="Tab"){H.preventDefault(),K1(p[P]);return}if(H.key==="Enter"&&!H.shiftKey){H.preventDefault(),K(p[P],q);return}}if(H.key==="Enter"&&!H.shiftKey){H.preventDefault(),I();return}if(H.key==="Escape")if(p.length>0&&!A)m(!0);else if(G)E();else X()},[p,P,t,d,S,e,K1,K,q,I,A,G,E,X]);return h(Gy,{anchorEl:Q,scrollContainer:y,onClose:G?E:X,ignoreSelector:G?"[data-annotation-id]":void 0,zIndex:G?"60":"50",padding:G?"10px 12px":"12px",width:"420px",children:[!G&&($??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:["“",Z,"”"]},void 0,!0,void 0,this)),h($0,{note:U,onNoteChange:T,images:q,onAddImage:(H)=>b((f)=>[...f,H]),onRemoveImage:(H)=>b((f)=>f.filter((u)=>u!==H)),sessionId:N,autoFocus:!0,autoResize:G,textareaRef:z,onKeyDown:D,attachButton:"none",openFilePickerRef:x,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),h("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:G?"6px":"8px"},children:[h(D1,{onClick:()=>x.current?.(),size:14},void 0,!1,void 0,this),h("div",{style:{flex:1}},void 0,!1,void 0,this),G?h("button",{onClick:()=>{if(L)L();X()},onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),style:{fontSize:"11px",color:r?"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):h(Py,{children:[h("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),h("button",{onClick:I,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),p.length>0&&h("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:i.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((f)=>{let u=p.indexOf(f);return h("div",{onMouseDown:(L1)=>{L1.preventDefault(),L1.stopPropagation(),K1(f)},onMouseEnter:()=>_(u),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:u===P?"var(--color-text-primary)":"var(--color-text-secondary)",background:u===P?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[h("span",{style:{fontWeight:500},children:f.slice(0,U.trim().length)},void 0,!1,void 0,this),f.slice(U.trim().length)]},f,!0,void 0,this)})]},H.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function B0({anchorEl:Q,scrollContainer:y,snippet:J,truncateAt:Y,header:$,onAdd:B,onCancel:W}){return h(Uy,{anchorEl:Q,scrollContainer:y,snippet:J,truncateAt:Y,header:$,onConfirm:(K,X)=>B(K,X),onCancel:W},void 0,!1,void 0,this)}import{jsxDEV as F,Fragment as L0}from"react/jsx-dev-runtime";var U1=0.2,k1=0.25,z1=4;function X0({zoom:Q,onZoomIn:y,onZoomOut:J,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:J,title:"Zoom out",disabled:Q<=k1,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(Q*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:Q>=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(L0,{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 K0(Q=1){let[y,J]=G1(Q),Y=s(()=>J((W)=>Math.min(z1,+(W+U1).toFixed(2))),[]),$=s(()=>J((W)=>Math.max(k1,+(W-U1).toFixed(2))),[]),B=s(()=>J(1),[]);return{zoom:y,zoomIn:Y,zoomOut:$,zoomReset:B,setZoom:J}}function Zy({svgHtml:Q,source:y,onClose:J}){let Y=H1(null),{zoom:$,zoomIn:B,zoomOut:W,zoomReset:K,setZoom:X}=K0(1),[L,N]=G1({x:0,y:0}),G=H1(null);c1(()=>{let _=(A)=>{if(A.key==="Escape")J()};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[J]);let U=s((_)=>{_.preventDefault();let A=_.deltaY>0?-U1:U1;X((m)=>Math.max(k1,Math.min(z1,+(m+A).toFixed(2))))},[X]),T=s((_)=>{if(_.button!==0)return;G.current={startX:_.clientX,startY:_.clientY,panX:L.x,panY:L.y},_.preventDefault()},[L]),q=s((_)=>{if(!G.current)return;N({x:G.current.panX+(_.clientX-G.current.startX),y:G.current.panY+(_.clientY-G.current.startY)})},[]),b=s(()=>{G.current=null},[]),P=s(()=>{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:b,onMouseLeave:b,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(X0,{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:J,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:U,onMouseDown:T,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:Q}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),document.body)}function Fy({children:Q}){let y=H1(null),[J,Y]=G1(null),[$,B]=G1(!1),[W,K]=G1(""),X=typeof Q==="string"?Q:String(Q??""),{annotations:L,addAnnotationWithId:N,activeAnnotationId:G,setActiveAnnotationId:U}=by(),T=Ty(),[q,b]=G1(null),{zoom:P,zoomIn:_,zoomOut:A,zoomReset:m,setZoom:r}=K0(1),g=H1(L);g.current=L;let z=s((O,R,c)=>{let C=`[Diagram ${c.toLowerCase()}] ${R}`,i=g.current.find((S)=>S.snippet===C);if(i)U(i.id);else b({anchorEl:O,snippet:R,prefix:c})},[U]),x=H1(z);x.current=z,c1(()=>{let O=!1,R=async()=>{try{let C=window.mermaid;if(!C){Y("Mermaid library not loaded");return}let i=document.documentElement.dataset.theme==="light"?"default":"dark";C.initialize({startOnLoad:!1,theme:i});let S=`mermaid-${Math.random().toString(36).slice(2)}`,{svg:p}=await C.render(S,X.trim());if(!O&&y.current)y.current.innerHTML=p,K(p),fy(y.current,(d,t,e)=>x.current(d,t,e)),W0(y.current,g.current);Y(null)}catch(C){if(!O)Y(C.message||"Invalid diagram")}};R();let c=new MutationObserver((C)=>{for(let i of C)if(i.attributeName==="data-theme")R()});return c.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{O=!0,c.disconnect()}},[X]),c1(()=>{if(y.current)W0(y.current,L,G)},[L,G]);let I=s((O)=>{if(!O.ctrlKey&&!O.metaKey)return;O.preventDefault();let R=O.deltaY>0?-U1:U1;r((c)=>Math.max(k1,Math.min(z1,+(c+R).toFixed(2))))},[r]);if(J)return F("div",{className:"bg-accent-red-muted rounded-md p-4 mt-3 text-body text-accent-red",children:["Mermaid error: ",J,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 E=y.current?.closest("#plan-scroll-container");return F(L0,{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(X0,{zoom:P,onZoomIn:_,onZoomOut:A,onZoomReset:m,onFullscreen:()=>B(!0)},void 0,!1,void 0,this)},void 0,!1,void 0,this),F("div",{style:{overflow:"auto",maxHeight:"70vh"},onWheel:I,children:F("div",{ref:y,className:"flex justify-center",style:{transform:`scale(${P})`,transformOrigin:"top center",transition:"transform 0.1s ease-out",minHeight:P<1?void 0:void 0}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q&&F(B0,{anchorEl:q.anchorEl,scrollContainer:E,snippet:q.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),q.snippet]},void 0,!0,void 0,this),onAdd:(O,R)=>{let c=`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;N(c,`[Diagram ${q.prefix.toLowerCase()}] ${q.snippet}`,O,void 0,void 0,R,T||void 0),b(null)},onCancel:()=>b(null)},void 0,!1,void 0,this),$&&W&&F(Zy,{svgHtml:W,source:X,onClose:()=>B(!1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function fy(Q,y){let J=(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 Q.querySelectorAll(".node"))J(Y,()=>{return(Y.querySelector(".nodeLabel")||Y.querySelector("foreignObject span")||Y.querySelector("text"))?.textContent?.trim()||"Node"},"Node");for(let Y of Q.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||"";J($,()=>{let K=Q.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 Q.querySelectorAll(".edgeLabel")){let $=Y.textContent?.trim();if(!$)continue;J(Y,()=>$,"Edge")}for(let Y of Q.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"),J(B,()=>$.textContent?.trim()||"Participant","Node")}for(let Y of Q.querySelectorAll(".messageText")){let $=Y.textContent?.trim();if(!$)continue;J(Y,()=>$,"Edge")}for(let Y of Q.querySelectorAll(".entityBox")){let $=Y.closest("g");if(!$||$.hasAttribute("data-clickable"))continue;let B=$.querySelector(".entityLabel");if(!B)continue;$.setAttribute("data-clickable","true"),J($,()=>B.textContent?.trim()||"Entity","Node")}for(let Y of Q.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"),J(W,()=>$,"Edge")}for(let Y of Q.querySelectorAll(".classGroup")){let $=Y;if($.hasAttribute("data-clickable"))continue;let B=$.querySelector(".classTitle, .classTitleText, text");if(!B)continue;$.setAttribute("data-clickable","true"),J($,()=>B.textContent?.trim()||"Class","Node")}for(let Y of Q.querySelectorAll(".statediagram-state")){let $=Y;if($.hasAttribute("data-clickable"))continue;let B=$.querySelector(".state-title, text");if(!B)continue;$.setAttribute("data-clickable","true"),J($,()=>B.textContent?.trim()||"State","Node")}for(let Y of Q.querySelectorAll(".mindmap-node")){let $=Y;if($.hasAttribute("data-clickable"))continue;let B=$.querySelector(".mindmap-node-label, text");if(!B)continue;$.setAttribute("data-clickable","true"),J($,()=>B.textContent?.trim()||"Node","Node")}}function W0(Q,y,J){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 Q.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 Q.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===J;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 Q.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===J;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 Q.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===J,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 Q.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===J;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 Q.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 U=Y.get(G);L.setAttribute("data-annotated",U);let T=U===J,q=L.querySelector("rect, circle, ellipse, polygon")||L;q.style.outline=T?"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 Q.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===J;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 b1}from"react/jsx-dev-runtime";function _y({before:Q,after:y,language:J}){let Y=Q.split(`
|
|
3
|
+
`);W(b),X(q.language||"text")}}).catch(()=>N("Failed to fetch file")).finally(()=>U(!1))},[B,J,y?.[0],y?.[1],Q]),e1(()=>{let q=T.current,b=window.hljs;if(!q||!b||!Y)return;q.removeAttribute("data-highlighted"),q.className=L?`language-${L}`:"",q.textContent=Y,b.highlightElement(q)},[Y,L]),G)return J1("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(K)return J1("div",{className:"text-accent-red text-body mt-3 bg-accent-red-muted rounded-md p-4",children:[J,": ",K]},void 0,!0,void 0,this);return J1("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:[J1("div",{className:"px-4 py-2 flex items-center justify-between",children:[J1("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&&J1("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),J1("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono !bg-transparent",style:{background:"transparent"},children:J1("code",{ref:T,className:L?`language-${L}`:"",children:Y},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as p1,useRef as b1,useState as U1,useCallback as s}from"react";import Z5 from"react-dom";import{useAnnotations as F5,useCanvasFile as f5}from"#canvas/runtime";import{useEffect as q5,useRef as z1,useState as G1,useCallback as k1,useMemo as B0,useContext as G5}from"react";import{createPortal as U5}from"react-dom";function $0(J,y){let $=y||document.body,Y=J.getBoundingClientRect(),W=$.getBoundingClientRect(),L=$===document.body?window.scrollY:$.scrollTop,X=Y.bottom-W.top+L+8,K=Math.max(0,Math.min(Y.left-W.left,W.width-280-12));return $.style.position="relative",{style:{position:"absolute",top:`${X}px`,left:`${K}px`},parent:$}}import{useState as x1,useRef as D1,useCallback as y1,useEffect as L5}from"react";function B1(J,y){J.style.height="auto",J.style.height=(y?Math.max(y,J.scrollHeight):J.scrollHeight)+"px"}function X5(){if(typeof window<"u"&&window.__CANVAS_SHARE__?.shareId)return{isShared:!0,shareId:window.__CANVAS_SHARE__.shareId};return{isShared:!1,sessionId:typeof window<"u"?window.location.pathname.replace("/s/",""):""}}var Y1=X5();function J0(){if(Y1.isShared)return`/s/${Y1.shareId}/upload`;return`/api/session/${Y1.sessionId}/upload`}var ey=!Y1.isShared,y2=!Y1.isShared;import{jsxDEV as j}from"react/jsx-dev-runtime";function K5(J){if(J.startsWith("/s/")||J.startsWith("http://")||J.startsWith("https://"))return J;return`/api/uploads/${J.split("/").pop()}`}async function N5(J,y){let Q=new FormData;Q.append("image",y);try{let $=await(await fetch(J0(),{method:"POST",body:Q})).json();if(Y1.isShared)return $.url||null;return $.path||null}catch{return null}}function Q0({note:J,onNoteChange:y,images:Q,onAddImage:B,onRemoveImage:$,sessionId:Y,placeholder:W="Add your note...",autoFocus:L=!1,autoResize:X=!1,readOnly:K=!1,onKeyDown:N,onTextareaClick:G,textareaRef:U,textareaClassName:T,textareaStyle:q,minHeight:b,attachButton:P="always",openFilePickerRef:_}){let[k,m]=x1(!1),[r,g]=x1(!1),[M,x]=x1(!1),I=D1(0),E=D1(null),O=D1(null),C=y1(()=>O.current?.click(),[]);if(_)_.current=C;let c=y1((Z)=>{if(E.current=Z,U)U.current=Z;if(Z&&X)B1(Z,b)},[U,X,b]);L5(()=>{if(L&&E.current){let Z=E.current;if(Z.focus(),Z.value)Z.setSelectionRange(Z.value.length,Z.value.length)}},[L]);let R=y1(async(Z)=>{if(!Z.type.startsWith("image/"))return;g(!0);try{let D=await N5(Y,Z);if(D)B(D)}finally{g(!1)}},[Y,B]),i=y1((Z)=>{let D=Z.clipboardData.items;for(let H of D)if(H.type.startsWith("image/")){Z.preventDefault();let f=H.getAsFile();if(f)R(f);return}},[R]),S=y1((Z)=>{if(Z.preventDefault(),I.current++,I.current===1)m(!0)},[]),p=y1((Z)=>{Z.preventDefault()},[]),d=y1((Z)=>{if(Z.preventDefault(),I.current--,I.current===0)m(!1)},[]),t=y1((Z)=>{Z.preventDefault(),I.current=0,m(!1);for(let D of Z.dataTransfer.files)if(D.type.startsWith("image/"))R(D)},[R]),e=y1((Z)=>{if(y(Z.target.value),X)Z.target.style.height="auto",Z.target.style.height=(b?Math.max(b,Z.target.scrollHeight):Z.target.scrollHeight)+"px"},[y,X,b]),g1="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",j1={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"}},K1=!K&&(P==="always"||P==="on-focus"&&M);return j("div",{style:{position:"relative"},onDragEnter:K?void 0:S,onDragOver:K?void 0:p,onDragLeave:K?void 0:d,onDrop:K?void 0:t,children:[j("textarea",{ref:c,value:J,onChange:K?void 0:e,onPaste:K?void 0:i,onKeyDown:N,onClick:G,onFocus:()=>x(!0),onBlur:()=>{setTimeout(()=>x(!1),150)},readOnly:K,placeholder:W,className:T??g1,style:q??j1,rows:X?1:void 0},void 0,!1,void 0,this),!K&&j("input",{ref:O,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:(Z)=>{let D=Z.target.files;if(D)for(let H of D)R(H);Z.target.value=""}},void 0,!1,void 0,this),(Q.length>0||K1)&&j("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[Q.map((Z)=>j("div",{style:{position:"relative",width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:[j("img",{src:K5(Z),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!K&&j("button",{onClick:(D)=>{D.stopPropagation(),$(Z)},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)]},Z,!0,void 0,this)),K1&&j(c1,{onClick:C},void 0,!1,void 0,this)]},void 0,!0,void 0,this),r&&j("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),k&&j("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 c1({onClick:J,size:y=16}){return j("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:j("svg",{width:y,height:y,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[j("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},void 0,!1,void 0,this),j("circle",{cx:"8.5",cy:"8.5",r:"1.5"},void 0,!1,void 0,this),j("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 P5}from"#canvas/runtime";import{jsxDEV as h,Fragment as T5}from"react/jsx-dev-runtime";function H5({anchorEl:J,scrollContainer:y,onClose:Q,ignoreSelector:B,zIndex:$="50",padding:Y="12px",width:W="280px",children:L}){let X=z1(null),K=z1(Q);K.current=Q;let{style:N,parent:G}=$0(J,y);return q5(()=>{let U=setTimeout(()=>{let T=(q)=>{if(X.current&&!X.current.contains(q.target)){if(B&&q.target.closest?.(B))return;K.current(),document.removeEventListener("mousedown",T)}};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},0);return()=>clearTimeout(U)},[B]),U5(h("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:Y,fontFamily:"'Inter', sans-serif"},children:L},void 0,!1,void 0,this),G)}var W0=[{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"]}],Y0=W0.flatMap((J)=>J.items);function b5({anchorEl:J,scrollContainer:y,snippet:Q,truncateAt:B=100,header:$,initialNote:Y="",initialImages:W,onConfirm:L,onCancel:X,onDelete:K}){let N=G5(P5),G=Y!==""||!!K,[U,T]=G1(Y),[q,b]=G1(W||[]),[P,_]=G1(null),[k,m]=G1(G),[r,g]=G1(!1),M=z1(null),x=z1(null),I=k1(()=>{if(U.trim()||q.length>0)L(U.trim(),q);else if(G&&K)K();else X()},[U,q,L,X,G,K]),E=k1(()=>{if(G){if(!U.trim()&&q.length===0&&K){K(),X();return}L(U,q);return}X()},[U,q,G,L,X,K]),O=!G,C=U.trim().length>0?Y0.filter((H)=>H.toLowerCase().startsWith(U.trim().toLowerCase())):Y0,c=!O||k?[]:C.length===1&&C[0].toLowerCase()===U.trim().toLowerCase()?[]:C,R=new Set(c),i=W0.map((H)=>({label:H.label,items:H.items.filter((f)=>R.has(f))})).filter((H)=>H.items.length>0),S=i.map((H)=>H.items),p=S.flat(),d=B0(()=>{if(P===null)return 0;let H=0;for(let f=0;f<S.length;f++){if(P<H+S[f].length)return f;H+=S[f].length}return 0},[P,S]),t=B0(()=>{if(P===null)return 0;let H=0;for(let f=0;f<d;f++)H+=S[f].length;return P-H},[P,d,S]),e=(H,f)=>{let u=0;for(let N1=0;N1<H;N1++)u+=S[N1].length;return u+f},[g1,j1]=G1(U);if(U!==g1)j1(U),_(null),m(G);let K1=k1((H)=>{T(H)},[]),Z=Q.length>B?Q.slice(0,B)+"...":Q,D=k1((H)=>{if(p.length>0&&(H.key==="ArrowDown"||H.key==="ArrowUp"||H.key==="ArrowLeft"||H.key==="ArrowRight")){if(H.preventDefault(),P===null){_(0);return}if(H.key==="ArrowDown"){let f=Math.min(t+1,S[d].length-1);_(e(d,f))}else if(H.key==="ArrowUp"){let f=Math.max(t-1,0);_(e(d,f))}else if(H.key==="ArrowRight"){let f=Math.min(d+1,S.length-1),u=Math.min(t,S[f].length-1);_(e(f,u))}else if(H.key==="ArrowLeft"){let f=Math.max(d-1,0),u=Math.min(t,S[f].length-1);_(e(f,u))}return}if(P!==null&&p.length>0){if(H.key==="Tab"){H.preventDefault(),K1(p[P]);return}if(H.key==="Enter"&&!H.shiftKey){H.preventDefault(),L(p[P],q);return}}if(H.key==="Enter"&&!H.shiftKey){H.preventDefault(),I();return}if(H.key==="Escape")if(p.length>0&&!k)m(!0);else if(G)E();else X()},[p,P,t,d,S,e,K1,L,q,I,k,G,E,X]);return h(H5,{anchorEl:J,scrollContainer:y,onClose:G?E:X,ignoreSelector:G?"[data-annotation-id]":void 0,zIndex:G?"60":"50",padding:G?"10px 12px":"12px",width:"420px",children:[!G&&($??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:["“",Z,"”"]},void 0,!0,void 0,this)),h(Q0,{note:U,onNoteChange:T,images:q,onAddImage:(H)=>b((f)=>[...f,H]),onRemoveImage:(H)=>b((f)=>f.filter((u)=>u!==H)),sessionId:N,autoFocus:!0,autoResize:G,textareaRef:M,onKeyDown:D,attachButton:"none",openFilePickerRef:x,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),h("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:G?"6px":"8px"},children:[h(c1,{onClick:()=>x.current?.(),size:14},void 0,!1,void 0,this),h("div",{style:{flex:1}},void 0,!1,void 0,this),G?h("button",{onClick:()=>{if(K)K();X()},onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),style:{fontSize:"11px",color:r?"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):h(T5,{children:[h("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),h("button",{onClick:I,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),p.length>0&&h("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:i.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((f)=>{let u=p.indexOf(f);return h("div",{onMouseDown:(N1)=>{N1.preventDefault(),N1.stopPropagation(),K1(f)},onMouseEnter:()=>_(u),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:u===P?"var(--color-text-primary)":"var(--color-text-secondary)",background:u===P?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[h("span",{style:{fontWeight:500},children:f.slice(0,U.trim().length)},void 0,!1,void 0,this),f.slice(U.trim().length)]},f,!0,void 0,this)})]},H.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function X0({anchorEl:J,scrollContainer:y,snippet:Q,truncateAt:B,header:$,onAdd:Y,onCancel:W}){return h(b5,{anchorEl:J,scrollContainer:y,snippet:Q,truncateAt:B,header:$,onConfirm:(L,X)=>Y(L,X),onCancel:W},void 0,!1,void 0,this)}import{jsxDEV as F,Fragment as q0}from"react/jsx-dev-runtime";var P1=0.2,M1=0.25,O1=4;function K0({zoom:J,onZoomIn:y,onZoomOut:Q,onZoomReset:B,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<=M1,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:B,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>=O1,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(q0,{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 N0(J=1){let[y,Q]=U1(J),B=s(()=>Q((W)=>Math.min(O1,+(W+P1).toFixed(2))),[]),$=s(()=>Q((W)=>Math.max(M1,+(W-P1).toFixed(2))),[]),Y=s(()=>Q(1),[]);return{zoom:y,zoomIn:B,zoomOut:$,zoomReset:Y,setZoom:Q}}function _5({svgHtml:J,source:y,onClose:Q}){let B=b1(null),{zoom:$,zoomIn:Y,zoomOut:W,zoomReset:L,setZoom:X}=N0(1),[K,N]=U1({x:0,y:0}),G=b1(null);p1(()=>{let _=(k)=>{if(k.key==="Escape")Q()};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[Q]);let U=s((_)=>{_.preventDefault();let k=_.deltaY>0?-P1:P1;X((m)=>Math.max(M1,Math.min(O1,+(m+k).toFixed(2))))},[X]),T=s((_)=>{if(_.button!==0)return;G.current={startX:_.clientX,startY:_.clientY,panX:K.x,panY:K.y},_.preventDefault()},[K]),q=s((_)=>{if(!G.current)return;N({x:G.current.panX+(_.clientX-G.current.startX),y:G.current.panY+(_.clientY-G.current.startY)})},[]),b=s(()=>{G.current=null},[]),P=s(()=>{L(),N({x:0,y:0})},[L]);return Z5.createPortal(F("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"var(--color-bg-base)",display:"flex",flexDirection:"column"},onMouseMove:q,onMouseUp:b,onMouseLeave:b,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:Y,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:U,onMouseDown:T,children:F("div",{ref:B,style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",transform:`translate(${K.x}px, ${K.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 w5({children:J}){let y=b1(null),[Q,B]=U1(null),[$,Y]=U1(!1),[W,L]=U1(""),X=typeof J==="string"?J:String(J??""),{annotations:K,addAnnotationWithId:N,activeAnnotationId:G,setActiveAnnotationId:U}=F5(),T=f5(),[q,b]=U1(null),{zoom:P,zoomIn:_,zoomOut:k,zoomReset:m,setZoom:r}=N0(1),g=b1(K);g.current=K;let M=s((O,C,c)=>{let R=`[Diagram ${c.toLowerCase()}] ${C}`,i=g.current.find((S)=>S.snippet===R);if(i)U(i.id);else b({anchorEl:O,snippet:C,prefix:c})},[U]),x=b1(M);x.current=M,p1(()=>{let O=!1,C=async()=>{try{let R=window.mermaid;if(!R){B("Mermaid library not loaded");return}let i=document.documentElement.dataset.theme==="light"?"default":"dark";R.initialize({startOnLoad:!1,theme:i});let S=`mermaid-${Math.random().toString(36).slice(2)}`,{svg:p}=await R.render(S,X.trim());if(!O&&y.current)y.current.innerHTML=p,L(p),A5(y.current,(d,t,e)=>x.current(d,t,e)),L0(y.current,g.current);B(null)}catch(R){if(!O)B(R.message||"Invalid diagram")}};C();let c=new MutationObserver((R)=>{for(let i of R)if(i.attributeName==="data-theme")C()});return c.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{O=!0,c.disconnect()}},[X]),p1(()=>{if(y.current)L0(y.current,K,G)},[K,G]);let I=s((O)=>{if(!O.ctrlKey&&!O.metaKey)return;O.preventDefault();let C=O.deltaY>0?-P1:P1;r((c)=>Math.max(M1,Math.min(O1,+(c+C).toFixed(2))))},[r]);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 E=y.current?.closest("#plan-scroll-container");return F(q0,{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:P,onZoomIn:_,onZoomOut:k,onZoomReset:m,onFullscreen:()=>Y(!0)},void 0,!1,void 0,this)},void 0,!1,void 0,this),F("div",{style:{overflow:"auto",maxHeight:"70vh"},onWheel:I,children:F("div",{ref:y,className:"flex justify-center",style:{transform:`scale(${P})`,transformOrigin:"top center",transition:"transform 0.1s ease-out",minHeight:P<1?void 0:void 0}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q&&F(X0,{anchorEl:q.anchorEl,scrollContainer:E,snippet:q.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),q.snippet]},void 0,!0,void 0,this),onAdd:(O,C)=>{let c=`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;N(c,`[Diagram ${q.prefix.toLowerCase()}] ${q.snippet}`,O,void 0,void 0,C,T||void 0),b(null)},onCancel:()=>b(null)},void 0,!1,void 0,this),$&&W&&F(_5,{svgHtml:W,source:X,onClose:()=>Y(!1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function A5(J,y){let Q=(B,$,Y)=>{B.style.cursor="pointer",B.addEventListener("mouseenter",()=>{B.style.filter="brightness(1.2)"}),B.addEventListener("mouseleave",()=>{B.style.filter=""}),B.addEventListener("click",(W)=>{W.stopPropagation(),W.preventDefault(),y(B,$(),Y)})};for(let B of J.querySelectorAll(".node"))Q(B,()=>{return(B.querySelector(".nodeLabel")||B.querySelector("foreignObject span")||B.querySelector("text"))?.textContent?.trim()||"Node"},"Node");for(let B of J.querySelectorAll(".edgePath")){let $=B,Y=$.querySelector("path");if(Y){Y.style.strokeWidth=Math.max(parseFloat(Y.style.strokeWidth||"1"),8)+"px",Y.style.strokeOpacity="0";let L=Y.cloneNode(!0);L.style.strokeWidth="",L.style.strokeOpacity="",$.insertBefore(L,Y)}let W=$.id||"";Q($,()=>{let L=J.querySelectorAll(".edgeLabel");for(let X of L)if(X.id&&W&&X.id.replace("label","").includes(W.replace("L-","").replace("edge",""))){let K=X.textContent?.trim();if(K)return K}return"Connection"},"Edge")}for(let B of J.querySelectorAll(".edgeLabel")){let $=B.textContent?.trim();if(!$)continue;Q(B,()=>$,"Edge")}for(let B of J.querySelectorAll(".actor")){let $=B.closest("g")?.querySelector("text")||B.parentElement?.querySelector("text");if(!$)continue;let Y=B.closest("g");if(!Y||Y.hasAttribute("data-clickable"))continue;Y.setAttribute("data-clickable","true"),Q(Y,()=>$.textContent?.trim()||"Participant","Node")}for(let B of J.querySelectorAll(".messageText")){let $=B.textContent?.trim();if(!$)continue;Q(B,()=>$,"Edge")}for(let B of J.querySelectorAll(".entityBox")){let $=B.closest("g");if(!$||$.hasAttribute("data-clickable"))continue;let Y=$.querySelector(".entityLabel");if(!Y)continue;$.setAttribute("data-clickable","true"),Q($,()=>Y.textContent?.trim()||"Entity","Node")}for(let B of J.querySelectorAll(".relationshipLabel")){let $=B.textContent?.trim();if(!$)continue;let W=B.closest("g")||B;if(W.hasAttribute("data-clickable"))continue;W.setAttribute("data-clickable","true"),Q(W,()=>$,"Edge")}for(let B of J.querySelectorAll(".classGroup")){let $=B;if($.hasAttribute("data-clickable"))continue;let Y=$.querySelector(".classTitle, .classTitleText, text");if(!Y)continue;$.setAttribute("data-clickable","true"),Q($,()=>Y.textContent?.trim()||"Class","Node")}for(let B of J.querySelectorAll(".statediagram-state")){let $=B;if($.hasAttribute("data-clickable"))continue;let Y=$.querySelector(".state-title, text");if(!Y)continue;$.setAttribute("data-clickable","true"),Q($,()=>Y.textContent?.trim()||"State","Node")}for(let B of J.querySelectorAll(".mindmap-node")){let $=B;if($.hasAttribute("data-clickable"))continue;let Y=$.querySelector(".mindmap-node-label, text");if(!Y)continue;$.setAttribute("data-clickable","true"),Q($,()=>Y.textContent?.trim()||"Node","Node")}}function L0(J,y,Q){let B=new Map;for(let Y of y){let W=Y.snippet.match(/^\[Diagram (?:node|edge)\] (.+)$/);if(W)B.set(W[1],Y.id)}for(let Y of J.querySelectorAll("[data-annotated]"))Y.style.outline="",Y.style.outlineOffset="",Y.style.borderRadius="",Y.removeAttribute("data-annotated");if(B.size===0)return;for(let Y of J.querySelectorAll(".node")){let L=(Y.querySelector(".nodeLabel")||Y.querySelector("foreignObject span")||Y.querySelector("text"))?.textContent?.trim();if(!L||!B.has(L))continue;let X=B.get(L),K=Y;K.setAttribute("data-annotated",X);let N=X===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"}for(let Y of J.querySelectorAll(".edgeLabel")){let W=Y.textContent?.trim();if(!W||!B.has(W))continue;let L=B.get(W),X=Y;X.setAttribute("data-annotated",L);let K=L===Q;X.style.outline=K?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",X.style.outlineOffset="2px",X.style.borderRadius="4px"}for(let Y of J.querySelectorAll(".actor")){let W=Y.closest("g");if(!W)continue;let X=W.querySelector("text")?.textContent?.trim();if(!X||!B.has(X))continue;if(W.hasAttribute("data-annotated"))continue;let K=B.get(X);W.setAttribute("data-annotated",K);let N=K===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 Y of J.querySelectorAll(".messageText")){let W=Y.textContent?.trim();if(!W||!B.has(W))continue;let L=B.get(W),X=Y;X.setAttribute("data-annotated",L);let K=L===Q;X.style.outline=K?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",X.style.outlineOffset="2px",X.style.borderRadius="4px"}let $=(Y,W,L)=>{for(let X of J.querySelectorAll(Y)){let K=L(X);if(!K||K.hasAttribute("data-annotated"))continue;let G=K.querySelector(W)?.textContent?.trim();if(!G||!B.has(G))continue;let U=B.get(G);K.setAttribute("data-annotated",U);let T=U===Q,q=K.querySelector("rect, circle, ellipse, polygon")||K;q.style.outline=T?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",q.style.outlineOffset="2px",q.style.borderRadius="4px"}};$(".entityBox",".entityLabel",(Y)=>Y.closest("g"));for(let Y of J.querySelectorAll(".relationshipLabel")){let L=Y.closest("g")||Y;if(L.hasAttribute("data-annotated"))continue;let X=Y.textContent?.trim();if(!X||!B.has(X))continue;let K=B.get(X);L.setAttribute("data-annotated",K);let N=K===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"}$(".classGroup",".classTitle, .classTitleText, text",(Y)=>Y),$(".statediagram-state",".state-title, text",(Y)=>Y),$(".mindmap-node",".mindmap-node-label, text",(Y)=>Y)}import{jsxDEV as T1}from"react/jsx-dev-runtime";function v5({before:J,after:y,language:Q}){let B=J.split(`
|
|
4
4
|
`),$=y.split(`
|
|
5
|
-
`),B=wy(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 b1("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden group/diff","data-md":"diff","data-md-language":J||"",children:[J&&b1("div",{className:"px-4 py-2 text-meta font-mono text-text-tertiary opacity-0 group-hover/diff:opacity-60 transition-opacity",children:["diff (",J,")"]},void 0,!0,void 0,this),b1("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono",children:W.map((N,G)=>b1("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:[b1("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 wy(Q,y){let J=Q.length,Y=y.length,$=Array.from({length:J+1},()=>Array(Y+1).fill(0));for(let X=1;X<=J;X++)for(let L=1;L<=Y;L++)$[X][L]=Q[X-1]===y[L-1]?$[X-1][L-1]+1:Math.max($[X-1][L],$[X][L-1]);let B=[],W=J,K=Y;while(W>0&&K>0)if(Q[W-1]===y[K-1])B.unshift(Q[W-1]),W--,K--;else if($[W-1][K]>$[W][K-1])W--;else K--;return B}import{useEffect as q0,useRef as G0,useState as U0}from"react";import{useAnnotations as P0}from"#canvas/runtime";import{jsxDEV as N0}from"react/jsx-dev-runtime";function P1({note:Q,onChange:y}){return N0("div",{className:"mt-1.5",children:N0("textarea",{value:Q,onChange:(J)=>y(J.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:(J)=>Y1(J.target),ref:(J)=>{if(J)Y1(J)}},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as k}from"react/jsx-dev-runtime";function vy({id:Q,label:y,options:J,required:Y}){let{responses:$,setResponse:B}=P0(),W=$.get(Q),K=W?.value,X=W?.note||"",[L,N]=U0(!1),G=G0(null);if(!$.has(Q))B(Q,{id:Q,type:"radio",label:y,value:null,options:J,required:Y});let U=(q)=>{B(Q,{...W,value:q})};q0(()=>{let q=G.current;if(!q)return;let b=(P)=>{let A=P.target.closest("[data-md-label]")?.getAttribute("data-md-label");if(A&&J.includes(A))U(A)};return q.addEventListener("kb-select",b),()=>q.removeEventListener("kb-select",b)},[J,U]);let T=W?.required&&!K;return k("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:[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),Y&&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:J.map((q)=>k("label",{"data-md":"choice-option","data-md-label":q,onClick:()=>U(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:[k("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&&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:q},void 0,!1,void 0,this)]},q,!0,void 0,this))},void 0,!1,void 0,this),k(P1,{show:L,note:X,onToggle:()=>N(!L),onChange:(q)=>B(Q,{...W,note:q})},void 0,!1,void 0,this),T&&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 My({id:Q,label:y,options:J,required:Y}){let{responses:$,setResponse:B}=P0(),W=$.get(Q),K=W?.value||[],X=W?.note||"",[L,N]=U0(!1),G=G0(null);if(!$.has(Q))B(Q,{id:Q,type:"checkbox",label:y,value:[],options:J,required:Y});let U=(q)=>{let b=K.includes(q)?K.filter((P)=>P!==q):[...K,q];B(Q,{...W,value:b})};q0(()=>{let q=G.current;if(!q)return;let b=(P)=>{let A=P.target.closest("[data-md-label]")?.getAttribute("data-md-label");if(A&&J.includes(A))U(A)};return q.addEventListener("kb-select",b),()=>q.removeEventListener("kb-select",b)},[J,U]);let T=W?.required&&K.length===0;return k("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:[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),Y&&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:J.map((q)=>{let b=K.includes(q);return k("label",{"data-md":"multichoice-option","data-md-label":q,onClick:()=>U(q),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${b?"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 ${b?"bg-accent-amber":"border-[1.5px] border-border-strong"}`,children:b&&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:q},void 0,!1,void 0,this)]},q,!0,void 0,this)})},void 0,!1,void 0,this),k(P1,{show:L,note:X,onToggle:()=>N(!L),onChange:(q)=>B(Q,{...W,note:q})},void 0,!1,void 0,this),T&&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{useRef as Ay,useState as H0}from"react";import{useAnnotations as b0}from"#canvas/runtime";import{jsxDEV as M}from"react/jsx-dev-runtime";function ky({id:Q,label:y,placeholder:J,multiline:Y,required:$}){let{responses:B,setResponse:W}=b0(),K=B.get(Q),X=K?.value??"",L=K?.note||"",[N,G]=H0(!1),U=Ay(null);if(!B.has(Q))W(Q,{id:Q,type:"text",label:y,value:"",required:$});let T=(P)=>{W(Q,{...K,value:P})},q=(P)=>Y1(P,Y?60:32),b=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:U,value:X,onChange:(P)=>{T(P.target.value),q(P.target)},placeholder:J||"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(P1,{show:N,note:L,onToggle:()=>G(!N),onChange:(P)=>W(Q,{...K,note:P})},void 0,!1,void 0,this),b&&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 zy({id:Q,label:y,min:J=1,max:Y=10,step:$=1,required:B,minLabel:W,maxLabel:K}){let{responses:X,setResponse:L}=b0(),N=X.get(Q),G=N?.value,U=N?.note||"",[T,q]=H0(!1);if(!X.has(Q))L(Q,{id:Q,type:"range",label:y,value:null,required:B});let b=(z)=>{L(Q,{...N,value:z})},P=G!==null&&G!==void 0,_=P?G:Math.round((J+Y)/2),A=(_-J)/(Y-J)*100,m=Math.round((Y-J)/$),r=m<=20,g=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(Q,{...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),r&&Array.from({length:m+1},(z,x)=>{let I=J+x*$,E=(I-J)/(Y-J)*100,O=P&&I<=G;return M("div",{className:`absolute rounded-full pointer-events-none transition-all duration-150 ${P&&I===G?"w-2.5 h-2.5 bg-accent-amber":O?"w-1.5 h-1.5 bg-accent-amber":"w-1.5 h-1.5 bg-border-hover"}`,style:{left:`${E}%`,transform:"translate(-50%, -50%)",top:"50%"}},x,!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:J,max:Y,step:$,value:_,onChange:(z)=>b(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),r&&m<=10?M("div",{className:"flex justify-between -mt-0.5 px-0",children:Array.from({length:m+1},(z,x)=>{let I=J+x*$;return M("span",{className:`text-[10px] font-mono transition-colors ${P&&I===G?"text-accent-amber font-medium":"text-text-disabled"}`,style:{minWidth:"1ch",textAlign:"center"},children:I},x,!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||J},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(P1,{show:T,note:U,onToggle:()=>q(!T),onChange:(z)=>L(Q,{...N,note:z})},void 0,!1,void 0,this),g&&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 Oy,useState as Sy}from"react";import{SessionContext as Iy}from"#canvas/runtime";import{jsxDEV as T1}from"react/jsx-dev-runtime";function my({src:Q,alt:y,caption:J,width:Y,height:$}){let B=Oy(Iy),[W,K]=Sy(!1),X=`/api/image?session=${encodeURIComponent(B)}&path=${encodeURIComponent(Q)}`;if(W)return T1("div",{className:"mt-3 text-accent-red text-body bg-accent-red-muted rounded-md p-4",children:[Q,": Failed to load image"]},void 0,!0,void 0,this);return T1("figure",{className:"mt-3 relative","data-md":"image","data-md-src":Q,children:[T1("div",{className:"rounded-md overflow-hidden border border-border-subtle bg-bg-code inline-block",children:T1("img",{src:X,alt:y||Q,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),J&&T1("figcaption",{className:"mt-1.5 text-meta text-text-tertiary font-body",children:J},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useMemo as _5}from"react";function E1(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var X1=E1();function v0(Q){X1=Q}var B1={exec:()=>null};function w(Q,y=""){let J=typeof Q=="string"?Q:Q.source,Y={replace:($,B)=>{let W=typeof B=="string"?B:B.source;return W=W.replace(V.caret,"$1"),J=J.replace($,W),Y},getRegex:()=>new RegExp(J,y)};return Y}var Ry=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),V={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:(Q)=>new RegExp(`^( {0,3}${Q})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}#`),htmlBeginRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}>`)},Cy=/^(?:[ \t]*(?:\n|$))+/,hy=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,gy=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,_1=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,jy=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,d1=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,M0=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,A0=w(M0).replace(/bull/g,d1).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(),Vy=w(M0).replace(/bull/g,d1).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(),u1=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,xy=/^[^\n]+/,r1=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Dy=w(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",r1).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),cy=w(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,d1).getRegex(),R1="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",i1=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,py=w("^ {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",i1).replace("tag",R1).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),k0=w(u1).replace("hr",_1).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",R1).getRegex(),Ey=w(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",k0).getRegex(),l1={blockquote:Ey,code:hy,def:Dy,fences:gy,heading:jy,hr:_1,html:py,lheading:A0,list:cy,newline:Cy,paragraph:k0,table:B1,text:xy},T0=w("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",_1).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",R1).getRegex(),dy={...l1,lheading:Vy,table:T0,paragraph:w(u1).replace("hr",_1).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",T0).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",R1).getRegex()},uy={...l1,html:w(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",i1).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:B1,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:w(u1).replace("hr",_1).replace("heading",` *#{1,6} *[^
|
|
6
|
-
]`).replace("lheading",
|
|
7
|
-
`).map((
|
|
8
|
-
`)}var
|
|
9
|
-
`)}}}fences(
|
|
10
|
-
`)}}blockquote(
|
|
5
|
+
`),Y=k5(B,$),W=[],L=0,X=0,K=0;while(L<B.length||X<$.length)if(K<Y.length&&L<B.length&&X<$.length&&B[L]===Y[K]&&$[X]===Y[K])W.push({type:"same",line:B[L]}),L++,X++,K++;else if(L<B.length&&(K>=Y.length||B[L]!==Y[K]))W.push({type:"removed",line:B[L]}),L++;else if(X<$.length)W.push({type:"added",line:$[X]}),X++;return T1("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden group/diff","data-md":"diff","data-md-language":Q||"",children:[Q&&T1("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),T1("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono",children:W.map((N,G)=>T1("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:[T1("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 k5(J,y){let Q=J.length,B=y.length,$=Array.from({length:Q+1},()=>Array(B+1).fill(0));for(let X=1;X<=Q;X++)for(let K=1;K<=B;K++)$[X][K]=J[X-1]===y[K-1]?$[X-1][K-1]+1:Math.max($[X-1][K],$[X][K-1]);let Y=[],W=Q,L=B;while(W>0&&L>0)if(J[W-1]===y[L-1])Y.unshift(J[W-1]),W--,L--;else if($[W-1][L]>$[W][L-1])W--;else L--;return Y}import{useEffect as U0,useRef as P0,useState as H0}from"react";import{useAnnotations as b0}from"#canvas/runtime";import{jsxDEV as G0}from"react/jsx-dev-runtime";function H1({note:J,onChange:y}){return G0("div",{className:"mt-1.5",children:G0("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)=>B1(Q.target),ref:(Q)=>{if(Q)B1(Q)}},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as z}from"react/jsx-dev-runtime";function z5({id:J,label:y,options:Q,required:B}){let{responses:$,setResponse:Y}=b0(),W=$.get(J),L=W?.value,X=W?.note||"",[K,N]=H0(!1),G=P0(null);if(!$.has(J))Y(J,{id:J,type:"radio",label:y,value:null,options:Q,required:B});let U=(q)=>{Y(J,{...W,value:q})};U0(()=>{let q=G.current;if(!q)return;let b=(P)=>{let k=P.target.closest("[data-md-label]")?.getAttribute("data-md-label");if(k&&Q.includes(k))U(k)};return q.addEventListener("kb-select",b),()=>q.removeEventListener("kb-select",b)},[Q,U]);let T=W?.required&&!L;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),B&&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:()=>U(q),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${L===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 ${L===q?"border-accent-amber bg-accent-amber":"border-border-strong"}`,children:L===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(H1,{show:K,note:X,onToggle:()=>N(!K),onChange:(q)=>Y(J,{...W,note:q})},void 0,!1,void 0,this),T&&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 M5({id:J,label:y,options:Q,required:B}){let{responses:$,setResponse:Y}=b0(),W=$.get(J),L=W?.value||[],X=W?.note||"",[K,N]=H0(!1),G=P0(null);if(!$.has(J))Y(J,{id:J,type:"checkbox",label:y,value:[],options:Q,required:B});let U=(q)=>{let b=L.includes(q)?L.filter((P)=>P!==q):[...L,q];Y(J,{...W,value:b})};U0(()=>{let q=G.current;if(!q)return;let b=(P)=>{let k=P.target.closest("[data-md-label]")?.getAttribute("data-md-label");if(k&&Q.includes(k))U(k)};return q.addEventListener("kb-select",b),()=>q.removeEventListener("kb-select",b)},[Q,U]);let T=W?.required&&L.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),B&&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 b=L.includes(q);return z("label",{"data-md":"multichoice-option","data-md-label":q,onClick:()=>U(q),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${b?"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 ${b?"bg-accent-amber":"border-[1.5px] border-border-strong"}`,children:b&&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(H1,{show:K,note:X,onToggle:()=>N(!K),onChange:(q)=>Y(J,{...W,note:q})},void 0,!1,void 0,this),T&&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{useRef as O5,useState as T0}from"react";import{useAnnotations as Z0}from"#canvas/runtime";import{jsxDEV as v}from"react/jsx-dev-runtime";function S5({id:J,label:y,placeholder:Q,multiline:B,required:$}){let{responses:Y,setResponse:W}=Z0(),L=Y.get(J),X=L?.value??"",K=L?.note||"",[N,G]=T0(!1),U=O5(null);if(!Y.has(J))W(J,{id:J,type:"text",label:y,value:"",required:$});let T=(P)=>{W(J,{...L,value:P})},q=(P)=>B1(P,B?60:32),b=L?.required&&!X.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:U,value:X,onChange:(P)=>{T(P.target.value),q(P.target)},placeholder:Q||"Type your response...",rows:B?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),v(H1,{show:N,note:K,onToggle:()=>G(!N),onChange:(P)=>W(J,{...L,note:P})},void 0,!1,void 0,this),b&&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 I5({id:J,label:y,min:Q=1,max:B=10,step:$=1,required:Y,minLabel:W,maxLabel:L}){let{responses:X,setResponse:K}=Z0(),N=X.get(J),G=N?.value,U=N?.note||"",[T,q]=T0(!1);if(!X.has(J))K(J,{id:J,type:"range",label:y,value:null,required:Y});let b=(M)=>{K(J,{...N,value:M})},P=G!==null&&G!==void 0,_=P?G:Math.round((Q+B)/2),k=(_-Q)/(B-Q)*100,m=Math.round((B-Q)/$),r=m<=20,g=N?.required&&!P;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),Y&&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 ${P?"text-accent-amber":"text-text-disabled"}`,children:P?G:"—"},void 0,!1,void 0,this),P&&v("button",{onClick:()=>K(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),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:P&&v("div",{className:"h-full rounded-full bg-accent-amber transition-all duration-150",style:{width:`${k}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this),r&&Array.from({length:m+1},(M,x)=>{let I=Q+x*$,E=(I-Q)/(B-Q)*100,O=P&&I<=G;return v("div",{className:`absolute rounded-full pointer-events-none transition-all duration-150 ${P&&I===G?"w-2.5 h-2.5 bg-accent-amber":O?"w-1.5 h-1.5 bg-accent-amber":"w-1.5 h-1.5 bg-border-hover"}`,style:{left:`${E}%`,transform:"translate(-50%, -50%)",top:"50%"}},x,!1,void 0,this)}),P?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(${k}% - 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:Q,max:B,step:$,value:_,onChange:(M)=>b(Number(M.target.value)),className:"absolute inset-0 w-full opacity-0 cursor-pointer"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),r&&m<=10?v("div",{className:"flex justify-between -mt-0.5 px-0",children:Array.from({length:m+1},(M,x)=>{let I=Q+x*$;return v("span",{className:`text-[10px] font-mono transition-colors ${P&&I===G?"text-accent-amber font-medium":"text-text-disabled"}`,style:{minWidth:"1ch",textAlign:"center"},children:I},x,!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:W||Q},void 0,!1,void 0,this),v("span",{className:"text-[11px] text-text-tertiary font-body",children:L||B},void 0,!1,void 0,this)]},void 0,!0,void 0,this),v(H1,{show:T,note:U,onToggle:()=>q(!T),onChange:(M)=>K(J,{...N,note:M})},void 0,!1,void 0,this),g&&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 m5,useState as C5}from"react";import{SessionContext as R5}from"#canvas/runtime";import{jsxDEV as Z1}from"react/jsx-dev-runtime";function h5({src:J,alt:y,caption:Q,width:B,height:$}){let Y=m5(R5),[W,L]=C5(!1),X=`/api/image?session=${encodeURIComponent(Y)}&path=${encodeURIComponent(J)}`;if(W)return Z1("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 Z1("figure",{className:"mt-3 relative","data-md":"image","data-md-src":J,children:[Z1("div",{className:"rounded-md overflow-hidden border border-border-subtle bg-bg-code inline-block",children:Z1("img",{src:X,alt:y||J,onError:()=>L(!0),className:"block max-w-full h-auto",...B?{width:B}:{},...$?{height:$}:{}},void 0,!1,void 0,this)},void 0,!1,void 0,this),Q&&Z1("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 vy}from"react";function d1(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var L1=d1();function k0(J){L1=J}var W1={exec:()=>null};function w(J,y=""){let Q=typeof J=="string"?J:J.source,B={replace:($,Y)=>{let W=typeof Y=="string"?Y:Y.source;return W=W.replace(V.caret,"$1"),Q=Q.replace($,W),B},getRegex:()=>new RegExp(Q,y)};return B}var g5=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),V={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)}}>`)},j5=/^(?:[ \t]*(?:\n|$))+/,V5=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,x5=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,w1=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,D5=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,u1=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,z0=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,M0=w(z0).replace(/bull/g,u1).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(),c5=w(z0).replace(/bull/g,u1).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(),r1=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,p5=/^[^\n]+/,i1=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,E5=w(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",i1).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),d5=w(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,u1).getRegex(),R1="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",l1=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,u5=w("^ {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",l1).replace("tag",R1).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),O0=w(r1).replace("hr",w1).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",R1).getRegex(),r5=w(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",O0).getRegex(),a1={blockquote:r5,code:V5,def:E5,fences:x5,heading:D5,hr:w1,html:u5,lheading:M0,list:d5,newline:j5,paragraph:O0,table:W1,text:p5},F0=w("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",w1).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",R1).getRegex(),i5={...a1,lheading:c5,table:F0,paragraph:w(r1).replace("hr",w1).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",F0).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",R1).getRegex()},l5={...a1,html:w(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",l1).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:W1,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:w(r1).replace("hr",w1).replace("heading",` *#{1,6} *[^
|
|
6
|
+
]`).replace("lheading",M0).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},a5=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,o5=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,S0=/^( {2,}|\\)\n(?!\s*$)/,s5=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,h1=/[\p{P}\p{S}]/u,o1=/[\s\p{P}\p{S}]/u,I0=/[^\s\p{P}\p{S}]/u,n5=w(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,o1).getRegex(),m0=/(?!~)[\p{P}\p{S}]/u,t5=/(?!~)[\s\p{P}\p{S}]/u,e5=/(?:[^\s\p{P}\p{S}]|~)/u,C0=/(?![*_])[\p{P}\p{S}]/u,yy=/(?![*_])[\s\p{P}\p{S}]/u,$y=/(?:[^\s\p{P}\p{S}]|[*_])/u,Jy=w(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",g5?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),R0=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Qy=w(R0,"u").replace(/punct/g,h1).getRegex(),By=w(R0,"u").replace(/punct/g,m0).getRegex(),h0="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Yy=w(h0,"gu").replace(/notPunctSpace/g,I0).replace(/punctSpace/g,o1).replace(/punct/g,h1).getRegex(),Wy=w(h0,"gu").replace(/notPunctSpace/g,e5).replace(/punctSpace/g,t5).replace(/punct/g,m0).getRegex(),Xy=w("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,I0).replace(/punctSpace/g,o1).replace(/punct/g,h1).getRegex(),Ly=w(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,C0).getRegex(),Ky="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Ny=w(Ky,"gu").replace(/notPunctSpace/g,$y).replace(/punctSpace/g,yy).replace(/punct/g,C0).getRegex(),qy=w(/\\(punct)/,"gu").replace(/punct/g,h1).getRegex(),Gy=w(/^<(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(),Uy=w(l1).replace("(?:-->|$)","-->").getRegex(),Py=w("^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",Uy).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),I1=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Hy=w(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",I1).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),g0=w(/^!?\[(label)\]\[(ref)\]/).replace("label",I1).replace("ref",i1).getRegex(),j0=w(/^!?\[(ref)\](?:\[\])?/).replace("ref",i1).getRegex(),by=w("reflink|nolink(?!\\()","g").replace("reflink",g0).replace("nolink",j0).getRegex(),f0=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,s1={_backpedal:W1,anyPunctuation:qy,autolink:Gy,blockSkip:Jy,br:S0,code:o5,del:W1,delLDelim:W1,delRDelim:W1,emStrongLDelim:Qy,emStrongRDelimAst:Yy,emStrongRDelimUnd:Xy,escape:a5,link:Hy,nolink:j0,punctuation:n5,reflink:g0,reflinkSearch:by,tag:Py,text:s5,url:W1},Ty={...s1,link:w(/^!?\[(label)\]\((.*?)\)/).replace("label",I1).getRegex(),reflink:w(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",I1).getRegex()},E1={...s1,emStrongRDelimAst:Wy,emStrongLDelim:By,delLDelim:Ly,delRDelim:Ny,url:w(/^((?: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:w(/^([`~]+|[^`~])(?:(?= {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()},Zy={...E1,br:w(S0).replace("{2,}","*").getRegex(),text:w(E1.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},S1={normal:a1,gfm:i5,pedantic:l5},F1={normal:s1,gfm:E1,breaks:Zy,pedantic:Ty},Fy={"&":"&","<":"<",">":">",'"':""","'":"'"},_0=(J)=>Fy[J];function n(J,y){if(y){if(V.escapeTest.test(J))return J.replace(V.escapeReplace,_0)}else if(V.escapeTestNoEncode.test(J))return J.replace(V.escapeReplaceNoEncode,_0);return J}function w0(J){try{J=encodeURI(J).replace(V.percentDecode,"%")}catch{return null}return J}function A0(J,y){let Q=J.replace(V.findPipe,(Y,W,L)=>{let X=!1,K=W;for(;--K>=0&&L[K]==="\\";)X=!X;return X?"|":" |"}),B=Q.split(V.splitPipe),$=0;if(B[0].trim()||B.shift(),B.length>0&&!B.at(-1)?.trim()&&B.pop(),y)if(B.length>y)B.splice(y);else for(;B.length<y;)B.push("");for(;$<B.length;$++)B[$]=B[$].trim().replace(V.slashPipe,"|");return B}function f1(J,y,Q){let B=J.length;if(B===0)return"";let $=0;for(;$<B;){let Y=J.charAt(B-$-1);if(Y===y&&!Q)$++;else if(Y!==y&&Q)$++;else break}return J.slice(0,B-$)}function fy(J,y){if(J.indexOf(y[1])===-1)return-1;let Q=0;for(let B=0;B<J.length;B++)if(J[B]==="\\")B++;else if(J[B]===y[0])Q++;else if(J[B]===y[1]&&(Q--,Q<0))return B;return Q>0?-2:-1}function _y(J,y=0){let Q=y,B="";for(let $ of J)if($==="\t"){let Y=4-Q%4;B+=" ".repeat(Y),Q+=Y}else B+=$,Q++;return B}function v0(J,y,Q,B,$){let Y=y.href,W=y.title||null,L=J[1].replace($.other.outputLinkReplace,"$1");B.state.inLink=!0;let X={type:J[0].charAt(0)==="!"?"image":"link",raw:Q,href:Y,title:W,text:L,tokens:B.inlineTokens(L)};return B.state.inLink=!1,X}function wy(J,y,Q){let B=J.match(Q.other.indentCodeCompensation);if(B===null)return y;let $=B[1];return y.split(`
|
|
7
|
+
`).map((Y)=>{let W=Y.match(Q.other.beginningSpace);if(W===null)return Y;let[L]=W;return L.length>=$.length?Y.slice($.length):Y}).join(`
|
|
8
|
+
`)}var m1=class{options;rules;lexer;constructor(J){this.options=J||L1}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:f1(Q,`
|
|
9
|
+
`)}}}fences(J){let y=this.rules.block.fences.exec(J);if(y){let Q=y[0],B=wy(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:B}}}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 B=f1(Q,"#");(this.options.pedantic||!B||this.rules.other.endingSpaceChar.test(B))&&(Q=B.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:f1(y[0],`
|
|
10
|
+
`)}}blockquote(J){let y=this.rules.block.blockquote.exec(J);if(y){let Q=f1(y[0],`
|
|
11
11
|
`).split(`
|
|
12
|
-
`),
|
|
13
|
-
`),N=
|
|
14
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");
|
|
15
|
-
${
|
|
16
|
-
${N}`:N;let G=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(N,
|
|
17
|
-
`+
|
|
18
|
-
`),b=this.blockquote(q);
|
|
19
|
-
`+
|
|
20
|
-
`),b=this.list(q);
|
|
21
|
-
`);continue}}return{type:"blockquote",raw:
|
|
22
|
-
`,1)[0],y[1].length),U=
|
|
23
|
-
`,1)[0],T=!G.trim(),q=0;if(this.options.pedantic?(q=2,N=G.trimStart()):T?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),T&&this.rules.other.blankLine.test(U)&&(
|
|
24
|
-
`,
|
|
25
|
-
`,1)[0],
|
|
26
|
-
`+
|
|
27
|
-
`+U}T=!U.trim(),
|
|
28
|
-
`,
|
|
29
|
-
`):[],
|
|
30
|
-
`?y[1].slice(0,-1):y[1];return{type:"paragraph",raw:y[0],text:
|
|
31
|
-
`),this.blockTokens(y,this.tokens);for(let
|
|
32
|
-
`:
|
|
12
|
+
`),B="",$="",Y=[];for(;Q.length>0;){let W=!1,L=[],X;for(X=0;X<Q.length;X++)if(this.rules.other.blockquoteStart.test(Q[X]))L.push(Q[X]),W=!0;else if(!W)L.push(Q[X]);else break;Q=Q.slice(X);let K=L.join(`
|
|
13
|
+
`),N=K.replace(this.rules.other.blockquoteSetextReplace,`
|
|
14
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");B=B?`${B}
|
|
15
|
+
${K}`:K,$=$?`${$}
|
|
16
|
+
${N}`:N;let G=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(N,Y,!0),this.lexer.state.top=G,Q.length===0)break;let U=Y.at(-1);if(U?.type==="code")break;if(U?.type==="blockquote"){let T=U,q=T.raw+`
|
|
17
|
+
`+Q.join(`
|
|
18
|
+
`),b=this.blockquote(q);Y[Y.length-1]=b,B=B.substring(0,B.length-T.raw.length)+b.raw,$=$.substring(0,$.length-T.text.length)+b.text;break}else if(U?.type==="list"){let T=U,q=T.raw+`
|
|
19
|
+
`+Q.join(`
|
|
20
|
+
`),b=this.list(q);Y[Y.length-1]=b,B=B.substring(0,B.length-U.raw.length)+b.raw,$=$.substring(0,$.length-T.raw.length)+b.raw,Q=q.substring(Y.at(-1).raw.length).split(`
|
|
21
|
+
`);continue}}return{type:"blockquote",raw:B,tokens:Y,text:$}}}list(J){let y=this.rules.block.list.exec(J);if(y){let Q=y[1].trim(),B=Q.length>1,$={type:"list",raw:"",ordered:B,start:B?+Q.slice(0,-1):"",loose:!1,items:[]};Q=B?`\\d{1,9}\\${Q.slice(-1)}`:`\\${Q}`,this.options.pedantic&&(Q=B?Q:"[*+-]");let Y=this.rules.other.listItemRegex(Q),W=!1;for(;J;){let X=!1,K="",N="";if(!(y=Y.exec(J))||this.rules.block.hr.test(J))break;K=y[0],J=J.substring(K.length);let G=_y(y[2].split(`
|
|
22
|
+
`,1)[0],y[1].length),U=J.split(`
|
|
23
|
+
`,1)[0],T=!G.trim(),q=0;if(this.options.pedantic?(q=2,N=G.trimStart()):T?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),T&&this.rules.other.blankLine.test(U)&&(K+=U+`
|
|
24
|
+
`,J=J.substring(U.length+1),X=!0),!X){let b=this.rules.other.nextBulletRegex(q),P=this.rules.other.hrRegex(q),_=this.rules.other.fencesBeginRegex(q),k=this.rules.other.headingBeginRegex(q),m=this.rules.other.htmlBeginRegex(q),r=this.rules.other.blockquoteBeginRegex(q);for(;J;){let g=J.split(`
|
|
25
|
+
`,1)[0],M;if(U=g,this.options.pedantic?(U=U.replace(this.rules.other.listReplaceNesting," "),M=U):M=U.replace(this.rules.other.tabCharGlobal," "),_.test(U)||k.test(U)||m.test(U)||r.test(U)||b.test(U)||P.test(U))break;if(M.search(this.rules.other.nonSpaceChar)>=q||!U.trim())N+=`
|
|
26
|
+
`+M.slice(q);else{if(T||G.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||_.test(G)||k.test(G)||P.test(G))break;N+=`
|
|
27
|
+
`+U}T=!U.trim(),K+=g+`
|
|
28
|
+
`,J=J.substring(g.length+1),G=M.slice(q)}}$.loose||(W?$.loose=!0:this.rules.other.doubleBlankLine.test(K)&&(W=!0)),$.items.push({type:"list_item",raw:K,task:!!this.options.gfm&&this.rules.other.listIsTask.test(N),loose:!1,text:N,tokens:[]}),$.raw+=K}let L=$.items.at(-1);if(L)L.raw=L.raw.trimEnd(),L.text=L.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 K=this.rules.other.listTaskCheckbox.exec(X.raw);if(K){let N={type:"checkbox",raw:K[0]+" ",checked:K[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 K=X.tokens.filter((G)=>G.type==="space"),N=K.length>0&&K.some((G)=>this.rules.other.anyLine.test(G.raw));$.loose=N}}if($.loose)for(let X of $.items){X.loose=!0;for(let K of X.tokens)K.type==="text"&&(K.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," "),B=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:B,title:$}}}table(J){let y=this.rules.block.table.exec(J);if(!y||!this.rules.other.tableDelimiter.test(y[2]))return;let Q=A0(y[1]),B=y[2].replace(this.rules.other.tableAlignChars,"").split("|"),$=y[3]?.trim()?y[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
29
|
+
`):[],Y={type:"table",raw:y[0],header:[],align:[],rows:[]};if(Q.length===B.length){for(let W of B)this.rules.other.tableAlignRight.test(W)?Y.align.push("right"):this.rules.other.tableAlignCenter.test(W)?Y.align.push("center"):this.rules.other.tableAlignLeft.test(W)?Y.align.push("left"):Y.align.push(null);for(let W=0;W<Q.length;W++)Y.header.push({text:Q[W],tokens:this.lexer.inline(Q[W]),header:!0,align:Y.align[W]});for(let W of $)Y.rows.push(A0(W,Y.header.length).map((L,X)=>({text:L,tokens:this.lexer.inline(L),header:!1,align:Y.align[X]})));return Y}}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 Y=f1(Q.slice(0,-1),"\\");if((Q.length-Y.length)%2===0)return}else{let Y=fy(y[2],"()");if(Y===-2)return;if(Y>-1){let W=(y[0].indexOf("!")===0?5:4)+y[1].length+Y;y[2]=y[2].substring(0,Y),y[0]=y[0].substring(0,W).trim(),y[3]=""}}let B=y[2],$="";if(this.options.pedantic){let Y=this.rules.other.pedanticHrefTitle.exec(B);Y&&(B=Y[1],$=Y[3])}else $=y[3]?y[3].slice(1,-1):"";return B=B.trim(),this.rules.other.startAngleBracket.test(B)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(Q)?B=B.slice(1):B=B.slice(1,-1)),v0(y,{href:B&&B.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 B=(Q[2]||Q[1]).replace(this.rules.other.multipleSpaceGlobal," "),$=y[B.toLowerCase()];if(!$){let Y=Q[0].charAt(0);return{type:"text",raw:Y,text:Y}}return v0(Q,$,Q[0],this.lexer,this.rules)}}emStrong(J,y,Q=""){let B=this.rules.inline.emStrongLDelim.exec(J);if(!B||B[3]&&Q.match(this.rules.other.unicodeAlphaNumeric))return;if(!(B[1]||B[2])||!Q||this.rules.inline.punctuation.exec(Q)){let $=[...B[0]].length-1,Y,W,L=$,X=0,K=B[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(K.lastIndex=0,y=y.slice(-1*J.length+$);(B=K.exec(y))!=null;){if(Y=B[1]||B[2]||B[3]||B[4]||B[5]||B[6],!Y)continue;if(W=[...Y].length,B[3]||B[4]){L+=W;continue}else if((B[5]||B[6])&&$%3&&!(($+W)%3)){X+=W;continue}if(L-=W,L>0)continue;W=Math.min(W,W+L+X);let N=[...B[0]][0].length,G=J.slice(0,$+B.index+N+W);if(Math.min($,W)%2){let T=G.slice(1,-1);return{type:"em",raw:G,text:T,tokens:this.lexer.inlineTokens(T)}}let U=G.slice(2,-2);return{type:"strong",raw:G,text:U,tokens:this.lexer.inlineTokens(U)}}}}codespan(J){let y=this.rules.inline.code.exec(J);if(y){let Q=y[2].replace(this.rules.other.newLineCharGlobal," "),B=this.rules.other.nonSpaceChar.test(Q),$=this.rules.other.startingSpaceChar.test(Q)&&this.rules.other.endingSpaceChar.test(Q);return B&&$&&(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 B=this.rules.inline.delLDelim.exec(J);if(!B)return;if(!B[1]||!Q||this.rules.inline.punctuation.exec(Q)){let $=[...B[0]].length-1,Y,W,L=$,X=this.rules.inline.delRDelim;for(X.lastIndex=0,y=y.slice(-1*J.length+$);(B=X.exec(y))!=null;){if(Y=B[1]||B[2]||B[3]||B[4]||B[5]||B[6],!Y||(W=[...Y].length,W!==$))continue;if(B[3]||B[4]){L+=W;continue}if(L-=W,L>0)continue;W=Math.min(W,W+L);let K=[...B[0]][0].length,N=J.slice(0,$+B.index+K+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,B;return y[2]==="@"?(Q=y[1],B="mailto:"+Q):(Q=y[1],B=Q),{type:"link",raw:y[0],text:Q,href:B,tokens:[{type:"text",raw:Q,text:Q}]}}}url(J){let y;if(y=this.rules.inline.url.exec(J)){let Q,B;if(y[2]==="@")Q=y[0],B="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."?B="http://"+y[0]:B=y[0]}return{type:"link",raw:y[0],text:Q,href:B,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}}}},l=class J{tokens;options;state;inlineQueue;tokenizer;constructor(y){this.tokens=[],this.tokens.links=Object.create(null),this.options=y||L1,this.options.tokenizer=this.options.tokenizer||new m1,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:V,block:S1.normal,inline:F1.normal};this.options.pedantic?(Q.block=S1.pedantic,Q.inline=F1.pedantic):this.options.gfm&&(Q.block=S1.gfm,this.options.breaks?Q.inline=F1.breaks:Q.inline=F1.gfm),this.tokenizer.rules=Q}static get rules(){return{block:S1,inline:F1}}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(V.carriageReturn,`
|
|
31
|
+
`),this.blockTokens(y,this.tokens);for(let Q=0;Q<this.inlineQueue.length;Q++){let B=this.inlineQueue[Q];this.inlineTokens(B.src,B.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(y,Q=[],B=!1){for(this.options.pedantic&&(y=y.replace(V.tabCharGlobal," ").replace(V.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
34
|
`)+$.raw,W.text+=`
|
|
35
|
-
`+$.text,this.inlineQueue.at(-1).src=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
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},
|
|
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 Y=y;if(this.options.extensions?.startBlock){let W=1/0,L=y.slice(1),X;this.options.extensions.startBlock.forEach((K)=>{X=K.call({lexer:this},L),typeof X=="number"&&X>=0&&(W=Math.min(W,X))}),W<1/0&&W>=0&&(Y=y.substring(0,W+1))}if(this.state.top&&($=this.tokenizer.paragraph(Y))){let W=Q.at(-1);B&&W?.type==="paragraph"?(W.raw+=(W.raw.endsWith(`
|
|
39
39
|
`)?"":`
|
|
40
40
|
`)+$.raw,W.text+=`
|
|
41
|
-
`+$.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=W.text):
|
|
41
|
+
`+$.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=W.text):Q.push($),B=Y.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
43
|
`)+$.raw,W.text+=`
|
|
44
|
-
`+$.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=W.text):
|
|
45
|
-
`;return
|
|
46
|
-
`:"<pre><code>"+(
|
|
47
|
-
`}blockquote({tokens:
|
|
48
|
-
${this.parser.parse(
|
|
49
|
-
`}html({text:
|
|
50
|
-
`}hr(
|
|
51
|
-
`}list(
|
|
52
|
-
`+
|
|
53
|
-
`}listitem(
|
|
54
|
-
`}checkbox({checked:
|
|
55
|
-
`}table(
|
|
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 B=y,$=null;if(this.tokens.links){let X=Object.keys(this.tokens.links);if(X.length>0)for(;($=this.tokenizer.rules.inline.reflinkSearch.exec(B))!=null;)X.includes($[0].slice($[0].lastIndexOf("[")+1,-1))&&(B=B.slice(0,$.index)+"["+"a".repeat($[0].length-2)+"]"+B.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;($=this.tokenizer.rules.inline.anyPunctuation.exec(B))!=null;)B=B.slice(0,$.index)+"++"+B.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let Y;for(;($=this.tokenizer.rules.inline.blockSkip.exec(B))!=null;)Y=$[2]?$[2].length:0,B=B.slice(0,$.index+Y)+"["+"a".repeat($[0].length-Y-2)+"]"+B.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);B=this.options.hooks?.emStrongMask?.call({lexer:this},B)??B;let W=!1,L="";for(;y;){W||(L=""),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,B,L)){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,B,L)){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 K=y;if(this.options.extensions?.startInline){let N=1/0,G=y.slice(1),U;this.options.extensions.startInline.forEach((T)=>{U=T.call({lexer:this},G),typeof U=="number"&&U>=0&&(N=Math.min(N,U))}),N<1/0&&N>=0&&(K=y.substring(0,N+1))}if(X=this.tokenizer.inlineText(K)){y=y.substring(X.raw.length),X.raw.slice(-1)!=="_"&&(L=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}},C1=class{options;parser;constructor(J){this.options=J||L1}space(J){return""}code({text:J,lang:y,escaped:Q}){let B=(y||"").match(V.notSpaceStart)?.[0],$=J.replace(V.endingNewline,"")+`
|
|
45
|
+
`;return B?'<pre><code class="language-'+n(B)+'">'+(Q?$:n($,!0))+`</code></pre>
|
|
46
|
+
`:"<pre><code>"+(Q?$:n($,!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,B="";for(let W=0;W<J.items.length;W++){let L=J.items[W];B+=this.listitem(L)}let $=y?"ol":"ul",Y=y&&Q!==1?' start="'+Q+'"':"";return"<"+$+Y+`>
|
|
52
|
+
`+B+"</"+$+`>
|
|
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 B="";for(let $=0;$<J.rows.length;$++){let Y=J.rows[$];Q="";for(let W=0;W<Y.length;W++)Q+=this.tablecell(Y[W]);B+=this.tablerow({text:Q})}return B&&(B=`<tbody>${B}</tbody>`),`<table>
|
|
56
56
|
<thead>
|
|
57
57
|
`+y+`</thead>
|
|
58
|
-
`+
|
|
59
|
-
`}tablerow({text:
|
|
60
|
-
${
|
|
61
|
-
`}tablecell(
|
|
62
|
-
`}strong({tokens:
|
|
63
|
-
Please report this to https://github.com/markedjs/marked.`,
|
|
58
|
+
`+B+`</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>${n(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 B=this.parser.parseInline(Q),$=w0(J);if($===null)return B;J=$;let Y='<a href="'+J+'"';return y&&(Y+=' title="'+n(y)+'"'),Y+=">"+B+"</a>",Y}image({href:J,title:y,text:Q,tokens:B}){B&&(Q=this.parser.parseInline(B,this.parser.textRenderer));let $=w0(J);if($===null)return n(Q);J=$;let Y=`<img src="${J}" alt="${n(Q)}"`;return y&&(Y+=` title="${n(y)}"`),Y+=">",Y}text(J){return"tokens"in J&&J.tokens?this.parser.parseInline(J.tokens):("escaped"in J)&&J.escaped?J.text:n(J.text)}},n1=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}},a=class J{options;renderer;textRenderer;constructor(y){this.options=y||L1,this.options.renderer=this.options.renderer||new C1,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new n1}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 B=0;B<y.length;B++){let $=y[B];if(this.options.extensions?.renderers?.[$.type]){let W=$,L=this.options.extensions.renderers[W.type].call({parser:this},W);if(L!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(W.type)){Q+=L||"";continue}}let Y=$;switch(Y.type){case"space":{Q+=this.renderer.space(Y);break}case"hr":{Q+=this.renderer.hr(Y);break}case"heading":{Q+=this.renderer.heading(Y);break}case"code":{Q+=this.renderer.code(Y);break}case"table":{Q+=this.renderer.table(Y);break}case"blockquote":{Q+=this.renderer.blockquote(Y);break}case"list":{Q+=this.renderer.list(Y);break}case"checkbox":{Q+=this.renderer.checkbox(Y);break}case"html":{Q+=this.renderer.html(Y);break}case"def":{Q+=this.renderer.def(Y);break}case"paragraph":{Q+=this.renderer.paragraph(Y);break}case"text":{Q+=this.renderer.text(Y);break}default:{let W='Token with "'+Y.type+'" type was not found.';if(this.options.silent)return console.error(W),"";throw Error(W)}}}return Q}parseInline(y,Q=this.renderer){let B="";for(let $=0;$<y.length;$++){let Y=y[$];if(this.options.extensions?.renderers?.[Y.type]){let L=this.options.extensions.renderers[Y.type].call({parser:this},Y);if(L!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(Y.type)){B+=L||"";continue}}let W=Y;switch(W.type){case"escape":{B+=Q.text(W);break}case"html":{B+=Q.html(W);break}case"link":{B+=Q.link(W);break}case"image":{B+=Q.image(W);break}case"checkbox":{B+=Q.checkbox(W);break}case"strong":{B+=Q.strong(W);break}case"em":{B+=Q.em(W);break}case"codespan":{B+=Q.codespan(W);break}case"br":{B+=Q.br(W);break}case"del":{B+=Q.del(W);break}case"text":{B+=Q.text(W);break}default:{let L='Token with "'+W.type+'" type was not found.';if(this.options.silent)return console.error(L),"";throw Error(L)}}}return B}},_1=class{options;block;constructor(J){this.options=J||L1}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?l.lex:l.lexInline}provideParser(){return this.block?a.parse:a.parseInline}},Ay=class{defaults=d1();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=a;Renderer=C1;TextRenderer=n1;Lexer=l;Tokenizer=m1;Hooks=_1;constructor(...J){this.use(...J)}walkTokens(J,y){let Q=[];for(let B of J)switch(Q=Q.concat(y.call(this,B)),B.type){case"table":{let $=B;for(let Y of $.header)Q=Q.concat(this.walkTokens(Y.tokens,y));for(let Y of $.rows)for(let W of Y)Q=Q.concat(this.walkTokens(W.tokens,y));break}case"list":{let $=B;Q=Q.concat(this.walkTokens($.items,y));break}default:{let $=B;this.defaults.extensions?.childTokens?.[$.type]?this.defaults.extensions.childTokens[$.type].forEach((Y)=>{let W=$[Y].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 B={...Q};if(B.async=this.defaults.async||B.async||!1,Q.extensions&&(Q.extensions.forEach(($)=>{if(!$.name)throw Error("extension name required");if("renderer"in $){let Y=y.renderers[$.name];Y?y.renderers[$.name]=function(...W){let L=$.renderer.apply(this,W);return L===!1&&(L=Y.apply(this,W)),L}:y.renderers[$.name]=$.renderer}if("tokenizer"in $){if(!$.level||$.level!=="block"&&$.level!=="inline")throw Error("extension level must be 'block' or 'inline'");let Y=y[$.level];Y?Y.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)}),B.extensions=y),Q.renderer){let $=this.defaults.renderer||new C1(this.defaults);for(let Y in Q.renderer){if(!(Y in $))throw Error(`renderer '${Y}' does not exist`);if(["options","parser"].includes(Y))continue;let W=Y,L=Q.renderer[W],X=$[W];$[W]=(...K)=>{let N=L.apply($,K);return N===!1&&(N=X.apply($,K)),N||""}}B.renderer=$}if(Q.tokenizer){let $=this.defaults.tokenizer||new m1(this.defaults);for(let Y in Q.tokenizer){if(!(Y in $))throw Error(`tokenizer '${Y}' does not exist`);if(["options","rules","lexer"].includes(Y))continue;let W=Y,L=Q.tokenizer[W],X=$[W];$[W]=(...K)=>{let N=L.apply($,K);return N===!1&&(N=X.apply($,K)),N}}B.tokenizer=$}if(Q.hooks){let $=this.defaults.hooks||new _1;for(let Y in Q.hooks){if(!(Y in $))throw Error(`hook '${Y}' does not exist`);if(["options","block"].includes(Y))continue;let W=Y,L=Q.hooks[W],X=$[W];_1.passThroughHooks.has(Y)?$[W]=(K)=>{if(this.defaults.async&&_1.passThroughHooksRespectAsync.has(Y))return(async()=>{let G=await L.call($,K);return X.call($,G)})();let N=L.call($,K);return X.call($,N)}:$[W]=(...K)=>{if(this.defaults.async)return(async()=>{let G=await L.apply($,K);return G===!1&&(G=await X.apply($,K)),G})();let N=L.apply($,K);return N===!1&&(N=X.apply($,K)),N}}B.hooks=$}if(Q.walkTokens){let $=this.defaults.walkTokens,Y=Q.walkTokens;B.walkTokens=function(W){let L=[];return L.push(Y.call(this,W)),$&&(L=L.concat($.call(this,W))),L}}this.defaults={...this.defaults,...B}}),this}setOptions(J){return this.defaults={...this.defaults,...J},this}lexer(J,y){return l.lex(J,y??this.defaults)}parser(J,y){return a.parse(J,y??this.defaults)}parseMarkdown(J){return(y,Q)=>{let B={...Q},$={...this.defaults,...B},Y=this.onError(!!$.silent,!!$.async);if(this.defaults.async===!0&&B.async===!1)return Y(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 Y(Error("marked(): input parameter is undefined or null"));if(typeof y!="string")return Y(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,L=await($.hooks?await $.hooks.provideLexer():J?l.lex:l.lexInline)(W,$),X=$.hooks?await $.hooks.processAllTokens(L):L;$.walkTokens&&await Promise.all(this.walkTokens(X,$.walkTokens));let K=await($.hooks?await $.hooks.provideParser():J?a.parse:a.parseInline)(X,$);return $.hooks?await $.hooks.postprocess(K):K})().catch(Y);try{$.hooks&&(y=$.hooks.preprocess(y));let W=($.hooks?$.hooks.provideLexer():J?l.lex:l.lexInline)(y,$);$.hooks&&(W=$.hooks.processAllTokens(W)),$.walkTokens&&this.walkTokens(W,$.walkTokens);let L=($.hooks?$.hooks.provideParser():J?a.parse:a.parseInline)(W,$);return $.hooks&&(L=$.hooks.postprocess(L)),L}catch(W){return Y(W)}}}onError(J,y){return(Q)=>{if(Q.message+=`
|
|
63
|
+
Please report this to https://github.com/markedjs/marked.`,J){let B="<p>An error occurred:</p><pre>"+n(Q.message+"",!0)+"</pre>";return y?Promise.resolve(B):B}if(y)return Promise.reject(Q);throw Q}}},X1=new Ay;function A(J,y){return X1.parse(J,y)}A.options=A.setOptions=function(J){return X1.setOptions(J),A.defaults=X1.defaults,k0(A.defaults),A};A.getDefaults=d1;A.defaults=L1;A.use=function(...J){return X1.use(...J),A.defaults=X1.defaults,k0(A.defaults),A};A.walkTokens=function(J,y){return X1.walkTokens(J,y)};A.parseInline=X1.parseInline;A.Parser=a;A.parser=a.parse;A.Renderer=C1;A.TextRenderer=n1;A.Lexer=l;A.lexer=l.lex;A.Tokenizer=m1;A.Hooks=_1;A.parse=A;var{options:l2,setOptions:a2,use:o2,walkTokens:s2,parseInline:n2}=A;var t2=a.parse,e2=l.lex;import{jsxDEV as V0}from"react/jsx-dev-runtime";A.setOptions({gfm:!0,breaks:!1});function ky({children:J,file:y,__content:Q}){let B=Q??(typeof J==="string"?J:String(J??"")),$=vy(()=>{if(!B)return"";return A.parse(B,{async:!1})},[B]);if(!B)return V0("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 V0("div",{className:"mt-3 prose-canvas","data-md":"markdown",...y?{"data-md-file":y}:{},"data-md-source":B,dangerouslySetInnerHTML:{__html:$}},void 0,!1,void 0,this)}import{useFeedback as O4}from"#canvas/runtime";export{O4 as useFeedback,S5 as UserInput,d0 as Task,n0 as Table,D0 as Section,I5 as RangeInput,y5 as Priority,o0 as Note,M5 as MultiChoice,w5 as Mermaid,ky as Markdown,t1 as Item,h5 as ImageView,W5 as FilePreview,v5 as Diff,i0 as CodeBlock,z5 as Choice,t0 as Checklist,a0 as Callout};
|