bitcoin-qr
Version:
A zero-dependency, zero-framework QR code web component for Bitcoin on-chain, Lightning, and unified BIP-21 payments.
2 lines • 8.21 kB
JavaScript
let n,e,t=!1,l=!1;const o={},s=n=>"object"==(n=typeof n)||"function"===n,i=(n,e,...t)=>{let l=null,o=null,i=!1,c=!1;const u=[],a=e=>{for(let t=0;t<e.length;t++)l=e[t],Array.isArray(l)?a(l):null!=l&&"boolean"!=typeof l&&((i="function"!=typeof n&&!s(l))&&(l+=""),i&&c?u[u.length-1].t+=l:u.push(i?r(null,l):l),c=i)};a(t),e&&e.key&&(o=e.key);const f=r(n,null);return f.l=e,u.length>0&&(f.o=u),f.i=o,f},r=(n,e)=>({u:0,$:n,t:e,m:null,o:null,l:null,i:null}),c={},u=n=>q(n).$hostElement$,a=(n,e,t,l,o,i)=>{if(t!==l){let r=U(n,e);if(e.toLowerCase(),"key"===e);else{const c=s(l);if((r||c&&null!==l)&&!o)try{if(n.tagName.includes("-"))n[e]=l;else{const o=null==l?"":l;"list"===e?r=!1:null!=t&&n[e]==o||(n[e]=o)}}catch(n){}null==l||!1===l?!1===l&&""!==n.getAttribute(e)||n.removeAttribute(e):(!r||4&i||o)&&!c&&n.setAttribute(e,l=!0===l?"":l)}}},f=(n,e,t,l)=>{const s=11===e.m.nodeType&&e.m.host?e.m.host:e.m,i=n&&n.l||o,r=e.l||o;for(l of d(Object.keys(i)))l in r||a(s,l,i[l],void 0,t,e.u);for(l of d(Object.keys(r)))a(s,l,i[l],r[l],t,e.u)};function d(n){return n.includes("ref")?[...n.filter((n=>"ref"!==n)),"ref"]:n}const $=(l,o,s)=>{const i=o.o[s];let r,c,u=0;if(r=i.m=V.createElement(i.$),f(null,i,t),null!=n&&r["s-si"]!==n&&r.classList.add(r["s-si"]=n),i.o)for(u=0;u<i.o.length;++u)c=$(l,i,u),c&&r.appendChild(c);return r["s-hn"]=e,r},m=(n,t,l,o,s,i)=>{let r,c=n;for(c.shadowRoot&&c.tagName===e&&(c=c.shadowRoot);s<=i;++s)o[s]&&(r=$(null,l,s),r&&(o[s].m=r,c.insertBefore(r,t)))},y=(n,e,t)=>{for(let l=e;l<=t;++l){const e=n[l];if(e){const n=e.m;n&&n.remove()}}},v=(n,e,t=!1)=>n.$===e.$&&(!!t||n.i===e.i),h=(n,e,l=!1)=>{const o=e.m=n.m,s=n.o,i=e.o;f(n,e,t),null!==s&&null!==i?((n,e,t,l,o=!1)=>{let s,i,r=0,c=0,u=0,a=0,f=e.length-1,d=e[0],p=e[f],b=l.length-1,w=l[0],j=l[b];for(;r<=f&&c<=b;)if(null==d)d=e[++r];else if(null==p)p=e[--f];else if(null==w)w=l[++c];else if(null==j)j=l[--b];else if(v(d,w,o))h(d,w,o),d=e[++r],w=l[++c];else if(v(p,j,o))h(p,j,o),p=e[--f],j=l[--b];else if(v(d,j,o))h(d,j,o),n.insertBefore(d.m,p.m.nextSibling),d=e[++r],j=l[--b];else if(v(p,w,o))h(p,w,o),n.insertBefore(p.m,d.m),p=e[--f],w=l[++c];else{for(u=-1,a=r;a<=f;++a)if(e[a]&&null!==e[a].i&&e[a].i===w.i){u=a;break}u>=0?(i=e[u],i.$!==w.$?s=$(e&&e[c],t,u):(h(i,w,o),e[u]=void 0,s=i.m),w=l[++c]):(s=$(e&&e[c],t,c),w=l[++c]),s&&d.m.parentNode.insertBefore(s,d.m)}r>f?m(n,null==l[b+1]?null:l[b+1].m,t,l,c,b):c>b&&y(e,r,f)})(o,s,e,i,l):null!==i?m(o,null,e,i,0,i.length-1):null!==s&&y(s,0,s.length-1)},p=(n,e)=>{e&&!n.v&&e["s-p"]&&e["s-p"].push(new Promise((e=>n.v=e)))},b=(n,e)=>{if(n.u|=16,!(4&n.u))return p(n,n.h),X((()=>w(n,e)));n.u|=512},w=(n,e)=>{const t=n.p;let l;return e&&(l=E(t,"componentWillLoad")),j(l,(()=>O(n,t,e)))},j=(n,e)=>g(n)?n.then(e):e(),g=n=>n instanceof Promise||n&&n.then&&"function"==typeof n.then,O=async(n,e,t)=>{var l;const o=n.$hostElement$,s=o["s-rc"];k(n,e,o,t),s&&(s.map((n=>n())),o["s-rc"]=void 0);{const e=null!==(l=o["s-p"])&&void 0!==l?l:[],t=()=>M(n);0===e.length?t():(Promise.all(e).then(t),n.u|=4,e.length=0)}},k=(t,l,o,s)=>{try{l=l.render(),t.u&=-17,t.u|=2,((t,l,o=!1)=>{const s=t.$hostElement$,u=t.j||r(null,null),a=(n=>n&&n.$===c)(l)?l:i(null,null,l);if(e=s.tagName,o&&a.l)for(const n of Object.keys(a.l))s.hasAttribute(n)&&!["key","ref","style","class"].includes(n)&&(a.l[n]=s[n]);a.$=null,a.u|=4,t.j=a,a.m=u.m=s.shadowRoot||s,n=s["s-sc"],h(u,a,o)})(t,l,s)}catch(n){W(n,t.$hostElement$)}return null},M=n=>{const e=n.$hostElement$,t=n.p,l=n.h;64&n.u||(n.u|=64,L(e),E(t,"componentDidLoad"),n.O(e),l||P()),n.v&&(n.v(),n.v=void 0),512&n.u&&Q((()=>b(n,!1))),n.u&=-517},P=()=>{L(V.documentElement),Q((()=>(n=>{const e=_.ce("appload",{detail:{namespace:"bitcoin-qr"}});return n.dispatchEvent(e),e})(S)))},E=(n,e,t)=>{if(n&&n[e])try{return n[e](t)}catch(n){W(n)}},L=n=>n.classList.add("hydrated"),x=(n,e,t)=>{var l;const o=n.prototype;if(e.k){n.watchers&&(e.M=n.watchers);const i=Object.entries(e.k);if(i.map((([n,[l]])=>{(31&l||2&t&&32&l)&&Object.defineProperty(o,n,{get(){return((n,e)=>q(this).P.get(e))(0,n)},set(t){((n,e,t,l)=>{const o=q(n),i=o.$hostElement$,r=o.P.get(e),c=o.u,u=o.p;if(t=((n,e)=>null==n||s(n)?n:4&e?"false"!==n&&(""===n||!!n):2&e?parseFloat(n):1&e?n+"":n)(t,l.k[e][0]),(!(8&c)||void 0===r)&&t!==r&&(!Number.isNaN(r)||!Number.isNaN(t))&&(o.P.set(e,t),u)){if(l.M&&128&c){const n=l.M[e];n&&n.map((n=>{try{u[n](t,r,e)}catch(n){W(n,i)}}))}if(2==(18&c)){if(u.componentShouldUpdate&&!1===u.componentShouldUpdate(t,r,e))return;b(o,!1)}}})(this,n,t,e)},configurable:!0,enumerable:!0})})),1&t){const t=new Map;o.attributeChangedCallback=function(n,l,s){_.jmp((()=>{var i;const r=t.get(n);if(this.hasOwnProperty(r))s=this[r],delete this[r];else{if(o.hasOwnProperty(r)&&"number"==typeof this[r]&&this[r]==s)return;if(null==r){const t=q(this),o=null==t?void 0:t.u;if(o&&!(8&o)&&128&o&&s!==l){const o=t.p,r=null===(i=e.M)||void 0===i?void 0:i[n];null==r||r.forEach((e=>{null!=o[e]&&o[e].call(o,s,l,n)}))}return}}this[r]=(null!==s||"boolean"!=typeof this[r])&&s}))},n.observedAttributes=Array.from(new Set([...Object.keys(null!==(l=e.M)&&void 0!==l?l:{}),...i.filter((([n,e])=>15&e[0])).map((([n,e])=>{const l=e[1]||n;return t.set(l,n),l}))]))}}return n},A=n=>{if(!(1&_.u)){const e=q(n),t=e.L,l=()=>{};if(1&e.u)(null==e?void 0:e.p)||(null==e?void 0:e.A)&&e.A.then((()=>{}));else{e.u|=1;{let t=n;for(;t=t.parentNode||t.host;)if(t["s-p"]){p(e,e.h=t);break}}t.k&&Object.entries(t.k).map((([e,[t]])=>{if(31&t&&n.hasOwnProperty(e)){const t=n[e];delete n[e],n[e]=t}})),(async(n,e,t)=>{let l;if(!(32&e.u))if(e.u|=32,t.C){if(l=H(t),l.then){const n=()=>{};l=await l,n()}l.isProxied||(t.M=l.watchers,x(l,t,2),l.isProxied=!0);const n=()=>{};e.u|=8;try{new l(e)}catch(n){W(n)}e.u&=-9,e.u|=128,n()}else l=n.constructor,customElements.whenDefined(t.N).then((()=>e.u|=128));const o=e.h,s=()=>b(e,!0);o&&o["s-rc"]?o["s-rc"].push(s):s()})(n,e,t)}l()}},C=(n,e={})=>{var t;const l=[],o=e.exclude||[],s=S.customElements,i=V.head,r=i.querySelector("meta[charset]"),c=V.createElement("style"),u=[];let a,f=!0;Object.assign(_,e),_.T=new URL(e.resourcesUrl||"./",V.baseURI).href;let d=!1;if(n.map((n=>{n[1].map((e=>{var t;const i={u:e[0],N:e[1],k:e[2],q:e[3]};4&i.u&&(d=!0),i.k=e[2],i.M=null!==(t=e[4])&&void 0!==t?t:{};const r=i.N,c=class extends HTMLElement{constructor(n){super(n),R(n=this,i),1&i.u&&n.attachShadow({mode:"open"})}connectedCallback(){a&&(clearTimeout(a),a=null),f?u.push(this):_.jmp((()=>A(this)))}disconnectedCallback(){_.jmp((()=>(async()=>{if(!(1&_.u)){const n=q(this);(null==n?void 0:n.p)||(null==n?void 0:n.A)&&n.A.then((()=>{}))}})()))}componentOnReady(){return q(this).A}};i.C=n[0],o.includes(r)||s.get(r)||(l.push(r),s.define(r,x(c,i,1)))}))})),l.length>0&&(d&&(c.textContent+="slot-fb{display:contents}slot-fb[hidden]{display:none}"),c.textContent+=l+"{visibility:hidden}.hydrated{visibility:inherit}",c.innerHTML.length)){c.setAttribute("data-styles","");const n=null!==(t=_.F)&&void 0!==t?t:function(n){var e,t,l;return null!==(l=null===(t=null===(e=n.head)||void 0===e?void 0:e.querySelector('meta[name="csp-nonce"]'))||void 0===t?void 0:t.getAttribute("content"))&&void 0!==l?l:void 0}(V);null!=n&&c.setAttribute("nonce",n),i.insertBefore(c,r?r.nextSibling:i.firstChild)}f=!1,u.length?u.map((n=>n.connectedCallback())):_.jmp((()=>a=setTimeout(P,30)))},N=n=>_.F=n,T=new WeakMap,q=n=>T.get(n),F=(n,e)=>T.set(e.p=n,e),R=(n,e)=>{const t={u:0,$hostElement$:n,L:e,P:new Map};return t.A=new Promise((n=>t.O=n)),n["s-p"]=[],n["s-rc"]=[],T.set(n,t)},U=(n,e)=>e in n,W=(n,e)=>(0,console.error)(n,e),D=new Map,H=n=>{const e=n.N.replace(/-/g,"_"),t=n.C,l=D.get(t);return l?l[e]:import(`./${t}.entry.js`).then((n=>(D.set(t,n),n[e])),W)
/*!__STENCIL_STATIC_IMPORT_SWITCH__*/},S="undefined"!=typeof window?window:{},V=S.document||{head:{}},_={u:0,T:"",jmp:n=>n(),raf:n=>requestAnimationFrame(n),ael:(n,e,t,l)=>n.addEventListener(e,t,l),rel:(n,e,t,l)=>n.removeEventListener(e,t,l),ce:(n,e)=>new CustomEvent(n,e)},z=n=>Promise.resolve(n),B=[],G=[],I=(n,e)=>t=>{n.push(t),l||(l=!0,e&&4&_.u?Q(K):_.raf(K))},J=n=>{for(let e=0;e<n.length;e++)try{n[e](performance.now())}catch(n){W(n)}n.length=0},K=()=>{J(B),J(G),(l=B.length>0)&&_.raf(K)},Q=n=>z().then(n),X=I(G,!0);export{C as b,u as g,i as h,z as p,F as r,N as s}