Spaces:
Running
Running
Upload 24 files
Browse files- assets/index-B7MnxBmF.js +1 -1
assets/index-B7MnxBmF.js
CHANGED
|
@@ -1306,5 +1306,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
| 1306 |
`))+1))}const o="#".repeat(i),s=n.enter("headingAtx"),l=n.enter("phrasing");a.move(o+" ");let u=n.containerPhrasing(e,{before:"# ",after:`
|
| 1307 |
`,...a.current()});return/^[\t ]/.test(u)&&(u=ta(u.charCodeAt(0))+u.slice(1)),u=u?o+" "+u:o,n.options.closeAtx&&(u+=" "+o),l(),s(),u}gy.peek=h3;function gy(e){return e.value||""}function h3(){return"<"}wy.peek=g3;function wy(e,t,n,r){const i=df(n),a=i==='"'?"Quote":"Apostrophe",o=n.enter("image");let s=n.enter("label");const l=n.createTracker(r);let u=l.move("![");return u+=l.move(n.safe(e.alt,{before:u,after:"]",...l.current()})),u+=l.move("]("),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(n.safe(e.url,{before:u,after:">",...l.current()})),u+=l.move(">")):(s=n.enter("destinationRaw"),u+=l.move(n.safe(e.url,{before:u,after:e.title?" ":")",...l.current()}))),s(),e.title&&(s=n.enter(`title${a}`),u+=l.move(" "+i),u+=l.move(n.safe(e.title,{before:u,after:i,...l.current()})),u+=l.move(i),s()),u+=l.move(")"),o(),u}function g3(){return"!"}yy.peek=w3;function yy(e,t,n,r){const i=e.referenceType,a=n.enter("imageReference");let o=n.enter("label");const s=n.createTracker(r);let l=s.move("![");const u=n.safe(e.alt,{before:l,after:"]",...s.current()});l+=s.move(u+"]["),o();const f=n.stack;n.stack=[],o=n.enter("reference");const c=n.safe(n.associationId(e),{before:l,after:"]",...s.current()});return o(),n.stack=f,a(),i==="full"||!u||u!==c?l+=s.move(c+"]"):i==="shortcut"?l=l.slice(0,-1):l+=s.move("]"),l}function w3(){return"!"}vy.peek=y3;function vy(e,t,n){let r=e.value||"",i="`",a=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++a<n.unsafe.length;){const o=n.unsafe[a],s=n.compilePattern(o);let l;if(o.atBreak)for(;l=s.exec(r);){let u=l.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(l.index+1)}}return i+r+i}function y3(){return"`"}function by(e,t){const n=nf(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}ky.peek=v3;function ky(e,t,n,r){const i=df(n),a=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let s,l;if(by(e,n)){const f=n.stack;n.stack=[],s=n.enter("autolink");let c=o.move("<");return c+=o.move(n.containerPhrasing(e,{before:c,after:">",...o.current()})),c+=o.move(">"),s(),n.stack=f,c}s=n.enter("link"),l=n.enter("label");let u=o.move("[");return u+=o.move(n.containerPhrasing(e,{before:u,after:"](",...o.current()})),u+=o.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=o.move("<"),u+=o.move(n.safe(e.url,{before:u,after:">",...o.current()})),u+=o.move(">")):(l=n.enter("destinationRaw"),u+=o.move(n.safe(e.url,{before:u,after:e.title?" ":")",...o.current()}))),l(),e.title&&(l=n.enter(`title${a}`),u+=o.move(" "+i),u+=o.move(n.safe(e.title,{before:u,after:i,...o.current()})),u+=o.move(i),l()),u+=o.move(")"),s(),u}function v3(e,t,n){return by(e,n)?"<":"["}xy.peek=b3;function xy(e,t,n,r){const i=e.referenceType,a=n.enter("linkReference");let o=n.enter("label");const s=n.createTracker(r);let l=s.move("[");const u=n.containerPhrasing(e,{before:l,after:"]",...s.current()});l+=s.move(u+"]["),o();const f=n.stack;n.stack=[],o=n.enter("reference");const c=n.safe(n.associationId(e),{before:l,after:"]",...s.current()});return o(),n.stack=f,a(),i==="full"||!u||u!==c?l+=s.move(c+"]"):i==="shortcut"?l=l.slice(0,-1):l+=s.move("]"),l}function b3(){return"["}function pf(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function k3(e){const t=pf(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function x3(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Sy(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function S3(e,t,n,r){const i=n.enter("list"),a=n.bulletCurrent;let o=e.ordered?x3(n):pf(n);const s=e.ordered?o==="."?")":".":k3(n);let l=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){const f=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&f&&(!f.children||!f.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),Sy(n)===o&&f){let c=-1;for(;++c<e.children.length;){const p=e.children[c];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(o=s),n.bulletCurrent=o;const u=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),u}function P3(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function E3(e,t,n,r){const i=P3(n);let a=n.bulletCurrent||pf(n);t&&t.type==="list"&&t.ordered&&(a=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);const s=n.createTracker(r);s.move(a+" ".repeat(o-a.length)),s.shift(o);const l=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,s.current()),f);return l(),u;function f(c,p,d){return p?(d?"":" ".repeat(o))+c:(d?a:a+" ".repeat(o-a.length))+c}}function C3(e,t,n,r){const i=n.enter("paragraph"),a=n.enter("phrasing"),o=n.containerPhrasing(e,r);return a(),i(),o}const A3=ls(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function F3(e,t,n,r){return(e.children.some(function(o){return A3(o)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function T3(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Py.peek=M3;function Py(e,t,n,r){const i=T3(n),a=n.enter("strong"),o=n.createTracker(r),s=o.move(i+i);let l=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()}));const u=l.charCodeAt(0),f=No(r.before.charCodeAt(r.before.length-1),u,i);f.inside&&(l=ta(u)+l.slice(1));const c=l.charCodeAt(l.length-1),p=No(r.after.charCodeAt(0),c,i);p.inside&&(l=l.slice(0,-1)+ta(c));const d=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:p.outside,before:f.outside},s+l+d}function M3(e,t,n){return n.options.strong||"*"}function _3(e,t,n,r){return n.safe(e.value,r)}function I3(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function N3(e,t,n){const r=(Sy(n)+(n.options.ruleSpaces?" ":"")).repeat(I3(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Ey={blockquote:n3,break:im,code:l3,definition:c3,emphasis:hy,hardBreak:im,heading:m3,html:gy,image:wy,imageReference:yy,inlineCode:vy,link:ky,linkReference:xy,list:S3,listItem:E3,paragraph:C3,root:F3,strong:Py,text:_3,thematicBreak:N3};function R3(){return{enter:{table:L3,tableData:am,tableHeader:am,tableRow:D3},exit:{codeText:U3,table:O3,tableData:pl,tableHeader:pl,tableRow:pl}}}function L3(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function O3(e){this.exit(e),this.data.inTable=void 0}function D3(e){this.enter({type:"tableRow",children:[]},e)}function pl(e){this.exit(e)}function am(e){this.enter({type:"tableCell",children:[]},e)}function U3(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,z3));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function z3(e,t){return t==="|"?t:e}function j3(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
| 1308 |
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:o,tableCell:l,tableRow:s}};function o(d,h,y,E){return u(f(d,y,E),d.align)}function s(d,h,y,E){const m=c(d,y,E),g=u([m]);return g.slice(0,g.indexOf(`
|
| 1309 |
-
`))}function l(d,h,y,E){const m=y.enter("tableCell"),g=y.enter("phrasing"),w=y.containerPhrasing(d,{...E,before:a,after:a});return g(),m(),w}function u(d,h){return e3(d,{align:h,alignDelimiters:r,padding:n,stringLength:i})}function f(d,h,y){const E=d.children;let m=-1;const g=[],w=h.enter("table");for(;++m<E.length;)g[m]=c(E[m],h,y);return w(),g}function c(d,h,y){const E=d.children;let m=-1;const g=[],w=h.enter("tableRow");for(;++m<E.length;)g[m]=l(E[m],d,h,y);return w(),g}function p(d,h,y){let E=Ey.inlineCode(d,h,y);return y.stack.includes("tableCell")&&(E=E.replace(/\|/g,"\\$&")),E}}function B3(){return{exit:{taskListCheckValueChecked:om,taskListCheckValueUnchecked:om,paragraph:H3}}}function V3(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:W3}}}function om(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function H3(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let a=-1,o;for(;++a<i.length;){const s=i[a];if(s.type==="paragraph"){o=s;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function W3(e,t,n,r){const i=e.children[0],a=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",s=n.createTracker(r);a&&s.move(o);let l=Ey.listItem(e,t,n,{...r,...s.current()});return a&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),l;function u(f){return f+o}}function G3(){return[SA(),WA(),XA(),R3(),B3()]}function q3(e){return{extensions:[PA(),GA(e),QA(),j3(e),V3()]}}const K3={tokenize:$3,partial:!0},Cy={tokenize:e4,partial:!0},Ay={tokenize:t4,partial:!0},Fy={tokenize:n4,partial:!0},X3={tokenize:r4,partial:!0},Ty={name:"wwwAutolink",tokenize:Z3,previous:_y},My={name:"protocolAutolink",tokenize:Y3,previous:Iy},un={name:"emailAutolink",tokenize:J3,previous:Ny},Gt={};function Q3(){return{text:Gt}}let Bn=48;for(;Bn<123;)Gt[Bn]=un,Bn++,Bn===58?Bn=65:Bn===91&&(Bn=97);Gt[43]=un;Gt[45]=un;Gt[46]=un;Gt[95]=un;Gt[72]=[un,My];Gt[104]=[un,My];Gt[87]=[un,Ty];Gt[119]=[un,Ty];function J3(e,t,n){const r=this;let i,a;return o;function o(c){return!ju(c)||!Ny.call(r,r.previous)||mf(r.events)?n(c):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(c))}function s(c){return ju(c)?(e.consume(c),s):c===64?(e.consume(c),l):n(c)}function l(c){return c===46?e.check(X3,f,u)(c):c===45||c===95||Ve(c)?(a=!0,e.consume(c),l):f(c)}function u(c){return e.consume(c),i=!0,l}function f(c){return a&&i&&Ke(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(c)):n(c)}}function Z3(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!_y.call(r,r.previous)||mf(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(K3,e.attempt(Cy,e.attempt(Ay,a),n),n)(o))}function a(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function Y3(e,t,n){const r=this;let i="",a=!1;return o;function o(c){return(c===72||c===104)&&Iy.call(r,r.previous)&&!mf(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(c),e.consume(c),s):n(c)}function s(c){if(Ke(c)&&i.length<5)return i+=String.fromCodePoint(c),e.consume(c),s;if(c===58){const p=i.toLowerCase();if(p==="http"||p==="https")return e.consume(c),l}return n(c)}function l(c){return c===47?(e.consume(c),a?u:(a=!0,l)):n(c)}function u(c){return c===null||To(c)||ue(c)||sr(c)||as(c)?n(c):e.attempt(Cy,e.attempt(Ay,f),n)(c)}function f(c){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(c)}}function $3(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),a):n(o)}function a(o){return o===null?n(o):t(o)}}function e4(e,t,n){let r,i,a;return o;function o(u){return u===46||u===95?e.check(Fy,l,s)(u):u===null||ue(u)||sr(u)||u!==45&&as(u)?l(u):(a=!0,e.consume(u),o)}function s(u){return u===95?r=!0:(i=r,r=void 0),e.consume(u),o}function l(u){return i||r||!a?n(u):t(u)}}function t4(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Fy,t,a)(o):o===null||ue(o)||sr(o)?t(o):(e.consume(o),i)}function a(o){return o===41&&r++,e.consume(o),i}}function n4(e,t,n){return r;function r(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(e.consume(s),r):s===38?(e.consume(s),a):s===93?(e.consume(s),i):s===60||s===null||ue(s)||sr(s)?t(s):n(s)}function i(s){return s===null||s===40||s===91||ue(s)||sr(s)?t(s):r(s)}function a(s){return Ke(s)?o(s):n(s)}function o(s){return s===59?(e.consume(s),r):Ke(s)?(e.consume(s),o):n(s)}}function r4(e,t,n){return r;function r(a){return e.consume(a),i}function i(a){return Ve(a)?n(a):t(a)}}function _y(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||ue(e)}function Iy(e){return!Ke(e)}function Ny(e){return!(e===47||ju(e))}function ju(e){return e===43||e===45||e===46||e===95||Ve(e)}function mf(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const i4={tokenize:d4,partial:!0};function a4(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:u4,continuation:{tokenize:c4},exit:f4}},text:{91:{name:"gfmFootnoteCall",tokenize:l4},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:o4,resolveTo:s4}}}}function o4(e,t,n){const r=this;let i=r.events.length;const a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return s;function s(l){if(!o||!o._balanced)return n(l);const u=It(r.sliceSerialize({start:o.end,end:r.now()}));return u.codePointAt(0)!==94||!a.includes(u.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function s4(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...s),e}function l4(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,o;return s;function s(c){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),l}function l(c){return c!==94?n(c):(e.enter("gfmFootnoteCallMarker"),e.consume(c),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(c){if(a>999||c===93&&!o||c===null||c===91||ue(c))return n(c);if(c===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(It(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(c)}return ue(c)||(o=!0),a++,e.consume(c),c===92?f:u}function f(c){return c===91||c===92||c===93?(e.consume(c),a++,u):u(c)}}function u4(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a,o=0,s;return l;function l(h){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(h),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(h){return h===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(h),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",f):n(h)}function f(h){if(o>999||h===93&&!s||h===null||h===91||ue(h))return n(h);if(h===93){e.exit("chunkString");const y=e.exit("gfmFootnoteDefinitionLabelString");return a=It(r.sliceSerialize(y)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(h),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return ue(h)||(s=!0),o++,e.consume(h),h===92?c:f}function c(h){return h===91||h===92||h===93?(e.consume(h),o++,f):f(h)}function p(h){return h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),i.includes(a)||i.push(a),te(e,d,"gfmFootnoteDefinitionWhitespace")):n(h)}function d(h){return t(h)}}function c4(e,t,n){return e.check(ca,t,e.attempt(i4,t,n))}function f4(e){e.exit("gfmFootnoteDefinition")}function d4(e,t,n){const r=this;return te(e,i,"gfmFootnoteDefinitionIndent",5);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(a):n(a)}}function p4(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,s){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let u=l;for(;u--;)if(o[u][0]==="exit"&&o[u][1].type==="strikethroughSequenceTemporary"&&o[u][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[u][1].end.offset-o[u][1].start.offset){o[l][1].type="strikethroughSequence",o[u][1].type="strikethroughSequence";const f={type:"strikethrough",start:Object.assign({},o[u][1].start),end:Object.assign({},o[l][1].end)},c={type:"strikethroughText",start:Object.assign({},o[u][1].end),end:Object.assign({},o[l][1].start)},p=[["enter",f,s],["enter",o[u][1],s],["exit",o[u][1],s],["enter",c,s]],d=s.parser.constructs.insideSpan.null;d&&dt(p,p.length,0,os(d,o.slice(u+1,l),s)),dt(p,p.length,0,[["exit",c,s],["enter",o[l][1],s],["exit",o[l][1],s],["exit",f,s]]),dt(o,u-1,l-u+3,p),l=u+p.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function a(o,s,l){const u=this.previous,f=this.events;let c=0;return p;function p(h){return u===126&&f[f.length-1][1].type!=="characterEscape"?l(h):(o.enter("strikethroughSequenceTemporary"),d(h))}function d(h){const y=Xr(u);if(h===126)return c>1?l(h):(o.consume(h),c++,d);if(c<2&&!n)return l(h);const E=o.exit("strikethroughSequenceTemporary"),m=Xr(h);return E._open=!m||m===2&&!!y,E._close=!y||y===2&&!!m,s(h)}}}class m4{constructor(){this.map=[]}add(t,n,r){h4(this,t,n,r)}consume(t){if(this.map.sort(function(a,o){return a[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const a of i)t.push(a);i=r.pop()}this.map.length=0}}function h4(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function g4(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const a=r.length-1;r[a]=r[a]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function w4(){return{flow:{null:{name:"table",tokenize:y4,resolveAll:v4}}}}function y4(e,t,n){const r=this;let i=0,a=0,o;return s;function s(S){let _=r.events.length-1;for(;_>-1;){const G=r.events[_][1].type;if(G==="lineEnding"||G==="linePrefix")_--;else break}const L=_>-1?r.events[_][1].type:null,W=L==="tableHead"||L==="tableRow"?x:l;return W===x&&r.parser.lazy[r.now().line]?n(S):W(S)}function l(S){return e.enter("tableHead"),e.enter("tableRow"),u(S)}function u(S){return S===124||(o=!0,a+=1),f(S)}function f(S){return S===null?n(S):H(S)?a>1?(a=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(S),e.exit("lineEnding"),d):n(S):Y(S)?te(e,f,"whitespace")(S):(a+=1,o&&(o=!1,i+=1),S===124?(e.enter("tableCellDivider"),e.consume(S),e.exit("tableCellDivider"),o=!0,f):(e.enter("data"),c(S)))}function c(S){return S===null||S===124||ue(S)?(e.exit("data"),f(S)):(e.consume(S),S===92?p:c)}function p(S){return S===92||S===124?(e.consume(S),c):c(S)}function d(S){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(S):(e.enter("tableDelimiterRow"),o=!1,Y(S)?te(e,h,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(S):h(S))}function h(S){return S===45||S===58?E(S):S===124?(o=!0,e.enter("tableCellDivider"),e.consume(S),e.exit("tableCellDivider"),y):C(S)}function y(S){return Y(S)?te(e,E,"whitespace")(S):E(S)}function E(S){return S===58?(a+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(S),e.exit("tableDelimiterMarker"),m):S===45?(a+=1,m(S)):S===null||H(S)?P(S):C(S)}function m(S){return S===45?(e.enter("tableDelimiterFiller"),g(S)):C(S)}function g(S){return S===45?(e.consume(S),g):S===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(S),e.exit("tableDelimiterMarker"),w):(e.exit("tableDelimiterFiller"),w(S))}function w(S){return Y(S)?te(e,P,"whitespace")(S):P(S)}function P(S){return S===124?h(S):S===null||H(S)?!o||i!==a?C(S):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(S)):C(S)}function C(S){return n(S)}function x(S){return e.enter("tableRow"),A(S)}function A(S){return S===124?(e.enter("tableCellDivider"),e.consume(S),e.exit("tableCellDivider"),A):S===null||H(S)?(e.exit("tableRow"),t(S)):Y(S)?te(e,A,"whitespace")(S):(e.enter("data"),M(S))}function M(S){return S===null||S===124||ue(S)?(e.exit("data"),A(S)):(e.consume(S),S===92?R:M)}function R(S){return S===92||S===124?(e.consume(S),M):M(S)}}function v4(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,l=0,u,f,c;const p=new m4;for(;++n<e.length;){const d=e[n],h=d[1];d[0]==="enter"?h.type==="tableHead"?(s=!1,l!==0&&(sm(p,t,l,u,f),f=void 0,l=0),u={type:"table",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(n,0,[["enter",u,t]])):h.type==="tableRow"||h.type==="tableDelimiterRow"?(r=!0,c=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,f={type:"tableBody",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(n,0,[["enter",f,t]])),i=h.type==="tableDelimiterRow"?2:f?3:1):i&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],c=Oa(p,t,a,i,void 0,c),a=[0,0,0,0]),o[2]=n)):h.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],c=Oa(p,t,a,i,void 0,c)),a=o,o=[a[1],n,0,0])):h.type==="tableHead"?(s=!0,l=n):h.type==="tableRow"||h.type==="tableDelimiterRow"?(l=n,a[1]!==0?(o[0]=o[1],c=Oa(p,t,a,i,n,c)):o[1]!==0&&(c=Oa(p,t,o,i,n,c)),i=0):i&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&sm(p,t,l,u,f),p.consume(t.events),n=-1;++n<t.events.length;){const d=t.events[n];d[0]==="enter"&&d[1].type==="table"&&(d[1]._align=g4(t.events,n))}return e}function Oa(e,t,n,r,i,a){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",s="tableContent";n[0]!==0&&(a.end=Object.assign({},gr(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const l=gr(t.events,n[1]);if(a={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",a,t]]),n[2]!==0){const u=gr(t.events,n[2]),f=gr(t.events,n[3]),c={type:s,start:Object.assign({},u),end:Object.assign({},f)};if(e.add(n[2],0,[["enter",c,t]]),r!==2){const p=t.events[n[2]],d=t.events[n[3]];if(p[1].end=Object.assign({},d[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const h=n[2]+1,y=n[3]-n[2]-1;e.add(h,y,[])}}e.add(n[3]+1,0,[["exit",c,t]])}return i!==void 0&&(a.end=Object.assign({},gr(t.events,i)),e.add(i,0,[["exit",a,t]]),a=void 0),a}function sm(e,t,n,r,i){const a=[],o=gr(t.events,n);i&&(i.end=Object.assign({},o),a.push(["exit",i,t])),r.end=Object.assign({},o),a.push(["exit",r,t]),e.add(n+1,0,a)}function gr(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const b4={name:"tasklistCheck",tokenize:x4};function k4(){return{text:{91:b4}}}function x4(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),a)}function a(l){return ue(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),s):n(l)}function s(l){return H(l)?t(l):Y(l)?e.check({tokenize:S4},t,n)(l):n(l)}}function S4(e,t,n){return te(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function P4(e){return Vw([Q3(),a4(),p4(e),w4(),k4()])}const E4={};function C4(e){const t=this,n=e||E4,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(P4(n)),a.push(G3()),o.push(q3(n))}const A4={code({inline:e,children:t,...n}){return e?v.jsx("code",{className:"bg-base-200 rounded px-1 py-[2px] text-sm",...n,children:t}):v.jsx("pre",{className:"bg-base-200 rounded p-3 overflow-x-auto whitespace-pre-wrap",children:v.jsx("code",{className:"text-sm",...n,children:t})})},a({href:e,children:t,...n}){return v.jsx("a",{href:e,className:"link",target:"_blank",rel:"noreferrer",...n,children:t})}};function lm({content:e}){return v.jsx(fA,{className:"chat-markdown",remarkPlugins:[C4,xA],components:A4,skipHtml:!0,children:e})}function VoiceOverlay({conv,isGenerating,spokenRef,setPersona,regen,genIdRef}){const{isEnabled:ttsOn,status:ttsStatus,enable:ttsEnable,speak:ttsSpeak,getAnalyser:getAn,voice:curVoice,setVoice:setVoiceName}=Ag(),{status:vadStatus,start:vadStart,stop:vadStop}=mk(),{createCompletion:cc,currentConvId:cid,setVoiceMode:svm,loadedModel:lm,isRemote:isR}=Wt(),{getConversationById:gcb}=Eg(),[personaText,setPersonaText]=T.useState(null),cv=T.useRef(null),trRef=T.useRef(null);T.useEffect(()=>{ttsEnable(),vadStart();return()=>{vadStop()}},[]),T.useEffect(()=>{const K=gcb(cid);if(cid===-1||personaText||!lm&&!isR||K&&K.messages&&K.messages.length>0)return;let acc="";const id=genIdRef.current;setPersonaText("…");cc([{role:"user",content:"You are a friendly AI companion that just powered on. Invent a random personality for yourself: give yourself a name, one personality trait, and a short spoken greeting of 1-2 sentences. Reply only with the greeting, in character."}],t=>{if(id!==genIdRef.current)return;acc=t,setPersonaText(t)}).then(()=>{if(id!==genIdRef.current)return;setPersona(acc),ttsSpeak(acc)}).catch(()=>{id===genIdRef.current&&setPersonaText(null)})},[cid]),T.useEffect(()=>{const canvas=cv.current;if(!canvas)return;const ctx=canvas.getContext("2d"),fft=new Uint8Array(128);let raf=0;const draw=()=>{raf=requestAnimationFrame(draw);const an=getAn();if(an&&an.frequencyBinCount>0)an.getByteFrequencyData(fft);const w=canvas.width,h=canvas.height;ctx.clearRect(0,0,w,h);const n=48,bw=w/n;for(let i=0;i<n;i++){const v=(fft[Math.floor(i*128/n)]||0)/255,bh=Math.max(2,v*h*.9);ctx.fillStyle=`hsla(${200+i*2},90%,${60+v*25}%,.95)`;ctx.fillRect(i*bw,h-bh,bw-2,bh)}};draw();return()=>cancelAnimationFrame(raf)},[]);const msgs=conv&&conv.messages?conv.messages:[],lastIdx=msgs.length-1;T.useEffect(()=>{const el=trRef.current;if(!el)return;const to=setTimeout(()=>el.scrollTo({top:el.scrollHeight,behavior:"smooth"}),60);return()=>clearTimeout(to)},[msgs.length,msgs.length?msgs[msgs.length-1].content:""]);const dotCls=vadStatus==="speaking"?"vo-dot speaking":vadStatus==="listening"?"vo-dot listening":"vo-dot",statusTxt=vadStatus==="speaking"?"Listening…":vadStatus==="listening"?"Listening — speak now":"Idle";return v.jsxs("div",{className:"voice-overlay",children:[v.jsxs("div",{className:"vo-top",children:[v.jsx("span",{className:"vo-title",children:"voice mode"}),v.jsx("button",{className:"vo-exit",onClick:()=>svm(!1),children:"✕ Exit"})]}),v.jsx("canvas",{ref:cv,className:"vo-visualizer",width:900,height:200}),v.jsxs("div",{className:"vo-body",children:[v.jsxs("div",{className:"vo-status",children:[v.jsx("span",{className:dotCls}),v.jsx("span",{children:statusTxt}),ttsStatus==="loading"&&v.jsx("span",{children:" · TTS loading"})]}),personaText&&v.jsx("div",{className:"vo-persona",children:personaText}),v.jsx("div",{className:"vo-transcript",ref:trRef,children:msgs.map((m,ix)=>{if(m.role==="user")return v.jsx("div",{className:"vo-user",children:m.content},m.id);let txt=m.content;if(ix===lastIdx&&isGenerating&&spokenRef.current>0&&spokenRef.current<txt.length)txt=txt.slice(0,spokenRef.current);return v.jsx("div",{className:"vo-sentence",onClick:()=>regen(m.id),title:"Click to regenerate",children:txt.length>0?txt:isGenerating?"▍":"…"},m.id)})}),v.jsx("div",{className:"vo-hint",children:"Speak or type — click any sentence to regenerate"})]})]})};function F4(){const[e,t]=T.useState(""),[n,r]=T.useState(null),[persona,setPersona]=T.useState(null),i=T.useRef(null),a=T.useRef(null),{currentConvId:o,isGenerating:s,createCompletion:l,navigateTo:u,loadedModel:f,isRemote:c,stopCompletion:p,currRuntimeInfo:d,voiceMode:vm}=Wt(),{getConversationById:h,addMessageToConversation:y,editMessageInConversation:E,newConversation:m,truncateConversation:trc}=Eg(),{isEnabled:g,status:w,error:P,enable:C,disable:x,speak:A,stop:M,voice:curVoice,setVoice:setVoiceName}=Ag(),{status:R,error:S,start:_,stop:L,onUtterance:W}=mk(),{status:G,progress:q,error:ae,warmup:ne,transcribe:O}=d0(),V=T.useRef(g),sRef=T.useRef(s);T.useEffect(()=>{V.current=g},[g]),T.useEffect(()=>{sRef.current=s},[s]);const b=T.useRef(0),genId=T.useRef(0),regen=async mid=>{if(sRef.current){p();for(let w=0;w<20&&sRef.current;w++)await new Promise(r=>setTimeout(r,50))}M();const KK=h(o);if(!KK)return;const mArr=KK.messages,ix=mArr.findIndex(m=>m.id===mid);if(ix<=0||mArr[ix].role==="user")return;trc(o,ix),b.current=0;const Re={id:Date.now()+1,content:"",role:"assistant"};y(o,Re);let Ze="";const id=++genId.current;await l(mArr.slice(0,ix),zn=>{if(id!==genId.current)return;Ze=zn,E(o,Re.id,zn);const{sentences:da,nextIndex:pa}=S0(zn,b.current);b.current=pa,V.current&&da.forEach(cs=>A(cs))});if(id!==genId.current)return;const Un=Ze.slice(b.current);V.current&&Un.trim().length>0&&A(Un)};NS(M4,500,s,!0);const K=h(o),ie=(d==null?void 0:d.supportsImage)||(d==null?void 0:d.supportsAudio),k=z=>Q=>{var Re;const se=(Re=Q.target.files)==null?void 0:Re[0];if(!se)return;const Pe=new FileReader;Pe.onload=Fe=>{r({type:z,data:Fe.target.result,dataUrl:URL.createObjectURL(se)})},Pe.readAsArrayBuffer(se),Q.target.value=""},he=async z=>{if(s||!z.trim())return;M();const Q=(K==null?void 0:K.messages)??[],se=n;b.current=0;const Pe={id:Date.now(),content:z,role:"user",mediaData:se??void 0},Re={id:Date.now()+1,content:"",role:"assistant"};let Fe=K==null?void 0:K.id;Fe?(y(Fe,Pe),y(Fe,Re)):(Fe=m(Pe).id,u(ve.CHAT,Fe),y(Fe,Re));let Ze="";const id=++genId.current;await l(vm&&persona?[{role:"system",content:"You are a friendly AI companion. Your persona: "+persona+". Stay in character."},...Q,Pe]:[...Q,Pe],zn=>{if(id!==genId.current)return;Ze=zn,E(Fe,Re.id,zn);const{sentences:da,nextIndex:pa}=S0(zn,b.current);b.current=pa,V.current&&da.forEach(cs=>A(cs))});if(id!==genId.current)return;const Un=Ze.slice(b.current);V.current&&Un.trim().length>0&&A(Un)},Ge=()=>{s||(t(""),r(null),he(e))},U=T.useRef(()=>{});return U.current=he,T.useEffect(()=>W(async(Q,se)=>{try{const Re=(await O(Q,se)||"").replace(/\[BLANK_AUDIO\]/gi,"").trim();Re&&U.current(Re)}catch(Pe){console.error("[asr] transcription failed:",Pe)}}),[W,O]),vm?v.jsx(VoiceOverlay,{conv:K,isGenerating:s,spokenRef:b,setPersona,regen,genIdRef:genId}):v.jsxs(rs,{fitScreen:!0,children:[v.jsxs("div",{className:"chat-messages grow overflow-auto",id:"chat-history",children:[v.jsx("div",{className:"h-10"}),K?v.jsx(v.Fragment,{children:K.messages.map(z=>{var Q,se;return z.role==="user"?v.jsx("div",{className:"chat chat-end",children:v.jsxs("div",{className:"chat-bubble",children:[((Q=z.mediaData)==null?void 0:Q.type)==="image"&&v.jsx("img",{src:z.mediaData.dataUrl,className:"max-w-48 rounded mb-1"}),((se=z.mediaData)==null?void 0:se.type)==="audio"&&v.jsx("audio",{controls:!0,src:z.mediaData.dataUrl,className:"mb-1"}),z.content.length>0&&v.jsx(lm,{content:z.content})]})},z.id):v.jsx("div",{className:"chat chat-start cursor-pointer",onClick:()=>regen(z.id),title:"Click to regenerate this reply",children:v.jsxs("div",{className:"chat-bubble bg-base-100 text-base-content",children:[z.content.length===0&&s&&v.jsx("span",{className:"loading loading-dots"}),z.content.length>0&&v.jsx(lm,{content:z.content})]})},z.id)})}):v.jsx("div",{className:"pt-24 text-center text-xl",children:"Ask me something 👋"})]}),v.jsxs("div",{className:"flex flex-col input-message py-4",children:[s&&v.jsx("div",{className:"text-center",children:v.jsxs("button",{className:"btn btn-outline btn-sm mb-4",onClick:p,children:[v.jsx(Be,{icon:CS}),"Stop generation"]})}),(f||c)&&v.jsxs(v.Fragment,{children:[n&&v.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.type==="image"?v.jsx("img",{src:n.dataUrl,className:"h-16 w-16 object-cover rounded"}):v.jsx("audio",{controls:!0,src:n.dataUrl}),v.jsx("button",{className:"btn btn-xs btn-circle btn-outline",onClick:()=>r(null),children:"✕"})]}),v.jsxs("div",{className:"flex gap-2",children:[ie&&v.jsxs(v.Fragment,{children:[v.jsx("input",{ref:i,type:"file",accept:"image/*",className:"hidden",onChange:k("image")}),v.jsx("input",{ref:a,type:"file",accept:"audio/*",className:"hidden",onChange:k("audio")}),v.jsxs("div",{className:"dropdown dropdown-top",children:[v.jsx("button",{tabIndex:0,className:"btn btn-sm btn-ghost h-full border border-base-content/20",disabled:s,children:"+"}),v.jsxs("ul",{className:"dropdown-content menu bg-base-100 rounded-box z-[1] w-36 p-2 shadow mb-1",children:[(d==null?void 0:d.supportsImage)&&v.jsx("li",{children:v.jsx("a",{onMouseDown:z=>{var Q;z.preventDefault(),(Q=i.current)==null||Q.click()},children:"Image"})}),(d==null?void 0:d.supportsAudio)&&v.jsx("li",{children:v.jsx("a",{onMouseDown:z=>{var Q;z.preventDefault(),(Q=a.current)==null||Q.click()},children:"Audio"})})]})]})]}),v.jsx("button",{className:`btn btn-sm btn-ghost h-full border border-base-content/20 ${R==="listening"?"text-success":R==="speaking"?"text-error":""}`,disabled:R==="loading",onClick:()=>{R==="idle"?(ne(),_()):L()},title:R==="idle"?"Start voice chat (Silero VAD)":"Stop voice chat",children:R==="loading"?v.jsx("span",{className:"loading loading-spinner loading-sm"}):v.jsx(Be,{icon:R==="speaking"?bS:kS})}),v.jsx("button",{className:`btn btn-sm btn-ghost h-full border border-base-content/20 ${g?"text-primary":""}`,disabled:w==="loading",onClick:()=>g?x():C(),title:g?"Stop reading answers aloud":"Read answers aloud with piper TTS",children:w==="loading"?v.jsx("span",{className:"loading loading-spinner loading-sm"}):v.jsx(Be,{icon:g?dp:ES})}),v.jsx("textarea",{className:"textarea textarea-bordered grow",placeholder:"Your message...",disabled:s,value:e,onChange:z=>t(z.target.value),onKeyDown:z=>{z.keyCode==13&&z.shiftKey==!1&&(z.preventDefault(),Ge())}})]}),P&&v.jsxs("small",{className:"text-error block mt-1",children:["TTS error: ",P]}),g&&w==="speaking"&&v.jsxs("small",{className:"opacity-70 block mt-1",children:[v.jsx(Be,{icon:dp})," Reading aloud…"," ",v.jsx("button",{className:"link",onClick:M,children:"Stop"})]}),S&&v.jsxs("small",{className:"text-error block mt-1",children:["Voice error: ",S]}),R==="listening"&&v.jsxs("small",{className:"opacity-70 block mt-1",children:[v.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-success mr-1"}),"Listening — speak to interrupt the assistant"]}),R==="speaking"&&v.jsxs("small",{className:"opacity-70 block mt-1",children:[v.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-error animate-pulse mr-1"}),"Speaking…"]}),ae&&v.jsxs("small",{className:"text-error block mt-1",children:["Speech-to-text error: ",ae]}),G==="loading"&&v.jsxs("small",{className:"opacity-70 block mt-1",children:[v.jsx("span",{className:"loading loading-spinner loading-xs mr-1"}),"Loading speech-to-text model…",q!=null&&` ${Math.round(q*100)}%`]}),G==="transcribing"&&v.jsxs("small",{className:"opacity-70 block mt-1",children:[v.jsx("span",{className:"loading loading-spinner loading-xs mr-1"}),"Transcribing…"]})]}),!f&&!c&&v.jsx(T4,{}),v.jsx("small",{className:"text-center mx-auto opacity-70 pt-2",children:"wllama may generate inaccurate information. Use with your own risk."})]})]})}function T4(){const{navigateTo:e}=Wt();return v.jsxs("div",{role:"alert",className:"alert",children:[v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 shrink-0 stroke-current",fill:"none",viewBox:"0 0 24 24",children:v.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),v.jsx("span",{children:"Model is not loaded"}),v.jsx("div",{children:v.jsx("button",{className:"btn btn-sm btn-primary",onClick:()=>e(ve.MODEL),children:"Select model"})})]})}const M4=()=>{const e=document.getElementById("chat-history");e==null||e.scrollTo({top:e.scrollHeight,behavior:"smooth"})};function _4(){const{navigateTo:e}=Wt();return v.jsx(rs,{children:v.jsxs("div",{className:"guide-text pt-16",children:[v.jsx("h1",{className:"text-2xl font-bold mb-4",children:"Wllama 🦙"}),v.jsxs("div",{className:"mb-3",children:["Wllama is a project based on"," ",v.jsx("a",{href:"https://github.com/ggerganov/llama.cpp",target:"_blank",rel:"noopener",children:"llama.cpp"}),". It enables running LLM inference directly on browser by leveraging the power of ",v.jsx("b",{children:"WebAssembly"}),". It accepts GGUF as model format."]}),v.jsxs("div",{className:"mb-3",children:["Please note that:",v.jsxs("ul",{children:[v.jsx("li",{children:"Due to WebAssembly overhead, performance will not be as good as running llama.cpp in native. Performance degradation can range from 25% to 50%."}),v.jsxs("li",{children:["Due to memory constraint of WebAssembly and emscripten, models larger than 2GB will need to be split."," ",v.jsx("a",{href:"https://github.com/ngxson/wllama?tab=readme-ov-file#split-model",target:"_blank",rel:"noopener",children:"Click here to learn more"})]}),v.jsx("li",{children:"Large model may not fit into RAM, (again) due to memory constraint of WebAssembly."}),v.jsx("li",{children:"Running on smartphone maybe buggy."}),v.jsxs("li",{children:[v.jsx("b",{children:"Safari is not supported"}),", due to lack of Memory64 support."]})]})]}),v.jsxs("div",{className:"mb-3",children:["To get started, go to"," ",v.jsx("button",{className:"btn btn-sm btn-primary btn-outline",onClick:()=>e(ve.MODEL),children:"Manage models"})," ","page to select a model."]}),v.jsx("h1",{className:"text-xl font-bold mb-4 mt-6",children:"Reporting bugs"}),v.jsxs("div",{className:"mb-3",children:["Wllama is in development and many bugs are expected to happen. If you find a bug, please"," ",v.jsx("a",{href:"https://github.com/ngxson/wllama/issues",target:"_blank",rel:"noopener",children:"open a issue"})," ","with log copied from"," ",v.jsx("button",{className:"btn btn-sm btn-primary btn-outline",onClick:()=>e(ve.LOG),children:"Debug log"})]})]})})}function I4(e){return e.split(`
|
| 1310 |
`).map((t,n)=>v.jsxs(Oo.Fragment,{children:[t,v.jsx("br",{})]},n))}function N4(){return v.jsx(rs,{children:v.jsxs("div",{className:"debug-log-screen pt-8",children:[v.jsx("h1",{className:"text-2xl mb-4",children:"Debug log"}),v.jsxs("div",{className:"font-mono bg-base-200 p-2 rounded-lg text-sm mb-16",children:[At.content.length===0&&v.jsx("span",{children:"(Log is empty. Please firstly load a model)"}),At.content.map((e,t)=>v.jsxs(Oo.Fragment,{children:[I4(e),v.jsx("br",{})]},t))]})]})})}function R4(){const[e,t]=T.useState(!1),[n,r]=T.useState(zg()),[inst,setInst]=T.useState(!1),[asrDone,setAsrDone]=T.useState(()=>localStorage.getItem("asrInstalled")==="1"),{models:i,removeCachedModel:a,isLoadingModel:o,isDownloading:s,loadedModel:l,currParams:u,setParams:f}=Wt(),{status:asrStatus,progress:asrProgress,error:asrError,warmup:asrWarmup}=d0(),{voice:curVoice,setVoice:setVoiceName}=Ag(),c=!!(l||s||o),p=d=>h=>{f({...u,[d]:parseFloat(h.target.value||-1)})};return v.jsxs(rs,{children:[v.jsxs("div",{className:"inference-params pt-8",children:[v.jsx("h1",{className:"text-2xl mb-4",children:"Inference parameters"}),v.jsxs("label",{className:"input input-bordered flex items-center gap-2 mb-2",children:["# threads",v.jsx("input",{type:"number",className:"grow",placeholder:"(auto detected)",min:"1",max:"100",step:"1",onChange:p("nThreads"),value:u.nThreads<1?"":u.nThreads,disabled:c})]}),v.jsxs("label",{className:"input input-bordered flex items-center gap-2 mb-2",children:["Context size",v.jsx("input",{type:"number",className:"grow",min:"128",step:"1",onChange:p("nContext"),value:u.nContext,disabled:c})]}),v.jsxs("label",{className:"input input-bordered flex items-center gap-2 mb-2",children:["Max generated tokens",v.jsx("input",{type:"number",className:"grow",min:"10",step:"1",onChange:p("nPredict"),value:u.nPredict})]}),v.jsxs("label",{className:"input input-bordered flex items-center gap-2 mb-2",children:["Temperature",v.jsx("input",{type:"number",className:"grow",min:"0.0",step:"0.05",onChange:p("temperature"),value:u.temperature})]}),v.jsxs("label",{className:"label cursor-pointer justify-start gap-2 mb-2",children:[v.jsx("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:n,onChange:d=>{$b(d.target.checked),r(d.target.checked)}}),v.jsx("span",{className:"label-text",children:"Disable hardware acceleration (force CPU/WASM; threads stay normal)"})]}),v.jsx("button",{className:"btn btn-sm mr-2",onClick:()=>f(Ug),children:"Reset params"}),v.jsx("button",{className:"btn btn-sm mr-2",onClick:async()=>{if(confirm("This will remove all downloaded model files from cache. Continue?"))for(const d of i)await a(d)},disabled:c,children:"Clear cache"})]}),v.jsxs("div",{className:"model-management",children:[v.jsx("h1",{className:"text-2xl mt-6 mb-4",children:"Voice modules"}),v.jsxs("div",{className:"card bg-base-100 w-full mb-2 p-4 flex flex-row items-center gap-3",children:[v.jsx("div",{className:"grow",children:[v.jsx("b",{children:"Voice activity detection (VAD)"}),v.jsx("br",{}),v.jsx("small",{children:"Silero VAD — bundled locally, works offline."})]}),v.jsx("span",{className:"badge badge-success",children:"Installed"})]}),v.jsxs("div",{className:"card bg-base-100 w-full mb-2 p-4",children:[v.jsxs("div",{className:"flex flex-row items-center gap-3 mb-2",children:[v.jsx("div",{className:"grow",children:[v.jsx("b",{children:"Text-to-speech (Piper)"}),v.jsx("br",{}),v.jsx("small",{children:"Bundled voice works offline; other voices stream from HuggingFace (internet required)."})]}),v.jsx("span",{className:"badge badge-success",children:"Installed"})]}),v.jsx("select",{className:"select select-bordered w-full",value:curVoice,onChange:ev=>setVoiceName(ev.target.value),title:"TTS voice",children:VoiceList.map(vz=>v.jsx("option",{value:vz[0],children:vz[1]},vz[0]))})]}),v.jsxs("div",{className:"card bg-base-100 w-full mb-2 p-4 flex flex-row items-center gap-3",children:[v.jsx("div",{className:"grow",children:[v.jsx("b",{children:"Speech-to-text (Whisper)"}),v.jsx("br",{}),v.jsx("small",{children:asrStatus==="ready"?"Whisper model cached — speech-to-text works offline.":"Download the whisper model once so speech-to-text works offline."})]}),asrStatus==="ready"||asrDone?v.jsx("span",{className:"badge badge-success",children:"Installed"}):v.jsx("button",{className:"btn btn-sm btn-primary",disabled:asrStatus==="loading"||asrStatus==="transcribing"||inst,onClick:()=>{setInst(!0),Promise.resolve(asrWarmup()).then(()=>{localStorage.setItem("asrInstalled","1"),setAsrDone(!0)}).catch(()=>{}).finally(()=>setInst(!1))},children:asrStatus==="loading"||inst?v.jsx("span",{className:"loading loading-spinner loading-sm"}):"Install"})]}),asrStatus==="loading"&&asrProgress!=null&&v.jsx("progress",{className:"progress progress-primary w-full",value:Math.round(asrProgress*100),max:"100"}),asrError&&v.jsxs("small",{className:"text-error block mt-1",children:["Speech-to-text error: ",asrError]})]}),v.jsxs("div",{className:"model-management",children:[v.jsxs("h1",{className:"text-2xl mt-6 mb-4",children:["Custom models",v.jsx("button",{className:"btn btn-primary btn-outline btn-sm ml-6",onClick:()=>t(!0),children:"+ Add GGUF"})]}),i.filter(d=>d.isUserAdded).map(d=>v.jsx(um,{model:d,blockModelBtn:c},d.url))]}),v.jsxs("div",{className:"model-management",children:[v.jsx("h1",{className:"text-2xl mt-6 mb-4",children:"Recommended models"}),i.filter(d=>!d.isUserAdded).map(d=>v.jsx(um,{model:d,blockModelBtn:c},d.url))]}),v.jsx("div",{className:"h-10"}),e&&v.jsx(L4,{onClose:()=>t(!1)})]})}function L4({onClose:e}){const{isLoadingModel:t,addCustomModel:n}=Wt(),[r,i]=T.useState(""),[a,o]=T.useState(""),[s,l]=T.useState(""),[u,f]=T.useState([]),[c,p]=T.useState([]),[d,h]=T.useState(new AbortController),[y,E]=T.useState();g0(async()=>{if(r.length<2){f([]),p([]);return}try{const P=await(await fetch(`https://huggingface.co/api/models/${r}`,{signal:d.signal})).json();if(P.siblings){const C=P.siblings.map(x=>x.rfilename).filter(x=>Ig(x));f(C.filter(x=>!x.toLowerCase().includes("mmproj"))),p(C.filter(x=>x.toLowerCase().includes("mmproj"))),E("")}else E("no model found or it is private"),f([]),p([])}catch(w){w.name!=="AbortError"&&(E((w==null?void 0:w.message)??"unknown error"),f([]),p([]))}},[r],500),T.useEffect(()=>{u.length===0&&o("")},[u]),T.useEffect(()=>{c.length===0&&l("")},[c]);const m=`https://huggingface.co/${r}/resolve/main`,g=async()=>{try{await n(`${m}/${a}`,s?`${m}/${s}`:void 0),e()}catch(w){E((w==null?void 0:w.message)??"unknown error")}};return v.jsx("dialog",{className:"modal modal-open",children:v.jsxs("div",{className:"modal-box",children:[v.jsx("h3",{className:"font-bold text-lg",children:"Add custom GGUF"}),v.jsxs("div",{className:"mt-4",children:["Max GGUF file size is 2GB. If your model is bigger than 2GB, please"," ",v.jsx("a",{href:"https://github.com/ngxson/wllama?tab=readme-ov-file#split-model",target:"_blank",rel:"noopener",className:"text-primary",children:"follow this guide"})," ","to split it into smaller shards."]}),v.jsxs("div",{className:"mt-4",children:[v.jsxs("label",{className:"input input-bordered flex items-center gap-2 mb-2",children:["HF repo",v.jsx("input",{type:"text",className:"grow",placeholder:"{username}/{repo}",value:r,onChange:w=>{d.abort(),i(w.target.value),h(new AbortController)}})]}),v.jsxs("select",{className:"select select-bordered w-full mb-2",value:a,onChange:w=>o(w.target.value),children:[v.jsx("option",{value:"",children:"Select a model file"}),u.map(w=>v.jsx("option",{value:w,children:w},w))]}),c.length>0&&v.jsxs("select",{className:"select select-bordered w-full",value:s,onChange:w=>l(w.target.value),children:[v.jsx("option",{value:"",children:"Select mmproj file (optional)"}),c.map(w=>v.jsx("option",{value:w,children:w},w))]})]}),y&&v.jsxs("div",{className:"mt-4 text-error",children:["Error: ",y]}),v.jsxs("div",{className:"modal-action",children:[v.jsxs("button",{className:"btn btn-primary",disabled:t||r.length<2||a.length<5,onClick:g,children:[t&&v.jsx("span",{className:"loading loading-spinner"}),"Add model"]}),v.jsx("button",{className:"btn",disabled:t,onClick:e,children:"Close"})]})]})})}function um({model:e,blockModelBtn:t}){const{downloadModel:n,removeCachedModel:r,loadModel:i,unloadModel:a,removeCustomModel:o,currRuntimeInfo:s,navigateTo:l}=Wt(),u=e,f=parseInt(Math.round(u.downloadPercent*100).toString());return v.jsx("div",{className:`card bg-base-100 w-full mb-2 ${u.state===Te.LOADED?"border-2 border-primary":""}`,children:v.jsxs("div",{className:"card-body p-4 flex flex-row",children:[v.jsxs("div",{className:"grow",children:[v.jsx("b",{children:u.hfPath.replace(/-\d{5}-of-\d{5}/,"-(shards)")}),v.jsx("br",{}),v.jsxs("small",{children:["HF repo: ",u.hfModel,v.jsx("br",{}),"Size: ",h0(u.size),u.size>jb&&v.jsx("div",{className:"tooltip tooltip-right","data-tip":"Big model size, may not be able to load due to RAM limitation",children:v.jsx("span",{className:"text-yellow-300 ml-2",children:v.jsx(Be,{icon:MS})})}),u.state==Te.DOWNLOADING?` - Downloaded: ${f}%`:"",u.modalities&&u.modalities.length>0&&v.jsxs(v.Fragment,{children:[" ",u.modalities.map(c=>v.jsx("span",{className:"badge badge-sm badge-accent ml-1",children:c},c))]})]}),u.state===Te.LOADED&&s&&v.jsxs(v.Fragment,{children:[v.jsx("br",{}),v.jsx(cm,{text:"Multithread",on:s.isMultithread})," ",v.jsx(cm,{text:"Chat template",on:s.hasChatTemplate})]}),u.state===Te.DOWNLOADING&&v.jsx("div",{children:v.jsx("progress",{className:"progress progress-primary w-full",value:f,max:"100"})}),u.state===Te.LOADING&&v.jsx("div",{children:v.jsx("progress",{className:"progress progress-primary w-full"})})]}),v.jsxs("div",{children:[u.state===Te.NOT_DOWNLOADED&&v.jsx("button",{className:"btn btn-primary btn-sm mr-2",onClick:()=>n(u),disabled:t,children:"Download"}),u.state===Te.READY&&v.jsxs(v.Fragment,{children:[v.jsx("button",{className:"btn btn-primary btn-sm mr-2",onClick:()=>i(u),disabled:t,children:"Load model"}),v.jsx("button",{className:"btn btn-outline btn-error btn-sm mr-2",onClick:()=>{confirm("Are you sure to remove this model from cache?")&&r(u)},disabled:t,children:v.jsx(Be,{icon:Cw})})]}),u.state===Te.LOADED&&v.jsxs(v.Fragment,{children:[v.jsx("button",{className:"btn btn-primary btn-sm mr-2",onClick:()=>l(ve.CHAT),children:"Start chat"}),v.jsx("button",{className:"btn btn-outline btn-primary btn-sm mr-2",onClick:()=>a(),children:"Unload"})]}),u.state===Te.NOT_DOWNLOADED&&u.isUserAdded&&v.jsx("button",{className:"btn btn-outline btn-error btn-sm mr-2",onClick:()=>{confirm("Are you sure to remove this model from the list?")&&o(u)},disabled:t,children:v.jsx(Be,{icon:Aw})}),u.state==Te.DOWNLOADING&&v.jsx("span",{className:"loading loading-spinner"})]})]})},u.url)}function cm({text:e,on:t}){return v.jsxs(v.Fragment,{children:[t?v.jsx("span",{className:"text-green-300",children:v.jsx(Be,{icon:FS})}):v.jsx("span",{className:"text-red-400",children:v.jsx(Be,{icon:Aw})}),v.jsxs("span",{className:"text-sm",children:[" ",e]})]})}function O4(){const{remoteConfig:e,isRemote:t,remoteError:n,setRemoteConfig:r,clearRemoteConfig:i,voiceMode:vm,setVoiceMode:svm,navigateTo:nav}=Wt(),[a,o]=T.useState((e==null?void 0:e.baseUrl)??""),s=()=>{const l=a.trim();l?r({baseUrl:l,apiKey:(e==null?void 0:e.apiKey)??"",model:(e==null?void 0:e.model)??""}):i()};return v.jsxs("div",{className:"navbar bg-base-100 shadow-md z-40",children:[v.jsx("div",{className:"flex-none",children:v.jsx("label",{htmlFor:"my-drawer-2",className:"btn btn-square btn-ghost flex lg:hidden",children:v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",className:"inline-block h-5 w-5 stroke-current",children:v.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M4 6h16M4 12h16M4 18h16"})})})}),v.jsx("a",{className:"btn btn-ghost text-xl",children:"wllama"}),v.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[v.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${t?"bg-success":"bg-base-300"}`,title:t?"Using remote LLM API":"Using local model"}),v.jsx("input",{className:"input input-sm input-bordered w-40 sm:w-64",placeholder:"API URL e.g. http://localhost:8080/v1",value:a,onChange:l=>o(l.target.value),onBlur:s,onKeyDown:l=>{l.key==="Enter"&&(s(),l.target.blur())}}),n&&v.jsx("span",{className:"text-error text-xs max-w-[16rem] truncate",title:n,children:n})]}),v.jsx("div",{className:"flex-1"}),v.jsx("button",{className:`btn btn-sm ${vm?"btn-primary":"btn-outline"}`,onClick:()=>{svm(!vm),vm||nav(ve.CHAT)},title:vm?"Exit voice-to-voice mode":"Enter voice-to-voice mode",children:vm?"✕ Voice":"🎙 Voice"})]})}function D4({children:e}){const{currentConvId:t,navigateTo:n,currScreen:r,loadedModel:i}=Wt(),{conversations:a,getConversationById:o,deleteConversation:s}=Eg(),l=o(t);return v.jsxs(v.Fragment,{children:[v.jsx("input",{id:"my-drawer-2",type:"checkbox",className:"drawer-toggle"}),v.jsxs("div",{className:"drawer-side h-screen lg:h-[calc(100vh-4rem)] z-50",children:[v.jsx("label",{htmlFor:"my-drawer-2","aria-label":"close sidebar",className:"drawer-overlay block lg:hidden"}),v.jsxs("div",{className:"h-screen lg:max-h-[calc(100vh-4rem)] flex flex-col text-base-content bg-base-200",children:[v.jsx("div",{className:"grow w-80 overflow-auto p-4",children:v.jsxs("ul",{className:"menu gap-1 overflow-x-hidden",children:[v.jsx("li",{onClick:()=>n(ve.CHAT),children:v.jsx("a",{className:!l&&r===ve.CHAT?"active":"",children:"+ New conversation"})}),a.map(u=>{var f;return v.jsxs("li",{onClick:()=>n(ve.CHAT,u.id),className:"group flex flex-row",children:[v.jsx("a",{className:`${u.id===t?"active":""} flex-1 min-w-0`,children:v.jsx("div",{className:"truncate",children:(f=u.messages[0])==null?void 0:f.content})}),v.jsx("span",{className:"text-right hidden group-hover:inline",children:v.jsx(Be,{icon:Cw,onClick:c=>{c.preventDefault(),confirm("Are you sure to delete this conversation?")&&(n(ve.CHAT),s(u.id))}})})]},u.id)})]})}),v.jsxs("div",{className:"w-80 px-4 pt-0 pb-8",children:[v.jsx("div",{className:"divider my-2"}),i&&v.jsxs("div",{className:"text-sm px-4 pb-2",children:["Model: ",i.hfModel]}),v.jsxs("ul",{className:"menu gap-1",children:[v.jsx("li",{onClick:()=>n(ve.GUIDE),children:v.jsxs("a",{className:r===ve.GUIDE?"active":"",children:[v.jsx(Be,{icon:PS})," Guide"]})}),v.jsx("li",{onClick:()=>n(ve.MODEL),children:v.jsxs("a",{className:r===ve.MODEL?"active":"",children:[v.jsx(Be,{icon:_S})," Manage models"]})}),v.jsx("li",{onClick:()=>n(ve.LOG),children:v.jsxs("a",{className:r===ve.LOG?"active":"",children:[v.jsx(Be,{icon:AS})," Debug log"]})}),v.jsx("li",{children:v.jsxs("a",{href:"https://github.com/ngxson/wllama",target:"_blank",rel:"noopener",children:[v.jsx(Be,{icon:xS})," Github"]})})]}),v.jsxs("div",{className:"text-xs pl-6 pt-2",children:["Version ",Db]})]})]})]}),v.jsx("div",{className:"drawer-content grow",children:e})]})}async function U4(){throw new Error("Benchmark is not ready yet, stay tuned!")}async function z4(){throw new Error("Perplexity test is not ready yet, stay tuned!")}window.__benchmark=U4;window.__perplexity=z4;function j4(){return v.jsx(w0,{children:v.jsx(tk,{children:v.jsx(T0,{children:v.jsx(f0,{children:v.jsx(pk,{children:v.jsx(B4,{})})})})})})}function B4(){const{currScreen:e}=Wt();return v.jsxs("div",{className:"flex flex-col drawer h-screen w-screen overflow-hidden",children:[v.jsx(O4,{}),v.jsx("div",{className:"grow flex flex-row lg:drawer-open h-[calc(100vh-4rem)]",children:v.jsxs(D4,{children:[e===ve.MODEL&&v.jsx(R4,{}),e===ve.CHAT&&v.jsx(F4,{}),e===ve.GUIDE&&v.jsx(_4,{}),e===ve.LOG&&v.jsx(N4,{})]})})]})}ml.createRoot(document.getElementById("root")).render(v.jsx(j4,{}));
|
|
|
|
| 1306 |
`))+1))}const o="#".repeat(i),s=n.enter("headingAtx"),l=n.enter("phrasing");a.move(o+" ");let u=n.containerPhrasing(e,{before:"# ",after:`
|
| 1307 |
`,...a.current()});return/^[\t ]/.test(u)&&(u=ta(u.charCodeAt(0))+u.slice(1)),u=u?o+" "+u:o,n.options.closeAtx&&(u+=" "+o),l(),s(),u}gy.peek=h3;function gy(e){return e.value||""}function h3(){return"<"}wy.peek=g3;function wy(e,t,n,r){const i=df(n),a=i==='"'?"Quote":"Apostrophe",o=n.enter("image");let s=n.enter("label");const l=n.createTracker(r);let u=l.move("![");return u+=l.move(n.safe(e.alt,{before:u,after:"]",...l.current()})),u+=l.move("]("),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(n.safe(e.url,{before:u,after:">",...l.current()})),u+=l.move(">")):(s=n.enter("destinationRaw"),u+=l.move(n.safe(e.url,{before:u,after:e.title?" ":")",...l.current()}))),s(),e.title&&(s=n.enter(`title${a}`),u+=l.move(" "+i),u+=l.move(n.safe(e.title,{before:u,after:i,...l.current()})),u+=l.move(i),s()),u+=l.move(")"),o(),u}function g3(){return"!"}yy.peek=w3;function yy(e,t,n,r){const i=e.referenceType,a=n.enter("imageReference");let o=n.enter("label");const s=n.createTracker(r);let l=s.move("![");const u=n.safe(e.alt,{before:l,after:"]",...s.current()});l+=s.move(u+"]["),o();const f=n.stack;n.stack=[],o=n.enter("reference");const c=n.safe(n.associationId(e),{before:l,after:"]",...s.current()});return o(),n.stack=f,a(),i==="full"||!u||u!==c?l+=s.move(c+"]"):i==="shortcut"?l=l.slice(0,-1):l+=s.move("]"),l}function w3(){return"!"}vy.peek=y3;function vy(e,t,n){let r=e.value||"",i="`",a=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++a<n.unsafe.length;){const o=n.unsafe[a],s=n.compilePattern(o);let l;if(o.atBreak)for(;l=s.exec(r);){let u=l.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(l.index+1)}}return i+r+i}function y3(){return"`"}function by(e,t){const n=nf(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}ky.peek=v3;function ky(e,t,n,r){const i=df(n),a=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let s,l;if(by(e,n)){const f=n.stack;n.stack=[],s=n.enter("autolink");let c=o.move("<");return c+=o.move(n.containerPhrasing(e,{before:c,after:">",...o.current()})),c+=o.move(">"),s(),n.stack=f,c}s=n.enter("link"),l=n.enter("label");let u=o.move("[");return u+=o.move(n.containerPhrasing(e,{before:u,after:"](",...o.current()})),u+=o.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=o.move("<"),u+=o.move(n.safe(e.url,{before:u,after:">",...o.current()})),u+=o.move(">")):(l=n.enter("destinationRaw"),u+=o.move(n.safe(e.url,{before:u,after:e.title?" ":")",...o.current()}))),l(),e.title&&(l=n.enter(`title${a}`),u+=o.move(" "+i),u+=o.move(n.safe(e.title,{before:u,after:i,...o.current()})),u+=o.move(i),l()),u+=o.move(")"),s(),u}function v3(e,t,n){return by(e,n)?"<":"["}xy.peek=b3;function xy(e,t,n,r){const i=e.referenceType,a=n.enter("linkReference");let o=n.enter("label");const s=n.createTracker(r);let l=s.move("[");const u=n.containerPhrasing(e,{before:l,after:"]",...s.current()});l+=s.move(u+"]["),o();const f=n.stack;n.stack=[],o=n.enter("reference");const c=n.safe(n.associationId(e),{before:l,after:"]",...s.current()});return o(),n.stack=f,a(),i==="full"||!u||u!==c?l+=s.move(c+"]"):i==="shortcut"?l=l.slice(0,-1):l+=s.move("]"),l}function b3(){return"["}function pf(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function k3(e){const t=pf(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function x3(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Sy(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function S3(e,t,n,r){const i=n.enter("list"),a=n.bulletCurrent;let o=e.ordered?x3(n):pf(n);const s=e.ordered?o==="."?")":".":k3(n);let l=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){const f=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&f&&(!f.children||!f.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),Sy(n)===o&&f){let c=-1;for(;++c<e.children.length;){const p=e.children[c];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(o=s),n.bulletCurrent=o;const u=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),u}function P3(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function E3(e,t,n,r){const i=P3(n);let a=n.bulletCurrent||pf(n);t&&t.type==="list"&&t.ordered&&(a=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);const s=n.createTracker(r);s.move(a+" ".repeat(o-a.length)),s.shift(o);const l=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,s.current()),f);return l(),u;function f(c,p,d){return p?(d?"":" ".repeat(o))+c:(d?a:a+" ".repeat(o-a.length))+c}}function C3(e,t,n,r){const i=n.enter("paragraph"),a=n.enter("phrasing"),o=n.containerPhrasing(e,r);return a(),i(),o}const A3=ls(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function F3(e,t,n,r){return(e.children.some(function(o){return A3(o)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function T3(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Py.peek=M3;function Py(e,t,n,r){const i=T3(n),a=n.enter("strong"),o=n.createTracker(r),s=o.move(i+i);let l=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()}));const u=l.charCodeAt(0),f=No(r.before.charCodeAt(r.before.length-1),u,i);f.inside&&(l=ta(u)+l.slice(1));const c=l.charCodeAt(l.length-1),p=No(r.after.charCodeAt(0),c,i);p.inside&&(l=l.slice(0,-1)+ta(c));const d=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:p.outside,before:f.outside},s+l+d}function M3(e,t,n){return n.options.strong||"*"}function _3(e,t,n,r){return n.safe(e.value,r)}function I3(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function N3(e,t,n){const r=(Sy(n)+(n.options.ruleSpaces?" ":"")).repeat(I3(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Ey={blockquote:n3,break:im,code:l3,definition:c3,emphasis:hy,hardBreak:im,heading:m3,html:gy,image:wy,imageReference:yy,inlineCode:vy,link:ky,linkReference:xy,list:S3,listItem:E3,paragraph:C3,root:F3,strong:Py,text:_3,thematicBreak:N3};function R3(){return{enter:{table:L3,tableData:am,tableHeader:am,tableRow:D3},exit:{codeText:U3,table:O3,tableData:pl,tableHeader:pl,tableRow:pl}}}function L3(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function O3(e){this.exit(e),this.data.inTable=void 0}function D3(e){this.enter({type:"tableRow",children:[]},e)}function pl(e){this.exit(e)}function am(e){this.enter({type:"tableCell",children:[]},e)}function U3(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,z3));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function z3(e,t){return t==="|"?t:e}function j3(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
| 1308 |
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:o,tableCell:l,tableRow:s}};function o(d,h,y,E){return u(f(d,y,E),d.align)}function s(d,h,y,E){const m=c(d,y,E),g=u([m]);return g.slice(0,g.indexOf(`
|
| 1309 |
+
`))}function l(d,h,y,E){const m=y.enter("tableCell"),g=y.enter("phrasing"),w=y.containerPhrasing(d,{...E,before:a,after:a});return g(),m(),w}function u(d,h){return e3(d,{align:h,alignDelimiters:r,padding:n,stringLength:i})}function f(d,h,y){const E=d.children;let m=-1;const g=[],w=h.enter("table");for(;++m<E.length;)g[m]=c(E[m],h,y);return w(),g}function c(d,h,y){const E=d.children;let m=-1;const g=[],w=h.enter("tableRow");for(;++m<E.length;)g[m]=l(E[m],d,h,y);return w(),g}function p(d,h,y){let E=Ey.inlineCode(d,h,y);return y.stack.includes("tableCell")&&(E=E.replace(/\|/g,"\\$&")),E}}function B3(){return{exit:{taskListCheckValueChecked:om,taskListCheckValueUnchecked:om,paragraph:H3}}}function V3(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:W3}}}function om(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function H3(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let a=-1,o;for(;++a<i.length;){const s=i[a];if(s.type==="paragraph"){o=s;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function W3(e,t,n,r){const i=e.children[0],a=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",s=n.createTracker(r);a&&s.move(o);let l=Ey.listItem(e,t,n,{...r,...s.current()});return a&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),l;function u(f){return f+o}}function G3(){return[SA(),WA(),XA(),R3(),B3()]}function q3(e){return{extensions:[PA(),GA(e),QA(),j3(e),V3()]}}const K3={tokenize:$3,partial:!0},Cy={tokenize:e4,partial:!0},Ay={tokenize:t4,partial:!0},Fy={tokenize:n4,partial:!0},X3={tokenize:r4,partial:!0},Ty={name:"wwwAutolink",tokenize:Z3,previous:_y},My={name:"protocolAutolink",tokenize:Y3,previous:Iy},un={name:"emailAutolink",tokenize:J3,previous:Ny},Gt={};function Q3(){return{text:Gt}}let Bn=48;for(;Bn<123;)Gt[Bn]=un,Bn++,Bn===58?Bn=65:Bn===91&&(Bn=97);Gt[43]=un;Gt[45]=un;Gt[46]=un;Gt[95]=un;Gt[72]=[un,My];Gt[104]=[un,My];Gt[87]=[un,Ty];Gt[119]=[un,Ty];function J3(e,t,n){const r=this;let i,a;return o;function o(c){return!ju(c)||!Ny.call(r,r.previous)||mf(r.events)?n(c):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(c))}function s(c){return ju(c)?(e.consume(c),s):c===64?(e.consume(c),l):n(c)}function l(c){return c===46?e.check(X3,f,u)(c):c===45||c===95||Ve(c)?(a=!0,e.consume(c),l):f(c)}function u(c){return e.consume(c),i=!0,l}function f(c){return a&&i&&Ke(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(c)):n(c)}}function Z3(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!_y.call(r,r.previous)||mf(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(K3,e.attempt(Cy,e.attempt(Ay,a),n),n)(o))}function a(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function Y3(e,t,n){const r=this;let i="",a=!1;return o;function o(c){return(c===72||c===104)&&Iy.call(r,r.previous)&&!mf(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(c),e.consume(c),s):n(c)}function s(c){if(Ke(c)&&i.length<5)return i+=String.fromCodePoint(c),e.consume(c),s;if(c===58){const p=i.toLowerCase();if(p==="http"||p==="https")return e.consume(c),l}return n(c)}function l(c){return c===47?(e.consume(c),a?u:(a=!0,l)):n(c)}function u(c){return c===null||To(c)||ue(c)||sr(c)||as(c)?n(c):e.attempt(Cy,e.attempt(Ay,f),n)(c)}function f(c){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(c)}}function $3(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),a):n(o)}function a(o){return o===null?n(o):t(o)}}function e4(e,t,n){let r,i,a;return o;function o(u){return u===46||u===95?e.check(Fy,l,s)(u):u===null||ue(u)||sr(u)||u!==45&&as(u)?l(u):(a=!0,e.consume(u),o)}function s(u){return u===95?r=!0:(i=r,r=void 0),e.consume(u),o}function l(u){return i||r||!a?n(u):t(u)}}function t4(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Fy,t,a)(o):o===null||ue(o)||sr(o)?t(o):(e.consume(o),i)}function a(o){return o===41&&r++,e.consume(o),i}}function n4(e,t,n){return r;function r(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(e.consume(s),r):s===38?(e.consume(s),a):s===93?(e.consume(s),i):s===60||s===null||ue(s)||sr(s)?t(s):n(s)}function i(s){return s===null||s===40||s===91||ue(s)||sr(s)?t(s):r(s)}function a(s){return Ke(s)?o(s):n(s)}function o(s){return s===59?(e.consume(s),r):Ke(s)?(e.consume(s),o):n(s)}}function r4(e,t,n){return r;function r(a){return e.consume(a),i}function i(a){return Ve(a)?n(a):t(a)}}function _y(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||ue(e)}function Iy(e){return!Ke(e)}function Ny(e){return!(e===47||ju(e))}function ju(e){return e===43||e===45||e===46||e===95||Ve(e)}function mf(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const i4={tokenize:d4,partial:!0};function a4(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:u4,continuation:{tokenize:c4},exit:f4}},text:{91:{name:"gfmFootnoteCall",tokenize:l4},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:o4,resolveTo:s4}}}}function o4(e,t,n){const r=this;let i=r.events.length;const a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return s;function s(l){if(!o||!o._balanced)return n(l);const u=It(r.sliceSerialize({start:o.end,end:r.now()}));return u.codePointAt(0)!==94||!a.includes(u.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function s4(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...s),e}function l4(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,o;return s;function s(c){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),l}function l(c){return c!==94?n(c):(e.enter("gfmFootnoteCallMarker"),e.consume(c),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(c){if(a>999||c===93&&!o||c===null||c===91||ue(c))return n(c);if(c===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(It(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(c)}return ue(c)||(o=!0),a++,e.consume(c),c===92?f:u}function f(c){return c===91||c===92||c===93?(e.consume(c),a++,u):u(c)}}function u4(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a,o=0,s;return l;function l(h){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(h),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(h){return h===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(h),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",f):n(h)}function f(h){if(o>999||h===93&&!s||h===null||h===91||ue(h))return n(h);if(h===93){e.exit("chunkString");const y=e.exit("gfmFootnoteDefinitionLabelString");return a=It(r.sliceSerialize(y)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(h),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return ue(h)||(s=!0),o++,e.consume(h),h===92?c:f}function c(h){return h===91||h===92||h===93?(e.consume(h),o++,f):f(h)}function p(h){return h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),i.includes(a)||i.push(a),te(e,d,"gfmFootnoteDefinitionWhitespace")):n(h)}function d(h){return t(h)}}function c4(e,t,n){return e.check(ca,t,e.attempt(i4,t,n))}function f4(e){e.exit("gfmFootnoteDefinition")}function d4(e,t,n){const r=this;return te(e,i,"gfmFootnoteDefinitionIndent",5);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(a):n(a)}}function p4(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,s){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let u=l;for(;u--;)if(o[u][0]==="exit"&&o[u][1].type==="strikethroughSequenceTemporary"&&o[u][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[u][1].end.offset-o[u][1].start.offset){o[l][1].type="strikethroughSequence",o[u][1].type="strikethroughSequence";const f={type:"strikethrough",start:Object.assign({},o[u][1].start),end:Object.assign({},o[l][1].end)},c={type:"strikethroughText",start:Object.assign({},o[u][1].end),end:Object.assign({},o[l][1].start)},p=[["enter",f,s],["enter",o[u][1],s],["exit",o[u][1],s],["enter",c,s]],d=s.parser.constructs.insideSpan.null;d&&dt(p,p.length,0,os(d,o.slice(u+1,l),s)),dt(p,p.length,0,[["exit",c,s],["enter",o[l][1],s],["exit",o[l][1],s],["exit",f,s]]),dt(o,u-1,l-u+3,p),l=u+p.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function a(o,s,l){const u=this.previous,f=this.events;let c=0;return p;function p(h){return u===126&&f[f.length-1][1].type!=="characterEscape"?l(h):(o.enter("strikethroughSequenceTemporary"),d(h))}function d(h){const y=Xr(u);if(h===126)return c>1?l(h):(o.consume(h),c++,d);if(c<2&&!n)return l(h);const E=o.exit("strikethroughSequenceTemporary"),m=Xr(h);return E._open=!m||m===2&&!!y,E._close=!y||y===2&&!!m,s(h)}}}class m4{constructor(){this.map=[]}add(t,n,r){h4(this,t,n,r)}consume(t){if(this.map.sort(function(a,o){return a[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const a of i)t.push(a);i=r.pop()}this.map.length=0}}function h4(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function g4(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const a=r.length-1;r[a]=r[a]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function w4(){return{flow:{null:{name:"table",tokenize:y4,resolveAll:v4}}}}function y4(e,t,n){const r=this;let i=0,a=0,o;return s;function s(S){let _=r.events.length-1;for(;_>-1;){const G=r.events[_][1].type;if(G==="lineEnding"||G==="linePrefix")_--;else break}const L=_>-1?r.events[_][1].type:null,W=L==="tableHead"||L==="tableRow"?x:l;return W===x&&r.parser.lazy[r.now().line]?n(S):W(S)}function l(S){return e.enter("tableHead"),e.enter("tableRow"),u(S)}function u(S){return S===124||(o=!0,a+=1),f(S)}function f(S){return S===null?n(S):H(S)?a>1?(a=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(S),e.exit("lineEnding"),d):n(S):Y(S)?te(e,f,"whitespace")(S):(a+=1,o&&(o=!1,i+=1),S===124?(e.enter("tableCellDivider"),e.consume(S),e.exit("tableCellDivider"),o=!0,f):(e.enter("data"),c(S)))}function c(S){return S===null||S===124||ue(S)?(e.exit("data"),f(S)):(e.consume(S),S===92?p:c)}function p(S){return S===92||S===124?(e.consume(S),c):c(S)}function d(S){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(S):(e.enter("tableDelimiterRow"),o=!1,Y(S)?te(e,h,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(S):h(S))}function h(S){return S===45||S===58?E(S):S===124?(o=!0,e.enter("tableCellDivider"),e.consume(S),e.exit("tableCellDivider"),y):C(S)}function y(S){return Y(S)?te(e,E,"whitespace")(S):E(S)}function E(S){return S===58?(a+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(S),e.exit("tableDelimiterMarker"),m):S===45?(a+=1,m(S)):S===null||H(S)?P(S):C(S)}function m(S){return S===45?(e.enter("tableDelimiterFiller"),g(S)):C(S)}function g(S){return S===45?(e.consume(S),g):S===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(S),e.exit("tableDelimiterMarker"),w):(e.exit("tableDelimiterFiller"),w(S))}function w(S){return Y(S)?te(e,P,"whitespace")(S):P(S)}function P(S){return S===124?h(S):S===null||H(S)?!o||i!==a?C(S):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(S)):C(S)}function C(S){return n(S)}function x(S){return e.enter("tableRow"),A(S)}function A(S){return S===124?(e.enter("tableCellDivider"),e.consume(S),e.exit("tableCellDivider"),A):S===null||H(S)?(e.exit("tableRow"),t(S)):Y(S)?te(e,A,"whitespace")(S):(e.enter("data"),M(S))}function M(S){return S===null||S===124||ue(S)?(e.exit("data"),A(S)):(e.consume(S),S===92?R:M)}function R(S){return S===92||S===124?(e.consume(S),M):M(S)}}function v4(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,l=0,u,f,c;const p=new m4;for(;++n<e.length;){const d=e[n],h=d[1];d[0]==="enter"?h.type==="tableHead"?(s=!1,l!==0&&(sm(p,t,l,u,f),f=void 0,l=0),u={type:"table",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(n,0,[["enter",u,t]])):h.type==="tableRow"||h.type==="tableDelimiterRow"?(r=!0,c=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,f={type:"tableBody",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(n,0,[["enter",f,t]])),i=h.type==="tableDelimiterRow"?2:f?3:1):i&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],c=Oa(p,t,a,i,void 0,c),a=[0,0,0,0]),o[2]=n)):h.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],c=Oa(p,t,a,i,void 0,c)),a=o,o=[a[1],n,0,0])):h.type==="tableHead"?(s=!0,l=n):h.type==="tableRow"||h.type==="tableDelimiterRow"?(l=n,a[1]!==0?(o[0]=o[1],c=Oa(p,t,a,i,n,c)):o[1]!==0&&(c=Oa(p,t,o,i,n,c)),i=0):i&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&sm(p,t,l,u,f),p.consume(t.events),n=-1;++n<t.events.length;){const d=t.events[n];d[0]==="enter"&&d[1].type==="table"&&(d[1]._align=g4(t.events,n))}return e}function Oa(e,t,n,r,i,a){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",s="tableContent";n[0]!==0&&(a.end=Object.assign({},gr(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const l=gr(t.events,n[1]);if(a={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",a,t]]),n[2]!==0){const u=gr(t.events,n[2]),f=gr(t.events,n[3]),c={type:s,start:Object.assign({},u),end:Object.assign({},f)};if(e.add(n[2],0,[["enter",c,t]]),r!==2){const p=t.events[n[2]],d=t.events[n[3]];if(p[1].end=Object.assign({},d[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const h=n[2]+1,y=n[3]-n[2]-1;e.add(h,y,[])}}e.add(n[3]+1,0,[["exit",c,t]])}return i!==void 0&&(a.end=Object.assign({},gr(t.events,i)),e.add(i,0,[["exit",a,t]]),a=void 0),a}function sm(e,t,n,r,i){const a=[],o=gr(t.events,n);i&&(i.end=Object.assign({},o),a.push(["exit",i,t])),r.end=Object.assign({},o),a.push(["exit",r,t]),e.add(n+1,0,a)}function gr(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const b4={name:"tasklistCheck",tokenize:x4};function k4(){return{text:{91:b4}}}function x4(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),a)}function a(l){return ue(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),s):n(l)}function s(l){return H(l)?t(l):Y(l)?e.check({tokenize:S4},t,n)(l):n(l)}}function S4(e,t,n){return te(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function P4(e){return Vw([Q3(),a4(),p4(e),w4(),k4()])}const E4={};function C4(e){const t=this,n=e||E4,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(P4(n)),a.push(G3()),o.push(q3(n))}const A4={code({inline:e,children:t,...n}){return e?v.jsx("code",{className:"bg-base-200 rounded px-1 py-[2px] text-sm",...n,children:t}):v.jsx("pre",{className:"bg-base-200 rounded p-3 overflow-x-auto whitespace-pre-wrap",children:v.jsx("code",{className:"text-sm",...n,children:t})})},a({href:e,children:t,...n}){return v.jsx("a",{href:e,className:"link",target:"_blank",rel:"noreferrer",...n,children:t})}};function lm({content:e}){return v.jsx(fA,{className:"chat-markdown",remarkPlugins:[C4,xA],components:A4,skipHtml:!0,children:e})}function VoiceOverlay({conv,isGenerating,spokenRef,regen}){const{isEnabled:ttsOn,status:ttsStatus,enable:ttsEnable,speak:ttsSpeak,getAnalyser:getAn,voice:curVoice,setVoice:setVoiceName}=Ag(),{status:vadStatus,start:vadStart,stop:vadStop}=mk(),{setVoiceMode:svm}=Wt(),cv=T.useRef(null),trRef=T.useRef(null);T.useEffect(()=>{ttsEnable(),vadStart();return()=>{vadStop()}},[]),T.useEffect(()=>{const canvas=cv.current;if(!canvas)return;const ctx=canvas.getContext("2d"),fft=new Uint8Array(128);let raf=0;const draw=()=>{raf=requestAnimationFrame(draw);const an=getAn();if(an&&an.frequencyBinCount>0)an.getByteFrequencyData(fft);const w=canvas.width,h=canvas.height;ctx.clearRect(0,0,w,h);const n=48,bw=w/n;for(let i=0;i<n;i++){const v=(fft[Math.floor(i*128/n)]||0)/255,bh=Math.max(2,v*h*.9);ctx.fillStyle=`hsla(${200+i*2},90%,${60+v*25}%,.95)`;ctx.fillRect(i*bw,h-bh,bw-2,bh)}};draw();return()=>cancelAnimationFrame(raf)},[]);const msgs=conv&&conv.messages?conv.messages:[],lastIdx=msgs.length-1;T.useEffect(()=>{const el=trRef.current;if(!el)return;const to=setTimeout(()=>el.scrollTo({top:el.scrollHeight,behavior:"smooth"}),60);return()=>clearTimeout(to)},[msgs.length,msgs.length?msgs[msgs.length-1].content:""]);const dotCls=vadStatus==="speaking"?"vo-dot speaking":vadStatus==="listening"?"vo-dot listening":"vo-dot",statusTxt=vadStatus==="speaking"?"Listening…":vadStatus==="listening"?"Listening — speak now":"Idle";return v.jsxs("div",{className:"voice-overlay",children:[v.jsxs("div",{className:"vo-top",children:[v.jsx("span",{className:"vo-title",children:"voice mode"}),v.jsx("button",{className:"vo-exit",onClick:()=>svm(!1),children:"✕ Exit"})]}),v.jsx("canvas",{ref:cv,className:"vo-visualizer",width:900,height:200}),v.jsxs("div",{className:"vo-body",children:[v.jsxs("div",{className:"vo-status",children:[v.jsx("span",{className:dotCls}),v.jsx("span",{children:statusTxt}),ttsStatus==="loading"&&v.jsx("span",{children:" · TTS loading"})]}),v.jsx("div",{className:"vo-transcript",ref:trRef,children:msgs.map((m,ix)=>{if(m.role==="user")return v.jsx("div",{className:"vo-user",children:m.content},m.id);let txt=m.content;if(ix===lastIdx&&isGenerating&&spokenRef.current>0&&spokenRef.current<txt.length)txt=txt.slice(0,spokenRef.current);return v.jsx("div",{className:"vo-sentence",onClick:()=>regen(m.id),title:"Click to regenerate",children:txt.length>0?txt:isGenerating?"▍":"…"},m.id)})}),v.jsx("div",{className:"vo-hint",children:"Speak or type — click any sentence to regenerate"})]})]})};function F4(){const[e,t]=T.useState(""),[n,r]=T.useState(null),i=T.useRef(null),a=T.useRef(null),{currentConvId:o,isGenerating:s,createCompletion:l,navigateTo:u,loadedModel:f,isRemote:c,stopCompletion:p,currRuntimeInfo:d,voiceMode:vm}=Wt(),{getConversationById:h,addMessageToConversation:y,editMessageInConversation:E,newConversation:m,truncateConversation:trc}=Eg(),{isEnabled:g,status:w,error:P,enable:C,disable:x,speak:A,stop:M,voice:curVoice,setVoice:setVoiceName}=Ag(),{status:R,error:S,start:_,stop:L,onUtterance:W}=mk(),{status:G,progress:q,error:ae,warmup:ne,transcribe:O}=d0(),V=T.useRef(g),sRef=T.useRef(s);T.useEffect(()=>{V.current=g},[g]),T.useEffect(()=>{sRef.current=s},[s]);const b=T.useRef(0),genId=T.useRef(0),regen=async mid=>{if(sRef.current){p();for(let w=0;w<20&&sRef.current;w++)await new Promise(r=>setTimeout(r,50))}M();const KK=h(o);if(!KK)return;const mArr=KK.messages,ix=mArr.findIndex(m=>m.id===mid);if(ix<=0||mArr[ix].role==="user")return;trc(o,ix),b.current=0;const Re={id:Date.now()+1,content:"",role:"assistant"};y(o,Re);let Ze="";const id=++genId.current;await l(mArr.slice(0,ix),zn=>{if(id!==genId.current)return;Ze=zn,E(o,Re.id,zn);const{sentences:da,nextIndex:pa}=S0(zn,b.current);b.current=pa,V.current&&da.forEach(cs=>A(cs))});if(id!==genId.current)return;const Un=Ze.slice(b.current);V.current&&Un.trim().length>0&&A(Un)};NS(M4,500,s,!0);const K=h(o),ie=(d==null?void 0:d.supportsImage)||(d==null?void 0:d.supportsAudio),k=z=>Q=>{var Re;const se=(Re=Q.target.files)==null?void 0:Re[0];if(!se)return;const Pe=new FileReader;Pe.onload=Fe=>{r({type:z,data:Fe.target.result,dataUrl:URL.createObjectURL(se)})},Pe.readAsArrayBuffer(se),Q.target.value=""},he=async z=>{if(s||!z.trim())return;M();const Q=(K==null?void 0:K.messages)??[],se=n;b.current=0;const Pe={id:Date.now(),content:z,role:"user",mediaData:se??void 0},Re={id:Date.now()+1,content:"",role:"assistant"};let Fe=K==null?void 0:K.id;Fe?(y(Fe,Pe),y(Fe,Re)):(Fe=m(Pe).id,u(ve.CHAT,Fe),y(Fe,Re));let Ze="";const id=++genId.current;await l([...Q,Pe],zn=>{if(id!==genId.current)return;Ze=zn,E(Fe,Re.id,zn);const{sentences:da,nextIndex:pa}=S0(zn,b.current);b.current=pa,V.current&&da.forEach(cs=>A(cs))});if(id!==genId.current)return;const Un=Ze.slice(b.current);V.current&&Un.trim().length>0&&A(Un)},Ge=()=>{s||(t(""),r(null),he(e))},U=T.useRef(()=>{});return U.current=he,T.useEffect(()=>W(async(Q,se)=>{try{const Re=(await O(Q,se)||"").replace(/\[BLANK_AUDIO\]/gi,"").trim();Re&&U.current(Re)}catch(Pe){console.error("[asr] transcription failed:",Pe)}}),[W,O]),vm?v.jsx(VoiceOverlay,{conv:K,isGenerating:s,spokenRef:b,regen}):v.jsxs(rs,{fitScreen:!0,children:[v.jsxs("div",{className:"chat-messages grow overflow-auto",id:"chat-history",children:[v.jsx("div",{className:"h-10"}),K?v.jsx(v.Fragment,{children:K.messages.map(z=>{var Q,se;return z.role==="user"?v.jsx("div",{className:"chat chat-end",children:v.jsxs("div",{className:"chat-bubble",children:[((Q=z.mediaData)==null?void 0:Q.type)==="image"&&v.jsx("img",{src:z.mediaData.dataUrl,className:"max-w-48 rounded mb-1"}),((se=z.mediaData)==null?void 0:se.type)==="audio"&&v.jsx("audio",{controls:!0,src:z.mediaData.dataUrl,className:"mb-1"}),z.content.length>0&&v.jsx(lm,{content:z.content})]})},z.id):v.jsx("div",{className:"chat chat-start cursor-pointer",onClick:()=>regen(z.id),title:"Click to regenerate this reply",children:v.jsxs("div",{className:"chat-bubble bg-base-100 text-base-content",children:[z.content.length===0&&s&&v.jsx("span",{className:"loading loading-dots"}),z.content.length>0&&v.jsx(lm,{content:z.content})]})},z.id)})}):v.jsx("div",{className:"pt-24 text-center text-xl",children:"Ask me something 👋"})]}),v.jsxs("div",{className:"flex flex-col input-message py-4",children:[s&&v.jsx("div",{className:"text-center",children:v.jsxs("button",{className:"btn btn-outline btn-sm mb-4",onClick:p,children:[v.jsx(Be,{icon:CS}),"Stop generation"]})}),(f||c)&&v.jsxs(v.Fragment,{children:[n&&v.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.type==="image"?v.jsx("img",{src:n.dataUrl,className:"h-16 w-16 object-cover rounded"}):v.jsx("audio",{controls:!0,src:n.dataUrl}),v.jsx("button",{className:"btn btn-xs btn-circle btn-outline",onClick:()=>r(null),children:"✕"})]}),v.jsxs("div",{className:"flex gap-2",children:[ie&&v.jsxs(v.Fragment,{children:[v.jsx("input",{ref:i,type:"file",accept:"image/*",className:"hidden",onChange:k("image")}),v.jsx("input",{ref:a,type:"file",accept:"audio/*",className:"hidden",onChange:k("audio")}),v.jsxs("div",{className:"dropdown dropdown-top",children:[v.jsx("button",{tabIndex:0,className:"btn btn-sm btn-ghost h-full border border-base-content/20",disabled:s,children:"+"}),v.jsxs("ul",{className:"dropdown-content menu bg-base-100 rounded-box z-[1] w-36 p-2 shadow mb-1",children:[(d==null?void 0:d.supportsImage)&&v.jsx("li",{children:v.jsx("a",{onMouseDown:z=>{var Q;z.preventDefault(),(Q=i.current)==null||Q.click()},children:"Image"})}),(d==null?void 0:d.supportsAudio)&&v.jsx("li",{children:v.jsx("a",{onMouseDown:z=>{var Q;z.preventDefault(),(Q=a.current)==null||Q.click()},children:"Audio"})})]})]})]}),v.jsx("button",{className:`btn btn-sm btn-ghost h-full border border-base-content/20 ${R==="listening"?"text-success":R==="speaking"?"text-error":""}`,disabled:R==="loading",onClick:()=>{R==="idle"?(ne(),_()):L()},title:R==="idle"?"Start voice chat (Silero VAD)":"Stop voice chat",children:R==="loading"?v.jsx("span",{className:"loading loading-spinner loading-sm"}):v.jsx(Be,{icon:R==="speaking"?bS:kS})}),v.jsx("button",{className:`btn btn-sm btn-ghost h-full border border-base-content/20 ${g?"text-primary":""}`,disabled:w==="loading",onClick:()=>g?x():C(),title:g?"Stop reading answers aloud":"Read answers aloud with piper TTS",children:w==="loading"?v.jsx("span",{className:"loading loading-spinner loading-sm"}):v.jsx(Be,{icon:g?dp:ES})}),v.jsx("textarea",{className:"textarea textarea-bordered grow",placeholder:"Your message...",disabled:s,value:e,onChange:z=>t(z.target.value),onKeyDown:z=>{z.keyCode==13&&z.shiftKey==!1&&(z.preventDefault(),Ge())}})]}),P&&v.jsxs("small",{className:"text-error block mt-1",children:["TTS error: ",P]}),g&&w==="speaking"&&v.jsxs("small",{className:"opacity-70 block mt-1",children:[v.jsx(Be,{icon:dp})," Reading aloud…"," ",v.jsx("button",{className:"link",onClick:M,children:"Stop"})]}),S&&v.jsxs("small",{className:"text-error block mt-1",children:["Voice error: ",S]}),R==="listening"&&v.jsxs("small",{className:"opacity-70 block mt-1",children:[v.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-success mr-1"}),"Listening — speak to interrupt the assistant"]}),R==="speaking"&&v.jsxs("small",{className:"opacity-70 block mt-1",children:[v.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-error animate-pulse mr-1"}),"Speaking…"]}),ae&&v.jsxs("small",{className:"text-error block mt-1",children:["Speech-to-text error: ",ae]}),G==="loading"&&v.jsxs("small",{className:"opacity-70 block mt-1",children:[v.jsx("span",{className:"loading loading-spinner loading-xs mr-1"}),"Loading speech-to-text model…",q!=null&&` ${Math.round(q*100)}%`]}),G==="transcribing"&&v.jsxs("small",{className:"opacity-70 block mt-1",children:[v.jsx("span",{className:"loading loading-spinner loading-xs mr-1"}),"Transcribing…"]})]}),!f&&!c&&v.jsx(T4,{}),v.jsx("small",{className:"text-center mx-auto opacity-70 pt-2",children:"wllama may generate inaccurate information. Use with your own risk."})]})]})}function T4(){const{navigateTo:e}=Wt();return v.jsxs("div",{role:"alert",className:"alert",children:[v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 shrink-0 stroke-current",fill:"none",viewBox:"0 0 24 24",children:v.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),v.jsx("span",{children:"Model is not loaded"}),v.jsx("div",{children:v.jsx("button",{className:"btn btn-sm btn-primary",onClick:()=>e(ve.MODEL),children:"Select model"})})]})}const M4=()=>{const e=document.getElementById("chat-history");e==null||e.scrollTo({top:e.scrollHeight,behavior:"smooth"})};function _4(){const{navigateTo:e}=Wt();return v.jsx(rs,{children:v.jsxs("div",{className:"guide-text pt-16",children:[v.jsx("h1",{className:"text-2xl font-bold mb-4",children:"Wllama 🦙"}),v.jsxs("div",{className:"mb-3",children:["Wllama is a project based on"," ",v.jsx("a",{href:"https://github.com/ggerganov/llama.cpp",target:"_blank",rel:"noopener",children:"llama.cpp"}),". It enables running LLM inference directly on browser by leveraging the power of ",v.jsx("b",{children:"WebAssembly"}),". It accepts GGUF as model format."]}),v.jsxs("div",{className:"mb-3",children:["Please note that:",v.jsxs("ul",{children:[v.jsx("li",{children:"Due to WebAssembly overhead, performance will not be as good as running llama.cpp in native. Performance degradation can range from 25% to 50%."}),v.jsxs("li",{children:["Due to memory constraint of WebAssembly and emscripten, models larger than 2GB will need to be split."," ",v.jsx("a",{href:"https://github.com/ngxson/wllama?tab=readme-ov-file#split-model",target:"_blank",rel:"noopener",children:"Click here to learn more"})]}),v.jsx("li",{children:"Large model may not fit into RAM, (again) due to memory constraint of WebAssembly."}),v.jsx("li",{children:"Running on smartphone maybe buggy."}),v.jsxs("li",{children:[v.jsx("b",{children:"Safari is not supported"}),", due to lack of Memory64 support."]})]})]}),v.jsxs("div",{className:"mb-3",children:["To get started, go to"," ",v.jsx("button",{className:"btn btn-sm btn-primary btn-outline",onClick:()=>e(ve.MODEL),children:"Manage models"})," ","page to select a model."]}),v.jsx("h1",{className:"text-xl font-bold mb-4 mt-6",children:"Reporting bugs"}),v.jsxs("div",{className:"mb-3",children:["Wllama is in development and many bugs are expected to happen. If you find a bug, please"," ",v.jsx("a",{href:"https://github.com/ngxson/wllama/issues",target:"_blank",rel:"noopener",children:"open a issue"})," ","with log copied from"," ",v.jsx("button",{className:"btn btn-sm btn-primary btn-outline",onClick:()=>e(ve.LOG),children:"Debug log"})]})]})})}function I4(e){return e.split(`
|
| 1310 |
`).map((t,n)=>v.jsxs(Oo.Fragment,{children:[t,v.jsx("br",{})]},n))}function N4(){return v.jsx(rs,{children:v.jsxs("div",{className:"debug-log-screen pt-8",children:[v.jsx("h1",{className:"text-2xl mb-4",children:"Debug log"}),v.jsxs("div",{className:"font-mono bg-base-200 p-2 rounded-lg text-sm mb-16",children:[At.content.length===0&&v.jsx("span",{children:"(Log is empty. Please firstly load a model)"}),At.content.map((e,t)=>v.jsxs(Oo.Fragment,{children:[I4(e),v.jsx("br",{})]},t))]})]})})}function R4(){const[e,t]=T.useState(!1),[n,r]=T.useState(zg()),[inst,setInst]=T.useState(!1),[asrDone,setAsrDone]=T.useState(()=>localStorage.getItem("asrInstalled")==="1"),{models:i,removeCachedModel:a,isLoadingModel:o,isDownloading:s,loadedModel:l,currParams:u,setParams:f}=Wt(),{status:asrStatus,progress:asrProgress,error:asrError,warmup:asrWarmup}=d0(),{voice:curVoice,setVoice:setVoiceName}=Ag(),c=!!(l||s||o),p=d=>h=>{f({...u,[d]:parseFloat(h.target.value||-1)})};return v.jsxs(rs,{children:[v.jsxs("div",{className:"inference-params pt-8",children:[v.jsx("h1",{className:"text-2xl mb-4",children:"Inference parameters"}),v.jsxs("label",{className:"input input-bordered flex items-center gap-2 mb-2",children:["# threads",v.jsx("input",{type:"number",className:"grow",placeholder:"(auto detected)",min:"1",max:"100",step:"1",onChange:p("nThreads"),value:u.nThreads<1?"":u.nThreads,disabled:c})]}),v.jsxs("label",{className:"input input-bordered flex items-center gap-2 mb-2",children:["Context size",v.jsx("input",{type:"number",className:"grow",min:"128",step:"1",onChange:p("nContext"),value:u.nContext,disabled:c})]}),v.jsxs("label",{className:"input input-bordered flex items-center gap-2 mb-2",children:["Max generated tokens",v.jsx("input",{type:"number",className:"grow",min:"10",step:"1",onChange:p("nPredict"),value:u.nPredict})]}),v.jsxs("label",{className:"input input-bordered flex items-center gap-2 mb-2",children:["Temperature",v.jsx("input",{type:"number",className:"grow",min:"0.0",step:"0.05",onChange:p("temperature"),value:u.temperature})]}),v.jsxs("label",{className:"label cursor-pointer justify-start gap-2 mb-2",children:[v.jsx("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:n,onChange:d=>{$b(d.target.checked),r(d.target.checked)}}),v.jsx("span",{className:"label-text",children:"Disable hardware acceleration (force CPU/WASM; threads stay normal)"})]}),v.jsx("button",{className:"btn btn-sm mr-2",onClick:()=>f(Ug),children:"Reset params"}),v.jsx("button",{className:"btn btn-sm mr-2",onClick:async()=>{if(confirm("This will remove all downloaded model files from cache. Continue?"))for(const d of i)await a(d)},disabled:c,children:"Clear cache"})]}),v.jsxs("div",{className:"model-management",children:[v.jsx("h1",{className:"text-2xl mt-6 mb-4",children:"Voice modules"}),v.jsxs("div",{className:"card bg-base-100 w-full mb-2 p-4 flex flex-row items-center gap-3",children:[v.jsx("div",{className:"grow",children:[v.jsx("b",{children:"Voice activity detection (VAD)"}),v.jsx("br",{}),v.jsx("small",{children:"Silero VAD — bundled locally, works offline."})]}),v.jsx("span",{className:"badge badge-success",children:"Installed"})]}),v.jsxs("div",{className:"card bg-base-100 w-full mb-2 p-4",children:[v.jsxs("div",{className:"flex flex-row items-center gap-3 mb-2",children:[v.jsx("div",{className:"grow",children:[v.jsx("b",{children:"Text-to-speech (Piper)"}),v.jsx("br",{}),v.jsx("small",{children:"Bundled voice works offline; other voices stream from HuggingFace (internet required)."})]}),v.jsx("span",{className:"badge badge-success",children:"Installed"})]}),v.jsx("select",{className:"select select-bordered w-full",value:curVoice,onChange:ev=>setVoiceName(ev.target.value),title:"TTS voice",children:VoiceList.map(vz=>v.jsx("option",{value:vz[0],children:vz[1]},vz[0]))})]}),v.jsxs("div",{className:"card bg-base-100 w-full mb-2 p-4 flex flex-row items-center gap-3",children:[v.jsx("div",{className:"grow",children:[v.jsx("b",{children:"Speech-to-text (Whisper)"}),v.jsx("br",{}),v.jsx("small",{children:asrStatus==="ready"?"Whisper model cached — speech-to-text works offline.":"Download the whisper model once so speech-to-text works offline."})]}),asrStatus==="ready"||asrDone?v.jsx("span",{className:"badge badge-success",children:"Installed"}):v.jsx("button",{className:"btn btn-sm btn-primary",disabled:asrStatus==="loading"||asrStatus==="transcribing"||inst,onClick:()=>{setInst(!0),Promise.resolve(asrWarmup()).then(()=>{localStorage.setItem("asrInstalled","1"),setAsrDone(!0)}).catch(()=>{}).finally(()=>setInst(!1))},children:asrStatus==="loading"||inst?v.jsx("span",{className:"loading loading-spinner loading-sm"}):"Install"})]}),asrStatus==="loading"&&asrProgress!=null&&v.jsx("progress",{className:"progress progress-primary w-full",value:Math.round(asrProgress*100),max:"100"}),asrError&&v.jsxs("small",{className:"text-error block mt-1",children:["Speech-to-text error: ",asrError]})]}),v.jsxs("div",{className:"model-management",children:[v.jsxs("h1",{className:"text-2xl mt-6 mb-4",children:["Custom models",v.jsx("button",{className:"btn btn-primary btn-outline btn-sm ml-6",onClick:()=>t(!0),children:"+ Add GGUF"})]}),i.filter(d=>d.isUserAdded).map(d=>v.jsx(um,{model:d,blockModelBtn:c},d.url))]}),v.jsxs("div",{className:"model-management",children:[v.jsx("h1",{className:"text-2xl mt-6 mb-4",children:"Recommended models"}),i.filter(d=>!d.isUserAdded).map(d=>v.jsx(um,{model:d,blockModelBtn:c},d.url))]}),v.jsx("div",{className:"h-10"}),e&&v.jsx(L4,{onClose:()=>t(!1)})]})}function L4({onClose:e}){const{isLoadingModel:t,addCustomModel:n}=Wt(),[r,i]=T.useState(""),[a,o]=T.useState(""),[s,l]=T.useState(""),[u,f]=T.useState([]),[c,p]=T.useState([]),[d,h]=T.useState(new AbortController),[y,E]=T.useState();g0(async()=>{if(r.length<2){f([]),p([]);return}try{const P=await(await fetch(`https://huggingface.co/api/models/${r}`,{signal:d.signal})).json();if(P.siblings){const C=P.siblings.map(x=>x.rfilename).filter(x=>Ig(x));f(C.filter(x=>!x.toLowerCase().includes("mmproj"))),p(C.filter(x=>x.toLowerCase().includes("mmproj"))),E("")}else E("no model found or it is private"),f([]),p([])}catch(w){w.name!=="AbortError"&&(E((w==null?void 0:w.message)??"unknown error"),f([]),p([]))}},[r],500),T.useEffect(()=>{u.length===0&&o("")},[u]),T.useEffect(()=>{c.length===0&&l("")},[c]);const m=`https://huggingface.co/${r}/resolve/main`,g=async()=>{try{await n(`${m}/${a}`,s?`${m}/${s}`:void 0),e()}catch(w){E((w==null?void 0:w.message)??"unknown error")}};return v.jsx("dialog",{className:"modal modal-open",children:v.jsxs("div",{className:"modal-box",children:[v.jsx("h3",{className:"font-bold text-lg",children:"Add custom GGUF"}),v.jsxs("div",{className:"mt-4",children:["Max GGUF file size is 2GB. If your model is bigger than 2GB, please"," ",v.jsx("a",{href:"https://github.com/ngxson/wllama?tab=readme-ov-file#split-model",target:"_blank",rel:"noopener",className:"text-primary",children:"follow this guide"})," ","to split it into smaller shards."]}),v.jsxs("div",{className:"mt-4",children:[v.jsxs("label",{className:"input input-bordered flex items-center gap-2 mb-2",children:["HF repo",v.jsx("input",{type:"text",className:"grow",placeholder:"{username}/{repo}",value:r,onChange:w=>{d.abort(),i(w.target.value),h(new AbortController)}})]}),v.jsxs("select",{className:"select select-bordered w-full mb-2",value:a,onChange:w=>o(w.target.value),children:[v.jsx("option",{value:"",children:"Select a model file"}),u.map(w=>v.jsx("option",{value:w,children:w},w))]}),c.length>0&&v.jsxs("select",{className:"select select-bordered w-full",value:s,onChange:w=>l(w.target.value),children:[v.jsx("option",{value:"",children:"Select mmproj file (optional)"}),c.map(w=>v.jsx("option",{value:w,children:w},w))]})]}),y&&v.jsxs("div",{className:"mt-4 text-error",children:["Error: ",y]}),v.jsxs("div",{className:"modal-action",children:[v.jsxs("button",{className:"btn btn-primary",disabled:t||r.length<2||a.length<5,onClick:g,children:[t&&v.jsx("span",{className:"loading loading-spinner"}),"Add model"]}),v.jsx("button",{className:"btn",disabled:t,onClick:e,children:"Close"})]})]})})}function um({model:e,blockModelBtn:t}){const{downloadModel:n,removeCachedModel:r,loadModel:i,unloadModel:a,removeCustomModel:o,currRuntimeInfo:s,navigateTo:l}=Wt(),u=e,f=parseInt(Math.round(u.downloadPercent*100).toString());return v.jsx("div",{className:`card bg-base-100 w-full mb-2 ${u.state===Te.LOADED?"border-2 border-primary":""}`,children:v.jsxs("div",{className:"card-body p-4 flex flex-row",children:[v.jsxs("div",{className:"grow",children:[v.jsx("b",{children:u.hfPath.replace(/-\d{5}-of-\d{5}/,"-(shards)")}),v.jsx("br",{}),v.jsxs("small",{children:["HF repo: ",u.hfModel,v.jsx("br",{}),"Size: ",h0(u.size),u.size>jb&&v.jsx("div",{className:"tooltip tooltip-right","data-tip":"Big model size, may not be able to load due to RAM limitation",children:v.jsx("span",{className:"text-yellow-300 ml-2",children:v.jsx(Be,{icon:MS})})}),u.state==Te.DOWNLOADING?` - Downloaded: ${f}%`:"",u.modalities&&u.modalities.length>0&&v.jsxs(v.Fragment,{children:[" ",u.modalities.map(c=>v.jsx("span",{className:"badge badge-sm badge-accent ml-1",children:c},c))]})]}),u.state===Te.LOADED&&s&&v.jsxs(v.Fragment,{children:[v.jsx("br",{}),v.jsx(cm,{text:"Multithread",on:s.isMultithread})," ",v.jsx(cm,{text:"Chat template",on:s.hasChatTemplate})]}),u.state===Te.DOWNLOADING&&v.jsx("div",{children:v.jsx("progress",{className:"progress progress-primary w-full",value:f,max:"100"})}),u.state===Te.LOADING&&v.jsx("div",{children:v.jsx("progress",{className:"progress progress-primary w-full"})})]}),v.jsxs("div",{children:[u.state===Te.NOT_DOWNLOADED&&v.jsx("button",{className:"btn btn-primary btn-sm mr-2",onClick:()=>n(u),disabled:t,children:"Download"}),u.state===Te.READY&&v.jsxs(v.Fragment,{children:[v.jsx("button",{className:"btn btn-primary btn-sm mr-2",onClick:()=>i(u),disabled:t,children:"Load model"}),v.jsx("button",{className:"btn btn-outline btn-error btn-sm mr-2",onClick:()=>{confirm("Are you sure to remove this model from cache?")&&r(u)},disabled:t,children:v.jsx(Be,{icon:Cw})})]}),u.state===Te.LOADED&&v.jsxs(v.Fragment,{children:[v.jsx("button",{className:"btn btn-primary btn-sm mr-2",onClick:()=>l(ve.CHAT),children:"Start chat"}),v.jsx("button",{className:"btn btn-outline btn-primary btn-sm mr-2",onClick:()=>a(),children:"Unload"})]}),u.state===Te.NOT_DOWNLOADED&&u.isUserAdded&&v.jsx("button",{className:"btn btn-outline btn-error btn-sm mr-2",onClick:()=>{confirm("Are you sure to remove this model from the list?")&&o(u)},disabled:t,children:v.jsx(Be,{icon:Aw})}),u.state==Te.DOWNLOADING&&v.jsx("span",{className:"loading loading-spinner"})]})]})},u.url)}function cm({text:e,on:t}){return v.jsxs(v.Fragment,{children:[t?v.jsx("span",{className:"text-green-300",children:v.jsx(Be,{icon:FS})}):v.jsx("span",{className:"text-red-400",children:v.jsx(Be,{icon:Aw})}),v.jsxs("span",{className:"text-sm",children:[" ",e]})]})}function O4(){const{remoteConfig:e,isRemote:t,remoteError:n,setRemoteConfig:r,clearRemoteConfig:i,voiceMode:vm,setVoiceMode:svm,navigateTo:nav}=Wt(),[a,o]=T.useState((e==null?void 0:e.baseUrl)??""),s=()=>{const l=a.trim();l?r({baseUrl:l,apiKey:(e==null?void 0:e.apiKey)??"",model:(e==null?void 0:e.model)??""}):i()};return v.jsxs("div",{className:"navbar bg-base-100 shadow-md z-40",children:[v.jsx("div",{className:"flex-none",children:v.jsx("label",{htmlFor:"my-drawer-2",className:"btn btn-square btn-ghost flex lg:hidden",children:v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",className:"inline-block h-5 w-5 stroke-current",children:v.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M4 6h16M4 12h16M4 18h16"})})})}),v.jsx("a",{className:"btn btn-ghost text-xl",children:"wllama"}),v.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[v.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${t?"bg-success":"bg-base-300"}`,title:t?"Using remote LLM API":"Using local model"}),v.jsx("input",{className:"input input-sm input-bordered w-40 sm:w-64",placeholder:"API URL e.g. http://localhost:8080/v1",value:a,onChange:l=>o(l.target.value),onBlur:s,onKeyDown:l=>{l.key==="Enter"&&(s(),l.target.blur())}}),n&&v.jsx("span",{className:"text-error text-xs max-w-[16rem] truncate",title:n,children:n})]}),v.jsx("div",{className:"flex-1"}),v.jsx("button",{className:`btn btn-sm ${vm?"btn-primary":"btn-outline"}`,onClick:()=>{svm(!vm),vm||nav(ve.CHAT)},title:vm?"Exit voice-to-voice mode":"Enter voice-to-voice mode",children:vm?"✕ Voice":"🎙 Voice"})]})}function D4({children:e}){const{currentConvId:t,navigateTo:n,currScreen:r,loadedModel:i}=Wt(),{conversations:a,getConversationById:o,deleteConversation:s}=Eg(),l=o(t);return v.jsxs(v.Fragment,{children:[v.jsx("input",{id:"my-drawer-2",type:"checkbox",className:"drawer-toggle"}),v.jsxs("div",{className:"drawer-side h-screen lg:h-[calc(100vh-4rem)] z-50",children:[v.jsx("label",{htmlFor:"my-drawer-2","aria-label":"close sidebar",className:"drawer-overlay block lg:hidden"}),v.jsxs("div",{className:"h-screen lg:max-h-[calc(100vh-4rem)] flex flex-col text-base-content bg-base-200",children:[v.jsx("div",{className:"grow w-80 overflow-auto p-4",children:v.jsxs("ul",{className:"menu gap-1 overflow-x-hidden",children:[v.jsx("li",{onClick:()=>n(ve.CHAT),children:v.jsx("a",{className:!l&&r===ve.CHAT?"active":"",children:"+ New conversation"})}),a.map(u=>{var f;return v.jsxs("li",{onClick:()=>n(ve.CHAT,u.id),className:"group flex flex-row",children:[v.jsx("a",{className:`${u.id===t?"active":""} flex-1 min-w-0`,children:v.jsx("div",{className:"truncate",children:(f=u.messages[0])==null?void 0:f.content})}),v.jsx("span",{className:"text-right hidden group-hover:inline",children:v.jsx(Be,{icon:Cw,onClick:c=>{c.preventDefault(),confirm("Are you sure to delete this conversation?")&&(n(ve.CHAT),s(u.id))}})})]},u.id)})]})}),v.jsxs("div",{className:"w-80 px-4 pt-0 pb-8",children:[v.jsx("div",{className:"divider my-2"}),i&&v.jsxs("div",{className:"text-sm px-4 pb-2",children:["Model: ",i.hfModel]}),v.jsxs("ul",{className:"menu gap-1",children:[v.jsx("li",{onClick:()=>n(ve.GUIDE),children:v.jsxs("a",{className:r===ve.GUIDE?"active":"",children:[v.jsx(Be,{icon:PS})," Guide"]})}),v.jsx("li",{onClick:()=>n(ve.MODEL),children:v.jsxs("a",{className:r===ve.MODEL?"active":"",children:[v.jsx(Be,{icon:_S})," Manage models"]})}),v.jsx("li",{onClick:()=>n(ve.LOG),children:v.jsxs("a",{className:r===ve.LOG?"active":"",children:[v.jsx(Be,{icon:AS})," Debug log"]})}),v.jsx("li",{children:v.jsxs("a",{href:"https://github.com/ngxson/wllama",target:"_blank",rel:"noopener",children:[v.jsx(Be,{icon:xS})," Github"]})})]}),v.jsxs("div",{className:"text-xs pl-6 pt-2",children:["Version ",Db]})]})]})]}),v.jsx("div",{className:"drawer-content grow",children:e})]})}async function U4(){throw new Error("Benchmark is not ready yet, stay tuned!")}async function z4(){throw new Error("Perplexity test is not ready yet, stay tuned!")}window.__benchmark=U4;window.__perplexity=z4;function j4(){return v.jsx(w0,{children:v.jsx(tk,{children:v.jsx(T0,{children:v.jsx(f0,{children:v.jsx(pk,{children:v.jsx(B4,{})})})})})})}function B4(){const{currScreen:e}=Wt();return v.jsxs("div",{className:"flex flex-col drawer h-screen w-screen overflow-hidden",children:[v.jsx(O4,{}),v.jsx("div",{className:"grow flex flex-row lg:drawer-open h-[calc(100vh-4rem)]",children:v.jsxs(D4,{children:[e===ve.MODEL&&v.jsx(R4,{}),e===ve.CHAT&&v.jsx(F4,{}),e===ve.GUIDE&&v.jsx(_4,{}),e===ve.LOG&&v.jsx(N4,{})]})})]})}ml.createRoot(document.getElementById("root")).render(v.jsx(j4,{}));
|