var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var __accessCheck = (obj, member, msg) => { if (!member.has(obj)) throw TypeError("Cannot " + msg); }; var __privateGet = (obj, member, getter) => { __accessCheck(obj, member, "read from private field"); return getter ? getter.call(obj) : member.get(obj); }; var __privateAdd = (obj, member, value) => { if (member.has(obj)) throw TypeError("Cannot add the same private member more than once"); member instanceof WeakSet ? member.add(obj) : member.set(obj, value); }; var __privateSet = (obj, member, value, setter) => { __accessCheck(obj, member, "write to private field"); setter ? setter.call(obj, value) : member.set(obj, value); return value; }; var media_loading_indicator_exports = {}; __export(media_loading_indicator_exports, { Attributes: () => Attributes, default: () => media_loading_indicator_default }); module.exports = __toCommonJS(media_loading_indicator_exports); var import_constants = require("./constants.js"); var import_labels = require("./labels/labels.js"); var import_server_safe_globals = require("./utils/server-safe-globals.js"); var import_element_utils = require("./utils/element-utils.js"); var _mediaController, _delay; const Attributes = { LOADING_DELAY: "loadingdelay" }; const DEFAULT_LOADING_DELAY = 500; const template = import_server_safe_globals.document.createElement("template"); const loadingIndicatorIcon = ` `; template.innerHTML = /*html*/ ` ${loadingIndicatorIcon}
${import_labels.nouns.MEDIA_LOADING()}
`; class MediaLoadingIndicator extends import_server_safe_globals.globalThis.HTMLElement { constructor() { super(); __privateAdd(this, _mediaController, void 0); __privateAdd(this, _delay, DEFAULT_LOADING_DELAY); if (!this.shadowRoot) { const shadow = this.attachShadow({ mode: "open" }); const indicatorHTML = template.content.cloneNode(true); shadow.appendChild(indicatorHTML); } } static get observedAttributes() { return [ import_constants.MediaStateReceiverAttributes.MEDIA_CONTROLLER, import_constants.MediaUIAttributes.MEDIA_PAUSED, import_constants.MediaUIAttributes.MEDIA_LOADING, Attributes.LOADING_DELAY ]; } attributeChangedCallback(attrName, oldValue, newValue) { var _a, _b, _c, _d, _e; if (attrName === Attributes.LOADING_DELAY && oldValue !== newValue) { this.loadingDelay = Number(newValue); } else if (attrName === import_constants.MediaStateReceiverAttributes.MEDIA_CONTROLLER) { if (oldValue) { (_b = (_a = __privateGet(this, _mediaController)) == null ? void 0 : _a.unassociateElement) == null ? void 0 : _b.call(_a, this); __privateSet(this, _mediaController, null); } if (newValue && this.isConnected) { __privateSet(this, _mediaController, (_c = this.getRootNode()) == null ? void 0 : _c.getElementById(newValue)); (_e = (_d = __privateGet(this, _mediaController)) == null ? void 0 : _d.associateElement) == null ? void 0 : _e.call(_d, this); } } } connectedCallback() { var _a, _b, _c; const mediaControllerId = this.getAttribute( import_constants.MediaStateReceiverAttributes.MEDIA_CONTROLLER ); if (mediaControllerId) { __privateSet(this, _mediaController, (_a = this.getRootNode()) == null ? void 0 : _a.getElementById( mediaControllerId )); (_c = (_b = __privateGet(this, _mediaController)) == null ? void 0 : _b.associateElement) == null ? void 0 : _c.call(_b, this); } } disconnectedCallback() { var _a, _b; (_b = (_a = __privateGet(this, _mediaController)) == null ? void 0 : _a.unassociateElement) == null ? void 0 : _b.call(_a, this); __privateSet(this, _mediaController, null); } /** * Delay in ms */ get loadingDelay() { return __privateGet(this, _delay); } set loadingDelay(delay) { __privateSet(this, _delay, delay); const { style } = (0, import_element_utils.getOrInsertCSSRule)(this.shadowRoot, ":host"); style.setProperty( "--_loading-indicator-delay", `var(--media-loading-indicator-transition-delay, ${delay}ms)` ); } /** * Is the media paused */ get mediaPaused() { return (0, import_element_utils.getBooleanAttr)(this, import_constants.MediaUIAttributes.MEDIA_PAUSED); } set mediaPaused(value) { (0, import_element_utils.setBooleanAttr)(this, import_constants.MediaUIAttributes.MEDIA_PAUSED, value); } /** * Is the media loading */ get mediaLoading() { return (0, import_element_utils.getBooleanAttr)(this, import_constants.MediaUIAttributes.MEDIA_LOADING); } set mediaLoading(value) { (0, import_element_utils.setBooleanAttr)(this, import_constants.MediaUIAttributes.MEDIA_LOADING, value); } } _mediaController = new WeakMap(); _delay = new WeakMap(); if (!import_server_safe_globals.globalThis.customElements.get("media-loading-indicator")) { import_server_safe_globals.globalThis.customElements.define( "media-loading-indicator", MediaLoadingIndicator ); } var media_loading_indicator_default = MediaLoadingIndicator;