UNPKG

@microblink/blinkinput-in-browser-sdk

Version:

A simple barcode scanning library for WebAssembly-enabled browsers.

1 lines 8.31 kB
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,"function"==typeof(new CSSStyleSheet).replace}catch(e){}return!1})(),a=new WeakMap,u=e=>"sc-"+e.o,f={},h=e=>"object"==(e=typeof e)||"function"===e,d=(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&&!h(l))&&(l+=""),s&&o?c[c.length-1].i+=l:c.push(s?p(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=p(e,null);return i.u=t,c.length>0&&(i.h=c),i},p=(e,t)=>({t:0,p:e,i:t,$:null,h:null,u:null}),$={},m=(e,t,n,l,o,r)=>{if(n!==l){let i=G(e,t),a=t.toLowerCase();if("class"===t){const t=e.classList,s=y(n),o=y(l);t.remove(...s.filter((e=>e&&!o.includes(e)))),t.add(...o.filter((e=>e&&!s.includes(e))))}else if("ref"===t)l&&l(e);else if(i||"o"!==t[0]||"n"!==t[1]){const s=h(l);if((i||s&&null!==l)&&!o)try{if(e.tagName.includes("-"))e[t]=l;else{let s=null==l?"":l;"list"===t?i=!1:null!=n&&e[t]==s||(e[t]=s)}}catch(e){}null==l||!1===l?!1===l&&""!==e.getAttribute(t)||e.removeAttribute(t):(!i||4&r||o)&&!s&&e.setAttribute(t,l=!0===l?"":l)}else t="-"===t[2]?t.slice(3):G(s,a)?a.slice(2):a[2]+t.slice(3),n&&c.rel(e,t,n,!1),l&&c.ael(e,t,l,!1)}},b=/\s/,y=e=>e?e.split(b):[],w=(e,t,n,l)=>{const s=11===t.$.nodeType&&t.$.host?t.$.host:t.$,o=e&&e.u||f,c=t.u||f;for(l in o)l in c||m(s,l,o[l],void 0,n,t.t);for(l in c)m(s,l,o[l],c[l],n,t.t)},g=(t,l,s)=>{let c,r,i=l.h[s],a=0;if(null!==i.i)c=i.$=o.createTextNode(i.i);else{if(n||(n="svg"===i.p),c=i.$=o.createElementNS(n?"http://www.w3.org/2000/svg":"http://www.w3.org/1999/xhtml",i.p),n&&"foreignObject"===i.p&&(n=!1),w(null,i,n),null!=e&&c["s-si"]!==e&&c.classList.add(c["s-si"]=e),i.h)for(a=0;a<i.h.length;++a)r=g(t,i,a),r&&c.appendChild(r);"svg"===i.p?n=!1:"foreignObject"===c.tagName&&(n=!0)}return c},j=(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=g(null,l,o),r&&(s[o].$=r,i.insertBefore(r,n)))},v=(e,t,n,l,s)=>{for(;t<=n;++t)(l=e[t])&&(s=l.$,k(l),s.remove())},S=(e,t)=>e.p===t.p,O=(e,t)=>{const l=t.$=e.$,s=e.h,o=t.h,c=t.p,r=t.i;null===r?(n="svg"===c||"foreignObject"!==c&&n,"slot"===c||w(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]:S(i,f)?(O(i,f),i=t[++o],f=l[++c]):S(a,h)?(O(a,h),a=t[--r],h=l[--u]):S(i,h)?(O(i,h),e.insertBefore(i.$,a.$.nextSibling),i=t[++o],h=l[--u]):S(a,f)?(O(a,f),e.insertBefore(a.$,i.$),a=t[--r],f=l[++c]):(s=g(t&&t[c],n,c),f=l[++c],s&&i.$.parentNode.insertBefore(s,i.$));o>r?j(e,null==l[u+1]?null:l[u+1].$,n,l,c,u):c>u&&v(t,o,r)})(l,s,t,o):null!==o?(null!==e.i&&(l.textContent=""),j(l,null,t,o,0,o.length-1)):null!==s&&v(s,0,s.length-1),n&&"svg"===c&&(n=!1)):e.i!==r&&(l.data=r)},k=e=>{e.u&&e.u.ref&&e.u.ref(null),e.h&&e.h.map(k)},C=e=>_(e).m,M=(e,t,n)=>{const l=C(e);return{emit:e=>P(l,t,{bubbles:!!(4&n),composed:!!(2&n),cancelable:!!(1&n),detail:e})}},P=(e,t,n)=>{const l=c.ce(t,n);return e.dispatchEvent(l),l},x=(e,t)=>{t&&!e.g&&t["s-p"]&&t["s-p"].push(new Promise((t=>e.g=t)))},W=(e,t)=>{if(e.t|=16,!(4&e.t))return x(e,e.j),le((()=>E(e,t)));e.t|=512},E=(e,t)=>{const n=e.v;let l;return l=A(n,t?"componentWillLoad":"componentWillUpdate"),F(l,(()=>L(e,n,t)))},L=async(e,t,n)=>{const l=e.m,s=l["s-rc"];n&&(e=>{const t=e.S,n=e.m,l=t.t,s=((e,t)=>{let n=u(t),l=Q.get(n);if(e=11===e.nodeType?e:o,l)if("string"==typeof l){let t,s=a.get(e=e.head||e);s||a.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"))})(e);R(e,t),s&&(s.map((e=>e())),l["s-rc"]=void 0);{const t=l["s-p"],n=()=>T(e);0===t.length?n():(Promise.all(t).then(n),e.t|=4,t.length=0)}},R=(n,l)=>{try{l=l.render(),n.t&=-17,n.t|=2,((n,l)=>{const s=n.m,o=n.O||p(null,null),c=(e=>e&&e.p===$)(l)?l:d(null,null,l);t=s.tagName,c.p=null,c.t|=4,n.O=c,c.$=o.$=s.shadowRoot||s,e=s["s-sc"],O(o,c)})(n,l)}catch(e){I(e,n.m)}return null},T=e=>{const t=e.m,n=e.j;A(e.v,"componentDidRender"),64&e.t||(e.t|=64,H(t),e.k(t),n||U()),e.C(t),e.g&&(e.g(),e.g=void 0),512&e.t&&ne((()=>W(e,!1))),e.t&=-517},U=()=>{H(o.documentElement),ne((()=>P(s,"appload",{detail:{namespace:"blinkinput-in-browser"}})))},A=(e,t,n)=>{if(e&&e[t])try{return e[t](n)}catch(e){I(e)}},F=(e,t)=>e&&e.then?e.then(t):t(),H=e=>e.classList.add("hydrated"),q=(e,t,n)=>{if(t.M){e.watchers&&(t.P=e.watchers);const l=Object.entries(t.M),s=e.prototype;if(l.map((([e,[l]])=>{31&l||2&n&&32&l?Object.defineProperty(s,e,{get(){return((e,t)=>_(this).W.get(t))(0,e)},set(n){((e,t,n,l)=>{const s=_(e),o=s.m,c=s.W.get(t),r=s.t,i=s.v;if(n=((e,t)=>null==e||h(e)?e:4&t?"false"!==e&&(""===e||!!e):2&t?parseFloat(e):1&t?e+"":e)(n,l.M[t][0]),!(8&r&&void 0!==c||n===c)&&(s.W.set(t,n),i)){if(l.P&&128&r){const e=l.P[t];e&&e.map((e=>{try{i[e](n,c,t)}catch(e){I(e,o)}}))}2==(18&r)&&W(s,!1)}})(this,e,n,t)},configurable:!0,enumerable:!0}):1&n&&64&l&&Object.defineProperty(s,e,{value(...t){const n=_(this);return n.L.then((()=>n.v[e](...t)))}})})),1&n){const t=new Map;s.attributeChangedCallback=function(e,n,l){c.jmp((()=>{const n=t.get(e);if(this.hasOwnProperty(n))l=this[n],delete this[n];else if(s.hasOwnProperty(n)&&"number"==typeof this[n]&&this[n]==l)return;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},D=e=>{A(e,"connectedCallback")},N=(e,t={})=>{const n=[],l=t.exclude||[],r=s.customElements,a=o.head,f=a.querySelector("meta[charset]"),h=o.createElement("style"),d=[];let p,$=!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],o:t[1],M:t[2],R:t[3]};s.M=t[2],s.P={};const o=s.o,a=class extends HTMLElement{constructor(e){super(e),B(e=this,s),1&s.t&&e.attachShadow({mode:"open"})}connectedCallback(){p&&(clearTimeout(p),p=null),$?d.push(this):c.jmp((()=>(e=>{if(0==(1&c.t)){const t=_(e),n=t.S,l=()=>{};if(1&t.t)D(t.v);else{t.t|=1;{let n=e;for(;n=n.parentNode||n.host;)if(n["s-p"]){x(t,t.j=n);break}}n.M&&Object.entries(n.M).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=K(n)).then){const e=()=>{};s=await s,e()}s.isProxied||(n.P=s.watchers,q(s,n,2),s.isProxied=!0);const e=()=>{};t.t|=8;try{new s(t)}catch(e){I(e)}t.t&=-9,t.t|=128,e(),D(t.v)}if(s.style){let e=s.style;const t=u(n);if(!Q.has(t)){const l=()=>{};((e,t,n)=>{let l=Q.get(e);i&&n?(l=l||new CSSStyleSheet,l.replace(t)):l=t,Q.set(e,l)})(t,e,!!(1&n.t)),l()}}}const o=t.j,c=()=>W(t,!0);o&&o["s-rc"]?o["s-rc"].push(c):c()})(0,t,n)}l()}})(this)))}disconnectedCallback(){c.jmp((()=>(()=>{0==(1&c.t)&&A(_(this).v,"disconnectedCallback")})()))}componentOnReady(){return _(this).T}};s.U=e[0],l.includes(o)||r.get(o)||(n.push(o),r.define(o,q(a,s,1)))}))})),h.innerHTML=n+"{visibility:hidden}.hydrated{visibility:inherit}",h.setAttribute("data-styles",""),a.insertBefore(h,f?f.nextSibling:a.firstChild),$=!1,d.length?d.map((e=>e.connectedCallback())):c.jmp((()=>p=setTimeout(U,30)))},V=new WeakMap,_=e=>V.get(e),z=(e,t)=>V.set(t.v=e,t),B=(e,t)=>{const n={t:0,m:e,S:t,W:new Map};return n.L=new Promise((e=>n.C=e)),n.T=new Promise((e=>n.k=e)),e["s-p"]=[],e["s-rc"]=[],V.set(e,n)},G=(e,t)=>t in e,I=(e,t)=>(0,console.error)(e,t),J=new Map,K=e=>{const t=e.o.replace(/-/g,"_"),n=e.U,l=J.get(n);return l?l[t]:import(`./${n}.entry.js`).then((e=>(J.set(n,e),e[t])),I)},Q=new Map,X=[],Y=[],Z=(e,t)=>n=>{e.push(n),l||(l=!0,t&&4&c.t?ne(te):c.raf(te))},ee=e=>{for(let t=0;t<e.length;t++)try{e[t](performance.now())}catch(e){I(e)}e.length=0},te=()=>{ee(X),ee(Y),(l=X.length>0)&&c.raf(te)},ne=e=>r().then(e),le=Z(Y,!0);export{$ as H,N as b,M as c,C as g,d as h,r as p,z as r}