@fabrika/builder 0.9.0-dev.14 → 0.9.0-dev.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,63 +1,63 @@
1
- var s5=Object.defineProperty;var t5=($)=>$;function e5($,J){this[$]=t5.bind(null,J)}var $2=($,J)=>{for(var Q in J)s5($,Q,{get:J[Q],enumerable:!0,configurable:!0,set:e5.bind(J,Q)})};import{useFeedback as KQ}from"#canvas/runtime";function H1(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var x$=H1();function c1($){x$=$}var m$={exec:()=>null};function E($,J=""){let Q=typeof $=="string"?$:$.source,q={replace:(W,Y)=>{let X=typeof Y=="string"?Y:Y.source;return X=X.replace(t.caret,"$1"),Q=Q.replace(W,X),q},getRegex:()=>new RegExp(Q,J)};return q}var J2=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),t={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:($)=>new RegExp(`^( {0,3}${$})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}#`),htmlBeginRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}>`)},Q2=/^(?:[ \t]*(?:\n|$))+/,W2=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,q2=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,L0=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Y2=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,G1=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,p1=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,d1=E(p1).replace(/bull/g,G1).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(),X2=E(p1).replace(/bull/g,G1).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(),B1=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,H2=/^[^\n]+/,_1=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,G2=E(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",_1).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),B2=E(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,G1).getRegex(),h0="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",M1=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,_2=E("^ {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",M1).replace("tag",h0).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),r1=E(B1).replace("hr",L0).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",h0).getRegex(),M2=E(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",r1).getRegex(),U1={blockquote:M2,code:W2,def:G2,fences:q2,heading:Y2,hr:L0,html:_2,lheading:d1,list:B2,newline:Q2,paragraph:r1,table:m$,text:H2},h1=E("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",L0).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",h0).getRegex(),U2={...U1,lheading:X2,table:h1,paragraph:E(B1).replace("hr",L0).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",h1).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",h0).getRegex()},w2={...U1,html:E(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",M1).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:m$,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:E(B1).replace("hr",L0).replace("heading",` *#{1,6} *[^
2
- ]`).replace("lheading",d1).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},z2=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,N2=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,i1=/^( {2,}|\\)\n(?!\s*$)/,K2=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,i$=/[\p{P}\p{S}]/u,m0=/[\s\p{P}\p{S}]/u,w1=/[^\s\p{P}\p{S}]/u,O2=E(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,m0).getRegex(),o1=/(?!~)[\p{P}\p{S}]/u,L2=/(?!~)[\s\p{P}\p{S}]/u,F2=/(?:[^\s\p{P}\p{S}]|~)/u,S2=E(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",J2?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),n1=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,A2=E(n1,"u").replace(/punct/g,i$).getRegex(),b2=E(n1,"u").replace(/punct/g,o1).getRegex(),a1="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",f2=E(a1,"gu").replace(/notPunctSpace/g,w1).replace(/punctSpace/g,m0).replace(/punct/g,i$).getRegex(),v2=E(a1,"gu").replace(/notPunctSpace/g,F2).replace(/punctSpace/g,L2).replace(/punct/g,o1).getRegex(),R2=E("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,w1).replace(/punctSpace/g,m0).replace(/punct/g,i$).getRegex(),j2=E(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,i$).getRegex(),V2="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",P2=E(V2,"gu").replace(/notPunctSpace/g,w1).replace(/punctSpace/g,m0).replace(/punct/g,i$).getRegex(),D2=E(/\\(punct)/,"gu").replace(/punct/g,i$).getRegex(),k2=E(/^<(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(),C2=E(M1).replace("(?:-->|$)","-->").getRegex(),E2=E("^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",C2).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),I0=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,T2=E(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",I0).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),s1=E(/^!?\[(label)\]\[(ref)\]/).replace("label",I0).replace("ref",_1).getRegex(),t1=E(/^!?\[(ref)\](?:\[\])?/).replace("ref",_1).getRegex(),I2=E("reflink|nolink(?!\\()","g").replace("reflink",s1).replace("nolink",t1).getRegex(),m1=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,z1={_backpedal:m$,anyPunctuation:D2,autolink:k2,blockSkip:S2,br:i1,code:N2,del:m$,delLDelim:m$,delRDelim:m$,emStrongLDelim:A2,emStrongRDelimAst:f2,emStrongRDelimUnd:R2,escape:z2,link:T2,nolink:t1,punctuation:O2,reflink:s1,reflinkSearch:I2,tag:E2,text:K2,url:m$},y2={...z1,link:E(/^!?\[(label)\]\((.*?)\)/).replace("label",I0).getRegex(),reflink:E(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",I0).getRegex()},X1={...z1,emStrongRDelimAst:v2,emStrongLDelim:b2,delLDelim:j2,delRDelim:P2,url:E(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",m1).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:E(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",m1).getRegex()},g2={...X1,br:E(i1).replace("{2,}","*").getRegex(),text:E(X1.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},T0={normal:U1,gfm:U2,pedantic:w2},N0={normal:z1,gfm:X1,breaks:g2,pedantic:y2},h2={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Z1=($)=>h2[$];function N$($,J){if(J){if(t.escapeTest.test($))return $.replace(t.escapeReplace,Z1)}else if(t.escapeTestNoEncode.test($))return $.replace(t.escapeReplaceNoEncode,Z1);return $}function x1($){try{$=encodeURI($).replace(t.percentDecode,"%")}catch{return null}return $}function u1($,J){let Q=$.replace(t.findPipe,(Y,X,G)=>{let H=!1,B=X;for(;--B>=0&&G[B]==="\\";)H=!H;return H?"|":" |"}),q=Q.split(t.splitPipe),W=0;if(q[0].trim()||q.shift(),q.length>0&&!q.at(-1)?.trim()&&q.pop(),J)if(q.length>J)q.splice(J);else for(;q.length<J;)q.push("");for(;W<q.length;W++)q[W]=q[W].trim().replace(t.slashPipe,"|");return q}function K0($,J,Q){let q=$.length;if(q===0)return"";let W=0;for(;W<q;){let Y=$.charAt(q-W-1);if(Y===J&&!Q)W++;else if(Y!==J&&Q)W++;else break}return $.slice(0,q-W)}function m2($,J){if($.indexOf(J[1])===-1)return-1;let Q=0;for(let q=0;q<$.length;q++)if($[q]==="\\")q++;else if($[q]===J[0])Q++;else if($[q]===J[1]&&(Q--,Q<0))return q;return Q>0?-2:-1}function Z2($,J=0){let Q=J,q="";for(let W of $)if(W==="\t"){let Y=4-Q%4;q+=" ".repeat(Y),Q+=Y}else q+=W,Q++;return q}function l1($,J,Q,q,W){let Y=J.href,X=J.title||null,G=$[1].replace(W.other.outputLinkReplace,"$1");q.state.inLink=!0;let H={type:$[0].charAt(0)==="!"?"image":"link",raw:Q,href:Y,title:X,text:G,tokens:q.inlineTokens(G)};return q.state.inLink=!1,H}function x2($,J,Q){let q=$.match(Q.other.indentCodeCompensation);if(q===null)return J;let W=q[1];return J.split(`
3
- `).map((Y)=>{let X=Y.match(Q.other.beginningSpace);if(X===null)return Y;let[G]=X;return G.length>=W.length?Y.slice(W.length):Y}).join(`
4
- `)}var y0=class{options;rules;lexer;constructor($){this.options=$||x$}space($){let J=this.rules.block.newline.exec($);if(J&&J[0].length>0)return{type:"space",raw:J[0]}}code($){let J=this.rules.block.code.exec($);if(J){let Q=J[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:J[0],codeBlockStyle:"indented",text:this.options.pedantic?Q:K0(Q,`
5
- `)}}}fences($){let J=this.rules.block.fences.exec($);if(J){let Q=J[0],q=x2(Q,J[3]||"",this.rules);return{type:"code",raw:Q,lang:J[2]?J[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):J[2],text:q}}}heading($){let J=this.rules.block.heading.exec($);if(J){let Q=J[2].trim();if(this.rules.other.endingHash.test(Q)){let q=K0(Q,"#");(this.options.pedantic||!q||this.rules.other.endingSpaceChar.test(q))&&(Q=q.trim())}return{type:"heading",raw:J[0],depth:J[1].length,text:Q,tokens:this.lexer.inline(Q)}}}hr($){let J=this.rules.block.hr.exec($);if(J)return{type:"hr",raw:K0(J[0],`
6
- `)}}blockquote($){let J=this.rules.block.blockquote.exec($);if(J){let Q=K0(J[0],`
1
+ import{useFeedback as Hd}from"#canvas/runtime";function an(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ze=an();function Un(e){ze=e}var Pe={exec:()=>null};function I(e,t=""){let n=typeof e=="string"?e:e.source,s={replace:(r,o)=>{let a=typeof o=="string"?o:o.source;return a=a.replace(J.caret,"$1"),n=n.replace(r,a),s},getRegex:()=>new RegExp(n,t)};return s}var Zr=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),J={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:(e)=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:(e)=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:(e)=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:(e)=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:(e)=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:(e)=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:(e)=>new RegExp(`^ {0,${Math.min(3,e-1)}}>`)},es=/^(?:[ \t]*(?:\n|$))+/,ts=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ns=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ot=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,rs=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ln=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Gn=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Kn=I(Gn).replace(/bull/g,ln).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(),ss=I(Gn).replace(/bull/g,ln).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(),cn=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,os=/^[^\n]+/,un=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,as=I(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",un).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),is=I(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ln).getRegex(),It="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",dn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ls=I("^ {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",dn).replace("tag",It).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Xn=I(cn).replace("hr",ot).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",It).getRegex(),cs=I(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Xn).getRegex(),pn={blockquote:cs,code:ts,def:as,fences:ns,heading:rs,hr:ot,html:ls,lheading:Kn,list:is,newline:es,paragraph:Xn,table:Pe,text:os},jn=I("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ot).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",It).getRegex(),us={...pn,lheading:ss,table:jn,paragraph:I(cn).replace("hr",ot).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",jn).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",It).getRegex()},ds={...pn,html:I(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",dn).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:Pe,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:I(cn).replace("hr",ot).replace("heading",` *#{1,6} *[^
2
+ ]`).replace("lheading",Kn).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ps=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,fs=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Yn=/^( {2,}|\\)\n(?!\s*$)/,hs=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,qe=/[\p{P}\p{S}]/u,Mt=/[\s\p{P}\p{S}]/u,fn=/[^\s\p{P}\p{S}]/u,ms=I(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Mt).getRegex(),Qn=/(?!~)[\p{P}\p{S}]/u,gs=/(?!~)[\s\p{P}\p{S}]/u,xs=/(?:[^\s\p{P}\p{S}]|~)/u,bs=I(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Zr?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Jn=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,ys=I(Jn,"u").replace(/punct/g,qe).getRegex(),vs=I(Jn,"u").replace(/punct/g,Qn).getRegex(),Zn="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ks=I(Zn,"gu").replace(/notPunctSpace/g,fn).replace(/punctSpace/g,Mt).replace(/punct/g,qe).getRegex(),_s=I(Zn,"gu").replace(/notPunctSpace/g,xs).replace(/punctSpace/g,gs).replace(/punct/g,Qn).getRegex(),ws=I("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,fn).replace(/punctSpace/g,Mt).replace(/punct/g,qe).getRegex(),Ts=I(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,qe).getRegex(),As="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Ss=I(As,"gu").replace(/notPunctSpace/g,fn).replace(/punctSpace/g,Mt).replace(/punct/g,qe).getRegex(),Rs=I(/\\(punct)/,"gu").replace(/punct/g,qe).getRegex(),Es=I(/^<(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(),Cs=I(dn).replace("(?:-->|$)","-->").getRegex(),Ns=I("^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",Cs).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Et=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Is=I(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Et).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),er=I(/^!?\[(label)\]\[(ref)\]/).replace("label",Et).replace("ref",un).getRegex(),tr=I(/^!?\[(ref)\](?:\[\])?/).replace("ref",un).getRegex(),Ms=I("reflink|nolink(?!\\()","g").replace("reflink",er).replace("nolink",tr).getRegex(),Bn=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,hn={_backpedal:Pe,anyPunctuation:Rs,autolink:Es,blockSkip:bs,br:Yn,code:fs,del:Pe,delLDelim:Pe,delRDelim:Pe,emStrongLDelim:ys,emStrongRDelimAst:ks,emStrongRDelimUnd:ws,escape:ps,link:Is,nolink:tr,punctuation:ms,reflink:er,reflinkSearch:Ms,tag:Ns,text:hs,url:Pe},Ls={...hn,link:I(/^!?\[(label)\]\((.*?)\)/).replace("label",Et).getRegex(),reflink:I(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Et).getRegex()},on={...hn,emStrongRDelimAst:_s,emStrongLDelim:vs,delLDelim:Ts,delRDelim:Ss,url:I(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Bn).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:I(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Bn).getRegex()},$s={...on,br:I(Yn).replace("{2,}","*").getRegex(),text:I(on.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Rt={normal:pn,gfm:us,pedantic:ds},nt={normal:hn,gfm:on,breaks:$s,pedantic:Ls},Ps={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Vn=(e)=>Ps[e];function fe(e,t){if(t){if(J.escapeTest.test(e))return e.replace(J.escapeReplace,Vn)}else if(J.escapeTestNoEncode.test(e))return e.replace(J.escapeReplaceNoEncode,Vn);return e}function qn(e){try{e=encodeURI(e).replace(J.percentDecode,"%")}catch{return null}return e}function Fn(e,t){let n=e.replace(J.findPipe,(o,a,l)=>{let i=!1,c=a;for(;--c>=0&&l[c]==="\\";)i=!i;return i?"|":" |"}),s=n.split(J.splitPipe),r=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;r<s.length;r++)s[r]=s[r].trim().replace(J.slashPipe,"|");return s}function rt(e,t,n){let s=e.length;if(s===0)return"";let r=0;for(;r<s;){let o=e.charAt(s-r-1);if(o===t&&!n)r++;else if(o!==t&&n)r++;else break}return e.slice(0,s-r)}function Os(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let s=0;s<e.length;s++)if(e[s]==="\\")s++;else if(e[s]===t[0])n++;else if(e[s]===t[1]&&(n--,n<0))return s;return n>0?-2:-1}function zs(e,t=0){let n=t,s="";for(let r of e)if(r==="\t"){let o=4-n%4;s+=" ".repeat(o),n+=o}else s+=r,n++;return s}function Wn(e,t,n,s,r){let o=t.href,a=t.title||null,l=e[1].replace(r.other.outputLinkReplace,"$1");s.state.inLink=!0;let i={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:a,text:l,tokens:s.inlineTokens(l)};return s.state.inLink=!1,i}function Hs(e,t,n){let s=e.match(n.other.indentCodeCompensation);if(s===null)return t;let r=s[1];return t.split(`
3
+ `).map((o)=>{let a=o.match(n.other.beginningSpace);if(a===null)return o;let[l]=a;return l.length>=r.length?o.slice(r.length):o}).join(`
4
+ `)}var Ct=class{options;rules;lexer;constructor(e){this.options=e||ze}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:rt(n,`
5
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=Hs(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let s=rt(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:rt(t[0],`
6
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=rt(t[0],`
7
7
  `).split(`
8
- `),q="",W="",Y=[];for(;Q.length>0;){let X=!1,G=[],H;for(H=0;H<Q.length;H++)if(this.rules.other.blockquoteStart.test(Q[H]))G.push(Q[H]),X=!0;else if(!X)G.push(Q[H]);else break;Q=Q.slice(H);let B=G.join(`
9
- `),_=B.replace(this.rules.other.blockquoteSetextReplace,`
10
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");q=q?`${q}
11
- ${B}`:B,W=W?`${W}
12
- ${_}`:_;let w=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(_,Y,!0),this.lexer.state.top=w,Q.length===0)break;let L=Y.at(-1);if(L?.type==="code")break;if(L?.type==="blockquote"){let F=L,U=F.raw+`
13
- `+Q.join(`
14
- `),K=this.blockquote(U);Y[Y.length-1]=K,q=q.substring(0,q.length-F.raw.length)+K.raw,W=W.substring(0,W.length-F.text.length)+K.text;break}else if(L?.type==="list"){let F=L,U=F.raw+`
15
- `+Q.join(`
16
- `),K=this.list(U);Y[Y.length-1]=K,q=q.substring(0,q.length-L.raw.length)+K.raw,W=W.substring(0,W.length-F.raw.length)+K.raw,Q=U.substring(Y.at(-1).raw.length).split(`
17
- `);continue}}return{type:"blockquote",raw:q,tokens:Y,text:W}}}list($){let J=this.rules.block.list.exec($);if(J){let Q=J[1].trim(),q=Q.length>1,W={type:"list",raw:"",ordered:q,start:q?+Q.slice(0,-1):"",loose:!1,items:[]};Q=q?`\\d{1,9}\\${Q.slice(-1)}`:`\\${Q}`,this.options.pedantic&&(Q=q?Q:"[*+-]");let Y=this.rules.other.listItemRegex(Q),X=!1;for(;$;){let H=!1,B="",_="";if(!(J=Y.exec($))||this.rules.block.hr.test($))break;B=J[0],$=$.substring(B.length);let w=Z2(J[2].split(`
18
- `,1)[0],J[1].length),L=$.split(`
19
- `,1)[0],F=!w.trim(),U=0;if(this.options.pedantic?(U=2,_=w.trimStart()):F?U=J[1].length+1:(U=w.search(this.rules.other.nonSpaceChar),U=U>4?1:U,_=w.slice(U),U+=J[1].length),F&&this.rules.other.blankLine.test(L)&&(B+=L+`
20
- `,$=$.substring(L.length+1),H=!0),!H){let K=this.rules.other.nextBulletRegex(U),O=this.rules.other.hrRegex(U),R=this.rules.other.fencesBeginRegex(U),I=this.rules.other.headingBeginRegex(U),y=this.rules.other.htmlBeginRegex(U),l=this.rules.other.blockquoteBeginRegex(U);for(;$;){let Z=$.split(`
21
- `,1)[0],x;if(L=Z,this.options.pedantic?(L=L.replace(this.rules.other.listReplaceNesting," "),x=L):x=L.replace(this.rules.other.tabCharGlobal," "),R.test(L)||I.test(L)||y.test(L)||l.test(L)||K.test(L)||O.test(L))break;if(x.search(this.rules.other.nonSpaceChar)>=U||!L.trim())_+=`
22
- `+x.slice(U);else{if(F||w.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||R.test(w)||I.test(w)||O.test(w))break;_+=`
23
- `+L}F=!L.trim(),B+=Z+`
24
- `,$=$.substring(Z.length+1),w=x.slice(U)}}W.loose||(X?W.loose=!0:this.rules.other.doubleBlankLine.test(B)&&(X=!0)),W.items.push({type:"list_item",raw:B,task:!!this.options.gfm&&this.rules.other.listIsTask.test(_),loose:!1,text:_,tokens:[]}),W.raw+=B}let G=W.items.at(-1);if(G)G.raw=G.raw.trimEnd(),G.text=G.text.trimEnd();else return;W.raw=W.raw.trimEnd();for(let H of W.items){if(this.lexer.state.top=!1,H.tokens=this.lexer.blockTokens(H.text,[]),H.task){if(H.text=H.text.replace(this.rules.other.listReplaceTask,""),H.tokens[0]?.type==="text"||H.tokens[0]?.type==="paragraph"){H.tokens[0].raw=H.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),H.tokens[0].text=H.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let _=this.lexer.inlineQueue.length-1;_>=0;_--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[_].src)){this.lexer.inlineQueue[_].src=this.lexer.inlineQueue[_].src.replace(this.rules.other.listReplaceTask,"");break}}let B=this.rules.other.listTaskCheckbox.exec(H.raw);if(B){let _={type:"checkbox",raw:B[0]+" ",checked:B[0]!=="[ ]"};H.checked=_.checked,W.loose?H.tokens[0]&&["paragraph","text"].includes(H.tokens[0].type)&&"tokens"in H.tokens[0]&&H.tokens[0].tokens?(H.tokens[0].raw=_.raw+H.tokens[0].raw,H.tokens[0].text=_.raw+H.tokens[0].text,H.tokens[0].tokens.unshift(_)):H.tokens.unshift({type:"paragraph",raw:_.raw,text:_.raw,tokens:[_]}):H.tokens.unshift(_)}}if(!W.loose){let B=H.tokens.filter((w)=>w.type==="space"),_=B.length>0&&B.some((w)=>this.rules.other.anyLine.test(w.raw));W.loose=_}}if(W.loose)for(let H of W.items){H.loose=!0;for(let B of H.tokens)B.type==="text"&&(B.type="paragraph")}return W}}html($){let J=this.rules.block.html.exec($);if(J)return{type:"html",block:!0,raw:J[0],pre:J[1]==="pre"||J[1]==="script"||J[1]==="style",text:J[0]}}def($){let J=this.rules.block.def.exec($);if(J){let Q=J[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),q=J[2]?J[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",W=J[3]?J[3].substring(1,J[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):J[3];return{type:"def",tag:Q,raw:J[0],href:q,title:W}}}table($){let J=this.rules.block.table.exec($);if(!J||!this.rules.other.tableDelimiter.test(J[2]))return;let Q=u1(J[1]),q=J[2].replace(this.rules.other.tableAlignChars,"").split("|"),W=J[3]?.trim()?J[3].replace(this.rules.other.tableRowBlankLine,"").split(`
25
- `):[],Y={type:"table",raw:J[0],header:[],align:[],rows:[]};if(Q.length===q.length){for(let X of q)this.rules.other.tableAlignRight.test(X)?Y.align.push("right"):this.rules.other.tableAlignCenter.test(X)?Y.align.push("center"):this.rules.other.tableAlignLeft.test(X)?Y.align.push("left"):Y.align.push(null);for(let X=0;X<Q.length;X++)Y.header.push({text:Q[X],tokens:this.lexer.inline(Q[X]),header:!0,align:Y.align[X]});for(let X of W)Y.rows.push(u1(X,Y.header.length).map((G,H)=>({text:G,tokens:this.lexer.inline(G),header:!1,align:Y.align[H]})));return Y}}lheading($){let J=this.rules.block.lheading.exec($);if(J){let Q=J[1].trim();return{type:"heading",raw:J[0],depth:J[2].charAt(0)==="="?1:2,text:Q,tokens:this.lexer.inline(Q)}}}paragraph($){let J=this.rules.block.paragraph.exec($);if(J){let Q=J[1].charAt(J[1].length-1)===`
26
- `?J[1].slice(0,-1):J[1];return{type:"paragraph",raw:J[0],text:Q,tokens:this.lexer.inline(Q)}}}text($){let J=this.rules.block.text.exec($);if(J)return{type:"text",raw:J[0],text:J[0],tokens:this.lexer.inline(J[0])}}escape($){let J=this.rules.inline.escape.exec($);if(J)return{type:"escape",raw:J[0],text:J[1]}}tag($){let J=this.rules.inline.tag.exec($);if(J)return!this.lexer.state.inLink&&this.rules.other.startATag.test(J[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(J[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(J[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(J[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:J[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:J[0]}}link($){let J=this.rules.inline.link.exec($);if(J){let Q=J[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(Q)){if(!this.rules.other.endAngleBracket.test(Q))return;let Y=K0(Q.slice(0,-1),"\\");if((Q.length-Y.length)%2===0)return}else{let Y=m2(J[2],"()");if(Y===-2)return;if(Y>-1){let X=(J[0].indexOf("!")===0?5:4)+J[1].length+Y;J[2]=J[2].substring(0,Y),J[0]=J[0].substring(0,X).trim(),J[3]=""}}let q=J[2],W="";if(this.options.pedantic){let Y=this.rules.other.pedanticHrefTitle.exec(q);Y&&(q=Y[1],W=Y[3])}else W=J[3]?J[3].slice(1,-1):"";return q=q.trim(),this.rules.other.startAngleBracket.test(q)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(Q)?q=q.slice(1):q=q.slice(1,-1)),l1(J,{href:q&&q.replace(this.rules.inline.anyPunctuation,"$1"),title:W&&W.replace(this.rules.inline.anyPunctuation,"$1")},J[0],this.lexer,this.rules)}}reflink($,J){let Q;if((Q=this.rules.inline.reflink.exec($))||(Q=this.rules.inline.nolink.exec($))){let q=(Q[2]||Q[1]).replace(this.rules.other.multipleSpaceGlobal," "),W=J[q.toLowerCase()];if(!W){let Y=Q[0].charAt(0);return{type:"text",raw:Y,text:Y}}return l1(Q,W,Q[0],this.lexer,this.rules)}}emStrong($,J,Q=""){let q=this.rules.inline.emStrongLDelim.exec($);if(!q||!q[1]&&!q[2]&&!q[3]&&!q[4]||q[4]&&Q.match(this.rules.other.unicodeAlphaNumeric))return;if(!(q[1]||q[3])||!Q||this.rules.inline.punctuation.exec(Q)){let W=[...q[0]].length-1,Y,X,G=W,H=0,B=q[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(B.lastIndex=0,J=J.slice(-1*$.length+W);(q=B.exec(J))!==null;){if(Y=q[1]||q[2]||q[3]||q[4]||q[5]||q[6],!Y)continue;if(X=[...Y].length,q[3]||q[4]){G+=X;continue}else if((q[5]||q[6])&&W%3&&!((W+X)%3)){H+=X;continue}if(G-=X,G>0)continue;X=Math.min(X,X+G+H);let _=[...q[0]][0].length,w=$.slice(0,W+q.index+_+X);if(Math.min(W,X)%2){let F=w.slice(1,-1);return{type:"em",raw:w,text:F,tokens:this.lexer.inlineTokens(F)}}let L=w.slice(2,-2);return{type:"strong",raw:w,text:L,tokens:this.lexer.inlineTokens(L)}}}}codespan($){let J=this.rules.inline.code.exec($);if(J){let Q=J[2].replace(this.rules.other.newLineCharGlobal," "),q=this.rules.other.nonSpaceChar.test(Q),W=this.rules.other.startingSpaceChar.test(Q)&&this.rules.other.endingSpaceChar.test(Q);return q&&W&&(Q=Q.substring(1,Q.length-1)),{type:"codespan",raw:J[0],text:Q}}}br($){let J=this.rules.inline.br.exec($);if(J)return{type:"br",raw:J[0]}}del($,J,Q=""){let q=this.rules.inline.delLDelim.exec($);if(!q)return;if(!q[1]||!Q||this.rules.inline.punctuation.exec(Q)){let W=[...q[0]].length-1,Y,X,G=W,H=this.rules.inline.delRDelim;for(H.lastIndex=0,J=J.slice(-1*$.length+W);(q=H.exec(J))!==null;){if(Y=q[1]||q[2]||q[3]||q[4]||q[5]||q[6],!Y||(X=[...Y].length,X!==W))continue;if(q[3]||q[4]){G+=X;continue}if(G-=X,G>0)continue;X=Math.min(X,X+G);let B=[...q[0]][0].length,_=$.slice(0,W+q.index+B+X),w=_.slice(W,-W);return{type:"del",raw:_,text:w,tokens:this.lexer.inlineTokens(w)}}}}autolink($){let J=this.rules.inline.autolink.exec($);if(J){let Q,q;return J[2]==="@"?(Q=J[1],q="mailto:"+Q):(Q=J[1],q=Q),{type:"link",raw:J[0],text:Q,href:q,tokens:[{type:"text",raw:Q,text:Q}]}}}url($){let J;if(J=this.rules.inline.url.exec($)){let Q,q;if(J[2]==="@")Q=J[0],q="mailto:"+Q;else{let W;do W=J[0],J[0]=this.rules.inline._backpedal.exec(J[0])?.[0]??"";while(W!==J[0]);Q=J[0],J[1]==="www."?q="http://"+J[0]:q=J[0]}return{type:"link",raw:J[0],text:Q,href:q,tokens:[{type:"text",raw:Q,text:Q}]}}}inlineText($){let J=this.rules.inline.text.exec($);if(J){let Q=this.lexer.state.inRawBlock;return{type:"text",raw:J[0],text:J[0],escaped:Q}}}},Y$=class ${tokens;options;state;inlineQueue;tokenizer;constructor(J){this.tokens=[],this.tokens.links=Object.create(null),this.options=J||x$,this.options.tokenizer=this.options.tokenizer||new y0,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let Q={other:t,block:T0.normal,inline:N0.normal};this.options.pedantic?(Q.block=T0.pedantic,Q.inline=N0.pedantic):this.options.gfm&&(Q.block=T0.gfm,this.options.breaks?Q.inline=N0.breaks:Q.inline=N0.gfm),this.tokenizer.rules=Q}static get rules(){return{block:T0,inline:N0}}static lex(J,Q){return new $(Q).lex(J)}static lexInline(J,Q){return new $(Q).inlineTokens(J)}lex(J){J=J.replace(t.carriageReturn,`
27
- `),this.blockTokens(J,this.tokens);for(let Q=0;Q<this.inlineQueue.length;Q++){let q=this.inlineQueue[Q];this.inlineTokens(q.src,q.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(J,Q=[],q=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(J=J.replace(t.tabCharGlobal," ").replace(t.spaceLine,""));J;){let W;if(this.options.extensions?.block?.some((X)=>(W=X.call({lexer:this},J,Q))?(J=J.substring(W.raw.length),Q.push(W),!0):!1))continue;if(W=this.tokenizer.space(J)){J=J.substring(W.raw.length);let X=Q.at(-1);W.raw.length===1&&X!==void 0?X.raw+=`
28
- `:Q.push(W);continue}if(W=this.tokenizer.code(J)){J=J.substring(W.raw.length);let X=Q.at(-1);X?.type==="paragraph"||X?.type==="text"?(X.raw+=(X.raw.endsWith(`
8
+ `),s="",r="",o=[];for(;n.length>0;){let a=!1,l=[],i;for(i=0;i<n.length;i++)if(this.rules.other.blockquoteStart.test(n[i]))l.push(n[i]),a=!0;else if(!a)l.push(n[i]);else break;n=n.slice(i);let c=l.join(`
9
+ `),u=c.replace(this.rules.other.blockquoteSetextReplace,`
10
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
11
+ ${c}`:c,r=r?`${r}
12
+ ${u}`:u;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,o,!0),this.lexer.state.top=f,n.length===0)break;let b=o.at(-1);if(b?.type==="code")break;if(b?.type==="blockquote"){let y=b,p=y.raw+`
13
+ `+n.join(`
14
+ `),h=this.blockquote(p);o[o.length-1]=h,s=s.substring(0,s.length-y.raw.length)+h.raw,r=r.substring(0,r.length-y.text.length)+h.text;break}else if(b?.type==="list"){let y=b,p=y.raw+`
15
+ `+n.join(`
16
+ `),h=this.list(p);o[o.length-1]=h,s=s.substring(0,s.length-b.raw.length)+h.raw,r=r.substring(0,r.length-y.raw.length)+h.raw,n=p.substring(o.at(-1).raw.length).split(`
17
+ `);continue}}return{type:"blockquote",raw:s,tokens:o,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),s=n.length>1,r={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");let o=this.rules.other.listItemRegex(n),a=!1;for(;e;){let i=!1,c="",u="";if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let f=zs(t[2].split(`
18
+ `,1)[0],t[1].length),b=e.split(`
19
+ `,1)[0],y=!f.trim(),p=0;if(this.options.pedantic?(p=2,u=f.trimStart()):y?p=t[1].length+1:(p=f.search(this.rules.other.nonSpaceChar),p=p>4?1:p,u=f.slice(p),p+=t[1].length),y&&this.rules.other.blankLine.test(b)&&(c+=b+`
20
+ `,e=e.substring(b.length+1),i=!0),!i){let h=this.rules.other.nextBulletRegex(p),g=this.rules.other.hrRegex(p),T=this.rules.other.fencesBeginRegex(p),P=this.rules.other.headingBeginRegex(p),O=this.rules.other.htmlBeginRegex(p),q=this.rules.other.blockquoteBeginRegex(p);for(;e;){let j=e.split(`
21
+ `,1)[0],B;if(b=j,this.options.pedantic?(b=b.replace(this.rules.other.listReplaceNesting," "),B=b):B=b.replace(this.rules.other.tabCharGlobal," "),T.test(b)||P.test(b)||O.test(b)||q.test(b)||h.test(b)||g.test(b))break;if(B.search(this.rules.other.nonSpaceChar)>=p||!b.trim())u+=`
22
+ `+B.slice(p);else{if(y||f.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||T.test(f)||P.test(f)||g.test(f))break;u+=`
23
+ `+b}y=!b.trim(),c+=j+`
24
+ `,e=e.substring(j.length+1),f=B.slice(p)}}r.loose||(a?r.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(a=!0)),r.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),r.raw+=c}let l=r.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let i of r.items){if(this.lexer.state.top=!1,i.tokens=this.lexer.blockTokens(i.text,[]),i.task){if(i.text=i.text.replace(this.rules.other.listReplaceTask,""),i.tokens[0]?.type==="text"||i.tokens[0]?.type==="paragraph"){i.tokens[0].raw=i.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),i.tokens[0].text=i.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let u=this.lexer.inlineQueue.length-1;u>=0;u--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[u].src)){this.lexer.inlineQueue[u].src=this.lexer.inlineQueue[u].src.replace(this.rules.other.listReplaceTask,"");break}}let c=this.rules.other.listTaskCheckbox.exec(i.raw);if(c){let u={type:"checkbox",raw:c[0]+" ",checked:c[0]!=="[ ]"};i.checked=u.checked,r.loose?i.tokens[0]&&["paragraph","text"].includes(i.tokens[0].type)&&"tokens"in i.tokens[0]&&i.tokens[0].tokens?(i.tokens[0].raw=u.raw+i.tokens[0].raw,i.tokens[0].text=u.raw+i.tokens[0].text,i.tokens[0].tokens.unshift(u)):i.tokens.unshift({type:"paragraph",raw:u.raw,text:u.raw,tokens:[u]}):i.tokens.unshift(u)}}if(!r.loose){let c=i.tokens.filter((f)=>f.type==="space"),u=c.length>0&&c.some((f)=>this.rules.other.anyLine.test(f.raw));r.loose=u}}if(r.loose)for(let i of r.items){i.loose=!0;for(let c of i.tokens)c.type==="text"&&(c.type="paragraph")}return r}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:s,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Fn(t[1]),s=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
25
+ `):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(let a of s)this.rules.other.tableAlignRight.test(a)?o.align.push("right"):this.rules.other.tableAlignCenter.test(a)?o.align.push("center"):this.rules.other.tableAlignLeft.test(a)?o.align.push("left"):o.align.push(null);for(let a=0;a<n.length;a++)o.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:o.align[a]});for(let a of r)o.rows.push(Fn(a,o.header.length).map((l,i)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:o.align[i]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
26
+ `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=rt(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=Os(t[2],"()");if(o===-2)return;if(o>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let s=t[2],r="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(s);o&&(s=o[1],r=o[3])}else r=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),Wn(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=t[s.toLowerCase()];if(!r){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return Wn(n,r,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!s||!s[1]&&!s[2]&&!s[3]&&!s[4]||s[4]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(s[1]||s[3])||!n||this.rules.inline.punctuation.exec(n)){let r=[...s[0]].length-1,o,a,l=r,i=0,c=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+r);(s=c.exec(t))!==null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o)continue;if(a=[...o].length,s[3]||s[4]){l+=a;continue}else if((s[5]||s[6])&&r%3&&!((r+a)%3)){i+=a;continue}if(l-=a,l>0)continue;a=Math.min(a,a+l+i);let u=[...s[0]][0].length,f=e.slice(0,r+s.index+u+a);if(Math.min(r,a)%2){let y=f.slice(1,-1);return{type:"em",raw:f,text:y,tokens:this.lexer.inlineTokens(y)}}let b=f.slice(2,-2);return{type:"strong",raw:f,text:b,tokens:this.lexer.inlineTokens(b)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(n),r=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return s&&r&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let s=this.rules.inline.delLDelim.exec(e);if(!s)return;if(!s[1]||!n||this.rules.inline.punctuation.exec(n)){let r=[...s[0]].length-1,o,a,l=r,i=this.rules.inline.delRDelim;for(i.lastIndex=0,t=t.slice(-1*e.length+r);(s=i.exec(t))!==null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o||(a=[...o].length,a!==r))continue;if(s[3]||s[4]){l+=a;continue}if(l-=a,l>0)continue;a=Math.min(a,a+l);let c=[...s[0]][0].length,u=e.slice(0,r+s.index+c+a),f=u.slice(r,-r);return{type:"del",raw:u,text:f,tokens:this.lexer.inlineTokens(f)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,s;return t[2]==="@"?(n=t[1],s="mailto:"+n):(n=t[1],s=n),{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,s;if(t[2]==="@")n=t[0],s="mailto:"+n;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(r!==t[0]);n=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},ie=class e{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||ze,this.options.tokenizer=this.options.tokenizer||new Ct,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:J,block:Rt.normal,inline:nt.normal};this.options.pedantic?(n.block=Rt.pedantic,n.inline=nt.pedantic):this.options.gfm&&(n.block=Rt.gfm,this.options.breaks?n.inline=nt.breaks:n.inline=nt.gfm),this.tokenizer.rules=n}static get rules(){return{block:Rt,inline:nt}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(t){t=t.replace(J.carriageReturn,`
27
+ `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let s=this.inlineQueue[n];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],s=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(J.tabCharGlobal," ").replace(J.spaceLine,""));t;){let r;if(this.options.extensions?.block?.some((a)=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))continue;if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length);let a=n.at(-1);r.raw.length===1&&a!==void 0?a.raw+=`
28
+ `:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length);let a=n.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
29
29
  `)?"":`
30
- `)+W.raw,X.text+=`
31
- `+W.text,this.inlineQueue.at(-1).src=X.text):Q.push(W);continue}if(W=this.tokenizer.fences(J)){J=J.substring(W.raw.length),Q.push(W);continue}if(W=this.tokenizer.heading(J)){J=J.substring(W.raw.length),Q.push(W);continue}if(W=this.tokenizer.hr(J)){J=J.substring(W.raw.length),Q.push(W);continue}if(W=this.tokenizer.blockquote(J)){J=J.substring(W.raw.length),Q.push(W);continue}if(W=this.tokenizer.list(J)){J=J.substring(W.raw.length),Q.push(W);continue}if(W=this.tokenizer.html(J)){J=J.substring(W.raw.length),Q.push(W);continue}if(W=this.tokenizer.def(J)){J=J.substring(W.raw.length);let X=Q.at(-1);X?.type==="paragraph"||X?.type==="text"?(X.raw+=(X.raw.endsWith(`
30
+ `)+r.raw,a.text+=`
31
+ `+r.text,this.inlineQueue.at(-1).src=a.text):n.push(r);continue}if(r=this.tokenizer.fences(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(t)){t=t.substring(r.raw.length);let a=n.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
32
32
  `)?"":`
33
- `)+W.raw,X.text+=`
34
- `+W.raw,this.inlineQueue.at(-1).src=X.text):this.tokens.links[W.tag]||(this.tokens.links[W.tag]={href:W.href,title:W.title},Q.push(W));continue}if(W=this.tokenizer.table(J)){J=J.substring(W.raw.length),Q.push(W);continue}if(W=this.tokenizer.lheading(J)){J=J.substring(W.raw.length),Q.push(W);continue}let Y=J;if(this.options.extensions?.startBlock){let X=1/0,G=J.slice(1),H;this.options.extensions.startBlock.forEach((B)=>{H=B.call({lexer:this},G),typeof H=="number"&&H>=0&&(X=Math.min(X,H))}),X<1/0&&X>=0&&(Y=J.substring(0,X+1))}if(this.state.top&&(W=this.tokenizer.paragraph(Y))){let X=Q.at(-1);q&&X?.type==="paragraph"?(X.raw+=(X.raw.endsWith(`
33
+ `)+r.raw,a.text+=`
34
+ `+r.raw,this.inlineQueue.at(-1).src=a.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},n.push(r));continue}if(r=this.tokenizer.table(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(t)){t=t.substring(r.raw.length),n.push(r);continue}let o=t;if(this.options.extensions?.startBlock){let a=1/0,l=t.slice(1),i;this.options.extensions.startBlock.forEach((c)=>{i=c.call({lexer:this},l),typeof i=="number"&&i>=0&&(a=Math.min(a,i))}),a<1/0&&a>=0&&(o=t.substring(0,a+1))}if(this.state.top&&(r=this.tokenizer.paragraph(o))){let a=n.at(-1);s&&a?.type==="paragraph"?(a.raw+=(a.raw.endsWith(`
35
35
  `)?"":`
36
- `)+W.raw,X.text+=`
37
- `+W.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=X.text):Q.push(W),q=Y.length!==J.length,J=J.substring(W.raw.length);continue}if(W=this.tokenizer.text(J)){J=J.substring(W.raw.length);let X=Q.at(-1);X?.type==="text"?(X.raw+=(X.raw.endsWith(`
36
+ `)+r.raw,a.text+=`
37
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(r),s=o.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length);let a=n.at(-1);a?.type==="text"?(a.raw+=(a.raw.endsWith(`
38
38
  `)?"":`
39
- `)+W.raw,X.text+=`
40
- `+W.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=X.text):Q.push(W);continue}if(J){let X="Infinite loop on byte: "+J.charCodeAt(0);if(this.options.silent){console.error(X);break}else throw Error(X)}}return this.state.top=!0,Q}inline(J,Q=[]){return this.inlineQueue.push({src:J,tokens:Q}),Q}inlineTokens(J,Q=[]){this.tokenizer.lexer=this;let q=J,W=null;if(this.tokens.links){let H=Object.keys(this.tokens.links);if(H.length>0)for(;(W=this.tokenizer.rules.inline.reflinkSearch.exec(q))!==null;)H.includes(W[0].slice(W[0].lastIndexOf("[")+1,-1))&&(q=q.slice(0,W.index)+"["+"a".repeat(W[0].length-2)+"]"+q.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(W=this.tokenizer.rules.inline.anyPunctuation.exec(q))!==null;)q=q.slice(0,W.index)+"++"+q.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let Y;for(;(W=this.tokenizer.rules.inline.blockSkip.exec(q))!==null;)Y=W[2]?W[2].length:0,q=q.slice(0,W.index+Y)+"["+"a".repeat(W[0].length-Y-2)+"]"+q.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);q=this.options.hooks?.emStrongMask?.call({lexer:this},q)??q;let X=!1,G="";for(;J;){X||(G=""),X=!1;let H;if(this.options.extensions?.inline?.some((_)=>(H=_.call({lexer:this},J,Q))?(J=J.substring(H.raw.length),Q.push(H),!0):!1))continue;if(H=this.tokenizer.escape(J)){J=J.substring(H.raw.length),Q.push(H);continue}if(H=this.tokenizer.tag(J)){J=J.substring(H.raw.length),Q.push(H);continue}if(H=this.tokenizer.link(J)){J=J.substring(H.raw.length),Q.push(H);continue}if(H=this.tokenizer.reflink(J,this.tokens.links)){J=J.substring(H.raw.length);let _=Q.at(-1);H.type==="text"&&_?.type==="text"?(_.raw+=H.raw,_.text+=H.text):Q.push(H);continue}if(H=this.tokenizer.emStrong(J,q,G)){J=J.substring(H.raw.length),Q.push(H);continue}if(H=this.tokenizer.codespan(J)){J=J.substring(H.raw.length),Q.push(H);continue}if(H=this.tokenizer.br(J)){J=J.substring(H.raw.length),Q.push(H);continue}if(H=this.tokenizer.del(J,q,G)){J=J.substring(H.raw.length),Q.push(H);continue}if(H=this.tokenizer.autolink(J)){J=J.substring(H.raw.length),Q.push(H);continue}if(!this.state.inLink&&(H=this.tokenizer.url(J))){J=J.substring(H.raw.length),Q.push(H);continue}let B=J;if(this.options.extensions?.startInline){let _=1/0,w=J.slice(1),L;this.options.extensions.startInline.forEach((F)=>{L=F.call({lexer:this},w),typeof L=="number"&&L>=0&&(_=Math.min(_,L))}),_<1/0&&_>=0&&(B=J.substring(0,_+1))}if(H=this.tokenizer.inlineText(B)){J=J.substring(H.raw.length),H.raw.slice(-1)!=="_"&&(G=H.raw.slice(-1)),X=!0;let _=Q.at(-1);_?.type==="text"?(_.raw+=H.raw,_.text+=H.text):Q.push(H);continue}if(J){let _="Infinite loop on byte: "+J.charCodeAt(0);if(this.options.silent){console.error(_);break}else throw Error(_)}}return Q}},g0=class{options;parser;constructor($){this.options=$||x$}space($){return""}code({text:$,lang:J,escaped:Q}){let q=(J||"").match(t.notSpaceStart)?.[0],W=$.replace(t.endingNewline,"")+`
41
- `;return q?'<pre><code class="language-'+N$(q)+'">'+(Q?W:N$(W,!0))+`</code></pre>
42
- `:"<pre><code>"+(Q?W:N$(W,!0))+`</code></pre>
43
- `}blockquote({tokens:$}){return`<blockquote>
44
- ${this.parser.parse($)}</blockquote>
45
- `}html({text:$}){return $}def($){return""}heading({tokens:$,depth:J}){return`<h${J}>${this.parser.parseInline($)}</h${J}>
46
- `}hr($){return`<hr>
47
- `}list($){let{ordered:J,start:Q}=$,q="";for(let X=0;X<$.items.length;X++){let G=$.items[X];q+=this.listitem(G)}let W=J?"ol":"ul",Y=J&&Q!==1?' start="'+Q+'"':"";return"<"+W+Y+`>
48
- `+q+"</"+W+`>
49
- `}listitem($){return`<li>${this.parser.parse($.tokens)}</li>
50
- `}checkbox({checked:$}){return"<input "+($?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:$}){return`<p>${this.parser.parseInline($)}</p>
51
- `}table($){let J="",Q="";for(let W=0;W<$.header.length;W++)Q+=this.tablecell($.header[W]);J+=this.tablerow({text:Q});let q="";for(let W=0;W<$.rows.length;W++){let Y=$.rows[W];Q="";for(let X=0;X<Y.length;X++)Q+=this.tablecell(Y[X]);q+=this.tablerow({text:Q})}return q&&(q=`<tbody>${q}</tbody>`),`<table>
39
+ `)+r.raw,a.text+=`
40
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(r);continue}if(t){let a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){this.tokenizer.lexer=this;let s=t,r=null;if(this.tokens.links){let i=Object.keys(this.tokens.links);if(i.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(s))!==null;)i.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(s))!==null;)s=s.slice(0,r.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(s))!==null;)o=r[2]?r[2].length:0,s=s.slice(0,r.index+o)+"["+"a".repeat(r[0].length-o-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=this.options.hooks?.emStrongMask?.call({lexer:this},s)??s;let a=!1,l="";for(;t;){a||(l=""),a=!1;let i;if(this.options.extensions?.inline?.some((u)=>(i=u.call({lexer:this},t,n))?(t=t.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.escape(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.tag(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.link(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(i.raw.length);let u=n.at(-1);i.type==="text"&&u?.type==="text"?(u.raw+=i.raw,u.text+=i.text):n.push(i);continue}if(i=this.tokenizer.emStrong(t,s,l)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.codespan(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.br(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.del(t,s,l)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.autolink(t)){t=t.substring(i.raw.length),n.push(i);continue}if(!this.state.inLink&&(i=this.tokenizer.url(t))){t=t.substring(i.raw.length),n.push(i);continue}let c=t;if(this.options.extensions?.startInline){let u=1/0,f=t.slice(1),b;this.options.extensions.startInline.forEach((y)=>{b=y.call({lexer:this},f),typeof b=="number"&&b>=0&&(u=Math.min(u,b))}),u<1/0&&u>=0&&(c=t.substring(0,u+1))}if(i=this.tokenizer.inlineText(c)){t=t.substring(i.raw.length),i.raw.slice(-1)!=="_"&&(l=i.raw.slice(-1)),a=!0;let u=n.at(-1);u?.type==="text"?(u.raw+=i.raw,u.text+=i.text):n.push(i);continue}if(t){let u="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw Error(u)}}return n}},Nt=class{options;parser;constructor(e){this.options=e||ze}space(e){return""}code({text:e,lang:t,escaped:n}){let s=(t||"").match(J.notSpaceStart)?.[0],r=e.replace(J.endingNewline,"")+`
41
+ `;return s?'<pre><code class="language-'+fe(s)+'">'+(n?r:fe(r,!0))+`</code></pre>
42
+ `:"<pre><code>"+(n?r:fe(r,!0))+`</code></pre>
43
+ `}blockquote({tokens:e}){return`<blockquote>
44
+ ${this.parser.parse(e)}</blockquote>
45
+ `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
46
+ `}hr(e){return`<hr>
47
+ `}list(e){let{ordered:t,start:n}=e,s="";for(let a=0;a<e.items.length;a++){let l=e.items[a];s+=this.listitem(l)}let r=t?"ol":"ul",o=t&&n!==1?' start="'+n+'"':"";return"<"+r+o+`>
48
+ `+s+"</"+r+`>
49
+ `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
50
+ `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
51
+ `}table(e){let t="",n="";for(let r=0;r<e.header.length;r++)n+=this.tablecell(e.header[r]);t+=this.tablerow({text:n});let s="";for(let r=0;r<e.rows.length;r++){let o=e.rows[r];n="";for(let a=0;a<o.length;a++)n+=this.tablecell(o[a]);s+=this.tablerow({text:n})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
52
52
  <thead>
53
- `+J+`</thead>
54
- `+q+`</table>
55
- `}tablerow({text:$}){return`<tr>
56
- ${$}</tr>
57
- `}tablecell($){let J=this.parser.parseInline($.tokens),Q=$.header?"th":"td";return($.align?`<${Q} align="${$.align}">`:`<${Q}>`)+J+`</${Q}>
58
- `}strong({tokens:$}){return`<strong>${this.parser.parseInline($)}</strong>`}em({tokens:$}){return`<em>${this.parser.parseInline($)}</em>`}codespan({text:$}){return`<code>${N$($,!0)}</code>`}br($){return"<br>"}del({tokens:$}){return`<del>${this.parser.parseInline($)}</del>`}link({href:$,title:J,tokens:Q}){let q=this.parser.parseInline(Q),W=x1($);if(W===null)return q;$=W;let Y='<a href="'+$+'"';return J&&(Y+=' title="'+N$(J)+'"'),Y+=">"+q+"</a>",Y}image({href:$,title:J,text:Q,tokens:q}){q&&(Q=this.parser.parseInline(q,this.parser.textRenderer));let W=x1($);if(W===null)return N$(Q);$=W;let Y=`<img src="${$}" alt="${N$(Q)}"`;return J&&(Y+=` title="${N$(J)}"`),Y+=">",Y}text($){return"tokens"in $&&$.tokens?this.parser.parseInline($.tokens):("escaped"in $)&&$.escaped?$.text:N$($.text)}},N1=class{strong({text:$}){return $}em({text:$}){return $}codespan({text:$}){return $}del({text:$}){return $}html({text:$}){return $}text({text:$}){return $}link({text:$}){return""+$}image({text:$}){return""+$}br(){return""}checkbox({raw:$}){return $}},X$=class ${options;renderer;textRenderer;constructor(J){this.options=J||x$,this.options.renderer=this.options.renderer||new g0,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new N1}static parse(J,Q){return new $(Q).parse(J)}static parseInline(J,Q){return new $(Q).parseInline(J)}parse(J){this.renderer.parser=this;let Q="";for(let q=0;q<J.length;q++){let W=J[q];if(this.options.extensions?.renderers?.[W.type]){let X=W,G=this.options.extensions.renderers[X.type].call({parser:this},X);if(G!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(X.type)){Q+=G||"";continue}}let Y=W;switch(Y.type){case"space":{Q+=this.renderer.space(Y);break}case"hr":{Q+=this.renderer.hr(Y);break}case"heading":{Q+=this.renderer.heading(Y);break}case"code":{Q+=this.renderer.code(Y);break}case"table":{Q+=this.renderer.table(Y);break}case"blockquote":{Q+=this.renderer.blockquote(Y);break}case"list":{Q+=this.renderer.list(Y);break}case"checkbox":{Q+=this.renderer.checkbox(Y);break}case"html":{Q+=this.renderer.html(Y);break}case"def":{Q+=this.renderer.def(Y);break}case"paragraph":{Q+=this.renderer.paragraph(Y);break}case"text":{Q+=this.renderer.text(Y);break}default:{let X='Token with "'+Y.type+'" type was not found.';if(this.options.silent)return console.error(X),"";throw Error(X)}}}return Q}parseInline(J,Q=this.renderer){this.renderer.parser=this;let q="";for(let W=0;W<J.length;W++){let Y=J[W];if(this.options.extensions?.renderers?.[Y.type]){let G=this.options.extensions.renderers[Y.type].call({parser:this},Y);if(G!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(Y.type)){q+=G||"";continue}}let X=Y;switch(X.type){case"escape":{q+=Q.text(X);break}case"html":{q+=Q.html(X);break}case"link":{q+=Q.link(X);break}case"image":{q+=Q.image(X);break}case"checkbox":{q+=Q.checkbox(X);break}case"strong":{q+=Q.strong(X);break}case"em":{q+=Q.em(X);break}case"codespan":{q+=Q.codespan(X);break}case"br":{q+=Q.br(X);break}case"del":{q+=Q.del(X);break}case"text":{q+=Q.text(X);break}default:{let G='Token with "'+X.type+'" type was not found.';if(this.options.silent)return console.error(G),"";throw Error(G)}}}return q}},O0=class{options;block;constructor($){this.options=$||x$}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess($){return $}postprocess($){return $}processAllTokens($){return $}emStrongMask($){return $}provideLexer($=this.block){return $?Y$.lex:Y$.lexInline}provideParser($=this.block){return $?X$.parse:X$.parseInline}},u2=class{defaults=H1();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=X$;Renderer=g0;TextRenderer=N1;Lexer=Y$;Tokenizer=y0;Hooks=O0;constructor(...$){this.use(...$)}walkTokens($,J){let Q=[];for(let q of $)switch(Q=Q.concat(J.call(this,q)),q.type){case"table":{let W=q;for(let Y of W.header)Q=Q.concat(this.walkTokens(Y.tokens,J));for(let Y of W.rows)for(let X of Y)Q=Q.concat(this.walkTokens(X.tokens,J));break}case"list":{let W=q;Q=Q.concat(this.walkTokens(W.items,J));break}default:{let W=q;this.defaults.extensions?.childTokens?.[W.type]?this.defaults.extensions.childTokens[W.type].forEach((Y)=>{let X=W[Y].flat(1/0);Q=Q.concat(this.walkTokens(X,J))}):W.tokens&&(Q=Q.concat(this.walkTokens(W.tokens,J)))}}return Q}use(...$){let J=this.defaults.extensions||{renderers:{},childTokens:{}};return $.forEach((Q)=>{let q={...Q};if(q.async=this.defaults.async||q.async||!1,Q.extensions&&(Q.extensions.forEach((W)=>{if(!W.name)throw Error("extension name required");if("renderer"in W){let Y=J.renderers[W.name];Y?J.renderers[W.name]=function(...X){let G=W.renderer.apply(this,X);return G===!1&&(G=Y.apply(this,X)),G}:J.renderers[W.name]=W.renderer}if("tokenizer"in W){if(!W.level||W.level!=="block"&&W.level!=="inline")throw Error("extension level must be 'block' or 'inline'");let Y=J[W.level];Y?Y.unshift(W.tokenizer):J[W.level]=[W.tokenizer],W.start&&(W.level==="block"?J.startBlock?J.startBlock.push(W.start):J.startBlock=[W.start]:W.level==="inline"&&(J.startInline?J.startInline.push(W.start):J.startInline=[W.start]))}"childTokens"in W&&W.childTokens&&(J.childTokens[W.name]=W.childTokens)}),q.extensions=J),Q.renderer){let W=this.defaults.renderer||new g0(this.defaults);for(let Y in Q.renderer){if(!(Y in W))throw Error(`renderer '${Y}' does not exist`);if(["options","parser"].includes(Y))continue;let X=Y,G=Q.renderer[X],H=W[X];W[X]=(...B)=>{let _=G.apply(W,B);return _===!1&&(_=H.apply(W,B)),_||""}}q.renderer=W}if(Q.tokenizer){let W=this.defaults.tokenizer||new y0(this.defaults);for(let Y in Q.tokenizer){if(!(Y in W))throw Error(`tokenizer '${Y}' does not exist`);if(["options","rules","lexer"].includes(Y))continue;let X=Y,G=Q.tokenizer[X],H=W[X];W[X]=(...B)=>{let _=G.apply(W,B);return _===!1&&(_=H.apply(W,B)),_}}q.tokenizer=W}if(Q.hooks){let W=this.defaults.hooks||new O0;for(let Y in Q.hooks){if(!(Y in W))throw Error(`hook '${Y}' does not exist`);if(["options","block"].includes(Y))continue;let X=Y,G=Q.hooks[X],H=W[X];O0.passThroughHooks.has(Y)?W[X]=(B)=>{if(this.defaults.async&&O0.passThroughHooksRespectAsync.has(Y))return(async()=>{let w=await G.call(W,B);return H.call(W,w)})();let _=G.call(W,B);return H.call(W,_)}:W[X]=(...B)=>{if(this.defaults.async)return(async()=>{let w=await G.apply(W,B);return w===!1&&(w=await H.apply(W,B)),w})();let _=G.apply(W,B);return _===!1&&(_=H.apply(W,B)),_}}q.hooks=W}if(Q.walkTokens){let W=this.defaults.walkTokens,Y=Q.walkTokens;q.walkTokens=function(X){let G=[];return G.push(Y.call(this,X)),W&&(G=G.concat(W.call(this,X))),G}}this.defaults={...this.defaults,...q}}),this}setOptions($){return this.defaults={...this.defaults,...$},this}lexer($,J){return Y$.lex($,J??this.defaults)}parser($,J){return X$.parse($,J??this.defaults)}parseMarkdown($){return(J,Q)=>{let q={...Q},W={...this.defaults,...q},Y=this.onError(!!W.silent,!!W.async);if(this.defaults.async===!0&&q.async===!1)return Y(Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof J>"u"||J===null)return Y(Error("marked(): input parameter is undefined or null"));if(typeof J!="string")return Y(Error("marked(): input parameter is of type "+Object.prototype.toString.call(J)+", string expected"));if(W.hooks&&(W.hooks.options=W,W.hooks.block=$),W.async)return(async()=>{let X=W.hooks?await W.hooks.preprocess(J):J,G=await(W.hooks?await W.hooks.provideLexer($):$?Y$.lex:Y$.lexInline)(X,W),H=W.hooks?await W.hooks.processAllTokens(G):G;W.walkTokens&&await Promise.all(this.walkTokens(H,W.walkTokens));let B=await(W.hooks?await W.hooks.provideParser($):$?X$.parse:X$.parseInline)(H,W);return W.hooks?await W.hooks.postprocess(B):B})().catch(Y);try{W.hooks&&(J=W.hooks.preprocess(J));let X=(W.hooks?W.hooks.provideLexer($):$?Y$.lex:Y$.lexInline)(J,W);W.hooks&&(X=W.hooks.processAllTokens(X)),W.walkTokens&&this.walkTokens(X,W.walkTokens);let G=(W.hooks?W.hooks.provideParser($):$?X$.parse:X$.parseInline)(X,W);return W.hooks&&(G=W.hooks.postprocess(G)),G}catch(X){return Y(X)}}}onError($,J){return(Q)=>{if(Q.message+=`
59
- Please report this to https://github.com/markedjs/marked.`,$){let q="<p>An error occurred:</p><pre>"+N$(Q.message+"",!0)+"</pre>";return J?Promise.resolve(q):q}if(J)return Promise.reject(Q);throw Q}}},Z$=new u2;function C($,J){return Z$.parse($,J)}C.options=C.setOptions=function($){return Z$.setOptions($),C.defaults=Z$.defaults,c1(C.defaults),C};C.getDefaults=H1;C.defaults=x$;C.use=function(...$){return Z$.use(...$),C.defaults=Z$.defaults,c1(C.defaults),C};C.walkTokens=function($,J){return Z$.walkTokens($,J)};C.parseInline=Z$.parseInline;C.Parser=X$;C.parser=X$.parse;C.Renderer=g0;C.TextRenderer=N1;C.Lexer=Y$;C.lexer=Y$.lex;C.Tokenizer=y0;C.Hooks=O0;C.parse=C;var{options:V6,setOptions:P6,use:D6,walkTokens:k6,parseInline:C6}=C;var E6=X$.parse,T6=Y$.lex;import e1 from"react";import{jsxDEV as K1}from"react/jsx-dev-runtime";C.setOptions({gfm:!0,breaks:!1});var l2=new Set(["a","abbr","b","br","code","del","em","i","kbd","mark","q","s","small","span","strong","sub","sup","time","u"]),c2=new Set(["Priority"]);function p2($){if(typeof $==="string"||typeof $==="number")return!0;if(!e1.isValidElement($))return!1;if(typeof $!=="object"||$===null||!("type"in $))return!1;let J=$.type;if(typeof J==="string")return l2.has(J);if(typeof J==="function"){let Q="displayName"in J&&typeof J.displayName==="string"?J.displayName:J.name;return Q?c2.has(Q):!1}return!1}function d2($,J){let Q=$.trim();if(!Q)return null;let q=C.parse(Q,{async:!1});return K1("div",{className:"prose-canvas","data-md":"markdown","data-md-source":Q,dangerouslySetInnerHTML:{__html:q}},J,!1,void 0,this)}function r2($,J){return K1("div",{className:"prose-canvas",children:$.map((Q,q)=>{if(typeof Q==="string"||typeof Q==="number"){let W=C.parseInline(String(Q),{async:!1});return K1("span",{dangerouslySetInnerHTML:{__html:W}},q,!1,void 0,this)}return Q})},J,!1,void 0,this)}function V$($){let J=e1.Children.toArray($);if(J.length===0)return null;let Q=[],q=[],W=0,Y=()=>{if(q.length===0)return;if(q.some((G)=>typeof G!=="string"&&typeof G!=="number"))Q.push(r2(q,`md-${W++}`));else{let G=d2(q.join(""),`md-${W++}`);if(G)Q.push(G)}q=[]};for(let X of J)if(p2(X))q.push(X);else Y(),Q.push(X);return Y(),Q}import{jsxDEV as O1}from"react/jsx-dev-runtime";var i2={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 o2({type:$="info",children:J}){let Q=i2[$];return O1("div",{className:`${Q.bg} relative rounded-lg px-5 py-4 mt-3 flex gap-3 items-start`,"data-md":"callout","data-md-type":$,children:[O1("span",{"aria-hidden":"true",className:`${Q.iconColor} opacity-70 text-base leading-relaxed flex-shrink-0 mt-px`,children:Q.icon},void 0,!1,void 0,this),O1("div",{className:"text-body text-text-secondary leading-relaxed",children:V$(J)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as o$}from"react/jsx-dev-runtime";function n2({items:$}){return o$("ul",{className:"space-y-1 mt-3","data-md":"checklist",children:$.map((J,Q)=>o$("li",{"data-md":"checklist-item","data-md-label":J.label,className:"relative flex items-start gap-2.5 py-1",children:[o$("span",{className:`w-4 h-4 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5 transition-all ${J.checked?"bg-accent-green":"border-[1.5px] border-border-hover"}`,children:J.checked&&o$("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:o$("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),o$("span",{className:`text-body font-body ${J.checked?"text-text-tertiary line-through decoration-border-hover":"text-text-secondary"}`,children:J.label},void 0,!1,void 0,this)]},Q,!0,void 0,this))},void 0,!1,void 0,this)}import{useAnnotations as k5,useResponseRegistration as C5}from"#canvas/runtime";import{useEffect as E5,useMemo as T5,useRef as I5,useState as y5}from"react";import{AnnotationCtx as T7,AnnotationHostContext as I7,SessionContext as y7,useAnnotationHost as g7,useAnnotations as h7}from"@fabrika/annotations/runtime";function L1($,J){let Q=[],q=a2($);for(let W of q){let Y=document.createRange();if(Y.selectNodeContents(W),W===$.startContainer)Y.setStart(W,$.startOffset);if(W===$.endContainer)Y.setEnd(W,$.endOffset);let X=Y.toString();if(!X||!X.trim())continue;let G=document.createElement("mark");G.setAttribute("data-annotation-id",J);try{Y.surroundContents(G)}catch{let H=Y.extractContents();G.appendChild(H),Y.insertNode(G)}Q.push(G)}return Q}function F1($){let J=$.parentElement;if(J?.classList.contains("select-none"))return!1;if(J?.closest("[data-annotation-id]"))return!1;return!0}function a2($){let J=[],Q=$.commonAncestorContainer;if(Q.nodeType===Node.TEXT_NODE)return J.push(Q),J;let q=document.createTreeWalker(Q,NodeFilter.SHOW_TEXT),W;while(W=q.nextNode()){if(!F1(W))continue;if($.intersectsNode(W))J.push(W)}return J}function S1($,J){for(let Q of J){if($.querySelector(`[data-annotation-id="${Q.id}"]`))continue;let q=Q.snippet;if(!q)continue;let{fullText:W,textNodes:Y}=s2($),X=[],G=0;while(!0){let U=W.indexOf(q,G);if(U===-1)break;X.push(U),G=U+1}let[H]=X;if(H===void 0)continue;let B=H;if(X.length>1&&Q.context){let U=-1;for(let K of X){let O=0;if(Q.context.before){let R=W.slice(Math.max(0,K-80),K);if(R.includes(Q.context.before))O+=2;else if(Q.context.before.length>10&&R.includes(Q.context.before.slice(-10)))O+=1}if(Q.context.after){let R=W.slice(K+q.length,K+q.length+80);if(R.includes(Q.context.after))O+=2;else if(Q.context.after.length>10&&R.includes(Q.context.after.slice(0,10)))O+=1}if(O>U)U=O,B=K}}let _=B,w=B+q.length,L=$5(Y,_),F=$5(Y,w);if(!L||!F)continue;try{let U=document.createRange();U.setStart(L.node,L.offset),U.setEnd(F.node,F.offset),L1(U,Q.id)}catch{}}}function s2($){let J=[],Q="",q=document.createTreeWalker($,NodeFilter.SHOW_TEXT),W;while(W=q.nextNode()){if(!F1(W))continue;J.push({node:W,start:Q.length}),Q+=W.textContent||""}return{fullText:Q,textNodes:J}}function $5($,J){for(let Q=$.length-1;Q>=0;Q--){let q=$[Q];if(!q||q.start>J)continue;let W=J-q.start,Y=q.node.textContent?.length??0;if(W<=Y)return{node:q.node,offset:W}}return null}function F0($){return{kind:$.kind,owns:(J)=>$.parse(J)!==null,find:(J,Q)=>{let q=$.parse(J);return q===null?null:$.find(q,Q)},restore:(J,Q)=>{let q=$.parse(Q.snippet);if(q===null)return;$.restore?.(q,J,Q)},describe:(J)=>{let Q=$.parse(J);if(Q===null||!$.describe)return null;return $.describe(Q)}}}function J5($){let J=document.createTreeWalker($,NodeFilter.SHOW_TEXT),Q="";for(let q=J.nextNode();q;q=J.nextNode()){let W=q.parentElement?.closest("[aria-hidden='true']");if(W&&$.contains(W))continue;Q+=q.textContent??""}return Q.trim()}function Z0($,J,Q){return{selector:$,snippet:(q)=>{let W=q.getAttribute(Q);return W?`${J} ${W}`:null}}}var A1=[Z0("[data-md='item']","[Item]","data-md-label"),Z0("[data-md='section']","[Section]","data-md-title"),Z0("[data-md='checklist-item']","[Checklist]","data-md-label"),Z0("[data-md='image']","[Image]","data-md-src"),{selector:"[data-md='callout']",snippet:($)=>{return`[Callout:${$.getAttribute("data-md-type")||"info"}] ${J5($).slice(0,60)||"Callout"}`}},{selector:"[data-md='note']",snippet:($)=>`[Note] ${J5($).slice(0,60)||"Note"}`},{selector:"[data-md='table'] tbody tr",snippet:($)=>{let J=Array.from($.querySelectorAll("td")).map((Q)=>Q.textContent?.trim()).filter(Boolean);return J.length?`[Row] ${J.join(" | ")}`:null}}],t2=["[data-md='choice-option']","[data-md='multichoice-option']","[data-md='userinput']","[data-md='rangeinput']"],b1=A1.map(($)=>$.selector).join(", "),Q5=[...A1.map(($)=>$.selector),...t2].join(", ");function f1($){for(let J of A1)if($.matches(J.selector))return J.snippet($);return null}var v1={kind:"block",parse:($)=>$.startsWith("[")?{snippet:$}:null,format:($)=>$.snippet,find:($,J)=>{for(let Q of J.querySelectorAll(b1)){if(!(Q instanceof HTMLElement))continue;if(f1(Q)===$.snippet)return Q}return null}};var e2=/^\[Region:(rect|ellipse)\] ([\s\S]+) @(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*)$/;function $4($){if($==="rect")return"rect";if($==="ellipse")return"ellipse";return null}function x0($){if($===void 0)return null;let J=Number($);if(!Number.isInteger(J)||J<0||J>1e4)return null;return J}function W5($){return{left:`${$.x/100}%`,top:`${$.y/100}%`,width:`${$.w/100}%`,height:`${$.h/100}%`}}function u0($){return`${($/100).toFixed(1).replace(/\.0$/,"")}%`}function j1($){let J=`${u0($.x)}-${u0($.x+$.w)}`,Q=`${u0($.y)}-${u0($.y+$.h)}`;return`[Region] ${$.src} — ${$.shape} x ${J}, y ${Q} of the image`}function R1($,J){for(let Q of J.querySelectorAll("[data-md='image']")){if(!(Q instanceof HTMLElement))continue;if(Q.getAttribute("data-md-src")!==$)continue;let q=Q.querySelector("[data-annotation-image]");if(q instanceof HTMLElement)return q}return null}function q5($,J){let Q=W5(J);$.style.left=Q.left,$.style.top=Q.top,$.style.width=Q.width,$.style.height=Q.height}function V1($,J,Q){let q=document.createElement("div");return q.className="ann-region",q.setAttribute("data-annotation-id",Q),q.setAttribute("data-annotation-region",J),q5(q,$),q}var l0={kind:"region",parse:($)=>{let J=e2.exec($);if(!J)return null;let Q=$4(J[1]),q=J[2],W=x0(J[3]),Y=x0(J[4]),X=x0(J[5]),G=x0(J[6]);if(Q===null||q===void 0)return null;if(W===null||Y===null||X===null||G===null)return null;if(X<1||G<1)return null;return{src:q,shape:Q,x:W,y:Y,w:X,h:G}},format:($)=>`[Region:${$.shape}] ${$.src} @${$.x},${$.y},${$.w},${$.h}`,find:($,J)=>R1($.src,J),restore:($,J,Q)=>{if(J.querySelector(`[data-annotation-id="${Q.id}"]`))return;let q=R1($.src,J);if(!q)return;q.appendChild(V1($,$.shape,Q.id))},describe:j1};var P1={kind:"text",parse:($)=>$?{text:$}:null,format:($)=>$.text,find:()=>null,restore:($,J,Q)=>{S1(J,[Q])}};var J4=[F0(l0),F0(v1),F0(P1)];import{AnnotationCtx as d8,SessionContext as r8,useAnnotationHost as i8}from"@fabrika/annotations/runtime";import{useEffect as a8,useRef as s8,useState as t8}from"react";var S={};$2(S,{void:()=>Z4,util:()=>k,unknown:()=>h4,union:()=>c4,undefined:()=>I4,tuple:()=>r4,transformer:()=>Q3,symbol:()=>T4,string:()=>w5,strictObject:()=>l4,setErrorMap:()=>q4,set:()=>n4,record:()=>i4,quotelessJson:()=>Q4,promise:()=>J3,preprocess:()=>Y3,pipeline:()=>X3,ostring:()=>H3,optional:()=>W3,onumber:()=>G3,oboolean:()=>B3,objectUtil:()=>D1,object:()=>u4,number:()=>z5,nullable:()=>q3,null:()=>y4,never:()=>m4,nativeEnum:()=>$3,nan:()=>k4,map:()=>o4,makeIssue:()=>S0,literal:()=>t4,lazy:()=>s4,late:()=>P4,isValid:()=>P$,isDirty:()=>p0,isAsync:()=>a$,isAborted:()=>c0,intersection:()=>d4,instanceof:()=>D4,getParsedType:()=>K$,getErrorMap:()=>n$,function:()=>a4,enum:()=>e4,effect:()=>Q3,discriminatedUnion:()=>p4,defaultErrorMap:()=>A$,datetimeRegex:()=>_5,date:()=>E4,custom:()=>U5,coerce:()=>_3,boolean:()=>N5,bigint:()=>C4,array:()=>x4,any:()=>g4,addIssueToContext:()=>N,ZodVoid:()=>b0,ZodUnknown:()=>D$,ZodUnion:()=>Q0,ZodUndefined:()=>$0,ZodType:()=>D,ZodTuple:()=>L$,ZodTransformer:()=>M$,ZodSymbol:()=>A0,ZodString:()=>H$,ZodSet:()=>p$,ZodSchema:()=>D,ZodRecord:()=>f0,ZodReadonly:()=>B0,ZodPromise:()=>d$,ZodPipeline:()=>j0,ZodParsedType:()=>z,ZodOptional:()=>B$,ZodObject:()=>h,ZodNumber:()=>k$,ZodNullable:()=>f$,ZodNull:()=>J0,ZodNever:()=>O$,ZodNativeEnum:()=>X0,ZodNaN:()=>R0,ZodMap:()=>v0,ZodLiteral:()=>Y0,ZodLazy:()=>q0,ZodIssueCode:()=>M,ZodIntersection:()=>W0,ZodFunction:()=>t$,ZodFirstPartyTypeKind:()=>v,ZodError:()=>$$,ZodEnum:()=>E$,ZodEffects:()=>M$,ZodDiscriminatedUnion:()=>d0,ZodDefault:()=>H0,ZodDate:()=>l$,ZodCatch:()=>G0,ZodBranded:()=>r0,ZodBoolean:()=>e$,ZodBigInt:()=>C$,ZodArray:()=>G$,ZodAny:()=>c$,Schema:()=>D,ParseStatus:()=>i,OK:()=>n,NEVER:()=>M3,INVALID:()=>f,EMPTY_PATH:()=>Y4,DIRTY:()=>u$,BRAND:()=>V4});var k;(function($){$.assertEqual=(W)=>{};function J(W){}$.assertIs=J;function Q(W){throw Error()}$.assertNever=Q,$.arrayToEnum=(W)=>{let Y={};for(let X of W)Y[X]=X;return Y},$.getValidEnumValues=(W)=>{let Y=$.objectKeys(W).filter((G)=>typeof W[W[G]]!=="number"),X={};for(let G of Y)X[G]=W[G];return $.objectValues(X)},$.objectValues=(W)=>{return $.objectKeys(W).map(function(Y){return W[Y]})},$.objectKeys=typeof Object.keys==="function"?(W)=>Object.keys(W):(W)=>{let Y=[];for(let X in W)if(Object.prototype.hasOwnProperty.call(W,X))Y.push(X);return Y},$.find=(W,Y)=>{for(let X of W)if(Y(X))return X;return},$.isInteger=typeof Number.isInteger==="function"?(W)=>Number.isInteger(W):(W)=>typeof W==="number"&&Number.isFinite(W)&&Math.floor(W)===W;function q(W,Y=" | "){return W.map((X)=>typeof X==="string"?`'${X}'`:X).join(Y)}$.joinValues=q,$.jsonStringifyReplacer=(W,Y)=>{if(typeof Y==="bigint")return Y.toString();return Y}})(k||(k={}));var D1;(function($){$.mergeShapes=(J,Q)=>{return{...J,...Q}}})(D1||(D1={}));var z=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),K$=($)=>{switch(typeof $){case"undefined":return z.undefined;case"string":return z.string;case"number":return Number.isNaN($)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":if(Array.isArray($))return z.array;if($===null)return z.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return z.promise;if(typeof Map<"u"&&$ instanceof Map)return z.map;if(typeof Set<"u"&&$ instanceof Set)return z.set;if(typeof Date<"u"&&$ instanceof Date)return z.date;return z.object;default:return z.unknown}};var M=k.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Q4=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class $$ extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(Q)=>{this.issues=[...this.issues,Q]},this.addIssues=(Q=[])=>{this.issues=[...this.issues,...Q]};let J=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,J);else this.__proto__=J;this.name="ZodError",this.issues=$}format($){let J=$||function(W){return W.message},Q={_errors:[]},q=(W)=>{for(let Y of W.issues)if(Y.code==="invalid_union")Y.unionErrors.map(q);else if(Y.code==="invalid_return_type")q(Y.returnTypeError);else if(Y.code==="invalid_arguments")q(Y.argumentsError);else if(Y.path.length===0)Q._errors.push(J(Y));else{let X=Q,G=0;while(G<Y.path.length){let H=Y.path[G];if(G!==Y.path.length-1)X[H]=X[H]||{_errors:[]};else X[H]=X[H]||{_errors:[]},X[H]._errors.push(J(Y));X=X[H],G++}}};return q(this),Q}static assert($){if(!($ instanceof $$))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,k.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(J)=>J.message){let J={},Q=[];for(let q of this.issues)if(q.path.length>0){let W=q.path[0];J[W]=J[W]||[],J[W].push($(q))}else Q.push($(q));return{formErrors:Q,fieldErrors:J}}get formErrors(){return this.flatten()}}$$.create=($)=>{return new $$($)};var W4=($,J)=>{let Q;switch($.code){case M.invalid_type:if($.received===z.undefined)Q="Required";else Q=`Expected ${$.expected}, received ${$.received}`;break;case M.invalid_literal:Q=`Invalid literal value, expected ${JSON.stringify($.expected,k.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:Q=`Unrecognized key(s) in object: ${k.joinValues($.keys,", ")}`;break;case M.invalid_union:Q="Invalid input";break;case M.invalid_union_discriminator:Q=`Invalid discriminator value. Expected ${k.joinValues($.options)}`;break;case M.invalid_enum_value:Q=`Invalid enum value. Expected ${k.joinValues($.options)}, received '${$.received}'`;break;case M.invalid_arguments:Q="Invalid function arguments";break;case M.invalid_return_type:Q="Invalid function return type";break;case M.invalid_date:Q="Invalid date";break;case M.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(Q=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")Q=`${Q} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)Q=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)Q=`Invalid input: must end with "${$.validation.endsWith}"`;else k.assertNever($.validation);else if($.validation!=="regex")Q=`Invalid ${$.validation}`;else Q="Invalid";break;case M.too_small:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")Q=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else Q="Invalid input";break;case M.too_big:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")Q=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else Q="Invalid input";break;case M.custom:Q="Invalid input";break;case M.invalid_intersection_types:Q="Intersection results could not be merged";break;case M.not_multiple_of:Q=`Number must be a multiple of ${$.multipleOf}`;break;case M.not_finite:Q="Number must be finite";break;default:Q=J.defaultError,k.assertNever($)}return{message:Q}},A$=W4;var Y5=A$;function q4($){Y5=$}function n$(){return Y5}var S0=($)=>{let{data:J,path:Q,errorMaps:q,issueData:W}=$,Y=[...Q,...W.path||[]],X={...W,path:Y};if(W.message!==void 0)return{...W,path:Y,message:W.message};let G="",H=q.filter((B)=>!!B).slice().reverse();for(let B of H)G=B(X,{data:J,defaultError:G}).message;return{...W,path:Y,message:G}},Y4=[];function N($,J){let Q=n$(),q=S0({issueData:J,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,Q,Q===A$?void 0:A$].filter((W)=>!!W)});$.common.issues.push(q)}class i{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,J){let Q=[];for(let q of J){if(q.status==="aborted")return f;if(q.status==="dirty")$.dirty();Q.push(q.value)}return{status:$.value,value:Q}}static async mergeObjectAsync($,J){let Q=[];for(let q of J){let W=await q.key,Y=await q.value;Q.push({key:W,value:Y})}return i.mergeObjectSync($,Q)}static mergeObjectSync($,J){let Q={};for(let q of J){let{key:W,value:Y}=q;if(W.status==="aborted")return f;if(Y.status==="aborted")return f;if(W.status==="dirty")$.dirty();if(Y.status==="dirty")$.dirty();if(W.value!=="__proto__"&&(typeof Y.value<"u"||q.alwaysSet))Q[W.value]=Y.value}return{status:$.value,value:Q}}}var f=Object.freeze({status:"aborted"}),u$=($)=>({status:"dirty",value:$}),n=($)=>({status:"valid",value:$}),c0=($)=>$.status==="aborted",p0=($)=>$.status==="dirty",P$=($)=>$.status==="valid",a$=($)=>typeof Promise<"u"&&$ instanceof Promise;var b;(function($){$.errToObj=(J)=>typeof J==="string"?{message:J}:J||{},$.toString=(J)=>typeof J==="string"?J:J?.message})(b||(b={}));class _${constructor($,J,Q,q){this._cachedPath=[],this.parent=$,this.data=J,this._path=Q,this._key=q}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var X5=($,J)=>{if(P$(J))return{success:!0,data:J.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let Q=new $$($.common.issues);return this._error=Q,this._error}}}};function j($){if(!$)return{};let{errorMap:J,invalid_type_error:Q,required_error:q,description:W}=$;if(J&&(Q||q))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(J)return{errorMap:J,description:W};return{errorMap:(X,G)=>{let{message:H}=$;if(X.code==="invalid_enum_value")return{message:H??G.defaultError};if(typeof G.data>"u")return{message:H??q??G.defaultError};if(X.code!=="invalid_type")return{message:G.defaultError};return{message:H??Q??G.defaultError}},description:W}}class D{get description(){return this._def.description}_getType($){return K$($.data)}_getOrReturnCtx($,J){return J||{common:$.parent.common,data:$.data,parsedType:K$($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new i,ctx:{common:$.parent.common,data:$.data,parsedType:K$($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let J=this._parse($);if(a$(J))throw Error("Synchronous parse encountered promise.");return J}_parseAsync($){let J=this._parse($);return Promise.resolve(J)}parse($,J){let Q=this.safeParse($,J);if(Q.success)return Q.data;throw Q.error}safeParse($,J){let Q={common:{issues:[],async:J?.async??!1,contextualErrorMap:J?.errorMap},path:J?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:K$($)},q=this._parseSync({data:$,path:Q.path,parent:Q});return X5(Q,q)}"~validate"($){let J={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:K$($)};if(!this["~standard"].async)try{let Q=this._parseSync({data:$,path:[],parent:J});return P$(Q)?{value:Q.value}:{issues:J.common.issues}}catch(Q){if(Q?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;J.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:J}).then((Q)=>P$(Q)?{value:Q.value}:{issues:J.common.issues})}async parseAsync($,J){let Q=await this.safeParseAsync($,J);if(Q.success)return Q.data;throw Q.error}async safeParseAsync($,J){let Q={common:{issues:[],contextualErrorMap:J?.errorMap,async:!0},path:J?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:K$($)},q=this._parse({data:$,path:Q.path,parent:Q}),W=await(a$(q)?q:Promise.resolve(q));return X5(Q,W)}refine($,J){let Q=(q)=>{if(typeof J==="string"||typeof J>"u")return{message:J};else if(typeof J==="function")return J(q);else return J};return this._refinement((q,W)=>{let Y=$(q),X=()=>W.addIssue({code:M.custom,...Q(q)});if(typeof Promise<"u"&&Y instanceof Promise)return Y.then((G)=>{if(!G)return X(),!1;else return!0});if(!Y)return X(),!1;else return!0})}refinement($,J){return this._refinement((Q,q)=>{if(!$(Q))return q.addIssue(typeof J==="function"?J(Q,q):J),!1;else return!0})}_refinement($){return new M$({schema:this,typeName:v.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(J)=>this["~validate"](J)}}optional(){return B$.create(this,this._def)}nullable(){return f$.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return G$.create(this)}promise(){return d$.create(this,this._def)}or($){return Q0.create([this,$],this._def)}and($){return W0.create(this,$,this._def)}transform($){return new M$({...j(this._def),schema:this,typeName:v.ZodEffects,effect:{type:"transform",transform:$}})}default($){let J=typeof $==="function"?$:()=>$;return new H0({...j(this._def),innerType:this,defaultValue:J,typeName:v.ZodDefault})}brand(){return new r0({typeName:v.ZodBranded,type:this,...j(this._def)})}catch($){let J=typeof $==="function"?$:()=>$;return new G0({...j(this._def),innerType:this,catchValue:J,typeName:v.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return j0.create(this,$)}readonly(){return B0.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var X4=/^c[^\s-]{8,}$/i,H4=/^[0-9a-z]+$/,G4=/^[0-9A-HJKMNP-TV-Z]{26}$/i,B4=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,_4=/^[a-z0-9_-]{21}$/i,M4=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,U4=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,w4=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,z4="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",k1,N4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,K4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,O4=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,L4=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,F4=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,S4=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,G5="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",A4=new RegExp(`^${G5}$`);function B5($){let J="[0-5]\\d";if($.precision)J=`${J}\\.\\d{${$.precision}}`;else if($.precision==null)J=`${J}(\\.\\d+)?`;let Q=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${J})${Q}`}function b4($){return new RegExp(`^${B5($)}$`)}function _5($){let J=`${G5}T${B5($)}`,Q=[];if(Q.push($.local?"Z?":"Z"),$.offset)Q.push("([+-]\\d{2}:?\\d{2})");return J=`${J}(${Q.join("|")})`,new RegExp(`^${J}$`)}function f4($,J){if((J==="v4"||!J)&&N4.test($))return!0;if((J==="v6"||!J)&&O4.test($))return!0;return!1}function v4($,J){if(!M4.test($))return!1;try{let[Q]=$.split(".");if(!Q)return!1;let q=Q.replace(/-/g,"+").replace(/_/g,"/").padEnd(Q.length+(4-Q.length%4)%4,"="),W=JSON.parse(atob(q));if(typeof W!=="object"||W===null)return!1;if("typ"in W&&W?.typ!=="JWT")return!1;if(!W.alg)return!1;if(J&&W.alg!==J)return!1;return!0}catch{return!1}}function R4($,J){if((J==="v4"||!J)&&K4.test($))return!0;if((J==="v6"||!J)&&L4.test($))return!0;return!1}class H$ extends D{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==z.string){let W=this._getOrReturnCtx($);return N(W,{code:M.invalid_type,expected:z.string,received:W.parsedType}),f}let Q=new i,q=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.length<W.value)q=this._getOrReturnCtx($,q),N(q,{code:M.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),Q.dirty()}else if(W.kind==="max"){if($.data.length>W.value)q=this._getOrReturnCtx($,q),N(q,{code:M.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),Q.dirty()}else if(W.kind==="length"){let Y=$.data.length>W.value,X=$.data.length<W.value;if(Y||X){if(q=this._getOrReturnCtx($,q),Y)N(q,{code:M.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});else if(X)N(q,{code:M.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});Q.dirty()}}else if(W.kind==="email"){if(!w4.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"email",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="emoji"){if(!k1)k1=new RegExp(z4,"u");if(!k1.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"emoji",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="uuid"){if(!B4.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"uuid",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="nanoid"){if(!_4.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"nanoid",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cuid"){if(!X4.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"cuid",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cuid2"){if(!H4.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"cuid2",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="ulid"){if(!G4.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"ulid",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="url")try{new URL($.data)}catch{q=this._getOrReturnCtx($,q),N(q,{validation:"url",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="regex"){if(W.regex.lastIndex=0,!W.regex.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"regex",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="trim")$.data=$.data.trim();else if(W.kind==="includes"){if(!$.data.includes(W.value,W.position))q=this._getOrReturnCtx($,q),N(q,{code:M.invalid_string,validation:{includes:W.value,position:W.position},message:W.message}),Q.dirty()}else if(W.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(W.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(W.kind==="startsWith"){if(!$.data.startsWith(W.value))q=this._getOrReturnCtx($,q),N(q,{code:M.invalid_string,validation:{startsWith:W.value},message:W.message}),Q.dirty()}else if(W.kind==="endsWith"){if(!$.data.endsWith(W.value))q=this._getOrReturnCtx($,q),N(q,{code:M.invalid_string,validation:{endsWith:W.value},message:W.message}),Q.dirty()}else if(W.kind==="datetime"){if(!_5(W).test($.data))q=this._getOrReturnCtx($,q),N(q,{code:M.invalid_string,validation:"datetime",message:W.message}),Q.dirty()}else if(W.kind==="date"){if(!A4.test($.data))q=this._getOrReturnCtx($,q),N(q,{code:M.invalid_string,validation:"date",message:W.message}),Q.dirty()}else if(W.kind==="time"){if(!b4(W).test($.data))q=this._getOrReturnCtx($,q),N(q,{code:M.invalid_string,validation:"time",message:W.message}),Q.dirty()}else if(W.kind==="duration"){if(!U4.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"duration",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="ip"){if(!f4($.data,W.version))q=this._getOrReturnCtx($,q),N(q,{validation:"ip",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="jwt"){if(!v4($.data,W.alg))q=this._getOrReturnCtx($,q),N(q,{validation:"jwt",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cidr"){if(!R4($.data,W.version))q=this._getOrReturnCtx($,q),N(q,{validation:"cidr",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="base64"){if(!F4.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"base64",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="base64url"){if(!S4.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"base64url",code:M.invalid_string,message:W.message}),Q.dirty()}else k.assertNever(W);return{status:Q.value,value:$.data}}_regex($,J,Q){return this.refinement((q)=>$.test(q),{validation:J,code:M.invalid_string,...b.errToObj(Q)})}_addCheck($){return new H$({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...b.errToObj($)})}url($){return this._addCheck({kind:"url",...b.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...b.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...b.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...b.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...b.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...b.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...b.errToObj($)})}base64($){return this._addCheck({kind:"base64",...b.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...b.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...b.errToObj($)})}ip($){return this._addCheck({kind:"ip",...b.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...b.errToObj($)})}datetime($){if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof $?.precision>"u"?null:$?.precision,offset:$?.offset??!1,local:$?.local??!1,...b.errToObj($?.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof $?.precision>"u"?null:$?.precision,...b.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...b.errToObj($)})}regex($,J){return this._addCheck({kind:"regex",regex:$,...b.errToObj(J)})}includes($,J){return this._addCheck({kind:"includes",value:$,position:J?.position,...b.errToObj(J?.message)})}startsWith($,J){return this._addCheck({kind:"startsWith",value:$,...b.errToObj(J)})}endsWith($,J){return this._addCheck({kind:"endsWith",value:$,...b.errToObj(J)})}min($,J){return this._addCheck({kind:"min",value:$,...b.errToObj(J)})}max($,J){return this._addCheck({kind:"max",value:$,...b.errToObj(J)})}length($,J){return this._addCheck({kind:"length",value:$,...b.errToObj(J)})}nonempty($){return this.min(1,b.errToObj($))}trim(){return new H$({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new H$({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new H$({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $}get maxLength(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $}}H$.create=($)=>{return new H$({checks:[],typeName:v.ZodString,coerce:$?.coerce??!1,...j($)})};function j4($,J){let Q=($.toString().split(".")[1]||"").length,q=(J.toString().split(".")[1]||"").length,W=Q>q?Q:q,Y=Number.parseInt($.toFixed(W).replace(".","")),X=Number.parseInt(J.toFixed(W).replace(".",""));return Y%X/10**W}class k$ extends D{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==z.number){let W=this._getOrReturnCtx($);return N(W,{code:M.invalid_type,expected:z.number,received:W.parsedType}),f}let Q=void 0,q=new i;for(let W of this._def.checks)if(W.kind==="int"){if(!k.isInteger($.data))Q=this._getOrReturnCtx($,Q),N(Q,{code:M.invalid_type,expected:"integer",received:"float",message:W.message}),q.dirty()}else if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)Q=this._getOrReturnCtx($,Q),N(Q,{code:M.too_small,minimum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),q.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)Q=this._getOrReturnCtx($,Q),N(Q,{code:M.too_big,maximum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),q.dirty()}else if(W.kind==="multipleOf"){if(j4($.data,W.value)!==0)Q=this._getOrReturnCtx($,Q),N(Q,{code:M.not_multiple_of,multipleOf:W.value,message:W.message}),q.dirty()}else if(W.kind==="finite"){if(!Number.isFinite($.data))Q=this._getOrReturnCtx($,Q),N(Q,{code:M.not_finite,message:W.message}),q.dirty()}else k.assertNever(W);return{status:q.value,value:$.data}}gte($,J){return this.setLimit("min",$,!0,b.toString(J))}gt($,J){return this.setLimit("min",$,!1,b.toString(J))}lte($,J){return this.setLimit("max",$,!0,b.toString(J))}lt($,J){return this.setLimit("max",$,!1,b.toString(J))}setLimit($,J,Q,q){return new k$({...this._def,checks:[...this._def.checks,{kind:$,value:J,inclusive:Q,message:b.toString(q)}]})}_addCheck($){return new k$({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:b.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString($)})}multipleOf($,J){return this._addCheck({kind:"multipleOf",value:$,message:b.toString(J)})}finite($){return this._addCheck({kind:"finite",message:b.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.toString($)})}get minValue(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $}get maxValue(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&k.isInteger($.value))}get isFinite(){let $=null,J=null;for(let Q of this._def.checks)if(Q.kind==="finite"||Q.kind==="int"||Q.kind==="multipleOf")return!0;else if(Q.kind==="min"){if(J===null||Q.value>J)J=Q.value}else if(Q.kind==="max"){if($===null||Q.value<$)$=Q.value}return Number.isFinite(J)&&Number.isFinite($)}}k$.create=($)=>{return new k$({checks:[],typeName:v.ZodNumber,coerce:$?.coerce||!1,...j($)})};class C$ extends D{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch{return this._getInvalidInput($)}if(this._getType($)!==z.bigint)return this._getInvalidInput($);let Q=void 0,q=new i;for(let W of this._def.checks)if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)Q=this._getOrReturnCtx($,Q),N(Q,{code:M.too_small,type:"bigint",minimum:W.value,inclusive:W.inclusive,message:W.message}),q.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)Q=this._getOrReturnCtx($,Q),N(Q,{code:M.too_big,type:"bigint",maximum:W.value,inclusive:W.inclusive,message:W.message}),q.dirty()}else if(W.kind==="multipleOf"){if($.data%W.value!==BigInt(0))Q=this._getOrReturnCtx($,Q),N(Q,{code:M.not_multiple_of,multipleOf:W.value,message:W.message}),q.dirty()}else k.assertNever(W);return{status:q.value,value:$.data}}_getInvalidInput($){let J=this._getOrReturnCtx($);return N(J,{code:M.invalid_type,expected:z.bigint,received:J.parsedType}),f}gte($,J){return this.setLimit("min",$,!0,b.toString(J))}gt($,J){return this.setLimit("min",$,!1,b.toString(J))}lte($,J){return this.setLimit("max",$,!0,b.toString(J))}lt($,J){return this.setLimit("max",$,!1,b.toString(J))}setLimit($,J,Q,q){return new C$({...this._def,checks:[...this._def.checks,{kind:$,value:J,inclusive:Q,message:b.toString(q)}]})}_addCheck($){return new C$({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:b.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString($)})}multipleOf($,J){return this._addCheck({kind:"multipleOf",value:$,message:b.toString(J)})}get minValue(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $}get maxValue(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $}}C$.create=($)=>{return new C$({checks:[],typeName:v.ZodBigInt,coerce:$?.coerce??!1,...j($)})};class e$ extends D{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==z.boolean){let Q=this._getOrReturnCtx($);return N(Q,{code:M.invalid_type,expected:z.boolean,received:Q.parsedType}),f}return n($.data)}}e$.create=($)=>{return new e$({typeName:v.ZodBoolean,coerce:$?.coerce||!1,...j($)})};class l$ extends D{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==z.date){let W=this._getOrReturnCtx($);return N(W,{code:M.invalid_type,expected:z.date,received:W.parsedType}),f}if(Number.isNaN($.data.getTime())){let W=this._getOrReturnCtx($);return N(W,{code:M.invalid_date}),f}let Q=new i,q=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.getTime()<W.value)q=this._getOrReturnCtx($,q),N(q,{code:M.too_small,message:W.message,inclusive:!0,exact:!1,minimum:W.value,type:"date"}),Q.dirty()}else if(W.kind==="max"){if($.data.getTime()>W.value)q=this._getOrReturnCtx($,q),N(q,{code:M.too_big,message:W.message,inclusive:!0,exact:!1,maximum:W.value,type:"date"}),Q.dirty()}else k.assertNever(W);return{status:Q.value,value:new Date($.data.getTime())}}_addCheck($){return new l$({...this._def,checks:[...this._def.checks,$]})}min($,J){return this._addCheck({kind:"min",value:$.getTime(),message:b.toString(J)})}max($,J){return this._addCheck({kind:"max",value:$.getTime(),message:b.toString(J)})}get minDate(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $!=null?new Date($):null}}l$.create=($)=>{return new l$({checks:[],coerce:$?.coerce||!1,typeName:v.ZodDate,...j($)})};class A0 extends D{_parse($){if(this._getType($)!==z.symbol){let Q=this._getOrReturnCtx($);return N(Q,{code:M.invalid_type,expected:z.symbol,received:Q.parsedType}),f}return n($.data)}}A0.create=($)=>{return new A0({typeName:v.ZodSymbol,...j($)})};class $0 extends D{_parse($){if(this._getType($)!==z.undefined){let Q=this._getOrReturnCtx($);return N(Q,{code:M.invalid_type,expected:z.undefined,received:Q.parsedType}),f}return n($.data)}}$0.create=($)=>{return new $0({typeName:v.ZodUndefined,...j($)})};class J0 extends D{_parse($){if(this._getType($)!==z.null){let Q=this._getOrReturnCtx($);return N(Q,{code:M.invalid_type,expected:z.null,received:Q.parsedType}),f}return n($.data)}}J0.create=($)=>{return new J0({typeName:v.ZodNull,...j($)})};class c$ extends D{constructor(){super(...arguments);this._any=!0}_parse($){return n($.data)}}c$.create=($)=>{return new c$({typeName:v.ZodAny,...j($)})};class D$ extends D{constructor(){super(...arguments);this._unknown=!0}_parse($){return n($.data)}}D$.create=($)=>{return new D$({typeName:v.ZodUnknown,...j($)})};class O$ extends D{_parse($){let J=this._getOrReturnCtx($);return N(J,{code:M.invalid_type,expected:z.never,received:J.parsedType}),f}}O$.create=($)=>{return new O$({typeName:v.ZodNever,...j($)})};class b0 extends D{_parse($){if(this._getType($)!==z.undefined){let Q=this._getOrReturnCtx($);return N(Q,{code:M.invalid_type,expected:z.void,received:Q.parsedType}),f}return n($.data)}}b0.create=($)=>{return new b0({typeName:v.ZodVoid,...j($)})};class G$ extends D{_parse($){let{ctx:J,status:Q}=this._processInputParams($),q=this._def;if(J.parsedType!==z.array)return N(J,{code:M.invalid_type,expected:z.array,received:J.parsedType}),f;if(q.exactLength!==null){let Y=J.data.length>q.exactLength.value,X=J.data.length<q.exactLength.value;if(Y||X)N(J,{code:Y?M.too_big:M.too_small,minimum:X?q.exactLength.value:void 0,maximum:Y?q.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:q.exactLength.message}),Q.dirty()}if(q.minLength!==null){if(J.data.length<q.minLength.value)N(J,{code:M.too_small,minimum:q.minLength.value,type:"array",inclusive:!0,exact:!1,message:q.minLength.message}),Q.dirty()}if(q.maxLength!==null){if(J.data.length>q.maxLength.value)N(J,{code:M.too_big,maximum:q.maxLength.value,type:"array",inclusive:!0,exact:!1,message:q.maxLength.message}),Q.dirty()}if(J.common.async)return Promise.all([...J.data].map((Y,X)=>{return q.type._parseAsync(new _$(J,Y,J.path,X))})).then((Y)=>{return i.mergeArray(Q,Y)});let W=[...J.data].map((Y,X)=>{return q.type._parseSync(new _$(J,Y,J.path,X))});return i.mergeArray(Q,W)}get element(){return this._def.type}min($,J){return new G$({...this._def,minLength:{value:$,message:b.toString(J)}})}max($,J){return new G$({...this._def,maxLength:{value:$,message:b.toString(J)}})}length($,J){return new G$({...this._def,exactLength:{value:$,message:b.toString(J)}})}nonempty($){return this.min(1,$)}}G$.create=($,J)=>{return new G$({type:$,minLength:null,maxLength:null,exactLength:null,typeName:v.ZodArray,...j(J)})};function s$($){if($ instanceof h){let J={};for(let Q in $.shape){let q=$.shape[Q];J[Q]=B$.create(s$(q))}return new h({...$._def,shape:()=>J})}else if($ instanceof G$)return new G$({...$._def,type:s$($.element)});else if($ instanceof B$)return B$.create(s$($.unwrap()));else if($ instanceof f$)return f$.create(s$($.unwrap()));else if($ instanceof L$)return L$.create($.items.map((J)=>s$(J)));else return $}class h extends D{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),J=k.objectKeys($);return this._cached={shape:$,keys:J},this._cached}_parse($){if(this._getType($)!==z.object){let H=this._getOrReturnCtx($);return N(H,{code:M.invalid_type,expected:z.object,received:H.parsedType}),f}let{status:Q,ctx:q}=this._processInputParams($),{shape:W,keys:Y}=this._getCached(),X=[];if(!(this._def.catchall instanceof O$&&this._def.unknownKeys==="strip")){for(let H in q.data)if(!Y.includes(H))X.push(H)}let G=[];for(let H of Y){let B=W[H],_=q.data[H];G.push({key:{status:"valid",value:H},value:B._parse(new _$(q,_,q.path,H)),alwaysSet:H in q.data})}if(this._def.catchall instanceof O$){let H=this._def.unknownKeys;if(H==="passthrough")for(let B of X)G.push({key:{status:"valid",value:B},value:{status:"valid",value:q.data[B]}});else if(H==="strict"){if(X.length>0)N(q,{code:M.unrecognized_keys,keys:X}),Q.dirty()}else if(H==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let H=this._def.catchall;for(let B of X){let _=q.data[B];G.push({key:{status:"valid",value:B},value:H._parse(new _$(q,_,q.path,B)),alwaysSet:B in q.data})}}if(q.common.async)return Promise.resolve().then(async()=>{let H=[];for(let B of G){let _=await B.key,w=await B.value;H.push({key:_,value:w,alwaysSet:B.alwaysSet})}return H}).then((H)=>{return i.mergeObjectSync(Q,H)});else return i.mergeObjectSync(Q,G)}get shape(){return this._def.shape()}strict($){return b.errToObj,new h({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(J,Q)=>{let q=this._def.errorMap?.(J,Q).message??Q.defaultError;if(J.code==="unrecognized_keys")return{message:b.errToObj($).message??q};return{message:q}}}:{}})}strip(){return new h({...this._def,unknownKeys:"strip"})}passthrough(){return new h({...this._def,unknownKeys:"passthrough"})}extend($){return new h({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new h({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:v.ZodObject})}setKey($,J){return this.augment({[$]:J})}catchall($){return new h({...this._def,catchall:$})}pick($){let J={};for(let Q of k.objectKeys($))if($[Q]&&this.shape[Q])J[Q]=this.shape[Q];return new h({...this._def,shape:()=>J})}omit($){let J={};for(let Q of k.objectKeys(this.shape))if(!$[Q])J[Q]=this.shape[Q];return new h({...this._def,shape:()=>J})}deepPartial(){return s$(this)}partial($){let J={};for(let Q of k.objectKeys(this.shape)){let q=this.shape[Q];if($&&!$[Q])J[Q]=q;else J[Q]=q.optional()}return new h({...this._def,shape:()=>J})}required($){let J={};for(let Q of k.objectKeys(this.shape))if($&&!$[Q])J[Q]=this.shape[Q];else{let W=this.shape[Q];while(W instanceof B$)W=W._def.innerType;J[Q]=W}return new h({...this._def,shape:()=>J})}keyof(){return M5(k.objectKeys(this.shape))}}h.create=($,J)=>{return new h({shape:()=>$,unknownKeys:"strip",catchall:O$.create(),typeName:v.ZodObject,...j(J)})};h.strictCreate=($,J)=>{return new h({shape:()=>$,unknownKeys:"strict",catchall:O$.create(),typeName:v.ZodObject,...j(J)})};h.lazycreate=($,J)=>{return new h({shape:$,unknownKeys:"strip",catchall:O$.create(),typeName:v.ZodObject,...j(J)})};class Q0 extends D{_parse($){let{ctx:J}=this._processInputParams($),Q=this._def.options;function q(W){for(let X of W)if(X.result.status==="valid")return X.result;for(let X of W)if(X.result.status==="dirty")return J.common.issues.push(...X.ctx.common.issues),X.result;let Y=W.map((X)=>new $$(X.ctx.common.issues));return N(J,{code:M.invalid_union,unionErrors:Y}),f}if(J.common.async)return Promise.all(Q.map(async(W)=>{let Y={...J,common:{...J.common,issues:[]},parent:null};return{result:await W._parseAsync({data:J.data,path:J.path,parent:Y}),ctx:Y}})).then(q);else{let W=void 0,Y=[];for(let G of Q){let H={...J,common:{...J.common,issues:[]},parent:null},B=G._parseSync({data:J.data,path:J.path,parent:H});if(B.status==="valid")return B;else if(B.status==="dirty"&&!W)W={result:B,ctx:H};if(H.common.issues.length)Y.push(H.common.issues)}if(W)return J.common.issues.push(...W.ctx.common.issues),W.result;let X=Y.map((G)=>new $$(G));return N(J,{code:M.invalid_union,unionErrors:X}),f}}get options(){return this._def.options}}Q0.create=($,J)=>{return new Q0({options:$,typeName:v.ZodUnion,...j(J)})};var b$=($)=>{if($ instanceof q0)return b$($.schema);else if($ instanceof M$)return b$($.innerType());else if($ instanceof Y0)return[$.value];else if($ instanceof E$)return $.options;else if($ instanceof X0)return k.objectValues($.enum);else if($ instanceof H0)return b$($._def.innerType);else if($ instanceof $0)return[void 0];else if($ instanceof J0)return[null];else if($ instanceof B$)return[void 0,...b$($.unwrap())];else if($ instanceof f$)return[null,...b$($.unwrap())];else if($ instanceof r0)return b$($.unwrap());else if($ instanceof B0)return b$($.unwrap());else if($ instanceof G0)return b$($._def.innerType);else return[]};class d0 extends D{_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==z.object)return N(J,{code:M.invalid_type,expected:z.object,received:J.parsedType}),f;let Q=this.discriminator,q=J.data[Q],W=this.optionsMap.get(q);if(!W)return N(J,{code:M.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[Q]}),f;if(J.common.async)return W._parseAsync({data:J.data,path:J.path,parent:J});else return W._parseSync({data:J.data,path:J.path,parent:J})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,J,Q){let q=new Map;for(let W of J){let Y=b$(W.shape[$]);if(!Y.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let X of Y){if(q.has(X))throw Error(`Discriminator property ${String($)} has duplicate value ${String(X)}`);q.set(X,W)}}return new d0({typeName:v.ZodDiscriminatedUnion,discriminator:$,options:J,optionsMap:q,...j(Q)})}}function C1($,J){let Q=K$($),q=K$(J);if($===J)return{valid:!0,data:$};else if(Q===z.object&&q===z.object){let W=k.objectKeys(J),Y=k.objectKeys($).filter((G)=>W.indexOf(G)!==-1),X={...$,...J};for(let G of Y){let H=C1($[G],J[G]);if(!H.valid)return{valid:!1};X[G]=H.data}return{valid:!0,data:X}}else if(Q===z.array&&q===z.array){if($.length!==J.length)return{valid:!1};let W=[];for(let Y=0;Y<$.length;Y++){let X=$[Y],G=J[Y],H=C1(X,G);if(!H.valid)return{valid:!1};W.push(H.data)}return{valid:!0,data:W}}else if(Q===z.date&&q===z.date&&+$===+J)return{valid:!0,data:$};else return{valid:!1}}class W0 extends D{_parse($){let{status:J,ctx:Q}=this._processInputParams($),q=(W,Y)=>{if(c0(W)||c0(Y))return f;let X=C1(W.value,Y.value);if(!X.valid)return N(Q,{code:M.invalid_intersection_types}),f;if(p0(W)||p0(Y))J.dirty();return{status:J.value,value:X.data}};if(Q.common.async)return Promise.all([this._def.left._parseAsync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseAsync({data:Q.data,path:Q.path,parent:Q})]).then(([W,Y])=>q(W,Y));else return q(this._def.left._parseSync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseSync({data:Q.data,path:Q.path,parent:Q}))}}W0.create=($,J,Q)=>{return new W0({left:$,right:J,typeName:v.ZodIntersection,...j(Q)})};class L$ extends D{_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.parsedType!==z.array)return N(Q,{code:M.invalid_type,expected:z.array,received:Q.parsedType}),f;if(Q.data.length<this._def.items.length)return N(Q,{code:M.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),f;if(!this._def.rest&&Q.data.length>this._def.items.length)N(Q,{code:M.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),J.dirty();let W=[...Q.data].map((Y,X)=>{let G=this._def.items[X]||this._def.rest;if(!G)return null;return G._parse(new _$(Q,Y,Q.path,X))}).filter((Y)=>!!Y);if(Q.common.async)return Promise.all(W).then((Y)=>{return i.mergeArray(J,Y)});else return i.mergeArray(J,W)}get items(){return this._def.items}rest($){return new L$({...this._def,rest:$})}}L$.create=($,J)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new L$({items:$,typeName:v.ZodTuple,rest:null,...j(J)})};class f0 extends D{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.parsedType!==z.object)return N(Q,{code:M.invalid_type,expected:z.object,received:Q.parsedType}),f;let q=[],W=this._def.keyType,Y=this._def.valueType;for(let X in Q.data)q.push({key:W._parse(new _$(Q,X,Q.path,X)),value:Y._parse(new _$(Q,Q.data[X],Q.path,X)),alwaysSet:X in Q.data});if(Q.common.async)return i.mergeObjectAsync(J,q);else return i.mergeObjectSync(J,q)}get element(){return this._def.valueType}static create($,J,Q){if(J instanceof D)return new f0({keyType:$,valueType:J,typeName:v.ZodRecord,...j(Q)});return new f0({keyType:H$.create(),valueType:$,typeName:v.ZodRecord,...j(J)})}}class v0 extends D{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.parsedType!==z.map)return N(Q,{code:M.invalid_type,expected:z.map,received:Q.parsedType}),f;let q=this._def.keyType,W=this._def.valueType,Y=[...Q.data.entries()].map(([X,G],H)=>{return{key:q._parse(new _$(Q,X,Q.path,[H,"key"])),value:W._parse(new _$(Q,G,Q.path,[H,"value"]))}});if(Q.common.async){let X=new Map;return Promise.resolve().then(async()=>{for(let G of Y){let H=await G.key,B=await G.value;if(H.status==="aborted"||B.status==="aborted")return f;if(H.status==="dirty"||B.status==="dirty")J.dirty();X.set(H.value,B.value)}return{status:J.value,value:X}})}else{let X=new Map;for(let G of Y){let{key:H,value:B}=G;if(H.status==="aborted"||B.status==="aborted")return f;if(H.status==="dirty"||B.status==="dirty")J.dirty();X.set(H.value,B.value)}return{status:J.value,value:X}}}}v0.create=($,J,Q)=>{return new v0({valueType:J,keyType:$,typeName:v.ZodMap,...j(Q)})};class p$ extends D{_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.parsedType!==z.set)return N(Q,{code:M.invalid_type,expected:z.set,received:Q.parsedType}),f;let q=this._def;if(q.minSize!==null){if(Q.data.size<q.minSize.value)N(Q,{code:M.too_small,minimum:q.minSize.value,type:"set",inclusive:!0,exact:!1,message:q.minSize.message}),J.dirty()}if(q.maxSize!==null){if(Q.data.size>q.maxSize.value)N(Q,{code:M.too_big,maximum:q.maxSize.value,type:"set",inclusive:!0,exact:!1,message:q.maxSize.message}),J.dirty()}let W=this._def.valueType;function Y(G){let H=new Set;for(let B of G){if(B.status==="aborted")return f;if(B.status==="dirty")J.dirty();H.add(B.value)}return{status:J.value,value:H}}let X=[...Q.data.values()].map((G,H)=>W._parse(new _$(Q,G,Q.path,H)));if(Q.common.async)return Promise.all(X).then((G)=>Y(G));else return Y(X)}min($,J){return new p$({...this._def,minSize:{value:$,message:b.toString(J)}})}max($,J){return new p$({...this._def,maxSize:{value:$,message:b.toString(J)}})}size($,J){return this.min($,J).max($,J)}nonempty($){return this.min(1,$)}}p$.create=($,J)=>{return new p$({valueType:$,minSize:null,maxSize:null,typeName:v.ZodSet,...j(J)})};class t$ extends D{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==z.function)return N(J,{code:M.invalid_type,expected:z.function,received:J.parsedType}),f;function Q(X,G){return S0({data:X,path:J.path,errorMaps:[J.common.contextualErrorMap,J.schemaErrorMap,n$(),A$].filter((H)=>!!H),issueData:{code:M.invalid_arguments,argumentsError:G}})}function q(X,G){return S0({data:X,path:J.path,errorMaps:[J.common.contextualErrorMap,J.schemaErrorMap,n$(),A$].filter((H)=>!!H),issueData:{code:M.invalid_return_type,returnTypeError:G}})}let W={errorMap:J.common.contextualErrorMap},Y=J.data;if(this._def.returns instanceof d$){let X=this;return n(async function(...G){let H=new $$([]),B=await X._def.args.parseAsync(G,W).catch((L)=>{throw H.addIssue(Q(G,L)),H}),_=await Reflect.apply(Y,this,B);return await X._def.returns._def.type.parseAsync(_,W).catch((L)=>{throw H.addIssue(q(_,L)),H})})}else{let X=this;return n(function(...G){let H=X._def.args.safeParse(G,W);if(!H.success)throw new $$([Q(G,H.error)]);let B=Reflect.apply(Y,this,H.data),_=X._def.returns.safeParse(B,W);if(!_.success)throw new $$([q(B,_.error)]);return _.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new t$({...this._def,args:L$.create($).rest(D$.create())})}returns($){return new t$({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,J,Q){return new t$({args:$?$:L$.create([]).rest(D$.create()),returns:J||D$.create(),typeName:v.ZodFunction,...j(Q)})}}class q0 extends D{get schema(){return this._def.getter()}_parse($){let{ctx:J}=this._processInputParams($);return this._def.getter()._parse({data:J.data,path:J.path,parent:J})}}q0.create=($,J)=>{return new q0({getter:$,typeName:v.ZodLazy,...j(J)})};class Y0 extends D{_parse($){if($.data!==this._def.value){let J=this._getOrReturnCtx($);return N(J,{received:J.data,code:M.invalid_literal,expected:this._def.value}),f}return{status:"valid",value:$.data}}get value(){return this._def.value}}Y0.create=($,J)=>{return new Y0({value:$,typeName:v.ZodLiteral,...j(J)})};function M5($,J){return new E$({values:$,typeName:v.ZodEnum,...j(J)})}class E$ extends D{_parse($){if(typeof $.data!=="string"){let J=this._getOrReturnCtx($),Q=this._def.values;return N(J,{expected:k.joinValues(Q),received:J.parsedType,code:M.invalid_type}),f}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let J=this._getOrReturnCtx($),Q=this._def.values;return N(J,{received:J.data,code:M.invalid_enum_value,options:Q}),f}return n($.data)}get options(){return this._def.values}get enum(){let $={};for(let J of this._def.values)$[J]=J;return $}get Values(){let $={};for(let J of this._def.values)$[J]=J;return $}get Enum(){let $={};for(let J of this._def.values)$[J]=J;return $}extract($,J=this._def){return E$.create($,{...this._def,...J})}exclude($,J=this._def){return E$.create(this.options.filter((Q)=>!$.includes(Q)),{...this._def,...J})}}E$.create=M5;class X0 extends D{_parse($){let J=k.getValidEnumValues(this._def.values),Q=this._getOrReturnCtx($);if(Q.parsedType!==z.string&&Q.parsedType!==z.number){let q=k.objectValues(J);return N(Q,{expected:k.joinValues(q),received:Q.parsedType,code:M.invalid_type}),f}if(!this._cache)this._cache=new Set(k.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let q=k.objectValues(J);return N(Q,{received:Q.data,code:M.invalid_enum_value,options:q}),f}return n($.data)}get enum(){return this._def.values}}X0.create=($,J)=>{return new X0({values:$,typeName:v.ZodNativeEnum,...j(J)})};class d$ extends D{unwrap(){return this._def.type}_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==z.promise&&J.common.async===!1)return N(J,{code:M.invalid_type,expected:z.promise,received:J.parsedType}),f;let Q=J.parsedType===z.promise?J.data:Promise.resolve(J.data);return n(Q.then((q)=>{return this._def.type.parseAsync(q,{path:J.path,errorMap:J.common.contextualErrorMap})}))}}d$.create=($,J)=>{return new d$({type:$,typeName:v.ZodPromise,...j(J)})};class M$ extends D{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===v.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:J,ctx:Q}=this._processInputParams($),q=this._def.effect||null,W={addIssue:(Y)=>{if(N(Q,Y),Y.fatal)J.abort();else J.dirty()},get path(){return Q.path}};if(W.addIssue=W.addIssue.bind(W),q.type==="preprocess"){let Y=q.transform(Q.data,W);if(Q.common.async)return Promise.resolve(Y).then(async(X)=>{if(J.value==="aborted")return f;let G=await this._def.schema._parseAsync({data:X,path:Q.path,parent:Q});if(G.status==="aborted")return f;if(G.status==="dirty")return u$(G.value);if(J.value==="dirty")return u$(G.value);return G});else{if(J.value==="aborted")return f;let X=this._def.schema._parseSync({data:Y,path:Q.path,parent:Q});if(X.status==="aborted")return f;if(X.status==="dirty")return u$(X.value);if(J.value==="dirty")return u$(X.value);return X}}if(q.type==="refinement"){let Y=(X)=>{let G=q.refinement(X,W);if(Q.common.async)return Promise.resolve(G);if(G instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return X};if(Q.common.async===!1){let X=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(X.status==="aborted")return f;if(X.status==="dirty")J.dirty();return Y(X.value),{status:J.value,value:X.value}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((X)=>{if(X.status==="aborted")return f;if(X.status==="dirty")J.dirty();return Y(X.value).then(()=>{return{status:J.value,value:X.value}})})}if(q.type==="transform")if(Q.common.async===!1){let Y=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(!P$(Y))return f;let X=q.transform(Y.value,W);if(X instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:J.value,value:X}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((Y)=>{if(!P$(Y))return f;return Promise.resolve(q.transform(Y.value,W)).then((X)=>({status:J.value,value:X}))});k.assertNever(q)}}M$.create=($,J,Q)=>{return new M$({schema:$,typeName:v.ZodEffects,effect:J,...j(Q)})};M$.createWithPreprocess=($,J,Q)=>{return new M$({schema:J,effect:{type:"preprocess",transform:$},typeName:v.ZodEffects,...j(Q)})};class B$ extends D{_parse($){if(this._getType($)===z.undefined)return n(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}B$.create=($,J)=>{return new B$({innerType:$,typeName:v.ZodOptional,...j(J)})};class f$ extends D{_parse($){if(this._getType($)===z.null)return n(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}f$.create=($,J)=>{return new f$({innerType:$,typeName:v.ZodNullable,...j(J)})};class H0 extends D{_parse($){let{ctx:J}=this._processInputParams($),Q=J.data;if(J.parsedType===z.undefined)Q=this._def.defaultValue();return this._def.innerType._parse({data:Q,path:J.path,parent:J})}removeDefault(){return this._def.innerType}}H0.create=($,J)=>{return new H0({innerType:$,typeName:v.ZodDefault,defaultValue:typeof J.default==="function"?J.default:()=>J.default,...j(J)})};class G0 extends D{_parse($){let{ctx:J}=this._processInputParams($),Q={...J,common:{...J.common,issues:[]}},q=this._def.innerType._parse({data:Q.data,path:Q.path,parent:{...Q}});if(a$(q))return q.then((W)=>{return{status:"valid",value:W.status==="valid"?W.value:this._def.catchValue({get error(){return new $$(Q.common.issues)},input:Q.data})}});else return{status:"valid",value:q.status==="valid"?q.value:this._def.catchValue({get error(){return new $$(Q.common.issues)},input:Q.data})}}removeCatch(){return this._def.innerType}}G0.create=($,J)=>{return new G0({innerType:$,typeName:v.ZodCatch,catchValue:typeof J.catch==="function"?J.catch:()=>J.catch,...j(J)})};class R0 extends D{_parse($){if(this._getType($)!==z.nan){let Q=this._getOrReturnCtx($);return N(Q,{code:M.invalid_type,expected:z.nan,received:Q.parsedType}),f}return{status:"valid",value:$.data}}}R0.create=($)=>{return new R0({typeName:v.ZodNaN,...j($)})};var V4=Symbol("zod_brand");class r0 extends D{_parse($){let{ctx:J}=this._processInputParams($),Q=J.data;return this._def.type._parse({data:Q,path:J.path,parent:J})}unwrap(){return this._def.type}}class j0 extends D{_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.common.async)return(async()=>{let W=await this._def.in._parseAsync({data:Q.data,path:Q.path,parent:Q});if(W.status==="aborted")return f;if(W.status==="dirty")return J.dirty(),u$(W.value);else return this._def.out._parseAsync({data:W.value,path:Q.path,parent:Q})})();else{let q=this._def.in._parseSync({data:Q.data,path:Q.path,parent:Q});if(q.status==="aborted")return f;if(q.status==="dirty")return J.dirty(),{status:"dirty",value:q.value};else return this._def.out._parseSync({data:q.value,path:Q.path,parent:Q})}}static create($,J){return new j0({in:$,out:J,typeName:v.ZodPipeline})}}class B0 extends D{_parse($){let J=this._def.innerType._parse($),Q=(q)=>{if(P$(q))q.value=Object.freeze(q.value);return q};return a$(J)?J.then((q)=>Q(q)):Q(J)}unwrap(){return this._def.innerType}}B0.create=($,J)=>{return new B0({innerType:$,typeName:v.ZodReadonly,...j(J)})};function H5($,J){let Q=typeof $==="function"?$(J):typeof $==="string"?{message:$}:$;return typeof Q==="string"?{message:Q}:Q}function U5($,J={},Q){if($)return c$.create().superRefine((q,W)=>{let Y=$(q);if(Y instanceof Promise)return Y.then((X)=>{if(!X){let G=H5(J,q),H=G.fatal??Q??!0;W.addIssue({code:"custom",...G,fatal:H})}});if(!Y){let X=H5(J,q),G=X.fatal??Q??!0;W.addIssue({code:"custom",...X,fatal:G})}return});return c$.create()}var P4={object:h.lazycreate},v;(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(v||(v={}));var D4=($,J={message:`Input not instance of ${$.name}`})=>U5((Q)=>Q instanceof $,J),w5=H$.create,z5=k$.create,k4=R0.create,C4=C$.create,N5=e$.create,E4=l$.create,T4=A0.create,I4=$0.create,y4=J0.create,g4=c$.create,h4=D$.create,m4=O$.create,Z4=b0.create,x4=G$.create,u4=h.create,l4=h.strictCreate,c4=Q0.create,p4=d0.create,d4=W0.create,r4=L$.create,i4=f0.create,o4=v0.create,n4=p$.create,a4=t$.create,s4=q0.create,t4=Y0.create,e4=E$.create,$3=X0.create,J3=d$.create,Q3=M$.create,W3=B$.create,q3=f$.create,Y3=M$.createWithPreprocess,X3=j0.create,H3=()=>w5().optional(),G3=()=>z5().optional(),B3=()=>N5().optional(),_3={string:($)=>H$.create({...$,coerce:!0}),number:($)=>k$.create({...$,coerce:!0}),boolean:($)=>e$.create({...$,coerce:!0}),bigint:($)=>C$.create({...$,coerce:!0}),date:($)=>l$.create({...$,coerce:!0})};var M3=f;var U3=S.object({before:S.string(),after:S.string(),hierarchy:S.array(S.string()),lineStart:S.number().optional(),lineEnd:S.number().optional()}).passthrough(),w3=S.object({id:S.string(),name:S.string()}).passthrough(),z3=S.object({url:S.string(),mime:S.string().optional()}).passthrough(),N3=S.object({id:S.string(),snippet:S.string(),note:S.string(),createdAt:S.string(),filePath:S.string().optional(),canvasFile:S.string().optional(),context:U3.optional(),images:S.array(S.string()).optional(),attachments:S.array(z3).optional(),source:S.enum(["local","remote"]).optional(),author:w3.optional()}).passthrough(),K3=S.array(N3.optional().catch(void 0)).transform(($)=>$.filter((J)=>J!==void 0)).catch([]),E1=S.object({annotations:K3,generalNote:S.string().catch("")}).passthrough(),K5=S.object({path:S.string()}),O5=S.object({url:S.string()}),L5=S.object({error:S.string()});import{useCallback as Z8,useMemo as x8,useState as u8}from"react";function V0($){return $.uploadUrl!==null}var T1=["image/png","image/jpeg","image/gif","image/webp"],F5="Only PNG, JPEG, GIF and WebP images can be attached";function v$($,J){$.style.height="auto",$.style.height=(J?Math.max(J,$.scrollHeight):$.scrollHeight)+"px"}import{useAnnotations as i0}from"@fabrika/annotations/runtime";import{jsxDEV as W9}from"react/jsx-dev-runtime";import{jsxDEV as B9,Fragment as G9}from"react/jsx-dev-runtime";import{useAnnotationHost as L3}from"@fabrika/annotations/runtime";import{useCallback as R$,useEffect as F3,useRef as y1,useState as o0}from"react";import{jsxDEV as a}from"react/jsx-dev-runtime";function S5($){if($.startsWith("/s/")||$.startsWith("http://")||$.startsWith("https://"))return $;return`/api/uploads/${$.split("/").pop()}`}async function S3($,J){let Q=$.uploadUrl;if(!Q)return{error:"Uploads are not available here"};let q=new FormData;q.append("image",J);try{let W=await fetch(Q(),{method:"POST",body:q}),Y=await W.json();if(!W.ok){let X=L5.safeParse(Y);return{error:X.success?X.data.error:`Upload failed (HTTP ${W.status})`}}return{path:$.isShared?O5.parse(Y).url:K5.parse(Y).path}}catch{return{error:"Upload failed"}}}function n0({note:$,onNoteChange:J,images:Q,onAddImage:q,onRemoveImage:W,sessionId:Y,placeholder:X="Add your note...",autoFocus:G=!1,autoResize:H=!1,readOnly:B=!1,onKeyDown:_,onTextareaClick:w,textareaRef:L,textareaClassName:F,textareaStyle:U,minHeight:K,attachButton:O="always",openFilePickerRef:R}){let I=L3(),y=!B&&V0(I),[l,Z]=o0(!1),[x,e]=o0(!1),[J$,Q$]=o0(null),[u,d]=o0(!1),r=y1(0),c=y1(null),W$=y1(null),j$=R$(()=>W$.current?.click(),[]);if(R)R.current=j$;let y$=R$((V)=>{if(c.current=V,L)L.current=V;if(V&&H)v$(V,K)},[L,H,K]);F3(()=>{if(G&&c.current){let V=c.current;if(V.focus(),V.value)V.setSelectionRange(V.value.length,V.value.length)}},[G]);let s=R$(async(V)=>{if(!T1.includes(V.type)){Q$(F5);return}Q$(null),e(!0);try{let A=await S3(I,V);if("path"in A)q(A.path);else Q$(A.error)}finally{e(!1)}},[I,q]),q$=R$((V)=>{for(let A of V.clipboardData?.items??[])if(A.type.startsWith("image/")){V.preventDefault();let T=A.getAsFile();if(T)s(T);return}},[s]),U$=R$((V)=>{if(V.preventDefault(),r.current++,r.current===1)Z(!0)},[]),w$=R$((V)=>{V.preventDefault()},[]),g$=R$((V)=>{if(V.preventDefault(),r.current--,r.current===0)Z(!1)},[]),h$=R$((V)=>{V.preventDefault(),r.current=0,Z(!1);for(let A of V.dataTransfer?.files??[])if(A.type.startsWith("image/"))s(A)},[s]),q1=R$((V)=>{if(J(V.currentTarget.value),H)V.currentTarget.style.height="auto",V.currentTarget.style.height=(K?Math.max(K,V.currentTarget.scrollHeight):V.currentTarget.scrollHeight)+"px"},[J,H,K]),Y1="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",z0={width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",outline:"none",...H?{resize:"none",overflow:"hidden"}:{resize:"vertical"}},E0=y&&(O==="always"||O==="on-focus"&&u);return a("div",{style:{position:"relative"},onDragEnter:y?U$:void 0,onDragOver:y?w$:void 0,onDragLeave:y?g$:void 0,onDrop:y?h$:void 0,children:[a("textarea",{ref:y$,value:$,onChange:B?void 0:q1,onPaste:y?q$:void 0,onKeyDown:_,onClick:w,onFocus:()=>d(!0),onBlur:()=>{setTimeout(()=>d(!1),150)},readOnly:B,placeholder:X,className:F??Y1,style:U??z0,rows:H?1:void 0},void 0,!1,void 0,this),y&&a("input",{ref:W$,type:"file",accept:T1.join(","),multiple:!0,style:{display:"none"},onChange:(V)=>{let A=V.currentTarget.files;if(A)for(let T of A)s(T);V.currentTarget.value=""}},void 0,!1,void 0,this),(Q.length>0||E0)&&a("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[Q.map((V)=>a("div",{style:{position:"relative",width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:[a("img",{src:S5(V),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!B&&a("button",{onClick:(A)=>{A.stopPropagation(),W(V)},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)]},V,!0,void 0,this)),E0&&a(a0,{onClick:j$},void 0,!1,void 0,this)]},void 0,!0,void 0,this),x&&a("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),J$&&a("div",{role:"alert",style:{fontSize:"11px",color:"var(--color-accent-red)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:J$},void 0,!1,void 0,this),l&&a("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 a0({onClick:$,size:J=16}){return a("button",{onClick:(Q)=>{Q.stopPropagation(),$()},style:{width:`${J*2}px`,height:`${J*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:a("svg",{width:J,height:J,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},void 0,!1,void 0,this),a("circle",{cx:"8.5",cy:"8.5",r:"1.5"},void 0,!1,void 0,this),a("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 F9}from"@fabrika/annotations/runtime";import{useContext as A9,useEffect as b9,useRef as f9}from"react";import{jsxDEV as D9,Fragment as k9}from"react/jsx-dev-runtime";import{SessionContext as v3,useAnnotationHost as R3}from"@fabrika/annotations/runtime";import{useCallback as s0,useContext as j3,useEffect as V3,useMemo as v5,useRef as t0,useState as _0}from"react";import{createPortal as P3}from"react-dom";function b5($){let J=/^(\d+(?:\.\d+)?)px$/.exec($.trim());return J?Number(J[1]):void 0}function f5($,J,Q=280){let W=J||document.body,Y=$.getBoundingClientRect(),X=W.getBoundingClientRect(),G=W===document.body?0:W.scrollTop,H=Y.bottom-X.top+G+8,B=Math.max(0,Math.min(Y.left-X.left,X.width-Q-12));return W.style.position="relative",{style:{position:"absolute",top:`${H}px`,left:`${B}px`},parent:W}}import{jsxDEV as o,Fragment as D3}from"react/jsx-dev-runtime";function j5({anchorEl:$,scrollContainer:J,onClose:Q,ignoreSelector:q,zIndex:W="50",padding:Y="12px",width:X="280px",children:G}){let H=t0(null),B=t0(Q);B.current=Q;let{style:_,parent:w}=f5($,J,b5(X));return V3(()=>{let L=setTimeout(()=>{let F=(U)=>{if(H.current&&!H.current.contains(U.target)){if(q&&U.target.closest?.(q))return;B.current(),document.removeEventListener("mousedown",F)}};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},0);return()=>clearTimeout(L)},[q]),P3(o("div",{ref:H,style:{..._,zIndex:W,width:X,background:"var(--color-bg-elevated)",border:"1px solid var(--color-border-hover)",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",padding:Y,fontFamily:"'Inter', sans-serif"},children:G},void 0,!1,void 0,this),w)}var V5=[{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"]}],R5=V5.flatMap(($)=>$.items);function P5({anchorEl:$,scrollContainer:J,snippet:Q,truncateAt:q=100,header:W,initialNote:Y="",initialImages:X,onConfirm:G,onCancel:H,onDelete:B}){let _=j3(v3),w=R3(),L=V0(w),F=Y!==""||!!B,[U,K]=_0(Y),[O,R]=_0(X||[]),[I,y]=_0(null),[l,Z]=_0(F),[x,e]=_0(!1),J$=t0(null),Q$=t0(null),u=s0(()=>{if(U.trim()||O.length>0)G(U.trim(),O);else if(F&&B)B();else H()},[U,O,G,H,F,B]),d=s0(()=>{if(F){if(!U.trim()&&O.length===0&&B){B(),H();return}G(U,O);return}H()},[U,O,F,G,H,B]),r=!F,c=U.trim().length>0?R5.filter((A)=>A.toLowerCase().startsWith(U.trim().toLowerCase())):R5,W$=!r||l?[]:c.length===1&&c[0]?.toLowerCase()===U.trim().toLowerCase()?[]:c,j$=new Set(W$),y$=V5.map((A)=>({label:A.label,items:A.items.filter((T)=>j$.has(T))})).filter((A)=>A.items.length>0),s=y$.map((A)=>A.items),q$=(A)=>s[A]?.length??0,U$=s.flat(),w$=v5(()=>{if(I===null)return 0;let A=0;for(let T=0;T<s.length;T++){if(I<A+q$(T))return T;A+=q$(T)}return 0},[I,s]),g$=v5(()=>{if(I===null)return 0;let A=0;for(let T=0;T<w$;T++)A+=q$(T);return I-A},[I,w$,s]),h$=(A,T)=>{let p=0;for(let z$=0;z$<A;z$++)p+=q$(z$);return p+T},[q1,Y1]=_0(U);if(U!==q1)Y1(U),y(null),Z(F);let z0=s0((A)=>{K(A)},[]),E0=Q.length>q?Q.slice(0,q)+"...":Q,V=s0((A)=>{if(U$.length>0&&(A.key==="ArrowDown"||A.key==="ArrowUp"||A.key==="ArrowLeft"||A.key==="ArrowRight")){if(A.preventDefault(),I===null){y(0);return}if(A.key==="ArrowDown"){let p=Math.min(g$+1,q$(w$)-1);y(h$(w$,p))}else if(A.key==="ArrowUp"){let p=Math.max(g$-1,0);y(h$(w$,p))}else if(A.key==="ArrowRight"){let p=Math.min(w$+1,s.length-1),z$=Math.min(g$,q$(p)-1);y(h$(p,z$))}else if(A.key==="ArrowLeft"){let p=Math.max(w$-1,0),z$=Math.min(g$,q$(p)-1);y(h$(p,z$))}return}let T=I===null?void 0:U$[I];if(T!==void 0){if(A.key==="Tab"){A.preventDefault(),z0(T);return}if(A.key==="Enter"&&!A.shiftKey){A.preventDefault(),G(T,O);return}}if(A.key==="Enter"&&!A.shiftKey){A.preventDefault(),u();return}if(A.key==="Escape")if(U$.length>0&&!l)Z(!0);else if(F)d();else H()},[U$,I,g$,w$,s,h$,z0,G,O,u,l,F,d,H]);return o(j5,{anchorEl:$,scrollContainer:J,onClose:F?d:H,ignoreSelector:F?"[data-annotation-id]":void 0,zIndex:F?"60":"50",padding:F?"10px 12px":"12px",width:"420px",children:[!F&&(W??o("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:["“",E0,"”"]},void 0,!0,void 0,this)),o(n0,{note:U,onNoteChange:K,images:O,onAddImage:(A)=>R((T)=>[...T,A]),onRemoveImage:(A)=>R((T)=>T.filter((p)=>p!==A)),sessionId:_,autoFocus:!0,autoResize:F,textareaRef:J$,onKeyDown:V,attachButton:"none",openFilePickerRef:Q$,textareaStyle:F?{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),o("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:F?"6px":"8px"},children:[L&&o(a0,{onClick:()=>Q$.current?.(),size:14},void 0,!1,void 0,this),o("div",{style:{flex:1}},void 0,!1,void 0,this),F?o("button",{onClick:()=>{if(B)B();H()},onMouseEnter:()=>e(!0),onMouseLeave:()=>e(!1),style:{fontSize:"11px",color:x?"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):o(D3,{children:[o("button",{onClick:H,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),o("button",{onClick:u,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),U$.length>0&&o("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:y$.map((A)=>o("div",{style:{flex:1},children:[o("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:A.label},void 0,!1,void 0,this),A.items.map((T)=>{let p=U$.indexOf(T);return o("div",{onMouseDown:(z$)=>{z$.preventDefault(),z$.stopPropagation(),z0(T)},onMouseEnter:()=>y(p),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:p===I?"var(--color-text-primary)":"var(--color-text-secondary)",background:p===I?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[o("span",{style:{fontWeight:500},children:T.slice(0,U.trim().length)},void 0,!1,void 0,this),T.slice(U.trim().length)]},T,!0,void 0,this)})]},A.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function P0({anchorEl:$,scrollContainer:J,snippet:Q,truncateAt:q,header:W,onAdd:Y,onCancel:X}){return o(P5,{anchorEl:$,scrollContainer:J,snippet:Q,truncateAt:q,header:W,onConfirm:(G,H)=>Y(G,H),onCancel:X},void 0,!1,void 0,this)}import{useEffect as i9,useRef as o9,useState as n9}from"react";import{jsxDEV as J7}from"react/jsx-dev-runtime";import{useCallback as X7,useEffect as H7,useRef as G7,useState as B7}from"react";import{jsxDEV as O7,Fragment as K7}from"react/jsx-dev-runtime";import{jsxDEV as D5}from"react/jsx-dev-runtime";function M0({note:$,onChange:J}){return D5("div",{className:"mt-1.5",children:D5("textarea",{value:$,onChange:(Q)=>J(Q.currentTarget.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)=>v$(Q.currentTarget),ref:(Q)=>{if(Q)v$(Q)}},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as m}from"react/jsx-dev-runtime";function g5($){return $.map((J)=>typeof J==="string"?{value:J,label:J}:{value:J.value,label:J.label??J.value})}function Z3({id:$,label:J,options:Q,required:q}){let{responses:W,setResponse:Y}=k5();C5($);let X=T5(()=>g5(Q),[Q]),G=W.get($),H=G?.value,B=G?.note||"",[_,w]=y5(!1),L=I5(null);if(!W.has($))Y($,{id:$,type:"radio",label:J,value:null,options:X.map((K)=>K.value),required:q});let F=(K)=>{Y($,{...G,value:K})};E5(()=>{let K=L.current;if(!K)return;let O=(R)=>{let y=R.target.closest("[data-md-label]")?.getAttribute("data-md-label"),l=X.find((Z)=>Z.label===y);if(l)F(l.value)};return K.addEventListener("kb-select",O),()=>K.removeEventListener("kb-select",O)},[X,F]);let U=G?.required&&!H;return m("div",{ref:L,"data-md":"choice","data-md-label":J,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:J},void 0,!1,void 0,this),q&&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:X.map(({value:K,label:O})=>m("label",{"data-md":"choice-option","data-md-label":O,onClick:()=>F(K),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${H===K?"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 ${H===K?"border-accent-amber bg-accent-amber":"border-border-strong"}`,children:H===K&&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:O},void 0,!1,void 0,this)]},K,!0,void 0,this))},void 0,!1,void 0,this),m(M0,{show:_,note:B,onToggle:()=>w(!_),onChange:(K)=>Y($,{...G,note:K})},void 0,!1,void 0,this),U&&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 x3({id:$,label:J,options:Q,required:q}){let{responses:W,setResponse:Y}=k5();C5($);let X=T5(()=>g5(Q),[Q]),G=W.get($),H=G?.value||[],B=G?.note||"",[_,w]=y5(!1),L=I5(null);if(!W.has($))Y($,{id:$,type:"checkbox",label:J,value:[],options:X.map((K)=>K.value),required:q});let F=(K)=>{let O=H.includes(K)?H.filter((R)=>R!==K):[...H,K];Y($,{...G,value:O})};E5(()=>{let K=L.current;if(!K)return;let O=(R)=>{let y=R.target.closest("[data-md-label]")?.getAttribute("data-md-label"),l=X.find((Z)=>Z.label===y);if(l)F(l.value)};return K.addEventListener("kb-select",O),()=>K.removeEventListener("kb-select",O)},[X,F]);let U=G?.required&&H.length===0;return m("div",{ref:L,"data-md":"multichoice","data-md-label":J,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:J},void 0,!1,void 0,this),q&&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:X.map(({value:K,label:O})=>{let R=H.includes(K);return m("label",{"data-md":"multichoice-option","data-md-label":O,onClick:()=>F(K),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${R?"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 ${R?"bg-accent-amber":"border-[1.5px] border-border-strong"}`,children:R&&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:O},void 0,!1,void 0,this)]},K,!0,void 0,this)})},void 0,!1,void 0,this),m(M0,{show:_,note:B,onToggle:()=>w(!_),onChange:(K)=>Y($,{...G,note:K})},void 0,!1,void 0,this),U&&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{useEffect as u3,useRef as l3}from"react";function e0(){return window.hljs}function h5(){return window.mermaid}import{jsxDEV as $1}from"react/jsx-dev-runtime";function c3({language:$,children:J}){let Q=typeof J==="string"?J:String(J??""),q=l3(null);return u3(()=>{let W=q.current,Y=e0();if(!W||!Y)return;W.removeAttribute("data-highlighted"),W.className=$?`language-${$}`:"",W.textContent=Q,Y.highlightElement(W)},[Q,$]),$1("div",{className:"relative mt-3 group/code","data-md":"codeblock","data-md-language":$||"",children:[$&&$1("span",{className:"absolute top-2 right-3 text-tiny text-text-tertiary opacity-0 group-hover/code:opacity-60 transition-opacity duration-150 z-10 font-mono",children:$},void 0,!1,void 0,this),$1("pre",{className:"bg-bg-code rounded-md p-4 overflow-x-auto text-code font-mono leading-relaxed",children:$1("code",{ref:q,className:$?`language-${$}`:"",children:Q},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function m5($,J){let Q=$.split(`
60
- `),q=J.split(`
61
- `),W=p3(Q,q),Y=[],X=0,G=0,H=0;while(X<Q.length||G<q.length){let B=Q[X],_=q[G];if(H<W.length&&B!==void 0&&_!==void 0&&B===W[H]&&_===W[H])Y.push({type:"same",line:B}),X++,G++,H++;else if(B!==void 0&&(H>=W.length||B!==W[H]))Y.push({type:"removed",line:B}),X++;else if(_!==void 0)Y.push({type:"added",line:_}),G++}return Y}function p3($,J){let Q=$.length,q=J.length,W=Array.from({length:Q+1},()=>Array(q+1).fill(0));for(let H=1;H<=Q;H++){let B=W[H]??[],_=W[H-1]??[];for(let w=1;w<=q;w++)B[w]=$[H-1]===J[w-1]?(_[w-1]??0)+1:Math.max(_[w]??0,B[w-1]??0)}let Y=[],X=Q,G=q;while(X>0&&G>0){let H=$[X-1];if(H!==void 0&&H===J[G-1])Y.unshift(H),X--,G--;else if((W[X-1]?.[G]??0)>(W[X]?.[G-1]??0))X--;else G--}return Y}import{jsxDEV as D0}from"react/jsx-dev-runtime";function d3({before:$,after:J,language:Q}){let q=m5($,J);return D0("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden group/diff","data-md":"diff","data-md-language":Q||"",children:[Q&&D0("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),D0("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono",children:q.map((W,Y)=>D0("div",{className:W.type==="removed"?"bg-accent-red-muted text-accent-red":W.type==="added"?"bg-accent-green-muted text-accent-green":"text-text-tertiary",children:[D0("span",{className:"select-none w-6 inline-block text-center opacity-60",children:W.type==="removed"?"-":W.type==="added"?"+":" "},void 0,!1,void 0,this),W.line]},Y,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{ActiveViewCtx as o3,SessionContext as n3}from"#canvas/runtime";import{useContext as x5,useEffect as u5,useRef as a3,useState as J1}from"react";var r3=S.object({id:S.string(),type:S.enum(["select","radio","checkbox","text","range"]),label:S.string(),value:S.unknown(),options:S.array(S.string()).optional(),required:S.boolean().optional(),note:S.string().optional()}).passthrough().transform(($)=>({...$,value:$.value})),i3=S.object({id:S.string(),markdown:S.string(),label:S.string().optional(),required:S.boolean().optional()}).passthrough(),AJ=E1.extend({responses:S.array(S.tuple([S.string(),r3]).optional().catch(void 0)).transform(($)=>$.filter((J)=>J!==void 0)).catch([]),feedbackEntries:S.array(S.tuple([S.string(),i3]).optional().catch(void 0)).transform(($)=>$.filter((J)=>J!==void 0)).optional().catch([])});var bJ=S.object({feedback:S.string().nullish()}),Z5=S.union([S.object({error:S.string().min(1)}),S.object({content:S.string(),language:S.string().nullish()})]);import{jsxDEV as T$}from"react/jsx-dev-runtime";var s3={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 t3({path:$,lines:J,__content:Q}){let q=x5(n3),{setActiveView:W}=x5(o3),[Y,X]=J1(Q??null),[G,H]=J1(()=>{let U=$.split(".").pop()||"";return s3[U]||"text"}),[B,_]=J1(null),[w,L]=J1(!Q),F=a3(null);if(u5(()=>{if(Q!==void 0)return;L(!0),_(null),fetch(`/api/file?session=${q}&path=${encodeURIComponent($)}`).then((U)=>U.json()).then((U)=>{let K=Z5.parse(U);if("error"in K)_(K.error);else{let O=K.content;if(J)O=O.split(`
62
- `).slice(J[0]-1,J[1]).join(`
63
- `);X(O),H(K.language||"text")}}).catch(()=>_("Failed to fetch file")).finally(()=>L(!1))},[q,$,J?.[0],J?.[1],Q]),u5(()=>{let U=F.current,K=e0();if(!U||!K||!Y)return;U.removeAttribute("data-highlighted"),U.className=G?`language-${G}`:"",U.textContent=Y,K.highlightElement(U)},[Y,G]),w)return T$("div",{className:"text-text-tertiary text-body mt-3 bg-bg-code rounded-md p-4",children:["Loading ",$,"..."]},void 0,!0,void 0,this);if(B)return T$("div",{className:"text-accent-red text-body mt-3 bg-accent-red-muted rounded-md p-4",children:[$,": ",B]},void 0,!0,void 0,this);return T$("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden","data-md":"filepreview","data-md-path":$,...J?{"data-md-lines":`${J[0]}-${J[1]}`}:{},children:[T$("div",{className:"px-4 py-2 flex items-center justify-between",children:[T$("button",{className:"font-mono text-meta text-text-tertiary hover:text-text-secondary hover:underline cursor-pointer text-left",onClick:()=>W({type:"file",path:$}),title:`Open ${$}`,children:$},void 0,!1,void 0,this),J&&T$("span",{className:"font-mono text-meta text-text-tertiary opacity-60",children:["L",J[0],"–",J[1]]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),T$("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono !bg-transparent",style:{background:"transparent"},children:T$("code",{ref:F,className:G?`language-${G}`:"",children:Y},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{SessionContext as e3}from"#canvas/runtime";import{useContext as $6,useState as J6}from"react";import{jsxDEV as k0}from"react/jsx-dev-runtime";function Q6({src:$,alt:J,caption:Q,width:q,height:W}){let Y=$6(e3),[X,G]=J6(!1),H=`/api/image?session=${encodeURIComponent(Y)}&path=${encodeURIComponent($)}`;if(X)return k0("div",{className:"mt-3 text-accent-red text-body bg-accent-red-muted rounded-md p-4",children:[$,": Failed to load image"]},void 0,!0,void 0,this);return k0("figure",{className:"mt-3 relative","data-md":"image","data-md-src":$,children:[k0("div",{"data-annotation-image":!0,className:"rounded-md overflow-hidden border border-border-subtle bg-bg-code inline-block",children:k0("img",{src:H,alt:J||$,onError:()=>G(!0),draggable:!1,className:"block max-w-full h-auto",...q?{width:q}:{},...W?{height:W}:{}},void 0,!1,void 0,this)},void 0,!1,void 0,this),Q&&k0("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 W6}from"react";import{jsxDEV as l5}from"react/jsx-dev-runtime";C.setOptions({gfm:!0,breaks:!1});function q6({children:$,file:J,__content:Q}){let q=Q??(typeof $==="string"?$:String($??"")),W=W6(()=>{if(!q)return"";return C.parse(q,{async:!1})},[q]);if(!q)return l5("div",{className:"text-text-tertiary text-tiny mt-3",children:J?`Could not load: ${J}`:"No markdown content"},void 0,!1,void 0,this);return l5("div",{className:"mt-3 prose-canvas","data-md":"markdown",...J?{"data-md-file":J}:{},"data-md-source":q,dangerouslySetInnerHTML:{__html:W}},void 0,!1,void 0,this)}import{useAnnotations as Y6,useCanvasFile as X6}from"#canvas/runtime";import{useCallback as F$,useEffect as g1,useRef as C0,useState as U0}from"react";import H6 from"react-dom";import{jsxDEV as P,Fragment as r5}from"react/jsx-dev-runtime";var w0=0.2,Q1=0.25,W1=4;function p5({zoom:$,onZoomIn:J,onZoomOut:Q,onZoomReset:q,onFullscreen:W}){return P("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:[P("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:$<=Q1,children:P("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:P("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),P("button",{className:"px-1.5 h-7 rounded hover:bg-bg-elevated text-text-tertiary hover:text-text-primary transition-colors tabular-nums",onClick:q,title:"Reset zoom",children:[Math.round($*100),"%"]},void 0,!0,void 0,this),P("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 in",disabled:$>=W1,children:P("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[P("line",{x1:"12",y1:"5",x2:"12",y2:"19"},void 0,!1,void 0,this),P("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),W&&P(r5,{children:[P("div",{className:"w-px h-4 bg-border-subtle mx-0.5"},void 0,!1,void 0,this),P("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:W,title:"Fullscreen",children:P("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[P("polyline",{points:"15 3 21 3 21 9"},void 0,!1,void 0,this),P("polyline",{points:"9 21 3 21 3 15"},void 0,!1,void 0,this),P("line",{x1:"21",y1:"3",x2:"14",y2:"10"},void 0,!1,void 0,this),P("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 d5($=1){let[J,Q]=U0($),q=F$(()=>Q((X)=>Math.min(W1,+(X+w0).toFixed(2))),[]),W=F$(()=>Q((X)=>Math.max(Q1,+(X-w0).toFixed(2))),[]),Y=F$(()=>Q(1),[]);return{zoom:J,zoomIn:q,zoomOut:W,zoomReset:Y,setZoom:Q}}function G6({svgHtml:$,source:J,onClose:Q}){let q=C0(null),{zoom:W,zoomIn:Y,zoomOut:X,zoomReset:G,setZoom:H}=d5(1),[B,_]=U0({x:0,y:0}),w=C0(null);g1(()=>{let R=(I)=>{if(I.key==="Escape")Q()};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[Q]);let L=F$((R)=>{R.preventDefault();let I=R.deltaY>0?-w0:w0;H((y)=>Math.max(Q1,Math.min(W1,+(y+I).toFixed(2))))},[H]),F=F$((R)=>{if(R.button!==0)return;w.current={startX:R.clientX,startY:R.clientY,panX:B.x,panY:B.y},R.preventDefault()},[B]),U=F$((R)=>{if(!w.current)return;_({x:w.current.panX+(R.clientX-w.current.startX),y:w.current.panY+(R.clientY-w.current.startY)})},[]),K=F$(()=>{w.current=null},[]),O=F$(()=>{G(),_({x:0,y:0})},[G]);return H6.createPortal(P("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"var(--color-bg-base)",display:"flex",flexDirection:"column"},onMouseMove:U,onMouseUp:K,onMouseLeave:K,children:[P("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:[P("span",{className:"text-body text-text-secondary",style:{fontSize:"13px"},children:"Mermaid Diagram"},void 0,!1,void 0,this),P("div",{className:"flex items-center gap-2",children:[P(p5,{zoom:W,onZoomIn:Y,onZoomOut:X,onZoomReset:O},void 0,!1,void 0,this),P("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:P("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[P("line",{x1:"18",y1:"6",x2:"6",y2:"18"},void 0,!1,void 0,this),P("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),P("div",{style:{flex:1,overflow:"hidden",cursor:w.current?"grabbing":"grab"},onWheel:L,onMouseDown:F,children:P("div",{ref:q,style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",transform:`translate(${B.x}px, ${B.y}px) scale(${W})`,transformOrigin:"center center",transition:w.current?"none":"transform 0.1s ease-out"},dangerouslySetInnerHTML:{__html:$}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),document.body)}function B6({children:$}){let J=C0(null),[Q,q]=U0(null),[W,Y]=U0(!1),[X,G]=U0(""),H=typeof $==="string"?$:String($??""),{annotations:B,addAnnotationWithId:_,activeAnnotationId:w,setActiveAnnotationId:L}=Y6(),F=X6(),[U,K]=U0(null),{zoom:O,zoomIn:R,zoomOut:I,zoomReset:y,setZoom:l}=d5(1),Z=C0(B);Z.current=B;let x=F$((u,d,r)=>{let c=`[Diagram ${r.toLowerCase()}] ${d}`,W$=Z.current.find((j$)=>j$.snippet===c);if(W$)L(W$.id);else K({anchorEl:u,snippet:d,prefix:r})},[L]),e=C0(x);e.current=x,g1(()=>{let u=!1,d=async()=>{try{let c=h5();if(!c){q("Mermaid library not loaded");return}let W$=document.documentElement.dataset.theme==="light"?"default":"dark";c.initialize({startOnLoad:!1,theme:W$});let j$=`mermaid-${Math.random().toString(36).slice(2)}`,{svg:y$}=await c.render(j$,H.trim());if(!u&&J.current)J.current.innerHTML=y$,G(y$),_6(J.current,(s,q$,U$)=>e.current(s,q$,U$)),c5(J.current,Z.current);q(null)}catch(c){if(!u)q(c instanceof Error&&c.message||"Invalid diagram")}};d();let r=new MutationObserver((c)=>{for(let W$ of c)if(W$.attributeName==="data-theme")d()});return r.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{u=!0,r.disconnect()}},[H]),g1(()=>{if(J.current)c5(J.current,B,w)},[B,w]);let J$=F$((u)=>{if(!u.ctrlKey&&!u.metaKey)return;u.preventDefault();let d=u.deltaY>0?-w0:w0;l((r)=>Math.max(Q1,Math.min(W1,+(r+d).toFixed(2))))},[l]);if(Q)return P("div",{className:"bg-accent-red-muted rounded-md p-4 mt-3 text-body text-accent-red",children:["Mermaid error: ",Q,P("pre",{className:"mt-2 text-tiny text-text-tertiary whitespace-pre-wrap",children:H},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let Q$=J.current?.closest("#plan-scroll-container");return P(r5,{children:[P("div",{className:"mt-3 mermaid-container","data-md":"mermaid","data-md-source":H.trim(),children:[P("div",{className:"flex justify-end mb-1",children:P(p5,{zoom:O,onZoomIn:R,onZoomOut:I,onZoomReset:y,onFullscreen:()=>Y(!0)},void 0,!1,void 0,this)},void 0,!1,void 0,this),P("div",{style:{overflow:"auto",maxHeight:"70vh"},onWheel:J$,children:P("div",{ref:J,className:"flex justify-center",style:{transform:`scale(${O})`,transformOrigin:"top center",transition:"transform 0.1s ease-out",minHeight:O<1?void 0:void 0}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U&&P(P0,{anchorEl:U.anchorEl,scrollContainer:Q$,snippet:U.snippet,header:P("div",{style:{fontSize:"12px",color:"var(--color-text-tertiary)",marginBottom:"8px",lineHeight:"1.4",display:"flex",alignItems:"center",gap:"6px"},children:[P("span",{style:{width:"8px",height:"8px",borderRadius:"50%",background:"var(--color-accent-amber)",flexShrink:0}},void 0,!1,void 0,this),U.snippet]},void 0,!0,void 0,this),onAdd:(u,d)=>{let r=`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;_(r,`[Diagram ${U.prefix.toLowerCase()}] ${U.snippet}`,u,void 0,void 0,d,F||void 0),K(null)},onCancel:()=>K(null)},void 0,!1,void 0,this),W&&X&&P(G6,{svgHtml:X,source:H,onClose:()=>Y(!1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function _6($,J){let Q=(q,W,Y)=>{q.style.cursor="pointer",q.addEventListener("mouseenter",()=>{q.style.filter="brightness(1.2)"}),q.addEventListener("mouseleave",()=>{q.style.filter=""}),q.addEventListener("click",(X)=>{X.stopPropagation(),X.preventDefault(),J(q,W(),Y)})};for(let q of $.querySelectorAll(".node"))Q(q,()=>{return(q.querySelector(".nodeLabel")||q.querySelector("foreignObject span")||q.querySelector("text"))?.textContent?.trim()||"Node"},"Node");for(let q of $.querySelectorAll(".edgePath")){let W=q,Y=W.querySelector("path");if(Y){Y.style.strokeWidth=Math.max(parseFloat(Y.style.strokeWidth||"1"),8)+"px",Y.style.strokeOpacity="0";let G=Y.cloneNode(!0);G.style.strokeWidth="",G.style.strokeOpacity="",W.insertBefore(G,Y)}let X=W.id||"";Q(W,()=>{let G=$.querySelectorAll(".edgeLabel");for(let H of G)if(H.id&&X&&H.id.replace("label","").includes(X.replace("L-","").replace("edge",""))){let B=H.textContent?.trim();if(B)return B}return"Connection"},"Edge")}for(let q of $.querySelectorAll(".edgeLabel")){let W=q.textContent?.trim();if(!W)continue;Q(q,()=>W,"Edge")}for(let q of $.querySelectorAll(".actor")){let W=q.closest("g")?.querySelector("text")||q.parentElement?.querySelector("text");if(!W)continue;let Y=q.closest("g");if(!Y||Y.hasAttribute("data-clickable"))continue;Y.setAttribute("data-clickable","true"),Q(Y,()=>W.textContent?.trim()||"Participant","Node")}for(let q of $.querySelectorAll(".messageText")){let W=q.textContent?.trim();if(!W)continue;Q(q,()=>W,"Edge")}for(let q of $.querySelectorAll(".entityBox")){let W=q.closest("g");if(!W||W.hasAttribute("data-clickable"))continue;let Y=W.querySelector(".entityLabel");if(!Y)continue;W.setAttribute("data-clickable","true"),Q(W,()=>Y.textContent?.trim()||"Entity","Node")}for(let q of $.querySelectorAll(".relationshipLabel")){let W=q.textContent?.trim();if(!W)continue;let X=q.closest("g")||q;if(X.hasAttribute("data-clickable"))continue;X.setAttribute("data-clickable","true"),Q(X,()=>W,"Edge")}for(let q of $.querySelectorAll(".classGroup")){let W=q;if(W.hasAttribute("data-clickable"))continue;let Y=W.querySelector(".classTitle, .classTitleText, text");if(!Y)continue;W.setAttribute("data-clickable","true"),Q(W,()=>Y.textContent?.trim()||"Class","Node")}for(let q of $.querySelectorAll(".statediagram-state")){let W=q;if(W.hasAttribute("data-clickable"))continue;let Y=W.querySelector(".state-title, text");if(!Y)continue;W.setAttribute("data-clickable","true"),Q(W,()=>Y.textContent?.trim()||"State","Node")}for(let q of $.querySelectorAll(".mindmap-node")){let W=q;if(W.hasAttribute("data-clickable"))continue;let Y=W.querySelector(".mindmap-node-label, text");if(!Y)continue;W.setAttribute("data-clickable","true"),Q(W,()=>Y.textContent?.trim()||"Node","Node")}}function c5($,J,Q){let q=new Map;for(let Y of J){let X=Y.snippet.match(/^\[Diagram (?:node|edge)\] (.+)$/)?.[1];if(X)q.set(X,Y.id)}for(let Y of $.querySelectorAll("[data-annotated]"))Y.style.outline="",Y.style.outlineOffset="",Y.style.borderRadius="",Y.removeAttribute("data-annotated");if(q.size===0)return;for(let Y of $.querySelectorAll(".node")){let G=(Y.querySelector(".nodeLabel")||Y.querySelector("foreignObject span")||Y.querySelector("text"))?.textContent?.trim();if(!G||!q.has(G))continue;let H=q.get(G),B=Y;B.setAttribute("data-annotated",H);let _=H===Q;B.style.outline=_?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",B.style.outlineOffset="2px",B.style.borderRadius="4px"}for(let Y of $.querySelectorAll(".edgeLabel")){let X=Y.textContent?.trim();if(!X||!q.has(X))continue;let G=q.get(X),H=Y;H.setAttribute("data-annotated",G);let B=G===Q;H.style.outline=B?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",H.style.outlineOffset="2px",H.style.borderRadius="4px"}for(let Y of $.querySelectorAll(".actor")){let X=Y.closest("g");if(!X)continue;let H=X.querySelector("text")?.textContent?.trim();if(!H||!q.has(H))continue;if(X.hasAttribute("data-annotated"))continue;let B=q.get(H);X.setAttribute("data-annotated",B);let _=B===Q,w=X.querySelector("rect");if(w)w.style.outline=_?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",w.style.outlineOffset="2px",w.style.borderRadius="4px"}for(let Y of $.querySelectorAll(".messageText")){let X=Y.textContent?.trim();if(!X||!q.has(X))continue;let G=q.get(X),H=Y;H.setAttribute("data-annotated",G);let B=G===Q;H.style.outline=B?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",H.style.outlineOffset="2px",H.style.borderRadius="4px"}let W=(Y,X,G)=>{for(let H of $.querySelectorAll(Y)){let B=G(H);if(!B||B.hasAttribute("data-annotated"))continue;let w=B.querySelector(X)?.textContent?.trim();if(!w||!q.has(w))continue;let L=q.get(w);B.setAttribute("data-annotated",L);let F=L===Q,U=B.querySelector("rect, circle, ellipse, polygon")||B;U.style.outline=F?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",U.style.outlineOffset="2px",U.style.borderRadius="4px"}};W(".entityBox",".entityLabel",(Y)=>Y.closest("g"));for(let Y of $.querySelectorAll(".relationshipLabel")){let G=Y.closest("g")||Y;if(G.hasAttribute("data-annotated"))continue;let H=Y.textContent?.trim();if(!H||!q.has(H))continue;let B=q.get(H);G.setAttribute("data-annotated",B);let _=B===Q;G.style.outline=_?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",G.style.outlineOffset="2px",G.style.borderRadius="4px"}W(".classGroup",".classTitle, .classTitleText, text",(Y)=>Y),W(".statediagram-state",".state-title, text",(Y)=>Y),W(".mindmap-node",".mindmap-node-label, text",(Y)=>Y)}import{jsxDEV as U6}from"react/jsx-dev-runtime";function M6({children:$}){return U6("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:V$($)},void 0,!1,void 0,this)}import{jsxDEV as N6}from"react/jsx-dev-runtime";var w6={high:"text-accent-red bg-accent-red-muted",medium:"text-accent-amber bg-accent-amber-muted",low:"text-text-tertiary bg-border-subtle"};function z6({level:$}){return N6("span",{className:`inline text-tiny font-medium font-body ml-2 px-1.5 py-0.5 rounded ${w6[$]}`,"data-md":"priority","data-md-level":$,children:$},void 0,!1,void 0,this)}import{useState as K6}from"react";import{jsxDEV as r$}from"react/jsx-dev-runtime";function O6({title:$,children:J}){let[Q,q]=K6(!1);return r$("div",{className:"relative mb-8 p-4 group/section","data-md":"section","data-md-title":$,children:[r$("div",{className:"relative mb-2",children:[r$("button",{onClick:()=>q(!Q),className:`absolute -left-8 top-1/2 -translate-y-1/2 text-text-tertiary opacity-0 group-hover/section:opacity-50 hover:!opacity-100 transition-all duration-150 p-0.5 ${Q?"-rotate-90":""}`,children:r$("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",children:r$("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),r$("h2",{className:"font-heading text-section text-text-primary",style:{fontWeight:400},children:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this),r$("div",{className:Q?"mt-6 hidden":"mt-6",children:V$(J)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as I$}from"react/jsx-dev-runtime";function L6({headers:$,rows:J}){return I$("div",{className:"overflow-x-auto mt-3","data-md":"table",children:I$("table",{className:"w-full text-body",children:[I$("thead",{children:I$("tr",{className:"border-b border-border-subtle",children:$.map((Q,q)=>I$("th",{className:"text-left px-4 py-2.5 text-meta font-medium uppercase tracking-wider text-text-tertiary font-body",children:Q},q,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),I$("tbody",{children:J.map((Q,q)=>I$("tr",{className:`relative border-b border-border-subtle last:border-b-0 transition-colors hover:bg-bg-surface/50 ${q%2===1?"bg-bg-surface/30":""}`,children:Q.map((W,Y)=>I$("td",{className:"px-4 py-2.5 text-text-secondary font-body",children:W},Y,!1,void 0,this))},q,!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 S$}from"react/jsx-dev-runtime";var F6={todo:"bg-border-hover",done:"bg-accent-green",blocked:"bg-accent-red","in-progress":"bg-accent-blue"},S6={todo:"Todo",done:"Done",blocked:"Blocked","in-progress":"In progress"},A6={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 i5({id:$,label:J,status:Q,badge:q,badgeVariant:W="neutral",children:Y}){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":$,"data-md":"item","data-md-label":J,...Q?{"data-md-status":Q}:{},...q?{"data-md-badge":q}:{},children:S$("div",{className:"flex items-start gap-3",children:[Q&&S$("span",{className:`w-2 h-2 rounded-full mt-[7px] flex-shrink-0 ${F6[Q]}`},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:J},void 0,!1,void 0,this),Q&&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:S6[Q]},void 0,!1,void 0,this),q&&S$("span",{className:`font-body text-tiny font-medium px-1.5 py-px rounded-full ${A6[W]}`,children:q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Y&&S$("div",{className:"text-body text-text-secondary mt-1 leading-relaxed",children:V$(Y)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function b6($){return S$(i5,{...$},void 0,!1,void 0,this)}import{useAnnotations as o5,useResponseRegistration as n5}from"#canvas/runtime";import{useRef as f6,useState as a5}from"react";import{jsxDEV as g}from"react/jsx-dev-runtime";function v6({id:$,label:J,placeholder:Q,multiline:q,required:W}){let{responses:Y,setResponse:X}=o5();n5($);let G=Y.get($),H=G?.value??"",B=G?.note||"",[_,w]=a5(!1),L=f6(null);if(!Y.has($))X($,{id:$,type:"text",label:J,value:"",required:W});let F=(O)=>{X($,{...G,value:O})},U=(O)=>v$(O,q?60:32),K=G?.required&&!H.trim();return g("div",{"data-md":"userinput","data-md-label":J,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[g("div",{className:"flex items-baseline gap-2 mb-2",children:[g("span",{className:"text-[13px] font-body font-medium text-text-primary",children:J},void 0,!1,void 0,this),W&&g("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),g("textarea",{ref:L,value:H,onChange:(O)=>{F(O.currentTarget.value),U(O.currentTarget)},placeholder:Q||"Type your response...",rows:q?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:(O)=>U(O.currentTarget),onFocus:(O)=>U(O.currentTarget)},void 0,!1,void 0,this),g(M0,{show:_,note:B,onToggle:()=>w(!_),onChange:(O)=>X($,{...G,note:O})},void 0,!1,void 0,this),K&&g("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 R6({id:$,label:J,min:Q=1,max:q=10,step:W=1,required:Y,minLabel:X,maxLabel:G}){let{responses:H,setResponse:B}=o5();n5($);let _=H.get($),w=_?.value,L=_?.note||"",[F,U]=a5(!1);if(!H.has($))B($,{id:$,type:"range",label:J,value:null,required:Y});let K=(x)=>{B($,{..._,value:x})},O=w!==null&&w!==void 0,R=O?w:Math.round((Q+q)/2),I=(R-Q)/(q-Q)*100,y=Math.round((q-Q)/W),l=y<=20,Z=_?.required&&!O;return g("div",{"data-md":"rangeinput","data-md-label":J,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[g("div",{className:"flex items-baseline justify-between mb-1",children:[g("div",{className:"flex items-baseline gap-2",children:[g("span",{className:"text-[13px] font-body font-medium text-text-primary",children:J},void 0,!1,void 0,this),Y&&g("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),g("span",{className:"flex items-center gap-1.5",children:[g("span",{className:`text-[13px] font-mono ${O?"text-accent-amber":"text-text-disabled"}`,children:O?w:"—"},void 0,!1,void 0,this),O&&g("button",{onClick:()=>B($,{..._,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),g("div",{className:"relative h-6 flex items-center",children:[g("div",{className:"absolute left-0 right-0 h-1.5 rounded-full bg-border-medium",children:O&&g("div",{className:"h-full rounded-full bg-accent-amber transition-all duration-150",style:{width:`${I}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this),l&&Array.from({length:y+1},(x,e)=>{let J$=Q+e*W,Q$=(J$-Q)/(q-Q)*100,u=O&&J$<=w;return g("div",{className:`absolute rounded-full pointer-events-none transition-all duration-150 ${O&&J$===w?"w-2.5 h-2.5 bg-accent-amber":u?"w-1.5 h-1.5 bg-accent-amber":"w-1.5 h-1.5 bg-border-hover"}`,style:{left:`${Q$}%`,transform:"translate(-50%, -50%)",top:"50%"}},e,!1,void 0,this)}),O?g("div",{className:"absolute h-5 w-5 rounded-full bg-accent-amber shadow-md pointer-events-none transition-all duration-150",style:{left:`calc(${I}% - 10px)`,borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this):g("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),g("input",{type:"range",min:Q,max:q,step:W,value:R,onChange:(x)=>K(Number(x.currentTarget.value)),className:"absolute inset-0 w-full opacity-0 cursor-pointer"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l&&y<=10?g("div",{className:"flex justify-between -mt-0.5 px-0",children:Array.from({length:y+1},(x,e)=>{let J$=Q+e*W;return g("span",{className:`text-[10px] font-mono transition-colors ${O&&J$===w?"text-accent-amber font-medium":"text-text-disabled"}`,style:{minWidth:"1ch",textAlign:"center"},children:J$},e,!1,void 0,this)})},void 0,!1,void 0,this):g("div",{className:"flex justify-between -mt-0.5",children:[g("span",{className:"text-[11px] text-text-tertiary font-body",children:X||Q},void 0,!1,void 0,this),g("span",{className:"text-[11px] text-text-tertiary font-body",children:G||q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),g(M0,{show:F,note:L,onToggle:()=>U(!F),onChange:(x)=>B($,{..._,note:x})},void 0,!1,void 0,this),Z&&g("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)}export{KQ as useFeedback,v6 as UserInput,b6 as Task,L6 as Table,O6 as Section,R6 as RangeInput,z6 as Priority,M6 as Note,x3 as MultiChoice,B6 as Mermaid,q6 as Markdown,i5 as Item,Q6 as ImageView,t3 as FilePreview,d3 as Diff,c3 as CodeBlock,Z3 as Choice,n2 as Checklist,o2 as Callout};
53
+ `+t+`</thead>
54
+ `+s+`</table>
55
+ `}tablerow({text:e}){return`<tr>
56
+ ${e}</tr>
57
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
58
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${fe(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let s=this.parser.parseInline(n),r=qn(e);if(r===null)return s;e=r;let o='<a href="'+e+'"';return t&&(o+=' title="'+fe(t)+'"'),o+=">"+s+"</a>",o}image({href:e,title:t,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let r=qn(e);if(r===null)return fe(n);e=r;let o=`<img src="${e}" alt="${fe(n)}"`;return t&&(o+=` title="${fe(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):("escaped"in e)&&e.escaped?e.text:fe(e.text)}},mn=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},le=class e{options;renderer;textRenderer;constructor(t){this.options=t||ze,this.options.renderer=this.options.renderer||new Nt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new mn}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(t){this.renderer.parser=this;let n="";for(let s=0;s<t.length;s++){let r=t[s];if(this.options.extensions?.renderers?.[r.type]){let a=r,l=this.options.extensions.renderers[a.type].call({parser:this},a);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(a.type)){n+=l||"";continue}}let o=r;switch(o.type){case"space":{n+=this.renderer.space(o);break}case"hr":{n+=this.renderer.hr(o);break}case"heading":{n+=this.renderer.heading(o);break}case"code":{n+=this.renderer.code(o);break}case"table":{n+=this.renderer.table(o);break}case"blockquote":{n+=this.renderer.blockquote(o);break}case"list":{n+=this.renderer.list(o);break}case"checkbox":{n+=this.renderer.checkbox(o);break}case"html":{n+=this.renderer.html(o);break}case"def":{n+=this.renderer.def(o);break}case"paragraph":{n+=this.renderer.paragraph(o);break}case"text":{n+=this.renderer.text(o);break}default:{let a='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw Error(a)}}}return n}parseInline(t,n=this.renderer){this.renderer.parser=this;let s="";for(let r=0;r<t.length;r++){let o=t[r];if(this.options.extensions?.renderers?.[o.type]){let l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){s+=l||"";continue}}let a=o;switch(a.type){case"escape":{s+=n.text(a);break}case"html":{s+=n.html(a);break}case"link":{s+=n.link(a);break}case"image":{s+=n.image(a);break}case"checkbox":{s+=n.checkbox(a);break}case"strong":{s+=n.strong(a);break}case"em":{s+=n.em(a);break}case"codespan":{s+=n.codespan(a);break}case"br":{s+=n.br(a);break}case"del":{s+=n.del(a);break}case"text":{s+=n.text(a);break}default:{let l='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw Error(l)}}}return s}},st=class{options;block;constructor(e){this.options=e||ze}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?ie.lex:ie.lexInline}provideParser(e=this.block){return e?le.parse:le.parseInline}},Ds=class{defaults=an();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=le;Renderer=Nt;TextRenderer=mn;Lexer=ie;Tokenizer=Ct;Hooks=st;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let s of e)switch(n=n.concat(t.call(this,s)),s.type){case"table":{let r=s;for(let o of r.header)n=n.concat(this.walkTokens(o.tokens,t));for(let o of r.rows)for(let a of o)n=n.concat(this.walkTokens(a.tokens,t));break}case"list":{let r=s;n=n.concat(this.walkTokens(r.items,t));break}default:{let r=s;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach((o)=>{let a=r[o].flat(1/0);n=n.concat(this.walkTokens(a,t))}):r.tokens&&(n=n.concat(this.walkTokens(r.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((n)=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach((r)=>{if(!r.name)throw Error("extension name required");if("renderer"in r){let o=t.renderers[r.name];o?t.renderers[r.name]=function(...a){let l=r.renderer.apply(this,a);return l===!1&&(l=o.apply(this,a)),l}:t.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw Error("extension level must be 'block' or 'inline'");let o=t[r.level];o?o.unshift(r.tokenizer):t[r.level]=[r.tokenizer],r.start&&(r.level==="block"?t.startBlock?t.startBlock.push(r.start):t.startBlock=[r.start]:r.level==="inline"&&(t.startInline?t.startInline.push(r.start):t.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(t.childTokens[r.name]=r.childTokens)}),s.extensions=t),n.renderer){let r=this.defaults.renderer||new Nt(this.defaults);for(let o in n.renderer){if(!(o in r))throw Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let a=o,l=n.renderer[a],i=r[a];r[a]=(...c)=>{let u=l.apply(r,c);return u===!1&&(u=i.apply(r,c)),u||""}}s.renderer=r}if(n.tokenizer){let r=this.defaults.tokenizer||new Ct(this.defaults);for(let o in n.tokenizer){if(!(o in r))throw Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let a=o,l=n.tokenizer[a],i=r[a];r[a]=(...c)=>{let u=l.apply(r,c);return u===!1&&(u=i.apply(r,c)),u}}s.tokenizer=r}if(n.hooks){let r=this.defaults.hooks||new st;for(let o in n.hooks){if(!(o in r))throw Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let a=o,l=n.hooks[a],i=r[a];st.passThroughHooks.has(o)?r[a]=(c)=>{if(this.defaults.async&&st.passThroughHooksRespectAsync.has(o))return(async()=>{let f=await l.call(r,c);return i.call(r,f)})();let u=l.call(r,c);return i.call(r,u)}:r[a]=(...c)=>{if(this.defaults.async)return(async()=>{let f=await l.apply(r,c);return f===!1&&(f=await i.apply(r,c)),f})();let u=l.apply(r,c);return u===!1&&(u=i.apply(r,c)),u}}s.hooks=r}if(n.walkTokens){let r=this.defaults.walkTokens,o=n.walkTokens;s.walkTokens=function(a){let l=[];return l.push(o.call(this,a)),r&&(l=l.concat(r.call(this,a))),l}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ie.lex(e,t??this.defaults)}parser(e,t){return le.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let s={...n},r={...this.defaults,...s},o=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&s.async===!1)return o(Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return o(Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=e),r.async)return(async()=>{let a=r.hooks?await r.hooks.preprocess(t):t,l=await(r.hooks?await r.hooks.provideLexer(e):e?ie.lex:ie.lexInline)(a,r),i=r.hooks?await r.hooks.processAllTokens(l):l;r.walkTokens&&await Promise.all(this.walkTokens(i,r.walkTokens));let c=await(r.hooks?await r.hooks.provideParser(e):e?le.parse:le.parseInline)(i,r);return r.hooks?await r.hooks.postprocess(c):c})().catch(o);try{r.hooks&&(t=r.hooks.preprocess(t));let a=(r.hooks?r.hooks.provideLexer(e):e?ie.lex:ie.lexInline)(t,r);r.hooks&&(a=r.hooks.processAllTokens(a)),r.walkTokens&&this.walkTokens(a,r.walkTokens);let l=(r.hooks?r.hooks.provideParser(e):e?le.parse:le.parseInline)(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return o(a)}}}onError(e,t){return(n)=>{if(n.message+=`
59
+ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error occurred:</p><pre>"+fe(n.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}},Oe=new Ds;function N(e,t){return Oe.parse(e,t)}N.options=N.setOptions=function(e){return Oe.setOptions(e),N.defaults=Oe.defaults,Un(N.defaults),N};N.getDefaults=an;N.defaults=ze;N.use=function(...e){return Oe.use(...e),N.defaults=Oe.defaults,Un(N.defaults),N};N.walkTokens=function(e,t){return Oe.walkTokens(e,t)};N.parseInline=Oe.parseInline;N.Parser=le;N.parser=le.parse;N.Renderer=Nt;N.TextRenderer=mn;N.Lexer=ie;N.lexer=ie.lex;N.Tokenizer=Ct;N.Hooks=st;N.parse=N;var{options:Ba,setOptions:Va,use:qa,walkTokens:Fa,parseInline:Wa}=N;var Ua=le.parse,Ga=ie.lex;import nr from"react";import{jsxDEV as gn}from"react/jsx-dev-runtime";N.setOptions({gfm:!0,breaks:!1});var js=new Set(["a","abbr","b","br","code","del","em","i","kbd","mark","q","s","small","span","strong","sub","sup","time","u"]),Bs=new Set(["Priority"]);function Vs(e){if(typeof e==="string"||typeof e==="number")return!0;if(!nr.isValidElement(e))return!1;if(typeof e!=="object"||e===null||!("type"in e))return!1;let t=e.type;if(typeof t==="string")return js.has(t);if(typeof t==="function"){let n="displayName"in t&&typeof t.displayName==="string"?t.displayName:t.name;return n?Bs.has(n):!1}return!1}function qs(e,t){let n=e.trim();if(!n)return null;let s=N.parse(n,{async:!1});return gn("div",{className:"prose-canvas","data-md":"markdown","data-md-source":n,dangerouslySetInnerHTML:{__html:s}},t,!1,void 0,this)}function Fs(e,t){return gn("div",{className:"prose-canvas",children:e.map((n,s)=>{if(typeof n==="string"||typeof n==="number"){let r=N.parseInline(String(n),{async:!1});return gn("span",{dangerouslySetInnerHTML:{__html:r}},s,!1,void 0,this)}return n})},t,!1,void 0,this)}function Re(e){let t=nr.Children.toArray(e);if(t.length===0)return null;let n=[],s=[],r=0,o=()=>{if(s.length===0)return;if(s.some((l)=>typeof l!=="string"&&typeof l!=="number"))n.push(Fs(s,`md-${r++}`));else{let l=qs(s.join(""),`md-${r++}`);if(l)n.push(l)}s=[]};for(let a of t)if(Vs(a))s.push(a);else o(),n.push(a);return o(),n}import{jsxDEV as xn}from"react/jsx-dev-runtime";var Ws={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 Us({type:e="info",children:t}){let n=Ws[e];return xn("div",{className:`${n.bg} relative rounded-lg px-5 py-4 mt-3 flex gap-3 items-start`,"data-md":"callout","data-md-type":e,children:[xn("span",{"aria-hidden":"true",className:`${n.iconColor} opacity-70 text-base leading-relaxed flex-shrink-0 mt-px`,children:n.icon},void 0,!1,void 0,this),xn("div",{className:"text-body text-text-secondary leading-relaxed",children:Re(t)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as Fe}from"react/jsx-dev-runtime";function Gs({items:e}){return Fe("ul",{className:"space-y-1 mt-3","data-md":"checklist",children:e.map((t,n)=>Fe("li",{"data-md":"checklist-item","data-md-label":t.label,className:"relative flex items-start gap-2.5 py-1",children:[Fe("span",{className:`w-4 h-4 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5 transition-all ${t.checked?"bg-accent-green":"border-[1.5px] border-border-hover"}`,children:t.checked&&Fe("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:Fe("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),Fe("span",{className:`text-body font-body ${t.checked?"text-text-tertiary line-through decoration-border-hover":"text-text-secondary"}`,children:t.label},void 0,!1,void 0,this)]},n,!0,void 0,this))},void 0,!1,void 0,this)}import{useAnnotations as Mr,useResponseRegistration as Lr}from"#canvas/runtime";import{useEffect as $r,useMemo as Pr,useRef as Or,useState as zr}from"react";import{AnnotationCtx as tu,AnnotationHostContext as nu,SessionContext as ru,useAnnotationHost as su,useAnnotations as ou}from"@fabrika/annotations/runtime";function bn(e,t){let n=[],s=Ks(e);for(let r of s){let o=document.createRange();if(o.selectNodeContents(r),r===e.startContainer)o.setStart(r,e.startOffset);if(r===e.endContainer)o.setEnd(r,e.endOffset);let a=o.toString();if(!a||!a.trim())continue;let l=document.createElement("mark");l.setAttribute("data-annotation-id",t);try{o.surroundContents(l)}catch{let i=o.extractContents();l.appendChild(i),o.insertNode(l)}n.push(l)}return n}function yn(e){let t=e.parentElement;if(t?.classList.contains("select-none"))return!1;if(t?.closest("[data-annotation-id]"))return!1;return!0}function Ks(e){let t=[],n=e.commonAncestorContainer;if(n.nodeType===Node.TEXT_NODE)return t.push(n),t;let s=document.createTreeWalker(n,NodeFilter.SHOW_TEXT),r;while(r=s.nextNode()){if(!yn(r))continue;if(e.intersectsNode(r))t.push(r)}return t}function vn(e,t){for(let n of t){if(e.querySelector(`[data-annotation-id="${n.id}"]`))continue;let s=n.snippet;if(!s)continue;let{fullText:r,textNodes:o}=Xs(e),a=[],l=0;while(!0){let p=r.indexOf(s,l);if(p===-1)break;a.push(p),l=p+1}let[i]=a;if(i===void 0)continue;let c=i;if(a.length>1&&n.context){let p=-1;for(let h of a){let g=0;if(n.context.before){let T=r.slice(Math.max(0,h-80),h);if(T.includes(n.context.before))g+=2;else if(n.context.before.length>10&&T.includes(n.context.before.slice(-10)))g+=1}if(n.context.after){let T=r.slice(h+s.length,h+s.length+80);if(T.includes(n.context.after))g+=2;else if(n.context.after.length>10&&T.includes(n.context.after.slice(0,10)))g+=1}if(g>p)p=g,c=h}}let u=c,f=c+s.length,b=rr(o,u),y=rr(o,f);if(!b||!y)continue;try{let p=document.createRange();p.setStart(b.node,b.offset),p.setEnd(y.node,y.offset),bn(p,n.id)}catch{}}}function Xs(e){let t=[],n="",s=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r;while(r=s.nextNode()){if(!yn(r))continue;t.push({node:r,start:n.length}),n+=r.textContent||""}return{fullText:n,textNodes:t}}function rr(e,t){for(let n=e.length-1;n>=0;n--){let s=e[n];if(!s||s.start>t)continue;let r=t-s.start,o=s.node.textContent?.length??0;if(r<=o)return{node:s.node,offset:r}}return null}function at(e){return{kind:e.kind,owns:(t)=>e.parse(t)!==null,find:(t,n)=>{let s=e.parse(t);return s===null?null:e.find(s,n)},restore:(t,n)=>{let s=e.parse(n.snippet);if(s===null)return;e.restore?.(s,t,n)},describe:(t)=>{let n=e.parse(t);if(n===null||!e.describe)return null;return e.describe(n)}}}function sr(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n="";for(let s=t.nextNode();s;s=t.nextNode()){let r=s.parentElement?.closest("[aria-hidden='true']");if(r&&e.contains(r))continue;n+=s.textContent??""}return n.trim()}function Lt(e,t,n){return{selector:e,snippet:(s)=>{let r=s.getAttribute(n);return r?`${t} ${r}`:null}}}var kn=[Lt("[data-md='item']","[Item]","data-md-label"),Lt("[data-md='section']","[Section]","data-md-title"),Lt("[data-md='checklist-item']","[Checklist]","data-md-label"),Lt("[data-md='image']","[Image]","data-md-src"),{selector:"[data-md='callout']",snippet:(e)=>`[Callout:${e.getAttribute("data-md-type")||"info"}] ${sr(e).slice(0,60)||"Callout"}`},{selector:"[data-md='note']",snippet:(e)=>`[Note] ${sr(e).slice(0,60)||"Note"}`},{selector:"[data-md='table'] tbody tr",snippet:(e)=>{let t=Array.from(e.querySelectorAll("td")).map((n)=>n.textContent?.trim()).filter(Boolean);return t.length?`[Row] ${t.join(" | ")}`:null}}],Ys=["[data-md='choice-option']","[data-md='multichoice-option']","[data-md='userinput']","[data-md='rangeinput']"],_n=kn.map((e)=>e.selector).join(", "),or=[...kn.map((e)=>e.selector),...Ys].join(", ");function wn(e){for(let t of kn)if(e.matches(t.selector))return t.snippet(e);return null}var Tn={kind:"block",parse:(e)=>e.startsWith("[")?{snippet:e}:null,format:(e)=>e.snippet,find:(e,t)=>{for(let n of t.querySelectorAll(_n)){if(!(n instanceof HTMLElement))continue;if(wn(n)===e.snippet)return n}return null}};var Qs=/^\[Region:(rect|ellipse)\] ([\s\S]+) @(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*)$/;function Js(e){if(e==="rect")return"rect";if(e==="ellipse")return"ellipse";return null}function $t(e){if(e===void 0)return null;let t=Number(e);if(!Number.isInteger(t)||t<0||t>1e4)return null;return t}function ar(e){return{left:`${e.x/100}%`,top:`${e.y/100}%`,width:`${e.w/100}%`,height:`${e.h/100}%`}}function Pt(e){return`${(e/100).toFixed(1).replace(/\.0$/,"")}%`}function Sn(e){let t=`${Pt(e.x)}-${Pt(e.x+e.w)}`,n=`${Pt(e.y)}-${Pt(e.y+e.h)}`;return`[Region] ${e.src} — ${e.shape} x ${t}, y ${n} of the image`}function An(e,t){for(let n of t.querySelectorAll("[data-md='image']")){if(!(n instanceof HTMLElement))continue;if(n.getAttribute("data-md-src")!==e)continue;let s=n.querySelector("[data-annotation-image]");if(s instanceof HTMLElement)return s}return null}function ir(e,t){let n=ar(t);e.style.left=n.left,e.style.top=n.top,e.style.width=n.width,e.style.height=n.height}function Rn(e,t,n){let s=document.createElement("div");return s.className="ann-region",s.setAttribute("data-annotation-id",n),s.setAttribute("data-annotation-region",t),ir(s,e),s}var Ot={kind:"region",parse:(e)=>{let t=Qs.exec(e);if(!t)return null;let n=Js(t[1]),s=t[2],r=$t(t[3]),o=$t(t[4]),a=$t(t[5]),l=$t(t[6]);if(n===null||s===void 0)return null;if(r===null||o===null||a===null||l===null)return null;if(a<1||l<1)return null;return{src:s,shape:n,x:r,y:o,w:a,h:l}},format:(e)=>`[Region:${e.shape}] ${e.src} @${e.x},${e.y},${e.w},${e.h}`,find:(e,t)=>An(e.src,t),restore:(e,t,n)=>{if(t.querySelector(`[data-annotation-id="${n.id}"]`))return;let s=An(e.src,t);if(!s)return;s.appendChild(Rn(e,e.shape,n.id))},describe:Sn};var En={kind:"text",parse:(e)=>e?{text:e}:null,format:(e)=>e.text,find:()=>null,restore:(e,t,n)=>{vn(t,[n])}};var Zs=[at(Ot),at(Tn),at(En)];import{AnnotationCtx as Sl,SessionContext as Rl,useAnnotationHost as El}from"@fabrika/annotations/runtime";import{useEffect as Il,useRef as Ml,useState as Ll}from"react";var C;(function(e){e.assertEqual=(r)=>{};function t(r){}e.assertIs=t;function n(r){throw Error()}e.assertNever=n,e.arrayToEnum=(r)=>{let o={};for(let a of r)o[a]=a;return o},e.getValidEnumValues=(r)=>{let o=e.objectKeys(r).filter((l)=>typeof r[r[l]]!=="number"),a={};for(let l of o)a[l]=r[l];return e.objectValues(a)},e.objectValues=(r)=>e.objectKeys(r).map(function(o){return r[o]}),e.objectKeys=typeof Object.keys==="function"?(r)=>Object.keys(r):(r)=>{let o=[];for(let a in r)if(Object.prototype.hasOwnProperty.call(r,a))o.push(a);return o},e.find=(r,o)=>{for(let a of r)if(o(a))return a;return},e.isInteger=typeof Number.isInteger==="function"?(r)=>Number.isInteger(r):(r)=>typeof r==="number"&&Number.isFinite(r)&&Math.floor(r)===r;function s(r,o=" | "){return r.map((a)=>typeof a==="string"?`'${a}'`:a).join(o)}e.joinValues=s,e.jsonStringifyReplacer=(r,o)=>{if(typeof o==="bigint")return o.toString();return o}})(C||(C={}));var lr;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(lr||(lr={}));var x=C.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ye=(e)=>{switch(typeof e){case"undefined":return x.undefined;case"string":return x.string;case"number":return Number.isNaN(e)?x.nan:x.number;case"boolean":return x.boolean;case"function":return x.function;case"bigint":return x.bigint;case"symbol":return x.symbol;case"object":if(Array.isArray(e))return x.array;if(e===null)return x.null;if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function")return x.promise;if(typeof Map<"u"&&e instanceof Map)return x.map;if(typeof Set<"u"&&e instanceof Set)return x.set;if(typeof Date<"u"&&e instanceof Date)return x.date;return x.object;default:return x.unknown}};var d=C.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class ne extends Error{get errors(){return this.issues}constructor(e){super();this.issues=[],this.addIssue=(n)=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let t=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,t);else this.__proto__=t;this.name="ZodError",this.issues=e}format(e){let t=e||function(r){return r.message},n={_errors:[]},s=(r)=>{for(let o of r.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)n._errors.push(t(o));else{let a=n,l=0;while(l<o.path.length){let i=o.path[l];if(l!==o.path.length-1)a[i]=a[i]||{_errors:[]};else a[i]=a[i]||{_errors:[]},a[i]._errors.push(t(o));a=a[i],l++}}};return s(this),n}static assert(e){if(!(e instanceof ne))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,C.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=(t)=>t.message){let t={},n=[];for(let s of this.issues)if(s.path.length>0){let r=s.path[0];t[r]=t[r]||[],t[r].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}ne.create=(e)=>new ne(e);var eo=(e,t)=>{let n;switch(e.code){case d.invalid_type:if(e.received===x.undefined)n="Required";else n=`Expected ${e.expected}, received ${e.received}`;break;case d.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,C.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:n=`Unrecognized key(s) in object: ${C.joinValues(e.keys,", ")}`;break;case d.invalid_union:n="Invalid input";break;case d.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${C.joinValues(e.options)}`;break;case d.invalid_enum_value:n=`Invalid enum value. Expected ${C.joinValues(e.options)}, received '${e.received}'`;break;case d.invalid_arguments:n="Invalid function arguments";break;case d.invalid_return_type:n="Invalid function return type";break;case d.invalid_date:n="Invalid date";break;case d.invalid_string:if(typeof e.validation==="object")if("includes"in e.validation){if(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==="number")n=`${n} at one or more positions greater than or equal to ${e.validation.position}`}else if("startsWith"in e.validation)n=`Invalid input: must start with "${e.validation.startsWith}"`;else if("endsWith"in e.validation)n=`Invalid input: must end with "${e.validation.endsWith}"`;else C.assertNever(e.validation);else if(e.validation!=="regex")n=`Invalid ${e.validation}`;else n="Invalid";break;case d.too_small:if(e.type==="array")n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`;else if(e.type==="string")n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`;else if(e.type==="number")n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`;else if(e.type==="bigint")n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`;else if(e.type==="date")n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`;else n="Invalid input";break;case d.too_big:if(e.type==="array")n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`;else if(e.type==="string")n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`;else if(e.type==="number")n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`;else if(e.type==="bigint")n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`;else if(e.type==="date")n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`;else n="Invalid input";break;case d.custom:n="Invalid input";break;case d.invalid_intersection_types:n="Intersection results could not be merged";break;case d.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case d.not_finite:n="Number must be finite";break;default:n=t.defaultError,C.assertNever(e)}return{message:n}},Ee=eo;var to=Ee;function it(){return to}var zt=(e)=>{let{data:t,path:n,errorMaps:s,issueData:r}=e,o=[...n,...r.path||[]],a={...r,path:o};if(r.message!==void 0)return{...r,path:o,message:r.message};let l="",i=s.filter((c)=>!!c).slice().reverse();for(let c of i)l=c(a,{data:t,defaultError:l}).message;return{...r,path:o,message:l}};function m(e,t){let n=it(),s=zt({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Ee?void 0:Ee].filter((r)=>!!r)});e.common.issues.push(s)}class X{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(e,t){let n=[];for(let s of t){if(s.status==="aborted")return _;if(s.status==="dirty")e.dirty();n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let s of t){let r=await s.key,o=await s.value;n.push({key:r,value:o})}return X.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let s of t){let{key:r,value:o}=s;if(r.status==="aborted")return _;if(o.status==="aborted")return _;if(r.status==="dirty")e.dirty();if(o.status==="dirty")e.dirty();if(r.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet))n[r.value]=o.value}return{status:e.value,value:n}}}var _=Object.freeze({status:"aborted"}),We=(e)=>({status:"dirty",value:e}),Z=(e)=>({status:"valid",value:e}),Cn=(e)=>e.status==="aborted",Nn=(e)=>e.status==="dirty",He=(e)=>e.status==="valid",lt=(e)=>typeof Promise<"u"&&e instanceof Promise;var k;(function(e){e.errToObj=(t)=>typeof t==="string"?{message:t}:t||{},e.toString=(t)=>typeof t==="string"?t:t?.message})(k||(k={}));class ce{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var cr=(e,t)=>{if(He(t))return{success:!0,data:t.value};else{if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new ne(e.common.issues);return this._error=n,this._error}}}};function A(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:s,description:r}=e;if(t&&(n||s))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(t)return{errorMap:t,description:r};return{errorMap:(a,l)=>{let{message:i}=e;if(a.code==="invalid_enum_value")return{message:i??l.defaultError};if(typeof l.data>"u")return{message:i??s??l.defaultError};if(a.code!=="invalid_type")return{message:l.defaultError};return{message:i??n??l.defaultError}},description:r}}class E{get description(){return this._def.description}_getType(e){return ye(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ye(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new X,ctx:{common:e.parent.common,data:e.data,parsedType:ye(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(lt(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ye(e)},s=this._parseSync({data:e,path:n.path,parent:n});return cr(n,s)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ye(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:t});return He(n)?{value:n.value}:{issues:t.common.issues}}catch(n){if(n?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then((n)=>He(n)?{value:n.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ye(e)},s=this._parse({data:e,path:n.path,parent:n}),r=await(lt(s)?s:Promise.resolve(s));return cr(n,r)}refine(e,t){let n=(s)=>{if(typeof t==="string"||typeof t>"u")return{message:t};else if(typeof t==="function")return t(s);else return t};return this._refinement((s,r)=>{let o=e(s),a=()=>r.addIssue({code:d.custom,...n(s)});if(typeof Promise<"u"&&o instanceof Promise)return o.then((l)=>{if(!l)return a(),!1;else return!0});if(!o)return a(),!1;else return!0})}refinement(e,t){return this._refinement((n,s)=>{if(!e(n))return s.addIssue(typeof t==="function"?t(n,s):t),!1;else return!0})}_refinement(e){return new ge({schema:this,typeName:w.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(t)=>this["~validate"](t)}}optional(){return me.create(this,this._def)}nullable(){return Ce.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return he.create(this)}promise(){return Ye.create(this,this._def)}or(e){return ft.create([this,e],this._def)}and(e){return ht.create(this,e,this._def)}transform(e){return new ge({...A(this._def),schema:this,typeName:w.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e==="function"?e:()=>e;return new bt({...A(this._def),innerType:this,defaultValue:t,typeName:w.ZodDefault})}brand(){return new $n({typeName:w.ZodBranded,type:this,...A(this._def)})}catch(e){let t=typeof e==="function"?e:()=>e;return new yt({...A(this._def),innerType:this,catchValue:t,typeName:w.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return Wt.create(this,e)}readonly(){return vt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var no=/^c[^\s-]{8,}$/i,ro=/^[0-9a-z]+$/,so=/^[0-9A-HJKMNP-TV-Z]{26}$/i,oo=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,ao=/^[a-z0-9_-]{21}$/i,io=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,lo=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,co=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,uo="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",In,po=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,fo=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ho=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,mo=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,go=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,xo=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ur="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",bo=new RegExp(`^${ur}$`);function dr(e){let t="[0-5]\\d";if(e.precision)t=`${t}\\.\\d{${e.precision}}`;else if(e.precision==null)t=`${t}(\\.\\d+)?`;let n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function yo(e){return new RegExp(`^${dr(e)}$`)}function vo(e){let t=`${ur}T${dr(e)}`,n=[];if(n.push(e.local?"Z?":"Z"),e.offset)n.push("([+-]\\d{2}:?\\d{2})");return t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function ko(e,t){if((t==="v4"||!t)&&po.test(e))return!0;if((t==="v6"||!t)&&ho.test(e))return!0;return!1}function _o(e,t){if(!io.test(e))return!1;try{let[n]=e.split(".");if(!n)return!1;let s=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(s));if(typeof r!=="object"||r===null)return!1;if("typ"in r&&r?.typ!=="JWT")return!1;if(!r.alg)return!1;if(t&&r.alg!==t)return!1;return!0}catch{return!1}}function wo(e,t){if((t==="v4"||!t)&&fo.test(e))return!0;if((t==="v6"||!t)&&mo.test(e))return!0;return!1}class ke extends E{_parse(e){if(this._def.coerce)e.data=String(e.data);if(this._getType(e)!==x.string){let r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:x.string,received:r.parsedType}),_}let n=new X,s=void 0;for(let r of this._def.checks)if(r.kind==="min"){if(e.data.length<r.value)s=this._getOrReturnCtx(e,s),m(s,{code:d.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),n.dirty()}else if(r.kind==="max"){if(e.data.length>r.value)s=this._getOrReturnCtx(e,s),m(s,{code:d.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),n.dirty()}else if(r.kind==="length"){let o=e.data.length>r.value,a=e.data.length<r.value;if(o||a){if(s=this._getOrReturnCtx(e,s),o)m(s,{code:d.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message});else if(a)m(s,{code:d.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message});n.dirty()}}else if(r.kind==="email"){if(!co.test(e.data))s=this._getOrReturnCtx(e,s),m(s,{validation:"email",code:d.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="emoji"){if(!In)In=new RegExp(uo,"u");if(!In.test(e.data))s=this._getOrReturnCtx(e,s),m(s,{validation:"emoji",code:d.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="uuid"){if(!oo.test(e.data))s=this._getOrReturnCtx(e,s),m(s,{validation:"uuid",code:d.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="nanoid"){if(!ao.test(e.data))s=this._getOrReturnCtx(e,s),m(s,{validation:"nanoid",code:d.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="cuid"){if(!no.test(e.data))s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid",code:d.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="cuid2"){if(!ro.test(e.data))s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid2",code:d.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="ulid"){if(!so.test(e.data))s=this._getOrReturnCtx(e,s),m(s,{validation:"ulid",code:d.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),m(s,{validation:"url",code:d.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="regex"){if(r.regex.lastIndex=0,!r.regex.test(e.data))s=this._getOrReturnCtx(e,s),m(s,{validation:"regex",code:d.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="trim")e.data=e.data.trim();else if(r.kind==="includes"){if(!e.data.includes(r.value,r.position))s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),n.dirty()}else if(r.kind==="toLowerCase")e.data=e.data.toLowerCase();else if(r.kind==="toUpperCase")e.data=e.data.toUpperCase();else if(r.kind==="startsWith"){if(!e.data.startsWith(r.value))s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:{startsWith:r.value},message:r.message}),n.dirty()}else if(r.kind==="endsWith"){if(!e.data.endsWith(r.value))s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:{endsWith:r.value},message:r.message}),n.dirty()}else if(r.kind==="datetime"){if(!vo(r).test(e.data))s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:"datetime",message:r.message}),n.dirty()}else if(r.kind==="date"){if(!bo.test(e.data))s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:"date",message:r.message}),n.dirty()}else if(r.kind==="time"){if(!yo(r).test(e.data))s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:"time",message:r.message}),n.dirty()}else if(r.kind==="duration"){if(!lo.test(e.data))s=this._getOrReturnCtx(e,s),m(s,{validation:"duration",code:d.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="ip"){if(!ko(e.data,r.version))s=this._getOrReturnCtx(e,s),m(s,{validation:"ip",code:d.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="jwt"){if(!_o(e.data,r.alg))s=this._getOrReturnCtx(e,s),m(s,{validation:"jwt",code:d.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="cidr"){if(!wo(e.data,r.version))s=this._getOrReturnCtx(e,s),m(s,{validation:"cidr",code:d.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="base64"){if(!go.test(e.data))s=this._getOrReturnCtx(e,s),m(s,{validation:"base64",code:d.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="base64url"){if(!xo.test(e.data))s=this._getOrReturnCtx(e,s),m(s,{validation:"base64url",code:d.invalid_string,message:r.message}),n.dirty()}else C.assertNever(r);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement((s)=>e.test(s),{validation:t,code:d.invalid_string,...k.errToObj(n)})}_addCheck(e){return new ke({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...k.errToObj(e)})}url(e){return this._addCheck({kind:"url",...k.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...k.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...k.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...k.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...k.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...k.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...k.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...k.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...k.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...k.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...k.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...k.errToObj(e)})}datetime(e){if(typeof e==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e});return this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...k.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){if(typeof e==="string")return this._addCheck({kind:"time",precision:null,message:e});return this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...k.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...k.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...k.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...k.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...k.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...k.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...k.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...k.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...k.errToObj(t)})}nonempty(e){return this.min(1,k.errToObj(e))}trim(){return new ke({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ke({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ke({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e)=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find((e)=>e.kind==="date")}get isTime(){return!!this._def.checks.find((e)=>e.kind==="time")}get isDuration(){return!!this._def.checks.find((e)=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find((e)=>e.kind==="email")}get isURL(){return!!this._def.checks.find((e)=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find((e)=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find((e)=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((e)=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((e)=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((e)=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find((e)=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find((e)=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find((e)=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find((e)=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find((e)=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxLength(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}}ke.create=(e)=>new ke({checks:[],typeName:w.ZodString,coerce:e?.coerce??!1,...A(e)});function To(e,t){let n=(e.toString().split(".")[1]||"").length,s=(t.toString().split(".")[1]||"").length,r=n>s?n:s,o=Number.parseInt(e.toFixed(r).replace(".","")),a=Number.parseInt(t.toFixed(r).replace(".",""));return o%a/10**r}class Ge extends E{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce)e.data=Number(e.data);if(this._getType(e)!==x.number){let r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:x.number,received:r.parsedType}),_}let n=void 0,s=new X;for(let r of this._def.checks)if(r.kind==="int"){if(!C.isInteger(e.data))n=this._getOrReturnCtx(e,n),m(n,{code:d.invalid_type,expected:"integer",received:"float",message:r.message}),s.dirty()}else if(r.kind==="min"){if(r.inclusive?e.data<r.value:e.data<=r.value)n=this._getOrReturnCtx(e,n),m(n,{code:d.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),s.dirty()}else if(r.kind==="max"){if(r.inclusive?e.data>r.value:e.data>=r.value)n=this._getOrReturnCtx(e,n),m(n,{code:d.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),s.dirty()}else if(r.kind==="multipleOf"){if(To(e.data,r.value)!==0)n=this._getOrReturnCtx(e,n),m(n,{code:d.not_multiple_of,multipleOf:r.value,message:r.message}),s.dirty()}else if(r.kind==="finite"){if(!Number.isFinite(e.data))n=this._getOrReturnCtx(e,n),m(n,{code:d.not_finite,message:r.message}),s.dirty()}else C.assertNever(r);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,k.toString(t))}gt(e,t){return this.setLimit("min",e,!1,k.toString(t))}lte(e,t){return this.setLimit("max",e,!0,k.toString(t))}lt(e,t){return this.setLimit("max",e,!1,k.toString(t))}setLimit(e,t,n,s){return new Ge({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:k.toString(s)}]})}_addCheck(e){return new Ge({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:k.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:k.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:k.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:k.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:k.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:k.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxValue(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}get isInt(){return!!this._def.checks.find((e)=>e.kind==="int"||e.kind==="multipleOf"&&C.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;else if(n.kind==="min"){if(t===null||n.value>t)t=n.value}else if(n.kind==="max"){if(e===null||n.value<e)e=n.value}return Number.isFinite(t)&&Number.isFinite(e)}}Ge.create=(e)=>new Ge({checks:[],typeName:w.ZodNumber,coerce:e?.coerce||!1,...A(e)});class Ke extends E{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==x.bigint)return this._getInvalidInput(e);let n=void 0,s=new X;for(let r of this._def.checks)if(r.kind==="min"){if(r.inclusive?e.data<r.value:e.data<=r.value)n=this._getOrReturnCtx(e,n),m(n,{code:d.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),s.dirty()}else if(r.kind==="max"){if(r.inclusive?e.data>r.value:e.data>=r.value)n=this._getOrReturnCtx(e,n),m(n,{code:d.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),s.dirty()}else if(r.kind==="multipleOf"){if(e.data%r.value!==BigInt(0))n=this._getOrReturnCtx(e,n),m(n,{code:d.not_multiple_of,multipleOf:r.value,message:r.message}),s.dirty()}else C.assertNever(r);return{status:s.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return m(t,{code:d.invalid_type,expected:x.bigint,received:t.parsedType}),_}gte(e,t){return this.setLimit("min",e,!0,k.toString(t))}gt(e,t){return this.setLimit("min",e,!1,k.toString(t))}lte(e,t){return this.setLimit("max",e,!0,k.toString(t))}lt(e,t){return this.setLimit("max",e,!1,k.toString(t))}setLimit(e,t,n,s){return new Ke({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:k.toString(s)}]})}_addCheck(e){return new Ke({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:k.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:k.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxValue(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}}Ke.create=(e)=>new Ke({checks:[],typeName:w.ZodBigInt,coerce:e?.coerce??!1,...A(e)});class Ht extends E{_parse(e){if(this._def.coerce)e.data=Boolean(e.data);if(this._getType(e)!==x.boolean){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:x.boolean,received:n.parsedType}),_}return Z(e.data)}}Ht.create=(e)=>new Ht({typeName:w.ZodBoolean,coerce:e?.coerce||!1,...A(e)});class ut extends E{_parse(e){if(this._def.coerce)e.data=new Date(e.data);if(this._getType(e)!==x.date){let r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:x.date,received:r.parsedType}),_}if(Number.isNaN(e.data.getTime())){let r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_date}),_}let n=new X,s=void 0;for(let r of this._def.checks)if(r.kind==="min"){if(e.data.getTime()<r.value)s=this._getOrReturnCtx(e,s),m(s,{code:d.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),n.dirty()}else if(r.kind==="max"){if(e.data.getTime()>r.value)s=this._getOrReturnCtx(e,s),m(s,{code:d.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),n.dirty()}else C.assertNever(r);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ut({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:k.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:k.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e!=null?new Date(e):null}}ut.create=(e)=>new ut({checks:[],coerce:e?.coerce||!1,typeName:w.ZodDate,...A(e)});class Dt extends E{_parse(e){if(this._getType(e)!==x.symbol){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:x.symbol,received:n.parsedType}),_}return Z(e.data)}}Dt.create=(e)=>new Dt({typeName:w.ZodSymbol,...A(e)});class dt extends E{_parse(e){if(this._getType(e)!==x.undefined){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:x.undefined,received:n.parsedType}),_}return Z(e.data)}}dt.create=(e)=>new dt({typeName:w.ZodUndefined,...A(e)});class pt extends E{_parse(e){if(this._getType(e)!==x.null){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:x.null,received:n.parsedType}),_}return Z(e.data)}}pt.create=(e)=>new pt({typeName:w.ZodNull,...A(e)});class jt extends E{constructor(){super(...arguments);this._any=!0}_parse(e){return Z(e.data)}}jt.create=(e)=>new jt({typeName:w.ZodAny,...A(e)});class De extends E{constructor(){super(...arguments);this._unknown=!0}_parse(e){return Z(e.data)}}De.create=(e)=>new De({typeName:w.ZodUnknown,...A(e)});class _e extends E{_parse(e){let t=this._getOrReturnCtx(e);return m(t,{code:d.invalid_type,expected:x.never,received:t.parsedType}),_}}_e.create=(e)=>new _e({typeName:w.ZodNever,...A(e)});class Bt extends E{_parse(e){if(this._getType(e)!==x.undefined){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:x.void,received:n.parsedType}),_}return Z(e.data)}}Bt.create=(e)=>new Bt({typeName:w.ZodVoid,...A(e)});class he extends E{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==x.array)return m(t,{code:d.invalid_type,expected:x.array,received:t.parsedType}),_;if(s.exactLength!==null){let o=t.data.length>s.exactLength.value,a=t.data.length<s.exactLength.value;if(o||a)m(t,{code:o?d.too_big:d.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty()}if(s.minLength!==null){if(t.data.length<s.minLength.value)m(t,{code:d.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()}if(s.maxLength!==null){if(t.data.length>s.maxLength.value)m(t,{code:d.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()}if(t.common.async)return Promise.all([...t.data].map((o,a)=>s.type._parseAsync(new ce(t,o,t.path,a)))).then((o)=>X.mergeArray(n,o));let r=[...t.data].map((o,a)=>s.type._parseSync(new ce(t,o,t.path,a)));return X.mergeArray(n,r)}get element(){return this._def.type}min(e,t){return new he({...this._def,minLength:{value:e,message:k.toString(t)}})}max(e,t){return new he({...this._def,maxLength:{value:e,message:k.toString(t)}})}length(e,t){return new he({...this._def,exactLength:{value:e,message:k.toString(t)}})}nonempty(e){return this.min(1,e)}}he.create=(e,t)=>new he({type:e,minLength:null,maxLength:null,exactLength:null,typeName:w.ZodArray,...A(t)});function Ue(e){if(e instanceof D){let t={};for(let n in e.shape){let s=e.shape[n];t[n]=me.create(Ue(s))}return new D({...e._def,shape:()=>t})}else if(e instanceof he)return new he({...e._def,type:Ue(e.element)});else if(e instanceof me)return me.create(Ue(e.unwrap()));else if(e instanceof Ce)return Ce.create(Ue(e.unwrap()));else if(e instanceof we)return we.create(e.items.map((t)=>Ue(t)));else return e}class D extends E{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=C.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==x.object){let i=this._getOrReturnCtx(e);return m(i,{code:d.invalid_type,expected:x.object,received:i.parsedType}),_}let{status:n,ctx:s}=this._processInputParams(e),{shape:r,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof _e&&this._def.unknownKeys==="strip")){for(let i in s.data)if(!o.includes(i))a.push(i)}let l=[];for(let i of o){let c=r[i],u=s.data[i];l.push({key:{status:"valid",value:i},value:c._parse(new ce(s,u,s.path,i)),alwaysSet:i in s.data})}if(this._def.catchall instanceof _e){let i=this._def.unknownKeys;if(i==="passthrough")for(let c of a)l.push({key:{status:"valid",value:c},value:{status:"valid",value:s.data[c]}});else if(i==="strict"){if(a.length>0)m(s,{code:d.unrecognized_keys,keys:a}),n.dirty()}else if(i==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let i=this._def.catchall;for(let c of a){let u=s.data[c];l.push({key:{status:"valid",value:c},value:i._parse(new ce(s,u,s.path,c)),alwaysSet:c in s.data})}}if(s.common.async)return Promise.resolve().then(async()=>{let i=[];for(let c of l){let u=await c.key,f=await c.value;i.push({key:u,value:f,alwaysSet:c.alwaysSet})}return i}).then((i)=>X.mergeObjectSync(n,i));else return X.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return k.errToObj,new D({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{let s=this._def.errorMap?.(t,n).message??n.defaultError;if(t.code==="unrecognized_keys")return{message:k.errToObj(e).message??s};return{message:s}}}:{}})}strip(){return new D({...this._def,unknownKeys:"strip"})}passthrough(){return new D({...this._def,unknownKeys:"passthrough"})}extend(e){return new D({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new D({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:w.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new D({...this._def,catchall:e})}pick(e){let t={};for(let n of C.objectKeys(e))if(e[n]&&this.shape[n])t[n]=this.shape[n];return new D({...this._def,shape:()=>t})}omit(e){let t={};for(let n of C.objectKeys(this.shape))if(!e[n])t[n]=this.shape[n];return new D({...this._def,shape:()=>t})}deepPartial(){return Ue(this)}partial(e){let t={};for(let n of C.objectKeys(this.shape)){let s=this.shape[n];if(e&&!e[n])t[n]=s;else t[n]=s.optional()}return new D({...this._def,shape:()=>t})}required(e){let t={};for(let n of C.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let r=this.shape[n];while(r instanceof me)r=r._def.innerType;t[n]=r}return new D({...this._def,shape:()=>t})}keyof(){return pr(C.objectKeys(this.shape))}}D.create=(e,t)=>new D({shape:()=>e,unknownKeys:"strip",catchall:_e.create(),typeName:w.ZodObject,...A(t)});D.strictCreate=(e,t)=>new D({shape:()=>e,unknownKeys:"strict",catchall:_e.create(),typeName:w.ZodObject,...A(t)});D.lazycreate=(e,t)=>new D({shape:e,unknownKeys:"strip",catchall:_e.create(),typeName:w.ZodObject,...A(t)});class ft extends E{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function s(r){for(let a of r)if(a.result.status==="valid")return a.result;for(let a of r)if(a.result.status==="dirty")return t.common.issues.push(...a.ctx.common.issues),a.result;let o=r.map((a)=>new ne(a.ctx.common.issues));return m(t,{code:d.invalid_union,unionErrors:o}),_}if(t.common.async)return Promise.all(n.map(async(r)=>{let o={...t,common:{...t.common,issues:[]},parent:null};return{result:await r._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(s);else{let r=void 0,o=[];for(let l of n){let i={...t,common:{...t.common,issues:[]},parent:null},c=l._parseSync({data:t.data,path:t.path,parent:i});if(c.status==="valid")return c;else if(c.status==="dirty"&&!r)r={result:c,ctx:i};if(i.common.issues.length)o.push(i.common.issues)}if(r)return t.common.issues.push(...r.ctx.common.issues),r.result;let a=o.map((l)=>new ne(l));return m(t,{code:d.invalid_union,unionErrors:a}),_}}get options(){return this._def.options}}ft.create=(e,t)=>new ft({options:e,typeName:w.ZodUnion,...A(t)});var ve=(e)=>{if(e instanceof mt)return ve(e.schema);else if(e instanceof ge)return ve(e.innerType());else if(e instanceof gt)return[e.value];else if(e instanceof je)return e.options;else if(e instanceof xt)return C.objectValues(e.enum);else if(e instanceof bt)return ve(e._def.innerType);else if(e instanceof dt)return[void 0];else if(e instanceof pt)return[null];else if(e instanceof me)return[void 0,...ve(e.unwrap())];else if(e instanceof Ce)return[null,...ve(e.unwrap())];else if(e instanceof $n)return ve(e.unwrap());else if(e instanceof vt)return ve(e.unwrap());else if(e instanceof yt)return ve(e._def.innerType);else return[]};class Ln extends E{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==x.object)return m(t,{code:d.invalid_type,expected:x.object,received:t.parsedType}),_;let n=this.discriminator,s=t.data[n],r=this.optionsMap.get(s);if(!r)return m(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),_;if(t.common.async)return r._parseAsync({data:t.data,path:t.path,parent:t});else return r._parseSync({data:t.data,path:t.path,parent:t})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let s=new Map;for(let r of t){let o=ve(r.shape[e]);if(!o.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(s.has(a))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,r)}}return new Ln({typeName:w.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...A(n)})}}function Mn(e,t){let n=ye(e),s=ye(t);if(e===t)return{valid:!0,data:e};else if(n===x.object&&s===x.object){let r=C.objectKeys(t),o=C.objectKeys(e).filter((l)=>r.indexOf(l)!==-1),a={...e,...t};for(let l of o){let i=Mn(e[l],t[l]);if(!i.valid)return{valid:!1};a[l]=i.data}return{valid:!0,data:a}}else if(n===x.array&&s===x.array){if(e.length!==t.length)return{valid:!1};let r=[];for(let o=0;o<e.length;o++){let a=e[o],l=t[o],i=Mn(a,l);if(!i.valid)return{valid:!1};r.push(i.data)}return{valid:!0,data:r}}else if(n===x.date&&s===x.date&&+e===+t)return{valid:!0,data:e};else return{valid:!1}}class ht extends E{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=(r,o)=>{if(Cn(r)||Cn(o))return _;let a=Mn(r.value,o.value);if(!a.valid)return m(n,{code:d.invalid_intersection_types}),_;if(Nn(r)||Nn(o))t.dirty();return{status:t.value,value:a.data}};if(n.common.async)return Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([r,o])=>s(r,o));else return s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}ht.create=(e,t,n)=>new ht({left:e,right:t,typeName:w.ZodIntersection,...A(n)});class we extends E{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==x.array)return m(n,{code:d.invalid_type,expected:x.array,received:n.parsedType}),_;if(n.data.length<this._def.items.length)return m(n,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),_;if(!this._def.rest&&n.data.length>this._def.items.length)m(n,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty();let r=[...n.data].map((o,a)=>{let l=this._def.items[a]||this._def.rest;if(!l)return null;return l._parse(new ce(n,o,n.path,a))}).filter((o)=>!!o);if(n.common.async)return Promise.all(r).then((o)=>X.mergeArray(t,o));else return X.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new we({...this._def,rest:e})}}we.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new we({items:e,typeName:w.ZodTuple,rest:null,...A(t)})};class Vt extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==x.object)return m(n,{code:d.invalid_type,expected:x.object,received:n.parsedType}),_;let s=[],r=this._def.keyType,o=this._def.valueType;for(let a in n.data)s.push({key:r._parse(new ce(n,a,n.path,a)),value:o._parse(new ce(n,n.data[a],n.path,a)),alwaysSet:a in n.data});if(n.common.async)return X.mergeObjectAsync(t,s);else return X.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){if(t instanceof E)return new Vt({keyType:e,valueType:t,typeName:w.ZodRecord,...A(n)});return new Vt({keyType:ke.create(),valueType:e,typeName:w.ZodRecord,...A(t)})}}class qt extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==x.map)return m(n,{code:d.invalid_type,expected:x.map,received:n.parsedType}),_;let s=this._def.keyType,r=this._def.valueType,o=[...n.data.entries()].map(([a,l],i)=>({key:s._parse(new ce(n,a,n.path,[i,"key"])),value:r._parse(new ce(n,l,n.path,[i,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let l of o){let i=await l.key,c=await l.value;if(i.status==="aborted"||c.status==="aborted")return _;if(i.status==="dirty"||c.status==="dirty")t.dirty();a.set(i.value,c.value)}return{status:t.value,value:a}})}else{let a=new Map;for(let l of o){let{key:i,value:c}=l;if(i.status==="aborted"||c.status==="aborted")return _;if(i.status==="dirty"||c.status==="dirty")t.dirty();a.set(i.value,c.value)}return{status:t.value,value:a}}}}qt.create=(e,t,n)=>new qt({valueType:t,keyType:e,typeName:w.ZodMap,...A(n)});class Xe extends E{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==x.set)return m(n,{code:d.invalid_type,expected:x.set,received:n.parsedType}),_;let s=this._def;if(s.minSize!==null){if(n.data.size<s.minSize.value)m(n,{code:d.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()}if(s.maxSize!==null){if(n.data.size>s.maxSize.value)m(n,{code:d.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty()}let r=this._def.valueType;function o(l){let i=new Set;for(let c of l){if(c.status==="aborted")return _;if(c.status==="dirty")t.dirty();i.add(c.value)}return{status:t.value,value:i}}let a=[...n.data.values()].map((l,i)=>r._parse(new ce(n,l,n.path,i)));if(n.common.async)return Promise.all(a).then((l)=>o(l));else return o(a)}min(e,t){return new Xe({...this._def,minSize:{value:e,message:k.toString(t)}})}max(e,t){return new Xe({...this._def,maxSize:{value:e,message:k.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Xe.create=(e,t)=>new Xe({valueType:e,minSize:null,maxSize:null,typeName:w.ZodSet,...A(t)});class ct extends E{constructor(){super(...arguments);this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==x.function)return m(t,{code:d.invalid_type,expected:x.function,received:t.parsedType}),_;function n(a,l){return zt({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,it(),Ee].filter((i)=>!!i),issueData:{code:d.invalid_arguments,argumentsError:l}})}function s(a,l){return zt({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,it(),Ee].filter((i)=>!!i),issueData:{code:d.invalid_return_type,returnTypeError:l}})}let r={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof Ye){let a=this;return Z(async function(...l){let i=new ne([]),c=await a._def.args.parseAsync(l,r).catch((b)=>{throw i.addIssue(n(l,b)),i}),u=await Reflect.apply(o,this,c);return await a._def.returns._def.type.parseAsync(u,r).catch((b)=>{throw i.addIssue(s(u,b)),i})})}else{let a=this;return Z(function(...l){let i=a._def.args.safeParse(l,r);if(!i.success)throw new ne([n(l,i.error)]);let c=Reflect.apply(o,this,i.data),u=a._def.returns.safeParse(c,r);if(!u.success)throw new ne([s(c,u.error)]);return u.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ct({...this._def,args:we.create(e).rest(De.create())})}returns(e){return new ct({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ct({args:e?e:we.create([]).rest(De.create()),returns:t||De.create(),typeName:w.ZodFunction,...A(n)})}}class mt extends E{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}mt.create=(e,t)=>new mt({getter:e,typeName:w.ZodLazy,...A(t)});class gt extends E{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return m(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),_}return{status:"valid",value:e.data}}get value(){return this._def.value}}gt.create=(e,t)=>new gt({value:e,typeName:w.ZodLiteral,...A(t)});function pr(e,t){return new je({values:e,typeName:w.ZodEnum,...A(t)})}class je extends E{_parse(e){if(typeof e.data!=="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return m(t,{expected:C.joinValues(n),received:t.parsedType,code:d.invalid_type}),_}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return m(t,{received:t.data,code:d.invalid_enum_value,options:n}),_}return Z(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return je.create(e,{...this._def,...t})}exclude(e,t=this._def){return je.create(this.options.filter((n)=>!e.includes(n)),{...this._def,...t})}}je.create=pr;class xt extends E{_parse(e){let t=C.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==x.string&&n.parsedType!==x.number){let s=C.objectValues(t);return m(n,{expected:C.joinValues(s),received:n.parsedType,code:d.invalid_type}),_}if(!this._cache)this._cache=new Set(C.getValidEnumValues(this._def.values));if(!this._cache.has(e.data)){let s=C.objectValues(t);return m(n,{received:n.data,code:d.invalid_enum_value,options:s}),_}return Z(e.data)}get enum(){return this._def.values}}xt.create=(e,t)=>new xt({values:e,typeName:w.ZodNativeEnum,...A(t)});class Ye extends E{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==x.promise&&t.common.async===!1)return m(t,{code:d.invalid_type,expected:x.promise,received:t.parsedType}),_;let n=t.parsedType===x.promise?t.data:Promise.resolve(t.data);return Z(n.then((s)=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ye.create=(e,t)=>new Ye({type:e,typeName:w.ZodPromise,...A(t)});class ge extends E{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===w.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,r={addIssue:(o)=>{if(m(n,o),o.fatal)t.abort();else t.dirty()},get path(){return n.path}};if(r.addIssue=r.addIssue.bind(r),s.type==="preprocess"){let o=s.transform(n.data,r);if(n.common.async)return Promise.resolve(o).then(async(a)=>{if(t.value==="aborted")return _;let l=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});if(l.status==="aborted")return _;if(l.status==="dirty")return We(l.value);if(t.value==="dirty")return We(l.value);return l});else{if(t.value==="aborted")return _;let a=this._def.schema._parseSync({data:o,path:n.path,parent:n});if(a.status==="aborted")return _;if(a.status==="dirty")return We(a.value);if(t.value==="dirty")return We(a.value);return a}}if(s.type==="refinement"){let o=(a)=>{let l=s.refinement(a,r);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(a.status==="aborted")return _;if(a.status==="dirty")t.dirty();return o(a.value),{status:t.value,value:a.value}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then((a)=>{if(a.status==="aborted")return _;if(a.status==="dirty")t.dirty();return o(a.value).then(()=>({status:t.value,value:a.value}))})}if(s.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!He(o))return _;let a=s.transform(o.value,r);if(a instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then((o)=>{if(!He(o))return _;return Promise.resolve(s.transform(o.value,r)).then((a)=>({status:t.value,value:a}))});C.assertNever(s)}}ge.create=(e,t,n)=>new ge({schema:e,typeName:w.ZodEffects,effect:t,...A(n)});ge.createWithPreprocess=(e,t,n)=>new ge({schema:t,effect:{type:"preprocess",transform:e},typeName:w.ZodEffects,...A(n)});class me extends E{_parse(e){if(this._getType(e)===x.undefined)return Z(void 0);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}me.create=(e,t)=>new me({innerType:e,typeName:w.ZodOptional,...A(t)});class Ce extends E{_parse(e){if(this._getType(e)===x.null)return Z(null);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ce.create=(e,t)=>new Ce({innerType:e,typeName:w.ZodNullable,...A(t)});class bt extends E{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;if(t.parsedType===x.undefined)n=this._def.defaultValue();return this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}bt.create=(e,t)=>new bt({innerType:e,typeName:w.ZodDefault,defaultValue:typeof t.default==="function"?t.default:()=>t.default,...A(t)});class yt extends E{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});if(lt(s))return s.then((r)=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new ne(n.common.issues)},input:n.data})}));else return{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ne(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}yt.create=(e,t)=>new yt({innerType:e,typeName:w.ZodCatch,catchValue:typeof t.catch==="function"?t.catch:()=>t.catch,...A(t)});class Ft extends E{_parse(e){if(this._getType(e)!==x.nan){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:x.nan,received:n.parsedType}),_}return{status:"valid",value:e.data}}}Ft.create=(e)=>new Ft({typeName:w.ZodNaN,...A(e)});var ji=Symbol("zod_brand");class $n extends E{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Wt extends E{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let r=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});if(r.status==="aborted")return _;if(r.status==="dirty")return t.dirty(),We(r.value);else return this._def.out._parseAsync({data:r.value,path:n.path,parent:n})})();else{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});if(s.status==="aborted")return _;if(s.status==="dirty")return t.dirty(),{status:"dirty",value:s.value};else return this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Wt({in:e,out:t,typeName:w.ZodPipeline})}}class vt extends E{_parse(e){let t=this._def.innerType._parse(e),n=(s)=>{if(He(s))s.value=Object.freeze(s.value);return s};return lt(t)?t.then((s)=>n(s)):n(t)}unwrap(){return this._def.innerType}}vt.create=(e,t)=>new vt({innerType:e,typeName:w.ZodReadonly,...A(t)});var Bi={object:D.lazycreate},w;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(w||(w={}));var L=ke.create,fr=Ge.create,Vi=Ft.create,qi=Ke.create,hr=Ht.create,Fi=ut.create,Wi=Dt.create,Ui=dt.create,Gi=pt.create,Ki=jt.create,Ao=De.create,Xi=_e.create,Yi=Bt.create,Be=he.create,{create:re,strictCreate:Qi}=D,So=ft.create,Ji=Ln.create,Zi=ht.create,mr=we.create,el=Vt.create,tl=qt.create,nl=Xe.create,rl=ct.create,sl=mt.create,ol=gt.create,gr=je.create,al=xt.create,il=Ye.create,ll=ge.create,cl=me.create,ul=Ce.create,dl=ge.createWithPreprocess,pl=Wt.create;var Ro=re({before:L(),after:L(),hierarchy:Be(L()),lineStart:fr().optional(),lineEnd:fr().optional()}).passthrough(),Eo=re({id:L(),name:L()}).passthrough(),Co=re({url:L(),mime:L().optional()}).passthrough(),No=re({id:L(),snippet:L(),note:L(),createdAt:L(),filePath:L().optional(),canvasFile:L().optional(),context:Ro.optional(),images:Be(L()).optional(),attachments:Be(Co).optional(),source:gr(["local","remote"]).optional(),author:Eo.optional()}).passthrough(),Io=Be(No.optional().catch(void 0)).transform((e)=>e.filter((t)=>t!==void 0)).catch([]),Pn=re({annotations:Io,generalNote:L().catch("")}).passthrough(),br=re({path:L()}),yr=re({url:L()}),vr=re({error:L()});import{useCallback as vl,useMemo as kl,useState as _l}from"react";function kt(e){return e.uploadUrl!==null}var On=["image/png","image/jpeg","image/gif","image/webp"],kr="Only PNG, JPEG, GIF and WebP images can be attached";function Te(e,t){e.style.height="auto",e.style.height=(t?Math.max(t,e.scrollHeight):e.scrollHeight)+"px"}import{useAnnotations as Ut}from"@fabrika/annotations/runtime";import{useAnnotationHost as Lo}from"@fabrika/annotations/runtime";import{useCallback as Ae,useEffect as $o,useRef as Hn,useState as Gt}from"react";import{jsxDEV as Y}from"react/jsx-dev-runtime";function _r(e){if(e.startsWith("/s/")||e.startsWith("http://")||e.startsWith("https://"))return e;return`/api/uploads/${e.split("/").pop()}`}async function Po(e,t){let n=e.uploadUrl;if(!n)return{error:"Uploads are not available here"};let s=new FormData;s.append("image",t);try{let r=await fetch(n(),{method:"POST",body:s}),o=await r.json();if(!r.ok){let a=vr.safeParse(o);return{error:a.success?a.data.error:`Upload failed (HTTP ${r.status})`}}return{path:e.isShared?yr.parse(o).url:br.parse(o).path}}catch{return{error:"Upload failed"}}}function Kt({note:e,onNoteChange:t,images:n,onAddImage:s,onRemoveImage:r,sessionId:o,placeholder:a="Add your note...",autoFocus:l=!1,autoResize:i=!1,readOnly:c=!1,onKeyDown:u,onTextareaClick:f,textareaRef:b,textareaClassName:y,textareaStyle:p,minHeight:h,attachButton:g="always",openFilePickerRef:T}){let P=Lo(),O=!c&&kt(P),[q,j]=Gt(!1),[B,ee]=Gt(!1),[te,se]=Gt(null),[V,U]=Gt(!1),G=Hn(0),F=Hn(null),oe=Hn(null),Se=Ae(()=>oe.current?.click(),[]);if(T)T.current=Se;let Me=Ae((S)=>{if(F.current=S,b)b.current=S;if(S&&i)Te(S,h)},[b,i,h]);$o(()=>{if(l&&F.current){let S=F.current;if(S.focus(),S.value)S.setSelectionRange(S.value.length,S.value.length)}},[l]);let Q=Ae(async(S)=>{if(!On.includes(S.type)){se(kr);return}se(null),ee(!0);try{let v=await Po(P,S);if("path"in v)s(v.path);else se(v.error)}finally{ee(!1)}},[P,s]),ae=Ae((S)=>{for(let v of S.clipboardData?.items??[])if(v.type.startsWith("image/")){S.preventDefault();let M=v.getAsFile();if(M)Q(M);return}},[Q]),ue=Ae((S)=>{if(S.preventDefault(),G.current++,G.current===1)j(!0)},[]),de=Ae((S)=>{S.preventDefault()},[]),Le=Ae((S)=>{if(S.preventDefault(),G.current--,G.current===0)j(!1)},[]),$e=Ae((S)=>{S.preventDefault(),G.current=0,j(!1);for(let v of S.dataTransfer?.files??[])if(v.type.startsWith("image/"))Q(v)},[Q]),rn=Ae((S)=>{if(t(S.currentTarget.value),i)S.currentTarget.style.height="auto",S.currentTarget.style.height=(h?Math.max(h,S.currentTarget.scrollHeight):S.currentTarget.scrollHeight)+"px"},[t,i,h]),sn="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",tt={width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",outline:"none",...i?{resize:"none",overflow:"hidden"}:{resize:"vertical"}},St=O&&(g==="always"||g==="on-focus"&&V);return Y("div",{style:{position:"relative"},onDragEnter:O?ue:void 0,onDragOver:O?de:void 0,onDragLeave:O?Le:void 0,onDrop:O?$e:void 0,children:[Y("textarea",{ref:Me,value:e,onChange:c?void 0:rn,onPaste:O?ae:void 0,onKeyDown:u,onClick:f,onFocus:()=>U(!0),onBlur:()=>{setTimeout(()=>U(!1),150)},readOnly:c,placeholder:a,className:y??sn,style:p??tt,rows:i?1:void 0},void 0,!1,void 0,this),O&&Y("input",{ref:oe,type:"file",accept:On.join(","),multiple:!0,style:{display:"none"},onChange:(S)=>{let v=S.currentTarget.files;if(v)for(let M of v)Q(M);S.currentTarget.value=""}},void 0,!1,void 0,this),(n.length>0||St)&&Y("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[n.map((S)=>Y("div",{style:{position:"relative",width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:[Y("img",{src:_r(S),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!c&&Y("button",{onClick:(v)=>{v.stopPropagation(),r(S)},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)]},S,!0,void 0,this)),St&&Y(Xt,{onClick:Se},void 0,!1,void 0,this)]},void 0,!0,void 0,this),B&&Y("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),te&&Y("div",{role:"alert",style:{fontSize:"11px",color:"var(--color-accent-red)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:te},void 0,!1,void 0,this),q&&Y("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 Xt({onClick:e,size:t=16}){return Y("button",{onClick:(n)=>{n.stopPropagation(),e()},style:{width:`${t*2}px`,height:`${t*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:(n)=>{n.currentTarget.style.color="var(--color-text-secondary)"},onMouseLeave:(n)=>{n.currentTarget.style.color="var(--color-text-tertiary)"},children:Y("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[Y("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},void 0,!1,void 0,this),Y("circle",{cx:"8.5",cy:"8.5",r:"1.5"},void 0,!1,void 0,this),Y("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 Xl}from"@fabrika/annotations/runtime";import{useContext as Ql,useEffect as Jl,useRef as Zl}from"react";import{SessionContext as Do,useAnnotationHost as jo}from"@fabrika/annotations/runtime";import{useCallback as Yt,useContext as Bo,useEffect as Vo,useMemo as Sr,useRef as Qt,useState as Qe}from"react";import{createPortal as qo}from"react-dom";function Tr(e){let t=/^(\d+(?:\.\d+)?)px$/.exec(e.trim());return t?Number(t[1]):void 0}function Ar(e,t,n=280){let r=t||document.body,o=e.getBoundingClientRect(),a=r.getBoundingClientRect(),l=r===document.body?0:r.scrollTop,i=o.bottom-a.top+l+8,c=Math.max(0,Math.min(o.left-a.left,a.width-n-12));return r.style.position="relative",{style:{position:"absolute",top:`${i}px`,left:`${c}px`},parent:r}}import{jsxDEV as K,Fragment as Fo}from"react/jsx-dev-runtime";function Er({anchorEl:e,scrollContainer:t,onClose:n,ignoreSelector:s,zIndex:r="50",padding:o="12px",width:a="280px",children:l}){let i=Qt(null),c=Qt(n);c.current=n;let{style:u,parent:f}=Ar(e,t,Tr(a));return Vo(()=>{let b=setTimeout(()=>{let y=(p)=>{if(i.current&&!i.current.contains(p.target)){if(s&&p.target.closest?.(s))return;c.current(),document.removeEventListener("mousedown",y)}};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},0);return()=>clearTimeout(b)},[s]),qo(K("div",{ref:i,style:{...u,zIndex:r,width:a,background:"var(--color-bg-elevated)",border:"1px solid var(--color-border-hover)",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",padding:o,fontFamily:"'Inter', sans-serif"},children:l},void 0,!1,void 0,this),f)}var Cr=[{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"]}],Rr=Cr.flatMap((e)=>e.items);function Nr({anchorEl:e,scrollContainer:t,snippet:n,truncateAt:s=100,header:r,initialNote:o="",initialImages:a,onConfirm:l,onCancel:i,onDelete:c}){let u=Bo(Do),f=jo(),b=kt(f),y=o!==""||!!c,[p,h]=Qe(o),[g,T]=Qe(a||[]),[P,O]=Qe(null),[q,j]=Qe(y),[B,ee]=Qe(!1),te=Qt(null),se=Qt(null),V=Yt(()=>{if(p.trim()||g.length>0)l(p.trim(),g);else if(y&&c)c();else i()},[p,g,l,i,y,c]),U=Yt(()=>{if(y){if(!p.trim()&&g.length===0&&c){c(),i();return}l(p,g);return}i()},[p,g,y,l,i,c]),G=!y,F=p.trim().length>0?Rr.filter((v)=>v.toLowerCase().startsWith(p.trim().toLowerCase())):Rr,oe=!G||q?[]:F.length===1&&F[0]?.toLowerCase()===p.trim().toLowerCase()?[]:F,Se=new Set(oe),Me=Cr.map((v)=>({label:v.label,items:v.items.filter((M)=>Se.has(M))})).filter((v)=>v.items.length>0),Q=Me.map((v)=>v.items),ae=(v)=>Q[v]?.length??0,ue=Q.flat(),de=Sr(()=>{if(P===null)return 0;let v=0;for(let M=0;M<Q.length;M++){if(P<v+ae(M))return M;v+=ae(M)}return 0},[P,Q]),Le=Sr(()=>{if(P===null)return 0;let v=0;for(let M=0;M<de;M++)v+=ae(M);return P-v},[P,de,Q]),$e=(v,M)=>{let W=0;for(let pe=0;pe<v;pe++)W+=ae(pe);return W+M},[rn,sn]=Qe(p);if(p!==rn)sn(p),O(null),j(y);let tt=Yt((v)=>{h(v)},[]),St=n.length>s?n.slice(0,s)+"...":n,S=Yt((v)=>{if(ue.length>0&&(v.key==="ArrowDown"||v.key==="ArrowUp"||v.key==="ArrowLeft"||v.key==="ArrowRight")){if(v.preventDefault(),P===null){O(0);return}if(v.key==="ArrowDown"){let W=Math.min(Le+1,ae(de)-1);O($e(de,W))}else if(v.key==="ArrowUp"){let W=Math.max(Le-1,0);O($e(de,W))}else if(v.key==="ArrowRight"){let W=Math.min(de+1,Q.length-1),pe=Math.min(Le,ae(W)-1);O($e(W,pe))}else if(v.key==="ArrowLeft"){let W=Math.max(de-1,0),pe=Math.min(Le,ae(W)-1);O($e(W,pe))}return}let M=P===null?void 0:ue[P];if(M!==void 0){if(v.key==="Tab"){v.preventDefault(),tt(M);return}if(v.key==="Enter"&&!v.shiftKey){v.preventDefault(),l(M,g);return}}if(v.key==="Enter"&&!v.shiftKey){v.preventDefault(),V();return}if(v.key==="Escape")if(ue.length>0&&!q)j(!0);else if(y)U();else i()},[ue,P,Le,de,Q,$e,tt,l,g,V,q,y,U,i]);return K(Er,{anchorEl:e,scrollContainer:t,onClose:y?U:i,ignoreSelector:y?"[data-annotation-id]":void 0,zIndex:y?"60":"50",padding:y?"10px 12px":"12px",width:"420px",children:[!y&&(r??K("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:["“",St,"”"]},void 0,!0,void 0,this)),K(Kt,{note:p,onNoteChange:h,images:g,onAddImage:(v)=>T((M)=>[...M,v]),onRemoveImage:(v)=>T((M)=>M.filter((W)=>W!==v)),sessionId:u,autoFocus:!0,autoResize:y,textareaRef:te,onKeyDown:S,attachButton:"none",openFilePickerRef:se,textareaStyle:y?{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),K("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:y?"6px":"8px"},children:[b&&K(Xt,{onClick:()=>se.current?.(),size:14},void 0,!1,void 0,this),K("div",{style:{flex:1}},void 0,!1,void 0,this),y?K("button",{onClick:()=>{if(c)c();i()},onMouseEnter:()=>ee(!0),onMouseLeave:()=>ee(!1),style:{fontSize:"11px",color:B?"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):K(Fo,{children:[K("button",{onClick:i,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),K("button",{onClick:V,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),ue.length>0&&K("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:Me.map((v)=>K("div",{style:{flex:1},children:[K("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:v.label},void 0,!1,void 0,this),v.items.map((M)=>{let W=ue.indexOf(M);return K("div",{onMouseDown:(pe)=>{pe.preventDefault(),pe.stopPropagation(),tt(M)},onMouseEnter:()=>O(W),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:W===P?"var(--color-text-primary)":"var(--color-text-secondary)",background:W===P?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[K("span",{style:{fontWeight:500},children:M.slice(0,p.trim().length)},void 0,!1,void 0,this),M.slice(p.trim().length)]},M,!0,void 0,this)})]},v.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function _t({anchorEl:e,scrollContainer:t,snippet:n,truncateAt:s,header:r,onAdd:o,onCancel:a}){return K(Nr,{anchorEl:e,scrollContainer:t,snippet:n,truncateAt:s,header:r,onConfirm:(l,i)=>o(l,i),onCancel:a},void 0,!1,void 0,this)}import{useEffect as vc,useRef as kc,useState as _c}from"react";import{useCallback as Ic,useEffect as Mc,useRef as Lc,useState as $c}from"react";import{jsxDEV as Ir}from"react/jsx-dev-runtime";function Je({note:e,onChange:t}){return Ir("div",{className:"mt-1.5",children:Ir("textarea",{value:e,onChange:(n)=>t(n.currentTarget.value),className:"w-full bg-transparent text-[12px] font-body text-text-primary resize-none focus:outline-none border-none placeholder:text-text-disabled transition-colors min-h-[20px] p-0 leading-relaxed",placeholder:"Add a note...",rows:1,onInput:(n)=>Te(n.currentTarget),ref:(n)=>{if(n)Te(n)}},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as H}from"react/jsx-dev-runtime";function Hr(e){return e.map((t)=>typeof t==="string"?{value:t,label:t}:{value:t.value,label:t.label??t.value})}function ea({id:e,label:t,options:n,required:s}){let{responses:r,setResponse:o}=Mr();Lr(e);let a=Pr(()=>Hr(n),[n]),l=r.get(e),i=l?.value,c=l?.note||"",[u,f]=zr(!1),b=Or(null);if(!r.has(e))o(e,{id:e,type:"radio",label:t,value:null,options:a.map((h)=>h.value),required:s});let y=(h)=>{o(e,{...l,value:h})};$r(()=>{let h=b.current;if(!h)return;let g=(T)=>{let O=T.target.closest("[data-md-label]")?.getAttribute("data-md-label"),q=a.find((j)=>j.label===O);if(q)y(q.value)};return h.addEventListener("kb-select",g),()=>h.removeEventListener("kb-select",g)},[a,y]);let p=l?.required&&!i;return H("div",{ref:b,"data-md":"choice","data-md-label":t,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[H("div",{className:"flex items-baseline gap-2 mb-2",children:[H("span",{className:"text-[13px] font-body font-medium text-text-primary",children:t},void 0,!1,void 0,this),s&&H("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H("div",{className:"space-y-1",children:a.map(({value:h,label:g})=>H("label",{"data-md":"choice-option","data-md-label":g,onClick:()=>y(h),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${i===h?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[H("span",{className:`w-4 h-4 rounded-full border-[1.5px] flex items-center justify-center flex-shrink-0 transition-all ${i===h?"border-accent-amber bg-accent-amber":"border-border-strong"}`,children:i===h&&H("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),H("span",{className:"text-[13px] font-body text-text-secondary",children:g},void 0,!1,void 0,this)]},h,!0,void 0,this))},void 0,!1,void 0,this),H(Je,{show:u,note:c,onToggle:()=>f(!u),onChange:(h)=>o(e,{...l,note:h})},void 0,!1,void 0,this),p&&H("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 ta({id:e,label:t,options:n,required:s}){let{responses:r,setResponse:o}=Mr();Lr(e);let a=Pr(()=>Hr(n),[n]),l=r.get(e),i=l?.value||[],c=l?.note||"",[u,f]=zr(!1),b=Or(null);if(!r.has(e))o(e,{id:e,type:"checkbox",label:t,value:[],options:a.map((h)=>h.value),required:s});let y=(h)=>{let g=i.includes(h)?i.filter((T)=>T!==h):[...i,h];o(e,{...l,value:g})};$r(()=>{let h=b.current;if(!h)return;let g=(T)=>{let O=T.target.closest("[data-md-label]")?.getAttribute("data-md-label"),q=a.find((j)=>j.label===O);if(q)y(q.value)};return h.addEventListener("kb-select",g),()=>h.removeEventListener("kb-select",g)},[a,y]);let p=l?.required&&i.length===0;return H("div",{ref:b,"data-md":"multichoice","data-md-label":t,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[H("div",{className:"flex items-baseline gap-2 mb-2",children:[H("span",{className:"text-[13px] font-body font-medium text-text-primary",children:t},void 0,!1,void 0,this),s&&H("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H("div",{className:"space-y-1",children:a.map(({value:h,label:g})=>{let T=i.includes(h);return H("label",{"data-md":"multichoice-option","data-md-label":g,onClick:()=>y(h),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${T?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[H("span",{className:`w-4 h-4 rounded flex items-center justify-center flex-shrink-0 transition-all ${T?"bg-accent-amber":"border-[1.5px] border-border-strong"}`,children:T&&H("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:H("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),H("span",{className:"text-[13px] font-body text-text-secondary",children:g},void 0,!1,void 0,this)]},h,!0,void 0,this)})},void 0,!1,void 0,this),H(Je,{show:u,note:c,onToggle:()=>f(!u),onChange:(h)=>o(e,{...l,note:h})},void 0,!1,void 0,this),p&&H("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select at least one option."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as na,useRef as ra}from"react";function Jt(){return window.hljs}function Dr(){return window.mermaid}import{jsxDEV as Zt}from"react/jsx-dev-runtime";function sa({language:e,children:t}){let n=typeof t==="string"?t:String(t??""),s=ra(null);return na(()=>{let r=s.current,o=Jt();if(!r||!o)return;r.removeAttribute("data-highlighted"),r.className=e?`language-${e}`:"",r.textContent=n,o.highlightElement(r)},[n,e]),Zt("div",{className:"relative mt-3 group/code","data-md":"codeblock","data-md-language":e||"",children:[e&&Zt("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:e},void 0,!1,void 0,this),Zt("pre",{className:"bg-bg-code rounded-md p-4 overflow-x-auto text-code font-mono leading-relaxed",children:Zt("code",{ref:s,className:e?`language-${e}`:"",children:n},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function jr(e,t){let n=e.split(`
60
+ `),s=t.split(`
61
+ `),r=oa(n,s),o=[],a=0,l=0,i=0;while(a<n.length||l<s.length){let c=n[a],u=s[l];if(i<r.length&&c!==void 0&&u!==void 0&&c===r[i]&&u===r[i])o.push({type:"same",line:c}),a++,l++,i++;else if(c!==void 0&&(i>=r.length||c!==r[i]))o.push({type:"removed",line:c}),a++;else if(u!==void 0)o.push({type:"added",line:u}),l++}return o}function oa(e,t){let n=e.length,s=t.length,r=Array.from({length:n+1},()=>Array(s+1).fill(0));for(let i=1;i<=n;i++){let c=r[i]??[],u=r[i-1]??[];for(let f=1;f<=s;f++)c[f]=e[i-1]===t[f-1]?(u[f-1]??0)+1:Math.max(u[f]??0,c[f-1]??0)}let o=[],a=n,l=s;while(a>0&&l>0){let i=e[a-1];if(i!==void 0&&i===t[l-1])o.unshift(i),a--,l--;else if((r[a-1]?.[l]??0)>(r[a]?.[l-1]??0))a--;else l--}return o}import{jsxDEV as wt}from"react/jsx-dev-runtime";function aa({before:e,after:t,language:n}){let s=jr(e,t);return wt("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden group/diff","data-md":"diff","data-md-language":n||"",children:[n&&wt("div",{className:"px-4 py-2 text-meta font-mono text-text-tertiary opacity-0 group-hover/diff:opacity-60 transition-opacity",children:["diff (",n,")"]},void 0,!0,void 0,this),wt("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono",children:s.map((r,o)=>wt("div",{className:r.type==="removed"?"bg-accent-red-muted text-accent-red":r.type==="added"?"bg-accent-green-muted text-accent-green":"text-text-tertiary",children:[wt("span",{className:"select-none w-6 inline-block text-center opacity-60",children:r.type==="removed"?"-":r.type==="added"?"+":" "},void 0,!1,void 0,this),r.line]},o,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{ActiveViewCtx as ca,SessionContext as ua}from"#canvas/runtime";import{useContext as Vr,useEffect as qr,useRef as da,useState as en}from"react";var ia=re({id:L(),type:gr(["select","radio","checkbox","text","range"]),label:L(),value:Ao(),options:Be(L()).optional(),required:hr().optional(),note:L().optional()}).passthrough().transform((e)=>({...e,value:e.value})),la=re({id:L(),markdown:L(),label:L().optional(),required:hr().optional()}).passthrough(),qu=Pn.extend({responses:Be(mr([L(),ia]).optional().catch(void 0)).transform((e)=>e.filter((t)=>t!==void 0)).catch([]),feedbackEntries:Be(mr([L(),la]).optional().catch(void 0)).transform((e)=>e.filter((t)=>t!==void 0)).optional().catch([])});var Fu=re({feedback:L().nullish()}),Br=So([re({error:L().min(1)}),re({content:L(),language:L().nullish()})]);import{jsxDEV as Ne}from"react/jsx-dev-runtime";var pa={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 fa({path:e,lines:t,__content:n}){let s=Vr(ua),{setActiveView:r}=Vr(ca),[o,a]=en(n??null),[l,i]=en(()=>{let p=e.split(".").pop()||"";return pa[p]||"text"}),[c,u]=en(null),[f,b]=en(!n),y=da(null);if(qr(()=>{if(n!==void 0)return;b(!0),u(null),fetch(`/api/file?session=${s}&path=${encodeURIComponent(e)}`).then((p)=>p.json()).then((p)=>{let h=Br.parse(p);if("error"in h)u(h.error);else{let g=h.content;if(t)g=g.split(`
62
+ `).slice(t[0]-1,t[1]).join(`
63
+ `);a(g),i(h.language||"text")}}).catch(()=>u("Failed to fetch file")).finally(()=>b(!1))},[s,e,t?.[0],t?.[1],n]),qr(()=>{let p=y.current,h=Jt();if(!p||!h||!o)return;p.removeAttribute("data-highlighted"),p.className=l?`language-${l}`:"",p.textContent=o,h.highlightElement(p)},[o,l]),f)return Ne("div",{className:"text-text-tertiary text-body mt-3 bg-bg-code rounded-md p-4",children:["Loading ",e,"..."]},void 0,!0,void 0,this);if(c)return Ne("div",{className:"text-accent-red text-body mt-3 bg-accent-red-muted rounded-md p-4",children:[e,": ",c]},void 0,!0,void 0,this);return Ne("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden","data-md":"filepreview","data-md-path":e,...t?{"data-md-lines":`${t[0]}-${t[1]}`}:{},children:[Ne("div",{className:"px-4 py-2 flex items-center justify-between",children:[Ne("button",{className:"font-mono text-meta text-text-tertiary hover:text-text-secondary hover:underline cursor-pointer text-left",onClick:()=>r({type:"file",path:e}),title:`Open ${e}`,children:e},void 0,!1,void 0,this),t&&Ne("span",{className:"font-mono text-meta text-text-tertiary opacity-60",children:["L",t[0],"–",t[1]]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Ne("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono !bg-transparent",style:{background:"transparent"},children:Ne("code",{ref:y,className:l?`language-${l}`:"",children:o},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{SessionContext as ha}from"#canvas/runtime";import{useContext as ma,useState as ga}from"react";import{jsxDEV as Tt}from"react/jsx-dev-runtime";function xa({src:e,alt:t,caption:n,width:s,height:r}){let o=ma(ha),[a,l]=ga(!1),i=`/api/image?session=${encodeURIComponent(o)}&path=${encodeURIComponent(e)}`;if(a)return Tt("div",{className:"mt-3 text-accent-red text-body bg-accent-red-muted rounded-md p-4",children:[e,": Failed to load image"]},void 0,!0,void 0,this);return Tt("figure",{className:"mt-3 relative","data-md":"image","data-md-src":e,children:[Tt("div",{"data-annotation-image":!0,className:"rounded-md overflow-hidden border border-border-subtle bg-bg-code inline-block",children:Tt("img",{src:i,alt:t||e,onError:()=>l(!0),draggable:!1,className:"block max-w-full h-auto",...s?{width:s}:{},...r?{height:r}:{}},void 0,!1,void 0,this)},void 0,!1,void 0,this),n&&Tt("figcaption",{className:"mt-1.5 text-meta text-text-tertiary font-body",children:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useMemo as ba}from"react";import{jsxDEV as Fr}from"react/jsx-dev-runtime";N.setOptions({gfm:!0,breaks:!1});function ya({children:e,file:t,__content:n}){let s=n??(typeof e==="string"?e:String(e??"")),r=ba(()=>{if(!s)return"";return N.parse(s,{async:!1})},[s]);if(!s)return Fr("div",{className:"text-text-tertiary text-tiny mt-3",children:t?`Could not load: ${t}`:"No markdown content"},void 0,!1,void 0,this);return Fr("div",{className:"mt-3 prose-canvas","data-md":"markdown",...t?{"data-md-file":t}:{},"data-md-source":s,dangerouslySetInnerHTML:{__html:r}},void 0,!1,void 0,this)}import{useAnnotations as va,useCanvasFile as ka}from"#canvas/runtime";import{useCallback as xe,useEffect as Dn,useRef as At,useState as Ze}from"react";import _a from"react-dom";import{jsxDEV as R,Fragment as Kr}from"react/jsx-dev-runtime";var et=0.2,tn=0.25,nn=4;function Ur({zoom:e,onZoomIn:t,onZoomOut:n,onZoomReset:s,onFullscreen:r}){return R("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:[R("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:n,title:"Zoom out",disabled:e<=tn,children:R("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:R("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),R("button",{className:"px-1.5 h-7 rounded hover:bg-bg-elevated text-text-tertiary hover:text-text-primary transition-colors tabular-nums",onClick:s,title:"Reset zoom",children:[Math.round(e*100),"%"]},void 0,!0,void 0,this),R("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:t,title:"Zoom in",disabled:e>=nn,children:R("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[R("line",{x1:"12",y1:"5",x2:"12",y2:"19"},void 0,!1,void 0,this),R("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),r&&R(Kr,{children:[R("div",{className:"w-px h-4 bg-border-subtle mx-0.5"},void 0,!1,void 0,this),R("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:r,title:"Fullscreen",children:R("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[R("polyline",{points:"15 3 21 3 21 9"},void 0,!1,void 0,this),R("polyline",{points:"9 21 3 21 3 15"},void 0,!1,void 0,this),R("line",{x1:"21",y1:"3",x2:"14",y2:"10"},void 0,!1,void 0,this),R("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 Gr(e=1){let[t,n]=Ze(e),s=xe(()=>n((a)=>Math.min(nn,+(a+et).toFixed(2))),[]),r=xe(()=>n((a)=>Math.max(tn,+(a-et).toFixed(2))),[]),o=xe(()=>n(1),[]);return{zoom:t,zoomIn:s,zoomOut:r,zoomReset:o,setZoom:n}}function wa({svgHtml:e,source:t,onClose:n}){let s=At(null),{zoom:r,zoomIn:o,zoomOut:a,zoomReset:l,setZoom:i}=Gr(1),[c,u]=Ze({x:0,y:0}),f=At(null);Dn(()=>{let T=(P)=>{if(P.key==="Escape")n()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[n]);let b=xe((T)=>{T.preventDefault();let P=T.deltaY>0?-et:et;i((O)=>Math.max(tn,Math.min(nn,+(O+P).toFixed(2))))},[i]),y=xe((T)=>{if(T.button!==0)return;f.current={startX:T.clientX,startY:T.clientY,panX:c.x,panY:c.y},T.preventDefault()},[c]),p=xe((T)=>{if(!f.current)return;u({x:f.current.panX+(T.clientX-f.current.startX),y:f.current.panY+(T.clientY-f.current.startY)})},[]),h=xe(()=>{f.current=null},[]),g=xe(()=>{l(),u({x:0,y:0})},[l]);return _a.createPortal(R("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"var(--color-bg-base)",display:"flex",flexDirection:"column"},onMouseMove:p,onMouseUp:h,onMouseLeave:h,children:[R("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:[R("span",{className:"text-body text-text-secondary",style:{fontSize:"13px"},children:"Mermaid Diagram"},void 0,!1,void 0,this),R("div",{className:"flex items-center gap-2",children:[R(Ur,{zoom:r,onZoomIn:o,onZoomOut:a,onZoomReset:g},void 0,!1,void 0,this),R("button",{className:"flex items-center justify-center w-8 h-8 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:n,title:"Close (Esc)",children:R("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[R("line",{x1:"18",y1:"6",x2:"6",y2:"18"},void 0,!1,void 0,this),R("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),R("div",{style:{flex:1,overflow:"hidden",cursor:f.current?"grabbing":"grab"},onWheel:b,onMouseDown:y,children:R("div",{ref:s,style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",transform:`translate(${c.x}px, ${c.y}px) scale(${r})`,transformOrigin:"center center",transition:f.current?"none":"transform 0.1s ease-out"},dangerouslySetInnerHTML:{__html:e}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),document.body)}function Ta({children:e}){let t=At(null),[n,s]=Ze(null),[r,o]=Ze(!1),[a,l]=Ze(""),i=typeof e==="string"?e:String(e??""),{annotations:c,addAnnotationWithId:u,activeAnnotationId:f,setActiveAnnotationId:b}=va(),y=ka(),[p,h]=Ze(null),{zoom:g,zoomIn:T,zoomOut:P,zoomReset:O,setZoom:q}=Gr(1),j=At(c);j.current=c;let B=xe((V,U,G)=>{let F=`[Diagram ${G.toLowerCase()}] ${U}`,oe=j.current.find((Se)=>Se.snippet===F);if(oe)b(oe.id);else h({anchorEl:V,snippet:U,prefix:G})},[b]),ee=At(B);ee.current=B,Dn(()=>{let V=!1,U=async()=>{try{let F=Dr();if(!F){s("Mermaid library not loaded");return}let oe=document.documentElement.dataset.theme==="light"?"default":"dark";F.initialize({startOnLoad:!1,theme:oe});let Se=`mermaid-${Math.random().toString(36).slice(2)}`,{svg:Me}=await F.render(Se,i.trim());if(!V&&t.current)t.current.innerHTML=Me,l(Me),Aa(t.current,(Q,ae,ue)=>ee.current(Q,ae,ue)),Wr(t.current,j.current);s(null)}catch(F){if(!V)s(F instanceof Error&&F.message||"Invalid diagram")}};U();let G=new MutationObserver((F)=>{for(let oe of F)if(oe.attributeName==="data-theme")U()});return G.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{V=!0,G.disconnect()}},[i]),Dn(()=>{if(t.current)Wr(t.current,c,f)},[c,f]);let te=xe((V)=>{if(!V.ctrlKey&&!V.metaKey)return;V.preventDefault();let U=V.deltaY>0?-et:et;q((G)=>Math.max(tn,Math.min(nn,+(G+U).toFixed(2))))},[q]);if(n)return R("div",{className:"bg-accent-red-muted rounded-md p-4 mt-3 text-body text-accent-red",children:["Mermaid error: ",n,R("pre",{className:"mt-2 text-tiny text-text-tertiary whitespace-pre-wrap",children:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let se=t.current?.closest("#plan-scroll-container");return R(Kr,{children:[R("div",{className:"mt-3 mermaid-container","data-md":"mermaid","data-md-source":i.trim(),children:[R("div",{className:"flex justify-end mb-1",children:R(Ur,{zoom:g,onZoomIn:T,onZoomOut:P,onZoomReset:O,onFullscreen:()=>o(!0)},void 0,!1,void 0,this)},void 0,!1,void 0,this),R("div",{style:{overflow:"auto",maxHeight:"70vh"},onWheel:te,children:R("div",{ref:t,className:"flex justify-center",style:{transform:`scale(${g})`,transformOrigin:"top center",transition:"transform 0.1s ease-out",minHeight:g<1?void 0:void 0}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),p&&R(_t,{anchorEl:p.anchorEl,scrollContainer:se,snippet:p.snippet,header:R("div",{style:{fontSize:"12px",color:"var(--color-text-tertiary)",marginBottom:"8px",lineHeight:"1.4",display:"flex",alignItems:"center",gap:"6px"},children:[R("span",{style:{width:"8px",height:"8px",borderRadius:"50%",background:"var(--color-accent-amber)",flexShrink:0}},void 0,!1,void 0,this),p.snippet]},void 0,!0,void 0,this),onAdd:(V,U)=>{let G=`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;u(G,`[Diagram ${p.prefix.toLowerCase()}] ${p.snippet}`,V,void 0,void 0,U,y||void 0),h(null)},onCancel:()=>h(null)},void 0,!1,void 0,this),r&&a&&R(wa,{svgHtml:a,source:i,onClose:()=>o(!1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Aa(e,t){let n=(s,r,o)=>{s.style.cursor="pointer",s.addEventListener("mouseenter",()=>{s.style.filter="brightness(1.2)"}),s.addEventListener("mouseleave",()=>{s.style.filter=""}),s.addEventListener("click",(a)=>{a.stopPropagation(),a.preventDefault(),t(s,r(),o)})};for(let s of e.querySelectorAll(".node"))n(s,()=>(s.querySelector(".nodeLabel")||s.querySelector("foreignObject span")||s.querySelector("text"))?.textContent?.trim()||"Node","Node");for(let s of e.querySelectorAll(".edgePath")){let r=s,o=r.querySelector("path");if(o){o.style.strokeWidth=Math.max(parseFloat(o.style.strokeWidth||"1"),8)+"px",o.style.strokeOpacity="0";let l=o.cloneNode(!0);l.style.strokeWidth="",l.style.strokeOpacity="",r.insertBefore(l,o)}let a=r.id||"";n(r,()=>{let l=e.querySelectorAll(".edgeLabel");for(let i of l)if(i.id&&a&&i.id.replace("label","").includes(a.replace("L-","").replace("edge",""))){let c=i.textContent?.trim();if(c)return c}return"Connection"},"Edge")}for(let s of e.querySelectorAll(".edgeLabel")){let r=s.textContent?.trim();if(!r)continue;n(s,()=>r,"Edge")}for(let s of e.querySelectorAll(".actor")){let r=s.closest("g")?.querySelector("text")||s.parentElement?.querySelector("text");if(!r)continue;let o=s.closest("g");if(!o||o.hasAttribute("data-clickable"))continue;o.setAttribute("data-clickable","true"),n(o,()=>r.textContent?.trim()||"Participant","Node")}for(let s of e.querySelectorAll(".messageText")){let r=s.textContent?.trim();if(!r)continue;n(s,()=>r,"Edge")}for(let s of e.querySelectorAll(".entityBox")){let r=s.closest("g");if(!r||r.hasAttribute("data-clickable"))continue;let o=r.querySelector(".entityLabel");if(!o)continue;r.setAttribute("data-clickable","true"),n(r,()=>o.textContent?.trim()||"Entity","Node")}for(let s of e.querySelectorAll(".relationshipLabel")){let r=s.textContent?.trim();if(!r)continue;let a=s.closest("g")||s;if(a.hasAttribute("data-clickable"))continue;a.setAttribute("data-clickable","true"),n(a,()=>r,"Edge")}for(let s of e.querySelectorAll(".classGroup")){let r=s;if(r.hasAttribute("data-clickable"))continue;let o=r.querySelector(".classTitle, .classTitleText, text");if(!o)continue;r.setAttribute("data-clickable","true"),n(r,()=>o.textContent?.trim()||"Class","Node")}for(let s of e.querySelectorAll(".statediagram-state")){let r=s;if(r.hasAttribute("data-clickable"))continue;let o=r.querySelector(".state-title, text");if(!o)continue;r.setAttribute("data-clickable","true"),n(r,()=>o.textContent?.trim()||"State","Node")}for(let s of e.querySelectorAll(".mindmap-node")){let r=s;if(r.hasAttribute("data-clickable"))continue;let o=r.querySelector(".mindmap-node-label, text");if(!o)continue;r.setAttribute("data-clickable","true"),n(r,()=>o.textContent?.trim()||"Node","Node")}}function Wr(e,t,n){let s=new Map;for(let o of t){let a=o.snippet.match(/^\[Diagram (?:node|edge)\] (.+)$/)?.[1];if(a)s.set(a,o.id)}for(let o of e.querySelectorAll("[data-annotated]"))o.style.outline="",o.style.outlineOffset="",o.style.borderRadius="",o.removeAttribute("data-annotated");if(s.size===0)return;for(let o of e.querySelectorAll(".node")){let l=(o.querySelector(".nodeLabel")||o.querySelector("foreignObject span")||o.querySelector("text"))?.textContent?.trim();if(!l||!s.has(l))continue;let i=s.get(l),c=o;c.setAttribute("data-annotated",i);let u=i===n;c.style.outline=u?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",c.style.outlineOffset="2px",c.style.borderRadius="4px"}for(let o of e.querySelectorAll(".edgeLabel")){let a=o.textContent?.trim();if(!a||!s.has(a))continue;let l=s.get(a),i=o;i.setAttribute("data-annotated",l);let c=l===n;i.style.outline=c?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",i.style.outlineOffset="2px",i.style.borderRadius="4px"}for(let o of e.querySelectorAll(".actor")){let a=o.closest("g");if(!a)continue;let i=a.querySelector("text")?.textContent?.trim();if(!i||!s.has(i))continue;if(a.hasAttribute("data-annotated"))continue;let c=s.get(i);a.setAttribute("data-annotated",c);let u=c===n,f=a.querySelector("rect");if(f)f.style.outline=u?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",f.style.outlineOffset="2px",f.style.borderRadius="4px"}for(let o of e.querySelectorAll(".messageText")){let a=o.textContent?.trim();if(!a||!s.has(a))continue;let l=s.get(a),i=o;i.setAttribute("data-annotated",l);let c=l===n;i.style.outline=c?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",i.style.outlineOffset="2px",i.style.borderRadius="4px"}let r=(o,a,l)=>{for(let i of e.querySelectorAll(o)){let c=l(i);if(!c||c.hasAttribute("data-annotated"))continue;let f=c.querySelector(a)?.textContent?.trim();if(!f||!s.has(f))continue;let b=s.get(f);c.setAttribute("data-annotated",b);let y=b===n,p=c.querySelector("rect, circle, ellipse, polygon")||c;p.style.outline=y?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",p.style.outlineOffset="2px",p.style.borderRadius="4px"}};r(".entityBox",".entityLabel",(o)=>o.closest("g"));for(let o of e.querySelectorAll(".relationshipLabel")){let l=o.closest("g")||o;if(l.hasAttribute("data-annotated"))continue;let i=o.textContent?.trim();if(!i||!s.has(i))continue;let c=s.get(i);l.setAttribute("data-annotated",c);let u=c===n;l.style.outline=u?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",l.style.outlineOffset="2px",l.style.borderRadius="4px"}r(".classGroup",".classTitle, .classTitleText, text",(o)=>o),r(".statediagram-state",".state-title, text",(o)=>o),r(".mindmap-node",".mindmap-node-label, text",(o)=>o)}import{jsxDEV as Ra}from"react/jsx-dev-runtime";function Sa({children:e}){return Ra("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:Re(e)},void 0,!1,void 0,this)}import{jsxDEV as Na}from"react/jsx-dev-runtime";var Ea={high:"text-accent-red bg-accent-red-muted",medium:"text-accent-amber bg-accent-amber-muted",low:"text-text-tertiary bg-border-subtle"};function Ca({level:e}){return Na("span",{className:`inline text-tiny font-medium font-body ml-2 px-1.5 py-0.5 rounded ${Ea[e]}`,"data-md":"priority","data-md-level":e,children:e},void 0,!1,void 0,this)}import{useState as Ia}from"react";import{jsxDEV as Ve}from"react/jsx-dev-runtime";function Ma({title:e,children:t}){let[n,s]=Ia(!1);return Ve("div",{className:"relative mb-8 p-4 group/section","data-md":"section","data-md-title":e,children:[Ve("div",{className:"relative mb-2",children:[Ve("button",{onClick:()=>s(!n),className:`absolute -left-8 top-1/2 -translate-y-1/2 text-text-tertiary opacity-0 group-hover/section:opacity-50 hover:!opacity-100 transition-all duration-150 p-0.5 ${n?"-rotate-90":""}`,children:Ve("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",children:Ve("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),Ve("h2",{className:"font-heading text-section text-text-primary",style:{fontWeight:400},children:e},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Ve("div",{className:n?"mt-6 hidden":"mt-6",children:Re(t)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as Ie}from"react/jsx-dev-runtime";function La({headers:e,rows:t}){return Ie("div",{className:"overflow-x-auto mt-3","data-md":"table",children:Ie("table",{className:"w-full text-body",children:[Ie("thead",{children:Ie("tr",{className:"border-b border-border-subtle",children:e.map((n,s)=>Ie("th",{className:"text-left px-4 py-2.5 text-meta font-medium uppercase tracking-wider text-text-tertiary font-body",children:n},s,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),Ie("tbody",{children:t.map((n,s)=>Ie("tr",{className:`relative border-b border-border-subtle last:border-b-0 transition-colors hover:bg-bg-surface/50 ${s%2===1?"bg-bg-surface/30":""}`,children:n.map((r,o)=>Ie("td",{className:"px-4 py-2.5 text-text-secondary font-body",children:r},o,!1,void 0,this))},s,!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 be}from"react/jsx-dev-runtime";var $a={todo:"bg-border-hover",done:"bg-accent-green",blocked:"bg-accent-red","in-progress":"bg-accent-blue"},Pa={todo:"Todo",done:"Done",blocked:"Blocked","in-progress":"In progress"},Oa={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 Xr({id:e,label:t,status:n,badge:s,badgeVariant:r="neutral",children:o}){return be("div",{className:"group/task relative -mx-4 px-4 py-3 rounded-md transition-colors duration-150 hover:bg-bg-input","data-task-id":e,"data-md":"item","data-md-label":t,...n?{"data-md-status":n}:{},...s?{"data-md-badge":s}:{},children:be("div",{className:"flex items-start gap-3",children:[n&&be("span",{className:`w-2 h-2 rounded-full mt-[7px] flex-shrink-0 ${$a[n]}`},void 0,!1,void 0,this),be("div",{className:"flex-1 min-w-0",children:[be("div",{className:"flex items-baseline gap-2",children:[be("span",{className:"font-body text-task-label font-semibold text-text-primary",children:t},void 0,!1,void 0,this),n&&be("span",{className:"font-body text-tiny uppercase tracking-wider text-text-tertiary opacity-0 group-hover/task:opacity-100 transition-opacity duration-150",children:Pa[n]},void 0,!1,void 0,this),s&&be("span",{className:`font-body text-tiny font-medium px-1.5 py-px rounded-full ${Oa[r]}`,children:s},void 0,!1,void 0,this)]},void 0,!0,void 0,this),o&&be("div",{className:"text-body text-text-secondary mt-1 leading-relaxed",children:Re(o)},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 za(e){return be(Xr,{...e},void 0,!1,void 0,this)}import{useAnnotations as Yr,useResponseRegistration as Qr}from"#canvas/runtime";import{useRef as Ha,useState as Jr}from"react";import{jsxDEV as z}from"react/jsx-dev-runtime";function Da({id:e,label:t,placeholder:n,multiline:s,required:r}){let{responses:o,setResponse:a}=Yr();Qr(e);let l=o.get(e),i=l?.value??"",c=l?.note||"",[u,f]=Jr(!1),b=Ha(null);if(!o.has(e))a(e,{id:e,type:"text",label:t,value:"",required:r});let y=(g)=>{a(e,{...l,value:g})},p=(g)=>Te(g,s?60:32),h=l?.required&&!i.trim();return z("div",{"data-md":"userinput","data-md-label":t,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:t},void 0,!1,void 0,this),r&&z("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z("textarea",{ref:b,value:i,onChange:(g)=>{y(g.currentTarget.value),p(g.currentTarget)},placeholder:n||"Type your response...",rows:s?3:1,className:"w-full bg-bg-input text-[13px] font-body text-text-primary rounded-lg px-3 py-2 resize-none focus:outline-none border border-border-subtle focus:border-border-hover placeholder:text-text-tertiary transition-colors",onInput:(g)=>p(g.currentTarget),onFocus:(g)=>p(g.currentTarget)},void 0,!1,void 0,this),z(Je,{show:u,note:c,onToggle:()=>f(!u),onChange:(g)=>a(e,{...l,note:g})},void 0,!1,void 0,this),h&&z("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 ja({id:e,label:t,min:n=1,max:s=10,step:r=1,required:o,minLabel:a,maxLabel:l}){let{responses:i,setResponse:c}=Yr();Qr(e);let u=i.get(e),f=u?.value,b=u?.note||"",[y,p]=Jr(!1);if(!i.has(e))c(e,{id:e,type:"range",label:t,value:null,required:o});let h=(B)=>{c(e,{...u,value:B})},g=f!==null&&f!==void 0,T=g?f:Math.round((n+s)/2),P=(T-n)/(s-n)*100,O=Math.round((s-n)/r),q=O<=20,j=u?.required&&!g;return z("div",{"data-md":"rangeinput","data-md-label":t,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 justify-between mb-1",children:[z("div",{className:"flex items-baseline gap-2",children:[z("span",{className:"text-[13px] font-body font-medium text-text-primary",children:t},void 0,!1,void 0,this),o&&z("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z("span",{className:"flex items-center gap-1.5",children:[z("span",{className:`text-[13px] font-mono ${g?"text-accent-amber":"text-text-disabled"}`,children:g?f:"—"},void 0,!1,void 0,this),g&&z("button",{onClick:()=>c(e,{...u,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),z("div",{className:"relative h-6 flex items-center",children:[z("div",{className:"absolute left-0 right-0 h-1.5 rounded-full bg-border-medium",children:g&&z("div",{className:"h-full rounded-full bg-accent-amber transition-all duration-150",style:{width:`${P}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this),q&&Array.from({length:O+1},(B,ee)=>{let te=n+ee*r,se=(te-n)/(s-n)*100,V=g&&te<=f;return z("div",{className:`absolute rounded-full pointer-events-none transition-all duration-150 ${g&&te===f?"w-2.5 h-2.5 bg-accent-amber":V?"w-1.5 h-1.5 bg-accent-amber":"w-1.5 h-1.5 bg-border-hover"}`,style:{left:`${se}%`,transform:"translate(-50%, -50%)",top:"50%"}},ee,!1,void 0,this)}),g?z("div",{className:"absolute h-5 w-5 rounded-full bg-accent-amber shadow-md pointer-events-none transition-all duration-150",style:{left:`calc(${P}% - 10px)`,borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this):z("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),z("input",{type:"range",min:n,max:s,step:r,value:T,onChange:(B)=>h(Number(B.currentTarget.value)),className:"absolute inset-0 w-full opacity-0 cursor-pointer"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q&&O<=10?z("div",{className:"flex justify-between -mt-0.5 px-0",children:Array.from({length:O+1},(B,ee)=>{let te=n+ee*r;return z("span",{className:`text-[10px] font-mono transition-colors ${g&&te===f?"text-accent-amber font-medium":"text-text-disabled"}`,style:{minWidth:"1ch",textAlign:"center"},children:te},ee,!1,void 0,this)})},void 0,!1,void 0,this):z("div",{className:"flex justify-between -mt-0.5",children:[z("span",{className:"text-[11px] text-text-tertiary font-body",children:a||n},void 0,!1,void 0,this),z("span",{className:"text-[11px] text-text-tertiary font-body",children:l||s},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z(Je,{show:y,note:b,onToggle:()=>p(!y),onChange:(B)=>c(e,{...u,note:B})},void 0,!1,void 0,this),j&&z("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)}export{Us as Callout,Gs as Checklist,ea as Choice,sa as CodeBlock,aa as Diff,fa as FilePreview,xa as ImageView,Xr as Item,ya as Markdown,Ta as Mermaid,ta as MultiChoice,Sa as Note,Ca as Priority,ja as RangeInput,Ma as Section,La as Table,za as Task,Da as UserInput,Hd as useFeedback};