@huluvu424242/honey-webcomponents
Version:
Text to Speech component wich is reading texts from DOM elements.
1 lines • 8.18 kB
JavaScript
let e,t,n=!1,l=!1;const s="undefined"!=typeof window?window:{},o=s.document||{head:{}},c={t:0,l:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,t,n,l)=>e.addEventListener(t,n,l),rel:(e,t,n,l)=>e.removeEventListener(t,n,l),ce:(e,t)=>new CustomEvent(e,t)},r=e=>Promise.resolve(e),i=(()=>{try{return new CSSStyleSheet,!0}catch(e){}return!1})(),a=(e,t,n)=>{n&&n.map((([n,l,s])=>{const o=e,r=u(t,s),i=f(n);c.ael(o,l,r,i),(t.o=t.o||[]).push((()=>c.rel(o,l,r,i)))}))},u=(e,t)=>n=>{try{256&e.t?e.i[t](n):(e.u=e.u||[]).push([t,n])}catch(e){K(e)}},f=e=>0!=(2&e),h=new WeakMap,$=e=>"sc-"+e.h,d={},p=e=>"object"==(e=typeof e)||"function"===e,m=(e,t,...n)=>{let l=null,s=!1,o=!1,c=[];const r=t=>{for(let n=0;n<t.length;n++)l=t[n],Array.isArray(l)?r(l):null!=l&&"boolean"!=typeof l&&((s="function"!=typeof e&&!p(l))&&(l+=""),s&&o?c[c.length-1].$+=l:c.push(s?y(null,l):l),o=s)};if(r(n),t){const e=t.className||t.class;e&&(t.class="object"!=typeof e?e:Object.keys(e).filter((t=>e[t])).join(" "))}const i=y(e,null);return i.p=t,c.length>0&&(i.m=c),i},y=(e,t)=>({t:0,g:e,$:t,v:null,m:null,p:null}),w={},b=(e,t,n,l,s,o)=>{if(n!==l){let c=J(e,t);if(t.toLowerCase(),"class"===t){const t=e.classList,s=v(n),o=v(l);t.remove(...s.filter((e=>e&&!o.includes(e)))),t.add(...o.filter((e=>e&&!s.includes(e))))}else{const r=p(l);if((c||r&&null!==l)&&!s)try{if(e.tagName.includes("-"))e[t]=l;else{let s=null==l?"":l;"list"===t?c=!1:null!=n&&e[t]==s||(e[t]=s)}}catch(e){}null==l||!1===l?!1===l&&""!==e.getAttribute(t)||e.removeAttribute(t):(!c||4&o||s)&&!r&&e.setAttribute(t,l=!0===l?"":l)}}},g=/\s/,v=e=>e?e.split(g):[],j=(e,t,n,l)=>{const s=11===t.v.nodeType&&t.v.host?t.v.host:t.v,o=e&&e.p||d,c=t.p||d;for(l in o)l in c||b(s,l,o[l],void 0,n,t.t);for(l in c)b(s,l,o[l],c[l],n,t.t)},O=(t,l,s)=>{let c,r,i=l.m[s],a=0;if(null!==i.$)c=i.v=o.createTextNode(i.$);else{if(n||(n="svg"===i.g),c=i.v=o.createElementNS(n?"http://www.w3.org/2000/svg":"http://www.w3.org/1999/xhtml",i.g),n&&"foreignObject"===i.g&&(n=!1),j(null,i,n),null!=e&&c["s-si"]!==e&&c.classList.add(c["s-si"]=e),i.m)for(a=0;a<i.m.length;++a)r=O(t,i,a),r&&c.appendChild(r);"svg"===i.g?n=!1:"foreignObject"===c.tagName&&(n=!0)}return c},S=(e,n,l,s,o,c)=>{let r,i=e;for(i.shadowRoot&&i.tagName===t&&(i=i.shadowRoot);o<=c;++o)s[o]&&(r=O(null,l,o),r&&(s[o].v=r,i.insertBefore(r,n)))},M=(e,t,n,l)=>{for(;t<=n;++t)(l=e[t])&&l.v.remove()},k=(e,t)=>e.g===t.g,C=(e,t)=>{const l=t.v=e.v,s=e.m,o=t.m,c=t.g,r=t.$;null===r?(n="svg"===c||"foreignObject"!==c&&n,j(e,t,n),null!==s&&null!==o?((e,t,n,l)=>{let s,o=0,c=0,r=t.length-1,i=t[0],a=t[r],u=l.length-1,f=l[0],h=l[u];for(;o<=r&&c<=u;)null==i?i=t[++o]:null==a?a=t[--r]:null==f?f=l[++c]:null==h?h=l[--u]:k(i,f)?(C(i,f),i=t[++o],f=l[++c]):k(a,h)?(C(a,h),a=t[--r],h=l[--u]):k(i,h)?(C(i,h),e.insertBefore(i.v,a.v.nextSibling),i=t[++o],h=l[--u]):k(a,f)?(C(a,f),e.insertBefore(a.v,i.v),a=t[--r],f=l[++c]):(s=O(t&&t[c],n,c),f=l[++c],s&&i.v.parentNode.insertBefore(s,i.v));o>r?S(e,null==l[u+1]?null:l[u+1].v,n,l,c,u):c>u&&M(t,o,r)})(l,s,t,o):null!==o?(null!==e.$&&(l.textContent=""),S(l,null,t,o,0,o.length-1)):null!==s&&M(s,0,s.length-1),n&&"svg"===c&&(n=!1)):e.$!==r&&(l.data=r)},P=e=>D(e).j,x=(e,t,n)=>{const l=P(e);return{emit:e=>E(l,t,{bubbles:!!(4&n),composed:!!(2&n),cancelable:!!(1&n),detail:e})}},E=(e,t,n)=>{const l=c.ce(t,n);return e.dispatchEvent(l),l},L=(e,t)=>{t&&!e.O&&t["s-p"]&&t["s-p"].push(new Promise((t=>e.O=t)))},T=(e,t)=>{if(e.t|=16,!(4&e.t))return L(e,e.S),oe((()=>W(e,t)));e.t|=512},W=(e,t)=>{const n=e.i;let l;return t&&(e.t|=256,e.u&&(e.u.map((([e,t])=>U(n,e,t))),e.u=null),l=U(n,"componentWillLoad")),q(l,(()=>A(e,n,t)))},A=async(n,l,s)=>{const c=n.j,r=c["s-rc"];s&&(e=>{const t=e.M,n=e.j,l=t.t,s=((e,t)=>{let n=$(t),l=Y.get(n);if(e=11===e.nodeType?e:o,l)if("string"==typeof l){let t,s=h.get(e=e.head||e);s||h.set(e,s=new Set),s.has(n)||(t=o.createElement("style"),t.innerHTML=l,e.insertBefore(t,e.querySelector("link")),s&&s.add(n))}else e.adoptedStyleSheets.includes(l)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,l]);return n})(n.shadowRoot?n.shadowRoot:n.getRootNode(),t);10&l&&(n["s-sc"]=s,n.classList.add(s+"-h"))})(n);((n,l)=>{const s=n.j,o=n.k||y(null,null),c=(e=>e&&e.g===w)(l)?l:m(null,null,l);t=s.tagName,c.g=null,c.t|=4,n.k=c,c.v=o.v=s.shadowRoot||s,e=s["s-sc"],C(o,c)})(n,F(n,l)),r&&(r.map((e=>e())),c["s-rc"]=void 0);{const e=c["s-p"],t=()=>H(n);0===e.length?t():(Promise.all(e).then(t),n.t|=4,e.length=0)}},F=(e,t)=>{try{t=t.render(),e.t&=-17,e.t|=2}catch(t){K(t,e.j)}return t},H=e=>{const t=e.j,n=e.S;64&e.t||(e.t|=64,N(t),e.C(t),n||R()),e.P(t),e.O&&(e.O(),e.O=void 0),512&e.t&&se((()=>T(e,!1))),e.t&=-517},R=()=>{N(o.documentElement),se((()=>E(s,"appload",{detail:{namespace:"honey-webcomponents"}})))},U=(e,t,n)=>{if(e&&e[t])try{return e[t](n)}catch(e){K(e)}},q=(e,t)=>e&&e.then?e.then(t):t(),N=e=>e.classList.add("hydrated"),V=(e,t,n)=>{if(t.L){e.watchers&&(t.T=e.watchers);const l=Object.entries(t.L),s=e.prototype;if(l.map((([e,[l]])=>{31&l||2&n&&32&l?Object.defineProperty(s,e,{get(){return((e,t)=>D(this).W.get(t))(0,e)},set(n){((e,t,n,l)=>{const s=D(e),o=s.j,c=s.W.get(t),r=s.t,i=s.i;if(n=((e,t)=>null==e||p(e)?e:4&t?"false"!==e&&(""===e||!!e):2&t?parseFloat(e):1&t?e+"":e)(n,l.L[t][0]),!(8&r&&void 0!==c||n===c)&&(s.W.set(t,n),i)){if(l.T&&128&r){const e=l.T[t];e&&e.map((e=>{try{i[e](n,c,t)}catch(e){K(e,o)}}))}2==(18&r)&&T(s,!1)}})(this,e,n,t)},configurable:!0,enumerable:!0}):1&n&&64&l&&Object.defineProperty(s,e,{value(...t){const n=D(this);return n.A.then((()=>n.i[e](...t)))}})})),1&n){const t=new Map;s.attributeChangedCallback=function(e,n,l){c.jmp((()=>{const n=t.get(e);this[n]=(null!==l||"boolean"!=typeof this[n])&&l}))},e.observedAttributes=l.filter((([e,t])=>15&t[0])).map((([e,n])=>{const l=n[1]||e;return t.set(l,e),l}))}}return e},_=e=>{U(e,"connectedCallback")},z=(e,t={})=>{const n=[],l=t.exclude||[],r=s.customElements,u=o.head,f=u.querySelector("meta[charset]"),h=o.createElement("style"),d=[];let p,m=!0;Object.assign(c,t),c.l=new URL(t.resourcesUrl||"./",o.baseURI).href,e.map((e=>e[1].map((t=>{const s={t:t[0],h:t[1],L:t[2],F:t[3]};s.L=t[2],s.F=t[3],s.T={};const o=s.h,u=class extends HTMLElement{constructor(e){super(e),I(e=this,s),1&s.t&&e.attachShadow({mode:"open"})}connectedCallback(){p&&(clearTimeout(p),p=null),m?d.push(this):c.jmp((()=>(e=>{if(0==(1&c.t)){const t=D(e),n=t.M,l=()=>{};if(1&t.t)a(e,t,n.F),_(t.i);else{t.t|=1;{let n=e;for(;n=n.parentNode||n.host;)if(n["s-p"]){L(t,t.S=n);break}}n.L&&Object.entries(n.L).map((([t,[n]])=>{if(31&n&&e.hasOwnProperty(t)){const n=e[t];delete e[t],e[t]=n}})),(async(e,t,n,l,s)=>{if(0==(32&t.t)){{if(t.t|=32,(s=X(n)).then){const e=()=>{};s=await s,e()}s.isProxied||(n.T=s.watchers,V(s,n,2),s.isProxied=!0);const e=()=>{};t.t|=8;try{new s(t)}catch(e){K(e)}t.t&=-9,t.t|=128,e(),_(t.i)}if(s.style){let e=s.style;const t=$(n);if(!Y.has(t)){const l=()=>{};((e,t,n)=>{let l=Y.get(e);i&&n?(l=l||new CSSStyleSheet,l.replace(t)):l=t,Y.set(e,l)})(t,e,!!(1&n.t)),l()}}}const o=t.S,c=()=>T(t,!0);o&&o["s-rc"]?o["s-rc"].push(c):c()})(0,t,n)}l()}})(this)))}disconnectedCallback(){c.jmp((()=>(()=>{if(0==(1&c.t)){const e=D(this);e.o&&(e.o.map((e=>e())),e.o=void 0)}})()))}componentOnReady(){return D(this).H}};s.R=e[0],l.includes(o)||r.get(o)||(n.push(o),r.define(o,V(u,s,1)))})))),h.innerHTML=n+"{visibility:hidden}.hydrated{visibility:inherit}",h.setAttribute("data-styles",""),u.insertBefore(h,f?f.nextSibling:u.firstChild),m=!1,d.length?d.map((e=>e.connectedCallback())):c.jmp((()=>p=setTimeout(R,30)))},B=new WeakMap,D=e=>B.get(e),G=(e,t)=>B.set(t.i=e,t),I=(e,t)=>{const n={t:0,j:e,M:t,W:new Map};return n.A=new Promise((e=>n.P=e)),n.H=new Promise((e=>n.C=e)),e["s-p"]=[],e["s-rc"]=[],a(e,n,t.F),B.set(e,n)},J=(e,t)=>t in e,K=(e,t)=>(0,console.error)(e,t),Q=new Map,X=e=>{const t=e.h.replace(/-/g,"_"),n=e.R,l=Q.get(n);return l?l[t]:import(`./${n}.entry.js`).then((e=>(Q.set(n,e),e[t])),K)},Y=new Map,Z=[],ee=[],te=(e,t)=>n=>{e.push(n),l||(l=!0,t&&4&c.t?se(le):c.raf(le))},ne=e=>{for(let t=0;t<e.length;t++)try{e[t](performance.now())}catch(e){K(e)}e.length=0},le=()=>{ne(Z),ne(ee),(l=Z.length>0)&&c.raf(le)},se=e=>r().then(e),oe=te(ee,!0);export{w as H,z as b,x as c,P as g,m as h,r as p,G as r}