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