bilibili-bangumi-component
Version:
展示 bilibili 与 Bangumi 追番列表的 WebComponent 组件
2 lines • 10 kB
JavaScript
let e,n,t=!1;const l="slot-fb{display:contents}slot-fb[hidden]{display:none}",o={},s=e=>"object"==(e=typeof e)||"function"===e;function i(e){var n,t,l;return null!==(l=null===(t=null===(n=e.head)||void 0===n?void 0:n.querySelector('meta[name="csp-nonce"]'))||void 0===t?void 0:t.getAttribute("content"))&&void 0!==l?l:void 0}const c=(e,n,...t)=>{let l=null,o=null,i=!1,c=!1;const u=[],a=n=>{for(let t=0;t<n.length;t++)l=n[t],Array.isArray(l)?a(l):null!=l&&"boolean"!=typeof l&&((i="function"!=typeof e&&!s(l))&&(l+=""),i&&c?u[u.length-1].t+=l:u.push(i?r(null,l):l),c=i)};if(a(t),n){n.key&&(o=n.key);{const e=n.className||n.class;e&&(n.class="object"!=typeof e?e:Object.keys(e).filter((n=>e[n])).join(" "))}}if("function"==typeof e)return e(null===n?{}:n,u,f);const d=r(e,null);return d.l=n,u.length>0&&(d.o=u),d.i=o,d},r=(e,n)=>({u:0,p:e,t:n,v:null,o:null,l:null,i:null}),u={},f={forEach:(e,n)=>e.map(a).forEach(n),map:(e,n)=>e.map(a).map(n).map(d)},a=e=>({vattrs:e.l,vchildren:e.o,vkey:e.i,vname:e.h,vtag:e.p,vtext:e.t}),d=e=>{if("function"==typeof e.vtag){const n=Object.assign({},e.vattrs);return e.vkey&&(n.key=e.vkey),e.vname&&(n.name=e.vname),c(e.vtag,n,...e.vchildren||[])}const n=r(e.vtag,e.vtext);return n.l=e.vattrs,n.o=e.vchildren,n.i=e.vkey,n.h=e.vname,n},y=new WeakMap,p=e=>"sc-"+e.m,v=(e,n,t,l,o,i)=>{if(t!==l){let c=B(e,n),r=n.toLowerCase();if("class"===n){const n=e.classList,o=m(t),s=m(l);n.remove(...o.filter((e=>e&&!s.includes(e)))),n.add(...s.filter((e=>e&&!o.includes(e))))}else if("style"===n){for(const n in t)l&&null!=l[n]||(n.includes("-")?e.style.removeProperty(n):e.style[n]="");for(const n in l)t&&l[n]===t[n]||(n.includes("-")?e.style.setProperty(n,l[n]):e.style[n]=l[n])}else if("key"===n);else if("ref"===n)l&&l(e);else if(c||"o"!==n[0]||"n"!==n[1]){const r=s(l);if((c||r&&null!==l)&&!o)try{if(e.tagName.includes("-"))e[n]=l;else{const o=null==l?"":l;"list"===n?c=!1:null!=t&&e[n]==o||(e[n]=o)}}catch(e){}null==l||!1===l?!1===l&&""!==e.getAttribute(n)||e.removeAttribute(n):(!c||4&i||o)&&!r&&e.setAttribute(n,l=!0===l?"":l)}else if(n="-"===n[2]?n.slice(3):B(Q,r)?r.slice(2):r[2]+n.slice(3),t||l){const o=n.endsWith($);n=n.replace(b,""),t&&Y.rel(e,n,t,o),l&&Y.ael(e,n,l,o)}}},h=/\s/,m=e=>e?e.split(h):[],$="Capture",b=RegExp($+"$"),w=(e,n,t,l)=>{const s=11===n.v.nodeType&&n.v.host?n.v.host:n.v,i=e&&e.l||o,c=n.l||o;for(l in i)l in c||v(s,l,i[l],void 0,t,n.u);for(l in c)v(s,l,i[l],c[l],t,n.u)},g=(t,l,o)=>{const s=l.o[o];let i,c,r=0;if(null!==s.t)i=s.v=X.createTextNode(s.t);else if(i=s.v=X.createElement(s.p),w(null,s,!1),null!=e&&i["s-si"]!==e&&i.classList.add(i["s-si"]=e),s.o)for(r=0;r<s.o.length;++r)c=g(t,s,r),c&&i.appendChild(c);return i["s-hn"]=n,i},S=(e,t,l,o,s,i)=>{let c,r=e;for(r.shadowRoot&&r.tagName===n&&(r=r.shadowRoot);s<=i;++s)o[s]&&(c=g(null,l,s),c&&(o[s].v=c,r.insertBefore(c,t)))},j=(e,n,t)=>{for(let l=n;l<=t;++l){const n=e[l];if(n){const e=n.v;M(n),e&&e.remove()}}},k=(e,n,t=!1)=>e.p===n.p&&(!!t||e.i===n.i),O=(e,n,t=!1)=>{const l=n.v=e.v,o=e.o,s=n.o,i=n.t;null===i?(w(e,n,!1),null!==o&&null!==s?((e,n,t,l,o=!1)=>{let s,i,c=0,r=0,u=0,f=0,a=n.length-1,d=n[0],y=n[a],p=l.length-1,v=l[0],h=l[p];for(;c<=a&&r<=p;)if(null==d)d=n[++c];else if(null==y)y=n[--a];else if(null==v)v=l[++r];else if(null==h)h=l[--p];else if(k(d,v,o))O(d,v,o),d=n[++c],v=l[++r];else if(k(y,h,o))O(y,h,o),y=n[--a],h=l[--p];else if(k(d,h,o))O(d,h,o),e.insertBefore(d.v,y.v.nextSibling),d=n[++c],h=l[--p];else if(k(y,v,o))O(y,v,o),e.insertBefore(y.v,d.v),y=n[--a],v=l[++r];else{for(u=-1,f=c;f<=a;++f)if(n[f]&&null!==n[f].i&&n[f].i===v.i){u=f;break}u>=0?(i=n[u],i.p!==v.p?s=g(n&&n[r],t,u):(O(i,v,o),n[u]=void 0,s=i.v),v=l[++r]):(s=g(n&&n[r],t,r),v=l[++r]),s&&d.v.parentNode.insertBefore(s,d.v)}c>a?S(e,null==l[p+1]?null:l[p+1].v,t,l,r,p):r>p&&j(n,c,a)})(l,o,n,s,t):null!==s?(null!==e.t&&(l.textContent=""),S(l,null,n,s,0,s.length-1)):null!==o&&j(o,0,o.length-1)):e.t!==i&&(l.data=i)},M=e=>{e.l&&e.l.ref&&e.l.ref(null),e.o&&e.o.map(M)},C=(e,n)=>{n&&!e.$&&n["s-p"]&&n["s-p"].push(new Promise((n=>e.$=n)))},x=(e,n)=>{if(e.u|=16,!(4&e.u))return C(e,e.S),ce((()=>E(e,n)));e.u|=512},E=(e,n)=>{const t=e.j;let l;return n&&(l=W(t,"componentWillLoad")),P(l,(()=>A(e,t,n)))},P=(e,n)=>L(e)?e.then(n):n(),L=e=>e instanceof Promise||e&&e.then&&"function"==typeof e.then,A=async(e,n,t)=>{var o;const s=e.$hostElement$,c=s["s-rc"];t&&(e=>{const n=e.k,t=e.$hostElement$,o=n.u,s=((e,n)=>{var t;const o=p(n),s=K.get(o);if(e=11===e.nodeType?e:X,s)if("string"==typeof s){let c,r=y.get(e=e.head||e);if(r||y.set(e,r=new Set),!r.has(o)){{c=X.createElement("style"),c.innerHTML=s;const n=null!==(t=Y.O)&&void 0!==t?t:i(X);null!=n&&c.setAttribute("nonce",n),e.insertBefore(c,e.querySelector("link"))}4&n.u&&(c.innerHTML+=l),r&&r.add(o)}}else e.adoptedStyleSheets.includes(s)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,s]);return o})(t.shadowRoot?t.shadowRoot:t.getRootNode(),n);10&o&&(t["s-sc"]=s,t.classList.add(s+"-h"))})(e);N(e,n,s,t),c&&(c.map((e=>e())),s["s-rc"]=void 0);{const n=null!==(o=s["s-p"])&&void 0!==o?o:[],t=()=>R(e);0===n.length?t():(Promise.all(n).then(t),e.u|=4,n.length=0)}},N=(t,l,o,s)=>{try{l=l.render(),t.u&=-17,t.u|=2,((t,l,o=!1)=>{const s=t.$hostElement$,i=t.M||r(null,null),f=(e=>e&&e.p===u)(l)?l:c(null,null,l);if(n=s.tagName,o&&f.l)for(const e of Object.keys(f.l))s.hasAttribute(e)&&!["key","ref","style","class"].includes(e)&&(f.l[e]=s[e]);f.p=null,f.u|=4,t.M=f,f.v=i.v=s.shadowRoot||s,e=s["s-sc"],O(i,f,o)})(t,l,s)}catch(e){G(e,t.$hostElement$)}return null},R=e=>{const n=e.$hostElement$,t=e.j,l=e.S;64&e.u||(e.u|=64,F(n),W(t,"componentDidLoad"),e.C(n),l||T()),e.$&&(e.$(),e.$=void 0),512&e.u&&ie((()=>x(e,!1))),e.u&=-517},T=()=>{F(X.documentElement),ie((()=>(e=>{const n=Y.ce("appload",{detail:{namespace:"bilibili-bangumi-component"}});return e.dispatchEvent(n),n})(Q)))},W=(e,n,t)=>{if(e&&e[n])try{return e[n](t)}catch(e){G(e)}},F=e=>e.classList.add("hydrated"),U=(e,n,t)=>{var l;const o=e.prototype;if(n.P){const i=Object.entries(n.P);if(i.map((([e,[l]])=>{(31&l||2&t&&32&l)&&Object.defineProperty(o,e,{get(){return((e,n)=>V(this).L.get(n))(0,e)},set(t){((e,n,t,l)=>{const o=V(e),i=o.L.get(n),c=o.u,r=o.j;t=((e,n)=>null==e||s(e)?e:4&n?"false"!==e&&(""===e||!!e):2&n?parseFloat(e):1&n?e+"":e)(t,l.P[n][0]),8&c&&void 0!==i||t===i||Number.isNaN(i)&&Number.isNaN(t)||(o.L.set(n,t),r&&2==(18&c)&&x(o,!1))})(this,e,t,n)},configurable:!0,enumerable:!0})})),1&t){const t=new Map;o.attributeChangedCallback=function(e,l,s){Y.jmp((()=>{var i;const c=t.get(e);if(this.hasOwnProperty(c))s=this[c],delete this[c];else{if(o.hasOwnProperty(c)&&"number"==typeof this[c]&&this[c]==s)return;if(null==c){const t=V(this),o=null==t?void 0:t.u;if(o&&!(8&o)&&128&o&&s!==l){const o=t.j,c=null===(i=n.A)||void 0===i?void 0:i[e];null==c||c.forEach((n=>{null!=o[n]&&o[n].call(o,s,l,e)}))}return}}this[c]=(null!==s||"boolean"!=typeof this[c])&&s}))},e.observedAttributes=Array.from(new Set([...Object.keys(null!==(l=n.A)&&void 0!==l?l:{}),...i.filter((([e,n])=>15&n[0])).map((([e,n])=>{const l=n[1]||e;return t.set(l,e),l}))]))}}return e},q=(e,n={})=>{var t;const o=[],s=n.exclude||[],c=Q.customElements,r=X.head,u=r.querySelector("meta[charset]"),f=X.createElement("style"),a=[];let d,y=!0;Object.assign(Y,n),Y.N=new URL(n.resourcesUrl||"./",X.baseURI).href;let v=!1;if(e.map((e=>{e[1].map((n=>{const t={u:n[0],m:n[1],P:n[2],R:n[3]};4&t.u&&(v=!0),t.P=n[2];const l=t.m,i=class extends HTMLElement{constructor(e){super(e),z(e=this,t),1&t.u&&e.attachShadow({mode:"open"})}connectedCallback(){d&&(clearTimeout(d),d=null),y?a.push(this):Y.jmp((()=>(e=>{if(0==(1&Y.u)){const n=V(e),t=n.k,l=()=>{};if(1&n.u)(null==n?void 0:n.j)||(null==n?void 0:n.T)&&n.T.then((()=>{}));else{n.u|=1;{let t=e;for(;t=t.parentNode||t.host;)if(t["s-p"]){C(n,n.S=t);break}}t.P&&Object.entries(t.P).map((([n,[t]])=>{if(31&t&&e.hasOwnProperty(n)){const t=e[n];delete e[n],e[n]=t}})),(async(e,n,t)=>{let l;if(0==(32&n.u)){n.u|=32;{if(l=J(t),l.then){const e=()=>{};l=await l,e()}l.isProxied||(U(l,t,2),l.isProxied=!0);const e=()=>{};n.u|=8;try{new l(n)}catch(e){G(e)}n.u&=-9,e()}if(l.style){let e=l.style;const n=p(t);if(!K.has(n)){const l=()=>{};((e,n,t)=>{let l=K.get(e);ee&&t?(l=l||new CSSStyleSheet,"string"==typeof l?l=n:l.replaceSync(n)):l=n,K.set(e,l)})(n,e,!!(1&t.u)),l()}}}const o=n.S,s=()=>x(n,!0);o&&o["s-rc"]?o["s-rc"].push(s):s()})(0,n,t)}l()}})(this)))}disconnectedCallback(){Y.jmp((()=>(async()=>{if(0==(1&Y.u)){const e=V(this);(null==e?void 0:e.j)||(null==e?void 0:e.T)&&e.T.then((()=>{}))}})()))}componentOnReady(){return V(this).T}};t.W=e[0],s.includes(l)||c.get(l)||(o.push(l),c.define(l,U(i,t,1)))}))})),v&&(f.innerHTML+=l),f.innerHTML+=o+"{visibility:hidden}.hydrated{visibility:inherit}",f.innerHTML.length){f.setAttribute("data-styles","");const e=null!==(t=Y.O)&&void 0!==t?t:i(X);null!=e&&f.setAttribute("nonce",e),r.insertBefore(f,u?u.nextSibling:r.firstChild)}y=!1,a.length?a.map((e=>e.connectedCallback())):Y.jmp((()=>d=setTimeout(T,30)))},D=e=>Y.O=e,H=new WeakMap,V=e=>H.get(e),_=(e,n)=>H.set(n.j=e,n),z=(e,n)=>{const t={u:0,$hostElement$:e,k:n,L:new Map};return t.T=new Promise((e=>t.C=e)),e["s-p"]=[],e["s-rc"]=[],H.set(e,t)},B=(e,n)=>n in e,G=(e,n)=>(0,console.error)(e,n),I=new Map,J=e=>{const n=e.m.replace(/-/g,"_"),t=e.W,l=I.get(t);return l?l[n]:import(`./${t}.entry.js`).then((e=>(I.set(t,e),e[n])),G)
/*!__STENCIL_STATIC_IMPORT_SWITCH__*/},K=new Map,Q="undefined"!=typeof window?window:{},X=Q.document||{head:{}},Y={u:0,N:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,n,t,l)=>e.addEventListener(n,t,l),rel:(e,n,t,l)=>e.removeEventListener(n,t,l),ce:(e,n)=>new CustomEvent(e,n)},Z=e=>Promise.resolve(e),ee=(()=>{try{return new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync}catch(e){}return!1})(),ne=[],te=[],le=(e,n)=>l=>{e.push(l),t||(t=!0,n&&4&Y.u?ie(se):Y.raf(se))},oe=e=>{for(let n=0;n<e.length;n++)try{e[n](performance.now())}catch(e){G(e)}e.length=0},se=()=>{oe(ne),oe(te),(t=ne.length>0)&&Y.raf(se)},ie=e=>Z().then(e),ce=le(te,!0);export{q as b,c as h,Z as p,_ as r,D as s}