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 __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_captions_menu_button_exports = {}; __export(media_captions_menu_button_exports, { MediaCaptionsMenuButton: () => MediaCaptionsMenuButton, default: () => media_captions_menu_button_default }); module.exports = __toCommonJS(media_captions_menu_button_exports); var import_server_safe_globals = require("../utils/server-safe-globals.js"); var import_constants = require("../constants.js"); var import_labels = require("../labels/labels.js"); var import_media_chrome_menu_button = require("./media-chrome-menu-button.js"); var import_element_utils = require("../utils/element-utils.js"); var import_captions = require("../utils/captions.js"); var _captionsReady; const ccIconOn = ``; const ccIconOff = ``; const slotTemplate = import_server_safe_globals.document.createElement("template"); slotTemplate.innerHTML = /*html*/ ` ${ccIconOn} ${ccIconOff} `; const updateAriaChecked = (el) => { el.setAttribute("aria-checked", (0, import_captions.areSubsOn)(el).toString()); }; class MediaCaptionsMenuButton extends import_media_chrome_menu_button.MediaChromeMenuButton { constructor(options = {}) { super({ slotTemplate, tooltipContent: import_labels.tooltipLabels.CAPTIONS, ...options }); __privateAdd(this, _captionsReady, void 0); __privateSet(this, _captionsReady, false); } static get observedAttributes() { return [ ...super.observedAttributes, import_constants.MediaUIAttributes.MEDIA_SUBTITLES_LIST, import_constants.MediaUIAttributes.MEDIA_SUBTITLES_SHOWING ]; } connectedCallback() { super.connectedCallback(); this.setAttribute("aria-label", import_labels.nouns.CLOSED_CAPTIONS()); updateAriaChecked(this); } attributeChangedCallback(attrName, oldValue, newValue) { super.attributeChangedCallback(attrName, oldValue, newValue); if (attrName === import_constants.MediaUIAttributes.MEDIA_SUBTITLES_SHOWING) { updateAriaChecked(this); } } /** * Returns the element with the id specified by the `invoketarget` attribute. * @return {HTMLElement | null} */ get invokeTargetElement() { var _a; if (this.invokeTarget != void 0) return super.invokeTargetElement; return (_a = (0, import_element_utils.getMediaController)(this)) == null ? void 0 : _a.querySelector("media-captions-menu"); } /** * An array of TextTrack-like objects. * Objects must have the properties: kind, language, and label. */ get mediaSubtitlesList() { return getSubtitlesListAttr(this, import_constants.MediaUIAttributes.MEDIA_SUBTITLES_LIST); } set mediaSubtitlesList(list) { setSubtitlesListAttr(this, import_constants.MediaUIAttributes.MEDIA_SUBTITLES_LIST, list); } /** * An array of TextTrack-like objects. * Objects must have the properties: kind, language, and label. */ get mediaSubtitlesShowing() { return getSubtitlesListAttr( this, import_constants.MediaUIAttributes.MEDIA_SUBTITLES_SHOWING ); } set mediaSubtitlesShowing(list) { setSubtitlesListAttr(this, import_constants.MediaUIAttributes.MEDIA_SUBTITLES_SHOWING, list); } } _captionsReady = new WeakMap(); const getSubtitlesListAttr = (el, attrName) => { const attrVal = el.getAttribute(attrName); return attrVal ? (0, import_captions.parseTextTracksStr)(attrVal) : []; }; const setSubtitlesListAttr = (el, attrName, list) => { if (!(list == null ? void 0 : list.length)) { el.removeAttribute(attrName); return; } const newValStr = (0, import_captions.stringifyTextTrackList)(list); const oldVal = el.getAttribute(attrName); if (oldVal === newValStr) return; el.setAttribute(attrName, newValStr); }; if (!import_server_safe_globals.globalThis.customElements.get("media-captions-menu-button")) { import_server_safe_globals.globalThis.customElements.define( "media-captions-menu-button", MediaCaptionsMenuButton ); } var media_captions_menu_button_default = MediaCaptionsMenuButton;