@nlux/core
Version:
nlux is JavaScript and React library for building conversational AI interfaces, with support for OpenAI, Hugging Face, and more.
1 lines • 148 kB
JavaScript
"use strict";var e=Object.defineProperty,t=(t,s,n)=>((t,s,n)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n)(t,"symbol"!=typeof s?s+"":s,n);class s extends Error{constructor(e={}){super(e.message),t(this,"exceptionId"),t(this,"message"),t(this,"source"),t(this,"type"),this.message=e.message??"",this.source=e.source,this.type=this.constructor.name,this.exceptionId=e.exceptionId}}class n extends s{}class o extends s{}class r extends s{}const i=e=>{"string"!=typeof e?e&&"function"==typeof e.toString?console.warn(`[nlux] ${e.toString()}`):console.warn("[nlux]"):console.warn(`[nlux] ${e}`)},a=[],c=e=>{a.includes(e)||(a.push(e),i(e))},l=class e{static register(t){const s=t.__compId;s?void 0===e.componentDefs.get(s)&&(t.__renderer&&t.__updater?e.componentDefs.set(s,{id:s,model:t,render:t.__renderer,update:t.__updater}):i(`Component with id "${s}" missing renderer or updater`)):i("Component definition missing valid id")}static retrieve(t){const s=e.componentDefs.get(t);if(s)return s;i(`Component with id "${t}" not registered`)}};l.componentDefs=new Map;let h=l;const d={version:"{versions.nlux}",[btoa("sectionsRegistered")]:!1},u=e=>{const t=requestAnimationFrame((()=>{e()}));return()=>{cancelAnimationFrame(t)}},p=e=>{e.replaceChildren()},m=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}));class g{constructor(e,t){this.subComponentElementIds=new Map,this.subComponents=new Map,this.__context=null,this.__destroyed=!1,this.__status="unmounted",this.actionsOnDomReady=[],this.compEventGetter=e=>{if(this.destroyed)return()=>{};const t=this.rendererEventListeners.get(e);if(!t)throw new s({source:this.constructor.name,message:`Unable to call renderer event "${e}" because no matching event listener was found. Make sure that the event listener is registered using @CompEventListener() decorator in the component model class, and use class methods instead of arrow function attributes.`});return t};const o=Object.getPrototypeOf(this).constructor.__compId;if(!o)throw new n({source:this.constructor.name,message:"Unable to instantiate component: missing compId in implementation. Component should be annotated using @Model() to set compId before iy can be instantiated."});if(this.def=h.retrieve(o)??null,!this.def)throw new n({source:this.constructor.name,message:`Unable to instantiate component "${o}" because it's not registered. Component should be registered using CompRegistry.register(ComponentClass) before instantiating a component.`});this.__instanceId=m(),this.__destroyed=!1,this.__context=e,this.renderedDom=null,this.renderingRoot=null,this.props=t;const r=t?Object.entries(t):[];this.elementProps=new Map(r),this.rendererEventListeners=new Map;const a=this.constructor.__compEventListeners;a&&a.forEach(((e,t)=>{e.forEach((e=>{const s=Object.getPrototypeOf(this)[e];"function"==typeof s?this.addRendererEventListener(t,s.bind(this)):i(`Unable to set event listener "${t}" because method "${e}" cannot be found on component "${this.constructor.name} at runtime!"`)}))})),this.rendererProps=Object.freeze(t)}get destroyed(){return this.__destroyed}get id(){return this.__instanceId}get rendered(){return null!==this.renderedDom}get root(){return this.throwIfDestroyed(),this.renderedDom&&this.renderingRoot?this.renderingRoot:null}get status(){return this.__status}get context(){if(!this.__context)throw new n({source:this.constructor.name,message:"Unable to get context because it's not set"});return this.__context}destroy(){this.destroyComponent()}destroyListItemComponent(){this.destroyComponent(!0)}getProp(e){return this.throwIfDestroyed(),this.elementProps.get(e)??null}render(e,t){if(!this.def)return;if(this.destroyed)return void i(`Unable to render component "${this.def?.id}" because it is already destroyed`);if(this.rendered||this.renderedDom)return void i(`Unable to render component "${this.def.id}" because it is already rendered`);const n=document.createDocumentFragment(),o=Object.getPrototypeOf(this).constructor.__compId,r=this.executeRenderer(n);if(!r)throw new s({source:this.constructor.name,message:`Unable to render component "${o}" because renderer returned null`});this.renderedDom=r;for(const[,e]of this.subComponents){const t=this.getSubComponentPortal(e.id);t&&this.mountSubComponentToPortal(e.id,t)}u((()=>{this.destroyed||(t?e.insertBefore(n,t):e.append(n),this.renderingRoot=e)}))}updateSubComponent(e,t,s){this.throwIfDestroyed();const n=this.subComponents.get(e);n&&!n.destroyed&&n.setProp(t,s)}addSubComponent(e,t,s){if(this.throwIfDestroyed(),this.subComponents.has(e))throw new n({source:this.constructor.name,message:`Unable to add sub-component "${e}" because it already exists`});if(this.subComponents.set(e,t),s&&this.subComponentElementIds.set(e,s),this.renderedDom){const t=this.getSubComponentPortal(e);t&&this.mountSubComponentToPortal(e,t)}}executeDomAction(e,...t){if(this.throwIfDestroyed(),!this.renderedDom)return void this.actionsOnDomReady.push((()=>this.executeDomAction(e,...t)));if(!this.renderingRoot)throw new s({source:this.constructor.name,message:"Unable to execute DOM action because renderingRoot is not set"});const n=this.renderedDom.actions[e];if(!n)throw new s({source:this.constructor.name,message:`Unable to execute DOM action "${String(e)}" because it does not exist`});return u((()=>n(...t)))}executeRenderer(e){const t=this.def?.render;if(!t)return null;if(this.renderingRoot)throw new s({source:this.constructor.name,message:"Unable to render component because renderingRoot is already set"});const n=t({appendToRoot:t=>{e.append(t),this.runDomActionsQueue()},compEvent:this.compEventGetter,props:this.rendererProps,context:this.context});return n&&(this.renderingRoot=e),n}removeSubComponent(e){this.throwIfDestroyed(),u((()=>{const t=this.subComponents.get(e);t&&(t.renderingRoot=null,t.destroy(),this.subComponents.delete(e))}))}runDomActionsQueue(){if(this.actionsOnDomReady.length>0&&this.rendered){const e=this.actionsOnDomReady;this.actionsOnDomReady=[];for(const t of e)u((()=>t()))}}setProp(e,t){this.destroyed?i(`Unable to set prop "${String(e)}" because component "${this.constructor.name}" is destroyed`):this.elementProps.has(e)?(this.schedulePropUpdate(e,this.elementProps.get(e),t),this.props=Object.freeze(Object.fromEntries(this.elementProps)),this.elementProps.set(e,t)):i(`Unable to set prop "${String(e)}" because it does not exist in the component props`)}throwIfDestroyed(){if(this.__destroyed)throw new n({source:this.constructor.name,message:"Unable to call method on destroyed component"})}addRendererEventListener(e,t){if(this.throwIfDestroyed(),this.rendererEventListeners.has(e))throw new n({source:this.constructor.name,message:`Unable to add event listener to rendererEvents "${e}" because it already exists`});this.rendererEventListeners.set(e,t)}destroyComponent(e=!1){if(this.throwIfDestroyed(),this.subComponents.forEach((e=>{e.destroy()})),this.renderedDom){this.renderedDom.elements&&(this.renderedDom.elements=void 0),this.renderedDom.actions&&(this.renderedDom.actions=void 0),this.renderedDom.onDestroy&&this.renderedDom.onDestroy();const t=this.renderingRoot;u((()=>{if(t)if(t instanceof DocumentFragment)for(;t.firstChild;)t.removeChild(t.firstChild);else e?t.parentElement?.removeChild(t):p(t)})),this.renderedDom=null,this.renderingRoot=null}this.__destroyed=!0,this.__context=null,this.props=void 0,this.elementProps.clear(),this.rendererEventListeners.clear(),this.subComponents.clear()}getSubComponentPortal(e){const t=this.subComponents.get(e),s=this.subComponentElementIds.get(e);if(!t||!s)return null;const n=(this.renderedDom?.elements)[s];return n instanceof HTMLElement?n:null}mountSubComponentToPortal(e,t){const s=this.subComponents.get(e);s?.render(t)}schedulePropUpdate(e,t,s){if(!this.renderedDom||!this.def?.update)return;const n=this.renderedDom,o=this.renderingRoot,r=this.def.update;o&&u((()=>{r({propName:e,currentValue:t,newValue:s,dom:{root:o,elements:n.elements,actions:n.actions},updateSubComponent:this.updateSubComponent})}))}}g.__compEventListeners=null,g.__compId=null,g.__renderer=null,g.__updater=null;const f=(e,t,s)=>n=>{n.__compId=e,n.__renderer=t,n.__updater=s},y=e=>(t,s)=>{const o=t;if("function"!=typeof o.constructor)throw new n({source:"CallbackFor",message:"@CallbackFor can only be used on methods of a class!"});o.constructor.hasOwnProperty("__compEventListeners")&&null!==o.constructor.__compEventListeners||(o.constructor.__compEventListeners=new Map);const r=o.constructor.__compEventListeners,i=r.get(e);i?i.push(s):r.set(e,[s])},w=(e,t)=>{const s=document.createElement("div");if(s.classList.add("nlux-comp-avatarContainer"),e){const t=document.createElement("div");t.classList.add("nlux-comp-avatarPicture"),t.style.backgroundImage=`url("${encodeURI(e)}")`,s.append(t)}return s},k="nlux-comp-avatar",x=e=>{const t=document.createElement("div");return t.classList.add(k),e.avatar||e.name?(e.name&&(t.title=e.name),e.avatar&&e.avatar instanceof HTMLElement?(t.append(e.avatar.cloneNode(!0)),t):(t.append(w(e.avatar)),t)):t},v={received:"nlux_msg_received",sent:"nlux_msg_sent"},b=(e,t)=>{Object.keys(v).forEach((t=>{e.classList.remove(v[t])})),v[t]&&e.classList.add(v[t])},C={streaming:"nlux_msg_streaming",complete:"nlux_msg_complete"},S=(e,t)=>{Object.keys(C).forEach((t=>{e.classList.remove(C[t])})),C[t]&&e.classList.add(C[t])},I=e=>{if(!(e instanceof HTMLButtonElement))return;if("true"===e.dataset.clickListenerSet)return;let t=!1;const s=e.nextElementSibling;e.addEventListener("click",(()=>{if(t||!s)return;const n=s.innerText;navigator.clipboard.writeText(n??""),t=!0,e.classList.add("clicked"),setTimeout((()=>{t=!1,e.classList.remove("clicked")}),1e3)})),e.dataset.clickListenerSet="true"},A=e=>{const t="nlux-comp-copyButton";e instanceof HTMLButtonElement&&e.classList.contains(t)?I(e):e.querySelectorAll(`.${t}`).forEach(I)};function P(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let E={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function T(e){E=e}var O=Object.defineProperty,B=(e,t,s)=>((e,t,s)=>t in e?O(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class L{constructor(e){B(this,"options"),this.options=e||E}postprocess(e){return e}preprocess(e){return e}processAllTokens(e){return e}}B(L,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));const D=/[&<>"']/,R=new RegExp(D.source,"g"),z=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,M=new RegExp(z.source,"g"),H={"&":"&","<":"<",">":">",'"':""","'":"'"},U=e=>H[e];function Q(e,t){if(t){if(D.test(e))return e.replace(R,U)}else if(z.test(e))return e.replace(M,U);return e}const N=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function F(e){return e.replace(N,((e,t)=>"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}const q=/(^|[^\[])\^/g;function j(e,t){let s="string"==typeof e?e:e.source;t=t||"";const n={replace:(e,t)=>{let o="string"==typeof t?t:t.source;return o=o.replace(q,"$1"),s=s.replace(e,o),n},getRegex:()=>new RegExp(s,t)};return n}function Y(e){try{e=encodeURI(e).replace(/%25/g,"%")}catch(e){return null}return e}const $={exec:()=>null};function W(e,t){const s=e.replace(/\|/g,((e,t,s)=>{let n=!1,o=t;for(;--o>=0&&"\\"===s[o];)n=!n;return n?"|":" |"})).split(/ \|/);let n=0;if(s[0].trim()||s.shift(),s.length>0&&!s[s.length-1].trim()&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;n<s.length;n++)s[n]=s[n].trim().replace(/\\\|/g,"|");return s}function X(e,t,s){const n=e.length;if(0===n)return"";let o=0;for(;o<n;){const r=e.charAt(n-o-1);if(r!==t||s){if(r===t||!s)break;o++}else o++}return e.slice(0,n-o)}const Z=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,G=/(?:[*+-]|\d{1,9}[.)])/,J=j(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,G).replace(/blockCode/g,/ {4}/).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/).getRegex(),K=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,V=/(?!\s*\])(?:\\.|[^\[\]\\])+/,_=j(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",V).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ee=j(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,G).getRegex(),te="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",se=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ne=j("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))","i").replace("comment",se).replace("tag",te).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),oe=j(K).replace("hr",Z).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",te).getRegex(),re={blockquote:j(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",oe).getRegex(),code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,def:_,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:Z,html:ne,lheading:J,list:ee,newline:/^(?: *(?:\n|$))+/,paragraph:oe,table:$,text:/^[^\n]+/},ie=j("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Z).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",te).getRegex(),ae={...re,table:ie,paragraph:j(K).replace("hr",Z).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ie).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",te).getRegex()},ce={...re,html:j("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",se).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:$,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:j(K).replace("hr",Z).replace("heading"," *#{1,6} *[^\n]").replace("lheading",J).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},le=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,he=/^( {2,}|\\)\n(?!\s*$)/,de="\\p{P}\\p{S}",ue=j(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,de).getRegex(),pe=j(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,de).getRegex(),me=j("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,de).getRegex(),ge=j("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,de).getRegex(),fe=j(/\\([punct])/,"gu").replace(/punct/g,de).getRegex(),ye=j(/^<(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(),we=j(se).replace("(?:--\x3e|$)","--\x3e").getRegex(),ke=j("^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",we).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),xe=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ve=j(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",xe).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),be=j(/^!?\[(label)\]\[(ref)\]/).replace("label",xe).replace("ref",V).getRegex(),Ce=j(/^!?\[(ref)\](?:\[\])?/).replace("ref",V).getRegex(),Se={_backpedal:$,anyPunctuation:fe,autolink:ye,blockSkip:/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,br:he,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:$,emStrongLDelim:pe,emStrongRDelimAst:me,emStrongRDelimUnd:ge,escape:le,link:ve,nolink:Ce,punctuation:ue,reflink:be,reflinkSearch:j("reflink|nolink(?!\\()","g").replace("reflink",be).replace("nolink",Ce).getRegex(),tag:ke,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:$},Ie={...Se,link:j(/^!?\[(label)\]\((.*?)\)/).replace("label",xe).getRegex(),reflink:j(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",xe).getRegex()},Ae={...Se,escape:j(le).replace("])","~|])").getRegex(),url:j(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").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~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},Pe={...Ae,br:j(he).replace("{2,}","*").getRegex(),text:j(Ae.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ee={normal:re,gfm:ae,pedantic:ce},Te={normal:Se,gfm:Ae,breaks:Pe,pedantic:Ie};var Oe=Object.defineProperty,Be=(e,t,s)=>((e,t,s)=>t in e?Oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);function Le(e,t,s,n){const o=t.href,r=t.title?Q(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if("!"!==e[0].charAt(0)){n.state.inLink=!0;const e={type:"link",raw:s,href:o,title:r,text:i,tokens:n.inlineTokens(i)};return n.state.inLink=!1,e}return{type:"image",raw:s,href:o,title:r,text:Q(i)}}class De{constructor(e){Be(this,"lexer"),Be(this,"options"),Be(this,"rules"),this.options=e||E}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let e,s;return"@"===t[2]?(e=Q(t[1]),s="mailto:"+e):(e=Q(t[1]),s=e),{type:"link",raw:t[0],text:e,href:s,tokens:[{type:"text",raw:e,text:e}]}}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){let e=t[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,"\n $1");e=X(e.replace(/^ *>[ \t]?/gm,""),"\n");const s=this.lexer.state.top;this.lexer.state.top=!0;const n=this.lexer.blockTokens(e);return this.lexer.state.top=s,{type:"blockquote",raw:t[0],tokens:n,text:e}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const e=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:X(e,"\n")}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g," ");const s=/[^ ]/.test(e),n=/^ /.test(e)&&/ $/.test(e);return s&&n&&(e=e.substring(1,e.length-1)),e=Q(e,!0),{type:"codespan",raw:t[0],text:e}}}def(e){const t=this.rules.block.def.exec(e);if(t){const e=t[1].toLowerCase().replace(/\s+/g," "),s=t[2]?t[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",n=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:s,title:n}}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}emStrong(e,t,s=""){let n=this.rules.inline.emStrongLDelim.exec(e);if(!n)return;if(n[3]&&s.match(/[\p{L}\p{N}]/u))return;if(!(n[1]||n[2]||"")||!s||this.rules.inline.punctuation.exec(s)){const s=[...n[0]].length-1;let o,r,i=s,a=0;const c="*"===n[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+s);null!=(n=c.exec(t));){if(o=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!o)continue;if(r=[...o].length,n[3]||n[4]){i+=r;continue}if((n[5]||n[6])&&s%3&&!((s+r)%3)){a+=r;continue}if(i-=r,i>0)continue;r=Math.min(r,r+i+a);const t=[...n[0]][0].length,c=e.slice(0,s+n.index+t+r);if(Math.min(s,r)%2){const e=c.slice(1,-1);return{type:"em",raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}const l=c.slice(2,-2);return{type:"strong",raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:Q(t[1])}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const e=t[0],s=function(e,t){const s=e.match(/^(\s+)(?:```)/);if(null===s)return t;const n=s[1];return t.split("\n").map((e=>{const t=e.match(/^\s+/);if(null===t)return e;const[s]=t;return s.length>=n.length?e.slice(n.length):e})).join("\n")}(e,t[3]||"");return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(/#$/.test(e)){const t=X(e,"#");this.options.pedantic?e=t.trim():t&&!/ $/.test(t)||(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}html(e){const t=this.rules.block.html.exec(e);if(t){return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){let e;return e=this.lexer.state.inRawBlock?t[0]:Q(t[0]),{type:"text",raw:t[0],text:e}}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}link(e){const t=this.rules.inline.link.exec(e);if(t){const e=t[2].trim();if(!this.options.pedantic&&/^</.test(e)){if(!/>$/.test(e))return;const t=X(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{const e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let s=0;for(let n=0;n<e.length;n++)if("\\"===e[n])n++;else if(e[n]===t[0])s++;else if(e[n]===t[1]&&(s--,s<0))return n;return-1}(t[2],"()");if(e>-1){const s=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,s).trim(),t[3]=""}}let s=t[2],n="";if(this.options.pedantic){const e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(s);e&&(s=e[1],n=e[3])}else n=t[3]?t[3].slice(1,-1):"";return s=s.trim(),/^</.test(s)&&(s=this.options.pedantic&&!/>$/.test(e)?s.slice(1):s.slice(1,-1)),Le(t,{href:s?s.replace(this.rules.inline.anyPunctuation,"$1"):s,title:n?n.replace(this.rules.inline.anyPunctuation,"$1"):n},t[0],this.lexer)}}list(e){let t=this.rules.block.list.exec(e);if(t){let s=t[1].trim();const n=s.length>1,o={type:"list",raw:"",ordered:n,start:n?+s.slice(0,-1):"",loose:!1,items:[]};s=n?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=n?s:"[*+-]");const r=new RegExp(`^( {0,3}${s})((?:[\t ][^\\n]*)?(?:\\n|$))`);let i="",a="",c=!1;for(;e;){let s=!1;if(!(t=r.exec(e)))break;if(this.rules.block.hr.test(e))break;i=t[0],e=e.substring(i.length);let n=t[2].split("\n",1)[0].replace(/^\t+/,(e=>" ".repeat(3*e.length))),l=e.split("\n",1)[0],h=0;this.options.pedantic?(h=2,a=n.trimStart()):(h=t[2].search(/[^ ]/),h=h>4?1:h,a=n.slice(h),h+=t[1].length);let d=!1;if(!n&&/^ *$/.test(l)&&(i+=l+"\n",e=e.substring(l.length+1),s=!0),!s){const t=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),s=new RegExp(`^ {0,${Math.min(3,h-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),o=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:\`\`\`|~~~)`),r=new RegExp(`^ {0,${Math.min(3,h-1)}}#`);for(;e;){const c=e.split("\n",1)[0];if(l=c,this.options.pedantic&&(l=l.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),o.test(l))break;if(r.test(l))break;if(t.test(l))break;if(s.test(e))break;if(l.search(/[^ ]/)>=h||!l.trim())a+="\n"+l.slice(h);else{if(d)break;if(n.search(/[^ ]/)>=4)break;if(o.test(n))break;if(r.test(n))break;if(s.test(n))break;a+="\n"+l}d||l.trim()||(d=!0),i+=c+"\n",e=e.substring(c.length+1),n=l.slice(h)}}o.loose||(c?o.loose=!0:/\n *\n *$/.test(i)&&(c=!0));let u,p=null;this.options.gfm&&(p=/^\[[ xX]\] /.exec(a),p&&(u="[ ] "!==p[0],a=a.replace(/^\[[ xX]\] +/,""))),o.items.push({type:"list_item",raw:i,task:!!p,checked:u,loose:!1,text:a,tokens:[]}),o.raw+=i}o.items[o.items.length-1].raw=i.trimEnd(),o.items[o.items.length-1].text=a.trimEnd(),o.raw=o.raw.trimEnd();for(let e=0;e<o.items.length;e++)if(this.lexer.state.top=!1,o.items[e].tokens=this.lexer.blockTokens(o.items[e].text,[]),!o.loose){const t=o.items[e].tokens.filter((e=>"space"===e.type)),s=t.length>0&&t.some((e=>/\n.*\n/.test(e.raw)));o.loose=s}if(o.loose)for(let e=0;e<o.items.length;e++)o.items[e].loose=!0;return o}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}reflink(e,t){let s;if((s=this.rules.inline.reflink.exec(e))||(s=this.rules.inline.nolink.exec(e))){const e=t[(s[2]||s[1]).replace(/\s+/g," ").toLowerCase()];if(!e){const e=s[0].charAt(0);return{type:"text",raw:e,text:e}}return Le(s,e,s[0],this.lexer)}}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}table(e){const t=this.rules.block.table.exec(e);if(!t)return;if(!/[:|]/.test(t[2]))return;const s=W(t[1]),n=t[2].replace(/^\||\| *$/g,"").split("|"),o=t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split("\n"):[],r={type:"table",raw:t[0],header:[],align:[],rows:[]};if(s.length===n.length){for(const e of n)/^ *-+: *$/.test(e)?r.align.push("right"):/^ *:-+: *$/.test(e)?r.align.push("center"):/^ *:-+ *$/.test(e)?r.align.push("left"):r.align.push(null);for(const e of s)r.header.push({text:e,tokens:this.lexer.inline(e)});for(const e of o)r.rows.push(W(e,r.header.length).map((e=>({text:e,tokens:this.lexer.inline(e)}))));return r}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.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]}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,s;if("@"===t[2])e=Q(t[0]),s="mailto:"+e;else{let n;do{n=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(n!==t[0]);e=Q(t[0]),s="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:s,tokens:[{type:"text",raw:e,text:e}]}}}}var Re=Object.defineProperty,ze=(e,t,s)=>((e,t,s)=>t in e?Re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Me{constructor(e){ze(this,"options"),ze(this,"state"),ze(this,"tokens"),ze(this,"inlineQueue"),ze(this,"tokenizer"),this.tokens=[],this.tokens.links=Object.create(null),this.options=e||E,this.options.tokenizer=this.options.tokenizer||new De,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={block:Ee.normal,inline:Te.normal};this.options.pedantic?(t.block=Ee.pedantic,t.inline=Te.pedantic):this.options.gfm&&(t.block=Ee.gfm,this.options.breaks?t.inline=Te.breaks:t.inline=Te.gfm),this.tokenizer.rules=t}static get rules(){return{block:Ee,inline:Te}}static lex(e,t){return new Me(t).lex(e)}static lexInline(e,t){return new Me(t).inlineTokens(e)}blockTokens(e,t=[]){let s,n,o,r;for(e=this.options.pedantic?e.replace(/\t/g," ").replace(/^ +$/gm,""):e.replace(/^( *)(\t+)/gm,((e,t,s)=>t+" ".repeat(s.length)));e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some((n=>!!(s=n.call({lexer:this},e,t))&&(e=e.substring(s.raw.length),t.push(s),!0)))))if(s=this.tokenizer.space(e))e=e.substring(s.raw.length),1===s.raw.length&&t.length>0?t[t.length-1].raw+="\n":t.push(s);else if(s=this.tokenizer.code(e))e=e.substring(s.raw.length),n=t[t.length-1],!n||"paragraph"!==n.type&&"text"!==n.type?t.push(s):(n.raw+="\n"+s.raw,n.text+="\n"+s.text,this.inlineQueue[this.inlineQueue.length-1].src=n.text);else if(s=this.tokenizer.fences(e))e=e.substring(s.raw.length),t.push(s);else if(s=this.tokenizer.heading(e))e=e.substring(s.raw.length),t.push(s);else if(s=this.tokenizer.hr(e))e=e.substring(s.raw.length),t.push(s);else if(s=this.tokenizer.blockquote(e))e=e.substring(s.raw.length),t.push(s);else if(s=this.tokenizer.list(e))e=e.substring(s.raw.length),t.push(s);else if(s=this.tokenizer.html(e))e=e.substring(s.raw.length),t.push(s);else if(s=this.tokenizer.def(e))e=e.substring(s.raw.length),n=t[t.length-1],!n||"paragraph"!==n.type&&"text"!==n.type?this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title}):(n.raw+="\n"+s.raw,n.text+="\n"+s.raw,this.inlineQueue[this.inlineQueue.length-1].src=n.text);else if(s=this.tokenizer.table(e))e=e.substring(s.raw.length),t.push(s);else if(s=this.tokenizer.lheading(e))e=e.substring(s.raw.length),t.push(s);else{if(o=e,this.options.extensions&&this.options.extensions.startBlock){let t=1/0;const s=e.slice(1);let n;this.options.extensions.startBlock.forEach((e=>{n=e.call({lexer:this},s),"number"==typeof n&&n>=0&&(t=Math.min(t,n))})),t<1/0&&t>=0&&(o=e.substring(0,t+1))}if(this.state.top&&(s=this.tokenizer.paragraph(o)))n=t[t.length-1],r&&"paragraph"===n.type?(n.raw+="\n"+s.raw,n.text+="\n"+s.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=n.text):t.push(s),r=o.length!==e.length,e=e.substring(s.raw.length);else if(s=this.tokenizer.text(e))e=e.substring(s.raw.length),n=t[t.length-1],n&&"text"===n.type?(n.raw+="\n"+s.raw,n.text+="\n"+s.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=n.text):t.push(s);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let s,n,o,r,i,a,c=e;if(this.tokens.links){const e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(r=this.tokenizer.rules.inline.reflinkSearch.exec(c));)e.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(c=c.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+c.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(r=this.tokenizer.rules.inline.blockSkip.exec(c));)c=c.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+c.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(r=this.tokenizer.rules.inline.anyPunctuation.exec(c));)c=c.slice(0,r.index)+"++"+c.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(i||(a=""),i=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some((n=>!!(s=n.call({lexer:this},e,t))&&(e=e.substring(s.raw.length),t.push(s),!0)))))if(s=this.tokenizer.escape(e))e=e.substring(s.raw.length),t.push(s);else if(s=this.tokenizer.tag(e))e=e.substring(s.raw.length),n=t[t.length-1],n&&"text"===s.type&&"text"===n.type?(n.raw+=s.raw,n.text+=s.text):t.push(s);else if(s=this.tokenizer.link(e))e=e.substring(s.raw.length),t.push(s);else if(s=this.tokenizer.reflink(e,this.tokens.links))e=e.substring(s.raw.length),n=t[t.length-1],n&&"text"===s.type&&"text"===n.type?(n.raw+=s.raw,n.text+=s.text):t.push(s);else if(s=this.tokenizer.emStrong(e,c,a))e=e.substring(s.raw.length),t.push(s);else if(s=this.tokenizer.codespan(e))e=e.substring(s.raw.length),t.push(s);else if(s=this.tokenizer.br(e))e=e.substring(s.raw.length),t.push(s);else if(s=this.tokenizer.del(e))e=e.substring(s.raw.length),t.push(s);else if(s=this.tokenizer.autolink(e))e=e.substring(s.raw.length),t.push(s);else if(this.state.inLink||!(s=this.tokenizer.url(e))){if(o=e,this.options.extensions&&this.options.extensions.startInline){let t=1/0;const s=e.slice(1);let n;this.options.extensions.startInline.forEach((e=>{n=e.call({lexer:this},s),"number"==typeof n&&n>=0&&(t=Math.min(t,n))})),t<1/0&&t>=0&&(o=e.substring(0,t+1))}if(s=this.tokenizer.inlineText(o))e=e.substring(s.raw.length),"_"!==s.raw.slice(-1)&&(a=s.raw.slice(-1)),i=!0,n=t[t.length-1],n&&"text"===n.type?(n.raw+=s.raw,n.text+=s.text):t.push(s);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}else e=e.substring(s.raw.length),t.push(s);return t}lex(e){e=e.replace(/\r\n|\r/g,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){const t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}}var He=Object.defineProperty,Ue=(e,t,s)=>((e,t,s)=>t in e?He(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,t+"",s);class Qe{constructor(e){Ue(this,"options"),this.options=e||E}blockquote(e){return`<blockquote>\n${e}</blockquote>\n`}br(){return"<br>"}checkbox(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}code(e,t,s){const n=(t||"").match(/^\S*/)?.[0];return e=e.replace(/\n$/,"")+"\n",n?'<pre><code class="language-'+Q(n)+'">'+(s?e:Q(e,!0))+"</code></pre>\n":"<pre><code>"+(s?e:Q(e,!0))+"</code></pre>\n"}codespan(e){return`<code>${e}</code>`}del(e){return`<del>${e}</del>`}em(e){return`<em>${e}</em>`}heading(e,t,s){return`<h${t}>${e}</h${t}>\n`}hr(){return"<hr>\n"}html(e,t){return e}image(e,t,s){const n=Y(e);if(null===n)return s;let o=`<img src="${e=n}" alt="${s}"`;return t&&(o+=` title="${t}"`),o+=">",o}link(e,t,s){const n=Y(e);if(null===n)return s;let o='<a href="'+(e=n)+'"';return t&&(o+=' title="'+t+'"'),o+=">"+s+"</a>",o}list(e,t,s){const n=t?"ol":"ul";return"<"+n+(t&&1!==s?' start="'+s+'"':"")+">\n"+e+"</"+n+">\n"}listitem(e,t,s){return`<li>${e}</li>\n`}paragraph(e){return`<p>${e}</p>\n`}strong(e){return`<strong>${e}</strong>`}table(e,t){return t&&(t=`<tbody>${t}</tbody>`),"<table>\n<thead>\n"+e+"</thead>\n"+t+"</table>\n"}tablecell(e,t){const s=t.header?"th":"td";return(t.align?`<${s} align="${t.align}">`:`<${s}>`)+e+`</${s}>\n`}tablerow(e){return`<tr>\n${e}</tr>\n`}text(e){return e}}class Ne{br(){return""}codespan(e){return e}del(e){return e}em(e){return e}html(e){return e}image(e,t,s){return""+s}link(e,t,s){return""+s}strong(e){return e}text(e){return e}}var Fe=Object.defineProperty,qe=(e,t,s)=>((e,t,s)=>t in e?Fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class je{constructor(e){qe(this,"options"),qe(this,"renderer"),qe(this,"textRenderer"),this.options=e||E,this.options.renderer=this.options.renderer||new Qe,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Ne}static parse(e,t){return new je(t).parse(e)}static parseInline(e,t){return new je(t).parseInline(e)}parse(e,t=!0){let s="";for(let n=0;n<e.length;n++){const o=e[n];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[o.type]){const e=o,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==t||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(e.type)){s+=t||"";continue}}switch(o.type){case"space":continue;case"hr":s+=this.renderer.hr();continue;case"heading":{const e=o;s+=this.renderer.heading(this.parseInline(e.tokens),e.depth,F(this.parseInline(e.tokens,this.textRenderer)));continue}case"code":{const e=o;s+=this.renderer.code(e.text,e.lang,!!e.escaped);continue}case"table":{const e=o;let t="",n="";for(let t=0;t<e.header.length;t++)n+=this.renderer.tablecell(this.parseInline(e.header[t].tokens),{header:!0,align:e.align[t]});t+=this.renderer.tablerow(n);let r="";for(let t=0;t<e.rows.length;t++){const s=e.rows[t];n="";for(let t=0;t<s.length;t++)n+=this.renderer.tablecell(this.parseInline(s[t].tokens),{header:!1,align:e.align[t]});r+=this.renderer.tablerow(n)}s+=this.renderer.table(t,r);continue}case"blockquote":{const e=o,t=this.parse(e.tokens);s+=this.renderer.blockquote(t);continue}case"list":{const e=o,t=e.ordered,n=e.start,r=e.loose;let i="";for(let t=0;t<e.items.length;t++){const s=e.items[t],n=s.checked,o=s.task;let a="";if(s.task){const e=this.renderer.checkbox(!!n);r?s.tokens.length>0&&"paragraph"===s.tokens[0].type?(s.tokens[0].text=e+" "+s.tokens[0].text,s.tokens[0].tokens&&s.tokens[0].tokens.length>0&&"text"===s.tokens[0].tokens[0].type&&(s.tokens[0].tokens[0].text=e+" "+s.tokens[0].tokens[0].text)):s.tokens.unshift({type:"text",text:e+" "}):a+=e+" "}a+=this.parse(s.tokens,r),i+=this.renderer.listitem(a,o,!!n)}s+=this.renderer.list(i,t,n);continue}case"html":{const e=o;s+=this.renderer.html(e.text,e.block);continue}case"paragraph":{const e=o;s+=this.renderer.paragraph(this.parseInline(e.tokens));continue}case"text":{let r=o,i=r.tokens?this.parseInline(r.tokens):r.text;for(;n+1<e.length&&"text"===e[n+1].type;)r=e[++n],i+="\n"+(r.tokens?this.parseInline(r.tokens):r.text);s+=t?this.renderer.paragraph(i):i;continue}default:{const e='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return s}parseInline(e,t){t=t||this.renderer;let s="";for(let n=0;n<e.length;n++){const o=e[n];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[o.type]){const e=this.options.extensions.renderers[o.type].call({parser:this},o);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){s+=e||"";continue}}switch(o.type){case"escape":{const e=o;s+=t.text(e.text);break}case"html":{const e=o;s+=t.html(e.text);break}case"link":{const e=o;s+=t.link(e.href,e.title,this.parseInline(e.tokens,t));break}case"image":{const e=o;s+=t.image(e.href,e.title,e.text);break}case"strong":{const e=o;s+=t.strong(this.parseInline(e.tokens,t));break}case"em":{const e=o;s+=t.em(this.parseInline(e.tokens,t));break}case"codespan":{const e=o;s+=t.codespan(e.text);break}case"br":s+=t.br();break;case"del":{const e=o;s+=t.del(this.parseInline(e.tokens,t));break}case"text":{const e=o;s+=t.text(e.text);break}default:{const e='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return s}}var Ye,$e,We,Xe=Object.defineProperty,Ze=e=>{throw TypeError(e)},Ge=(e,t,s)=>((e,t,s)=>t in e?Xe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s),Je=(e,t,s)=>(((e,t,s)=>{t.has(e)||Ze("Cannot "+s)})(e,t,"access private method"),s);Ye=new WeakSet,$e=function(e,t){return s=>{if(s.message+="\nPlease report this to https://github.com/markedjs/marked.",e){const e="<p>An error occurred:</p><pre>"+Q(s.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(s);throw s}},We=function(e,t){return(s,n)=>{const o={...n},r={...this.defaults,...o};!0===this.defaults.async&&!1===o.async&&(r.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),r.async=!0);const i=Je(this,Ye,$e).call(this,!!r.silent,!!r.async);if(null==s)return i(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof s)return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(s)+", string expected"));if(r.hooks&&(r.hooks.options=r),r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(s):s).then((t=>e(t,r))).then((e=>r.hooks?r.hooks.processAllTokens(e):e)).then((e=>r.walkTokens?Promise.all(this.walkTokens(e,r.walkTokens)).then((()=>e)):e)).then((e=>t(e,r))).then((e=>r.hooks?r.hooks.postprocess(e):e)).catch(i);try{r.hooks&&(s=r.hooks.preprocess(s));let n=e(s,r);r.hooks&&(n=r.hooks.processAllTokens(n)),r.walkTokens&&this.walkTokens(n,r.walkTokens);let o=t(n,r);return r.hooks&&(o=r.hooks.postprocess(o)),o}catch(e){return i(e)}}};const Ke=new class{constructor(...e){var t,s,n;t=this,(s=Ye).has(t)?Ze("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,n),Ge(this,"Hooks",L),Ge(this,"Lexer",Me),Ge(this,"Parser",je),Ge(this,"Renderer",Qe),Ge(this,"TextRenderer",Ne),Ge(this,"Tokenizer",De),Ge(this,"defaults",{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}),Ge(this,"options",this.setOptions),Ge(this,"parse",Je(this,Ye,We).call(this,Me.lex,je.parse)),Ge(this,"parseInline",Je(this,Ye,We).call(this,Me.lexInline,je.parseInline)),this.use(...e)}lexer(e,t){return Me.lex(e,t??this.defaults)}parser(e,t){return je.parse(e,t??this.defaults)}setOptions(e){return this.defaults={...this.defaults,...e},this}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((e=>{const s={...e};if(s.async=this.defaults.async||s.async||!1,e.extensions&&(e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){const s=t.renderers[e.name];t.renderers[e.name]=s?function(...t){let n=e.renderer.apply(this,t);return!1===n&&(n=s.apply(this,t)),n}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");const s=t[e.level];s?s.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)})),s.extensions=t),e.renderer){const t=this.defaults.renderer||new Qe(this.defaults);for(const s in e.renderer){if(!(s in t))throw new Error(`renderer '${s}' does not exist`);if("options"===s)continue;const n=s,o=e.renderer[n],r=t[n];t[n]=(...e)=>{let s=o.apply(t,e);return!1===s&&(s=r.apply(t,e)),s||""}}s.renderer=t}if(e.tokenizer){const t=this.defaults.tokenizer||new De(this.defaults);for(const s in e.tokenizer){if(!(s in t))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;const n=s,o=e.tokenizer[n],r=t[n];t[n]=(...e)=>{let s=o.apply(t,e);return!1===s&&(s=r.apply(t,e)),s}}s.tokenizer=t}if(e.hooks){const t=this.defaults.hooks||new L;for(const s in e.hooks){if(!(s in t))throw new Error(`hook '${s}' does not exist`);if("options"===s)continue;const n=s,o=e.hooks[n],r=t[n];L.passThroughHooks.has(s)?t[n]=e=>{if(this.defaults.async)return Promise.resolve(o.call(t,e)).then((e=>r.call(t,e)));const s=o.call(t,e);return r.call(t,s)}:t[n]=(...e)=>{let s=o.apply(t,e);return!1===s&&(s=r.apply(t,e)),s}}s.hooks=t}if(e.walkTokens){const t=this.defaults.walkTokens,n=e.walkTokens;s.walkTokens=function(e){let s=[];return s.push(n.call(this,e)),t&&(s=s.concat(t.call(this,e))),s}}this.defaults={...this.defaults,...s}})),this}walkTokens(e,t){let s=[];for(const n of e)switch(s=s.concat(t.call(this,n)),n.type){case"table":{const e=n;for(const n of e.header)s=s.concat(this.walkTokens(n.tokens,t));for(const n of e.rows)for(const e of n)s=s.concat(this.walkTokens(e.tokens,t));break}case"list":{const e=n;s=s.concat(this.walkTokens(e.items,t));break}default:{const e=n;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach((n=>{const o=e[n].flat(1/0);s=s.concat(this.walkTokens(o,t))})):e.tokens&&(s=s.concat(this.walkTokens(e.tokens,t)))}}return s}};function Ve(e,t){return Ke.parse(e,t)}Ve.options=Ve.setOptions=function(e){return Ke.setOptions(e),Ve.defaults=Ke.defaults,T(Ve.defaults),Ve},Ve.getDefaults=P,Ve.defaults=E,Ve.use=function(...e){return Ke.use(...e),Ve.defaults=Ke.defaults,T(Ve.defaults),Ve},Ve.walkTokens=function(e,t){return Ke.walkTokens(e,t)},Ve.parseInline=Ke.parseInline,Ve.Parser=je,Ve.parser=je.parse,Ve.Renderer=Qe,Ve.TextRenderer=Ne,Ve.Lexer=Me,Ve.lexer=Me.lex,Ve.Tokenizer=De,Ve.Hooks=L,Ve.parse=Ve;const _e=(e,t)=>{const{showCodeBlockCopyButton:s,markdownLinkTarget:n,syntaxHighlighter:o,htmlSanitizer:r}=t||{},i=Ve(e,{async:!1,breaks:!0});if("string"!=typeof i)throw new Error("Markdown parsing failed");const a=document.createElement("div");return a.innerHTML=r?r(i):i,a.querySelectorAll("pre").forEach((e=>{const s=document.createElement("div");s.className="code-block";const n=e.querySelector("code");if(!n){const t=e.innerHTML;return s.innerHTML=r?r(t):t,void e.replaceWith(s)}let i;for(let e=0;e<n.classList.length;e++){const t=n.classList[e];if(t.startsWith("language-")){i=t.slice(9);break}}const a=document.createElement("pre"),c="<div>"+n.innerHTML+"</div>";if(a.innerHTML=t?.htmlSanitizer?t.htmlSanitizer(c):c,i&&(a.setAttribute("data-language",i),o)){const e="<div>"+o.createHighlighter()(n.textContent||"",i)+"</div>";a.innerHTML=r?r(e):e,a.className="highlighter-dark"}p(s),s.appendChild(a),e.replaceWith(s)})),!1!==s&&a.querySelectorAll(".code-block").forEach((e=>{if(!e.querySelector("pre"))return;if(e.previousElementSibling?.classList.contains("nlux-comp-copyButton"))return;const t="Copy code block to clipboard",s=document.createElement("button");s.classList.add("nlux-comp-copyButton"),s.setAttribute("aria-label",t),s.setAttribute("title",t);const n=document.createElement("span");n.classList.add("icon-copy"),s.appendChild(n),e.appendChild(s)})),"self"!==n&&a.querySelectorAll("a").forEach((e=>{e.setAttribute("target","_blank")})),a.innerHTML},et=(e,t="text",s)=>{if("markdown"===t){const t=document.createElement("div"),n=_e(e,s);t.innerHTML=s?.htmlSanitizer?s.htmlSanitizer(n):n,A(t);const o=document.createDocumentFragment();for(;t.firstChild;)o.appendChild(t.firstChild);return o}return document.createTextNode(e)},tt="nlux-comp-message",st={received:"nlux-comp-chatItem--received",sent:"nlux-comp-chatItem--sent"},nt=(e,t)=>{Object.keys(st).forEach((t=>{e.classList.remove(st[t])})),st[t]&&e.classList.add(st[t])},ot={bubbles:"nlux-comp-chatItem--bubblesLayout",list:"nlux-comp-chatItem--listLayout"},rt=(e,t)=>{Object.keys(ot).forEach((t=>{e.classList.remove(ot[t])})),ot[t]&&e.classList.add(ot[t])},it="nlux-comp-chatItem-participantInfo",at="nlux-comp-chatItem-participantName",ct=e=>{const t=document.createElement("div");t.classList.add("nlux-comp-chatItem");const s={direction:e.direction,status:e.status,message:e.message,htmlSanitizer:e.htmlSanitizer};let n;if(void 0!==e.avatar){const t={name:e.name,avatar:e.avatar};n=x(t)}const o=document.createElement("span");o.classList.add(at),o.textContent=e.name;{const e=document.createElement("div");e.classList.add(it),void 0!==n&&e.append(n),e.append(o),t.append(e)}nt(t,e.direction),rt(t,e.layout);const r=(e=>{const t=document.createElement("div");t.classList.add(tt);const s=e.status?e.status:"complete";return S(t,s),b(t,e.direction),t})(s);return t.append(r),t},lt=(e,t,s)=>{if(t.name!==s.name&&"string"==typeof s.avatar){const t=s.name&&s.name.length>0?s.name[0].toUpperCase():"",n=e.querySelector("* > .nlux-comp-avatarContainer > .avtr_ltr");n?.replaceChildren(t)}},ht=(e,t,s)=>{t.avatar===s.avatar&&t.name===s.name||(t.avatar!==s.avatar&&((e,t,s)=>{if(t.avatar!==s.avatar)if("string"==typeof s.avatar&&"string"==typeof t.avatar){const t=e.querySelector("* > .nlux-comp-avatarContainer > .nlux-comp-avatarPicture");null!==t&&(t.style.backgroundImage=`url("${encodeURI(s.avatar)}")`)}else if("string"==typeof s.avatar){const t=w(s.avatar);e.replaceChildren(t)}else s.avatar?e.replaceChildren(s.avatar.cloneNode(!0)):p(e)})(e,t,s),s.name?t.name!==s.name&&(e.title=s.name,lt(e,t,s)):(e.title="",lt(e,t,s)))},dt=(e,t,s)=>{if(t.message===s.message&&t.status===s.status&&t.direction===s.direction)return;if(!s||!s.hasOwnProperty("message")&&!s.hasOwnProperty("status")&&!s.hasOwnProperty("direction"))return;t.dire