mirror of
https://github.com/jlengrand/webcomponentsjs.git
synced 2026-03-10 08:51:22 +00:00
3 lines
34 KiB
JavaScript
3 lines
34 KiB
JavaScript
(function(){'use strict';function d(we){return we=y(we),_(h(we),we)}function y(we){return we.replace(B.comments,'').replace(B.port,'')}function h(we){let Ue={start:0,end:we.length},ke=Ue;for(let De=0,He=we.length;De<He;De++)if(we[De]===q){ke.rules||(ke.rules=[]);let Fe=ke,je=Fe.rules[Fe.rules.length-1];ke={start:De+1,parent:Fe,previous:je},Fe.rules.push(ke)}else we[De]===K&&(ke.end=De+1,ke=ke.parent||Ue);return Ue}function _(we,Ue){let ke=Ue.substring(we.start,we.end-1);if(we.parsedCssText=we.cssText=ke.trim(),we.parent){let He=we.previous?we.previous.end:we.parent.start;ke=Ue.substring(He,we.start-1),ke=S(ke),ke=ke.replace(B.multipleSpaces,' '),ke=ke.substring(ke.lastIndexOf(';')+1);let Fe=we.parsedSelector=we.selector=ke.trim();we.atRule=0===Fe.indexOf('@'),we.atRule?0===Fe.indexOf('@media')?we.type=F.MEDIA_RULE:Fe.match(B.keyframesRule)&&(we.type=F.KEYFRAMES_RULE,we.keyframesName=we.selector.split(B.multipleSpaces).pop()):0===Fe.indexOf(X)?we.type=F.MIXIN_RULE:we.type=F.STYLE_RULE}let De=we.rules;if(De)for(let je,He=0,Fe=De.length;He<Fe&&(je=De[He]);He++)_(je,Ue);return we}function S(we){return we.replace(/\\([0-9a-f]{1,6})\s/gi,function(){let Ue=arguments[1],ke=6-Ue.length;for(;ke--;)Ue='0'+Ue;return'\\'+Ue})}function g(we,Ue,ke){ke=ke||'';let De='';if(we.cssText||we.rules){let He=we.rules;if(He&&!C(He))for(let qe,Fe=0,je=He.length;Fe<je&&(qe=He[Fe]);Fe++)De=g(qe,Ue,De);else De=Ue?we.cssText:A(we.cssText),De=De.trim(),De&&(De=' '+De+'\n')}return De&&(we.selector&&(ke+=we.selector+' '+q+'\n'),ke+=De,we.selector&&(ke+=K+'\n\n')),ke}function C(we){return 0===we[0].selector.indexOf(X)}function A(we){return we=E(we),N(we)}function E(we){return we.replace(B.customProp,'').replace(B.mixinProp,'')}function N(we){return we.replace(B.mixinApply,'').replace(B.varApply,'')}function b(we){we&&(Y=Y&&!we.shimcssproperties,V=V&&!we.shimshadow)}function T(we,Ue){return'string'==typeof we&&(we=d(we)),Ue&&P(we,Ue),g(we,Y)}function R(we){return!we.__cssRules&&we.textContent&&(we.__cssRules=d(we.textContent)),we.__cssRules}function I(we){return we.parent&&we.parent.type===F.KEYFRAMES_RULE}function P(we,Ue,ke,De){if(we){let He=!1;if(De&&we.type===F.MEDIA_RULE){let je=we.selector.match(z.MEDIA_MATCH);je&&!window.matchMedia(je[1]).matches&&(He=!0)}we.type===F.STYLE_RULE?Ue(we):ke&&we.type===F.KEYFRAMES_RULE?ke(we):we.type===F.MIXIN_RULE&&(He=!0);let Fe=we.rules;if(Fe&&!He)for(let Ke,je=0,qe=Fe.length;je<qe&&(Ke=Fe[je]);je++)P(Ke,Ue,ke,De)}}function M(we,Ue,ke,De){let He=L(we,Ue);return O(He,ke,De)}function O(we,Ue,ke){Ue=Ue||document.head;let De=ke&&ke.nextSibling||Ue.firstChild;return W=we,Ue.insertBefore(we,De)}function L(we,Ue){let ke=document.createElement('style');return Ue&&ke.setAttribute('scope',Ue),ke.textContent=we,ke}function w(we){let Ue=document.createComment(' Shady DOM styles for '+we+' '),ke=W?W.nextSibling:null,De=document.head;return De.insertBefore(Ue,ke||De.firstChild),W=Ue,Ue}function U(we,Ue){let ke=0;for(let De=Ue,He=we.length;De<He;De++)if('('===we[De])ke++;else if(')'===we[De]&&0==--ke)return De;return-1}function k(we,Ue){let ke=we.indexOf('var(');if(-1===ke)return Ue(we,'','','');let De=U(we,ke+3),He=we.substring(ke+4,De),Fe=we.substring(0,ke),je=k(we.substring(De+1),Ue),qe=He.indexOf(',');if(-1===qe)return Ue(Fe,He.trim(),'',je);let Ke=He.substring(0,qe).trim(),Be=He.substring(qe+1).trim();return Ue(Fe,Ke,Be,je)}function D(we,Ue){window.ShadyDOM?window.ShadyDOM.nativeMethods.setAttribute.call(we,'class',Ue):we.setAttribute('class',Ue)}function H(we,Ue){let ke=parseInt(we/32);Ue[ke]=(Ue[ke]||0)|1<<we%32}(function(we){function Ue(ft){return ft.nodeType===Node.ELEMENT_NODE&&ct.call(ft,Je)}function ke(ft,_t){mt.forEach(St=>{const gt=ft.attributes[St],Ct=gt&>.value;Ct&&0>Ct.search(/({{|\[\[)/)&&(gt.value='style'===St?nt.resolveUrlsInCssText(Ct,_t):nt.replaceAttrUrl(Ct,_t))})}function De(ft,_t){const St=ft.content;if(St){const gt=St.querySelectorAll('style, form[action], [src], [href], [url], [style]');for(let Ct=0;Ct<gt.length;Ct++){const xt=gt[Ct];'style'==xt.localName?nt.resolveUrlsInStyle(xt,_t):ke(xt,_t)}He(St,_t)}}function He(ft,_t){const St=ft.querySelectorAll('template');for(let gt=0;gt<St.length;gt++)De(St[gt],_t)}function Fe(ft,_t){const St=ft.querySelectorAll(dt);for(let xt,gt=0,Ct=St.length;gt<Ct&&(xt=St[gt]);gt++)Ve(xt),xt.href&&xt.setAttribute('href',nt.replaceAttrUrl(xt.getAttribute('href'),_t)),xt.src&&xt.setAttribute('src',nt.replaceAttrUrl(xt.getAttribute('src'),_t)),'style'==xt.localName?nt.resolveUrlsInStyle(xt,_t):'script'===xt.localName&&(xt.textContent&&(xt.textContent+=`\n//# sourceURL=${_t}`),xt.setAttribute('type',ut));He(ft,_t)}function je(ft,_t){const St=ft.querySelectorAll('dom-module');for(let gt=0;gt<St.length;gt++){const Ct=St[gt],xt=Ct.getAttribute('assetpath')||'';Ct.setAttribute('assetpath',nt.replaceAttrUrl(xt,_t))}}function qe(ft){const _t=ft.querySelectorAll(`script[type=${ut}]`);let St=Promise.resolve();for(let xt,gt=0,Ct=_t.length;gt<Ct&&(xt=_t[gt]);gt++)St=St.then(()=>{const At=ft.createElement('script');At.textContent=xt.textContent,xt.src&&At.setAttribute('src',xt.getAttribute('src'));const vt=Ve(At).catch(()=>At);return et=At,xt.parentNode.replaceChild(At,xt),vt.then(Et=>{Et===et&&(et=null)})});return St}function Ke(ft){const _t=ft.querySelectorAll(pt),St=[];for(let xt,gt=0,Ct=_t.length;gt<Ct&&(xt=_t[gt]);gt++)St.push(Ve(xt).catch(()=>xt));return Promise.all(St)}function Be(ft){const _t=ft.import.querySelectorAll(it);for(let Ct,St=0,gt=_t.length;St<gt&&(Ct=_t[St]);St++){const xt=document.createElement(Ct.localName);Ve(xt),xt.textContent=Ct.textContent;for(let At=0,vt=Ct.attributes.length;At<vt;At++)xt.setAttribute(Ct.attributes[At].name,Ct.attributes[At].value);Ct.parentNode.removeChild(Ct),ft.parentNode.insertBefore(xt,ft)}}function Xe(ft){const _t=ft.querySelectorAll(Je);for(let gt,St=_t.length-1;0<=St&&(gt=_t[St]);St--)if(!gt.__fired){gt.__fired=!0;const Ct=gt.import?'load':'error';Qe.log&&console.warn('fire',Ct,gt.href),Ve(gt),gt.dispatchEvent(new CustomEvent(Ct,{bubbles:!1,cancelable:!1,detail:void 0}))}}function Ve(ft){return ft.__loadPromise||(ft.__loadPromise=new Promise((_t,St)=>{Ye(ft)?_t(ft):(ft.addEventListener('load',()=>_t(ft)),ft.addEventListener('error',()=>St(ft)))})),ft.__loadPromise}function Ye(ft){let _t=!1;if(Ze&&Ue(ft)&&ft.import&&'loading'!==ft.import.readyState)_t=!0;else if(!(yt&&'style'===ft.localName))'script'!==ft.localName||ft.src||(_t=!0);else if(-1==ft.textContent.indexOf('@import'))_t=!0;else if(ft.sheet){_t=!0;const St=ft.sheet.cssRules;for(let gt=0,Ct=St?St.length:0;gt<Ct&&_t;gt++)St[gt].type===CSSRule.IMPORT_RULE&&(_t=!!St[gt].styleSheet)}return _t}function Ge(ft,_t){const St=document.createElement('import-content');St.style.display='none',_t&&St.setAttribute('import-href',_t),ft&&(St.innerHTML=ft);const gt=St.querySelector('base');return gt&&(_t=nt._resolveUrl(gt.getAttribute('href'),_t),gt.parentNode.removeChild(gt)),je(St,_t),Fe(St,_t),St}function We(ft,_t){return _t=_t||document,ze(_t).then($e).then(St=>{return ft&&ft(St),St})}function ze(ft){return new Promise(_t=>{'loading'===ft.readyState?ft.addEventListener('readystatechange',()=>{'loading'!==ft.readyState&&_t(ft)}):_t(ft)})}function $e(ft){let _t=ft.querySelectorAll(Je);const St=[],gt={allImports:[],loadedImports:[],errorImports:[]};for(let At,Ct=0,xt=_t.length;Ct<xt&&(At=_t[Ct]);Ct++)ct.call(At,`${Je} ${Je}`)||(gt.allImports.push(At),St.push(Ve(At).then(vt=>{return gt.loadedImports.push(vt),vt}).catch(vt=>{return gt.errorImports.push(vt),vt})));return Promise.all(St).then(()=>gt)}const Je='link[rel=import]',Ze=!!('import'in document.createElement('link')),Qe={bust:!1,log:!1};let et=null;!1=='currentScript'in document&&Object.defineProperty(document,'currentScript',{get:function(){return et||('complete'===document.readyState?null:document.scripts[document.scripts.length-1])},configurable:!0});const tt=/(^\/)|(^#)|(^[\w-\d]*:)/,rt=/(url\()([^)]*)(\))/g,st=/(@import[\s]+(?!url\())([^;]*)(;)/g,nt={resolveUrlsInStyle:function(ft,_t){ft.textContent=nt.resolveUrlsInCssText(ft.textContent,_t)},resolveUrlsInCssText:function(ft,_t){let St=nt.replaceUrls(ft,_t,rt);return St=nt.replaceUrls(St,_t,st),St},replaceUrls:function(ft,_t,St){return ft.replace(St,function(gt,Ct,xt,At){let vt=xt.replace(/["']/g,'');return _t&&(vt=nt._resolveUrl(vt,_t)),Ct+'\''+vt+'\''+At})},replaceAttrUrl:function(ft,_t){return ft&&tt.test(ft)?ft:nt._resolveUrl(ft,_t)},_resolveUrl:function(ft,_t){if(void 0===nt.__workingURL){nt.__workingURL=!1;try{const gt=new URL('b','http://a');gt.pathname='c%20d',nt.__workingURL='http://a/c%20d'===gt.href}catch(gt){}}if(nt.__workingURL)return new URL(ft,_t).href;let St=nt.__tempDoc;return St||(St=document.implementation.createHTMLDocument('temp'),nt.__tempDoc=St,St.__base=St.createElement('base'),St.head.appendChild(St.__base),St.__anchor=St.createElement('a')),St.__base.href=_t,St.__anchor.href=ft,St.__anchor.href||ft}},ot={async:!0,load:function(ft,_t){const St=new XMLHttpRequest;return Qe.bust&&(ft+='?'+Math.random()),St.open('GET',ft,ot.async),St.addEventListener('readystatechange',()=>{if(4===St.readyState){let gt;try{const At=St.getResponseHeader('Location');At&&(gt='/'===At.substr(0,1)?location.origin+At:At)}catch(At){console.error(At.message)}const Ct=200<=St.status&&300>St.status||304===St.status||0===St.status,xt=St.response||St.responseText;_t(!Ct,xt,gt)}}),St.send(),St}};class lt{constructor(ft,_t){this.cache={},this.onload=ft,this.oncomplete=_t,this.inflight=0,this.pending={}}addNodes(ft){this.inflight+=ft.length;for(let gt,_t=0,St=ft.length;_t<St&&(gt=ft[_t]);_t++)this.require(gt);this.checkDone()}addNode(ft){this.inflight++,this.require(ft),this.checkDone()}require(ft){const _t=ft.src||ft.href;this.dedupe(_t,ft)||this.fetch(_t,ft)}dedupe(ft,_t){return this.pending[ft]?(this.pending[ft].push(_t),!0):this.cache[ft]?(this.onload(ft,_t,this.cache[ft]),this.tail(),!0):(this.pending[ft]=[_t],!1)}fetch(ft,_t){if(Qe.log&&console.log('fetch',ft,_t),!ft)this.receive(ft,_t,!0,'error: href must be specified');else if(ft.match(/^data:/)){const St=ft.split(','),gt=St[0];let Ct=St[1];Ct=-1<gt.indexOf(';base64')?atob(Ct):decodeURIComponent(Ct),this.receive(ft,_t,!1,Ct)}else ot.load(ft,(St,gt,Ct)=>this.receive(ft,_t,St,gt,Ct))}receive(ft,_t,St,gt,Ct){this.cache[ft]=gt;const xt=this.pending[ft];for(let Et,At=0,vt=xt.length;At<vt&&(Et=xt[At]);At++)this.onload(ft,Et,gt,St,Ct),this.tail();this.pending[ft]=null}tail(){--this.inflight,this.checkDone()}checkDone(){this.inflight||this.oncomplete()}}const it=['style:not([type])','link[rel=stylesheet][href]:not([type])'].join(','),pt=[`${Je} style:not([type])`,`${Je} link[rel=stylesheet][href]:not([type])`].join(','),dt=[Je,it,'script:not([type])','script[type="application/javascript"]','script[type="text/javascript"]'].join(','),ct=Element.prototype.matches||Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector,mt=['action','src','href','url','style'],ut='import-script',yt=/Trident/.test(navigator.userAgent),ht=!yt&&/Edge\/\d./i.test(navigator.userAgent);new class{constructor(_t){this.documents={},this._doc=_t;const St=_t.querySelectorAll(Je);for(let gt=0,Ct=St.length;gt<Ct;gt++)Ve(St[gt]);new MutationObserver(this._onMutation.bind(this)).observe(_t.head,{childList:!0}),Ze||(this._loader=new lt(this._onLoaded.bind(this),this._onLoadedAll.bind(this)),ze(_t).then(()=>this._loadSubtree(_t)))}_loadSubtree(_t){const St=_t.querySelectorAll(Je);this._loader.addNodes(St)}_onLoaded(_t,St,gt,Ct,xt){if(Qe.log&&console.log('loaded',_t,St),void 0===this.documents[_t])if(Ct)this.documents[_t]=null;else{const At=Ge(gt,xt||_t);this._loadSubtree(At),this.documents[_t]=At}}_onLoadedAll(){this._flatten(this._doc),Promise.all([qe(this._doc),Ke(this._doc)]).then(()=>Xe(this._doc))}_flatten(_t){const St=_t.querySelectorAll(Je);for(let xt,gt=0,Ct=St.length;gt<Ct&&(xt=St[gt]);gt++)xt.import=this.documents[xt.href],xt.import&&!xt.import.__firstImport&&(xt.import.__firstImport=xt,this._flatten(xt.import),_t===document&&((yt||ht)&&Be(xt),this._observe(xt.import)),xt.appendChild(xt.import))}_observe(_t){_t.__importObserver||(_t.__importObserver=new MutationObserver(this._onMutation.bind(this)),_t.__importObserver.observe(_t,{childList:!0,subtree:!0}))}_onMutation(_t){for(let gt,St=0;St<_t.length&&(gt=_t[St]);St++)for(let Ct=0,xt=gt.addedNodes?gt.addedNodes.length:0;Ct<xt;Ct++){const At=gt.addedNodes[Ct];At&&Ue(At)&&(Ze?Ve(At):this._loader.addNode(At))}}}(document),We(ft=>document.dispatchEvent(new CustomEvent('HTMLImportsLoaded',{cancelable:!0,bubbles:!0,detail:ft}))),we.useNative=Ze,we.whenReady=We})(window.HTMLImports=window.HTMLImports||{});let F={STYLE_RULE:1,KEYFRAMES_RULE:7,MEDIA_RULE:4,MIXIN_RULE:1e3},q='{',K='}',B={comments:/\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,port:/@import[^;]*;/gim,customProp:/(?:^[^;\-\s}]+)?--[^;{}]*?:[^{};]*?(?:[;\n]|$)/gim,mixinProp:/(?:^[^;\-\s}]+)?--[^;{}]*?:[^{};]*?{[^}]*?}(?:[;\n]|$)?/gim,mixinApply:/@apply\s*\(?[^);]*\)?\s*(?:[;\n]|$)?/gim,varApply:/[^;:]*?:[^;]*?var\([^;]*\)(?:[;\n]|$)?/gim,keyframesRule:/^@[^\s]*keyframes/,multipleSpaces:/\s+/g},X='--',V=!(window.ShadyDOM&&window.ShadyDOM.inUse),Y=!navigator.userAgent.match('AppleWebKit/601')&&window.CSS&&CSS.supports&&CSS.supports('box-shadow','0 0 0 var(--foo)'),G=!1;window.ShadyCSS?b(window.ShadyCSS):window.WebComponents&&b(window.WebComponents.flags);let W=null,z={VAR_ASSIGN:/(?:^|[;\s{]\s*)(--[\w-]*?)\s*:\s*(?:([^;{]*)|{([^}]*)})(?:(?=[;\s}])|$)/gi,MIXIN_MATCH:/(?:^|\W+)@apply\s*\(?([^);\n]*)\)?/gi,VAR_CONSUMED:/(--[\w-]+)\s*([:,;)]|$)/gi,ANIMATION_MATCH:/(animation\s*:)|(animation-name\s*:)/,MEDIA_MATCH:/@media[^(]*(\([^)]*\))/,IS_VAR:/^--/,BRACKETED:/\{[^}]*\}/g,HOST_PREFIX:'(?:^|[^.#[:])',HOST_SUFFIX:'($|[.:[\\s>+~])'};const $='style-scope';class J{get SCOPE_NAME(){return $}dom(we,Ue,ke){we.__styleScoped?we.__styleScoped=null:this._transformDom(we,Ue||'',ke)}_transformDom(we,Ue,ke){we.nodeType===Node.ELEMENT_NODE&&this.element(we,Ue,ke);let De='template'===we.localName?(we.content||we._content).childNodes:we.children||we.childNodes;if(De)for(let He=0;He<De.length;He++)this._transformDom(De[He],Ue,ke)}element(we,Ue,ke){if(Ue)if(we.classList)ke?(we.classList.remove($),we.classList.remove(Ue)):(we.classList.add($),we.classList.add(Ue));else if(we.getAttribute){let De=we.getAttribute('class');if(!ke){let He=(De?De+' ':'')+$+' '+Ue;D(we,He)}else if(De){let He=De.replace($,'').replace(Ue,'');D(we,He)}}}elementStyles(we,Ue,ke){let De=we.__cssBuild,He=V||'shady'===De?T(Ue,ke):this.css(Ue,we.is,we.extends,ke)+'\n\n';return He.trim()}css(we,Ue,ke,De){let He=this._calcHostScope(Ue,ke);Ue=this._calcElementScope(Ue);let Fe=this;return T(we,function(je){je.isScoped||(Fe.rule(je,Ue,He),je.isScoped=!0),De&&De(je,Ue,He)})}_calcElementScope(we){return we?'.'+we:''}_calcHostScope(we,Ue){return Ue?'[is='+we+']':we}rule(we,Ue,ke){this._transformRule(we,this._transformComplexSelector,Ue,ke)}_transformRule(we,Ue,ke,De){we.selector=we.transformedSelector=this._transformRuleCss(we,Ue,ke,De)}_transformRuleCss(we,Ue,ke,De){let He=we.selector.split(ee);if(!I(we))for(let qe,Fe=0,je=He.length;Fe<je&&(qe=He[Fe]);Fe++)He[Fe]=Ue.call(this,qe,ke,De);return He.join(ee)}_transformComplexSelector(we,Ue,ke){let De=!1;return we=we.trim(),we=we.replace(Z,(He,Fe,je)=>`:${Fe}(${je.replace(/\s/g,'')})`),we=we.replace(oe,`${se} $1`),we=we.replace(te,(He,Fe,je)=>{if(!De){let qe=this._transformCompoundSelector(je,Fe,Ue,ke);De=De||qe.stop,Fe=qe.combinator,je=qe.value}return Fe+je}),we}_transformCompoundSelector(we,Ue,ke,De){let He=we.indexOf(ne);0<=we.indexOf(se)?we=this._transformHostSelector(we,De):0!==He&&(we=ke?this._transformSimpleSelector(we,ke):we);let Fe=!1;0<=He&&(Ue='',Fe=!0);let je;return Fe&&(je=!0,Fe&&(we=we.replace(ae,(qe,Ke)=>` > ${Ke}`))),we=we.replace(ie,(qe,Ke,Be)=>`[dir="${Be}"] ${Ke}, ${Ke}[dir="${Be}"]`),{value:we,combinator:Ue,stop:je}}_transformSimpleSelector(we,Ue){let ke=we.split(pe);return ke[0]+=Ue,ke.join(pe)}_transformHostSelector(we,Ue){let ke=we.match(le),De=ke&&ke[2].trim()||'';if(De){if(!De[0].match(re)){let He=De.split(re)[0];return He===Ue?De:'should_not_match'}return we.replace(le,function(He,Fe,je){return Ue+je})}return we.replace(se,Ue)}documentRule(we){we.selector=we.parsedSelector,this.normalizeRootSelector(we),this._transformRule(we,this._transformDocumentSelector)}normalizeRootSelector(we){':root'===we.selector&&(we.selector='html')}_transformDocumentSelector(we){return we.match(ne)?this._transformComplexSelector(we,Q):this._transformSimpleSelector(we.trim(),Q)}}let Z=/:(nth[-\w]+)\(([^)]+)\)/,Q=`:not(.${$})`,ee=',',te=/(^|[\s>+~]+)((?:\[.+?\]|[^\s>+~=\[])+)/g,re=/[[.:#*]/,se=':host',ne='::slotted',oe=/^(::slotted)/,le=/(:host)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/,ae=/(?:::slotted)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/,ie=/(.*):dir\((?:(ltr|rtl))\)/,pe=':';var de=new J,me={};const ue=Promise.resolve();class ye{static get(we){return we.__styleInfo}static set(we,Ue){return we.__styleInfo=Ue,Ue}static invalidate(we){me[we]&&(me[we]._applyShimInvalid=!0)}static startValidating(we){const Ue=me[we];Ue._validating||(Ue._validating=!0,ue.then(()=>{Ue._applyShimInvalid=!1,Ue._validating=!1}))}constructor(we,Ue,ke,De,He,Fe){this.styleRules=we||null,this.placeholder=Ue||null,this.ownStylePropertyNames=ke||[],this.overrideStyleProperties=null,this.elementName=De||'',this.cssBuild=Fe||'',this.typeExtension=He||'',this.styleProperties=null,this.scopeSelector=null,this.customStyle=null}}const he=window.Element.prototype,fe=he.matches||he.matchesSelector||he.mozMatchesSelector||he.msMatchesSelector||he.oMatchesSelector||he.webkitMatchesSelector,_e=navigator.userAgent.match('Trident'),Se='x-scope';class ge{get XSCOPE_NAME(){return Se}decorateStyles(we){let Ue=this,ke={},De=[],He=0;P(we,function(je){Ue.decorateRule(je),je.index=He++,Ue.collectPropertiesInCssText(je.propertyInfo.cssText,ke)},function(qe){De.push(qe)}),we._keyframes=De;let Fe=[];for(let je in ke)Fe.push(je);return Fe}decorateRule(we){if(we.propertyInfo)return we.propertyInfo;let Ue={},ke={},De=this.collectProperties(we,ke);return De&&(Ue.properties=ke,we.rules=null),Ue.cssText=this.collectCssText(we),we.propertyInfo=Ue,Ue}collectProperties(we,Ue){let ke=we.propertyInfo;if(!ke){let De,He=z.VAR_ASSIGN,Fe=we.parsedCssText,je,qe;for(;De=He.exec(Fe);)je=(De[2]||De[3]).trim(),('inherit'!==je||'unset'!==je)&&(Ue[De[1].trim()]=je),qe=!0;return qe}else if(ke.properties)return Object.assign(Ue,ke.properties),!0}collectCssText(we){return this.collectConsumingCssText(we.parsedCssText)}collectConsumingCssText(we){return we.replace(z.BRACKETED,'').replace(z.VAR_ASSIGN,'')}collectPropertiesInCssText(we,Ue){for(let ke;ke=z.VAR_CONSUMED.exec(we);){let De=ke[1];':'!==ke[2]&&(Ue[De]=!0)}}reify(we){let Ue=Object.getOwnPropertyNames(we);for(let De,ke=0;ke<Ue.length;ke++)De=Ue[ke],we[De]=this.valueForProperty(we[De],we)}valueForProperty(we,Ue){if(we)if(0<=we.indexOf(';'))we=this.valueForProperties(we,Ue);else{let ke=this;we=k(we,function(De,He,Fe,je){if(!He)return De+je;let qe=ke.valueForProperty(Ue[He],Ue);return qe&&'initial'!==qe?'apply-shim-inherit'===qe&&(qe='inherit'):qe=ke.valueForProperty(Ue[Fe]||Fe,Ue)||Fe,De+(qe||'')+je})}return we&&we.trim()||''}valueForProperties(we,Ue){let ke=we.split(';');for(let He,Fe,De=0;De<ke.length;De++)if(He=ke[De]){if(z.MIXIN_MATCH.lastIndex=0,Fe=z.MIXIN_MATCH.exec(He),Fe)He=this.valueForProperty(Ue[Fe[1]],Ue);else{let je=He.indexOf(':');if(-1!==je){let qe=He.substring(je);qe=qe.trim(),qe=this.valueForProperty(qe,Ue)||qe,He=He.substring(0,je)+qe}}ke[De]=He&&He.lastIndexOf(';')===He.length-1?He.slice(0,-1):He||''}return ke.join(';')}applyProperties(we,Ue){let ke='';we.propertyInfo||this.decorateRule(we),we.propertyInfo.cssText&&(ke=this.valueForProperties(we.propertyInfo.cssText,Ue)),we.cssText=ke}applyKeyframeTransforms(we,Ue){let ke=we.cssText,De=we.cssText;if(null==we.hasAnimations&&(we.hasAnimations=z.ANIMATION_MATCH.test(ke)),we.hasAnimations){let He;if(null==we.keyframeNamesToTransform)for(let Fe in we.keyframeNamesToTransform=[],Ue)He=Ue[Fe],De=He(ke),ke!==De&&(ke=De,we.keyframeNamesToTransform.push(Fe));else{for(let Fe=0;Fe<we.keyframeNamesToTransform.length;++Fe)He=Ue[we.keyframeNamesToTransform[Fe]],ke=He(ke);De=ke}}we.cssText=De}propertyDataFromStyles(we,Ue){let ke={},De=this,He=[];return P(we,function(Fe){Fe.propertyInfo||De.decorateRule(Fe);let je=Fe.transformedSelector||Fe.parsedSelector;Ue&&Fe.propertyInfo.properties&&je&&fe.call(Ue,je)&&(De.collectProperties(Fe,ke),H(Fe.index,He))},null,!0),{properties:ke,key:He}}whenHostOrRootRule(we,Ue,ke,De){if(Ue.propertyInfo||this.decorateRule(Ue),!!Ue.propertyInfo.properties){let He=we.is?de._calcHostScope(we.is,we.extends):'html',Fe=Ue.parsedSelector,je=':host > *'===Fe||'html'===Fe,qe=0===Fe.indexOf(':host')&&!je;if('shady'===ke&&(je=Fe===He+' > *.'+He||-1!==Fe.indexOf('html'),qe=!je&&0===Fe.indexOf(He)),'shadow'===ke&&(je=':host > *'===Fe||'html'===Fe,qe=qe&&!je),je||qe){let Ke=He;qe&&(V&&!Ue.transformedSelector&&(Ue.transformedSelector=de._transformRuleCss(Ue,de._transformComplexSelector,de._calcElementScope(we.is),He)),Ke=Ue.transformedSelector||He),De({selector:Ke,isHost:qe,isRoot:je})}}}hostAndRootPropertiesForScope(we,Ue){let ke={},De={},He=this,Fe=Ue&&Ue.__cssBuild;return P(Ue,function(je){He.whenHostOrRootRule(we,je,Fe,function(qe){let Ke=we._element||we;fe.call(Ke,qe.selector)&&(qe.isHost?He.collectProperties(je,ke):He.collectProperties(je,De))})},null,!0),{rootProps:De,hostProps:ke}}transformStyles(we,Ue,ke){let De=this,He=de._calcHostScope(we.is,we.extends),Fe=we.extends?'\\'+He.slice(0,-1)+'\\]':He,je=new RegExp(z.HOST_PREFIX+Fe+z.HOST_SUFFIX),qe=ye.get(we).styleRules,Ke=this._elementKeyframeTransforms(we,qe,ke);return de.elementStyles(we,qe,function(Be){De.applyProperties(Be,Ue),V||I(Be)||!Be.cssText||(De.applyKeyframeTransforms(Be,Ke),De._scopeSelector(Be,je,He,ke))})}_elementKeyframeTransforms(we,Ue,ke){let De=Ue._keyframes,He={};if(!V&&De)for(let Fe=0,je=De[Fe];Fe<De.length;je=De[++Fe])this._scopeKeyframes(je,ke),He[je.keyframesName]=this._keyframesRuleTransformer(je);return He}_keyframesRuleTransformer(we){return function(Ue){return Ue.replace(we.keyframesNameRx,we.transformedKeyframesName)}}_scopeKeyframes(we,Ue){we.keyframesNameRx=new RegExp(we.keyframesName,'g'),we.transformedKeyframesName=we.keyframesName+'-'+Ue,we.transformedSelector=we.transformedSelector||we.selector,we.selector=we.transformedSelector.replace(we.keyframesName,we.transformedKeyframesName)}_scopeSelector(we,Ue,ke,De){we.transformedSelector=we.transformedSelector||we.selector;let He=we.transformedSelector,Fe='.'+De,je=He.split(',');for(let Be,qe=0,Ke=je.length;qe<Ke&&(Be=je[qe]);qe++)je[qe]=Be.match(Ue)?Be.replace(ke,Fe):Fe+' '+Be;we.selector=je.join(',')}applyElementScopeSelector(we,Ue,ke){let De=we.getAttribute('class')||'',He=De;ke&&(He=De.replace(new RegExp('\\s*'+Se+'\\s*'+ke+'\\s*','g'),' ')),He+=(He?' ':'')+Se+' '+Ue,De!==He&&D(we,He)}applyElementStyle(we,Ue,ke,De){let He=De?De.textContent||'':this.transformStyles(we,Ue,ke),Fe=ye.get(we),je=Fe.customStyle;return je&&!V&&je!==De&&(je._useCount--,0>=je._useCount&&je.parentNode&&je.parentNode.removeChild(je)),V?Fe.customStyle?(Fe.customStyle.textContent=He,De=Fe.customStyle):He&&(De=M(He,ke,we.shadowRoot,Fe.placeholder)):De?!De.parentNode&&O(De,null,Fe.placeholder):He&&(De=M(He,ke,null,Fe.placeholder)),De&&(De._useCount=De._useCount||0,Fe.customStyle!=De&&De._useCount++,Fe.customStyle=De),_e&&(De.textContent=De.textContent),De}applyCustomStyle(we,Ue){let ke=R(we),De=this;we.textContent=T(ke,function(He){let Fe=He.cssText=He.parsedCssText;He.propertyInfo&&He.propertyInfo.cssText&&(Fe=E(Fe),He.cssText=De.valueForProperties(Fe,Ue))})}}var Ce=new ge;let xe={};const Ae=window.customElements;if(Ae&&!V){const we=Ae.define;Ae.define=function(Ue,ke,De){return xe[Ue]=w(Ue),we.call(Ae,Ue,ke,De)}}let ve=z.MIXIN_MATCH,Ee=z.VAR_ASSIGN,Ne=/;\s*/m,be=/^\s*(initial)|(inherit)\s*$/,Te='_-_';class Re{constructor(){this._map={}}set(we,Ue){we=we.trim(),this._map[we]={properties:Ue,dependants:{}}}get(we){return we=we.trim(),this._map[we]}}class Ie{constructor(){this._currentTemplate=null,this._measureElement=null,this._map=new Re,this._separator=Te,this._boundProduceCssProperties=(we,Ue,ke,De)=>this._produceCssProperties(we,Ue,ke,De)}detectMixin(we){const Ue=ve.test(we)||Ee.test(we);return ve.lastIndex=0,Ee.lastIndex=0,Ue}transformStyle(we,Ue){let ke=R(we);return this.transformRules(ke,Ue),ke}transformRules(we,Ue){this._currentTemplate=me[Ue],P(we,ke=>{this.transformRule(ke)}),this._currentTemplate=null}transformRule(we){we.cssText=this.transformCssText(we.parsedCssText),':root'===we.selector&&(we.selector=':host > *')}transformCssText(we){return we=we.replace(Ee,this._boundProduceCssProperties),this._consumeCssProperties(we)}_getInitialValueForProperty(we){return this._measureElement||(this._measureElement=document.createElement('meta'),this._measureElement.style.all='initial',document.head.appendChild(this._measureElement)),window.getComputedStyle(this._measureElement).getPropertyValue(we)}_consumeCssProperties(we){for(let Ue;Ue=ve.exec(we);){let ke=Ue[0],De=Ue[1],He=Ue.index,Fe=He+ke.indexOf('@apply'),je=He+ke.length,qe=we.slice(0,Fe),Ke=we.slice(je),Be=this._cssTextToMap(qe),Xe=this._atApplyToCssProperties(De,Be);we=[qe,Xe,Ke].join(''),ve.lastIndex=He+Xe.length}return we}_atApplyToCssProperties(we,Ue){we=we.replace(Ne,'');let ke=[],De=this._map.get(we);if(De||(this._map.set(we,{}),De=this._map.get(we)),De){this._currentTemplate&&(De.dependants[this._currentTemplate.name]=this._currentTemplate);let He,Fe,je;for(He in De.properties)je=Ue&&Ue[He],Fe=[He,': var(',we,Te,He],je&&Fe.push(',',je),Fe.push(')'),ke.push(Fe.join(''))}return ke.join('; ')}_replaceInitialOrInherit(we,Ue){let ke=be.exec(Ue);return ke&&(ke[1]?Ue=Ie._getInitialValueForProperty(we):Ue='apply-shim-inherit'),Ue}_cssTextToMap(we){let Ue=we.split(';'),ke,De,He={};for(let je,qe,Fe=0;Fe<Ue.length;Fe++)je=Ue[Fe],je&&(qe=je.split(':'),1<qe.length&&(ke=qe[0].trim(),De=this._replaceInitialOrInherit(ke,qe.slice(1).join(':')),He[ke]=De));return He}_invalidateMixinEntry(we){for(let Ue in we.dependants)this._currentTemplate&&Ue===this._currentTemplate.name||ye.invalidate(Ue)}_produceCssProperties(we,Ue,ke,De){if(ke&&k(ke,(We,ze)=>{ze&&this._map.get(ze)&&(De='@apply '+ze+';')}),!De)return we;let He=this._consumeCssProperties(De),Fe=we.slice(0,we.indexOf('--')),je=this._cssTextToMap(He),qe=je,Ke=this._map.get(Ue),Be=Ke&&Ke.properties;Be?qe=Object.assign(Object.create(Be),je):this._map.set(Ue,qe);let Ve,Ye,Xe=[],Ge=!1;for(Ve in qe)Ye=je[Ve],void 0==Ye&&(Ye='initial'),Be&&!(Ve in Be)&&(Ge=!0),Xe.push(Ue+Te+Ve+': '+Ye);return Ge&&this._invalidateMixinEntry(Ke),Ke&&(Ke.properties=qe),ke&&(Fe=we+';'+Fe),Fe+Xe.join('; ')+';'}}let Pe=new Ie;window.ApplyShim=Pe;let Me=function(){};if(!V){let we=Fe=>{return Fe.classList&&!Fe.classList.contains(de.SCOPE_NAME)||Fe instanceof SVGElement&&(!Fe.hasAttribute('class')||0>Fe.getAttribute('class').indexOf(de.SCOPE_NAME))},Ue=Fe=>{for(let je=0;je<Fe.length;je++){let qe=Fe[je];if(qe.target!==document.documentElement&&qe.target!==document.head){for(let Ke=0;Ke<qe.addedNodes.length;Ke++){let Be=qe.addedNodes[Ke];if(we(Be)){let Xe=Be.getRootNode();if(Xe.nodeType===Node.DOCUMENT_FRAGMENT_NODE){let Ve=Xe.host;if(Ve){let Ye=Ve.is||Ve.localName;de.dom(Be,Ye)}}}}for(let Ke=0;Ke<qe.removedNodes.length;Ke++){let Be=qe.removedNodes[Ke];if(Be.nodeType===Node.ELEMENT_NODE){let Xe;if(Be.classList?Xe=Array.from(Be.classList):Be.hasAttribute('class')&&(Xe=Be.getAttribute('class').split(/\s+/)),void 0!=Xe){let Ve=Xe.indexOf(de.SCOPE_NAME);if(0<=Ve){let Ye=Xe[Ve+1];Ye&&de.dom(Be,Ye,!0)}}}}}}},ke=new MutationObserver(Ue),De=Fe=>{ke.observe(Fe,{childList:!0,subtree:!0})},He=window.customElements&&!window.customElements.flush;if(He)De(document);else{let Fe=()=>{De(document.body)};window.HTMLImports?window.HTMLImports.whenReady(Fe):requestAnimationFrame(function(){if('loading'===document.readyState){let je=function(){Fe(),document.removeEventListener('readystatechange',je)};document.addEventListener('readystatechange',je)}else Fe()})}Me=function(){Ue(ke.takeRecords())}}let Oe=new class{constructor(Ue=100){this.cache={},this.typeMax=Ue}_validate(Ue,ke,De){for(let He=0;He<De.length;He++){let Fe=De[He];if(Ue.properties[Fe]!==ke[Fe])return!1}return!0}store(Ue,ke,De,He){let Fe=this.cache[Ue]||[];Fe.push({properties:ke,styleElement:De,scopeSelector:He}),Fe.length>this.typeMax&&Fe.shift(),this.cache[Ue]=Fe}fetch(Ue,ke,De){let He=this.cache[Ue];if(He)for(let Fe=He.length-1;0<=Fe;Fe--){let je=He[Fe];if(this._validate(je,ke,De))return je}}};class Le{constructor(){this._scopeCounter={},this._documentOwner=document.documentElement,this._documentOwnerStyleInfo=ye.set(document.documentElement,new ye({rules:[]})),this._elementsHaveApplied=!1}get nativeShadow(){return V}get nativeCss(){return Y}get nativeCssApply(){return G}flush(){Me()}_generateScopeSelector(we){let Ue=this._scopeCounter[we]=(this._scopeCounter[we]||0)+1;return`${we}-${Ue}`}getStyleAst(we){return R(we)}styleAstToString(we){return T(we)}_gatherStyles(we){let Ue=we.content.querySelectorAll('style'),ke=[];for(let De=0;De<Ue.length;De++){let He=Ue[De];ke.push(He.textContent),He.parentNode.removeChild(He)}return ke.join('').trim()}_getCssBuild(we){let Ue=we.content.querySelector('style');return Ue?Ue.getAttribute('css-build')||'':''}prepareTemplate(we,Ue,ke){if(!we._prepared){we._prepared=!0,we.name=Ue,we.extends=ke,me[Ue]=we;let De=this._getCssBuild(we),He=this._gatherStyles(we),Fe={is:Ue,extends:ke,__cssBuild:De};this.nativeShadow||de.dom(we.content,Ue);let je=Pe.detectMixin(He),qe=d(He);je&&this.nativeCss&&!this.nativeCssApply&&Pe.transformRules(qe,Ue),we._styleAst=qe;let Ke=[];if(this.nativeCss||(Ke=Ce.decorateStyles(we._styleAst,Fe)),!Ke.length||this.nativeCss){let Be=this.nativeShadow?we.content:null,Xe=xe[Ue],Ve=this._generateStaticStyle(Fe,we._styleAst,Be,Xe);we._style=Ve}we._ownPropertyNames=Ke}}_generateStaticStyle(we,Ue,ke,De){let He=de.elementStyles(we,Ue);if(He.length)return M(He,we.is,ke,De)}_prepareHost(we){let ke,Ue=we.getAttribute('is')||we.localName;Ue!==we.localName&&(ke=we.localName);let Fe,je,qe,De=xe[Ue],He=me[Ue];return He&&(Fe=He._styleAst,je=He._ownPropertyNames,qe=He._cssBuild),ye.set(we,new ye(Fe,De,je,Ue,ke,qe))}applyStyle(we,Ue){let ke=we.getAttribute('is')||we.localName,De=ye.get(we),He=!!De;if(De||(De=this._prepareHost(we)),this._isRootOwner(we)||(this._elementsHaveApplied=!0),window.CustomStyle){let Fe=window.CustomStyle;if(Fe._documentDirty){if(Fe.findStyles(),this.nativeCss?!this.nativeCssApply&&Fe._revalidateApplyShim():this._updateProperties(this._documentOwner,this._documentOwnerStyleInfo),Fe.applyStyles(),!this._elementsHaveApplied)return;if(!this.nativeCss&&(this.updateStyles(),He))return}}if(Ue&&(De.overrideStyleProperties=De.overrideStyleProperties||{},Object.assign(De.overrideStyleProperties,Ue)),this.nativeCss){De.overrideStyleProperties&&this._updateNativeProperties(we,De.overrideStyleProperties);let Fe=me[ke];if(!Fe&&!this._isRootOwner(we))return;if(Fe&&Fe._applyShimInvalid&&Fe._style){if(Fe._validating||(Pe.transformRules(Fe._styleAst,ke),Fe._style.textContent=de.elementStyles(we,De.styleRules),ye.startValidating(ke)),this.nativeShadow){let je=we.shadowRoot;if(je){let qe=je.querySelector('style');qe.textContent=de.elementStyles(we,De.styleRules)}}De.styleRules=Fe._styleAst}}else this._updateProperties(we,De),De.ownStylePropertyNames&&De.ownStylePropertyNames.length&&this._applyStyleProperties(we,De);if(He){let Fe=this._isRootOwner(we)?we:we.shadowRoot;Fe&&this._applyToDescendants(Fe)}}_applyToDescendants(we){let Ue=we.children;for(let De,ke=0;ke<Ue.length;ke++)De=Ue[ke],De.shadowRoot&&this.applyStyle(De),this._applyToDescendants(De)}_styleOwnerForNode(we){let Ue=we.getRootNode(),ke=Ue.host;return ke?ye.get(ke)?ke:this._styleOwnerForNode(ke):this._documentOwner}_isRootOwner(we){return we===this._documentOwner}_applyStyleProperties(we,Ue){let ke=we.getAttribute('is')||we.localName,De=Oe.fetch(ke,Ue.styleProperties,Ue.ownStylePropertyNames),He=De&&De.scopeSelector,Fe=De?De.styleElement:null,je=Ue.scopeSelector;Ue.scopeSelector=He||this._generateScopeSelector(ke);let qe=Ce.applyElementStyle(we,Ue.styleProperties,Ue.scopeSelector,Fe);return this.nativeShadow||Ce.applyElementScopeSelector(we,Ue.scopeSelector,je),De||Oe.store(ke,Ue.styleProperties,qe,Ue.scopeSelector),qe}_updateProperties(we,Ue){let ke=this._styleOwnerForNode(we),De=ye.get(ke),He=De.styleProperties,Fe=Object.create(He||null),je=Ce.hostAndRootPropertiesForScope(we,Ue.styleRules),qe=Ce.propertyDataFromStyles(De.styleRules,we),Ke=qe.properties;Object.assign(Fe,je.hostProps,Ke,je.rootProps),this._mixinOverrideStyles(Fe,Ue.overrideStyleProperties),Ce.reify(Fe),Ue.styleProperties=Fe}_mixinOverrideStyles(we,Ue){for(let ke in Ue){let De=Ue[ke];(De||0===De)&&(we[ke]=De)}}_updateNativeProperties(we,Ue){for(let ke in Ue)null===ke?we.style.removeProperty(ke):we.style.setProperty(ke,Ue[ke])}updateStyles(we){this.applyStyle(this._documentOwner,we)}_transformCustomStyleForDocument(we){let Ue=R(we);P(Ue,ke=>{V?de.normalizeRootSelector(ke):de.documentRule(ke),this.nativeCss&&!this.nativeCssApply&&Pe.transformRule(ke)}),this.nativeCss?we.textContent=T(Ue):this._documentOwnerStyleInfo.styleRules.rules.push(Ue)}_revalidateApplyShim(we){if(this.nativeCss&&!this.nativeCssApply){let Ue=R(we);Pe.transformRules(Ue),we.textContent=T(Ue)}}_applyCustomStyleToDocument(we){this.nativeCss||Ce.applyCustomStyle(we,this._documentOwnerStyleInfo.styleProperties)}getComputedStyleValue(we,Ue){let ke;if(!this.nativeCss){let De=ye.get(we)||ye.get(this._styleOwnerForNode(we));ke=De.styleProperties[Ue]}return ke=ke||window.getComputedStyle(we).getPropertyValue(Ue),ke.trim()}setElementClass(we,Ue){let ke=we.getRootNode(),De=Ue?Ue.split(/\s/):[],He=ke.host&&ke.host.localName;if(!He){var Fe=we.getAttribute('class');if(Fe){let je=Fe.split(/\s/);for(let qe=0;qe<je.length;qe++)if(je[qe]===de.SCOPE_NAME){He=je[qe+1];break}}}if(He&&De.push(de.SCOPE_NAME,He),!this.nativeCss){let je=ye.get(we);je&&je.scopeSelector&&De.push(Ce.XSCOPE_NAME,je.scopeSelector)}D(we,De.join(' '))}_styleInfoForNode(we){return ye.get(we)}}window.ShadyCSS=new Le,function(){'use strict';HTMLImports.whenReady(function(){requestAnimationFrame(function(){window.dispatchEvent(new CustomEvent('WebComponentsReady'))})})}(window.WebComponents),function(){var we=document.createElement('style');we.textContent='body {transition: opacity ease-in 0.2s; } \nbody[unresolved] {opacity: 0; display: block; overflow: hidden; position: relative; } \n';var Ue=document.querySelector('head');Ue.insertBefore(we,Ue.firstChild)}(window.WebComponents)})();
|
|
//# sourceMappingURL=webcomponents-hi.js.map
|