655 lines
490 KiB
JavaScript
Raw Normal View History

2024-12-24 20:38:19 +00:00
function e(e,t,n,i){var a,r=arguments.length,s=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(s=(r<3?a(s):r>3?a(t,n,s):a(t,n))||s);return r>3&&s&&Object.defineProperty(t,n,s),s}"function"==typeof SuppressedError&&SuppressedError;
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const t=globalThis,n=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,i=Symbol(),a=new WeakMap;let r=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==i)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(n&&void 0===e){const n=void 0!==t&&1===t.length;n&&(e=a.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&a.set(t,e))}return e}toString(){return this.cssText}};const s=e=>new r("string"==typeof e?e:e+"",void 0,i),o=(e,...t)=>{const n=1===e.length?e[0]:t.reduce(((t,n,i)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+e[i+1]),e[0]);return new r(n,e,i)},c=(e,i)=>{if(n)e.adoptedStyleSheets=i.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(const n of i){const i=document.createElement("style"),a=t.litNonce;void 0!==a&&i.setAttribute("nonce",a),i.textContent=n.cssText,e.appendChild(i)}},l=n?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const n of e.cssRules)t+=n.cssText;return s(t)})(e):e
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/,{is:d,defineProperty:u,getOwnPropertyDescriptor:h,getOwnPropertyNames:p,getOwnPropertySymbols:g,getPrototypeOf:m}=Object,f=globalThis,_=f.trustedTypes,y=_?_.emptyScript:"",v=f.reactiveElementPolyfillSupport,b=(e,t)=>e,w={toAttribute(e,t){switch(t){case Boolean:e=e?y:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=null!==e;break;case Number:n=null===e?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch(e){n=null}}return n}},x=(e,t)=>!d(e,t),C={attribute:!0,type:String,converter:w,reflect:!1,hasChanged:x};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;class M extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=C){if(t.state&&(t.attribute=!1),this._$Ei(),this.elementProperties.set(e,t),!t.noAccessor){const n=Symbol(),i=this.getPropertyDescriptor(e,n,t);void 0!==i&&u(this.prototype,e,i)}}static getPropertyDescriptor(e,t,n){const{get:i,set:a}=h(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get(){return i?.call(this)},set(t){const r=i?.call(this);a.call(this,t),this.requestUpdate(e,r,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??C}static _$Ei(){if(this.hasOwnProperty(b("elementProperties")))return;const e=m(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(b("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(b("properties"))){const e=this.properties,t=[...p(e),...g(e)];for(const n of t)this.createProperty(n,e[n])}const e=this[Symbol.metadata];if(null!==e){const t=litPropertyMetadata.get(e);if(void 0!==t)for(const[e,n]of t)this.elementProperties.set(e,n)}this._$Eh=new Map;for(const[e,t]of this.elementProperties){const n=this._$Eu(e,t);void 0!==n&&this._$Eh.set(n,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const n=new Set(e.flat(1/0).reverse());for(const e of n)t.unshift(l(e))}else void 0!==e&&t.push(l(e));return t}static _$Eu(e,t){const n=t.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof e?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((e=>e(this)))}addController(e){(this._$EO??=new Set).add(e),void 0!==this.renderRoot&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return c(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((e=>e.hostConnected?.()))}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach((e=>e.hostDisconnected?.()))}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$EC(e,t){const n=this.constructor.elementProperties.get(e),i=this.constructor._$Eu(e,n);if(void 0!==i&&!0===n.reflect){const a=(void 0!==n.converter?.toAttribute?n.converter:w).toAttribute(t,n.type);this._$Em=e,null==a?this.removeAttribute(i):this.setAttribute(i,a),this._$Em=null}}_$AK(e,t){const n=this.constructor,i=n._$Eh.get(e);if(void 0!==i&&this._$Em!==i){const e=n.getPropertyOptions(i),a="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==e.converter?.fromAttribute?e.converter:w;this._$Em=i,this[i]=a.fromAttribute(t,e.type),this._$Em=null}}requestUpdate(e,t,n){if(void 0!==e){if(n??=this.constructor.getPropertyOptions(e),!(n.hasChanged??x)(this[e],t))return;this.P(e,t,n)}!1===this.isUpdateP
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const S=globalThis,k=S.trustedTypes,E=k?k.createPolicy("lit-html",{createHTML:e=>e}):void 0,$="$lit$",A=`lit$${(Math.random()+"").slice(9)}$`,I="?"+A,z=`<${I}>`,T=document,j=()=>T.createComment(""),O=e=>null===e||"object"!=typeof e&&"function"!=typeof e,D=Array.isArray,R="[ \t\n\f\r]",P=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,L=/-->/g,N=/>/g,F=RegExp(`>|${R}(?:([^\\s"'>=/]+)(${R}*=${R}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),V=/'/g,H=/"/g,B=/^(?:script|style|textarea|title)$/i,q=(e=>(t,...n)=>({_$litType$:e,strings:t,values:n}))(1),U=Symbol.for("lit-noChange"),W=Symbol.for("lit-nothing"),Z=new WeakMap,Q=T.createTreeWalker(T,129);function G(e,t){if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==E?E.createHTML(t):t}const Y=(e,t)=>{const n=e.length-1,i=[];let a,r=2===t?"<svg>":"",s=P;for(let t=0;t<n;t++){const n=e[t];let o,c,l=-1,d=0;for(;d<n.length&&(s.lastIndex=d,c=s.exec(n),null!==c);)d=s.lastIndex,s===P?"!--"===c[1]?s=L:void 0!==c[1]?s=N:void 0!==c[2]?(B.test(c[2])&&(a=RegExp("</"+c[2],"g")),s=F):void 0!==c[3]&&(s=F):s===F?">"===c[0]?(s=a??P,l=-1):void 0===c[1]?l=-2:(l=s.lastIndex-c[2].length,o=c[1],s=void 0===c[3]?F:'"'===c[3]?H:V):s===H||s===V?s=F:s===L||s===N?s=P:(s=F,a=void 0);const u=s===F&&e[t+1].startsWith("/>")?" ":"";r+=s===P?n+z:l>=0?(i.push(o),n.slice(0,l)+$+n.slice(l)+A+u):n+A+(-2===l?t:u)}return[G(e,r+(e[n]||"<?>")+(2===t?"</svg>":"")),i]};class K{constructor({strings:e,_$litType$:t},n){let i;this.parts=[];let a=0,r=0;const s=e.length-1,o=this.parts,[c,l]=Y(e,t);if(this.el=K.createElement(c,n),Q.currentNode=this.el.content,2===t){const e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;null!==(i=Q.nextNode())&&o.length<s;){if(1===i.nodeType){if(i.hasAttributes())for(const e of i.getAttributeNames())if(e.endsWith($)){const t=l[r++],n=i.getAttribute(e).split(A),s=/([.?@])?(.*)/.exec(t);o.push({type:1,index:a,name:s[2],strings:n,ctor:"."===s[1]?ne:"?"===s[1]?ie:"@"===s[1]?ae:te}),i.removeAttribute(e)}else e.startsWith(A)&&(o.push({type:6,index:a}),i.removeAttribute(e));if(B.test(i.tagName)){const e=i.textContent.split(A),t=e.length-1;if(t>0){i.textContent=k?k.emptyScript:"";for(let n=0;n<t;n++)i.append(e[n],j()),Q.nextNode(),o.push({type:2,index:++a});i.append(e[t],j())}}}else if(8===i.nodeType)if(i.data===I)o.push({type:2,index:a});else{let e=-1;for(;-1!==(e=i.data.indexOf(A,e+1));)o.push({type:7,index:a}),e+=A.length-1}a++}}static createElement(e,t){const n=T.createElement("template");return n.innerHTML=e,n}}function X(e,t,n=e,i){if(t===U)return t;let a=void 0!==i?n._$Co?.[i]:n._$Cl;const r=O(t)?void 0:t._$litDirective$;return a?.constructor!==r&&(a?._$AO?.(!1),void 0===r?a=void 0:(a=new r(e),a._$AT(e,n,i)),void 0!==i?(n._$Co??=[])[i]=a:n._$Cl=a),void 0!==a&&(t=X(e,a._$AS(e,t.values),a,i)),t}let J=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:n}=this._$AD,i=(e?.creationScope??T).importNode(t,!0);Q.currentNode=i;let a=Q.nextNode(),r=0,s=0,o=n[0];for(;void 0!==o;){if(r===o.index){let t;2===o.type?t=new ee(a,a.nextSibling,this,e):1===o.type?t=new o.ctor(a,o.name,o.strings,this,e):6===o.type&&(t=new re(a,this,e)),this._$AV.push(t),o=n[++s]}r!==o?.index&&(a=Q.nextNode(),r++)}return Q.currentNode=T,i}p(e){let t=0;for(const n of this._$AV)void 0!==n&&(void 0!==n.strings?(n._$AI(e,n,t),t+=n.strings.length-2):n._$AI(e[t])),t++}};class ee{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,i){this.type=2,this._$AH=W,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===e?.nodeType&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=X(this,e,t),O(e)?e===W||null==e||""===e?(this._$AH!==W&&this._$AR(),this._$AH=W):e!==this._$AH&&e!==U&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
let oe=class extends M{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=((e,t,n)=>{const i=n?.renderBefore??t;let a=i._$litPart$;if(void 0===a){const e=n?.renderBefore??null;i._$litPart$=a=new ee(t.insertBefore(j(),e),e,void 0,n??{})}return a._$AI(e),a})(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return U}};oe._$litElement$=!0,oe.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:oe});const ce=globalThis.litElementPolyfillSupport;ce?.({LitElement:oe}),(globalThis.litElementVersions??=[]).push("4.0.4");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const le=e=>(t,n)=>{void 0!==n?n.addInitializer((()=>{customElements.define(e,t)})):customElements.define(e,t)}
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/,de={attribute:!0,type:String,converter:w,reflect:!1,hasChanged:x},ue=(e=de,t,n)=>{const{kind:i,metadata:a}=n;let r=globalThis.litPropertyMetadata.get(a);if(void 0===r&&globalThis.litPropertyMetadata.set(a,r=new Map),r.set(n.name,e),"accessor"===i){const{name:i}=n;return{set(n){const a=t.get.call(this);t.set.call(this,n),this.requestUpdate(i,a,e)},init(t){return void 0!==t&&this.P(i,void 0,e),t}}}if("setter"===i){const{name:i}=n;return function(n){const a=this[i];t.call(this,n),this.requestUpdate(i,a,e)}}throw Error("Unsupported decorator location: "+i)};function he(e){return(t,n)=>"object"==typeof n?ue(e,t,n):((e,t,n)=>{const i=t.hasOwnProperty(n);return t.constructor.createProperty(n,i?{...e,wrapped:!0}:e),i?Object.getOwnPropertyDescriptor(t,n):void 0})(e,t,n)
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/}function pe(e){return he({...e,state:!0,attribute:!1})}
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const ge={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},me=e=>(...t)=>({_$litDirective$:e,values:t});let fe=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,n){this._$Ct=e,this._$AM=t,this._$Ci=n}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}};
/**
* @license
* Copyright 2018 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const _e=me(class extends fe{constructor(e){if(super(e),e.type!==ge.ATTRIBUTE||"class"!==e.name||e.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return" "+Object.keys(e).filter((t=>e[t])).join(" ")+" "}update(e,[t]){if(void 0===this.st){this.st=new Set,void 0!==e.strings&&(this.nt=new Set(e.strings.join(" ").split(/\s/).filter((e=>""!==e))));for(const e in t)t[e]&&!this.nt?.has(e)&&this.st.add(e);return this.render(t)}const n=e.element.classList;for(const e of this.st)e in t||(n.remove(e),this.st.delete(e));for(const e in t){const i=!!t[e];i===this.st.has(e)||this.nt?.has(e)||(i?(n.add(e),this.st.add(e)):(n.remove(e),this.st.delete(e)))}return U}}),ye=e=>e??W
/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/,ve=e=>null===e||"object"!=typeof e&&"function"!=typeof e,be=e=>void 0===e.strings,we={},xe=(e,t=we)=>e._$AH=t
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/,Ce=(e,t)=>{const n=e._$AN;if(void 0===n)return!1;for(const e of n)e._$AO?.(t,!1),Ce(e,t);return!0},Me=e=>{let t,n;do{if(void 0===(t=e._$AM))break;n=t._$AN,n.delete(e),e=t}while(0===n?.size)},Se=e=>{for(let t;t=e._$AM;e=t){let n=t._$AN;if(void 0===n)t._$AN=n=new Set;else if(n.has(e))break;n.add(e),$e(t)}};
/**
* @license
* Copyright 2018 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/function ke(e){void 0!==this._$AN?(Me(this),this._$AM=e,Se(this)):this._$AM=e}function Ee(e,t=!1,n=0){const i=this._$AH,a=this._$AN;if(void 0!==a&&0!==a.size)if(t)if(Array.isArray(i))for(let e=n;e<i.length;e++)Ce(i[e],!1),Me(i[e]);else null!=i&&(Ce(i,!1),Me(i));else Ce(this,e)}const $e=e=>{e.type==ge.CHILD&&(e._$AP??=Ee,e._$AQ??=ke)};class Ae extends fe{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,n){super._$AT(e,t,n),Se(this),this.isConnected=e._$AU}_$AO(e,t=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),t&&(Ce(this,e),Me(this))}setValue(e){if(be(this._$Ct))this._$Ct._$AI(e,this);else{const t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}}
/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const Ie=()=>new ze;let ze=class{};const Te=new WeakMap,je=me(class extends Ae{render(e){return W}update(e,[t]){const n=t!==this.Y;return n&&void 0!==this.Y&&this.rt(void 0),(n||this.lt!==this.ct)&&(this.Y=t,this.ht=e.options?.host,this.rt(this.ct=e.element)),W}rt(e){if("function"==typeof this.Y){const t=this.ht??globalThis;let n=Te.get(t);void 0===n&&(n=new WeakMap,Te.set(t,n)),void 0!==n.get(this.Y)&&this.Y.call(this.ht,void 0),n.set(this.Y,e),void 0!==e&&this.Y.call(this.ht,e)}else this.Y.value=e}get lt(){return"function"==typeof this.Y?Te.get(this.ht??globalThis)?.get(this.Y):this.Y?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}}),Oe="important",De=" !"+Oe,Re=me(class extends fe{constructor(e){if(super(e),e.type!==ge.ATTRIBUTE||"style"!==e.name||e.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce(((t,n)=>{const i=e[n];return null==i?t:t+`${n=n.includes("-")?n:n.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`}),"")}update(e,[t]){const{style:n}=e.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(t)),this.render(t);for(const e of this.ft)null==t[e]&&(this.ft.delete(e),e.includes("-")?n.removeProperty(e):n[e]=null);for(const e in t){const i=t[e];if(null!=i){this.ft.add(e);const t="string"==typeof i&&i.endsWith(De);e.includes("-")||t?n.setProperty(e,t?i.slice(0,-11):i,t?Oe:""):n[e]=i}}return U}});
/**
* @license
* Copyright 2018 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/function Pe(e,t,n,i=20,a=0){let r=[];if(a>=i)return r;const s=e=>{const r=e.assignedNodes().filter((e=>1===e.nodeType));return r.length>0?Pe(r[0].parentElement,t,n,i,a+1):[]},o=Array.from(e.children||[]);for(const e of o)t(e)||(n(e)&&r.push(e),null!=e.shadowRoot?r.push(...Pe(e.shadowRoot,t,n,i,a+1)):"SLOT"===e.tagName?r.push(...s(e)):r.push(...Pe(e,t,n,i,a+1)));return r}function Le(e){return e.hasAttribute("hidden")||e.hasAttribute("aria-hidden")&&"false"!==e.getAttribute("aria-hidden")||"none"===e.style.display||"0"===e.style.opacity||"hidden"===e.style.visibility||"collapse"===e.style.visibility}function Ne(e){return"-1"!==e.getAttribute("tabindex")&&!Le(e)&&!function(e){return e.hasAttribute("disabled")||e.hasAttribute("aria-disabled")&&"false"!==e.getAttribute("aria-disabled")}(e)&&(e.hasAttribute("tabindex")||(e instanceof HTMLAnchorElement||e instanceof HTMLAreaElement)&&e.hasAttribute("href")||e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLIFrameElement)}const Fe=new Map;const Ve=document.createElement("template");Ve.innerHTML='\n\t<div id="start"></div>\n\t<div id="backup"></div>\n\t<slot></slot>\n\t<div id="end"></div>\n';class He extends HTMLElement{constructor(){super(),this.debounceId=Math.random().toString(),this._focused=!1;const e=this.attachShadow({mode:"open"});e.appendChild(Ve.content.cloneNode(!0)),this.$backup=e.querySelector("#backup"),this.$start=e.querySelector("#start"),this.$end=e.querySelector("#end"),this.focusLastElement=this.focusLastElement.bind(this),this.focusFirstElement=this.focusFirstElement.bind(this),this.onFocusIn=this.onFocusIn.bind(this),this.onFocusOut=this.onFocusOut.bind(this)}static get observedAttributes(){return["inactive"]}get inactive(){return this.hasAttribute("inactive")}set inactive(e){e?this.setAttribute("inactive",""):this.removeAttribute("inactive")}get focused(){return this._focused}connectedCallback(){this.$start.addEventListener("focus",this.focusLastElement),this.$end.addEventListener("focus",this.focusFirstElement),this.addEventListener("focusin",this.onFocusIn),this.addEventListener("focusout",this.onFocusOut),this.render()}disconnectedCallback(){this.$start.removeEventListener("focus",this.focusLastElement),this.$end.removeEventListener("focus",this.focusFirstElement),this.removeEventListener("focusin",this.onFocusIn),this.removeEventListener("focusout",this.onFocusOut)}attributeChangedCallback(){this.render()}focusFirstElement(){this.trapFocus()}focusLastElement(){this.trapFocus(!0)}getFocusableElements(){return Pe(this,Le,Ne)}trapFocus(e){if(this.inactive)return;let t=this.getFocusableElements();t.length>0?(e?t[t.length-1].focus():t[0].focus(),this.$backup.setAttribute("tabindex","-1")):(this.$backup.setAttribute("tabindex","0"),this.$backup.focus())}onFocusIn(){this.updateFocused(!0)}onFocusOut(){this.updateFocused(!1)}updateFocused(e){!function(e,t,n){const i=Fe.get(n);null!=i&&window.clearTimeout(i),Fe.set(n,window.setTimeout((()=>{e(),Fe.delete(n)}),t))}((()=>{this.focused!==e&&(this._focused=e,this.render())}),0,this.debounceId)}render(){this.$start.setAttribute("tabindex",!this.focused||this.inactive?"-1":"0"),this.$end.setAttribute("tabindex",!this.focused||this.inactive?"-1":"0"),this.focused?this.setAttribute("focused",""):this.removeAttribute("focused")}}function Be(e){return Number(e.getAttribute("data-dialog-count"))||0}function qe(e,t){e.setAttribute("data-dialog-count",t.toString())}function Ue(e=document.activeElement){return null!=e&&null!=e.shadowRoot&&null!=e.shadowRoot.activeElement?Ue(e.shadowRoot.activeElement):e}window.customElements.define("focus-trap",He);const We=document.createElement("template");We.innerHTML='\n <style>*{box-sizing:border-box}:host{padding:var(--dialog-container-padding,5vw 24px);z-index:var(--dialog-z-index,12345678);outline:none}#backdrop,:host{position:fixed;top:0;left:0;bottom:0;right:0}:host,:host([center]) #dialog{overflow-x:var(--dialog-overflow-x,hidden);overflow-y:var(--dialog-overflow-y,auto);overscroll-
/* istanbul ignore if: the if path cannot be reached -- @preserve */
if(!i)return t;const a=await(async e=>await Jm(e,(e=>this._engineFactory.getEngineForCamera(i,e))))(e);for(const[i,r]of e.entries()){const e=a[i],s=e?n.get(e)??await this._engineFactory.createEngine(e,{eventCallback:e=>this._api.getTriggersManager().handleCameraEvent(e),stateWatcher:this._api.getHASSManager().getStateWatcher(),resolvedMediaCache:this._api.getResolvedMediaCache()}):null;if(!s||!e)throw new qy(N_("error.no_camera_engine"),l_(r));n.set(e,s),t.set(r,s)}return t}async _initializeCameras(e){const t=new Date,n=this._api.getHASSManager().getHASS();
/* istanbul ignore if: the if path cannot be reached -- @preserve */
if(!n)return;e.some((e=>(e=>e.triggers.motion||e.triggers.occupancy)(e)))&&await this._api.getEntityRegistryManager().fetchEntityList(n);const i=await this._getEnginesForCameras(e),a=await Jm(i.entries(),(async([e,t])=>await t.createCamera(n,e))),r=async()=>{a.forEach((e=>e.destroy()))},s=new Set;for(const e of a){const t=F_(e.getConfig());if(!t)throw await r(),new qy(N_("error.no_camera_id"),e.getConfig());if(s.has(t))throw await r(),new qy(N_("error.duplicate_camera_id"),e.getConfig());e.setID(t),s.add(t)}await this._store.setCameras(a),V_(this._api.getConfigManager().getCardWideConfig(),"Frigate Card CameraManager initialized (Cameras: ",this._store.getCameras(),`, Duration: ${((new Date).getTime()-t.getTime())/1e3}s,`,")")}isInitialized(){return this._store.getCameraCount()>0}getStore(){return this._store}generateDefaultEventQueries(e,t){return this._generateDefaultQueries(e,{type:Wy.Event,...t})}generateDefaultRecordingQueries(e,t){return this._generateDefaultQueries(e,{type:Wy.Recording,...t})}generateDefaultRecordingSegmentsQueries(e,t){return this._generateDefaultQueries(e,{type:Wy.RecordingSegments,...t})}_generateDefaultQueries(e,t){const n=[],i=Um(e),a=this._store.getEnginesForCameraIDs(i);if(!a)return null;for(const[e,i]of a){let a=null;
/* istanbul ignore else: the else path cannot be reached -- @preserve */Jy.isEventQuery(t)?a=e.generateDefaultEventQuery(this._store,i,t):Jy.isRecordingQuery(t)?a=e.generateDefaultRecordingQuery(this._store,i,t):Jy.isRecordingSegmentsQuery(t)&&(a=e.generateDefaultRecordingSegmentsQuery(this._store,i,t));for(const e of a??[])n.push(e)}return n.length?n:null}async getMediaMetadata(){const e=new Set,t=new Set,n=new Set,i=new Set,a={type:Wy.MediaMetadata,cameraIDs:this._store.getCameraIDs()},r=await this._handleQuery(a);for(const a of r.values())a.metadata.tags&&a.metadata.tags.forEach(e.add,e),a.metadata.what&&a.metadata.what.forEach(t.add,t),a.metadata.where&&a.metadata.where.forEach(n.add,n),a.metadata.days&&a.metadata.days.forEach(i.add,i);return t.size||n.size||i.size||e.size?{...e.size&&{tags:e},...t.size&&{what:t},...n.size&&{where:n},...i.size&&{days:i}}:null}async getEvents(e,t){return await this._handleQuery(e,t)}async getRecordings(e,t){return await this._handleQuery(e,t)}async getRecordingSegments(e,t){return await this._handleQuery(e,t)}async executeMediaQueries(e,t){return this._convertQueryResultsToMedia(await this._handleQuery(e,t))}async extendMediaQueries(e,t,n,i){if(!this._api.getHASSManager().getHASS())return null;const a=e=>{let n=null;for(const i of t){const t=i.getStartTime();t&&(!n||"earliest"===e&&t<n||"latest"===e&&t>n)&&(n=t)}return n},r=this._api.getConfigManager().getCardWideConfig()?.performance?.features.media_chunk_size??50,s=[],o=[];for(const t of e){const e={...t};
/* istanbul ignore else: the else path cannot be reached -- @preserve */if("later"===n){const t=a("latest");t&&(e.start=t,delete e.end)}else if("earlier"===n){const t=a("earliest");t&&(e.end=t,delete e.start)}e.limit=r,o.push({...t,limit:(t.limit??0)+r}),s.push(e)}const c=this._convertQueryResultsToMedia(await this._handleQuery(s,i));if(!c.length)return null;const l=Xy(t.concat(c));return l.length===t.length?null:{queries:o,results:l}}async getMediaDownloadPath(e){const t=this._store.getCameraConfigForMedia(e),n=this._store.getEngineForMedia(e),i=this._api.getHASSManager().getHASS();return t&&n&&i?await n.getMediaDownloadPath(i,t,e):null}getMediaCapabilities(e){const t=this._store.getEngineForMedia(e);return t?t.getMediaCapabilities(e):null}async favoriteMedia(e,t){const n=this._store.getCameraConfigForMedia(e),i=this._store.getEngineForMedia(e),a=this._api.getHASSManager().getHASS();if(!n||!i||!a)return;const r=new Date;await this._requestLimit.add((()=>i.favoriteMedia(a,n,e,t))),V_(this._api.getConfigManager().getCardWideConfig(),"Frigate Card CameraManager favorite request (",`Duration: ${((new Date).getTime()-r.getTime())/1e3}s,`,"Media:",e.getID(),", Favorite:",t,")")}areMediaQueriesResultsFresh(e,t){const n=new Date;for(const i of e){const e=this._store.getEnginesForCameraIDs(i.cameraIDs);for(const[a,r]of e??[]){const e=a.getQueryResultMaxAge({...i,cameraIDs:r});if(null!==e&&Bd(t,{seconds:e})<n)return!1}}return!0}async getMediaSeekTime(e,t){const n=e.getStartTime(),i=e.getEndTime(),a=this._store.getEngineForMedia(e),r=this._api.getHASSManager().getHASS();return!r||!a||!n||!i||t<n||t>i?null:await this._requestLimit.add((()=>a.getMediaSeekTime(r,this._store,e,t)))??null}async _handleQuery(e,t){const n=qm(e),i=new Map,a=new Date,r=this._api.getHASSManager().getHASS();if(!r)return i;const s=async(e,n)=>{let a=null;
/* istanbul ignore else: the else path cannot be reached -- @preserve */Jy.isEventQuery(n)?a=await e.getEvents(r,this._store,n,t):Jy.isRecordingQuery(n)?a=await e.getRecordings(r,this._store,n,t):Jy.isRecordingSegmentsQuery(n)?a=await e.getRecordingSegments(r,this._store,n,t):Jy.isMediaMetadataQuery(n)&&(a=await e.getMediaMetadata(r,this._store,n,t)),a?.forEach(((e,t)=>i.set(t,e)))},o=async e=>{const t=this._store.getEnginesForCameraIDs(e.cameraIDs);t&&await Promise.all(Array.from(t.keys()).map((n=>this._requestLimit.add((()=>s(n,{...e,cameraIDs:t.get(n)}))))))};await Promise.all(n.map((e=>o(e))));const c=(l=Array.from(i.values()).map((e=>Number(e.cached??0))))&&l.length?function(e,t){for(var n,i=-1,a=e.length;++i<a;){var r=t(e[i]);void 0!==r&&(n=void 0===n?r:n+r)}return n}(l,Xg):0;var l;return V_(this._api.getConfigManager().getCardWideConfig(),"Frigate Card CameraManager request [Input queries:",n.length,", Cached output queries:",c,", Total output queries:",i.size,", Duration:",((new Date).getTime()-a.getTime())/1e3+"s,",", Queries:",n,", Results:",i,", Options:",t??{},"]"),i}_convertQueryResultsToMedia(e){const t=[],n=this._api.getHASSManager().getHASS();if(!n)return t;for(const[i,a]of e.entries()){const e=this._store.getEngineOfType(a.engine);if(e){let r=null;
/* istanbul ignore else: the else path cannot be reached -- @preserve */Jy.isEventQuery(i)&&ev.isEventQueryResult(a)?r=e.generateMediaFromEvents(n,this._store,i,a):Jy.isRecordingQuery(i)&&ev.isRecordingQueryResult(a)&&(r=e.generateMediaFromRecordings(n,this._store,i,a)),r&&t.push(...r)}}return Xy(t)}getCameraEndpoints(e,t){const n=this._store.getCameraConfig(e),i=this._store.getEngineForCameraID(e);return n&&i?i.getCameraEndpoints(n,t):null}getCameraMetadata(e){const t=this._store.getCameraConfig(e),n=this._store.getEngineForCameraID(e),i=this._api.getHASSManager().getHASS();return t&&n&&i?n.getCameraMetadata(i,t):null}getCameraCapabilities(e){return this._store.getCamera(e)?.getCapabilities()??null}getAggregateCameraCapabilities(e){const t=[...e??this._store.getCameraIDs()].map((e=>this._store.getCamera(e))).filter(rf);return new W_({live:t.some((e=>e.getCapabilities()?.has("live"))),clips:t.some((e=>e.getCapabilities()?.has("clips"))),recordings:t.some((e=>e.getCapabilities()?.has("recordings"))),snapshots:t.some((e=>e.getCapabilities()?.has("snapshots"))),"favorite-events":t.some((e=>e.getCapabilities()?.has("favorite-events"))),"favorite-recordings":t.some((e=>e.getCapabilities()?.has("favorite-recordings"))),seek:t.some((e=>e.getCapabilities()?.has("seek"))),menu:t.some((e=>e.getCapabilities()?.has("menu")))})}async executePTZAction(e,t,n){const i=this._store.getCameraConfig(e);if(!i)return;const a=H_(i,t,n);if(a)return await this._api.getActionsManager().executeActions(a);const r=this._api.getHASSManager().getHASS(),s=this._store.getEngineForCameraID(e);return s&&r?await this._requestLimit.add((()=>s.executePTZAction(r,i,t,n))):void 0}}class nv{constructor(e){this._cache=new Map,this._keyCallback=e}has(e){return this._cache.has(e)}getMatches(e){return[...this._cache.values()].filter(e)}get(e){return this._cache.get(e)??null}add(e){const t=e=>this._cache.set(this._keyCallback(e),e);Array.isArray(e)?e.forEach(t):t(e)}}const iv=bi.object({id:bi.string(),model:bi.string().nullable(),config_entries:bi.string().array(),manufacturer:bi.string().nullable()}).array();class av{constructor(e){this._fetchedDeviceList=!1,this._cache=e}async getDevice(e,t){return this._cache.has(t)?this._cache.get(t):(await this._fetchDeviceList(e),this._cache.get(t)??null)}async getMatchingDevices(e,t){return await this._fetchDeviceList(e),this._cache.getMatches(t)}async _fetchDeviceList(e){if(this._fetchedDeviceList)return;let t=null;try{t=await ky(e,iv,{type:"config/device_registry/list"})}catch(e){return void Zm(e)}this._cache.add(t),this._fetchedDeviceList=!0}}const rv=bi.object({config_entry_id:bi.string().nullable(),device_id:bi.string().nullable(),disabled_by:bi.string().nullable(),entity_id:bi.string(),hidden_by:bi.string().nullable(),platform:bi.string(),translation_key:bi.string().nullable(),unique_id:bi.string().or(bi.number()).optional()}),sv=rv.array();class ov{constructor(e){this._fetchedEntityList=!1,this._cache=e}async getEntity(e,t){const n=this._cache.get(t);if(n)return n;let i=null;try{i=await ky(e,rv,{type:"config/entity_registry/get",entity_id:t})}catch(e){return Zm(e),null}return this._cache.add(i),i}async getMatchingEntities(e,t){return await this.fetchEntityList(e),this._cache.getMatches(t)}async getEntities(e,t){const n=new Map;return await Promise.all(t.map((async t=>{const i=await this.getEntity(e,t);i&&n.set(t,i)}))),n}async fetchEntityList(e){if(this._fetchedEntityList)return;let t=null;try{t=await ky(e,sv,{type:"config/entity_registry/list"})}catch(e){return void Zm(e)}this._cache.add(t),this._fetchedEntityList=!0}}class cv extends Map{constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if("number"==typeof e.maxAge&&0===e.maxAge)throw new TypeError("`maxAge` must be a number greater than 0");this.maxSize=e.maxSize,this.maxAge=e.maxAge||Number.POSITIVE_INFINITY,this.onEviction=e.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_emitEvictions(e){if("function"==typeof this.onEviction)for(const[t,n]of e)this.onEviction(t,n.value)}_dele
/* istanbul ignore else: the else path cannot be reached -- @preserve */
void("start"===this._action.ptz_phase?(Pv(n,this._context.ptzDigital),Lv(n,this._context,"ptzDigital",this),await this._stepChange(e,n),this._timer.startRepeated(.1,(()=>this._stepChange(e,n)))):"stop"===this._action.ptz_phase&&(Pv(n,this._context.ptzDigital),delete this._context.ptzDigital?.[n])):void 0}_convertActionToZoomSettings(e){if(!this._action.absolute&&!this._action.ptz_action)return{};if(this._action.absolute)return this._action.absolute;const t=e?.zoom??1,n=e?.pan?.x??50,i=e?.pan?.y??50,a="zoom_in"===this._action.ptz_action?.1:"zoom_out"===this._action.ptz_action?-.1:0,r="left"===this._action.ptz_action?-5:"right"===this._action.ptz_action?5:0,s="up"===this._action.ptz_action?-5:"down"===this._action.ptz_action?5:0;return{zoom:Vv(t+a,1,10),pan:{x:Vv(n+r,0,100),y:Vv(i+s,0,100)}}}}class Kv extends hv{async execute(e){const t=e.getViewManager().getView();let n=null,i=null;if(this._action.target_id)n=this._action.target_id,i=Dv(e.getCameraManager(),n)?"ptz":"digital";else if(t){const a=Ov(t,{cameraManager:e.getCameraManager()});n=a?.targetID??null,i=a?.type??null}n&&null!==i&&("ptz"===i?this._toPTZAction(n):this._toPTZDigitalAction(n)).execute(e)}_toPTZAction(e){return new Nv(this._context,(t={cardID:this._action.card_id,cameraID:e,ptzAction:this._action.ptz_action,ptzPhase:this._action.ptz_phase,ptzPreset:this._action.ptz_preset},{action:"fire-dom-event",frigate_card_action:"ptz",...t?.cardID&&{card_id:t.cardID},...t?.ptzAction&&{ptz_action:t.ptzAction},...t?.ptzPhase&&{ptz_phase:t.ptzPhase},...t?.ptzPreset&&{ptz_preset:t.ptzPreset},...t?.cameraID&&{camera:t.cameraID}}),this._config);var t}_toPTZDigitalAction(e){return new Yv(this._context,(t={cardID:this._action.card_id,ptzPhase:this._action.ptz_phase,ptzAction:this._action.ptz_action,targetID:e},{action:"fire-dom-event",frigate_card_action:"ptz_digital",...t?.cardID&&{card_id:t.cardID},...t?.ptzAction&&{ptz_action:t.ptzAction},...t?.ptzPhase&&{ptz_phase:t.ptzPhase},...t?.absolute&&{absolute:t.absolute},...t?.targetID&&{target_id:t.targetID}}),this._config);var t}}class Xv extends hv{async execute(e){await e.getDownloadManager().downloadScreenshot()}}class Jv extends hv{async execute(e){var t;await tf((t=this._action.duration,3600*(t.h??0)+60*(t.m??0)+(t.s??0)+(t.ms??0)/1e3))}}class eb extends hv{async execute(e){switch(this._action.status_bar_action){case"reset":e.getStatusBarItemManager().removeAllDynamicStatusBarItems();break;case"add":this._action.items?.forEach((t=>e.getStatusBarItemManager().addDynamicStatusBarItem(t)));break;case"remove":this._action.items?.forEach((t=>e.getStatusBarItemManager().removeDynamicStatusBarItem(t)))}}}class tb{modify(e){(e=>{const t=e.context?.live?.overrides;t&&t.has(e.camera)&&e.context?.live?.overrides?.delete(e.camera)})(e)}}class nb extends hv{async execute(e){e.getViewManager().setViewByParameters({modifiers:[new tb]})}}class ib{constructor(e){this._api=e}modify(e){const t=[...this._api.getCameraManager().getStore().getAllDependentCameras(e.camera,"substream")];if(t.length<=1)return;const n=xv(e),i=t.indexOf(n),a=i<0?0:(i+1)%t.length;Mv(e,t[a])}}class ab extends hv{async execute(e){e.getViewManager().setViewByParameters({modifiers:[new ib(e)]})}}class rb{constructor(e){this._substreamID=e}modify(e){Mv(e,this._substreamID)}}class sb extends hv{async execute(e){e.getViewManager().setViewByParameters({modifiers:[new rb(this._action.camera)]})}}class ob extends hv{async execute(e){await(e.getMediaLoadedInfoManager().get()?.player?.unmute())}}class cb extends hv{async execute(e){await e.getViewManager().setViewByParametersWithNewQuery({params:{view:this._action.frigate_card_action}})}}class lb{createAction(e,t,n){const i=hf(t);if("fire-dom-event"!==t.action||!i)return new bv(e,t,n?.config);if(i.card_id&&i.card_id!==n?.cardID)return null;switch(i.frigate_card_action){case"default":return new mv(e,i,n?.config);case"clip":case"clips":case"image":case"live":case"recording":case"recordings":case"snapshot":case"snapshots":case"timeline":case"diagnostics":return new cb(e,i,n?.config);case"sleep":return new Jv(e,i,n?.config);case"d
/* istanbul ignore next: this path cannot be reached -- @preserve */
/* istanbul ignore next: this path cannot be reached -- @preserve */
return console.warn(`Frigate card received unknown card action: ${i.frigate_card_action}`),null}}class db{constructor(e,t,n){this._actions=[],this._factory=new lb,this._stopped=!1,this._context=e;for(const i of qm(t)){const t=this._factory.createAction(e,i,n);t&&this._actions.push(t)}}async execute(e){for(const t of this._actions){if(this._stopped)break;await t.execute(e)}}async stop(){this._stopped=!0}}const ub=bi.object({action:bi.enum(["tap","double_tap","hold","start_tap","end_tap"])}),hb=bi.object({detail:ub});class pb{constructor(e){this._actionsInFlight=[],this._actionContext={},this.handleInteractionEvent=e=>{const t=hb.safeParse(e);if(!t.success)return;const n=t.data.detail.action,i=this.getMergedActions(),a=_f(n,i);i&&n&&a&&this.executeActions(a,i)},this.handleCustomActionEvent=e=>{"detail"in e&&this.executeActions(e.detail)},this.handleActionExecutionRequestEvent=async e=>{await this.executeActions(e.detail.action,e.detail.config)},this._api=e}getMergedActions(){const e=this._api.getViewManager().getView();if(this._api.getMessageManager().hasMessage())return{};const t=this._api.getConfigManager().getConfig();let n;if(e?.is("live"))n=t?.live.actions;else if(e?.isGalleryView())n=t?.media_gallery?.actions;else if(e?.isViewerView())n=t?.media_viewer.actions;else{if(!e?.is("image"))return{};n=t?.image?.actions}return{...t?.view.actions,...n}}uninitialize(){this._actionsInFlight.forEach((e=>e.stop()))}async executeActions(e,t){const n=new db(this._actionContext,e,{config:t,cardID:this._api.getConfigManager().getConfig()?.card_id});this._actionsInFlight.push(n),await n.execute(this._api),this._actionsInFlight=this._actionsInFlight.filter((e=>e!==n))}}class gb{constructor(e){this._automations=[],this._priorEvaluations=new Map,this._nestedAutomationExecutions=0,this._api=e}deleteAutomations(e){this._automations=this._automations.filter((t=>t.tag!==e))}addAutomations(e){this._automations.push(...e)}execute(){if(!this._api.getHASSManager().hasHASS()||!this._api.getInitializationManager().isInitializedMandatory()||this._api.getMessageManager().hasErrorMessage())return;const e=[];for(const t of this._automations){const n=this._api.getConditionsManager().evaluateConditions(t.conditions),i=n?t.actions:t.actions_not,a=this._priorEvaluations.get(t);this._priorEvaluations.set(t,n),n!==a&&i&&e.push(...i)}if(!e.length)return;(async e=>{++this._nestedAutomationExecutions,this._nestedAutomationExecutions>10?this._api.getMessageManager().setMessageIfHigherPriority({type:"error",message:N_("error.too_many_automations")}):(await this._api.getActionsManager().executeActions(e),--this._nestedAutomationExecutions)})(e)}}class mb{constructor(e){this._api=e}openURL(){const e=this.getCameraURL();e&&window.open(e)}hasCameraURL(){return!!this.getCameraURL()}getCameraURL(){const e=this._api.getViewManager().getView(),t=e?.queryResults?.getSelectedResult()??null,n=e?.camera?this._api.getCameraManager().getCameraEndpoints(e.camera,{view:e.view,...t&&{media:t}})??null:null;return n?.ui?.endpoint??null}}const fb=()=>!!navigator.userAgent.match(/CrKey\//);async function _b(e,t,n){const i={type:"auth/sign_path",path:t,expires:n},a=await ky(e,To,i);return a?e.hassUrl(a.path):null}function yb(e,t,n,i){if(!e||!n||!n.length)return[];const a=[];for(const r of n){const n=t?.states[r],s=e.states[r];if((i?.stateOnly&&n?.state!==s?.state||!i?.stateOnly&&n!==s)&&(a.push({entityID:r,oldState:n,newState:s}),i?.firstOnly))break}return a}function vb(e,t,n,i){return!!yb(e,t,n,{...i,firstOnly:!0}).length}function bb(e,t){return t?e?.states[t]?.attributes?.friendly_name??null:null}const wb=async()=>{if(["ha-button-menu","ha-button","ha-camera-stream","ha-card","ha-circular-progress","ha-combo-box","ha-hls-player","ha-icon-button","ha-icon","ha-menu-button","ha-selector","ha-state-icon","ha-web-rtc-player","mwc-button","mwc-list-item","state-badge"].every((e=>customElements.get(e))))return!0;const e=await window.loadCardHelpers();await e.createCardElement({type:"picture-glance",entities:[],camera_image:"dummy-to-load-editor-components"}),await customElements.whenDef
/* istanbul ignore next: No (current) way to reach this code -- @preserve */return null},rw=(e,t)=>{if(!t.enabled)return[];const n=[];for(const i of["ptz_down","ptz_left","ptz_right","ptz_up","ptz_zoom_in","ptz_zoom_out"]){const a=t[i],r=aw(i);a&&r&&(n.push({conditions:[{condition:"key",key:a.key,state:"down",shift:a.shift,ctrl:a.ctrl,alt:a.alt,meta:a.meta}],actions:[ff({ptzAction:r,ptzPhase:"start"})],tag:e}),n.push({conditions:[{condition:"key",key:a.key,state:"up"}],actions:[ff({ptzAction:r,ptzPhase:"stop"})],tag:e}))}const i=t.ptz_home;return i&&n.push({conditions:[{condition:"key",key:i.key,state:"down",shift:i.shift,ctrl:i.ctrl,alt:i.alt,meta:i.meta}],actions:[ff()],tag:e}),n};class sw{constructor(e){this._config=null,this._overriddenConfig=null,this._rawConfig=null,this._cardWideConfig=null,this._api=e}hasConfig(){return!!this.getConfig()}getConfig(){return this._overriddenConfig??this._config}getCardWideConfig(){return this._cardWideConfig}getNonOverriddenConfig(){return this._config}getRawConfig(){return this._rawConfig}setConfig(e){if(!e)throw new Error(N_("error.invalid_configuration"));const t=Pd.safeParse(e);if(!t.success){const n=Nb(e),i=Do(t.error);let a="";throw n&&(a=`${N_("error.upgrade_available")}. `),new Error(a+`${N_("error.invalid_configuration")}: `+(i&&i.size?JSON.stringify([...i],null," "):N_("error.invalid_configuration_no_hint")))}const n=iw(e,t.data,t.data.profiles);var i;(this._rawConfig=e,jy(this._config,n))||(this._config=n,this._cardWideConfig={performance:n.performance,debug:n.debug},this._api.getConditionsManager().setConditionsFromConfig(),this._api.getConditionsManager().setState({view:void 0,displayMode:void 0,camera:void 0}),this._api.getMediaLoadedInfoManager().clear(),this._api.getInitializationManager().uninitialize($b.VIEW),this._api.getViewManager().reset(),this._api.getMessageManager().reset(),this._api.getStyleManager().setPerformance(),this._api.getStatusBarItemManager().removeAllDynamicStatusBarItems(),((e,t)=>{e.getAutomationsManager().deleteAutomations(t);const n=e.getConfigManager().getConfig()?.view.keyboard_shortcuts;if(!n)return;const i=rw(t,n);i.length&&e.getAutomationsManager().addAutomations(i)})(this._api,this),(i=this._api).getAutomationsManager().deleteAutomations(),i.getAutomationsManager().addAutomations(i.getConfigManager().getNonOverriddenConfig()?.automations??[]),this.computeOverrideConfig(),this._api.getCardElementManager().update())}computeOverrideConfig(){const e=this._api.getConditionsManager();if(!this._config)return;let t=null;try{t=ew(e,this._config,{configOverrides:this._config.overrides,schema:Pd})}catch(e){return void this._api.getMessageManager().setErrorIfHigherPriority(e)}if(jy(t,this._overriddenConfig))return;const n=this._overriddenConfig;this._overriddenConfig=t,this._api.getStyleManager().setMinMaxHeight(),!n||jy(n?.cameras,this._overriddenConfig?.cameras)&&jy(n?.cameras_global,this._overriddenConfig?.cameras_global)||this._api.getInitializationManager().uninitialize($b.CAMERAS),n&&n?.live.microphone.always_connected!==this._overriddenConfig?.live.microphone.always_connected&&this._api.getInitializationManager().uninitialize($b.MICROPHONE_CONNECT),this._initializeBackground(n)}async _initializeBackground(e){await this._api.getDefaultManager().initializeIfNecessary(e),await this._api.getMediaPlayerManager().initializeIfNecessary(e),this._api.getCardElementManager().update()}}class ow{constructor(e){this._timer=new bf,this._stateChangeHandler=()=>{this._setToDefaultIfAllowed()},this._api=e}async initializeIfNecessary(e){jy(e?.view.default_reset,this._api.getConfigManager().getConfig()?.view.default_reset)||await this.initialize()}async initialize(){this.uninitialize();const e=this._api.getConfigManager().getConfig()?.view.default_reset;e?.entities.length&&this._api.getHASSManager().getStateWatcher().subscribe(this._stateChangeHandler,e.entities);const t=this._api.getConfigManager().getConfig()?.view.default_reset.every_seconds;return t&&this._timer.startRepeated(t,(()=>this._setToDefaultIfAllowed())),this._api.getConfigManager().getConfig()
/* istanbul ignore next: the case of config being null here cannot be
reached, as there's no way to have the untrigger call happen without
a config. -- @preserve */
this._api.getConfigManager().getConfig()?.view.triggers.untrigger_seconds??0,(async()=>{await this._untriggerAction(e)}))}_deleteTimer(e){this._triggeredCameraTimers.get(e)?.stop(),this._triggeredCameraTimers.delete(e)}}function Uw(e,t){return t="function"==typeof t?t:void 0,e&&e.length?Fm(e,void 0,t):[]}class Ww{constructor(e){this._queries=null,e&&(this._queries=e)}clone(){return l_(this)}getQueries(){return this._queries}setQueries(e){return this._queries=e,this}getQueryCameraIDs(){if(!this._queries)return null;const e=new Set;return this._queries.forEach((t=>[...t.cameraIDs].forEach((t=>e.add(t))))),e}setQueryCameraIDs(e){if(!this._queries)return this;const t=[];return this._queries.forEach((n=>t.push({...n,cameraIDs:Um(e)}))),this._queries=Uw(t,jy),this}hasQueriesForCameraIDs(e){for(const t of e)if(!this._queries?.some((e=>e.cameraIDs.has(t))))return!1;return!0}}class Zw extends Ww{convertToClipsQueries(){for(const e of this._queries??[])delete e.hasSnapshot,e.hasClip=!0;return this}}class Qw extends Ww{}class Gw{static areEventQueries(e){return e instanceof Zw}static areRecordingQueries(e){return e instanceof Qw}static areClipsQueries(e){return this.areEventQueries(e)&&!!e?.getQueries()?.every((e=>e.hasClip))}static areSnapshotQueries(e){return this.areEventQueries(e)&&!!e?.getQueries()?.every((e=>e.hasSnapshot))}static getQueriesType(e){return this.areEventQueries(e)?"event":this.areRecordingQueries(e)?"recording":null}static getMediaType(e){return this.areClipsQueries(e)?"clips":this.areSnapshotQueries(e)?"snapshots":this.areRecordingQueries(e)?"recordings":null}}const Yw=(e,t,n)=>{const i={anyCapabilities:["clips","snapshots","recordings"]};switch(t){case"image":case"diagnostics":return e.getStore().getCameraIDs();case"live":case"clip":case"clips":case"snapshot":case"snapshots":case"recording":case"recordings":const a="clip"===t?"clips":"snapshot"===t?"snapshots":"recording"===t?"recordings":t;return n?e.getStore().getAllDependentCameras(n,a):e.getStore().getCameraIDsWithCapability(a);case"timeline":return e.getStore().getCameraIDsWithCapability(i);case"media":return n?e.getStore().getAllDependentCameras(n,i):e.getStore().getCameraIDsWithCapability(i)}},Kw=(e,t)=>Rv({},e,t);class Xw{constructor(e){this.view=e.view,this.camera=e.camera,this.query=e.query??null,this.queryResults=e.queryResults??null,this.context=e.context??null,this.displayMode=e.displayMode??null}clone(){return new Xw({view:this.view,camera:this.camera,query:this.query?.clone()??null,queryResults:this.queryResults?.clone()??null,context:this.context,displayMode:this.displayMode})}evolve(e){return new Xw({view:void 0!==e.view?e.view:this.view,camera:void 0!==e.camera?e.camera:this.camera,query:void 0!==e.query?e.query:this.query?.clone()??null,queryResults:void 0!==e.queryResults?e.queryResults:this.queryResults?.clone()??null,context:void 0!==e.context?e.context:this.context,displayMode:void 0!==e.displayMode?e.displayMode:this.displayMode})}mergeInContext(e){return this.context=Kw(this.context,e),this}removeContext(e){return this.context&&delete this.context[e],this}removeContextProperty(e,t){const n=this.context?.[e];return n&&delete n[t],this}is(e){return this.view==e}isGalleryView(){return["clips","snapshots","recordings"].includes(this.view)}isAnyMediaView(){return this.isViewerView()||this.is("live")||this.is("image")}isViewerView(){return["media","clip","snapshot","recording"].includes(this.view)}supportsMultipleDisplayModes(){return this.isViewerView()||this.is("live")}getDefaultMediaType(){return["clip","clips"].includes(this.view)?"clips":["snapshot","snapshots"].includes(this.view)?"snapshots":["recording","recordings"].includes(this.view)?"recordings":null}isGrid(){return"grid"===this.displayMode}}const Jw=(e,t)=>{t?.forEach((t=>t.modify(e)))};class ex extends $o{}class tx extends $o{}class nx{constructor(e){this._api=e}getViewDefault(e){const t=this._api.getConfigManager().getConfig();if(!t)return null;let n=null;const i=e?.params?.view??t.view.default;if(e?.params?.camera)n=e.params.camera;else{const a=[...Yw(this._api.getCameraMan
/* istanbul ignore if: this path cannot be reached -- @preserve */
if(!n)return[];const i="recordings"===n?await this._executor.executeDefaultRecordingQuery({...!e.isGrid()&&{cameraID:e.camera},executorOptions:t}):"clips"===n||"snapshots"===n||"all"===n?await this._executor.executeDefaultEventQuery({...!e.isGrid()&&{cameraID:e.camera},eventsMediaType:n,executorOptions:t}):/* istanbul ignore next -- @preserve */
null;return i?[new ax(i)]:[]};switch(e.view){case"live":"none"!==n.live.controls.thumbnails.mode&&a.push(...await r("recordings"===n.live.controls.thumbnails.media_type?"recordings":n.live.controls.thumbnails.events_media_type));break;case"media":a.push(...await r("clips"));break;case"clip":case"clips":case"snapshot":case"snapshots":case"recording":case"recordings":a.push(...await r(i))}return a.push(...this._getTimelineWindowViewModifier(e)),a.push(...this._getSeekTimeModifier(t?.selectResult?.time?.time)),a}_getTimelineWindowViewModifier(e){if(e.is("live")){const e=new Date,t=this._api.getConfigManager().getConfig()?.live;
/* istanbul ignore if: this if branch cannot be reached as if the config is
empty this function is never called -- @preserve */
return t?[new Zv({timeline:{window:{start:Wu(e,{seconds:t.controls.timeline.window_seconds}),end:e}}})]:[]}return[new ix("timeline","window")]}_getSeekTimeModifier(e){return e?[new Zv({mediaViewer:{seek:e}})]:[new ix("mediaViewer","seek")]}}class dx{constructor(e,t){this._view=null,this._epoch=this._createEpoch(),this._loadingIndex=1,this.setViewDefault=e=>this._setViewGeneric(this._viewFactory.getViewDefault.bind(this._viewFactory),e),this.setViewByParameters=e=>this._setViewGeneric(this._viewFactory.getViewByParameters.bind(this._viewFactory),e),this.setViewDefaultWithNewQuery=async e=>await this._setViewThenModifyAsync(this._viewFactory.getViewDefault.bind(this._viewFactory),this._viewQueryExecutor.getNewQueryModifiers.bind(this._viewQueryExecutor),e),this.setViewByParametersWithNewQuery=async e=>await this._setViewThenModifyAsync(this._viewFactory.getViewByParameters.bind(this._viewFactory),this._viewQueryExecutor.getNewQueryModifiers.bind(this._viewQueryExecutor),e),this.setViewByParametersWithExistingQuery=async e=>await this._setViewThenModifyAsync(this._viewFactory.getViewByParameters.bind(this._viewFactory),this._viewQueryExecutor.getExistingQueryModifiers.bind(this._viewQueryExecutor),e),this.initialize=async()=>(this._api.getQueryStringManager().hasViewRelatedActionsToRun()||this.setViewDefaultWithNewQuery({failSafe:!0}),!0),this._api=e,this._viewFactory=t?.viewFactory??new nx(e),this._viewQueryExecutor=t?.viewQueryExecutor??new lx(e)}getEpoch(){return this._epoch}_createEpoch(e){return{manager:this,...e&&{oldView:e}}}getView(){return this._view}hasView(){return!!this.getView()}reset(){this._view&&this._setView(null)}_setViewGeneric(e,t){let n=null;try{n=e({baseView:this._view,...t})}catch(e){this._api.getMessageManager().setErrorIfHigherPriority(e)}n&&this._setView(n)}_markViewLoadingQuery(e,t){return e.mergeInContext({loading:{query:t}})}_markViewAsNotLoadingQuery(e){return e.removeContextProperty("loading","query")}async _setViewThenModifyAsync(e,t,n){let i=null;try{i=e({baseView:this._view,...n,params:{query:null,queryResults:null,...n?.params}})}catch(e){this._api.getMessageManager().setErrorIfHigherPriority(e)}if(!i)return;if(this._view&&this._shouldAdoptQueryAndResults(i))return i.query=this._view.query,i.queryResults=this._view.queryResults,this._markViewAsNotLoadingQuery(i),void this._setView(i);const a=this._loadingIndex++;this._markViewLoadingQuery(i,a),this._setView(i);let r=null,s=null;try{r=await t(i,n?.queryExecutorOptions)}catch(e){s=e}if(this._view&&this.hasMajorMediaChange(this._view,i))return void(this._view.context?.loading?.query===a&&this._setView(this._markViewAsNotLoadingQuery(this._view.clone())));if(s)return void this._api.getMessageManager().setErrorIfHigherPriority(s);
/* istanbul ignore if: the if path cannot be reached as the view is set
above -- @preserve */if(!this._view)return;const o=this._view.clone();this._view.context?.loading?.query===a&&this._markViewAsNotLoadingQuery(o),Jw(o,r),this._setView(o)}_shouldAdoptQueryAndResults(e){const t=this._view?.isViewerView()&&e?.isGalleryView(),n=e?.getDefaultMediaType(),i=Gw.getMediaType(this._view?.query)===n;return!!t&&i}setViewWithMergedContext(e){if(this._view)return this._setView(this._view?.clone().mergeInContext(e))}isViewSupportedByCamera(e,t){return!!Yw(this._api.getCameraManager(),t,e).size}hasMajorMediaChange(e,t){const n=t??this._view;return!!e!=!!n||e?.view!==n?.view||e?.camera!==n?.camera||"live"===n?.view&&e&&xv(e)!==xv(n)||"live"!==n?.view&&e?.queryResults!==n?.queryResults}_setView(e){const t=this._view;V_(this._api.getConfigManager().getCardWideConfig(),"Frigate Card view change: ",e),this._view=e,this._epoch=this._createEpoch(t),this.hasMajorMediaChange(t)&&this._api.getMediaLoadedInfoManager().clear(),t?.view!==e?.view&&this._api.getCardElementManager().scrollReset(),this._api.getMessageManager().reset(),this._api.getStyleManager().setExpandedMode(),this._api.getConditionsManager()?.setState({view:e?.view,camera:e?.camera,displayMode:e?.displayMode??void 0}),this._api.getCardElementManager().update()}}class ux{constructor(e,t,n,i){this._deviceRegistryManager=new av(new nv((e=>e.id))),this._entityRegistryManager=new ov(new nv((e=>e.entity_id))),this._resolvedMediaCache=new lv,this._actionsManager=new pb(this),this._automationsManager=new gb(this),this._cameraManager=new tv(this),this._cameraURLManager=new mb(this),this._configManager=new sw(this),this._defaultManager=new ow(this),this._downloadManager=new uw(this),this._expandManager=new hw(this),this._fullscreenManager=new yw(this),this._hassManager=new bw(this),this._initializationManager=new Ab(this),this._interactionManager=new Ew(this),this._keyboardStateManager=new $w(this),this._mediaLoadedInfoManager=new Rw(this),this._mediaPlayerManager=new Lw(this),this._messageManager=new Nw(this),this._microphoneManager=new Fw(this),this._queryStringManager=new Vw(this),this._statusBarItemManager=new Hw(this),this._styleManager=new Bw(this),this._triggersManager=new qw(this),this._viewManager=new dx(this),e.addController(this),this._conditionsManager=new tw(this,i),this._cardElementManager=new Ib(this,e,t,n)}getActionsManager(){return this._actionsManager}getAutomationsManager(){return this._automationsManager}getCameraManager(){return this._cameraManager}getCameraURLManager(){return this._cameraURLManager}getCardElementManager(){return this._cardElementManager}getConditionsManager(){return this._conditionsManager}static async getConfigElement(){return await import("./editor-238b96c0.js"),document.createElement("frigate-card-editor")}getConfigManager(){return this._configManager}getDefaultManager(){return this._defaultManager}getDeviceRegistryManager(){return this._deviceRegistryManager}getDownloadManager(){return this._downloadManager}getEntityRegistryManager(){return this._entityRegistryManager}getExpandManager(){return this._expandManager}getFullscreenManager(){return this._fullscreenManager}getHASSManager(){return this._hassManager}getInitializationManager(){return this._initializationManager}getInteractionManager(){return this._interactionManager}getKeyboardStateManager(){return this._keyboardStateManager}getMediaLoadedInfoManager(){return this._mediaLoadedInfoManager}getMediaPlayerManager(){return this._mediaPlayerManager}getMessageManager(){return this._messageManager}getMicrophoneManager(){return this._microphoneManager}getQueryStringManager(){return this._queryStringManager}getResolvedMediaCache(){return this._resolvedMediaCache}getStatusBarItemManager(){return this._statusBarItemManager}static getStubConfig(e){return{cameras:[{camera_entity:e.find((e=>e.startsWith("camera.")))??"camera.demo"}]}}getStyleManager(){return this._styleManager}getTriggersManager(){return this._triggersManager}getViewManager(){return this._viewManager}hostConnected(){this.getCardElementManager().elementConnected()}hostDisconnected(){this.getCardEleme
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
function px(e){return null==e}var gx=function(e,t){var n,i="";for(n=0;n<t;n+=1)i+=e;return i},mx={isNothing:px,isObject:function(e){return"object"==typeof e&&null!==e},toArray:function(e){return Array.isArray(e)?e:px(e)?[]:[e]},repeat:gx,isNegativeZero:function(e){return 0===e&&Number.NEGATIVE_INFINITY===1/e},extend:function(e,t){var n,i,a,r;if(t)for(n=0,i=(r=Object.keys(t)).length;n<i;n+=1)e[a=r[n]]=t[a];return e}};function fx(e,t){var n="",i=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+="\n\n"+e.mark.snippet),i+" "+n):i}function _x(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=fx(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack||""}_x.prototype=Object.create(Error.prototype),_x.prototype.constructor=_x,_x.prototype.toString=function(e){return this.name+": "+fx(this,e)};var yx=_x;function vx(e,t,n,i,a){var r="",s="",o=Math.floor(a/2)-1;return i-t>o&&(t=i-o+(r=" ... ").length),n-i>o&&(n=i+o-(s=" ...").length),{str:r+e.slice(t,n).replace(/\t/g,"→")+s,pos:i-t+r.length}}function bx(e,t){return mx.repeat(" ",t-e.length)+e}var wx=function(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),"number"!=typeof t.indent&&(t.indent=1),"number"!=typeof t.linesBefore&&(t.linesBefore=3),"number"!=typeof t.linesAfter&&(t.linesAfter=2);for(var n,i=/\r?\n|\r|\0/g,a=[0],r=[],s=-1;n=i.exec(e.buffer);)r.push(n.index),a.push(n.index+n[0].length),e.position<=n.index&&s<0&&(s=a.length-2);s<0&&(s=a.length-1);var o,c,l="",d=Math.min(e.line+t.linesAfter,r.length).toString().length,u=t.maxLength-(t.indent+d+3);for(o=1;o<=t.linesBefore&&!(s-o<0);o++)c=vx(e.buffer,a[s-o],r[s-o],e.position-(a[s]-a[s-o]),u),l=mx.repeat(" ",t.indent)+bx((e.line-o+1).toString(),d)+" | "+c.str+"\n"+l;for(c=vx(e.buffer,a[s],r[s],e.position,u),l+=mx.repeat(" ",t.indent)+bx((e.line+1).toString(),d)+" | "+c.str+"\n",l+=mx.repeat("-",t.indent+d+3+c.pos)+"^\n",o=1;o<=t.linesAfter&&!(s+o>=r.length);o++)c=vx(e.buffer,a[s+o],r[s+o],e.position-(a[s]-a[s+o]),u),l+=mx.repeat(" ",t.indent)+bx((e.line+o+1).toString(),d)+" | "+c.str+"\n";return l.replace(/\n$/,"")},xx=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Cx=["scalar","sequence","mapping"];var Mx=function(e,t){if(t=t||{},Object.keys(t).forEach((function(t){if(-1===xx.indexOf(t))throw new yx('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')})),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=function(e){var t={};return null!==e&&Object.keys(e).forEach((function(n){e[n].forEach((function(e){t[String(e)]=n}))})),t}(t.styleAliases||null),-1===Cx.indexOf(this.kind))throw new yx('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')};function Sx(e,t){var n=[];return e[t].forEach((function(e){var t=n.length;n.forEach((function(n,i){n.tag===e.tag&&n.kind===e.kind&&n.multi===e.multi&&(t=i)})),n[t]=e})),n}function kx(e){return this.extend(e)}kx.prototype.extend=function(e){var t=[],n=[];if(e instanceof Mx)n.push(e);else if(Array.isArray(e))n=n.concat(e);else{if(!e||!Array.isArray(e.implicit)&&!Array.isArray(e.explicit))throw new yx("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");e.implicit&&(t=t.concat(e.implicit)),e.explicit&&(n=n.concat(e.explicit))}t.forEach((function(e){if(!(e instanceof Mx))throw new yx("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(e.loadKind&&"scalar"!==e.loadKind)throw new yx("There is a non-scalar type in the implicit list of a schema. Implic
.stateColor=${this.icon.stateColor??!0}
.hass=${this.hass}
.stateObj=${e}
></state-badge>`}return this.icon?.fallback?q`<ha-icon icon="${this.icon.fallback}"></ha-icon>`:q``}static get styles(){return s(":host {\n display: inline-block;\n width: var(--mdc-icon-size, 24px);\n height: var(--mdc-icon-size, 24px);\n --ha-icon-display: block;\n}\n\n* {\n display: block;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n}")}};e([he({attribute:!1})],tS.prototype,"hass",void 0),e([he({attribute:!1})],tS.prototype,"icon",void 0),tS=e([le("frigate-card-icon")],tS);let nS=class extends oe{constructor(){super(...arguments),this.message=""}render(){const e=this.icon?this.icon:"mdi:information-outline",t={dotdotdot:!!this.dotdotdot},n=e=>q`<pre>${XM.dump(e)}</pre>`;return q` <div class="wrapper">
<div class="message padded">
<div class="icon">
<frigate-card-icon .icon="${{icon:e}}"></frigate-card-icon>
</div>
<div class="contents">
<span class="${_e(t)}">
${this.message?q`${this.message}${this.context&&"string"==typeof this.context?": "+this.context:""}`:""}
</span>
${this.context&&Array.isArray(this.context)?this.context.map((e=>n(e))):"object"==typeof this.context?n(this.context):""}
</div>
</div>
</div>`}static get styles(){return s(JM)}};e([he({attribute:!1})],nS.prototype,"message",void 0),e([he({attribute:!1})],nS.prototype,"context",void 0),e([he({attribute:!1})],nS.prototype,"icon",void 0),e([he({attribute:!0,type:Boolean})],nS.prototype,"dotdotdot",void 0),nS=e([le("frigate-card-message")],nS);let iS=class extends oe{render(){if(this.message)return q` <frigate-card-message
.message=${q` ${this.message.message}.
<a href="${"https://card.camera/#/troubleshooting"}"> ${N_("error.troubleshooting")}</a>.`}
.icon=${this.message.icon??"mdi:alert-circle"}
.context=${this.message.context}
.dotdotdot=${this.message.dotdotdot}
>
</frigate-card-message>`}static get styles(){return s(JM)}};e([he({attribute:!1})],iS.prototype,"message",void 0),iS=e([le("frigate-card-error-message")],iS);let aS=class extends oe{constructor(){super(...arguments),this.message="",this.animated=!1,this.size="large"}render(){return q` <div class="message vertical">
${this.animated?q`<ha-circular-progress indeterminate size="${this.size}">
</ha-circular-progress>`:q`<frigate-card-icon
.icon=${{icon:"mdi:timer-sand"}}
></frigate-card-icon>`}
${this.message?q`<span>${this.message}</span>`:q``}
</div>`}static get styles(){return s(JM)}};function rS(e){return"error"===e?.type?q` <frigate-card-error-message
.message=${e}
></frigate-card-error-message>`:e?q` <frigate-card-message
.message=${e.message}
.icon=${e.icon}
.context=${e.context}
.dotdotdot=${e.dotdotdot}
></frigate-card-message>`:q``}function sS(e){return q`
<frigate-card-progress-indicator
class="${_e(e?.classes??{})}"
.size=${e?.size}
${e?.componentRef?je(e.componentRef):""}
.message=${e?.message||""}
.animated=${e?.cardWideConfig?.performance?.features.animated_progress_indicator??!0}
>
</frigate-card-progress-indicator>
`}function oS(e,t,n){!function(e,t,n,i){Vm(e,"message",{message:t,type:n,icon:i?.icon,context:i?.context})}(e,t,"error",{context:n?.context})}function cS(e,t){t instanceof Error&&oS(e,t.message,{...t instanceof $o&&{context:t.context}})}e([he({attribute:!1})],aS.prototype,"message",void 0),e([he({attribute:!1})],aS.prototype,"animated",void 0),e([he({attribute:!1})],aS.prototype,"size",void 0),aS=e([le("frigate-card-progress-indicator")],aS);let lS=class extends oe{constructor(){super(...arguments),this._root=null}createRenderRoot(){return this}_createRoot(){const e=customElements.get("hui-conditional-element");if(!e||!this.hass)throw new Error(N_("error.could_not_render_elements"));const t=new e;t.hass=this.hass;const n={type:"conditional",conditions:[],elements:this.elements};try{t.setConfig(n)}catch(e){throw Zm(e,console.error),new $o(N_("error.invalid_elements_config"))}return t}willUpdate(e){try{!this.elements||this._root&&!e.has("elements")||(this._root=this._createRoot())}catch(e){return cS(this,e)}}render(){return q`${this._root||""}`}updated(){this.hass&&this._root&&(this._root.hass=this.hass)}};e([he({attribute:!1})],lS.prototype,"elements",void 0),e([he({attribute:!1})],lS.prototype,"conditionsManagerEpoch",void 0),e([he({attribute:!1})],lS.prototype,"hass",void 0),lS=e([le("frigate-card-elements-core")],lS);let dS=class extends oe{constructor(){super(...arguments),this._menuRemoveHandler=e=>{Vm(this,"menu:remove",e.detail)},this._statusBarRemoveHandler=e=>{Vm(this,"status-bar:remove",e.detail)},this._menuAddHandler=e=>{const t=e.composedPath();t.length&&this._addHandler(t[0],"frigate-card:menu:remove",this._menuRemoveHandler)},this._statusBarAddHandler=e=>{const t=e.composedPath();t.length&&this._addHandler(t[0],"frigate-card:status-bar:add",this._statusBarRemoveHandler)}}_addHandler(e,t,n){e.removeEventListener(t,n),e.addEventListener(t,n)}connectedCallback(){super.connectedCallback(),this.addEventListener("frigate-card:menu:add",this._menuAddHandler),this.addEventListener("frigate-card:status-bar:add",this._statusBarAddHandler)}disconnectedCallback(){this.removeEventListener("frigate-card:menu:add",this._menuAddHandler),this.addEventListener("frigate-card:status-bar:add",this._statusBarAddHandler),super.disconnectedCallback()}render(){return q`<frigate-card-elements-core
.hass=${this.hass}
.conditionsManagerEpoch=${this.conditionsManagerEpoch}
.elements=${this.elements}
>
</frigate-card-elements-core>`}static get styles(){return s(":host {\n position: absolute;\n inset: 0;\n overflow: hidden;\n pointer-events: none;\n}\n\n.element {\n position: absolute;\n transform: translate(-50%, -50%);\n pointer-events: auto;\n}\n\nhui-error-card.element {\n inset: 0px;\n transform: unset;\n}")}};e([he({attribute:!1})],dS.prototype,"hass",void 0),e([he({attribute:!1})],dS.prototype,"conditionsManagerEpoch",void 0),e([he({attribute:!1})],dS.prototype,"elements",void 0),dS=e([le("frigate-card-elements")],dS);let uS=class extends oe{setConfig(e){this._config=e}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.className=""}render(){if(function(e,t){if(!t)return!0;const n=new Jb(t,{bubbles:!0,composed:!0});return e.dispatchEvent(n),n.evaluation??!1}(this,this._config?.conditions))return q` <frigate-card-elements-core
.hass=${this.hass}
.elements=${this._config?.elements}
>
</frigate-card-elements-core>`}};e([he({attribute:!1,hasChanged:()=>!0})],uS.prototype,"hass",void 0),uS=e([le("frigate-card-conditional")],uS);class hS extends oe{constructor(e){super(),this._config=null,this._eventCategory=e}setConfig(e){this._config=e}connectedCallback(){super.connectedCallback(),this._config&&Vm(this,`${this._eventCategory}:add`,this._config)}disconnectedCallback(){this._config&&Vm(this,`${this._eventCategory}:remove`,this._config),super.disconnectedCallback()}}e([pe()],hS.prototype,"_config",void 0);class pS extends hS{constructor(){super("menu")}}let gS=class extends pS{};gS=e([le("frigate-card-menu-icon")],gS);let mS=class extends pS{};mS=e([le("frigate-card-menu-state-icon")],mS);let fS=class extends pS{};fS=e([le("frigate-card-menu-submenu")],fS);let _S=class extends pS{};_S=e([le("frigate-card-menu-submenu-select")],_S);class yS extends hS{constructor(){super("status-bar")}}let vS=class extends yS{};vS=e([le("frigate-card-status-bar-icon")],vS);let bS=class extends yS{};bS=e([le("frigate-card-status-bar-image")],bS);let wS=class extends yS{};wS=e([le("frigate-card-status-bar-string")],wS);let xS=class extends oe{render(){return q` <img src="${"data:image/svg+xml,%3c%3fxml version='1.0' encoding='UTF-8' standalone='no'%3f%3e%3csvg inkscape:version='1.2.2 (b0a8486541%2c 2022-12-01)' sodipodi:docname='camera-iris.svg' id='svg4' version='1.1' viewBox='0 0 24 24' xmlns:inkscape='http://www.inkscape.org/namespaces/inkscape' xmlns:sodipodi='http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd' xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg'%3e %3cdefs id='defs8' /%3e %3csodipodi:namedview id='namedview6' pagecolor='%23b93e3e' bordercolor='black' borderopacity='0.25' inkscape:showpageshadow='2' inkscape:pageopacity='0.60784314' inkscape:pagecheckerboard='false' inkscape:deskcolor='%23d1d1d1' showgrid='false' inkscape:zoom='26.62506' inkscape:cx='-1.934268' inkscape:cy='15.680716' inkscape:window-width='3840' inkscape:window-height='1527' inkscape:window-x='1080' inkscape:window-y='227' inkscape:window-maximized='1' inkscape:current-layer='svg4' /%3e %3cg id='g1119' style='fill-opacity:0.05%3bfill:white'%3e %3ccircle style='fill:white%3bfill-opacity:0.05%3bstroke-width:1.39729' id='path170' cx='12' cy='12' inkscape:label='White Background' r='11.25' /%3e %3cpath d='M 13.730001%2c15 9.8300003%2c21.76 C 10.53%2c21.91 11.25%2c22 12%2c22 c 2.400001%2c0 4.6%2c-0.85 6.32%2c-2.25 L 14.660001%2c13.4 M 2.4600003%2c15 c 0.92%2c2.92 3.15%2c5.26 5.99%2c6.34 L 12.12%2c15 m -3.5799997%2c-3 -3.9%2c-6.7499996 c -1.64%2c1.749999 -2.64%2c4.1399993 -2.64%2c6.7499996 0%2c0.68 0.07%2c1.35 0.2%2c2 h 7.49 M 21.8%2c9.9999997 H 14.310001 L 14.600001%2c10.5 19.36%2c18.75 C 21%2c16.97 22%2c14.6 22%2c12 22%2c11.31 21.93%2c10.64 21.8%2c9.9999997 m -0.26%2c-1 C 20.62%2c6.0700005 18.39%2c3.7400002 15.550001%2c2.6600002 L 11.88%2c8.9999997 M 9.4000003%2c10.5 14.170001%2c2.2400002 c -0.7%2c-0.15 -1.420001%2c-0.24 -2.170001%2c-0.24 -2.3999997%2c0 -4.5999997%2c0.84 -6.3199997%2c2.2500003 l 3.66%2c6.3499995 z' id='path2' inkscape:label='Iris' style='fill-opacity:0.05%3bfill:white' /%3e %3c/g%3e%3c/svg%3e"}" /> `}static get styles(){return s(":host {\n width: intrinsic;\n height: intrinsic;\n display: flex;\n justify-content: center;\n align-items: center;\n pointer-events: none;\n}\n\nimg {\n width: 10%;\n animation: rotate 8s linear infinite;\n}\n\n@keyframes rotate {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}")}};xS=e([le("frigate-card-loading")],xS);const CS=(e,t)=>{Vm(e,"action:execution-request",t)};class MS{constructor(e){this._config=null,this._buttons=[],this._expanded=!1,this._host=e}setMenuConfig(e){this._config=e,this._host.style.setProperty("--frigate-card-menu-button-size",`${e.button_size}px`),this._host.setAttribute("data-style",e.style),this._host.setAttribute("data-position",e.position),this._host.setAttribute("data-alignment",e.alignment),this._sortButtons(),this._host.requestUpdate()}getMenuConfig(){return this._config}isExpanded(){
<mwc-list-item
style="${Re(e.style||{})}"
graphic=${ye(e.icon||e.entity?"icon":void 0)}
?twoline=${!!e.subtitle}
?selected=${e.selected}
?activated=${e.selected}
?disabled=${!1===e.enabled}
aria-label="${t??""}"
@action=${t=>{t.detail.config=e}}
.actionHandler=${Cf({hasHold:yf(e.hold_action),hasDoubleClick:yf(e.double_tap_action)})}
>
<span>${t??""}</span>
${e.subtitle?q`<span slot="secondary">${e.subtitle}</span>`:""}
<frigate-card-icon
slot="graphic"
.hass=${this.hass}
.icon=${{icon:e.icon,entity:e.entity}}
style="${Re(e.style||{})}"
></frigate-card-icon>
</mwc-list-item>
`}render(){if(!this.submenu)return q``;const e=this.submenu.items;return q`
<ha-button-menu
corner=${"BOTTOM_LEFT"}
@closed=${e=>e.stopPropagation()}
@click=${e=>vf(e)}
>
<ha-icon-button
style="${Re(this.submenu.style||{})}"
class="button"
slot="trigger"
.label=${this.submenu.title||""}
.actionHandler=${Cf({allowPropagation:!0,hasHold:yf(this.submenu.hold_action),hasDoubleClick:yf(this.submenu.double_tap_action)})}
>
<frigate-card-icon
.hass=${this.hass}
.icon=${"string"==typeof this.submenu.icon?{icon:this.submenu.icon}:this.submenu.icon}
></frigate-card-icon>
</ha-icon-button>
${e.map(this._renderItem.bind(this))}
</ha-button-menu>
`}static get styles(){return s("ha-icon-button.button {\n color: var(--secondary-color, white);\n background-color: rgba(0, 0, 0, 0.6);\n border-radius: 50%;\n padding: 0px;\n margin: 3px;\n --ha-icon-display: block;\n /* Buttons can always be clicked */\n pointer-events: auto;\n opacity: 0.9;\n}\n\n:host {\n pointer-events: auto;\n}\n\nmwc-list-item {\n z-index: 20;\n}")}};e([he({attribute:!1})],kS.prototype,"hass",void 0),e([he({attribute:!1})],kS.prototype,"submenu",void 0),kS=e([le("frigate-card-submenu")],kS);let ES=class extends oe{shouldUpdate(e){const t=e.get("hass");return!e.has("hass")||!t||!this.submenuSelect||vb(this.hass,t,[this.submenuSelect.entity])}async _refreshOptionTitles(){if(!this.hass||!this.submenuSelect)return;const e=this.submenuSelect.entity,t=this.hass.states[e],n=t?.attributes?.options,i=await(this.entityRegistryManager?.getEntity(this.hass,e))??null,a={};for(const t of n){const n=SS(this.hass,e,{...i&&{entity:i},state:t});n&&(a[t]=n)}this._optionTitles=a}willUpdate(){if(!this.submenuSelect||!this.hass)return;this._optionTitles||this._refreshOptionTitles();const e=this.submenuSelect.entity,t=this.hass.states[e],n=t?.attributes?.options;if(!t||!n)return;const i=bb(this.hass,e),a={...i&&{title:i},...this.submenuSelect,icon:{icon:this.submenuSelect.icon,entity:e,fallback:"mdi:format-list-bulleted"},type:"custom:frigate-card-menu-submenu",items:[]};delete a.options;const r=a.items;for(const i of n){const n=this._optionTitles?.[i]??i;r.push({state_color:!0,selected:t.state===i,enabled:!0,title:n||i,...(e.startsWith("select.")||e.startsWith("input_select."))&&{tap_action:{action:"perform-action",perform_action:e.startsWith("select.")?"select.select_option":"input_select.select_option",target:{entity_id:e},data:{option:i}}},...this.submenuSelect.options&&this.submenuSelect.options[i]})}this._generatedSubmenu=a}render(){return q` <frigate-card-submenu
.hass=${this.hass}
.submenu=${this._generatedSubmenu}
></frigate-card-submenu>`}};e([he({attribute:!1})],ES.prototype,"hass",void 0),e([he({attribute:!1})],ES.prototype,"submenuSelect",void 0),e([he({attribute:!1})],ES.prototype,"entityRegistryManager",void 0),e([pe()],ES.prototype,"_optionTitles",void 0),ES=e([le("frigate-card-submenu-select")],ES);let $S=class extends oe{constructor(){super(...arguments),this._controller=new MS(this)}set menuConfig(e){this._controller.setMenuConfig(e)}set buttons(e){this._controller.setButtons(e)}set expanded(e){this._controller.setExpanded(e)}toggleMenu(){this._controller.toggleExpanded()}_renderButton(e){if(!this.hass)return;if("custom:frigate-card-menu-submenu"===e.type)return q` <frigate-card-submenu
.hass=${this.hass}
.submenu=${e}
@action=${e=>this._controller.actionHandler(e)}
>
</frigate-card-submenu>`;if("custom:frigate-card-menu-submenu-select"===e.type)return q` <frigate-card-submenu-select
.hass=${this.hass}
.submenuSelect=${e}
.entityRegistryManager=${this.entityRegistryManager}
@action=${e=>this._controller.actionHandler(e)}
>
</frigate-card-submenu-select>`;const t=this.hass&&"custom:frigate-card-menu-state-icon"===e.type&&!e.title?bb(this.hass,e.entity):e.title;return q` <ha-icon-button
class="button"
style="${Re(e.style||{})}"
.actionHandler=${Cf({hasHold:yf(e.hold_action),hasDoubleClick:yf(e.double_tap_action)})}
.label=${t??""}
@action=${t=>this._controller.actionHandler(t,e)}
>
<frigate-card-icon
.hass=${this.hass}
.icon=${{icon:e.icon,entity:e.entity,stateColor:e.state_color,fallback:"mdi:gesture-tap-button"}}
></frigate-card-icon>
</ha-icon-button>`}render(){const e=this._controller.getMenuConfig(),t=e?.style;if(!e||"none"===t)return;const n=this._controller.getButtons("matching"),i=this._controller.getButtons("opposing");return q` <div
class="matching"
style="${Re({flex:String(n.length)})}"
>
${n.map((e=>this._renderButton(e)))}
</div>
<div
class="opposing"
style="${Re({flex:String(i.length)})}"
>
${i.map((e=>this._renderButton(e)))}
</div>`}static get styles(){return s('ha-icon-button.button {\n color: var(--secondary-color, white);\n background-color: rgba(0, 0, 0, 0.6);\n border-radius: 50%;\n padding: 0px;\n margin: 3px;\n --ha-icon-display: block;\n /* Buttons can always be clicked */\n pointer-events: auto;\n opacity: 0.9;\n}\n\n:host {\n --frigate-card-menu-button-size: 40px;\n --mdc-icon-button-size: var(--frigate-card-menu-button-size);\n --mdc-icon-size: calc(var(--mdc-icon-button-size) / 2);\n pointer-events: auto;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n overflow: visible;\n}\n\n/*******************************************************\n * Non-hover styles should not interact with the pointer\n *******************************************************/\n:host(:not([data-style*=hover])) {\n pointer-events: none;\n}\n\n/***********************************\n * Aligned divs: matching & opposing\n ***********************************/\ndiv.matching,\ndiv.opposing {\n display: flex;\n flex-wrap: wrap;\n flex-direction: row;\n align-items: flex-start;\n min-width: 0px;\n min-height: 0px;\n}\n\ndiv.matching {\n justify-content: flex-start;\n}\n\ndiv.opposing {\n justify-content: flex-end;\n}\n\n/********************\n * Outside menu style\n ********************/\n:host([data-style=outside]) {\n width: 100%;\n background: var(--secondary-background-color);\n}\n\n/********************************************************\n * Hack: Ensure host & div expand for column flex layouts\n ********************************************************/\n:host(:not([data-style=outside])[data-position=left]) {\n writing-mode: vertical-lr;\n}\n\n:host(:not([data-style=outside])[data-position=right]) {\n writing-mode: vertical-rl;\n}\n\n:host(:not([data-style=outside])[data-style=overlay][data-position=left]) div > *,\n:host(:not([data-style=outside])[data-style=overlay][data-position=right]) div > *,\n:host(:not([data-style=outside])[data-style*=hover][data-position=left]) div > *,\n:host(:not([data-style=outside])[data-style*=hover][data-position=right]) div > *,\n:host(:not([data-style=outside])[data-style=hidden][data-position=left]) div > *,\n:host(:not([data-style=outside])[data-style=hidden][data-position=right]) div > * {\n writing-mode: horizontal-tb;\n}\n\n/**********************\n * "Reverse" alignments\n **********************/\n:host(:not([data-style=outside])[data-position=left][data-alignment=bottom]),\n:host(:not([data-style=outside])[data-position=right][data-alignment=bottom]),\n:host([data-position=top][data-alignment=right]),\n:host([data-position=bottom][data-alignment=right]),\n:host(:not([data-style=outside])[data-position=left][data-alignment=bottom]) div,\n:host(:not([data-style=outside])[data-position=right][data-alignment=bottom]) div,\n:host([data-position=top][data-alignment=right]) div,\n:host([data-position=bottom][data-alignment=right]) div {\n flex-direction: row-reverse;\n}\n\n/****************************\n * Wrap upwards on the bottom\n ****************************/\n:host(:not([data-style=outside])[data-position=bottom]) div {\n flex-wrap: wrap-reverse;\n}\n\n/********************************************\n * Positioning for absolute based menu styles\n ********************************************/\n:host([data-style=overlay][data-position=top]),\n:host([data-style=overlay][data-position=bottom]),\n:host([data-style*=hover][data-position=top]),\n:host([data-style*=hover][data-position=bottom]),\n:host([data-style=hidden][data-position=top]),\n:host([data-style=hidden][data-position=bottom]) {\n width: 100%;\n height: auto;\n}\n\n:host([data-style=overlay][data-position=top][data-alignment=left]),\n:host([data-style=overlay][data-position=bottom][data-alignment=left]),\n:host([data-style*=hover][data-position=top][data-alignment=left]),\n:host([data-style*=hover][data-position=bottom][data-alignment=left]),\n:host([data-style=hidden][data-position=top][data-alignment=left][expanded]),\n:host([data-style=hidden][data-position=bottom][data-alignment=left][expanded
<slot name="top"></slot>
<slot name="left"></slot>
<slot name="right"></slot>
<slot name="bottom"></slot>
`}static get styles(){return s("ha-icon-button.button {\n color: var(--secondary-color, white);\n background-color: rgba(0, 0, 0, 0.6);\n border-radius: 50%;\n padding: 0px;\n margin: 3px;\n --ha-icon-display: block;\n /* Buttons can always be clicked */\n pointer-events: auto;\n opacity: 0.9;\n}\n\n:host {\n position: absolute;\n width: 100%;\n height: 100%;\n pointer-events: none;\n}\n\nslot {\n position: absolute;\n display: flex;\n}\n\n/***************\n * Slot position\n ***************/\nslot[name=top] {\n top: 0px;\n}\n\nslot[name=bottom] {\n bottom: 0px;\n}\n\nslot[name=left] {\n left: 0px;\n}\n\nslot[name=right] {\n right: 0px;\n}\n\n/***********\n * Slot size\n ***********/\nslot[name=top],\nslot[name=bottom] {\n width: 100%;\n flex-direction: column;\n}\n\nslot[name=left],\nslot[name=right] {\n height: 100%;\n flex-direction: row;\n}\n\nslot[name=top],\nslot[name=left] {\n justify-content: flex-start;\n}\n\nslot[name=bottom],\nslot[name=right] {\n justify-content: flex-end;\n}\n\n/*******************************\n * Match rounded corners to card\n *******************************/\n::slotted([slot=top]:first-child),\n::slotted([slot=left]:first-child) {\n border-top-left-radius: var(--ha-card-border-radius, 4px);\n}\n\n::slotted([slot=top]:first-child),\n::slotted([slot=right]:first-child) {\n border-top-right-radius: var(--ha-card-border-radius, 4px);\n}\n\n::slotted([slot=bottom]:last-child),\n::slotted([slot=left]:last-child) {\n border-bottom-left-radius: var(--ha-card-border-radius, 4px);\n}\n\n::slotted([slot=bottom]:last-child),\n::slotted([slot=right]:last-child) {\n border-bottom-right-radius: var(--ha-card-border-radius, 4px);\n}")}};AS=e([le("frigate-card-overlay")],AS);class IS{constructor(e){this._config=null,this._popupTimer=new bf,this._items=[],this._host=e}getRenderItems(){return this._items}setItems(e){const t=e.filter((e=>!!e.exclusive)),n=Sy(t.length?t:e,(e=>e.priority??50),"desc"),i=this._getSufficientValues(this._items),a=this._getSufficientValues(n);this._items=n,"popup"!==this._config?.style||jy(i,a)||(this._show(),this._popupTimer.start(this._config.popup_seconds,(()=>this._hide()))),this._host.requestUpdate()}setConfig(e){this._config=e,this._host.style.setProperty("--frigate-card-status-bar-height",`${e.height}px`),this._host.setAttribute("data-style",e.style),this._host.setAttribute("data-position",e.position),"popup"!==this._config?.style&&this._show(),this._host.requestUpdate()}shouldRender(){return this._items.some((e=>!1!==e.enabled&&e.sufficient))}actionHandler(e,t){e.stopPropagation();const n=_f(e.detail.action,t);n&&CS(this._host,{action:qm(n),config:t})}_getSufficientValue(e){
/* istanbul ignore else: cannot happen -- @preserve */
return"custom:frigate-card-status-bar-icon"===e.type?e.icon:"custom:frigate-card-status-bar-string"===e.type?e.string:"custom:frigate-card-status-bar-image"===e.type?e.image:null}_getSufficientValues(e){return e.filter((e=>!1!==e.enabled&&e.sufficient)).map((e=>this._getSufficientValue(e)))}_show(){af(this._host,!1,"hide")}_hide(){af(this._host,!0,"hide")}}let zS=class extends oe{constructor(){super(...arguments),this._controller=new IS(this)}willUpdate(e){e.has("config")&&this.config&&this._controller.setConfig(this.config),e.has("items")&&this._controller.setItems(this.items??[])}render(){if(this._controller.shouldRender())return q`
<div class="status">
${this._controller.getRenderItems().map((e=>{if(!1===e.enabled)return;const t=_e({item:!0,expand:!!e.expand,action:!!Object.keys(e.actions??{}).length}),n=Cf({hasHold:yf(e.actions?.hold_action),hasDoubleClick:yf(e.actions?.double_tap_action)});return"custom:frigate-card-status-bar-string"===e.type?q`<div
.actionHandler=${n}
class="${t}"
@action=${t=>this._controller.actionHandler(t,e.actions)}
>
${e.string}
</div>`:"custom:frigate-card-status-bar-icon"===e.type?q`<frigate-card-icon
.actionHandler=${n}
.icon=${{icon:e.icon}}
class="${t}"
@action=${t=>this._controller.actionHandler(t,e.actions)}
></frigate-card-icon>`:"custom:frigate-card-status-bar-image"===e.type?q`<img
.actionHandler=${n}
class="${t}"
src="${e.image}"
@action=${t=>this._controller.actionHandler(t,e.actions)}
/>`:void 0}))}
</div>
`}static get styles(){return s("ha-icon-button.button {\n color: var(--secondary-color, white);\n background-color: rgba(0, 0, 0, 0.6);\n border-radius: 50%;\n padding: 0px;\n margin: 3px;\n --ha-icon-display: block;\n /* Buttons can always be clicked */\n pointer-events: auto;\n opacity: 0.9;\n}\n\n:host {\n --mdc-icon-size: calc(var(--frigate-card-status-bar-height) - 6px);\n display: block;\n width: 100%;\n pointer-events: auto;\n opacity: 1;\n transition: opacity 1s;\n}\n\n/*******************************************************\n * Non-hover styles should not interact with the pointer\n *******************************************************/\n:host(:not([data-style*=hover])) {\n pointer-events: none;\n}\n\n/***************\n * Outside style\n ***************/\n:host([data-style=outside]) {\n color: var(--primary-text-color);\n background: var(--secondary-background-color);\n}\n\n/*******************\n * Non-outside style\n *******************/\n:host(:not([data-style=outside])) {\n color: white;\n background: linear-gradient(90deg, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0));\n}\n\n:host([data-style=popup][hide]) {\n opacity: 0;\n}\n\n/*********************\n * Status bar contents\n *********************/\n.status {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n overflow: hidden;\n width: 100%;\n height: var(--frigate-card-status-bar-height);\n}\n\n.item {\n display: inline-block;\n margin: 3px 5px;\n align-content: center;\n opacity: 0.7;\n}\n\n.item:first-child {\n margin-left: 10px;\n}\n\n.item:last-child {\n margin-right: 10px;\n}\n\n.item.expand {\n flex: 1;\n}\n\n.item.action {\n cursor: pointer;\n}\n\nimg.item {\n display: block;\n height: var(--mdc-icon-size, 24px);\n width: auto;\n}")}};e([he({attribute:!1})],zS.prototype,"items",void 0),e([he({attribute:!1})],zS.prototype,"config",void 0),zS=e([le("frigate-card-status-bar")],zS);function TS(e){return"number"==typeof e}function jS(e){return"string"==typeof e}function OS(e){return"boolean"==typeof e}function DS(e){return"[object Object]"===Object.prototype.toString.call(e)}function RS(e){return Math.abs(e)}function PS(e){return Math.sign(e)}function LS(e,t){return RS(e-t)}function NS(e){return qS(e).map(Number)}function FS(e){return e[VS(e)]}function VS(e){return Math.max(0,e.length-1)}function HS(e,t){return t===VS(e)}function BS(e,t=0){return Array.from(Array(e),((e,n)=>t+n))}function qS(e){return Object.keys(e)}function US(e,t){return[e,t].reduce(((e,t)=>(qS(t).forEach((n=>{const i=e[n],a=t[n],r=DS(i)&&DS(a);e[n]=r?US(i,a):a})),e)),{})}function WS(e,t){return void 0!==t.MouseEvent&&e instanceof t.MouseEvent}function ZS(){let e=[];const t={add:function(n,i,a,r={passive:!0}){let s;if("addEventListener"in n)n.addEventListener(i,a,r),s=()=>n.removeEventListener(i,a,r);else{const e=n;e.addListener(a),s=()=>e.removeListener(a)}return e.push(s),t},clear:function(){e=e.filter((e=>e()))}};return t}function QS(e,t,n,i){const a=ZS(),r=1e3/60;let s=null,o=0,c=0;function l(e){if(!c)return;s||(s=e);const a=e-s;for(s=e,o+=a;o>=r;)n(r),o-=r;i(o/r),c&&t.requestAnimationFrame(l)}function d(){t.cancelAnimationFrame(c),s=null,o=0,c=0}return{init:function(){a.add(e,"visibilitychange",(()=>{e.hidden&&(s=null,o=0)}))},destroy:function(){d(),a.clear()},start:function(){c||(c=t.requestAnimationFrame(l))},stop:d,update:()=>n(r),render:i}}function GS(e=0,t=0){const n=RS(e-t);function i(t){return t<e}function a(e){return e>t}function r(e){return i(e)||a(e)}const s={length:n,max:t,min:e,constrain:function(n){return r(n)?i(n)?e:t:n},reachedAny:r,reachedMax:a,reachedMin:i,removeOffset:function(e){return n?e-n*Math.ceil((e-t)/n):e}};return s}function YS(e,t,n){const{constrain:i}=GS(0,e),a=e+1;let r=s(t);function s(e){return n?RS((a+e)%a):i(e)}function o(){return r}function c(){return YS(e,o(),n)}const l={get:o,set:function(e){return r=s(e),l},add:function(e){return c().set(o()+e)},clone:c};return l}function KS(e,t,n,i,a,r,s,o,c,l,d,u,h,p,g,m,f,_,y){const{cross:v,direction:b}=e,w=["INPUT","SELECT",
<slot name="left"></slot>
<div ${je(this._refRoot)} class="embla__viewport">
<div class="embla__container">
<slot ${je(this._refParent)}></slot>
</div>
</div>
<slot name="right"></slot>
</div>`}updated(e){!this._carousel&&this._refRoot.value&&this._refParent.value?this._carousel=new Tk(this._refRoot.value,this._refParent.value,{direction:this.direction,dragEnabled:this.dragEnabled,dragFree:this.dragFree,startIndex:this.selected,transitionEffect:this.transitionEffect,loop:this.loop,plugins:this.plugins,textDirection:jk(this)}):e.has("selected")&&this._carousel?.selectSlide(this.selected)}static get styles(){return s(":host {\n display: block;\n height: 100%;\n width: 100%;\n position: relative;\n}\n\n.embla {\n width: 100%;\n height: 100%;\n margin-left: auto;\n margin-right: auto;\n}\n\n.embla__container {\n display: flex;\n width: 100%;\n height: 100%;\n user-select: none;\n -webkit-touch-callout: none;\n -khtml-user-select: none;\n -webkit-tap-highlight-color: transparent;\n}\n\n:host([direction=vertical]) .embla__container {\n flex-direction: column;\n}\n\n:host([direction=horizontal]) .embla__container {\n flex-direction: row;\n}\n\n.embla__viewport {\n width: 100%;\n height: 100%;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n justify-content: center;\n}\n\n.embla__viewport.is-draggable {\n cursor: move;\n cursor: grab;\n}\n\n.embla__viewport.is-dragging {\n cursor: grabbing;\n}\n\n:host([direction=vertical]) ::slotted(.embla__slide) {\n margin-bottom: 5px;\n}\n\n:host([direction=horizontal]) ::slotted(.embla__slide) {\n margin-right: 5px;\n}")}};e([he({attribute:!0,reflect:!0})],Ok.prototype,"direction",void 0),e([he({attribute:!0})],Ok.prototype,"transitionEffect",void 0),e([he({attribute:!1})],Ok.prototype,"loop",void 0),e([he({attribute:!1})],Ok.prototype,"dragFree",void 0),e([he({attribute:!1})],Ok.prototype,"dragEnabled",void 0),e([he({attribute:!1})],Ok.prototype,"plugins",void 0),e([he({attribute:!1})],Ok.prototype,"selected",void 0),Ok=e([le("frigate-card-carousel")],Ok);
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const Dk=window,Rk=Dk.ShadowRoot&&(void 0===Dk.ShadyCSS||Dk.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Pk=Symbol(),Lk=new WeakMap;let Nk=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==Pk)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(Rk&&void 0===e){const n=void 0!==t&&1===t.length;n&&(e=Lk.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&Lk.set(t,e))}return e}toString(){return this.cssText}};const Fk=(e,t)=>{Rk?e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):t.forEach((t=>{const n=document.createElement("style"),i=Dk.litNonce;void 0!==i&&n.setAttribute("nonce",i),n.textContent=t.cssText,e.appendChild(n)}))},Vk=Rk?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const n of e.cssRules)t+=n.cssText;return(e=>new Nk("string"==typeof e?e:e+"",void 0,Pk))(t)})(e):e
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/;var Hk;const Bk=window,qk=Bk.trustedTypes,Uk=qk?qk.emptyScript:"",Wk=Bk.reactiveElementPolyfillSupport,Zk={toAttribute(e,t){switch(t){case Boolean:e=e?Uk:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=null!==e;break;case Number:n=null===e?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch(e){n=null}}return n}},Qk=(e,t)=>t!==e&&(t==t||e==e),Gk={attribute:!0,type:String,converter:Zk,reflect:!1,hasChanged:Qk},Yk="finalized";class Kk extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(e){var t;this.finalize(),(null!==(t=this.h)&&void 0!==t?t:this.h=[]).push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,n)=>{const i=this._$Ep(n,t);void 0!==i&&(this._$Ev.set(i,n),e.push(i))})),e}static createProperty(e,t=Gk){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const n="symbol"==typeof e?Symbol():"__"+e,i=this.getPropertyDescriptor(e,n,t);void 0!==i&&Object.defineProperty(this.prototype,e,i)}}static getPropertyDescriptor(e,t,n){return{get(){return this[t]},set(i){const a=this[e];this[t]=i,this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||Gk}static finalize(){if(this.hasOwnProperty(Yk))return!1;this[Yk]=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),void 0!==e.h&&(this.h=[...e.h]),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const n of t)this.createProperty(n,e[n])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const n=new Set(e.flat(1/0).reverse());for(const e of n)t.unshift(Vk(e))}else void 0!==e&&t.push(Vk(e));return t}static _$Ep(e,t){const n=t.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof e?e.toLowerCase():void 0}_$Eu(){var e;this._$E_=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(e=this.constructor.h)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,n;(null!==(t=this._$ES)&&void 0!==t?t:this._$ES=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(n=e.hostConnected)||void 0===n||n.call(e))}removeController(e){var t;null===(t=this._$ES)||void 0===t||t.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this._$Ei.set(t,this[t]),delete this[t])}))}createRenderRoot(){var e;const t=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return Fk(t,this.constructor.elementStyles),t}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)}))}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)}))}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$EO(e,t,n=Gk){var i;const a=this.constructor._$Ep(e,n);if(void 0!==a&&!0===n.reflect){const r=(void 0!==(null===(i=n.converter)||void 0===i?void 0:i.toAttribute)?n.converter:Zk).toAttribute(t,n.type);this._$El=e,null==r?this.removeAttribute(a):this.setAttribute(a,r),this._$El=null}}_$AK(e,t){var n;const i=this.constructor,a=i._$Ev.get(e);if(void 0!==a&&this._$El!==a){const e=i.getPropertyOptions(a),r="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==(null===(n=e.converter)||void 0===n?void 0:n.fromAttribute)?e.converter:Zk;this._$El=a,this[a]=r.fromAttribute(t,e.type),this._$El=null}}requestUpdate(e,t,n){let i=!0;void 0!==e&&(((n=n||this.constr
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const Xk=0,Jk=Symbol();class eE{constructor(e,t,n){this.o=0,this.status=0,this.autoRun=!0,this.i=e,this.i.addController(this);const i="object"==typeof t?t:{task:t,args:n};this.t=i.task,this.h=i.args,void 0!==i.autoRun&&(this.autoRun=i.autoRun),this.taskComplete=new Promise(((e,t)=>{this.l=e,this.u=t}))}hostUpdated(){this.performTask()}async performTask(){var e;const t=null===(e=this.h)||void 0===e?void 0:e.call(this);this.shouldRun(t)&&this.run(t)}shouldRun(e){return this.autoRun&&this.v(e)}async run(e){var t;let n,i;null!=e||(e=null===(t=this.h)||void 0===t?void 0:t.call(this)),2!==this.status&&3!==this.status||(this.taskComplete=new Promise(((e,t)=>{this.l=e,this.u=t}))),this.status=1,this._=void 0,this.m=void 0,this.i.requestUpdate();const a=++this.o;try{n=await this.t(e)}catch(e){i=e}this.o===a&&(n===Jk?this.status=0:(void 0===i?(this.status=2,this.l(n)):(this.status=3,this.u(i)),this.m=n,this._=i),this.i.requestUpdate())}get value(){return this.m}get error(){return this._}render(e){var t,n,i,a;switch(this.status){case 0:return null===(t=e.initial)||void 0===t?void 0:t.call(e);case 1:return null===(n=e.pending)||void 0===n?void 0:n.call(e);case 2:return null===(i=e.complete)||void 0===i?void 0:i.call(e,this.value);case 3:return null===(a=e.error)||void 0===a?void 0:a.call(e,this.error);default:this.status}}v(e){const t=this.T;return this.T=e,Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.some(((e,n)=>Qk(e,t[n]))):e!==t}}class tE{constructor(e){this._keys=e}modify(e){this._keys.forEach((t=>e.removeContext(t)))}}var nE=":host {\n display: flex;\n flex-direction: column;\n width: 100%;\n margin-left: 5px;\n padding: 5px;\n color: var(--primary-text-color);\n overflow: hidden;\n column-gap: 5%;\n}\n\ndiv.title {\n font-size: 1.2rem;\n font-weight: bold;\n}\n\ndiv.details {\n flex: 1;\n justify-content: center;\n display: flex;\n flex-direction: column;\n flex-wrap: wrap;\n --mdc-icon-size: 16px;\n min-height: 0px;\n}\n\ndiv.details div {\n display: flex;\n align-items: center;\n}\n\ndiv.details div * {\n margin: 0px 3px;\n}";const iE=(e,t,n)=>{const i={...n?.cardWideConfig&&{cardWideConfig:n.cardWideConfig}};return q` ${e.render({initial:()=>n?.inProgressFunc?.()??sS(i),pending:()=>n?.inProgressFunc?.()??sS(i),error:e=>{Zm(e),n?.errorFunc&&n.errorFunc(e)},complete:t})}`},aE=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,rE=(e,t,n,i=!0)=>new eE(e,{args:()=>[!!t(),n()],task:async([e,n])=>{const i=t();return e&&i&&n?(async(e,t)=>e&&t?t.startsWith("data:")||t.match(aE)?t:new Promise(((n,i)=>{e?e.fetchWithAuth(t).then((e=>e.blob())).then((e=>{const t=new FileReader;t.onload=()=>{const e=t.result;n("string"==typeof e?e:null)},t.onerror=e=>i(e),t.readAsDataURL(e)})).catch((e=>i(e))):i()})):null)(i,n):null},autoRun:i}),sE=300;let oE=class extends oe{constructor(){super(),this._thumbnailError=!1,this._intersectionObserver=new IntersectionObserver(this._intersectionHandler.bind(this))}connectedCallback(){this._intersectionObserver.observe(this),super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),this._intersectionObserver.disconnect()}willUpdate(e){e.has("thumbnail")&&(this._embedThumbnailTask=rE(this,(()=>this.hass),(()=>this.thumbnail),!1),this._intersectionObserver.unobserve(this),this._intersectionObserver.observe(this))}_intersectionHandler(e){this._embedThumbnailTask?.status===Xk&&e.some((e=>e.isIntersecting))&&this._embedThumbnailTask?.run()}render(){const e=q`<frigate-card-icon
.icon=${{icon:"mdi:image-off"}}
title=${N_("thumbnail.no_thumbnail")}
></frigate-card-icon> `;return!this._embedThumbnailTask||this._thumbnailError?e:q`${this.thumbnail?iE(this._embedThumbnailTask,(e=>e?q`<img src="${e}" />`:q``),{inProgressFunc:()=>e,errorFunc:()=>{this._thumbnailError=!0}}):e} `}static get styles(){return s(":host {\n display: block;\n overflow: hidden;\n aspect-ratio: 1/1;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\nimg {\n display: block;\n}\n\nimg,\nfrigate-card-icon {\n display: inline-block;\n vertical-align: top;\n margin: 0;\n border-radius: var(--frigate-card-css-border-radius, var(--ha-card-border-radius, 4px));\n width: var(--frigate-card-thumbnail-size);\n max-height: 100%;\n aspect-ratio: 1/1;\n object-fit: cover;\n}\n\nfrigate-card-icon {\n --mdc-icon-size: 50%;\n color: var(--primary-text-color);\n display: flex;\n justify-content: center;\n align-items: center;\n border: 1px solid rgba(255, 255, 255, 0.3);\n box-sizing: border-box;\n opacity: 0.2;\n}")}};e([he({attribute:!1})],oE.prototype,"thumbnail",void 0),e([he({attribute:!1})],oE.prototype,"hass",void 0),e([pe()],oE.prototype,"_thumbnailError",void 0),oE=e([le("frigate-card-thumbnail-feature-thumbnail")],oE);let cE=class extends oe{render(){if(this.date)return q`
${this.cameraMetadata?.engineIcon?q`<frigate-card-icon
class="background"
.icon=${{icon:this.cameraMetadata.engineIcon}}
></frigate-card-icon>`:""}
<div class="content">
<div class="title">${qu(this.date,"HH:mm")}</div>
<div class="subtitle">${qu(this.date,"MMM do")}</div>
${this.showCameraTitle&&this.cameraMetadata?.title?q`<div class="camera">${this.cameraMetadata.title}</div>`:q``}
</div>
`}static get styles(){return s(":host {\n display: block;\n max-width: var(--frigate-card-thumbnail-size);\n max-height: var(--frigate-card-thumbnail-size);\n aspect-ratio: 1/1;\n border: 1px solid var(--secondary-color);\n background-color: var(--secondary-background-color);\n border-radius: var(--frigate-card-css-border-radius, var(--ha-card-border-radius, 4px));\n overflow: hidden;\n padding: 10px;\n box-sizing: border-box;\n position: relative;\n}\n\nfrigate-card-icon.background {\n display: block;\n width: 100%;\n height: 100%;\n position: absolute;\n inset: 0;\n padding: 10%;\n box-sizing: border-box;\n pointer-events: none;\n opacity: 0.1;\n}\n\ndiv.content {\n height: 100%;\n width: 100%;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n color: var(--primary-text-color);\n}\n\ndiv {\n text-align: center;\n}\n\ndiv.title {\n font-size: 1.5rem;\n}\n\ndiv.camera {\n font-size: 0.7em;\n}")}};e([he({attribute:!1})],cE.prototype,"date",void 0),e([he({attribute:!1})],cE.prototype,"cameraMetadata",void 0),e([he({attribute:!1})],cE.prototype,"showCameraTitle",void 0),cE=e([le("frigate-card-thumbnail-feature-text")],cE);let lE=class extends oe{render(){if(!this.media)return;const e=this.media.getScore(),t=e?(100*e).toFixed(2)+"%":null,n=this.media.getStartTime(),i=n?Gm(n):null,a=this.media.getEndTime(),r=n&&a?Xm(n,a):null,s=this.media.inProgress()?N_("event.in_progress"):null,o=Hm(this.media.getWhat()?.join(", "))??null,c=Hm(this.media.getWhere()?.join(", "))??null,l=Hm(this.media.getTags()?.join(", "))??null,d=o||l?(o??"")+(o&&l?": ":"")+(l??""):null,u=this.seek?qu(this.seek,"HH:mm:ss"):null;return q`
${d?q` <div class="title">
<span title=${d}>${d}</span>
${t?q`<span title="${t}">${t}</span>`:""}
</div>`:""}
<div class="details">
${i?q` <div>
<frigate-card-icon
title=${N_("event.start")}
.icon=${{icon:"mdi:calendar-clock-outline"}}
></frigate-card-icon>
<span title="${i}">${i}</span>
</div>
${r||s?q` <div>
<frigate-card-icon
title=${N_("event.duration")}
.icon=${{icon:"mdi:clock-outline"}}
></frigate-card-icon>
${r?q`<span title="${r}">${r}</span>`:""}
${s?q`<span title="${s}">${s}</span>`:""}
</div>`:""}`:""}
${this.cameraTitle?q` <div>
<frigate-card-icon
title=${N_("event.camera")}
.icon=${{icon:"mdi:cctv"}}
></frigate-card-icon>
<span title="${this.cameraTitle}">${this.cameraTitle}</span>
</div>`:""}
${c?q` <div>
<frigate-card-icon
title=${N_("event.where")}
.icon=${{icon:"mdi:map-marker-outline"}}
></frigate-card-icon>
<span title="${c}">${c}</span>
</div>`:q``}
${l?q` <div>
<frigate-card-icon
title=${N_("event.tag")}
.icon=${{icon:"mdi:tag"}}
></frigate-card-icon>
<span title="${l}">${l}</span>
</div>`:q``}
${u?q` <div>
<frigate-card-icon
title=${N_("event.seek")}
.icon=${{icon:"mdi:clock-fast"}}
></frigate-card-icon>
<span title="${u}">${u}</span>
</div>`:q``}
</div>
`}static get styles(){return s(nE)}};e([he({attribute:!1})],lE.prototype,"media",void 0),e([he({attribute:!1})],lE.prototype,"seek",void 0),e([he({attribute:!1})],lE.prototype,"cameraTitle",void 0),lE=e([le("frigate-card-thumbnail-details-event")],lE);let dE=class extends oe{render(){if(!this.media)return;const e=this.media.getStartTime(),t=e?Gm(e):null,n=this.media.getEndTime(),i=e&&n?Xm(e,n):null,a=this.media.inProgress()?N_("recording.in_progress"):null,r=this.seek?qu(this.seek,"HH:mm:ss"):null,s=this.media.getEventCount();return q`
${this.cameraTitle?q` <div class="title">
<span title="${this.cameraTitle}">${this.cameraTitle}</span>
</div>`:""}
<div class="details">
${t?q` <div>
<frigate-card-icon
title=${N_("recording.start")}
.icon=${{icon:"mdi:calendar-clock-outline"}}
></frigate-card-icon>
<span title="${t}">${t}</span>
</div>
${i||a?q` <div>
<frigate-card-icon
title=${N_("recording.duration")}
.icon=${{icon:"mdi:clock-outline"}}
></frigate-card-icon>
${i?q`<span title="${i}">${i}</span>`:""}
${a?q`<span title="${a}">${a}</span>`:""}
</div>`:""}`:""}
${r?q` <div>
<frigate-card-icon
title=${N_("event.seek")}
.icon=${{icon:"mdi:clock-fast"}}
></frigate-card-icon>
<span title="${r}">${r}</span>
</div>`:q``}
${null!==s?q`<div>
<frigate-card-icon
title=${N_("recording.events")}
.icon=${{icon:"mdi:shield-alert"}}
></frigate-card-icon>
<span title="${s}">${s}</span>
</div>`:""}
</div>
`}static get styles(){return s(nE)}};e([he({attribute:!1})],dE.prototype,"media",void 0),e([he({attribute:!1})],dE.prototype,"seek",void 0),e([he({attribute:!1})],dE.prototype,"cameraTitle",void 0),dE=e([le("frigate-card-thumbnail-details-recording")],dE);let uE=class extends oe{constructor(){super(...arguments),this.details=!1,this.show_favorite_control=!1,this.show_timeline_control=!1,this.show_download_control=!1}render(){if(!this.media||!this.cameraManager||!this.hass)return;const e=this.media.getThumbnail(),t=this.media.getTitle()??"",n={star:!0,starred:!!this.media?.isFavorite()},i=this.show_timeline_control&&(!Pw.isRecording(this.media)||this.media.getStartTime()&&this.media.getEndTime()),a=this.cameraManager?.getMediaCapabilities(this.media),r=this.show_favorite_control&&this.media&&this.hass&&a?.canFavorite,s=this.show_download_control&&this.hass&&this.media.getID()&&a?.canDownload,o=this.cameraManager.getCameraMetadata(this.media.getCameraID());return q`
${Pw.isEvent(this.media)&&e?q`<frigate-card-thumbnail-feature-thumbnail
aria-label="${t??""}"
title=${t}
.hass=${this.hass}
.date=${this.media.getStartTime()??void 0}
.thumbnail=${e??void 0}
></frigate-card-thumbnail-feature-thumbnail>`:Pw.isEvent(this.media)||Pw.isRecording(this.media)?q`<frigate-card-thumbnail-feature-text
aria-label="${t??""}"
title="${t??""}"
.cameraMetadata=${o}
.showCameraTitle=${!this.details}
.date=${this.media.getStartTime()??void 0}
></frigate-card-thumbnail-feature-text>`:q``}
${r?q` <frigate-card-icon
class="${_e(n)}"
title=${N_("thumbnail.retain_indefinitely")}
.icon=${{icon:this.media.isFavorite()?"mdi:star":"mdi:star-outline"}}
@click=${async e=>{if(vf(e),this.hass&&this.media){try{await(this.cameraManager?.favoriteMedia(this.media,!this.media?.isFavorite()))}catch(e){return void Zm(e)}this.requestUpdate()}}}
/></frigate-card-icon>`:""}
${this.details&&Pw.isEvent(this.media)?q`<frigate-card-thumbnail-details-event
.media=${this.media??void 0}
.cameraTitle=${o?.title}
.seek=${this.seek}
></frigate-card-thumbnail-details-event>`:this.details&&Pw.isRecording(this.media)?q`<frigate-card-thumbnail-details-recording
.media=${this.media??void 0}
.cameraTitle=${o?.title}
.seek=${this.seek}
></frigate-card-thumbnail-details-recording>`:q``}
${i?q`<frigate-card-icon
class="timeline"
.icon=${{icon:"mdi:target"}}
title=${N_("thumbnail.timeline")}
@click=${e=>{vf(e),this.viewManagerEpoch&&this.media&&this.viewManagerEpoch.manager.setViewByParameters({params:{view:"timeline",queryResults:this.viewManagerEpoch?.manager.getView()?.queryResults?.clone().selectResultIfFound((e=>e===this.media))},modifiers:[new tE(["timeline"])]})}}
></frigate-card-icon>`:""}
${s?q` <frigate-card-icon
class="download"
.icon=${{icon:"mdi:download"}}
title=${N_("thumbnail.download")}
@click=${async e=>{if(vf(e),this.hass&&this.cameraManager&&this.media)try{await lw(this.hass,this.cameraManager,this.media)}catch(e){cS(this,e)}}}
></frigate-card-icon>`:""}
`}static get styles(){return s(":host {\n display: flex;\n flex-direction: row;\n box-sizing: border-box;\n position: relative;\n overflow: hidden;\n transition: transform 0.2s linear;\n}\n\n:host(:not([details])) {\n aspect-ratio: 1/1;\n}\n\n:host([details]) {\n border: 1px solid var(--primary-color);\n border-radius: var(--frigate-card-css-border-radius, var(--ha-card-border-radius, 4px));\n padding: 2px;\n background-color: var(--primary-background-color, black);\n}\n\n:host(:hover) {\n transform: scale(1.04);\n}\n\nfrigate-card-icon {\n position: absolute;\n border-radius: 50%;\n opacity: 0.5;\n color: var(--primary-color);\n cursor: pointer;\n transition: opacity 0.2s ease-in-out, color 0.2s ease-in-out;\n}\n\nfrigate-card-icon:hover {\n opacity: 1;\n}\n\nfrigate-card-icon.star {\n top: 3px;\n left: 3px;\n}\n\nfrigate-card-icon.star.starred {\n color: gold;\n}\n\nfrigate-card-icon.timeline {\n top: 3px;\n right: 3px;\n}\n\nfrigate-card-icon.download {\n right: 3px;\n bottom: 3px;\n}\n\nfrigate-card-thumbnail-details-event,\nfrigate-card-thumbnail-details-recording {\n flex: 1;\n}")}};e([he({attribute:!1})],uE.prototype,"cameraManager",void 0),e([he({attribute:!1})],uE.prototype,"media",void 0),e([he({attribute:!0,type:Boolean})],uE.prototype,"details",void 0),e([he({attribute:!0,type:Boolean})],uE.prototype,"show_favorite_control",void 0),e([he({attribute:!0,type:Boolean})],uE.prototype,"show_timeline_control",void 0),e([he({attribute:!0,type:Boolean})],uE.prototype,"show_download_control",void 0),e([he({attribute:!1})],uE.prototype,"seek",void 0),uE=e([le("frigate-card-thumbnail")],uE);let hE=class extends oe{constructor(){super(...arguments),this.fadeThumbnails=!1,this._thumbnailSlides=[]}willUpdate(e){if(e.has("config")){this.config?.size&&this.style.setProperty("--frigate-card-thumbnail-size",`${this.config.size}px`);const e=this._getDirection();e?this.setAttribute("direction",e):this.removeAttribute("direction")}["cameraManager","config","transitionEffect","viewManagerEpoch"].some((t=>e.has(t)))&&(this._thumbnailSlides=this._renderSlides()),e.has("viewManagerEpoch")&&this.style.setProperty("--frigate-card-carousel-thumbnail-opacity",this.fadeThumbnails&&null!==this._getSelectedSlide()?"0.4":"1.0")}_getSelectedSlide(){return this.viewManagerEpoch?.manager.getView()?.queryResults?.getSelectedIndex()??null}_renderSlides(){const e=[],t=this.viewManagerEpoch?.manager.getView(),n=t?.context?.mediaViewer?.seek,i=this._getSelectedSlide();for(const a of t?.queryResults?.getResults()??[]){const t=e.length,r={embla__slide:!0,"slide-selected":i===t};e.push(q` <frigate-card-thumbnail
class="${_e(r)}"
.cameraManager=${this.cameraManager}
.hass=${this.hass}
.media=${a}
.viewManagerEpoch=${this.viewManagerEpoch}
.seek=${n&&a.includesTime(n)?n:void 0}
?details=${!!this.config?.show_details}
?show_favorite_control=${this.config?.show_favorite_control}
?show_timeline_control=${this.config?.show_timeline_control}
?show_download_control=${this.config?.show_download_control}
@click=${e=>{const n=this.viewManagerEpoch?.manager.getView();n&&n.queryResults&&Vm(this,"thumbnail-carousel:tap",{queryResults:n.queryResults.clone().selectIndex(t)}),vf(e)}}
>
</frigate-card-thumbnail>`)}return e}_getDirection(){return"left"===this.config?.mode||"right"===this.config?.mode?"vertical":"above"===this.config?.mode||"below"===this.config?.mode?"horizontal":null}render(){const e=this._getDirection();if(this._thumbnailSlides.length&&this.config&&e)return q`<frigate-card-carousel
direction=${e}
.selected=${this._getSelectedSlide()??0}
.dragFree=${!0}
>
${this._thumbnailSlides}
</frigate-card-carousel>`}static get styles(){return s(":host {\n --frigate-card-thumbnail-size-max: 300px;\n --frigate-card-thumbnail-details-width: calc(\n var(--frigate-card-thumbnail-size) + 200px\n );\n}\n\n:host {\n display: block;\n width: 100%;\n height: 100%;\n --frigate-card-carousel-thumbnail-opacity: 1;\n}\n\n:host([direction=vertical]) {\n height: 100%;\n}\n\n:host([direction=horizontal]) {\n height: auto;\n}\n\n.embla__slide {\n flex: 0 0 auto;\n opacity: var(--frigate-card-carousel-thumbnail-opacity);\n}\n\n.embla__slide.slide-selected {\n opacity: 1;\n}\n\nfrigate-card-thumbnail {\n width: var(--frigate-card-thumbnail-size);\n height: var(--frigate-card-thumbnail-size);\n max-width: 100%;\n}\n\nfrigate-card-thumbnail[details] {\n width: var(--frigate-card-thumbnail-details-width);\n}")}};e([he({attribute:!1})],hE.prototype,"hass",void 0),e([he({attribute:!1})],hE.prototype,"viewManagerEpoch",void 0),e([he({attribute:!1})],hE.prototype,"cameraManager",void 0),e([he({attribute:!1})],hE.prototype,"config",void 0),e([he({attribute:!1})],hE.prototype,"fadeThumbnails",void 0),hE=e([le("frigate-card-thumbnail-carousel")],hE);var pE=":host {\n width: 100%;\n height: 100%;\n display: block;\n}";const gE=document.createElement("template");gE.innerHTML='<style>\n:host {\n background-color: #ffffff;\n width: 350px;\n max-width: 75vw;\n\n visibility: hidden;\n transition: visibility 0.5s;\n}\n\n:host([open]) {\n visibility: visible;\n}\n\n::slotted(div) {\n box-sizing: border-box;\n}\n\n#d {\n position: fixed;\n z-index: 99;\n background-color: inherit;\n -webkit-overflow-scrolling: touch;\n overflow: auto;\n overscroll-behavior: contain;\n backdrop-filter: var(--side-drawer-backdrop-filter, none);\n\n top: 0;\n bottom: 0;\n left: 0;\n height: 100%;\n box-sizing: border-box;\n transform: translateX(-100%);\n transition: var(\n --side-drawer-transition,\n transform 0.25s ease-out\n );\n width: inherit;\n max-width: inherit;\n border-top-right-radius: inherit;\n border-bottom-right-radius: inherit;\n}\n\n:host([open]) #d {\n transform: none;\n box-shadow: 0px 0px 25px 0px rgba(0, 0, 0, 0.5);\n}\n\n#fs {\n position: fixed;\n z-index: 98;\n background-color: #000000;\n backdrop-filter: var(--side-drawer-backdrop-filter, none);\n\n top: 0;\n bottom: 0;\n right: -30px; /* hide scrollbar until overscroll bug is fixed */\n height: 100vh;\n transition: var(\n --side-drawer-overlay-transition,\n opacity linear 0.25s\n );\n width: calc(\n 100vw + 30px\n ); /* put back to just 100vw once overscroll bug fixed */\n opacity: 0;\n visibility: hidden;\n\n overflow: auto;\n overscroll-behavior: contain;\n}\n\n:host([open]) #fs {\n opacity: var(--side-drawer-overlay-opacity, 0.7);\n visibility: visible;\n}\n\n/*\n * Workaround for bug https://bugs.chromium.org/p/chromium/issues/detail?id=813094\n * Once bug is fixed and in the wild we can remove this element and make #if overflow:hidden\n * and set "right: 0; width: 100vw" for #fs\n */\n#ifs {\n height: calc(100vh + 1px);\n}\n</style>\n<div id="d"><slot></slot></div>\n<div id="fs"><div id="ifs"></div></div>\n';class mE extends HTMLElement{constructor(){super();const e=this.attachShadow({mode:"open"});e.appendChild(gE.content.cloneNode(!0)),this._freeSpaceDiv=e.getElementById("fs")}connectedCallback(){this._freeSpaceDiv&&this._freeSpaceDiv.addEventListener("click",this.handleFreeSpaceDivClick),this.upgradeProperty("open")}disconnectedCallback(){document.removeEventListener("keyup",this.handleKeyUp)}upgradeProperty(e){if(this.hasOwnProperty(e)){let t=this[e];delete this[e],this[e]=t}}handleKeyUp=e=>{if(!e.altKey&&"Escape"===e.key)e.preventDefault(),this.open=!1};get open(){return this.hasAttribute("open")}set open(e){e?this.hasAttribute("open")||this.setAttribute("open",""):this.hasAttribute("open")&&this.removeAttribute("open")}static get observedAttributes(){return["open"]}attributeChangedCallback(e,t,n){"open"===e&&(this.open?(this.setAttribute("tabindex","0"),this.setAttribute("aria-disabl
<side-drawer
${je(this._refDrawer)}
location="${this.location}"
?open=${this.open}
@mouseleave=${()=>{this.open&&(this.open=!1)}}
>
${this.control?q`
<div
class="control-surround"
@click=${e=>{vf(e),this.open=!this.open}}
>
<frigate-card-icon
class="control"
.icon="${{icon:this.open?this.icons?.open??"mdi:menu-open":this.icons?.closed??"mdi:menu"}}"
@mouseenter=${()=>{this._isHoverableDevice&&!this.open&&(this.open=!0)}}
>
</frigate-card-icon>
</div>
`:""}
<slot ${je(this._refSlot)} @slotchange=${()=>this._slotChanged()}></slot>
</side-drawer>
`}static get styles(){return s("side-drawer {\n background-color: var(--card-background-color);\n}\n\ndiv.control-surround {\n position: absolute;\n bottom: 50%;\n transform: translateY(50%);\n z-index: 0;\n padding-top: 20px;\n padding-bottom: 20px;\n}\n\n:host([location=left]) div.control-surround {\n padding-right: 12px;\n left: 100%;\n}\n\n:host([location=right]) div.control-surround {\n padding-left: 12px;\n right: 100%;\n}\n\n:host([empty]),\n:host([empty]) > * {\n visibility: hidden;\n}\n\n:host(:not([empty])),\n:host(:not([empty])) > * {\n visibility: visible;\n}\n\nfrigate-card-icon.control {\n color: var(--secondary-color, white);\n background-color: rgba(0, 0, 0, 0.7);\n opacity: 0.5;\n pointer-events: all;\n --mdc-icon-size: 20px;\n padding-top: 20px;\n padding-bottom: 20px;\n transition: opacity 0.5s ease;\n}\n\n:host([open]) frigate-card-icon.control,\nfrigate-card-icon.control:hover {\n opacity: 1;\n background-color: black;\n}\n\n:host([location=left]) frigate-card-icon.control {\n border-top-right-radius: 20px;\n border-bottom-right-radius: 20px;\n}\n\n:host([location=right]) frigate-card-icon.control {\n border-top-left-radius: 20px;\n border-bottom-left-radius: 20px;\n}")}};e([he({attribute:!0,reflect:!0})],fE.prototype,"location",void 0),e([he({attribute:!0,reflect:!0,type:Boolean})],fE.prototype,"control",void 0),e([he({type:Boolean,reflect:!0,attribute:!0})],fE.prototype,"open",void 0),e([he({attribute:!1})],fE.prototype,"icons",void 0),e([he({type:Boolean,reflect:!0,attribute:!0})],fE.prototype,"empty",void 0),fE=e([le("frigate-card-drawer")],fE);let _E=class extends oe{constructor(){super(...arguments),this._refDrawerLeft=Ie(),this._refDrawerRight=Ie(),this._boundDrawerHandler=this._drawerHandler.bind(this)}connectedCallback(){super.connectedCallback(),this.addEventListener("frigate-card:drawer:open",this._boundDrawerHandler),this.addEventListener("frigate-card:drawer:close",this._boundDrawerHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("frigate-card:drawer:open",this._boundDrawerHandler),this.removeEventListener("frigate-card:drawer:close",this._boundDrawerHandler)}_drawerHandler(e){const t=e.detail.drawer,n=e.type.endsWith(":open");"left"===t&&this._refDrawerLeft.value?this._refDrawerLeft.value.open=n:"right"===t&&this._refDrawerRight.value&&(this._refDrawerRight.value.open=n)}render(){return q` <slot name="above"></slot>
<slot></slot>
<frigate-card-drawer
${je(this._refDrawerLeft)}
location="left"
.icons=${this.drawerIcons?.left}
>
<slot name="left"></slot>
</frigate-card-drawer>
<frigate-card-drawer
${je(this._refDrawerRight)}
location="right"
.icons=${this.drawerIcons?.right}
>
<slot name="right"></slot>
</frigate-card-drawer>
<slot name="below"></slot>`}static get styles(){return s(":host {\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n position: relative;\n overflow: hidden;\n}\n\n::slotted(:not([slot])) {\n flex: 1;\n min-height: 0px;\n}")}};e([he({attribute:!1})],_E.prototype,"drawerIcons",void 0),_E=e([le("frigate-card-surround-basic")],_E);let yE=class extends oe{_hasDrawer(){return!!this.thumbnailConfig&&["left","right"].includes(this.thumbnailConfig.mode)}willUpdate(e){this.timelineConfig?.mode&&"none"!==this.timelineConfig.mode&&import("./timeline-core-14147786.js");const t=this.viewManagerEpoch?.manager.getView();e.has("viewManagerEpoch")&&(this.viewManagerEpoch?.manager.hasMajorMediaChange(this.viewManagerEpoch?.oldView)||this.viewManagerEpoch?.oldView?.displayMode!==t?.displayMode)&&(this._cameraIDsForTimeline=this._getCameraIDsForTimeline()??void 0)}_getCameraIDsForTimeline(){const e=this.viewManagerEpoch?.manager.getView();if(!e||!this.cameraManager)return null;if(e.is("live")){const t={anyCapabilities:["clips","snapshots","recordings"]};return e.supportsMultipleDisplayModes()&&e.isGrid()?this.cameraManager.getStore().getCameraIDsWithCapability(t):this.cameraManager.getStore().getAllDependentCameras(e.camera,t)}return e.isViewerView()?e.query?.getQueryCameraIDs()??null:null}render(){const e=this.viewManagerEpoch?.manager.getView();if(!this.hass||!e)return;const t=(e,t)=>{this.thumbnailConfig&&this._hasDrawer()&&Vm(e.composedPath()[0],"drawer:"+t,{drawer:this.thumbnailConfig.mode})};return q` <frigate-card-surround-basic
@frigate-card:thumbnails:open=${e=>t(e,"open")}
@frigate-card:thumbnails:close=${e=>t(e,"close")}
>
${this.thumbnailConfig&&"none"!==this.thumbnailConfig.mode?q` <frigate-card-thumbnail-carousel
slot=${this.thumbnailConfig.mode}
.hass=${this.hass}
.config=${this.thumbnailConfig}
.cameraManager=${this.cameraManager}
.fadeThumbnails=${e.isViewerView()}
.viewManagerEpoch=${this.viewManagerEpoch}
.selected=${e.queryResults?.getSelectedIndex()??void 0}
@frigate-card:thumbnail-carousel:tap=${e=>{const n=e.detail.queryResults.getSelectedResult();n&&(this.viewManagerEpoch?.manager.setViewByParameters({params:{view:"media",queryResults:e.detail.queryResults,...n.getCameraID()&&{camera:n.getCameraID()}},modifiers:[new tE(["timeline","mediaViewer"])]}),t(e,"close"))}}
>
</frigate-card-thumbnail-carousel>`:""}
${this.timelineConfig&&"none"!==this.timelineConfig.mode?q` <frigate-card-timeline-core
slot=${this.timelineConfig.mode}
.hass=${this.hass}
.viewManagerEpoch=${this.viewManagerEpoch}
.itemClickAction=${e.isViewerView()||!this.thumbnailConfig||"none"===this.thumbnailConfig?.mode?"play":"select"}
.cameraIDs=${this._cameraIDsForTimeline}
.mini=${!0}
.timelineConfig=${this.timelineConfig}
.thumbnailConfig=${this.thumbnailConfig}
.cameraManager=${this.cameraManager}
.cardWideConfig=${this.cardWideConfig}
>
</frigate-card-timeline-core>`:""}
<slot></slot>
</frigate-card-surround-basic>`}static get styles(){return s(pE)}};e([he({attribute:!1})],yE.prototype,"hass",void 0),e([he({attribute:!1})],yE.prototype,"viewManagerEpoch",void 0),e([he({attribute:!1,hasChanged:Wm})],yE.prototype,"thumbnailConfig",void 0),e([he({attribute:!1,hasChanged:Wm})],yE.prototype,"timelineConfig",void 0),e([he({attribute:!1})],yE.prototype,"cameraManager",void 0),e([he({attribute:!1})],yE.prototype,"cardWideConfig",void 0),yE=e([le("frigate-card-surround")],yE);var vE="Tue, 24 Dec 2024 00:23:18 GMT",bE="bc95f55",wE="Mon, 23 Dec 2024 16:22:10 -0800";const xE=bi.object({domain:bi.string(),version:bi.string().optional()}).passthrough(),CE="hass_web_proxy",ME=(e,t)=>`/api/${CE}/v${t??0}/?url=${encodeURIComponent(e)}`,SE=(e,t,n="media")=>(e=>e.config.components.includes(CE))(e)&&!!t[n];async function kE(e,t,n){await e.callService(CE,"create_proxied_url",{url_pattern:t,...n&&{url_id:n.urlID,ssl_verification:n.sslVerification,ssl_ciphers:n.sslCiphers,open_limit:n.openLimit,ttl:n.ttl,allow_unauthenticated:n.allowUnauthenticated}})}const EE=async(e,t)=>{let n=null;if(t)try{n=await(async(e,t)=>await ky(e,xE,{type:"manifest/get",integration:t}))(t,e)}catch(e){}return{detected:!!n,...n?.version&&{version:n.version}}};let $E=class extends oe{constructor(){super(...arguments),this._diagnostics=null}async _fetchDiagnostics(){this._diagnostics=await(async(e,t,n)=>{const i=e&&t?await t.getMatchingDevices(e,(e=>"Frigate"===e.manufacturer)):[],a=new Map;return i?.forEach((e=>{e.config_entries.forEach((t=>{e.model&&a.set(t,e.model)}))})),{card_version:"6.1.2",browser:navigator.userAgent,date:new Date,lang:L_(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,git:{hash:bE,build_date:vE,commit_date:wE},...e&&{ha_version:e.config.version},custom_integrations:{frigate:{...await EE("frigate",e),...a.size&&{devices:Object.fromEntries(a)}},hass_web_proxy:await EE(CE,e)},...n&&{config:n}}})(this.hass,this.deviceRegistryManager,this.rawConfig)}shouldUpdate(){return!!this._diagnostics||(this._fetchDiagnostics().then((()=>this.requestUpdate())),!1)}render(){return rS({message:N_("error.diagnostics"),type:"diagnostics",icon:"mdi:information",context:this._diagnostics})}static get styles(){return s(pE)}};e([he({attribute:!1})],$E.prototype,"hass",void 0),e([he({attribute:!1})],$E.prototype,"deviceRegistryManager",void 0),e([he({attribute:!1})],$E.prototype,"rawConfig",void 0),e([pe()],$E.prototype,"_diagnostics",void 0),$E=e([le("frigate-card-diagnostics")],$E);let AE=class extends oe{willUpdate(e){if(e.has("viewManagerEpoch")||e.has("config")){const e=this.viewManagerEpoch?.manager.getView();(e?.is("live")||this._shouldLivePreload())&&import("./index-dd357256.js"),e?.isGalleryView()?import("./gallery-f478918c.js"):e?.isViewerView()?import("./index-befc50c0.js"):e?.is("image")?import("./image-04d4df35.js"):e?.is("timeline")&&import("./timeline-b24153cf.js")}e.has("hide")&&(this.hide?this.setAttribute("hidden",""):this.removeAttribute("hidden"))}shouldUpdate(e){return!0}_shouldLivePreload(){const e=this.viewManagerEpoch?.manager.getView();return!!this.overriddenConfig?.live.preload&&!e?.is("diagnostics")}render(){if(!(this.hass&&this.overriddenConfig&&this.nonOverriddenConfig&&this.cardWideConfig))return q``;const e=this.viewManagerEpoch?.manager.getView(),t={hidden:this._shouldLivePreload()&&!e?.is("live")},n={hidden:!!this.hide},i=e?.is("live")?this.overriddenConfig.live.controls.thumbnails:e?.isViewerView()?this.overriddenConfig.media_viewer.controls.thumbnails:e?.is("timeline")?this.overriddenConfig.timeline.controls.thumbnails:void 0,a=e?.is("live")?this.overriddenConfig.live.controls.timeline:e?.isViewerView()?this.overriddenConfig.media_viewer.controls.timeline:void 0,r=e?this.cameraManager?.getStore().getCameraConfig(e.camera)??null:null;return q` <frigate-card-surround
class="${_e(n)}"
.hass=${this.hass}
.viewManagerEpoch=${this.viewManagerEpoch}
.thumbnailConfig=${this.hide?void 0:i}
.timelineConfig=${this.hide?void 0:a}
.cameraManager=${this.cameraManager}
.cardWideConfig=${this.cardWideConfig}
>
${!this.hide&&e?.is("image")&&r?q` <frigate-card-image
.imageConfig=${this.overriddenConfig.image}
.view=${e}
.hass=${this.hass}
.cameraConfig=${r}
.cameraManager=${this.cameraManager}
>
</frigate-card-image>`:""}
${!this.hide&&e?.isGalleryView()?q` <frigate-card-gallery
.hass=${this.hass}
.viewManagerEpoch=${this.viewManagerEpoch}
.galleryConfig=${this.overriddenConfig.media_gallery}
.cameraManager=${this.cameraManager}
.cardWideConfig=${this.cardWideConfig}
>
</frigate-card-gallery>`:""}
${!this.hide&&e?.isViewerView()?q`
<frigate-card-viewer
.hass=${this.hass}
.viewManagerEpoch=${this.viewManagerEpoch}
.viewerConfig=${this.overriddenConfig.media_viewer}
.resolvedMediaCache=${this.resolvedMediaCache}
.cameraManager=${this.cameraManager}
.cardWideConfig=${this.cardWideConfig}
>
</frigate-card-viewer>
`:""}
${!this.hide&&e?.is("timeline")?q` <frigate-card-timeline
.hass=${this.hass}
.viewManagerEpoch=${this.viewManagerEpoch}
.timelineConfig=${this.overriddenConfig.timeline}
.cameraManager=${this.cameraManager}
.cardWideConfig=${this.cardWideConfig}
>
</frigate-card-timeline>`:""}
${!this.hide&&e?.is("diagnostics")?q` <frigate-card-diagnostics
.hass=${this.hass}
.rawConfig=${this.rawConfig}
.deviceRegistryManager=${this.deviceRegistryManager}
>
</frigate-card-diagnostics>`:""}
${this._shouldLivePreload()||!this.hide&&e?.is("live")?q`
<frigate-card-live
.hass=${this.hass}
.viewManagerEpoch=${this.viewManagerEpoch}
.nonOverriddenLiveConfig=${this.nonOverriddenConfig.live}
.overriddenLiveConfig=${this.overriddenConfig.live}
.conditionsManagerEpoch=${this.conditionsManagerEpoch}
.overrides=${this.overriddenConfig.overrides}
.cameraManager=${this.cameraManager}
.cardWideConfig=${this.cardWideConfig}
.microphoneManager=${this.microphoneManager}
.triggeredCameraIDs=${this.triggeredCameraIDs}
class="${_e(t)}"
>
</frigate-card-live>
`:""}
</frigate-card-surround>`}static get styles(){return s(":host {\n width: 100%;\n height: 100%;\n display: block;\n}\n\n:host([hidden]),\n.hidden {\n display: none;\n}")}};e([he({attribute:!1})],AE.prototype,"hass",void 0),e([he({attribute:!1})],AE.prototype,"viewManagerEpoch",void 0),e([he({attribute:!1})],AE.prototype,"cameraManager",void 0),e([he({attribute:!1})],AE.prototype,"nonOverriddenConfig",void 0),e([he({attribute:!1})],AE.prototype,"overriddenConfig",void 0),e([he({attribute:!1})],AE.prototype,"cardWideConfig",void 0),e([he({attribute:!1})],AE.prototype,"rawConfig",void 0),e([he({attribute:!1})],AE.prototype,"resolvedMediaCache",void 0),e([he({attribute:!1})],AE.prototype,"conditionsManagerEpoch",void 0),e([he({attribute:!1})],AE.prototype,"hide",void 0),e([he({attribute:!1})],AE.prototype,"microphoneManager",void 0),e([he({attribute:!1})],AE.prototype,"triggeredCameraIDs",void 0),e([he({attribute:!1})],AE.prototype,"deviceRegistryManager",void 0),AE=e([le("frigate-card-views")],AE);console.info(`%c FRIGATE-HASS-CARD \n%c ${N_("common.version")} 6.1.2`,"color: pink; font-weight: bold; background: black","color: white; font-weight: bold; background: dimgray"),window.customCards=window.customCards||[],window.customCards.push({type:"frigate-card",name:N_("common.frigate_card"),description:N_("common.frigate_card_description"),preview:!0,documentationURL:"https://github.com/dermotduffy/frigate-hass-card"});let IE=class extends oe{constructor(){super(...arguments),this._controller=new ux(this,(()=>this._refMain.value?.scroll({top:0})),(()=>this._refMenu.value?.toggleMenu()),this._requestUpdateForComponentsThatUseConditions.bind(this)),this._menuButtonController=new hx,this._refMenu=Ie(),this._refOverlay=Ie(),this._refMain=Ie(),this._refElements=Ie(),this._refViews=Ie()}get _config(){return this._controller.getConfigManager().getConfig()}get _hass(){return this._controller.getHASSManager().getHASS()}set hass(e){this._controller.getHASSManager().setHASS(e),this._refMenu.value&&(this._refMenu.value.hass=e),this._refElements.value&&(this._refElements.value.hass=e),this._refViews.value&&(this._refViews.value.hass=e)}static async getConfigElement(){return await ux.getConfigElement()}static getStubConfig(e,t){return ux.getStubConfig(t)}_requestUpdateForComponentsThatUseConditions(){this._refViews.value&&(this._refViews.value.conditionsManagerEpoch=this._controller.getConditionsManager().getEpoch()??void 0),this._refElements.value&&(this._refElements.value.conditionsManagerEpoch=this._controller.getConditionsManager().getEpoch()??void 0)}setConfig(e){this._controller.getConfigManager().setConfig(e)}shouldUpdate(){return!!this.isConnected&&(this._controller.getMessageManager().hasMessage()||this._controller.getInitializationManager().isInitializedMandatory()||this._controller.getInitializationManager().initializeMandatory(),!0)}_renderMenuStatusContainer(e){if(!this._config)return;const t=this._config.menu.style,n=this._config.menu.position,i=this._config.status_bar.style,a=this._config.status_bar.position;if("none"===t&&"none"===i||"overlay"===e&&"outside"===t&&"outside"===i||"overlay"!==e&&("outside"!==t||n!==e)&&("outside"!==i||a!==e))return;const r=e=>{const r="none"!==t&&("outside"===t&&"outerlay"===e||"outside"!==t&&"overlay"===e),s="none"!==i&&("outside"===i&&"outerlay"===e||"outside"!==i&&"overlay"===e),o="left"===n||"right"===n||"bottom"===n&&"hidden"===t&&"popup"!==i||"top"===n&&("hidden"!==t||"popup"===i);return q`
${r&&o?this._renderMenu(n):""}
${s?this._renderStatusBar(a):""}
${r&&!o?this._renderMenu(n):""}
`};return q`
${"overlay"===e?q`<frigate-card-overlay>${r("overlay")}</frigate-card-overlay>`:q`<div class="outerlay" data-position="${e}">
${r("outerlay")}
</div>`}
`}_renderMenu(e){const t=this._controller.getViewManager().getView();if(this._hass&&this._config)return q`
<frigate-card-menu
${je(this._refMenu)}
slot=${ye(e)}
.hass=${this._hass}
.menuConfig=${this._config.menu}
.buttons=${this._menuButtonController.calculateButtons(this._hass,this._config,this._controller.getCameraManager(),{inExpandedMode:this._controller.getExpandManager().isExpanded(),inFullscreenMode:this._controller.getFullscreenManager().isInFullscreen(),currentMediaLoadedInfo:this._controller.getMediaLoadedInfoManager().get(),showCameraUIButton:this._controller.getCameraURLManager().hasCameraURL(),mediaPlayerController:this._controller.getMediaPlayerManager(),microphoneManager:this._controller.getMicrophoneManager(),view:t,viewManager:this._controller.getViewManager()})}
.entityRegistryManager=${this._controller.getEntityRegistryManager()}
></frigate-card-menu>
`}_renderStatusBar(e){if(this._config)return q`
<frigate-card-status-bar
slot=${ye(e)}
.items=${this._controller.getStatusBarItemManager().calculateItems({statusConfig:this._config.status_bar,cameraManager:this._controller.getCameraManager(),view:this._controller.getViewManager().getView(),mediaLoadedInfo:this._controller.getMediaLoadedInfoManager().get()})}
.config=${this._config.status_bar}
></frigate-card-status-bar>
`}updated(){this._controller.getInitializationManager().isInitializedMandatory()&&this._controller.getQueryStringManager().executeIfNecessary()}_renderInDialogIfNecessary(e){return this._controller.getExpandManager().isExpanded()?q` <web-dialog
open
center
@close=${()=>{this._controller.getExpandManager().setExpanded(!1)}}
>
${e}
</web-dialog>`:e}render(){if(!this._hass)return;const e={main:!0,"curve-top":"outside"!==this._config?.menu.style||"top"!==this._config?.menu.position,"curve-bottom":"outside"!==this._config?.menu.style||"top"===this._config?.menu.position},t=this._controller.getActionsManager().getMergedActions(),n=this._controller.getCameraManager(),i=!1!==this._config?.performance?.features.animated_progress_indicator&&!this._controller.getInitializationManager().wasEverInitialized()&&!this._controller.getMessageManager().hasMessage();return this._renderInDialogIfNecessary(q` <ha-card
id="ha-card"
.actionHandler=${Cf({hasHold:yf(t.hold_action),hasDoubleClick:yf(t.double_tap_action)})}
style="${Re(this._controller.getStyleManager().getAspectRatioStyle())}"
@frigate-card:message=${e=>this._controller.getMessageManager().setMessageIfHigherPriority(e.detail)}
@frigate-card:media:loaded=${e=>this._controller.getMediaLoadedInfoManager().set(e.detail)}
@frigate-card:media:unloaded=${()=>this._controller.getMediaLoadedInfoManager().clear()}
@frigate-card:media:volumechange=${()=>this.requestUpdate()}
@frigate-card:media:play=${()=>this.requestUpdate()}
@frigate-card:media:pause=${()=>this.requestUpdate()}
@frigate-card:focus=${()=>this.focus()}
>
${i?q`<frigate-card-loading></frigate-card-loading>`:""}
${this._renderMenuStatusContainer("top")}
${this._renderMenuStatusContainer("overlay")}
<div ${je(this._refMain)} class="${_e(e)}">
<frigate-card-views
${je(this._refViews)}
.hass=${this._hass}
.viewManagerEpoch=${this._controller.getViewManager().getEpoch()}
.cameraManager=${n}
.resolvedMediaCache=${this._controller.getResolvedMediaCache()}
.nonOverriddenConfig=${this._controller.getConfigManager().getNonOverriddenConfig()}
.overriddenConfig=${this._controller.getConfigManager().getConfig()}
.cardWideConfig=${this._controller.getConfigManager().getCardWideConfig()}
.rawConfig=${this._controller.getConfigManager().getRawConfig()}
.configManager=${this._controller.getConfigManager()}
.conditionsManagerEpoch=${this._controller.getConditionsManager()?.getEpoch()}
.hide=${!!this._controller.getMessageManager().hasMessage()}
.microphoneManager=${this._controller.getMicrophoneManager()}
.triggeredCameraIDs=${this._config?.view.triggers.show_trigger_status?this._controller.getTriggersManager().getTriggeredCameraIDs():void 0}
.deviceRegistryManager=${this._controller.getDeviceRegistryManager()}
></frigate-card-views>
${rS(this._controller.getMessageManager().getMessage())}
</div>
${this._renderMenuStatusContainer("bottom")}
${this._config?.elements?q` <frigate-card-elements
${je(this._refElements)}
.hass=${this._hass}
.elements=${this._config?.elements}
.conditionsManagerEpoch=${this._controller.getConditionsManager()?.getEpoch()}
@frigate-card:menu:add=${e=>{this._menuButtonController.addDynamicMenuButton(e.detail),this.requestUpdate()}}
@frigate-card:menu:remove=${e=>{this._menuButtonController.removeDynamicMenuButton(e.detail),this.requestUpdate()}}
@frigate-card:status-bar:add=${e=>{this._controller.getStatusBarItemManager().addDynamicStatusBarItem(e.detail)}}
@frigate-card:status-bar:remove=${e=>{this._controller.getStatusBarItemManager().removeDynamicStatusBarItem(e.detail)}}
@frigate-card:conditions:evaluate=${e=>{e.evaluation=this._controller.getConditionsManager()?.evaluateConditions(e.conditions)}}
>
</frigate-card-elements>`:""}
</ha-card>`)}static get styles(){return s(':host {\n display: block;\n position: relative;\n background-color: var(--card-background-color);\n border-radius: var(--ha-card-border-radius, 4px);\n height: var(--frigate-card-height);\n min-height: 100px;\n pointer-events: all;\n --frigate-card-expand-max-height: calc((100vh - (2 * 56px)) * 0.85);\n --frigate-card-expand-max-width: 85vw;\n --frigate-card-expand-width: none;\n --frigate-card-expand-height: none;\n --frigate-card-expand-aspect-ratio: unset;\n --frigate-card-height: auto;\n}\n\nfrigate-card-loading {\n position: absolute;\n inset: 0;\n z-index: 1;\n}\n\n:host([dark]) {\n filter: brightness(75%);\n}\n\n:host([panel]:not([casted])) {\n height: calc(100vh - var(--header-height));\n}\n\n:host([panel][casted]) {\n height: 100%;\n}\n\ndiv.main {\n position: relative;\n overflow: auto;\n width: 100%;\n height: 100%;\n margin: auto;\n display: block;\n transform: translateZ(0);\n scrollbar-width: none;\n -ms-overflow-style: none;\n}\n\n/* Hide scrollbar for Chrome, Safari and Opera */\ndiv.main::-webkit-scrollbar {\n display: none;\n}\n\ndiv.main.curve-top {\n border-top-left-radius: var(--ha-card-border-radius, 4px);\n border-top-right-radius: var(--ha-card-border-radius, 4px);\n}\n\ndiv.main.curve-bottom {\n border-bottom-left-radius: var(--ha-card-border-radius, 4px);\n border-bottom-right-radius: var(--ha-card-border-radius, 4px);\n}\n\nha-card {\n display: flex;\n flex-direction: column;\n margin: auto;\n border: 0px;\n overflow: visible;\n width: 100%;\n height: 100%;\n position: static;\n color: var(--secondary-text-color, white);\n}\n\n/************\n * Fullscreen\n *************/\n:host(:fullscreen) #ha-card {\n border-radius: 0px;\n box-shadow: none;\n margin: 0;\n}\n\n:host(:-webkit-full-screen) #ha-card {\n border-radius: 0px;\n box-shadow: none;\n margin: 0;\n}\n\n:host(:fullscreen) div.main,\n:host(:fullscreen) frigate-card-menu {\n border-radius: 0px;\n}\n\n:host(:-webkit-full-screen) div.main,\n:host(:-webkit-full-screen) frigate-card-menu {\n border-radius: 0px;\n}\n\n/***************\n * Expanded mode\n ***************/\nweb-dialog {\n --dialog-padding: 0px;\n --dialog-container-padding: 0px;\n --dialog-max-height: var(--frigate-card-expand-max-height);\n --dialog-max-width: var(--frigate-card-expand-max-width);\n --dialog-width: var(--frigate-card-expand-width);\n --dialog-height: var(--frigate-card-expand-height);\n --dialog-overflow-x: visible;\n --dialog-overflow-y: visible;\n max-height: 100vh;\n}\n\nweb-dialog::part(dialog) {\n aspect-ratio: var(--frigate-card-expand-aspect-ratio);\n border-radius: 0px;\n background: transparent;\n}\n\n/*************************************\n * "Outside" style for menu/status bar\n *************************************/\n.outerlay[data-position=top] > *:first-child {\n border-top-left-radius: var(--ha-card-border-radius, 4px);\n border-top-right-radius: var(--ha-card-border-radius, 4px);\n}\n\n.outerlay[data-position=bottom] > *:last-child {\n border-bottom-left-radius: var(--ha-card-border-radius, 4px);\n border-bottom-right-radius: var(--ha-card-border-radius, 4px);\n}\n\n/*******************\n * Menu hover styles\n *******************/\nfrigate-card-menu {\n z-index: 2;\n}\n\nfrigate-card-menu[data-style*=hover] {\n transition: opacity 0.5s ease;\n opacity: 0;\n}\n\nfrigate-card-menu[data-style*=hover]:hover,\nha-card:hover > frigate-card-overlay > frigate-card-menu[data-style=hover-card] {\n opacity: 1;\n}\n\n/*************************\n * Status bar hover styles\n *************************/\nfrigate-card-status-bar {\n z-index: 1;\n}\n\nfrigate-card-status-bar[data-style*=hover] {\n transition: opacity 0.5s ease;\n opacity: 0;\n}\n\nfrigate-card-status-bar[data-style*=hover]:hover,\nha-card:hover > frigate-card-overlay > frigate-card-status-bar[data-style=hover-card] {\n opacity: 1;\n}')}getCardSize(){return 6}};IE=e([le("frigate-card")],IE);export{Al as $,Ja as A,er as B,Ua as C,tr as D,nr as E,ir as F,Da as G,Ra as H,Pa as I,