2shay commited on
Commit
2d4c8ac
·
verified ·
1 Parent(s): e04d18b

deploy e8e1e40

Browse files
assets/{index-Cf81bvtQ.js → index-HoiRag-_.js} RENAMED
@@ -1,3 +1,3 @@
1
- import{l as e}from"./loader-D0INP31U.js";import{i as t,r as n,t as r}from"./pins-DVBrHC3g.js";import{a as i,i as a,n as o,r as s,t as c}from"./llm-DH311QE0.js";import{a as l,i as u}from"./tts-Cm1VA0A9.js";var d,f,p,m,h,g,_,v,y,b,x,S,C,w,T={},E=[],D=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,O=Array.isArray;function k(e,t){for(var n in t)e[n]=t[n];return e}function ee(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function A(e,t,n){var r,i,a,o={};for(a in t)a==`key`?r=t[a]:a==`ref`?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?d.call(arguments,2):n),typeof e==`function`&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return j(e,o,r,i,null)}function j(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++p,__i:-1,__u:0};return i==null&&f.vnode!=null&&f.vnode(a),a}function M(e){return e.children}function N(e,t){this.props=e,this.context=t}function P(e,t){if(t==null)return e.__?P(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?P(e):null}function te(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=k({},t);a.__v=t.__v+1,f.vnode&&f.vnode(a),ue(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??P(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,fe(r,a,i),t.__e=t.__=null,a.__e!=n&&ne(a)}}function ne(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),ne(e)}function re(e){(!e.__d&&(e.__d=!0)&&m.push(e)&&!F.__r++||h!=f.debounceRendering)&&((h=f.debounceRendering)||g)(F)}function F(){try{for(var e,t=1;m.length;)m.length>t&&m.sort(_),e=m.shift(),t=m.length,te(e)}finally{m.length=F.__r=0}}function ie(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r&&r.__k||E,v=t.length;for(c=ae(n,t,_,c,v),d=0;d<v;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&_[p.__i]||T,p.__i=d,g=ue(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&he(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h==null&&m!=null&&(h=m),4&p.__u?(c=oe(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function ae(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=j(null,o,null,null,null):O(o)?o=e.__k[a]=j(M,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=j(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=se(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=P(s)),ge(s,s));return r}function oe(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=oe(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=P(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function se(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function ce(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||D.test(t)?n:n+`px`}function I(e,t,n,r,i){var a,o;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||ce(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ce(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(x,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[b]=r[b]:(n[b]=S,e.addEventListener(t,a?w:C,a)):e.removeEventListener(t,a?w:C,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function le(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[y]==null)t[y]=S++;else if(t[y]<n[b])return;return n(f.event?f.event(t):t)}}}function ue(e,t,n,r,i,a,o,s,c,l){var u,d,p,m,h,g,_,v,y,b,x,S,C,w,T,D,A=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),a=[s=t.__e=n.__e]),(u=f.__b)&&u(t);n:if(typeof A==`function`){d=o.length;try{if(y=t.props,b=A.prototype&&A.prototype.render,x=(u=A.contextType)&&r[u.__c],S=u?x?x.props.value:u.__:r,n.__c?v=(p=t.__c=n.__c).__=p.__E:(b?t.__c=p=new A(y,S):(t.__c=p=new N(y,S),p.constructor=A,p.render=_e),x&&x.sub(p),p.state||(p.state={}),p.__n=r,m=p.__d=!0,p.__h=[],p._sb=[]),b&&p.__s==null&&(p.__s=p.state),b&&A.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=k({},p.__s)),k(p.__s,A.getDerivedStateFromProps(y,p.__s))),h=p.props,g=p.state,p.__v=t,m)b&&A.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),b&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(b&&A.getDerivedStateFromProps==null&&y!==h&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(y,S),t.__v==n.__v||!p.__e&&p.shouldComponentUpdate!=null&&!1===p.shouldComponentUpdate(y,p.__s,S)){t.__v!=n.__v&&(p.props=y,p.state=p.__s,p.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),E.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&o.push(p),s=P(n);break n}p.componentWillUpdate!=null&&p.componentWillUpdate(y,p.__s,S),b&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(h,g,_)})}if(p.context=S,p.props=y,p.__P=e,p.__e=!1,C=f.__r,w=0,b)p.state=p.__s,p.__d=!1,C&&C(t),u=p.render(p.props,p.state,p.context),E.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,C&&C(t),u=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++w<25);p.state=p.__s,p.getChildContext!=null&&(r=k(k({},r),p.getChildContext())),b&&!m&&p.getSnapshotBeforeUpdate!=null&&(_=p.getSnapshotBeforeUpdate(h,g)),T=u!=null&&u.type===M&&u.key==null?pe(u.props.children):u,s=ie(e,O(T)?T:[T],t,n,r,i,a,o,s,c,l),p.base=t.__e,t.__u&=-161,p.__h.length&&o.push(p),v&&(p.__E=p.__=null)}catch(e){if(o.length=d,t.__v=null,c||a!=null){if(e.then){for(t.__u|=c?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a!=null&&(a[a.indexOf(s)]=null),t.__e=s}else if(a!=null)for(D=a.length;D--;)ee(a[D])}else t.__e=n.__e;t.__k??=n.__k||[],e.then||de(t),f.__e(e,t,n)}}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=me(n.__e,t,n,r,i,a,o,c,l);return(u=f.diffed)&&u(t),128&t.__u?void 0:s}function de(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(de))}function fe(e,t,n){for(var r=0;r<n.length;r++)he(n[r],n[++r],n[++r]);f.__c&&f.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){f.__e(e,t.__v)}})}function pe(e){return typeof e!=`object`||!e||e.__b>0?e:O(e)?e.map(pe):e.constructor===void 0?k({},e):null}function me(e,t,n,r,i,a,o,s,c){var l,u,p,m,h,g,_,v=n.props||T,y=t.props,b=t.type;if(b==`svg`?i=`http://www.w3.org/2000/svg`:b==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(l=0;l<a.length;l++)if((h=a[l])&&`setAttribute`in h==!!b&&(b?h.localName==b:h.nodeType==3)){e=h,a[l]=null;break}}if(e==null){if(b==null)return document.createTextNode(y);e=document.createElementNS(i,b,y.is&&y),s&&=(f.__m&&f.__m(t,a),!1),a=null}if(b==null)v===y||s&&e.data==y||(e.data=y);else{if(a=b==`textarea`&&y.defaultValue!=null?null:a&&d.call(e.childNodes),!s&&a!=null)for(v={},l=0;l<e.attributes.length;l++)v[(h=e.attributes[l]).name]=h.value;for(l in v)h=v[l],l==`dangerouslySetInnerHTML`?p=h:l==`children`||l in y||l==`value`&&`defaultValue`in y||l==`checked`&&`defaultChecked`in y||I(e,l,null,h,i);for(l in y)h=y[l],l==`children`?m=h:l==`dangerouslySetInnerHTML`?u=h:l==`value`?g=h:l==`checked`?_=h:s&&typeof h!=`function`||v[l]===h||I(e,l,h,v[l],i);if(u)s||p&&(u.__html==p.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(p&&(e.innerHTML=``),ie(t.type==`template`?e.content:e,O(m)?m:[m],t,n,r,b==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,o,a?a[0]:n.__k&&P(n,0),s,c),a!=null)for(l=a.length;l--;)ee(a[l]);s&&b!=`textarea`||(l=`value`,b==`progress`&&g==null?e.removeAttribute(`value`):g!=null&&(g!==e[l]||b==`progress`&&!g||b==`option`&&g!=v[l])&&I(e,l,g,v[l],i),l=`checked`,_!=null&&_!=e[l]&&I(e,l,_,v[l],i))}return e}function he(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){f.__e(e,n)}}function ge(e,t,n){var r,i;if(f.unmount&&f.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||he(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){f.__e(e,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&ge(r[i],t,n||typeof e.type!=`function`);n||ee(e.__e),e.__c=e.__=e.__e=void 0}function _e(e,t,n){return this.constructor(e,n)}function ve(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),f.__&&f.__(e,t),i=(r=typeof n==`function`)?null:n&&n.__k||t.__k,a=[],o=[],ue(t,e=(!r&&n||t).__k=A(M,null,[e]),i||T,T,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?d.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),fe(a,e,o),e.props.children=null}d=E.slice,f={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},p=0,N.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=k({},this.state);typeof e==`function`&&(e=e(k({},n),this.props)),e&&k(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),re(this))},N.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),re(this))},N.prototype.render=M,m=[],g=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,_=function(e,t){return e.__v.__b-t.__v.__b},F.__r=0,v=Math.random().toString(8),y=`__d`+v,b=`__a`+v,x=/(PointerCapture)$|Capture$/i,S=0,C=le(!1),w=le(!0);var L,R,ye,be,z=0,xe=[],B=f,Se=B.__b,Ce=B.__r,we=B.diffed,Te=B.__c,Ee=B.unmount,De=B.__;function Oe(e,t){B.__h&&B.__h(R,e,z||t),z=0;var n=R.__H||(R.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function V(e){return z=1,ke(Le,e)}function ke(e,t,n){var r=Oe(L++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Le(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=R,!R.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};R.__f=!0;var a=R.shouldComponentUpdate,o=R.componentWillUpdate;R.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},R.shouldComponentUpdate=i}return r.__N||r.__}function H(e,t){var n=Oe(L++,3);!B.__s&&Ie(n.__H,t)&&(n.__=e,n.u=t,R.__H.__h.push(n))}function Ae(e){return z=5,je(function(){return{current:e}},[])}function je(e,t){var n=Oe(L++,7);return Ie(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Me(){for(var e;e=xe.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(U),t.__h.some(Fe),t.__h=[]}catch(n){t.__h=[],B.__e(n,e.__v)}}}B.__b=function(e){R=null,Se&&Se(e)},B.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),De&&De(e,t)},B.__r=function(e){Ce&&Ce(e),L=0;var t=(R=e.__c).__H;t&&(ye===R?(t.__h=[],R.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(U),t.__h.some(Fe),t.__h=[],L=0)),ye=R},B.diffed=function(e){we&&we(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(xe.push(t)!==1&&be===B.requestAnimationFrame||((be=B.requestAnimationFrame)||Pe)(Me)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),ye=R=null},B.__c=function(e,t){t.some(function(e){try{e.__h.some(U),e.__h=e.__h.filter(function(e){return!e.__||Fe(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],B.__e(n,e.__v)}}),Te&&Te(e,t)},B.unmount=function(e){Ee&&Ee(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{U(e)}catch(e){t=e}}),n.__H=void 0,t&&B.__e(t,n.__v))};var Ne=typeof requestAnimationFrame==`function`;function Pe(e){var t,n=function(){clearTimeout(r),Ne&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Ne&&(t=requestAnimationFrame(n))}function U(e){var t=R,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),R=t}function Fe(e){var t=R;e.__c=e.__(),R=t}function Ie(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Le(e,t){return typeof t==`function`?t(e):t}var W=i.default??`short`,Re=new Set;function ze(){return W}function Be(e){if(e!==W){W=e;for(let e of Re)e(W)}}function Ve(e){return Re.add(e),()=>Re.delete(e)}var He=96,Ue=36,G=8;function We(){let e=typeof window<`u`?window.getSelection():null;return!e||e.isCollapsed||e.rangeCount===0?``:e.toString().trim()}function Ge(){return We().length>0}function Ke(e){return e.trim().length>=20}function qe(){let e=typeof window<`u`?window.getSelection():null;if(!e||e.rangeCount===0)return null;let t=e.getRangeAt(0).getBoundingClientRect();return t.width===0&&t.height===0?null:t}function Je(e,t,n){let r=e.bottom+G;return r+Ue>n&&(r=e.top-Ue-G),r=Math.max(G,Math.min(r,n-Ue-G)),{left:Math.max(G,Math.min(e.left,t-He-G)),top:r}}function Ye(e){return e.altKey&&e.code===`KeyR`}function Xe(e){let t=e.trim();t&&window.__fruitbat.run(t,ze())}var Ze=0;Array.isArray;function K(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ze,__i:-1,__u:0,__source:i,__self:a};if(typeof e==`function`&&(o=e.defaultProps))for(s in o)c[s]===void 0&&(c[s]=o[s]);return f.vnode&&f.vnode(l),l}function Qe(e){let t=e.trim();return t===``?0:t.split(/\s+/).length}function $e(){let[e,t]=V(``),n=Qe(e),r=e.trim()===``;function i(){r||Xe(e)}return K(`div`,{class:`paste-box`,children:[K(`label`,{class:`paste-label`,for:`paste-input`,children:l(`intake.paste_placeholder`)}),K(`textarea`,{id:`paste-input`,class:`paste-textarea`,placeholder:l(`intake.paste_placeholder`),value:e,onInput:e=>t(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),i())}}),K(`div`,{class:`paste-row`,children:[K(`p`,{class:`word-count`,"aria-live":`polite`,"data-word-count":n,children:l(`intake.word_count`).replace(`{n}`,String(n))}),K(`button`,{type:`button`,class:`read-button`,onClick:i,disabled:r,children:l(`intake.read_button`)})]})]})}function et(){let[e,t]=V(null);return H(()=>{function e(){let e=We();if(!Ke(e)){t(null);return}let n=qe();if(!n){t(null);return}t({text:e,position:Je(n,window.innerWidth,window.innerHeight)})}function n(t){t.key!==`Escape`&&e()}function r(e){if(e.key===`Escape`){t(null);return}Ye(e)&&Ge()&&(e.preventDefault(),Xe(We()),t(null))}return document.addEventListener(`mouseup`,e),document.addEventListener(`keyup`,n),document.addEventListener(`keydown`,r),window.addEventListener(`scroll`,e,{passive:!0,capture:!0}),window.addEventListener(`resize`,e),()=>{document.removeEventListener(`mouseup`,e),document.removeEventListener(`keyup`,n),document.removeEventListener(`keydown`,r),window.removeEventListener(`scroll`,e,{capture:!0}),window.removeEventListener(`resize`,e)}},[]),e?K(`button`,{type:`button`,class:`read-chip`,style:{left:`${e.position.left}px`,top:`${e.position.top}px`},"aria-label":l(`panel.read_chip`),onMouseDown:e=>e.preventDefault(),onClick:()=>{Xe(e.text),t(null)},children:l(`panel.read_chip`)}):null}var tt={idle:{start:`loading`,stop:`idle`},loading:{loaded:`running`,fail:`failed`,stop:`idle`},running:{finish:`done`,fail:`failed`,stop:`idle`},done:{start:`loading`,stop:`idle`},failed:{start:`loading`,stop:`idle`}},nt={idle:{audio:`playing`,stop:`stopped`,reset:`idle`},playing:{audio:`playing`,pause:`paused`,stop:`stopped`,drain:`idle`,reset:`idle`},paused:{resume:`playing`,stop:`stopped`,drain:`idle`,reset:`idle`},stopped:{audio:`playing`,stop:`stopped`,reset:`idle`}};function q(e,t){return tt[e][t]??e}function J(e,t){return nt[e][t]??e}function rt(e,t){return e===`loading`||e===`running`||t===`playing`||t===`paused`}var it=i.levels.map(e=>e.id),at=i.default??`short`,ot=`fruitbat.speakMessages`,st=[`notice.dial_shorter`,`notice.dial_longer`,`notice.stopped`,`notice.all_cut`,`notice.oneline_failed`,`notice.input_limit`,`notice.done`];function ct(e){try{return localStorage.getItem(e)}catch{return null}}function lt(e,t){try{localStorage.setItem(e,t)}catch{}}var ut=class{voice;llm;gen=`idle`;play=`idle`;level=at;speakMessages;bullets=[];allCut=[];notices=[];lastNotice=null;current=null;error=null;progress=null;voiceProgress=null;runId=0;text=``;chunks=null;voiceReady=!1;listeners=new Set;runs=0;last=null;ttfa=null;runT0=0;stopMs=null;noticeLatency=null;spoken=[];genStats=null;voiceRun=null;constructor(e=u(),t=new c(s())){this.voice=e,this.llm=t,this.speakMessages=ct(ot)!==`off`,t.onNotice=e=>this.onLlmNotice(e);let n=new Map,r=new Map,i=e=>{let t=0,n=0;for(let r of e.values())t+=r.loaded,n+=r.total;return{loaded:t,total:n}};t.onProgress=e=>{e.file&&n.set(e.file,{loaded:e.loaded??0,total:e.total??0}),this.progress={file:e.file,...i(n)},this.emit()},e.onProgress((e,t,n)=>{r.set(e,{loaded:t,total:n}),this.voiceProgress={file:e,...i(r)},this.emit()}),typeof Worker<`u`&&!a()&&!o()&&this.warmVoice()}markVoiceReady(){if(!this.voiceReady){this.voiceReady=!0,this.emit();for(let e of this.pendingNotices.splice(0))this.notice(e)}}finishPrewarm(){this.voiceReady&&!this.voice.prewarmed&&this.voice.prewarm(st).catch(()=>void 0)}async warmVoice(){try{await this.voice.load(),this.markVoiceReady(),await this.voice.prewarm(st)}catch(e){this.error=e instanceof Error?`${e.name}: ${e.message}`:String(e),this.notice(`error.voice`)}this.emit()}subscribe(e){return this.listeners.add(e),e(this.snapshot()),()=>this.listeners.delete(e)}snapshot(){let e=this.voice.state();return{gen:this.gen,play:this.play,level:this.level,runId:this.runId,settledRunId:this.settledRunId,bullets:[...this.bullets],current:this.current,allCut:[...this.allCut],notices:[...this.notices],lastNotice:this.lastNotice,chunks:this.chunks?.length??0,voiceReady:this.voiceReady,prewarmed:this.voice.prewarmed,speakMessages:this.speakMessages,progress:this.progress,voiceProgress:this.voiceProgress,error:this.error,voice:{aheadSeconds:e.aheadSeconds,enqueued:e.enqueued,inFlight:e.inFlight,ended:e.ended,pending:e.pending,phase:e.phase}}}emit(){let e=this.snapshot();for(let t of this.listeners)t(e)}stats(){return{runs:this.runs,last:this.last,ttfa_ms:this.ttfa===null?null:Math.round(this.ttfa),stop_ms:this.stopMs===null?null:Math.round(this.stopMs*100)/100,notice_latency_ms:this.noticeLatency,notices_spoken:[...this.spoken],gen:this.genStats??((this.last?.level??this.level)===`readall`?null:this.llm.stats()),voice:this.voice.stats(),voice_run:this.voiceRun}}setSpeakMessages(e){this.speakMessages=e,lt(ot,e?`on`:`off`),this.emit()}onLlmNotice(e){e.key!==`notice.stopped`&&(e.key===`notice.all_cut`&&e.chunkIndex!==void 0&&!this.allCut.includes(e.chunkIndex)&&this.allCut.push(e.chunkIndex),this.notice(e.key))}pendingNotices=[];notice(e,t){if(this.notices.push(e),this.lastNotice=e,this.emit(),this.speakMessages){if(!this.voiceReady){this.pendingNotices.push(e);return}this.spoken.push(e),this.voice.speak(e,t).then(()=>{t!==void 0&&(this.noticeLatency=this.voice.lastNoticeLatencyMs,this.emit())}).catch(()=>{})}}runAbort=null;newRun(){let e=++this.runId;return this.pendingNotices=[],this.runAbort?.abort(),this.runAbort=new AbortController,this.llm.abort(),this.stopMs=this.voice.stop(),this.gen=q(this.gen,`stop`),this.play=J(this.play,`stop`),e}run(e,t){this.voice.ensureContext(),this.runs++,this.last={level:t,chars:e.length},this.text=e,this.level=t,this.chunks=null,this.notices=[],this.lastNotice=null,this.regenFrom=null;let n=this.newRun();return this.begin(n,t,{fromChunk:0,base:0,end:e.length})}silenceVoice(){this.voice.stop()}stop(e={}){let t=rt(this.gen,this.play)&&!e.quiet;return this.newRun(),this.current=null,this.progress=null,this.emit(),t&&this.notice(`notice.stopped`),this.stopMs??0}pause(){this.play===`playing`&&(this.voice.pause(),this.play=J(this.play,`pause`),this.emit())}resume(){this.play===`paused`&&(this.voice.resume(),this.play=J(this.play,`resume`),this.emit())}skip(){return this.voice.skip()}async setLevel(e){let t=performance.now(),n=this.level;if(e===n)return;if(this.level=e,!this.busy()||!this.text){this.emit();return}let r=it.indexOf(e)>it.indexOf(n),i=this.newRun();this.notice(r?`notice.dial_shorter`:`notice.dial_longer`,t),this.regenPending=i;let a=await this.currentChunkIndex();if(this.regenPending===i&&(this.regenPending=null),i!==this.runId)return;this.regenFrom=a;let o=this.chunks?.[a];await this.begin(i,e,{fromChunk:a,base:o?.start??0,end:this.text.length})}regenPending=null;busy(){if(this.regenPending===this.runId||rt(this.gen,this.play))return!0;if(this.play===`stopped`)return!1;let e=this.voice.state();return e.pending>0||e.inFlight>0||e.enqueued>e.ended}async readThisPart(e){let t=this.newRun(),n=await this.ensureChunks();if(t!==this.runId)return;let r=n?.[e];r&&await this.begin(t,`readall`,{fromChunk:e,base:r.start,end:r.end,keep:!0})}async ensureChunks(){if(this.chunks)return this.chunks;if(!this.text)return null;let e=this.text,t=null;try{t=await this.llm.chunk(e)}catch{t=null}return e===this.text?(this.chunks=t,this.chunks):null}async currentChunkIndex(){let e=this.current;if(e?.kind===`bullet`)return e.chunkIndex;let t=await this.ensureChunks();if(!t)return 0;if(e?.kind===`sentence`){let n=t.findIndex(t=>e.start>=t.start&&e.start<t.end);return n>=0?n:0}return this.heardChunk===null?this.regenFrom??0:this.heardChunk}heardChunk=null;regenFrom=null;async begin(e,t,n){this.last={level:t,chars:n.end-n.base},typeof window<`u`&&window.dispatchEvent(new CustomEvent(`fruitbat:live`)),this.play=J(this.play,`reset`),n.keep||(this.bullets=[],this.allCut=[],this.heardChunk=null),this.current=null,this.error=null,this.ttfa=null,this.runT0=performance.now(),this.voiceRun=null,this.genStats=null,this.gen=q(this.gen,`start`),this.emit();try{t===`readall`?await this.readAloud(e,n.base,n.end):await this.summarize(e,t,n.fromChunk)}catch(t){if(e!==this.runId)return;this.gen=q(this.gen,`fail`),this.error=t instanceof Error?`${t.name}: ${t.message}`:String(t),this.notice(`error.generation`)}e===this.runId&&(this.settledRunId=e),this.emit()}settledRunId=0;markAudio(){this.ttfa===null&&(this.ttfa=performance.now()-this.runT0),this.play=J(this.play,`audio`)}async readAloud(e,t,n){let r=this.text.slice(t,n),i=[];if(await this.voice.load(),e!==this.runId)return;this.markVoiceReady(),this.gen=q(this.gen,`loaded`),this.emit();let a=await this.voice.readAll(r,{onPlanned:e=>{i=e},onStart:n=>{e===this.runId&&(this.markAudio(),this.current={kind:`sentence`,start:t+n.start,end:t+n.end,text:r.slice(n.start,n.end),next:i[n.seq+1]?.text??null},this.emit())}});if(e===this.runId){if(this.voice.phase===`failed`){this.gen=q(this.gen,`fail`),this.error=this.voice.error,this.play=J(this.play,`stop`),this.current=null,this.notice(`error.voice`);return}this.gen=q(this.gen,`finish`),this.voiceRun=this.voice.metrics(a.seconds),a.finished&&(this.play=J(this.play,`drain`),this.current=null,this.notice(`notice.done`),this.finishPrewarm())}}async summarize(e,t,n){this.voice.load().then(()=>{this.markVoiceReady(),this.voice.prewarm(st).catch(()=>void 0)},()=>void 0);let r=this.voice.beginStream({onStart:t=>{if(e!==this.runId)return;this.markAudio();let n=t.tag===void 0?void 0:this.bullets[t.tag];n&&(this.current={kind:`bullet`,chunkIndex:n.chunkIndex,index:t.tag},this.heardChunk=n.chunkIndex),this.emit()}}),i=this.runAbort?.signal,a=await this.llm.ensureLoaded({signal:i});if(!a&&e===this.runId&&this.llm.error===`aborted`&&(a=await this.llm.ensureLoaded({signal:i})),e!==this.runId)return;if(!a){this.gen=q(this.gen,`fail`),this.error=this.llm.error,this.llm.gpu?.ok===!1&&!this.notices.includes(`notice.no_webgpu`)&&this.notice(`notice.no_webgpu`),this.voice.endStream(r),this.play=J(this.play,`reset`);return}if(this.gen=q(this.gen,`loaded`),this.emit(),await this.ensureChunks(),e!==this.runId)return;let o=await this.llm.summarize(this.text,t,{signal:this.runAbort?.signal,fromChunk:n,onBullet:t=>{if(e!==this.runId)return;let n=this.bullets.push(t)-1;this.emit(),this.voice.pushText(r,t.text,t.start,t.end,n)}});if(e!==this.runId)return;this.genStats=o,this.llm.state===`failed`?(this.gen=q(this.gen,`fail`),this.error=this.llm.error):this.gen=q(this.gen,`finish`),this.emit();let{finished:s,metrics:c}=await this.voice.endStream(r);e===this.runId&&(this.voiceRun=c,s||(this.play=J(this.play,`stop`),this.current=null),!s&&this.gen===`done`&&(this.error=this.error??`voice_failed`,this.notice(`error.voice`)),s&&(this.play=J(this.play,`drain`),this.current=null,this.gen===`done`&&this.bullets.length>0&&this.notice(`notice.done`),this.finishPrewarm()))}},dt=null;function Y(){return dt||=new ut,dt}function ft(e,t){for(let n=0;n<e.length;n++){let r=e[n],i=t>=r.audioStart,a=t<r.audioEnd;if(i&&a)return n}let n=e[e.length-1];return n&&t>=n.audioEnd?e.length-1:-1}function pt(){let[t,n]=V(ze),[r,i]=V({});return H(()=>Ve(n),[]),H(()=>{if(r[t])return;let n=!1;return e(`/demo/${t}.json`).then(e=>e.json()).then(e=>{n||i(n=>({...n,[t]:e}))}).catch(()=>{}),()=>{n=!0}},[t,r]),{track:r[t]??null,level:t}}function mt(){let{track:e,level:t}=pt(),[n,r]=V(!1),[i,a]=V(-1),o=Ae(null);return H(()=>{let t=o.current;if(!t||!e)return;let i=n;t.load(),a(-1),i&&t.play().catch(()=>r(!1))},[e?.level]),H(()=>{let e=()=>{let e=o.current;e&&!e.paused&&e.pause(),r(!1)},t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`fruitbat:stop`,e),window.addEventListener(`fruitbat:run`,e),window.addEventListener(`fruitbat:live`,e),document.addEventListener(`keydown`,t),()=>{window.removeEventListener(`fruitbat:stop`,e),window.removeEventListener(`fruitbat:run`,e),window.removeEventListener(`fruitbat:live`,e),document.removeEventListener(`keydown`,t)}},[]),K(`section`,{class:`demo`,"data-testid":`demo`,"data-level":t,children:[K(`p`,{class:`demo-recording-label`,children:l(`demo.recording_label`)}),K(`p`,{class:`demo-excerpt-note`,children:l(`demo.excerpt_note`)}),K(`button`,{type:`button`,class:`demo-try-it-now`,"data-testid":`demo-try`,onClick:()=>{let e=o.current;e&&(window.dispatchEvent(new CustomEvent(`fruitbat:demo`)),e.play().catch(()=>r(!1)))},disabled:!e,children:l(`demo.try_it_now`)}),K(`p`,{class:`demo-switch-level`,children:l(`demo.switch_level`)}),e&&K(`audio`,{ref:o,"data-testid":`demo-audio`,preload:`auto`,src:`/demo/${e.level}.wav`,onPlay:()=>r(!0),onPause:()=>r(!1),onEnded:()=>r(!1),onTimeUpdate:()=>{let t=o.current;t&&e&&a(ft(e.items,t.currentTime))}}),e&&K(`ul`,{class:`demo-items`,"data-testid":`demo-bullets`,"aria-label":l(`a11y.bullet_list`),children:e.items.map((e,t)=>K(`li`,{"aria-current":t===i?`true`:void 0,children:e.text},t))})]})}async function ht(e){if(typeof caches>`u`)return!1;try{return!!await caches.match(e)}catch{return!1}}function gt(e){let t=[...e.files].sort((e,t)=>t.bytes-e.bytes)[0];return t?ht(r(e,t.path)):Promise.resolve(!1)}function X(e){return Math.round((e??0)/1e6)}function _t(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,String(n)),e)}function vt({testId:e,loaded:t,total:n}){let r=n>0?Math.min(100,Math.round(t/n*100)):void 0;return r===void 0?K(`progress`,{"data-testid":e,class:`loading-bar`}):K(`progress`,{"data-testid":e,class:`loading-bar`,max:100,value:r,"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100})}function yt(e){let[t,n]=V(`unknown`);return H(()=>{if(!e)return;let t=!1;return gt(e).then(e=>{t||n(e?`cached`:`first_time`)}),()=>{t=!0}},[e?.id,e?.revision]),t}function bt({state:e}){return e===`unknown`?null:K(`p`,{class:`loading-cache`,children:l(e===`cached`?`loading.cached`:`loading.first_time`)})}function xt(){let[e,t]=V(()=>Y().snapshot());return H(()=>Y().subscribe(t),[]),e}function St({s:e}){let t=Y().llm,[n,r]=V(`idle`),i=yt(t.tier()),a=t.isLoaded(),o=!a&&(n===`failed`||t.state===`failed`||t.state===`stopped`),s=a||!o&&(n!==`idle`||e.progress!==null||t.state===`loading`),c=a||n===`ready`,u=X(e.progress?.loaded),d=Math.max(X(e.progress?.total),s?t.sizeMb():0);return K(`div`,{class:`loading-summarizer`,"data-started":s,children:[K(`p`,{class:`loading-line`,children:l(`loading.summarizer_size`).replace(`{mb}`,String(t.sizeMb()))}),!s&&K(`button`,{type:`button`,class:`loading-summarizer-button`,"data-testid":`summarizer-load`,onClick:()=>{s||(r(`loading`),t.ensureLoaded().then(e=>r(e?`ready`:`failed`)))},children:l(`loading.summarizer_button`).replace(`{mb}`,String(t.sizeMb()))}),s&&K(M,{children:[K(vt,{testId:`summarizer-progress`,loaded:c?1:u,total:c?1:d}),K(`p`,{class:`loading-line`,children:_t(l(`loading.progress`),{mb:u})}),K(bt,{state:i})]}),e.notices.filter((t,n)=>(t===`notice.no_webgpu`||t===`notice.probe_failed`||t===`notice.low_end_tier`)&&e.notices.indexOf(t)===n).map(e=>K(`p`,{class:`loading-notice`,role:`status`,"data-notice":e,children:l(e)},e))]})}function Ct({s:e}){let t=n().web.voice,r=yt(t);if(a())return K(`p`,{class:`loading-line`,"data-phase":`save_data`,children:l(`loading.save_data`)});if(o())return K(`p`,{class:`loading-line`,"data-phase":`mobile`,children:l(`loading.mobile`)});if(e.voiceReady)return K(`p`,{class:`loading-line`,"data-phase":`ready`,children:l(`loading.ready`)});if(e.voiceProgress){let n=X(e.voiceProgress.loaded),i=Math.max(X(e.voiceProgress.total),Math.round(t.files.reduce((e,t)=>e+t.bytes,0)/1e6));return K(`div`,{class:`loading-voice`,"data-phase":`voice`,children:[K(`p`,{class:`loading-line`,children:l(`loading.voice`)}),K(vt,{testId:`voice-progress`,loaded:n,total:i}),K(`p`,{class:`loading-line`,children:_t(l(`loading.progress`),{mb:n})}),K(bt,{state:r})]})}return K(`p`,{class:`loading-line`,"data-phase":`probing`,children:l(`loading.probing`)})}function wt(){let e=xt();return K(`section`,{class:`loading`,"data-testid":`loading`,children:[K(Ct,{s:e}),K(St,{s:e})]})}var Z={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`run-stats.schema.json`,title:`RunStats`,$comment:"One bench measurement (docs/PLAN.md rule 3, C11, S0-05). Numbers, enums, and validated metadata only — no free-text field. Metrics are nullable when a dial level doesn't produce them (readall has no LLM metrics; only readall has `coverage`). Bench identity = target, model_id, model_rev, dtype, device, browser(+major), os(+major), machine_id, cache_state, doc_id, level (bench/identity.md). Field order here is the fixed column order of bench/results.csv.",type:`object`,additionalProperties:!1,$defs:{level:{type:`string`,enum:[`readall`,`short`,`caveman`,`oneline`]},device:{type:`string`,enum:[`webgpu`,`wasm`,`mlx`]},model_id:{type:`string`,$comment:`Closed set sourced from spec/models.json. Add a value here (small PR) whenever a new model_id is pinned there.`,enum:[`onnx-community/Qwen3.5-0.8B-Text-ONNX`,`onnx-community/Qwen2.5-0.5B-Instruct`,`onnx-community/Qwen3-0.6B-ONNX`,`HuggingFaceTB/SmolLM2-360M-Instruct`,`onnx-community/Kokoro-82M-v1.0-ONNX`,`mlx-community/Qwen3.5-2B-4bit`,`mlx-community/Qwen3-1.7B-4bit`,`mlx-community/Kokoro-82M-bf16`]}},required:`schema_version.target.device.level.browser.browser_major.os.os_major.cache_state.model_id.model_rev.dtype.doc_id.commit.date.machine_id.ttfa_ms.gen_ms.tok_s.rtf.gap_ms.stop_ms.coverage.bullets_total.bullets_cut.cut_rate.facts_token_hit.halluc_flags.forbidden_hits.oneline_keyword_hit.tts_overlimit.peak_mb.heap_mb`.split(`.`),properties:{schema_version:{type:`integer`,enum:[1]},target:{type:`string`,enum:[`web`,`mac`]},device:{$ref:`#/$defs/device`},level:{$ref:`#/$defs/level`},browser:{type:`string`,enum:[`chrome`,`safari`,`firefox`,`none`]},browser_major:{type:[`integer`,`null`],minimum:0},os:{type:`string`,enum:[`macos`,`windows`,`linux`,`ios`,`android`]},os_major:{type:`integer`,minimum:0},cache_state:{type:`string`,enum:[`cold`,`warm`]},model_id:{$ref:`#/$defs/model_id`},model_rev:{type:`string`,pattern:`^[0-9a-f]{40}$`},dtype:{type:`string`,enum:[`q4f16`,`q8`,`q8f16`,`q4`,`fp32`,`bf16`,`fp16`,`4bit`,`8bit`],$comment:`q8f16: the WebGPU voice variant (?tts=webgpu, spec/models.json).`},doc_id:{type:`string`,pattern:`^([0-9]{3}|paste)$`,$comment:`S1-10: bench rows use the 3-digit eval corpus id; every other row (real usage, not the corpus) is 'paste' unless window.__fruitbat.setDocId(id) overrides it.`},commit:{type:`string`,pattern:`^[0-9a-f]{7,40}$`},date:{type:`string`,pattern:`^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})?)?$`},machine_id:{type:`string`,pattern:`^(web|[0-9a-f]{12})$`},ttfa_ms:{type:[`number`,`null`],minimum:0},gen_ms:{type:[`number`,`null`],minimum:0},tok_s:{type:[`number`,`null`],minimum:0},rtf:{type:[`number`,`null`],minimum:0},gap_ms:{type:[`number`,`null`],minimum:0},stop_ms:{type:[`number`,`null`],minimum:0},coverage:{type:[`number`,`null`],minimum:0,maximum:1},bullets_total:{type:[`integer`,`null`],minimum:0},bullets_cut:{type:[`integer`,`null`],minimum:0},cut_rate:{type:[`number`,`null`],minimum:0,maximum:1},facts_token_hit:{type:[`number`,`null`],minimum:0,maximum:1},halluc_flags:{type:[`integer`,`null`],minimum:0},forbidden_hits:{type:[`integer`,`null`],minimum:0},oneline_keyword_hit:{type:[`number`,`null`],minimum:0,maximum:1},tts_overlimit:{type:[`integer`,`null`],minimum:0},peak_mb:{type:[`number`,`null`],minimum:0},heap_mb:{type:[`number`,`null`],minimum:0}}},Tt=Object.freeze([...Z.required??[]]);function Et(e){let t=/^#\/\$defs\/(.+)$/.exec(e);if(!t)throw Error(`stats/schema: unsupported $ref "${e}"`);let n=Z.$defs?.[t[1]];if(!n)throw Error(`stats/schema: unknown $defs entry "${t[1]}"`);return n}function Dt(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e==`number`?Number.isInteger(e)?`integer`:`number`:typeof e==`string`?`string`:typeof e==`boolean`?`boolean`:`object`}function Ot(e,t){let n=Dt(e);return t===`number`?n===`number`||n===`integer`:n===t}function kt(e,t,n,r){let i=n.$ref?Et(n.$ref):n;if(i.type!==void 0&&!(Array.isArray(i.type)?i.type:[i.type]).some(e=>Ot(t,e))){r.push(`${e}: expected type ${JSON.stringify(i.type)}, got ${Dt(t)} (${JSON.stringify(t)})`);return}t!==null&&(i.enum!==void 0&&!i.enum.includes(t)&&r.push(`${e}: ${JSON.stringify(t)} is not one of ${JSON.stringify(i.enum)}`),i.pattern!==void 0&&typeof t==`string`&&!new RegExp(i.pattern).test(t)&&r.push(`${e}: ${JSON.stringify(t)} does not match pattern ${i.pattern}`),i.minimum!==void 0&&typeof t==`number`&&t<i.minimum&&r.push(`${e}: ${t} is below minimum ${i.minimum}`),i.maximum!==void 0&&typeof t==`number`&&t>i.maximum&&r.push(`${e}: ${t} is above maximum ${i.maximum}`))}function At(e){let t=[];if(typeof e!=`object`||!e||Array.isArray(e))return{ok:!1,errors:[`row is not a plain object`]};let n=e,r=Z.properties??{};for(let e of Z.required??[])e in n||t.push(`missing required field: ${e}`);if(Z.additionalProperties===!1)for(let e of Object.keys(n))e in r||t.push(`unknown field: ${e}`);for(let[e,i]of Object.entries(r))e in n&&kt(e,n[e],i,t);return{ok:t.length===0,errors:t}}var jt=`fruitbat.stats`,Mt=`fruitbat.stats.errors`,Nt=`paste`;function Pt(e){Nt=e}function Ft(){return Nt}function Q(e,t){let n=e.exec(t);return n?Number(n[1]):null}function It(e=typeof navigator<`u`?navigator.userAgent:``){let t=`none`,n=null;/Firefox\//.test(e)?(t=`firefox`,n=Q(/Firefox\/(\d+)/,e)):/Chrome\//.test(e)&&!/Edg\//.test(e)?(t=`chrome`,n=Q(/Chrome\/(\d+)/,e)):/Safari\//.test(e)&&/Version\//.test(e)&&(t=`safari`,n=Q(/Version\/(\d+)/,e));let r=`linux`,i=0;return/iPhone|iPad/.test(e)?(r=`ios`,i=Q(/OS (\d+)_/,e)??0):/Android/.test(e)?(r=`android`,i=Q(/Android (\d+)/,e)??0):/Mac OS X/.test(e)?(r=`macos`,i=Q(/Mac OS X (\d+)/,e)??0):/Windows NT/.test(e)&&(r=`windows`,i=Q(/Windows NT (\d+)/,e)??0),{browser:t,browser_major:n,os:r,os_major:i}}function Lt(){return`4dda870`}function Rt(){let e=It(),t=typeof performance<`u`?performance.memory:void 0,n=t?Math.round(t.usedJSHeapSize/1e6*10)/10:null;return{...e,machine_id:`web`,commit:Lt(),date:new Date().toISOString(),doc_id:Ft(),heap_mb:n}}function zt(e,r){let i=e.last?.level??`short`,a=i===`readall`?e.voice:null,o=e.gen,s=e.voice_run,c,l,u,d;if(i===`readall`){let e=n().web.voice;c=e.id,l=e.revision,u=s?s.dtype:a?.dtype??e.dtype,d=s?s.device:a?.device??e.device}else{let e=t(),n=e.find(e=>e.id===o?.model_id)??e[0];c=n.id,l=n.revision,u=n.dtype,d=n.device}let f=(s?s.cache_state:a?.cache_state)===`cold`,p=i!==`readall`&&o?.cache_cold===!0,m=f||p?`cold`:`warm`,h=o?.bullets_total??null,g=o?.bullets_cut??null,_=h===null?null:h>0?(g??0)/h:0;return{schema_version:1,target:`web`,device:d,level:i,browser:r.browser,browser_major:r.browser_major,os:r.os,os_major:r.os_major,cache_state:m,model_id:c,model_rev:l,dtype:u,doc_id:r.doc_id,commit:r.commit,date:r.date,machine_id:r.machine_id,ttfa_ms:e.ttfa_ms,gen_ms:o?.gen_ms??null,tok_s:o?.tok_s??null,rtf:s?s.rtf:a?.rtf??null,gap_ms:s?s.gap_ms:a?.gap_ms??null,stop_ms:null,coverage:i===`readall`?a?.coverage??null:null,bullets_total:h,bullets_cut:g,cut_rate:_,facts_token_hit:null,halluc_flags:null,forbidden_hits:null,oneline_keyword_hit:null,tts_overlimit:s?s.tts_overlimit:a?.tts_overlimit??0,peak_mb:null,heap_mb:r.heap_mb??null}}function Bt(){try{let e=localStorage.getItem(jt);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function Vt(){try{let e=Number(localStorage.getItem(`fruitbat.stats.errors`))||0;localStorage.setItem(Mt,String(e+1))}catch{}}function Ht(){return Bt()}function Ut(){try{localStorage.removeItem(jt),localStorage.removeItem(Mt)}catch{}}function Wt(e){try{let t=Bt();for(t.push(e);t.length>200;)t.shift();localStorage.setItem(jt,JSON.stringify(t))}catch{Vt()}}function Gt(e,t=Rt()){let n=zt(e,t),{ok:r,errors:i}=At(n);return r&&Wt(n),{ok:r,errors:i,row:n}}function Kt(e){if(e==null)return``;let t=String(e);return/[",\n]/.test(t)?`"${t.replace(/"/g,`""`)}"`:t}function qt(){let e=[Tt.join(`,`)];for(let t of Bt()){let n=t;e.push(Tt.map(e=>Kt(n[e])).join(`,`))}return e.join(`
2
  `)+`
3
  `}var Jt=[`date`,`level`,`device`,`dtype`,`cache_state`,`doc_id`,`ttfa_ms`,`tok_s`,`rtf`,`bullets_total`,`bullets_cut`],Yt={date:`stats.col.date`,level:`stats.col.level`,device:`stats.col.device`,dtype:`stats.col.dtype`,cache_state:`stats.col.cache_state`,doc_id:`stats.col.doc_id`,ttfa_ms:`stats.col.ttfa_ms`,tok_s:`stats.col.tok_s`,rtf:`stats.col.rtf`,bullets_total:`stats.col.bullets_total`,bullets_cut:`stats.col.bullets_cut`};function Xt(e){let t=new Blob([e],{type:`text/csv`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`fruitbat-stats.csv`,r.click(),URL.revokeObjectURL(n)}function Zt({onClose:e}){let[t,n]=V(()=>Ht()),r=Ae(null);return H(()=>{r.current?.scrollIntoView({block:`start`}),r.current?.focus()},[]),K(`div`,{class:`stats-view`,role:`dialog`,"aria-label":l(`stats.title`),ref:r,tabIndex:-1,children:[K(`div`,{class:`stats-view-header`,children:[K(`h2`,{children:l(`stats.title`)}),K(`button`,{type:`button`,class:`stats-close`,onClick:e,children:l(`panel.close`)})]}),t.length===0?K(`p`,{class:`stats-empty`,children:l(`stats.empty`)}):K(`table`,{class:`stats-table`,children:[K(`thead`,{children:K(`tr`,{children:Jt.map(e=>K(`th`,{children:l(Yt[e])},e))})}),K(`tbody`,{children:t.map((e,t)=>K(`tr`,{children:Jt.map(t=>K(`td`,{children:e[t]===null?``:String(e[t])},t))},t))})]}),K(`div`,{class:`stats-actions`,children:[K(`button`,{type:`button`,onClick:()=>Xt(qt()),children:l(`stats.export`)}),K(`button`,{type:`button`,onClick:()=>{Ut(),n(Ht())},children:l(`stats.clear`)})]})]})}var Qt=i.levels,$t=i.default??`short`;function en({level:e,onChange:t}){return K(`fieldset`,{class:`dial`,children:[K(`legend`,{class:`visually-hidden`,children:l(`a11y.dial`)}),Qt.map(n=>K(`label`,{class:`dial-option`,children:[K(`input`,{type:`radio`,name:`level`,value:n.id,checked:e===n.id,onChange:()=>t(n.id)}),K(`span`,{children:l(n.label_key)})]},n.id))]})}function tn(){if(typeof document<`u`){let e=document.documentElement.getAttribute(`data-theme`);if(e===`dark`||e===`light`)return e}return typeof matchMedia<`u`&&matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function nn(){let[e,t]=V(tn);return K(`button`,{type:`button`,class:`theme-toggle`,onClick:()=>{let n=e===`dark`?`light`:`dark`;t(n),document.documentElement.setAttribute(`data-theme`,n);try{localStorage.setItem(`fruitbat-theme`,n)}catch{}},"aria-pressed":e===`dark`,children:l(`theme.toggle`)})}function rn({paragraphs:e}){return K(`article`,{class:`article`,"aria-label":l(`intake.sample_label`),children:e.map((e,t)=>K(`p`,{children:e},t))})}function an(){let[t,n]=V([]);return H(()=>{let t=!1;return e(`/sample.txt`).then(e=>e.text()).then(e=>{t||n(e.split(/\n{2,}/).map(e=>e.trim()).filter(Boolean))}).catch(()=>{t||n([])}),()=>{t=!0}},[]),t}function on(){let[e,t]=V(()=>Y().snapshot());return H(()=>Y().subscribe(t),[]),e}function sn(){let e=on(),t=e.current,n=e.bullets.length===0&&!t&&e.allCut.length===0&&!e.lastNotice;return K(`aside`,{id:`panel`,class:`panel`,"aria-label":l(`a11y.panel_region`),"data-gen":e.gen,"data-play":e.play,children:[n&&K(`p`,{class:`panel-empty`,children:l(`panel.empty`)}),t?.kind===`sentence`&&K(`div`,{class:`now-reading`,children:[K(`p`,{class:`now-label`,children:l(`panel.now_reading`)}),K(`p`,{class:`now-text`,"data-testid":`now-text`,children:t.text}),t.next&&K(`p`,{class:`next-text`,children:[K(`span`,{class:`next-label`,children:l(`panel.next_up`)}),` `,t.next]})]}),e.bullets.length>0&&K(`ul`,{class:`bullets`,"aria-label":l(`a11y.bullet_list`),children:e.bullets.map((e,n)=>K(`li`,{"data-chunk":e.chunkIndex,"aria-current":t?.kind===`bullet`&&t.index===n?`true`:void 0,children:e.text},n))}),e.allCut.map(e=>K(`p`,{class:`read-part-row`,children:K(`button`,{type:`button`,class:`read-part`,"data-chunk":e,onClick:()=>void Y().readThisPart(e),children:l(`panel.read_this_part`)})},e)),e.lastNotice&&K(`p`,{class:`panel-notice`,role:`status`,"aria-live":`polite`,"data-notice":e.lastNotice,children:l(e.lastNotice)})]})}function cn(){let[e,t]=V($t),[n,r]=V(!1),i=an();return H(()=>{document.title=l(`app.title`)},[]),H(()=>{Be(e)},[e]),K(`div`,{class:`app-shell`,children:[K(`header`,{class:`app-header`,children:[K(`h1`,{class:`app-title`,children:l(`app.title`)}),K(en,{level:e,onChange:e=>{Be(e),t(e)}}),K(`button`,{type:`button`,class:`stats-toggle`,onClick:()=>r(!0),children:l(`panel.stats`)}),K(nn,{})]}),K(wt,{}),K(`main`,{class:`app-main`,children:[K(mt,{}),K(rn,{paragraphs:i}),K($e,{})]}),K(sn,{}),K(et,{}),n&&K(Zt,{onClose:()=>r(!1)})]})}function ln(){try{let e=localStorage.getItem(`fruitbat-theme`);(e===`dark`||e===`light`)&&document.documentElement.setAttribute(`data-theme`,e)}catch{}}var $=Y();window.__fruitbat={run(e,t){window.dispatchEvent(new CustomEvent(`fruitbat:run`,{detail:{text:e,level:t}}))},stop(){window.dispatchEvent(new CustomEvent(`fruitbat:stop`))},stats(){return $.stats()},state:()=>$.snapshot(),setLevel:e=>$.setLevel(e),readThisPart:e=>$.readThisPart(e),pause:()=>$.pause(),resume:()=>$.resume(),skip:()=>$.skip(),setSpeakMessages:e=>$.setSpeakMessages(e),rows:()=>Ht(),setDocId:e=>Pt(e)},window.addEventListener(`fruitbat:run`,e=>void $.run(e.detail.text,e.detail.level)),window.addEventListener(`fruitbat:stop`,()=>$.stop()),window.addEventListener(`fruitbat:demo`,()=>{let e=$.snapshot(),t=e.voice.pending>0||e.voice.inFlight>0||e.voice.enqueued>e.voice.ended;rt(e.gen,e.play)||t?$.stop({quiet:!0}):$.silenceVoice()});var un=0;$.subscribe(e=>{(e.gen===`done`||e.gen===`failed`)&&e.settledRunId===e.runId&&e.runId!==un&&(un=e.runId,Gt($.stats()))}),Ve(e=>void $.setLevel(e)),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&$.stop()}),ln();var dn=document.getElementById(`app`);dn&&ve(K(cn,{}),dn);
 
1
+ import{l as e}from"./loader-D0INP31U.js";import{i as t,r as n,t as r}from"./pins-DVBrHC3g.js";import{a as i,i as a,n as o,r as s,t as c}from"./llm-DH311QE0.js";import{a as l,i as u}from"./tts-Cm1VA0A9.js";var d,f,p,m,h,g,_,v,y,b,x,S,C,w,T={},E=[],D=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,O=Array.isArray;function k(e,t){for(var n in t)e[n]=t[n];return e}function ee(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function A(e,t,n){var r,i,a,o={};for(a in t)a==`key`?r=t[a]:a==`ref`?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?d.call(arguments,2):n),typeof e==`function`&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return j(e,o,r,i,null)}function j(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++p,__i:-1,__u:0};return i==null&&f.vnode!=null&&f.vnode(a),a}function M(e){return e.children}function N(e,t){this.props=e,this.context=t}function P(e,t){if(t==null)return e.__?P(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?P(e):null}function te(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=k({},t);a.__v=t.__v+1,f.vnode&&f.vnode(a),ue(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??P(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,fe(r,a,i),t.__e=t.__=null,a.__e!=n&&ne(a)}}function ne(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),ne(e)}function re(e){(!e.__d&&(e.__d=!0)&&m.push(e)&&!F.__r++||h!=f.debounceRendering)&&((h=f.debounceRendering)||g)(F)}function F(){try{for(var e,t=1;m.length;)m.length>t&&m.sort(_),e=m.shift(),t=m.length,te(e)}finally{m.length=F.__r=0}}function ie(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r&&r.__k||E,v=t.length;for(c=ae(n,t,_,c,v),d=0;d<v;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&_[p.__i]||T,p.__i=d,g=ue(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&he(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h==null&&m!=null&&(h=m),4&p.__u?(c=oe(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function ae(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=j(null,o,null,null,null):O(o)?o=e.__k[a]=j(M,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=j(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=se(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=P(s)),ge(s,s));return r}function oe(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=oe(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=P(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function se(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function ce(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||D.test(t)?n:n+`px`}function I(e,t,n,r,i){var a,o;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||ce(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ce(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(x,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[b]=r[b]:(n[b]=S,e.addEventListener(t,a?w:C,a)):e.removeEventListener(t,a?w:C,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function le(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[y]==null)t[y]=S++;else if(t[y]<n[b])return;return n(f.event?f.event(t):t)}}}function ue(e,t,n,r,i,a,o,s,c,l){var u,d,p,m,h,g,_,v,y,b,x,S,C,w,T,D,A=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),a=[s=t.__e=n.__e]),(u=f.__b)&&u(t);n:if(typeof A==`function`){d=o.length;try{if(y=t.props,b=A.prototype&&A.prototype.render,x=(u=A.contextType)&&r[u.__c],S=u?x?x.props.value:u.__:r,n.__c?v=(p=t.__c=n.__c).__=p.__E:(b?t.__c=p=new A(y,S):(t.__c=p=new N(y,S),p.constructor=A,p.render=_e),x&&x.sub(p),p.state||(p.state={}),p.__n=r,m=p.__d=!0,p.__h=[],p._sb=[]),b&&p.__s==null&&(p.__s=p.state),b&&A.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=k({},p.__s)),k(p.__s,A.getDerivedStateFromProps(y,p.__s))),h=p.props,g=p.state,p.__v=t,m)b&&A.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),b&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(b&&A.getDerivedStateFromProps==null&&y!==h&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(y,S),t.__v==n.__v||!p.__e&&p.shouldComponentUpdate!=null&&!1===p.shouldComponentUpdate(y,p.__s,S)){t.__v!=n.__v&&(p.props=y,p.state=p.__s,p.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),E.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&o.push(p),s=P(n);break n}p.componentWillUpdate!=null&&p.componentWillUpdate(y,p.__s,S),b&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(h,g,_)})}if(p.context=S,p.props=y,p.__P=e,p.__e=!1,C=f.__r,w=0,b)p.state=p.__s,p.__d=!1,C&&C(t),u=p.render(p.props,p.state,p.context),E.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,C&&C(t),u=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++w<25);p.state=p.__s,p.getChildContext!=null&&(r=k(k({},r),p.getChildContext())),b&&!m&&p.getSnapshotBeforeUpdate!=null&&(_=p.getSnapshotBeforeUpdate(h,g)),T=u!=null&&u.type===M&&u.key==null?pe(u.props.children):u,s=ie(e,O(T)?T:[T],t,n,r,i,a,o,s,c,l),p.base=t.__e,t.__u&=-161,p.__h.length&&o.push(p),v&&(p.__E=p.__=null)}catch(e){if(o.length=d,t.__v=null,c||a!=null){if(e.then){for(t.__u|=c?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a!=null&&(a[a.indexOf(s)]=null),t.__e=s}else if(a!=null)for(D=a.length;D--;)ee(a[D])}else t.__e=n.__e;t.__k??=n.__k||[],e.then||de(t),f.__e(e,t,n)}}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=me(n.__e,t,n,r,i,a,o,c,l);return(u=f.diffed)&&u(t),128&t.__u?void 0:s}function de(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(de))}function fe(e,t,n){for(var r=0;r<n.length;r++)he(n[r],n[++r],n[++r]);f.__c&&f.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){f.__e(e,t.__v)}})}function pe(e){return typeof e!=`object`||!e||e.__b>0?e:O(e)?e.map(pe):e.constructor===void 0?k({},e):null}function me(e,t,n,r,i,a,o,s,c){var l,u,p,m,h,g,_,v=n.props||T,y=t.props,b=t.type;if(b==`svg`?i=`http://www.w3.org/2000/svg`:b==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(l=0;l<a.length;l++)if((h=a[l])&&`setAttribute`in h==!!b&&(b?h.localName==b:h.nodeType==3)){e=h,a[l]=null;break}}if(e==null){if(b==null)return document.createTextNode(y);e=document.createElementNS(i,b,y.is&&y),s&&=(f.__m&&f.__m(t,a),!1),a=null}if(b==null)v===y||s&&e.data==y||(e.data=y);else{if(a=b==`textarea`&&y.defaultValue!=null?null:a&&d.call(e.childNodes),!s&&a!=null)for(v={},l=0;l<e.attributes.length;l++)v[(h=e.attributes[l]).name]=h.value;for(l in v)h=v[l],l==`dangerouslySetInnerHTML`?p=h:l==`children`||l in y||l==`value`&&`defaultValue`in y||l==`checked`&&`defaultChecked`in y||I(e,l,null,h,i);for(l in y)h=y[l],l==`children`?m=h:l==`dangerouslySetInnerHTML`?u=h:l==`value`?g=h:l==`checked`?_=h:s&&typeof h!=`function`||v[l]===h||I(e,l,h,v[l],i);if(u)s||p&&(u.__html==p.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(p&&(e.innerHTML=``),ie(t.type==`template`?e.content:e,O(m)?m:[m],t,n,r,b==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,o,a?a[0]:n.__k&&P(n,0),s,c),a!=null)for(l=a.length;l--;)ee(a[l]);s&&b!=`textarea`||(l=`value`,b==`progress`&&g==null?e.removeAttribute(`value`):g!=null&&(g!==e[l]||b==`progress`&&!g||b==`option`&&g!=v[l])&&I(e,l,g,v[l],i),l=`checked`,_!=null&&_!=e[l]&&I(e,l,_,v[l],i))}return e}function he(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){f.__e(e,n)}}function ge(e,t,n){var r,i;if(f.unmount&&f.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||he(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){f.__e(e,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&ge(r[i],t,n||typeof e.type!=`function`);n||ee(e.__e),e.__c=e.__=e.__e=void 0}function _e(e,t,n){return this.constructor(e,n)}function ve(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),f.__&&f.__(e,t),i=(r=typeof n==`function`)?null:n&&n.__k||t.__k,a=[],o=[],ue(t,e=(!r&&n||t).__k=A(M,null,[e]),i||T,T,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?d.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),fe(a,e,o),e.props.children=null}d=E.slice,f={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},p=0,N.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=k({},this.state);typeof e==`function`&&(e=e(k({},n),this.props)),e&&k(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),re(this))},N.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),re(this))},N.prototype.render=M,m=[],g=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,_=function(e,t){return e.__v.__b-t.__v.__b},F.__r=0,v=Math.random().toString(8),y=`__d`+v,b=`__a`+v,x=/(PointerCapture)$|Capture$/i,S=0,C=le(!1),w=le(!0);var L,R,ye,be,z=0,xe=[],B=f,Se=B.__b,Ce=B.__r,we=B.diffed,Te=B.__c,Ee=B.unmount,De=B.__;function Oe(e,t){B.__h&&B.__h(R,e,z||t),z=0;var n=R.__H||(R.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function V(e){return z=1,ke(Le,e)}function ke(e,t,n){var r=Oe(L++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Le(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=R,!R.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};R.__f=!0;var a=R.shouldComponentUpdate,o=R.componentWillUpdate;R.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},R.shouldComponentUpdate=i}return r.__N||r.__}function H(e,t){var n=Oe(L++,3);!B.__s&&Ie(n.__H,t)&&(n.__=e,n.u=t,R.__H.__h.push(n))}function Ae(e){return z=5,je(function(){return{current:e}},[])}function je(e,t){var n=Oe(L++,7);return Ie(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Me(){for(var e;e=xe.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(U),t.__h.some(Fe),t.__h=[]}catch(n){t.__h=[],B.__e(n,e.__v)}}}B.__b=function(e){R=null,Se&&Se(e)},B.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),De&&De(e,t)},B.__r=function(e){Ce&&Ce(e),L=0;var t=(R=e.__c).__H;t&&(ye===R?(t.__h=[],R.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(U),t.__h.some(Fe),t.__h=[],L=0)),ye=R},B.diffed=function(e){we&&we(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(xe.push(t)!==1&&be===B.requestAnimationFrame||((be=B.requestAnimationFrame)||Pe)(Me)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),ye=R=null},B.__c=function(e,t){t.some(function(e){try{e.__h.some(U),e.__h=e.__h.filter(function(e){return!e.__||Fe(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],B.__e(n,e.__v)}}),Te&&Te(e,t)},B.unmount=function(e){Ee&&Ee(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{U(e)}catch(e){t=e}}),n.__H=void 0,t&&B.__e(t,n.__v))};var Ne=typeof requestAnimationFrame==`function`;function Pe(e){var t,n=function(){clearTimeout(r),Ne&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Ne&&(t=requestAnimationFrame(n))}function U(e){var t=R,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),R=t}function Fe(e){var t=R;e.__c=e.__(),R=t}function Ie(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Le(e,t){return typeof t==`function`?t(e):t}var W=i.default??`short`,Re=new Set;function ze(){return W}function Be(e){if(e!==W){W=e;for(let e of Re)e(W)}}function Ve(e){return Re.add(e),()=>Re.delete(e)}var He=96,Ue=36,G=8;function We(){let e=typeof window<`u`?window.getSelection():null;return!e||e.isCollapsed||e.rangeCount===0?``:e.toString().trim()}function Ge(){return We().length>0}function Ke(e){return e.trim().length>=20}function qe(){let e=typeof window<`u`?window.getSelection():null;if(!e||e.rangeCount===0)return null;let t=e.getRangeAt(0).getBoundingClientRect();return t.width===0&&t.height===0?null:t}function Je(e,t,n){let r=e.bottom+G;return r+Ue>n&&(r=e.top-Ue-G),r=Math.max(G,Math.min(r,n-Ue-G)),{left:Math.max(G,Math.min(e.left,t-He-G)),top:r}}function Ye(e){return e.altKey&&e.code===`KeyR`}function Xe(e){let t=e.trim();t&&window.__fruitbat.run(t,ze())}var Ze=0;Array.isArray;function K(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ze,__i:-1,__u:0,__source:i,__self:a};if(typeof e==`function`&&(o=e.defaultProps))for(s in o)c[s]===void 0&&(c[s]=o[s]);return f.vnode&&f.vnode(l),l}function Qe(e){let t=e.trim();return t===``?0:t.split(/\s+/).length}function $e(){let[e,t]=V(``),n=Qe(e),r=e.trim()===``;function i(){r||Xe(e)}return K(`div`,{class:`paste-box`,children:[K(`label`,{class:`paste-label`,for:`paste-input`,children:l(`intake.paste_placeholder`)}),K(`textarea`,{id:`paste-input`,class:`paste-textarea`,placeholder:l(`intake.paste_placeholder`),value:e,onInput:e=>t(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),i())}}),K(`div`,{class:`paste-row`,children:[K(`p`,{class:`word-count`,"aria-live":`polite`,"data-word-count":n,children:l(`intake.word_count`).replace(`{n}`,String(n))}),K(`button`,{type:`button`,class:`read-button`,onClick:i,disabled:r,children:l(`intake.read_button`)})]})]})}function et(){let[e,t]=V(null);return H(()=>{function e(){let e=We();if(!Ke(e)){t(null);return}let n=qe();if(!n){t(null);return}t({text:e,position:Je(n,window.innerWidth,window.innerHeight)})}function n(t){t.key!==`Escape`&&e()}function r(e){if(e.key===`Escape`){t(null);return}Ye(e)&&Ge()&&(e.preventDefault(),Xe(We()),t(null))}return document.addEventListener(`mouseup`,e),document.addEventListener(`keyup`,n),document.addEventListener(`keydown`,r),window.addEventListener(`scroll`,e,{passive:!0,capture:!0}),window.addEventListener(`resize`,e),()=>{document.removeEventListener(`mouseup`,e),document.removeEventListener(`keyup`,n),document.removeEventListener(`keydown`,r),window.removeEventListener(`scroll`,e,{capture:!0}),window.removeEventListener(`resize`,e)}},[]),e?K(`button`,{type:`button`,class:`read-chip`,style:{left:`${e.position.left}px`,top:`${e.position.top}px`},"aria-label":l(`panel.read_chip`),onMouseDown:e=>e.preventDefault(),onClick:()=>{Xe(e.text),t(null)},children:l(`panel.read_chip`)}):null}var tt={idle:{start:`loading`,stop:`idle`},loading:{loaded:`running`,fail:`failed`,stop:`idle`},running:{finish:`done`,fail:`failed`,stop:`idle`},done:{start:`loading`,stop:`idle`},failed:{start:`loading`,stop:`idle`}},nt={idle:{audio:`playing`,stop:`stopped`,reset:`idle`},playing:{audio:`playing`,pause:`paused`,stop:`stopped`,drain:`idle`,reset:`idle`},paused:{resume:`playing`,stop:`stopped`,drain:`idle`,reset:`idle`},stopped:{audio:`playing`,stop:`stopped`,reset:`idle`}};function q(e,t){return tt[e][t]??e}function J(e,t){return nt[e][t]??e}function rt(e,t){return e===`loading`||e===`running`||t===`playing`||t===`paused`}var it=i.levels.map(e=>e.id),at=i.default??`short`,ot=`fruitbat.speakMessages`,st=[`notice.dial_shorter`,`notice.dial_longer`,`notice.stopped`,`notice.all_cut`,`notice.oneline_failed`,`notice.input_limit`,`notice.done`];function ct(e){try{return localStorage.getItem(e)}catch{return null}}function lt(e,t){try{localStorage.setItem(e,t)}catch{}}var ut=class{voice;llm;gen=`idle`;play=`idle`;level=at;speakMessages;bullets=[];allCut=[];notices=[];lastNotice=null;current=null;error=null;progress=null;voiceProgress=null;runId=0;text=``;chunks=null;voiceReady=!1;listeners=new Set;runs=0;last=null;ttfa=null;runT0=0;stopMs=null;noticeLatency=null;spoken=[];genStats=null;voiceRun=null;constructor(e=u(),t=new c(s())){this.voice=e,this.llm=t,this.speakMessages=ct(ot)!==`off`,t.onNotice=e=>this.onLlmNotice(e);let n=new Map,r=new Map,i=e=>{let t=0,n=0;for(let r of e.values())t+=r.loaded,n+=r.total;return{loaded:t,total:n}};t.onProgress=e=>{e.file&&n.set(e.file,{loaded:e.loaded??0,total:e.total??0}),this.progress={file:e.file,...i(n)},this.emit()},e.onProgress((e,t,n)=>{r.set(e,{loaded:t,total:n}),this.voiceProgress={file:e,...i(r)},this.emit()}),typeof Worker<`u`&&!a()&&!o()&&this.warmVoice()}markVoiceReady(){if(!this.voiceReady){this.voiceReady=!0,this.emit();for(let e of this.pendingNotices.splice(0))this.notice(e)}}finishPrewarm(){this.voiceReady&&!this.voice.prewarmed&&this.voice.prewarm(st).catch(()=>void 0)}async warmVoice(){try{await this.voice.load(),this.markVoiceReady(),await this.voice.prewarm(st)}catch(e){this.error=e instanceof Error?`${e.name}: ${e.message}`:String(e),this.notice(`error.voice`)}this.emit()}subscribe(e){return this.listeners.add(e),e(this.snapshot()),()=>this.listeners.delete(e)}snapshot(){let e=this.voice.state();return{gen:this.gen,play:this.play,level:this.level,runId:this.runId,settledRunId:this.settledRunId,bullets:[...this.bullets],current:this.current,allCut:[...this.allCut],notices:[...this.notices],lastNotice:this.lastNotice,chunks:this.chunks?.length??0,voiceReady:this.voiceReady,prewarmed:this.voice.prewarmed,speakMessages:this.speakMessages,progress:this.progress,voiceProgress:this.voiceProgress,error:this.error,voice:{aheadSeconds:e.aheadSeconds,enqueued:e.enqueued,inFlight:e.inFlight,ended:e.ended,pending:e.pending,phase:e.phase}}}emit(){let e=this.snapshot();for(let t of this.listeners)t(e)}stats(){return{runs:this.runs,last:this.last,ttfa_ms:this.ttfa===null?null:Math.round(this.ttfa),stop_ms:this.stopMs===null?null:Math.round(this.stopMs*100)/100,notice_latency_ms:this.noticeLatency,notices_spoken:[...this.spoken],gen:this.genStats??((this.last?.level??this.level)===`readall`?null:this.llm.stats()),voice:this.voice.stats(),voice_run:this.voiceRun}}setSpeakMessages(e){this.speakMessages=e,lt(ot,e?`on`:`off`),this.emit()}onLlmNotice(e){e.key!==`notice.stopped`&&(e.key===`notice.all_cut`&&e.chunkIndex!==void 0&&!this.allCut.includes(e.chunkIndex)&&this.allCut.push(e.chunkIndex),this.notice(e.key))}pendingNotices=[];notice(e,t){if(this.notices.push(e),this.lastNotice=e,this.emit(),this.speakMessages){if(!this.voiceReady){this.pendingNotices.push(e);return}this.spoken.push(e),this.voice.speak(e,t).then(()=>{t!==void 0&&(this.noticeLatency=this.voice.lastNoticeLatencyMs,this.emit())}).catch(()=>{})}}runAbort=null;newRun(){let e=++this.runId;return this.pendingNotices=[],this.runAbort?.abort(),this.runAbort=new AbortController,this.llm.abort(),this.stopMs=this.voice.stop(),this.gen=q(this.gen,`stop`),this.play=J(this.play,`stop`),e}run(e,t){this.voice.ensureContext(),this.runs++,this.last={level:t,chars:e.length},this.text=e,this.level=t,this.chunks=null,this.notices=[],this.lastNotice=null,this.regenFrom=null;let n=this.newRun();return this.begin(n,t,{fromChunk:0,base:0,end:e.length})}silenceVoice(){this.voice.stop()}stop(e={}){let t=rt(this.gen,this.play)&&!e.quiet;return this.newRun(),this.current=null,this.progress=null,this.emit(),t&&this.notice(`notice.stopped`),this.stopMs??0}pause(){this.play===`playing`&&(this.voice.pause(),this.play=J(this.play,`pause`),this.emit())}resume(){this.play===`paused`&&(this.voice.resume(),this.play=J(this.play,`resume`),this.emit())}skip(){return this.voice.skip()}async setLevel(e){let t=performance.now(),n=this.level;if(e===n)return;if(this.level=e,!this.busy()||!this.text){this.emit();return}let r=it.indexOf(e)>it.indexOf(n),i=this.newRun();this.notice(r?`notice.dial_shorter`:`notice.dial_longer`,t),this.regenPending=i;let a=await this.currentChunkIndex();if(this.regenPending===i&&(this.regenPending=null),i!==this.runId)return;this.regenFrom=a;let o=this.chunks?.[a];await this.begin(i,e,{fromChunk:a,base:o?.start??0,end:this.text.length})}regenPending=null;busy(){if(this.regenPending===this.runId||rt(this.gen,this.play))return!0;if(this.play===`stopped`)return!1;let e=this.voice.state();return e.pending>0||e.inFlight>0||e.enqueued>e.ended}async readThisPart(e){let t=this.newRun(),n=await this.ensureChunks();if(t!==this.runId)return;let r=n?.[e];r&&await this.begin(t,`readall`,{fromChunk:e,base:r.start,end:r.end,keep:!0})}async ensureChunks(){if(this.chunks)return this.chunks;if(!this.text)return null;let e=this.text,t=null;try{t=await this.llm.chunk(e)}catch{t=null}return e===this.text?(this.chunks=t,this.chunks):null}async currentChunkIndex(){let e=this.current;if(e?.kind===`bullet`)return e.chunkIndex;let t=await this.ensureChunks();if(!t)return 0;if(e?.kind===`sentence`){let n=t.findIndex(t=>e.start>=t.start&&e.start<t.end);return n>=0?n:0}return this.heardChunk===null?this.regenFrom??0:this.heardChunk}heardChunk=null;regenFrom=null;async begin(e,t,n){this.last={level:t,chars:n.end-n.base},typeof window<`u`&&window.dispatchEvent(new CustomEvent(`fruitbat:live`)),this.play=J(this.play,`reset`),n.keep||(this.bullets=[],this.allCut=[],this.heardChunk=null),this.current=null,this.error=null,this.ttfa=null,this.runT0=performance.now(),this.voiceRun=null,this.genStats=null,this.gen=q(this.gen,`start`),this.emit();try{t===`readall`?await this.readAloud(e,n.base,n.end):await this.summarize(e,t,n.fromChunk)}catch(t){if(e!==this.runId)return;this.gen=q(this.gen,`fail`),this.error=t instanceof Error?`${t.name}: ${t.message}`:String(t),this.notice(`error.generation`)}e===this.runId&&(this.settledRunId=e),this.emit()}settledRunId=0;markAudio(){this.ttfa===null&&(this.ttfa=performance.now()-this.runT0),this.play=J(this.play,`audio`)}async readAloud(e,t,n){let r=this.text.slice(t,n),i=[];if(await this.voice.load(),e!==this.runId)return;this.markVoiceReady(),this.gen=q(this.gen,`loaded`),this.emit();let a=await this.voice.readAll(r,{onPlanned:e=>{i=e},onStart:n=>{e===this.runId&&(this.markAudio(),this.current={kind:`sentence`,start:t+n.start,end:t+n.end,text:r.slice(n.start,n.end),next:i[n.seq+1]?.text??null},this.emit())}});if(e===this.runId){if(this.voice.phase===`failed`){this.gen=q(this.gen,`fail`),this.error=this.voice.error,this.play=J(this.play,`stop`),this.current=null,this.notice(`error.voice`);return}this.gen=q(this.gen,`finish`),this.voiceRun=this.voice.metrics(a.seconds),a.finished&&(this.play=J(this.play,`drain`),this.current=null,this.notice(`notice.done`),this.finishPrewarm())}}async summarize(e,t,n){this.voice.load().then(()=>{this.markVoiceReady(),this.voice.prewarm(st).catch(()=>void 0)},()=>void 0);let r=this.voice.beginStream({onStart:t=>{if(e!==this.runId)return;this.markAudio();let n=t.tag===void 0?void 0:this.bullets[t.tag];n&&(this.current={kind:`bullet`,chunkIndex:n.chunkIndex,index:t.tag},this.heardChunk=n.chunkIndex),this.emit()}}),i=this.runAbort?.signal,a=await this.llm.ensureLoaded({signal:i});if(!a&&e===this.runId&&this.llm.error===`aborted`&&(a=await this.llm.ensureLoaded({signal:i})),e!==this.runId)return;if(!a){this.gen=q(this.gen,`fail`),this.error=this.llm.error,this.llm.gpu?.ok===!1&&!this.notices.includes(`notice.no_webgpu`)&&this.notice(`notice.no_webgpu`),this.voice.endStream(r),this.play=J(this.play,`reset`);return}if(this.gen=q(this.gen,`loaded`),this.emit(),await this.ensureChunks(),e!==this.runId)return;let o=await this.llm.summarize(this.text,t,{signal:this.runAbort?.signal,fromChunk:n,onBullet:t=>{if(e!==this.runId)return;let n=this.bullets.push(t)-1;this.emit(),this.voice.pushText(r,t.text,t.start,t.end,n)}});if(e!==this.runId)return;this.genStats=o,this.llm.state===`failed`?(this.gen=q(this.gen,`fail`),this.error=this.llm.error):this.gen=q(this.gen,`finish`),this.emit();let{finished:s,metrics:c}=await this.voice.endStream(r);e===this.runId&&(this.voiceRun=c,s||(this.play=J(this.play,`stop`),this.current=null),!s&&this.gen===`done`&&(this.error=this.error??`voice_failed`,this.notice(`error.voice`)),s&&(this.play=J(this.play,`drain`),this.current=null,this.gen===`done`&&this.bullets.length>0&&this.notice(`notice.done`),this.finishPrewarm()))}},dt=null;function Y(){return dt||=new ut,dt}function ft(e,t){for(let n=0;n<e.length;n++){let r=e[n],i=t>=r.audioStart,a=t<r.audioEnd;if(i&&a)return n}let n=e[e.length-1];return n&&t>=n.audioEnd?e.length-1:-1}function pt(){let[t,n]=V(ze),[r,i]=V({});return H(()=>Ve(n),[]),H(()=>{if(r[t])return;let n=!1;return e(`/demo/${t}.json`).then(e=>e.json()).then(e=>{n||i(n=>({...n,[t]:e}))}).catch(()=>{}),()=>{n=!0}},[t,r]),{track:r[t]??null,level:t}}function mt(){let{track:e,level:t}=pt(),[n,r]=V(!1),[i,a]=V(-1),o=Ae(null);return H(()=>{let t=o.current;if(!t||!e)return;let i=n;t.load(),a(-1),i&&t.play().catch(()=>r(!1))},[e?.level]),H(()=>{let e=()=>{let e=o.current;e&&!e.paused&&e.pause(),r(!1)},t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`fruitbat:stop`,e),window.addEventListener(`fruitbat:run`,e),window.addEventListener(`fruitbat:live`,e),document.addEventListener(`keydown`,t),()=>{window.removeEventListener(`fruitbat:stop`,e),window.removeEventListener(`fruitbat:run`,e),window.removeEventListener(`fruitbat:live`,e),document.removeEventListener(`keydown`,t)}},[]),K(`section`,{class:`demo`,"data-testid":`demo`,"data-level":t,children:[K(`p`,{class:`demo-recording-label`,children:l(`demo.recording_label`)}),K(`p`,{class:`demo-excerpt-note`,children:l(`demo.excerpt_note`)}),K(`button`,{type:`button`,class:`demo-try-it-now`,"data-testid":`demo-try`,onClick:()=>{let e=o.current;e&&(window.dispatchEvent(new CustomEvent(`fruitbat:demo`)),e.play().catch(()=>r(!1)))},disabled:!e,children:l(`demo.try_it_now`)}),K(`p`,{class:`demo-switch-level`,children:l(`demo.switch_level`)}),e&&K(`audio`,{ref:o,"data-testid":`demo-audio`,preload:`auto`,src:`/demo/${e.level}.wav`,onPlay:()=>r(!0),onPause:()=>r(!1),onEnded:()=>r(!1),onTimeUpdate:()=>{let t=o.current;t&&e&&a(ft(e.items,t.currentTime))}}),e&&K(`ul`,{class:`demo-items`,"data-testid":`demo-bullets`,"aria-label":l(`a11y.bullet_list`),children:e.items.map((e,t)=>K(`li`,{"aria-current":t===i?`true`:void 0,children:e.text},t))})]})}async function ht(e){if(typeof caches>`u`)return!1;try{return!!await caches.match(e)}catch{return!1}}function gt(e){let t=[...e.files].sort((e,t)=>t.bytes-e.bytes)[0];return t?ht(r(e,t.path)):Promise.resolve(!1)}function X(e){return Math.round((e??0)/1e6)}function _t(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,String(n)),e)}function vt({testId:e,loaded:t,total:n}){let r=n>0?Math.min(100,Math.round(t/n*100)):void 0;return r===void 0?K(`progress`,{"data-testid":e,class:`loading-bar`}):K(`progress`,{"data-testid":e,class:`loading-bar`,max:100,value:r,"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100})}function yt(e){let[t,n]=V(`unknown`);return H(()=>{if(!e)return;let t=!1;return gt(e).then(e=>{t||n(e?`cached`:`first_time`)}),()=>{t=!0}},[e?.id,e?.revision]),t}function bt({state:e}){return e===`unknown`?null:K(`p`,{class:`loading-cache`,children:l(e===`cached`?`loading.cached`:`loading.first_time`)})}function xt(){let[e,t]=V(()=>Y().snapshot());return H(()=>Y().subscribe(t),[]),e}function St({s:e}){let t=Y().llm,[n,r]=V(`idle`),i=yt(t.tier()),a=t.isLoaded(),o=!a&&(n===`failed`||t.state===`failed`||t.state===`stopped`),s=a||!o&&(n!==`idle`||e.progress!==null||t.state===`loading`),c=a||n===`ready`,u=X(e.progress?.loaded),d=Math.max(X(e.progress?.total),s?t.sizeMb():0);return K(`div`,{class:`loading-summarizer`,"data-started":s,children:[K(`p`,{class:`loading-line`,children:l(`loading.summarizer_size`).replace(`{mb}`,String(t.sizeMb()))}),!s&&K(`button`,{type:`button`,class:`loading-summarizer-button`,"data-testid":`summarizer-load`,onClick:()=>{s||(r(`loading`),t.ensureLoaded().then(e=>r(e?`ready`:`failed`)))},children:l(`loading.summarizer_button`).replace(`{mb}`,String(t.sizeMb()))}),s&&K(M,{children:[K(vt,{testId:`summarizer-progress`,loaded:c?1:u,total:c?1:d}),K(`p`,{class:`loading-line`,children:_t(l(`loading.progress`),{mb:u})}),K(bt,{state:i})]}),e.notices.filter((t,n)=>(t===`notice.no_webgpu`||t===`notice.probe_failed`||t===`notice.low_end_tier`)&&e.notices.indexOf(t)===n).map(e=>K(`p`,{class:`loading-notice`,role:`status`,"data-notice":e,children:l(e)},e))]})}function Ct({s:e}){let t=n().web.voice,r=yt(t);if(a())return K(`p`,{class:`loading-line`,"data-phase":`save_data`,children:l(`loading.save_data`)});if(o())return K(`p`,{class:`loading-line`,"data-phase":`mobile`,children:l(`loading.mobile`)});if(e.voiceReady)return K(`p`,{class:`loading-line`,"data-phase":`ready`,children:l(`loading.ready`)});if(e.voiceProgress){let n=X(e.voiceProgress.loaded),i=Math.max(X(e.voiceProgress.total),Math.round(t.files.reduce((e,t)=>e+t.bytes,0)/1e6));return K(`div`,{class:`loading-voice`,"data-phase":`voice`,children:[K(`p`,{class:`loading-line`,children:l(`loading.voice`)}),K(vt,{testId:`voice-progress`,loaded:n,total:i}),K(`p`,{class:`loading-line`,children:_t(l(`loading.progress`),{mb:n})}),K(bt,{state:r})]})}return K(`p`,{class:`loading-line`,"data-phase":`probing`,children:l(`loading.probing`)})}function wt(){let e=xt();return K(`section`,{class:`loading`,"data-testid":`loading`,children:[K(Ct,{s:e}),K(St,{s:e})]})}var Z={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`run-stats.schema.json`,title:`RunStats`,$comment:"One bench measurement (docs/PLAN.md rule 3, C11, S0-05). Numbers, enums, and validated metadata only — no free-text field. Metrics are nullable when a dial level doesn't produce them (readall has no LLM metrics; only readall has `coverage`). Bench identity = target, model_id, model_rev, dtype, device, browser(+major), os(+major), machine_id, cache_state, doc_id, level (bench/identity.md). Field order here is the fixed column order of bench/results.csv.",type:`object`,additionalProperties:!1,$defs:{level:{type:`string`,enum:[`readall`,`short`,`caveman`,`oneline`]},device:{type:`string`,enum:[`webgpu`,`wasm`,`mlx`]},model_id:{type:`string`,$comment:`Closed set sourced from spec/models.json. Add a value here (small PR) whenever a new model_id is pinned there.`,enum:[`onnx-community/Qwen3.5-0.8B-Text-ONNX`,`onnx-community/Qwen2.5-0.5B-Instruct`,`onnx-community/Qwen3-0.6B-ONNX`,`HuggingFaceTB/SmolLM2-360M-Instruct`,`onnx-community/Kokoro-82M-v1.0-ONNX`,`mlx-community/Qwen3.5-2B-4bit`,`mlx-community/Qwen3-1.7B-4bit`,`mlx-community/Kokoro-82M-bf16`]}},required:`schema_version.target.device.level.browser.browser_major.os.os_major.cache_state.model_id.model_rev.dtype.doc_id.commit.date.machine_id.ttfa_ms.gen_ms.tok_s.rtf.gap_ms.stop_ms.coverage.bullets_total.bullets_cut.cut_rate.facts_token_hit.halluc_flags.forbidden_hits.oneline_keyword_hit.tts_overlimit.peak_mb.heap_mb`.split(`.`),properties:{schema_version:{type:`integer`,enum:[1]},target:{type:`string`,enum:[`web`,`mac`]},device:{$ref:`#/$defs/device`},level:{$ref:`#/$defs/level`},browser:{type:`string`,enum:[`chrome`,`safari`,`firefox`,`none`]},browser_major:{type:[`integer`,`null`],minimum:0},os:{type:`string`,enum:[`macos`,`windows`,`linux`,`ios`,`android`]},os_major:{type:`integer`,minimum:0},cache_state:{type:`string`,enum:[`cold`,`warm`]},model_id:{$ref:`#/$defs/model_id`},model_rev:{type:`string`,pattern:`^[0-9a-f]{40}$`},dtype:{type:`string`,enum:[`q4f16`,`q8`,`q8f16`,`q4`,`fp32`,`bf16`,`fp16`,`4bit`,`8bit`],$comment:`q8f16: the WebGPU voice variant (?tts=webgpu, spec/models.json).`},doc_id:{type:`string`,pattern:`^([0-9]{3}|paste)$`,$comment:`S1-10: bench rows use the 3-digit eval corpus id; every other row (real usage, not the corpus) is 'paste' unless window.__fruitbat.setDocId(id) overrides it.`},commit:{type:`string`,pattern:`^[0-9a-f]{7,40}$`},date:{type:`string`,pattern:`^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})?)?$`},machine_id:{type:`string`,pattern:`^(web|[0-9a-f]{12})$`},ttfa_ms:{type:[`number`,`null`],minimum:0},gen_ms:{type:[`number`,`null`],minimum:0},tok_s:{type:[`number`,`null`],minimum:0},rtf:{type:[`number`,`null`],minimum:0},gap_ms:{type:[`number`,`null`],minimum:0},stop_ms:{type:[`number`,`null`],minimum:0},coverage:{type:[`number`,`null`],minimum:0,maximum:1},bullets_total:{type:[`integer`,`null`],minimum:0},bullets_cut:{type:[`integer`,`null`],minimum:0},cut_rate:{type:[`number`,`null`],minimum:0,maximum:1},facts_token_hit:{type:[`number`,`null`],minimum:0,maximum:1},halluc_flags:{type:[`integer`,`null`],minimum:0},forbidden_hits:{type:[`integer`,`null`],minimum:0},oneline_keyword_hit:{type:[`number`,`null`],minimum:0,maximum:1},tts_overlimit:{type:[`integer`,`null`],minimum:0},peak_mb:{type:[`number`,`null`],minimum:0},heap_mb:{type:[`number`,`null`],minimum:0}}},Tt=Object.freeze([...Z.required??[]]);function Et(e){let t=/^#\/\$defs\/(.+)$/.exec(e);if(!t)throw Error(`stats/schema: unsupported $ref "${e}"`);let n=Z.$defs?.[t[1]];if(!n)throw Error(`stats/schema: unknown $defs entry "${t[1]}"`);return n}function Dt(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e==`number`?Number.isInteger(e)?`integer`:`number`:typeof e==`string`?`string`:typeof e==`boolean`?`boolean`:`object`}function Ot(e,t){let n=Dt(e);return t===`number`?n===`number`||n===`integer`:n===t}function kt(e,t,n,r){let i=n.$ref?Et(n.$ref):n;if(i.type!==void 0&&!(Array.isArray(i.type)?i.type:[i.type]).some(e=>Ot(t,e))){r.push(`${e}: expected type ${JSON.stringify(i.type)}, got ${Dt(t)} (${JSON.stringify(t)})`);return}t!==null&&(i.enum!==void 0&&!i.enum.includes(t)&&r.push(`${e}: ${JSON.stringify(t)} is not one of ${JSON.stringify(i.enum)}`),i.pattern!==void 0&&typeof t==`string`&&!new RegExp(i.pattern).test(t)&&r.push(`${e}: ${JSON.stringify(t)} does not match pattern ${i.pattern}`),i.minimum!==void 0&&typeof t==`number`&&t<i.minimum&&r.push(`${e}: ${t} is below minimum ${i.minimum}`),i.maximum!==void 0&&typeof t==`number`&&t>i.maximum&&r.push(`${e}: ${t} is above maximum ${i.maximum}`))}function At(e){let t=[];if(typeof e!=`object`||!e||Array.isArray(e))return{ok:!1,errors:[`row is not a plain object`]};let n=e,r=Z.properties??{};for(let e of Z.required??[])e in n||t.push(`missing required field: ${e}`);if(Z.additionalProperties===!1)for(let e of Object.keys(n))e in r||t.push(`unknown field: ${e}`);for(let[e,i]of Object.entries(r))e in n&&kt(e,n[e],i,t);return{ok:t.length===0,errors:t}}var jt=`fruitbat.stats`,Mt=`fruitbat.stats.errors`,Nt=`paste`;function Pt(e){Nt=e}function Ft(){return Nt}function Q(e,t){let n=e.exec(t);return n?Number(n[1]):null}function It(e=typeof navigator<`u`?navigator.userAgent:``){let t=`none`,n=null;/Firefox\//.test(e)?(t=`firefox`,n=Q(/Firefox\/(\d+)/,e)):/Chrome\//.test(e)&&!/Edg\//.test(e)?(t=`chrome`,n=Q(/Chrome\/(\d+)/,e)):/Safari\//.test(e)&&/Version\//.test(e)&&(t=`safari`,n=Q(/Version\/(\d+)/,e));let r=`linux`,i=0;return/iPhone|iPad/.test(e)?(r=`ios`,i=Q(/OS (\d+)_/,e)??0):/Android/.test(e)?(r=`android`,i=Q(/Android (\d+)/,e)??0):/Mac OS X/.test(e)?(r=`macos`,i=Q(/Mac OS X (\d+)/,e)??0):/Windows NT/.test(e)&&(r=`windows`,i=Q(/Windows NT (\d+)/,e)??0),{browser:t,browser_major:n,os:r,os_major:i}}function Lt(){return`e8e1e40`}function Rt(){let e=It(),t=typeof performance<`u`?performance.memory:void 0,n=t?Math.round(t.usedJSHeapSize/1e6*10)/10:null;return{...e,machine_id:`web`,commit:Lt(),date:new Date().toISOString(),doc_id:Ft(),heap_mb:n}}function zt(e,r){let i=e.last?.level??`short`,a=i===`readall`?e.voice:null,o=e.gen,s=e.voice_run,c,l,u,d;if(i===`readall`){let e=n().web.voice;c=e.id,l=e.revision,u=s?s.dtype:a?.dtype??e.dtype,d=s?s.device:a?.device??e.device}else{let e=t(),n=e.find(e=>e.id===o?.model_id)??e[0];c=n.id,l=n.revision,u=n.dtype,d=n.device}let f=(s?s.cache_state:a?.cache_state)===`cold`,p=i!==`readall`&&o?.cache_cold===!0,m=f||p?`cold`:`warm`,h=o?.bullets_total??null,g=o?.bullets_cut??null,_=h===null?null:h>0?(g??0)/h:0;return{schema_version:1,target:`web`,device:d,level:i,browser:r.browser,browser_major:r.browser_major,os:r.os,os_major:r.os_major,cache_state:m,model_id:c,model_rev:l,dtype:u,doc_id:r.doc_id,commit:r.commit,date:r.date,machine_id:r.machine_id,ttfa_ms:e.ttfa_ms,gen_ms:o?.gen_ms??null,tok_s:o?.tok_s??null,rtf:s?s.rtf:a?.rtf??null,gap_ms:s?s.gap_ms:a?.gap_ms??null,stop_ms:null,coverage:i===`readall`?a?.coverage??null:null,bullets_total:h,bullets_cut:g,cut_rate:_,facts_token_hit:null,halluc_flags:null,forbidden_hits:null,oneline_keyword_hit:null,tts_overlimit:s?s.tts_overlimit:a?.tts_overlimit??0,peak_mb:null,heap_mb:r.heap_mb??null}}function Bt(){try{let e=localStorage.getItem(jt);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function Vt(){try{let e=Number(localStorage.getItem(`fruitbat.stats.errors`))||0;localStorage.setItem(Mt,String(e+1))}catch{}}function Ht(){return Bt()}function Ut(){try{localStorage.removeItem(jt),localStorage.removeItem(Mt)}catch{}}function Wt(e){try{let t=Bt();for(t.push(e);t.length>200;)t.shift();localStorage.setItem(jt,JSON.stringify(t))}catch{Vt()}}function Gt(e,t=Rt()){let n=zt(e,t),{ok:r,errors:i}=At(n);return r&&Wt(n),{ok:r,errors:i,row:n}}function Kt(e){if(e==null)return``;let t=String(e);return/[",\n]/.test(t)?`"${t.replace(/"/g,`""`)}"`:t}function qt(){let e=[Tt.join(`,`)];for(let t of Bt()){let n=t;e.push(Tt.map(e=>Kt(n[e])).join(`,`))}return e.join(`
2
  `)+`
3
  `}var Jt=[`date`,`level`,`device`,`dtype`,`cache_state`,`doc_id`,`ttfa_ms`,`tok_s`,`rtf`,`bullets_total`,`bullets_cut`],Yt={date:`stats.col.date`,level:`stats.col.level`,device:`stats.col.device`,dtype:`stats.col.dtype`,cache_state:`stats.col.cache_state`,doc_id:`stats.col.doc_id`,ttfa_ms:`stats.col.ttfa_ms`,tok_s:`stats.col.tok_s`,rtf:`stats.col.rtf`,bullets_total:`stats.col.bullets_total`,bullets_cut:`stats.col.bullets_cut`};function Xt(e){let t=new Blob([e],{type:`text/csv`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`fruitbat-stats.csv`,r.click(),URL.revokeObjectURL(n)}function Zt({onClose:e}){let[t,n]=V(()=>Ht()),r=Ae(null);return H(()=>{r.current?.scrollIntoView({block:`start`}),r.current?.focus()},[]),K(`div`,{class:`stats-view`,role:`dialog`,"aria-label":l(`stats.title`),ref:r,tabIndex:-1,children:[K(`div`,{class:`stats-view-header`,children:[K(`h2`,{children:l(`stats.title`)}),K(`button`,{type:`button`,class:`stats-close`,onClick:e,children:l(`panel.close`)})]}),t.length===0?K(`p`,{class:`stats-empty`,children:l(`stats.empty`)}):K(`table`,{class:`stats-table`,children:[K(`thead`,{children:K(`tr`,{children:Jt.map(e=>K(`th`,{children:l(Yt[e])},e))})}),K(`tbody`,{children:t.map((e,t)=>K(`tr`,{children:Jt.map(t=>K(`td`,{children:e[t]===null?``:String(e[t])},t))},t))})]}),K(`div`,{class:`stats-actions`,children:[K(`button`,{type:`button`,onClick:()=>Xt(qt()),children:l(`stats.export`)}),K(`button`,{type:`button`,onClick:()=>{Ut(),n(Ht())},children:l(`stats.clear`)})]})]})}var Qt=i.levels,$t=i.default??`short`;function en({level:e,onChange:t}){return K(`fieldset`,{class:`dial`,children:[K(`legend`,{class:`visually-hidden`,children:l(`a11y.dial`)}),Qt.map(n=>K(`label`,{class:`dial-option`,children:[K(`input`,{type:`radio`,name:`level`,value:n.id,checked:e===n.id,onChange:()=>t(n.id)}),K(`span`,{children:l(n.label_key)})]},n.id))]})}function tn(){if(typeof document<`u`){let e=document.documentElement.getAttribute(`data-theme`);if(e===`dark`||e===`light`)return e}return typeof matchMedia<`u`&&matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function nn(){let[e,t]=V(tn);return K(`button`,{type:`button`,class:`theme-toggle`,onClick:()=>{let n=e===`dark`?`light`:`dark`;t(n),document.documentElement.setAttribute(`data-theme`,n);try{localStorage.setItem(`fruitbat-theme`,n)}catch{}},"aria-pressed":e===`dark`,children:l(`theme.toggle`)})}function rn({paragraphs:e}){return K(`article`,{class:`article`,"aria-label":l(`intake.sample_label`),children:e.map((e,t)=>K(`p`,{children:e},t))})}function an(){let[t,n]=V([]);return H(()=>{let t=!1;return e(`/sample.txt`).then(e=>e.text()).then(e=>{t||n(e.split(/\n{2,}/).map(e=>e.trim()).filter(Boolean))}).catch(()=>{t||n([])}),()=>{t=!0}},[]),t}function on(){let[e,t]=V(()=>Y().snapshot());return H(()=>Y().subscribe(t),[]),e}function sn(){let e=on(),t=e.current,n=e.bullets.length===0&&!t&&e.allCut.length===0&&!e.lastNotice;return K(`aside`,{id:`panel`,class:`panel`,"aria-label":l(`a11y.panel_region`),"data-gen":e.gen,"data-play":e.play,children:[n&&K(`p`,{class:`panel-empty`,children:l(`panel.empty`)}),t?.kind===`sentence`&&K(`div`,{class:`now-reading`,children:[K(`p`,{class:`now-label`,children:l(`panel.now_reading`)}),K(`p`,{class:`now-text`,"data-testid":`now-text`,children:t.text}),t.next&&K(`p`,{class:`next-text`,children:[K(`span`,{class:`next-label`,children:l(`panel.next_up`)}),` `,t.next]})]}),e.bullets.length>0&&K(`ul`,{class:`bullets`,"aria-label":l(`a11y.bullet_list`),children:e.bullets.map((e,n)=>K(`li`,{"data-chunk":e.chunkIndex,"aria-current":t?.kind===`bullet`&&t.index===n?`true`:void 0,children:e.text},n))}),e.allCut.map(e=>K(`p`,{class:`read-part-row`,children:K(`button`,{type:`button`,class:`read-part`,"data-chunk":e,onClick:()=>void Y().readThisPart(e),children:l(`panel.read_this_part`)})},e)),e.lastNotice&&K(`p`,{class:`panel-notice`,role:`status`,"aria-live":`polite`,"data-notice":e.lastNotice,children:l(e.lastNotice)})]})}function cn(){let[e,t]=V($t),[n,r]=V(!1),i=an();return H(()=>{document.title=l(`app.title`)},[]),H(()=>{Be(e)},[e]),K(`div`,{class:`app-shell`,children:[K(`header`,{class:`app-header`,children:[K(`h1`,{class:`app-title`,children:l(`app.title`)}),K(en,{level:e,onChange:e=>{Be(e),t(e)}}),K(`button`,{type:`button`,class:`stats-toggle`,onClick:()=>r(!0),children:l(`panel.stats`)}),K(nn,{})]}),K(wt,{}),K(`main`,{class:`app-main`,children:[K(mt,{}),K(rn,{paragraphs:i}),K($e,{})]}),K(sn,{}),K(et,{}),n&&K(Zt,{onClose:()=>r(!1)})]})}function ln(){try{let e=localStorage.getItem(`fruitbat-theme`);(e===`dark`||e===`light`)&&document.documentElement.setAttribute(`data-theme`,e)}catch{}}var $=Y();window.__fruitbat={run(e,t){window.dispatchEvent(new CustomEvent(`fruitbat:run`,{detail:{text:e,level:t}}))},stop(){window.dispatchEvent(new CustomEvent(`fruitbat:stop`))},stats(){return $.stats()},state:()=>$.snapshot(),setLevel:e=>$.setLevel(e),readThisPart:e=>$.readThisPart(e),pause:()=>$.pause(),resume:()=>$.resume(),skip:()=>$.skip(),setSpeakMessages:e=>$.setSpeakMessages(e),rows:()=>Ht(),setDocId:e=>Pt(e)},window.addEventListener(`fruitbat:run`,e=>void $.run(e.detail.text,e.detail.level)),window.addEventListener(`fruitbat:stop`,()=>$.stop()),window.addEventListener(`fruitbat:demo`,()=>{let e=$.snapshot(),t=e.voice.pending>0||e.voice.inFlight>0||e.voice.enqueued>e.voice.ended;rt(e.gen,e.play)||t?$.stop({quiet:!0}):$.silenceVoice()});var un=0;$.subscribe(e=>{(e.gen===`done`||e.gen===`failed`)&&e.settledRunId===e.runId&&e.runId!==un&&(un=e.runId,Gt($.stats()))}),Ve(e=>void $.setLevel(e)),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&$.stop()}),ln();var dn=document.getElementById(`app`);dn&&ve(K(cn,{}),dn);
index.html CHANGED
@@ -9,7 +9,7 @@
9
  <!-- csp:end -->
10
  <!-- Cross-origin isolation on a static host: the service worker adds COOP/COEP (S1-00a). -->
11
  <script src="/coi-serviceworker.js"></script>
12
- <script type="module" crossorigin src="/assets/index-Cf81bvtQ.js"></script>
13
  <link rel="modulepreload" crossorigin href="/assets/pins-DVBrHC3g.js">
14
  <link rel="modulepreload" crossorigin href="/assets/loader-D0INP31U.js">
15
  <link rel="modulepreload" crossorigin href="/assets/llm-DH311QE0.js">
 
9
  <!-- csp:end -->
10
  <!-- Cross-origin isolation on a static host: the service worker adds COOP/COEP (S1-00a). -->
11
  <script src="/coi-serviceworker.js"></script>
12
+ <script type="module" crossorigin src="/assets/index-HoiRag-_.js"></script>
13
  <link rel="modulepreload" crossorigin href="/assets/pins-DVBrHC3g.js">
14
  <link rel="modulepreload" crossorigin href="/assets/loader-D0INP31U.js">
15
  <link rel="modulepreload" crossorigin href="/assets/llm-DH311QE0.js">