@nodecg/types
Version:
Dynamic broadcast graphics rendered in a browser
1,419 lines (1,408 loc) • 2.46 MB
JavaScript
(function() {
//#region rolldown:runtime
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __esm = (fn, res) => function() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __commonJS = (cb, mod) => function() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (all, symbols) => {
let target = {};
for (var name in all) {
__defProp(target, name, {
get: all[name],
enumerable: true
});
}
if (symbols) {
__defProp(target, Symbol.toStringTag, { value: "Module" });
}
return target;
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (var keys$1 = __getOwnPropNames(from), i$1 = 0, n = keys$1.length, key; i$1 < n; i$1++) {
key = keys$1[i$1];
if (!__hasOwnProp.call(to, key) && key !== except) {
__defProp(to, key, {
get: ((k$1) => from[k$1]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
}
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
//#endregion
//#region ../../node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js
var init_webcomponents_loader = __esm({ "../../node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js": (() => {
/**
* @license
* Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
(function() {
"use strict";
/**
* Basic flow of the loader process
*
* There are 4 flows the loader can take when booting up
*
* - Synchronous script, no polyfills needed
* - wait for `DOMContentLoaded`
* - fire WCR event, as there could not be any callbacks passed to `waitFor`
*
* - Synchronous script, polyfills needed
* - document.write the polyfill bundle
* - wait on the `load` event of the bundle to batch Custom Element upgrades
* - wait for `DOMContentLoaded`
* - run callbacks passed to `waitFor`
* - fire WCR event
*
* - Asynchronous script, no polyfills needed
* - wait for `DOMContentLoaded`
* - run callbacks passed to `waitFor`
* - fire WCR event
*
* - Asynchronous script, polyfills needed
* - Append the polyfill bundle script
* - wait for `load` event of the bundle
* - batch Custom Element Upgrades
* - run callbacks pass to `waitFor`
* - fire WCR event
*/
var polyfillsLoaded = false;
var whenLoadedFns = [];
var allowUpgrades = false;
var flushFn;
function fireEvent() {
window.WebComponents.ready = true;
document.dispatchEvent(new CustomEvent("WebComponentsReady", { bubbles: true }));
}
function batchCustomElements() {
if (window.customElements && customElements.polyfillWrapFlushCallback) customElements.polyfillWrapFlushCallback(function(flushCallback) {
flushFn = flushCallback;
if (allowUpgrades) flushFn();
});
}
function asyncReady() {
batchCustomElements();
ready();
}
function ready() {
if (window.HTMLTemplateElement && HTMLTemplateElement.bootstrap) HTMLTemplateElement.bootstrap(window.document);
polyfillsLoaded = true;
runWhenLoadedFns().then(fireEvent);
}
function runWhenLoadedFns() {
allowUpgrades = false;
var fnsMap = whenLoadedFns.map(function(fn) {
return fn instanceof Function ? fn() : fn;
});
whenLoadedFns = [];
return Promise.all(fnsMap).then(function() {
allowUpgrades = true;
flushFn && flushFn();
}).catch(function(err) {
console.error(err);
});
}
window.WebComponents = window.WebComponents || {};
window.WebComponents.ready = window.WebComponents.ready || false;
window.WebComponents.waitFor = window.WebComponents.waitFor || function(waitFn) {
if (!waitFn) return;
whenLoadedFns.push(waitFn);
if (polyfillsLoaded) runWhenLoadedFns();
};
window.WebComponents._batchCustomElements = batchCustomElements;
var name = "webcomponents-loader.js";
var polyfills = [];
if (!("attachShadow" in Element.prototype && "getRootNode" in Element.prototype) || window.ShadyDOM && window.ShadyDOM.force) polyfills.push("sd");
if (!window.customElements || window.customElements.forcePolyfill) polyfills.push("ce");
var needsTemplate = (function() {
var t$1 = document.createElement("template");
if (!("content" in t$1)) return true;
if (!(t$1.content.cloneNode() instanceof DocumentFragment)) return true;
var t2 = document.createElement("template");
t2.content.appendChild(document.createElement("div"));
t$1.content.appendChild(t2);
var clone = t$1.cloneNode(true);
return clone.content.childNodes.length === 0 || clone.content.firstChild.content.childNodes.length === 0;
})();
if (!window.Promise || !Array.from || !window.URL || !window.Symbol || needsTemplate) polyfills = ["sd-ce-pf"];
if (polyfills.length) {
var policy$1 = (function() {
var identity = function(x$1) {
return x$1;
};
var policyOptions = {
createHTML: identity,
createScript: identity,
createScriptURL: identity
};
return window.trustedTypes && window.trustedTypes.createPolicy("webcomponents-loader", policyOptions) || policyOptions;
})();
var url;
var polyfillFile = "bundles/webcomponents-" + polyfills.join("-") + ".js";
if (window.WebComponents.root) {
url = window.WebComponents.root + polyfillFile;
if (window.trustedTypes && window.trustedTypes.isScriptURL(window.WebComponents.root)) url = policy$1.createScriptURL(url);
} else {
var script = document.querySelector("script[src*=\"" + name + "\"]");
url = policy$1.createScriptURL(script.src.replace(name, polyfillFile));
}
var newScript = document.createElement("script");
newScript.src = url;
if (document.readyState === "loading") {
newScript.setAttribute("onload", policy$1.createScript("window.WebComponents._batchCustomElements()"));
document.write(policy$1.createHTML(newScript.outerHTML));
document.addEventListener("DOMContentLoaded", ready);
} else {
newScript.addEventListener("load", function() {
asyncReady();
});
newScript.addEventListener("error", function() {
throw new Error("Could not load polyfill bundle" + url);
});
document.head.appendChild(newScript);
}
} else if (document.readyState === "complete") {
polyfillsLoaded = true;
fireEvent();
} else {
window.addEventListener("load", ready);
window.addEventListener("DOMContentLoaded", function() {
window.removeEventListener("load", ready);
ready();
});
}
})();
}) });
//#endregion
//#region ../../node_modules/@webcomponents/shadycss/apply-shim.min.js
var init_apply_shim_min = __esm({ "../../node_modules/@webcomponents/shadycss/apply-shim.min.js": (() => {
(function() {
"use strict";
var k$1 = !(window.ShadyDOM && window.ShadyDOM.inUse), p$3;
function r$2(a) {
p$3 = a && a.shimcssproperties ? !1 : k$1 || !(navigator.userAgent.match(/AppleWebKit\/601|Edge\/15/) || !window.CSS || !CSS.supports || !CSS.supports("box-shadow", "0 0 0 var(--foo)"));
}
var t$1;
window.ShadyCSS && void 0 !== window.ShadyCSS.cssBuild && (t$1 = window.ShadyCSS.cssBuild);
var aa = !(!window.ShadyCSS || !window.ShadyCSS.disableRuntime);
window.ShadyCSS && void 0 !== window.ShadyCSS.nativeCss ? p$3 = window.ShadyCSS.nativeCss : window.ShadyCSS ? (r$2(window.ShadyCSS), window.ShadyCSS = void 0) : r$2(window.WebComponents && window.WebComponents.flags);
var u = p$3;
function v$1() {
this.end = this.start = 0;
this.rules = this.parent = this.previous = null;
this.cssText = this.parsedCssText = "";
this.atRule = !1;
this.type = 0;
this.parsedSelector = this.selector = this.keyframesName = "";
}
function w(a) {
var b$1 = a = a.replace(ba, "").replace(ca, ""), c = new v$1();
c.start = 0;
c.end = b$1.length;
for (var d = c, e$1 = 0, f$1 = b$1.length; e$1 < f$1; e$1++) if ("{" === b$1[e$1]) {
d.rules || (d.rules = []);
var g$1 = d, h$1 = g$1.rules[g$1.rules.length - 1] || null;
d = new v$1();
d.start = e$1 + 1;
d.parent = g$1;
d.previous = h$1;
g$1.rules.push(d);
} else "}" === b$1[e$1] && (d.end = e$1 + 1, d = d.parent || c);
return x$1(c, a);
}
function x$1(a, b$1) {
var c = b$1.substring(a.start, a.end - 1);
a.parsedCssText = a.cssText = c.trim();
a.parent && (c = b$1.substring(a.previous ? a.previous.end : a.parent.start, a.start - 1), c = da(c), c = c.replace(y, " "), c = c.substring(c.lastIndexOf(";") + 1), c = a.parsedSelector = a.selector = c.trim(), a.atRule = 0 === c.indexOf("@"), a.atRule ? 0 === c.indexOf("@media") ? a.type = z$1 : c.match(ea) && (a.type = A$1, a.keyframesName = a.selector.split(y).pop()) : a.type = 0 === c.indexOf("--") ? B$1 : C$1);
if (c = a.rules) for (var d = 0, e$1 = c.length, f$1 = void 0; d < e$1 && (f$1 = c[d]); d++) x$1(f$1, b$1);
return a;
}
function da(a) {
return a.replace(/\\([0-9a-f]{1,6})\s/gi, function(b$1, c) {
b$1 = c;
for (c = 6 - b$1.length; c--;) b$1 = "0" + b$1;
return "\\" + b$1;
});
}
function D$1(a, b$1, c) {
c = void 0 === c ? "" : c;
var d = "";
if (a.cssText || a.rules) {
var e$1 = a.rules, f$1;
if (f$1 = e$1) f$1 = e$1[0], f$1 = !(f$1 && f$1.selector && 0 === f$1.selector.indexOf("--"));
if (f$1) {
f$1 = 0;
for (var g$1 = e$1.length, h$1 = void 0; f$1 < g$1 && (h$1 = e$1[f$1]); f$1++) d = D$1(h$1, b$1, d);
} else b$1 ? b$1 = a.cssText : (b$1 = a.cssText, b$1 = b$1.replace(fa, "").replace(ha, ""), b$1 = b$1.replace(ia, "").replace(ja, "")), (d = b$1.trim()) && (d = " " + d + "\n");
}
d && (a.selector && (c += a.selector + " {\n"), c += d, a.selector && (c += "}\n\n"));
return c;
}
var C$1 = 1, A$1 = 7, z$1 = 4, B$1 = 1e3, ba = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim, ca = /@import[^;]*;/gim, fa = /(?:^[^;\-\s}]+)?--[^;{}]*?:[^{};]*?(?:[;\n]|$)/gim, ha = /(?:^[^;\-\s}]+)?--[^;{}]*?:[^{};]*?{[^}]*?}(?:[;\n]|$)?/gim, ia = /@apply\s*\(?[^);]*\)?\s*(?:[;\n]|$)?/gim, ja = /[^;:]*?:[^;]*?var\([^;]*\)(?:[;\n]|$)?/gim, ea = /^@[^\s]*keyframes/, y = /\s+/g;
var E$1 = /(?:^|[;\s{]\s*)(--[\w-]*?)\s*:\s*(?:((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};{])+)|\{([^}]*)\}(?:(?=[;\s}])|$))/gi, H$1 = /(?:^|\W+)@apply\s*\(?([^);\n]*)\)?/gi, ka = /@media\s(.*)/;
var I$1 = /* @__PURE__ */ new Set();
function J(a) {
if (!a) return "";
"string" === typeof a && (a = w(a));
return D$1(a, u);
}
function K$1(a) {
!a.__cssRules && a.textContent && (a.__cssRules = w(a.textContent));
return a.__cssRules || null;
}
function L$1(a, b$1, c, d) {
if (a) {
var e$1 = !1, f$1 = a.type;
if (d && f$1 === z$1) {
var g$1 = a.selector.match(ka);
g$1 && (window.matchMedia(g$1[1]).matches || (e$1 = !0));
}
f$1 === C$1 ? b$1(a) : c && f$1 === A$1 ? c(a) : f$1 === B$1 && (e$1 = !0);
if ((a = a.rules) && !e$1) for (e$1 = 0, f$1 = a.length, g$1 = void 0; e$1 < f$1 && (g$1 = a[e$1]); e$1++) L$1(g$1, b$1, c, d);
}
}
function M$1(a, b$1) {
var c = a.indexOf("var(");
if (-1 === c) return b$1(a, "", "", "");
a: {
var d = 0;
var e$1 = c + 3;
for (var f$1 = a.length; e$1 < f$1; e$1++) if ("(" === a[e$1]) d++;
else if (")" === a[e$1] && 0 === --d) break a;
e$1 = -1;
}
d = a.substring(c + 4, e$1);
c = a.substring(0, c);
a = M$1(a.substring(e$1 + 1), b$1);
e$1 = d.indexOf(",");
return -1 === e$1 ? b$1(c, d.trim(), "", a) : b$1(c, d.substring(0, e$1).trim(), d.substring(e$1 + 1).trim(), a);
}
function N$1(a) {
if (void 0 !== t$1) return t$1;
if (void 0 === a.__cssBuild) {
var b$1 = a.getAttribute("css-build");
if (b$1) a.__cssBuild = b$1;
else {
a: {
b$1 = "template" === a.localName ? a.content.firstChild : a.firstChild;
if (b$1 instanceof Comment && (b$1 = b$1.textContent.trim().split(":"), "css-build" === b$1[0])) {
b$1 = b$1[1];
break a;
}
b$1 = "";
}
if ("" !== b$1) {
var c = "template" === a.localName ? a.content.firstChild : a.firstChild;
c.parentNode.removeChild(c);
}
a.__cssBuild = b$1;
}
}
return a.__cssBuild || "";
}
var la = /;\s*/m, ma = /^\s*(initial)|(inherit)\s*$/, O$1 = /\s*!important/;
function P$1() {
this.g = {};
}
P$1.prototype.set = function(a, b$1) {
a = a.trim();
this.g[a] = {
m: b$1,
o: {}
};
};
P$1.prototype.get = function(a) {
a = a.trim();
return this.g[a] || null;
};
var Q = null;
function R() {
this.h = this.i = null;
this.g = new P$1();
}
R.prototype.A = function(a) {
a = H$1.test(a) || E$1.test(a);
H$1.lastIndex = 0;
E$1.lastIndex = 0;
return a;
};
R.prototype.v = function(a, b$1) {
if (void 0 === a._gatheredStyle) {
var c = [];
for (var d = a.content.querySelectorAll("style"), e$1 = 0; e$1 < d.length; e$1++) {
var f$1 = d[e$1];
if (f$1.hasAttribute("shady-unscoped")) {
if (!k$1) {
var g$1 = f$1.textContent;
if (!I$1.has(g$1)) {
I$1.add(g$1);
var h$1 = document.createElement("style");
h$1.setAttribute("shady-unscoped", "");
h$1.textContent = g$1;
document.head.appendChild(h$1);
}
f$1.parentNode.removeChild(f$1);
}
} else c.push(f$1.textContent), f$1.parentNode.removeChild(f$1);
}
(c = c.join("").trim()) ? (d = document.createElement("style"), d.textContent = c, a.content.insertBefore(d, a.content.firstChild), c = d) : c = null;
a._gatheredStyle = c;
}
return (a = a._gatheredStyle) ? this.s(a, b$1) : null;
};
R.prototype.s = function(a, b$1) {
b$1 = void 0 === b$1 ? "" : b$1;
var c = K$1(a);
this.u(c, b$1);
a.textContent = J(c);
return c;
};
R.prototype.j = function(a) {
var b$1 = this, c = K$1(a);
L$1(c, function(d) {
":root" === d.selector && (d.selector = "html");
b$1.l(d);
});
a.textContent = J(c);
return c;
};
R.prototype.u = function(a, b$1) {
var c = this;
this.i = b$1;
L$1(a, function(d) {
c.l(d);
});
this.i = null;
};
R.prototype.l = function(a) {
a.cssText = na(this, a.parsedCssText, a);
":root" === a.selector && (a.selector = ":host > *");
};
function na(a, b$1, c) {
b$1 = b$1.replace(E$1, function(d, e$1, f$1, g$1) {
return oa(a, d, e$1, f$1, g$1, c);
});
return S(a, b$1, c);
}
function pa(a, b$1) {
for (var c = b$1; c.parent;) c = c.parent;
var d = {}, e$1 = !1;
L$1(c, function(f$1) {
(e$1 = e$1 || f$1 === b$1) || f$1.selector === b$1.selector && Object.assign(d, T$1(a, f$1.parsedCssText));
});
return d;
}
function S(a, b$1, c) {
for (var d; d = H$1.exec(b$1);) {
var e$1 = d[0], f$1 = d[1];
d = d.index;
var g$1 = b$1.slice(0, d + e$1.indexOf("@apply"));
b$1 = b$1.slice(d + e$1.length);
var h$1 = c ? pa(a, c) : {};
Object.assign(h$1, T$1(a, g$1));
e$1 = void 0;
var l = a;
f$1 = f$1.replace(la, "");
var n = [];
var m$1 = l.g.get(f$1);
m$1 || (l.g.set(f$1, {}), m$1 = l.g.get(f$1));
if (m$1) {
l.i && (m$1.o[l.i] = !0);
var q$1 = m$1.m;
for (e$1 in q$1) l = h$1 && h$1[e$1], m$1 = [
e$1,
": var(",
f$1,
"_-_",
e$1
], l && m$1.push(",", l.replace(O$1, "")), m$1.push(")"), O$1.test(q$1[e$1]) && m$1.push(" !important"), n.push(m$1.join(""));
}
e$1 = n.join("; ");
b$1 = g$1 + e$1 + b$1;
H$1.lastIndex = d + e$1.length;
}
return b$1;
}
function T$1(a, b$1, c) {
c = void 0 === c ? !1 : c;
b$1 = b$1.split(";");
for (var d, e$1, f$1 = {}, g$1 = 0, h$1; g$1 < b$1.length; g$1++) if (d = b$1[g$1]) {
if (h$1 = d.split(":"), 1 < h$1.length) {
d = h$1[0].trim();
e$1 = h$1.slice(1).join(":");
if (c) {
var l = a;
h$1 = d;
var n = ma.exec(e$1);
n && (n[1] ? (l.h || (l.h = document.createElement("meta"), l.h.setAttribute("apply-shim-measure", ""), l.h.style.all = "initial", document.head.appendChild(l.h)), h$1 = window.getComputedStyle(l.h).getPropertyValue(h$1)) : h$1 = "apply-shim-inherit", e$1 = h$1);
}
f$1[d] = e$1;
}
}
return f$1;
}
function qa(a, b$1) {
if (Q) for (var c in b$1.o) c !== a.i && Q(c);
}
function oa(a, b$1, c, d, e$1, f$1) {
d && M$1(d, function(wa, F$1) {
F$1 && a.g.get(F$1) && (e$1 = "@apply " + F$1 + ";");
});
if (!e$1) return b$1;
var g$1 = S(a, "" + e$1, f$1);
f$1 = b$1.slice(0, b$1.indexOf("--"));
var h$1 = g$1 = T$1(a, g$1, !0), l = a.g.get(c), n = l && l.m;
n ? h$1 = Object.assign(Object.create(n), g$1) : a.g.set(c, h$1);
var m$1 = [], q$1, Z = !1;
for (q$1 in h$1) {
var G$1 = g$1[q$1];
void 0 === G$1 && (G$1 = "initial");
!n || q$1 in n || (Z = !0);
m$1.push(c + "_-_" + q$1 + ": " + G$1);
}
Z && qa(a, l);
l && (l.m = h$1);
d && (f$1 = b$1 + ";" + f$1);
return f$1 + m$1.join("; ") + ";";
}
R.prototype.detectMixin = R.prototype.A;
R.prototype.transformStyle = R.prototype.s;
R.prototype.transformCustomStyle = R.prototype.j;
R.prototype.transformRules = R.prototype.u;
R.prototype.transformRule = R.prototype.l;
R.prototype.transformTemplate = R.prototype.v;
R.prototype._separator = "_-_";
Object.defineProperty(R.prototype, "invalidCallback", {
get: function() {
return Q;
},
set: function(a) {
Q = a;
}
});
var U$1 = {};
var ra = Promise.resolve();
function sa(a) {
if (a = U$1[a]) a._applyShimCurrentVersion = a._applyShimCurrentVersion || 0, a._applyShimValidatingVersion = a._applyShimValidatingVersion || 0, a._applyShimNextVersion = (a._applyShimNextVersion || 0) + 1;
}
function ta(a) {
return a._applyShimCurrentVersion === a._applyShimNextVersion;
}
function ua(a) {
a._applyShimValidatingVersion = a._applyShimNextVersion;
a._validating || (a._validating = !0, ra.then(function() {
a._applyShimCurrentVersion = a._applyShimNextVersion;
a._validating = !1;
}));
}
var V$1 = new R();
function W$1() {
this.g = null;
V$1.invalidCallback = sa;
}
function X(a) {
!a.g && window.ShadyCSS.CustomStyleInterface && (a.g = window.ShadyCSS.CustomStyleInterface, a.g.transformCallback = function(b$1) {
V$1.j(b$1);
}, a.g.validateCallback = function() {
requestAnimationFrame(function() {
a.g.enqueued && a.flushCustomStyles();
});
});
}
W$1.prototype.prepareTemplate = function(a, b$1) {
X(this);
"" === N$1(a) && (U$1[b$1] = a, b$1 = V$1.v(a, b$1), a._styleAst = b$1);
};
W$1.prototype.flushCustomStyles = function() {
X(this);
if (this.g) {
var a = this.g.processStyles();
if (this.g.enqueued) {
for (var b$1 = 0; b$1 < a.length; b$1++) {
var c = this.g.getStyleForCustomStyle(a[b$1]);
c && V$1.j(c);
}
this.g.enqueued = !1;
}
}
};
W$1.prototype.styleSubtree = function(a, b$1) {
X(this);
if (b$1) for (var c in b$1) null === c ? a.style.removeProperty(c) : a.style.setProperty(c, b$1[c]);
if (a.shadowRoot) for (this.styleElement(a), a = a.shadowRoot.children || a.shadowRoot.childNodes, b$1 = 0; b$1 < a.length; b$1++) this.styleSubtree(a[b$1]);
else for (a = a.children || a.childNodes, b$1 = 0; b$1 < a.length; b$1++) this.styleSubtree(a[b$1]);
};
W$1.prototype.styleElement = function(a) {
X(this);
var b$1 = a.localName, c;
b$1 ? -1 < b$1.indexOf("-") ? c = b$1 : c = a.getAttribute && a.getAttribute("is") || "" : c = a.is;
b$1 = U$1[c];
if (!(b$1 && "" !== N$1(b$1) || !b$1 || ta(b$1))) {
if (ta(b$1) || b$1._applyShimValidatingVersion !== b$1._applyShimNextVersion) this.prepareTemplate(b$1, c), ua(b$1);
if (a = a.shadowRoot) {
if (a = a.querySelector("style")) a.__cssRules = b$1._styleAst, a.textContent = J(b$1._styleAst);
}
}
};
W$1.prototype.styleDocument = function(a) {
X(this);
this.styleSubtree(document.body, a);
};
if (!window.ShadyCSS || !window.ShadyCSS.ScopingShim) {
var Y = new W$1(), va = window.ShadyCSS && window.ShadyCSS.CustomStyleInterface;
window.ShadyCSS = {
prepareTemplate: function(a, b$1) {
Y.flushCustomStyles();
Y.prepareTemplate(a, b$1);
},
prepareTemplateStyles: function(a, b$1, c) {
window.ShadyCSS.prepareTemplate(a, b$1, c);
},
prepareTemplateDom: function() {},
styleSubtree: function(a, b$1) {
Y.flushCustomStyles();
Y.styleSubtree(a, b$1);
},
styleElement: function(a) {
Y.flushCustomStyles();
Y.styleElement(a);
},
styleDocument: function(a) {
Y.flushCustomStyles();
Y.styleDocument(a);
},
getComputedStyleValue: function(a, b$1) {
return (a = window.getComputedStyle(a).getPropertyValue(b$1)) ? a.trim() : "";
},
flushCustomStyles: function() {
Y.flushCustomStyles();
},
nativeCss: u,
nativeShadow: k$1,
cssBuild: t$1,
disableRuntime: aa
};
va && (window.ShadyCSS.CustomStyleInterface = va);
}
window.ShadyCSS.ApplyShim = V$1;
}).call(void 0);
}) });
//#endregion
//#region ../../node_modules/@webcomponents/shadycss/src/style-settings.js
/**
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
/**
* @param {(ShadyCSSOptions | ShadyCSSInterface)=} settings
*/
function calcCssVariables(settings) {
if (settings && settings.shimcssproperties) nativeCssVariables_ = false;
else nativeCssVariables_ = nativeShadow || Boolean(!navigator.userAgent.match(/AppleWebKit\/601|Edge\/15/) && window.CSS && CSS.supports && CSS.supports("box-shadow", "0 0 0 var(--foo)"));
}
var nativeShadow, nativeCssVariables_, cssBuild, disableRuntime, nativeCssVariables;
var init_style_settings = __esm({ "../../node_modules/@webcomponents/shadycss/src/style-settings.js": (() => {
nativeShadow = !(window["ShadyDOM"] && window["ShadyDOM"]["inUse"]);
;
;
if (window.ShadyCSS && window.ShadyCSS.cssBuild !== void 0) cssBuild = window.ShadyCSS.cssBuild;
disableRuntime = Boolean(window.ShadyCSS && window.ShadyCSS.disableRuntime);
if (window.ShadyCSS && window.ShadyCSS.nativeCss !== void 0) nativeCssVariables_ = window.ShadyCSS.nativeCss;
else if (window.ShadyCSS) {
calcCssVariables(window.ShadyCSS);
window.ShadyCSS = void 0;
} else calcCssVariables(window["WebComponents"] && window["WebComponents"]["flags"]);
nativeCssVariables = nativeCssVariables_;
}) });
//#endregion
//#region ../../node_modules/@webcomponents/shadycss/src/css-parse.js
/**
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
/**
* @param {string} text
* @return {StyleNode}
*/
function parse(text) {
text = clean(text);
return parseCss(lex(text), text);
}
/**
* @param {string} cssText
* @return {string}
*/
function clean(cssText) {
return cssText.replace(RX.comments, "").replace(RX.port, "");
}
/**
* @param {string} text
* @return {!StyleNode}
*/
function lex(text) {
let root$1 = new StyleNode();
root$1["start"] = 0;
root$1["end"] = text.length;
let n = root$1;
for (let i$1 = 0, l = text.length; i$1 < l; i$1++) if (text[i$1] === OPEN_BRACE) {
if (!n["rules"]) n["rules"] = [];
let p$3 = n;
let previous = p$3["rules"][p$3["rules"].length - 1] || null;
n = new StyleNode();
n["start"] = i$1 + 1;
n["parent"] = p$3;
n["previous"] = previous;
p$3["rules"].push(n);
} else if (text[i$1] === CLOSE_BRACE) {
n["end"] = i$1 + 1;
n = n["parent"] || root$1;
}
return root$1;
}
/**
* @param {StyleNode} node
* @param {string} text
* @return {!StyleNode}
*/
function parseCss(node, text) {
let t$1 = text.substring(node["start"], node["end"] - 1);
node["parsedCssText"] = node["cssText"] = t$1.trim();
if (node["parent"]) {
let ss = node["previous"] ? node["previous"]["end"] : node["parent"]["start"];
t$1 = text.substring(ss, node["start"] - 1);
t$1 = _expandUnicodeEscapes(t$1);
t$1 = t$1.replace(RX.multipleSpaces, " ");
t$1 = t$1.substring(t$1.lastIndexOf(";") + 1);
let s = node["parsedSelector"] = node["selector"] = t$1.trim();
node["atRule"] = s.indexOf(AT_START) === 0;
if (node["atRule"]) {
if (s.indexOf(MEDIA_START) === 0) node["type"] = types.MEDIA_RULE;
else if (s.match(RX.keyframesRule)) {
node["type"] = types.KEYFRAMES_RULE;
node["keyframesName"] = node["selector"].split(RX.multipleSpaces).pop();
}
} else if (s.indexOf(VAR_START) === 0) node["type"] = types.MIXIN_RULE;
else node["type"] = types.STYLE_RULE;
}
let r$ = node["rules"];
if (r$) for (let i$1 = 0, l = r$.length, r$2; i$1 < l && (r$2 = r$[i$1]); i$1++) parseCss(r$2, text);
return node;
}
/**
* conversion of sort unicode escapes with spaces like `\33 ` (and longer) into
* expanded form that doesn't require trailing space `\000033`
* @param {string} s
* @return {string}
*/
function _expandUnicodeEscapes(s) {
return s.replace(/\\([0-9a-f]{1,6})\s/gi, function() {
let code = arguments[1], repeat = 6 - code.length;
while (repeat--) code = "0" + code;
return "\\" + code;
});
}
/**
* stringify parsed css.
* @param {StyleNode} node
* @param {boolean=} preserveProperties
* @param {string=} text
* @return {string}
*/
function stringify(node, preserveProperties, text = "") {
let cssText = "";
if (node["cssText"] || node["rules"]) {
let r$ = node["rules"];
if (r$ && !_hasMixinRules(r$)) for (let i$1 = 0, l = r$.length, r$2; i$1 < l && (r$2 = r$[i$1]); i$1++) cssText = stringify(r$2, preserveProperties, cssText);
else {
cssText = preserveProperties ? node["cssText"] : removeCustomProps(node["cssText"]);
cssText = cssText.trim();
if (cssText) cssText = " " + cssText + "\n";
}
}
if (cssText) {
if (node["selector"]) text += node["selector"] + " " + OPEN_BRACE + "\n";
text += cssText;
if (node["selector"]) text += CLOSE_BRACE + "\n\n";
}
return text;
}
/**
* @param {Array<StyleNode>} rules
* @return {boolean}
*/
function _hasMixinRules(rules) {
let r$2 = rules[0];
return Boolean(r$2) && Boolean(r$2["selector"]) && r$2["selector"].indexOf(VAR_START) === 0;
}
/**
* @param {string} cssText
* @return {string}
*/
function removeCustomProps(cssText) {
cssText = removeCustomPropAssignment(cssText);
return removeCustomPropApply(cssText);
}
/**
* @param {string} cssText
* @return {string}
*/
function removeCustomPropAssignment(cssText) {
return cssText.replace(RX.customProp, "").replace(RX.mixinProp, "");
}
/**
* @param {string} cssText
* @return {string}
*/
function removeCustomPropApply(cssText) {
return cssText.replace(RX.mixinApply, "").replace(RX.varApply, "");
}
var StyleNode, types, OPEN_BRACE, CLOSE_BRACE, RX, VAR_START, MEDIA_START, AT_START;
var init_css_parse = __esm({ "../../node_modules/@webcomponents/shadycss/src/css-parse.js": (() => {
StyleNode = class {
constructor() {
/** @type {number} */
this["start"] = 0;
/** @type {number} */
this["end"] = 0;
/** @type {StyleNode} */
this["previous"] = null;
/** @type {StyleNode} */
this["parent"] = null;
/** @type {Array<StyleNode>} */
this["rules"] = null;
/** @type {string} */
this["parsedCssText"] = "";
/** @type {string} */
this["cssText"] = "";
/** @type {boolean} */
this["atRule"] = false;
/** @type {number} */
this["type"] = 0;
/** @type {string} */
this["keyframesName"] = "";
/** @type {string} */
this["selector"] = "";
/** @type {string} */
this["parsedSelector"] = "";
}
};
types = {
STYLE_RULE: 1,
KEYFRAMES_RULE: 7,
MEDIA_RULE: 4,
MIXIN_RULE: 1e3
};
OPEN_BRACE = "{";
CLOSE_BRACE = "}";
RX = {
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
};
VAR_START = "--";
MEDIA_START = "@media";
AT_START = "@";
}) });
//#endregion
//#region ../../node_modules/@webcomponents/shadycss/src/common-regex.js
var VAR_ASSIGN, MIXIN_MATCH, MEDIA_MATCH;
var init_common_regex = __esm({ "../../node_modules/@webcomponents/shadycss/src/common-regex.js": (() => {
VAR_ASSIGN = /(?:^|[;\s{]\s*)(--[\w-]*?)\s*:\s*(?:((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};{])+)|\{([^}]*)\}(?:(?=[;\s}])|$))/gi;
MIXIN_MATCH = /(?:^|\W+)@apply\s*\(?([^);\n]*)\)?/gi;
MEDIA_MATCH = /@media\s(.*)/;
}) });
//#endregion
//#region ../../node_modules/@webcomponents/shadycss/src/unscoped-style-handler.js
/**
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
/**
* Add a specifically-marked style to the document directly, and only one copy of that style.
*
* @param {!HTMLStyleElement} style
* @return {undefined}
*/
function processUnscopedStyle(style$1) {
const text = style$1.textContent;
if (!styleTextSet.has(text)) {
styleTextSet.add(text);
const newStyle = document.createElement("style");
newStyle.setAttribute("shady-unscoped", "");
newStyle.textContent = text;
document.head.appendChild(newStyle);
}
}
/**
* Check if a style is supposed to be unscoped
* @param {!HTMLStyleElement} style
* @return {boolean} true if the style has the unscoping attribute
*/
function isUnscopedStyle(style$1) {
return style$1.hasAttribute(scopingAttribute);
}
var styleTextSet, scopingAttribute;
var init_unscoped_style_handler = __esm({ "../../node_modules/@webcomponents/shadycss/src/unscoped-style-handler.js": (() => {
styleTextSet = /* @__PURE__ */ new Set();
scopingAttribute = "shady-unscoped";
}) });
//#endregion
//#region ../../node_modules/@webcomponents/shadycss/src/style-util.js
/**
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
/**
* @param {string|StyleNode} rules
* @param {function(StyleNode)=} callback
* @return {string}
*/
function toCssText(rules, callback) {
if (!rules) return "";
if (typeof rules === "string") rules = parse(rules);
if (callback) forEachRule(rules, callback);
return stringify(rules, nativeCssVariables);
}
/**
* @param {HTMLStyleElement} style
* @return {StyleNode}
*/
function rulesForStyle(style$1) {
if (!style$1["__cssRules"] && style$1.textContent) style$1["__cssRules"] = parse(style$1.textContent);
return style$1["__cssRules"] || null;
}
/**
* @param {StyleNode} node
* @param {Function=} styleRuleCallback
* @param {Function=} keyframesRuleCallback
* @param {boolean=} onlyActiveRules
*/
function forEachRule(node, styleRuleCallback, keyframesRuleCallback, onlyActiveRules) {
if (!node) return;
let skipRules = false;
let type = node["type"];
if (onlyActiveRules) {
if (type === types.MEDIA_RULE) {
let matchMedia = node["selector"].match(MEDIA_MATCH);
if (matchMedia) {
if (!window.matchMedia(matchMedia[1]).matches) skipRules = true;
}
}
}
if (type === types.STYLE_RULE) styleRuleCallback(node);
else if (keyframesRuleCallback && type === types.KEYFRAMES_RULE) keyframesRuleCallback(node);
else if (type === types.MIXIN_RULE) skipRules = true;
let r$ = node["rules"];
if (r$ && !skipRules) for (let i$1 = 0, l = r$.length, r$2; i$1 < l && (r$2 = r$[i$1]); i$1++) forEachRule(r$2, styleRuleCallback, keyframesRuleCallback, onlyActiveRules);
}
/**
* Walk from text[start] matching parens and
* returns position of the outer end paren
* @param {string} text
* @param {number} start
* @return {number}
*/
function findMatchingParen(text, start) {
let level = 0;
for (let i$1 = start, l = text.length; i$1 < l; i$1++) if (text[i$1] === "(") level++;
else if (text[i$1] === ")") {
if (--level === 0) return i$1;
}
return -1;
}
/**
* @param {string} str
* @param {function(string, string, string, string)} callback
*/
function processVariableAndFallback(str, callback) {
let start = str.indexOf("var(");
if (start === -1) return callback(str, "", "", "");
let end = findMatchingParen(str, start + 3);
let inner = str.substring(start + 4, end);
let prefix = str.substring(0, start);
let suffix = processVariableAndFallback(str.substring(end + 1), callback);
let comma = inner.indexOf(",");
if (comma === -1) return callback(prefix, inner.trim(), "", suffix);
return callback(prefix, inner.substring(0, comma).trim(), inner.substring(comma + 1).trim(), suffix);
}
/**
* @param {Element | {is: string, extends: string}} element
* @return {{is: string, typeExtension: string}}
*/
function getIsExtends(element) {
let localName = element["localName"];
let is = "", typeExtension = "";
if (localName) if (localName.indexOf("-") > -1) is = localName;
else {
typeExtension = localName;
is = element.getAttribute && element.getAttribute("is") || "";
}
else {
is = element.is;
typeExtension = element.extends;
}
return {
is,
typeExtension
};
}
/**
* @param {Element|DocumentFragment} element
* @return {string}
*/
function gatherStyleText(element) {
/** @type {!Array<string>} */
const styleTextParts = [];
const styles = element.querySelectorAll("style");
for (let i$1 = 0; i$1 < styles.length; i$1++) {
const style$1 = styles[i$1];
if (isUnscopedStyle(style$1)) {
if (!nativeShadow) {
processUnscopedStyle(style$1);
style$1.parentNode.removeChild(style$1);
}
} else {
styleTextParts.push(style$1.textContent);
style$1.parentNode.removeChild(style$1);
}
}
return styleTextParts.join("").trim();
}
/**
* Return the polymer-css-build "build type" applied to this element
*
* @param {!HTMLElement} element
* @return {string} Can be "", "shady", or "shadow"
*/
function getCssBuild(element) {
if (cssBuild !== void 0) return cssBuild;
if (element.__cssBuild === void 0) {
const attrValue = element.getAttribute(CSS_BUILD_ATTR);
if (attrValue) element.__cssBuild = attrValue;
else {
const buildComment = getBuildComment(element);
if (buildComment !== "") removeBuildComment(element);
element.__cssBuild = buildComment;
}
}
return element.__cssBuild || "";
}
/**
* Check if the given element, either a <template> or <style>, has been processed
* by polymer-css-build.
*
* If so, then we can make a number of optimizations:
* - polymer-css-build will decompose mixins into individual CSS Custom Properties,
* so the ApplyShim can be skipped entirely.
* - Under native ShadowDOM, the style text can just be copied into each instance
* without modification
* - If the build is "shady" and ShadyDOM is in use, the styling does not need
* scoping beyond the shimming of CSS Custom Properties
*
* @param {!HTMLElement} element
* @return {boolean}
*/
function elementHasBuiltCss(element) {
return getCssBuild(element) !== "";
}
/**
* For templates made with tagged template literals, polymer-css-build will
* insert a comment of the form `<!--css-build:shadow-->`
*
* @param {!HTMLElement} element
* @return {string}
*/
function getBuildComment(element) {
const buildComment = element.localName === "template" ? element.content.firstChild : element.firstChild;
if (buildComment instanceof Comment) {
const commentParts = buildComment.textContent.trim().split(":");
if (commentParts[0] === CSS_BUILD_ATTR) return commentParts[1];
}
return "";
}
/**
* @param {!HTMLElement} element
*/
function removeBuildComment(element) {
const buildComment = element.localName === "template" ? element.content.firstChild : element.firstChild;
buildComment.parentNode.removeChild(buildComment);
}
var wrap$3, CSS_BUILD_ATTR;
var init_style_util = __esm({ "../../node_modules/@webcomponents/shadycss/src/style-util.js": (() => {
init_style_settings();
init_css_parse();
init_common_regex();
init_unscoped_style_handler();
wrap$3 = window["ShadyDOM"] && window["ShadyDOM"]["wrap"] || ((node) => node);
CSS_BUILD_ATTR = "css-build";
}) });
//#endregion
//#region ../../node_modules/@webcomponents/shadycss/src/common-utils.js
/**
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
/**
* @param {Element} element
* @param {Object=} properties
*/
function updateNativeProperties(element, properties) {
for (let p$3 in properties) if (p$3 === null) element.style.removeProperty(p$3);
else element.style.setProperty(p$3, properties[p$3]);
}
/**
* @param {Element} element
* @param {string} property
* @return {string}
*/
function getComputedStyleValue(element, property) {
/**
* @const {string}
*/
const value = window.getComputedStyle(element).getPropertyValue(property);
if (!value) return "";
else return value.trim();
}
/**
* return true if `cssText` contains a mixin definition or consumption
* @param {string} cssText
* @return {boolean}
*/
function detectMixin(cssText) {
const has = MIXIN_MATCH.test(cssText) || VAR_ASSIGN.test(cssText);
MIXIN_MATCH.lastIndex = 0;
VAR_ASSIGN.lastIndex = 0;
return has;
}
var init_common_utils = __esm({ "../../node_modules/@webcomponents/shadycss/src/common-utils.js": (() => {
init_common_regex();
}) });
//#endregion
//#region ../../node_modules/@webcomponents/shadycss/src/apply-shim.js
/**
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
var APPLY_NAME_CLEAN, INITIAL_INHERIT, IMPORTANT, MIXIN_VAR_SEP, MixinMap, invalidCallback, ApplyShim, apply_shim_default;
var init_apply_shim$1 = __esm({ "../../node_modules/@webcomponents/shadycss/src/apply-shim.js": (() => {
init_style_util();
init_common_regex();
init_common_utils();
APPLY_NAME_CLEAN = /;\s*/m;
INITIAL_INHERIT = /^\s*(initial)|(inherit)\s*$/;
IMPORTANT = /\s*!important/;
MIXIN_VAR_SEP = "_-_";
MixinMap = class {
constructor() {
/** @type {!Object<string, !MixinMapEntry>} */
this._map = {};
}
/**
* @param {string} name
* @param {!PropertyEntry} props
*/
set(name, props) {
name = name.trim();
this._map[name] = {
properties: props,
dependants: {}
};
}
/**
* @param {string} name
* @return {MixinMapEntry}
*/
get(name) {
name = name.trim();
return this._map[name] || null;
}
};
invalidCallback = null;
ApplyShim = class {
constructor() {
/** @type {?string} */
this._currentElement = null;
/** @type {HTMLMetaElement} */
this._measureElement = null;
this._map = new MixinMap();
}
/**
* return true if `cssText` contains a mixin definition or consumption
* @param {string} cssText
* @return {boolean}
*/
detectMixin(cssText) {
return detectMixin(cssText);
}
/**
* Gather styles into one style for easier processing
* @param {!HTMLTemplateElement} template
* @return {HTMLStyleElement}
*/
gatherStyles(template$18) {
const styleText = gatherStyleText(template$18.content);
if (styleText) {
const style$1 = document.createElement("style");
style$1.textContent = styleText;
template$18.content.insertBefore(style$1, template$18.content.firstChild);
return style$1;
}
return null;
}
/**
* @param {!HTMLTemplateElement} template
* @param {string} elementName
* @return {StyleNode}
*/
transformTemplate(template$18, elementName) {
if (template$18._gatheredStyle === void 0) template$18._gatheredStyle = this.gatherStyles(template$18);
/** @type {HTMLStyleElement} */
const style$1 = template$18._gatheredStyle;
return style$1 ? this.transformStyle(style$1, elementName) : null;
}
/**
* @param {!HTMLStyleElement} style
* @param {string} elementName
* @return {StyleNode}
*/
transformStyle(style$1, elementName = "") {
let ast = rulesForStyle(style$1);
this.transformRules(ast, elementName);
style$1.textContent = toCssText(ast);
return ast;
}
/**
* @param {!HTMLStyleElement} style
* @return {StyleNode}
*/
transformCustomStyle(style$1) {
let ast = rulesForStyle(style$1);
forEachRule(ast, (rule) => {
if (rule["selector"] === ":root") rule["selector"] = "html";
this.transformRule(rule);
});
style$1.textContent = toCssText(ast);
return ast;
}
/**
* @param {StyleNode} rules
* @param {string} elementName
*/
transformRules(rules, elementName) {
this._currentElement = elementName;
forEachRule(rules, (r$2) => {
this.transformRule(r$2);
});
this._currentElement = null;
}
/**
* @param {!StyleNode} rule
*/
transformRule(rule) {
rule["cssText"] = this.transformCssText(rule["parsedCssText"], rule);
if (rule["selector"] === ":root") rule["selector"] = ":host > *";
}
/**
* @param {string} cssText
* @param {!StyleNode} rule
* @return {string}
*/
transformCssText(cssText, rule) {
cssText = cssText.replace(VAR_ASSIGN, (matchText, propertyName, valueProperty, valueMixin) => this._produceCssProperties(matchText, propertyName, valueProperty, valueMixin, rule));
return this._consumeCssProperties(cssText, rule);
}
/**
* @param {string} property
* @return {string}
*/
_getInitialValueForProperty(property) {
if (!this._measureElement) {
this._measureElement = document.createElement("meta");
this._measureElement.setAttribute("apply-shim-measure", "");
this._measureElement.style.all = "initial";
document.head.appendChild(this._measureElement);
}
return window.getComputedStyle(this._measureElement).getPropertyValue(property);
}
/**
* Walk over all rules before this rule to find fallbacks for mixins
*
* @param {!StyleNode} startRule
* @return {!Object}
*/
_fallbacksFromPreviousRules(startRule) {
let topRule = startRule;
while (topRule["parent"]) topRule = topRule["parent"];
const fallbacks = {};
let seenStartRule = false;
forEachRule(topRule, (r$2) => {
seenStartRule = seenStartRule || r$2 === startRule;
if (seenStartRule) return;
if (r$2["selector"] === startRule["selector"]) Object.assign(fallbacks, this._cssTextToMap(r$2["parsedCssText"]));
});
return fallbacks;
}
/**
* replace mixin consumption with variable consumption
* @param {string} text
* @param {!StyleNode=} rule
* @return {string}
*/
_consumeCssProperties(text, rule) {
/** @type {Array} */
let m$1 = null;
while (m$1 = MIXIN_MATCH.exec(text)) {
let matchText = m$1[0];
let mixinName = m$1[1];
let idx = m$1.index;
let applyPos = idx + matchText.indexOf("@apply");
let afterApplyPos = idx + matchText.length;
let textBeforeApply = text.slice(0, applyPos);
let textAfterApply = text.slice(afterApplyPos);
let defaults = rule ? this._fallbacksFromPreviousRules(rule) : {};
Object.assign(defaults, this._cssTextToMap(textBeforeApply));
let replacement = this._atApplyToCssProperties(mixinName, defaults);
text = `${textBeforeApply}${replacement}${textAfterApply}`;
MIXIN_MATCH.lastIndex = idx + replacement.length;
}
return text;
}
/**
* produce variable consumption at the site of mixin consumption
* `@apply` --foo; -> for all props (${propname}: var(--foo_-_${propname}, ${fallback[propname]}}))
* Example:
* border: var(--foo_-_border); padding: var(--foo_-_padding, 2px)
*
* @param {string} mixinName
* @param {Object} fallbacks
* @return {string}
*/
_atApplyToCssProperties(mixinName, fallbacks) {
mixinName = mixinName.replace(APPLY_NAME_CLEAN, "");
let vars = [];
let mixinEntry = this._map.get(mixinName);
if (!mixinEntry) {
this._map.set(mixinName, {});
mixinEntry = this._map.get(mixinName);
}
if (mixinEntry) {
if (this._currentElement) mixinEntry.dependants[this._currentElement] = true;
let p$3, parts, f$1;
const properties = mixinEntry.properties;
for (p$3 in properties) {
f$1 = fallbacks && fallbacks[p$3];
parts = [
p$3,
": var(",
mixinName,
MIXIN_VAR_SEP,
p$3
];
if (f$1) parts.push(",", f$1.replace(IMPORTANT, ""));
parts.push(")");
if (IMPORTANT.test(properties[p$3])) parts.push(" !important");
vars.push(parts.join(""));
}
}
return vars.join("; ");
}
/**
* @param {string} property
* @param {string} value
* @return {string}
*/
_replaceInitialOrInherit(property, value) {
let match = INITIAL_INHERIT.exec(value);
if (match) if (match[1]) value = this._getInitialValueForProperty(property);
else value = "apply-shim-inherit";
return value;
}
/**
* "parse" a mixin definition into a map of properties and values
* cssTextToMap('border: 2px solid black') -> ('border', '2px solid black')
* @param {string} text
* @param {boolean=} replaceInitialOrInherit
* @return {!Object<string, string>}
*/
_cssTextToMap(text, replaceInitialOrInherit = false) {
let props = text.split(";");
let property, value;
let out = {};
for (let i$1 = 0, p$3, sp; i$1 < props.length; i$1++) {
p$3 = props[i$1];
if (p$3) {
sp = p$3.split(":");
if (sp.length > 1) {
property = sp[0].trim();
value = sp.slice(1).join(":");
if (replaceInitialOrInherit) value = this._replaceInitialOrInherit(property, value);
out[property] = value;
}
}
}
return out;
}
/**
* @param {MixinMapEntry} mixinEntry
*/
_invalidateMixinEntry(mixinEntry) {
if (!invalidCallback) return;
for (let elementName in mixinEntry.dependants) if (elementName !== this._currentElement) invalidCallback(elementName);
}
/**
* @param {string} matchText
* @param {string} prop