UNPKG

@bulmil/core

Version:

![bulmil](https://user-images.githubusercontent.com/2362138/65766959-c721a080-e16f-11e9-9fb9-45a5a2ad0391.jpg)

5 lines 14.5 kB
/*! * Bulmil - MIT License */ let l,e,n=!1,t=!1,o=!1,s=!1,i=!1;const f="s-id",c="c-id",r="slot-fb{display:contents}slot-fb[hidden]{display:none}",u={},a=l=>"object"==(l=typeof l)||"function"===l;function $(l){var e,n,t;return null!==(t=null===(n=null===(e=l.head)||void 0===e?void 0:e.querySelector('meta[name="csp-nonce"]'))||void 0===n?void 0:n.getAttribute("content"))&&void 0!==t?t:void 0}const d=(l,e,...n)=>{let t=null,o=null,s=null,i=!1,f=!1;const c=[],r=e=>{for(let n=0;n<e.length;n++)t=e[n],Array.isArray(t)?r(t):null!=t&&"boolean"!=typeof t&&((i="function"!=typeof l&&!a(t))&&(t+=""),i&&f?c[c.length-1].l+=t:c.push(i?v(null,t):t),f=i)};if(r(n),e){e.key&&(o=e.key),e.name&&(s=e.name);{const l=e.className||e.class;l&&(e.class="object"!=typeof l?l:Object.keys(l).filter((e=>l[e])).join(" "))}}if("function"==typeof l)return l(null===e?{}:e,c,p);const u=v(l,null);return u.t=e,c.length>0&&(u.o=c),u.i=o,u.u=s,u},v=(l,e)=>({$:0,v:l,l:e,p:null,o:null,t:null,i:null,u:null}),y={},p={forEach:(l,e)=>l.map(h).forEach(e),map:(l,e)=>l.map(h).map(e).map(m)},h=l=>({vattrs:l.t,vchildren:l.o,vkey:l.i,vname:l.u,vtag:l.v,vtext:l.l}),m=l=>{if("function"==typeof l.vtag){const e=Object.assign({},l.vattrs);return l.vkey&&(e.key=l.vkey),l.vname&&(e.name=l.vname),d(l.vtag,e,...l.vchildren||[])}const e=v(l.vtag,l.vtext);return e.t=l.vattrs,e.o=l.vchildren,e.i=l.vkey,e.u=l.vname,e},b=(l,e,n,t,o,s,i)=>{let f,r,u,a;if(1===s.nodeType){for(f=s.getAttribute(c),f&&(r=f.split("."),r[0]!==i&&"0"!==r[0]||(u={$:0,h:r[0],m:r[1],k:r[2],j:r[3],v:s.tagName.toLowerCase(),p:s,t:null,o:null,i:null,u:null,l:null},e.push(u),s.removeAttribute(c),l.o||(l.o=[]),l.o[u.j]=u,l=u,t&&"0"===u.k&&(t[u.j]=u.p))),a=s.childNodes.length-1;a>=0;a--)b(l,e,n,t,o,s.childNodes[a],i);if(s.shadowRoot)for(a=s.shadowRoot.childNodes.length-1;a>=0;a--)b(l,e,n,t,o,s.shadowRoot.childNodes[a],i)}else if(8===s.nodeType)r=s.nodeValue.split("."),r[1]!==i&&"0"!==r[1]||(f=r[0],u={$:0,h:r[1],m:r[2],k:r[3],j:r[4],p:s,t:null,o:null,i:null,u:null,v:null,l:null},"t"===f?(u.p=s.nextSibling,u.p&&3===u.p.nodeType&&(u.l=u.p.textContent,e.push(u),s.remove(),l.o||(l.o=[]),l.o[u.j]=u,t&&"0"===u.k&&(t[u.j]=u.p))):u.h===i&&("s"===f?(u.v="slot",s["s-sn"]=r[5]?u.u=r[5]:"",s["s-sr"]=!0,n.push(u),l.o||(l.o=[]),l.o[u.j]=u):"r"===f&&(o["s-cr"]=s,s["s-cn"]=!0)));else if(l&&"style"===l.v){const e=v(null,s.textContent);e.p=s,e.j="0",l.o=[e]}},w=(l,e)=>{if(1===l.nodeType){let n=0;for(;n<l.childNodes.length;n++)w(l.childNodes[n],e);if(l.shadowRoot)for(n=0;n<l.shadowRoot.childNodes.length;n++)w(l.shadowRoot.childNodes[n],e)}else if(8===l.nodeType){const n=l.nodeValue.split(".");"o"===n[0]&&(e.set(n[1]+"."+n[2],l),l.nodeValue="",l["s-en"]=n[3])}},g=new WeakMap,k=l=>"sc-"+l.S,j=(l,e,n,t,o,s)=>{if(n!==t){let i=fl(l,e),f=e.toLowerCase();if("class"===e){const e=l.classList,o=O(n),s=O(t);e.remove(...o.filter((l=>l&&!s.includes(l)))),e.add(...s.filter((l=>l&&!o.includes(l))))}else if("key"===e);else if(i||"o"!==e[0]||"n"!==e[1]){const f=a(t);if((i||f&&null!==t)&&!o)try{if(l.tagName.includes("-"))l[e]=t;else{const o=null==t?"":t;"list"===e?i=!1:null!=n&&l[e]==o||(l[e]=o)}}catch(l){}null==t||!1===t?!1===t&&""!==l.getAttribute(e)||l.removeAttribute(e):(!i||4&s||o)&&!f&&l.setAttribute(e,t=!0===t?"":t)}else if(e="-"===e[2]?e.slice(3):fl($l,f)?f.slice(2):f[2]+e.slice(3),n||t){const o=e.endsWith(x);e=e.replace(M,""),n&&vl.rel(l,e,n,o),t&&vl.ael(l,e,t,o)}}},S=/\s/,O=l=>l?l.split(S):[],x="Capture",M=RegExp(x+"$"),C=(l,e,n,t)=>{const o=11===e.p.nodeType&&e.p.host?e.p.host:e.p,s=l&&l.t||u,i=e.t||u;for(t of E(Object.keys(s)))t in i||j(o,t,s[t],void 0,n,e.$);for(t of E(Object.keys(i)))j(o,t,s[t],i[t],n,e.$)};function E(l){return l.includes("ref")?[...l.filter((l=>"ref"!==l)),"ref"]:l}const R=(t,i,f)=>{var c;const r=i.o[f];let u,a,$,d=0;if(n||(o=!0,"slot"===r.v&&(r.$|=r.o?2:1)),null!==r.l)u=r.p=dl.createTextNode(r.l);else if(1&r.$)u=r.p=dl.createTextNode("");else if(u=r.p=dl.createElement(2&r.$?"slot-fb":r.v),C(null,r,s),r.o)for(d=0;d<r.o.length;++d)a=R(t,r,d),a&&u.appendChild(a);return u["s-hn"]=e,3&r.$&&(u["s-sr"]=!0,u["s-cr"]=l,u["s-sn"]=r.u||"",u["s-rf"]=null===(c=r.t)||void 0===c?void 0:c.ref,$=t&&t.o&&t.o[f],$&&$.v===r.v&&t.p&&P(t.p,!1)),u},P=(l,n)=>{vl.$|=1;const t=Array.from(l.childNodes);for(let l=t.length-1;l>=0;l--){const s=t[l];s["s-hn"]!==e&&s["s-ol"]&&(F(s).insertBefore(s,N(s)),s["s-ol"].remove(),s["s-ol"]=void 0,s["s-sh"]=void 0,o=!0),n&&P(s,n)}vl.$&=-2},T=(l,e,n,t,o,s)=>{let i,f=l["s-cr"]&&l["s-cr"].parentNode||l;for(;o<=s;++o)t[o]&&(i=R(null,n,o),i&&(t[o].p=i,f.insertBefore(i,N(e))))},A=(l,e,n)=>{for(let o=e;o<=n;++o){const e=l[o];if(e){const l=e.p;l&&(t=!0,l["s-ol"]?l["s-ol"].remove():P(l,!0),l.remove())}}},I=(l,e,n=!1)=>l.v===e.v&&("slot"===l.v?l.u===e.u:!!n||l.i===e.i),N=l=>l&&l["s-ol"]||l,F=l=>(l["s-ol"]?l["s-ol"]:l).parentNode,H=(l,e,t=!1)=>{const o=e.p=l.p,i=l.o,f=e.o,c=e.l;let r;null===c?(("slot"!==e.v||n)&&C(l,e,s),null!==i&&null!==f?((l,e,n,t,o=!1)=>{let s,i,f=0,c=0,r=0,u=0,a=e.length-1,$=e[0],d=e[a],v=t.length-1,y=t[0],p=t[v];for(;f<=a&&c<=v;)if(null==$)$=e[++f];else if(null==d)d=e[--a];else if(null==y)y=t[++c];else if(null==p)p=t[--v];else if(I($,y,o))H($,y,o),$=e[++f],y=t[++c];else if(I(d,p,o))H(d,p,o),d=e[--a],p=t[--v];else if(I($,p,o))"slot"!==$.v&&"slot"!==p.v||P($.p.parentNode,!1),H($,p,o),l.insertBefore($.p,d.p.nextSibling),$=e[++f],p=t[--v];else if(I(d,y,o))"slot"!==$.v&&"slot"!==p.v||P(d.p.parentNode,!1),H(d,y,o),l.insertBefore(d.p,$.p),d=e[--a],y=t[++c];else{for(r=-1,u=f;u<=a;++u)if(e[u]&&null!==e[u].i&&e[u].i===y.i){r=u;break}r>=0?(i=e[r],i.v!==y.v?s=R(e&&e[c],n,r):(H(i,y,o),e[r]=void 0,s=i.p),y=t[++c]):(s=R(e&&e[c],n,c),y=t[++c]),s&&F($.p).insertBefore(s,N($.p))}f>a?T(l,null==t[v+1]?null:t[v+1].p,n,t,c,v):c>v&&A(e,f,a)})(o,i,e,f,t):null!==f?(null!==l.l&&(o.textContent=""),T(o,null,e,f,0,f.length-1)):null!==i&&A(i,0,i.length-1)):(r=o["s-cr"])?r.parentNode.textContent=c:l.l!==c&&(o.data=c)},L=l=>{const e=l.childNodes;for(const l of e)if(1===l.nodeType){if(l["s-sr"]){const n=l["s-sn"];l.hidden=!1;for(const t of e)if(t!==l)if(t["s-hn"]!==l["s-hn"]||""!==n){if(1===t.nodeType&&(n===t.getAttribute("slot")||n===t["s-sn"])){l.hidden=!0;break}}else if(1===t.nodeType||3===t.nodeType&&""!==t.textContent.trim()){l.hidden=!0;break}}L(l)}},U=[],W=l=>{let e,n,o;for(const s of l.childNodes){if(s["s-sr"]&&(e=s["s-cr"])&&e.parentNode){n=e.parentNode.childNodes;const l=s["s-sn"];for(o=n.length-1;o>=0;o--)if(e=n[o],!e["s-cn"]&&!e["s-nr"]&&e["s-hn"]!==s["s-hn"])if(q(e,l)){let n=U.find((l=>l.O===e));t=!0,e["s-sn"]=e["s-sn"]||l,n?(n.O["s-sh"]=s["s-hn"],n.M=s):(e["s-sh"]=s["s-hn"],U.push({M:s,O:e})),e["s-sr"]&&U.map((l=>{q(l.O,e["s-sn"])&&(n=U.find((l=>l.O===e)),n&&!l.M&&(l.M=n.M))}))}else U.some((l=>l.O===e))||U.push({O:e})}1===s.nodeType&&W(s)}},q=(l,e)=>1===l.nodeType?null===l.getAttribute("slot")&&""===e||l.getAttribute("slot")===e:l["s-sn"]===e||""===e,V=(l,e)=>{e&&!l.C&&e["s-p"]&&e["s-p"].push(new Promise((e=>l.C=e)))},_=(l,e)=>{if(l.$|=16,!(4&l.$))return V(l,l.R),Sl((()=>z(l,e)));l.$|=512},z=(l,e)=>{const n=l.P;return B(void 0,(()=>G(l,n,e)))},B=(l,e)=>D(l)?l.then(e):e(),D=l=>l instanceof Promise||l&&l.then&&"function"==typeof l.then,G=async(l,e,n)=>{var t;const o=l.$hostElement$,s=o["s-rc"];n&&(l=>{const e=l.T;((l,e)=>{var n;const t=k(e),o=al.get(t);if(l=11===l.nodeType?l:dl,o)if("string"==typeof o){let s,i=g.get(l=l.head||l);if(i||g.set(l,i=new Set),!i.has(t)){if(l.host&&(s=l.querySelector(`[sty-id="${t}"]`)))s.innerHTML=o;else{s=dl.createElement("style"),s.innerHTML=o;const e=null!==(n=vl.A)&&void 0!==n?n:$(dl);null!=e&&s.setAttribute("nonce",e),l.insertBefore(s,l.querySelector("link"))}4&e.$&&(s.innerHTML+=r),i&&i.add(t)}}else l.adoptedStyleSheets.includes(o)||(l.adoptedStyleSheets=[...l.adoptedStyleSheets,o])})(l.$hostElement$.getRootNode(),e)})(l);J(l,e,o,n),s&&(s.map((l=>l())),o["s-rc"]=void 0);{const e=null!==(t=o["s-p"])&&void 0!==t?t:[],n=()=>K(l);0===e.length?n():(Promise.all(e).then(n),l.$|=4,e.length=0)}},J=(s,i,f,c)=>{try{i=i.render(),s.$&=-17,s.$|=2,((s,i,f=!1)=>{var c,r,u,a;const $=s.$hostElement$,p=s.T,h=s.I||v(null,null),m=(l=>l&&l.v===y)(i)?i:d(null,null,i);if(e=$.tagName,p.N&&(m.t=m.t||{},p.N.map((([l,e])=>m.t[e]=$[l]))),f&&m.t)for(const l of Object.keys(m.t))$.hasAttribute(l)&&!["key","ref","style","class"].includes(l)&&(m.t[l]=$[l]);if(m.v=null,m.$|=4,s.I=m,m.p=h.p=$,n=!!(1&p.$),l=$["s-cr"],t=!1,H(h,m,f),vl.$|=1,o){W(m.p);for(const l of U){const e=l.O;if(!e["s-ol"]){const l=dl.createTextNode("");l["s-nr"]=e,e.parentNode.insertBefore(e["s-ol"]=l,e)}}for(const l of U){const e=l.O,n=l.M;if(n){const l=n.parentNode;let t=n.nextSibling;{let n=null===(c=e["s-ol"])||void 0===c?void 0:c.previousSibling;for(;n;){let o=null!==(r=n["s-nr"])&&void 0!==r?r:null;if(o&&o["s-sn"]===e["s-sn"]&&l===o.parentNode){for(o=o.nextSibling;o===e||(null==o?void 0:o["s-sr"]);)o=null==o?void 0:o.nextSibling;if(!o||!o["s-nr"]){t=o;break}}n=n.previousSibling}}(!t&&l!==e.parentNode||e.nextSibling!==t)&&e!==t&&(!e["s-hn"]&&e["s-ol"]&&(e["s-hn"]=e["s-ol"].parentNode.nodeName),l.insertBefore(e,t),1===e.nodeType&&(e.hidden=null!==(u=e["s-ih"])&&void 0!==u&&u)),e&&"function"==typeof n["s-rf"]&&n["s-rf"](e)}else 1===e.nodeType&&(f&&(e["s-ih"]=null!==(a=e.hidden)&&void 0!==a&&a),e.hidden=!0)}}t&&L(m.p),vl.$&=-2,U.length=0,l=void 0})(s,i,c)}catch(l){cl(l,s.$hostElement$)}return null},K=l=>{const e=l.$hostElement$,n=l.R;64&l.$||(l.$|=64,X(e),l.F(e),n||Q()),l.C&&(l.C(),l.C=void 0),512&l.$&&jl((()=>_(l,!1))),l.$&=-517},Q=()=>{X(dl.documentElement),jl((()=>(l=>{const e=vl.ce("appload",{detail:{namespace:"bulmil"}});return l.dispatchEvent(e),e})($l)))},X=l=>l.classList.add("hydrated"),Y=(l,e,n)=>{var t;const o=l.prototype;if(e.H){const s=Object.entries(e.H);if(s.map((([l,[t]])=>{(31&t||2&n&&32&t)&&Object.defineProperty(o,l,{get(){return((l,e)=>ol(this).L.get(e))(0,l)},set(n){((l,e,n,t)=>{const o=ol(l),s=o.L.get(e),i=o.$,f=o.P;n=((l,e)=>null==l||a(l)?l:4&e?"false"!==l&&(""===l||!!l):2&e?parseFloat(l):1&e?l+"":l)(n,t.H[e][0]),8&i&&void 0!==s||n===s||Number.isNaN(s)&&Number.isNaN(n)||(o.L.set(e,n),f&&2==(18&i)&&_(o,!1))})(this,l,n,e)},configurable:!0,enumerable:!0})})),1&n){const n=new Map;o.attributeChangedCallback=function(l,t,s){vl.jmp((()=>{var i;const f=n.get(l);if(this.hasOwnProperty(f))s=this[f],delete this[f];else{if(o.hasOwnProperty(f)&&"number"==typeof this[f]&&this[f]==s)return;if(null==f){const n=ol(this),o=null==n?void 0:n.$;if(o&&!(8&o)&&128&o&&s!==t){const o=n.P,f=null===(i=e.U)||void 0===i?void 0:i[l];null==f||f.forEach((e=>{null!=o[e]&&o[e].call(o,s,t,l)}))}return}}this[f]=(null!==s||"boolean"!=typeof this[f])&&s}))},l.observedAttributes=Array.from(new Set([...Object.keys(null!==(t=e.U)&&void 0!==t?t:{}),...s.filter((([l,e])=>15&e[0])).map((([l,t])=>{var o;const s=t[1]||l;return n.set(s,l),512&t[0]&&(null===(o=e.N)||void 0===o||o.push([l,s])),s}))]))}}return l},Z=l=>{if(!(1&vl.$)){const e=ol(l),n=e.T,t=()=>{};if(1&e.$)(null==e?void 0:e.P)||(null==e?void 0:e.W)&&e.W.then((()=>{}));else{let t;e.$|=1,t=l.getAttribute(f),t&&((l,e,n,t)=>{const o=l.shadowRoot,s=[],i=t.I=v(e,null);vl.q||w(dl.body,vl.q=new Map),l[f]=n,l.removeAttribute(f),b(i,s,[],null,l,l,n),s.map((l=>{const n=l.h+"."+l.m,t=vl.q.get(n),s=l.p;t&&yl&&""===t["s-en"]&&t.parentNode.insertBefore(s,t.nextSibling),o||(s["s-hn"]=e,t&&(s["s-ol"]=t,s["s-ol"]["s-nr"]=s)),vl.q.delete(n)}))})(l,n.S,t,e),t||12&n.$&&ll(l);{let n=l;for(;n=n.parentNode||n.host;)if(1===n.nodeType&&n.hasAttribute("s-id")&&n["s-p"]||n["s-p"]){V(e,e.R=n);break}}n.H&&Object.entries(n.H).map((([e,[n]])=>{if(31&n&&l.hasOwnProperty(e)){const n=l[e];delete l[e],l[e]=n}})),(async(l,e,n)=>{let t;if(!(32&e.$)){if(e.$|=32,n.V){if(t=ul(n),t.then){const l=()=>{};t=await t,l()}t.isProxied||(Y(t,n,2),t.isProxied=!0);const l=()=>{};e.$|=8;try{new t(e)}catch(l){cl(l)}e.$&=-9,l()}else t=l.constructor,customElements.whenDefined(n.S).then((()=>e.$|=128));if(t.style){let l=t.style;const e=k(n);if(!al.has(e)){const t=()=>{};((l,e,n)=>{let t=al.get(l);hl&&n?(t=t||new CSSStyleSheet,"string"==typeof t?t=e:t.replaceSync(e)):t=e,al.set(l,t)})(e,l,!!(1&n.$)),t()}}}const o=e.R,s=()=>_(e,!0);o&&o["s-rc"]?o["s-rc"].push(s):s()})(l,e,n)}t()}},ll=l=>{const e=l["s-cr"]=dl.createComment("");e["s-cn"]=!0,l.insertBefore(e,l.firstChild)},el=(l,e={})=>{var n;const t=[],o=e.exclude||[],s=$l.customElements,i=dl.head,f=i.querySelector("meta[charset]"),c=dl.createElement("style"),u=[];let a,d=!0;Object.assign(vl,e),vl._=new URL(e.resourcesUrl||"./",dl.baseURI).href,vl.$|=2;let v=!1;if(l.map((l=>{l[1].map((e=>{const n={$:e[0],S:e[1],H:e[2],B:e[3]};4&n.$&&(v=!0),n.H=e[2],n.N=[];const i=n.S,f=class extends HTMLElement{constructor(l){super(l),il(l=this,n)}connectedCallback(){a&&(clearTimeout(a),a=null),d?u.push(this):vl.jmp((()=>Z(this)))}disconnectedCallback(){vl.jmp((()=>(async()=>{if(!(1&vl.$)){const l=ol(this);(null==l?void 0:l.P)||(null==l?void 0:l.W)&&l.W.then((()=>{}))}})()))}componentOnReady(){return ol(this).W}};n.V=l[0],o.includes(i)||s.get(i)||(t.push(i),s.define(i,Y(f,n,1)))}))})),t.length>0&&(v&&(c.textContent+=r),c.textContent+=t+"{visibility:hidden}.hydrated{visibility:inherit}",c.innerHTML.length)){c.setAttribute("data-styles","");const l=null!==(n=vl.A)&&void 0!==n?n:$(dl);null!=l&&c.setAttribute("nonce",l),i.insertBefore(c,f?f.nextSibling:i.firstChild)}d=!1,u.length?u.map((l=>l.connectedCallback())):vl.jmp((()=>a=setTimeout(Q,30)))},nl=l=>vl.A=l,tl=new WeakMap,ol=l=>tl.get(l),sl=(l,e)=>tl.set(e.P=l,e),il=(l,e)=>{const n={$:0,$hostElement$:l,T:e,L:new Map};return n.W=new Promise((l=>n.F=l)),l["s-p"]=[],l["s-rc"]=[],tl.set(l,n)},fl=(l,e)=>e in l,cl=(l,e)=>(0,console.error)(l,e),rl=new Map,ul=l=>{const e=l.S.replace(/-/g,"_"),n=l.V,t=rl.get(n);return t?t[e]:import(`./${n}.entry.js`).then((l=>(rl.set(n,l),l[e])),cl) /*!__STENCIL_STATIC_IMPORT_SWITCH__*/},al=new Map,$l="undefined"!=typeof window?window:{},dl=$l.document||{head:{}},vl={$:0,_:"",jmp:l=>l(),raf:l=>requestAnimationFrame(l),ael:(l,e,n,t)=>l.addEventListener(e,n,t),rel:(l,e,n,t)=>l.removeEventListener(e,n,t),ce:(l,e)=>new CustomEvent(l,e)},yl=!0,pl=l=>Promise.resolve(l),hl=(()=>{try{return new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync}catch(l){}return!1})(),ml=[],bl=[],wl=(l,e)=>n=>{l.push(n),i||(i=!0,e&&4&vl.$?jl(kl):vl.raf(kl))},gl=l=>{for(let e=0;e<l.length;e++)try{l[e](performance.now())}catch(l){cl(l)}l.length=0},kl=()=>{gl(ml),gl(bl),(i=ml.length>0)&&vl.raf(kl)},jl=l=>pl().then(l),Sl=wl(bl,!0);export{y as H,el as b,d as h,pl as p,sl as r,nl as s}