Xenova HF staff commited on
Commit
078fce2
1 Parent(s): 4b53236

Update assets/index-DrdC1ZCt.js

Browse files
Files changed (1) hide show
  1. assets/index-DrdC1ZCt.js +1 -1
assets/index-DrdC1ZCt.js CHANGED
@@ -83,4 +83,4 @@ ${t}</tr>
83
  `}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){const l=Ja(t);if(l===null)return r;t=l;let i='<a href="'+t+'"';return n&&(i+=' title="'+n+'"'),i+=">"+r+"</a>",i}image(t,n,r){const l=Ja(t);if(l===null)return r;t=l;let i=`<img src="${t}" alt="${r}"`;return n&&(i+=` title="${n}"`),i+=">",i}text(t){return t}}class vu{strong(t){return t}em(t){return t}codespan(t){return t}del(t){return t}html(t){return t}text(t){return t}link(t,n,r){return""+r}image(t,n,r){return""+r}br(){return""}}class ft{constructor(t){Y(this,"options");Y(this,"renderer");Y(this,"textRenderer");this.options=t||pn,this.options.renderer=this.options.renderer||new pi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new vu}static parse(t,n){return new ft(n).parse(t)}static parseInline(t,n){return new ft(n).parseInline(t)}parse(t,n=!0){let r="";for(let l=0;l<t.length;l++){const i=t[l];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[i.type]){const o=i,s=this.options.extensions.renderers[o.type].call({parser:this},o);if(s!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(o.type)){r+=s||"";continue}}switch(i.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{const o=i;r+=this.renderer.heading(this.parseInline(o.tokens),o.depth,Lm(this.parseInline(o.tokens,this.textRenderer)));continue}case"code":{const o=i;r+=this.renderer.code(o.text,o.lang,!!o.escaped);continue}case"table":{const o=i;let s="",u="";for(let m=0;m<o.header.length;m++)u+=this.renderer.tablecell(this.parseInline(o.header[m].tokens),{header:!0,align:o.align[m]});s+=this.renderer.tablerow(u);let a="";for(let m=0;m<o.rows.length;m++){const g=o.rows[m];u="";for(let h=0;h<g.length;h++)u+=this.renderer.tablecell(this.parseInline(g[h].tokens),{header:!1,align:o.align[h]});a+=this.renderer.tablerow(u)}r+=this.renderer.table(s,a);continue}case"blockquote":{const o=i,s=this.parse(o.tokens);r+=this.renderer.blockquote(s);continue}case"list":{const o=i,s=o.ordered,u=o.start,a=o.loose;let m="";for(let g=0;g<o.items.length;g++){const h=o.items[g],y=h.checked,w=h.task;let x="";if(h.task){const M=this.renderer.checkbox(!!y);a?h.tokens.length>0&&h.tokens[0].type==="paragraph"?(h.tokens[0].text=M+" "+h.tokens[0].text,h.tokens[0].tokens&&h.tokens[0].tokens.length>0&&h.tokens[0].tokens[0].type==="text"&&(h.tokens[0].tokens[0].text=M+" "+h.tokens[0].tokens[0].text)):h.tokens.unshift({type:"text",text:M+" "}):x+=M+" "}x+=this.parse(h.tokens,a),m+=this.renderer.listitem(x,w,!!y)}r+=this.renderer.list(m,s,u);continue}case"html":{const o=i;r+=this.renderer.html(o.text,o.block);continue}case"paragraph":{const o=i;r+=this.renderer.paragraph(this.parseInline(o.tokens));continue}case"text":{let o=i,s=o.tokens?this.parseInline(o.tokens):o.text;for(;l+1<t.length&&t[l+1].type==="text";)o=t[++l],s+=`
84
  `+(o.tokens?this.parseInline(o.tokens):o.text);r+=n?this.renderer.paragraph(s):s;continue}default:{const o='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return r}parseInline(t,n){n=n||this.renderer;let r="";for(let l=0;l<t.length;l++){const i=t[l];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[i.type]){const o=this.options.extensions.renderers[i.type].call({parser:this},i);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){r+=o||"";continue}}switch(i.type){case"escape":{const o=i;r+=n.text(o.text);break}case"html":{const o=i;r+=n.html(o.text);break}case"link":{const o=i;r+=n.link(o.href,o.title,this.parseInline(o.tokens,n));break}case"image":{const o=i;r+=n.image(o.href,o.title,o.text);break}case"strong":{const o=i;r+=n.strong(this.parseInline(o.tokens,n));break}case"em":{const o=i;r+=n.em(this.parseInline(o.tokens,n));break}case"codespan":{const o=i;r+=n.codespan(o.text);break}case"br":{r+=n.br();break}case"del":{const o=i;r+=n.del(this.parseInline(o.tokens,n));break}case"text":{const o=i;r+=n.text(o.text);break}default:{const o='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return r}}class Nr{constructor(t){Y(this,"options");this.options=t||pn}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}}Y(Nr,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));var Qr,ms,hi,Od;class ig{constructor(...t){Hi(this,Qr);Hi(this,hi);Y(this,"defaults",du());Y(this,"options",this.setOptions);Y(this,"parse",il(this,Qr,ms).call(this,ct.lex,ft.parse));Y(this,"parseInline",il(this,Qr,ms).call(this,ct.lexInline,ft.parseInline));Y(this,"Parser",ft);Y(this,"Renderer",pi);Y(this,"TextRenderer",vu);Y(this,"Lexer",ct);Y(this,"Tokenizer",fi);Y(this,"Hooks",Nr);this.use(...t)}walkTokens(t,n){var l,i;let r=[];for(const o of t)switch(r=r.concat(n.call(this,o)),o.type){case"table":{const s=o;for(const u of s.header)r=r.concat(this.walkTokens(u.tokens,n));for(const u of s.rows)for(const a of u)r=r.concat(this.walkTokens(a.tokens,n));break}case"list":{const s=o;r=r.concat(this.walkTokens(s.items,n));break}default:{const s=o;(i=(l=this.defaults.extensions)==null?void 0:l.childTokens)!=null&&i[s.type]?this.defaults.extensions.childTokens[s.type].forEach(u=>{const a=s[u].flat(1/0);r=r.concat(this.walkTokens(a,n))}):s.tokens&&(r=r.concat(this.walkTokens(s.tokens,n)))}}return r}use(...t){const n=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(r=>{const l={...r};if(l.async=this.defaults.async||l.async||!1,r.extensions&&(r.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){const o=n.renderers[i.name];o?n.renderers[i.name]=function(...s){let u=i.renderer.apply(this,s);return u===!1&&(u=o.apply(this,s)),u}:n.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const o=n[i.level];o?o.unshift(i.tokenizer):n[i.level]=[i.tokenizer],i.start&&(i.level==="block"?n.startBlock?n.startBlock.push(i.start):n.startBlock=[i.start]:i.level==="inline"&&(n.startInline?n.startInline.push(i.start):n.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(n.childTokens[i.name]=i.childTokens)}),l.extensions=n),r.renderer){const i=this.defaults.renderer||new pi(this.defaults);for(const o in r.renderer){if(!(o in i))throw new Error(`renderer '${o}' does not exist`);if(o==="options")continue;const s=o,u=r.renderer[s],a=i[s];i[s]=(...m)=>{let g=u.apply(i,m);return g===!1&&(g=a.apply(i,m)),g||""}}l.renderer=i}if(r.tokenizer){const i=this.defaults.tokenizer||new fi(this.defaults);for(const o in r.tokenizer){if(!(o in i))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;const s=o,u=r.tokenizer[s],a=i[s];i[s]=(...m)=>{let g=u.apply(i,m);return g===!1&&(g=a.apply(i,m)),g}}l.tokenizer=i}if(r.hooks){const i=this.defaults.hooks||new Nr;for(const o in r.hooks){if(!(o in i))throw new Error(`hook '${o}' does not exist`);if(o==="options")continue;const s=o,u=r.hooks[s],a=i[s];Nr.passThroughHooks.has(o)?i[s]=m=>{if(this.defaults.async)return Promise.resolve(u.call(i,m)).then(h=>a.call(i,h));const g=u.call(i,m);return a.call(i,g)}:i[s]=(...m)=>{let g=u.apply(i,m);return g===!1&&(g=a.apply(i,m)),g}}l.hooks=i}if(r.walkTokens){const i=this.defaults.walkTokens,o=r.walkTokens;l.walkTokens=function(s){let u=[];return u.push(o.call(this,s)),i&&(u=u.concat(i.call(this,s))),u}}this.defaults={...this.defaults,...l}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,n){return ct.lex(t,n??this.defaults)}parser(t,n){return ft.parse(t,n??this.defaults)}}Qr=new WeakSet,ms=function(t,n){return(r,l)=>{const i={...l},o={...this.defaults,...i};this.defaults.async===!0&&i.async===!1&&(o.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),o.async=!0);const s=il(this,hi,Od).call(this,!!o.silent,!!o.async);if(typeof r>"u"||r===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));if(o.hooks&&(o.hooks.options=o),o.async)return Promise.resolve(o.hooks?o.hooks.preprocess(r):r).then(u=>t(u,o)).then(u=>o.hooks?o.hooks.processAllTokens(u):u).then(u=>o.walkTokens?Promise.all(this.walkTokens(u,o.walkTokens)).then(()=>u):u).then(u=>n(u,o)).then(u=>o.hooks?o.hooks.postprocess(u):u).catch(s);try{o.hooks&&(r=o.hooks.preprocess(r));let u=t(r,o);o.hooks&&(u=o.hooks.processAllTokens(u)),o.walkTokens&&this.walkTokens(u,o.walkTokens);let a=n(u,o);return o.hooks&&(a=o.hooks.postprocess(a)),a}catch(u){return s(u)}}},hi=new WeakSet,Od=function(t,n){return r=>{if(r.message+=`
85
  Please report this to https://github.com/markedjs/marked.`,t){const l="<p>An error occurred:</p><pre>"+Me(r.message+"",!0)+"</pre>";return n?Promise.resolve(l):l}if(n)return Promise.reject(r);throw r}};const cn=new ig;function H(e,t){return cn.parse(e,t)}H.options=H.setOptions=function(e){return cn.setOptions(e),H.defaults=cn.defaults,_d(H.defaults),H};H.getDefaults=du;H.defaults=pn;H.use=function(...e){return cn.use(...e),H.defaults=cn.defaults,_d(H.defaults),H};H.walkTokens=function(e,t){return cn.walkTokens(e,t)};H.parseInline=cn.parseInline;H.Parser=ft;H.parser=ft.parse;H.Renderer=pi;H.TextRenderer=vu;H.Lexer=ct;H.lexer=ct.lex;H.Tokenizer=fi;H.Hooks=Nr;H.parse=H;H.options;H.setOptions;H.use;H.walkTokens;H.parseInline;ft.parse;ct.lex;/*! @license DOMPurify 3.1.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.5/LICENSE */const{entries:Md,setPrototypeOf:nc,isFrozen:og,getPrototypeOf:sg,getOwnPropertyDescriptor:ug}=Object;let{freeze:_e,seal:Xe,create:Dd}=Object,{apply:gs,construct:ys}=typeof Reflect<"u"&&Reflect;_e||(_e=function(t){return t});Xe||(Xe=function(t){return t});gs||(gs=function(t,n,r){return t.apply(n,r)});ys||(ys=function(t,n){return new t(...n)});const Tl=$e(Array.prototype.forEach),rc=$e(Array.prototype.pop),ar=$e(Array.prototype.push),Ul=$e(String.prototype.toLowerCase),go=$e(String.prototype.toString),lc=$e(String.prototype.match),cr=$e(String.prototype.replace),ag=$e(String.prototype.indexOf),cg=$e(String.prototype.trim),Je=$e(Object.prototype.hasOwnProperty),xe=$e(RegExp.prototype.test),fr=fg(TypeError);function $e(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),l=1;l<n;l++)r[l-1]=arguments[l];return gs(e,t,r)}}function fg(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return ys(e,n)}}function j(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ul;nc&&nc(e,null);let r=t.length;for(;r--;){let l=t[r];if(typeof l=="string"){const i=n(l);i!==l&&(og(t)||(t[r]=i),l=i)}e[l]=!0}return e}function dg(e){for(let t=0;t<e.length;t++)Je(e,t)||(e[t]=null);return e}function Jt(e){const t=Dd(null);for(const[n,r]of Md(e))Je(e,n)&&(Array.isArray(r)?t[n]=dg(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=Jt(r):t[n]=r);return t}function Cl(e,t){for(;e!==null;){const r=ug(e,t);if(r){if(r.get)return $e(r.get);if(typeof r.value=="function")return $e(r.value)}e=sg(e)}function n(){return null}return n}const ic=_e(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),yo=_e(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),vo=_e(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),pg=_e(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ko=_e(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),hg=_e(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),oc=_e(["#text"]),sc=_e(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),wo=_e(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),uc=_e(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Nl=_e(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),mg=Xe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),gg=Xe(/<%[\w\W]*|[\w\W]*%>/gm),yg=Xe(/\${[\w\W]*}/gm),vg=Xe(/^data-[\-\w.\u00B7-\uFFFF]/),kg=Xe(/^aria-[\-\w]+$/),jd=Xe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),wg=Xe(/^(?:\w+script|data):/i),xg=Xe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Fd=Xe(/^html$/i),Sg=Xe(/^[a-z][.\w]*(-[.\w]+)+$/i);var ac=Object.freeze({__proto__:null,MUSTACHE_EXPR:mg,ERB_EXPR:gg,TMPLIT_EXPR:yg,DATA_ATTR:vg,ARIA_ATTR:kg,IS_ALLOWED_URI:jd,IS_SCRIPT_OR_DATA:wg,ATTR_WHITESPACE:xg,DOCTYPE_NAME:Fd,CUSTOM_ELEMENT:Sg});const dr={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Eg=function(){return typeof window>"u"?null:window},_g=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const l="data-tt-policy-suffix";n&&n.hasAttribute(l)&&(r=n.getAttribute(l));const i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}};function $d(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Eg();const t=z=>$d(z);if(t.version="3.1.5",t.removed=[],!e||!e.document||e.document.nodeType!==dr.document)return t.isSupported=!1,t;let{document:n}=e;const r=n,l=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:o,Node:s,Element:u,NodeFilter:a,NamedNodeMap:m=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:g,DOMParser:h,trustedTypes:y}=e,w=u.prototype,x=Cl(w,"cloneNode"),M=Cl(w,"nextSibling"),p=Cl(w,"childNodes"),c=Cl(w,"parentNode");if(typeof o=="function"){const z=n.createElement("template");z.content&&z.content.ownerDocument&&(n=z.content.ownerDocument)}let d,v="";const{implementation:T,createNodeIterator:E,createDocumentFragment:C,getElementsByTagName:N}=n,{importNode:$}=r;let I={};t.isSupported=typeof Md=="function"&&typeof c=="function"&&T&&T.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ce,ERB_EXPR:Ne,TMPLIT_EXPR:He,DATA_ATTR:br,ARIA_ATTR:zi,IS_SCRIPT_OR_DATA:Zn,ATTR_WHITESPACE:hn,CUSTOM_ELEMENT:R}=ac;let{IS_ALLOWED_URI:O}=ac,A=null;const Z=j({},[...ic,...yo,...vo,...ko,...oc]);let D=null;const Yt=j({},[...sc,...wo,...uc,...Nl]);let B=Object.seal(Dd(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ht=null,Ze=null,Kt=!0,Ii=!0,ku=!1,wu=!0,mn=!1,Oi=!0,Xt=!1,Mi=!1,Di=!1,gn=!1,el=!1,tl=!1,xu=!0,Su=!1;const Ud="user-content-";let ji=!0,qn=!1,yn={},vn=null;const Eu=j({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let _u=null;const Tu=j({},["audio","video","img","source","image","track"]);let Fi=null;const Cu=j({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),nl="http://www.w3.org/1998/Math/MathML",rl="http://www.w3.org/2000/svg",mt="http://www.w3.org/1999/xhtml";let kn=mt,$i=!1,Ui=null;const Bd=j({},[nl,rl,mt],go);let Jn=null;const Hd=["application/xhtml+xml","text/html"],Wd="text/html";let oe=null,wn=null;const Vd=n.createElement("form"),Nu=function(f){return f instanceof RegExp||f instanceof Function},Bi=function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(wn&&wn===f)){if((!f||typeof f!="object")&&(f={}),f=Jt(f),Jn=Hd.indexOf(f.PARSER_MEDIA_TYPE)===-1?Wd:f.PARSER_MEDIA_TYPE,oe=Jn==="application/xhtml+xml"?go:Ul,A=Je(f,"ALLOWED_TAGS")?j({},f.ALLOWED_TAGS,oe):Z,D=Je(f,"ALLOWED_ATTR")?j({},f.ALLOWED_ATTR,oe):Yt,Ui=Je(f,"ALLOWED_NAMESPACES")?j({},f.ALLOWED_NAMESPACES,go):Bd,Fi=Je(f,"ADD_URI_SAFE_ATTR")?j(Jt(Cu),f.ADD_URI_SAFE_ATTR,oe):Cu,_u=Je(f,"ADD_DATA_URI_TAGS")?j(Jt(Tu),f.ADD_DATA_URI_TAGS,oe):Tu,vn=Je(f,"FORBID_CONTENTS")?j({},f.FORBID_CONTENTS,oe):Eu,ht=Je(f,"FORBID_TAGS")?j({},f.FORBID_TAGS,oe):{},Ze=Je(f,"FORBID_ATTR")?j({},f.FORBID_ATTR,oe):{},yn=Je(f,"USE_PROFILES")?f.USE_PROFILES:!1,Kt=f.ALLOW_ARIA_ATTR!==!1,Ii=f.ALLOW_DATA_ATTR!==!1,ku=f.ALLOW_UNKNOWN_PROTOCOLS||!1,wu=f.ALLOW_SELF_CLOSE_IN_ATTR!==!1,mn=f.SAFE_FOR_TEMPLATES||!1,Oi=f.SAFE_FOR_XML!==!1,Xt=f.WHOLE_DOCUMENT||!1,gn=f.RETURN_DOM||!1,el=f.RETURN_DOM_FRAGMENT||!1,tl=f.RETURN_TRUSTED_TYPE||!1,Di=f.FORCE_BODY||!1,xu=f.SANITIZE_DOM!==!1,Su=f.SANITIZE_NAMED_PROPS||!1,ji=f.KEEP_CONTENT!==!1,qn=f.IN_PLACE||!1,O=f.ALLOWED_URI_REGEXP||jd,kn=f.NAMESPACE||mt,B=f.CUSTOM_ELEMENT_HANDLING||{},f.CUSTOM_ELEMENT_HANDLING&&Nu(f.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(B.tagNameCheck=f.CUSTOM_ELEMENT_HANDLING.tagNameCheck),f.CUSTOM_ELEMENT_HANDLING&&Nu(f.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(B.attributeNameCheck=f.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),f.CUSTOM_ELEMENT_HANDLING&&typeof f.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(B.allowCustomizedBuiltInElements=f.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),mn&&(Ii=!1),el&&(gn=!0),yn&&(A=j({},oc),D=[],yn.html===!0&&(j(A,ic),j(D,sc)),yn.svg===!0&&(j(A,yo),j(D,wo),j(D,Nl)),yn.svgFilters===!0&&(j(A,vo),j(D,wo),j(D,Nl)),yn.mathMl===!0&&(j(A,ko),j(D,uc),j(D,Nl))),f.ADD_TAGS&&(A===Z&&(A=Jt(A)),j(A,f.ADD_TAGS,oe)),f.ADD_ATTR&&(D===Yt&&(D=Jt(D)),j(D,f.ADD_ATTR,oe)),f.ADD_URI_SAFE_ATTR&&j(Fi,f.ADD_URI_SAFE_ATTR,oe),f.FORBID_CONTENTS&&(vn===Eu&&(vn=Jt(vn)),j(vn,f.FORBID_CONTENTS,oe)),ji&&(A["#text"]=!0),Xt&&j(A,["html","head","body"]),A.table&&(j(A,["tbody"]),delete ht.tbody),f.TRUSTED_TYPES_POLICY){if(typeof f.TRUSTED_TYPES_POLICY.createHTML!="function")throw fr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof f.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw fr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');d=f.TRUSTED_TYPES_POLICY,v=d.createHTML("")}else d===void 0&&(d=_g(y,l)),d!==null&&typeof v=="string"&&(v=d.createHTML(""));_e&&_e(f),wn=f}},Ru=j({},["mi","mo","mn","ms","mtext"]),Lu=j({},["foreignobject","annotation-xml"]),Qd=j({},["title","style","font","a","script"]),Pu=j({},[...yo,...vo,...pg]),Au=j({},[...ko,...hg]),Gd=function(f){let S=c(f);(!S||!S.tagName)&&(S={namespaceURI:kn,tagName:"template"});const P=Ul(f.tagName),Q=Ul(S.tagName);return Ui[f.namespaceURI]?f.namespaceURI===rl?S.namespaceURI===mt?P==="svg":S.namespaceURI===nl?P==="svg"&&(Q==="annotation-xml"||Ru[Q]):!!Pu[P]:f.namespaceURI===nl?S.namespaceURI===mt?P==="math":S.namespaceURI===rl?P==="math"&&Lu[Q]:!!Au[P]:f.namespaceURI===mt?S.namespaceURI===rl&&!Lu[Q]||S.namespaceURI===nl&&!Ru[Q]?!1:!Au[P]&&(Qd[P]||!Pu[P]):!!(Jn==="application/xhtml+xml"&&Ui[f.namespaceURI]):!1},it=function(f){ar(t.removed,{element:f});try{f.parentNode.removeChild(f)}catch{f.remove()}},ll=function(f,S){try{ar(t.removed,{attribute:S.getAttributeNode(f),from:S})}catch{ar(t.removed,{attribute:null,from:S})}if(S.removeAttribute(f),f==="is"&&!D[f])if(gn||el)try{it(S)}catch{}else try{S.setAttribute(f,"")}catch{}},zu=function(f){let S=null,P=null;if(Di)f="<remove></remove>"+f;else{const fe=lc(f,/^[\r\n\t ]+/);P=fe&&fe[0]}Jn==="application/xhtml+xml"&&kn===mt&&(f='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+f+"</body></html>");const Q=d?d.createHTML(f):f;if(kn===mt)try{S=new h().parseFromString(Q,Jn)}catch{}if(!S||!S.documentElement){S=T.createDocument(kn,"template",null);try{S.documentElement.innerHTML=$i?v:Q}catch{}}const me=S.body||S.documentElement;return f&&P&&me.insertBefore(n.createTextNode(P),me.childNodes[0]||null),kn===mt?N.call(S,Xt?"html":"body")[0]:Xt?S.documentElement:me},Iu=function(f){return E.call(f.ownerDocument||f,f,a.SHOW_ELEMENT|a.SHOW_COMMENT|a.SHOW_TEXT|a.SHOW_PROCESSING_INSTRUCTION|a.SHOW_CDATA_SECTION,null)},Ou=function(f){return f instanceof g&&(typeof f.nodeName!="string"||typeof f.textContent!="string"||typeof f.removeChild!="function"||!(f.attributes instanceof m)||typeof f.removeAttribute!="function"||typeof f.setAttribute!="function"||typeof f.namespaceURI!="string"||typeof f.insertBefore!="function"||typeof f.hasChildNodes!="function")},Mu=function(f){return typeof s=="function"&&f instanceof s},gt=function(f,S,P){I[f]&&Tl(I[f],Q=>{Q.call(t,S,P,wn)})},Du=function(f){let S=null;if(gt("beforeSanitizeElements",f,null),Ou(f))return it(f),!0;const P=oe(f.nodeName);if(gt("uponSanitizeElement",f,{tagName:P,allowedTags:A}),f.hasChildNodes()&&!Mu(f.firstElementChild)&&xe(/<[/\w]/g,f.innerHTML)&&xe(/<[/\w]/g,f.textContent)||f.nodeType===dr.progressingInstruction||Oi&&f.nodeType===dr.comment&&xe(/<[/\w]/g,f.data))return it(f),!0;if(!A[P]||ht[P]){if(!ht[P]&&Fu(P)&&(B.tagNameCheck instanceof RegExp&&xe(B.tagNameCheck,P)||B.tagNameCheck instanceof Function&&B.tagNameCheck(P)))return!1;if(ji&&!vn[P]){const Q=c(f)||f.parentNode,me=p(f)||f.childNodes;if(me&&Q){const fe=me.length;for(let Re=fe-1;Re>=0;--Re){const ot=x(me[Re],!0);ot.__removalCount=(f.__removalCount||0)+1,Q.insertBefore(ot,M(f))}}}return it(f),!0}return f instanceof u&&!Gd(f)||(P==="noscript"||P==="noembed"||P==="noframes")&&xe(/<\/no(script|embed|frames)/i,f.innerHTML)?(it(f),!0):(mn&&f.nodeType===dr.text&&(S=f.textContent,Tl([ce,Ne,He],Q=>{S=cr(S,Q," ")}),f.textContent!==S&&(ar(t.removed,{element:f.cloneNode()}),f.textContent=S)),gt("afterSanitizeElements",f,null),!1)},ju=function(f,S,P){if(xu&&(S==="id"||S==="name")&&(P in n||P in Vd))return!1;if(!(Ii&&!Ze[S]&&xe(br,S))){if(!(Kt&&xe(zi,S))){if(!D[S]||Ze[S]){if(!(Fu(f)&&(B.tagNameCheck instanceof RegExp&&xe(B.tagNameCheck,f)||B.tagNameCheck instanceof Function&&B.tagNameCheck(f))&&(B.attributeNameCheck instanceof RegExp&&xe(B.attributeNameCheck,S)||B.attributeNameCheck instanceof Function&&B.attributeNameCheck(S))||S==="is"&&B.allowCustomizedBuiltInElements&&(B.tagNameCheck instanceof RegExp&&xe(B.tagNameCheck,P)||B.tagNameCheck instanceof Function&&B.tagNameCheck(P))))return!1}else if(!Fi[S]){if(!xe(O,cr(P,hn,""))){if(!((S==="src"||S==="xlink:href"||S==="href")&&f!=="script"&&ag(P,"data:")===0&&_u[f])){if(!(ku&&!xe(Zn,cr(P,hn,"")))){if(P)return!1}}}}}}return!0},Fu=function(f){return f!=="annotation-xml"&&lc(f,R)},$u=function(f){gt("beforeSanitizeAttributes",f,null);const{attributes:S}=f;if(!S)return;const P={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:D};let Q=S.length;for(;Q--;){const me=S[Q],{name:fe,namespaceURI:Re,value:ot}=me,bn=oe(fe);let we=fe==="value"?ot:cg(ot);if(P.attrName=bn,P.attrValue=we,P.keepAttr=!0,P.forceKeepAttr=void 0,gt("uponSanitizeAttribute",f,P),we=P.attrValue,P.forceKeepAttr||(ll(fe,f),!P.keepAttr))continue;if(!wu&&xe(/\/>/i,we)){ll(fe,f);continue}if(Oi&&xe(/((--!?|])>)|<\/(style|title)/i,we)){ll(fe,f);continue}mn&&Tl([ce,Ne,He],Bu=>{we=cr(we,Bu," ")});const Uu=oe(f.nodeName);if(ju(Uu,bn,we)){if(Su&&(bn==="id"||bn==="name")&&(ll(fe,f),we=Ud+we),d&&typeof y=="object"&&typeof y.getAttributeType=="function"&&!Re)switch(y.getAttributeType(Uu,bn)){case"TrustedHTML":{we=d.createHTML(we);break}case"TrustedScriptURL":{we=d.createScriptURL(we);break}}try{Re?f.setAttributeNS(Re,fe,we):f.setAttribute(fe,we),Ou(f)?it(f):rc(t.removed)}catch{}}}gt("afterSanitizeAttributes",f,null)},Yd=function z(f){let S=null;const P=Iu(f);for(gt("beforeSanitizeShadowDOM",f,null);S=P.nextNode();)gt("uponSanitizeShadowNode",S,null),!Du(S)&&(S.content instanceof i&&z(S.content),$u(S));gt("afterSanitizeShadowDOM",f,null)};return t.sanitize=function(z){let f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},S=null,P=null,Q=null,me=null;if($i=!z,$i&&(z="<!-->"),typeof z!="string"&&!Mu(z))if(typeof z.toString=="function"){if(z=z.toString(),typeof z!="string")throw fr("dirty is not a string, aborting")}else throw fr("toString is not a function");if(!t.isSupported)return z;if(Mi||Bi(f),t.removed=[],typeof z=="string"&&(qn=!1),qn){if(z.nodeName){const ot=oe(z.nodeName);if(!A[ot]||ht[ot])throw fr("root node is forbidden and cannot be sanitized in-place")}}else if(z instanceof s)S=zu("<!---->"),P=S.ownerDocument.importNode(z,!0),P.nodeType===dr.element&&P.nodeName==="BODY"||P.nodeName==="HTML"?S=P:S.appendChild(P);else{if(!gn&&!mn&&!Xt&&z.indexOf("<")===-1)return d&&tl?d.createHTML(z):z;if(S=zu(z),!S)return gn?null:tl?v:""}S&&Di&&it(S.firstChild);const fe=Iu(qn?z:S);for(;Q=fe.nextNode();)Du(Q)||(Q.content instanceof i&&Yd(Q.content),$u(Q));if(qn)return z;if(gn){if(el)for(me=C.call(S.ownerDocument);S.firstChild;)me.appendChild(S.firstChild);else me=S;return(D.shadowroot||D.shadowrootmode)&&(me=$.call(r,me,!0)),me}let Re=Xt?S.outerHTML:S.innerHTML;return Xt&&A["!doctype"]&&S.ownerDocument&&S.ownerDocument.doctype&&S.ownerDocument.doctype.name&&xe(Fd,S.ownerDocument.doctype.name)&&(Re="<!DOCTYPE "+S.ownerDocument.doctype.name+`>
86
- `+Re),mn&&Tl([ce,Ne,He],ot=>{Re=cr(Re,ot," ")}),d&&tl?d.createHTML(Re):Re},t.setConfig=function(){let z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Bi(z),Mi=!0},t.clearConfig=function(){wn=null,Mi=!1},t.isValidAttribute=function(z,f,S){wn||Bi({});const P=oe(z),Q=oe(f);return ju(P,Q,S)},t.addHook=function(z,f){typeof f=="function"&&(I[z]=I[z]||[],ar(I[z],f))},t.removeHook=function(z){if(I[z])return rc(I[z])},t.removeHooks=function(z){I[z]&&(I[z]=[])},t.removeAllHooks=function(){I={}},t}var Tg=$d();function Cg(e){return _.jsxs("svg",{...e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[_.jsx("path",{d:"M12 8V4H8"}),_.jsx("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),_.jsx("path",{d:"M2 14h2"}),_.jsx("path",{d:"M20 14h2"}),_.jsx("path",{d:"M15 13v2"}),_.jsx("path",{d:"M9 13v2"})]})}function Ng(e){return _.jsxs("svg",{...e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[_.jsx("path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}),_.jsx("circle",{cx:"12",cy:"7",r:"4"})]})}function Rg({messages:e}){const t=e.length===0;return _.jsx("div",{className:`flex-1 p-6 max-w-[960px] w-full ${t?"flex flex-col items-center justify-end":"space-y-4"}`,children:t?_.jsx("div",{className:"text-xl",children:"Ready!"}):e.map((n,r)=>_.jsx("div",{className:"flex items-start space-x-4",children:n.role==="assistant"?_.jsxs(_.Fragment,{children:[_.jsx(Cg,{className:"h-6 w-6 min-h-6 min-w-6 my-3 text-gray-500 dark:text-gray-300"}),_.jsx("div",{className:"bg-gray-200 dark:bg-gray-700 rounded-lg p-4",children:_.jsx("p",{className:"min-h-6 text-gray-800 dark:text-gray-200 overflow-wrap-anywhere",children:n.content.length>0?_.jsx("span",{className:"markdown",dangerouslySetInnerHTML:{__html:Tg.sanitize(H.parse(n.content))}}):_.jsxs("span",{className:"h-6 flex items-center gap-1",children:[_.jsx("span",{className:"w-2.5 h-2.5 bg-gray-600 dark:bg-gray-300 rounded-full animate-pulse"}),_.jsx("span",{className:"w-2.5 h-2.5 bg-gray-600 dark:bg-gray-300 rounded-full animate-pulse animation-delay-200"}),_.jsx("span",{className:"w-2.5 h-2.5 bg-gray-600 dark:bg-gray-300 rounded-full animate-pulse animation-delay-400"})]})})})]}):_.jsxs(_.Fragment,{children:[_.jsx(Ng,{className:"h-6 w-6 min-h-6 min-w-6 my-3 text-gray-500 dark:text-gray-300"}),_.jsx("div",{className:"bg-blue-500 text-white rounded-lg p-4",children:_.jsx("p",{className:"min-h-6 overflow-wrap-anywhere",children:n.content})})]})},`message-${r}`))})}function cc(e){return _.jsxs("svg",{...e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[_.jsx("path",{d:"M5 12h14"}),_.jsx("path",{d:"m12 5 7 7-7 7"})]})}function Lg(e){return _.jsxs("svg",{...e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[_.jsx("path",{d:"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"}),_.jsx("path",{fill:"currentColor",d:"M9 9.563C9 9.252 9.252 9 9.563 9h4.874c.311 0 .563.252.563.563v4.874c0 .311-.252.563-.563.563H9.564A.562.562 0 0 1 9 14.437V9.564Z"})]})}function Pg(e){const t=e==0?0:Math.floor(Math.log(e)/Math.log(1024));return+(e/Math.pow(1024,t)).toFixed(2)*1+["B","kB","MB","GB","TB"][t]}function Ag({text:e,percentage:t,total:n}){return t??(t=0),_.jsx("div",{className:"w-full bg-gray-100 dark:bg-gray-700 text-left rounded-lg overflow-hidden mb-0.5",children:_.jsxs("div",{className:"bg-blue-400 whitespace-nowrap px-1 text-sm",style:{width:`${t}%`},children:[e," (",t.toFixed(2),"%",isNaN(n)?"":` of ${Pg(n)}`,")"]})})}const zg=!!navigator.gpu,Ig=120;function Og(){const e=se.useRef(null),t=se.useRef(null),n=se.useRef(null),[r,l]=se.useState(null),[i,o]=se.useState(""),[s,u]=se.useState([]),[a,m]=se.useState(!1),[g,h]=se.useState(""),[y,w]=se.useState([]),[x,M]=se.useState(null),[p,c]=se.useState(null);function d(E){w(C=>[...C,{role:"user",content:E}]),M(null),m(!0),h("")}se.useEffect(()=>{T()},[g]);function v(){e.current.postMessage({type:"interrupt"})}function T(){if(!t.current)return;const E=t.current;E.style.height="auto";const C=Math.min(Math.max(E.scrollHeight,24),200);E.style.height=`${C}px`}return se.useEffect(()=>{e.current||(e.current=new Worker(new URL("/assets/worker-CqnEQYb0.js",import.meta.url),{type:"module"}));const E=C=>{switch(C.data.status){case"loading":l("loading"),o(C.data.data);break;case"initiate":u(N=>[...N,C.data]);break;case"progress":u(N=>N.map($=>$.file===C.data.file?{...$,...C.data}:$));break;case"done":u(N=>N.filter($=>$.file!==C.data.file));break;case"ready":l("ready");break;case"start":w(N=>[...N,{role:"assistant",content:""}]);break;case"update":{const{output:N,tps:$,numTokens:I}=C.data;M($),c(I),w(ce=>{const Ne=[...ce],He=Ne.at(-1);return Ne[Ne.length-1]={...He,content:He.content+N},Ne})}break;case"complete":m(!1);break}};return e.current.addEventListener("message",E),()=>{e.current.removeEventListener("message",E)}},[]),se.useEffect(()=>{y.filter(E=>E.role==="user").length!==0&&y.at(-1).role!=="assistant"&&(M(null),e.current.postMessage({type:"generate",data:y}))},[y,a]),se.useEffect(()=>{if(n.current&&a){const E=n.current;E.scrollHeight-E.scrollTop-E.clientHeight<Ig&&(E.scrollTop=E.scrollHeight)}},[y,a]),zg?_.jsxs("div",{className:"flex flex-col h-screen mx-auto items justify-end text-gray-800 dark:text-gray-200 bg-white dark:bg-gray-900",children:[r===null&&y.length===0&&_.jsxs("div",{className:"h-full overflow-auto scrollbar-thin flex justify-center items-center flex-col relative",children:[_.jsxs("div",{className:"flex flex-col items-center mb-1 max-w-[300px] text-center",children:[_.jsx("img",{src:"logo.png",width:"85%",height:"auto",className:"block"}),_.jsx("h1",{className:"text-4xl font-bold mb-1",children:"Qwen2 WebGPU"}),_.jsx("h2",{className:"font-semibold",children:"A private and powerful AI chatbot that runs locally in your browser."})]}),_.jsxs("div",{className:"flex flex-col items-center px-4",children:[_.jsxs("p",{className:"max-w-[514px] mb-4",children:[_.jsx("br",{}),"You are about to load ",_.jsx("a",{href:"https://huggingface.co/Qwen/Qwen2-0.5B-Instruct",target:"_blank",rel:"noreferrer",className:"font-medium underline",children:"Qwen2-0.5B-Instruct"}),", a 1.54 billion parameter LLM that is optimized for inference on the web. Once downloaded, the model (750 MB) will be cached and reused when you revisit the page.",_.jsx("br",{}),_.jsx("br",{}),"Everything runs directly in your browser using ",_.jsx("a",{href:"https://huggingface.co/docs/transformers.js",target:"_blank",rel:"noreferrer",className:"underline",children:"🤗 Transformers.js"})," and ONNX Runtime Web, meaning your conversations aren't sent to a server. You can even disconnect from the internet after the model has loaded!"]}),_.jsx("button",{className:"border px-4 py-2 rounded-lg bg-blue-400 text-white hover:bg-blue-500 disabled:bg-blue-100 disabled:cursor-not-allowed select-none",onClick:()=>{e.current.postMessage({type:"load"}),l("loading")},disabled:r!==null,children:"Load model"})]})]}),r==="loading"&&_.jsx(_.Fragment,{children:_.jsxs("div",{className:"w-full max-w-[500px] text-left mx-auto p-4 bottom-0 mt-auto",children:[_.jsx("p",{className:"text-center mb-1",children:i}),s.map(({file:E,progress:C,total:N},$)=>_.jsx(Ag,{text:E,percentage:C,total:N},$))]})}),r==="ready"&&_.jsxs("div",{ref:n,className:"overflow-y-auto scrollbar-thin w-full flex flex-col items-center h-full",children:[_.jsx(Rg,{messages:y}),_.jsx("p",{className:"text-center text-sm min-h-6 text-gray-500 dark:text-gray-300",children:x&&y.length>0&&_.jsxs(_.Fragment,{children:[!a&&_.jsxs("span",{children:["Generated ",p," tokens in ",(p/x).toFixed(2)," seconds ("]}),_.jsxs(_.Fragment,{children:[_.jsx("span",{className:"font-medium text-center mr-1 text-black dark:text-white",children:x.toFixed(2)}),_.jsx("span",{className:"text-gray-500 dark:text-gray-300",children:"tokens/second"})]}),!a&&_.jsxs(_.Fragment,{children:[_.jsx("span",{className:"mr-1",children:")."}),_.jsx("span",{className:"underline cursor-pointer",onClick:()=>{e.current.postMessage({type:"reset"}),w([])},children:"Reset"})]})]})})]}),_.jsxs("div",{className:"mt-2 border dark:bg-gray-700 rounded-lg w-[600px] max-w-[80%] max-h-[200px] mx-auto relative mb-3 flex",children:[_.jsx("textarea",{ref:t,className:"scrollbar-thin w-[550px] dark:bg-gray-700 px-3 py-4 rounded-lg bg-transparent border-none outline-none text-gray-800 disabled:text-gray-400 dark:text-gray-200 placeholder-gray-500 dark:placeholder-gray-400 disabled:placeholder-gray-200 resize-none disabled:cursor-not-allowed",placeholder:"Type your message...",type:"text",rows:1,value:g,disabled:r!=="ready",title:r==="ready"?"Model is ready":"Model not loaded yet",onKeyDown:E=>{g.length>0&&!a&&E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),d(g))},onInput:E=>h(E.target.value)}),a?_.jsx("div",{className:"cursor-pointer",onClick:v,children:_.jsx(Lg,{className:"h-8 w-8 p-1 rounded-md text-gray-800 dark:text-gray-100 absolute right-3 bottom-3"})}):g.length>0?_.jsx("div",{className:"cursor-pointer",onClick:()=>d(g),children:_.jsx(cc,{className:"h-8 w-8 p-1 bg-gray-800 dark:bg-gray-100 text-white dark:text-black rounded-md absolute right-3 bottom-3"})}):_.jsx("div",{children:_.jsx(cc,{className:"h-8 w-8 p-1 bg-gray-200 dark:bg-gray-600 text-gray-50 dark:text-gray-800 rounded-md absolute right-3 bottom-3"})})]}),_.jsx("p",{className:"text-xs text-gray-400 text-center mb-3",children:"Disclaimer: Generated content may be inaccurate or false."})]}):_.jsxs("div",{className:"fixed w-screen h-screen bg-black z-10 bg-opacity-[92%] text-white text-2xl font-semibold flex justify-center items-center text-center",children:["WebGPU is not supported",_.jsx("br",{}),"by this browser :("]})}xo.createRoot(document.getElementById("root")).render(_.jsx(pp.StrictMode,{children:_.jsx(Og,{})}));
 
83
  `}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){const l=Ja(t);if(l===null)return r;t=l;let i='<a href="'+t+'"';return n&&(i+=' title="'+n+'"'),i+=">"+r+"</a>",i}image(t,n,r){const l=Ja(t);if(l===null)return r;t=l;let i=`<img src="${t}" alt="${r}"`;return n&&(i+=` title="${n}"`),i+=">",i}text(t){return t}}class vu{strong(t){return t}em(t){return t}codespan(t){return t}del(t){return t}html(t){return t}text(t){return t}link(t,n,r){return""+r}image(t,n,r){return""+r}br(){return""}}class ft{constructor(t){Y(this,"options");Y(this,"renderer");Y(this,"textRenderer");this.options=t||pn,this.options.renderer=this.options.renderer||new pi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new vu}static parse(t,n){return new ft(n).parse(t)}static parseInline(t,n){return new ft(n).parseInline(t)}parse(t,n=!0){let r="";for(let l=0;l<t.length;l++){const i=t[l];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[i.type]){const o=i,s=this.options.extensions.renderers[o.type].call({parser:this},o);if(s!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(o.type)){r+=s||"";continue}}switch(i.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{const o=i;r+=this.renderer.heading(this.parseInline(o.tokens),o.depth,Lm(this.parseInline(o.tokens,this.textRenderer)));continue}case"code":{const o=i;r+=this.renderer.code(o.text,o.lang,!!o.escaped);continue}case"table":{const o=i;let s="",u="";for(let m=0;m<o.header.length;m++)u+=this.renderer.tablecell(this.parseInline(o.header[m].tokens),{header:!0,align:o.align[m]});s+=this.renderer.tablerow(u);let a="";for(let m=0;m<o.rows.length;m++){const g=o.rows[m];u="";for(let h=0;h<g.length;h++)u+=this.renderer.tablecell(this.parseInline(g[h].tokens),{header:!1,align:o.align[h]});a+=this.renderer.tablerow(u)}r+=this.renderer.table(s,a);continue}case"blockquote":{const o=i,s=this.parse(o.tokens);r+=this.renderer.blockquote(s);continue}case"list":{const o=i,s=o.ordered,u=o.start,a=o.loose;let m="";for(let g=0;g<o.items.length;g++){const h=o.items[g],y=h.checked,w=h.task;let x="";if(h.task){const M=this.renderer.checkbox(!!y);a?h.tokens.length>0&&h.tokens[0].type==="paragraph"?(h.tokens[0].text=M+" "+h.tokens[0].text,h.tokens[0].tokens&&h.tokens[0].tokens.length>0&&h.tokens[0].tokens[0].type==="text"&&(h.tokens[0].tokens[0].text=M+" "+h.tokens[0].tokens[0].text)):h.tokens.unshift({type:"text",text:M+" "}):x+=M+" "}x+=this.parse(h.tokens,a),m+=this.renderer.listitem(x,w,!!y)}r+=this.renderer.list(m,s,u);continue}case"html":{const o=i;r+=this.renderer.html(o.text,o.block);continue}case"paragraph":{const o=i;r+=this.renderer.paragraph(this.parseInline(o.tokens));continue}case"text":{let o=i,s=o.tokens?this.parseInline(o.tokens):o.text;for(;l+1<t.length&&t[l+1].type==="text";)o=t[++l],s+=`
84
  `+(o.tokens?this.parseInline(o.tokens):o.text);r+=n?this.renderer.paragraph(s):s;continue}default:{const o='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return r}parseInline(t,n){n=n||this.renderer;let r="";for(let l=0;l<t.length;l++){const i=t[l];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[i.type]){const o=this.options.extensions.renderers[i.type].call({parser:this},i);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){r+=o||"";continue}}switch(i.type){case"escape":{const o=i;r+=n.text(o.text);break}case"html":{const o=i;r+=n.html(o.text);break}case"link":{const o=i;r+=n.link(o.href,o.title,this.parseInline(o.tokens,n));break}case"image":{const o=i;r+=n.image(o.href,o.title,o.text);break}case"strong":{const o=i;r+=n.strong(this.parseInline(o.tokens,n));break}case"em":{const o=i;r+=n.em(this.parseInline(o.tokens,n));break}case"codespan":{const o=i;r+=n.codespan(o.text);break}case"br":{r+=n.br();break}case"del":{const o=i;r+=n.del(this.parseInline(o.tokens,n));break}case"text":{const o=i;r+=n.text(o.text);break}default:{const o='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return r}}class Nr{constructor(t){Y(this,"options");this.options=t||pn}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}}Y(Nr,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));var Qr,ms,hi,Od;class ig{constructor(...t){Hi(this,Qr);Hi(this,hi);Y(this,"defaults",du());Y(this,"options",this.setOptions);Y(this,"parse",il(this,Qr,ms).call(this,ct.lex,ft.parse));Y(this,"parseInline",il(this,Qr,ms).call(this,ct.lexInline,ft.parseInline));Y(this,"Parser",ft);Y(this,"Renderer",pi);Y(this,"TextRenderer",vu);Y(this,"Lexer",ct);Y(this,"Tokenizer",fi);Y(this,"Hooks",Nr);this.use(...t)}walkTokens(t,n){var l,i;let r=[];for(const o of t)switch(r=r.concat(n.call(this,o)),o.type){case"table":{const s=o;for(const u of s.header)r=r.concat(this.walkTokens(u.tokens,n));for(const u of s.rows)for(const a of u)r=r.concat(this.walkTokens(a.tokens,n));break}case"list":{const s=o;r=r.concat(this.walkTokens(s.items,n));break}default:{const s=o;(i=(l=this.defaults.extensions)==null?void 0:l.childTokens)!=null&&i[s.type]?this.defaults.extensions.childTokens[s.type].forEach(u=>{const a=s[u].flat(1/0);r=r.concat(this.walkTokens(a,n))}):s.tokens&&(r=r.concat(this.walkTokens(s.tokens,n)))}}return r}use(...t){const n=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(r=>{const l={...r};if(l.async=this.defaults.async||l.async||!1,r.extensions&&(r.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){const o=n.renderers[i.name];o?n.renderers[i.name]=function(...s){let u=i.renderer.apply(this,s);return u===!1&&(u=o.apply(this,s)),u}:n.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const o=n[i.level];o?o.unshift(i.tokenizer):n[i.level]=[i.tokenizer],i.start&&(i.level==="block"?n.startBlock?n.startBlock.push(i.start):n.startBlock=[i.start]:i.level==="inline"&&(n.startInline?n.startInline.push(i.start):n.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(n.childTokens[i.name]=i.childTokens)}),l.extensions=n),r.renderer){const i=this.defaults.renderer||new pi(this.defaults);for(const o in r.renderer){if(!(o in i))throw new Error(`renderer '${o}' does not exist`);if(o==="options")continue;const s=o,u=r.renderer[s],a=i[s];i[s]=(...m)=>{let g=u.apply(i,m);return g===!1&&(g=a.apply(i,m)),g||""}}l.renderer=i}if(r.tokenizer){const i=this.defaults.tokenizer||new fi(this.defaults);for(const o in r.tokenizer){if(!(o in i))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;const s=o,u=r.tokenizer[s],a=i[s];i[s]=(...m)=>{let g=u.apply(i,m);return g===!1&&(g=a.apply(i,m)),g}}l.tokenizer=i}if(r.hooks){const i=this.defaults.hooks||new Nr;for(const o in r.hooks){if(!(o in i))throw new Error(`hook '${o}' does not exist`);if(o==="options")continue;const s=o,u=r.hooks[s],a=i[s];Nr.passThroughHooks.has(o)?i[s]=m=>{if(this.defaults.async)return Promise.resolve(u.call(i,m)).then(h=>a.call(i,h));const g=u.call(i,m);return a.call(i,g)}:i[s]=(...m)=>{let g=u.apply(i,m);return g===!1&&(g=a.apply(i,m)),g}}l.hooks=i}if(r.walkTokens){const i=this.defaults.walkTokens,o=r.walkTokens;l.walkTokens=function(s){let u=[];return u.push(o.call(this,s)),i&&(u=u.concat(i.call(this,s))),u}}this.defaults={...this.defaults,...l}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,n){return ct.lex(t,n??this.defaults)}parser(t,n){return ft.parse(t,n??this.defaults)}}Qr=new WeakSet,ms=function(t,n){return(r,l)=>{const i={...l},o={...this.defaults,...i};this.defaults.async===!0&&i.async===!1&&(o.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),o.async=!0);const s=il(this,hi,Od).call(this,!!o.silent,!!o.async);if(typeof r>"u"||r===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));if(o.hooks&&(o.hooks.options=o),o.async)return Promise.resolve(o.hooks?o.hooks.preprocess(r):r).then(u=>t(u,o)).then(u=>o.hooks?o.hooks.processAllTokens(u):u).then(u=>o.walkTokens?Promise.all(this.walkTokens(u,o.walkTokens)).then(()=>u):u).then(u=>n(u,o)).then(u=>o.hooks?o.hooks.postprocess(u):u).catch(s);try{o.hooks&&(r=o.hooks.preprocess(r));let u=t(r,o);o.hooks&&(u=o.hooks.processAllTokens(u)),o.walkTokens&&this.walkTokens(u,o.walkTokens);let a=n(u,o);return o.hooks&&(a=o.hooks.postprocess(a)),a}catch(u){return s(u)}}},hi=new WeakSet,Od=function(t,n){return r=>{if(r.message+=`
85
  Please report this to https://github.com/markedjs/marked.`,t){const l="<p>An error occurred:</p><pre>"+Me(r.message+"",!0)+"</pre>";return n?Promise.resolve(l):l}if(n)return Promise.reject(r);throw r}};const cn=new ig;function H(e,t){return cn.parse(e,t)}H.options=H.setOptions=function(e){return cn.setOptions(e),H.defaults=cn.defaults,_d(H.defaults),H};H.getDefaults=du;H.defaults=pn;H.use=function(...e){return cn.use(...e),H.defaults=cn.defaults,_d(H.defaults),H};H.walkTokens=function(e,t){return cn.walkTokens(e,t)};H.parseInline=cn.parseInline;H.Parser=ft;H.parser=ft.parse;H.Renderer=pi;H.TextRenderer=vu;H.Lexer=ct;H.lexer=ct.lex;H.Tokenizer=fi;H.Hooks=Nr;H.parse=H;H.options;H.setOptions;H.use;H.walkTokens;H.parseInline;ft.parse;ct.lex;/*! @license DOMPurify 3.1.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.5/LICENSE */const{entries:Md,setPrototypeOf:nc,isFrozen:og,getPrototypeOf:sg,getOwnPropertyDescriptor:ug}=Object;let{freeze:_e,seal:Xe,create:Dd}=Object,{apply:gs,construct:ys}=typeof Reflect<"u"&&Reflect;_e||(_e=function(t){return t});Xe||(Xe=function(t){return t});gs||(gs=function(t,n,r){return t.apply(n,r)});ys||(ys=function(t,n){return new t(...n)});const Tl=$e(Array.prototype.forEach),rc=$e(Array.prototype.pop),ar=$e(Array.prototype.push),Ul=$e(String.prototype.toLowerCase),go=$e(String.prototype.toString),lc=$e(String.prototype.match),cr=$e(String.prototype.replace),ag=$e(String.prototype.indexOf),cg=$e(String.prototype.trim),Je=$e(Object.prototype.hasOwnProperty),xe=$e(RegExp.prototype.test),fr=fg(TypeError);function $e(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),l=1;l<n;l++)r[l-1]=arguments[l];return gs(e,t,r)}}function fg(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return ys(e,n)}}function j(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ul;nc&&nc(e,null);let r=t.length;for(;r--;){let l=t[r];if(typeof l=="string"){const i=n(l);i!==l&&(og(t)||(t[r]=i),l=i)}e[l]=!0}return e}function dg(e){for(let t=0;t<e.length;t++)Je(e,t)||(e[t]=null);return e}function Jt(e){const t=Dd(null);for(const[n,r]of Md(e))Je(e,n)&&(Array.isArray(r)?t[n]=dg(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=Jt(r):t[n]=r);return t}function Cl(e,t){for(;e!==null;){const r=ug(e,t);if(r){if(r.get)return $e(r.get);if(typeof r.value=="function")return $e(r.value)}e=sg(e)}function n(){return null}return n}const ic=_e(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),yo=_e(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),vo=_e(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),pg=_e(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ko=_e(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),hg=_e(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),oc=_e(["#text"]),sc=_e(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),wo=_e(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),uc=_e(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Nl=_e(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),mg=Xe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),gg=Xe(/<%[\w\W]*|[\w\W]*%>/gm),yg=Xe(/\${[\w\W]*}/gm),vg=Xe(/^data-[\-\w.\u00B7-\uFFFF]/),kg=Xe(/^aria-[\-\w]+$/),jd=Xe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),wg=Xe(/^(?:\w+script|data):/i),xg=Xe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Fd=Xe(/^html$/i),Sg=Xe(/^[a-z][.\w]*(-[.\w]+)+$/i);var ac=Object.freeze({__proto__:null,MUSTACHE_EXPR:mg,ERB_EXPR:gg,TMPLIT_EXPR:yg,DATA_ATTR:vg,ARIA_ATTR:kg,IS_ALLOWED_URI:jd,IS_SCRIPT_OR_DATA:wg,ATTR_WHITESPACE:xg,DOCTYPE_NAME:Fd,CUSTOM_ELEMENT:Sg});const dr={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Eg=function(){return typeof window>"u"?null:window},_g=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const l="data-tt-policy-suffix";n&&n.hasAttribute(l)&&(r=n.getAttribute(l));const i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}};function $d(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Eg();const t=z=>$d(z);if(t.version="3.1.5",t.removed=[],!e||!e.document||e.document.nodeType!==dr.document)return t.isSupported=!1,t;let{document:n}=e;const r=n,l=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:o,Node:s,Element:u,NodeFilter:a,NamedNodeMap:m=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:g,DOMParser:h,trustedTypes:y}=e,w=u.prototype,x=Cl(w,"cloneNode"),M=Cl(w,"nextSibling"),p=Cl(w,"childNodes"),c=Cl(w,"parentNode");if(typeof o=="function"){const z=n.createElement("template");z.content&&z.content.ownerDocument&&(n=z.content.ownerDocument)}let d,v="";const{implementation:T,createNodeIterator:E,createDocumentFragment:C,getElementsByTagName:N}=n,{importNode:$}=r;let I={};t.isSupported=typeof Md=="function"&&typeof c=="function"&&T&&T.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ce,ERB_EXPR:Ne,TMPLIT_EXPR:He,DATA_ATTR:br,ARIA_ATTR:zi,IS_SCRIPT_OR_DATA:Zn,ATTR_WHITESPACE:hn,CUSTOM_ELEMENT:R}=ac;let{IS_ALLOWED_URI:O}=ac,A=null;const Z=j({},[...ic,...yo,...vo,...ko,...oc]);let D=null;const Yt=j({},[...sc,...wo,...uc,...Nl]);let B=Object.seal(Dd(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ht=null,Ze=null,Kt=!0,Ii=!0,ku=!1,wu=!0,mn=!1,Oi=!0,Xt=!1,Mi=!1,Di=!1,gn=!1,el=!1,tl=!1,xu=!0,Su=!1;const Ud="user-content-";let ji=!0,qn=!1,yn={},vn=null;const Eu=j({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let _u=null;const Tu=j({},["audio","video","img","source","image","track"]);let Fi=null;const Cu=j({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),nl="http://www.w3.org/1998/Math/MathML",rl="http://www.w3.org/2000/svg",mt="http://www.w3.org/1999/xhtml";let kn=mt,$i=!1,Ui=null;const Bd=j({},[nl,rl,mt],go);let Jn=null;const Hd=["application/xhtml+xml","text/html"],Wd="text/html";let oe=null,wn=null;const Vd=n.createElement("form"),Nu=function(f){return f instanceof RegExp||f instanceof Function},Bi=function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(wn&&wn===f)){if((!f||typeof f!="object")&&(f={}),f=Jt(f),Jn=Hd.indexOf(f.PARSER_MEDIA_TYPE)===-1?Wd:f.PARSER_MEDIA_TYPE,oe=Jn==="application/xhtml+xml"?go:Ul,A=Je(f,"ALLOWED_TAGS")?j({},f.ALLOWED_TAGS,oe):Z,D=Je(f,"ALLOWED_ATTR")?j({},f.ALLOWED_ATTR,oe):Yt,Ui=Je(f,"ALLOWED_NAMESPACES")?j({},f.ALLOWED_NAMESPACES,go):Bd,Fi=Je(f,"ADD_URI_SAFE_ATTR")?j(Jt(Cu),f.ADD_URI_SAFE_ATTR,oe):Cu,_u=Je(f,"ADD_DATA_URI_TAGS")?j(Jt(Tu),f.ADD_DATA_URI_TAGS,oe):Tu,vn=Je(f,"FORBID_CONTENTS")?j({},f.FORBID_CONTENTS,oe):Eu,ht=Je(f,"FORBID_TAGS")?j({},f.FORBID_TAGS,oe):{},Ze=Je(f,"FORBID_ATTR")?j({},f.FORBID_ATTR,oe):{},yn=Je(f,"USE_PROFILES")?f.USE_PROFILES:!1,Kt=f.ALLOW_ARIA_ATTR!==!1,Ii=f.ALLOW_DATA_ATTR!==!1,ku=f.ALLOW_UNKNOWN_PROTOCOLS||!1,wu=f.ALLOW_SELF_CLOSE_IN_ATTR!==!1,mn=f.SAFE_FOR_TEMPLATES||!1,Oi=f.SAFE_FOR_XML!==!1,Xt=f.WHOLE_DOCUMENT||!1,gn=f.RETURN_DOM||!1,el=f.RETURN_DOM_FRAGMENT||!1,tl=f.RETURN_TRUSTED_TYPE||!1,Di=f.FORCE_BODY||!1,xu=f.SANITIZE_DOM!==!1,Su=f.SANITIZE_NAMED_PROPS||!1,ji=f.KEEP_CONTENT!==!1,qn=f.IN_PLACE||!1,O=f.ALLOWED_URI_REGEXP||jd,kn=f.NAMESPACE||mt,B=f.CUSTOM_ELEMENT_HANDLING||{},f.CUSTOM_ELEMENT_HANDLING&&Nu(f.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(B.tagNameCheck=f.CUSTOM_ELEMENT_HANDLING.tagNameCheck),f.CUSTOM_ELEMENT_HANDLING&&Nu(f.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(B.attributeNameCheck=f.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),f.CUSTOM_ELEMENT_HANDLING&&typeof f.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(B.allowCustomizedBuiltInElements=f.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),mn&&(Ii=!1),el&&(gn=!0),yn&&(A=j({},oc),D=[],yn.html===!0&&(j(A,ic),j(D,sc)),yn.svg===!0&&(j(A,yo),j(D,wo),j(D,Nl)),yn.svgFilters===!0&&(j(A,vo),j(D,wo),j(D,Nl)),yn.mathMl===!0&&(j(A,ko),j(D,uc),j(D,Nl))),f.ADD_TAGS&&(A===Z&&(A=Jt(A)),j(A,f.ADD_TAGS,oe)),f.ADD_ATTR&&(D===Yt&&(D=Jt(D)),j(D,f.ADD_ATTR,oe)),f.ADD_URI_SAFE_ATTR&&j(Fi,f.ADD_URI_SAFE_ATTR,oe),f.FORBID_CONTENTS&&(vn===Eu&&(vn=Jt(vn)),j(vn,f.FORBID_CONTENTS,oe)),ji&&(A["#text"]=!0),Xt&&j(A,["html","head","body"]),A.table&&(j(A,["tbody"]),delete ht.tbody),f.TRUSTED_TYPES_POLICY){if(typeof f.TRUSTED_TYPES_POLICY.createHTML!="function")throw fr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof f.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw fr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');d=f.TRUSTED_TYPES_POLICY,v=d.createHTML("")}else d===void 0&&(d=_g(y,l)),d!==null&&typeof v=="string"&&(v=d.createHTML(""));_e&&_e(f),wn=f}},Ru=j({},["mi","mo","mn","ms","mtext"]),Lu=j({},["foreignobject","annotation-xml"]),Qd=j({},["title","style","font","a","script"]),Pu=j({},[...yo,...vo,...pg]),Au=j({},[...ko,...hg]),Gd=function(f){let S=c(f);(!S||!S.tagName)&&(S={namespaceURI:kn,tagName:"template"});const P=Ul(f.tagName),Q=Ul(S.tagName);return Ui[f.namespaceURI]?f.namespaceURI===rl?S.namespaceURI===mt?P==="svg":S.namespaceURI===nl?P==="svg"&&(Q==="annotation-xml"||Ru[Q]):!!Pu[P]:f.namespaceURI===nl?S.namespaceURI===mt?P==="math":S.namespaceURI===rl?P==="math"&&Lu[Q]:!!Au[P]:f.namespaceURI===mt?S.namespaceURI===rl&&!Lu[Q]||S.namespaceURI===nl&&!Ru[Q]?!1:!Au[P]&&(Qd[P]||!Pu[P]):!!(Jn==="application/xhtml+xml"&&Ui[f.namespaceURI]):!1},it=function(f){ar(t.removed,{element:f});try{f.parentNode.removeChild(f)}catch{f.remove()}},ll=function(f,S){try{ar(t.removed,{attribute:S.getAttributeNode(f),from:S})}catch{ar(t.removed,{attribute:null,from:S})}if(S.removeAttribute(f),f==="is"&&!D[f])if(gn||el)try{it(S)}catch{}else try{S.setAttribute(f,"")}catch{}},zu=function(f){let S=null,P=null;if(Di)f="<remove></remove>"+f;else{const fe=lc(f,/^[\r\n\t ]+/);P=fe&&fe[0]}Jn==="application/xhtml+xml"&&kn===mt&&(f='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+f+"</body></html>");const Q=d?d.createHTML(f):f;if(kn===mt)try{S=new h().parseFromString(Q,Jn)}catch{}if(!S||!S.documentElement){S=T.createDocument(kn,"template",null);try{S.documentElement.innerHTML=$i?v:Q}catch{}}const me=S.body||S.documentElement;return f&&P&&me.insertBefore(n.createTextNode(P),me.childNodes[0]||null),kn===mt?N.call(S,Xt?"html":"body")[0]:Xt?S.documentElement:me},Iu=function(f){return E.call(f.ownerDocument||f,f,a.SHOW_ELEMENT|a.SHOW_COMMENT|a.SHOW_TEXT|a.SHOW_PROCESSING_INSTRUCTION|a.SHOW_CDATA_SECTION,null)},Ou=function(f){return f instanceof g&&(typeof f.nodeName!="string"||typeof f.textContent!="string"||typeof f.removeChild!="function"||!(f.attributes instanceof m)||typeof f.removeAttribute!="function"||typeof f.setAttribute!="function"||typeof f.namespaceURI!="string"||typeof f.insertBefore!="function"||typeof f.hasChildNodes!="function")},Mu=function(f){return typeof s=="function"&&f instanceof s},gt=function(f,S,P){I[f]&&Tl(I[f],Q=>{Q.call(t,S,P,wn)})},Du=function(f){let S=null;if(gt("beforeSanitizeElements",f,null),Ou(f))return it(f),!0;const P=oe(f.nodeName);if(gt("uponSanitizeElement",f,{tagName:P,allowedTags:A}),f.hasChildNodes()&&!Mu(f.firstElementChild)&&xe(/<[/\w]/g,f.innerHTML)&&xe(/<[/\w]/g,f.textContent)||f.nodeType===dr.progressingInstruction||Oi&&f.nodeType===dr.comment&&xe(/<[/\w]/g,f.data))return it(f),!0;if(!A[P]||ht[P]){if(!ht[P]&&Fu(P)&&(B.tagNameCheck instanceof RegExp&&xe(B.tagNameCheck,P)||B.tagNameCheck instanceof Function&&B.tagNameCheck(P)))return!1;if(ji&&!vn[P]){const Q=c(f)||f.parentNode,me=p(f)||f.childNodes;if(me&&Q){const fe=me.length;for(let Re=fe-1;Re>=0;--Re){const ot=x(me[Re],!0);ot.__removalCount=(f.__removalCount||0)+1,Q.insertBefore(ot,M(f))}}}return it(f),!0}return f instanceof u&&!Gd(f)||(P==="noscript"||P==="noembed"||P==="noframes")&&xe(/<\/no(script|embed|frames)/i,f.innerHTML)?(it(f),!0):(mn&&f.nodeType===dr.text&&(S=f.textContent,Tl([ce,Ne,He],Q=>{S=cr(S,Q," ")}),f.textContent!==S&&(ar(t.removed,{element:f.cloneNode()}),f.textContent=S)),gt("afterSanitizeElements",f,null),!1)},ju=function(f,S,P){if(xu&&(S==="id"||S==="name")&&(P in n||P in Vd))return!1;if(!(Ii&&!Ze[S]&&xe(br,S))){if(!(Kt&&xe(zi,S))){if(!D[S]||Ze[S]){if(!(Fu(f)&&(B.tagNameCheck instanceof RegExp&&xe(B.tagNameCheck,f)||B.tagNameCheck instanceof Function&&B.tagNameCheck(f))&&(B.attributeNameCheck instanceof RegExp&&xe(B.attributeNameCheck,S)||B.attributeNameCheck instanceof Function&&B.attributeNameCheck(S))||S==="is"&&B.allowCustomizedBuiltInElements&&(B.tagNameCheck instanceof RegExp&&xe(B.tagNameCheck,P)||B.tagNameCheck instanceof Function&&B.tagNameCheck(P))))return!1}else if(!Fi[S]){if(!xe(O,cr(P,hn,""))){if(!((S==="src"||S==="xlink:href"||S==="href")&&f!=="script"&&ag(P,"data:")===0&&_u[f])){if(!(ku&&!xe(Zn,cr(P,hn,"")))){if(P)return!1}}}}}}return!0},Fu=function(f){return f!=="annotation-xml"&&lc(f,R)},$u=function(f){gt("beforeSanitizeAttributes",f,null);const{attributes:S}=f;if(!S)return;const P={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:D};let Q=S.length;for(;Q--;){const me=S[Q],{name:fe,namespaceURI:Re,value:ot}=me,bn=oe(fe);let we=fe==="value"?ot:cg(ot);if(P.attrName=bn,P.attrValue=we,P.keepAttr=!0,P.forceKeepAttr=void 0,gt("uponSanitizeAttribute",f,P),we=P.attrValue,P.forceKeepAttr||(ll(fe,f),!P.keepAttr))continue;if(!wu&&xe(/\/>/i,we)){ll(fe,f);continue}if(Oi&&xe(/((--!?|])>)|<\/(style|title)/i,we)){ll(fe,f);continue}mn&&Tl([ce,Ne,He],Bu=>{we=cr(we,Bu," ")});const Uu=oe(f.nodeName);if(ju(Uu,bn,we)){if(Su&&(bn==="id"||bn==="name")&&(ll(fe,f),we=Ud+we),d&&typeof y=="object"&&typeof y.getAttributeType=="function"&&!Re)switch(y.getAttributeType(Uu,bn)){case"TrustedHTML":{we=d.createHTML(we);break}case"TrustedScriptURL":{we=d.createScriptURL(we);break}}try{Re?f.setAttributeNS(Re,fe,we):f.setAttribute(fe,we),Ou(f)?it(f):rc(t.removed)}catch{}}}gt("afterSanitizeAttributes",f,null)},Yd=function z(f){let S=null;const P=Iu(f);for(gt("beforeSanitizeShadowDOM",f,null);S=P.nextNode();)gt("uponSanitizeShadowNode",S,null),!Du(S)&&(S.content instanceof i&&z(S.content),$u(S));gt("afterSanitizeShadowDOM",f,null)};return t.sanitize=function(z){let f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},S=null,P=null,Q=null,me=null;if($i=!z,$i&&(z="<!-->"),typeof z!="string"&&!Mu(z))if(typeof z.toString=="function"){if(z=z.toString(),typeof z!="string")throw fr("dirty is not a string, aborting")}else throw fr("toString is not a function");if(!t.isSupported)return z;if(Mi||Bi(f),t.removed=[],typeof z=="string"&&(qn=!1),qn){if(z.nodeName){const ot=oe(z.nodeName);if(!A[ot]||ht[ot])throw fr("root node is forbidden and cannot be sanitized in-place")}}else if(z instanceof s)S=zu("<!---->"),P=S.ownerDocument.importNode(z,!0),P.nodeType===dr.element&&P.nodeName==="BODY"||P.nodeName==="HTML"?S=P:S.appendChild(P);else{if(!gn&&!mn&&!Xt&&z.indexOf("<")===-1)return d&&tl?d.createHTML(z):z;if(S=zu(z),!S)return gn?null:tl?v:""}S&&Di&&it(S.firstChild);const fe=Iu(qn?z:S);for(;Q=fe.nextNode();)Du(Q)||(Q.content instanceof i&&Yd(Q.content),$u(Q));if(qn)return z;if(gn){if(el)for(me=C.call(S.ownerDocument);S.firstChild;)me.appendChild(S.firstChild);else me=S;return(D.shadowroot||D.shadowrootmode)&&(me=$.call(r,me,!0)),me}let Re=Xt?S.outerHTML:S.innerHTML;return Xt&&A["!doctype"]&&S.ownerDocument&&S.ownerDocument.doctype&&S.ownerDocument.doctype.name&&xe(Fd,S.ownerDocument.doctype.name)&&(Re="<!DOCTYPE "+S.ownerDocument.doctype.name+`>
86
+ `+Re),mn&&Tl([ce,Ne,He],ot=>{Re=cr(Re,ot," ")}),d&&tl?d.createHTML(Re):Re},t.setConfig=function(){let z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Bi(z),Mi=!0},t.clearConfig=function(){wn=null,Mi=!1},t.isValidAttribute=function(z,f,S){wn||Bi({});const P=oe(z),Q=oe(f);return ju(P,Q,S)},t.addHook=function(z,f){typeof f=="function"&&(I[z]=I[z]||[],ar(I[z],f))},t.removeHook=function(z){if(I[z])return rc(I[z])},t.removeHooks=function(z){I[z]&&(I[z]=[])},t.removeAllHooks=function(){I={}},t}var Tg=$d();function Cg(e){return _.jsxs("svg",{...e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[_.jsx("path",{d:"M12 8V4H8"}),_.jsx("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),_.jsx("path",{d:"M2 14h2"}),_.jsx("path",{d:"M20 14h2"}),_.jsx("path",{d:"M15 13v2"}),_.jsx("path",{d:"M9 13v2"})]})}function Ng(e){return _.jsxs("svg",{...e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[_.jsx("path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}),_.jsx("circle",{cx:"12",cy:"7",r:"4"})]})}function Rg({messages:e}){const t=e.length===0;return _.jsx("div",{className:`flex-1 p-6 max-w-[960px] w-full ${t?"flex flex-col items-center justify-end":"space-y-4"}`,children:t?_.jsx("div",{className:"text-xl",children:"Ready!"}):e.map((n,r)=>_.jsx("div",{className:"flex items-start space-x-4",children:n.role==="assistant"?_.jsxs(_.Fragment,{children:[_.jsx(Cg,{className:"h-6 w-6 min-h-6 min-w-6 my-3 text-gray-500 dark:text-gray-300"}),_.jsx("div",{className:"bg-gray-200 dark:bg-gray-700 rounded-lg p-4",children:_.jsx("p",{className:"min-h-6 text-gray-800 dark:text-gray-200 overflow-wrap-anywhere",children:n.content.length>0?_.jsx("span",{className:"markdown",dangerouslySetInnerHTML:{__html:Tg.sanitize(H.parse(n.content))}}):_.jsxs("span",{className:"h-6 flex items-center gap-1",children:[_.jsx("span",{className:"w-2.5 h-2.5 bg-gray-600 dark:bg-gray-300 rounded-full animate-pulse"}),_.jsx("span",{className:"w-2.5 h-2.5 bg-gray-600 dark:bg-gray-300 rounded-full animate-pulse animation-delay-200"}),_.jsx("span",{className:"w-2.5 h-2.5 bg-gray-600 dark:bg-gray-300 rounded-full animate-pulse animation-delay-400"})]})})})]}):_.jsxs(_.Fragment,{children:[_.jsx(Ng,{className:"h-6 w-6 min-h-6 min-w-6 my-3 text-gray-500 dark:text-gray-300"}),_.jsx("div",{className:"bg-blue-500 text-white rounded-lg p-4",children:_.jsx("p",{className:"min-h-6 overflow-wrap-anywhere",children:n.content})})]})},`message-${r}`))})}function cc(e){return _.jsxs("svg",{...e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[_.jsx("path",{d:"M5 12h14"}),_.jsx("path",{d:"m12 5 7 7-7 7"})]})}function Lg(e){return _.jsxs("svg",{...e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[_.jsx("path",{d:"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"}),_.jsx("path",{fill:"currentColor",d:"M9 9.563C9 9.252 9.252 9 9.563 9h4.874c.311 0 .563.252.563.563v4.874c0 .311-.252.563-.563.563H9.564A.562.562 0 0 1 9 14.437V9.564Z"})]})}function Pg(e){const t=e==0?0:Math.floor(Math.log(e)/Math.log(1024));return+(e/Math.pow(1024,t)).toFixed(2)*1+["B","kB","MB","GB","TB"][t]}function Ag({text:e,percentage:t,total:n}){return t??(t=0),_.jsx("div",{className:"w-full bg-gray-100 dark:bg-gray-700 text-left rounded-lg overflow-hidden mb-0.5",children:_.jsxs("div",{className:"bg-blue-400 whitespace-nowrap px-1 text-sm",style:{width:`${t}%`},children:[e," (",t.toFixed(2),"%",isNaN(n)?"":` of ${Pg(n)}`,")"]})})}const zg=!!navigator.gpu,Ig=120;function Og(){const e=se.useRef(null),t=se.useRef(null),n=se.useRef(null),[r,l]=se.useState(null),[i,o]=se.useState(""),[s,u]=se.useState([]),[a,m]=se.useState(!1),[g,h]=se.useState(""),[y,w]=se.useState([]),[x,M]=se.useState(null),[p,c]=se.useState(null);function d(E){w(C=>[...C,{role:"user",content:E}]),M(null),m(!0),h("")}se.useEffect(()=>{T()},[g]);function v(){e.current.postMessage({type:"interrupt"})}function T(){if(!t.current)return;const E=t.current;E.style.height="auto";const C=Math.min(Math.max(E.scrollHeight,24),200);E.style.height=`${C}px`}return se.useEffect(()=>{e.current||(e.current=new Worker(new URL("/assets/worker-CqnEQYb0.js",import.meta.url),{type:"module"}));const E=C=>{switch(C.data.status){case"loading":l("loading"),o(C.data.data);break;case"initiate":u(N=>[...N,C.data]);break;case"progress":u(N=>N.map($=>$.file===C.data.file?{...$,...C.data}:$));break;case"done":u(N=>N.filter($=>$.file!==C.data.file));break;case"ready":l("ready");break;case"start":w(N=>[...N,{role:"assistant",content:""}]);break;case"update":{const{output:N,tps:$,numTokens:I}=C.data;M($),c(I),w(ce=>{const Ne=[...ce],He=Ne.at(-1);return Ne[Ne.length-1]={...He,content:He.content+N},Ne})}break;case"complete":m(!1);break}};return e.current.addEventListener("message",E),()=>{e.current.removeEventListener("message",E)}},[]),se.useEffect(()=>{y.filter(E=>E.role==="user").length!==0&&y.at(-1).role!=="assistant"&&(M(null),e.current.postMessage({type:"generate",data:y}))},[y,a]),se.useEffect(()=>{if(n.current&&a){const E=n.current;E.scrollHeight-E.scrollTop-E.clientHeight<Ig&&(E.scrollTop=E.scrollHeight)}},[y,a]),zg?_.jsxs("div",{className:"flex flex-col h-screen mx-auto items justify-end text-gray-800 dark:text-gray-200 bg-white dark:bg-gray-900",children:[r===null&&y.length===0&&_.jsxs("div",{className:"h-full overflow-auto scrollbar-thin flex justify-center items-center flex-col relative",children:[_.jsxs("div",{className:"flex flex-col items-center mb-1 max-w-[300px] text-center",children:[_.jsx("img",{src:"logo.png",width:"85%",height:"auto",className:"block"}),_.jsx("h1",{className:"text-4xl font-bold mb-1",children:"Qwen2 WebGPU"}),_.jsx("h2",{className:"font-semibold",children:"A private and powerful AI chatbot that runs locally in your browser."})]}),_.jsxs("div",{className:"flex flex-col items-center px-4",children:[_.jsxs("p",{className:"max-w-[514px] mb-4",children:[_.jsx("br",{}),"You are about to load ",_.jsx("a",{href:"https://huggingface.co/Qwen/Qwen2-0.5B-Instruct",target:"_blank",rel:"noreferrer",className:"font-medium underline",children:"Qwen2-0.5B-Instruct"}),", a 0.5 billion parameter LLM that is optimized for inference on the web. Once downloaded, the model (750 MB) will be cached and reused when you revisit the page.",_.jsx("br",{}),_.jsx("br",{}),"Everything runs directly in your browser using ",_.jsx("a",{href:"https://huggingface.co/docs/transformers.js",target:"_blank",rel:"noreferrer",className:"underline",children:"🤗 Transformers.js"})," and ONNX Runtime Web, meaning your conversations aren't sent to a server. You can even disconnect from the internet after the model has loaded!"]}),_.jsx("button",{className:"border px-4 py-2 rounded-lg bg-blue-400 text-white hover:bg-blue-500 disabled:bg-blue-100 disabled:cursor-not-allowed select-none",onClick:()=>{e.current.postMessage({type:"load"}),l("loading")},disabled:r!==null,children:"Load model"})]})]}),r==="loading"&&_.jsx(_.Fragment,{children:_.jsxs("div",{className:"w-full max-w-[500px] text-left mx-auto p-4 bottom-0 mt-auto",children:[_.jsx("p",{className:"text-center mb-1",children:i}),s.map(({file:E,progress:C,total:N},$)=>_.jsx(Ag,{text:E,percentage:C,total:N},$))]})}),r==="ready"&&_.jsxs("div",{ref:n,className:"overflow-y-auto scrollbar-thin w-full flex flex-col items-center h-full",children:[_.jsx(Rg,{messages:y}),_.jsx("p",{className:"text-center text-sm min-h-6 text-gray-500 dark:text-gray-300",children:x&&y.length>0&&_.jsxs(_.Fragment,{children:[!a&&_.jsxs("span",{children:["Generated ",p," tokens in ",(p/x).toFixed(2)," seconds ("]}),_.jsxs(_.Fragment,{children:[_.jsx("span",{className:"font-medium text-center mr-1 text-black dark:text-white",children:x.toFixed(2)}),_.jsx("span",{className:"text-gray-500 dark:text-gray-300",children:"tokens/second"})]}),!a&&_.jsxs(_.Fragment,{children:[_.jsx("span",{className:"mr-1",children:")."}),_.jsx("span",{className:"underline cursor-pointer",onClick:()=>{e.current.postMessage({type:"reset"}),w([])},children:"Reset"})]})]})})]}),_.jsxs("div",{className:"mt-2 border dark:bg-gray-700 rounded-lg w-[600px] max-w-[80%] max-h-[200px] mx-auto relative mb-3 flex",children:[_.jsx("textarea",{ref:t,className:"scrollbar-thin w-[550px] dark:bg-gray-700 px-3 py-4 rounded-lg bg-transparent border-none outline-none text-gray-800 disabled:text-gray-400 dark:text-gray-200 placeholder-gray-500 dark:placeholder-gray-400 disabled:placeholder-gray-200 resize-none disabled:cursor-not-allowed",placeholder:"Type your message...",type:"text",rows:1,value:g,disabled:r!=="ready",title:r==="ready"?"Model is ready":"Model not loaded yet",onKeyDown:E=>{g.length>0&&!a&&E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),d(g))},onInput:E=>h(E.target.value)}),a?_.jsx("div",{className:"cursor-pointer",onClick:v,children:_.jsx(Lg,{className:"h-8 w-8 p-1 rounded-md text-gray-800 dark:text-gray-100 absolute right-3 bottom-3"})}):g.length>0?_.jsx("div",{className:"cursor-pointer",onClick:()=>d(g),children:_.jsx(cc,{className:"h-8 w-8 p-1 bg-gray-800 dark:bg-gray-100 text-white dark:text-black rounded-md absolute right-3 bottom-3"})}):_.jsx("div",{children:_.jsx(cc,{className:"h-8 w-8 p-1 bg-gray-200 dark:bg-gray-600 text-gray-50 dark:text-gray-800 rounded-md absolute right-3 bottom-3"})})]}),_.jsx("p",{className:"text-xs text-gray-400 text-center mb-3",children:"Disclaimer: Generated content may be inaccurate or false."})]}):_.jsxs("div",{className:"fixed w-screen h-screen bg-black z-10 bg-opacity-[92%] text-white text-2xl font-semibold flex justify-center items-center text-center",children:["WebGPU is not supported",_.jsx("br",{}),"by this browser :("]})}xo.createRoot(document.getElementById("root")).render(_.jsx(pp.StrictMode,{children:_.jsx(Og,{})}));